refactoring of change_state()
[strongswan.git] / src / libimcv / imv / imv_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 imv_agent_t imv_agent
18 * @{ @ingroup imv_agent
19 */
20
21 #ifndef IMV_AGENT_H_
22 #define IMV_AGENT_H_
23
24 #include "imv_state.h"
25 #include "pa_tnc/pa_tnc_msg.h"
26
27 #include <tncifimv.h>
28 #include <pen/pen.h>
29
30 #include <library.h>
31
32 typedef struct imv_agent_t imv_agent_t;
33
34 /**
35 * Core functions of an Integrity Measurement Verifier (IMV)
36 */
37 struct imv_agent_t {
38
39 /**
40 * Ask a TNCS to retry an Integrity Check Handshake
41 *
42 * @param imv_id IMV ID assigned by TNCS
43 * @param connection_id network connection ID assigned by TNCS
44 * @param reason IMV retry reason
45 * @return TNC result code
46 */
47 TNC_Result (*request_handshake_retry)(TNC_IMVID imv_id,
48 TNC_ConnectionID connection_id,
49 TNC_RetryReason reason);
50
51 /**
52 * Bind TNCS functions
53 *
54 * @param bind_function function offered by the TNCS
55 * @return TNC result code
56 */
57 TNC_Result (*bind_functions)(imv_agent_t *this,
58 TNC_TNCS_BindFunctionPointer bind_function);
59
60 /**
61 * Create the IMV state for a TNCCS connection instance
62 *
63 * @param state internal IMV state instance
64 * @return TNC result code
65 */
66 TNC_Result (*create_state)(imv_agent_t *this, imv_state_t *state);
67
68 /**
69 * Delete the IMV 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)(imv_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 IMV state instance [optional argument]
83 * @return TNC result code
84 */
85 TNC_Result (*change_state)(imv_agent_t *this,
86 TNC_ConnectionID connection_id,
87 TNC_ConnectionState new_state,
88 imv_state_t **state_p);
89
90 /**
91 * Get the IMV state for a TNCCS connection instance
92 *
93 * @param connection_id network connection ID assigned by TNCS
94 * @param state internal IMV state instance
95 * @return TRUE if the state was found
96 */
97 bool (*get_state)(imv_agent_t *this,
98 TNC_ConnectionID connection_id, imv_state_t **state);
99
100 /**
101 * Call when a PA-TNC message is to be sent
102 *
103 * @param connection_id network connection ID assigned by TNCS
104 * @param msg message to send
105 * @return TNC result code
106 */
107 TNC_Result (*send_message)(imv_agent_t *this,
108 TNC_ConnectionID connection_id, chunk_t msg);
109
110 /**
111 * Call when a PA-TNC message was received
112 *
113 * @param connection_id network connection ID assigned by TNCS
114 * @param msg received unparsed message
115 * @param msg_type message type of the received message
116 * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
117 * @return TNC result code
118 */
119 TNC_Result (*receive_message)(imv_agent_t *this,
120 TNC_ConnectionID connection_id, chunk_t msg,
121 TNC_MessageType msg_type,
122 pa_tnc_msg_t **pa_tnc_msg);
123
124 /**
125 * Set Action Recommendation and Evaluation Result in the IMV state
126 *
127 * @param connection_id network connection ID assigned by TNCS
128 * @param rec IMV action recommendation
129 * @param eval IMV evaluation result
130 * @return TNC result code
131 */
132 TNC_Result (*set_recommendation)(imv_agent_t *this,
133 TNC_ConnectionID connection_id,
134 TNC_IMV_Action_Recommendation rec,
135 TNC_IMV_Evaluation_Result eval);
136
137 /**
138 * Deliver IMV Action Recommendation and IMV Evaluation Result to the TNCS
139 *
140 * @param connection_id network connection ID assigned by TNCS
141 * @return TNC result code
142 */
143 TNC_Result (*provide_recommendation)(imv_agent_t *this,
144 TNC_ConnectionID connection_id);
145
146 /**
147 * Destroys an imv_agent_t object
148 */
149 void (*destroy)(imv_agent_t *this);
150 };
151
152 /**
153 * Create an imv_agent_t object
154 *
155 * @param name name of the IMV
156 * @param vendor_id vendor ID of the IMV
157 * @param subtype message subtype of the IMV
158 * @param id ID of the IMV as assigned by the TNCS
159 * @param actual_version actual version of the IF-IMV API
160 *
161 */
162 imv_agent_t *imv_agent_create(const char *name,
163 pen_t vendor_id, u_int32_t subtype,
164 TNC_IMVID id, TNC_Version *actual_version);
165
166 #endif /** IMV_AGENT_H_ @}*/