2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * @defgroup encodings encodings
19 * @{ @ingroup payloads
25 typedef enum encoding_type_t encoding_type_t
;
26 typedef struct encoding_rule_t encoding_rule_t
;
31 * All different kinds of encoding types.
33 * Each field of an IKEv2-Message (in header or payload)
34 * which has to be parsed or generated differently has its own
37 * Header is parsed like a payload and gets its one payload_id
38 * from PRIVATE USE space. Also the substructures
39 * of specific payload types get their own payload_id
40 * from PRIVATE_USE space. See IKEv2-Draft for more informations.
42 enum encoding_type_t
{
45 * Representing a 4 Bit unsigned int value.
48 * When generating it must be changed from host to network order.
49 * The value is read from the associated data struct.
50 * The current write position is moved 4 bit forward afterwards.
52 * When parsing it must be changed from network to host order.
53 * The value is written to the associated data struct.
54 * The current read pointer is moved 4 bit forward afterwards.
59 * Representing a 8 Bit unsigned int value.
62 * When generating it must be changed from host to network order.
63 * The value is read from the associated data struct.
64 * The current write position is moved 8 bit forward afterwards.
66 * When parsing it must be changed from network to host order.
67 * The value is written to the associated data struct.
68 * The current read pointer is moved 8 bit forward afterwards.
73 * Representing a 16 Bit unsigned int value.
76 * When generating it must be changed from host to network order.
77 * The value is read from the associated data struct.
78 * The current write position is moved 16 bit forward afterwards.
80 * When parsing it must be changed from network to host order.
81 * The value is written to the associated data struct.
82 * The current read pointer is moved 16 bit forward afterwards.
87 * Representing a 32 Bit unsigned int value.
89 * When generating it must be changed from host to network order.
90 * The value is read from the associated data struct.
91 * The current write position is moved 32 bit forward afterwards.
93 * When parsing it must be changed from network to host order.
94 * The value is written to the associated data struct.
95 * The current read pointer is moved 32 bit forward afterwards.
100 * represents a RESERVED_BIT used in FLAG-Bytes.
102 * When generating, the next bit is set to zero and the current write
103 * position is moved one bit forward.
104 * No value is read from the associated data struct.
105 * The current write position is moved 1 bit forward afterwards.
107 * When parsing, the current read pointer is moved one bit forward.
108 * No value is written to the associated data struct.
109 * The current read pointer is moved 1 bit forward afterwards.
114 * represents a RESERVED_BYTE.
116 * When generating, the next byte is set to zero and the current write
117 * position is moved one byte forward.
118 * No value is read from the associated data struct.
119 * The current write position is moved 1 byte forward afterwards.
121 * When parsing, the current read pointer is moved one byte forward.
122 * No value is written to the associated data struct.
123 * The current read pointer is moved 1 byte forward afterwards.
128 * Representing a 1 Bit flag.
130 * When generation, the next bit is set to 1 if the associated value
131 * in the data struct is TRUE, 0 otherwise. The current write position
132 * is moved 1 bit forward afterwards.
134 * When parsing, the next bit is read and stored in the associated data
135 * struct. 0 means FALSE, 1 means TRUE, The current read pointer
136 * is moved 1 bit forward afterwards
141 * Representating a length field of a payload.
143 * When generating it must be changed from host to network order.
144 * The value is read from the associated data struct.
145 * The current write position is moved 16 bit forward afterwards.
147 * When parsing it must be changed from network to host order.
148 * The value is written to the associated data struct.
149 * The current read pointer is moved 16 bit forward afterwards.
154 * Representating a length field of a header.
156 * When generating it must be changed from host to network order.
157 * The value is read from the associated data struct.
158 * The current write position is moved 32 bit forward afterwards.
160 * When parsing it must be changed from network to host order.
161 * The value is written to the associated data struct.
162 * The current read pointer is moved 32 bit forward afterwards.
167 * Representating a spi size field.
169 * When generating it must be changed from host to network order.
170 * The value is read from the associated data struct.
171 * The current write position is moved 8 bit forward afterwards.
173 * When parsing it must be changed from network to host order.
174 * The value is written to the associated data struct.
175 * The current read pointer is moved 8 bit forward afterwards.
180 * Representating a spi field.
182 * When generating the content of the chunkt pointing to
185 * When parsing SPI_SIZE bytes are read and written into the chunk pointing to.
190 * Representing a 1 Bit flag specifying the format of a transform attribute.
192 * When generation, the next bit is set to 1 if the associated value
193 * in the data struct is TRUE, 0 otherwise. The current write position
194 * is moved 1 bit forward afterwards.
196 * When parsing, the next bit is read and stored in the associated data
197 * struct. 0 means FALSE, 1 means TRUE, The current read pointer
198 * is moved 1 bit forward afterwards.
203 * Representing a 15 Bit unsigned int value used as attribute type
204 * in an attribute transform.
207 * When generating it must be changed from host to network order.
208 * The value is read from the associated data struct.
209 * The current write position is moved 15 bit forward afterwards.
211 * When parsing it must be changed from network to host order.
212 * The value is written to the associated data struct.
213 * The current read pointer is moved 15 bit forward afterwards.
218 * Depending on the field of type ATTRIBUTE_FORMAT
219 * this field contains the length or the value of an transform attribute.
220 * Its stored in a 16 unsigned integer field.
222 * When generating it must be changed from host to network order.
223 * The value is read from the associated data struct.
224 * The current write position is moved 16 bit forward afterwards.
226 * When parsing it must be changed from network to host order.
227 * The value is written to the associated data struct.
228 * The current read pointer is moved 16 bit forward afterwards.
230 ATTRIBUTE_LENGTH_OR_VALUE
,
233 * This field contains the length or the value of an configuration attribute.
234 * Its stored in a 16 unsigned integer field.
236 * When generating it must be changed from host to network order.
237 * The value is read from the associated data struct.
238 * The current write position is moved 16 bit forward afterwards.
240 * When parsing it must be changed from network to host order.
241 * The value is written to the associated data struct.
242 * The current read pointer is moved 16 bit forward afterwards.
244 CONFIGURATION_ATTRIBUTE_LENGTH
,
247 * Depending on the field of type ATTRIBUTE_FORMAT
248 * this field is available or missing and so parsed/generated
249 * or not parsed/not generated.
251 * When generating the content of the chunkt pointing to
254 * When parsing SPI_SIZE bytes are read and written into the chunk pointing to.
259 * Representating a Traffic selector type field.
261 * When generating it must be changed from host to network order.
262 * The value is read from the associated data struct.
263 * The current write position is moved 16 bit forward afterwards.
265 * When parsing it must be changed from network to host order.
266 * The value is written to the associated data struct.
267 * The current read pointer is moved 16 bit forward afterwards.
272 * Representating an address field in a traffic selector.
274 * Depending on the last field of type TS_TYPE
275 * this field is either 4 or 16 byte long.
277 * When generating the content of the chunkt pointing to
280 * When parsing 4 or 16 bytes are read and written into the chunk pointing to.
285 * Representing a variable length byte field.
290 * Representating an IKE_SPI field in an IKEv2 Header.
292 * When generating the value of the u_int64_t pointing to
293 * is written (host and networ order is not changed).
295 * When parsing 8 bytes are read and written into the u_int64_t pointing to.
300 * Reprensenting a field containing a set of wrapped payloads.
302 * This type is not used directly, but as an offset to the wrapped payloads.
303 * The type of the wrapped payload is added to this encoding type.
305 * @note As payload types are added to this encoding type, it has
306 * to be the last in encoding_type_t.
308 PAYLOAD_LIST
= 1000 /* no comma, read above! */
312 * enum name for encoding_type_t
314 extern enum_name_t
*encoding_type_names
;
317 * Rule how to en-/decode a payload field.
319 * An encoding rule is a mapping of a specific encoding type to
320 * a location in the data struct where the current field is stored to
322 * This rules are used by parser and generator.
324 struct encoding_rule_t
{
329 encoding_type_t type
;
332 * Offset in the data struct.
334 * When parsing, data are written to this offset of the
337 * When generating, data are read from this offset in the
343 #endif /** ENCODINGS_H_ @}*/