2 * Copyright (C) 2008 Martin Willi
3 * 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_sync_message ha_sync_message
21 #ifndef HA_SYNC_MESSAGE_H_
22 #define HA_SYNC_MESSAGE_H_
25 #include <utils/host.h>
26 #include <utils/identification.h>
27 #include <sa/ike_sa_id.h>
28 #include <config/traffic_selector.h>
31 * Protocol version of this implementation
33 #define HA_SYNC_MESSAGE_VERSION 1
35 typedef struct ha_sync_message_t ha_sync_message_t
;
36 typedef enum ha_sync_message_type_t ha_sync_message_type_t
;
37 typedef enum ha_sync_message_attribute_t ha_sync_message_attribute_t
;
38 typedef union ha_sync_message_value_t ha_sync_message_value_t
;
41 * Type of a sync message
43 enum ha_sync_message_type_t
{
44 /** add a completely new IKE_SA */
46 /** update an existing IKE_SA (message IDs, address update, ...) */
48 /** delete an existing IKE_SA */
50 /** add a new CHILD_SA */
52 /** delete an existing CHILD_SA */
57 * Type of attributes contained in a message
59 enum ha_sync_message_attribute_t
{
60 /** ike_sa_id_t*, to identify IKE_SA */
62 /** ike_Sa_id_t*, identifies IKE_SA which gets rekeyed */
64 /** identification_t*, local identity */
66 /** identification_t*, remote identity */
68 /** identification_t*, EAP identity */
70 /** host_t*, local address */
72 /** host_t*, remote address */
74 /** char*, name of configuration */
76 /** u_int32_t, bitset of ike_condition_t */
78 /** u_int32_t, bitset of ike_extension_t */
80 /** host_t*, local virtual IP */
82 /** host_t*, remote virtual IP */
84 /** host_t*, additional MOBIKE peer address */
85 HA_SYNC_ADDITIONAL_ADDR
,
86 /** chunk_t, initiators nonce */
88 /** chunk_t, responders nonce */
90 /** chunk_t, diffie hellman shared secret */
92 /** chunk_t, SKd of old SA if rekeying */
94 /** u_int16_t, pseudo random function */
96 /** u_int16_t, old pseudo random function if rekeying */
98 /** u_int16_t, encryption algorithm */
100 /** u_int16_t, encryption key size in bytes */
101 HA_SYNC_ALG_ENCR_LEN
,
102 /** u_int16_t, integrity protection algorithm */
104 /** u_int8_t, IPsec mode, TUNNEL|TRANSPORT|... */
106 /** u_int8_t, IPComp protocol */
108 /** u_int32_t, inbound security parameter index */
110 /** u_int32_t, outbound security parameter index */
111 HA_SYNC_OUTBOUND_SPI
,
112 /** u_int16_t, inbound security parameter index */
114 /** u_int16_t, outbound security parameter index */
115 HA_SYNC_OUTBOUND_CPI
,
116 /** traffic_selector_t*, local traffic selector */
118 /** traffic_selector_t*, remote traffic selector */
120 /** u_int32_t, initiating message ID */
121 HA_SYNC_INITIATE_MID
,
122 /** u_int32_t, responding message ID */
127 * Union to enumerate typed attributes in a message
129 union ha_sync_message_value_t
{
135 ike_sa_id_t
*ike_sa_id
;
136 identification_t
*id
;
138 traffic_selector_t
*ts
;
142 * Abstracted message passed between nodes in a HA cluster.
144 struct ha_sync_message_t
{
147 * Get the type of the message.
149 * @return message type
151 ha_sync_message_type_t (*get_type
)(ha_sync_message_t
*this);
154 * Add an attribute to a message.
156 * @param attribute attribute type to add
157 * @param ... attribute specific data
159 void (*add_attribute
)(ha_sync_message_t
*this,
160 ha_sync_message_attribute_t attribute
, ...);
163 * Create an enumerator over all attributes in a message.
165 * @return enumerator over attribute, ha_sync_message_value_t
167 enumerator_t
* (*create_attribute_enumerator
)(ha_sync_message_t
*this);
170 * Get the message in a encoded form.
172 * @return chunk pointing to internal data
174 chunk_t (*get_encoding
)(ha_sync_message_t
*this);
177 * Destroy a ha_sync_message_t.
179 void (*destroy
)(ha_sync_message_t
*this);
183 * Create a new ha_sync_message instance, ready for adding attributes
185 * @param version protocol version to create a message from
186 * @param type type of the message
188 ha_sync_message_t
*ha_sync_message_create(ha_sync_message_type_t type
);
191 * Create a ha_sync_message from encoded data.
193 * @param data encoded message data
195 ha_sync_message_t
*ha_sync_message_parse(chunk_t data
);
197 #endif /* HA_SYNC_MESSAGE_ @}*/