diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-11-01 13:32:07 +0100 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-11-01 13:32:07 +0100 |
commit | 5313d2d78ca150515f7f5eb39801c100690b6b29 (patch) | |
tree | c78e420367283bb1b16f14210b12687cdfbd26eb /src/libcharon/sa/ike_sa.c | |
parent | 6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (diff) | |
download | vyos-strongswan-5313d2d78ca150515f7f5eb39801c100690b6b29.tar.gz vyos-strongswan-5313d2d78ca150515f7f5eb39801c100690b6b29.zip |
Imported Upstream version 5.1.1
Diffstat (limited to 'src/libcharon/sa/ike_sa.c')
-rw-r--r-- | src/libcharon/sa/ike_sa.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/libcharon/sa/ike_sa.c b/src/libcharon/sa/ike_sa.c index 2f4e1123c..028208782 100644 --- a/src/libcharon/sa/ike_sa.c +++ b/src/libcharon/sa/ike_sa.c @@ -1077,7 +1077,7 @@ METHOD(ike_sa_t, initiate_mediated, status_t, static void resolve_hosts(private_ike_sa_t *this) { host_t *host; - int family = 0; + int family = AF_UNSPEC; switch (charon->socket->supported_families(charon->socket)) { @@ -1099,12 +1099,7 @@ static void resolve_hosts(private_ike_sa_t *this) } else { - char *other_addr; - u_int16_t other_port; - - other_addr = this->ike_cfg->get_other_addr(this->ike_cfg, NULL); - other_port = this->ike_cfg->get_other_port(this->ike_cfg); - host = host_create_from_dns(other_addr, family, other_port); + host = this->ike_cfg->resolve_other(this->ike_cfg, family); } if (host) { @@ -1118,17 +1113,12 @@ static void resolve_hosts(private_ike_sa_t *this) } else { - char *my_addr; - u_int16_t my_port; - /* use same address family as for other */ if (!this->other_host->is_anyaddr(this->other_host)) { family = this->other_host->get_family(this->other_host); } - my_addr = this->ike_cfg->get_my_addr(this->ike_cfg, NULL); - my_port = this->ike_cfg->get_my_port(this->ike_cfg); - host = host_create_from_dns(my_addr, family, my_port); + host = this->ike_cfg->resolve_me(this->ike_cfg, family); if (host && host->is_anyaddr(host) && !this->other_host->is_anyaddr(this->other_host)) @@ -1142,7 +1132,7 @@ static void resolve_hosts(private_ike_sa_t *this) } else { /* fallback to address family specific %any(6), if configured */ - host = host_create_from_dns(my_addr, family, my_port); + host = this->ike_cfg->resolve_me(this->ike_cfg, family); } } } @@ -1172,8 +1162,14 @@ METHOD(ike_sa_t, initiate, status_t, #endif /* ME */ ) { - char *addr = this->ike_cfg->get_other_addr(this->ike_cfg, NULL); - bool is_anyaddr = streq(addr, "%any") || streq(addr, "%any6"); + bool is_anyaddr; + host_t *host; + char *addr; + + addr = this->ike_cfg->get_my_addr(this->ike_cfg); + host = this->ike_cfg->resolve_other(this->ike_cfg, AF_UNSPEC); + is_anyaddr = host && host->is_anyaddr(host); + DESTROY_IF(host); if (is_anyaddr || !this->retry_initiate_interval) { @@ -1659,6 +1655,8 @@ METHOD(ike_sa_t, reestablish, status_t, new->set_other_host(new, host->clone(host)); host = this->my_host; new->set_my_host(new, host->clone(host)); + /* resolve hosts but use the old addresses above as fallback */ + resolve_hosts((private_ike_sa_t*)new); /* if we already have a virtual IP, we reuse it */ enumerator = array_create_enumerator(this->my_vips); while (enumerator->enumerate(enumerator, &host)) |