aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/charon/sa/ike_sa.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/charon/sa/ike_sa.c b/src/charon/sa/ike_sa.c
index 6805a7ea6..feb8d8dad 100644
--- a/src/charon/sa/ike_sa.c
+++ b/src/charon/sa/ike_sa.c
@@ -1041,18 +1041,28 @@ static void resolve_hosts(private_ike_sa_t *this)
{
host_t *host;
- host = host_create_from_dns(this->ike_cfg->get_my_addr(this->ike_cfg), 0,
- IKEV2_UDP_PORT);
+ host = host_create_from_dns(this->ike_cfg->get_other_addr(this->ike_cfg),
+ 0, IKEV2_UDP_PORT);
if (host)
{
- set_my_host(this, host);
+ set_other_host(this, host);
}
- host = host_create_from_dns(this->ike_cfg->get_other_addr(this->ike_cfg),
+
+ host = host_create_from_dns(this->ike_cfg->get_my_addr(this->ike_cfg),
this->my_host->get_family(this->my_host),
IKEV2_UDP_PORT);
+
+ if (host && host->is_anyaddr(host) &&
+ !this->other_host->is_anyaddr(this->other_host))
+ {
+ host->destroy(host);
+ host = charon->kernel_interface->get_source_addr(
+ charon->kernel_interface, this->other_host);
+ host->set_port(host, IKEV2_UDP_PORT);
+ }
if (host)
{
- set_other_host(this, host);
+ set_my_host(this, host);
}
}