summaryrefslogtreecommitdiff
path: root/network_io/win32
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2011-04-13 12:01:09 +0000
committerJeff Trawick <trawick@apache.org>2011-04-13 12:01:09 +0000
commit25d1b0f00aa0ca3fd2b48028f02490cd95dd0fbe (patch)
tree31259cf0e602267703655734bad9d48b14d096b4 /network_io/win32
parent6e20429d1f0831e88fba9f40d6b003a243e8de8f (diff)
downloadapr-25d1b0f00aa0ca3fd2b48028f02490cd95dd0fbe.tar.gz
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 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1091757 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io/win32')
-rw-r--r--network_io/win32/sockets.c6
-rw-r--r--network_io/win32/sockopt.c21
2 files changed, 26 insertions, 1 deletions
diff --git a/network_io/win32/sockets.c b/network_io/win32/sockets.c
index a5ed15899..be7ddcbde 100644
--- a/network_io/win32/sockets.c
+++ b/network_io/win32/sockets.c
@@ -51,6 +51,12 @@ static void set_socket_vars(apr_socket_t *sock, int family, int type, int protoc
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)
{
diff --git a/network_io/win32/sockopt.c b/network_io/win32/sockopt.c
index c5a4e7715..62b50d0a9 100644
--- a/network_io/win32/sockopt.c
+++ b/network_io/win32/sockopt.c
@@ -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_set(apr_socket_t *sock,
}
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