diff options
author | Tobias Brunner <tobias@strongswan.org> | 2016-02-04 18:35:07 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2016-03-10 11:57:38 +0100 |
commit | e8262251e17f97497331dca84a8d490c7605ef69 (patch) | |
tree | 566b36fff0ecab153678d80db6e4246af0e9ad67 | |
parent | 3d91d013cc4b0d9da69ecc800016db6164b2a7fc (diff) | |
download | strongswan-e8262251e17f97497331dca84a8d490c7605ef69.tar.bz2 strongswan-e8262251e17f97497331dca84a8d490c7605ef69.tar.xz |
p-cscf: Only send requests if virtual IPs of the same family are requested
-rw-r--r-- | src/libcharon/plugins/p_cscf/p_cscf_handler.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/libcharon/plugins/p_cscf/p_cscf_handler.c b/src/libcharon/plugins/p_cscf/p_cscf_handler.c index 15313ea6a..f122f9ac4 100644 --- a/src/libcharon/plugins/p_cscf/p_cscf_handler.c +++ b/src/libcharon/plugins/p_cscf/p_cscf_handler.c @@ -103,6 +103,22 @@ METHOD(enumerator_t, enumerate_attrs, bool, return FALSE; } +/** + * Check if the given host has a matching address family + */ +static bool is_family(host_t *host, int *family) +{ + return host->get_family(host) == *family; +} + +/** + * Check if a list has a host of a given family + */ +static bool has_host_family(linked_list_t *list, int family) +{ + return list->find_first(list, (void*)is_family, NULL, &family) == SUCCESS; +} + METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *, private_p_cscf_handler_t *this, ike_sa_t *ike_sa, linked_list_t *vips) @@ -119,8 +135,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *, .enumerate = (void*)_enumerate_attrs, .destroy = (void*)free, }, - .request_ipv4 = TRUE, - .request_ipv6 = TRUE, + .request_ipv4 = has_host_family(vips, AF_INET), + .request_ipv6 = has_host_family(vips, AF_INET6), ); return &enumerator->public; } |