From cdffa876663bf8d4efe657cf3ae0b5a9af832912 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Wed, 12 Aug 2009 09:15:33 -0700 Subject: [PATCH] ws2_32: Implement getsockopt(SOL_IRLMP, IRLMP_ENUMDEVICES). --- dlls/ws2_32/socket.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index afa8d9b397c..273f84a7af8 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)