diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-09-19 15:16:47 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-09-19 15:16:47 +0000 |
commit | 2297eca103307e077837951f33d06d08a19559d3 (patch) | |
tree | 1fbadc9140e25ffe53cebae88fdbb1e24f4bf744 | |
parent | 09ccfcdcd422fc0b0421562bbdcf53f78a3f3e4b (diff) |
Added CURLOPT_IPRESOLVE support
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | include/curl/curl.h | 15 | ||||
-rw-r--r-- | lib/hostip.c | 20 | ||||
-rw-r--r-- | lib/urldata.h | 2 |
4 files changed, 39 insertions, 3 deletions
@@ -8,6 +8,11 @@ Daniel (19 September) +- Added the CURLOPT_IPRESOLVE option, that allows an application to select + what kind of IP addresses he wants to use when resolving host names. This + is only interesting when using host names that resolve addresses using more + than one version of IP. + - Applied Markus Moeller's patch that introduces SPNEGO support if libcurl is built with the FBopenssl libraries. curl_version_info() now returns info on SPNEGO availability. The patch also made the GSSAPI stuff work fine diff --git a/include/curl/curl.h b/include/curl/curl.h index f78d8a84d..76ca1f8a8 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -678,15 +678,28 @@ typedef enum { Note that setting multiple bits may cause extra network round-trips. */ CINIT(PROXYAUTH, LONG, 111), - /* FPT Option that changes the timeout, in seconds, associated with + /* FTP option that changes the timeout, in seconds, associated with getting a response. This is different from transfer timeout time and essentially places a demand on the FTP server to acknowledge commands in a timely manner. */ CINIT(FTP_RESPONSE_TIMEOUT, LONG , 112), + /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to + tell libcurl to resolve names to those IP versions only. This only has + affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */ + CINIT(IPRESOLVE, LONG, 113), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; + /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host + name resolves addresses using more than one IP protocol version, this + option might be handy to force libcurl to use a specific IP version. */ +#define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP + versions that your system allows */ +#define CURL_IPRESOLVE_V4 1 /* resolve to ipv4 addresses */ +#define CURL_IPRESOLVE_V6 2 /* resolve to ipv6 addresses */ + /* two convenient "aliases" that follow the name scheme better */ #define CURLOPT_WRITEDATA CURLOPT_FILE #define CURLOPT_READDATA CURLOPT_INFILE 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; diff --git a/lib/urldata.h b/lib/urldata.h index 16c413d61..471049d51 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -826,6 +826,8 @@ struct UserDefined { char *private; /* Private data */ struct curl_slist *http200aliases; /* linked list of aliases for http200 */ + + int ip_version; /* Here follows boolean settings that define how to behave during this session. They are STATIC, set by libcurl users or at least initially |