2 * Copyright (C) 2008 Martin Willi
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup ha_message ha_message
25 #include <networking/host.h>
26 #include <utils/identification.h>
27 #include <sa/ike_sa_id.h>
28 #include <selectors/traffic_selector.h>
31 * Protocol version of this implementation
33 #define HA_MESSAGE_VERSION 3
35 typedef struct ha_message_t ha_message_t
;
36 typedef enum ha_message_type_t ha_message_type_t
;
37 typedef enum ha_message_attribute_t ha_message_attribute_t
;
38 typedef union ha_message_value_t ha_message_value_t
;
41 * Type of a HA message
43 enum ha_message_type_t
{
44 /** add a completely new IKE_SA */
46 /** update an existing IKE_SA (identities, address update, ...) */
48 /** update initiator message id */
50 /** update responder message id */
52 /** delete an existing IKE_SA */
54 /** add a new CHILD_SA */
56 /** delete an existing CHILD_SA */
58 /** segments the sending node is giving up */
60 /** segments the sending node is taking over */
62 /** status with the segments the sending node is currently serving */
64 /** segments the receiving node is requested to resync */
66 /** IV synchronization for IKEv1 Main/Aggressive mode */
71 * Enum names for message types
73 extern enum_name_t
*ha_message_type_names
;
76 * Type of attributes contained in a message
78 enum ha_message_attribute_t
{
79 /** ike_sa_id_t*, to identify IKE_SA */
81 /** ike_sa_id_t*, identifies IKE_SA which gets rekeyed */
83 /** identification_t*, local identity */
85 /** identification_t*, remote identity */
87 /** identification_t*, remote EAP identity */
89 /** host_t*, local address */
91 /** host_t*, remote address */
93 /** char*, name of configuration */
95 /** uint32_t, bitset of ike_condition_t */
97 /** uint32_t, bitset of ike_extension_t */
99 /** host_t*, local virtual IP */
101 /** host_t*, remote virtual IP */
103 /** host_t*, known peer addresses (used for MOBIKE) */
105 /** uint8_t, initiator of an exchange, TRUE for local */
107 /** chunk_t, initiators nonce */
109 /** chunk_t, responders nonce */
111 /** chunk_t, diffie hellman shared secret */
113 /** chunk_t, SKd of old SA if rekeying */
115 /** uint16_t, pseudo random function */
117 /** uint16_t, old pseudo random function if rekeying */
119 /** uint16_t, encryption algorithm */
121 /** uint16_t, encryption key size in bytes */
123 /** uint16_t, integrity protection algorithm */
125 /** uint16_t, DH group */
127 /** uint8_t, IPsec mode, TUNNEL|TRANSPORT|... */
129 /** uint8_t, IPComp protocol */
131 /** uint32_t, inbound security parameter index */
133 /** uint32_t, outbound security parameter index */
135 /** uint16_t, inbound security parameter index */
137 /** uint16_t, outbound security parameter index */
139 /** traffic_selector_t*, local traffic selector */
141 /** traffic_selector_t*, remote traffic selector */
143 /** uint32_t, message ID */
145 /** uint16_t, HA segment */
147 /** uint16_t, Extended Sequence numbers */
149 /** uint8_t, IKE version */
151 /** chunk_t, own DH public value */
153 /** chunk_t, remote DH public value */
155 /** chunk_t, shared secret for IKEv1 key derivation */
157 /** chunk_t, IV for next IKEv1 message */
159 /** uint16_t, auth_method_t for IKEv1 key derivation */
164 * Union to enumerate typed attributes in a message
166 union ha_message_value_t
{
172 ike_sa_id_t
*ike_sa_id
;
173 identification_t
*id
;
175 traffic_selector_t
*ts
;
179 * Abstracted message passed between nodes in a HA cluster.
181 struct ha_message_t
{
184 * Get the type of the message.
186 * @return message type
188 ha_message_type_t (*get_type
)(ha_message_t
*this);
191 * Add an attribute to a message.
193 * @param attribute attribute type to add
194 * @param ... attribute specific data
196 void (*add_attribute
)(ha_message_t
*this,
197 ha_message_attribute_t attribute
, ...);
200 * Create an enumerator over all attributes in a message.
202 * @return enumerator over attribute, ha_message_value_t
204 enumerator_t
* (*create_attribute_enumerator
)(ha_message_t
*this);
207 * Get the message in a encoded form.
209 * @return chunk pointing to internal data
211 chunk_t (*get_encoding
)(ha_message_t
*this);
214 * Destroy a ha_message_t.
216 void (*destroy
)(ha_message_t
*this);
220 * Create a new ha_message instance, ready for adding attributes
222 * @param type type of the message
224 ha_message_t
*ha_message_create(ha_message_type_t type
);
227 * Create a ha_message from encoded data.
229 * @param data encoded message data
231 ha_message_t
*ha_message_parse(chunk_t data
);
233 #endif /** HA_MESSAGE_ @}*/