/* release virtual IP address lease if any */
if (c->spd.that.modecfg && c->spd.that.pool &&
- !isanyaddr(&c->spd.that.host_srcip))
+ !c->spd.that.host_srcip->is_anyaddr(c->spd.that.host_srcip))
{
- host_t *vip;
-
- vip = host_create_from_sockaddr((sockaddr_t*)&c->spd.that.host_srcip);
hydra->attributes->release_address(hydra->attributes, c->spd.that.pool,
- vip, c->spd.that.id);
- vip->destroy(vip);
+ c->spd.that.host_srcip, c->spd.that.id);
}
/* release requested attributes if any */
DESTROY_IF(c->spd.this.id);
DESTROY_IF(c->spd.this.ca);
DESTROY_IF(c->spd.this.groups);
+ DESTROY_IF(c->spd.this.host_srcip);
+
free(c->spd.this.updown);
free(c->spd.this.pool);
DESTROY_IF(c->spd.that.id);
DESTROY_IF(c->spd.that.ca);
DESTROY_IF(c->spd.that.groups);
+ DESTROY_IF(c->spd.that.host_srcip);
free(c->spd.that.updown);
free(c->spd.that.pool);
if (c->requested_ca)
subnettot(&this->client, 0, client, sizeof(client));
}
}
- else if (this->modecfg && isanyaddr(&this->host_srcip))
+ else if (this->modecfg && this->host_srcip->is_anyaddr(this->host_srcip))
{
/* we are mode config client, or a server with a pool */
client_sep = "===";
c->spd.this.id = c->spd.this.id->clone(c->spd.this.id);
c->spd.this.pool = clone_str(c->spd.this.pool);
c->spd.this.updown = clone_str(c->spd.this.updown);
+ c->spd.this.host_srcip = c->spd.this.host_srcip->clone(c->spd.this.host_srcip);
scx_share(c->spd.this.sc);
cert_share(c->spd.this.cert);
if (c->spd.this.ca)
c->spd.that.id = c->spd.that.id->clone(c->spd.that.id);
c->spd.that.pool = clone_str(c->spd.that.pool);
c->spd.that.updown = clone_str(c->spd.that.updown);
+ c->spd.that.host_srcip = c->spd.that.host_srcip->clone(c->spd.that.host_srcip);
scx_share(c->spd.that.sc);
cert_share(c->spd.that.cert);
if (c->spd.that.ca)
/* the rest is simple copying of corresponding fields */
dst->host_addr = src->host_addr;
dst->host_nexthop = src->host_nexthop;
- dst->host_srcip = src->host_srcip;
+ dst->host_srcip = host_create_from_sockaddr((sockaddr_t*)&src->host_srcip);
dst->has_natip = src->has_natip;
dst->client = src->client;
dst->protocol = src->protocol;
/* if host sourceip is defined but no client is present
* behind the host then set client to sourceip/32
*/
- if (addrbytesptr(&dst->host_srcip, NULL) &&
- !isanyaddr(&dst->host_srcip) && !dst->has_natip && !dst->has_client)
+ if (!dst->host_srcip->is_anyaddr(dst->host_srcip) &&
+ !dst->has_natip && !dst->has_client)
{
- err_t ugh = addrtosubnet(&dst->host_srcip, &dst->client);
+ ip_address addr;
+ err_t ugh;
+
+ addr = *(ip_address*)dst->host_srcip->get_sockaddr(dst->host_srcip);
+ ugh = addrtosubnet(&addr, &dst->client);
if (ugh)
{
c->spd.that.modecfg = TRUE;
c->spd.that.has_client = FALSE;
/* reset the host_srcip so that it gets assigned in modecfg */
- anyaddr(AF_INET, &c->spd.that.host_srcip);
+ DESTROY_IF(c->spd.that.host_srcip);
+ c->spd.that.host_srcip = host_create_any(AF_INET);
}
if (c->ikev1)
/* the connection is now oriented so that we are able to determine
* whether we are a mode config server with a virtual IP to send.
*/
- if (!isanyaddr(&c->spd.that.host_srcip) && !c->spd.that.has_natip)
+ if (!c->spd.that.host_srcip->is_anyaddr(c->spd.that.host_srcip) &&
+ !c->spd.that.has_natip)
{
c->spd.that.modecfg = TRUE;
}
}
else
{
+ host_t *vip = c->spd.that.host_srcip;
+
if (!peer_net_is_host && !(sr->that.modecfg && c->spd.that.modecfg &&
- subnetisaddr(peer_net, &c->spd.that.host_srcip)))
+ subnetisaddr(peer_net, (ip_address*)vip->get_sockaddr(vip))))
{
continue;
}