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/config/backend_manager.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/config/backend_manager.c')
-rw-r--r-- | src/libcharon/config/backend_manager.c | 64 |
1 files changed, 15 insertions, 49 deletions
diff --git a/src/libcharon/config/backend_manager.c b/src/libcharon/config/backend_manager.c index f47d5715a..79f1d9fee 100644 --- a/src/libcharon/config/backend_manager.c +++ b/src/libcharon/config/backend_manager.c @@ -84,10 +84,8 @@ static enumerator_t *ike_enum_create(backend_t *backend, ike_data_t *data) static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other, ike_version_t version) { - host_t *me_cand, *other_cand; - char *my_addr, *other_addr; - bool my_allow_any, other_allow_any; ike_cfg_match_t match = MATCH_NONE; + int quality; if (cand->get_version(cand) != IKE_ANY && version != cand->get_version(cand)) @@ -97,26 +95,12 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other, if (me) { - my_addr = cand->get_my_addr(cand, &my_allow_any); - me_cand = host_create_from_dns(my_addr, me->get_family(me), 0); - if (!me_cand) - { - return MATCH_NONE; - } - if (me_cand->ip_equals(me_cand, me)) - { - match += MATCH_ME; - } - else if (my_allow_any || me_cand->is_anyaddr(me_cand)) - { - match += MATCH_ANY; - } - else + quality = cand->match_me(cand, me); + if (!quality) { - me_cand->destroy(me_cand); return MATCH_NONE; } - me_cand->destroy(me_cand); + match += quality * MATCH_ME; } else { @@ -125,26 +109,12 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other, if (other) { - other_addr = cand->get_other_addr(cand, &other_allow_any); - other_cand = host_create_from_dns(other_addr, other->get_family(other), 0); - if (!other_cand) + quality = cand->match_other(cand, other); + if (!quality) { return MATCH_NONE; } - if (other_cand->ip_equals(other_cand, other)) - { - match += MATCH_OTHER; - } - else if (other_allow_any || other_cand->is_anyaddr(other_cand)) - { - match += MATCH_ANY; - } - else - { - other_cand->destroy(other_cand); - return MATCH_NONE; - } - other_cand->destroy(other_cand); + match += quality * MATCH_OTHER; } else { @@ -165,7 +135,6 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*, { ike_cfg_t *current, *found = NULL; char *my_addr, *other_addr; - bool my_allow_any, other_allow_any; enumerator_t *enumerator; ike_cfg_match_t match, best = MATCH_ANY; ike_data_t *data; @@ -189,11 +158,10 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*, match, me, other, ike_version_names, version); if (match) { - my_addr = current->get_my_addr(current, &my_allow_any); - other_addr = current->get_other_addr(current, &other_allow_any); - DBG2(DBG_CFG, " candidate: %s%s...%s%s, prio %d", - my_allow_any ? "%":"", my_addr, - other_allow_any ? "%":"", other_addr, match); + my_addr = current->get_my_addr(current); + other_addr = current->get_other_addr(current); + DBG2(DBG_CFG, " candidate: %s...%s, prio %d", + my_addr, other_addr, match); if (match > best) { DESTROY_IF(found); @@ -207,11 +175,10 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*, this->lock->unlock(this->lock); if (found) { - my_addr = found->get_my_addr(found, &my_allow_any); - other_addr = found->get_other_addr(found, &other_allow_any); - DBG2(DBG_CFG, "found matching ike config: %s%s...%s%s with prio %d", - my_allow_any ? "%":"", my_addr, - other_allow_any ? "%":"", other_addr, best); + my_addr = found->get_my_addr(found); + other_addr = found->get_other_addr(found); + DBG2(DBG_CFG, "found matching ike config: %s...%s with prio %d", + my_addr, other_addr, best); } return found; } @@ -481,4 +448,3 @@ backend_manager_t *backend_manager_create() return &this->public; } - |