Author: trawick
Date: Wed Apr 13 12:01:09 2011
New Revision: 1091757
URL: http://svn.apache.org/viewvc?rev=1091757&view=rev
Log:
IPV6_V6ONLY on Windows:
* Deal with SDKs which don't have the symbol definition
* Deal with old run-time platforms which don't implement the option
and have hard-coded behavior internally (option always on)
Behavior changes:
run on Windows >= Vista, SDK has IPV6_V6ONLY:
no change in behavior
run on Windows >= Vista, SDK doesn't have IPV6_V6ONLY:
works just like SDK had the def'n (will return APR_SUCCESS on
IPv6 socket instead of WSAENOPROTOOPT)
run on Windows < Vista, regardless of SDK:
socket_opt_get/set(APR_IPV6_V6ONLY) reflect stack behavior (always on)
previously, if IPV6_V6ONLY was defined: set returned WSAENOPROTOOPT
previously, if IPV6_V6ONLY was not defined: set returned APR_ENOTIMPL
previously, regardless of IPV6_V6ONLY presence: get returned not-enabled
now: get always returns enabled; set returns APR_SUCCESS when enabling,
APR_ENOTIMPL when trying to disable
PR: 45321
Submitted by: Sob <sob hisoftware.cz>
Tweaked by: trawick
Modified:
apr/apr/trunk/network_io/win32/sockets.c
apr/apr/trunk/network_io/win32/sockopt.c
Modified: apr/apr/trunk/network_io/win32/sockets.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/win32/sockets.c?rev=1091757&r1=1091756&r2=1091757&view=diff
==============================================================================
--- apr/apr/trunk/network_io/win32/sockets.c (original)
+++ apr/apr/trunk/network_io/win32/sockets.c Wed Apr 13 12:01:09 2011
@@ -51,6 +51,12 @@ static void set_socket_vars(apr_socket_t
sock->protocol = protocol;
apr_sockaddr_vars_set(sock->local_addr, family, 0);
apr_sockaddr_vars_set(sock->remote_addr, family, 0);
+#if APR_HAVE_IPV6
+ /* hard-coded behavior for older Windows IPv6 */
+ if (apr_os_level < APR_WIN_VISTA && family == AF_INET6) {
+ apr_set_option(sock, APR_IPV6_V6ONLY, 1);
+ }
+#endif
}
static void alloc_socket(apr_socket_t **new, apr_pool_t *p)
{
Modified: apr/apr/trunk/network_io/win32/sockopt.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/win32/sockopt.c?rev=1091757&r1=1091756&r2=1091757&view=diff
==============================================================================
--- apr/apr/trunk/network_io/win32/sockopt.c (original)
+++ apr/apr/trunk/network_io/win32/sockopt.c Wed Apr 13 12:01:09 2011
@@ -15,11 +15,20 @@
*/
#include "apr_arch_networkio.h"
+#include "apr_arch_misc.h" /* apr_os_level */
#include "apr_network_io.h"
#include "apr_general.h"
#include "apr_strings.h"
#include <string.h>
+/* IPV6_V6ONLY is missing from pre-Windows 2008 SDK as well as MinGW
+ * (at least up through 1.0.16).
+ * Runtime support is a separate issue.
+ */
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
static apr_status_t soblock(SOCKET sd)
{
u_long zero = 0;
@@ -195,7 +204,17 @@ APR_DECLARE(apr_status_t) apr_socket_opt
}
break;
case APR_IPV6_V6ONLY:
-#if APR_HAVE_IPV6 && defined(IPV6_V6ONLY)
+#if APR_HAVE_IPV6
+ if (apr_os_level < APR_WIN_VISTA &&
+ sock->local_addr->family == AF_INET6) {
+ /* apr_set_option() called at socket creation */
+ if (on) {
+ return APR_SUCCESS;
+ }
+ else {
+ return APR_ENOTIMPL;
+ }
+ }
/* we don't know the initial setting of this option,
* so don't check sock->options since that optimization
* won't work
|