ws2_32: Make getsockopt(SO_TYPE) convert the returned socket type.

This commit is contained in:
Bruno Jesus 2013-09-18 17:36:25 -03:00 committed by Alexandre Julliard
parent 018d629b3c
commit e9bd764a7b
1 changed files with 21 additions and 1 deletions

View File

@ -2937,7 +2937,6 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
case WS_SO_RCVBUF: case WS_SO_RCVBUF:
case WS_SO_REUSEADDR: case WS_SO_REUSEADDR:
case WS_SO_SNDBUF: case WS_SO_SNDBUF:
case WS_SO_TYPE:
if ( (fd = get_sock_fd( s, 0, NULL )) == -1) if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
return SOCKET_ERROR; return SOCKET_ERROR;
convert_sockopt(&level, &optname); convert_sockopt(&level, &optname);
@ -3136,6 +3135,27 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
return ret; return ret;
} }
#endif #endif
case WS_SO_TYPE:
{
if (!optlen || *optlen < sizeof(int) || !optval)
{
SetLastError(WSAEFAULT);
return SOCKET_ERROR;
}
if ( (fd = get_sock_fd( s, 0, NULL )) == -1)
return SOCKET_ERROR;
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, optval, (socklen_t *)optlen) != 0 )
{
SetLastError((errno == EBADF) ? WSAENOTSOCK : wsaErrno());
ret = SOCKET_ERROR;
}
else
(*(int *)optval) = convert_socktype_u2w(*(int *)optval);
release_sock_fd( s, fd );
return ret;
}
default: default:
TRACE("Unknown SOL_SOCKET optname: 0x%08x\n", optname); TRACE("Unknown SOL_SOCKET optname: 0x%08x\n", optname);
SetLastError(WSAENOPROTOOPT); SetLastError(WSAENOPROTOOPT);