centralized processing of assessment information
[strongswan.git] / src / libimcv / imv / imv_msg.h
1 /*
2 * Copyright (C) 2012 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_msg imv_msg
18 * @{ @ingroup libimcv
19 */
20
21 #ifndef IMV_MSG_H_
22 #define IMV_MSG_H_
23
24 #include <imv/imv_agent.h>
25
26 typedef struct imv_msg_t imv_msg_t;
27
28 #include <library.h>
29
30 /**
31 * Interface for a PA-TNC message handled by an IMV.
32 *
33 */
34 struct imv_msg_t {
35
36 /**
37 * Get source ID of PA-TNC message
38 *
39 * @return src ID
40 */
41 TNC_UInt32 (*get_src_id)(imv_msg_t *this);
42
43 /**
44 * Get destination ID of PA-TNC message
45 *
46 * @return destination ID
47 */
48 TNC_UInt32 (*get_dst_id)(imv_msg_t *this);
49
50 /**
51 * Set the type of a PA-TNC message
52 *
53 * @param msg_type message type
54 */
55 void (*set_msg_type)(imv_msg_t *this, pen_type_t msg_type);
56
57 /**
58 * Sends one or multiple PA-TNC messages
59 *
60 * @param excl set the excl message flag if supported
61 * @return TNC result code
62 */
63 TNC_Result (*send)(imv_msg_t *this, bool excl);
64
65 /**
66 * Send a PA-TNC message containing an IETF Assessment Result attribute
67 *
68 * @return TNC result code
69 */
70 TNC_Result (*send_assessment)(imv_msg_t *this);
71
72 /**
73 * Processes a received PA-TNC message
74 *
75 * @param fatal_error TRUE if IMC sent a fatal error message
76 * @return TNC result code
77 */
78 TNC_Result (*receive)(imv_msg_t *this, bool *fatal_error);
79
80 /**
81 * Add a PA-TNC attribute to the send queue
82 *
83 * @param attr PA-TNC attribute to be added
84 */
85 void (*add_attribute)(imv_msg_t *this, pa_tnc_attr_t *attr);
86
87 /**
88 * Delete all PA-TNC attributes in the send queue
89 *
90 */
91 void (*delete_attributes)(imv_msg_t *this);
92
93 /**
94 * Enumerator over PA-TNC attributes contained in the PA-TNC message
95 *
96 * @return PA-TNC attribute enumerator
97 */
98 enumerator_t* (*create_attribute_enumerator)(imv_msg_t *this);
99
100 /**
101 * Destroys a imv_msg_t object.
102 */
103 void (*destroy)(imv_msg_t *this);
104 };
105
106 /**
107 * Create a wrapper for an outbound message
108 *
109 * @param agent IMV agent responsible for the message
110 * @param state IMV state for the given connection ID
111 * @param connection_id connection ID
112 * @param src_id source IMV ID
113 * @param dst_id destination IMC ID
114 * @param msg_type PA-TNC message type
115 */
116 imv_msg_t* imv_msg_create(imv_agent_t *agent, imv_state_t *state,
117 TNC_ConnectionID connection_id,
118 TNC_UInt32 src_id, TNC_UInt32 dst_id,
119 pen_type_t msg_type);
120
121 /**
122 * Create a wrapper for an outbound message based on a received message
123 *
124 * @param msg received message the reply is based on
125 */
126 imv_msg_t* imv_msg_create_as_reply(imv_msg_t *msg);
127
128 /**
129 * Create a wrapper around message data received via the legacy IF-IMV interface
130 *
131 * @param agent IMV agent responsible for the message
132 * @param state IMV state for the given connection ID
133 * @param connection_id connection ID
134 * @param msg_type PA-TNC message type
135 * @param msg received PA-TNC message blob
136 */
137 imv_msg_t* imv_msg_create_from_data(imv_agent_t *agent, imv_state_t *state,
138 TNC_ConnectionID connection_id,
139 TNC_MessageType msg_type,
140 chunk_t msg);
141
142 /**
143 * Create a wrapper around message data received via the long IF-IMV interface
144 *
145 * @param agent IMV agent responsible for the message
146 * @param state IMV state for the given connection ID
147 * @param connection_id connection ID
148 * @param src_id source IMC ID
149 * @param dst_id destination IMV ID
150 * @param msg_flags PA-TNC message flags
151 * @param msg_vid PA-TNC message vendor ID
152 * @param msg_subtype PA-TNC subtype
153 * @param msg received PA-TNC message blob
154 */
155 imv_msg_t* imv_msg_create_from_long_data(imv_agent_t *agent, imv_state_t *state,
156 TNC_ConnectionID connection_id,
157 TNC_UInt32 src_id, TNC_UInt32 dst_id,
158 TNC_VendorID msg_vid,
159 TNC_MessageSubtype msg_subtype,
160 chunk_t msg);
161
162 #endif /** IMV_MSG_H_ @}*/