From 585832c41e822ccea521e4f39bd5571caad2e978 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 28 Apr 2023 14:37:51 +0000 Subject: [PATCH] Upgrade libpcap to 1.10.4 --- libpcap/CHANGES | 268 +- libpcap/CMakeLists.txt | 757 +- libpcap/CONTRIBUTING.md | 6 +- libpcap/CREDITS | 11 +- libpcap/INSTALL.md | 294 +- libpcap/Makefile.in | 111 +- ...01-Don-t-autogenerate-Lex-Yacc-files.patch | 34 +- .../0002-Disable-unnecessary-features.patch | 36 +- libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE | 2 +- libpcap/README.md | 12 +- libpcap/VERSION | 1 + libpcap/VERSION.txt | 1 - libpcap/Win32/Prj/wpcap.sln | 28 - libpcap/Win32/Prj/wpcap.vcxproj | 233 - libpcap/Win32/Prj/wpcap.vcxproj.filters | 107 - libpcap/aclocal.m4 | 281 +- libpcap/charconv.c | 1 + libpcap/charconv.h | 6 +- libpcap/cmake/Modules/FindAirPcap.cmake | 69 + libpcap/cmake/Modules/FindDAG.cmake | 7 + libpcap/cmake/Modules/FindPacket.cmake | 26 +- libpcap/cmake/Modules/FindSNF.cmake | 6 + libpcap/cmake/Modules/Finddpdk.cmake | 195 +- libpcap/cmakeconfig.h.in | 9 - libpcap/config.guess | 1270 +- libpcap/config.h.in | 19 +- libpcap/config.sub | 115 +- libpcap/configure | 10455 +++++++++------- libpcap/configure.ac | 1211 +- libpcap/diag-control.h | 163 +- libpcap/dlpisubs.c | 7 +- libpcap/extract.h | 2 +- libpcap/fmtutils.c | 26 +- libpcap/fmtutils.h | 6 + libpcap/ftmacros.h | 7 +- libpcap/gencode.c | 273 +- libpcap/gencode.h | 14 + libpcap/grammar.c | 1012 +- libpcap/grammar.h | 2 +- libpcap/grammar.y.in | 126 +- libpcap/libpcap.pc.in | 5 +- libpcap/missing/asprintf.c | 2 +- libpcap/mkdep | 23 +- libpcap/msdos/makefile | 8 +- libpcap/nametoaddr.c | 47 +- libpcap/optimize.c | 30 +- libpcap/pcap-airpcap.c | 3 + libpcap/pcap-bpf.c | 37 +- libpcap/pcap-bt-linux.c | 14 +- libpcap/pcap-common.c | 320 +- libpcap/pcap-common.h | 25 - libpcap/pcap-config.1 | 2 +- libpcap/pcap-config.in | 102 +- libpcap/pcap-dag.c | 34 +- libpcap/pcap-dll.rc | 6 +- libpcap/pcap-dlpi.c | 78 +- libpcap/pcap-dos.c | 26 +- libpcap/pcap-dpdk.c | 22 +- libpcap/pcap-filter.manmisc.in | 417 +- libpcap/pcap-haiku.cpp | 31 +- libpcap/pcap-int.h | 22 +- libpcap/pcap-libdlpi.c | 46 +- libpcap/pcap-linux.c | 434 +- libpcap/pcap-netfilter-linux.c | 14 +- libpcap/pcap-new.c | 32 +- libpcap/pcap-nit.c | 3 + libpcap/pcap-npf.c | 520 +- libpcap/pcap-pf.c | 3 + libpcap/pcap-rdmasniff.c | 22 +- libpcap/pcap-rpcap.c | 238 +- libpcap/pcap-septel.c | 4 +- libpcap/pcap-sita.c | 6 +- libpcap/pcap-sita.html | 22 +- libpcap/pcap-snf.c | 38 +- libpcap/pcap-snit.c | 15 +- libpcap/pcap-tc.c | 4 +- libpcap/pcap-usb-linux-common.c | 130 + libpcap/pcap-usb-linux-common.h | 26 + libpcap/pcap-usb-linux.c | 139 +- libpcap/pcap-util.c | 474 + libpcap/pcap-util.h | 55 + libpcap/pcap.3pcap.in | 28 +- libpcap/pcap.c | 104 +- libpcap/pcap/bpf.h | 7 +- libpcap/pcap/can_socketcan.h | 7 +- libpcap/pcap/compiler-tests.h | 50 +- libpcap/pcap/dlt.h | 96 +- libpcap/pcap/funcattrs.h | 82 +- libpcap/pcap/namedb.h | 5 +- libpcap/pcap/pcap-inttypes.h | 85 +- libpcap/pcap/pcap.h | 26 +- libpcap/pcap_breakloop.3pcap | 73 +- libpcap/pcap_compile.3pcap.in | 4 +- libpcap/pcap_datalink_val_to_name.3pcap | 4 +- libpcap/pcap_dump_open.3pcap.in | 2 +- libpcap/pcap_findalldevs.3pcap | 4 +- libpcap/pcap_get_tstamp_precision.3pcap.in | 2 +- libpcap/pcap_inject.3pcap | 14 +- libpcap/pcap_list_tstamp_types.3pcap.in | 4 +- libpcap/pcap_loop.3pcap | 20 +- libpcap/pcap_next_ex.3pcap | 11 +- libpcap/pcap_open_offline.3pcap.in | 4 +- libpcap/pcap_set_datalink.3pcap | 8 +- libpcap/pcap_set_immediate_mode.3pcap.in | 2 +- libpcap/pcap_set_tstamp_precision.3pcap.in | 2 +- libpcap/pcap_set_tstamp_type.3pcap.in | 2 +- libpcap/pcap_setdirection.3pcap | 8 +- libpcap/pcap_setfilter.3pcap | 8 +- libpcap/pcap_setnonblock.3pcap | 9 +- libpcap/pcap_stats.3pcap | 9 +- libpcap/pflog.h | 157 + libpcap/rpcap-protocol.h | 21 + libpcap/savefile.c | 52 +- libpcap/scanner.c | 401 +- libpcap/scanner.h | 13 +- libpcap/scanner.l | 11 +- libpcap/sf-pcap.c | 50 +- libpcap/sf-pcapng.c | 10 +- libpcap/sockutils.c | 676 +- libpcap/sockutils.h | 19 +- libpcap/tests/shb-option-too-long.pcapng | Bin 180 -> 0 bytes 121 files changed, 13810 insertions(+), 8968 deletions(-) create mode 100644 libpcap/VERSION delete mode 100644 libpcap/VERSION.txt delete mode 100644 libpcap/Win32/Prj/wpcap.sln delete mode 100644 libpcap/Win32/Prj/wpcap.vcxproj delete mode 100644 libpcap/Win32/Prj/wpcap.vcxproj.filters create mode 100644 libpcap/cmake/Modules/FindAirPcap.cmake create mode 100644 libpcap/pcap-usb-linux-common.c create mode 100644 libpcap/pcap-usb-linux-common.h create mode 100644 libpcap/pcap-util.c create mode 100644 libpcap/pcap-util.h create mode 100644 libpcap/pflog.h delete mode 100644 libpcap/tests/shb-option-too-long.pcapng diff --git a/libpcap/CHANGES b/libpcap/CHANGES index 1bf3fb27d..c574a2780 100644 --- a/libpcap/CHANGES +++ b/libpcap/CHANGES @@ -1,5 +1,240 @@ -Monthday, Month DD, YYYY - Summary for 1.10.1 libpcap release (so far!) +Friday, April 7, 2023 / The Tcpdump Group + Summary for 1.10.4 libpcap release + Source code: + Fix spaces before tabs in indentation. + rpcap: + Fix name of launchd service. + Documentation: + Document use of rpcapd with systemd, launchd, inetd, and xinetd. + Building and testing: + Require at least pkg-config 0.17.0, as we use --static. + Get rid of the remains of gnuc.h. + Require at least autoconf 2.69. + Update config.{guess,sub}, timestamps 2023-01-01,2023-01-21. + +Thursday, January 12, 2023 / The Tcpdump Group + Summary for 1.10.3 libpcap release + Source code: + Sort the PUBHDR variable in Makefile.in in "ls" order. + Fix typo in comment in pflog.h. + Remove two no-longer-present files from .gitignore. + Update code and comments for handling failure to set promiscuous + mode based on new information. + Building and testing: + install: Fixed not to install the non-public pcap-util.h header. + pcap-config: add a --version flag. + Makefile.in: Add some missing files in the distclean target. + +Saturday, December 31, 2022 / The Tcpdump Group + Summary for 1.10.2 libpcap release + Source code: + Use __builtin_unreachable() in PCAP_UNREACHABLE. + Use AS_HELP_STRING macro instead of AC_HELP_STRING in the + configure scripts, to avoid deprecation warnings. + Change availability tags in pcap.h to make it easier to + arrange for it to be used in Darwin releases. + Use AS_HELP_STRING for --enable-remote. + Fix some formatting string issues found by cppcheck. + Various small code and comment cleanups. + Use PCAP_ERROR (defined as -1) rather than explicit -1 for + functions the documentation says return PCAP_ERROR. + Remove unused code from the filter compiler. + Use _declspec(deprecated(msg)) rather than __pragma(deprecated) + for Windows deprecation warnings, so the message that was + specified shows up. + diag-control.h: define PCAP_DO_PRAGMA() iff we're going to use it. + Use "%d" to print some signed ints. + Use the Wayback Machine for a removed document in a comment. + Add some const qualifiers. + RDMA: Use PRIu64 to print a uint64_t. + "Dead" pcap_ts from pcap_open_dead() and ..._with_tstamp_precision(): + Don't crash if pcap_breakloop() is called. + Savefiles: + Fix pcap_dispatch() to return number of packets processed, rather + than 0, even at EOF. + If we get an error writing the packet header, don't write the + packet data. + Put PFLOG UID and PID values in the header into host byte order + when reading a LINKTYPE_PFLOG file. + Put CAN ID field in CAN pseudo-headers for LINUX_SLL2, as we do + for LINUX_SLL. + Fix inorrectly-computed "real" length for isochronous USB + transfers when reading savefiles. + Don't crash if pcap_can_set_rfmon() is called. + Fix pcap_offline_read() loop. + Capture: + Never process more than INT_MAX packets in a pcap_dispatch() call, + to avoid integer overflow (issue #1087). + Improve error messages for "no such device" and "permission + denied" errors. + SITA: Fix a typo in a variable name. + Packet filtering: + Get PFLOG header length from the length value in the header. + Support all the direction, reason, and action types supported by + all systems that support PFLOG. + Don't require PFLOG support on the target machine in order to + support PFLOG filtering (also fixes issue #1076). + Expand abbreviations into "proto X" properly. + gencode.c: Update a comment about the VLAN TPID test. + Add the minimum and maximum matching DLTs to an error message. + Linux: + Fix memory leak in capture device open (pull request #1038). + Fix detection of CAN/CAN FD packets in direction check (issue + #1051). + Fix double-free crashes on errors such as running on a kernel with + CONFIG_PACKET_MMAP not configured (issue #1054). + Use DLT_CAN_SOCKETCAN for CANbus interfaces (issue #1052; includes + changes from pull request #1035). + Make sure the CANFD_FDF can be relied on to indicate whether a + CANbus packet is a CAN frame or a CAN FD frame + Improve error message for "out of memory" errors for kernel + filters (see issue #1089). + Fix pcap_findalldevs() to find usbmon devices. + Fix handling of VLAN tagged packets if the link-layer type is + changed from DLT_LINUX_SLL to DLT_LINUX_SLL2 (see issue #1105). + Always turn on PACKET_AUXDATA (see issue #1105). + We require 2.6.27 or later, so PACKET_RESERVE is available. + Make sure there's reserved space for a DLT_LINUX_SLL2 header + when capturing. + Correctly compute the "real" length for isochronous USB transfers. + Don't have an eventfd descriptor open in non-blocking mode, so as + not to waste descriptors. + netfilter: Squelch a narrowing warning (To be look at before 2038). + BPF capture (*BSD, macOS, AIX, Solaris 11): + Fix case where a device open might fail, rather than falling back + to a smaller buffer size, when the initial buffer size is too + big. + Use an unsigned device number to iterate over BPF devices, to + squelch a compiler warning. + NetBSD: + Fix handling of LINKTYPE_HDLC/DLT_HDLC. + rpcap: + Fix unaligned accesses in rpcapd (pull request #1037). + Fix code to process port number. + Clean up findalldevs code in rpcapd. + Clean up bufferizing code. + Fix a file descriptor/handle leak in pcap_findalldevs_ex() + (Coverity CID 1507240). + Improve error messages for host and port resolution errors. + Fix connect code not to fail if both IPv4 and IPv6 addresses are + tried. + Improve connect failure error message. + Provide an error message for a bad authentication reply size. + For link-layer types with host-endian fields in the header, fix + those fields if capturing from a server with a different byte + order. + Suppress temporarily the warnings with "enable remote packet capture". + Windows: + Add support for NdisMediumIP (pull request #1027). + Don't require applications using pcap to be built with VS 2015 or + later. + Use the correct string for the DLL VersionInfo. + Remove unnecessary DllMain() function. + Correctly handle ERROR_INVALID_FUNCTION from + PacketGetTimestampModes() (indicate that WinPcap or an older + version of Npcap is probably installed). + Fix use-after-free in some cases when a pcap_t is closed. + Make sure an error is returned by pcap_create_interface() if + PacketOpenAdapter() fails. + Return an error if the driver reports 0 timestamp modes supported. + Close the ADAPTER handle for some errors in + pcap_create_interface(). + Get rid of old umaintained VS project files. + Fix deprecation warning for pcap_handle(). + Npcap is now at npcap.com, not npcap.org. + Make sure "no such device" and "no permission to open device" + errors show up in pcap_activate(), not pcap_create() (fixes, + among other things, tcpdump -i ). + npcap: squelch deprecation warnings for kernel dump mode. + Haiku: + Implement pcap_lib_version(), as now required. + Handle negative or too-large snaplen values. + Fix various build issues and warnings. + Building and testing: + Update configure-time universal build checks for macOS. + Update config.guess and config.sub. + If we look for an SSL library with pkg-config in configure script, + try pkg-config first. + If we have pkg-config and Homebrew, try to set pkg-config up to + find Homebrew packages. + Handle some Autoconf/make errors better. + Use "git archive" for the "make releasetar" process. + Remove the release candidate rcX targets. + Fix compiling on Solaris 9/SPARC and 11/AMD64. + Address assorted compiler warnings. + Fix cross-building on Linux for Windows with mingw32 for Win64 + (pull request #1031). + Properly set installation directory on Windows when not compiling + with MSVC. + Fix configure script checks for compiler flags. + Give more details if check for usable (F)Lex fails. + Fix compiling with GCC 4.6.4. + Don't use add_compile_options() with CMake, as we currently don't + require 2.8.12, where it first appeared. + Don't provide -L/usr/lib for pkg-config --libs in pkg-config. + Fix error message for inadequate Bison/Berkeley YACC. + configure: correctly do some DPDK checks. + Only use pkg-config when checking for DPDK. + Allow the path in which DPDK is installed to be specified. + Use pkg-config first when checking for libibverbs. + CMake: fix check for libibverbs with Sun's C compiler. + Have CMake warn if no capture mechanism can be found. + Don't do stuff requiring 3.19 or later on earlier CMakes. + Squelch some CMake warnings. + Fix diag-control.h to handle compiling with clang-cl (issues + #1101 and #1115). + Cleanup various leftover cruft in the configure script. + Fix building without protochain support. (GH #852) + Check for a usable YACC (or Bison) and {F}lex in CMake, as we do + in autotools. + Only check for a C++ compiler on Haiku, as that's the only + platform with C++ code, and make sure they generate code for + the same instruction set bit-width (both 32-bit or both 64-bit) + (issue #1112). + On Solaris, check the target bit-width and set PKG_CONFIG_PATH + appropriately, to handle the mess that is the D-Bus library + package (issue #1112). + Fix generation of pcap-config and libpcap.pc files (issue #1062). + pcap-config: don't assume the system library directory is /usr/lib. + pcap-config: add a --static-pcap-only flag. + Cirrus CI: Use the same configuration as for the main branch. + Add four libpcap test files. + Update Npcap SDK to 1.13. + Makefile.in: Use TEST_DIST, like for tcpdump. + Remove awk code from mkdep. + Cirrus CI: Add the libssl-dev package in the Linux task. + Cirrus CI: Add the openssl@3 brew package in the macOS task. + Get "make shellcheck" to pass again. + CMake: Build valgrindtest only if Autoconf would. + CMake: use ${CMAKE_INSTALL_SBINDIR} rather than just sbin. + CMake: use NUL: as the null device on Windows. + autoconf: fix typo in test of macOS version. + Makefile.in: Add two missing files in EXTRA_DIST. + autotools, cmake: provide an rpath option if necessary. + configure: get rid of the attempt to auto-run PKG_PROG_PKG_CONFIG. + configure: use PKG_CHECK_MODULES to run pkg-config. + Documentation: + Add README.solaris.md. + Add SCTP to pcap-filter(7). + Note that = and == are the same operator in filters (issue #1044). + Update INSTALL.md, README.md, and README.solaris.md. + Update and clean up CONTRIBUTING.md. + Trim documentation of support for now-dead UN*Xe and older + versions of other UN*Xes. + Move the "how to allocate a LINKTYPE_/DLT_ value" documentation to + the web site. + Clean up man pages. + Move README.capture-module to the web site. + Improve some protocol details in pcap-filter(7). + Refine "relop" notes in pcap-filter(7). + In pcap-filter(7) "domain" is an id. + Discuss backward compatibility in pcap-filter(7). + Other improvements to pcap-filter(7). + Document pcap_breakloop(3PCAP) interaction with threads better. + Document PCAP_ERROR_NOT_ACTIVATED for more routines. + +Wednesday, June 9, 2021: + Summary for 1.10.1 libpcap release: Packet filtering: Fix "type XXX subtype YYY" giving a parse error Source code: @@ -234,7 +469,7 @@ Sunday, July 22, 2018 need to be Fix reading of capture statistics for Linux USB Fix packet size values for Linux USB packets (GitHub issue #808) - Check only VID in VLAN test in filterss (GitHub issue #461) + Check only VID in VLAN test in filters (GitHub issue #461) Fix pcap_list_datalinks on 802.11 devices on macOS Fix overflows with very large snapshot length in pcap file Improve parsing of rpcapd configuration file (GitHub issue #767) @@ -275,7 +510,6 @@ Sunday, July 22, 2018 Boost the TPACKET_V3 timeout to the maximum if a timeout of 0 was specified Five CVE-2019-15161, CVE-2019-15162, CVE-2019-15163, CVE-2019-15164, CVE-2019-15165 - Fixes for CVE-2018-16301, errors in pcapng reading. PCAPNG reader applies some sanity checks before doing malloc(). Sunday, June 24, 2018, by mcr@sandelman.ca @@ -283,7 +517,7 @@ Sunday, June 24, 2018, by mcr@sandelman.ca Added testing system to libpcap, independent of tcpdump Changes to how pcap_t is activated Adding support for Large stream buffers on Endace DAG cards - Changes to BSD 3-clause license to 2-clause licence + Changes to BSD 3-clause license to 2-clause license Additions to TCP header parsing, per RFC3168 Add CMake build process (extensive number of changes) Assign a value for OpenBSD DLT_OPENFLOW. @@ -790,7 +1024,7 @@ Tue. September 19, 2006. ken@xelerance.com. Summary for 0.9.5 libpcap release Add support to build libpcap.lib and wpcap.dll under Cygnus and MingW32. -Mon. September 5, 2005. ken@xelerance.com. Summary for 0.9.4 libpcap release +Mon. September 5, 2005. ken@xelerance.com. Summary for 0.9.4 libpcap release Support for radiotap on Linux (Mike Kershaw) Fixes for HP-UX @@ -801,7 +1035,7 @@ Mon. September 5, 2005. ken@xelerance.com. Summary for 0.9.4 libpcap release parts of the filter expression to look at the PPP headers and headers in the PPP payload -Tue. July 5, 2005. ken@xelerance.com. Summary for 0.9.3 libpcap release +Tue. July 5, 2005. ken@xelerance.com. Summary for 0.9.3 libpcap release Fixes for compiling on nearly every platform, including improved 64bit support @@ -840,16 +1074,16 @@ Wed. November 12, 2003. mcr@sandelman.ottawa.on.ca. Summary for 0.8 release Tuesday, February 25, 2003. fenner@research.att.com. 0.7.2 release - Support link types that use 802.2 always, never, and sometimes. - Don't decrease the size of the BPF buffer from the default. - Support frame relay. - Handle 32-bit timestamps in DLPI, and pass the right buffer size. - Handle Linux systems with modern kernel but without - SOL_PACKET in the userland headers. - Linux support for ARPHRD_RAWHDLC. - Handle 32-bit timestamps in snoop. - Support eg (Octane/O2xxx/O3xxx Gigabit) devices. - Add new reserved DLT types. + Support link types that use 802.2 always, never, and sometimes. + Don't decrease the size of the BPF buffer from the default. + Support frame relay. + Handle 32-bit timestamps in DLPI, and pass the right buffer size. + Handle Linux systems with modern kernel but without + SOL_PACKET in the userland headers. + Linux support for ARPHRD_RAWHDLC. + Handle 32-bit timestamps in snoop. + Support eg (Octane/O2xxx/O3xxx Gigabit) devices. + Add new reserved DLT types. Monday October 23, 2001. mcr@sandelman.ottawa.on.ca. Summary for 0.7 release diff --git a/libpcap/CMakeLists.txt b/libpcap/CMakeLists.txt index b83fbbd76..58c515990 100644 --- a/libpcap/CMakeLists.txt +++ b/libpcap/CMakeLists.txt @@ -35,9 +35,283 @@ if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() +# +# We want check_include_file() to honor CMAKE_REQUIRED_LIBRARIES; see +# the big comment before the check_include_file() test for +# infiniband/verbs.h for the reason. +# +if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) +endif() + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) -project(pcap) +# +# We only need a C++ compiler for Haiku; all code except for its +# pcap module is in C. +# +# We do that by specifying just C in the project() call and, after +# that finishes, checking for Haiku and, if we're building for +# Haiku, use enable_language() to check for C++. This means that +# we don't require a C++ compiler on platforms other than Haiku. +# +# CMAKE_SYSTEM_NAME is set by project(), so we can't do this by +# testing CMAKE_SYSTEM_NAME and then passing different language +# lists to project() based on the system. +# +project(pcap C) + +# +# For getting raw lists of --libs and --libs --static information from a +# pkg-config module. +# +# In CMake up to 2.8.12, pkg_check_modules() sets: +# +# _LIBRARIES, which is a list of library names to which, on +# a UN*X, -l can be prefixed - i.e., names, without extensions, +# rather than full paths to the file. +# _LIBRARY_DIRS, which is a list of paths to directories +# containing the libraries, to which, on a UN*X, -L can be +# prefixed. +# _LDFLAGS, which is a list of *all* required linker flags +# _LDFLAGS_OTHER, which is a list of all linker flags other +# than -l and -L flags +# +# In 3.0 (at least as of 3.0.2), it also sets: +# +# _LINK_LIBRARIES, which is a list of full paths to the +# library files. +# +# but if is _STATIC, _LINK_LIBRARIES is +# currently not set by CMake. +# +# Unfortunately, pkg_check_modules() sets the +# PKG_CONFIG_ALLOW_SYSTEM_LIBS environment variable when running +# pkg-config, so the output of --libs, etc. may include a -L for the +# system library, which we do *NOT* want to put in our libpcap.pc and +# pcap-config files. +# +# So we just run pkg-config ourselves, so that we get its output +# directly without any processing by CMake. +# +macro(pkg_get_link_info _prefix _package) + if (PKG_CONFIG_EXECUTABLE) + # + # Get the --libs information. + # + # We force PKG_CONFIG_ALLOW_SYSTEM_LIBS to be undefined, as + # at least some versions of CMake appear to define it in + # pkg_check_modules() before running pkg-config and *not* undefine + # it after running it. + # + unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}) + set(_pkg_config_result "") + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} "--libs" ${_package} + OUTPUT_VARIABLE _pkg_config_result + RESULT_VARIABLE _pkg_config_failed + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (_pkg_config_failed) + # + # pkg-config failed; assume that means that there is no such + # package for it to find. XXX - what do we do here? + # + set(${_prefix}_FOUND_WITH_PKG_CONFIG FALSE) + else() + # + # pkg-config succeeded; replace CR and LF with spaces. + # + string(REGEX REPLACE "[\r\n]" " " ${_prefix}_LIBS "${_pkg_config_result}") + + # + # Now get the --libs --static information. + # + set(_pkg_config_result "") + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} "--libs" "--static" ${_package} + OUTPUT_VARIABLE _pkg_config_result + RESULT_VARIABLE _pkg_config_failed + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (_pkg_config_failed) + # + # pkg-config failed; assume that means that there is no such + # package for it to find. XXX - what do we do here? + # + set(${_prefix}_FOUND_WITH_PKG_CONFIG FALSE) + else() + # + # pkg-config succeeded; replace CR and LF with spaces. + # + string(REGEX REPLACE "[\r\n]" " " ${_prefix}_LIBS_STATIC "${_pkg_config_result}") + + # + # List this package in its PACKAGE_NAME variable. + # + set(${_prefix}_PACKAGE_NAME "${_package}") + + # + # It worked. + # + set(${_prefix}_FOUND_WITH_PKG_CONFIG TRUE) + endif() + endif() + endif() +endmacro() + +macro(get_link_info_from_library_path _library_prefix _library_name) + if(NOT ${_library_prefix}_LIBRARY STREQUAL "${_library_prefix}_LIBRARY-NOTFOUND") + get_filename_component(_lib_directory "${${_library_prefix}_LIBRARY}}" DIRECTORY) + + # + # The closest thing to a list of "system library directories" in + # which the linker will, by default, search for libraries appears to + # be CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES, so that's what we use + # when we're trying to construct a -L argument, for insertion into + # pcap-config and libpcap.pc, for a library upon which we depend. + # + # In some versions of CMake it appears to have duplicate entries, + # but that shouldn't affect a search for a directory in that list. + # + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_lib_directory}" _lib_index) + if(_lib_index EQUAL -1) + # + # No, so add a -L flag to get the linker to search in that + # directory. + # + set(${_library_prefix}_LIBS "-L${_lib_directory}") + set(${_library_prefix}_LIBS_STATIC "-L${_lib_directory}") + set(${_libraryprefix}_LIBS_PRIVATE "-L${_lib_directory}") + endif() + set(${_library_prefix}_LIBS "${${_library_prefix}_LIBS} -l${_library_name}") + set(${_library_prefix}_LIBS_STATIC "${${_library_prefix}_LIBS} -l${_library_name}") + set(${_library_prefix}_LIBS_PRIVATE "${${_library_prefix}_LIBS} -l${_library_name}") + endif() +endmacro() + +if(CMAKE_SYSTEM_NAME STREQUAL "Haiku") + enable_language(CXX) + + # + # OK, this is a royal pain. + # + # CMake will try to determine the sizes of some data types, including + # void *, early in the process of configuration; apparently, it's done + # as part of processing the project() command. + # + # At least as of CMake 2.8.6, it does so by checking the size of + # "void *" in C, setting CMAKE_C_SIZEOF_DATA_PTR based on that, + # setting CMAKE_SIZEOF_VOID_P to that, and then checking the size + # of "void *" in C++, setting CMAKE_CXX_SIZEOF_DATA_PTR based on + # that, and then setting CMAKE_SIZEOF_VOID_P to *that*. + # + # The compile tests include whatever C flags may have been provided + # to CMake in the CFLAGS and CXXFLAGS environment variables. + # + # If you set an architecture flag such as -m32 or -m64 in CFLAGS + # but *not* in CXXFLAGS, the size for C++ will win, and hilarity + # will ensue. + # + # Or if, at least on Solaris, you have a newer version of GCC + # installed, but *not* a newer version of G++, and you have Oracle + # Studio installed, it will find GCC, which will default to building + # 64-bit, and Oracle Studio's C++ compiler, which will default to + # building 32-bit, the size for C++ will win, and, again, hilarity + # will ensue. + # + # So we make sure both languages have the same pointer sizes with + # the flags they're given; if they don't, it means that the + # compilers for the languages will, with those flags, not produce + # code that can be linked together. + # + # This is unlikely to happen on Haiku, but it *has* happened on + # Solaris; we do this for future-proofing, in case we ever need + # C++ on a platform where that can happen. + # + if(NOT ${CMAKE_C_SIZEOF_DATA_PTR} EQUAL ${CMAKE_CXX_SIZEOF_DATA_PTR}) + message(FATAL_ERROR +"C compiler ${CMAKE_C_COMPILER} produces code with \ +${CMAKE_C_SIZEOF_DATA_PTR}-byte pointers while C++ compiler \ +${CMAKE_CXX_COMPILER} produces code with \ +${CMAKE_CXX_SIZEOF_DATA_PTR}-byte pointers. \ +This prevents code in these languages from being combined.") + endif() +endif() + +# +# Show the bit width for which we're compiling. +# This can help debug problems if you're dealing with a compiler that +# defaults to generating 32-bit code even when running on a 64-bit +# platform, and where that platform may provide only 64-bit versions of +# libraries that we might use (looking at *you*, Oracle Studio!). +# +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + message(STATUS "Building 32-bit") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + message(STATUS "Building 64-bit") +endif() + +# +# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm +# looking at *you*!), there are separate include files for 32-bit and +# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer +# type on a 64-bit build is like crossing the beams or soething), and +# there are two separate .pc files, so if we're doing a 32-bit build we +# should make sure we look in /usr/lib/pkgconfig for .pc files and if +# we're doing a 64-bit build we should make sure we look in +# /usr/lib/amd64/pkgconfig for .pc files. +# +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") + # + # Note: string(REPLACE) does not appear to support using ENV{...} + # as an argument, so we set a variable and then use set() to set + # the environment variable. + # + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # + # 64-bit build. If /usr/lib/pkgconfig appears in the path, + # prepend /usr/lib/amd64/pkgconfig to it; otherwise, + # put /usr/lib/amd64 at the end. + # + if((NOT DEFINED ENV{PKG_CONFIG_PATH}) OR "$ENV{PKG_CONFIG_PATH}" EQUAL "") + # + # Not set, or empty. Set it to /usr/lib/amd64/pkgconfig. + # + set(fixed_path "/usr/lib/amd64/pkgconfig") + elseif("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/pkgconfig") + # + # It contains /usr/lib/pkgconfig. Prepend + # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig. + # + string(REPLACE "/usr/lib/pkgconfig" + "/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig" + fixed_path "$ENV{PKG_CONFIG_PATH}") + else() + # + # Not empty, but doesn't contain /usr/lib/pkgconfig. + # Append /usr/lib/amd64/pkgconfig to it. + # + set(fixed_path "$ENV{PKG_CONFIG_PATH}:/usr/lib/amd64/pkgconfig") + endif() + set(ENV{PKG_CONFIG_PATH} "${fixed_path}") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + # + # 32-bit build. If /usr/amd64/lib/pkgconfig appears in the path, + # prepend /usr/lib/pkgconfig to it. + # + if("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/amd64/pkgconfig") + # + # It contains /usr/lib/amd64/pkgconfig. Prepend + # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig. + # + string(REPLACE "/usr/lib/amd64/pkgconfig" + "/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig" + fixed_path "$ENV{PKG_CONFIG_PATH}") + set(ENV{PKG_CONFIG_PATH} "${fixed_path}") + endif() + endif() +endif() include(CheckCCompilerFlag) @@ -141,15 +415,17 @@ endif(MSVC) # # If we're building with MinGW, we need to specify _WIN32_WINNT as -# 0x0600 ("NT 6.0", a/k/a Vista/Windows Server 2008) in order to -# get the full IPv6 API, including inet_ntop(). +# 0x0600 ("NT 6.0", a/k/a Vista/Windows Server 2008) or higher +# in order to get the full IPv6 API, including inet_ntop(), and we +# need to specify it as 0x0601 ("NT 6.1", a/k/a Windows 7) or higher +# in order to get NdisMediumIP. # # NOTE: pcap does *NOT* work with msvcrt.dll; it must link with # a newer version of the C library, i.e. Visual Studio 2015 or # later, as it depends on C99 features introduced in VS 2015. # if(MINGW) - add_definitions(-D_WIN32_WINNT=0x0600) + add_definitions(-D_WIN32_WINNT=0x0601) endif(MINGW) # @@ -183,6 +459,7 @@ if(WIN32) option(USE_STATIC_RT "Use static Runtime" ON) endif(WIN32) option(BUILD_SHARED_LIBS "Build shared libraries" ON) +set(dpdk_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for DPDK") if(WIN32) set(Packet_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll") set(AirPcap_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for airpcap.dll") @@ -304,19 +581,19 @@ if(WIN32) endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/../../Common) find_package(Packet) - if(PACKET_FOUND) + if(Packet_FOUND) set(HAVE_PACKET32 TRUE) - include_directories(${PACKET_INCLUDE_DIRS}) + include_directories(${Packet_INCLUDE_DIRS}) # # Check whether we have the NPcap PacketIsLoopbackAdapter() # function. # cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES ${PACKET_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${Packet_LIBRARIES}) check_function_exists(PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER) check_function_exists(PacketGetTimestampModes HAVE_PACKET_GET_TIMESTAMP_MODES) cmake_pop_check_state() - endif(PACKET_FOUND) + endif(Packet_FOUND) message(STATUS "checking for Npcap's version.h") check_symbol_exists(WINPCAP_PRODUCT_NAME "${CMAKE_SOURCE_DIR}/../../version.h" HAVE_VERSION_H) @@ -380,25 +657,6 @@ if(NOT WIN32) check_include_file(sys/select.h HAVE_SYS_SELECT_H) check_include_file(netpacket/packet.h HAVE_NETPACKET_PACKET_H) - check_include_files("sys/types.h;sys/socket.h;net/if.h;net/pfvar.h" HAVE_NET_PFVAR_H) - if(HAVE_NET_PFVAR_H) - # - # Check for various PF actions. - # - check_c_source_compiles( -"#include -#include -#include -#include - -int -main(void) -{ - return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR; -} -" - HAVE_PF_NAT_THROUGH_PF_NORDR) - endif(HAVE_NET_PFVAR_H) check_include_file(netinet/if_ether.h HAVE_NETINET_IF_ETHER_H) endif(NOT WIN32) @@ -522,6 +780,10 @@ endif() # that's been set, it skips the test, so we need different variables. # set(PCAP_LINK_LIBRARIES "") +set(LIBS "") +set(LIBS_STATIC "") +set(REQUIRES_PRIVATE "") +set(LIBS_PRIVATE "") include(CheckLibraryExists) if(WIN32) # @@ -557,6 +819,9 @@ else(WIN32) # OK, we found it in libsocket. # set(PCAP_LINK_LIBRARIES socket nsl ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lsocket -lnsl ${LIBS}") + set(LIBS_STATIC "-lsocket -lnsl ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lsocket -lnsl ${LIBS_PRIVATE}") else(LIBSOCKET_HAS_GETADDRINFO) check_library_exists(network getaddrinfo "" LIBNETWORK_HAS_GETADDRINFO) if(LIBNETWORK_HAS_GETADDRINFO) @@ -564,6 +829,9 @@ else(WIN32) # OK, we found it in libnetwork (Haiku). # set(PCAP_LINK_LIBRARIES network ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lnetwork ${LIBS}") + set(LIBS_STATIC "-lnetwork ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lnetwork ${LIBS_PRIVATE}") else(LIBNETWORK_HAS_GETADDRINFO) # # We didn't find it. @@ -585,6 +853,9 @@ else(WIN32) # Yes - link with it as well. # set(PCAP_LINK_LIBRARIES xnet ${PCAP_LINK_LIBRARIES}) + set(LIBSC "-lxnet ${LIBS_LIBS}") + set(LIBS_STATIC "-lxnet ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lxnet ${LIBS_PRIVATE}") endif(LIBXNET_HAS_RECVMSG) endif(NOT STDLIBS_HAVE_GETADDRINFO) @@ -594,8 +865,20 @@ else(WIN32) check_library_exists(str putmsg "" LIBSTR_HAS_PUTMSG) if(LIBSTR_HAS_PUTMSG) set(PCAP_LINK_LIBRARIES str ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lstr ${LIBS}") + set(LIBS_STATIC "-lstr ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lstr ${LIBS_PRIVATE}") endif(LIBSTR_HAS_PUTMSG) endif(NOT STDLIBS_HAVE_PUTMSG) + + # Haiku has getpass in libbsd + check_function_exists(getpass STDLIBS_HAVE_GETPASS) + if(NOT STDLIBS_HAVE_GETPASS) + check_library_exists(bsd getpass "" LIBBSD_HAS_GETPASS) + if(LIBBSD_HAS_GETPASS) + set(PCAP_LINK_LIBRARIES bsd ${PCAP_LINK_LIBRARIES}) + endif(LIBBSD_HAS_GETPASS) + endif(NOT STDLIBS_HAVE_GETPASS) endif(WIN32) # @@ -1049,6 +1332,76 @@ if(OPENSSL_FOUND) # include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${OPENSSL_LIBRARIES}) + + # + # The find_package() module CMake provides for OpenSSL uses does not + # give us a defined indication of whether it found OpenSSL with + # pkg-config or not. We need to know that as, if it was found with + # pkg-config, we should set the Requires.private value in libpcap.pc + # to include its package name, openssl, otherwise we should add the + # names for the static libraries to Libs.private. + # + # On UN*X, FindOpenSSL happens to use pkg-config to find OpenSSL, but + # it doesn't appear to be documented as doing so; therefore, we don't + # assume that, if we got here, we have pkg-config. + # + # So we use pkg_get_link_info() to run pkg-config ourselves, both + # because FindOpenSSL doesn't set the OPENSSL_LDFLAGS or + # OPENSSL_STATIC_LDFLAGS variables and because, for reasons explained + # in the comment before the pkg_get_link_info() macro, even if it did, + # it wouldn't be what we want anyway. + # + if (PKG_CONFIG_EXECUTABLE) + pkg_get_link_info(OPENSSL openssl) + if (OPENSSL_FOUND_WITH_PKG_CONFIG) + # + # pkg-config failed; assume that means that there is no openssl + # package for it to find. Just add OPENSSL_LIBRARIES to + # LIBS_PRIVATE AND LIBS_STATIC, as that's the + # best we can do. XXX - need list of -l and -L flags to add.... + # + set(LIBS "${LIBS} ${OPENSSL_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${OPENSSL_LIBS_STATIC}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${OPENSSL_PACKAGE_NAME}") + endif() + else() + # Get it from OPENSSL_LIBRARIES + foreach(_lib IN LISTS OPENSSL_LIBRARIES) + # + # Get the directory in which the library resides. + # + get_filename_component(_lib_directory "${_lib}" DIRECTORY) + + # + # Is the library directory in CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES? + # (See comment above on why we use that.) + # + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_lib_directory}" _lib_index) + if(_lib_index EQUAL -1) + # + # No, so add a -L flag to get the linker to search in that + # directory. + # + set(LIBS "${LIBS} -L${_lib_directory}") + set(LIBS_STATIC "${LIBS_STATIC} -L${_lib_directory}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -L${_lib_directory}") + endif() + + # + # Get the file name of the library, without the extension. + # + get_filename_component(_lib_filename "${_lib}" NAME_WE) + + # + # Strip off the "lib" prefix to get the library name, and + # add a -l flag based on that. + # + string(REGEX REPLACE "^lib" "" _library_name "${_lib_filename}") + set(LIBS "${LIBS} -l${_library_name}") + set(LIBS_STATIC "${LIBS_STATIC} -l${_library_name}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -l${_library_name}") + endforeach() + endif() set(HAVE_OPENSSL YES) endif(OPENSSL_FOUND) @@ -1078,6 +1431,8 @@ set(PROJECT_SOURCE_LIST_C nametoaddr.c optimize.c pcap-common.c + pcap-usb-linux-common.c + pcap-util.c pcap.c savefile.c sf-pcapng.c @@ -1255,6 +1610,9 @@ else() # Nothing we support. # set(PCAP_TYPE null) + message(WARNING +"cannot determine packet capture interface +(see the INSTALL.md file for more info)") endif() endif() endif(WIN32) @@ -1270,7 +1628,7 @@ if(WIN32) # # Link with packet.dll before Winsock2. # - set(PCAP_LINK_LIBRARIES ${PACKET_LIBRARIES} ${PCAP_LINK_LIBRARIES}) + set(PCAP_LINK_LIBRARIES ${Packet_LIBRARIES} ${PCAP_LINK_LIBRARIES}) elseif(PCAP_TYPE STREQUAL "null") else() message(FATAL_ERROR "${PCAP_TYPE} is not a valid pcap type") @@ -1309,6 +1667,9 @@ else(WIN32) # XXX - add -L/lib # set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} dlpi) + set(LIBS "${LIBS} -ldlpi") + set(LIBS_STATIC "${LIBS_STATIC} -ldlpi") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -ldlpi") set(PCAP_TYPE libdlpi) endif() @@ -1341,9 +1702,17 @@ else(WIN32) # let's drop support for older versions of libnl, too. # if(BUILD_WITH_LIBNL) - pkg_check_modules(LIBNL libnl-3.0) + pkg_check_modules(LIBNL libnl-genl-3.0) if(LIBNL_FOUND) set(PCAP_LINK_LIBRARIES ${LIBNL_LIBRARIES} ${PCAP_LINK_LIBRARIES}) + + # + # Get raw link flags from pkg-config. + # + pkg_get_link_info(LIBNL libnl-genl-3.0) + set(LIBS "${LIBNL_LIBS} ${LIBS}") + set(LIBS_STATIC "${LIBNL_LIBS_STATIC} ${LIBS_STATIC}") + set(REQUIRES_PRIVATE "${LIBNL_PACKAGE_NAME} ${REQUIRES_PRIVATE}") else() cmake_push_check_state() set(CMAKE_REQUIRED_LIBRARIES nl-3) @@ -1355,6 +1724,9 @@ else(WIN32) # set(PCAP_LINK_LIBRARIES nl-genl-3 nl-3 ${PCAP_LINK_LIBRARIES}) include_directories("/usr/include/libnl3") + set(LIBS "-lnl-genl-3 -lnl-3 ${LIBS}") + set(LIBS_STATIC "-lnl-genl-3 -lnl-3 ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lnl-genl-3 -lnl-3 ${LIBS_PRIVATE}") endif() endif() else() @@ -1437,6 +1809,9 @@ if(NOT WIN32) check_library_exists(socket getifaddrs "" SOCKET_HAS_GETIFADDRS) if(SOCKET_HAS_GETIFADDRS) set(PCAP_LINK_LIBRARIES socket ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lsocket ${LIBS}") + set(LIBS_STATIC "-lsocket ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lsocket ${LIBS_PRIVATE}") set(HAVE_GETIFADDRS TRUE) endif() endif() @@ -1514,7 +1889,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(NOT DISABLE_LINUX_USBMON) set(PCAP_SUPPORT_LINUX_USBMON TRUE) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-usb-linux.c) - set(LINUX_USB_MON_DEV /dev/usbmon) # # Do we have a version of available? # If so, we might need it for . @@ -1605,25 +1979,23 @@ if(NOT DISABLE_DPDK) find_package(dpdk) if(dpdk_FOUND) # - # We include rte_bus.h, and older versions of DPDK didn't have - # it, so check for it. - # - # Also, we call rte_eth_dev_count_avail(), and older versions - # of DPDK didn't have it, so check for it. + # We call rte_eth_dev_count_avail(), and older versions of DPDK + # didn't have it, so check for it. # cmake_push_check_state() set(CMAKE_REQUIRED_INCLUDES ${dpdk_INCLUDE_DIRS}) - check_include_file(rte_bus.h HAVE_RTE_BUS_H) set(CMAKE_REQUIRED_LIBRARIES ${dpdk_LIBRARIES}) check_function_exists(rte_eth_dev_count_avail HAVE_RTE_ETH_DEV_COUNT_AVAIL) cmake_pop_check_state() - if(HAVE_RTE_BUS_H AND HAVE_RTE_ETH_DEV_COUNT_AVAIL) + if(HAVE_RTE_ETH_DEV_COUNT_AVAIL) set(DPDK_C_FLAGS "-march=native") - set(DPDK_LIB dpdk rt m numa dl) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${DPDK_C_FLAGS}) include_directories(AFTER ${dpdk_INCLUDE_DIRS}) link_directories(AFTER ${dpdk_LIBRARIES}) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${dpdk_LIBRARIES}) + set(LIBS "${LIBS} ${dpdk_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${dpdk_LIBS_STATIC}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${dpdk_PACKAGE_NAME}") set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dpdk.c) set(PCAP_SUPPORT_DPDK TRUE) @@ -1639,6 +2011,11 @@ if(NOT DISABLE_DPDK) check_type_size("struct rte_ether_addr" STRUCT_RTE_ETHER_ADDR) cmake_pop_check_state() endif() + else() + message(WARNING, +"We couldn't find DPDK with pkg-config. If you want DPDK support, +make sure that pkg-config is installed, that DPDK 18.02.2 or later is +installed, and that DPDK provides a .pc file.") endif() endif() @@ -1721,22 +2098,80 @@ if(NOT DISABLE_DBUS) list(APPEND DBUS_LIBRARY_FULLPATHS ${_libfullpath}) endforeach() set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DBUS_LIBRARY_FULLPATHS}) + + # + # Get library information for DPDK. + # + pkg_get_link_info(DBUS dbus-1) + set(LIBS "${LIBS} ${DBUS_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${DBUS_LIBS_STATIC}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${DBUS_PACKAGE_NAME}") endif(DBUS_FOUND) endif(NOT DISABLE_DBUS) # Check for RDMA sniffing support if(NOT DISABLE_RDMA) - check_library_exists(ibverbs ibv_get_device_list "" LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) - if(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + pkg_check_modules(LIBIBVERBS libibverbs) + if(LIBIBVERBS_FOUND) + # + # pkg-config found it; remember its pkg-config name. + # + set(LIBIBVERBS_REQUIRES_PRIVATE ${LIBIBVERBS_PACKAGE_NAME}) + + # + # Get static linking information for it. + # + pkg_get_link_info(LIBIBVERBS libibverbs) + else() + # + # pkg-config didn't find it; try to look for it ourselves + # + check_library_exists(ibverbs ibv_get_device_list "" LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + if(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + set(LIBIBVERBS_FOUND TRUE) + set(LIBIBVERBS_LIBRARIES ibverbs) + # XXX - at least on Ubuntu 20.04, there are many more + # libraries needed; is there any platform where + # libibverbs is available but where pkg-config + # isn't available or libibverbs doesn't use it? + # If not, we should only use pkg-config for it. + set(LIBIBVERBS_STATIC_LIBRARIES ibverbs) + set(LIBIBVERBS_LIBS -libverbs) + set(LIBIBVERBS_LIBS_STATIC -libverbs) + set(LIBIBVERBS_LIBS_PRIVATE -libverbs) + endif() + endif() + if(LIBIBVERBS_FOUND) + # + # For unknown reasons, check_include_file() doesn't just attempt + # to compile a test program that includes the header in + # question, it also attempts to link it. + # + # For unknown reasons, at least some of the static inline + # functions defined in infiniband/verbs.h are not inlined by the + # Sun^WOracle Studio C compiler, so the compiler generates code + # for them as part of the object code resulting from compiling + # the test program. At lest some of those functions call + # routines in -libverbs, so, in order to keep the compile and + # link from failing, even though the header file exists and is + # usable, we need to link with -libverbs. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ${LIBIBVERBS_LIBRARIES}) check_include_file(infiniband/verbs.h HAVE_INFINIBAND_VERBS_H) if(HAVE_INFINIBAND_VERBS_H) check_symbol_exists(ibv_create_flow infiniband/verbs.h PCAP_SUPPORT_RDMASNIFF) if(PCAP_SUPPORT_RDMASNIFF) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-rdmasniff.c) - set(PCAP_LINK_LIBRARIES ibverbs ${PCAP_LINK_LIBRARIES}) + set(PCAP_LINK_LIBRARIES ${LIBIBVERBS_LIBRARIES} ${PCAP_LINK_LIBRARIES}) + set(LIBS "${LIBIBVERBS_LIBS} ${LIBS}") + set(LIBS_STATIC "${LIBIBVERBS_LIBS_STATIC} ${LIBS_STATIC}") + set(LIBS_PRIVATE "${LIBIBVERBS_LIBS_PRIVATE} ${LIBS_PRIVATE}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${LIBIBVERBS_PACKAGE_NAME}") endif(PCAP_SUPPORT_RDMASNIFF) endif(HAVE_INFINIBAND_VERBS_H) - endif(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + cmake_pop_check_state() + endif(LIBIBVERBS_FOUND) endif(NOT DISABLE_RDMA) # @@ -1774,12 +2209,18 @@ if(NOT DISABLE_DAG) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dag.c) set(HAVE_DAG_API TRUE) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DAG_LIBRARIES}) + set(LIBS "${LIBS} ${DAG_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${DAG_LIBS_STATIC}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} ${DAG_LIBS_PRIVATE}") if(HAVE_DAG_LARGE_STREAMS_API) get_filename_component(DAG_LIBRARY_DIR ${DAG_LIBRARY} PATH) check_library_exists(vdag vdag_set_device_info ${DAG_LIBRARY_DIR} HAVE_DAG_VDAG) if(HAVE_DAG_VDAG) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + set(LIBS "${LIBS} ${CMAKE_THREAD_LIBS_INIT}") + set(LIBS_STATIC "${LIBS_STATIC} ${CMAKE_THREAD_LIBS_INIT}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} ${CMAKE_THREAD_LIBS_INIT}") endif() endif() endif() @@ -1825,6 +2266,9 @@ if(NOT DISABLE_SNF) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-snf.c) set(HAVE_SNF_API TRUE) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${SNF_LIBRARIES}) + set(LIBS "${LIBS_STATIC} ${SNF_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${SNF_LIBS_STATIC}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} ${SNF_LIBS_PRIVATE}") endif() endif() @@ -1838,14 +2282,14 @@ if(NOT DISABLE_AIRPCAP) # # Did we succeed? # - if(AIRPCAP_FOUND) + if(AirPcap_FOUND) # # Yes. # - include_directories(AFTER ${AIRPCAP_INCLUDE_DIRS}) + include_directories(AFTER ${AirPcap_INCLUDE_DIRS}) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-airpcap.c) set(HAVE_AIRPCAP_API TRUE) - set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${AIRPCAP_LIBRARIES}) + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${AirPcap_LIBRARIES}) endif() endif() @@ -2050,6 +2494,19 @@ if(NOT MSVC) endif() endif(NOT MSVC) +# +# Extra compiler options for the build matrix scripts to request -Werror or +# its equivalent if required. The CMake variable name cannot be CFLAGS +# because that is already used for a different purpose in CMake. Example +# usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ... +# +if(NOT "${EXTRA_CFLAGS}" STREQUAL "") + foreach(_extra_cflag ${EXTRA_CFLAGS}) + check_and_add_compiler_option("${_extra_cflag}") + endforeach(_extra_cflag) + message(STATUS "Added extra compile options (${EXTRA_CFLAGS})") +endif() + # # Flex/Lex and YACC/Berkeley YACC/Bison. # From a mail message to the CMake mailing list by Andy Cedilnik of @@ -2065,6 +2522,28 @@ if(LEX_EXECUTABLE STREQUAL "LEX_EXECUTABLE-NOTFOUND") endif() message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}") +# +# Make sure {f}lex supports the -P, --header-file, and --nounput flags +# and supports processing our scanner.l. +# +if(WIN32) + set(NULL_DEVICE "NUL:") +else() + set(NULL_DEVICE "/dev/null") +endif() +execute_process(COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=${NULL_DEVICE} --nounput -t ${pcap_SOURCE_DIR}/scanner.l + OUTPUT_QUIET RESULT_VARIABLE EXIT_STATUS) +if(NOT EXIT_STATUS EQUAL 0) + message(FATAL_ERROR "${LEX_EXECUTABLE} is insufficient to compile libpcap. +libpcap requires Flex 2.5.31 or later, or a compatible version of lex. +If a suitable version of Lex/Flex is available as a non-standard command +and/or not in the PATH, you can specify it using the LEX environment +variable. That said, on some systems the error can mean that Flex/Lex is +actually acceptable, but m4 is not. Likewise, if a suitable version of +m4 (such as GNU M4) is available but has not been detected, you can +specify it using the M4 environment variable.") +endif() + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h SOURCE ${pcap_SOURCE_DIR}/scanner.l @@ -2097,6 +2576,25 @@ if(YACC_EXECUTABLE STREQUAL "YACC_EXECUTABLE-NOTFOUND") endif() if(YACC_EXECUTABLE MATCHES "byacc" OR YACC_EXECUTABLE MATCHES "yacc") + # + # Make sure this is Berkeley YACC, not AT&T YACC; + # the latter doesn't support reentrant parsers. + # Run it with "-V"; that succeeds and reports the + # version number with Berkeley YACC, but will + # (probably) fail with various vendor flavors + # of AT&T YACC. + # + # Hopefully this also eliminates any versions + # of Berkeley YACC that don't support reentrant + # parsers, if there are any. + # + execute_process(COMMAND ${YACC_EXECUTABLE} -V OUTPUT_QUIET + RESULT_VARIABLE EXIT_STATUS) + if(NOT EXIT_STATUS EQUAL 0) + message(FATAL_ERROR "${YACC_EXECUTABLE} is insufficient to compile libpcap. +libpcap requires Bison, a newer version of Berkeley YACC with support +for reentrant parsers, or another YACC compatible with them.") + endif() # # Berkeley YACC doesn't support "%define api.pure", so use # "%pure-parser". @@ -2162,6 +2660,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") # we use them to load the BPF module. # set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} odm cfg) + set(LIBS "${LIBS} -lodm -lcfg") + set(LIBS_STATIC "${LIBS_STATIC} -lodm -lcfg") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -lodm -lcfg") endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") if(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*9\.[0-9]*") @@ -2200,7 +2701,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "IRIX" OR CMAKE_SYSTEM_NAME STREQUAL "IRIX64") set(MAN_MISC_INFO 5) elseif(CMAKE_SYSTEM_NAME STREQUAL "OSF1") # - # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX. + # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX. # Use Tru64 UNIX conventions for man pages; they're the same as the # System V conventions except that they use section 8 for # administrative commands and daemons. @@ -2445,13 +2946,10 @@ if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") # captures.) # set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386;ppc") - else() + elseif(SYSTEM_VERSION_MAJOR GREATER 10 AND SYSTEM_VERSION_MAJOR LESS 19) # - # Post-Snow Leopard. Build for x86-64 and 32-bit x86, - # with x86-64 first. (That's what Apple does) - # XXX - update if and when Apple drops support - # for 32-bit x86 code and if and when Apple adds - # ARM-based Macs. (You're on your own for iOS etc.) + # Post-Snow Leopard, pre-Catalina. Build for x86-64 + # and 32-bit x86, with x86-64 first. (That's what Apple does) # # First, check whether we're building with OpenSSL. # If so, don't bother trying to build fat. @@ -2494,6 +2992,61 @@ main(void) endif() endif() endif() + elseif(SYSTEM_VERSION_MAJOR EQUAL 19) + # + # Catalina. Build libraries and executables + # only for x86-64. (That's what Apple does; + # 32-bit x86 binaries are not supported on + # Catalina.) + # + set(OSX_LIBRARY_ARCHITECTURES "x86_64") + else() + # + # Post-Catalina. Build libraries and + # executables for x86-64 and ARM64. + # (That's what Apple does, except they + # build for arm64e, which may include + # some of the pointer-checking extensions.) + # + # If we're building with libssl, make sure + # we can build fat with it (i.e., that it + # was built fat); if we can't, don't set + # the target architectures, and just + # build for the host we're on. + # + # Otherwise, just add both of them. + # + if(HAVE_OPENSSL) + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "-arch x86_64 -arch arm64") + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + # + # We must test whether this compiles and links, so + # check_symbol_exists() isn't sufficient. + # + # SSL_library_init() may be a macro that's #defined + # to be the real function to call, so we have to + # include , and check_function_exists() + # isn't sufficient. + # + check_c_source_compiles( +"#include +int +main(void) +{ + SSL_library_init(); + return 0; +} +" + FAT_SSL_BUILDS_SUPPORTED) + cmake_pop_check_state() + if(FAT_SSL_BUILDS_SUPPORTED) + set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64") + endif() + else() + set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64") + endif() endif() if(BUILD_SHARED_LIBS) set_target_properties(${LIBRARY_NAME} PROPERTIES @@ -2619,7 +3172,9 @@ set(MAN3PCAP_NOEXPAND pcap_tstamp_type_name_to_val.3pcap pcap_tstamp_type_val_to_name.3pcap ) -set(MANFILE_EXPAND pcap-savefile.manfile.in) +set(MANFILE_EXPAND + pcap-savefile.manfile.in +) set(MANMISC_EXPAND pcap-filter.manmisc.in pcap-linktype.manmisc.in @@ -2633,6 +3188,11 @@ else(BUILD_SHARED_LIBS) endif(BUILD_SHARED_LIBS) if(WIN32 OR CYGWIN OR MSYS) + # + # XXX - according to the CMake documentation, WIN32 is set if + # the target is Windows; would there ever be a case where + # CYGWIN or MSYS are set but WIN32 *isn't* set? + # if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) # # Install 64-bit code built with MSVC in the x64 subdirectories, @@ -2685,36 +3245,69 @@ if(NOT MSVC) set(exec_prefix "\${prefix}") set(includedir "\${prefix}/include") set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") - if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "DragonFly BSD" OR - CMAKE_SYSTEM_NAME STREQUAL "Linux" OR - CMAKE_SYSTEM_NAME STREQUAL "OSF1") - # - # Platforms where the linker is the GNU linker - # or accepts command-line arguments like - # those the GNU linker accepts. - # - set(V_RPATH_OPT "-Wl,-rpath,") - elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") - # - # SunOS 5.x. - # - # XXX - this assumes GCC is using the Sun linker, - # rather than the GNU linker. - # - set(V_RPATH_OPT "-Wl,-R,") - else() - # - # No option needed to set the RPATH. - # - set(V_RPATH_OPT "") + + # + # If this is a platform where we need to have the .pc file and + # pcap-config script supply an rpath option to specify the directory + # in which the libpcap shared library is installed, and the install + # prefix /usr (meaning we're not installing a system library), + # provide the rpath option. + # + # (We must check CMAKE_INSTALL_PREFIX, as the library directory + # isn't necessarily /usr/lib in this case - for example, Linux + # distributions for 64-bit platforms that also provide support for + # binaries for a 32-bit version of the platform may put the 64-bit + # libraries, the 32-bit libraries, or both in directories other than + # /usr/lib.) + # + # In AIX, do we have to do this? + # + # In Darwin-based OSes, the full paths of the shared libraries with + # which the program was linked are stored in the executable, so we + # don't need to provide an rpath option. + # + # With the HP-UX linker, directories specified with -L are, by + # default, added to the run-time search path, so we don't need to + # supply them. + # + # For Tru64 UNIX, "-rpath" works with DEC's^WCompaq's^WHP's C + # compiler for Alpha, but isn't documented as working with GCC, and + # no GCC-compatible option is documented as working with the DEC + # compiler. If anybody needs this on Tru64/Alpha, they're welcome + # to figure out a way to make it work. + # + # This must *not* depend on the compiler, as, on platforms where + # there's a GCC-compatible compiler and a vendor compiler, we need + # to work with both. + # + if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr") + if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "DragonFly BSD" OR + CMAKE_SYSTEM_NAME STREQUAL "Linux") + # + # Platforms where the "native" C compiler is GCC or accepts + # compatible command-line arguments, and the "native" linker + # is the GNU linker or accepts compatible command-line + # arguments. + # + set(RPATH "-Wl,-rpath,\${libdir}") + elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") + # + # SunOS 5.x. + # + # Sun/Oracle's linker, the GNU linker, and GNU-compatible + # linkers all support -R. + # + set(RPATH "-Wl,-R,\${libdir}") + else() + # + # No option needed to set the RPATH. + # + set(RPATH "") + endif() endif() - set(LIBS "") - foreach(LIB ${PCAP_LINK_LIBRARIES}) - set(LIBS "${LIBS} -l${LIB}") - endforeach(LIB) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pcap-config DESTINATION bin) diff --git a/libpcap/CONTRIBUTING.md b/libpcap/CONTRIBUTING.md index 69b597260..fb22c5e38 100644 --- a/libpcap/CONTRIBUTING.md +++ b/libpcap/CONTRIBUTING.md @@ -14,10 +14,10 @@ above), please navigate to https://github.com/the-tcpdump-group/libpcap/issues and check if the problem has already been reported. If it has not, please open a new issue and provide the following details: -* libpcap version (e.g. from tcpdump --version) +* libpcap version (e.g. from `tcpdump --version`) * operating system name and version and any other details that may be relevant - (uname -a, compiler name and version, CPU type etc.) -* configure flags if any were used + (`uname -a`, compiler name and version, CPU type etc.) +* `configure` or `cmake` flags if any were used * statement of the problem * steps to reproduce diff --git a/libpcap/CREDITS b/libpcap/CREDITS index d01e83221..4b820ee7b 100644 --- a/libpcap/CREDITS +++ b/libpcap/CREDITS @@ -33,6 +33,7 @@ Additional people who have contributed patches (in alphabetical order): Baptiste Peugnez Baruch Siach Bill Parker + Biswapriyo Nath blazeable bleader Brent Cook @@ -58,6 +59,7 @@ Additional people who have contributed patches (in alphabetical order): Dave Barach David Clark David Kaelbling + David Karoly David Ward David Young Dean Gaudet @@ -68,11 +70,13 @@ Additional people who have contributed patches (in alphabetical order): Dustin Spicuzza dzejarczech Edward Sheldrake + Eli Schwartz Eric Anderson Erik de Castro Lopo Fedor Sakharov Felix Janda Felix Obenhuber + fghzxm Florent Drouin Florian Fainelli François Revol @@ -132,6 +136,7 @@ Additional people who have contributed patches (in alphabetical order): Kris Katterjohn Krzysztof Halasa Lennert Buytenhek + Li kunyu lixiaoyan Lorenzo Cavallaro Loris Degioanni @@ -157,6 +162,7 @@ Additional people who have contributed patches (in alphabetical order): Max Laier Michal Kubecek Michal Labedzki + Michal Ruprich Michal Sekletar Mike Frysinger Mike Kershaw @@ -166,6 +172,7 @@ Additional people who have contributed patches (in alphabetical order): Monroe Williams Myricom Help Nan Xiao + nic-kaczinsky <68271784+nic-kaczinsky at users dot noreply dot github dot com> Nick Kelsey Nicolas Dade Niko Delarich @@ -181,7 +188,7 @@ Additional people who have contributed patches (in alphabetical order): Ørjan Malde Paolo Abeni Patrick Marie - Patrick McHardy + Patrick McHardy Paul Mundt Pavel Kankovsky Pawel Brzezinski @@ -193,6 +200,7 @@ Additional people who have contributed patches (in alphabetical order): Philippe Antoine Phil Wood Rafal Maszkowski + ramin Richard Stearn Rick Jones @@ -208,6 +216,7 @@ Additional people who have contributed patches (in alphabetical order): Sebastian Krahmer Sebastien Roy Sepherosa Ziehau + Shane Kerr Shaun Clowes solofox Solomon Peachy diff --git a/libpcap/INSTALL.md b/libpcap/INSTALL.md index feef03dc8..d0a19d811 100644 --- a/libpcap/INSTALL.md +++ b/libpcap/INSTALL.md @@ -1,105 +1,120 @@ -To build libpcap, run "./configure" (a shell script). The configure -script will determine your system attributes and generate an -appropriate Makefile from Makefile.in. Next run "make". If everything -goes well you can su to root and run "make install". However, you need -not install libpcap if you just want to build tcpdump; just make sure -the tcpdump and libpcap directory trees have the same parent -directory. +# libpcap installation notes +Libpcap can be built either with the configure script and `make`, or +with CMake and any build system supported by CMake. + +To build libpcap with the configure script and `make`: + +* Run `./configure` (a shell script). The configure script will +determine your system attributes and generate an appropriate `Makefile` +from `Makefile.in`. The configure script has a number of options to +control the configuration of libpcap; `./configure --help`` will show +them. + +* Next, run `make`. If everything goes well, you can +`su` to root and run `make install`. However, you need not install +libpcap if you just want to build tcpdump; just make sure the tcpdump +and libpcap directory trees have the same parent directory. + +To build libpcap with CMake and the build system of your choice, from +the command line: + +* Create a build directory into which CMake will put the build files it +generates; CMake does not work as well with builds done in the source +code directory as does the configure script. The build directory may be +created as a subdirectory of the source directory or as a directory +outside the source directory. + +* Change to the build directory and run CMake with the path from the +build directory to the source directory as an argument. The `-G` flag +can be used to select the CMake "generator" appropriate for the build +system you're using; various `-D` flags can be used to control the +configuration of libpcap. + +* Run the build tool. If everything goes well, you can `su` to root and +run the build tool with the `install` target. Building tcpdump from a +libpcap in a build directory is not supported. + +An `uninstall` target is supported with both `./configure` and CMake. + +***DO NOT*** run the build as root; there is no need to do so, running +anything as root that doesn't need to be run as root increases the risk +of damaging your system, and running the build as root will put files in +the build directory that are owned by root and that probably cannot be +overwritten, removed, or replaced except by root, which could cause +permission errors in subsequent builds. If configure says: configure: warning: cannot determine packet capture interface - configure: warning: (see INSTALL for more info) + configure: warning: (see INSTALL.md file for more info) + +or CMake says: + + cannot determine packet capture interface + + (see the INSTALL.md file for more info) then your system either does not support packet capture or your system does support packet capture but libpcap does not support that particular type. (If you have HP-UX, see below.) If your system uses a packet capture not supported by libpcap, please send us patches; don't forget to include an autoconf fragment suitable for use in -configure.ac. +`configure.ac`. -It is possible to override the default packet capture type, although -the circumstance where this works are limited. For example if you have -installed bpf under SunOS 4 and wish to build a snit libpcap: +It is possible to override the default packet capture type with the +`--with-pcap`` option to `./configure` or the `-DPCAP_TYPE` option to +CMake, although the circumstances where this works are limited. One +possible reason to do that would be to force a supported packet capture +type in the case where the configure or CMake scripts fails to detect +it. - ./configure --with-pcap=snit - -Another example is to force a supported packet capture type in the case -where the configure scripts fails to detect it. - -You will need an ANSI C compiler to build libpcap. The configure script -will abort if your compiler is not ANSI compliant. If this happens, use -the generally available GNU C compiler (GCC). +You will need a C99 compiler to build libpcap. The configure script +will abort if your compiler is not C99 compliant. If this happens, use +the generally available GNU C compiler (GCC) or Clang. You will need either Flex 2.5.31 or later, or a version of Lex compatible with it (if any exist), to build libpcap. The configure -script will abort if there isn't any such program. If you have an older -version of Flex, or don't have a compatible version of Lex, the current -version of flex is available at flex.sourceforge.net. +script will abort if there isn't any such program; CMake fails if Flex +or Lex cannot be found, but doesn't ensure that it's compatible with +Flex 2.5.31 or later. If you have an older version of Flex, or don't +have a compatible version of Lex, the current version of Flex is +available [here](https://github.com/westes/flex). You will need either Bison, Berkeley YACC, or a version of YACC compatible with them (if any exist), to build libpcap. The configure -script will abort if there isn't any such program. If you don't have -any such program, the current version of Bison can be found at -https://ftp.gnu.org/gnu/bison/ and the current version of Berkeley YACC -can be found at https://invisible-island.net/byacc/. +script will abort if there isn't any such program; CMake fails if Bison +or some form of YACC cannot be found, but doesn't ensure that it's +compatible with Bison or Berkeley YACC. If you don't have any such +program, the current version of Bison can be found +[here](https://ftp.gnu.org/gnu/bison/) and the current version of +Berkeley YACC can be found [here](https://invisible-island.net/byacc/). Sometimes the stock C compiler does not interact well with Flex and -Bison. The list of problems includes undefined references for alloca. +Bison. The list of problems includes undefined references for alloca(3). You can get around this by installing GCC. -If you use Solaris, there is a bug with bufmod(7) that is fixed in -Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the -broken bufmod(7) results in data be truncated from the FRONT of the -packet instead of the end. The work around is to not set a snapshot -length but this results in performance problems since the entire packet -is copied to user space. If you must run an older version of Solaris, -there is a patch available from Sun; ask for bugid 1149065. After -installing the patch, use "setenv BUFMOD_FIXED" to enable use of -bufmod(7). However, we recommend you run a more current release of -Solaris. +## Linux specifics +On Linux, libpcap will not work if the kernel does not have the packet +socket option enabled; see [this file](doc/README.linux) for more +information. +## Solaris specifics If you use the SPARCompiler, you must be careful to not use the -/usr/ucb/cc interface. If you do, you will get bogus warnings and -perhaps errors. Either make sure your path has /opt/SUNWspro/bin -before /usr/ucb or else: +`/usr/ucb/cc` interface. If you do, you will get bogus warnings and +perhaps errors. Either make sure your path has `/opt/SUNWspro/bin` +before `/usr/ucb` or else: setenv CC /opt/SUNWspro/bin/cc -before running configure. (You might have to do a "make distclean" -if you already ran configure once). +before running configure. (You might have to do a `make distclean` +if you already ran `configure` once). -If you are trying to do packet capture with a FORE ATM card, you may or -may not be able to. They usually only release their driver in object -code so unless their driver supports packet capture, there's not much -libpcap can do. - -If you get an error like: - - tcpdump: recv_ack: bind error 0x??? - -when using DLPI, look for the DL_ERROR_ACK error return values, usually -in /usr/include/sys/dlpi.h, and find the corresponding value. - -Under {DEC OSF/1, Digital UNIX, Tru64 UNIX}, packet capture must be -enabled before it can be used. For instructions on how to enable packet -filter support, see: - - ftp://ftp.digital.com/pub/Digital/dec-faq/Digital-UNIX - -Look for the "How do I configure the Berkeley Packet Filter and capture -tcpdump traces?" item. - -Once you enable packet filter support, your OSF system will support bpf -natively. - -Under Ultrix, packet capture must be enabled before it can be used. For -instructions on how to enable packet filter support, see: - - ftp://ftp.digital.com/pub/Digital/dec-faq/ultrix +See [this file](doc/README.solaris.md) for more up to date +Solaris-related information. +## HP-UX specifics If you use HP-UX, you must have at least version 9 and either the -version of cc that supports ANSI C (cc -Aa) or else use the GNU C +version of `cc` that supports C99 (`cc -AC99`) or else use the GNU C compiler. You must also buy the optional streams package. If you don't have: @@ -113,10 +128,10 @@ need to install the "9.X LAN and DLPI drivers cumulative" patch The DLPI streams package is standard starting with HP-UX 10. The HP implementation of DLPI is a little bit eccentric. Unlike -Solaris, you must attach /dev/dlpi instead of the specific /dev/* +Solaris, you must attach `/dev/dlpi` instead of the specific `/dev/*` network pseudo device entry in order to capture packets. The PPA is based on the ifnet "index" number. Under HP-UX 9, it is necessary to -read /dev/kmem and the kernel symbol file (/hp-ux). Under HP-UX 10, +read `/dev/kmem` and the kernel symbol file (`/hp-ux`). Under HP-UX 10, DLPI can provide information for determining the PPA. It does not seem to be possible to trace the loopback interface. Unlike other DLPI implementations, PHYS implies MULTI and SAP and you get an error if you @@ -137,117 +152,34 @@ doing echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem -You would have to arrange that this happen on reboots; the right way to +You would have to arrange that this happens on reboots; the right way to do that would probably be to put it into an executable script file -"/sbin/init.d/outbound_promisc" and making -"/sbin/rc2.d/S350outbound_promisc" a symbolic link to that script. +`/sbin/init.d/outbound_promisc` and making +`/sbin/rc2.d/S350outbound_promisc` a symbolic link to that script. Finally, testing shows that there can't be more than one simultaneous DLPI user per network interface. -If you use Linux, this version of libpcap is known to compile and run -under Red Hat 4.0 with the 2.0.25 kernel. It may work with earlier 2.X -versions but is guaranteed not to work with 1.X kernels. Running more -than one libpcap program at a time, on a system with a 2.0.X kernel, can -cause problems since promiscuous mode is implemented by twiddling the -interface flags from the libpcap application; the packet capture -mechanism in the 2.2 and later kernels doesn't have this problem. Also, -packet timestamps aren't very good. This appears to be due to haphazard -handling of the timestamp in the kernel. +See [this file](doc/README.hpux) for more information specific to HP-UX. -Note well: there is rumoured to be a version of tcpdump floating around -called 3.0.3 that includes libpcap and is supposed to support Linux. -You should be advised that neither the Network Research Group at LBNL -nor the Tcpdump Group ever generated a release with this version number. -The LBNL Network Research Group notes with interest that a standard -cracker trick to get people to install trojans is to distribute bogus -packages that have a version number higher than the current release. -They also noted with annoyance that 90% of the Linux related bug reports -they got are due to changes made to unofficial versions of their page. -If you are having trouble but aren't using a version that came from -tcpdump.org, please try that before submitting a bug report! - -On Linux, libpcap will not work if the kernel does not have the packet -socket option enabled; see the README.linux file for information about -this. - -If you use AIX, you may not be able to build libpcap from this release. -We do not have an AIX system in house so it's impossible for us to test -AIX patches submitted to us. We are told that you must link against -/lib/pse.exp, that you must use AIX cc or a GNU C compiler newer than -2.7.2, and that you may need to run strload before running a libpcap -application. - -Read the README.aix file for information on installing libpcap and +## AIX specifics +See [this file](doc/README.aix) for information on installing libpcap and configuring your system to be able to support libpcap. -If you use NeXTSTEP, you will not be able to build libpcap from this -release. +## other specifics +If you are trying to do packet capture with a FORE ATM card, you may or +may not be able to. They usually only release their driver in object +code so unless their driver supports packet capture, there's not much +libpcap can do. -If you use SINIX, you should be able to build libpcap from this -release. It is known to compile and run on SINIX-Y/N 5.42 with the C-DS -V1.0 or V1.1 compiler. But note that in some releases of SINIX, yacc -emits incorrect code; if grammar.y fails to compile, change every -occurrence of: +If you get an error like: - #ifdef YYDEBUG + tcpdump: recv_ack: bind error 0x??? -to: - #if YYDEBUG +when using DLPI, look for the DL_ERROR_ACK error return values, usually +in `/usr/include/sys/dlpi.h`, and find the corresponding value. -Another workaround is to use flex and bison. - -If you use SCO, you might have trouble building libpcap from this -release. We do not have a machine running SCO and have not had reports -of anyone successfully building on it; the current release of libpcap -does not compile on SCO OpenServer 5. Although SCO apparently supports -DLPI to some extent, the DLPI in OpenServer 5 is very non-standard, and -it appears that completely new code would need to be written to capture -network traffic. SCO do not appear to provide tcpdump binaries for -OpenServer 5 or OpenServer 6 as part of SCO Skunkware: - - http://www.sco.com/skunkware/ - -If you use UnixWare, you might be able to build libpcap from this -release, or you might not. We do not have a machine running UnixWare, -so we have not tested it; however, SCO provide packages for libpcap -0.6.2 and tcpdump 3.7.1 in the UnixWare 7/Open UNIX 8 part of SCO -Skunkware, and the source package for libpcap 0.6.2 is not changed from -the libpcap 0.6.2 source release, so this release of libpcap might also -build without changes on UnixWare 7. - -If linking tcpdump fails with "Undefined: _alloca" when using bison on -a Sun4, your version of Bison is broken. In any case version 1.16 or -higher is recommended (1.14 is known to cause problems 1.16 is known to -work). Either pick up a current version from: - - https://ftp.gnu.org/gnu/bison/ - -or hack around it by inserting the lines: - - #ifdef __GNUC__ - #define alloca __builtin_alloca - #else - #ifdef sparc - #include - #else - char *alloca (); - #endif - #endif - -right after the (100 line!) GNU license comment in bison.simple, remove -grammar.[co] and fire up make again. - -If you use SunOS 4, your kernel must support streams NIT. If you run a -libpcap program and it dies with: - - /dev/nit: No such device - -You must add streams NIT support to your kernel configuration, run -config and boot the new kernel. - -FILES ------ +## Description of files CHANGES - description of differences between releases ChmodBPF/* - macOS startup item to set ownership and permissions on /dev/bpf* CMakeLists.txt - CMake file @@ -264,10 +196,9 @@ FILES doc/README.macos - notes on using libpcap on macOS doc/README.septel - notes on using libpcap to capture on Intel/Septel devices doc/README.sita - notes on using libpcap to capture on SITA devices - doc/README.tru64 - notes on using libpcap on Digital/Tru64 UNIX + doc/README.solaris.md - notes on using libpcap on Solaris doc/README.Win32.md - notes on using libpcap on Win32 systems (with Npcap) VERSION - version of this release - acconfig.h - support for post-2.13 autoconf aclocal.m4 - autoconf macros arcnet.h - ARCNET definitions atmuni31.h - ATM Q.2931 definitions @@ -286,8 +217,8 @@ FILES fad-getad.c - pcap_findalldevs() for systems with getifaddrs() fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF - filtertest.c - test program for BPF compiler - findalldevstest.c - test program for pcap_findalldevs() + testprogs/filtertest.c - test program for BPF compiler + testprogs/findalldevstest.c - test program for pcap_findalldevs() gencode.c - BPF code generation routines gencode.h - BPF code generation definitions grammar.y - filter string grammar @@ -300,7 +231,6 @@ FILES msdos/* - drivers for MS-DOS capture support nametoaddr.c - hostname to address routines nlpid.h - OSI network layer protocol identifier definitions - net - symlink to bpf/net optimize.c - BPF optimization routines pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header pcap/bpf.h - BPF definitions @@ -323,17 +253,14 @@ FILES pcap-linux.c - Linux packet socket support pcap-namedb.h - header for backwards compatibility pcap-nit.c - SunOS Network Interface Tap support - pcap-nit.h - SunOS Network Interface Tap definitions pcap-npf.c - Npcap capture support pcap-null.c - dummy monitor support (allows offline use of libpcap) pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support - pcap-pf.h - Ultrix and Digital/Tru64 UNIX Packet Filter definitions pcap-septel.c - Intel/Septel device capture support pcap-septel.h - Intel/Septel device capture support pcap-sita.c - SITA device capture support pcap-sita.h - SITA device capture support pcap-sita.html - SITA device capture documentation - pcap-stdinc.h - includes and #defines for compiling on Win32 systems pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support pcap-snoop.c - IRIX Snoop network monitoring support pcap-usb-linux.c - USB capture support for Linux @@ -342,10 +269,9 @@ FILES pcap.c - pcap utility routines pcap.h - header for backwards compatibility pcap_*.3pcap - manual entries for library functions - pcap-filter.4 - manual entry for filter syntax - pcap-linktype.4 - manual entry for link-layer header types + pcap-filter.manmisc.in - manual entry for filter syntax + pcap-linktype.manmisc.in - manual entry for link-layer header types ppp.h - Point to Point Protocol definitions savefile.c - offline support scanner.l - filter string scanner sunatmpos.h - definitions for SunATM capturing - Win32 - headers and routines for building on Win32 systems diff --git a/libpcap/Makefile.in b/libpcap/Makefile.in index f22c3c1c4..30a23a202 100644 --- a/libpcap/Makefile.in +++ b/libpcap/Makefile.in @@ -1,5 +1,5 @@ # Copyright (c) 1993, 1994, 1995, 1996 -# The Regents of the University of California. All rights reserved. +# The Regents of the University of California. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that: (1) source code distributions @@ -61,13 +61,12 @@ CROSSFLAGS= CFLAGS = @CFLAGS@ ${CROSSFLAGS} LDFLAGS = @LDFLAGS@ ${CROSSFLAGS} DYEXT = @DYEXT@ -V_RPATH_OPT = @V_RPATH_OPT@ +RPATH = @RPATH@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ PROG=libpcap PTHREAD_LIBS=@PTHREAD_LIBS@ BUILD_RPCAPD=@BUILD_RPCAPD@ INSTALL_RPCAPD=@INSTALL_RPCAPD@ -EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@ # Standard CFLAGS for building members of a shared library FULL_CFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS) @@ -90,9 +89,9 @@ PLATFORM_CXX_SRC = @PLATFORM_CXX_SRC@ MODULE_C_SRC = @MODULE_C_SRC@ REMOTE_C_SRC = @REMOTE_C_SRC@ COMMON_C_SRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \ - fmtutils.c \ + fmtutils.c pcap-util.c \ savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \ - bpf_image.c bpf_filter.c bpf_dump.c + pcap-usb-linux-common.c bpf_image.c bpf_filter.c bpf_dump.c GENERATED_C_SRC = scanner.c grammar.c LIBOBJS = @LIBOBJS@ @@ -112,21 +111,21 @@ PUBHDR = \ pcap.h \ pcap-bpf.h \ pcap-namedb.h \ - pcap/bpf.h \ pcap/bluetooth.h \ + pcap/bpf.h \ pcap/can_socketcan.h \ pcap/compiler-tests.h \ pcap/dlt.h \ pcap/funcattrs.h \ - pcap/pcap-inttypes.h \ pcap/ipnet.h \ pcap/namedb.h \ pcap/nflog.h \ + pcap/pcap-inttypes.h \ pcap/pcap.h \ pcap/sll.h \ pcap/socket.h \ - pcap/vlan.h \ - pcap/usb.h + pcap/usb.h \ + pcap/vlan.h HDR = $(PUBHDR) \ arcnet.h \ @@ -146,6 +145,9 @@ HDR = $(PUBHDR) \ pcap-int.h \ pcap-rpcap.h \ pcap-types.h \ + pcap-usb-linux-common.h \ + pcap-util.h \ + pflog.h \ portability.h \ ppp.h \ rpcap-protocol.h \ @@ -160,8 +162,8 @@ GENHDR = \ TAGFILES = \ $(SRC) $(HDR) -CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION.txt` \ - $(PROG)-`cat $(srcdir)/VERSION.txt`.tar.gz \ +CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \ + $(PROG)-`cat $(srcdir)/VERSION`.tar.gz \ lex.yy.c pcap-config libpcap.pc MAN1 = pcap-config.1 @@ -249,16 +251,25 @@ EXTRA_DIST = \ Makefile.in \ Makefile-devel-adds \ README.md \ - doc \ + doc/README.Win32.md \ + doc/README.aix \ + doc/README.dag \ + doc/README.hpux \ + doc/README.linux \ + doc/README.macos \ + doc/README.septel \ + doc/README.sita \ + doc/README.solaris.md \ CONTRIBUTING.md \ TODO \ - VERSION.txt \ + VERSION \ aclocal.m4 \ charconv.c \ charconv.h \ chmod_bpf \ cmake_uninstall.cmake.in \ cmakeconfig.h.in \ + cmake/Modules/FindAirPcap.cmake \ cmake/Modules/FindDAG.cmake \ cmake/Modules/Finddpdk.cmake \ cmake/Modules/FindFseeko.cmake \ @@ -399,6 +410,7 @@ EXTRA_DIST = \ testprogs/fuzz/fuzz_pcap.c \ testprogs/fuzz/fuzz_pcap.options \ testprogs/fuzz/onefile.c \ + testprogs/nonblocktest.c \ testprogs/opentest.c \ testprogs/reactivatetest.c \ testprogs/selpolltest.c \ @@ -406,11 +418,13 @@ EXTRA_DIST = \ testprogs/unix.h \ testprogs/valgrindtest.c \ testprogs/visopts.py \ - testprogs/writecaptest.c \ - tests/shb-option-too-long.pcapng \ - Win32/Prj/wpcap.sln \ - Win32/Prj/wpcap.vcxproj \ - Win32/Prj/wpcap.vcxproj.filters + testprogs/writecaptest.c + +TEST_DIST = `git ls-files tests | grep -v 'tests/\..*'` + +RELEASE_FILES = $(COMMON_C_SRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \ + $(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) \ + $(TEST_DIST) all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config @@ -432,8 +446,8 @@ shared: libpcap.$(DYEXT) libpcap.so: $(OBJ) @rm -f $@ - VER=`cat $(srcdir)/VERSION.txt`; \ - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION.txt`; \ + VER=`cat $(srcdir)/VERSION`; \ + MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ @V_SHLIB_CMD@ $(LDFLAGS) @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER \ -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS) @@ -448,17 +462,17 @@ libpcap.so: $(OBJ) # but not in the older version. # # We also use "A" as the major version, and 1 as the compatibility version, -# but set the current version to the value in VERSION.txt, with any non-numeric +# but set the current version to the value in VERSION, with any non-numeric # stuff stripped off (the compatibility and current version must be of the # form X[.Y[.Z]], with Y and Z possibly absent, and with all components # numeric). # libpcap.dylib: $(OBJ) rm -f libpcap*.dylib - VER=`cat $(srcdir)/VERSION.txt`; \ + VER=`cat $(srcdir)/VERSION`; \ MAJOR_VER=A; \ COMPAT_VER=1; \ - CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION.txt`; \ + CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \ $(CC) -dynamiclib -undefined error $(LDFLAGS) @V_LIB_LDFLAGS_FAT@ \ -o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \ -install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \ @@ -478,9 +492,9 @@ libpcap.dylib: $(OBJ) # linker, even with GCC. # libpcap.sl: $(OBJ) - @MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION.txt`; \ + @MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ rm -f libpcap.$$MAJOR_VER - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION.txt`; \ + MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \ $(OBJ) $(ADDLOBJS) $(LIBS) @@ -671,15 +685,15 @@ install-shared: install-shared-$(DYEXT) install-shared-so: libpcap.so [ -d $(DESTDIR)$(libdir) ] || \ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) - VER=`cat $(srcdir)/VERSION.txt`; \ - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION.txt`; \ + VER=`cat $(srcdir)/VERSION`; \ + MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \ ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \ ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so install-shared-dylib: libpcap.dylib [ -d $(DESTDIR)$(libdir) ] || \ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) - VER=`cat $(srcdir)/VERSION.txt`; \ + VER=`cat $(srcdir)/VERSION`; \ MAJOR_VER=A; \ $(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \ ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \ @@ -687,7 +701,7 @@ install-shared-dylib: libpcap.dylib install-shared-sl: libpcap.sl [ -d $(DESTDIR)$(libdir) ] || \ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION.txt`; \ + MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ $(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir) ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl install-shared-shareda: libpcap.shareda @@ -754,19 +768,19 @@ uninstall: uninstall-shared uninstall-rpcapd uninstall-shared: uninstall-shared-$(DYEXT) uninstall-shared-so: - VER=`cat $(srcdir)/VERSION.txt`; \ - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION.txt`; \ + VER=`cat $(srcdir)/VERSION`; \ + MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \ rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \ rm -f $(DESTDIR)$(libdir)/libpcap.so uninstall-shared-dylib: - VER=`cat $(srcdir)/VERSION.txt`; \ + VER=`cat $(srcdir)/VERSION`; \ MAJOR_VER=A; \ rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \ rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \ rm -f $(DESTDIR)$(libdir)/libpcap.dylib uninstall-shared-sl: - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION.txt`; \ + MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \ rm -f $(DESTDIR)$(libdir)/libpcap.sl uninstall-shared-shareda: @@ -781,8 +795,8 @@ clean: distclean: clean rm -f Makefile grammar.y config.cache config.log config.status \ - config.h gnuc.h net os-proto.h libpcap.pc \ - pcap-config stamp-h stamp-h.in + config.h config.h.in~ configure~ configure.ac~ \ + net os-proto.h libpcap.pc pcap-config stamp-h stamp-h.in rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=) rm -rf autom4te.cache @@ -793,24 +807,19 @@ tags: $(TAGFILES) ctags -wtd $(TAGFILES) releasetar: - @autoreconf -f; \ - name=$(PROG)-`cat VERSION.txt` ; \ - mkdir $$name; \ - tar -c --exclude='*~' -f - $(COMMON_C_SRC) $(HDR) $(MAN1) \ - $(MAN3PCAP_EXPAND) $(MAN3PCAP_NOEXPAND) $(MANFILE) \ - $(MANMISC) $(EXTRA_DIST) | \ - (cd $$name; tar xf -); \ - tar -c -z -f $$name.tar.gz $$name; \ - rm -rf $$name - -rc1 rc2 rc3 rc4 rc5: - @VER=`cat $(srcdir)/VERSION.txt`; \ - sed -i "s/$$VER/$${VER}$@/" VERSION.txt ; \ - make releasetar; \ - git checkout VERSION.txt configure + @TAG=$(PROG)-`cat VERSION` && \ + if git show-ref --tags --quiet --verify -- "refs/tags/$$TAG"; then \ + git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz "$$TAG" \ + $(RELEASE_FILES) && \ + echo "Archive build from tag $$TAG."; \ + else \ + git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz HEAD \ + $(RELEASE_FILES) && \ + echo "No $$TAG tag. Archive build from HEAD."; \ + fi depend: $(GENERATED_C_SRC) $(GENHDR) $(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC) shellcheck: - shellcheck -f gcc build.sh build_matrix.sh + shellcheck -f gcc -e SC2006 build.sh build_matrix.sh build_common.sh diff --git a/libpcap/NMAP_MODIFICATIONS/0001-Don-t-autogenerate-Lex-Yacc-files.patch b/libpcap/NMAP_MODIFICATIONS/0001-Don-t-autogenerate-Lex-Yacc-files.patch index af157905f..0c1fa0524 100644 --- a/libpcap/NMAP_MODIFICATIONS/0001-Don-t-autogenerate-Lex-Yacc-files.patch +++ b/libpcap/NMAP_MODIFICATIONS/0001-Don-t-autogenerate-Lex-Yacc-files.patch @@ -1,5 +1,5 @@ ---- libpcap-1.10.1/Makefile.in 2021-06-07 20:21:35.000000000 +0000 -+++ libpcap/Makefile.in 2022-08-31 18:00:55.284383667 +0000 +--- a/libpcap/Makefile.in 2021-06-07 20:21:35.000000000 +0000 ++++ b/libpcap/Makefile.in 2022-08-31 18:00:55.284383667 +0000 @@ -78,9 +78,6 @@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ @@ -67,9 +67,9 @@ grammar.o: grammar.c scanner.h $(CC) $(FULL_CFLAGS) -c grammar.c ---- libpcap-1.10.1/configure.ac 2021-06-07 20:21:35.000000000 +0000 -+++ libpcap/configure.ac 2022-08-31 18:02:07.017322554 +0000 -@@ -1716,106 +1716,6 @@ +--- a/libpcap/configure.ac 2021-06-07 20:21:35.000000000 +0000 ++++ b/libpcap/configure.ac 2022-08-31 18:02:07.017322554 +0000 +@@ -1716,112 +1716,6 @@ AC_MSG_RESULT(${enable_yydebug-no}) # @@ -92,7 +92,13 @@ - fi) -if test $tcpdump_cv_capable_lex = insufficient ; then - AC_MSG_ERROR([$LEX is insufficient to compile libpcap. -- libpcap requires Flex 2.5.31 or later, or a compatible version of lex.]) +- libpcap requires Flex 2.5.31 or later, or a compatible version of lex. +- If a suitable version of Lex/Flex is available as a non-standard command +- and/or not in the PATH, you can specify it using the LEX environment +- variable. That said, on some systems the error can mean that Flex/Lex is +- actually acceptable, but m4 is not. Likewise, if a suitable version of +- m4 (such as GNU M4) is available but has not been detected, you can +- specify it using the M4 environment variable.]) -fi - -# @@ -150,7 +156,7 @@ - tcpdump_cv_capable_yacc=insufficient - fi) - if test $tcpdump_cv_capable_yacc = insufficient ; then -- AC_MSG_ERROR([$YACC is insufficient to compile libpcap. +- AC_MSG_ERROR([$BISON_BYACC is insufficient to compile libpcap. - libpcap requires Bison, a newer version of Berkeley YACC with support - for reentrant parsers, or another YACC compatible with them.]) - fi @@ -176,17 +182,3 @@ # Do various checks for various OSes and versions of those OSes. # # Assume, by default, no support for shared libraries and V7/BSD -@@ -2237,13 +2137,11 @@ - AC_SUBST(V_PROG_LDFLAGS_FAT) - AC_SUBST(V_DEFS) - AC_SUBST(V_INCLS) --AC_SUBST(V_LEX) - AC_SUBST(V_SHLIB_CCOPT) - AC_SUBST(V_SHLIB_CMD) - AC_SUBST(V_SHLIB_OPT) - AC_SUBST(V_SONAME_OPT) - AC_SUBST(V_RPATH_OPT) --AC_SUBST(V_YACC) - AC_SUBST(ADDLOBJS) - AC_SUBST(ADDLARCHIVEOBJS) - AC_SUBST(PLATFORM_C_SRC) diff --git a/libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch b/libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch index 1ed6bfdea..c47b6148d 100644 --- a/libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch +++ b/libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch @@ -6,22 +6,22 @@ index eba2723..6255f07 100644 # let's drop support for older versions of libnl, too. # AC_ARG_WITH(libnl, -- AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]), -+ AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=disabled@:>@]), +- AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]), ++ AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=disabled@:>@]), with_libnl=$withval,with_libnl=if_available) - if test x$with_libnl != xno ; then + if test x$with_libnl = xyes ; then - if test "x$PKGCONFIG" != "xno"; then - # - # We have pkg-config; see if we have libnl-genl-3.0 + # + # Check for libnl-genl-3.0 with pkg-config. + # @@ -2183,8 +2083,8 @@ - esac + AC_SUBST(MAN_ADMIN_COMMANDS) AC_ARG_ENABLE(shared, --AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@])) +-AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@])) -test "x$enable_shared" = "xno" && DYEXT="none" -+AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=no@:>@])) ++AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=no@:>@])) +test "x$enable_shared" != "xyes" && DYEXT="none" AC_PROG_RANLIB @@ -30,8 +30,8 @@ index eba2723..6255f07 100644 # Various Linux-specific mechanisms. # AC_ARG_ENABLE([usb], --[AC_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])], -+[AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=no@:>@])], +-[AS_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])], ++[AS_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=no@:>@])], [], - [enable_usb=yes]) + [enable_usb=no]) @@ -42,8 +42,8 @@ index eba2723..6255f07 100644 AC_SUBST(PCAP_SUPPORT_DPDK) AC_ARG_ENABLE([bluetooth], --[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])], -+[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=no@:>@])], +-[AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])], ++[AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=no@:>@])], [], - [enable_bluetooth=ifsupportavailable]) + [enable_bluetooth=no]) @@ -54,8 +54,8 @@ index eba2723..6255f07 100644 fi AC_ARG_ENABLE([dbus], --[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])], -+[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=no@:>@])], +-[AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])], ++[AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=no@:>@])], [], - [enable_dbus=ifavailable]) + [enable_dbus=no]) @@ -70,8 +70,8 @@ index eba2723..6255f07 100644 - testprogs/Makefile) + ) exit 0 ---- libpcap-1.10.1/Makefile.in 2021-06-07 20:21:35.000000000 +0000 -+++ libpcap/Makefile.in 2022-08-31 18:00:55.284383667 +0000 +--- a/libpcap/Makefile.in 2021-06-07 20:21:35.000000000 +0000 ++++ b/libpcap/Makefile.in 2022-08-31 18:00:55.284383667 +0000 @@ -790,8 +778,6 @@ clean: @@ -82,7 +82,7 @@ index eba2723..6255f07 100644 distclean: clean rm -f Makefile grammar.y config.cache config.log config.status \ @@ -799,8 +785,6 @@ - pcap-config stamp-h stamp-h.in + net os-proto.h libpcap.pc pcap-config stamp-h stamp-h.in rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=) rm -rf autom4te.cache - (cd rpcapd; $(MAKE) distclean) @@ -98,4 +98,4 @@ index eba2723..6255f07 100644 - (cd testprogs; $(MAKE) depend) shellcheck: - shellcheck -f gcc build.sh build_matrix.sh + shellcheck -f gcc -e SC2006 build.sh build_matrix.sh build_common.sh diff --git a/libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE b/libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE index 7f01ff865..81fc3768e 100644 --- a/libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE +++ b/libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE @@ -8,7 +8,7 @@ tar xzvf libpcap-X.Y.tar.gz cd nmap rsync -rv --delete ~/libpcap-X.Y/ ~/nmap/libpcap/ # Remove some things we don't want to ship -rm -rf ~/nmap/libpcap/{rpcapd,testprogs,doc} +rm -rf ~/nmap/libpcap/{rpcapd,testprogs,doc,tests} # Apply patch to avoid those dirs git apply ~/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch git add -A libpcap diff --git a/libpcap/README.md b/libpcap/README.md index d89e3bb62..e38b9a15d 100644 --- a/libpcap/README.md +++ b/libpcap/README.md @@ -24,7 +24,7 @@ to ease in porting and to alleviate the need for several system-dependent packet capture modules in each application. ```text -formerly from Lawrence Berkeley National Laboratory +formerly from Lawrence Berkeley National Laboratory Network Research Group ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z ``` @@ -52,12 +52,10 @@ would translate BPF filters into a filter program that is compatible with the underlying kernel subsystem, but this is not yet implemented. BPF is standard in 4.4BSD, BSD/OS, NetBSD, FreeBSD, OpenBSD, DragonFly -BSD, and macOS; an older, modified and undocumented version is standard -in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the packetfilter -interface but has been extended to accept BPF filters (which libpcap -utilizes). Also, you can add BPF filter support to Ultrix using the -kernel source and/or object patches available -[here](https://www.tcpdump.org/other/bpfext42.tar.Z). +BSD, macOS, and Solaris 11; an older, modified and undocumented version +is standard in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the +packetfilter interface but has been extended to accept BPF filters +(which libpcap utilizes). Linux has a number of BPF based systems, and libpcap does not support any of the eBPF mechanisms as yet, although it supports many of the diff --git a/libpcap/VERSION b/libpcap/VERSION new file mode 100644 index 000000000..18b311420 --- /dev/null +++ b/libpcap/VERSION @@ -0,0 +1 @@ +1.10.4 diff --git a/libpcap/VERSION.txt b/libpcap/VERSION.txt deleted file mode 100644 index 4dae2985b..000000000 --- a/libpcap/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -1.10.1 diff --git a/libpcap/Win32/Prj/wpcap.sln b/libpcap/Win32/Prj/wpcap.sln deleted file mode 100644 index 5a9fce98e..000000000 --- a/libpcap/Win32/Prj/wpcap.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap", "wpcap.vcxproj", "{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.ActiveCfg = Debug|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.Build.0 = Debug|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.ActiveCfg = Debug|x64 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.Build.0 = Debug|x64 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.ActiveCfg = Release|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.Build.0 = Release|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.ActiveCfg = Release|x64 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libpcap/Win32/Prj/wpcap.vcxproj b/libpcap/Win32/Prj/wpcap.vcxproj deleted file mode 100644 index 43b7099b7..000000000 --- a/libpcap/Win32/Prj/wpcap.vcxproj +++ /dev/null @@ -1,233 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9} - - - - DynamicLibrary - v120 - false - MultiByte - - - DynamicLibrary - v120 - false - MultiByte - - - DynamicLibrary - v120 - false - MultiByte - true - - - DynamicLibrary - v120 - false - MultiByte - true - - - - - - - - - - - - - - - - - - - - - - - .\Release\ - .\Release\ - false - ../../../;$(IncludePath) - - - false - ../../../;$(IncludePath) - - - .\Debug\ - .\Debug\ - true - ../../../;$(IncludePath) - - - true - ../../../;$(IncludePath) - - - - MultiThreaded - Default - true - true - MaxSpeed - true - Level3 - ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies) - - - call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - - - - - MultiThreaded - Default - true - true - MaxSpeed - true - Level3 - ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) - - - 0x0409 - NDEBUG;%(PreprocessorDefinitions) - - - ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies) - - - call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - true - EditAndContinue - ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) - EnableFastChecks - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies) - - - call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - - - - - MultiThreadedDebug - Default - false - Disabled - true - Level3 - ProgramDatabase - ../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories) - HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) - EnableFastChecks - - - 0x0409 - _DEBUG;%(PreprocessorDefinitions) - - - ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies) - - - call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libpcap/Win32/Prj/wpcap.vcxproj.filters b/libpcap/Win32/Prj/wpcap.vcxproj.filters deleted file mode 100644 index 879bb0598..000000000 --- a/libpcap/Win32/Prj/wpcap.vcxproj.filters +++ /dev/null @@ -1,107 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - {c51dce5e-0da9-4e33-a235-d5c76c76485c} - - - {5ec9fd4b-10b5-4527-b249-56b53d844fb1} - - - {c90886f0-8973-436b-a7a1-b9e881544f9a} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - diff --git a/libpcap/aclocal.m4 b/libpcap/aclocal.m4 index 2fd29feda..9ec93c28d 100644 --- a/libpcap/aclocal.m4 +++ b/libpcap/aclocal.m4 @@ -232,34 +232,27 @@ AC_DEFUN(AC_LBL_C_INIT, ]) dnl -dnl Check whether, if you pass an unknown warning option to the -dnl compiler, it fails or just prints a warning message and succeeds. -dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag -dnl to force an error if it would otherwise just print a warning message -dnl and succeed. +dnl Save the values of various variables that affect compilation and +dnl linking, and that we don't ourselves modify persistently; done +dnl before a test involving compiling or linking is done, so that we +dnl can restore those variables after the test is done. dnl -AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR, - [ - AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option]) +AC_DEFUN(AC_LBL_SAVE_CHECK_STATE, +[ save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy" - AC_TRY_COMPILE( - [], - [return 0], - [ - AC_MSG_RESULT([no]) - # - # We're assuming this is clang, where - # -Werror=unknown-warning-option is the appropriate - # option to force the compiler to fail. - # - ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option" - ], - [ - AC_MSG_RESULT([yes]) - ]) + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" +]) + +dnl +dnl Restore the values of variables saved by AC_LBL_SAVE_CHECK_STATE. +dnl +AC_DEFUN(AC_LBL_RESTORE_CHECK_STATE, +[ CFLAGS="$save_CFLAGS" - ]) + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" +]) dnl dnl Check whether the compiler option specified as the second argument @@ -278,21 +271,35 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT, [ AC_MSG_CHECKING([whether the compiler supports the $2 option]) save_CFLAGS="$CFLAGS" - if expr "x$2" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2" - elif expr "x$2" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror $2" - elif expr "x$2" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror $2" - else - CFLAGS="$CFLAGS $2" - fi - AC_TRY_COMPILE( - [], - [return 0], + CFLAGS="$CFLAGS $2" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[int main(void) { return 0; }]])], [ AC_MSG_RESULT([yes]) can_add_to_cflags=yes @@ -332,6 +339,7 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT, AC_MSG_RESULT([no]) CFLAGS="$save_CFLAGS" ]) + ac_c_werror_flag="$save_ac_c_werror_flag" ]) dnl @@ -460,7 +468,6 @@ dnl V_SHLIB_CCOPT (modified to build position-independent code) dnl V_SHLIB_CMD dnl V_SHLIB_OPT dnl V_SONAME_OPT -dnl V_RPATH_OPT dnl AC_DEFUN(AC_LBL_SHLIBS_INIT, [AC_PREREQ(2.50) @@ -486,9 +493,10 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*) # - # Platforms where the linker is the GNU linker - # or accepts command-line arguments like - # those the GNU linker accepts. + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. # # Some instruction sets require -fPIC on some # operating systems. Check for them. If you @@ -509,7 +517,6 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, esac V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) @@ -531,11 +538,12 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # - # XXX - this assumes GCC is using the Sun linker, - # rather than the GNU linker. + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. # V_SONAME_OPT="-Wl,-h," - V_RPATH_OPT="-Wl,-R," ;; esac else @@ -557,7 +565,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, # "-Wl,-soname,{soname}" option, with the soname part # of the option, while on other platforms the C compiler # driver takes it as a regular option with the soname - # following the option. The same applies to V_RPATH_OPT. + # following the option. # case "$host_os" in @@ -568,13 +576,17 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, freebsd*|netbsd*|openbsd*|dragonfly*|linux*) # - # "cc" is GCC. + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. + # + # XXX - does 64-bit SPARC require -fPIC? # V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) @@ -597,15 +609,19 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-soname " - V_RPATH_OPT="-rpath " ;; solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-G" - V_SONAME_OPT="-h " - V_RPATH_OPT="-R" + # + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. + # + V_SONAME_OPT="-Wl,-h," ;; esac fi @@ -662,8 +678,6 @@ AC_DEFUN(AC_LBL_C_INLINE, fi AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])]) -FFF - # # Test whether we have __atomic_load_n() and __atomic_store_n(). # @@ -819,7 +833,6 @@ AC_DEFUN(AC_LBL_DEVEL, # Skip all the warning option stuff on some compilers. # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then - AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR() AC_LBL_CHECK_COMPILER_OPT($1, -W) AC_LBL_CHECK_COMPILER_OPT($1, -Wall) AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma) @@ -1000,19 +1013,23 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [ LIBS="-lsocket -lnsl $LIBS" ], [ - AC_CHECK_LIB(network, getaddrinfo, - [ - # - # OK, we found it in libnetwork on Haiku. - # - LIBS="-lnetwork $LIBS" - ], - [ - # - # We didn't find it. - # - AC_MSG_ERROR([getaddrinfo is required, but wasn't found]) - ]) + # + # Not found in libsocket; test for it in libnetwork, which + # is where it is in Haiku. + # + AC_CHECK_LIB(network, getaddrinfo, + [ + # + # OK, we found it in libnetwork. + # + LIBS="-lnetwork $LIBS" + ], + [ + # + # We didn't find it. + # + AC_MSG_ERROR([getaddrinfo is required, but wasn't found]) + ]) ], -lnsl) # @@ -1086,9 +1103,8 @@ dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found -dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is -dnl used since that's the first version where most current features of -dnl pkg-config existed. +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.17.0 is +dnl used since that's the first version where --static was supported. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) @@ -1101,7 +1117,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_default([$1], [0.9.0]) + _pkg_min_version=m4_default([$1], [0.17.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) @@ -1118,13 +1134,8 @@ dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. -dnl -dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -dnl only at the first occurrence in configure.ac, so if the first place -dnl it's called might be skipped (such as if it is within an "if", you -dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +[ if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) @@ -1132,7 +1143,7 @@ m4_ifvaln([$3], [else $3])dnl fi]) -dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl _PKG_CONFIG([VARIABLE], [FLAGS], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. @@ -1141,7 +1152,7 @@ m4_define([_PKG_CONFIG], pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + [pkg_cv_[]$1=`$PKG_CONFIG $2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else @@ -1153,7 +1164,7 @@ dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +[ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else @@ -1166,37 +1177,44 @@ dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 -dnl -dnl Note that if there is a possibility the first call to -dnl PKG_CHECK_MODULES might not happen, you should be sure to include an -dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl +[ +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS_STATIC], [static-link linker flags for $2, overriding pkg-config])dnl pkg_failed=no -AC_MSG_CHECKING([for $1]) +AC_MSG_CHECKING([for $2 with pkg-config]) +PKG_CHECK_EXISTS($2, + [ + # + # The package was found, so try to get its C flags and + # libraries. + # + _PKG_CONFIG([$1][_CFLAGS], [--cflags], [$2]) + _PKG_CONFIG([$1][_LIBS], [--libs], [$2]) + _PKG_CONFIG([$1][_LIBS_STATIC], [--libs --static], [$2]) -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS + m4_define([_PKG_TEXT], [ +Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) -if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + AC_MSG_RESULT([error]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - m4_default([$4], [AC_MSG_ERROR( + m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS @@ -1206,23 +1224,28 @@ installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) -elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) - m4_default([$4], [AC_MSG_FAILURE( -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see .])[]dnl - ]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - $3 -fi[]dnl + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + AC_MSG_RESULT([not found (pkg-config not found)]) + else + # + # We found the package. + # + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + $1[]_LIBS_STATIC=$pkg_cv_[]$1[]_LIBS_STATIC + AC_MSG_RESULT([found]) + $3 + fi[]dnl + ], + [ + # + # The package isn't present. + # + AC_MSG_RESULT([not found]) + ]) ])dnl PKG_CHECK_MODULES @@ -1234,13 +1257,8 @@ dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. -dnl -dnl Note that if there is a possibility the first call to -dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to -dnl include an explicit call to PKG_PROG_PKG_CONFIG in your -dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +[ _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) @@ -1299,12 +1317,11 @@ dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +[ AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl -_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +_PKG_CONFIG([$1], [--variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR - diff --git a/libpcap/charconv.c b/libpcap/charconv.c index 4ede57204..5f97509ab 100644 --- a/libpcap/charconv.c +++ b/libpcap/charconv.c @@ -34,6 +34,7 @@ #ifdef _WIN32 #include +#include #include /* Needed for PCAP_ERRBUF_SIZE */ diff --git a/libpcap/charconv.h b/libpcap/charconv.h index a37d424b7..93103d461 100644 --- a/libpcap/charconv.h +++ b/libpcap/charconv.h @@ -32,8 +32,8 @@ * SUCH DAMAGE. */ -#ifndef charonv_h -#define charonv_h +#ifndef charconv_h +#define charconv_h #ifdef _WIN32 extern wchar_t *cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags); @@ -41,4 +41,4 @@ extern char *utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string); extern void utf_8_to_acp_truncated(char *); #endif -#endif +#endif /* charconv_h */ diff --git a/libpcap/cmake/Modules/FindAirPcap.cmake b/libpcap/cmake/Modules/FindAirPcap.cmake new file mode 100644 index 000000000..56c71b7bf --- /dev/null +++ b/libpcap/cmake/Modules/FindAirPcap.cmake @@ -0,0 +1,69 @@ +# +# FindAirPcap +# ========== +# +# Find the AirPcap library and include files. +# +# This module defines the following variables: +# +# AirPcap_INCLUDE_DIR - absolute path to the directory containing airpcap.h. +# +# AirPcap_LIBRARY - relative or absolute path to the AirPcap library to +# link with. An absolute path is will be used if the +# AirPcap library is not located in the compiler's +# default search path. + +# AirPcap_FOUND - TRUE if the AirPcap library *and* header are found. +# +# Hints and Backward Compatibility +# ================================ +# +# To tell this module where to look, a user may set the environment variable +# AirPcap_ROOT to point cmake to the *root* of a directory with include and +# lib subdirectories for airpcap.dll (e.g Airpcap_Devpack). +# Alternatively, AirPcap_ROOT may also be set from the CMake command +# line or GUI (e.g cmake -DAirPcap_ROOT=C:\path\to\airpcap_sdk [...]) +# + +# The 64-bit airpcap.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". + # + # In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to + # the language, e.g., CMAKE__LIBRARY_ARCHITECTURE. So, set the new + # variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE + # inherits the correct value. + # + set(CMAKE_C_LIBRARY_ARCHITECTURE "x64") + set(CMAKE_LIBRARY_ARCHITECTURE "x64") +endif() + +# Find the header +find_path(AirPcap_INCLUDE_DIR airpcap.h + PATH_SUFFIXES include +) + +# Find the library +find_library(AirPcap_LIBRARY + NAMES airpcap +) + +# Set AirPcap_FOUND to TRUE if AirPcap_INCLUDE_DIR and AirPcap_LIBRARY are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(AirPcap + DEFAULT_MSG + AirPcap_INCLUDE_DIR + AirPcap_LIBRARY +) + +mark_as_advanced(AirPcap_INCLUDE_DIR AirPcap_LIBRARY) + +set(AirPcap_INCLUDE_DIRS ${AirPcap_INCLUDE_DIR}) +set(AirPcap_LIBRARIES ${AirPcap_LIBRARY}) diff --git a/libpcap/cmake/Modules/FindDAG.cmake b/libpcap/cmake/Modules/FindDAG.cmake index ef1352844..f41b90a24 100644 --- a/libpcap/cmake/Modules/FindDAG.cmake +++ b/libpcap/cmake/Modules/FindDAG.cmake @@ -14,6 +14,12 @@ find_path(DAG_INCLUDE_DIR dagapi.h) find_library(DAG_LIBRARY dag) find_library(DAGCONF_LIBRARY dagconf) +# +# Get link information from the _LIBRARY paths. +# +get_link_info_from_library_path(DAG dag) +get_link_info_from_library_path(DAGCONF dagconf) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(DAG DEFAULT_MSG @@ -30,3 +36,4 @@ mark_as_advanced( set(DAG_INCLUDE_DIRS ${DAG_INCLUDE_DIR}) set(DAG_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY}) +set(DAG_STATIC_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY}) diff --git a/libpcap/cmake/Modules/FindPacket.cmake b/libpcap/cmake/Modules/FindPacket.cmake index 7253d2266..8224cd3f3 100644 --- a/libpcap/cmake/Modules/FindPacket.cmake +++ b/libpcap/cmake/Modules/FindPacket.cmake @@ -28,14 +28,14 @@ # # This module defines the following variables: # -# PACKET_INCLUDE_DIR - absolute path to the directory containing Packet32.h. +# Packet_INCLUDE_DIR - absolute path to the directory containing Packet32.h. # -# PACKET_LIBRARY - relative or absolute path to the Packet library to +# Packet_LIBRARY - relative or absolute path to the Packet library to # link with. An absolute path is will be used if the # Packet library is not located in the compiler's # default search path. -# PACKET_FOUND - TRUE if the Packet library *and* header are found. +# Packet_FOUND - TRUE if the Packet library *and* header are found. # # Hints and Backward Compatibility # ================================ @@ -72,7 +72,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) file(WRITE "${CMAKE_BINARY_DIR}/archdetect.c" "${archdetect_c_code}") try_compile( - IsArm64 + IsArm64 "${CMAKE_BINARY_DIR}/archdetect" "${CMAKE_BINARY_DIR}/archdetect.c" ) @@ -86,24 +86,24 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) endif() # Find the header -find_path(PACKET_INCLUDE_DIR Packet32.h +find_path(Packet_INCLUDE_DIR Packet32.h PATH_SUFFIXES include Include ) # Find the library -find_library(PACKET_LIBRARY +find_library(Packet_LIBRARY NAMES Packet packet ) -# Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE. +# Set Packet_FOUND to TRUE if Packet_INCLUDE_DIR and Packet_LIBRARY are TRUE. include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PACKET +find_package_handle_standard_args(Packet DEFAULT_MSG - PACKET_INCLUDE_DIR - PACKET_LIBRARY + Packet_INCLUDE_DIR + Packet_LIBRARY ) -mark_as_advanced(PACKET_INCLUDE_DIR PACKET_LIBRARY) +mark_as_advanced(Packet_INCLUDE_DIR Packet_LIBRARY) -set(PACKET_INCLUDE_DIRS ${PACKET_INCLUDE_DIR}) -set(PACKET_LIBRARIES ${PACKET_LIBRARY}) +set(Packet_INCLUDE_DIRS ${Packet_INCLUDE_DIR}) +set(Packet_LIBRARIES ${Packet_LIBRARY}) diff --git a/libpcap/cmake/Modules/FindSNF.cmake b/libpcap/cmake/Modules/FindSNF.cmake index 76dcced41..d873b5aa7 100644 --- a/libpcap/cmake/Modules/FindSNF.cmake +++ b/libpcap/cmake/Modules/FindSNF.cmake @@ -8,6 +8,11 @@ find_path(SNF_INCLUDE_DIR snf.h /opt/snf) # Try to find the library find_library(SNF_LIBRARY snf /opt/snf) +# +# Get link information from the _LIBRARY paths. +# +get_link_info_from_library_path(SNF snf) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SNF DEFAULT_MSG @@ -22,3 +27,4 @@ mark_as_advanced( set(SNF_INCLUDE_DIRS ${SNF_INCLUDE_DIR}) set(SNF_LIBRARIES ${SNF_LIBRARY}) +set(SNF_STATIC_LIBRARIES ${SNF_LIBRARY}) diff --git a/libpcap/cmake/Modules/Finddpdk.cmake b/libpcap/cmake/Modules/Finddpdk.cmake index c51b1f324..323262afa 100644 --- a/libpcap/cmake/Modules/Finddpdk.cmake +++ b/libpcap/cmake/Modules/Finddpdk.cmake @@ -5,89 +5,49 @@ # dpdk_FOUND # dpdk_INCLUDE_DIRS # dpdk_LIBRARIES +# dpdk_STATIC_LIBRARIES +# dpdk_LIBS_STATIC +# dpdk_REQUIRES_PRIVATE +# dpdk_PACKAGE_NAME +# +# We only try to find DPDK using pkg-config; DPDK is *SO* +# complicated - DPDK 19.02, for example, has about 117(!) +# libraries, and the precise set of libraries required has +# changed over time - so attempting to guess which libraries +# you need, and hardcoding that in an attempt to find the +# libraries without DPDK, rather than relying on DPDK to +# tell you, with a .pc file, what libraries are needed, +# is *EXTREMELY* fragile and has caused some bug reports, +# so we're just not going to do it. +# +# If that causes a problem, the only thing we will do is +# accept an alternative way of finding the appropriate +# library set for the installed version of DPDK that is +# as robust as pkg-config (i.e., it had better work as well +# as pkg-config with *ALL* versions of DPDK that provide a +# libdpdk.pc file). +# +# If dpdk_ROOT is set, add ${dpdk_ROOT}/pkgconfig +# to PKG_CONFIG_PATH, so we look for the .pc file there, +# first. +# if(PKG_CONFIG_FOUND) - pkg_check_modules(dpdk QUIET libdpdk) -endif() -message(STATUS "Executing Finddpdk") -if(NOT dpdk_INCLUDE_DIRS) - message(STATUS "Executing find_path") - find_path(dpdk_config_INCLUDE_DIR rte_config.h - HINTS - ENV DPDK_DIR - PATH_SUFFIXES - dpdk - include -) - find_path(dpdk_common_INCLUDE_DIR rte_common.h - HINTS - ENV DPDK_DIR - PATH_SUFFIXES - dpdk - include -) - set(dpdk_INCLUDE_DIRS "${dpdk_config_INCLUDE_DIR}") - if(NOT dpdk_config_INCLUDE_DIR STREQUAL dpdk_common_INCLUDE_DIR) - list(APPEND dpdk_INCLUDE_DIRS "${dpdk_common_INCLUDE_DIR}") + set(save_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH}) + if(dpdk_ROOT) + set(ENV{PKG_CONFIG_PATH} "${dpdk_ROOT}/pkgconfig:$ENV{PKG_CONFIG_PATH}") endif() - - set(components - bus_pci - cmdline - eal - ethdev - hash - kvargs - mbuf - mempool - mempool_ring - mempool_stack - pci - pmd_af_packet - pmd_bond - pmd_i40e - pmd_ixgbe - pmd_mlx5 - pmd_ring - pmd_vmxnet3_uio - ring) - - set(dpdk_LIBRARIES) - - foreach(c ${components}) - find_library(DPDK_rte_${c}_LIBRARY rte_${c} - HINTS - ENV DPDK_DIR - ${dpdk_LIBRARY_DIRS} - PATH_SUFFIXES lib) - if(DPDK_rte_${c}_LIBRARY) - set(dpdk_lib dpdk::${c}) - if (NOT TARGET ${dpdk_lib}) - add_library(${dpdk_lib} UNKNOWN IMPORTED) - set_target_properties(${dpdk_lib} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}" - IMPORTED_LOCATION "${DPDK_rte_${c}_LIBRARY}") - if(c STREQUAL pmd_mlx5) - find_package(verbs QUIET) - if(verbs_FOUND) - target_link_libraries(${dpdk_lib} INTERFACE IBVerbs::verbs) - endif() - endif() - endif() - list(APPEND dpdk_LIBRARIES ${dpdk_lib}) - endif() - endforeach() - - # - # Where the heck did this list come from? libdpdk on Ubuntu 20.04, - # for example, doesn't even *have* -ldpdk; that's why we go with - # pkg-config, in the hopes that it provides a correct set of flags - # for this tangled mess. - # - list(APPEND dpdk_LIBRARIES dpdk rt m numo dl) + pkg_check_modules(dpdk QUIET libdpdk) + if(dpdk_FOUND) + # + # Get link information for DPDK. + # + pkg_get_link_info(dpdk libdpdk) + endif() + set(ENV{PKG_CONFIG_PATH} "${save_PKG_CONFIG_PATH}") endif() -mark_as_advanced(dpdk_INCLUDE_DIRS ${dpdk_LIBRARIES}) +mark_as_advanced(dpdk_INCLUDE_DIRS dpdk_LIBRARIES dpdk_STATIC_LIBRARIES dpdk_REQUIRES_PRIVATE) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(dpdk DEFAULT_MSG @@ -95,29 +55,64 @@ find_package_handle_standard_args(dpdk DEFAULT_MSG dpdk_LIBRARIES) if(dpdk_FOUND) - if(NOT TARGET dpdk::cflags) - if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64") - set(rte_cflags "-march=core2") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM") - set(rte_cflags "-march=armv7-a") - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64") - set(rte_cflags "-march=armv8-a+crc") + # + # This depends on CMake support for "imported targets", + # which are not supported until CMake 3.19. + # + # Ubuntu 20.04 provides CMake 3.16.3, so we are *NOT* + # going to require CMake 3.19. If you want to use + # Shiny New Features(TM), wait until all the OSes on + # which a build might conceivably be done, and that + # provide CMake, provide 3.19 or later. + # + # Just don't do this stuff on earlier versions. If that + # breaks something, figure out a way to do it *without* + # "imported targets", and either do this that way, or, + # at least, do it that way on older versions of CMake. + # + # (One good thing about autotools is that only the builders + # of a package, and people doing configure-script development, + # have to care about the autoconf etc. version; you don't + # even need to have autotools installed in order to be able + # to run an autotools-generated configure script, you just + # need an environment UN*Xy enough, and modern enough, to + # run the stuff in the script. + # + # This is *NOT* the case for CMake; not only do you need + # CMake in order to build a package using CMake, you need + # a version recent enough to run the stuff the package's + # CMake files use. + # + # Please keep this in mind when changing any CMake files, + # and keep in mind what versions of CMake come with, for + # example, commonly-used versions of commonly-used + # Linux distributiions.) + # + if(NOT CMAKE_VERSION VERSION_LESS 3.19) + if(NOT TARGET dpdk::cflags) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64") + set(rte_cflags "-march=core2") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM") + set(rte_cflags "-march=armv7-a") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64") + set(rte_cflags "-march=armv8-a+crc") + endif() + add_library(dpdk::cflags INTERFACE IMPORTED) + if (rte_cflags) + set_target_properties(dpdk::cflags PROPERTIES + INTERFACE_COMPILE_OPTIONS "${rte_cflags}") + endif() endif() - add_library(dpdk::cflags INTERFACE IMPORTED) - if (rte_cflags) - set_target_properties(dpdk::cflags PROPERTIES - INTERFACE_COMPILE_OPTIONS "${rte_cflags}") - endif() - endif() - if(NOT TARGET dpdk::dpdk) - add_library(dpdk::dpdk INTERFACE IMPORTED) - find_package(Threads QUIET) - list(APPEND dpdk_LIBRARIES - Threads::Threads - dpdk::cflags) - set_target_properties(dpdk::dpdk PROPERTIES - INTERFACE_LINK_LIBRARIES "${dpdk_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}") + if(NOT TARGET dpdk::dpdk) + add_library(dpdk::dpdk INTERFACE IMPORTED) + find_package(Threads QUIET) + list(APPEND dpdk_LIBRARIES + Threads::Threads + dpdk::cflags) + set_target_properties(dpdk::dpdk PROPERTIES + INTERFACE_LINK_LIBRARIES "${dpdk_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}") + endif() endif() endif() diff --git a/libpcap/cmakeconfig.h.in b/libpcap/cmakeconfig.h.in index ee51ac635..4ac85cc53 100644 --- a/libpcap/cmakeconfig.h.in +++ b/libpcap/cmakeconfig.h.in @@ -117,9 +117,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NET_PFILT_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NET_PFVAR_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NET_RAW_H 1 @@ -138,9 +135,6 @@ /* Define to 1 if you have a POSIX-style `strerror_r' function. */ #cmakedefine HAVE_POSIX_STRERROR_R 1 -/* define if net/pfvar.h defines PF_NAT through PF_NORDR */ -#cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1 - /* define if you have the Septel API */ #cmakedefine HAVE_SEPTEL_API 1 @@ -274,9 +268,6 @@ /* IPv6 */ #cmakedefine INET6 1 -/* path for device for USB sniffing */ -#cmakedefine LINUX_USB_MON_DEV "@LINUX_USB_MON_DEV@" - /* Define to 1 if netinet/ether.h declares `ether_hostton' */ #cmakedefine NETINET_ETHER_H_DECLARES_ETHER_HOSTTON 1 diff --git a/libpcap/config.guess b/libpcap/config.guess index 1972fda8e..69188da73 100755 --- a/libpcap/config.guess +++ b/libpcap/config.guess @@ -1,12 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2021 Free Software Foundation, Inc. +# Copyright 1992-2023 Free Software Foundation, Inc. -timestamp='2021-01-25' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2023-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -32,7 +34,15 @@ timestamp='2021-01-25' # Please send patches to . -me=$(echo "$0" | sed -e 's,.*/,,') +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + +me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] @@ -50,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2021 Free Software Foundation, Inc. +Copyright 1992-2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,6 +94,9 @@ if test $# != 0; then exit 1 fi +# Just in case it came from the environment. +GUESS= + # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -102,8 +115,8 @@ set_cc_for_build() { # prevent multiple calls if $tmp is already set test "$tmp" && return 0 : "${TMPDIR=/tmp}" - # shellcheck disable=SC2039 - { tmp=$( (umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null) && test -n "$tmp" && test -d "$tmp" ; } || + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } @@ -112,7 +125,7 @@ set_cc_for_build() { ,,) echo "int x;" > "$dummy.c" for driver in cc gcc c89 c99 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then - CC_FOR_BUILD="$driver" + CC_FOR_BUILD=$driver break fi done @@ -131,12 +144,12 @@ if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi -UNAME_MACHINE=$( (uname -m) 2>/dev/null) || UNAME_MACHINE=unknown -UNAME_RELEASE=$( (uname -r) 2>/dev/null) || UNAME_RELEASE=unknown -UNAME_SYSTEM=$( (uname -s) 2>/dev/null) || UNAME_SYSTEM=unknown -UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "$UNAME_SYSTEM" in +case $UNAME_SYSTEM in Linux|GNU|GNU/*) LIBC=unknown @@ -157,7 +170,8 @@ Linux|GNU|GNU/*) #endif #endif EOF - eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')" + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" # Second heuristic to detect musl libc. if [ "$LIBC" = unknown ] && @@ -176,7 +190,7 @@ esac # Note: order is significant - the case branches are not exclusive. -case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -188,11 +202,11 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \ + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ - echo unknown)) - case "$UNAME_MACHINE_ARCH" in + echo unknown)` + case $UNAME_MACHINE_ARCH in aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; @@ -200,15 +214,15 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=$(echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,') - endian=$(echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p') - machine="${arch}${endian}"-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown ;; - *) machine="$UNAME_MACHINE_ARCH"-unknown ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; @@ -229,10 +243,10 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in ;; esac # Determine ABI tags. - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=$(echo "$UNAME_MACHINE_ARCH" | sed -e "$expr") + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -240,76 +254,82 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "$UNAME_VERSION" in + case $UNAME_VERSION in Debian*) release='-gnu' ;; *) - release=$(echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2) + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "$machine-${os}${release}${abi-}" - exit ;; + GUESS=$machine-${os}${release}${abi-} + ;; *:Bitrig:*:*) - UNAME_MACHINE_ARCH=$(arch | sed 's/Bitrig.//') - echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" - exit ;; + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=$(arch | sed 's/OpenBSD.//') - echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" - exit ;; + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; *:LibertyBSD:*:*) - UNAME_MACHINE_ARCH=$(arch | sed 's/^.*BSD\.//') - echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" - exit ;; + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; *:MidnightBSD:*:*) - echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; *:ekkoBSD:*:*) - echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; *:SolidBSD:*:*) - echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; *:OS108:*:*) - echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; *:MirBSD:*:*) - echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; *:Sortix:*:*) - echo "$UNAME_MACHINE"-unknown-sortix - exit ;; + GUESS=$UNAME_MACHINE-unknown-sortix + ;; *:Twizzler:*:*) - echo "$UNAME_MACHINE"-unknown-twizzler - exit ;; + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; *:Redox:*:*) - echo "$UNAME_MACHINE"-unknown-redox - exit ;; + GUESS=$UNAME_MACHINE-unknown-redox + ;; mips:OSF1:*.*) - echo mips-dec-osf1 - exit ;; + GUESS=mips-dec-osf1 + ;; alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 case $UNAME_RELEASE in *4.0) - UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $3}') + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $4}') + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=$(/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1) - case "$ALPHA_CPU_TYPE" in + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") @@ -346,68 +366,69 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo "$UNAME_MACHINE"-dec-osf"$(echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)" - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; + GUESS=m68k-unknown-sysv4 + ;; *:[Aa]miga[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-amigaos - exit ;; + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; *:[Mm]orph[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-morphos - exit ;; + GUESS=$UNAME_MACHINE-unknown-morphos + ;; *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; + GUESS=i370-ibm-openedition + ;; *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; + GUESS=s390-ibm-zvmoe + ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + GUESS=powerpc-ibm-os400 + ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix"$UNAME_RELEASE" - exit ;; + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; + GUESS=arm-unknown-riscos + ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; + GUESS=hppa1.1-hitachi-hiuxmpp + ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "$( (/bin/universe) 2>/dev/null)" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; + GUESS=pyramid-pyramid-svr4 + ;; DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; + GUESS=sparc-icl-nx6 + ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case $(/usr/bin/uname -p) in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; + case `/usr/bin/uname -p` in + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; s390x:SunOS:*:*) - echo "$UNAME_MACHINE"-ibm-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux"$UNAME_RELEASE" - exit ;; + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) set_cc_for_build SUN_ARCH=i386 @@ -416,47 +437,50 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # This test works for both compilers. if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi - echo "$SUN_ARCH"-pc-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; sun4*:SunOS:*:*) - case "$(/usr/bin/arch -k)" in + case `/usr/bin/arch -k` in Series*|S4*) - UNAME_RELEASE=$(uname -v) + UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/')" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos"$UNAME_RELEASE" - exit ;; + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=$( (sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 - case "$(/bin/arch)" in + case `/bin/arch` in sun3) - echo m68k-sun-sunos"$UNAME_RELEASE" + GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) - echo sparc-sun-sunos"$UNAME_RELEASE" + GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac - exit ;; + ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos"$UNAME_RELEASE" - exit ;; + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -466,41 +490,41 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; m68k:machten:*:*) - echo m68k-apple-machten"$UNAME_RELEASE" - exit ;; + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; powerpc:machten:*:*) - echo powerpc-apple-machten"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; + GUESS=mips-dec-mach_bsd4.3 + ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix"$UNAME_RELEASE" - exit ;; + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix"$UNAME_RELEASE" - exit ;; + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix"$UNAME_RELEASE" - exit ;; + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" @@ -525,78 +549,79 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && - dummyarg=$(echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p') && - SYSTEM_NAME=$("$dummy" "$dummyarg") && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos"$UNAME_RELEASE" - exit ;; + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; + GUESS=powerpc-motorola-powermax + ;; Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; + GUESS=powerpc-harris-powerunix + ;; m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; + GUESS=m88k-harris-cxux7 + ;; m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; + GUESS=m88k-motorola-sysv4 + ;; m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=$(/usr/bin/uname -p) + UNAME_PROCESSOR=`/usr/bin/uname -p` if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux"$UNAME_RELEASE" + GUESS=m88k-dg-dgux$UNAME_RELEASE else - echo m88k-dg-dguxbcs"$UNAME_RELEASE" + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else - echo i586-dg-dgux"$UNAME_RELEASE" + GUESS=i586-dg-dgux$UNAME_RELEASE fi - exit ;; + ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; + GUESS=m88k-dolphin-sysv3 + ;; M88*:*:R3*:*) # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; + GUESS=m88k-tektronix-sysv3 + ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; + GUESS=m68k-tektronix-bsd + ;; *:IRIX*:*:*) - echo mips-sgi-irix"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/g')" - exit ;; + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'$(uname -s)'" gives 'AIX ' + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; + GUESS=i386-ibm-aix + ;; ia64:AIX:*:*) if test -x /usr/bin/oslevel ; then - IBM_REV=$(/usr/bin/oslevel) + IBM_REV=`/usr/bin/oslevel` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" - exit ;; + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then set_cc_for_build @@ -611,68 +636,68 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then - echo "$SYSTEM_NAME" + GUESS=$SYSTEM_NAME else - echo rs6000-ibm-aix3.2.5 + GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 + GUESS=rs6000-ibm-aix3.2.4 else - echo rs6000-ibm-aix3.2 + GUESS=rs6000-ibm-aix3.2 fi - exit ;; + ;; *:AIX:*:[4567]) - IBM_CPU_ID=$(/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }') + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if test -x /usr/bin/lslpp ; then - IBM_REV=$(/usr/bin/lslpp -Lqc bos.rte.libc | - awk -F: '{ print $3 }' | sed s/[0-9]*$/0/) + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo "$IBM_ARCH"-ibm-aix"$IBM_REV" - exit ;; + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; + GUESS=rs6000-ibm-aix + ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) - echo romp-ibm-bsd4.4 - exit ;; + GUESS=romp-ibm-bsd4.4 + ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; + GUESS=rs6000-bull-bosx + ;; DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; + GUESS=m68k-bull-sysv3 + ;; 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; + GUESS=m68k-hp-bsd + ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; + GUESS=m68k-hp-bsd4.4 + ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') - case "$UNAME_MACHINE" in + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if test -x /usr/bin/getconf; then - sc_cpu_version=$(/usr/bin/getconf SC_CPU_VERSION 2>/dev/null) - sc_kernel_bits=$(/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null) - case "$sc_cpu_version" in + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "$sc_kernel_bits" in + case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 @@ -714,7 +739,7 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=$("$dummy") + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac @@ -739,12 +764,12 @@ EOF HP_ARCH=hppa64 fi fi - echo "$HP_ARCH"-hp-hpux"$HPUX_REV" - exit ;; + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; ia64:HP-UX:*:*) - HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') - echo ia64-hp-hpux"$HPUX_REV" - exit ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" @@ -772,38 +797,38 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; + GUESS=unknown-hitachi-hiuxwe2 + ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) - echo hppa1.1-hp-bsd - exit ;; + GUESS=hppa1.1-hp-bsd + ;; 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; + GUESS=hppa1.0-hp-bsd + ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; + GUESS=hppa1.0-hp-mpeix + ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) - echo hppa1.1-hp-osf - exit ;; + GUESS=hppa1.1-hp-osf + ;; hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; + GUESS=hppa1.0-hp-osf + ;; i*86:OSF1:*:*) if test -x /usr/sbin/sysversion ; then - echo "$UNAME_MACHINE"-unknown-osf1mk + GUESS=$UNAME_MACHINE-unknown-osf1mk else - echo "$UNAME_MACHINE"-unknown-osf1 + GUESS=$UNAME_MACHINE-unknown-osf1 fi - exit ;; + ;; parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; + GUESS=hppa1.1-hp-lites + ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; + GUESS=c1-convex-bsd + ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd @@ -811,17 +836,18 @@ EOF fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; + GUESS=c34-convex-bsd + ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; + GUESS=c38-convex-bsd + ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; + GUESS=c4-convex-bsd + ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ @@ -829,114 +855,135 @@ EOF -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=$(uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) - FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') - FUJITSU_REL=$(echo "$UNAME_RELEASE" | sed -e 's/ /_/') - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') - FUJITSU_REL=$(echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/') - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; *:BSD/OS:*:*) - echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; arm:FreeBSD:*:*) - UNAME_PROCESSOR=$(uname -p) + UNAME_PROCESSOR=`uname -p` set_cc_for_build if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabi + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi else - echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabihf + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf fi - exit ;; + ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=$(/usr/bin/uname -p) - case "$UNAME_PROCESSOR" in + UNAME_PROCESSOR=`/usr/bin/uname -p` + case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo "$UNAME_PROCESSOR"-unknown-freebsd"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" - exit ;; + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; i*:CYGWIN*:*) - echo "$UNAME_MACHINE"-pc-cygwin - exit ;; + GUESS=$UNAME_MACHINE-pc-cygwin + ;; *:MINGW64*:*) - echo "$UNAME_MACHINE"-pc-mingw64 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; *:MINGW*:*) - echo "$UNAME_MACHINE"-pc-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; *:MSYS*:*) - echo "$UNAME_MACHINE"-pc-msys - exit ;; + GUESS=$UNAME_MACHINE-pc-msys + ;; i*:PW*:*) - echo "$UNAME_MACHINE"-pc-pw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; *:Interix*:*) - case "$UNAME_MACHINE" in + case $UNAME_MACHINE in x86) - echo i586-pc-interix"$UNAME_RELEASE" - exit ;; + GUESS=i586-pc-interix$UNAME_RELEASE + ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix"$UNAME_RELEASE" - exit ;; + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; IA64) - echo ia64-unknown-interix"$UNAME_RELEASE" - exit ;; + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; esac ;; i*:UWIN*:*) - echo "$UNAME_MACHINE"-pc-uwin - exit ;; + GUESS=$UNAME_MACHINE-pc-uwin + ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-pc-cygwin - exit ;; + GUESS=x86_64-pc-cygwin + ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; *:GNU:*:*) # the GNU system - echo "$(echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,')-unknown-$LIBC$(echo "$UNAME_RELEASE"|sed -e 's,/.*$,,')" - exit ;; + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo "$UNAME_MACHINE-unknown-$(echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]")$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')-$LIBC" - exit ;; + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; *:Minix:*:*) - echo "$UNAME_MACHINE"-unknown-minix - exit ;; + GUESS=$UNAME_MACHINE-unknown-minix + ;; aarch64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; alpha:Linux:*:*) - case $(sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null) in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -947,63 +994,63 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; arm*:Linux:*:*) set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi - exit ;; + ;; avr32*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; cris:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; crisv32:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; e2k:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; frv:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; hexagon:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; ia64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; k1om:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m32r*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m68*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; mips:Linux:*:* | mips64:Linux:*:*) set_cc_for_build IS_GLIBC=0 @@ -1048,138 +1095,150 @@ EOF #endif #endif EOF - eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI')" + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-"$LIBC" - exit ;; + GUESS=or1k-unknown-linux-$LIBC + ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; padre:Linux:*:*) - echo sparc-unknown-linux-"$LIBC" - exit ;; + GUESS=sparc-unknown-linux-$LIBC + ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-"$LIBC" - exit ;; + GUESS=hppa64-unknown-linux-$LIBC + ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level - case $(grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2) in - PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; - PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; - *) echo hppa-unknown-linux-"$LIBC" ;; + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; esac - exit ;; + ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc64-unknown-linux-$LIBC + ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc-unknown-linux-$LIBC + ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc64le-unknown-linux-$LIBC + ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpcle-unknown-linux-$LIBC + ;; riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; s390:Linux:*:* | s390x:Linux:*:*) - echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; sh64*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sh*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; tile*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; vax:Linux:*:*) - echo "$UNAME_MACHINE"-dec-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; x86_64:Linux:*:*) set_cc_for_build + CPU=$UNAME_MACHINE LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then - if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_X32 >/dev/null - then - LIBCABI="$LIBC"x32 - fi + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __i386__ + ABI=x86 + #else + #ifdef __ILP32__ + ABI=x32 + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + x86) CPU=i686 ;; + x32) LIBCABI=${LIBC}x32 ;; + esac fi - echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" - exit ;; + GUESS=$CPU-pc-linux-$LIBCABI + ;; xtensa*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; + GUESS=i386-sequent-sysv4 + ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" - exit ;; + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo "$UNAME_MACHINE"-pc-os2-emx - exit ;; + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; i*86:XTS-300:*:STOP) - echo "$UNAME_MACHINE"-unknown-stop - exit ;; + GUESS=$UNAME_MACHINE-unknown-stop + ;; i*86:atheos:*:*) - echo "$UNAME_MACHINE"-unknown-atheos - exit ;; + GUESS=$UNAME_MACHINE-unknown-atheos + ;; i*86:syllable:*:*) - echo "$UNAME_MACHINE"-pc-syllable - exit ;; + GUESS=$UNAME_MACHINE-pc-syllable + ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; i*86:*DOS:*:*) - echo "$UNAME_MACHINE"-pc-msdosdjgpp - exit ;; + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; i*86:*:4.*:*) - UNAME_REL=$(echo "$UNAME_RELEASE" | sed 's/\/MP$//') + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else - echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi - exit ;; + ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. - case $(/bin/uname -X | grep "^Machine") in + case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" - exit ;; + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then - UNAME_REL=$(sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=$( (/bin/uname -X|grep Release|sed -e 's/.*= //')) + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 @@ -1187,11 +1246,11 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else - echo "$UNAME_MACHINE"-pc-sysv32 + GUESS=$UNAME_MACHINE-pc-sysv32 fi - exit ;; + ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1199,37 +1258,37 @@ EOF # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; + GUESS=i586-pc-msdosdjgpp + ;; Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; + GUESS=i386-pc-mach3 + ;; paragon:*:*:*) - echo i860-intel-osf1 - exit ;; + GUESS=i860-intel-osf1 + ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi - exit ;; + ;; mini*:CTIX:SYS*5:*) # "miniframe" - echo m68010-convergent-sysv - exit ;; + GUESS=m68010-convergent-sysv + ;; mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; + GUESS=m68k-convergent-sysv + ;; M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; + GUESS=m68k-diab-dnix + ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ - && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ @@ -1240,7 +1299,7 @@ EOF NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ - && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ @@ -1248,118 +1307,121 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; + GUESS=m68k-atari-sysv4 + ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv"$UNAME_RELEASE" - exit ;; + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=$( (uname -p) 2>/dev/null) - echo "$UNAME_MACHINE"-sni-sysv4 + UNAME_MACHINE=`(uname -p) 2>/dev/null` + GUESS=$UNAME_MACHINE-sni-sysv4 else - echo ns32k-sni-sysv + GUESS=ns32k-sni-sysv fi - exit ;; + ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says - echo i586-unisys-sysv4 - exit ;; + GUESS=i586-unisys-sysv4 + ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; + GUESS=hppa1.1-stratus-sysv4 + ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; + GUESS=i860-stratus-sysv4 + ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo "$UNAME_MACHINE"-stratus-vos - exit ;; + GUESS=$UNAME_MACHINE-stratus-vos + ;; *:VOS:*:*) # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; + GUESS=hppa1.1-stratus-vos + ;; mc68*:A/UX:*:*) - echo m68k-apple-aux"$UNAME_RELEASE" - exit ;; + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; + GUESS=mips-sony-newsos6 + ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if test -d /usr/nec; then - echo mips-nec-sysv"$UNAME_RELEASE" + GUESS=mips-nec-sysv$UNAME_RELEASE else - echo mips-unknown-sysv"$UNAME_RELEASE" + GUESS=mips-unknown-sysv$UNAME_RELEASE fi - exit ;; + ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; + GUESS=powerpc-be-beos + ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; + GUESS=powerpc-apple-beos + ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; + GUESS=i586-pc-beos + ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; + GUESS=i586-pc-haiku + ;; + ppc:Haiku:*:*) # Haiku running on Apple PowerPC + GUESS=powerpc-apple-haiku + ;; + *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) + GUESS=$UNAME_MACHINE-unknown-haiku + ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; *:Rhapsody:*:*) - echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; arm64:Darwin:*:*) - echo aarch64-apple-darwin"$UNAME_RELEASE" - exit ;; + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; *:Darwin:*:*) - UNAME_PROCESSOR=$(uname -p) + UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac @@ -1393,109 +1455,119 @@ EOF # uname -m returns i386 or x86_64 UNAME_PROCESSOR=$UNAME_MACHINE fi - echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=$(uname -p) + UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; *:QNX:*:4*) - echo i386-pc-qnx - exit ;; + GUESS=i386-pc-qnx + ;; NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; NSV-*:NONSTOP_KERNEL:*:*) - echo nsv-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; + GUESS=mips-compaq-nonstopux + ;; BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; + GUESS=bs2000-siemens-sysv + ;; DS/*:UNIX_System_V:*:*) - echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - # shellcheck disable=SC2154 - if test "$cputype" = 386; then + if test "${cputype-}" = 386; then UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype fi - echo "$UNAME_MACHINE"-unknown-plan9 - exit ;; + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; + GUESS=pdp10-unknown-tops10 + ;; *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; + GUESS=pdp10-unknown-tenex + ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; + GUESS=pdp10-dec-tops20 + ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; + GUESS=pdp10-xkl-tops20 + ;; *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; + GUESS=pdp10-unknown-tops20 + ;; *:ITS:*:*) - echo pdp10-unknown-its - exit ;; + GUESS=pdp10-unknown-its + ;; SEI:*:*:SEIUX) - echo mips-sei-seiux"$UNAME_RELEASE" - exit ;; + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; *:DragonFly:*:*) - echo "$UNAME_MACHINE"-unknown-dragonfly"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" - exit ;; + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; *:*VMS:*:*) - UNAME_MACHINE=$( (uname -p) 2>/dev/null) - case "$UNAME_MACHINE" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; + GUESS=i386-pc-xenix + ;; i*86:skyos:*:*) - echo "$UNAME_MACHINE"-pc-skyos"$(echo "$UNAME_RELEASE" | sed -e 's/ .*$//')" - exit ;; + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; i*86:rdos:*:*) - echo "$UNAME_MACHINE"-pc-rdos - exit ;; + GUESS=$UNAME_MACHINE-pc-rdos + ;; + i*86:Fiwix:*:*) + GUESS=$UNAME_MACHINE-pc-fiwix + ;; *:AROS:*:*) - echo "$UNAME_MACHINE"-unknown-aros - exit ;; + GUESS=$UNAME_MACHINE-unknown-aros + ;; x86_64:VMkernel:*:*) - echo "$UNAME_MACHINE"-unknown-esx - exit ;; + GUESS=$UNAME_MACHINE-unknown-esx + ;; amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; + GUESS=x86_64-unknown-onefs + ;; *:Unleashed:*:*) - echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; esac +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" </dev/null); + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else @@ -1627,7 +1699,7 @@ main () } EOF -$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=$($dummy) && +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. @@ -1635,7 +1707,7 @@ test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } echo "$0: unable to guess system type" >&2 -case "$UNAME_MACHINE:$UNAME_SYSTEM" in +case $UNAME_MACHINE:$UNAME_SYSTEM in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 </dev/null || echo unknown) -uname -r = $( (uname -r) 2>/dev/null || echo unknown) -uname -s = $( (uname -s) 2>/dev/null || echo unknown) -uname -v = $( (uname -v) 2>/dev/null || echo unknown) +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` -/usr/bin/uname -p = $( (/usr/bin/uname -p) 2>/dev/null) -/bin/uname -X = $( (/bin/uname -X) 2>/dev/null) +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` -hostinfo = $( (hostinfo) 2>/dev/null) -/bin/universe = $( (/bin/universe) 2>/dev/null) -/usr/bin/arch -k = $( (/usr/bin/arch -k) 2>/dev/null) -/bin/arch = $( (/bin/arch) 2>/dev/null) -/usr/bin/oslevel = $( (/usr/bin/oslevel) 2>/dev/null) -/usr/convex/getsysinfo = $( (/usr/convex/getsysinfo) 2>/dev/null) +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" diff --git a/libpcap/config.h.in b/libpcap/config.h.in index a1e371a93..282a95591 100644 --- a/libpcap/config.h.in +++ b/libpcap/config.h.in @@ -72,8 +72,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the `dag' library (-ldag). */ -#undef HAVE_LIBDAG +/* Define to 1 if you have the `bsd' library (-lbsd). */ +#undef HAVE_LIBBSD /* if libdlpi exists */ #undef HAVE_LIBDLPI @@ -132,9 +132,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NET_PFILT_H -/* Define to 1 if you have the header file. */ -#undef HAVE_NET_PFVAR_H - /* Define to 1 if you have the header file. */ #undef HAVE_NET_RAW_H @@ -144,9 +141,6 @@ /* if there's an os_proto.h for this platform, to use additional prototypes */ #undef HAVE_OS_PROTO_H -/* define if net/pfvar.h defines PF_NAT through PF_NORDR */ -#undef HAVE_PF_NAT_THROUGH_PF_NORDR - /* Define to 1 if you have a POSIX-style `strerror_r' function. */ #undef HAVE_POSIX_STRERROR_R @@ -271,9 +265,6 @@ /* IPv6 */ #undef INET6 -/* path for device for USB sniffing */ -#undef LINUX_USB_MON_DEV - /* Define to 1 if netinet/ether.h declares `ether_hostton' */ #undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON @@ -328,6 +319,12 @@ /* target host supports RDMA sniffing */ #undef PCAP_SUPPORT_RDMASNIFF +/* The size of `const void *', as computed by sizeof. */ +#undef SIZEOF_CONST_VOID_P + +/* The size of `void *', as computed by sizeof. */ +#undef SIZEOF_VOID_P + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS diff --git a/libpcap/config.sub b/libpcap/config.sub index 7f7d0b055..de4259e40 100755 --- a/libpcap/config.sub +++ b/libpcap/config.sub @@ -1,12 +1,14 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2021 Free Software Foundation, Inc. +# Copyright 1992-2023 Free Software Foundation, Inc. -timestamp='2021-03-10' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2023-01-21' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -50,7 +52,14 @@ timestamp='2021-03-10' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. -me=$(echo "$0" | sed -e 's,.*/,,') +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + +me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS @@ -67,7 +76,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2021 Free Software Foundation, Inc. +Copyright 1992-2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -112,9 +121,11 @@ esac # Split fields of configuration type # shellcheck disable=SC2162 +saved_IFS=$IFS IFS="-" read field1 field2 field3 field4 <&2 exit 1 @@ -1742,16 +1778,27 @@ esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. case $kernel-$os in - linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ + | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* ) ;; uclinux-uclibc* ) ;; - -dietlibc* | -newlib* | -musl* | -uclibc* ) + managarm-mlibc* | managarm-kernel* ) + ;; + -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* ) # These are just libc implementations, not actual OSes, and thus # require a kernel. echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 exit 1 ;; + -kernel* ) + echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + *-kernel* ) + echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2 + exit 1 + ;; kfreebsd*-gnu* | kopensolaris*-gnu*) ;; vxworks-simlinux | vxworks-simwindows | vxworks-spe) diff --git a/libpcap/configure b/libpcap/configure index 157ba9717..374572da2 100755 --- a/libpcap/configure +++ b/libpcap/configure @@ -1,10 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for pcap 1.10.1. +# Generated by GNU Autoconf 2.69 for pcap 1.10.4. # # -# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, -# Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -15,16 +14,14 @@ # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: -if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else $as_nop +else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( @@ -34,46 +31,46 @@ esac fi - -# Reset variables that may have inherited troublesome values from -# the environment. - -# IFS needs to be set, to space, tab, and newline, in precisely that order. -# (If _AS_PATH_WALK were called with IFS unset, it would have the -# side effect of setting IFS to empty, thus disabling word splitting.) -# Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl -IFS=" "" $as_nl" - -PS1='$ ' -PS2='> ' -PS4='+ ' - -# Ensure predictable behavior from utilities with locale-dependent output. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# We cannot yet rely on "unset" to work, but we need these variables -# to be unset--not just set to an empty or harmless value--now, to -# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct -# also avoids known problems related to "unset" and subshell syntax -# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). -for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH -do eval test \${$as_var+y} \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done - -# Ensure that fds 0, 1, and 2 are open. -if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi -if (exec 3>&2) ; then :; else exec 2>/dev/null; fi +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi # The user is always right. -if ${PATH_SEPARATOR+false} :; then +if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || @@ -82,6 +79,13 @@ if ${PATH_SEPARATOR+false} :; then fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( @@ -90,12 +94,8 @@ case $0 in #(( for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - test -r "$as_dir$0" && as_myself=$as_dir$0 && break + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS @@ -107,10 +107,30 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. @@ -132,22 +152,20 @@ esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. -printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="as_nop=: -if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST -else \$as_nop +else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( @@ -167,52 +185,42 @@ as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ) -then : +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : -else \$as_nop +else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 -blah=\$(echo \$(echo blah)) -test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" - if (eval "$as_required") 2>/dev/null -then : + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : as_have_required=yes -else $as_nop +else as_have_required=no fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null -then : + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : -else $as_nop +else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. - as_shell=$as_dir$as_base + as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null -then : + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes - if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null -then : + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi @@ -220,21 +228,14 @@ fi esac as_found=false done -IFS=$as_save_IFS -if $as_found -then : - -else $as_nop - if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null -then : +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes -fi -fi +fi; } +IFS=$as_save_IFS - if test "x$CONFIG_SHELL" != x -then : + if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also @@ -252,19 +253,18 @@ esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. -printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi - if test x$as_have_required = xno -then : - printf "%s\n" "$0: This script requires a shell more modern than all" - printf "%s\n" "$0: the shells that I found on your system." - if test ${ZSH_VERSION+y} ; then - printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" - printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." else - printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." @@ -291,7 +291,6 @@ as_fn_unset () } as_unset=as_fn_unset - # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. @@ -309,14 +308,6 @@ as_fn_exit () as_fn_set_status $1 exit $1 } # as_fn_exit -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop # as_fn_mkdir_p # ------------- @@ -331,7 +322,7 @@ as_fn_mkdir_p () as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -340,7 +331,7 @@ $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_dir" | +$as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -379,13 +370,12 @@ as_fn_executable_p () # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null -then : +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' -else $as_nop +else as_fn_append () { eval $1=\$$1\$2 @@ -397,27 +387,18 @@ fi # as_fn_append # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null -then : +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' -else $as_nop +else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- @@ -429,9 +410,9 @@ as_fn_error () as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - printf "%s\n" "$as_me: error: $2" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -458,7 +439,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -502,7 +483,7 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall @@ -516,10 +497,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits exit } - -# Determine whether it's possible to make 'echo' print without a newline. -# These variables are no longer used directly by Autoconf, but are AC_SUBSTed -# for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) @@ -533,13 +510,6 @@ case `echo -n x` in #((((( ECHO_N='-n';; esac -# For backward compatibility with old third-party macros, we provide -# the shell variables $as_echo and $as_echo_n. New code should use -# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. -as_echo='printf %s\n' -as_echo_n='printf %s' - - rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file @@ -607,94 +577,115 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pcap' PACKAGE_TARNAME='pcap' -PACKAGE_VERSION='1.10.1' -PACKAGE_STRING='pcap 1.10.1' +PACKAGE_VERSION='1.10.4' +PACKAGE_STRING='pcap 1.10.4' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="pcap.c" # Factoring default headers for most tests. ac_includes_default="\ -#include -#ifdef HAVE_STDIO_H -# include +#include +#ifdef HAVE_SYS_TYPES_H +# include #endif -#ifdef HAVE_STDLIB_H +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS # include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif #endif #ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif # include #endif +#ifdef HAVE_STRINGS_H +# include +#endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif #ifdef HAVE_UNISTD_H # include #endif" -ac_header_c_list= ac_subst_vars='LTLIBOBJS -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -PCAP_SUPPORT_RDMASNIFF -PCAP_SUPPORT_DBUS -PCAP_SUPPORT_BT -PCAP_SUPPORT_DPDK -PCAP_SUPPORT_NETMAP -PCAP_SUPPORT_NETFILTER -PCAP_SUPPORT_LINUX_USBMON -EXTRA_NETWORK_LIBS RPCAPD_LIBS INSTALL_RPCAPD BUILD_RPCAPD PTHREAD_LIBS -MAN_ADMIN_COMMANDS -MAN_MISC_INFO -MAN_FILE_FORMATS -MAN_DEVICES -DYEXT REMOTE_C_SRC MODULE_C_SRC PLATFORM_CXX_SRC PLATFORM_C_SRC ADDLARCHIVEOBJS ADDLOBJS -V_RPATH_OPT +RPATH V_SONAME_OPT V_SHLIB_OPT V_SHLIB_CMD V_SHLIB_CCOPT -V_INCLS -V_DEFS -V_PROG_LDFLAGS_FAT -V_PROG_CCOPT_FAT -V_LIB_LDFLAGS_FAT -V_LIB_CCOPT_FAT -V_CCOPT +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +PCAP_SUPPORT_RDMASNIFF +LIBIBVERBS_LIBS_STATIC +LIBIBVERBS_LIBS +LIBIBVERBS_CFLAGS +PCAP_SUPPORT_DBUS +DBUS_LIBS_STATIC +DBUS_LIBS +DBUS_CFLAGS +PCAP_SUPPORT_BT +PCAP_SUPPORT_DPDK +DPDK_LIBS_STATIC +DPDK_LIBS +DPDK_CFLAGS +PCAP_SUPPORT_NETMAP +PCAP_SUPPORT_NETFILTER +PCAP_SUPPORT_LINUX_USBMON MKDEP DEPENDENCY_CFLAG LN_S AR RANLIB -PKGCONFIG +MAN_ADMIN_COMMANDS +MAN_MISC_INFO +MAN_FILE_FORMATS +MAN_DEVICES +DYEXT +V_PROG_LDFLAGS_FAT +V_PROG_CCOPT_FAT +V_LIB_LDFLAGS_FAT +V_LIB_CCOPT_FAT +OPENSSL_LIBS_STATIC +OPENSSL_LIBS +OPENSSL_CFLAGS +LIBNL_LIBS_STATIC +LIBNL_LIBS +LIBNL_CFLAGS +BREW +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG VALGRINDTEST_SRC LIBOBJS ac_ct_CXX CXXFLAGS CXX +EGREP +GREP +CPP OBJEXT EXEEXT ac_ct_CC @@ -715,6 +706,12 @@ build_os build_vendor build_cpu build +LIBS_PRIVATE +REQUIRES_PRIVATE +LIBS_STATIC +V_INCLS +V_DEFS +V_CCOPT target_alias host_alias build_alias @@ -791,9 +788,28 @@ CFLAGS LDFLAGS LIBS CPPFLAGS +CPP CXX CXXFLAGS -CCC' +CCC +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR +LIBNL_CFLAGS +LIBNL_LIBS +LIBNL_LIBS_STATIC +OPENSSL_CFLAGS +OPENSSL_LIBS +OPENSSL_LIBS_STATIC +DPDK_CFLAGS +DPDK_LIBS +DPDK_LIBS_STATIC +DBUS_CFLAGS +DBUS_LIBS +DBUS_LIBS_STATIC +LIBIBVERBS_CFLAGS +LIBIBVERBS_LIBS +LIBIBVERBS_LIBS_STATIC' # Initialize some variables set by options. @@ -862,6 +878,8 @@ do *) ac_optarg=yes ;; esac + # Accept the important Cygnus configure options, so we can diagnose typos. + case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; @@ -902,9 +920,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" @@ -928,9 +946,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" @@ -1141,9 +1159,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" @@ -1157,9 +1175,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" @@ -1203,9 +1221,9 @@ Try \`$0 --help' for more information" *) # FIXME: should be removed in autoconf 3.0. - printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; @@ -1221,7 +1239,7 @@ if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1285,7 +1303,7 @@ $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_myself" | +$as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -1342,7 +1360,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pcap 1.10.1 to adapt to many kinds of systems. +\`configure' configures pcap 1.10.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1409,7 +1427,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pcap 1.10.1:";; + short | recursive ) echo "Configuration of pcap 1.10.4:";; esac cat <<\_ACEOF @@ -1421,7 +1439,6 @@ Optional Features: --disable-protochain disable \"protochain\" insn --enable-ipv6 build IPv6-capable version [default=yes] --enable-remote enable remote packet capture [default=no] - --disable-remote disable remote packet capture --enable-optimizer-dbg build optimizer debugging code --enable-yydebug build parser debugging code --disable-universal don't build universal on macOS @@ -1468,8 +1485,40 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory + CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags + PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path + LIBNL_CFLAGS + C compiler flags for libnl-genl-3.0, overriding pkg-config + LIBNL_LIBS linker flags for libnl-genl-3.0, overriding pkg-config + LIBNL_LIBS_STATIC + static-link linker flags for libnl-genl-3.0, overriding + pkg-config + OPENSSL_CFLAGS + C compiler flags for openssl, overriding pkg-config + OPENSSL_LIBS + linker flags for openssl, overriding pkg-config + OPENSSL_LIBS_STATIC + static-link linker flags for openssl, overriding pkg-config + DPDK_CFLAGS C compiler flags for libdpdk, overriding pkg-config + DPDK_LIBS linker flags for libdpdk, overriding pkg-config + DPDK_LIBS_STATIC + static-link linker flags for libdpdk, overriding pkg-config + DBUS_CFLAGS C compiler flags for dbus-1, overriding pkg-config + DBUS_LIBS linker flags for dbus-1, overriding pkg-config + DBUS_LIBS_STATIC + static-link linker flags for dbus-1, overriding pkg-config + LIBIBVERBS_CFLAGS + C compiler flags for libibverbs, overriding pkg-config + LIBIBVERBS_LIBS + linker flags for libibverbs, overriding pkg-config + LIBIBVERBS_LIBS_STATIC + static-link linker flags for libibverbs, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1490,9 +1539,9 @@ if test "$ac_init_help" = "recursive"; then case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -1520,8 +1569,7 @@ esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } - # Check for configure.gnu first; this name is used for a wrapper for - # Metaconfig's "Configure" on case-insensitive file systems. + # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive @@ -1529,7 +1577,7 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix echo && $SHELL "$ac_srcdir/configure" --help=recursive else - printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done @@ -1538,10 +1586,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pcap configure 1.10.1 -generated by GNU Autoconf 2.71 +pcap configure 1.10.4 +generated by GNU Autoconf 2.69 -Copyright (C) 2021 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1558,14 +1606,14 @@ fi ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam + rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1573,15 +1621,14 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext -then : + } && test -s conftest.$ac_objext; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1591,20 +1638,313 @@ fi } # ac_fn_c_try_compile +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam + rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1612,15 +1952,14 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext -then : + } && test -s conftest.$ac_objext; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1630,38 +1969,317 @@ fi } # ac_fn_cxx_try_compile -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + +# ac_fn_cxx_compute_int LINENO EXPR VAR INCLUDES +# ---------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_cxx_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 #include <$2> _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - eval "$3=yes" -else $as_nop - eval "$3=no" +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -} # ac_fn_c_check_header_compile +} # ac_fn_c_check_header_mongrel # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- @@ -1669,12 +2287,11 @@ printf "%s\n" "$ac_res" >&6; } ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. @@ -1682,9 +2299,16 @@ else $as_nop #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. */ + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif -#include #undef $2 /* Override any GCC internal prototype to avoid an error. @@ -1702,51 +2326,47 @@ choke me #endif int -main (void) +main () { return $2 (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" -else $as_nop +else eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func -# ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR -# ------------------------------------------------------------------ +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR. -ac_fn_check_decl () +# accordingly. +ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -printf %s "checking whether $as_decl_name is declared... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - eval ac_save_FLAGS=\$$6 - as_fn_append $6 " $5" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main (void) +main () { #ifndef $as_decl_name #ifdef __cplusplus @@ -1760,22 +2380,19 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" -else $as_nop +else eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - eval $6=\$ac_save_FLAGS - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -} # ac_fn_check_decl +} # ac_fn_c_check_decl # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- @@ -1784,18 +2401,17 @@ printf "%s\n" "$ac_res" >&6; } ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main (void) +main () { if (sizeof ($2)) return 0; @@ -1803,13 +2419,12 @@ if (sizeof ($2)) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main (void) +main () { if (sizeof (($2))) return 0; @@ -1817,19 +2432,18 @@ if (sizeof (($2))) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -else $as_nop +else eval "$3=yes" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type @@ -1841,17 +2455,16 @@ printf "%s\n" "$ac_res" >&6; } ac_fn_c_check_member () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -printf %s "checking for $2.$3... " >&6; } -if eval test \${$4+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval \${$4+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int -main (void) +main () { static $2 ac_aggr; if (ac_aggr.$3) @@ -1860,15 +2473,14 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" -else $as_nop +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int -main (void) +main () { static $2 ac_aggr; if (sizeof ac_aggr.$3) @@ -1877,50 +2489,29 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" -else $as_nop +else eval "$4=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$4 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member -ac_configure_args_raw= -for ac_arg -do - case $ac_arg in - *\'*) - ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append ac_configure_args_raw " '$ac_arg'" -done - -case $ac_configure_args_raw in - *$as_nl*) - ac_safe_unquote= ;; - *) - ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. - ac_unsafe_a="$ac_unsafe_z#~" - ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" - ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; -esac - cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pcap $as_me 1.10.1, which was -generated by GNU Autoconf 2.71. Invocation command line was +It was created by pcap $as_me 1.10.4, which was +generated by GNU Autoconf 2.69. Invocation command line was - $ $0$ac_configure_args_raw + $ $0 $@ _ACEOF exec 5>>config.log @@ -1953,12 +2544,8 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - printf "%s\n" "PATH: $as_dir" + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" done IFS=$as_save_IFS @@ -1993,7 +2580,7 @@ do | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) - ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; @@ -2028,13 +2615,11 @@ done # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? - # Sanitize IFS. - IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo - printf "%s\n" "## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo @@ -2045,8 +2630,8 @@ trap 'exit_status=$? case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( @@ -2070,7 +2655,7 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ) echo - printf "%s\n" "## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo @@ -2078,14 +2663,14 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - printf "%s\n" "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then - printf "%s\n" "## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo @@ -2093,15 +2678,15 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - printf "%s\n" "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then - printf "%s\n" "## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo @@ -2109,8 +2694,8 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} echo fi test "$ac_signal" != 0 && - printf "%s\n" "$as_me: caught signal $ac_signal" - printf "%s\n" "$as_me: exit $exit_status" + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && @@ -2124,48 +2709,63 @@ ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h -printf "%s\n" "/* confdefs.h */" > confdefs.h +$as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. -printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF -printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF -printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF -printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF -printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF -printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_files="$CONFIG_SITE" + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then - ac_site_files="$prefix/share/config.site $prefix/etc/config.site" + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site else - ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site fi - -for ac_site_file in $ac_site_files +for ac_site_file in "$ac_site_file1" "$ac_site_file2" do - case $ac_site_file in #( - */*) : - ;; #( - *) : - ac_site_file=./$ac_site_file ;; -esac - if test -f "$ac_site_file" && test -r "$ac_site_file"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ - || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi @@ -2175,650 +2775,19 @@ if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -printf "%s\n" "$as_me: loading cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -printf "%s\n" "$as_me: creating cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi -# Test code for whether the C compiler supports C89 (global declarations) -ac_c_conftest_c89_globals=' -/* Does the compiler advertise C89 conformance? - Do not test the value of __STDC__, because some compilers set it to 0 - while being otherwise adequately conformant. */ -#if !defined __STDC__ -# error "Compiler does not advertise C89 conformance" -#endif - -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ -struct buf { int x; }; -struct buf * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not \xHH hex character constants. - These do not provoke an error unfortunately, instead are silently treated - as an "x". The following induces an error, until -std is added to get - proper ANSI mode. Curiously \x00 != x always comes out true, for an - array size at least. It is necessary to write \x00 == 0 to get something - that is true only with -std. */ -int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) '\''x'\'' -int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), - int, int);' - -# Test code for whether the C compiler supports C89 (body of main). -ac_c_conftest_c89_main=' -ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); -' - -# Test code for whether the C compiler supports C99 (global declarations) -ac_c_conftest_c99_globals=' -// Does the compiler advertise C99 conformance? -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L -# error "Compiler does not advertise C99 conformance" -#endif - -#include -extern int puts (const char *); -extern int printf (const char *, ...); -extern int dprintf (int, const char *, ...); -extern void *malloc (size_t); - -// Check varargs macros. These examples are taken from C99 6.10.3.5. -// dprintf is used instead of fprintf to avoid needing to declare -// FILE and stderr. -#define debug(...) dprintf (2, __VA_ARGS__) -#define showlist(...) puts (#__VA_ARGS__) -#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) -static void -test_varargs_macros (void) -{ - int x = 1234; - int y = 5678; - debug ("Flag"); - debug ("X = %d\n", x); - showlist (The first, second, and third items.); - report (x>y, "x is %d but y is %d", x, y); -} - -// Check long long types. -#define BIG64 18446744073709551615ull -#define BIG32 4294967295ul -#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) -#if !BIG_OK - #error "your preprocessor is broken" -#endif -#if BIG_OK -#else - #error "your preprocessor is broken" -#endif -static long long int bignum = -9223372036854775807LL; -static unsigned long long int ubignum = BIG64; - -struct incomplete_array -{ - int datasize; - double data[]; -}; - -struct named_init { - int number; - const wchar_t *name; - double average; -}; - -typedef const char *ccp; - -static inline int -test_restrict (ccp restrict text) -{ - // See if C++-style comments work. - // Iterate through items via the restricted pointer. - // Also check for declarations in for loops. - for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) - continue; - return 0; -} - -// Check varargs and va_copy. -static bool -test_varargs (const char *format, ...) -{ - va_list args; - va_start (args, format); - va_list args_copy; - va_copy (args_copy, args); - - const char *str = ""; - int number = 0; - float fnumber = 0; - - while (*format) - { - switch (*format++) - { - case '\''s'\'': // string - str = va_arg (args_copy, const char *); - break; - case '\''d'\'': // int - number = va_arg (args_copy, int); - break; - case '\''f'\'': // float - fnumber = va_arg (args_copy, double); - break; - default: - break; - } - } - va_end (args_copy); - va_end (args); - - return *str && number && fnumber; -} -' - -# Test code for whether the C compiler supports C99 (body of main). -ac_c_conftest_c99_main=' - // Check bool. - _Bool success = false; - success |= (argc != 0); - - // Check restrict. - if (test_restrict ("String literal") == 0) - success = true; - char *restrict newvar = "Another string"; - - // Check varargs. - success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); - test_varargs_macros (); - - // Check flexible array members. - struct incomplete_array *ia = - malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); - ia->datasize = 10; - for (int i = 0; i < ia->datasize; ++i) - ia->data[i] = i * 1.234; - - // Check named initializers. - struct named_init ni = { - .number = 34, - .name = L"Test wide string", - .average = 543.34343, - }; - - ni.number = 58; - - int dynamic_array[ni.number]; - dynamic_array[0] = argv[0][0]; - dynamic_array[ni.number - 1] = 543; - - // work around unused variable warnings - ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' - || dynamic_array[ni.number - 1] != 543); -' - -# Test code for whether the C compiler supports C11 (global declarations) -ac_c_conftest_c11_globals=' -// Does the compiler advertise C11 conformance? -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L -# error "Compiler does not advertise C11 conformance" -#endif - -// Check _Alignas. -char _Alignas (double) aligned_as_double; -char _Alignas (0) no_special_alignment; -extern char aligned_as_int; -char _Alignas (0) _Alignas (int) aligned_as_int; - -// Check _Alignof. -enum -{ - int_alignment = _Alignof (int), - int_array_alignment = _Alignof (int[100]), - char_alignment = _Alignof (char) -}; -_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); - -// Check _Noreturn. -int _Noreturn does_not_return (void) { for (;;) continue; } - -// Check _Static_assert. -struct test_static_assert -{ - int x; - _Static_assert (sizeof (int) <= sizeof (long int), - "_Static_assert does not work in struct"); - long int y; -}; - -// Check UTF-8 literals. -#define u8 syntax error! -char const utf8_literal[] = u8"happens to be ASCII" "another string"; - -// Check duplicate typedefs. -typedef long *long_ptr; -typedef long int *long_ptr; -typedef long_ptr long_ptr; - -// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. -struct anonymous -{ - union { - struct { int i; int j; }; - struct { int k; long int l; } w; - }; - int m; -} v1; -' - -# Test code for whether the C compiler supports C11 (body of main). -ac_c_conftest_c11_main=' - _Static_assert ((offsetof (struct anonymous, i) - == offsetof (struct anonymous, w.k)), - "Anonymous union alignment botch"); - v1.i = 2; - v1.w.k = 5; - ok |= v1.i != 5; -' - -# Test code for whether the C compiler supports C11 (complete). -ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} -${ac_c_conftest_c99_globals} -${ac_c_conftest_c11_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - ${ac_c_conftest_c99_main} - ${ac_c_conftest_c11_main} - return ok; -} -" - -# Test code for whether the C compiler supports C99 (complete). -ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} -${ac_c_conftest_c99_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - ${ac_c_conftest_c99_main} - return ok; -} -" - -# Test code for whether the C compiler supports C89 (complete). -ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - return ok; -} -" - -# Test code for whether the C++ compiler supports C++98 (global declarations) -ac_cxx_conftest_cxx98_globals=' -// Does the compiler advertise C++98 conformance? -#if !defined __cplusplus || __cplusplus < 199711L -# error "Compiler does not advertise C++98 conformance" -#endif - -// These inclusions are to reject old compilers that -// lack the unsuffixed header files. -#include -#include - -// and are *not* freestanding headers in C++98. -extern void assert (int); -namespace std { - extern int strcmp (const char *, const char *); -} - -// Namespaces, exceptions, and templates were all added after "C++ 2.0". -using std::exception; -using std::strcmp; - -namespace { - -void test_exception_syntax() -{ - try { - throw "test"; - } catch (const char *s) { - // Extra parentheses suppress a warning when building autoconf itself, - // due to lint rules shared with more typical C programs. - assert (!(strcmp) (s, "test")); - } -} - -template struct test_template -{ - T const val; - explicit test_template(T t) : val(t) {} - template T add(U u) { return static_cast(u) + val; } -}; - -} // anonymous namespace -' - -# Test code for whether the C++ compiler supports C++98 (body of main) -ac_cxx_conftest_cxx98_main=' - assert (argc); - assert (! argv[0]); -{ - test_exception_syntax (); - test_template tt (2.0); - assert (tt.add (4) == 6.0); - assert (true && !false); -} -' - -# Test code for whether the C++ compiler supports C++11 (global declarations) -ac_cxx_conftest_cxx11_globals=' -// Does the compiler advertise C++ 2011 conformance? -#if !defined __cplusplus || __cplusplus < 201103L -# error "Compiler does not advertise C++11 conformance" -#endif - -namespace cxx11test -{ - constexpr int get_val() { return 20; } - - struct testinit - { - int i; - double d; - }; - - class delegate - { - public: - delegate(int n) : n(n) {} - delegate(): delegate(2354) {} - - virtual int getval() { return this->n; }; - protected: - int n; - }; - - class overridden : public delegate - { - public: - overridden(int n): delegate(n) {} - virtual int getval() override final { return this->n * 2; } - }; - - class nocopy - { - public: - nocopy(int i): i(i) {} - nocopy() = default; - nocopy(const nocopy&) = delete; - nocopy & operator=(const nocopy&) = delete; - private: - int i; - }; - - // for testing lambda expressions - template Ret eval(Fn f, Ret v) - { - return f(v); - } - - // for testing variadic templates and trailing return types - template auto sum(V first) -> V - { - return first; - } - template auto sum(V first, Args... rest) -> V - { - return first + sum(rest...); - } -} -' - -# Test code for whether the C++ compiler supports C++11 (body of main) -ac_cxx_conftest_cxx11_main=' -{ - // Test auto and decltype - auto a1 = 6538; - auto a2 = 48573953.4; - auto a3 = "String literal"; - - int total = 0; - for (auto i = a3; *i; ++i) { total += *i; } - - decltype(a2) a4 = 34895.034; -} -{ - // Test constexpr - short sa[cxx11test::get_val()] = { 0 }; -} -{ - // Test initializer lists - cxx11test::testinit il = { 4323, 435234.23544 }; -} -{ - // Test range-based for - int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, - 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; - for (auto &x : array) { x += 23; } -} -{ - // Test lambda expressions - using cxx11test::eval; - assert (eval ([](int x) { return x*2; }, 21) == 42); - double d = 2.0; - assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0); - assert (d == 5.0); - assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0); - assert (d == 5.0); -} -{ - // Test use of variadic templates - using cxx11test::sum; - auto a = sum(1); - auto b = sum(1, 2); - auto c = sum(1.0, 2.0, 3.0); -} -{ - // Test constructor delegation - cxx11test::delegate d1; - cxx11test::delegate d2(); - cxx11test::delegate d3(45); -} -{ - // Test override and final - cxx11test::overridden o1(55464); -} -{ - // Test nullptr - char *c = nullptr; -} -{ - // Test template brackets - test_template<::test_template> v(test_template(12)); -} -{ - // Unicode literals - char const *utf8 = u8"UTF-8 string \u2500"; - char16_t const *utf16 = u"UTF-8 string \u2500"; - char32_t const *utf32 = U"UTF-32 string \u2500"; -} -' - -# Test code for whether the C compiler supports C++11 (complete). -ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals} -${ac_cxx_conftest_cxx11_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_cxx_conftest_cxx98_main} - ${ac_cxx_conftest_cxx11_main} - return ok; -} -" - -# Test code for whether the C compiler supports C++98 (complete). -ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals} -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_cxx_conftest_cxx98_main} - return ok; -} -" - -as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" -as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" -as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" -as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" -as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" -as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" -as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" -as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" -as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" - -# Auxiliary files required by this configure script. -ac_aux_files="install-sh config.guess config.sub" - -# Locations in which to look for auxiliary files. -ac_aux_dir_candidates="${srcdir}${PATH_SEPARATOR}${srcdir}/..${PATH_SEPARATOR}${srcdir}/../.." - -# Search for a directory containing all of the required auxiliary files, -# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. -# If we don't find one directory that contains all the files we need, -# we report the set of missing files from the *first* directory in -# $ac_aux_dir_candidates and give up. -ac_missing_aux_files="" -ac_first_candidate=: -printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in $ac_aux_dir_candidates -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - as_found=: - - printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 - ac_aux_dir_found=yes - ac_install_sh= - for ac_aux in $ac_aux_files - do - # As a special case, if "install-sh" is required, that requirement - # can be satisfied by any of "install-sh", "install.sh", or "shtool", - # and $ac_install_sh is set appropriately for whichever one is found. - if test x"$ac_aux" = x"install-sh" - then - if test -f "${as_dir}install-sh"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 - ac_install_sh="${as_dir}install-sh -c" - elif test -f "${as_dir}install.sh"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 - ac_install_sh="${as_dir}install.sh -c" - elif test -f "${as_dir}shtool"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 - ac_install_sh="${as_dir}shtool install -c" - else - ac_aux_dir_found=no - if $ac_first_candidate; then - ac_missing_aux_files="${ac_missing_aux_files} install-sh" - else - break - fi - fi - else - if test -f "${as_dir}${ac_aux}"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 - else - ac_aux_dir_found=no - if $ac_first_candidate; then - ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" - else - break - fi - fi - fi - done - if test "$ac_aux_dir_found" = yes; then - ac_aux_dir="$as_dir" - break - fi - ac_first_candidate=false - - as_found=false -done -IFS=$as_save_IFS -if $as_found -then : - -else $as_nop - as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 -fi - - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -if test -f "${ac_aux_dir}config.guess"; then - ac_config_guess="$SHELL ${ac_aux_dir}config.guess" -fi -if test -f "${ac_aux_dir}config.sub"; then - ac_config_sub="$SHELL ${ac_aux_dir}config.sub" -fi -if test -f "$ac_aux_dir/configure"; then - ac_configure="$SHELL ${ac_aux_dir}configure" -fi - # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false @@ -2829,12 +2798,12 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) @@ -2843,24 +2812,24 @@ printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -2870,12 +2839,11 @@ printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi done if $ac_cache_corrupted; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' - and start over" "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2891,30 +2859,135 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# +# These are the variables that are used in Makefile, pcap-config, and +# libpcap.pc. +# +# CFLAGS: inherited from the environment, not modified by us (except +# temporarily during tests that involve compilation). Used only when +# compiling C source. +# +# CXXFLAGS: inherited from the environment, not modified by us. Used only +# when compiling C++ source. +# +# LDFLAGS: inherited from the environment, not modified by us. +# +# LIBS: inherited from the environment; we add libraries required by +# libpcap. Librares that the core libpcap code requires are added +# first; libraries required by additional pcap modules are first +# added to ADDITIONAL_LIBS, and only added to LIBS at the end, after +# we're finished doing configuration tests for the modules. +# +# LIBS_STATIC: libraries with which a program using the libpcap *static* +# library needs to be linked. This is a superset of LIBS, used in +# pcap-config, so that "pcap-config --libs --static" will report them. +# Initialized to LIBS. +# +# REQUIRES_PRIVATE: pkg-config package names for additional libraries +# with which a program using the libpcap *static* library needs to be +# linked and for which a .pc file exists. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them, and so that +# those libraries will be determined using the library's .pc file, not +# from our .pc file. Initialized to an empty string. +# +# V_CCOPT: additional compiler flags other than -I and -D flags +# needed when compiling libpcap. Used in Makefile for both C and +# C++ source. +# +# V_DEFS: additional -D compiler flags needed when compiling +# libpcap. Used in Makefile for both C and C++ source. +# +# V_INCLS: additional -I compiler flags needed when compiling +# libpcap. Used in Makefile for both C and C++ source. +# +# ADDITIONAL_LIBS: additional libraries with which the libpcap dynamic +# library needs to be linked. Used in Makwfile; not used in pcap-config +# or libpcap.pc, as, in all platforms on which we run, if a dynamic +# library is linked with other dynamic libraries, a program using +# that dynamic library doesn't have to link with those libraries - +# they will be automatically loaded at run time. Initialized to an +# empty string. +# +# ADDITIONAL_LIBS_STATIC: additional libraries with which a program +# using the libpcap *static* library needs to be linked. This is used +# in pcap-config, so that "pcap-config --libs --static" will report +# them. Initialized to an empty string. +# +# REQUIRES_PRIVATE: pkg-config package names for additional libraries +# with which a program using the libpcap *static* library needs to be +# linked and for which a .pc file exists. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them, and so that +# those libraries will be determined using the library's .pc file, not +# from our .pc file. Initialized to an empty string. +# +# LIBS_PRIVATE: pkg-config package names for additional libraries with +# which a program using the libpcap *static* library needs to be linked +# and for which a .pc file does not exist. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them (those libraries +# cannot be determined using the library's .pc file, as there is no such +# file, so it has to come from our .pc file. Initialized to an empty +# string. +# +LIBS_STATIC="" +REQUIRES_PRIVATE="" +LIBS_PRIVATE="" - # Make sure we can run config.sub. -$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -printf %s "checking build system type... " >&6; } -if test ${ac_cv_build+y} -then : - printf %s "(cached) " >&6 -else $as_nop + + + + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_build_alias=$build_alias test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -printf "%s\n" "$ac_cv_build" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; @@ -2933,22 +3006,21 @@ IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -printf %s "checking host system type... " >&6; } -if test ${ac_cv_host+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else - ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -printf "%s\n" "$ac_cv_host" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; @@ -2967,22 +3039,21 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 -printf %s "checking target system type... " >&6; } -if test ${ac_cv_target+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +$as_echo_n "checking target system type... " >&6; } +if ${ac_cv_target+:} false; then : + $as_echo_n "(cached) " >&6 +else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else - ac_cv_target=`$SHELL "${ac_aux_dir}config.sub" $target_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $target_alias failed" "$LINENO" 5 + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 -printf "%s\n" "$ac_cv_target" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +$as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; @@ -3016,8 +3087,7 @@ test -n "$target_alias" && # Check whether --with-gcc was given. -if test ${with_gcc+y} -then : +if test "${with_gcc+set}" = set; then : withval=$with_gcc; fi @@ -3034,12 +3104,11 @@ fi bsdi*) # Extract the first word of "shlicc2", so it can be a program name with args. set dummy shlicc2; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_SHLICC2+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_SHLICC2+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$SHLICC2"; then ac_cv_prog_SHLICC2="$SHLICC2" # Let the user override the test. else @@ -3047,15 +3116,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_SHLICC2="yes" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3067,11 +3132,11 @@ fi fi SHLICC2=$ac_cv_prog_SHLICC2 if test -n "$SHLICC2"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SHLICC2" >&5 -printf "%s\n" "$SHLICC2" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLICC2" >&5 +$as_echo "$SHLICC2" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3092,15 +3157,6 @@ fi # Try to get it, which may involve adding compiler flags; # if that fails, give up. # - - - - - - - - - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -3109,12 +3165,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3122,15 +3177,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3141,11 +3192,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3154,12 +3205,11 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else @@ -3167,15 +3217,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3186,11 +3232,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then @@ -3198,8 +3244,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $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 CC=$ac_ct_CC @@ -3212,12 +3258,11 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3225,15 +3270,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3244,11 +3285,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3257,12 +3298,11 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3271,19 +3311,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 - if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3299,18 +3335,18 @@ if test $ac_prog_rejected = yes; then # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3321,12 +3357,11 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3334,15 +3369,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3353,11 +3384,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3370,12 +3401,11 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else @@ -3383,15 +3413,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3402,11 +3428,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3418,8 +3444,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $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 CC=$ac_ct_CC @@ -3427,129 +3453,25 @@ esac fi fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. -set dummy ${ac_tool_prefix}clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "clang", so it can be a program name with args. -set dummy clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -fi - - -test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -for ac_option in --version -v -V -qversion -version; do +for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -3559,7 +3481,7 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done @@ -3567,7 +3489,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; @@ -3579,9 +3501,9 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -printf %s "checking whether the C compiler works... " >&6; } -ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" @@ -3602,12 +3524,11 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -3624,7 +3545,7 @@ do # certainly right. break;; *.* ) - if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -3640,46 +3561,44 @@ do done test "$ac_cv_exeext" = no && ac_cv_exeext= -else $as_nop +else ac_file='' fi -if test -z "$ac_file" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -printf "%s\n" "$as_me: failed program was:" >&5 +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -printf %s "checking for C compiler default output file name... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -printf "%s\n" "$ac_file" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -printf %s "checking for suffix of executables... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -3693,15 +3612,15 @@ for ac_file in conftest.exe conftest conftest.*; do * ) break;; esac done -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -printf "%s\n" "$ac_cv_exeext" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext @@ -3710,7 +3629,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; @@ -3722,8 +3641,8 @@ _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -printf %s "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in @@ -3731,10 +3650,10 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in @@ -3742,40 +3661,39 @@ printf "%s\n" "$ac_try_echo"; } >&5 *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot run C compiled programs. + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -printf "%s\n" "$cross_compiling" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -printf %s "checking for suffix of object files... " >&6; } -if test ${ac_cv_objext+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; @@ -3789,12 +3707,11 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -3803,32 +3720,31 @@ then : break;; esac done -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -printf "%s\n" "$ac_cv_objext" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 -printf %s "checking whether the compiler supports GNU C... " >&6; } -if test ${ac_cv_c_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { #ifndef __GNUC__ choke me @@ -3838,33 +3754,29 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes -else $as_nop +else ac_compiler_gnu=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_c_compiler_gnu - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi -ac_test_CFLAGS=${CFLAGS+y} +ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -printf %s "checking whether $CC accepts -g... " >&6; } -if test ${ac_cv_prog_cc_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no @@ -3873,60 +3785,57 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else $as_nop +else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -else $as_nop +else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -printf "%s\n" "$ac_cv_prog_cc_g" >&6; } -if test $ac_test_CFLAGS; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then @@ -3941,144 +3850,417 @@ else CFLAGS= fi fi -ac_prog_cc_stdc=no -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 -printf %s "checking for $CC option to enable C11 features... " >&6; } -if test ${ac_cv_prog_cc_c11+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c11=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c11_program -_ACEOF -for ac_arg in '' -std=gnu11 -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c11=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c11" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi - -if test "x$ac_cv_prog_cc_c11" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c11" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 -printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } - CC="$CC $ac_cv_prog_cc_c11" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 - ac_prog_cc_stdc=c11 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 -printf %s "checking for $CC option to enable C99 features... " >&6; } -if test ${ac_cv_prog_cc_c99+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c99=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c99_program -_ACEOF -for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c99=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c99" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi - -if test "x$ac_cv_prog_cc_c99" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c99" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 -printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } - CC="$CC $ac_cv_prog_cc_c99" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 - ac_prog_cc_stdc=c99 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 -printf %s "checking for $CC option to enable C89 features... " >&6; } -if test ${ac_cv_prog_cc_c89+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_c_conftest_c89_program +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi -rm -f core conftest.err conftest.$ac_objext conftest.beam +rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + fi -if test "x$ac_cv_prog_cc_c89" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c89" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } - CC="$CC $ac_cv_prog_cc_c89" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 +$as_echo_n "checking for $CC option to accept ISO C99... " >&6; } +if ${ac_cv_prog_cc_c99+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +#include + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +#define debug(...) fprintf (stderr, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + your preprocessor is broken; +#endif +#if BIG_OK +#else + your preprocessor is broken; +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static void +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str; + int number; + float fnumber; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg (args_copy, const char *); + break; + case 'd': // int + number = va_arg (args_copy, int); + break; + case 'f': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); +} + +int +main () +{ + + // Check bool. + _Bool success = false; + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + test_varargs ("s, d' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' + || dynamic_array[ni.number - 1] != 543); + + ; + return 0; +} +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c99=$ac_arg fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 - ac_prog_cc_stdc=c89 +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c99" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c99" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +$as_echo "$ac_cv_prog_cc_c99" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c99" != xno; then : + +fi + + +if test "$ac_cv_prog_cc_c99" = "no"; then + as_fn_error $? "The C compiler does not support C99" "$LINENO" 5 +fi + +# +# Get the size of a void *, to determine whether this is a 32-bit +# or 64-bit build. +# + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -4088,21 +4270,307 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test "$ac_cv_prog_cc_c99" = "no"; then - as_fn_error $? "The C compiler does not support C99" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 +$as_echo_n "checking size of void *... " >&6; } +if ${ac_cv_sizeof_void_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_void_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (void *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_void_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 +$as_echo "$ac_cv_sizeof_void_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_VOID_P $ac_cv_sizeof_void_p +_ACEOF + + +ac_lbl_c_sizeof_void_p="$ac_cv_sizeof_void_p" + +# +# We only need a C++ compiler for Haiku; all code except for its +# pcap module is in C. +# case "$host_os" in haiku*) - # - # Haiku's platform file is in C++. - # - - - - - - -ac_ext=cpp + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -4112,16 +4580,15 @@ if test -z "$CXX"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else @@ -4129,15 +4596,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4148,11 +4611,11 @@ fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -printf "%s\n" "$CXX" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -4161,16 +4624,15 @@ fi fi if test -z "$CXX"; then ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else @@ -4178,15 +4640,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4197,11 +4655,11 @@ fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -printf "%s\n" "$ac_ct_CXX" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -4213,8 +4671,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $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 CXX=$ac_ct_CXX @@ -4224,7 +4682,7 @@ fi fi fi # Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do @@ -4234,7 +4692,7 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -4244,21 +4702,20 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C++" >&5 -printf %s "checking whether the compiler supports GNU C++... " >&6; } -if test ${ac_cv_cxx_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { #ifndef __GNUC__ choke me @@ -4268,33 +4725,29 @@ main (void) return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes -else $as_nop +else ac_compiler_gnu=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_cxx_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi -ac_test_CXXFLAGS=${CXXFLAGS+y} +ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -printf %s "checking whether $CXX accepts -g... " >&6; } -if test ${ac_cv_prog_cxx_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no @@ -4303,60 +4756,57 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes -else $as_nop +else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : -else $as_nop +else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -printf "%s\n" "$ac_cv_prog_cxx_g" >&6; } -if test $ac_test_CXXFLAGS; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then @@ -4371,106 +4821,80 @@ else CXXFLAGS= fi fi -ac_prog_cxx_stdcxx=no -if test x$ac_prog_cxx_stdcxx = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 -printf %s "checking for $CXX option to enable C++11 features... " >&6; } -if test ${ac_cv_prog_cxx_11+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cxx_11=no -ac_save_CXX=$CXX -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_cxx_conftest_cxx11_program -_ACEOF -for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA -do - CXX="$ac_save_CXX $ac_arg" - if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_cxx11=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cxx_cxx11" != "xno" && break -done -rm -f conftest.$ac_ext -CXX=$ac_save_CXX -fi - -if test "x$ac_cv_prog_cxx_cxx11" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cxx_cxx11" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5 -printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; } - CXX="$CXX $ac_cv_prog_cxx_cxx11" -fi - ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 - ac_prog_cxx_stdcxx=cxx11 -fi -fi -if test x$ac_prog_cxx_stdcxx = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 -printf %s "checking for $CXX option to enable C++98 features... " >&6; } -if test ${ac_cv_prog_cxx_98+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cxx_98=no -ac_save_CXX=$CXX -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_cxx_conftest_cxx98_program -_ACEOF -for ac_arg in '' -std=gnu++98 -std=c++98 -qlanglvl=extended -AA -do - CXX="$ac_save_CXX $ac_arg" - if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_cxx98=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cxx_cxx98" != "xno" && break -done -rm -f conftest.$ac_ext -CXX=$ac_save_CXX -fi - -if test "x$ac_cv_prog_cxx_cxx98" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cxx_cxx98" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5 -printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; } - CXX="$CXX $ac_cv_prog_cxx_cxx98" -fi - ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98 - ac_prog_cxx_stdcxx=cxx98 -fi -fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + + # + # Make sure C and C++ have the same pointer sizes with the flags + # they're given; if they don't, it means that the compilers for the + # languages will, with those flags, not produce code that can be + # linked together. + # + # We have to use different data types, because the results of + # a test are cached, so if we test for the size of a given type + # in C, the subsequent test in C++ will use the cached variable. + # We trick autoconf by testing the size of a "void *" in C and a + # "const void *" in C++. + # + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of const void *" >&5 +$as_echo_n "checking size of const void *... " >&6; } +if ${ac_cv_sizeof_const_void_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (const void *))" "ac_cv_sizeof_const_void_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_const_void_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (const void *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_const_void_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_const_void_p" >&5 +$as_echo "$ac_cv_sizeof_const_void_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CONST_VOID_P $ac_cv_sizeof_const_void_p +_ACEOF + + + ac_lbl_cxx_sizeof_void_p="$ac_cv_sizeof_const_void_p" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$ac_lbl_cxx_sizeof_void_p" -eq 0; then + as_fn_error $? "No C++ compiler was found" "$LINENO" 5 + fi + if test "$ac_lbl_c_sizeof_void_p" -ne "$ac_lbl_cxx_sizeof_void_p"; then + as_fn_error $? "C compiler $CC produces code with $ac_lbl_c_sizeof_void_p-byte pointers +while C++ compiler $CXX produces code with $ac_lbl_cxx_sizeof_void_p-byte pointers. This prevents +code in those languages from being combined." "$LINENO" 5 + fi ;; esac @@ -4478,7 +4902,6 @@ esac - if test "$GCC" = yes ; then # # -Werror forces warnings to be errors. @@ -4491,37 +4914,44 @@ esac # PCAP_API will be visible outside (shared) libraries. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5 -printf %s "checking whether the compiler supports the -fvisibility=hidden option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5 +$as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - else - CFLAGS="$CFLAGS -fvisibility=hidden" - fi + CFLAGS="$CFLAGS -fvisibility=hidden" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -4532,32 +4962,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -fvisibility=hidden " >&5 -printf %s "checking whether -fvisibility=hidden ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -fvisibility=hidden " >&5 +$as_echo_n "checking whether -fvisibility=hidden ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -4565,14 +4994,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -fvisibility=hidden" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" else V_INCLS="$V_INCLS -I/usr/local/include" @@ -4593,37 +5023,44 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # PCAP_API will be visible outside (shared) libraries. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5 -printf %s "checking whether the compiler supports the -fvisibility=hidden option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5 +$as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - else - CFLAGS="$CFLAGS -fvisibility=hidden" - fi + CFLAGS="$CFLAGS -fvisibility=hidden" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -4634,32 +5071,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -fvisibility=hidden " >&5 -printf %s "checking whether -fvisibility=hidden ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -fvisibility=hidden " >&5 +$as_echo_n "checking whether -fvisibility=hidden ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -4667,14 +5103,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -fvisibility=hidden" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" ;; @@ -4757,37 +5194,44 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # PCAP_API will be visible outside (shared) libraries. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -xldscope=hidden option" >&5 -printf %s "checking whether the compiler supports the -xldscope=hidden option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -xldscope=hidden option" >&5 +$as_echo_n "checking whether the compiler supports the -xldscope=hidden option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-xldscope=hidden" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -xldscope=hidden" - elif expr "x-xldscope=hidden" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -xldscope=hidden" - elif expr "x-xldscope=hidden" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -xldscope=hidden" - else - CFLAGS="$CFLAGS -xldscope=hidden" - fi + CFLAGS="$CFLAGS -xldscope=hidden" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -4798,32 +5242,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -xldscope=hidden " >&5 -printf %s "checking whether -xldscope=hidden ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -xldscope=hidden " >&5 +$as_echo_n "checking whether -xldscope=hidden ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -4831,29 +5274,29 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -xldscope=hidden" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" ;; ultrix*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking that Ultrix $CC hacks const in prototypes" >&5 -printf %s "checking that Ultrix $CC hacks const in prototypes... " >&6; } - if test ${ac_cv_lbl_cc_const_proto+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking that Ultrix $CC hacks const in prototypes" >&5 +$as_echo_n "checking that Ultrix $CC hacks const in prototypes... " >&6; } + if ${ac_cv_lbl_cc_const_proto+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { struct a { int b; }; void c(const struct a *) @@ -4861,20 +5304,19 @@ struct a { int b; }; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_cc_const_proto=yes -else $as_nop +else ac_cv_lbl_cc_const_proto=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_const_proto" >&5 -printf "%s\n" "$ac_cv_lbl_cc_const_proto" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_const_proto" >&5 +$as_echo "$ac_cv_lbl_cc_const_proto" >&6; } if test $ac_cv_lbl_cc_const_proto = no ; then -printf "%s\n" "#define const /**/" >>confdefs.h +$as_echo "#define const /**/" >>confdefs.h fi ;; @@ -4905,9 +5347,10 @@ printf "%s\n" "#define const /**/" >>confdefs.h freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*) # - # Platforms where the linker is the GNU linker - # or accepts command-line arguments like - # those the GNU linker accepts. + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. # # Some instruction sets require -fPIC on some # operating systems. Check for them. If you @@ -4928,7 +5371,6 @@ printf "%s\n" "#define const /**/" >>confdefs.h esac V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) @@ -4950,11 +5392,12 @@ printf "%s\n" "#define const /**/" >>confdefs.h solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # - # XXX - this assumes GCC is using the Sun linker, - # rather than the GNU linker. + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. # V_SONAME_OPT="-Wl,-h," - V_RPATH_OPT="-Wl,-R," ;; esac else @@ -4976,7 +5419,7 @@ printf "%s\n" "#define const /**/" >>confdefs.h # "-Wl,-soname,{soname}" option, with the soname part # of the option, while on other platforms the C compiler # driver takes it as a regular option with the soname - # following the option. The same applies to V_RPATH_OPT. + # following the option. # case "$host_os" in @@ -4987,13 +5430,17 @@ printf "%s\n" "#define const /**/" >>confdefs.h freebsd*|netbsd*|openbsd*|dragonfly*|linux*) # - # "cc" is GCC. + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. + # + # XXX - does 64-bit SPARC require -fPIC? # V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) @@ -5016,27 +5463,30 @@ printf "%s\n" "#define const /**/" >>confdefs.h V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-soname " - V_RPATH_OPT="-rpath " ;; solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-G" - V_SONAME_OPT="-h " - V_RPATH_OPT="-R" + # + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. + # + V_SONAME_OPT="-Wl,-h," ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -printf %s "checking for inline... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } save_CFLAGS="$CFLAGS" CFLAGS="$V_CCOPT" - if test ${ac_cv_lbl_inline+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if ${ac_cv_lbl_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_cv_lbl_inline="" ac_lbl_cc_inline=no @@ -5059,18 +5509,17 @@ else $as_nop return &xxx; } int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_lbl_cc_inline=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ac_lbl_cc_inline" = yes ; then break; fi @@ -5082,22 +5531,23 @@ fi CFLAGS="$save_CFLAGS" if test ! -z "$ac_cv_lbl_inline" ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_inline" >&5 -printf "%s\n" "$ac_cv_lbl_inline" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_inline" >&5 +$as_echo "$ac_cv_lbl_inline" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -printf "%s\n" "#define inline $ac_cv_lbl_inline" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define inline $ac_cv_lbl_inline +_ACEOF - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for __atomic_load_n" >&5 -printf %s "checking for __atomic_load_n... " >&6; } - if test ${ac_cv_have___atomic_load_n+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load_n" >&5 +$as_echo_n "checking for __atomic_load_n... " >&6; } + if ${ac_cv_have___atomic_load_n+:} false; then : + $as_echo_n "(cached) " >&6 +else # ac_fn_c_try_link LINENO # ----------------------- @@ -5105,14 +5555,14 @@ else $as_nop ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext + rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -5120,18 +5570,17 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext - } -then : + }; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -5149,7 +5598,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { int i = 17; @@ -5160,35 +5609,33 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_have___atomic_load_n=yes -else $as_nop +else ac_have___atomic_load_n=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_load_n" >&5 -printf "%s\n" "$ac_have___atomic_load_n" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_load_n" >&5 +$as_echo "$ac_have___atomic_load_n" >&6; } if test $ac_have___atomic_load_n = yes ; then -printf "%s\n" "#define HAVE___ATOMIC_LOAD_N 1" >>confdefs.h +$as_echo "#define HAVE___ATOMIC_LOAD_N 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for __atomic_store_n" >&5 -printf %s "checking for __atomic_store_n... " >&6; } - if test ${ac_cv_have___atomic_store_n+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_store_n" >&5 +$as_echo_n "checking for __atomic_store_n... " >&6; } + if ${ac_cv_have___atomic_store_n+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { int i; @@ -5198,21 +5645,20 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_have___atomic_store_n=yes -else $as_nop +else ac_have___atomic_store_n=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_store_n" >&5 -printf "%s\n" "$ac_have___atomic_store_n" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_store_n" >&5 +$as_echo "$ac_have___atomic_store_n" >&6; } if test $ac_have___atomic_store_n = yes ; then -printf "%s\n" "#define HAVE___ATOMIC_STORE_N 1" >>confdefs.h +$as_echo "#define HAVE___ATOMIC_STORE_N 1" >>confdefs.h fi @@ -5220,19 +5666,17 @@ printf "%s\n" "#define HAVE___ATOMIC_STORE_N 1" >>confdefs.h # Try to arrange for large file support. # # Check whether --enable-largefile was given. -if test ${enable_largefile+y} -then : +if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 -printf %s "checking for special C compiler options needed for large files... " >&6; } -if test ${ac_cv_sys_largefile_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if ${ac_cv_sys_largefile_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC @@ -5246,47 +5690,44 @@ else $as_nop We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF - if ac_fn_c_try_compile "$LINENO" -then : + if ac_fn_c_try_compile "$LINENO"; then : break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam +rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" - if ac_fn_c_try_compile "$LINENO" -then : + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam +rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 -printf "%s\n" "$ac_cv_sys_largefile_CC" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -printf %s "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } -if test ${ac_cv_sys_file_offset_bits+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if ${ac_cv_sys_file_offset_bits+:} false; then : + $as_echo_n "(cached) " >&6 +else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5295,23 +5736,22 @@ else $as_nop We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 @@ -5320,43 +5760,43 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 -printf "%s\n" "$ac_cv_sys_file_offset_bits" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) -printf "%s\n" "#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 -printf %s "checking for _LARGE_FILES value needed for large files... " >&6; } -if test ${ac_cv_sys_large_files+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if ${ac_cv_sys_large_files+:} false; then : + $as_echo_n "(cached) " >&6 +else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5365,23 +5805,22 @@ else $as_nop We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 @@ -5390,52 +5829,54 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 -printf "%s\n" "$ac_cv_sys_large_files" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) -printf "%s\n" "#define _LARGE_FILES $ac_cv_sys_large_files" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF ;; esac rm -rf conftest* fi + + fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 -printf %s "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } -if test ${ac_cv_sys_largefile_source+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 +$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } +if ${ac_cv_sys_largefile_source+:} false; then : + $as_echo_n "(cached) " >&6 +else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for off_t */ #include int -main (void) +main () { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); @@ -5443,11 +5884,10 @@ int (*fp) (FILE *, off_t, int) = fseeko; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_sys_largefile_source=no; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5455,7 +5895,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ #include /* for off_t */ #include int -main (void) +main () { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); @@ -5463,22 +5903,23 @@ int (*fp) (FILE *, off_t, int) = fseeko; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_sys_largefile_source=1; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_cv_sys_largefile_source=unknown break done fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 -printf "%s\n" "$ac_cv_sys_largefile_source" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 +$as_echo "$ac_cv_sys_largefile_source" >&6; } case $ac_cv_sys_largefile_source in #( no | unknown) ;; *) -printf "%s\n" "#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF ;; esac rm -rf conftest* @@ -5488,105 +5929,41 @@ rm -rf conftest* # If you want fseeko and ftello with glibc, upgrade to a fixed glibc. if test $ac_cv_sys_largefile_source != unknown; then -printf "%s\n" "#define HAVE_FSEEKO 1" >>confdefs.h +$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h fi -ac_header= ac_cache= -for ac_item in $ac_header_c_list -do - if test $ac_cache; then - ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" - if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then - printf "%s\n" "#define $ac_item 1" >> confdefs.h - fi - ac_header= ac_cache= - elif test $ac_header; then - ac_cache=$ac_item - else - ac_header=$ac_item - fi +for ac_header in sys/ioccom.h sys/sockio.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in netpacket/packet.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "netpacket/packet.h" "ac_cv_header_netpacket_packet_h" "$ac_includes_default" +if test "x$ac_cv_header_netpacket_packet_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_NETPACKET_PACKET_H 1 +_ACEOF + +fi + done - - - - - -if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes -then : - -printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "sys/ioccom.h" "ac_cv_header_sys_ioccom_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_ioccom_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_IOCCOM_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "sys/sockio.h" "ac_cv_header_sys_sockio_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_sockio_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_SOCKIO_H 1" >>confdefs.h - -fi - -ac_fn_c_check_header_compile "$LINENO" "netpacket/packet.h" "ac_cv_header_netpacket_packet_h" "$ac_includes_default" -if test "x$ac_cv_header_netpacket_packet_h" = xyes -then : - printf "%s\n" "#define HAVE_NETPACKET_PACKET_H 1" >>confdefs.h - -fi - -ac_fn_c_check_header_compile "$LINENO" "net/pfvar.h" "ac_cv_header_net_pfvar_h" "#include -#include -#include -" -if test "x$ac_cv_header_net_pfvar_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_PFVAR_H 1" >>confdefs.h - -fi - -if test "$ac_cv_header_net_pfvar_h" = yes; then - # - # Check for various PF actions. - # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether net/pfvar.h defines PF_NAT through PF_NORDR" >&5 -printf %s "checking whether net/pfvar.h defines PF_NAT through PF_NORDR... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - #include - #include -int -main (void) -{ -return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - -printf "%s\n" "#define HAVE_PF_NAT_THROUGH_PF_NORDR 1" >>confdefs.h - - -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" case "$host_os" in haiku*) @@ -5594,16 +5971,63 @@ haiku*) # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them. # CFLAGS="$CFLAGS -D_BSD_SOURCE" + # + # Haiku has getpass in libbsd. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpass in -lbsd" >&5 +$as_echo_n "checking for getpass in -lbsd... " >&6; } +if ${ac_cv_lib_bsd_getpass+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getpass (); +int +main () +{ +return getpass (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_bsd_getpass=yes +else + ac_cv_lib_bsd_getpass=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_getpass" >&5 +$as_echo "$ac_cv_lib_bsd_getpass" >&6; } +if test "x$ac_cv_lib_bsd_getpass" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBBSD 1 +_ACEOF + + LIBS="-lbsd $LIBS" + +fi + ;; esac if test "$GCC" = yes ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ANSI ioctl definitions" >&5 -printf %s "checking for ANSI ioctl definitions... " >&6; } - if test ${ac_cv_lbl_gcc_fixincludes+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI ioctl definitions" >&5 +$as_echo_n "checking for ANSI ioctl definitions... " >&6; } + if ${ac_cv_lbl_gcc_fixincludes+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* @@ -5617,7 +6041,7 @@ else $as_nop # include # endif int -main (void) +main () { switch (0) { case _IO('A', 1):; @@ -5627,17 +6051,16 @@ switch (0) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_gcc_fixincludes=yes -else $as_nop +else ac_cv_lbl_gcc_fixincludes=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_gcc_fixincludes" >&5 -printf "%s\n" "$ac_cv_lbl_gcc_fixincludes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_gcc_fixincludes" >&5 +$as_echo "$ac_cv_lbl_gcc_fixincludes" >&6; } if test $ac_cv_lbl_gcc_fixincludes = no ; then # Don't cache failure unset ac_cv_lbl_gcc_fixincludes @@ -5645,23 +6068,31 @@ printf "%s\n" "$ac_cv_lbl_gcc_fixincludes" >&6; } fi fi -ac_fn_c_check_func "$LINENO" "strerror" "ac_cv_func_strerror" -if test "x$ac_cv_func_strerror" = xyes -then : - printf "%s\n" "#define HAVE_STRERROR 1" >>confdefs.h + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + +for ac_func in strerror +do : + ac_fn_c_check_func "$LINENO" "strerror" "ac_cv_func_strerror" +if test "x$ac_cv_func_strerror" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRERROR 1 +_ACEOF fi +done ac_fn_c_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r" -if test "x$ac_cv_func_strerror_r" = xyes -then : +if test "x$ac_cv_func_strerror_r" = xyes; then : # # We have strerror_r; if we define _GNU_SOURCE, is it a # POSIX-compliant strerror_r() or a GNU strerror_r()? # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether strerror_r is GNU-style" >&5 -printf %s "checking whether strerror_r is GNU-style... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r is GNU-style" >&5 +$as_echo_n "checking whether strerror_r is GNU-style... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5679,38 +6110,41 @@ main(void) _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - # GNU-style - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + # GNU-style + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define HAVE_GNU_STRERROR_R /**/" >>confdefs.h +$as_echo "#define HAVE_GNU_STRERROR_R /**/" >>confdefs.h -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -printf "%s\n" "#define HAVE_POSIX_STRERROR_R /**/" >>confdefs.h +$as_echo "#define HAVE_POSIX_STRERROR_R /**/" >>confdefs.h fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else $as_nop +else # # We don't have strerror_r; do we have _wcserror_s? # - ac_fn_c_check_func "$LINENO" "_wcserror_s" "ac_cv_func__wcserror_s" -if test "x$ac_cv_func__wcserror_s" = xyes -then : - printf "%s\n" "#define HAVE__WCSERROR_S 1" >>confdefs.h + for ac_func in _wcserror_s +do : + ac_fn_c_check_func "$LINENO" "_wcserror_s" "ac_cv_func__wcserror_s" +if test "x$ac_cv_func__wcserror_s" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE__WCSERROR_S 1 +_ACEOF fi +done fi @@ -5719,51 +6153,51 @@ fi # # Thanks, IBM, for not providing vsyslog() in AIX! # -ac_fn_c_check_func "$LINENO" "vsyslog" "ac_cv_func_vsyslog" -if test "x$ac_cv_func_vsyslog" = xyes -then : - printf "%s\n" "#define HAVE_VSYSLOG 1" >>confdefs.h +for ac_func in vsyslog +do : + ac_fn_c_check_func "$LINENO" "vsyslog" "ac_cv_func_vsyslog" +if test "x$ac_cv_func_vsyslog" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VSYSLOG 1 +_ACEOF fi +done # # Make sure we have vsnprintf() and snprintf(); we require them. # ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf" -if test "x$ac_cv_func_vsnprintf" = xyes -then : +if test "x$ac_cv_func_vsnprintf" = xyes; then : -else $as_nop +else as_fn_error $? "vsnprintf() is required but wasn't found" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf" -if test "x$ac_cv_func_snprintf" = xyes -then : +if test "x$ac_cv_func_snprintf" = xyes; then : -else $as_nop +else as_fn_error $? "snprintf() is required but wasn't found" "$LINENO" 5 fi needasprintf=no - - for ac_func in vasprintf asprintf +for ac_func in vasprintf asprintf do : - as_ac_var=`printf "%s\n" "ac_cv_func_$ac_func" | $as_tr_sh` + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes" -then : +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define `printf "%s\n" "HAVE_$ac_func" | $as_tr_cpp` 1 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF -else $as_nop +else needasprintf=yes fi - done + if test $needasprintf = yes; then case " $LIBOBJS " in *" asprintf.$ac_objext "* ) ;; @@ -5774,19 +6208,19 @@ esac fi needstrlcat=no - - for ac_func in strlcat +for ac_func in strlcat do : ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" -if test "x$ac_cv_func_strlcat" = xyes -then : - printf "%s\n" "#define HAVE_STRLCAT 1" >>confdefs.h +if test "x$ac_cv_func_strlcat" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRLCAT 1 +_ACEOF -else $as_nop +else needstrlcat=yes fi - done + if test $needstrlcat = yes; then case " $LIBOBJS " in *" strlcat.$ac_objext "* ) ;; @@ -5797,19 +6231,19 @@ esac fi needstrlcpy=no - - for ac_func in strlcpy +for ac_func in strlcpy do : ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" -if test "x$ac_cv_func_strlcpy" = xyes -then : - printf "%s\n" "#define HAVE_STRLCPY 1" >>confdefs.h +if test "x$ac_cv_func_strlcpy" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRLCPY 1 +_ACEOF -else $as_nop +else needstrlcpy=yes fi - done + if test $needstrlcpy = yes; then case " $LIBOBJS " in *" strlcpy.$ac_objext "* ) ;; @@ -5820,19 +6254,19 @@ esac fi needstrtok_r=no - - for ac_func in strtok_r +for ac_func in strtok_r do : ac_fn_c_check_func "$LINENO" "strtok_r" "ac_cv_func_strtok_r" -if test "x$ac_cv_func_strtok_r" = xyes -then : - printf "%s\n" "#define HAVE_STRTOK_R 1" >>confdefs.h +if test "x$ac_cv_func_strtok_r" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRTOK_R 1 +_ACEOF -else $as_nop +else needstrtok_r=yes fi - done + if test $needstrtok_r = yes; then case " $LIBOBJS " in *" strtok_r.$ac_objext "* ) ;; @@ -5845,12 +6279,16 @@ fi # # Do we have ffs(), and is it declared in ? # -ac_fn_c_check_func "$LINENO" "ffs" "ac_cv_func_ffs" -if test "x$ac_cv_func_ffs" = xyes -then : - printf "%s\n" "#define HAVE_FFS 1" >>confdefs.h +for ac_func in ffs +do : + ac_fn_c_check_func "$LINENO" "ffs" "ac_cv_func_ffs" +if test "x$ac_cv_func_ffs" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_FFS 1 +_ACEOF fi +done if test "$ac_cv_func_ffs" = yes; then # @@ -5859,98 +6297,18 @@ if test "$ac_cv_func_ffs" = yes; then # This test fails if we don't have or if we do # but it doesn't declare ffs(). # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 -printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } -if test ${ac_cv_c_undeclared_builtin_options+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_save_CFLAGS=$CFLAGS - ac_cv_c_undeclared_builtin_options='cannot detect' - for ac_arg in '' -fno-builtin; do - CFLAGS="$ac_save_CFLAGS $ac_arg" - # This test program should *not* compile successfully. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ -(void) strchr; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - -else $as_nop - # This test program should compile successfully. - # No library function is consistently available on - # freestanding implementations, so test against a dummy - # declaration. Include always-available headers on the - # off chance that they somehow elicit warnings. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include -extern void ac_decl (int, char *); - -int -main (void) -{ -(void) ac_decl (0, (char *) 0); - (void) ac_decl; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - if test x"$ac_arg" = x -then : - ac_cv_c_undeclared_builtin_options='none needed' -else $as_nop - ac_cv_c_undeclared_builtin_options=$ac_arg -fi - break -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - done - CFLAGS=$ac_save_CFLAGS - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5 -printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; } - case $ac_cv_c_undeclared_builtin_options in #( - 'cannot detect') : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot make $CC report undeclared builtins -See \`config.log' for more details" "$LINENO" 5; } ;; #( - 'none needed') : - ac_c_undeclared_builtin_options='' ;; #( - *) : - ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;; -esac - -ac_fn_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" " + ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" " #include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ffs" = xyes -then : +" +if test "x$ac_cv_have_decl_ffs" = xyes; then : -printf "%s\n" "#define STRINGS_H_DECLARES_FFS /**/" >>confdefs.h +$as_echo "#define STRINGS_H_DECLARES_FFS /**/" >>confdefs.h fi + fi # @@ -5963,21 +6321,19 @@ fi # libraries (i.e. libc). Check there first. # ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" -if test "x$ac_cv_func_getaddrinfo" = xyes -then : +if test "x$ac_cv_func_getaddrinfo" = xyes; then : -else $as_nop +else # # Not found in the standard system libraries. # Try libsocket, which requires libnsl. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lsocket" >&5 -printf %s "checking for getaddrinfo in -lsocket... " >&6; } -if test ${ac_cv_lib_socket_getaddrinfo+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lsocket" >&5 +$as_echo_n "checking for getaddrinfo in -lsocket... " >&6; } +if ${ac_cv_lib_socket_getaddrinfo+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket -lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5986,43 +6342,47 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char getaddrinfo (); int -main (void) +main () { return getaddrinfo (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_getaddrinfo=yes -else $as_nop +else ac_cv_lib_socket_getaddrinfo=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_getaddrinfo" >&5 -printf "%s\n" "$ac_cv_lib_socket_getaddrinfo" >&6; } -if test "x$ac_cv_lib_socket_getaddrinfo" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_getaddrinfo" >&5 +$as_echo "$ac_cv_lib_socket_getaddrinfo" >&6; } +if test "x$ac_cv_lib_socket_getaddrinfo" = xyes; then : # # OK, we found it in libsocket. # LIBS="-lsocket -lnsl $LIBS" -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lnetwork" >&5 -printf %s "checking for getaddrinfo in -lnetwork... " >&6; } -if test ${ac_cv_lib_network_getaddrinfo+y} -then : - printf %s "(cached) " >&6 -else $as_nop + # + # Not found in libsocket; test for it in libnetwork, which + # is where it is in Haiku. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lnetwork" >&5 +$as_echo_n "checking for getaddrinfo in -lnetwork... " >&6; } +if ${ac_cv_lib_network_getaddrinfo+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lnetwork $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6031,41 +6391,42 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char getaddrinfo (); int -main (void) +main () { return getaddrinfo (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_network_getaddrinfo=yes -else $as_nop +else ac_cv_lib_network_getaddrinfo=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_getaddrinfo" >&5 -printf "%s\n" "$ac_cv_lib_network_getaddrinfo" >&6; } -if test "x$ac_cv_lib_network_getaddrinfo" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_getaddrinfo" >&5 +$as_echo "$ac_cv_lib_network_getaddrinfo" >&6; } +if test "x$ac_cv_lib_network_getaddrinfo" = xyes; then : - # - # OK, we found it in libnetwork on Haiku. - # - LIBS="-lnetwork $LIBS" + # + # OK, we found it in libnetwork. + # + LIBS="-lnetwork $LIBS" -else $as_nop +else - # - # We didn't find it. - # - as_fn_error $? "getaddrinfo is required, but wasn't found" "$LINENO" 5 + # + # We didn't find it. + # + as_fn_error $? "getaddrinfo is required, but wasn't found" "$LINENO" 5 fi @@ -6077,12 +6438,11 @@ fi # OK, do we have recvmsg() in libxnet? # We also link with libsocket and libnsl. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for recvmsg in -lxnet" >&5 -printf %s "checking for recvmsg in -lxnet... " >&6; } -if test ${ac_cv_lib_xnet_recvmsg+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for recvmsg in -lxnet" >&5 +$as_echo_n "checking for recvmsg in -lxnet... " >&6; } +if ${ac_cv_lib_xnet_recvmsg+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lxnet -lsocket -lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6091,29 +6451,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char recvmsg (); int -main (void) +main () { return recvmsg (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_xnet_recvmsg=yes -else $as_nop +else ac_cv_lib_xnet_recvmsg=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xnet_recvmsg" >&5 -printf "%s\n" "$ac_cv_lib_xnet_recvmsg" >&6; } -if test "x$ac_cv_lib_xnet_recvmsg" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xnet_recvmsg" >&5 +$as_echo "$ac_cv_lib_xnet_recvmsg" >&6; } +if test "x$ac_cv_lib_xnet_recvmsg" = xyes; then : # # Yes - link with it as well. @@ -6126,12 +6487,11 @@ fi fi # DLPI needs putmsg under HPUX so test for -lstr while we're at it - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing putmsg" >&5 -printf %s "checking for library containing putmsg... " >&6; } -if test ${ac_cv_search_putmsg+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing putmsg" >&5 +$as_echo_n "checking for library containing putmsg... " >&6; } +if ${ac_cv_search_putmsg+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6139,48 +6499,46 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char putmsg (); int -main (void) +main () { return putmsg (); ; return 0; } _ACEOF -for ac_lib in '' str -do +for ac_lib in '' str; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO" -then : + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_putmsg=$ac_res fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if test ${ac_cv_search_putmsg+y} -then : + if ${ac_cv_search_putmsg+:} false; then : break fi done -if test ${ac_cv_search_putmsg+y} -then : +if ${ac_cv_search_putmsg+:} false; then : -else $as_nop +else ac_cv_search_putmsg=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_putmsg" >&5 -printf "%s\n" "$ac_cv_search_putmsg" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_putmsg" >&5 +$as_echo "$ac_cv_search_putmsg" >&6; } ac_res=$ac_cv_search_putmsg -if test "$ac_res" != no -then : +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi @@ -6200,18 +6558,17 @@ fi # if there's a declaration, it has a prototype, so that the API # can be checked.) # -ac_fn_check_decl "$LINENO" "getnetbyname_r" "ac_cv_have_decl_getnetbyname_r" "#include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_getnetbyname_r" = xyes -then : +ac_fn_c_check_decl "$LINENO" "getnetbyname_r" "ac_cv_have_decl_getnetbyname_r" "#include +" +if test "x$ac_cv_have_decl_getnetbyname_r" = xyes; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the Linux getnetbyname_r()" >&5 -printf %s "checking for the Linux getnetbyname_r()... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the Linux getnetbyname_r()" >&5 +$as_echo_n "checking for the Linux getnetbyname_r()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { struct netent netent_buf; @@ -6225,27 +6582,26 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define HAVE_LINUX_GETNETBYNAME_R 1" >>confdefs.h +$as_echo "#define HAVE_LINUX_GETNETBYNAME_R 1" >>confdefs.h -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Solaris/IRIX getnetbyname_r()" >&5 -printf %s "checking for Solaris/IRIX getnetbyname_r()... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Solaris/IRIX getnetbyname_r()" >&5 +$as_echo_n "checking for Solaris/IRIX getnetbyname_r()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { struct netent netent_buf; @@ -6257,27 +6613,26 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define HAVE_SOLARIS_IRIX_GETNETBYNAME_R 1" >>confdefs.h +$as_echo "#define HAVE_SOLARIS_IRIX_GETNETBYNAME_R 1" >>confdefs.h -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for AIX getnetbyname_r()" >&5 -printf %s "checking for AIX getnetbyname_r()... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AIX getnetbyname_r()" >&5 +$as_echo_n "checking for AIX getnetbyname_r()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { struct netent netent_buf; @@ -6289,34 +6644,34 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define HAVE_AIX_GETNETBYNAME_R 1" >>confdefs.h +$as_echo "#define HAVE_AIX_GETNETBYNAME_R 1" >>confdefs.h -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi + # # Check for reentrant versions of getprotobyname_r(), as provided by # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). @@ -6330,18 +6685,17 @@ fi # if there's a declaration, it has a prototype, so that the API # can be checked.) # -ac_fn_check_decl "$LINENO" "getprotobyname_r" "ac_cv_have_decl_getprotobyname_r" "#include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_getprotobyname_r" = xyes -then : +ac_fn_c_check_decl "$LINENO" "getprotobyname_r" "ac_cv_have_decl_getprotobyname_r" "#include +" +if test "x$ac_cv_have_decl_getprotobyname_r" = xyes; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the Linux getprotobyname_r()" >&5 -printf %s "checking for the Linux getprotobyname_r()... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the Linux getprotobyname_r()" >&5 +$as_echo_n "checking for the Linux getprotobyname_r()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { struct protoent protoent_buf; @@ -6354,27 +6708,26 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define HAVE_LINUX_GETPROTOBYNAME_R 1" >>confdefs.h +$as_echo "#define HAVE_LINUX_GETPROTOBYNAME_R 1" >>confdefs.h -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Solaris/IRIX getprotobyname_r()" >&5 -printf %s "checking for Solaris/IRIX getprotobyname_r()... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Solaris/IRIX getprotobyname_r()" >&5 +$as_echo_n "checking for Solaris/IRIX getprotobyname_r()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { struct protoent protoent_buf; @@ -6386,27 +6739,26 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R 1" >>confdefs.h +$as_echo "#define HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R 1" >>confdefs.h -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for AIX getprotobyname_r()" >&5 -printf %s "checking for AIX getprotobyname_r()... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AIX getprotobyname_r()" >&5 +$as_echo_n "checking for AIX getprotobyname_r()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { struct protoent protoent_buf; @@ -6418,34 +6770,34 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define HAVE_AIX_GETPROTOBYNAME_R 1" >>confdefs.h +$as_echo "#define HAVE_AIX_GETPROTOBYNAME_R 1" >>confdefs.h -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi + # # You are in a twisty little maze of UN*Xes, all different. # Some might not have ether_hostton(). @@ -6458,12 +6810,16 @@ fi # # Before you is a C compiler. # -ac_fn_c_check_func "$LINENO" "ether_hostton" "ac_cv_func_ether_hostton" -if test "x$ac_cv_func_ether_hostton" = xyes -then : - printf "%s\n" "#define HAVE_ETHER_HOSTTON 1" >>confdefs.h +for ac_func in ether_hostton +do : + ac_fn_c_check_func "$LINENO" "ether_hostton" "ac_cv_func_ether_hostton" +if test "x$ac_cv_func_ether_hostton" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ETHER_HOSTTON 1 +_ACEOF fi +done if test "$ac_cv_func_ether_hostton" = yes; then # @@ -6472,18 +6828,18 @@ if test "$ac_cv_func_ether_hostton" = yes; then # This test fails if we don't have or if we do # but it doesn't declare ether_hostton(). # - ac_fn_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ether_hostton" = xyes -then : +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : -printf "%s\n" "#define NET_ETHERNET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h +$as_echo "#define NET_ETHERNET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h fi + # # Did that succeed? # @@ -6499,18 +6855,18 @@ fi # suppress the next test. # unset ac_cv_have_decl_ether_hostton - ac_fn_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ether_hostton" = xyes -then : +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : -printf "%s\n" "#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h +$as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h fi + fi # # Did that succeed? @@ -6528,18 +6884,18 @@ fi # suppress the next test. # unset ac_cv_have_decl_ether_hostton - ac_fn_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ether_hostton" = xyes -then : +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : -printf "%s\n" "#define SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h +$as_echo "#define SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h fi + fi # # Did that succeed? @@ -6551,7 +6907,7 @@ fi # This test fails if we don't have # (if we have ether_hostton(), we should have # networking, and if we have networking, we should - # have ) or if we do but it doesn't + # have ) or if we do but it doesn't # declare ether_hostton(). # # Unset ac_cv_have_decl_ether_hostton so we don't @@ -6559,18 +6915,18 @@ fi # suppress the next test. # unset ac_cv_have_decl_ether_hostton - ac_fn_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ether_hostton" = xyes -then : +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : -printf "%s\n" "#define ARPA_INET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h +$as_echo "#define ARPA_INET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h fi + fi # # Did that succeed? @@ -6591,22 +6947,22 @@ fi # suppress the next test. # unset ac_cv_have_decl_ether_hostton - ac_fn_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include #include #include #include #include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_ether_hostton" = xyes -then : +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : -printf "%s\n" "#define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h +$as_echo "#define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h fi + fi # # After all that, is ether_hostton() declared? @@ -6616,7 +6972,7 @@ fi # Yes. # -printf "%s\n" "#define HAVE_DECL_ETHER_HOSTTON 1" >>confdefs.h +$as_echo "#define HAVE_DECL_ETHER_HOSTTON 1" >>confdefs.h else # @@ -6632,10 +6988,11 @@ printf "%s\n" "#define HAVE_DECL_ETHER_HOSTTON 1" >>confdefs.h #include " -if test "x$ac_cv_type_struct_ether_addr" = xyes -then : +if test "x$ac_cv_type_struct_ether_addr" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_ETHER_ADDR 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_ETHER_ADDR 1 +_ACEOF fi @@ -6646,34 +7003,31 @@ fi # # For various things that might use pthreads. # -ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = xyes -then : +ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" +if test "x$ac_cv_header_pthread_h" = xyes; then : # # OK, we have pthread.h. Do we have pthread_create in the # system libraries? # ac_fn_c_check_func "$LINENO" "pthread_create" "ac_cv_func_pthread_create" -if test "x$ac_cv_func_pthread_create" = xyes -then : +if test "x$ac_cv_func_pthread_create" = xyes; then : # # Yes. # ac_lbl_have_pthreads="found" -else $as_nop +else # # No - do we have it in -lpthreads? # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthreads" >&5 -printf %s "checking for pthread_create in -lpthreads... " >&6; } -if test ${ac_cv_lib_pthreads_pthread_create+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthreads" >&5 +$as_echo_n "checking for pthread_create in -lpthreads... " >&6; } +if ${ac_cv_lib_pthreads_pthread_create+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthreads $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6682,29 +7036,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char pthread_create (); int -main (void) +main () { return pthread_create (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthreads_pthread_create=yes -else $as_nop +else ac_cv_lib_pthreads_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_pthread_create" >&5 -printf "%s\n" "$ac_cv_lib_pthreads_pthread_create" >&6; } -if test "x$ac_cv_lib_pthreads_pthread_create" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_pthread_create" >&5 +$as_echo "$ac_cv_lib_pthreads_pthread_create" >&6; } +if test "x$ac_cv_lib_pthreads_pthread_create" = xyes; then : # # Yes - add -lpthreads. @@ -6712,17 +7067,16 @@ then : ac_lbl_have_pthreads="found" PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads" -else $as_nop +else # # No - do we have it in -lpthread? # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 -printf %s "checking for pthread_create in -lpthread... " >&6; } -if test ${ac_cv_lib_pthread_pthread_create+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 +$as_echo_n "checking for pthread_create in -lpthread... " >&6; } +if ${ac_cv_lib_pthread_pthread_create+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6731,29 +7085,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char pthread_create (); int -main (void) +main () { return pthread_create (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes -else $as_nop +else ac_cv_lib_pthread_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 -printf "%s\n" "$ac_cv_lib_pthread_pthread_create" >&6; } -if test "x$ac_cv_lib_pthread_pthread_create" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } +if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : # # Yes - add -lpthread. @@ -6761,7 +7116,7 @@ then : ac_lbl_have_pthreads="found" PTHREAD_LIBS="$PTHREAD_LIBS -lpthread" -else $as_nop +else # # No. @@ -6777,7 +7132,7 @@ fi fi -else $as_nop +else # # We didn't find pthread.h. @@ -6788,11 +7143,11 @@ else $as_nop fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if --disable-protochain option is specified" >&5 -printf %s "checking if --disable-protochain option is specified... " >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if --disable-protochain option is specified" >&5 +$as_echo_n "checking if --disable-protochain option is specified... " >&6; } # Check whether --enable-protochain was given. -if test ${enable_protochain+y} -then : +if test "${enable_protochain+set}" = set; then : enableval=$enable_protochain; fi @@ -6804,11 +7159,11 @@ esac if test "$enable_protochain" = "disabled"; then -printf "%s\n" "#define NO_PROTOCHAIN 1" >>confdefs.h +$as_echo "#define NO_PROTOCHAIN 1" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_protochain}" >&5 -printf "%s\n" "${enable_protochain}" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_protochain}" >&5 +$as_echo "${enable_protochain}" >&6; } # # valgrindtest directly uses the native capture mechanism, but @@ -6819,8 +7174,7 @@ VALGRINDTEST_SRC= # Check whether --with-pcap was given. -if test ${with_pcap+y} -then : +if test "${with_pcap+set}" = set; then : withval=$with_pcap; fi @@ -6831,13 +7185,18 @@ else # Check for a bunch of headers for various packet # capture mechanisms. # - ac_fn_c_check_header_compile "$LINENO" "net/bpf.h" "ac_cv_header_net_bpf_h" "$ac_includes_default" -if test "x$ac_cv_header_net_bpf_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_BPF_H 1" >>confdefs.h + for ac_header in net/bpf.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "net/bpf.h" "ac_cv_header_net_bpf_h" "$ac_includes_default" +if test "x$ac_cv_header_net_bpf_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_NET_BPF_H 1 +_ACEOF fi +done + if test "$ac_cv_header_net_bpf_h" = yes; then # # Does it define BIOCSETIF? @@ -6871,12 +7230,11 @@ fi # and net/bpf.h doesn't necessarily include all # of those headers itself. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if net/bpf.h defines BIOCSETIF" >&5 -printf %s "checking if net/bpf.h defines BIOCSETIF... " >&6; } - if test ${ac_cv_lbl_bpf_h_defines_biocsetif+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if net/bpf.h defines BIOCSETIF" >&5 +$as_echo_n "checking if net/bpf.h defines BIOCSETIF... " >&6; } + if ${ac_cv_lbl_bpf_h_defines_biocsetif+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6891,77 +7249,75 @@ else $as_nop #include int -main (void) +main () { u_int i = BIOCSETIF; ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_bpf_h_defines_biocsetif=yes -else $as_nop +else ac_cv_lbl_bpf_h_defines_biocsetif=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_bpf_h_defines_biocsetif" >&5 -printf "%s\n" "$ac_cv_lbl_bpf_h_defines_biocsetif" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_bpf_h_defines_biocsetif" >&5 +$as_echo "$ac_cv_lbl_bpf_h_defines_biocsetif" >&6; } fi - ac_fn_c_check_header_compile "$LINENO" "net/pfilt.h" "ac_cv_header_net_pfilt_h" "$ac_includes_default" -if test "x$ac_cv_header_net_pfilt_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_PFILT_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "net/enet.h" "ac_cv_header_net_enet_h" "$ac_includes_default" -if test "x$ac_cv_header_net_enet_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_ENET_H 1" >>confdefs.h + for ac_header in net/pfilt.h net/enet.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi - ac_fn_c_check_header_compile "$LINENO" "net/nit.h" "ac_cv_header_net_nit_h" "$ac_includes_default" -if test "x$ac_cv_header_net_nit_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_NIT_H 1" >>confdefs.h +done -fi -ac_fn_c_check_header_compile "$LINENO" "sys/net/nit.h" "ac_cv_header_sys_net_nit_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_net_nit_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_NET_NIT_H 1" >>confdefs.h + for ac_header in net/nit.h sys/net/nit.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi - ac_fn_c_check_header_compile "$LINENO" "linux/socket.h" "ac_cv_header_linux_socket_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_socket_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_SOCKET_H 1" >>confdefs.h +done -fi -ac_fn_c_check_header_compile "$LINENO" "net/raw.h" "ac_cv_header_net_raw_h" "$ac_includes_default" -if test "x$ac_cv_header_net_raw_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_RAW_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "sys/dlpi.h" "ac_cv_header_sys_dlpi_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_dlpi_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_DLPI_H 1" >>confdefs.h + for ac_header in linux/socket.h net/raw.h sys/dlpi.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi - ac_fn_c_check_header_compile "$LINENO" "config/HaikuConfig.h" "ac_cv_header_config_HaikuConfig_h" "$ac_includes_default" -if test "x$ac_cv_header_config_HaikuConfig_h" = xyes -then : - printf "%s\n" "#define HAVE_CONFIG_HAIKUCONFIG_H 1" >>confdefs.h +done + + for ac_header in config/HaikuConfig.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "config/HaikuConfig.h" "ac_cv_header_config_HaikuConfig_h" "$ac_includes_default" +if test "x$ac_cv_header_config_HaikuConfig_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_CONFIG_HAIKUCONFIG_H 1 +_ACEOF fi +done + if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then # @@ -6989,9 +7345,9 @@ fi V_PCAP=linux VALGRINDTEST_SRC=valgrindtest.c elif test "$ac_cv_header_net_pfilt_h" = yes; then - # - # DEC OSF/1, Digital UNIX, Tru64 UNIX - # + # + # DEC OSF/1, Digital UNIX, Tru64 UNIX + # V_PCAP=pf elif test "$ac_cv_header_net_enet_h" = yes; then # @@ -7028,64 +7384,242 @@ fi # Nothing we support. # V_PCAP=null - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine packet capture interface" >&5 -printf "%s\n" "$as_me: WARNING: cannot determine packet capture interface" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: (see the INSTALL doc for more info)" >&5 -printf "%s\n" "$as_me: WARNING: (see the INSTALL doc for more info)" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine packet capture interface" >&5 +$as_echo "$as_me: WARNING: cannot determine packet capture interface" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: (see the INSTALL.md file for more info)" >&5 +$as_echo "$as_me: WARNING: (see the INSTALL.md file for more info)" >&2;} fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking packet capture type" >&5 -printf %s "checking packet capture type... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $V_PCAP" >&5 -printf "%s\n" "$V_PCAP" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking packet capture type" >&5 +$as_echo_n "checking packet capture type... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $V_PCAP" >&5 +$as_echo "$V_PCAP" >&6; } # # Do we have 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 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_PKGCONFIG+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$PKGCONFIG"; then - ac_cv_prog_PKGCONFIG="$PKGCONFIG" # Let the user override the test. + + + + + + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + 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 -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + 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 - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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_prog_PKGCONFIG="pkg-config" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + 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 - test -z "$ac_cv_prog_PKGCONFIG" && ac_cv_prog_PKGCONFIG="no" + ;; +esac fi -fi -PKGCONFIG=$ac_cv_prog_PKGCONFIG -if test -n "$PKGCONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKGCONFIG" >&5 -printf "%s\n" "$PKGCONFIG" >&6; } +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 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $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 + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.17.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi +fi + +# +# Do we have the brew command from Homebrew? +# +# Extract the first word of "brew", so it can be a program name with args. +set dummy brew; 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_BREW+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $BREW in + [\\/]* | ?:[\\/]*) + ac_cv_path_BREW="$BREW" # 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_BREW="$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 +BREW=$ac_cv_path_BREW +if test -n "$BREW"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BREW" >&5 +$as_echo "$BREW" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +# +# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm +# looking at *you*!), there are separate include files for 32-bit and +# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer +# type on a 64-bit build is like crossing the beams or soething), and +# there are two separate .pc files, so if we're doing a 32-bit build we +# should make sure we look in /usr/lib/pkgconfig for .pc files and if +# we're doing a 64-bit build we should make sure we look in +# /usr/lib/amd64/pkgconfig for .pc files. +# +case "$host_os" in + +solaris*) + if test "$ac_cv_sizeof_void_p" -eq 8; then + # + # 64-bit build. If the path is empty, set it to + # /usr/lib/amd64/pkgconfig; otherwise, if + # /usr/lib/pkgconfig appears in the path, prepend + # /usr/lib/amd64/pkgconfig to it; otherwise, put + # /usr/lib/amd64/pkgconfig at the end. + # + if test -z "$PKG_CONFIG_PATH"; then + # + # Not set, or empty. Set it to + # /usr/lib/amd64/pkgconfig. + # + PKG_CONFIG_PATH=/usr/lib/amd64/pkgconfig + elif test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/pkgconfig"`; then + # + # It contains /usr/lib/pkgconfig. Prepend + # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig. + # + PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/pkgconfig;/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig;"` + else + # + # Not empty, but doesn't contain /usr/lib/pkgconfig. + # Append /usr/lib/amd64/pkgconfig to it. + # + PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/amd64/pkgconfig" + fi + export PKG_CONFIG_PATH + elif test "$ac_cv_sizeof_void_p" -eq 4; then + # + # 32-bit build. If /usr/amd64/lib/pkgconfig appears + # in the path, prepend /usr/lib/pkgconfig to it. + # + if test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/amd64/pkgconfig"`; then + # + # It contains /usr/lib/amd64/pkgconfig. Prepend + # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig. + # + PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/amd64/pkgconfig;/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig;"` + export PKG_CONFIG_PATH + fi + fi +esac # # Handle each capture type. @@ -7095,18 +7629,18 @@ dlpi) # # Checks for some header files. # - ac_fn_c_check_header_compile "$LINENO" "sys/bufmod.h" "ac_cv_header_sys_bufmod_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_bufmod_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_BUFMOD_H 1" >>confdefs.h + for ac_header in sys/bufmod.h sys/dlpi_ext.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi -ac_fn_c_check_header_compile "$LINENO" "sys/dlpi_ext.h" "ac_cv_header_sys_dlpi_ext_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_dlpi_ext_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_DLPI_EXT_H 1" >>confdefs.h -fi +done # @@ -7122,12 +7656,11 @@ fi # save_LDFLAGS="$LDFLAGS" LDFLAGS="$LIBS -L/lib" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5 -printf %s "checking for dlpi_walk in -ldlpi... " >&6; } -if test ${ac_cv_lib_dlpi_dlpi_walk+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5 +$as_echo_n "checking for dlpi_walk in -ldlpi... " >&6; } +if ${ac_cv_lib_dlpi_dlpi_walk+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldlpi $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7136,31 +7669,34 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dlpi_walk (); int -main (void) +main () { return dlpi_walk (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dlpi_dlpi_walk=yes -else $as_nop +else ac_cv_lib_dlpi_dlpi_walk=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dlpi_dlpi_walk" >&5 -printf "%s\n" "$ac_cv_lib_dlpi_dlpi_walk" >&6; } -if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dlpi_dlpi_walk" >&5 +$as_echo "$ac_cv_lib_dlpi_dlpi_walk" >&6; } +if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then : LIBS="-ldlpi $LIBS" + LIBS_STATIC="-ldlpi $LIBS_STATIC" + LIBS_PRIVATE="-ldlpi $LIBS_PRIVATE" V_PCAP=libdlpi # @@ -7169,10 +7705,10 @@ then : # PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c" -printf "%s\n" "#define HAVE_LIBDLPI 1" >>confdefs.h +$as_echo "#define HAVE_LIBDLPI 1" >>confdefs.h -else $as_nop +else V_PCAP=dlpi @@ -7190,12 +7726,11 @@ fi # Checks whether is usable, to catch weird SCO # versions of DLPI. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether is usable" >&5 -printf %s "checking whether is usable... " >&6; } - if test ${ac_cv_sys_dlpi_usable+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is usable" >&5 +$as_echo_n "checking whether is usable... " >&6; } + if ${ac_cv_sys_dlpi_usable+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -7204,24 +7739,23 @@ else $as_nop #include int -main (void) +main () { int i = DL_PROMISC_PHYS; ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_dlpi_usable=yes -else $as_nop +else ac_cv_sys_dlpi_usable=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_dlpi_usable" >&5 -printf "%s\n" "$ac_cv_sys_dlpi_usable" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_dlpi_usable" >&5 +$as_echo "$ac_cv_sys_dlpi_usable" >&6; } if test $ac_cv_sys_dlpi_usable = no ; then as_fn_error $? " is not usable on this system; it probably has a non-standard DLPI" "$LINENO" 5 fi @@ -7237,10 +7771,11 @@ printf "%s\n" "$ac_cv_sys_dlpi_usable" >&6; } #include " -if test "x$ac_cv_type_dl_passive_req_t" = xyes -then : +if test "x$ac_cv_type_dl_passive_req_t" = xyes; then : -printf "%s\n" "#define HAVE_DL_PASSIVE_REQ_T 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_DL_PASSIVE_REQ_T 1 +_ACEOF fi @@ -7251,36 +7786,30 @@ enet) # # Capture module # - PLATFORM_C_SRC="pcap-enet.c" + PLATFORM_C_SRC="pcap-enet.c" ;; haiku) # # Capture module # - PLATFORM_CXX_SRC="pcap-haiku.cpp" + PLATFORM_CXX_SRC="pcap-haiku.cpp" # # Just for the sake of it. # - ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "$ac_includes_default" -if test "x$ac_cv_header_net_if_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_IF_H 1" >>confdefs.h + for ac_header in net/if.h net/if_dl.h net/if_types.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi -ac_fn_c_check_header_compile "$LINENO" "net/if_dl.h" "ac_cv_header_net_if_dl_h" "$ac_includes_default" -if test "x$ac_cv_header_net_if_dl_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_IF_DL_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "net/if_types.h" "ac_cv_header_net_if_types_h" "$ac_includes_default" -if test "x$ac_cv_header_net_if_types_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_IF_TYPES_H 1" >>confdefs.h - -fi +done ;; @@ -7288,23 +7817,28 @@ linux) # # Capture module # - PLATFORM_C_SRC="pcap-linux.c" + PLATFORM_C_SRC="pcap-linux.c" # # Do we have the wireless extensions? # - ac_fn_c_check_header_compile "$LINENO" "linux/wireless.h" "ac_cv_header_linux_wireless_h" " + for ac_header in linux/wireless.h +do : + ac_fn_c_check_header_compile "$LINENO" "linux/wireless.h" "ac_cv_header_linux_wireless_h" " #include #include #include " -if test "x$ac_cv_header_linux_wireless_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_WIRELESS_H 1" >>confdefs.h +if test "x$ac_cv_header_linux_wireless_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_WIRELESS_H 1 +_ACEOF fi +done + # # Do we have libnl? @@ -7317,38 +7851,158 @@ fi # # Check whether --with-libnl was given. -if test ${with_libnl+y} -then : +if test "${with_libnl+set}" = set; then : withval=$with_libnl; with_libnl=$withval -else $as_nop +else with_libnl=if_available fi if test x$with_libnl = xyes ; then - if test "x$PKGCONFIG" != "xno"; then - # - # We have pkg-config; see if we have libnl-genl-3.0 - # as a package. - # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libnl-genl-3.0 with pkg-config" >&5 -printf %s "checking for libnl-genl-3.0 with pkg-config... " >&6; } - if "$PKGCONFIG" libnl-genl-3.0; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5 -printf "%s\n" "found" >&6; } - pkg_config_found_libnl=yes - libnl_genl_cflags=`"$PKGCONFIG" --cflags libnl-genl-3.0` - V_INCLS="$V_INCLS ${libnl_genl_cflags}" - libnl_genl_libs=`"$PKGCONFIG" --libs libnl-genl-3.0` - LIBS="${libnl_genl_libs} $LIBS" + # + # Check for libnl-genl-3.0 with pkg-config. + # -printf "%s\n" "#define HAVE_LIBNL 1" >>confdefs.h - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -printf "%s\n" "not found" >&6; } - fi - fi +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnl-genl-3.0 with pkg-config" >&5 +$as_echo_n "checking for libnl-genl-3.0 with pkg-config... " >&6; } + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + + # + # The package was found, so try to get its C flags and + # libraries. + # + if test -n "$LIBNL_CFLAGS"; then + pkg_cv_LIBNL_CFLAGS="$LIBNL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL_CFLAGS=`$PKG_CONFIG --cflags "libnl-genl-3.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$LIBNL_LIBS"; then + pkg_cv_LIBNL_LIBS="$LIBNL_LIBS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL_LIBS=`$PKG_CONFIG --libs "libnl-genl-3.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$LIBNL_LIBS_STATIC"; then + pkg_cv_LIBNL_LIBS_STATIC="$LIBNL_LIBS_STATIC" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL_LIBS_STATIC=`$PKG_CONFIG --libs --static "libnl-genl-3.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBNL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnl-genl-3.0" 2>&1` + else + LIBNL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnl-genl-3.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libnl-genl-3.0) were not met: + +$LIBNL_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + + +Alternatively, you may set the environment variables LIBNL_CFLAGS +and LIBNL_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5 +$as_echo "not found (pkg-config not found)" >&6; } + else + # + # We found the package. + # + LIBNL_CFLAGS=$pkg_cv_LIBNL_CFLAGS + LIBNL_LIBS=$pkg_cv_LIBNL_LIBS + LIBNL_LIBS_STATIC=$pkg_cv_LIBNL_LIBS_STATIC + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + + pkg_config_found_libnl=yes + V_INCLS="$V_INCLS $LIBNL_CFLAGS" + ADDITIONAL_LIBS="$LIBNL_LIBS $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="$LIBNL_LIBS_STATIC $ADDITIONAL_LIBS_STATIC" + REQUIRES_PRIVATE="libnl-genl-3.0 $REQUIRES_PRIVATE" + +$as_echo "#define HAVE_LIBNL 1" >>confdefs.h + + + fi +else + + # + # The package isn't present. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + +fi + if test x$pkg_config_found_libnl != xyes; then # @@ -7370,12 +8024,11 @@ printf "%s\n" "not found" >&6; } ;; esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl-3" >&5 -printf %s "checking for nl_socket_alloc in -lnl-3... " >&6; } -if test ${ac_cv_lib_nl_3_nl_socket_alloc+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl-3" >&5 +$as_echo_n "checking for nl_socket_alloc in -lnl-3... " >&6; } +if ${ac_cv_lib_nl_3_nl_socket_alloc+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lnl-3 ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7384,40 +8037,43 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char nl_socket_alloc (); int -main (void) +main () { return nl_socket_alloc (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nl_3_nl_socket_alloc=yes -else $as_nop +else ac_cv_lib_nl_3_nl_socket_alloc=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_3_nl_socket_alloc" >&5 -printf "%s\n" "$ac_cv_lib_nl_3_nl_socket_alloc" >&6; } -if test "x$ac_cv_lib_nl_3_nl_socket_alloc" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_3_nl_socket_alloc" >&5 +$as_echo "$ac_cv_lib_nl_3_nl_socket_alloc" >&6; } +if test "x$ac_cv_lib_nl_3_nl_socket_alloc" = xyes; then : # # Yes, we have libnl 3.x. # - LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS" + ADDITIONAL_LIBS="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS_STATIC" + LIBS_PRIVATE="${libnldir} -lnl-genl-3 -lnl-3 $LIBS_PRIVATE" -printf "%s\n" "#define HAVE_LIBNL 1" >>confdefs.h +$as_echo "#define HAVE_LIBNL 1" >>confdefs.h V_INCLS="$V_INCLS ${incdir}" -else $as_nop +else # # No, we don't have libnl at all. @@ -7446,10 +8102,11 @@ fi #include " -if test "x$ac_cv_member_struct_tpacket_auxdata_tp_vlan_tci" = xyes -then : +if test "x$ac_cv_member_struct_tpacket_auxdata_tp_vlan_tci" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI 1 +_ACEOF fi @@ -7460,18 +8117,23 @@ bpf) # # Capture module # - PLATFORM_C_SRC="pcap-bpf.c" + PLATFORM_C_SRC="pcap-bpf.c" # # Check whether we have the *BSD-style ioctls. # - ac_fn_c_check_header_compile "$LINENO" "net/if_media.h" "ac_cv_header_net_if_media_h" "$ac_includes_default" -if test "x$ac_cv_header_net_if_media_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_IF_MEDIA_H 1" >>confdefs.h + for ac_header in net/if_media.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "net/if_media.h" "ac_cv_header_net_if_media_h" "$ac_includes_default" +if test "x$ac_cv_header_net_if_media_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_NET_IF_MEDIA_H 1 +_ACEOF fi +done + # # Check whether we have struct BPF_TIMEVAL. @@ -7485,10 +8147,11 @@ fi #include " -if test "x$ac_cv_type_struct_BPF_TIMEVAL" = xyes -then : +if test "x$ac_cv_type_struct_BPF_TIMEVAL" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_BPF_TIMEVAL 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_BPF_TIMEVAL 1 +_ACEOF fi @@ -7499,21 +8162,21 @@ pf) # # Capture module # - PLATFORM_C_SRC="pcap-pf.c" + PLATFORM_C_SRC="pcap-pf.c" ;; snit) # # Capture module # - PLATFORM_C_SRC="pcap-snit.c" + PLATFORM_C_SRC="pcap-snit.c" ;; snoop) # # Capture module # - PLATFORM_C_SRC="pcap-snoop.c" + PLATFORM_C_SRC="pcap-snoop.c" ;; dag) @@ -7560,7 +8223,7 @@ null) # # Capture module # - PLATFORM_C_SRC="pcap-null.c" + PLATFORM_C_SRC="pcap-null.c" ;; *) @@ -7571,16 +8234,14 @@ esac if test "$V_PCAP" != null then ac_fn_c_check_func "$LINENO" "getifaddrs" "ac_cv_func_getifaddrs" -if test "x$ac_cv_func_getifaddrs" = xyes -then : +if test "x$ac_cv_func_getifaddrs" = xyes; then : # # We have "getifaddrs()"; make sure we have # as well, just in case some platform is really weird. # - ac_fn_c_check_header_compile "$LINENO" "ifaddrs.h" "ac_cv_header_ifaddrs_h" "$ac_includes_default" -if test "x$ac_cv_header_ifaddrs_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "ifaddrs.h" "ac_cv_header_ifaddrs_h" "$ac_includes_default" +if test "x$ac_cv_header_ifaddrs_h" = xyes; then : # # We have the header, so we use "getifaddrs()" to @@ -7588,7 +8249,7 @@ then : # PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c" -else $as_nop +else # # We don't have the header - give up. @@ -7604,7 +8265,8 @@ else $as_nop fi -else $as_nop + +else # # Well, we don't have "getifaddrs()", at least not with the @@ -7623,12 +8285,11 @@ else $as_nop # be built atop SIOCGLIFCONF; using it directly # avoids a not-all-that-useful middleman.) # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have SIOCGLIFCONF" >&5 -printf %s "checking whether we have SIOCGLIFCONF... " >&6; } - if test ${ac_cv_lbl_have_siocglifconf+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have SIOCGLIFCONF" >&5 +$as_echo_n "checking whether we have SIOCGLIFCONF... " >&6; } + if ${ac_cv_lbl_have_siocglifconf+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -7637,24 +8298,23 @@ else $as_nop #include #include int -main (void) +main () { ioctl(0, SIOCGLIFCONF, (char *)0); ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_have_siocglifconf=yes -else $as_nop +else ac_cv_lbl_have_siocglifconf=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_have_siocglifconf" >&5 -printf "%s\n" "$ac_cv_lbl_have_siocglifconf" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_have_siocglifconf" >&5 +$as_echo "$ac_cv_lbl_have_siocglifconf" >&6; } if test $ac_cv_lbl_have_siocglifconf = yes ; then PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c" else @@ -7667,17 +8327,22 @@ fi case "$host_os" in linux*) - ac_fn_c_check_header_compile "$LINENO" "linux/net_tstamp.h" "ac_cv_header_linux_net_tstamp_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_net_tstamp_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_NET_TSTAMP_H 1" >>confdefs.h + for ac_header in linux/net_tstamp.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "linux/net_tstamp.h" "ac_cv_header_linux_net_tstamp_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_net_tstamp_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_NET_TSTAMP_H 1 +_ACEOF fi +done + ;; *) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: no hardware timestamp support implemented for $host_os" >&5 -printf "%s\n" "$as_me: no hardware timestamp support implemented for $host_os" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: no hardware timestamp support implemented for $host_os" >&5 +$as_echo "$as_me: no hardware timestamp support implemented for $host_os" >&6;} ;; esac @@ -7689,20 +8354,20 @@ ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " #include " -if test "x$ac_cv_type_socklen_t" = xyes -then : +if test "x$ac_cv_type_socklen_t" = xyes; then : -printf "%s\n" "#define HAVE_SOCKLEN_T 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_SOCKLEN_T 1 +_ACEOF fi # Check whether --enable-ipv6 was given. -if test ${enable_ipv6+y} -then : +if test "${enable_ipv6+set}" = set; then : enableval=$enable_ipv6; -else $as_nop +else enable_ipv6=yes fi @@ -7712,15 +8377,14 @@ if test "$enable_ipv6" != "no"; then # AC_LBL_LIBRARY_NET. # -printf "%s\n" "#define INET6 1" >>confdefs.h +$as_echo "#define INET6 1" >>confdefs.h fi # Check for Endace DAG card support. # Check whether --with-dag was given. -if test ${with_dag+y} -then : +if test "${with_dag+set}" = set; then : withval=$with_dag; if test "$withval" = no then @@ -7736,7 +8400,7 @@ then : dag_root=$withval fi -else $as_nop +else if test "$V_PCAP" = dag; then # User requested DAG-only libpcap, so we'd better have @@ -7758,8 +8422,7 @@ fi # Check whether --with-dag-includes was given. -if test ${with_dag_includes+y} -then : +if test "${with_dag_includes+set}" = set; then : withval=$with_dag_includes; # User wants DAG support and has specified a header directory, so use the provided value. want_dag=yes @@ -7770,8 +8433,7 @@ fi # Check whether --with-dag-libraries was given. -if test ${with_dag_libraries+y} -then : +if test "${with_dag_libraries+set}" = set; then : withval=$with_dag_libraries; # User wants DAG support and has specified a library directory, so use the provided value. want_dag=yes @@ -7802,15 +8464,29 @@ if test "$want_dag" != no; then fi fi + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + CFLAGS="$CFLAGS -I$dag_include_dir" - ac_fn_c_check_header_compile "$LINENO" "dagapi.h" "ac_cv_header_dagapi_h" "$ac_includes_default" -if test "x$ac_cv_header_dagapi_h" = xyes -then : - printf "%s\n" "#define HAVE_DAGAPI_H 1" >>confdefs.h + for ac_header in dagapi.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "dagapi.h" "ac_cv_header_dagapi_h" "$ac_includes_default" +if test "x$ac_cv_header_dagapi_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DAGAPI_H 1 +_ACEOF fi +done + + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + if test "$ac_cv_header_dagapi_h" = yes; then @@ -7823,14 +8499,17 @@ fi # Check for various DAG API functions. # Don't need to save and restore LIBS to prevent -ldag being # included if there's a found-action (arg 3). - save_LDFLAGS="$LDFLAGS" + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + LDFLAGS="-L$dag_lib_dir" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream in -ldag" >&5 -printf %s "checking for dag_attach_stream in -ldag... " >&6; } -if test ${ac_cv_lib_dag_dag_attach_stream+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream in -ldag" >&5 +$as_echo_n "checking for dag_attach_stream in -ldag... " >&6; } +if ${ac_cv_lib_dag_dag_attach_stream+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldag $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7839,43 +8518,49 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dag_attach_stream (); int -main (void) +main () { return dag_attach_stream (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dag_dag_attach_stream=yes -else $as_nop +else ac_cv_lib_dag_dag_attach_stream=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_attach_stream" >&5 -printf "%s\n" "$ac_cv_lib_dag_dag_attach_stream" >&6; } -if test "x$ac_cv_lib_dag_dag_attach_stream" = xyes -then : - printf "%s\n" "#define HAVE_LIBDAG 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_attach_stream" >&5 +$as_echo "$ac_cv_lib_dag_dag_attach_stream" >&6; } +if test "x$ac_cv_lib_dag_dag_attach_stream" = xyes; then : - LIBS="-ldag $LIBS" + # + # We assume that if we have libdag we have + # libdagconf, as they're installed at the + # same time from the same package. + # + ADDITIONAL_LIBS="-L$dag_lib_dir $ADDITIONAL_LIBS -ldag -ldagconf" + ADDITIONAL_LIBS_STATIC="-L$dag_lib_dir $ADDITIONAL_LIBS_STATIC -ldag -ldagconf" + LIBS_PRIVATE="-L$dag_lib_dir $LIBS_PRIVATE -ldag -ldagconf" -else $as_nop +else as_fn_error $? "DAG library lacks streams support" "$LINENO" 5 fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream64 in -ldag" >&5 -printf %s "checking for dag_attach_stream64 in -ldag... " >&6; } -if test ${ac_cv_lib_dag_dag_attach_stream64+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream64 in -ldag" >&5 +$as_echo_n "checking for dag_attach_stream64 in -ldag... " >&6; } +if ${ac_cv_lib_dag_dag_attach_stream64+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldag $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7884,40 +8569,40 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dag_attach_stream64 (); int -main (void) +main () { return dag_attach_stream64 (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dag_dag_attach_stream64=yes -else $as_nop +else ac_cv_lib_dag_dag_attach_stream64=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_attach_stream64" >&5 -printf "%s\n" "$ac_cv_lib_dag_dag_attach_stream64" >&6; } -if test "x$ac_cv_lib_dag_dag_attach_stream64" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_attach_stream64" >&5 +$as_echo "$ac_cv_lib_dag_dag_attach_stream64" >&6; } +if test "x$ac_cv_lib_dag_dag_attach_stream64" = xyes; then : dag_large_streams="1" -else $as_nop +else dag_large_streams="0" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dag_get_erf_types in -ldag" >&5 -printf %s "checking for dag_get_erf_types in -ldag... " >&6; } -if test ${ac_cv_lib_dag_dag_get_erf_types+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_erf_types in -ldag" >&5 +$as_echo_n "checking for dag_get_erf_types in -ldag... " >&6; } +if ${ac_cv_lib_dag_dag_get_erf_types+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldag $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7926,41 +8611,41 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dag_get_erf_types (); int -main (void) +main () { return dag_get_erf_types (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dag_dag_get_erf_types=yes -else $as_nop +else ac_cv_lib_dag_dag_get_erf_types=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_erf_types" >&5 -printf "%s\n" "$ac_cv_lib_dag_dag_get_erf_types" >&6; } -if test "x$ac_cv_lib_dag_dag_get_erf_types" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_erf_types" >&5 +$as_echo "$ac_cv_lib_dag_dag_get_erf_types" >&6; } +if test "x$ac_cv_lib_dag_dag_get_erf_types" = xyes; then : -printf "%s\n" "#define HAVE_DAG_GET_ERF_TYPES 1" >>confdefs.h +$as_echo "#define HAVE_DAG_GET_ERF_TYPES 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dag_get_stream_erf_types in -ldag" >&5 -printf %s "checking for dag_get_stream_erf_types in -ldag... " >&6; } -if test ${ac_cv_lib_dag_dag_get_stream_erf_types+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_stream_erf_types in -ldag" >&5 +$as_echo_n "checking for dag_get_stream_erf_types in -ldag... " >&6; } +if ${ac_cv_lib_dag_dag_get_stream_erf_types+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldag $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7969,56 +8654,63 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dag_get_stream_erf_types (); int -main (void) +main () { return dag_get_stream_erf_types (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dag_dag_get_stream_erf_types=yes -else $as_nop +else ac_cv_lib_dag_dag_get_stream_erf_types=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_stream_erf_types" >&5 -printf "%s\n" "$ac_cv_lib_dag_dag_get_stream_erf_types" >&6; } -if test "x$ac_cv_lib_dag_dag_get_stream_erf_types" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_stream_erf_types" >&5 +$as_echo "$ac_cv_lib_dag_dag_get_stream_erf_types" >&6; } +if test "x$ac_cv_lib_dag_dag_get_stream_erf_types" = xyes; then : -printf "%s\n" "#define HAVE_DAG_GET_STREAM_ERF_TYPES 1" >>confdefs.h +$as_echo "#define HAVE_DAG_GET_STREAM_ERF_TYPES 1" >>confdefs.h fi - LDFLAGS="$save_LDFLAGS" + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + # # We assume that if we have libdag we have libdagconf, # as they're installed at the same time from the same # package. # - LIBS="$LIBS -ldag -ldagconf" - LDFLAGS="$LDFLAGS -L$dag_lib_dir" - if test "$dag_large_streams" = 1; then -printf "%s\n" "#define HAVE_DAG_LARGE_STREAMS_API 1" >>confdefs.h +$as_echo "#define HAVE_DAG_LARGE_STREAMS_API 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for vdag_set_device_info in -lvdag" >&5 -printf %s "checking for vdag_set_device_info in -lvdag... " >&6; } -if test ${ac_cv_lib_vdag_vdag_set_device_info+y} -then : - printf %s "(cached) " >&6 -else $as_nop + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + LIBS="$LIBS -ldag -ldagconf" + LDFLAGS="$LDFLAGS -L$dag_lib_dir" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vdag_set_device_info in -lvdag" >&5 +$as_echo_n "checking for vdag_set_device_info in -lvdag... " >&6; } +if ${ac_cv_lib_vdag_vdag_set_device_info+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lvdag $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -8027,50 +8719,57 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char vdag_set_device_info (); int -main (void) +main () { return vdag_set_device_info (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_vdag_vdag_set_device_info=yes -else $as_nop +else ac_cv_lib_vdag_vdag_set_device_info=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vdag_vdag_set_device_info" >&5 -printf "%s\n" "$ac_cv_lib_vdag_vdag_set_device_info" >&6; } -if test "x$ac_cv_lib_vdag_vdag_set_device_info" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vdag_vdag_set_device_info" >&5 +$as_echo "$ac_cv_lib_vdag_vdag_set_device_info" >&6; } +if test "x$ac_cv_lib_vdag_vdag_set_device_info" = xyes; then : ac_dag_have_vdag="1" -else $as_nop +else ac_dag_have_vdag="0" fi + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + if test "$ac_dag_have_vdag" = 1; then -printf "%s\n" "#define HAVE_DAG_VDAG 1" >>confdefs.h +$as_echo "#define HAVE_DAG_VDAG 1" >>confdefs.h if test "$ac_lbl_have_pthreads" != "found"; then as_fn_error $? "DAG requires pthreads, but we didn't find them" "$LINENO" 5 fi - LIBS="$LIBS $PTHREAD_LIBS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $PTHREAD_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $PTHREAD_LIBS" + LIBS_PRIVATE="$LIBS_PRIVATE $PTHREAD_LIBS" fi fi -printf "%s\n" "#define HAVE_DAG_API 1" >>confdefs.h +$as_echo "#define HAVE_DAG_API 1" >>confdefs.h else - if test "$V_PCAP" = dag; then # User requested "dag" capture type but we couldn't # find the DAG API support. @@ -8087,8 +8786,7 @@ fi # Check whether --with-septel was given. -if test ${with_septel+y} -then : +if test "${with_septel+set}" = set; then : withval=$with_septel; if test "$withval" = no then @@ -8102,7 +8800,7 @@ then : septel_root=$withval fi -else $as_nop +else if test "$V_PCAP" = septel; then # User requested Septel-only libpcap, so we'd better have @@ -8125,8 +8823,8 @@ fi ac_cv_lbl_septel_api=no if test "$with_septel" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have Septel API headers" >&5 -printf %s "checking whether we have Septel API headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have Septel API headers" >&5 +$as_echo_n "checking whether we have Septel API headers... " >&6; } # If necessary, set default paths for Septel API headers and libraries. if test -z "$septel_root"; then @@ -8141,8 +8839,8 @@ printf %s "checking whether we have Septel API headers... " >&6; } fi if test "$ac_cv_lbl_septel_api" = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes ($septel_include_dir)" >&5 -printf "%s\n" "yes ($septel_include_dir)" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($septel_include_dir)" >&5 +$as_echo "yes ($septel_include_dir)" >&6; } V_INCLS="$V_INCLS -I$septel_include_dir" ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o" @@ -8153,11 +8851,11 @@ printf "%s\n" "yes ($septel_include_dir)" >&6; } fi -printf "%s\n" "#define HAVE_SEPTEL_API 1" >>confdefs.h +$as_echo "#define HAVE_SEPTEL_API 1" >>confdefs.h else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if test "$V_PCAP" = septel; then # User requested "septel" capture type but @@ -8175,8 +8873,7 @@ fi # Check for Myricom SNF support. # Check whether --with-snf was given. -if test ${with_snf+y} -then : +if test "${with_snf+set}" = set; then : withval=$with_snf; if test "$withval" = no then @@ -8192,7 +8889,7 @@ then : snf_root=$withval fi -else $as_nop +else if test "$V_PCAP" = snf; then # User requested Sniffer-only libpcap, so we'd better have @@ -8214,8 +8911,7 @@ fi # Check whether --with-snf-includes was given. -if test ${with_snf_includes+y} -then : +if test "${with_snf_includes+set}" = set; then : withval=$with_snf_includes; # User wants SNF with specific header directory want_snf=yes @@ -8226,8 +8922,7 @@ fi # Check whether --with-snf-libraries was given. -if test ${with_snf_libraries+y} -then : +if test "${with_snf_libraries+set}" = set; then : withval=$with_snf_libraries; # User wants SNF with specific lib directory want_snf=yes @@ -8239,8 +8934,8 @@ fi ac_cv_lbl_snf_api=no if test "$with_snf" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have Myricom Sniffer API" >&5 -printf %s "checking whether we have Myricom Sniffer API... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have Myricom Sniffer API" >&5 +$as_echo_n "checking whether we have Myricom Sniffer API... " >&6; } # If necessary, set default paths for Sniffer headers and libraries. if test -z "$snf_root"; then @@ -8264,14 +8959,17 @@ printf %s "checking whether we have Myricom Sniffer API... " >&6; } if test -f "$snf_include_dir/snf.h"; then # We found a header; make sure we can link with the library - save_LDFLAGS="$LDFLAGS" + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -L$snf_lib_dir" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for snf_init in -lsnf" >&5 -printf %s "checking for snf_init in -lsnf... " >&6; } -if test ${ac_cv_lib_snf_snf_init+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for snf_init in -lsnf" >&5 +$as_echo_n "checking for snf_init in -lsnf... " >&6; } +if ${ac_cv_lib_snf_snf_init+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lsnf $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -8280,56 +8978,62 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char snf_init (); int -main (void) +main () { return snf_init (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_snf_snf_init=yes -else $as_nop +else ac_cv_lib_snf_snf_init=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_snf_snf_init" >&5 -printf "%s\n" "$ac_cv_lib_snf_snf_init" >&6; } -if test "x$ac_cv_lib_snf_snf_init" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_snf_snf_init" >&5 +$as_echo "$ac_cv_lib_snf_snf_init" >&6; } +if test "x$ac_cv_lib_snf_snf_init" = xyes; then : ac_cv_lbl_snf_api="yes" fi - LDFLAGS="$save_LDFLAGS" + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + if test "$ac_cv_lbl_snf_api" = no; then as_fn_error $? "SNF API cannot correctly be linked; check config.log" "$LINENO" 5 fi fi if test "$ac_cv_lbl_snf_api" = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes ($snf_root)" >&5 -printf "%s\n" "yes ($snf_root)" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($snf_root)" >&5 +$as_echo "yes ($snf_root)" >&6; } V_INCLS="$V_INCLS -I$snf_include_dir" - LIBS="$LIBS -lsnf" - LDFLAGS="$LDFLAGS -L$snf_lib_dir" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS -L$snf_lib_dir -lsnf" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC -L$snf_lib_dir -lsnf" + LIBS_PRIVATE="$LIBS_PRIVATE -L$snf_lib_dir -lsnf" if test "$V_PCAP" != snf ; then MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c" fi -printf "%s\n" "#define HAVE_SNF_API 1" >>confdefs.h +$as_echo "#define HAVE_SNF_API 1" >>confdefs.h else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if test "$want_snf" = yes; then # User requested "snf" capture type but @@ -8346,8 +9050,7 @@ fi # Check for Riverbed TurboCap support. # Check whether --with-turbocap was given. -if test ${with_turbocap+y} -then : +if test "${with_turbocap+set}" = set; then : withval=$with_turbocap; if test "$withval" = no then @@ -8363,7 +9066,7 @@ then : turbocap_root=$withval fi -else $as_nop +else if test "xxx_only" = yes; then # User requested something-else-only pcap, so they don't @@ -8382,15 +9085,19 @@ fi ac_cv_lbl_turbocap_api=no if test "$want_turbocap" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether TurboCap is supported" >&5 -printf %s "checking whether TurboCap is supported... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether TurboCap is supported" >&5 +$as_echo_n "checking whether TurboCap is supported... " >&6; } + save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + if test ! -z "$turbocap_root"; then TURBOCAP_CFLAGS="-I$turbocap_root/include" - TURBOCAP_LIBS="-L$turbocap_root/lib" + TURBOCAP_LDFLAGS="-L$turbocap_root/lib" CFLAGS="$CFLAGS $TURBOCAP_CFLAGS" + LDFLAGS="$LDFLAGS $TURBOCAP_LDFLAGS" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -8399,7 +9106,7 @@ printf %s "checking whether TurboCap is supported... " >&6; } #include int -main (void) +main () { TC_INSTANCE a; TC_PORT b; TC_BOARD c; @@ -8410,27 +9117,32 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_turbocap_api=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + if test $ac_cv_lbl_turbocap_api = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c" V_INCLS="$V_INCLS $TURBOCAP_CFLAGS" - LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" + LIBS_PRIVATE="$LIBS_PRIVATE $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" -printf "%s\n" "#define HAVE_TC_API 1" >>confdefs.h +$as_echo "#define HAVE_TC_API 1" >>confdefs.h else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if test "$want_turbocap" = yes; then # User wanted Turbo support but we couldn't find it. @@ -8439,23 +9151,22 @@ printf "%s\n" "no" >&6; } fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable remote packet capture" >&5 -printf %s "checking whether to enable remote packet capture... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable remote packet capture" >&5 +$as_echo_n "checking whether to enable remote packet capture... " >&6; } # Check whether --enable-remote was given. -if test ${enable_remote+y} -then : +if test "${enable_remote+set}" = set; then : enableval=$enable_remote; -else $as_nop +else enableval=no fi case "$enableval" in -yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Remote packet capture may expose libpcap-based applications" >&5 -printf "%s\n" "$as_me: WARNING: Remote packet capture may expose libpcap-based applications" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: to attacks by malicious remote capture servers!" >&5 -printf "%s\n" "$as_me: WARNING: to attacks by malicious remote capture servers!" >&2;} +yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Remote packet capture may expose libpcap-based applications" >&5 +$as_echo "$as_me: WARNING: Remote packet capture may expose libpcap-based applications" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: to attacks by malicious remote capture servers!" >&5 +$as_echo "$as_me: WARNING: to attacks by malicious remote capture servers!" >&2;} # # rpcapd requires pthreads on UN*X. # @@ -8467,20 +9178,18 @@ printf "%s\n" "$as_me: WARNING: to attacks by malicious remote capture servers!" # Do we have it in the system libraries? # ac_fn_c_check_func "$LINENO" "crypt" "ac_cv_func_crypt" -if test "x$ac_cv_func_crypt" = xyes -then : +if test "x$ac_cv_func_crypt" = xyes; then : -else $as_nop +else # # No. Do we have it in -lcrypt? # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5 -printf %s "checking for crypt in -lcrypt... " >&6; } -if test ${ac_cv_lib_crypt_crypt+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5 +$as_echo_n "checking for crypt in -lcrypt... " >&6; } +if ${ac_cv_lib_crypt_crypt+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -8489,36 +9198,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char crypt (); int -main (void) +main () { return crypt (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypt_crypt=yes -else $as_nop +else ac_cv_lib_crypt_crypt=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5 -printf "%s\n" "$ac_cv_lib_crypt_crypt" >&6; } -if test "x$ac_cv_lib_crypt_crypt" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5 +$as_echo "$ac_cv_lib_crypt_crypt" >&6; } +if test "x$ac_cv_lib_crypt_crypt" = xyes; then : # # Yes; add -lcrypt to the libraries for rpcapd. # RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt" -else $as_nop +else as_fn_error $? "rpcapd requires crypt(), but we didn't find it" "$LINENO" 5 @@ -8531,12 +9241,16 @@ fi # # OK, we have crypt(). Do we have getspnam()? # - ac_fn_c_check_func "$LINENO" "getspnam" "ac_cv_func_getspnam" -if test "x$ac_cv_func_getspnam" = xyes -then : - printf "%s\n" "#define HAVE_GETSPNAM 1" >>confdefs.h + for ac_func in getspnam +do : + ac_fn_c_check_func "$LINENO" "getspnam" "ac_cv_func_getspnam" +if test "x$ac_cv_func_getspnam" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GETSPNAM 1 +_ACEOF fi +done # @@ -8547,10 +9261,11 @@ fi #include " -if test "x$ac_cv_member_struct_msghdr_msg_control" = xyes -then : +if test "x$ac_cv_member_struct_msghdr_msg_control" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1 +_ACEOF fi @@ -8560,10 +9275,11 @@ fi #include " -if test "x$ac_cv_member_struct_msghdr_msg_flags" = xyes -then : +if test "x$ac_cv_member_struct_msghdr_msg_flags" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 1 +_ACEOF fi @@ -8573,94 +9289,236 @@ fi # Optionally, we may want to support SSL. # Check for OpenSSL/libressl. # - # First, try looking for it as a regular system library. - # Make sure we can find SSL_library_init() using the - # standard headers, just in case we're running a version - # of macOS that ships with the OpenSSL library but not - # the OpenSSL headers, and have also installed another - # version of OpenSSL with headers. + # First, try looking for it with pkg-config, if we have it. # - save_LIBS="$LIBS" - LIBS="-lssl -lcrypto" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have a system OpenSSL/libressl that we can use" >&5 -printf %s "checking whether we have a system OpenSSL/libressl that we can use... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + # Homebrew's pkg-config does not, by default, look for + # pkg-config files for packages it has installed. + # Furthermore, at least for OpenSSL, they appear to be + # dumped in package-specific directories whose paths are + # not only package-specific but package-version-specific. + # + # So the only way to find openssl is to get the value of + # PKG_CONFIG_PATH from "brew --env openssl" and add that + # to PKG_CONFIG_PATH. (No, we can't just assume it's under + # /usr/local; Homebrew have conveniently chosen to put it + # under /opt/homebrew on ARM.) + # + # That's the nice thing about Homebrew - it makes things easier! + # Thanks! + # + save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" + if test -n "$BREW"; then + openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'` + PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH" + fi -#include -int -main (void) -{ +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl with pkg-config" >&5 +$as_echo_n "checking for openssl with pkg-config... " >&6; } -SSL_library_init(); -return 0; +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : + # + # The package was found, so try to get its C flags and + # libraries. + # + if test -n "$OPENSSL_CFLAGS"; then + pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" + elif test -n "$PKG_CONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - HAVE_OPENSSL=yes - OPENSSL_LIBS="-lssl -lcrypto" - -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$save_LIBS" + else + pkg_failed=untried +fi + if test -n "$OPENSSL_LIBS"; then + pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$OPENSSL_LIBS_STATIC"; then + pkg_cv_OPENSSL_LIBS_STATIC="$OPENSSL_LIBS_STATIC" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_OPENSSL_LIBS_STATIC=`$PKG_CONFIG --libs --static "openssl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl" 2>&1` + else + OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$OPENSSL_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (openssl) were not met: + +$OPENSSL_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + + +Alternatively, you may set the environment variables OPENSSL_CFLAGS +and OPENSSL_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5 +$as_echo "not found (pkg-config not found)" >&6; } + else + # + # We found the package. + # + OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS + OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS + OPENSSL_LIBS_STATIC=$pkg_cv_OPENSSL_LIBS_STATIC + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + + # + # We found OpenSSL/libressl. + # + HAVE_OPENSSL=yes + REQUIRES_PRIVATE="$REQUIRES_PRIVATE openssl" + + fi +else # - # If we didn't find it, check for it with pkg-config. + # The package isn't present. # - if test "x$HAVE_OPENSSL" != "xyes"; then - if test "x$PKGCONFIG" != "xno"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + +fi + + PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH" + + # + # If it wasn't found, and we have Homebrew installed, see + # if it's in Homebrew. + # + if test "x$HAVE_OPENSSL" != "xyes" -a -n "$BREW"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl in Homebrew" >&5 +$as_echo_n "checking for openssl in Homebrew... " >&6; } + # + # The brew man page lies when it speaks of + # $BREW --prefix --installed + # outputting nothing. In Homebrew 3.3.16, + # it produces output regardless of whether + # the formula is installed or not, so we + # send the standard output and error to + # the bit bucket. + # + if $BREW --prefix --installed openssl >/dev/null 2>&1; then # - # We have pkg-config; see if we have OpenSSL/ - # libressl installed as a package. + # Yes. Get the include directory and library + # directory. (No, we can't just assume it's + # under /usr/local; Homebrew have conveniently + # chosen to put it under /opt/homebrew on ARM.) # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenSSL/libressl with pkg-config" >&5 -printf %s "checking for OpenSSL/libressl with pkg-config... " >&6; } - if "$PKGCONFIG" openssl; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5 -printf "%s\n" "found" >&6; } - HAVE_OPENSSL=yes - OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl` - OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl` - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -printf "%s\n" "not found" >&6; } - fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_OPENSSL=yes + openssl_path=`$BREW --prefix openssl` + OPENSSL_CFLAGS="-I$openssl_path/include" + OPENSSL_LIBS="-L$openssl_path/lib -lssl -lcrypto" + OPENSSL_LIBS_STATIC="-L$openssl_path/lib -lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-L$openssl_path/lib -lssl -lcrypto" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi fi # - # If we didn't find it, check for it under /usr/local/opt/openssl; - # that's where Homebrew puts it on macOS. Feel free to add other - # -L directories as necessary; the "system library" check should - # also handle "add-on library under /usr/local", so that shouldn't - # be necessary here. + # If it wasn't found, and /usr/local/include and /usr/local/lib + # exist, check if it's in /usr/local. (We check whether they + # exist because, if they don't exist, the compiler will warn + # about that and then ignore the argument, so they test + # using just the system header files and libraries.) # - if test "x$HAVE_OPENSSL" != "xyes"; then - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS -L/usr/local/opt/openssl/include" - LIBS="$LIBS -L/usr/local/opt/openssl/lib -lssl -lcrypto" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have OpenSSL/libressl in /usr/local/opt that we can use" >&5 -printf %s "checking whether we have OpenSSL/libressl in /usr/local/opt that we can use... " >&6; } + # We include the standard include file to 1) make sure that + # it's installed (if it's just a shared library for the + # benefit of existing programs, that's not useful) and 2) + # because SSL_library_init() is a library routine in some + # versions and a #defined wrapper around OPENSSL_init_ssl() + # in others. + # + if test "x$HAVE_OPENSSL" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS -I/usr/local/include" + LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have OpenSSL/libressl in /usr/local that we can use" >&5 +$as_echo_n "checking whether we have OpenSSL/libressl in /usr/local that we can use... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { SSL_library_init(); @@ -8670,23 +9528,84 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } HAVE_OPENSSL=yes - OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include" - OPENSSL_LIBS="-L/usr/local/opt/openssl/lib -lssl -lcrypto" + OPENSSL_CFLAGS="-I/usr/local/include" + OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto" + OPENSSL_LIBS_STATIC="-L/usr/local/lib -lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-L/usr/local/lib -lssl -lcrypto" -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS="$save_CFLAGS" - LIBS="$save_LIBS" + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + fi + + # + # If it wasn't found, check if it's a system library. + # + # We include the standard include file to 1) make sure that + # it's installed (if it's just a shared library for the + # benefit of existing programs, that's not useful) and 2) + # because SSL_library_init() is a library routine in some + # versions and a #defined wrapper around OPENSSL_init_ssl() + # in others. + # + if test "x$HAVE_OPENSSL" != "xyes"; then + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + LIBS="$LIBS -lssl -lcrypto" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have a system OpenSSL/libressl that we can use" >&5 +$as_echo_n "checking whether we have a system OpenSSL/libressl that we can use... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ + +SSL_library_init(); +return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_OPENSSL=yes + OPENSSL_LIBS="-lssl -lcrypto" + OPENSSL_LIBS_STATIC="-lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-lssl -lcrypto" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + fi # @@ -8694,58 +9613,59 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ # if test "x$HAVE_OPENSSL" = "xyes"; then -printf "%s\n" "#define HAVE_OPENSSL 1" >>confdefs.h +$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h - CFLAGS="$CFLAGS $OPENSSL_CFLAGS" - LIBS="$LIBS $OPENSSL_LIBS" + V_INCLS="$V_INCLS $OPENSSL_CFLAGS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $OPENSSL_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $OPENSSL_LIBS_STATIC" + LIBS_PRIVATE="$LIBS_PRIVATE $OPENSSL_LIBS_PRIVATE" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE $OPENSSL_REQUIRES_PRIVATE" else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: OpenSSL not found" >&5 -printf "%s\n" "$as_me: OpenSSL not found" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: OpenSSL not found" >&5 +$as_echo "$as_me: OpenSSL not found" >&6;} fi -printf "%s\n" "#define ENABLE_REMOTE /**/" >>confdefs.h +$as_echo "#define ENABLE_REMOTE /**/" >>confdefs.h REMOTE_C_SRC="$REMOTE_C_SRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c" BUILD_RPCAPD=build-rpcapd INSTALL_RPCAPD=install-rpcapd ;; -*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } +*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build optimizer debugging code" >&5 -printf %s "checking whether to build optimizer debugging code... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build optimizer debugging code" >&5 +$as_echo_n "checking whether to build optimizer debugging code... " >&6; } # Check whether --enable-optimizer-dbg was given. -if test ${enable_optimizer_dbg+y} -then : +if test "${enable_optimizer_dbg+set}" = set; then : enableval=$enable_optimizer_dbg; fi if test "$enable_optimizer_dbg" = "yes"; then -printf "%s\n" "#define BDEBUG 1" >>confdefs.h +$as_echo "#define BDEBUG 1" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_optimizer_dbg-no}" >&5 -printf "%s\n" "${enable_optimizer_dbg-no}" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_optimizer_dbg-no}" >&5 +$as_echo "${enable_optimizer_dbg-no}" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build parser debugging code" >&5 -printf %s "checking whether to build parser debugging code... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build parser debugging code" >&5 +$as_echo_n "checking whether to build parser debugging code... " >&6; } # Check whether --enable-yydebug was given. -if test ${enable_yydebug+y} -then : +if test "${enable_yydebug+set}" = set; then : enableval=$enable_yydebug; fi if test "$enable_yydebug" = "yes"; then -printf "%s\n" "#define YYDEBUG 1" >>confdefs.h +$as_echo "#define YYDEBUG 1" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${enable_yydebug-no}" >&5 -printf "%s\n" "${enable_yydebug-no}" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_yydebug-no}" >&5 +$as_echo "${enable_yydebug-no}" >&6; } # # Do various checks for various OSes and versions of those OSes. @@ -8764,7 +9684,7 @@ case "$host_os" in aix*) -printf "%s\n" "#define _SUN 1" >>confdefs.h +$as_echo "#define _SUN 1" >>confdefs.h # @@ -8788,11 +9708,11 @@ printf "%s\n" "#define _SUN 1" >>confdefs.h # STREAMS routines. # pseexe="/lib/pse.exp" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $pseexe" >&5 -printf %s "checking for $pseexe... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $pseexe" >&5 +$as_echo_n "checking for $pseexe... " >&6; } if test -f $pseexe ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } LIBS="-I:$pseexe" fi ;; @@ -8811,8 +9731,7 @@ darwin*) DYEXT="dylib" V_CCOPT="$V_CCOPT -fno-common" # Check whether --enable-universal was given. -if test ${enable_universal+y} -then : +if test "${enable_universal+set}" = set; then : enableval=$enable_universal; fi @@ -8845,7 +9764,7 @@ fi V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64" ;; - darwin8.[456]|darwin.[456].*) + darwin8.[456]|darwin8.[456].*) # # Tiger, subsequent to Intel support but prior # to x86-64 support. Build libraries and @@ -8910,43 +9829,42 @@ fi V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386" ;; - darwin*) + darwin1[1-8]*) # - # Post-Snow Leopard. Build libraries for x86-64 - # and 32-bit x86, with x86-64 first, and build - # executables only for x86-64. (That's what - # Apple does.) This requires no special flags - # for programs. - # XXX - update if and when Apple drops support - # for 32-bit x86 code and if and when Apple adds - # ARM-based Macs. (You're on your own for iOS - # etc.) + # Post-Snow Leopard, pre-Catalina. Build + # libraries for x86-64 and 32-bit x86, with + # x86-64 first, and build executables only for + # x86-64. (That's what Apple does.) This + # requires no special flags for programs. # - # XXX - check whether we *can* build for - # i386 and, if not, suggest that the user - # install the /usr/include headers if they - # want to build fat. + # We check whether we *can* build for i386 and, + # if not, suggest that the user install the + # /usr/include headers if they want to build + # fat. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether building for 32-bit x86 is supported" >&5 -printf %s "checking whether building for 32-bit x86 is supported... " >&6; } - save_CFLAGS="$CFLAGS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether building for 32-bit x86 is supported" >&5 +$as_echo_n "checking whether building for 32-bit x86 is supported... " >&6; } + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + CFLAGS="$CFLAGS -arch i386" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { return 0; ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } V_LIB_CCOPT_FAT="-arch x86_64" V_LIB_LDFLAGS_FAT="-arch x86_64" @@ -8962,10 +9880,10 @@ printf "%s\n" "yes" >&6; } V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } V_LIB_CCOPT_FAT="-arch x86_64" V_LIB_LDFLAGS_FAT="-arch x86_64" case "$host_os" in @@ -8976,8 +9894,8 @@ printf "%s\n" "no" >&6; } # /usr/include headers to get # 32-bit x86 builds to work. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package" >&5 -printf "%s\n" "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package" >&5 +$as_echo "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package" >&2;} ;; *) @@ -8986,15 +9904,103 @@ printf "%s\n" "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try ins # tools should be sufficient to # enable 32-bit x86 builds. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools" >&5 -printf "%s\n" "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools" >&5 +$as_echo "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools" >&2;} ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS="$save_CFLAGS" + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + ;; + + darwin19*) + # + # Catalina. Build libraries and executables + # only for x86-64. (That's what Apple does; + # 32-bit x86 binaries are not supported on + # Catalina.) + # + V_LIB_CCOPT_FAT="-arch x86_64" + V_LIB_LDFLAGS_FAT="-arch x86_64" + V_PROG_CCOPT_FAT="-arch x86_64" + V_PROG_LDFLAGS_FAT="-arch x86_64" + ;; + + darwin*) + # + # Post-Catalina. Build libraries and + # executables for x86-64 and ARM64. + # (That's what Apple does, except they + # build for arm64e, which may include + # some of the pointer-checking extensions.) + # + # If we're building with libssl, make sure + # we can build fat with it (i.e., that it + # was built fat); if we can't, don't set + # the target architectures, and just + # build for the host we're on. + # + # Otherwise, just add both of them. + # + if test "$HAVE_OPENSSL" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether building fat with libssl is supported" >&5 +$as_echo_n "checking whether building fat with libssl is supported... " >&6; } + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS -arch x86_64 -arch arm64" + LDFLAGS="$LDFLAGS $OPENSSL_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + SSL_library_init(); + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64" + V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64" + V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64" + V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + else + V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64" + V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64" + V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64" + V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64" + fi ;; esac fi @@ -9002,7 +10008,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ hpux9*) -printf "%s\n" "#define HAVE_HPUX9 1" >>confdefs.h +$as_echo "#define HAVE_HPUX9 1" >>confdefs.h # @@ -9035,7 +10041,7 @@ hpux10.1*) hpux*) -printf "%s\n" "#define HAVE_HPUX10_20_OR_LATER 1" >>confdefs.h +$as_echo "#define HAVE_HPUX10_20_OR_LATER 1" >>confdefs.h if test "`uname -m`" = "ia64"; then DYEXT="so" @@ -9068,21 +10074,13 @@ irix*) linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*) DYEXT="so" - - # - # Compiler assumed to be GCC; run-time linker may require a -R - # flag. - # - if test "$libdir" != "/usr/lib"; then - V_RFLAGS=-Wl,-R$libdir - fi ;; osf*) DYEXT="so" # - # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX. + # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX. # Use Tru64 UNIX conventions for man pages; they're the same as # the System V conventions except that they use section 8 for # administrative commands and daemons. @@ -9093,44 +10091,42 @@ osf*) ;; sinix*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if SINIX compiler defines sinix" >&5 -printf %s "checking if SINIX compiler defines sinix... " >&6; } - if test ${ac_cv_cc_sinix_defined+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if SINIX compiler defines sinix" >&5 +$as_echo_n "checking if SINIX compiler defines sinix... " >&6; } + if ${ac_cv_cc_sinix_defined+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { int i = sinix; ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_cc_sinix_defined=yes -else $as_nop +else ac_cv_cc_sinix_defined=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cc_sinix_defined" >&5 -printf "%s\n" "$ac_cv_cc_sinix_defined" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cc_sinix_defined" >&5 +$as_echo "$ac_cv_cc_sinix_defined" >&6; } if test $ac_cv_cc_sinix_defined = no ; then -printf "%s\n" "#define sinix 1" >>confdefs.h +$as_echo "#define sinix 1" >>confdefs.h fi ;; solaris*) -printf "%s\n" "#define HAVE_SOLARIS 1" >>confdefs.h +$as_echo "#define HAVE_SOLARIS 1" >>confdefs.h DYEXT="so" @@ -9162,9 +10158,17 @@ printf "%s\n" "#define HAVE_SOLARIS 1" >>confdefs.h ;; esac + + + + + + + + + # Check whether --enable-shared was given. -if test ${enable_shared+y} -then : +if test "${enable_shared+set}" = set; then : enableval=$enable_shared; fi @@ -9173,12 +10177,11 @@ test "x$enable_shared" != "xyes" && DYEXT="none" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_RANLIB+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else @@ -9186,15 +10189,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -9205,11 +10204,11 @@ fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -printf "%s\n" "$RANLIB" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -9218,12 +10217,11 @@ if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_RANLIB+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else @@ -9231,15 +10229,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -9250,11 +10244,11 @@ fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -printf "%s\n" "$ac_ct_RANLIB" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then @@ -9262,8 +10256,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $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 RANLIB=$ac_ct_RANLIB @@ -9275,12 +10269,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_AR+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else @@ -9288,15 +10281,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="${ac_tool_prefix}ar" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -9307,11 +10296,11 @@ fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -printf "%s\n" "$AR" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -9320,12 +10309,11 @@ if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_AR+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else @@ -9333,15 +10321,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + 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 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="ar" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -9352,11 +10336,11 @@ fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -printf "%s\n" "$ac_ct_AR" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_AR" = x; then @@ -9364,8 +10348,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $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 AR=$ac_ct_AR @@ -9375,15 +10359,15 @@ else fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -printf %s "checking whether ln -s works... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -printf "%s\n" "no, using $LN_S" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } fi @@ -9398,74 +10382,44 @@ rm -f os-proto.h # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5 -printf %s "checking whether the compiler fails when given an unknown warning option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5 +$as_echo_n "checking whether the compiler supports the -W option... " >&6; } save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy" + CFLAGS="$CFLAGS -W" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - # - # We're assuming this is clang, where - # -Werror=unknown-warning-option is the appropriate - # option to force the compiler to fail. - # - ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option" - -else $as_nop - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS="$save_CFLAGS" - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5 -printf %s "checking whether the compiler supports the -W option... " >&6; } - save_CFLAGS="$CFLAGS" - if expr "x-W" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W" - elif expr "x-W" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -W" - elif expr "x-W" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -W" - else - CFLAGS="$CFLAGS -W" - fi - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -9476,32 +10430,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -W " >&5 -printf %s "checking whether -W ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -W " >&5 +$as_echo_n "checking whether -W ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -9509,47 +10462,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -W" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5 -printf %s "checking whether the compiler supports the -Wall option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5 +$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wall" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall" - elif expr "x-Wall" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wall" - elif expr "x-Wall" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wall" - else - CFLAGS="$CFLAGS -Wall" - fi + CFLAGS="$CFLAGS -Wall" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -9560,32 +10521,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wall " >&5 -printf %s "checking whether -Wall ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wall " >&5 +$as_echo_n "checking whether -Wall ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -9593,47 +10553,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wall" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcomma option" >&5 -printf %s "checking whether the compiler supports the -Wcomma option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcomma option" >&5 +$as_echo_n "checking whether the compiler supports the -Wcomma option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wcomma" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wcomma" - elif expr "x-Wcomma" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wcomma" - elif expr "x-Wcomma" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wcomma" - else - CFLAGS="$CFLAGS -Wcomma" - fi + CFLAGS="$CFLAGS -Wcomma" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -9644,32 +10612,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wcomma " >&5 -printf %s "checking whether -Wcomma ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wcomma " >&5 +$as_echo_n "checking whether -Wcomma ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -9677,47 +10644,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wcomma" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdocumentation option" >&5 -printf %s "checking whether the compiler supports the -Wdocumentation option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdocumentation option" >&5 +$as_echo_n "checking whether the compiler supports the -Wdocumentation option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wdocumentation" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdocumentation" - elif expr "x-Wdocumentation" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wdocumentation" - elif expr "x-Wdocumentation" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wdocumentation" - else - CFLAGS="$CFLAGS -Wdocumentation" - fi + CFLAGS="$CFLAGS -Wdocumentation" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -9728,32 +10703,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wdocumentation " >&5 -printf %s "checking whether -Wdocumentation ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wdocumentation " >&5 +$as_echo_n "checking whether -Wdocumentation ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -9761,47 +10735,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wdocumentation" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wformat-nonliteral option" >&5 -printf %s "checking whether the compiler supports the -Wformat-nonliteral option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wformat-nonliteral option" >&5 +$as_echo_n "checking whether the compiler supports the -Wformat-nonliteral option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wformat-nonliteral" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wformat-nonliteral" - elif expr "x-Wformat-nonliteral" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wformat-nonliteral" - elif expr "x-Wformat-nonliteral" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wformat-nonliteral" - else - CFLAGS="$CFLAGS -Wformat-nonliteral" - fi + CFLAGS="$CFLAGS -Wformat-nonliteral" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -9812,32 +10794,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wformat-nonliteral " >&5 -printf %s "checking whether -Wformat-nonliteral ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wformat-nonliteral " >&5 +$as_echo_n "checking whether -Wformat-nonliteral ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -9845,47 +10826,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wformat-nonliteral" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-noreturn option" >&5 -printf %s "checking whether the compiler supports the -Wmissing-noreturn option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-noreturn option" >&5 +$as_echo_n "checking whether the compiler supports the -Wmissing-noreturn option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wmissing-noreturn" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-noreturn" - elif expr "x-Wmissing-noreturn" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-noreturn" - elif expr "x-Wmissing-noreturn" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-noreturn" - else - CFLAGS="$CFLAGS -Wmissing-noreturn" - fi + CFLAGS="$CFLAGS -Wmissing-noreturn" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -9896,32 +10885,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-noreturn " >&5 -printf %s "checking whether -Wmissing-noreturn ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-noreturn " >&5 +$as_echo_n "checking whether -Wmissing-noreturn ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -9929,47 +10917,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wmissing-noreturn" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5 -printf %s "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5 +$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes" - elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-prototypes" - elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-prototypes" - else - CFLAGS="$CFLAGS -Wmissing-prototypes" - fi + CFLAGS="$CFLAGS -Wmissing-prototypes" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -9980,32 +10976,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-prototypes " >&5 -printf %s "checking whether -Wmissing-prototypes ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-prototypes " >&5 +$as_echo_n "checking whether -Wmissing-prototypes ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10013,47 +11008,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wmissing-prototypes" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-variable-declarations option" >&5 -printf %s "checking whether the compiler supports the -Wmissing-variable-declarations option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-variable-declarations option" >&5 +$as_echo_n "checking whether the compiler supports the -Wmissing-variable-declarations option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wmissing-variable-declarations" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-variable-declarations" - elif expr "x-Wmissing-variable-declarations" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-variable-declarations" - elif expr "x-Wmissing-variable-declarations" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-variable-declarations" - else - CFLAGS="$CFLAGS -Wmissing-variable-declarations" - fi + CFLAGS="$CFLAGS -Wmissing-variable-declarations" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10064,32 +11067,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-variable-declarations " >&5 -printf %s "checking whether -Wmissing-variable-declarations ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-variable-declarations " >&5 +$as_echo_n "checking whether -Wmissing-variable-declarations ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10097,47 +11099,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wmissing-variable-declarations" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-arith option" >&5 -printf %s "checking whether the compiler supports the -Wpointer-arith option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-arith option" >&5 +$as_echo_n "checking whether the compiler supports the -Wpointer-arith option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wpointer-arith" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-arith" - elif expr "x-Wpointer-arith" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-arith" - elif expr "x-Wpointer-arith" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-arith" - else - CFLAGS="$CFLAGS -Wpointer-arith" - fi + CFLAGS="$CFLAGS -Wpointer-arith" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10148,32 +11158,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wpointer-arith " >&5 -printf %s "checking whether -Wpointer-arith ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wpointer-arith " >&5 +$as_echo_n "checking whether -Wpointer-arith ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10181,47 +11190,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wpointer-arith" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-sign option" >&5 -printf %s "checking whether the compiler supports the -Wpointer-sign option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-sign option" >&5 +$as_echo_n "checking whether the compiler supports the -Wpointer-sign option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wpointer-sign" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-sign" - elif expr "x-Wpointer-sign" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-sign" - elif expr "x-Wpointer-sign" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-sign" - else - CFLAGS="$CFLAGS -Wpointer-sign" - fi + CFLAGS="$CFLAGS -Wpointer-sign" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10232,32 +11249,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wpointer-sign " >&5 -printf %s "checking whether -Wpointer-sign ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wpointer-sign " >&5 +$as_echo_n "checking whether -Wpointer-sign ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10265,47 +11281,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wpointer-sign" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5 -printf %s "checking whether the compiler supports the -Wshadow option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5 +$as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wshadow" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow" - elif expr "x-Wshadow" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wshadow" - elif expr "x-Wshadow" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wshadow" - else - CFLAGS="$CFLAGS -Wshadow" - fi + CFLAGS="$CFLAGS -Wshadow" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10316,32 +11340,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wshadow " >&5 -printf %s "checking whether -Wshadow ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wshadow " >&5 +$as_echo_n "checking whether -Wshadow ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10349,47 +11372,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wshadow" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wsign-compare option" >&5 -printf %s "checking whether the compiler supports the -Wsign-compare option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wsign-compare option" >&5 +$as_echo_n "checking whether the compiler supports the -Wsign-compare option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wsign-compare" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wsign-compare" - elif expr "x-Wsign-compare" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wsign-compare" - elif expr "x-Wsign-compare" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wsign-compare" - else - CFLAGS="$CFLAGS -Wsign-compare" - fi + CFLAGS="$CFLAGS -Wsign-compare" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10400,32 +11431,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wsign-compare " >&5 -printf %s "checking whether -Wsign-compare ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wsign-compare " >&5 +$as_echo_n "checking whether -Wsign-compare ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10433,47 +11463,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wsign-compare" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5 -printf %s "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5 +$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes" - elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wstrict-prototypes" - elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wstrict-prototypes" - else - CFLAGS="$CFLAGS -Wstrict-prototypes" - fi + CFLAGS="$CFLAGS -Wstrict-prototypes" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10484,32 +11522,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wstrict-prototypes " >&5 -printf %s "checking whether -Wstrict-prototypes ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wstrict-prototypes " >&5 +$as_echo_n "checking whether -Wstrict-prototypes ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10517,47 +11554,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wstrict-prototypes" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunused-parameter option" >&5 -printf %s "checking whether the compiler supports the -Wunused-parameter option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunused-parameter option" >&5 +$as_echo_n "checking whether the compiler supports the -Wunused-parameter option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wunused-parameter" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wunused-parameter" - elif expr "x-Wunused-parameter" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wunused-parameter" - elif expr "x-Wunused-parameter" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wunused-parameter" - else - CFLAGS="$CFLAGS -Wunused-parameter" - fi + CFLAGS="$CFLAGS -Wunused-parameter" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10568,32 +11613,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wunused-parameter " >&5 -printf %s "checking whether -Wunused-parameter ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wunused-parameter " >&5 +$as_echo_n "checking whether -Wunused-parameter ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10601,47 +11645,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wunused-parameter" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5 -printf %s "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5 +$as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused" - elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused" - elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused" - else - CFLAGS="$CFLAGS -Wused-but-marked-unused" - fi + CFLAGS="$CFLAGS -Wused-but-marked-unused" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10652,32 +11704,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wused-but-marked-unused " >&5 -printf %s "checking whether -Wused-but-marked-unused ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wused-but-marked-unused " >&5 +$as_echo_n "checking whether -Wused-but-marked-unused ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10685,14 +11736,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wused-but-marked-unused" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" # Warns about safeguards added in case the enums are # extended @@ -10722,37 +11774,44 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # branch will never be reached.) # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunreachable-code option" >&5 -printf %s "checking whether the compiler supports the -Wunreachable-code option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunreachable-code option" >&5 +$as_echo_n "checking whether the compiler supports the -Wunreachable-code option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wunreachable-code" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wunreachable-code" - elif expr "x-Wunreachable-code" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wunreachable-code" - elif expr "x-Wunreachable-code" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wunreachable-code" - else - CFLAGS="$CFLAGS -Wunreachable-code" - fi + CFLAGS="$CFLAGS -Wunreachable-code" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10763,8 +11822,8 @@ printf "%s\n" "yes" >&6; } if test "xgenerates warnings from ntohs()" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wunreachable-code generates warnings from ntohs()" >&5 -printf %s "checking whether -Wunreachable-code generates warnings from ntohs()... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wunreachable-code generates warnings from ntohs()" >&5 +$as_echo_n "checking whether -Wunreachable-code generates warnings from ntohs()... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -10776,26 +11835,25 @@ testme(unsigned short a) } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10803,47 +11861,55 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wunreachable-code" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshorten-64-to-32 option" >&5 -printf %s "checking whether the compiler supports the -Wshorten-64-to-32 option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshorten-64-to-32 option" >&5 +$as_echo_n "checking whether the compiler supports the -Wshorten-64-to-32 option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wshorten-64-to-32" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshorten-64-to-32" - elif expr "x-Wshorten-64-to-32" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wshorten-64-to-32" - elif expr "x-Wshorten-64-to-32" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wshorten-64-to-32" - else - CFLAGS="$CFLAGS -Wshorten-64-to-32" - fi + CFLAGS="$CFLAGS -Wshorten-64-to-32" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main (void) -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=yes # # The compile supports this; do we have some C code for @@ -10854,32 +11920,31 @@ printf "%s\n" "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -Wshorten-64-to-32 " >&5 -printf %s "checking whether -Wshorten-64-to-32 ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wshorten-64-to-32 " >&5 +$as_echo_n "checking whether -Wshorten-64-to-32 ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : # # Not a problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } -else $as_nop +else # # A problem. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } can_add_to_cflags=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" @@ -10887,19 +11952,20 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext V_CCOPT="$V_CCOPT -Wshorten-64-to-32" fi -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports generating dependencies" >&5 -printf %s "checking whether the compiler supports generating dependencies... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports generating dependencies" >&5 +$as_echo_n "checking whether the compiler supports generating dependencies... " >&6; } if test "$GCC" = yes ; then # # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even @@ -10968,18 +12034,18 @@ printf %s "checking whether the compiler supports generating dependencies... " > /* end confdefs.h. */ int main(void) { return 0; } _ACEOF - if { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: eval \"\$CC \$ac_lbl_dependency_flag conftest.c >/dev/null 2>&1\""; } >&5 + if { { $as_echo "$as_me:${as_lineno-$LINENO}: eval \"\$CC \$ac_lbl_dependency_flag conftest.c >/dev/null 2>&1\""; } >&5 (eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, with $ac_lbl_dependency_flag" >&5 -printf "%s\n" "yes, with $ac_lbl_dependency_flag" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, with $ac_lbl_dependency_flag" >&5 +$as_echo "yes, with $ac_lbl_dependency_flag" >&6; } DEPENDENCY_CFLAG="$ac_lbl_dependency_flag" MKDEP='${top_srcdir}/mkdep' else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } # # We can't run mkdep, so have "make depend" do # nothing. @@ -10988,8 +12054,8 @@ printf "%s\n" "no" >&6; } fi rm -rf conftest* else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } # # We can't run mkdep, so have "make depend" do # nothing. @@ -11012,11 +12078,11 @@ printf "%s\n" "no" >&6; } if test -f $name ; then ln -s $name os-proto.h -printf "%s\n" "#define HAVE_OS_PROTO_H 1" >>confdefs.h +$as_echo "#define HAVE_OS_PROTO_H 1" >>confdefs.h else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: can't find $name" >&5 -printf "%s\n" "$as_me: WARNING: can't find $name" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find $name" >&5 +$as_echo "$as_me: WARNING: can't find $name" >&2;} fi fi @@ -11028,10 +12094,11 @@ ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_s #include " -if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes -then : +if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_SA_LEN 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_SA_LEN 1 +_ACEOF fi @@ -11045,10 +12112,11 @@ ac_fn_c_check_type "$LINENO" "struct sockaddr_storage" "ac_cv_type_struct_sockad #include " -if test "x$ac_cv_type_struct_sockaddr_storage" = xyes -then : +if test "x$ac_cv_type_struct_sockaddr_storage" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_STORAGE 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 +_ACEOF fi @@ -11071,52 +12139,23 @@ ac_fn_c_check_member "$LINENO" "dl_hp_ppa_info_t" "dl_module_id_1" "ac_cv_member #include " -if test "x$ac_cv_member_dl_hp_ppa_info_t_dl_module_id_1" = xyes -then : +if test "x$ac_cv_member_dl_hp_ppa_info_t_dl_module_id_1" = xyes; then : -printf "%s\n" "#define HAVE_DL_HP_PPA_INFO_T_DL_MODULE_ID_1 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_DL_HP_PPA_INFO_T_DL_MODULE_ID_1 1 +_ACEOF fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Various Linux-specific mechanisms. # # Check whether --enable-usb was given. -if test ${enable_usb+y} -then : +if test "${enable_usb+set}" = set; then : enableval=$enable_usb; -else $as_nop +else enable_usb=no fi @@ -11128,55 +12167,72 @@ fi if test "xxx_only" != yes; then case "$host_os" in linux*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Linux usbmon USB sniffing support" >&5 -printf %s "checking for Linux usbmon USB sniffing support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux usbmon USB sniffing support" >&5 +$as_echo_n "checking for Linux usbmon USB sniffing support... " >&6; } if test "x$enable_usb" != "xno" ; then -printf "%s\n" "#define PCAP_SUPPORT_LINUX_USBMON 1" >>confdefs.h +$as_echo "#define PCAP_SUPPORT_LINUX_USBMON 1" >>confdefs.h MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null` - if test $? -ne 0 ; then - ac_usb_dev_name="usbmon" - fi - -printf "%s\n" "#define LINUX_USB_MON_DEV \"/dev/$ac_usb_dev_name\"" >>confdefs.h - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Device for USB sniffing is /dev/$ac_usb_dev_name" >&5 -printf "%s\n" "$as_me: Device for USB sniffing is /dev/$ac_usb_dev_name" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + # + # Note: if the directory for special files is *EVER* somewhere + # other than the UN*X standard of /dev (which will break any + # software that looks for /dev/null or /dev/tty, for example, + # so doing that is *REALLY* not a good idea), please provide + # some mechanism to determine that directory at *run time*, + # rather than *configure time*, so that it works when doinga + # a cross-build, and that works with *multiple* distributions, + # with our without udev, and with multiple versions of udev, + # with udevinfo or udevadm or any other mechanism to get the + # special files directory. # # Do we have a version of available? # If so, we might need it for . # - ac_fn_c_check_header_compile "$LINENO" "linux/compiler.h" "ac_cv_header_linux_compiler_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_compiler_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_COMPILER_H 1" >>confdefs.h + for ac_header in linux/compiler.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "linux/compiler.h" "ac_cv_header_linux_compiler_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_compiler_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_COMPILER_H 1 +_ACEOF fi +done + if test "$ac_cv_header_linux_compiler_h" = yes; then # # Yes - include it when testing for . # - ac_fn_c_check_header_compile "$LINENO" "linux/usbdevice_fs.h" "ac_cv_header_linux_usbdevice_fs_h" "#include + for ac_header in linux/usbdevice_fs.h +do : + ac_fn_c_check_header_compile "$LINENO" "linux/usbdevice_fs.h" "ac_cv_header_linux_usbdevice_fs_h" "#include " -if test "x$ac_cv_header_linux_usbdevice_fs_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_USBDEVICE_FS_H 1" >>confdefs.h +if test "x$ac_cv_header_linux_usbdevice_fs_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_USBDEVICE_FS_H 1 +_ACEOF fi +done + else - ac_fn_c_check_header_compile "$LINENO" "linux/usbdevice_fs.h" "ac_cv_header_linux_usbdevice_fs_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_usbdevice_fs_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_USBDEVICE_FS_H 1" >>confdefs.h + for ac_header in linux/usbdevice_fs.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "linux/usbdevice_fs.h" "ac_cv_header_linux_usbdevice_fs_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_usbdevice_fs_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_USBDEVICE_FS_H 1 +_ACEOF fi +done + fi if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then # @@ -11193,18 +12249,19 @@ fi #include " -if test "x$ac_cv_member_struct_usbdevfs_ctrltransfer_bRequestType" = xyes -then : +if test "x$ac_cv_member_struct_usbdevfs_ctrltransfer_bRequestType" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1 +_ACEOF fi fi else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi # @@ -11215,12 +12272,11 @@ printf "%s\n" "no" >&6; } # Check whether the includes Just Work. If not, don't turn on # netfilter support. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we can compile the netfilter support" >&5 -printf %s "checking whether we can compile the netfilter support... " >&6; } - if test ${ac_cv_netfilter_can_compile+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile the netfilter support" >&5 +$as_echo_n "checking whether we can compile the netfilter support... " >&6; } + if ${ac_cv_netfilter_can_compile+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -11235,27 +12291,26 @@ $ac_includes_default #include #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_netfilter_can_compile=yes -else $as_nop +else ac_cv_netfilter_can_compile=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_netfilter_can_compile" >&5 -printf "%s\n" "$ac_cv_netfilter_can_compile" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_netfilter_can_compile" >&5 +$as_echo "$ac_cv_netfilter_can_compile" >&6; } if test $ac_cv_netfilter_can_compile = yes ; then -printf "%s\n" "#define PCAP_SUPPORT_NETFILTER 1" >>confdefs.h +$as_echo "#define PCAP_SUPPORT_NETFILTER 1" >>confdefs.h MODULE_C_SRC="$MODULE_C_SRC pcap-netfilter-linux.c" fi @@ -11266,10 +12321,9 @@ fi # Check whether --enable-netmap was given. -if test ${enable_netmap+y} -then : +if test "${enable_netmap+set}" = set; then : enableval=$enable_netmap; -else $as_nop +else enable_netmap=yes fi @@ -11281,12 +12335,11 @@ if test "x$enable_netmap" != "xno" ; then # is defined, for example, as it includes a non-existent malloc.h # header. # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we can compile the netmap support" >&5 -printf %s "checking whether we can compile the netmap support... " >&6; } - if test ${ac_cv_net_netmap_user_can_compile+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile the netmap support" >&5 +$as_echo_n "checking whether we can compile the netmap support... " >&6; } + if ${ac_cv_net_netmap_user_can_compile+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -11294,27 +12347,26 @@ $ac_includes_default #define NETMAP_WITH_LIBS #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_net_netmap_user_can_compile=yes -else $as_nop +else ac_cv_net_netmap_user_can_compile=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_net_netmap_user_can_compile" >&5 -printf "%s\n" "$ac_cv_net_netmap_user_can_compile" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_net_netmap_user_can_compile" >&5 +$as_echo "$ac_cv_net_netmap_user_can_compile" >&6; } if test $ac_cv_net_netmap_user_can_compile = yes ; then -printf "%s\n" "#define PCAP_SUPPORT_NETMAP 1" >>confdefs.h +$as_echo "#define PCAP_SUPPORT_NETMAP 1" >>confdefs.h MODULE_C_SRC="$MODULE_C_SRC pcap-netmap.c" fi @@ -11324,8 +12376,7 @@ fi # Check for DPDK support. # Check whether --with-dpdk was given. -if test ${with_dpdk+y} -then : +if test "${with_dpdk+set}" = set; then : withval=$with_dpdk; if test "$withval" = no then @@ -11342,7 +12393,7 @@ then : dpdk_dir=$withval fi -else $as_nop +else if test "$V_PCAP" = dpdk; then # User requested DPDK-only libpcap, so we'd better have @@ -11363,258 +12414,340 @@ fi if test "$want_dpdk" != no; then - if test "x$PKGCONFIG" != "xno" - then - # - # We have pkg-config; see if we have DPDK installed - # as a package. - # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for DPDK with pkg-config" >&5 -printf %s "checking for DPDK with pkg-config... " >&6; } - if "$PKGCONFIG" libdpdk - then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found" >&5 -printf "%s\n" "found" >&6; } - found_dpdk_with_pkg_config=yes - DPDK_CFLAGS=`"$PKGCONFIG" --cflags libdpdk` - DPDK_LDFLAGS=`"$PKGCONFIG" --libs libdpdk` - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -printf "%s\n" "not found" >&6; } - fi + # + # The user didn't explicitly say they don't want DPDK, + # so see if we have it. + # + # We only try to find it using pkg-config; DPDK is *SO* + # complicated - DPDK 19.02, for example, has about 117(!) + # libraries, and the precise set of libraries required has + # changed over time - so attempting to guess which libraries + # you need, and hardcoding that in an attempt to find the + # libraries without DPDK, rather than relying on DPDK to + # tell you, with a .pc file, what libraries are needed, + # is *EXTREMELY* fragile and has caused some bug reports, + # so we're just not going to do it. + # + # If that causes a problem, the only thing we will do is + # accept an alternative way of finding the appropriate + # library set for the installed version of DPDK that is + # as robust as pkg-config (i.e., it had better work as well + # as pkg-config with *ALL* versions of DPDK that provide a + # libdpdk.pc file). + # + # If --with-dpdk={path} was specified, add {path}/pkgconfig + # to PKG_CONFIG_PATH, so we look for the .pc file there, + # first. + # + save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" + if test -n "$dpdk_dir"; then + PKG_CONFIG_PATH="$dpdk_dir:$PKG_CONFIG_PATH" fi - # - # If we didn't find it with pkg-config, try checking for - # it manually. - # - if test "x$found_dpdk_with_pkg_config" != "xyes" - then - if test -z "$dpdk_dir"; then - # - # The user didn't specify a directory containing - # the DPDK headers and libraries. If we find - # a /usr/local/include/dpdk directory, assume - # it's /usr/local, otherwise assume it's /usr. - # - if test -d "/usr/local/include/dpdk"; then - dpdk_dir="/usr/local" - else - dpdk_dir="/usr" - fi - fi - # - # The convention appears to be that 1) there's a "dpdk" - # subdirectory of the include directory, containing DPDK - # headers (at least in the installation on Ubuntu with - # the system DPDK packages) and 2) includes of DPDK - # headers don't use "dpdk/{header}" (at least from the - # way the DPDK documentation is written). - # - # So we add "/dpdk" to the include directory, and always - # add that to the list of include directories to search. - # - dpdk_inc_dir="$dpdk_dir/include/dpdk" - dpdk_inc_flags="-I$dpdk_inc_dir" - dpdk_lib_dir="$dpdk_dir/lib" - # - # Handle multiarch systems. - # - # Step 1: run the C compiler with the -dumpmachine option; - # if it succeeds, the output would be the multiarch directory - # name if your system has multiarch directories. - # - multiarch_dir=`$CC -dumpmachine 2>/dev/null` - if test ! -z "$multiarch_dir" - then - # - # OK, we have a multiarch directory. - # - # Now deal with includes. On Ubuntu 20.04, for - # example, we have /usr/include/dpdk *and* - # /usr/include/$multiarch_dir/dpdk, and must - # search both. - # - if test -d "$dpdk_dir/include/$multiarch_dir/dpdk" - then - dpdk_inc_flags="-I$dpdk_dir/include/$multiarch_dir/dpdk $dpdk_inc_flags" - fi - # - # Now deal with libraries. - # - if test -d "$dpdk_lib_dir/$multiarch_dir" - then - dpdk_lib_dir="$dpdk_lib_dir/$multiarch_dir" - fi - fi - DPDK_MACHINE_CFLAGS="-march=native" - DPDK_CFLAGS="$DPDK_MACHINE_CFLAGS $dpdk_inc_flags" - DPDK_LDFLAGS="-L$dpdk_lib_dir -ldpdk -lrt -lm -lnuma -ldl -pthread" +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdpdk with pkg-config" >&5 +$as_echo_n "checking for libdpdk with pkg-config... " >&6; } + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdpdk\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + + # + # The package was found, so try to get its C flags and + # libraries. + # + if test -n "$DPDK_CFLAGS"; then + pkg_cv_DPDK_CFLAGS="$DPDK_CFLAGS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdpdk\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DPDK_CFLAGS=`$PKG_CONFIG --cflags "libdpdk" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$DPDK_LIBS"; then + pkg_cv_DPDK_LIBS="$DPDK_LIBS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdpdk\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DPDK_LIBS=`$PKG_CONFIG --libs "libdpdk" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$DPDK_LIBS_STATIC"; then + pkg_cv_DPDK_LIBS_STATIC="$DPDK_LIBS_STATIC" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdpdk\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DPDK_LIBS_STATIC=`$PKG_CONFIG --libs --static "libdpdk" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + DPDK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdpdk" 2>&1` + else + DPDK_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdpdk" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$DPDK_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libdpdk) were not met: + +$DPDK_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + + +Alternatively, you may set the environment variables DPDK_CFLAGS +and DPDK_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5 +$as_echo "not found (pkg-config not found)" >&6; } + else + # + # We found the package. + # + DPDK_CFLAGS=$pkg_cv_DPDK_CFLAGS + DPDK_LIBS=$pkg_cv_DPDK_LIBS + DPDK_LIBS_STATIC=$pkg_cv_DPDK_LIBS_STATIC + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + + found_dpdk=yes + fi +else + + # + # The package isn't present. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + +fi + + PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH" + + # + # Did we find DPDK? + # + if test "$found_dpdk" = yes; then + # + # Found it. + # + # We call rte_eth_dev_count_avail(), and older versions + # of DPDK didn't have it, so check for it. + # save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" save_LDFLAGS="$LDFLAGS" - CFLAGS="$CFLAGS $DPDK_CFLAGS" - LIBS="$LIBS $DPDK_LDFLAGS" - LDFLAGS="$LDFLAGS $DPDK_LDFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we can compile the DPDK support" >&5 -printf %s "checking whether we can compile the DPDK support... " >&6; } - if test ${ac_cv_dpdk_can_compile+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -$ac_includes_default -#include -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_dpdk_can_compile=yes -else $as_nop - ac_cv_dpdk_can_compile=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_dpdk_can_compile" >&5 -printf "%s\n" "$ac_cv_dpdk_can_compile" >&6; } - - # - # We include rte_bus.h, and older versions of DPDK - # didn't have it, so check for it. - # - if test "$ac_cv_dpdk_can_compile" = yes; then - # - # This runs the preprocessor, so make sure it - # looks in the DPDK directories. Instead of - # including dpdk/XXX.h, we include just XXX.h - # and assume DPDK_CFLAGS is the directory - # containing the DPDK headers (that's how - # pkg-config sets it, at least on Ubuntu), - # so just looking under /usr/include won't - # find it. - # - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DPDK_CFLAGS" - ac_fn_c_check_header_compile "$LINENO" "rte_bus.h" "ac_cv_header_rte_bus_h" "$ac_includes_default" -if test "x$ac_cv_header_rte_bus_h" = xyes -then : - -fi - - CPPFLAGS="$save_CPPFLAGS" - fi - - # - # We call rte_eth_dev_count_avail(), and older versions - # of DPDK didn't have it, so check for it. - # - if test "$ac_cv_header_rte_bus_h" = yes; then + CFLAGS="$CFLAGS $DPDK_CFLAGS" + LIBS="$LIBS $DPDK_LIBS" ac_fn_c_check_func "$LINENO" "rte_eth_dev_count_avail" "ac_cv_func_rte_eth_dev_count_avail" -if test "x$ac_cv_func_rte_eth_dev_count_avail" = xyes -then : +if test "x$ac_cv_func_rte_eth_dev_count_avail" = xyes; then : fi - fi CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" LDFLAGS="$save_LDFLAGS" + fi + if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then - CFLAGS="$CFLAGS $DPDK_CFLAGS" - LIBS="$LIBS $DPDK_LDFLAGS" - LDFLAGS="$LDFLAGS $DPDK_LDFLAGS" - V_INCLS="$V_INCLS $DPDK_CFLAGS" - -printf "%s\n" "#define PCAP_SUPPORT_DPDK 1" >>confdefs.h - - if test $V_PCAP != dpdk ; then - MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c" - fi - + # + # We found a usable DPDK. # # Check whether the rte_ether.h file defines # struct ether_addr or struct rte_ether_addr. # # ("API compatibility? That's for losers!") # + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS $DPDK_CFLAGS" + LIBS="$LIBS $DPDK_LIBS" ac_fn_c_check_type "$LINENO" "struct rte_ether_addr" "ac_cv_type_struct_rte_ether_addr" " #include " -if test "x$ac_cv_type_struct_rte_ether_addr" = xyes -then : +if test "x$ac_cv_type_struct_rte_ether_addr" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_RTE_ETHER_ADDR 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_RTE_ETHER_ADDR 1 +_ACEOF fi - else - if test "$V_PCAP" = dpdk; then - # User requested DPDK-only capture support, but - # we couldn't the DPDK API support at all, or we - # found it but it wasn't a sufficiently recent - # version. - if test "$ac_cv_dpdk_can_compile" != yes; then - # - # Couldn't even find the headers. - # - as_fn_error $? "DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support" "$LINENO" 5 - else - # - # Found the headers, but we couldn't find - # rte_bus.h or rte_eth_dev_count_avail(), - # we don't have a sufficiently recent - # version of DPDK. - # - as_fn_error $? "DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later; install a newer version of DPDK, or don't request DPDK support" "$LINENO" 5 - fi - fi - if test "$want_dpdk" = yes; then - # User requested DPDK-only capture support, but - # we couldn't the DPDK API support at all, or we - # found it but it wasn't a sufficiently recent - # version. - if test "$ac_cv_dpdk_can_compile" != yes; then + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + + # + # We can build with DPDK. + # + V_INCLS="$V_INCLS $DPDK_CFLAGS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DPDK_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DPDK_LIBS_STATIC" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE libdpdk" + +$as_echo "#define PCAP_SUPPORT_DPDK 1" >>confdefs.h + + if test $V_PCAP != dpdk ; then + MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c" + fi + else + # + # We didn't find a usable DPDK. + # If we required it (with --with-dpdk or --with-pcap=dpdk), + # fail with an appropriate message telling the user what + # the problem was, otherwise note the problem with a + # warning. + # + if test "$found_dpdk" != yes; then + # + # Not found with pkg-config. Note that we + # require that DPDK must be findable with + # pkg-config. + # + if test "$V_PCAP" = dpdk; then # - # Couldn't even find the headers. + # User requested DPDK-only capture support. # - as_fn_error $? "DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support" "$LINENO" 5 - else - # - # Found the headers, but we couldn't find - # rte_bus.h or rte_eth_dev_count_avail(), - # we don't have a sufficiently recent - # version of DPDK. - # - as_fn_error $? "DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later: install a newer version of DPDK, or don't request DPDK support" "$LINENO" 5 + as_fn_error $? "DPDK support requested with --with-pcap=dpdk, but +we couldn't find DPDK with pkg-config. Make sure that pkg-config is +installed, that DPDK 18.02.2 or later is installed, and that DPDK +provides a .pc file." "$LINENO" 5 fi + + if test "$want_dpdk" = yes; then + # + # User requested that libpcap include + # DPDK capture support. + # + as_fn_error $? "DPDK support requested with --with-dpdk, but we +couldn't find DPDK with pkg-config. Make sure that pkg-config +is installed, that DPDK 18.02.2 or later is installed, and that +DPDK provides .pc file." "$LINENO" 5 + fi + + # + # User didn't indicate whether they wanted DPDK + # or not; just warn why we didn't find it. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: We couldn't find DPDK with pkg-config. If +you want DPDK support, make sure that pkg-config is installed, +that DPDK 18.02.2 or later is installed, and that DPDK provides a +.pc file." >&5 +$as_echo "$as_me: WARNING: We couldn't find DPDK with pkg-config. If +you want DPDK support, make sure that pkg-config is installed, +that DPDK 18.02.2 or later is installed, and that DPDK provides a +.pc file." >&2;} + elif test "$ac_cv_func_rte_eth_dev_count_avail" != yes; then + # + # Found with pkg-config, but we couldn't compile + # a program that calls rte_eth_dev_count(); we + # probably have the developer package installed, + # but don't have a sufficiently recent version + # of DPDK. Note that we need a sufficiently + # recent version of DPDK. + # + if test "$V_PCAP" = dpdk; then + # + # User requested DPDK-only capture support. + # + as_fn_error $? "DPDK support requested with --with-pcap=dpdk, but we +can't compile libpcap with DPDK. Make sure that DPDK 18.02.2 or later +is installed." "$LINENO" 5 + fi + + if test "$want_dpdk" = yes; then + # + # User requested that libpcap include + # DPDK capture support. + # + as_fn_error $? "DPDK support requested with --with-dpdk, but +we can't compile libpcap with DPDK. Make sure that DPDK 18.02.2 +or later is DPDK is installed." "$LINENO" 5 + fi + + # + # User didn't indicate whether they wanted DPDK + # or not; just warn why we didn't find it. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: DPDK was found, but we can't compile libpcap with it. +Make sure that DPDK 18.02.2 or later is installed." >&5 +$as_echo "$as_me: WARNING: DPDK was found, but we can't compile libpcap with it. +Make sure that DPDK 18.02.2 or later is installed." >&2;} fi fi fi # Check whether --enable-bluetooth was given. -if test ${enable_bluetooth+y} -then : +if test "${enable_bluetooth+set}" = set; then : enableval=$enable_bluetooth; -else $as_nop +else enable_bluetooth=no fi @@ -11628,20 +12761,19 @@ fi if test "x$enable_bluetooth" != "xno" ; then case "$host_os" in linux*) - ac_fn_c_check_header_compile "$LINENO" "bluetooth/bluetooth.h" "ac_cv_header_bluetooth_bluetooth_h" "$ac_includes_default" -if test "x$ac_cv_header_bluetooth_bluetooth_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "bluetooth/bluetooth.h" "ac_cv_header_bluetooth_bluetooth_h" "$ac_includes_default" +if test "x$ac_cv_header_bluetooth_bluetooth_h" = xyes; then : # # We have bluetooth.h, so we support Bluetooth # sniffing. # -printf "%s\n" "#define PCAP_SUPPORT_BT 1" >>confdefs.h +$as_echo "#define PCAP_SUPPORT_BT 1" >>confdefs.h MODULE_C_SRC="$MODULE_C_SRC pcap-bt-linux.c" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is supported" >&5 -printf "%s\n" "$as_me: Bluetooth sniffing is supported" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is supported" >&5 +$as_echo "$as_me: Bluetooth sniffing is supported" >&6;} ac_lbl_bluetooth_available=yes # @@ -11653,21 +12785,21 @@ printf "%s\n" "$as_me: Bluetooth sniffing is supported" >&6;} #include " -if test "x$ac_cv_member_struct_sockaddr_hci_hci_channel" = xyes -then : +if test "x$ac_cv_member_struct_sockaddr_hci_hci_channel" = xyes; then : -printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL 1 +_ACEOF # # Yes; is HCI_CHANNEL_MONITOR defined? # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if HCI_CHANNEL_MONITOR is defined" >&5 -printf %s "checking if HCI_CHANNEL_MONITOR is defined... " >&6; } - if test ${ac_cv_lbl_hci_channel_monitor_is_defined+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if HCI_CHANNEL_MONITOR is defined" >&5 +$as_echo_n "checking if HCI_CHANNEL_MONITOR is defined... " >&6; } + if ${ac_cv_lbl_hci_channel_monitor_is_defined+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -11675,7 +12807,7 @@ else $as_nop #include int -main (void) +main () { u_int i = HCI_CHANNEL_MONITOR; @@ -11684,30 +12816,29 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define PCAP_SUPPORT_BT_MONITOR /**/" >>confdefs.h +$as_echo "#define PCAP_SUPPORT_BT_MONITOR /**/" >>confdefs.h MODULE_C_SRC="$MODULE_C_SRC pcap-bt-monitor-linux.c" -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi -else $as_nop +else # # We don't have bluetooth.h, so we don't support @@ -11716,19 +12847,20 @@ else $as_nop if test "x$enable_bluetooth" = "xyes" ; then as_fn_error $? "Bluetooth sniffing is not supported; install bluez-lib devel to enable it" "$LINENO" 5 else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5 -printf "%s\n" "$as_me: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5 +$as_echo "$as_me: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&6;} fi fi + ;; *) if test "x$enable_bluetooth" = "xyes" ; then as_fn_error $? "no Bluetooth sniffing support implemented for $host_os" "$LINENO" 5 else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: no Bluetooth sniffing support implemented for $host_os" >&5 -printf "%s\n" "$as_me: no Bluetooth sniffing support implemented for $host_os" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: no Bluetooth sniffing support implemented for $host_os" >&5 +$as_echo "$as_me: no Bluetooth sniffing support implemented for $host_os" >&6;} fi ;; esac @@ -11736,10 +12868,9 @@ printf "%s\n" "$as_me: no Bluetooth sniffing support implemented for $host_os" > fi # Check whether --enable-dbus was given. -if test ${enable_dbus+y} -then : +if test "${enable_dbus+set}" = set; then : enableval=$enable_dbus; -else $as_nop +else enable_dbus=no fi @@ -11783,76 +12914,194 @@ if test "x$enable_dbus" != "xno"; then fi if test "x$enable_dbus" != "xno"; then - if test "x$PKGCONFIG" != "xno"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5 -printf %s "checking for D-Bus... " >&6; } - if "$PKGCONFIG" dbus-1; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` - DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS $DBUS_CFLAGS" - LIBS="$LIBS $DBUS_LIBS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5 -printf %s "checking whether the D-Bus library defines dbus_connection_read_write... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbus-1 with pkg-config" >&5 +$as_echo_n "checking for dbus-1 with pkg-config... " >&6; } + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + + # + # The package was found, so try to get its C flags and + # libraries. + # + if test -n "$DBUS_CFLAGS"; then + pkg_cv_DBUS_CFLAGS="$DBUS_CFLAGS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "dbus-1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$DBUS_LIBS"; then + pkg_cv_DBUS_LIBS="$DBUS_LIBS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "dbus-1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$DBUS_LIBS_STATIC"; then + pkg_cv_DBUS_LIBS_STATIC="$DBUS_LIBS_STATIC" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 + ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DBUS_LIBS_STATIC=`$PKG_CONFIG --libs --static "dbus-1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-1" 2>&1` + else + DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-1" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$DBUS_PKG_ERRORS" >&5 + + + if test "x$enable_dbus" = "xyes"; then + as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5 + fi + + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5 +$as_echo "not found (pkg-config not found)" >&6; } + else + # + # We found the package. + # + DBUS_CFLAGS=$pkg_cv_DBUS_CFLAGS + DBUS_LIBS=$pkg_cv_DBUS_LIBS + DBUS_LIBS_STATIC=$pkg_cv_DBUS_LIBS_STATIC + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS $DBUS_CFLAGS" + LIBS="$LIBS $DBUS_LIBS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5 +$as_echo_n "checking whether the D-Bus library defines dbus_connection_read_write... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include + #include + #include - #include + #include int -main (void) +main () { return dbus_connection_read_write(NULL, 0); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -printf "%s\n" "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h +$as_echo "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h - MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c" - V_INCLS="$V_INCLS $DBUS_CFLAGS" + MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c" + V_INCLS="$V_INCLS $DBUS_CFLAGS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DBUS_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DBUS_LIBS_STATIC" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE dbus-1" -else $as_nop +else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - if test "x$enable_dbus" = "xyes"; then - as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5 - fi - LIBS="$save_LIBS" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + if test "x$enable_dbus" = "xyes"; then + as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5 + fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - CFLAGS="$save_CFLAGS" - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - if test "x$enable_dbus" = "xyes"; then - as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5 - fi - fi + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + fi +else + + # + # The package isn't present. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + +fi + fi # Check whether --enable-rdma was given. -if test ${enable_rdma+y} -then : +if test "${enable_rdma+set}" = set; then : enableval=$enable_rdma; -else $as_nop +else enable_rdma=ifavailable fi @@ -11864,12 +13113,148 @@ if test "xxx_only" = yes; then fi if test "x$enable_rdma" != "xno"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ibv_get_device_list in -libverbs" >&5 -printf %s "checking for ibv_get_device_list in -libverbs... " >&6; } -if test ${ac_cv_lib_ibverbs_ibv_get_device_list+y} -then : - printf %s "(cached) " >&6 -else $as_nop + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libibverbs with pkg-config" >&5 +$as_echo_n "checking for libibverbs with pkg-config... " >&6; } + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libibverbs\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libibverbs") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + + # + # The package was found, so try to get its C flags and + # libraries. + # + if test -n "$LIBIBVERBS_CFLAGS"; then + pkg_cv_LIBIBVERBS_CFLAGS="$LIBIBVERBS_CFLAGS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libibverbs\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libibverbs") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBIBVERBS_CFLAGS=`$PKG_CONFIG --cflags "libibverbs" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$LIBIBVERBS_LIBS"; then + pkg_cv_LIBIBVERBS_LIBS="$LIBIBVERBS_LIBS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libibverbs\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libibverbs") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBIBVERBS_LIBS=`$PKG_CONFIG --libs "libibverbs" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$LIBIBVERBS_LIBS_STATIC"; then + pkg_cv_LIBIBVERBS_LIBS_STATIC="$LIBIBVERBS_LIBS_STATIC" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libibverbs\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libibverbs") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBIBVERBS_LIBS_STATIC=`$PKG_CONFIG --libs --static "libibverbs" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBIBVERBS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libibverbs" 2>&1` + else + LIBIBVERBS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libibverbs" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBIBVERBS_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libibverbs) were not met: + +$LIBIBVERBS_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + + +Alternatively, you may set the environment variables LIBIBVERBS_CFLAGS +and LIBIBVERBS_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5 +$as_echo "not found (pkg-config not found)" >&6; } + else + # + # We found the package. + # + LIBIBVERBS_CFLAGS=$pkg_cv_LIBIBVERBS_CFLAGS + LIBIBVERBS_LIBS=$pkg_cv_LIBIBVERBS_LIBS + LIBIBVERBS_LIBS_STATIC=$pkg_cv_LIBIBVERBS_LIBS_STATIC + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + + found_libibverbs=yes + LIBIBVERBS_REQUIRES_PRIVATE="libibverbs" + + fi +else + + # + # The package isn't present. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + +fi + + + if test "x$found_libibverbs" != "xyes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ibv_get_device_list in -libverbs" >&5 +$as_echo_n "checking for ibv_get_device_list in -libverbs... " >&6; } +if ${ac_cv_lib_ibverbs_ibv_get_device_list+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-libverbs $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11878,33 +13263,57 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char ibv_get_device_list (); int -main (void) +main () { return ibv_get_device_list (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ibverbs_ibv_get_device_list=yes -else $as_nop +else ac_cv_lib_ibverbs_ibv_get_device_list=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ibverbs_ibv_get_device_list" >&5 -printf "%s\n" "$ac_cv_lib_ibverbs_ibv_get_device_list" >&6; } -if test "x$ac_cv_lib_ibverbs_ibv_get_device_list" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ibverbs_ibv_get_device_list" >&5 +$as_echo "$ac_cv_lib_ibverbs_ibv_get_device_list" >&6; } +if test "x$ac_cv_lib_ibverbs_ibv_get_device_list" = xyes; then : - ac_fn_c_check_header_compile "$LINENO" "infiniband/verbs.h" "ac_cv_header_infiniband_verbs_h" "$ac_includes_default" -if test "x$ac_cv_header_infiniband_verbs_h" = xyes -then : + found_libibverbs=yes + LIBIBVERBS_CFLAGS="" + LIBIBVERBS_LIBS="-libverbs" + # XXX - at least on Ubuntu 20.04, there are many more + # libraries needed; is there any platform where + # libibverbs is available but where pkg-config isn't + # available or libibverbs doesn't use it? If not, + # we should only use pkg-config for it. + LIBIBVERBS_LIBS_STATIC="-libverbs" + LIBIBVERBS_LIBS_PRIVATE="-libverbs" + + +fi + + fi + + if test "x$found_libibverbs" = "xyes"; then + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS $LIBIBVERBS_CFLAGS" + LIBS="$LIBS $LIBIBVERBS_LIBS" + ac_fn_c_check_header_mongrel "$LINENO" "infiniband/verbs.h" "ac_cv_header_infiniband_verbs_h" "$ac_includes_default" +if test "x$ac_cv_header_infiniband_verbs_h" = xyes; then : # # ibv_create_flow may be defined as a static inline @@ -11917,15 +13326,15 @@ then : # this (they do a clever trick to avoid having # to know the function's signature). # - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether libibverbs defines ibv_create_flow" >&5 -printf %s "checking whether libibverbs defines ibv_create_flow... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libibverbs defines ibv_create_flow" >&5 +$as_echo_n "checking whether libibverbs defines ibv_create_flow... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { (void) ibv_create_flow((struct ibv_qp *) NULL, @@ -11935,37 +13344,103 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + found_usable_libibverbs=yes -printf "%s\n" "#define PCAP_SUPPORT_RDMASNIFF /**/" >>confdefs.h +else - MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c" - LIBS="-libverbs $LIBS" - -else $as_nop - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -fi + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + fi + + if test "x$found_usable_libibverbs" = "xyes" + then + +$as_echo "#define PCAP_SUPPORT_RDMASNIFF /**/" >>confdefs.h + + MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c" + CFLAGS="$LIBIBVERBS_CFLAGS $CFLAGS" + ADDITIONAL_LIBS="$LIBIBVERBS_LIBS $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="$LIBIBVERBS_LIBS_STATIC $ADDITIONAL_LIBS_STATIC" + LIBS_PRIVATE="$LIBIBVERBS_LIBS_PRIVATE $LIBS_PRIVATE" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE $LIBIBVERBS_REQUIRES_PRIVATE" + fi fi +# +# If this is a platform where we need to have the .pc file and +# pcap-config script supply an rpath option to specify the directory +# in which the libpcap shared library is installed, and the install +# prefix /usr (meaning we're not installing a system library), provide +# the rpath option. +# +# (We must check $prefix, as $libdir isn't necessarily /usr/lib in this +# case - for example, Linux distributions for 64-bit platforms that +# also provide support for binaries for a 32-bit version of the +# platform may put the 64-bit libraries, the 32-bit libraries, or both +# in directories other than /usr/lib.) +# +# In AIX, do we have to do this? +# +# In Darwin-based OSes, the full paths of the shared libraries with +# which the program was linked are stored in the executable, so we don't +# need to provide an rpath option. +# +# With the HP-UX linker, directories specified with -L are, by default, +# added to the run-time search path, so we don't need to supply them. +# +# For Tru64 UNIX, "-rpath" works with DEC's^WCompaq's^WHP's C compiler +# for Alpha, but isn't documented as working with GCC, and no GCC- +# compatible option is documented as working with the DEC compiler. +# If anybody needs this on Tru64/Alpha, they're welcome to figure out a +# way to make it work. +# +# This must *not* depend on the compiler, as, on platforms where there's +# a GCC-compatible compiler and a vendor compiler, we need to work with +# both. +# +if test "$prefix" != "/usr"; then + case "$host_os" in - # Find a good install program. We prefer a C program (faster), + freebsd*|netbsd*|openbsd*|dragonfly*|linux*|haiku*|midipix*|gnu*) + # + # Platforms where the "native" C compiler is GCC or + # accepts compatible command-line arguments, and the + # "native" linker is the GNU linker or accepts + # compatible command-line arguments. + # + RPATH="-Wl,-rpath,\${libdir}" + ;; + + solaris*) + # + # Sun/Oracle's linker, the GNU linker, and + # GNU-compatible linkers all support -R. + # + RPATH="-Wl,-R,\${libdir}" + ;; + esac +fi + +# Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install @@ -11979,25 +13454,20 @@ fi # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -printf %s "checking for a BSD-compatible install... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test ${ac_cv_path_install+y} -then : - printf %s "(cached) " >&6 -else $as_nop +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - # Account for fact that we put trailing slashes in our PATH walk. -case $as_dir in #(( - ./ | /[cC]/* | \ + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; @@ -12007,13 +13477,13 @@ case $as_dir in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && - grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && - grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else @@ -12021,12 +13491,12 @@ case $as_dir in #(( echo one > conftest.one echo two > conftest.two mkdir conftest.dir - if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" && + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then - ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c" + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi @@ -12042,7 +13512,7 @@ IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi - if test ${ac_cv_path_install+y}; then + if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a @@ -12052,8 +13522,8 @@ fi INSTALL=$ac_install_sh fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -printf "%s\n" "$INSTALL" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -12067,6 +13537,29 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' ac_config_headers="$ac_config_headers config.h" + + + + + + + + + + + + + + + + +# +# We're done with configuration operations; add ADDITIONAL_LIBS and +# ADDITIONAL_LIBS_STATIC to LIBS and LIBS_STATIC, respectively. +# +LIBS="$ADDITIONAL_LIBS $LIBS" +LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $LIBS_STATIC" + ac_config_commands="$ac_config_commands default-1" ac_config_files="$ac_config_files Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap" @@ -12098,8 +13591,8 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( @@ -12129,15 +13622,15 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} /^ac_cv_env_/b end t clear :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -printf "%s\n" "$as_me: updating cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else @@ -12151,8 +13644,8 @@ printf "%s\n" "$as_me: updating cache $cache_file" >&6;} fi fi else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -12169,7 +13662,7 @@ U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" @@ -12185,8 +13678,8 @@ LTLIBOBJS=$ac_ltlibobjs ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL @@ -12209,16 +13702,14 @@ cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: -if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else $as_nop +else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( @@ -12228,46 +13719,46 @@ esac fi - -# Reset variables that may have inherited troublesome values from -# the environment. - -# IFS needs to be set, to space, tab, and newline, in precisely that order. -# (If _AS_PATH_WALK were called with IFS unset, it would have the -# side effect of setting IFS to empty, thus disabling word splitting.) -# Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl -IFS=" "" $as_nl" - -PS1='$ ' -PS2='> ' -PS4='+ ' - -# Ensure predictable behavior from utilities with locale-dependent output. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# We cannot yet rely on "unset" to work, but we need these variables -# to be unset--not just set to an empty or harmless value--now, to -# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct -# also avoids known problems related to "unset" and subshell syntax -# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). -for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH -do eval test \${$as_var+y} \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done - -# Ensure that fds 0, 1, and 2 are open. -if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi -if (exec 3>&2) ; then :; else exec 2>/dev/null; fi +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi # The user is always right. -if ${PATH_SEPARATOR+false} :; then +if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || @@ -12276,6 +13767,13 @@ if ${PATH_SEPARATOR+false} :; then fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( @@ -12284,12 +13782,8 @@ case $0 in #(( for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - test -r "$as_dir$0" && as_myself=$as_dir$0 && break + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS @@ -12301,10 +13795,30 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] @@ -12317,14 +13831,13 @@ as_fn_error () as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - printf "%s\n" "$as_me: error: $2" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error - # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. @@ -12351,20 +13864,18 @@ as_fn_unset () { eval $1=; unset $1;} } as_unset=as_fn_unset - # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null -then : +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' -else $as_nop +else as_fn_append () { eval $1=\$$1\$2 @@ -12376,13 +13887,12 @@ fi # as_fn_append # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null -then : +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' -else $as_nop +else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` @@ -12413,7 +13923,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -12435,10 +13945,6 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits - -# Determine whether it's possible to make 'echo' print without a newline. -# These variables are no longer used directly by Autoconf, but are AC_SUBSTed -# for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) @@ -12452,12 +13958,6 @@ case `echo -n x` in #((((( ECHO_N='-n';; esac -# For backward compatibility with old third-party macros, we provide -# the shell variables $as_echo and $as_echo_n. New code should use -# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. -as_echo='printf %s\n' -as_echo_n='printf %s' - rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file @@ -12499,7 +13999,7 @@ as_fn_mkdir_p () as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -12508,7 +14008,7 @@ $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_dir" | +$as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -12570,8 +14070,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pcap $as_me 1.10.1, which was -generated by GNU Autoconf 2.71. Invocation command line was +This file was extended by pcap $as_me 1.10.4, which was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -12633,16 +14133,14 @@ $config_commands Report bugs to the package provider." _ACEOF -ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` -ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config='$ac_cs_config_escaped' +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -pcap config.status 1.10.1 -configured by $0, generated by GNU Autoconf 2.71, +pcap config.status 1.10.4 +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2021 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -12680,15 +14178,15 @@ do -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - printf "%s\n" "$ac_cs_version"; exit ;; + $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) - printf "%s\n" "$ac_cs_config"; exit ;; + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in - *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" @@ -12696,7 +14194,7 @@ do --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in - *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; @@ -12705,7 +14203,7 @@ do as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) - printf "%s\n" "$ac_cs_usage"; exit ;; + $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; @@ -12733,7 +14231,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift - \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" @@ -12747,7 +14245,7 @@ exec 5>>config.log sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX - printf "%s\n" "$ac_log" + $as_echo "$ac_log" } >&5 _ACEOF @@ -12796,9 +14294,9 @@ done # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then - test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files - test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers - test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree @@ -13134,7 +14632,7 @@ do esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac - case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done @@ -13142,17 +14640,17 @@ do # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` - printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -printf "%s\n" "$as_me: creating $ac_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) - ac_sed_conf_input=`printf "%s\n" "$configure_input" | + ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac @@ -13169,7 +14667,7 @@ $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$ac_file" | +$as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -13193,9 +14691,9 @@ printf "%s\n" X"$ac_file" | case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -13252,8 +14750,8 @@ ac_sed_dataroot=' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' @@ -13296,9 +14794,9 @@ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 -printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" @@ -13314,27 +14812,27 @@ which seems to be undefined. Please make sure it is defined" >&2;} # if test x"$ac_file" != x-; then { - printf "%s\n" "/* $configure_input */" >&1 \ + $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else - printf "%s\n" "/* $configure_input */" >&1 \ + $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; - :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -printf "%s\n" "$as_me: executing $ac_file commands" >&6;} + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac @@ -13343,7 +14841,7 @@ printf "%s\n" "$as_me: executing $ac_file commands" >&6;} "default-1":C) if test -f .devel; then echo timestamp > stamp-h cat $srcdir/Makefile-devel-adds >> Makefile - make depend + make depend || exit 1 fi ;; esac @@ -13379,9 +14877,8 @@ if test "$no_create" != yes; then $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi exit 0 - diff --git a/libpcap/configure.ac b/libpcap/configure.ac index 2a7a50084..cde530fe2 100644 --- a/libpcap/configure.ac +++ b/libpcap/configure.ac @@ -14,12 +14,92 @@ dnl # config.sub. # -AC_PREREQ(2.64) +AC_PREREQ(2.69) -AC_INIT(pcap, m4_esyscmd_s([cat VERSION.txt])) +AC_INIT(pcap, m4_esyscmd_s([cat VERSION])) AC_CONFIG_SRCDIR(pcap.c) AC_SUBST(PACKAGE_NAME) +# +# These are the variables that are used in Makefile, pcap-config, and +# libpcap.pc. +# +# CFLAGS: inherited from the environment, not modified by us (except +# temporarily during tests that involve compilation). Used only when +# compiling C source. +# +# CXXFLAGS: inherited from the environment, not modified by us. Used only +# when compiling C++ source. +# +# LDFLAGS: inherited from the environment, not modified by us. +# +# LIBS: inherited from the environment; we add libraries required by +# libpcap. Librares that the core libpcap code requires are added +# first; libraries required by additional pcap modules are first +# added to ADDITIONAL_LIBS, and only added to LIBS at the end, after +# we're finished doing configuration tests for the modules. +# +# LIBS_STATIC: libraries with which a program using the libpcap *static* +# library needs to be linked. This is a superset of LIBS, used in +# pcap-config, so that "pcap-config --libs --static" will report them. +# Initialized to LIBS. +# +# REQUIRES_PRIVATE: pkg-config package names for additional libraries +# with which a program using the libpcap *static* library needs to be +# linked and for which a .pc file exists. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them, and so that +# those libraries will be determined using the library's .pc file, not +# from our .pc file. Initialized to an empty string. +# +# V_CCOPT: additional compiler flags other than -I and -D flags +# needed when compiling libpcap. Used in Makefile for both C and +# C++ source. +# +# V_DEFS: additional -D compiler flags needed when compiling +# libpcap. Used in Makefile for both C and C++ source. +# +# V_INCLS: additional -I compiler flags needed when compiling +# libpcap. Used in Makefile for both C and C++ source. +# +# ADDITIONAL_LIBS: additional libraries with which the libpcap dynamic +# library needs to be linked. Used in Makwfile; not used in pcap-config +# or libpcap.pc, as, in all platforms on which we run, if a dynamic +# library is linked with other dynamic libraries, a program using +# that dynamic library doesn't have to link with those libraries - +# they will be automatically loaded at run time. Initialized to an +# empty string. +# +# ADDITIONAL_LIBS_STATIC: additional libraries with which a program +# using the libpcap *static* library needs to be linked. This is used +# in pcap-config, so that "pcap-config --libs --static" will report +# them. Initialized to an empty string. +# +# REQUIRES_PRIVATE: pkg-config package names for additional libraries +# with which a program using the libpcap *static* library needs to be +# linked and for which a .pc file exists. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them, and so that +# those libraries will be determined using the library's .pc file, not +# from our .pc file. Initialized to an empty string. +# +# LIBS_PRIVATE: pkg-config package names for additional libraries with +# which a program using the libpcap *static* library needs to be linked +# and for which a .pc file does not exist. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them (those libraries +# cannot be determined using the library's .pc file, as there is no such +# file, so it has to come from our .pc file. Initialized to an empty +# string. +# +LIBS_STATIC="" +REQUIRES_PRIVATE="" +LIBS_PRIVATE="" + +AC_SUBST(V_CCOPT) +AC_SUBST(V_DEFS) +AC_SUBST(V_INCLS) +AC_SUBST(LIBS_STATIC) +AC_SUBST(REQUIRES_PRIVATE) +AC_SUBST(LIBS_PRIVATE) + AC_CANONICAL_SYSTEM AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS) @@ -32,12 +112,46 @@ AC_PROG_CC_C99 if test "$ac_cv_prog_cc_c99" = "no"; then AC_MSG_ERROR([The C compiler does not support C99]) fi + +# +# Get the size of a void *, to determine whether this is a 32-bit +# or 64-bit build. +# +AC_CHECK_SIZEOF([void *]) +ac_lbl_c_sizeof_void_p="$ac_cv_sizeof_void_p" + +# +# We only need a C++ compiler for Haiku; all code except for its +# pcap module is in C. +# case "$host_os" in haiku*) - # - # Haiku's platform file is in C++. - # AC_PROG_CXX + + # + # Make sure C and C++ have the same pointer sizes with the flags + # they're given; if they don't, it means that the compilers for the + # languages will, with those flags, not produce code that can be + # linked together. + # + # We have to use different data types, because the results of + # a test are cached, so if we test for the size of a given type + # in C, the subsequent test in C++ will use the cached variable. + # We trick autoconf by testing the size of a "void *" in C and a + # "const void *" in C++. + # + AC_LANG_PUSH([C++]) + AC_CHECK_SIZEOF([const void *]) + ac_lbl_cxx_sizeof_void_p="$ac_cv_sizeof_const_void_p" + AC_LANG_POP([C++]) + if test "$ac_lbl_cxx_sizeof_void_p" -eq 0; then + AC_MSG_ERROR([No C++ compiler was found]) + fi + if test "$ac_lbl_c_sizeof_void_p" -ne "$ac_lbl_cxx_sizeof_void_p"; then + AC_MSG_ERROR([C compiler $CC produces code with $ac_lbl_c_sizeof_void_p-byte pointers +while C++ compiler $CXX produces code with $ac_lbl_cxx_sizeof_void_p-byte pointers. This prevents +code in those languages from being combined.]) + fi ;; esac @@ -63,38 +177,23 @@ dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris. dnl AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h) AC_CHECK_HEADERS(netpacket/packet.h) -AC_CHECK_HEADERS(net/pfvar.h, , , [#include -#include -#include ]) -if test "$ac_cv_header_net_pfvar_h" = yes; then - # - # Check for various PF actions. - # - AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR) - AC_TRY_COMPILE( - [#include - #include - #include - #include ], - [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;], - [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1, - [define if net/pfvar.h defines PF_NAT through PF_NORDR]) - ], - AC_MSG_RESULT(no)) -fi +AC_LBL_SAVE_CHECK_STATE case "$host_os" in haiku*) # # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them. # CFLAGS="$CFLAGS -D_BSD_SOURCE" + # + # Haiku has getpass in libbsd. + # + AC_CHECK_LIB(bsd, getpass) ;; esac AC_LBL_FIXINCLUDES +AC_LBL_RESTORE_CHECK_STATE AC_CHECK_FUNCS(strerror) AC_CHECK_FUNC(strerror_r, @@ -121,7 +220,7 @@ main(void) ) ], [ - # GNU-style + # GNU-style AC_MSG_RESULT(yes) AC_DEFINE(HAVE_GNU_STRERROR_R,, [Define to 1 if you have a GNU-style `strerror_r' function.]) @@ -437,7 +536,7 @@ if test "$ac_cv_func_ether_hostton" = yes; then # This test fails if we don't have # (if we have ether_hostton(), we should have # networking, and if we have networking, we should - # have ) or if we do but it doesn't + # have ) or if we do but it doesn't # declare ether_hostton(). # # Unset ac_cv_have_decl_ether_hostton so we don't @@ -572,7 +671,7 @@ AC_CHECK_HEADER(pthread.h, dnl to pacify those who hate protochain insn AC_MSG_CHECKING(if --disable-protochain option is specified) AC_ARG_ENABLE(protochain, -AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn])) +AS_HELP_STRING([--disable-protochain],[disable \"protochain\" insn])) case "x$enable_protochain" in xyes) enable_protochain=enabled ;; xno) enable_protochain=disabled ;; @@ -592,7 +691,7 @@ AC_MSG_RESULT(${enable_protochain}) VALGRINDTEST_SRC= AC_ARG_WITH(pcap, -AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE])) +AS_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE])) if test ! -z "$with_pcap" ; then V_PCAP="$withval" else @@ -684,9 +783,9 @@ else V_PCAP=linux VALGRINDTEST_SRC=valgrindtest.c elif test "$ac_cv_header_net_pfilt_h" = yes; then - # - # DEC OSF/1, Digital UNIX, Tru64 UNIX - # + # + # DEC OSF/1, Digital UNIX, Tru64 UNIX + # V_PCAP=pf elif test "$ac_cv_header_net_enet_h" = yes; then # @@ -724,7 +823,7 @@ else # V_PCAP=null AC_MSG_WARN(cannot determine packet capture interface) - AC_MSG_WARN((see the INSTALL doc for more info)) + AC_MSG_WARN((see the INSTALL.md file for more info)) fi fi AC_MSG_CHECKING(packet capture type) @@ -734,7 +833,69 @@ AC_SUBST(VALGRINDTEST_SRC) # # Do we have pkg-config? # -AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no]) +PKG_PROG_PKG_CONFIG + +# +# Do we have the brew command from Homebrew? +# +AC_PATH_PROG([BREW], [brew]) + +# +# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm +# looking at *you*!), there are separate include files for 32-bit and +# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer +# type on a 64-bit build is like crossing the beams or soething), and +# there are two separate .pc files, so if we're doing a 32-bit build we +# should make sure we look in /usr/lib/pkgconfig for .pc files and if +# we're doing a 64-bit build we should make sure we look in +# /usr/lib/amd64/pkgconfig for .pc files. +# +case "$host_os" in + +solaris*) + if test "$ac_cv_sizeof_void_p" -eq 8; then + # + # 64-bit build. If the path is empty, set it to + # /usr/lib/amd64/pkgconfig; otherwise, if + # /usr/lib/pkgconfig appears in the path, prepend + # /usr/lib/amd64/pkgconfig to it; otherwise, put + # /usr/lib/amd64/pkgconfig at the end. + # + if test -z "$PKG_CONFIG_PATH"; then + # + # Not set, or empty. Set it to + # /usr/lib/amd64/pkgconfig. + # + PKG_CONFIG_PATH=/usr/lib/amd64/pkgconfig + elif test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/pkgconfig"`; then + # + # It contains /usr/lib/pkgconfig. Prepend + # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig. + # + PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/pkgconfig;/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig;"` + else + # + # Not empty, but doesn't contain /usr/lib/pkgconfig. + # Append /usr/lib/amd64/pkgconfig to it. + # + PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/amd64/pkgconfig" + fi + export PKG_CONFIG_PATH + elif test "$ac_cv_sizeof_void_p" -eq 4; then + # + # 32-bit build. If /usr/amd64/lib/pkgconfig appears + # in the path, prepend /usr/lib/pkgconfig to it. + # + if test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/amd64/pkgconfig"`; then + # + # It contains /usr/lib/amd64/pkgconfig. Prepend + # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig. + # + PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/amd64/pkgconfig;/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig;"` + export PKG_CONFIG_PATH + fi + fi +esac # # Handle each capture type. @@ -762,6 +923,8 @@ dlpi) AC_CHECK_LIB(dlpi, dlpi_walk, [ LIBS="-ldlpi $LIBS" + LIBS_STATIC="-ldlpi $LIBS_STATIC" + LIBS_PRIVATE="-ldlpi $LIBS_PRIVATE" V_PCAP=libdlpi # @@ -819,14 +982,14 @@ enet) # # Capture module # - PLATFORM_C_SRC="pcap-enet.c" + PLATFORM_C_SRC="pcap-enet.c" ;; haiku) # # Capture module # - PLATFORM_CXX_SRC="pcap-haiku.cpp" + PLATFORM_CXX_SRC="pcap-haiku.cpp" # # Just for the sake of it. @@ -838,7 +1001,7 @@ linux) # # Capture module # - PLATFORM_C_SRC="pcap-linux.c" + PLATFORM_C_SRC="pcap-linux.c" # # Do we have the wireless extensions? @@ -860,28 +1023,22 @@ linux) # let's drop support for older versions of libnl, too. # AC_ARG_WITH(libnl, - AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=disabled@:>@]), + AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=disabled@:>@]), with_libnl=$withval,with_libnl=if_available) if test x$with_libnl = xyes ; then - if test "x$PKGCONFIG" != "xno"; then - # - # We have pkg-config; see if we have libnl-genl-3.0 - # as a package. - # - AC_MSG_CHECKING([for libnl-genl-3.0 with pkg-config]) - if "$PKGCONFIG" libnl-genl-3.0; then - AC_MSG_RESULT([found]) - pkg_config_found_libnl=yes - libnl_genl_cflags=`"$PKGCONFIG" --cflags libnl-genl-3.0` - V_INCLS="$V_INCLS ${libnl_genl_cflags}" - libnl_genl_libs=`"$PKGCONFIG" --libs libnl-genl-3.0` - LIBS="${libnl_genl_libs} $LIBS" - AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) - else - AC_MSG_RESULT([not found]) - fi - fi + # + # Check for libnl-genl-3.0 with pkg-config. + # + PKG_CHECK_MODULES(LIBNL, libnl-genl-3.0, + [ + pkg_config_found_libnl=yes + V_INCLS="$V_INCLS $LIBNL_CFLAGS" + ADDITIONAL_LIBS="$LIBNL_LIBS $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="$LIBNL_LIBS_STATIC $ADDITIONAL_LIBS_STATIC" + REQUIRES_PRIVATE="libnl-genl-3.0 $REQUIRES_PRIVATE" + AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) + ]) if test x$pkg_config_found_libnl != xyes; then # @@ -908,7 +1065,9 @@ linux) # # Yes, we have libnl 3.x. # - LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS" + ADDITIONAL_LIBS="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS_STATIC" + LIBS_PRIVATE="${libnldir} -lnl-genl-3 -lnl-3 $LIBS_PRIVATE" AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) V_INCLS="$V_INCLS ${incdir}" ],[ @@ -943,7 +1102,7 @@ bpf) # # Capture module # - PLATFORM_C_SRC="pcap-bpf.c" + PLATFORM_C_SRC="pcap-bpf.c" # # Check whether we have the *BSD-style ioctls. @@ -968,21 +1127,21 @@ pf) # # Capture module # - PLATFORM_C_SRC="pcap-pf.c" + PLATFORM_C_SRC="pcap-pf.c" ;; snit) # # Capture module # - PLATFORM_C_SRC="pcap-snit.c" + PLATFORM_C_SRC="pcap-snit.c" ;; snoop) # # Capture module # - PLATFORM_C_SRC="pcap-snoop.c" + PLATFORM_C_SRC="pcap-snoop.c" ;; dag) @@ -1029,7 +1188,7 @@ null) # # Capture module # - PLATFORM_C_SRC="pcap-null.c" + PLATFORM_C_SRC="pcap-null.c" ;; *) @@ -1125,7 +1284,7 @@ AC_CHECK_TYPES(socklen_t,,, ]) AC_ARG_ENABLE(ipv6, -AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]), +AS_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]), [], [enable_ipv6=yes]) if test "$enable_ipv6" != "no"; then @@ -1138,7 +1297,7 @@ fi # Check for Endace DAG card support. AC_ARG_WITH([dag], -AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), +AS_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), [ if test "$withval" = no then @@ -1171,7 +1330,7 @@ AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in ]) AC_ARG_WITH([dag-includes], -AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]), +AS_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]), [ # User wants DAG support and has specified a header directory, so use the provided value. want_dag=yes @@ -1179,7 +1338,7 @@ AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not ],[]) AC_ARG_WITH([dag-libraries], -AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]), +AS_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]), [ # User wants DAG support and has specified a library directory, so use the provided value. want_dag=yes @@ -1208,9 +1367,10 @@ if test "$want_dag" != no; then fi fi - save_CFLAGS="$CFLAGS" + AC_LBL_SAVE_CHECK_STATE CFLAGS="$CFLAGS -I$dag_include_dir" AC_CHECK_HEADERS([dagapi.h]) + AC_LBL_RESTORE_CHECK_STATE if test "$ac_cv_header_dagapi_h" = yes; then @@ -1223,42 +1383,52 @@ if test "$want_dag" != no; then # Check for various DAG API functions. # Don't need to save and restore LIBS to prevent -ldag being # included if there's a found-action (arg 3). - save_LDFLAGS="$LDFLAGS" + AC_LBL_SAVE_CHECK_STATE LDFLAGS="-L$dag_lib_dir" AC_CHECK_LIB([dag], [dag_attach_stream], - [], + [ + # + # We assume that if we have libdag we have + # libdagconf, as they're installed at the + # same time from the same package. + # + ADDITIONAL_LIBS="-L$dag_lib_dir $ADDITIONAL_LIBS -ldag -ldagconf" + ADDITIONAL_LIBS_STATIC="-L$dag_lib_dir $ADDITIONAL_LIBS_STATIC -ldag -ldagconf" + LIBS_PRIVATE="-L$dag_lib_dir $LIBS_PRIVATE -ldag -ldagconf" + ], [AC_MSG_ERROR(DAG library lacks streams support)]) AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"]) AC_CHECK_LIB([dag],[dag_get_erf_types], [ AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])]) AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [ AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])]) - - LDFLAGS="$save_LDFLAGS" + AC_LBL_RESTORE_CHECK_STATE # # We assume that if we have libdag we have libdagconf, # as they're installed at the same time from the same # package. # - LIBS="$LIBS -ldag -ldagconf" - LDFLAGS="$LDFLAGS -L$dag_lib_dir" - if test "$dag_large_streams" = 1; then AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API]) + AC_LBL_SAVE_CHECK_STATE + LIBS="$LIBS -ldag -ldagconf" + LDFLAGS="$LDFLAGS -L$dag_lib_dir" AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"]) + AC_LBL_RESTORE_CHECK_STATE if test "$ac_dag_have_vdag" = 1; then AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()]) if test "$ac_lbl_have_pthreads" != "found"; then AC_MSG_ERROR([DAG requires pthreads, but we didn't find them]) fi - LIBS="$LIBS $PTHREAD_LIBS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $PTHREAD_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $PTHREAD_LIBS" + LIBS_PRIVATE="$LIBS_PRIVATE $PTHREAD_LIBS" fi fi AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) else - if test "$V_PCAP" = dag; then # User requested "dag" capture type but we couldn't # find the DAG API support. @@ -1274,7 +1444,7 @@ if test "$want_dag" != no; then fi AC_ARG_WITH(septel, -AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), +AS_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), [ if test "$withval" = no then @@ -1351,7 +1521,7 @@ fi # Check for Myricom SNF support. AC_ARG_WITH([snf], -AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), +AS_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), [ if test "$withval" = no then @@ -1384,7 +1554,7 @@ AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in ]) AC_ARG_WITH([snf-includes], -AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]), +AS_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]), [ # User wants SNF with specific header directory want_snf=yes @@ -1392,7 +1562,7 @@ AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not ],[]) AC_ARG_WITH([snf-libraries], -AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]), +AS_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]), [ # User wants SNF with specific lib directory want_snf=yes @@ -1426,10 +1596,10 @@ if test "$with_snf" != no; then if test -f "$snf_include_dir/snf.h"; then # We found a header; make sure we can link with the library - save_LDFLAGS="$LDFLAGS" + AC_LBL_SAVE_CHECK_STATE LDFLAGS="$LDFLAGS -L$snf_lib_dir" AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"]) - LDFLAGS="$save_LDFLAGS" + AC_LBL_RESTORE_CHECK_STATE if test "$ac_cv_lbl_snf_api" = no; then AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log) fi @@ -1439,8 +1609,9 @@ if test "$with_snf" != no; then AC_MSG_RESULT([yes ($snf_root)]) V_INCLS="$V_INCLS -I$snf_include_dir" - LIBS="$LIBS -lsnf" - LDFLAGS="$LDFLAGS -L$snf_lib_dir" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS -L$snf_lib_dir -lsnf" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC -L$snf_lib_dir -lsnf" + LIBS_PRIVATE="$LIBS_PRIVATE -L$snf_lib_dir -lsnf" if test "$V_PCAP" != snf ; then MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c" @@ -1464,7 +1635,7 @@ fi # Check for Riverbed TurboCap support. AC_ARG_WITH([turbocap], -AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), +AS_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), [ if test "$withval" = no then @@ -1497,12 +1668,12 @@ if test "$want_turbocap" != no; then AC_MSG_CHECKING(whether TurboCap is supported) - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" + AC_LBL_SAVE_CHECK_STATE if test ! -z "$turbocap_root"; then TURBOCAP_CFLAGS="-I$turbocap_root/include" - TURBOCAP_LIBS="-L$turbocap_root/lib" + TURBOCAP_LDFLAGS="-L$turbocap_root/lib" CFLAGS="$CFLAGS $TURBOCAP_CFLAGS" + LDFLAGS="$LDFLAGS $TURBOCAP_LDFLAGS" fi AC_TRY_COMPILE( @@ -1516,13 +1687,15 @@ if test "$want_turbocap" != no; then ], ac_cv_lbl_turbocap_api=yes) - CFLAGS="$save_CFLAGS" + AC_LBL_RESTORE_CHECK_STATE if test $ac_cv_lbl_turbocap_api = yes; then AC_MSG_RESULT(yes) MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c" V_INCLS="$V_INCLS $TURBOCAP_CFLAGS" - LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" + LIBS_PRIVATE="$LIBS_PRIVATE $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API]) else @@ -1541,10 +1714,11 @@ dnl It's off by default, as that increases the attack surface of dnl libpcap, exposing it to malicious servers. dnl AC_MSG_CHECKING([whether to enable remote packet capture]) -AC_ARG_ENABLE(remote, -[ --enable-remote enable remote packet capture @<:@default=no@:>@ - --disable-remote disable remote packet capture],, - enableval=no) +AC_ARG_ENABLE([remote], + [AS_HELP_STRING([--enable-remote], + [enable remote packet capture @<:@default=no@:>@])], + [], + [enableval=no]) case "$enableval" in yes) AC_MSG_RESULT(yes) AC_WARN([Remote packet capture may expose libpcap-based applications]) @@ -1599,66 +1773,91 @@ yes) AC_MSG_RESULT(yes) # Optionally, we may want to support SSL. # Check for OpenSSL/libressl. # - # First, try looking for it as a regular system library. - # Make sure we can find SSL_library_init() using the - # standard headers, just in case we're running a version - # of macOS that ships with the OpenSSL library but not - # the OpenSSL headers, and have also installed another - # version of OpenSSL with headers. + # First, try looking for it with pkg-config, if we have it. # - save_LIBS="$LIBS" - LIBS="-lssl -lcrypto" - AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use) - AC_TRY_LINK( + # Homebrew's pkg-config does not, by default, look for + # pkg-config files for packages it has installed. + # Furthermore, at least for OpenSSL, they appear to be + # dumped in package-specific directories whose paths are + # not only package-specific but package-version-specific. + # + # So the only way to find openssl is to get the value of + # PKG_CONFIG_PATH from "brew --env openssl" and add that + # to PKG_CONFIG_PATH. (No, we can't just assume it's under + # /usr/local; Homebrew have conveniently chosen to put it + # under /opt/homebrew on ARM.) + # + # That's the nice thing about Homebrew - it makes things easier! + # Thanks! + # + save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" + if test -n "$BREW"; then + openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'` + PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH" + fi + PKG_CHECK_MODULES(OPENSSL, openssl, [ -#include - ], - [ -SSL_library_init(); -return 0; - ], - [ - AC_MSG_RESULT(yes) + # + # We found OpenSSL/libressl. + # HAVE_OPENSSL=yes - OPENSSL_LIBS="-lssl -lcrypto" - ], - AC_MSG_RESULT(no)) - LIBS="$save_LIBS" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE openssl" + ]) + PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH" # - # If we didn't find it, check for it with pkg-config. + # If it wasn't found, and we have Homebrew installed, see + # if it's in Homebrew. # - if test "x$HAVE_OPENSSL" != "xyes"; then - if test "x$PKGCONFIG" != "xno"; then + if test "x$HAVE_OPENSSL" != "xyes" -a -n "$BREW"; then + AC_MSG_CHECKING(for openssl in Homebrew) + # + # The brew man page lies when it speaks of + # $BREW --prefix --installed + # outputting nothing. In Homebrew 3.3.16, + # it produces output regardless of whether + # the formula is installed or not, so we + # send the standard output and error to + # the bit bucket. + # + if $BREW --prefix --installed openssl >/dev/null 2>&1; then # - # We have pkg-config; see if we have OpenSSL/ - # libressl installed as a package. + # Yes. Get the include directory and library + # directory. (No, we can't just assume it's + # under /usr/local; Homebrew have conveniently + # chosen to put it under /opt/homebrew on ARM.) # - AC_MSG_CHECKING([for OpenSSL/libressl with pkg-config]) - if "$PKGCONFIG" openssl; then - AC_MSG_RESULT([found]) - HAVE_OPENSSL=yes - OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl` - OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl` - else - AC_MSG_RESULT([not found]) - fi + AC_MSG_RESULT(yes) + HAVE_OPENSSL=yes + openssl_path=`$BREW --prefix openssl` + OPENSSL_CFLAGS="-I$openssl_path/include" + OPENSSL_LIBS="-L$openssl_path/lib -lssl -lcrypto" + OPENSSL_LIBS_STATIC="-L$openssl_path/lib -lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-L$openssl_path/lib -lssl -lcrypto" + else + AC_MSG_RESULT(no) fi fi # - # If we didn't find it, check for it under /usr/local/opt/openssl; - # that's where Homebrew puts it on macOS. Feel free to add other - # -L directories as necessary; the "system library" check should - # also handle "add-on library under /usr/local", so that shouldn't - # be necessary here. + # If it wasn't found, and /usr/local/include and /usr/local/lib + # exist, check if it's in /usr/local. (We check whether they + # exist because, if they don't exist, the compiler will warn + # about that and then ignore the argument, so they test + # using just the system header files and libraries.) # - if test "x$HAVE_OPENSSL" != "xyes"; then - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS -L/usr/local/opt/openssl/include" - LIBS="$LIBS -L/usr/local/opt/openssl/lib -lssl -lcrypto" - AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local/opt that we can use) + # We include the standard include file to 1) make sure that + # it's installed (if it's just a shared library for the + # benefit of existing programs, that's not useful) and 2) + # because SSL_library_init() is a library routine in some + # versions and a #defined wrapper around OPENSSL_init_ssl() + # in others. + # + if test "x$HAVE_OPENSSL" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then + AC_LBL_SAVE_CHECK_STATE + CFLAGS="$CFLAGS -I/usr/local/include" + LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto" + AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local that we can use) AC_TRY_LINK( [ #include @@ -1670,12 +1869,46 @@ return 0; [ AC_MSG_RESULT(yes) HAVE_OPENSSL=yes - OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include" - OPENSSL_LIBS="-L/usr/local/opt/openssl/lib -lssl -lcrypto" + OPENSSL_CFLAGS="-I/usr/local/include" + OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto" + OPENSSL_LIBS_STATIC="-L/usr/local/lib -lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-L/usr/local/lib -lssl -lcrypto" ], AC_MSG_RESULT(no)) - CFLAGS="$save_CFLAGS" - LIBS="$save_LIBS" + AC_LBL_RESTORE_CHECK_STATE + fi + + # + # If it wasn't found, check if it's a system library. + # + # We include the standard include file to 1) make sure that + # it's installed (if it's just a shared library for the + # benefit of existing programs, that's not useful) and 2) + # because SSL_library_init() is a library routine in some + # versions and a #defined wrapper around OPENSSL_init_ssl() + # in others. + # + if test "x$HAVE_OPENSSL" != "xyes"; then + AC_LBL_SAVE_CHECK_STATE + LIBS="$LIBS -lssl -lcrypto" + AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use) + AC_TRY_LINK( + [ +#include + ], + [ +SSL_library_init(); +return 0; + ], + [ + AC_MSG_RESULT(yes) + HAVE_OPENSSL=yes + OPENSSL_LIBS="-lssl -lcrypto" + OPENSSL_LIBS_STATIC="-lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-lssl -lcrypto" + ], + AC_MSG_RESULT(no)) + AC_LBL_RESTORE_CHECK_STATE fi # @@ -1683,8 +1916,11 @@ return 0; # if test "x$HAVE_OPENSSL" = "xyes"; then AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL]) - CFLAGS="$CFLAGS $OPENSSL_CFLAGS" - LIBS="$LIBS $OPENSSL_LIBS" + V_INCLS="$V_INCLS $OPENSSL_CFLAGS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $OPENSSL_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $OPENSSL_LIBS_STATIC" + LIBS_PRIVATE="$LIBS_PRIVATE $OPENSSL_LIBS_PRIVATE" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE $OPENSSL_REQUIRES_PRIVATE" else AC_MSG_NOTICE(OpenSSL not found) fi @@ -1701,7 +1937,7 @@ esac AC_MSG_CHECKING(whether to build optimizer debugging code) AC_ARG_ENABLE(optimizer-dbg, -AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code])) +AS_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code])) if test "$enable_optimizer_dbg" = "yes"; then AC_DEFINE(BDEBUG,1,[Enable optimizer debugging]) fi @@ -1709,7 +1945,7 @@ AC_MSG_RESULT(${enable_optimizer_dbg-no}) AC_MSG_CHECKING(whether to build parser debugging code) AC_ARG_ENABLE(yydebug, -AC_HELP_STRING([--enable-yydebug],[build parser debugging code])) +AS_HELP_STRING([--enable-yydebug],[build parser debugging code])) if test "$enable_yydebug" = "yes"; then AC_DEFINE(YYDEBUG,1,[Enable parser debugging]) fi @@ -1776,7 +2012,7 @@ darwin*) DYEXT="dylib" V_CCOPT="$V_CCOPT -fno-common" AC_ARG_ENABLE(universal, - AC_HELP_STRING([--disable-universal],[don't build universal on macOS])) + AS_HELP_STRING([--disable-universal],[don't build universal on macOS])) if test "$enable_universal" != "no"; then case "$host_os" in @@ -1806,7 +2042,7 @@ darwin*) V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64" ;; - darwin8.[[456]]|darwin.[[456]].*) + darwin8.[[456]]|darwin8.[[456]].*) # # Tiger, subsequent to Intel support but prior # to x86-64 support. Build libraries and @@ -1871,25 +2107,21 @@ darwin*) V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386" ;; - darwin*) + darwin1[[1-8]]*) # - # Post-Snow Leopard. Build libraries for x86-64 - # and 32-bit x86, with x86-64 first, and build - # executables only for x86-64. (That's what - # Apple does.) This requires no special flags - # for programs. - # XXX - update if and when Apple drops support - # for 32-bit x86 code and if and when Apple adds - # ARM-based Macs. (You're on your own for iOS - # etc.) + # Post-Snow Leopard, pre-Catalina. Build + # libraries for x86-64 and 32-bit x86, with + # x86-64 first, and build executables only for + # x86-64. (That's what Apple does.) This + # requires no special flags for programs. # - # XXX - check whether we *can* build for - # i386 and, if not, suggest that the user - # install the /usr/include headers if they - # want to build fat. + # We check whether we *can* build for i386 and, + # if not, suggest that the user install the + # /usr/include headers if they want to build + # fat. # AC_MSG_CHECKING(whether building for 32-bit x86 is supported) - save_CFLAGS="$CFLAGS" + AC_LBL_SAVE_CHECK_STATE CFLAGS="$CFLAGS -arch i386" AC_TRY_LINK( [], @@ -1936,7 +2168,67 @@ darwin*) ;; esac ]) - CFLAGS="$save_CFLAGS" + AC_LBL_RESTORE_CHECK_STATE + ;; + + darwin19*) + # + # Catalina. Build libraries and executables + # only for x86-64. (That's what Apple does; + # 32-bit x86 binaries are not supported on + # Catalina.) + # + V_LIB_CCOPT_FAT="-arch x86_64" + V_LIB_LDFLAGS_FAT="-arch x86_64" + V_PROG_CCOPT_FAT="-arch x86_64" + V_PROG_LDFLAGS_FAT="-arch x86_64" + ;; + + darwin*) + # + # Post-Catalina. Build libraries and + # executables for x86-64 and ARM64. + # (That's what Apple does, except they + # build for arm64e, which may include + # some of the pointer-checking extensions.) + # + # If we're building with libssl, make sure + # we can build fat with it (i.e., that it + # was built fat); if we can't, don't set + # the target architectures, and just + # build for the host we're on. + # + # Otherwise, just add both of them. + # + if test "$HAVE_OPENSSL" = yes; then + AC_MSG_CHECKING(whether building fat with libssl is supported) + AC_LBL_SAVE_CHECK_STATE + CFLAGS="$CFLAGS -arch x86_64 -arch arm64" + LDFLAGS="$LDFLAGS $OPENSSL_LIBS" + AC_TRY_LINK( + [ + #include + ], + [ + SSL_library_init(); + return 0; + ], + [ + AC_MSG_RESULT(yes) + V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64" + V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64" + V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64" + V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64" + ], + [AC_MSG_RESULT(no)] + ) + AC_LBL_RESTORE_CHECK_STATE + else + V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64" + V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64" + V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64" + V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64" + fi ;; esac fi @@ -2012,21 +2304,13 @@ irix*) linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*) DYEXT="so" - - # - # Compiler assumed to be GCC; run-time linker may require a -R - # flag. - # - if test "$libdir" != "/usr/lib"; then - V_RFLAGS=-Wl,-R$libdir - fi ;; osf*) DYEXT="so" # - # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX. + # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX. # Use Tru64 UNIX conventions for man pages; they're the same as # the System V conventions except that they use section 8 for # administrative commands and daemons. @@ -2081,9 +2365,18 @@ solaris*) esac ;; esac +AC_SUBST(V_LIB_CCOPT_FAT) +AC_SUBST(V_LIB_LDFLAGS_FAT) +AC_SUBST(V_PROG_CCOPT_FAT) +AC_SUBST(V_PROG_LDFLAGS_FAT) +AC_SUBST(DYEXT) +AC_SUBST(MAN_DEVICES) +AC_SUBST(MAN_FILE_FORMATS) +AC_SUBST(MAN_MISC_INFO) +AC_SUBST(MAN_ADMIN_COMMANDS) AC_ARG_ENABLE(shared, -AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=no@:>@])) +AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=no@:>@])) test "x$enable_shared" != "xyes" && DYEXT="none" AC_PROG_RANLIB @@ -2130,40 +2423,11 @@ AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,, #include ]) -AC_SUBST(V_CCOPT) -AC_SUBST(V_LIB_CCOPT_FAT) -AC_SUBST(V_LIB_LDFLAGS_FAT) -AC_SUBST(V_PROG_CCOPT_FAT) -AC_SUBST(V_PROG_LDFLAGS_FAT) -AC_SUBST(V_DEFS) -AC_SUBST(V_INCLS) -AC_SUBST(V_SHLIB_CCOPT) -AC_SUBST(V_SHLIB_CMD) -AC_SUBST(V_SHLIB_OPT) -AC_SUBST(V_SONAME_OPT) -AC_SUBST(V_RPATH_OPT) -AC_SUBST(ADDLOBJS) -AC_SUBST(ADDLARCHIVEOBJS) -AC_SUBST(PLATFORM_C_SRC) -AC_SUBST(PLATFORM_CXX_SRC) -AC_SUBST(MODULE_C_SRC) -AC_SUBST(REMOTE_C_SRC) -AC_SUBST(DYEXT) -AC_SUBST(MAN_DEVICES) -AC_SUBST(MAN_FILE_FORMATS) -AC_SUBST(MAN_MISC_INFO) -AC_SUBST(MAN_ADMIN_COMMANDS) -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(BUILD_RPCAPD) -AC_SUBST(INSTALL_RPCAPD) -AC_SUBST(RPCAPD_LIBS) -AC_SUBST(EXTRA_NETWORK_LIBS) - # # Various Linux-specific mechanisms. # AC_ARG_ENABLE([usb], -[AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=no@:>@])], +[AS_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=no@:>@])], [], [enable_usb=no]) @@ -2180,12 +2444,17 @@ if test "xxx_only" != yes; then AC_DEFINE(PCAP_SUPPORT_LINUX_USBMON, 1, [target host supports Linux usbmon for USB sniffing]) MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c" AC_MSG_RESULT(yes) - ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null` - if test $? -ne 0 ; then - ac_usb_dev_name="usbmon" - fi - AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing]) - AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name) + # + # Note: if the directory for special files is *EVER* somewhere + # other than the UN*X standard of /dev (which will break any + # software that looks for /dev/null or /dev/tty, for example, + # so doing that is *REALLY* not a good idea), please provide + # some mechanism to determine that directory at *run time*, + # rather than *configure time*, so that it works when doinga + # a cross-build, and that works with *multiple* distributions, + # with our without udev, and with multiple versions of udev, + # with udevinfo or udevadm or any other mechanism to get the + # special files directory. # # Do we have a version of available? # If so, we might need it for . @@ -2256,7 +2525,7 @@ AC_SUBST(PCAP_SUPPORT_LINUX_USBMON) AC_SUBST(PCAP_SUPPORT_NETFILTER) AC_ARG_ENABLE([netmap], -[AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])], +[AS_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])], [], [enable_netmap=yes]) @@ -2287,7 +2556,7 @@ fi # Check for DPDK support. AC_ARG_WITH([dpdk], -AC_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), +AS_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]), [ if test "$withval" = no then @@ -2321,211 +2590,177 @@ AC_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in direc ]) if test "$want_dpdk" != no; then - if test "x$PKGCONFIG" != "xno" - then - # - # We have pkg-config; see if we have DPDK installed - # as a package. - # - AC_MSG_CHECKING([for DPDK with pkg-config]) - if "$PKGCONFIG" libdpdk - then - AC_MSG_RESULT([found]) - found_dpdk_with_pkg_config=yes - DPDK_CFLAGS=`"$PKGCONFIG" --cflags libdpdk` - DPDK_LDFLAGS=`"$PKGCONFIG" --libs libdpdk` - else - AC_MSG_RESULT([not found]) - fi + # + # The user didn't explicitly say they don't want DPDK, + # so see if we have it. + # + # We only try to find it using pkg-config; DPDK is *SO* + # complicated - DPDK 19.02, for example, has about 117(!) + # libraries, and the precise set of libraries required has + # changed over time - so attempting to guess which libraries + # you need, and hardcoding that in an attempt to find the + # libraries without DPDK, rather than relying on DPDK to + # tell you, with a .pc file, what libraries are needed, + # is *EXTREMELY* fragile and has caused some bug reports, + # so we're just not going to do it. + # + # If that causes a problem, the only thing we will do is + # accept an alternative way of finding the appropriate + # library set for the installed version of DPDK that is + # as robust as pkg-config (i.e., it had better work as well + # as pkg-config with *ALL* versions of DPDK that provide a + # libdpdk.pc file). + # + # If --with-dpdk={path} was specified, add {path}/pkgconfig + # to PKG_CONFIG_PATH, so we look for the .pc file there, + # first. + # + save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" + if test -n "$dpdk_dir"; then + PKG_CONFIG_PATH="$dpdk_dir:$PKG_CONFIG_PATH" fi + PKG_CHECK_MODULES(DPDK, libdpdk, + [ + found_dpdk=yes + ]) + PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH" # - # If we didn't find it with pkg-config, try checking for - # it manually. + # Did we find DPDK? # - if test "x$found_dpdk_with_pkg_config" != "xyes" - then - if test -z "$dpdk_dir"; then - # - # The user didn't specify a directory containing - # the DPDK headers and libraries. If we find - # a /usr/local/include/dpdk directory, assume - # it's /usr/local, otherwise assume it's /usr. - # - if test -d "/usr/local/include/dpdk"; then - dpdk_dir="/usr/local" - else - dpdk_dir="/usr" - fi - fi + if test "$found_dpdk" = yes; then # - # The convention appears to be that 1) there's a "dpdk" - # subdirectory of the include directory, containing DPDK - # headers (at least in the installation on Ubuntu with - # the system DPDK packages) and 2) includes of DPDK - # headers don't use "dpdk/{header}" (at least from the - # way the DPDK documentation is written). + # Found it. # - # So we add "/dpdk" to the include directory, and always - # add that to the list of include directories to search. + # We call rte_eth_dev_count_avail(), and older versions + # of DPDK didn't have it, so check for it. # - dpdk_inc_dir="$dpdk_dir/include/dpdk" - dpdk_inc_flags="-I$dpdk_inc_dir" - dpdk_lib_dir="$dpdk_dir/lib" - # - # Handle multiarch systems. - # - # Step 1: run the C compiler with the -dumpmachine option; - # if it succeeds, the output would be the multiarch directory - # name if your system has multiarch directories. - # - multiarch_dir=`$CC -dumpmachine 2>/dev/null` - if test ! -z "$multiarch_dir" - then - # - # OK, we have a multiarch directory. - # - # Now deal with includes. On Ubuntu 20.04, for - # example, we have /usr/include/dpdk *and* - # /usr/include/$multiarch_dir/dpdk, and must - # search both. - # - if test -d "$dpdk_dir/include/$multiarch_dir/dpdk" - then - dpdk_inc_flags="-I$dpdk_dir/include/$multiarch_dir/dpdk $dpdk_inc_flags" - fi - - # - # Now deal with libraries. - # - if test -d "$dpdk_lib_dir/$multiarch_dir" - then - dpdk_lib_dir="$dpdk_lib_dir/$multiarch_dir" - fi - fi - DPDK_MACHINE_CFLAGS="-march=native" - DPDK_CFLAGS="$DPDK_MACHINE_CFLAGS $dpdk_inc_flags" - DPDK_LDFLAGS="-L$dpdk_lib_dir -ldpdk -lrt -lm -lnuma -ldl -pthread" - fi - - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - save_LDFLAGS="$LDFLAGS" - CFLAGS="$CFLAGS $DPDK_CFLAGS" - LIBS="$LIBS $DPDK_LDFLAGS" - LDFLAGS="$LDFLAGS $DPDK_LDFLAGS" - - AC_MSG_CHECKING(whether we can compile the DPDK support) - AC_CACHE_VAL(ac_cv_dpdk_can_compile, - AC_TRY_COMPILE([ -AC_INCLUDES_DEFAULT -#include ], - [], - ac_cv_dpdk_can_compile=yes, - ac_cv_dpdk_can_compile=no)) - AC_MSG_RESULT($ac_cv_dpdk_can_compile) - - # - # We include rte_bus.h, and older versions of DPDK - # didn't have it, so check for it. - # - if test "$ac_cv_dpdk_can_compile" = yes; then - # - # This runs the preprocessor, so make sure it - # looks in the DPDK directories. Instead of - # including dpdk/XXX.h, we include just XXX.h - # and assume DPDK_CFLAGS is the directory - # containing the DPDK headers (that's how - # pkg-config sets it, at least on Ubuntu), - # so just looking under /usr/include won't - # find it. - # - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $DPDK_CFLAGS" - AC_CHECK_HEADER(rte_bus.h) - CPPFLAGS="$save_CPPFLAGS" - fi - - # - # We call rte_eth_dev_count_avail(), and older versions - # of DPDK didn't have it, so check for it. - # - if test "$ac_cv_header_rte_bus_h" = yes; then + AC_LBL_SAVE_CHECK_STATE + CFLAGS="$CFLAGS $DPDK_CFLAGS" + LIBS="$LIBS $DPDK_LIBS" AC_CHECK_FUNC(rte_eth_dev_count_avail) + AC_LBL_RESTORE_CHECK_STATE fi - CFLAGS="$save_CFLAGS" - LIBS="$save_LIBS" - LDFLAGS="$save_LDFLAGS" - if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then - CFLAGS="$CFLAGS $DPDK_CFLAGS" - LIBS="$LIBS $DPDK_LDFLAGS" - LDFLAGS="$LDFLAGS $DPDK_LDFLAGS" - V_INCLS="$V_INCLS $DPDK_CFLAGS" - AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK]) - if test $V_PCAP != dpdk ; then - MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c" - fi - + # + # We found a usable DPDK. # # Check whether the rte_ether.h file defines # struct ether_addr or struct rte_ether_addr. # # ("API compatibility? That's for losers!") # + AC_LBL_SAVE_CHECK_STATE + CFLAGS="$CFLAGS $DPDK_CFLAGS" + LIBS="$LIBS $DPDK_LIBS" AC_CHECK_TYPES(struct rte_ether_addr,,, [ #include ]) - else - if test "$V_PCAP" = dpdk; then - # User requested DPDK-only capture support, but - # we couldn't the DPDK API support at all, or we - # found it but it wasn't a sufficiently recent - # version. - if test "$ac_cv_dpdk_can_compile" != yes; then - # - # Couldn't even find the headers. - # - AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support]) - else - # - # Found the headers, but we couldn't find - # rte_bus.h or rte_eth_dev_count_avail(), - # we don't have a sufficiently recent - # version of DPDK. - # - AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later; install a newer version of DPDK, or don't request DPDK support]) - fi - fi + AC_LBL_RESTORE_CHECK_STATE - if test "$want_dpdk" = yes; then - # User requested DPDK-only capture support, but - # we couldn't the DPDK API support at all, or we - # found it but it wasn't a sufficiently recent - # version. - if test "$ac_cv_dpdk_can_compile" != yes; then + # + # We can build with DPDK. + # + V_INCLS="$V_INCLS $DPDK_CFLAGS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DPDK_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DPDK_LIBS_STATIC" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE libdpdk" + AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK]) + if test $V_PCAP != dpdk ; then + MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c" + fi + else + # + # We didn't find a usable DPDK. + # If we required it (with --with-dpdk or --with-pcap=dpdk), + # fail with an appropriate message telling the user what + # the problem was, otherwise note the problem with a + # warning. + # + if test "$found_dpdk" != yes; then + # + # Not found with pkg-config. Note that we + # require that DPDK must be findable with + # pkg-config. + # + if test "$V_PCAP" = dpdk; then # - # Couldn't even find the headers. + # User requested DPDK-only capture support. # - AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support]) - else - # - # Found the headers, but we couldn't find - # rte_bus.h or rte_eth_dev_count_avail(), - # we don't have a sufficiently recent - # version of DPDK. - # - AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later: install a newer version of DPDK, or don't request DPDK support]) + AC_MSG_ERROR( +[DPDK support requested with --with-pcap=dpdk, but +we couldn't find DPDK with pkg-config. Make sure that pkg-config is +installed, that DPDK 18.02.2 or later is installed, and that DPDK +provides a .pc file.]) fi + + if test "$want_dpdk" = yes; then + # + # User requested that libpcap include + # DPDK capture support. + # + AC_MSG_ERROR( +[DPDK support requested with --with-dpdk, but we +couldn't find DPDK with pkg-config. Make sure that pkg-config +is installed, that DPDK 18.02.2 or later is installed, and that +DPDK provides .pc file.]) + fi + + # + # User didn't indicate whether they wanted DPDK + # or not; just warn why we didn't find it. + # + AC_MSG_WARN( +[We couldn't find DPDK with pkg-config. If +you want DPDK support, make sure that pkg-config is installed, +that DPDK 18.02.2 or later is installed, and that DPDK provides a +.pc file.]) + elif test "$ac_cv_func_rte_eth_dev_count_avail" != yes; then + # + # Found with pkg-config, but we couldn't compile + # a program that calls rte_eth_dev_count(); we + # probably have the developer package installed, + # but don't have a sufficiently recent version + # of DPDK. Note that we need a sufficiently + # recent version of DPDK. + # + if test "$V_PCAP" = dpdk; then + # + # User requested DPDK-only capture support. + # + AC_MSG_ERROR( +[DPDK support requested with --with-pcap=dpdk, but we +can't compile libpcap with DPDK. Make sure that DPDK 18.02.2 or later +is installed.]) + fi + + if test "$want_dpdk" = yes; then + # + # User requested that libpcap include + # DPDK capture support. + # + AC_MSG_ERROR( +[DPDK support requested with --with-dpdk, but +we can't compile libpcap with DPDK. Make sure that DPDK 18.02.2 +or later is DPDK is installed.]) + fi + + # + # User didn't indicate whether they wanted DPDK + # or not; just warn why we didn't find it. + # + AC_MSG_WARN( +[DPDK was found, but we can't compile libpcap with it. +Make sure that DPDK 18.02.2 or later is installed.]) fi fi fi AC_SUBST(PCAP_SUPPORT_DPDK) AC_ARG_ENABLE([bluetooth], -[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=no@:>@])], +[AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=no@:>@])], [], [enable_bluetooth=no]) @@ -2608,7 +2843,7 @@ if test "x$enable_bluetooth" != "xno" ; then fi AC_ARG_ENABLE([dbus], -[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=no@:>@])], +[AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=no@:>@])], [], [enable_dbus=no]) @@ -2651,51 +2886,47 @@ if test "x$enable_dbus" != "xno"; then fi if test "x$enable_dbus" != "xno"; then - if test "x$PKGCONFIG" != "xno"; then - AC_MSG_CHECKING([for D-Bus]) - if "$PKGCONFIG" dbus-1; then + PKG_CHECK_MODULES(DBUS, dbus-1, + [ + AC_LBL_SAVE_CHECK_STATE + CFLAGS="$CFLAGS $DBUS_CFLAGS" + LIBS="$LIBS $DBUS_LIBS" + AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write) + AC_TRY_LINK( + [#include + + #include + #include + + #include ], + [return dbus_connection_read_write(NULL, 0);], + [ AC_MSG_RESULT([yes]) - DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1` - DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1` - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS $DBUS_CFLAGS" - LIBS="$LIBS $DBUS_LIBS" - AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write) - AC_TRY_LINK( - [#include - - #include - #include - - #include ], - [return dbus_connection_read_write(NULL, 0);], - [ - AC_MSG_RESULT([yes]) - AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing]) - MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c" - V_INCLS="$V_INCLS $DBUS_CFLAGS" - ], - [ - AC_MSG_RESULT([no]) - if test "x$enable_dbus" = "xyes"; then - AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()]) - fi - LIBS="$save_LIBS" - ]) - CFLAGS="$save_CFLAGS" - else + AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing]) + MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c" + V_INCLS="$V_INCLS $DBUS_CFLAGS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DBUS_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DBUS_LIBS_STATIC" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE dbus-1" + ], + [ AC_MSG_RESULT([no]) if test "x$enable_dbus" = "xyes"; then - AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed]) + AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()]) fi + ]) + AC_LBL_RESTORE_CHECK_STATE + ], + [ + if test "x$enable_dbus" = "xyes"; then + AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed]) fi - fi + ]) AC_SUBST(PCAP_SUPPORT_DBUS) fi AC_ARG_ENABLE([rdma], -[AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])], +[AS_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])], [], [enable_rdma=ifavailable]) @@ -2706,7 +2937,33 @@ if test "xxx_only" = yes; then fi if test "x$enable_rdma" != "xno"; then - AC_CHECK_LIB(ibverbs, ibv_get_device_list, [ + PKG_CHECK_MODULES(LIBIBVERBS, libibverbs, + [ + found_libibverbs=yes + LIBIBVERBS_REQUIRES_PRIVATE="libibverbs" + ]) + + if test "x$found_libibverbs" != "xyes"; then + AC_CHECK_LIB(ibverbs, ibv_get_device_list, + [ + found_libibverbs=yes + LIBIBVERBS_CFLAGS="" + LIBIBVERBS_LIBS="-libverbs" + # XXX - at least on Ubuntu 20.04, there are many more + # libraries needed; is there any platform where + # libibverbs is available but where pkg-config isn't + # available or libibverbs doesn't use it? If not, + # we should only use pkg-config for it. + LIBIBVERBS_LIBS_STATIC="-libverbs" + LIBIBVERBS_LIBS_PRIVATE="-libverbs" + ] + ) + fi + + if test "x$found_libibverbs" = "xyes"; then + AC_LBL_SAVE_CHECK_STATE + CFLAGS="$CFLAGS $LIBIBVERBS_CFLAGS" + LIBS="$LIBS $LIBIBVERBS_LIBS" AC_CHECK_HEADER(infiniband/verbs.h, [ # # ibv_create_flow may be defined as a static inline @@ -2730,27 +2987,115 @@ if test "x$enable_rdma" != "xno"; then ], [ AC_MSG_RESULT([yes]) - AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing]) - MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c" - LIBS="-libverbs $LIBS" + found_usable_libibverbs=yes ], [ AC_MSG_RESULT([no]) ] ) ]) - ]) + AC_LBL_RESTORE_CHECK_STATE + fi + + if test "x$found_usable_libibverbs" = "xyes" + then + AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing]) + MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c" + CFLAGS="$LIBIBVERBS_CFLAGS $CFLAGS" + ADDITIONAL_LIBS="$LIBIBVERBS_LIBS $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="$LIBIBVERBS_LIBS_STATIC $ADDITIONAL_LIBS_STATIC" + LIBS_PRIVATE="$LIBIBVERBS_LIBS_PRIVATE $LIBS_PRIVATE" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE $LIBIBVERBS_REQUIRES_PRIVATE" + fi AC_SUBST(PCAP_SUPPORT_RDMASNIFF) fi +# +# If this is a platform where we need to have the .pc file and +# pcap-config script supply an rpath option to specify the directory +# in which the libpcap shared library is installed, and the install +# prefix /usr (meaning we're not installing a system library), provide +# the rpath option. +# +# (We must check $prefix, as $libdir isn't necessarily /usr/lib in this +# case - for example, Linux distributions for 64-bit platforms that +# also provide support for binaries for a 32-bit version of the +# platform may put the 64-bit libraries, the 32-bit libraries, or both +# in directories other than /usr/lib.) +# +# In AIX, do we have to do this? +# +# In Darwin-based OSes, the full paths of the shared libraries with +# which the program was linked are stored in the executable, so we don't +# need to provide an rpath option. +# +# With the HP-UX linker, directories specified with -L are, by default, +# added to the run-time search path, so we don't need to supply them. +# +# For Tru64 UNIX, "-rpath" works with DEC's^WCompaq's^WHP's C compiler +# for Alpha, but isn't documented as working with GCC, and no GCC- +# compatible option is documented as working with the DEC compiler. +# If anybody needs this on Tru64/Alpha, they're welcome to figure out a +# way to make it work. +# +# This must *not* depend on the compiler, as, on platforms where there's +# a GCC-compatible compiler and a vendor compiler, we need to work with +# both. +# +if test "$prefix" != "/usr"; then + case "$host_os" in + + freebsd*|netbsd*|openbsd*|dragonfly*|linux*|haiku*|midipix*|gnu*) + # + # Platforms where the "native" C compiler is GCC or + # accepts compatible command-line arguments, and the + # "native" linker is the GNU linker or accepts + # compatible command-line arguments. + # + RPATH="-Wl,-rpath,\${libdir}" + ;; + + solaris*) + # + # Sun/Oracle's linker, the GNU linker, and + # GNU-compatible linkers all support -R. + # + RPATH="-Wl,-R,\${libdir}" + ;; + esac +fi + AC_PROG_INSTALL AC_CONFIG_HEADER(config.h) +AC_SUBST(V_SHLIB_CCOPT) +AC_SUBST(V_SHLIB_CMD) +AC_SUBST(V_SHLIB_OPT) +AC_SUBST(V_SONAME_OPT) +AC_SUBST(RPATH) +AC_SUBST(ADDLOBJS) +AC_SUBST(ADDLARCHIVEOBJS) +AC_SUBST(PLATFORM_C_SRC) +AC_SUBST(PLATFORM_CXX_SRC) +AC_SUBST(MODULE_C_SRC) +AC_SUBST(REMOTE_C_SRC) +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(BUILD_RPCAPD) +AC_SUBST(INSTALL_RPCAPD) +AC_SUBST(RPCAPD_LIBS) + +# +# We're done with configuration operations; add ADDITIONAL_LIBS and +# ADDITIONAL_LIBS_STATIC to LIBS and LIBS_STATIC, respectively. +# +LIBS="$ADDITIONAL_LIBS $LIBS" +LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $LIBS_STATIC" + AC_OUTPUT_COMMANDS([if test -f .devel; then echo timestamp > stamp-h cat $srcdir/Makefile-devel-adds >> Makefile - make depend + make depend || exit 1 fi]) AC_OUTPUT(Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap diff --git a/libpcap/diag-control.h b/libpcap/diag-control.h index 47d31b982..ae2641b45 100644 --- a/libpcap/diag-control.h +++ b/libpcap/diag-control.h @@ -37,12 +37,12 @@ #include "pcap/compiler-tests.h" -#ifndef _MSC_VER +#if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) || PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) /* * Clang and GCC both support this way of putting pragmas into #defines. - * We don't use it unless we have a compiler that supports it; the - * warning-suppressing pragmas differ between Clang and GCC, so we test - * for both of those separately. + * We use it only if we have a compiler that supports it; see below + * for the code that uses it and the #defines that control whether + * that code is used. */ #define PCAP_DO_PRAGMA(x) _Pragma (#x) #endif @@ -86,7 +86,51 @@ /* * Suppress Flex, narrowing, and deprecation warnings. */ -#if defined(_MSC_VER) +#if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) + /* + * This is Clang 2.8 or later; we can use "clang diagnostic + * ignored -Wxxx" and "clang diagnostic push/pop". + * + * Suppress -Wdocumentation warnings; GCC doesn't support -Wdocumentation, + * at least according to the GCC 7.3 documentation. Apparently, Flex + * generates code that upsets at least some versions of Clang's + * -Wdocumentation. + * + * (This could be clang-cl, which defines _MSC_VER, so test this + * before testing _MSC_VER.) + */ + #define DIAG_OFF_FLEX \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wsign-compare") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdocumentation") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wmissing-noreturn") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunused-parameter") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_FLEX \ + PCAP_DO_PRAGMA(clang diagnostic pop) + + /* + * Suppress the only narrowing warnings you get from Clang. + */ + #define DIAG_OFF_NARROWING \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32") + + #define DIAG_ON_NARROWING \ + PCAP_DO_PRAGMA(clang diagnostic pop) + + /* + * Suppress deprecation warnings. + */ + #define DIAG_OFF_DEPRECATION \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations") + #define DIAG_ON_DEPRECATION \ + PCAP_DO_PRAGMA(clang diagnostic pop) + #define DIAG_OFF_FORMAT_TRUNCATION + #define DIAG_ON_FORMAT_TRUNCATION +#elif defined(_MSC_VER) /* * This is Microsoft Visual Studio; we can use __pragma(warning(disable:XXXX)) * and __pragma(warning(push/pop)). @@ -121,45 +165,8 @@ __pragma(warning(disable:4996)) #define DIAG_ON_DEPRECATION \ __pragma(warning(pop)) -#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) - /* - * This is Clang 2.8 or later; we can use "clang diagnostic - * ignored -Wxxx" and "clang diagnostic push/pop". - * - * Suppress -Wdocumentation warnings; GCC doesn't support -Wdocumentation, - * at least according to the GCC 7.3 documentation. Apparently, Flex - * generates code that upsets at least some versions of Clang's - * -Wdocumentation. - */ - #define DIAG_OFF_FLEX \ - PCAP_DO_PRAGMA(clang diagnostic push) \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wsign-compare") \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdocumentation") \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32") \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wmissing-noreturn") \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunused-parameter") \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") - #define DIAG_ON_FLEX \ - PCAP_DO_PRAGMA(clang diagnostic pop) - - /* - * Suppress the only narrowing warnings you get from Clang. - */ - #define DIAG_OFF_NARROWING \ - PCAP_DO_PRAGMA(clang diagnostic push) \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshorten-64-to-32") - - #define DIAG_ON_NARROWING \ - PCAP_DO_PRAGMA(clang diagnostic pop) - - /* - * Suppress deprecation warnings. - */ - #define DIAG_OFF_DEPRECATION \ - PCAP_DO_PRAGMA(clang diagnostic push) \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations") - #define DIAG_ON_DEPRECATION \ - PCAP_DO_PRAGMA(clang diagnostic pop) + #define DIAG_OFF_FORMAT_TRUNCATION + #define DIAG_ON_FORMAT_TRUNCATION #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) /* * This is GCC 4.6 or later, or a compiler claiming to be that. @@ -188,6 +195,22 @@ PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations") #define DIAG_ON_DEPRECATION \ PCAP_DO_PRAGMA(GCC diagnostic pop) + + /* + * Suppress format-truncation= warnings. + * GCC 7.1 had introduced this warning option. Earlier versions (at least + * one particular copy of GCC 4.6.4) treat the request as a warning. + */ + #if PCAP_IS_AT_LEAST_GNUC_VERSION(7,1) + #define DIAG_OFF_FORMAT_TRUNCATION \ + PCAP_DO_PRAGMA(GCC diagnostic push) \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wformat-truncation=") + #define DIAG_ON_FORMAT_TRUNCATION \ + PCAP_DO_PRAGMA(GCC diagnostic pop) + #else + #define DIAG_OFF_FORMAT_TRUNCATION + #define DIAG_ON_FORMAT_TRUNCATION + #endif #else /* * Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later @@ -200,6 +223,8 @@ #define DIAG_ON_NARROWING #define DIAG_OFF_DEPRECATION #define DIAG_ON_DEPRECATION + #define DIAG_OFF_FORMAT_TRUNCATION + #define DIAG_ON_FORMAT_TRUNCATION #endif #ifdef YYBYACC @@ -219,21 +244,21 @@ * In addition, the generated code may have functions with unreachable * code, so suppress warnings about those. */ - #if defined(_MSC_VER) + #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) + /* + * This is Clang 2.8 or later (including clang-cl, so test this + * before _MSC_VER); we can use "clang diagnostic ignored -Wxxx". + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #elif defined(_MSC_VER) /* * This is Microsoft Visual Studio; we can use * __pragma(warning(disable:XXXX)). */ #define DIAG_OFF_BISON_BYACC \ __pragma(warning(disable:4702)) - #elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) - /* - * This is Clang 2.8 or later; we can use "clang diagnostic - * ignored -Wxxx". - */ - #define DIAG_OFF_BISON_BYACC \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) /* * This is GCC 4.6 or later, or a compiler claiming to be that. @@ -257,7 +282,14 @@ * The generated code may have functions with unreachable code and * switches with only a default case, so suppress warnings about those. */ - #if defined(_MSC_VER) + #if PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) + /* + * This is Clang 2.8 or later (including clang-cl, so test this + * before _MSC_VER); we can use "clang diagnostic ignored -Wxxx". + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #elif defined(_MSC_VER) /* * This is Microsoft Visual Studio; we can use * __pragma(warning(disable:XXXX)). @@ -270,13 +302,6 @@ __pragma(warning(disable:4242)) \ __pragma(warning(disable:4244)) \ __pragma(warning(disable:4702)) - #elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8) - /* - * This is Clang 2.8 or later; we can use "clang diagnostic - * ignored -Wxxx". - */ - #define DIAG_OFF_BISON_BYACC \ - PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) /* * This is GCC 4.6 or later, or a compiler claiming to be that. @@ -294,4 +319,20 @@ #endif #endif +/* + * GCC needs this on AIX for longjmp(). + */ +#if PCAP_IS_AT_LEAST_GNUC_VERSION(5,1) + /* + * Beware that the effect of this builtin is more than just squelching the + * warning! GCC trusts it enough for the process to segfault if the control + * flow reaches the builtin (an infinite empty loop in the same context would + * squelch the warning and ruin the process too, albeit in a different way). + * So please remember to use this very carefully. + */ + #define PCAP_UNREACHABLE __builtin_unreachable(); +#else + #define PCAP_UNREACHABLE +#endif + #endif /* _diag_control_h */ diff --git a/libpcap/dlpisubs.c b/libpcap/dlpisubs.c index 2ef09315b..6815b0ec2 100644 --- a/libpcap/dlpisubs.c +++ b/libpcap/dlpisubs.c @@ -146,7 +146,12 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user, #endif #endif - /* Loop through packets */ + /* + * Loop through packets. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. + */ ep = bufp + len; n = 0; diff --git a/libpcap/extract.h b/libpcap/extract.h index e776a9eb2..33579b115 100644 --- a/libpcap/extract.h +++ b/libpcap/extract.h @@ -127,7 +127,7 @@ EXTRACT_BE_S_8(const void *p) * cast the pointer to point to one of those, and fetch through it; * the GCC manual doesn't appear to explicitly say that * __attribute__((packed)) causes the compiler to generate unaligned-safe - * code, but it apppears to do so. + * code, but it appears to do so. * * We do this in case the compiler can generate code using those * instructions to do an unaligned load and pass stuff to "ntohs()" or diff --git a/libpcap/fmtutils.c b/libpcap/fmtutils.c index 5c7ddadfe..2d3576244 100644 --- a/libpcap/fmtutils.c +++ b/libpcap/fmtutils.c @@ -270,13 +270,21 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum, const char *fmt, ...) { va_list ap; + + va_start(ap, fmt); + pcap_vfmt_errmsg_for_errno(errbuf, errbuflen, errnum, fmt, ap); + va_end(ap); +} + +void +pcap_vfmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum, + const char *fmt, va_list ap) +{ size_t msglen; char *p; size_t errbuflen_remaining; - va_start(ap, fmt); - vsnprintf(errbuf, errbuflen, fmt, ap); - va_end(ap); + (void)vsnprintf(errbuf, errbuflen, fmt, ap); msglen = strlen(errbuf); /* @@ -378,6 +386,16 @@ pcap_fmt_errmsg_for_win32_err(char *errbuf, size_t errbuflen, DWORD errnum, const char *fmt, ...) { va_list ap; + + va_start(ap, fmt); + pcap_vfmt_errmsg_for_win32_err(errbuf, errbuflen, errnum, fmt, ap); + va_end(ap); +} + +void +pcap_vfmt_errmsg_for_win32_err(char *errbuf, size_t errbuflen, DWORD errnum, + const char *fmt, va_list ap) +{ size_t msglen; char *p; size_t errbuflen_remaining; @@ -385,9 +403,7 @@ pcap_fmt_errmsg_for_win32_err(char *errbuf, size_t errbuflen, DWORD errnum, wchar_t utf_16_errbuf[PCAP_ERRBUF_SIZE]; size_t utf_8_len; - va_start(ap, fmt); vsnprintf(errbuf, errbuflen, fmt, ap); - va_end(ap); msglen = strlen(errbuf); /* diff --git a/libpcap/fmtutils.h b/libpcap/fmtutils.h index ba0f66ca0..4fa344865 100644 --- a/libpcap/fmtutils.h +++ b/libpcap/fmtutils.h @@ -34,6 +34,8 @@ #ifndef fmtutils_h #define fmtutils_h +#include /* we declare varargs functions */ + #include "pcap/funcattrs.h" #ifdef __cplusplus @@ -44,10 +46,14 @@ void pcap_fmt_set_encoding(unsigned int); void pcap_fmt_errmsg_for_errno(char *, size_t, int, PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); +void pcap_vfmt_errmsg_for_errno(char *, size_t, int, + PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0); #ifdef _WIN32 void pcap_fmt_errmsg_for_win32_err(char *, size_t, DWORD, PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); +void pcap_vfmt_errmsg_for_win32_err(char *, size_t, DWORD, + PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(4, 0); #endif #ifdef __cplusplus diff --git a/libpcap/ftmacros.h b/libpcap/ftmacros.h index 3cd750568..7975463b3 100644 --- a/libpcap/ftmacros.h +++ b/libpcap/ftmacros.h @@ -45,7 +45,12 @@ * namespace to the maximum extent possible"? */ #if defined(sun) || defined(__sun) - #define __EXTENSIONS__ + /* + * On Solaris Clang defines __EXTENSIONS__ automatically. + */ + #ifndef __EXTENSIONS__ + #define __EXTENSIONS__ + #endif /* * We also need to define _XPG4_2 in order to get diff --git a/libpcap/gencode.c b/libpcap/gencode.c index efdcb9874..496e02f37 100644 --- a/libpcap/gencode.c +++ b/libpcap/gencode.c @@ -1,4 +1,3 @@ -/*#define CHASE_CHAIN*/ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 * The Regents of the University of California. All rights reserved. @@ -24,7 +23,6 @@ #include #endif -#include #ifdef _WIN32 #include #else @@ -43,25 +41,12 @@ #include #include #include +#include #ifdef MSDOS #include "pcap-dos.h" #endif -#ifdef HAVE_NET_PFVAR_H -/* - * In NetBSD includes , which is an older version of - * "pcap/dlt.h" with a lower value of DLT_MATCHING_MAX. Include the headers - * below before "pcap-int.h", which eventually includes "pcap/dlt.h", which - * redefines DLT_MATCHING_MAX from what this version of NetBSD has to what - * this version of libpcap has. - */ -#include -#include -#include -#include -#endif /* HAVE_NET_PFVAR_H */ - #include "pcap-int.h" #include "extract.h" @@ -73,12 +58,13 @@ #include "ieee80211.h" #include "atmuni31.h" #include "sunatmpos.h" +#include "pflog.h" #include "ppp.h" #include "pcap/sll.h" #include "pcap/ipnet.h" #include "arcnet.h" +#include "diag-control.h" -#include "grammar.h" #include "scanner.h" #if defined(linux) @@ -475,6 +461,9 @@ bpf_error(compiler_state_t *cstate, const char *fmt, ...) va_end(ap); longjmp(cstate->top_ctx, 1); /*NOTREACHED*/ +#ifdef _AIX + PCAP_UNREACHABLE +#endif /* _AIX */ } static int init_linktype(compiler_state_t *, pcap_t *); @@ -521,6 +510,7 @@ static inline struct block *gen_false(compiler_state_t *); static struct block *gen_ether_linktype(compiler_state_t *, bpf_u_int32); static struct block *gen_ipnet_linktype(compiler_state_t *, bpf_u_int32); static struct block *gen_linux_sll_linktype(compiler_state_t *, bpf_u_int32); +static struct slist *gen_load_pflog_llprefixlen(compiler_state_t *); static struct slist *gen_load_prism_llprefixlen(compiler_state_t *); static struct slist *gen_load_avs_llprefixlen(compiler_state_t *); static struct slist *gen_load_radiotap_llprefixlen(compiler_state_t *); @@ -574,7 +564,9 @@ static struct block *gen_portrangeop6(compiler_state_t *, u_int, u_int, bpf_u_int32, int); static struct block *gen_portrange6(compiler_state_t *, u_int, u_int, int, int); static int lookup_proto(compiler_state_t *, const char *, int); +#if !defined(NO_PROTOCHAIN) static struct block *gen_protochain(compiler_state_t *, bpf_u_int32, int); +#endif /* !defined(NO_PROTOCHAIN) */ static struct block *gen_proto(compiler_state_t *, bpf_u_int32, int, int); static struct slist *xfer_to_x(compiler_state_t *, struct arth *); static struct slist *xfer_to_a(compiler_state_t *, struct arth *); @@ -741,7 +733,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, if (!p->activated) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "not-yet-activated pcap_t passed to pcap_compile"); - return (-1); + return (PCAP_ERROR); } #ifdef _WIN32 @@ -789,7 +781,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, if (cstate.snaplen == 0) { snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snaplen of 0 rejects all packets"); - rc = -1; + rc = PCAP_ERROR; goto quit; } @@ -805,7 +797,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, pcap_set_extra(&cstate, scanner); if (init_linktype(&cstate, p) == -1) { - rc = -1; + rc = PCAP_ERROR; goto quit; } if (pcap_parse(scanner, &cstate) != 0) { @@ -815,7 +807,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, #endif if (cstate.e != NULL) free(cstate.e); - rc = -1; + rc = PCAP_ERROR; goto quit; } @@ -824,7 +816,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, * Catch errors reported by gen_retblk(). */ if (setjmp(cstate.top_ctx)) { - rc = -1; + rc = PCAP_ERROR; goto quit; } cstate.ic.root = gen_retblk(&cstate, cstate.snaplen); @@ -833,14 +825,14 @@ pcap_compile(pcap_t *p, struct bpf_program *program, if (optimize && !cstate.no_optimize) { if (bpf_optimize(&cstate.ic, p->errbuf) == -1) { /* Failure */ - rc = -1; + rc = PCAP_ERROR; goto quit; } if (cstate.ic.root == NULL || (cstate.ic.root->s.code == (BPF_RET|BPF_K) && cstate.ic.root->s.k == 0)) { (void)snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "expression rejects all packets"); - rc = -1; + rc = PCAP_ERROR; goto quit; } } @@ -848,7 +840,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program, cstate.ic.root, &len, p->errbuf); if (program->bf_insns == NULL) { /* Failure */ - rc = -1; + rc = PCAP_ERROR; goto quit; } program->bf_len = len; @@ -886,7 +878,7 @@ pcap_compile_nopcap(int snaplen_arg, int linktype_arg, p = pcap_open_dead(linktype_arg, snaplen_arg); if (p == NULL) - return (-1); + return (PCAP_ERROR); ret = pcap_compile(p, program, buf, optimize, mask); pcap_close(p); return (ret); @@ -1265,6 +1257,7 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) case DLT_PPP: case DLT_PPP_PPPD: case DLT_C_HDLC: /* BSD/OS Cisco HDLC */ + case DLT_HDLC: /* NetBSD (Cisco) HDLC */ case DLT_PPP_SERIAL: /* NetBSD sync/async serial PPP */ cstate->off_linktype.constant_part = 2; /* skip HDLC-like framing */ cstate->off_linkpl.constant_part = 4; /* skip HDLC-like framing and protocol field */ @@ -1513,14 +1506,13 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->off_nl_nosnap = 0; /* XXX - what does it do with 802.3 packets? */ break; -#ifdef HAVE_NET_PFVAR_H case DLT_PFLOG: cstate->off_linktype.constant_part = 0; - cstate->off_linkpl.constant_part = PFLOG_HDRLEN; + cstate->off_linkpl.constant_part = 0; /* link-layer header is variable-length */ + cstate->off_linkpl.is_variable = 1; cstate->off_nl = 0; cstate->off_nl_nosnap = 0; /* no 802.2 LLC */ break; -#endif case DLT_JUNIPER_MFR: case DLT_JUNIPER_MLFR: @@ -1722,7 +1714,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p) cstate->off_nl = OFFSET_NOT_SET; cstate->off_nl_nosnap = OFFSET_NOT_SET; } else { - bpf_set_error(cstate, "unknown data link type %d", cstate->linktype); + bpf_set_error(cstate, "unknown data link type %d (min %d, max %d)", + cstate->linktype, DLT_MATCHING_MIN, DLT_MATCHING_MAX); return (-1); } break; @@ -2344,6 +2337,59 @@ gen_linux_sll_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto) } } +/* + * Load a value relative to the beginning of the link-layer header after the + * pflog header. + */ +static struct slist * +gen_load_pflog_llprefixlen(compiler_state_t *cstate) +{ + struct slist *s1, *s2; + + /* + * Generate code to load the length of the pflog header into + * the register assigned to hold that length, if one has been + * assigned. (If one hasn't been assigned, no code we've + * generated uses that prefix, so we don't need to generate any + * code to load it.) + */ + if (cstate->off_linkpl.reg != -1) { + /* + * The length is in the first byte of the header. + */ + s1 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); + s1->s.k = 0; + + /* + * Round it up to a multiple of 4. + * Add 3, and clear the lower 2 bits. + */ + s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K); + s2->s.k = 3; + sappend(s1, s2); + s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K); + s2->s.k = 0xfffffffc; + sappend(s1, s2); + + /* + * Now allocate a register to hold that value and store + * it. + */ + s2 = new_stmt(cstate, BPF_ST); + s2->s.k = cstate->off_linkpl.reg; + sappend(s1, s2); + + /* + * Now move it into the X register. + */ + s2 = new_stmt(cstate, BPF_MISC|BPF_TAX); + sappend(s1, s2); + + return (s1); + } else + return (NULL); +} + static struct slist * gen_load_prism_llprefixlen(compiler_state_t *cstate) { @@ -2931,6 +2977,10 @@ insert_compute_vloffsets(compiler_state_t *cstate, struct block *b) case DLT_PPI: s = gen_load_802_11_header_len(cstate, s, b->stmts); break; + + case DLT_PFLOG: + s = gen_load_pflog_llprefixlen(cstate); + break; } /* @@ -3166,6 +3216,7 @@ gen_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto) /*NOTREACHED*/ case DLT_C_HDLC: + case DLT_HDLC: switch (ll_proto) { case LLCSAP_ISONS: @@ -3395,7 +3446,6 @@ gen_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto) return gen_false(cstate); } -#ifdef HAVE_NET_PFVAR_H case DLT_PFLOG: /* * af field is host byte order in contrast to the rest of @@ -3410,7 +3460,6 @@ gen_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto) else return gen_false(cstate); /*NOTREACHED*/ -#endif /* HAVE_NET_PFVAR_H */ case DLT_ARCNET: case DLT_ARCNET_LINUX: @@ -5310,21 +5359,15 @@ gen_proto_abbrev_internal(compiler_state_t *cstate, int proto) switch (proto) { case Q_SCTP: - b1 = gen_proto(cstate, IPPROTO_SCTP, Q_IP, Q_DEFAULT); - b0 = gen_proto(cstate, IPPROTO_SCTP, Q_IPV6, Q_DEFAULT); - gen_or(b0, b1); + b1 = gen_proto(cstate, IPPROTO_SCTP, Q_DEFAULT, Q_DEFAULT); break; case Q_TCP: - b1 = gen_proto(cstate, IPPROTO_TCP, Q_IP, Q_DEFAULT); - b0 = gen_proto(cstate, IPPROTO_TCP, Q_IPV6, Q_DEFAULT); - gen_or(b0, b1); + b1 = gen_proto(cstate, IPPROTO_TCP, Q_DEFAULT, Q_DEFAULT); break; case Q_UDP: - b1 = gen_proto(cstate, IPPROTO_UDP, Q_IP, Q_DEFAULT); - b0 = gen_proto(cstate, IPPROTO_UDP, Q_IPV6, Q_DEFAULT); - gen_or(b0, b1); + b1 = gen_proto(cstate, IPPROTO_UDP, Q_DEFAULT, Q_DEFAULT); break; case Q_ICMP: @@ -5351,9 +5394,7 @@ gen_proto_abbrev_internal(compiler_state_t *cstate, int proto) #endif case Q_PIM: - b1 = gen_proto(cstate, IPPROTO_PIM, Q_IP, Q_DEFAULT); - b0 = gen_proto(cstate, IPPROTO_PIM, Q_IPV6, Q_DEFAULT); - gen_or(b0, b1); + b1 = gen_proto(cstate, IPPROTO_PIM, Q_DEFAULT, Q_DEFAULT); break; #ifndef IPPROTO_VRRP @@ -5430,18 +5471,14 @@ gen_proto_abbrev_internal(compiler_state_t *cstate, int proto) #define IPPROTO_AH 51 #endif case Q_AH: - b1 = gen_proto(cstate, IPPROTO_AH, Q_IP, Q_DEFAULT); - b0 = gen_proto(cstate, IPPROTO_AH, Q_IPV6, Q_DEFAULT); - gen_or(b0, b1); + b1 = gen_proto(cstate, IPPROTO_AH, Q_DEFAULT, Q_DEFAULT); break; #ifndef IPPROTO_ESP #define IPPROTO_ESP 50 #endif case Q_ESP: - b1 = gen_proto(cstate, IPPROTO_ESP, Q_IP, Q_DEFAULT); - b0 = gen_proto(cstate, IPPROTO_ESP, Q_IPV6, Q_DEFAULT); - gen_or(b0, b1); + b1 = gen_proto(cstate, IPPROTO_ESP, Q_DEFAULT, Q_DEFAULT); break; case Q_ISO: @@ -6035,20 +6072,10 @@ lookup_proto(compiler_state_t *cstate, const char *name, int proto) return v; } -#if 0 -struct stmt * -gen_joinsp(struct stmt **s, int n) -{ - return NULL; -} -#endif - +#if !defined(NO_PROTOCHAIN) static struct block * gen_protochain(compiler_state_t *cstate, bpf_u_int32 v, int proto) { -#ifdef NO_PROTOCHAIN - return gen_proto(cstate, v, proto); -#else struct block *b0, *b; struct slist *s[100]; int fix2, fix3, fix4, fix5; @@ -6342,8 +6369,8 @@ gen_protochain(compiler_state_t *cstate, bpf_u_int32 v, int proto) gen_and(b0, b); return b; -#endif } +#endif /* !defined(NO_PROTOCHAIN) */ static struct block * gen_check_802_11_data_frame(compiler_state_t *cstate) @@ -6384,9 +6411,7 @@ static struct block * gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto, int dir) { struct block *b0, *b1; -#ifndef CHASE_CHAIN struct block *b2; -#endif if (dir != Q_DEFAULT) bpf_error(cstate, "direction applied to 'proto'"); @@ -6418,11 +6443,7 @@ gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto, int dir) * So we always check for ETHERTYPE_IP. */ b0 = gen_linktype(cstate, ETHERTYPE_IP); -#ifndef CHASE_CHAIN b1 = gen_cmp(cstate, OR_LINKPL, 9, BPF_B, v); -#else - b1 = gen_protochain(cstate, v, Q_IP); -#endif gen_and(b0, b1); return b1; @@ -6484,7 +6505,6 @@ gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto, int dir) case Q_IPV6: b0 = gen_linktype(cstate, ETHERTYPE_IPV6); -#ifndef CHASE_CHAIN /* * Also check for a fragment header before the final * header. @@ -6494,9 +6514,6 @@ gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto, int dir) gen_and(b2, b1); b2 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, v); gen_or(b2, b1); -#else - b1 = gen_protochain(cstate, v, Q_IPV6); -#endif gen_and(b0, b1); return b1; @@ -6550,6 +6567,7 @@ gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto, int dir) /*NOTREACHED*/ case DLT_C_HDLC: + case DLT_HDLC: /* * Cisco uses an Ethertype lookalike - for OSI, * it's 0xfefe. @@ -6935,12 +6953,14 @@ gen_scode(compiler_state_t *cstate, const char *name, struct qual q) else bpf_error(cstate, "unknown protocol: %s", name); +#if !defined(NO_PROTOCHAIN) case Q_PROTOCHAIN: real_proto = lookup_proto(cstate, name, proto); if (real_proto >= 0) return gen_protochain(cstate, real_proto, proto); else bpf_error(cstate, "unknown protocol: %s", name); +#endif /* !defined(NO_PROTOCHAIN) */ case Q_UNDEF: syntax(cstate); @@ -7113,8 +7133,10 @@ gen_ncode(compiler_state_t *cstate, const char *s, bpf_u_int32 v, struct qual q) case Q_PROTO: return gen_proto(cstate, v, proto, dir); +#if !defined(NO_PROTOCHAIN) case Q_PROTOCHAIN: return gen_protochain(cstate, v, proto); +#endif case Q_UNDEF: syntax(cstate); @@ -7968,7 +7990,7 @@ gen_broadcast(compiler_state_t *cstate, int proto) default: bpf_error(cstate, "not a broadcast link"); } - /*NOTREACHED*/ + /*NOTREACHED*/ case Q_IP: /* @@ -8300,12 +8322,10 @@ gen_inbound(compiler_state_t *cstate, int dir) } break; -#ifdef HAVE_NET_PFVAR_H case DLT_PFLOG: b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, dir), BPF_B, ((dir == 0) ? PF_IN : PF_OUT)); break; -#endif case DLT_PPP_PPPD: if (dir) { @@ -8396,7 +8416,6 @@ gen_inbound(compiler_state_t *cstate, int dir) return (b0); } -#ifdef HAVE_NET_PFVAR_H /* PF firewall log matched interface */ struct block * gen_pf_ifname(compiler_state_t *cstate, const char *ifname) @@ -8547,91 +8566,6 @@ gen_pf_action(compiler_state_t *cstate, int action) (bpf_u_int32)action); return (b0); } -#else /* !HAVE_NET_PFVAR_H */ -struct block * -gen_pf_ifname(compiler_state_t *cstate, const char *ifname _U_) -{ - /* - * Catch errors reported by us and routines below us, and return NULL - * on an error. - */ - if (setjmp(cstate->top_ctx)) - return (NULL); - - bpf_error(cstate, "libpcap was compiled without pf support"); - /*NOTREACHED*/ -} - -struct block * -gen_pf_ruleset(compiler_state_t *cstate, char *ruleset _U_) -{ - /* - * Catch errors reported by us and routines below us, and return NULL - * on an error. - */ - if (setjmp(cstate->top_ctx)) - return (NULL); - - bpf_error(cstate, "libpcap was compiled on a machine without pf support"); - /*NOTREACHED*/ -} - -struct block * -gen_pf_rnr(compiler_state_t *cstate, int rnr _U_) -{ - /* - * Catch errors reported by us and routines below us, and return NULL - * on an error. - */ - if (setjmp(cstate->top_ctx)) - return (NULL); - - bpf_error(cstate, "libpcap was compiled on a machine without pf support"); - /*NOTREACHED*/ -} - -struct block * -gen_pf_srnr(compiler_state_t *cstate, int srnr _U_) -{ - /* - * Catch errors reported by us and routines below us, and return NULL - * on an error. - */ - if (setjmp(cstate->top_ctx)) - return (NULL); - - bpf_error(cstate, "libpcap was compiled on a machine without pf support"); - /*NOTREACHED*/ -} - -struct block * -gen_pf_reason(compiler_state_t *cstate, int reason _U_) -{ - /* - * Catch errors reported by us and routines below us, and return NULL - * on an error. - */ - if (setjmp(cstate->top_ctx)) - return (NULL); - - bpf_error(cstate, "libpcap was compiled on a machine without pf support"); - /*NOTREACHED*/ -} - -struct block * -gen_pf_action(compiler_state_t *cstate, int action _U_) -{ - /* - * Catch errors reported by us and routines below us, and return NULL - * on an error. - */ - if (setjmp(cstate->top_ctx)) - return (NULL); - - bpf_error(cstate, "libpcap was compiled on a machine without pf support"); - /*NOTREACHED*/ -} -#endif /* HAVE_NET_PFVAR_H */ /* IEEE 802.11 wireless header */ struct block * @@ -8721,7 +8655,7 @@ gen_acode(compiler_state_t *cstate, const char *s, struct qual q) return (b); } else bpf_error(cstate, "ARCnet address used in non-arc expression"); - /*NOTREACHED*/ + /*NOTREACHED*/ default: bpf_error(cstate, "aid supported only on ARCnet"); @@ -8757,27 +8691,27 @@ gen_ahostop(compiler_state_t *cstate, const u_char *eaddr, int dir) case Q_ADDR1: bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11"); - /*NOTREACHED*/ + /*NOTREACHED*/ case Q_ADDR2: bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11"); - /*NOTREACHED*/ + /*NOTREACHED*/ case Q_ADDR3: bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11"); - /*NOTREACHED*/ + /*NOTREACHED*/ case Q_ADDR4: bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11"); - /*NOTREACHED*/ + /*NOTREACHED*/ case Q_RA: bpf_error(cstate, "'ra' is only supported on 802.11"); - /*NOTREACHED*/ + /*NOTREACHED*/ case Q_TA: bpf_error(cstate, "'ta' is only supported on 802.11"); - /*NOTREACHED*/ + /*NOTREACHED*/ } abort(); /*NOTREACHED*/ @@ -8788,7 +8722,7 @@ gen_vlan_tpid_test(compiler_state_t *cstate) { struct block *b0, *b1; - /* check for VLAN, including QinQ */ + /* check for VLAN, including 802.1ad and QinQ */ b0 = gen_linktype(cstate, ETHERTYPE_8021Q); b1 = gen_linktype(cstate, ETHERTYPE_8021AD); gen_or(b0,b1); @@ -9095,6 +9029,7 @@ gen_mpls(compiler_state_t *cstate, bpf_u_int32 label_num_arg, switch (cstate->linktype) { case DLT_C_HDLC: /* fall through */ + case DLT_HDLC: case DLT_EN10MB: case DLT_NETANALYZER: case DLT_NETANALYZER_TRANSPARENT: diff --git a/libpcap/gencode.h b/libpcap/gencode.h index 053e85f9c..93ca5216b 100644 --- a/libpcap/gencode.h +++ b/libpcap/gencode.h @@ -19,7 +19,19 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#ifndef gencode_h +#define gencode_h + #include "pcap/funcattrs.h" +/* + * pcap/bpf.h (a public header) needs u_char, u_short and u_int, which can be + * made available via either pcap-types.h (a private header) or pcap/pcap.h + * (a public header), none of which pcap/bpf.h includes. Include the private + * header to keep things simple, this way this private header should compile + * even if included early from another file. + */ +#include "pcap-types.h" +#include "pcap/bpf.h" /* bpf_u_int32 and BPF_MEMWORDS */ /* * ATM support: @@ -400,3 +412,5 @@ int pcap_parse(void *, compiler_state_t *); /* XXX */ #define JT(b) ((b)->et.succ) #define JF(b) ((b)->ef.succ) + +#endif /* gencode_h */ diff --git a/libpcap/grammar.c b/libpcap/grammar.c index cfc217e22..29339b907 100644 --- a/libpcap/grammar.c +++ b/libpcap/grammar.c @@ -96,6 +96,13 @@ #include #endif +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include #ifndef _WIN32 @@ -117,17 +124,11 @@ struct rtentry; #include "pcap-int.h" -#include "gencode.h" -#include "grammar.h" #include "scanner.h" -#ifdef HAVE_NET_PFVAR_H -#include -#include -#include -#endif #include "llc.h" #include "ieee80211.h" +#include "pflog.h" #include #ifdef HAVE_OS_PROTO_H @@ -279,60 +280,87 @@ yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg) bpf_set_error(cstate, "can't parse filter expression: %s", msg); } -#ifdef HAVE_NET_PFVAR_H +static const struct tok pflog_reasons[] = { + { PFRES_MATCH, "match" }, + { PFRES_BADOFF, "bad-offset" }, + { PFRES_FRAG, "fragment" }, + { PFRES_SHORT, "short" }, + { PFRES_NORM, "normalize" }, + { PFRES_MEMORY, "memory" }, + { PFRES_TS, "bad-timestamp" }, + { PFRES_CONGEST, "congestion" }, + { PFRES_IPOPTIONS, "ip-option" }, + { PFRES_PROTCKSUM, "proto-cksum" }, + { PFRES_BADSTATE, "state-mismatch" }, + { PFRES_STATEINS, "state-insert" }, + { PFRES_MAXSTATES, "state-limit" }, + { PFRES_SRCLIMIT, "src-limit" }, + { PFRES_SYNPROXY, "synproxy" }, +#if defined(__FreeBSD__) + { PFRES_MAPFAILED, "map-failed" }, +#elif defined(__NetBSD__) + { PFRES_STATELOCKED, "state-locked" }, +#elif defined(__OpenBSD__) + { PFRES_TRANSLATE, "translate" }, + { PFRES_NOROUTE, "no-route" }, +#elif defined(__APPLE__) + { PFRES_DUMMYNET, "dummynet" }, +#endif + { 0, NULL } +}; + static int pfreason_to_num(compiler_state_t *cstate, const char *reason) { - const char *reasons[] = PFRES_NAMES; int i; - for (i = 0; reasons[i]; i++) { - if (pcap_strcasecmp(reason, reasons[i]) == 0) - return (i); - } - bpf_set_error(cstate, "unknown PF reason \"%s\"", reason); - return (-1); + i = str2tok(reason, pflog_reasons); + if (i == -1) + bpf_set_error(cstate, "unknown PF reason \"%s\"", reason); + return (i); } +static const struct tok pflog_actions[] = { + { PF_PASS, "pass" }, + { PF_PASS, "accept" }, /* alias for "pass" */ + { PF_DROP, "drop" }, + { PF_DROP, "block" }, /* alias for "drop" */ + { PF_SCRUB, "scrub" }, + { PF_NOSCRUB, "noscrub" }, + { PF_NAT, "nat" }, + { PF_NONAT, "nonat" }, + { PF_BINAT, "binat" }, + { PF_NOBINAT, "nobinat" }, + { PF_RDR, "rdr" }, + { PF_NORDR, "nordr" }, + { PF_SYNPROXY_DROP, "synproxy-drop" }, +#if defined(__FreeBSD__) + { PF_DEFER, "defer" }, +#elif defined(__OpenBSD__) + { PF_DEFER, "defer" }, + { PF_MATCH, "match" }, + { PF_DIVERT, "divert" }, + { PF_RT, "rt" }, + { PF_AFRT, "afrt" }, +#elif defined(__APPLE__) + { PF_DUMMYNET, "dummynet" }, + { PF_NODUMMYNET, "nodummynet" }, + { PF_NAT64, "nat64" }, + { PF_NONAT64, "nonat64" }, +#endif + { 0, NULL }, +}; + static int pfaction_to_num(compiler_state_t *cstate, const char *action) { - if (pcap_strcasecmp(action, "pass") == 0 || - pcap_strcasecmp(action, "accept") == 0) - return (PF_PASS); - else if (pcap_strcasecmp(action, "drop") == 0 || - pcap_strcasecmp(action, "block") == 0) - return (PF_DROP); -#if HAVE_PF_NAT_THROUGH_PF_NORDR - else if (pcap_strcasecmp(action, "rdr") == 0) - return (PF_RDR); - else if (pcap_strcasecmp(action, "nat") == 0) - return (PF_NAT); - else if (pcap_strcasecmp(action, "binat") == 0) - return (PF_BINAT); - else if (pcap_strcasecmp(action, "nordr") == 0) - return (PF_NORDR); -#endif - else { - bpf_set_error(cstate, "unknown PF action \"%s\"", action); - return (-1); - } -} -#else /* !HAVE_NET_PFVAR_H */ -static int -pfreason_to_num(compiler_state_t *cstate, const char *reason _U_) -{ - bpf_set_error(cstate, "libpcap was compiled on a machine without pf support"); - return (-1); -} + int i; -static int -pfaction_to_num(compiler_state_t *cstate, const char *action _U_) -{ - bpf_set_error(cstate, "libpcap was compiled on a machine without pf support"); - return (-1); + i = str2tok(action, pflog_actions); + if (i == -1) + bpf_set_error(cstate, "unknown PF action \"%s\"", action); + return (i); } -#endif /* HAVE_NET_PFVAR_H */ /* * For calls that might return an "an error occurred" value. @@ -342,7 +370,7 @@ pfaction_to_num(compiler_state_t *cstate, const char *action _U_) DIAG_OFF_BISON_BYACC -#line 346 "grammar.c" /* yacc.c:339 */ +#line 374 "grammar.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -506,7 +534,7 @@ extern int pcap_debug; union YYSTYPE { -#line 321 "grammar.y" /* yacc.c:355 */ +#line 349 "grammar.y" /* yacc.c:355 */ int i; bpf_u_int32 h; @@ -521,7 +549,7 @@ union YYSTYPE } blk; struct block *rblk; -#line 525 "grammar.c" /* yacc.c:355 */ +#line 553 "grammar.c" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; @@ -537,7 +565,7 @@ int pcap_parse (void *yyscanner, compiler_state_t *cstate); /* Copy the second part of user declarations. */ -#line 541 "grammar.c" /* yacc.c:358 */ +#line 569 "grammar.c" /* yacc.c:358 */ #ifdef short # undef short @@ -846,29 +874,29 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 395, 395, 399, 401, 403, 404, 405, 406, 407, - 409, 411, 413, 414, 416, 418, 419, 421, 423, 442, - 453, 464, 465, 466, 468, 470, 472, 473, 474, 476, - 478, 480, 481, 483, 484, 485, 486, 487, 495, 497, - 498, 499, 500, 502, 504, 505, 506, 507, 508, 509, - 512, 513, 516, 517, 518, 519, 520, 521, 522, 523, - 524, 525, 526, 527, 530, 531, 532, 533, 536, 538, - 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, - 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, - 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, - 569, 570, 571, 572, 573, 574, 575, 576, 578, 579, - 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, - 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, - 602, 603, 604, 605, 608, 613, 616, 620, 623, 629, - 638, 644, 667, 684, 685, 709, 712, 713, 729, 730, - 733, 736, 737, 738, 740, 741, 742, 744, 745, 747, - 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, - 758, 759, 760, 761, 763, 764, 765, 766, 767, 769, - 770, 772, 773, 774, 775, 776, 777, 778, 780, 781, - 782, 783, 786, 787, 789, 790, 791, 792, 794, 801, - 802, 805, 806, 807, 808, 809, 810, 813, 814, 815, - 816, 817, 818, 819, 820, 822, 823, 824, 825, 827, - 840, 841 + 0, 423, 423, 427, 429, 431, 432, 433, 434, 435, + 437, 439, 441, 442, 444, 446, 447, 449, 451, 470, + 481, 492, 493, 494, 496, 498, 500, 501, 502, 504, + 506, 508, 509, 511, 512, 513, 514, 515, 523, 525, + 526, 527, 528, 530, 532, 533, 534, 535, 536, 537, + 540, 541, 544, 545, 546, 547, 548, 549, 550, 551, + 552, 553, 554, 555, 558, 559, 560, 561, 564, 566, + 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, + 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, + 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, + 597, 598, 599, 600, 601, 602, 603, 604, 606, 607, + 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, + 618, 619, 620, 621, 622, 623, 624, 625, 628, 629, + 630, 631, 632, 633, 636, 641, 644, 648, 651, 657, + 666, 672, 695, 712, 713, 737, 740, 741, 757, 758, + 761, 764, 765, 766, 768, 769, 770, 772, 773, 775, + 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, + 786, 787, 788, 789, 791, 792, 793, 794, 795, 797, + 798, 800, 801, 802, 803, 804, 805, 806, 808, 809, + 810, 811, 814, 815, 817, 818, 819, 820, 822, 829, + 830, 833, 834, 835, 836, 837, 838, 841, 842, 843, + 844, 845, 846, 847, 848, 850, 851, 852, 853, 855, + 868, 869 }; #endif @@ -1977,90 +2005,90 @@ yyreduce: switch (yyn) { case 2: -#line 396 "grammar.y" /* yacc.c:1646 */ +#line 424 "grammar.y" /* yacc.c:1646 */ { CHECK_INT_VAL(finish_parse(cstate, (yyvsp[0].blk).b)); } -#line 1985 "grammar.c" /* yacc.c:1646 */ +#line 2013 "grammar.c" /* yacc.c:1646 */ break; case 4: -#line 401 "grammar.y" /* yacc.c:1646 */ +#line 429 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).q = qerr; } -#line 1991 "grammar.c" /* yacc.c:1646 */ +#line 2019 "grammar.c" /* yacc.c:1646 */ break; case 6: -#line 404 "grammar.y" /* yacc.c:1646 */ +#line 432 "grammar.y" /* yacc.c:1646 */ { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 1997 "grammar.c" /* yacc.c:1646 */ +#line 2025 "grammar.c" /* yacc.c:1646 */ break; case 7: -#line 405 "grammar.y" /* yacc.c:1646 */ +#line 433 "grammar.y" /* yacc.c:1646 */ { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2003 "grammar.c" /* yacc.c:1646 */ +#line 2031 "grammar.c" /* yacc.c:1646 */ break; case 8: -#line 406 "grammar.y" /* yacc.c:1646 */ +#line 434 "grammar.y" /* yacc.c:1646 */ { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2009 "grammar.c" /* yacc.c:1646 */ +#line 2037 "grammar.c" /* yacc.c:1646 */ break; case 9: -#line 407 "grammar.y" /* yacc.c:1646 */ +#line 435 "grammar.y" /* yacc.c:1646 */ { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2015 "grammar.c" /* yacc.c:1646 */ +#line 2043 "grammar.c" /* yacc.c:1646 */ break; case 10: -#line 409 "grammar.y" /* yacc.c:1646 */ +#line 437 "grammar.y" /* yacc.c:1646 */ { (yyval.blk) = (yyvsp[-1].blk); } -#line 2021 "grammar.c" /* yacc.c:1646 */ +#line 2049 "grammar.c" /* yacc.c:1646 */ break; case 11: -#line 411 "grammar.y" /* yacc.c:1646 */ +#line 439 "grammar.y" /* yacc.c:1646 */ { (yyval.blk) = (yyvsp[-1].blk); } -#line 2027 "grammar.c" /* yacc.c:1646 */ +#line 2055 "grammar.c" /* yacc.c:1646 */ break; case 13: -#line 414 "grammar.y" /* yacc.c:1646 */ +#line 442 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, NULL, (yyvsp[0].h), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2034 "grammar.c" /* yacc.c:1646 */ +#line 2062 "grammar.c" /* yacc.c:1646 */ break; case 14: -#line 416 "grammar.y" /* yacc.c:1646 */ +#line 444 "grammar.y" /* yacc.c:1646 */ { (yyval.blk) = (yyvsp[-1].blk); } -#line 2040 "grammar.c" /* yacc.c:1646 */ +#line 2068 "grammar.c" /* yacc.c:1646 */ break; case 15: -#line 418 "grammar.y" /* yacc.c:1646 */ +#line 446 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_scode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2046 "grammar.c" /* yacc.c:1646 */ +#line 2074 "grammar.c" /* yacc.c:1646 */ break; case 16: -#line 419 "grammar.y" /* yacc.c:1646 */ +#line 447 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[-2].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), NULL, (yyvsp[0].h), (yyval.blk).q = (yyvsp[-3].blk).q))); } -#line 2053 "grammar.c" /* yacc.c:1646 */ +#line 2081 "grammar.c" /* yacc.c:1646 */ break; case 17: -#line 421 "grammar.y" /* yacc.c:1646 */ +#line 449 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[-2].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), (yyvsp[0].s), 0, (yyval.blk).q = (yyvsp[-3].blk).q))); } -#line 2060 "grammar.c" /* yacc.c:1646 */ +#line 2088 "grammar.c" /* yacc.c:1646 */ break; case 18: -#line 423 "grammar.y" /* yacc.c:1646 */ +#line 451 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); /* Decide how to parse HID based on proto */ @@ -2080,11 +2108,11 @@ yyreduce: } CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, (yyvsp[0].s), 0, (yyval.blk).q))); } -#line 2084 "grammar.c" /* yacc.c:1646 */ +#line 2112 "grammar.c" /* yacc.c:1646 */ break; case 19: -#line 442 "grammar.y" /* yacc.c:1646 */ +#line 470 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[-2].s)); #ifdef INET6 @@ -2096,11 +2124,11 @@ yyreduce: YYABORT; #endif /*INET6*/ } -#line 2100 "grammar.c" /* yacc.c:1646 */ +#line 2128 "grammar.c" /* yacc.c:1646 */ break; case 20: -#line 453 "grammar.y" /* yacc.c:1646 */ +#line 481 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); #ifdef INET6 @@ -2112,90 +2140,90 @@ yyreduce: YYABORT; #endif /*INET6*/ } -#line 2116 "grammar.c" /* yacc.c:1646 */ +#line 2144 "grammar.c" /* yacc.c:1646 */ break; case 21: -#line 464 "grammar.y" /* yacc.c:1646 */ +#line 492 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_ecode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2122 "grammar.c" /* yacc.c:1646 */ +#line 2150 "grammar.c" /* yacc.c:1646 */ break; case 22: -#line 465 "grammar.y" /* yacc.c:1646 */ +#line 493 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_acode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2128 "grammar.c" /* yacc.c:1646 */ +#line 2156 "grammar.c" /* yacc.c:1646 */ break; case 23: -#line 466 "grammar.y" /* yacc.c:1646 */ +#line 494 "grammar.y" /* yacc.c:1646 */ { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2134 "grammar.c" /* yacc.c:1646 */ +#line 2162 "grammar.c" /* yacc.c:1646 */ break; case 24: -#line 468 "grammar.y" /* yacc.c:1646 */ +#line 496 "grammar.y" /* yacc.c:1646 */ { (yyval.blk) = (yyvsp[-1].blk); } -#line 2140 "grammar.c" /* yacc.c:1646 */ +#line 2168 "grammar.c" /* yacc.c:1646 */ break; case 25: -#line 470 "grammar.y" /* yacc.c:1646 */ +#line 498 "grammar.y" /* yacc.c:1646 */ { (yyval.blk) = (yyvsp[-1].blk); } -#line 2146 "grammar.c" /* yacc.c:1646 */ +#line 2174 "grammar.c" /* yacc.c:1646 */ break; case 27: -#line 473 "grammar.y" /* yacc.c:1646 */ +#line 501 "grammar.y" /* yacc.c:1646 */ { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2152 "grammar.c" /* yacc.c:1646 */ +#line 2180 "grammar.c" /* yacc.c:1646 */ break; case 28: -#line 474 "grammar.y" /* yacc.c:1646 */ +#line 502 "grammar.y" /* yacc.c:1646 */ { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2158 "grammar.c" /* yacc.c:1646 */ +#line 2186 "grammar.c" /* yacc.c:1646 */ break; case 29: -#line 476 "grammar.y" /* yacc.c:1646 */ +#line 504 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, NULL, (yyvsp[0].h), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2165 "grammar.c" /* yacc.c:1646 */ +#line 2193 "grammar.c" /* yacc.c:1646 */ break; case 32: -#line 481 "grammar.y" /* yacc.c:1646 */ +#line 509 "grammar.y" /* yacc.c:1646 */ { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2171 "grammar.c" /* yacc.c:1646 */ +#line 2199 "grammar.c" /* yacc.c:1646 */ break; case 33: -#line 483 "grammar.y" /* yacc.c:1646 */ +#line 511 "grammar.y" /* yacc.c:1646 */ { QSET((yyval.blk).q, (yyvsp[-2].i), (yyvsp[-1].i), (yyvsp[0].i)); } -#line 2177 "grammar.c" /* yacc.c:1646 */ +#line 2205 "grammar.c" /* yacc.c:1646 */ break; case 34: -#line 484 "grammar.y" /* yacc.c:1646 */ +#line 512 "grammar.y" /* yacc.c:1646 */ { QSET((yyval.blk).q, (yyvsp[-1].i), (yyvsp[0].i), Q_DEFAULT); } -#line 2183 "grammar.c" /* yacc.c:1646 */ +#line 2211 "grammar.c" /* yacc.c:1646 */ break; case 35: -#line 485 "grammar.y" /* yacc.c:1646 */ +#line 513 "grammar.y" /* yacc.c:1646 */ { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); } -#line 2189 "grammar.c" /* yacc.c:1646 */ +#line 2217 "grammar.c" /* yacc.c:1646 */ break; case 36: -#line 486 "grammar.y" /* yacc.c:1646 */ +#line 514 "grammar.y" /* yacc.c:1646 */ { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTO); } -#line 2195 "grammar.c" /* yacc.c:1646 */ +#line 2223 "grammar.c" /* yacc.c:1646 */ break; case 37: -#line 487 "grammar.y" /* yacc.c:1646 */ +#line 515 "grammar.y" /* yacc.c:1646 */ { #ifdef NO_PROTOCHAIN bpf_set_error(cstate, "protochain not supported"); @@ -2204,626 +2232,626 @@ yyreduce: QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTOCHAIN); #endif } -#line 2208 "grammar.c" /* yacc.c:1646 */ +#line 2236 "grammar.c" /* yacc.c:1646 */ break; case 38: -#line 495 "grammar.y" /* yacc.c:1646 */ +#line 523 "grammar.y" /* yacc.c:1646 */ { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); } -#line 2214 "grammar.c" /* yacc.c:1646 */ +#line 2242 "grammar.c" /* yacc.c:1646 */ break; case 39: -#line 497 "grammar.y" /* yacc.c:1646 */ +#line 525 "grammar.y" /* yacc.c:1646 */ { (yyval.blk) = (yyvsp[0].blk); } -#line 2220 "grammar.c" /* yacc.c:1646 */ +#line 2248 "grammar.c" /* yacc.c:1646 */ break; case 40: -#line 498 "grammar.y" /* yacc.c:1646 */ +#line 526 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = (yyvsp[-2].blk).q; } -#line 2226 "grammar.c" /* yacc.c:1646 */ +#line 2254 "grammar.c" /* yacc.c:1646 */ break; case 41: -#line 499 "grammar.y" /* yacc.c:1646 */ +#line 527 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_proto_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2232 "grammar.c" /* yacc.c:1646 */ +#line 2260 "grammar.c" /* yacc.c:1646 */ break; case 42: -#line 500 "grammar.y" /* yacc.c:1646 */ +#line 528 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 0))); (yyval.blk).q = qerr; } -#line 2239 "grammar.c" /* yacc.c:1646 */ +#line 2267 "grammar.c" /* yacc.c:1646 */ break; case 43: -#line 502 "grammar.y" /* yacc.c:1646 */ +#line 530 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 1))); (yyval.blk).q = qerr; } -#line 2246 "grammar.c" /* yacc.c:1646 */ +#line 2274 "grammar.c" /* yacc.c:1646 */ break; case 44: -#line 504 "grammar.y" /* yacc.c:1646 */ +#line 532 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).b = (yyvsp[0].rblk); (yyval.blk).q = qerr; } -#line 2252 "grammar.c" /* yacc.c:1646 */ +#line 2280 "grammar.c" /* yacc.c:1646 */ break; case 45: -#line 505 "grammar.y" /* yacc.c:1646 */ +#line 533 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_atmtype_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2258 "grammar.c" /* yacc.c:1646 */ +#line 2286 "grammar.c" /* yacc.c:1646 */ break; case 46: -#line 506 "grammar.y" /* yacc.c:1646 */ +#line 534 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_atmmulti_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2264 "grammar.c" /* yacc.c:1646 */ +#line 2292 "grammar.c" /* yacc.c:1646 */ break; case 47: -#line 507 "grammar.y" /* yacc.c:1646 */ +#line 535 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; } -#line 2270 "grammar.c" /* yacc.c:1646 */ +#line 2298 "grammar.c" /* yacc.c:1646 */ break; case 48: -#line 508 "grammar.y" /* yacc.c:1646 */ +#line 536 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp2type_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2276 "grammar.c" /* yacc.c:1646 */ +#line 2304 "grammar.c" /* yacc.c:1646 */ break; case 49: -#line 509 "grammar.y" /* yacc.c:1646 */ +#line 537 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; } -#line 2282 "grammar.c" /* yacc.c:1646 */ +#line 2310 "grammar.c" /* yacc.c:1646 */ break; case 51: -#line 513 "grammar.y" /* yacc.c:1646 */ +#line 541 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_DEFAULT; } -#line 2288 "grammar.c" /* yacc.c:1646 */ +#line 2316 "grammar.c" /* yacc.c:1646 */ break; case 52: -#line 516 "grammar.y" /* yacc.c:1646 */ +#line 544 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_SRC; } -#line 2294 "grammar.c" /* yacc.c:1646 */ +#line 2322 "grammar.c" /* yacc.c:1646 */ break; case 53: -#line 517 "grammar.y" /* yacc.c:1646 */ +#line 545 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_DST; } -#line 2300 "grammar.c" /* yacc.c:1646 */ +#line 2328 "grammar.c" /* yacc.c:1646 */ break; case 54: -#line 518 "grammar.y" /* yacc.c:1646 */ +#line 546 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_OR; } -#line 2306 "grammar.c" /* yacc.c:1646 */ +#line 2334 "grammar.c" /* yacc.c:1646 */ break; case 55: -#line 519 "grammar.y" /* yacc.c:1646 */ +#line 547 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_OR; } -#line 2312 "grammar.c" /* yacc.c:1646 */ +#line 2340 "grammar.c" /* yacc.c:1646 */ break; case 56: -#line 520 "grammar.y" /* yacc.c:1646 */ +#line 548 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_AND; } -#line 2318 "grammar.c" /* yacc.c:1646 */ +#line 2346 "grammar.c" /* yacc.c:1646 */ break; case 57: -#line 521 "grammar.y" /* yacc.c:1646 */ +#line 549 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_AND; } -#line 2324 "grammar.c" /* yacc.c:1646 */ +#line 2352 "grammar.c" /* yacc.c:1646 */ break; case 58: -#line 522 "grammar.y" /* yacc.c:1646 */ +#line 550 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ADDR1; } -#line 2330 "grammar.c" /* yacc.c:1646 */ +#line 2358 "grammar.c" /* yacc.c:1646 */ break; case 59: -#line 523 "grammar.y" /* yacc.c:1646 */ +#line 551 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ADDR2; } -#line 2336 "grammar.c" /* yacc.c:1646 */ +#line 2364 "grammar.c" /* yacc.c:1646 */ break; case 60: -#line 524 "grammar.y" /* yacc.c:1646 */ +#line 552 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ADDR3; } -#line 2342 "grammar.c" /* yacc.c:1646 */ +#line 2370 "grammar.c" /* yacc.c:1646 */ break; case 61: -#line 525 "grammar.y" /* yacc.c:1646 */ +#line 553 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ADDR4; } -#line 2348 "grammar.c" /* yacc.c:1646 */ +#line 2376 "grammar.c" /* yacc.c:1646 */ break; case 62: -#line 526 "grammar.y" /* yacc.c:1646 */ +#line 554 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_RA; } -#line 2354 "grammar.c" /* yacc.c:1646 */ +#line 2382 "grammar.c" /* yacc.c:1646 */ break; case 63: -#line 527 "grammar.y" /* yacc.c:1646 */ +#line 555 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_TA; } -#line 2360 "grammar.c" /* yacc.c:1646 */ +#line 2388 "grammar.c" /* yacc.c:1646 */ break; case 64: -#line 530 "grammar.y" /* yacc.c:1646 */ +#line 558 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_HOST; } -#line 2366 "grammar.c" /* yacc.c:1646 */ +#line 2394 "grammar.c" /* yacc.c:1646 */ break; case 65: -#line 531 "grammar.y" /* yacc.c:1646 */ +#line 559 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_NET; } -#line 2372 "grammar.c" /* yacc.c:1646 */ +#line 2400 "grammar.c" /* yacc.c:1646 */ break; case 66: -#line 532 "grammar.y" /* yacc.c:1646 */ +#line 560 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_PORT; } -#line 2378 "grammar.c" /* yacc.c:1646 */ +#line 2406 "grammar.c" /* yacc.c:1646 */ break; case 67: -#line 533 "grammar.y" /* yacc.c:1646 */ +#line 561 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_PORTRANGE; } -#line 2384 "grammar.c" /* yacc.c:1646 */ +#line 2412 "grammar.c" /* yacc.c:1646 */ break; case 68: -#line 536 "grammar.y" /* yacc.c:1646 */ +#line 564 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_GATEWAY; } -#line 2390 "grammar.c" /* yacc.c:1646 */ +#line 2418 "grammar.c" /* yacc.c:1646 */ break; case 69: -#line 538 "grammar.y" /* yacc.c:1646 */ +#line 566 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_LINK; } -#line 2396 "grammar.c" /* yacc.c:1646 */ +#line 2424 "grammar.c" /* yacc.c:1646 */ break; case 70: -#line 539 "grammar.y" /* yacc.c:1646 */ +#line 567 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_IP; } -#line 2402 "grammar.c" /* yacc.c:1646 */ +#line 2430 "grammar.c" /* yacc.c:1646 */ break; case 71: -#line 540 "grammar.y" /* yacc.c:1646 */ +#line 568 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ARP; } -#line 2408 "grammar.c" /* yacc.c:1646 */ +#line 2436 "grammar.c" /* yacc.c:1646 */ break; case 72: -#line 541 "grammar.y" /* yacc.c:1646 */ +#line 569 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_RARP; } -#line 2414 "grammar.c" /* yacc.c:1646 */ +#line 2442 "grammar.c" /* yacc.c:1646 */ break; case 73: -#line 542 "grammar.y" /* yacc.c:1646 */ +#line 570 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_SCTP; } -#line 2420 "grammar.c" /* yacc.c:1646 */ +#line 2448 "grammar.c" /* yacc.c:1646 */ break; case 74: -#line 543 "grammar.y" /* yacc.c:1646 */ +#line 571 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_TCP; } -#line 2426 "grammar.c" /* yacc.c:1646 */ +#line 2454 "grammar.c" /* yacc.c:1646 */ break; case 75: -#line 544 "grammar.y" /* yacc.c:1646 */ +#line 572 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_UDP; } -#line 2432 "grammar.c" /* yacc.c:1646 */ +#line 2460 "grammar.c" /* yacc.c:1646 */ break; case 76: -#line 545 "grammar.y" /* yacc.c:1646 */ +#line 573 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ICMP; } -#line 2438 "grammar.c" /* yacc.c:1646 */ +#line 2466 "grammar.c" /* yacc.c:1646 */ break; case 77: -#line 546 "grammar.y" /* yacc.c:1646 */ +#line 574 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_IGMP; } -#line 2444 "grammar.c" /* yacc.c:1646 */ +#line 2472 "grammar.c" /* yacc.c:1646 */ break; case 78: -#line 547 "grammar.y" /* yacc.c:1646 */ +#line 575 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_IGRP; } -#line 2450 "grammar.c" /* yacc.c:1646 */ +#line 2478 "grammar.c" /* yacc.c:1646 */ break; case 79: -#line 548 "grammar.y" /* yacc.c:1646 */ +#line 576 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_PIM; } -#line 2456 "grammar.c" /* yacc.c:1646 */ +#line 2484 "grammar.c" /* yacc.c:1646 */ break; case 80: -#line 549 "grammar.y" /* yacc.c:1646 */ +#line 577 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_VRRP; } -#line 2462 "grammar.c" /* yacc.c:1646 */ +#line 2490 "grammar.c" /* yacc.c:1646 */ break; case 81: -#line 550 "grammar.y" /* yacc.c:1646 */ +#line 578 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_CARP; } -#line 2468 "grammar.c" /* yacc.c:1646 */ +#line 2496 "grammar.c" /* yacc.c:1646 */ break; case 82: -#line 551 "grammar.y" /* yacc.c:1646 */ +#line 579 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ATALK; } -#line 2474 "grammar.c" /* yacc.c:1646 */ +#line 2502 "grammar.c" /* yacc.c:1646 */ break; case 83: -#line 552 "grammar.y" /* yacc.c:1646 */ +#line 580 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_AARP; } -#line 2480 "grammar.c" /* yacc.c:1646 */ +#line 2508 "grammar.c" /* yacc.c:1646 */ break; case 84: -#line 553 "grammar.y" /* yacc.c:1646 */ +#line 581 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_DECNET; } -#line 2486 "grammar.c" /* yacc.c:1646 */ +#line 2514 "grammar.c" /* yacc.c:1646 */ break; case 85: -#line 554 "grammar.y" /* yacc.c:1646 */ +#line 582 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_LAT; } -#line 2492 "grammar.c" /* yacc.c:1646 */ +#line 2520 "grammar.c" /* yacc.c:1646 */ break; case 86: -#line 555 "grammar.y" /* yacc.c:1646 */ +#line 583 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_SCA; } -#line 2498 "grammar.c" /* yacc.c:1646 */ +#line 2526 "grammar.c" /* yacc.c:1646 */ break; case 87: -#line 556 "grammar.y" /* yacc.c:1646 */ +#line 584 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_MOPDL; } -#line 2504 "grammar.c" /* yacc.c:1646 */ +#line 2532 "grammar.c" /* yacc.c:1646 */ break; case 88: -#line 557 "grammar.y" /* yacc.c:1646 */ +#line 585 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_MOPRC; } -#line 2510 "grammar.c" /* yacc.c:1646 */ +#line 2538 "grammar.c" /* yacc.c:1646 */ break; case 89: -#line 558 "grammar.y" /* yacc.c:1646 */ +#line 586 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_IPV6; } -#line 2516 "grammar.c" /* yacc.c:1646 */ +#line 2544 "grammar.c" /* yacc.c:1646 */ break; case 90: -#line 559 "grammar.y" /* yacc.c:1646 */ +#line 587 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ICMPV6; } -#line 2522 "grammar.c" /* yacc.c:1646 */ +#line 2550 "grammar.c" /* yacc.c:1646 */ break; case 91: -#line 560 "grammar.y" /* yacc.c:1646 */ +#line 588 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_AH; } -#line 2528 "grammar.c" /* yacc.c:1646 */ +#line 2556 "grammar.c" /* yacc.c:1646 */ break; case 92: -#line 561 "grammar.y" /* yacc.c:1646 */ +#line 589 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ESP; } -#line 2534 "grammar.c" /* yacc.c:1646 */ +#line 2562 "grammar.c" /* yacc.c:1646 */ break; case 93: -#line 562 "grammar.y" /* yacc.c:1646 */ +#line 590 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISO; } -#line 2540 "grammar.c" /* yacc.c:1646 */ +#line 2568 "grammar.c" /* yacc.c:1646 */ break; case 94: -#line 563 "grammar.y" /* yacc.c:1646 */ +#line 591 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ESIS; } -#line 2546 "grammar.c" /* yacc.c:1646 */ +#line 2574 "grammar.c" /* yacc.c:1646 */ break; case 95: -#line 564 "grammar.y" /* yacc.c:1646 */ +#line 592 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS; } -#line 2552 "grammar.c" /* yacc.c:1646 */ +#line 2580 "grammar.c" /* yacc.c:1646 */ break; case 96: -#line 565 "grammar.y" /* yacc.c:1646 */ +#line 593 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS_L1; } -#line 2558 "grammar.c" /* yacc.c:1646 */ +#line 2586 "grammar.c" /* yacc.c:1646 */ break; case 97: -#line 566 "grammar.y" /* yacc.c:1646 */ +#line 594 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS_L2; } -#line 2564 "grammar.c" /* yacc.c:1646 */ +#line 2592 "grammar.c" /* yacc.c:1646 */ break; case 98: -#line 567 "grammar.y" /* yacc.c:1646 */ +#line 595 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS_IIH; } -#line 2570 "grammar.c" /* yacc.c:1646 */ +#line 2598 "grammar.c" /* yacc.c:1646 */ break; case 99: -#line 568 "grammar.y" /* yacc.c:1646 */ +#line 596 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS_LSP; } -#line 2576 "grammar.c" /* yacc.c:1646 */ +#line 2604 "grammar.c" /* yacc.c:1646 */ break; case 100: -#line 569 "grammar.y" /* yacc.c:1646 */ +#line 597 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS_SNP; } -#line 2582 "grammar.c" /* yacc.c:1646 */ +#line 2610 "grammar.c" /* yacc.c:1646 */ break; case 101: -#line 570 "grammar.y" /* yacc.c:1646 */ +#line 598 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS_PSNP; } -#line 2588 "grammar.c" /* yacc.c:1646 */ +#line 2616 "grammar.c" /* yacc.c:1646 */ break; case 102: -#line 571 "grammar.y" /* yacc.c:1646 */ +#line 599 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_ISIS_CSNP; } -#line 2594 "grammar.c" /* yacc.c:1646 */ +#line 2622 "grammar.c" /* yacc.c:1646 */ break; case 103: -#line 572 "grammar.y" /* yacc.c:1646 */ +#line 600 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_CLNP; } -#line 2600 "grammar.c" /* yacc.c:1646 */ +#line 2628 "grammar.c" /* yacc.c:1646 */ break; case 104: -#line 573 "grammar.y" /* yacc.c:1646 */ +#line 601 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_STP; } -#line 2606 "grammar.c" /* yacc.c:1646 */ +#line 2634 "grammar.c" /* yacc.c:1646 */ break; case 105: -#line 574 "grammar.y" /* yacc.c:1646 */ +#line 602 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_IPX; } -#line 2612 "grammar.c" /* yacc.c:1646 */ +#line 2640 "grammar.c" /* yacc.c:1646 */ break; case 106: -#line 575 "grammar.y" /* yacc.c:1646 */ +#line 603 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_NETBEUI; } -#line 2618 "grammar.c" /* yacc.c:1646 */ +#line 2646 "grammar.c" /* yacc.c:1646 */ break; case 107: -#line 576 "grammar.y" /* yacc.c:1646 */ +#line 604 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = Q_RADIO; } -#line 2624 "grammar.c" /* yacc.c:1646 */ +#line 2652 "grammar.c" /* yacc.c:1646 */ break; case 108: -#line 578 "grammar.y" /* yacc.c:1646 */ +#line 606 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_broadcast(cstate, (yyvsp[-1].i)))); } -#line 2630 "grammar.c" /* yacc.c:1646 */ +#line 2658 "grammar.c" /* yacc.c:1646 */ break; case 109: -#line 579 "grammar.y" /* yacc.c:1646 */ +#line 607 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_multicast(cstate, (yyvsp[-1].i)))); } -#line 2636 "grammar.c" /* yacc.c:1646 */ +#line 2664 "grammar.c" /* yacc.c:1646 */ break; case 110: -#line 580 "grammar.y" /* yacc.c:1646 */ +#line 608 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_less(cstate, (yyvsp[0].h)))); } -#line 2642 "grammar.c" /* yacc.c:1646 */ +#line 2670 "grammar.c" /* yacc.c:1646 */ break; case 111: -#line 581 "grammar.y" /* yacc.c:1646 */ +#line 609 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_greater(cstate, (yyvsp[0].h)))); } -#line 2648 "grammar.c" /* yacc.c:1646 */ +#line 2676 "grammar.c" /* yacc.c:1646 */ break; case 112: -#line 582 "grammar.y" /* yacc.c:1646 */ +#line 610 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_byteop(cstate, (yyvsp[-1].i), (yyvsp[-2].h), (yyvsp[0].h)))); } -#line 2654 "grammar.c" /* yacc.c:1646 */ +#line 2682 "grammar.c" /* yacc.c:1646 */ break; case 113: -#line 583 "grammar.y" /* yacc.c:1646 */ +#line 611 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_inbound(cstate, 0))); } -#line 2660 "grammar.c" /* yacc.c:1646 */ +#line 2688 "grammar.c" /* yacc.c:1646 */ break; case 114: -#line 584 "grammar.y" /* yacc.c:1646 */ +#line 612 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_inbound(cstate, 1))); } -#line 2666 "grammar.c" /* yacc.c:1646 */ +#line 2694 "grammar.c" /* yacc.c:1646 */ break; case 115: -#line 585 "grammar.y" /* yacc.c:1646 */ +#line 613 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_ifindex(cstate, (yyvsp[0].h)))); } -#line 2672 "grammar.c" /* yacc.c:1646 */ +#line 2700 "grammar.c" /* yacc.c:1646 */ break; case 116: -#line 586 "grammar.y" /* yacc.c:1646 */ +#line 614 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_vlan(cstate, (yyvsp[0].h), 1))); } -#line 2678 "grammar.c" /* yacc.c:1646 */ +#line 2706 "grammar.c" /* yacc.c:1646 */ break; case 117: -#line 587 "grammar.y" /* yacc.c:1646 */ +#line 615 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_vlan(cstate, 0, 0))); } -#line 2684 "grammar.c" /* yacc.c:1646 */ +#line 2712 "grammar.c" /* yacc.c:1646 */ break; case 118: -#line 588 "grammar.y" /* yacc.c:1646 */ +#line 616 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_mpls(cstate, (yyvsp[0].h), 1))); } -#line 2690 "grammar.c" /* yacc.c:1646 */ +#line 2718 "grammar.c" /* yacc.c:1646 */ break; case 119: -#line 589 "grammar.y" /* yacc.c:1646 */ +#line 617 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_mpls(cstate, 0, 0))); } -#line 2696 "grammar.c" /* yacc.c:1646 */ +#line 2724 "grammar.c" /* yacc.c:1646 */ break; case 120: -#line 590 "grammar.y" /* yacc.c:1646 */ +#line 618 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoed(cstate))); } -#line 2702 "grammar.c" /* yacc.c:1646 */ +#line 2730 "grammar.c" /* yacc.c:1646 */ break; case 121: -#line 591 "grammar.y" /* yacc.c:1646 */ +#line 619 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoes(cstate, (yyvsp[0].h), 1))); } -#line 2708 "grammar.c" /* yacc.c:1646 */ +#line 2736 "grammar.c" /* yacc.c:1646 */ break; case 122: -#line 592 "grammar.y" /* yacc.c:1646 */ +#line 620 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoes(cstate, 0, 0))); } -#line 2714 "grammar.c" /* yacc.c:1646 */ +#line 2742 "grammar.c" /* yacc.c:1646 */ break; case 123: -#line 593 "grammar.y" /* yacc.c:1646 */ +#line 621 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_geneve(cstate, (yyvsp[0].h), 1))); } -#line 2720 "grammar.c" /* yacc.c:1646 */ +#line 2748 "grammar.c" /* yacc.c:1646 */ break; case 124: -#line 594 "grammar.y" /* yacc.c:1646 */ +#line 622 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_geneve(cstate, 0, 0))); } -#line 2726 "grammar.c" /* yacc.c:1646 */ +#line 2754 "grammar.c" /* yacc.c:1646 */ break; case 125: -#line 595 "grammar.y" /* yacc.c:1646 */ +#line 623 "grammar.y" /* yacc.c:1646 */ { (yyval.rblk) = (yyvsp[0].rblk); } -#line 2732 "grammar.c" /* yacc.c:1646 */ +#line 2760 "grammar.c" /* yacc.c:1646 */ break; case 126: -#line 596 "grammar.y" /* yacc.c:1646 */ +#line 624 "grammar.y" /* yacc.c:1646 */ { (yyval.rblk) = (yyvsp[0].rblk); } -#line 2738 "grammar.c" /* yacc.c:1646 */ +#line 2766 "grammar.c" /* yacc.c:1646 */ break; case 127: -#line 597 "grammar.y" /* yacc.c:1646 */ +#line 625 "grammar.y" /* yacc.c:1646 */ { (yyval.rblk) = (yyvsp[0].rblk); } -#line 2744 "grammar.c" /* yacc.c:1646 */ +#line 2772 "grammar.c" /* yacc.c:1646 */ break; case 128: -#line 600 "grammar.y" /* yacc.c:1646 */ +#line 628 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.rblk) = gen_pf_ifname(cstate, (yyvsp[0].s)))); } -#line 2750 "grammar.c" /* yacc.c:1646 */ +#line 2778 "grammar.c" /* yacc.c:1646 */ break; case 129: -#line 601 "grammar.y" /* yacc.c:1646 */ +#line 629 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.rblk) = gen_pf_ruleset(cstate, (yyvsp[0].s)))); } -#line 2756 "grammar.c" /* yacc.c:1646 */ +#line 2784 "grammar.c" /* yacc.c:1646 */ break; case 130: -#line 602 "grammar.y" /* yacc.c:1646 */ +#line 630 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_rnr(cstate, (yyvsp[0].h)))); } -#line 2762 "grammar.c" /* yacc.c:1646 */ +#line 2790 "grammar.c" /* yacc.c:1646 */ break; case 131: -#line 603 "grammar.y" /* yacc.c:1646 */ +#line 631 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_srnr(cstate, (yyvsp[0].h)))); } -#line 2768 "grammar.c" /* yacc.c:1646 */ +#line 2796 "grammar.c" /* yacc.c:1646 */ break; case 132: -#line 604 "grammar.y" /* yacc.c:1646 */ +#line 632 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_reason(cstate, (yyvsp[0].i)))); } -#line 2774 "grammar.c" /* yacc.c:1646 */ +#line 2802 "grammar.c" /* yacc.c:1646 */ break; case 133: -#line 605 "grammar.y" /* yacc.c:1646 */ +#line 633 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_action(cstate, (yyvsp[0].i)))); } -#line 2780 "grammar.c" /* yacc.c:1646 */ +#line 2808 "grammar.c" /* yacc.c:1646 */ break; case 134: -#line 609 "grammar.y" /* yacc.c:1646 */ +#line 637 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[-2].i) | (yyvsp[0].i), IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK))); } -#line 2789 "grammar.c" /* yacc.c:1646 */ +#line 2817 "grammar.c" /* yacc.c:1646 */ break; case 135: -#line 613 "grammar.y" /* yacc.c:1646 */ +#line 641 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i), IEEE80211_FC0_TYPE_MASK))); } -#line 2797 "grammar.c" /* yacc.c:1646 */ +#line 2825 "grammar.c" /* yacc.c:1646 */ break; case 136: -#line 616 "grammar.y" /* yacc.c:1646 */ +#line 644 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i), IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK))); } -#line 2806 "grammar.c" /* yacc.c:1646 */ +#line 2834 "grammar.c" /* yacc.c:1646 */ break; case 137: -#line 620 "grammar.y" /* yacc.c:1646 */ +#line 648 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_fcdir(cstate, (yyvsp[0].i)))); } -#line 2812 "grammar.c" /* yacc.c:1646 */ +#line 2840 "grammar.c" /* yacc.c:1646 */ break; case 138: -#line 623 "grammar.y" /* yacc.c:1646 */ +#line 651 "grammar.y" /* yacc.c:1646 */ { if (((yyvsp[0].h) & (~IEEE80211_FC0_TYPE_MASK)) != 0) { bpf_set_error(cstate, "invalid 802.11 type value 0x%02x", (yyvsp[0].h)); YYABORT; } (yyval.i) = (int)(yyvsp[0].h); } -#line 2823 "grammar.c" /* yacc.c:1646 */ +#line 2851 "grammar.c" /* yacc.c:1646 */ break; case 139: -#line 629 "grammar.y" /* yacc.c:1646 */ +#line 657 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); (yyval.i) = str2tok((yyvsp[0].s), ieee80211_types); if ((yyval.i) == -1) { @@ -2831,22 +2859,22 @@ yyreduce: YYABORT; } } -#line 2835 "grammar.c" /* yacc.c:1646 */ +#line 2863 "grammar.c" /* yacc.c:1646 */ break; case 140: -#line 638 "grammar.y" /* yacc.c:1646 */ +#line 666 "grammar.y" /* yacc.c:1646 */ { if (((yyvsp[0].h) & (~IEEE80211_FC0_SUBTYPE_MASK)) != 0) { bpf_set_error(cstate, "invalid 802.11 subtype value 0x%02x", (yyvsp[0].h)); YYABORT; } (yyval.i) = (int)(yyvsp[0].h); } -#line 2846 "grammar.c" /* yacc.c:1646 */ +#line 2874 "grammar.c" /* yacc.c:1646 */ break; case 141: -#line 644 "grammar.y" /* yacc.c:1646 */ +#line 672 "grammar.y" /* yacc.c:1646 */ { const struct tok *types = NULL; int i; CHECK_PTR_VAL((yyvsp[0].s)); @@ -2868,11 +2896,11 @@ yyreduce: YYABORT; } } -#line 2872 "grammar.c" /* yacc.c:1646 */ +#line 2900 "grammar.c" /* yacc.c:1646 */ break; case 142: -#line 667 "grammar.y" /* yacc.c:1646 */ +#line 695 "grammar.y" /* yacc.c:1646 */ { int i; CHECK_PTR_VAL((yyvsp[0].s)); for (i = 0;; i++) { @@ -2888,17 +2916,17 @@ yyreduce: } } } -#line 2892 "grammar.c" /* yacc.c:1646 */ +#line 2920 "grammar.c" /* yacc.c:1646 */ break; case 143: -#line 684 "grammar.y" /* yacc.c:1646 */ +#line 712 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_llc(cstate))); } -#line 2898 "grammar.c" /* yacc.c:1646 */ +#line 2926 "grammar.c" /* yacc.c:1646 */ break; case 144: -#line 685 "grammar.y" /* yacc.c:1646 */ +#line 713 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); if (pcap_strcasecmp((yyvsp[0].s), "i") == 0) { CHECK_PTR_VAL(((yyval.rblk) = gen_llc_i(cstate))); @@ -2922,23 +2950,23 @@ yyreduce: } } } -#line 2926 "grammar.c" /* yacc.c:1646 */ +#line 2954 "grammar.c" /* yacc.c:1646 */ break; case 145: -#line 709 "grammar.y" /* yacc.c:1646 */ +#line 737 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.rblk) = gen_llc_s_subtype(cstate, LLC_RNR))); } -#line 2932 "grammar.c" /* yacc.c:1646 */ +#line 2960 "grammar.c" /* yacc.c:1646 */ break; case 146: -#line 712 "grammar.y" /* yacc.c:1646 */ +#line 740 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = (int)(yyvsp[0].h); } -#line 2938 "grammar.c" /* yacc.c:1646 */ +#line 2966 "grammar.c" /* yacc.c:1646 */ break; case 147: -#line 713 "grammar.y" /* yacc.c:1646 */ +#line 741 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); if (pcap_strcasecmp((yyvsp[0].s), "nods") == 0) (yyval.i) = IEEE80211_FC1_DIR_NODS; @@ -2953,412 +2981,412 @@ yyreduce: YYABORT; } } -#line 2957 "grammar.c" /* yacc.c:1646 */ +#line 2985 "grammar.c" /* yacc.c:1646 */ break; case 148: -#line 729 "grammar.y" /* yacc.c:1646 */ +#line 757 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].h); } -#line 2963 "grammar.c" /* yacc.c:1646 */ +#line 2991 "grammar.c" /* yacc.c:1646 */ break; case 149: -#line 730 "grammar.y" /* yacc.c:1646 */ +#line 758 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_INT_VAL(((yyval.i) = pfreason_to_num(cstate, (yyvsp[0].s)))); } -#line 2969 "grammar.c" /* yacc.c:1646 */ +#line 2997 "grammar.c" /* yacc.c:1646 */ break; case 150: -#line 733 "grammar.y" /* yacc.c:1646 */ +#line 761 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_INT_VAL(((yyval.i) = pfaction_to_num(cstate, (yyvsp[0].s)))); } -#line 2975 "grammar.c" /* yacc.c:1646 */ +#line 3003 "grammar.c" /* yacc.c:1646 */ break; case 151: -#line 736 "grammar.y" /* yacc.c:1646 */ +#line 764 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = BPF_JGT; } -#line 2981 "grammar.c" /* yacc.c:1646 */ +#line 3009 "grammar.c" /* yacc.c:1646 */ break; case 152: -#line 737 "grammar.y" /* yacc.c:1646 */ +#line 765 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = BPF_JGE; } -#line 2987 "grammar.c" /* yacc.c:1646 */ +#line 3015 "grammar.c" /* yacc.c:1646 */ break; case 153: -#line 738 "grammar.y" /* yacc.c:1646 */ +#line 766 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = BPF_JEQ; } -#line 2993 "grammar.c" /* yacc.c:1646 */ +#line 3021 "grammar.c" /* yacc.c:1646 */ break; case 154: -#line 740 "grammar.y" /* yacc.c:1646 */ +#line 768 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = BPF_JGT; } -#line 2999 "grammar.c" /* yacc.c:1646 */ +#line 3027 "grammar.c" /* yacc.c:1646 */ break; case 155: -#line 741 "grammar.y" /* yacc.c:1646 */ +#line 769 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = BPF_JGE; } -#line 3005 "grammar.c" /* yacc.c:1646 */ +#line 3033 "grammar.c" /* yacc.c:1646 */ break; case 156: -#line 742 "grammar.y" /* yacc.c:1646 */ +#line 770 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = BPF_JEQ; } -#line 3011 "grammar.c" /* yacc.c:1646 */ +#line 3039 "grammar.c" /* yacc.c:1646 */ break; case 157: -#line 744 "grammar.y" /* yacc.c:1646 */ +#line 772 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_loadi(cstate, (yyvsp[0].h)))); } -#line 3017 "grammar.c" /* yacc.c:1646 */ +#line 3045 "grammar.c" /* yacc.c:1646 */ break; case 159: -#line 747 "grammar.y" /* yacc.c:1646 */ +#line 775 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_load(cstate, (yyvsp[-3].i), (yyvsp[-1].a), 1))); } -#line 3023 "grammar.c" /* yacc.c:1646 */ +#line 3051 "grammar.c" /* yacc.c:1646 */ break; case 160: -#line 748 "grammar.y" /* yacc.c:1646 */ +#line 776 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_load(cstate, (yyvsp[-5].i), (yyvsp[-3].a), (yyvsp[-1].h)))); } -#line 3029 "grammar.c" /* yacc.c:1646 */ +#line 3057 "grammar.c" /* yacc.c:1646 */ break; case 161: -#line 749 "grammar.y" /* yacc.c:1646 */ +#line 777 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_ADD, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3035 "grammar.c" /* yacc.c:1646 */ +#line 3063 "grammar.c" /* yacc.c:1646 */ break; case 162: -#line 750 "grammar.y" /* yacc.c:1646 */ +#line 778 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_SUB, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3041 "grammar.c" /* yacc.c:1646 */ +#line 3069 "grammar.c" /* yacc.c:1646 */ break; case 163: -#line 751 "grammar.y" /* yacc.c:1646 */ +#line 779 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_MUL, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3047 "grammar.c" /* yacc.c:1646 */ +#line 3075 "grammar.c" /* yacc.c:1646 */ break; case 164: -#line 752 "grammar.y" /* yacc.c:1646 */ +#line 780 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_DIV, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3053 "grammar.c" /* yacc.c:1646 */ +#line 3081 "grammar.c" /* yacc.c:1646 */ break; case 165: -#line 753 "grammar.y" /* yacc.c:1646 */ +#line 781 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_MOD, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3059 "grammar.c" /* yacc.c:1646 */ +#line 3087 "grammar.c" /* yacc.c:1646 */ break; case 166: -#line 754 "grammar.y" /* yacc.c:1646 */ +#line 782 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_AND, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3065 "grammar.c" /* yacc.c:1646 */ +#line 3093 "grammar.c" /* yacc.c:1646 */ break; case 167: -#line 755 "grammar.y" /* yacc.c:1646 */ +#line 783 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_OR, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3071 "grammar.c" /* yacc.c:1646 */ +#line 3099 "grammar.c" /* yacc.c:1646 */ break; case 168: -#line 756 "grammar.y" /* yacc.c:1646 */ +#line 784 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_XOR, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3077 "grammar.c" /* yacc.c:1646 */ +#line 3105 "grammar.c" /* yacc.c:1646 */ break; case 169: -#line 757 "grammar.y" /* yacc.c:1646 */ +#line 785 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_LSH, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3083 "grammar.c" /* yacc.c:1646 */ +#line 3111 "grammar.c" /* yacc.c:1646 */ break; case 170: -#line 758 "grammar.y" /* yacc.c:1646 */ +#line 786 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_RSH, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3089 "grammar.c" /* yacc.c:1646 */ +#line 3117 "grammar.c" /* yacc.c:1646 */ break; case 171: -#line 759 "grammar.y" /* yacc.c:1646 */ +#line 787 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_neg(cstate, (yyvsp[0].a)))); } -#line 3095 "grammar.c" /* yacc.c:1646 */ +#line 3123 "grammar.c" /* yacc.c:1646 */ break; case 172: -#line 760 "grammar.y" /* yacc.c:1646 */ +#line 788 "grammar.y" /* yacc.c:1646 */ { (yyval.a) = (yyvsp[-1].a); } -#line 3101 "grammar.c" /* yacc.c:1646 */ +#line 3129 "grammar.c" /* yacc.c:1646 */ break; case 173: -#line 761 "grammar.y" /* yacc.c:1646 */ +#line 789 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.a) = gen_loadlen(cstate))); } -#line 3107 "grammar.c" /* yacc.c:1646 */ +#line 3135 "grammar.c" /* yacc.c:1646 */ break; case 174: -#line 763 "grammar.y" /* yacc.c:1646 */ +#line 791 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = '&'; } -#line 3113 "grammar.c" /* yacc.c:1646 */ +#line 3141 "grammar.c" /* yacc.c:1646 */ break; case 175: -#line 764 "grammar.y" /* yacc.c:1646 */ +#line 792 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = '|'; } -#line 3119 "grammar.c" /* yacc.c:1646 */ +#line 3147 "grammar.c" /* yacc.c:1646 */ break; case 176: -#line 765 "grammar.y" /* yacc.c:1646 */ +#line 793 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = '<'; } -#line 3125 "grammar.c" /* yacc.c:1646 */ +#line 3153 "grammar.c" /* yacc.c:1646 */ break; case 177: -#line 766 "grammar.y" /* yacc.c:1646 */ +#line 794 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = '>'; } -#line 3131 "grammar.c" /* yacc.c:1646 */ +#line 3159 "grammar.c" /* yacc.c:1646 */ break; case 178: -#line 767 "grammar.y" /* yacc.c:1646 */ +#line 795 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = '='; } -#line 3137 "grammar.c" /* yacc.c:1646 */ +#line 3165 "grammar.c" /* yacc.c:1646 */ break; case 180: -#line 770 "grammar.y" /* yacc.c:1646 */ +#line 798 "grammar.y" /* yacc.c:1646 */ { (yyval.h) = (yyvsp[-1].h); } -#line 3143 "grammar.c" /* yacc.c:1646 */ +#line 3171 "grammar.c" /* yacc.c:1646 */ break; case 181: -#line 772 "grammar.y" /* yacc.c:1646 */ +#line 800 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_LANE; } -#line 3149 "grammar.c" /* yacc.c:1646 */ +#line 3177 "grammar.c" /* yacc.c:1646 */ break; case 182: -#line 773 "grammar.y" /* yacc.c:1646 */ +#line 801 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_METAC; } -#line 3155 "grammar.c" /* yacc.c:1646 */ +#line 3183 "grammar.c" /* yacc.c:1646 */ break; case 183: -#line 774 "grammar.y" /* yacc.c:1646 */ +#line 802 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_BCC; } -#line 3161 "grammar.c" /* yacc.c:1646 */ +#line 3189 "grammar.c" /* yacc.c:1646 */ break; case 184: -#line 775 "grammar.y" /* yacc.c:1646 */ +#line 803 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_OAMF4EC; } -#line 3167 "grammar.c" /* yacc.c:1646 */ +#line 3195 "grammar.c" /* yacc.c:1646 */ break; case 185: -#line 776 "grammar.y" /* yacc.c:1646 */ +#line 804 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_OAMF4SC; } -#line 3173 "grammar.c" /* yacc.c:1646 */ +#line 3201 "grammar.c" /* yacc.c:1646 */ break; case 186: -#line 777 "grammar.y" /* yacc.c:1646 */ +#line 805 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_SC; } -#line 3179 "grammar.c" /* yacc.c:1646 */ +#line 3207 "grammar.c" /* yacc.c:1646 */ break; case 187: -#line 778 "grammar.y" /* yacc.c:1646 */ +#line 806 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_ILMIC; } -#line 3185 "grammar.c" /* yacc.c:1646 */ +#line 3213 "grammar.c" /* yacc.c:1646 */ break; case 188: -#line 780 "grammar.y" /* yacc.c:1646 */ +#line 808 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_OAM; } -#line 3191 "grammar.c" /* yacc.c:1646 */ +#line 3219 "grammar.c" /* yacc.c:1646 */ break; case 189: -#line 781 "grammar.y" /* yacc.c:1646 */ +#line 809 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_OAMF4; } -#line 3197 "grammar.c" /* yacc.c:1646 */ +#line 3225 "grammar.c" /* yacc.c:1646 */ break; case 190: -#line 782 "grammar.y" /* yacc.c:1646 */ +#line 810 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_CONNECTMSG; } -#line 3203 "grammar.c" /* yacc.c:1646 */ +#line 3231 "grammar.c" /* yacc.c:1646 */ break; case 191: -#line 783 "grammar.y" /* yacc.c:1646 */ +#line 811 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = A_METACONNECT; } -#line 3209 "grammar.c" /* yacc.c:1646 */ +#line 3237 "grammar.c" /* yacc.c:1646 */ break; case 192: -#line 786 "grammar.y" /* yacc.c:1646 */ +#line 814 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).atmfieldtype = A_VPI; } -#line 3215 "grammar.c" /* yacc.c:1646 */ +#line 3243 "grammar.c" /* yacc.c:1646 */ break; case 193: -#line 787 "grammar.y" /* yacc.c:1646 */ +#line 815 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).atmfieldtype = A_VCI; } -#line 3221 "grammar.c" /* yacc.c:1646 */ +#line 3249 "grammar.c" /* yacc.c:1646 */ break; case 195: -#line 790 "grammar.y" /* yacc.c:1646 */ +#line 818 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (yyvsp[0].h), (yyvsp[-1].i), 0))); } -#line 3227 "grammar.c" /* yacc.c:1646 */ +#line 3255 "grammar.c" /* yacc.c:1646 */ break; case 196: -#line 791 "grammar.y" /* yacc.c:1646 */ +#line 819 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (yyvsp[0].h), (yyvsp[-1].i), 1))); } -#line 3233 "grammar.c" /* yacc.c:1646 */ +#line 3261 "grammar.c" /* yacc.c:1646 */ break; case 197: -#line 792 "grammar.y" /* yacc.c:1646 */ +#line 820 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; } -#line 3239 "grammar.c" /* yacc.c:1646 */ +#line 3267 "grammar.c" /* yacc.c:1646 */ break; case 198: -#line 794 "grammar.y" /* yacc.c:1646 */ +#line 822 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).atmfieldtype = (yyvsp[-1].blk).atmfieldtype; if ((yyval.blk).atmfieldtype == A_VPI || (yyval.blk).atmfieldtype == A_VCI) CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyval.blk).atmfieldtype, (yyvsp[0].h), BPF_JEQ, 0))); } -#line 3250 "grammar.c" /* yacc.c:1646 */ +#line 3278 "grammar.c" /* yacc.c:1646 */ break; case 200: -#line 802 "grammar.y" /* yacc.c:1646 */ +#line 830 "grammar.y" /* yacc.c:1646 */ { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 3256 "grammar.c" /* yacc.c:1646 */ +#line 3284 "grammar.c" /* yacc.c:1646 */ break; case 201: -#line 805 "grammar.y" /* yacc.c:1646 */ +#line 833 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = M_FISU; } -#line 3262 "grammar.c" /* yacc.c:1646 */ +#line 3290 "grammar.c" /* yacc.c:1646 */ break; case 202: -#line 806 "grammar.y" /* yacc.c:1646 */ +#line 834 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = M_LSSU; } -#line 3268 "grammar.c" /* yacc.c:1646 */ +#line 3296 "grammar.c" /* yacc.c:1646 */ break; case 203: -#line 807 "grammar.y" /* yacc.c:1646 */ +#line 835 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = M_MSU; } -#line 3274 "grammar.c" /* yacc.c:1646 */ +#line 3302 "grammar.c" /* yacc.c:1646 */ break; case 204: -#line 808 "grammar.y" /* yacc.c:1646 */ +#line 836 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = MH_FISU; } -#line 3280 "grammar.c" /* yacc.c:1646 */ +#line 3308 "grammar.c" /* yacc.c:1646 */ break; case 205: -#line 809 "grammar.y" /* yacc.c:1646 */ +#line 837 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = MH_LSSU; } -#line 3286 "grammar.c" /* yacc.c:1646 */ +#line 3314 "grammar.c" /* yacc.c:1646 */ break; case 206: -#line 810 "grammar.y" /* yacc.c:1646 */ +#line 838 "grammar.y" /* yacc.c:1646 */ { (yyval.i) = MH_MSU; } -#line 3292 "grammar.c" /* yacc.c:1646 */ +#line 3320 "grammar.c" /* yacc.c:1646 */ break; case 207: -#line 813 "grammar.y" /* yacc.c:1646 */ +#line 841 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = M_SIO; } -#line 3298 "grammar.c" /* yacc.c:1646 */ +#line 3326 "grammar.c" /* yacc.c:1646 */ break; case 208: -#line 814 "grammar.y" /* yacc.c:1646 */ +#line 842 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = M_OPC; } -#line 3304 "grammar.c" /* yacc.c:1646 */ +#line 3332 "grammar.c" /* yacc.c:1646 */ break; case 209: -#line 815 "grammar.y" /* yacc.c:1646 */ +#line 843 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = M_DPC; } -#line 3310 "grammar.c" /* yacc.c:1646 */ +#line 3338 "grammar.c" /* yacc.c:1646 */ break; case 210: -#line 816 "grammar.y" /* yacc.c:1646 */ +#line 844 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = M_SLS; } -#line 3316 "grammar.c" /* yacc.c:1646 */ +#line 3344 "grammar.c" /* yacc.c:1646 */ break; case 211: -#line 817 "grammar.y" /* yacc.c:1646 */ +#line 845 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = MH_SIO; } -#line 3322 "grammar.c" /* yacc.c:1646 */ +#line 3350 "grammar.c" /* yacc.c:1646 */ break; case 212: -#line 818 "grammar.y" /* yacc.c:1646 */ +#line 846 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = MH_OPC; } -#line 3328 "grammar.c" /* yacc.c:1646 */ +#line 3356 "grammar.c" /* yacc.c:1646 */ break; case 213: -#line 819 "grammar.y" /* yacc.c:1646 */ +#line 847 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = MH_DPC; } -#line 3334 "grammar.c" /* yacc.c:1646 */ +#line 3362 "grammar.c" /* yacc.c:1646 */ break; case 214: -#line 820 "grammar.y" /* yacc.c:1646 */ +#line 848 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = MH_SLS; } -#line 3340 "grammar.c" /* yacc.c:1646 */ +#line 3368 "grammar.c" /* yacc.c:1646 */ break; case 216: -#line 823 "grammar.y" /* yacc.c:1646 */ +#line 851 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (yyvsp[0].h), (yyvsp[-1].i), 0))); } -#line 3346 "grammar.c" /* yacc.c:1646 */ +#line 3374 "grammar.c" /* yacc.c:1646 */ break; case 217: -#line 824 "grammar.y" /* yacc.c:1646 */ +#line 852 "grammar.y" /* yacc.c:1646 */ { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (yyvsp[0].h), (yyvsp[-1].i), 1))); } -#line 3352 "grammar.c" /* yacc.c:1646 */ +#line 3380 "grammar.c" /* yacc.c:1646 */ break; case 218: -#line 825 "grammar.y" /* yacc.c:1646 */ +#line 853 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; } -#line 3358 "grammar.c" /* yacc.c:1646 */ +#line 3386 "grammar.c" /* yacc.c:1646 */ break; case 219: -#line 827 "grammar.y" /* yacc.c:1646 */ +#line 855 "grammar.y" /* yacc.c:1646 */ { (yyval.blk).mtp3fieldtype = (yyvsp[-1].blk).mtp3fieldtype; if ((yyval.blk).mtp3fieldtype == M_SIO || @@ -3371,17 +3399,17 @@ yyreduce: (yyval.blk).mtp3fieldtype == MH_SLS) CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyval.blk).mtp3fieldtype, (yyvsp[0].h), BPF_JEQ, 0))); } -#line 3375 "grammar.c" /* yacc.c:1646 */ +#line 3403 "grammar.c" /* yacc.c:1646 */ break; case 221: -#line 841 "grammar.y" /* yacc.c:1646 */ +#line 869 "grammar.y" /* yacc.c:1646 */ { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 3381 "grammar.c" /* yacc.c:1646 */ +#line 3409 "grammar.c" /* yacc.c:1646 */ break; -#line 3385 "grammar.c" /* yacc.c:1646 */ +#line 3413 "grammar.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -3609,5 +3637,5 @@ yyreturn: #endif return yyresult; } -#line 843 "grammar.y" /* yacc.c:1906 */ +#line 871 "grammar.y" /* yacc.c:1906 */ diff --git a/libpcap/grammar.h b/libpcap/grammar.h index 8f3c6566b..61c1e6eef 100644 --- a/libpcap/grammar.h +++ b/libpcap/grammar.h @@ -174,7 +174,7 @@ extern int pcap_debug; union YYSTYPE { -#line 321 "grammar.y" /* yacc.c:1909 */ +#line 349 "grammar.y" /* yacc.c:1909 */ int i; bpf_u_int32 h; diff --git a/libpcap/grammar.y.in b/libpcap/grammar.y.in index 2fbd86153..b6a3d1838 100644 --- a/libpcap/grammar.y.in +++ b/libpcap/grammar.y.in @@ -71,6 +71,13 @@ #include #endif +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include #ifndef _WIN32 @@ -92,17 +99,11 @@ struct rtentry; #include "pcap-int.h" -#include "gencode.h" -#include "grammar.h" #include "scanner.h" -#ifdef HAVE_NET_PFVAR_H -#include -#include -#include -#endif #include "llc.h" #include "ieee80211.h" +#include "pflog.h" #include #ifdef HAVE_OS_PROTO_H @@ -254,60 +255,87 @@ yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg) bpf_set_error(cstate, "can't parse filter expression: %s", msg); } -#ifdef HAVE_NET_PFVAR_H +static const struct tok pflog_reasons[] = { + { PFRES_MATCH, "match" }, + { PFRES_BADOFF, "bad-offset" }, + { PFRES_FRAG, "fragment" }, + { PFRES_SHORT, "short" }, + { PFRES_NORM, "normalize" }, + { PFRES_MEMORY, "memory" }, + { PFRES_TS, "bad-timestamp" }, + { PFRES_CONGEST, "congestion" }, + { PFRES_IPOPTIONS, "ip-option" }, + { PFRES_PROTCKSUM, "proto-cksum" }, + { PFRES_BADSTATE, "state-mismatch" }, + { PFRES_STATEINS, "state-insert" }, + { PFRES_MAXSTATES, "state-limit" }, + { PFRES_SRCLIMIT, "src-limit" }, + { PFRES_SYNPROXY, "synproxy" }, +#if defined(__FreeBSD__) + { PFRES_MAPFAILED, "map-failed" }, +#elif defined(__NetBSD__) + { PFRES_STATELOCKED, "state-locked" }, +#elif defined(__OpenBSD__) + { PFRES_TRANSLATE, "translate" }, + { PFRES_NOROUTE, "no-route" }, +#elif defined(__APPLE__) + { PFRES_DUMMYNET, "dummynet" }, +#endif + { 0, NULL } +}; + static int pfreason_to_num(compiler_state_t *cstate, const char *reason) { - const char *reasons[] = PFRES_NAMES; int i; - for (i = 0; reasons[i]; i++) { - if (pcap_strcasecmp(reason, reasons[i]) == 0) - return (i); - } - bpf_set_error(cstate, "unknown PF reason \"%s\"", reason); - return (-1); + i = str2tok(reason, pflog_reasons); + if (i == -1) + bpf_set_error(cstate, "unknown PF reason \"%s\"", reason); + return (i); } +static const struct tok pflog_actions[] = { + { PF_PASS, "pass" }, + { PF_PASS, "accept" }, /* alias for "pass" */ + { PF_DROP, "drop" }, + { PF_DROP, "block" }, /* alias for "drop" */ + { PF_SCRUB, "scrub" }, + { PF_NOSCRUB, "noscrub" }, + { PF_NAT, "nat" }, + { PF_NONAT, "nonat" }, + { PF_BINAT, "binat" }, + { PF_NOBINAT, "nobinat" }, + { PF_RDR, "rdr" }, + { PF_NORDR, "nordr" }, + { PF_SYNPROXY_DROP, "synproxy-drop" }, +#if defined(__FreeBSD__) + { PF_DEFER, "defer" }, +#elif defined(__OpenBSD__) + { PF_DEFER, "defer" }, + { PF_MATCH, "match" }, + { PF_DIVERT, "divert" }, + { PF_RT, "rt" }, + { PF_AFRT, "afrt" }, +#elif defined(__APPLE__) + { PF_DUMMYNET, "dummynet" }, + { PF_NODUMMYNET, "nodummynet" }, + { PF_NAT64, "nat64" }, + { PF_NONAT64, "nonat64" }, +#endif + { 0, NULL }, +}; + static int pfaction_to_num(compiler_state_t *cstate, const char *action) { - if (pcap_strcasecmp(action, "pass") == 0 || - pcap_strcasecmp(action, "accept") == 0) - return (PF_PASS); - else if (pcap_strcasecmp(action, "drop") == 0 || - pcap_strcasecmp(action, "block") == 0) - return (PF_DROP); -#if HAVE_PF_NAT_THROUGH_PF_NORDR - else if (pcap_strcasecmp(action, "rdr") == 0) - return (PF_RDR); - else if (pcap_strcasecmp(action, "nat") == 0) - return (PF_NAT); - else if (pcap_strcasecmp(action, "binat") == 0) - return (PF_BINAT); - else if (pcap_strcasecmp(action, "nordr") == 0) - return (PF_NORDR); -#endif - else { - bpf_set_error(cstate, "unknown PF action \"%s\"", action); - return (-1); - } -} -#else /* !HAVE_NET_PFVAR_H */ -static int -pfreason_to_num(compiler_state_t *cstate, const char *reason _U_) -{ - bpf_set_error(cstate, "libpcap was compiled on a machine without pf support"); - return (-1); -} + int i; -static int -pfaction_to_num(compiler_state_t *cstate, const char *action _U_) -{ - bpf_set_error(cstate, "libpcap was compiled on a machine without pf support"); - return (-1); + i = str2tok(action, pflog_actions); + if (i == -1) + bpf_set_error(cstate, "unknown PF action \"%s\"", action); + return (i); } -#endif /* HAVE_NET_PFVAR_H */ /* * For calls that might return an "an error occurred" value. diff --git a/libpcap/libpcap.pc.in b/libpcap/libpcap.pc.in index d74cbc55d..629e662ab 100644 --- a/libpcap/libpcap.pc.in +++ b/libpcap/libpcap.pc.in @@ -13,6 +13,7 @@ libdir="@libdir@" Name: libpcap Description: Platform-independent network traffic capture library Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -l@PACKAGE_NAME@ -Libs.private: @LIBS@ +Requires.private: @REQUIRES_PRIVATE@ +Libs: -L${libdir} @RPATH@ -l@PACKAGE_NAME@ +Libs.private: @LIBS_PRIVATE@ Cflags: -I${includedir} diff --git a/libpcap/missing/asprintf.c b/libpcap/missing/asprintf.c index 3aa55ed9d..b65310e1d 100644 --- a/libpcap/missing/asprintf.c +++ b/libpcap/missing/asprintf.c @@ -20,7 +20,7 @@ pcap_vasprintf(char **strp, const char *format, va_list args) int ret; /* - * XXX - the C99 standard says, in section 7.19.6.5 "Thes + * XXX - the C99 standard says, in section 7.19.6.5 "The * nprintf function": * * The snprintf function is equivalent to fprintf, except that diff --git a/libpcap/mkdep b/libpcap/mkdep index 6e8dbd6ff..f85a447a7 100755 --- a/libpcap/mkdep +++ b/libpcap/mkdep @@ -92,7 +92,7 @@ _EOF_ # hack can't deal with anything that requires a search path, and doesn't # even try for anything using bracket (<>) syntax. # -# egrep '^#include[ ]*".*"' /dev/null $* | +# grep -E '^#include[[:blank:]]*".*"' /dev/null $* | # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | # @@ -108,26 +108,7 @@ done $CC $DEPENDENCY_CFLAG $flags $sources | sed " s; \./; ;g - $SED" | -awk '{ - if ($1 != prev) { - if (rec != "") - print rec; - rec = $0; - prev = $1; - } - else { - if (length(rec $2) > 78) { - print rec; - rec = $0; - } - else - rec = rec " " $2 - } -} -END { - print rec -}' >> $TMP + $SED" >> $TMP cat << _EOF_ >> $TMP diff --git a/libpcap/msdos/makefile b/libpcap/msdos/makefile index 599a619f4..84819aae3 100644 --- a/libpcap/msdos/makefile +++ b/libpcap/msdos/makefile @@ -104,7 +104,7 @@ clean: # pkt_rx0.obj: msdos\pkt_rx0.asm -bpf_filt.obj: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h +bpf_filt.obj: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h bpf_imag.obj: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h @@ -134,7 +134,7 @@ nametoad.obj: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h \ pcap-dos.obj: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h \ msdos\pktdrvr.h -pktdrvr.obj: msdos\pktdrvr.c gnuc.h pcap-dos.h pcap-int.h \ +pktdrvr.obj: msdos\pktdrvr.c pcap-dos.h pcap-int.h \ pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc ndis2.obj: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h \ @@ -142,7 +142,7 @@ ndis2.obj: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h \ pkt_rx0.o32: msdos\pkt_rx0.asm -bpf_filt.o32: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h gnuc.h +bpf_filt.o32: bpf_filt.c pcap-int.h pcap.h pcap-bpf.h bpf_imag.o32: bpf_imag.c pcap-int.h pcap.h pcap-bpf.h @@ -172,7 +172,7 @@ nametoad.o32: nametoad.c pcap-int.h pcap.h pcap-bpf.h gencode.h \ pcap-dos.o32: pcap-dos.c pcap.h pcap-bpf.h pcap-dos.h pcap-int.h \ msdos\pktdrvr.h -pktdrvr.o32: msdos\pktdrvr.c gnuc.h pcap-dos.h pcap-int.h \ +pktdrvr.o32: msdos\pktdrvr.c pcap-dos.h pcap-int.h \ pcap.h pcap-bpf.h msdos\pktdrvr.h msdos\pkt_stub.inc ndis2.o32: msdos\ndis2.c pcap-dos.h pcap-int.h pcap.h pcap-bpf.h \ diff --git a/libpcap/nametoaddr.c b/libpcap/nametoaddr.c index c944ad366..7a04a61db 100644 --- a/libpcap/nametoaddr.c +++ b/libpcap/nametoaddr.c @@ -267,7 +267,7 @@ pcap_nametonetaddr(const char *name) * *not* always get set if getnetbyname_r() succeeds. */ np = NULL; - err = getnetbyname_r(name, &result_buf, buf, sizeof buf, &np, + err = getnetbyname_r(name, &result_buf, buf, sizeof buf, &np, &h_errnoval); if (err != 0) { /* @@ -296,16 +296,16 @@ pcap_nametonetaddr(const char *name) else np = &result_buf; #else - /* - * We don't have any getnetbyname_r(); either we have a - * getnetbyname() that uses thread-specific data, in which - * case we're thread-safe (sufficiently recent FreeBSD, - * sufficiently recent Darwin-based OS, sufficiently recent - * HP-UX, sufficiently recent Tru64 UNIX), or we have the - * traditional getnetbyname() (everything else, including - * current NetBSD and OpenBSD), in which case we're not - * thread-safe. - */ + /* + * We don't have any getnetbyname_r(); either we have a + * getnetbyname() that uses thread-specific data, in which + * case we're thread-safe (sufficiently recent FreeBSD, + * sufficiently recent Darwin-based OS, sufficiently recent + * HP-UX, sufficiently recent Tru64 UNIX), or we have the + * traditional getnetbyname() (everything else, including + * current NetBSD and OpenBSD), in which case we're not + * thread-safe. + */ np = getnetbyname(name); #endif if (np != NULL) @@ -552,16 +552,16 @@ pcap_nametoproto(const char *str) else p = &result_buf; #else - /* - * We don't have any getprotobyname_r(); either we have a - * getprotobyname() that uses thread-specific data, in which - * case we're thread-safe (sufficiently recent FreeBSD, - * sufficiently recent Darwin-based OS, sufficiently recent - * HP-UX, sufficiently recent Tru64 UNIX, Windows), or we have + /* + * We don't have any getprotobyname_r(); either we have a + * getprotobyname() that uses thread-specific data, in which + * case we're thread-safe (sufficiently recent FreeBSD, + * sufficiently recent Darwin-based OS, sufficiently recent + * HP-UX, sufficiently recent Tru64 UNIX, Windows), or we have * the traditional getprotobyname() (everything else, including - * current NetBSD and OpenBSD), in which case we're not - * thread-safe. - */ + * current NetBSD and OpenBSD), in which case we're not + * thread-safe. + */ p = getprotobyname(str); #endif if (p != 0) @@ -785,9 +785,14 @@ pcap_ether_hostton(const char *name) { register u_char *ap; u_char a[6]; + char namebuf[1024]; + /* + * In AIX 7.1 and 7.2: int ether_hostton(char *, struct ether_addr *); + */ + pcap_strlcpy(namebuf, name, sizeof(namebuf)); ap = NULL; - if (ether_hostton(name, (struct ether_addr *)a) == 0) { + if (ether_hostton(namebuf, (struct ether_addr *)a) == 0) { ap = (u_char *)malloc(6); if (ap != NULL) memcpy((char *)ap, (char *)a, 6); diff --git a/libpcap/optimize.c b/libpcap/optimize.c index 610a03037..9af4c15d2 100644 --- a/libpcap/optimize.c +++ b/libpcap/optimize.c @@ -32,13 +32,14 @@ #include #include #include - +#include /* for SIZE_MAX */ #include #include "pcap-int.h" #include "gencode.h" #include "optimize.h" +#include "diag-control.h" #ifdef HAVE_OS_PROTO_H #include "os-proto.h" @@ -2098,7 +2099,7 @@ opt_blks(opt_state_t *opt_state, struct icode *ic, int do_stmts) * versions of the machine code, eventually returning * to the first version. (We're really not doing a * full loop detection, we're just testing for two - * passes in a row where where we do nothing but + * passes in a row where we do nothing but * move branches.) */ return; @@ -2421,6 +2422,9 @@ opt_error(opt_state_t *opt_state, const char *fmt, ...) } longjmp(opt_state->top_ctx, 1); /* NOTREACHED */ +#ifdef _AIX + PCAP_UNREACHABLE +#endif /* _AIX */ } /* @@ -2606,7 +2610,7 @@ opt_init(opt_state_t *opt_state, struct icode *ic) } /* - * Make sure the total memory required for both of them dosn't + * Make sure the total memory required for both of them doesn't * overflow. */ if (block_memsize > SIZE_MAX - edge_memsize) { @@ -2895,7 +2899,6 @@ icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp, if (fp == NULL) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc"); - free(fp); return NULL; } memset((char *)fp, 0, sizeof(*fp) * n); @@ -2925,6 +2928,9 @@ conv_error(conv_state_t *conv_state, const char *fmt, ...) va_end(ap); longjmp(conv_state->top_ctx, 1); /* NOTREACHED */ +#ifdef _AIX + PCAP_UNREACHABLE +#endif /* _AIX */ } /* @@ -3023,14 +3029,14 @@ dot_dump_edge(struct icode *ic, struct block *block, FILE *out) * * example DOT for BPF `ip src host 1.1.1.1' is: digraph BPF { - block0 [shape=ellipse, id="block-0" label="BLOCK0\n\n(000) ldh [12]\n(001) jeq #0x800 jt 2 jf 5" tooltip="val[A]=0 val[X]=0"]; - block1 [shape=ellipse, id="block-1" label="BLOCK1\n\n(002) ld [26]\n(003) jeq #0x1010101 jt 4 jf 5" tooltip="val[A]=0 val[X]=0"]; - block2 [shape=ellipse, id="block-2" label="BLOCK2\n\n(004) ret #68" tooltip="val[A]=0 val[X]=0", peripheries=2]; - block3 [shape=ellipse, id="block-3" label="BLOCK3\n\n(005) ret #0" tooltip="val[A]=0 val[X]=0", peripheries=2]; - "block0":se -> "block1":n [label="T"]; - "block0":sw -> "block3":n [label="F"]; - "block1":se -> "block2":n [label="T"]; - "block1":sw -> "block3":n [label="F"]; + block0 [shape=ellipse, id="block-0" label="BLOCK0\n\n(000) ldh [12]\n(001) jeq #0x800 jt 2 jf 5" tooltip="val[A]=0 val[X]=0"]; + block1 [shape=ellipse, id="block-1" label="BLOCK1\n\n(002) ld [26]\n(003) jeq #0x1010101 jt 4 jf 5" tooltip="val[A]=0 val[X]=0"]; + block2 [shape=ellipse, id="block-2" label="BLOCK2\n\n(004) ret #68" tooltip="val[A]=0 val[X]=0", peripheries=2]; + block3 [shape=ellipse, id="block-3" label="BLOCK3\n\n(005) ret #0" tooltip="val[A]=0 val[X]=0", peripheries=2]; + "block0":se -> "block1":n [label="T"]; + "block0":sw -> "block3":n [label="F"]; + "block1":se -> "block2":n [label="T"]; + "block1":sw -> "block3":n [label="F"]; } * * After install graphviz on https://www.graphviz.org/, save it as bpf.dot diff --git a/libpcap/pcap-airpcap.c b/libpcap/pcap-airpcap.c index d986ad9c3..510e4c4e6 100644 --- a/libpcap/pcap-airpcap.c +++ b/libpcap/pcap-airpcap.c @@ -627,6 +627,9 @@ airpcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* * Loop through each packet. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. */ #define bhp ((AirpcapBpfHeader *)bp) n = 0; diff --git a/libpcap/pcap-bpf.c b/libpcap/pcap-bpf.c index f0ccb9656..2898e598d 100644 --- a/libpcap/pcap-bpf.c +++ b/libpcap/pcap-bpf.c @@ -478,7 +478,7 @@ bpf_open(char *errbuf) { int fd = -1; static const char cloning_device[] = "/dev/bpf"; - int n = 0; + u_int n = 0; char device[sizeof "/dev/bpf0000000000"]; static int no_cloning_bpf = 0; @@ -503,12 +503,17 @@ bpf_open(char *errbuf) ((errno != EACCES && errno != ENOENT) || (fd = open(cloning_device, O_RDONLY)) == -1)) { if (errno != ENOENT) { - if (errno == EACCES) + if (errno == EACCES) { fd = PCAP_ERROR_PERM_DENIED; - else + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed - root privileges may be required", + cloning_device); + } else { fd = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, - errno, "(cannot open device) %s", cloning_device); + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "(cannot open device) %s", cloning_device); + } return (fd); } no_cloning_bpf = 1; @@ -521,7 +526,7 @@ bpf_open(char *errbuf) * that isn't in use. */ do { - (void)snprintf(device, sizeof(device), "/dev/bpf%d", n++); + (void)snprintf(device, sizeof(device), "/dev/bpf%u", n++); /* * Initially try a read/write open (to allow the inject * method to work). If that fails due to permission @@ -577,8 +582,9 @@ bpf_open(char *errbuf) * if any. */ fd = PCAP_ERROR_PERM_DENIED; - pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, - errno, "(cannot open BPF device) %s", device); + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed - root privileges may be required", + device); break; default: @@ -655,7 +661,11 @@ bpf_bind(int fd, const char *name, char *errbuf) case ENXIO: /* * There's no such device. + * + * There's nothing more to say, so clear out the + * error message. */ + errbuf[0] = '\0'; return (PCAP_ERROR_NO_SUCH_DEVICE); case ENETDOWN: @@ -1177,6 +1187,9 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* * Loop through each packet. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. */ #ifdef BIOCSTSTAMP #define bhp ((struct bpf_xhdr *)bp) @@ -2191,7 +2204,7 @@ pcap_activate_bpf(pcap_t *p) * * Otherwise, fail. */ - if (errno != BPF_BIND_BUFFER_TOO_BIG) { + if (status != BPF_BIND_BUFFER_TOO_BIG) { /* * Special checks on macOS to deal * with the way monitor mode was @@ -2968,7 +2981,7 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf) } #else static int -get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_) +get_if_flags(const char *name _U_, bpf_u_int32 *flags, char *errbuf _U_) { /* * Nothing we can do other than mark loopback devices as "the @@ -3043,7 +3056,11 @@ monitor_mode(pcap_t *p, int set) case ENXIO: /* * There's no such device. + * + * There's nothing more to say, so clear the + * error message. */ + p->errbuf[0] = '\0'; close(sock); return (PCAP_ERROR_NO_SUCH_DEVICE); diff --git a/libpcap/pcap-bt-linux.c b/libpcap/pcap-bt-linux.c index 8e70febc6..c7bfef1df 100644 --- a/libpcap/pcap-bt-linux.c +++ b/libpcap/pcap-bt-linux.c @@ -98,6 +98,14 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str) goto done; } + /* + * Zero the complete header, which is larger than dev_num because of tail + * padding, to silence Valgrind, which overshoots validating that dev_num + * has been set. + * https://github.com/the-tcpdump-group/libpcap/issues/1083 + * https://bugs.kde.org/show_bug.cgi?id=448464 + */ + memset(dev_list, 0, sizeof(*dev_list)); dev_list->dev_num = HCI_MAX_DEV; if (ioctl(sock, HCIGETDEVLIST, (void *) dev_list) < 0) @@ -359,9 +367,9 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char case HCI_CMSG_DIR: memcpy(&in, CMSG_DATA(cmsg), sizeof in); break; - case HCI_CMSG_TSTAMP: - memcpy(&pkth.ts, CMSG_DATA(cmsg), - sizeof pkth.ts); + case HCI_CMSG_TSTAMP: + memcpy(&pkth.ts, CMSG_DATA(cmsg), + sizeof pkth.ts); break; } cmsg = CMSG_NXTHDR(&msg, cmsg); diff --git a/libpcap/pcap-common.c b/libpcap/pcap-common.c index 51d0666f7..75461b12c 100644 --- a/libpcap/pcap-common.c +++ b/libpcap/pcap-common.c @@ -28,11 +28,6 @@ #include #include "pcap-int.h" -#include "extract.h" -#include "pcap/sll.h" -#include "pcap/usb.h" -#include "pcap/nflog.h" -#include "pcap/can_socketcan.h" #include "pcap-common.h" @@ -168,11 +163,20 @@ #define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */ /* - * These three types are reserved for future use. + * These two types are reserved for future use. */ #define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */ #define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */ -#define LINKTYPE_HDLC 112 /* NetBSD HDLC framing */ + +/* + * Used for NetBSD DLT_HDLC; from looking at the one driver in NetBSD + * that uses it, it's Cisco HDLC, so it's the same as DLT_C_HDLC/ + * LINKTYPE_C_HDLC, but we define a separate value to avoid some + * compatibility issues with programs on NetBSD. + * + * All code should treat LINKTYPE_NETBSD_HDLC and LINKTYPE_C_HDLC the same. + */ +#define LINKTYPE_NETBSD_HDLC 112 /* NetBSD HDLC framing */ #define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */ #define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */ @@ -405,7 +409,7 @@ * DLT_ requested by Gianluca Varenni . * Every frame contains a 32bit A429 label. * More documentation on Arinc 429 can be found at - * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf + * https://web.archive.org/web/20040616233302/https://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf */ #define LINKTYPE_A429 184 @@ -956,13 +960,15 @@ /* * Link-layer header type for upper-protocol layer PDU saves from wireshark. * - * the actual contents are determined by two TAGs stored with each - * packet: - * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the - * original packet. + * the actual contents are determined by two TAGs, one or more of + * which is stored with each packet: * - * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector - * that can make sense of the data stored. + * EXP_PDU_TAG_DISSECTOR_NAME the name of the Wireshark dissector + * that can make sense of the data stored. + * + * EXP_PDU_TAG_HEUR_DISSECTOR_NAME the name of the Wireshark heuristic + * dissector that can make sense of the + * data stored. */ #define LINKTYPE_WIRESHARK_UPPER_PDU 252 @@ -1234,10 +1240,11 @@ static struct linktype_map { { DLT_FR, LINKTYPE_FRELAY }, #endif - { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 }, + { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 }, { DLT_RAW, LINKTYPE_RAW }, { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS }, { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS }, + { DLT_HDLC, LINKTYPE_NETBSD_HDLC }, /* BSD/OS Cisco HDLC */ { DLT_C_HDLC, LINKTYPE_C_HDLC }, @@ -1391,286 +1398,3 @@ max_snaplen_for_dlt(int dlt) return MAXIMUM_SNAPLEN; } } - -/* - * DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or - * LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload, - * with the CAN ID being in host byte order. - * - * When reading a DLT_LINUX_SLL capture file, we need to check for those - * packets and convert the CAN ID from the byte order of the host that - * wrote the file to this host's byte order. - */ -static void -swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf) -{ - u_int caplen = hdr->caplen; - u_int length = hdr->len; - struct sll_header *shdr = (struct sll_header *)buf; - uint16_t protocol; - pcap_can_socketcan_hdr *chdr; - - if (caplen < (u_int) sizeof(struct sll_header) || - length < (u_int) sizeof(struct sll_header)) { - /* Not enough data to have the protocol field */ - return; - } - - protocol = EXTRACT_BE_U_2(&shdr->sll_protocol); - if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD) - return; - - /* - * SocketCAN packet; fix up the packet's header. - */ - chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header)); - if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) || - length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) { - /* Not enough data to have the CAN ID */ - return; - } - chdr->can_id = SWAPLONG(chdr->can_id); -} - -/* - * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host - * byte order when capturing (it's supplied directly from a - * memory-mapped buffer shared by the kernel). - * - * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file, - * we need to convert it from the byte order of the host that wrote - * the file to this host's byte order. - */ -static void -swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, - int header_len_64_bytes) -{ - pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf; - bpf_u_int32 offset = 0; - - /* - * "offset" is the offset *past* the field we're swapping; - * we skip the field *before* checking to make sure - * the captured data length includes the entire field. - */ - - /* - * The URB id is a totally opaque value; do we really need to - * convert it to the reading host's byte order??? - */ - offset += 8; /* skip past id */ - if (hdr->caplen < offset) - return; - uhdr->id = SWAPLL(uhdr->id); - - offset += 4; /* skip past various 1-byte fields */ - - offset += 2; /* skip past bus_id */ - if (hdr->caplen < offset) - return; - uhdr->bus_id = SWAPSHORT(uhdr->bus_id); - - offset += 2; /* skip past various 1-byte fields */ - - offset += 8; /* skip past ts_sec */ - if (hdr->caplen < offset) - return; - uhdr->ts_sec = SWAPLL(uhdr->ts_sec); - - offset += 4; /* skip past ts_usec */ - if (hdr->caplen < offset) - return; - uhdr->ts_usec = SWAPLONG(uhdr->ts_usec); - - offset += 4; /* skip past status */ - if (hdr->caplen < offset) - return; - uhdr->status = SWAPLONG(uhdr->status); - - offset += 4; /* skip past urb_len */ - if (hdr->caplen < offset) - return; - uhdr->urb_len = SWAPLONG(uhdr->urb_len); - - offset += 4; /* skip past data_len */ - if (hdr->caplen < offset) - return; - uhdr->data_len = SWAPLONG(uhdr->data_len); - - if (uhdr->transfer_type == URB_ISOCHRONOUS) { - offset += 4; /* skip past s.iso.error_count */ - if (hdr->caplen < offset) - return; - uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count); - - offset += 4; /* skip past s.iso.numdesc */ - if (hdr->caplen < offset) - return; - uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc); - } else - offset += 8; /* skip USB setup header */ - - /* - * With the old header, there are no isochronous descriptors - * after the header. - * - * With the new header, the actual number of descriptors in - * the header is not s.iso.numdesc, it's ndesc - only the - * first N descriptors, for some value of N, are put into - * the header, and ndesc is set to the actual number copied. - * In addition, if s.iso.numdesc is negative, no descriptors - * are captured, and ndesc is set to 0. - */ - if (header_len_64_bytes) { - /* - * This is either the "version 1" header, with - * 16 bytes of additional fields at the end, or - * a "version 0" header from a memory-mapped - * capture, with 16 bytes of zeroed-out padding - * at the end. Byte swap them as if this were - * a "version 1" header. - */ - offset += 4; /* skip past interval */ - if (hdr->caplen < offset) - return; - uhdr->interval = SWAPLONG(uhdr->interval); - - offset += 4; /* skip past start_frame */ - if (hdr->caplen < offset) - return; - uhdr->start_frame = SWAPLONG(uhdr->start_frame); - - offset += 4; /* skip past xfer_flags */ - if (hdr->caplen < offset) - return; - uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags); - - offset += 4; /* skip past ndesc */ - if (hdr->caplen < offset) - return; - uhdr->ndesc = SWAPLONG(uhdr->ndesc); - - if (uhdr->transfer_type == URB_ISOCHRONOUS) { - /* swap the values in struct linux_usb_isodesc */ - usb_isodesc *pisodesc; - uint32_t i; - - pisodesc = (usb_isodesc *)(void *)(buf+offset); - for (i = 0; i < uhdr->ndesc; i++) { - offset += 4; /* skip past status */ - if (hdr->caplen < offset) - return; - pisodesc->status = SWAPLONG(pisodesc->status); - - offset += 4; /* skip past offset */ - if (hdr->caplen < offset) - return; - pisodesc->offset = SWAPLONG(pisodesc->offset); - - offset += 4; /* skip past len */ - if (hdr->caplen < offset) - return; - pisodesc->len = SWAPLONG(pisodesc->len); - - offset += 4; /* skip past padding */ - - pisodesc++; - } - } - } -} - -/* - * The DLT_NFLOG "packets" have a mixture of big-endian and host-byte-order - * data. They begin with a fixed-length header with big-endian fields, - * followed by a set of TLVs, where the type and length are in host - * byte order but the values are either big-endian or are a raw byte - * sequence that's the same regardless of the host's byte order. - * - * When reading a DLT_NFLOG capture file, we need to convert the type - * and length values from the byte order of the host that wrote the - * file to the byte order of this host. - */ -static void -swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf) -{ - u_char *p = buf; - nflog_hdr_t *nfhdr = (nflog_hdr_t *)buf; - nflog_tlv_t *tlv; - u_int caplen = hdr->caplen; - u_int length = hdr->len; - uint16_t size; - - if (caplen < (u_int) sizeof(nflog_hdr_t) || - length < (u_int) sizeof(nflog_hdr_t)) { - /* Not enough data to have any TLVs. */ - return; - } - - if (nfhdr->nflog_version != 0) { - /* Unknown NFLOG version */ - return; - } - - length -= sizeof(nflog_hdr_t); - caplen -= sizeof(nflog_hdr_t); - p += sizeof(nflog_hdr_t); - - while (caplen >= sizeof(nflog_tlv_t)) { - tlv = (nflog_tlv_t *) p; - - /* Swap the type and length. */ - tlv->tlv_type = SWAPSHORT(tlv->tlv_type); - tlv->tlv_length = SWAPSHORT(tlv->tlv_length); - - /* Get the length of the TLV. */ - size = tlv->tlv_length; - if (size % 4 != 0) - size += 4 - size % 4; - - /* Is the TLV's length less than the minimum? */ - if (size < sizeof(nflog_tlv_t)) { - /* Yes. Give up now. */ - return; - } - - /* Do we have enough data for the full TLV? */ - if (caplen < size || length < size) { - /* No. */ - return; - } - - /* Skip over the TLV. */ - length -= size; - caplen -= size; - p += size; - } -} - -void -swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data) -{ - /* - * Convert pseudo-headers from the byte order of - * the host on which the file was saved to our - * byte order, as necessary. - */ - switch (linktype) { - - case DLT_LINUX_SLL: - swap_linux_sll_header(hdr, data); - break; - - case DLT_USB_LINUX: - swap_linux_usb_header(hdr, data, 0); - break; - - case DLT_USB_LINUX_MMAPPED: - swap_linux_usb_header(hdr, data, 1); - break; - - case DLT_NFLOG: - swap_nflog_header(hdr, data); - break; - } -} diff --git a/libpcap/pcap-common.h b/libpcap/pcap-common.h index 8795a8297..d765c9476 100644 --- a/libpcap/pcap-common.h +++ b/libpcap/pcap-common.h @@ -21,33 +21,8 @@ * pcap-common.h - common code for pcap and pcapng files */ -/* - * We use the "receiver-makes-right" approach to byte order, - * because time is at a premium when we are writing the file. - * In other words, the pcap_file_header and pcap_pkthdr, - * records are written in host byte order. - * Note that the bytes of packet data are written out in the order in - * which they were received, so multi-byte fields in packets are not - * written in host byte order, they're written in whatever order the - * sending machine put them in. - * - * ntoh[ls] aren't sufficient because we might need to swap on a big-endian - * machine (if the file was written in little-end order). - */ -#define SWAPLONG(y) \ - (((((u_int)(y))&0xff)<<24) | \ - ((((u_int)(y))&0xff00)<<8) | \ - ((((u_int)(y))&0xff0000)>>8) | \ - ((((u_int)(y))>>24)&0xff)) -#define SWAPSHORT(y) \ - ((u_short)(((((u_int)(y))&0xff)<<8) | \ - ((((u_int)(y))&0xff00)>>8))) - extern int dlt_to_linktype(int dlt); extern int linktype_to_dlt(int linktype); -extern void swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, - u_char *data); - extern u_int max_snaplen_for_dlt(int dlt); diff --git a/libpcap/pcap-config.1 b/libpcap/pcap-config.1 index fe8d799c2..87ab0accb 100644 --- a/libpcap/pcap-config.1 +++ b/libpcap/pcap-config.1 @@ -68,5 +68,5 @@ dynamically-linked version of libpcap; the .B \-\-static flag causes it to write flags appropriate for compiling with a statically-linked version of libpcap. -.SH "SEE ALSO" +.SH SEE ALSO .BR pcap (3PCAP) diff --git a/libpcap/pcap-config.in b/libpcap/pcap-config.in index 54ca42f07..6039ef33b 100644 --- a/libpcap/pcap-config.in +++ b/libpcap/pcap-config.in @@ -12,13 +12,15 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" includedir="@includedir@" libdir="@libdir@" -V_RPATH_OPT="@V_RPATH_OPT@" LIBS="@LIBS@" -PACKAGE_NAME="@PACKAGE_NAME@" +LIBS_STATIC="@LIBS_STATIC@" +VERSION="@PACKAGE_VERSION@" static=0 +static_pcap_only=0 show_cflags=0 show_libs=0 +show_additional_libs=0 while [ "$#" != 0 ] do case "$1" in @@ -27,6 +29,10 @@ do static=1 ;; + --static-pcap-only) + static_pcap_only=1 + ;; + --cflags) show_cflags=1 ;; @@ -38,49 +44,107 @@ do --additional-libs) show_additional_libs=1 ;; + + -h|--help) + echo "Usage: pcap-config [ --help ] [--version] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]" + exit 0 + ;; + + --version) + echo "$VERSION" + exit 0 + ;; + + *) + echo "pcap-config: Invalid command-line option $1 specified" 1>&2 + echo "Usage: pcap-config [ --help ] [ --static | --static-pcap-only ] [ --libs | --additional-libs ]" 1>&2 + exit 1 + ;; esac shift done -if [ "$V_RPATH_OPT" != "" ] + +# +# If we aren't installing in /usr, then provide a -L flag to let build +# processes find our library. +# +# (We must check $prefix, as $libdir isn't necessarily /usr/lib in this +# case - for example, Linux distributions for 64-bit platforms that +# also provide support for binaries for a 32-bit version of the +# platform may put the 64-bit libraries, the 32-bit libraries, or both +# in directories other than /usr/lib.) +# +if [ "$prefix" != "/usr" ] then - # - # If libdir isn't /usr/lib, add it to the run-time linker path. - # - if [ "$libdir" != "/usr/lib" ] - then - RPATH=$V_RPATH_OPT$libdir - fi + LPATH=-L$libdir fi if [ "$static" = 1 ] then # - # Include LIBS so that the flags include libraries containing - # routines that libpcap uses. + # Include LIBS_STATIC so that the flags include libraries + # containing routines that libpcap uses, and libraries + # containing routines those libraries use, etc., so that a + # completely statically linked program - i.e., linked only with + # static libraries - will be linked with all necessary + # libraries. # if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] then - echo "-I$includedir -L$libdir -lpcap $LIBS" + echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS_STATIC" elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] then - echo "-I$includedir -L$libdir $LIBS" + echo "-I$includedir $LPATH $LIBS_STATIC" elif [ "$show_cflags" = 1 ] then echo "-I$includedir" elif [ "$show_libs" = 1 ] then - echo "-L$libdir -lpcap $LIBS" + echo "$LPATH -l@PACKAGE_NAME@ $LIBS_STATIC" + elif [ "$show_additional_libs" = 1 ] + then + echo "$LIBS_STATIC" + fi +elif [ "$static_pcap_only" = 1 ] +then + # + # Include LIBS so that the flags include libraries + # containing routines that libpcap uses, but not the libraries + # on which libpcap depends, so that an otherwise + # dynamically-linked program, linked statically only with + # libpcap - i.e., linked with a static libpcap and dynamic + # versions of other libraries - will be linked with all + # necessary libraries. + # + if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] + then + echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS" + elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] + then + echo "-I$includedir $LPATH $LIBS" + elif [ "$show_cflags" = 1 ] + then + echo "-I$includedir" + elif [ "$show_libs" = 1 ] + then + echo "$LPATH -l@PACKAGE_NAME@ $LIBS" elif [ "$show_additional_libs" = 1 ] then echo "$LIBS" fi else # - # Omit LIBS - libpcap is assumed to be linked with those - # libraries, so there's no need to do so explicitly. + # Don't included LIBS or LIBS_STATIC, for building a program + # with a dynamic libpcap; libpcap, being a dynamic library, will + # cause all of its dynamic-library dependencies to be pulled in + # at run time. + # + # Do, however, include RPATH, to make sure that, on platforms + # that require this, programs built with this version of + # libpcap can find it at run time. # if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] then - echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME" + echo "-I$includedir $LPATH @RPATH@ -l@PACKAGE_NAME@" elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] then echo "-I$includedir" @@ -89,6 +153,6 @@ else echo "-I$includedir" elif [ "$show_libs" = 1 ] then - echo "-L$libdir $RPATH -l$PACKAGE_NAME" + echo "$LPATH @RPATH@ -l@PACKAGE_NAME@" fi fi diff --git a/libpcap/pcap-dag.c b/libpcap/pcap-dag.c index b207dd84c..f261ead00 100644 --- a/libpcap/pcap-dag.c +++ b/libpcap/pcap-dag.c @@ -213,7 +213,7 @@ static int dag_get_datalink(pcap_t *p); static int dag_setnonblock(pcap_t *p, int nonblock); static void -delete_pcap_dag(pcap_t *p) +delete_pcap_dag(const pcap_t *p) { pcap_dag_node_t *curr = NULL, *prev = NULL; @@ -299,7 +299,7 @@ new_pcap_dag(pcap_t *p) } static unsigned int -dag_erf_ext_header_count(uint8_t * erf, size_t len) +dag_erf_ext_header_count(const uint8_t *erf, size_t len) { uint32_t hdr_num = 0; uint8_t hdr_type; @@ -391,7 +391,12 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) } - /* Process the packets. */ + /* + * Process the packets. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. + */ while (pd->dag_mem_top - pd->dag_mem_bottom >= dag_record_size) { unsigned short packet_len = 0; @@ -731,7 +736,7 @@ dag_inject(pcap_t *p, const void *buf _U_, int size _U_) * API polling parameters. * * snaplen is now also ignored, until we get per-stream slen support. Set - * slen with approprite DAG tool BEFORE pcap_activate(). + * slen with appropriate DAG tool BEFORE pcap_activate(). * * See also pcap(3). */ @@ -788,14 +793,23 @@ static int dag_activate(pcap_t* p) /* * XXX - does this reliably set errno? */ - if (errno == ENOENT) + if (errno == ENOENT) { + /* + * There's nothing more to say, so clear + * the error message. + */ ret = PCAP_ERROR_NO_SUCH_DEVICE; - else if (errno == EPERM || errno == EACCES) + p->errbuf[0] = '\0'; + } else if (errno == EPERM || errno == EACCES) { ret = PCAP_ERROR_PERM_DENIED; - else + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed with %s - additional privileges may be required", + device, (errno == EPERM) ? "EPERM" : "EACCES"); + } else { ret = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "dag_config_init %s", device); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "dag_config_init %s", device); + } goto fail; } @@ -945,7 +959,7 @@ static int dag_activate(pcap_t* p) * Did the user request that they not be stripped? */ if ((s = getenv("ERF_DONT_STRIP_FCS")) != NULL) { - /* Yes. Note the number of bytes that will be + /* Yes. Note the number of 16-bit words that will be supplied. */ p->linktype_ext = LT_FCS_DATALINK_EXT(pd->dag_fcs_bits/16); diff --git a/libpcap/pcap-dll.rc b/libpcap/pcap-dll.rc index fc4f42b26..85de542f0 100644 --- a/libpcap/pcap-dll.rc +++ b/libpcap/pcap-dll.rc @@ -20,12 +20,12 @@ VALUE "Comments", "https://github.com/the-tcpdump-group/libpcap/" VALUE "CompanyName", "The TCPdump Group" VALUE "FileDescription", "System-Independent Interface for User-Level Packet Capture" - VALUE "FileVersion", "PACKAGE_VERSION_DLL" + VALUE "FileVersion", PACKAGE_VERSION VALUE "InternalName", PACKAGE_NAME VALUE "LegalCopyright", "Copyright (c) The TCPdump Group" VALUE "LegalTrademarks", "" - VALUE "OriginalFilename", "wpcap.dll" - VALUE "ProductName", PACKAGE_NAME + VALUE "OriginalFilename", PACKAGE_NAME ".dll" + VALUE "ProductName", "libpcap" VALUE "ProductVersion", PACKAGE_VERSION END END diff --git a/libpcap/pcap-dlpi.c b/libpcap/pcap-dlpi.c index 208a63bc3..16ed52da5 100644 --- a/libpcap/pcap-dlpi.c +++ b/libpcap/pcap-dlpi.c @@ -146,7 +146,7 @@ static int dl_dohpuxbind(int, char *); static int dlpromiscon(pcap_t *, bpf_u_int32); static int dlbindreq(int, bpf_u_int32, char *); static int dlbindack(int, char *, char *, int *); -static int dlokack(int, const char *, char *, char *); +static int dlokack(int, const char *, char *, char *, int *); static int dlinforeq(int, char *); static int dlinfoack(int, char *, char *); @@ -366,8 +366,12 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf) * chop off the unit number, so "dname" is just a device type name. */ cp = split_dname(dname, &unit, errbuf); - if (cp == NULL) + if (cp == NULL) { + /* + * split_dname() has filled in the error message. + */ return (PCAP_ERROR_NO_SUCH_DEVICE); + } *cp = '\0'; /* @@ -383,12 +387,16 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf) */ cp = "/dev/dlpi"; if ((fd = open(cp, O_RDWR)) < 0) { - if (errno == EPERM || errno == EACCES) + if (errno == EPERM || errno == EACCES) { status = PCAP_ERROR_PERM_DENIED; - else + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed with %s - root privilege may be required", + cp, (errno == EPERM) ? "EPERM" : "EACCES"); + } else { status = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, - errno, "%s", cp); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "Attempt to open %s failed", cp); + } return (status); } @@ -419,8 +427,12 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf) * type name. */ cp = split_dname(dname, ppa, errbuf); - if (cp == NULL) + if (cp == NULL) { + /* + * split_dname() has filled in the error message. + */ return (PCAP_ERROR_NO_SUCH_DEVICE); + } /* * Make a copy of the device pathname, and then remove the unit @@ -432,12 +444,18 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf) /* Try device without unit number */ if ((fd = open(dname, O_RDWR)) < 0) { if (errno != ENOENT) { - if (errno == EPERM || errno == EACCES) + if (errno == EPERM || errno == EACCES) { status = PCAP_ERROR_PERM_DENIED; - else + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed with %s - root privilege may be required", + dname, + (errno == EPERM) ? "EPERM" : "EACCES"); + } else { status = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, - errno, "%s", dname); + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "Attempt to open %s failed", dname); + } return (status); } @@ -472,12 +490,19 @@ open_dlpi_device(const char *name, u_int *ppa, char *errbuf) snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: No DLPI device found", name); } else { - if (errno == EPERM || errno == EACCES) + if (errno == EPERM || errno == EACCES) { status = PCAP_ERROR_PERM_DENIED; - else + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed with %s - root privilege may be required", + dname2, + (errno == EPERM) ? "EPERM" : "EACCES"); + } else { status = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(errbuf, - PCAP_ERRBUF_SIZE, errno, "%s", dname2); + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "Attempt to open %s failed", + dname2); + } } return (status); } @@ -915,7 +940,7 @@ dl_doattach(int fd, int ppa, char *ebuf) if (send_request(fd, (char *)&req, sizeof(req), "attach", ebuf) < 0) return (PCAP_ERROR); - err = dlokack(fd, "attach", (char *)buf, ebuf); + err = dlokack(fd, "attach", (char *)buf, ebuf, NULL); if (err < 0) return (err); return (0); @@ -980,6 +1005,7 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level) dl_promiscon_req_t req; bpf_u_int32 buf[MAXDLBUF]; int err; + int uerror; req.dl_primitive = DL_PROMISCON_REQ; req.dl_level = level; @@ -987,9 +1013,16 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level) p->errbuf) < 0) return (PCAP_ERROR); err = dlokack(p->fd, "promiscon" STRINGIFY(level), (char *)buf, - p->errbuf); - if (err < 0) + p->errbuf, &uerror); + if (err < 0) { + if (err == PCAP_ERROR_PERM_DENIED) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to set promiscuous mode failed with %s - root privilege may be required", + (uerror == EPERM) ? "EPERM" : "EACCES"); + err = PCAP_ERROR_PROMISC_PERM_DENIED; + } return (err); + } return (0); } @@ -1196,6 +1229,9 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror break; default: + /* + * Neither EPERM nor EACCES. + */ snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s: %s", what, dlstrerror(errmsgbuf, sizeof (errmsgbuf), dlp->error_ack.dl_errno)); @@ -1452,10 +1488,10 @@ dlbindack(int fd, char *bufp, char *ebuf, int *uerror) } static int -dlokack(int fd, const char *what, char *bufp, char *ebuf) +dlokack(int fd, const char *what, char *bufp, char *ebuf, int *uerror) { - return (recv_ack(fd, DL_OK_ACK_SIZE, what, bufp, ebuf, NULL)); + return (recv_ack(fd, DL_OK_ACK_SIZE, what, bufp, ebuf, uerror)); } @@ -1490,7 +1526,7 @@ dlpassive(int fd, char *ebuf) req.dl_primitive = DL_PASSIVE_REQ; if (send_request(fd, (char *)&req, sizeof(req), "dlpassive", ebuf) == 0) - (void) dlokack(fd, "dlpassive", (char *)buf, ebuf); + (void) dlokack(fd, "dlpassive", (char *)buf, ebuf, NULL); } #endif diff --git a/libpcap/pcap-dos.c b/libpcap/pcap-dos.c index cdd60ea45..897118b1a 100644 --- a/libpcap/pcap-dos.c +++ b/libpcap/pcap-dos.c @@ -12,6 +12,7 @@ #include #include #include +#include /* for INT_MAX */ #include #if defined(USE_32BIT_DRIVERS) @@ -355,7 +356,22 @@ pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data) { int rc, num = 0; - while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(cnt)) + cnt = INT_MAX; + + while (num <= cnt) { if (p->fd <= 0) return (-1); @@ -553,7 +569,7 @@ int pcap_lookupnet (const char *device, bpf_u_int32 *localnet, /* * Get a list of all interfaces that are present and that we probe okay. * Returns -1 on error, 0 otherwise. - * The list may be NULL epty if no interfaces were up and could be opened. + * The list may be NULL empty if no interfaces were up and could be opened. */ int pcap_platform_finddevs (pcap_if_list_t *devlistp, char *errbuf) { @@ -1188,14 +1204,14 @@ static void ndis_close (struct device *dev) static int ndis_open (struct device *dev) { - int promis = (dev->flags & IFF_PROMISC); + int promisc = (dev->flags & IFF_PROMISC); #ifdef USE_NDIS2 - if (!NdisInit(promis)) + if (!NdisInit(promisc)) return (0); return (1); #else - ARGSUSED (promis); + ARGSUSED (promisc); return (0); #endif } diff --git a/libpcap/pcap-dpdk.c b/libpcap/pcap-dpdk.c index 765abe59b..025a67482 100644 --- a/libpcap/pcap-dpdk.c +++ b/libpcap/pcap-dpdk.c @@ -50,7 +50,7 @@ sed -i 's/CONFIG_RTE_BUILD_SHARED_LIB=n/CONFIG_RTE_BUILD_SHARED_LIB=y/' $RTE_SDK You shall learn how to bind nic with DPDK-compatible driver by $RTE_SDK/usertools/dpdk-devbind.py, such as igb_uio. And enable hugepages by dpdk-setup.sh -Then launch the l2fwd with dynamic dirver support. For example: +Then launch the l2fwd with dynamic driver support. For example: $RTE_SDK/examples/l2fwd/$RTE_TARGET/l2fwd -dlibrte_pmd_e1000.so -dlibrte_pmd_ixgbe.so -dlibrte_mempool_ring.so -- -p 0x1 3. Compile libpcap with dpdk options. @@ -85,6 +85,7 @@ env DPDK_CFG="--log-level=debug -l0 -dlibrte_pmd_e1000.so -dlibrte_pmd_ixgbe.so #include #include #include +#include /* for INT_MAX */ #include #include @@ -331,13 +332,28 @@ static int pcap_dpdk_dispatch(pcap_t *p, int max_cnt, pcap_handler cb, u_char *c u_char *large_buffer=NULL; int timeout_ms = p->opt.timeout; - if ( !PACKET_COUNT_IS_UNLIMITED(max_cnt) && max_cnt < MAX_PKT_BURST){ + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(max_cnt)) + max_cnt = INT_MAX; + + if (max_cnt < MAX_PKT_BURST){ burst_cnt = max_cnt; }else{ burst_cnt = MAX_PKT_BURST; } - while( PACKET_COUNT_IS_UNLIMITED(max_cnt) || pkt_cnt < max_cnt){ + while( pkt_cnt < max_cnt){ if (p->break_loop){ p->break_loop = 0; return PCAP_ERROR_BREAK; diff --git a/libpcap/pcap-filter.manmisc.in b/libpcap/pcap-filter.manmisc.in index b4296901b..4b44cee9c 100644 --- a/libpcap/pcap-filter.manmisc.in +++ b/libpcap/pcap-filter.manmisc.in @@ -18,14 +18,14 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP-FILTER @MAN_MISC_INFO@ "6 February 2021" +.TH PCAP-FILTER @MAN_MISC_INFO@ "19 November 2022" .SH NAME pcap-filter \- packet filter syntax .br .ad .SH DESCRIPTION .LP -.BR pcap_compile () +.BR pcap_compile (3PCAP) is used to compile a string into a filter program. The resulting filter program can then be applied to some stream of packets to determine which packets will be supplied to @@ -88,7 +88,7 @@ qualifiers are only valid for IEEE 802.11 Wireless LAN link layers. .I proto qualifiers restrict the match to a particular protocol. Possible -protos are: +protocols are: .BR ether , .BR fddi , .BR tr , @@ -98,18 +98,19 @@ protos are: .BR arp , .BR rarp , .BR decnet , +.BR sctp , .B tcp and .BR udp . E.g., `\fBether src\fP foo', `\fBarp net\fP 128.3', `\fBtcp port\fP 21', `\fBudp portrange\fP 7000-7009', `\fBwlan addr2\fP 0:2:3:4:5:6'. -If there is -no proto qualifier, all protocols consistent with the type are -assumed. -E.g., `\fBsrc\fP foo' means `\fB(ip or arp or rarp) src\fP foo' -(except the latter is not legal syntax), `\fBnet\fP bar' means `\fB(ip or -arp or rarp) net\fP bar' and `\fBport\fP 53' means `\fB(tcp or udp) -port\fP 53'. +If there is no +.I proto +qualifier, all protocols consistent with the type are assumed. +E.g., `\fBsrc\fP foo' means `\fB(ip or arp or rarp) src\fP foo', +`\fBnet\fP bar' means `\fB(ip or arp or rarp) net\fP bar' and +`\fBport\fP 53' means `\fB(tcp or udp or sctp) port\fP 53' +(note that these examples use invalid syntax to illustrate the principle). .LP [\fBfddi\fP is actually an alias for \fBether\fP; the parser treats them identically as meaning ``the data link level used on the specified @@ -149,40 +150,40 @@ E.g., `\fBtcp dst port\fP ftp \fBor tcp dst port\fP ftp-data \fBor tcp dst port\fP domain'. .LP Allowable primitives are: -.IP "\fBdst host \fIhost\fR" -True if the IPv4/v6 destination field of the packet is \fIhost\fP, +.IP "\fBdst host \fIhostnameaddr\fR" +True if the IPv4/v6 destination field of the packet is \fIhostnameaddr\fP, which may be either an address or a name. -.IP "\fBsrc host \fIhost\fR" -True if the IPv4/v6 source field of the packet is \fIhost\fP. -.IP "\fBhost \fIhost\fP" -True if either the IPv4/v6 source or destination of the packet is \fIhost\fP. +.IP "\fBsrc host \fIhostnameaddr\fR" +True if the IPv4/v6 source field of the packet is \fIhostnameaddr\fP. +.IP "\fBhost \fIhostnameaddr\fP" +True if either the IPv4/v6 source or destination of the packet is \fIhostnameaddr\fP. .IP Any of the above host expressions can be prepended with the keywords, \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in: .in +.5i .nf -\fBip host \fIhost\fR +\fBip host \fIhostnameaddr\fR .fi .in -.5i which is equivalent to: .in +.5i .nf -\fBether proto \\ip and host \fIhost\fR +\fBether proto \\\fRip \fBand host \fIhostnameaddr\fR .fi .in -.5i -If \fIhost\fR is a name with multiple IPv4 addresses, each address will +If \fIhostnameaddr\fR is a name with multiple IPv4/v6 addresses, each address will be checked for a match. -.IP "\fBether dst \fIehost\fP" -True if the Ethernet destination address is \fIehost\fP. -\fIEhost\fP +.IP "\fBether dst \fIethernameaddr\fP" +True if the Ethernet destination address is \fIethernameaddr\fP. +\fIethernameaddr\fP may be either a name from /etc/ethers or a numerical MAC address of the form "xx:xx:xx:xx:xx:xx", "xx.xx.xx.xx.xx.xx", "xx-xx-xx-xx-xx-xx", "xxxx.xxxx.xxxx", "xxxxxxxxxxxx", or various mixes of ':', '.', and '-', where each "x" is a hex digit (0-9, a-f, or A-F). -.IP "\fBether src \fIehost\fP" -True if the Ethernet source address is \fIehost\fP. -.IP "\fBether host \fIehost\fP" -True if either the Ethernet source or destination address is \fIehost\fP. +.IP "\fBether src \fIethernameaddr\fP" +True if the Ethernet source address is \fIethernameaddr\fP. +.IP "\fBether host \fIethernameaddr\fP" +True if either the Ethernet source or destination address is \fIethernameaddr\fP. .IP "\fBgateway\fP \fIhost\fP" True if the packet used \fIhost\fP as a gateway. I.e., the Ethernet @@ -195,14 +196,14 @@ host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.). (An equivalent expression is .in +.5i .nf -\fBether host \fIehost \fBand not host \fIhost\fR +\fBether host \fIethernameaddr \fBand not host \fIhostnameaddr\fR .fi .in -.5i -which can be used with either names or numbers for \fIhost / ehost\fP.) +which can be used with either names or numbers for \fIhostnameaddr / ethernameaddr\fP.) This syntax does not work in IPv6-enabled configuration at this moment. -.IP "\fBdst net \fInet\fR" +.IP "\fBdst net \fInetnameaddr\fR" True if the IPv4/v6 destination address of the packet has a network -number of \fInet\fP. +number of \fInetnameaddr\fP. \fINet\fP may be either a name from the networks database (/etc/networks, etc.) or a network number. An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0), @@ -213,24 +214,24 @@ triple, 255.255.0.0 for a dotted pair, or 255.0.0.0 for a single number. An IPv6 network number must be written out fully; the netmask is ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network" matches are really always host matches, and a network match requires a netmask length. -.IP "\fBsrc net \fInet\fR" +.IP "\fBsrc net \fInetnameaddr\fR" True if the IPv4/v6 source address of the packet has a network -number of \fInet\fP. -.IP "\fBnet \fInet\fR" +number of \fInetnameaddr\fP. +.IP "\fBnet \fInetnameaddr\fR" True if either the IPv4/v6 source or destination address of the packet has a network -number of \fInet\fP. -.IP "\fBnet \fInet\fR \fBmask \fInetmask\fR" -True if the IPv4 address matches \fInet\fR with the specific \fInetmask\fR. +number of \fInetnameaddr\fP. +.IP "\fBnet \fInetaddr\fR \fBmask \fInetmask\fR" +True if the IPv4 address matches \fInetaddr\fR with the specific \fInetmask\fR. May be qualified with \fBsrc\fR or \fBdst\fR. -Note that this syntax is not valid for IPv6 \fInet\fR. -.IP "\fBnet \fInet\fR/\fIlen\fR" -True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR +Note that this syntax is not valid for IPv6 \fInetaddr\fR. +.IP "\fBnet \fInetaddr\fR/\fIlen\fR" +True if the IPv4/v6 address matches \fInetaddr\fR with a netmask \fIlen\fR bits wide. May be qualified with \fBsrc\fR or \fBdst\fR. -.IP "\fBdst port \fIport\fR" -True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or IPv6 UDP and has a -destination port value of \fIport\fP. -The \fIport\fP can be a number or a name used in /etc/services (see +.IP "\fBdst port \fIportnamenum\fR" +True if the packet is IPv4/v6 TCP, UDP or SCTP and has a +destination port value of \fIportnamenum\fP. +The \fIportnamenum\fP can be a number or a name used in /etc/services (see .BR tcp (4P) and .BR udp (4P)). @@ -238,37 +239,37 @@ If a name is used, both the port number and protocol are checked. If a number or ambiguous name is used, only the port number is checked (e.g., `\fBdst port\fR 513' will print both -tcp/login traffic and udp/who traffic, and `\fBport domain\fR' will print +tcp/login traffic and udp/who traffic, and `\fBport\fR domain' will print both tcp/domain and udp/domain traffic). -.IP "\fBsrc port \fIport\fR" -True if the packet has a source port value of \fIport\fP. -.IP "\fBport \fIport\fR" -True if either the source or destination port of the packet is \fIport\fP. -.IP "\fBdst portrange \fIport1-port2\fR" -True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or IPv6 UDP and has a -destination port value between \fIport1\fP and \fIport2\fP (both inclusive). -.I port1 +.IP "\fBsrc port \fIportnamenum\fR" +True if the packet has a source port value of \fIportnamenum\fP. +.IP "\fBport \fIportnamenum\fR" +True if either the source or destination port of the packet is \fIportnamenum\fP. +.IP "\fBdst portrange \fIportnamenum1-portnamenum2\fR" +True if the packet is IPv4/v6 TCP, UDP or SCTP and has a +destination port value between \fIportnamenum1\fP and \fIportnamenum2\fP (both inclusive). +.I portnamenum1 and -.I port2 +.I portnamenum2 are interpreted in the same fashion as the -.I port +.I portnamenum parameter for .BR port . -.IP "\fBsrc portrange \fIport1-port2\fR" -True if the packet has a source port value between \fIport1\fP and -\fIport2\fP (both inclusive). -.IP "\fBportrange \fIport1-port2\fR" +.IP "\fBsrc portrange \fIportnamenum1-portnamenum2\fR" +True if the packet has a source port value between \fIportnamenum1\fP and +\fIportnamenum2\fP (both inclusive). +.IP "\fBportrange \fIportnamenum1-portnamenum2\fR" True if either the source or destination port of the packet is between -\fIport1\fP and \fIport2\fP (both inclusive). +\fIportnamenum1\fP and \fIportnamenum2\fP (both inclusive). .IP Any of the above port or port range expressions can be prepended with -the keywords, \fBtcp\fP or \fBudp\fP, as in: +the keywords, \fBtcp\fP, \fBudp\fP or \fBsctp\fP, as in: .in +.5i .nf -\fBtcp src port \fIport\fR +\fBtcp src port \fIportnamenum\fR .fi .in -.5i -which matches only TCP packets whose source port is \fIport\fP. +which matches only TCP packets whose source port is \fIportnamenum\fP. .IP "\fBless \fIlength\fR" True if the packet has a length less than or equal to \fIlength\fP. This is equivalent to: @@ -289,24 +290,59 @@ This is equivalent to: True if the packet is an IPv4 packet (see .BR ip (4P)) of protocol type \fIprotocol\fP. -\fIProtocol\fP can be a number or one of the names -\fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP, -\fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP. -Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also -keywords and must be escaped via backslash (\\). +\fIProtocol\fP can be a number or one of the names recognized by +.BR getprotobyname (3) +(as in e.g. `\fBgetent\fR(1) protocols'), typically from an entry in +.IR \%/etc/protocols , +for example: +.BR ah , +.BR esp , +.B eigrp +(only in Linux, FreeBSD, NetBSD, DragonFly BSD, and macOS), +.BR icmp , +.BR igmp , +.B igrp +(only in OpenBSD), +.BR pim , +.BR sctp , +.BR tcp , +.B udp +or +.BR vrrp . +Note that most of these example identifiers +are also keywords and must be escaped via backslash (\\). Note that this primitive does not chase the protocol header chain. +.IP "\fBicmp\fR" +Abbreviation for: +.in +.5i +.nf +\fBip proto\fR 1 +.fi +.in -.5i .IP "\fBip6 proto \fIprotocol\fR" True if the packet is an IPv6 packet of protocol type \fIprotocol\fP. +(See `\fBip proto\fP' above for the meaning of \fIprotocol\fR.) +Note that the IPv6 variant of ICMP uses a different protocol number, named +.B \%ipv6-icmp +in AIX, FreeBSD, illumos, Linux, macOS, NetBSD, OpenBSD, Solaris and Windows. Note that this primitive does not chase the protocol header chain. +.IP "\fBicmp6\fR" +Abbreviation for: +.in +.5i +.nf +\fBip6 proto\fR 58 +.fi +.in -.5i .IP "\fBproto \fIprotocol\fR" True if the packet is an IPv4 or IPv6 packet of protocol type -\fIprotocol\fP. Note that this primitive does not chase the protocol +\fIprotocol\fP. (See `\fBip proto\fP' above for the meaning of +\fIprotocol\fP.) Note that this primitive does not chase the protocol header chain. -.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR" +.IP "\fBah\fR, \fBesp\fR, \fBpim\fR, \fBsctp\fR, \fBtcp\fR, \fBudp\fR" Abbreviations for: .in +.5i .nf -\fBproto \\\fIprotocol\fR\fB +\fBproto \\\fIprotocol\fR .fi .in -.5i where \fIprotocol\fR is one of the above protocols. @@ -314,6 +350,7 @@ where \fIprotocol\fR is one of the above protocols. True if the packet is IPv6 packet, and contains protocol header with type \fIprotocol\fR in its protocol header chain. +(See `\fBip proto\fP' above for the meaning of \fIprotocol\fP.) For example, .in +.5i .nf @@ -330,9 +367,11 @@ filter engines in the kernel, so this can be somewhat slow, and may cause more packets to be dropped. .IP "\fBip protochain \fIprotocol\fR" Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4. +(See `\fBip proto\fP' above for the meaning of \fIprotocol\fP.) .IP "\fBprotochain \fIprotocol\fR" True if the packet is an IPv4 or IPv6 packet of protocol type -\fIprotocol\fP. Note that this primitive chases the protocol +\fIprotocol\fP. (See `\fBip proto\fP' above for the meaning of +\fIprotocol\fP.) Note that this primitive chases the protocol header chain. .IP "\fBether broadcast\fR" True if the packet is an Ethernet broadcast packet. @@ -434,19 +473,19 @@ where \fIprotocol\fR is one of the above protocols. Note that not all applications using .BR pcap (3PCAP) currently know how to parse these protocols. -.IP "\fBdecnet src \fIhost\fR" +.IP "\fBdecnet src \fIdecnetaddr\fR" True if the DECnet source address is -.IR host , +.IR decnetaddr , which may be an address of the form ``10.123'', or a DECnet host name. [DECnet host name support is only available on ULTRIX systems that are configured to run DECnet.] -.IP "\fBdecnet dst \fIhost\fR" +.IP "\fBdecnet dst \fIdecnetaddr\fR" True if the DECnet destination address is -.IR host . -.IP "\fBdecnet host \fIhost\fR" +.IR decnetaddr . +.IP "\fBdecnet host \fIdecnetaddr\fR" True if either the DECnet source or destination address is -.IR host . +.IR decnetaddr . .IP \fBllc\fP True if the packet has an 802.2 LLC header. This includes: .IP @@ -535,11 +574,11 @@ modifier. .IP "\fBreason \fIcode\fR" True if the packet was logged with the specified PF reason code. The known codes are: -.BR match , -.BR bad-offset , -.BR fragment , -.BR short , -.BR normalize , +.BR \%match , +.BR \%bad-offset , +.BR \%fragment , +.BR \%short , +.BR \%normalize , and .B memory (applies only to packets logged by OpenBSD's or FreeBSD's @@ -639,27 +678,28 @@ then valid \fIwlan_subtype\fRs are: .IP If the specified \fIwlan_type\fR is \fBdata\fP, then valid \fIwlan_subtype\fRs are: -\fBdata\fP, -\fBdata-cf-ack\fP, -\fBdata-cf-poll\fP, -\fBdata-cf-ack-poll\fP, -\fBnull\fP, -\fBcf-ack\fP, -\fBcf-poll\fP, -\fBcf-ack-poll\fP, -\fBqos-data\fP, -\fBqos-data-cf-ack\fP, -\fBqos-data-cf-poll\fP, -\fBqos-data-cf-ack-poll\fP, -\fBqos\fP, -\fBqos-cf-poll\fP and -\fBqos-cf-ack-poll\fP. +.BR \%data , +.BR \%data-cf-ack , +.BR \%data-cf-poll , +.BR \%data-cf-ack-poll , +.BR \%null , +.BR \%cf-ack , +.BR \%cf-poll , +.BR \%cf-ack-poll , +.BR \%qos-data , +.BR \%qos-data-cf-ack , +.BR \%qos-data-cf-poll , +.BR \%qos-data-cf-ack-poll , +.BR \%qos , +.B \%qos-cf-poll +and +.BR \%qos-cf-ack-poll . .IP "\fBsubtype \fIwlan_subtype\fR" True if the IEEE 802.11 frame subtype matches the specified \fIwlan_subtype\fR and frame has the type to which the specified \fIwlan_subtype\fR belongs. -.IP "\fBdir \fIdir\fR" +.IP "\fBdir \fIdirection\fR" True if the IEEE 802.11 frame direction matches the specified -.IR dir . +.IR direction . Valid directions are: .BR nods , .BR tods , @@ -815,30 +855,98 @@ Connect Ack, Release, or Release Done message. True if the packet is an ATM packet, for SunATM on Solaris, and is on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect, Release, or Release Done message. -.IP "\fIexpr relop expr\fR" -True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, -!=, and \fIexpr\fR is an arithmetic expression composed of integer -constants (expressed in standard C syntax), the normal binary operators -[+, -, *, /, %, &, |, ^, <<, >>], a length operator, and special packet data +.IP "\fIexpr1 relop expr2\fR" +True if the relation holds. \fIRelop\fR is one of +.RB { > , +.BR < , +.BR >= , +.BR <= , +.BR = , +.BR == , +.BR != } +(where +.B = +means the same as +.BR == ). +Each of \fIexpr1\fR and \fIexpr2\fR is an arithmetic expression composed of +integer constants (expressed in standard C syntax), the normal binary operators +.RB { + , +.BR - , +.BR * , +.BR / , +.BR % , +.BR & , +.BR | , +.BR ^ , +.BR << , +.BR >> }, +a length operator, and special packet data accessors. Note that all comparisons are unsigned, so that, for example, 0x80000000 and 0xffffffff are > 0. .IP -The % and ^ operators are currently only supported for filtering in the -kernel on Linux with 3.7 and later kernels; on all other systems, if +The +.B % +and +.B ^ +operators are currently only supported for filtering in the kernel on +particular operating systems (for example: FreeBSD, Linux with 3.7 and later +kernels, NetBSD); on all other systems (for example: AIX, illumos, Solaris, +OpenBSD), if those operators are used, filtering will be done in user mode, which will increase the overhead of capturing packets and may cause more packets to be dropped. .IP +The length operator, indicated by the keyword \fBlen\fP, gives the +length of the packet. +.IP To access data inside the packet, use the following syntax: .in +.5i .nf \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR .fi .in -.5i -\fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link, -ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and +.I Proto +is one of +.BR arp , +.BR atalk , +.BR carp , +.BR decnet , +.BR ether , +.BR fddi , +.BR icmp , +.BR icmp6 , +.BR igmp , +.BR igrp , +.BR ip , +.BR ip6 , +.BR lat , +.BR link , +.BR mopdl , +.BR moprc , +.BR pim , +.BR ppp , +.BR radio , +.BR rarp , +.BR sca , +.BR sctp , +.BR slip , +.BR tcp , +.BR tr , +.BR udp , +.B vrrp +or +.BR wlan , +and indicates the protocol layer for the index operation. -(\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the +.RB ( ether , +.BR fddi , +.BR link , +.BR ppp , +.BR slip , +.B tr +and +.BR wlan +all refer to the link layer. \fBradio\fR refers to the "radio header" added to some 802.11 captures.) Note that \fBtcp\fR, \fBudp\fR and other upper-layer protocol types only @@ -847,8 +955,6 @@ The byte offset, relative to the indicated protocol layer, is given by \fIexpr\fR. \fISize\fR is optional and indicates the number of bytes in the field of interest; it can be either one, two, or four, and defaults to one. -The length operator, indicated by the keyword \fBlen\fP, gives the -length of the packet. For example, `\fBether[\fP0\fB] &\fP 1 \fB!=\fP 0' catches all multicast traffic. The expression `\fBip[\fP0\fB] &\fP 0xf \fB!=\fP 5' @@ -862,37 +968,62 @@ index operations. For instance, \fBtcp[\fP0\fB]\fP always means the first byte of the TCP \fIheader\fP, and never means the first byte of an intervening fragment. - +.IP Some offsets and field values may be expressed as names rather than as numeric values. The following protocol header field offsets are available: \fBicmptype\fP (ICMP type field), \fBicmp6type\fP (ICMPv6 type field), \fBicmpcode\fP (ICMP code field), \fBicmp6code\fP (ICMPv6 code field) and \fBtcpflags\fP (TCP flags field). - -The following ICMP type field values are available: \fBicmp-echoreply\fP, -\fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP, -\fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP, -\fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP, -\fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP, -\fBicmp-maskreq\fP, \fBicmp-maskreply\fP. - -The following ICMPv6 type fields are available: \fBicmp6-destinationrunreach\fP, -\fBicmp6-packettoobig\fP, \fBicmp6-timeexceeded\fP, -\fBicmp6-parameterproblem\fP, \fBicmp6-echo\fP, -\fBicmp6-echoreply\fP, \fBicmp6-multicastlistenerquery\fP, -\fBicmp6-multicastlistenerreportv1\fP, \fBicmp6-multicastlistenerdone\fP, -\fBicmp6-routersolicit\fP, \fBicmp6-routeradvert\fP, -\fBicmp6-neighborsolicit\fP, \fBicmp6-neighboradvert\fP, \fBicmp6-redirect\fP, -\fBicmp6-routerrenum\fP, \fBicmp6-nodeinformationquery\fP, -\fBicmp6-nodeinformationresponse\fP, \fBicmp6-ineighbordiscoverysolicit\fP, -\fBicmp6-ineighbordiscoveryadvert\fP, \fBicmp6-multicastlistenerreportv2\fP, -\fBicmp6-homeagentdiscoveryrequest\fP, \fBicmp6-homeagentdiscoveryreply\fP, -\fBicmp6-mobileprefixsolicit\fP, \fBicmp6-mobileprefixadvert\fP, -\fBicmp6-certpathsolicit\fP, \fBicmp6-certpathadvert\fP, -\fBicmp6-multicastrouteradvert\fP, \fBicmp6-multicastroutersolicit\fP, -\fBicmp6-multicastrouterterm\fP. - +.IP +The following ICMP type field values are available: +.BR \%icmp-echoreply , +.BR \%icmp-unreach , +.BR \%icmp-sourcequench , +.BR \%icmp-redirect , +.BR \%icmp-echo , +.BR \%icmp-routeradvert , +.BR \%icmp-routersolicit , +.BR \%icmp-timxceed , +.BR \%icmp-paramprob , +.BR \%icmp-tstamp , +.BR \%icmp-tstampreply , +.BR \%icmp-ireq , +.BR \%icmp-ireqreply , +.BR \%icmp-maskreq , +.BR \%icmp-maskreply . +.IP +The following ICMPv6 type field values are available: +.BR \%icmp6-destinationunreach , +.BR \%icmp6-packettoobig , +.BR \%icmp6-timeexceeded , +.BR \%icmp6-parameterproblem , +.BR \%icmp6-echo , +.BR \%icmp6-echoreply , +.BR \%icmp6-multicastlistenerquery , +.BR \%icmp6-multicastlistenerreportv1 , +.BR \%icmp6-multicastlistenerdone , +.BR \%icmp6-routersolicit , +.BR \%icmp6-routeradvert , +.BR \%icmp6-neighborsolicit , +.BR \%icmp6-neighboradvert , +.BR \%icmp6-redirect , +.BR \%icmp6-routerrenum , +.BR \%icmp6-nodeinformationquery , +.BR \%icmp6-nodeinformationresponse , +.BR \%icmp6-ineighbordiscoverysolicit , +.BR \%icmp6-ineighbordiscoveryadvert , +.BR \%icmp6-multicastlistenerreportv2 , +.BR \%icmp6-homeagentdiscoveryrequest , +.BR \%icmp6-homeagentdiscoveryreply , +.BR \%icmp6-mobileprefixsolicit , +.BR \%icmp6-mobileprefixadvert , +.BR \%icmp6-certpathsolicit , +.BR \%icmp6-certpathadvert , +.BR \%icmp6-multicastrouteradvert , +.BR \%icmp6-multicastroutersolicit , +.BR \%icmp6-multicastrouterterm . +.IP The following TCP flags field values are available: \fBtcp-fin\fP, \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP, \fBtcp-ack\fP, \fBtcp-urg\fP, \fBtcp-ece\fP, @@ -1033,10 +1164,20 @@ icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply .fi .RE -.SH "SEE ALSO" +.SH BACKWARD COMPATIBILITY +The ICMPv6 type code names, as well as the +.B tcp-ece +and +.B tcp-cwr +TCP flag names became available in libpcap 1.9.0. +.PP +The +.B geneve +keyword became available in libpcap 1.8.0. +.SH SEE ALSO .BR pcap (3PCAP) .SH BUGS -To report a security issue please send an e-mail to security@tcpdump.org. +To report a security issue please send an e-mail to \%security@tcpdump.org. .LP To report bugs and other problems, contribute patches, request a feature, provide generic feedback etc please see the file diff --git a/libpcap/pcap-haiku.cpp b/libpcap/pcap-haiku.cpp index 701cac383..8ae9119c2 100644 --- a/libpcap/pcap-haiku.cpp +++ b/libpcap/pcap-haiku.cpp @@ -47,12 +47,11 @@ prepare_request(struct ifreq& request, const char* name) static int -pcap_read_haiku(pcap_t* handle, int maxPackets, pcap_handler callback, +pcap_read_haiku(pcap_t* handle, int maxPackets _U_, pcap_handler callback, u_char* userdata) { // Receive a single packet - struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv; u_char* buffer = (u_char*)handle->buffer + handle->offset; struct sockaddr_dl from; ssize_t bytesReceived; @@ -160,6 +159,17 @@ pcap_activate_haiku(pcap_t *handle) handle->getnonblock_op = pcap_getnonblock_fd; handle->setnonblock_op = pcap_setnonblock_fd; + /* + * Turn a negative snapshot value (invalid), a snapshot value of + * 0 (unspecified), or a value bigger than the normal maximum + * value, into the maximum allowed value. + * + * If some application really *needs* a bigger snapshot + * length, we should just increase MAXIMUM_SNAPLEN. + */ + if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN) + handle->snapshot = MAXIMUM_SNAPLEN; + handlep->device = strdup(device); if (handlep->device == NULL) { pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE, @@ -238,7 +248,11 @@ pcap_create_interface(const char *device, char *errorBuffer) return NULL; } - pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku); + struct wrapper_struct { pcap_t __common; struct pcap_haiku __private; }; + pcap_t* handle = pcap_create_common(errorBuffer, + sizeof (struct wrapper_struct), + offsetof (struct wrapper_struct, __private)); + if (handle == NULL) { snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "malloc: %s", strerror(errno)); close(socket); @@ -254,7 +268,7 @@ pcap_create_interface(const char *device, char *errorBuffer) } static int -can_be_bound(const char *name) +can_be_bound(const char *name _U_) { return 1; } @@ -280,3 +294,12 @@ pcap_platform_finddevs(pcap_if_list_t* _allDevices, char* errorBuffer) return pcap_findalldevs_interfaces(_allDevices, errorBuffer, can_be_bound, get_if_flags); } + +/* + * Libpcap version string. + */ +extern "C" const char * +pcap_lib_version(void) +{ + return (PCAP_VERSION_STRING); +} diff --git a/libpcap/pcap-int.h b/libpcap/pcap-int.h index dc18d50cb..894e74afa 100644 --- a/libpcap/pcap-int.h +++ b/libpcap/pcap-int.h @@ -52,6 +52,24 @@ #include "portability.h" +/* + * If we're compiling with Visual Studio, make sure we have at least + * VS 2015 or later, so we have sufficient C99 support. + * + * XXX - verify that we have at least C99 support on UN*Xes? + * + * What about MinGW or various DOS toolchains? We're currently assuming + * sufficient C99 support there. + */ +#if defined(_MSC_VER) + /* + * Compiler is MSVC. Make sure we have VS 2015 or later. + */ + #if _MSC_VER < 1900 + #error "Building libpcap requires VS 2015 or later" + #endif +#endif + /* * Version string. * Uses PACKAGE_VERSION from config.h. @@ -467,7 +485,7 @@ pcap_t *pcap_create_interface(const char *, char *); /* * This wrapper takes an error buffer pointer and a type to use for the * private data, and calls pcap_create_common(), passing it the error - * buffer pointer, the size fo the private data type, in bytes, and the + * buffer pointer, the size for the private data type, in bytes, and the * offset of the private data from the beginning of the structure, in * bytes. */ @@ -551,7 +569,7 @@ int add_addr_to_if(pcap_if_list_t *, const char *, bpf_u_int32, /* * This wrapper takes an error buffer pointer and a type to use for the * private data, and calls pcap_create_common(), passing it the error - * buffer pointer, the size fo the private data type, in bytes, and the + * buffer pointer, the size for the private data type, in bytes, and the * offset of the private data from the beginning of the structure, in * bytes. */ diff --git a/libpcap/pcap-libdlpi.c b/libpcap/pcap-libdlpi.c index ef3fdac37..f281fb933 100644 --- a/libpcap/pcap-libdlpi.c +++ b/libpcap/pcap-libdlpi.c @@ -108,15 +108,24 @@ pcap_activate_libdlpi(pcap_t *p) */ retv = dlpi_open(p->opt.device, &dh, DLPI_RAW|DLPI_PASSIVE); if (retv != DLPI_SUCCESS) { - if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK) + if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK) { + /* + * There's nothing more to say, so clear the + * error message. + */ status = PCAP_ERROR_NO_SUCH_DEVICE; - else if (retv == DL_SYSERR && - (errno == EPERM || errno == EACCES)) + p->errbuf[0] = '\0'; + } else if (retv == DL_SYSERR && + (errno == EPERM || errno == EACCES)) { status = PCAP_ERROR_PERM_DENIED; - else + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open DLPI device failed with %s - root privilege may be required", + (errno == EPERM) ? "EPERM" : "EACCES"); + } else { status = PCAP_ERROR; - pcap_libdlpi_err(p->opt.device, "dlpi_open", retv, - p->errbuf); + pcap_libdlpi_err(p->opt.device, "dlpi_open", retv, + p->errbuf); + } return (status); } pd->dlpi_hd = dh; @@ -265,12 +274,25 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level) retv = dlpi_promiscon(pd->dlpi_hd, level); if (retv != DLPI_SUCCESS) { if (retv == DL_SYSERR && - (errno == EPERM || errno == EACCES)) - err = PCAP_ERROR_PERM_DENIED; - else + (errno == EPERM || errno == EACCES)) { + if (level == DL_PROMISC_PHYS) { + err = PCAP_ERROR_PROMISC_PERM_DENIED; + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to set promiscuous mode failed with %s - root privilege may be required", + (errno == EPERM) ? "EPERM" : "EACCES"); + } else { + err = PCAP_ERROR_PERM_DENIED; + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to set %s mode failed with %s - root privilege may be required", + (level == DL_PROMISC_MULTI) ? "multicast" : "SAP promiscuous", + (errno == EPERM) ? "EPERM" : "EACCES"); + } + } else { err = PCAP_ERROR; - pcap_libdlpi_err(p->opt.device, "dlpi_promiscon" STRINGIFY(level), - retv, p->errbuf); + pcap_libdlpi_err(p->opt.device, + "dlpi_promiscon" STRINGIFY(level), + retv, p->errbuf); + } return (err); } return (0); @@ -322,7 +344,7 @@ pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf) linknamelist_t *entry, *next; linkwalk_t lw = {NULL, 0}; - int save_errno; + int save_errno; /* * Get the list of regular interfaces first. diff --git a/libpcap/pcap-linux.c b/libpcap/pcap-linux.c index 878f27f01..13bd8529f 100644 --- a/libpcap/pcap-linux.c +++ b/libpcap/pcap-linux.c @@ -2,7 +2,7 @@ * pcap-linux.c: Packet capture interface to the Linux kernel * * Copyright (c) 2000 Torsten Landschoff - * Sebastian Krahmer + * Sebastian Krahmer * * License: BSD * @@ -100,6 +100,7 @@ #include "pcap-int.h" #include "pcap/sll.h" #include "pcap/vlan.h" +#include "pcap/can_socketcan.h" #include "diag-control.h" @@ -222,7 +223,7 @@ static int get_if_flags(const char *, bpf_u_int32 *, char *); static int is_wifi(const char *); static void map_arphrd_to_dlt(pcap_t *, int, const char *, int); static int pcap_activate_linux(pcap_t *); -static int activate_pf_packet(pcap_t *, int); +static int setup_socket(pcap_t *, int); static int setup_mmapped(pcap_t *, int *); static int pcap_can_set_rfmon_linux(pcap_t *); static int pcap_inject_linux(pcap_t *, const void *, int); @@ -314,14 +315,12 @@ static const struct timeval netdown_timeout = { */ static int iface_get_id(int fd, const char *device, char *ebuf); static int iface_get_mtu(int fd, const char *device, char *ebuf); -static int iface_get_arptype(int fd, const char *device, char *ebuf); -static int iface_bind(int fd, int ifindex, char *ebuf, int protocol); +static int iface_get_arptype(int fd, const char *device, char *ebuf); +static int iface_bind(int fd, int ifindex, char *ebuf, int protocol); static int enter_rfmon_mode(pcap_t *handle, int sock_fd, const char *device); -#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) -static int iface_ethtool_get_ts_info(const char *device, pcap_t *handle, +static int iface_get_ts_types(const char *device, pcap_t *handle, char *ebuf); -#endif static int iface_get_offload(pcap_t *handle); static int fix_program(pcap_t *handle, struct sock_fprog *fcode); @@ -348,15 +347,13 @@ pcap_create_interface(const char *device, char *ebuf) handle->activate_op = pcap_activate_linux; handle->can_set_rfmon_op = pcap_can_set_rfmon_linux; -#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) /* * See what time stamp types we support. */ - if (iface_ethtool_get_ts_info(device, handle, ebuf) == -1) { + if (iface_get_ts_types(device, handle, ebuf) == -1) { pcap_close(handle); return NULL; } -#endif /* * We claim that we support microsecond and nanosecond time @@ -845,7 +842,10 @@ static void pcap_cleanup_linux( pcap_t *handle ) handlep->device = NULL; } - close(handlep->poll_breakloop_fd); + if (handlep->poll_breakloop_fd != -1) { + close(handlep->poll_breakloop_fd); + handlep->poll_breakloop_fd = -1; + } pcap_cleanup_live_common(handle); } @@ -944,7 +944,41 @@ static void pcap_breakloop_linux(pcap_t *handle) uint64_t value = 1; /* XXX - what if this fails? */ - (void)write(handlep->poll_breakloop_fd, &value, sizeof(value)); + if (handlep->poll_breakloop_fd != -1) + (void)write(handlep->poll_breakloop_fd, &value, sizeof(value)); +} + +/* + * Set the offset at which to insert VLAN tags. + * That should be the offset of the type field. + */ +static void +set_vlan_offset(pcap_t *handle) +{ + struct pcap_linux *handlep = handle->priv; + + switch (handle->linktype) { + + case DLT_EN10MB: + /* + * The type field is after the destination and source + * MAC address. + */ + handlep->vlan_offset = 2 * ETH_ALEN; + break; + + case DLT_LINUX_SLL: + /* + * The type field is in the last 2 bytes of the + * DLT_LINUX_SLL header. + */ + handlep->vlan_offset = SLL_HDR_LEN - 2; + break; + + default: + handlep->vlan_offset = -1; /* unknown */ + break; + } } /* @@ -980,6 +1014,11 @@ pcap_activate_linux(pcap_t *handle) * we'll be copying it, that won't fit. */ if (strlen(device) >= sizeof(ifr.ifr_name)) { + /* + * There's nothing more to say, so clear the error + * message. + */ + handle->errbuf[0] = '\0'; status = PCAP_ERROR_NO_SUCH_DEVICE; goto fail; } @@ -1035,7 +1074,7 @@ pcap_activate_linux(pcap_t *handle) * If the "any" device is specified, try to open a SOCK_DGRAM. * Otherwise, open a SOCK_RAW. */ - ret = activate_pf_packet(handle, is_any_device); + ret = setup_socket(handle, is_any_device); if (ret < 0) { /* * Fatal error; the return value is the error code, @@ -1111,6 +1150,13 @@ static int pcap_set_datalink_linux(pcap_t *handle, int dlt) { handle->linktype = dlt; + + /* + * Update the offset at which to insert VLAN tags for the + * new link-layer type. + */ + set_vlan_offset(handle); + return 0; } @@ -1144,9 +1190,12 @@ linux_check_direction(const pcap_t *handle, const struct sockaddr_ll *sll) * easily distinguish packets looped back by the CAN * layer than those received by the CAN layer, so we * eliminate this packet instead. + * + * We check whether this is a CAN or CAN FD frame + * by checking whether the device's hardware type + * is ARPHRD_CAN. */ - if ((sll->sll_protocol == LINUX_SLL_P_CAN || - sll->sll_protocol == LINUX_SLL_P_CANFD) && + if (sll->sll_hatype == ARPHRD_CAN && handle->direction != PCAP_D_OUT) return 0; @@ -1440,7 +1489,7 @@ get_if_ioctl_socket(void) * capture on them, "why do no interfaces show up?" - when the * real problem is a permissions problem. Error reports of that * type require a lot more back-and-forth to debug, as evidenced - * by many Wireshark bugs/mailing list questions/Q&A questoins.) + * by many Wireshark bugs/mailing list questions/Q&A questions.) * * So: * @@ -1612,8 +1661,8 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf) } } fclose(fh); - free(pathstr); } + free(pathstr); } #ifdef ETHTOOL_GLINK @@ -1815,7 +1864,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, * XXX - are there any other sorts of "fake Ethernet" that * have ARPHRD_ETHER but that shouldn't offer DLT_DOCSIS as * a Cisco CMTS won't put traffic onto it or get traffic - * bridged onto it? ISDN is handled in "activate_pf_packet()", + * bridged onto it? ISDN is handled in "setup_socket()", * as we fall back on cooked mode there, and we use * is_wifi() to check for 802.11 devices; are there any * others? @@ -1882,14 +1931,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, #define ARPHRD_CAN 280 #endif case ARPHRD_CAN: - /* - * Map this to DLT_LINUX_SLL; that way, CAN frames will - * have ETH_P_CAN/LINUX_SLL_P_CAN as the protocol and - * CAN FD frames will have ETH_P_CANFD/LINUX_SLL_P_CANFD - * as the protocol, so they can be distinguished by the - * protocol in the SLL header. - */ - handle->linktype = DLT_LINUX_SLL; + handle->linktype = DLT_CAN_SOCKETCAN; break; #ifndef ARPHRD_IEEE802_TR @@ -2171,7 +2213,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, /* We need to save packet direction for IrDA decoding, * so let's use "Linux-cooked" mode. Jean II * - * XXX - this is handled in activate_pf_packet(). */ + * XXX - this is handled in setup_socket(). */ /* handlep->cooked = 1; */ break; @@ -2213,7 +2255,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, * pick up the netlink protocol type such as NETLINK_ROUTE, * NETLINK_GENERIC, NETLINK_FIB_LOOKUP, etc. * - * XXX - this is handled in activate_pf_packet(). + * XXX - this is handled in setup_socket(). */ /* handlep->cooked = 1; */ break; @@ -2231,59 +2273,36 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, } } -#ifdef PACKET_RESERVE static void -set_dlt_list_cooked(pcap_t *handle, int sock_fd) +set_dlt_list_cooked(pcap_t *handle) { - socklen_t len; - unsigned int tp_reserve; + /* + * Support both DLT_LINUX_SLL and DLT_LINUX_SLL2. + */ + handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); /* - * If we can't do PACKET_RESERVE, we can't reserve extra space - * for a DLL_LINUX_SLL2 header, so we can't support DLT_LINUX_SLL2. + * If that failed, just leave the list empty. */ - len = sizeof(tp_reserve); - if (getsockopt(sock_fd, SOL_PACKET, PACKET_RESERVE, &tp_reserve, - &len) == 0) { - /* - * Yes, we can do DLL_LINUX_SLL2. - */ - handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); - /* - * If that fails, just leave the list empty. - */ - if (handle->dlt_list != NULL) { - handle->dlt_list[0] = DLT_LINUX_SLL; - handle->dlt_list[1] = DLT_LINUX_SLL2; - handle->dlt_count = 2; - } + if (handle->dlt_list != NULL) { + handle->dlt_list[0] = DLT_LINUX_SLL; + handle->dlt_list[1] = DLT_LINUX_SLL2; + handle->dlt_count = 2; } } -#else/* PACKET_RESERVE */ -/* - * The build environment doesn't define PACKET_RESERVE, so we can't reserve - * extra space for a DLL_LINUX_SLL2 header, so we can't support DLT_LINUX_SLL2. - */ -static void -set_dlt_list_cooked(pcap_t *handle _U_, int sock_fd _U_) -{ -} -#endif /* PACKET_RESERVE */ /* * Try to set up a PF_PACKET socket. * Returns 0 on success and a PCAP_ERROR_ value on failure. */ static int -activate_pf_packet(pcap_t *handle, int is_any_device) +setup_socket(pcap_t *handle, int is_any_device) { struct pcap_linux *handlep = handle->priv; const char *device = handle->opt.device; int status = 0; int sock_fd, arptype; -#ifdef HAVE_PACKET_AUXDATA int val; -#endif int err = 0; struct packet_mreq mr; #if defined(SO_BPF_EXTENSIONS) && defined(SKF_AD_VLAN_TAG_PRESENT) @@ -2312,6 +2331,8 @@ activate_pf_packet(pcap_t *handle, int is_any_device) * socket. */ status = PCAP_ERROR_PERM_DENIED; + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to create packet socket failed - CAP_NET_RAW may be required"); } else { /* * Other error. @@ -2439,7 +2460,7 @@ activate_pf_packet(pcap_t *handle, int is_any_device) free(handle->dlt_list); handle->dlt_list = NULL; handle->dlt_count = 0; - set_dlt_list_cooked(handle, sock_fd); + set_dlt_list_cooked(handle); } if (handle->linktype == -1) { @@ -2505,7 +2526,7 @@ activate_pf_packet(pcap_t *handle, int is_any_device) handle->linktype = DLT_LINUX_SLL; handle->dlt_list = NULL; handle->dlt_count = 0; - set_dlt_list_cooked(handle, sock_fd); + set_dlt_list_cooked(handle); /* * We're not bound to a device. @@ -2552,9 +2573,15 @@ activate_pf_packet(pcap_t *handle, int is_any_device) } } - /* Enable auxiliary data if supported and reserve room for - * reconstructing VLAN headers. */ -#ifdef HAVE_PACKET_AUXDATA + /* + * Enable auxiliary data and reserve room for reconstructing + * VLAN headers. + * + * XXX - is enabling auxiliary data necessary, now that we + * only support memory-mapped capture? The kernel's memory-mapped + * capture code doesn't seem to check whether auxiliary data + * is enabled, it seems to provide it whether it is or not. + */ val = 1; if (setsockopt(sock_fd, SOL_PACKET, PACKET_AUXDATA, &val, sizeof(val)) == -1 && errno != ENOPROTOOPT) { @@ -2564,7 +2591,6 @@ activate_pf_packet(pcap_t *handle, int is_any_device) return PCAP_ERROR; } handle->offset += VLAN_TAG_LEN; -#endif /* HAVE_PACKET_AUXDATA */ /* * If we're in cooked mode, make the snapshot length @@ -2584,30 +2610,8 @@ activate_pf_packet(pcap_t *handle, int is_any_device) /* * Set the offset at which to insert VLAN tags. - * That should be the offset of the type field. */ - switch (handle->linktype) { - - case DLT_EN10MB: - /* - * The type field is after the destination and source - * MAC address. - */ - handlep->vlan_offset = 2 * ETH_ALEN; - break; - - case DLT_LINUX_SLL: - /* - * The type field is in the last 2 bytes of the - * DLT_LINUX_SLL header. - */ - handlep->vlan_offset = SLL_HDR_LEN - 2; - break; - - default: - handlep->vlan_offset = -1; /* unknown */ - break; - } + set_vlan_offset(handle); if (handle->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO) { int nsec_tstamps = 1; @@ -2678,6 +2682,7 @@ setup_mmapped(pcap_t *handle, int *status) ret = prepare_tpacket_socket(handle); if (ret == -1) { free(handlep->oneshot_buffer); + handlep->oneshot_buffer = NULL; *status = PCAP_ERROR; return ret; } @@ -2688,6 +2693,7 @@ setup_mmapped(pcap_t *handle, int *status) * fail. create_ring() has set *status. */ free(handlep->oneshot_buffer); + handlep->oneshot_buffer = NULL; return -1; } @@ -2889,40 +2895,30 @@ create_ring(pcap_t *handle, int *status) tp_reserve = VLAN_TAG_LEN; /* - * If we're using DLT_LINUX_SLL2, reserve space for a - * DLT_LINUX_SLL2 header. + * If we're capturing in cooked mode, reserve space for + * a DLT_LINUX_SLL2 header; we don't know yet whether + * we'll be using DLT_LINUX_SLL or DLT_LINUX_SLL2, as + * that can be changed on an open device, so we reserve + * space for the larger of the two. * * XXX - we assume that the kernel is still adding - * 16 bytes of extra space; that happens to - * correspond to SLL_HDR_LEN (whether intentionally - * or not - the kernel code has a raw "16" in - * the expression), so we subtract SLL_HDR_LEN - * from SLL2_HDR_LEN to get the additional space - * needed. That also means we don't bother reserving - * any additional space if we're using DLT_LINUX_SLL. + * 16 bytes of extra space, so we subtract 16 from + * SLL2_HDR_LEN to get the additional space needed. + * (Are they doing that for DLT_LINUX_SLL, the link- + * layer header for which is 16 bytes?) * - * XXX - should we use TPACKET_ALIGN(SLL2_HDR_LEN - SLL_HDR_LEN)? + * XXX - should we use TPACKET_ALIGN(SLL2_HDR_LEN - 16)? */ - if (handle->linktype == DLT_LINUX_SLL2) - tp_reserve += SLL2_HDR_LEN - SLL_HDR_LEN; + if (handlep->cooked) + tp_reserve += SLL2_HDR_LEN - 16; /* * Try to request that amount of reserve space. * This must be done before creating the ring buffer. - * If PACKET_RESERVE is supported, creating the ring - * buffer should be, although if creating the ring - * buffer fails, the PACKET_RESERVE call has no effect, - * so falling back on read-from-the-socket capturing - * won't be affected. */ len = sizeof(tp_reserve); if (setsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE, &tp_reserve, len) < 0) { - /* - * We treat ENOPROTOOPT as an error, as we - * already determined that we support - * TPACKET_V2 and later; see above. - */ pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE, errno, "setsockopt (PACKET_RESERVE)"); @@ -3118,6 +3114,9 @@ create_ring(pcap_t *handle, int *status) pcap_strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name)); ifr.ifr_data = (void *)&hwconfig; + /* + * This may require CAP_NET_ADMIN. + */ if (ioctl(handle->fd, SIOCSHWTSTAMP, &ifr) < 0) { switch (errno) { @@ -3130,6 +3129,8 @@ create_ring(pcap_t *handle, int *status) * try requesting hardware time stamps. */ *status = PCAP_ERROR_PERM_DENIED; + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to set hardware timestamp failed - CAP_NET_ADMIN may be required"); return -1; case EOPNOTSUPP: @@ -3378,7 +3379,23 @@ pcap_setnonblock_linux(pcap_t *handle, int nonblock) */ handlep->timeout = ~handlep->timeout; } + if (handlep->poll_breakloop_fd != -1) { + /* Close the eventfd; we do not need it in nonblock mode. */ + close(handlep->poll_breakloop_fd); + handlep->poll_breakloop_fd = -1; + } } else { + if (handlep->poll_breakloop_fd == -1) { + /* If we did not have an eventfd, open one now that we are blocking. */ + if ( ( handlep->poll_breakloop_fd = eventfd(0, EFD_NONBLOCK) ) == -1 ) { + int save_errno = errno; + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Could not open eventfd: %s", + strerror(errno)); + errno = save_errno; + return -1; + } + } if (handlep->timeout < 0) { handlep->timeout = ~handlep->timeout; } @@ -3422,10 +3439,24 @@ static int pcap_wait_for_frames_mmap(pcap_t *handle) struct ifreq ifr; int ret; struct pollfd pollinfo[2]; + int numpollinfo; pollinfo[0].fd = handle->fd; pollinfo[0].events = POLLIN; - pollinfo[1].fd = handlep->poll_breakloop_fd; - pollinfo[1].events = POLLIN; + if ( handlep->poll_breakloop_fd == -1 ) { + numpollinfo = 1; + pollinfo[1].revents = 0; + /* + * We set pollinfo[1].revents to zero, even though + * numpollinfo = 1 meaning that poll() doesn't see + * pollinfo[1], so that we do not have to add a + * conditional of numpollinfo > 1 below when we + * test pollinfo[1].revents. + */ + } else { + pollinfo[1].fd = handlep->poll_breakloop_fd; + pollinfo[1].events = POLLIN; + numpollinfo = 2; + } /* * Keep polling until we either get some packets to read, see @@ -3467,7 +3498,7 @@ static int pcap_wait_for_frames_mmap(pcap_t *handle) * don't need to poll. */ for (;;) { - /* + /* * Yes, we do this even in non-blocking mode, as it's * the only way to get error indications from a * tpacket socket. @@ -3490,7 +3521,7 @@ static int pcap_wait_for_frames_mmap(pcap_t *handle) if (timeout != 0) timeout = 1; } - ret = poll(pollinfo, 2, timeout); + ret = poll(pollinfo, numpollinfo, timeout); if (ret < 0) { /* * Error. If it's not EINTR, report it. @@ -3772,6 +3803,7 @@ static int pcap_handle_packet_mmap( unsigned char *bp; struct sockaddr_ll *sll; struct pcap_pkthdr pcaphdr; + pcap_can_socketcan_hdr *canhdr; unsigned int snaplen = tp_snaplen; struct utsname utsname; @@ -3890,6 +3922,68 @@ static int pcap_handle_packet_mmap( snaplen += sizeof(struct sll_header); } + } else { + /* + * If this is a packet from a CAN device, so that + * sll->sll_hatype is ARPHRD_CAN, then, as we're + * not capturing in cooked mode, its link-layer + * type is DLT_CAN_SOCKETCAN. Fix up the header + * provided by the code below us to match what + * DLT_CAN_SOCKETCAN is expected to provide. + */ + if (sll->sll_hatype == ARPHRD_CAN) { + /* + * DLT_CAN_SOCKETCAN is specified as having the + * CAN ID and flags in network byte order, but + * capturing on a CAN device provides it in host + * byte order. Convert it to network byte order. + */ + canhdr = (pcap_can_socketcan_hdr *)bp; + canhdr->can_id = htonl(canhdr->can_id); + + /* + * In addition, set the CANFD_FDF flag if + * the protocol is LINUX_SLL_P_CANFD, as + * the protocol field itself isn't in + * the packet to indicate that it's a + * CAN FD packet. + */ + uint16_t protocol = ntohs(sll->sll_protocol); + if (protocol == LINUX_SLL_P_CANFD) { + canhdr->fd_flags |= CANFD_FDF; + + /* + * Zero out all the unknown bits in + * fd_flags and clear the reserved + * fields, so that a program reading + * this can assume that CANFD_FDF + * is set because we set it, not + * because some uninitialized crap + * was provided in the fd_flags + * field. + * + * (At least some LINKTYPE_CAN_SOCKETCAN + * files attached to Wireshark bugs + * had uninitialized junk there, so it + * does happen.) + * + * Update this if Linux adds more flag + * bits to the fd_flags field or uses + * either of the reserved fields for + * FD frames. + */ + canhdr->fd_flags &= ~(CANFD_FDF|CANFD_ESI|CANFD_BRS); + canhdr->reserved1 = 0; + canhdr->reserved2 = 0; + } else { + /* + * Clear CANFD_FDF if it's set (probably + * again meaning that this field is + * uninitialized junk). + */ + canhdr->fd_flags &= ~CANFD_FDF; + } + } } if (handlep->filter_in_userland && handle->fcode.bf_insns) { @@ -4002,9 +4096,22 @@ pcap_read_linux_mmap_v2(pcap_t *handle, int max_packets, pcap_handler callback, } } - /* non-positive values of max_packets are used to require all - * packets currently available in the ring */ - while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(max_packets)) + max_packets = INT_MAX; + + while (pkts < max_packets) { /* * Get the current ring buffer frame, and break if * it's still owned by the kernel. @@ -4097,9 +4204,22 @@ again: return pkts; } - /* non-positive values of max_packets are used to require all - * packets currently available in the ring */ - while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(max_packets)) + max_packets = INT_MAX; + + while (pkts < max_packets) { int packets_to_read; if (handlep->current_packet == NULL) { @@ -4112,12 +4232,12 @@ again: } packets_to_read = handlep->packets_left; - if (!PACKET_COUNT_IS_UNLIMITED(max_packets) && - packets_to_read > (max_packets - pkts)) { + if (packets_to_read > (max_packets - pkts)) { /* - * We've been given a maximum number of packets - * to process, and there are more packets in - * this buffer than that. Only process enough + * There are more packets in the buffer than + * the number of packets we have left to + * process to get up to the maximum number + * of packets to process. Only process enough * of them to get us up to that maximum. */ packets_to_read = max_packets - pkts; @@ -4322,7 +4442,18 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter) * the filter for a reason other than "this kernel * isn't configured to support socket filters. */ - if (errno != ENOPROTOOPT && errno != EOPNOTSUPP) { + if (errno == ENOMEM) { + /* + * Either a kernel memory allocation + * failure occurred, or there's too + * much "other/option memory" allocated + * for this socket. Suggest that they + * increase the "other/option memory" + * limit. + */ + fprintf(stderr, + "Warning: Couldn't allocate kernel memory for filter: try increasing net.core.optmem_max with sysctl\n"); + } else if (errno != ENOPROTOOPT && errno != EOPNOTSUPP) { fprintf(stderr, "Warning: Kernel filter failed: %s\n", pcap_strerror(errno)); @@ -4465,12 +4596,18 @@ iface_bind(int fd, int ifindex, char *ebuf, int protocol) */ return PCAP_ERROR_IFACE_NOT_UP; } - if (errno == ENODEV) + if (errno == ENODEV) { + /* + * There's nothing more to say, so clear the + * error message. + */ + ebuf[0] = '\0'; ret = PCAP_ERROR_NO_SUCH_DEVICE; - else + } else { ret = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, - errno, "bind"); + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "bind"); + } return ret; } @@ -4681,12 +4818,12 @@ iface_set_all_ts_types(pcap_t *handle, char *ebuf) return 0; } -#ifdef ETHTOOL_GET_TS_INFO /* - * Get a list of time stamping capabilities. + * Get a list of time stamp types. */ +#ifdef ETHTOOL_GET_TS_INFO static int -iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf) +iface_get_ts_types(const char *device, pcap_t *handle, char *ebuf) { int fd; struct ifreq ifr; @@ -4773,6 +4910,8 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf) * report HWTSTAMP_FILTER_ALL but map it to only * time stamping a few PTP packets. See * http://marc.info/?l=linux-netdev&m=146318183529571&w=2 + * + * Maybe that got fixed later. */ handle->tstamp_type_list = NULL; return 0; @@ -4804,7 +4943,7 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf) } #else /* ETHTOOL_GET_TS_INFO */ static int -iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf) +iface_get_ts_types(const char *device, pcap_t *handle, char *ebuf) { /* * This doesn't apply to the "any" device; you can't say "turn on @@ -4827,7 +4966,15 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf) return 0; } #endif /* ETHTOOL_GET_TS_INFO */ - +#else /* defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) */ +static int +iface_get_ts_types(const char *device _U_, pcap_t *p _U_, char *ebuf _U_) +{ + /* + * Nothing to fetch, so it always "succeeds". + */ + return 0; +} #endif /* defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) */ /* @@ -5093,12 +5240,17 @@ iface_get_arptype(int fd, const char *device, char *ebuf) if (errno == ENODEV) { /* * No such device. + * + * There's nothing more to say, so clear + * the error message. */ ret = PCAP_ERROR_NO_SUCH_DEVICE; - } else + ebuf[0] = '\0'; + } else { ret = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, - errno, "SIOCGIFHWADDR"); + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGIFHWADDR"); + } return ret; } diff --git a/libpcap/pcap-netfilter-linux.c b/libpcap/pcap-netfilter-linux.c index 17f528fc0..2eb0fc8c0 100644 --- a/libpcap/pcap-netfilter-linux.c +++ b/libpcap/pcap-netfilter-linux.c @@ -33,6 +33,7 @@ #endif #include "pcap-int.h" +#include "diag-control.h" #ifdef NEED_STRERROR_H #include "strerror.h" @@ -135,6 +136,13 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c bp = (unsigned char *)handle->buffer; } else bp = handle->bp; + + /* + * Loop through each message. + * + * This assumes that a single buffer of message will have + * <= INT_MAX packets, so the message count doesn't overflow. + */ ep = bp + len; while (bp < ep) { const struct nlmsghdr *nlh = (const struct nlmsghdr *) bp; @@ -343,7 +351,9 @@ netfilter_send_config_msg(const pcap_t *handle, uint16_t msg_type, int ack, u_in static unsigned int seq_id; if (!seq_id) +DIAG_OFF_NARROWING seq_id = time(NULL); +DIAG_ON_NARROWING ++seq_id; nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg)); @@ -516,8 +526,8 @@ netfilter_activate(pcap_t* handle) nftype_t type = OTHER; int i; - if (strncmp(dev, NFLOG_IFACE, strlen(NFLOG_IFACE)) == 0) { - dev += strlen(NFLOG_IFACE); + if (strncmp(dev, NFLOG_IFACE, strlen(NFLOG_IFACE)) == 0) { + dev += strlen(NFLOG_IFACE); type = NFLOG; } else if (strncmp(dev, NFQUEUE_IFACE, strlen(NFQUEUE_IFACE)) == 0) { diff --git a/libpcap/pcap-new.c b/libpcap/pcap-new.c index 7c006595c..76388a998 100644 --- a/libpcap/pcap-new.c +++ b/libpcap/pcap-new.c @@ -36,6 +36,7 @@ #endif #include "ftmacros.h" +#include "diag-control.h" /* * sockutils.h may include on Windows, and pcap-int.h will @@ -237,7 +238,10 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t if (filedata == NULL) { + DIAG_OFF_FORMAT_TRUNCATION snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path); + DIAG_ON_FORMAT_TRUNCATION + closedir(unixdir); return -1; } #endif @@ -253,7 +257,9 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t #else if (pathlen + strlen(filedata->d_name) >= sizeof(filename)) continue; + DIAG_OFF_FORMAT_TRUNCATION snprintf(filename, sizeof(filename), "%s%s", path, filedata->d_name); + DIAG_ON_FORMAT_TRUNCATION #endif fp = pcap_open_offline(filename, errbuf); @@ -268,6 +274,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t PCAP_ERRBUF_SIZE, errno, "malloc() failed"); pcap_freealldevs(*alldevs); +#ifdef _WIN32 + FindClose(filehandle); +#else + closedir(unixdir); +#endif return -1; } @@ -297,6 +308,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t if (pcap_createsrcstr(tmpstring, PCAP_SRC_FILE, NULL, NULL, filename, errbuf) == -1) { pcap_freealldevs(*alldevs); +#ifdef _WIN32 + FindClose(filehandle); +#else + closedir(unixdir); +#endif return -1; } @@ -307,6 +323,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t PCAP_ERRBUF_SIZE, errno, "malloc() failed"); pcap_freealldevs(*alldevs); +#ifdef _WIN32 + FindClose(filehandle); +#else + closedir(unixdir); +#endif return -1; } @@ -321,6 +342,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t PCAP_ERRBUF_SIZE, errno, "malloc() failed"); pcap_freealldevs(*alldevs); +#ifdef _WIN32 + FindClose(filehandle); +#else + closedir(unixdir); +#endif return -1; } @@ -334,9 +360,11 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t #endif -#ifdef _WIN32 /* Close the search handle. */ +#ifdef _WIN32 FindClose(filehandle); +#else + closedir(unixdir); #endif return 0; @@ -444,6 +472,7 @@ pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout, return fp; fail: + DIAG_OFF_FORMAT_TRUNCATION if (status == PCAP_ERROR) snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", name, fp->errbuf); @@ -455,6 +484,7 @@ fail: else snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", name, pcap_statustostr(status)); + DIAG_ON_FORMAT_TRUNCATION pcap_close(fp); return NULL; } diff --git a/libpcap/pcap-nit.c b/libpcap/pcap-nit.c index cfd95191d..6f4f8dd87 100644 --- a/libpcap/pcap-nit.c +++ b/libpcap/pcap-nit.c @@ -125,6 +125,9 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user) * Loop through each packet. The increment expression * rounds up to the next int boundary past the end of * the previous packet. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. */ n = 0; ep = bp + cc; diff --git a/libpcap/pcap-npf.c b/libpcap/pcap-npf.c index 52aee78a9..99b5981e5 100644 --- a/libpcap/pcap-npf.c +++ b/libpcap/pcap-npf.c @@ -36,6 +36,7 @@ #endif #include +#include /* for INT_MAX */ #define PCAP_DONT_INCLUDE_PCAP_BPF_H #include #include @@ -445,6 +446,31 @@ pcap_setuserbuffer_npf(pcap_t *p, int size) return (0); } +#ifdef HAVE_NPCAP_PACKET_API +/* + * Kernel dump mode isn't supported in Npcap; calls to PacketSetDumpName(), + * PacketSetDumpLimits(), and PacketIsDumpEnded() will get compile-time + * deprecation warnings. + * + * Avoid calling them; just return errors indicating that kernel dump + * mode isn't supported in Npcap. + */ +static int +pcap_live_dump_npf(pcap_t *p, char *filename _U_, int maxsize _U_, + int maxpacks _U_) +{ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Npcap doesn't support kernel dump mode"); + return (-1); +} +static int +pcap_live_dump_ended_npf(pcap_t *p, int sync) +{ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Npcap doesn't support kernel dump mode"); + return (-1); +} +#else /* HAVE_NPCAP_PACKET_API */ static int pcap_live_dump_npf(pcap_t *p, char *filename, int maxsize, int maxpacks) { @@ -485,6 +511,7 @@ pcap_live_dump_ended_npf(pcap_t *p, int sync) return (PacketIsDumpEnded(pw->adapter, (BOOLEAN)sync)); } +#endif /* HAVE_NPCAP_PACKET_API */ #ifdef HAVE_AIRPCAP_API static PAirpcapHandle @@ -607,6 +634,9 @@ pcap_read_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* * Loop through each packet. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. */ #define bhp ((struct bpf_hdr *)bp) n = 0; @@ -766,6 +796,21 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user) endofbuf = (char*)header + cc; + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(cnt)) + cnt = INT_MAX; + /* * Cycle through the packets */ @@ -856,7 +901,7 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user) } } - /* No underlaying filtering system. We need to filter on our own */ + /* No underlying filtering system. We need to filter on our own */ if (p->fcode.bf_insns) { if (pcap_filter(p->fcode.bf_insns, dp, packet_len, caplen) == 0) @@ -867,7 +912,7 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user) } } - /* Fill the header for the user suppplied callback function */ + /* Fill the header for the user supplied callback function */ pcap_header.caplen = caplen; pcap_header.len = packet_len; @@ -940,8 +985,6 @@ pcap_breakloop_npf(pcap_t *p) } /* - * Vendor-specific error codes. - * * These are NTSTATUS values: * * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781 @@ -950,15 +993,28 @@ pcap_breakloop_npf(pcap_t *p) * mapped to Windows error values in userland; they're returned by * GetLastError(). * - * Attempting to set non-promiscuous mode on a Microsoft Surface Pro's - * Mobile Broadband Adapter returns an error; that error can safely be - * ignored, as it's always in non-promiscuous mode. + * Note that "driver" here includes the Npcap NPF driver, as various + * versions would take NT status values and set the "Customer" bit + * before returning the status code. The commit message for the + * change that started doing that is + * + * Returned a customer-defined NTSTATUS in OID requests to avoid + * NTSTATUS-to-Win32 Error code translation. + * + * but I don't know why the goal was to avoid that translation. + * + * Attempting to set the hardware filter on a Microsoft Surface Pro's + * Mobile Broadband Adapter returns an error that appears to be + * NDIS_STATUS_NOT_SUPPORTED ORed with the "Customer" bit, so it's + * probably indicating that it doesn't support that. * * It is likely that there are other devices which throw spurious errors, * at which point this will need refactoring to efficiently check against - * a list, but for now we can just check this one value. + * a list, but for now we can just check this one value. Perhaps the + * right way to do this is compare against various NDIS errors with + * the "customer" bit ORed in. */ -#define NPF_SURFACE_MOBILE_NONPROMISC 0xe00000bb +#define NT_STATUS_CUSTOMER_DEFINED 0x20000000 static int pcap_activate_npf(pcap_t *p) @@ -1017,14 +1073,22 @@ pcap_activate_npf(pcap_t *p) case ERROR_BAD_UNIT: /* * There's no such device. + * There's nothing to add, so clear the error + * message. */ + p->errbuf[0] = '\0'; return (PCAP_ERROR_NO_SUCH_DEVICE); case ERROR_ACCESS_DENIED: /* * There is, but we don't have permission to * use it. + * + * XXX - we currently get ERROR_BAD_UNIT if the + * user says "no" to the UAC prompt. */ + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "The helper program for \"Admin-only Mode\" must be allowed to make changes to your device"); return (PCAP_ERROR_PERM_DENIED); default: @@ -1052,10 +1116,9 @@ pcap_activate_npf(pcap_t *p) /*Set the linktype*/ switch (type.LinkType) { - case NdisMediumWan: - p->linktype = DLT_EN10MB; - break; - + /* + * NDIS-defined medium types. + */ case NdisMedium802_3: p->linktype = DLT_EN10MB; /* @@ -1079,12 +1142,19 @@ pcap_activate_npf(pcap_t *p) } break; + case NdisMedium802_5: + /* + * Token Ring. + */ + p->linktype = DLT_IEEE802; + break; + case NdisMediumFddi: p->linktype = DLT_FDDI; break; - case NdisMedium802_5: - p->linktype = DLT_IEEE802; + case NdisMediumWan: + p->linktype = DLT_EN10MB; break; case NdisMediumArcnetRaw: @@ -1099,6 +1169,21 @@ pcap_activate_npf(pcap_t *p) p->linktype = DLT_ATM_RFC1483; break; + case NdisMediumWirelessWan: + p->linktype = DLT_RAW; + break; + + case NdisMediumIP: + p->linktype = DLT_RAW; + break; + + /* + * Npcap-defined medium types. + */ + case NdisMediumNull: + p->linktype = DLT_NULL; + break; + case NdisMediumCHDLC: p->linktype = DLT_CHDLC; break; @@ -1107,10 +1192,6 @@ pcap_activate_npf(pcap_t *p) p->linktype = DLT_PPP_SERIAL; break; - case NdisMediumNull: - p->linktype = DLT_NULL; - break; - case NdisMediumBare80211: p->linktype = DLT_IEEE802_11; break; @@ -1123,10 +1204,6 @@ pcap_activate_npf(pcap_t *p) p->linktype = DLT_PPI; break; - case NdisMediumWirelessWan: - p->linktype = DLT_RAW; - break; - default: /* * An unknown medium type is assumed to supply Ethernet @@ -1227,7 +1304,13 @@ pcap_activate_npf(pcap_t *p) /* * Suppress spurious error generated by non-compiant - * MS Surface mobile adapters. + * MS Surface mobile adapters that appear to + * return NDIS_STATUS_NOT_SUPPORTED for attempts + * to set the hardware filter. + * + * It appears to be reporting NDIS_STATUS_NOT_SUPPORTED, + * but with the NT status value "Customer" bit set; + * the Npcap NPF driver sets that bit in some cases. * * If we knew that this meant "promiscuous mode * isn't supported", we could add a "promiscuous @@ -1249,8 +1332,17 @@ pcap_activate_npf(pcap_t *p) * and rejecting it with an error could disrupt * attempts to capture, as many programs (tcpdump, * *shark) default to promiscuous mode. + * + * Alternatively, we could return the "promiscuous + * mode not supported" *warning* value, so that + * correct code will either ignore it or report + * it and continue capturing. (This may require + * a pcap_init() flag to request that return + * value, so that old incorrect programs that + * assume a non-zero return from pcap_activate() + * is an error don't break.) */ - if (errcode != NPF_SURFACE_MOBILE_NONPROMISC) + if (errcode != (NDIS_STATUS_NOT_SUPPORTED|NT_STATUS_CUSTOMER_DEFINED)) { pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE, errcode, @@ -1281,7 +1373,7 @@ pcap_activate_npf(pcap_t *p) * Suppress spurious error generated by non-compiant * MS Surface mobile adapters. */ - if (errcode != NPF_SURFACE_MOBILE_NONPROMISC) + if (errcode != (NDIS_STATUS_NOT_SUPPORTED|NT_STATUS_CUSTOMER_DEFINED)) { pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE, errcode, @@ -1498,40 +1590,84 @@ pcap_can_set_rfmon_npf(pcap_t *p) return (PacketIsMonitorModeSupported(p->opt.device) == 1); } -pcap_t * -pcap_create_interface(const char *device _U_, char *ebuf) -{ - pcap_t *p; +/* + * Get a list of time stamp types. + */ #ifdef HAVE_PACKET_GET_TIMESTAMP_MODES - char *device_copy; - ADAPTER *adapter; +static int +get_ts_types(const char *device, pcap_t *p, char *ebuf) +{ + char *device_copy = NULL; + ADAPTER *adapter = NULL; ULONG num_ts_modes; BOOL ret; - DWORD error; - ULONG *modes; -#endif + DWORD error = ERROR_SUCCESS; + ULONG *modes = NULL; + int status = 0; - p = PCAP_CREATE_COMMON(ebuf, struct pcap_win); - if (p == NULL) - return (NULL); + do { + /* + * First, find out how many time stamp modes we have. + * To do that, we have to open the adapter. + * + * XXX - PacketOpenAdapter() takes a non-const pointer + * as an argument, so we make a copy of the argument and + * pass that to it. + */ + device_copy = strdup(device); + if (device_copy == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno, "malloc"); + status = -1; + break; + } - p->activate_op = pcap_activate_npf; - p->can_set_rfmon_op = pcap_can_set_rfmon_npf; + adapter = PacketOpenAdapter(device_copy); + if (adapter == NULL) + { + error = GetLastError(); + /* + * If we can't open the device now, we won't be + * able to later, either. + * + * If the error is something that indicates + * that the device doesn't exist, or that they + * don't have permission to open the device - or + * perhaps that they don't have permission to get + * a list of devices, if PacketOpenAdapter() does + * that - the user will find that out when they try + * to activate the device; just return an empty + * list of time stamp types. + * + * Treating either of those as errors will, for + * example, cause "tcpdump -i " to fail, + * because it first tries to pass the interface + * name to pcap_create() and pcap_activate(), + * in order to handle OSes where interfaces can + * have names that are just numbers (stand up + * and say hello, Linux!), and, if pcap_activate() + * fails with a "no such device" error, checks + * whether the interface name is a valid number + * and, if so, tries to use it as an index in + * the list of interfaces. + * + * That means pcap_create() must succeed even + * for interfaces that don't exist, with the + * failure occurring at pcap_activate() time. + */ + if (error == ERROR_BAD_UNIT || + error == ERROR_ACCESS_DENIED) { + p->tstamp_type_count = 0; + p->tstamp_type_list = NULL; + status = 0; + } else { + pcap_fmt_errmsg_for_win32_err(ebuf, + PCAP_ERRBUF_SIZE, error, + "Error opening adapter"); + status = -1; + } + break; + } -#ifdef HAVE_PACKET_GET_TIMESTAMP_MODES - /* - * First, find out how many time stamp modes we have. - * To do that, we have to open the adapter. - * - * XXX - PacketOpenAdapter() takes a non-const pointer - * as an argument, so we make a copy of the argument and - * pass that to it. - */ - device_copy = strdup(device); - adapter = PacketOpenAdapter(device_copy); - free(device_copy); - if (adapter != NULL) - { /* * Get the total number of time stamp modes. * @@ -1563,116 +1699,186 @@ pcap_create_interface(const char *device _U_, char *ebuf) */ error = GetLastError(); if (error != ERROR_MORE_DATA) { + /* + * No, did it fail with ERROR_INVALID_FUNCTION? + */ + if (error == ERROR_INVALID_FUNCTION) { + /* + * This is probably due to + * the driver with which Packet.dll + * communicates being older, or + * being a WinPcap driver, so + * that it doesn't support + * BIOCGTIMESTAMPMODES. + * + * Tell the user to try uninstalling + * Npcap - and WinPcap if installed - + * and re-installing it, to flush + * out all older drivers. + */ + snprintf(ebuf, PCAP_ERRBUF_SIZE, + "PacketGetTimestampModes() failed with ERROR_INVALID_FUNCTION; try uninstalling Npcap, and WinPcap if installed, and re-installing it from npcap.com"); + status = -1; + break; + } + /* * No, some other error. Fail. */ pcap_fmt_errmsg_for_win32_err(ebuf, - PCAP_ERRBUF_SIZE, GetLastError(), + PCAP_ERRBUF_SIZE, error, "Error calling PacketGetTimestampModes"); - pcap_close(p); - return (NULL); - } - - /* - * Yes, so we now know how many types to fetch. - * - * The buffer needs to have one ULONG for the - * count and num_ts_modes ULONGs for the - * num_ts_modes time stamp types. - */ - modes = (ULONG *)malloc((1 + num_ts_modes) * sizeof(ULONG)); - if (modes == NULL) { - /* Out of memory. */ - /* XXX SET ebuf */ - pcap_close(p); - return (NULL); - } - modes[0] = 1 + num_ts_modes; - if (!PacketGetTimestampModes(adapter, modes)) { - pcap_fmt_errmsg_for_win32_err(ebuf, - PCAP_ERRBUF_SIZE, GetLastError(), - "Error calling PacketGetTimestampModes"); - free(modes); - pcap_close(p); - return (NULL); - } - if (modes[0] != num_ts_modes) { - snprintf(ebuf, PCAP_ERRBUF_SIZE, - "First PacketGetTimestampModes() call gives %lu modes, second call gives %lu modes", - num_ts_modes, modes[0]); - free(modes); - pcap_close(p); - return (NULL); - } - if (num_ts_modes != 0) { - u_int num_ts_types; - - /* - * Allocate a buffer big enough for - * PCAP_TSTAMP_HOST (default) plus - * the explicitly specified modes. - */ - p->tstamp_type_list = malloc((1 + modes[0]) * sizeof(u_int)); - if (p->tstamp_type_list == NULL) { - /* XXX SET ebuf */ - free(modes); - pcap_close(p); - return (NULL); - } - num_ts_types = 0; - p->tstamp_type_list[num_ts_types] = - PCAP_TSTAMP_HOST; - num_ts_types++; - for (ULONG i = 0; i < modes[0]; i++) { - switch (modes[i + 1]) { - - case TIMESTAMPMODE_SINGLE_SYNCHRONIZATION: - /* - * Better than low-res, - * but *not* synchronized - * with the OS clock. - */ - p->tstamp_type_list[num_ts_types] = - PCAP_TSTAMP_HOST_HIPREC_UNSYNCED; - num_ts_types++; - break; - - case TIMESTAMPMODE_QUERYSYSTEMTIME: - /* - * Low-res, but synchronized - * with the OS clock. - */ - p->tstamp_type_list[num_ts_types] = - PCAP_TSTAMP_HOST_LOWPREC; - num_ts_types++; - break; - - case TIMESTAMPMODE_QUERYSYSTEMTIME_PRECISE: - /* - * High-res, and synchronized - * with the OS clock. - */ - p->tstamp_type_list[num_ts_types] = - PCAP_TSTAMP_HOST_HIPREC; - num_ts_types++; - break; - - default: - /* - * Unknown, so we can't - * report it. - */ - break; - } - } - p->tstamp_type_count = num_ts_types; - free(modes); + status = -1; + break; } } + /* else (ret == TRUE) + * Unexpected success. Let's act like we got ERROR_MORE_DATA. + * If it doesn't work, we'll hit some other error condition farther on. + */ + + /* If the driver reports no modes supported *and* + * ERROR_MORE_DATA, something is seriously wrong. + * We *could* ignore the error and continue without supporting + * settable timestamp modes, but that would hide a bug. + */ + if (num_ts_modes == 0) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, + "PacketGetTimestampModes() reports 0 modes supported."); + status = -1; + break; + } + + /* + * Yes, so we now know how many types to fetch. + * + * The buffer needs to have one ULONG for the + * count and num_ts_modes ULONGs for the + * num_ts_modes time stamp types. + */ + modes = (ULONG *)malloc((1 + num_ts_modes) * sizeof(ULONG)); + if (modes == NULL) { + /* Out of memory. */ + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno, "malloc"); + status = -1; + break; + } + modes[0] = 1 + num_ts_modes; + if (!PacketGetTimestampModes(adapter, modes)) { + pcap_fmt_errmsg_for_win32_err(ebuf, + PCAP_ERRBUF_SIZE, GetLastError(), + "Error calling PacketGetTimestampModes"); + status = -1; + break; + } + if (modes[0] != num_ts_modes) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, + "First PacketGetTimestampModes() call gives %lu modes, second call gives %lu modes", + num_ts_modes, modes[0]); + status = -1; + break; + } + + /* + * Allocate a buffer big enough for + * PCAP_TSTAMP_HOST (default) plus + * the explicitly specified modes. + */ + p->tstamp_type_list = malloc((1 + num_ts_modes) * sizeof(u_int)); + if (p->tstamp_type_list == NULL) { + pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno, "malloc"); + status = -1; + break; + } + u_int num_ts_types = 0; + p->tstamp_type_list[num_ts_types] = + PCAP_TSTAMP_HOST; + num_ts_types++; + for (ULONG i = 0; i < num_ts_modes; i++) { + switch (modes[i + 1]) { + + case TIMESTAMPMODE_SINGLE_SYNCHRONIZATION: + /* + * Better than low-res, + * but *not* synchronized + * with the OS clock. + */ + p->tstamp_type_list[num_ts_types] = + PCAP_TSTAMP_HOST_HIPREC_UNSYNCED; + num_ts_types++; + break; + + case TIMESTAMPMODE_QUERYSYSTEMTIME: + /* + * Low-res, but synchronized + * with the OS clock. + */ + p->tstamp_type_list[num_ts_types] = + PCAP_TSTAMP_HOST_LOWPREC; + num_ts_types++; + break; + + case TIMESTAMPMODE_QUERYSYSTEMTIME_PRECISE: + /* + * High-res, and synchronized + * with the OS clock. + */ + p->tstamp_type_list[num_ts_types] = + PCAP_TSTAMP_HOST_HIPREC; + num_ts_types++; + break; + + default: + /* + * Unknown, so we can't + * report it. + */ + break; + } + } + p->tstamp_type_count = num_ts_types; + } while (0); + + /* Clean up temporary allocations */ + if (device_copy != NULL) { + free(device_copy); + } + if (modes != NULL) { + free(modes); + } + if (adapter != NULL) { PacketCloseAdapter(adapter); } + + return status; +} +#else /* HAVE_PACKET_GET_TIMESTAMP_MODES */ +static int +get_ts_types(const char *device _U_, pcap_t *p _U_, char *ebuf _U_) +{ + /* + * Nothing to fetch, so it always "succeeds". + */ + return 0; +} #endif /* HAVE_PACKET_GET_TIMESTAMP_MODES */ +pcap_t * +pcap_create_interface(const char *device _U_, char *ebuf) +{ + pcap_t *p; + + p = PCAP_CREATE_COMMON(ebuf, struct pcap_win); + if (p == NULL) + return (NULL); + + p->activate_op = pcap_activate_npf; + p->can_set_rfmon_op = pcap_can_set_rfmon_npf; + + if (get_ts_types(device, p, ebuf) == -1) { + pcap_close(p); + return (NULL); + } return (p); } @@ -1879,8 +2085,8 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf) #ifdef OID_GEN_PHYSICAL_MEDIUM_EX OID_GEN_PHYSICAL_MEDIUM_EX, #endif - OID_GEN_PHYSICAL_MEDIUM - }; + OID_GEN_PHYSICAL_MEDIUM + }; #define N_GEN_PHYSICAL_MEDIUM_OIDS (sizeof gen_physical_medium_oids / sizeof gen_physical_medium_oids[0]) size_t i; #endif /* OID_GEN_PHYSICAL_MEDIUM */ @@ -1933,7 +2139,7 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf) *flags |= PCAP_IF_WIRELESS; /* - * A "network assosiation state" makes no sense for airpcap. + * A "network association state" makes no sense for airpcap. */ *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE; PacketCloseAdapter(adapter); @@ -2192,7 +2398,7 @@ pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf) desc++; /* - * Found it - "desc" points to the first of the two + * Found it - "desc" points to the first of the two * nulls at the end of the list of names, so the * first byte of the list of descriptions is two bytes * after it. diff --git a/libpcap/pcap-pf.c b/libpcap/pcap-pf.c index 4563a225d..bd27933ef 100644 --- a/libpcap/pcap-pf.c +++ b/libpcap/pcap-pf.c @@ -133,6 +133,9 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) bp = pc->bp; /* * Loop through each packet. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. */ n = 0; pad = pc->fddipad; diff --git a/libpcap/pcap-rdmasniff.c b/libpcap/pcap-rdmasniff.c index 224821de4..d63ca8988 100644 --- a/libpcap/pcap-rdmasniff.c +++ b/libpcap/pcap-rdmasniff.c @@ -38,6 +38,7 @@ #include #include #include +#include /* for INT_MAX */ #include #if !defined(IBV_FLOW_ATTR_SNIFFER) @@ -136,15 +137,30 @@ rdmasniff_read(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u priv->cq_event = 1; } - while (count < max_packets || PACKET_COUNT_IS_UNLIMITED(max_packets)) { + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(max_packets)) + max_packets = INT_MAX; + + while (count < max_packets) { if (ibv_poll_cq(priv->cq, 1, &wc) != 1) { priv->cq_event = 0; break; } if (wc.status != IBV_WC_SUCCESS) { - fprintf(stderr, "failed WC wr_id %lld status %d/%s\n", - (unsigned long long) wc.wr_id, + fprintf(stderr, "failed WC wr_id %" PRIu64 " status %d/%s\n", + wc.wr_id, wc.status, ibv_wc_status_str(wc.status)); continue; } diff --git a/libpcap/pcap-rpcap.c b/libpcap/pcap-rpcap.c index 0c6c55896..22fc73635 100644 --- a/libpcap/pcap-rpcap.c +++ b/libpcap/pcap-rpcap.c @@ -36,13 +36,16 @@ #endif #include "ftmacros.h" +#include "diag-control.h" #include /* for strlen(), ... */ #include /* for malloc(), free(), ... */ #include /* for functions with variable number of arguments */ #include /* for the errno variable */ +#include /* for INT_MAX */ #include "sockutils.h" #include "pcap-int.h" +#include "pcap-util.h" #include "rpcap-protocol.h" #include "pcap-rpcap.h" @@ -93,6 +96,7 @@ struct activehosts SOCKET sockctrl; SSL *ssl; uint8 protocol_version; + int byte_swapped; struct activehosts *next; }; @@ -128,6 +132,7 @@ struct pcap_rpcap { uint8 protocol_version; /* negotiated protocol version */ uint8 uses_ssl; /* User asked for rpcaps scheme */ + int byte_swapped; /* Server byte order is swapped from ours */ unsigned int TotNetDrops; /* keeps the number of packets that have been dropped by the network */ @@ -432,7 +437,8 @@ static int pcap_read_nocb_remote(pcap_t *p, struct pcap_pkthdr *pkt_header, u_ch return 0; } #endif - sock_geterror("select()", p->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(p->errbuf, PCAP_ERRBUF_SIZE, + "select() failed"); return -1; } } @@ -644,6 +650,21 @@ static int pcap_read_rpcap(pcap_t *p, int cnt, pcap_handler callback, u_char *us } } + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(cnt)) + cnt = INT_MAX; + while (n < cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) { /* @@ -666,9 +687,14 @@ static int pcap_read_rpcap(pcap_t *p, int cnt, pcap_handler callback, u_char *us if (ret == 1) { /* - * We got a packet. Hand it to the callback - * and count it so we can return the count. + * We got a packet. + * + * Do whatever post-processing is necessary, hand + * it to the callback, and count it so we can + * return the count. */ + pcap_post_process(p->linktype, pr->byte_swapped, + &pkt_header, pkt_data); (*callback)(user, &pkt_header, pkt_data); n++; } @@ -1003,7 +1029,7 @@ rpcap_remoteact_getsock(const char *host, int *error, char *errbuf) hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - retval = sock_initaddress(host, "0", &hints, &addrinfo, errbuf, + retval = sock_initaddress(host, NULL, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE); if (retval != 0) { @@ -1059,7 +1085,7 @@ static int pcap_startcapture_remote(pcap_t *fp) struct pcap_rpcap *pr = fp->priv; /* structure used when doing a remote live capture */ char sendbuf[RPCAP_NETBUF_SIZE]; /* temporary buffer in which data to be sent is buffered */ int sendbufidx = 0; /* index which keeps the number of bytes currently buffered */ - char portdata[PCAP_BUF_SIZE]; /* temp variable needed to keep the network port for the data connection */ + uint16 portdata = 0; /* temp variable needed to keep the network port for the data connection */ uint32 plen; int active = 0; /* '1' if we're in active mode */ struct activehosts *temp; /* temp var needed to scan the host list chain, to detect if we're in active mode */ @@ -1072,6 +1098,8 @@ static int pcap_startcapture_remote(pcap_t *fp) struct sockaddr_storage saddr; /* temp, needed to retrieve the network data port chosen on the local machine */ socklen_t saddrlen; /* temp, needed to retrieve the network data port chosen on the local machine */ int ai_family; /* temp, keeps the address family used by the control connection */ + struct sockaddr_in *sin4; + struct sockaddr_in6 *sin6; /* RPCAP-related variables*/ struct rpcap_header header; /* header of the RPCAP packet */ @@ -1085,7 +1113,9 @@ static int pcap_startcapture_remote(pcap_t *fp) uint32 server_sockbufsize; // Take the opportunity to clear pr->data_ssl before any goto error, - // as it seems pr->priv is not zeroed after its malloced. + // as it seems p->priv is not zeroed after its malloced. + // XXX - it now should be, as it's allocated by pcap_alloc_pcap_t(), + // which does a calloc(). pr->data_ssl = NULL; /* @@ -1119,7 +1149,8 @@ static int pcap_startcapture_remote(pcap_t *fp) saddrlen = sizeof(struct sockaddr_storage); if (getpeername(pr->rmt_sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1) { - sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getsockname() failed"); goto error_nodiscard; } ai_family = ((struct sockaddr_storage *) &saddr)->ss_family; @@ -1128,7 +1159,8 @@ static int pcap_startcapture_remote(pcap_t *fp) if (getnameinfo((struct sockaddr *) &saddr, saddrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST)) { - sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getnameinfo() failed"); goto error_nodiscard; } @@ -1151,10 +1183,10 @@ static int pcap_startcapture_remote(pcap_t *fp) hints.ai_flags = AI_PASSIVE; /* Data connection is opened by the server toward the client */ /* Let's the server pick up a free network port for us */ - if (sock_initaddress(NULL, "0", &hints, &addrinfo, fp->errbuf, PCAP_ERRBUF_SIZE) == -1) + if (sock_initaddress(NULL, NULL, &hints, &addrinfo, fp->errbuf, PCAP_ERRBUF_SIZE) == -1) goto error_nodiscard; - if ((sockdata = sock_open(addrinfo, SOCKOPEN_SERVER, + if ((sockdata = sock_open(NULL, addrinfo, SOCKOPEN_SERVER, 1 /* max 1 connection in queue */, fp->errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET) goto error_nodiscard; @@ -1166,15 +1198,27 @@ static int pcap_startcapture_remote(pcap_t *fp) saddrlen = sizeof(struct sockaddr_storage); if (getsockname(sockdata, (struct sockaddr *) &saddr, &saddrlen) == -1) { - sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getsockname() failed"); goto error_nodiscard; } - /* Get the local port the system picked up */ - if (getnameinfo((struct sockaddr *) &saddr, saddrlen, NULL, - 0, portdata, sizeof(portdata), NI_NUMERICSERV)) - { - sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE); + switch (saddr.ss_family) { + + case AF_INET: + sin4 = (struct sockaddr_in *)&saddr; + portdata = sin4->sin_port; + break; + + case AF_INET6: + sin6 = (struct sockaddr_in6 *)&saddr; + portdata = sin6->sin6_port; + break; + + default: + snprintf(fp->errbuf, PCAP_ERRBUF_SIZE, + "Local address has unknown address family %u", + saddr.ss_family); goto error_nodiscard; } } @@ -1207,8 +1251,7 @@ static int pcap_startcapture_remote(pcap_t *fp) /* portdata on the openreq is meaningful only if we're in active mode */ if ((active) || (pr->rmt_flags & PCAP_OPENFLAG_DATATX_UDP)) { - sscanf(portdata, "%d", (int *)&(startcapreq->portdata)); /* cast to avoid a compiler warning */ - startcapreq->portdata = htons(startcapreq->portdata); + startcapreq->portdata = portdata; } startcapreq->snaplen = htonl(fp->snapshot); @@ -1257,16 +1300,18 @@ static int pcap_startcapture_remote(pcap_t *fp) { if (!active) { + char portstring[PCAP_BUF_SIZE]; + memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = ai_family; /* Use the same address family of the control socket */ hints.ai_socktype = (pr->rmt_flags & PCAP_OPENFLAG_DATATX_UDP) ? SOCK_DGRAM : SOCK_STREAM; - snprintf(portdata, PCAP_BUF_SIZE, "%d", ntohs(startcapreply.portdata)); + snprintf(portstring, PCAP_BUF_SIZE, "%d", ntohs(startcapreply.portdata)); /* Let's the server pick up a free network port for us */ - if (sock_initaddress(host, portdata, &hints, &addrinfo, fp->errbuf, PCAP_ERRBUF_SIZE) == -1) + if (sock_initaddress(host, portstring, &hints, &addrinfo, fp->errbuf, PCAP_ERRBUF_SIZE) == -1) goto error; - if ((sockdata = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, fp->errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET) + if ((sockdata = sock_open(host, addrinfo, SOCKOPEN_CLIENT, 0, fp->errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET) goto error; /* addrinfo is no longer used */ @@ -1284,7 +1329,8 @@ static int pcap_startcapture_remote(pcap_t *fp) if (socktemp == INVALID_SOCKET) { - sock_geterror("accept()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "accept() failed"); goto error; } @@ -1318,7 +1364,8 @@ static int pcap_startcapture_remote(pcap_t *fp) res = getsockopt(sockdata, SOL_SOCKET, SO_RCVBUF, (char *)&sockbufsize, &itemp); if (res == -1) { - sock_geterror("pcap_startcapture_remote(): getsockopt() failed", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "pcap_startcapture_remote(): getsockopt() failed"); goto error; } @@ -1697,14 +1744,16 @@ static int pcap_createfilter_norpcappkt(pcap_t *fp, struct bpf_program *prog) saddrlen = sizeof(struct sockaddr_storage); if (getpeername(pr->rmt_sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1) { - sock_geterror("getpeername()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getpeername() failed"); return -1; } if (getnameinfo((struct sockaddr *) &saddr, saddrlen, peeraddress, sizeof(peeraddress), peerctrlport, sizeof(peerctrlport), NI_NUMERICHOST | NI_NUMERICSERV)) { - sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getnameinfo() failed"); return -1; } @@ -1712,7 +1761,8 @@ static int pcap_createfilter_norpcappkt(pcap_t *fp, struct bpf_program *prog) /* Get the name/port of the current host */ if (getsockname(pr->rmt_sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1) { - sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getsockname() failed"); return -1; } @@ -1720,21 +1770,24 @@ static int pcap_createfilter_norpcappkt(pcap_t *fp, struct bpf_program *prog) if (getnameinfo((struct sockaddr *) &saddr, saddrlen, myaddress, sizeof(myaddress), myctrlport, sizeof(myctrlport), NI_NUMERICHOST | NI_NUMERICSERV)) { - sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getnameinfo() failed"); return -1; } /* Let's now check the data port */ if (getsockname(pr->rmt_sockdata, (struct sockaddr *) &saddr, &saddrlen) == -1) { - sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getsockname() failed"); return -1; } /* Get the local port the system picked up */ if (getnameinfo((struct sockaddr *) &saddr, saddrlen, NULL, 0, mydataport, sizeof(mydataport), NI_NUMERICSERV)) { - sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(fp->errbuf, PCAP_ERRBUF_SIZE, + "getnameinfo() failed"); return -1; } @@ -1900,6 +1953,10 @@ static int pcap_setsampling_remote(pcap_t *fp) * \param ver: pointer to variable to which to set the protocol version * number we selected. * + * \param byte_swapped: pointer to variable to which to set 1 if the + * byte order the server says it has is byte-swapped from ours, 0 + * otherwise (whether it's the same as ours or is unknown). + * * \param auth: authentication parameters that have to be sent. * * \param errbuf: a pointer to a user-allocated buffer (of size @@ -1910,7 +1967,8 @@ static int pcap_setsampling_remote(pcap_t *fp) * \return '0' if everything is fine, '-1' for an error. For errors, * an error message string is returned in the 'errbuf' variable. */ -static int rpcap_doauth(SOCKET sockctrl, SSL *ssl, uint8 *ver, struct pcap_rmtauth *auth, char *errbuf) +static int rpcap_doauth(SOCKET sockctrl, SSL *ssl, uint8 *ver, + int *byte_swapped, struct pcap_rmtauth *auth, char *errbuf) { char sendbuf[RPCAP_NETBUF_SIZE]; /* temporary buffer in which data that has to be sent is buffered */ int sendbufidx = 0; /* index which keeps the number of bytes currently buffered */ @@ -1922,6 +1980,8 @@ static int rpcap_doauth(SOCKET sockctrl, SSL *ssl, uint8 *ver, struct pcap_rmtau uint32 plen; struct rpcap_authreply authreply; /* authentication reply message */ uint8 ourvers; + int has_byte_order; /* The server sent its version of the byte-order magic number */ + u_int their_byte_order_magic; /* Here's what it is */ if (auth) { @@ -2026,17 +2086,46 @@ static int rpcap_doauth(SOCKET sockctrl, SSL *ssl, uint8 *ver, struct pcap_rmtau plen = header.plen; if (plen != 0) { - /* Yes - is it big enough to be version information? */ - if (plen < sizeof(struct rpcap_authreply)) + size_t reply_len; + + /* Yes - is it big enough to include version information? */ + if (plen < sizeof(struct rpcap_authreply_old)) { /* No - discard it and fail. */ + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Authenticaton reply from server is too short"); + (void)rpcap_discard(sockctrl, ssl, plen, NULL); + return -1; + } + + /* Yes - does it include server byte order information? */ + if (plen == sizeof(struct rpcap_authreply_old)) + { + /* No - just read the version information */ + has_byte_order = 0; + reply_len = sizeof(struct rpcap_authreply_old); + } + else if (plen >= sizeof(struct rpcap_authreply_old)) + { + /* Yes - read it all. */ + has_byte_order = 1; + reply_len = sizeof(struct rpcap_authreply); + } + else + { + /* + * Too long for old reply, too short for new reply. + * Discard it and fail. + */ + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Authenticaton reply from server is too short"); (void)rpcap_discard(sockctrl, ssl, plen, NULL); return -1; } /* Read the reply body */ if (rpcap_recv(sockctrl, ssl, (char *)&authreply, - sizeof(struct rpcap_authreply), &plen, errbuf) == -1) + reply_len, &plen, errbuf) == -1) { (void)rpcap_discard(sockctrl, ssl, plen, NULL); return -1; @@ -2059,12 +2148,32 @@ static int rpcap_doauth(SOCKET sockctrl, SSL *ssl, uint8 *ver, struct pcap_rmtau "The server's minimum supported protocol version is greater than its maximum supported protocol version"); return -1; } + + if (has_byte_order) + { + their_byte_order_magic = authreply.byte_order_magic; + } + else + { + /* + * The server didn't tell us what its byte + * order is; assume it's ours. + */ + their_byte_order_magic = RPCAP_BYTE_ORDER_MAGIC; + } } else { /* No - it supports only version 0. */ authreply.minvers = 0; authreply.maxvers = 0; + + /* + * And it didn't tell us what its byte order is; assume + * it's ours. + */ + has_byte_order = 0; + their_byte_order_magic = RPCAP_BYTE_ORDER_MAGIC; } /* @@ -2097,6 +2206,27 @@ static int rpcap_doauth(SOCKET sockctrl, SSL *ssl, uint8 *ver, struct pcap_rmtau goto novers; } + /* + * Is the server byte order the opposite of ours? + */ + if (their_byte_order_magic == RPCAP_BYTE_ORDER_MAGIC) + { + /* No, it's the same. */ + *byte_swapped = 0; + } + else if (their_byte_order_magic == RPCAP_BYTE_ORDER_MAGIC_SWAPPED) + { + /* Yes, it's the opposite of ours. */ + *byte_swapped = 1; + } + else + { + /* They sent us something bogus. */ + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "The server did not send us a valid byte order value"); + return -1; + } + *ver = ourvers; return 0; @@ -2129,8 +2259,8 @@ pcap_setnonblock_rpcap(pcap_t *p, int nonblock _U_) static int rpcap_setup_session(const char *source, struct pcap_rmtauth *auth, int *activep, SOCKET *sockctrlp, uint8 *uses_sslp, SSL **sslp, - int rmt_flags, uint8 *protocol_versionp, char *host, char *port, - char *iface, char *errbuf) + int rmt_flags, uint8 *protocol_versionp, int *byte_swappedp, + char *host, char *port, char *iface, char *errbuf) { int type; struct activehosts *activeconn; /* active connection, if there is one */ @@ -2180,6 +2310,7 @@ rpcap_setup_session(const char *source, struct pcap_rmtauth *auth, *sockctrlp = activeconn->sockctrl; *sslp = activeconn->ssl; *protocol_versionp = activeconn->protocol_version; + *byte_swappedp = activeconn->byte_swapped; } else { @@ -2217,7 +2348,7 @@ rpcap_setup_session(const char *source, struct pcap_rmtauth *auth, return -1; } - if ((*sockctrlp = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, + if ((*sockctrlp = sock_open(host, addrinfo, SOCKOPEN_CLIENT, 0, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET) { freeaddrinfo(addrinfo); @@ -2246,8 +2377,8 @@ rpcap_setup_session(const char *source, struct pcap_rmtauth *auth, #endif } - if (rpcap_doauth(*sockctrlp, *sslp, protocol_versionp, auth, - errbuf) == -1) + if (rpcap_doauth(*sockctrlp, *sslp, protocol_versionp, + byte_swappedp, auth, errbuf) == -1) { #ifdef HAVE_OPENSSL if (*sslp) @@ -2313,6 +2444,7 @@ pcap_t *pcap_open_rpcap(const char *source, int snaplen, int flags, int read_tim SOCKET sockctrl; SSL *ssl = NULL; uint8 protocol_version; /* negotiated protocol version */ + int byte_swapped; /* server is known to be byte-swapped */ int active; uint32 plen; char sendbuf[RPCAP_NETBUF_SIZE]; /* temporary buffer in which data to be sent is buffered */ @@ -2358,8 +2490,8 @@ pcap_t *pcap_open_rpcap(const char *source, int snaplen, int flags, int read_tim * Attempt to set up the session with the server. */ if (rpcap_setup_session(fp->opt.device, auth, &active, &sockctrl, - &pr->uses_ssl, &ssl, flags, &protocol_version, host, ctrlport, - iface, errbuf) == -1) + &pr->uses_ssl, &ssl, flags, &protocol_version, &byte_swapped, + host, ctrlport, iface, errbuf) == -1) { /* Session setup failed. */ pcap_close(fp); @@ -2408,6 +2540,7 @@ pcap_t *pcap_open_rpcap(const char *source, int snaplen, int flags, int read_tim pr->rmt_sockctrl = sockctrl; pr->ctrl_ssl = ssl; pr->protocol_version = protocol_version; + pr->byte_swapped = byte_swapped; pr->rmt_clientside = 1; /* This code is duplicated from the end of this function */ @@ -2479,6 +2612,7 @@ int pcap_findalldevs_ex_remote(const char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf) { uint8 protocol_version; /* protocol version */ + int byte_swapped; /* Server byte order is swapped from ours */ SOCKET sockctrl; /* socket descriptor of the control connection */ SSL *ssl = NULL; /* optional SSL handler for sockctrl */ uint32 plen; @@ -2500,7 +2634,8 @@ pcap_findalldevs_ex_remote(const char *source, struct pcap_rmtauth *auth, pcap_i * Attempt to set up the session with the server. */ if (rpcap_setup_session(source, auth, &active, &sockctrl, &uses_ssl, - &ssl, 0, &protocol_version, host, port, NULL, errbuf) == -1) + &ssl, 0, &protocol_version, &byte_swapped, host, port, NULL, + errbuf) == -1) { /* Session setup failed. */ return -1; @@ -2792,6 +2927,7 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha SOCKET sockctrl; /* keeps the main socket identifier */ SSL *ssl = NULL; /* Optional SSL handler for sockctrl */ uint8 protocol_version; /* negotiated protocol version */ + int byte_swapped; /* 1 if server byte order is known to be the reverse of ours */ struct activehosts *temp, *prev; /* temp var needed to scan he host list chain */ *connectinghost = 0; /* just in case */ @@ -2825,7 +2961,7 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha } - if ((sockmain = sock_open(addrinfo, SOCKOPEN_SERVER, 1, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET) + if ((sockmain = sock_open(NULL, addrinfo, SOCKOPEN_SERVER, 1, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET) { freeaddrinfo(addrinfo); return (SOCKET)-2; @@ -2844,7 +2980,7 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha if (sockctrl == INVALID_SOCKET) { - sock_geterror("accept()", errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(errbuf, PCAP_ERRBUF_SIZE, "accept() failed"); return (SOCKET)-2; } @@ -2868,7 +3004,8 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha /* Get the numeric for of the name of the connecting host */ if (getnameinfo((struct sockaddr *) &from, fromlen, connectinghost, RPCAP_HOSTLIST_SIZE, NULL, 0, NI_NUMERICHOST)) { - sock_geterror("getnameinfo()", errbuf, PCAP_ERRBUF_SIZE); + sock_geterrmsg(errbuf, PCAP_ERRBUF_SIZE, + "getnameinfo() failed"); rpcap_senderror(sockctrl, ssl, 0, PCAP_ERR_REMOTEACCEPT, errbuf, NULL); #ifdef HAVE_OPENSSL if (ssl) @@ -2901,7 +3038,8 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha /* * Send authentication to the remote machine. */ - if (rpcap_doauth(sockctrl, ssl, &protocol_version, auth, errbuf) == -1) + if (rpcap_doauth(sockctrl, ssl, &protocol_version, &byte_swapped, + auth, errbuf) == -1) { /* Unrecoverable error. */ rpcap_senderror(sockctrl, ssl, 0, PCAP_ERR_REMOTEACCEPT, errbuf, NULL); @@ -2966,6 +3104,7 @@ SOCKET pcap_remoteact_accept_ex(const char *address, const char *port, const cha temp->sockctrl = sockctrl; temp->ssl = ssl; temp->protocol_version = protocol_version; + temp->byte_swapped = byte_swapped; temp->next = NULL; return sockctrl; @@ -2991,7 +3130,7 @@ int pcap_remoteact_close(const char *host, char *errbuf) hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - retval = sock_initaddress(host, "0", &hints, &addrinfo, errbuf, + retval = sock_initaddress(host, NULL, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE); if (retval != 0) { @@ -3134,7 +3273,8 @@ int pcap_remoteact_list(char *hostlist, char sep, int size, char *errbuf) /* if (getnameinfo( (struct sockaddr *) &temp->host, sizeof (struct sockaddr_storage), hoststr, */ /* RPCAP_HOSTLIST_SIZE, NULL, 0, NI_NUMERICHOST) ) */ { - /* sock_geterror("getnameinfo()", errbuf, PCAP_ERRBUF_SIZE); */ + /* sock_geterrmsg(errbuf, PCAP_ERRBUF_SIZE, */ + /* "getnameinfo() failed"); */ return -1; } @@ -3351,7 +3491,9 @@ static void rpcap_msg_err(SOCKET sockctrl, SSL *ssl, uint32 plen, char *remote_e PCAP_ERRBUF_SIZE) == -1) { // Network error. + DIAG_OFF_FORMAT_TRUNCATION snprintf(remote_errbuf, PCAP_ERRBUF_SIZE, "Read of error message from client failed: %s", errbuf); + DIAG_ON_FORMAT_TRUNCATION return; } @@ -3386,7 +3528,9 @@ static void rpcap_msg_err(SOCKET sockctrl, SSL *ssl, uint32 plen, char *remote_e PCAP_ERRBUF_SIZE) == -1) { // Network error. + DIAG_OFF_FORMAT_TRUNCATION snprintf(remote_errbuf, PCAP_ERRBUF_SIZE, "Read of error message from client failed: %s", errbuf); + DIAG_ON_FORMAT_TRUNCATION return; } diff --git a/libpcap/pcap-septel.c b/libpcap/pcap-septel.c index e917edd7b..6d1d90474 100644 --- a/libpcap/pcap-septel.c +++ b/libpcap/pcap-septel.c @@ -93,7 +93,7 @@ loop: h = GCT_grab(id); m = (MSG*)h; - /* a couter is added here to avoid an infinite loop + /* a counter is added here to avoid an infinite loop * that will cause our capture program GUI to freeze while waiting * for a packet*/ counter++ ; @@ -105,7 +105,7 @@ loop: t = h->type ; - /* catch only messages with type = 0xcf00 or 0x8f01 corrsponding to ss7 messages*/ + /* catch only messages with type = 0xcf00 or 0x8f01 corresponding to ss7 messages*/ /* XXX = why not use API_MSG_TX_REQ for 0xcf00 and API_MSG_RX_IND * for 0x8f01? */ if ((t != 0xcf00) && (t != 0x8f01)) { diff --git a/libpcap/pcap-sita.c b/libpcap/pcap-sita.c index c53f32358..70a36471d 100644 --- a/libpcap/pcap-sita.c +++ b/libpcap/pcap-sita.c @@ -441,7 +441,7 @@ static char *translate_IOP_to_pcap_name(unit_t *u, char *IOPname, bpf_u_int32 if iface->iftype = iftype; /* remember the interface type of this interface */ - iface->IOPname = strdup(IOPnam); /* copy it and stick it into the structure */ + iface->IOPname = strdup(IOPname); /* copy it and stick it into the structure */ if (iface->IOPname == NULL) { /* oops, we didn't get the memory requested */ fprintf(stderr, "Error...couldn't allocate memory for IOPname...value of errno is: %d\n", errno); return NULL; @@ -492,7 +492,7 @@ static char *translate_IOP_to_pcap_name(unit_t *u, char *IOPname, bpf_u_int32 if u->iface = iface; /* stick this entry at the head of the list */ } else { iface_ptr = u->iface; - while (iface_ptr->next) { /* othewise scan the list */ + while (iface_ptr->next) { /* otherwise scan the list */ iface_ptr = iface_ptr->next; /* till we're at the last entry */ } iface_ptr->next = iface; /* then tack this entry on the end of the list */ @@ -634,7 +634,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0 "malloc"); return -1; } - memset((char *)addr, 0, sizeof(pcap_addr_t)); /* bzero() is deprecated, replaced with memset() */ + memset((char *)addr, 0, sizeof(pcap_addr_t)); /* bzero() is deprecated, replaced with memset() */ if (iff->addresses == 0) iff->addresses = addr; if (prev_addr) prev_addr->next = addr; /* insert a forward link */ if (*ptr) { /* if there is a count for the address */ diff --git a/libpcap/pcap-sita.html b/libpcap/pcap-sita.html index 33f1e10fa..04f51292f 100644 --- a/libpcap/pcap-sita.html +++ b/libpcap/pcap-sita.html @@ -52,16 +52,16 @@ A { text-decoration:none }

- - + + - + - + @@ -771,13 +771,13 @@ A { text-decoration:none }

Application Capture Termination
wireshark
Application Capture Termination
wireshark pcap_dispatch(all packets in one buffer of capture only) pcap_breakloop()
tshark
tshark pcap_dispatch(one buffer of capture only) Since a CTRL-C was used to terminate the application, pcap_breakloop() is never called.
tcpdump
tcpdump pcap_loop(all packets in the next buffer, and loop forever) pcap_breakloop()
- - - - - - - + + + + + + +
 [Packet Header]  [Packet Data]  [Packet Header]  [Packet Data]  [Packet Header]  [Packet Data] ... [Packet Header]  [Packet Data]  [Packet Header]  [Packet Data]  [Packet Header]  [Packet Data] ...
diff --git a/libpcap/pcap-snf.c b/libpcap/pcap-snf.c index a9162eba5..fe9cc9c8d 100644 --- a/libpcap/pcap-snf.c +++ b/libpcap/pcap-snf.c @@ -9,6 +9,7 @@ #include #include #include +#include /* for INT_MAX */ #ifndef _WIN32 #include @@ -139,9 +140,24 @@ snf_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) if (!p) return -1; + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(cnt)) + cnt = INT_MAX; + n = 0; timeout = ps->snf_timeout; - while (n < cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) { + while (n < cnt) { /* * Has "pcap_breakloop()" been called? */ @@ -387,7 +403,7 @@ snf_findalldevs(pcap_if_list_t *devlistp, char *errbuf) * the port? If so, should we add them to the * entry for the device, if they're not already in the * list of IP addresses for the device? - */ + */ (void)snprintf(desc,MAX_DESC_LENGTH,"Myricom %ssnf%d", merge ? "Merge Bitmask Port " : "", merge ? 1 << ifa->snf_ifa_portnum : ifa->snf_ifa_portnum); @@ -436,14 +452,14 @@ snf_findalldevs(pcap_if_list_t *devlistp, char *errbuf) */ ret = inet_pton(AF_INET, dev->name, &addr.sin_addr); if (ret == 1) { - /* - * Successful conversion of device name - * to IPv4 address. - */ - addr.sin_family = AF_INET; - if (add_addr_to_dev(dev, &addr, sizeof(addr), - NULL, 0, NULL, 0, NULL, 0, errbuf) == -1) - return -1; + /* + * Successful conversion of device name + * to IPv4 address. + */ + addr.sin_family = AF_INET; + if (add_addr_to_dev(dev, &addr, sizeof(addr), + NULL, 0, NULL, 0, NULL, 0, errbuf) == -1) + return -1; } else if (ret == -1) { /* * Error. @@ -459,7 +475,7 @@ snf_findalldevs(pcap_if_list_t *devlistp, char *errbuf) snf_freeifaddrs(ifaddrs); /* * Create a snfX entry if port aggregation is enabled - */ + */ if (merge) { /* * Add a new entry with all ports bitmask diff --git a/libpcap/pcap-snit.c b/libpcap/pcap-snit.c index ca6222cf0..3f4e69d71 100644 --- a/libpcap/pcap-snit.c +++ b/libpcap/pcap-snit.c @@ -139,6 +139,9 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user) /* * loop through each snapshot in the chunk + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. */ n = 0; ep = bp + cc; @@ -331,12 +334,16 @@ pcap_activate_snit(pcap_t *p) if (fd < 0 && errno == EACCES) p->fd = fd = open(dev, O_RDONLY); if (fd < 0) { - if (errno == EACCES) + if (errno == EACCES) { err = PCAP_ERROR_PERM_DENIED; - else + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed with EACCES - root privileges may be required", + dev); + } else { err = PCAP_ERROR; - pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "%s", dev); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "%s", dev); + } goto bad; } diff --git a/libpcap/pcap-tc.c b/libpcap/pcap-tc.c index 9902633a9..1d753b547 100644 --- a/libpcap/pcap-tc.c +++ b/libpcap/pcap-tc.c @@ -914,7 +914,7 @@ static int TcRead(pcap_t *p, int cnt, pcap_handler callback, u_char *user) return -1; } - /* No underlaying filtering system. We need to filter on our own */ + /* No underlying filtering system. We need to filter on our own */ if (p->fcode.bf_insns) { filterResult = pcap_filter(p->fcode.bf_insns, data, tcHeader.Length, tcHeader.CapturedLength); @@ -1124,7 +1124,7 @@ TcSetMode(pcap_t *p, int mode) { if (mode != MODE_CAPT) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Mode %u not supported by TurboCap devices. TurboCap only supports capture.", mode); + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Mode %d not supported by TurboCap devices. TurboCap only supports capture.", mode); return -1; } diff --git a/libpcap/pcap-usb-linux-common.c b/libpcap/pcap-usb-linux-common.c new file mode 100644 index 000000000..fb4a8c19b --- /dev/null +++ b/libpcap/pcap-usb-linux-common.c @@ -0,0 +1,130 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * pcap-usb-linux-common.c - common code for everything that needs to + * deal with Linux USB captures. + */ + +#include "pcap/pcap.h" +#include "pcap/usb.h" + +#include "pcap-usb-linux-common.h" + +/* + * Compute, from the data provided by the Linux USB memory-mapped capture + * mechanism, the amount of packet data that would have been provided + * had the capture mechanism not chopped off any data at the end, if, in + * fact, it did so. + * + * Set the "unsliced length" field of the packet header to that value. + */ +void +fix_linux_usb_mmapped_length(struct pcap_pkthdr *pkth, const u_char *bp) +{ + const pcap_usb_header_mmapped *hdr; + u_int bytes_left; + + /* + * All callers of this routine must ensure that pkth->caplen is + * >= sizeof (pcap_usb_header_mmapped). + */ + bytes_left = pkth->caplen; + bytes_left -= sizeof (pcap_usb_header_mmapped); + + hdr = (const pcap_usb_header_mmapped *) bp; + if (!hdr->data_flag && hdr->transfer_type == URB_ISOCHRONOUS && + hdr->event_type == URB_COMPLETE && + (hdr->endpoint_number & URB_TRANSFER_IN) && + pkth->len == sizeof(pcap_usb_header_mmapped) + + (hdr->ndesc * sizeof (usb_isodesc)) + hdr->urb_len) { + usb_isodesc *descs; + u_int pre_truncation_data_len, pre_truncation_len; + + descs = (usb_isodesc *) (bp + sizeof(pcap_usb_header_mmapped)); + + /* + * We have data (yes, data_flag is 0 if we *do* have data), + * and this is a "this is complete" incoming isochronous + * transfer event, and the length was calculated based + * on the URB length. + * + * That's not correct, because the data isn't contiguous, + * and the isochronous descriptos show how it's scattered. + * + * Find the end of the last chunk of data in the buffer + * referred to by the isochronous descriptors; that indicates + * how far into the buffer the data would have gone. + * + * Make sure we don't run past the end of the captured data + * while processing the isochronous descriptors. + */ + pre_truncation_data_len = 0; + for (uint32_t desc = 0; + desc < hdr->ndesc && bytes_left >= sizeof (usb_isodesc); + desc++, bytes_left -= sizeof (usb_isodesc)) { + u_int desc_end; + + if (descs[desc].len != 0) { + desc_end = descs[desc].offset + descs[desc].len; + if (desc_end > pre_truncation_data_len) + pre_truncation_data_len = desc_end; + } + } + + /* + * Now calculate the total length based on that data + * length. + */ + pre_truncation_len = sizeof(pcap_usb_header_mmapped) + + (hdr->ndesc * sizeof (usb_isodesc)) + + pre_truncation_data_len; + + /* + * If that's greater than or equal to the captured length, + * use that as the length. + */ + if (pre_truncation_len >= pkth->caplen) + pkth->len = pre_truncation_len; + + /* + * If the captured length is greater than the length, + * use the captured length. + * + * For completion events for incoming isochronous transfers, + * it's based on data_len, which is calculated the same way + * we calculated pre_truncation_data_len above, except that + * it has access to all the isochronous descriptors, not + * just the ones that the kernel were able to provide us or, + * for a capture file, that weren't sliced off by a snapshot + * length. + * + * However, it might have been reduced by the USB capture + * mechanism arbitrarily limiting the amount of data it + * provides to userland, or by the libpcap capture code + * limiting it to being no more than the snapshot, so + * we don't want to just use it all the time; we only + * do so to try to get a better estimate of the actual + * length - and to make sure the on-the-network length + * is always >= the captured length. + */ + if (pkth->caplen > pkth->len) + pkth->len = pkth->caplen; + } +} diff --git a/libpcap/pcap-usb-linux-common.h b/libpcap/pcap-usb-linux-common.h new file mode 100644 index 000000000..8cff7ba1c --- /dev/null +++ b/libpcap/pcap-usb-linux-common.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * pcap-usb-linux-common.h - common code for everything that needs to + * deal with Linux USB captures. + */ + +extern void fix_linux_usb_mmapped_length(struct pcap_pkthdr *pkth, + const u_char *bp); diff --git a/libpcap/pcap-usb-linux.c b/libpcap/pcap-usb-linux.c index ee8834f03..726e4a8a6 100644 --- a/libpcap/pcap-usb-linux.c +++ b/libpcap/pcap-usb-linux.c @@ -39,6 +39,7 @@ #include "pcap-int.h" #include "pcap-usb-linux.h" +#include "pcap-usb-linux-common.h" #include "pcap/usb.h" #include "extract.h" @@ -70,7 +71,12 @@ #include #endif /* HAVE_LINUX_USBDEVICE_FS_H */ +#include "diag-control.h" + #define USB_IFACE "usbmon" + +#define USBMON_DEV_PREFIX "usbmon" +#define USBMON_DEV_PREFIX_LEN (sizeof USBMON_DEV_PREFIX - 1) #define USB_LINE_LEN 4096 #if __BYTE_ORDER == __LITTLE_ENDIAN @@ -111,10 +117,10 @@ struct mon_bin_mfetch { #define MON_IOCX_MFETCH _IOWR(MON_IOC_MAGIC, 7, struct mon_bin_mfetch) #define MON_IOCH_MFLUSH _IO(MON_IOC_MAGIC, 8) -#define MON_BIN_SETUP 0x1 /* setup hdr is present*/ -#define MON_BIN_SETUP_ZERO 0x2 /* setup buffer is not available */ -#define MON_BIN_DATA_ZERO 0x4 /* data buffer is not available */ -#define MON_BIN_ERROR 0x8 +#define MON_BIN_SETUP 0x1 /* setup hdr is present*/ +#define MON_BIN_SETUP_ZERO 0x2 /* setup buffer is not available */ +#define MON_BIN_DATA_ZERO 0x4 /* data buffer is not available */ +#define MON_BIN_ERROR 0x8 /* * Private data for capturing on Linux USB. @@ -173,9 +179,6 @@ usb_dev_add(pcap_if_list_t *devlistp, int n, char *err_str) int usb_findalldevs(pcap_if_list_t *devlistp, char *err_str) { - char usb_mon_dir[PATH_MAX]; - char *usb_mon_prefix; - size_t usb_mon_prefix_len; struct dirent* data; int ret = 0; DIR* dir; @@ -184,26 +187,10 @@ usb_findalldevs(pcap_if_list_t *devlistp, char *err_str) /* * We require 2.6.27 or later kernels, so we have binary-mode support. - * What do the device names look like? - * Split LINUX_USB_MON_DEV into a directory that we'll - * scan and a file name prefix that we'll check for. + * The devices are of the form /dev/usbmon{N}. + * Open /dev and scan it. */ - pcap_strlcpy(usb_mon_dir, LINUX_USB_MON_DEV, sizeof usb_mon_dir); - usb_mon_prefix = strrchr(usb_mon_dir, '/'); - if (usb_mon_prefix == NULL) { - /* - * This "shouldn't happen". Just give up if it - * does. - */ - return 0; - } - *usb_mon_prefix++ = '\0'; - usb_mon_prefix_len = strlen(usb_mon_prefix); - - /* - * Open the directory and scan it. - */ - dir = opendir(usb_mon_dir); + dir = opendir("/dev"); if (dir != NULL) { while ((ret == 0) && ((data = readdir(dir)) != 0)) { name = data->d_name; @@ -211,13 +198,14 @@ usb_findalldevs(pcap_if_list_t *devlistp, char *err_str) /* * Is this a usbmon device? */ - if (strncmp(name, usb_mon_prefix, usb_mon_prefix_len) != 0) + if (strncmp(name, USBMON_DEV_PREFIX, + USBMON_DEV_PREFIX_LEN) != 0) continue; /* no */ /* * What's the device number? */ - if (sscanf(&name[usb_mon_prefix_len], "%d", &n) == 0) + if (sscanf(&name[USBMON_DEV_PREFIX_LEN], "%d", &n) == 0) continue; /* failed */ ret = usb_dev_add(devlistp, n, err_str); @@ -385,13 +373,13 @@ probe_devices(int bus) ctrl.bRequest = USB_REQ_GET_DESCRIPTOR; ctrl.wValue = USB_DT_DEVICE << 8; ctrl.wIndex = 0; - ctrl.wLength = sizeof(descriptor); + ctrl.wLength = sizeof(descriptor); #else ctrl.requesttype = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE; ctrl.request = USB_REQ_GET_DESCRIPTOR; ctrl.value = USB_DT_DEVICE << 8; ctrl.index = 0; - ctrl.length = sizeof(descriptor); + ctrl.length = sizeof(descriptor); #endif ctrl.data = descriptor; ctrl.timeout = CTRL_TIMEOUT; @@ -475,7 +463,7 @@ static int usb_activate(pcap_t* handle) { struct pcap_usb_linux *handlep = handle->priv; - char full_path[USB_LINE_LEN]; + char full_path[USB_LINE_LEN]; /* * Turn a negative snapshot value (invalid), a snapshot value of @@ -512,7 +500,8 @@ usb_activate(pcap_t* handle) * We require 2.6.27 or later kernels, so we have binary-mode support. * Try to open the binary interface. */ - snprintf(full_path, USB_LINE_LEN, LINUX_USB_MON_DEV"%d", handlep->bus_index); + snprintf(full_path, USB_LINE_LEN, "/dev/"USBMON_DEV_PREFIX"%d", + handlep->bus_index); handle->fd = open(full_path, O_RDONLY, 0); if (handle->fd < 0) { @@ -532,13 +521,23 @@ usb_activate(pcap_t* handle) * doesn't exist (no "scan all buses" * device if the bus index is 0, no * such bus if the bus index isn't 0). + * + * For now, don't provide an error message; + * if we can determine what the particular + * problem is, we should report that. */ + handle->errbuf[0] = '\0'; return PCAP_ERROR_NO_SUCH_DEVICE; case EACCES: /* * We didn't have permission to open it. */ +DIAG_OFF_FORMAT_TRUNCATION + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Attempt to open %s failed with EACCES - root privileges may be required", + full_path); +DIAG_ON_FORMAT_TRUNCATION return PCAP_ERROR_PERM_DENIED; default: @@ -758,6 +757,7 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch struct mon_bin_mfetch fetch; int32_t vec[VEC_SIZE]; struct pcap_pkthdr pkth; + u_char *bp; pcap_usb_header_mmapped* hdr; int nflush = 0; int packets = 0; @@ -767,13 +767,40 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch for (;;) { int i, ret; - int limit = max_packets - packets; - if (limit <= 0) - limit = VEC_SIZE; - if (limit > VEC_SIZE) - limit = VEC_SIZE; + int limit; - /* try to fetch as many events as possible*/ + if (PACKET_COUNT_IS_UNLIMITED(max_packets)) { + /* + * There's no limit on the number of packets + * to process, so try to fetch VEC_SIZE packets. + */ + limit = VEC_SIZE; + } else { + /* + * Try to fetch as many packets as we have left + * to process, or VEC_SIZE packets, whichever + * is less. + * + * At this point, max_packets > 0 (otherwise, + * PACKET_COUNT_IS_UNLIMITED(max_packets) + * would be true) and max_packets > packets + * (packet starts out as 0, and the test + * at the bottom of the loop exits if + * max_packets <= packets), so limit is + * guaranteed to be > 0. + */ + limit = max_packets - packets; + if (limit > VEC_SIZE) + limit = VEC_SIZE; + } + + /* + * Try to fetch as many events as possible, up to + * the limit, and flush the events we've processed + * earlier (nflush) - MON_IOCX_MFETCH does both + * (presumably to reduce the number of system + * calls in loops like this). + */ fetch.offvec = vec; fetch.nfetch = limit; fetch.nflush = nflush; @@ -800,8 +827,27 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch /* keep track of processed events, we will flush them later */ nflush = fetch.nfetch; for (i=0; immapbuf[vec[i]]; + + /* That begins with a metadata header */ + hdr = (pcap_usb_header_mmapped*) bp; + /* discard filler */ - hdr = (pcap_usb_header_mmapped*) &handlep->mmapbuf[vec[i]]; if (hdr->event_type == '@') continue; @@ -846,6 +892,13 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch */ pkth.len = sizeof(pcap_usb_header_mmapped) + (hdr->ndesc * sizeof (usb_isodesc)) + hdr->urb_len; + + /* + * Now clean it up if it's a completion + * event for an incoming isochronous + * transfer. + */ + fix_linux_usb_mmapped_length(&pkth, bp); } pkth.ts.tv_sec = (time_t)hdr->ts_sec; pkth.ts.tv_usec = hdr->ts_usec; @@ -859,8 +912,12 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch } } - /* with max_packets specifying "unlimited" we stop after the first chunk*/ - if (PACKET_COUNT_IS_UNLIMITED(max_packets) || (packets == max_packets)) + /* + * If max_packets specifiesg "unlimited", we stop after + * the first chunk. + */ + if (PACKET_COUNT_IS_UNLIMITED(max_packets) || + (packets >= max_packets)) break; } diff --git a/libpcap/pcap-util.c b/libpcap/pcap-util.c new file mode 100644 index 000000000..8b5669e90 --- /dev/null +++ b/libpcap/pcap-util.c @@ -0,0 +1,474 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * pcap-common.c - common code for pcap and pcapng files + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "pcap-int.h" +#include "extract.h" +#include "pcap-usb-linux-common.h" + +#include "pcap-util.h" + +#include "pflog.h" +#include "pcap/can_socketcan.h" +#include "pcap/sll.h" +#include "pcap/usb.h" +#include "pcap/nflog.h" + +/* + * Most versions of the DLT_PFLOG pseudo-header have UID and PID fields + * that are saved in host byte order. + * + * When reading a DLT_PFLOG packet, we need to convert those fields from + * the byte order of the host that wrote the file to this host's byte + * order. + */ +static void +swap_pflog_header(const struct pcap_pkthdr *hdr, u_char *buf) +{ + u_int caplen = hdr->caplen; + u_int length = hdr->len; + u_int pfloghdr_length; + struct pfloghdr *pflhdr = (struct pfloghdr *)buf; + + if (caplen < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid) || + length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) { + /* Not enough data to have the uid field */ + return; + } + + pfloghdr_length = pflhdr->length; + + if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) { + /* Header doesn't include uid field */ + return; + } + pflhdr->uid = SWAPLONG(pflhdr->uid); + + if (caplen < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid) || + length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) { + /* Not enough data to have the pid field */ + return; + } + if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) { + /* Header doesn't include pid field */ + return; + } + pflhdr->pid = SWAPLONG(pflhdr->pid); + + if (caplen < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid) || + length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) { + /* Not enough data to have the rule_uid field */ + return; + } + if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) { + /* Header doesn't include rule_uid field */ + return; + } + pflhdr->rule_uid = SWAPLONG(pflhdr->rule_uid); + + if (caplen < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid) || + length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) { + /* Not enough data to have the rule_pid field */ + return; + } + if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) { + /* Header doesn't include rule_pid field */ + return; + } + pflhdr->rule_pid = SWAPLONG(pflhdr->rule_pid); +} + +/* + * DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or + * LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload, + * with the CAN ID being in host byte order. + * + * When reading a DLT_LINUX_SLL packet, we need to check for those + * packets and convert the CAN ID from the byte order of the host that + * wrote the file to this host's byte order. + */ +static void +swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf) +{ + u_int caplen = hdr->caplen; + u_int length = hdr->len; + struct sll_header *shdr = (struct sll_header *)buf; + uint16_t protocol; + pcap_can_socketcan_hdr *chdr; + + if (caplen < (u_int) sizeof(struct sll_header) || + length < (u_int) sizeof(struct sll_header)) { + /* Not enough data to have the protocol field */ + return; + } + + protocol = EXTRACT_BE_U_2(&shdr->sll_protocol); + if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD) + return; + + /* + * SocketCAN packet; fix up the packet's header. + */ + chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header)); + if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) || + length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) { + /* Not enough data to have the CAN ID */ + return; + } + chdr->can_id = SWAPLONG(chdr->can_id); +} + +/* + * The same applies for DLT_LINUX_SLL2. + */ +static void +swap_linux_sll2_header(const struct pcap_pkthdr *hdr, u_char *buf) +{ + u_int caplen = hdr->caplen; + u_int length = hdr->len; + struct sll2_header *shdr = (struct sll2_header *)buf; + uint16_t protocol; + pcap_can_socketcan_hdr *chdr; + + if (caplen < (u_int) sizeof(struct sll2_header) || + length < (u_int) sizeof(struct sll2_header)) { + /* Not enough data to have the protocol field */ + return; + } + + protocol = EXTRACT_BE_U_2(&shdr->sll2_protocol); + if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD) + return; + + /* + * SocketCAN packet; fix up the packet's header. + */ + chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll2_header)); + if (caplen < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id) || + length < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id)) { + /* Not enough data to have the CAN ID */ + return; + } + chdr->can_id = SWAPLONG(chdr->can_id); +} + +/* + * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host + * byte order when capturing (it's supplied directly from a + * memory-mapped buffer shared by the kernel). + * + * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED packet, we + * need to convert it from the byte order of the host that wrote the + * file to this host's byte order. + */ +static void +swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, + int header_len_64_bytes) +{ + pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf; + bpf_u_int32 offset = 0; + + /* + * "offset" is the offset *past* the field we're swapping; + * we skip the field *before* checking to make sure + * the captured data length includes the entire field. + */ + + /* + * The URB id is a totally opaque value; do we really need to + * convert it to the reading host's byte order??? + */ + offset += 8; /* skip past id */ + if (hdr->caplen < offset) + return; + uhdr->id = SWAPLL(uhdr->id); + + offset += 4; /* skip past various 1-byte fields */ + + offset += 2; /* skip past bus_id */ + if (hdr->caplen < offset) + return; + uhdr->bus_id = SWAPSHORT(uhdr->bus_id); + + offset += 2; /* skip past various 1-byte fields */ + + offset += 8; /* skip past ts_sec */ + if (hdr->caplen < offset) + return; + uhdr->ts_sec = SWAPLL(uhdr->ts_sec); + + offset += 4; /* skip past ts_usec */ + if (hdr->caplen < offset) + return; + uhdr->ts_usec = SWAPLONG(uhdr->ts_usec); + + offset += 4; /* skip past status */ + if (hdr->caplen < offset) + return; + uhdr->status = SWAPLONG(uhdr->status); + + offset += 4; /* skip past urb_len */ + if (hdr->caplen < offset) + return; + uhdr->urb_len = SWAPLONG(uhdr->urb_len); + + offset += 4; /* skip past data_len */ + if (hdr->caplen < offset) + return; + uhdr->data_len = SWAPLONG(uhdr->data_len); + + if (uhdr->transfer_type == URB_ISOCHRONOUS) { + offset += 4; /* skip past s.iso.error_count */ + if (hdr->caplen < offset) + return; + uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count); + + offset += 4; /* skip past s.iso.numdesc */ + if (hdr->caplen < offset) + return; + uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc); + } else + offset += 8; /* skip USB setup header */ + + /* + * With the old header, there are no isochronous descriptors + * after the header. + * + * With the new header, the actual number of descriptors in + * the header is not s.iso.numdesc, it's ndesc - only the + * first N descriptors, for some value of N, are put into + * the header, and ndesc is set to the actual number copied. + * In addition, if s.iso.numdesc is negative, no descriptors + * are captured, and ndesc is set to 0. + */ + if (header_len_64_bytes) { + /* + * This is either the "version 1" header, with + * 16 bytes of additional fields at the end, or + * a "version 0" header from a memory-mapped + * capture, with 16 bytes of zeroed-out padding + * at the end. Byte swap them as if this were + * a "version 1" header. + */ + offset += 4; /* skip past interval */ + if (hdr->caplen < offset) + return; + uhdr->interval = SWAPLONG(uhdr->interval); + + offset += 4; /* skip past start_frame */ + if (hdr->caplen < offset) + return; + uhdr->start_frame = SWAPLONG(uhdr->start_frame); + + offset += 4; /* skip past xfer_flags */ + if (hdr->caplen < offset) + return; + uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags); + + offset += 4; /* skip past ndesc */ + if (hdr->caplen < offset) + return; + uhdr->ndesc = SWAPLONG(uhdr->ndesc); + + if (uhdr->transfer_type == URB_ISOCHRONOUS) { + /* swap the values in struct linux_usb_isodesc */ + usb_isodesc *pisodesc; + uint32_t i; + + pisodesc = (usb_isodesc *)(void *)(buf+offset); + for (i = 0; i < uhdr->ndesc; i++) { + offset += 4; /* skip past status */ + if (hdr->caplen < offset) + return; + pisodesc->status = SWAPLONG(pisodesc->status); + + offset += 4; /* skip past offset */ + if (hdr->caplen < offset) + return; + pisodesc->offset = SWAPLONG(pisodesc->offset); + + offset += 4; /* skip past len */ + if (hdr->caplen < offset) + return; + pisodesc->len = SWAPLONG(pisodesc->len); + + offset += 4; /* skip past padding */ + + pisodesc++; + } + } + } +} + +/* + * The DLT_NFLOG "packets" have a mixture of big-endian and host-byte-order + * data. They begin with a fixed-length header with big-endian fields, + * followed by a set of TLVs, where the type and length are in host + * byte order but the values are either big-endian or are a raw byte + * sequence that's the same regardless of the host's byte order. + * + * When reading a DLT_NFLOG packet, we need to convert the type and + * length values from the byte order of the host that wrote the file + * to the byte order of this host. + */ +static void +swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf) +{ + u_char *p = buf; + nflog_hdr_t *nfhdr = (nflog_hdr_t *)buf; + nflog_tlv_t *tlv; + u_int caplen = hdr->caplen; + u_int length = hdr->len; + uint16_t size; + + if (caplen < (u_int) sizeof(nflog_hdr_t) || + length < (u_int) sizeof(nflog_hdr_t)) { + /* Not enough data to have any TLVs. */ + return; + } + + if (nfhdr->nflog_version != 0) { + /* Unknown NFLOG version */ + return; + } + + length -= sizeof(nflog_hdr_t); + caplen -= sizeof(nflog_hdr_t); + p += sizeof(nflog_hdr_t); + + while (caplen >= sizeof(nflog_tlv_t)) { + tlv = (nflog_tlv_t *) p; + + /* Swap the type and length. */ + tlv->tlv_type = SWAPSHORT(tlv->tlv_type); + tlv->tlv_length = SWAPSHORT(tlv->tlv_length); + + /* Get the length of the TLV. */ + size = tlv->tlv_length; + if (size % 4 != 0) + size += 4 - size % 4; + + /* Is the TLV's length less than the minimum? */ + if (size < sizeof(nflog_tlv_t)) { + /* Yes. Give up now. */ + return; + } + + /* Do we have enough data for the full TLV? */ + if (caplen < size || length < size) { + /* No. */ + return; + } + + /* Skip over the TLV. */ + length -= size; + caplen -= size; + p += size; + } +} + +static void +swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data) +{ + /* + * Convert pseudo-headers from the byte order of + * the host on which the file was saved to our + * byte order, as necessary. + */ + switch (linktype) { + + case DLT_PFLOG: + swap_pflog_header(hdr, data); + break; + + case DLT_LINUX_SLL: + swap_linux_sll_header(hdr, data); + break; + + case DLT_LINUX_SLL2: + swap_linux_sll2_header(hdr, data); + break; + + case DLT_USB_LINUX: + swap_linux_usb_header(hdr, data, 0); + break; + + case DLT_USB_LINUX_MMAPPED: + swap_linux_usb_header(hdr, data, 1); + break; + + case DLT_NFLOG: + swap_nflog_header(hdr, data); + break; + } +} + +void +pcap_post_process(int linktype, int swapped, struct pcap_pkthdr *hdr, + u_char *data) +{ + if (swapped) + swap_pseudo_headers(linktype, hdr, data); + + fixup_pcap_pkthdr(linktype, hdr, data); +} + +void +fixup_pcap_pkthdr(int linktype, struct pcap_pkthdr *hdr, const u_char *data) +{ + const pcap_usb_header_mmapped *usb_hdr; + + usb_hdr = (const pcap_usb_header_mmapped *) data; + if (linktype == DLT_USB_LINUX_MMAPPED && + hdr->caplen >= sizeof (pcap_usb_header_mmapped)) { + /* + * In older versions of libpcap, in memory-mapped captures, + * the "on-the-bus length" for completion events for + * incoming isochronous transfers was miscalculated; it + * needed to be calculated based on the* offsets and lengths + * in the descriptors, not on the raw URB length, but it + * wasn't. + * + * If this packet contains transferred data (yes, data_flag + * is 0 if we *do* have data), and the total on-the-network + * length is equal to the value calculated from the raw URB + * length, then it might be one of those transfers. + * + * We only do this if we have the full USB pseudo-header. + */ + if (!usb_hdr->data_flag && + hdr->len == sizeof(pcap_usb_header_mmapped) + + (usb_hdr->ndesc * sizeof (usb_isodesc)) + usb_hdr->urb_len) { + /* + * It might need fixing; fix it if it's a completion + * event for an incoming isochronous transfer. + */ + fix_linux_usb_mmapped_length(hdr, data); + } + } +} diff --git a/libpcap/pcap-util.h b/libpcap/pcap-util.h new file mode 100644 index 000000000..de958191c --- /dev/null +++ b/libpcap/pcap-util.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * pcap-util.h - common code for various files + */ + +/* + * We use the "receiver-makes-right" approach to byte order; + * because time is at a premium when we are writing the file. + * In other words, the pcap_file_header and pcap_pkthdr, + * records are written in host byte order. + * Note that the bytes of packet data are written out in the order in + * which they were received, so multi-byte fields in packets are not + * written in host byte order, they're written in whatever order the + * sending machine put them in. + * + * We also use this for fixing up packet data headers from a remote + * capture, where the server may have a different byte order from the + * client. + * + * ntoh[ls] aren't sufficient because we might need to swap on a big-endian + * machine (if the file was written in little-end order). + */ +#define SWAPLONG(y) \ + (((((u_int)(y))&0xff)<<24) | \ + ((((u_int)(y))&0xff00)<<8) | \ + ((((u_int)(y))&0xff0000)>>8) | \ + ((((u_int)(y))>>24)&0xff)) +#define SWAPSHORT(y) \ + ((u_short)(((((u_int)(y))&0xff)<<8) | \ + ((((u_int)(y))&0xff00)>>8))) + +extern void pcap_post_process(int linktype, int swapped, + struct pcap_pkthdr *hdr, u_char *data); + +extern void fixup_pcap_pkthdr(int linktype, struct pcap_pkthdr *hdr, + const u_char *data); + diff --git a/libpcap/pcap.3pcap.in b/libpcap/pcap.3pcap.in index 492c227e1..e98932d85 100644 --- a/libpcap/pcap.3pcap.in +++ b/libpcap/pcap.3pcap.in @@ -272,7 +272,7 @@ On some platforms, the time stamp given to packets on live captures can come from different sources that can have different resolutions or that can have different relationships to the time values for the current time supplied by routines on the native operating system. See -.BR pcap-tstamp (@MAN_MISC_INFO@) +.BR \%pcap-tstamp (@MAN_MISC_INFO@) for a list of time stamp types. .IP The time stamp type is set with @@ -720,7 +720,7 @@ periodically for packets; in that case, will return a pointer to a .B struct timeval whose value can be used as a timeout in those routines. When the -routine returns, an attmept should be made to read packets from the +routine returns, an attempt should be made to read packets from the device. If .BR pcap_get_required_select_timeout () returns @@ -784,17 +784,17 @@ get the state of non-blocking mode for a attempt to get a descriptor for a .B pcap_t that can be used in calls such as -.BR select (2) +.BR select () and -.BR poll (2) +.BR poll () .TP .BR pcap_get_required_select_timeout (3PCAP) attempt to get a timeout required for using a .B pcap_t in calls such as -.BR select (2) +.BR select () and -.BR poll (2) +.BR poll () .RE .SS Filters In order to cause only certain packets to be returned when reading @@ -804,7 +804,7 @@ copying ``uninteresting'' packets from the kernel to user mode. .PP A filter can be specified as a text string; the syntax and semantics of the string are as described by -.BR pcap-filter (@MAN_MISC_INFO@). +.BR \%pcap-filter (@MAN_MISC_INFO@). A filter string is compiled into a program in a pseudo-machine-language by .BR pcap_compile () @@ -894,13 +894,19 @@ call .BR pcap_dump_open (3PCAP) open a .B pcap_dumper_t -for a ``savefile``, given a pathname +for a ``savefile``, given a pathname, replacing any existing data +.TP +.BR pcap_dump_open_append (3PCAP) +open a +.B pcap_dumper_t +for a ``savefile``, given a pathname, appending to the existing data .TP .BR pcap_dump_fopen (3PCAP) open a .B pcap_dumper_t for a ``savefile``, given a -.B "FILE\ *" +.BR "FILE\ *" , +assuming an empty file .TP .BR pcap_dump_close (3PCAP) close a @@ -1027,7 +1033,7 @@ script or some other configuration script to check whether the libpcap .BR autoconf (1), .BR tcpdump (1), .BR tcpslice (1), -.BR pcap-filter (@MAN_MISC_INFO@), +.BR \%pcap-filter (@MAN_MISC_INFO@), .BR pfconfig (8), .BR usermod (@MAN_ADMIN_COMMANDS@) .SH AUTHORS @@ -1044,7 +1050,7 @@ The current version is available from "The Tcpdump Group"'s Web site at .I https://www.tcpdump.org/ .RE .SH BUGS -To report a security issue please send an e-mail to security@tcpdump.org. +To report a security issue please send an e-mail to \%security@tcpdump.org. .LP To report bugs and other problems, contribute patches, request a feature, provide generic feedback etc please see the file diff --git a/libpcap/pcap.c b/libpcap/pcap.c index ed8570aa2..ef1bbb71f 100644 --- a/libpcap/pcap.c +++ b/libpcap/pcap.c @@ -131,8 +131,6 @@ struct rtentry; /* declarations in */ #ifdef _WIN32 /* - * DllMain(), required when built as a Windows DLL. - * * To quote the WSAStartup() documentation: * * The WSAStartup function typically leads to protocol-specific helper @@ -147,19 +145,12 @@ struct rtentry; /* declarations in */ * be called from the DllMain function in a application DLL. This can * potentially cause deadlocks. * - * So we don't initialize Winsock here. pcap_init() should be called - * to initialize pcap on both UN*X and Windows; it will initialize - * Winsock on Windows. (It will also be initialized as needed if - * pcap_init() hasn't been called.) + * So we don't initialize Winsock in a DllMain() routine. + * + * pcap_init() should be called to initialize pcap on both UN*X and + * Windows; it will initialize Winsock on Windows. (It will also be + * initialized as needed if pcap_init() hasn't been called.) */ -BOOL WINAPI DllMain( - HANDLE hinstDLL _U_, - DWORD dwReason _U_, - LPVOID lpvReserved _U_ -) -{ - return (TRUE); -} /* * Start Winsock. @@ -259,7 +250,7 @@ pcap_init(unsigned int opts, char *errbuf) if (pcap_utf_8_mode) { snprintf(errbuf, PCAP_ERRBUF_SIZE, "Multiple pcap_init calls with different character encodings"); - return (-1); + return (PCAP_ERROR); } } break; @@ -270,7 +261,7 @@ pcap_init(unsigned int opts, char *errbuf) if (!pcap_utf_8_mode) { snprintf(errbuf, PCAP_ERRBUF_SIZE, "Multiple pcap_init calls with different character encodings"); - return (-1); + return (PCAP_ERROR); } } pcap_utf_8_mode = 1; @@ -278,7 +269,7 @@ pcap_init(unsigned int opts, char *errbuf) default: snprintf(errbuf, PCAP_ERRBUF_SIZE, "Unknown options specified"); - return (-1); + return (PCAP_ERROR); } /* @@ -303,7 +294,7 @@ pcap_init(unsigned int opts, char *errbuf) */ if (internal_wsockinit(errbuf) == -1) { /* Failed. */ - return (-1); + return (PCAP_ERROR); } #endif @@ -622,7 +613,9 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, * Return codes for pcap_offline_read() are: * - 0: EOF * - -1: error - * - >1: OK + * - >0: OK - result is number of packets read, so + * it will be 1 in this case, as we've passed + * a maximum packet count of 1 * The first one ('0') conflicts with the return code of * 0 from pcap_read() meaning "no packets arrived before * the timeout expired", so we map it to -2 so you can @@ -641,7 +634,9 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, * - 0: timeout * - -1: error * - -2: loop was broken out of with pcap_breakloop() - * - >1: OK + * - >0: OK, result is number of packets captured, so + * it will be 1 in this case, as we've passed + * a maximum packet count of 1 * The first one ('0') conflicts with the return code of 0 from * pcap_offline_read() meaning "end of file". */ @@ -2849,17 +2844,41 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *er goto fail; return (p); fail: - if (status == PCAP_ERROR) + if (status == PCAP_ERROR) { + /* + * Another buffer is a bit cumbersome, but it avoids + * -Wformat-truncation. + */ + char trimbuf[PCAP_ERRBUF_SIZE - 5]; /* 2 bytes shorter */ + + pcap_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf)); snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %.*s", device, - PCAP_ERRBUF_SIZE - 3, p->errbuf); - else if (status == PCAP_ERROR_NO_SUCH_DEVICE || + PCAP_ERRBUF_SIZE - 3, trimbuf); + } else if (status == PCAP_ERROR_NO_SUCH_DEVICE || status == PCAP_ERROR_PERM_DENIED || - status == PCAP_ERROR_PROMISC_PERM_DENIED) - snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%.*s)", device, - pcap_statustostr(status), PCAP_ERRBUF_SIZE - 6, p->errbuf); - else + status == PCAP_ERROR_PROMISC_PERM_DENIED) { + /* + * Only show the additional message if it's not + * empty. + */ + if (p->errbuf[0] != '\0') { + /* + * Idem. + */ + char trimbuf[PCAP_ERRBUF_SIZE - 8]; /* 2 bytes shorter */ + + pcap_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf)); + snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%.*s)", + device, pcap_statustostr(status), + PCAP_ERRBUF_SIZE - 6, trimbuf); + } else { + snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", + device, pcap_statustostr(status)); + } + } else { snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device, pcap_statustostr(status)); + } pcap_close(p); return (NULL); } @@ -3350,7 +3369,7 @@ pcap_datalink_val_to_description_or_dlt(int dlt) if (description != NULL) { return description; } else { - (void)snprintf(unkbuf, sizeof(unkbuf), "DLT %u", dlt); + (void)snprintf(unkbuf, sizeof(unkbuf), "DLT %d", dlt); return unkbuf; } } @@ -3461,14 +3480,14 @@ pcap_fileno(pcap_t *p) /* * This is a bogus and now-deprecated API; we * squelch the narrowing warning for the cast - * from HANDLE to DWORD. If Windows programmmers + * from HANDLE to intptr_t. If Windows programmmers * need to get at the HANDLE for a pcap_t, *if* * there is one, they should request such a * routine (and be prepared for it to return * INVALID_HANDLE_VALUE). */ DIAG_OFF_NARROWING - return ((int)(DWORD)p->handle); + return ((int)(intptr_t)p->handle); DIAG_ON_NARROWING } else return (PCAP_ERROR); @@ -3644,7 +3663,7 @@ pcap_statustostr(int errnum) return ("That operation is supported only in monitor mode"); case PCAP_ERROR_PERM_DENIED: - return ("You don't have permission to capture on that device"); + return ("You don't have permission to perform this capture on that device"); case PCAP_ERROR_IFACE_NOT_UP: return ("That device is not up"); @@ -3986,6 +4005,10 @@ pcap_breakloop_common(pcap_t *p) void pcap_cleanup_live_common(pcap_t *p) { + if (p->opt.device != NULL) { + free(p->opt.device); + p->opt.device = NULL; + } if (p->buffer != NULL) { free(p->buffer); p->buffer = NULL; @@ -4064,14 +4087,12 @@ pcap_inject(pcap_t *p, const void *buf, size_t size) void pcap_close(pcap_t *p) { - if (p->opt.device != NULL) - free(p->opt.device); p->cleanup_op(p); free(p); } /* - * Helpers for safely loding code at run time. + * Helpers for safely loading code at run time. * Currently Windows-only. */ #ifdef _WIN32 @@ -4180,6 +4201,20 @@ pcap_read_dead(pcap_t *p, int cnt _U_, pcap_handler callback _U_, return (-1); } +static void +pcap_breakloop_dead(pcap_t *p _U_) +{ + /* + * A "dead" pcap_t is just a placeholder to use in order to + * compile a filter to BPF code or to open a savefile for + * writing. It doesn't support any operations, including + * capturing or reading packets, so there will never be a + * get-packets loop in progress to break out *of*. + * + * As such, this routine doesn't need to do anything. + */ +} + static int pcap_inject_dead(pcap_t *p, const void *buf _U_, int size _U_) { @@ -4393,6 +4428,7 @@ pcap_open_dead_with_tstamp_precision(int linktype, int snaplen, u_int precision) p->live_dump_ended_op = pcap_live_dump_ended_dead; p->get_airpcap_handle_op = pcap_get_airpcap_handle_dead; #endif + p->breakloop_op = pcap_breakloop_dead; p->cleanup_op = pcap_cleanup_dead; /* diff --git a/libpcap/pcap/bpf.h b/libpcap/pcap/bpf.h index 54373af8a..3970d0a18 100644 --- a/libpcap/pcap/bpf.h +++ b/libpcap/pcap/bpf.h @@ -80,7 +80,6 @@ #define lib_pcap_bpf_h #include - #include #ifdef __cplusplus @@ -150,7 +149,7 @@ struct bpf_program { #define BPF_B 0x10 /* 0x18 reserved; used by BSD/OS */ #define BPF_MODE(code) ((code) & 0xe0) -#define BPF_IMM 0x00 +#define BPF_IMM 0x00 #define BPF_ABS 0x20 #define BPF_IND 0x40 #define BPF_MEM 0x60 @@ -244,8 +243,8 @@ struct bpf_program { */ struct bpf_insn { u_short code; - u_char jt; - u_char jf; + u_char jt; + u_char jf; bpf_u_int32 k; }; diff --git a/libpcap/pcap/can_socketcan.h b/libpcap/pcap/can_socketcan.h index 332d9ff5d..0cb3584a8 100644 --- a/libpcap/pcap/can_socketcan.h +++ b/libpcap/pcap/can_socketcan.h @@ -48,9 +48,14 @@ typedef struct { uint32_t can_id; uint8_t payload_length; - uint8_t pad; + uint8_t fd_flags; uint8_t reserved1; uint8_t reserved2; } pcap_can_socketcan_hdr; +/* Bits in the fd_flags field */ +#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */ +#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */ +#define CANFD_FDF 0x04 /* mark CAN FD for dual use of CAN format */ + #endif diff --git a/libpcap/pcap/compiler-tests.h b/libpcap/pcap/compiler-tests.h index a69c2b098..2d98a7070 100644 --- a/libpcap/pcap/compiler-tests.h +++ b/libpcap/pcap/compiler-tests.h @@ -80,9 +80,11 @@ */ #if ! defined(__GNUC__) -#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0 + /* Not GCC and not "just like GCC" */ + #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0 #else -#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \ + /* GCC or "just like GCC" */ + #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \ (__GNUC__ > (major) || \ (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) #endif @@ -92,9 +94,11 @@ */ #if !defined(__clang__) -#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 + /* Not Clang */ + #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 #else -#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \ + /* Clang */ + #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \ (__clang_major__ > (major) || \ (__clang_major__ == (major) && __clang_minor__ >= (minor))) #endif @@ -118,13 +122,15 @@ */ #if ! defined(__SUNPRO_C) -#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0 + /* Not Sun/Oracle C */ + #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0 #else -#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \ + /* Sun/Oracle C */ + #define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \ (((minor) >= 10) ? \ (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \ (((major) << 8) | ((minor) << 4))) -#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \ + #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \ (__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor))) #endif @@ -133,13 +139,31 @@ * * The version number in __xlC__ has the major version in the * upper 8 bits and the minor version in the lower 8 bits. + * On AIX __xlC__ is always defined, __ibmxl__ becomes defined in XL C 16.1. + * On Linux since XL C 13.1.6 __xlC__ is not defined by default anymore, but + * __ibmxl__ is defined since at least XL C 13.1.1. */ -#if ! defined(__xlC__) -#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 +#if ! defined(__xlC__) && ! defined(__ibmxl__) + /* Not XL C */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 #else -#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + /* XL C */ + #if defined(__ibmxl__) + /* + * Later Linux version of XL C; use __ibmxl_version__ to test + * the version. + */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + (__ibmxl_version__ > (major) || \ + (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor))) + #else /* __ibmxl__ */ + /* + * __ibmxl__ not defined; use __xlC__ to test the version. + */ + #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__xlC__ >= (((major) << 8) | (minor))) + #endif /* __ibmxl__ */ #endif /* @@ -154,9 +178,11 @@ */ #if ! defined(__HP_aCC) -#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0 + /* Not HP C */ + #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0 #else -#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \ + /* HP C */ + #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \ (__HP_aCC >= ((major)*10000 + (minor)*100)) #endif diff --git a/libpcap/pcap/dlt.h b/libpcap/pcap/dlt.h index eaba34f30..0da6de236 100644 --- a/libpcap/pcap/dlt.h +++ b/libpcap/pcap/dlt.h @@ -104,6 +104,67 @@ #define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */ #endif +/* + * NetBSD uses 15 for HIPPI. + * + * From a quick look at sys/net/if_hippi.h and sys/net/if_hippisubr.c + * in an older version of NetBSD , the header appears to be: + * + * a 1-byte ULP field (ULP-id)? + * + * a 1-byte flags field; + * + * a 2-byte "offsets" field; + * + * a 4-byte "D2 length" field (D2_Size?); + * + * a 4-byte "destination switch" field (or a 1-byte field + * containing the Forwarding Class, Double_Wide, and Message_Type + * sub fields, followed by a 3-byte Destination_Switch_Address + * field?, HIPPI-LE 3.4-style?); + * + * a 4-byte "source switch" field (or a 1-byte field containing the + * Destination_Address_type and Source_Address_Type fields, followed + * by a 3-byte Source_Switch_Address field, HIPPI-LE 3.4-style?); + * + * a 2-byte reserved field; + * + * a 6-byte destination address field; + * + * a 2-byte "local admin" field; + * + * a 6-byte source address field; + * + * followed by an 802.2 LLC header. + * + * This looks somewhat like something derived from the HIPPI-FP 4.4 + * Header_Area, followed an HIPPI-FP 4.4 D1_Area containing a D1 data set + * with the header in HIPPI-LE 3.4 (ANSI X3.218-1993), followed by an + * HIPPI-FP 4.4 D2_Area (with no Offset) containing the 802.2 LLC header + * and payload? Or does the "offsets" field contain the D2_Offset, + * with that many bytes of offset before the payload? + * + * See http://wotug.org/parallel/standards/hippi/ for an archive of + * HIPPI specifications. + * + * RFC 2067 imposes some additional restrictions. It says that the + * Offset is always zero + * + * HIPPI is long-gone, and the source files found in an older version + * of NetBSD don't appear to be in the main CVS branch, so we may never + * see a capture with this link-layer type. + */ +#if defined(__NetBSD__) +#define DLT_HIPPI 15 /* HIPPI */ +#endif + +/* + * NetBSD uses 16 for DLT_HDLC; see below. + * BSD/OS uses it for PPP; see above. + * As far as I know, no other OS uses it for anything; don't use it + * for anything else. + */ + /* * 17 was used for DLT_PFLOG in OpenBSD; it no longer is. * @@ -219,7 +280,8 @@ * that the AF_ type in the link-layer header is in network byte order. * * DLT_LOOP is 12 in OpenBSD, but that's DLT_RAW in other OSes, so - * we don't use 12 for it in OSes other than OpenBSD. + * we don't use 12 for it in OSes other than OpenBSD; instead, we + * use the same value as LINKTYPE_LOOP. */ #ifdef __OpenBSD__ #define DLT_LOOP 12 @@ -230,7 +292,7 @@ /* * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other - * than OpenBSD. + * than OpenBSD; instead, we use the same value as LINKTYPE_ENC. */ #ifdef __OpenBSD__ #define DLT_ENC 13 @@ -239,12 +301,22 @@ #endif /* - * Values between 110 and 112 are reserved for use in capture file headers + * Values 110 and 111 are reserved for use in capture file headers * as link-layer types corresponding to DLT_ types that might differ * between platforms; don't use those values for new DLT_ types * other than the corresponding DLT_ types. */ +/* + * NetBSD uses 16 for (Cisco) "HDLC framing". For other platforms, + * we define it to have the same value as LINKTYPE_NETBSD_HDLC. + */ +#if defined(__NetBSD__) +#define DLT_HDLC 16 /* Cisco HDLC */ +#else +#define DLT_HDLC 112 +#endif + /* * Linux cooked sockets. */ @@ -651,7 +723,7 @@ * DLT_ requested by Gianluca Varenni . * Every frame contains a 32bit A429 label. * More documentation on Arinc 429 can be found at - * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf + * https://web.archive.org/web/20040616233302/https://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf */ #define DLT_A429 184 @@ -1214,15 +1286,17 @@ #define DLT_BLUETOOTH_LE_LL 251 /* - * DLT type for upper-protocol layer PDU saves from wireshark. + * DLT type for upper-protocol layer PDU saves from Wireshark. * - * the actual contents are determined by two TAGs stored with each - * packet: - * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the - * original packet. + * the actual contents are determined by two TAGs, one or more of + * which is stored with each packet: * - * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector - * that can make sense of the data stored. + * EXP_PDU_TAG_DISSECTOR_NAME the name of the Wireshark dissector + * that can make sense of the data stored. + * + * EXP_PDU_TAG_HEUR_DISSECTOR_NAME the name of the Wireshark heuristic + * dissector that can make sense of the + * data stored. */ #define DLT_WIRESHARK_UPPER_PDU 252 diff --git a/libpcap/pcap/funcattrs.h b/libpcap/pcap/funcattrs.h index a2ca542b0..374094992 100644 --- a/libpcap/pcap/funcattrs.h +++ b/libpcap/pcap/funcattrs.h @@ -118,14 +118,14 @@ #if PCAP_IS_AT_LEAST_GNUC_VERSION(3,4) \ || PCAP_IS_AT_LEAST_XL_C_VERSION(12,0) /* - * GCC 3.4 or later, or some compiler asserting compatibility with - * GCC 3.4 or later, or XL C 13.0 or later, so we have + * GCC 3.4 and later, or some compiler asserting compatibility with + * GCC 3.4 and later, or XL C 13.0 and later, so we have * __attribute__((visibility()). */ #define PCAP_API_DEF __attribute__((visibility("default"))) #elif PCAP_IS_AT_LEAST_SUNC_VERSION(5,5) /* - * Sun C 5.5 or later, so we have __global. + * Sun C 5.5 and later, so we have __global. * (Sun C 5.9 and later also have __attribute__((visibility()), * but there's no reason to prefer it with Sun C.) */ @@ -161,6 +161,15 @@ * provided by Apple, so each release can come with a version compiled * to use the APIs present in that release.) * + * The non-macOS versioning is based on + * + * https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history + * + * If there are any corrections, please submit it upstream to the + * libpcap maintainers, preferably as a pull request on + * + * https://github.com/the-tcpdump-group/libpcap + * * We don't define it ourselves because, if you're building and * installing libpcap on macOS yourself, the APIs will be available * no matter what OS version you're installing it on. @@ -172,25 +181,32 @@ * I've never seen earlier releases. */ #ifdef __APPLE__ -#define PCAP_AVAILABLE_MACOS(v) /* define to say "first appears in v" */ -#define PCAP_AVAILABLE_0_4 PCAP_AVAILABLE_MACOS(10.0) /* Did any version of Mac OS X ship with this? */ -#define PCAP_AVAILABLE_0_5 PCAP_AVAILABLE_MACOS(10.0) /* Did any version of Mac OS X ship with this? */ -#define PCAP_AVAILABLE_0_6 PCAP_AVAILABLE_MACOS(10.1) -#define PCAP_AVAILABLE_0_7 PCAP_AVAILABLE_MACOS(10.4) -#define PCAP_AVAILABLE_0_8 PCAP_AVAILABLE_MACOS(10.4) -#define PCAP_AVAILABLE_0_9 PCAP_AVAILABLE_MACOS(10.5) -#define PCAP_AVAILABLE_1_0 PCAP_AVAILABLE_MACOS(10.6) +#include +/* + * When building as part of macOS, define this as __API_AVAILABLE(__VA_ARGS__). + * + * XXX - if there's some #define to indicate that this is being built + * as part of the macOS build process, we could make that Just Work. + */ +#define PCAP_AVAILABLE(...) +#define PCAP_AVAILABLE_0_4 PCAP_AVAILABLE(macos(10.0)) /* Did any version of Mac OS X ship with this? */ +#define PCAP_AVAILABLE_0_5 PCAP_AVAILABLE(macos(10.0)) /* Did any version of Mac OS X ship with this? */ +#define PCAP_AVAILABLE_0_6 PCAP_AVAILABLE(macos(10.1)) +#define PCAP_AVAILABLE_0_7 PCAP_AVAILABLE(macos(10.4)) +#define PCAP_AVAILABLE_0_8 PCAP_AVAILABLE(macos(10.4)) +#define PCAP_AVAILABLE_0_9 PCAP_AVAILABLE(macos(10.5), ios(1.0)) +#define PCAP_AVAILABLE_1_0 PCAP_AVAILABLE(macos(10.6), ios(4.0)) /* #define PCAP_AVAILABLE_1_1 no routines added to the API */ -#define PCAP_AVAILABLE_1_2 PCAP_AVAILABLE_MACOS(10.9) +#define PCAP_AVAILABLE_1_2 PCAP_AVAILABLE(macos(10.9), ios(6.0)) /* #define PCAP_AVAILABLE_1_3 no routines added to the API */ /* #define PCAP_AVAILABLE_1_4 no routines added to the API */ -#define PCAP_AVAILABLE_1_5 PCAP_AVAILABLE_MACOS(10.10) +#define PCAP_AVAILABLE_1_5 PCAP_AVAILABLE(macos(10.10), ios(7.0), watchos(1.0)) /* #define PCAP_AVAILABLE_1_6 no routines added to the API */ -#define PCAP_AVAILABLE_1_7 PCAP_AVAILABLE_MACOS(10.12) -#define PCAP_AVAILABLE_1_8 PCAP_AVAILABLE_MACOS(10.13) /* only Windows adds routines to the API; XXX - what version first had it? */ -#define PCAP_AVAILABLE_1_9 PCAP_AVAILABLE_MACOS(10.13) +#define PCAP_AVAILABLE_1_7 PCAP_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +#define PCAP_AVAILABLE_1_8 PCAP_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) /* only Windows adds routines to the API; XXX - what version first had it? */ +#define PCAP_AVAILABLE_1_9 PCAP_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) #define PCAP_AVAILABLE_1_10 /* not in macOS yet */ -#define PCAP_AVAILABLE_1_11 /* not released yet, so not in macOS yet */ +#define PCAP_AVAILABLE_1_11 /* not released yet, so not in macOS yet */ #else /* __APPLE__ */ #define PCAP_AVAILABLE_0_4 #define PCAP_AVAILABLE_0_5 @@ -230,11 +246,11 @@ || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \ || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10) /* - * Compiler with support for __attribute((noreturn)), or GCC 2.5 or - * later, or some compiler asserting compatibility with GCC 2.5 or - * later, or Solaris Studio 12 (Sun C 5.9) or later, or IBM XL C 10.1 - * or later (do any earlier versions of XL C support this?), or HP aCC - * A.06.10 or later. + * Compiler with support for __attribute((noreturn)), or GCC 2.5 and + * later, or some compiler asserting compatibility with GCC 2.5 and + * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1 + * and later (do any earlier versions of XL C support this?), or HP aCC + * A.06.10 and later. */ #define PCAP_NORETURN __attribute((noreturn)) #define PCAP_NORETURN_DEF __attribute((noreturn)) @@ -260,8 +276,8 @@ || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \ || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10) /* - * Compiler with support for it, or GCC 2.3 or later, or some compiler - * asserting compatibility with GCC 2.3 or later, or IBM XL C 10.1 + * Compiler with support for it, or GCC 2.3 and later, or some compiler + * asserting compatibility with GCC 2.3 and later, or IBM XL C 10.1 * and later (do any earlier versions of XL C support this?), * or HP aCC A.06.10 and later. */ @@ -274,23 +290,21 @@ * PCAP_DEPRECATED(func, msg), after a function declaration, marks the * function as deprecated. * - * The first argument is the name of the function; the second argument is - * a string giving the warning message to use if the compiler supports that. - * - * (Thank you, Microsoft, for requiring the function name.) + * The argument is a string giving the warning message to use if the + * compiler supports that. */ #if __has_attribute(deprecated) \ || PCAP_IS_AT_LEAST_GNUC_VERSION(4,5) \ || PCAP_IS_AT_LEAST_SUNC_VERSION(5,13) /* * Compiler that supports __has_attribute and __attribute__((deprecated)), - * or GCC 4.5 or later, or Sun/Oracle C 12.4 (Sun C 5.13) or later. + * or GCC 4.5 and later, or Sun/Oracle C 12.4 (Sun C 5.13) and later. * * Those support __attribute__((deprecated(msg))) (we assume, perhaps * incorrectly, that anything that supports __has_attribute() is * recent enough to support __attribute__((deprecated(msg)))). */ - #define PCAP_DEPRECATED(func, msg) __attribute__((deprecated(msg))) + #define PCAP_DEPRECATED(msg) __attribute__((deprecated(msg))) #elif PCAP_IS_AT_LEAST_GNUC_VERSION(3,1) /* * GCC 3.1 through 4.4. @@ -298,18 +312,18 @@ * Those support __attribute__((deprecated)) but not * __attribute__((deprecated(msg))). */ - #define PCAP_DEPRECATED(func, msg) __attribute__((deprecated)) + #define PCAP_DEPRECATED(msg) __attribute__((deprecated)) #elif defined(_MSC_VER) && !defined(BUILDING_PCAP) /* * MSVC, and we're not building libpcap itself; it's VS 2015 - * or later, so we have the deprecated pragma. + * and later, so we have __declspec(deprecated(...)). * * If we *are* building libpcap, we don't want this, as it'll warn * us even if we *define* the function. */ - #define PCAP_DEPRECATED(func, msg) __pragma(deprecated(func)) + #define PCAP_DEPRECATED(msg) _declspec(deprecated(msg)) #else - #define PCAP_DEPRECATED(func, msg) + #define PCAP_DEPRECATED(msg) #endif /* diff --git a/libpcap/pcap/namedb.h b/libpcap/pcap/namedb.h index 34a0ae7ee..51d1e3184 100644 --- a/libpcap/pcap/namedb.h +++ b/libpcap/pcap/namedb.h @@ -59,8 +59,9 @@ PCAP_API struct pcap_etherent *pcap_next_etherent(FILE *); PCAP_API u_char *pcap_ether_hostton(const char*); PCAP_API u_char *pcap_ether_aton(const char *); -PCAP_API bpf_u_int32 **pcap_nametoaddr(const char *) -PCAP_DEPRECATED(pcap_nametoaddr, "this is not reentrant; use 'pcap_nametoaddrinfo' instead"); +PCAP_API +PCAP_DEPRECATED("this is not reentrant; use 'pcap_nametoaddrinfo' instead") +bpf_u_int32 **pcap_nametoaddr(const char *); PCAP_API struct addrinfo *pcap_nametoaddrinfo(const char *); PCAP_API bpf_u_int32 pcap_nametonetaddr(const char *); diff --git a/libpcap/pcap/pcap-inttypes.h b/libpcap/pcap/pcap-inttypes.h index 1cfa0bfc3..8c7b4f651 100644 --- a/libpcap/pcap/pcap-inttypes.h +++ b/libpcap/pcap/pcap-inttypes.h @@ -32,8 +32,8 @@ #define pcap_pcap_inttypes_h /* - * If we're compiling with Visual Studio, make sure we have at least - * VS 2015 or later, so we have sufficient C99 support. + * If we're compiling with Visual Studio, make sure the C99 integer + * types are defined, by hook or by crook. * * XXX - verify that we have at least C99 support on UN*Xes? * @@ -42,39 +42,60 @@ */ #if defined(_MSC_VER) /* - * Compiler is MSVC. Make sure we have VS 2015 or later. + * Compiler is MSVC. */ - #if _MSC_VER < 1900 - #error "Building libpcap requires VS 2015 or later" + #if _MSC_VER >= 1800 + /* + * VS 2013 or newer; we have . + */ + #include + #else + /* + * Earlier VS; we have to define this stuff ourselves. + * We don't support building libpcap with earlier versions of VS, + * but SDKs for Npcap have to support building applications using + * earlier versions of VS, so we work around this by defining + * those types ourselves, as some files use them. + */ + typedef unsigned char uint8_t; + typedef signed char int8_t; + typedef unsigned short uint16_t; + typedef signed short int16_t; + typedef unsigned int uint32_t; + typedef signed int int32_t; + #ifdef _MSC_EXTENSIONS + typedef unsigned _int64 uint64_t; + typedef _int64 int64_t; + #else /* _MSC_EXTENSIONS */ + typedef unsigned long long uint64_t; + typedef long long int64_t; + #endif #endif -#endif +#else /* defined(_MSC_VER) */ + /* + * Not Visual Studio. + * Include to get the integer types and PRi[doux]64 values + * defined. + * + * If the compiler is MinGW, we assume we have - and + * support for %zu in the formatted printing functions. + * + * If the target is UN*X, we assume we have a C99-or-later development + * environment, and thus have - and support for %zu in + * the formatted printing functions. + * + * If the target is MS-DOS, we assume we have - and support + * for %zu in the formatted printing functions. + * + * I.e., assume we have and that it suffices. + */ -/* - * Include to get the integer types and PRi[doux]64 values - * defined. - * - * If the compiler is MSVC, we require VS 2015 or newer, so we - * have - and support for %zu in the formatted - * printing functions. - * - * If the compiler is MinGW, we assume we have - and - * support for %zu in the formatted printing functions. - * - * If the target is UN*X, we assume we have a C99-or-later development - * environment, and thus have - and support for %zu in - * the formatted printing functions. - * - * If the target is MS-DOS, we assume we have - and support - * for %zu in the formatted printing functions. - * - * I.e., assume we have and that it suffices. - */ + /* + * XXX - somehow make sure we have enough C99 support with other + * compilers and support libraries? + */ -/* - * XXX - somehow make sure we have enough C99 support with other - * compilers and support libraries? - */ - -#include + #include +#endif /* defined(_MSC_VER) */ #endif /* pcap/pcap-inttypes.h */ diff --git a/libpcap/pcap/pcap.h b/libpcap/pcap/pcap.h index 8182bef44..6894b3cd3 100644 --- a/libpcap/pcap/pcap.h +++ b/libpcap/pcap/pcap.h @@ -71,7 +71,7 @@ /* * Some software that uses libpcap/WinPcap/Npcap defines _MSC_VER before - * includeing pcap.h if it's not defined - and it defines it to 1500. + * including pcap.h if it's not defined - and it defines it to 1500. * (I'm looking at *you*, lwIP!) * * Attempt to detect this, and undefine _MSC_VER so that we can *reliably* @@ -391,8 +391,8 @@ PCAP_API int pcap_init(unsigned int, char *); * should use pcap_findalldevs() and use the first device. */ PCAP_AVAILABLE_0_4 -PCAP_API char *pcap_lookupdev(char *) -PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device"); +PCAP_DEPRECATED("use 'pcap_findalldevs' and use the first device") +PCAP_API char *pcap_lookupdev(char *); PCAP_AVAILABLE_0_4 PCAP_API int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *); @@ -571,7 +571,7 @@ PCAP_AVAILABLE_0_4 PCAP_API const u_char *pcap_next(pcap_t *, struct pcap_pkthdr *); PCAP_AVAILABLE_0_8 -PCAP_API int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **); +PCAP_API int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **); PCAP_AVAILABLE_0_8 PCAP_API void pcap_breakloop(pcap_t *); @@ -583,7 +583,7 @@ PCAP_AVAILABLE_0_4 PCAP_API int pcap_setfilter(pcap_t *, struct bpf_program *); PCAP_AVAILABLE_0_9 -PCAP_API int pcap_setdirection(pcap_t *, pcap_direction_t); +PCAP_API int pcap_setdirection(pcap_t *, pcap_direction_t); PCAP_AVAILABLE_0_7 PCAP_API int pcap_getnonblock(pcap_t *, char *); @@ -614,6 +614,7 @@ PCAP_API int pcap_compile(pcap_t *, struct bpf_program *, const char *, int, bpf_u_int32); PCAP_AVAILABLE_0_5 +PCAP_DEPRECATED("use pcap_open_dead(), pcap_compile() and pcap_close()") PCAP_API int pcap_compile_nopcap(int, int, struct bpf_program *, const char *, int, bpf_u_int32); @@ -680,8 +681,8 @@ PCAP_API FILE *pcap_file(pcap_t *); * a Windows-only pcap_handle() API that returns the HANDLE. */ PCAP_AVAILABLE_0_4 -PCAP_API int pcap_fileno(pcap_t *) -PCAP_DEPRECATED(pcap_fileno, "use 'pcap_handle'"); +PCAP_DEPRECATED("request a 'pcap_handle' that returns a HANDLE if you need it") +PCAP_API int pcap_fileno(pcap_t *); #else /* _WIN32 */ PCAP_AVAILABLE_0_4 PCAP_API int pcap_fileno(pcap_t *); @@ -878,7 +879,7 @@ PCAP_API const char *pcap_lib_version(void); /* * The formats allowed by pcap_open() are the following: * - file://path_and_filename [opens a local file] - * - rpcap://devicename [opens the selected device devices available on the local host, without using the RPCAP protocol] + * - rpcap://devicename [opens the selected device available on the local host, without using the RPCAP protocol] * - rpcap://host/devicename [opens the selected device available on a remote host] * - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP] * - adaptername [to open a local adapter; kept for compatibility, but it is strongly discouraged] @@ -1013,10 +1014,11 @@ PCAP_API const char *pcap_lib_version(void); * authentication is successful (and the user has the right to open network * devices) the RPCAP connection will continue; otherwise it will be dropped. * - * *******NOTE********: the username and password are sent over the network - * to the capture server *IN CLEAR TEXT*. Don't use this on a network - * that you don't completely control! (And be *really* careful in your - * definition of "completely"!) + * *******NOTE********: unless TLS is being used, the username and password + * are sent over the network to the capture server *IN CLEAR TEXT*. Don't + * use this, without TLS (i.e., with rpcap:// rather than rpcaps://) on + * a network that you don't completely control! (And be *really* careful + * in your definition of "completely"!) */ #define RPCAP_RMTAUTH_PWD 1 diff --git a/libpcap/pcap_breakloop.3pcap b/libpcap/pcap_breakloop.3pcap index 996290f9b..3cd74db27 100644 --- a/libpcap/pcap_breakloop.3pcap +++ b/libpcap/pcap_breakloop.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_BREAKLOOP 3PCAP "25 July 2018" +.TH PCAP_BREAKLOOP 3PCAP "8 December 2022" .SH NAME pcap_breakloop \- force a pcap_dispatch() or pcap_loop() call to return .SH SYNOPSIS @@ -39,11 +39,23 @@ or to return rather than looping; they will return the number of packets that have been processed so far, or .B PCAP_ERROR_BREAK -if no packets have been processed so far. +if no packets have been processed so far. If the loop is currently +blocked waiting for packets to arrive, +.BR pcap_breakloop () +will also, on some platforms, wake up the thread that is blocked. In +this version of libpcap, the only platforms on which a wakeup is caused +by +.BR pcap_breakloop () +are Linux and Windows, and the wakeup will only be caused when capturing +on network interfaces; it will not be caused on other operating systems, +and will not be caused on any OS when capturing on other types of +devices. .PP This routine is safe to use inside a signal handler on UNIX or a console -control handler on Windows, as it merely sets a flag that is checked -within the loop. +control handler on Windows, or in a thread other than the one in which +the loop is running, as it merely sets a flag that is checked within the +loop and, on some platforms, performs a signal-safe and thread-safe API +call. .PP The flag is checked in loops reading packets from the OS - a signal by itself will not necessarily terminate those loops - as well as in loops @@ -61,23 +73,37 @@ packets arrive and the call completes. .PP .ft B Note also that, in a multi-threaded application, if one thread is -blocked in pcap_dispatch(), pcap_loop(), pcap_next(3PCAP), or pcap_next_ex(3PCAP), -a call to pcap_breakloop() in a different thread will not unblock that -thread. +blocked in pcap_dispatch(), pcap_loop(), pcap_next(3PCAP), or +pcap_next_ex(3PCAP), a call to pcap_breakloop() in a different thread +will only unblock that thread on the platforms and capture devices +listed above. +.PP +If a non-zero packet buffer timeout is set on the +.BR pcap_t , +and you are capturing on a network interface, the thread will be +unblocked with the timeout expires. This is not guaranteed to happen +unless at least one packet has arrived; the only platforms on which it +happens are macOS, the BSDs, Solaris 11, AIX, Tru64 UNIX, and Windows. +.PP +If you want to ensure that the loop will eventually be unblocked on any +other platforms, or unblocked when capturing on a device other than a +network interface, you will need to use whatever mechanism the OS +provides for breaking a thread out of blocking calls in order to unblock +the thread, such as thread cancellation or thread signalling in systems +that support POSIX threads. .ft R -You will need to use whatever mechanism the OS provides for -breaking a thread out of blocking calls in order to unblock the thread, -such as thread cancellation or thread signalling in systems that support -POSIX threads, or -.BR SetEvent () -on the result of -.BR pcap_getevent () -on a -.B pcap_t -on which the thread is blocked on Windows. Asynchronous procedure calls -will not work on Windows, as a thread blocked on a -.B pcap_t -will not be in an alertable state. +.PP +.ft B +Note that if pcap_breakloop() unblocks the thread capturing packets, and +you are running on a platform that supports packet buffering, there may +be packets in the buffer that arrived before pcap_breakloop() were +called but that weren't yet provided to libpcap, those packets will not +have been processed by pcap_dispatch() or pcap_loop(). If +pcap_breakloop() was called in order to terminate the capture process, +then, in order to process those packets, you would have to call +pcap_dispatch() one time in order to process the last batch of packets. +This may block until the packet buffer timeout expires, so a non-zero +packet buffer timeout must be used. .ft R .PP Note that @@ -111,5 +137,12 @@ If a positive number is returned, the flag is not cleared, so a subsequent call will return .B PCAP_ERROR_BREAK and clear the flag. +.SH BACKWARD COMPATIBILITY +.PP +This function became available in libpcap release 0.8.1. +.PP +In releases prior to libpcap 1.10.0, +.BR pcap_breakloop () +will not wake up a blocked thread on any platform. .SH SEE ALSO .BR pcap (3PCAP) diff --git a/libpcap/pcap_compile.3pcap.in b/libpcap/pcap_compile.3pcap.in index 8238e54f6..67001fa49 100644 --- a/libpcap/pcap_compile.3pcap.in +++ b/libpcap/pcap_compile.3pcap.in @@ -37,9 +37,9 @@ const char *str, int optimize, bpf_u_int32 netmask); is used to compile the string .I str into a filter program. See -.BR pcap-filter (@MAN_MISC_INFO@) +.BR \%pcap-filter (@MAN_MISC_INFO@) for the syntax of that string. -.I program +.I fp is a pointer to a .I bpf_program struct and is filled in by diff --git a/libpcap/pcap_datalink_val_to_name.3pcap b/libpcap/pcap_datalink_val_to_name.3pcap index bbfa3f80c..41790950a 100644 --- a/libpcap/pcap_datalink_val_to_name.3pcap +++ b/libpcap/pcap_datalink_val_to_name.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_DATALINK_VAL_TO_NAME 3PCAP "15 April 2019" +.TH PCAP_DATALINK_VAL_TO_NAME 3PCAP "4 May 2022" .SH NAME pcap_datalink_val_to_name, pcap_datalink_val_to_description, pcap_datalink_val_to_description_or_dlt \- get a @@ -66,7 +66,7 @@ the dlt argument. .SH BACKWARD COMPATIBILITY The .BR pcap_datalink_val_to_description_or_dlt () -function first became available in libpcap release 1.10.0. In previous +function first became available in libpcap release 1.9.1. In previous releases, .BR pcap_datalink_val_to_description () would have to be called and, if it returned diff --git a/libpcap/pcap_dump_open.3pcap.in b/libpcap/pcap_dump_open.3pcap.in index fddecb8d3..555484ffc 100644 --- a/libpcap/pcap_dump_open.3pcap.in +++ b/libpcap/pcap_dump_open.3pcap.in @@ -81,7 +81,7 @@ order as the host opening the file, and has the same time stamp precision, link-layer header type, and snapshot length as .IR p , it will write new packets at the end of the file. -.SH RETURN VALUES +.SH RETURN VALUE A pointer to a .B pcap_dumper_t structure to use in subsequent diff --git a/libpcap/pcap_findalldevs.3pcap b/libpcap/pcap_findalldevs.3pcap index 41c98fe14..0dcc0af69 100644 --- a/libpcap/pcap_findalldevs.3pcap +++ b/libpcap/pcap_findalldevs.3pcap @@ -204,7 +204,9 @@ returns on success and .B PCAP_ERROR on failure; as indicated, finding no -devices is considered success, rather than failure, so 0 will be +devices is considered success, rather than failure, so +.B 0 +will be returned in that case. If .B PCAP_ERROR is returned, diff --git a/libpcap/pcap_get_tstamp_precision.3pcap.in b/libpcap/pcap_get_tstamp_precision.3pcap.in index 7dbb56900..46451446b 100644 --- a/libpcap/pcap_get_tstamp_precision.3pcap.in +++ b/libpcap/pcap_get_tstamp_precision.3pcap.in @@ -53,4 +53,4 @@ in seconds and microseconds. .SH SEE ALSO .BR pcap (3PCAP), .BR pcap_set_tstamp_precision (3PCAP), -.BR pcap-tstamp (@MAN_MISC_INFO@) +.BR \%pcap-tstamp (@MAN_MISC_INFO@) diff --git a/libpcap/pcap_inject.3pcap b/libpcap/pcap_inject.3pcap index 6b4554e72..83eae1c38 100644 --- a/libpcap/pcap_inject.3pcap +++ b/libpcap/pcap_inject.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_INJECT 3PCAP "25 July 2018" +.TH PCAP_INJECT 3PCAP "5 March 2022" .SH NAME pcap_inject, pcap_sendpacket \- transmit a packet .SH SYNOPSIS @@ -74,16 +74,20 @@ comes from OpenBSD; comes from WinPcap/Npcap. Both are provided for compatibility.) .SH RETURN VALUE .BR pcap_inject () -returns the number of bytes written on success and +returns the number of bytes written on success, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, and .B PCAP_ERROR -on failure. +on other errors. .PP .BR pcap_sendpacket () returns .B 0 -on success and +on success, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, and .B PCAP_ERROR -on failure. +on other errors. .PP If .B PCAP_ERROR diff --git a/libpcap/pcap_list_tstamp_types.3pcap.in b/libpcap/pcap_list_tstamp_types.3pcap.in index 74ef00ac5..8b6174f4c 100644 --- a/libpcap/pcap_list_tstamp_types.3pcap.in +++ b/libpcap/pcap_list_tstamp_types.3pcap.in @@ -42,7 +42,7 @@ allocates an array to hold the list and sets .I *tstamp_typesp to point to the array. See -.BR pcap-tstamp (@MAN_MISC_INFO@) +.BR \%pcap-tstamp (@MAN_MISC_INFO@) for a list of all the time stamp types. .PP The caller is responsible for freeing the array with @@ -79,4 +79,4 @@ type offered by a capture source is available. .SH SEE ALSO .BR pcap (3PCAP), .BR pcap_tstamp_type_val_to_name (3PCAP), -.BR pcap-tstamp (@MAN_MISC_INFO@) +.BR \%pcap-tstamp (@MAN_MISC_INFO@) diff --git a/libpcap/pcap_loop.3pcap b/libpcap/pcap_loop.3pcap index 3d741efaa..0c5952627 100644 --- a/libpcap/pcap_loop.3pcap +++ b/libpcap/pcap_loop.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_LOOP 3PCAP "22 August 2020" +.TH PCAP_LOOP 3PCAP "5 March 2022" .SH NAME pcap_loop, pcap_dispatch \- process packets from a live capture or savefile .SH SYNOPSIS @@ -164,12 +164,15 @@ if .I cnt is exhausted or if, when reading from a ``savefile'', no more packets are available. It returns -.B PCAP_ERROR -if an error occurs or .B PCAP_ERROR_BREAK if the loop terminated due to a call to .BR pcap_breakloop () -before any packets were processed. +before any packets were processed, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, +or +.B PCAP_ERROR +if another error occurs. It does .B not return when live packet buffer timeouts occur; instead, it attempts to @@ -184,12 +187,15 @@ packets arrive, the timeout expires before any packets arrive, or if the file descriptor for the capture device is in non-blocking mode and no packets were available to be read) or if no more packets are available in a ``savefile.'' It returns -.B PCAP_ERROR -if an error occurs or .B PCAP_ERROR_BREAK if the loop terminated due to a call to .BR pcap_breakloop () -before any packets were processed. +before any packets were processed, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, +or +.B PCAP_ERROR +if another error occurs. .ft B If your application uses pcap_breakloop(), make sure that you explicitly check for PCAP_ERROR and PCAP_ERROR_BREAK, diff --git a/libpcap/pcap_next_ex.3pcap b/libpcap/pcap_next_ex.3pcap index 2bd1a4273..4d2c43e87 100644 --- a/libpcap/pcap_next_ex.3pcap +++ b/libpcap/pcap_next_ex.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_NEXT_EX 3PCAP "25 July 2018" +.TH PCAP_NEXT_EX 3PCAP "5 March 2022" .SH NAME pcap_next_ex, pcap_next \- read the next packet from a pcap_t .SH SYNOPSIS @@ -120,12 +120,15 @@ if the packet was read without problems, .B 0 if packets are being read from a live capture and the packet buffer timeout expired, -.B PCAP_ERROR -if an error occurred while reading the packet, and .B PCAP_ERROR_BREAK if packets are being read from a ``savefile'' and there are no more packets to read -from the savefile. If +from the savefile, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, +or +.B PCAP_ERROR +if an error occurred while reading the packet. If .B PCAP_ERROR is returned, .BR pcap_geterr (3PCAP) diff --git a/libpcap/pcap_open_offline.3pcap.in b/libpcap/pcap_open_offline.3pcap.in index 5e878fea9..e48bf25eb 100644 --- a/libpcap/pcap_open_offline.3pcap.in +++ b/libpcap/pcap_open_offline.3pcap.in @@ -50,7 +50,7 @@ are called to open a ``savefile'' for reading. .I fname specifies the name of the file to open. The file can have the pcap file format as described in -.BR pcap-savefile (@MAN_FILE_FORMATS@), +.BR \%pcap-savefile (@MAN_FILE_FORMATS@), which is the file format used by, among other programs, .BR tcpdump (1) and @@ -114,4 +114,4 @@ became available in libpcap release 1.5.1. In previous releases, time stamps from a savefile are always given in seconds and microseconds. .SH SEE ALSO .BR pcap (3PCAP), -.BR pcap-savefile (@MAN_FILE_FORMATS@) +.BR \%pcap-savefile (@MAN_FILE_FORMATS@) diff --git a/libpcap/pcap_set_datalink.3pcap b/libpcap/pcap_set_datalink.3pcap index 14e9d209e..fd9079131 100644 --- a/libpcap/pcap_set_datalink.3pcap +++ b/libpcap/pcap_set_datalink.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SET_DATALINK 3PCAP "25 July 2018" +.TH PCAP_SET_DATALINK 3PCAP "5 March 2022" .SH NAME pcap_set_datalink \- set the link-layer header type to be used by a capture device @@ -40,9 +40,11 @@ to the type specified by .BR pcap_set_datalink () returns .B 0 -on success and +on success, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, or .B PCAP_ERROR -on failure. If +on other errors. If .B PCAP_ERROR is returned, .BR pcap_geterr (3PCAP) diff --git a/libpcap/pcap_set_immediate_mode.3pcap.in b/libpcap/pcap_set_immediate_mode.3pcap.in index e493d55aa..95c9cffbd 100644 --- a/libpcap/pcap_set_immediate_mode.3pcap.in +++ b/libpcap/pcap_set_immediate_mode.3pcap.in @@ -70,7 +70,7 @@ don't assume it's sufficient); .IP on Digital UNIX/Tru64 UNIX, immediate mode must be turned on by doing a .B BIOCMBIC -.BR ioctl , +.BR ioctl (), as documented in .BR packetfilter (7), to clear the diff --git a/libpcap/pcap_set_tstamp_precision.3pcap.in b/libpcap/pcap_set_tstamp_precision.3pcap.in index eb449d5d8..1889f43df 100644 --- a/libpcap/pcap_set_tstamp_precision.3pcap.in +++ b/libpcap/pcap_set_tstamp_precision.3pcap.in @@ -65,4 +65,4 @@ in seconds and microseconds. .SH SEE ALSO .BR pcap (3PCAP), .BR pcap_get_tstamp_precision (3PCAP), -.BR pcap-tstamp (@MAN_MISC_INFO@) +.BR \%pcap-tstamp (@MAN_MISC_INFO@) diff --git a/libpcap/pcap_set_tstamp_type.3pcap.in b/libpcap/pcap_set_tstamp_type.3pcap.in index e19d6e5fb..cd2dc71ce 100644 --- a/libpcap/pcap_set_tstamp_type.3pcap.in +++ b/libpcap/pcap_set_tstamp_type.3pcap.in @@ -45,7 +45,7 @@ that has not yet been activated by will give a list of the time stamp types supported by a given capture device. See -.BR pcap-tstamp (@MAN_MISC_INFO@) +.BR \%pcap-tstamp (@MAN_MISC_INFO@) for a list of all the time stamp types. .SH RETURN VALUE .BR pcap_set_tstamp_type () diff --git a/libpcap/pcap_setdirection.3pcap b/libpcap/pcap_setdirection.3pcap index 7b3884505..04278e848 100644 --- a/libpcap/pcap_setdirection.3pcap +++ b/libpcap/pcap_setdirection.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SETDIRECTION 3PCAP "25 July 2018" +.TH PCAP_SETDIRECTION 3PCAP "5 March 2022" .SH NAME pcap_setdirection \- set the direction for which packets will be captured .SH SYNOPSIS @@ -59,9 +59,11 @@ This operation is not supported if a ``savefile'' is being read. .BR pcap_setdirection () returns .B 0 -on success and +on success, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, or .B PCAP_ERROR -on failure. If +on other errors. If .B PCAP_ERROR is returned, .BR pcap_geterr (3PCAP) diff --git a/libpcap/pcap_setfilter.3pcap b/libpcap/pcap_setfilter.3pcap index 1e3c5a593..e063ae0ea 100644 --- a/libpcap/pcap_setfilter.3pcap +++ b/libpcap/pcap_setfilter.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SETFILTER 3PCAP "25 July 2018" +.TH PCAP_SETFILTER 3PCAP "5 March 2022" .SH NAME pcap_setfilter \- set the filter .SH SYNOPSIS @@ -42,9 +42,11 @@ struct, usually the result of a call to .BR pcap_setfilter () returns .B 0 -on success and +on success, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, or .B PCAP_ERROR -on failure. If +on other errors. If .B PCAP_ERROR is returned, .BR pcap_geterr (3PCAP) diff --git a/libpcap/pcap_setnonblock.3pcap b/libpcap/pcap_setnonblock.3pcap index 65cfea284..1f3364747 100644 --- a/libpcap/pcap_setnonblock.3pcap +++ b/libpcap/pcap_setnonblock.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SETNONBLOCK 3PCAP "25 July 2018" +.TH PCAP_SETNONBLOCK 3PCAP "5 March 2022" .SH NAME pcap_setnonblock, pcap_getnonblock \- set or get the state of non-blocking mode on a capture device @@ -64,7 +64,7 @@ immediately rather than blocking waiting for packets to arrive. .BR pcap_loop (3PCAP) will loop forever, consuming CPU time when no packets are currently available; -.BR pacp_dispatch () +.BR pcap_dispatch () should be used instead. .BR pcap_next (3PCAP) will return @@ -87,7 +87,10 @@ returns the current ``non-blocking'' state of the capture descriptor; it always returns .B 0 on ``savefiles''. -If there is an error, +If called on a capture handle that has been created but not activated, +.B PCAP_ERROR_NOT_ACTIVATED +is returned. +If there is another error, .B PCAP_ERROR is returned and .I errbuf diff --git a/libpcap/pcap_stats.3pcap b/libpcap/pcap_stats.3pcap index aa03013c8..98be9bd7d 100644 --- a/libpcap/pcap_stats.3pcap +++ b/libpcap/pcap_stats.3pcap @@ -17,7 +17,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_STATS 3PCAP "25 July 2018" +.TH PCAP_STATS 3PCAP "5 March 2022" .SH NAME pcap_stats \- get capture statistics .SH SYNOPSIS @@ -85,9 +85,12 @@ that the interface did not drop any packets. .BR pcap_stats () returns .B 0 -on success and returns +on success, +.B PCAP_ERROR_NOT_ACTIVATED +if called on a capture handle that has been created but not activated, +or .B PCAP_ERROR -if there is an error or if +if there is another error or if .I p doesn't support packet statistics. If .B PCAP_ERROR diff --git a/libpcap/pflog.h b/libpcap/pflog.h new file mode 100644 index 000000000..b49d04fc8 --- /dev/null +++ b/libpcap/pflog.h @@ -0,0 +1,157 @@ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * pflog headers, at least as they exist now. + */ +#define PFLOG_IFNAMSIZ 16 +#define PFLOG_RULESET_NAME_SIZE 16 + +/* + * Direction values. + */ +#define PF_INOUT 0 +#define PF_IN 1 +#define PF_OUT 2 +#if defined(__OpenBSD__) +#define PF_FWD 3 +#endif + +/* + * Reason values. + */ +#define PFRES_MATCH 0 +#define PFRES_BADOFF 1 +#define PFRES_FRAG 2 +#define PFRES_SHORT 3 +#define PFRES_NORM 4 +#define PFRES_MEMORY 5 +#define PFRES_TS 6 +#define PFRES_CONGEST 7 +#define PFRES_IPOPTIONS 8 +#define PFRES_PROTCKSUM 9 +#define PFRES_BADSTATE 10 +#define PFRES_STATEINS 11 +#define PFRES_MAXSTATES 12 +#define PFRES_SRCLIMIT 13 +#define PFRES_SYNPROXY 14 +#if defined(__FreeBSD__) +#define PFRES_MAPFAILED 15 +#elif defined(__NetBSD__) +#define PFRES_STATELOCKED 15 +#elif defined(__OpenBSD__) +#define PFRES_TRANSLATE 15 +#define PFRES_NOROUTE 16 +#elif defined(__APPLE__) +#define PFRES_DUMMYNET 15 +#endif + +/* + * Action values. + */ +#define PF_PASS 0 +#define PF_DROP 1 +#define PF_SCRUB 2 +#define PF_NOSCRUB 3 +#define PF_NAT 4 +#define PF_NONAT 5 +#define PF_BINAT 6 +#define PF_NOBINAT 7 +#define PF_RDR 8 +#define PF_NORDR 9 +#define PF_SYNPROXY_DROP 10 +#if defined(__FreeBSD__) +#define PF_DEFER 11 +#elif defined(__OpenBSD__) +#define PF_DEFER 11 +#define PF_MATCH 12 +#define PF_DIVERT 13 +#define PF_RT 14 +#define PF_AFRT 15 +#elif defined(__APPLE__) +#define PF_DUMMYNET 11 +#define PF_NODUMMYNET 12 +#define PF_NAT64 13 +#define PF_NONAT64 14 +#endif + +struct pf_addr { + union { + struct in_addr v4; + struct in6_addr v6; + uint8_t addr8[16]; + uint16_t addr16[8]; + uint32_t addr32[4]; + } pfa; /* 128-bit address */ +#define v4 pfa.v4 +#define v6 pfa.v6 +#define addr8 pfa.addr8 +#define addr16 pfa.addr16 +#define addr32 pfa.addr32 +}; + +struct pfloghdr { + uint8_t length; + uint8_t af; + uint8_t action; + uint8_t reason; + char ifname[PFLOG_IFNAMSIZ]; + char ruleset[PFLOG_RULESET_NAME_SIZE]; + uint32_t rulenr; + uint32_t subrulenr; + uint32_t uid; + int32_t pid; + uint32_t rule_uid; + int32_t rule_pid; + uint8_t dir; +#if defined(__OpenBSD__) + uint8_t rewritten; + uint8_t naf; + uint8_t pad[1]; +#else + uint8_t pad[3]; +#endif +#if defined(__FreeBSD__) + uint32_t ridentifier; + uint8_t reserve; + uint8_t pad2[3]; +#elif defined(__OpenBSD__) + struct pf_addr saddr; + struct pf_addr daddr; + uint16_t sport; + uint16_t dport; +#endif +}; + + + diff --git a/libpcap/rpcap-protocol.h b/libpcap/rpcap-protocol.h index a69cf8023..a93b0a8b4 100644 --- a/libpcap/rpcap-protocol.h +++ b/libpcap/rpcap-protocol.h @@ -132,10 +132,12 @@ * XXX - use the C99 types? Microsoft's newer versions of Visual Studio * support them. */ +#ifndef __HAIKU__ typedef unsigned char uint8; /* 8-bit unsigned integer */ typedef unsigned short uint16; /* 16-bit unsigned integer */ typedef unsigned int uint32; /* 32-bit unsigned integer */ typedef int int32; /* 32-bit signed integer */ +#endif /* Common header for all the RPCAP messages */ struct rpcap_header @@ -154,6 +156,25 @@ struct rpcap_header * Older servers don't provide this; they support only version 0. */ struct rpcap_authreply +{ + uint8 minvers; /* Minimum version supported */ + uint8 maxvers; /* Maximum version supported */ + uint8 pad[2]; /* Pad to 4-byte boundary **/ + uint32 byte_order_magic; /* RPCAP_BYTE_ORDER_MAGIC, in server byte order */ +}; + +/* + * Any resemblance between this and the pcap file magic number + * is purely coincidental, trust me. + */ +#define RPCAP_BYTE_ORDER_MAGIC 0xa1b2c3d4U +#define RPCAP_BYTE_ORDER_MAGIC_SWAPPED 0xd4c3b2a1U + +/* + * Older version of authentication reply, without byte order indication + * and padding. + */ +struct rpcap_authreply_old { uint8 minvers; /* Minimum version supported */ uint8 maxvers; /* Maximum version supported */ diff --git a/libpcap/savefile.c b/libpcap/savefile.c index d04b917a5..db8a3aa05 100644 --- a/libpcap/savefile.c +++ b/libpcap/savefile.c @@ -111,6 +111,16 @@ sf_setnonblock(pcap_t *p, int nonblock _U_) return (-1); } +static int +sf_cant_set_rfmon(pcap_t *p _U_) +{ + /* + * This is a savefile, not a device on which you can capture, + * so never say it supports being put into monitor mode. + */ + return (0); +} + static int sf_stats(pcap_t *p, struct pcap_stat *ps _U_) { @@ -350,7 +360,7 @@ pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision, if (fname[0] == '-' && fname[1] == '\0') { fp = stdin; - if (stdin == NULL) { + if (fp == NULL) { snprintf(errbuf, PCAP_ERRBUF_SIZE, "The standard input is not open"); return (NULL); @@ -551,6 +561,7 @@ found: p->selectable_fd = fileno(fp); #endif + p->can_set_rfmon_op = sf_cant_set_rfmon; p->read_op = pcap_offline_read; p->inject_op = sf_inject; p->setfilter_op = install_bpf_program; @@ -618,12 +629,27 @@ int pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { struct bpf_insn *fcode; - int status = 0; int n = 0; u_char *data; - while (status == 0) { + /* + * This can conceivably process more than INT_MAX packets, + * which would overflow the packet count, causing it either + * to look like a negative number, and thus cause us to + * return a value that looks like an error, or overflow + * back into positive territory, and thus cause us to + * return a too-low count. + * + * Therefore, if the packet count is unlimited, we clip + * it at INT_MAX; this routine is not expected to + * process packets indefinitely, so that's not an issue. + */ + if (PACKET_COUNT_IS_UNLIMITED(cnt)) + cnt = INT_MAX; + + for (;;) { struct pcap_pkthdr h; + int status; /* * Has "pcap_breakloop()" been called? @@ -643,16 +669,28 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) } status = p->next_packet_op(p, &h, &data); - if (status) { - if (status == 1) - return (0); + if (status < 0) { + /* + * Error. Pass it back to the caller. + */ return (status); } + if (status == 0) { + /* + * EOF. Nothing more to process; + */ + break; + } + /* + * OK, we've read a packet; run it through the filter + * and, if it passes, process it. + */ if ((fcode = p->fcode.bf_insns) == NULL || pcap_filter(fcode, data, h.len, h.caplen)) { (*callback)(user, &h, data); - if (++n >= cnt && cnt > 0) + n++; /* count the packet */ + if (n >= cnt) break; } } diff --git a/libpcap/scanner.c b/libpcap/scanner.c index 7b7979dbd..596507e23 100644 --- a/libpcap/scanner.c +++ b/libpcap/scanner.c @@ -24,9 +24,16 @@ */ #include +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include "diag-control.h" -#line 30 "scanner.c" +#line 37 "scanner.c" #define YY_INT_ALIGNED short int @@ -2893,7 +2900,7 @@ static yyconst flex_int16_t yy_chk[7789] = * We want to generate code that can be used by a reentrant parser * generated by Bison or Berkeley YACC. */ -#line 67 "scanner.l" +#line 74 "scanner.l" /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -2919,10 +2926,6 @@ static yyconst flex_int16_t yy_chk[7789] = #include "pcap-int.h" -#include "gencode.h" - -#include "grammar.h" - /* * Earlier versions of Flex don't declare these, so we declare them * ourselves to squelch warnings. @@ -2983,7 +2986,7 @@ static int stou(char *, YYSTYPE *, compiler_state_t *); */ DIAG_OFF_FLEX -#line 2987 "scanner.c" +#line 2990 "scanner.c" #define INITIAL 0 @@ -3254,9 +3257,9 @@ YY_DECL } { -#line 252 "scanner.l" +#line 255 "scanner.l" -#line 3260 "scanner.c" +#line 3263 "scanner.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -3311,634 +3314,634 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 253 "scanner.l" +#line 256 "scanner.l" return DST; YY_BREAK case 2: YY_RULE_SETUP -#line 254 "scanner.l" +#line 257 "scanner.l" return SRC; YY_BREAK case 3: YY_RULE_SETUP -#line 256 "scanner.l" +#line 259 "scanner.l" return LINK; YY_BREAK case 4: YY_RULE_SETUP -#line 257 "scanner.l" +#line 260 "scanner.l" return LINK; YY_BREAK case 5: YY_RULE_SETUP -#line 258 "scanner.l" +#line 261 "scanner.l" return ARP; YY_BREAK case 6: YY_RULE_SETUP -#line 259 "scanner.l" +#line 262 "scanner.l" return RARP; YY_BREAK case 7: YY_RULE_SETUP -#line 260 "scanner.l" +#line 263 "scanner.l" return IP; YY_BREAK case 8: YY_RULE_SETUP -#line 261 "scanner.l" +#line 264 "scanner.l" return SCTP; YY_BREAK case 9: YY_RULE_SETUP -#line 262 "scanner.l" +#line 265 "scanner.l" return TCP; YY_BREAK case 10: YY_RULE_SETUP -#line 263 "scanner.l" +#line 266 "scanner.l" return UDP; YY_BREAK case 11: YY_RULE_SETUP -#line 264 "scanner.l" +#line 267 "scanner.l" return ICMP; YY_BREAK case 12: YY_RULE_SETUP -#line 265 "scanner.l" +#line 268 "scanner.l" return IGMP; YY_BREAK case 13: YY_RULE_SETUP -#line 266 "scanner.l" +#line 269 "scanner.l" return IGRP; YY_BREAK case 14: YY_RULE_SETUP -#line 267 "scanner.l" +#line 270 "scanner.l" return PIM; YY_BREAK case 15: YY_RULE_SETUP -#line 268 "scanner.l" +#line 271 "scanner.l" return VRRP; YY_BREAK case 16: YY_RULE_SETUP -#line 269 "scanner.l" +#line 272 "scanner.l" return CARP; YY_BREAK case 17: YY_RULE_SETUP -#line 270 "scanner.l" +#line 273 "scanner.l" return RADIO; YY_BREAK case 18: YY_RULE_SETUP -#line 272 "scanner.l" +#line 275 "scanner.l" return IPV6; YY_BREAK case 19: YY_RULE_SETUP -#line 273 "scanner.l" +#line 276 "scanner.l" return ICMPV6; YY_BREAK case 20: YY_RULE_SETUP -#line 274 "scanner.l" +#line 277 "scanner.l" return AH; YY_BREAK case 21: YY_RULE_SETUP -#line 275 "scanner.l" +#line 278 "scanner.l" return ESP; YY_BREAK case 22: YY_RULE_SETUP -#line 277 "scanner.l" +#line 280 "scanner.l" return ATALK; YY_BREAK case 23: YY_RULE_SETUP -#line 278 "scanner.l" +#line 281 "scanner.l" return AARP; YY_BREAK case 24: YY_RULE_SETUP -#line 279 "scanner.l" +#line 282 "scanner.l" return DECNET; YY_BREAK case 25: YY_RULE_SETUP -#line 280 "scanner.l" +#line 283 "scanner.l" return LAT; YY_BREAK case 26: YY_RULE_SETUP -#line 281 "scanner.l" +#line 284 "scanner.l" return SCA; YY_BREAK case 27: YY_RULE_SETUP -#line 282 "scanner.l" +#line 285 "scanner.l" return MOPRC; YY_BREAK case 28: YY_RULE_SETUP -#line 283 "scanner.l" +#line 286 "scanner.l" return MOPDL; YY_BREAK case 29: YY_RULE_SETUP -#line 285 "scanner.l" +#line 288 "scanner.l" return ISO; YY_BREAK case 30: YY_RULE_SETUP -#line 286 "scanner.l" +#line 289 "scanner.l" return ESIS; YY_BREAK case 31: YY_RULE_SETUP -#line 287 "scanner.l" +#line 290 "scanner.l" return ESIS; YY_BREAK case 32: YY_RULE_SETUP -#line 288 "scanner.l" +#line 291 "scanner.l" return ISIS; YY_BREAK case 33: YY_RULE_SETUP -#line 289 "scanner.l" +#line 292 "scanner.l" return ISIS; YY_BREAK case 34: YY_RULE_SETUP -#line 290 "scanner.l" +#line 293 "scanner.l" return L1; YY_BREAK case 35: YY_RULE_SETUP -#line 291 "scanner.l" +#line 294 "scanner.l" return L2; YY_BREAK case 36: YY_RULE_SETUP -#line 292 "scanner.l" +#line 295 "scanner.l" return IIH; YY_BREAK case 37: YY_RULE_SETUP -#line 293 "scanner.l" +#line 296 "scanner.l" return LSP; YY_BREAK case 38: YY_RULE_SETUP -#line 294 "scanner.l" +#line 297 "scanner.l" return SNP; YY_BREAK case 39: YY_RULE_SETUP -#line 295 "scanner.l" +#line 298 "scanner.l" return CSNP; YY_BREAK case 40: YY_RULE_SETUP -#line 296 "scanner.l" +#line 299 "scanner.l" return PSNP; YY_BREAK case 41: YY_RULE_SETUP -#line 298 "scanner.l" +#line 301 "scanner.l" return CLNP; YY_BREAK case 42: YY_RULE_SETUP -#line 300 "scanner.l" +#line 303 "scanner.l" return STP; YY_BREAK case 43: YY_RULE_SETUP -#line 302 "scanner.l" +#line 305 "scanner.l" return IPX; YY_BREAK case 44: YY_RULE_SETUP -#line 304 "scanner.l" +#line 307 "scanner.l" return NETBEUI; YY_BREAK case 45: YY_RULE_SETUP -#line 306 "scanner.l" +#line 309 "scanner.l" return HOST; YY_BREAK case 46: YY_RULE_SETUP -#line 307 "scanner.l" +#line 310 "scanner.l" return NET; YY_BREAK case 47: YY_RULE_SETUP -#line 308 "scanner.l" +#line 311 "scanner.l" return NETMASK; YY_BREAK case 48: YY_RULE_SETUP -#line 309 "scanner.l" +#line 312 "scanner.l" return PORT; YY_BREAK case 49: YY_RULE_SETUP -#line 310 "scanner.l" +#line 313 "scanner.l" return PORTRANGE; YY_BREAK case 50: YY_RULE_SETUP -#line 311 "scanner.l" +#line 314 "scanner.l" return PROTO; YY_BREAK case 51: YY_RULE_SETUP -#line 312 "scanner.l" +#line 315 "scanner.l" return PROTOCHAIN; YY_BREAK case 52: YY_RULE_SETUP -#line 314 "scanner.l" +#line 317 "scanner.l" return GATEWAY; YY_BREAK case 53: YY_RULE_SETUP -#line 316 "scanner.l" +#line 319 "scanner.l" return TYPE; YY_BREAK case 54: YY_RULE_SETUP -#line 317 "scanner.l" +#line 320 "scanner.l" return SUBTYPE; YY_BREAK case 55: YY_RULE_SETUP -#line 318 "scanner.l" +#line 321 "scanner.l" return DIR; YY_BREAK case 56: YY_RULE_SETUP -#line 319 "scanner.l" +#line 322 "scanner.l" return ADDR1; YY_BREAK case 57: YY_RULE_SETUP -#line 320 "scanner.l" +#line 323 "scanner.l" return ADDR2; YY_BREAK case 58: YY_RULE_SETUP -#line 321 "scanner.l" +#line 324 "scanner.l" return ADDR3; YY_BREAK case 59: YY_RULE_SETUP -#line 322 "scanner.l" +#line 325 "scanner.l" return ADDR4; YY_BREAK case 60: YY_RULE_SETUP -#line 323 "scanner.l" +#line 326 "scanner.l" return RA; YY_BREAK case 61: YY_RULE_SETUP -#line 324 "scanner.l" +#line 327 "scanner.l" return TA; YY_BREAK case 62: YY_RULE_SETUP -#line 326 "scanner.l" +#line 329 "scanner.l" return LESS; YY_BREAK case 63: YY_RULE_SETUP -#line 327 "scanner.l" +#line 330 "scanner.l" return GREATER; YY_BREAK case 64: YY_RULE_SETUP -#line 328 "scanner.l" +#line 331 "scanner.l" return CBYTE; YY_BREAK case 65: YY_RULE_SETUP -#line 329 "scanner.l" +#line 332 "scanner.l" return TK_BROADCAST; YY_BREAK case 66: YY_RULE_SETUP -#line 330 "scanner.l" +#line 333 "scanner.l" return TK_MULTICAST; YY_BREAK case 67: YY_RULE_SETUP -#line 332 "scanner.l" +#line 335 "scanner.l" return AND; YY_BREAK case 68: YY_RULE_SETUP -#line 333 "scanner.l" +#line 336 "scanner.l" return OR; YY_BREAK case 69: YY_RULE_SETUP -#line 334 "scanner.l" +#line 337 "scanner.l" return '!'; YY_BREAK case 70: YY_RULE_SETUP -#line 336 "scanner.l" +#line 339 "scanner.l" return LEN; YY_BREAK case 71: YY_RULE_SETUP -#line 337 "scanner.l" +#line 340 "scanner.l" return INBOUND; YY_BREAK case 72: YY_RULE_SETUP -#line 338 "scanner.l" +#line 341 "scanner.l" return OUTBOUND; YY_BREAK case 73: YY_RULE_SETUP -#line 340 "scanner.l" +#line 343 "scanner.l" return IFINDEX; YY_BREAK case 74: YY_RULE_SETUP -#line 342 "scanner.l" +#line 345 "scanner.l" return VLAN; YY_BREAK case 75: YY_RULE_SETUP -#line 343 "scanner.l" +#line 346 "scanner.l" return MPLS; YY_BREAK case 76: YY_RULE_SETUP -#line 344 "scanner.l" +#line 347 "scanner.l" return PPPOED; YY_BREAK case 77: YY_RULE_SETUP -#line 345 "scanner.l" +#line 348 "scanner.l" return PPPOES; YY_BREAK case 78: YY_RULE_SETUP -#line 346 "scanner.l" +#line 349 "scanner.l" return GENEVE; YY_BREAK case 79: YY_RULE_SETUP -#line 348 "scanner.l" +#line 351 "scanner.l" return LANE; YY_BREAK case 80: YY_RULE_SETUP -#line 349 "scanner.l" +#line 352 "scanner.l" return LLC; YY_BREAK case 81: YY_RULE_SETUP -#line 350 "scanner.l" +#line 353 "scanner.l" return METAC; YY_BREAK case 82: YY_RULE_SETUP -#line 351 "scanner.l" +#line 354 "scanner.l" return BCC; YY_BREAK case 83: YY_RULE_SETUP -#line 352 "scanner.l" +#line 355 "scanner.l" return OAM; YY_BREAK case 84: YY_RULE_SETUP -#line 353 "scanner.l" +#line 356 "scanner.l" return OAMF4; YY_BREAK case 85: YY_RULE_SETUP -#line 354 "scanner.l" +#line 357 "scanner.l" return OAMF4EC; YY_BREAK case 86: YY_RULE_SETUP -#line 355 "scanner.l" +#line 358 "scanner.l" return OAMF4SC; YY_BREAK case 87: YY_RULE_SETUP -#line 356 "scanner.l" +#line 359 "scanner.l" return SC; YY_BREAK case 88: YY_RULE_SETUP -#line 357 "scanner.l" +#line 360 "scanner.l" return ILMIC; YY_BREAK case 89: YY_RULE_SETUP -#line 358 "scanner.l" +#line 361 "scanner.l" return VPI; YY_BREAK case 90: YY_RULE_SETUP -#line 359 "scanner.l" +#line 362 "scanner.l" return VCI; YY_BREAK case 91: YY_RULE_SETUP -#line 360 "scanner.l" +#line 363 "scanner.l" return CONNECTMSG; YY_BREAK case 92: YY_RULE_SETUP -#line 361 "scanner.l" +#line 364 "scanner.l" return METACONNECT; YY_BREAK case 93: YY_RULE_SETUP -#line 363 "scanner.l" +#line 366 "scanner.l" return PF_IFNAME; YY_BREAK case 94: YY_RULE_SETUP -#line 364 "scanner.l" +#line 367 "scanner.l" return PF_RSET; YY_BREAK case 95: YY_RULE_SETUP -#line 365 "scanner.l" +#line 368 "scanner.l" return PF_RNR; YY_BREAK case 96: YY_RULE_SETUP -#line 366 "scanner.l" +#line 369 "scanner.l" return PF_SRNR; YY_BREAK case 97: YY_RULE_SETUP -#line 367 "scanner.l" +#line 370 "scanner.l" return PF_REASON; YY_BREAK case 98: YY_RULE_SETUP -#line 368 "scanner.l" +#line 371 "scanner.l" return PF_ACTION; YY_BREAK case 99: YY_RULE_SETUP -#line 370 "scanner.l" +#line 373 "scanner.l" return FISU; YY_BREAK case 100: YY_RULE_SETUP -#line 371 "scanner.l" +#line 374 "scanner.l" return LSSU; YY_BREAK case 101: YY_RULE_SETUP -#line 372 "scanner.l" +#line 375 "scanner.l" return LSSU; YY_BREAK case 102: YY_RULE_SETUP -#line 373 "scanner.l" +#line 376 "scanner.l" return MSU; YY_BREAK case 103: YY_RULE_SETUP -#line 374 "scanner.l" +#line 377 "scanner.l" return HFISU; YY_BREAK case 104: YY_RULE_SETUP -#line 375 "scanner.l" +#line 378 "scanner.l" return HLSSU; YY_BREAK case 105: YY_RULE_SETUP -#line 376 "scanner.l" +#line 379 "scanner.l" return HMSU; YY_BREAK case 106: YY_RULE_SETUP -#line 377 "scanner.l" +#line 380 "scanner.l" return SIO; YY_BREAK case 107: YY_RULE_SETUP -#line 378 "scanner.l" +#line 381 "scanner.l" return OPC; YY_BREAK case 108: YY_RULE_SETUP -#line 379 "scanner.l" +#line 382 "scanner.l" return DPC; YY_BREAK case 109: YY_RULE_SETUP -#line 380 "scanner.l" +#line 383 "scanner.l" return SLS; YY_BREAK case 110: YY_RULE_SETUP -#line 381 "scanner.l" +#line 384 "scanner.l" return HSIO; YY_BREAK case 111: YY_RULE_SETUP -#line 382 "scanner.l" +#line 385 "scanner.l" return HOPC; YY_BREAK case 112: YY_RULE_SETUP -#line 383 "scanner.l" +#line 386 "scanner.l" return HDPC; YY_BREAK case 113: YY_RULE_SETUP -#line 384 "scanner.l" +#line 387 "scanner.l" return HSLS; YY_BREAK case 114: /* rule 114 can match eol */ YY_RULE_SETUP -#line 386 "scanner.l" +#line 389 "scanner.l" ; YY_BREAK case 115: YY_RULE_SETUP -#line 387 "scanner.l" +#line 390 "scanner.l" return yytext[0]; YY_BREAK case 116: YY_RULE_SETUP -#line 388 "scanner.l" +#line 391 "scanner.l" return GEQ; YY_BREAK case 117: YY_RULE_SETUP -#line 389 "scanner.l" +#line 392 "scanner.l" return LEQ; YY_BREAK case 118: YY_RULE_SETUP -#line 390 "scanner.l" +#line 393 "scanner.l" return NEQ; YY_BREAK case 119: YY_RULE_SETUP -#line 391 "scanner.l" +#line 394 "scanner.l" return '='; YY_BREAK case 120: YY_RULE_SETUP -#line 392 "scanner.l" +#line 395 "scanner.l" return LSH; YY_BREAK case 121: YY_RULE_SETUP -#line 393 "scanner.l" +#line 396 "scanner.l" return RSH; YY_BREAK case 122: YY_RULE_SETUP -#line 394 "scanner.l" +#line 397 "scanner.l" { yylval->s = sdup(yyextra, yytext); return AID; } YY_BREAK case 123: YY_RULE_SETUP -#line 395 "scanner.l" +#line 398 "scanner.l" { yylval->s = sdup(yyextra, yytext); return EID; } YY_BREAK case 124: YY_RULE_SETUP -#line 396 "scanner.l" +#line 399 "scanner.l" { return stou(yytext, yylval, yyextra); } YY_BREAK case 125: YY_RULE_SETUP -#line 397 "scanner.l" +#line 400 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext); return HID; } YY_BREAK case 126: YY_RULE_SETUP -#line 399 "scanner.l" +#line 402 "scanner.l" { #ifdef INET6 struct addrinfo hints, *res; @@ -3961,316 +3964,316 @@ YY_RULE_SETUP YY_BREAK case 127: YY_RULE_SETUP -#line 418 "scanner.l" +#line 421 "scanner.l" { bpf_set_error(yyextra, "bogus ethernet address %s", yytext); yylval->s = NULL; return EID; } YY_BREAK case 128: YY_RULE_SETUP -#line 419 "scanner.l" +#line 422 "scanner.l" { yylval->h = 0; return NUM; } YY_BREAK case 129: YY_RULE_SETUP -#line 420 "scanner.l" +#line 423 "scanner.l" { yylval->h = 1; return NUM; } YY_BREAK case 130: YY_RULE_SETUP -#line 421 "scanner.l" +#line 424 "scanner.l" { yylval->h = 0; return NUM; } YY_BREAK case 131: YY_RULE_SETUP -#line 422 "scanner.l" +#line 425 "scanner.l" { yylval->h = 3; return NUM; } YY_BREAK case 132: YY_RULE_SETUP -#line 423 "scanner.l" +#line 426 "scanner.l" { yylval->h = 4; return NUM; } YY_BREAK case 133: YY_RULE_SETUP -#line 424 "scanner.l" +#line 427 "scanner.l" { yylval->h = 5; return NUM; } YY_BREAK case 134: YY_RULE_SETUP -#line 425 "scanner.l" +#line 428 "scanner.l" { yylval->h = 8; return NUM; } YY_BREAK case 135: YY_RULE_SETUP -#line 426 "scanner.l" +#line 429 "scanner.l" { yylval->h = 9; return NUM; } YY_BREAK case 136: YY_RULE_SETUP -#line 427 "scanner.l" +#line 430 "scanner.l" { yylval->h = 10; return NUM; } YY_BREAK case 137: YY_RULE_SETUP -#line 428 "scanner.l" +#line 431 "scanner.l" { yylval->h = 11; return NUM; } YY_BREAK case 138: YY_RULE_SETUP -#line 429 "scanner.l" +#line 432 "scanner.l" { yylval->h = 12; return NUM; } YY_BREAK case 139: YY_RULE_SETUP -#line 430 "scanner.l" +#line 433 "scanner.l" { yylval->h = 13; return NUM; } YY_BREAK case 140: YY_RULE_SETUP -#line 431 "scanner.l" +#line 434 "scanner.l" { yylval->h = 14; return NUM; } YY_BREAK case 141: YY_RULE_SETUP -#line 432 "scanner.l" +#line 435 "scanner.l" { yylval->h = 15; return NUM; } YY_BREAK case 142: YY_RULE_SETUP -#line 433 "scanner.l" +#line 436 "scanner.l" { yylval->h = 16; return NUM; } YY_BREAK case 143: YY_RULE_SETUP -#line 434 "scanner.l" +#line 437 "scanner.l" { yylval->h = 17; return NUM; } YY_BREAK case 144: YY_RULE_SETUP -#line 435 "scanner.l" +#line 438 "scanner.l" { yylval->h = 18; return NUM; } YY_BREAK case 145: YY_RULE_SETUP -#line 437 "scanner.l" +#line 440 "scanner.l" { yylval->h = 0; return NUM; } YY_BREAK case 146: YY_RULE_SETUP -#line 438 "scanner.l" +#line 441 "scanner.l" { yylval->h = 1; return NUM; } YY_BREAK case 147: YY_RULE_SETUP -#line 440 "scanner.l" +#line 443 "scanner.l" { yylval->h = 1; return NUM; } YY_BREAK case 148: YY_RULE_SETUP -#line 441 "scanner.l" +#line 444 "scanner.l" { yylval->h = 2; return NUM; } YY_BREAK case 149: YY_RULE_SETUP -#line 442 "scanner.l" +#line 445 "scanner.l" { yylval->h = 3; return NUM; } YY_BREAK case 150: YY_RULE_SETUP -#line 443 "scanner.l" +#line 446 "scanner.l" { yylval->h = 4; return NUM; } YY_BREAK case 151: YY_RULE_SETUP -#line 444 "scanner.l" +#line 447 "scanner.l" { yylval->h = 128; return NUM; } YY_BREAK case 152: YY_RULE_SETUP -#line 445 "scanner.l" +#line 448 "scanner.l" { yylval->h = 129; return NUM; } YY_BREAK case 153: YY_RULE_SETUP -#line 446 "scanner.l" +#line 449 "scanner.l" { yylval->h = 130; return NUM; } YY_BREAK case 154: YY_RULE_SETUP -#line 447 "scanner.l" +#line 450 "scanner.l" { yylval->h = 131; return NUM; } YY_BREAK case 155: YY_RULE_SETUP -#line 448 "scanner.l" +#line 451 "scanner.l" { yylval->h = 132; return NUM; } YY_BREAK case 156: YY_RULE_SETUP -#line 449 "scanner.l" +#line 452 "scanner.l" { yylval->h = 133; return NUM; } YY_BREAK case 157: YY_RULE_SETUP -#line 450 "scanner.l" +#line 453 "scanner.l" { yylval->h = 134; return NUM; } YY_BREAK case 158: YY_RULE_SETUP -#line 451 "scanner.l" +#line 454 "scanner.l" { yylval->h = 135; return NUM; } YY_BREAK case 159: YY_RULE_SETUP -#line 452 "scanner.l" +#line 455 "scanner.l" { yylval->h = 136; return NUM; } YY_BREAK case 160: YY_RULE_SETUP -#line 453 "scanner.l" +#line 456 "scanner.l" { yylval->h = 137; return NUM; } YY_BREAK case 161: YY_RULE_SETUP -#line 454 "scanner.l" +#line 457 "scanner.l" { yylval->h = 138; return NUM; } YY_BREAK case 162: YY_RULE_SETUP -#line 455 "scanner.l" +#line 458 "scanner.l" { yylval->h = 139; return NUM; } YY_BREAK case 163: YY_RULE_SETUP -#line 456 "scanner.l" +#line 459 "scanner.l" { yylval->h = 140; return NUM; } YY_BREAK case 164: YY_RULE_SETUP -#line 457 "scanner.l" +#line 460 "scanner.l" { yylval->h = 141; return NUM; } YY_BREAK case 165: YY_RULE_SETUP -#line 458 "scanner.l" +#line 461 "scanner.l" { yylval->h = 142; return NUM; } YY_BREAK case 166: YY_RULE_SETUP -#line 459 "scanner.l" +#line 462 "scanner.l" { yylval->h = 143; return NUM; } YY_BREAK case 167: YY_RULE_SETUP -#line 460 "scanner.l" +#line 463 "scanner.l" { yylval->h = 144; return NUM; } YY_BREAK case 168: YY_RULE_SETUP -#line 461 "scanner.l" +#line 464 "scanner.l" { yylval->h = 145; return NUM; } YY_BREAK case 169: YY_RULE_SETUP -#line 462 "scanner.l" +#line 465 "scanner.l" { yylval->h = 146; return NUM; } YY_BREAK case 170: YY_RULE_SETUP -#line 463 "scanner.l" +#line 466 "scanner.l" { yylval->h = 147; return NUM; } YY_BREAK case 171: YY_RULE_SETUP -#line 464 "scanner.l" +#line 467 "scanner.l" { yylval->h = 148; return NUM; } YY_BREAK case 172: YY_RULE_SETUP -#line 465 "scanner.l" +#line 468 "scanner.l" { yylval->h = 149; return NUM; } YY_BREAK case 173: YY_RULE_SETUP -#line 466 "scanner.l" +#line 469 "scanner.l" { yylval->h = 151; return NUM; } YY_BREAK case 174: YY_RULE_SETUP -#line 467 "scanner.l" +#line 470 "scanner.l" { yylval->h = 152; return NUM; } YY_BREAK case 175: YY_RULE_SETUP -#line 468 "scanner.l" +#line 471 "scanner.l" { yylval->h = 153; return NUM; } YY_BREAK case 176: YY_RULE_SETUP -#line 470 "scanner.l" +#line 473 "scanner.l" { yylval->h = 13; return NUM; } YY_BREAK case 177: YY_RULE_SETUP -#line 471 "scanner.l" +#line 474 "scanner.l" { yylval->h = 0x01; return NUM; } YY_BREAK case 178: YY_RULE_SETUP -#line 472 "scanner.l" +#line 475 "scanner.l" { yylval->h = 0x02; return NUM; } YY_BREAK case 179: YY_RULE_SETUP -#line 473 "scanner.l" +#line 476 "scanner.l" { yylval->h = 0x04; return NUM; } YY_BREAK case 180: YY_RULE_SETUP -#line 474 "scanner.l" +#line 477 "scanner.l" { yylval->h = 0x08; return NUM; } YY_BREAK case 181: YY_RULE_SETUP -#line 475 "scanner.l" +#line 478 "scanner.l" { yylval->h = 0x10; return NUM; } YY_BREAK case 182: YY_RULE_SETUP -#line 476 "scanner.l" +#line 479 "scanner.l" { yylval->h = 0x20; return NUM; } YY_BREAK case 183: YY_RULE_SETUP -#line 477 "scanner.l" +#line 480 "scanner.l" { yylval->h = 0x40; return NUM; } YY_BREAK case 184: YY_RULE_SETUP -#line 478 "scanner.l" +#line 481 "scanner.l" { yylval->h = 0x80; return NUM; } YY_BREAK case 185: YY_RULE_SETUP -#line 479 "scanner.l" +#line 482 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext); return ID; } YY_BREAK case 186: YY_RULE_SETUP -#line 481 "scanner.l" +#line 484 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; } YY_BREAK case 187: YY_RULE_SETUP -#line 482 "scanner.l" +#line 485 "scanner.l" { return LEX_ERROR; } YY_BREAK case 188: YY_RULE_SETUP -#line 483 "scanner.l" +#line 486 "scanner.l" ECHO; YY_BREAK -#line 4274 "scanner.c" +#line 4277 "scanner.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -5414,7 +5417,7 @@ void pcap_free (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 483 "scanner.l" +#line 486 "scanner.l" diff --git a/libpcap/scanner.h b/libpcap/scanner.h index a70035e93..5d74f4ed1 100644 --- a/libpcap/scanner.h +++ b/libpcap/scanner.h @@ -28,9 +28,16 @@ */ #include +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include "diag-control.h" -#line 34 "scanner.h" +#line 41 "scanner.h" #define YY_INT_ALIGNED short int @@ -375,9 +382,9 @@ extern int pcap_lex \ #undef YY_DECL #endif -#line 483 "scanner.l" +#line 486 "scanner.l" -#line 382 "scanner.h" +#line 389 "scanner.h" #undef pcap_IN_HEADER #endif /* pcap_HEADER_H */ diff --git a/libpcap/scanner.l b/libpcap/scanner.l index 06b9acc14..85fe395aa 100644 --- a/libpcap/scanner.l +++ b/libpcap/scanner.l @@ -24,6 +24,13 @@ */ #include +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include "diag-control.h" } @@ -89,10 +96,6 @@ #include "pcap-int.h" -#include "gencode.h" - -#include "grammar.h" - /* * Earlier versions of Flex don't declare these, so we declare them * ourselves to squelch warnings. diff --git a/libpcap/sf-pcap.c b/libpcap/sf-pcap.c index d8443e982..429493312 100644 --- a/libpcap/sf-pcap.c +++ b/libpcap/sf-pcap.c @@ -46,6 +46,7 @@ #include /* for INT_MAX */ #include "pcap-int.h" +#include "pcap-util.h" #include "pcap-common.h" @@ -70,6 +71,10 @@ /* * Standard libpcap format. + * + * The same value is used in the rpcap protocol as an indication of + * the server byte order, to let the client know whether it needs to + * byte-swap some host-byte-order metadata. */ #define TCPDUMP_MAGIC 0xa1b2c3d4 @@ -434,7 +439,7 @@ grow_buffer(pcap_t *p, u_int bufsize) /* * Read and return the next packet from the savefile. Return the header - * in hdr and a pointer to the contents in data. Return 0 on success, 1 + * in hdr and a pointer to the contents in data. Return 1 on success, 0 * if there were no more packets, and -1 on an error. */ static int @@ -467,7 +472,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) return (-1); } /* EOF */ - return (1); + return (0); } } @@ -579,7 +584,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) * userland. * * However, perhaps some versions of libpcap failed to - * set the snapshot length currectly in the file header + * set the snapshot length correctly in the file header * or the per-packet header, or perhaps this is a * corrupted safefile or a savefile built/modified by a * fuzz tester, so we check anyway. We grow the buffer @@ -622,7 +627,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) * the read finished. */ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "truncated dump file; tried to read %u captured bytes, only got %zu", + "truncated dump file; tried to read %d captured bytes, only got %zu", p->snapshot, amt_read); } return (-1); @@ -706,10 +711,9 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) } *data = p->buffer; - if (p->swapped) - swap_pseudo_headers(p->linktype, hdr, *data); + pcap_post_process(p->linktype, p->swapped, hdr, *data); - return (0); + return (1); } static int @@ -748,6 +752,24 @@ pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) struct pcap_sf_pkthdr sf_hdr; f = (FILE *)user; + /* + * If the output file handle is in an error state, don't write + * anything. + * + * While in principle a file handle can return from an error state + * to a normal state (for example if a disk that is full has space + * freed), we have possibly left a broken file already, and won't + * be able to clean it up. The safest option is to do nothing. + * + * Note that if we could guarantee that fwrite() was atomic we + * might be able to insure that we don't produce a corrupted file, + * but the standard defines fwrite() as a series of fputc() calls, + * so we really have no insurance that things are not fubared. + * + * http://pubs.opengroup.org/onlinepubs/009695399/functions/fwrite.html + */ + if (ferror(f)) + return; /* * Better not try writing pcap files after * 2038-01-19 03:14:07 UTC; switch to pcapng. @@ -756,9 +778,17 @@ pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) sf_hdr.ts.tv_usec = (bpf_int32)h->ts.tv_usec; sf_hdr.caplen = h->caplen; sf_hdr.len = h->len; - /* XXX we should check the return status */ - (void)fwrite(&sf_hdr, sizeof(sf_hdr), 1, f); - (void)fwrite(sp, h->caplen, 1, f); + /* + * We only write the packet if we can write the header properly. + * + * This doesn't prevent us from having corrupted output, and if we + * for some reason don't get a complete write we don't have any + * way to set ferror() to prevent future writes from being + * attempted, but it is better than nothing. + */ + if (fwrite(&sf_hdr, sizeof(sf_hdr), 1, f) == 1) { + (void)fwrite(sp, h->caplen, 1, f); + } } static pcap_dumper_t * diff --git a/libpcap/sf-pcapng.c b/libpcap/sf-pcapng.c index 3fd366c3a..058a7244d 100644 --- a/libpcap/sf-pcapng.c +++ b/libpcap/sf-pcapng.c @@ -34,6 +34,7 @@ #include #include "pcap-int.h" +#include "pcap-util.h" #include "pcap-common.h" @@ -1094,7 +1095,7 @@ pcap_ng_cleanup(pcap_t *p) /* * Read and return the next packet from the savefile. Return the header - * in hdr and a pointer to the contents in data. Return 0 on success, 1 + * in hdr and a pointer to the contents in data. Return 1 on success, 0 * if there were no more packets, and -1 on an error. */ static int @@ -1123,7 +1124,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data) */ status = read_block(fp, p, &cursor, p->errbuf); if (status == 0) - return (1); /* EOF */ + return (0); /* EOF */ if (status == -1) return (-1); /* error */ switch (cursor.block_type) { @@ -1511,8 +1512,7 @@ found: if (*data == NULL) return (-1); - if (p->swapped) - swap_pseudo_headers(p->linktype, hdr, *data); + pcap_post_process(p->linktype, p->swapped, hdr, *data); - return (0); + return (1); } diff --git a/libpcap/sockutils.c b/libpcap/sockutils.c index ca16bbf28..1c07f76fd 100644 --- a/libpcap/sockutils.c +++ b/libpcap/sockutils.c @@ -93,7 +93,7 @@ * * On Windows, send() and recv() return an int. * - * Wth MSVC, there *is* no ssize_t. + * With MSVC, there *is* no ssize_t. * * With MinGW, there is an ssize_t type; it is either an int (32 bit) * or a long long (64 bit). @@ -143,51 +143,164 @@ static int fuzz_recv(char *bufp, int remaining) { } #endif +int sock_geterrcode(void) +{ +#ifdef _WIN32 + return GetLastError(); +#else + return errno; +#endif +} + /* * Format an error message given an errno value (UN*X) or a Winsock error * (Windows). */ -void sock_fmterror(const char *caller, int errcode, char *errbuf, int errbuflen) +void sock_vfmterrmsg(char *errbuf, size_t errbuflen, int errcode, + const char *fmt, va_list ap) { if (errbuf == NULL) return; #ifdef _WIN32 - pcap_fmt_errmsg_for_win32_err(errbuf, errbuflen, errcode, - "%s", caller); + pcap_vfmt_errmsg_for_win32_err(errbuf, errbuflen, errcode, + fmt, ap); #else - pcap_fmt_errmsg_for_errno(errbuf, errbuflen, errcode, - "%s", caller); + pcap_vfmt_errmsg_for_errno(errbuf, errbuflen, errcode, + fmt, ap); #endif } -/* - * \brief It retrieves the error message after an error occurred in the socket interface. - * - * This function is defined because of the different way errors are returned in UNIX - * and Win32. This function provides a consistent way to retrieve the error message - * (after a socket error occurred) on all the platforms. - * - * \param caller: a pointer to a user-allocated string which contains a message that has - * to be printed *before* the true error message. It could be, for example, 'this error - * comes from the recv() call at line 31'. - * - * \param errbuf: a pointer to an user-allocated buffer that will contain the complete - * error message. This buffer has to be at least 'errbuflen' in length. - * It can be NULL; in this case the error cannot be printed. - * - * \param errbuflen: length of the buffer that will contains the error. The error message cannot be - * larger than 'errbuflen - 1' because the last char is reserved for the string terminator. - * - * \return No return values. The error message is returned in the 'string' parameter. - */ -void sock_geterror(const char *caller, char *errbuf, int errbuflen) +void sock_fmterrmsg(char *errbuf, size_t errbuflen, int errcode, + const char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + sock_vfmterrmsg(errbuf, errbuflen, errcode, fmt, ap); + va_end(ap); +} + +/* + * Format an error message for the last socket error. + */ +void sock_geterrmsg(char *errbuf, size_t errbuflen, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + sock_vfmterrmsg(errbuf, errbuflen, sock_geterrcode(), fmt, ap); + va_end(ap); +} + +/* + * Types of error. + * + * These are sorted by how likely they are to be the "underlying" problem, + * so that lower-rated errors for a given address in a given family + * should not overwrite higher-rated errors for another address in that + * family, and higher-rated errors should overwrit elower-rated errors. + */ +typedef enum { + SOCK_CONNERR, /* connection error */ + SOCK_HOSTERR, /* host error */ + SOCK_NETERR, /* network error */ + SOCK_AFNOTSUPERR, /* address family not supported */ + SOCK_UNKNOWNERR, /* unknown error */ + SOCK_NOERR /* no error */ +} sock_errtype; + +static sock_errtype sock_geterrtype(int errcode) +{ + switch (errcode) { + #ifdef _WIN32 - sock_fmterror(caller, GetLastError(), errbuf, errbuflen); + case WSAECONNRESET: + case WSAECONNABORTED: + case WSAECONNREFUSED: #else - sock_fmterror(caller, errno, errbuf, errbuflen); + case ECONNRESET: + case ECONNABORTED: + case ECONNREFUSED: #endif + /* + * Connection error; this means the problem is probably + * that there's no server set up on the remote machine, + * or that it is set up, but it's IPv4-only or IPv6-only + * and we're trying the wrong address family. + * + * These overwrite all other errors, as they indicate + * that, even if somethng else went wrong in another + * attempt, this probably wouldn't work even if the + * other problems were fixed. + */ + return (SOCK_CONNERR); + +#ifdef _WIN32 + case WSAENETUNREACH: + case WSAETIMEDOUT: + case WSAEHOSTDOWN: + case WSAEHOSTUNREACH: +#else + case ENETUNREACH: + case ETIMEDOUT: + case EHOSTDOWN: + case EHOSTUNREACH: +#endif + /* + * Network errors that could be IPv4-specific, IPv6- + * specific, or present with both. + * + * Don't overwrite connection errors, but overwrite + * everything else. + */ + return (SOCK_HOSTERR); + +#ifdef _WIN32 + case WSAENETDOWN: + case WSAENETRESET: +#else + case ENETDOWN: + case ENETRESET: +#endif + /* + * Network error; this means we don't know whether + * there's a server set up on the remote machine, + * and we don't have a reason to believe that IPv6 + * any worse or better than IPv4. + * + * These probably indicate a local failure, e.g. + * an interface is down. + * + * Don't overwrite connection errors or host errors, + * but overwrite everything else. + */ + return (SOCK_NETERR); + +#ifdef _WIN32 + case WSAEAFNOSUPPORT: +#else + case EAFNOSUPPORT: +#endif + /* + * "Address family not supported" probably means + * "No soup^WIPv6 for you!". + * + * Don't overwrite connection errors, host errors, or + * network errors (none of which we should get for this + * address family if it's not supported), but overwrite + * everything else. + */ + return (SOCK_AFNOTSUPERR); + + default: + /* + * Anything else. + * + * Don't overwrite any errors. + */ + return (SOCK_UNKNOWNERR); + } } /* @@ -281,6 +394,79 @@ static int sock_ismcastaddr(const struct sockaddr *saddr) } } +struct addr_status { + struct addrinfo *info; + int errcode; + sock_errtype errtype; +}; + +/* + * Sort by IPv4 address vs. IPv6 address. + */ +static int compare_addrs_to_try_by_address_family(const void *a, const void *b) +{ + const struct addr_status *addr_a = (const struct addr_status *)a; + const struct addr_status *addr_b = (const struct addr_status *)b; + + return addr_a->info->ai_family - addr_b->info->ai_family; +} + +/* + * Sort by error type and, within a given error type, by error code and, + * within a given error code, by IPv4 address vs. IPv6 address. + */ +static int compare_addrs_to_try_by_status(const void *a, const void *b) +{ + const struct addr_status *addr_a = (const struct addr_status *)a; + const struct addr_status *addr_b = (const struct addr_status *)b; + + if (addr_a->errtype == addr_b->errtype) + { + if (addr_a->errcode == addr_b->errcode) + { + return addr_a->info->ai_family - addr_b->info->ai_family; + } + return addr_a->errcode - addr_b->errcode; + } + + return addr_a->errtype - addr_b->errtype; +} + +static SOCKET sock_create_socket(struct addrinfo *addrinfo, char *errbuf, + int errbuflen) +{ + SOCKET sock; +#ifdef SO_NOSIGPIPE + int on = 1; +#endif + + sock = socket(addrinfo->ai_family, addrinfo->ai_socktype, + addrinfo->ai_protocol); + if (sock == INVALID_SOCKET) + { + sock_geterrmsg(errbuf, errbuflen, "socket() failed"); + return INVALID_SOCKET; + } + + /* + * Disable SIGPIPE, if we have SO_NOSIGPIPE. We don't want to + * have to deal with signals if the peer closes the connection, + * especially in client programs, which may not even be aware that + * they're sending to sockets. + */ +#ifdef SO_NOSIGPIPE + if (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (char *)&on, + sizeof (int)) == -1) + { + sock_geterrmsg(errbuf, errbuflen, + "setsockopt(SO_NOSIGPIPE) failed"); + closesocket(sock); + return INVALID_SOCKET; + } +#endif + return sock; +} + /* * \brief It initializes a network connection both from the client and the server side. * @@ -292,6 +478,9 @@ static int sock_ismcastaddr(const struct sockaddr *saddr) * * This function is usually preceded by the sock_initaddress(). * + * \param host: for client sockets, the host name to which we're trying + * to connect. + * * \param addrinfo: pointer to an addrinfo variable which will be used to * open the socket and such. This variable is the one returned by the previous call to * sock_initaddress(). @@ -312,48 +501,33 @@ static int sock_ismcastaddr(const struct sockaddr *saddr) * if everything is fine, INVALID_SOCKET if some errors occurred. The error message is returned * in the 'errbuf' variable. */ -SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen) +SOCKET sock_open(const char *host, struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen) { SOCKET sock; -#if defined(SO_NOSIGPIPE) || defined(IPV6_V6ONLY) || defined(IPV6_BINDV6ONLY) - int on = 1; -#endif - - sock = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol); - if (sock == INVALID_SOCKET) - { - sock_geterror("socket()", errbuf, errbuflen); - return INVALID_SOCKET; - } - - /* - * Disable SIGPIPE, if we have SO_NOSIGPIPE. We don't want to - * have to deal with signals if the peer closes the connection, - * especially in client programs, which may not even be aware that - * they're sending to sockets. - */ -#ifdef SO_NOSIGPIPE - if (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (char *)&on, - sizeof (int)) == -1) - { - sock_geterror("setsockopt(SO_NOSIGPIPE)", errbuf, errbuflen); - closesocket(sock); - return INVALID_SOCKET; - } -#endif /* This is a server socket */ if (server) { + int on; + + /* + * Attempt to create the socket. + */ + sock = sock_create_socket(addrinfo, errbuf, errbuflen); + if (sock == INVALID_SOCKET) + { + return INVALID_SOCKET; + } + /* * Allow a new server to bind the socket after the old one * exited, even if lingering sockets are still present. * * Don't treat an error as a failure. */ - int optval = 1; + on = 1; (void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&optval, sizeof (optval)); + (char *)&on, sizeof (on)); #if defined(IPV6_V6ONLY) || defined(IPV6_BINDV6ONLY) /* @@ -390,6 +564,7 @@ SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, #endif /* IPV6_V6ONLY */ if (addrinfo->ai_family == PF_INET6) { + on = 1; if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&on, sizeof (int)) == -1) { @@ -404,7 +579,7 @@ SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, /* WARNING: if the address is a mcast one, I should place the proper Win32 code here */ if (bind(sock, addrinfo->ai_addr, (int) addrinfo->ai_addrlen) != 0) { - sock_geterror("bind()", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, "bind() failed"); closesocket(sock); return INVALID_SOCKET; } @@ -412,7 +587,8 @@ SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, if (addrinfo->ai_socktype == SOCK_STREAM) if (listen(sock, nconn) == -1) { - sock_geterror("listen()", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, + "listen() failed"); closesocket(sock); return INVALID_SOCKET; } @@ -422,70 +598,259 @@ SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, } else /* we're the client */ { + struct addr_status *addrs_to_try; struct addrinfo *tempaddrinfo; - char *errbufptr; - size_t bufspaceleft; - - tempaddrinfo = addrinfo; - errbufptr = errbuf; - bufspaceleft = errbuflen; - *errbufptr = 0; + size_t numaddrinfos; + size_t i; + int current_af = AF_UNSPEC; /* - * We have to loop though all the addinfo returned. - * For instance, we can have both IPv6 and IPv4 addresses, but the service we're trying - * to connect to is unavailable in IPv6, so we have to try in IPv4 as well + * We have to loop though all the addrinfos returned. + * For instance, we can have both IPv6 and IPv4 addresses, + * but the service we're trying to connect to is unavailable + * in IPv6, so we have to try in IPv4 as well. + * + * How many addrinfos do we have? */ - while (tempaddrinfo) + numaddrinfos = 0; + for (tempaddrinfo = addrinfo; tempaddrinfo != NULL; + tempaddrinfo = tempaddrinfo->ai_next) { + numaddrinfos++; + } + + if (numaddrinfos == 0) + { + snprintf(errbuf, errbuflen, + "There are no addresses in the address list"); + return INVALID_SOCKET; + } + + /* + * Allocate an array of struct addr_status and fill it in. + */ + addrs_to_try = calloc(numaddrinfos, sizeof *addrs_to_try); + if (addrs_to_try == NULL) + { + snprintf(errbuf, errbuflen, + "Out of memory connecting to %s", host); + return INVALID_SOCKET; + } + + for (tempaddrinfo = addrinfo, i = 0; tempaddrinfo != NULL; + tempaddrinfo = tempaddrinfo->ai_next, i++) + { + addrs_to_try[i].info = tempaddrinfo; + addrs_to_try[i].errcode = 0; + addrs_to_try[i].errtype = SOCK_NOERR; + } + + /* + * Sort the structures to put the IPv4 addresses before the + * IPv6 addresses; we will have to create an IPv4 socket + * for the IPv4 addresses and an IPv6 socket for the IPv6 + * addresses (one of the arguments to socket() is the + * address/protocol family to use, and IPv4 and IPv6 are + * separate address/protocol families). + */ + qsort(addrs_to_try, numaddrinfos, sizeof *addrs_to_try, + compare_addrs_to_try_by_address_family); + + /* Start out with no socket. */ + sock = INVALID_SOCKET; + + /* + * Now try them all. + */ + for (i = 0; i < numaddrinfos; i++) + { + tempaddrinfo = addrs_to_try[i].info; #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION break; #endif + /* + * If we have a socket, but it's for a + * different address family, close it. + */ + if (sock != INVALID_SOCKET && + current_af != tempaddrinfo->ai_family) + { + closesocket(sock); + sock = INVALID_SOCKET; + } + + /* + * If we don't have a socket, open one + * for *this* address's address family. + */ + if (sock == INVALID_SOCKET) + { + sock = sock_create_socket(tempaddrinfo, + errbuf, errbuflen); + if (sock == INVALID_SOCKET) + { + free(addrs_to_try); + return INVALID_SOCKET; + } + } if (connect(sock, tempaddrinfo->ai_addr, (int) tempaddrinfo->ai_addrlen) == -1) { - size_t msglen; - char TmpBuffer[100]; - char SocketErrorMessage[SOCK_ERRBUF_SIZE]; - - /* - * We have to retrieve the error message before any other socket call completes, otherwise - * the error message is lost - */ - sock_geterror("Connect to socket failed", - SocketErrorMessage, sizeof(SocketErrorMessage)); - - /* Returns the numeric address of the host that triggered the error */ - sock_getascii_addrport((struct sockaddr_storage *) tempaddrinfo->ai_addr, TmpBuffer, sizeof(TmpBuffer), NULL, 0, NI_NUMERICHOST, TmpBuffer, sizeof(TmpBuffer)); - - snprintf(errbufptr, bufspaceleft, - "Is the server properly installed on %s? %s", TmpBuffer, SocketErrorMessage); - - /* In case more then one 'connect' fails, we manage to keep all the error messages */ - msglen = strlen(errbufptr); - - errbufptr[msglen] = ' '; - errbufptr[msglen + 1] = 0; - - bufspaceleft = bufspaceleft - (msglen + 1); - errbufptr += (msglen + 1); - - tempaddrinfo = tempaddrinfo->ai_next; + addrs_to_try[i].errcode = sock_geterrcode(); + addrs_to_try[i].errtype = + sock_geterrtype(addrs_to_try[i].errcode); } else break; } /* - * Check how we exit from the previous loop - * If tempaddrinfo is equal to NULL, it means that all the connect() failed. + * Check how we exited from the previous loop. + * If tempaddrinfo is equal to NULL, it means that all + * the connect() attempts failed. Construct an + * error message. */ - if (tempaddrinfo == NULL) + if (i == numaddrinfos) { + int same_error_for_all; + int first_error; + closesocket(sock); + + /* + * Sort the statuses to group together categories + * of errors, errors within categories, and + * address families within error sets. + */ + qsort(addrs_to_try, numaddrinfos, sizeof *addrs_to_try, + compare_addrs_to_try_by_status); + + /* + * Are all the errors the same? + */ + same_error_for_all = 1; + first_error = addrs_to_try[0].errcode; + for (i = 1; i < numaddrinfos; i++) + { + if (addrs_to_try[i].errcode != first_error) + { + same_error_for_all = 0; + break; + } + } + + if (same_error_for_all) { + /* + * Yes. No need to show the IP + * addresses. + */ + if (addrs_to_try[0].errtype == SOCK_CONNERR) { + /* + * Connection error; note that + * the daemon might not be set + * up correctly, or set up at all. + */ + sock_fmterrmsg(errbuf, errbuflen, + addrs_to_try[0].errcode, + "Is the server properly installed? Cannot connect to %s", + host); + } else { + sock_fmterrmsg(errbuf, errbuflen, + addrs_to_try[0].errcode, + "Cannot connect to %s", host); + } + } else { + /* + * Show all the errors and the IP addresses + * to which they apply. + */ + char *errbufptr; + size_t bufspaceleft; + size_t msglen; + + snprintf(errbuf, errbuflen, + "Connect to %s failed: ", host); + + msglen = strlen(errbuf); + errbufptr = errbuf + msglen; + bufspaceleft = errbuflen - msglen; + + for (i = 0; i < numaddrinfos && + addrs_to_try[i].errcode != SOCK_NOERR; + i++) + { + /* + * Get the string for the address + * and port that got this error. + */ + sock_getascii_addrport((struct sockaddr_storage *) addrs_to_try[i].info->ai_addr, + errbufptr, (int)bufspaceleft, + NULL, 0, NI_NUMERICHOST, NULL, 0); + msglen = strlen(errbuf); + errbufptr = errbuf + msglen; + bufspaceleft = errbuflen - msglen; + + if (i + 1 < numaddrinfos && + addrs_to_try[i + 1].errcode == addrs_to_try[i].errcode) + { + /* + * There's another error + * after this, and it has + * the same error code. + * + * Append a comma, as the + * list of addresses with + * this error has another + * entry. + */ + snprintf(errbufptr, bufspaceleft, + ", "); + } + else + { + /* + * Either there are no + * more errors after this, + * or the next error is + * different. + * + * Append a colon and + * the message for tis + * error, followed by a + * comma if there are + * more errors. + */ + sock_fmterrmsg(errbufptr, + bufspaceleft, + addrs_to_try[i].errcode, + "%s", ""); + msglen = strlen(errbuf); + errbufptr = errbuf + msglen; + bufspaceleft = errbuflen - msglen; + + if (i + 1 < numaddrinfos && + addrs_to_try[i + 1].errcode != SOCK_NOERR) + { + /* + * More to come. + */ + snprintf(errbufptr, + bufspaceleft, + ", "); + } + } + msglen = strlen(errbuf); + errbufptr = errbuf + msglen; + bufspaceleft = errbuflen - msglen; + } + } + free(addrs_to_try); return INVALID_SOCKET; } else + { + free(addrs_to_try); return sock; + } } } @@ -516,7 +881,7 @@ int sock_close(SOCKET sock, char *errbuf, int errbuflen) */ if (shutdown(sock, SHUT_WR)) { - sock_geterror("shutdown()", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, "shutdown() feiled"); /* close the socket anyway */ closesocket(sock); return -1; @@ -548,13 +913,13 @@ get_gai_errstring(char *errbuf, int errbuflen, const char *prefix, int err, char hostport[PCAP_ERRBUF_SIZE]; if (hostname != NULL && portname != NULL) - snprintf(hostport, PCAP_ERRBUF_SIZE, "%s:%s", + snprintf(hostport, PCAP_ERRBUF_SIZE, "host and port %s:%s", hostname, portname); else if (hostname != NULL) - snprintf(hostport, PCAP_ERRBUF_SIZE, "%s", + snprintf(hostport, PCAP_ERRBUF_SIZE, "host %s", hostname); else if (portname != NULL) - snprintf(hostport, PCAP_ERRBUF_SIZE, ":%s", + snprintf(hostport, PCAP_ERRBUF_SIZE, "port %s", portname); else snprintf(hostport, PCAP_ERRBUF_SIZE, ""); @@ -618,7 +983,7 @@ get_gai_errstring(char *errbuf, int errbuflen, const char *prefix, int err, case EAI_NONAME: snprintf(errbuf, errbuflen, - "%sThe host name %s couldn't be resolved", + "%sThe %s couldn't be resolved", prefix, hostport); break; @@ -720,13 +1085,58 @@ int sock_initaddress(const char *host, const char *port, { int retval; - retval = getaddrinfo(host, port, hints, addrinfo); + /* + * We allow both the host and port to be null, but getaddrinfo() + * is not guaranteed to do so; to handle that, if port is null, + * we provide "0" as the port number. + * + * This results in better error messages from get_gai_errstring(), + * as those messages won't talk about a problem with the port if + * no port was specified. + */ + retval = getaddrinfo(host, port == NULL ? "0" : port, hints, addrinfo); if (retval != 0) { if (errbuf) { - get_gai_errstring(errbuf, errbuflen, "", retval, - host, port); + if (host != NULL && port != NULL) { + /* + * Try with just a host, to distinguish + * between "host is bad" and "port is + * bad". + */ + int try_retval; + + try_retval = getaddrinfo(host, NULL, hints, + addrinfo); + if (try_retval == 0) { + /* + * Worked with just the host, + * so assume the problem is + * with the port. + * + * Free up the address info first. + */ + freeaddrinfo(*addrinfo); + get_gai_errstring(errbuf, errbuflen, + "", retval, NULL, port); + } else { + /* + * Didn't work with just the host, + * so assume the problem is + * with the host. + */ + get_gai_errstring(errbuf, errbuflen, + "", retval, host, NULL); + } + } else { + /* + * Either the host or port was null, so + * there's nothing to determine. + */ + get_gai_errstring(errbuf, errbuflen, "", + retval, host, port); + } } return -1; } @@ -857,7 +1267,8 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size, */ return -2; } - sock_fmterror("send()", errcode, errbuf, errbuflen); + sock_fmterrmsg(errbuf, errbuflen, errcode, + "send() failed"); #else errcode = errno; if (errcode == ECONNRESET || errcode == EPIPE) @@ -869,7 +1280,8 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size, */ return -2; } - sock_fmterror("send()", errcode, errbuf, errbuflen); + sock_fmterrmsg(errbuf, errbuflen, errcode, + "send() failed"); #endif return -1; } @@ -882,11 +1294,11 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size, } /* - * \brief It copies the amount of data contained into 'buffer' into 'tempbuf'. + * \brief It copies the amount of data contained in 'data' into 'outbuf'. * and it checks for buffer overflows. * - * This function basically copies 'size' bytes of data contained into 'buffer' - * into 'tempbuf', starting at offset 'offset'. Before that, it checks that the + * This function basically copies 'size' bytes of data contained in 'data' + * into 'outbuf', starting at offset 'offset'. Before that, it checks that the * resulting buffer will not be larger than 'totsize'. Finally, it updates * the 'offset' variable in order to point to the first empty location of the buffer. * @@ -895,25 +1307,24 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size, * 'offset' variable. This mode can be useful when the buffer already contains the * data (maybe because the producer writes directly into the target buffer), so * only the buffer overflow check has to be made. - * In this case, both 'buffer' and 'tempbuf' can be NULL values. + * In this case, both 'data' and 'outbuf' can be NULL values. * * This function is useful in case the userland application does not know immediately * all the data it has to write into the socket. This function provides a way to create * the "stream" step by step, appending the new data to the old one. Then, when all the * data has been bufferized, the application can call the sock_send() function. * - * \param buffer: a char pointer to a user-allocated buffer that keeps the data - * that has to be copied. + * \param data: a void pointer to the data that has to be copied. * * \param size: number of bytes that have to be copied. * - * \param tempbuf: user-allocated buffer (of size 'totsize') in which data + * \param outbuf: user-allocated buffer (of size 'totsize') into which data * has to be copied. * - * \param offset: an index into 'tempbuf' which keeps the location of its first + * \param offset: an index into 'outbuf' which keeps the location of its first * empty location. * - * \param totsize: total size of the buffer in which data is being copied. + * \param totsize: total size of the buffer into which data is being copied. * * \param checkonly: '1' if we do not want to copy data into the buffer and we * want just do a buffer ovreflow control, '0' if data has to be copied as well. @@ -926,7 +1337,7 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size, * larger than 'errbuflen - 1' because the last char is reserved for the string terminator. * * \return '0' if everything is fine, '-1' if some errors occurred. The error message - * is returned in the 'errbuf' variable. When the function returns, 'tempbuf' will + * is returned in the 'errbuf' variable. When the function returns, 'outbuf' will * have the new string appended, and 'offset' will keep the length of that buffer. * In case of 'checkonly == 1', data is not copied, but 'offset' is updated in any case. * @@ -936,7 +1347,7 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size, * \warning In case of 'checkonly', be carefully to call this function *before* copying * the data into the buffer. Otherwise, the control about the buffer overflow is useless. */ -int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen) +int sock_bufferize(const void *data, int size, char *outbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen) { if ((*offset + size) > totsize) { @@ -946,7 +1357,7 @@ int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int } if (!checkonly) - memcpy(tempbuf + (*offset), buffer, size); + memcpy(outbuf + (*offset), data, size); (*offset) += size; @@ -978,7 +1389,7 @@ int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int * * SOCK_RECEIVALL_XXX: * - * if SOCK_RECEIVEALL_NO, return as soon as some data is ready + * if SOCK_RECEIVEALL_NO, return as soon as some data is ready * if SOCK_RECEIVALL_YES, wait until 'size' data has been * received (in case the socket does not have enough data available). * @@ -1056,7 +1467,7 @@ int sock_recv(SOCKET sock, SSL *ssl _U_NOSSL_, void *buffer, size_t size, if (errno == EINTR) return -3; #endif - sock_geterror("recv()", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, "recv() failed"); return -1; } @@ -1161,7 +1572,8 @@ int sock_recv_dgram(SOCKET sock, SSL *ssl _U_NOSSL_, void *buffer, size_t size, * supplied to us, the excess data is discarded, * and we'll report an error. */ - sock_geterror("recv()", errbuf, errbuflen); + sock_fmterrmsg(errbuf, errbuflen, sock_geterrcode(), + "recv() failed"); return -1; } #else /* _WIN32 */ @@ -1198,7 +1610,7 @@ int sock_recv_dgram(SOCKET sock, SSL *ssl _U_NOSSL_, void *buffer, size_t size, { if (errno == EINTR) return -3; - sock_geterror("recv()", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, "recv() failed"); return -1; } #ifdef HAVE_STRUCT_MSGHDR_MSG_FLAGS @@ -1334,7 +1746,8 @@ int sock_check_hostlist(char *hostlist, const char *sep, struct sockaddr_storage temphostlist = strdup(hostlist); if (temphostlist == NULL) { - sock_geterror("sock_check_hostlist(), malloc() failed", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, + "sock_check_hostlist(), malloc() failed"); return -2; } @@ -1520,7 +1933,7 @@ int sock_getmyinfo(SOCKET sock, char *address, int addrlen, char *port, int port if (getsockname(sock, (struct sockaddr *) &mysockaddr, &sockaddrlen) == -1) { - sock_geterror("getsockname()", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, "getsockname() failed"); return 0; } @@ -1576,7 +1989,7 @@ int sock_getmyinfo(SOCKET sock, char *address, int addrlen, char *port, int port * and 'port'. * In any case, the returned strings are '0' terminated. */ -int sock_getascii_addrport(const struct sockaddr_storage *sockaddr, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen) +int sock_getascii_addrport(const struct sockaddr_storage *sockaddr, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, size_t errbuflen) { socklen_t sockaddrlen; int retval; /* Variable that keeps the return value; */ @@ -1608,7 +2021,8 @@ int sock_getascii_addrport(const struct sockaddr_storage *sockaddr, char *addres /* If the user wants to receive an error message */ if (errbuf) { - sock_geterror("getnameinfo()", errbuf, errbuflen); + sock_geterrmsg(errbuf, errbuflen, + "getnameinfo() failed"); errbuf[errbuflen - 1] = 0; } diff --git a/libpcap/sockutils.h b/libpcap/sockutils.h index e748662e3..a488d8fcb 100644 --- a/libpcap/sockutils.h +++ b/libpcap/sockutils.h @@ -37,6 +37,10 @@ #pragma once #endif +#include /* we declare varargs functions */ + +#include "pcap/funcattrs.h" + #include "pcap/socket.h" #ifndef _WIN32 @@ -127,8 +131,13 @@ extern "C" { int sock_init(char *errbuf, int errbuflen); void sock_cleanup(void); -void sock_fmterror(const char *caller, int errcode, char *errbuf, int errbuflen); -void sock_geterror(const char *caller, char *errbuf, int errbufsize); +int sock_geterrcode(void); +void sock_vfmterrmsg(char *errbuf, size_t errbuflen, int errcode, + PCAP_FORMAT_STRING(const char *fmt), va_list ap) PCAP_PRINTFLIKE(4, 0); +void sock_fmterrmsg(char *errbuf, size_t errbuflen, int errcode, + PCAP_FORMAT_STRING(const char *fmt), ...) PCAP_PRINTFLIKE(4, 5); +void sock_geterrmsg(char *errbuf, size_t errbuflen, + PCAP_FORMAT_STRING(const char *fmt), ...) PCAP_PRINTFLIKE(3, 4); int sock_initaddress(const char *address, const char *port, struct addrinfo *hints, struct addrinfo **addrinfo, char *errbuf, int errbuflen); @@ -136,19 +145,19 @@ int sock_recv(SOCKET sock, SSL *, void *buffer, size_t size, int receiveall, char *errbuf, int errbuflen); int sock_recv_dgram(SOCKET sock, SSL *, void *buffer, size_t size, char *errbuf, int errbuflen); -SOCKET sock_open(struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen); +SOCKET sock_open(const char *host, struct addrinfo *addrinfo, int server, int nconn, char *errbuf, int errbuflen); int sock_close(SOCKET sock, char *errbuf, int errbuflen); int sock_send(SOCKET sock, SSL *, const char *buffer, size_t size, char *errbuf, int errbuflen); -int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen); +int sock_bufferize(const void *data, int size, char *outbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen); int sock_discard(SOCKET sock, SSL *, int size, char *errbuf, int errbuflen); int sock_check_hostlist(char *hostlist, const char *sep, struct sockaddr_storage *from, char *errbuf, int errbuflen); int sock_cmpaddr(struct sockaddr_storage *first, struct sockaddr_storage *second); int sock_getmyinfo(SOCKET sock, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen); -int sock_getascii_addrport(const struct sockaddr_storage *sockaddr, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, int errbuflen); +int sock_getascii_addrport(const struct sockaddr_storage *sockaddr, char *address, int addrlen, char *port, int portlen, int flags, char *errbuf, size_t errbuflen); int sock_present2network(const char *address, struct sockaddr_storage *sockaddr, int addr_family, char *errbuf, int errbuflen); #ifdef __cplusplus diff --git a/libpcap/tests/shb-option-too-long.pcapng b/libpcap/tests/shb-option-too-long.pcapng deleted file mode 100644 index f77397476f3841cb4f4a5db041132f3e90733274..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 180 zcmd<$<>fMAU|{gI(UxKa(gs8TkU9k*W(2BcU|<1~AQlKf^s@ow5`Y*4AmRoF4oGa6 VSjP$j0}eJIX5eFCV1$VhrU7888Q1^-