moved imv_manager to libtnccs
[strongswan.git] / src / libcharon / 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 #ifdef USE_TNC
27
28 #include "tnccs.h"
29
30 #include <imv/imv_recommendations.h>
31
32 /**
33 * The TNCCS manager manages all TNCCS implementations and creates instances.
34 *
35 * A plugin registers its implemented TNCCS protocol with the manager by
36 * providing type and a constructor function. The manager then creates
37 * TNCCS protocol instances via the provided constructor.
38 */
39 struct tnccs_manager_t {
40
41 /**
42 * Register a TNCCS protocol implementation.
43 *
44 * @param type TNCCS protocol type
45 * @param constructor constructor, returns a TNCCS protocol implementation
46 */
47 void (*add_method)(tnccs_manager_t *this, tnccs_type_t type,
48 tnccs_constructor_t constructor);
49
50 /**
51 * Unregister a TNCCS protocol implementation using it's constructor.
52 *
53 * @param constructor constructor function to remove, as added in add_method
54 */
55 void (*remove_method)(tnccs_manager_t *this, tnccs_constructor_t constructor);
56
57 /**
58 * Create a new TNCCS protocol instance.
59 *
60 * @param type type of the TNCCS protocol
61 * @param is_server TRUE if TNC Server, FALSE if TNC Client
62 * @return TNCCS protocol instance, NULL if no constructor found
63 */
64 tnccs_t* (*create_instance)(tnccs_manager_t *this, tnccs_type_t type,
65 bool is_server);
66
67 /**
68 * Create a TNCCS connection and assign a unique connection ID as well a
69 * callback function for adding a message to a TNCCS batch and create
70 * an empty set for collecting IMV recommendations
71 *
72 * @param tnccs TNCCS connection instance
73 * @param send_message TNCCS callback function
74 * @param request_handshake_retry pointer to boolean variable
75 * @param recs pointer to IMV recommendation set
76 * @return assigned connection ID
77 */
78 TNC_ConnectionID (*create_connection)(tnccs_manager_t *this, tnccs_t *tnccs,
79 tnccs_send_message_t send_message,
80 bool *request_handshake_retry,
81 recommendations_t **recs);
82
83 /**
84 * Remove a TNCCS connection using its connection ID.
85 *
86 * @param id ID of the connection to be removed
87 * @param is_server TNC Server if TRUE, TNC Client if FALSE
88 */
89 void (*remove_connection)(tnccs_manager_t *this, TNC_ConnectionID id,
90 bool is_server);
91
92 /**
93 * Request a handshake retry
94 *
95 * @param is_imc TRUE if IMC, FALSE if IMV
96 * @param imcv_id ID of IMC or IMV requesting the retry
97 * @param id ID of a specific connection or any connection
98 * @param reason reason for the handshake retry
99 * @return return code
100 */
101 TNC_Result (*request_handshake_retry)(tnccs_manager_t *this, bool is_imc,
102 TNC_UInt32 imcv_id,
103 TNC_ConnectionID id,
104 TNC_RetryReason reason);
105
106 /**
107 * Add an IMC/IMV message to the batch of a given connection ID.
108 *
109 * @param imc_id ID of IMC or TNC_IMCID_ANY
110 * @param imv_id ID of IMV or TNC_IMVID_ANY
111 * @param id ID of target connection
112 * @param msg message to be added
113 * @param msg_len message length
114 * @param msg_type message type
115 * @return return code
116 */
117 TNC_Result (*send_message)(tnccs_manager_t *this, TNC_IMCID imc_id,
118 TNC_IMVID imv_id,
119 TNC_ConnectionID id,
120 TNC_BufferReference msg,
121 TNC_UInt32 msg_len,
122 TNC_MessageType msg_type);
123
124 /**
125 * Deliver an IMV Action Recommendation and IMV Evaluation Result to the TNCS
126 *
127 * @param imv_id ID of the IMV providing the recommendation
128 * @param id ID of target connection
129 * @param rec action recommendation
130 * @param eval evaluation result
131 * @return return code
132 */
133 TNC_Result (*provide_recommendation)(tnccs_manager_t *this,
134 TNC_IMVID imv_id,
135 TNC_ConnectionID id,
136 TNC_IMV_Action_Recommendation rec,
137 TNC_IMV_Evaluation_Result eval);
138
139 /**
140 * Get the value of an attribute associated with a connection or with the
141 * TNCS as a whole.
142 *
143 * @param imv_id ID of the IMV requesting the attribute
144 * @param id ID of target connection
145 * @param attribute_id ID of the requested attribute
146 * @param buffer_len length of the buffer in bytes
147 * @param buffer pointer to the buffer
148 * @param out_value_len actual length of the returned attribute
149 * @return return code
150 */
151 TNC_Result (*get_attribute)(tnccs_manager_t *this,
152 TNC_IMVID imv_id,
153 TNC_ConnectionID id,
154 TNC_AttributeID attribute_id,
155 TNC_UInt32 buffer_len,
156 TNC_BufferReference buffer,
157 TNC_UInt32 *out_value_len);
158
159 /**
160 * Set the value of an attribute associated with a connection or with the
161 * TNCS as a whole.
162 *
163 * @param imv_id ID of the IMV setting the attribute
164 * @param id ID of target connection
165 * @param attribute_id ID of the attribute to be set
166 * @param buffer_len length of the buffer in bytes
167 * @param buffer pointer to the buffer
168 * @return return code
169 */
170 TNC_Result (*set_attribute)(tnccs_manager_t *this,
171 TNC_IMVID imv_id,
172 TNC_ConnectionID id,
173 TNC_AttributeID attribute_id,
174 TNC_UInt32 buffer_len,
175 TNC_BufferReference buffer);
176
177 /**
178 * Destroy a tnccs_manager instance.
179 */
180 void (*destroy)(tnccs_manager_t *this);
181 };
182
183 /**
184 * Create a tnccs_manager instance.
185 */
186 tnccs_manager_t *tnccs_manager_create();
187
188 #endif /* USE_TNC */
189
190 #endif /** TNCCS_MANAGER_H_ @}*/