Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/socket.c | 27 ++++++++++++++++----------- dlls/ws2_32/tests/sock.c | 21 +++++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 7493b9e9f87..6f111e263c2 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -3435,7 +3435,8 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID struct WS_sockaddr_in *saddr_in = out_buff; MIB_IPFORWARDROW row; PMIB_IPADDRTABLE ipAddrTable = NULL; - DWORD size, i, found_index; + DWORD size, i, found_index, ret = 0; + NTSTATUS status = STATUS_SUCCESS;
TRACE( "-> WS_SIO_ROUTING_INTERFACE_QUERY request\n" );
@@ -3448,21 +3449,21 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID if (daddr->sa_family != WS_AF_INET) { FIXME("unsupported address family %d\n", daddr->sa_family); - status = WSAEAFNOSUPPORT; - break; + SetLastError( WSAEAFNOSUPPORT ); + return -1; } if (GetBestRoute( daddr_in->sin_addr.S_un.S_addr, 0, &row ) != NOERROR || GetIpAddrTable( NULL, &size, FALSE ) != ERROR_INSUFFICIENT_BUFFER) { - status = WSAEFAULT; - break; + SetLastError( WSAEFAULT ); + return -1; } ipAddrTable = HeapAlloc( GetProcessHeap(), 0, size ); if (GetIpAddrTable( ipAddrTable, &size, FALSE )) { HeapFree( GetProcessHeap(), 0, ipAddrTable ); - status = WSAEFAULT; - break; + SetLastError( WSAEFAULT ); + return -1; } for (i = 0, found_index = ipAddrTable->dwNumEntries; i < ipAddrTable->dwNumEntries; i++) @@ -3475,15 +3476,19 @@ INT WINAPI WSAIoctl(SOCKET s, DWORD code, LPVOID in_buff, DWORD in_size, LPVOID ERR("no matching IP address for interface %d\n", row.dwForwardIfIndex); HeapFree( GetProcessHeap(), 0, ipAddrTable ); - status = WSAEFAULT; - break; + SetLastError( WSAEFAULT ); + return -1; } saddr_in->sin_family = WS_AF_INET; saddr_in->sin_addr.S_un.S_addr = ipAddrTable->table[found_index].dwAddr; saddr_in->sin_port = 0; - total = sizeof(struct WS_sockaddr_in); HeapFree( GetProcessHeap(), 0, ipAddrTable ); - break; + + ret = server_ioctl_sock( s, IOCTL_AFD_WINE_COMPLETE_ASYNC, &status, sizeof(status), + NULL, 0, ret_size, overlapped, completion ); + if (!ret) *ret_size = sizeof(struct WS_sockaddr_in); + SetLastError( ret ); + return ret ? -1 : 0; }
case WS_SIO_SET_COMPATIBILITY_MODE: diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 3648fa2a329..055fdf8feae 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -7770,7 +7770,7 @@ static void test_sioRoutingInterfaceQuery(void) size = 0xdeadbeef; ret = WSAIoctl(sock, SIO_ROUTING_INTERFACE_QUERY, &in, sizeof(in), &out, sizeof(out), &size, NULL, NULL); ok(!ret, "expected failure\n"); - todo_wine ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError()); + ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError()); ok(size == sizeof(out), "got size %u\n", size); /* We expect the source address to be INADDR_LOOPBACK as well, but * there's no guarantee that a route to the loopback address exists, @@ -7801,15 +7801,15 @@ static void test_sioRoutingInterfaceQuery(void) overlapped.InternalHigh = 0xdeadbeef; ret = WSAIoctl(sock, SIO_ROUTING_INTERFACE_QUERY, &in, sizeof(in), &out, sizeof(out), &size, &overlapped, NULL); ok(!ret, "expected failure\n"); - todo_wine ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError()); + ok(!WSAGetLastError(), "got error %u\n", WSAGetLastError()); ok(size == sizeof(out), "got size %u\n", size);
ret = GetQueuedCompletionStatus(port, &size, &key, &overlapped_ptr, 0); ok(ret, "got error %u\n", GetLastError()); - todo_wine ok(!size, "got size %u\n", size); + ok(!size, "got size %u\n", size); ok(overlapped_ptr == &overlapped, "got overlapped %p\n", overlapped_ptr); ok(!overlapped.Internal, "got status %#x\n", (NTSTATUS)overlapped.Internal); - todo_wine ok(!overlapped.InternalHigh, "got size %Iu\n", overlapped.InternalHigh); + ok(!overlapped.InternalHigh, "got size %Iu\n", overlapped.InternalHigh);
CloseHandle(port); closesocket(sock); @@ -7829,14 +7829,11 @@ static void test_sioRoutingInterfaceQuery(void) ok(size == sizeof(out), "got size %u\n", size);
ret = SleepEx(0, TRUE); - todo_wine ok(ret == WAIT_IO_COMPLETION, "got %d\n", ret); - if (ret == WAIT_IO_COMPLETION) - { - ok(apc_count == 1, "APC was called %u times\n", apc_count); - ok(!apc_error, "got APC error %u\n", apc_error); - ok(!apc_size, "got APC size %u\n", apc_size); - ok(apc_overlapped == &overlapped, "got APC overlapped %p\n", apc_overlapped); - } + ok(ret == WAIT_IO_COMPLETION, "got %d\n", ret); + ok(apc_count == 1, "APC was called %u times\n", apc_count); + ok(!apc_error, "got APC error %u\n", apc_error); + ok(!apc_size, "got APC size %u\n", apc_size); + ok(apc_overlapped == &overlapped, "got APC overlapped %p\n", apc_overlapped);
closesocket(sock); }