+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.
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.
dnl
AC_INIT(src/version.c)
-AC_PREREQ(2.12)
+AC_PREREQ(2.50)
AC_CONFIG_HEADER(src/config.h)
dnl
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.
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
+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 [...]
/* 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
switch (mysrv.sa.sa_family)
{
-#ifdef INET6
+#ifdef ENABLE_IPV6
case AF_INET6:
memcpy (ip, &mysrv.sin6.sin6_addr, 16);
return 1;
return FTPOK;
}
-#ifdef INET6
+#ifdef ENABLE_IPV6
uerr_t
ftp_eprt (struct rbuf *rbuf)
{
int nwritten;
unsigned short port;
-#ifdef INET6
+#ifdef ENABLE_IPV6
/*
Only try the Extented Version if we actually use IPv6
*/
return FTPOK;
}
-#ifdef INET6
+#ifdef ENABLE_IPV6
uerr_t
ftp_epsv (struct rbuf *rbuf, ip_address *addr, unsigned short *port,
char *typ)
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 */
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
# endif
#endif
-#ifdef INET6
+#ifdef ENABLE_IPV6
int ip_default_family = AF_INET6;
#else
int ip_default_family = AF_INET;
al->faulty = 0;
}
-#ifdef INET6
+#ifdef HAVE_GETADDRINFO
/**
* address_list_from_addrinfo
*
}
return;
}
-#ifdef INET6
+#ifdef ENABLE_IPV6
if (ip_family == AF_INET6)
{
sa->sin6.sin6_family = ip_family;
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);
{
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
{
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
{
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
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);
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;
\f
/* Versions of gethostbyname and getaddrinfo that support timeout. */
-#ifndef INET6
+#ifndef ENABLE_IPV6
struct ghbnwt_context {
const char *host_name;
return ctx.hptr;
}
-#else /* INET6 */
+#else /* ENABLE_IPV6 */
struct gaiwt_context {
const char *node;
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
char *
pretty_print_address (ip_address *addr)
{
-#ifdef INET6
+#ifdef ENABLE_IPV6
ip4_address addr4;
static char buf[128];
/* 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
/* Host name lookup goes on below. */
-#ifdef INET6
+#ifdef HAVE_GETADDRINFO
{
struct addrinfo hints, *ai;
int err;
#endif
#endif
-#undef INET6
-
struct url;
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;
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
*(p) = (v); \
} while (0)
-#ifdef INET6
+#ifdef ENABLE_IPV6
/* The following two functions were adapted from glibc. */
static int
return NULL;
}
-#ifdef INET6
+#ifdef ENABLE_IPV6
/* Check if the IPv6 address is valid. */
if (!is_valid_ipv6_address(host_b, host_e))
{