4 * @brief Definition of the encoding rules used when parsing or generating
10 * Copyright (C) 2005 Jan Hutter, Martin Willi
11 * Hochschule fuer Technik Rapperswil
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 #include "encodings.h"
28 #include "ike_header.h"
31 * Encoding rules to parse or generate a IKEv2-Header
33 * The defined offsets are the positions in a struct of type
37 encoding_rule_t ike_header_encodings
[] = {
38 /* 8 Byte SPI, stored in the field initiator_spi */
39 { U_INT_64
, offsetof(ike_header_t
, initiator_spi
) },
40 /* 8 Byte SPI, stored in the field responder_spi */
41 { U_INT_64
, offsetof(ike_header_t
, responder_spi
) },
42 /* 1 Byte next payload type, stored in the field next_payload */
43 { U_INT_8
, offsetof(ike_header_t
, next_payload
) },
44 /* 4 Bit major version, stored in the field maj_version */
45 { U_INT_4
, offsetof(ike_header_t
, maj_version
) },
46 /* 4 Bit minor version, stored in the field min_version */
47 { U_INT_4
, offsetof(ike_header_t
, min_version
) },
48 /* 8 Bit for the exchange type */
49 { U_INT_8
, offsetof(ike_header_t
, exchange_type
) },
50 /* 2 Bit reserved bits, nowhere stored */
53 /* 3 Bit flags, stored in the fields response, version and initiator */
54 { FLAG
, offsetof(ike_header_t
, flags
.response
) },
55 { FLAG
, offsetof(ike_header_t
, flags
.version
) },
56 { FLAG
, offsetof(ike_header_t
, flags
.initiator
) },
57 /* 3 Bit reserved bits, nowhere stored */
61 /* 4 Byte message id, stored in the field message_id */
62 { U_INT_32
, offsetof(ike_header_t
, message_id
) },
63 /* 4 Byte length fied, stored in the field length */
64 { LENGTH
, offsetof(ike_header_t
, length
) }
68 * This informations are needed for autmatic parsing of header content
70 payload_info_t ike_header_info
= {HEADER
,
73 (sizeof(ike_header_encodings
)/sizeof(encoding_rule_t
))};