e87450aa646429c211282eaae7c421d4f2f7aba2
[strongswan.git] / src / libimcv / imc / imc_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 imc_agent_t imc_agent
19 * @{ @ingroup imc_agent
20 */
21
22 #ifndef IMC_AGENT_H_
23 #define IMC_AGENT_H_
24
25 #include "imc_state.h"
26 #include "pa_tnc/pa_tnc_msg.h"
27
28 #include <tncifimc.h>
29 #include <pen/pen.h>
30 #include <utils/linked_list.h>
31
32 #include <library.h>
33
34 typedef struct imc_agent_t imc_agent_t;
35
36 /**
37 * Core functions of an Integrity Measurement Verifier (IMC)
38 */
39 struct imc_agent_t {
40
41 /**
42 * Ask a TNCC to retry an Integrity Check Handshake
43 *
44 * @param imc_id IMC ID assigned by TNCC
45 * @param connection_id network connection ID assigned by TNCC
46 * @param reason IMC retry reason
47 * @return TNC result code
48 */
49 TNC_Result (*request_handshake_retry)(TNC_IMCID imc_id,
50 TNC_ConnectionID connection_id,
51 TNC_RetryReason reason);
52
53 /**
54 * Bind TNCC functions
55 *
56 * @param bind_function function offered by the TNCC
57 * @return TNC result code
58 */
59 TNC_Result (*bind_functions)(imc_agent_t *this,
60 TNC_TNCC_BindFunctionPointer bind_function);
61
62 /**
63 * Create the IMC state for a TNCCS connection instance
64 *
65 * @param state internal IMC state instance
66 * @return TNC result code
67 */
68 TNC_Result (*create_state)(imc_agent_t *this, imc_state_t *state);
69
70 /**
71 * Delete the IMC 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)(imc_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 IMC state instance [optional argument]
85 * @return TNC result code
86 */
87 TNC_Result (*change_state)(imc_agent_t *this,
88 TNC_ConnectionID connection_id,
89 TNC_ConnectionState new_state,
90 imc_state_t **state_p);
91
92 /**
93 * Get the IMC state for a TNCCS connection instance
94 *
95 * @param connection_id network connection ID assigned by TNCS
96 * @param state internal IMC state instance
97 * @return TRUE if the state was found
98 */
99 bool (*get_state)(imc_agent_t *this,
100 TNC_ConnectionID connection_id, imc_state_t **state);
101
102 /**
103 * Call when an PA-TNC message is to be sent
104 *
105 * @param connection_id network connection ID assigned by TNCC
106 * @param excl exclusive flag
107 * @param src_imc_id IMC ID to be set as source
108 * @param dst_imv_id IMV 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)(imc_agent_t *this,
113 TNC_ConnectionID connection_id, bool excl,
114 TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_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_imv_id source IMV ID
125 * @param dst_imc_id destination IMC 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)(imc_agent_t *this,
130 imc_state_t *state, chunk_t msg,
131 TNC_VendorID msg_vid,
132 TNC_MessageSubtype msg_subtype,
133 TNC_UInt32 src_imv_id,
134 TNC_UInt32 dst_imc_id,
135 pa_tnc_msg_t **pa_tnc_msg);
136
137 /**
138 * Reserve additional IMC IDs from TNCC
139 *
140 * @param count number of additional IMC IDs to be assigned
141 * @return TNC result code
142 */
143 TNC_Result (*reserve_additional_ids)(imc_agent_t *this, int count);
144
145 /**
146 * Return the number of additional IMC IDs assigned by the TNCC
147 *
148 * @return number of additional IMC IDs
149 */
150 int (*count_additional_ids)(imc_agent_t *this);
151
152 /**
153 * Create an enumerator for the additional IMC IDs
154 */
155 enumerator_t* (*create_id_enumerator)(imc_agent_t *this);
156
157 /**
158 * Destroys an imc_agent_t object
159 */
160 void (*destroy)(imc_agent_t *this);
161 };
162
163 /**
164 * Create an imc_agent_t object
165 *
166 * @param name name of the IMC
167 * @param vendor_id vendor ID of the IMC
168 * @param subtype message subtype of the IMC
169 * @param id ID of the IMC as assigned by the TNCS
170 * @param actual_version actual version of the IF-IMC API
171 *
172 */
173 imc_agent_t *imc_agent_create(const char *name,
174 pen_t vendor_id, u_int32_t subtype,
175 TNC_IMCID id, TNC_Version *actual_version);
176
177 #endif /** IMC_AGENT_H_ @}*/