IP_PKTINFO already had tests, but it doesn't hurt to add a few more. IP_RECVTTL and IP_RECVTCLASS didn't have any tests.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/ws2_32/tests/sock.c | 120 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 8cbb393b542..4105ce624b2 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1984,6 +1984,125 @@ static void test_ip_pktinfo(void) CloseHandle(ov.hEvent); }
+static void test_ipv4_cmsg(void) +{ + static const DWORD off = 0; + static const DWORD on = 1; + SOCKADDR_IN localhost = {0}; + SOCKET client, server; + char payload[] = "HELLO"; + char control[100]; + WSABUF payload_buf = {sizeof(payload), payload}; + WSAMSG msg = {NULL, 0, &payload_buf, 1, {sizeof(control), control}, 0}; + WSACMSGHDR *header = (WSACMSGHDR *)control; + LPFN_WSARECVMSG pWSARecvMsg; + INT *int_data = (INT *)WSA_CMSG_DATA(header); + IN_PKTINFO *pkt_info = (IN_PKTINFO *)WSA_CMSG_DATA(header); + DWORD count, state; + int rc; + + localhost.sin_family = AF_INET; + localhost.sin_port = htons(SERVERPORT); + inet_pton(AF_INET, "127.0.0.1", &localhost.sin_addr); + + client = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ok(client != INVALID_SOCKET, "failed to create socket, error %u\n", WSAGetLastError()); + server = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + ok(server != INVALID_SOCKET, "failed to create socket, error %u\n", WSAGetLastError()); + + rc = bind(server, (SOCKADDR *)&localhost, sizeof(localhost)); + ok(rc != SOCKET_ERROR, "bind failed, error %u\n", WSAGetLastError()); + rc = connect(client, (SOCKADDR *)&localhost, sizeof(localhost)); + ok(rc != SOCKET_ERROR, "connect failed, error %u\n", WSAGetLastError()); + + rc = WSAIoctl(server, SIO_GET_EXTENSION_FUNCTION_POINTER, &WSARecvMsg_GUID, sizeof(WSARecvMsg_GUID), + &pWSARecvMsg, sizeof(pWSARecvMsg), &count, NULL, NULL); + ok(!rc, "failed to get WSARecvMsg, error %u\n", WSAGetLastError()); + + memset(control, 0, sizeof(control)); + msg.Control.len = sizeof(control); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&on, sizeof(on)); +todo_wine + ok(!rc, "failed to set IP_RECVTTL, error %u\n", WSAGetLastError()); + state = 0; + count = sizeof(state); + rc = getsockopt(server, IPPROTO_IP, IP_RECVTTL, (char *)&state, (INT *)&count); +todo_wine + ok(!rc, "failed to get IP_RECVTTL, error %u\n", WSAGetLastError()); +todo_wine + ok(state == 1, "expected 1, got %u\n", state); + rc = send(client, payload, sizeof(payload), 0); + ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); + rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); + ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); + ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); + ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); +todo_wine + ok(header->cmsg_type == IP_TTL || broken(header->cmsg_type == IP_HOPLIMIT) /* win8 */, + "expected IP_TTL, got %i\n", header->cmsg_type); +todo_wine + ok(header->cmsg_len == sizeof(*header) + sizeof(INT), + "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len); +todo_wine + ok(*int_data >= 32, "expected at least 32, got %i\n", *int_data); + setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&off, sizeof(off)); + ok(!rc, "failed to clear IP_RECVTTL, error %u\n", WSAGetLastError()); + + memset(control, 0, sizeof(control)); + msg.Control.len = sizeof(control); + rc = setsockopt(server, IPPROTO_IP, IP_PKTINFO, (const char *)&on, sizeof(on)); + ok(!rc, "failed to set IP_PKTINFO, error %u\n", WSAGetLastError()); + state = 0; + count = sizeof(state); + rc = getsockopt(server, IPPROTO_IP, IP_PKTINFO, (char *)&state, (INT *)&count); + ok(!rc, "failed to get IP_PKTINFO, error %u\n", WSAGetLastError()); + ok(state == 1, "expected 1, got %u\n", state); + rc = send(client, payload, sizeof(payload), 0); + ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); + rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); + ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); + ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); + ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); + ok(header->cmsg_type == IP_PKTINFO, "expected IP_PKTINFO, got %i\n", header->cmsg_type); + ok(header->cmsg_len == sizeof(*header) + sizeof(IN_PKTINFO), + "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(IN_PKTINFO)), (INT)header->cmsg_len); + ok(!memcmp(&pkt_info->ipi_addr, &localhost.sin_addr, sizeof(IN_ADDR)), "expected 127.0.0.1\n"); + rc = setsockopt(server, IPPROTO_IP, IP_PKTINFO, (const char *)&off, sizeof(off)); + ok(!rc, "failed to clear IP_PKTINFO, error %u\n", WSAGetLastError()); + + memset(control, 0, sizeof(control)); + msg.Control.len = sizeof(control); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&on, sizeof(on)); +todo_wine + ok(!rc, "failed to set IP_RECVTCLASS, error %u\n", WSAGetLastError()); + state = 0; + count = sizeof(state); + rc = getsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (char *)&state, (INT *)&count); +todo_wine + ok(!rc, "failed to get IP_RECVTCLASS, error %u\n", WSAGetLastError()); +todo_wine + ok(state == 1, "expected 1, got %u\n", state); + rc = send(client, payload, sizeof(payload), 0); + ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); + rc = pWSARecvMsg(server, &msg, &count, NULL, NULL); + ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); + ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); + ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); +todo_wine + ok(header->cmsg_type == IP_TOS || broken(header->cmsg_type == IP_TCLASS) /* win8 */, + "expected IP_TOS, got %i\n", header->cmsg_type); +todo_wine + ok(header->cmsg_len == sizeof(*header) + sizeof(INT), + "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len); + ok(*int_data == 0, "expected 0, got %i\n", *int_data); + rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&off, sizeof(off)); +todo_wine + ok(!rc, "failed to clear IP_RECVTCLASS, error %u\n", WSAGetLastError()); + + closesocket(server); + closesocket(client); +} + static void test_ipv6_cmsg(void) { static const DWORD off = 0; @@ -11767,6 +11886,7 @@ START_TEST( sock ) test_set_getsockopt(); test_so_reuseaddr(); test_ip_pktinfo(); + test_ipv4_cmsg(); test_ipv6_cmsg(); test_extendedSocketOptions(); test_so_debug();
The checks were ugly and unnecessary. Furthermore, these functions are used for both IPv4 and IPv6 options, and it's conceivable that a system could be stripped down to only provide IPv6 support and not IPv4 support.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/ntdll/unix/socket.c | 7 ------- 1 file changed, 7 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 75c54295c20..2be4f2b52a3 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -369,7 +369,6 @@ static int sockaddr_from_unix( const union unix_sockaddr *uaddr, struct WS_socka }
#ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS -#if defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) static WSACMSGHDR *fill_control_message( int level, int type, WSACMSGHDR *current, ULONG *maxsize, void *data, int len ) { ULONG msgsize = sizeof(WSACMSGHDR) + WSA_CMSG_ALIGN(len); @@ -384,11 +383,9 @@ static WSACMSGHDR *fill_control_message( int level, int type, WSACMSGHDR *curren memcpy(ptr, data, len); return (WSACMSGHDR *)(ptr + WSA_CMSG_ALIGN(len)); } -#endif /* defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) */
static int convert_control_headers(struct msghdr *hdr, WSABUF *control) { -#if defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) WSACMSGHDR *cmsg_win = (WSACMSGHDR *)control->buf, *ptr; ULONG ctlsize = control->len; struct cmsghdr *cmsg_unix; @@ -490,10 +487,6 @@ static int convert_control_headers(struct msghdr *hdr, WSABUF *control) error: control->len = 0; return 0; -#else /* defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) */ - control->len = 0; - return 1; -#endif /* defined(IP_PKTINFO) || defined(IP_RECVDSTADDR) */ } #endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- SkyDNS and DJI Flight Simulator use this option, see:
https://forum.winehq.org/viewtopic.php?t=32375
https://www.reddit.com/r/macgaming/comments/f9u80m/help_error_install_a_driv... --- dlls/ntdll/unix/socket.c | 27 +++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 7 +++++++ dlls/ws2_32/tests/sock.c | 12 +++--------- include/wine/afd.h | 2 ++ 4 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index 2be4f2b52a3..f9576a44eef 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -425,6 +425,17 @@ static int convert_control_headers(struct msghdr *hdr, WSABUF *control) break; } #endif /* IP_PKTINFO */ + +#if defined(IP_TTL) + case IP_TTL: + { + ptr = fill_control_message( WS_IPPROTO_IP, WS_IP_TTL, ptr, &ctlsize, + CMSG_DATA(cmsg_unix), sizeof(INT) ); + if (!ptr) goto error; + break; + } +#endif /* IP_TTL */ + default: FIXME("Unhandled IPPROTO_IP message header type %d\n", cmsg_unix->cmsg_type); break; @@ -1834,6 +1845,22 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } #endif
+#ifdef IP_RECVTTL + case IOCTL_AFD_WINE_GET_IP_RECVTTL: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_getsockopt( handle, io, IPPROTO_IP, IP_RECVTTL, out_buffer, out_size ); + } + + case IOCTL_AFD_WINE_SET_IP_RECVTTL: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_setsockopt( handle, io, IPPROTO_IP, IP_RECVTTL, in_buffer, in_size ); + } +#endif + case IOCTL_AFD_WINE_GET_IP_TOS: return do_getsockopt( handle, io, IPPROTO_IP, IP_TOS, out_buffer, out_size );
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index bf87e7824e5..8085a1c2d35 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -295,6 +295,7 @@ static inline const char *debugstr_sockopt(int level, int optname) DEBUG_SOCKOPT(IP_OPTIONS); DEBUG_SOCKOPT(IP_PKTINFO); DEBUG_SOCKOPT(IP_RECEIVE_BROADCAST); + DEBUG_SOCKOPT(IP_RECVTTL); DEBUG_SOCKOPT(IP_TOS); DEBUG_SOCKOPT(IP_TTL); DEBUG_SOCKOPT(IP_UNICAST_IF); @@ -1693,6 +1694,9 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl case IP_PKTINFO: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTTL: + return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_RECVTTL, optval, optlen ); + case IP_TOS: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_TOS, optval, optlen );
@@ -2908,6 +2912,9 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int case IP_PKTINFO: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTTL: + return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_RECVTTL, optval, optlen ); + case IP_TOS: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_TOS, optval, optlen );
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 4105ce624b2..e7717f0cc1e 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2022,14 +2022,11 @@ static void test_ipv4_cmsg(void) memset(control, 0, sizeof(control)); msg.Control.len = sizeof(control); rc = setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&on, sizeof(on)); -todo_wine ok(!rc, "failed to set IP_RECVTTL, error %u\n", WSAGetLastError()); state = 0; count = sizeof(state); rc = getsockopt(server, IPPROTO_IP, IP_RECVTTL, (char *)&state, (INT *)&count); -todo_wine ok(!rc, "failed to get IP_RECVTTL, error %u\n", WSAGetLastError()); -todo_wine ok(state == 1, "expected 1, got %u\n", state); rc = send(client, payload, sizeof(payload), 0); ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); @@ -2037,13 +2034,10 @@ todo_wine ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); -todo_wine ok(header->cmsg_type == IP_TTL || broken(header->cmsg_type == IP_HOPLIMIT) /* win8 */, "expected IP_TTL, got %i\n", header->cmsg_type); -todo_wine ok(header->cmsg_len == sizeof(*header) + sizeof(INT), "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len); -todo_wine ok(*int_data >= 32, "expected at least 32, got %i\n", *int_data); setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&off, sizeof(off)); ok(!rc, "failed to clear IP_RECVTTL, error %u\n", WSAGetLastError()); @@ -11614,7 +11608,7 @@ static void test_sockopt_validity(void) { IP_DROP_MEMBERSHIP, WSAENOPROTOOPT }, { IP_DONTFRAGMENT }, { IP_PKTINFO, WSAEINVAL }, - { IP_RECVTTL, WSAEINVAL, 0, TRUE }, + { IP_RECVTTL, WSAEINVAL }, { IP_RECEIVE_BROADCAST, WSAEINVAL, 0, TRUE }, { IP_RECVIF, WSAEINVAL, 0, TRUE }, { IP_RECVDSTADDR, WSAEINVAL, 0, TRUE }, @@ -11649,7 +11643,7 @@ static void test_sockopt_validity(void) { IP_DROP_MEMBERSHIP, WSAENOPROTOOPT }, { IP_DONTFRAGMENT }, { IP_PKTINFO }, - { IP_RECVTTL, 0, 0, TRUE }, + { IP_RECVTTL }, { IP_RECEIVE_BROADCAST, 0, 0, TRUE }, { IP_RECVIF, 0, 0, TRUE }, { IP_RECVDSTADDR, 0, 0, TRUE }, @@ -11684,7 +11678,7 @@ static void test_sockopt_validity(void) { IP_DROP_MEMBERSHIP, WSAENOPROTOOPT }, { IP_DONTFRAGMENT }, { IP_PKTINFO }, - { IP_RECVTTL, 0, 0, TRUE }, + { IP_RECVTTL }, { IP_RECEIVE_BROADCAST, 0, 0, TRUE }, { IP_RECVIF, 0, 0, TRUE }, { IP_RECVDSTADDR, 0, 0, TRUE }, diff --git a/include/wine/afd.h b/include/wine/afd.h index f4682f464e8..8ffce81ab6f 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -234,6 +234,8 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_IPV6_RECVTCLASS WINE_AFD_IOC(290) #define IOCTL_AFD_WINE_SET_IPV6_RECVTCLASS WINE_AFD_IOC(291) #define IOCTL_AFD_WINE_GET_SO_CONNECT_TIME WINE_AFD_IOC(292) +#define IOCTL_AFD_WINE_GET_IP_RECVTTL WINE_AFD_IOC(293) +#define IOCTL_AFD_WINE_SET_IP_RECVTTL WINE_AFD_IOC(294)
struct afd_create_params {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=98858
Your paranoid android.
=== debiant2 (32 bit report) ===
ws2_32: afd.c:339: Test failed: got flags 0x43 afd.c:345: Test failed: got flags 0x41
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/ntdll/unix/socket.c | 26 ++++++++++++++++++++++++++ dlls/ws2_32/socket.c | 7 +++++++ dlls/ws2_32/tests/sock.c | 12 +++--------- include/wine/afd.h | 2 ++ 4 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index f9576a44eef..480d8b4f490 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -426,6 +426,16 @@ static int convert_control_headers(struct msghdr *hdr, WSABUF *control) } #endif /* IP_PKTINFO */
+#if defined(IP_TOS) + case IP_TOS: + { + ptr = fill_control_message( WS_IPPROTO_IP, WS_IP_TOS, ptr, &ctlsize, + CMSG_DATA(cmsg_unix), sizeof(INT) ); + if (!ptr) goto error; + break; + } +#endif /* IP_TOS */ + #if defined(IP_TTL) case IP_TTL: { @@ -1845,6 +1855,22 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc } #endif
+#ifdef IP_RECVTOS + case IOCTL_AFD_WINE_GET_IP_RECVTOS: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_getsockopt( handle, io, IPPROTO_IP, IP_RECVTOS, out_buffer, out_size ); + } + + case IOCTL_AFD_WINE_SET_IP_RECVTOS: + { + int sock_type = get_sock_type( handle ); + if (sock_type != SOCK_DGRAM && sock_type != SOCK_RAW) return STATUS_INVALID_PARAMETER; + return do_setsockopt( handle, io, IPPROTO_IP, IP_RECVTOS, in_buffer, in_size ); + } +#endif + #ifdef IP_RECVTTL case IOCTL_AFD_WINE_GET_IP_RECVTTL: { diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 8085a1c2d35..b353b08390b 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -295,6 +295,7 @@ static inline const char *debugstr_sockopt(int level, int optname) DEBUG_SOCKOPT(IP_OPTIONS); DEBUG_SOCKOPT(IP_PKTINFO); DEBUG_SOCKOPT(IP_RECEIVE_BROADCAST); + DEBUG_SOCKOPT(IP_RECVTCLASS); DEBUG_SOCKOPT(IP_RECVTTL); DEBUG_SOCKOPT(IP_TOS); DEBUG_SOCKOPT(IP_TTL); @@ -1694,6 +1695,9 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl case IP_PKTINFO: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTCLASS: + return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_RECVTOS, optval, optlen ); + case IP_RECVTTL: return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_RECVTTL, optval, optlen );
@@ -2912,6 +2916,9 @@ int WINAPI setsockopt( SOCKET s, int level, int optname, const char *optval, int case IP_PKTINFO: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_PKTINFO, optval, optlen );
+ case IP_RECVTCLASS: + return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_RECVTOS, optval, optlen ); + case IP_RECVTTL: return server_setsockopt( s, IOCTL_AFD_WINE_SET_IP_RECVTTL, optval, optlen );
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index e7717f0cc1e..cc5072ec8d6 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -2067,14 +2067,11 @@ static void test_ipv4_cmsg(void) memset(control, 0, sizeof(control)); msg.Control.len = sizeof(control); rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&on, sizeof(on)); -todo_wine ok(!rc, "failed to set IP_RECVTCLASS, error %u\n", WSAGetLastError()); state = 0; count = sizeof(state); rc = getsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (char *)&state, (INT *)&count); -todo_wine ok(!rc, "failed to get IP_RECVTCLASS, error %u\n", WSAGetLastError()); -todo_wine ok(state == 1, "expected 1, got %u\n", state); rc = send(client, payload, sizeof(payload), 0); ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError()); @@ -2082,15 +2079,12 @@ todo_wine ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError()); ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count); ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level); -todo_wine ok(header->cmsg_type == IP_TOS || broken(header->cmsg_type == IP_TCLASS) /* win8 */, "expected IP_TOS, got %i\n", header->cmsg_type); -todo_wine ok(header->cmsg_len == sizeof(*header) + sizeof(INT), "expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len); ok(*int_data == 0, "expected 0, got %i\n", *int_data); rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&off, sizeof(off)); -todo_wine ok(!rc, "failed to clear IP_RECVTCLASS, error %u\n", WSAGetLastError());
closesocket(server); @@ -11617,7 +11611,7 @@ static void test_sockopt_validity(void) { IP_RTHDR, 0, 0, TRUE }, { IP_GET_IFLIST, WSAEINVAL, 0, TRUE }, { IP_RECVRTHDR, WSAEINVAL, 0, TRUE }, - { IP_RECVTCLASS, WSAEINVAL, 0, TRUE }, + { IP_RECVTCLASS, WSAEINVAL }, { IP_ORIGINAL_ARRIVAL_IF, WSAEINVAL, 0, TRUE }, { IP_ECN, WSAEINVAL, 0, TRUE }, { IP_PKTINFO_EX, WSAEINVAL, 0, TRUE }, @@ -11652,7 +11646,7 @@ static void test_sockopt_validity(void) { IP_RTHDR, 0, 0, TRUE }, { IP_GET_IFLIST, WSAEINVAL, 0, TRUE }, { IP_RECVRTHDR, 0, 0, TRUE }, - { IP_RECVTCLASS, 0, 0, TRUE }, + { IP_RECVTCLASS }, { IP_ORIGINAL_ARRIVAL_IF, 0, 0, TRUE }, { IP_ECN, 0, 0, TRUE }, { IP_PKTINFO_EX, 0, 0, TRUE }, @@ -11687,7 +11681,7 @@ static void test_sockopt_validity(void) { IP_RTHDR, 0, 0, TRUE }, { IP_GET_IFLIST, WSAEINVAL, 0, TRUE }, { IP_RECVRTHDR, 0, 0, TRUE }, - { IP_RECVTCLASS, 0, 0, TRUE }, + { IP_RECVTCLASS }, { IP_ORIGINAL_ARRIVAL_IF, 0, 0, TRUE }, { IP_ECN, 0, 0, TRUE }, { IP_PKTINFO_EX, 0, 0, TRUE }, diff --git a/include/wine/afd.h b/include/wine/afd.h index 8ffce81ab6f..3b8bdcb9e5d 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -236,6 +236,8 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_GET_SO_CONNECT_TIME WINE_AFD_IOC(292) #define IOCTL_AFD_WINE_GET_IP_RECVTTL WINE_AFD_IOC(293) #define IOCTL_AFD_WINE_SET_IP_RECVTTL WINE_AFD_IOC(294) +#define IOCTL_AFD_WINE_GET_IP_RECVTOS WINE_AFD_IOC(295) +#define IOCTL_AFD_WINE_SET_IP_RECVTOS WINE_AFD_IOC(296)
struct afd_create_params {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=98859
Your paranoid android.
=== debiant2 (32 bit report) ===
ws2_32: sock.c:5164: Test failed: expected timeout
=== debiant2 (32 bit Chinese:China report) ===
ntdll: change.c:277: Test failed: should be ready
On 9/27/21 9:40 AM, Alex Henrie wrote:
IP_PKTINFO already had tests, but it doesn't hurt to add a few more. IP_RECVTTL and IP_RECVTCLASS didn't have any tests.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com
dlls/ws2_32/tests/sock.c | 120 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 8cbb393b542..4105ce624b2 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1984,6 +1984,125 @@ static void test_ip_pktinfo(void) CloseHandle(ov.hEvent); }
+static void test_ipv4_cmsg(void) +{
- static const DWORD off = 0;
- static const DWORD on = 1;
- SOCKADDR_IN localhost = {0};
- SOCKET client, server;
- char payload[] = "HELLO";
- char control[100];
- WSABUF payload_buf = {sizeof(payload), payload};
- WSAMSG msg = {NULL, 0, &payload_buf, 1, {sizeof(control), control}, 0};
- WSACMSGHDR *header = (WSACMSGHDR *)control;
- LPFN_WSARECVMSG pWSARecvMsg;
- INT *int_data = (INT *)WSA_CMSG_DATA(header);
- IN_PKTINFO *pkt_info = (IN_PKTINFO *)WSA_CMSG_DATA(header);
- DWORD count, state;
- int rc;
- localhost.sin_family = AF_INET;
- localhost.sin_port = htons(SERVERPORT);
- inet_pton(AF_INET, "127.0.0.1", &localhost.sin_addr);
- client = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- ok(client != INVALID_SOCKET, "failed to create socket, error %u\n", WSAGetLastError());
- server = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- ok(server != INVALID_SOCKET, "failed to create socket, error %u\n", WSAGetLastError());
- rc = bind(server, (SOCKADDR *)&localhost, sizeof(localhost));
- ok(rc != SOCKET_ERROR, "bind failed, error %u\n", WSAGetLastError());
- rc = connect(client, (SOCKADDR *)&localhost, sizeof(localhost));
- ok(rc != SOCKET_ERROR, "connect failed, error %u\n", WSAGetLastError());
- rc = WSAIoctl(server, SIO_GET_EXTENSION_FUNCTION_POINTER, &WSARecvMsg_GUID, sizeof(WSARecvMsg_GUID),
&pWSARecvMsg, sizeof(pWSARecvMsg), &count, NULL, NULL);
- ok(!rc, "failed to get WSARecvMsg, error %u\n", WSAGetLastError());
- memset(control, 0, sizeof(control));
- msg.Control.len = sizeof(control);
- rc = setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&on, sizeof(on));
+todo_wine
- ok(!rc, "failed to set IP_RECVTTL, error %u\n", WSAGetLastError());
- state = 0;
- count = sizeof(state);
- rc = getsockopt(server, IPPROTO_IP, IP_RECVTTL, (char *)&state, (INT *)&count);
+todo_wine
- ok(!rc, "failed to get IP_RECVTTL, error %u\n", WSAGetLastError());
+todo_wine
- ok(state == 1, "expected 1, got %u\n", state);
- rc = send(client, payload, sizeof(payload), 0);
- ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError());
- rc = pWSARecvMsg(server, &msg, &count, NULL, NULL);
- ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError());
- ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count);
- ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level);
+todo_wine
- ok(header->cmsg_type == IP_TTL || broken(header->cmsg_type == IP_HOPLIMIT) /* win8 */,
"expected IP_TTL, got %i\n", header->cmsg_type);
Actually, every version up to and including win10 v1607 returns IP_HOPLIMIT here. I'm also not sure I see a reason to mark it broken; it certainly can't be called incorrect.
+todo_wine
- ok(header->cmsg_len == sizeof(*header) + sizeof(INT),
"expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len);
+todo_wine
- ok(*int_data >= 32, "expected at least 32, got %i\n", *int_data);
- setsockopt(server, IPPROTO_IP, IP_RECVTTL, (const char *)&off, sizeof(off));
- ok(!rc, "failed to clear IP_RECVTTL, error %u\n", WSAGetLastError());
- memset(control, 0, sizeof(control));
- msg.Control.len = sizeof(control);
- rc = setsockopt(server, IPPROTO_IP, IP_PKTINFO, (const char *)&on, sizeof(on));
- ok(!rc, "failed to set IP_PKTINFO, error %u\n", WSAGetLastError());
- state = 0;
- count = sizeof(state);
- rc = getsockopt(server, IPPROTO_IP, IP_PKTINFO, (char *)&state, (INT *)&count);
- ok(!rc, "failed to get IP_PKTINFO, error %u\n", WSAGetLastError());
- ok(state == 1, "expected 1, got %u\n", state);
- rc = send(client, payload, sizeof(payload), 0);
- ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError());
- rc = pWSARecvMsg(server, &msg, &count, NULL, NULL);
- ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError());
- ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count);
- ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level);
- ok(header->cmsg_type == IP_PKTINFO, "expected IP_PKTINFO, got %i\n", header->cmsg_type);
- ok(header->cmsg_len == sizeof(*header) + sizeof(IN_PKTINFO),
"expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(IN_PKTINFO)), (INT)header->cmsg_len);
These can be %zu or %Iu. There are many other instances in this patch. There are also many instances of using %i for an unsigned variable.
- ok(!memcmp(&pkt_info->ipi_addr, &localhost.sin_addr, sizeof(IN_ADDR)), "expected 127.0.0.1\n");
- rc = setsockopt(server, IPPROTO_IP, IP_PKTINFO, (const char *)&off, sizeof(off));
- ok(!rc, "failed to clear IP_PKTINFO, error %u\n", WSAGetLastError());
- memset(control, 0, sizeof(control));
- msg.Control.len = sizeof(control);
- rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&on, sizeof(on));
+todo_wine
- ok(!rc, "failed to set IP_RECVTCLASS, error %u\n", WSAGetLastError());
- state = 0;
- count = sizeof(state);
- rc = getsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (char *)&state, (INT *)&count);
+todo_wine
- ok(!rc, "failed to get IP_RECVTCLASS, error %u\n", WSAGetLastError());
+todo_wine
- ok(state == 1, "expected 1, got %u\n", state);
- rc = send(client, payload, sizeof(payload), 0);
- ok(rc == sizeof(payload), "send failed, error %u\n", WSAGetLastError());
- rc = pWSARecvMsg(server, &msg, &count, NULL, NULL);
- ok(!rc, "WSARecvMsg failed, error %u\n", WSAGetLastError());
- ok(count == sizeof(payload), "expected length %i, got %i\n", (INT)sizeof(payload), count);
- ok(header->cmsg_level == IPPROTO_IP, "expected IPPROTO_IP, got %i\n", header->cmsg_level);
+todo_wine
- ok(header->cmsg_type == IP_TOS || broken(header->cmsg_type == IP_TCLASS) /* win8 */,
"expected IP_TOS, got %i\n", header->cmsg_type);
Same here, every version of Windows up to and including v1607 returns IP_TCLASS.
+todo_wine
- ok(header->cmsg_len == sizeof(*header) + sizeof(INT),
"expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(INT)), (INT)header->cmsg_len);
- ok(*int_data == 0, "expected 0, got %i\n", *int_data);
- rc = setsockopt(server, IPPROTO_IP, IP_RECVTCLASS, (const char *)&off, sizeof(off));
+todo_wine
- ok(!rc, "failed to clear IP_RECVTCLASS, error %u\n", WSAGetLastError());
- closesocket(server);
- closesocket(client);
+}
- static void test_ipv6_cmsg(void) { static const DWORD off = 0;
@@ -11767,6 +11886,7 @@ START_TEST( sock ) test_set_getsockopt(); test_so_reuseaddr(); test_ip_pktinfo();
- test_ipv4_cmsg(); test_ipv6_cmsg(); test_extendedSocketOptions(); test_so_debug();