centralized processing of assessment information
[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 <collections/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 * Call when an IMV-IMC message is to be sent
55 *
56 * @param imv_id IMV ID assigned by TNCS
57 * @param connection_id network connection ID assigned by TNCS
58 * @param msg message to send
59 * @param msg_len message length in bytes
60 * @param msg_type message type
61 * @return TNC result code
62 */
63 TNC_Result (*send_message)(TNC_IMVID imv_id,
64 TNC_ConnectionID connection_id,
65 TNC_BufferReference msg,
66 TNC_UInt32 msg_len,
67 TNC_MessageType msg_type);
68
69 /**
70 * Call when an IMV-IMC message is to be sent with long message types
71 *
72 * @param imv_id IMV ID assigned by TNCS
73 * @param connection_id network connection ID assigned by TNCS
74 * @param msg_flags message flags
75 * @param msg message to send
76 * @param msg_len message length in bytes
77 * @param msg_vid message vendor ID
78 * @param msg_subtype message subtype
79 * @param dst_imc_id destination IMC ID
80 * @return TNC result code
81 */
82 TNC_Result (*send_message_long)(TNC_IMVID imv_id,
83 TNC_ConnectionID connection_id,
84 TNC_UInt32 msg_flags,
85 TNC_BufferReference msg,
86 TNC_UInt32 msg_len,
87 TNC_VendorID msg_vid,
88 TNC_MessageSubtype msg_subtype,
89 TNC_UInt32 dst_imc_id);
90
91 /**
92 * Bind TNCS functions
93 *
94 * @param bind_function function offered by the TNCS
95 * @return TNC result code
96 */
97 TNC_Result (*bind_functions)(imv_agent_t *this,
98 TNC_TNCS_BindFunctionPointer bind_function);
99
100 /**
101 * Create the IMV state for a TNCCS connection instance
102 *
103 * @param state internal IMV state instance
104 * @return TNC result code
105 */
106 TNC_Result (*create_state)(imv_agent_t *this, imv_state_t *state);
107
108 /**
109 * Delete the IMV state for a TNCCS connection instance
110 *
111 * @param connection_id network connection ID assigned by TNCS
112 * @return TNC result code
113 */
114 TNC_Result (*delete_state)(imv_agent_t *this,
115 TNC_ConnectionID connection_id);
116
117 /**
118 * Change the current state of a TNCCS connection
119 *
120 * @param connection_id network connection ID assigned by TNCS
121 * @param new_state new state of TNCCS connection
122 * @param state_p internal IMV state instance [optional argument]
123 * @return TNC result code
124 */
125 TNC_Result (*change_state)(imv_agent_t *this,
126 TNC_ConnectionID connection_id,
127 TNC_ConnectionState new_state,
128 imv_state_t **state_p);
129
130 /**
131 * Get the IMV state for a TNCCS connection instance
132 *
133 * @param connection_id network connection ID assigned by TNCS
134 * @param state internal IMV state instance
135 * @return TRUE if the state was found
136 */
137 bool (*get_state)(imv_agent_t *this,
138 TNC_ConnectionID connection_id, imv_state_t **state);
139
140 /**
141 * Get IMV name
142 *
143 * return IMV name
144 */
145 const char* (*get_name)(imv_agent_t *this);
146
147 /**
148 * Get base IMV ID
149 *
150 * return base IMV ID
151 */
152 TNC_IMVID (*get_id)(imv_agent_t *this);
153
154 /**
155 * Reserve additional IMV IDs from TNCS
156 *
157 * @param count number of additional IMV IDs to be assigned
158 * @return TNC result code
159 */
160 TNC_Result (*reserve_additional_ids)(imv_agent_t *this, int count);
161
162 /**
163 * Return the number of additional IMV IDs assigned by the TNCS
164 *
165 * @return number of additional IMV IDs
166 */
167 int (*count_additional_ids)(imv_agent_t *this);
168
169 /**
170 * Create an enumerator for the additional IMV IDs
171 */
172 enumerator_t* (*create_id_enumerator)(imv_agent_t *this);
173
174 /**
175 * Create a preferred languages enumerator
176 *
177 * @param state of TNCCS connection
178 */
179 enumerator_t* (*create_language_enumerator)(imv_agent_t *this,
180 imv_state_t *state);
181
182 /**
183 * Deliver IMV Action Recommendation and IMV Evaluation Result to the TNCS
184 *
185 * @param state state bound to a connection ID
186 * @return TNC result code
187 */
188 TNC_Result (*provide_recommendation)(imv_agent_t *this, imv_state_t* state);
189
190 /**
191 * Destroys an imv_agent_t object
192 */
193 void (*destroy)(imv_agent_t *this);
194 };
195
196 /**
197 * Create an imv_agent_t object
198 *
199 * @param name name of the IMV
200 * @param supported_types list of message types registered by the IMV
201 * @param type_count number of registered message types
202 * @param id ID of the IMV as assigned by the TNCS
203 * @param actual_version actual version of the IF-IMV API
204 *
205 */
206 imv_agent_t *imv_agent_create(const char *name,
207 pen_type_t *supported_types, u_int32_t type_count,
208 TNC_IMVID id, TNC_Version *actual_version);
209
210 #endif /** IMV_AGENT_H_ @}*/