]> granicus.if.org Git - curl/commitdiff
Added CURLOPT_IPRESOLVE support
authorDaniel Stenberg <daniel@haxx.se>
Fri, 19 Sep 2003 15:16:47 +0000 (15:16 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 19 Sep 2003 15:16:47 +0000 (15:16 +0000)
CHANGES
include/curl/curl.h
lib/hostip.c
lib/urldata.h

diff --git a/CHANGES b/CHANGES
index f35d2a1f4c53482e5be6c7beeb9d7f50de89ae57..a6ded52e82d387b235e37f63f2780d2d26142153 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index f78d8a84d73b4c634fcc445d13db534cf30fb8c6..76ca1f8a85b3f333c23d160ebf0dccad5a5b0e26 100644 (file)
@@ -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 
index 3f465a0d05151ec451baea0fd3a0b9161c5c8ba3..1a881cf9bf5f520ca56dd0215e6a8210097cdc65 100644 (file)
@@ -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;
index 16c413d610f0f69971ef71c4a40949c77f1693ea..471049d517651ac344850344a4fdb2e493c301e7 100644 (file)
@@ -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