ha: Add getter for the number of segments
authorTobias Brunner <tobias@strongswan.org>
Tue, 20 Nov 2018 15:39:04 +0000 (16:39 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 7 Dec 2018 09:15:05 +0000 (10:15 +0100)
src/libcharon/plugins/ha/ha_segments.c
src/libcharon/plugins/ha/ha_segments.h

index 0a407f9..1535349 100644 (file)
@@ -433,6 +433,12 @@ METHOD(ha_segments_t, is_active, bool,
        return (this->active & SEGMENTS_BIT(segment)) != 0;
 }
 
+METHOD(ha_segments_t, count, u_int,
+       private_ha_segments_t *this)
+{
+       return this->count;
+}
+
 METHOD(ha_segments_t, destroy, void,
        private_ha_segments_t *this)
 {
@@ -459,6 +465,7 @@ ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
                        .deactivate = _deactivate,
                        .handle_status = _handle_status,
                        .is_active = _is_active,
+                       .count = _count,
                        .destroy = _destroy,
                },
                .socket = socket,
index 10d5812..bc96a8d 100644 (file)
@@ -83,6 +83,13 @@ struct ha_segments_t {
        bool (*is_active)(ha_segments_t *this, u_int segment);
 
        /**
+        * Return the number of segments
+        *
+        * @return                      number of segments
+        */
+       u_int (*count)(ha_segments_t *this);
+
+       /**
         * Destroy a ha_segments_t.
         */
        void (*destroy)(ha_segments_t *this);