1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] IPv6 configure auto-detection.

This commit is contained in:
hniksic 2003-09-09 12:30:45 -07:00
parent 0e9b4de751
commit cd8b1259f1
11 changed files with 134 additions and 29 deletions

View File

@ -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> 2003-09-05 Maciej W. Rozycki <macro@ds2.pg.gda.pl>
* configure.in: Additional M4 quoting. * configure.in: Additional M4 quoting.

41
aclocal.m4 vendored
View File

@ -86,6 +86,47 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi]) 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
])
# This code originates from Ulrich Drepper's AM_WITH_NLS. # This code originates from Ulrich Drepper's AM_WITH_NLS.

View File

@ -30,7 +30,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl dnl
AC_INIT(src/version.c) AC_INIT(src/version.c)
AC_PREREQ(2.12) AC_PREREQ(2.50)
AC_CONFIG_HEADER(src/config.h) AC_CONFIG_HEADER(src/config.h)
dnl dnl
@ -155,7 +155,6 @@ AC_C_CONST
AC_C_INLINE AC_C_INLINE
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_TYPE_PID_T AC_TYPE_PID_T
dnl #### This generates a warning. What do I do to shut it up?
AC_C_BIGENDIAN AC_C_BIGENDIAN
# Check size of long. # Check size of long.
@ -442,6 +441,55 @@ fi
AC_DEFINE(HAVE_MD5) AC_DEFINE(HAVE_MD5)
AC_SUBST(MD5_OBJ) 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
dnl Set of available languages. dnl Set of available languages.
dnl dnl

View 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> 2003-09-09 Hrvoje Niksic <hniksic@xemacs.org>
* url.c (url_parse): Return an error if the URL contains a [...] * url.c (url_parse): Return an error if the URL contains a [...]

View File

@ -250,6 +250,12 @@ char *alloca ();
/* Define if we're using builtin (GNU) md5.c. */ /* Define if we're using builtin (GNU) md5.c. */
#undef HAVE_BUILTIN_MD5 #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 /* First a gambit to see whether we're on Solaris. We'll
need it below. */ need it below. */
#ifdef __sun #ifdef __sun

View File

@ -412,7 +412,7 @@ conaddr (int fd, ip_address *ip)
switch (mysrv.sa.sa_family) switch (mysrv.sa.sa_family)
{ {
#ifdef INET6 #ifdef ENABLE_IPV6
case AF_INET6: case AF_INET6:
memcpy (ip, &mysrv.sin6.sin6_addr, 16); memcpy (ip, &mysrv.sin6.sin6_addr, 16);
return 1; return 1;

View File

@ -252,7 +252,7 @@ ftp_login (struct rbuf *rbuf, const char *acc, const char *pass)
return FTPOK; return FTPOK;
} }
#ifdef INET6 #ifdef ENABLE_IPV6
uerr_t uerr_t
ftp_eprt (struct rbuf *rbuf) ftp_eprt (struct rbuf *rbuf)
{ {
@ -324,7 +324,7 @@ ftp_port (struct rbuf *rbuf)
int nwritten; int nwritten;
unsigned short port; unsigned short port;
#ifdef INET6 #ifdef ENABLE_IPV6
/* /*
Only try the Extented Version if we actually use IPv6 Only try the Extented Version if we actually use IPv6
*/ */
@ -382,7 +382,7 @@ ftp_port (struct rbuf *rbuf)
return FTPOK; return FTPOK;
} }
#ifdef INET6 #ifdef ENABLE_IPV6
uerr_t uerr_t
ftp_epsv (struct rbuf *rbuf, ip_address *addr, unsigned short *port, ftp_epsv (struct rbuf *rbuf, ip_address *addr, unsigned short *port,
char *typ) char *typ)
@ -453,7 +453,7 @@ ftp_pasv (struct rbuf *rbuf, ip_address *addr, unsigned short *port)
uerr_t err; uerr_t err;
unsigned char addr4[4]; unsigned char addr4[4];
#ifdef INET6 #ifdef ENABLE_IPV6
if (ip_default_family == AF_INET6) if (ip_default_family == AF_INET6)
{ {
err = ftp_epsv (rbuf, addr, port, "2"); /* try IPv6 with EPSV */ err = ftp_epsv (rbuf, addr, port, "2"); /* try IPv6 with EPSV */

View File

@ -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_login PARAMS ((struct rbuf *, const char *, const char *));
uerr_t ftp_port PARAMS ((struct rbuf *)); uerr_t ftp_port PARAMS ((struct rbuf *));
uerr_t ftp_pasv PARAMS ((struct rbuf *, ip_address *, unsigned short *)); 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 *, uerr_t ftp_epsv PARAMS ((struct rbuf *, ip_address *, unsigned short *,
char *)); char *));
#endif #endif

View File

@ -81,7 +81,7 @@ extern int h_errno;
# endif # endif
#endif #endif
#ifdef INET6 #ifdef ENABLE_IPV6
int ip_default_family = AF_INET6; int ip_default_family = AF_INET6;
#else #else
int ip_default_family = AF_INET; int ip_default_family = AF_INET;
@ -153,7 +153,7 @@ address_list_set_faulty (struct address_list *al, int index)
al->faulty = 0; al->faulty = 0;
} }
#ifdef INET6 #ifdef HAVE_GETADDRINFO
/** /**
* address_list_from_addrinfo * address_list_from_addrinfo
* *
@ -296,7 +296,7 @@ wget_sockaddr_set_address (wget_sockaddr *sa,
} }
return; return;
} }
#ifdef INET6 #ifdef ENABLE_IPV6
if (ip_family == AF_INET6) if (ip_family == AF_INET6)
{ {
sa->sin6.sin6_family = ip_family; 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); sa->sin.sin_port = htons (port);
return; return;
} }
#ifdef INET6 #ifdef ENABLE_IPV6
if (sa->sa.sa_family == AF_INET6) if (sa->sa.sa_family == AF_INET6)
{ {
sa->sin6.sin6_port = htons (port); sa->sin6.sin6_port = htons (port);
@ -366,7 +366,7 @@ wget_sockaddr_get_addr (wget_sockaddr *sa)
{ {
if (sa->sa.sa_family == AF_INET) if (sa->sa.sa_family == AF_INET)
return &sa->sin.sin_addr; return &sa->sin.sin_addr;
#ifdef INET6 #ifdef ENABLE_IPV6
if (sa->sa.sa_family == AF_INET6) if (sa->sa.sa_family == AF_INET6)
return &sa->sin6.sin6_addr; return &sa->sin6.sin6_addr;
#endif #endif
@ -395,7 +395,7 @@ wget_sockaddr_get_port (const wget_sockaddr *sa)
{ {
if (sa->sa.sa_family == AF_INET) if (sa->sa.sa_family == AF_INET)
return htons (sa->sin.sin_port); return htons (sa->sin.sin_port);
#ifdef INET6 #ifdef ENABLE_IPV6
if (sa->sa.sa_family == AF_INET6) if (sa->sa.sa_family == AF_INET6)
return htons (sa->sin6.sin6_port); return htons (sa->sin6.sin6_port);
#endif #endif
@ -425,7 +425,7 @@ sockaddr_len ()
{ {
if (ip_default_family == AF_INET) if (ip_default_family == AF_INET)
return sizeof (struct sockaddr_in); return sizeof (struct sockaddr_in);
#ifdef INET6 #ifdef ENABLE_IPV6
if (ip_default_family == AF_INET6) if (ip_default_family == AF_INET6)
return sizeof (struct sockaddr_in6); return sizeof (struct sockaddr_in6);
#endif #endif
@ -440,7 +440,7 @@ sockaddr_len ()
void void
map_ipv4_to_ip (ip4_address *ipv4, ip_address *ip) 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}; 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 + 12, ipv4 , 4);
memcpy ((char *)ip + 0, ipv64, 12); memcpy ((char *)ip + 0, ipv64, 12);
@ -458,7 +458,7 @@ map_ipv4_to_ip (ip4_address *ipv4, ip_address *ip)
int int
map_ip_to_ipv4 (ip_address *ip, ip4_address *ipv4) 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}; static unsigned char ipv64[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff};
if (0 != memcmp (ip, ipv64, 12)) if (0 != memcmp (ip, ipv64, 12))
return 0; return 0;
@ -473,7 +473,7 @@ map_ip_to_ipv4 (ip_address *ip, ip4_address *ipv4)
/* Versions of gethostbyname and getaddrinfo that support timeout. */ /* Versions of gethostbyname and getaddrinfo that support timeout. */
#ifndef INET6 #ifndef ENABLE_IPV6
struct ghbnwt_context { struct ghbnwt_context {
const char *host_name; const char *host_name;
@ -508,7 +508,7 @@ gethostbyname_with_timeout (const char *host_name, int timeout)
return ctx.hptr; return ctx.hptr;
} }
#else /* INET6 */ #else /* ENABLE_IPV6 */
struct gaiwt_context { struct gaiwt_context {
const char *node; const char *node;
@ -548,7 +548,7 @@ getaddrinfo_with_timeout (const char *node, const char *service,
return ctx.exit_code; return ctx.exit_code;
} }
#endif /* INET6 */ #endif /* ENABLE_IPV6 */
/* Pretty-print ADDR. When compiled without IPv6, this is the same as /* 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 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 * char *
pretty_print_address (ip_address *addr) pretty_print_address (ip_address *addr)
{ {
#ifdef INET6 #ifdef ENABLE_IPV6
ip4_address addr4; ip4_address addr4;
static char buf[128]; 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 /* First, try to check whether the address is already a numeric
address. */ address. */
#ifdef INET6 #ifdef ENABLE_IPV6
if (inet_pton (AF_INET6, host, &addr) > 0) if (inet_pton (AF_INET6, host, &addr) > 0)
return address_list_new_one (&addr); return address_list_new_one (&addr);
#endif #endif
@ -644,7 +644,7 @@ lookup_host (const char *host, int silent)
/* Host name lookup goes on below. */ /* Host name lookup goes on below. */
#ifdef INET6 #ifdef HAVE_GETADDRINFO
{ {
struct addrinfo hints, *ai; struct addrinfo hints, *ai;
int err; int err;

View File

@ -41,8 +41,6 @@ so, delete this exception statement from your version. */
#endif #endif
#endif #endif
#undef INET6
struct url; struct url;
struct address_list; struct address_list;
@ -52,7 +50,7 @@ struct address_list;
typedef union { typedef union {
struct sockaddr sa; /* Generic but too small */ struct sockaddr sa; /* Generic but too small */
struct sockaddr_in sin; /* IPv4 socket address */ struct sockaddr_in sin; /* IPv4 socket address */
#ifdef INET6 #ifdef ENABLE_IPV6
struct sockaddr_in6 sin6; /* IPv6 socket address */ struct sockaddr_in6 sin6; /* IPv6 socket address */
#endif #endif
} wget_sockaddr; } wget_sockaddr;
@ -65,7 +63,7 @@ typedef struct {
addresses as IPv6 addresses. IPv4 addresses are dynamically mapped addresses as IPv6 addresses. IPv4 addresses are dynamically mapped
to IPv6, i.e. stored in the format ::ffff:<Ipv4>. */ to IPv6, i.e. stored in the format ::ffff:<Ipv4>. */
#ifdef INET6 #ifdef ENABLE_IPV6
# define MAX_IP_ADDRESS_SIZE 16 # define MAX_IP_ADDRESS_SIZE 16
#else #else
# define MAX_IP_ADDRESS_SIZE 4 # define MAX_IP_ADDRESS_SIZE 4

View File

@ -660,7 +660,7 @@ static char *parse_errors[] = {
*(p) = (v); \ *(p) = (v); \
} while (0) } while (0)
#ifdef INET6 #ifdef ENABLE_IPV6
/* The following two functions were adapted from glibc. */ /* The following two functions were adapted from glibc. */
static int static int
@ -863,7 +863,7 @@ url_parse (const char *url, int *error)
return NULL; return NULL;
} }
#ifdef INET6 #ifdef ENABLE_IPV6
/* Check if the IPv6 address is valid. */ /* Check if the IPv6 address is valid. */
if (!is_valid_ipv6_address(host_b, host_e)) if (!is_valid_ipv6_address(host_b, host_e))
{ {