3794fd26d4b81527b0b4e49a00038811119662cb
[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 notify IMCs that all IMV messages
99 * received in a batch have been delivered and this is the IMC’s last chance
100 * to send a message in the batch of IMC messages currently being collected.
101 *
102 * @param imcID IMC ID assigned by TNCC
103 * @param connectionID network connection ID assigned by TNCC
104 * @return TNC result code
105 */
106 TNC_Result (*batch_ending)(TNC_IMCID imcID,
107 TNC_ConnectionID connectionID);
108
109 /**
110 * The TNC Client calls this function to close down the IMC when all work is
111 * complete or the IMC reports TNC_RESULT_FATAL.
112 *
113 * @param imcID IMC ID assigned by TNCC
114 * @return TNC result code
115 */
116 TNC_Result (*terminate)(TNC_IMCID imcID);
117
118 /**
119 * IMVs implementing the UNIX/Linux Dynamic Linkage platform binding MUST
120 * define this additional function. The TNC Server MUST call the function
121 * immediately after calling TNC_IMV_Initialize to provide a pointer to the
122 * TNCS bind function. The IMV can then use the TNCS bind function to obtain
123 * pointers to any other TNCS functions.
124 *
125 * @param imcID IMC ID assigned by TNCC
126 * @param bindFunction pointer to TNC_TNCC_BindFunction
127 * @return TNC result code
128 */
129 TNC_Result (*provide_bind_function)(TNC_IMCID imcID,
130 TNC_TNCC_BindFunctionPointer bindFunction);
131
132 /**
133 * Sets the ID of an imc_t object.
134 *
135 * @param id IMC ID to be assigned
136 */
137 void (*set_id)(imc_t *this, TNC_IMCID id);
138
139 /**
140 * Returns the ID of an imc_t object.
141 *
142 * @return assigned IMC ID
143 */
144 TNC_IMCID (*get_id)(imc_t *this);
145
146 /**
147 * Assign an additional ID to an imc_t object.
148 *
149 * @param id additional IMC ID to be assigned
150 */
151 void (*add_id)(imc_t *this, TNC_IMCID id);
152
153 /**
154 * Checks if the ID is assigned to the imc_t object.
155 *
156 * @return TRUE if IMC ID is assigned to imc_t object
157 */
158 bool (*has_id)(imc_t *this, TNC_IMCID id);
159
160 /**
161 * Returns the name of an imc_t object.
162 *
163 * @return name of IMC
164 */
165 char* (*get_name)(imc_t *this);
166
167 /**
168 * Sets the supported message types of an imc_t object.
169 *
170 * @param supported_types list of messages type supported by IMC
171 * @param type_count number of supported message types
172 */
173 void (*set_message_types)(imc_t *this, TNC_MessageTypeList supported_types,
174 TNC_UInt32 type_count);
175
176 /**
177 * Sets the supported long message types of an imc_t object.
178 *
179 * @param supported_vids list of vendor IDs supported by IMC
180 * @param supported_subtypes list of messages type supported by IMC
181 * @param type_count number of supported message types
182 */
183 void (*set_message_types_long)(imc_t *this, TNC_VendorIDList supported_vids,
184 TNC_MessageSubtypeList supported_subtypes,
185 TNC_UInt32 type_count);
186
187 /**
188 * Check if the IMC supports a given message type.
189 *
190 * @param message_type message type
191 * @return TRUE if supported
192 */
193 bool (*type_supported)(imc_t *this, TNC_MessageType message_type);
194
195 /**
196 * Destroys an imc_t object.
197 */
198 void (*destroy)(imc_t *this);
199 };
200
201 #endif /** IMC_H_ @}*/