From: Jason Ish Date: Tue, 25 Jan 2022 20:53:24 +0000 (-0600) Subject: configure: fallback to libpcap on Windows X-Git-Tag: suricata-7.0.0-beta1~973 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31ba4fd1522dd0d7f933767b9205c67a4e726fe5;p=thirdparty%2Fsuricata.git configure: fallback to libpcap on Windows If npcap/wpcap is not found on Windows, try libpcap. This allows Suricata to build without NPCap on Windows, however live capture won't be available. --- diff --git a/configure.ac b/configure.ac index 462bff447a..7492c8bcbc 100644 --- a/configure.ac +++ b/configure.ac @@ -278,7 +278,6 @@ e_magic_file="" e_magic_file_comment="#" - PCAP_LIB_NAME="pcap" case "$host" in *-*-*freebsd*) LUA_LIB_NAME="lua-5.1" @@ -308,14 +307,14 @@ *-*-mingw32*|*-*-msys) CFLAGS="${CFLAGS} -DOS_WIN32" WINDOWS_PATH="yes" - PCAP_LIB_NAME="wpcap" AC_DEFINE([HAVE_NON_POSIX_MKDIR], [1], [mkdir is not POSIX compliant: single arg]) RUST_LDADD=" -lws2_32 -liphlpapi -lwbemuuid -lOle32 -lOleAut32 -lUuid -luserenv -lshell32 -ladvapi32 -lgcc_eh -lbcrypt" + TRY_WPCAP="yes" ;; *-*-cygwin) LUA_LIB_NAME="lua" WINDOWS_PATH="yes" - PCAP_LIB_NAME="wpcap" + TRY_WPCAP="yes" ;; *-*-solaris*) AC_MSG_WARN([support for Solaris/Illumos/SunOS is experimental]) @@ -1176,38 +1175,36 @@ #define _DEFAULT_SOURCE 1 ]]) - LIBPCAP="" - PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[:]) - AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_open_live,, LIBPCAP="no") - if test "$LIBPCAP" = "no"; then - echo - echo " ERROR! libpcap library not found, go get it" - echo " from http://www.tcpdump.org or your distribution:" - echo - echo " Ubuntu: apt-get install libpcap-dev" - echo " Fedora: dnf install libpcap-devel" - echo " CentOS/RHEL: yum install libpcap-devel" - echo - exit 1 + have_wpcap="" + if test "$TRY_WPCAP" = "yes"; then + AC_CHECK_LIB(wpcap, pcap_activate, [], have_wpcap="no") + if test "$have_wpcap" = "no"; then + echo "" + echo " Warning: NPCap was not found. Live capture will not be available." + echo "" + else + PCAP_LIB_NAME="wpcap" + have_wpcap="yes" + fi fi - # pcap_activate and pcap_create only exists in libpcap >= 1.0 - LIBPCAPVTEST="" - #To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work - #see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful - TMPLIBS="${LIBS}" - AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_activate,, LPCAPVTEST="no") - if test "$LPCAPVTEST" = "no"; then - echo - echo " ERROR! libpcap library too old, need at least 1+, " - echo " go get it from http://www.tcpdump.org or your distribution:" - echo - echo " Ubuntu: apt-get install libpcap-dev" - echo " Fedora: dnf install libpcap-devel" - echo " CentOS/RHEL: yum install libpcap-devel" - echo - exit 1 + if test "$have_wpcap" != "yes"; then + AC_CHECK_LIB(pcap, pcap_open_dead, [], [ + echo + echo " ERROR! libpcap library not found, go get it" + echo " from http://www.tcpdump.org or your distribution:" + echo + echo " Ubuntu: apt-get install libpcap-dev" + echo " Fedora: dnf install libpcap-devel" + echo " CentOS/RHEL: yum install libpcap-devel" + echo + exit 1 + ]) + PCAP_LIB_NAME="pcap" fi + + PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[:]) + AC_PATH_PROG(HAVE_PCAP_CONFIG, pcap-config, "no") if test "$HAVE_PCAP_CONFIG" = "no" -o "$cross_compiling" = "yes"; then AC_MSG_RESULT(no pcap-config is use) @@ -1215,7 +1212,6 @@ PCAP_CFLAGS="$(pcap-config --defines) $(pcap-config --cflags)" AC_SUBST(PCAP_CFLAGS) fi - LIBS="${TMPLIBS}" #Appears as if pcap_set_buffer_size is linux only? LIBPCAPSBUFF=""