support command-line ipv6 addresses given in [] format

git.mgm/mediaproxy-ng/2.0
Richard Fuchs 14 years ago
parent 7129c25e64
commit 8bc2f0505d

@ -113,6 +113,14 @@ static inline void smart_ntop(char *o, struct in6_addr *a, size_t len) {
inet_ntop(AF_INET6, a, o, len);
}
static inline int smart_pton(int af, const char *src, void *dst) {
if (af == AF_INET6) {
if (src[0] == '[')
return inet_pton(af, src+1, dst);
}
return inet_pton(af, src, dst);
}
#endif

@ -197,11 +197,11 @@ static void options(int *argc, char ***argv) {
}
if (ipv6s) {
if (inet_pton(AF_INET6, ipv6s, &ipv6) != 1)
if (smart_pton(AF_INET6, ipv6s, &ipv6) != 1)
die("Invalid IPv6 address (--ip6)\n");
}
if (adv_ipv6s) {
if (inet_pton(AF_INET6, adv_ipv6s, &adv_ipv6) != 1)
if (smart_pton(AF_INET6, adv_ipv6s, &adv_ipv6) != 1)
die("Invalid IPv6 address (--advertised-ip6)\n");
}

Loading…
Cancel
Save