26#define _WIN32_WINNT 0x0600
30#define WIN32_NO_STATUS
44#define WSA_CMSG_ALIGN(len) (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))
50#define TEST_TIMEOUT 30
53#define NUM_UDP_PEERS 3
56#define NUM_QUERIES 250
58#define SERVERIP "127.0.0.1"
59#define SERVERPORT 9374
61#define wsa_ok(op, cond, msg) \
65 if ( !(cond tmp) ) err = WSAGetLastError(); \
66 ok ( cond tmp, msg, GetCurrentThreadId(), err); \
69#define make_keepalive(k, enable, time, interval) \
71 k.keepalivetime = time; \
72 k.keepaliveinterval = interval;
348 (
LPVOID) &optval,
sizeof (optval) ) == 0,
349 "setting SO_OPENTYPE failed\n" );
352 "getting SO_OPENTYPE failed\n" );
353 ok ( optval == newval,
"failed to set SO_OPENTYPE\n" );
362static void fill_buffer (
char *
buf,
int chunk_size,
int n_chunks )
375 for (
i = 0;
i < chunk_size;
i++ )
376 if (
p[
i] !=
c )
return i;
389 while ( ( tmp =
recv (
s,
buf, 256, 0 ) ) > 0 )
391 ok (
n <= 0,
"garbage data received: %d bytes\n",
n );
403 wsa_ok (
n, 0 <=,
"do_synchronous_send (%x): error %d\n" );
416 wsa_ok (
n, 0 <=,
"do_synchronous_recv (%x): error %d:\n" );
429 wsa_ok (
n, 0 <=,
"do_synchronous_recv (%x): error %d:\n" );
442 ok ( tmp == 0,
"check_so_opentype: wrong startup value of SO_OPENTYPE: %d\n", tmp );
447 for (;
a &&
b ;
a =
a->ai_next,
b =
b->ai_next)
449 ok(
a->ai_flags ==
b->ai_flags,
450 "Wrong flags %d != %d\n",
a->ai_flags,
b->ai_flags);
451 ok(
a->ai_family ==
b->ai_family,
452 "Wrong family %d != %d\n",
a->ai_family,
b->ai_family);
453 ok(
a->ai_socktype ==
b->ai_socktype,
454 "Wrong socktype %d != %d\n",
a->ai_socktype,
b->ai_socktype);
455 ok(
a->ai_protocol ==
b->ai_protocol,
456 "Wrong protocol %d != %d\n",
a->ai_protocol,
b->ai_protocol);
457 ok(
a->ai_addrlen ==
b->ai_addrlen,
458 "Wrong addrlen %lu != %lu\n",
a->ai_addrlen,
b->ai_addrlen);
460 "Wrong address data\n");
461 if (
a->ai_canonname &&
b->ai_canonname)
463 ok(!
strcmp(
a->ai_canonname,
b->ai_canonname),
"Wrong canonical name '%s' != '%s'\n",
464 a->ai_canonname,
b->ai_canonname);
467 ok(!
a->ai_canonname && !
b->ai_canonname,
"Expected both names absent (%p != %p)\n",
468 a->ai_canonname,
b->ai_canonname);
470 ok(!
a && !
b,
"Expected both addresses null (%p != %p)\n",
a,
b);
475 for (;
a &&
b ;
a =
a->ai_next,
b =
b->ai_next)
477 ok(
a->ai_flags ==
b->ai_flags,
478 "Wrong flags %d != %d\n",
a->ai_flags,
b->ai_flags);
479 ok(
a->ai_family ==
b->ai_family,
480 "Wrong family %d != %d\n",
a->ai_family,
b->ai_family);
481 ok(
a->ai_socktype ==
b->ai_socktype,
482 "Wrong socktype %d != %d\n",
a->ai_socktype,
b->ai_socktype);
483 ok(
a->ai_protocol ==
b->ai_protocol,
484 "Wrong protocol %d != %d\n",
a->ai_protocol,
b->ai_protocol);
485 ok(
a->ai_addrlen ==
b->ai_addrlen,
486 "Wrong addrlen %lu != %lu\n",
a->ai_addrlen,
b->ai_addrlen);
488 "Wrong address data\n");
489 if (
a->ai_canonname &&
b->ai_canonname)
491 ok(!
lstrcmpW(
a->ai_canonname,
b->ai_canonname),
"Wrong canonical name '%s' != '%s'\n",
495 ok(!
a->ai_canonname && !
b->ai_canonname,
"Expected both names absent (%p != %p)\n",
496 a->ai_canonname,
b->ai_canonname);
498 ok(!
a && !
b,
"Expected both addresses null (%p != %p)\n",
a,
b);
516 trace (
"address in use, waiting ...\n" );
519 ok (
err == 0,
"failed to bind: %d\n", wsaerr );
541 mem->sock[
i].n_recvd = 0;
542 mem->sock[
i].n_sent = 0;
615 trace (
"simple_server (%x) starting\n",
id );
624 trace (
"simple_server (%x) ready\n",
id );
629 trace (
"simple_server (%x): waiting for client\n",
id );
632 tmp =
sizeof (
mem->sock[0].peer );
637 "simple_server (%x): strange peer address\n",
id );
641 ok ( n_recvd == n_expected,
642 "simple_server (%x): received less data than expected: %d of %d\n",
id, n_recvd, n_expected );
644 ok (
pos == -1,
"simple_server (%x): test pattern error: %d\n",
id,
pos);
648 ok ( n_sent == n_expected,
649 "simple_server (%x): sent less data than expected: %d of %d\n",
id, n_sent, n_expected );
657 trace (
"simple_server (%x) exiting\n",
id );
672 trace (
"oob_server (%x) starting\n",
id );
681 trace (
"oob_server (%x) ready\n",
id );
684 trace (
"oob_server (%x): waiting for client\n",
id );
687 tmp =
sizeof (
mem->sock[0].peer );
692 "oob_server (%x): strange peer address\n",
id );
696 ok ( atmark == 1,
"oob_server (%x): unexpectedly at the OOB mark: %i\n",
id, atmark );
700 ok ( n_recvd == n_expected,
701 "oob_server (%x): received less data than expected: %d of %d\n",
id, n_recvd, n_expected );
703 ok (
pos == -1,
"oob_server (%x): test pattern error: %d\n",
id,
pos);
707 ok ( atmark == 1,
"oob_server (%x): unexpectedly at the OOB mark: %i\n",
id, atmark );
711 ok ( n_sent == n_expected,
712 "oob_server (%x): sent less data than expected: %d of %d\n",
id, n_sent, n_expected );
717 "oob_server (%x): received less data than expected: %d of %d\n",
id, n_recvd, 8 );
721 trace(
"oob_server (%x): %s the OOB mark: %i\n",
id, atmark == 1 ?
"not at" :
"at", atmark );
727 todo_wine ok ( atmark == 0,
"oob_server (%x): not at the OOB mark: %i\n",
id, atmark );
733 trace (
"oob_server (%x) exiting\n",
id );
746 n_set, delta, n_ready;
748 fd_set fds_recv, fds_send, fds_openrecv, fds_opensend;
750 trace (
"select_server (%x) starting\n",
id );
759 trace (
"select_server (%x) ready\n",
id );
771 fds_recv = fds_openrecv;
772 fds_send = fds_opensend;
777 "select_server (%x): select() failed: %d\n" );
783 trace (
"select_server (%x): accepting client connection\n",
id );
786 tmp =
sizeof (
mem->sock[n_connections].peer );
791 "select_server (%x): strange peer address\n",
id );
794 FD_SET (
mem->sock[n_connections].s, &fds_openrecv );
795 FD_SET (
mem->sock[n_connections].s, &fds_opensend );
802 for (
i = 0;
i < n_connections;
i++ )
807 if (
mem->sock[
i].n_recvd < n_expected ) {
811 mem->sock[
i].n_recvd += n_recvd;
813 if (
mem->sock[
i].n_recvd == n_expected ) {
815 ok (
pos == -1,
"select_server (%x): test pattern error: %d\n",
id,
pos );
819 ok (
mem->sock[
i].n_recvd <= n_expected,
"select_server (%x): received too many bytes: %d\n",
id,
mem->sock[
i].n_recvd );
824 delta =
mem->sock[
i].n_recvd -
mem->sock[
i].n_sent;
829 if ( ( delta > 0 ) && (
mem->sock[
i].n_sent < n_expected ) ) {
833 mem->sock[
i].n_sent += n_sent;
835 if (
mem->sock[
i].n_sent == n_expected ) {
839 ok (
mem->sock[
i].n_sent <= n_expected,
"select_server (%x): sent too many bytes: %d\n",
id,
mem->sock[
i].n_sent );
845 ok ( ( n_set == n_ready ),
"select_server (%x): select() returns wrong number of ready sockets\n",
id );
863 trace (
"select_server (%x) exiting\n",
id );
879 trace (
"simple_client (%x): starting\n",
id );
882 trace (
"simple_client (%x): server ready\n",
id );
891 0 ==,
"simple_client (%x): connect error: %d\n" );
893 "simple_client (%x): failed to set blocking mode\n",
id );
894 trace (
"simple_client (%x) connected\n",
id );
898 ok ( n_sent == n_expected,
899 "simple_client (%x): sent less data than expected: %d of %d\n",
id, n_sent, n_expected );
906 ok ( n_recvd == n_expected,
907 "simple_client (%x): received less data than expected: %d of %d\n",
id, n_recvd, n_expected );
911 ok (
pos == -1,
"simple_client (%x): test pattern error: %d\n",
id,
pos);
915 trace (
"simple_client (%x) exiting\n",
id );
929 trace (
"oob_client (%x): starting\n",
id );
932 trace (
"oob_client (%x): server ready\n",
id );
941 0 ==,
"oob_client (%x): connect error: %d\n" );
943 "oob_client (%x): failed to set blocking mode\n",
id );
944 trace (
"oob_client (%x) connected\n",
id );
948 ok ( n_sent == n_expected,
949 "oob_client (%x): sent less data than expected: %d of %d\n",
id, n_sent, n_expected );
953 ok ( n_recvd == n_expected,
954 "simple_client (%x): received less data than expected: %d of %d\n",
id, n_recvd, n_expected );
956 ok (
pos == -1,
"simple_client (%x): test pattern error: %d\n",
id,
pos);
960 ok ( n_sent == n_expected,
961 "oob_client (%x): sent less data than expected: %d of %d\n",
id, n_sent, n_expected );
968 trace (
"oob_client (%x) exiting\n",
id );
980 int fromLen =
sizeof(
mem->addr);
984 trace (
"simple_client (%x): starting\n",
id );
987 trace (
"simple_client (%x): server ready\n",
id );
996 0 ==,
"simple_client (%x): connect error: %d\n" );
998 "simple_client (%x): failed to set blocking mode\n",
id );
999 trace (
"simple_client (%x) connected\n",
id );
1003 ok ( n_sent == n_expected,
1004 "simple_client (%x): sent less data than expected: %d of %d\n",
id, n_sent, n_expected );
1022 ok ( n_recvd == n_expected,
1023 "simple_client (%x): received less data than expected: %d of %d\n",
id, n_recvd, n_expected );
1029 "0.0.0.0"),
"lpFrom shouldn't be updated on connection oriented sockets\n");
1033 ok (
pos == -1,
"simple_client (%x): test pattern error: %d\n",
id,
pos);
1037 trace (
"simple_client (%x) exiting\n",
id );
1052 char *send_last, *recv_last, *send_p, *recv_p;
1055 trace (
"event_client (%x): starting\n",
id );
1057 trace (
"event_client (%x): server ready\n",
id );
1069 ok ( tmp ==
WAIT_OBJECT_0,
"event_client (%x): wait for connect event failed: %d\n",
id, tmp );
1071 ok (
err == 0,
"event_client (%x): WSAEnumNetworkEvents error: %d\n",
id,
err );
1073 ok (
err == 0,
"event_client (%x): connect error: %d\n",
id,
err );
1077 trace (
"event_client (%x) connected\n",
id );
1081 recv_p =
mem->recv_buf;
1082 recv_last =
mem->recv_buf + n_expected;
1083 send_p =
mem->send_buf;
1084 send_last =
mem->send_buf + n_expected;
1092 ok(
err == 0,
"event_client (%x): WSAEnumNetworkEvents error: %d\n",
id,
err );
1097 ok (
err == 0,
"event_client (%x): FD_WRITE error code: %d\n",
id,
err );
1111 while (
n >= 0 && send_p < send_last );
1113 if ( send_p == send_last )
1115 trace (
"event_client (%x): all data sent - shutdown\n",
id );
1124 ok (
err == 0,
"event_client (%x): FD_READ error code: %d\n",
id,
err );
1125 if (
err != 0 )
break;
1129 wsa_ok (
n, 0 <=,
"event_client (%x): recv error: %d\n" );
1133 if ( recv_p == recv_last )
1136 trace (
"event_client (%x): all data received\n",
id );
1142 ok ( 0,
"event_client (%x): read error: %d\n",
id,
err );
1148 trace (
"event_client (%x): close event\n",
id );
1150 ok (
err == 0,
"event_client (%x): FD_CLOSE error code: %d\n",
id,
err );
1155 n = send_p -
mem->send_buf;
1156 ok ( send_p == send_last,
1157 "simple_client (%x): sent less data than expected: %d of %d\n",
id,
n, n_expected );
1158 n = recv_p -
mem->recv_buf;
1159 ok ( recv_p == recv_last,
1160 "simple_client (%x): received less data than expected: %d of %d\n",
id,
n, n_expected );
1162 ok (
n == -1,
"event_client (%x): test pattern error: %d\n",
id,
n);
1166 trace (
"event_client (%x) exiting\n",
id );
1200 ok(
res == 0,
"WSAStartup() failed unexpectedly: %d\n",
res);
1206 for (socks = 0; socks <
sizeof(pairs) /
sizeof(pairs[0]); socks++)
1213 "WSADuplicateSocketA should have worked\n");
1219 "WSADuplicateSocketA should have worked\n");
1230 ok(
res == 0,
"WSAStartup() failed unexpectedly: %d\n",
res);
1246 for (
i = 0;
i < socks;
i++)
1248 for (
j = 0;
j < 4;
j++)
1251 int size =
sizeof(saddr);
1254 case 0:
sock = pairs[
i].src;
break;
1255 case 1:
sock = pairs[
i].dup_src;
break;
1256 case 2:
sock = pairs[
i].dst;
break;
1257 case 3:
sock = pairs[
i].dup_dst;
break;
1269 for (
i = 0;
i < socks;
i++)
1278 ok(
res == 0,
"expected 0, got %d\n",
res);
1283 "WSACleanup returned %d WSAGetLastError is %d\n",
res,
error);
1288static void Init (
void)
1296 pFreeAddrInfoW = (
void *)
GetProcAddress(hws2_32,
"FreeAddrInfoW");
1297 pFreeAddrInfoExW = (
void *)
GetProcAddress(hws2_32,
"FreeAddrInfoExW");
1299 pGetAddrInfoExW = (
void *)
GetProcAddress(hws2_32,
"GetAddrInfoExW");
1300 pGetAddrInfoExOverlappedResult = (
void *)
GetProcAddress(hws2_32,
"GetAddrInfoExOverlappedResult");
1305 pWSALookupServiceBeginW = (
void *)
GetProcAddress(hws2_32,
"WSALookupServiceBeginW");
1306 pWSALookupServiceEnd = (
void *)
GetProcAddress(hws2_32,
"WSALookupServiceEnd");
1307 pWSALookupServiceNextW = (
void *)
GetProcAddress(hws2_32,
"WSALookupServiceNextW");
1308 pWSAEnumNameSpaceProvidersA = (
void *)
GetProcAddress(hws2_32,
"WSAEnumNameSpaceProvidersA");
1309 pWSAEnumNameSpaceProvidersW = (
void *)
GetProcAddress(hws2_32,
"WSAEnumNameSpaceProvidersW");
1315 pGetIpForwardTable = (
void *)
GetProcAddress(hiphlpapi,
"GetIpForwardTable");
1316 pGetAdaptersInfo = (
void *)
GetProcAddress(hiphlpapi,
"GetAdaptersInfo");
1323 pNtSetInformationFile = (
void *)
GetProcAddress(ntdll,
"NtSetInformationFile");
1324 pNtQueryInformationFile = (
void *)
GetProcAddress(ntdll,
"NtQueryInformationFile");
1331static void Exit (
void)
1337 ok (
ret == 0,
"WSACleanup failed ret = %d GetLastError is %d\n",
ret,
err);
1345 ok (
thread[0] !=
NULL,
"Failed to create server thread\n" );
1357 ok (
thread[
i] !=
NULL,
"Failed to create client thread\n" );
1369 for (
i = 0;
i <=
n;
i++)
1378 "some threads have not completed: %x\n", wait );
1382 for (
i = 0;
i <=
n;
i++)
1392 for (
i = 0;
i <=
n;
i++)
1406#define SOCKTIMEOUT1 63000
1408#define SOCKTIMEOUT2 997000
1413 int i,
err, lasterr;
1454 ok(
timeout == 0,
"getsockopt(SO_RCVTIMEO) returned wrong value %d\n",
timeout);
1487 size =
sizeof(lingval);
1496 ,
"getsockopt(SO_LINGER #%d) returned wrong value %d,%d not %d,%d\n",
i,
1497 lingval.l_onoff, lingval.l_linger,
1501 size =
sizeof(lingval);
1521 "instead of failing.\n");
1523 ok(lasterr ==
WSAEFAULT,
"setsockopt with optval being a value "
1524 "returned 0x%08x, not WSAEFAULT(0x%08x)\n",
1533 "got %d with %d (expected SOCKET_ERROR with WSAEINVAL)\n",
1540 "got %d with %d (expected SOCKET_ERROR with WSAEINVAL)\n",
1549 "got %d with %d (expected 0 with 0)\n",
1557 "got %d with %d (expected 0 with 0)\n",
1560 ok (
i == 1234,
"got %d (expected 1234)\n",
i);
1568 "got %d with %d (expected SOCKET_ERROR with WSAEFAULT)\n",
1579 "got %d with %d (expected SOCKET_ERROR with WSAENOTSOCK)\n",
1581 ok (
i == 1234,
"expected 1234, got %d\n",
i);
1591 for (
i = 0;
i < 4;
i++)
1594 const int tests[] = {0xffffff0a, 0xffff000b, 0xff00000c, 0x0000000d};
1596 ok(!
err,
"Test [%d] Expected 0, got %d\n",
i,
err);
1598 ok(!
err,
"Test [%d] Expected 0, got %d\n",
i,
err);
1600 ok(
k ==
j,
"Test [%d] Expected 0x%x, got 0x%x\n",
i,
j,
k);
1604 win_skip(
"IP_MULTICAST_TTL is unsupported\n");
1609 "getsockopt should have failed\n");
1614 "getsockopt should have failed\n");
1620 "getsockopt should have failed\n");
1624 "getsockopt should have failed\n");
1628 "getsockopt should have failed\n");
1633 "getsockopt should have failed\n");
1645 for (
i = 0;
i <
sizeof(prottest) /
sizeof(prottest[0]);
i++)
1656 infoA.szProtocol[0] = 0;
1662 infoW.szProtocol[0] = 0;
1668 trace(
"provider name '%s', family %d, type %d, proto %d\n",
1669 infoA.szProtocol, prottest[
i].family, prottest[
i].type, prottest[
i].proto);
1671 ok(
infoA.szProtocol[0],
"WSAPROTOCOL_INFOA was not filled\n");
1672 ok(
infoW.szProtocol[0],
"WSAPROTOCOL_INFOW was not filled\n");
1675 providername,
sizeof(providername),
NULL,
NULL);
1677 "different provider names '%s' != '%s'\n",
infoA.szProtocol, providername);
1680 "SO_PROTOCOL_INFO[A/W] comparison failed\n");
1684 ok(
infoA.iAddressFamily == prottest[
i].family,
"socket family invalid, expected %d received %d\n",
1685 prottest[
i].family,
infoA.iAddressFamily);
1686 ok(
infoA.iSocketType == prottest[
i].type,
"socket type invalid, expected %d received %d\n",
1687 prottest[
i].type,
infoA.iSocketType);
1688 ok(
infoA.iProtocol == prottest[
i].proto,
"socket protocol invalid, expected %d received %d\n",
1689 prottest[
i].proto,
infoA.iProtocol);
1703 ok(
err == -1,
"Expected -1, got %d\n",
err);
1705 ok(
k == 99,
"Expected 99, got %d\n",
k);
1712 ok(
err == -1,
"Expected -1, got %d\n",
err);
1718 ok(
err == -1,
"Expected -1, got %d\n",
err);
1720 ok(
k == 99,
"Expected 99, got %d\n",
k);
1730 ok(
err == 0,
"Expected 0, got %d\n",
err);
1731 ok(
k == 1,
"Expected 1, got %d\n",
k);
1736 ok(
err == -1,
"Expected -1, got %d\n",
err);
1738 ok(
k == 0,
"Expected 0, got %d\n",
k);
1743 ok(
err == 0,
"Expected 0, got %d\n",
err);
1749 ok(
err == 0,
"Expected 0, got %d\n",
err);
1750 ok(
k == 0,
"Expected 0, got %d\n",
k);
1755 ok(
err == -1,
"Expected -1, got %d\n",
err);
1757 ok(
k == 0,
"Expected 0, got %d\n",
k);
1771 size =
sizeof(csinfoA);
1776 memset(&saddr, 0,
sizeof(saddr));
1781 ok(!csinfoA.cs.LocalAddr.iSockaddrLength,
"Expected 0, got %d\n", csinfoA.cs.LocalAddr.iSockaddrLength);
1782 ok(csinfoA.cs.LocalAddr.lpSockaddr ==
NULL,
"Expected NULL, got %p\n", csinfoA.cs.LocalAddr.lpSockaddr);
1784 ok(!csinfoA.cs.RemoteAddr.iSockaddrLength,
"Expected 0, got %d\n", csinfoA.cs.RemoteAddr.iSockaddrLength);
1785 ok(csinfoA.cs.RemoteAddr.lpSockaddr ==
NULL,
"Expected NULL, got %p\n", csinfoA.cs.RemoteAddr.lpSockaddr);
1788 ok(!
err,
"Expected 0, got %d\n",
err);
1789 size =
sizeof(csinfoA);
1791 ok(!
err,
"Expected 0, got %d\n",
err);
1794 ok(csinfoA.cs.LocalAddr.iSockaddrLength,
"Expected non-zero\n");
1795 ok(csinfoA.cs.LocalAddr.lpSockaddr !=
NULL,
"Expected non-null\n");
1797 ok(!csinfoA.cs.RemoteAddr.iSockaddrLength,
"Expected 0, got %d\n", csinfoA.cs.RemoteAddr.iSockaddrLength);
1798 ok(csinfoA.cs.RemoteAddr.lpSockaddr ==
NULL,
"Expected NULL, got %p\n", csinfoA.cs.RemoteAddr.lpSockaddr);
1801 ok(!
err,
"Expected 0, got %d\n",
err);
1803 ok(!
err,
"Expected 0, got %d\n",
err);
1805 ok(!
err,
"Expected 0, got %d\n",
err);
1807 ok(!
err,
"Expected 0, got %d\n",
err);
1808 size =
sizeof(saddr);
1814 size =
sizeof(csinfoA);
1816 ok(!
err,
"Expected 0, got %d\n",
err);
1818 ok(!
err,
"Expected 0, got %d\n",
err);
1819 ok(
size ==
sizeof(csinfoA),
"Got %d\n",
size);
1820 size =
sizeof(saddr);
1821 ok(
size == csinfoA.cs.LocalAddr.iSockaddrLength,
"Expected %d, got %d\n",
size,
1822 csinfoA.cs.LocalAddr.iSockaddrLength);
1823 ok(
size == csinfoA.cs.RemoteAddr.iSockaddrLength,
"Expected %d, got %d\n",
size,
1824 csinfoA.cs.RemoteAddr.iSockaddrLength);
1825 ok(!
memcmp(csinfoA.cs.LocalAddr.lpSockaddr, csinfoB.cs.RemoteAddr.lpSockaddr,
size),
1826 "Expected matching addresses\n");
1827 ok(!
memcmp(csinfoB.cs.LocalAddr.lpSockaddr, csinfoA.cs.RemoteAddr.lpSockaddr,
size),
1828 "Expected matching addresses\n");
1829 ok(csinfoA.cs.iSocketType ==
SOCK_STREAM,
"Wrong socket type\n");
1830 ok(csinfoB.cs.iSocketType ==
SOCK_STREAM,
"Wrong socket type\n");
1831 ok(csinfoA.cs.iProtocol ==
IPPROTO_TCP,
"Wrong socket protocol\n");
1832 ok(csinfoB.cs.iProtocol ==
IPPROTO_TCP,
"Wrong socket protocol\n");
1835 ok(!
err,
"Expected 0, got %d\n",
err);
1836 ok(!
memcmp(&saddr, csinfoA.cs.RemoteAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1837 ok(!
memcmp(&saddr, csinfoB.cs.LocalAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1839 ok(!
err,
"Expected 0, got %d\n",
err);
1840 ok(!
memcmp(&saddr, csinfoB.cs.RemoteAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1841 ok(!
memcmp(&saddr, csinfoA.cs.LocalAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1843 ok(!
err,
"Expected 0, got %d\n",
err);
1844 ok(!
memcmp(&saddr, csinfoA.cs.LocalAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1845 ok(!
memcmp(&saddr, csinfoB.cs.RemoteAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1847 ok(!
err,
"Expected 0, got %d\n",
err);
1848 ok(!
memcmp(&saddr, csinfoB.cs.LocalAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1849 ok(!
memcmp(&saddr, csinfoA.cs.RemoteAddr.lpSockaddr,
size),
"Expected matching addresses\n");
1854 ok(
err,
"Expected non-zero\n");
1859 size =
sizeof(*csinfoA.cs.LocalAddr.lpSockaddr) * 2 +
sizeof(csinfoA.cs);
1861 ok(!
err,
"Expected 0, got %d\n",
err);
1865 ok(
err,
"Expected non-zero\n");
1874 for (
i = 0;
i < 2;
i++)
1881 level = IPPROTO_IPV6;
1892 skip(
"IPv6 is not supported\n");
1930 unsigned int rc,reuse;
1949 ok(rc==0 && reuse==0,
"wrong result in getsockopt(SO_REUSEADDR): rc=%d reuse=%d\n",rc,reuse);
1965 trace(
"<= Win XP behavior of SO_REUSEADDR\n");
1979 size =
sizeof(saddr);
1983 ok(s4 !=
INVALID_SOCKET,
"none of the listening sockets could get the connection\n");
1991 trace(
">= Win 2003 behavior of SO_REUSEADDR\n");
2003#define IP_PKTINFO_LEN (sizeof(WSACMSGHDR) + WSA_CMSG_ALIGN(sizeof(struct in_pktinfo)))
2008 char recvbuf[10], pktbuf[512],
msg[] =
"HELLO";
2010 GUID WSARecvMsg_GUID = WSAID_WSARECVMSG;
2011 LPFN_WSARECVMSG pWSARecvMsg =
NULL;
2012 unsigned int rc,
yes = 1;
2023 memset(&ov, 0,
sizeof(ov));
2027 skip(
"Could not create event object, some tests will be skipped. errno = %d\n",
GetLastError());
2035 iovec[0].buf = recvbuf;
2036 iovec[0].len =
sizeof(recvbuf);
2038 hdr.namelen =
sizeof(s3addr);
2040 hdr.dwBufferCount = 1;
2041 hdr.Control.buf = pktbuf;
2045 for (
i=0;
i<
sizeof(addresses)/
sizeof(
UINT32);
i++)
2059 &pWSARecvMsg,
sizeof(pWSARecvMsg), &dwBytes,
NULL,
NULL);
2062 win_skip(
"WSARecvMsg is unsupported, some tests will be skipped.\n");
2071 ok(rc == 0,
"failed to set IPPROTO_IP flag IP_PKTINFO!\n");
2074 addrlen =
sizeof(s2addr);
2081 s2addr.sin_addr.s_addr = addresses[0];
2103 hdr.Control.len = 1;
2107 "WSARecvMsg() failed error: %d (ret: %d, flags: %d)\n",
err, rc,
hdr.dwFlags);
2111 hdr.Control.len = 1;
2121 skip(
"Server side did not receive packet, some tests skipped.\n");
2129 "WSAGetOverlappedResult() returned unexpected flags %d!\n",
dwFlags);
2131 "WSARecvMsg() overlapped operation set unexpected flags %d.\n",
hdr.dwFlags);
2138 hdr.Control.len =
sizeof(pktbuf);
2142 ok(
hdr.Control.len ==
sizeof(pktbuf),
2143 "WSARecvMsg() control length mismatch (%d != sizeof pktbuf).\n",
hdr.Control.len);
2148 skip(
"Server side did not receive packet, some tests skipped.\n");
2156 "WSARecvMsg() buffer length does not match transmitted data!\n");
2158 "WSARecvMsg() buffer does not match transmitted data!\n");
2160 "WSARecvMsg() control length mismatch (%d).\n",
hdr.Control.len);
2170 ok(
pi->ipi_addr.s_addr == s2addr.sin_addr.s_addr,
"destination ip mismatch!\n");
2174 ok(foundhdr,
"IP_PKTINFO header information was not returned!\n");
2186#define STD_STREAM_SOCKET \
2329 ok (
peer[
i].
addr.sin_port !=
htons ( 0 ),
"UDP: bind() did not associate port\n" );
2339 ok (
n_sent ==
sizeof(
buf),
"UDP: sendto() sent wrong amount of data or socket error: %d\n",
n_sent );
2344 ok ( n_recv ==
sizeof(
buf),
"UDP: recvfrom() received wrong amount of data or socket error: %d\n", n_recv );
2345 ok (
memcmp ( &
peer[0].
peer.sin_port,
buf,
sizeof(
peer[0].addr.sin_port) ) == 0,
"UDP: port numbers do not match\n" );
2355 } serv[2] = { {
"domain",
"udp", 53}, {
"telnet",
"tcp", 23} };
2362 "test_getservbyname: timeout waiting for start signal\n" );
2365 for (
j = 0;
j < 2;
j++) {
2370 for (
j = 0;
j < 2;
j++ ) {
2373 "getservbyname could not retrieve information for %s: %d\n", serv[
j].
name,
WSAGetLastError() );
2374 if ( !pserv[
j] )
continue;
2376 "getservbyname returned the wrong port for %s: %d\n", serv[
j].
name,
ntohs(pserv[
j]->
s_port) );
2378 "getservbyname returned the wrong protocol for %s: %s\n", serv[
j].
name, pserv[
j]->
s_proto );
2380 "getservbyname returned the wrong name for %s: %s\n", serv[
j].
name, pserv[
j]->
s_name );
2383 ok ( pserv[0] == pserv[1] ||
broken(pserv[0] != pserv[1]) ,
2384 "getservbyname: winsock resized servent buffer when not necessary\n" );
2422 "WSASocketA should have failed\n");
2436 "WSASocketA should have failed\n");
2442 "WSASocketA should have failed\n");
2448 "WSASocketA should have failed\n");
2454 "WSASocketA should have failed\n");
2460 "WSASocketA should have failed\n");
2466 "WSASocketA should have failed\n");
2472 "WSASocketA should have failed\n");
2482 "WSASocketA should have failed\n");
2488 "WSASocketA should have failed\n");
2494 "WSASocketA should have failed\n");
2500 "WSASocketA should have failed\n");
2511 "WSASocketA should have failed\n");
2518 "WSASocketA should have failed\n");
2530 ok(
err ==
WSAENOBUFS,
"WSAEnumProtocolsA error is %d, not WSAENOBUFS(%d)\n",
2534 ok(
pi !=
NULL,
"Failed to allocate memory\n");
2536 skip(
"Can't continue without memory.\n");
2545 skip(
"No protocols enumerated.\n");
2557 pi[0].iProtocol = -1;
2558 pi[0].iSocketType = -1;
2559 pi[0].iAddressFamily = -1;
2561 "WSASocketA should have failed\n");
2565 pi[0].iProtocol = 0;
2566 pi[0].iSocketType = 0;
2567 pi[0].iAddressFamily = 0;
2571 win_skip(
"must work only in OS <= 2003\n");
2586 size =
sizeof(socktype);
2590 ok(socktype ==
SOCK_DGRAM,
"Wrong socket type, expected %d received %d\n",
2597 size =
sizeof(socktype);
2601 ok(socktype ==
SOCK_STREAM,
"Wrong socket type, expected %d received %d\n",
2612 ok(
err ==
WSAENOBUFS,
"WSAEnumProtocolsA error is %d, not WSAENOBUFS(%d)\n",
2616 ok(
pi !=
NULL,
"Failed to allocate memory\n");
2618 skip(
"Can't continue without memory.\n");
2633 size =
sizeof(socktype);
2641 ok(socktype ==
pi[
i].iSocketType,
"Wrong socket type, expected %d received %d\n",
2642 pi[
i].iSocketType, socktype);
2646 ok(
i !=
items,
"Creating a socket without protocol and socket type didn't work\n");
2651 for (
i = 0;
i <
sizeof(autoprotocols) /
sizeof(autoprotocols[0]);
i++)
2657 size =
sizeof(socktype);
2664 if (
pi[
j].iProtocol == autoprotocols[
i])
2666 if (socktype ==
pi[
j].iSocketType)
2669 ok(0,
"Wrong socket type, expected %d received %d\n",
2670 pi[
j].iSocketType, socktype);
2674 ok(!
err,
"Protocol %d not found in WSAEnumProtocols\n", autoprotocols[
i]);
2689 skip(
"SOCK_RAW is not supported\n");
2693 trace(
"SOCK_RAW is supported\n");
2695 size =
sizeof(socktype);
2699 ok(socktype ==
SOCK_RAW,
"Wrong socket type, expected %d received %d\n",
2707 size =
sizeof(socktype);
2711 ok(socktype ==
SOCK_RAW,
"Wrong socket type, expected %d received %d\n",
2719 size =
sizeof(socktype);
2723 ok(socktype ==
SOCK_RAW,
"Wrong socket type, expected %d received %d\n",
2737 skip(
"IPX is not supported\n");
2744 trace(
"IPX is supported\n");
2750 size =
sizeof(socktype);
2754 ok(socktype ==
SOCK_DGRAM,
"Wrong socket type, expected %d received %d\n",
2763 ok(
info.iAddressFamily ==
AF_IPX,
"expected family %d, received %d\n",
2772 "WSASocketA should have failed\n");
2778 for(
i = 0;
i <= 255;
i += 17)
2789 ok(socktype ==
i,
"Wrong IPX packet type, expected %d received %d\n",
2803 int socktype,
size, addrsize,
ret;
2804 char teststr[] =
"TEST",
buffer[16];
2817 "WSADuplicateSocketA should have failed\n");
2823 "WSADuplicateSocketA should have failed\n");
2829 "WSADuplicateSocketA should have failed\n");
2835 "WSADuplicateSocketA should have failed\n");
2842 "WSADuplicateSocketA should have worked\n");
2846 ok(
info.iAddressFamily ==
AF_INET,
"expected family %d, received %d\n",
2864 "WSADuplicateSocketA should have worked\n");
2868 ok(
info.iAddressFamily ==
AF_INET,
"expected family %d, received %d\n",
2877 "bind should have worked\n");
2881 addrsize =
sizeof(
addr);
2883 "getsockname should have worked\n");
2884 ok(
addr.sin_port,
"socket port should be != 0\n");
2892 ok(socktype ==
SOCK_DGRAM,
"Wrong socket type, expected %d received %d\n",
2898 addrsize =
sizeof(
addr);
2903 addrsize =
sizeof(
addr);
2907 buffer[
sizeof(teststr) - 1] = 0;
2920 "WSADuplicateSocketA should have worked\n");
2929 "bind should have worked\n");
2933 addrsize =
sizeof(
addr);
2935 "getsockname should have worked\n");
2936 ok(
addr.sin_port,
"socket port should be != 0\n");
2940 addrsize =
sizeof(
addr);
2945 addrsize =
sizeof(
addr);
2949 "recvfrom should have failed\n");
2971 for (
l = 0;
l < 2;
l++)
2973 for (
i = 0;
i <
sizeof(sock_type) /
sizeof(sock_type[0]);
i++)
2984 ok (
event !=
NULL,
"Test[%d]: failed to create event\n",
i);
2985 for (
j = 0;
j < 5;
j++)
2994 memset(&net_events, 0xAB,
sizeof(net_events));
2996 "Test[%d]: WSAEnumNetworkEvents failed\n",
i);
2997 if (
i >= 1 &&
j == 0)
3001 i, net_events.lNetworkEvents);
3007 i, net_events.lNetworkEvents);
3013 ok (net_events.
iErrorCode[
k] == 0x0,
"Test[%d][%d]: expected 0x0, got 0x%x\n",
3019 ok (net_events.
iErrorCode[
k] == 0xABABABAB,
"Test[%d][%d]: expected 0xABABABAB, got 0x%x\n",
3040 CHAR expect1[] =
"0.0.0.0";
3042 CHAR expect3[] =
"0.0.0.0:65535";
3043 CHAR expect4[] =
"255.255.255.255:65535";
3048 CHAR addr6_1[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
3049 CHAR addr6_2[] = {0x20,0xab,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
3050 CHAR addr6_3[] = {0x20,0xab,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x01};
3052 CHAR expect6_1[] =
"::1";
3053 CHAR expect6_2[] =
"20ab::1";
3054 CHAR expect6_3[] =
"[20ab::2001]:33274";
3055 CHAR expect6_3_2[] =
"[20ab::2001%4660]:33274";
3056 CHAR expect6_3_3[] =
"20ab::2001%4660";
3067 "WSAAddressToStringA() failed unexpectedly: WSAGetLastError()=%d, ret=%d\n",
3080 ok(
len ==
sizeof( expect1 ),
"Got size %d\n",
len);
3086 sockaddr.sin_addr.s_addr = 0xffffffff;
3108 sockaddr.sin_addr.s_addr = 0xffffffff;
3114 ok(
len ==
sizeof( expect4 ),
"Got size %d\n",
len);
3119 skip(
"Could not create IPv6 socket (LastError: %d; %d expected if IPv6 not available).\n",
3124 len =
sizeof(address6);
3133 ok( !
strcmp( address6, expect6_1 ),
"Expected: %s, got: %s\n", expect6_1, address6 );
3134 ok(
len ==
sizeof(expect6_1),
"Got size %d\n",
len);
3137 len =
sizeof(address6);
3140 sockaddr6.sin6_port = 0x0000;
3141 sockaddr6.sin6_scope_id = 0;
3142 memcpy (sockaddr6.sin6_addr.s6_addr, addr6_2,
sizeof(addr6_2));
3146 ok( !
strcmp( address6, expect6_2 ),
"Expected: %s, got: %s\n", expect6_2, address6 );
3147 ok(
len ==
sizeof(expect6_2),
"Got size %d\n",
len);
3150 len =
sizeof(address6);
3153 sockaddr6.sin6_port = 0xfa81;
3154 sockaddr6.sin6_scope_id = 0;
3155 memcpy (sockaddr6.sin6_addr.s6_addr, addr6_3,
sizeof(addr6_3));
3159 ok( !
strcmp( address6, expect6_3 ),
"Expected: %s, got: %s\n", expect6_3, address6 );
3160 ok(
len ==
sizeof(expect6_3),
"Got size %d\n",
len );
3163 len =
sizeof(address6);
3166 sockaddr6.sin6_port = 0xfa81;
3167 sockaddr6.sin6_scope_id = 0x1234;
3168 memcpy (sockaddr6.sin6_addr.s6_addr, addr6_3,
sizeof(addr6_3));
3172 ok( !
strcmp( address6, expect6_3_2 ),
"Expected: %s, got: %s\n", expect6_3_2, address6 );
3173 ok(
len ==
sizeof(expect6_3_2),
"Got size %d\n",
len );
3176 len =
sizeof(address6);
3179 sockaddr6.sin6_port = 0x0000;
3180 sockaddr6.sin6_scope_id = 0x1234;
3181 memcpy (sockaddr6.sin6_addr.s6_addr, addr6_3,
sizeof(addr6_3));
3185 ok( !
strcmp( address6, expect6_3_3 ),
"Expected: %s, got: %s\n", expect6_3_3, address6 );
3186 ok(
len ==
sizeof(expect6_3_3),
"Got size %d\n",
len );
3202 WCHAR expect1[] = {
'0',
'.',
'0',
'.',
'0',
'.',
'0', 0 };
3203 WCHAR expect2[] = {
'2',
'5',
'5',
'.',
'2',
'5',
'5',
'.',
'2',
'5',
'5',
'.',
'2',
'5',
'5', 0 };
3204 WCHAR expect3[] = {
'0',
'.',
'0',
'.',
'0',
'.',
'0',
':',
'6',
'5',
'5',
'3',
'5', 0 };
3205 WCHAR expect4[] = {
'2',
'5',
'5',
'.',
'2',
'5',
'5',
'.',
'2',
'5',
'5',
'.',
'2',
'5',
'5',
':',
3206 '6',
'5',
'5',
'3',
'5', 0 };
3211 CHAR addr6_1[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
3212 CHAR addr6_2[] = {0x20,0xab,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
3213 CHAR addr6_3[] = {0x20,0xab,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x01};
3215 WCHAR expect6_1[] = {
':',
':',
'1',0};
3216 WCHAR expect6_2[] = {
'2',
'0',
'a',
'b',
':',
':',
'1',0};
3217 WCHAR expect6_3[] = {
'[',
'2',
'0',
'a',
'b',
':',
':',
'2',
'0',
'0',
'1',
']',
':',
'3',
'3',
'2',
'7',
'4',0};
3218 WCHAR expect6_3_2[] = {
'[',
'2',
'0',
'a',
'b',
':',
':',
'2',
'0',
'0',
'1',
'%',
'4',
'6',
'6',
'0',
']',
':',
'3',
'3',
'2',
'7',
'4',0};
3219 WCHAR expect6_3_3[] = {
'2',
'0',
'a',
'b',
':',
':',
'2',
'0',
'0',
'1',
'%',
'6',
'5',
'5',
'3',
'4',0};
3230 "WSAAddressToStringW() failed unexpectedly: WSAGetLastError()=%d, ret=%d\n",
3243 ok(
len ==
sizeof( expect1 )/
sizeof(
WCHAR ),
"Got size %d\n",
len);
3249 sockaddr.sin_addr.s_addr = 0xffffffff;
3271 sockaddr.sin_addr.s_addr = 0xffffffff;