diff --git a/CHANGES b/CHANGES index fde55804d4..594f551ef3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1146. [func] Allow IPV6_IPV6ONLY to be set/cleared on a socket if + supported by the OS by a new function + isc_socket_ipv6only(). + 1145. [func] "host" no longer reports a NOERROR/NODATA response by printing nothing. [RT #2065] diff --git a/lib/isc/include/isc/socket.h b/lib/isc/include/isc/socket.h index 50ba2c42a4..a2dd8ffb07 100644 --- a/lib/isc/include/isc/socket.h +++ b/lib/isc/include/isc/socket.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.h,v 1.54 2001/03/06 01:23:02 bwelling Exp $ */ +/* $Id: socket.h,v 1.55 2001/11/29 07:31:25 marka Exp $ */ #ifndef ISC_SOCKET_H #define ISC_SOCKET_H 1 @@ -682,6 +682,16 @@ isc_socket_gettype(isc_socket_t *sock); isc_boolean_t isc_socket_isbound(isc_socket_t *sock); +void +isc_socket_ipv6only(isc_socket_t *sock, isc_boolean_t yes); +/* + * If the socket is an IPv6 socket set/clear the IPV6_IPV6ONLY socket + * option if the host OS supports this option. + * + * Requires: + * 'sock' is a valid socket. + */ + ISC_LANG_ENDDECLS #endif /* ISC_SOCKET_H */ diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index a395b35b64..20011f7340 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.215 2001/11/27 01:56:19 gson Exp $ */ +/* $Id: socket.c,v 1.216 2001/11/29 07:31:22 marka Exp $ */ #include @@ -3310,6 +3310,25 @@ isc_socket_isbound(isc_socket_t *sock) { return (val); } +void +isc_socket_ipv6only(isc_socket_t *sock, isc_boolean_t yes) { +#if defined(IPV6_V6ONLY) + int onoff = yes ? 1 : 0; +#else + UNUSED(yes); + UNUSED(sock); +#endif + + REQUIRE(VALID_SOCKET(sock)); + +#ifdef IPV6_V6ONLY + if (sock->pf == AF_INET6) { + (void)setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&onoff, sizeof(onoff)); + } +#endif +} + #ifndef ISC_PLATFORM_USETHREADS void isc__socketmgr_getfdsets(fd_set *readset, fd_set *writeset, int *maxfd) { diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index cc0e9769c5..442255b640 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.11 2001/11/27 01:56:22 gson Exp $ */ +/* $Id: socket.c,v 1.12 2001/11/29 07:31:23 marka Exp $ */ #define MAKE_EXTERNAL 1 @@ -3401,3 +3401,11 @@ isc_socket_isbound(isc_socket_t *sock) { return (val); } + +void +isc_socket_ipv6only(isc_socket_t *sock, isc_boolean_t yes) { + UNUSED(yes); + UNUSED(sock); + + REQUIRE(VALID_SOCKET(sock)); +}