implemented the RFC 5792 PA-TNC protocol and an example IMC/IMV pair
[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
26 #include <tnc/tncifimv.h>
27 #include <tnc/pen/pen.h>
28 #include <library.h>
29
30 typedef struct imv_agent_t imv_agent_t;
31
32 /**
33 * Core functions of an Integrity Measurement Verifier (IMV)
34 */
35 struct imv_agent_t {
36
37 /**
38 * Ask a TNCS to retry an Integrity Check Handshake
39 *
40 * @param imv_id IMV ID assigned by TNCS
41 * @param connection_id network connection ID assigned by TNCS
42 * @param reason IMV retry reason
43 * @return TNC result code
44 */
45 TNC_Result (*request_handshake_retry)(TNC_IMVID imv_id,
46 TNC_ConnectionID connection_id,
47 TNC_RetryReason reason);
48
49 /**
50 * Get the value of an attribute associated with a connection
51 * or with the TNCS as a whole.
52 *
53 * @param imv_id IMV ID assigned by TNCS
54 * @param connection_id network connection ID assigned by TNCS
55 * @param attribute_id attribute ID
56 * @param buffer_len length of buffer in bytes
57 * @param buffer buffer
58 * @param out_value_len size in bytes of attribute stored in buffer
59 * @return TNC result code
60 */
61 TNC_Result (*get_attribute)(TNC_IMVID imv_id,
62 TNC_ConnectionID connection_id,
63 TNC_AttributeID attribute_id,
64 TNC_UInt32 buffer_len,
65 TNC_BufferReference buffer,
66 TNC_UInt32 *out_value_len);
67
68 /**
69 * Set the value of an attribute associated with a connection
70 * or with the TNCS as a whole.
71 *
72 * @param imv_id IMV ID assigned by TNCS
73 * @param connection_id network connection ID assigned by TNCS
74 * @param attribute_id attribute ID
75 * @param buffer_len length of buffer in bytes
76 * @param buffer buffer
77 * @return TNC result code
78 */
79 TNC_Result (*set_attribute)(TNC_IMVID imv_id,
80 TNC_ConnectionID connection_id,
81 TNC_AttributeID attribute_id,
82 TNC_UInt32 buffer_len,
83 TNC_BufferReference buffer);
84
85 /**
86 * Bind TNCS functions
87 *
88 * @param bind_function function offered by the TNCS
89 * @return TNC result code
90 */
91 TNC_Result (*bind_functions)(imv_agent_t *this,
92 TNC_TNCS_BindFunctionPointer bind_function);
93
94 /**
95 * Create the IMV state for a TNCCS connection instance
96 *
97 * @param state internal IMV state instance
98 * @return TNC result code
99 */
100 TNC_Result (*create_state)(imv_agent_t *this, imv_state_t *state);
101
102 /**
103 * Delete the IMV state for a TNCCS connection instance
104 *
105 * @param connection_id network connection ID assigned by TNCS
106 * @return TNC result code
107 */
108 TNC_Result (*delete_state)(imv_agent_t *this,
109 TNC_ConnectionID connection_id);
110
111 /**
112 * Change the current state of a TNCCS connection
113 *
114 * @param connection_id network connection ID assigned by TNCS
115 * @param new_state new state of TNCCS connection
116 * @return TNC result code
117 */
118 TNC_Result (*change_state)(imv_agent_t *this,
119 TNC_ConnectionID connection_id,
120 TNC_ConnectionState new_state);
121
122 /**
123 * Get the IMV state for a TNCCS connection instance
124 *
125 * @param connection_id network connection ID assigned by TNCS
126 * @param state internal IMV state instance
127 * @return TRUE if the state was found
128 */
129 bool (*get_state)(imv_agent_t *this,
130 TNC_ConnectionID connection_id, imv_state_t **state);
131
132 /**
133 * Call when an IMV-IMC message is to be sent
134 *
135 * @param connection_id network connection ID assigned by TNCS
136 * @param msg message to send
137 * @return TNC result code
138 */
139 TNC_Result (*send_message)(imv_agent_t *this,
140 TNC_ConnectionID connection_id, chunk_t msg);
141
142 /**
143 * Set Action Recommendation and Evaluation Result in the IMV state
144 *
145 # @param connection_id network connection ID assigned by TNCS
146 * @param rec IMV action recommendation
147 * @param eval IMV evaluation result
148 * @return TNC result code
149 */
150 TNC_Result (*set_recommendation)(imv_agent_t *this,
151 TNC_ConnectionID connection_id,
152 TNC_IMV_Action_Recommendation rec,
153 TNC_IMV_Evaluation_Result eval);
154
155 /**
156 * Deliver IMV Action Recommendation and IMV Evaluation Result to the TNCS
157 *
158 # @param connection_id network connection ID assigned by TNCS
159 * @return TNC result code
160 */
161 TNC_Result (*provide_recommendation)(imv_agent_t *this,
162 TNC_ConnectionID connection_id);
163
164 /**
165 * Destroys an imv_agent_t object
166 */
167 void (*destroy)(imv_agent_t *this);
168 };
169
170 /**
171 * Create an imv_agent_t object
172 *
173 * @param name name of the IMV
174 * @param vendor_id vendor ID of the IMV
175 * @param subtype message subtype of the IMV
176 * @param id ID of the IMV as assigned by the TNCS
177 * @param actual_version actual version of the IF-IMV API
178 *
179 */
180 imv_agent_t *imv_agent_create(const char *name,
181 pen_t vendor_id, u_int32_t subtype,
182 TNC_IMVID id, TNC_Version *actual_version);
183
184 #endif /** IMV_AGENT_H_ @}*/