Annotation of embedaddon/strongswan/src/libcharon/plugins/ha/ha_segments.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2008 Martin Willi
                      3:  * HSR 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_segments ha_segments
                     18:  * @{ @ingroup ha
                     19:  */
                     20: 
                     21: #ifndef HA_SEGMENTS_H_
                     22: #define HA_SEGMENTS_H_
                     23: 
                     24: #include <daemon.h>
                     25: 
                     26: typedef struct ha_segments_t ha_segments_t;
                     27: 
                     28: typedef uint16_t segment_mask_t;
                     29: 
                     30: /**
                     31:  * maximum number of segments
                     32:  */
                     33: #define SEGMENTS_MAX (sizeof(segment_mask_t)*8)
                     34: 
                     35: /**
                     36:  * Get the bit in the mask of a segment
                     37:  */
                     38: #define SEGMENTS_BIT(segment) (0x01 << (segment - 1))
                     39: 
                     40: #include "ha_socket.h"
                     41: #include "ha_tunnel.h"
                     42: #include "ha_kernel.h"
                     43: 
                     44: /**
                     45:  * Segmentation of peers into active and passive.
                     46:  */
                     47: struct ha_segments_t {
                     48: 
                     49:        /**
                     50:         * Implements listener interface to catch daemon shutdown.
                     51:         */
                     52:        listener_t listener;
                     53: 
                     54:        /**
                     55:         * Activate a set of IKE_SAs identified by a segment.
                     56:         *
                     57:         * @param segment       numerical segment to takeover, 0 for all
                     58:         * @param notify        whether to notify other nodes about activation
                     59:         */
                     60:        void (*activate)(ha_segments_t *this, u_int segment, bool notify);
                     61: 
                     62:        /**
                     63:         * Deactivate a set of IKE_SAs identified by a segment.
                     64:         *
                     65:         * @param segment       numerical segment to takeover, 0 for all
                     66:         * @param notify        whether to notify other nodes about deactivation
                     67:         */
                     68:        void (*deactivate)(ha_segments_t *this, u_int segment, bool notify);
                     69: 
                     70:        /**
                     71:         * Handle a status message from the remote node.
                     72:         *
                     73:         * @param mask          segments the remote node is serving actively
                     74:         */
                     75:        void (*handle_status)(ha_segments_t *this, segment_mask_t mask);
                     76: 
                     77:        /**
                     78:         * Check if a given segment is currently active.
                     79:         *
                     80:         * @param segment       segment to check
                     81:         * @return                      TRUE if segment active
                     82:         */
                     83:        bool (*is_active)(ha_segments_t *this, u_int segment);
                     84: 
                     85:        /**
                     86:         * Return the number of segments
                     87:         *
                     88:         * @return                      number of segments
                     89:         */
                     90:        u_int (*count)(ha_segments_t *this);
                     91: 
                     92:        /**
                     93:         * Destroy a ha_segments_t.
                     94:         */
                     95:        void (*destroy)(ha_segments_t *this);
                     96: };
                     97: 
                     98: /**
                     99:  * Create a ha_segments instance.
                    100:  *
                    101:  * @param socket               socket to communicate segment (de-)activation
                    102:  * @param kernel               interface to control segments at kernel level
                    103:  * @param tunnel               HA tunnel
                    104:  * @param count                        number of segments the cluster uses
                    105:  * @param node                 node, currently 1 or 0
                    106:  * @param monitor              should we use monitoring functionality
                    107:  * @return                             segment object
                    108:  */
                    109: ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
                    110:                                                                  ha_tunnel_t *tunnel, u_int count, u_int node,
                    111:                                                                  bool monitor);
                    112: 
                    113: #endif /** HA_SEGMENTS_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>