4 * @brief Interface payload_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
27 #include <definitions.h>
28 #include <encoding/payloads/encodings.h>
31 typedef enum payload_type_t payload_type_t
;
34 * @brief Payload-Types of a IKEv2-Message.
36 * Header and substructures are also defined as
37 * payload types with values from PRIVATE USE space.
44 * End of payload list in next_payload
49 * The security association (SA) payload containing proposals.
51 SECURITY_ASSOCIATION
= 33,
54 * The key exchange (KE) payload containing diffie-hellman values.
59 * Identification for the original initiator (IDi).
64 * Identification for the original responder (IDr).
69 * Certificate payload with certificates (CERT).
74 * Certificate request payload (CERTREQ).
76 CERTIFICATE_REQUEST
= 38,
79 * Authentication payload contains auth data (AUTH).
84 * Nonces, for initator and responder (Ni, Nr, N)
99 * Vendor id paylpoad (V).
104 * Traffic selector for the original initiator (TSi).
106 TRAFFIC_SELECTOR_INITIATOR
= 44,
109 * Traffic selector for the original responser (TSr).
111 TRAFFIC_SELECTOR_RESPONDER
= 45,
114 * Encryption payload, contains other payloads (E).
119 * Configuration payload (CP).
124 * Extensible authentication payload (EAP).
126 EXTENSIBLE_AUTHENTICATION
= 48,
129 * Header has a value of PRIVATE USE space.
131 * This payload type is not send over wire and just
132 * used internally to handle IKEv2-Header like a payload.
137 * PROPOSAL_SUBSTRUCTURE has a value of PRIVATE USE space.
139 * This payload type is not send over wire and just
140 * used internally to handle a proposal substructure like a payload.
142 PROPOSAL_SUBSTRUCTURE
= 141,
145 * TRANSFORM_SUBSTRUCTURE has a value of PRIVATE USE space.
147 * This payload type is not send over wire and just
148 * used internally to handle a transform substructure like a payload.
150 TRANSFORM_SUBSTRUCTURE
= 142,
153 * TRANSFORM_ATTRIBUTE has a value of PRIVATE USE space.
155 * This payload type is not send over wire and just
156 * used internally to handle a transform attribute like a payload.
158 TRANSFORM_ATTRIBUTE
= 143,
161 * TRAFFIC_SELECTOR_SUBSTRUCTURE has a value of PRIVATE USE space.
163 * This payload type is not send over wire and just
164 * used internally to handle a transform selector like a payload.
166 TRAFFIC_SELECTOR_SUBSTRUCTURE
= 144,
169 * CONFIGURATION_ATTRIBUTE has a value of PRIVATE USE space.
171 * This payload type is not send over wire and just
172 * used internally to handle a transform attribute like a payload.
174 CONFIGURATION_ATTRIBUTE
= 145,
177 * A unknown payload has a value of PRIVATE USE space.
179 * This payload type is not send over wire and just
180 * used internally to handle a unknown payload.
182 UNKNOWN_PAYLOAD
= 146,
187 * String mappings for payload_type_t.
189 extern mapping_t payload_type_m
[];
192 typedef struct payload_t payload_t
;
195 * @brief Generic interface for all payload types (incl.header and substructures).
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.
202 * - payload_create() with the payload to instanciate.
209 * @brief Get encoding rules for this payload.
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
215 void (*get_encoding_rules
) (payload_t
*this, encoding_rule_t
**rules
, size_t *rule_count
);
218 * @brief Get type of payload.
220 * @param this calling object
221 * @return type of this payload
223 payload_type_t (*get_type
) (payload_t
*this);
226 * @brief Get type of next payload or NO_PAYLOAD (0) if this is the last one.
228 * @param this calling object
229 * @return type of next payload
231 payload_type_t (*get_next_type
) (payload_t
*this);
234 * @brief Set type of next payload.
236 * @param this calling object
237 * @param type type of next payload
239 void (*set_next_type
) (payload_t
*this,payload_type_t type
);
242 * @brief Get length of payload.
244 * @param this calling object
245 * @return length of this payload
247 size_t (*get_length
) (payload_t
*this);
250 * @brief Verifies payload structure and makes consistence check.
252 * @param this calling object
255 * - FAILED if consistence not given
257 status_t (*verify
) (payload_t
*this);
260 * @brief Destroys a payload and all included substructures.
262 * @param this payload to destroy
264 void (*destroy
) (payload_t
*this);
268 * @brief Create an empty payload.
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.
274 * @param type type of the payload to create
275 * @return payload_t object
277 payload_t
*payload_create(payload_type_t type
);
279 #endif /*PAYLOAD_H_*/