]> sjero.net Git - wget/commitdiff
[svn] IPv6 configure auto-detection.
authorhniksic <devnull@localhost>
Tue, 9 Sep 2003 19:30:45 +0000 (12:30 -0700)
committerhniksic <devnull@localhost>
Tue, 9 Sep 2003 19:30:45 +0000 (12:30 -0700)
ChangeLog
aclocal.m4
configure.in
src/ChangeLog
src/config.h.in
src/connect.c
src/ftp-basic.c
src/ftp.h
src/host.c
src/host.h
src/url.c

index 5a666a25dfca2803cb4a428d8fc76a659286cc08..402a5440da0f7080f42489fe029fc52897f46165 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-09-09  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * configure.in, aclocal.m4: Added configure check for IPv6 and
+       getaddrinfo.  From Daniel Stenberg.
+
 2003-09-05  Maciej W. Rozycki  <macro@ds2.pg.gda.pl>
 
        * configure.in: Additional M4 quoting.
index 3406e42e91b89b32492538e715fd02d09eb8797c..c0e40bdb01ae919deb20cb9403c0b4a4d20c8625 100644 (file)
@@ -86,6 +86,47 @@ else
   AC_MSG_RESULT(no)
 fi])
 
+dnl ************************************************************
+dnl check for working getaddrinfo()
+dnl
+AC_DEFUN(WGET_CHECK_WORKING_GETADDRINFO,[
+  AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
+  AC_TRY_RUN( [
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int main(void) {
+    struct addrinfo hints, *ai;
+    int error;
+
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+    error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
+    if (error) {
+        exit(1);
+    }
+    else {
+        exit(0);
+    }
+}
+],[
+  ac_cv_working_getaddrinfo="yes"
+],[
+  ac_cv_working_getaddrinfo="no"
+],[
+  ac_cv_working_getaddrinfo="yes"
+])])
+if test x"$ac_cv_working_getaddrinfo" = xyes; then
+  AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
+  AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
+
+  IPV6_ENABLED=1
+  AC_SUBST(IPV6_ENABLED)
+fi
+])
+
 \f
 # This code originates from Ulrich Drepper's AM_WITH_NLS.
 
index 2166cc5de7b89e267f3f5f3e139e346e3bf3e5ed..55555b27cd19af11a95bb79ed68ff722aa9ddea9 100644 (file)
@@ -30,7 +30,7 @@ dnl Process this file with autoconf to produce a configure script.
 dnl
 
 AC_INIT(src/version.c)
-AC_PREREQ(2.12)
+AC_PREREQ(2.50)
 AC_CONFIG_HEADER(src/config.h)
 
 dnl
@@ -155,7 +155,6 @@ AC_C_CONST
 AC_C_INLINE
 AC_TYPE_SIZE_T
 AC_TYPE_PID_T
-dnl #### This generates a warning.  What do I do to shut it up?
 AC_C_BIGENDIAN
 
 # Check size of long.
@@ -442,6 +441,55 @@ fi
 AC_DEFINE(HAVE_MD5)
 AC_SUBST(MD5_OBJ)
 
+dnl **********************************************************************
+dnl Checks for IPv6
+dnl **********************************************************************
+
+dnl
+dnl If --enable-ipv6 is specified, we try to use IPv6 (as long as
+dnl getaddrinfo is also present).  If --disable-ipv6 is specified, we
+dnl don't use IPv6 or getaddrinfo.  If neither are specified, we test
+dnl whether it's possible to create an AF_INET6 socket and if yes, use
+dnl IPv6.
+dnl
+
+AC_MSG_CHECKING([whether to enable ipv6])
+AC_ARG_ENABLE(ipv6,
+AC_HELP_STRING([--enable-ipv6],[Enable ipv6 support])
+AC_HELP_STRING([--disable-ipv6],[Disable ipv6 support]),
+[ case "$enableval" in
+  no)
+       AC_MSG_RESULT(no)
+       ipv6=no
+       ;;
+  *)   AC_MSG_RESULT(yes)
+       ipv6=yes
+       ;;
+  esac ],
+
+  AC_TRY_RUN([ /* is AF_INET6 available? */
+#include <sys/types.h>
+#include <sys/socket.h>
+main()
+{
+ if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
+   exit(1);
+ else
+   exit(0);
+}
+],
+  AC_MSG_RESULT(yes)
+  ipv6=yes,
+  AC_MSG_RESULT(no)
+  ipv6=no,
+  AC_MSG_RESULT(no)
+  ipv6=no
+))
+
+if test x"$ipv6" = xyes; then
+  WGET_CHECK_WORKING_GETADDRINFO
+fi
+
 dnl
 dnl Set of available languages.
 dnl
index 15affbcabe5079189e133cdc5ce822759f0eabcd..73201fb79535054b0291d320bcb73630253b51e7 100644 (file)
@@ -1,3 +1,10 @@
+2003-09-09  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * config.h.in: Initialize HAVE_GETADDRINFO and ENABLE_IPV6.
+
+       * all: Use #ifdef ENABLE_IPV6 instead of the older INET6.  Use
+       HAVE_GETADDRINFO for getaddrinfo-related stuff.
+
 2003-09-09  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * url.c (url_parse): Return an error if the URL contains a [...]
index dc5f37cb46040707413fb877038b394c4e98abd8..0ee23e38b37cc902a09ff7ba46c11e85167721db 100644 (file)
@@ -250,6 +250,12 @@ char *alloca ();
 /* Define if we're using builtin (GNU) md5.c.  */
 #undef HAVE_BUILTIN_MD5
 
+/* Define if you have the getaddrinfo function.  */
+#undef HAVE_GETADDRINFO
+
+/* Define if you want to enable the IPv6 support.  */
+#undef ENABLE_IPV6
+
 /* First a gambit to see whether we're on Solaris.  We'll
    need it below.  */
 #ifdef __sun
index 8db283998ead7ec8eaf7a2208ff8266558dabe96..99f0909d1c6d711fd3bbc136a09f9ab983855ac7 100644 (file)
@@ -412,7 +412,7 @@ conaddr (int fd, ip_address *ip)
 
   switch (mysrv.sa.sa_family)
     {
-#ifdef INET6
+#ifdef ENABLE_IPV6
     case AF_INET6:
       memcpy (ip, &mysrv.sin6.sin6_addr, 16);
       return 1;
index dd868a3a94db224bc0cb924805c17208e24c2402..5ba09527e9ac7ba4744f09a83d0d6370db03f697 100644 (file)
@@ -252,7 +252,7 @@ ftp_login (struct rbuf *rbuf, const char *acc, const char *pass)
   return FTPOK;
 }
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
 uerr_t
 ftp_eprt (struct rbuf *rbuf)
 {
@@ -324,7 +324,7 @@ ftp_port (struct rbuf *rbuf)
 
   int nwritten;
   unsigned short port;
-#ifdef INET6
+#ifdef ENABLE_IPV6
   /*
     Only try the Extented Version if we actually use IPv6
   */
@@ -382,7 +382,7 @@ ftp_port (struct rbuf *rbuf)
   return FTPOK;
 }
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
 uerr_t
 ftp_epsv (struct rbuf *rbuf, ip_address *addr, unsigned short *port, 
          char *typ)
@@ -453,7 +453,7 @@ ftp_pasv (struct rbuf *rbuf, ip_address *addr, unsigned short *port)
   uerr_t err;
   unsigned char addr4[4];
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
   if (ip_default_family == AF_INET6) 
     {
       err = ftp_epsv (rbuf, addr, port, "2");  /* try IPv6 with EPSV */
index e2c657a6b6a6ed9d23efc801cffec3868ab97791..ad49cc82b6045f2fc9d826440477beba96ad7dcc 100644 (file)
--- a/src/ftp.h
+++ b/src/ftp.h
@@ -49,7 +49,7 @@ uerr_t ftp_response PARAMS ((struct rbuf *, char **));
 uerr_t ftp_login PARAMS ((struct rbuf *, const char *, const char *));
 uerr_t ftp_port PARAMS ((struct rbuf *));
 uerr_t ftp_pasv PARAMS ((struct rbuf *, ip_address *, unsigned short *));
-#ifdef INET6
+#ifdef ENABLE_IPV6
 uerr_t ftp_epsv PARAMS ((struct rbuf *, ip_address *, unsigned short *,
                         char *));
 #endif
index 5000a2026d71b09a42c7cdaea993d1b515a3370c..382707db4f4d151029e9e85b69326b246769ec01 100644 (file)
@@ -81,7 +81,7 @@ extern int h_errno;
 # endif
 #endif
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
 int     ip_default_family = AF_INET6;
 #else
 int     ip_default_family = AF_INET;
@@ -153,7 +153,7 @@ address_list_set_faulty (struct address_list *al, int index)
     al->faulty = 0;
 }
 
-#ifdef INET6
+#ifdef HAVE_GETADDRINFO
 /**
   * address_list_from_addrinfo
   *
@@ -296,7 +296,7 @@ wget_sockaddr_set_address (wget_sockaddr *sa,
        }
       return;
     }
-#ifdef INET6
+#ifdef ENABLE_IPV6
   if (ip_family == AF_INET6) 
     {
       sa->sin6.sin6_family = ip_family;
@@ -336,7 +336,7 @@ wget_sockaddr_set_port (wget_sockaddr *sa, unsigned short port)
       sa->sin.sin_port = htons (port);
       return;
     }  
-#ifdef INET6
+#ifdef ENABLE_IPV6
   if (sa->sa.sa_family == AF_INET6)
     {
       sa->sin6.sin6_port = htons (port);
@@ -366,7 +366,7 @@ wget_sockaddr_get_addr (wget_sockaddr *sa)
 { 
   if (sa->sa.sa_family == AF_INET)
     return &sa->sin.sin_addr;
-#ifdef INET6
+#ifdef ENABLE_IPV6
   if (sa->sa.sa_family == AF_INET6)
     return &sa->sin6.sin6_addr;
 #endif
@@ -395,7 +395,7 @@ wget_sockaddr_get_port (const wget_sockaddr *sa)
 {
   if (sa->sa.sa_family == AF_INET)
       return htons (sa->sin.sin_port);
-#ifdef INET6
+#ifdef ENABLE_IPV6
   if (sa->sa.sa_family == AF_INET6)
       return htons (sa->sin6.sin6_port);
 #endif
@@ -425,7 +425,7 @@ sockaddr_len ()
 {
   if (ip_default_family == AF_INET) 
     return sizeof (struct sockaddr_in);
-#ifdef INET6
+#ifdef ENABLE_IPV6
   if (ip_default_family == AF_INET6) 
     return sizeof (struct sockaddr_in6);
 #endif
@@ -440,7 +440,7 @@ sockaddr_len ()
 void 
 map_ipv4_to_ip (ip4_address *ipv4, ip_address *ip) 
 {
-#ifdef INET6
+#ifdef ENABLE_IPV6
   static unsigned char ipv64[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff};
   memcpy ((char *)ip + 12, ipv4 , 4);
   memcpy ((char *)ip + 0, ipv64, 12);
@@ -458,7 +458,7 @@ map_ipv4_to_ip (ip4_address *ipv4, ip_address *ip)
 int 
 map_ip_to_ipv4 (ip_address *ip, ip4_address *ipv4) 
 {
-#ifdef INET6
+#ifdef ENABLE_IPV6
   static unsigned char ipv64[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff};
   if (0 != memcmp (ip, ipv64, 12))
     return 0;
@@ -473,7 +473,7 @@ map_ip_to_ipv4 (ip_address *ip, ip4_address *ipv4)
 \f
 /* Versions of gethostbyname and getaddrinfo that support timeout. */
 
-#ifndef INET6
+#ifndef ENABLE_IPV6
 
 struct ghbnwt_context {
   const char *host_name;
@@ -508,7 +508,7 @@ gethostbyname_with_timeout (const char *host_name, int timeout)
   return ctx.hptr;
 }
 
-#else  /* INET6 */
+#else  /* ENABLE_IPV6 */
 
 struct gaiwt_context {
   const char *node;
@@ -548,7 +548,7 @@ getaddrinfo_with_timeout (const char *node, const char *service,
   return ctx.exit_code;
 }
 
-#endif /* INET6 */
+#endif /* ENABLE_IPV6 */
 \f
 /* Pretty-print ADDR.  When compiled without IPv6, this is the same as
    inet_ntoa.  With IPv6, it either prints an IPv6 address or an IPv4
@@ -557,7 +557,7 @@ getaddrinfo_with_timeout (const char *node, const char *service,
 char *
 pretty_print_address (ip_address *addr)
 {
-#ifdef INET6
+#ifdef ENABLE_IPV6
   ip4_address addr4;
   static char buf[128];
 
@@ -606,7 +606,7 @@ lookup_host (const char *host, int silent)
   /* First, try to check whether the address is already a numeric
      address.  */
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
   if (inet_pton (AF_INET6, host, &addr) > 0)
     return address_list_new_one (&addr);
 #endif
@@ -644,7 +644,7 @@ lookup_host (const char *host, int silent)
 
   /* Host name lookup goes on below. */
 
-#ifdef INET6
+#ifdef HAVE_GETADDRINFO
   {
     struct addrinfo hints, *ai;
     int err;
index 0fa922a1f8c41371160eebdef3feee274d616a9b..3688bd8b0f8959be3afc27d1a1b27a73450ba945 100644 (file)
@@ -41,8 +41,6 @@ so, delete this exception statement from your version.  */
 #endif
 #endif
 
-#undef INET6
-
 struct url;
 struct address_list;
 
@@ -52,7 +50,7 @@ struct address_list;
 typedef union {
        struct sockaddr     sa;   /* Generic but too small */
        struct sockaddr_in  sin;  /* IPv4 socket address */
-#ifdef INET6
+#ifdef ENABLE_IPV6
        struct sockaddr_in6 sin6; /* IPv6 socket address */
 #endif
 } wget_sockaddr;
@@ -65,7 +63,7 @@ typedef struct {
    addresses as IPv6 addresses.  IPv4 addresses are dynamically mapped
    to IPv6, i.e. stored in the format ::ffff:<Ipv4>.  */
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
 # define MAX_IP_ADDRESS_SIZE 16
 #else
 # define MAX_IP_ADDRESS_SIZE 4
index 5435f9bc0709ab12801d3deeefa50fcb07588323..eac1cfdd193a44556777910221501e10436ba521 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -660,7 +660,7 @@ static char *parse_errors[] = {
     *(p) = (v);                                        \
 } while (0)
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
 /* The following two functions were adapted from glibc. */
 
 static int
@@ -863,7 +863,7 @@ url_parse (const char *url, int *error)
          return NULL;
        }
 
-#ifdef INET6
+#ifdef ENABLE_IPV6
       /* Check if the IPv6 address is valid. */
       if (!is_valid_ipv6_address(host_b, host_e))
        {