Skip to content

Commit

Permalink
Set IPV6_V6ONLY on the protocol socket.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliusz Chroboczek committed Jun 11, 2007
1 parent e3e18ef commit b6dfc76
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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:
Expand Down

0 comments on commit b6dfc76

Please sign in to comment.