summaryrefslogtreecommitdiff
path: root/lib/hostip.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-09-19 15:16:47 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-09-19 15:16:47 +0000
commit2297eca103307e077837951f33d06d08a19559d3 (patch)
tree1fbadc9140e25ffe53cebae88fdbb1e24f4bf744 /lib/hostip.c
parent09ccfcdcd422fc0b0421562bbdcf53f78a3f3e4b (diff)
downloadcurl-2297eca103307e077837951f33d06d08a19559d3.tar.gz
Added CURLOPT_IPRESOLVE support
Diffstat (limited to 'lib/hostip.c')
-rw-r--r--lib/hostip.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index 3f465a0d0..1a881cf9b 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -653,7 +653,7 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
struct addrinfo hints, *res;
int error;
char sbuf[NI_MAXSERV];
- int s, pf = PF_UNSPEC;
+ int s, pf;
struct SessionHandle *data = conn->data;
*waitp=0; /* don't wait, we have the response now */
@@ -665,11 +665,27 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
* the stack seems to be a non-ipv6 one. */
pf = PF_INET;
- else
+ else {
/* This seems to be an IPv6-capable stack, use PF_UNSPEC for the widest
* possible checks. And close the socket again.
*/
sclose(s);
+
+ /*
+ * Check if a more limited name resolve has been requested.
+ */
+ switch(data->set.ip_version) {
+ case CURL_IPRESOLVE_V4:
+ pf = PF_INET;
+ break;
+ case CURL_IPRESOLVE_V6:
+ pf = PF_INET6;
+ break;
+ default:
+ pf = PF_UNSPEC;
+ break;
+ }
+ }
memset(&hints, 0, sizeof(hints));
hints.ai_family = pf;