2 * Copyright (C) 2010 Andreas Steffen
4 * Copyright (C) secunet Security Networks AG
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * @defgroup imc_manager imc_manager
22 #ifndef IMC_MANAGER_H_
23 #define IMC_MANAGER_H_
25 typedef struct imc_manager_t imc_manager_t
;
32 * The IMC manager controls all IMC instances.
34 struct imc_manager_t
{
39 * @param imc IMC instance
40 * @return TRUE if initialization successful
42 bool (*add
)(imc_manager_t
*this, imc_t
*imc
);
45 * Remove an IMC instance from the list and return it
47 * @param id ID of IMC instance
48 * @return removed IMC instance
50 imc_t
* (*remove
)(imc_manager_t
*this, TNC_IMCID id
);
53 * Load and initialize an IMC as a dynamic library and add it to the list
55 * @param name name of the IMC to be loaded
56 * @param path path of the IMC dynamic library file
57 * @return TRUE if loading succeeded
59 bool (*load
)(imc_manager_t
*this, char *name
, char *path
);
62 * Load and initialize an IMC from a set of TNC IMC functions.
64 * @param name name of the IMC
65 * @param initialize TNC_IMC_InitializePointer
66 * @param notify_connection_change TNC_IMC_NotifyConnectionChangePointer
67 * @param begin_handshake TNC_IMC_BeginHandshakePointer
68 * @param receive_message TNC_IMC_ReceiveMessagePointer
69 * @param receive_message_long TNC_IMC_ReceiveMessageLongPointer
70 * @param batch_ending TNC_IMC_BatchEndingPointer
71 * @param terminate TNC_IMC_TerminatePointer
72 * @param provide_bind_function TNC_IMC_ProvideBindFunctionPointer
73 * @return TRUE if loading succeeded
75 bool (*load_from_functions
)(imc_manager_t
*this, char *name
,
76 TNC_IMC_InitializePointer initialize
,
77 TNC_IMC_NotifyConnectionChangePointer notify_connection_change
,
78 TNC_IMC_BeginHandshakePointer begin_handshake
,
79 TNC_IMC_ReceiveMessagePointer receive_message
,
80 TNC_IMC_ReceiveMessageLongPointer receive_message_long
,
81 TNC_IMC_BatchEndingPointer batch_ending
,
82 TNC_IMC_TerminatePointer terminate
,
83 TNC_IMC_ProvideBindFunctionPointer provide_bind_function
);
86 * Check if an IMC with a given ID is registered with the IMC manager
88 * @param id ID of IMC instance
89 * @return TRUE if registered
91 bool (*is_registered
)(imc_manager_t
*this, TNC_IMCID id
);
94 * Reserve an additional ID for an IMC
96 * @param id ID of IMC instance
97 * @param new_id reserved ID assigned to IMC
98 * @return TRUE if primary IMC ID was used
100 bool (*reserve_id
)(imc_manager_t
*this, TNC_IMCID id
, TNC_UInt32
*new_id
);
103 * Return the preferred language for recommendations
105 * @return preferred language string
107 char* (*get_preferred_language
)(imc_manager_t
*this);
110 * Notify all IMC instances
112 * @param state communicate the state a connection has reached
114 void (*notify_connection_change
)(imc_manager_t
*this,
116 TNC_ConnectionState state
);
119 * Begin a handshake between the IMCs and a connection
121 * @param id connection ID
123 void (*begin_handshake
)(imc_manager_t
*this, TNC_ConnectionID id
);
126 * Sets the supported message types reported by a given IMC
128 * @param id ID of reporting IMC
129 * @param supported_types list of messages type supported by IMC
130 * @param type_count number of supported message types
131 * @return TNC result code
133 TNC_Result (*set_message_types
)(imc_manager_t
*this,
135 TNC_MessageTypeList supported_types
,
136 TNC_UInt32 type_count
);
139 * Sets the supported long message types reported by a given IMC
141 * @param id ID of reporting IMC
142 * @param supported_vids list of vendor IDs supported by IMC
143 * @param supported_subtypes list of messages type supported by IMC
144 * @param type_count number of supported message types
145 * @return TNC result code
147 TNC_Result (*set_message_types_long
)(imc_manager_t
*this,
149 TNC_VendorIDList supported_vids
,
150 TNC_MessageSubtypeList supported_subtypes
,
151 TNC_UInt32 type_count
);
154 * Delivers a message to interested IMCs.
156 * @param connection_id connection ID
157 * @param excl exclusive message flag
159 * @param msg_len message length
160 * @param msg_vid message Vendor ID
161 * @param msg_subtype message subtype
162 * @param src_imv_id source IMV ID
163 * @param dst_imc_id destination IMC ID
165 void (*receive_message
)(imc_manager_t
*this,
166 TNC_ConnectionID connection_id
,
168 TNC_BufferReference msg
,
170 TNC_VendorID msg_vid
,
171 TNC_MessageSubtype msg_subtype
,
172 TNC_UInt32 src_imv_id
,
173 TNC_UInt32 dst_imc_id
);
176 * Notify all IMCs that all IMV messages received in a batch have been
177 * delivered and this is the IMCs last chance to send a message in the
178 * batch of IMC messages currently being collected.
180 * @param id connection ID
182 void (*batch_ending
)(imc_manager_t
*this, TNC_ConnectionID id
);
185 * Destroy an IMC manager and all its controlled instances.
187 void (*destroy
)(imc_manager_t
*this);
190 #endif /** IMC_MANAGER_H_ @}*/