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...
v3: Rebase without changes --- 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 d42c1c1ffbc..7ab96c830b9 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 %Iu, got %u\n", 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) /* <= win10 v1607 */, "expected IP_TTL, got %i\n", header->cmsg_type); -todo_wine ok(header->cmsg_len == sizeof(*header) + sizeof(INT), "expected length %Iu, got %Iu\n", sizeof(*header) + sizeof(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 {