From b6dfc76c2557595b1e1a7e51f1672895ebbbbf6c Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Mon, 11 Jun 2007 22:32:55 +0200 Subject: [PATCH] Set IPV6_V6ONLY on the protocol socket. --- net.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/net.c b/net.c index 29c88945..03b5a0d0 100644 --- a/net.c +++ b/net.c @@ -42,14 +42,11 @@ babel_socket(int port) if(s < 0) return -1; - rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + rc = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)); if(rc < 0) goto fail; - memset(&sin6, 0, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_port = htons(port); - rc = bind(s, (struct sockaddr*)&sin6, sizeof(sin6)); + rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); if(rc < 0) goto fail; @@ -76,6 +73,13 @@ babel_socket(int port) if(rc < 0) goto fail; + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_family = AF_INET6; + sin6.sin6_port = htons(port); + rc = bind(s, (struct sockaddr*)&sin6, sizeof(sin6)); + if(rc < 0) + goto fail; + return s; fail: