diff options
author | Martin Willi <martin@revosec.ch> | 2010-07-22 14:38:05 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-07-26 11:33:00 +0200 |
commit | 2cbc48ecabfbd3b780d3ea16c352156cf5e40f9c (patch) | |
tree | 651f9b1e53a0cf048f699323ea86688992ccfad9 /src | |
parent | ad2488fcdf97a76bd36dbf8348b3df3b000430da (diff) | |
download | strongswan-2cbc48ecabfbd3b780d3ea16c352156cf5e40f9c.tar.bz2 strongswan-2cbc48ecabfbd3b780d3ea16c352156cf5e40f9c.tar.xz |
Replaces in_segment() by a more generic get_segment() function
Diffstat (limited to 'src')
-rw-r--r-- | src/libcharon/plugins/ha/ha_kernel.c | 13 | ||||
-rw-r--r-- | src/libcharon/plugins/ha/ha_kernel.h | 9 | ||||
-rw-r--r-- | src/libcharon/plugins/ha/ha_segments.c | 8 |
3 files changed, 13 insertions, 17 deletions
diff --git a/src/libcharon/plugins/ha/ha_kernel.c b/src/libcharon/plugins/ha/ha_kernel.c index 561cff14a..7428de497 100644 --- a/src/libcharon/plugins/ha/ha_kernel.c +++ b/src/libcharon/plugins/ha/ha_kernel.c @@ -51,8 +51,8 @@ struct private_ha_kernel_t { u_int count; }; -METHOD(ha_kernel_t, in_segment, bool, - private_ha_kernel_t *this, host_t *host, u_int segment) +METHOD(ha_kernel_t, get_segment, u_int, + private_ha_kernel_t *this, host_t *host) { if (host->get_family(host) == AF_INET) { @@ -62,12 +62,9 @@ METHOD(ha_kernel_t, in_segment, bool, addr = *(u_int32_t*)host->get_address(host).ptr; hash = jhash_1word(ntohl(addr), this->initval); - if ((((u_int64_t)hash * this->count) >> 32) + 1 == segment) - { - return TRUE; - } + return (((u_int64_t)hash * this->count) >> 32) + 1; } - return FALSE; + return 0; } /** @@ -208,7 +205,7 @@ ha_kernel_t *ha_kernel_create(u_int count) INIT(this, .public = { - .in_segment = _in_segment, + .get_segment = _get_segment, .activate = _activate, .deactivate = _deactivate, .destroy = _destroy, diff --git a/src/libcharon/plugins/ha/ha_kernel.h b/src/libcharon/plugins/ha/ha_kernel.h index b6ad5594c..b9341f4cc 100644 --- a/src/libcharon/plugins/ha/ha_kernel.h +++ b/src/libcharon/plugins/ha/ha_kernel.h @@ -31,13 +31,12 @@ typedef struct ha_kernel_t ha_kernel_t; struct ha_kernel_t { /** - * Check if a host is in a segment. + * Get the segment a host is in. * - * @param host host to check - * @param segment segment - * @return TRUE if host belongs to segment + * @param host host to get segment for + * @return segment number */ - bool (*in_segment)(ha_kernel_t *this, host_t *host, u_int segment); + u_int (*get_segment)(ha_kernel_t *this, host_t *host); /** * Activate a segment at kernel level for all cluster addresses. diff --git a/src/libcharon/plugins/ha/ha_segments.c b/src/libcharon/plugins/ha/ha_segments.c index b9b7ab082..5f6e40db2 100644 --- a/src/libcharon/plugins/ha/ha_segments.c +++ b/src/libcharon/plugins/ha/ha_segments.c @@ -168,8 +168,8 @@ static void enable_disable(private_ha_segments_t *this, u_int segment, { continue; } - if (this->kernel->in_segment(this->kernel, - ike_sa->get_other_host(ike_sa), segment)) + if (this->kernel->get_segment(this->kernel, + ike_sa->get_other_host(ike_sa)) == segment) { ike_sa->set_state(ike_sa, new); } @@ -267,8 +267,8 @@ METHOD(ha_segments_t, resync, void, while (enumerator->enumerate(enumerator, &ike_sa)) { if (ike_sa->get_state(ike_sa) == IKE_ESTABLISHED && - this->kernel->in_segment(this->kernel, - ike_sa->get_other_host(ike_sa), segment)) + this->kernel->get_segment(this->kernel, + ike_sa->get_other_host(ike_sa)) == segment) { id = ike_sa->get_id(ike_sa); list->insert_last(list, id->clone(id)); |