2 * Copyright (C) 2007 Tobias Brunner
3 * Copyright (C) 2005-2006 Martin Willi
4 * Copyright (C) 2005 Jan Hutter
5 * Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * @defgroup payload payload
20 * @{ @ingroup payloads
26 typedef enum payload_type_t payload_type_t
;
27 typedef struct payload_t payload_t
;
30 #include <encoding/payloads/encodings.h>
34 * Payload-Types of an IKE message.
36 * Header and substructures are also defined as
37 * payload types with values from PRIVATE USE space.
42 * End of payload list in next_payload
47 * The security association (SA) payload containing proposals.
49 SECURITY_ASSOCIATION_V1
= 1,
52 * The proposal payload, containing transforms.
57 * The transform payload.
62 * The key exchange (KE) payload containing diffie-hellman values.
72 * Certificate payload with certificates (CERT).
77 * Certificate request payload.
79 CERTIFICATE_REQUEST_V1
= 7,
97 * Notification payload.
112 * The security association (SA) payload containing proposals.
114 SECURITY_ASSOCIATION
= 33,
117 * The key exchange (KE) payload containing diffie-hellman values.
122 * Identification for the original initiator (IDi).
127 * Identification for the original responder (IDr).
132 * Certificate payload with certificates (CERT).
137 * Certificate request payload (CERTREQ).
139 CERTIFICATE_REQUEST
= 38,
142 * Authentication payload contains auth data (AUTH).
147 * Nonces, for initiator and responder (Ni, Nr, N)
152 * Notify paylaod (N).
162 * Vendor id paylpoad (V).
167 * Traffic selector for the original initiator (TSi).
169 TRAFFIC_SELECTOR_INITIATOR
= 44,
172 * Traffic selector for the original responser (TSr).
174 TRAFFIC_SELECTOR_RESPONDER
= 45,
177 * Encryption payload, contains other payloads (E).
182 * Configuration payload (CP).
187 * Extensible authentication payload (EAP).
189 EXTENSIBLE_AUTHENTICATION
= 48,
193 * Identification payload for peers has a value from
194 * the PRIVATE USE space.
200 * Header has a value of PRIVATE USE space.
202 * This payload type is not sent over wire and just
203 * used internally to handle IKEv2-Header like a payload.
208 * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
210 * This payload type is not sent over wire and just
211 * used internally to handle a proposal substructure like a payload.
213 PROPOSAL_SUBSTRUCTURE
= 257,
216 * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space.
218 * This payload type is not sent over wire and just
219 * used internally to handle a transform substructure like a payload.
221 TRANSFORM_SUBSTRUCTURE
= 258,
224 * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
226 * This payload type is not sent over wire and just
227 * used internally to handle a transform attribute like a payload.
229 TRANSFORM_ATTRIBUTE
= 259,
232 * TRAFFIC_SELECTOR_SUBSTRUCTURE has a value of PRIVATE USE space.
234 * This payload type is not sent over wire and just
235 * used internally to handle a transform selector like a payload.
237 TRAFFIC_SELECTOR_SUBSTRUCTURE
= 260,
240 * CONFIGURATION_ATTRIBUTE has a value of PRIVATE USE space.
242 * This payload type is not sent over wire and just
243 * used internally to handle a transform attribute like a payload.
245 CONFIGURATION_ATTRIBUTE
= 261,
249 * enum names for payload_type_t.
251 extern enum_name_t
*payload_type_names
;
254 * enum names for payload_type_t in a short form.
256 extern enum_name_t
*payload_type_short_names
;
259 * Generic interface for all payload types (incl.header and substructures).
261 * To handle all kinds of payloads on a generic way, this interface must
262 * be implemented by every payload. This allows parser_t/generator_t a simple
263 * handling of all payloads.
268 * Get encoding rules for this payload.
270 * @param rules location to store pointer of first rule
271 * @param rule_count location to store number of rules
273 void (*get_encoding_rules
) (payload_t
*this, encoding_rule_t
**rules
, size_t *rule_count
);
276 * Get type of payload.
278 * @return type of this payload
280 payload_type_t (*get_type
) (payload_t
*this);
283 * Get type of next payload or NO_PAYLOAD (0) if this is the last one.
285 * @return type of next payload
287 payload_type_t (*get_next_type
) (payload_t
*this);
290 * Set type of next payload.
292 * @param type type of next payload
294 void (*set_next_type
) (payload_t
*this,payload_type_t type
);
297 * Get length of payload.
299 * @return length of this payload
301 size_t (*get_length
) (payload_t
*this);
304 * Verifies payload structure and makes consistence check.
306 * @return SUCCESS, FAILED if consistence not given
308 status_t (*verify
) (payload_t
*this);
311 * Destroys a payload and all included substructures.
313 void (*destroy
) (payload_t
*this);
317 * Create an empty payload.
319 * Useful for the parser, who wants a generic constructor for all payloads.
320 * It supports all payload_t methods. If a payload type is not known,
321 * an unknwon_paylod is created with the chunk of data in it.
323 * @param type type of the payload to create
324 * @return payload_t object
326 payload_t
*payload_create(payload_type_t type
);
329 * Check if a specific payload is implemented, or handled as unknown payload.
331 * @param type type of the payload to check
332 * @return FALSE if payload type handled as unknown payload
334 bool payload_is_known(payload_type_t type
);
337 * Get the value field in a payload using encoding rules.
339 * @param payload payload to look up a field
340 * @param type encoding rule type to look up
341 * @param skip number rules of type to skip, 0 to get first
342 * @return type specific value pointer, NULL if not found
344 void* payload_get_field(payload_t
*payload
, encoding_type_t type
, u_int skip
);
346 #endif /** PAYLOAD_H_ @}*/