summaryrefslogtreecommitdiff
path: root/lib/hostip6.c
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2016-06-07 18:11:37 +0800
committerDaniel Stenberg <daniel@haxx.se>2016-06-07 20:39:05 +0200
commit01a49a7626ee4a226cd0b50d70591ab147d60ee0 (patch)
treeef54a49ff290e8c432570d6dc081ebb6c56f420d /lib/hostip6.c
parent9b6d3a662ea81ec3bbb12002ca79fd27d750671e (diff)
downloadcurl-01a49a7626ee4a226cd0b50d70591ab147d60ee0.tar.gz
resolve: add support for IPv6 DNS64/NAT64 Networks on OS X + iOS
Use getaddrinfo() to resolve the IPv4 address literal on iOS/Mac OS X. If the current network interface doesn’t support IPv4, but supports IPv6, NAT64, and DNS64. Closes #866 Fixes #863
Diffstat (limited to 'lib/hostip6.c')
-rw-r--r--lib/hostip6.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/hostip6.c b/lib/hostip6.c
index 59bc4e4ac..9d401484a 100644
--- a/lib/hostip6.c
+++ b/lib/hostip6.c
@@ -167,7 +167,9 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
int error;
char sbuf[12];
char *sbufptr = NULL;
+#ifndef USE_RESOLVE_ON_IPS
char addrbuf[128];
+#endif
int pf;
#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
struct SessionHandle *data = conn->data;
@@ -196,11 +198,17 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
hints.ai_family = pf;
hints.ai_socktype = conn->socktype;
+#ifndef USE_RESOLVE_ON_IPS
+ /*
+ * The AI_NUMERICHOST must not be set to get synthesized IPv6 address from
+ * an IPv4 address on iOS and Mac OS X.
+ */
if((1 == Curl_inet_pton(AF_INET, hostname, addrbuf)) ||
(1 == Curl_inet_pton(AF_INET6, hostname, addrbuf))) {
/* the given address is numerical only, prevent a reverse lookup */
hints.ai_flags = AI_NUMERICHOST;
}
+#endif
if(port) {
snprintf(sbuf, sizeof(sbuf), "%d", port);
@@ -213,6 +221,10 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
return NULL;
}
+ if(port) {
+ Curl_addrinfo_set_port(res, port);
+ }
+
dump_addrinfo(conn, res);
return res;