[PATCH 4/5] ws2_32: Move the getsockopt(IP_DONTFRAGMENT) implementation to ntdll.

Zebediah Figura z.figura12 at gmail.com
Thu Jul 1 17:10:27 CDT 2021


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ntdll/unix/socket.c | 33 +++++++++++++++++++++++++++++++++
 dlls/ws2_32/socket.c     |  5 +++--
 include/wine/afd.h       |  1 +
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c
index 8b140ce4930..f9f701f734c 100644
--- a/dlls/ntdll/unix/socket.c
+++ b/dlls/ntdll/unix/socket.c
@@ -1684,6 +1684,39 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc
         case IOCTL_AFD_WINE_SET_IP_BLOCK_SOURCE:
             return do_setsockopt( handle, io, IPPROTO_IP, IP_BLOCK_SOURCE, in_buffer, in_size );
 
+        case IOCTL_AFD_WINE_GET_IP_DONTFRAGMENT:
+        {
+            socklen_t len = out_size;
+            int ret;
+
+            if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
+                return status;
+
+#ifdef IP_DONTFRAG
+            ret = getsockopt( fd, IPPROTO_IP, IP_DONTFRAG, out_buffer, &len );
+#elif defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
+            {
+                int value;
+
+                len = sizeof(value);
+                ret = getsockopt( fd, IPPROTO_IP, IP_MTU_DISCOVER, &value, &len );
+                if (!ret) *(DWORD *)out_buffer = (value != IP_PMTUDISC_DONT);
+            }
+#else
+            {
+                static int once;
+
+                if (!once++)
+                    FIXME( "IP_DONTFRAGMENT is not supported on this platform\n" );
+                ret = 0; /* fake success */
+            }
+#endif
+            if (needs_close) close( fd );
+            if (ret) return sock_errno_to_status( errno );
+            io->Information = len;
+            return STATUS_SUCCESS;
+        }
+
         default:
         {
             if ((code >> 16) == FILE_DEVICE_NETWORK)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 00b83d06478..963d55ead2c 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2433,6 +2433,9 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
     case WS_IPPROTO_IP:
         switch(optname)
         {
+        case WS_IP_DONTFRAGMENT:
+            return server_getsockopt( s, IOCTL_AFD_WINE_GET_IP_DONTFRAGMENT, optval, optlen );
+
 #ifdef IP_HDRINCL
         case WS_IP_HDRINCL:
 #endif
@@ -2458,8 +2461,6 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
             }
             release_sock_fd( s, fd );
             return ret;
-        case WS_IP_DONTFRAGMENT:
-            return get_dont_fragment(s, IPPROTO_IP, (BOOL *)optval) ? 0 : SOCKET_ERROR;
 
         default:
             FIXME( "unrecognized IP option %u\n", optname );
diff --git a/include/wine/afd.h b/include/wine/afd.h
index 4ed75067264..13ede0d2450 100644
--- a/include/wine/afd.h
+++ b/include/wine/afd.h
@@ -184,6 +184,7 @@ struct afd_get_events_params
 #define IOCTL_AFD_WINE_SET_IP_ADD_MEMBERSHIP            WINE_AFD_IOC(239)
 #define IOCTL_AFD_WINE_SET_IP_ADD_SOURCE_MEMBERSHIP     WINE_AFD_IOC(240)
 #define IOCTL_AFD_WINE_SET_IP_BLOCK_SOURCE              WINE_AFD_IOC(241)
+#define IOCTL_AFD_WINE_GET_IP_DONTFRAGMENT              WINE_AFD_IOC(242)
 
 struct afd_create_params
 {
-- 
2.30.2




More information about the wine-devel mailing list