diff options
Diffstat (limited to 'src/libcharon/config/peer_cfg.c')
-rw-r--r-- | src/libcharon/config/peer_cfg.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/libcharon/config/peer_cfg.c b/src/libcharon/config/peer_cfg.c index 091176a25..59869eab2 100644 --- a/src/libcharon/config/peer_cfg.c +++ b/src/libcharon/config/peer_cfg.c @@ -146,9 +146,9 @@ struct private_peer_cfg_t { linked_list_t *vips; /** - * pool to acquire configuration attributes from + * List of pool names to use for virtual IP lookup */ - char *pool; + linked_list_t *pools; /** * local authentication configs (rulesets) @@ -421,10 +421,16 @@ METHOD(peer_cfg_t, create_virtual_ip_enumerator, enumerator_t*, return this->vips->create_enumerator(this->vips); } -METHOD(peer_cfg_t, get_pool, char*, +METHOD(peer_cfg_t, add_pool, void, + private_peer_cfg_t *this, char *name) +{ + this->pools->insert_last(this->pools, strdup(name)); +} + +METHOD(peer_cfg_t, create_pool_enumerator, enumerator_t*, private_peer_cfg_t *this) { - return this->pool; + return this->pools->create_enumerator(this->pools); } METHOD(peer_cfg_t, add_auth_cfg, void, @@ -529,6 +535,7 @@ METHOD(peer_cfg_t, equals, bool, { enumerator_t *e1, *e2; host_t *vip1, *vip2; + char *pool1, *pool2; if (this == other) { @@ -557,6 +564,25 @@ METHOD(peer_cfg_t, equals, bool, e1->destroy(e1); e2->destroy(e2); + if (this->pools->get_count(this->pools) != + other->pools->get_count(other->pools)) + { + return FALSE; + } + e1 = create_pool_enumerator(this); + e2 = create_pool_enumerator(other); + if (e1->enumerate(e1, &pool1) && e2->enumerate(e2, &pool2)) + { + if (!streq(pool1, pool2)) + { + e1->destroy(e1); + e2->destroy(e2); + return FALSE; + } + } + e1->destroy(e1); + e2->destroy(e2); + return ( this->ike_version == other->ike_version && this->cert_policy == other->cert_policy && @@ -568,8 +594,6 @@ METHOD(peer_cfg_t, equals, bool, this->jitter_time == other->jitter_time && this->over_time == other->over_time && this->dpd == other->dpd && - (this->pool == other->pool || - (this->pool && other->pool && streq(this->pool, other->pool))) && auth_cfg_equal(this, other) #ifdef ME && this->mediation == other->mediation && @@ -601,13 +625,13 @@ METHOD(peer_cfg_t, destroy, void, this->remote_auth->destroy_offset(this->remote_auth, offsetof(auth_cfg_t, destroy)); this->vips->destroy_offset(this->vips, offsetof(host_t, destroy)); + this->pools->destroy_function(this->pools, free); #ifdef ME DESTROY_IF(this->mediated_by); DESTROY_IF(this->peer_id); #endif /* ME */ this->mutex->destroy(this->mutex); free(this->name); - free(this->pool); free(this); } } @@ -621,7 +645,7 @@ peer_cfg_t *peer_cfg_create(char *name, ike_version_t ike_version, u_int32_t rekey_time, u_int32_t reauth_time, u_int32_t jitter_time, u_int32_t over_time, bool mobike, bool aggressive, u_int32_t dpd, - u_int32_t dpd_timeout, char *pool, + u_int32_t dpd_timeout, bool mediation, peer_cfg_t *mediated_by, identification_t *peer_id) { @@ -657,7 +681,8 @@ peer_cfg_t *peer_cfg_create(char *name, ike_version_t ike_version, .get_dpd_timeout = _get_dpd_timeout, .add_virtual_ip = _add_virtual_ip, .create_virtual_ip_enumerator = _create_virtual_ip_enumerator, - .get_pool = _get_pool, + .add_pool = _add_pool, + .create_pool_enumerator = _create_pool_enumerator, .add_auth_cfg = _add_auth_cfg, .create_auth_cfg_enumerator = _create_auth_cfg_enumerator, .equals = (void*)_equals, @@ -686,7 +711,7 @@ peer_cfg_t *peer_cfg_create(char *name, ike_version_t ike_version, .dpd = dpd, .dpd_timeout = dpd_timeout, .vips = linked_list_create(), - .pool = strdupnull(pool), + .pools = linked_list_create(), .local_auth = linked_list_create(), .remote_auth = linked_list_create(), .refcount = 1, |