1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-21 15:09:02 +00:00

Replace a config-time check with a ifndef that also works on Windows.

This commit is contained in:
dmiller
2018-11-21 06:23:08 +00:00
parent 33f16dd075
commit f8004b792c
11 changed files with 13 additions and 134 deletions

View File

@@ -87,27 +87,6 @@ int main() {
[AC_MSG_RESULT(cross-compiling -- assuming yes); $3]) [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 <pcap.h>
],
[
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 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 Defines HAVE_IPV6_IPPROTO_RAW if so. So far I only know this happens on
dnl Linux. dnl Linux.

38
configure vendored
View File

@@ -6380,43 +6380,7 @@ else
# link with -lpcap for the purposes of this test # link with -lpcap for the purposes of this test
LIBS_OLD="$LIBS" LIBS_OLD="$LIBS"
LIBS="$LIBS -lpcap" LIBS="$LIBS -lpcap"
PCAP_DEFINE_NETMASK_UNKNOWN
{ $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 <pcap.h>
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; }
for ac_func in pcap_set_immediate_mode for ac_func in pcap_set_immediate_mode
do : do :
ac_fn_c_check_func "$LINENO" "pcap_set_immediate_mode" "ac_cv_func_pcap_set_immediate_mode" ac_fn_c_check_func "$LINENO" "pcap_set_immediate_mode" "ac_cv_func_pcap_set_immediate_mode"

View File

@@ -206,6 +206,11 @@
#define NBASE_MAX_ERR_STR_LEN 1024 /* Max length of an error message */ #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 /** Print fatal error messages to stderr and then exits. A newline
character is printed automatically after the supplied text. character is printed automatically after the supplied text.
* @warning This function does not return because it calls exit() */ * @warning This function does not return because it calls exit() */

View File

@@ -254,7 +254,6 @@ extern "C" int gethostname (char *, unsigned int);
#undef MACOSX #undef MACOSX
#undef HAVE_IPV6_IPPROTO_RAW #undef HAVE_IPV6_IPPROTO_RAW
#undef PCAP_NETMASK_UNKNOWN
#undef HAVE_PCAP_SET_IMMEDIATE_MODE #undef HAVE_PCAP_SET_IMMEDIATE_MODE
/* Various possibilities for lua.h */ /* Various possibilities for lua.h */

View File

@@ -11,8 +11,7 @@
#include <locale.h> #include <locale.h>
#include "nbase.h" #include <nbase.h>
#include "nmap_error.h"
#ifdef HAVE_PCRE_PCRE_H #ifdef HAVE_PCRE_PCRE_H
# include <pcre/pcre.h> # include <pcre/pcre.h>

View File

@@ -89,5 +89,4 @@
#undef HAVE_POLL #undef HAVE_POLL
#undef HAVE_KQUEUE #undef HAVE_KQUEUE
#undef PCAP_NETMASK_UNKNOWN
#undef HAVE_PCAP_SET_IMMEDIATE_MODE #undef HAVE_PCAP_SET_IMMEDIATE_MODE

View File

@@ -117,25 +117,3 @@ AC_DEFUN([AX_HAVE_POLL], [dnl
$1],[AC_MSG_RESULT([no]) $1],[AC_MSG_RESULT([no])
$2]) $2])
])dnl ])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 <pcap.h>
],
[
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)
])

38
nsock/src/configure vendored
View File

@@ -3672,43 +3672,7 @@ $as_echo "#define HAVE_PCAP 1" >>confdefs.h
fi fi
PCAP_DEFINE_NETMASK_UNKNOWN
{ $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 <pcap.h>
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; }
ax_have_epoll_cppflags="${CPPFLAGS}" ax_have_epoll_cppflags="${CPPFLAGS}"
ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default" ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default"

View File

@@ -81,6 +81,11 @@ extern struct timeval nsock_tod;
#if HAVE_PCAP #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_OPEN_MAX_RETRIES 3
#define PCAP_FAILURE_EXPL_MESSAGE \ #define PCAP_FAILURE_EXPL_MESSAGE \

View File

@@ -66,13 +66,6 @@
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#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: * There are three possible ways to read packets from pcap descriptor:
* - select() on descriptor: * - select() on descriptor:

View File

@@ -138,12 +138,6 @@
#include "nbase.h" #include "nbase.h"
#include <pcap.h> #include <pcap.h>
#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; class Target;