From c3340cf8dacc2ff61fda73315da1f93b82d6ffe9 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 19 Mar 2009 09:16:03 +0000 Subject: [PATCH] respect port in create_dns/create_from_string when passing %any --- src/libstrongswan/utils/host.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libstrongswan/utils/host.c b/src/libstrongswan/utils/host.c index 6a6a49089..d42ec5f00 100644 --- a/src/libstrongswan/utils/host.c +++ b/src/libstrongswan/utils/host.c @@ -364,6 +364,18 @@ static private_host_t *host_create_empty(void) return this; } +/* + * Create a %any host with port + */ +static host_t *host_create_any_port(int family, u_int16_t port) +{ + host_t *this; + + this = host_create_any(family); + this->set_port(this, port); + return this; +} + /* * Described in header. */ @@ -373,11 +385,11 @@ host_t *host_create_from_string(char *string, u_int16_t port) if (streq(string, "%any")) { - return host_create_any(AF_INET); + return host_create_any_port(AF_INET, port); } if (streq(string, "%any6")) { - return host_create_any(AF_INET6); + return host_create_any_port(AF_INET6, port); } this = host_create_empty(); @@ -432,11 +444,11 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port) if (streq(string, "%any")) { - return host_create_any(af ? af : AF_INET); + return host_create_any_port(af ? af : AF_INET, port); } if (streq(string, "%any6")) { - return host_create_any(af ? af : AF_INET6); + return host_create_any_port(af ? af : AF_INET6, port); } else if (strchr(string, ':')) {