summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2023-02-24 23:10:04 +0000
committerDenis Ovsienko <denis@ovsienko.info>2023-02-25 18:02:18 +0000
commit161c18fa34a4f28d9671afa5bdc10f53bc2ef422 (patch)
tree11da7b8c1365593293522455e69c1ec6b489e426
parent00fd858c850bcd011932f911b8cb43ffaa51dd51 (diff)
downloadtcpdump-161c18fa34a4f28d9671afa5bdc10f53bc2ef422.tar.gz
Untangle detection of pcap_findalldevs().
tcpdump.c requires both HAVE_PCAP_IF_T and HAVE_PCAP_FINDALLDEVS to manage the code that depends on pcap_findalldevs(). Other than that, the Autoconf and CMake checks that produce these two macros do not relate directly, so having the check for pcap_if_t conditional on the check for pcap_findalldevs() is an unnecessary complication. More importantly, in the CMake case this places the check_type_size() for pcap_if_t into a context with CMAKE_REQUIRED_LIBRARIES already set to PCAP_LIBRARIES. This works only if check_type_size() does not have to check for <sys/types.h>, <stdint.h> or <stddef.h> implicitly. This was the case so long as another check_type_size() before the CMAKE_REQUIRED_LIBRARIES change made the implicit checks and cached the results, but removing that earlier instance resulted in a warning: Policy CMP0075 is not set: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMAKE_REQUIRED_LIBRARIES is set to: /usr/lib/x86_64-linux-gnu/libpcap.so For compatibility with CMake 3.11 and below this check is ignoring it. To fix that, in both Autoconf and CMake make the two checks separate and unconditional and place the check for pcap_if_t where it fits better. In CMake remove the earlier workaround with in6_addr.
-rw-r--r--CMakeLists.txt27
-rw-r--r--configure.ac21
2 files changed, 17 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2beaedb1..180e2ecf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -632,12 +632,6 @@ cmake_pop_check_state()
# so we use check_struct_has_member() and look for ss_family.
#
-#
-# FIXME: This check does not influence the build logic, but without it CMake
-# 3.18.4 fails trying to make the next check_type_size() check later on.
-#
-check_type_size("struct in6_addr" HAVE_STRUCT_IN6_ADDR)
-
######################################
# External dependencies
######################################
@@ -663,6 +657,14 @@ set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS})
check_include_file(pcap/pcap-inttypes.h HAVE_PCAP_PCAP_INTTYPES_H)
#
+# At compile time HAVE_PCAP_FINDALLDEVS depends on HAVE_PCAP_IF_T.
+#
+cmake_push_check_state()
+set(CMAKE_EXTRA_INCLUDE_FILES pcap.h)
+check_type_size(pcap_if_t PCAP_IF_T)
+cmake_pop_check_state()
+
+#
# Check for various functions in libpcap/WinPcap/Npcap.
#
cmake_push_check_state()
@@ -751,19 +753,6 @@ endif(HAVE_PCAP_CREATE)
# if we have them.
#
check_function_exists(pcap_findalldevs HAVE_PCAP_FINDALLDEVS)
-if(HAVE_PCAP_FINDALLDEVS)
- #
- # Check for libpcap having pcap_findalldevs() but the pcap.h header
- # not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
- # from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
- # pcap.h didn't have pcap_if_t.
- #
- cmake_push_check_state()
- set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS})
- set(CMAKE_EXTRA_INCLUDE_FILES pcap.h)
- check_type_size(pcap_if_t PCAP_IF_T)
- cmake_pop_check_state()
-endif(HAVE_PCAP_FINDALLDEVS)
check_function_exists(pcap_dump_flush HAVE_PCAP_DUMP_FLUSH)
check_function_exists(pcap_lib_version HAVE_PCAP_LIB_VERSION)
if(NOT HAVE_PCAP_LIB_VERSION)
diff --git a/configure.ac b/configure.ac
index ee26ffc0..cb6a883f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -620,16 +620,6 @@ fi
# if we have them.
#
AC_CHECK_FUNCS(pcap_findalldevs)
-if test $ac_cv_func_pcap_findalldevs = "yes" ; then
-dnl Check for libpcap having pcap_findalldevs() but the pcap.h header
-dnl not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
-dnl from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
-dnl pcap.h didn't have pcap_if_t.
- savedcppflags="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $V_INCLS"
- AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
- CPPFLAGS="$savedcppflags"
-fi
AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
if test $ac_cv_func_pcap_lib_version = "no" ; then
AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
@@ -764,13 +754,20 @@ fi
#
AC_TYPE_UINTPTR_T
+savedcppflags="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $V_INCLS"
+
#
# Check whether we have pcap/pcap-inttypes.h.
# If we do, we use that to get the C99 types defined.
#
-savedcppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $V_INCLS"
AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
+
+#
+# At compile time HAVE_PCAP_FINDALLDEVS depends on HAVE_PCAP_IF_T.
+#
+AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
+
CPPFLAGS="$savedcppflags"
#