diff --git a/acinclude.m4 b/acinclude.m4 index 491769a5f..6a192ea24 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -87,27 +87,6 @@ int main() { [AC_MSG_RESULT(cross-compiling -- assuming yes); $3]) ]) -dnl Checks if PCAP_NETMASK_UNKNOWN is defined (has been since libpcap 1.1.1) -dnl Sets it to 0 (no checking) if it's not defined. -AC_DEFUN([PCAP_DEFINE_NETMASK_UNKNOWN], -[ - AC_MSG_CHECKING(if PCAP_NETMASK_UNKNOWN is defined/handled by libpcap) - AC_CACHE_VAL(ac_cv_have_pcap_netmask_unknown, - AC_TRY_COMPILE( - [ - #include - ], - [ - int i = PCAP_NETMASK_UNKNOWN; - ], - ac_cv_have_pcap_netmask_unknown=yes, - ac_cv_have_pcap_netmask_unknown=no)) - if test $ac_cv_have_pcap_netmask_unknown = no; then - AC_DEFINE(PCAP_NETMASK_UNKNOWN, 0, [Possibly using libpcap prior to 1.1.0.]) - fi - AC_MSG_RESULT($ac_cv_have_pcap_netmask_unknown) -]) - dnl Checks if IPPROTO_RAW induces IP_HDRINCL-like behavior in AF_INET6 sockets. dnl Defines HAVE_IPV6_IPPROTO_RAW if so. So far I only know this happens on dnl Linux. diff --git a/configure b/configure index 79a10e770..9df1bc28a 100755 --- a/configure +++ b/configure @@ -6380,43 +6380,7 @@ else # link with -lpcap for the purposes of this test LIBS_OLD="$LIBS" LIBS="$LIBS -lpcap" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if PCAP_NETMASK_UNKNOWN is defined/handled by libpcap" >&5 -$as_echo_n "checking if PCAP_NETMASK_UNKNOWN is defined/handled by libpcap... " >&6; } - if ${ac_cv_have_pcap_netmask_unknown+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - -int -main () -{ - - int i = PCAP_NETMASK_UNKNOWN; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_have_pcap_netmask_unknown=yes -else - ac_cv_have_pcap_netmask_unknown=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - if test $ac_cv_have_pcap_netmask_unknown = no; then - -$as_echo "#define PCAP_NETMASK_UNKNOWN 0" >>confdefs.h - - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_pcap_netmask_unknown" >&5 -$as_echo "$ac_cv_have_pcap_netmask_unknown" >&6; } - + PCAP_DEFINE_NETMASK_UNKNOWN for ac_func in pcap_set_immediate_mode do : ac_fn_c_check_func "$LINENO" "pcap_set_immediate_mode" "ac_cv_func_pcap_set_immediate_mode" diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index 8e082424c..2527ea296 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -206,6 +206,11 @@ #define NBASE_MAX_ERR_STR_LEN 1024 /* Max length of an error message */ +#ifndef PCAP_NETMASK_UNKNOWN +/* libpcap before 1.1.1 (e.g. WinPcap) doesn't handle this specially, so just use 0 netmask */ +#define PCAP_NETMASK_UNKNOWN 0 +#endif + /** Print fatal error messages to stderr and then exits. A newline character is printed automatically after the supplied text. * @warning This function does not return because it calls exit() */ diff --git a/nmap_config.h.in b/nmap_config.h.in index 524ff7437..ead0007d8 100644 --- a/nmap_config.h.in +++ b/nmap_config.h.in @@ -254,7 +254,6 @@ extern "C" int gethostname (char *, unsigned int); #undef MACOSX #undef HAVE_IPV6_IPPROTO_RAW -#undef PCAP_NETMASK_UNKNOWN #undef HAVE_PCAP_SET_IMMEDIATE_MODE /* Various possibilities for lua.h */ diff --git a/nse_pcrelib.cc b/nse_pcrelib.cc index adc52c68f..9f6a72dc0 100644 --- a/nse_pcrelib.cc +++ b/nse_pcrelib.cc @@ -11,8 +11,7 @@ #include -#include "nbase.h" -#include "nmap_error.h" +#include #ifdef HAVE_PCRE_PCRE_H # include diff --git a/nsock/include/nsock_config.h.in b/nsock/include/nsock_config.h.in index ee9c0206e..33883488d 100644 --- a/nsock/include/nsock_config.h.in +++ b/nsock/include/nsock_config.h.in @@ -89,5 +89,4 @@ #undef HAVE_POLL #undef HAVE_KQUEUE -#undef PCAP_NETMASK_UNKNOWN #undef HAVE_PCAP_SET_IMMEDIATE_MODE diff --git a/nsock/src/acinclude.m4 b/nsock/src/acinclude.m4 index 696cd3414..fc096648c 100644 --- a/nsock/src/acinclude.m4 +++ b/nsock/src/acinclude.m4 @@ -117,25 +117,3 @@ AC_DEFUN([AX_HAVE_POLL], [dnl $1],[AC_MSG_RESULT([no]) $2]) ])dnl - -dnl Checks if PCAP_NETMASK_UNKNOWN is defined (has been since libpcap 1.1.1) -dnl Sets it to 0 (no checking) if it's not defined. -AC_DEFUN([PCAP_DEFINE_NETMASK_UNKNOWN], -[ - AC_MSG_CHECKING(if PCAP_NETMASK_UNKNOWN is defined/handled by libpcap) - AC_CACHE_VAL(ac_cv_have_pcap_netmask_unknown, - AC_TRY_COMPILE( - [ - #include - ], - [ - int i = PCAP_NETMASK_UNKNOWN; - ], - ac_cv_have_pcap_netmask_unknown=yes, - ac_cv_have_pcap_netmask_unknown=no)) - if test $ac_cv_have_pcap_netmask_unknown = no; then - AC_DEFINE(PCAP_NETMASK_UNKNOWN, 0, [Possibly using libpcap prior to 1.1.0.]) - fi - AC_MSG_RESULT($ac_cv_have_pcap_netmask_unknown) -]) - diff --git a/nsock/src/configure b/nsock/src/configure index 954f68769..55c812261 100755 --- a/nsock/src/configure +++ b/nsock/src/configure @@ -3672,43 +3672,7 @@ $as_echo "#define HAVE_PCAP 1" >>confdefs.h fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if PCAP_NETMASK_UNKNOWN is defined/handled by libpcap" >&5 -$as_echo_n "checking if PCAP_NETMASK_UNKNOWN is defined/handled by libpcap... " >&6; } - if ${ac_cv_have_pcap_netmask_unknown+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - -int -main () -{ - - int i = PCAP_NETMASK_UNKNOWN; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_have_pcap_netmask_unknown=yes -else - ac_cv_have_pcap_netmask_unknown=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - if test $ac_cv_have_pcap_netmask_unknown = no; then - -$as_echo "#define PCAP_NETMASK_UNKNOWN 0" >>confdefs.h - - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_pcap_netmask_unknown" >&5 -$as_echo "$ac_cv_have_pcap_netmask_unknown" >&6; } - +PCAP_DEFINE_NETMASK_UNKNOWN ax_have_epoll_cppflags="${CPPFLAGS}" ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default" diff --git a/nsock/src/nsock_pcap.c b/nsock/src/nsock_pcap.c index 554510d1b..9f9ae2bf0 100644 --- a/nsock/src/nsock_pcap.c +++ b/nsock/src/nsock_pcap.c @@ -81,6 +81,11 @@ extern struct timeval nsock_tod; #if HAVE_PCAP +#ifndef PCAP_NETMASK_UNKNOWN +/* libpcap before 1.1.1 (e.g. WinPcap) doesn't handle this specially, so just use 0 netmask */ +#define PCAP_NETMASK_UNKNOWN 0 +#endif + #define PCAP_OPEN_MAX_RETRIES 3 #define PCAP_FAILURE_EXPL_MESSAGE \ diff --git a/nsock/src/nsock_pcap.h b/nsock/src/nsock_pcap.h index 395d99098..ed754795d 100644 --- a/nsock/src/nsock_pcap.h +++ b/nsock/src/nsock_pcap.h @@ -66,13 +66,6 @@ #include #include -#ifdef WIN32 -/* WinPCAP doesn't have this, but Npcap does. - * Using 0 is safe for both, but change this if we decide to drop WinPcap */ -#undef PCAP_NETMASK_UNKNOWN -#define PCAP_NETMASK_UNKNOWN 0 -#endif - /* * There are three possible ways to read packets from pcap descriptor: * - select() on descriptor: diff --git a/tcpip.h b/tcpip.h index 3ac7ba8f6..939b0d969 100644 --- a/tcpip.h +++ b/tcpip.h @@ -138,12 +138,6 @@ #include "nbase.h" #include -#ifdef WIN32 -/* WinPCAP doesn't have this, but Npcap does. - * Using 0 is safe for both, but change this if we decide to drop WinPcap */ -#undef PCAP_NETMASK_UNKNOWN -#define PCAP_NETMASK_UNKNOWN 0 -#endif class Target;