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