diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2015-10-22 11:43:58 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2015-11-03 17:16:28 +0100 |
commit | 27902f634ea544c1f077b19a26ca8c81b67059f3 (patch) | |
tree | 2f0977205608987a9239d39111f02ea1c086c1af /src/libcharon/config/ike_cfg.c | |
parent | 3b7ae6673ae7bc330d0305098cd9818a4f6a7856 (diff) | |
download | vyos-strongswan-27902f634ea544c1f077b19a26ca8c81b67059f3.tar.gz vyos-strongswan-27902f634ea544c1f077b19a26ca8c81b67059f3.zip |
Imported Upstream version 5.3.3
Diffstat (limited to 'src/libcharon/config/ike_cfg.c')
-rw-r--r-- | src/libcharon/config/ike_cfg.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/libcharon/config/ike_cfg.c b/src/libcharon/config/ike_cfg.c index 9464ceb5d..dee9e4c29 100644 --- a/src/libcharon/config/ike_cfg.c +++ b/src/libcharon/config/ike_cfg.c @@ -1,4 +1,5 @@ /* + * Copyright (C) 2012-2015 Tobias Brunner * Copyright (C) 2005-2007 Martin Willi * Copyright (C) 2005 Jan Hutter * Hochschule fuer Technik Rapperswil @@ -513,6 +514,52 @@ static void parse_addresses(char *str, linked_list_t *hosts, /** * Described in header. */ +int ike_cfg_get_family(ike_cfg_t *cfg, bool local) +{ + private_ike_cfg_t *this = (private_ike_cfg_t*)cfg; + enumerator_t *enumerator; + host_t *host; + char *str; + int family = AF_UNSPEC; + + if (local) + { + enumerator = this->my_hosts->create_enumerator(this->my_hosts); + } + else + { + enumerator = this->other_hosts->create_enumerator(this->other_hosts); + } + while (enumerator->enumerate(enumerator, &str)) + { + if (streq(str, "%any")) + { /* ignore %any as its family is undetermined */ + continue; + } + host = host_create_from_string(str, 0); + if (host) + { + if (family == AF_UNSPEC) + { + family = host->get_family(host); + } + else if (family != host->get_family(host)) + { + /* more than one address family defined */ + family = AF_UNSPEC; + host->destroy(host); + break; + } + } + DESTROY_IF(host); + } + enumerator->destroy(enumerator); + return family; +} + +/** + * Described in header. + */ ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap, char *me, u_int16_t my_port, char *other, u_int16_t other_port, |