diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2018-05-04 16:44:45 +0200 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2018-05-04 16:44:45 +0200 |
commit | 3a9d92818b4c2f083e26fe164a1be82212bd4061 (patch) | |
tree | 8ca4551b60f44cbb816373231c31752194cbcdcd /stun | |
parent | e6217f8eba6ea17d90eac67ef5fa5412fbf10dad (diff) | |
download | libnice-3a9d92818b4c2f083e26fe164a1be82212bd4061.tar.gz |
stund: Pass the right length for ipv6
Diffstat (limited to 'stun')
-rw-r--r-- | stun/tools/stund.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/stun/tools/stund.c b/stun/tools/stund.c index addc4fa..c148e51 100644 --- a/stun/tools/stund.c +++ b/stun/tools/stund.c @@ -100,6 +100,8 @@ int listen_socket (int fam, int type, int proto, unsigned int port) struct sockaddr_in6 in6; struct sockaddr_storage storage; } addr; + int len; + if (fd == -1) { perror ("Error opening IP port"); @@ -118,6 +120,7 @@ int listen_socket (int fam, int type, int proto, unsigned int port) { case AF_INET: addr.in.sin_port = htons (port); + len = sizeof (struct sockaddr_in); break; case AF_INET6: @@ -125,13 +128,14 @@ int listen_socket (int fam, int type, int proto, unsigned int port) setsockopt (fd, SOL_IPV6, IPV6_V6ONLY, &yes, sizeof (yes)); #endif addr.in6.sin6_port = htons (port); + len = sizeof (struct sockaddr_in6); break; default: assert (0); /* should never be reached */ } - if (bind (fd, &addr.addr, sizeof (struct sockaddr))) + if (bind (fd, &addr.addr, len)) { perror ("Error opening IP port"); goto error; |