diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-08-25 15:37:26 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-08-25 15:37:26 +0200 |
commit | 6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (patch) | |
tree | 009fc492961e13860d2a4bc2de8caf2bbe2975e7 /src/libstrongswan/selectors | |
parent | c83921a2b566aa9d55d8ccc7258f04fca6292ee6 (diff) | |
download | vyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.tar.gz vyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.zip |
Imported Upstream version 5.1.0
Diffstat (limited to 'src/libstrongswan/selectors')
-rw-r--r-- | src/libstrongswan/selectors/traffic_selector.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/libstrongswan/selectors/traffic_selector.c b/src/libstrongswan/selectors/traffic_selector.c index ff8285f8c..75a8717dd 100644 --- a/src/libstrongswan/selectors/traffic_selector.c +++ b/src/libstrongswan/selectors/traffic_selector.c @@ -814,38 +814,32 @@ traffic_selector_t *traffic_selector_create_from_string( char *from_addr, u_int16_t from_port, char *to_addr, u_int16_t to_port) { - private_traffic_selector_t *this = traffic_selector_create(protocol, type, - from_port, to_port); + private_traffic_selector_t *this; + int family; switch (type) { case TS_IPV4_ADDR_RANGE: - if (inet_pton(AF_INET, from_addr, (struct in_addr*)this->from4) < 0) - { - free(this); - return NULL; - } - if (inet_pton(AF_INET, to_addr, (struct in_addr*)this->to4) < 0) - { - free(this); - return NULL; - } + family = AF_INET; break; case TS_IPV6_ADDR_RANGE: - if (inet_pton(AF_INET6, from_addr, (struct in6_addr*)this->from6) < 0) - { - free(this); - return NULL; - } - if (inet_pton(AF_INET6, to_addr, (struct in6_addr*)this->to6) < 0) - { - free(this); - return NULL; - } + family = AF_INET6; break; + default: + return NULL; } + + this = traffic_selector_create(protocol, type, from_port, to_port); + + if (inet_pton(family, from_addr, this->from) != 1 || + inet_pton(family, to_addr, this->to) != 1) + { + free(this); + return NULL; + } + calc_netbits(this); - return (&this->public); + return &this->public; } /* |