Philip Nilsson : ws2_32/tests: Add a testcase for binding with IPv6 and IPv4 on the same port.
Alexandre Julliard
julliard at winehq.org
Tue Sep 25 07:50:55 CDT 2007
Module: wine
Branch: master
Commit: 65dbd2b1140d397bfa658229ecf339ea7e7ca60c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=65dbd2b1140d397bfa658229ecf339ea7e7ca60c
Author: Philip Nilsson <wine-devel at nullref.se>
Date: Sat Sep 22 16:19:18 2007 +0200
ws2_32/tests: Add a testcase for binding with IPv6 and IPv4 on the same port.
---
dlls/ws2_32/tests/sock.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index d04552e..8225f5f 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1909,6 +1909,52 @@ end:
CloseHandle(hEvent);
}
+static void test_ipv6only(void)
+{
+ SOCKET v4 = INVALID_SOCKET,
+ v6 = INVALID_SOCKET;
+ struct sockaddr_in sin4;
+ struct sockaddr_in6 sin6;
+ int ret;
+
+ memset(&sin4, 0, sizeof(sin4));
+ sin4.sin_family = AF_INET;
+ sin4.sin_port = htons(SERVERPORT);
+
+ memset(&sin6, 0, sizeof(sin6));
+ sin6.sin6_family = AF_INET6;
+ sin6.sin6_port = htons(SERVERPORT);
+
+ v6 = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
+ if (v6 == INVALID_SOCKET) {
+ skip("Could not create IPv6 socket (LastError: %d; %d expected if IPv6 not available).\n",
+ WSAGetLastError(), WSAEAFNOSUPPORT);
+ goto end;
+ }
+ ret = bind(v6, (struct sockaddr*)&sin6, sizeof(sin6));
+ if (ret) {
+ skip("Could not bind IPv6 address (LastError: %d).\n",
+ WSAGetLastError());
+ goto end;
+ }
+
+ v4 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (v4 == INVALID_SOCKET) {
+ skip("Could not create IPv4 socket (LastError: %d).\n",
+ WSAGetLastError());
+ goto end;
+ }
+ ret = bind(v4, (struct sockaddr*)&sin4, sizeof(sin4));
+ ok(!ret, "Could not bind IPv4 address (LastError: %d; %d expected if IPv6 binds to IPv4 as well).\n",
+ WSAGetLastError(), WSAEADDRINUSE);
+
+end:
+ if (v4 != INVALID_SOCKET)
+ closesocket(v4);
+ if (v6 != INVALID_SOCKET)
+ closesocket(v6);
+}
+
/**************** Main program ***************/
START_TEST( sock )
@@ -1946,5 +1992,7 @@ START_TEST( sock )
test_send();
test_write_events();
+ test_ipv6only();
+
Exit();
}
More information about the wine-cvs
mailing list