]> git.ipfire.org Git - thirdparty/strongswan.git/blob - Source/charon/encoding/payloads/ike_header.h
- created encoding package
[thirdparty/strongswan.git] / Source / charon / encoding / 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 <encoding/payloads/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 * EXCHANGE_TYPE_UNDEFINED, not a official message type :-)
63 */
64 EXCHANGE_TYPE_UNDEFINED = 240,
65 /**
66 * IKE_SA_INIT
67 */
68 IKE_SA_INIT = 34,
69 /**
70 * IKE_AUTH
71 */
72 IKE_AUTH = 35,
73 /**
74 * CREATE_CHILD_SA
75 */
76 CREATE_CHILD_SA = 36,
77 /**
78 * INFORMATIONAL
79 */
80 INFORMATIONAL = 37
81 };
82
83 extern mapping_t exchange_type_m[];
84
85 /**
86 * Object representing an IKEv2-Header
87 *
88 * The header format of an IKEv2-Message is compatible to the
89 * ISAKMP-Header format to allow implementations supporting
90 * both versions of the IKE-protocol.
91 *
92 */
93 typedef struct ike_header_s ike_header_t;
94
95 struct ike_header_s {
96 /**
97 * implements payload_t interface
98 */
99 payload_t payload_interface;
100
101 /**
102 * @brief get the initiator spi
103 *
104 * @param this ike_header_t object
105 * @return initiator_spi
106 */
107 u_int64_t (*get_initiator_spi) (ike_header_t *this);
108
109 /**
110 * @brief set the initiator spi
111 *
112 * @param this ike_header_t object
113 * @param initiator_spi initiator_spi
114 */
115 void (*set_initiator_spi) (ike_header_t *this, u_int64_t initiator_spi);
116
117 /**
118 * @brief get the responder spi
119 *
120 * @param this ike_header_t object
121 * @return responder_spi
122 */
123 u_int64_t (*get_responder_spi) (ike_header_t *this);
124
125 /**
126 * @brief set the responder spi
127 *
128 * @param this ike_header_t object
129 * @param responder_spi responder_spi
130 */
131 void (*set_responder_spi) (ike_header_t *this, u_int64_t responder_spi);
132
133 /**
134 * @brief get the major version
135 *
136 * @param this ike_header_t object
137 * @return major version
138 */
139 u_int8_t (*get_maj_version) (ike_header_t *this);
140
141 /**
142 * @brief get the mainor version
143 *
144 * @param this ike_header_t object
145 * @return minor version
146 */
147 u_int8_t (*get_min_version) (ike_header_t *this);
148
149 /**
150 * @brief get the response flag
151 *
152 * @param this ike_header_t object
153 * @return response flag
154 */
155 bool (*get_response_flag) (ike_header_t *this);
156
157 /**
158 * @brief Set the response flag
159 *
160 * @param this ike_header_t object
161 * @param response response flag
162 *
163 */
164 void (*set_response_flag) (ike_header_t *this, bool response);
165 /**
166 * @brief get "higher version supported"-flag
167 *
168 * @param this ike_header_t object
169 * @return version flag
170 */
171 bool (*get_version_flag) (ike_header_t *this);
172
173 /**
174 * @brief get the initiator flag
175 *
176 * @param this ike_header_t object
177 * @return initiator flag
178 */
179 bool (*get_initiator_flag) (ike_header_t *this);
180
181 /**
182 * @brief Set the initiator flag
183 *
184 * @param this ike_header_t object
185 * @param initiator initiator flag
186 *
187 */
188 void (*set_initiator_flag) (ike_header_t *this, bool initiator);
189
190 /**
191 * @brief get the exchange type
192 *
193 * @param this ike_header_t object
194 * @return exchange type
195 */
196 u_int8_t (*get_exchange_type) (ike_header_t *this);
197
198 /**
199 * @brief set the exchange type
200 *
201 * @param this ike_header_t object
202 * @param exchange_type exchange type
203 */
204 void (*set_exchange_type) (ike_header_t *this, u_int8_t exchange_type);
205
206 /**
207 * @brief get the message id
208 *
209 * @param this ike_header_t object
210 * @return message id
211 */
212 u_int32_t (*get_message_id) (ike_header_t *this);
213
214 /**
215 * @brief set the message id
216 *
217 * @param this ike_header_t object
218 * @param initiator_spi message id
219 */
220 void (*set_message_id) (ike_header_t *this, u_int32_t message_id);
221
222 /**
223 * @brief Destroys a ike_header_t object.
224 *
225 * @param this ike_header_t object to destroy
226 * @return
227 * SUCCESS in any case
228 */
229 status_t (*destroy) (ike_header_t *this);
230 };
231
232 /**
233 * @brief Create an ike_header_t object
234 *
235 * @return
236 * - created ike_header, or
237 * - NULL if failed
238 */
239
240 ike_header_t *ike_header_create();
241
242 #endif /*IKE_HEADER_H_*/