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