Zebediah Figura : ws2_32: Move the getsockopt(IRLMP_ENUMDEVICES) implementation to ntdll.
Alexandre Julliard
julliard at winehq.org
Mon Aug 2 16:43:35 CDT 2021
Module: wine
Branch: master
Commit: 3e09e2506899107eb832f173ad4356421ae3c3e3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3e09e2506899107eb832f173ad4356421ae3c3e3
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Fri Jul 30 18:55:38 2021 -0500
ws2_32: Move the getsockopt(IRLMP_ENUMDEVICES) implementation to ntdll.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/socket.c | 43 ++++++++++++++++++++++++++++++++++
dlls/ws2_32/socket.c | 60 +-----------------------------------------------
include/wine/afd.h | 1 +
3 files changed, 45 insertions(+), 59 deletions(-)
diff --git a/dlls/ntdll/unix/socket.c b/dlls/ntdll/unix/socket.c
index a63209e6ae6..7fc41ff9f1a 100644
--- a/dlls/ntdll/unix/socket.c
+++ b/dlls/ntdll/unix/socket.c
@@ -1956,6 +1956,49 @@ NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc
}
#endif
+#ifdef HAS_IRDA
+#define MAX_IRDA_DEVICES 10
+ case IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES:
+ {
+ char buffer[offsetof( struct irda_device_list, dev[MAX_IRDA_DEVICES] )];
+ struct irda_device_list *unix_list = (struct irda_device_list *)buffer;
+ socklen_t len = sizeof(buffer);
+ DEVICELIST *ws_list = out_buffer;
+ int fd, needs_close = FALSE;
+ NTSTATUS status;
+ unsigned int i;
+ int ret;
+
+ if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL )))
+ return status;
+
+ ret = getsockopt( fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buffer, &len );
+ if (needs_close) close( fd );
+ if (ret) return sock_errno_to_status( errno );
+
+ io->Information = offsetof( DEVICELIST, unix_list->len );
+ if (out_size < io->Information)
+ return STATUS_BUFFER_TOO_SMALL;
+
+ TRACE( "IRLMP_ENUMDEVICES: got %u devices:\n", unix_list->len );
+ ws_list->numDevice = unix_list->len;
+ for (i = 0; i < unix_list->len; ++i)
+ {
+ const struct irda_device_info *unix_dev = &unix_list->dev[i];
+ IRDA_DEVICE_INFO *ws_dev = &ws_list->Device[i];
+
+ TRACE( "saddr %#08x, daddr %#08x, info %s, hints 0x%02x%02x\n",
+ unix_dev->saddr, unix_dev->daddr, unix_dev->info, unix_dev->hints[0], unix_dev->hints[1] );
+ memcpy( ws_dev->irdaDeviceID, &unix_dev->daddr, sizeof(unix_dev->daddr) );
+ memcpy( ws_dev->irdaDeviceName, unix_dev->info, sizeof(unix_dev->info) );
+ ws_dev->irdaDeviceHints1 = unix_dev->hints[0];
+ ws_dev->irdaDeviceHints2 = unix_dev->hints[1];
+ ws_dev->irdaCharSet = unix_dev->charset;
+ }
+ return STATUS_SUCCESS;
+ }
+#endif
+
default:
{
if ((code >> 16) == FILE_DEVICE_NETWORK)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index da45734803c..7da975167ee 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2169,75 +2169,17 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
}/* end switch(optname) */
} /* end case WS_NSPROTO_IPX */
-#ifdef HAS_IRDA
-#define MAX_IRDA_DEVICES 10
-
case WS_SOL_IRLMP:
switch(optname)
{
case WS_IRLMP_ENUMDEVICES:
- {
- char buf[sizeof(struct irda_device_list) +
- (MAX_IRDA_DEVICES - 1) * sizeof(struct irda_device_info)];
- int res;
- socklen_t len = sizeof(buf);
+ return server_getsockopt( s, IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES, optval, optlen );
- if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
- return SOCKET_ERROR;
- res = getsockopt( fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len );
- release_sock_fd( s, fd );
- if (res < 0)
- {
- SetLastError(wsaErrno());
- return SOCKET_ERROR;
- }
- else
- {
- struct irda_device_list *src = (struct irda_device_list *)buf;
- DEVICELIST *dst = (DEVICELIST *)optval;
- INT needed = sizeof(DEVICELIST);
- unsigned int i;
-
- if (src->len > 0)
- needed += (src->len - 1) * sizeof(IRDA_DEVICE_INFO);
- if (*optlen < needed)
- {
- SetLastError(WSAEFAULT);
- return SOCKET_ERROR;
- }
- *optlen = needed;
- TRACE("IRLMP_ENUMDEVICES: %d devices found:\n", src->len);
- dst->numDevice = src->len;
- for (i = 0; i < src->len; i++)
- {
- TRACE("saddr = %08x, daddr = %08x, info = %s, hints = %02x%02x\n",
- src->dev[i].saddr, src->dev[i].daddr,
- src->dev[i].info, src->dev[i].hints[0],
- src->dev[i].hints[1]);
- memcpy( dst->Device[i].irdaDeviceID,
- &src->dev[i].daddr,
- sizeof(dst->Device[i].irdaDeviceID) ) ;
- memcpy( dst->Device[i].irdaDeviceName,
- src->dev[i].info,
- sizeof(dst->Device[i].irdaDeviceName) ) ;
- memcpy( &dst->Device[i].irdaDeviceHints1,
- &src->dev[i].hints[0],
- sizeof(dst->Device[i].irdaDeviceHints1) ) ;
- memcpy( &dst->Device[i].irdaDeviceHints2,
- &src->dev[i].hints[1],
- sizeof(dst->Device[i].irdaDeviceHints2) ) ;
- dst->Device[i].irdaCharSet = src->dev[i].charset;
- }
- return 0;
- }
- }
default:
FIXME("IrDA optname:0x%x\n", optname);
return SOCKET_ERROR;
}
break; /* case WS_SOL_IRLMP */
-#undef MAX_IRDA_DEVICES
-#endif
/* Levels WS_IPPROTO_TCP and WS_IPPROTO_IP convert directly */
case WS_IPPROTO_TCP:
diff --git a/include/wine/afd.h b/include/wine/afd.h
index 4db6525a7d8..6e601f60095 100644
--- a/include/wine/afd.h
+++ b/include/wine/afd.h
@@ -225,6 +225,7 @@ struct afd_get_events_params
#define IOCTL_AFD_WINE_SET_IPV6_V6ONLY WINE_AFD_IOC(280)
#define IOCTL_AFD_WINE_GET_IPX_PTYPE WINE_AFD_IOC(281)
#define IOCTL_AFD_WINE_SET_IPX_PTYPE WINE_AFD_IOC(282)
+#define IOCTL_AFD_WINE_GET_IRLMP_ENUMDEVICES WINE_AFD_IOC(283)
struct afd_create_params
{
More information about the wine-cvs
mailing list