|
|
@ -28,6 +28,10 @@ |
|
|
|
/* Whether ipv6 is supported */ |
|
|
|
int uv_allow_ipv6; |
|
|
|
|
|
|
|
/* Whether there are any non-IFS LSPs stacked on TCP */ |
|
|
|
int uv_tcp_non_ifs_lsp_ipv4; |
|
|
|
int uv_tcp_non_ifs_lsp_ipv6; |
|
|
|
|
|
|
|
/* Ip address used to bind to any port at any interface */ |
|
|
|
struct sockaddr_in uv_addr_ip4_any_; |
|
|
|
struct sockaddr_in6 uv_addr_ip6_any_; |
|
|
@ -80,7 +84,9 @@ void uv_winsock_init() { |
|
|
|
|
|
|
|
WSADATA wsa_data; |
|
|
|
int errorno; |
|
|
|
SOCKET dummy6; |
|
|
|
SOCKET dummy; |
|
|
|
WSAPROTOCOL_INFOW protocol_info; |
|
|
|
int opt_len; |
|
|
|
|
|
|
|
/* Initialize winsock */ |
|
|
|
errorno = WSAStartup(MAKEWORD(2, 2), &wsa_data); |
|
|
@ -92,11 +98,48 @@ void uv_winsock_init() { |
|
|
|
uv_addr_ip4_any_ = uv_ip4_addr("0.0.0.0", 0); |
|
|
|
uv_addr_ip6_any_ = uv_ip6_addr("::", 0); |
|
|
|
|
|
|
|
/* Detect IPV6 support */ |
|
|
|
dummy6 = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); |
|
|
|
if (dummy6 != INVALID_SOCKET) { |
|
|
|
/* Detect non-IFS LSPs */ |
|
|
|
dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); |
|
|
|
if (dummy == INVALID_SOCKET) { |
|
|
|
uv_fatal_error(WSAGetLastError(), "socket"); |
|
|
|
} |
|
|
|
|
|
|
|
opt_len = (int) sizeof protocol_info; |
|
|
|
if (!getsockopt(dummy, |
|
|
|
SOL_SOCKET, |
|
|
|
SO_PROTOCOL_INFOW, |
|
|
|
(char*) &protocol_info, |
|
|
|
&opt_len) == SOCKET_ERROR) { |
|
|
|
uv_fatal_error(WSAGetLastError(), "socket"); |
|
|
|
} |
|
|
|
|
|
|
|
if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) { |
|
|
|
uv_tcp_non_ifs_lsp_ipv4 = 1; |
|
|
|
} |
|
|
|
|
|
|
|
if (closesocket(dummy) == SOCKET_ERROR) { |
|
|
|
uv_fatal_error(WSAGetLastError(), "closesocket"); |
|
|
|
} |
|
|
|
|
|
|
|
/* Detect IPV6 support and non-IFS LSPs */ |
|
|
|
dummy = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); |
|
|
|
if (dummy != INVALID_SOCKET) { |
|
|
|
uv_allow_ipv6 = TRUE; |
|
|
|
if (closesocket(dummy6) == SOCKET_ERROR) { |
|
|
|
|
|
|
|
opt_len = (int) sizeof protocol_info; |
|
|
|
if (!getsockopt(dummy, |
|
|
|
SOL_SOCKET, |
|
|
|
SO_PROTOCOL_INFOW, |
|
|
|
(char*) &protocol_info, |
|
|
|
&opt_len) == SOCKET_ERROR) { |
|
|
|
uv_fatal_error(WSAGetLastError(), "socket"); |
|
|
|
} |
|
|
|
|
|
|
|
if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) { |
|
|
|
uv_tcp_non_ifs_lsp_ipv6 = 1; |
|
|
|
} |
|
|
|
|
|
|
|
if (closesocket(dummy) == SOCKET_ERROR) { |
|
|
|
uv_fatal_error(WSAGetLastError(), "closesocket"); |
|
|
|
} |
|
|
|
} |
|
|
|