- test of header payload rewritten
[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 /**
101 * @brief get the next payload type
102 *
103 * @param this ike_header_t object
104 * @return next payload type
105 */
106 u_int8_t (*get_next_payload) (ike_header_t *this);
107
108 /**
109 * @brief set the next payload
110 *
111 * @param this ike_header_t object
112 * @param next_payload next payload type
113 */
114 void (*set_next_payload) (ike_header_t *this, u_int8_t next_payload);
115
116 /**
117 * @brief get the initiator spi
118 *
119 * @param this ike_header_t object
120 * @return initiator_spi
121 */
122 u_int64_t (*get_initiator_spi) (ike_header_t *this);
123
124 /**
125 * @brief set the initiator spi
126 *
127 * @param this ike_header_t object
128 * @param initiator_spi initiator_spi
129 */
130 void (*set_initiator_spi) (ike_header_t *this, u_int64_t initiator_spi);
131
132 /**
133 * @brief get the responder spi
134 *
135 * @param this ike_header_t object
136 * @return responder_spi
137 */
138 u_int64_t (*get_responder_spi) (ike_header_t *this);
139
140 /**
141 * @brief set the responder spi
142 *
143 * @param this ike_header_t object
144 * @param responder_spi responder_spi
145 */
146 void (*set_responder_spi) (ike_header_t *this, u_int64_t responder_spi);
147
148 /**
149 * @brief get the major version
150 *
151 * @param this ike_header_t object
152 * @return major version
153 */
154 u_int8_t (*get_maj_version) (ike_header_t *this);
155
156 /**
157 * @brief get the mainor version
158 *
159 * @param this ike_header_t object
160 * @return minor version
161 */
162 u_int8_t (*get_min_version) (ike_header_t *this);
163
164 /**
165 * @brief get the response flag
166 *
167 * @param this ike_header_t object
168 * @return response flag
169 */
170 bool (*get_response_flag) (ike_header_t *this);
171
172 /**
173 * @brief Set the response flag
174 *
175 * @param this ike_header_t object
176 * @param response response flag
177 *
178 */
179 void (*set_response_flag) (ike_header_t *this, bool response);
180 /**
181 * @brief get "higher version supported"-flag
182 *
183 * @param this ike_header_t object
184 * @return version flag
185 */
186 bool (*get_version_flag) (ike_header_t *this);
187
188 /**
189 * @brief get the initiator flag
190 *
191 * @param this ike_header_t object
192 * @return initiator flag
193 */
194 bool (*get_initiator_flag) (ike_header_t *this);
195
196 /**
197 * @brief Set the initiator flag
198 *
199 * @param this ike_header_t object
200 * @param initiator initiator flag
201 *
202 */
203 void (*set_initiator_flag) (ike_header_t *this, bool initiator);
204
205 /**
206 * @brief get the exchange type
207 *
208 * @param this ike_header_t object
209 * @return exchange type
210 */
211 u_int8_t (*get_exchange_type) (ike_header_t *this);
212
213 /**
214 * @brief set the exchange type
215 *
216 * @param this ike_header_t object
217 * @param exchange_type exchange type
218 */
219 void (*set_exchange_type) (ike_header_t *this, u_int8_t exchange_type);
220
221 /**
222 * @brief get the message id
223 *
224 * @param this ike_header_t object
225 * @return message id
226 */
227 u_int32_t (*get_message_id) (ike_header_t *this);
228
229 /**
230 * @brief set the message id
231 *
232 * @param this ike_header_t object
233 * @param initiator_spi message id
234 */
235 void (*set_message_id) (ike_header_t *this, u_int32_t message_id);
236
237 /**
238 * @brief Destroys a ike_header_t object.
239 *
240 * @param this ike_header_t object to destroy
241 * @return
242 * SUCCESS in any case
243 */
244 status_t (*destroy) (ike_header_t *this);
245 };
246
247 /**
248 * @brief Create an ike_header_t object
249 *
250 * @return
251 * - created ike_header, or
252 * - NULL if failed
253 */
254
255 ike_header_t *ike_header_create();
256
257 #endif /*IKE_HEADER_H_*/