2 * Copyright (C) 2010-2013 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup tnccs_manager tnccs_manager
21 #ifndef TNCCS_MANAGER_H_
22 #define TNCCS_MANAGER_H_
24 typedef struct tnccs_manager_t tnccs_manager_t
;
27 #include "tnc/imv/imv_recommendations.h"
30 * The TNCCS manager manages all TNCCS implementations and creates instances.
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.
36 struct tnccs_manager_t
{
39 * Register a TNCCS protocol implementation.
41 * @param type TNCCS protocol type
42 * @param constructor constructor, returns a TNCCS protocol implementation
44 void (*add_method
)(tnccs_manager_t
*this, tnccs_type_t type
,
45 tnccs_constructor_t constructor
);
48 * Unregister a TNCCS protocol implementation using it's constructor.
50 * @param constructor constructor function to remove, as added in add_method
52 void (*remove_method
)(tnccs_manager_t
*this, tnccs_constructor_t constructor
);
55 * Create a new TNCCS protocol instance.
57 * @param type type of the TNCCS protocol
58 * @param is_server TRUE if TNC Server, FALSE if TNC Client
59 * @param server Server identity
60 * @param peer Client identity
61 * @param transport Underlying TNC IF-T transport protocol used
62 * @param cb Callback function if TNC Server, NULL if TNC Client
63 * @return TNCCS protocol instance, NULL if no constructor found
65 tnccs_t
* (*create_instance
)(tnccs_manager_t
*this, tnccs_type_t type
,
66 bool is_server
, identification_t
*server
,
67 identification_t
*peer
,
68 tnc_ift_type_t transport
, tnccs_cb_t cb
);
71 * Create a TNCCS connection and assign a unique connection ID as well a
72 * callback function for adding a message to a TNCCS batch and create
73 * an empty set for collecting IMV recommendations
75 * @param type TNCCS protocol type
76 * @param tnccs TNCCS connection instance
77 * @param send_message TNCCS callback function
78 * @param request_handshake_retry pointer to boolean variable
79 * @param max_msg_len maximum PA-TNC message size
80 * @param recs pointer to IMV recommendation set
81 * @return assigned connection ID
83 TNC_ConnectionID (*create_connection
)(tnccs_manager_t
*this,
84 tnccs_type_t type
, tnccs_t
*tnccs
,
85 tnccs_send_message_t send_message
,
86 bool *request_handshake_retry
,
87 u_int32_t max_msg_len
,
88 recommendations_t
**recs
);
91 * Remove a TNCCS connection using its connection ID.
93 * @param id ID of the connection to be removed
94 * @param is_server TNC Server if TRUE, TNC Client if FALSE
96 void (*remove_connection
)(tnccs_manager_t
*this, TNC_ConnectionID id
,
100 * Request a handshake retry
102 * @param is_imc TRUE if IMC, FALSE if IMV
103 * @param imcv_id ID of IMC or IMV requesting the retry
104 * @param id ID of a specific connection or any connection
105 * @param reason reason for the handshake retry
106 * @return return code
108 TNC_Result (*request_handshake_retry
)(tnccs_manager_t
*this, bool is_imc
,
111 TNC_RetryReason reason
);
114 * Add an IMC/IMV message to the batch of a given connection ID.
116 * @param imc_id ID of IMC or TNC_IMCID_ANY
117 * @param imv_id ID of IMV or TNC_IMVID_ANY
118 * @param id ID of target connection
119 * @param msg_flags message flags
120 * @param msg message to be added
121 * @param msg_len message length
122 * @param msg_vid message vendor ID
123 * @param msg_subtype message subtype
124 * @return return code
126 TNC_Result (*send_message
)(tnccs_manager_t
*this,
130 TNC_UInt32 msg_flags
,
131 TNC_BufferReference msg
,
133 TNC_VendorID msg_vid
,
134 TNC_MessageSubtype msg_subtype
);
137 * Deliver an IMV Action Recommendation and IMV Evaluation Result to the TNCS
139 * @param imv_id ID of the IMV providing the recommendation
140 * @param id ID of target connection
141 * @param rec action recommendation
142 * @param eval evaluation result
143 * @return return code
145 TNC_Result (*provide_recommendation
)(tnccs_manager_t
*this,
148 TNC_IMV_Action_Recommendation rec
,
149 TNC_IMV_Evaluation_Result eval
);
152 * Get the value of an attribute associated with a connection or with the
155 * @param is_imc TRUE if IMC, FALSE if IMV
156 * @param imcv_id ID of the IMC/IMV requesting the attribute
157 * @param id ID of target connection
158 * @param attribute_id ID of the requested attribute
159 * @param buffer_len length of the buffer in bytes
160 * @param buffer pointer to the buffer
161 * @param value_len actual length of the returned attribute
162 * @return return code
164 TNC_Result (*get_attribute
)(tnccs_manager_t
*this, bool is_imc
,
167 TNC_AttributeID attribute_id
,
168 TNC_UInt32 buffer_len
,
169 TNC_BufferReference buffer
,
170 TNC_UInt32
*value_len
);
173 * Set the value of an attribute associated with a connection or with the
176 * @param is_imc TRUE if IMC, FALSE if IMV
177 * @param imcv_id ID of the IMC/IMV setting the attribute
178 * @param id ID of target connection
179 * @param attribute_id ID of the attribute to be set
180 * @param buffer_len length of the buffer in bytes
181 * @param buffer pointer to the buffer
182 * @return return code
184 TNC_Result (*set_attribute
)(tnccs_manager_t
*this, bool is_imc
,
187 TNC_AttributeID attribute_id
,
188 TNC_UInt32 buffer_len
,
189 TNC_BufferReference buffer
);
192 * Destroy a tnccs_manager instance.
194 void (*destroy
)(tnccs_manager_t
*this);
198 * Helper function to (un-)register TNCCS methods from plugin features.
200 * This function is a plugin_feature_callback_t and can be used with the
201 * PLUGIN_CALLBACK macro to register a TNCCS method constructor.
203 * @param plugin plugin registering the TNCCS method constructor
204 * @param feature associated plugin feature
205 * @param reg TRUE to register, FALSE to unregister.
206 * @param data data passed to callback, a tnccs_constructor_t
208 bool tnccs_method_register(plugin_t
*plugin
, plugin_feature_t
*feature
,
209 bool reg
, void *data
);
211 #endif /** TNCCS_MANAGER_H_ @}*/