- parser succesfully parses sa payload
[strongswan.git] / Source / charon / payloads / ike_header.h
1 /**
2 * @file ike_header.h
3 *
4 * @brief Declaration of the class ike_header_t.
5 *
6 * An object of this type represents an ike header and is used to
7 * generate and parse ike headers.
8 *
9 */
10
11 /*
12 * Copyright (C) 2005 Jan Hutter, Martin Willi
13 * Hochschule fuer Technik Rapperswil
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * for more details.
24 */
25
26 #ifndef IKE_HEADER_H_
27 #define IKE_HEADER_H_
28
29 #include "../types.h"
30 #include "payload.h"
31
32 /**
33 * Major Version of IKEv2
34 */
35 #define IKE_MAJOR_VERSION 2
36
37 /**
38 * Minor Version of IKEv2
39 */
40 #define IKE_MINOR_VERSION 0
41
42 /**
43 * Flag in IKEv2-Header. Always 0
44 */
45 #define HIGHER_VERSION_SUPPORTED_FLAG 0
46
47 /**
48 * Length of IKE Header in Bytes
49 */
50 #define IKE_HEADER_LENGTH 28
51
52 /**
53 * @brief Different types of IKE-Exchanges.
54 *
55 * See RFC for different types.
56 */
57 typedef enum exchange_type_e exchange_type_t;
58
59 enum exchange_type_e{
60
61 /**
62 * NOT_SET, not a official message type :-)
63 */
64 NOT_SET = 0,
65
66 /**
67 * IKE_SA_INIT
68 */
69 IKE_SA_INIT = 34,
70 /**
71 * IKE_AUTH
72 */
73 IKE_AUTH = 35,
74 /**
75 * CREATE_CHILD_SA
76 */
77 CREATE_CHILD_SA = 36,
78 /**
79 * INFORMATIONAL
80 */
81 INFORMATIONAL = 37
82 };
83
84 /**
85 * Object representing an IKEv2-Header
86 *
87 * The header format of an IKEv2-Message is compatible to the
88 * ISAKMP-Header format to allow implementations supporting
89 * both versions of the IKE-protocol.
90 *
91 */
92 typedef struct ike_header_s ike_header_t;
93
94 struct ike_header_s {
95 /**
96 * implements payload_t interface
97 */
98 payload_t payload_interface;
99 /**
100 * SPI of the initiator
101 */
102 u_int64_t initiator_spi;
103 /**
104 * SPI of the responder
105 */
106 u_int64_t responder_spi;
107 /**
108 * next payload type
109 */
110 u_int8_t next_payload;
111 /**
112 * IKE major version
113 */
114 u_int8_t maj_version;
115
116 /**
117 * IKE minor version
118 */
119 u_int8_t min_version;
120
121 /**
122 * Exchange type
123 */
124 u_int8_t exchange_type;
125
126 /**
127 * Flags of the Message
128 *
129 */
130 struct {
131 /**
132 * Sender is initiator of the associated IKE_SA_INIT-Exchange
133 */
134 bool initiator;
135 /**
136 * is protocol supporting higher version?
137 */
138 bool version;
139 /**
140 * TRUE, if this is a response, FALSE if its a Request
141 */
142 bool response;
143 } flags;
144 /**
145 * Associated Message-ID
146 */
147 u_int32_t message_id;
148 /**
149 * Length of the whole IKEv2-Message (header and all payloads)
150 */
151 u_int32_t length;
152
153 /**
154 * @brief Destroys a ike_header_t object.
155 *
156 * @param this ike_header_t object to destroy
157 * @return
158 * SUCCESS in any case
159 */
160 status_t (*destroy) (ike_header_t *this);
161 };
162
163 /**
164 * @brief Create an ike_header_t object
165 *
166 * @return
167 * - created ike_header, or
168 * - NULL if failed
169 */
170
171 ike_header_t *ike_header_create();
172
173 #endif /*IKE_HEADER_H_*/