diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | include/apr_network_io.h | 3 | ||||
-rw-r--r-- | network_io/unix/sockopt.c | 14 | ||||
-rw-r--r-- | network_io/win32/sockopt.c | 14 |
4 files changed, 34 insertions, 0 deletions
@@ -1,4 +1,7 @@ Changes with APR 0.9.2 + + *) Add APR_IPV6_V6ONLY socket option. [Jeff Trawick] + *) Update timeout algorithm in free_proc_chain. If a subprocess did not exit immediately, the thread would sleep for 3 seconds before checking the subprocess exit status again. In a very diff --git a/include/apr_network_io.h b/include/apr_network_io.h index cd05cb63a..30eaa9786 100644 --- a/include/apr_network_io.h +++ b/include/apr_network_io.h @@ -130,6 +130,9 @@ extern "C" { #define APR_INCOMPLETE_WRITE 8192 /**< like APR_INCOMPLETE_READ, but for write * @see APR_INCOMPLETE_READ */ +#define APR_IPV6_V6ONLY 16384 /**< Don't accept IPv4 connections on an + * IPv6 listening socket. + */ /** @} */ diff --git a/network_io/unix/sockopt.c b/network_io/unix/sockopt.c index 41ed14746..31024a8aa 100644 --- a/network_io/unix/sockopt.c +++ b/network_io/unix/sockopt.c @@ -310,6 +310,20 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock, if (opt & APR_INCOMPLETE_READ) { apr_set_option(&sock->netmask, APR_INCOMPLETE_READ, on); } + if (opt & APR_IPV6_V6ONLY) { +#if APR_HAVE_IPV6 && defined(IPV6_V6ONLY) + /* we don't know the initial setting of this option, + * so don't check/set sock->netmask since that optimization + * won't work + */ + if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&on, sizeof(int)) == -1) { + return errno; + } +#else + return APR_ENOTIMPL; +#endif + } return APR_SUCCESS; } diff --git a/network_io/win32/sockopt.c b/network_io/win32/sockopt.c index 53f633265..c326f9dae 100644 --- a/network_io/win32/sockopt.c +++ b/network_io/win32/sockopt.c @@ -210,6 +210,20 @@ APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, apr_set_option(&sock->netmask, APR_TCP_NODELAY, on); } break; + case APR_IPV6_V6ONLY: +#if APR_HAVE_IPV6 && defined(IPV6_V6ONLY) + /* we don't know the initial setting of this option, + * so don't check/set sock->netmask since that optimization + * won't work + */ + if (setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&on, sizeof(int)) == -1) { + return apr_get_netos_error(); + } +#else + return APR_ENOTIMPL; +#endif + break; default: return APR_EINVAL; break; |