ws2_32: Implement getsockopt(SOL_IRLMP, IRLMP_ENUMDEVICES).

This commit is contained in:
Juan Lang 2009-08-12 09:15:33 -07:00 committed by Alexandre Julliard
parent c3f2eceaf2
commit cdffa87666
1 changed files with 67 additions and 0 deletions

View File

@ -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)