Fixed return values of several functions (e.g. return FALSE for pointer types).
[strongswan.git] / src / libimcv / imc / imc_agent.h
1 /*
2 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 /**
16 *
17 * @defgroup imc_agent_t imc_agent
18 * @{ @ingroup imc_agent
19 */
20
21 #ifndef IMC_AGENT_H_
22 #define IMC_AGENT_H_
23
24 #include "imc_state.h"
25 #include "pa_tnc/pa_tnc_msg.h"
26
27 #include <tncifimc.h>
28 #include <pen/pen.h>
29
30 #include <library.h>
31
32 typedef struct imc_agent_t imc_agent_t;
33
34 /**
35 * Core functions of an Integrity Measurement Verifier (IMC)
36 */
37 struct imc_agent_t {
38
39 /**
40 * Ask a TNCC to retry an Integrity Check Handshake
41 *
42 * @param imc_id IMC ID assigned by TNCC
43 * @param connection_id network connection ID assigned by TNCC
44 * @param reason IMC retry reason
45 * @return TNC result code
46 */
47 TNC_Result (*request_handshake_retry)(TNC_IMCID imc_id,
48 TNC_ConnectionID connection_id,
49 TNC_RetryReason reason);
50
51 /**
52 * Bind TNCC functions
53 *
54 * @param bind_function function offered by the TNCC
55 * @return TNC result code
56 */
57 TNC_Result (*bind_functions)(imc_agent_t *this,
58 TNC_TNCC_BindFunctionPointer bind_function);
59
60 /**
61 * Create the IMC state for a TNCCS connection instance
62 *
63 * @param state internal IMC state instance
64 * @return TNC result code
65 */
66 TNC_Result (*create_state)(imc_agent_t *this, imc_state_t *state);
67
68 /**
69 * Delete the IMC state for a TNCCS connection instance
70 *
71 * @param connection_id network connection ID assigned by TNCS
72 * @return TNC result code
73 */
74 TNC_Result (*delete_state)(imc_agent_t *this,
75 TNC_ConnectionID connection_id);
76
77 /**
78 * Change the current state of a TNCCS connection
79 *
80 * @param connection_id network connection ID assigned by TNCS
81 * @param new_state new state of TNCCS connection
82 * @param state_p internal IMC state instance [optional argument]
83 * @return TNC result code
84 */
85 TNC_Result (*change_state)(imc_agent_t *this,
86 TNC_ConnectionID connection_id,
87 TNC_ConnectionState new_state,
88 imc_state_t **state_p);
89
90 /**
91 * Get the IMC state for a TNCCS connection instance
92 *
93 * @param connection_id network connection ID assigned by TNCS
94 * @param state internal IMC state instance
95 * @return TRUE if the state was found
96 */
97 bool (*get_state)(imc_agent_t *this,
98 TNC_ConnectionID connection_id, imc_state_t **state);
99
100 /**
101 * Call when an PA-TNC message is to be sent
102 *
103 * @param connection_id network connection ID assigned by TNCC
104 * @param excl exclusive flag
105 * @param src_imc_id IMC ID to be set as source
106 * @param dst_imv_id IMV ID to be set as destination
107 * @param msg message to send
108 * @return TNC result code
109 */
110 TNC_Result (*send_message)(imc_agent_t *this,
111 TNC_ConnectionID connection_id, bool excl,
112 TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
113 chunk_t msg);
114
115 /**
116 * Call when a PA-TNC message was received
117 *
118 * @param state state for current connection
119 * @param msg received unparsed message
120 * @param msg_vid message vendorID of the received message
121 * @param msg_subtype message subtype of the received message
122 * @param src_imv_id source IMV ID
123 * @param dst_imc_id destination IMC ID
124 * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
125 * @return TNC result code
126 */
127 TNC_Result (*receive_message)(imc_agent_t *this,
128 imc_state_t *state, chunk_t msg,
129 TNC_VendorID msg_vid,
130 TNC_MessageSubtype msg_subtype,
131 TNC_UInt32 src_imv_id,
132 TNC_UInt32 dst_imc_id,
133 pa_tnc_msg_t **pa_tnc_msg);
134
135 /**
136 * Reserve additional IMC IDs from TNCC
137 *
138 * @param count number of additional IMC IDs to be assigned
139 * @return TNC result code
140 */
141 TNC_Result (*reserve_additional_ids)(imc_agent_t *this, int count);
142
143 /**
144 * Return the number of additional IMC IDs assigned by the TNCC
145 *
146 * @return number of additional IMC IDs
147 */
148 int (*count_additional_ids)(imc_agent_t *this);
149
150 /**
151 * Create an enumerator for the additional IMC IDs
152 */
153 enumerator_t* (*create_id_enumerator)(imc_agent_t *this);
154
155 /**
156 * Destroys an imc_agent_t object
157 */
158 void (*destroy)(imc_agent_t *this);
159 };
160
161 /**
162 * Create an imc_agent_t object
163 *
164 * @param name name of the IMC
165 * @param vendor_id vendor ID of the IMC
166 * @param subtype message subtype of the IMC
167 * @param id ID of the IMC as assigned by the TNCS
168 * @param actual_version actual version of the IF-IMC API
169 *
170 */
171 imc_agent_t *imc_agent_create(const char *name,
172 pen_t vendor_id, u_int32_t subtype,
173 TNC_IMCID id, TNC_Version *actual_version);
174
175 #endif /** IMC_AGENT_H_ @}*/