34ac3c10939e457419b0d08572d734d8ec7d82f7
[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 attr_list list of PA-TNC attributes to send
110 * @return TNC result code
111 */
112 TNC_Result (*send_message)(imv_agent_t *this,
113 TNC_ConnectionID connection_id, bool excl,
114 TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id,
115 linked_list_t *attr_list);
116
117 /**
118 * Call when a PA-TNC message was received
119 *
120 * @param state state for current connection
121 * @param msg received unparsed message
122 * @param msg_vid message vendorID of the received message
123 * @param msg_subtype message subtype of the received message
124 * @param src_imc_id source IMC ID
125 * @param dst_imv_id destination IMV ID
126 * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
127 * @return TNC result code
128 */
129 TNC_Result (*receive_message)(imv_agent_t *this,
130 imv_state_t *state, chunk_t msg,
131 TNC_VendorID msg_vid,
132 TNC_MessageSubtype msg_subtype,
133 TNC_UInt32 src_imc_id,
134 TNC_UInt32 dst_imv_id,
135 pa_tnc_msg_t **pa_tnc_msg);
136
137 /**
138 * Set Action Recommendation and Evaluation Result in the IMV state
139 *
140 * @param connection_id network connection ID assigned by TNCS
141 * @param rec IMV action recommendation
142 * @param eval IMV evaluation result
143 * @return TNC result code
144 */
145 TNC_Result (*set_recommendation)(imv_agent_t *this,
146 TNC_ConnectionID connection_id,
147 TNC_IMV_Action_Recommendation rec,
148 TNC_IMV_Evaluation_Result eval);
149
150 /**
151 * Deliver IMV Action Recommendation and IMV Evaluation Result to the TNCS
152 *
153 * @param connection_id network connection ID assigned by TNCS
154 * @param dst_imc_id IMD ID to be set as destination
155 * @return TNC result code
156 */
157 TNC_Result (*provide_recommendation)(imv_agent_t *this,
158 TNC_ConnectionID connection_id,
159 TNC_UInt32 dst_imc_id);
160
161 /**
162 * Reserve additional IMV IDs from TNCS
163 *
164 * @param count number of additional IMV IDs to be assigned
165 * @return TNC result code
166 */
167 TNC_Result (*reserve_additional_ids)(imv_agent_t *this, int count);
168
169 /**
170 * Return the number of additional IMV IDs assigned by the TNCS
171 *
172 * @return number of additional IMV IDs
173 */
174 int (*count_additional_ids)(imv_agent_t *this);
175
176 /**
177 * Create an enumerator for the additional IMV IDs
178 */
179 enumerator_t* (*create_id_enumerator)(imv_agent_t *this);
180
181 /**
182 * Destroys an imv_agent_t object
183 */
184 void (*destroy)(imv_agent_t *this);
185 };
186
187 /**
188 * Create an imv_agent_t object
189 *
190 * @param name name of the IMV
191 * @param vendor_id vendor ID of the IMV
192 * @param subtype message subtype of the IMV
193 * @param id ID of the IMV as assigned by the TNCS
194 * @param actual_version actual version of the IF-IMV API
195 *
196 */
197 imv_agent_t *imv_agent_create(const char *name,
198 pen_t vendor_id, u_int32_t subtype,
199 TNC_IMVID id, TNC_Version *actual_version);
200
201 #endif /** IMV_AGENT_H_ @}*/