changeset 3373:690dcc51cdc1 HEAD

if using IPv6, bind both on the IPv4 and IPv6 addresses if IPV6_V6ONLY is defined. Patch by Marco d'Itri
author Timo Sirainen <tss@iki.fi>
date Fri, 13 May 2005 16:35:19 +0300
parents 7e046c4cba1f
children 8b2dd340e16d
files src/lib/network.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/network.c	Fri May 13 16:11:17 2005 +0300
+++ b/src/lib/network.c	Fri May 13 16:35:19 2005 +0300
@@ -271,6 +271,13 @@
 	setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
 	setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt));
 
+	/* if using IPv6, bind both on the IPv4 and IPv6 addresses */
+#ifdef IPV6_V6ONLY
+	if (so.sin.sin_family == AF_INET6) {
+		opt = 0;
+		setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt));
+	}
+#endif
 	/* specify the address/port we want to listen in */
 	ret = bind(fd, &so.sa, SIZEOF_SOCKADDR(so));
 	if (ret >= 0) {