added TNC_IMC_ReceiveMessageLong() and TNC_IMV_ReceiveMessageLong() support
[strongswan.git] / src / libtnccs / tnc / imc / imc.h
1 /*
2 * Copyright (C) 2010-2011 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 * @defgroup imc imc
18 * @ingroup tnc
19 *
20 * @defgroup imct imc
21 * @{ @ingroup imc
22 */
23
24 #ifndef IMC_H_
25 #define IMC_H_
26
27 #include <tncifimc.h>
28
29 #include <library.h>
30
31 typedef struct imc_t imc_t;
32
33 /**
34 * Controls a single Integrity Measurement Collector (IMC)
35 */
36 struct imc_t {
37
38 /**
39 * The TNC Client calls this function to initialize the IMC and agree on
40 * the API version number to be used. It also supplies the IMC ID, an IMC
41 * identifier that the IMC must use when calling TNC Client callback functions.
42 *
43 * @param imcID IMC ID assigned by TNCC
44 * @param minVersion minimum API version supported by TNCC
45 * @param maxVersion maximum API version supported by TNCC
46 * @param OutActualVersion mutually supported API version number
47 * @return TNC result code
48 */
49 TNC_Result (*initialize)(TNC_IMCID imcID,
50 TNC_Version minVersion,
51 TNC_Version maxVersion,
52 TNC_Version *OutActualVersion);
53
54 /**
55 * The TNC Client calls this function to inform the IMC that the state of
56 * the network connection identified by connectionID has changed to newState.
57 *
58 * @param imcID IMC ID assigned by TNCC
59 * @param connectionID network connection ID assigned by TNCC
60 * @param newState new network connection state
61 * @return TNC result code
62 */
63 TNC_Result (*notify_connection_change)(TNC_IMCID imcID,
64 TNC_ConnectionID connectionID,
65 TNC_ConnectionState newState);
66
67 /**
68 * The TNC Client calls this function to indicate that an Integrity Check
69 * Handshake is beginning and solicit messages from IMCs for the first batch.
70 *
71 * @param imcID IMC ID assigned by TNCC
72 * @param connectionID network connection ID assigned by TNCC
73 * @return TNC result code
74 */
75 TNC_Result (*begin_handshake)(TNC_IMCID imcID,
76 TNC_ConnectionID connectionID);
77
78 /**
79 * The TNC Client calls this function to deliver a message to the IMC.
80 * The message is contained in the buffer referenced by message and contains
81 * the number of octets indicated by messageLength. The type of the message
82 * is indicated by messageType.
83 *
84 * @param imcID IMC ID assigned by TNCS
85 * @param connectionID network connection ID assigned by TNCC
86 * @param message reference to buffer containing message
87 * @param messageLength number of octets in message
88 * @param messageType message type of message
89 * @return TNC result code
90 */
91 TNC_Result (*receive_message)(TNC_IMCID imcID,
92 TNC_ConnectionID connectionID,
93 TNC_BufferReference message,
94 TNC_UInt32 messageLength,
95 TNC_MessageType messageType);
96
97 /**
98 * The TNC Client calls this function to deliver a message to the IMC.
99 * The message is contained in the buffer referenced by message and contains
100 * the number of octets indicated by messageLength. The type of the message
101 * is indicated by the message Vendor ID and message subtype.
102 *
103 * @param imcID IMC ID assigned by TNCS
104 * @param connectionID network connection ID assigned by TNCC
105 * @param messageFlags message flags
106 * @param message reference to buffer containing message
107 * @param messageLength number of octets in message
108 * @param messageVendorID message Vendor ID
109 * @param messageSubtype message subtype
110 * @param sourceIMVID source IMV ID
111 * @param destinationIMCID destination IMC ID
112 * @return TNC result code
113 */
114 TNC_Result (*receive_message_long)(TNC_IMCID imcID,
115 TNC_ConnectionID connectionID,
116 TNC_UInt32 messageFlags,
117 TNC_BufferReference message,
118 TNC_UInt32 messageLength,
119 TNC_VendorID messageVendorID,
120 TNC_MessageSubtype messageSubtype,
121 TNC_UInt32 sourceIMVID,
122 TNC_UInt32 destinationIMCID);
123
124 /**
125 * The TNC Client calls this function to notify IMCs that all IMV messages
126 * received in a batch have been delivered and this is the IMC’s last chance
127 * to send a message in the batch of IMC messages currently being collected.
128 *
129 * @param imcID IMC ID assigned by TNCC
130 * @param connectionID network connection ID assigned by TNCC
131 * @return TNC result code
132 */
133 TNC_Result (*batch_ending)(TNC_IMCID imcID,
134 TNC_ConnectionID connectionID);
135
136 /**
137 * The TNC Client calls this function to close down the IMC when all work is
138 * complete or the IMC reports TNC_RESULT_FATAL.
139 *
140 * @param imcID IMC ID assigned by TNCC
141 * @return TNC result code
142 */
143 TNC_Result (*terminate)(TNC_IMCID imcID);
144
145 /**
146 * IMVs implementing the UNIX/Linux Dynamic Linkage platform binding MUST
147 * define this additional function. The TNC Server MUST call the function
148 * immediately after calling TNC_IMV_Initialize to provide a pointer to the
149 * TNCS bind function. The IMV can then use the TNCS bind function to obtain
150 * pointers to any other TNCS functions.
151 *
152 * @param imcID IMC ID assigned by TNCC
153 * @param bindFunction pointer to TNC_TNCC_BindFunction
154 * @return TNC result code
155 */
156 TNC_Result (*provide_bind_function)(TNC_IMCID imcID,
157 TNC_TNCC_BindFunctionPointer bindFunction);
158
159 /**
160 * Sets the ID of an imc_t object.
161 *
162 * @param id IMC ID to be assigned
163 */
164 void (*set_id)(imc_t *this, TNC_IMCID id);
165
166 /**
167 * Returns the ID of an imc_t object.
168 *
169 * @return assigned IMC ID
170 */
171 TNC_IMCID (*get_id)(imc_t *this);
172
173 /**
174 * Assign an additional ID to an imc_t object.
175 *
176 * @param id additional IMC ID to be assigned
177 */
178 void (*add_id)(imc_t *this, TNC_IMCID id);
179
180 /**
181 * Checks if the ID is assigned to the imc_t object.
182 *
183 * @return TRUE if IMC ID is assigned to imc_t object
184 */
185 bool (*has_id)(imc_t *this, TNC_IMCID id);
186
187 /**
188 * Returns the name of an imc_t object.
189 *
190 * @return name of IMC
191 */
192 char* (*get_name)(imc_t *this);
193
194 /**
195 * Sets the supported message types of an imc_t object.
196 *
197 * @param supported_types list of messages type supported by IMC
198 * @param type_count number of supported message types
199 */
200 void (*set_message_types)(imc_t *this, TNC_MessageTypeList supported_types,
201 TNC_UInt32 type_count);
202
203 /**
204 * Sets the supported long message types of an imc_t object.
205 *
206 * @param supported_vids list of vendor IDs supported by IMC
207 * @param supported_subtypes list of messages type supported by IMC
208 * @param type_count number of supported message types
209 */
210 void (*set_message_types_long)(imc_t *this, TNC_VendorIDList supported_vids,
211 TNC_MessageSubtypeList supported_subtypes,
212 TNC_UInt32 type_count);
213
214 /**
215 * Check if the IMC supports a given message type.
216 *
217 * @param msg_vid message vendor ID
218 * @param msg_subtype message subtype
219 * @return TRUE if supported
220 */
221 bool (*type_supported)(imc_t *this, TNC_VendorID msg_vid,
222 TNC_MessageSubtype msg_subtype);
223
224 /**
225 * Destroys an imc_t object.
226 */
227 void (*destroy)(imc_t *this);
228 };
229
230 #endif /** IMC_H_ @}*/