mirror of
https://frontier.innolan.net/rainlance/c-ares.git
synced 2025-11-20 00:35:00 +00:00
configure: inet_net_pton function check adjustments
Define HAVE_INET_NET_PTON only when system's inet_net_pton function is IPv6 capable and is not affected by the WLB-2008080064 advisory. HAVE_INET_NET_PTON_IPV6 is no longer defined nor used.
This commit is contained in:
1
CHANGES
1
CHANGES
@ -7,6 +7,7 @@ Changed:
|
||||
Fixed:
|
||||
|
||||
o detection of semicolon comments in resolv.conf
|
||||
o avoid using system's inet_net_pton affected by the WLB-2008080064 advisory
|
||||
|
||||
Version 1.7.4 (December 9, 2010)
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ Changed:
|
||||
Fixed:
|
||||
|
||||
o detection of semicolon comments in resolv.conf
|
||||
o avoid using system's inet_net_pton affected by the WLB-2008080064 advisory
|
||||
|
||||
Thanks go to these friendly people for their efforts and contributions:
|
||||
|
||||
|
||||
32
configure.ac
32
configure.ac
@ -532,6 +532,7 @@ CARES_CHECK_FUNC_GETHOSTBYADDR
|
||||
CARES_CHECK_FUNC_GETHOSTBYNAME
|
||||
CARES_CHECK_FUNC_GETHOSTNAME
|
||||
CARES_CHECK_FUNC_GETSERVBYPORT_R
|
||||
CARES_CHECK_FUNC_INET_NET_PTON
|
||||
CARES_CHECK_FUNC_INET_NTOP
|
||||
CARES_CHECK_FUNC_INET_PTON
|
||||
CARES_CHECK_FUNC_IOCTL
|
||||
@ -738,37 +739,6 @@ AC_CHECK_FUNCS([bitncmp \
|
||||
])
|
||||
|
||||
|
||||
dnl Check for inet_net_pton
|
||||
AC_CHECK_FUNCS(inet_net_pton)
|
||||
dnl Again, some systems have it, but not IPv6
|
||||
if test "$ac_cv_func_inet_net_pton" = "yes" ; then
|
||||
AC_MSG_CHECKING(if inet_net_pton supports IPv6)
|
||||
AC_TRY_RUN(
|
||||
[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
int main()
|
||||
{
|
||||
struct in6_addr addr6;
|
||||
if (inet_net_pton(AF_INET6, "::1", &addr6, sizeof(addr6)) < 1)
|
||||
exit(1);
|
||||
else
|
||||
exit(0);
|
||||
}
|
||||
], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON_IPV6,1,[Define to 1 if inet_net_pton supports IPv6.])
|
||||
], AC_MSG_RESULT(no),AC_MSG_RESULT(no))
|
||||
fi
|
||||
|
||||
|
||||
AC_CHECK_SIZEOF(struct in6_addr, ,
|
||||
[
|
||||
#undef inline
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
|
||||
|
||||
|
||||
#if !defined(HAVE_INET_NET_PTON) || !defined(HAVE_INET_NET_PTON_IPV6)
|
||||
#ifndef HAVE_INET_NET_PTON
|
||||
|
||||
/*
|
||||
* static int
|
||||
@ -425,7 +425,7 @@ ares_inet_net_pton(int af, const char *src, void *dst, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* HAVE_INET_NET_PTON */
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
int ares_inet_pton(int af, const char *src, void *dst)
|
||||
@ -447,4 +447,4 @@ int ares_inet_pton(int af, const char *src, void *dst)
|
||||
return 0;
|
||||
return (result > -1 ? 1 : -1);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_INET_PTON */
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
#ifndef __ARES_INET_NET_PTON_H
|
||||
#define __ARES_INET_NET_PTON_H
|
||||
#ifndef HEADER_CARES_INET_NET_PTON_H
|
||||
#define HEADER_CARES_INET_NET_PTON_H
|
||||
|
||||
|
||||
/* Copyright (C) 2005 by Daniel Stenberg
|
||||
/* Copyright (C) 2005-2010 by Daniel Stenberg et al
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@ -22,10 +21,11 @@
|
||||
#else
|
||||
int ares_inet_pton(int af, const char *src, void *dst);
|
||||
#endif
|
||||
#if defined(HAVE_INET_NET_PTON) && defined(HAVE_INET_NET_PTON_IPV6)
|
||||
|
||||
#ifdef HAVE_INET_NET_PTON
|
||||
#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z)
|
||||
#else
|
||||
int ares_inet_net_pton(int af, const char *src, void *dst, size_t size);
|
||||
#endif
|
||||
|
||||
#endif /* __ARES_INET_NET_PTON_H */
|
||||
#endif /* HEADER_CARES_INET_NET_PTON_H */
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#***************************************************************************
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (C) 2008 - 2009 by Daniel Stenberg et al
|
||||
# Copyright (C) 2008 - 2010 by Daniel Stenberg et al
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software and its
|
||||
# documentation for any purpose and without fee is hereby granted, provided
|
||||
@ -16,7 +15,7 @@
|
||||
#***************************************************************************
|
||||
|
||||
# File version for 'aclocal' use. Keep it a single number.
|
||||
# serial 39
|
||||
# serial 40
|
||||
|
||||
|
||||
dnl CARES_INCLUDES_ARPA_INET
|
||||
@ -1507,6 +1506,232 @@ AC_DEFUN([CARES_CHECK_FUNC_GETSERVBYPORT_R], [
|
||||
])
|
||||
|
||||
|
||||
dnl CARES_CHECK_FUNC_INET_NET_PTON
|
||||
dnl -------------------------------------------------
|
||||
dnl Verify if inet_net_pton is available, prototyped, can
|
||||
dnl be compiled and seems to work. If all of these are
|
||||
dnl true, and usage has not been previously disallowed
|
||||
dnl with shell variable cares_disallow_inet_net_pton, then
|
||||
dnl HAVE_INET_NET_PTON will be defined.
|
||||
|
||||
AC_DEFUN([CARES_CHECK_FUNC_INET_NET_PTON], [
|
||||
AC_REQUIRE([CARES_INCLUDES_STDLIB])dnl
|
||||
AC_REQUIRE([CARES_INCLUDES_ARPA_INET])dnl
|
||||
AC_REQUIRE([CARES_INCLUDES_STRING])dnl
|
||||
#
|
||||
tst_links_inet_net_pton="unknown"
|
||||
tst_proto_inet_net_pton="unknown"
|
||||
tst_compi_inet_net_pton="unknown"
|
||||
tst_works_inet_net_pton="unknown"
|
||||
tst_allow_inet_net_pton="unknown"
|
||||
#
|
||||
AC_MSG_CHECKING([if inet_net_pton can be linked])
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_FUNC_LINK_TRY([inet_net_pton])
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
tst_links_inet_net_pton="yes"
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
tst_links_inet_net_pton="no"
|
||||
])
|
||||
#
|
||||
if test "$tst_links_inet_net_pton" = "yes"; then
|
||||
AC_MSG_CHECKING([if inet_net_pton is prototyped])
|
||||
AC_EGREP_CPP([inet_net_pton],[
|
||||
$cares_includes_arpa_inet
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
tst_proto_inet_net_pton="yes"
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
tst_proto_inet_net_pton="no"
|
||||
])
|
||||
fi
|
||||
#
|
||||
if test "$tst_proto_inet_net_pton" = "yes"; then
|
||||
AC_MSG_CHECKING([if inet_net_pton is compilable])
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
$cares_includes_arpa_inet
|
||||
]],[[
|
||||
if(0 != inet_net_pton(0, 0, 0, 0))
|
||||
return 1;
|
||||
]])
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
tst_compi_inet_net_pton="yes"
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
tst_compi_inet_net_pton="no"
|
||||
])
|
||||
fi
|
||||
#
|
||||
dnl only do runtime verification when not cross-compiling
|
||||
if test "x$cross_compiling" != "xyes" &&
|
||||
test "$tst_compi_inet_net_pton" = "yes"; then
|
||||
AC_MSG_CHECKING([if inet_net_pton seems to work])
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
$cares_includes_stdlib
|
||||
$cares_includes_arpa_inet
|
||||
$cares_includes_string
|
||||
]],[[
|
||||
unsigned char ipv6a[16+1];
|
||||
unsigned char ipv4a[4+1];
|
||||
const char *ipv6net1 = "fe80::214:4fff:fe0b:76c8";
|
||||
const char *ipv6net2 = "::fffe:7f00:1";
|
||||
const char *ipv6net3 = "7f20:1::/64";
|
||||
const char *ipv6net4 = "7f20:1::/2147483649";
|
||||
const char *ipv4net1 = "192.168.100.1";
|
||||
const char *ipv4net2 = "192.168.100/32";
|
||||
const char *ipv4net3 = "192.168.100.1/2147483649";
|
||||
/* - */
|
||||
memset(ipv4a, 1, sizeof(ipv4a));
|
||||
if(32 != inet_net_pton(AF_INET, ipv4net1, ipv4a, 4))
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
if( (ipv4a[0x00] != 0xc0) ||
|
||||
(ipv4a[0x01] != 0xa8) ||
|
||||
(ipv4a[0x02] != 0x64) ||
|
||||
(ipv4a[0x03] != 0x01) ||
|
||||
(ipv4a[0x04] != 0x01) )
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
memset(ipv4a, 1, sizeof(ipv4a));
|
||||
if(32 != inet_net_pton(AF_INET, ipv4net2, ipv4a, 4))
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
if( (ipv4a[0x00] != 0xc0) ||
|
||||
(ipv4a[0x01] != 0xa8) ||
|
||||
(ipv4a[0x02] != 0x64) ||
|
||||
(ipv4a[0x03] != 0x00) ||
|
||||
(ipv4a[0x04] != 0x01) )
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
memset(ipv4a, 1, sizeof(ipv4a));
|
||||
if(-1 != inet_net_pton(AF_INET, ipv4net3, ipv4a, 4))
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
memset(ipv6a, 1, sizeof(ipv6a));
|
||||
if(128 != inet_net_pton(AF_INET6, ipv6net1, ipv6a, 16))
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
if( (ipv6a[0x00] != 0xfe) ||
|
||||
(ipv6a[0x01] != 0x80) ||
|
||||
(ipv6a[0x08] != 0x02) ||
|
||||
(ipv6a[0x09] != 0x14) ||
|
||||
(ipv6a[0x0a] != 0x4f) ||
|
||||
(ipv6a[0x0b] != 0xff) ||
|
||||
(ipv6a[0x0c] != 0xfe) ||
|
||||
(ipv6a[0x0d] != 0x0b) ||
|
||||
(ipv6a[0x0e] != 0x76) ||
|
||||
(ipv6a[0x0f] != 0xc8) ||
|
||||
(ipv6a[0x10] != 0x01) )
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
if( (ipv6a[0x02] != 0x0) ||
|
||||
(ipv6a[0x03] != 0x0) ||
|
||||
(ipv6a[0x04] != 0x0) ||
|
||||
(ipv6a[0x05] != 0x0) ||
|
||||
(ipv6a[0x06] != 0x0) ||
|
||||
(ipv6a[0x07] != 0x0) )
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
memset(ipv6a, 0, sizeof(ipv6a));
|
||||
ipv6a[0x10] = 0x01;
|
||||
if(128 != inet_net_pton(AF_INET6, ipv6net2, ipv6a, 16))
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
if( (ipv6a[0x0a] != 0xff) ||
|
||||
(ipv6a[0x0b] != 0xfe) ||
|
||||
(ipv6a[0x0c] != 0x7f) ||
|
||||
(ipv6a[0x0f] != 0x01) ||
|
||||
(ipv6a[0x10] != 0x01) )
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
if( (ipv6a[0x00] != 0x0) ||
|
||||
(ipv6a[0x01] != 0x0) ||
|
||||
(ipv6a[0x02] != 0x0) ||
|
||||
(ipv6a[0x03] != 0x0) ||
|
||||
(ipv6a[0x04] != 0x0) ||
|
||||
(ipv6a[0x05] != 0x0) ||
|
||||
(ipv6a[0x06] != 0x0) ||
|
||||
(ipv6a[0x07] != 0x0) ||
|
||||
(ipv6a[0x08] != 0x0) ||
|
||||
(ipv6a[0x09] != 0x0) ||
|
||||
(ipv6a[0x0d] != 0x0) ||
|
||||
(ipv6a[0x0e] != 0x0) )
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
memset(ipv6a, 1, sizeof(ipv6a));
|
||||
if(64 != inet_net_pton(AF_INET6, ipv6net3, ipv6a, 16))
|
||||
exit(1); /* fail */
|
||||
if( (ipv6a[0x00] != 0x7f) ||
|
||||
(ipv6a[0x01] != 0x20) ||
|
||||
(ipv6a[0x03] != 0x01) ||
|
||||
(ipv6a[0x08] != 0x01) ||
|
||||
(ipv6a[0x09] != 0x01) ||
|
||||
(ipv6a[0x0a] != 0x01) ||
|
||||
(ipv6a[0x0b] != 0x01) ||
|
||||
(ipv6a[0x0c] != 0x01) ||
|
||||
(ipv6a[0x0d] != 0x01) ||
|
||||
(ipv6a[0x0e] != 0x01) ||
|
||||
(ipv6a[0x0f] != 0x01) ||
|
||||
(ipv6a[0x10] != 0x01) )
|
||||
exit(1); /* fail */
|
||||
if( (ipv6a[0x02] != 0x0) ||
|
||||
(ipv6a[0x04] != 0x0) ||
|
||||
(ipv6a[0x05] != 0x0) ||
|
||||
(ipv6a[0x06] != 0x0) ||
|
||||
(ipv6a[0x07] != 0x0) ||
|
||||
(ipv6a[0x07] != 0x0) )
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
memset(ipv6a, 1, sizeof(ipv6a));
|
||||
if(-1 != inet_net_pton(AF_INET6, ipv6net4, ipv6a, 16))
|
||||
exit(1); /* fail */
|
||||
/* - */
|
||||
exit(0);
|
||||
]])
|
||||
],[
|
||||
AC_MSG_RESULT([yes])
|
||||
tst_works_inet_net_pton="yes"
|
||||
],[
|
||||
AC_MSG_RESULT([no])
|
||||
tst_works_inet_net_pton="no"
|
||||
])
|
||||
fi
|
||||
#
|
||||
if test "$tst_compi_inet_net_pton" = "yes" &&
|
||||
test "$tst_works_inet_net_pton" != "no"; then
|
||||
AC_MSG_CHECKING([if inet_net_pton usage allowed])
|
||||
if test "x$cares_disallow_inet_net_pton" != "xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
tst_allow_inet_net_pton="yes"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
tst_allow_inet_net_pton="no"
|
||||
fi
|
||||
fi
|
||||
#
|
||||
AC_MSG_CHECKING([if inet_net_pton might be used])
|
||||
if test "$tst_links_inet_net_pton" = "yes" &&
|
||||
test "$tst_proto_inet_net_pton" = "yes" &&
|
||||
test "$tst_compi_inet_net_pton" = "yes" &&
|
||||
test "$tst_allow_inet_net_pton" = "yes" &&
|
||||
test "$tst_works_inet_net_pton" != "no"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE_UNQUOTED(HAVE_INET_NET_PTON, 1,
|
||||
[Define to 1 if you have a IPv6 capable working inet_net_pton function.])
|
||||
ac_cv_func_inet_net_pton="yes"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
ac_cv_func_inet_net_pton="no"
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl CARES_CHECK_FUNC_INET_NTOP
|
||||
dnl -------------------------------------------------
|
||||
dnl Verify if inet_ntop is available, prototyped, can
|
||||
|
||||
Reference in New Issue
Block a user