ws2_32: Hook up IPV6_PKTINFO.

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-08-02 23:08:39 -06:00 committed by Alexandre Julliard
parent 71d1bb60f1
commit cade5944be
7 changed files with 57 additions and 8 deletions

15
configure vendored
View File

@ -19366,6 +19366,21 @@ _ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct in6_pktinfo" "ipi6_addr" "ac_cv_member_struct_in6_pktinfo_ipi6_addr" "#ifdef HAVE_NETINET_IN_H
#define _GNU_SOURCE
#include <netinet/in.h>
#endif
"
if test "x$ac_cv_member_struct_in6_pktinfo_ipi6_addr" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_IN6_PKTINFO_IPI6_ADDR 1
_ACEOF
fi
ac_fn_c_check_member "$LINENO" "struct ipstat" "ips_total" "ac_cv_member_struct_ipstat_ips_total" "#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

View File

@ -2546,6 +2546,13 @@ AC_CHECK_MEMBERS([struct icmpstat.icps_outhist],,,
#include <netinet/icmp_var.h>
#endif])
dnl Check for struct in6_pktinfo
AC_CHECK_MEMBERS([struct in6_pktinfo.ipi6_addr],,,
[#ifdef HAVE_NETINET_IN_H
#define _GNU_SOURCE
#include <netinet/in.h>
#endif])
dnl Check for struct ipstat
AC_CHECK_MEMBERS([struct ipstat.ips_total],,,
[#ifdef HAVE_SYS_TYPES_H

View File

@ -23,6 +23,7 @@
#endif
#include "config.h"
#define _GNU_SOURCE /* for struct in6_pktinfo */
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
@ -466,6 +467,20 @@ static int convert_control_headers(struct msghdr *hdr, WSABUF *control)
}
#endif /* IPV6_HOPLIMIT */
#if defined(IPV6_PKTINFO) && defined(HAVE_STRUCT_IN6_PKTINFO_IPI6_ADDR)
case IPV6_PKTINFO:
{
struct in6_pktinfo *data_unix = (struct in6_pktinfo *)CMSG_DATA(cmsg_unix);
struct WS_in6_pktinfo data_win;
memcpy(&data_win.ipi6_addr, &data_unix->ipi6_addr.s6_addr, 16);
data_win.ipi6_ifindex = data_unix->ipi6_ifindex;
ptr = fill_control_message( WS_IPPROTO_IPV6, WS_IPV6_PKTINFO, ptr, &ctlsize,
(void *)&data_win, sizeof(data_win) );
if (!ptr) goto error;
}
#endif /* IPV6_PKTINFO */
default:
FIXME("Unhandled IPPROTO_IPV6 message header type %d\n", cmsg_unix->cmsg_type);
break;
@ -1910,6 +1925,14 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc
return do_setsockopt( handle, io, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, in_buffer, in_size );
#endif
#ifdef IPV6_RECVPKTINFO
case IOCTL_AFD_WINE_GET_IPV6_RECVPKTINFO:
return do_getsockopt( handle, io, IPPROTO_IPV6, IPV6_RECVPKTINFO, out_buffer, out_size );
case IOCTL_AFD_WINE_SET_IPV6_RECVPKTINFO:
return do_setsockopt( handle, io, IPPROTO_IPV6, IPV6_RECVPKTINFO, in_buffer, in_size );
#endif
case IOCTL_AFD_WINE_GET_IPV6_UNICAST_HOPS:
return do_getsockopt( handle, io, IPPROTO_IPV6, IPV6_UNICAST_HOPS, out_buffer, out_size );

View File

@ -318,6 +318,7 @@ static inline const char *debugstr_sockopt(int level, int optname)
DEBUG_SOCKOPT(WS_IPV6_MULTICAST_IF);
DEBUG_SOCKOPT(WS_IPV6_MULTICAST_HOPS);
DEBUG_SOCKOPT(WS_IPV6_MULTICAST_LOOP);
DEBUG_SOCKOPT(WS_IPV6_PKTINFO);
DEBUG_SOCKOPT(WS_IPV6_UNICAST_HOPS);
DEBUG_SOCKOPT(WS_IPV6_V6ONLY);
DEBUG_SOCKOPT(WS_IPV6_UNICAST_IF);
@ -1938,6 +1939,9 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
case WS_IPV6_MULTICAST_LOOP:
return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPV6_MULTICAST_LOOP, optval, optlen );
case WS_IPV6_PKTINFO:
return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPV6_RECVPKTINFO, optval, optlen );
case WS_IPV6_UNICAST_HOPS:
return server_getsockopt( s, IOCTL_AFD_WINE_GET_IPV6_UNICAST_HOPS, optval, optlen );
@ -3147,6 +3151,9 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname,
case WS_IPV6_MULTICAST_LOOP:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_MULTICAST_LOOP, optval, optlen );
case WS_IPV6_PKTINFO:
return server_setsockopt( s, IOCTL_AFD_WINE_SET_IPV6_RECVPKTINFO, optval, optlen );
case WS_IPV6_PROTECTION_LEVEL:
FIXME("IPV6_PROTECTION_LEVEL is ignored!\n");
return 0;

View File

@ -2050,31 +2050,23 @@ static void test_ipv6_cmsg(void)
memset(control, 0, sizeof(control));
msg.Control.len = sizeof(control);
rc = setsockopt(server, IPPROTO_IPV6, IPV6_PKTINFO, (const char *)&on, sizeof(on));
todo_wine
ok(!rc, "failed to set IPV6_PKTINFO, error %u\n", WSAGetLastError());
state = 0;
count = sizeof(state);
rc = getsockopt(server, IPPROTO_IPV6, IPV6_PKTINFO, (char *)&state, (INT *)&count);
todo_wine
ok(!rc, "failed to get IPV6_PKTINFO, 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);
todo_wine
ok(header->cmsg_level == IPPROTO_IPV6, "expected IPPROTO_IPV6, got %i\n", header->cmsg_level);
todo_wine
ok(header->cmsg_type == IPV6_PKTINFO, "expected IPV6_PKTINFO, got %i\n", header->cmsg_type);
todo_wine
ok(header->cmsg_len == sizeof(*header) + sizeof(IN6_PKTINFO),
"expected length %i, got %i\n", (INT)(sizeof(*header) + sizeof(IN6_PKTINFO)), (INT)header->cmsg_len);
todo_wine
ok(!memcmp(&pkt_info->ipi6_addr, &localhost.sin6_addr, sizeof(IN6_ADDR)), "expected ::1\n");
rc = setsockopt(server, IPPROTO_IPV6, IPV6_PKTINFO, (const char *)&off, sizeof(off));
todo_wine
ok(!rc, "failed to clear IPV6_PKTINFO, error %u\n", WSAGetLastError());
closesocket(server);

View File

@ -645,6 +645,9 @@
/* Define to 1 if `ifr_hwaddr' is a member of `struct ifreq'. */
#undef HAVE_STRUCT_IFREQ_IFR_HWADDR
/* Define to 1 if `ipi6_addr' is a member of `struct in6_pktinfo'. */
#undef HAVE_STRUCT_IN6_PKTINFO_IPI6_ADDR
/* Define to 1 if `ips_total' is a member of `struct ipstat'. */
#undef HAVE_STRUCT_IPSTAT_IPS_TOTAL

View File

@ -230,6 +230,8 @@ struct afd_get_events_params
#define IOCTL_AFD_WINE_SET_TCP_NODELAY WINE_AFD_IOC(285)
#define IOCTL_AFD_WINE_GET_IPV6_RECVHOPLIMIT WINE_AFD_IOC(286)
#define IOCTL_AFD_WINE_SET_IPV6_RECVHOPLIMIT WINE_AFD_IOC(287)
#define IOCTL_AFD_WINE_GET_IPV6_RECVPKTINFO WINE_AFD_IOC(288)
#define IOCTL_AFD_WINE_SET_IPV6_RECVPKTINFO WINE_AFD_IOC(289)
struct afd_create_params
{