Propagate segment manipulation to cluster node
[strongswan.git] / src / charon / plugins / ha_sync / ha_sync_message.h
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 /**
17 * @defgroup ha_sync_message ha_sync_message
18 * @{ @ingroup ha_sync
19 */
20
21 #ifndef HA_SYNC_MESSAGE_H_
22 #define HA_SYNC_MESSAGE_H_
23
24 #include <library.h>
25 #include <utils/host.h>
26 #include <utils/identification.h>
27 #include <sa/ike_sa_id.h>
28 #include <config/traffic_selector.h>
29
30 /**
31 * Protocol version of this implementation
32 */
33 #define HA_SYNC_MESSAGE_VERSION 1
34
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;
39
40 /**
41 * Type of a sync message
42 */
43 enum ha_sync_message_type_t {
44 /** add a completely new IKE_SA */
45 HA_SYNC_IKE_ADD = 1,
46 /** update an existing IKE_SA (message IDs, address update, ...) */
47 HA_SYNC_IKE_UPDATE,
48 /** delete an existing IKE_SA */
49 HA_SYNC_IKE_DELETE,
50 /** add a new CHILD_SA */
51 HA_SYNC_CHILD_ADD,
52 /** delete an existing CHILD_SA */
53 HA_SYNC_CHILD_DELETE,
54 /** segments the sending node is giving up */
55 HA_SYNC_SEGMENT_DROP,
56 /** segments the sending node is taking over */
57 HA_SYNC_SEGMENT_TAKE,
58 };
59
60 /**
61 * Type of attributes contained in a message
62 */
63 enum ha_sync_message_attribute_t {
64 /** ike_sa_id_t*, to identify IKE_SA */
65 HA_SYNC_IKE_ID = 1,
66 /** ike_Sa_id_t*, identifies IKE_SA which gets rekeyed */
67 HA_SYNC_IKE_REKEY_ID,
68 /** identification_t*, local identity */
69 HA_SYNC_LOCAL_ID,
70 /** identification_t*, remote identity */
71 HA_SYNC_REMOTE_ID,
72 /** identification_t*, EAP identity */
73 HA_SYNC_EAP_ID,
74 /** host_t*, local address */
75 HA_SYNC_LOCAL_ADDR,
76 /** host_t*, remote address */
77 HA_SYNC_REMOTE_ADDR,
78 /** char*, name of configuration */
79 HA_SYNC_CONFIG_NAME,
80 /** u_int32_t, bitset of ike_condition_t */
81 HA_SYNC_CONDITIONS,
82 /** u_int32_t, bitset of ike_extension_t */
83 HA_SYNC_EXTENSIONS,
84 /** host_t*, local virtual IP */
85 HA_SYNC_LOCAL_VIP,
86 /** host_t*, remote virtual IP */
87 HA_SYNC_REMOTE_VIP,
88 /** host_t*, additional MOBIKE peer address */
89 HA_SYNC_ADDITIONAL_ADDR,
90 /** chunk_t, initiators nonce */
91 HA_SYNC_NONCE_I,
92 /** chunk_t, responders nonce */
93 HA_SYNC_NONCE_R,
94 /** chunk_t, diffie hellman shared secret */
95 HA_SYNC_SECRET,
96 /** chunk_t, SKd of old SA if rekeying */
97 HA_SYNC_OLD_SKD,
98 /** u_int16_t, pseudo random function */
99 HA_SYNC_ALG_PRF,
100 /** u_int16_t, old pseudo random function if rekeying */
101 HA_SYNC_ALG_OLD_PRF,
102 /** u_int16_t, encryption algorithm */
103 HA_SYNC_ALG_ENCR,
104 /** u_int16_t, encryption key size in bytes */
105 HA_SYNC_ALG_ENCR_LEN,
106 /** u_int16_t, integrity protection algorithm */
107 HA_SYNC_ALG_INTEG,
108 /** u_int8_t, IPsec mode, TUNNEL|TRANSPORT|... */
109 HA_SYNC_IPSEC_MODE,
110 /** u_int8_t, IPComp protocol */
111 HA_SYNC_IPCOMP,
112 /** u_int32_t, inbound security parameter index */
113 HA_SYNC_INBOUND_SPI,
114 /** u_int32_t, outbound security parameter index */
115 HA_SYNC_OUTBOUND_SPI,
116 /** u_int16_t, inbound security parameter index */
117 HA_SYNC_INBOUND_CPI,
118 /** u_int16_t, outbound security parameter index */
119 HA_SYNC_OUTBOUND_CPI,
120 /** traffic_selector_t*, local traffic selector */
121 HA_SYNC_LOCAL_TS,
122 /** traffic_selector_t*, remote traffic selector */
123 HA_SYNC_REMOTE_TS,
124 /** u_int32_t, initiating message ID */
125 HA_SYNC_INITIATE_MID,
126 /** u_int32_t, responding message ID */
127 HA_SYNC_RESPOND_MID,
128 /** u_int16_t, HA sync segment */
129 HA_SYNC_SEGMENT,
130 };
131
132 /**
133 * Union to enumerate typed attributes in a message
134 */
135 union ha_sync_message_value_t {
136 u_int8_t u8;
137 u_int16_t u16;
138 u_int32_t u32;
139 char *str;
140 chunk_t chunk;
141 ike_sa_id_t *ike_sa_id;
142 identification_t *id;
143 host_t *host;
144 traffic_selector_t *ts;
145 };
146
147 /**
148 * Abstracted message passed between nodes in a HA cluster.
149 */
150 struct ha_sync_message_t {
151
152 /**
153 * Get the type of the message.
154 *
155 * @return message type
156 */
157 ha_sync_message_type_t (*get_type)(ha_sync_message_t *this);
158
159 /**
160 * Add an attribute to a message.
161 *
162 * @param attribute attribute type to add
163 * @param ... attribute specific data
164 */
165 void (*add_attribute)(ha_sync_message_t *this,
166 ha_sync_message_attribute_t attribute, ...);
167
168 /**
169 * Create an enumerator over all attributes in a message.
170 *
171 * @return enumerator over attribute, ha_sync_message_value_t
172 */
173 enumerator_t* (*create_attribute_enumerator)(ha_sync_message_t *this);
174
175 /**
176 * Get the message in a encoded form.
177 *
178 * @return chunk pointing to internal data
179 */
180 chunk_t (*get_encoding)(ha_sync_message_t *this);
181
182 /**
183 * Destroy a ha_sync_message_t.
184 */
185 void (*destroy)(ha_sync_message_t *this);
186 };
187
188 /**
189 * Create a new ha_sync_message instance, ready for adding attributes
190 *
191 * @param version protocol version to create a message from
192 * @param type type of the message
193 */
194 ha_sync_message_t *ha_sync_message_create(ha_sync_message_type_t type);
195
196 /**
197 * Create a ha_sync_message from encoded data.
198 *
199 * @param data encoded message data
200 */
201 ha_sync_message_t *ha_sync_message_parse(chunk_t data);
202
203 #endif /* HA_SYNC_MESSAGE_ @}*/