]> git.ipfire.org Git - people/ms/strongswan.git/blob - src/charon/charon/encoding/payloads/ike_header.h
(no commit message)
[people/ms/strongswan.git] / src / charon / charon / encoding / payloads / ike_header.h
1 /**
2 * @file ike_header.h
3 *
4 * @brief Interface of ike_header_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
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>.
16 *
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
20 * for more details.
21 */
22
23 #ifndef IKE_HEADER_H_
24 #define IKE_HEADER_H_
25
26 #include <types.h>
27 #include <encoding/payloads/payload.h>
28
29 /**
30 * Major Version of IKEv2.
31 *
32 * @ingroup payloads
33 */
34 #define IKE_MAJOR_VERSION 2
35
36 /**
37 * Minor Version of IKEv2.
38 *
39 * @ingroup payloads
40 */
41 #define IKE_MINOR_VERSION 0
42
43 /**
44 * Flag in IKEv2-Header. Always 0.
45 *
46 * @ingroup payloads
47 */
48 #define HIGHER_VERSION_SUPPORTED_FLAG 0
49
50 /**
51 * Length of IKE Header in Bytes.
52 *
53 * @ingroup payloads
54 */
55 #define IKE_HEADER_LENGTH 28
56
57 typedef enum exchange_type_t exchange_type_t;
58
59 /**
60 * @brief Different types of IKE-Exchanges.
61 *
62 * See Draft for different types.
63 *
64 * @ingroup payloads
65 */
66 enum exchange_type_t{
67
68 /**
69 * EXCHANGE_TYPE_UNDEFINED. In private space, since not a official message type.
70 */
71 EXCHANGE_TYPE_UNDEFINED = 240,
72
73 /**
74 * IKE_SA_INIT.
75 */
76 IKE_SA_INIT = 34,
77
78 /**
79 * IKE_AUTH.
80 */
81 IKE_AUTH = 35,
82
83 /**
84 * CREATE_CHILD_SA.
85 */
86 CREATE_CHILD_SA = 36,
87
88 /**
89 * INFORMATIONAL.
90 */
91 INFORMATIONAL = 37
92 };
93
94 /**
95 * string mappings for exchange_type_t
96 *
97 * @ingroup payloads
98 */
99 extern mapping_t exchange_type_m[];
100
101
102 typedef struct ike_header_t ike_header_t;
103
104 /**
105 * @brief An object of this type represents an IKEv2 header and is used to
106 * generate and parse IKEv2 headers.
107 *
108 * The header format of an IKEv2-Message is compatible to the
109 * ISAKMP-Header format to allow implementations supporting
110 * both versions of the IKE-protocol.
111 *
112 * @b Constructors:
113 * - ike_header_create()
114 *
115 * @ingroup payloads
116 */
117 struct ike_header_t {
118 /**
119 * The payload_t interface.
120 */
121 payload_t payload_interface;
122
123 /**
124 * @brief Get the initiator spi.
125 *
126 * @param this ike_header_t object
127 * @return initiator_spi
128 */
129 u_int64_t (*get_initiator_spi) (ike_header_t *this);
130
131 /**
132 * @brief Set the initiator spi.
133 *
134 * @param this ike_header_t object
135 * @param initiator_spi initiator_spi
136 */
137 void (*set_initiator_spi) (ike_header_t *this, u_int64_t initiator_spi);
138
139 /**
140 * @brief Get the responder spi.
141 *
142 * @param this ike_header_t object
143 * @return responder_spi
144 */
145 u_int64_t (*get_responder_spi) (ike_header_t *this);
146
147 /**
148 * @brief Set the responder spi.
149 *
150 * @param this ike_header_t object
151 * @param responder_spi responder_spi
152 */
153 void (*set_responder_spi) (ike_header_t *this, u_int64_t responder_spi);
154
155 /**
156 * @brief Get the major version.
157 *
158 * @param this ike_header_t object
159 * @return major version
160 */
161 u_int8_t (*get_maj_version) (ike_header_t *this);
162
163 /**
164 * @brief Get the minor version.
165 *
166 * @param this ike_header_t object
167 * @return minor version
168 */
169 u_int8_t (*get_min_version) (ike_header_t *this);
170
171 /**
172 * @brief Get the response flag.
173 *
174 * @param this ike_header_t object
175 * @return response flag
176 */
177 bool (*get_response_flag) (ike_header_t *this);
178
179 /**
180 * @brief Set the response flag-
181 *
182 * @param this ike_header_t object
183 * @param response response flag
184 *
185 */
186 void (*set_response_flag) (ike_header_t *this, bool response);
187 /**
188 * @brief Get "higher version supported"-flag.
189 *
190 * @param this ike_header_t object
191 * @return version flag
192 */
193 bool (*get_version_flag) (ike_header_t *this);
194
195 /**
196 * @brief Get the initiator flag.
197 *
198 * @param this ike_header_t object
199 * @return initiator flag
200 */
201 bool (*get_initiator_flag) (ike_header_t *this);
202
203 /**
204 * @brief Set the initiator flag.
205 *
206 * @param this ike_header_t object
207 * @param initiator initiator flag
208 *
209 */
210 void (*set_initiator_flag) (ike_header_t *this, bool initiator);
211
212 /**
213 * @brief Get the exchange type.
214 *
215 * @param this ike_header_t object
216 * @return exchange type
217 */
218 u_int8_t (*get_exchange_type) (ike_header_t *this);
219
220 /**
221 * @brief Set the exchange type.
222 *
223 * @param this ike_header_t object
224 * @param exchange_type exchange type
225 */
226 void (*set_exchange_type) (ike_header_t *this, u_int8_t exchange_type);
227
228 /**
229 * @brief Get the message id.
230 *
231 * @param this ike_header_t object
232 * @return message id
233 */
234 u_int32_t (*get_message_id) (ike_header_t *this);
235
236 /**
237 * @brief Set the message id.
238 *
239 * @param this ike_header_t object
240 * @param initiator_spi message id
241 */
242 void (*set_message_id) (ike_header_t *this, u_int32_t message_id);
243
244 /**
245 * @brief Destroys a ike_header_t object.
246 *
247 * @param this ike_header_t object to destroy
248 */
249 void (*destroy) (ike_header_t *this);
250 };
251
252 /**
253 * @brief Create an ike_header_t object
254 *
255 * @return ike_header_t object
256 *
257 * @ingroup payloads
258 */
259 ike_header_t *ike_header_create(void);
260
261 #endif /*IKE_HEADER_H_*/