implemented receive_message() function
[strongswan.git] / src / libcharon / tnc / imv / imv.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 imv
18 * @{ @ingroup libcharon
19 */
20
21 #ifndef IMV_H_
22 #define IMV_H_
23
24 #include <tnc/tncifimv.h>
25
26 #include <library.h>
27
28 typedef struct imv_t imv_t;
29
30 struct imv_t {
31
32 /**
33 * The TNC Server calls this function to initialize the IMV and agree on
34 * the API version number to be used. It also supplies the IMV ID, an IMV
35 * identifier that the IMV must use when calling TNC Server callback functions.
36 *
37 * @param imvID IMV ID assigned by TNCS
38 * @param minVersion Minimum API version supported
39 * @param maxVersion Maximum API version supported by TNCS
40 * @param OutActualVersion Mutually supported API version number
41 * @return TNC result code
42 */
43 TNC_Result (*initialize)(TNC_IMVID imvID,
44 TNC_Version minVersion,
45 TNC_Version maxVersion,
46 TNC_Version *OutActualVersion);
47
48 /**
49 * The TNC Server calls this function to inform the IMV that the state of
50 * the network connection identified by connectionID has changed to newState.
51 *
52 * @param imvID IMV ID assigned by TNCS
53 * @param connectionID Network connection ID assigned by TNCS
54 * @param newState New network connection state
55 * @return TNC result code
56 */
57 TNC_Result (*notify_connection_change)(TNC_IMVID imvID,
58 TNC_ConnectionID connectionID,
59 TNC_ConnectionState newState);
60
61 /**
62 * The TNC Server calls this function at the end of an Integrity Check
63 * Handshake (after all IMC-IMV messages have been delivered) to solicit
64 * recommendations from IMVs that have not yet provided a recommendation.
65 *
66 * @param imvID IMV ID assigned by TNCS
67 * @param connectionID Network connection ID assigned by TNCS
68 * @return TNC result code
69 */
70 TNC_Result (*solicit_recommendation)(TNC_IMVID imvID,
71 TNC_ConnectionID connectionID);
72
73 /**
74 * The TNC Server calls this function to deliver a message to the IMV.
75 * The message is contained in the buffer referenced by message and contains
76 * the number of octets indicated by messageLength. The type of the message
77 * is indicated by messageType.
78 *
79 * @param imvID IMV ID assigned by TNCS
80 * @param connectionID Network connection ID assigned by TNCS
81 * @param message Reference to buffer containing message
82 * @param messageLength Number of octets in message
83 * @param messageType Message type of message
84 * @return TNC result code
85 */
86 TNC_Result (*receive_message)(TNC_IMVID imvID,
87 TNC_ConnectionID connectionID,
88 TNC_BufferReference message,
89 TNC_UInt32 messageLength,
90 TNC_MessageType messageType);
91
92 /**
93 * The TNC Server calls this function to notify IMVs that all IMC messages
94 * received in a batch have been delivered and this is the IMV’s last chance
95 * to send a message in the batch of IMV messages currently being collected.
96 *
97 * @param imvID IMV ID assigned by TNCS
98 * @param connectionID Network connection ID assigned by TNCS
99 * @return TNC result code
100 */
101 TNC_Result (*batch_ending)(TNC_IMVID imvID,
102 TNC_ConnectionID connectionID);
103
104 /**
105 * The TNC Server calls this function to close down the IMV.
106 *
107 * @param imvID IMV ID assigned by TNCS
108 * @return TNC result code
109 */
110 TNC_Result (*terminate)(TNC_IMVID imvID);
111
112 /**
113 * IMVs implementing the UNIX/Linux Dynamic Linkage platform binding MUST
114 * define this additional function. The TNC Server MUST call the function
115 * immediately after calling TNC_IMV_Initialize to provide a pointer to the
116 * TNCS bind function. The IMV can then use the TNCS bind function to obtain
117 * pointers to any other TNCS functions.
118 *
119 * @param imvID IMV ID assigned by TNCS
120 * @param bindFunction Pointer to TNC_TNCS_BindFunction
121 * @return TNC result code
122 */
123 TNC_Result (*provide_bind_function)(TNC_IMVID imvID,
124 TNC_TNCS_BindFunctionPointer bindFunction);
125
126 /**
127 * Sets the ID of an imv_t object.
128 *
129 * @param id IMV ID to be assigned
130 */
131 void (*set_id)(imv_t *this, TNC_IMVID id);
132
133 /**
134 * Returns the ID of an imv_t object.
135 *
136 * @return IMV ID assigned by TNCS
137 */
138 TNC_IMVID (*get_id)(imv_t *this);
139
140 /**
141 * Returns the name of an imv_t object.
142 *
143 * @return name of IMV
144 */
145 char* (*get_name)(imv_t *this);
146
147 /**
148 * Sets the supported message types of an imv_t object.
149 *
150 * @param supported_types List of messages type supported by IMV
151 * @param type_count Number of supported message types
152 */
153 void (*set_message_types)(imv_t *this, TNC_MessageTypeList supported_types,
154 TNC_UInt32 type_count);
155
156 /**
157 * Check if the IMV supports a given message type.
158 *
159 * @param message_type message type
160 * @return TRUE if supported
161 */
162 bool (*type_supported)(imv_t *this, TNC_MessageType message_type);
163
164 /**
165 * Destroys an imv_t object.
166 */
167 void (*destroy)(imv_t *this);
168 };
169
170 #endif /** IMV_H_ @}*/