Support multiple address pools configured on a peer_cfg
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -294,11 +294,18 @@ struct peer_cfg_t {
|
||||
enumerator_t* (*create_virtual_ip_enumerator)(peer_cfg_t *this);
|
||||
|
||||
/**
|
||||
* Get the name of the pool to acquire configuration attributes from.
|
||||
* Add a pool name this configuration uses to select virtual IPs.
|
||||
*
|
||||
* @return pool name, NULL if none defined
|
||||
* @param name pool name to use for virtual IP lookup
|
||||
*/
|
||||
char* (*get_pool)(peer_cfg_t *this);
|
||||
void (*add_pool)(peer_cfg_t *this, char *name);
|
||||
|
||||
/**
|
||||
* Create an enumerator over pool names of this config.
|
||||
*
|
||||
* @return enumerator over char*
|
||||
*/
|
||||
enumerator_t* (*create_pool_enumerator)(peer_cfg_t *this);
|
||||
|
||||
#ifdef ME
|
||||
/**
|
||||
@@ -378,7 +385,6 @@ struct peer_cfg_t {
|
||||
* @param aggressive use/accept aggressive mode with IKEv1
|
||||
* @param dpd DPD check interval, 0 to disable
|
||||
* @param dpd_timeout DPD timeout interval (IKEv1 only), if 0 default applies
|
||||
* @param pool pool name to get configuration attributes from, or NULL
|
||||
* @param mediation TRUE if this is a mediation connection
|
||||
* @param mediated_by peer_cfg_t of the mediation connection to mediate through
|
||||
* @param peer_id ID that identifies our peer at the mediation server
|
||||
@@ -390,7 +396,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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user