4 * @brief Class message_t. Object of this type represents an IKEv2-Message.
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
28 #include "ike_sa_id.h"
29 #include "payloads/ike_header.h"
35 * @brief This class is used to represent an IKEv2-Message.
37 * An IKEv2-Message is either a request or response.
39 typedef struct message_s message_t
;
44 * @brief Sets the IKE major version of the message.
46 * @param this message_t object
47 * @param major_version major version to set
50 status_t (*set_major_version
) (message_t
*this,u_int8_t major_version
);
53 * @brief Gets the IKE major version of the message.
55 * @param this message_t object
56 * @return major version of the message
58 u_int8_t (*get_major_version
) (message_t
*this);
61 * @brief Sets the IKE minor version of the message.
63 * @param this message_t object
64 * @param minor_version minor version to set
67 status_t (*set_minor_version
) (message_t
*this,u_int8_t minor_version
);
70 * @brief Gets the IKE minor version of the message.
72 * @param this message_t object
73 * @return minor version of the message
75 u_int8_t (*get_minor_version
) (message_t
*this);
78 * @brief Sets the Message ID of the message.
80 * @param this message_t object
81 * @param message_id message_id to set
84 status_t (*set_message_id
) (message_t
*this,u_int32_t message_id
);
87 * @brief Gets the Message ID of the message.
89 * @param this message_t object
90 * @return message_id type of the message
92 u_int32_t (*get_message_id
) (message_t
*this);
95 * @brief Sets the IKE_SA ID of the message.
97 * @warning ike_sa_id gets cloned internaly and
98 * so can be destroyed afterwards.
100 * @param this message_t object
101 * @param ike_sa_id ike_sa_id to set
107 status_t (*set_ike_sa_id
) (message_t
*this,ike_sa_id_t
* ike_sa_id
);
110 * @brief Gets the IKE_SA ID of the message.
112 * @warning The returned ike_sa_id is a clone of the internal one.
113 * So it has to be destroyed by the caller.
115 * @param this message_t object
116 * @param ike_sa_id pointer to ike_sa_id pointer which will be set
120 * - FAILED if no ike_sa_id is set
122 status_t (*get_ike_sa_id
) (message_t
*this,ike_sa_id_t
**ike_sa_id
);
125 * @brief Sets the exchange type of the message.
127 * @param this message_t object
128 * @param exchange_type exchange_type to set
131 status_t (*set_exchange_type
) (message_t
*this,exchange_type_t exchange_type
);
134 * @brief Gets the exchange type of the message.
136 * @param this message_t object
137 * @return exchange type of the message
139 exchange_type_t (*get_exchange_type
) (message_t
*this);
142 * @brief Sets the original initiator flag.
144 * @param this message_t object
145 * @param original_initiator TRUE if message is from original initiator
148 status_t (*set_original_initiator
) (message_t
*this,bool original_initiator
);
151 * @brief Gets original initiator flag.
153 * @param this message_t object
154 * @return TRUE if message is from original initiator, FALSE otherwise
156 bool (*get_original_initiator
) (message_t
*this);
159 * @brief Sets the request flag.
161 * @param this message_t object
162 * @param original_initiator TRUE if message is a request, FALSE if it is a reply
165 status_t (*set_request
) (message_t
*this,bool request
);
168 * @brief Gets request flag.
170 * @param this message_t object
171 * @return TRUE if message is a request, FALSE if it is a reply
173 bool (*get_request
) (message_t
*this);
176 * @brief Append a payload to the message.
178 * @param this message_t object
179 * @param payload payload to append
184 status_t (*add_payload
) (message_t
*this, payload_t
*payload
);
187 * @brief Generates the UDP packet of specific message
189 * @param this message_t object
191 * - SUCCESS if packet could be generated
192 * - EXCHANGE_TYPE_NOT_SET if exchange type is currently not set
197 * @brief Parses header of message
199 * @param this message_t object
201 * - SUCCESS if header could be parsed
202 * - NOT_SUPPORTED if payload_type is not supported
203 * - OUT_OF_RES if out of ressources
204 * - PARSE_ERROR if corrupted/invalid data found
206 status_t (*parse_header
) (message_t
*this);
209 * @brief Parses body of message
211 * @param this message_t object
213 * - SUCCESS if header could be parsed
214 * - NOT_SUPPORTED if payload_type is not supported
215 * - OUT_OF_RES if out of ressources
216 * - PARSE_ERROR if corrupted/invalid data found
218 status_t (*parse_body
) (message_t
*this);
220 status_t (*generate
) (message_t
*this, packet_t
**packet
);
221 status_t (*get_source
) (message_t
*this, host_t
**host
);
222 status_t (*set_source
) (message_t
*this, host_t
*host
);
223 status_t (*get_destination
) (message_t
*this, host_t
**host
);
224 status_t (*set_destination
) (message_t
*this, host_t
*host
);
227 * @brief Destroys a message and all including objects
229 * @param this message_t object
232 status_t (*destroy
) (message_t
*this);
236 * Creates an message_t object from a incoming UDP Packet.
238 * @warning the given packet_t object is not copied and gets
239 * destroyed in message_t's destroy call.
241 * @warning Packet is not parsed in here!
243 * - exchange_type is set to NOT_SET
244 * - original_initiator is set to TRUE
245 * - is_request is set to TRUE
247 * @param packet packet_t object which is assigned to message
250 * - created message_t object
251 * - NULL if out of ressources
253 message_t
* message_create_from_packet(packet_t
*packet
);
257 * Creates an empty message_t object.
259 * - exchange_type is set to NOT_SET
260 * - original_initiator is set to TRUE
261 * - is_request is set to TRUE
264 * - created message_t object
265 * - NULL if out of ressources
267 message_t
* message_create();
269 #endif /*MESSAGE_H_*/