From 32bd2a8953356d41a8a665896ccebf7f96c0d9a0 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Mon, 19 Nov 2012 00:13:19 +0100 Subject: [PATCH] use IPV6_V6ONLY --- sndiod/listen.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sndiod/listen.c b/sndiod/listen.c index 11df33e..e80cd8c 100644 --- a/sndiod/listen.c +++ b/sndiod/listen.c @@ -166,6 +166,20 @@ listen_new_tcp(char *addr, unsigned int port) perror("setsockopt"); goto bad_close; } + if (ai->ai_family == AF_INET6) { + /* + * make sure IPv6 sockets are restricted to IPv6 + * addresses because we already use a IP socket + * for IP addresses + */ + opt = 1; + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + &opt, sizeof(int)) < 0) { + perror("setsockopt"); + goto bad_close; + } + } + if (bind(s, ai->ai_addr, ai->ai_addrlen) < 0) { perror("bind"); goto bad_close;