From: Paul Gofman pgofman@codeweavers.com
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/ws2_32/socket.c | 30 ++++++++++++++++++++++++------ dlls/ws2_32/tests/protocol.c | 2 ++ dlls/ws2_32/tests/sock.c | 23 +++++++++++++++++++++-- 3 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 9cc75aacf20..d3c93e15a47 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -70,6 +70,23 @@ static const WSAPROTOCOL_INFOW supported_protocols[] = .dwMessageSize = 0xffbb, .szProtocol = L"UDP/IP", }, + { + .dwServiceFlags1 = XP1_IFS_HANDLES | XP1_SUPPORT_BROADCAST + | XP1_SUPPORT_MULTIPOINT | XP1_MESSAGE_ORIENTED | XP1_CONNECTIONLESS, + .dwProviderFlags = PFL_MATCHES_PROTOCOL_ZERO | PFL_HIDDEN, + .ProviderId = {0xe70f1aa0, 0xab8b, 0x11cf, {0x8c, 0xa3, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}, + .dwCatalogEntryId = 1003, + .ProtocolChain.ChainLen = 1, + .iVersion = 2, + .iAddressFamily = AF_INET, + .iMaxSockAddr = sizeof(struct sockaddr_in), + .iMinSockAddr = sizeof(struct sockaddr_in), + .iSocketType = SOCK_RAW, + .iProtocol = 0, + .iProtocolMaxOffset = 255, + .dwMessageSize = 0x8000, + .szProtocol = L"MSAFD Tcpip [RAW/IP]", + }, { .dwServiceFlags1 = XP1_IFS_HANDLES | XP1_EXPEDITED_DATA | XP1_GRACEFUL_CLOSE | XP1_GUARANTEED_ORDER | XP1_GUARANTEED_DELIVERY, @@ -4097,12 +4114,13 @@ int WINAPI WSARecvDisconnect( SOCKET s, WSABUF *data ) }
-static BOOL protocol_matches_filter( const int *filter, int protocol ) +static BOOL protocol_matches_filter( const int *filter, unsigned int index ) { + if (supported_protocols[index].dwProviderFlags & PFL_HIDDEN) return FALSE; if (!filter) return TRUE; while (*filter) { - if (protocol == *filter++) return TRUE; + if (supported_protocols[index].iProtocol == *filter++) return TRUE; } return FALSE; } @@ -4120,7 +4138,7 @@ int WINAPI WSAEnumProtocolsA( int *filter, WSAPROTOCOL_INFOA *protocols, DWORD *
for (i = 0; i < ARRAY_SIZE(supported_protocols); ++i) { - if (protocol_matches_filter( filter, supported_protocols[i].iProtocol )) + if (protocol_matches_filter( filter, i )) ++count; }
@@ -4134,7 +4152,7 @@ int WINAPI WSAEnumProtocolsA( int *filter, WSAPROTOCOL_INFOA *protocols, DWORD * count = 0; for (i = 0; i < ARRAY_SIZE(supported_protocols); ++i) { - if (protocol_matches_filter( filter, supported_protocols[i].iProtocol )) + if (protocol_matches_filter( filter, i )) { memcpy( &protocols[count], &supported_protocols[i], offsetof( WSAPROTOCOL_INFOW, szProtocol ) ); WideCharToMultiByte( CP_ACP, 0, supported_protocols[i].szProtocol, -1, @@ -4190,7 +4208,7 @@ int WINAPI WSAEnumProtocolsW( int *filter, WSAPROTOCOL_INFOW *protocols, DWORD *
for (i = 0; i < ARRAY_SIZE(supported_protocols); ++i) { - if (protocol_matches_filter( filter, supported_protocols[i].iProtocol )) + if (protocol_matches_filter( filter, i )) ++count; }
@@ -4204,7 +4222,7 @@ int WINAPI WSAEnumProtocolsW( int *filter, WSAPROTOCOL_INFOW *protocols, DWORD * count = 0; for (i = 0; i < ARRAY_SIZE(supported_protocols); ++i) { - if (protocol_matches_filter( filter, supported_protocols[i].iProtocol )) + if (protocol_matches_filter( filter, i )) protocols[count++] = supported_protocols[i]; } return count; diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c index 9a6c8610718..0b14543606a 100644 --- a/dlls/ws2_32/tests/protocol.c +++ b/dlls/ws2_32/tests/protocol.c @@ -107,6 +107,7 @@ static void test_WSAEnumProtocolsA(void) for (i = 0; i < ret; i++) { ok( strlen( buffer[i].szProtocol ), "No protocol name found\n" ); + ok( !(buffer[i].dwProviderFlags & PFL_HIDDEN), "Found a protocol with PFL_HIDDEN.\n" ); test_service_flags( buffer[i].iAddressFamily, buffer[i].iVersion, buffer[i].iSocketType, buffer[i].iProtocol, buffer[i].dwServiceFlags1); @@ -174,6 +175,7 @@ static void test_WSAEnumProtocolsW(void) for (i = 0; i < ret; i++) { ok( lstrlenW( buffer[i].szProtocol ), "No protocol name found\n" ); + ok( !(buffer[i].dwProviderFlags & PFL_HIDDEN), "Found a protocol with PFL_HIDDEN.\n" ); test_service_flags( buffer[i].iAddressFamily, buffer[i].iVersion, buffer[i].iSocketType, buffer[i].iProtocol, buffer[i].dwServiceFlags1); diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 3ec0ab67040..f611fe6ed9d 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2937,18 +2937,38 @@ static void test_WSASocket(void) } else { + WSAPROTOCOL_INFOW info; + size = sizeof(socktype); socktype = 0xdead; err = getsockopt(sock, SOL_SOCKET, SO_TYPE, (char *) &socktype, &size); ok(!err, "getsockopt failed with %d\n", WSAGetLastError()); ok(socktype == SOCK_RAW, "Wrong socket type, expected %d received %d\n", SOCK_RAW, socktype); + + size = sizeof(info); + err = getsockopt(sock, SOL_SOCKET, SO_PROTOCOL_INFOW, (char *) &info, &size); + ok(!err,"got error %d\n", WSAGetLastError()); + ok(!wcscmp(info.szProtocol, L"MSAFD Tcpip [RAW/IP]") + || broken(!wcscmp(info.szProtocol, L"MSAFD-Tcpip [RAW/IP]")) /* Some Win7 machines. */, + "got szProtocol %s.\n", debugstr_w(info.szProtocol)); + ok(info.iAddressFamily == AF_INET, "got iAddressFamily %d.\n", info.iAddressFamily); + ok(info.iSocketType == SOCK_RAW, "got iSocketType %d.\n", info.iSocketType); + ok(info.iMaxSockAddr == 0x10, "got iMaxSockAddr %d.\n", info.iMaxSockAddr); + ok(info.iMinSockAddr == 0x10, "got iMinSockAddr %d.\n", info.iMinSockAddr); + todo_wine ok(!info.iProtocol, "got iProtocol %d.\n", info.iProtocol); + ok(info.iProtocolMaxOffset == 255, "got iProtocol %d.\n", info.iProtocolMaxOffset); + ok(info.dwProviderFlags == (PFL_MATCHES_PROTOCOL_ZERO | PFL_HIDDEN), "got dwProviderFlags %#lx.\n", + info.dwProviderFlags); + ok(info.dwServiceFlags1 == (XP1_IFS_HANDLES | XP1_SUPPORT_BROADCAST | XP1_SUPPORT_MULTIPOINT + | XP1_MESSAGE_ORIENTED | XP1_CONNECTIONLESS), "got dwServiceFlags1 %#lx.\n", + info.dwServiceFlags1); + closesocket(sock);
sock = WSASocketA(0, 0, IPPROTO_RAW, NULL, 0, 0); if (sock != INVALID_SOCKET) { - todo_wine { size = sizeof(socktype); socktype = 0xdead; err = getsockopt(sock, SOL_SOCKET, SO_TYPE, (char *) &socktype, &size); @@ -2956,7 +2976,6 @@ static void test_WSASocket(void) ok(socktype == SOCK_RAW, "Wrong socket type, expected %d received %d\n", SOCK_RAW, socktype); closesocket(sock); - }
sock = WSASocketA(AF_INET, SOCK_RAW, IPPROTO_TCP, NULL, 0, 0); ok(sock != INVALID_SOCKET, "Failed to create socket: %d\n",