mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
Subject: [PATCH] fixed not to use IPv4-mapped address for IPv6 only node
Since IPv6 only node can not connect with IPv4-mapped address.
This commit is contained in:
parent
cb0cbfaec1
commit
4fee9de6bc
1 changed files with 2 additions and 10 deletions
|
@ -63,6 +63,8 @@ lws_client_connect_2(struct lws_context *context, struct lws *wsi)
|
|||
#ifdef LWS_USE_IPV6
|
||||
if (LWS_IPV6_ENABLED(context)) {
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_INET6;
|
||||
hints.ai_flags = AI_V4MAPPED;
|
||||
n = getaddrinfo(ads, NULL, &hints, &result);
|
||||
if (n) {
|
||||
#ifdef _WIN32
|
||||
|
@ -75,16 +77,6 @@ lws_client_connect_2(struct lws_context *context, struct lws *wsi)
|
|||
|
||||
server_addr6.sin6_family = AF_INET6;
|
||||
switch (result->ai_family) {
|
||||
case AF_INET:
|
||||
/* map IPv4 to IPv6 */
|
||||
bzero((char *)&server_addr6.sin6_addr,
|
||||
sizeof(struct in6_addr));
|
||||
server_addr6.sin6_addr.s6_addr[10] = 0xff;
|
||||
server_addr6.sin6_addr.s6_addr[11] = 0xff;
|
||||
memcpy(&server_addr6.sin6_addr.s6_addr[12],
|
||||
&((struct sockaddr_in *)result->ai_addr)->sin_addr,
|
||||
sizeof(struct in_addr));
|
||||
break;
|
||||
case AF_INET6:
|
||||
memcpy(&server_addr6.sin6_addr,
|
||||
&((struct sockaddr_in6 *)result->ai_addr)->sin6_addr,
|
||||
|
|
Loading…
Add table
Reference in a new issue