ws2_32: Move the getsockopt(IRLMP_ENUMDEVICES) implementation to ntdll.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
55c761540d
commit
3e09e25068
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue