ws2_32(8/8): Implement getsockopt(SOL_IRLMP, IRLMP_ENUMDEVICES) (try 4)

Juan Lang juan.lang at gmail.com
Wed Aug 12 11:17:31 CDT 2009


--Juan
-------------- next part --------------
From 078bf1d393d6673d1bf71f8d686e4b0a5f77dc20 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Wed, 12 Aug 2009 09:15:33 -0700
Subject: [PATCH 8/8] Implement getsockopt(SOL_IRLMP, IRLMP_ENUMDEVICES)

---
 dlls/ws2_32/socket.c |   67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index afa8d9b..273f84a 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2007,6 +2007,73 @@ 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;
+                }
+                *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 */
+#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