- fixed bad SVN issues, should all work again now
[strongswan.git] / Source / charon / payloads / ike_header.c
1 /**
2 * @file ike_header.c
3 *
4 * @brief Definition of the encoding rules used when parsing or generating
5 * an IKEv2-Header
6 *
7 */
8
9 /*
10 * Copyright (C) 2005 Jan Hutter, Martin Willi
11 * Hochschule fuer Technik Rapperswil
12 *
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>.
17 *
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
21 * for more details.
22 */
23
24 /* offsetof macro */
25 #include <stddef.h>
26
27 #include "encodings.h"
28 #include "ike_header.h"
29
30 /**
31 * Encoding rules to parse or generate a IKEv2-Header
32 *
33 * The defined offsets are the positions in a struct of type
34 * ike_header_t.
35 *
36 */
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 */
51 { RESERVED_BIT, 0 },
52 { RESERVED_BIT, 0 },
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 */
58 { RESERVED_BIT, 0 },
59 { RESERVED_BIT, 0 },
60 { RESERVED_BIT, 0 },
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) }
65 };
66
67