allow registration of multiple message type
[strongswan.git] / src / libimcv / imv / imv_agent.h
1 /*
2 * Copyright (C) 2011-2012 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 *
18 * @defgroup imv_agent_t imv_agent
19 * @{ @ingroup imv_agent
20 */
21
22 #ifndef IMV_AGENT_H_
23 #define IMV_AGENT_H_
24
25 #include "imv_state.h"
26 #include "pa_tnc/pa_tnc_msg.h"
27
28 #include <tncifimv.h>
29 #include <pen/pen.h>
30 #include <utils/linked_list.h>
31
32 #include <library.h>
33
34 typedef struct imv_agent_t imv_agent_t;
35
36 /**
37 * Core functions of an Integrity Measurement Verifier (IMV)
38 */
39 struct imv_agent_t {
40
41 /**
42 * Ask a TNCS to retry an Integrity Check Handshake
43 *
44 * @param imv_id IMV ID assigned by TNCS
45 * @param connection_id network connection ID assigned by TNCS
46 * @param reason IMV retry reason
47 * @return TNC result code
48 */
49 TNC_Result (*request_handshake_retry)(TNC_IMVID imv_id,
50 TNC_ConnectionID connection_id,
51 TNC_RetryReason reason);
52
53 /**
54 * Bind TNCS functions
55 *
56 * @param bind_function function offered by the TNCS
57 * @return TNC result code
58 */
59 TNC_Result (*bind_functions)(imv_agent_t *this,
60 TNC_TNCS_BindFunctionPointer bind_function);
61
62 /**
63 * Create the IMV state for a TNCCS connection instance
64 *
65 * @param state internal IMV state instance
66 * @return TNC result code
67 */
68 TNC_Result (*create_state)(imv_agent_t *this, imv_state_t *state);
69
70 /**
71 * Delete the IMV state for a TNCCS connection instance
72 *
73 * @param connection_id network connection ID assigned by TNCS
74 * @return TNC result code
75 */
76 TNC_Result (*delete_state)(imv_agent_t *this,
77 TNC_ConnectionID connection_id);
78
79 /**
80 * Change the current state of a TNCCS connection
81 *
82 * @param connection_id network connection ID assigned by TNCS
83 * @param new_state new state of TNCCS connection
84 * @param state_p internal IMV state instance [optional argument]
85 * @return TNC result code
86 */
87 TNC_Result (*change_state)(imv_agent_t *this,
88 TNC_ConnectionID connection_id,
89 TNC_ConnectionState new_state,
90 imv_state_t **state_p);
91
92 /**
93 * Get the IMV state for a TNCCS connection instance
94 *
95 * @param connection_id network connection ID assigned by TNCS
96 * @param state internal IMV state instance
97 * @return TRUE if the state was found
98 */
99 bool (*get_state)(imv_agent_t *this,
100 TNC_ConnectionID connection_id, imv_state_t **state);
101
102 /**
103 * Call when a PA-TNC message is to be sent
104 *
105 * @param connection_id network connection ID assigned by TNCS
106 * @param excl exclusive flag
107 * @param src_imv_id IMV ID to be set as source
108 * @param dst_imc_id IMD ID to be set as destination
109 * @param msg_vid message vendor ID
110 * @param msg_subtype message subtype
111 * @param attr_list list of PA-TNC attributes to send
112 * @return TNC result code
113 */
114 TNC_Result (*send_message)(imv_agent_t *this,
115 TNC_ConnectionID connection_id, bool excl,
116 TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id,
117 TNC_VendorID msg_vid,
118 TNC_MessageSubtype msg_subtype,
119 linked_list_t *attr_list);
120
121 /**
122 * Call when a PA-TNC message was received
123 *
124 * @param state state for current connection
125 * @param msg received unparsed message
126 * @param msg_vid message vendorID of the received message
127 * @param msg_subtype message subtype of the received message
128 * @param src_imc_id source IMC ID
129 * @param dst_imv_id destination IMV ID
130 * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
131 * @return TNC result code
132 */
133 TNC_Result (*receive_message)(imv_agent_t *this,
134 imv_state_t *state, chunk_t msg,
135 TNC_VendorID msg_vid,
136 TNC_MessageSubtype msg_subtype,
137 TNC_UInt32 src_imc_id,
138 TNC_UInt32 dst_imv_id,
139 pa_tnc_msg_t **pa_tnc_msg);
140
141 /**
142 * Set Action Recommendation and Evaluation Result in the IMV state
143 *
144 * @param connection_id network connection ID assigned by TNCS
145 * @param rec IMV action recommendation
146 * @param eval IMV evaluation result
147 * @return TNC result code
148 */
149 TNC_Result (*set_recommendation)(imv_agent_t *this,
150 TNC_ConnectionID connection_id,
151 TNC_IMV_Action_Recommendation rec,
152 TNC_IMV_Evaluation_Result eval);
153
154 /**
155 * Deliver IMV Action Recommendation and IMV Evaluation Result to the TNCS
156 *
157 * @param connection_id network connection ID assigned by TNCS
158 * @param dst_imc_id IMD ID to be set as destination
159 * @param msg_vid message vendor ID
160 * @param msg_subtype message subtype
161 * @return TNC result code
162 */
163 TNC_Result (*provide_recommendation)(imv_agent_t *this,
164 TNC_ConnectionID connection_id,
165 TNC_UInt32 dst_imc_id,
166 TNC_VendorID msg_vid,
167 TNC_MessageSubtype msg_subtype);
168
169 /**
170 * Reserve additional IMV IDs from TNCS
171 *
172 * @param count number of additional IMV IDs to be assigned
173 * @return TNC result code
174 */
175 TNC_Result (*reserve_additional_ids)(imv_agent_t *this, int count);
176
177 /**
178 * Return the number of additional IMV IDs assigned by the TNCS
179 *
180 * @return number of additional IMV IDs
181 */
182 int (*count_additional_ids)(imv_agent_t *this);
183
184 /**
185 * Create an enumerator for the additional IMV IDs
186 */
187 enumerator_t* (*create_id_enumerator)(imv_agent_t *this);
188
189 /**
190 * Destroys an imv_agent_t object
191 */
192 void (*destroy)(imv_agent_t *this);
193 };
194
195 /**
196 * Create an imv_agent_t object
197 *
198 * @param name name of the IMV
199 * @param supported_types list of message types registered by the IMV
200 * @param type_count number of registered message types
201 * @param id ID of the IMV as assigned by the TNCS
202 * @param actual_version actual version of the IF-IMV API
203 *
204 */
205 imv_agent_t *imv_agent_create(const char *name,
206 pen_type_t *supported_types, u_int32_t type_count,
207 TNC_IMVID id, TNC_Version *actual_version);
208
209 #endif /** IMV_AGENT_H_ @}*/