From: Tobias Brunner Date: Thu, 4 Feb 2016 17:35:07 +0000 (+0100) Subject: p-cscf: Only send requests if virtual IPs of the same family are requested X-Git-Tag: 5.4.0rc1~9^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8262251e17f97497331dca84a8d490c7605ef69;p=thirdparty%2Fstrongswan.git p-cscf: Only send requests if virtual IPs of the same family are requested --- diff --git a/src/libcharon/plugins/p_cscf/p_cscf_handler.c b/src/libcharon/plugins/p_cscf/p_cscf_handler.c index 15313ea6a6..f122f9ac41 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; }