]> git.ipfire.org Git - people/ms/strongswan.git/blob - programs/charon/charon/encoding/payloads/payload.h
- import of strongswan-2.7.0
[people/ms/strongswan.git] / programs / charon / charon / encoding / payloads / payload.h
1 /**
2 * @file payload.h
3 *
4 * @brief Interface payload_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef PAYLOAD_H_
24 #define PAYLOAD_H_
25
26 #include <types.h>
27 #include <definitions.h>
28 #include <encoding/payloads/encodings.h>
29
30
31 typedef enum payload_type_t payload_type_t;
32
33 /**
34 * @brief Payload-Types of a IKEv2-Message.
35 *
36 * Header and substructures are also defined as
37 * payload types with values from PRIVATE USE space.
38 *
39 * @ingroup payloads
40 */
41 enum payload_type_t{
42
43 /**
44 * End of payload list in next_payload
45 */
46 NO_PAYLOAD = 0,
47
48 /**
49 * The security association (SA) payload containing proposals.
50 */
51 SECURITY_ASSOCIATION = 33,
52
53 /**
54 * The key exchange (KE) payload containing diffie-hellman values.
55 */
56 KEY_EXCHANGE = 34,
57
58 /**
59 * Identification for the original initiator (IDi).
60 */
61 ID_INITIATOR = 35,
62
63 /**
64 * Identification for the original responder (IDr).
65 */
66 ID_RESPONDER = 36,
67
68 /**
69 * Certificate payload with certificates (CERT).
70 */
71 CERTIFICATE = 37,
72
73 /**
74 * Certificate request payload (CERTREQ).
75 */
76 CERTIFICATE_REQUEST = 38,
77
78 /**
79 * Authentication payload contains auth data (AUTH).
80 */
81 AUTHENTICATION = 39,
82
83 /**
84 * Nonces, for initator and responder (Ni, Nr, N)
85 */
86 NONCE = 40,
87
88 /**
89 * Notif paylaod (N).
90 */
91 NOTIFY = 41,
92
93 /**
94 * Delete payload (D)
95 */
96 DELETE = 42,
97
98 /**
99 * Vendor id paylpoad (V).
100 */
101 VENDOR_ID = 43,
102
103 /**
104 * Traffic selector for the original initiator (TSi).
105 */
106 TRAFFIC_SELECTOR_INITIATOR = 44,
107
108 /**
109 * Traffic selector for the original responser (TSr).
110 */
111 TRAFFIC_SELECTOR_RESPONDER = 45,
112
113 /**
114 * Encryption payload, contains other payloads (E).
115 */
116 ENCRYPTED = 46,
117
118 /**
119 * Configuration payload (CP).
120 */
121 CONFIGURATION = 47,
122
123 /**
124 * Extensible authentication payload (EAP).
125 */
126 EXTENSIBLE_AUTHENTICATION = 48,
127
128 /**
129 * Header has a value of PRIVATE USE space.
130 *
131 * This payload type is not send over wire and just
132 * used internally to handle IKEv2-Header like a payload.
133 */
134 HEADER = 140,
135
136 /**
137 * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
138 *
139 * This payload type is not send over wire and just
140 * used internally to handle a proposal substructure like a payload.
141 */
142 PROPOSAL_SUBSTRUCTURE = 141,
143
144 /**
145 * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space.
146 *
147 * This payload type is not send over wire and just
148 * used internally to handle a transform substructure like a payload.
149 */
150 TRANSFORM_SUBSTRUCTURE = 142,
151
152 /**
153 * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
154 *
155 * This payload type is not send over wire and just
156 * used internally to handle a transform attribute like a payload.
157 */
158 TRANSFORM_ATTRIBUTE = 143,
159
160 /**
161 * TRAFFIC_SELECTOR_SUBSTRUCTURE has a value of PRIVATE USE space.
162 *
163 * This payload type is not send over wire and just
164 * used internally to handle a transform selector like a payload.
165 */
166 TRAFFIC_SELECTOR_SUBSTRUCTURE = 144,
167
168 /**
169 * CONFIGURATION_ATTRIBUTE has a value of PRIVATE USE space.
170 *
171 * This payload type is not send over wire and just
172 * used internally to handle a transform attribute like a payload.
173 */
174 CONFIGURATION_ATTRIBUTE = 145,
175
176 /**
177 * A unknown payload has a value of PRIVATE USE space.
178 *
179 * This payload type is not send over wire and just
180 * used internally to handle a unknown payload.
181 */
182 UNKNOWN_PAYLOAD = 146,
183 };
184
185
186 /**
187 * String mappings for payload_type_t.
188 */
189 extern mapping_t payload_type_m[];
190
191
192 typedef struct payload_t payload_t;
193
194 /**
195 * @brief Generic interface for all payload types (incl.header and substructures).
196 *
197 * To handle all kinds of payloads on a generic way, this interface must
198 * be implemented by every payload. This allows parser_t/generator_t a simple
199 * handling of all payloads.
200 *
201 * @b Constructors:
202 * - payload_create() with the payload to instanciate.
203 *
204 * @ingroup payloads
205 */
206 struct payload_t {
207
208 /**
209 * @brief Get encoding rules for this payload.
210 *
211 * @param this calling object
212 * @param[out] rules location to store pointer of first rule
213 * @param[out] rule_count location to store number of rules
214 */
215 void (*get_encoding_rules) (payload_t *this, encoding_rule_t **rules, size_t *rule_count);
216
217 /**
218 * @brief Get type of payload.
219 *
220 * @param this calling object
221 * @return type of this payload
222 */
223 payload_type_t (*get_type) (payload_t *this);
224
225 /**
226 * @brief Get type of next payload or NO_PAYLOAD (0) if this is the last one.
227 *
228 * @param this calling object
229 * @return type of next payload
230 */
231 payload_type_t (*get_next_type) (payload_t *this);
232
233 /**
234 * @brief Set type of next payload.
235 *
236 * @param this calling object
237 * @param type type of next payload
238 */
239 void (*set_next_type) (payload_t *this,payload_type_t type);
240
241 /**
242 * @brief Get length of payload.
243 *
244 * @param this calling object
245 * @return length of this payload
246 */
247 size_t (*get_length) (payload_t *this);
248
249 /**
250 * @brief Verifies payload structure and makes consistence check.
251 *
252 * @param this calling object
253 * @return
254 * - SUCCESS
255 * - FAILED if consistence not given
256 */
257 status_t (*verify) (payload_t *this);
258
259 /**
260 * @brief Destroys a payload and all included substructures.
261 *
262 * @param this payload to destroy
263 */
264 void (*destroy) (payload_t *this);
265 };
266
267 /**
268 * @brief Create an empty payload.
269 *
270 * Useful for the parser, who wants a generic constructor for all payloads.
271 * It supports all payload_t methods. If a payload type is not known,
272 * an unknwon_paylod is created with the chunk of data in it.
273 *
274 * @param type type of the payload to create
275 * @return payload_t object
276 */
277 payload_t *payload_create(payload_type_t type);
278
279 #endif /*PAYLOAD_H_*/