From 4fee9de6bc79cf11b1eed37bfe904ab8799e5a03 Mon Sep 17 00:00:00 2001 From: Yusuke Ishiguro Date: Wed, 9 Dec 2015 19:24:44 +0900 Subject: [PATCH] Subject: [PATCH] fixed not to use IPv4-mapped address for IPv6 only node Since IPv6 only node can not connect with IPv4-mapped address. --- lib/client-handshake.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/client-handshake.c b/lib/client-handshake.c index 9e4bd764..bfda3c04 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -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,