ws2_32(8/8): Implement getsockopt(SOL_IRLMP, IRLMP_ENUMDEVICES)
Juan Lang
juan.lang at gmail.com
Tue Aug 11 11:20:50 CDT 2009
--Juan
-------------- next part --------------
From ae197b7c566b8952dd1d41442ada930b7fec77db Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Mon, 10 Aug 2009 09:36:33 -0700
Subject: [PATCH 8/8] Implement getsockopt(SOL_IRLMP, IRLMP_ENUMDEVICES)
---
dlls/ws2_32/socket.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 4bba111..dc61bf7 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2006,6 +2006,72 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
}/* end switch(optname) */
} /* end case NSPROTO_IPX */
#endif
+
+#ifdef HAVE_IRDA
+ case WS_SOL_IRLMP:
+ switch(optname)
+ {
+ case WS_IRLMP_ENUMDEVICES:
+ {
+ static const int MAX_IRDA_DEVICES = 10;
+ char buf[sizeof(struct irda_device_list) +
+ (MAX_IRDA_DEVICES - 1) * sizeof(struct irda_device_info)];
+ int fd, res;
+ socklen_t len = sizeof(buf);
+
+ if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
+ return SOCKET_ERROR;
+ res = getsockopt( fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len );
+ 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), i;
+
+ if (src->len > 0)
+ needed += (src->len - 1) * sizeof(IRDA_DEVICE_INFO);
+ if (*optlen < needed)
+ {
+ SetLastError(WSAEFAULT);
+ return SOCKET_ERROR;
+ }
+ 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 */
+#endif
+
/* Levels WS_IPPROTO_TCP and WS_IPPROTO_IP convert directly */
case WS_IPPROTO_TCP:
switch(optname)
--
1.6.3.2
More information about the wine-patches
mailing list