ef2dcc6540994ffa53e96d43c0623b3d9732f761
[strongswan.git] / src / libtnccs / tnc / imc / imc_manager.h
1 /*
2 * Copyright (C) 2010 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_manager imc_manager
18 * @{ @ingroup imc
19 */
20
21 #ifndef IMC_MANAGER_H_
22 #define IMC_MANAGER_H_
23
24 typedef struct imc_manager_t imc_manager_t;
25
26 #include "imc.h"
27
28 #include <library.h>
29
30 /**
31 * The IMC manager controls all IMC instances.
32 */
33 struct imc_manager_t {
34
35 /**
36 * Add an IMC instance
37 *
38 * @param imc IMC instance
39 * @return TRUE if initialization successful
40 */
41 bool (*add)(imc_manager_t *this, imc_t *imc);
42
43 /**
44 * Remove an IMC instance from the list and return it
45 *
46 * @param id ID of IMC instance
47 * @return removed IMC instance
48 */
49 imc_t* (*remove)(imc_manager_t *this, TNC_IMCID id);
50
51 /**
52 * Load and initialize an IMC as a dynamic library and add it to the list
53 *
54 * @param name name of the IMC to be loaded
55 * @param path path of the IMC dynamic library file
56 * @return TRUE if loading succeeded
57 */
58 bool (*load)(imc_manager_t *this, char *name, char *path);
59
60 /**
61 * Check if an IMC with a given ID is registered with the IMC manager
62 *
63 * @param id ID of IMC instance
64 * @return TRUE if registered
65 */
66 bool (*is_registered)(imc_manager_t *this, TNC_IMCID id);
67
68 /**
69 * Reserve an additional ID for an IMC
70 *
71 * @param id ID of IMC instance
72 * @param new_id reserved ID assigned to IMC
73 * @return TRUE if primary IMC ID was used
74 */
75 bool (*reserve_id)(imc_manager_t *this, TNC_IMCID id, TNC_UInt32 *new_id);
76
77 /**
78 * Return the preferred language for recommendations
79 *
80 * @return preferred language string
81 */
82 char* (*get_preferred_language)(imc_manager_t *this);
83
84 /**
85 * Notify all IMC instances
86 *
87 * @param state communicate the state a connection has reached
88 */
89 void (*notify_connection_change)(imc_manager_t *this,
90 TNC_ConnectionID id,
91 TNC_ConnectionState state);
92
93 /**
94 * Begin a handshake between the IMCs and a connection
95 *
96 * @param id connection ID
97 */
98 void (*begin_handshake)(imc_manager_t *this, TNC_ConnectionID id);
99
100 /**
101 * Sets the supported message types reported by a given IMC
102 *
103 * @param id ID of reporting IMC
104 * @param supported_types list of messages type supported by IMC
105 * @param type_count number of supported message types
106 * @return TNC result code
107 */
108 TNC_Result (*set_message_types)(imc_manager_t *this,
109 TNC_IMCID id,
110 TNC_MessageTypeList supported_types,
111 TNC_UInt32 type_count);
112
113 /**
114 * Sets the supported long message types reported by a given IMC
115 *
116 * @param id ID of reporting IMC
117 * @param supported_vids list of vendor IDs supported by IMC
118 * @param supported_subtypes list of messages type supported by IMC
119 * @param type_count number of supported message types
120 * @return TNC result code
121 */
122 TNC_Result (*set_message_types_long)(imc_manager_t *this,
123 TNC_IMCID id,
124 TNC_VendorIDList supported_vids,
125 TNC_MessageSubtypeList supported_subtypes,
126 TNC_UInt32 type_count);
127
128 /**
129 * Delivers a message to interested IMCs.
130 *
131 * @param connection_id ID of connection over which message was received
132 * @param message message
133 * @param message_len message length
134 * @param message_type message type
135 */
136 void (*receive_message)(imc_manager_t *this,
137 TNC_ConnectionID connection_id,
138 TNC_BufferReference message,
139 TNC_UInt32 message_len,
140 TNC_MessageType message_type);
141
142 /**
143 * Notify all IMCs that all IMV messages received in a batch have been
144 * delivered and this is the IMCs last chance to send a message in the
145 * batch of IMC messages currently being collected.
146 *
147 * @param id connection ID
148 */
149 void (*batch_ending)(imc_manager_t *this, TNC_ConnectionID id);
150
151 /**
152 * Destroy an IMC manager and all its controlled instances.
153 */
154 void (*destroy)(imc_manager_t *this);
155 };
156
157 #endif /** IMC_MANAGER_H_ @}*/