From d4ff5e9688d3ef90e727bcff53217bc990538a10 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 27 Apr 2010 23:33:17 +0000 Subject: [PATCH] Make the Autoconf check for PF_PACKET support Linux-specific. Recent versions of OpenSolaris (I tested snv_134) also support PF_PACKET, but not in an entirely compatible way. The configure check was making the build use eth-linux.c, which doesn't compile under OpenSolaris. This change makes OpenSolaris fall back to eth-dlpi.c, which works. The report about this was sent by Darren Reed. --- libdnet-stripped/NMAP_MODIFICATIONS | 35 ++++++++++++++ libdnet-stripped/config/acinclude.m4 | 18 +++++--- libdnet-stripped/configure | 69 ++++++++++++++++++++++++---- 3 files changed, 107 insertions(+), 15 deletions(-) diff --git a/libdnet-stripped/NMAP_MODIFICATIONS b/libdnet-stripped/NMAP_MODIFICATIONS index 45d735b96..076a47f95 100644 --- a/libdnet-stripped/NMAP_MODIFICATIONS +++ b/libdnet-stripped/NMAP_MODIFICATIONS @@ -253,6 +253,41 @@ Index: src/eth-dlpi.c return (eth_close(e)); } +o Made the Autoconf check for PF_PACKET Linux-specific. Recent versions + of OpenSolaris also support PF_PACKET, but the code in eth-linux.c + only works under Linux. + +Index: config/acinclude.m4 +=================================================================== +--- config/acinclude.m4 (revision 17391) ++++ config/acinclude.m4 (working copy) +@@ -135,14 +135,18 @@ + dnl usage: AC_DNET_LINUX_PF_PACKET + dnl results: HAVE_LINUX_PF_PACKET + dnl ++dnl This is a Linux-specific check, even though other operating systems ++dnl (OpenSolaris) may have the PF_PACKET interface. The eth-linux.c code ++dnl activated by this check is specific to Linux. + AC_DEFUN(AC_DNET_LINUX_PF_PACKET, +- [AC_MSG_CHECKING(for Linux PF_PACKET sockets) +- AC_CACHE_VAL(ac_cv_dnet_linux_pf_packet, +- if test -f /usr/include/netpacket/packet.h ; then +- ac_cv_dnet_linux_pf_packet=yes +- else +- ac_cv_dnet_linux_pf_packet=no +- fi) ++ [AC_CHECK_DECL([ETH_P_ALL], ++ ac_cv_dnet_linux_pf_packet=yes, ++ ac_cv_dnet_linux_pf_packet=no, ++ [ ++#include ++#include ++]) ++ AC_MSG_CHECKING(for Linux PF_PACKET sockets) + AC_MSG_RESULT($ac_cv_dnet_linux_pf_packet) + if test $ac_cv_dnet_linux_pf_packet = yes ; then + AC_DEFINE(HAVE_LINUX_PF_PACKET, 1, + ===CHANGES ALREADY MERGED TO UPSTREAM LIBDNET GO BELOW THIS LINE=== o Made some code changes to intf.c (the patch below). This does the following: diff --git a/libdnet-stripped/config/acinclude.m4 b/libdnet-stripped/config/acinclude.m4 index c54710b74..3b6c0fb6e 100644 --- a/libdnet-stripped/config/acinclude.m4 +++ b/libdnet-stripped/config/acinclude.m4 @@ -135,14 +135,18 @@ dnl dnl usage: AC_DNET_LINUX_PF_PACKET dnl results: HAVE_LINUX_PF_PACKET dnl +dnl This is a Linux-specific check, even though other operating systems +dnl (OpenSolaris) may have the PF_PACKET interface. The eth-linux.c code +dnl activated by this check is specific to Linux. AC_DEFUN(AC_DNET_LINUX_PF_PACKET, - [AC_MSG_CHECKING(for Linux PF_PACKET sockets) - AC_CACHE_VAL(ac_cv_dnet_linux_pf_packet, - if test -f /usr/include/netpacket/packet.h ; then - ac_cv_dnet_linux_pf_packet=yes - else - ac_cv_dnet_linux_pf_packet=no - fi) + [AC_CHECK_DECL([ETH_P_ALL], + ac_cv_dnet_linux_pf_packet=yes, + ac_cv_dnet_linux_pf_packet=no, + [ +#include +#include +]) + AC_MSG_CHECKING(for Linux PF_PACKET sockets) AC_MSG_RESULT($ac_cv_dnet_linux_pf_packet) if test $ac_cv_dnet_linux_pf_packet = yes ; then AC_DEFINE(HAVE_LINUX_PF_PACKET, 1, diff --git a/libdnet-stripped/configure b/libdnet-stripped/configure index 9ded8cd99..c496ef2b4 100755 --- a/libdnet-stripped/configure +++ b/libdnet-stripped/configure @@ -14378,18 +14378,71 @@ cat >>confdefs.h <<\_ACEOF _ACEOF fi - { $as_echo "$as_me:$LINENO: checking for Linux PF_PACKET sockets" >&5 -$as_echo_n "checking for Linux PF_PACKET sockets... " >&6; } - if test "${ac_cv_dnet_linux_pf_packet+set}" = set; then + { $as_echo "$as_me:$LINENO: checking whether ETH_P_ALL is declared" >&5 +$as_echo_n "checking whether ETH_P_ALL is declared... " >&6; } +if test "${ac_cv_have_decl_ETH_P_ALL+set}" = set; then $as_echo_n "(cached) " >&6 else - if test -f /usr/include/netpacket/packet.h ; then - ac_cv_dnet_linux_pf_packet=yes - else - ac_cv_dnet_linux_pf_packet=no - fi + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include + + +int +main () +{ +#ifndef ETH_P_ALL + (void) ETH_P_ALL; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_ETH_P_ALL=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_ETH_P_ALL=no fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_ETH_P_ALL" >&5 +$as_echo "$ac_cv_have_decl_ETH_P_ALL" >&6; } +if test "x$ac_cv_have_decl_ETH_P_ALL" = x""yes; then + ac_cv_dnet_linux_pf_packet=yes +else + ac_cv_dnet_linux_pf_packet=no +fi + + { $as_echo "$as_me:$LINENO: checking for Linux PF_PACKET sockets" >&5 +$as_echo_n "checking for Linux PF_PACKET sockets... " >&6; } { $as_echo "$as_me:$LINENO: result: $ac_cv_dnet_linux_pf_packet" >&5 $as_echo "$ac_cv_dnet_linux_pf_packet" >&6; } if test $ac_cv_dnet_linux_pf_packet = yes ; then