From 16a898f5f75e21917e78ab65c43ec85efcfac5b2 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 20 Nov 2018 16:39:04 +0100 Subject: [PATCH] ha: Add getter for the number of segments --- src/libcharon/plugins/ha/ha_segments.c | 7 +++++++ src/libcharon/plugins/ha/ha_segments.h | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/libcharon/plugins/ha/ha_segments.c b/src/libcharon/plugins/ha/ha_segments.c index 0a407f9ef..153534915 100644 --- a/src/libcharon/plugins/ha/ha_segments.c +++ b/src/libcharon/plugins/ha/ha_segments.c @@ -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, diff --git a/src/libcharon/plugins/ha/ha_segments.h b/src/libcharon/plugins/ha/ha_segments.h index 10d5812c6..bc96a8d3e 100644 --- a/src/libcharon/plugins/ha/ha_segments.h +++ b/src/libcharon/plugins/ha/ha_segments.h @@ -82,6 +82,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. */