4 * @brief Interface of ike_header_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
27 #include <encoding/payloads/payload.h>
30 * Major Version of IKEv2.
34 #define IKE_MAJOR_VERSION 2
37 * Minor Version of IKEv2.
41 #define IKE_MINOR_VERSION 0
44 * Flag in IKEv2-Header. Always 0.
48 #define HIGHER_VERSION_SUPPORTED_FLAG 0
51 * Length of IKE Header in Bytes.
55 #define IKE_HEADER_LENGTH 28
57 typedef enum exchange_type_t exchange_type_t
;
60 * @brief Different types of IKE-Exchanges.
62 * See Draft for different types.
69 * EXCHANGE_TYPE_UNDEFINED. In private space, since not a official message type.
71 EXCHANGE_TYPE_UNDEFINED
= 240,
95 * string mappings for exchange_type_t
99 extern mapping_t exchange_type_m
[];
102 typedef struct ike_header_t ike_header_t
;
105 * @brief An object of this type represents an IKEv2 header and is used to
106 * generate and parse IKEv2 headers.
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.
113 * - ike_header_create()
117 struct ike_header_t
{
119 * The payload_t interface.
121 payload_t payload_interface
;
124 * @brief Get the initiator spi.
126 * @param this ike_header_t object
127 * @return initiator_spi
129 u_int64_t (*get_initiator_spi
) (ike_header_t
*this);
132 * @brief Set the initiator spi.
134 * @param this ike_header_t object
135 * @param initiator_spi initiator_spi
137 void (*set_initiator_spi
) (ike_header_t
*this, u_int64_t initiator_spi
);
140 * @brief Get the responder spi.
142 * @param this ike_header_t object
143 * @return responder_spi
145 u_int64_t (*get_responder_spi
) (ike_header_t
*this);
148 * @brief Set the responder spi.
150 * @param this ike_header_t object
151 * @param responder_spi responder_spi
153 void (*set_responder_spi
) (ike_header_t
*this, u_int64_t responder_spi
);
156 * @brief Get the major version.
158 * @param this ike_header_t object
159 * @return major version
161 u_int8_t (*get_maj_version
) (ike_header_t
*this);
164 * @brief Get the minor version.
166 * @param this ike_header_t object
167 * @return minor version
169 u_int8_t (*get_min_version
) (ike_header_t
*this);
172 * @brief Get the response flag.
174 * @param this ike_header_t object
175 * @return response flag
177 bool (*get_response_flag
) (ike_header_t
*this);
180 * @brief Set the response flag-
182 * @param this ike_header_t object
183 * @param response response flag
186 void (*set_response_flag
) (ike_header_t
*this, bool response
);
188 * @brief Get "higher version supported"-flag.
190 * @param this ike_header_t object
191 * @return version flag
193 bool (*get_version_flag
) (ike_header_t
*this);
196 * @brief Get the initiator flag.
198 * @param this ike_header_t object
199 * @return initiator flag
201 bool (*get_initiator_flag
) (ike_header_t
*this);
204 * @brief Set the initiator flag.
206 * @param this ike_header_t object
207 * @param initiator initiator flag
210 void (*set_initiator_flag
) (ike_header_t
*this, bool initiator
);
213 * @brief Get the exchange type.
215 * @param this ike_header_t object
216 * @return exchange type
218 u_int8_t (*get_exchange_type
) (ike_header_t
*this);
221 * @brief Set the exchange type.
223 * @param this ike_header_t object
224 * @param exchange_type exchange type
226 void (*set_exchange_type
) (ike_header_t
*this, u_int8_t exchange_type
);
229 * @brief Get the message id.
231 * @param this ike_header_t object
234 u_int32_t (*get_message_id
) (ike_header_t
*this);
237 * @brief Set the message id.
239 * @param this ike_header_t object
240 * @param initiator_spi message id
242 void (*set_message_id
) (ike_header_t
*this, u_int32_t message_id
);
245 * @brief Destroys a ike_header_t object.
247 * @param this ike_header_t object to destroy
249 void (*destroy
) (ike_header_t
*this);
253 * @brief Create an ike_header_t object
255 * @return ike_header_t object
259 ike_header_t
*ike_header_create(void);
261 #endif /*IKE_HEADER_H_*/