From 6c503833279f9eef60e56a9b100fde410be893d6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 16:50:19 +0200 Subject: libreplace: split out network checks into a AC_LIBREPLACE_NETWORK_CHECKS macro Note: moving it out of AC_LIBREPLACE_BROKEN_CHECKS will be the next step metze (cherry picked from commit 55a904b1d7aeca849d450e371b18afca5b0c6218) (This used to be commit 2a3ddc23cc8d050dfe5b4e1c0e139a7c97cc3b59) --- source3/lib/replace/libreplace_network.m4 | 71 +++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 source3/lib/replace/libreplace_network.m4 (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 new file mode 100644 index 0000000000..7702702799 --- /dev/null +++ b/source3/lib/replace/libreplace_network.m4 @@ -0,0 +1,71 @@ +AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, +[ +echo "LIBREPLACE_NETWORK_CHECKS: START" + +AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) +AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) + +dnl we need to check that net/if.h really can be used, to cope with hpux +dnl where including it always fails +AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_INCLUDES_DEFAULT + #if HAVE_SYS_SOCKET_H + # include + #endif + #include + int main(void) {return 0;}])], + [libreplace_cv_USABLE_NET_IF_H=yes], + [libreplace_cv_USABLE_NET_IF_H=no] + ) +]) +if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then + AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) +fi + +AC_HAVE_TYPE([socklen_t],[#include ]) +AC_HAVE_TYPE([sa_family_t],[#include ]) +AC_HAVE_TYPE([struct addrinfo], [#include ]) +AC_HAVE_TYPE([struct sockaddr], [#include ]) +AC_HAVE_TYPE([struct sockaddr_storage], [ +#include +#include +#include +]) +AC_HAVE_TYPE([struct sockaddr_in6], [ +#include +#include +#include +]) + +if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, + AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, + [ +#include +#include +#include + ]) + +if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, + AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, + [ +#include +#include +#include + ]) +fi +fi + +m4_include(socket.m4) +m4_include(inet_ntop.m4) +m4_include(inet_pton.m4) +m4_include(inet_aton.m4) +m4_include(inet_ntoa.m4) +m4_include(getaddrinfo.m4) +m4_include(getifaddrs.m4) +m4_include(socketpair.m4) + +echo "LIBREPLACE_NETWORK_CHECKS: END" +]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From b76992d2622c178d28b486f92d27e0162b2e2ac8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 09:56:10 +0200 Subject: libreplace: merge socket.m4 into libreplace_network.m4 metze (cherry picked from commit c70eba87dbbac6c2c1e68c343cdd410577c1686f) (This used to be commit c48b2d8679dd139323936af68b48707c5a9f500c) --- source3/lib/replace/libreplace_network.m4 | 41 ++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 7702702799..209d418be6 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -58,7 +58,46 @@ AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, fi fi -m4_include(socket.m4) +dnl The following test is roughl taken from the cvs sources. +dnl +dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. +dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has +dnl libsocket.so which has a bad implementation of gethostbyname (it +dnl only looks in /etc/hosts), so we only look for -lsocket if we need +dnl it. +AC_CHECK_FUNCS(connect) +if test x"$ac_cv_func_connect" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect) + AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect) + dnl We can't just call AC_CHECK_FUNCS(connect) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" || + test x"$ac_cv_lib_ext_nsl_connect" = x"yes" || + test x"$ac_cv_lib_ext_socket_connect" = x"yes" || + test x"$ac_cv_lib_ext_inet_connect" = x"yes" + then + AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()]) + fi +fi + +AC_CHECK_FUNCS(gethostbyname) +if test x"$ac_cv_func_gethostbyname" = x"no"; then + AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname) + AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname) + dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" || + test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes" + then + AC_DEFINE(HAVE_GETHOSTBYNAME,1, + [Whether the system has gethostbyname()]) + fi +fi + m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(inet_aton.m4) -- cgit From cf7bdeaa2d639ff1dc19de6206a0e89947cb92be Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 09:58:07 +0200 Subject: libreplace: merge inet_ntoa.m4 into libreplace_network.m4 metze (cherry picked from commit 82e826253b6d18832931dbb5c1dda009889bf9e0) (This used to be commit 09632f9694599e626e889e54310383878c51413f) --- source3/lib/replace/libreplace_network.m4 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 209d418be6..35aa3ede7c 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -98,10 +98,29 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) + +AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ +AC_TRY_RUN([ +#include +#include +#include +#include +#ifdef HAVE_ARPA_INET_H +#include +#endif +main() { struct in_addr ip; ip.s_addr = 0x12345678; +if (strcmp(inet_ntoa(ip),"18.52.86.120") && + strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } +exit(1);}], + libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) +if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then + AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) +fi + m4_include(inet_ntop.m4) m4_include(inet_pton.m4) m4_include(inet_aton.m4) -m4_include(inet_ntoa.m4) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) m4_include(socketpair.m4) -- cgit From d1bfe04230cf3b976e59e1a798f55f653c89d293 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 09:59:16 +0200 Subject: libreplace: merge inet_aton.m4 into libreplace_network.m4 metze (cherry picked from commit fba00736c870f449c0eee32fe0d7b0d539dca51f) (This used to be commit 7669daa9f536b73a0b933a3d3fcac68c1771dc15) --- source3/lib/replace/libreplace_network.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 35aa3ede7c..66c8192a1e 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -118,9 +118,10 @@ if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) fi +AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) + m4_include(inet_ntop.m4) m4_include(inet_pton.m4) -m4_include(inet_aton.m4) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) m4_include(socketpair.m4) -- cgit From 09b0cd0e1f9bbfe8cb6eb8fdba2f11b3d77e3970 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:00:58 +0200 Subject: libreplace: merge inet_ntop.m4 into libreplace_network.m4 metze (cherry picked from commit 223ef6c08efb52251d0a772bb0c481b2803cf0ce) (This used to be commit 438ddd9c81e74e3042154cf5f0416043ee6a8c35) --- source3/lib/replace/libreplace_network.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 66c8192a1e..7ee7519e7e 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -120,7 +120,8 @@ fi AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) -m4_include(inet_ntop.m4) +AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) + m4_include(inet_pton.m4) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) -- cgit From d364bdb3004531a33f6bc71f8d4dddf33a3699dc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:02:21 +0200 Subject: libreplace: merge inet_pton.m4 into libreplace_network.m4 metze (cherry picked from commit 3a70274c908e31453942b442351eab8423c1a53d) (This used to be commit b078ae2b56c9a932655ef619a7af5ce0aeb904dd) --- source3/lib/replace/libreplace_network.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 7ee7519e7e..25ededb027 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -122,7 +122,8 @@ AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) -m4_include(inet_pton.m4) +AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) + m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) m4_include(socketpair.m4) -- cgit From 3f080815c9ff57eb863b012e6861db4dabb541ee Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:04:51 +0200 Subject: libreplace: merge socketpair.m4 into libreplace_network.m4 metze (cherry picked from commit f9f8f93adcc7161ebb18f5a0bf28c73d951a15ad) (This used to be commit 9aa0f6626d6a69ceeb8bb4ea71ea3d4a6157d101) --- source3/lib/replace/libreplace_network.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 25ededb027..87f6153e90 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -98,6 +98,8 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) + AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ @@ -126,7 +128,6 @@ AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) m4_include(getaddrinfo.m4) m4_include(getifaddrs.m4) -m4_include(socketpair.m4) echo "LIBREPLACE_NETWORK_CHECKS: END" ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From a4c24a7e8b0e31b754e684661bb050ab7926d9f3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:06:39 +0200 Subject: libreplace: merge getaddrinfo.m4 into libreplace_network.m4 metze (cherry picked from commit 64591d064dc3da6074f0f7539911a6e433d9cc43) (This used to be commit 2f43e282e0fa723dd62e3b28e529c6eb01ef5b8a) --- source3/lib/replace/libreplace_network.m4 | 34 ++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 87f6153e90..ff41056891 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -126,7 +126,39 @@ AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) -m4_include(getaddrinfo.m4) +dnl test for getaddrinfo/getnameinfo +AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ +AC_TRY_LINK([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include +#include ], +[ +struct sockaddr sa; +struct addrinfo *ai = NULL; +int ret = getaddrinfo(NULL, NULL, NULL, &ai); +if (ret != 0) { + const char *es = gai_strerror(ret); +} +freeaddrinfo(ai); +ret = getnameinfo(&sa, sizeof(sa), + NULL, 0, + NULL, 0, 0); + +], +libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)]) +if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then + AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo]) + AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo]) + AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) + AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) +else + LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" +fi + m4_include(getifaddrs.m4) echo "LIBREPLACE_NETWORK_CHECKS: END" -- cgit From a887473d3c9050348100d02cecc89c7fff2c8318 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:08:42 +0200 Subject: libreplace: merge getifaddrs.m4 into libreplace_network.m4 metze (cherry picked from commit 0234d397fefee8e1d0dcd3402f748c2251021c90) (This used to be commit d7038405d68eb3c69ef10f63ce37db838eb44b7a) --- source3/lib/replace/libreplace_network.m4 | 128 +++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index ff41056891..5ff699b36a 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -159,7 +159,133 @@ else LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" fi -m4_include(getifaddrs.m4) +AC_CHECK_HEADERS([ifaddrs.h]) + +dnl Used when getifaddrs is not available +AC_CHECK_MEMBERS([struct sockaddr.sa_len], + [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])], + [], + [#include ]) + +dnl test for getifaddrs and freeifaddrs +AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[ +AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include +#include +#include +#include +#include ], +[ +struct ifaddrs *ifp = NULL; +int ret = getifaddrs (&ifp); +freeifaddrs(ifp); +], +libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)]) +if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then + AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs]) + AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs]) + AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) +fi + +################## +# look for a method of finding the list of network interfaces +# +# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" +# +old_LIBS=$LIBS +LIBS="${LIBREPLACE_NETWORK_LIBS}" +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I$libreplacedir" +iface=no; +################## +# look for a method of finding the list of network interfaces +iface=no; +AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[ +AC_TRY_RUN([ +#define HAVE_IFACE_GETIFADDRS 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) +else + LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[ +AC_TRY_RUN([ +#define HAVE_IFACE_AIX 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#undef _XOPEN_SOURCE_EXTENDED +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) +fi +fi + + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFCONF 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available]) +fi +fi + +if test $iface = no; then +AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[ +AC_TRY_RUN([ +#define HAVE_IFACE_IFREQ 1 +#define NO_CONFIG_H 1 +#define AUTOCONF_TEST 1 +#define SOCKET_WRAPPER_NOT_REPLACE +#include "$libreplacedir/replace.c" +#include "$libreplacedir/inet_ntop.c" +#include "$libreplacedir/snprintf.c" +#include "$libreplacedir/getifaddrs.c" +#define getifaddrs_test main +#include "$libreplacedir/test/getifaddrs.c"], + libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)]) +if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available]) +fi +fi + +LIBS=$old_LIBS +CPPFLAGS="$SAVE_CPPFLAGS" echo "LIBREPLACE_NETWORK_CHECKS: END" ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From 2775d304d0e6e6350e37b503804110729133556b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:27:23 +0200 Subject: libreplace: include inet_ntoa.o when the system one is broken metze (cherry picked from commit 67845d3471711d24069636d0d4032f9d53748334) (This used to be commit 734ade407ed8d5b61a831509c3efc90fc521fe1b) --- source3/lib/replace/libreplace_network.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 5ff699b36a..6d10313e47 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -100,8 +100,6 @@ fi AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) -AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"]) - AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ #include @@ -116,8 +114,11 @@ if (strcmp(inet_ntoa(ip),"18.52.86.120") && strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } exit(1);}], libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)]) + +AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes]) if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) + LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o" fi AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) -- cgit From 9eefcfd42fa6a77551d64565e943f211cd8bf7a3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:32:19 +0200 Subject: libreplace: export LIBREPLACE_NETWORK_OBJS and LIBREPLACE_NETWORK_LIBS vars metze (cherry picked from commit aa7ef1af746319a3d771decd0ec03dabe8b8ad28) (This used to be commit dbbc05c87ba2b2d9b3247cfba58bc1a3f12ad4f5) --- source3/lib/replace/libreplace_network.m4 | 35 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 6d10313e47..f1657d9f79 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -2,6 +2,9 @@ AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, [ echo "LIBREPLACE_NETWORK_CHECKS: START" +LIBREPLACE_NETWORK_OBJS="" +LIBREPLACE_NETWORK_LIBS="" + AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) @@ -98,7 +101,13 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi -AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"]) +# The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" +old_LIBS=$LIBS +LIBS="${LIBREPLACE_NETWORK_LIBS}" +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS -I$libreplacedir" + +AC_CHECK_FUNCS(socketpair,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} socketpair.o"]) AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[ AC_TRY_RUN([ @@ -118,14 +127,14 @@ exit(1);}], AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes]) if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced]) - LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o" + LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntoa.o" fi -AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"]) +AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_aton.o"]) -AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"]) +AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntop.o"]) -AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"]) +AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_pton.o"]) dnl test for getaddrinfo/getnameinfo AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[ @@ -157,7 +166,7 @@ if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo]) AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror]) else - LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o" + LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getaddrinfo.o" fi AC_CHECK_HEADERS([ifaddrs.h]) @@ -193,16 +202,6 @@ if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available]) fi -################## -# look for a method of finding the list of network interfaces -# -# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" -# -old_LIBS=$LIBS -LIBS="${LIBREPLACE_NETWORK_LIBS}" -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I$libreplacedir" -iface=no; ################## # look for a method of finding the list of network interfaces iface=no; @@ -222,7 +221,7 @@ AC_TRY_RUN([ if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) else - LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o" + LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getifaddrs.o" fi @@ -288,5 +287,7 @@ fi LIBS=$old_LIBS CPPFLAGS="$SAVE_CPPFLAGS" +LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}" + echo "LIBREPLACE_NETWORK_CHECKS: END" ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From 107ed5fe0c51abeb4def8f8e2cc041b3f16061ad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 10:39:41 +0200 Subject: libreplace: make sure system/network.h is only used when AC_LIBREPLACE_NETWORK_CHECKS was used metze (cherry picked from commit 3fddd36e119f73a5021370450f9687ef9d252bab) (This used to be commit cd37fdb2401bfd6c23160e34f03238faa1f5cbd3) --- source3/lib/replace/libreplace_network.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index f1657d9f79..56c603a155 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -2,6 +2,7 @@ AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, [ echo "LIBREPLACE_NETWORK_CHECKS: START" +AC_DEFINE(LIBREPLACE_NETWORK_CHECKS, 1, [LIBREPLACE_NETWORK_CHECKS were used]) LIBREPLACE_NETWORK_OBJS="" LIBREPLACE_NETWORK_LIBS="" -- cgit From a4cb989e4897118aaf306bf87d6716a233886972 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 8 May 2008 11:01:09 +0200 Subject: libreplace: try to fix the build on HP-UX which has if_nametoindex() in -lipv6 metze (cherry picked from commit da2179ee5d5b6094ab63a9d9d6a8d59893937087) (This used to be commit 151d62da1321322615daadabb41d049974f5fe6a) --- source3/lib/replace/libreplace_network.m4 | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 56c603a155..5ab71f160a 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -102,6 +102,19 @@ if test x"$ac_cv_func_gethostbyname" = x"no"; then fi fi +dnl HP-UX has if_nametoindex in -lipv6 +AC_CHECK_FUNCS(if_nametoindex) +if test x"$ac_cv_func_if_nametoindex" = x"no"; then + AC_CHECK_LIB_EXT(ipv6, LIBREPLACE_NETWORK_LIBS, if_nametoindex) + dnl We can't just call AC_CHECK_FUNCS(if_nametoindex) here, + dnl because the value has been cached. + if test x"$ac_cv_lib_ext_ipv6_if_nametoindex" = x"yes" + then + AC_DEFINE(HAVE_IF_NAMETOINDEX, 1, + [Whether the system has if_nametoindex()]) + fi +fi + # The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}" old_LIBS=$LIBS LIBS="${LIBREPLACE_NETWORK_LIBS}" -- cgit From 84e9d52d4486444b5022078b157f59efa61c25d3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 May 2008 12:29:21 +0200 Subject: lib/replace: add checks for HAVE_SOCK_SIN_LEN and HAVE_UNIXSOCKET Moved from the samba specific locations metze (cherry picked from commit e674128ee2f11596f358ed46104c9d25eb2f754f) (This used to be commit 951b8c757ada337229a4efe81e6532d15fa0b63a) --- source3/lib/replace/libreplace_network.m4 | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 5ab71f160a..d29c13196d 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -62,6 +62,46 @@ AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, fi fi +AC_CACHE_CHECK([for sin_len in sock],libreplace_cv_HAVE_SOCK_SIN_LEN,[ + AC_TRY_COMPILE( + [ +#include +#include +#include + ],[ +struct sockaddr_in sock; sock.sin_len = sizeof(sock); + ],[ + libreplace_cv_HAVE_SOCK_SIN_LEN=yes + ],[ + libreplace_cv_HAVE_SOCK_SIN_LEN=no + ]) +]) +if test x"$libreplace_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then + AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property]) +fi + +############################################ +# check for unix domain sockets +AC_CACHE_CHECK([for unix domain sockets],libreplace_cv_HAVE_UNIXSOCKET,[ + AC_TRY_COMPILE([ +#include +#include +#include +#include +#include + ],[ +struct sockaddr_un sunaddr; +sunaddr.sun_family = AF_UNIX; + ],[ + libreplace_cv_HAVE_UNIXSOCKET=yes + ],[ + libreplace_cv_HAVE_UNIXSOCKET=no + ]) +]) +if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then + AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support]) +fi + dnl The following test is roughl taken from the cvs sources. dnl dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet. -- cgit From 7bff7f433e864a21cae8df814394d13848f0c885 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 May 2008 12:46:10 +0200 Subject: lib/replace: move sys/sockio.h and sys/un.h checks into AC_LIBREPLACE_NETWORK_CHECKS metze (cherry picked from commit 7f26a5425e706a97cc07c5139b3fea4fde9e4020) (This used to be commit c97ff995e41d1cd31a7169e95ca415078da4a16c) --- source3/lib/replace/libreplace_network.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index d29c13196d..f2d177b165 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -8,6 +8,7 @@ LIBREPLACE_NETWORK_LIBS="" AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) +AC_CHECK_HEADERS(sys/sockio.h sys/un.h) dnl we need to check that net/if.h really can be used, to cope with hpux dnl where including it always fails -- cgit From 5797e33b8171ee77762ea96dae7744f4bda255ee Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 21 May 2008 21:27:45 +0200 Subject: libreplace: add test for HAVE_IPV6 Samba can later just check libreplace_cv_HAVE_IPV6 = yes. metze (cherry picked from commit e835e7eebcc064ce0813814796828f15ad112fbd) (This used to be commit 1ca4508f3a996982a528942da1b12b94b91e94cd) --- source3/lib/replace/libreplace_network.m4 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index f2d177b165..6cde6b9e0c 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -339,6 +339,35 @@ if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then fi fi +dnl test for ipv6 +AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[ + AC_TRY_COMPILE([ +#include /* for NULL */ +#include +#include +#include + ], + [ +struct sockaddr_storage sa_store; +struct addrinfo *ai = NULL; +struct in6_addr in6addr; +int idx = if_nametoindex("iface1"); +int s = socket(AF_INET6, SOCK_STREAM, 0); +int ret = getaddrinfo(NULL, NULL, NULL, &ai); +if (ret != 0) { + const char *es = gai_strerror(ret); +} +freeaddrinfo(ai); + ],[ + libreplace_cv_HAVE_IPV6=yes + ],[ + libreplace_cv_HAVE_IPV6=no + ]) +]) +if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then + AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support]) +fi + LIBS=$old_LIBS CPPFLAGS="$SAVE_CPPFLAGS" -- cgit From b54f34bb3321d3318189549df712ae1618dd71ca Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 May 2008 15:00:19 +0200 Subject: libreplace: we need to use AC_TRY_LINK() to make sure HAVE_IPV6 is correctly detected metze (cherry picked from commit 84b5652d3e5766521436e4c7d59615b08b2bb198) (This used to be commit b28b63c911efe17ba37c15c9b74edd96e9584832) --- source3/lib/replace/libreplace_network.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/replace/libreplace_network.m4') diff --git a/source3/lib/replace/libreplace_network.m4 b/source3/lib/replace/libreplace_network.m4 index 6cde6b9e0c..4edb55c03a 100644 --- a/source3/lib/replace/libreplace_network.m4 +++ b/source3/lib/replace/libreplace_network.m4 @@ -341,7 +341,7 @@ fi dnl test for ipv6 AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[ - AC_TRY_COMPILE([ + AC_TRY_LINK([ #include /* for NULL */ #include #include -- cgit