nearly completed PA-TNC error handling
[strongswan.git] / src / libimcv / imv / imv_agent.h
1 /*
2 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 /**
16 *
17 * @defgroup imv_agent_t imv_agent
18 * @{ @ingroup imv_agent
19 */
20
21 #ifndef IMV_AGENT_H_
22 #define IMV_AGENT_H_
23
24 #include "imv_state.h"
25 #include "pa_tnc/pa_tnc_msg.h"
26
27 #include <tncifimv.h>
28 #include <pen/pen.h>
29
30 #include <library.h>
31
32 typedef struct imv_agent_t imv_agent_t;
33
34 /**
35 * Core functions of an Integrity Measurement Verifier (IMV)
36 */
37 struct imv_agent_t {
38
39 /**
40 * Ask a TNCS to retry an Integrity Check Handshake
41 *
42 * @param imv_id IMV ID assigned by TNCS
43 * @param connection_id network connection ID assigned by TNCS
44 * @param reason IMV retry reason
45 * @return TNC result code
46 */
47 TNC_Result (*request_handshake_retry)(TNC_IMVID imv_id,
48 TNC_ConnectionID connection_id,
49 TNC_RetryReason reason);
50
51 /**
52 * Get the value of an attribute associated with a connection
53 * or with the TNCS as a whole.
54 *
55 * @param imv_id IMV ID assigned by TNCS
56 * @param connection_id network connection ID assigned by TNCS
57 * @param attribute_id attribute ID
58 * @param buffer_len length of buffer in bytes
59 * @param buffer buffer
60 * @param out_value_len size in bytes of attribute stored in buffer
61 * @return TNC result code
62 */
63 TNC_Result (*get_attribute)(TNC_IMVID imv_id,
64 TNC_ConnectionID connection_id,
65 TNC_AttributeID attribute_id,
66 TNC_UInt32 buffer_len,
67 TNC_BufferReference buffer,
68 TNC_UInt32 *out_value_len);
69
70 /**
71 * Set the value of an attribute associated with a connection
72 * or with the TNCS as a whole.
73 *
74 * @param imv_id IMV ID assigned by TNCS
75 * @param connection_id network connection ID assigned by TNCS
76 * @param attribute_id attribute ID
77 * @param buffer_len length of buffer in bytes
78 * @param buffer buffer
79 * @return TNC result code
80 */
81 TNC_Result (*set_attribute)(TNC_IMVID imv_id,
82 TNC_ConnectionID connection_id,
83 TNC_AttributeID attribute_id,
84 TNC_UInt32 buffer_len,
85 TNC_BufferReference buffer);
86
87 /**
88 * Bind TNCS functions
89 *
90 * @param bind_function function offered by the TNCS
91 * @return TNC result code
92 */
93 TNC_Result (*bind_functions)(imv_agent_t *this,
94 TNC_TNCS_BindFunctionPointer bind_function);
95
96 /**
97 * Create the IMV state for a TNCCS connection instance
98 *
99 * @param state internal IMV state instance
100 * @return TNC result code
101 */
102 TNC_Result (*create_state)(imv_agent_t *this, imv_state_t *state);
103
104 /**
105 * Delete the IMV state for a TNCCS connection instance
106 *
107 * @param connection_id network connection ID assigned by TNCS
108 * @return TNC result code
109 */
110 TNC_Result (*delete_state)(imv_agent_t *this,
111 TNC_ConnectionID connection_id);
112
113 /**
114 * Change the current state of a TNCCS connection
115 *
116 * @param connection_id network connection ID assigned by TNCS
117 * @param new_state new state of TNCCS connection
118 * @return TNC result code
119 */
120 TNC_Result (*change_state)(imv_agent_t *this,
121 TNC_ConnectionID connection_id,
122 TNC_ConnectionState new_state);
123
124 /**
125 * Get the IMV state for a TNCCS connection instance
126 *
127 * @param connection_id network connection ID assigned by TNCS
128 * @param state internal IMV state instance
129 * @return TRUE if the state was found
130 */
131 bool (*get_state)(imv_agent_t *this,
132 TNC_ConnectionID connection_id, imv_state_t **state);
133
134 /**
135 * Call when a PA-TNC message is to be sent
136 *
137 * @param connection_id network connection ID assigned by TNCS
138 * @param msg message to send
139 * @return TNC result code
140 */
141 TNC_Result (*send_message)(imv_agent_t *this,
142 TNC_ConnectionID connection_id, chunk_t msg);
143
144 /**
145 * Call when a PA-TNC message was received
146 *
147 * @param connection_id network connection ID assigned by TNCS
148 * @param msg received unparsed message
149 * @param msg_type message type of the received message
150 * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
151 * @return TNC result code
152 */
153 TNC_Result (*receive_message)(imv_agent_t *this,
154 TNC_ConnectionID connection_id, chunk_t msg,
155 TNC_MessageType msg_type,
156 pa_tnc_msg_t **pa_tnc_msg);
157
158 /**
159 * Set Action Recommendation and Evaluation Result in the IMV state
160 *
161 # @param connection_id network connection ID assigned by TNCS
162 * @param rec IMV action recommendation
163 * @param eval IMV evaluation result
164 * @return TNC result code
165 */
166 TNC_Result (*set_recommendation)(imv_agent_t *this,
167 TNC_ConnectionID connection_id,
168 TNC_IMV_Action_Recommendation rec,
169 TNC_IMV_Evaluation_Result eval);
170
171 /**
172 * Deliver IMV Action Recommendation and IMV Evaluation Result to the TNCS
173 *
174 # @param connection_id network connection ID assigned by TNCS
175 * @return TNC result code
176 */
177 TNC_Result (*provide_recommendation)(imv_agent_t *this,
178 TNC_ConnectionID connection_id);
179
180 /**
181 * Destroys an imv_agent_t object
182 */
183 void (*destroy)(imv_agent_t *this);
184 };
185
186 /**
187 * Create an imv_agent_t object
188 *
189 * @param name name of the IMV
190 * @param vendor_id vendor ID of the IMV
191 * @param subtype message subtype of the IMV
192 * @param id ID of the IMV as assigned by the TNCS
193 * @param actual_version actual version of the IF-IMV API
194 *
195 */
196 imv_agent_t *imv_agent_create(const char *name,
197 pen_t vendor_id, u_int32_t subtype,
198 TNC_IMVID id, TNC_Version *actual_version);
199
200 #endif /** IMV_AGENT_H_ @}*/