ws2_32: Hook up IP_RECVTTL.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alex Henrie 2021-09-29 00:40:54 -06:00 committed by Alexandre Julliard
parent 77f07a0da2
commit 0853573caf
4 changed files with 39 additions and 9 deletions

View File

@ -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 );

View File

@ -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 );

View File

@ -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 },

View File

@ -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
{