From: Guy Harris Date: Fri, 26 Apr 2019 22:13:12 +0000 (-0700) Subject: Merge pull request #757 from fenner/bfd-multihop X-Git-Tag: tcpdump-4.99-bp~803 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/0f9428904ade10d6cf116e00b4bcc63e233b0a79?hp=9aa4f490f48e11d94a5089add2d9ea915a1f06a9 Merge pull request #757 from fenner/bfd-multihop Add BFD multihop and lag decoding --- diff --git a/aclocal.m4 b/aclocal.m4 index 2b45203d..2326db0a 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -530,12 +530,38 @@ AC_DEFUN(AC_LBL_LIBPCAP, if test $using_local_libpcap = no ; then # # We didn't find a local libpcap. - # Look for an installed pcap-config. + # Look for an installed pkg-config. # - AC_PATH_TOOL(PCAP_CONFIG, pcap-config) - if test -n "$PCAP_CONFIG" ; then + AC_PATH_TOOL(PKG_CONFIG, pkg-config) + if test -n "$PKG_CONFIG" ; then # - # Found - use it to get the include flags for + # We have it. Are there .pc files for libpcap? + # + AC_MSG_CHECKING(whether there are .pc files for libpcap) + if "$PKG_CONFIG" libpcap --exists ; then + # + # Yes, so we can use pkg-config to get configuration + # information for libpcap. + # + AC_MSG_RESULT(yes) + pkg_config_usable=yes + else + # + # No, so we can't use pkg-config to get configuration + # information for libpcap. + # + AC_MSG_RESULT(no) + pkg_config_usable=no + fi + else + # + # We don't have it, so we obviously can't use it. + # + pkg_config_usable=no + fi + if test "$pkg_config_usable" = "yes" ; then + # + # Found both - use pkg-config to get the include flags for # libpcap and the flags to link with libpcap. # # Please read section 11.6 "Shell Substitutions" @@ -545,50 +571,72 @@ AC_DEFUN(AC_LBL_LIBPCAP, # double-quoted strings inside double-quoted back-quoted # expressions (pfew!)." # - cflags=`"$PCAP_CONFIG" --cflags` + cflags=`"$PKG_CONFIG" libpcap --cflags` $2="$cflags $$2" - libpcap=`"$PCAP_CONFIG" --libs` + libpcap=`"$PKG_CONFIG" libpcap --libs` else # - # Not found; look for an installed pcap. + # No pkg-config + # Look for an installed pcap-config. # - AC_CHECK_LIB(pcap, main, libpcap="-lpcap") - if test $libpcap = FAIL ; then - AC_MSG_ERROR(see the INSTALL doc for more info) - fi - dnl - dnl Some versions of Red Hat Linux put "pcap.h" in - dnl "/usr/include/pcap"; had the LBL folks done so, - dnl that would have been a good idea, but for - dnl the Red Hat folks to do so just breaks source - dnl compatibility with other systems. - dnl - dnl We work around this by assuming that, as we didn't - dnl find a local libpcap, libpcap is in /usr/lib or - dnl /usr/local/lib and that the corresponding header - dnl file is under one of those directories; if we don't - dnl find it in either of those directories, we check to - dnl see if it's in a "pcap" subdirectory of them and, - dnl if so, add that subdirectory to the "-I" list. - dnl - dnl (We now also put pcap.h in /usr/include/pcap, but we - dnl leave behind a /usr/include/pcap.h that includes it, - dnl so you can still just include .) - dnl - AC_MSG_CHECKING(for extraneous pcap header directories) - if test \( ! -r /usr/local/include/pcap.h \) -a \ - \( ! -r /usr/include/pcap.h \); then - if test -r /usr/local/include/pcap/pcap.h; then - d="/usr/local/include/pcap" - elif test -r /usr/include/pcap/pcap.h; then - d="/usr/include/pcap" - fi - fi - if test -z "$d" ; then - AC_MSG_RESULT(not found) + AC_PATH_TOOL(PCAP_CONFIG, pcap-config) + if test -n "$PCAP_CONFIG" ; then + # + # Found - use it to get the include flags for + # libpcap and the flags to link with libpcap. + # + # Please read section 11.6 "Shell Substitutions" + # in the autoconf manual before doing anything + # to this that involves quoting. Especially note + # the statement "There is just no portable way to use + # double-quoted strings inside double-quoted back-quoted + # expressions (pfew!)." + # + cflags=`"$PCAP_CONFIG" --cflags` + $2="$cflags $$2" + libpcap=`"$PCAP_CONFIG" --libs` else - $2="-I$d $$2" - AC_MSG_RESULT(found -- -I$d added) + # + # Not found; look for an installed pcap. + # + AC_CHECK_LIB(pcap, main, libpcap="-lpcap") + if test $libpcap = FAIL ; then + AC_MSG_ERROR(see the INSTALL doc for more info) + fi + dnl + dnl Some versions of Red Hat Linux put "pcap.h" in + dnl "/usr/include/pcap"; had the LBL folks done so, + dnl that would have been a good idea, but for + dnl the Red Hat folks to do so just breaks source + dnl compatibility with other systems. + dnl + dnl We work around this by assuming that, as we didn't + dnl find a local libpcap, libpcap is in /usr/lib or + dnl /usr/local/lib and that the corresponding header + dnl file is under one of those directories; if we don't + dnl find it in either of those directories, we check to + dnl see if it's in a "pcap" subdirectory of them and, + dnl if so, add that subdirectory to the "-I" list. + dnl + dnl (We now also put pcap.h in /usr/include/pcap, but we + dnl leave behind a /usr/include/pcap.h that includes it, + dnl so you can still just include .) + dnl + AC_MSG_CHECKING(for extraneous pcap header directories) + if test \( ! -r /usr/local/include/pcap.h \) -a \ + \( ! -r /usr/include/pcap.h \); then + if test -r /usr/local/include/pcap/pcap.h; then + d="/usr/local/include/pcap" + elif test -r /usr/include/pcap/pcap.h; then + d="/usr/include/pcap" + fi + fi + if test -z "$d" ; then + AC_MSG_RESULT(not found) + else + $2="-I$d $$2" + AC_MSG_RESULT(found -- -I$d added) + fi fi fi else @@ -650,11 +698,11 @@ AC_DEFUN(AC_LBL_LIBPCAP, fi fi - if test -z "$PCAP_CONFIG"; then + if test -z "$PKG_CONFIG" -a -z "$PCAP_CONFIG"; then # - # We don't have pcap-config; find out any additional link flags - # we need. (If we have pcap-config, we assume it tells us what - # we need.) + # We don't have pkg-config or pcap-config; find out any additional + # link flags we need. (If we have pkg-config or pcap-config, we + # assume it tells us what we need.) # case "$host_os" in diff --git a/cmake/Modules/FindPCAP.cmake b/cmake/Modules/FindPCAP.cmake index a4135677..077405e5 100644 --- a/cmake/Modules/FindPCAP.cmake +++ b/cmake/Modules/FindPCAP.cmake @@ -2,150 +2,217 @@ # Try to find libpcap. # -find_program(PCAP_CONFIG pcap-config) -if(PCAP_CONFIG) - # - # We have pcap-config; use it. - # XXX - what if this is on Windows? If you're using, for example, - # MinGW, that might be the right thing to do, *if* pcap-config - # were made to work properly on Windows, but what about MSVC? +# +# First, try pkg-config. +# +find_package(PkgConfig) +pkg_search_module(PCAP libpcap) + +if(PCAP_FOUND) # - # First, get the include directory. + # That worked. + # Now, for each library, try to find it, so we get its full path. + # CMake *really* doesn't like the notion of specifying "here are + # the directories in which to look for libraries" except in + # find_library() calls; it *really* prefers using full paths to + # library files, rather than library names. # - execute_process(COMMAND "${PCAP_CONFIG}" "--cflags" - RESULT_VARIABLE PCAP_CONFIG_RESULT - OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(NOT PCAP_CONFIG_RESULT EQUAL 0) - message(FATAL_ERROR "pcap-config --cflags failed") - endif() + set(_pcap_libraries "${PCAP_LIBRARIES}") + set(PCAP_LIBRARIES "") + foreach(_lib IN LISTS _pcap_libraries) + # + # Try to find that library. + # + find_library(_libfullpath ${_lib} HINTS ${PCAP_LIBRARY_DIRS}) + list(APPEND PCAP_LIBRARIES ${_libfullpath}) + # + # Remove that from the cache; we're using it as a local variable, + # but find_library insists on making it a cache variable. + # + unset(_libfullpath CACHE) + endforeach() + # - # XXX - this assumes that there's only one -I flag in the output - # of pcap-config --cflags. That *should* be the case. + # Now find the static libraries. + # (XXX - what about AIX?) # - string(REGEX REPLACE "-I" "" PCAP_INCLUDE_DIRS "${PCAP_CONFIG_OUTPUT}") - set(PCAP_INCLUDE_DIR ${PCAP_INCLUDE_DIRS}) - - # Now, get the libraries. - execute_process(COMMAND "${PCAP_CONFIG}" "--libs" - RESULT_VARIABLE PCAP_CONFIG_RESULT - OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(NOT PCAP_CONFIG_RESULT EQUAL 0) - message(FATAL_ERROR "pcap-config --libs failed") - endif() - separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT}) - set(_pcap_library_dirs) - set(PCAP_LIBRARIES) - foreach(_arg IN LISTS LIBS_LIST) - if(_arg MATCHES "^-L") - # Add this directory to _pcap_library_dirs - string(REGEX REPLACE "-L" "" _dir ${_arg}) - list(APPEND _pcap_library_dirs ${_dir}) - elseif(_arg MATCHES "^-l") - string(REGEX REPLACE "-l" "" _lib ${_arg}) - # - # Try to find that library, so we get its full path. - # CMake *really* doesn't like the notion of specifying "here are - # the directories in which to look for libraries" except in - # find_library() calls; it *really* prefers using full paths to - # library files, rather than library names. - # - find_library(_libfullpath ${_lib} HINTS ${__pcap_library_dirs}) - list(APPEND PCAP_LIBRARIES ${_libfullpath}) - endif() + set(_pcap_static_libraries "${PCAP_STATIC_LIBRARIES}") + set(PCAP_STATIC_LIBRARIES "") + set(SAVED_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + foreach(_lib IN LISTS _pcap_static_libraries) + # + # Try to find that library, so we get its full path, as + # we do with dynamic libraries. + # + find_library(_libfullpath ${_lib} HINTS ${PCAP_LIBRARY_DIRS}) + list(APPEND PCAP_STATIC_LIBRARIES ${_libfullpath}) + # + # Remove that from the cache; we're using it as a local variable, + # but find_library insists on making it a cache variable. + # + unset(_libfullpath CACHE) endforeach() - - # Now, get the library directories and libraries for static linking. - execute_process(COMMAND "${PCAP_CONFIG}" "--libs" "--static" - RESULT_VARIABLE PCAP_CONFIG_RESULT - OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT - ) - if(NOT PCAP_CONFIG_RESULT EQUAL 0) - message(FATAL_ERROR "pcap-config --libs --static failed") - endif() - separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT}) - set(_pcap_static_library_dirs) - set(PCAP_STATIC_LIBRARIES) - foreach(_arg IN LISTS LIBS_LIST) - if(_arg MATCHES "^-L") - # Add this directory to _pcap_static_library_dirs - string(REGEX REPLACE "-L" "" _dir ${_arg}) - list(APPEND _pcap_static_library_dirs ${_dir}) - elseif(_arg MATCHES "^-l") - string(REGEX REPLACE "-l" "" _lib ${_arg}) - # - # Try to find that library, so we get its full path, as - # we do with dynamic libraries. - # - find_library(_libfullpath ${_lib} HINTS ${__pcap_static_library_dirs}) - list(APPEND PCAP_STATIC_LIBRARIES ${_libfullpath}) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${SAVED_CMAKE_FIND_LIBRARY_SUFFIXES}") +else(PCAP_FOUND) + # + # That didn't work. Try pcap-config. + # + find_program(PCAP_CONFIG pcap-config) + if(PCAP_CONFIG) + # + # We have pcap-config; use it. + # XXX - what if this is on Windows? If you're using, for example, + # MinGW, that might be the right thing to do, *if* pcap-config + # were made to work properly on Windows, but what about MSVC? + # + # First, get the include directory. + # + execute_process(COMMAND "${PCAP_CONFIG}" "--cflags" + RESULT_VARIABLE PCAP_CONFIG_RESULT + OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT PCAP_CONFIG_RESULT EQUAL 0) + message(FATAL_ERROR "pcap-config --cflags failed") endif() - endforeach() + # + # XXX - this assumes that there's only one -I flag in the output + # of pcap-config --cflags. That *should* be the case. + # + string(REGEX REPLACE "-I" "" _pcap_include_dir "${PCAP_CONFIG_OUTPUT}") - # Try to find the header - find_path(PCAP_INCLUDE_DIR pcap.h HINTS ${PCAP_INCLUDE_DIRS}) + # Try to find the header + # We use what pcap-config provided as a hint, because the + # pcap-config that ships with macOS bogusly supplies + # -I/usr/local/include even though the header isn't + # there (it may be under /usr/include or it may be + # buried in the Xcode app bundle). + find_path(PCAP_INCLUDE_DIRS pcap.h HINTS ${_pcap_include_dir}) - # Try to find the library - find_library(PCAP_LIBRARY pcap HINTS ${_pcap_library_dirs}) + # Now, get the libraries. + execute_process(COMMAND "${PCAP_CONFIG}" "--libs" + RESULT_VARIABLE PCAP_CONFIG_RESULT + OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT PCAP_CONFIG_RESULT EQUAL 0) + message(FATAL_ERROR "pcap-config --libs failed") + endif() + separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT}) + set(_pcap_library_dirs "") + set(PCAP_LIBRARIES "") + foreach(_arg IN LISTS LIBS_LIST) + if(_arg MATCHES "^-L") + # Add this directory to _pcap_library_dirs + string(REGEX REPLACE "-L" "" _dir ${_arg}) + list(APPEND _pcap_library_dirs ${_dir}) + elseif(_arg MATCHES "^-l") + string(REGEX REPLACE "-l" "" _lib ${_arg}) + # + # Try to find that library, so we get its full path. See the + # comment above for why we do this. + # + # Furthermore, the pcap-config shipped with macOS reports + # -I/usr/local/include for --cflags and -L/usr/local/lib for + # --libs, rather than reporting the appropriate system (or + # Xcode application) directory. + # + find_library(_libfullpath ${_lib} HINTS ${__pcap_library_dirs}) + list(APPEND PCAP_LIBRARIES ${_libfullpath}) + # + # Remove that from the cache; we're using it as a local variable, + # but find_library insists on making it a cache variable. + # + unset(_libfullpath CACHE) + endif() + endforeach() - # Try to find the static library (XXX - what about AIX?) - include(CMakePushCheckState) - cmake_push_check_state() - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - find_library(PCAP_STATIC_LIBRARY pcap HINTS ${_pcap_static_library_dirs}) - cmake_pop_check_state() -else(PCAP_CONFIG) - # Try to find the header - find_path(PCAP_INCLUDE_DIR pcap.h) + # Now, get the library directories and libraries for static linking. + # (XXX - what about AIX?) + execute_process(COMMAND "${PCAP_CONFIG}" "--libs" "--static" + RESULT_VARIABLE PCAP_CONFIG_RESULT + OUTPUT_VARIABLE PCAP_CONFIG_OUTPUT + ) + if(NOT PCAP_CONFIG_RESULT EQUAL 0) + message(FATAL_ERROR "pcap-config --libs --static failed") + endif() + separate_arguments(LIBS_LIST UNIX_COMMAND ${PCAP_CONFIG_OUTPUT}) + set(_pcap_static_library_dirs "") + set(PCAP_STATIC_LIBRARIES "") + set(SAVED_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + foreach(_arg IN LISTS LIBS_LIST) + if(_arg MATCHES "^-L") + # Add this directory to _pcap_static_library_dirs + string(REGEX REPLACE "-L" "" _dir ${_arg}) + list(APPEND _pcap_static_library_dirs ${_dir}) + elseif(_arg MATCHES "^-l") + string(REGEX REPLACE "-l" "" _lib ${_arg}) + # + # Try to find that library, so we get its full path, as + # we do with dynamic libraries. + # + find_library(_libfullpath ${_lib} HINTS ${__pcap_static_library_dirs}) + list(APPEND PCAP_STATIC_LIBRARIES ${_libfullpath}) + # + # Remove that from the cache; we're using it as a local variable, + # but find_library insists on making it a cache variable. + # + unset(_libfullpath CACHE) + endif() + endforeach() + set(CMAKE_FIND_LIBRARY_SUFFIXES "${SAVED_CMAKE_FIND_LIBRARY_SUFFIXES}") + else(PCAP_CONFIG) + # + # We don't have pcap-config. + # Try to find the header by just looking for it in whatever + # directories find_path() uses by default. + # + find_path(PCAP_INCLUDE_DIRS pcap.h) - # Try to find the library - if(WIN32) - # The 64-bit Packet.lib is located under /x64 - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - # - # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level - # directory contains 32-bit libraries; the 64-bit libraries are in the - # Lib/x64 directory. - # - # The only way to *FORCE* CMake to look in the Lib/x64 directory - # without searching in the Lib directory first appears to be to set - # CMAKE_LIBRARY_ARCHITECTURE to "x64". - # - set(CMAKE_LIBRARY_ARCHITECTURE "x64") + # Try to find the library + if(WIN32) + # The 64-bit Packet.lib is located under /x64 + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # + # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level + # directory contains 32-bit libraries; the 64-bit libraries are in the + # Lib/x64 directory. + # + # The only way to *FORCE* CMake to look in the Lib/x64 directory + # without searching in the Lib directory first appears to be to set + # CMAKE_LIBRARY_ARCHITECTURE to "x64". + # + set(CMAKE_LIBRARY_ARCHITECTURE "x64") + endif() endif() - endif() - find_library(PCAP_LIBRARY pcap) - if(WIN32) - if(NOT PCAP_LIBRARY) - # - # OK, look for it under the name wpcap. - # - find_library(PCAP_LIBRARY wpcap) - endif(NOT PCAP_LIBRARY) - endif(WIN32) - if(NOT WIN32) - # Try to find the static library (XXX - what about AIX?) - include(CMakePushCheckState) - cmake_push_check_state() - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - find_library(PCAP_STATIC_LIBRARY pcap) - cmake_pop_check_state() - endif(NOT WIN32) + find_library(PCAP_LIBRARIES pcap) + if(WIN32) + if(NOT PCAP_LIBRARIES) + # + # OK, look for it under the name wpcap. + # + find_library(PCAP_LIBRARIES wpcap) + endif(NOT PCAP_LIBRARIES) + endif(WIN32) - set(PCAP_INCLUDE_DIRS ${PCAP_INCLUDE_DIR}) - set(PCAP_LIBRARIES ${PCAP_LIBRARY}) - set(PCAP_STATIC_LIBRARIES ${PCAP_STATIC_LIBRARY}) -endif(PCAP_CONFIG) + if(NOT WIN32) + # Try to find the static library (XXX - what about AIX?) + set(SAVED_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + find_library(PCAP_STATIC_LIBRARIES pcap) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${SAVED_CMAKE_FIND_LIBRARY_SUFFIXES}") + endif(NOT WIN32) + endif(PCAP_CONFIG) +endif(PCAP_FOUND) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PCAP DEFAULT_MSG - PCAP_INCLUDE_DIR - PCAP_LIBRARY + PCAP_INCLUDE_DIRS + PCAP_LIBRARIES ) mark_as_advanced( diff --git a/configure b/configure index 16a3ac0b..afd5fb5a 100755 --- a/configure +++ b/configure @@ -636,6 +636,7 @@ DEPENDENCY_CFLAG AR RANLIB PCAP_CONFIG +PKG_CONFIG LIBOBJS EGREP GREP @@ -5357,9 +5358,156 @@ fi if test $using_local_libpcap = no ; then # # We didn't find a local libpcap. - # Look for an installed pcap-config. + # Look for an installed pkg-config. # if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + + if test -n "$PKG_CONFIG" ; then + # + # We have it. Are there .pc files for libpcap? + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether there are .pc files for libpcap" >&5 +$as_echo_n "checking whether there are .pc files for libpcap... " >&6; } + if "$PKG_CONFIG" libpcap --exists ; then + # + # Yes, so we can use pkg-config to get configuration + # information for libpcap. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + pkg_config_usable=yes + else + # + # No, so we can't use pkg-config to get configuration + # information for libpcap. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + pkg_config_usable=no + fi + else + # + # We don't have it, so we obviously can't use it. + # + pkg_config_usable=no + fi + if test "$pkg_config_usable" = "yes" ; then + # + # Found both - use pkg-config to get the include flags for + # libpcap and the flags to link with libpcap. + # + # Please read section 11.6 "Shell Substitutions" + # in the autoconf manual before doing anything + # to this that involves quoting. Especially note + # the statement "There is just no portable way to use + # double-quoted strings inside double-quoted back-quoted + # expressions (pfew!)." + # + cflags=`"$PKG_CONFIG" libpcap --cflags` + V_INCLS="$cflags $V_INCLS" + libpcap=`"$PKG_CONFIG" libpcap --libs` + else + # + # No pkg-config + # Look for an installed pcap-config. + # + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pcap-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pcap-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -5457,26 +5605,26 @@ else PCAP_CONFIG="$ac_cv_path_PCAP_CONFIG" fi - if test -n "$PCAP_CONFIG" ; then - # - # Found - use it to get the include flags for - # libpcap and the flags to link with libpcap. - # - # Please read section 11.6 "Shell Substitutions" - # in the autoconf manual before doing anything - # to this that involves quoting. Especially note - # the statement "There is just no portable way to use - # double-quoted strings inside double-quoted back-quoted - # expressions (pfew!)." - # - cflags=`"$PCAP_CONFIG" --cflags` - V_INCLS="$cflags $V_INCLS" - libpcap=`"$PCAP_CONFIG" --libs` - else - # - # Not found; look for an installed pcap. - # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpcap" >&5 + if test -n "$PCAP_CONFIG" ; then + # + # Found - use it to get the include flags for + # libpcap and the flags to link with libpcap. + # + # Please read section 11.6 "Shell Substitutions" + # in the autoconf manual before doing anything + # to this that involves quoting. Especially note + # the statement "There is just no portable way to use + # double-quoted strings inside double-quoted back-quoted + # expressions (pfew!)." + # + cflags=`"$PCAP_CONFIG" --cflags` + V_INCLS="$cflags $V_INCLS" + libpcap=`"$PCAP_CONFIG" --libs` + else + # + # Not found; look for an installed pcap. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpcap" >&5 $as_echo_n "checking for main in -lpcap... " >&6; } if ${ac_cv_lib_pcap_main+:} false; then : $as_echo_n "(cached) " >&6 @@ -5510,26 +5658,27 @@ if test "x$ac_cv_lib_pcap_main" = xyes; then : libpcap="-lpcap" fi - if test $libpcap = FAIL ; then - as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for extraneous pcap header directories" >&5 + if test $libpcap = FAIL ; then + as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for extraneous pcap header directories" >&5 $as_echo_n "checking for extraneous pcap header directories... " >&6; } - if test \( ! -r /usr/local/include/pcap.h \) -a \ - \( ! -r /usr/include/pcap.h \); then - if test -r /usr/local/include/pcap/pcap.h; then - d="/usr/local/include/pcap" - elif test -r /usr/include/pcap/pcap.h; then - d="/usr/include/pcap" + if test \( ! -r /usr/local/include/pcap.h \) -a \ + \( ! -r /usr/include/pcap.h \); then + if test -r /usr/local/include/pcap/pcap.h; then + d="/usr/local/include/pcap" + elif test -r /usr/include/pcap/pcap.h; then + d="/usr/include/pcap" + fi fi - fi - if test -z "$d" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + if test -z "$d" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - else - V_INCLS="-I$d $V_INCLS" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found -- -I$d added" >&5 + else + V_INCLS="-I$d $V_INCLS" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found -- -I$d added" >&5 $as_echo "found -- -I$d added" >&6; } + fi fi fi else @@ -5630,11 +5779,11 @@ fi fi fi - if test -z "$PCAP_CONFIG"; then + if test -z "$PKG_CONFIG" -a -z "$PCAP_CONFIG"; then # - # We don't have pcap-config; find out any additional link flags - # we need. (If we have pcap-config, we assume it tells us what - # we need.) + # We don't have pkg-config or pcap-config; find out any additional + # link flags we need. (If we have pkg-config or pcap-config, we + # assume it tells us what we need.) # case "$host_os" in diff --git a/print-ipoib.c b/print-ipoib.c index 63d61b3a..067ae937 100644 --- a/print-ipoib.c +++ b/print-ipoib.c @@ -26,7 +26,7 @@ /* \summary: IP-over-InfiniBand (IPoIB) printer */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include diff --git a/print-ldp.c b/print-ldp.c index 19e87b7f..680a7e1e 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -253,7 +253,7 @@ ldp_tlv_print(netdissect_options *ndo, ldp_tlv_header = (const struct ldp_tlv_header *)tptr; ND_TCHECK_SIZE(ldp_tlv_header); tlv_len=GET_BE_U_2(ldp_tlv_header->length); - if (tlv_len + 4 > msg_tlen) { + if (tlv_len + 4U > msg_tlen) { ND_PRINT("\n\t\t TLV contents go past end of message"); return 0; } diff --git a/print-vsock.c b/print-vsock.c index a91fecb7..5f0209b2 100644 --- a/print-vsock.c +++ b/print-vsock.c @@ -24,7 +24,7 @@ /* \summary: Linux vsock printer */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include "netdissect-stdinc.h"