static upper size limit for PA-TNC messages
[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 #include <utils/linked_list.h>
30
31 #include <library.h>
32
33 typedef struct imc_agent_t imc_agent_t;
34
35 /**
36 * Core functions of an Integrity Measurement Verifier (IMC)
37 */
38 struct imc_agent_t {
39
40 /**
41 * Ask a TNCC to retry an Integrity Check Handshake
42 *
43 * @param imc_id IMC ID assigned by TNCC
44 * @param connection_id network connection ID assigned by TNCC
45 * @param reason IMC retry reason
46 * @return TNC result code
47 */
48 TNC_Result (*request_handshake_retry)(TNC_IMCID imc_id,
49 TNC_ConnectionID connection_id,
50 TNC_RetryReason reason);
51
52 /**
53 * Bind TNCC functions
54 *
55 * @param bind_function function offered by the TNCC
56 * @return TNC result code
57 */
58 TNC_Result (*bind_functions)(imc_agent_t *this,
59 TNC_TNCC_BindFunctionPointer bind_function);
60
61 /**
62 * Create the IMC state for a TNCCS connection instance
63 *
64 * @param state internal IMC state instance
65 * @return TNC result code
66 */
67 TNC_Result (*create_state)(imc_agent_t *this, imc_state_t *state);
68
69 /**
70 * Delete the IMC state for a TNCCS connection instance
71 *
72 * @param connection_id network connection ID assigned by TNCS
73 * @return TNC result code
74 */
75 TNC_Result (*delete_state)(imc_agent_t *this,
76 TNC_ConnectionID connection_id);
77
78 /**
79 * Change the current state of a TNCCS connection
80 *
81 * @param connection_id network connection ID assigned by TNCS
82 * @param new_state new state of TNCCS connection
83 * @param state_p internal IMC state instance [optional argument]
84 * @return TNC result code
85 */
86 TNC_Result (*change_state)(imc_agent_t *this,
87 TNC_ConnectionID connection_id,
88 TNC_ConnectionState new_state,
89 imc_state_t **state_p);
90
91 /**
92 * Get the IMC state for a TNCCS connection instance
93 *
94 * @param connection_id network connection ID assigned by TNCS
95 * @param state internal IMC state instance
96 * @return TRUE if the state was found
97 */
98 bool (*get_state)(imc_agent_t *this,
99 TNC_ConnectionID connection_id, imc_state_t **state);
100
101 /**
102 * Call when an PA-TNC message is to be sent
103 *
104 * @param connection_id network connection ID assigned by TNCC
105 * @param excl exclusive flag
106 * @param src_imc_id IMC ID to be set as source
107 * @param dst_imv_id IMV ID to be set as destination
108 * @param attr_list list of PA-TNC attributes to send
109 * @return TNC result code
110 */
111 TNC_Result (*send_message)(imc_agent_t *this,
112 TNC_ConnectionID connection_id, bool excl,
113 TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
114 linked_list_t *attr_list);
115
116 /**
117 * Call when a PA-TNC message was received
118 *
119 * @param state state for current connection
120 * @param msg received unparsed message
121 * @param msg_vid message vendorID of the received message
122 * @param msg_subtype message subtype of the received message
123 * @param src_imv_id source IMV ID
124 * @param dst_imc_id destination IMC ID
125 * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
126 * @return TNC result code
127 */
128 TNC_Result (*receive_message)(imc_agent_t *this,
129 imc_state_t *state, chunk_t msg,
130 TNC_VendorID msg_vid,
131 TNC_MessageSubtype msg_subtype,
132 TNC_UInt32 src_imv_id,
133 TNC_UInt32 dst_imc_id,
134 pa_tnc_msg_t **pa_tnc_msg);
135
136 /**
137 * Reserve additional IMC IDs from TNCC
138 *
139 * @param count number of additional IMC IDs to be assigned
140 * @return TNC result code
141 */
142 TNC_Result (*reserve_additional_ids)(imc_agent_t *this, int count);
143
144 /**
145 * Return the number of additional IMC IDs assigned by the TNCC
146 *
147 * @return number of additional IMC IDs
148 */
149 int (*count_additional_ids)(imc_agent_t *this);
150
151 /**
152 * Create an enumerator for the additional IMC IDs
153 */
154 enumerator_t* (*create_id_enumerator)(imc_agent_t *this);
155
156 /**
157 * Destroys an imc_agent_t object
158 */
159 void (*destroy)(imc_agent_t *this);
160 };
161
162 /**
163 * Create an imc_agent_t object
164 *
165 * @param name name of the IMC
166 * @param vendor_id vendor ID of the IMC
167 * @param subtype message subtype of the IMC
168 * @param id ID of the IMC as assigned by the TNCS
169 * @param actual_version actual version of the IF-IMC API
170 *
171 */
172 imc_agent_t *imc_agent_create(const char *name,
173 pen_t vendor_id, u_int32_t subtype,
174 TNC_IMCID id, TNC_Version *actual_version);
175
176 #endif /** IMC_AGENT_H_ @}*/