4 * @brief Definition of encoding_type_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>
30 typedef enum encoding_type_t encoding_type_t
;
33 * @brief All different kinds of encoding types.
35 * Each field of an IKEv2-Message (in header or payload)
36 * which has to be parsed or generated differently has its own
39 * Header is parsed like a payload and gets its one payload_id
40 * from PRIVATE USE space. Also the substructures
41 * of specific payload types get their own payload_id
42 * from PRIVATE_USE space. See IKEv2-Draft for more informations.
46 enum encoding_type_t
{
49 * Representing a 4 Bit unsigned int value.
52 * When generating it must be changed from host to network order.
53 * The value is read from the associated data struct.
54 * The current write position is moved 4 bit forward afterwards.
56 * When parsing it must be changed from network to host order.
57 * The value is written to the associated data struct.
58 * The current read pointer is moved 4 bit forward afterwards.
63 * Representing a 8 Bit unsigned int value.
66 * When generating it must be changed from host to network order.
67 * The value is read from the associated data struct.
68 * The current write position is moved 8 bit forward afterwards.
70 * When parsing it must be changed from network to host order.
71 * The value is written to the associated data struct.
72 * The current read pointer is moved 8 bit forward afterwards.
77 * Representing a 16 Bit unsigned int value.
80 * When generating it must be changed from host to network order.
81 * The value is read from the associated data struct.
82 * The current write position is moved 16 bit forward afterwards.
84 * When parsing it must be changed from network to host order.
85 * The value is written to the associated data struct.
86 * The current read pointer is moved 16 bit forward afterwards.
91 * Representing a 32 Bit unsigned int value.
93 * When generating it must be changed from host to network order.
94 * The value is read from the associated data struct.
95 * The current write position is moved 32 bit forward afterwards.
97 * When parsing it must be changed from network to host order.
98 * The value is written to the associated data struct.
99 * The current read pointer is moved 32 bit forward afterwards.
104 * Representing a 64 Bit unsigned int value.
106 * When generating it must be changed from host to network order.
107 * The value is read from the associated data struct.
108 * The current write position is moved 64 bit forward afterwards.
110 * When parsing it must be changed from network to host order.
111 * The value is written to the associated data struct.
112 * The current read pointer is moved 64 bit forward afterwards.
117 * @brief represents a RESERVED_BIT used in FLAG-Bytes.
119 * When generating, the next bit is set to zero and the current write
120 * position is moved one bit forward.
121 * No value is read from the associated data struct.
122 * The current write position is moved 1 bit forward afterwards.
124 * When parsing, the current read pointer is moved one bit forward.
125 * No value is written to the associated data struct.
126 * The current read pointer is moved 1 bit forward afterwards.
131 * @brief represents a RESERVED_BYTE.
133 * When generating, the next byte is set to zero and the current write
134 * position is moved one byte forward.
135 * No value is read from the associated data struct.
136 * The current write position is moved 1 byte forward afterwards.
138 * When parsing, the current read pointer is moved one byte forward.
139 * No value is written to the associated data struct.
140 * The current read pointer is moved 1 byte forward afterwards.
145 * Representing a 1 Bit flag.
147 * When generation, the next bit is set to 1 if the associated value
148 * in the data struct is TRUE, 0 otherwise. The current write position
149 * is moved 1 bit forward afterwards.
151 * When parsing, the next bit is read and stored in the associated data
152 * struct. 0 means FALSE, 1 means TRUE, The current read pointer
153 * is moved 1 bit forward afterwards
158 * Representating a length field of a payload.
160 * When generating it must be changed from host to network order.
161 * The value is read from the associated data struct.
162 * The current write position is moved 16 bit forward afterwards.
164 * When parsing it must be changed from network to host order.
165 * The value is written to the associated data struct.
166 * The current read pointer is moved 16 bit forward afterwards.
171 * Representating a length field of a header.
173 * When generating it must be changed from host to network order.
174 * The value is read from the associated data struct.
175 * The current write position is moved 32 bit forward afterwards.
177 * When parsing it must be changed from network to host order.
178 * The value is written to the associated data struct.
179 * The current read pointer is moved 32 bit forward afterwards.
184 * Representating a spi size field.
186 * When generating it must be changed from host to network order.
187 * The value is read from the associated data struct.
188 * The current write position is moved 8 bit forward afterwards.
190 * When parsing it must be changed from network to host order.
191 * The value is written to the associated data struct.
192 * The current read pointer is moved 8 bit forward afterwards.
197 * Representating a spi field.
199 * When generating the content of the chunkt pointing to
202 * When parsing SPI_SIZE bytes are read and written into the chunk pointing to.
207 * Representating a Key Exchange Data field.
209 * When generating the content of the chunkt pointing to
212 * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
217 * Representating a Notification field.
219 * When generating the content of the chunkt pointing to
222 * When parsing (Payload Length - spi size - 8) bytes are read and written into the chunk pointing to.
227 * Representating one or more proposal substructures.
229 * The offset points to a linked_list_t pointer.
231 * When generating the proposal_substructure_t objects are stored
232 * in the pointed linked_list.
234 * When parsing the parsed proposal_substructure_t objects have
235 * to be stored in the pointed linked_list.
240 * Representating one or more transform substructures.
242 * The offset points to a linked_list_t pointer.
244 * When generating the transform_substructure_t objects are stored
245 * in the pointed linked_list.
247 * When parsing the parsed transform_substructure_t objects have
248 * to be stored in the pointed linked_list.
253 * Representating one or more Attributes of a transform substructure.
255 * The offset points to a linked_list_t pointer.
257 * When generating the transform_attribute_t objects are stored
258 * in the pointed linked_list.
260 * When parsing the parsed transform_attribute_t objects have
261 * to be stored in the pointed linked_list.
263 TRANSFORM_ATTRIBUTES
,
266 * Representating one or more Attributes of a configuration payload.
268 * The offset points to a linked_list_t pointer.
270 * When generating the configuration_attribute_t objects are stored
271 * in the pointed linked_list.
273 * When parsing the parsed configuration_attribute_t objects have
274 * to be stored in the pointed linked_list.
276 CONFIGURATION_ATTRIBUTES
,
280 * When generating the content of the chunkt pointing to
283 * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
285 CONFIGURATION_ATTRIBUTE_VALUE
,
288 * Representing a 1 Bit flag specifying the format of a transform attribute.
290 * When generation, the next bit is set to 1 if the associated value
291 * in the data struct is TRUE, 0 otherwise. The current write position
292 * is moved 1 bit forward afterwards.
294 * When parsing, the next bit is read and stored in the associated data
295 * struct. 0 means FALSE, 1 means TRUE, The current read pointer
296 * is moved 1 bit forward afterwards.
300 * Representing a 15 Bit unsigned int value used as attribute type
301 * in an attribute transform.
304 * When generating it must be changed from host to network order.
305 * The value is read from the associated data struct.
306 * The current write position is moved 15 bit forward afterwards.
308 * When parsing it must be changed from network to host order.
309 * The value is written to the associated data struct.
310 * The current read pointer is moved 15 bit forward afterwards.
315 * Depending on the field of type ATTRIBUTE_FORMAT
316 * this field contains the length or the value of an transform attribute.
317 * Its stored in a 16 unsigned integer field.
319 * When generating it must be changed from host to network order.
320 * The value is read from the associated data struct.
321 * The current write position is moved 16 bit forward afterwards.
323 * When parsing it must be changed from network to host order.
324 * The value is written to the associated data struct.
325 * The current read pointer is moved 16 bit forward afterwards.
327 ATTRIBUTE_LENGTH_OR_VALUE
,
330 * This field contains the length or the value of an configuration attribute.
331 * Its stored in a 16 unsigned integer field.
333 * When generating it must be changed from host to network order.
334 * The value is read from the associated data struct.
335 * The current write position is moved 16 bit forward afterwards.
337 * When parsing it must be changed from network to host order.
338 * The value is written to the associated data struct.
339 * The current read pointer is moved 16 bit forward afterwards.
341 CONFIGURATION_ATTRIBUTE_LENGTH
,
344 * Depending on the field of type ATTRIBUTE_FORMAT
345 * this field is available or missing and so parsed/generated
346 * or not parsed/not generated.
348 * When generating the content of the chunkt pointing to
351 * When parsing SPI_SIZE bytes are read and written into the chunk pointing to.
356 * Representating one or more Traffic selectors of a TS payload.
358 * The offset points to a linked_list_t pointer.
360 * When generating the traffic_selector_substructure_t objects are stored
361 * in the pointed linked_list.
363 * When parsing the parsed traffic_selector_substructure_t objects have
364 * to be stored in the pointed linked_list.
369 * Representating a Traffic selector type field.
371 * When generating it must be changed from host to network order.
372 * The value is read from the associated data struct.
373 * The current write position is moved 16 bit forward afterwards.
375 * When parsing it must be changed from network to host order.
376 * The value is written to the associated data struct.
377 * The current read pointer is moved 16 bit forward afterwards.
382 * Representating an address field in a traffic selector.
384 * Depending on the last field of type TS_TYPE
385 * this field is either 4 or 16 byte long.
387 * When generating the content of the chunkt pointing to
390 * When parsing 4 or 16 bytes are read and written into the chunk pointing to.
395 * Representating a Nonce Data field.
397 * When generating the content of the chunkt pointing to
400 * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
405 * Representating a ID Data field.
407 * When generating the content of the chunkt pointing to
410 * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
415 * Representating a AUTH Data field.
417 * When generating the content of the chunkt pointing to
420 * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
425 * Representating a CERT Data field.
427 * When generating the content of the chunkt pointing to
430 * When parsing (Payload Length - 5) bytes are read and written into the chunk pointing to.
435 * Representating a CERTREQ Data field.
437 * When generating the content of the chunkt pointing to
440 * When parsing (Payload Length - 5) bytes are read and written into the chunk pointing to.
445 * Representating an EAP message field.
447 * When generating the content of the chunkt pointing to
450 * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
455 * Representating the SPIS field in a DELETE payload.
457 * When generating the content of the chunkt pointing to
460 * When parsing (Payload Length - 8) bytes are read and written into the chunk pointing to.
465 * Representating the VID DATA field in a VENDOR ID payload.
467 * When generating the content of the chunkt pointing to
470 * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
475 * Representating the DATA of an unknown payload.
477 * When generating the content of the chunkt pointing to
480 * When parsing (Payload Length - 4) bytes are read and written into the chunk pointing to.
485 * Representating an IKE_SPI field in an IKEv2 Header.
487 * When generating the value of the u_int64_t pointing to
488 * is written (host and networ order is not changed).
490 * When parsing 8 bytes are read and written into the u_int64_t pointing to.
495 * Representing the encrypted data body of a encryption payload.
501 * mappings to map encoding_type_t's to strings
505 extern mapping_t encoding_type_m
[];
508 typedef struct encoding_rule_t encoding_rule_t
;
511 * An encoding rule is a mapping of a specific encoding type to
512 * a location in the data struct where the current field is stored to
515 * For examples see files in this directory.
517 * This rules are used by parser and generator.
521 struct encoding_rule_t
{
526 encoding_type_t type
;
529 * Offset in the data struct.
531 * When parsing, data are written to this offset of the
534 * When generating, data are read from this offset in the
540 #endif /*ENCODINGS_H_*/