implemented IF-IMC/IMV 1.3 attributes
[strongswan.git] / src / libtnccs / tnc / tnccs / tnccs_manager.h
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup tnccs_manager tnccs_manager
18 * @{ @ingroup tnccs
19 */
20
21 #ifndef TNCCS_MANAGER_H_
22 #define TNCCS_MANAGER_H_
23
24 typedef struct tnccs_manager_t tnccs_manager_t;
25
26 #include "tnccs.h"
27 #include "tnc/imv/imv_recommendations.h"
28
29 /**
30 * The TNCCS manager manages all TNCCS implementations and creates instances.
31 *
32 * A plugin registers its implemented TNCCS protocol with the manager by
33 * providing type and a constructor function. The manager then creates
34 * TNCCS protocol instances via the provided constructor.
35 */
36 struct tnccs_manager_t {
37
38 /**
39 * Register a TNCCS protocol implementation.
40 *
41 * @param type TNCCS protocol type
42 * @param constructor constructor, returns a TNCCS protocol implementation
43 */
44 void (*add_method)(tnccs_manager_t *this, tnccs_type_t type,
45 tnccs_constructor_t constructor);
46
47 /**
48 * Unregister a TNCCS protocol implementation using it's constructor.
49 *
50 * @param constructor constructor function to remove, as added in add_method
51 */
52 void (*remove_method)(tnccs_manager_t *this, tnccs_constructor_t constructor);
53
54 /**
55 * Create a new TNCCS protocol instance.
56 *
57 * @param type type of the TNCCS protocol
58 * @param is_server TRUE if TNC Server, FALSE if TNC Client
59 * @return TNCCS protocol instance, NULL if no constructor found
60 */
61 tnccs_t* (*create_instance)(tnccs_manager_t *this, tnccs_type_t type,
62 bool is_server);
63
64 /**
65 * Create a TNCCS connection and assign a unique connection ID as well a
66 * callback function for adding a message to a TNCCS batch and create
67 * an empty set for collecting IMV recommendations
68 *
69 * @param type TNCCS protocol type
70 * @param tnccs TNCCS connection instance
71 * @param send_message TNCCS callback function
72 * @param request_handshake_retry pointer to boolean variable
73 * @param recs pointer to IMV recommendation set
74 * @return assigned connection ID
75 */
76 TNC_ConnectionID (*create_connection)(tnccs_manager_t *this,
77 tnccs_type_t type, tnccs_t *tnccs,
78 tnccs_send_message_t send_message,
79 bool *request_handshake_retry,
80 recommendations_t **recs);
81
82 /**
83 * Remove a TNCCS connection using its connection ID.
84 *
85 * @param id ID of the connection to be removed
86 * @param is_server TNC Server if TRUE, TNC Client if FALSE
87 */
88 void (*remove_connection)(tnccs_manager_t *this, TNC_ConnectionID id,
89 bool is_server);
90
91 /**
92 * Request a handshake retry
93 *
94 * @param is_imc TRUE if IMC, FALSE if IMV
95 * @param imcv_id ID of IMC or IMV requesting the retry
96 * @param id ID of a specific connection or any connection
97 * @param reason reason for the handshake retry
98 * @return return code
99 */
100 TNC_Result (*request_handshake_retry)(tnccs_manager_t *this, bool is_imc,
101 TNC_UInt32 imcv_id,
102 TNC_ConnectionID id,
103 TNC_RetryReason reason);
104
105 /**
106 * Add an IMC/IMV message to the batch of a given connection ID.
107 *
108 * @param imc_id ID of IMC or TNC_IMCID_ANY
109 * @param imv_id ID of IMV or TNC_IMVID_ANY
110 * @param id ID of target connection
111 * @param msg_flags message flags
112 * @param msg message to be added
113 * @param msg_len message length
114 * @param msg_vid message vendor ID
115 * @param msg_subtype message subtype
116 * @return return code
117 */
118 TNC_Result (*send_message)(tnccs_manager_t *this,
119 TNC_IMCID imc_id,
120 TNC_IMVID imv_id,
121 TNC_ConnectionID id,
122 TNC_UInt32 msg_flags,
123 TNC_BufferReference msg,
124 TNC_UInt32 msg_len,
125 TNC_VendorID msg_vid,
126 TNC_MessageSubtype msg_subtype);
127
128 /**
129 * Deliver an IMV Action Recommendation and IMV Evaluation Result to the TNCS
130 *
131 * @param imv_id ID of the IMV providing the recommendation
132 * @param id ID of target connection
133 * @param rec action recommendation
134 * @param eval evaluation result
135 * @return return code
136 */
137 TNC_Result (*provide_recommendation)(tnccs_manager_t *this,
138 TNC_IMVID imv_id,
139 TNC_ConnectionID id,
140 TNC_IMV_Action_Recommendation rec,
141 TNC_IMV_Evaluation_Result eval);
142
143 /**
144 * Get the value of an attribute associated with a connection or with the
145 * TNCS as a whole.
146 *
147 * @param is_imc TRUE if IMC, FALSE if IMV
148 * @param imcv_id ID of the IMC/IMV requesting the attribute
149 * @param id ID of target connection
150 * @param attribute_id ID of the requested attribute
151 * @param buffer_len length of the buffer in bytes
152 * @param buffer pointer to the buffer
153 * @param value_len actual length of the returned attribute
154 * @return return code
155 */
156 TNC_Result (*get_attribute)(tnccs_manager_t *this, bool is_imc,
157 TNC_UInt32 imcv_id,
158 TNC_ConnectionID id,
159 TNC_AttributeID attribute_id,
160 TNC_UInt32 buffer_len,
161 TNC_BufferReference buffer,
162 TNC_UInt32 *value_len);
163
164 /**
165 * Set the value of an attribute associated with a connection or with the
166 * TNCS as a whole.
167 *
168 * @param is_imc TRUE if IMC, FALSE if IMV
169 * @param imcv_id ID of the IMC/IMV setting the attribute
170 * @param id ID of target connection
171 * @param attribute_id ID of the attribute to be set
172 * @param buffer_len length of the buffer in bytes
173 * @param buffer pointer to the buffer
174 * @return return code
175 */
176 TNC_Result (*set_attribute)(tnccs_manager_t *this, bool is_imc,
177 TNC_UInt32 imcv_id,
178 TNC_ConnectionID id,
179 TNC_AttributeID attribute_id,
180 TNC_UInt32 buffer_len,
181 TNC_BufferReference buffer);
182
183 /**
184 * Destroy a tnccs_manager instance.
185 */
186 void (*destroy)(tnccs_manager_t *this);
187 };
188
189 /**
190 * Helper function to (un-)register TNCCS methods from plugin features.
191 *
192 * This function is a plugin_feature_callback_t and can be used with the
193 * PLUGIN_CALLBACK macro to register a TNCCS method constructor.
194 *
195 * @param plugin plugin registering the TNCCS method constructor
196 * @param feature associated plugin feature
197 * @param reg TRUE to register, FALSE to unregister.
198 * @param data data passed to callback, a tnccs_constructor_t
199 */
200 bool tnccs_method_register(plugin_t *plugin, plugin_feature_t *feature,
201 bool reg, void *data);
202
203 #endif /** TNCCS_MANAGER_H_ @}*/