allow registration of multiple message type
[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 msg_vid message vendor ID
110 * @param msg_subtype message subtype
111 * @param attr_list list of PA-TNC attributes to send
112 * @return TNC result code
113 */
114 TNC_Result (*send_message)(imc_agent_t *this,
115 TNC_ConnectionID connection_id, bool excl,
116 TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
117 TNC_VendorID msg_vid,
118 TNC_MessageSubtype msg_subtype,
119 linked_list_t *attr_list);
120
121 /**
122 * Call when a PA-TNC message was received
123 *
124 * @param state state for current connection
125 * @param msg received unparsed message
126 * @param msg_vid message vendorID of the received message
127 * @param msg_subtype message subtype of the received message
128 * @param src_imv_id source IMV ID
129 * @param dst_imc_id destination IMC ID
130 * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
131 * @return TNC result code
132 */
133 TNC_Result (*receive_message)(imc_agent_t *this,
134 imc_state_t *state, chunk_t msg,
135 TNC_VendorID msg_vid,
136 TNC_MessageSubtype msg_subtype,
137 TNC_UInt32 src_imv_id,
138 TNC_UInt32 dst_imc_id,
139 pa_tnc_msg_t **pa_tnc_msg);
140
141 /**
142 * Reserve additional IMC IDs from TNCC
143 *
144 * @param count number of additional IMC IDs to be assigned
145 * @return TNC result code
146 */
147 TNC_Result (*reserve_additional_ids)(imc_agent_t *this, int count);
148
149 /**
150 * Return the number of additional IMC IDs assigned by the TNCC
151 *
152 * @return number of additional IMC IDs
153 */
154 int (*count_additional_ids)(imc_agent_t *this);
155
156 /**
157 * Create an enumerator for the additional IMC IDs
158 */
159 enumerator_t* (*create_id_enumerator)(imc_agent_t *this);
160
161 /**
162 * Destroys an imc_agent_t object
163 */
164 void (*destroy)(imc_agent_t *this);
165 };
166
167 /**
168 * Create an imc_agent_t object
169 *
170 * @param name name of the IMC
171 * @param supported_types list of message types registered by the IMC
172 * @param type_count number of registered message types
173 * @param id ID of the IMC as assigned by the TNCS
174 * @param actual_version actual version of the IF-IMC API
175 *
176 */
177 imc_agent_t *imc_agent_create(const char *name,
178 pen_type_t *supported_types, u_int32_t type_count,
179 TNC_IMCID id, TNC_Version *actual_version);
180
181 #endif /** IMC_AGENT_H_ @}*/