7c0c7d274f6778c52a913ae0a575a9bc10418b0f
[strongswan.git] / src / libcharon / tnc / tnccs / tnccs_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 tnccs_manager tnccs_manager
18 * @{ @ingroup tnccs
19 */
20
21 #ifndef TNCCS_MANAGER_H_
22 #define TNCCS_MANAGER_H_
23
24 #include "tnccs.h"
25
26 #include <tnc/imv/imv_recommendations.h>
27
28 typedef struct tnccs_manager_t tnccs_manager_t;
29
30 /**
31 * The TNCCS manager manages all TNCCS implementations and creates instances.
32 *
33 * A plugin registers its implemented TNCCS protocol with the manager by
34 * providing type and a constructor function. The manager then creates
35 * TNCCS protocol instances via the provided constructor.
36 */
37 struct tnccs_manager_t {
38
39 /**
40 * Register a TNCCS protocol implementation.
41 *
42 * @param type TNCCS protocol type
43 * @param constructor constructor, returns a TNCCS protocol implementation
44 */
45 void (*add_method)(tnccs_manager_t *this, tnccs_type_t type,
46 tnccs_constructor_t constructor);
47
48 /**
49 * Unregister a TNCCS protocol implementation using it's constructor.
50 *
51 * @param constructor constructor function to remove, as added in add_method
52 */
53 void (*remove_method)(tnccs_manager_t *this, tnccs_constructor_t constructor);
54
55 /**
56 * Create a new TNCCS protocol instance.
57 *
58 * @param type type of the TNCCS protocol
59 * @param is_server TRUE if TNC Server, FALSE if TNC Client
60 * @return TNCCS protocol instance, NULL if no constructor found
61 */
62 tnccs_t* (*create_instance)(tnccs_manager_t *this, tnccs_type_t type,
63 bool is_server);
64
65 /**
66 * Create a TNCCS connection and assign a unique connection ID as well a
67 * callback function for adding a message to a TNCCS batch and create
68 * an empty set for collecting IMV recommendations
69 *
70 * @param tnccs TNCCS connection instance
71 * @param send_message TNCCS callback function
72 * @param recs pointer to IMV recommendation set
73 * @return assigned connection ID
74 */
75 TNC_ConnectionID (*create_connection)(tnccs_manager_t *this, tnccs_t *tnccs,
76 tnccs_send_message_t send_message,
77 recommendations_t **recs);
78
79 /**
80 * Remove a TNCCS connection using its connection ID.
81 *
82 * @param id connection ID of the connection to be removed
83 */
84 void (*remove_connection)(tnccs_manager_t *this, TNC_ConnectionID id);
85
86 /**
87 * Add an IMC/IMV message to the batch of a given connection ID.
88 *
89 * @param id target connection ID
90 * @param msg message to be added
91 * @param msg_len message length
92 * @param msg_type message type
93 * @return return code
94 */
95 TNC_Result (*send_message)(tnccs_manager_t *this,
96 TNC_ConnectionID id,
97 TNC_BufferReference msg,
98 TNC_UInt32 msg_len,
99 TNC_MessageType msg_type);
100
101 /**
102 * Deliver an IMV Action Recommendation and IMV Evaluation Result to the TNCS
103 *
104 * @param imv_id ID of the IMV providing the recommendation
105 * @param connection_id ID of target connection
106 * @param rec action recommendation
107 * @param eval evaluation result
108 * @return return code
109 */
110 TNC_Result (*provide_recommendation)(tnccs_manager_t *this,
111 TNC_IMVID imv_id,
112 TNC_ConnectionID connection_id,
113 TNC_IMV_Action_Recommendation rec,
114 TNC_IMV_Evaluation_Result eval);
115
116 /**
117 * Get the value of an attribute associated with a connection or with the
118 * TNCS as a whole.
119 *
120 * @param imv_id ID of the IMV requesting the attribute
121 * @param connection_id ID of target connection
122 * @param attribute_id ID of the requested attribute
123 * @param buffer_len length of the buffer in bytes
124 * @param buffer pointer to the buffer
125 * @param out_value_len actual length of the returned attribute
126 * @return return code
127 */
128 TNC_Result (*get_attribute)(tnccs_manager_t *this,
129 TNC_IMVID imv_id,
130 TNC_ConnectionID connection_id,
131 TNC_AttributeID attribute_id,
132 TNC_UInt32 buffer_len,
133 TNC_BufferReference buffer,
134 TNC_UInt32 *out_value_len);
135
136 /**
137 * Set the value of an attribute associated with a connection or with the
138 * TNCS as a whole.
139 *
140 * @param imv_id ID of the IMV setting the attribute
141 * @param connection_id ID of target connection
142 * @param attribute_id ID of the attribute to be set
143 * @param buffer_len length of the buffer in bytes
144 * @param buffer pointer to the buffer
145 * @return return code
146 */
147 TNC_Result (*set_attribute)(tnccs_manager_t *this,
148 TNC_IMVID imv_id,
149 TNC_ConnectionID connection_id,
150 TNC_AttributeID attribute_id,
151 TNC_UInt32 buffer_len,
152 TNC_BufferReference buffer);
153
154 /**
155 * Destroy a tnccs_manager instance.
156 */
157 void (*destroy)(tnccs_manager_t *this);
158 };
159
160 /**
161 * Create a tnccs_manager instance.
162 */
163 tnccs_manager_t *tnccs_manager_create();
164
165 #endif /** TNCCS_MANAGER_H_ @}*/