added TNC_TNCS_ReserveAdditionalIMVID() function
[strongswan.git] / src / libtnccs / tnc / imv / imv_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 imv_manager imv_manager
18 * @{ @ingroup imv
19 */
20
21 #ifndef IMV_MANAGER_H_
22 #define IMV_MANAGER_H_
23
24 typedef struct imv_manager_t imv_manager_t;
25
26 #include "imv.h"
27 #include "imv_recommendations.h"
28
29 #include <library.h>
30
31 /**
32 * The IMV manager controls all IMV instances.
33 */
34 struct imv_manager_t {
35
36 /**
37 * Add an IMV instance
38 *
39 * @param imv IMV instance
40 * @return TRUE if initialization successful
41 */
42 bool (*add)(imv_manager_t *this, imv_t *imv);
43
44 /**
45 * Remove an IMV instance from the list and return it
46 *
47 * @param id ID of IMV instance
48 * @return removed IMC instance
49 */
50 imv_t* (*remove)(imv_manager_t *this, TNC_IMVID id);
51
52 /**
53 * Load and initialize an IMV as a dynamic library and add it to the list
54 *
55 * @param name name of the IMV to be loaded
56 * @param path path of the IMV dynamic library file
57 * @return TRUE if loading succeeded
58 */
59 bool (*load)(imv_manager_t *this, char *name, char *path);
60
61
62 /**
63 * Check if an IMV with a given ID is registered with the IMV manager
64 *
65 * @param id ID of IMV instance
66 * @return TRUE if registered
67 */
68 bool (*is_registered)(imv_manager_t *this, TNC_IMVID id);
69
70 /**
71 * Reserve an additional ID for an IMV
72 *
73 * @param id ID of IMV instance
74 * @param new_id reserved ID assigned to IMV
75 * @return TRUE if primary IMV ID was used
76 */
77 bool (*reserve_id)(imv_manager_t *this, TNC_IMVID id, TNC_UInt32 *new_id);
78
79 /**
80 * Get the configured recommendation policy
81 *
82 * @return configured recommendation policy
83 */
84 recommendation_policy_t (*get_recommendation_policy)(imv_manager_t *this);
85
86 /**
87 * Create an empty set of IMV recommendations and evaluations
88 *
89 * @return instance of a recommendations_t list
90 */
91 recommendations_t* (*create_recommendations)(imv_manager_t *this);
92
93 /**
94 * Enforce the TNC recommendation on the IKE_SA by either inserting an
95 * allow|isolate group membership rule (TRUE) or by blocking access (FALSE)
96 *
97 * @param rec TNC action recommendation
98 * @param eval TNC evaluation result
99 * @return TRUE for allow|isolate, FALSE for none
100 */
101 bool (*enforce_recommendation)(imv_manager_t *this,
102 TNC_IMV_Action_Recommendation rec,
103 TNC_IMV_Evaluation_Result eval);
104
105 /**
106 * Notify all IMV instances
107 *
108 * @param state communicate the state a connection has reached
109 */
110 void (*notify_connection_change)(imv_manager_t *this,
111 TNC_ConnectionID id,
112 TNC_ConnectionState state);
113
114 /**
115 * Sets the supported message types reported by a given IMV
116 *
117 * @param id ID of reporting IMV
118 * @param supported_types list of messages type supported by IMV
119 * @param type_count number of supported message types
120 * @return TNC result code
121 */
122 TNC_Result (*set_message_types)(imv_manager_t *this,
123 TNC_IMVID id,
124 TNC_MessageTypeList supported_types,
125 TNC_UInt32 type_count);
126
127 /**
128 * Sets the supported long message types reported by a given IMV
129 *
130 * @param id ID of reporting IMV
131 * @param supported_vids list of vendor IDs supported by IMV
132 * @param supported_subtypes list of messages type supported by IMV
133 * @param type_count number of supported message types
134 * @return TNC result code
135 */
136 TNC_Result (*set_message_types_long)(imv_manager_t *this,
137 TNC_IMVID id,
138 TNC_VendorIDList supported_vids,
139 TNC_MessageSubtypeList supported_subtypes,
140 TNC_UInt32 type_count);
141
142 /**
143 * Solicit recommendations from IMVs that have not yet provided one
144 *
145 * @param id connection ID
146 */
147 void (*solicit_recommendation)(imv_manager_t *this, TNC_ConnectionID id);
148
149 /**
150 * Delivers a message to interested IMVs.
151 *
152 * @param connection_id ID of connection over which message was received
153 * @param message message
154 * @param message_len message length
155 * @param message_type message type
156 */
157 void (*receive_message)(imv_manager_t *this,
158 TNC_ConnectionID connection_id,
159 TNC_BufferReference message,
160 TNC_UInt32 message_len,
161 TNC_MessageType message_type);
162
163 /**
164 * Notify all IMVs that all IMC messages received in a batch have been
165 * delivered and this is the IMVs last chance to send a message in the
166 * batch of IMV messages currently being collected.
167 *
168 * @param id connection ID
169 */
170 void (*batch_ending)(imv_manager_t *this, TNC_ConnectionID id);
171
172 /**
173 * Destroy an IMV manager and all its controlled instances.
174 */
175 void (*destroy)(imv_manager_t *this);
176 };
177
178 #endif /** IMV_MANAGER_H_ @}*/