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