Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- configure.ac | 7 +++++++ dlls/ntdll/unix/socket.c | 23 +++++++++++++++++++++++ dlls/ws2_32/socket.c | 7 +++++++ dlls/ws2_32/tests/sock.c | 8 -------- include/wine/afd.h | 2 ++ 5 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac index b5d3217f2a0..a42c2aff272 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c index babc5990593..1af123b1251 100644 --- a/dlls/ntdll/unix/socket.c +++ b/dlls/ntdll/unix/socket.c @@ -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 );
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 8026bc62ace..bec474898e7 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -316,6 +316,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); @@ -2109,6 +2110,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 );
@@ -3318,6 +3322,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; diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 12c1a859336..dd8c83374d0 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -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); diff --git a/include/wine/afd.h b/include/wine/afd.h index 0be0678606d..caa86eabf83 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -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 {