fixed rightsourceip=%config scenarios
This commit is contained in:
@@ -62,7 +62,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
static void pool_destroy(pool_t *this)
|
static void pool_destroy(pool_t *this)
|
||||||
{
|
{
|
||||||
this->base->destroy(this->base);
|
DESTROY_IF(this->base);
|
||||||
free(this->name);
|
free(this->name);
|
||||||
free(this->in_use);
|
free(this->in_use);
|
||||||
free(this);
|
free(this);
|
||||||
@@ -167,6 +167,12 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
|
|||||||
if (pool)
|
if (pool)
|
||||||
{
|
{
|
||||||
if (requested && !requested->is_anyaddr(requested))
|
if (requested && !requested->is_anyaddr(requested))
|
||||||
|
{
|
||||||
|
if (pool->count == 0)
|
||||||
|
{ /* %config, give any */
|
||||||
|
host = requested->clone(requested);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
i = host2offset(pool, requested);
|
i = host2offset(pool, requested);
|
||||||
if (i >= 0 && !pool->in_use[i])
|
if (i >= 0 && !pool->in_use[i])
|
||||||
@@ -175,6 +181,7 @@ static host_t* acquire_address(private_stroke_attribute_t *this,
|
|||||||
host = requested->clone(requested);
|
host = requested->clone(requested);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!host)
|
if (!host)
|
||||||
{
|
{
|
||||||
for (i = 0; i < pool->count; i++)
|
for (i = 0; i < pool->count; i++)
|
||||||
@@ -205,6 +212,8 @@ static bool release_address(private_stroke_attribute_t *this,
|
|||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
pool = find_pool(this, name);
|
pool = find_pool(this, name);
|
||||||
if (pool)
|
if (pool)
|
||||||
|
{
|
||||||
|
if (pool->count != 0)
|
||||||
{
|
{
|
||||||
i = host2offset(pool, address);
|
i = host2offset(pool, address);
|
||||||
if (i >= 0 && pool->in_use[i])
|
if (i >= 0 && pool->in_use[i])
|
||||||
@@ -213,6 +222,7 @@ static bool release_address(private_stroke_attribute_t *this,
|
|||||||
found = TRUE;
|
found = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this->mutex->unlock(this->mutex);
|
this->mutex->unlock(this->mutex);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
@@ -222,9 +232,12 @@ static bool release_address(private_stroke_attribute_t *this,
|
|||||||
*/
|
*/
|
||||||
static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
|
static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
|
||||||
{
|
{
|
||||||
if (msg->add_conn.other.sourceip && msg->add_conn.other.sourceip_size)
|
if (msg->add_conn.other.sourceip_size)
|
||||||
{
|
{
|
||||||
pool_t *pool;
|
pool_t *pool;
|
||||||
|
|
||||||
|
if (msg->add_conn.other.sourceip)
|
||||||
|
{
|
||||||
u_int32_t bits;
|
u_int32_t bits;
|
||||||
int family;
|
int family;
|
||||||
|
|
||||||
@@ -258,6 +271,15 @@ static void add_pool(private_stroke_attribute_t *this, stroke_msg_t *msg)
|
|||||||
pool->in_use[0] = TRUE;
|
pool->in_use[0] = TRUE;
|
||||||
pool->in_use[pool->count-1] = TRUE;
|
pool->in_use[pool->count-1] = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* %config, add an empty pool */
|
||||||
|
pool = malloc_thing(pool_t);
|
||||||
|
pool->name = strdup(msg->add_conn.name);
|
||||||
|
pool->base = NULL;
|
||||||
|
pool->count = 0;
|
||||||
|
pool->in_use = NULL;
|
||||||
|
}
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
this->pools->insert_last(this->pools, pool);
|
this->pools->insert_last(this->pools, pool);
|
||||||
this->mutex->unlock(this->mutex);
|
this->mutex->unlock(this->mutex);
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
|
|||||||
msg->add_conn.eap_type, msg->add_conn.eap_vendor,
|
msg->add_conn.eap_type, msg->add_conn.eap_vendor,
|
||||||
msg->add_conn.rekey.tries, rekey, reauth, jitter, over,
|
msg->add_conn.rekey.tries, rekey, reauth, jitter, over,
|
||||||
msg->add_conn.mobike, msg->add_conn.dpd.delay,
|
msg->add_conn.mobike, msg->add_conn.dpd.delay,
|
||||||
vip, msg->add_conn.other.sourceip ? msg->add_conn.name : NULL,
|
vip, msg->add_conn.other.sourceip_size ? msg->add_conn.name : NULL,
|
||||||
msg->add_conn.ikeme.mediation, mediated_by, peer_id);
|
msg->add_conn.ikeme.mediation, mediated_by, peer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -302,14 +302,17 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
|
|||||||
|
|
||||||
if (config && this->virtual_ip)
|
if (config && this->virtual_ip)
|
||||||
{
|
{
|
||||||
host_t *ip;
|
host_t *ip = NULL;
|
||||||
|
|
||||||
DBG1(DBG_IKE, "peer requested virtual IP %H", this->virtual_ip);
|
DBG1(DBG_IKE, "peer requested virtual IP %H", this->virtual_ip);
|
||||||
|
if (config->get_pool(config))
|
||||||
|
{
|
||||||
ip = charon->attributes->acquire_address(charon->attributes,
|
ip = charon->attributes->acquire_address(charon->attributes,
|
||||||
config->get_pool(config),
|
config->get_pool(config),
|
||||||
this->ike_sa->get_other_id(this->ike_sa),
|
this->ike_sa->get_other_id(this->ike_sa),
|
||||||
this->ike_sa->get_other_auth(this->ike_sa),
|
this->ike_sa->get_other_auth(this->ike_sa),
|
||||||
this->virtual_ip);
|
this->virtual_ip);
|
||||||
|
}
|
||||||
if (ip == NULL)
|
if (ip == NULL)
|
||||||
{
|
{
|
||||||
DBG1(DBG_IKE, "not assigning a virtual IP to peer");
|
DBG1(DBG_IKE, "not assigning a virtual IP to peer");
|
||||||
|
|||||||
Reference in New Issue
Block a user