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_segments ha_sync_segments
21 #ifndef HA_SYNC_SEGMENTS_H_
22 #define HA_SYNC_SEGMENTS_H_
26 typedef struct ha_sync_segments_t ha_sync_segments_t
;
28 typedef u_int16_t segment_mask_t
;
31 * maximum number of segments
33 #define SEGMENTS_MAX (sizeof(segment_mask_t)*8)
36 * Get the bit in the mask of a segment
38 #define SEGMENTS_BIT(segment) (0x01 << (segment - 1))
40 #include "ha_sync_socket.h"
41 #include "ha_sync_tunnel.h"
42 #include "ha_sync_kernel.h"
45 * Segmentation of peers into active and passive.
47 struct ha_sync_segments_t
{
50 * Implements listener interface to catch daemon shutdown.
55 * Activate a set of IKE_SAs identified by a segment.
57 * @param segment numerical segment to takeover, 0 for all
58 * @param notify wheter to notify other nodes about activation
60 void (*activate
)(ha_sync_segments_t
*this, u_int segment
, bool notify
);
63 * Deactivate a set of IKE_SAs identified by a segment.
65 * @param segment numerical segment to takeover, 0 for all
66 * @param notify wheter to notify other nodes about deactivation
68 void (*deactivate
)(ha_sync_segments_t
*this, u_int segment
, bool notify
);
71 * Resync an active segment.
73 * To reintegrade a node into the cluster, resynchronization is reqired.
74 * IKE_SAs and CHILD_SAs are synced automatically during rekeying. A call
75 * to this method enforces a rekeying immediately sync all state of a
78 * @param segment segment to resync
80 void (*resync
)(ha_sync_segments_t
*this, u_int segment
);
83 * Destroy a ha_sync_segments_t.
85 void (*destroy
)(ha_sync_segments_t
*this);
89 * Create a ha_sync_segments instance.
91 * @param socket socket to communicate segment (de-)activation
92 * @param kernel interface to control segments at kernel level
93 * @param count number of segments the cluster uses
94 * @param active bit mask of initially active segments
95 * @return segment object
97 ha_sync_segments_t
*ha_sync_segments_create(ha_sync_socket_t
*socket
,
98 ha_sync_kernel_t
*kernel
,
99 ha_sync_tunnel_t
*tunnel
,
100 u_int count
, segment_mask_t active
);
102 #endif /* HA_SYNC_SEGMENTS_ @}*/