From a2442ea29fb5f8e67c8dba1a68a4a3377ff4dea3 Mon Sep 17 00:00:00 2001 From: dmiller Date: Sat, 30 Mar 2019 03:24:44 +0000 Subject: [PATCH] Update libpcap to 1.9.0 (no patches applied yet) --- libpcap/CHANGES | 79 + libpcap/CMakeLists.txt | 2356 +++++++- libpcap/CONTRIBUTING.md | 29 + libpcap/CREDITS | 30 +- libpcap/GenVersion.bat | 23 - libpcap/{INSTALL.txt => INSTALL.md} | 49 +- libpcap/Makefile.in | 310 +- ...01-Don-t-autogenerate-Lex-Yacc-files.patch | 126 - .../0002-Disable-unnecessary-features.patch | 174 - libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE | 25 - libpcap/README.Win32 | 46 - libpcap/README.aix | 88 - libpcap/README.dag | 122 - libpcap/README.hpux | 254 - libpcap/README.linux | 108 - libpcap/README.macosx | 74 - libpcap/{README => README.md} | 67 +- libpcap/README.septel | 50 - libpcap/README.sita | 64 - libpcap/README.tru64 | 49 - libpcap/SUNOS4/nit_if.o.sparc | Bin 5212 -> 0 bytes libpcap/SUNOS4/nit_if.o.sun3 | Bin 4267 -> 0 bytes libpcap/SUNOS4/nit_if.o.sun4c.4.0.3c | Bin 5291 -> 0 bytes libpcap/VERSION | 2 +- libpcap/Win32/Include/Gnuc.h | 8 - libpcap/Win32/Include/net/if.h | 230 - libpcap/Win32/Prj/wpcap.sln | 28 - libpcap/Win32/Prj/wpcap.vcxproj | 234 - libpcap/Win32/Prj/wpcap.vcxproj.filters | 107 - libpcap/aclocal.m4 | 467 +- libpcap/bpf/net/bpf_filter.c | 766 --- libpcap/bpf_dump.c | 7 +- libpcap/bpf_image.c | 158 +- libpcap/chmod_bpf | 2 +- libpcap/cmake/Modules/FindDAG.cmake | 32 + libpcap/cmake/Modules/FindFseeko.cmake | 85 + libpcap/cmake/Modules/FindLFS.cmake | 153 + libpcap/cmake/Modules/FindPacket.cmake | 81 + libpcap/cmake/Modules/FindSNF.cmake | 24 + libpcap/cmake/Modules/FindTC.cmake | 24 + libpcap/{config => cmake}/have_siocglifconf.c | 0 libpcap/cmake/preconfigure.cmake | 55 - libpcap/cmake_uninstall.cmake.in | 21 + libpcap/cmakeconfig.h.in | 229 +- libpcap/config.guess | 685 +-- libpcap/config.h.in | 203 +- libpcap/config.sub | 1695 +++--- libpcap/configure | 5041 ++++++++++++----- libpcap/configure.ac | 1508 +++-- libpcap/diag-control.h | 219 + libpcap/dlpisubs.c | 18 +- libpcap/etherent.c | 79 +- libpcap/extract.h | 16 +- libpcap/fad-getad.c | 40 +- libpcap/fad-gifc.c | 89 +- libpcap/fad-glifc.c | 73 +- libpcap/fad-helpers.c | 884 --- libpcap/fmtutils.c | 131 + libpcap/fmtutils.h | 50 + libpcap/ftmacros.h | 115 + libpcap/gen_version_c.sh | 11 - libpcap/gen_version_header.sh | 19 - libpcap/gencode.c | 813 ++- libpcap/gencode.h | 42 +- libpcap/grammar.c | 931 +-- libpcap/grammar.h | 323 -- libpcap/grammar.y | 63 +- libpcap/inet.c | 403 -- libpcap/libpcap.pc.in | 18 + libpcap/missing/getopt.c | 5 +- libpcap/missing/getopt.h | 2 +- libpcap/missing/strtok_r.c | 2 +- libpcap/msdos/common.dj | 86 - libpcap/msdos/makefile | 6 +- libpcap/msdos/makefile.dj | 2 +- libpcap/msdos/makefile.wc | 4 +- libpcap/msdos/ndis2.c | 860 --- libpcap/msdos/ndis2.h | 559 -- libpcap/msdos/ndis_0.asm | 188 - libpcap/msdos/readme.dos | 2 +- libpcap/nametoaddr.c | 423 +- libpcap/nomkdep | 6 + libpcap/optimize.c | 272 +- libpcap/optimize.h | 28 + libpcap/pcap-bpf.c | 606 +- libpcap/pcap-bt-linux.c | 83 +- libpcap/pcap-bt-linux.h | 2 +- libpcap/pcap-bt-monitor-linux.c | 48 +- libpcap/pcap-bt-monitor-linux.h | 2 +- libpcap/pcap-common.c | 141 +- libpcap/pcap-common.h | 32 +- libpcap/pcap-config.in | 9 +- libpcap/pcap-dag.c | 745 +-- libpcap/pcap-dag.h | 2 +- libpcap/pcap-dbus.c | 86 +- libpcap/pcap-dbus.h | 2 +- libpcap/pcap-dll.rc | 36 + libpcap/pcap-dlpi.c | 246 +- libpcap/pcap-dos.c | 70 +- libpcap/pcap-enet.c | 2 +- libpcap/pcap-filter.manmisc.in | 42 +- libpcap/pcap-int.h | 156 +- libpcap/pcap-libdlpi.c | 72 +- libpcap/pcap-linktype.manmisc.in | 2 +- libpcap/pcap-linux.c | 850 ++- libpcap/pcap-netfilter-linux.c | 205 +- libpcap/pcap-netfilter-linux.h | 2 +- libpcap/pcap-netmap.c | 306 + libpcap/pcap-netmap.h | 2 + libpcap/pcap-new.c | 1095 +--- libpcap/pcap-nit.c | 63 +- libpcap/{pcap-win32.c => pcap-npf.c} | 1144 +++- libpcap/pcap-null.c | 30 +- libpcap/pcap-pf.c | 115 +- libpcap/pcap-rdmasniff.c | 436 ++ libpcap/pcap-rdmasniff.h | 2 + libpcap/pcap-rpcap-int.h | 75 + libpcap/pcap-rpcap.c | 3412 +++++++---- libpcap/pcap-rpcap.h | 478 +- libpcap/pcap-septel.c | 70 +- libpcap/pcap-septel.h | 2 +- libpcap/pcap-sita.c | 72 +- libpcap/pcap-snf.c | 353 +- libpcap/pcap-snf.h | 2 +- libpcap/pcap-snit.c | 104 +- libpcap/pcap-snoop.c | 80 +- libpcap/pcap-stdinc.h | 126 - libpcap/pcap-tc.c | 71 +- libpcap/pcap-tc.h | 2 +- libpcap/pcap-tstamp.manmisc.in | 6 +- libpcap/pcap-types.h | 50 + libpcap/pcap-usb-linux.c | 461 +- libpcap/pcap-usb-linux.h | 2 +- libpcap/pcap.3pcap.in | 92 +- libpcap/pcap.c | 2430 ++++++-- libpcap/pcap/bluetooth.h | 9 +- libpcap/pcap/bpf.h | 14 +- libpcap/pcap/can_socketcan.h | 12 +- libpcap/pcap/compiler-tests.h | 163 + libpcap/pcap/dlt.h | 107 +- libpcap/pcap/export-defs.h | 108 - libpcap/pcap/funcattrs.h | 261 + libpcap/pcap/namedb.h | 2 - libpcap/pcap/nflog.h | 30 +- libpcap/pcap/pcap-inttypes.h | 117 + libpcap/pcap/pcap.h | 469 +- libpcap/pcap/sll.h | 12 +- libpcap/pcap/usb.h | 54 +- libpcap/pcap/vlan.h | 6 +- libpcap/pcap_activate.3pcap | 2 +- libpcap/pcap_breakloop.3pcap | 18 +- libpcap/pcap_can_set_rfmon.3pcap | 2 +- libpcap/pcap_compile.3pcap.in | 12 +- libpcap/pcap_datalink.3pcap.in | 2 +- libpcap/pcap_datalink_name_to_val.3pcap | 2 +- libpcap/pcap_datalink_val_to_name.3pcap | 2 +- libpcap/pcap_dump_ftell.3pcap | 19 +- libpcap/pcap_dump_open.3pcap.in | 10 +- libpcap/pcap_fileno.3pcap | 2 +- libpcap/pcap_findalldevs.3pcap | 26 +- libpcap/pcap_get_selectable_fd.3pcap | 96 +- libpcap/pcap_geterr.3pcap | 2 +- libpcap/pcap_is_swapped.3pcap | 2 +- libpcap/pcap_lookupdev.3pcap | 24 +- libpcap/pcap_loop.3pcap | 20 +- libpcap/pcap_major_version.3pcap | 4 +- libpcap/pcap_next_ex.3pcap | 29 +- libpcap/pcap_open_dead.3pcap.in | 2 +- libpcap/pcap_open_live.3pcap | 7 +- libpcap/pcap_open_offline.3pcap.in | 4 +- libpcap/pcap_set_timeout.3pcap | 19 +- libpcap/pcap_set_tstamp_type.3pcap.in | 2 +- libpcap/pcap_version.h.in | 13 - libpcap/portability.h | 114 +- libpcap/remote-ext.h | 467 -- libpcap/rpcap-protocol.c | 195 + libpcap/rpcap-protocol.h | 450 ++ libpcap/savefile.c | 69 +- libpcap/scanner.c | 4739 +++++++++------- libpcap/scanner.h | 30 +- libpcap/scanner.l | 93 +- libpcap/sf-pcap.c | 302 +- libpcap/{sf-pcap-ng.c => sf-pcapng.c} | 227 +- libpcap/{sf-pcap-ng.h => sf-pcapng.h} | 8 +- libpcap/sockutils.c | 485 +- libpcap/sockutils.h | 79 +- libpcap/tests/CMakeLists.txt | 42 - libpcap/tests/can_set_rfmon_test.c | 92 - libpcap/tests/capturetest.c | 334 -- libpcap/tests/filtertest.c | 364 -- libpcap/tests/findalldevstest.c | 161 - libpcap/tests/opentest.c | 273 - libpcap/tests/reactivatetest.c | 84 - libpcap/tests/selpolltest.c | 407 -- libpcap/tests/shb-option-too-long.pcapng | Bin 0 -> 180 bytes libpcap/tests/valgrindtest.c | 470 -- libpcap/varattrs.h | 59 + 197 files changed, 26419 insertions(+), 22082 deletions(-) create mode 100644 libpcap/CONTRIBUTING.md delete mode 100644 libpcap/GenVersion.bat rename libpcap/{INSTALL.txt => INSTALL.md} (90%) delete mode 100644 libpcap/NMAP_MODIFICATIONS/0001-Don-t-autogenerate-Lex-Yacc-files.patch delete mode 100644 libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch delete mode 100644 libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE delete mode 100644 libpcap/README.Win32 delete mode 100644 libpcap/README.aix delete mode 100644 libpcap/README.dag delete mode 100644 libpcap/README.hpux delete mode 100644 libpcap/README.linux delete mode 100644 libpcap/README.macosx rename libpcap/{README => README.md} (61%) delete mode 100644 libpcap/README.septel delete mode 100644 libpcap/README.sita delete mode 100644 libpcap/README.tru64 delete mode 100644 libpcap/SUNOS4/nit_if.o.sparc delete mode 100644 libpcap/SUNOS4/nit_if.o.sun3 delete mode 100644 libpcap/SUNOS4/nit_if.o.sun4c.4.0.3c delete mode 100644 libpcap/Win32/Include/Gnuc.h delete mode 100644 libpcap/Win32/Include/net/if.h 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 delete mode 100644 libpcap/bpf/net/bpf_filter.c create mode 100644 libpcap/cmake/Modules/FindDAG.cmake create mode 100644 libpcap/cmake/Modules/FindFseeko.cmake create mode 100644 libpcap/cmake/Modules/FindLFS.cmake create mode 100644 libpcap/cmake/Modules/FindPacket.cmake create mode 100644 libpcap/cmake/Modules/FindSNF.cmake create mode 100644 libpcap/cmake/Modules/FindTC.cmake rename libpcap/{config => cmake}/have_siocglifconf.c (100%) delete mode 100644 libpcap/cmake/preconfigure.cmake create mode 100644 libpcap/cmake_uninstall.cmake.in create mode 100644 libpcap/diag-control.h delete mode 100644 libpcap/fad-helpers.c create mode 100644 libpcap/fmtutils.c create mode 100644 libpcap/fmtutils.h create mode 100644 libpcap/ftmacros.h delete mode 100755 libpcap/gen_version_c.sh delete mode 100755 libpcap/gen_version_header.sh delete mode 100644 libpcap/grammar.h delete mode 100644 libpcap/inet.c create mode 100644 libpcap/libpcap.pc.in delete mode 100644 libpcap/msdos/common.dj delete mode 100644 libpcap/msdos/ndis2.c delete mode 100644 libpcap/msdos/ndis2.h delete mode 100644 libpcap/msdos/ndis_0.asm create mode 100755 libpcap/nomkdep create mode 100644 libpcap/optimize.h create mode 100644 libpcap/pcap-dll.rc create mode 100644 libpcap/pcap-netmap.c create mode 100644 libpcap/pcap-netmap.h rename libpcap/{pcap-win32.c => pcap-npf.c} (57%) create mode 100644 libpcap/pcap-rdmasniff.c create mode 100644 libpcap/pcap-rdmasniff.h create mode 100644 libpcap/pcap-rpcap-int.h delete mode 100644 libpcap/pcap-stdinc.h create mode 100644 libpcap/pcap-types.h create mode 100644 libpcap/pcap/compiler-tests.h delete mode 100644 libpcap/pcap/export-defs.h create mode 100644 libpcap/pcap/funcattrs.h create mode 100644 libpcap/pcap/pcap-inttypes.h delete mode 100644 libpcap/pcap_version.h.in delete mode 100644 libpcap/remote-ext.h create mode 100644 libpcap/rpcap-protocol.c create mode 100644 libpcap/rpcap-protocol.h rename libpcap/{sf-pcap-ng.c => sf-pcapng.c} (86%) rename libpcap/{sf-pcap-ng.h => sf-pcapng.h} (90%) delete mode 100644 libpcap/tests/CMakeLists.txt delete mode 100644 libpcap/tests/can_set_rfmon_test.c delete mode 100644 libpcap/tests/capturetest.c delete mode 100644 libpcap/tests/filtertest.c delete mode 100644 libpcap/tests/findalldevstest.c delete mode 100644 libpcap/tests/opentest.c delete mode 100644 libpcap/tests/reactivatetest.c delete mode 100644 libpcap/tests/selpolltest.c create mode 100644 libpcap/tests/shb-option-too-long.pcapng delete mode 100644 libpcap/tests/valgrindtest.c create mode 100644 libpcap/varattrs.h diff --git a/libpcap/CHANGES b/libpcap/CHANGES index 178409659..4607f14a2 100644 --- a/libpcap/CHANGES +++ b/libpcap/CHANGES @@ -1,3 +1,82 @@ +Sunday, June 24, 2018, by mcr@sandelman.ca + Summary for 1.9.0 libpcap release + 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 + Additions to TCP header parsing, per RFC3168 + Add CMake build process (extensive number of changes) + Assign a value for OpenBSD DLT_OPENFLOW. + Support setting non-blocking mode before activating. + Extensive build support for Windows VS2010 and MINGW (many many changes, over many months) + Added RPCAPD support when --enable-remote (default no) + Add the rpcap daemon source and build instructions. + Put back the greasy "save the capture filter string so we can tweak it" + hack, that keeps libpcap from capturing rpcap traffic. + Fixes for captures on MacOS, utun0 + fixes so that non-AF_INET addresses, are not ==AF_INET6 addresses. + Add a linktype for IBM SDLC frames containing SNA PDUs. + pcap_compile() in 1.8.0 and later is newly thread-safe. + bound snaplen for linux tpacket_v2 to ~64k + Make VLAN filter handle both metadata and inline tags + D-Bus captures can now be up to 128MB in size + Added LORATAP DLT value + Added DLT_VSOCK for http://qemu-project.org/Features/VirtioVsock + probe_devices() fixes not to overrun buffer for name of device + Add linux-specific pcap_set_protocol_linux() to allow specifying a specific capture protocol. + RDMA sniffing support for pcap + Add Nordic Semiconductor Bluetooth LE sniffer link-layer header type. + fixes for reading /etc/ethers + Make it possible to build on Windows without packet.dll. + Add tests for large file support on UN*X. + Solaris fixes to work with 2.8.6 + configuration test now looks for header files, not capture devices present + Fix to work with Berkeley YACC. + fixes for DragonBSD compilation of pcap-netmap.c + Clean up the ether_hostton() stuff. + Add an option to disable Linux memory-mapped capture support. + Add DAG API support checks. + Add Septel, Myricom SNF, and Riverbed TurboCap checks. + Add checks for Linux USB, Linux Bluetooth, D-Bus, and RDMA sniffing support. + Add a check for hardware time stamping on Linux. + Don't bother supporting pre-2005 Visual Studio. + Increased minimum autoconf version requirement to 2.64 + Add DLT value 273 for XRA-31 sniffer + Clean up handing of signal interrupts in pcap_read_nocb_remote(). + Use the XPG 4.2 versions of the networking APIs in Solaris. + Fix, and better explain, the "IPv6 means IPv6, not IPv4" option setting. + Explicitly warn that negative packet buffer timeouts should not be used. + rpcapd: Add support inetd-likes, including xinetd.conf, and systemd units + Rename DLT_IEEE802_15_4 to DLT_IEEE802_15_4_WITHFCS. + Add DISPLAYPORT AUX link type + Remove the sunos4 kernel modules and all references to them. + Add more interface flags to pcap_findalldevs(). + Summary for 1.9.0 libpcap release (to 2017-01-25 by guy@alum.mit.edu) + Man page improvements + Fix Linux cooked mode userspace filtering (GitHub pull request #429) + Fix compilation if IPv6 support not enabled + Fix some Linux memory-mapped capture buffer size issues + Don't fail if kernel filter can't be set on Linux (GitHub issue + #549) + Improve sorting of interfaces for pcap_findalldevs() + Don't list Linux usbmon devices if usbmon module isn't loaded + Report PCAP_ERROR_PERM_DENIED if no permission to open Linux usbmon + devices + Fix DLT_ type for Solaris IPNET devices + Always return an error message for errors finding DAG or Myricom + devices + If possible, don't require that a device be openable when + enumerating them for pcap_findalldevs() + Don't put incompletely-initialized addresses in the address list for + When finding Myricom devices, update description for regular + interfaces that are Myricom devices and handle SNF_FLAGS=0x2(port + aggregation enabled) + Fix compilation error in DAG support + Fix issues with CMake configuration + Add support for stream buffers larger than 2GB on newer DAG cards + Remove support for building against DAG versions without STREAMS + support (before dag-3.0.0 2007) + Tuesday, Oct. 25, 2016 mcr@sandelman.ca Summary for 1.8.1 libpcap release Add a target in Makefile.in for Exuberant Ctags use: 'extags'. diff --git a/libpcap/CMakeLists.txt b/libpcap/CMakeLists.txt index 0ed8b6129..905ba61aa 100644 --- a/libpcap/CMakeLists.txt +++ b/libpcap/CMakeLists.txt @@ -1,167 +1,848 @@ -cmake_minimum_required( VERSION 2.8.8 ) +cmake_minimum_required(VERSION 2.8.6) -project( pcap ) # -# Call the library "wpcap" on Windows, for backwards compatibility. +# Apple doesn't build with an install_name starting with @rpath, and +# neither do we with autotools; don't do so with CMake, either, and +# suppress warnings about that. # -if( WIN32 ) - set( LIBRARY_NAME wpcap ) -else() - set( LIBRARY_NAME pcap ) +if(POLICY CMP0042) + cmake_policy(SET CMP0042 OLD) endif() +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) + +project(pcap) + +# +# Try to enable as many C99 features as we can. +# At minimum, we want C++/C99-style // comments. +# +# Newer versions of compilers might default to supporting C99, but older +# versions may require a special flag. +# +# Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have any effect, +# so, unless and until we require CMake 3.1 or later, we have to do it +# ourselves on pre-3.1 CMake, so we just do it ourselves on all versions +# of CMake. +# +# Note: with CMake 3.1 through 3.5, the only compilers for which CMake +# handles CMAKE_C_STANDARD are GCC and Clang. 3.6 adds support only +# for Intel C; 3.9 adds support for PGI C, Sun C, and IBM XL C, and +# 3.10 adds support for Cray C and IAR C, but no version of CMake has +# support for HP C. Therefore, even if we use CMAKE_C_STANDARD with +# compilers for which CMake supports it, we may still have to do it +# ourselves on other compilers. +# +# See the CMake documentation for the CMAKE__COMPILER_ID variables +# for a list of compiler IDs. +# +# We don't worry about MSVC; it doesn't have such a flag - either it +# doesn't support the C99 features we need at all, or it supports them +# regardless of the compiler flag. +# +# XXX - this just tests whether the option works and adds it if it does. +# We don't test whether it's necessary in order to get the C99 features +# that we use; if we ever have a user who tries to compile with a compiler +# that can't be made to support those features, we can add a test to make +# sure we actually *have* C99 support. +# +include(CheckCCompilerFlag) +macro(check_and_add_compiler_option _option) + message(STATUS "Checking C compiler flag ${_option}") + string(REPLACE "=" "-" _temp_option_variable ${_option}) + string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable}) + check_c_compiler_flag("${_option}" ${_option_variable}) + if(${${_option_variable}}) + set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}") + endif() +endmacro() + +set(C_ADDITIONAL_FLAGS "") +if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR + CMAKE_C_COMPILER_ID MATCHES "Clang") + check_and_add_compiler_option("-std=gnu99") +elseif(CMAKE_C_COMPILER_ID MATCHES "XL") + # + # We want support for extensions picked up for GNU C compatibility, + # so we use -qlanglvl=extc99. + # + check_and_add_compiler_option("-qlanglvl=extc99") +elseif(CMAKE_C_COMPILER_ID MATCHES "HP") + check_and_add_compiler_option("-AC99") +elseif(CMAKE_C_COMPILER_ID MATCHES "Sun") + check_and_add_compiler_option("-xc99") +elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + check_and_add_compiler_option("-c99") +endif() + +# +# Build all runtimes in the top-level binary directory; that way, +# on Windows, the executables will be in the same directory as +# the DLLs, so the system will find pcap.dll when any of the +# executables are run. +# +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run) + ################################################################### # Parameters ################################################################### -option (INET6 "Enable IPv6" ON) -if( MSVC ) - option (USE_STATIC_RT "Use static Runtime" ON) -endif( MSVC ) -option (BUILD_SHARED_LIBS "Build shared libraries" ON) -if( WIN32 ) +if(WIN32) + # + # On Windows, allow the library name to be overridden, for the + # benefit of projects that combine libpcap with their own + # kernel-mode code to support capturing. + # + set(LIBRARY_NAME pcap CACHE STRING "Library name") +else() + # + # On UN*X, it's always been libpcap. + # + set(LIBRARY_NAME pcap) +endif() + +option(INET6 "Enable IPv6" ON) +if(WIN32) + option(USE_STATIC_RT "Use static Runtime" ON) +endif(WIN32) +option(BUILD_SHARED_LIBS "Build shared libraries" ON) +if(WIN32) set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll") -endif( WIN32 ) +endif(WIN32) + +# To pacify those who hate the protochain instruction +option(NO_PROTOCHAIN "Disable protochain instruction" OFF) # -# XXX - this should be an option, defaulting to "yes" for Windows and to -# "no", for now, on UN*X. +# Start out with the capture mechanism type unspecified; the user +# can explicitly specify it and, if they don't, we'll pick an +# appropriate one. # -if( WIN32 ) - set( HAVE_REMOTE 1 ) -endif( WIN32 ) +set(PCAP_TYPE "" CACHE STRING "Packet capture type") + +# +# Default to having remote capture support on Windows and, for now, to +# not having it on UN*X. +# +if(WIN32) + option(ENABLE_REMOTE "Enable remote capture" ON) +else() + option(ENABLE_REMOTE "Enable remote capture" OFF) +endif(WIN32) + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + option(PCAP_SUPPORT_PACKET_RING "Enable Linux packet ring support" ON) + option(BUILD_WITH_LIBNL "Build with libnl" ON) +endif() + +# +# By default, build universal with the appropriate set of architectures +# for the OS on which we're doing the build. +# +if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") + # + # Get the major version of Darwin. + # + string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}") + + if(SYSTEM_VERSION_MAJOR LESS 8) + # + # Pre-Tiger. Build only for 32-bit PowerPC. + # + set(CMAKE_OSX_ARCHITECTURES "ppc") + elseif(SYSTEM_VERSION_MAJOR EQUAL 8) + # + # Tiger. Is this prior to, or with, Intel support? + # + # Get the minor version of Darwin. + # + string(REPLACE "${SYSTEM_VERSION_MAJOR}." "" SYSTEM_MINOR_AND_PATCH_VERSION ${CMAKE_SYSTEM_VERSION}) + string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MINOR "${SYSTEM_MINOR_AND_PATCH_VERSION}") + if(SYSTEM_VERSION_MINOR LESS 4) + # + # Prior to Intel support. Build for 32-bit + # PowerPC and 64-bit PowerPC, with 32-bit PowerPC + # first. (I'm guessing that's what Apple does.) + # + set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64") + elseif(SYSTEM_VERSION_MINOR LESS 7) + # + # With Intel support but prior to x86-64 support. + # Build for 32-bit PowerPC, 64-bit PowerPC, and x86, + # with 32-bit PowerPC first. + # (I'm guessing that's what Apple does.) + # + set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64;i386") + else() + # + # With Intel support including x86-64 support. + # Build for 32-bit PowerPC, 64-bit PowerPC, x86, + # and x86-64, with 32-bit PowerPC first. + # (I'm guessing that's what Apple does.) + # + set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64;i386;x86_64") + endif() + elseif(SYSTEM_VERSION_MAJOR EQUAL 9) + # + # Leopard. Build for 32-bit PowerPC, 64-bit + # PowerPC, x86, and x86-64, with 32-bit PowerPC + # first. (That's what Apple does.) + # + set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64;i386;x86_64") + elseif(SYSTEM_VERSION_MAJOR EQUAL 10) + # + # Snow Leopard. Build for x86-64, x86, and + # 32-bit PowerPC, with x86-64 first. (That's + # what Apple does, even though Snow Leopard + # doesn't run on PPC, so PPC libpcap runs under + # Rosetta, and Rosetta doesn't support BPF + # ioctls, so PPC programs can't do live + # captures.) + # + set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc") + else() + # + # Post-Snow Leopard. Build for x86-64 and + # x86, with x86-64 first. (That's probably what + # Apple does, given that Rosetta is gone.) + # XXX - update if and when Apple drops support + # for 32-bit x86 code. + # + set(CMAKE_OSX_ARCHITECTURES "x86_64;i386") + endif() +endif() + +# +# Additional capture modules. +# +option(DISABLE_USB "Disable USB sniffing support" OFF) +option(DISABLE_BLUETOOTH "Disable Bluetooth sniffing support" OFF) +option(DISABLE_NETMAP "Disable netmap support" OFF) +# +# We don't support D-Bus sniffing on macOS; see +# +# https://bugs.freedesktop.org/show_bug.cgi?id=74029 +# +if(APPLE) + option(DISABLE_DBUS "Disable D-Bus sniffing support" ON) +else(APPLE) + option(DISABLE_DBUS "Disable D-Bus sniffing support" OFF) +endif(APPLE) +option(DISABLE_RDMA "Disable RDMA sniffing support" OFF) + +option(DISABLE_DAG "Disable Endace DAG card support" OFF) + +option(DISABLE_SEPTEL "Disable Septel card support" OFF) +set(SEPTEL_ROOT "${CMAKE_SOURCE_DIR}/../septel" CACHE PATH "Path to directory with include and lib subdirectories for Septel API") + +option(DISABLE_SNF "Disable Myricom SNF support" OFF) + +option(DISABLE_TC "Disable Riverbed TurboCap support" OFF) + +# +# Debugging options. +# +option(BDEBUG "Build optimizer debugging code" OFF) +option(YYDEBUG "Build parser debugging code" OFF) + +################################################################### +# Versioning +################################################################### + +# Get, parse, format and set pcap's version string from [pcap_root]/VERSION +# for later use. + +# Get MAJOR, MINOR, PATCH & SUFFIX +file(STRINGS ${pcap_SOURCE_DIR}/VERSION + PACKAGE_VERSION + LIMIT_COUNT 1 # Read only the first line +) + +# Get "just" MAJOR +string(REGEX MATCH "^([0-9]+)" PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION}") + +# Get MAJOR, MINOR & PATCH +string(REGEX MATCH "^([0-9]+.)?([0-9]+.)?([0-9]+)" PACKAGE_VERSION_NOSUFFIX "${PACKAGE_VERSION}") + +if(WIN32) + # Convert PCAP_VERSION_NOSUFFIX to Windows preferred version format + string(REPLACE "." "," PACKAGE_VERSION_PREDLL ${PACKAGE_VERSION_NOSUFFIX}) + + # Append NANO (used for Windows internal versioning) to PCAP_VERSION_PREDLL + # 0 means unused. + set(PACKAGE_VERSION_DLL ${PACKAGE_VERSION_PREDLL},0) +endif(WIN32) + +set(PACKAGE_NAME "${LIBRARY_NAME}") +set(PACKAGE_STRING "${LIBRARY_NAME} ${PACKAGE_VERSION}") ###################################### # Project settings ###################################### -add_definitions( -DHAVE_CONFIG_H ) +add_definitions(-DHAVE_CONFIG_H) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${pcap_SOURCE_DIR} ) -if( WIN32 ) - if( NOT "${PACKET_DLL_DIR}" STREQUAL "" ) - include_directories("${PACKET_DLL_DIR}/Include") - if( CMAKE_CL_64 ) - link_directories("${PACKET_DLL_DIR}/Lib/x64") - else( CMAKE_CL_64 ) - link_directories("${PACKET_DLL_DIR}/Lib") - endif( CMAKE_CL_64 ) - endif() - include_directories( - ../Common/ - Win32/Include - ) -endif( WIN32) +include(CheckFunctionExists) +include(CMakePushCheckState) -add_definitions( -DBUILDING_PCAP ) +if(WIN32) -if( MSVC ) - add_definitions( -D__STDC__ ) - add_definitions( -D_CRT_SECURE_NO_WARNINGS ) - add_definitions( "-D_U_=" ) -elseif( CMAKE_COMPILER_IS_GNUCXX ) - add_definitions( "-D_U_=__attribute__((unused))" ) -else(MSVC) - add_definitions( "-D_U_=" ) -endif( MSVC ) + if(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/../../Common) + include_directories(${CMAKE_HOME_DIRECTORY}/../../Common) + endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/../../Common) -if( MSVC ) - if (USE_STATIC_RT) - MESSAGE( STATUS "Use STATIC runtime" ) - set(NAME_RT MT) - set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT") - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") + find_package(Packet) + if(PACKET_FOUND) + set(HAVE_PACKET32 TRUE) + include_directories(${PACKET_INCLUDE_DIRS}) + # + # Check whether we have the NPcap PacketIsLoopbackAdapter() + # function. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ${PACKET_LIBRARIES}) + check_function_exists(PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER) + cmake_pop_check_state() + endif(PACKET_FOUND) - set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT") - set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT") - set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") - set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") - else (USE_STATIC_RT) - MESSAGE( STATUS "Use DYNAMIC runtime" ) - set(NAME_RT MD) - set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD") - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") +endif(WIN32) - set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD") - set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD") - set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD") - set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd") - endif (USE_STATIC_RT) -endif( MSVC ) +if(MSVC) + add_definitions(-D__STDC__) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif(MSVC) + +if(USE_STATIC_RT) + message(STATUS "Use STATIC runtime") + if(MSVC) + foreach(RT_FLAG + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + string(REGEX REPLACE "/MD" "/MT" ${RT_FLAG} "${${RT_FLAG}}") + endforeach(RT_FLAG) + elseif(MINGW) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc") + endif() +else (USE_STATIC_RT) + message(STATUS "Use DYNAMIC runtime") +endif(USE_STATIC_RT) ################################################################### # Detect available platform features ################################################################### include(CheckIncludeFile) -include(CheckFunctionExists) +include(CheckIncludeFiles) include(CheckStructHasMember) include(CheckTypeSize) # # Header files. # -check_include_file( inttypes.h HAVE_INTTYPES_H ) -check_include_file( stdint.h HAVE_STDINT_H ) -check_include_file( unistd.h HAVE_UNISTD_H ) -if( NOT HAVE_UNISTD_H ) - add_definitions( -DYY_NO_UNISTD_H ) -endif( NOT HAVE_UNISTD_H ) -check_include_file( bitypes.h HAVE_SYS_BITYPES_H ) -check_include_file( limits.h HAVE_LIMITS_H ) +check_include_file(inttypes.h HAVE_INTTYPES_H) +check_include_file(stdint.h HAVE_STDINT_H) +check_include_file(unistd.h HAVE_UNISTD_H) +if(NOT HAVE_UNISTD_H) + add_definitions(-DYY_NO_UNISTD_H) +endif(NOT HAVE_UNISTD_H) +check_include_file(bitypes.h HAVE_SYS_BITYPES_H) +if(NOT WIN32) + check_include_file(sys/ioccom.h HAVE_SYS_IOCCOM_H) + check_include_file(sys/sockio.h HAVE_SYS_SOCKIO_H) + check_include_file(sys/select.h HAVE_SYS_SELECT_H) +endif(NOT WIN32) +check_include_file(limits.h HAVE_LIMITS_H) +if(NOT WIN32) + 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) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + check_include_file(linux/sockios.h HAVE_LINUX_SOCKIOS_H) + # + # linux/if_bonding.h requires sys/socket.h. + # + check_include_files("sys/socket.h;linux/if_bonding.h" HAVE_LINUX_IF_BONDING_H) + endif() +endif(NOT WIN32) # # Functions. # -check_function_exists( strerror HAVE_STRERROR ) -check_function_exists( strlcpy HAVE_STRLCPY ) -check_function_exists( snprintf HAVE_SNPRINTF ) -check_function_exists( vsnprintf HAVE_VSNPRINTF ) -check_function_exists( strtok_r HAVE_STRTOK_R ) +check_function_exists(strerror HAVE_STRERROR) +check_function_exists(strerror_r HAVE_STRERROR_R) +check_function_exists(strerror_s HAVE_STRERROR_S) +check_function_exists(strlcpy HAVE_STRLCPY) +check_function_exists(strlcat HAVE_STRLCAT) +check_function_exists(snprintf HAVE_SNPRINTF) +check_function_exists(vsnprintf HAVE_VSNPRINTF) +check_function_exists(strtok_r HAVE_STRTOK_R) -if (WIN32) +# +# These tests are for network applications that need socket functions +# and getaddrinfo()/getnameinfo()-ish functions. We now require +# getaddrinfo() and getnameinfo(). On UN*X systems, we also prefer +# versions of recvmsg() that conform to the Single UNIX Specification, +# so that we can check whether a datagram received with recvmsg() was +# truncated when received due to the buffer being too small. +# +# On Windows, getaddrinfo() is in the ws2_32 library. + +# On most UN*X systems, they're available in the system library. +# +# Under Solaris, we need to link with libsocket and libnsl to get +# getaddrinfo() and getnameinfo() and, if we have libxnet, we need to +# link with libxnet before libsocket to get a version of recvmsg() +# that conforms to the Single UNIX Specification. +# +# We use getaddrinfo() because we want a portable thread-safe way +# of getting information for a host name or port; there exist _r +# versions of gethostbyname() and getservbyname() on some platforms, +# but not on all platforms. +# +# NOTE: if you hand check_library_exists as its last argument a variable +# that's been set, it skips the test, so we need different variables. +# +set(PCAP_LINK_LIBRARIES "") +include(CheckLibraryExists) +include(CheckSymbolExists) +if(WIN32) # - # Check for Windows-only functions, such as packet.dll functions. + # We need winsock2.h and ws2tcpip.h. # - check_function_exists( PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER ) -endif() + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ws2_32) + check_symbol_exists(getaddrinfo "winsock2.h;ws2tcpip.h" LIBWS2_32_HAS_GETADDRINFO) + cmake_pop_check_state() + if(LIBWS2_32_HAS_GETADDRINFO) + set(PCAP_LINK_LIBRARIES ws2_32 ${PCAP_LINK_LIBRARIES}) + else(LIBWS2_32_HAS_GETADDRINFO) + message(FATAL_ERROR "getaddrinfo is required, but wasn't found") + endif(LIBWS2_32_HAS_GETADDRINFO) +else(WIN32) + # + # UN*X. First try the system libraries, then try the libraries + # for Solaris and possibly other systems that picked up the + # System V library split. + # + check_function_exists(getaddrinfo STDLIBS_HAVE_GETADDRINFO) + if(NOT STDLIBS_HAVE_GETADDRINFO) + # + # Not found in the standard system libraries. + # Try libsocket, which requires libnsl. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES nsl) + check_library_exists(socket getaddrinfo "" LIBSOCKET_HAS_GETADDRINFO) + cmake_pop_check_state() + if(LIBSOCKET_HAS_GETADDRINFO) + # + # OK, we found it in libsocket. + # + set(PCAP_LINK_LIBRARIES socket nsl ${PCAP_LINK_LIBRARIES}) + else(LIBSOCKET_HAS_GETADDRINFO) + # + # We didn't find it. + # + message(FATAL_ERROR "getaddrinfo is required, but wasn't found") + endif(LIBSOCKET_HAS_GETADDRINFO) + + # + # OK, do we have recvmsg() in libxnet? + # We also link with libsocket and libnsl. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES socket nsl) + check_library_exists(xnet recvmsg "" LIBXNET_HAS_RECVMSG) + cmake_pop_check_state() + if(LIBXNET_HAS_RECVMSG) + # + # Yes - link with it as well. + # + set(PCAP_LINK_LIBRARIES xnet ${PCAP_LINK_LIBRARIES}) + endif(LIBXNET_HAS_RECVMSG) + endif(NOT STDLIBS_HAVE_GETADDRINFO) + + # DLPI needs putmsg under HPUX so test for -lstr while we're at it + check_function_exists(putmsg STDLIBS_HAVE_PUTMSG) + if(NOT STDLIBS_HAVE_PUTMSG) + check_library_exists(str putmsg "" LIBSTR_HAS_PUTMSG) + if(LIBSTR_HAS_PUTMSG) + set(PCAP_LINK_LIBRARIES str ${PCAP_LINK_LIBRARIES}) + endif(LIBSTR_HAS_PUTMSG) + endif(NOT STDLIBS_HAVE_PUTMSG) +endif(WIN32) + +# +# Check for reentrant versions of getnetbyname_r(), as provided by +# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). +# If we don't find one, we just use getnetbyname(), which uses +# thread-specific data on many platforms, but doesn't use it on +# NetBSD or OpenBSD, and may not use it on older versions of other +# platforms. +# +# Only do the check if we have a declaration of getnetbyname_r(); +# without it, we can't check which API it has. (We assume that +# if there's a declaration, it has a prototype, so that the API +# can be checked.) +# +cmake_push_check_state() +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) +check_symbol_exists(getnetbyname_r netdb.h NETDB_H_DECLARES_GETNETBYNAME_R) +if(NETDB_H_DECLARES_GETNETBYNAME_R) + check_c_source_compiles( +"#include + +int +main(void) +{ + struct netent netent_buf; + char buf[1024]; + struct netent *resultp; + int h_errnoval; + + return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval); +} +" + HAVE_LINUX_GETNETBYNAME_R) + if(NOT HAVE_LINUX_GETNETBYNAME_R) + check_c_source_compiles( +"#include + +int +main(void) +{ + struct netent netent_buf; + char buf[1024]; + + return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL; +} +" + HAVE_SOLARIS_IRIX_GETNETBYNAME_R) + if(NOT HAVE_SOLARIS_IRIX_GETNETBYNAME_R) + check_c_source_compiles( +"#include + +int +main(void) +{ + struct netent netent_buf; + struct netent_data net_data; + + return getnetbyname_r((const char *)0, &netent_buf, &net_data); +} +" + HAVE_AIX_GETNETBYNAME_R) + endif(NOT HAVE_SOLARIS_IRIX_GETNETBYNAME_R) + endif(NOT HAVE_LINUX_GETNETBYNAME_R) +endif(NETDB_H_DECLARES_GETNETBYNAME_R) +cmake_pop_check_state() + +# +# Check for reentrant versions of getprotobyname_r(), as provided by +# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). +# If we don't find one, we just use getprotobyname(), which uses +# thread-specific data on many platforms, but doesn't use it on +# NetBSD or OpenBSD, and may not use it on older versions of other +# platforms. +# +# Only do the check if we have a declaration of getprotobyname_r(); +# without it, we can't check which API it has. (We assume that +# if there's a declaration, it has a prototype, so that the API +# can be checked.) +# +cmake_push_check_state() +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) +check_symbol_exists(getprotobyname_r netdb.h NETDB_H_DECLARES_GETPROTOBYNAME_R) +if(NETDB_H_DECLARES_GETPROTOBYNAME_R) + check_c_source_compiles( +"#include + +int +main(void) +{ + struct protoent protoent_buf; + char buf[1024]; + struct protoent *resultp; + + return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp); +} +" + HAVE_LINUX_GETPROTOBYNAME_R) + if(NOT HAVE_LINUX_GETPROTOBYNAME_R) + check_c_source_compiles( +"#include + +int +main(void) +{ + struct protoent protoent_buf; + char buf[1024]; + + return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL; +} +" + HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R) + if(NOT HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R) + check_c_source_compiles( +"#include + +int +main(void) +{ + struct protoent protoent_buf; + struct protoent_data proto_data; + + return getprotobyname_r((const char *)0, &protoent_buf, &proto_data); +} +" + HAVE_AIX_GETPROTOBYNAME_R) + endif(NOT HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R) + endif(NOT HAVE_LINUX_GETPROTOBYNAME_R) +endif(NETDB_H_DECLARES_GETPROTOBYNAME_R) +cmake_pop_check_state() # # Data types. # -# XXX - there's no check_struct() macro that's like check_struct_has_member() +# XXX - there's no check_type() macro that's like check_type_size() # except that it only checks for the existence of the structure type, -# so we use check_struct_has_member() and look for ss_family. +# so we use check_type_size() and ignore the size. # -check_struct_has_member("struct sockaddr_storage" ss_family sys/socket.h HAVE_SOCKADDR_STORAGE) -set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h) +cmake_push_check_state() +if(WIN32) + set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h) +else(WIN32) + set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h) +endif(WIN32) +check_type_size("struct sockaddr_storage" STRUCT_SOCKADDR_STORAGE) check_type_size("socklen_t" SOCKLEN_T) -set(CMAKE_EXTRA_INCLUDE_FILES unistd.h) +cmake_pop_check_state() # # Structure fields. # -check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_SOCKADDR_SA_LEN ) +if(WIN32) + check_struct_has_member("struct sockaddr" sa_len winsock2.h HAVE_STRUCT_SOCKADDR_SA_LEN) +else(WIN32) + check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_STRUCT_SOCKADDR_SA_LEN) +endif(WIN32) -if( INET6 ) - MESSAGE( STATUS "Use IPv6" ) -endif( INET6 ) +# +# Do we have ffs(), and is it declared in ? +# +check_function_exists(ffs HAVE_FFS) +if(HAVE_FFS) + # + # OK, we have ffs(). Is it declared in ? + # + # This test fails if we don't have or if we do + # but it doesn't declare ffs(). + # + check_symbol_exists(ffs strings.h STRINGS_H_DECLARES_FFS) +endif() -if( WIN32 ) - add_definitions( -DHAVE_ADDRINFO ) -endif( WIN32 ) +# +# This requires the libraries that we require, as ether_hostton might be +# in one of those libraries. That means we have to do this after +# we check for those libraries. +# +# You are in a twisty little maze of UN*Xes, all different. +# Some might not have ether_hostton(). +# Some might have it and declare it in . +# Some might have it and declare it in +# Some might have it and declare it in . +# Some might have it and declare it in . +# Some might have it and declare it in . +# Some might have it and not declare it in any header file. +# +# Before you is a C compiler. +# +cmake_push_check_state() +set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) +check_function_exists(ether_hostton HAVE_ETHER_HOSTTON) +if(HAVE_ETHER_HOSTTON) + # + # OK, we have ether_hostton(). Is it declared in ? + # + # This test fails if we don't have or if we do + # but it doesn't declare ether_hostton(). + # + check_symbol_exists(ether_hostton net/ethernet.h NET_ETHERNET_H_DECLARES_ETHER_HOSTTON) + if(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON) + # + # Yes - we have it declared. + # + set(HAVE_DECL_ETHER_HOSTTON TRUE) + endif() + # + # Did that succeed? + # + if(NOT HAVE_DECL_ETHER_HOSTTON) + # + # No - how about , as on Linux? + # + # This test fails if we don't have + # or if we do but it doesn't declare ether_hostton(). + # + check_symbol_exists(ether_hostton netinet/ether.h NETINET_ETHER_H_DECLARES_ETHER_HOSTTON) + if(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON) + # + # Yes - we have it declared. + # + set(HAVE_DECL_ETHER_HOSTTON TRUE) + endif() + endif() + # + # Did that succeed? + # + if(NOT HAVE_DECL_ETHER_HOSTTON) + # + # No - how about , as on Solaris 10 and later? + # + # This test fails if we don't have + # or if we do but it doesn't declare ether_hostton(). + # + check_symbol_exists(ether_hostton sys/ethernet.h SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON) + if(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON) + # + # Yes - we have it declared. + # + set(HAVE_DECL_ETHER_HOSTTON TRUE) + endif() + endif() + # + # Did that succeed? + # + if(NOT HAVE_DECL_ETHER_HOSTTON) + # + # No, how about , as on AIX? + # + # This test fails if we don't have + # or if we do but it doesn't declare ether_hostton(). + # + check_symbol_exists(ether_hostton arpa/inet.h ARPA_INET_H_DECLARES_ETHER_HOSTTON) + if(ARPA_INET_H_DECLARES_ETHER_HOSTTON) + # + # Yes - we have it declared. + # + set(HAVE_DECL_ETHER_HOSTTON TRUE) + endif() + endif() + # + # Did that succeed? + # + if(NOT HAVE_DECL_ETHER_HOSTTON) + # + # No, how about ? + # On some platforms, it requires and + # , and we always include it with + # both of them, so test it with both of them. + # + # This test fails if we don't have + # and the headers we include before it, or if we do but + # doesn't declare ether_hostton(). + # + check_symbol_exists(ether_hostton "sys/types.h;sys/socket.h;net/if.h;netinet/in.h;netinet/if_ether.h" NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON) + if(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON) + # + # Yes - we have it declared. + # + set(HAVE_DECL_ETHER_HOSTTON TRUE) + endif() + endif() + # + # After all that, is ether_hostton() declared? + # + if(NOT HAVE_DECL_ETHER_HOSTTON) + # + # No, we'll have to declare it ourselves. + # Do we have "struct ether_addr" if we include ? + # + # XXX - there's no check_type() macro that's like check_type_size() + # except that it only checks for the existence of the structure type, + # so we use check_type_size() and ignore the size. + # + cmake_push_check_state() + set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h net/if.h netinet/in.h netinet/if_ether.h) + check_type_size("struct ether_addr" STRUCT_ETHER_ADDR) + cmake_pop_check_state() + endif() +endif() +cmake_pop_check_state() -###################################### -# External dependencies -###################################### +# +# Large file support on UN*X, a/k/a LFS. +# +if(NOT WIN32) + include(FindLFS) + if(LFS_FOUND) + # + # Add the required #defines. + # + add_definitions(${LFS_DEFINITIONS}) + endif() + + # + # Check for fseeko as well. + # + include(FindFseeko) + if(FSEEKO_FOUND) + set(HAVE_FSEEKO ON) + + # + # Add the required #defines. + # + add_definitions(${FSEEKO_DEFINITIONS}) + endif() +endif() + +if(INET6) + message(STATUS "Support IPv6") +endif(INET6) + +# +# Pthreads. +# We might need them, because some libraries we use might use them, +# but we don't necessarily need them. +# That's only on UN*X; on Windows, if they use threads, we assume +# they're native Windows threads. +# +if(NOT WIN32) + set(CMAKE_THREAD_PREFER_PTHREAD ON) + find_package(Threads) + if(NOT CMAKE_USE_PTHREADS_INIT) + # + # If it's not pthreads, we won't use it; we use it for libraries + # that require it. + # + set(CMAKE_THREAD_LIBS_INIT "") + endif(NOT CMAKE_USE_PTHREADS_INIT) +endif(NOT WIN32) ###################################### # Input files @@ -169,104 +850,337 @@ endif( WIN32 ) set(PROJECT_SOURCE_LIST_C bpf_dump.c + bpf_filter.c bpf_image.c etherent.c - fad-helpers.c + fmtutils.c gencode.c - inet.c nametoaddr.c optimize.c pcap-common.c pcap.c savefile.c - sf-pcap-ng.c + sf-pcapng.c sf-pcap.c - bpf/net/bpf_filter.c ) -if( WIN32 ) - set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/win_snprintf.c ) +if(WIN32) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/win_snprintf.c) else() - if( NOT HAVE_SNPRINTF ) - set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c ) - endif( NOT HAVE_SNPRINTF ) - if( NOT HAVE_STRTOK_R ) - set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strtok_r.c ) - endif( NOT HAVE_STRTOK_R ) -endif( WIN32 ) - -if( HAVE_REMOTE ) - set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} - pcap-new.c pcap-rpcap.c sockutils.c) -endif( HAVE_REMOTE ) + if(NOT HAVE_SNPRINTF) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c) + endif(NOT HAVE_SNPRINTF) + if(NOT HAVE_STRTOK_R) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strtok_r.c) + endif(NOT HAVE_STRTOK_R) +endif(WIN32) # -# Determine the main pcap-XXX.c file to use. +# Determine the main pcap-XXX.c file to use, and the libraries with +# which we need to link libpcap, if any. # -if( WIN32 ) +if(WIN32) # - # WinPcap. + # Windows. # - set( PCAP_TYPE win32 ) -else() + # Has the user explicitly specified a capture type? # - # UN*X - figure out what type of packet capture mechanism we - # have. - # - if( EXISTS /dev/bpf ) - # - # Cloning BPF device. - # - set( PCAP_TYPE bpf ) - AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device]) - elseif( EXISTS /dev/bpf0 ) - set( PCAP_TYPE bpf ) - + if(PCAP_TYPE STREQUAL "") # - # XXX - many more BPF checks. + # The user didn't explicitly specify a capture mechanism. + # Check whether we have packet.dll. # - elseif( EXISTS /usr/include/net/pfilt.h ) - # - # DEC OSF/1, Digital UNIX, Tru64 UNIX - # - set( PCAP_TYPE pf ) - elseif( EXISTS /dev/enet ) - set( PCAP_TYPE enet ) - elseif( EXISTS /dev/nit ) - set( PCAP_TYPE snit ) - elseif( EXISTS /usr/include/sys/net/nit.h ) - set( PCAP_TYPE nit ) - elseif( EXISTS /usr/include/linux/socket.h ) - set( PCAP_TYPE linux ) - - # - # Do we have the wireless extensions? - # - check_include_file( linux/wireless.h HAVE_LINUX_WIRELESS_H ) - - # - # XXX - many more Linux checks. - # - elseif( EXISTS /usr/include/net/raw.h ) - set( PCAP_TYPE snoop ) - elseif( EXISTS /usr/include/odmi.h ) - # - # On AIX, the BPF devices might not yet be present - they're - # created the first time libpcap runs after booting. - # We check for odmi.h instead. - # - set( PCAP_TYPE bpf ) - elseif( /usr/include/sys/dlpi.h ) - set( PCAP_TYPE dlpi ) - - # - # XXX - many more DLPI checks. - # - else() - set( PCAP_TYPE null ) + if(HAVE_PACKET32) + # + # We have packet.dll. + # Set the capture type to NPF. + # + set(PCAP_TYPE npf) + else() + # + # We don't have any capture type we know about, so just use + # the null capture type, and only support reading (and writing) + # capture files. + # + set(PCAP_TYPE null) + endif() endif() -endif( WIN32 ) +else() + # + # UN*X. + # + # Figure out what type of packet capture mechanism we have, and + # what libraries we'd need to link libpcap with, if any. + # + + # + # Has the user explicitly specified a capture type? + # + if(PCAP_TYPE STREQUAL "") + # + # Check for a bunch of headers for various packet capture mechanisms. + # + check_include_files("sys/types.h;net/bpf.h" HAVE_NET_BPF_H) + if(HAVE_NET_BPF_H) + # + # Does it define BIOCSETIF? + # I.e., is it a header for an LBL/BSD-style capture + # mechanism, or is it just a header for a BPF filter + # engine? Some versions of Arch Linux, for example, + # have a net/bpf.h that doesn't define BIOCSETIF; + # as it's a Linux, it should use packet sockets, + # instead. + # + # + # We need: + # + # sys/types.h, because FreeBSD 10's net/bpf.h + # requires that various BSD-style integer types + # be defined; + # + # sys/ioctl.h and, if we have it, sys/ioccom.h, + # because net/bpf.h defines ioctls; + # + # net/if.h, because it defines some structures + # used in ioctls defined by net/bpf.h; + # + # sys/socket.h, because OpenBSD 5.9's net/bpf.h + # defines some structure fields as being + # struct sockaddrs; + # + # and net/bpf.h doesn't necessarily include all + # of those headers itself. + # + if(HAVE_SYS_IOCCOM_H) + check_symbol_exists(BIOCSETIF "sys/types.h;sys/ioctl.h;sys/socket.h;sys/ioccom.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF) + else(HAVE_SYS_IOCCOM_H) + check_symbol_exists(BIOCSETIF "sys/types.h;sys/ioctl.h;sys/socket.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF) + endif(HAVE_SYS_IOCCOM_H) + endif(HAVE_NET_BPF_H) + check_include_file(net/pfilt.h HAVE_NET_PFILT_H) + check_include_file(net/enet.h HAVE_NET_ENET_H) + check_include_file(net/nit.h HAVE_NET_NIT_H) + check_include_file(sys/net/nit.h HAVE_SYS_NET_NIT_H) + check_include_file(linux/socket.h HAVE_LINUX_SOCKET_H) + check_include_file(net/raw.h HAVE_NET_RAW_H) + check_include_file(sys/dlpi.h HAVE_SYS_DLPI_H) + + if(BPF_H_DEFINES_BIOCSETIF) + # + # BPF. + # Check this before DLPI, so that we pick BPF on + # Solaris 11 and later. + # + set(PCAP_TYPE bpf) + elseif(HAVE_LINUX_SOCKET_H) + # + # No prizes for guessing this one. + # + set(PCAP_TYPE linux) + elseif(HAVE_NET_PFILT_H) + # + # DEC OSF/1, Digital UNIX, Tru64 UNIX + # + set(PCAP_TYPE pf) + elseif(HAVE_NET_ENET_H) + # + # Stanford Enetfilter. + # + set(PCAP_TYPE enet) + elseif(HAVE_NET_NIT_H) + # + # SunOS 4.x STREAMS NIT. + # + set(PCAP_TYPE snit) + elseif(HAVE_SYS_NET_NIT_H) + # + # Pre-SunOS 4.x non-STREAMS NIT. + # + set(PCAP_TYPE nit) + elseif(HAVE_NET_RAW_H) + # + # IRIX snoop. + # + set(PCAP_TYPE snoop) + elseif(HAVE_SYS_DLPI_H) + # + # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others. + # + set(PCAP_TYPE dlpi) + else() + # + # Nothing we support. + # + set(PCAP_TYPE null) + endif() + endif() +endif(WIN32) message(STATUS "Packet capture mechanism type: ${PCAP_TYPE}") + +# +# Do capture-mechanism-dependent tests. +# +if(WIN32) + if(PCAP_TYPE STREQUAL "npf") + # + # Link with packet.dll before WinSock2. + # + set(PCAP_LINK_LIBRARIES ${PACKET_LIBRARIES} ${PCAP_LINK_LIBRARIES}) + elseif(PCAP_TYPE STREQUAL "null") + else() + message(ERROR "${PCAP_TYPE} is not a valid pcap type") + endif() +else(WIN32) + if(PCAP_TYPE STREQUAL "dlpi") + # + # Needed for common functions used by pcap-[dlpi,libdlpi].c + # + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} dlpisubs.c) + + # + # Checks for some header files. + # + check_include_file(sys/bufmod.h HAVE_SYS_BUFMOD_H) + check_include_file(sys/dlpi_ext.h HAVE_SYS_DLPI_EXT_H) + + # + # Checks to see if Solaris has the public libdlpi(3LIB) library. + # Note: The existence of /usr/include/libdlpi.h does not mean it is the + # public libdlpi(3LIB) version. Before libdlpi was made public, a + # private version also existed, which did not have the same APIs. + # Due to a gcc bug, the default search path for 32-bit libraries does + # not include /lib, we add it explicitly here. + # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485]. + # Also, due to the bug above applications that link to libpcap with + # libdlpi will have to add "-L/lib" option to "configure". + # + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "-L/lib") + set(CMAKE_REQUIRED_LIBRARIES dlpi) + check_function_exists(dlpi_walk HAVE_LIBDLPI) + cmake_pop_check_state() + if(HAVE_LIBDLPI) + # + # XXX - add -L/lib + # + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} dlpi) + set(PCAP_TYPE libdlpi) + endif() + + # + # This check is for Solaris with DLPI support for passive modes. + # See dlpi(7P) for more details. + # + # XXX - there's no check_type() macro that's like check_type_size() + # except that it only checks for the existence of the structure type, + # so we use check_type_size() and ignore the size. + # + cmake_push_check_state() + set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/dlpi.h) + check_type_size(dl_passive_req_t DL_PASSIVE_REQ_T) + cmake_pop_check_state() + elseif(PCAP_TYPE STREQUAL "linux") + # + # Do we have the wireless extensions? + # linux/wireless.h requires sys/socket.h. + # + check_include_files("sys/socket.h;linux/wireless.h" HAVE_LINUX_WIRELESS_H) + + # + # Do we have libnl? + # + if(BUILD_WITH_LIBNL) + # + # Try libnl 3.x first. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES nl-3) + check_function_exists(nl_socket_alloc HAVE_LIBNL) + cmake_pop_check_state() + if(HAVE_LIBNL) + # + # Yes, we have libnl 3.x. + # + set(PCAP_LINK_LIBRARIES nl-genl-3 nl-3 ${PCAP_LINK_LIBRARIES}) + set(HAVE_LIBNL_3_x ON) + set(HAVE_LIBNL_NLE ON) + set(HAVE_LIBNL_SOCKETS ON) + include_directories("/usr/include/libnl3") + else() + # + # Try libnl 2.x. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES nl) + check_function_exists(nl_socket_alloc HAVE_LIBNL) + cmake_pop_check_state() + if(HAVE_LIBNL) + # + # Yes, we have libnl 2.x. + # + set(PCAP_LINK_LIBRARIES nl-genl nl ${PCAP_LINK_LIBRARIES}) + set(HAVE_LIBNL_2_x ON) + set(HAVE_LIBNL_NLE ON) + set(HAVE_LIBNL_SOCKETS ON) + else() + # + # No, we don't; do we have libnl 1.x? + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES nl) + check_function_exists(nl_handle_alloc HAVE_LIBNL) + cmake_pop_check_state() + if(HAVE_LIBNL) + set(PCAP_LINK_LIBRARIES nl ${PCAP_LINK_LIBRARIES}) + endif() + endif() + endif() + endif() + + check_include_file(linux/ethtool.h HAVE_LINUX_ETHTOOL_H) + + # + # Checks to see if tpacket_stats is defined in linux/if_packet.h + # If so then pcap-linux.c can use this to report proper statistics. + # + # XXX - there's no check_type() macro that's like check_type_size() + # except that it only checks for the existence of the structure type, + # so we use check_type_size() and ignore the size. + # + cmake_push_check_state() + set(CMAKE_EXTRA_INCLUDE_FILES linux/if_packet.h) + check_type_size("struct tpacket_stats" STRUCT_TPACKET_STATS) + cmake_pop_check_state() + + check_struct_has_member("struct tpacket_auxdata" tp_vlan_tci linux/if_packet.h HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI) + elseif(PCAP_TYPE STREQUAL "bpf") + # + # Check whether we have the *BSD-style ioctls. + # + check_include_files("sys/types.h;net/if_media.h" HAVE_NET_IF_MEDIA_H) + + # + # Check whether we have struct BPF_TIMEVAL. + # + # XXX - there's no check_type() macro that's like check_type_size() + # except that it only checks for the existence of the structure type, + # so we use check_type_size() and ignore the size. + # + cmake_push_check_state() + if(HAVE_SYS_IOCCOM_H) + set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/ioccom.h net/bpf.h) + check_type_size("struct BPF_TIMEVAL" STRUCT_BPF_TIMEVAL) + else() + set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h net/bpf.h) + check_type_size("struct BPF_TIMEVAL" STRUCT_BPF_TIMEVAL) + endif() + cmake_pop_check_state() + elseif(PCAP_TYPE STREQUAL "null") + else() + message(FATAL_ERROR "${PCAP_TYPE} is not a valid pcap type") + endif() +endif(WIN32) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-${PCAP_TYPE}.c) # @@ -274,31 +1188,54 @@ set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-${PCAP_TYPE}.c) # if we support capturing. Don't bother if we don't support # capturing. # -if( NOT WIN32 ) +if(NOT WIN32) # # UN*X - figure out what type of interface list mechanism we # have. # - if( ${PCAP_TYPE} STREQUAL "null" ) - # - # We can't capture, so we can't open any capture - # devices, so we won't return any interfaces. - # - set( FINDALLDEVS_TYPE null ) - else() - check_function_exists( getifaddrs HAVE_GETIFADDRS ) - if( ${HAVE_GETIFADDRS} ) + # If the capture type is null, that means we can't capture, + # so we can't open any capture devices, so we won't return + # any interfaces. + # + if(NOT PCAP_TYPE STREQUAL "null") + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) + check_function_exists(getifaddrs HAVE_GETIFADDRS) + cmake_pop_check_state() + if(NOT HAVE_GETIFADDRS) + # + # It's not in the libraries that, at this point, we've + # found we need to link libpcap with. + # + # It's in libsocket on Solaris and possibly other OSes; + # as long as we're not linking with libxnet, check there. + # + # NOTE: if you hand check_library_exists as its last + # argument a variable that's been set, it skips the test, + # so we need different variables. + # + if(NOT LIBXNET_HAS_GETHOSTBYNAME) + check_library_exists(socket getifaddrs "" SOCKET_HAS_GETIFADDRS) + if(SOCKET_HAS_GETIFADDRS) + set(PCAP_LINK_LIBRARIES socket ${PCAP_LINK_LIBRARIES}) + set(HAVE_GETIFADDRS TRUE) + endif() + endif() + endif() + if(HAVE_GETIFADDRS) # # We have "getifaddrs()"; make sure we have # as well, just in case some platform is really weird. + # It may require that sys/types.h be included first, + # so include it first. # - check_include_file( ifaddrs.h HAVE_IFADDRS_H ) - if( ${HAVE_IFADDRS_H} ) + check_include_files("sys/types.h;ifaddrs.h" HAVE_IFADDRS_H) + if(HAVE_IFADDRS_H) # # We have the header, so we use "getifaddrs()" to # get the list of interfaces. # - set( FINDALLDEVS_TYPE getad ) + set(FINDALLDEVS_TYPE getad) else() # # We don't have the header - give up. @@ -309,60 +1246,491 @@ if( NOT WIN32 ) # but without "ifaddrs.h", if there is something # we can do on those systems. # - message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable ." ) + message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable .") endif() else() # - # Well, we don't have "getifaddrs()", so we have to use - # some other mechanism; determine what that mechanism is. + # Well, we don't have "getifaddrs()", at least not with the + # libraries with which we've decided we need to link + # libpcap with, so we have to use some other mechanism. # - # The first thing we use is the type of capture mechanism, - # which is somewhat of a proxy for the OS we're using. + # Note that this may happen on Solaris, which has + # getifaddrs(), but in -lsocket, not in -lxnet, so we + # won't find it if we link with -lxnet, which we want + # to do for other reasons. # - if( ${PCAP_TYPE} STREQUAL "dlpi" OR ${PCAP_TYPE} STREQUAL "libdlpi" ) - # - # This might be Solaris 8 or later, with - # SIOCGLIFCONF, or it might be some other OS - # or some older version of Solaris, with - # just SIOCGIFCONF. - # - try_compile( HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/config/have_siocglifconf.c" ) - message( STATUS "HAVE_SIOCGLIFCONF = ${HAVE_SIOCGLIFCONF}" ) - if( HAVE_SIOCGLIFCONF ) - set( FINDALLDEVS_TYPE glifc ) - else() - set( FINDALLDEVS_TYPE gifc ) - endif() + # For now, we use either the SIOCGIFCONF ioctl or the + # SIOCGLIFCONF ioctl, preferring the latter if we have + # it; the latter is a Solarisism that first appeared + # in Solaris 8. (Solaris's getifaddrs() appears to + # be built atop SIOCGLIFCONF; using it directly + # avoids a not-all-that-useful middleman.) + # + try_compile(HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/cmake/have_siocglifconf.c" ) + if(HAVE_SIOCGLIFCONF) + set(FINDALLDEVS_TYPE glifc) else() + set(FINDALLDEVS_TYPE gifc) + endif() + endif() + message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}") + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c) + endif() +endif() + +# Check for hardware timestamp support. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + check_include_file(linux/net_tstamp.h HAVE_LINUX_NET_TSTAMP_H) +endif() + +# +# Check for additional native sniffing capabilities. +# + +# Check for USB sniffing support on Linux. +# On FreeBSD, it uses BPF, so we don't need to do anything special here. +if(NOT DISABLE_USB) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(PCAP_SUPPORT_USB 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 . + # + check_include_files("linux/compiler.h" HAVE_LINUX_COMPILER_H) + if(HAVE_LINUX_COMPILER_H) + # + # Yes - include it when testing for . + # + check_include_files("linux/compiler.h;linux/usbdevice_fs.h" HAVE_LINUX_USBDEVICE_FS_H) + else(HAVE_LINUX_COMPILER_H) + check_include_files("linux/usbdevice_fs.h" HAVE_LINUX_USBDEVICE_FS_H) + endif(HAVE_LINUX_COMPILER_H) + if(HAVE_LINUX_USBDEVICE_FS_H) + # + # OK, does it define bRequestType? Older versions of the kernel + # define fields with names like "requesttype, "request", and + # "value", rather than "bRequestType", "bRequest", and + # "wValue". + # + if(HAVE_LINUX_COMPILER_H) + check_struct_has_member("struct usbdevfs_ctrltransfer" bRequestType "linux/compiler.h;linux/usbdevice_fs.h" HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE) + else(HAVE_LINUX_COMPILER_H) + check_struct_has_member("struct usbdevfs_ctrltransfer" bRequestType "linux/usbdevice_fs.h" HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE) + endif(HAVE_LINUX_COMPILER_H) + endif() + endif() +endif() + +# Check for netfilter sniffing support. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # + # Life's too short to deal with trying to get this to compile + # if you don't get the right types defined with + # __KERNEL_STRICT_NAMES getting defined by some other include. + # + # Check whether the includes Just Work. If not, don't turn on + # netfilter support. + # + check_c_source_compiles( +"#include +#include +#include + +#include +#include +#include +#include +#include + +int +main(void) +{ + return 0; +} +" + PCAP_SUPPORT_NETFILTER) + if(PCAP_SUPPORT_NETFILTER) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-netfilter-linux.c) + endif(PCAP_SUPPORT_NETFILTER) +endif() + +# Check for netmap sniffing support. +if(NOT DISABLE_NETMAP) + # + # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is + # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS + # is defined, for example, as it includes a non-existent malloc.h + # header. + # + check_c_source_compiles( +"#define NETMAP_WITH_LIBS +#include + +int +main(void) +{ + return 0; +} +" + PCAP_SUPPORT_NETMAP) + if(PCAP_SUPPORT_NETMAP) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-netmap.c) + endif(PCAP_SUPPORT_NETMAP) +endif() + +# Check for Bluetooth sniffing support +if(NOT DISABLE_BLUETOOTH) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + check_include_file(bluetooth/bluetooth.h HAVE_BLUETOOTH_BLUETOOTH_H) + if(HAVE_BLUETOOTH_BLUETOOTH_H) + set(PCAP_SUPPORT_BT TRUE) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-bt-linux.c) + # + # OK, does struct sockaddr_hci have an hci_channel + # member? + # + check_struct_has_member("struct sockaddr_hci" hci_channel "bluetooth/bluetooth.h;bluetooth/hci.h" HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL) + if(HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL) # - # Assume we just have SIOCGIFCONF. - # (XXX - on at least later Linux kernels, there's - # another mechanism, and we should be using that - # instead.) + # OK, is HCI_CHANNEL_MONITOR defined? # - set( FINDALLDEVS_TYPE gifc ) + check_c_source_compiles( +"#include +#include + +int +main(void) +{ + u_int i = HCI_CHANNEL_MONITOR; + return 0; +} +" + PCAP_SUPPORT_BT_MONITOR) + if(PCAP_SUPPORT_BT_MONITOR) + # + # Yes, so we can also support Bluetooth monitor + # sniffing. + # + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-bt-monitor-linux.c) + endif(PCAP_SUPPORT_BT_MONITOR) + endif(HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL) + endif(HAVE_BLUETOOTH_BLUETOOTH_H) + endif() +endif() + +# Check for Bluetooth sniffing support +if(NOT DISABLE_DBUS) + # + # We don't support D-Bus sniffing on macOS; see + # + # https://bugs.freedesktop.org/show_bug.cgi?id=74029 + # + if(APPLE) + message(FATAL_ERROR "Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS") + endif(APPLE) + include(FindPkgConfig) + pkg_check_modules(DBUS dbus-1) + if(DBUS_FOUND) + set(PCAP_SUPPORT_DBUS TRUE) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dbus.c) + include_directories(${DBUS_INCLUDE_DIRS}) + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DBUS_LIBRARIES}) + 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) + 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}) + endif(PCAP_SUPPORT_RDMASNIFF) + endif(HAVE_INFINIBAND_VERBS_H) + endif(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) +endif(NOT DISABLE_RDMA) + +# +# Check for sniffing capabilities using third-party APIs. +# + +# Check for Endace DAG card support. +if(NOT DISABLE_DAG) + # + # Try to find the DAG header file and library. + # + find_package(DAG) + + # + # Did we succeed? + # + if(DAG_FOUND) + # + # Yes. + # Check for various DAG API functions. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${DAG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${DAG_LIBRARIES}) + check_function_exists(dag_attach_stream HAVE_DAG_STREAMS_API) + if(NOT HAVE_DAG_STREAMS_API) + message(FATAL_ERROR "DAG library lacks streams support") + endif() + check_function_exists(dag_attach_stream64 HAVE_DAG_LARGE_STREAMS_API) + check_function_exists(dag_get_erf_types HAVE_DAG_GET_ERF_TYPES) + check_function_exists(dag_get_stream_erf_types HAVE_DAG_GET_STREAM_ERF_TYPES) + cmake_pop_check_state() + + include_directories(AFTER ${DAG_INCLUDE_DIRS}) + 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}) + + 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}) endif() endif() endif() - message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}") - set( PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c ) endif() -file(GLOB PROJECT_SOURCE_LIST_CORE_H +# Check for Septel card support. +set(PROJECT_EXTERNAL_OBJECT_LIST "") +if(NOT DISABLE_SEPTEL) + # + # Do we have the msg.h header? + # + set(SEPTEL_INCLUDE_DIRS "${SEPTEL_ROOT}/INC") + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${SEPTEL_INCLUDE_DIRS}) + check_include_file(msg.h HAVE_INC_MSG_H) + cmake_pop_check_state() + if(HAVE_INC_MSG_H) + # + # Yes. + # + include_directories(AFTER ${SEPTEL_INCLUDE_DIRS}) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-septel.c) + set(PROJECT_EXTERNAL_OBJECT_LIST ${PROJECT_EXTERNAL_OBJECT_LIST} "${SEPTEL_ROOT}/asciibin.o ${SEPTEL_ROOT}/bit2byte.o ${SEPTEL_ROOT}/confirm.o ${SEPTEL_ROOT}/fmtmsg.o ${SEPTEL_ROOT}/gct_unix.o ${SEPTEL_ROOT}/hqueue.o ${SEPTEL_ROOT}/ident.o ${SEPTEL_ROOT}/mem.o ${SEPTEL_ROOT}/pack.o ${SEPTEL_ROOT}/parse.o ${SEPTEL_ROOT}/pool.o ${SEPTEL_ROOT}/sdlsig.o ${SEPTEL_ROOT}/strtonum.o ${SEPTEL_ROOT}/timer.o ${SEPTEL_ROOT}/trace.o") + set(HAVE_SEPTEL_API TRUE) + endif() +endif() + +# Check for Myricom SNF support. +if(NOT DISABLE_SNF) + # + # Try to find the SNF header file and library. + # + find_package(SNF) + + # + # Did we succeed? + # + if(SNF_FOUND) + # + # Yes. + # + include_directories(AFTER ${SNF_INCLUDE_DIRS}) + 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}) + endif() +endif() + +# Check for Riverbed TurboCap support. +if(NOT DISABLE_TC) + # + # Try to find the TurboCap header file and library. + # + find_package(TC) + + # + # Did we succeed? + # + if(TC_FOUND) + # + # Yes. + # + include_directories(AFTER ${TC_INCLUDE_DIRS}) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-tc.c) + set(HAVE_TC_API TRUE) + set(PCAP_LINK_LIBRARIES "${PCAP_LINK_LIBRARIES} ${TC_LIBRARIES} ${CMAKE_USE_PTHREADS_INIT} stdc++") + endif() +endif() + +# +# Remote capture support. +# + +if(ENABLE_REMOTE) + # + # Check for various members of struct msghdr. + # We need to include ftmacros.h on some platforms, to make sure we + # get the POSIX/Single USER Specification version of struct msghdr, + # which has those members, rather than the backwards-compatible + # version, which doesn't. That's not a system header file, and + # at least some versions of CMake include it as , which + # won't check the current directory, so we add the top-level + # source directory to the list of include directories when we do + # the check. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR}) + check_struct_has_member("struct msghdr" msg_control "ftmacros.h;sys/socket.h" HAVE_STRUCT_MSGHDR_MSG_CONTROL) + check_struct_has_member("struct msghdr" msg_flags "ftmacros.h;sys/socket.h" HAVE_STRUCT_MSGHDR_MSG_FLAGS) + cmake_pop_check_state() + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} + pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c) +endif(ENABLE_REMOTE) + +################################################################### +# Warning options +################################################################### + +# +# Check and add warning options if we have a .devel file. +# +if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel) + # + # Warning options. + # + if(MSVC AND NOT ${CMAKE_C_COMPILER} MATCHES "clang*") + # + # MSVC, with Microsoft's front end and code generator. + # "MSVC" is also set for Microsoft's compiler with a Clang + # front end and their code generator ("Clang/C2"), so we + # check for clang.exe and treat that differently. + # + check_and_add_compiler_option(-Wall) + # + # Disable some pointless warnings that /Wall turns on. + # + # Unfortunately, MSVC does not appear to have an equivalent + # to "__attribute__((unused))" to mark a particular function + # parameter as being known to be unused, so that the compiler + # won't warn about it (for example, the function might have + # that parameter because a pointer to it is being used, and + # the signature of that function includes that parameter). + # C++ lets you give a parameter a type but no name, but C + # doesn't have that. + # + check_and_add_compiler_option(-wd4100) + # + # In theory, we care whether somebody uses f() rather than + # f(void) to declare a function with no arguments, but, in + # practice, there are places in the Windows header files + # that appear to do that, so we squelch that warning. + # + check_and_add_compiler_option(-wd4255) + # + # Windows FD_SET() generates this, so we suppress it. + # + check_and_add_compiler_option(-wd4548) + # + # Perhaps testing something #defined to be 0 with #ifdef is an + # error, and it should be tested with #if, but perhaps it's + # not, and Microsoft does that in its headers, so we squelch + # that warning. + # + check_and_add_compiler_option(-wd4574) + # + # The Windows headers also test not-defined values in #if, so + # we don't want warnings about that, either. + # + check_and_add_compiler_option(-wd4668) + # + # We do *not* care whether some function is, or isn't, going to be + # expanded inline. + # + check_and_add_compiler_option(-wd4710) + check_and_add_compiler_option(-wd4711) + # + # We do *not* care whether we're adding padding bytes after + # structure members. + # + check_and_add_compiler_option(-wd4820) + else() + # + # Other compilers, including MSVC with a Clang front end and + # Microsoft's code generator. We currently treat them as if + # they might support GCC-style -W options. + # + check_and_add_compiler_option(-Wall) + check_and_add_compiler_option(-Wsign-compare) + check_and_add_compiler_option(-Wmissing-prototypes) + check_and_add_compiler_option(-Wstrict-prototypes) + check_and_add_compiler_option(-Wshadow) + check_and_add_compiler_option(-Wdeclaration-after-statement) + check_and_add_compiler_option(-Wused-but-marked-unused) + check_and_add_compiler_option(-Wdocumentation) + check_and_add_compiler_option(-Wcomma) + check_and_add_compiler_option(-Wmissing-noreturn) + # Warns about safeguards added in case the enums are extended + # check_and_add_compiler_option(-Wcovered-switch-default) + check_and_add_compiler_option(-Wmissing-variable-declarations) + check_and_add_compiler_option(-Wunused-parameter) + check_and_add_compiler_option(-Wformat-nonliteral) + check_and_add_compiler_option(-Wunreachable-code) + endif() +endif() + +# +# Suppress some warnings we get with MSVC even without /Wall. +# +if(MSVC AND NOT ${CMAKE_C_COMPILER} MATCHES "clang*") + # + # Yes, we have some functions that never return but that + # have a non-void return type. That's because, on some + # platforms, they *do* return values but, on other + # platforms, including Windows, they just fail and + # longjmp out by calling bpf_error(). + # + check_and_add_compiler_option(-wd4646) +endif() + +file(GLOB PROJECT_SOURCE_LIST_H *.h pcap/*.h ) -set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_CORE_H} ) - -if( WIN32 ) - file(GLOB PROJECT_SOURCE_LIST_WIN32_H - Win32/Include/*.h - ) - set( PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${PROJECT_SOURCE_LIST_WIN32_H} ) -endif( WIN32 ) # -# {Flex} and YACC/Berkeley YACC/Bison. +# Try to have the compiler default to hiding symbols, so that only +# symbols explicitly exported with PCAP_API will be visible outside +# (shared) libraries. +# +# Not necessary with MSVC, as that's the default. +# +# XXX - we don't use ADD_COMPILER_EXPORT_FLAGS, because, as of CMake +# 2.8.12.2, it doesn't know about Sun C/Oracle Studio, and, as of +# CMake 2.8.6, it only sets the C++ compiler flags, rather than +# allowing an arbitrary variable to be set with the "hide symbols +# not explicitly exported" flag. +# +if(NOT MSVC) + if(CMAKE_C_COMPILER_ID MATCHES "SunPro") + # + # Sun C/Oracle Studio. + # + check_and_add_compiler_option(-xldscope=hidden) + else() + # + # Try this for all other compilers; it's what GCC uses, + # and a number of other compilers, such as Clang and Intel C, + # use it as well. + # + check_and_add_compiler_option(-fvisibility=hidden) + endif() +endif(NOT MSVC) + +# +# Flex/Lex and YACC/Berkeley YACC/Bison. # From a mail message to the CMake mailing list by Andy Cedilnik of # Kitware. # @@ -371,8 +1739,8 @@ endif( WIN32 ) # Try to find Flex, a Windows version of Flex, or Lex. # find_program(LEX_EXECUTABLE NAMES flex win_flex lex) -if( ${LEX_EXECUTABLE} STREQUAL "LEX_EXECUTABLE-NOTFOUND" ) - message(FATAL_ERROR "Neither flex nor win_flex nor lex was found." ) +if(LEX_EXECUTABLE STREQUAL "LEX_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Neither flex nor win_flex nor lex was found.") endif() message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}") @@ -391,7 +1759,7 @@ add_custom_command( # set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES GENERATED TRUE - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h + OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/grammar.h ) # @@ -403,19 +1771,19 @@ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES # Try to find YACC or Bison. # find_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc) -if( ${YACC_EXECUTABLE} STREQUAL "YACC_EXECUTABLE-NOTFOUND" ) - message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found." ) +if(YACC_EXECUTABLE STREQUAL "YACC_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found.") endif() message(STATUS "Parser generator: ${YACC_EXECUTABLE}") # # Create custom command for the scanner. -# Find out whether it's Bison or notby looking at the last component +# Find out whether it's Bison or not by looking at the last component # of the path (without a .exe extension, if this is Windows). # get_filename_component(YACC_NAME ${YACC_EXECUTABLE} NAME_WE) -if( "${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison" ) - set( YACC_COMPATIBILITY_FLAG "-y" ) +if("${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison") + set(YACC_COMPATIBILITY_FLAG "-y") endif() add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h @@ -430,6 +1798,7 @@ add_custom_command( # set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES GENERATED TRUE + OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h ) # @@ -437,84 +1806,491 @@ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES # #set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c) -if( WIN32 ) - # - # CMake does not love Windows. - # - file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/GenVersion.bat" GenVersion_path) - file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/VERSION" VERSION_path) - file(TO_NATIVE_PATH "${pcap_SOURCE_DIR}/pcap_version.h.in" version_h_in_path) - file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h" version_h_path) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h - SOURCE ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in - COMMAND ${GenVersion_path} ${VERSION_path} ${version_h_in_path} ${version_h_path} - DEPENDS ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in - ) -else( WIN32 ) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.c - SOURCE ${pcap_SOURCE_DIR}/VERSION - COMMAND ${pcap_SOURCE_DIR}/gen_version_c.sh ${pcap_SOURCE_DIR}/VERSION ${CMAKE_CURRENT_BINARY_DIR}/version.c - DEPENDS ${pcap_SOURCE_DIR}/VERSION - ) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h - SOURCE ${pcap_SOURCE_DIR}/VERSION - COMMAND ${pcap_SOURCE_DIR}/gen_version_header.sh ${pcap_SOURCE_DIR}/VERSION ${pcap_SOURCE_DIR}/pcap_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h - DEPENDS ${pcap_SOURCE_DIR}/VERSION - ) +# +# Assume, by default, no support for shared libraries and V7/BSD +# convention for man pages (file formats in section 5, miscellaneous +# info in section 7, administrative commands and daemons in section 8). +# Individual cases can override this. +# +set(MAN_FILE_FORMATS 5) +set(MAN_MISC_INFO 7) +set(MAN_ADMIN_COMMANDS 8) +if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + # Workaround to enable certain features + set(_SUN TRUE) + if(PCAP_TYPE STREQUAL "bpf") + # + # If we're using BPF, we need libodm and libcfg, as + # we use them to load the BPF module. + # + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} odm cfg) + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") + if(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*9\.[0-9]*") + # + # HP-UX 9.x. + # + set(HAVE_HPUX9 TRUE) + elseif(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*10\.0") + # + # HP-UX 10.0. + # + elseif(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*10\.1") + # + # HP-UX 10.1. + # + else() + # + # HP-UX 10.20 and later. + # + set(HAVE_HPUX10_20_OR_LATER TRUE) + endif() # - # Since version.c does not exists yet when cmake is run, mark - # it as generated. + # Use System V conventions for man pages. # - set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c PROPERTIES - GENERATED TRUE - ) - + set(MAN_ADMIN_COMMANDS 1m) + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) +elseif(CMAKE_SYSTEM_NAME STREQUAL "IRIX" OR CMAKE_SYSTEM_NAME STREQUAL "IRIX64") # - # Add version.c to the list of sources. + # Use IRIX conventions for man pages; they're the same as the + # System V conventions, except that they use section 8 for + # administrative commands and daemons. # - set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/version.c) -endif( WIN32 ) + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) +elseif(CMAKE_SYSTEM_NAME STREQUAL "OSF1") + # + # DEC OSF/1, a/k/a Digial 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. + # + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) +elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") + # + # SunOS 5.x. + # + set(HAVE_SOLARIS TRUE) + # + # Make sure errno is thread-safe, in case we're called in + # a multithreaded program. We don't guarantee that two + # threads can use the *same* pcap_t safely, but the + # current version does guarantee that you can use different + # pcap_t's in different threads, and even that pcap_compile() + # is thread-safe (it wasn't thread-safe in some older versions). + # + add_definitions(-D_TS_ERRNO) -# -# Since pcap_version.h does not exists yet when cmake is run, mark -# it as generated. -# -set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h PROPERTIES - GENERATED TRUE -) - -# -# Add pcap_version.h to the list of headers. -# -set(PROJECT_SOURCE_LIST_H ${PROJECT_SOURCE_LIST_H} ${CMAKE_CURRENT_BINARY_DIR}/pcap_version.h) + if(CMAKE_SYSTEM_VERSION STREQUAL "5.12") + else() + # + # Use System V conventions for man pages. + # + set(MAN_ADMIN_COMMANDS 1m) + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) + endif() +endif() source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C}) source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H}) +if(WIN32) + # + # Add pcap-dll.rc to the list of sources. + # + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${pcap_SOURCE_DIR}/pcap-dll.rc) +endif(WIN32) + +# +# Add subdirectories after we've set various variables, so they pick up +# pick up those variables. +# +if(ENABLE_REMOTE) + add_subdirectory(rpcapd) +endif(ENABLE_REMOTE) +add_subdirectory(testprogs) + ###################################### # Register targets ###################################### -add_library(${LIBRARY_NAME} +# +# Special target to serialize the building of the generated source. +# +# See +# +# http://public.kitware.com/pipermail/cmake/2013-August/055510.html +# +add_custom_target(SerializeTarget + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/grammar.c + ${CMAKE_CURRENT_BINARY_DIR}/scanner.c +) + +set_source_files_properties(${PROJECT_EXTERNAL_OBJECT_LIST} PROPERTIES + EXTERNAL_OBJECT TRUE) + +if(BUILD_SHARED_LIBS) + add_library(${LIBRARY_NAME} SHARED + ${PROJECT_SOURCE_LIST_C} + ${CMAKE_CURRENT_BINARY_DIR}/grammar.c + ${CMAKE_CURRENT_BINARY_DIR}/scanner.c + ${PROJECT_EXTERNAL_OBJECT_LIST} + ) + add_dependencies(${LIBRARY_NAME} SerializeTarget) + set_target_properties(${LIBRARY_NAME} PROPERTIES + COMPILE_DEFINITIONS BUILDING_PCAP) +endif(BUILD_SHARED_LIBS) + +add_library(${LIBRARY_NAME}_static STATIC ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.c - ${PROJECT_SOURCE_LIST_H} + ${PROJECT_EXTERNAL_OBJECT_LIST} ) +add_dependencies(${LIBRARY_NAME}_static SerializeTarget) +set_target_properties(${LIBRARY_NAME}_static PROPERTIES + COMPILE_DEFINITIONS BUILDING_PCAP) -if( WIN32 ) - target_link_libraries ( ${LIBRARY_NAME} - packet - ws2_32 +if(WIN32) + if(BUILD_SHARED_LIBS) + set_target_properties(${LIBRARY_NAME} PROPERTIES + VERSION ${PACKAGE_VERSION_NOSUFFIX} # only MAJOR and MINOR are needed + ) + endif(BUILD_SHARED_LIBS) + if(MSVC) + # XXX For DLLs, the TARGET_PDB_FILE generator expression can be used to locate + # its PDB file's output directory for installation. + # cmake doesn't offer a generator expression for PDB files generated by the + # compiler (static libraries). + # So instead of considering any possible output there is (there are many), + # this will search for the PDB file in the compiler's initial output directory, + # which is always ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles\wpcap_static.dir + # regardless of architecture, build generator etc. + # Quite hackish indeed. + set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY $) + set_target_properties(${LIBRARY_NAME}_static PROPERTIES + COMPILE_PDB_NAME ${LIBRARY_NAME}_static + OUTPUT_NAME "${LIBRARY_NAME}_static" + ) + elseif(MINGW) + # + # For compatibility, build the shared library without the "lib" prefix on + # MinGW as well. + # + set_target_properties(${LIBRARY_NAME} PROPERTIES + PREFIX "" + OUTPUT_NAME "${LIBRARY_NAME}" + ) + set_target_properties(${LIBRARY_NAME}_static PROPERTIES + OUTPUT_NAME "${LIBRARY_NAME}" + ) + endif() +else(WIN32) # UN*X + if(BUILD_SHARED_LIBS) + if(APPLE) + set_target_properties(${LIBRARY_NAME} PROPERTIES + VERSION ${PACKAGE_VERSION} + SOVERSION A + ) + else(APPLE) + set_target_properties(${LIBRARY_NAME} PROPERTIES + VERSION ${PACKAGE_VERSION} + SOVERSION ${PACKAGE_VERSION_MAJOR} + ) + endif(APPLE) + endif(BUILD_SHARED_LIBS) + set_target_properties(${LIBRARY_NAME}_static PROPERTIES + OUTPUT_NAME "${LIBRARY_NAME}" ) -endif( WIN32 ) +endif(WIN32) + +if(BUILD_SHARED_LIBS) + if(NOT C_ADDITIONAL_FLAGS STREQUAL "") + set_target_properties(${LIBRARY_NAME} PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) + endif() + target_link_libraries(${LIBRARY_NAME} ${PCAP_LINK_LIBRARIES}) +endif(BUILD_SHARED_LIBS) + +if(NOT C_ADDITIONAL_FLAGS STREQUAL "") + set_target_properties(${LIBRARY_NAME}_static PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) +endif() ###################################### # Write out the config.h file ###################################### configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) + +###################################### +# Install pcap library, include files, and man pages +###################################### + +# +# "Define GNU standard installation directories", which actually +# are also defined, to some degree, by autotools, and at least +# some of which are general UN*X conventions. +# +include(GNUInstallDirs) + +set(LIBRARY_NAME_STATIC ${LIBRARY_NAME}_static) + +function(install_manpage_symlink SOURCE TARGET MANDIR) + if(MINGW) + find_program(LINK_EXECUTABLE ln) + if(LINK_EXECUTABLE) + set(LINK_COMMAND "\"${LINK_EXECUTABLE}\" \"-s\" \"${SOURCE}\" \"${TARGET}\"") + else(LINK_EXECUTABLE) + message(FATAL_ERROR "ln (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ln.html) not found.") + endif(LINK_EXECUTABLE) + else(MINGW) + set(LINK_COMMAND "\"${CMAKE_COMMAND}\" \"-E\" \"create_symlink\" \"${SOURCE}\" \"${TARGET}\"") + endif(MINGW) + + install(CODE + "message(STATUS \"Symlinking: ${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\") + execute_process( + COMMAND \"${CMAKE_COMMAND}\" \"-E\" \"remove\" \"${TARGET}\" + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${MANDIR} + ) + execute_process( + COMMAND ${LINK_COMMAND} + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${MANDIR} + RESULT_VARIABLE EXIT_STATUS + ) + if(NOT EXIT_STATUS EQUAL 0) + message(FATAL_ERROR \"Could not create symbolic link from ${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\") + endif() + set(CMAKE_INSTALL_MANIFEST_FILES \${CMAKE_INSTALL_MANIFEST_FILES} ${CMAKE_INSTALL_PREFIX}/${MANDIR}/${TARGET})") +endfunction(install_manpage_symlink) + +set(MAN1_NOEXPAND pcap-config.1) +set(MAN3PCAP_EXPAND + pcap.3pcap.in + pcap_compile.3pcap.in + pcap_datalink.3pcap.in + pcap_dump_open.3pcap.in + pcap_get_tstamp_precision.3pcap.in + pcap_list_datalinks.3pcap.in + pcap_list_tstamp_types.3pcap.in + pcap_open_dead.3pcap.in + pcap_open_offline.3pcap.in + pcap_set_tstamp_precision.3pcap.in + pcap_set_tstamp_type.3pcap.in +) +set(MAN3PCAP_NOEXPAND + pcap_activate.3pcap + pcap_breakloop.3pcap + pcap_can_set_rfmon.3pcap + pcap_close.3pcap + pcap_create.3pcap + pcap_datalink_name_to_val.3pcap + pcap_datalink_val_to_name.3pcap + pcap_dump.3pcap + pcap_dump_close.3pcap + pcap_dump_file.3pcap + pcap_dump_flush.3pcap + pcap_dump_ftell.3pcap + pcap_file.3pcap + pcap_fileno.3pcap + pcap_findalldevs.3pcap + pcap_freecode.3pcap + pcap_get_required_select_timeout.3pcap + pcap_get_selectable_fd.3pcap + pcap_geterr.3pcap + pcap_inject.3pcap + pcap_is_swapped.3pcap + pcap_lib_version.3pcap + pcap_lookupdev.3pcap + pcap_lookupnet.3pcap + pcap_loop.3pcap + pcap_major_version.3pcap + pcap_next_ex.3pcap + pcap_offline_filter.3pcap + pcap_open_live.3pcap + pcap_set_buffer_size.3pcap + pcap_set_datalink.3pcap + pcap_set_immediate_mode.3pcap + pcap_set_promisc.3pcap + pcap_set_protocol_linux.3pcap + pcap_set_rfmon.3pcap + pcap_set_snaplen.3pcap + pcap_set_timeout.3pcap + pcap_setdirection.3pcap + pcap_setfilter.3pcap + pcap_setnonblock.3pcap + pcap_snapshot.3pcap + pcap_stats.3pcap + pcap_statustostr.3pcap + pcap_strerror.3pcap + pcap_tstamp_type_name_to_val.3pcap + pcap_tstamp_type_val_to_name.3pcap +) +set(MANFILE_EXPAND pcap-savefile.manfile.in) +set(MANMISC_EXPAND + pcap-filter.manmisc.in + pcap-linktype.manmisc.in + pcap-tstamp.manmisc.in +) + +if(NOT BUILD_SHARED_LIBS) + unset(LIBRARY_NAME) +endif(NOT BUILD_SHARED_LIBS) + +if(WIN32) + if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) + # + # Install 64-bit code built with MSVC in the amd64 subdirectories, + # as that's where it expects it to be. + # + install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} + RUNTIME DESTINATION bin/amd64 + LIBRARY DESTINATION lib/amd64 + ARCHIVE DESTINATION lib/amd64) + if(NOT MINGW) + install(FILES $/${LIBRARY_NAME_STATIC}.pdb + DESTINATION bin/amd64 OPTIONAL) + if(BUILD_SHARED_LIBS) + install(FILES $ + DESTINATION bin/amd64 OPTIONAL) + endif(BUILD_SHARED_LIBS) + endif(NOT MINGW) + else(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) + # + # Install 32-bit code, and 64-bit code not built with MSVC + # in the top-level directories, as those are where they + # expect it to be. + # + install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + if(NOT MINGW) + install(FILES $/${LIBRARY_NAME_STATIC}.pdb + DESTINATION bin OPTIONAL) + if(BUILD_SHARED_LIBS) + install(FILES $ + DESTINATION bin OPTIONAL) + endif(BUILD_SHARED_LIBS) + endif(NOT MINGW) + endif(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) +else(WIN32) + install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} DESTINATION lib) +endif(WIN32) + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pcap/ DESTINATION include/pcap) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap.h DESTINATION include) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap-bpf.h DESTINATION include) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap-namedb.h DESTINATION include) + +# On UN*X, and on Windows when not using MSVC, generate libpcap.pc and +# pcap-config and process man pages and arrange that they be installed. +if(NOT MSVC) + set(PACKAGE_NAME ${LIBRARY_NAME}) + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix "\${prefix}") + set(includedir "\${prefix}/include") + set(libdir "\${exec_prefix}/lib") + 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 "") + endif() + set(LIBS "") + foreach(LIB ${PCAP_LINK_LIBRARIES}) + set(LIBS "${LIBS} -l${LIB}") + endforeach(LIB) + configure_file(${CMAKE_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY) + configure_file(${CMAKE_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pcap-config DESTINATION bin) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc DESTINATION lib/pkgconfig) + + # + # Man pages. + # + # For each section of the manual for which we have man pages + # that require macro expansion, do the expansion. + # + set(MAN1 "") + foreach(MANPAGE ${MAN1_NOEXPAND}) + set(MAN1 ${MAN1} ${CMAKE_SOURCE_DIR}/${MANPAGE}) + endforeach(MANPAGE) + install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) + + set(MAN3PCAP "") + foreach(MANPAGE ${MAN3PCAP_NOEXPAND}) + set(MAN3PCAP ${MAN3PCAP} ${CMAKE_SOURCE_DIR}/${MANPAGE}) + endforeach(MANPAGE) + foreach(TEMPLATE_MANPAGE ${MAN3PCAP_EXPAND}) + string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE}) + configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) + set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) + endforeach(TEMPLATE_MANPAGE) + install(FILES ${MAN3PCAP} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_dump_open.3pcap pcap_dump_fopen.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_findalldevs.3pcap pcap_freealldevs.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_geterr.3pcap pcap_perror.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_inject.3pcap pcap_sendpacket.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_loop.3pcap pcap_dispatch.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_major_version.3pcap pcap_minor_version.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_next_ex.3pcap pcap_next.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_dead.3pcap pcap_open_dead_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_setnonblock.3pcap pcap_getnonblock.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + + set(MANFILE "") + foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND}) + string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE}) + configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) + set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) + endforeach(TEMPLATE_MANPAGE) + install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS}) + + set(MANMISC "") + foreach(TEMPLATE_MANPAGE ${MANMISC_EXPAND}) + string(REPLACE ".manmisc.in" ".${MAN_MISC_INFO}" MANPAGE ${TEMPLATE_MANPAGE}) + configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) + set(MANMISC ${MANMISC} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) + endforeach(TEMPLATE_MANPAGE) + install(FILES ${MANMISC} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_MISC_INFO}) +endif(NOT MSVC) + +# uninstall target +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) diff --git a/libpcap/CONTRIBUTING.md b/libpcap/CONTRIBUTING.md new file mode 100644 index 000000000..69b597260 --- /dev/null +++ b/libpcap/CONTRIBUTING.md @@ -0,0 +1,29 @@ +Guidelines for contributing +=========================== + +To report a security issue (segfault, buffer overflow, infinite loop, arbitrary +code execution etc) please send an e-mail to security@tcpdump.org, do not use +the bug tracker! + +To report a non-security problem (failure to compile, failure to capture packets +properly, missing support for a network interface type or DLT) please check +first that it reproduces with the latest stable release of libpcap. If it does, +please check that the problem reproduces with the current git master branch of +libpcap. If it does (and it is not a security-related problem, otherwise see +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) +* 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 +* statement of the problem +* steps to reproduce + +Please note that if you know exactly how to solve the problem and the solution +would not be too intrusive, it would be best to contribute some development time +and open a pull request instead. + +Still not sure how to do? Feel free to [subscribe](https://www.tcpdump.org/#mailing-lists) +to the mailing list tcpdump-workers@lists.tcpdump.org and ask! diff --git a/libpcap/CREDITS b/libpcap/CREDITS index b40152f5e..8b7e7ce89 100644 --- a/libpcap/CREDITS +++ b/libpcap/CREDITS @@ -1,21 +1,18 @@ -This file lists people who have contributed to libpcap: +This file lists people who have contributed to libpcap. -The current maintainers: - Bill Fenner +The current maintainers (in alphabetical order): Denis Ovsienko - Fulvio Risso + Francois-Xavier Le Bail Guy Harris - Hannes Gredler Michael Richardson - Francois-Xavier Le Bail - -Additional people who have contributed patches: +Additional people who have contributed patches (in alphabetical order): Akos Vandra Alan Bawden Albert Chin Alexander 'Leo' Bergolth Alexey Kuznetsov + Ali Abdulkadir Alon Bar-Lev Andres Perera Andrew Brown @@ -62,9 +59,10 @@ Additional people who have contributed patches: Gabor Tatarka Garrett Cooper George Neville-Neil + Gerard Garcia Gianluca Varenni Gilbert Hoyek - Gisle Vanem + Gisle Vanem Graeme Hewson Gregor Maier Greg Stark @@ -99,6 +97,7 @@ Additional people who have contributed patches: Koryn Grant Kris Katterjohn Krzysztof Halasa + Lennert Buytenhek Lorenzo Cavallaro Loris Degioanni Love Hörnquist-Åstrand @@ -114,6 +113,7 @@ Additional people who have contributed patches: Márton Németh Matthew Luckie Max Laier + Michal Kubecek Michal Labedzki Michal Sekletar Mike Frysinger @@ -129,7 +129,7 @@ Additional people who have contributed patches: Olaf Kirch Ollie Wild Onno van der Linden - Paolo Abeni + Paolo Abeni and redhat dot com Patrick Marie Patrick McHardy Paul Mundt @@ -145,6 +145,8 @@ Additional people who have contributed patches: Rick Jones Robert Edmonds Roberto Mariani + Rongxi Li + Roland Dreier Romain Francoise Sagun Shakya Scott Barron @@ -167,6 +169,7 @@ Additional people who have contributed patches: Wesley Shields Xianjie Zhang Xin Li + Xue Jiang Qing Yen Yen Lim Yoann Vandoorselaere Yvan Vanhullebus @@ -176,5 +179,8 @@ The original LBL crew: Craig Leres Van Jacobson -Past maintainers: - Jun-ichiro itojun Hagino Also see: http://www.wide.ad.jp/itojun-award/ +Past maintainers (in alphabetical order): + Bill Fenner + Fulvio Risso + Hannes Gredler + Jun-ichiro itojun Hagino Also see: http://www.wide.ad.jp/itojun-award/ diff --git a/libpcap/GenVersion.bat b/libpcap/GenVersion.bat deleted file mode 100644 index babf3737e..000000000 --- a/libpcap/GenVersion.bat +++ /dev/null @@ -1,23 +0,0 @@ -REM -REM Automatically generate pcap_version.h based on pcap_version.h.in -REM for Windows -REM The version string comes from VERSION -REM @echo off -REM - -setlocal enableextensions disabledelayedexpansion - -set "search=%%%%LIBPCAP_VERSION%%%%" -set /p replace=<%1 - -if exist %3 del %3 2>nul - -for /f "delims=" %%i in ('type %2' ) do ( - set "line=%%i" - setlocal enabledelayedexpansion - set "line=!line:%search%=%replace%!" - >>%3 echo(!line! - endlocal -) - -echo pcap_version.h generated diff --git a/libpcap/INSTALL.txt b/libpcap/INSTALL.md similarity index 90% rename from libpcap/INSTALL.txt rename to libpcap/INSTALL.md index f305aa2b7..96c87a2ce 100644 --- a/libpcap/INSTALL.txt +++ b/libpcap/INSTALL.md @@ -69,10 +69,6 @@ before /usr/ucb or else: before running configure. (You might have to do a "make distclean" if you already ran configure once). -Also note that "make depend" won't work; while all of the known -universe uses -M, the SPARCompiler uses -xM to generate makefile -dependencies. - 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 @@ -250,43 +246,27 @@ libpcap program and it dies with: You must add streams NIT support to your kernel configuration, run config and boot the new kernel. -If you are running a version of SunOS earlier than 4.1, you will need -to replace the Sun supplied /sys/sun{3,4,4c}/OBJ/nit_if.o with the -appropriate version from this distribution's SUNOS4 subdirectory and -build a new kernel: - - nit_if.o.sun3-sunos4 (any flavor of sun3) - nit_if.o.sun4c-sunos4.0.3c (SS1, SS1+, IPC, SLC, etc.) - nit_if.o.sun4-sunos4 (Sun4's not covered by - nit_if.o.sun4c-sunos4.0.3c) - -These nit replacements fix a bug that makes nit essentially unusable in -pre-SunOS 4.1. In addition, our sun4c-sunos4.0.3c nit gives you -timestamps to the resolution of the SS-1 clock (1 us) rather than the -lousy 20ms timestamps Sun gives you (tcpdump will print out the full -timestamp resolution if it finds it's running on a SS-1). - FILES ----- CHANGES - description of differences between releases -ChmodBPF/* - Mac OS X startup item to set ownership and permissions +ChmodBPF/* - macOS startup item to set ownership and permissions on /dev/bpf* CMakeLists.txt - CMake file +CONTRIBUTING - guidelines for contributing CREDITS - people that have helped libpcap along -INSTALL.txt - this file +INSTALL.md - this file LICENSE - the license under which tcpdump is distributed Makefile.in - compilation rules (input to the configure script) -README - description of distribution -README.aix - notes on using libpcap on AIX -README.dag - notes on using libpcap to capture on Endace DAG devices -README.hpux - notes on using libpcap on HP-UX -README.linux - notes on using libpcap on Linux -README.macosx - notes on using libpcap on Mac OS X -README.septel - notes on using libpcap to capture on Intel/Septel devices -README.sita - notes on using libpcap to capture on SITA devices -README.tru64 - notes on using libpcap on Digital/Tru64 UNIX -README.Win32 - notes on using libpcap on Win32 systems (with WinPcap) -SUNOS4 - pre-SunOS 4.1 replacement kernel nit modules +README.md - description of distribution +doc/README.aix - notes on using libpcap on AIX +doc/README.dag - notes on using libpcap to capture on Endace DAG devices +doc/README.hpux - notes on using libpcap on HP-UX +doc/README.linux.md - notes on using libpcap on Linux +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.Win32 - notes on using libpcap on Win32 systems (with WinPcap) VERSION - version of this release acconfig.h - support for post-2.13 autoconf aclocal.m4 - autoconf macros @@ -314,7 +294,6 @@ gencode.c - BPF code generation routines gencode.h - BPF code generation definitions grammar.y - filter string grammar ieee80211.h - 802.11 definitions -inet.c - network routines install-sh - BSD style install script lbl/os-*.h - OS-dependent defines and prototypes llc.h - 802.2 LLC SAP definitions @@ -347,6 +326,7 @@ 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 - WinPcap 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 @@ -360,7 +340,6 @@ 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 pcap-usb-linux.h - USB capture support for Linux -pcap-win32.c - WinPcap capture support pcap.3pcap - manual entry for the library pcap.c - pcap utility routines pcap.h - header for backwards compatibility diff --git a/libpcap/Makefile.in b/libpcap/Makefile.in index 81d962225..dff75ec12 100644 --- a/libpcap/Makefile.in +++ b/libpcap/Makefile.in @@ -27,6 +27,8 @@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ # Pathname of directory to install the configure program bindir = @bindir@ +# Pathname of directory to install the rpcapd daemon +sbindir = @sbindir@ # Pathname of directory to install the include files includedir = @includedir@ # Pathname of directory to install the library @@ -48,8 +50,9 @@ AR = @AR@ LN_S = @LN_S@ MKDEP = @MKDEP@ CCOPT = @V_CCOPT@ +SHLIB_CCOPT = @V_SHLIB_CCOPT@ INCLS = -I. @V_INCLS@ -DEFS = -DBUILDING_PCAP @DEFS@ @V_DEFS@ +DEFS = -DBUILDING_PCAP -Dpcap_EXPORTS @DEFS@ @V_DEFS@ ADDLOBJS = @ADDLOBJS@ ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@ LIBS = @LIBS@ @@ -60,15 +63,22 @@ DYEXT = @DYEXT@ V_RPATH_OPT = @V_RPATH_OPT@ 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 -FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) +# Standard CFLAGS for building members of a shared library +FULL_CFLAGS = $(CCOPT) $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS) INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ +LEX = @LEX@ +YACC = @YACC@ + # Explicitly define compilation rule since SunOS 4's make doesn't like gcc. # Also, gcc does not remove the .o before forking 'as', which can be a # problem if you don't own the file but can write to the directory. @@ -76,13 +86,14 @@ RANLIB = @RANLIB@ @rm -f $@ $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c -PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ +PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ @NETMAP_SRC@ @RDMA_SRC@ FSRC = @V_FINDALLDEVS@ SSRC = @SSRC@ -CSRC = pcap.c inet.c fad-helpers.c gencode.c optimize.c nametoaddr.c \ - etherent.c savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \ - bpf_image.c bpf_dump.c -GENSRC = scanner.c grammar.c bpf_filter.c version.c +CSRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \ + fmtutils.c \ + savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \ + bpf_image.c bpf_filter.c bpf_dump.c +GENSRC = scanner.c grammar.c LIBOBJS = @LIBOBJS@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC) @@ -97,8 +108,10 @@ PUBHDR = \ pcap/bpf.h \ pcap/bluetooth.h \ pcap/can_socketcan.h \ + pcap/compiler-tests.h \ pcap/dlt.h \ - pcap/export-defs.h \ + pcap/funcattrs.h \ + pcap/pcap-inttypes.h \ pcap/ipnet.h \ pcap/namedb.h \ pcap/nflog.h \ @@ -110,51 +123,38 @@ PUBHDR = \ HDR = $(PUBHDR) \ arcnet.h \ atmuni31.h \ + diag-control.h \ ethertype.h \ extract.h \ + fmtutils.h \ + ftmacros.h \ gencode.h \ ieee80211.h \ llc.h \ nametoaddr.h \ nlpid.h \ + optimize.h \ pcap-common.h \ pcap-int.h \ - pcap-stdinc.h \ + pcap-rpcap.h \ + pcap-types.h \ portability.h \ ppp.h \ + rpcap-protocol.h \ sf-pcap.h \ - sf-pcap-ng.h \ - sunatmpos.h - -TESTS = \ - @VALGRINDTEST@ \ - capturetest \ - can_set_rfmon_test \ - filtertest \ - findalldevstest \ - opentest \ - reactivatetest \ - selpolltest - -TESTS_SRC = \ - tests/valgrindtest.c \ - tests/capturetest.c \ - tests/can_set_rfmon_test.c \ - tests/filtertest.c \ - tests/findalldevstest.c \ - tests/opentest.c \ - tests/reactivatetest.c \ - tests/selpolltest.c + sf-pcapng.h \ + sunatmpos.h \ + varattrs.h GENHDR = \ - scanner.h grammar.h pcap_version.h + scanner.h grammar.h TAGFILES = \ $(SRC) $(HDR) -CLEANFILES = $(OBJ) libpcap.* $(TESTS) \ - $(PROG)-`cat $(srcdir)/VERSION`.tar.gz \ - lex.yy.c pcap-config +CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \ + $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ + lex.yy.c pcap-config libpcap.pc MAN1 = pcap-config.1 @@ -188,6 +188,7 @@ MAN3PCAP_NOEXPAND = \ pcap_fileno.3pcap \ pcap_findalldevs.3pcap \ pcap_freecode.3pcap \ + pcap_get_required_select_timeout.3pcap \ pcap_get_selectable_fd.3pcap \ pcap_geterr.3pcap \ pcap_inject.3pcap \ @@ -204,6 +205,7 @@ MAN3PCAP_NOEXPAND = \ pcap_set_datalink.3pcap \ pcap_set_immediate_mode.3pcap \ pcap_set_promisc.3pcap \ + pcap_set_protocol_linux.3pcap \ pcap_set_rfmon.3pcap \ pcap_set_snaplen.3pcap \ pcap_set_timeout.3pcap \ @@ -228,38 +230,31 @@ MANMISC = \ pcap-tstamp.manmisc.in EXTRA_DIST = \ - $(TESTS_SRC) \ CHANGES \ ChmodBPF/ChmodBPF \ ChmodBPF/StartupParameters.plist \ CREDITS \ CMakeLists.txt \ - GenVersion.bat \ - INSTALL.txt \ + INSTALL.md \ LICENSE \ Makefile.in \ Makefile-devel-adds \ - README \ - README.aix \ - README.dag \ - README.hpux \ - README.linux \ - README.macosx \ - README.septel \ - README.sita \ - README.tru64 \ - README.Win32 \ - SUNOS4/nit_if.o.sparc \ - SUNOS4/nit_if.o.sun3 \ - SUNOS4/nit_if.o.sun4c.4.0.3c \ + README.md \ + doc \ + CONTRIBUTING.md \ TODO \ VERSION \ aclocal.m4 \ - bpf/net/bpf_filter.c \ chmod_bpf \ + cmake_uninstall.cmake.in \ cmakeconfig.h.in \ - cmake/preconfigure.cmake \ - config/have_siocglifconf.c \ + cmake/Modules/FindDAG.cmake \ + cmake/Modules/FindFseeko.cmake \ + cmake/Modules/FindLFS.cmake \ + cmake/Modules/FindPacket.cmake \ + cmake/Modules/FindSNF.cmake \ + cmake/Modules/FindTC.cmake \ + cmake/have_siocglifconf.c \ config.guess \ config.h.in \ config.sub \ @@ -270,9 +265,6 @@ EXTRA_DIST = \ fad-getad.c \ fad-gifc.c \ fad-glifc.c \ - fad-helpers.c \ - gen_version_c.sh \ - gen_version_header.sh \ grammar.y \ install-sh \ lbl/os-aix4.h \ @@ -283,6 +275,7 @@ EXTRA_DIST = \ lbl/os-solaris2.h \ lbl/os-sunos4.h \ lbl/os-ultrix4.h \ + libpcap.pc.in \ missing/getopt.c \ missing/getopt.h \ missing/snprintf.c \ @@ -290,18 +283,15 @@ EXTRA_DIST = \ missing/win_snprintf.c \ mkdep \ msdos/bin2c.c \ - msdos/common.dj \ msdos/makefile \ msdos/makefile.dj \ msdos/makefile.wc \ - msdos/ndis2.c \ - msdos/ndis2.h \ - msdos/ndis_0.asm \ msdos/pkt_rx0.asm \ msdos/pkt_rx1.s \ msdos/pktdrvr.c \ msdos/pktdrvr.h \ msdos/readme.dos \ + nomkdep \ org.tcpdump.chmod_bpf.plist \ pcap-bpf.c \ pcap-bt-linux.c \ @@ -313,6 +303,7 @@ EXTRA_DIST = \ pcap-dag.h \ pcap-dbus.c \ pcap-dbus.h \ + pcap-dll.rc \ pcap-dlpi.c \ pcap-dos.c \ pcap-dos.h \ @@ -324,11 +315,16 @@ EXTRA_DIST = \ pcap-new.c \ pcap-netfilter-linux.c \ pcap-netfilter-linux.h \ + pcap-netmap.c \ + pcap-netmap.h \ pcap-nit.c \ + pcap-npf.c \ pcap-null.c \ pcap-pf.c \ + pcap-rdmasniff.c \ + pcap-rdmasniff.h \ pcap-rpcap.c \ - pcap-rpcap.h \ + pcap-rpcap-int.h \ pcap-septel.c \ pcap-septel.h \ pcap-sita.h \ @@ -342,29 +338,48 @@ EXTRA_DIST = \ pcap-tc.h \ pcap-usb-linux.c \ pcap-usb-linux.h \ - pcap-win32.c \ - remote-ext.h \ + rpcap-protocol.c \ + rpcapd/CMakeLists.txt \ + rpcapd/Makefile.in \ + rpcapd/config_params.h \ + rpcapd/daemon.h \ + rpcapd/daemon.c \ + rpcapd/fileconf.c \ + rpcapd/fileconf.h \ + rpcapd/log.h \ + rpcapd/log-stderr.c \ + rpcapd/org.tcpdump.rpcapd.plist \ + rpcapd/rpcapd.c \ + rpcapd/rpcapd.h \ + rpcapd/rpcapd.inetd.conf \ + rpcapd/rpcapd.manadmin.in \ + rpcapd/rpcapd.rc \ + rpcapd/rpcapd.socket \ + rpcapd/rpcapd.xinetd.conf \ + rpcapd/rpcapd@.service \ + rpcapd/win32-svc.c \ + rpcapd/win32-svc.h \ sockutils.c \ sockutils.h \ scanner.l \ - tests/CMakeLists.txt \ - pcap_version.h.in \ - Win32/Include/Gnuc.h \ - Win32/Include/net/if.h \ + testprogs/CMakeLists.txt \ + testprogs/Makefile.in \ + testprogs/can_set_rfmon_test.c \ + testprogs/capturetest.c \ + testprogs/filtertest.c \ + testprogs/findalldevstest.c \ + testprogs/opentest.c \ + testprogs/reactivatetest.c \ + testprogs/selpolltest.c \ + testprogs/threadsignaltest.c \ + testprogs/unix.h \ + testprogs/valgrindtest.c \ + tests/shb-option-too-long.pcapng \ Win32/Prj/wpcap.sln \ Win32/Prj/wpcap.vcxproj \ Win32/Prj/wpcap.vcxproj.filters -all: libpcap.a shared pcap-config - -# Inhibit implicit rule Make seems to have for using yacc/lex to -# recompile new scanner.c/grammar.c -- we ship ones which we want to -# use instead. -grammar.c: - echo "Not rebuilding grammar.c" - -scanner.c: - echo "Not rebuilding scanner.c" +all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config libpcap.a: $(OBJ) @rm -f $@ @@ -377,20 +392,18 @@ libpcap.so: $(OBJ) @rm -f $@ VER=`cat $(srcdir)/VERSION`; \ MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \ - @V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \ + @V_SHLIB_CMD@ $(LDFLAGS) @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER \ -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS) # # The following rule succeeds, but the result is untested. # -# In Mac OS X, the libpcap dylib has the name "libpcap.A.dylib", with -# its full path as the install_name, and with the compatibility and -# current version both set to 1. The compatibility version is set to -# 1 so that programs built with a newer version of the library will run -# against older versions; multi-platform software probably will fail if -# it uses APIs added in the newer version, but Mac OS X-specific software -# will use weak linking and check at run time whether those APIs are -# available. +# In macOS, the libpcap dylib has the name "libpcap.A.dylib", with its +# full path as the install_name, and with the compatibility and current +# version both set to 1. The compatibility version is set to 1 so that +# programs built with a newer version of the library will run against +# older versions if they don't use APIs available in the newer version +# 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, with any non-numeric @@ -440,7 +453,7 @@ libpcap.sl: $(OBJ) # libpcap.shareda: $(OBJ) @rm -f $@ shr.o - $(CC) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LDFLAGS) $(LIBS) + $(CC) $(LDFLAGS) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LIBS) $(AR) rc $@ shr.o # @@ -449,48 +462,41 @@ libpcap.shareda: $(OBJ) # libpcap.none: +scanner.c: $(srcdir)/scanner.l + $(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $< +scanner.h: scanner.c +## Recover from the removal of $@ + @if test -f $@; then :; else \ + rm -f scanner.c; \ + $(MAKE) $(MAKEFLAGS) scanner.c; \ + fi + scanner.o: scanner.c grammar.h $(CC) $(FULL_CFLAGS) -c scanner.c -pcap.o: pcap_version.h +grammar.c: $(srcdir)/grammar.y + $(YACC) -p pcap_ -o grammar.c -d $< +grammar.h: grammar.c +## Recover from the removal of $@ + @if test -f $@; then :; else \ + rm -f grammar.c; \ + $(MAKE) $(MAKEFLAGS) grammar.c; \ + fi -grammar.o: grammar.c +grammar.o: grammar.c scanner.h $(CC) $(FULL_CFLAGS) -c grammar.c gencode.o: $(srcdir)/gencode.c grammar.h scanner.h $(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c -version.o: version.c - $(CC) $(FULL_CFLAGS) -c version.c - snprintf.o: $(srcdir)/missing/snprintf.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c strtok_r.o: $(srcdir)/missing/strtok_r.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c -version.c: $(srcdir)/VERSION $(srcdir)/gen_version_c.sh - # - # Older programs import this if they want to show the - # libpcap version number, rather than calling - # pcap_lib_version(), so we need to export it. - # - @rm -f $@ - $(srcdir)/gen_version_c.sh $(srcdir)/VERSION $@ - -pcap_version.h: $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $(srcdir)/gen_version_header.sh - @rm -f $@ - $(srcdir)/gen_version_header.sh $(srcdir)/VERSION $(srcdir)/pcap_version.h.in $@ - -bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c - rm -f bpf_filter.c - ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c - -bpf_filter.o: bpf_filter.c - $(CC) $(FULL_CFLAGS) -c bpf_filter.c - # -# Generate the pcap-config script. +# Generate the libpcap.pc file. # # Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<"; # for example, the Solaris 9 make man page says @@ -501,7 +507,16 @@ bpf_filter.o: bpf_filter.c # # and this is an explicit target entry. # -# Therefore, instead of using $<, we explicitly put in $(srcdir)/pcap-config.in. +# Therefore, instead of using $<, we explicitly put in $(srcdir)/libpcap.pc.in. +# +libpcap.pc: $(srcdir)/libpcap.pc.in ./config.status + @rm -f $@ $@.tmp + ./config.status --file=$@.tmp:$(srcdir)/libpcap.pc.in + mv $@.tmp $@ + chmod a+x $@ + +# +# Generate the pcap-config script. See above. # pcap-config: $(srcdir)/pcap-config.in ./config.status @rm -f $@ $@.tmp @@ -509,36 +524,21 @@ pcap-config: $(srcdir)/pcap-config.in ./config.status mv $@.tmp $@ chmod a+x $@ +# +# Remote pcap daemon. +# +build-rpcapd: libpcap.a + cd rpcapd; $(MAKE) + # # Test programs - not built by default, and not installed. # -tests: $(TESTS) +testprogs: FORCE + cd testprogs; $(MAKE) -capturetest: tests/capturetest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS) +FORCE: -can_set_rfmon_test: tests/can_set_rfmon_test.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o can_set_rfmon_test $(srcdir)/tests/can_set_rfmon_test.c libpcap.a $(LIBS) - -filtertest: tests/filtertest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS) - -findalldevstest: tests/findalldevstest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o findalldevstest $(srcdir)/tests/findalldevstest.c libpcap.a $(LIBS) - -opentest: tests/opentest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS) - -reactivatetest: tests/reactivatetest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o reactivatetest $(srcdir)/tests/reactivatetest.c libpcap.a $(LIBS) - -selpolltest: tests/selpolltest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS) - -valgrindtest: tests/valgrindtest.c libpcap.a - $(CC) $(FULL_CFLAGS) -I. -L. -o valgrindtest $(srcdir)/tests/valgrindtest.c libpcap.a $(LIBS) - -install: install-shared install-archive pcap-config +install: install-shared install-archive libpcap.pc pcap-config @INSTALL_RPCAPD@ [ -d $(DESTDIR)$(libdir) ] || \ (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir)) [ -d $(DESTDIR)$(includedir) ] || \ @@ -559,6 +559,9 @@ install: install-shared install-archive pcap-config [ -d $(DESTDIR)$(bindir) ] || \ (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir)) $(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config + [ -d $(DESTDIR)$(libdir)/pkgconfig ] || \ + (mkdir -p $(DESTDIR)$(libdir)/pkgconfig; chmod 755 $(DESTDIR)$(libdir)/pkgconfig) + $(INSTALL_DATA) libpcap.pc $(DESTDIR)$(libdir)/pkgconfig/libpcap.pc for i in $(MAN1); do \ $(INSTALL_DATA) $(srcdir)/$$i \ $(DESTDIR)$(mandir)/man1/$$i; done @@ -659,11 +662,15 @@ install-archive-shareda: # library on AIX. # -uninstall: uninstall-shared +install-rpcapd: + cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install + +uninstall: uninstall-shared uninstall-rpcapd rm -f $(DESTDIR)$(libdir)/libpcap.a for i in $(PUBHDR); do \ rm -f $(DESTDIR)$(includedir)/$$i; done -rmdir $(DESTDIR)$(includedir)/pcap + rm -f $(DESTDIR)/$(libdir)/pkgconfig/libpcap.pc rm -f $(DESTDIR)/$(bindir)/pcap-config for i in $(MAN1); do \ rm -f $(DESTDIR)$(mandir)/man1/$$i; done @@ -711,15 +718,22 @@ uninstall-shared-shareda: rm -f $(DESTDIR)$(libdir)/libpcap.a uninstall-shared-none: +uninstall-rpcapd: + cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall + clean: rm -f $(CLEANFILES) + cd rpcapd; $(MAKE) clean + cd testprogs; $(MAKE) clean distclean: clean rm -f Makefile config.cache config.log config.status \ - config.h gnuc.h net os-proto.h bpf_filter.c pcap-config \ - stamp-h stamp-h.in + config.h gnuc.h 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 + cd testprogs; $(MAKE) distclean extags: $(TAGFILES) ctags $(TAGFILES) @@ -730,11 +744,13 @@ tags: $(TAGFILES) releasetar: @cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \ mkdir $$name; \ - tar cf - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \ + tar -c --exclude='*~' -f - $(CSRC) $(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 -depend: $(GENSRC) $(GENHDR) bpf_filter.c - $(MKDEP) -c $(CC) -m $(CFLAGS) $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC) +depend: $(GENSRC) $(GENHDR) + $(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC) + cd rpcapd; $(MAKE) depend + cd testprogs; $(MAKE) depend 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 deleted file mode 100644 index 07eafe321..000000000 --- a/libpcap/NMAP_MODIFICATIONS/0001-Don-t-autogenerate-Lex-Yacc-files.patch +++ /dev/null @@ -1,126 +0,0 @@ -From f38b1fc263d65a53746108e2c9afacf1dc6a058a Mon Sep 17 00:00:00 2001 -From: Daniel Miller -Date: Fri, 1 May 2015 14:44:28 +0000 -Subject: [PATCH 1/2] Don't autogenerate Lex/Yacc files. - ---- - libpcap/Makefile.in | 33 ++++++++++----------------------- - libpcap/configure.in | 20 -------------------- - 2 files changed, 10 insertions(+), 43 deletions(-) - -diff --git a/libpcap/Makefile.in b/libpcap/Makefile.in -index f317973..577b848 100644 ---- a/libpcap/Makefile.in -+++ b/libpcap/Makefile.in -@@ -69,14 +69,6 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ - INSTALL_DATA = @INSTALL_DATA@ - RANLIB = @RANLIB@ - --# --# Flex and bison allow you to specify the prefixes of the global symbols --# used by the generated parser. This allows programs to use lex/yacc --# and link against libpcap. If you don't have flex or bison, get them. --# --LEX = @V_LEX@ --YACC = @V_YACC@ -- - # Explicitly define compilation rule since SunOS 4's make doesn't like gcc. - # Also, gcc does not remove the .o before forking 'as', which can be a - # problem if you don't own the file but can write to the directory. -@@ -152,7 +144,7 @@ TAGFILES = \ - $(SRC) $(HDR) - - CLEANFILES = $(OBJ) libpcap.* $(TESTS) \ -- $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ -+ $(PROG)-`cat $(srcdir)/VERSION`.tar.gz \ - lex.yy.c pcap-config - - MAN1 = pcap-config.1 -@@ -360,6 +352,15 @@ EXTRA_DIST = \ - - all: libpcap.a shared pcap-config - -+# Inhibit implicit rule Make seems to have for using yacc/lex to -+# recompile new scanner.c/grammar.c -- we ship ones which we want to -+# use instead. -+grammar.c: -+ echo "Not rebuilding grammar.c" -+ -+scanner.c: -+ echo "Not rebuilding scanner.c" -+ - libpcap.a: $(OBJ) - @rm -f $@ - $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS) -@@ -443,25 +444,11 @@ libpcap.shareda: $(OBJ) - # - libpcap.none: - --scanner.c: $(srcdir)/scanner.l -- @rm -f $@ $@.bottom -- $(srcdir)/runlex.sh $(LEX) -o$@ $< -- mv $@ $@.bottom -- cat $@.top $@.bottom > $@ -- @rm $@.bottom -- - scanner.o: scanner.c tokdefs.h - $(CC) $(FULL_CFLAGS) -c scanner.c - - pcap.o: version.h - --tokdefs.h: grammar.c --grammar.c: $(srcdir)/grammar.y -- @rm -f grammar.c tokdefs.h -- $(YACC) -d $< -- mv y.tab.c grammar.c -- mv y.tab.h tokdefs.h -- - grammar.o: grammar.c - @rm -f $@ - $(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c -diff --git a/libpcap/configure.in b/libpcap/configure.in -index be4b29e..ec87283 100644 ---- a/libpcap/configure.in -+++ b/libpcap/configure.in -@@ -1051,24 +1051,6 @@ if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then - AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR) - fi - --AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_) --if test "$V_LEX" = lex ; then --# Some versions of lex can't handle the definitions section of scanner.l . --# Try lexing it and complain if it can't deal. -- AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex, -- if lex -t scanner.l > /dev/null 2>&1; then -- tcpdump_cv_capable_lex=yes -- else -- tcpdump_cv_capable_lex=insufficient -- fi) -- if test $tcpdump_cv_capable_lex = insufficient ; then -- AC_MSG_ERROR([Your operating system's lex is insufficient to compile -- libpcap. flex is a lex replacement that has many advantages, including -- being able to compile libpcap. For more information, see -- http://www.gnu.org/software/flex/flex.html .]) -- fi --fi -- - # - # Assume, by default, no support for shared libraries and V7/BSD convention - # for man pages (file formats in section 5, miscellaneous info in section 7). -@@ -1351,13 +1333,11 @@ AC_SUBST(V_CCOPT) - AC_SUBST(V_DEFS) - AC_SUBST(V_FINDALLDEVS) - AC_SUBST(V_INCLS) --AC_SUBST(V_LEX) - AC_SUBST(V_PCAP) - 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(SSRC) --- -1.9.1 - diff --git a/libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch b/libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch deleted file mode 100644 index 8ec65265c..000000000 --- a/libpcap/NMAP_MODIFICATIONS/0002-Disable-unnecessary-features.patch +++ /dev/null @@ -1,174 +0,0 @@ -From 7a42932439162be1f263986cdc7bbef78840a71a Mon Sep 17 00:00:00 2001 -From: Daniel Miller -Date: Fri, 1 May 2015 14:53:42 +0000 -Subject: [PATCH 2/2] Disable unnecessary features - -The following features are disabled: - -* monitor-mode sniffing of wireless interfaces on Linux, via libnl -* building shared libraries -* Bluetooth support -* canusb support -* CAN support -* dbus capture support ---- - libpcap/configure.ac | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -diff --git a/libpcap/configure.ac b/libpcap/configure.ac -index ec87283..ad2e437 100644 ---- a/libpcap/configure.ac -+++ b/libpcap/configure.ac -@@ -450,10 +450,10 @@ linux) - # Do we have libnl? - # - 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@:>@]), - with_libnl=$withval,,) - -- if test x$with_libnl != xno ; then -+ if test x$with_libnl = xyes ; then - have_any_nl="no" - - incdir=-I/usr/include/libnl3 -@@ -1301,8 +1301,8 @@ solaris*) - esac - - AC_ARG_ENABLE(shared, --AC_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@:>@])) -+test "x$enable_shared" != "xyes" && DYEXT="none" - - AC_PROG_RANLIB - AC_CHECK_TOOL([AR], [ar]) -@@ -1457,9 +1457,9 @@ AC_SUBST(PCAP_SUPPORT_NETFILTER) - AC_SUBST(NETFILTER_SRC) - - 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@:>@])], - [], -- [enable_bluetooth=ifsupportavailable]) -+ [enable_bluetooth=no]) - - if test "x$enable_bluetooth" != "xno" ; then - dnl check for Bluetooth sniffing support -@@ -1536,9 +1536,9 @@ if test "x$enable_bluetooth" != "xno" ; then - fi - - AC_ARG_ENABLE([canusb], --[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])], -+[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=no@:>@])], - [], -- [enable_canusb=ifsupportavailable]) -+ [enable_canusb=no]) - - if test "x$enable_canusb" != "xno" ; then - dnl check for canusb support -@@ -1582,9 +1582,9 @@ if test "x$enable_canusb" != "xno" ; then - fi - - AC_ARG_ENABLE([can], --[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])], -+[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=no@:>@])], - [], -- [enable_can=ifsupportavailable]) -+ [enable_can=no]) - - if test "x$enable_can" != "xno" ; then - dnl check for CAN sniffing support -@@ -1619,9 +1619,9 @@ if test "x$enable_can" != "xno" ; then - 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@:>@])], - [], -- [enable_dbus=ifavailable]) -+ [enable_dbus=no]) - - if test "x$enable_dbus" != "xno"; then - if test "x$enable_dbus" = "xyes"; then --- -1.9.1 - -commit e79d124eed3951184e812ea95609a0cefb855b01 -Author: Daniel Miller -Date: Tue Jul 17 19:36:10 2018 +0000 - - libpcap: Disable unnecessary features - - The following features are disabled: - - * monitor-mode sniffing of wireless interfaces on Linux, via libnl - * building shared libraries - * Bluetooth support - * usb support - * dbus capture support - -diff --git a/libpcap/configure.ac b/libpcap/configure.ac -index 4300866..21e2b5f 100644 ---- a/libpcap/configure.ac -+++ b/libpcap/configure.ac -@@ -485,10 +485,10 @@ linux) - # Do we have libnl? - # - 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@:>@]), - with_libnl=$withval,,) - -- if test x$with_libnl != xno ; then -+ if test x$with_libnl = xyes ; then - have_any_nl="no" - - incdir=-I/usr/include/libnl3 -@@ -1390,8 +1390,8 @@ solaris*) - esac - - AC_ARG_ENABLE(shared, --AC_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@:>@])) -+test "x$enable_shared" != "xyes" && DYEXT="none" - - AC_PROG_RANLIB - AC_CHECK_TOOL([AR], [ar]) -@@ -1429,9 +1429,9 @@ AC_SUBST(MAN_FILE_FORMATS) - AC_SUBST(MAN_MISC_INFO) - - AC_ARG_ENABLE([usb], --[AC_HELP_STRING([--enable-usb],[enable nusb support @<:@default=yes, if support available@:>@])], -+[AC_HELP_STRING([--enable-usb],[enable nusb support @<:@default=no@:>@])], - [], -- [enable_usb=yes]) -+ [enable_usb=no]) - - if test "xxx_only" = yes; then - # User requested something-else-only pcap, so they don't -@@ -1556,9 +1556,9 @@ AC_SUBST(PCAP_SUPPORT_NETFILTER) - AC_SUBST(NETFILTER_SRC) - - 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@:>@])], - [], -- [enable_bluetooth=ifsupportavailable]) -+ [enable_bluetooth=no]) - - if test "xxx_only" = yes; then - # User requested something-else-only pcap, so they don't -@@ -1641,9 +1641,9 @@ if test "x$enable_bluetooth" != "xno" ; then - 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@:>@])], - [], -- [enable_dbus=ifavailable]) -+ [enable_dbus=no]) - - if test "xxx_only" = yes; then - # User requested something-else-only pcap, so they don't diff --git a/libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE b/libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE deleted file mode 100644 index bdd4c16c1..000000000 --- a/libpcap/NMAP_MODIFICATIONS/HOWTO-UPGRADE +++ /dev/null @@ -1,25 +0,0 @@ -Download libpcap-X.Y.tar.gz from http://www.tcpdump.org/#latest-release -and verify the signature. - -cd -# Make a copy of this directory. -cp -r ~/nmap/libpcap/NMAP_MODIFICATIONS . -tar xzvf libpcap-X.Y.tar.gz -cd nmap -rsync -rv --delete ~/libpcap-X.Y/ ~/nmap/libpcap/ -git add -A libpcap -cd libpcap -./configure -make grammar.c scanner.c scanner.h -git add grammar.c scanner.c scanner.h -cd .. -# Apply patches. -git apply ~/NMAP_MODIFICATIONS/000* -# Make changes as necessary and update the patch files -cd libpcap -autoconf -cd .. -git add -u libpcap -mv ~/NMAP_MODIFICATIONS libpcap/ -git add libpcap/NMAP_MODIFICATIONS -git commit -m "Upgrade libpcap to X.Y." diff --git a/libpcap/README.Win32 b/libpcap/README.Win32 deleted file mode 100644 index 0a42dab93..000000000 --- a/libpcap/README.Win32 +++ /dev/null @@ -1,46 +0,0 @@ -Under Win32, libpcap is integrated in the WinPcap packet capture system. -WinPcap provides a framework that allows libpcap to capture the packets -under Windows 95, Windows 98, Windows ME, Windows NT 4, Windows 2000 -and Windows XP. -WinPcap binaries and source code can be found at http://winpcap.polito.it: -they include also a developer's pack with all the necessary to compile -libpcap-based applications under Windows. - -How to compile libpcap with Visual Studio ------------------------------------------ - -In order to compile libpcap you will need: - -- version 6 (or higher) of Microsoft Visual Studio -- The November 2001 (or later) edition of Microsoft Platform -Software Development Kit (SDK), that contains some necessary includes -for IPv6 support. You can download it from http://www.microsoft.com/sdk -- the latest WinPcap sources from http://winpcap.polito.it/install - -The WinPcap source code already contains a recent (usually the latest -stable) version of libpcap. If you need to compile a different one, -simply download it from www.tcpdump.org and copy the sources in the -winpcap\wpcap\libpcap folder of the WinPcap distribution. If you want to -compile a libpcap source retrieved from the tcpdump.org Git, you will -have to create the scanner and the grammar by hand (with lex and yacc) -or with the cygnus makefile, since The Visual Studio project is not able -to build them. - -Open the project file winpcap\wpcap\prj\wpcap.dsw with Visual Studio and -build wpcap.dll. wpcap.lib, the library file to link with the applications, -will be generated in winpcap\wpcap\lib\. wpcap.dll will be generated in -winpcap\wpcap\prj\release or winpcap\wpcap\prj\debug depending on the type -of binary that is being created. - -How to compile libpcap with Cygnus ----------------------------------- - -To build wpcap.dll, cd to the directory WPCAP/PRJ of the WinPcap source code -distribution and type "make". libwpcap.a, the library file to link with the -applications, will be generated in winpcap\wpcap\lib\. wpcap.dll will be -generated in winpcap\wpcap\prj. - -Remember, you CANNOT use the MSVC-generated .lib files with gcc, use -libwpcap.a instead. - -"make install" installs wpcap.dll in the Windows system folder. diff --git a/libpcap/README.aix b/libpcap/README.aix deleted file mode 100644 index 92e513ff7..000000000 --- a/libpcap/README.aix +++ /dev/null @@ -1,88 +0,0 @@ -Using BPF: - -(1) AIX 4.x's version of BPF is undocumented and somewhat unstandard; the - current BPF support code includes changes that should work around - that; it appears to compile and work on at least one AIX 4.3.3 - machine. - - Note that the BPF driver and the "/dev/bpf" devices might not exist - on your machine; AIX's tcpdump loads the driver and creates the - devices if they don't already exist. Our libpcap should do the - same, and the configure script should detect that it's on an AIX - system and choose BPF even if the devices aren't there. - - Also note that tcpdump _binary_ compiled on AIX 4 may have a problem - doing the initial loading of the BPF driver if copied to AIX 5 and - run there (GH #52). tcpdump binary natively compiled on AIX 5 should - not have this issue. - -(2) If libpcap doesn't compile on your machine when configured to use - BPF, or if the workarounds fail to make it work correctly, you - should send to tcpdump-workers@lists.tcpdump.org a detailed bug - report (if the compile fails, send us the compile error messages; - if it compiles but fails to work correctly, send us as detailed as - possible a description of the symptoms, including indications of the - network link-layer type being wrong or time stamps being wrong). - - If you fix the problems yourself, please submit a patch by forking - the branch at - - https://github.com/the-tcpdump-group/libpcap/issues - - and issuing a pull request, so we can incorporate the fixes into the - next release. - - If you don't fix the problems yourself, you can, as a workaround, - make libpcap use DLPI instead of BPF. - - This can be done by specifying the flag: - - --with-pcap=dlpi - - to the "configure" script for libpcap. - -If you use DLPI: - -(1) It is a good idea to have the latest version of the DLPI driver on - your system, since certain versions may be buggy and cause your AIX - system to crash. DLPI is included in the fileset bos.rte.tty. I - found that the DLPI driver that came with AIX 4.3.2 was buggy, and - had to upgrade to bos.rte.tty 4.3.2.4: - - lslpp -l bos.rte.tty - - bos.rte.tty 4.3.2.4 COMMITTED Base TTY Support and Commands - - Updates for AIX filesets can be obtained from: - ftp://service.software.ibm.com/aix/fixes/ - - These updates can be installed with the smit program. - -(2) After compiling libpcap, you need to make sure that the DLPI driver - is loaded. Type: - - strload -q -d dlpi - - If the result is: - - dlpi: yes - - then the DLPI driver is loaded correctly. - - If it is: - - dlpi: no - - Then you need to type: - - strload -f /etc/dlpi.conf - - Check again with strload -q -d dlpi that the dlpi driver is loaded. - - Alternatively, you can uncomment the lines for DLPI in - /etc/pse.conf and reboot the machine; this way DLPI will always - be loaded when you boot your system. - -(3) There appears to be a problem in the DLPI code in some versions of - AIX, causing a warning about DL_PROMISC_MULTI failing; this might - be responsible for DLPI not being able to capture outgoing packets. diff --git a/libpcap/README.dag b/libpcap/README.dag deleted file mode 100644 index accae7c38..000000000 --- a/libpcap/README.dag +++ /dev/null @@ -1,122 +0,0 @@ - -The following instructions apply if you have a Linux or FreeBSD platform and -want libpcap to support the DAG range of passive network monitoring cards from -Endace (http://www.endace.com, see below for further contact details). - -1) Install and build the DAG software distribution by following the -instructions supplied with that package. Current Endace customers can download -the DAG software distibution from https://www.endace.com - -2) Configure libcap. To allow the 'configure' script to locate the DAG -software distribution use the '--with-dag' option: - - ./configure --with-dag=DIR - -Where DIR is the root of the DAG software distribution, for example -/var/src/dag. If the DAG software is correctly detected 'configure' will -report: - - checking whether we have DAG API... yes - -If 'configure' reports that there is no DAG API, the directory may have been -incorrectly specified or the DAG software was not built before configuring -libpcap. - -See also the libpcap INSTALL.txt file for further libpcap configuration -options. - -Building libpcap at this stage will include support for both the native packet -capture stream (linux or bpf) and for capturing from DAG cards. To build -libpcap with only DAG support specify the capture type as 'dag' when -configuring libpcap: - - ./configure --with-dag=DIR --with-pcap=dag - -Applications built with libpcap configured in this way will only detect DAG -cards and will not capture from the native OS packet stream. - ----------------------------------------------------------------------- - -Libpcap when built for DAG cards against dag-2.5.1 or later releases: - -Timeouts are supported. pcap_dispatch() will return after to_ms milliseconds -regardless of how many packets are received. If to_ms is zero pcap_dispatch() -will block waiting for data indefinitely. - -pcap_dispatch() will block on and process a minimum of 64kB of data (before -filtering) for efficiency. This can introduce high latencies on quiet -interfaces unless a timeout value is set. The timeout expiring will override -the 64kB minimum causing pcap_dispatch() to process any available data and -return. - -pcap_setnonblock is supported. When nonblock is set, pcap_dispatch() will -check once for available data, process any data available up to count, then -return immediately. - -pcap_findalldevs() is supported, e.g. dag0, dag1... - -Some DAG cards can provide more than one 'stream' of received data. -This can be data from different physical ports, or separated by filtering -or load balancing mechanisms. Receive streams have even numbers, e.g. -dag0:0, dag0:2 etc. Specifying transmit streams for capture is not supported. - -pcap_setfilter() is supported, BPF programs run in userspace. - -pcap_setdirection() is not supported. Only received traffic is captured. -DAG cards normally do not have IP or link layer addresses assigned as -they are used to passively monitor links. - -pcap_breakloop() is supported. - -pcap_datalink() and pcap_list_datalinks() are supported. The DAG card does -not attempt to set the correct datalink type automatically where more than -one type is possible. - -pcap_stats() is supported. ps_drop is the number of packets dropped due to -RX stream buffer overflow, this count is before filters are applied (it will -include packets that would have been dropped by the filter). The RX stream -buffer size is user configurable outside libpcap, typically 16-512MB. - -pcap_get_selectable_fd() is not supported, as DAG cards do not support -poll/select methods. - -pcap_inject() and pcap_sendpacket() are not supported. - -Some DAG cards now support capturing to multiple virtual interfaces, called -streams. Capture streams have even numbers. These are available via libpcap -as separate interfaces, e.g. dag0:0, dag0:2, dag0:4 etc. dag0:0 is the same -as dag0. These are visible via pcap_findalldevs(). - -libpcap now does NOT set the card's hardware snaplen (slen). This must now be -set using the appropriate DAG coniguration program, e.g. dagthree, dagfour, -dagsix, dagconfig. This is because the snaplen is currently shared between -all of the streams. In future this may change if per-stream slen is -implemented. - -DAG cards by default capture entire packets including the L2 -CRC/FCS. If the card is not configured to discard the CRC/FCS, this -can confuse applications that use libpcap if they're not prepared for -packets to have an FCS. - -Libpcap now reads the environment variable ERF_FCS_BITS to determine -how many bits of CRC/FCS to strip from the end of the captured -frame. This defaults to 32 for use with Ethernet. If the card is -configured to strip the CRC/FCS, then set ERF_FCS_BITS=0. If used with -a HDLC/PoS/PPP/Frame Relay link with 16 bit CRC/FCS, then set -ERF_FCS_BITS=16. - -If you wish to create a pcap file that DOES contain the Ethernet FCS, -specify the environment variable ERF_DONT_STRIP_FCS. This will cause -the existing FCS to be captured into the pcap file. Note some -applications may incorrectly report capture errors or oversize packets -when reading these files. - ----------------------------------------------------------------------- - -Please submit bug reports via . - -Please also visit our Web site at: - - http://www.endace.com/ - -For more information about Endace DAG cards contact . diff --git a/libpcap/README.hpux b/libpcap/README.hpux deleted file mode 100644 index 65ecff97c..000000000 --- a/libpcap/README.hpux +++ /dev/null @@ -1,254 +0,0 @@ -For HP-UX 11i (11.11) and later, there are no known issues with -promiscuous mode under HP-UX. If you are using a earlier version of -HP-UX and cannot upgrade, please continue reading. - -HP-UX patches to fix packet capture problems - -Note that packet-capture programs such as tcpdump may, on HP-UX, not be -able to see packets sent from the machine on which they're running. -Some articles on groups.google.com discussing this are: - - http://groups.google.com/groups?selm=82ld3v%2480i%241%40mamenchi.zrz.TU-Berlin.DE - -which says: - - Newsgroups: comp.sys.hp.hpux - Subject: Re: Did someone made tcpdump working on 10.20 ? - Date: 12/08/1999 - From: Lutz Jaenicke - - In article <82ks5i$5vc$1@news1.dti.ne.jp>, mtsat - wrote: - >Hello, - > - >I downloaded and compiled tcpdump3.4 a couple of week ago. I tried to use - >it, but I can only see incoming data, never outgoing. - >Someone (raj) explained me that a patch was missing, and that this patch - >must me "patched" (poked) in order to see outbound data in promiscuous mode. - >Many things to do .... So the question is : did someone has already this - >"ready to use" PHNE_**** patch ? - - Two things: - 1. You do need a late "LAN products cumulative patch" (e.g. PHNE_18173 - for s700/10.20). - 2. You must use -echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem - You can insert this e.g. into /sbin/init.d/lan - - Best regards, - Lutz - -and - - http://groups.google.com/groups?selm=88cf4t%24p03%241%40web1.cup.hp.com - -which says: - - Newsgroups: comp.sys.hp.hpux - Subject: Re: tcpdump only shows incoming packets - Date: 02/15/2000 - From: Rick Jones - - Harald Skotnes wrote: - > I am running HPUX 11.0 on a C200 hanging on a 100Mb switch. I have - > compiled libpcap-0.4 an tcpdump-3.4 and it seems to work. But at a - > closer look I only get to see the incoming packets not the - > outgoing. I have tried tcpflow-0.12 which also uses libpcap and the - > same thing happens. Could someone please give me a hint on how to - > get this right? - - Search/Read the archives ?-) - - What you are seeing is expected, un-patched, behaviour for an HP-UX - system. On 11.00, you need to install the latest lancommon/DLPI - patches, and then the latest driver patch for the interface(s) in use. - At that point, a miracle happens and you should start seeing outbound - traffic. - -[That article also mentions the patch that appears below.] - -and - - http://groups.google.com/groups?selm=38AA973E.96BE7DF7%40cc.uit.no - -which says: - - Newsgroups: comp.sys.hp.hpux - Subject: Re: tcpdump only shows incoming packets - Date: 02/16/2000 - From: Harald Skotnes - - Rick Jones wrote: - - ... - - > What you are seeing is expected, un-patched, behaviour for an HP-UX - > system. On 11.00, you need to install the latest lancommon/DLPI - > patches, and then the latest driver patch for the interface(s) in - > use. At that point, a miracle happens and you should start seeing - > outbound traffic. - - Thanks a lot. I have this problem on several machines running HPUX - 10.20 and 11.00. The machines where patched up before y2k so did not - know what to think. Anyway I have now installed PHNE_19766, - PHNE_19826, PHNE_20008, PHNE_20735 on the C200 and now I can see the - outbound traffic too. Thanks again. - -(although those patches may not be the ones to install - there may be -later patches). - -And another message to tcpdump-workers@tcpdump.org, from Rick Jones: - - Date: Mon, 29 Apr 2002 15:59:55 -0700 - From: Rick Jones - To: tcpdump-workers@tcpdump.org - Subject: Re: [tcpdump-workers] I Can't Capture the Outbound Traffic - - ... - - http://itrc.hp.com/ would be one place to start in a search for the most - up-to-date patches for DLPI and the lan driver(s) used on your system (I - cannot guess because 9000/800 is too generic - one hs to use the "model" - command these days and/or an ioscan command (see manpage) to guess what - the drivers (btlan[3456], gelan, etc) might be involved in addition to - DLPI. - - Another option is to upgrade to 11i as outbound promiscuous mode support - is there in the base OS, no patches required. - -Another posting: - - http://groups.google.com/groups?selm=7d6gvn%24b3%241%40ocean.cup.hp.com - -indicates that you need to install the optional STREAMS product to do -captures on HP-UX 9.x: - - Newsgroups: comp.sys.hp.hpux - Subject: Re: tcpdump HP/UX 9.x - Date: 03/22/1999 - From: Rick Jones - - Dave Barr (barr@cis.ohio-state.edu) wrote: - : Has anyone ported tcpdump (or something similar) to HP/UX 9.x? - - I'm reasonably confident that any port of tcpdump to 9.X would require - the (then optional) STREAMS product. This would bring DLPI, which is - what one uses to access interfaces in promiscuous mode. - - I'm not sure that HP even sells the 9.X STREAMS product any longer, - since HP-UX 9.X is off the pricelist (well, maybe 9.10 for the old 68K - devices). - - Your best bet is to be up on 10.20 or better if that is at all - possible. If your hardware is supported by it, I'd go with HP-UX 11. - If you want to see the system's own outbound traffic, you'll never get - that functionality on 9.X, but it might happen at some point for 10.20 - and 11.X. - - rick jones - -(as per other messages cited here, the ability to see the system's own -outbound traffic did happen). - -Rick Jones reports that HP-UX 11i needs no patches for outbound -promiscuous mode support. - -An additional note, from Jost Martin, for HP-UX 10.20: - - Q: How do I get ethereral on HPUX to capture the _outgoing_ packets - of an interface - A: You need to get PHNE_20892,PHNE_20725 and PHCO_10947 (or - newer, this is as of 4.4.00) and its dependencies. Then you can - enable the feature as descibed below: - - Patch Name: PHNE_20892 - Patch Description: s700 10.20 PCI 100Base-T cumulative patch - To trace the outbound packets, please do the following - to turn on a global promiscuous switch before running - the promiscuous applications like snoop or tcpdump: - - adb -w /stand/vmunix /dev/mem - lanc_outbound_promisc_flag/W 1 - (adb will echo the result showing that the flag has - been changed) - $quit - (Thanks for this part to HP-support, Ratingen) - - The attached hack does this and some security-related stuff - (thanks to hildeb@www.stahl.bau.tu-bs.de (Ralf Hildebrandt) who - posted the security-part some time ago) - - <> - - (Don't switch IP-forwarding off, if you need it !) - Install the hack as /sbin/init.d/hacl_ip_stack (adjust - permissions !) and make a sequencing-symlink - /sbin/rc2.d/S350hack_ip_stack pointing to this script. - Now all this is done on every reboot. - -According to Rick Jones, the global promiscuous switch also has to be -turned on for HP-UX 11.00, but not for 11i - and, in fact, the switch -doesn't even exist on 11i. - -Here's the "hack_ip_stack" script: - ------------------------------------Cut Here------------------------------------- -#!/sbin/sh -# -# nettune: hack kernel parms for safety - -OKAY=0 -ERROR=-1 - -# /usr/contrib/bin fuer nettune auf Pfad -PATH=/sbin:/usr/sbin:/usr/bin:/usr/contrib/bin -export PATH - - -########## -# main # -########## - -case $1 in - start_msg) - print "Tune IP-Stack for security" - exit $OKAY - ;; - - stop_msg) - print "This action is not applicable" - exit $OKAY - ;; - - stop) - exit $OKAY - ;; - - start) - ;; # fall through - - *) - print "USAGE: $0 {start_msg | stop_msg | start | stop}" >&2 - exit $ERROR - ;; - esac - -########### -# start # -########### - -# -# tcp-Sequence-Numbers nicht mehr inkrementieren sondern random -# Syn-Flood-Protection an -# ip_forwarding aus -# Source-Routing aus -# Ausgehende Packets an ethereal/tcpdump etc. - -/usr/contrib/bin/nettune -s tcp_random_seq 2 || exit $ERROR -/usr/contrib/bin/nettune -s hp_syn_protect 1 || exit $ERROR -/usr/contrib/bin/nettune -s ip_forwarding 0 || exit $ERROR -echo 'ip_block_source_routed/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem || exit $ERROR -echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem || exit $ERROR - -exit $OKAY ------------------------------------Cut Here------------------------------------- diff --git a/libpcap/README.linux b/libpcap/README.linux deleted file mode 100644 index ffcb9288c..000000000 --- a/libpcap/README.linux +++ /dev/null @@ -1,108 +0,0 @@ -In order for libpcap to be able to capture packets on a Linux system, -the "packet" protocol must be supported by your kernel. If it is not, -you may get error messages such as - - modprobe: can't locate module net-pf-17 - -in "/var/adm/messages", or may get messages such as - - socket: Address family not supported by protocol - -from applications using libpcap. - -You must configure the kernel with the CONFIG_PACKET option for this -protocol; the following note is from the Linux "Configure.help" file for -the 2.0[.x] kernel: - - Packet socket - CONFIG_PACKET - The Packet protocol is used by applications which communicate - directly with network devices without an intermediate network - protocol implemented in the kernel, e.g. tcpdump. If you want them - to work, choose Y. - - This driver is also available as a module called af_packet.o ( = - code which can be inserted in and removed from the running kernel - whenever you want). If you want to compile it as a module, say M - here and read Documentation/modules.txt; if you use modprobe or - kmod, you may also want to add "alias net-pf-17 af_packet" to - /etc/modules.conf. - -and the note for the 2.2[.x] kernel says: - - Packet socket - CONFIG_PACKET - The Packet protocol is used by applications which communicate - directly with network devices without an intermediate network - protocol implemented in the kernel, e.g. tcpdump. If you want them - to work, choose Y. This driver is also available as a module called - af_packet.o ( = code which can be inserted in and removed from the - running kernel whenever you want). If you want to compile it as a - module, say M here and read Documentation/modules.txt. You will - need to add 'alias net-pf-17 af_packet' to your /etc/conf.modules - file for the module version to function automatically. If unsure, - say Y. - -In addition, there is an option that, in 2.2 and later kernels, will -allow packet capture filters specified to programs such as tcpdump to be -executed in the kernel, so that packets that don't pass the filter won't -be copied from the kernel to the program, rather than having all packets -copied to the program and libpcap doing the filtering in user mode. - -Copying packets from the kernel to the program consumes a significant -amount of CPU, so filtering in the kernel can reduce the overhead of -capturing packets if a filter has been specified that discards a -significant number of packets. (If no filter is specified, it makes no -difference whether the filtering isn't performed in the kernel or isn't -performed in user mode. :-)) - -The option for this is the CONFIG_FILTER option; the "Configure.help" -file says: - - Socket filtering - CONFIG_FILTER - The Linux Socket Filter is derived from the Berkeley Packet Filter. - If you say Y here, user-space programs can attach a filter to any - socket and thereby tell the kernel that it should allow or disallow - certain types of data to get through the socket. Linux Socket - Filtering works on all socket types except TCP for now. See the text - file linux/Documentation/networking/filter.txt for more information. - If unsure, say N. - -Note that, by default, libpcap will, if libnl is present, build with it; -it uses libnl to support monitor mode on mac80211 devices. There is a -configuration option to disable building with libnl, but, if that option -is chosen, the monitor-mode APIs (as used by tcpdump's "-I" flag, and as -will probably be used by other applications in the future) won't work -properly on mac80211 devices. - -Linux's run-time linker allows shared libraries to be linked with other -shared libraries, which means that if an older version of a shared -library doesn't require routines from some other shared library, and a -later version of the shared library does require those routines, the -later version of the shared library can be linked with that other shared -library and, if it's otherwise binary-compatible with the older version, -can replace that older version without breaking applications built with -the older version, and without breaking configure scripts or the build -procedure for applications whose configure script doesn't use the -pcap-config script if they build with the shared library. (The build -procedure for applications whose configure scripts use the pcap-config -script if present will not break even if they build with the static -library.) - -Statistics: -Statistics reported by pcap are platform specific. The statistics -reported by pcap_stats on Linux are as follows: - -2.2.x -===== -ps_recv Number of packets that were accepted by the pcap filter -ps_drop Always 0, this statistic is not gatherd on this platform - -2.4.x -===== -ps_recv Number of packets that were accepted by the pcap filter -ps_drop Number of packets that had passed filtering but were not - passed on to pcap due to things like buffer shortage, etc. - This is useful because these are packets you are interested in - but won't be reported by, for example, tcpdump output. diff --git a/libpcap/README.macosx b/libpcap/README.macosx deleted file mode 100644 index 3dc921171..000000000 --- a/libpcap/README.macosx +++ /dev/null @@ -1,74 +0,0 @@ -As with other systems using BPF, Mac OS X allows users with read access -to the BPF devices to capture packets with libpcap and allows users with -write access to the BPF devices to send packets with libpcap. - -On some systems that use BPF, the BPF devices live on the root file -system, and the permissions and/or ownership on those devices can be -changed to give users other than root permission to read or write those -devices. - -On newer versions of FreeBSD, the BPF devices live on devfs, and devfs -can be configured to set the permissions and/or ownership of those -devices to give users other than root permission to read or write those -devices. - -On Mac OS X, the BPF devices live on devfs, but the OS X version of -devfs is based on an older (non-default) FreeBSD devfs, and that version -of devfs cannot be configured to set the permissions and/or ownership of -those devices. - -Therefore, we supply: - - a "startup item" for older versions of Mac OS X; - - a launchd daemon for Tiger and later versions of Mac OS X; - -Both of them will change the ownership of the BPF devices so that the -"admin" group owns them, and will change the permission of the BPF -devices to rw-rw----, so that all users in the "admin" group - i.e., all -users with "Allow user to administer this computer" turned on - have -both read and write access to them. - -The startup item is in the ChmodBPF directory in the source tree. A -/Library/StartupItems directory should be created if it doesn't already -exist, and the ChmodBPF directory should be copied to the -/Library/StartupItems directory (copy the entire directory, so that -there's a /Library/StartupItems/ChmodBPF directory, containing all the -files in the source tree's ChmodBPF directory; don't copy the individual -items in that directory to /Library/StartupItems). The ChmodBPF -directory, and all files under it, must be owned by root. Installing -the files won't immediately cause the startup item to be executed; it -will be executed on the next reboot. To change the permissions before -the reboot, run - - sudo SystemStarter start ChmodBPF - -The launchd daemon is the chmod_bpf script, plus the -org.tcpdump.chmod_bpf.plist launchd plist file. chmod_bpf should be -installed in /usr/local/bin/chmod_bpf, and org.tcpdump.chmod_bpf.plist -should be installed in /Library/LaunchDaemons. chmod_bpf, and -org.tcpdump.chmod_bpf.plist, must be owned by root. Installing the -script and plist file won't immediately cause the script to be executed; -it will be executed on the next reboot. To change the permissions -before the reboot, run - - sudo /usr/local/bin/chmod_bpf - -or - - sudo launchctl load /Library/LaunchDaemons/org.tcpdump.chmod_bpf.plist - -If you want to give a particular user permission to access the BPF -devices, rather than giving all administrative users permission to -access them, you can have the ChmodBPF/ChmodBPF script change the -ownership of /dev/bpf* without changing the permissions. If you want to -give a particular user permission to read and write the BPF devices and -give the administrative users permission to read but not write the BPF -devices, you can have the script change the owner to that user, the -group to "admin", and the permissions to rw-r-----. Other possibilities -are left as an exercise for the reader. - -(NOTE: due to a bug in Snow Leopard, if you change the permissions not -to grant write permission to everybody who should be allowed to capture -traffic, non-root users who cannot open the BPF devices for writing will -not be able to capture outgoing packets.) diff --git a/libpcap/README b/libpcap/README.md similarity index 61% rename from libpcap/README rename to libpcap/README.md index 9f65948d4..78cc3c4b4 100644 --- a/libpcap/README +++ b/libpcap/README.md @@ -1,18 +1,18 @@ +To report a security issue please send an e-mail to security@tcpdump.org. + +To report bugs and other problems, contribute patches, request a +feature, provide generic feedback etc please see the file +[CONTRIBUTING](CONTRIBUTING.md) in the libpcap source tree root. + +The directory doc/ has README files about specific operating systems and +options. + LIBPCAP 1.x.y - -www.tcpdump.org - -Please send inquiries/comments/reports to: - tcpdump-workers@lists.tcpdump.org +Now maintained by "The Tcpdump Group" +https://www.tcpdump.org Anonymous Git is available via: - git clone git://bpf.tcpdump.org/libpcap - -Please submit patches by forking the branch on GitHub at - - http://github.com/the-tcpdump-group/libpcap/tree/master - -and issuing a pull request. + https://github.com/the-tcpdump-group/libpcap.git formerly from Lawrence Berkeley National Laboratory Network Research Group @@ -43,15 +43,15 @@ found at or - http://www.tcpdump.org/papers/bpf-usenix93.ps.Z + https://www.tcpdump.org/papers/bpf-usenix93.ps.Z and a gzipped version can be found at - http://www.tcpdump.org/papers/bpf-usenix93.ps.gz + https://www.tcpdump.org/papers/bpf-usenix93.ps.gz A PDF version can be found at - http://www.tcpdump.org/papers/bpf-usenix93.pdf + https://www.tcpdump.org/papers/bpf-usenix93.pdf Although most packet capture interfaces support in-kernel filtering, libpcap utilizes in-kernel filtering only for the BPF interface. @@ -62,17 +62,18 @@ 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 Mac OS X; 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 in: +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 in: - http://www.tcpdump.org/other/bpfext42.tar.Z + https://www.tcpdump.org/other/bpfext42.tar.Z -Linux, in the 2.2 kernel and later kernels, has a "Socket Filter" -mechanism that accepts BPF filters; see the README.linux file for -information on configuring that option. +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 +memory mapped receive mechanisms. +See the [README.linux](doc/README.linux.md) file for more information. Note to Linux distributions and *BSD systems that include libpcap: @@ -87,20 +88,6 @@ We've been maintaining binary compatibility between libpcap releases for quite a while; there's no reason to tie a binary linked with libpcap to a particular release of libpcap. -Problems, bugs, questions, desirable enhancements, etc. should be sent -to the address "tcpdump-workers@lists.tcpdump.org". Bugs, support -requests, and feature requests may also be submitted on the GitHub issue -tracker for libpcap at +Current versions can be found at https://www.tcpdump.org. - https://github.com/the-tcpdump-group/libpcap/issues - -Source code contributions, etc. should be sent to the email address -above or submitted by forking the branch on GitHub at - - http://github.com/the-tcpdump-group/libpcap/tree/master - -and issuing a pull request. - -Current versions can be found at www.tcpdump.org. - - - The TCPdump team + - The TCPdump group diff --git a/libpcap/README.septel b/libpcap/README.septel deleted file mode 100644 index 483de6a7f..000000000 --- a/libpcap/README.septel +++ /dev/null @@ -1,50 +0,0 @@ -The following instructions apply if you have a Linux platform and want -libpcap to support the Septel range of passive network monitoring cards -from Intel (http://www.intel.com) - -1) Install and build the Septel software distribution by following the -instructions supplied with that package. - -2) Configure libcap. To allow the 'configure' script to locate the Septel -software distribution use the '--with-septel' option: - - ./configure --with-septel=DIR - -where DIR is the root of the Septel software distribution, for example -/var/src/septel. - -By default (if you write only ./configure --with-septel) it takes -./../septel as argument for DIR. - -If the Septel software is correctly detected 'configure' will -report: - - checking whether we have Septel API... yes - -If 'configure' reports that there is no Septel API, the directory may have been -incorrectly specified or the Septel software was not built before configuring -libpcap. - -See also the libpcap INSTALL.txt file for further libpcap configuration -options. - -Building libpcap at this stage will include support for both the native -packet capture stream and for capturing from Septel cards. To build -libpcap with only Septel support specify the capture type as 'septel' -when configuring libpcap: - - ./configure --with-septel=DIR --with-pcap=septel - -Applications built with libpcap configured in this way will only detect Septel -cards and will not capture from the native OS packet stream. - -Note: As mentioned in pcap-septel.c we should first edit the system.txt -file to change the user part example (UPE) module id to 0xdd instead of -0x2d for technical reason. So this change in system.txt is crutial and -things will go wrong if it's not done. System.txt along with config.txt -are configuration files that are edited by the user before running the -gctload program that uses these files for initialising modules and -configuring parameters. - ----------------------------------------------------------------------- -for more information please contact me : gil_hoyek@hotmail.com diff --git a/libpcap/README.sita b/libpcap/README.sita deleted file mode 100644 index 014d51d98..000000000 --- a/libpcap/README.sita +++ /dev/null @@ -1,64 +0,0 @@ -The following instructions apply if you have a Linux platform and want -libpcap to support the 'ACN' WAN/LAN router product from from SITA -(http://www.sita.aero) - -This might also work on non-Linux Unix-compatible platforms, but that -has not been tested. - -See also the libpcap INSTALL.txt file for further libpcap configuration -options. - -These additions/extensions have been made to PCAP to allow it to -capture packets from a SITA ACN device (and potentially others). - -To enable its support you need to ensure that the distribution has -a correct configure.ac file; that can be created if neccessay by -using the normal autoconf procedure of: - -aclocal -autoconf -autoheader -automake - -Then run configure with the 'sita' option: - -./configure --with-sita - -Applications built with libpcap configured in this way will only detect SITA -ACN interfaces and will not capture from the native OS packet stream. - -The SITA extension provides a remote datascope operation for capturing -both WAN and LAN protocols. It effectively splits the operation of -PCAP into two halves. The top layer performs the majority of the -work, but interfaces via a TCP session to remote agents that -provide the lower layer functionality of actual sniffing and -filtering. More detailed information regarding the functions and -inter-device protocol and naming conventions are described in detail -in 'pcap-sita.html'. - -pcap_findalldevs() reads the local system's /etc/hosts file looking -for host names that match the format of IOP type devices. ie. aaa_I_x_y -and then queries each associated IP address for a list of its WAN and -LAN devices. The local system the aggregates the lists obtained from -each IOP, sorts it, and provides it (to Wireshark et.al) as the -list of monitorable interfaces. - -Once a valid interface has been selected, pcap_open() is called -which opens a TCP session (to a well known port) on the target IOP -and tells it to start monitoring. - -All captured packets are then forwarded across that TCP session -back to the local 'top layer' for forwarding to the actual -sniffing program (wireshark...) - -Note that the DLT_SITA link-layer type includes a proprietary header -that is documented as part of the SITA dissector of Wireshark and is -also described in 'pcap-sita.html' for posterity sake. - -That header provides: -- Packet direction (in/out) (1 octet) -- Link layer hardware signal status (1 octet) -- Transmit/Receive error status (2 octets) -- Encapsulated WAN protocol ID (1 octet) - - diff --git a/libpcap/README.tru64 b/libpcap/README.tru64 deleted file mode 100644 index 2420d9e12..000000000 --- a/libpcap/README.tru64 +++ /dev/null @@ -1,49 +0,0 @@ -The following instructions are applicable to Tru64 UNIX -(formerly Digital UNIX (formerly DEC OSF/1)) version 4.0, and -probably to later versions as well; at least some options apply to -Digital UNIX 3.2 - perhaps all do. - -In order to use kernel packet filtering on this system, you have -to configure it in such a way: - -Kernel configuration --------------------- - -The packet filtering kernel option must be enabled at kernel -installation. If it was not the case, you can rebuild the kernel with -"doconfig -c" after adding the following line in the kernel -configuration file (/sys/conf/): - - option PACKETFILTER - -or use "doconfig" without any arguments to add the packet filter driver -option via the kernel option menu (see the system administration -documentation for information on how to do this). - -Device configuration --------------------- - -Devices used for packet filtering must be created thanks to -the following command (executed in the /dev directory): - - ./MAKEDEV pfilt - -Interface configuration ------------------------ - -In order to capture all packets on a network, you may want to allow -applications to put the interface on that network into "local copy" -mode, so that tcpdump can see packets sent by the host on which it's -running as well as packets received by that host, and to put the -interface into "promiscuous" mode, so that tcpdump can see packets on -the network segment not sent to the host on which it's running, by using -the pfconfig(1) command: - - pfconfig +c +p - -or allow application to put any interface into "local copy" or -"promiscuous" mode by using the command: - - pfconfig +c +p -a - -Note: all instructions given require root privileges. diff --git a/libpcap/SUNOS4/nit_if.o.sparc b/libpcap/SUNOS4/nit_if.o.sparc deleted file mode 100644 index d05073eac7666b6a880f01c53c7077581fc9fac9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5212 zcmb_gYiu0V6+Sb&o>{MVor%4P*ROI(h#ep}CUWyYrQH^UXhjR6{Xr|l&U(GZtL!V@ zbqR=8-LLsu8w31g5YWt&7SJu|GENTtGa@}B}s5QZC0`7Na z#_{w=|8=FwJ@?%2p7Wi@y)%yFlT@OHt3)(~2S0gZd<+x))sLpl_j+{AIBm&I2DQES zbzN)5!dY3Tni8W)O^`88ojVK)8>c^{s;YMwr^~@EgX(#HR-;ZEr&to>_D!#U?qEKo zeFpU&*MxjR6UwCajdjhSCuVo|Re)=UJ^wB61KkgKZL(2cKkKt>pRT`Kd9UU8)Aqyv zCCIFcVc)nW#FRz>U_0Qab6FMIX-$M&Kld-OpVQ^7eFiDa@eNIA?%KVJSYytvAN9Zd zOt1g@fBD%lz5Y-3!M?CZdb3W5l)LM?h=ySH*6M#r0y#>@dd zxD5rJXgXz859py;MF$sZJt13>*)CnXsEE)-iV;7rmt$1HeDsf2;H711=UR^|;x_ip z{I4nCrdXkhVnvJ>goK*ZbM4){C@cd9OPp`&<)i}O}Nt|~$BdO^tG(lC!X$H;cUJ<7S9-4de{LF)@V>$7`f#F+U8^udd^ zUGyroZs5_EJ#5$2-NiPbyPb7x3;qI=sxE_DfH|>#Q5KQKkjZ?Tz^j9Gms?pXgTSGls?3dNv55czptSyt1EbBO>6?QISzsS@d#E9XmJie(&6yzZ&*l z1J`CDb*w36Ixg#edw!4d2tjm%BLcdI0^SajcwsPrU*-=OI3)IG4vNIH$lV*f&1|U*Hizu106? zFvHOOwG3OUur&p)tBMKPAmdjipS6}{6 z3E1U57Gqz&4D1T9D|KdQrOv?JsB1GS-ZwbY;8M?a;Y%}4nT_`tRL67VuW=SQx9+3t zmwh6BnPcI*cG9^w+i@rVgnMGavB@>|UC?%Y08W~5MjycakDgDABd>MHs~>Y8=NFHB z3HKhq7Z&&E;Z?;7A&UEX>j~d zJL3HjbK!V#Zbms~=7D(pwOt1BdE&DK+`~9aA-?1IK3tOp*QNv9`L67k!TZEG6^o+& z&1)**o;3Mf24(awpY>T);J&uFhZ=aDxm8rb_b;E_AlsNzMf9XkNORpH${5z+KK|IY z4H>pfw&lFbs1^531a@9UTy5_-xov^{-~#OMUdR&{(8G{f{}Ri{X)E9LulXzq^4J1= z8E-heYif)Z9o|jwW%FJ_pBQ5fZ(etJ>t5cS=-24DETjtFmyCfw{-*dCXM=OV-y!W5 z;&*z+h#=k&%WMnWTi$ZGZ-ag-<7QzG??&bqLQh4xKENh9P7k&YXHlC6_7$Hl%>&1K zjWN*(f8V)?++MQIqEwX%N!Wr~iyG&ZxW%?Jf z_J-dKETS(Ni}xXOt7jX$5A~1Epcmm+n~+U^6*$*E^KC$WS{OI4nEnOD47}otZJ7ri zXGJ^Z*Zr4(XN=3a9lg@d`C;8f(re#;Ngs92Vcm_RjpJ~+L>-;|4RaFqqEqVh4cVZtl)I;I%ql{g!8aLv zhED7#*KZ~CExv`2zbNlN2|tL}{+2>4p;|Z2KlZ~8pZ}Zh`U-R#{t#>6UF<^)c+cQ_ z3_fvY{=vSk0>^wtmth>g*zTRT=hCHkdax%c?(W&wCk`Im+q-XX?;&wtzVP(0xckt- z1LFH5Iq}_eayU=KAAR<(?(*-99?PBl--aT{5dRZTX7a_9$mMgXqv>KPl`DyKu2@Rs zk}20&gedg9D@P%}=*rJ}^kW|VIil9**4Nh`B9b~B`O8JfM_n1Vq*bCWV7?3y$=aqJ z8Tbuf@@+)70Q1EM!0hqpdpCW_1tKMY`7eMe5$$3;xXAFOG`M>BYi2!kvgP>wLJ;}j zcR%zuu0nP(H-Pa?Irtk7LjDucR~d7V$lvGSum2e`V&uKoA0n!QtvevsV7u;3hjZ;Q z$cUNw*ASEPt`qy`j}WO*qC?QHEkoYz%5#wKcWkcx9PCQQ%oe z{tW8@@Z1UgXW&_%aeQ5yfQ&Wfe+}6BDWdJqll`lQkL_+9gV@ss%%`vsEIWHYjS(Sz zq_G}j!ycjtj~E;;-?{x{UfdnH9g~zf9AoAxv~Mw z%O3sft{j8@H?9nk-t}N6J@T{%^9PSy@nHVu%FOfc9{oqI9D)85S7u+IdgL3Mc**DF zhx0FmJ$n1^E$l;XrJb95CHwCBK_3W z#~{Dp%FJQHga5Thf5szk*B^L@9zL(u=l(W~ewY2Mk(|4IuUJ4=o%Be&8O zSI_dlT$%Cq-<@n7_m9uj<1Hw+;2-?>|A^#UHu3Up@xstE6d%eLOSwcgl}Y6&zIjt` z$c1e2NmowilckI+XVbaCyemJI=1bn$JM75)`FyFA&Za1yO=bp%Q!K=J%-WhKQ>CL6 z&!vm`!BUdqh4jEsqBul0qA;9?YJ(NU`;&NY0b{G58cHXJjuahaKO0RJo-Xl*^k6Op z5{}bSI(eAl!wE1e4IiO+B9qA{0nem!hk5AFXEq2IMj#F3vx#)>W)`vzY=7o(F<#0;7#Re)LL!&OroqfeaR}bon!Plb8nCfmhZKJ% zpY3$RV(7KVGq% s77(`6&&514oGN6H(o|_EHQYa(PYfgzfDH^_b1|7LrU$4eJCdRQ0D)>YZ2$lO diff --git a/libpcap/SUNOS4/nit_if.o.sun3 b/libpcap/SUNOS4/nit_if.o.sun3 deleted file mode 100644 index c393fc6ec79182d5146b988eaece342d257e893c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4267 zcmZu!eP|o!8GlZ>NV0o&E}fQ!5|Ufv8AY}wCpd{Svf;UqYN}%i=L2tyNV2RutCmix zB#!U`p8&DdC%1v8;p!wuywFHuO3&QN%o z8JX7mcW6hcb>wpRXykZeR$oyr6G@~W+1e!kTW2d)hUjtPE`6FtmKQVLcu`H9RG9MiKCAJ0L_Ag zH-&}YIdd&{W6~R_&K6h)nSh&c}=^< zQN_ARc4sRDZ)n{cc+B30Dx`*~EzvMYQmWFz1*2MR$9q(1z?Dln(Nn=xf+|VI4)#74 zrJ(DZyXsTvQx}6t2GKq66fZYJ^i%Jg?`bNDx$C^I2br^)cn7UjEowE7H+lvv)QYug zR1wiC`cn*pxk4EY{(mTW(n8|;AA_(&{(s+y#Ij&FMgNKM=( z6*^CQbY6f?4LTL*D2jP!|5;S!TK(APWV>e{`{HL`u&)m%g>&Tk37vztZH+Iw8sU}F zld_uA)E2cYV<1r^*^sBDjHdNCHLE{w*F}$;|5UP@5|@m99=))+=LlPr9=N-V=Lc`Z zHtf-VH?#6CDp!S_nJtT#F93UVtobI*czt7i%+?wkxihkp8!6>wccqX^oP9%8?x4oo zNgemkw4)QK8+UUS5EXZvwVr@FYvQDkz26VJYR0b}CffWEE30-#9Jf|YR6|DPku+zI zd>LOw;u_`J74?9Q!lO>)_5ivHYJTCF#0b|~&XRM8RG~zpc zwu0^6vS>XN=VXb`$>3eYhQ5Sbp-<}~W#KLb^)U3PiFs0tR?LNFq{YidDAwi1GMY>@ z^wyDEw7v5f`r2<2SCQ-YqFsnNAZ*%QE*R(Y8X3S1L()9+QC0JaS+K8n9D}{c|FIVl z-8B@8e8%2Q+TJmexB`1ujKTXiamu#EPq=+EJdpUV-aP_NrV~5e)9dlWX83J}90h|T zn{HpcgbuhoO*}$ZmkeL(lE9k`->8dyjJe8Uez&7?jp014dEmrH_dK;Dp>|xo9XyZT zrdq3C{Ws_PC3MT(6C{)T(j2d)P%~?mai(21(5i;q@yzHt$7gsn^7qohB)>P$cPRKc zVGcWfg6q)rIfB{v3G^%H7KG%U;ogLuiO3MXCp|kQDrIT?PV8OcJ24t1wY!IciOWX2 z7C7HNckx~$C;#YTcOc^b@D9l*FaCMF_l7Q4C^MoJaf9P-U=maVatLer3V|9?SZ@2avyi?hyS}? zV`p;3axJf!Wix-aP^;(7x>hi2^{ko86R(S1+laQLfR79L9ik2%|H+Y3f~Xr~sYuk% z68o4hT_f@jK)yv3{%pSD@cfF9-Ht#0lejj(^EVtj{$GpnCpdkW55O<>Bk&DJPvAAj zZs3PRJy;L66YXdDhO-{T@9dpCMs^RdTy^|y*+;Y$8 zk4D5i?Al{fj86-BUPyT}$o$I*uNV9dZb0mkY>eJP)ahXR9l<{Y__M$M0T1WP9(+V# z`BNS|>DUe8JJA_29|FE0@Br{tfssS{p1^?g1A*DM>mJTc59cS2e!HrFDdsu6 z_l5uXuJn<>3&4*&I{)R-^Ply33Aerd2fNa99;}L3mNCEE!OWAQg3|y#C@{}|#e>~k z4Pbu6qx0(?PS%58^Wdrne@kHY?c0tIKEx1mOY&}t5YVW$IGQ` z!8Eg_d@+yVM7dU98#sNeQmPr0u4bXBUVVL?Lh1T>O6Rg>Wr__HYGu6+6JzCayD^3}0wIXj-qq8*NpSH*h4)XM^v99&AD$(m4I(5LJe>V@1S zr8$t{)JXDWzzH~@SMzy033`6q&Wcb{u5dh+!uUkCHUYPCxCxM#YQ9p0Tn`(5vI{NQ_Qc*e8~>Es1lxfmwh30^L{PTSR;ilO2>Q?m+MV@!jaS*f z?5-go9wsTJ2xw&@H%T3OcCil{XNH?>kXid2(2OJMt* znY+$B^s%cs&gab7fk8psJhf(ek#z67)J?Prd_wAbXhBrkjlFd9P*r6#iOiujTmD z;jfwIm!0{BL6a%u`!${G!uEYjuuWV9kAKr%+7p7G37zv9o%yiV30}&w%Jnlk*TmkP zSFjhlp0jnFFZXi2qH+y;0&Bg7yaJmmy&+cV39;+FhOg4Y19*mty+#m^exuju#26qy z7&Y)BKbs|!ZKAASQ;fhAc&_fW8Y_ySA-{dFJy6;cV#iye=G-2`zY&Kt*>c*N-(zTH z#n6xIZ1V}p3Y2>c{i4FPi!8+GIaLg?66Qz$VEJBNW*u~X6AHhRd=vj03b-kjR#L2h z`2zPK&-HYkBBu&r=)n@@gmuw;hRzyQB6J#PG+z(V8BrWv$Xi!!9q0Qgt&yDaIIk4h z2G|JUnP}mR=JUPC19C(%@Q@v@oDtVKaGO`7KzG>Bvz|BXTNWLWTz>-!VzAfO@NwTY(V1I&b#5_pz5R+6I-Su^? z&C)`U!N+F!&}n@VdAzop&V~oTp|d36TqQn0XX@Bl*O%RMcm68adjnisxuxwqV7*|in|Kar2W zknefq0`snUsi0j{jX~mQbB6w+V(GBij5AS|V9&yH8a5H<}&Vz0QS^F*JHk9c#s1XYj#eE2h~!I2lO{ygFeLr z{>O+v_Wp1U9Lyitebh+nluxmjYQTqmD#@>6-#P4C*=f+er%Kp2)l_JHtFe0hTCWkn zof!Bz;+SkP+vhP~fc~ZJoODwZ(;{L*zK$+>Ev*9GH+3#wXf~QFTZ`-pbeDHnq#L~o z-4*Dr)D^UqIurMjq0gxXoku;m)RSHK(#_L_rhO)>qdD@|RE8d5;y`}MC*qeV7P{xA zojZ$q{u|UEi;hh?WA6pM`$KTj&DV_)+`Fi^$OO35A+Iv#Udk^X=`!vdx{sH37>%on zr6G?4S9Y6r-H@M``;EHN?t&kqm*#do?Jj7`iltNS;qDEfR_q$VS_gb=BQ6v#YW66_ zOgs>eTT+Ila{R*z7vW3Je}FizJmiToX-{1GpTfq0)sEjm5QHq#wP_u-nvsXjW9Ke{VB=kPu;Pltl2!PYgE z`l~>F>6g$$)Nf^#IXpKL6sJb2Q}Jqx`&NIE3Lef&?`HZW|R zBU|)tBYwDV0E5%xAbQ2lW09o6a?=)um|E(7=y>o>Vz@&Jc0J9*_H{hy zOS((DCM7c{qwnUSTZW9@-SBPKG3sga0%Rw>tZM=5B93;7LvRT?GW(n7B61g;=yoFYXKMhaI{v*1ru( zkk$MlR^Qv$hZyi~#P=I~qL=h`EY!+FS_Fi zeox;Z-#gGhaBu&v0e;WWKKi$pCt}%Hj(_z?hTq9^zZs8a(};`F$EN+OyZWBlXNk%GWypaHqyNIu zL^>DasdOrKB%aI1Qh6RvR$f z{(K7f1IBtF|9l7-IyIXf{H?W)*BHBlbbO3Sa8r{@@@@OlR~S>UuKgK0`x)zo{%145 z@TD{e`C~{P$zOvUzRB-rSeM{;4`Fcg3Y}Zf@q$0;-^v63lCj-{M;Mdghx9)MFFC{5 zcES_Dg6F4LuN!nYSN;V5;7qYsFe+n=?E}7f68MO~&jU|7Hg6^vQ}1)|+WWxY26wE} zPyG(C$g_(59Cp@V&xeQbe<1TsF}9U3;;M%}`Mq%#7(9vp4e+c-Y;D43J=WTUO+Wm$ zL+2Ct_2Z$vpFq|i<1b9$)my*=j0FgnfDbzPS$!M$Stl5cU*-3ql9^Vc<-1iSTb-a&WfoJOepw*%&sQ zUZ)XHJ-yrUBivSJL)-oq2m7CesL#RPbHMvlTSp^bUlW*YJ|Zyr`kt`q10HkPKP)iB z>}ePNzDwsNflcWA#3er^a0v1@1O{YpyL6^qc-E!!dlxRbbp9$Z@%)=h{;|LT$p0lU z`TE3#Z{61Sc%A%E{ymK@x&3z?_93^Pt+)4j?7tVuAmqDU`uDr=mtFc_ckDM9(0|M& zkGk+7>MGRHb?9V;{sG`02%Qk{%K{UhU%2+Z>XN_Z!oLw%gMQJmNj^M(6laaz@{}F9 zdJy;{N1y)p{M}_o*!w-$74@snfm=-A<$qd81Q zqnW4jv>`s4ih+dVG#`&1V&QBA%<|d8EF4KB(ov`<;;BP445t${!kKZPk#sT=PpxMm z=`fCu!f7&|gY{@6WhM$Ymm_I5v$Y#&cuvo{i?> zBMxO-V>C8mZ*lu&;iuEdVaIxWblgrT%^p7Z$hRJ{18~+NPsCE$@!CnHGwX-uIu8n( zg(*wP@RN}g;!6(WO-tDUZ~GMJOb=&cnFKN$%a6sf!`XCXBpQL*$Oty)qBiHg does not depend on on most other systems. This - * helps userland compatability. (struct timeval ifi_lastchange) - */ -#ifndef KERNEL -#include -#endif - -/* - * Structure describing information about an interface - * which may be of interest to management entities. - */ -struct if_data { - /* generic interface information */ - u_char ifi_type; /* ethernet, tokenring, etc */ - u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ - u_char ifi_addrlen; /* media address length */ - u_char ifi_hdrlen; /* media header length */ - u_char ifi_recvquota; /* polling quota for receive intrs */ - u_char ifi_xmitquota; /* polling quota for xmit intrs */ - u_long ifi_mtu; /* maximum transmission unit */ - u_long ifi_metric; /* routing metric (external only) */ - u_long ifi_baudrate; /* linespeed */ - /* volatile statistics */ - u_long ifi_ipackets; /* packets received on interface */ - u_long ifi_ierrors; /* input errors on interface */ - u_long ifi_opackets; /* packets sent on interface */ - u_long ifi_oerrors; /* output errors on interface */ - u_long ifi_collisions; /* collisions on csma interfaces */ - u_long ifi_ibytes; /* total number of octets received */ - u_long ifi_obytes; /* total number of octets sent */ - u_long ifi_imcasts; /* packets received via multicast */ - u_long ifi_omcasts; /* packets sent via multicast */ - u_long ifi_iqdrops; /* dropped on input, this interface */ - u_long ifi_noproto; /* destined for unsupported protocol */ - u_long ifi_recvtiming; /* usec spent receiving when timing */ - u_long ifi_xmittiming; /* usec spent xmitting when timing */ - struct timeval ifi_lastchange; /* time of last administrative change */ -}; - -/* ws2tcpip.h has interface flags: IFF_* */ -#if 0 -#define IFF_UP 0x1 /* interface is up */ -#define IFF_BROADCAST 0x2 /* broadcast address valid */ -#define IFF_DEBUG 0x4 /* turn on debugging */ -#define IFF_LOOPBACK 0x8 /* is a loopback net */ -#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */ -/*#define IFF_NOTRAILERS 0x20 * obsolete: avoid use of trailers */ -#define IFF_RUNNING 0x40 /* resources allocated */ -#define IFF_NOARP 0x80 /* no address resolution protocol */ -#define IFF_PROMISC 0x100 /* receive all packets */ -#define IFF_ALLMULTI 0x200 /* receive all multicast packets */ -#define IFF_OACTIVE 0x400 /* transmission in progress */ -#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */ -#define IFF_LINK0 0x1000 /* per link layer defined bit */ -#define IFF_LINK1 0x2000 /* per link layer defined bit */ -#define IFF_LINK2 0x4000 /* per link layer defined bit */ -#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ -#define IFF_MULTICAST 0x8000 /* supports multicast */ -#endif /* 0 */ - -/* flags set internally only: */ -#define IFF_CANTCHANGE \ - (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ - IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) - -#define IFQ_MAXLEN 50 -#define IFNET_SLOWHZ 1 /* granularity is 1 second */ - -/* - * Message format for use in obtaining information about interfaces - * from getkerninfo and the routing socket - */ -struct if_msghdr { - u_short ifm_msglen; /* to skip over non-understood messages */ - u_char ifm_version; /* future binary compatability */ - u_char ifm_type; /* message type */ - int ifm_addrs; /* like rtm_addrs */ - int ifm_flags; /* value of if_flags */ - u_short ifm_index; /* index for associated ifp */ - struct if_data ifm_data;/* statistics and other data about if */ -}; - -/* - * Message format for use in obtaining information about interface addresses - * from getkerninfo and the routing socket - */ -struct ifa_msghdr { - u_short ifam_msglen; /* to skip over non-understood messages */ - u_char ifam_version; /* future binary compatability */ - u_char ifam_type; /* message type */ - int ifam_addrs; /* like rtm_addrs */ - int ifam_flags; /* value of ifa_flags */ - u_short ifam_index; /* index for associated ifp */ - int ifam_metric; /* value of ifa_metric */ -}; - -/* - * Message format for use in obtaining information about multicast addresses - * from the routing socket - */ -struct ifma_msghdr { - u_short ifmam_msglen; /* to skip over non-understood messages */ - u_char ifmam_version; /* future binary compatability */ - u_char ifmam_type; /* message type */ - int ifmam_addrs; /* like rtm_addrs */ - int ifmam_flags; /* value of ifa_flags */ - u_short ifmam_index; /* index for associated ifp */ -}; - -/* - * Interface request structure used for socket - * ioctl's. All interface ioctl's must have parameter - * definitions which begin with ifr_name. The - * remainder may be interface specific. - */ -struct ifreq { -#define IFNAMSIZ 16 - char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ - union { - struct sockaddr ifru_addr; - struct sockaddr ifru_dstaddr; - struct sockaddr ifru_broadaddr; - short ifru_flags; - int ifru_metric; - int ifru_mtu; - int ifru_phys; - int ifru_media; - caddr_t ifru_data; - } ifr_ifru; -#define ifr_addr ifr_ifru.ifru_addr /* address */ -#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ -#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ -#define ifr_flags ifr_ifru.ifru_flags /* flags */ -#define ifr_metric ifr_ifru.ifru_metric /* metric */ -#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ -#define ifr_phys ifr_ifru.ifru_phys /* physical wire */ -#define ifr_media ifr_ifru.ifru_media /* physical media */ -#define ifr_data ifr_ifru.ifru_data /* for use by interface */ -}; - -#define _SIZEOF_ADDR_IFREQ(ifr) \ - ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ - (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ - (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) - -struct ifaliasreq { - char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ - struct sockaddr ifra_addr; - struct sockaddr ifra_broadaddr; - struct sockaddr ifra_mask; -}; - -struct ifmediareq { - char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ - int ifm_current; /* current media options */ - int ifm_mask; /* don't care mask */ - int ifm_status; /* media status */ - int ifm_active; /* active options */ - int ifm_count; /* # entries in ifm_ulist array */ - int *ifm_ulist; /* media words */ -}; -/* - * Structure used in SIOCGIFCONF request. - * Used to retrieve interface configuration - * for machine (useful for programs which - * must know all networks accessible). - */ -struct ifconf { - int ifc_len; /* size of associated buffer */ - union { - caddr_t ifcu_buf; - struct ifreq *ifcu_req; - } ifc_ifcu; -#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ -#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ -}; - -#ifdef KERNEL -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_IFADDR); -MALLOC_DECLARE(M_IFMADDR); -#endif -#endif - -/* XXX - this should go away soon */ -#ifdef KERNEL -#include -#endif - -#endif /* !_NET_IF_H_ */ 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 c923357aa..000000000 --- a/libpcap/Win32/Prj/wpcap.vcxproj +++ /dev/null @@ -1,234 +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;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_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;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_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;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_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;BUILDING_PCAP;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;HAVE_ADDRINFO;HAVE_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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/libpcap/Win32/Prj/wpcap.vcxproj.filters b/libpcap/Win32/Prj/wpcap.vcxproj.filters deleted file mode 100644 index 72f1492c0..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 83f5761f0..ac163d426 100644 --- a/libpcap/aclocal.m4 +++ b/libpcap/aclocal.m4 @@ -266,6 +266,14 @@ dnl Check whether the compiler option specified as the second argument dnl is supported by the compiler and, if so, add it to the macro dnl specified as the first argument dnl +dnl If a third argument is supplied, treat it as C code to be compiled +dnl with the flag in question, and the "treat warnings as errors" flag +dnl set, and don't add the flag to the first argument if the compile +dnl fails; this is for warning options cause problems that can't be +dnl worked around. If a third argument is supplied, a fourth argument +dnl should also be supplied; it's a message desribing what the test +dnl program is checking. +dnl AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT, [ AC_MSG_CHECKING([whether the compiler supports the $2 option]) @@ -287,8 +295,38 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT, [return 0], [ AC_MSG_RESULT([yes]) + can_add_to_cflags=yes + # + # The compile supports this; do we have some C code for + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x$4" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + AC_MSG_CHECKING(whether $2 $4) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE($3)], + [ + # + # Not a problem. + # + AC_MSG_RESULT(no) + ], + [ + # + # A problem. + # + AC_MSG_RESULT(yes) + can_add_to_cflags=no + ]) + fi CFLAGS="$save_CFLAGS" - $1="$$1 $2" + if test x"$can_add_to_cflags" = "xyes" + then + $1="$$1 $2" + fi ], [ AC_MSG_RESULT([no]) @@ -384,8 +422,7 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT, if test ! -z "$ac_lbl_dependency_flag"; then AC_LANG_CONFTEST( [AC_LANG_SOURCE([[int main(void) { return 0; }]])]) - echo "$CC" $ac_lbl_dependency_flag conftest.c >&5 - if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then + if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag]) DEPENDENCY_CFLAG="$ac_lbl_dependency_flag" MKDEP='${srcdir}/mkdep' @@ -395,7 +432,7 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT, # We can't run mkdep, so have "make depend" do # nothing. # - MKDEP=: + MKDEP='${srcdir}/nomkdep' fi rm -rf conftest* else @@ -404,7 +441,7 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT, # We can't run mkdep, so have "make depend" do # nothing. # - MKDEP=: + MKDEP='${srcdir}/nomkdep' fi AC_SUBST(DEPENDENCY_CFLAG) AC_SUBST(MKDEP) @@ -419,7 +456,7 @@ dnl AC_LBL_SHLIBS_INIT dnl dnl results: dnl -dnl V_CCOPT (modified to build position-independent code) +dnl V_SHLIB_CCOPT (modified to build position-independent code) dnl V_SHLIB_CMD dnl V_SHLIB_OPT dnl V_SONAME_OPT @@ -432,7 +469,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, # On platforms where we build a shared library: # # add options to generate position-independent code, - # if necessary (it's the default in AIX and Darwin/OS X); + # if necessary (it's the default in AIX and Darwin/macOS); # # define option to set the soname of the shared library, # if the OS supports that; @@ -470,13 +507,13 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, esac ;; esac - V_CCOPT="$V_CCOPT $PIC_OPT" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT" V_SONAME_OPT="-Wl,-soname," V_RPATH_OPT="-Wl,-rpath," ;; hpux*) - V_CCOPT="$V_CCOPT -fpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # # XXX - this assumes GCC is using the HP linker, # rather than the GNU linker, and that the "+h" @@ -492,7 +529,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, ;; solaris*) - V_CCOPT="$V_CCOPT -fpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # # XXX - this assumes GCC is using the Sun linker, # rather than the GNU linker. @@ -507,7 +544,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, # where we build a shared library: # # add options to generate position-independent code, - # if necessary (it's the default in Darwin/OS X); + # if necessary (it's the default in Darwin/macOS); # # if we generate ".so" shared libraries, define the # appropriate options for building the shared library; @@ -533,7 +570,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, # # "cc" is GCC. # - V_CCOPT="$V_CCOPT -fpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-Wl,-soname," @@ -541,7 +578,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, ;; hpux*) - V_CCOPT="$V_CCOPT +z" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT +z" V_SHLIB_CMD="\$(LD)" V_SHLIB_OPT="-b" V_SONAME_OPT="+h " @@ -564,7 +601,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, ;; solaris*) - V_CCOPT="$V_CCOPT -Kpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-G" V_SONAME_OPT="-h " @@ -690,90 +727,6 @@ AC_DEFUN(AC_LBL_UNION_WAIT, AC_DEFINE(DECLWAITSTATUS,int,[type for wait]) fi]) -dnl -dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member -dnl -dnl usage: -dnl -dnl AC_LBL_SOCKADDR_SA_LEN -dnl -dnl results: -dnl -dnl HAVE_SOCKADDR_SA_LEN (defined) -dnl -AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, - [AC_MSG_CHECKING(if sockaddr struct has the sa_len member) - AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len, - AC_TRY_COMPILE([ -# include -# include ], - [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], - ac_cv_lbl_sockaddr_has_sa_len=yes, - ac_cv_lbl_sockaddr_has_sa_len=no)) - AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len) - if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then - AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member]) - fi]) - -dnl -dnl Checks to see if there's a sockaddr_storage structure -dnl -dnl usage: -dnl -dnl AC_LBL_SOCKADDR_STORAGE -dnl -dnl results: -dnl -dnl HAVE_SOCKADDR_STORAGE (defined) -dnl -AC_DEFUN(AC_LBL_SOCKADDR_STORAGE, - [AC_MSG_CHECKING(if sockaddr_storage struct exists) - AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage, - AC_TRY_COMPILE([ -# include -# include ], - [u_int i = sizeof (struct sockaddr_storage)], - ac_cv_lbl_has_sockaddr_storage=yes, - ac_cv_lbl_has_sockaddr_storage=no)) - AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage) - if test $ac_cv_lbl_has_sockaddr_storage = yes ; then - AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists]) - fi]) - -dnl -dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00 -dnl dl_module_id_1 member -dnl -dnl usage: -dnl -dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1 -dnl -dnl results: -dnl -dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined) -dnl -dnl NOTE: any compile failure means we conclude that it doesn't have -dnl that member, so if we don't have DLPI, don't have a -dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type, -dnl we conclude it doesn't have that member (which is OK, as either we -dnl won't be using code that would use that member, or we wouldn't -dnl compile in any case). -dnl -AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1, - [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member) - AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1, - AC_TRY_COMPILE([ -# include -# include -# include ], - [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)], - ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes, - ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no)) - AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1) - if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then - AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists]) - fi]) - dnl dnl Checks to see if -R is used dnl @@ -932,6 +885,50 @@ AC_DEFUN(AC_LBL_DEVEL, AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow) AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement) AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused) + AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation) + AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma) + AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn) + # Warns about safeguards added in case the enums are + # extended + # AC_LBL_CHECK_COMPILER_OPT($1, -Wcovered-switch-default) + AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations) + AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter) + AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral) + # + # This can cause problems with ntohs(), ntohl(), + # htons(), and htonl() on some platforms, such + # as OpenBSD 6.3 with Clang 5.0.1. I guess the + # problem is that the macro that ultimately does + # the byte-swapping involves a conditional + # expression that tests whether the value being + # swapped is a compile-time constant or not, + # using __builtin_constant_p(), and, depending + # on whether it is, does a compile-time swap or + # a run-time swap; perhaps the compiler always + # considers one of the two results of the + # conditional expressin is never evaluated, + # because the conditional check is done at + # compile time, and thus always says "that + # expression is never executed". + # + # (Perhaps there should be a way of flagging + # an expression that you *want* evaluated at + # compile time, so that the compiler 1) warns + # if it *can't* be evaluated at compile time + # and 2) *doesn't* warn that the true or false + # branch will never be reached.) + # + AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code, + [ +#include + +unsigned short +testme(unsigned short a) +{ + return ntohs(a); +} + ], + [generates warnings from ntohs()]) fi AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT() # @@ -1020,234 +1017,62 @@ fi dnl dnl AC_LBL_LIBRARY_NET dnl -dnl This test is for network applications that need socket() and -dnl gethostbyname() -ish functions. Under Solaris, those applications -dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link -dnl with "-lnsl" but should *not* link with "-lsocket" because -dnl libsocket.a breaks a number of things (for instance: -dnl gethostbyname() under IRIX 5.2, and snoop sockets under most -dnl versions of IRIX). +dnl This test is for network applications that need socket functions and +dnl getaddrinfo()/getnameinfo()-ish functions. We now require +dnl getaddrinfo() and getnameinfo(). We also prefer versions of +dnl recvmsg() that conform to the Single UNIX Specification, so that we +dnl can check whether a datagram received with recvmsg() was truncated +dnl when received due to the buffer being too small. dnl -dnl Unfortunately, many application developers are not aware of this, -dnl and mistakenly write tests that cause -lsocket to be used under -dnl IRIX. It is also easy to write tests that cause -lnsl to be used -dnl under operating systems where neither are necessary (or useful), -dnl such as SunOS 4.1.4, which uses -lnsl for TLI. +dnl On most operating systems, they're available in the system library. dnl -dnl This test exists so that every application developer does not test -dnl this in a different, and subtly broken fashion. - -dnl It has been argued that this test should be broken up into two -dnl seperate tests, one for the resolver libraries, and one for the -dnl libraries necessary for using Sockets API. Unfortunately, the two -dnl are carefully intertwined and allowing the autoconf user to use -dnl them independantly potentially results in unfortunate ordering -dnl dependancies -- as such, such component macros would have to -dnl carefully use indirection and be aware if the other components were -dnl executed. Since other autoconf macros do not go to this trouble, -dnl and almost no applications use sockets without the resolver, this -dnl complexity has not been implemented. +dnl Under Solaris, we need to link with libsocket and libnsl to get +dnl getaddrinfo() and getnameinfo() and, if we have libxnet, we need to +dnl link with libxnet before libsocket to get a version of recvmsg() +dnl that conforms to the Single UNIX Specification. dnl -dnl The check for libresolv is in case you are attempting to link -dnl statically and happen to have a libresolv.a lying around (and no -dnl libnsl.a). +dnl We use getaddrinfo() because we want a portable thread-safe way +dnl of getting information for a host name or port; there exist _r +dnl versions of gethostbyname() and getservbyname() on some platforms, +dnl but not on all platforms. dnl AC_DEFUN(AC_LBL_LIBRARY_NET, [ - # Most operating systems have gethostbyname() in the default searched - # libraries (i.e. libc): - # Some OSes (eg. Solaris) place it in libnsl - # Some strange OSes (SINIX) have it in libsocket: - AC_SEARCH_LIBS(gethostbyname, nsl socket resolv) - # Unfortunately libsocket sometimes depends on libnsl and - # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. - if test "$ac_cv_search_gethostbyname" = "no" - then - AC_CHECK_LIB(socket, gethostbyname, - LIBS="-lsocket -lnsl $LIBS", , -lnsl) - fi - AC_SEARCH_LIBS(socket, socket, , - AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)) + # + # Most operating systems have getaddrinfo() in the default searched + # libraries (i.e. libc). Check there first. + # + AC_CHECK_FUNC(getaddrinfo,, + [ + # + # Not found in the standard system libraries. + # Try libsocket, which requires libnsl. + # + AC_CHECK_LIB(socket, getaddrinfo, + [ + # + # OK, we found it in libsocket. + # + LIBS="-lsocket -lnsl $LIBS" + ], + [ + # + # We didn't find it. + # + AC_MSG_ERROR([getaddrinfo is required, but wasn't found]) + ], -lnsl) + + # + # OK, do we have recvmsg() in libxnet? + # We also link with libsocket and libnsl. + # + AC_CHECK_LIB(xnet, recvmsg, + [ + # + # Yes - link with it as well. + # + LIBS="-lxnet $LIBS" + ], , -lsocket -lnsl) + ]) # DLPI needs putmsg under HPUX so test for -lstr while we're at it AC_SEARCH_LIBS(putmsg, str) - ]) - -dnl -dnl Test for __attribute__ -dnl - -AC_DEFUN(AC_C___ATTRIBUTE__, [ -AC_MSG_CHECKING(for __attribute__) -AC_CACHE_VAL(ac_cv___attribute__, [ -AC_COMPILE_IFELSE([ - AC_LANG_SOURCE([[ -#include - -static void foo(void) __attribute__ ((noreturn)); - -static void -foo(void) -{ - exit(1); -} - -int -main(int argc, char **argv) -{ - foo(); -} - ]])], -ac_cv___attribute__=yes, -ac_cv___attribute__=no)]) -if test "$ac_cv___attribute__" = "yes"; then - AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) -else - # - # We can't use __attribute__, so we can't use __attribute__((unused)), - # so we define _U_ to an empty string. - # - V_DEFS="$V_DEFS -D_U_=\"\"" -fi -AC_MSG_RESULT($ac_cv___attribute__) ]) - -dnl -dnl Test whether __attribute__((unused)) can be used without warnings -dnl - -AC_DEFUN(AC_C___ATTRIBUTE___UNUSED, [ -AC_MSG_CHECKING([whether __attribute__((unused)) can be used without warnings]) -AC_CACHE_VAL(ac_cv___attribute___unused, [ -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" -AC_COMPILE_IFELSE([ - AC_LANG_SOURCE([[ -#include -#include - -int -main(int argc __attribute((unused)), char **argv __attribute((unused))) -{ - printf("Hello, world!\n"); - return 0; -} - ]])], -ac_cv___attribute___unused=yes, -ac_cv___attribute___unused=no)]) -CFLAGS="$save_CFLAGS" -if test "$ac_cv___attribute___unused" = "yes"; then - V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" -else - V_DEFS="$V_DEFS -D_U_=\"\"" -fi -AC_MSG_RESULT($ac_cv___attribute___unused) -]) - -dnl -dnl Test whether __attribute__((format)) can be used without warnings -dnl - -AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [ -AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings]) -AC_CACHE_VAL(ac_cv___attribute___format, [ -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" -AC_COMPILE_IFELSE([ - AC_LANG_SOURCE([[ -#include - -extern int foo(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); - -int -main(int argc, char **argv) -{ - foo("%s", "test"); -} - ]])], -ac_cv___attribute___format=yes, -ac_cv___attribute___format=no)]) -CFLAGS="$save_CFLAGS" -if test "$ac_cv___attribute___format" = "yes"; then - AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1, - [define if your compiler allows __attribute__((format)) without a warning]) -fi -AC_MSG_RESULT($ac_cv___attribute___format) -]) - -dnl -dnl Checks to see if tpacket_stats is defined in linux/if_packet.h -dnl If so then pcap-linux.c can use this to report proper statistics. -dnl -dnl -Scott Barron -dnl -AC_DEFUN(AC_LBL_TPACKET_STATS, - [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined) - AC_CACHE_VAL(ac_cv_lbl_tpacket_stats, - AC_TRY_COMPILE([ -# include ], - [struct tpacket_stats stats], - ac_cv_lbl_tpacket_stats=yes, - ac_cv_lbl_tpacket_stats=no)) - AC_MSG_RESULT($ac_cv_lbl_tpacket_stats) - if test $ac_cv_lbl_tpacket_stats = yes; then - AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined]) - fi]) - -dnl -dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member. -dnl -dnl usage: -dnl -dnl AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI -dnl -dnl results: -dnl -dnl HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined) -dnl -dnl NOTE: any compile failure means we conclude that it doesn't have -dnl that member, so if we don't have tpacket_auxdata, we conclude it -dnl doesn't have that member (which is OK, as either we won't be using -dnl code that would use that member, or we wouldn't compile in any case). -dnl -AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI, - [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member) - AC_CACHE_VAL(ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci, - AC_TRY_COMPILE([ -# include -# include ], - [u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)], - ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes, - ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no)) - AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci) - if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then - HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci - AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA) - AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists]) - fi]) - -dnl -dnl Checks to see if Solaris has the dl_passive_req_t struct defined -dnl in . -dnl -dnl usage: -dnl -dnl AC_LBL_DL_PASSIVE_REQ_T -dnl -dnl results: -dnl -dnl HAVE_DLPI_PASSIVE (defined) -dnl -AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T, - [AC_MSG_CHECKING(if dl_passive_req_t struct exists) - AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t, - AC_TRY_COMPILE([ -# include -# include ], - [u_int i = sizeof(dl_passive_req_t)], - ac_cv_lbl_has_dl_passive_req_t=yes, - ac_cv_lbl_has_dl_passive_req_t=no)) - AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t) - if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then - AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive - exists]) - fi]) diff --git a/libpcap/bpf/net/bpf_filter.c b/libpcap/bpf/net/bpf_filter.c deleted file mode 100644 index 01a1b64e7..000000000 --- a/libpcap/bpf/net/bpf_filter.c +++ /dev/null @@ -1,766 +0,0 @@ -/*- - * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from the Stanford/CMU enet packet filter, - * (net/enet.c) distributed as part of 4.3BSD, and code contributed - * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence - * Berkeley Laboratory. - * - * 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. - * - * @(#)bpf.c 7.5 (Berkeley) 7/15/91 - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef _WIN32 - -#include - -#else /* _WIN32 */ - -#if HAVE_INTTYPES_H -#include -#elif HAVE_STDINT_H -#include -#endif -#ifdef HAVE_SYS_BITYPES_H -#include -#endif - -#include -#include -#include - -#define SOLARIS (defined(sun) && (defined(__SVR4) || defined(__svr4__))) -#if defined(__hpux) || SOLARIS -# include -# include -# define mbuf msgb -# define m_next b_cont -# define MLEN(m) ((m)->b_wptr - (m)->b_rptr) -# define mtod(m,t) ((t)(m)->b_rptr) -#else /* defined(__hpux) || SOLARIS */ -# define MLEN(m) ((m)->m_len) -#endif /* defined(__hpux) || SOLARIS */ - -#endif /* _WIN32 */ - -#include - -#if !defined(KERNEL) && !defined(_KERNEL) -#include -#endif - -#define int32 bpf_int32 -#define u_int32 bpf_u_int32 - -#ifndef LBL_ALIGN -/* - * XXX - IA-64? If not, this probably won't work on Win64 IA-64 - * systems, unless LBL_ALIGN is defined elsewhere for them. - * XXX - SuperH? If not, this probably won't work on WinCE SuperH - * systems, unless LBL_ALIGN is defined elsewhere for them. - */ -#if defined(sparc) || defined(__sparc__) || defined(mips) || \ - defined(ibm032) || defined(__alpha) || defined(__hpux) || \ - defined(__arm__) -#define LBL_ALIGN -#endif -#endif - -#ifndef LBL_ALIGN -#ifndef _WIN32 -#include -#endif - -#define EXTRACT_SHORT(p) ((u_short)ntohs(*(u_short *)p)) -#define EXTRACT_LONG(p) (ntohl(*(u_int32 *)p)) -#else -#define EXTRACT_SHORT(p)\ - ((u_short)\ - ((u_short)*((u_char *)p+0)<<8|\ - (u_short)*((u_char *)p+1)<<0)) -#define EXTRACT_LONG(p)\ - ((u_int32)*((u_char *)p+0)<<24|\ - (u_int32)*((u_char *)p+1)<<16|\ - (u_int32)*((u_char *)p+2)<<8|\ - (u_int32)*((u_char *)p+3)<<0) -#endif - -#if defined(KERNEL) || defined(_KERNEL) -# if !defined(__hpux) && !SOLARIS -#include -# endif -#define MINDEX(len, _m, _k) \ -{ \ - len = MLEN(m); \ - while ((_k) >= len) { \ - (_k) -= len; \ - (_m) = (_m)->m_next; \ - if ((_m) == 0) \ - return 0; \ - len = MLEN(m); \ - } \ -} - -static int -m_xword(m, k, err) - register struct mbuf *m; - register int k, *err; -{ - register int len; - register u_char *cp, *np; - register struct mbuf *m0; - - MINDEX(len, m, k); - cp = mtod(m, u_char *) + k; - if (len - k >= 4) { - *err = 0; - return EXTRACT_LONG(cp); - } - m0 = m->m_next; - if (m0 == 0 || MLEN(m0) + len - k < 4) - goto bad; - *err = 0; - np = mtod(m0, u_char *); - switch (len - k) { - - case 1: - return (cp[0] << 24) | (np[0] << 16) | (np[1] << 8) | np[2]; - - case 2: - return (cp[0] << 24) | (cp[1] << 16) | (np[0] << 8) | np[1]; - - default: - return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | np[0]; - } - bad: - *err = 1; - return 0; -} - -static int -m_xhalf(m, k, err) - register struct mbuf *m; - register int k, *err; -{ - register int len; - register u_char *cp; - register struct mbuf *m0; - - MINDEX(len, m, k); - cp = mtod(m, u_char *) + k; - if (len - k >= 2) { - *err = 0; - return EXTRACT_SHORT(cp); - } - m0 = m->m_next; - if (m0 == 0) - goto bad; - *err = 0; - return (cp[0] << 8) | mtod(m0, u_char *)[0]; - bad: - *err = 1; - return 0; -} -#endif - -#ifdef __linux__ -#include -#include -#include -#endif - -enum { - BPF_S_ANC_NONE, - BPF_S_ANC_VLAN_TAG, - BPF_S_ANC_VLAN_TAG_PRESENT, -}; - -/* - * Execute the filter program starting at pc on the packet p - * wirelen is the length of the original packet - * buflen is the amount of data present - * aux_data is auxiliary data, currently used only when interpreting - * filters intended for the Linux kernel in cases where the kernel - * rejects the filter; it contains VLAN tag information - * For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0, - * in all other cases, p is a pointer to a buffer and buflen is its size. - * - * Thanks to Ani Sinha for providing initial implementation - */ -u_int -bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) - register const struct bpf_insn *pc; - register const u_char *p; - u_int wirelen; - register u_int buflen; - register const struct bpf_aux_data *aux_data; -{ - register u_int32 A, X; - register bpf_u_int32 k; - u_int32 mem[BPF_MEMWORDS]; -#if defined(KERNEL) || defined(_KERNEL) - struct mbuf *m, *n; - int merr, len; - - if (buflen == 0) { - m = (struct mbuf *)p; - p = mtod(m, u_char *); - buflen = MLEN(m); - } else - m = NULL; -#endif - - if (pc == 0) - /* - * No filter means accept all. - */ - return (u_int)-1; - A = 0; - X = 0; - --pc; - while (1) { - ++pc; - switch (pc->code) { - - default: -#if defined(KERNEL) || defined(_KERNEL) - return 0; -#else - abort(); -#endif - case BPF_RET|BPF_K: - return (u_int)pc->k; - - case BPF_RET|BPF_A: - return (u_int)A; - - case BPF_LD|BPF_W|BPF_ABS: - k = pc->k; - if (k > buflen || sizeof(int32_t) > buflen - k) { -#if defined(KERNEL) || defined(_KERNEL) - if (m == NULL) - return 0; - A = m_xword(m, k, &merr); - if (merr != 0) - return 0; - continue; -#else - return 0; -#endif - } - A = EXTRACT_LONG(&p[k]); - continue; - - case BPF_LD|BPF_H|BPF_ABS: - k = pc->k; - if (k > buflen || sizeof(int16_t) > buflen - k) { -#if defined(KERNEL) || defined(_KERNEL) - if (m == NULL) - return 0; - A = m_xhalf(m, k, &merr); - if (merr != 0) - return 0; - continue; -#else - return 0; -#endif - } - A = EXTRACT_SHORT(&p[k]); - continue; - - case BPF_LD|BPF_B|BPF_ABS: - { -#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT) - int code = BPF_S_ANC_NONE; -#define ANCILLARY(CODE) case SKF_AD_OFF + SKF_AD_##CODE: \ - code = BPF_S_ANC_##CODE; \ - if (!aux_data) \ - return 0; \ - break; - - switch (pc->k) { - ANCILLARY(VLAN_TAG); - ANCILLARY(VLAN_TAG_PRESENT); - default : -#endif - k = pc->k; - if (k >= buflen) { -#if defined(KERNEL) || defined(_KERNEL) - if (m == NULL) - return 0; - n = m; - MINDEX(len, n, k); - A = mtod(n, u_char *)[k]; - continue; -#else - return 0; -#endif - } - A = p[k]; -#if defined(SKF_AD_VLAN_TAG) && defined(SKF_AD_VLAN_TAG_PRESENT) - } - switch (code) { - case BPF_S_ANC_VLAN_TAG: - if (aux_data) - A = aux_data->vlan_tag; - break; - - case BPF_S_ANC_VLAN_TAG_PRESENT: - if (aux_data) - A = aux_data->vlan_tag_present; - break; - } -#endif - continue; - } - case BPF_LD|BPF_W|BPF_LEN: - A = wirelen; - continue; - - case BPF_LDX|BPF_W|BPF_LEN: - X = wirelen; - continue; - - case BPF_LD|BPF_W|BPF_IND: - k = X + pc->k; - if (pc->k > buflen || X > buflen - pc->k || - sizeof(int32_t) > buflen - k) { -#if defined(KERNEL) || defined(_KERNEL) - if (m == NULL) - return 0; - A = m_xword(m, k, &merr); - if (merr != 0) - return 0; - continue; -#else - return 0; -#endif - } - A = EXTRACT_LONG(&p[k]); - continue; - - case BPF_LD|BPF_H|BPF_IND: - k = X + pc->k; - if (X > buflen || pc->k > buflen - X || - sizeof(int16_t) > buflen - k) { -#if defined(KERNEL) || defined(_KERNEL) - if (m == NULL) - return 0; - A = m_xhalf(m, k, &merr); - if (merr != 0) - return 0; - continue; -#else - return 0; -#endif - } - A = EXTRACT_SHORT(&p[k]); - continue; - - case BPF_LD|BPF_B|BPF_IND: - k = X + pc->k; - if (pc->k >= buflen || X >= buflen - pc->k) { -#if defined(KERNEL) || defined(_KERNEL) - if (m == NULL) - return 0; - n = m; - MINDEX(len, n, k); - A = mtod(n, u_char *)[k]; - continue; -#else - return 0; -#endif - } - A = p[k]; - continue; - - case BPF_LDX|BPF_MSH|BPF_B: - k = pc->k; - if (k >= buflen) { -#if defined(KERNEL) || defined(_KERNEL) - if (m == NULL) - return 0; - n = m; - MINDEX(len, n, k); - X = (mtod(n, char *)[k] & 0xf) << 2; - continue; -#else - return 0; -#endif - } - X = (p[pc->k] & 0xf) << 2; - continue; - - case BPF_LD|BPF_IMM: - A = pc->k; - continue; - - case BPF_LDX|BPF_IMM: - X = pc->k; - continue; - - case BPF_LD|BPF_MEM: - A = mem[pc->k]; - continue; - - case BPF_LDX|BPF_MEM: - X = mem[pc->k]; - continue; - - case BPF_ST: - mem[pc->k] = A; - continue; - - case BPF_STX: - mem[pc->k] = X; - continue; - - case BPF_JMP|BPF_JA: -#if defined(KERNEL) || defined(_KERNEL) - /* - * No backward jumps allowed. - */ - pc += pc->k; -#else - /* - * XXX - we currently implement "ip6 protochain" - * with backward jumps, so sign-extend pc->k. - */ - pc += (bpf_int32)pc->k; -#endif - continue; - - case BPF_JMP|BPF_JGT|BPF_K: - pc += (A > pc->k) ? pc->jt : pc->jf; - continue; - - case BPF_JMP|BPF_JGE|BPF_K: - pc += (A >= pc->k) ? pc->jt : pc->jf; - continue; - - case BPF_JMP|BPF_JEQ|BPF_K: - pc += (A == pc->k) ? pc->jt : pc->jf; - continue; - - case BPF_JMP|BPF_JSET|BPF_K: - pc += (A & pc->k) ? pc->jt : pc->jf; - continue; - - case BPF_JMP|BPF_JGT|BPF_X: - pc += (A > X) ? pc->jt : pc->jf; - continue; - - case BPF_JMP|BPF_JGE|BPF_X: - pc += (A >= X) ? pc->jt : pc->jf; - continue; - - case BPF_JMP|BPF_JEQ|BPF_X: - pc += (A == X) ? pc->jt : pc->jf; - continue; - - case BPF_JMP|BPF_JSET|BPF_X: - pc += (A & X) ? pc->jt : pc->jf; - continue; - - case BPF_ALU|BPF_ADD|BPF_X: - A += X; - continue; - - case BPF_ALU|BPF_SUB|BPF_X: - A -= X; - continue; - - case BPF_ALU|BPF_MUL|BPF_X: - A *= X; - continue; - - case BPF_ALU|BPF_DIV|BPF_X: - if (X == 0) - return 0; - A /= X; - continue; - - case BPF_ALU|BPF_MOD|BPF_X: - if (X == 0) - return 0; - A %= X; - continue; - - case BPF_ALU|BPF_AND|BPF_X: - A &= X; - continue; - - case BPF_ALU|BPF_OR|BPF_X: - A |= X; - continue; - - case BPF_ALU|BPF_XOR|BPF_X: - A ^= X; - continue; - - case BPF_ALU|BPF_LSH|BPF_X: - A <<= X; - continue; - - case BPF_ALU|BPF_RSH|BPF_X: - A >>= X; - continue; - - case BPF_ALU|BPF_ADD|BPF_K: - A += pc->k; - continue; - - case BPF_ALU|BPF_SUB|BPF_K: - A -= pc->k; - continue; - - case BPF_ALU|BPF_MUL|BPF_K: - A *= pc->k; - continue; - - case BPF_ALU|BPF_DIV|BPF_K: - A /= pc->k; - continue; - - case BPF_ALU|BPF_MOD|BPF_K: - A %= pc->k; - continue; - - case BPF_ALU|BPF_AND|BPF_K: - A &= pc->k; - continue; - - case BPF_ALU|BPF_OR|BPF_K: - A |= pc->k; - continue; - - case BPF_ALU|BPF_XOR|BPF_K: - A ^= pc->k; - continue; - - case BPF_ALU|BPF_LSH|BPF_K: - A <<= pc->k; - continue; - - case BPF_ALU|BPF_RSH|BPF_K: - A >>= pc->k; - continue; - - case BPF_ALU|BPF_NEG: - /* - * Most BPF arithmetic is unsigned, but negation - * can't be unsigned; throw some casts to - * specify what we're trying to do. - */ - A = (u_int32)(-(int32)A); - continue; - - case BPF_MISC|BPF_TAX: - X = A; - continue; - - case BPF_MISC|BPF_TXA: - A = X; - continue; - } - } -} - -u_int -bpf_filter(pc, p, wirelen, buflen) - register const struct bpf_insn *pc; - register const u_char *p; - u_int wirelen; - register u_int buflen; -{ - return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL); -} - - -/* - * Return true if the 'fcode' is a valid filter program. - * The constraints are that each jump be forward and to a valid - * code, that memory accesses are within valid ranges (to the - * extent that this can be checked statically; loads of packet - * data have to be, and are, also checked at run time), and that - * the code terminates with either an accept or reject. - * - * The kernel needs to be able to verify an application's filter code. - * Otherwise, a bogus program could easily crash the system. - */ -int -bpf_validate(f, len) - const struct bpf_insn *f; - int len; -{ - u_int i, from; - const struct bpf_insn *p; - - if (len < 1) - return 0; - /* - * There's no maximum program length in userland. - */ -#if defined(KERNEL) || defined(_KERNEL) - if (len > BPF_MAXINSNS) - return 0; -#endif - - for (i = 0; i < (u_int)len; ++i) { - p = &f[i]; - switch (BPF_CLASS(p->code)) { - /* - * Check that memory operations use valid addresses. - */ - case BPF_LD: - case BPF_LDX: - switch (BPF_MODE(p->code)) { - case BPF_IMM: - break; - case BPF_ABS: - case BPF_IND: - case BPF_MSH: - /* - * There's no maximum packet data size - * in userland. The runtime packet length - * check suffices. - */ -#if defined(KERNEL) || defined(_KERNEL) - /* - * More strict check with actual packet length - * is done runtime. - */ - if (p->k >= bpf_maxbufsize) - return 0; -#endif - break; - case BPF_MEM: - if (p->k >= BPF_MEMWORDS) - return 0; - break; - case BPF_LEN: - break; - default: - return 0; - } - break; - case BPF_ST: - case BPF_STX: - if (p->k >= BPF_MEMWORDS) - return 0; - break; - case BPF_ALU: - switch (BPF_OP(p->code)) { - case BPF_ADD: - case BPF_SUB: - case BPF_MUL: - case BPF_OR: - case BPF_AND: - case BPF_XOR: - case BPF_LSH: - case BPF_RSH: - case BPF_NEG: - break; - case BPF_DIV: - case BPF_MOD: - /* - * Check for constant division or modulus - * by 0. - */ - if (BPF_SRC(p->code) == BPF_K && p->k == 0) - return 0; - break; - default: - return 0; - } - break; - case BPF_JMP: - /* - * Check that jumps are within the code block, - * and that unconditional branches don't go - * backwards as a result of an overflow. - * Unconditional branches have a 32-bit offset, - * so they could overflow; we check to make - * sure they don't. Conditional branches have - * an 8-bit offset, and the from address is <= - * BPF_MAXINSNS, and we assume that BPF_MAXINSNS - * is sufficiently small that adding 255 to it - * won't overflow. - * - * We know that len is <= BPF_MAXINSNS, and we - * assume that BPF_MAXINSNS is < the maximum size - * of a u_int, so that i + 1 doesn't overflow. - * - * For userland, we don't know that the from - * or len are <= BPF_MAXINSNS, but we know that - * from <= len, and, except on a 64-bit system, - * it's unlikely that len, if it truly reflects - * the size of the program we've been handed, - * will be anywhere near the maximum size of - * a u_int. We also don't check for backward - * branches, as we currently support them in - * userland for the protochain operation. - */ - from = i + 1; - switch (BPF_OP(p->code)) { - case BPF_JA: -#if defined(KERNEL) || defined(_KERNEL) - if (from + p->k < from || from + p->k >= len) -#else - if (from + p->k >= (u_int)len) -#endif - return 0; - break; - case BPF_JEQ: - case BPF_JGT: - case BPF_JGE: - case BPF_JSET: - if (from + p->jt >= (u_int)len || from + p->jf >= (u_int)len) - return 0; - break; - default: - return 0; - } - break; - case BPF_RET: - break; - case BPF_MISC: - break; - default: - return 0; - } - } - return BPF_CLASS(f[len - 1].code) == BPF_RET; -} diff --git a/libpcap/bpf_dump.c b/libpcap/bpf_dump.c index d5ab61e5e..a9c91169f 100644 --- a/libpcap/bpf_dump.c +++ b/libpcap/bpf_dump.c @@ -20,12 +20,14 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include #include +#include "optimize.h" + void bpf_dump(const struct bpf_program *p, int option) { @@ -50,8 +52,7 @@ bpf_dump(const struct bpf_program *p, int option) } for (i = 0; i < n; ++insn, ++i) { #ifdef BDEBUG - extern int bids[]; - if (bids[i] > 0) + if (i < NBIDS && bids[i] > 0) printf("[%02d]", bids[i] - 1); else printf(" -- "); diff --git a/libpcap/bpf_image.c b/libpcap/bpf_image.c index 01ec536df..ab41d1ef9 100644 --- a/libpcap/bpf_image.c +++ b/libpcap/bpf_image.c @@ -20,22 +20,10 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#ifdef _WIN32 -#include -#else /* _WIN32 */ -#if HAVE_INTTYPES_H -#include -#elif HAVE_STDINT_H -#include -#endif -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -#include -#endif /* _WIN32 */ +#include #include #include @@ -47,266 +35,290 @@ #endif char * -bpf_image(p, n) - const struct bpf_insn *p; - int n; +bpf_image(const struct bpf_insn *p, int n) { - int v; - const char *fmt, *op; + const char *op; static char image[256]; - char operand[64]; + char operand_buf[64]; + const char *operand; - v = p->k; switch (p->code) { default: op = "unimp"; - fmt = "0x%x"; - v = p->code; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "0x%x", p->code); + operand = operand_buf; break; case BPF_RET|BPF_K: op = "ret"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_RET|BPF_A: op = "ret"; - fmt = ""; + operand = ""; break; case BPF_LD|BPF_W|BPF_ABS: op = "ld"; - fmt = "[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_H|BPF_ABS: op = "ldh"; - fmt = "[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_B|BPF_ABS: op = "ldb"; - fmt = "[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_W|BPF_LEN: op = "ld"; - fmt = "#pktlen"; + operand = "#pktlen"; break; case BPF_LD|BPF_W|BPF_IND: op = "ld"; - fmt = "[x + %d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_H|BPF_IND: op = "ldh"; - fmt = "[x + %d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_B|BPF_IND: op = "ldb"; - fmt = "[x + %d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + operand = operand_buf; break; case BPF_LD|BPF_IMM: op = "ld"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_LDX|BPF_IMM: op = "ldx"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_LDX|BPF_MSH|BPF_B: op = "ldxb"; - fmt = "4*([%d]&0xf)"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "4*([%d]&0xf)", p->k); + operand = operand_buf; break; case BPF_LD|BPF_MEM: op = "ld"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_LDX|BPF_MEM: op = "ldx"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_ST: op = "st"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_STX: op = "stx"; - fmt = "M[%d]"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JA: op = "ja"; - fmt = "%d"; - v = n + 1 + p->k; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "%d", n + 1 + p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JGT|BPF_K: op = "jgt"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JGE|BPF_K: op = "jge"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JEQ|BPF_K: op = "jeq"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JSET|BPF_K: op = "jset"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_JMP|BPF_JGT|BPF_X: op = "jgt"; - fmt = "x"; + operand = "x"; break; case BPF_JMP|BPF_JGE|BPF_X: op = "jge"; - fmt = "x"; + operand = "x"; break; case BPF_JMP|BPF_JEQ|BPF_X: op = "jeq"; - fmt = "x"; + operand = "x"; break; case BPF_JMP|BPF_JSET|BPF_X: op = "jset"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_ADD|BPF_X: op = "add"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_SUB|BPF_X: op = "sub"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_MUL|BPF_X: op = "mul"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_DIV|BPF_X: op = "div"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_MOD|BPF_X: op = "mod"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_AND|BPF_X: op = "and"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_OR|BPF_X: op = "or"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_XOR|BPF_X: op = "xor"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_LSH|BPF_X: op = "lsh"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_RSH|BPF_X: op = "rsh"; - fmt = "x"; + operand = "x"; break; case BPF_ALU|BPF_ADD|BPF_K: op = "add"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_SUB|BPF_K: op = "sub"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_MUL|BPF_K: op = "mul"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_DIV|BPF_K: op = "div"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_MOD|BPF_K: op = "mod"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_AND|BPF_K: op = "and"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_OR|BPF_K: op = "or"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_XOR|BPF_K: op = "xor"; - fmt = "#0x%x"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_LSH|BPF_K: op = "lsh"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_RSH|BPF_K: op = "rsh"; - fmt = "#%d"; + (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + operand = operand_buf; break; case BPF_ALU|BPF_NEG: op = "neg"; - fmt = ""; + operand = ""; break; case BPF_MISC|BPF_TAX: op = "tax"; - fmt = ""; + operand = ""; break; case BPF_MISC|BPF_TXA: op = "txa"; - fmt = ""; + operand = ""; break; } - (void)pcap_snprintf(operand, sizeof operand, fmt, v); if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) { (void)pcap_snprintf(image, sizeof image, "(%03d) %-8s %-16s jt %d\tjf %d", diff --git a/libpcap/chmod_bpf b/libpcap/chmod_bpf index 0a30d9930..946fec37f 100755 --- a/libpcap/chmod_bpf +++ b/libpcap/chmod_bpf @@ -1,7 +1,7 @@ #! /bin/sh # -# Unfortunately, Mac OS X's devfs is based on the old FreeBSD +# Unfortunately, macOS's devfs is based on the old FreeBSD # one, not the current one, so there's no way to configure it # to create BPF devices with particular owners or groups. # This startup item will make it owned by the admin group, diff --git a/libpcap/cmake/Modules/FindDAG.cmake b/libpcap/cmake/Modules/FindDAG.cmake new file mode 100644 index 000000000..ef1352844 --- /dev/null +++ b/libpcap/cmake/Modules/FindDAG.cmake @@ -0,0 +1,32 @@ +# +# Try to find the Endace DAG library. +# + +# Try to find the header +find_path(DAG_INCLUDE_DIR dagapi.h) + +# +# Try to find the libraries +# +# We assume that if we have libdag we have libdagconf, as they're +# installed at the same time from the same package. +# +find_library(DAG_LIBRARY dag) +find_library(DAGCONF_LIBRARY dagconf) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(DAG + DEFAULT_MSG + DAG_INCLUDE_DIR + DAG_LIBRARY + DAGCONF_LIBRARY +) + +mark_as_advanced( + DAG_INCLUDE_DIR + DAG_LIBRARY + DAGCONF_LIBRARY +) + +set(DAG_INCLUDE_DIRS ${DAG_INCLUDE_DIR}) +set(DAG_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY}) diff --git a/libpcap/cmake/Modules/FindFseeko.cmake b/libpcap/cmake/Modules/FindFseeko.cmake new file mode 100644 index 000000000..ca53a5a61 --- /dev/null +++ b/libpcap/cmake/Modules/FindFseeko.cmake @@ -0,0 +1,85 @@ +# CMake support for fseeko +# +# Based on FindLFS.cmake by +# Copyright (C) 2016 Julian Andres Klode . +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# This defines the following variables +# +# FSEEKO_DEFINITIONS - List of definitions to pass to add_definitions() +# FSEEKO_COMPILE_OPTIONS - List of definitions to pass to add_compile_options() +# FSEEKO_LIBRARIES - List of libraries and linker flags +# FSEEKO_FOUND - If there is Large files support +# + +include(CheckCSourceCompiles) +include(FindPackageHandleStandardArgs) +include(CMakePushCheckState) + +# Check for the availability of fseeko() +# The cases handled are: +# +# * Native fseeko() +# * Preprocessor flag -D_LARGEFILE_SOURCE +# +function(_fseeko_check) + set(_fseeko_cppflags) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET 1) + set(CMAKE_REQUIRED_DEFINITIONS ${LFS_DEFINITIONS}) + message(STATUS "Looking for native fseeko support") + check_symbol_exists(fseeko stdio.h fseeko_native) + cmake_pop_check_state() + if (fseeko_native) + message(STATUS "Looking for native fseeko support - found") + set(FSEEKO_FOUND TRUE) + else() + message(STATUS "Looking for native fseeko support - not found") + endif() + + if (NOT FSEEKO_FOUND) + # See if it's available with _LARGEFILE_SOURCE. + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET 1) + set(CMAKE_REQUIRED_DEFINITIONS ${LFS_DEFINITIONS} "-D_LARGEFILE_SOURCE") + check_symbol_exists(fseeko stdio.h fseeko_need_largefile_source) + cmake_pop_check_state() + if (fseeko_need_largefile_source) + message(STATUS "Looking for fseeko support with _LARGEFILE_SOURCE - found") + set(FSEEKO_FOUND TRUE) + set(_fseeko_cppflags "-D_LARGEFILE_SOURCE") + else() + message(STATUS "Looking for fseeko support with _LARGEFILE_SOURCE - not found") + endif() + endif() + + set(FSEEKO_DEFINITIONS ${_fseeko_cppflags} CACHE STRING "Extra definitions for fseeko support") + set(FSEEKO_COMPILE_OPTIONS "" CACHE STRING "Extra compiler options for fseeko support") + set(FSEEKO_LIBRARIES "" CACHE STRING "Extra definitions for fseeko support") + set(FSEEKO_FOUND ${FSEEKO_FOUND} CACHE INTERNAL "Found fseeko") +endfunction() + +if (NOT FSEEKO_FOUND) + _fseeko_check() +endif() + +find_package_handle_standard_args(FSEEKO "Could not find fseeko. Set FSEEKO_DEFINITIONS, FSEEKO_COMPILE_OPTIONS, FSEEKO_LIBRARIES." FSEEKO_FOUND) diff --git a/libpcap/cmake/Modules/FindLFS.cmake b/libpcap/cmake/Modules/FindLFS.cmake new file mode 100644 index 000000000..be5f0d487 --- /dev/null +++ b/libpcap/cmake/Modules/FindLFS.cmake @@ -0,0 +1,153 @@ +# CMake support for large files +# +# Copyright (C) 2016 Julian Andres Klode . +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# This defines the following variables +# +# LFS_DEFINITIONS - List of definitions to pass to add_definitions() +# LFS_COMPILE_OPTIONS - List of definitions to pass to add_compile_options() +# LFS_LIBRARIES - List of libraries and linker flags +# LFS_FOUND - If there is Large files support +# + +include(CheckCSourceCompiles) +include(FindPackageHandleStandardArgs) +include(CMakePushCheckState) + +# Test program to check for LFS. Requires that off_t has at least 8 byte large +set(_lfs_test_source + " + #include + typedef char my_static_assert[sizeof(off_t) >= 8 ? 1 : -1]; + int main(void) { return 0; } + " +) + +# Check if the given options are needed +# +# This appends to the variables _lfs_cppflags, _lfs_cflags, and _lfs_ldflags, +# it also sets LFS_FOUND to 1 if it works. +function(_lfs_check_compiler_option var options definitions libraries) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET 1) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${options}) + set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${definitions}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_DEFINITIONS} ${libraries}) + + message(STATUS "Looking for LFS support using ${options} ${definitions} ${libraries}") + check_c_source_compiles("${_lfs_test_source}" ${var}) + cmake_pop_check_state() + + if(${var}) + message(STATUS "Looking for LFS support using ${options} ${definitions} ${libraries} - found") + set(_lfs_cppflags ${_lfs_cppflags} ${definitions} PARENT_SCOPE) + set(_lfs_cflags ${_lfs_cflags} ${options} PARENT_SCOPE) + set(_lfs_ldflags ${_lfs_ldflags} ${libraries} PARENT_SCOPE) + set(LFS_FOUND TRUE PARENT_SCOPE) + else() + message(STATUS "Looking for LFS support using ${options} ${definitions} ${libraries} - not found") + endif() +endfunction() + +# Check for the availability of LFS. +# The cases handled are: +# +# * Native LFS +# * Output of getconf LFS_CFLAGS; getconf LFS_LIBS; getconf LFS_LDFLAGS +# * Preprocessor flag -D_FILE_OFFSET_BITS=64 +# * Preprocessor flag -D_LARGE_FILES +# +function(_lfs_check) + set(_lfs_cflags) + set(_lfs_cppflags) + set(_lfs_ldflags) + set(_lfs_libs) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET 1) + message(STATUS "Looking for native LFS support") + check_c_source_compiles("${_lfs_test_source}" lfs_native) + cmake_pop_check_state() + if (lfs_native) + message(STATUS "Looking for native LFS support - found") + set(LFS_FOUND TRUE) + else() + message(STATUS "Looking for native LFS support - not found") + endif() + + if (NOT LFS_FOUND) + # Check using getconf. If getconf fails, don't worry, the check in + # _lfs_check_compiler_option will fail as well. + execute_process(COMMAND getconf LFS_CFLAGS + OUTPUT_VARIABLE _lfs_cflags_raw + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + execute_process(COMMAND getconf LFS_LIBS + OUTPUT_VARIABLE _lfs_libs_tmp + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + execute_process(COMMAND getconf LFS_LDFLAGS + OUTPUT_VARIABLE _lfs_ldflags_tmp + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + + separate_arguments(_lfs_cflags_raw) + separate_arguments(_lfs_ldflags_tmp) + separate_arguments(_lfs_libs_tmp) + + # Move -D flags to the place they are supposed to be + foreach(flag ${_lfs_cflags_raw}) + if (flag MATCHES "-D.*") + list(APPEND _lfs_cppflags_tmp ${flag}) + else() + list(APPEND _lfs_cflags_tmp ${flag}) + endif() + endforeach() + + # Check if the flags we received (if any) produce working LFS support + _lfs_check_compiler_option(lfs_getconf_works + "${_lfs_cflags_tmp}" + "${_lfs_cppflags_tmp}" + "${_lfs_libs_tmp};${_lfs_ldflags_tmp}") + endif() + + if(NOT LFS_FOUND) # IRIX stuff + _lfs_check_compiler_option(lfs_need_n32 "-n32" "" "") + endif() + if(NOT LFS_FOUND) # Linux and friends + _lfs_check_compiler_option(lfs_need_file_offset_bits "" "-D_FILE_OFFSET_BITS=64" "") + endif() + if(NOT LFS_FOUND) # AIX + _lfs_check_compiler_option(lfs_need_large_files "" "-D_LARGE_FILES=1" "") + endif() + + set(LFS_DEFINITIONS ${_lfs_cppflags} CACHE STRING "Extra definitions for large file support") + set(LFS_COMPILE_OPTIONS ${_lfs_cflags} CACHE STRING "Extra definitions for large file support") + set(LFS_LIBRARIES ${_lfs_libs} ${_lfs_ldflags} CACHE STRING "Extra definitions for large file support") + set(LFS_FOUND ${LFS_FOUND} CACHE INTERNAL "Found LFS") +endfunction() + +if (NOT LFS_FOUND) + _lfs_check() +endif() + +find_package_handle_standard_args(LFS "Could not find LFS. Set LFS_DEFINITIONS, LFS_COMPILE_OPTIONS, LFS_LIBRARIES." LFS_FOUND) diff --git a/libpcap/cmake/Modules/FindPacket.cmake b/libpcap/cmake/Modules/FindPacket.cmake new file mode 100644 index 000000000..1311cdb94 --- /dev/null +++ b/libpcap/cmake/Modules/FindPacket.cmake @@ -0,0 +1,81 @@ +# +# Copyright (C) 2017 Ali Abdulkadir . +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sub-license, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# FindPacket +# ========== +# +# Find the Packet library and include files. +# +# This module defines the following variables: +# +# PACKET_INCLUDE_DIR - absolute path to the directory containing Packet32.h. +# +# 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. See e.g. PACKET_DLL_DIR +# variable below. + +# PACKET_FOUND - TRUE if the Packet library *and* header are found. +# +# Hints and Backward Compatibility +# ================================ +# +# To tell this module where to look, a user may set the environment variable +# PACKET_DLL_DIR to point cmake to the *root* of a directory with include and +# lib subdirectories for packet.dll (e.g WpdPack/npcap-sdk). +# Alternatively, PACKET_DLL_DIR may also be set from cmake command line or GUI +# (e.g cmake -DPACKET_DLL_DIR=/path/to/packet [...]) +# + +# The 64-bit Packet.lib is located under /x64 +set(64BIT_SUBDIR "") +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(64BIT_SUBDIR "/x64") +endif() + +# Find the header +find_path(PACKET_INCLUDE_DIR Packet32.h + HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR + PATH_SUFFIXES include Include +) + +# Find the library +find_library(PACKET_LIBRARY + NAMES Packet packet + HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR + PATH_SUFFIXES Lib${64BIT_SUBDIR} lib${64BIT_SUBDIR} +) + +# Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PACKET + DEFAULT_MSG + 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}) diff --git a/libpcap/cmake/Modules/FindSNF.cmake b/libpcap/cmake/Modules/FindSNF.cmake new file mode 100644 index 000000000..76dcced41 --- /dev/null +++ b/libpcap/cmake/Modules/FindSNF.cmake @@ -0,0 +1,24 @@ +# +# Try to find the Myricom SNF library. +# + +# Try to find the header +find_path(SNF_INCLUDE_DIR snf.h /opt/snf) + +# Try to find the library +find_library(SNF_LIBRARY snf /opt/snf) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SNF + DEFAULT_MSG + SNF_INCLUDE_DIR + SNF_LIBRARY +) + +mark_as_advanced( + SNF_INCLUDE_DIR + SNF_LIBRARY +) + +set(SNF_INCLUDE_DIRS ${SNF_INCLUDE_DIR}) +set(SNF_LIBRARIES ${SNF_LIBRARY}) diff --git a/libpcap/cmake/Modules/FindTC.cmake b/libpcap/cmake/Modules/FindTC.cmake new file mode 100644 index 000000000..bb24c6671 --- /dev/null +++ b/libpcap/cmake/Modules/FindTC.cmake @@ -0,0 +1,24 @@ +# +# Try to find the Riverbed TurboCap library. +# + +# Try to find the header +find_path(TC_INCLUDE_DIR TcApi.h) + +# Try to find the library +find_library(TC_LIBRARY TcApi) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(TC + DEFAULT_MSG + TC_INCLUDE_DIR + TC_LIBRARY +) + +mark_as_advanced( + TC_INCLUDE_DIR + TC_LIBRARY +) + +set(TC_INCLUDE_DIRS ${TC_INCLUDE_DIR}) +set(TC_LIBRARIES ${TC_LIBRARY}) diff --git a/libpcap/config/have_siocglifconf.c b/libpcap/cmake/have_siocglifconf.c similarity index 100% rename from libpcap/config/have_siocglifconf.c rename to libpcap/cmake/have_siocglifconf.c diff --git a/libpcap/cmake/preconfigure.cmake b/libpcap/cmake/preconfigure.cmake deleted file mode 100644 index c8c92a48e..000000000 --- a/libpcap/cmake/preconfigure.cmake +++ /dev/null @@ -1,55 +0,0 @@ -if( NOT LIBPCAP_PRECONFIGURED ) - set( LIBPCAP_PRECONFIGURED TRUE ) - - ################################################################### - # Parameters - ################################################################### - - option (USE_STATIC_RT "Use static Runtime" ON) - - ###################################### - # Project setings - ###################################### - - add_definitions( -DBUILDING_PCAP ) - - if( MSVC ) - add_definitions( -D__STDC__ ) - add_definitions( -D_CRT_SECURE_NO_WARNINGS ) - add_definitions( "-D_U_=" ) - elseif( CMAKE_COMPILER_IS_GNUCXX ) - add_definitions( "-D_U_=__attribute__((unused))" ) - else(MSVC) - add_definitions( "-D_U_=" ) - endif( MSVC ) - - if (USE_STATIC_RT) - MESSAGE( STATUS "Use STATIC runtime" ) - - if( MSVC ) - set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT") - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") - - set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT") - set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT") - set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") - set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") - endif( MSVC ) - else (USE_STATIC_RT) - MESSAGE( STATUS "Use DYNAMIC runtime" ) - - if( MSVC ) - set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD") - set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") - set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") - - set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD") - set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD") - set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD") - set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd") - endif( MSVC ) - endif (USE_STATIC_RT) -endif( NOT LIBPCAP_PRECONFIGURED ) diff --git a/libpcap/cmake_uninstall.cmake.in b/libpcap/cmake_uninstall.cmake.in new file mode 100644 index 000000000..2037e3653 --- /dev/null +++ b/libpcap/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/libpcap/cmakeconfig.h.in b/libpcap/cmakeconfig.h.in index 94edb5f44..6760cec76 100644 --- a/libpcap/cmakeconfig.h.in +++ b/libpcap/cmakeconfig.h.in @@ -1,10 +1,19 @@ /* cmakeconfig.h.in */ +/* Define to 1 if arpa/inet.h declares `ether_hostton' */ +#cmakedefine ARPA_INET_H_DECLARES_ETHER_HOSTTON 1 + /* Enable optimizer debugging */ #cmakedefine BDEBUG 1 -/* define if you have a cloning BPF device */ -#cmakedefine HAVE_CLONING_BPF 1 +/* Define to 1 if remote packet capture is to be supported */ +#cmakedefine ENABLE_REMOTE 1 + +/* define if we have the AIX getnetbyname_r() */ +#cmakedefine HAVE_AIX_GETNETBYNAME_R 1 + +/* define if we have the AIX getprotobyname_r() */ +#cmakedefine HAVE_AIX_GETPROTOBYNAME_R 1 /* define if you have the DAG API */ #cmakedefine HAVE_DAG_API 1 @@ -15,21 +24,20 @@ /* define if you have dag_get_stream_erf_types() */ #cmakedefine HAVE_DAG_GET_STREAM_ERF_TYPES 1 -/* define if you have streams capable DAG API */ -#cmakedefine HAVE_DAG_STREAMS_API 1 +/* define if you have large streams capable DAG API */ +#cmakedefine HAVE_DAG_LARGE_STREAMS_API 1 /* define if you have vdag_set_device_info() */ #cmakedefine HAVE_DAG_VDAG 1 -/* Define to 1 if you have the declaration of `ether_hostton', and to 0 if you - don't. */ +/* Define to 1 if you have the declaration of `ether_hostton' */ #cmakedefine HAVE_DECL_ETHER_HOSTTON 1 -/* define if you have a /dev/dlpi */ -#cmakedefine HAVE_DEV_DLPI 1 +/* Define to 1 if `dl_module_id_1' is a member of `dl_hp_ppa_info_t'. */ +#cmakedefine HAVE_DL_HP_PPA_INFO_T_DL_MODULE_ID_1 1 -/* if passive_req_t primitive exists */ -#cmakedefine HAVE_DLPI_PASSIVE 1 +/* Define to 1 if the system has the type `dl_passive_req_t'. */ +#cmakedefine HAVE_DL_PASSIVE_REQ_T 1 /* Define to 1 if you have the `ether_hostton' function. */ #cmakedefine HAVE_ETHER_HOSTTON 1 @@ -37,15 +45,15 @@ /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #cmakedefine HAVE_FSEEKO 1 +/* Define to 1 if you have the `getspnam' function. */ +#cmakedefine HAVE_GETSPNAM 1 + /* on HP-UX 10.20 or later */ #cmakedefine HAVE_HPUX10_20_OR_LATER 1 /* on HP-UX 9.x */ #cmakedefine HAVE_HPUX9 1 -/* if ppa_info_t_dl_module_id exists */ -#cmakedefine HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 @@ -76,24 +84,24 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_ETHTOOL_H 1 +/* define if we have the Linux getnetbyname_r() */ +#cmakedefine HAVE_LINUX_GETNETBYNAME_R 1 + +/* define if we have the Linux getprotobyname_r() */ +#cmakedefine HAVE_LINUX_GETPROTOBYNAME_R 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_IF_BONDING_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LINUX_IF_PACKET_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_NET_TSTAMP_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_SOCKET_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_SOCKIOS_H 1 -/* if tp_vlan_tci exists */ -#cmakedefine HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LINUX_TYPES_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LINUX_USBDEVICE_FS_H 1 @@ -103,32 +111,35 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MEMORY_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_ETHER_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_IF_ETHER_H 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETPACKET_IF_PACKET_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NETPACKET_PACKET_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_BPF_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_ENET_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NET_IF_MEDIA_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_NIT_H 1 + +/* 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 + /* if there's an os_proto.h for this platform, to use additional prototypes */ #cmakedefine HAVE_OS_PROTO_H 1 -/* Define to 1 if remote packet capture is to be supported */ -#cmakedefine HAVE_REMOTE 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_PATHS_H 1 +/* Define to 1 if Packet32 API (WinPcap NPF driver) is available */ +#cmakedefine HAVE_PACKET32 1 /* define if net/pfvar.h defines PF_NAT through PF_NORDR */ #cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1 @@ -142,18 +153,18 @@ /* Define to 1 if you have the `snprintf' function. */ #cmakedefine HAVE_SNPRINTF 1 -/* if struct sockaddr has the sa_len member */ -#cmakedefine HAVE_SOCKADDR_SA_LEN 1 - -/* if struct sockaddr_storage exists */ -#cmakedefine HAVE_SOCKADDR_STORAGE 1 - -/* define if socklen_t is defined */ +/* Define to 1 if the system has the type `socklen_t'. */ #cmakedefine HAVE_SOCKLEN_T 1 /* On solaris */ #cmakedefine HAVE_SOLARIS 1 +/* define if we have the Solaris/IRIX getnetbyname_r() */ +#cmakedefine HAVE_SOLARIS_IRIX_GETNETBYNAME_R 1 + +/* define if we have the Solaris/IRIX getprotobyname_r() */ +#cmakedefine HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDINT_H 1 @@ -163,17 +174,57 @@ /* Define to 1 if you have the `strerror' function. */ #cmakedefine HAVE_STRERROR 1 +/* Define to 1 if you have the `strerror_r' function. */ +#cmakedefine HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strerror_s' function. */ +#cmakedefine HAVE_STRERROR_S 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcat' function. */ +#cmakedefine HAVE_STRLCAT 1 + /* Define to 1 if you have the `strlcpy' function. */ #cmakedefine HAVE_STRLCPY 1 +/* Define to 1 if you have the `strtok_r' function. */ +#cmakedefine HAVE_STRTOK_R 1 + /* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */ #cmakedefine HAVE_STRUCT_BPF_TIMEVAL 1 /* Define to 1 if the system has the type `struct ether_addr'. */ #cmakedefine HAVE_STRUCT_ETHER_ADDR 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_BITYPES_H 1 +/* Define to 1 if `msg_control' is a member of `struct msghdr'. */ +#cmakedefine HAVE_STRUCT_MSGHDR_MSG_CONTROL 1 + +/* Define to 1 if `msg_flags' is a member of `struct msghdr'. */ +#cmakedefine HAVE_STRUCT_MSGHDR_MSG_FLAGS 1 + +/* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */ +#cmakedefine HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL 1 + +/* Define to 1 if `sa_len' is a member of `struct sockaddr'. */ +#cmakedefine HAVE_STRUCT_SOCKADDR_SA_LEN 1 + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#cmakedefine HAVE_STRUCT_SOCKADDR_STORAGE 1 + +/* Define to 1 if `tp_vlan_tci' is a member of `struct tpacket_auxdata'. */ +#cmakedefine HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI 1 + +/* Define to 1 if the system has the type `struct tpacket_stats'. */ +#cmakedefine HAVE_STRUCT_TPACKET_STATS 1 + +/* Define to 1 if `bRequestType' is a member of `struct + usbdevfs_ctrltransfer'. */ +#cmakedefine HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_BUFMOD_H 1 @@ -181,9 +232,15 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_DLPI_EXT_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_DLPI_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_IOCCOM_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_NET_NIT_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_SOCKIO_H 1 @@ -196,27 +253,15 @@ /* define if you have the TurboCap API */ #cmakedefine HAVE_TC_API 1 -/* if if_packet.h has tpacket_stats defined */ -#cmakedefine HAVE_TPACKET_STATS 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H 1 -/* if struct usbdevfs_ctrltransfer has bRequestType */ -#cmakedefine HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1 - /* Define to 1 if you have the `vsnprintf' function. */ #cmakedefine HAVE_VSNPRINTF 1 /* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */ #cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1 -/* define if the system supports zerocopy BPF */ -#cmakedefine HAVE_ZEROCOPY_BPF 1 - -/* define if your compiler has __attribute__ */ -#cmakedefine HAVE___ATTRIBUTE__ 1 - /* IPv6 */ #cmakedefine INET6 1 @@ -224,10 +269,7 @@ #cmakedefine LBL_ALIGN 1 /* path for device for USB sniffing */ -#cmakedefine LINUX_USB_MON_DEV 1 - -/* if we need a pcap_parse wrapper around yyparse */ -#cmakedefine NEED_YYPARSE_WRAPPER 1 +#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 @@ -235,17 +277,23 @@ /* Define to 1 if netinet/if_ether.h declares `ether_hostton' */ #cmakedefine NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON 1 +/* Define to 1 if net/ethernet.h declares `ether_hostton' */ +#cmakedefine NET_ETHERNET_H_DECLARES_ETHER_HOSTTON 1 + /* do not use protochain */ #cmakedefine NO_PROTOCHAIN 1 /* Define to the address where bug reports for this package should be sent. */ #cmakedefine PACKAGE_BUGREPORT 1 +/* Define to the DLL-preferred version string of of this package. */ +#cmakedefine PACKAGE_VERSION_DLL @PACKAGE_VERSION_DLL@ + /* Define to the full name of this package. */ -#cmakedefine PACKAGE_NAME 1 +#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" /* Define to the full name and version of this package. */ -#cmakedefine PACKAGE_STRING 1 +#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" /* Define to the one symbol short name of this package. */ #cmakedefine PACKAGE_TARNAME 1 @@ -254,10 +302,7 @@ #cmakedefine PACKAGE_URL 1 /* Define to the version of this package. */ -#cmakedefine PACKAGE_VERSION 1 - -/* /dev/dlpi directory */ -#cmakedefine PCAP_DEV_PREFIX 1 +#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" /* target host supports Bluetooth sniffing */ #cmakedefine PCAP_SUPPORT_BT 1 @@ -271,21 +316,30 @@ /* target host supports netfilter sniffing */ #cmakedefine PCAP_SUPPORT_NETFILTER 1 -/* use Linux packet ring capture if available */ +/* target host supports netmap */ +#cmakedefine PCAP_SUPPORT_NETMAP 1 + +/* use packet ring capture support on Linux if available */ #cmakedefine PCAP_SUPPORT_PACKET_RING 1 +/* target host supports RDMA sniffing */ +#cmakedefine PCAP_SUPPORT_RDMASNIFF 1 + /* target host supports USB sniffing */ #cmakedefine PCAP_SUPPORT_USB 1 /* include ACN support */ #cmakedefine SITA 1 -/* if struct sockaddr_hci has hci_channel member */ -#cmakedefine SOCKADDR_HCI_HAS_HCI_CHANNEL 1 - /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS 1 +/* Define to 1 if strings.h declares `ffs' */ +#cmakedefine STRINGS_H_DECLARES_FFS 1 + +/* Define to 1 if sys/ethernet.h declares `ether_hostton' */ +#cmakedefine SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON 1 + /* Enable parser debugging */ #cmakedefine YYDEBUG 1 @@ -306,40 +360,7 @@ /* define on AIX to get certain functions */ #cmakedefine _SUN 1 -/* define if your compiler allows __attribute__((format)) without a warning */ -#cmakedefine __ATTRIBUTE___FORMAT_OK 1 - #if 0 -/* to handle Ultrix compilers that don't support const in prototypes */ -#cmakedefine const 1 - -/* Define as token for inline if inlining supported */ -#cmakedefine inline 1 - -/* Define to `short' if int16_t not defined. */ -#cmakedefine int16_t 1 - -/* Define to `int' if int32_t not defined. */ -#cmakedefine int32_t 1 - -/* Define to `long long' if int64_t not defined. */ -#cmakedefine int64_t 1 - -/* Define to `signed char' if int8_t not defined. */ -#cmakedefine int8_t 1 - /* on sinix */ #cmakedefine sinix 1 - -/* Define to `unsigned short' if u_int16_t not defined. */ -#cmakedefine u_int16_t 1 - -/* Define to `unsigned int' if u_int32_t not defined. */ -#cmakedefine u_int32_t 1 - -/* Define to `unsigned long long' if u_int64_t not defined. */ -#cmakedefine u_int64_t 1 - -/* Define to `unsigned char' if u_int8_t not defined. */ -#cmakedefine u_int8_t 1 #endif diff --git a/libpcap/config.guess b/libpcap/config.guess index 44290b838..2b79f6d83 100755 --- a/libpcap/config.guess +++ b/libpcap/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2015-02-23' +timestamp='2018-07-06' # 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 @@ -15,7 +15,7 @@ timestamp='2015-02-23' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,7 +27,7 @@ timestamp='2015-02-23' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . @@ -39,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2018 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." @@ -101,15 +101,15 @@ trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && e trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { 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) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { 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 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; +case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; @@ -132,14 +132,14 @@ 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/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu - eval $set_cc_for_build - cat <<-EOF > $dummy.c + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc @@ -149,13 +149,20 @@ Linux|GNU|GNU/*) LIBC=gnu #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi ;; 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*, @@ -169,27 +176,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; 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. - case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -205,10 +215,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 @@ -216,39 +226,55 @@ 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/[-_].*/\./'` + 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}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -265,63 +291,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 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" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # 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'` + 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 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -333,7 +350,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -360,38 +377,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + eval "$set_cc_for_build" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$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 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; 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/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -400,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -429,44 +446,44 @@ 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} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -475,23 +492,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + 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} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -517,17 +534,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -544,7 +561,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????: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 @@ -556,14 +573,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then 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} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -574,7 +591,7 @@ 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" else @@ -588,7 +605,7 @@ EOF exit ;; *:AIX:*:[4567]) 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 + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc @@ -597,18 +614,18 @@ EOF 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} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -623,28 +640,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + 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 [ -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 - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 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 - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -677,13 +694,13 @@ 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 - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -694,23 +711,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -735,11 +752,11 @@ 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 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -748,7 +765,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -756,9 +773,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -783,127 +800,109 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; 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/ /_/'` + 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 ;; 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/ /_/'` + 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 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -916,58 +915,64 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + eval "$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} + echo "$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 + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el @@ -981,64 +986,70 @@ EOF #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; 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} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1052,34 +1063,34 @@ EOF # 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} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + 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} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1089,12 +1100,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; 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/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1104,9 +1115,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1114,7 +1125,7 @@ EOF # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1126,9 +1137,9 @@ EOF exit ;; 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 + echo 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 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1148,9 +1159,9 @@ EOF test -r /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; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1159,28 +1170,28 @@ EOF test -r /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; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1191,7 +1202,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1211,23 +1222,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1246,46 +1257,56 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build + eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub @@ -1296,27 +1317,33 @@ EOF # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1325,18 +1352,18 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1357,14 +1384,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1373,34 +1400,48 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs exit ;; esac +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp @@ -1419,16 +1460,16 @@ hostinfo = `(hostinfo) 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} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/libpcap/config.h.in b/libpcap/config.h.in index e85b2a3f5..b1a20a441 100644 --- a/libpcap/config.h.in +++ b/libpcap/config.h.in @@ -1,10 +1,22 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Define to 1 if arpa/inet.h declares `ether_hostton' */ +#undef ARPA_INET_H_DECLARES_ETHER_HOSTTON + /* Enable optimizer debugging */ #undef BDEBUG -/* define if you have a cloning BPF device */ -#undef HAVE_CLONING_BPF +/* Define to 1 if remote packet capture is to be supported */ +#undef ENABLE_REMOTE + +/* define if we have the AIX getnetbyname_r() */ +#undef HAVE_AIX_GETNETBYNAME_R + +/* define if we have the AIX getprotobyname_r() */ +#undef HAVE_AIX_GETPROTOBYNAME_R + +/* Define to 1 if you have the header file. */ +#undef HAVE_DAGAPI_H /* define if you have the DAG API */ #undef HAVE_DAG_API @@ -15,40 +27,45 @@ /* define if you have dag_get_stream_erf_types() */ #undef HAVE_DAG_GET_STREAM_ERF_TYPES -/* define if you have streams capable DAG API */ -#undef HAVE_DAG_STREAMS_API +/* define if you have large streams capable DAG API */ +#undef HAVE_DAG_LARGE_STREAMS_API /* define if you have vdag_set_device_info() */ #undef HAVE_DAG_VDAG -/* Define to 1 if you have the declaration of `ether_hostton', and to 0 if you - don't. */ +/* Define to 1 if you have the declaration of `ether_hostton' */ #undef HAVE_DECL_ETHER_HOSTTON -/* define if you have a /dev/dlpi */ -#undef HAVE_DEV_DLPI +/* Define to 1 if `dl_module_id_1' is a member of `dl_hp_ppa_info_t'. */ +#undef HAVE_DL_HP_PPA_INFO_T_DL_MODULE_ID_1 -/* if passive_req_t primitive exists */ -#undef HAVE_DLPI_PASSIVE +/* Define to 1 if the system has the type `dl_passive_req_t'. */ +#undef HAVE_DL_PASSIVE_REQ_T /* Define to 1 if you have the `ether_hostton' function. */ #undef HAVE_ETHER_HOSTTON +/* Define to 1 if you have the `ffs' function. */ +#undef HAVE_FFS + /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO +/* Define to 1 if you have the `getspnam' function. */ +#undef HAVE_GETSPNAM + /* on HP-UX 10.20 or later */ #undef HAVE_HPUX10_20_OR_LATER /* on HP-UX 9.x */ #undef HAVE_HPUX9 -/* if ppa_info_t_dl_module_id exists */ -#undef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 - /* 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 + /* if libdlpi exists */ #undef HAVE_LIBDLPI @@ -76,24 +93,24 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_ETHTOOL_H +/* define if we have the Linux getnetbyname_r() */ +#undef HAVE_LINUX_GETNETBYNAME_R + +/* define if we have the Linux getprotobyname_r() */ +#undef HAVE_LINUX_GETPROTOBYNAME_R + /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_IF_BONDING_H -/* Define to 1 if you have the header file. */ -#undef HAVE_LINUX_IF_PACKET_H - /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_NET_TSTAMP_H +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_SOCKET_H + /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_SOCKIOS_H -/* if tp_vlan_tci exists */ -#undef HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI - -/* Define to 1 if you have the header file. */ -#undef HAVE_LINUX_TYPES_H - /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_USBDEVICE_FS_H @@ -103,24 +120,30 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_ETHER_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IF_ETHER_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETPACKET_IF_PACKET_H - /* Define to 1 if you have the header file. */ #undef HAVE_NETPACKET_PACKET_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_BPF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_ENET_H + /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_MEDIA_H +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_NIT_H + +/* 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 + /* if there's an os_proto.h for this platform, to use additional prototypes */ #undef HAVE_OS_PROTO_H @@ -136,18 +159,18 @@ /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF -/* if struct sockaddr has the sa_len member */ -#undef HAVE_SOCKADDR_SA_LEN - -/* if struct sockaddr_storage exists */ -#undef HAVE_SOCKADDR_STORAGE - -/* define if socklen_t is defined */ +/* Define to 1 if the system has the type `socklen_t'. */ #undef HAVE_SOCKLEN_T /* On solaris */ #undef HAVE_SOLARIS +/* define if we have the Solaris/IRIX getnetbyname_r() */ +#undef HAVE_SOLARIS_IRIX_GETNETBYNAME_R + +/* define if we have the Solaris/IRIX getprotobyname_r() */ +#undef HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H @@ -157,12 +180,21 @@ /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR +/* Define to 1 if you have the `strerror_r' function. */ +#undef HAVE_STRERROR_R + +/* Define to 1 if you have the `strerror_s' function. */ +#undef HAVE_STRERROR_S + /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strlcat' function. */ +#undef HAVE_STRLCAT + /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY @@ -175,8 +207,30 @@ /* Define to 1 if the system has the type `struct ether_addr'. */ #undef HAVE_STRUCT_ETHER_ADDR -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_BITYPES_H +/* Define to 1 if `msg_control' is a member of `struct msghdr'. */ +#undef HAVE_STRUCT_MSGHDR_MSG_CONTROL + +/* Define to 1 if `msg_flags' is a member of `struct msghdr'. */ +#undef HAVE_STRUCT_MSGHDR_MSG_FLAGS + +/* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */ +#undef HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL + +/* Define to 1 if `sa_len' is a member of `struct sockaddr'. */ +#undef HAVE_STRUCT_SOCKADDR_SA_LEN + +/* Define to 1 if the system has the type `struct sockaddr_storage'. */ +#undef HAVE_STRUCT_SOCKADDR_STORAGE + +/* Define to 1 if `tp_vlan_tci' is a member of `struct tpacket_auxdata'. */ +#undef HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI + +/* Define to 1 if the system has the type `struct tpacket_stats'. */ +#undef HAVE_STRUCT_TPACKET_STATS + +/* Define to 1 if `bRequestType' is a member of `struct + usbdevfs_ctrltransfer'. */ +#undef HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE /* Define to 1 if you have the header file. */ #undef HAVE_SYS_BUFMOD_H @@ -184,11 +238,14 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_DLPI_EXT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_DLPI_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCCOM_H -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SELECT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_NET_NIT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKIO_H @@ -202,24 +259,12 @@ /* define if you have the TurboCap API */ #undef HAVE_TC_API -/* if if_packet.h has tpacket_stats defined */ -#undef HAVE_TPACKET_STATS - /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* if struct usbdevfs_ctrltransfer has bRequestType */ -#undef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE - /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF -/* define if the system supports zerocopy BPF */ -#undef HAVE_ZEROCOPY_BPF - -/* define if your compiler has __attribute__ */ -#undef HAVE___ATTRIBUTE__ - /* IPv6 */ #undef INET6 @@ -235,6 +280,9 @@ /* Define to 1 if netinet/if_ether.h declares `ether_hostton' */ #undef NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON +/* Define to 1 if net/ethernet.h declares `ether_hostton' */ +#undef NET_ETHERNET_H_DECLARES_ETHER_HOSTTON + /* do not use protochain */ #undef NO_PROTOCHAIN @@ -256,9 +304,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* /dev/dlpi directory */ -#undef PCAP_DEV_PREFIX - /* target host supports Bluetooth sniffing */ #undef PCAP_SUPPORT_BT @@ -271,21 +316,30 @@ /* target host supports netfilter sniffing */ #undef PCAP_SUPPORT_NETFILTER -/* use Linux packet ring capture if available */ +/* target host supports netmap */ +#undef PCAP_SUPPORT_NETMAP + +/* use packet ring capture support on Linux if available */ #undef PCAP_SUPPORT_PACKET_RING +/* target host supports RDMA sniffing */ +#undef PCAP_SUPPORT_RDMASNIFF + /* target host supports USB sniffing */ #undef PCAP_SUPPORT_USB /* include ACN support */ #undef SITA -/* if struct sockaddr_hci has hci_channel member */ -#undef SOCKADDR_HCI_HAS_HCI_CHANNEL - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if strings.h declares `ffs' */ +#undef STRINGS_H_DECLARES_FFS + +/* Define to 1 if sys/ethernet.h declares `ether_hostton' */ +#undef SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON + /* Enable parser debugging */ #undef YYDEBUG @@ -310,38 +364,11 @@ /* define on AIX to get certain functions */ #undef _SUN -/* define if your compiler allows __attribute__((format)) without a warning */ -#undef __ATTRIBUTE___FORMAT_OK - /* to handle Ultrix compilers that don't support const in prototypes */ #undef const /* Define as token for inline if inlining supported */ #undef inline -/* Define to `short' if int16_t not defined. */ -#undef int16_t - -/* Define to `int' if int32_t not defined. */ -#undef int32_t - -/* Define to `long long' if int64_t not defined. */ -#undef int64_t - -/* Define to `signed char' if int8_t not defined. */ -#undef int8_t - /* on sinix */ #undef sinix - -/* Define to `unsigned short' if u_int16_t not defined. */ -#undef u_int16_t - -/* Define to `unsigned int' if u_int32_t not defined. */ -#undef u_int32_t - -/* Define to `unsigned long long' if u_int64_t not defined. */ -#undef u_int64_t - -/* Define to `unsigned char' if u_int8_t not defined. */ -#undef u_int8_t diff --git a/libpcap/config.sub b/libpcap/config.sub index bc855a2a9..c95acc681 100755 --- a/libpcap/config.sub +++ b/libpcap/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2015-02-22' +timestamp='2018-07-03' # 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 @@ -15,7 +15,7 @@ timestamp='2015-02-22' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ timestamp='2015-02-22' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -53,12 +53,11 @@ timestamp='2015-02-22' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -68,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2018 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." @@ -95,7 +94,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -111,134 +110,455 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +IFS="-" read -r field1 field2 field3 field4 <&2 + exit 1 ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 + *-*-*-*) + basic_machine=$field1-$field2 + os=$field3-$field4 ;; - -bluegene*) - os=-cnk + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ + | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + os=linux-android + ;; + *) + basic_machine=$field1-$field2 + os=$field3 + ;; + esac ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc532* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* | hitachi* \ + | c[123]* | convex* | sun | crds | omron* | dg | ultra | tti* \ + | harris | dolphin | highlevel | gould | cbm | ns | masscomp \ + | apple | axis | knuth | cray | microblaze* \ + | sim | cisco | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + os= + ;; + *) + basic_machine=$field1 + os=$field2 + ;; + esac ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + os=bsd + ;; + a29khif) + basic_machine=a29k-amd + os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=scout + ;; + am29k) + basic_machine=a29k-none + os=bsd + ;; + amdahl) + basic_machine=580-amdahl + os=sysv + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=bsd + ;; + aros) + basic_machine=i386-pc + os=aros + ;; + aux) + basic_machine=m68k-apple + os=aux + ;; + balance) + basic_machine=ns32k-sequent + os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=linux + ;; + cegcc) + basic_machine=arm-unknown + os=cegcc + ;; + cray) + basic_machine=j90-cray + os=unicos + ;; + craynv) + basic_machine=craynv-cray + os=unicosmp + ;; + delta88) + basic_machine=m88k-motorola + os=sysv3 + ;; + dicos) + basic_machine=i686-pc + os=dicos + ;; + djgpp) + basic_machine=i586-pc + os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=ose + ;; + gmicro) + basic_machine=tron-gmicro + os=sysv + ;; + go32) + basic_machine=i386-pc + os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=hms + ;; + harris) + basic_machine=m88k-harris + os=sysv3 + ;; + hp300bsd) + basic_machine=m68k-hp + os=bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=hpux + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=proelf + ;; + i386mach) + basic_machine=i386-mach + os=mach + ;; + vsta) + basic_machine=i386-unknown + os=vsta + ;; + isi68 | isi) + basic_machine=m68k-isi + os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=sysv + ;; + merlin) + basic_machine=ns32k-utek + os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + os=coff + ;; + morphos) + basic_machine=powerpc-unknown + os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=moxiebox + ;; + msdos) + basic_machine=i386-pc + os=msdos + ;; + msys) + basic_machine=i686-pc + os=msys + ;; + mvs) + basic_machine=i370-ibm + os=mvs + ;; + nacl) + basic_machine=le32-unknown + os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=newsos + ;; + news1000) + basic_machine=m68030-sony + os=newsos + ;; + necv70) + basic_machine=v70-nec + os=sysv + ;; + nh3000) + basic_machine=m68k-harris + os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=cxux + ;; + nindy960) + basic_machine=i960-intel + os=nindy + ;; + mon960) + basic_machine=i960-intel + os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=ose + ;; + os68k) + basic_machine=m68k-none + os=os68k + ;; + paragon) + basic_machine=i860-intel + os=osf + ;; + parisc) + basic_machine=hppa-unknown + os=linux + ;; + pw32) + basic_machine=i586-unknown + os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=rdos + ;; + rdos32) + basic_machine=i386-pc + os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=coff + ;; + sa29200) + basic_machine=a29k-amd + os=udi + ;; + sei) + basic_machine=mips-sei + os=seiux + ;; + sps7) + basic_machine=m68k-bull + os=sysv2 + ;; + stratus) + basic_machine=i860-stratus + os=sysv4 + ;; + sun2os3) + basic_machine=m68000-sun + os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=solaris2 + ;; + sv1) + basic_machine=sv1-cray + os=unicos + ;; + symmetry) + basic_machine=i386-sequent + os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=unicos + ;; + t90) + basic_machine=t90-cray + os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + os=tpf + ;; + udi29k) + basic_machine=a29k-amd + os=udi + ;; + ultra3) + basic_machine=a29k-nyu + os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=none + ;; + vaxv) + basic_machine=vax-dec + os=sysv + ;; + vms) + basic_machine=vax-dec + os=vms + ;; + vxworks960) + basic_machine=i960-wrs + os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=vxworks + ;; + xbox) + basic_machine=i686-pc + os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + os=unicos + ;; + *) + basic_machine=$1 + os= + ;; + esac ;; esac @@ -253,17 +573,18 @@ case $basic_machine in | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ | avr | avr32 \ + | ba \ | be32 | be64 \ | bfin \ - | c4x | c8051 | clipper \ + | c4x | c8051 | clipper | csky \ | d10v | d30v | dlx | dsp16xx \ - | epiphany \ + | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ - | i370 | i860 | i960 | ia64 \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ @@ -296,16 +617,18 @@ case $basic_machine in | mt \ | msp430 \ | nds32 | nds32le | nds32be \ + | nfp \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ + | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ - | riscv32 | riscv64 \ + | riscv | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -314,7 +637,7 @@ case $basic_machine in | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ - | we32k \ + | wasm32 \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown @@ -333,20 +656,23 @@ case $basic_machine in ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown - os=-none + os=${os:-none} ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + ;; + m9s12z | m68hcs12z | hcs12z | s12z) + basic_machine=s12z-unknown + os=${os:-none} ;; ms1) basic_machine=mt-unknown ;; - strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown - os=-none + os=${os:-none} ;; xscaleeb) basic_machine=armeb-unknown @@ -362,11 +688,6 @@ case $basic_machine in i*86 | x86_64) basic_machine=$basic_machine-pc ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ @@ -376,17 +697,18 @@ case $basic_machine in | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ + | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ + | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ @@ -420,6 +742,7 @@ case $basic_machine in | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ + | nfp-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ @@ -427,13 +750,15 @@ case $basic_machine in | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ + | riscv-* | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ @@ -442,6 +767,7 @@ case $basic_machine in | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ + | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -454,138 +780,77 @@ case $basic_machine in ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; abacus) basic_machine=abacus-unknown ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; amd64) basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amiga | amiga-*) basic_machine=m68k-unknown ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux + asmjs) + basic_machine=asmjs-unknown ;; blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; bluegene*) basic_machine=powerpc-ibm - os=-cnk + os=cnk ;; c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc + os=${os:-unicos} ;; convex-c1) basic_machine=c1-convex - os=-bsd + os=bsd ;; convex-c2) basic_machine=c2-convex - os=-bsd + os=bsd ;; convex-c32) basic_machine=c32-convex - os=-bsd + os=bsd ;; convex-c34) basic_machine=c34-convex - os=-bsd + os=bsd ;; convex-c38) basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp + os=bsd ;; cr16 | cr16-*) basic_machine=cr16-unknown - os=-elf + os=${os:-elf} ;; crds | unos) basic_machine=m68k-crds @@ -598,7 +863,7 @@ case $basic_machine in ;; crx) basic_machine=crx-unknown - os=-elf + os=${os:-elf} ;; da30 | da30-*) basic_machine=m68k-da30 @@ -608,50 +873,38 @@ case $basic_machine in ;; decsystem10* | dec10*) basic_machine=pdp10-dec - os=-tops10 + os=tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec - os=-tops20 + os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; dpx20 | dpx20-*) basic_machine=rs6000-bull - os=-bosx + os=${os:-bosx} ;; - dpx2* | dpx2*-bull) + dpx2*) basic_machine=m68k-bull - os=-sysv3 + os=sysv3 ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + e500v[12]-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=$os"spe" ;; encore | umax | mmax) basic_machine=ns32k-encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + basic_machine=elxsi-elxsi + os=${os:-bsd} ;; fx2800) basic_machine=i860-alliant @@ -659,45 +912,13 @@ case $basic_machine in genix) basic_machine=ns32k-ns ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 + os=hiuxwe2 ;; hp300-*) basic_machine=m68k-hp ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; @@ -727,200 +948,82 @@ case $basic_machine in hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=solaris2 ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + basic_machine=j90-cray + os=${os:-unicos} ;; iris | iris4d) basic_machine=mips-sgi case $os in - -irix*) + irix*) ;; *) - os=-irix4 + os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; microblaze*) basic_machine=microblaze-xilinx ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) basic_machine=m68000-convergent ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari - os=-mint + os=mint ;; mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; news-3600 | risc-news) basic_machine=mips-sony - os=-newsos + os=newsos ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) + next | m*-next) basic_machine=m68k-next case $os in - -nextstep* ) + nextstep* ) ;; - -ns2*) - os=-nextstep2 + ns2*) + os=nextstep2 ;; *) - os=-nextstep3 + os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) basic_machine=np1-gould ;; @@ -933,40 +1036,26 @@ case $basic_machine in nsr-tandem) basic_machine=nsr-tandem ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki - os=-proelf + os=proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; pa-hitachi) basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux + os=hiuxwe2 ;; parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; pbd) basic_machine=sparc-tti @@ -981,7 +1070,7 @@ case $basic_machine in basic_machine=i386-pc ;; pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc @@ -996,16 +1085,16 @@ case $basic_machine in basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould @@ -1015,43 +1104,27 @@ case $basic_machine in ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; rm[46]00) basic_machine=mips-siemens ;; @@ -1064,10 +1137,6 @@ case $basic_machine in s390x | s390x-*) basic_machine=s390x-ibm ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; sb1) basic_machine=mipsisa64sb1-unknown ;; @@ -1076,32 +1145,17 @@ case $basic_machine in ;; sde) basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux + os=${os:-elf} ;; sequent) basic_machine=i386-sequent ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; sh5el) basic_machine=sh5le-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) + simso-wrs) basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 + os=vxworks ;; spur) basic_machine=spur-unknown @@ -1109,44 +1163,12 @@ case $basic_machine in st2000) basic_machine=m68k-tandem ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; sun3 | sun3-*) basic_machine=m68k-sun ;; @@ -1156,25 +1178,9 @@ case $basic_machine in sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; tile*) basic_machine=$basic_machine-unknown - os=-linux-gnu + os=linux-gnu ;; tx39) basic_machine=mipstx39-unknown @@ -1182,85 +1188,32 @@ case $basic_machine in tx39el) basic_machine=mipstx39el-unknown ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; tower | tower-32) basic_machine=m68k-ncr ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; w65*) basic_machine=w65-wdc - os=-none + os=none ;; w89k-*) basic_machine=hppa1.1-winbond - os=-proelf + os=proelf ;; - xbox) - basic_machine=i686-pc - os=-mingw32 + x64) + basic_machine=x86_64-pc ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; none) basic_machine=none-none - os=-none + os=${os:-none} ;; # Here we handle the default manufacturer of certain CPU types. It is in @@ -1286,10 +1239,6 @@ case $basic_machine in vax) basic_machine=vax-dec ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; pdp11) basic_machine=pdp11-dec ;; @@ -1299,9 +1248,6 @@ case $basic_machine in sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; cydra) basic_machine=cydra-cydrome ;; @@ -1321,7 +1267,7 @@ case $basic_machine in # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac @@ -1329,10 +1275,10 @@ esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; @@ -1340,197 +1286,246 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if [ x$os != x ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux ;; - -solaris1 | -solaris1.*) + bluegene*) + os=cnk + ;; + solaris1 | solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; - -solaris) - os=-solaris2 + solaris) + os=solaris2 ;; - -svr4*) - os=-sysv4 + unixware*) + os=sysv4.2uw ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) + gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose + ;; + # Some version numbers need modification + chorusos*) + os=chorusos + ;; + isc) + os=isc2.2 + ;; + sco6) + os=sco5v6 + ;; + sco5) + os=sco3.2v5 + ;; + sco4) + os=sco3.2v4 + ;; + sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + ;; + sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + scout) + # Don't match below + ;; + sco*) + os=sco3.2v2 + ;; + psos*) + os=psos + ;; + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Each alternative MUST end in a * to match a version number. + # sysv* is not here because it comes later, after sysvr4. + gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | kopensolaris* | plan9* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \ + | knetbsd* | mirbsd* | netbsd* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* \ + | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \ + | linux-newlib* | linux-musl* | linux-uclibc* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* \ + | morphos* | superux* | rtmk* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; - -qnx*) + qnx*) case $basic_machine in x86-* | i*86-*) ;; *) - os=-nto$os + os=nto-$os ;; esac ;; - -nto-qnx*) + hiux*) + os=hiuxwe2 ;; - -nto*) + nto-qnx*) + ;; + nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + sim | xray | os68k* | v88r* \ + | windows* | osx | abug | netware* | os9* \ + | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + linux-dietlibc) + os=linux-dietlibc ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) + linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + lynx*178) + os=lynxos178 ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + lynx*5) + os=lynxos5 ;; - -opened*) - os=-openedition + lynx*) + os=lynxos ;; - -os400*) - os=-os400 + mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` ;; - -wince*) - os=-wince + opened*) + os=openedition ;; - -osfrose*) - os=-osfrose + os400*) + os=os400 ;; - -osf*) - os=-osf + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; - -utek*) - os=-bsd + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; - -dynix*) - os=-bsd + wince*) + os=wince ;; - -acis*) - os=-aos + utek*) + os=bsd ;; - -atheos*) - os=-atheos + dynix*) + os=bsd ;; - -syllable*) - os=-syllable + acis*) + os=aos ;; - -386bsd) - os=-bsd + atheos*) + os=atheos ;; - -ctix* | -uts*) - os=-sysv + syllable*) + os=syllable ;; - -nova*) - os=-rtmk-nova + 386bsd) + os=bsd ;; - -ns2 ) - os=-nextstep2 + ctix* | uts*) + os=sysv ;; - -nsk*) - os=-nsk + nova*) + os=rtmk-nova + ;; + ns2) + os=nextstep2 + ;; + nsk*) + os=nsk ;; # Preserve the version number of sinix5. - -sinix5.*) + sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; - -sinix*) - os=-sysv4 + sinix*) + os=sysv4 ;; - -tpf*) - os=-tpf + tpf*) + os=tpf ;; - -triton*) - os=-sysv3 + triton*) + os=sysv3 ;; - -oss*) - os=-sysv3 + oss*) + os=sysv3 ;; - -svr4) - os=-sysv4 + svr4*) + os=sysv4 ;; - -svr3) - os=-sysv3 + svr3) + os=sysv3 ;; - -sysvr4) - os=-sysv4 + sysvr4) + os=sysv4 ;; - # This must come after -sysvr4. - -sysv*) + # This must come after sysvr4. + sysv*) ;; - -ose*) - os=-ose + ose*) + os=ose ;; - -es1800*) - os=-ose + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -xenix) - os=-xenix + zvmoe) + os=zvmoe ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + dicos*) + os=dicos ;; - -aros*) - os=-aros + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; - -zvmoe) - os=-zvmoe + nacl*) ;; - -dicos*) - os=-dicos + ios) ;; - -nacl*) + none) ;; - -none) + *-eabi) ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1548,176 +1543,179 @@ else case $basic_machine in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + os=linux ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 + ;; + pru-*) + os=elf ;; *-be) - os=-beos - ;; - *-haiku) - os=-haiku + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs + os=luna ;; *-next) - os=-nextstep3 + os=nextstep + ;; + *-sequent) + os=ptx + ;; + *-crds) + os=unos + ;; + *-ns) + os=genix + ;; + i370-*) + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac fi @@ -1728,79 +1726,82 @@ vendor=unknown case $basic_machine in *-unknown) case $os in - -riscix*) + riscix*) vendor=acorn ;; - -sunos*) + sunos*) vendor=sun ;; - -cnk*|-aix*) + cnk*|-aix*) vendor=ibm ;; - -beos*) + beos*) vendor=be ;; - -hpux*) + hpux*) vendor=hp ;; - -mpeix*) + mpeix*) vendor=hp ;; - -hiux*) + hiux*) vendor=hitachi ;; - -unos*) + unos*) vendor=crds ;; - -dgux*) + dgux*) vendor=dg ;; - -luna*) + luna*) vendor=omron ;; - -genix*) + genix*) vendor=ns ;; - -mvs* | -opened*) + clix*) + vendor=intergraph + ;; + mvs* | opened*) vendor=ibm ;; - -os400*) + os400*) vendor=ibm ;; - -ptx*) + ptx*) vendor=sequent ;; - -tpf*) + tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + vxsim* | vxworks* | windiss*) vendor=wrs ;; - -aux*) + aux*) vendor=apple ;; - -hms*) + hms*) vendor=hitachi ;; - -mpw* | -macos*) + mpw* | macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) vendor=atari ;; - -vos*) + vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$basic_machine-$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/libpcap/configure b/libpcap/configure index c4a883842..9a8c1588f 100755 --- a/libpcap/configure +++ b/libpcap/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69. +# Generated by GNU Autoconf 2.69 for pcap 1.9.0-PRE-GIT. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -575,12 +575,12 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= -PACKAGE_URL= +PACKAGE_NAME='pcap' +PACKAGE_TARNAME='pcap' +PACKAGE_VERSION='1.9.0-PRE-GIT' +PACKAGE_STRING='pcap 1.9.0-PRE-GIT' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' ac_unique_file="pcap.c" # Factoring default headers for most tests. @@ -623,28 +623,40 @@ ac_subst_vars='LTLIBOBJS INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM -PCAP_SUPPORT_PACKET_RING +RDMA_SRC +PCAP_SUPPORT_RDMASNIFF DBUS_SRC PCAP_SUPPORT_DBUS PKGCONFIG BT_MONITOR_SRC BT_SRC PCAP_SUPPORT_BT +NETMAP_SRC +PCAP_SUPPORT_NETMAP NETFILTER_SRC PCAP_SUPPORT_NETFILTER USB_SRC PCAP_SUPPORT_USB +EXTRA_NETWORK_LIBS +RPCAPD_LIBS +INSTALL_RPCAPD +BUILD_RPCAPD +PTHREAD_LIBS +MAN_ADMIN_COMMANDS MAN_MISC_INFO MAN_FILE_FORMATS DYEXT SSRC ADDLARCHIVEOBJS ADDLOBJS +V_YACC V_RPATH_OPT V_SONAME_OPT V_SHLIB_OPT V_SHLIB_CMD +V_SHLIB_CCOPT V_PCAP +V_LEX V_INCLS V_FINDALLDEVS V_DEFS @@ -654,8 +666,13 @@ DEPENDENCY_CFLAG LN_S AR RANLIB -HAVE_LINUX_TPACKET_AUXDATA -VALGRINDTEST +YFLAGS +YACC +LEXLIB +LEX_OUTPUT_ROOT +LEX +PCAP_SUPPORT_PACKET_RING +VALGRINDTEST_SRC LIBOBJS EGREP GREP @@ -699,7 +716,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -728,9 +744,8 @@ enable_protochain with_sita with_pcap with_libnl +enable_packet_ring enable_ipv6 -enable_optimizer_dbg -enable_yydebug with_dag with_dag_includes with_dag_libraries @@ -739,12 +754,16 @@ with_snf with_snf_includes with_snf_libraries with_turbocap +enable_remote +enable_optimizer_dbg +enable_yydebug enable_universal enable_shared enable_usb +enable_netmap enable_bluetooth enable_dbus -enable_packet_ring +enable_rdma ' ac_precious_vars='build_alias host_alias @@ -754,7 +773,9 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP' +CPP +YACC +YFLAGS' # Initialize some variables set by options. @@ -793,10 +814,9 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' @@ -1046,15 +1066,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1192,7 +1203,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1305,7 +1316,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 this package to adapt to many kinds of systems. +\`configure' configures pcap 1.9.0-PRE-GIT to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1345,7 +1356,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1354,7 +1364,7 @@ Fine tuning of the installation directories: --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --docdir=DIR documentation root [DATAROOTDIR/doc/pcap] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1371,7 +1381,9 @@ _ACEOF fi if test -n "$ac_init_help"; then - + case $ac_init_help in + short | recursive ) echo "Configuration of pcap 1.9.0-PRE-GIT:";; + esac cat <<\_ACEOF Optional Features: @@ -1380,16 +1392,25 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-largefile omit support for large files --disable-protochain disable \"protochain\" insn - --enable-ipv6 build IPv6-capable version [default=yes, if - getaddrinfo available] + --enable-packet-ring enable packet ring support on Linux [default=yes] + --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 OS X - --enable-shared build shared libraries [default=no] - --enable-usb enable nusb support [default=no] - --enable-bluetooth enable Bluetooth support [default=no] - --enable-dbus enable D-Bus capture support [default=no] - --enable-packet-ring enable Linux packet ring support [default=yes] + --disable-universal don't build universal on macOS + --enable-shared build shared libraries [default=yes, if support + available] + --enable-usb enable USB capture support [default=yes, if support + available] + --enable-netmap enable netmap support [default=yes, if support + available] + --enable-bluetooth enable Bluetooth support [default=yes, if support + available] + --enable-dbus enable D-Bus capture support [default=yes, if + support available] + --enable-rdma enable RDMA capture support [default=yes, if support + available] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1397,7 +1418,8 @@ Optional Packages: --without-gcc don't use gcc --with-sita include SITA support --with-pcap=TYPE use packet capture TYPE - --without-libnl disable libnl support [default=disabled] + --without-libnl disable libnl support [default=yes, on Linux, if + present] --with-dag[=DIR] include Endace DAG support (located in directory DIR, if supplied). [default=yes, if present] --with-dag-includes=IDIR @@ -1425,6 +1447,12 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor + YACC The `Yet Another Compiler Compiler' implementation to use. + Defaults to the first program found out of: `bison -y', `byacc', + `yacc'. + YFLAGS The list of arguments that will be passed by default to $YACC. + This script will default YFLAGS to the empty string to avoid a + default value of `-d' given by some make applications. Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1492,7 +1520,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -configure +pcap configure 1.9.0-PRE-GIT generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1544,6 +1572,52 @@ fi } # ac_fn_c_try_compile +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +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$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\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 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; } && { + 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 : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + 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_link + # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -1741,106 +1815,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - 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 - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -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_type - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -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$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\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 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; } && { - 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 : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - 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_link - # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -1953,11 +1927,122 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + 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 + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +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_type + +# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES +# ---------------------------------------------------- +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_c_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $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 () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $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 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 $as_me, which was +It was created by pcap $as_me 1.9.0-PRE-GIT, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2306,6 +2391,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -2519,6 +2606,10 @@ fi export CC fi +# +# Try to enable as many C99 features as we can. +# At minimum, we want C++/C99-style // comments. +# ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -3308,6 +3399,183 @@ 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 +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 + + @@ -3355,8 +3623,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -fvisibility=hidden" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -fvisibility=hidden" + fi else @@ -3416,8 +3723,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -fvisibility=hidden" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -fvisibility=hidden" + fi else @@ -3539,8 +3885,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -xldscope=hidden" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -xldscope=hidden" + fi else @@ -3597,7 +3982,7 @@ $as_echo "#define const /**/" >>confdefs.h # On platforms where we build a shared library: # # add options to generate position-independent code, - # if necessary (it's the default in AIX and Darwin/OS X); + # if necessary (it's the default in AIX and Darwin/macOS); # # define option to set the soname of the shared library, # if the OS supports that; @@ -3635,13 +4020,13 @@ $as_echo "#define const /**/" >>confdefs.h esac ;; esac - V_CCOPT="$V_CCOPT $PIC_OPT" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT" V_SONAME_OPT="-Wl,-soname," V_RPATH_OPT="-Wl,-rpath," ;; hpux*) - V_CCOPT="$V_CCOPT -fpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # # XXX - this assumes GCC is using the HP linker, # rather than the GNU linker, and that the "+h" @@ -3657,7 +4042,7 @@ $as_echo "#define const /**/" >>confdefs.h ;; solaris*) - V_CCOPT="$V_CCOPT -fpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # # XXX - this assumes GCC is using the Sun linker, # rather than the GNU linker. @@ -3672,7 +4057,7 @@ $as_echo "#define const /**/" >>confdefs.h # where we build a shared library: # # add options to generate position-independent code, - # if necessary (it's the default in Darwin/OS X); + # if necessary (it's the default in Darwin/macOS); # # if we generate ".so" shared libraries, define the # appropriate options for building the shared library; @@ -3698,7 +4083,7 @@ $as_echo "#define const /**/" >>confdefs.h # # "cc" is GCC. # - V_CCOPT="$V_CCOPT -fpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-Wl,-soname," @@ -3706,7 +4091,7 @@ $as_echo "#define const /**/" >>confdefs.h ;; hpux*) - V_CCOPT="$V_CCOPT +z" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT +z" V_SHLIB_CMD="\$(LD)" V_SHLIB_OPT="-b" V_SONAME_OPT="+h " @@ -3729,7 +4114,7 @@ $as_echo "#define const /**/" >>confdefs.h ;; solaris*) - V_CCOPT="$V_CCOPT -Kpic" + V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-G" V_SONAME_OPT="-h " @@ -3801,140 +4186,277 @@ cat >>confdefs.h <<_ACEOF _ACEOF -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5 -$as_echo_n "checking for __attribute__... " >&6; } -if ${ac_cv___attribute__+:} false; then : +# +# Try to arrange for large file support. +# +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then : + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $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 - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - - -#include - -static void foo(void) __attribute__ ((noreturn)); - -static void -foo(void) -{ - exit(1); -} - +#include + /* Check that off_t can represent 2**63 - 1 correctly. + 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 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; int -main(int argc, char **argv) +main () { - foo(); -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv___attribute__=yes -else - ac_cv___attribute__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -if test "$ac_cv___attribute__" = "yes"; then - -$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h - -else - # - # We can't use __attribute__, so we can't use __attribute__((unused)), - # so we define _U_ to an empty string. - # - V_DEFS="$V_DEFS -D_U_=\"\"" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5 -$as_echo "$ac_cv___attribute__" >&6; } - -if test "$ac_cv___attribute__" = "yes"; then - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((unused)) can be used without warnings" >&5 -$as_echo_n "checking whether __attribute__((unused)) can be used without warnings... " >&6; } -if ${ac_cv___attribute___unused+:} false; then : - $as_echo_n "(cached) " >&6 -else - -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -#include -#include - -int -main(int argc __attribute((unused)), char **argv __attribute((unused))) -{ - printf("Hello, world!\n"); + ; return 0; } - _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv___attribute___unused=yes -else - ac_cv___attribute___unused=no + if ac_fn_c_try_compile "$LINENO"; then : + break fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_largefile_CC=' -n32'; break fi - -CFLAGS="$save_CFLAGS" -if test "$ac_cv___attribute___unused" = "yes"; then - V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" -else - V_DEFS="$V_DEFS -D_U_=\"\"" +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___unused" >&5 -$as_echo "$ac_cv___attribute___unused" >&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 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((format)) can be used without warnings" >&5 -$as_echo_n "checking whether __attribute__((format)) can be used without warnings... " >&6; } -if ${ac_cv___attribute___format+:} false; then : + { $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 - -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - - -#include - -extern int foo(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); - +#include + /* Check that off_t can represent 2**63 - 1 correctly. + 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 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; int -main(int argc, char **argv) +main () { - foo("%s", "test"); -} + ; + return 0; +} _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - ac_cv___attribute___format=yes -else - ac_cv___attribute___format=no + ac_cv_sys_file_offset_bits=no; break fi 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 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + 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 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +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.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $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) ;; + *) +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 + { $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. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + 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 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +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.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + 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 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +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.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $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) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi + + fi -CFLAGS="$save_CFLAGS" -if test "$ac_cv___attribute___format" = "yes"; then +{ $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 () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +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$ac_exeext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGEFILE_SOURCE 1 +#include /* for off_t */ + #include +int +main () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +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$ac_exeext conftest.$ac_ext + ac_cv_sys_largefile_source=unknown + break +done +fi +{ $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) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF +;; +esac +rm -rf conftest* -$as_echo "#define __ATTRIBUTE___FORMAT_OK 1" >>confdefs.h +# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug +# in glibc 2.1.3, but that breaks too many other things. +# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. +if test $ac_cv_sys_largefile_source != unknown; then + +$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___format" >&5 -$as_echo "$ac_cv___attribute___format" >&6; } -fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -4333,397 +4855,7 @@ fi done -for ac_header in sys/bitypes.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "sys/bitypes.h" "ac_cv_header_sys_bitypes_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_bitypes_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_BITYPES_H 1 -_ACEOF - -fi - -done - - -ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -" -if test "x$ac_cv_type_int8_t" = xyes; then : - -else - -$as_echo "#define int8_t signed char" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -" -if test "x$ac_cv_type_u_int8_t" = xyes; then : - -else - -$as_echo "#define u_int8_t unsigned char" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default" -if test "x$ac_cv_type_int16_t" = xyes; then : - -else - -$as_echo "#define int16_t short" >>confdefs.h - - $ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -fi - -ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -" -if test "x$ac_cv_type_u_int16_t" = xyes; then : - -else - -$as_echo "#define u_int16_t unsigned short" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -" -if test "x$ac_cv_type_int32_t" = xyes; then : - -else - -$as_echo "#define int32_t int" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -" -if test "x$ac_cv_type_u_int32_t" = xyes; then : - -else - -$as_echo "#define u_int32_t unsigned int" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -" -if test "x$ac_cv_type_int64_t" = xyes; then : - -else - -$as_echo "#define int64_t long long" >>confdefs.h - -fi - -ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -" -if test "x$ac_cv_type_u_int64_t" = xyes; then : - -else - -$as_echo "#define u_int64_t unsigned long long" >>confdefs.h - -fi - - -# -# Try to arrange for large file support. -# -# Check whether --enable-largefile was given. -if test "${enable_largefile+set}" = set; then : - enableval=$enable_largefile; -fi - -if test "$enable_largefile" != no; then - - { $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 - while :; do - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - 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)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF - if ac_fn_c_try_compile "$LINENO"; then : - break -fi -rm -f core conftest.err conftest.$ac_objext - CC="$CC -n32" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_sys_largefile_CC=' -n32'; break -fi -rm -f core conftest.err conftest.$ac_objext - break - done - CC=$ac_save_CC - rm -f conftest.$ac_ext - fi -fi -{ $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 - - { $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. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - 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)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -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.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _FILE_OFFSET_BITS 64 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - 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)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -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.$ac_ext - ac_cv_sys_file_offset_bits=unknown - break -done -fi -{ $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) ;; - *) -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 - { $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. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - 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)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -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.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _LARGE_FILES 1 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - 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)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -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.$ac_ext - ac_cv_sys_large_files=unknown - break -done -fi -{ $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) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _LARGE_FILES $ac_cv_sys_large_files -_ACEOF -;; -esac -rm -rf conftest* - fi - - -fi - -{ $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 () -{ -int (*fp) (FILE *, off_t, int) = fseeko; - return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); - ; - return 0; -} -_ACEOF -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$ac_exeext conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _LARGEFILE_SOURCE 1 -#include /* for off_t */ - #include -int -main () -{ -int (*fp) (FILE *, off_t, int) = fseeko; - return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); - ; - return 0; -} -_ACEOF -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$ac_exeext conftest.$ac_ext - ac_cv_sys_largefile_source=unknown - break -done -fi -{ $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) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source -_ACEOF -;; -esac -rm -rf conftest* - -# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug -# in glibc 2.1.3, but that breaks too many other things. -# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. -if test $ac_cv_sys_largefile_source != unknown; then - -$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h - -fi - - -for ac_header in sys/ioccom.h sys/select.h sys/sockio.h limits.h +for ac_header in sys/ioccom.h sys/sockio.h limits.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" @@ -4736,25 +4868,12 @@ fi done -for ac_header in linux/types.h +for ac_header in netpacket/packet.h do : - ac_fn_c_check_header_mongrel "$LINENO" "linux/types.h" "ac_cv_header_linux_types_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_types_h" = xyes; then : + 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_LINUX_TYPES_H 1 -_ACEOF - -fi - -done - -for ac_header in linux/if_packet.h netpacket/packet.h netpacket/if_packet.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 +#define HAVE_NETPACKET_PACKET_H 1 _ACEOF fi @@ -4809,50 +4928,6 @@ else $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -for ac_header in netinet/if_ether.h -do : - ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "#include -#include -" -if test "x$ac_cv_header_netinet_if_ether_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NETINET_IF_ETHER_H 1 -_ACEOF - -fi - -done - -if test "$ac_cv_header_netinet_if_ether_h" != yes; then - # - # The simple test didn't work. - # Do we need to include first? - # Unset ac_cv_header_netinet_if_ether_h so we don't - # treat the previous failure as a cached value and - # suppress the next test. - # - { $as_echo "$as_me:${as_lineno-$LINENO}: Rechecking with some additional includes" >&5 -$as_echo "$as_me: Rechecking with some additional includes" >&6;} - unset ac_cv_header_netinet_if_ether_h - for ac_header in netinet/if_ether.h -do : - ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "#include -#include -#include -struct mbuf; -struct rtentry; -#include -" -if test "x$ac_cv_header_netinet_if_ether_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NETINET_IF_ETHER_H 1 -_ACEOF - -fi - -done - fi case "$host_os" in @@ -4923,7 +4998,7 @@ $as_echo "$ac_cv_lbl_gcc_fixincludes" >&6; } fi fi -for ac_func in strerror strlcpy +for ac_func in strerror strerror_r strerror_s strlcpy strlcat do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -4983,78 +5058,62 @@ esac fi +# +# Do we have ffs(), and is it declared in ? +# +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 + # + # We have ffs(); is it declared in ? + # + # This test fails if we don't have or if we do + # but it doesn't declare ffs(). + # + ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" " +#include + +" +if test "x$ac_cv_have_decl_ffs" = xyes; then : + + +$as_echo "#define STRINGS_H_DECLARES_FFS /**/" >>confdefs.h + + +fi + +fi + # # Do this before checking for ether_hostton(), as it's a -# "gethostbyname() -ish function". +# "getaddrinfo()-ish function". # - # Most operating systems have gethostbyname() in the default searched - # libraries (i.e. libc): - # Some OSes (eg. Solaris) place it in libnsl - # Some strange OSes (SINIX) have it in libsocket: - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 -$as_echo_n "checking for library containing gethostbyname... " >&6; } -if ${ac_cv_search_gethostbyname+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$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 gethostbyname (); -int -main () -{ -return gethostbyname (); - ; - return 0; -} -_ACEOF -for ac_lib in '' nsl socket resolv; 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 : - ac_cv_search_gethostbyname=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_gethostbyname+:} false; then : - break -fi -done -if ${ac_cv_search_gethostbyname+:} false; then : + # + # Most operating systems have getaddrinfo() in the default searched + # 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 : else - ac_cv_search_gethostbyname=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 -$as_echo "$ac_cv_search_gethostbyname" >&6; } -ac_res=$ac_cv_search_gethostbyname -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" -fi - - # Unfortunately libsocket sometimes depends on libnsl and - # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. - if test "$ac_cv_search_gethostbyname" = "no" - then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lsocket" >&5 -$as_echo_n "checking for gethostbyname in -lsocket... " >&6; } -if ${ac_cv_lib_socket_gethostbyname+:} false; then : + # + # Not found in the standard system libraries. + # Try libsocket, which requires libnsl. + # + { $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 @@ -5068,93 +5127,54 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char gethostbyname (); +char getaddrinfo (); int main () { -return gethostbyname (); +return getaddrinfo (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_socket_gethostbyname=yes + ac_cv_lib_socket_getaddrinfo=yes else - ac_cv_lib_socket_gethostbyname=no + ac_cv_lib_socket_getaddrinfo=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_socket_gethostbyname" >&5 -$as_echo "$ac_cv_lib_socket_gethostbyname" >&6; } -if test "x$ac_cv_lib_socket_gethostbyname" = xyes; then : - LIBS="-lsocket -lnsl $LIBS" -fi +{ $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 : - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 -$as_echo_n "checking for library containing socket... " >&6; } -if ${ac_cv_search_socket+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$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 socket (); -int -main () -{ -return socket (); - ; - return 0; -} -_ACEOF -for ac_lib in '' socket; 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 : - ac_cv_search_socket=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_socket+:} false; then : - break -fi -done -if ${ac_cv_search_socket+:} false; then : + # + # OK, we found it in libsocket. + # + LIBS="-lsocket -lnsl $LIBS" else - ac_cv_search_socket=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 -$as_echo "$ac_cv_search_socket" >&6; } -ac_res=$ac_cv_search_socket -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 -$as_echo_n "checking for socket in -lsocket... " >&6; } -if ${ac_cv_lib_socket_socket+:} false; then : + # + # We didn't find it. + # + as_fn_error $? "getaddrinfo is required, but wasn't found" "$LINENO" 5 + +fi + + + # + # OK, do we have recvmsg() in libxnet? + # We also link with libsocket and libnsl. + # + { $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="-lsocket -lnsl $LIBS" +LIBS="-lxnet -lsocket -lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -5164,30 +5184,36 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char socket (); +char recvmsg (); int main () { -return socket (); +return recvmsg (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_socket_socket=yes + ac_cv_lib_xnet_recvmsg=yes else - ac_cv_lib_socket_socket=no + ac_cv_lib_xnet_recvmsg=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_socket_socket" >&5 -$as_echo "$ac_cv_lib_socket_socket" >&6; } -if test "x$ac_cv_lib_socket_socket" = xyes; then : - LIBS="-lsocket -lnsl $LIBS" +{ $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. + # + LIBS="-lxnet $LIBS" + fi + fi # DLPI needs putmsg under HPUX so test for -lstr while we're at it @@ -5249,14 +5275,268 @@ fi +# +# Check for reentrant versions of getnetbyname_r(), as provided by +# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). +# If we don't find one, we just use getnetbyname(), which uses +# thread-specific data on many platforms, but doesn't use it on +# NetBSD or OpenBSD, and may not use it on older versions of other +# platforms. +# +# Only do the check if we have a declaration of getnetbyname_r(); +# without it, we can't check which API it has. (We assume that +# if there's a declaration, it has a prototype, so that the API +# can be checked.) +# +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 : + + { $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 () +{ + + struct netent netent_buf; + char buf[1024]; + struct netent *resultp; + int h_errnoval; + + return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval); + + ; + 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; } + +$as_echo "#define HAVE_LINUX_GETNETBYNAME_R 1" >>confdefs.h + + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&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 () +{ + + struct netent netent_buf; + char buf[1024]; + + return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL; + + ; + 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; } + +$as_echo "#define HAVE_SOLARIS_IRIX_GETNETBYNAME_R 1" >>confdefs.h + + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&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 () +{ + + struct netent netent_buf; + struct netent_data net_data; + + return getnetbyname_r((const char *)0, &netent_buf, &net_data); + + ; + 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; } + +$as_echo "#define HAVE_AIX_GETNETBYNAME_R 1" >>confdefs.h + + +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 + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +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!). +# If we don't find one, we just use getprotobyname(), which uses +# thread-specific data on many platforms, but doesn't use it on +# NetBSD or OpenBSD, and may not use it on older versions of other +# platforms. +# +# Only do the check if we have a declaration of getprotobyname_r(); +# without it, we can't check which API it has. (We assume that +# if there's a declaration, it has a prototype, so that the API +# can be checked.) +# +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 : + + { $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 () +{ + + struct protoent protoent_buf; + char buf[1024]; + struct protoent *resultp; + + return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp); + + ; + 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; } + +$as_echo "#define HAVE_LINUX_GETPROTOBYNAME_R 1" >>confdefs.h + + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&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 () +{ + + struct protoent protoent_buf; + char buf[1024]; + + return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL; + + ; + 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; } + +$as_echo "#define HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R 1" >>confdefs.h + + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&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 () +{ + + struct protoent protoent_buf; + struct protoent_data proto_data; + + return getprotobyname_r((const char *)0, &protoent_buf, &proto_data); + + ; + 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; } + +$as_echo "#define HAVE_AIX_GETPROTOBYNAME_R 1" >>confdefs.h + + +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 + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +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(). -# Some might have it, but not declare it in any header file. -# Some might have it, but declare it in . -# Some might have it, but declare it in -# (And some might have it but document it as something declared in -# , although appears to work.) +# Some might have it and declare it in . +# Some might have it and declare it in +# Some might have it and declare it in . +# Some might have it and declare it in . +# Some might have it and declare it in . +# Some might have it and not declare it in any header file. # # Before you is a C compiler. # @@ -5273,20 +5553,135 @@ done if test "$ac_cv_func_ether_hostton" = yes; then # - # OK, we have ether_hostton(). Do we have ? + # OK, we have ether_hostton(). Is it declared in ? # - if test "$ac_cv_header_netinet_if_ether_h" = yes; then + # This test fails if we don't have or if we do + # but it doesn't declare ether_hostton(). + # + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " +#include + +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : + + +$as_echo "#define NET_ETHERNET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h + + +fi + + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then # - # Yes. Does it declare ether_hostton()? + # No, how about , as on Linux? # + # This test fails if we don't have + # or if we do but it doesn't declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " +#include + +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : + + +$as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h + + +fi + + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, how about , as on Solaris 10 + # and later? + # + # This test fails if we don't have + # or if we do but it doesn't declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " +#include + +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : + + +$as_echo "#define SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h + + +fi + + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, how about , as in AIX? + # + # 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 + # declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton + ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " +#include + +" +if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : + + +$as_echo "#define ARPA_INET_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h + + +fi + + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, how about ? + # On some platforms, it requires and + # , and we always include it with + # both of them, so test it with both of them. + # + # This test fails if we don't have + # and the headers we include before it, or if we do but + # doesn't declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " #include #include -#include -#include -struct mbuf; -struct rtentry; #include +#include #include " @@ -5300,63 +5695,27 @@ fi fi # - # Did that succeed? + # After all that, is ether_hostton() declared? # - if test "$ac_cv_have_decl_ether_hostton" != yes; then + if test "$ac_cv_have_decl_ether_hostton" = yes; then # - # No, how about , as on Linux? + # Yes. # - for ac_header in netinet/ether.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "netinet/ether.h" "ac_cv_header_netinet_ether_h" "$ac_includes_default" -if test "x$ac_cv_header_netinet_ether_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NETINET_ETHER_H 1 -_ACEOF -fi +$as_echo "#define HAVE_DECL_ETHER_HOSTTON 1" >>confdefs.h -done - - if test "$ac_cv_header_netinet_ether_h" = yes; then - # - # We have it - does it declare ether_hostton()? - # Unset ac_cv_have_decl_ether_hostton so we don't - # treat the previous failure as a cached value and - # suppress the next test. - # - unset ac_cv_have_decl_ether_hostton - ac_fn_c_check_decl "$LINENO" "ether_hostton" "ac_cv_have_decl_ether_hostton" " -#include - -" -if test "x$ac_cv_have_decl_ether_hostton" = xyes; then : - - -$as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h - - -fi - - fi - fi - # - # Is ether_hostton() declared? - # - if test "$ac_cv_have_decl_ether_hostton" != yes; then + else # # No, we'll have to declare it ourselves. - # Do we have "struct ether_addr"? + # Do we have "struct ether_addr" if we include + # ? # ac_fn_c_check_type "$LINENO" "struct ether_addr" "ac_cv_type_struct_ether_addr" " -#include -#include -#include -#include -struct mbuf; -struct rtentry; -#include -#include + #include + #include + #include + #include + #include " if test "x$ac_cv_type_struct_ether_addr" = xyes; then : @@ -5368,16 +5727,153 @@ _ACEOF fi - -$as_echo "#define HAVE_DECL_ETHER_HOSTTON 0" >>confdefs.h - - else - -$as_echo "#define HAVE_DECL_ETHER_HOSTTON 1" >>confdefs.h - fi fi +# +# For various things that might use pthreads. +# +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 : + + # + # Yes. + # + ac_lbl_have_pthreads="found" + +else + + # + # No - do we have it in -lpthreads? + # + { $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 +/* 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 pthread_create (); +int +main () +{ +return pthread_create (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthreads_pthread_create=yes +else + ac_cv_lib_pthreads_pthread_create=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_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. + # + ac_lbl_have_pthreads="found" + PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads" + +else + + # + # No - do we have it in -lpthread? + # + { $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 +/* 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 pthread_create (); +int +main () +{ +return pthread_create (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthread_pthread_create=yes +else + ac_cv_lib_pthread_pthread_create=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_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. + # + ac_lbl_have_pthreads="found" + PTHREAD_LIBS="$PTHREAD_LIBS -lpthread" + +else + + # + # No. + # + ac_lbl_have_pthreads="not found" + +fi + + +fi + + +fi + + +else + + # + # We didn't find pthread.h. + # + ac_lbl_have_pthreads="not found" + + +fi + + + { $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. @@ -5404,7 +5900,7 @@ $as_echo "${enable_protochain}" >&6; } # only tests with BPF and PF_PACKET sockets; only enable it if # we have BPF or PF_PACKET sockets. # -VALGRINDTEST= +VALGRINDTEST_SRC= # # SITA support is mutually exclusive with native capture support; @@ -5425,80 +5921,209 @@ $as_echo "$as_me: Enabling SITA ACN support" >&6;} else -if test -z "$with_pcap" && test "$cross_compiling" = yes; then - as_fn_error $? "pcap type not determined when cross-compiling; use --with-pcap=..." "$LINENO" 5 -fi # Check whether --with-pcap was given. if test "${with_pcap+set}" = set; then : withval=$with_pcap; fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking packet capture type" >&5 -$as_echo_n "checking packet capture type... " >&6; } if test ! -z "$with_pcap" ; then V_PCAP="$withval" -elif test -r /dev/bpf -o -h /dev/bpf ; then - # - # Cloning BPF device. - # - V_PCAP=bpf - -$as_echo "#define HAVE_CLONING_BPF 1" >>confdefs.h - - - # - # We have BPF, so build valgrindtest with "make test". - # - VALGRINDTEST=valgrindtest -elif test -r /dev/bpf0 ; then - V_PCAP=bpf - - # - # We have BPF, so build valgrindtest with "make test". - # - VALGRINDTEST=valgrindtest -elif test -r /usr/include/net/pfilt.h ; then - V_PCAP=pf -elif test -r /dev/enet ; then - V_PCAP=enet -elif test -r /dev/nit ; then - V_PCAP=snit -elif test -r /usr/include/sys/net/nit.h ; then - V_PCAP=nit -elif test -r /usr/include/linux/socket.h ; then - V_PCAP=linux - - # - # XXX - this won't work with older kernels that have SOCK_PACKET - # sockets but not PF_PACKET sockets. - # - VALGRINDTEST=valgrindtest -elif test -r /usr/include/net/raw.h ; then - V_PCAP=snoop -elif test -r /usr/include/odmi.h ; then - # - # On AIX, the BPF devices might not yet be present - they're - # created the first time libpcap runs after booting. - # We check for odmi.h instead. - # - V_PCAP=bpf -elif test -c /dev/bpf0 ; then # check again in case not readable - V_PCAP=bpf - - # - # We have BPF, so build valgrindtest with "make test". - # - VALGRINDTEST=valgrindtest -elif test -r /usr/include/sys/dlpi.h ; then - V_PCAP=dlpi -elif test -c /dev/enet ; then # check again in case not readable - V_PCAP=enet -elif test -c /dev/nit ; then # check again in case not readable - V_PCAP=snit else - V_PCAP=null + # + # Check for a bunch of headers for various packet + # capture mechanisms. + # + 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? + # I.e., is it a header for an LBL/BSD-style capture + # mechanism, or is it just a header for a BPF filter + # engine? Some versions of Arch Linux, for example, + # have a net/bpf.h that doesn't define BIOCSETIF; + # as it's a Linux, it should use packet sockets, + # instead. + # + # We need: + # + # sys/types.h, because FreeBSD 10's net/bpf.h + # requires that various BSD-style integer types + # be defined; + # + # sys/ioctl.h and, if we have it, sys/ioccom.h, + # because net/bpf.h defines ioctls; + # + # net/if.h, because it defines some structures + # used in ioctls defined by net/bpf.h; + # + # sys/socket.h, because OpenBSD 5.9's net/bpf.h + # defines some structure fields as being + # struct sockaddrs; + # + # and net/bpf.h doesn't necessarily include all + # of those headers itself. + # + { $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. */ + +#include +#include +#include +#ifdef HAVE_SYS_IOCCOM_H +#include +#endif +#include +#include + +int +main () +{ +u_int i = BIOCSETIF; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_lbl_bpf_h_defines_biocsetif=yes +else + ac_cv_lbl_bpf_h_defines_biocsetif=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { $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 + 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 + +done + + 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 + +done + + 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 + +done + + + if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then + # + # BPF. + # Check this before DLPI, so that we pick BPF on + # Solaris 11 and later. + # + V_PCAP=bpf + + # + # We have BPF, so build valgrindtest with "make test" + # on macOS and FreeBSD (add your OS once there's a + # valgrind for it). + # + case "$host_os" in + + freebsd*|darwin*|linux*) + VALGRINDTEST_SRC=valgrindtest.c + ;; + esac + elif test "$ac_cv_header_linux_socket_h" = yes; then + # + # No prizes for guessing this one. + # + V_PCAP=linux + + # + # XXX - this won't work with older kernels that have + # SOCK_PACKET sockets but not PF_PACKET sockets. + # + VALGRINDTEST_SRC=valgrindtest.c + elif test "$ac_cv_header_net_pfilt_h" = yes; then + # + # DEC OSF/1, Digital UNIX, Tru64 UNIX + # + V_PCAP=pf + elif test "$ac_cv_header_net_enet_h" = yes; then + # + # Stanford Enetfilter. + # + V_PCAP=enet + elif test "$ac_cv_header_net_nit_h" = yes; then + # + # SunOS 4.x STREAMS NIT. + # + V_PCAP=snit + elif test "$ac_cv_header_sys_net_nit_h" = yes; then + # + # Pre-SunOS 4.x non-STREAMS NIT. + # + V_PCAP=nit + elif test "$ac_cv_header_net_raw_h" = yes; then + # + # IRIX snoop. + # + V_PCAP=snoop + elif test "$ac_cv_header_sys_dlpi_h" = yes; then + # + # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others. + # + V_PCAP=dlpi + else + # + # Nothing we support. + # + V_PCAP=null + { $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 doc for more info)" >&5 +$as_echo "$as_me: WARNING: (see the INSTALL doc for more info)" >&2;} + fi +fi +{ $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; } @@ -5632,73 +6257,25 @@ $as_echo "$ac_cv_sys_dlpi_usable" >&6; } fi # - # Check whether we have a /dev/dlpi device or have multiple devices. - # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/dlpi device" >&5 -$as_echo_n "checking for /dev/dlpi device... " >&6; } - if test -c /dev/dlpi ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -$as_echo "#define HAVE_DEV_DLPI 1" >>confdefs.h - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - dir="/dev/dlpi" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $dir directory" >&5 -$as_echo_n "checking for $dir directory... " >&6; } - if test -d $dir ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -cat >>confdefs.h <<_ACEOF -#define PCAP_DEV_PREFIX "$dir" -_ACEOF - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - fi - - # - # This check is for Solaris with DLPI support for passive modes. + # Check to see if Solaris has the dl_passive_req_t struct defined + # in . + # This check is for DLPI support for passive modes. # See dlpi(7P) for more details. # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dl_passive_req_t struct exists" >&5 -$as_echo_n "checking if dl_passive_req_t struct exists... " >&6; } - if ${ac_cv_lbl_has_dl_passive_req_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + ac_fn_c_check_type "$LINENO" "dl_passive_req_t" "ac_cv_type_dl_passive_req_t" " + #include + #include -# include -# include -int -main () -{ -u_int i = sizeof(dl_passive_req_t) - ; - return 0; -} +" +if test "x$ac_cv_type_dl_passive_req_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_DL_PASSIVE_REQ_T 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_has_dl_passive_req_t=yes -else - ac_cv_lbl_has_dl_passive_req_t=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_has_dl_passive_req_t" >&5 -$as_echo "$ac_cv_lbl_has_dl_passive_req_t" >&6; } - if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then - -$as_echo "#define HAVE_DLPI_PASSIVE 1" >>confdefs.h - - fi ;; linux) @@ -5730,18 +6307,28 @@ done # Check whether --with-libnl was given. if test "${with_libnl+set}" = set; then : withval=$with_libnl; with_libnl=$withval +else + with_libnl=if_available fi - if test x$with_libnl = xyes ; then + if test x$with_libnl != xno ; then have_any_nl="no" incdir=-I/usr/include/libnl3 libnldir= - if test x$withval != x ; then - libnldir=-L${withval}/lib/.libs - incdir=-I${withval}/include - fi + case "$with_libnl" in + + yes|if_available) + ;; + + *) + if test -d $withval; then + libnldir=-L${withval}/lib/.libs + incdir=-I${withval}/include + fi + ;; + esac # # Try libnl 3.x first. @@ -5951,73 +6538,50 @@ fi done - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if if_packet.h has tpacket_stats defined" >&5 -$as_echo_n "checking if if_packet.h has tpacket_stats defined... " >&6; } - if ${ac_cv_lbl_tpacket_stats+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -# include -int -main () -{ -struct tpacket_stats stats - ; - return 0; -} + # + # Check to see if struct tpacket_stats is defined in + # . If so, then pcap-linux.c can use this + # to report proper statistics. + # + # -Scott Barron + # + ac_fn_c_check_type "$LINENO" "struct tpacket_stats" "ac_cv_type_struct_tpacket_stats" " + #include + +" +if test "x$ac_cv_type_struct_tpacket_stats" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TPACKET_STATS 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_tpacket_stats=yes -else - ac_cv_lbl_tpacket_stats=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_tpacket_stats" >&5 -$as_echo "$ac_cv_lbl_tpacket_stats" >&6; } - if test $ac_cv_lbl_tpacket_stats = yes; then -$as_echo "#define HAVE_TPACKET_STATS 1" >>confdefs.h + # + # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member. + # + # NOTE: any failure means we conclude that it doesn't have that + # member, so if we don't have tpacket_auxdata, we conclude it + # doesn't have that member (which is OK, as either we won't be + # using code that would use that member, or we wouldn't compile + # in any case). + ac_fn_c_check_member "$LINENO" "struct tpacket_auxdata" "tp_vlan_tci" "ac_cv_member_struct_tpacket_auxdata_tp_vlan_tci" " + #include + #include - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if tpacket_auxdata struct has tp_vlan_tci member" >&5 -$as_echo_n "checking if tpacket_auxdata struct has tp_vlan_tci member... " >&6; } - if ${ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +" +if test "x$ac_cv_member_struct_tpacket_auxdata_tp_vlan_tci" = xyes; then : -# include -# include -int -main () -{ -u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci) - ; - return 0; -} +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes -else - ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci" >&5 -$as_echo "$ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci" >&6; } - if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then - HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci - - -$as_echo "#define HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI 1" >>confdefs.h - - fi ;; bpf) @@ -6037,46 +6601,16 @@ fi done - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the system supports zerocopy BPF" >&5 -$as_echo_n "checking whether the system supports zerocopy BPF... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - #include - #include - #include -int -main () -{ -return (BIOCROTZBUF + BPF_BUFMODE_ZBUF); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -$as_echo "#define HAVE_ZEROCOPY_BPF 1" >>confdefs.h - - -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_ext - - # - # Check whether we have struct BPF_TIMEVAL. - # - ac_fn_c_check_type "$LINENO" "struct BPF_TIMEVAL" "ac_cv_type_struct_BPF_TIMEVAL" " -#include -#include -#ifdef HAVE_SYS_IOCCOM_H -#include -#endif -#include + # + # Check whether we have struct BPF_TIMEVAL. + # + ac_fn_c_check_type "$LINENO" "struct BPF_TIMEVAL" "ac_cv_type_struct_BPF_TIMEVAL" " + #include + #include + #ifdef HAVE_SYS_IOCCOM_H + #include + #endif + #include " if test "x$ac_cv_type_struct_BPF_TIMEVAL" = xyes; then : @@ -6118,10 +6652,10 @@ snf) ;; null) - { $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 doc for more info)" >&5 -$as_echo "$as_me: WARNING: (see the INSTALL doc for more info)" >&2;} + ;; + +*) + as_fn_error $? "$V_PCAP is not a valid pcap type" "$LINENO" 5 ;; esac @@ -6163,33 +6697,34 @@ fi else # - # Well, we don't have "getifaddrs()", so we have to use - # some other mechanism; determine what that mechanism is. + # Well, we don't have "getifaddrs()", at least not with the + # libraries with which we've decided we need to link + # libpcap with, so we have to use some other mechanism. # - # The first thing we use is the type of capture mechanism, - # which is somewhat of a proxy for the OS we're using. + # Note that this may happen on Solaris, which has + # getifaddrs(), but in -lsocket, not in -lxnet, so we + # won't find it if we link with -lxnet, which we want + # to do for other reasons. # - case "$V_PCAP" in - - dlpi|libdlpi) - # - # This might be Solaris 8 or later, with - # SIOCGLIFCONF, or it might be some other OS - # or some older version of Solaris, with - # just SIOCGIFCONF. - # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have SIOCGLIFCONF" >&5 + # For now, we use either the SIOCGIFCONF ioctl or the + # SIOCGLIFCONF ioctl, preferring the latter if we have + # it; the latter is a Solarisism that first appeared + # in Solaris 8. (Solaris's getifaddrs() appears to + # be built atop SIOCGLIFCONF; using it directly + # avoids a not-all-that-useful middleman.) + # + { $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 : + 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 - #include - #include - #include - #include + #include + #include + #include + #include int main () { @@ -6206,119 +6741,91 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_have_siocglifconf" >&5 + { $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 - V_FINDALLDEVS=fad-glifc.c - else - V_FINDALLDEVS=fad-gifc.c - fi - ;; - - *) - # - # Assume we just have SIOCGIFCONF. - # (XXX - on at least later Linux kernels, there's - # another mechanism, and we should be using that - # instead.) - # + if test $ac_cv_lbl_have_siocglifconf = yes ; then + V_FINDALLDEVS=fad-glifc.c + else V_FINDALLDEVS=fad-gifc.c - ;; - esac -fi - -fi - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t" >&5 -$as_echo_n "checking for socklen_t... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - #include - -int -main () -{ - socklen_t x; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_socklen_t=yes -else - have_socklen_t=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test "x$have_socklen_t" = "xyes"; then - -$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_socklen_t" >&5 -$as_echo "$have_socklen_t" >&6; } - -# Check whether --enable-ipv6 was given. -if test "${enable_ipv6+set}" = set; then : - enableval=$enable_ipv6; -else - enable_ipv6=ifavailable -fi - -if test "$enable_ipv6" != "no"; then - ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" -if test "x$ac_cv_func_getaddrinfo" = xyes; then : - - -$as_echo "#define INET6 1" >>confdefs.h - - -else - - if test "$enable_ipv6" != "ifavailable"; 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 $? "--enable-ipv6 was given, but getaddrinfo isn't available -See \`config.log' for more details" "$LINENO" 5; } fi fi fi -{ $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+set}" = set; then : - enableval=$enable_optimizer_dbg; fi -if test "$enable_optimizer_dbg" = "yes"; then -$as_echo "#define BDEBUG 1" >>confdefs.h +case "$host_os" in +linux*) + 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 -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_optimizer_dbg-no}" >&5 -$as_echo "${enable_optimizer_dbg-no}" >&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+set}" = set; then : - enableval=$enable_yydebug; +done + + ;; +*) + { $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 + +# Check whether --enable-packet-ring was given. +if test "${enable_packet_ring+set}" = set; then : + enableval=$enable_packet_ring; +else + enable_packet_ring=yes fi -if test "$enable_yydebug" = "yes"; then -$as_echo "#define YYDEBUG 1" >>confdefs.h +if test "x$enable_packet_ring" != "xno" ; then + +$as_echo "#define PCAP_SUPPORT_PACKET_RING 1" >>confdefs.h + + +fi + +# +# Check for socklen_t. +# +ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " + #include + #include + +" +if test "x$ac_cv_type_socklen_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_SOCKLEN_T 1 +_ACEOF + + +fi + + +# Check whether --enable-ipv6 was given. +if test "${enable_ipv6+set}" = set; then : + enableval=$enable_ipv6; +else + enable_ipv6=yes +fi + +if test "$enable_ipv6" != "no"; then + # + # We've already made sure we have getaddrinfo above in + # AC_LBL_LIBRARY_NET. + # + +$as_echo "#define INET6 1" >>confdefs.h fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_yydebug-no}" >&5 -$as_echo "${enable_yydebug-no}" >&6; } # Check for Endace DAG card support. @@ -6381,12 +6888,8 @@ if test "${with_dag_libraries+set}" = set; then : fi -ac_cv_lbl_dag_api=no if test "$want_dag" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have DAG API headers" >&5 -$as_echo_n "checking whether we have DAG API headers... " >&6; } - # If necessary, set default paths for DAG API headers and libraries. if test -z "$dag_root"; then dag_root=/usr/local @@ -6400,25 +6903,28 @@ $as_echo_n "checking whether we have DAG API headers... " >&6; } dag_lib_dir="$dag_root/lib" fi - if test -z "$dag_tools_dir"; then - dag_tools_dir="$dag_root/tools" - fi + V_INCLS="$V_INCLS -I$dag_include_dir" - if test -r $dag_include_dir/dagapi.h; then - ac_cv_lbl_dag_api=yes - fi + 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 - if test "$ac_cv_lbl_dag_api" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($dag_include_dir)" >&5 -$as_echo "yes ($dag_include_dir)" >&6; } +fi - V_INCLS="$V_INCLS -I$dag_include_dir" +done + + + if test "$ac_cv_header_dagapi_h" = yes; then if test $V_PCAP != dag ; then SSRC="$SSRC pcap-dag.c" fi - # See if we can find a general version string. + # 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). saved_ldflags=$LDFLAGS @@ -6460,9 +6966,56 @@ fi { $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 : - dag_streams="1" + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBDAG 1 +_ACEOF + + LIBS="-ldag $LIBS" + else - dag_streams="0" + as_fn_error $? "DAG library lacks streams support" "$LINENO" 5 +fi + + { $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 +/* 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 dag_attach_stream64 (); +int +main () +{ +return dag_attach_stream64 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dag_dag_attach_stream64=yes +else + ac_cv_lib_dag_dag_attach_stream64=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_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 + dag_large_streams="0" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_erf_types in -ldag" >&5 @@ -6554,12 +7107,17 @@ fi LDFLAGS=$saved_ldflags - if test "$dag_streams" = 1; then + # + # 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" -$as_echo "#define HAVE_DAG_STREAMS_API 1" >>confdefs.h + if test "$dag_large_streams" = 1; then - LIBS="$LIBS -ldag" - LDFLAGS="$LDFLAGS -L$dag_lib_dir" +$as_echo "#define HAVE_DAG_LARGE_STREAMS_API 1" >>confdefs.h { $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; } @@ -6607,7 +7165,10 @@ fi $as_echo "#define HAVE_DAG_VDAG 1" >>confdefs.h - LIBS="$LIBS -lpthread" + 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" fi fi @@ -6615,8 +7176,6 @@ $as_echo "#define HAVE_DAG_VDAG 1" >>confdefs.h $as_echo "#define HAVE_DAG_API 1" >>confdefs.h else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } if test "$V_PCAP" = dag; then # User requested "dag" capture type but we couldn't @@ -6972,14 +7531,452 @@ $as_echo "no" >&6; } fi fi +{ $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+set}" = set; then : + enableval=$enable_remote; +else + enableval=no +fi + +case "$enableval" in +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. + # + if test "$ac_lbl_have_pthreads" != "found"; then + as_fn_error $? "rpcapd requires pthreads, but we didn't find them" "$LINENO" 5 + fi + # + # It also requires crypt(). + # 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 : + +else + + # + # No. Do we have it in -lcrypt? + # + { $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 +/* 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 crypt (); +int +main () +{ +return crypt (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_crypt_crypt=yes +else + ac_cv_lib_crypt_crypt=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_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_fn_error $? "rpcapd requires crypt(), but we didn't find it" "$LINENO" 5 + +fi + + +fi + + + # + # OK, we have crypt(). Do we have getspnam()? + # + 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 + + + # + # Check for various members of struct msghdr. + # + ac_fn_c_check_member "$LINENO" "struct msghdr" "msg_control" "ac_cv_member_struct_msghdr_msg_control" " + #include \"ftmacros.h\" + #include + +" +if test "x$ac_cv_member_struct_msghdr_msg_control" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1 +_ACEOF + + +fi + + ac_fn_c_check_member "$LINENO" "struct msghdr" "msg_flags" "ac_cv_member_struct_msghdr_msg_flags" " + #include \"ftmacros.h\" + #include + +" +if test "x$ac_cv_member_struct_msghdr_msg_flags" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 1 +_ACEOF + + +fi + + + +$as_echo "#define ENABLE_REMOTE /**/" >>confdefs.h + + SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c" + BUILD_RPCAPD=build-rpcapd + INSTALL_RPCAPD=install-rpcapd + ;; +*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; +esac + +{ $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+set}" = set; then : + enableval=$enable_optimizer_dbg; +fi + +if test "$enable_optimizer_dbg" = "yes"; then + +$as_echo "#define BDEBUG 1" >>confdefs.h + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_optimizer_dbg-no}" >&5 +$as_echo "${enable_optimizer_dbg-no}" >&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+set}" = set; then : + enableval=$enable_yydebug; +fi + +if test "$enable_yydebug" = "yes"; then + +$as_echo "#define YYDEBUG 1" >>confdefs.h + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_yydebug-no}" >&5 +$as_echo "${enable_yydebug-no}" >&6; } + # -# Assume, by default, no support for shared libraries and V7/BSD convention -# for man pages (file formats in section 5, miscellaneous info in section 7). +# Look for {f}lex. +# +for ac_prog in flex lex +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; 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_prog_LEX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else +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_prog_LEX="$ac_prog" + $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 + +fi +fi +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5 +$as_echo "$LEX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$LEX" && break +done +test -n "$LEX" || LEX=":" + +if test "x$LEX" != "x:"; then + cat >conftest.l <<_ACEOF +%% +a { ECHO; } +b { REJECT; } +c { yymore (); } +d { yyless (1); } +e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */ + yyless ((input () != 0)); } +f { unput (yytext[0]); } +. { BEGIN INITIAL; } +%% +#ifdef YYTEXT_POINTER +extern char *yytext; +#endif +int +main (void) +{ + return ! yylex () + ! yywrap (); +} +_ACEOF +{ { ac_try="$LEX conftest.l" +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 "$LEX conftest.l") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5 +$as_echo_n "checking lex output file root... " >&6; } +if ${ac_cv_prog_lex_root+:} false; then : + $as_echo_n "(cached) " >&6 +else + +if test -f lex.yy.c; then + ac_cv_prog_lex_root=lex.yy +elif test -f lexyy.c; then + ac_cv_prog_lex_root=lexyy +else + as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5 +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5 +$as_echo "$ac_cv_prog_lex_root" >&6; } +LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root + +if test -z "${LEXLIB+set}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5 +$as_echo_n "checking lex library... " >&6; } +if ${ac_cv_lib_lex+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ac_save_LIBS=$LIBS + ac_cv_lib_lex='none needed' + for ac_lib in '' -lfl -ll; do + LIBS="$ac_lib $ac_save_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_lex=$ac_lib +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + test "$ac_cv_lib_lex" != 'none needed' && break + done + LIBS=$ac_save_LIBS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5 +$as_echo "$ac_cv_lib_lex" >&6; } + test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5 +$as_echo_n "checking whether yytext is a pointer... " >&6; } +if ${ac_cv_prog_lex_yytext_pointer+:} false; then : + $as_echo_n "(cached) " >&6 +else + # POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +ac_cv_prog_lex_yytext_pointer=no +ac_save_LIBS=$LIBS +LIBS="$LEXLIB $ac_save_LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define YYTEXT_POINTER 1 +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_prog_lex_yytext_pointer=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_save_LIBS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5 +$as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; } +if test $ac_cv_prog_lex_yytext_pointer = yes; then + +$as_echo "#define YYTEXT_POINTER 1" >>confdefs.h + +fi +rm -f conftest.l $LEX_OUTPUT_ROOT.c + +fi +if test "$LEX" = ":"; then + as_fn_error $? "Neither flex nor lex was found." "$LINENO" 5 +fi + +# +# Make sure {f}lex supports the -P, --header-file, and --nounput flags +# and supports processing our scanner.l. +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable lex" >&5 +$as_echo_n "checking for capable lex... " >&6; } +if ${tcpdump_cv_capable_lex+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then + tcpdump_cv_capable_lex=yes + else + tcpdump_cv_capable_lex=insufficient + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_lex" >&5 +$as_echo "$tcpdump_cv_capable_lex" >&6; } +if test $tcpdump_cv_capable_lex = insufficient ; then + as_fn_error $? "$LEX is insufficient to compile libpcap. + libpcap requires Flex 2.5.31 or later, or a compatible version of lex." "$LINENO" 5 +fi + +# +# Look for yacc/bison/byacc. +# +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; 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_prog_YACC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +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_prog_YACC="$ac_prog" + $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 + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 +$as_echo "$YACC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + + +# +# Make sure it supports the -p flag and supports processing our +# grammar.y. +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc/bison" >&5 +$as_echo_n "checking for capable yacc/bison... " >&6; } +if ${tcpdump_cv_capable_yacc+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then + tcpdump_cv_capable_yacc=yes + else + tcpdump_cv_capable_yacc=insufficient + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_yacc" >&5 +$as_echo "$tcpdump_cv_capable_yacc" >&6; } +if test $tcpdump_cv_capable_yacc = insufficient ; then + as_fn_error $? "$YACC 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." "$LINENO" 5 +fi + +# +# Do various checks for various OSes and versions of those OSes. +# +# Assume, by default, no support for shared libraries and V7/BSD +# convention for man pages (file formats in section 5, miscellaneous +# info in section 7, administrative commands and daemons in section 8). # Individual cases can override this. # DYEXT="none" MAN_FILE_FORMATS=5 MAN_MISC_INFO=7 +MAN_ADMIN_COMMANDS=8 case "$host_os" in aix*) @@ -7124,6 +8121,7 @@ $as_echo "#define HAVE_HPUX9 1" >>confdefs.h # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -7133,6 +8131,7 @@ hpux10.0*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -7142,6 +8141,7 @@ hpux10.1*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -7171,7 +8171,9 @@ $as_echo "#define HAVE_HPUX10_20_OR_LATER 1" >>confdefs.h irix*) # - # Use System V conventions for man pages. + # Use IRIX conventions for man pages; they're the same as the + # System V conventions, except that they use section 8 for + # administrative commands and daemons. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 @@ -7193,7 +8195,10 @@ osf*) DYEXT="so" # - # Use System V conventions for man pages. + # DEC OSF/1, a/k/a Digial 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. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 @@ -7239,11 +8244,30 @@ $as_echo "#define HAVE_SOLARIS 1" >>confdefs.h DYEXT="so" + # - # Use System V conventions for man pages. + # Make sure errno is thread-safe, in case we're called in + # a multithreaded program. We don't guarantee that two + # threads can use the *same* pcap_t safely, but the + # current version does guarantee that you can use different + # pcap_t's in different threads, and even that pcap_compile() + # is thread-safe (it wasn't thread-safe in some older versions). # - MAN_FILE_FORMATS=4 - MAN_MISC_INFO=5 + V_CCOPT="$V_CCOPT -D_TS_ERRNO" + + case "`uname -r`" in + + 5.12) + ;; + + *) + # + # Use System V conventions for man pages. + # + MAN_ADMIN_COMMANDS=1m + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + esac ;; esac @@ -7252,7 +8276,7 @@ if test "${enable_shared+set}" = set; then : enableval=$enable_shared; fi -test "x$enable_shared" != "xyes" && DYEXT="none" +test "x$enable_shared" = "xno" && 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. @@ -7528,8 +8552,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -Wall" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wall" + fi else @@ -7571,8 +8634,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -Wsign-compare" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wsign-compare" + fi else @@ -7614,8 +8716,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -Wmissing-prototypes" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wmissing-prototypes" + fi else @@ -7657,8 +8798,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -Wstrict-prototypes" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wstrict-prototypes" + fi else @@ -7700,8 +8880,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -Wshadow" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wshadow" + fi else @@ -7743,8 +8962,47 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wdeclaration-after-statement " >&5 +$as_echo_n "checking whether -Wdeclaration-after-statement ... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -Wdeclaration-after-statement" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wdeclaration-after-statement" + fi else @@ -7786,8 +9044,655 @@ if ac_fn_c_try_compile "$LINENO"; then : { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi CFLAGS="$save_CFLAGS" - V_CCOPT="$V_CCOPT -Wused-but-marked-unused" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wused-but-marked-unused" + fi + +else + + { $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.$ac_ext + + + { $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 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wdocumentation" + fi + +else + + { $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.$ac_ext + + + { $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 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wcomma" + fi + +else + + { $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.$ac_ext + + + { $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 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wmissing-noreturn" + fi + +else + + { $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.$ac_ext + + # Warns about safeguards added in case the enums are + # extended + # AC_LBL_CHECK_COMPILER_OPT(V_CCOPT, -Wcovered-switch-default) + + { $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 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wmissing-variable-declarations" + fi + +else + + { $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.$ac_ext + + + { $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 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wunused-parameter" + fi + +else + + { $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.$ac_ext + + + { $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 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wformat-nonliteral" + fi + +else + + { $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.$ac_ext + + # + # This can cause problems with ntohs(), ntohl(), + # htons(), and htonl() on some platforms, such + # as OpenBSD 6.3 with Clang 5.0.1. I guess the + # problem is that the macro that ultimately does + # the byte-swapping involves a conditional + # expression that tests whether the value being + # swapped is a compile-time constant or not, + # using __builtin_constant_p(), and, depending + # on whether it is, does a compile-time swap or + # a run-time swap; perhaps the compiler always + # considers one of the two results of the + # conditional expressin is never evaluated, + # because the conditional check is done at + # compile time, and thus always says "that + # expression is never executed". + # + # (Perhaps there should be a way of flagging + # an expression that you *want* evaluated at + # compile time, so that the compiler 1) warns + # if it *can't* be evaluated at compile time + # and 2) *doesn't* warn that the true or false + # branch will never be reached.) + # + + { $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 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + { $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 + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. + # + if test "xgenerates warnings from ntohs()" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $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 + +unsigned short +testme(unsigned short a) +{ + return ntohs(a); +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +else + + # + # A problem. + # + { $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.$ac_ext + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -Wunreachable-code" + fi else @@ -7870,8 +9775,11 @@ $as_echo_n "checking whether the compiler supports generating dependencies... " /* end confdefs.h. */ int main(void) { return 0; } _ACEOF - echo "$CC" $ac_lbl_dependency_flag conftest.c >&5 - if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then + 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=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then { $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" @@ -7883,7 +9791,7 @@ $as_echo "no" >&6; } # We can't run mkdep, so have "make depend" do # nothing. # - MKDEP=: + MKDEP='${srcdir}/nomkdep' fi rm -rf conftest* else @@ -7893,7 +9801,7 @@ $as_echo "no" >&6; } # We can't run mkdep, so have "make depend" do # nothing. # - MKDEP=: + MKDEP='${srcdir}/nomkdep' fi @@ -7919,108 +9827,68 @@ $as_echo "$as_me: WARNING: can't find $name" >&2;} fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr struct has the sa_len member" >&5 -$as_echo_n "checking if sockaddr struct has the sa_len member... " >&6; } - if ${ac_cv_lbl_sockaddr_has_sa_len+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +# +# Check to see if the sockaddr struct has the 4.4 BSD sa_len member. +# +ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" " + #include + #include -# include -# include -int -main () -{ -u_int i = sizeof(((struct sockaddr *)0)->sa_len) - ; - return 0; -} +" +if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_SA_LEN 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_sockaddr_has_sa_len=yes -else - ac_cv_lbl_sockaddr_has_sa_len=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_sockaddr_has_sa_len" >&5 -$as_echo "$ac_cv_lbl_sockaddr_has_sa_len" >&6; } - if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then -$as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h +# +# Check to see if there's a sockaddr_storage structure. +# +ac_fn_c_check_type "$LINENO" "struct sockaddr_storage" "ac_cv_type_struct_sockaddr_storage" " + #include + #include - fi +" +if test "x$ac_cv_type_struct_sockaddr_storage" = xyes; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr_storage struct exists" >&5 -$as_echo_n "checking if sockaddr_storage struct exists... " >&6; } - if ${ac_cv_lbl_has_sockaddr_storage+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# include -# include -int -main () -{ -u_int i = sizeof (struct sockaddr_storage) - ; - return 0; -} +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_has_sockaddr_storage=yes -else - ac_cv_lbl_has_sockaddr_storage=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_has_sockaddr_storage" >&5 -$as_echo "$ac_cv_lbl_has_sockaddr_storage" >&6; } - if test $ac_cv_lbl_has_sockaddr_storage = yes ; then -$as_echo "#define HAVE_SOCKADDR_STORAGE 1" >>confdefs.h +# +# Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00 +# dl_module_id_1 member. +# +# NOTE: any failure means we conclude that it doesn't have that member, +# so if we don't have DLPI, don't have a header, or +# have one that doesn't declare a dl_hp_ppa_info_t type, we conclude +# it doesn't have that member (which is OK, as either we won't be +# using code that would use that member, or we wouldn't compile in +# any case). +# +ac_fn_c_check_member "$LINENO" "dl_hp_ppa_info_t" "dl_module_id_1" "ac_cv_member_dl_hp_ppa_info_t_dl_module_id_1" " + #include + #include + #include - fi +" +if test "x$ac_cv_member_dl_hp_ppa_info_t_dl_module_id_1" = xyes; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5 -$as_echo_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member... " >&6; } - if ${ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# include -# include -# include -int -main () -{ -u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1) - ; - return 0; -} +cat >>confdefs.h <<_ACEOF +#define HAVE_DL_HP_PPA_INFO_T_DL_MODULE_ID_1 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes -else - ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" >&5 -$as_echo "$ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" >&6; } - if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then - -$as_echo "#define HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1" >>confdefs.h - - fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if unaligned accesses fail" >&5 $as_echo_n "checking if unaligned accesses fail... " >&6; } @@ -8117,8 +9985,14 @@ $as_echo "#define LBL_ALIGN 1" >>confdefs.h fi -rm -f net -ln -s ${srcdir}/bpf/net net + + + + + + + + @@ -8140,7 +10014,7 @@ ln -s ${srcdir}/bpf/net net if test "${enable_usb+set}" = set; then : enableval=$enable_usb; else - enable_usb=no + enable_usb=yes fi @@ -8226,45 +10100,23 @@ done # "value", rather than "bRequestType", "bRequest", and # "wValue". # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if usbdevfs_ctrltransfer struct has bRequestType member" >&5 -$as_echo_n "checking if usbdevfs_ctrltransfer struct has bRequestType member... " >&6; } - if ${ac_cv_usbdevfs_ctrltransfer_has_bRequestType+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + ac_fn_c_check_member "$LINENO" "struct usbdevfs_ctrltransfer" "bRequestType" "ac_cv_member_struct_usbdevfs_ctrltransfer_bRequestType" " + $ac_includes_default + #ifdef HAVE_LINUX_COMPILER_H + #include + #endif + #include -$ac_includes_default -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -#ifdef HAVE_LINUX_COMPILER_H -#include -#endif -#include -int -main () -{ -u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType) - ; - return 0; -} +" +if test "x$ac_cv_member_struct_usbdevfs_ctrltransfer_bRequestType" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes -else - ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_usbdevfs_ctrltransfer_has_bRequestType" >&5 -$as_echo "$ac_cv_usbdevfs_ctrltransfer_has_bRequestType" >&6; } - if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then - -$as_echo "#define HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1" >>confdefs.h - - fi fi ;; freebsd*) @@ -8352,11 +10204,66 @@ fi +# Check whether --enable-netmap was given. +if test "${enable_netmap+set}" = set; then : + enableval=$enable_netmap; +else + enable_netmap=yes +fi + + +if test "x$enable_netmap" != "xno" ; then + # + # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is + # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS + # is defined, for example, as it includes a non-existent malloc.h + # header. + # + { $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. */ + +$ac_includes_default +#define NETMAP_WITH_LIBS +#include +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_net_netmap_user_can_compile=yes +else + ac_cv_net_netmap_user_can_compile=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { $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 + +$as_echo "#define PCAP_SUPPORT_NETMAP 1" >>confdefs.h + + NETMAP_SRC=pcap-netmap.c + fi + + +fi + + # Check whether --enable-bluetooth was given. if test "${enable_bluetooth+set}" = set; then : enableval=$enable_bluetooth; else - enable_bluetooth=no + enable_bluetooth=ifsupportavailable fi @@ -8372,112 +10279,102 @@ if test "x$enable_bluetooth" != "xno" ; 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. + # $as_echo "#define PCAP_SUPPORT_BT 1" >>confdefs.h - BT_SRC=pcap-bt-linux.c - { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is supported" >&5 + BT_SRC=pcap-bt-linux.c + { $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 - # - # OK, does struct sockaddr_hci have an hci_channel - # member? - # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct sockaddr_hci has hci_channel member" >&5 -$as_echo_n "checking if struct sockaddr_hci has hci_channel member... " >&6; } - if ${ac_cv_lbl_sockaddr_hci_has_hci_channel+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + # + # OK, does struct sockaddr_hci have an hci_channel + # member? + # + ac_fn_c_check_member "$LINENO" "struct sockaddr_hci" "hci_channel" "ac_cv_member_struct_sockaddr_hci_hci_channel" " + #include + #include -#include -#include +" +if test "x$ac_cv_member_struct_sockaddr_hci_hci_channel" = xyes; then : -int -main () -{ -u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel) - ; - return 0; -} +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_sockaddr_hci_has_hci_channel=yes -else - ac_cv_lbl_sockaddr_hci_has_hci_channel=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_sockaddr_hci_has_hci_channel" >&5 -$as_echo "$ac_cv_lbl_sockaddr_hci_has_hci_channel" >&6; } - if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then - -$as_echo "#define SOCKADDR_HCI_HAS_HCI_CHANNEL /**/" >>confdefs.h - # - # OK, is HCI_CHANNEL_MONITOR defined? - # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if HCI_CHANNEL_MONITOR is defined" >&5 + # + # Yes; is HCI_CHANNEL_MONITOR defined? + # + { $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 : + 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. */ -#include -#include + #include + #include int main () { -u_int i = HCI_CHANNEL_MONITOR + + u_int i = HCI_CHANNEL_MONITOR; + ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_lbl_hci_channel_monitor_is_defined=yes -else - ac_cv_lbl_hci_channel_monitor_is_defined=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_hci_channel_monitor_is_defined" >&5 -$as_echo "$ac_cv_lbl_hci_channel_monitor_is_defined" >&6; } - if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } $as_echo "#define PCAP_SUPPORT_BT_MONITOR /**/" >>confdefs.h - BT_MONITOR_SRC=pcap-bt-monitor-linux.c - fi - fi - ac_lbl_bluetooth_available=yes + BT_MONITOR_SRC=pcap-bt-monitor-linux.c else - ac_lbl_bluetooth_available=no + + { $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_ext +fi + fi - if test "x$ac_lbl_bluetooth_available" == "xno" ; then - 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 - { $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5 +else + + # + # We don't have bluetooth.h, so we don't support + # Bluetooth sniffing. + # + 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 + { $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 + fi + +fi + + ;; *) if test "x$enable_bluetooth" = "xyes" ; then - as_fn_error $? "no Bluetooth sniffing support implemented for $host_os" "$LINENO" 5 + as_fn_error $? "no Bluetooth sniffing support implemented for $host_os" "$LINENO" 5 else - { $as_echo "$as_me:${as_lineno-$LINENO}: no Bluetooth sniffing support implemented for $host_os" >&5 + { $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 ;; @@ -8491,7 +10388,7 @@ fi if test "${enable_dbus+set}" = set; then : enableval=$enable_dbus; else - enable_dbus=no + enable_dbus=ifavailable fi @@ -8507,20 +10404,20 @@ if test "x$enable_dbus" != "xno"; then darwin*) # - # We don't support D-Bus sniffing on OS X; see + # We don't support D-Bus sniffing on macOS; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # # The user requested it, so fail. # - as_fn_error $? "Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X" "$LINENO" 5 + as_fn_error $? "Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS" "$LINENO" 5 esac else case "$host_os" in darwin*) # - # We don't support D-Bus sniffing on OS X; see + # We don't support D-Bus sniffing on macOS; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # @@ -8637,38 +10534,117 @@ $as_echo "no" >&6; } fi -case "$host_os" in -linux*) - 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 - - ;; -*) - { $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 - -# Check whether --enable-packet-ring was given. -if test "${enable_packet_ring+set}" = set; then : - enableval=$enable_packet_ring; +# Check whether --enable-rdma was given. +if test "${enable_rdma+set}" = set; then : + enableval=$enable_rdma; else - enable_packet_ring=yes + enable_rdmasniff=ifavailable fi -if test "x$enable_packet_ring" != "xno" ; then +if test "xxx_only" = yes; then + # User requested something-else-only pcap, so they don't + # want RDMA support. + enable_rdmasniff=no +fi + +if test "x$enable_rdmasniff" != "xno"; 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 +/* 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 ibv_get_device_list (); +int +main () +{ +return ibv_get_device_list (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ibverbs_ibv_get_device_list=yes +else + ac_cv_lib_ibverbs_ibv_get_device_list=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_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_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 + # function in infiniband/verbs.h, so we can't + # use AC_CHECK_LIB. + # + # Too bad autoconf has no AC_SYMBOL_EXISTS() + # macro that works like CMake's check_symbol_exists() + # function, to check do a compile check like + # this (they do a clever trick to avoid having + # to know the function's signature). + # + { $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) ibv_create_flow((struct ibv_qp *) NULL, + (struct ibv_flow_attr *) NULL); + + ; + 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; } + +$as_echo "#define PCAP_SUPPORT_RDMASNIFF /**/" >>confdefs.h + + RDMA_SRC=pcap-rdmasniff.c + LIBS="-libverbs $LIBS" + +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 + +fi + + + +fi -$as_echo "#define PCAP_SUPPORT_PACKET_RING 1" >>confdefs.h fi @@ -8772,7 +10748,7 @@ ac_config_headers="$ac_config_headers config.h" ac_config_commands="$ac_config_commands default-1" -ac_config_files="$ac_config_files Makefile 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_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap" +ac_config_files="$ac_config_files Makefile 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_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap rpcapd/Makefile rpcapd/rpcapd.manadmin testprogs/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -9280,7 +11256,7 @@ 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 $as_me, which was +This file was extended by pcap $as_me 1.9.0-PRE-GIT, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -9346,7 +11322,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -config.status +pcap config.status 1.9.0-PRE-GIT configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -9491,6 +11467,9 @@ do "pcap_open_offline.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_open_offline.3pcap" ;; "pcap_set_tstamp_precision.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_set_tstamp_precision.3pcap" ;; "pcap_set_tstamp_type.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_set_tstamp_type.3pcap" ;; + "rpcapd/Makefile") CONFIG_FILES="$CONFIG_FILES rpcapd/Makefile" ;; + "rpcapd/rpcapd.manadmin") CONFIG_FILES="$CONFIG_FILES rpcapd/rpcapd.manadmin" ;; + "testprogs/Makefile") CONFIG_FILES="$CONFIG_FILES testprogs/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac @@ -10048,7 +12027,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} case $ac_file$ac_mode in "default-1":C) if test -f .devel; then echo timestamp > stamp-h - cat Makefile-devel-adds >> Makefile + cat $srcdir/Makefile-devel-adds >> Makefile make depend fi ;; diff --git a/libpcap/configure.ac b/libpcap/configure.ac index 21e2b5fc3..eff6eb897 100644 --- a/libpcap/configure.ac +++ b/libpcap/configure.ac @@ -14,80 +14,23 @@ dnl # config.sub. # -AC_PREREQ(2.61) -AC_INIT(pcap.c) +AC_PREREQ(2.64) + +AC_INIT(pcap, m4_esyscmd_s([cat VERSION])) +AC_CONFIG_SRCDIR(pcap.c) +AC_SUBST(PACKAGE_NAME) AC_CANONICAL_SYSTEM AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS) -AC_PROG_CC +# +# Try to enable as many C99 features as we can. +# At minimum, we want C++/C99-style // comments. +# +AC_PROG_CC_C99 AC_LBL_C_INIT(V_CCOPT, V_INCLS) AC_LBL_SHLIBS_INIT AC_LBL_C_INLINE -AC_C___ATTRIBUTE__ -if test "$ac_cv___attribute__" = "yes"; then - AC_C___ATTRIBUTE___UNUSED - AC_C___ATTRIBUTE___FORMAT -fi - -AC_CHECK_HEADERS(sys/bitypes.h) - -AC_CHECK_TYPE([int8_t], , - [AC_DEFINE([int8_t], [signed char], - [Define to `signed char' if int8_t not defined.])], - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) -AC_CHECK_TYPE([u_int8_t], , - [AC_DEFINE([u_int8_t], [unsigned char], - [Define to `unsigned char' if u_int8_t not defined.])], - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) -AC_CHECK_TYPE([int16_t], , - [AC_DEFINE([int16_t], [short], - [Define to `short' if int16_t not defined.])] - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) -AC_CHECK_TYPE([u_int16_t], , - [AC_DEFINE([u_int16_t], [unsigned short], - [Define to `unsigned short' if u_int16_t not defined.])], - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) -AC_CHECK_TYPE([int32_t], , - [AC_DEFINE([int32_t], [int], - [Define to `int' if int32_t not defined.])], - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) -AC_CHECK_TYPE([u_int32_t], , - [AC_DEFINE([u_int32_t], [unsigned int], - [Define to `unsigned int' if u_int32_t not defined.])], - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) -AC_CHECK_TYPE([int64_t], , - [AC_DEFINE([int64_t], [long long], - [Define to `long long' if int64_t not defined.])], - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) -AC_CHECK_TYPE([u_int64_t], , - [AC_DEFINE([u_int64_t], [unsigned long long], - [Define to `unsigned long long' if u_int64_t not defined.])], - [AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif]) # # Try to arrange for large file support. @@ -104,9 +47,8 @@ dnl in "aclocal.m4" uses it, so we would still have to test for it dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris. dnl -AC_CHECK_HEADERS(sys/ioccom.h sys/select.h sys/sockio.h limits.h) -AC_CHECK_HEADERS(linux/types.h) -AC_CHECK_HEADERS(linux/if_packet.h netpacket/packet.h netpacket/if_packet.h) +AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h) +AC_CHECK_HEADERS(netpacket/packet.h) AC_CHECK_HEADERS(net/pfvar.h, , , [#include #include #include ]) @@ -128,25 +70,6 @@ if test "$ac_cv_header_net_pfvar_h" = yes; then ], AC_MSG_RESULT(no)) fi -AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include -#include ]) -if test "$ac_cv_header_netinet_if_ether_h" != yes; then - # - # The simple test didn't work. - # Do we need to include first? - # Unset ac_cv_header_netinet_if_ether_h so we don't - # treat the previous failure as a cached value and - # suppress the next test. - # - AC_MSG_NOTICE([Rechecking with some additional includes]) - unset ac_cv_header_netinet_if_ether_h - AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include -#include -#include -struct mbuf; -struct rtentry; -#include ]) -fi case "$host_os" in linux*|uclinux*) @@ -160,7 +83,7 @@ esac AC_LBL_FIXINCLUDES -AC_CHECK_FUNCS(strerror strlcpy) +AC_CHECK_FUNCS(strerror strerror_r strerror_s strlcpy strlcat) needsnprintf=no AC_CHECK_FUNCS(vsnprintf snprintf,, @@ -176,32 +99,299 @@ if test $needstrtok_r = yes; then AC_LIBOBJ([strtok_r]) fi +# +# Do we have ffs(), and is it declared in ? +# +AC_CHECK_FUNCS(ffs) +if test "$ac_cv_func_ffs" = yes; then + # + # We have ffs(); is it declared in ? + # + # This test fails if we don't have or if we do + # but it doesn't declare ffs(). + # + AC_CHECK_DECL(ffs, + [ + AC_DEFINE(STRINGS_H_DECLARES_FFS,, + [Define to 1 if strings.h declares `ffs']) + ],, + [ +#include + ]) +fi + # # Do this before checking for ether_hostton(), as it's a -# "gethostbyname() -ish function". +# "getaddrinfo()-ish function". # AC_LBL_LIBRARY_NET +# +# Check for reentrant versions of getnetbyname_r(), as provided by +# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). +# If we don't find one, we just use getnetbyname(), which uses +# thread-specific data on many platforms, but doesn't use it on +# NetBSD or OpenBSD, and may not use it on older versions of other +# platforms. +# +# Only do the check if we have a declaration of getnetbyname_r(); +# without it, we can't check which API it has. (We assume that +# if there's a declaration, it has a prototype, so that the API +# can be checked.) +# +AC_CHECK_DECL(getnetbyname_r, + [ + AC_MSG_CHECKING([for the Linux getnetbyname_r()]) + AC_TRY_LINK( + [#include ], + [ + struct netent netent_buf; + char buf[1024]; + struct netent *resultp; + int h_errnoval; + + return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval); + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1, + [define if we have the Linux getnetbyname_r()]) + ], + [ + AC_MSG_RESULT(no) + + AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()]) + AC_TRY_LINK( + [#include ], + [ + struct netent netent_buf; + char buf[1024]; + + return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL; + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1, + [define if we have the Solaris/IRIX getnetbyname_r()]) + ], + [ + AC_MSG_RESULT(no) + + AC_MSG_CHECKING([for AIX getnetbyname_r()]) + AC_TRY_LINK( + [#include ], + [ + struct netent netent_buf; + struct netent_data net_data; + + return getnetbyname_r((const char *)0, &netent_buf, &net_data); + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1, + [define if we have the AIX getnetbyname_r()]) + ], + [ + AC_MSG_RESULT(no) + ]) + ]) + ]) + ],,[#include ]) + +# +# Check for reentrant versions of getprotobyname_r(), as provided by +# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). +# If we don't find one, we just use getprotobyname(), which uses +# thread-specific data on many platforms, but doesn't use it on +# NetBSD or OpenBSD, and may not use it on older versions of other +# platforms. +# +# Only do the check if we have a declaration of getprotobyname_r(); +# without it, we can't check which API it has. (We assume that +# if there's a declaration, it has a prototype, so that the API +# can be checked.) +# +AC_CHECK_DECL(getprotobyname_r, + [ + AC_MSG_CHECKING([for the Linux getprotobyname_r()]) + AC_TRY_LINK( + [#include ], + [ + struct protoent protoent_buf; + char buf[1024]; + struct protoent *resultp; + + return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp); + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1, + [define if we have the Linux getprotobyname_r()]) + ], + [ + AC_MSG_RESULT(no) + + AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()]) + AC_TRY_LINK( + [#include ], + [ + struct protoent protoent_buf; + char buf[1024]; + + return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL; + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1, + [define if we have the Solaris/IRIX getprotobyname_r()]) + ], + [ + AC_MSG_RESULT(no) + + AC_MSG_CHECKING([for AIX getprotobyname_r()]) + AC_TRY_LINK( + [#include ], + [ + struct protoent protoent_buf; + struct protoent_data proto_data; + + return getprotobyname_r((const char *)0, &protoent_buf, &proto_data); + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1, + [define if we have the AIX getprotobyname_r()]) + ], + [ + AC_MSG_RESULT(no) + ]) + ]) + ]) + ],,[#include ]) + # # You are in a twisty little maze of UN*Xes, all different. # Some might not have ether_hostton(). -# Some might have it, but not declare it in any header file. -# Some might have it, but declare it in . -# Some might have it, but declare it in -# (And some might have it but document it as something declared in -# , although appears to work.) +# Some might have it and declare it in . +# Some might have it and declare it in +# Some might have it and declare it in . +# Some might have it and declare it in . +# Some might have it and declare it in . +# Some might have it and not declare it in any header file. # # Before you is a C compiler. # AC_CHECK_FUNCS(ether_hostton) if test "$ac_cv_func_ether_hostton" = yes; then # - # OK, we have ether_hostton(). Do we have ? + # OK, we have ether_hostton(). Is it declared in ? # - if test "$ac_cv_header_netinet_if_ether_h" = yes; then + # This test fails if we don't have or if we do + # but it doesn't declare ether_hostton(). + # + AC_CHECK_DECL(ether_hostton, + [ + AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,, + [Define to 1 if net/ethernet.h declares `ether_hostton']) + ],, + [ +#include + ]) + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then # - # Yes. Does it declare ether_hostton()? + # No, how about , as on Linux? # + # This test fails if we don't have + # or if we do but it doesn't declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton + AC_CHECK_DECL(ether_hostton, + [ + AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,, + [Define to 1 if netinet/ether.h declares `ether_hostton']) + ],, + [ +#include + ]) + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, how about , as on Solaris 10 + # and later? + # + # This test fails if we don't have + # or if we do but it doesn't declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton + AC_CHECK_DECL(ether_hostton, + [ + AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,, + [Define to 1 if sys/ethernet.h declares `ether_hostton']) + ],, + [ +#include + ]) + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, how about , as in AIX? + # + # 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 + # declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton + AC_CHECK_DECL(ether_hostton, + [ + AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,, + [Define to 1 if arpa/inet.h declares `ether_hostton']) + ],, + [ +#include + ]) + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, how about ? + # On some platforms, it requires and + # , and we always include it with + # both of them, so test it with both of them. + # + # This test fails if we don't have + # and the headers we include before it, or if we do but + # doesn't declare ether_hostton(). + # + # Unset ac_cv_have_decl_ether_hostton so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_ether_hostton AC_CHECK_DECL(ether_hostton, [ AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,, @@ -210,69 +400,94 @@ if test "$ac_cv_func_ether_hostton" = yes; then [ #include #include -#include -#include -struct mbuf; -struct rtentry; #include +#include #include ]) fi # - # Did that succeed? + # After all that, is ether_hostton() declared? # - if test "$ac_cv_have_decl_ether_hostton" != yes; then + if test "$ac_cv_have_decl_ether_hostton" = yes; then # - # No, how about , as on Linux? + # Yes. # - AC_CHECK_HEADERS(netinet/ether.h) - if test "$ac_cv_header_netinet_ether_h" = yes; then - # - # We have it - does it declare ether_hostton()? - # Unset ac_cv_have_decl_ether_hostton so we don't - # treat the previous failure as a cached value and - # suppress the next test. - # - unset ac_cv_have_decl_ether_hostton - AC_CHECK_DECL(ether_hostton, - [ - AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,, - [Define to 1 if netinet/ether.h declares `ether_hostton']) - ],, - [ -#include - ]) - fi - fi - # - # Is ether_hostton() declared? - # - if test "$ac_cv_have_decl_ether_hostton" != yes; then + AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1, + [Define to 1 if you have the declaration of `ether_hostton']) + else # # No, we'll have to declare it ourselves. - # Do we have "struct ether_addr"? + # Do we have "struct ether_addr" if we include + # ? # AC_CHECK_TYPES(struct ether_addr,,, [ -#include -#include -#include -#include -struct mbuf; -struct rtentry; -#include -#include + #include + #include + #include + #include + #include ]) - AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 0, - [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you -don't.]) - else - AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1, - [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you -don't.]) fi fi +# +# For various things that might use pthreads. +# +AC_CHECK_HEADER(pthread.h, + [ + # + # OK, we have pthread.h. Do we have pthread_create in the + # system libraries? + # + AC_CHECK_FUNC(pthread_create, + [ + # + # Yes. + # + ac_lbl_have_pthreads="found" + ], + [ + # + # No - do we have it in -lpthreads? + # + AC_CHECK_LIB(pthreads, pthread_create, + [ + # + # Yes - add -lpthreads. + # + ac_lbl_have_pthreads="found" + PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads" + ], + [ + # + # No - do we have it in -lpthread? + # + AC_CHECK_LIB(pthread, pthread_create, + [ + # + # Yes - add -lpthread. + # + ac_lbl_have_pthreads="found" + PTHREAD_LIBS="$PTHREAD_LIBS -lpthread" + ], + [ + # + # No. + # + ac_lbl_have_pthreads="not found" + ]) + ]) + ]) + ], + [ + # + # We didn't find pthread.h. + # + ac_lbl_have_pthreads="not found" + ] +) + dnl to pacify those who hate protochain insn AC_MSG_CHECKING(if --disable-protochain option is specified) AC_ARG_ENABLE(protochain, @@ -293,7 +508,7 @@ AC_MSG_RESULT(${enable_protochain}) # only tests with BPF and PF_PACKET sockets; only enable it if # we have BPF or PF_PACKET sockets. # -VALGRINDTEST= +VALGRINDTEST_SRC= # # SITA support is mutually exclusive with native capture support; @@ -309,83 +524,139 @@ AC_HELP_STRING([--with-sita],[include SITA support]), fi ], [ -dnl -dnl Not all versions of test support -c (character special) but it's a -dnl better way of testing since the device might be protected. So we -dnl check in our normal order using -r and then check the for the /dev -dnl guys again using -c. -dnl -dnl XXX This could be done for cross-compiling, but for now it's not. -dnl -if test -z "$with_pcap" && test "$cross_compiling" = yes; then - AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...) -fi AC_ARG_WITH(pcap, AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE])) -AC_MSG_CHECKING(packet capture type) if test ! -z "$with_pcap" ; then V_PCAP="$withval" -elif test -r /dev/bpf -o -h /dev/bpf ; then - # - # Cloning BPF device. - # - V_PCAP=bpf - AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device]) - - # - # We have BPF, so build valgrindtest with "make test". - # - VALGRINDTEST=valgrindtest -elif test -r /dev/bpf0 ; then - V_PCAP=bpf - - # - # We have BPF, so build valgrindtest with "make test". - # - VALGRINDTEST=valgrindtest -elif test -r /usr/include/net/pfilt.h ; then - V_PCAP=pf -elif test -r /dev/enet ; then - V_PCAP=enet -elif test -r /dev/nit ; then - V_PCAP=snit -elif test -r /usr/include/sys/net/nit.h ; then - V_PCAP=nit -elif test -r /usr/include/linux/socket.h ; then - V_PCAP=linux - - # - # XXX - this won't work with older kernels that have SOCK_PACKET - # sockets but not PF_PACKET sockets. - # - VALGRINDTEST=valgrindtest -elif test -r /usr/include/net/raw.h ; then - V_PCAP=snoop -elif test -r /usr/include/odmi.h ; then - # - # On AIX, the BPF devices might not yet be present - they're - # created the first time libpcap runs after booting. - # We check for odmi.h instead. - # - V_PCAP=bpf -elif test -c /dev/bpf0 ; then # check again in case not readable - V_PCAP=bpf - - # - # We have BPF, so build valgrindtest with "make test". - # - VALGRINDTEST=valgrindtest -elif test -r /usr/include/sys/dlpi.h ; then - V_PCAP=dlpi -elif test -c /dev/enet ; then # check again in case not readable - V_PCAP=enet -elif test -c /dev/nit ; then # check again in case not readable - V_PCAP=snit else - V_PCAP=null + # + # Check for a bunch of headers for various packet + # capture mechanisms. + # + AC_CHECK_HEADERS(net/bpf.h) + if test "$ac_cv_header_net_bpf_h" = yes; then + # + # Does it define BIOCSETIF? + # I.e., is it a header for an LBL/BSD-style capture + # mechanism, or is it just a header for a BPF filter + # engine? Some versions of Arch Linux, for example, + # have a net/bpf.h that doesn't define BIOCSETIF; + # as it's a Linux, it should use packet sockets, + # instead. + # + # We need: + # + # sys/types.h, because FreeBSD 10's net/bpf.h + # requires that various BSD-style integer types + # be defined; + # + # sys/ioctl.h and, if we have it, sys/ioccom.h, + # because net/bpf.h defines ioctls; + # + # net/if.h, because it defines some structures + # used in ioctls defined by net/bpf.h; + # + # sys/socket.h, because OpenBSD 5.9's net/bpf.h + # defines some structure fields as being + # struct sockaddrs; + # + # and net/bpf.h doesn't necessarily include all + # of those headers itself. + # + AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF) + AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif, + AC_TRY_COMPILE( +[ +#include +#include +#include +#ifdef HAVE_SYS_IOCCOM_H +#include +#endif +#include +#include +], + [u_int i = BIOCSETIF;], + ac_cv_lbl_bpf_h_defines_biocsetif=yes, + ac_cv_lbl_bpf_h_defines_biocsetif=no)) + AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif) + fi + AC_CHECK_HEADERS(net/pfilt.h net/enet.h) + AC_CHECK_HEADERS(net/nit.h sys/net/nit.h) + AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h) + + if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then + # + # BPF. + # Check this before DLPI, so that we pick BPF on + # Solaris 11 and later. + # + V_PCAP=bpf + + # + # We have BPF, so build valgrindtest with "make test" + # on macOS and FreeBSD (add your OS once there's a + # valgrind for it). + # + case "$host_os" in + + freebsd*|darwin*|linux*) + VALGRINDTEST_SRC=valgrindtest.c + ;; + esac + elif test "$ac_cv_header_linux_socket_h" = yes; then + # + # No prizes for guessing this one. + # + V_PCAP=linux + + # + # XXX - this won't work with older kernels that have + # SOCK_PACKET sockets but not PF_PACKET sockets. + # + VALGRINDTEST_SRC=valgrindtest.c + elif test "$ac_cv_header_net_pfilt_h" = yes; then + # + # DEC OSF/1, Digital UNIX, Tru64 UNIX + # + V_PCAP=pf + elif test "$ac_cv_header_net_enet_h" = yes; then + # + # Stanford Enetfilter. + # + V_PCAP=enet + elif test "$ac_cv_header_net_nit_h" = yes; then + # + # SunOS 4.x STREAMS NIT. + # + V_PCAP=snit + elif test "$ac_cv_header_sys_net_nit_h" = yes; then + # + # Pre-SunOS 4.x non-STREAMS NIT. + # + V_PCAP=nit + elif test "$ac_cv_header_net_raw_h" = yes; then + # + # IRIX snoop. + # + V_PCAP=snoop + elif test "$ac_cv_header_sys_dlpi_h" = yes; then + # + # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others. + # + V_PCAP=dlpi + else + # + # Nothing we support. + # + V_PCAP=null + AC_MSG_WARN(cannot determine packet capture interface) + AC_MSG_WARN((see the INSTALL doc for more info)) + fi fi +AC_MSG_CHECKING(packet capture type) AC_MSG_RESULT($V_PCAP) -AC_SUBST(VALGRINDTEST) +AC_SUBST(VALGRINDTEST_SRC) # # Do capture-mechanism-dependent tests. @@ -445,29 +716,16 @@ dlpi) fi # - # Check whether we have a /dev/dlpi device or have multiple devices. - # - AC_MSG_CHECKING(for /dev/dlpi device) - if test -c /dev/dlpi ; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_DEV_DLPI, 1, [define if you have a /dev/dlpi]) - else - AC_MSG_RESULT(no) - dir="/dev/dlpi" - AC_MSG_CHECKING(for $dir directory) - if test -d $dir ; then - AC_MSG_RESULT(yes) - AC_DEFINE_UNQUOTED(PCAP_DEV_PREFIX, "$dir", [/dev/dlpi directory]) - else - AC_MSG_RESULT(no) - fi - fi - - # - # This check is for Solaris with DLPI support for passive modes. + # Check to see if Solaris has the dl_passive_req_t struct defined + # in . + # This check is for DLPI support for passive modes. # See dlpi(7P) for more details. # - AC_LBL_DL_PASSIVE_REQ_T + AC_CHECK_TYPES(dl_passive_req_t,,, + [ + #include + #include + ]) ;; linux) @@ -485,18 +743,26 @@ linux) # Do we have libnl? # AC_ARG_WITH(libnl, - AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=disabled@:>@]), - with_libnl=$withval,,) + AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]), + with_libnl=$withval,with_libnl=if_available) - if test x$with_libnl = xyes ; then + if test x$with_libnl != xno ; then have_any_nl="no" incdir=-I/usr/include/libnl3 libnldir= - if test x$withval != x ; then - libnldir=-L${withval}/lib/.libs - incdir=-I${withval}/include - fi + case "$with_libnl" in + + yes|if_available) + ;; + + *) + if test -d $withval; then + libnldir=-L${withval}/lib/.libs + incdir=-I${withval}/include + fi + ;; + esac # # Try libnl 3.x first. @@ -563,8 +829,32 @@ linux) AC_INCLUDES_DEFAULT #include ]) - AC_LBL_TPACKET_STATS - AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI + + # + # Check to see if struct tpacket_stats is defined in + # . If so, then pcap-linux.c can use this + # to report proper statistics. + # + # -Scott Barron + # + AC_CHECK_TYPES(struct tpacket_stats,,, + [ + #include + ]) + + # + # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member. + # + # NOTE: any failure means we conclude that it doesn't have that + # member, so if we don't have tpacket_auxdata, we conclude it + # doesn't have that member (which is OK, as either we won't be + # using code that would use that member, or we wouldn't compile + # in any case). + AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,, + [ + #include + #include + ]) ;; bpf) @@ -573,32 +863,18 @@ bpf) # AC_CHECK_HEADERS(net/if_media.h) - AC_MSG_CHECKING(whether the system supports zerocopy BPF) - AC_TRY_COMPILE( - [#include - #include - #include - #include ], - [return (BIOCROTZBUF + BPF_BUFMODE_ZBUF);], + # + # Check whether we have struct BPF_TIMEVAL. + # + AC_CHECK_TYPES(struct BPF_TIMEVAL,,, [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_ZEROCOPY_BPF, 1, - [define if the system supports zerocopy BPF]) - ], - AC_MSG_RESULT(no)) - - # - # Check whether we have struct BPF_TIMEVAL. - # - AC_CHECK_TYPES(struct BPF_TIMEVAL,,, - [ -#include -#include -#ifdef HAVE_SYS_IOCCOM_H -#include -#endif -#include - ]) + #include + #include + #ifdef HAVE_SYS_IOCCOM_H + #include + #endif + #include + ]) ;; dag) @@ -629,8 +905,10 @@ snf) ;; null) - AC_MSG_WARN(cannot determine packet capture interface) - AC_MSG_WARN((see the INSTALL doc for more info)) + ;; + +*) + AC_MSG_ERROR($V_PCAP is not a valid pcap type) ;; esac @@ -666,98 +944,83 @@ then ]) ],[ # - # Well, we don't have "getifaddrs()", so we have to use - # some other mechanism; determine what that mechanism is. + # Well, we don't have "getifaddrs()", at least not with the + # libraries with which we've decided we need to link + # libpcap with, so we have to use some other mechanism. # - # The first thing we use is the type of capture mechanism, - # which is somewhat of a proxy for the OS we're using. + # Note that this may happen on Solaris, which has + # getifaddrs(), but in -lsocket, not in -lxnet, so we + # won't find it if we link with -lxnet, which we want + # to do for other reasons. # - case "$V_PCAP" in - - dlpi|libdlpi) - # - # This might be Solaris 8 or later, with - # SIOCGLIFCONF, or it might be some other OS - # or some older version of Solaris, with - # just SIOCGIFCONF. - # - AC_MSG_CHECKING(whether we have SIOCGLIFCONF) - AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf, - AC_TRY_COMPILE( - [#include - #include - #include - #include - #include ], - [ioctl(0, SIOCGLIFCONF, (char *)0);], - ac_cv_lbl_have_siocglifconf=yes, - ac_cv_lbl_have_siocglifconf=no)) - AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf) - if test $ac_cv_lbl_have_siocglifconf = yes ; then - V_FINDALLDEVS=fad-glifc.c - else - V_FINDALLDEVS=fad-gifc.c - fi - ;; - - *) - # - # Assume we just have SIOCGIFCONF. - # (XXX - on at least later Linux kernels, there's - # another mechanism, and we should be using that - # instead.) - # + # For now, we use either the SIOCGIFCONF ioctl or the + # SIOCGLIFCONF ioctl, preferring the latter if we have + # it; the latter is a Solarisism that first appeared + # in Solaris 8. (Solaris's getifaddrs() appears to + # be built atop SIOCGLIFCONF; using it directly + # avoids a not-all-that-useful middleman.) + # + AC_MSG_CHECKING(whether we have SIOCGLIFCONF) + AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf, + AC_TRY_COMPILE( + [#include + #include + #include + #include + #include ], + [ioctl(0, SIOCGLIFCONF, (char *)0);], + ac_cv_lbl_have_siocglifconf=yes, + ac_cv_lbl_have_siocglifconf=no)) + AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf) + if test $ac_cv_lbl_have_siocglifconf = yes ; then + V_FINDALLDEVS=fad-glifc.c + else V_FINDALLDEVS=fad-gifc.c - ;; - esac]) + fi + ]) fi ]) -AC_MSG_CHECKING(for socklen_t) -AC_TRY_COMPILE([ +dnl check for hardware timestamp support +case "$host_os" in +linux*) + AC_CHECK_HEADERS([linux/net_tstamp.h]) + ;; +*) + AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os) + ;; +esac + +AC_ARG_ENABLE([packet-ring], +[AC_HELP_STRING([--enable-packet-ring],[enable packet ring support on Linux @<:@default=yes@:>@])], +,enable_packet_ring=yes) + +if test "x$enable_packet_ring" != "xno" ; then + AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use packet ring capture support on Linux if available]) + AC_SUBST(PCAP_SUPPORT_PACKET_RING) +fi + +# +# Check for socklen_t. +# +AC_CHECK_TYPES(socklen_t,,, + [ #include #include - ], - [ socklen_t x; ], - have_socklen_t=yes, - have_socklen_t=no) -if test "x$have_socklen_t" = "xyes"; then - AC_DEFINE(HAVE_SOCKLEN_T, 1, [define if socklen_t is defined]) -fi -AC_MSG_RESULT($have_socklen_t) + ]) AC_ARG_ENABLE(ipv6, -AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@]), +AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]), [], - [enable_ipv6=ifavailable]) + [enable_ipv6=yes]) if test "$enable_ipv6" != "no"; then - AC_CHECK_FUNC(getaddrinfo, - [ - AC_DEFINE(INET6,1,[IPv6]) - ], - [ - if test "$enable_ipv6" != "ifavailable"; then - AC_MSG_FAILURE([--enable-ipv6 was given, but getaddrinfo isn't available]) - fi - ]) + # + # We've already made sure we have getaddrinfo above in + # AC_LBL_LIBRARY_NET. + # + AC_DEFINE(INET6,1,[IPv6]) fi -AC_MSG_CHECKING(whether to build optimizer debugging code) -AC_ARG_ENABLE(optimizer-dbg, -AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code])) -if test "$enable_optimizer_dbg" = "yes"; then - AC_DEFINE(BDEBUG,1,[Enable optimizer debugging]) -fi -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])) -if test "$enable_yydebug" = "yes"; then - AC_DEFINE(YYDEBUG,1,[Enable parser debugging]) -fi -AC_MSG_RESULT(${enable_yydebug-no}) - # 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@:>@]), @@ -808,11 +1071,8 @@ AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not dag_lib_dir=$withval ],[]) -ac_cv_lbl_dag_api=no if test "$want_dag" != no; then - AC_MSG_CHECKING([whether we have DAG API headers]) - # If necessary, set default paths for DAG API headers and libraries. if test -z "$dag_root"; then dag_root=/usr/local @@ -826,29 +1086,25 @@ if test "$want_dag" != no; then dag_lib_dir="$dag_root/lib" fi - if test -z "$dag_tools_dir"; then - dag_tools_dir="$dag_root/tools" - fi + V_INCLS="$V_INCLS -I$dag_include_dir" - if test -r $dag_include_dir/dagapi.h; then - ac_cv_lbl_dag_api=yes - fi + AC_CHECK_HEADERS([dagapi.h]) - if test "$ac_cv_lbl_dag_api" = yes; then - AC_MSG_RESULT([yes ($dag_include_dir)]) - - V_INCLS="$V_INCLS -I$dag_include_dir" + if test "$ac_cv_header_dagapi_h" = yes; then if test $V_PCAP != dag ; then SSRC="$SSRC pcap-dag.c" fi - # See if we can find a general version string. + # 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). saved_ldflags=$LDFLAGS LDFLAGS="-L$dag_lib_dir" - AC_CHECK_LIB([dag], [dag_attach_stream], [dag_streams="1"], [dag_streams="0"]) + AC_CHECK_LIB([dag], [dag_attach_stream], + [], + [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], [ @@ -856,21 +1112,28 @@ if test "$want_dag" != no; then LDFLAGS=$saved_ldflags - if test "$dag_streams" = 1; then - AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API]) - LIBS="$LIBS -ldag" - LDFLAGS="$LDFLAGS -L$dag_lib_dir" + # + # 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_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"]) if test "$ac_dag_have_vdag" = 1; then AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()]) - LIBS="$LIBS -lpthread" + 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" fi fi AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) else - AC_MSG_RESULT(no) if test "$V_PCAP" = dag; then # User requested "dag" capture type but we couldn't @@ -1140,14 +1403,148 @@ if test "$want_turbocap" != no; then fi fi +dnl +dnl Allow the user to enable remote capture. +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) +case "$enableval" in +yes) AC_MSG_RESULT(yes) + AC_WARN([Remote packet capture may expose libpcap-based applications]) + AC_WARN([to attacks by malicious remote capture servers!]) + # + # rpcapd requires pthreads on UN*X. + # + if test "$ac_lbl_have_pthreads" != "found"; then + AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them]) + fi + # + # It also requires crypt(). + # Do we have it in the system libraries? + # + AC_CHECK_FUNC(crypt,, + [ + # + # No. Do we have it in -lcrypt? + # + AC_CHECK_LIB(crypt, crypt, + [ + # + # Yes; add -lcrypt to the libraries for rpcapd. + # + RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt" + ], + [ + AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it]) + ]) + ]) + + # + # OK, we have crypt(). Do we have getspnam()? + # + AC_CHECK_FUNCS(getspnam) + + # + # Check for various members of struct msghdr. + # + AC_CHECK_MEMBERS([struct msghdr.msg_control],,, + [ + #include "ftmacros.h" + #include + ]) + AC_CHECK_MEMBERS([struct msghdr.msg_flags],,, + [ + #include "ftmacros.h" + #include + ]) + + AC_DEFINE(ENABLE_REMOTE,, + [Define to 1 if remote packet capture is to be supported]) + SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c" + BUILD_RPCAPD=build-rpcapd + INSTALL_RPCAPD=install-rpcapd + ;; +*) AC_MSG_RESULT(no) + ;; +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])) +if test "$enable_optimizer_dbg" = "yes"; then + AC_DEFINE(BDEBUG,1,[Enable optimizer debugging]) +fi +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])) +if test "$enable_yydebug" = "yes"; then + AC_DEFINE(YYDEBUG,1,[Enable parser debugging]) +fi +AC_MSG_RESULT(${enable_yydebug-no}) + # -# Assume, by default, no support for shared libraries and V7/BSD convention -# for man pages (file formats in section 5, miscellaneous info in section 7). +# Look for {f}lex. +# +AC_PROG_LEX +if test "$LEX" = ":"; then + AC_MSG_ERROR([Neither flex nor lex was found.]) +fi + +# +# Make sure {f}lex supports the -P, --header-file, and --nounput flags +# and supports processing our scanner.l. +# +AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex, + if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then + tcpdump_cv_capable_lex=yes + else + tcpdump_cv_capable_lex=insufficient + 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.]) +fi + +# +# Look for yacc/bison/byacc. +# +AC_PROG_YACC + +# +# Make sure it supports the -p flag and supports processing our +# grammar.y. +# +AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc, + if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then + tcpdump_cv_capable_yacc=yes + else + tcpdump_cv_capable_yacc=insufficient + fi) +if test $tcpdump_cv_capable_yacc = insufficient ; then + AC_MSG_ERROR([$YACC 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 + +# +# Do various checks for various OSes and versions of those OSes. +# +# Assume, by default, no support for shared libraries and V7/BSD +# convention for man pages (file formats in section 5, miscellaneous +# info in section 7, administrative commands and daemons in section 8). # Individual cases can override this. # DYEXT="none" MAN_FILE_FORMATS=5 MAN_MISC_INFO=7 +MAN_ADMIN_COMMANDS=8 case "$host_os" in aix*) @@ -1196,7 +1593,7 @@ darwin*) DYEXT="dylib" V_CCOPT="$V_CCOPT -fno-common" AC_ARG_ENABLE(universal, - AC_HELP_STRING([--disable-universal],[don't build universal on OS X])) + AC_HELP_STRING([--disable-universal],[don't build universal on macOS])) if test "$enable_universal" != "no"; then case "$host_os" in @@ -1284,6 +1681,7 @@ hpux9*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -1293,6 +1691,7 @@ hpux10.0*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -1302,6 +1701,7 @@ hpux10.1*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -1335,7 +1735,9 @@ hpux*) irix*) # - # Use System V conventions for man pages. + # Use IRIX conventions for man pages; they're the same as the + # System V conventions, except that they use section 8 for + # administrative commands and daemons. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 @@ -1357,7 +1759,10 @@ osf*) DYEXT="so" # - # Use System V conventions for man pages. + # DEC OSF/1, a/k/a Digial 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. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 @@ -1381,17 +1786,36 @@ solaris*) AC_DEFINE(HAVE_SOLARIS,1,[On solaris]) DYEXT="so" + # - # Use System V conventions for man pages. + # Make sure errno is thread-safe, in case we're called in + # a multithreaded program. We don't guarantee that two + # threads can use the *same* pcap_t safely, but the + # current version does guarantee that you can use different + # pcap_t's in different threads, and even that pcap_compile() + # is thread-safe (it wasn't thread-safe in some older versions). # - MAN_FILE_FORMATS=4 - MAN_MISC_INFO=5 + V_CCOPT="$V_CCOPT -D_TS_ERRNO" + + case "`uname -r`" in + + 5.12) + ;; + + *) + # + # Use System V conventions for man pages. + # + MAN_ADMIN_COMMANDS=1m + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + esac ;; esac AC_ARG_ENABLE(shared, -AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=no@:>@])) -test "x$enable_shared" != "xyes" && DYEXT="none" +AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@])) +test "x$enable_shared" = "xno" && DYEXT="none" AC_PROG_RANLIB AC_CHECK_TOOL([AR], [ar]) @@ -1401,37 +1825,73 @@ AC_SUBST(LN_S) AC_LBL_DEVEL(V_CCOPT) -AC_LBL_SOCKADDR_SA_LEN +# +# Check to see if the sockaddr struct has the 4.4 BSD sa_len member. +# +AC_CHECK_MEMBERS([struct sockaddr.sa_len],,, + [ + #include + #include + ]) -AC_LBL_SOCKADDR_STORAGE +# +# Check to see if there's a sockaddr_storage structure. +# +AC_CHECK_TYPES(struct sockaddr_storage,,, + [ + #include + #include + ]) -AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1 +# +# Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00 +# dl_module_id_1 member. +# +# NOTE: any failure means we conclude that it doesn't have that member, +# so if we don't have DLPI, don't have a header, or +# have one that doesn't declare a dl_hp_ppa_info_t type, we conclude +# it doesn't have that member (which is OK, as either we won't be +# using code that would use that member, or we wouldn't compile in +# any case). +# +AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,, + [ + #include + #include + #include + ]) AC_LBL_UNALIGNED_ACCESS -rm -f net -ln -s ${srcdir}/bpf/net net - AC_SUBST(V_CCOPT) AC_SUBST(V_DEFS) AC_SUBST(V_FINDALLDEVS) AC_SUBST(V_INCLS) +AC_SUBST(V_LEX) AC_SUBST(V_PCAP) +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(SSRC) AC_SUBST(DYEXT) 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) AC_ARG_ENABLE([usb], -[AC_HELP_STRING([--enable-usb],[enable nusb support @<:@default=no@:>@])], +[AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])], [], - [enable_usb=no]) + [enable_usb=yes]) if test "xxx_only" = yes; then # User requested something-else-only pcap, so they don't @@ -1473,25 +1933,14 @@ if test "x$enable_usb" != "xno" ; then # "value", rather than "bRequestType", "bRequest", and # "wValue". # - AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member) - AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType, - AC_TRY_COMPILE([ -AC_INCLUDES_DEFAULT -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -#ifdef HAVE_LINUX_COMPILER_H -#include -#endif -#include ], - [u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)], - ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes, - ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no)) - AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType) - if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then - AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1, - [if struct usbdevfs_ctrltransfer has bRequestType]) - fi + AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,, + [ + AC_INCLUDES_DEFAULT + #ifdef HAVE_LINUX_COMPILER_H + #include + #endif + #include + ]) fi ;; freebsd*) @@ -1537,9 +1986,9 @@ AC_INCLUDES_DEFAULT #include #include #include ], - [], - ac_cv_netfilter_can_compile=yes, - ac_cv_netfilter_can_compile=no)) + [], + ac_cv_netfilter_can_compile=yes, + ac_cv_netfilter_can_compile=no)) AC_MSG_RESULT($ac_cv_netfilter_can_compile) if test $ac_cv_netfilter_can_compile = yes ; then AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1, @@ -1555,10 +2004,42 @@ fi AC_SUBST(PCAP_SUPPORT_NETFILTER) AC_SUBST(NETFILTER_SRC) -AC_ARG_ENABLE([bluetooth], -[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=no@:>@])], +AC_ARG_ENABLE([netmap], +[AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])], [], - [enable_bluetooth=no]) + [enable_netmap=yes]) + +if test "x$enable_netmap" != "xno" ; then + # + # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is + # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS + # is defined, for example, as it includes a non-existent malloc.h + # header. + # + AC_MSG_CHECKING(whether we can compile the netmap support) + AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile, + AC_TRY_COMPILE([ +AC_INCLUDES_DEFAULT +#define NETMAP_WITH_LIBS +#include ], + [], + ac_cv_net_netmap_user_can_compile=yes, + ac_cv_net_netmap_user_can_compile=no)) + AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile) + if test $ac_cv_net_netmap_user_can_compile = yes ; then + AC_DEFINE(PCAP_SUPPORT_NETMAP, 1, + [target host supports netmap]) + NETMAP_SRC=pcap-netmap.c + fi + AC_SUBST(PCAP_SUPPORT_NETMAP) + AC_SUBST(NETMAP_SRC) +fi + + +AC_ARG_ENABLE([bluetooth], +[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])], + [], + [enable_bluetooth=ifsupportavailable]) if test "xxx_only" = yes; then # User requested something-else-only pcap, so they don't @@ -1571,67 +2052,67 @@ if test "x$enable_bluetooth" != "xno" ; then case "$host_os" in linux*) AC_CHECK_HEADER(bluetooth/bluetooth.h, - [ - AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing]) - BT_SRC=pcap-bt-linux.c - AC_MSG_NOTICE(Bluetooth sniffing is supported) + [ + # + # We have bluetooth.h, so we support Bluetooth + # sniffing. + # + AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing]) + BT_SRC=pcap-bt-linux.c + AC_MSG_NOTICE(Bluetooth sniffing is supported) + ac_lbl_bluetooth_available=yes - # - # OK, does struct sockaddr_hci have an hci_channel - # member? - # - AC_MSG_CHECKING(if struct sockaddr_hci has hci_channel member) - AC_CACHE_VAL(ac_cv_lbl_sockaddr_hci_has_hci_channel, - AC_TRY_COMPILE( -[ -#include -#include -], - [u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel)], - ac_cv_lbl_sockaddr_hci_has_hci_channel=yes, - ac_cv_lbl_sockaddr_hci_has_hci_channel=no)) - AC_MSG_RESULT($ac_cv_lbl_sockaddr_hci_has_hci_channel) - if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then - AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,, - [if struct sockaddr_hci has hci_channel member]) - - # - # OK, is HCI_CHANNEL_MONITOR defined? - # - AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined) - AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined, - AC_TRY_COMPILE( -[ -#include -#include -], - [u_int i = HCI_CHANNEL_MONITOR], - ac_cv_lbl_hci_channel_monitor_is_defined=yes, - ac_cv_lbl_hci_channel_monitor_is_defined=no)) - AC_MSG_RESULT($ac_cv_lbl_hci_channel_monitor_is_defined) - if test $ac_cv_lbl_hci_channel_monitor_is_defined = yes ; then - AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,, - [target host supports Bluetooth Monitor]) - BT_MONITOR_SRC=pcap-bt-monitor-linux.c - fi - fi - ac_lbl_bluetooth_available=yes - ], - ac_lbl_bluetooth_available=no - ) - if test "x$ac_lbl_bluetooth_available" == "xno" ; then - if test "x$enable_bluetooth" = "xyes" ; then - AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it) - else - AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it) - fi - fi + # + # OK, does struct sockaddr_hci have an hci_channel + # member? + # + AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel], + [ + # + # Yes; is HCI_CHANNEL_MONITOR defined? + # + AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined) + AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined, + AC_TRY_COMPILE( + [ + #include + #include + ], + [ + u_int i = HCI_CHANNEL_MONITOR; + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,, + [target host supports Bluetooth Monitor]) + BT_MONITOR_SRC=pcap-bt-monitor-linux.c + ], + [ + AC_MSG_RESULT(no) + ])) + ],, + [ + #include + #include + ]) + ], + [ + # + # We don't have bluetooth.h, so we don't support + # Bluetooth sniffing. + # + if test "x$enable_bluetooth" = "xyes" ; then + AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it) + else + AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it) + fi + ]) ;; *) if test "x$enable_bluetooth" = "xyes" ; then - AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os) + AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os) else - AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os) + AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os) fi ;; esac @@ -1641,9 +2122,9 @@ if test "x$enable_bluetooth" != "xno" ; then fi AC_ARG_ENABLE([dbus], -[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=no@:>@])], +[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])], [], - [enable_dbus=no]) + [enable_dbus=ifavailable]) if test "xxx_only" = yes; then # User requested something-else-only pcap, so they don't @@ -1657,20 +2138,20 @@ if test "x$enable_dbus" != "xno"; then darwin*) # - # We don't support D-Bus sniffing on OS X; see + # We don't support D-Bus sniffing on macOS; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # # The user requested it, so fail. # - AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on OS X]) + AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS]) esac else case "$host_os" in darwin*) # - # We don't support D-Bus sniffing on OS X; see + # We don't support D-Bus sniffing on macOS; see # # https://bugs.freedesktop.org/show_bug.cgi?id=74029 # @@ -1729,32 +2210,54 @@ if test "x$enable_dbus" != "xno"; then AC_SUBST(DBUS_SRC) fi -dnl check for hardware timestamp support -case "$host_os" in -linux*) - AC_CHECK_HEADERS([linux/net_tstamp.h]) - ;; -*) - AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os) - ;; -esac +AC_ARG_ENABLE([rdma], +[AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])], + [], + [enable_rdmasniff=ifavailable]) -dnl The packet ring capture facility of Linux, described in -dnl Documentation/networking/packet_mmap.txt, is not 32/64-bit compatible before -dnl version 2.6.27. A 32-bit kernel requires a 32-bit userland, and likewise for -dnl 64-bit. The effect of this is that a 32-bit libpcap binary will not run -dnl correctly on a 64-bit kernel (the binary will use the wrong offsets into a -dnl kernel struct). This problem was solved in Linux 2.6.27. Use -dnl --disable-packet-ring whenever a 32-bit application must run on a 64-bit -dnl target host, and either the build host or the target host run Linux 2.6.26 -dnl or earlier. -AC_ARG_ENABLE([packet-ring], -[AC_HELP_STRING([--enable-packet-ring],[enable Linux packet ring support @<:@default=yes@:>@])], -,enable_packet_ring=yes) +if test "xxx_only" = yes; then + # User requested something-else-only pcap, so they don't + # want RDMA support. + enable_rdmasniff=no +fi -if test "x$enable_packet_ring" != "xno" ; then - AC_DEFINE(PCAP_SUPPORT_PACKET_RING, 1, [use Linux packet ring capture if available]) - AC_SUBST(PCAP_SUPPORT_PACKET_RING) +if test "x$enable_rdmasniff" != "xno"; then + AC_CHECK_LIB(ibverbs, ibv_get_device_list, [ + AC_CHECK_HEADER(infiniband/verbs.h, [ + # + # ibv_create_flow may be defined as a static inline + # function in infiniband/verbs.h, so we can't + # use AC_CHECK_LIB. + # + # Too bad autoconf has no AC_SYMBOL_EXISTS() + # macro that works like CMake's check_symbol_exists() + # function, to check do a compile check like + # this (they do a clever trick to avoid having + # to know the function's signature). + # + AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow) + AC_TRY_LINK( + [ + #include + ], + [ + (void) ibv_create_flow((struct ibv_qp *) NULL, + (struct ibv_flow_attr *) NULL); + ], + [ + AC_MSG_RESULT([yes]) + AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing]) + RDMA_SRC=pcap-rdmasniff.c + LIBS="-libverbs $LIBS" + ], + [ + AC_MSG_RESULT([no]) + ] + ) + ]) + ]) + AC_SUBST(PCAP_SUPPORT_RDMASNIFF) + AC_SUBST(RDMA_SRC) fi AC_PROG_INSTALL @@ -1763,7 +2266,7 @@ AC_CONFIG_HEADER(config.h) AC_OUTPUT_COMMANDS([if test -f .devel; then echo timestamp > stamp-h - cat Makefile-devel-adds >> Makefile + cat $srcdir/Makefile-devel-adds >> Makefile make depend fi]) AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc @@ -1772,5 +2275,6 @@ AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap - pcap_set_tstamp_type.3pcap) + pcap_set_tstamp_type.3pcap rpcapd/Makefile rpcapd/rpcapd.manadmin + testprogs/Makefile) exit 0 diff --git a/libpcap/diag-control.h b/libpcap/diag-control.h new file mode 100644 index 000000000..cfc581b37 --- /dev/null +++ b/libpcap/diag-control.h @@ -0,0 +1,219 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * 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 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 Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory 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. + */ + +#ifndef _diag_control_h +#define _diag_control_h + +#include "pcap/compiler-tests.h" + +#ifndef _MSC_VER + /* + * 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. + */ + #define PCAP_DO_PRAGMA(x) _Pragma (#x) +#endif + +/* + * Suppress Flex warnings. + */ +#if defined(_MSC_VER) + /* + * This is Microsoft Visual Studio; we can use __pragma(warning(disable:XXXX)) + * and __pragma(warning(push/pop)). + * + * Suppress signed-vs-unsigned comparison, narrowing, and unreachable + * code warnings. + */ + #define DIAG_OFF_FLEX \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + __pragma(warning(disable:4242)) \ + __pragma(warning(disable:4244)) \ + __pragma(warning(disable:4702)) + #define DIAG_ON_FLEX __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 "-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) +#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) + /* + * This is GCC 4.6 or later, or a compiler claiming to be that. + * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2) + * and "GCC diagnostic push/pop" (introduced in 4.6). + */ + #define DIAG_OFF_FLEX \ + PCAP_DO_PRAGMA(GCC diagnostic push) \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wsign-compare") \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunused-parameter") \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_FLEX \ + PCAP_DO_PRAGMA(GCC diagnostic pop) +#else + /* + * Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later + * or a compiler claiming to be that; there's nothing we know of that + * we can do. + */ + #define DIAG_OFF_FLEX + #define DIAG_ON_FLEX +#endif + +#ifdef YYBYACC + /* + * Berkeley YACC. + * + * It generates a global declaration of yylval, or the appropriately + * prefixed version of yylval, in grammar.h, *even though it's been + * told to generate a pure parser, meaning it doesn't have any global + * variables*. Bison doesn't do this. + * + * That causes a warning due to the local declaration in the parser + * shadowing the global declaration. + * + * So, if the compiler warns about that, we turn off -Wshadow warnings. + * + * In addition, the generated code may have functions with unreachable + * code, so suppress warnings about those. + */ + #if defined(_MSC_VER) + /* + * This is Microsoft Visual Studio; we can use + * __pragma(warning(disable:XXXX)) and __pragma(warning(push/pop)). + */ + #define DIAG_OFF_BISON_BYACC \ + __pragma(warning(push)) \ + __pragma(warning(disable:4702)) + #define DIAG_ON_BISON_BYACC __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". + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wshadow") \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic pop) + #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) + /* + * This is GCC 4.6 or later, or a compiler claiming to be that. + * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2) + * and "GCC diagnostic push/pop" (introduced in 4.6). + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic push) \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wshadow") \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic pop) + #else + /* + * Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler + * claiming to be that; there's nothing we know of that we can do. + */ + #define DIAG_OFF_BISON_BYACC + #define DIAG_ON_BISON_BYACC + #endif +#else + /* + * Bison. + * + * The generated code may have functions with unreachable code, so + * suppress warnings about those. + */ + #if defined(_MSC_VER) + /* + * This is Microsoft Visual Studio; we can use + * __pragma(warning(disable:XXXX)) and __pragma(warning(push/pop)). + * + * Suppress some /Wall warnings. + */ + #define DIAG_OFF_BISON_BYACC \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + __pragma(warning(disable:4242)) \ + __pragma(warning(disable:4244)) \ + __pragma(warning(disable:4702)) + #define DIAG_ON_BISON_BYACC __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". + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic push) \ + PCAP_DO_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(clang diagnostic pop) + #elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6) + /* + * This is GCC 4.6 or later, or a compiler claiming to be that. + * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2) + * and "GCC diagnostic push/pop" (introduced in 4.6). + */ + #define DIAG_OFF_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic push) \ + PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wunreachable-code") + #define DIAG_ON_BISON_BYACC \ + PCAP_DO_PRAGMA(GCC diagnostic pop) + #else + /* + * Neither Clang 2.8 or later nor GCC 4.6 or later or a compiler + * claiming to be that; there's nothing we know of that we can do. + */ + #define DIAG_OFF_BISON_BYACC + #define DIAG_ON_BISON_BYACC + #endif +#endif + +#endif /* _diag_control_h */ diff --git a/libpcap/dlpisubs.c b/libpcap/dlpisubs.c index fb94a6057..5f6e41af8 100644 --- a/libpcap/dlpisubs.c +++ b/libpcap/dlpisubs.c @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #ifndef DL_IPATM @@ -271,7 +271,16 @@ pcap_process_mactype(pcap_t *p, u_int mactype) #ifdef DL_IPNET case DL_IPNET: - p->linktype = DLT_IPNET; + /* + * XXX - DL_IPNET devices default to "raw IP" rather than + * "IPNET header"; see + * + * http://seclists.org/tcpdump/2009/q1/202 + * + * We'd have to do DL_IOC_IPNET_INFO to enable getting + * the IPNET header. + */ + p->linktype = DLT_RAW; p->offset = 0; break; #endif @@ -349,7 +358,8 @@ pcap_alloc_databuf(pcap_t *p) p->bufsize = PKTBUFSIZE; p->buffer = malloc(p->bufsize + p->offset); if (p->buffer == NULL) { - strlcpy(p->errbuf, pcap_strerror(errno), PCAP_ERRBUF_SIZE); + pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); return (-1); } @@ -383,6 +393,6 @@ strioctl(int fd, int cmd, int len, char *dp) static void pcap_stream_err(const char *func, int err, char *errbuf) { - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, err, "%s", func); } #endif diff --git a/libpcap/etherent.c b/libpcap/etherent.c index 5cfd1b4c3..5f499613e 100644 --- a/libpcap/etherent.c +++ b/libpcap/etherent.c @@ -20,22 +20,10 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#ifdef _WIN32 -#include -#else /* _WIN32 */ -#if HAVE_INTTYPES_H -#include -#elif HAVE_STDINT_H -#include -#endif -#ifdef HAVE_SYS_BITYPES_H -#include -#endif -#include -#endif /* _WIN32 */ +#include #include #include @@ -50,26 +38,23 @@ #include "os-proto.h" #endif -static inline int xdtoi(int); static inline int skip_space(FILE *); static inline int skip_line(FILE *); /* Hex digit to integer. */ -static inline int -xdtoi(c) - register int c; +static inline u_char +xdtoi(u_char c) { if (isdigit(c)) - return c - '0'; + return (u_char)(c - '0'); else if (islower(c)) - return c - 'a' + 10; + return (u_char)(c - 'a' + 10); else - return c - 'A' + 10; + return (u_char)(c - 'A' + 10); } static inline int -skip_space(f) - FILE *f; +skip_space(FILE *f) { int c; @@ -81,8 +66,7 @@ skip_space(f) } static inline int -skip_line(f) - FILE *f; +skip_line(FILE *f) { int c; @@ -96,47 +80,61 @@ skip_line(f) struct pcap_etherent * pcap_next_etherent(FILE *fp) { - register int c, d, i; + register int c, i; + u_char d; char *bp; + size_t namesize; static struct pcap_etherent e; memset((char *)&e, 0, sizeof(e)); - do { + for (;;) { /* Find addr */ c = skip_space(fp); + if (c == EOF) + return (NULL); if (c == '\n') continue; /* If this is a comment, or first thing on line - cannot be etehrnet address, skip the line. */ + cannot be Ethernet address, skip the line. */ if (!isxdigit(c)) { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } /* must be the start of an address */ for (i = 0; i < 6; i += 1) { - d = xdtoi(c); + d = xdtoi((u_char)c); c = getc(fp); + if (c == EOF) + return (NULL); if (isxdigit(c)) { d <<= 4; - d |= xdtoi(c); + d |= xdtoi((u_char)c); c = getc(fp); + if (c == EOF) + return (NULL); } e.addr[i] = d; if (c != ':') break; c = getc(fp); + if (c == EOF) + return (NULL); } - if (c == EOF) - break; /* Must be whitespace */ if (!isspace(c)) { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } c = skip_space(fp); + if (c == EOF) + return (NULL); /* hit end of line... */ if (c == '\n') @@ -144,17 +142,21 @@ pcap_next_etherent(FILE *fp) if (c == '#') { c = skip_line(fp); + if (c == EOF) + return (NULL); continue; } /* pick up name */ bp = e.name; - /* Use 'd' to prevent buffer overflow. */ - d = sizeof(e.name) - 1; + /* Use 'namesize' to prevent buffer overflow. */ + namesize = sizeof(e.name) - 1; do { - *bp++ = c; + *bp++ = (u_char)c; c = getc(fp); - } while (!isspace(c) && c != EOF && --d > 0); + if (c == EOF) + return (NULL); + } while (!isspace(c) && --namesize != 0); *bp = '\0'; /* Eat trailing junk */ @@ -162,8 +164,5 @@ pcap_next_etherent(FILE *fp) (void)skip_line(fp); return &e; - - } while (c != EOF); - - return (NULL); + } } diff --git a/libpcap/extract.h b/libpcap/extract.h index face5b7e9..aa3ff9919 100644 --- a/libpcap/extract.h +++ b/libpcap/extract.h @@ -23,6 +23,9 @@ #include #endif +#include +#include + /* * Macros to extract possibly-unaligned big-endian integral values. */ @@ -30,15 +33,16 @@ /* * The processor doesn't natively handle unaligned loads. */ -#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \ +#if PCAP_IS_AT_LEAST_GNUC_VERSION(2,0) && \ (defined(__alpha) || defined(__alpha__) || \ defined(__mips) || defined(__mips__)) - /* - * This is a GCC-compatible compiler and we have __attribute__, which - * we assume that mean we have __attribute__((packed)), and this is - * MIPS or Alpha, which has instructions that can help when doing - * unaligned loads. + * This is MIPS or Alpha, which don't natively handle unaligned loads, + * but which have instructions that can help when doing unaligned + * loads, and this is GCC 2.0 or later or a compiler that claims to + * be GCC 2.0 or later, which we assume that mean we have + * __attribute__((packed)), which we can use to convince the compiler + * to generate those instructions. * * Declare packed structures containing a uint16_t and a uint32_t, * cast the pointer to point to one of those, and fetch through it; diff --git a/libpcap/fad-getad.c b/libpcap/fad-getad.c index b67b5cdcd..5236fbb94 100644 --- a/libpcap/fad-getad.c +++ b/libpcap/fad-getad.c @@ -33,7 +33,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include @@ -102,10 +102,10 @@ * all those systems we have "struct sockaddr_storage". */ #ifndef SA_LEN -#ifdef HAVE_SOCKADDR_SA_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN #define SA_LEN(addr) ((addr)->sa_len) -#else /* HAVE_SOCKADDR_SA_LEN */ -#ifdef HAVE_SOCKADDR_STORAGE +#else /* HAVE_STRUCT_SOCKADDR_SA_LEN */ +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE static size_t get_sa_len(struct sockaddr *addr) { @@ -131,10 +131,10 @@ get_sa_len(struct sockaddr *addr) } } #define SA_LEN(addr) (get_sa_len(addr)) -#else /* HAVE_SOCKADDR_STORAGE */ +#else /* HAVE_STRUCT_SOCKADDR_STORAGE */ #define SA_LEN(addr) (sizeof (struct sockaddr)) -#endif /* HAVE_SOCKADDR_STORAGE */ -#endif /* HAVE_SOCKADDR_SA_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */ +#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ #endif /* SA_LEN */ /* @@ -144,10 +144,9 @@ get_sa_len(struct sockaddr *addr) * could be opened. */ int -pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, - int (*check_usable)(const char *)) +pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf, + int (*check_usable)(const char *), get_if_flags_func get_flags_func) { - pcap_if_t *devlist = NULL; struct ifaddrs *ifap, *ifa; struct sockaddr *addr, *netmask, *broadaddr, *dstaddr; size_t addr_size, broadaddr_size, dstaddr_size; @@ -169,8 +168,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, * those. */ if (getifaddrs(&ifap) != 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "getifaddrs: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "getifaddrs"); return (-1); } for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) { @@ -233,7 +232,7 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, /* * Note that, on some platforms, ifa_broadaddr and * ifa_dstaddr could be the same field (true on at - * least some versions of *BSD and OS X), so we + * least some versions of *BSD and macOS), so we * can't just check whether the broadcast address * is null and add it if so and check whether the * destination address is null and add it if so. @@ -265,8 +264,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, /* * Add information for this address to the list. */ - if (add_addr_to_iflist(&devlist, ifa->ifa_name, - if_flags_to_pcap_flags(ifa->ifa_name, ifa->ifa_flags), + if (add_addr_to_if(devlistp, ifa->ifa_name, ifa->ifa_flags, + get_flags_func, addr, addr_size, netmask, addr_size, broadaddr, broadaddr_size, dstaddr, dstaddr_size, errbuf) < 0) { @@ -277,16 +276,5 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, freeifaddrs(ifap); - if (ret == -1) { - /* - * We had an error; free the list we've been constructing. - */ - if (devlist != NULL) { - pcap_freealldevs(devlist); - devlist = NULL; - } - } - - *alldevsp = devlist; return (ret); } diff --git a/libpcap/fad-gifc.c b/libpcap/fad-gifc.c index 1b24af292..6b1612747 100644 --- a/libpcap/fad-gifc.c +++ b/libpcap/fad-gifc.c @@ -33,7 +33,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include @@ -57,6 +57,12 @@ struct rtentry; /* declarations in */ #include #include +#ifdef HAVE_LIMITS_H +#include +#else +#define INT_MAX 2147483647 +#endif + #include "pcap-int.h" #ifdef HAVE_OS_PROTO_H @@ -89,11 +95,11 @@ struct rtentry; /* declarations in */ * address in an entry returned by SIOCGIFCONF. */ #ifndef SA_LEN -#ifdef HAVE_SOCKADDR_SA_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN #define SA_LEN(addr) ((addr)->sa_len) -#else /* HAVE_SOCKADDR_SA_LEN */ +#else /* HAVE_STRUCT_SOCKADDR_SA_LEN */ #define SA_LEN(addr) (sizeof (struct sockaddr)) -#endif /* HAVE_SOCKADDR_SA_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ #endif /* SA_LEN */ /* @@ -132,10 +138,9 @@ struct rtentry; /* declarations in */ * we already have that. */ int -pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, - int (*check_usable)(const char *)) +pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf, + int (*check_usable)(const char *), get_if_flags_func get_flags_func) { - pcap_if_t *devlist = NULL; register int fd; register struct ifreq *ifrp, *ifend, *ifnext; size_t n; @@ -155,8 +160,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, */ fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "socket: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "socket"); return (-1); } @@ -169,10 +174,20 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, */ buf_size = 8192; for (;;) { + /* + * Don't let the buffer size get bigger than INT_MAX. + */ + if (buf_size > INT_MAX) { + (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + "interface information requires more than %u bytes", + INT_MAX); + (void)close(fd); + return (-1); + } buf = malloc(buf_size); if (buf == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); (void)close(fd); return (-1); } @@ -182,13 +197,13 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, memset(buf, 0, buf_size); if (ioctl(fd, SIOCGIFCONF, (char *)&ifc) < 0 && errno != EINVAL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFCONF: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGIFCONF"); (void)close(fd); free(buf); return (-1); } - if (ifc.ifc_len < buf_size && + if (ifc.ifc_len < (int)buf_size && (buf_size - ifc.ifc_len) > sizeof(ifrp->ifr_name) + MAX_SA_LEN) break; free(buf); @@ -255,11 +270,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) { if (errno == ENXIO) continue; - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFFLAGS: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGIFFLAGS: %.*s", (int)sizeof(ifrflags.ifr_name), - ifrflags.ifr_name, - pcap_strerror(errno)); + ifrflags.ifr_name); ret = -1; break; } @@ -279,11 +293,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, netmask = NULL; netmask_size = 0; } else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFNETMASK: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "SIOCGIFNETMASK: %.*s", (int)sizeof(ifrnetmask.ifr_name), - ifrnetmask.ifr_name, - pcap_strerror(errno)); + ifrnetmask.ifr_name); ret = -1; break; } @@ -310,11 +324,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, broadaddr = NULL; broadaddr_size = 0; } else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFBRDADDR: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "SIOCGIFBRDADDR: %.*s", (int)sizeof(ifrbroadaddr.ifr_name), - ifrbroadaddr.ifr_name, - pcap_strerror(errno)); + ifrbroadaddr.ifr_name); ret = -1; break; } @@ -349,11 +363,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, dstaddr = NULL; dstaddr_size = 0; } else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGIFDSTADDR: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "SIOCGIFDSTADDR: %.*s", (int)sizeof(ifrdstaddr.ifr_name), - ifrdstaddr.ifr_name, - pcap_strerror(errno)); + ifrdstaddr.ifr_name); ret = -1; break; } @@ -401,8 +415,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, /* * Add information for this address to the list. */ - if (add_addr_to_iflist(&devlist, ifrp->ifr_name, - if_flags_to_pcap_flags(ifrp->ifr_name, ifrflags.ifr_flags), + if (add_addr_to_if(devlistp, ifrp->ifr_name, + ifrflags.ifr_flags, get_flags_func, &ifrp->ifr_addr, SA_LEN(&ifrp->ifr_addr), netmask, netmask_size, broadaddr, broadaddr_size, dstaddr, dstaddr_size, errbuf) < 0) { @@ -413,16 +427,5 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, free(buf); (void)close(fd); - if (ret == -1) { - /* - * We had an error; free the list we've been constructing. - */ - if (devlist != NULL) { - pcap_freealldevs(devlist); - devlist = NULL; - } - } - - *alldevsp = devlist; return (ret); } diff --git a/libpcap/fad-glifc.c b/libpcap/fad-glifc.c index 511481cf9..f22f56d73 100644 --- a/libpcap/fad-glifc.c +++ b/libpcap/fad-glifc.c @@ -33,7 +33,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include @@ -75,10 +75,9 @@ struct rtentry; /* declarations in */ * SIOCGLIFCONF rather than SIOCGIFCONF in order to get IPv6 addresses.) */ int -pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, - int (*check_usable)(const char *)) +pcap_findalldevs_interfaces(pcap_if_list_t *devlistp, char *errbuf, + int (*check_usable)(const char *), get_if_flags_func get_flags_func) { - pcap_if_t *devlist = NULL; register int fd4, fd6, fd; register struct lifreq *ifrp, *ifend; struct lifnum ifn; @@ -98,8 +97,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, */ fd4 = socket(AF_INET, SOCK_DGRAM, 0); if (fd4 < 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "socket: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "socket: AF_INET"); return (-1); } @@ -108,8 +107,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, */ fd6 = socket(AF_INET6, SOCK_DGRAM, 0); if (fd6 < 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "socket: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "socket: AF_INET6"); (void)close(fd4); return (-1); } @@ -121,8 +120,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, ifn.lifn_flags = 0; ifn.lifn_count = 0; if (ioctl(fd4, SIOCGLIFNUM, (char *)&ifn) < 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGLIFNUM: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGLIFNUM"); (void)close(fd6); (void)close(fd4); return (-1); @@ -134,8 +133,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, buf_size = ifn.lifn_count * sizeof (struct lifreq); buf = malloc(buf_size); if (buf == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "malloc"); (void)close(fd6); (void)close(fd4); return (-1); @@ -150,8 +149,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, ifc.lifc_flags = 0; memset(buf, 0, buf_size); if (ioctl(fd4, SIOCGLIFCONF, (char *)&ifc) < 0) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGLIFCONF: %s", pcap_strerror(errno)); + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGLIFCONF"); (void)close(fd6); (void)close(fd4); free(buf); @@ -199,11 +198,10 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, if (ioctl(fd, SIOCGLIFFLAGS, (char *)&ifrflags) < 0) { if (errno == ENXIO) continue; - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGLIFFLAGS: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE, + errno, "SIOCGLIFFLAGS: %.*s", (int)sizeof(ifrflags.lifr_name), - ifrflags.lifr_name, - pcap_strerror(errno)); + ifrflags.lifr_name); ret = -1; break; } @@ -222,11 +220,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, */ netmask = NULL; } else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGLIFNETMASK: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "SIOCGLIFNETMASK: %.*s", (int)sizeof(ifrnetmask.lifr_name), - ifrnetmask.lifr_name, - pcap_strerror(errno)); + ifrnetmask.lifr_name); ret = -1; break; } @@ -250,11 +248,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, */ broadaddr = NULL; } else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGLIFBRDADDR: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "SIOCGLIFBRDADDR: %.*s", (int)sizeof(ifrbroadaddr.lifr_name), - ifrbroadaddr.lifr_name, - pcap_strerror(errno)); + ifrbroadaddr.lifr_name); ret = -1; break; } @@ -285,11 +283,11 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, */ dstaddr = NULL; } else { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "SIOCGLIFDSTADDR: %.*s: %s", + pcap_fmt_errmsg_for_errno(errbuf, + PCAP_ERRBUF_SIZE, errno, + "SIOCGLIFDSTADDR: %.*s", (int)sizeof(ifrdstaddr.lifr_name), - ifrdstaddr.lifr_name, - pcap_strerror(errno)); + ifrdstaddr.lifr_name); ret = -1; break; } @@ -329,8 +327,8 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, /* * Add information for this address to the list. */ - if (add_addr_to_iflist(&devlist, ifrp->lifr_name, - if_flags_to_pcap_flags(ifrp->lifr_name, ifrflags.lifr_flags), + if (add_addr_to_if(devlistp, ifrp->lifr_name, + ifrflags.lifr_flags, get_flags_func, (struct sockaddr *)&ifrp->lifr_addr, sizeof (struct sockaddr_storage), netmask, sizeof (struct sockaddr_storage), @@ -344,16 +342,5 @@ pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf, (void)close(fd6); (void)close(fd4); - if (ret == -1) { - /* - * We had an error; free the list we've been constructing. - */ - if (devlist != NULL) { - pcap_freealldevs(devlist); - devlist = NULL; - } - } - - *alldevsp = devlist; return (ret); } diff --git a/libpcap/fad-helpers.c b/libpcap/fad-helpers.c deleted file mode 100644 index 4860bc55c..000000000 --- a/libpcap/fad-helpers.c +++ /dev/null @@ -1,884 +0,0 @@ -/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ -/* - * Copyright (c) 1994, 1995, 1996, 1997, 1998 - * 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 Computer Systems - * Engineering Group at Lawrence Berkeley Laboratory. - * 4. Neither the name of the University nor of the Laboratory 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef _WIN32 -#include -#else /* _WIN32 */ - -#include -#ifndef MSDOS -#include -#endif -#include -#include -#ifdef HAVE_SYS_SOCKIO_H -#include -#endif - -struct mbuf; /* Squelch compiler warnings on some platforms for */ -struct rtentry; /* declarations in */ -#include -#include -#endif /* _WIN32 */ - -#include -#include -#include -#include -#include -#include -#if !defined(_WIN32) && !defined(__BORLANDC__) -#include -#endif /* !_WIN32 && !__BORLANDC__ */ -#ifdef HAVE_LIMITS_H -#include -#else -#define INT_MAX 2147483647 -#endif - -#include "pcap-int.h" - -#ifdef HAVE_OS_PROTO_H -#include "os-proto.h" -#endif - -#ifndef _WIN32 -/* Not all systems have IFF_LOOPBACK */ -#ifdef IFF_LOOPBACK -#define ISLOOPBACK(name, flags) ((flags) & IFF_LOOPBACK) -#else -#define ISLOOPBACK(name, flags) ((name)[0] == 'l' && (name)[1] == 'o' && \ - (isdigit((unsigned char)((name)[2])) || (name)[2] == '\0')) -#endif - -#ifdef IFF_UP -#define ISUP(flags) ((flags) & IFF_UP) -#else -#define ISUP(flags) 0 -#endif - -#ifdef IFF_RUNNING -#define ISRUNNING(flags) ((flags) & IFF_RUNNING) -#else -#define ISRUNNING(flags) 0 -#endif - -/* - * Map UN*X-style interface flags to libpcap flags. - */ -bpf_u_int32 -if_flags_to_pcap_flags(const char *name _U_, u_int if_flags) -{ - bpf_u_int32 pcap_flags; - - pcap_flags = 0; - if (ISLOOPBACK(name, if_flags)) - pcap_flags |= PCAP_IF_LOOPBACK; - if (ISUP(if_flags)) - pcap_flags |= PCAP_IF_UP; - if (ISRUNNING(if_flags)) - pcap_flags |= PCAP_IF_RUNNING; - return (pcap_flags); -} -#endif - -static struct sockaddr * -dup_sockaddr(struct sockaddr *sa, size_t sa_length) -{ - struct sockaddr *newsa; - - if ((newsa = malloc(sa_length)) == NULL) - return (NULL); - return (memcpy(newsa, sa, sa_length)); -} - -/* - * Construct a "figure of merit" for an interface, for use when sorting - * the list of interfaces, in which interfaces that are up are superior - * to interfaces that aren't up, interfaces that are up and running are - * superior to interfaces that are up but not running, and non-loopback - * interfaces that are up and running are superior to loopback interfaces, - * and interfaces with the same flags have a figure of merit that's higher - * the lower the instance number. - * - * The goal is to try to put the interfaces most likely to be useful for - * capture at the beginning of the list. - * - * The figure of merit, which is lower the "better" the interface is, - * has the uppermost bit set if the interface isn't running, the bit - * below that set if the interface isn't up, the bit below that set - * if the interface is a loopback interface, and the interface index - * in the 29 bits below that. (Yes, we assume u_int is 32 bits.) - */ -static u_int -get_figure_of_merit(pcap_if_t *dev) -{ - const char *cp; - u_int n; - - if (strcmp(dev->name, "any") == 0) { - /* - * Give the "any" device an artificially high instance - * number, so it shows up after all other non-loopback - * interfaces. - */ - n = 0x1FFFFFFF; /* 29 all-1 bits */ - } else { - /* - * A number at the end of the device name string is - * assumed to be a unit number. - */ - cp = dev->name + strlen(dev->name) - 1; - while (cp-1 >= dev->name && *(cp-1) >= '0' && *(cp-1) <= '9') - cp--; - if (*cp >= '0' && *cp <= '9') - n = atoi(cp); - else - n = 0; - } - if (!(dev->flags & PCAP_IF_RUNNING)) - n |= 0x80000000; - if (!(dev->flags & PCAP_IF_UP)) - n |= 0x40000000; - if (dev->flags & PCAP_IF_LOOPBACK) - n |= 0x20000000; - return (n); -} - -/* - * Try to get a description for a given device. - * Returns a mallocated description if it could and NULL if it couldn't. - * - * XXX - on FreeBSDs that support it, should it get the sysctl named - * "dev.{adapter family name}.{adapter unit}.%desc" to get a description - * of the adapter? Note that "dev.an.0.%desc" is "Aironet PC4500/PC4800" - * with my Cisco 350 card, so the name isn't entirely descriptive. The - * "dev.an.0.%pnpinfo" has a better description, although one might argue - * that the problem is really a driver bug - if it can find out that it's - * a Cisco 340 or 350, rather than an old Aironet card, it should use - * that in the description. - * - * Do NetBSD, DragonflyBSD, or OpenBSD support this as well? FreeBSD - * and OpenBSD let you get a description, but it's not generated by the OS, - * it's set with another ioctl that ifconfig supports; we use that to get - * a description in FreeBSD and OpenBSD, but if there is no such - * description available, it still might be nice to get some description - * string based on the device type or something such as that. - * - * In OS X, the System Configuration framework can apparently return - * names in 10.4 and later. - * - * It also appears that freedesktop.org's HAL offers an "info.product" - * string, but the HAL specification says it "should not be used in any - * UI" and "subsystem/capability specific properties" should be used - * instead and, in any case, I think HAL is being deprecated in - * favor of other stuff such as DeviceKit. DeviceKit doesn't appear - * to have any obvious product information for devices, but maybe - * I haven't looked hard enough. - * - * Using the System Configuration framework, or HAL, or DeviceKit, or - * whatever, would require that libpcap applications be linked with - * the frameworks/libraries in question. That shouldn't be a problem - * for programs linking with the shared version of libpcap (unless - * you're running on AIX - which I think is the only UN*X that doesn't - * support linking a shared library with other libraries on which it - * depends, and having an executable linked only with the first shared - * library automatically pick up the other libraries when started - - * and using HAL or whatever). Programs linked with the static - * version of libpcap would have to use pcap-config with the --static - * flag in order to get the right linker flags in order to pick up - * the additional libraries/frameworks; those programs need that anyway - * for libpcap 1.1 and beyond on Linux, as, by default, it requires - * -lnl. - * - * Do any other UN*Xes, or desktop environments support getting a - * description? - */ -static char * -get_if_description(const char *name) -{ -#ifdef SIOCGIFDESCR - char *description = NULL; - int s; - struct ifreq ifrdesc; -#ifndef IFDESCRSIZE - size_t descrlen = 64; -#else - size_t descrlen = IFDESCRSIZE; -#endif /* IFDESCRSIZE */ - - /* - * Get the description for the interface. - */ - memset(&ifrdesc, 0, sizeof ifrdesc); - strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name); - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s >= 0) { -#ifdef __FreeBSD__ - /* - * On FreeBSD, if the buffer isn't big enough for the - * description, the ioctl succeeds, but the description - * isn't copied, ifr_buffer.length is set to the description - * length, and ifr_buffer.buffer is set to NULL. - */ - for (;;) { - free(description); - if ((description = malloc(descrlen)) != NULL) { - ifrdesc.ifr_buffer.buffer = description; - ifrdesc.ifr_buffer.length = descrlen; - if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0) { - if (ifrdesc.ifr_buffer.buffer == - description) - break; - else - descrlen = ifrdesc.ifr_buffer.length; - } else { - /* - * Failed to get interface description. - */ - free(description); - description = NULL; - break; - } - } else - break; - } -#else /* __FreeBSD__ */ - /* - * The only other OS that currently supports - * SIOCGIFDESCR is OpenBSD, and it has no way - * to get the description length - it's clamped - * to a maximum of IFDESCRSIZE. - */ - if ((description = malloc(descrlen)) != NULL) { - ifrdesc.ifr_data = (caddr_t)description; - if (ioctl(s, SIOCGIFDESCR, &ifrdesc) != 0) { - /* - * Failed to get interface description. - */ - free(description); - description = NULL; - } - } -#endif /* __FreeBSD__ */ - close(s); - if (description != NULL && strlen(description) == 0) { - /* - * Description is empty, so discard it. - */ - free(description); - description = NULL; - } - } - -#ifdef __FreeBSD__ - /* - * For FreeBSD, if we didn't get a description, and this is - * a device with a name of the form usbusN, label it as a USB - * bus. - */ - if (description == NULL) { - if (strncmp(name, "usbus", 5) == 0) { - /* - * OK, it begins with "usbus". - */ - long busnum; - char *p; - - errno = 0; - busnum = strtol(name + 5, &p, 10); - if (errno == 0 && p != name + 5 && *p == '\0' && - busnum >= 0 && busnum <= INT_MAX) { - /* - * OK, it's a valid number that's not - * bigger than INT_MAX. Construct - * a description from it. - */ - static const char descr_prefix[] = "USB bus number "; - size_t descr_size; - - /* - * Allow enough room for a 32-bit bus number. - * sizeof (descr_prefix) includes the - * terminating NUL. - */ - descr_size = sizeof (descr_prefix) + 10; - description = malloc(descr_size); - if (description != NULL) { - pcap_snprintf(description, descr_size, - "%s%ld", descr_prefix, busnum); - } - } - } - } -#endif - return (description); -#else /* SIOCGIFDESCR */ - return (NULL); -#endif /* SIOCGIFDESCR */ -} - -/* - * Look for a given device in the specified list of devices. - * - * If we find it, return 0 and set *curdev_ret to point to it. - * - * If we don't find it, check whether we can open it: - * - * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or - * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for - * it, as that probably means it exists but doesn't support - * packet capture. - * - * Otherwise, attempt to add an entry for it, with the specified - * ifnet flags and description, and, if that succeeds, return 0 - * and set *curdev_ret to point to the new entry, otherwise - * return PCAP_ERROR and set errbuf to an error message. If we - * weren't given a description, try to get one. - */ -int -add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, - bpf_u_int32 flags, const char *description, char *errbuf) -{ - pcap_t *p; - pcap_if_t *curdev, *prevdev, *nextdev; - u_int this_figure_of_merit, nextdev_figure_of_merit; - char open_errbuf[PCAP_ERRBUF_SIZE]; - int ret; - - /* - * Is there already an entry in the list for this interface? - */ - for (curdev = *alldevs; curdev != NULL; curdev = curdev->next) { - if (strcmp(name, curdev->name) == 0) - break; /* yes, we found it */ - } - - if (curdev == NULL) { - /* - * No, we didn't find it. - * - * Can we open this interface for live capture? - * - * We do this check so that interfaces that are - * supplied by the interface enumeration mechanism - * we're using but that don't support packet capture - * aren't included in the list. Loopback interfaces - * on Solaris are an example of this; we don't just - * omit loopback interfaces on all platforms because - * you *can* capture on loopback interfaces on some - * OSes. - * - * On OS X, we don't do this check if the device - * name begins with "wlt"; at least some versions - * of OS X offer monitor mode capturing by having - * a separate "monitor mode" device for each wireless - * adapter, rather than by implementing the ioctls - * that {Free,Net,Open,DragonFly}BSD provide. - * Opening that device puts the adapter into monitor - * mode, which, at least for some adapters, causes - * them to deassociate from the network with which - * they're associated. - * - * Instead, we try to open the corresponding "en" - * device (so that we don't end up with, for users - * without sufficient privilege to open capture - * devices, a list of adapters that only includes - * the wlt devices). - */ -#ifdef __APPLE__ - if (strncmp(name, "wlt", 3) == 0) { - char *en_name; - size_t en_name_len; - - /* - * Try to allocate a buffer for the "en" - * device's name. - */ - en_name_len = strlen(name) - 1; - en_name = malloc(en_name_len + 1); - if (en_name == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - return (-1); - } - strcpy(en_name, "en"); - strcat(en_name, name + 3); - p = pcap_create(en_name, open_errbuf); - free(en_name); - } else -#endif /* __APPLE */ - p = pcap_create(name, open_errbuf); - if (p == NULL) { - /* - * The attempt to create the pcap_t failed; - * that's probably an indication that we're - * out of memory. - * - * Don't bother including this interface, - * but don't treat it as an error. - */ - *curdev_ret = NULL; - return (0); - } - /* Small snaplen, so we don't try to allocate much memory. */ - pcap_set_snaplen(p, 68); - ret = pcap_activate(p); - pcap_close(p); - switch (ret) { - - case PCAP_ERROR_NO_SUCH_DEVICE: - case PCAP_ERROR_IFACE_NOT_UP: - /* - * We expect these two errors - they're the - * reason we try to open the device. - * - * PCAP_ERROR_NO_SUCH_DEVICE typically means - * "there's no such device *known to the - * OS's capture mechanism*", so, even though - * it might be a valid network interface, you - * can't capture on it (e.g., the loopback - * device in Solaris up to Solaris 10, or - * the vmnet devices in OS X with VMware - * Fusion). We don't include those devices - * in our list of devices, as there's no - * point in doing so - they're not available - * for capture. - * - * PCAP_ERROR_IFACE_NOT_UP means that the - * OS's capture mechanism doesn't work on - * interfaces not marked as up; some capture - * mechanisms *do* support that, so we no - * longer reject those interfaces out of hand, - * but we *do* want to reject them if they - * can't be opened for capture. - */ - *curdev_ret = NULL; - return (0); - } - - /* - * Yes, we can open it, or we can't, for some other - * reason. - * - * If we can open it, we want to offer it for - * capture, as you can capture on it. If we can't, - * we want to offer it for capture, so that, if - * the user tries to capture on it, they'll get - * an error and they'll know why they can't - * capture on it (e.g., insufficient permissions) - * or they'll report it as a problem (and then - * have the error message to provide as information). - * - * Allocate a new entry. - */ - curdev = malloc(sizeof(pcap_if_t)); - if (curdev == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - return (-1); - } - - /* - * Fill in the entry. - */ - curdev->next = NULL; - curdev->name = strdup(name); - if (curdev->name == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curdev); - return (-1); - } - if (description == NULL) { - /* - * We weren't handed a description for the - * interface, so see if we can generate one - * ourselves. - */ - curdev->description = get_if_description(name); - } else { - /* - * We were handed a description; make a copy. - */ - curdev->description = strdup(description); - if (curdev->description == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curdev->name); - free(curdev); - return (-1); - } - } - curdev->addresses = NULL; /* list starts out as empty */ - curdev->flags = flags; - - /* - * Add it to the list, in the appropriate location. - * First, get the "figure of merit" for this - * interface. - */ - this_figure_of_merit = get_figure_of_merit(curdev); - - /* - * Now look for the last interface with an figure of merit - * less than or equal to the new interface's figure of - * merit. - * - * We start with "prevdev" being NULL, meaning we're before - * the first element in the list. - */ - prevdev = NULL; - for (;;) { - /* - * Get the interface after this one. - */ - if (prevdev == NULL) { - /* - * The next element is the first element. - */ - nextdev = *alldevs; - } else - nextdev = prevdev->next; - - /* - * Are we at the end of the list? - */ - if (nextdev == NULL) { - /* - * Yes - we have to put the new entry - * after "prevdev". - */ - break; - } - - /* - * Is the new interface's figure of merit less - * than the next interface's figure of merit, - * meaning that the new interface is better - * than the next interface? - */ - nextdev_figure_of_merit = get_figure_of_merit(nextdev); - if (this_figure_of_merit < nextdev_figure_of_merit) { - /* - * Yes - we should put the new entry - * before "nextdev", i.e. after "prevdev". - */ - break; - } - - prevdev = nextdev; - } - - /* - * Insert before "nextdev". - */ - curdev->next = nextdev; - - /* - * Insert after "prevdev" - unless "prevdev" is null, - * in which case this is the first interface. - */ - if (prevdev == NULL) { - /* - * This is the first interface. Pass back a - * pointer to it, and put "curdev" before - * "nextdev". - */ - *alldevs = curdev; - } else - prevdev->next = curdev; - } - - *curdev_ret = curdev; - return (0); -} - -/* - * Try to get a description for a given device, and then look for that - * device in the specified list of devices. - * - * If we find it, then, if the specified address isn't null, add it to - * the list of addresses for the device and return 0. - * - * If we don't find it, check whether we can open it: - * - * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or - * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for - * it, as that probably means it exists but doesn't support - * packet capture. - * - * Otherwise, attempt to add an entry for it, with the specified - * ifnet flags, and, if that succeeds, add the specified address - * to its list of addresses if that address is non-null, set - * *curdev_ret to point to the new entry, and return 0, otherwise - * return PCAP_ERROR and set errbuf to an error message. - * - * (We can get called with a null address because we might get a list - * of interface name/address combinations from the underlying OS, with - * the address being absent in some cases, rather than a list of - * interfaces with each interface having a list of addresses, so this - * call may be the only call made to add to the list, and we want to - * add interfaces even if they have no addresses.) - */ -int -add_addr_to_iflist(pcap_if_t **alldevs, const char *name, bpf_u_int32 flags, - struct sockaddr *addr, size_t addr_size, - struct sockaddr *netmask, size_t netmask_size, - struct sockaddr *broadaddr, size_t broadaddr_size, - struct sockaddr *dstaddr, size_t dstaddr_size, - char *errbuf) -{ - pcap_if_t *curdev; - - if (add_or_find_if(&curdev, alldevs, name, flags, NULL, errbuf) == -1) { - /* - * Error - give up. - */ - return (-1); - } - if (curdev == NULL) { - /* - * Device wasn't added because it can't be opened. - * Not a fatal error. - */ - return (0); - } - - if (addr == NULL) { - /* - * There's no address to add; this entry just meant - * "here's a new interface". - */ - return (0); - } - - /* - * "curdev" is an entry for this interface, and we have an - * address for it; add an entry for that address to the - * interface's list of addresses. - * - * Allocate the new entry and fill it in. - */ - return (add_addr_to_dev(curdev, addr, addr_size, netmask, - netmask_size, broadaddr, broadaddr_size, dstaddr, - dstaddr_size, errbuf)); -} - -/* - * Add an entry to the list of addresses for an interface. - * "curdev" is the entry for that interface. - * If this is the first IP address added to the interface, move it - * in the list as appropriate. - */ -int -add_addr_to_dev(pcap_if_t *curdev, - struct sockaddr *addr, size_t addr_size, - struct sockaddr *netmask, size_t netmask_size, - struct sockaddr *broadaddr, size_t broadaddr_size, - struct sockaddr *dstaddr, size_t dstaddr_size, - char *errbuf) -{ - pcap_addr_t *curaddr, *prevaddr, *nextaddr; - - curaddr = malloc(sizeof(pcap_addr_t)); - if (curaddr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - return (-1); - } - - curaddr->next = NULL; - if (addr != NULL) { - curaddr->addr = dup_sockaddr(addr, addr_size); - if (curaddr->addr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - free(curaddr); - return (-1); - } - } else - curaddr->addr = NULL; - - if (netmask != NULL) { - curaddr->netmask = dup_sockaddr(netmask, netmask_size); - if (curaddr->netmask == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - if (curaddr->addr != NULL) - free(curaddr->addr); - free(curaddr); - return (-1); - } - } else - curaddr->netmask = NULL; - - if (broadaddr != NULL) { - curaddr->broadaddr = dup_sockaddr(broadaddr, broadaddr_size); - if (curaddr->broadaddr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - if (curaddr->netmask != NULL) - free(curaddr->netmask); - if (curaddr->addr != NULL) - free(curaddr->addr); - free(curaddr); - return (-1); - } - } else - curaddr->broadaddr = NULL; - - if (dstaddr != NULL) { - curaddr->dstaddr = dup_sockaddr(dstaddr, dstaddr_size); - if (curaddr->dstaddr == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, - "malloc: %s", pcap_strerror(errno)); - if (curaddr->broadaddr != NULL) - free(curaddr->broadaddr); - if (curaddr->netmask != NULL) - free(curaddr->netmask); - if (curaddr->addr != NULL) - free(curaddr->addr); - free(curaddr); - return (-1); - } - } else - curaddr->dstaddr = NULL; - - /* - * Find the end of the list of addresses. - */ - for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) { - nextaddr = prevaddr->next; - if (nextaddr == NULL) { - /* - * This is the end of the list. - */ - break; - } - } - - if (prevaddr == NULL) { - /* - * The list was empty; this is the first member. - */ - curdev->addresses = curaddr; - } else { - /* - * "prevaddr" is the last member of the list; append - * this member to it. - */ - prevaddr->next = curaddr; - } - - return (0); -} - -/* - * Look for a given device in the specified list of devices. - * - * If we find it, return 0. - * - * If we don't find it, check whether we can open it: - * - * If that fails with PCAP_ERROR_NO_SUCH_DEVICE or - * PCAP_ERROR_IFACE_NOT_UP, don't attempt to add an entry for - * it, as that probably means it exists but doesn't support - * packet capture. - * - * Otherwise, attempt to add an entry for it, with the specified - * ifnet flags and description, and, if that succeeds, return 0 - * and set *curdev_ret to point to the new entry, otherwise - * return PCAP_ERROR and set errbuf to an error message. - */ -int -pcap_add_if(pcap_if_t **devlist, const char *name, u_int flags, - const char *description, char *errbuf) -{ - pcap_if_t *curdev; - - return (add_or_find_if(&curdev, devlist, name, flags, description, - errbuf)); -} - - -/* - * Free a list of interfaces. - */ -void -pcap_freealldevs(pcap_if_t *alldevs) -{ - pcap_if_t *curdev, *nextdev; - pcap_addr_t *curaddr, *nextaddr; - - for (curdev = alldevs; curdev != NULL; curdev = nextdev) { - nextdev = curdev->next; - - /* - * Free all addresses. - */ - for (curaddr = curdev->addresses; curaddr != NULL; curaddr = nextaddr) { - nextaddr = curaddr->next; - if (curaddr->addr) - free(curaddr->addr); - if (curaddr->netmask) - free(curaddr->netmask); - if (curaddr->broadaddr) - free(curaddr->broadaddr); - if (curaddr->dstaddr) - free(curaddr->dstaddr); - free(curaddr); - } - - /* - * Free the name string. - */ - free(curdev->name); - - /* - * Free the description string, if any. - */ - if (curdev->description != NULL) - free(curdev->description); - - /* - * Free the interface. - */ - free(curdev); - } -} diff --git a/libpcap/fmtutils.c b/libpcap/fmtutils.c new file mode 100644 index 000000000..f1a890732 --- /dev/null +++ b/libpcap/fmtutils.c @@ -0,0 +1,131 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 + * 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 Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory 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. + */ + +/* + * Utilities for message formatting used both by libpcap and rpcapd. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "ftmacros.h" + +#include +#include +#include +#include +#include + +#include + +#include "portability.h" + +#include "fmtutils.h" + +/* + * Generate an error message based on a format, arguments, and an + * errno, with a message for the errno after the formatted output. + */ +void +pcap_fmt_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; +#if defined(HAVE_STRERROR_S) + errno_t err; +#elif defined(HAVE_STRERROR_R) + int err; +#endif + + va_start(ap, fmt); + pcap_vsnprintf(errbuf, errbuflen, fmt, ap); + va_end(ap); + msglen = strlen(errbuf); + + /* + * Do we have enough space to append ": "? + * Including the terminating '\0', that's 3 bytes. + */ + if (msglen + 3 > errbuflen) { + /* No - just give them what we've produced. */ + return; + } + p = errbuf + msglen; + errbuflen_remaining = errbuflen - msglen; + *p++ = ':'; + *p++ = ' '; + *p = '\0'; + msglen += 2; + errbuflen_remaining -= 2; + + /* + * Now append the string for the error code. + */ +#if defined(HAVE_STRERROR_S) + err = strerror_s(p, errbuflen_remaining, errnum); + if (err != 0) { + /* + * It doesn't appear to be documented anywhere obvious + * what the error returns from strerror_s(). + */ + pcap_snprintf(p, errbuflen_remaining, "Error %d", errnum); + } +#elif defined(HAVE_STRERROR_R) + err = strerror_r(errnum, p, errbuflen_remaining); + if (err == EINVAL) { + /* + * UNIX 03 says this isn't guaranteed to produce a + * fallback error message. + */ + pcap_snprintf(p, errbuflen_remaining, "Unknown error: %d", + errnum); + } else if (err == ERANGE) { + /* + * UNIX 03 says this isn't guaranteed to produce a + * fallback error message. + */ + pcap_snprintf(p, errbuflen_remaining, + "Message for error %d is too long", errnum); + } +#else + /* + * We have neither strerror_s() nor strerror_r(), so we're + * stuck with using pcap_strerror(). + */ + pcap_snprintf(p, errbuflen_remaining, "%s", pcap_strerror(errnum)); +#endif +} diff --git a/libpcap/fmtutils.h b/libpcap/fmtutils.h new file mode 100644 index 000000000..62c78fdba --- /dev/null +++ b/libpcap/fmtutils.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1994, 1995, 1996 + * 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 Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory 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. + */ + +#ifndef fmtutils_h +#define fmtutils_h + +#include "pcap/funcattrs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void pcap_fmt_errmsg_for_errno(char *, size_t, int, + PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libpcap/ftmacros.h b/libpcap/ftmacros.h new file mode 100644 index 000000000..de8da98e3 --- /dev/null +++ b/libpcap/ftmacros.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1994, 1995, 1996 + * 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 Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory 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. + */ + +#ifndef ftmacros_h +#define ftmacros_h + +/* + * Define some feature test macros to make sure that everything we want + * to be declared gets declared. + * + * On some UN*Xes we need to force strtok_r() to be declared. + * We do *NOT* want to define _POSIX_C_SOURCE, as that tends + * to make non-POSIX APIs that we use unavailable. + * XXX - is there no portable way to say "please pollute the + * namespace to the maximum extent possible"? + */ +#if defined(sun) || defined(__sun) + #define __EXTENSIONS__ + + /* + * We also need to define _XPG4_2 in order to get + * the Single UNIX Specification version of + * recvmsg(). + */ + #define _XPG4_2 +#elif defined(_hpux) || defined(hpux) || defined(__hpux) + #define _REENTRANT + + /* + * We need this to get the versions of socket functions that + * use socklen_t. Define it only if it's not already defined, + * so we don't get redefiniton warnings. + */ + #ifndef _XOPEN_SOURCE_EXTENDED + #define _XOPEN_SOURCE_EXTENDED + #endif + + /* + * XXX - the list of PA-RISC options for GCC makes it sound as if + * building code that uses a particular vintage of UNIX API/ABI + * is complicated: + * + * https://gcc.gnu.org/onlinedocs/gcc/HPPA-Options.html + * + * See the description of the -munix flag. + * + * We probably want libpcap to work with programs built for any + * UN*X standard. I'm not sure whether that's possible and, if + * it is, what sort of stuff it'd have to do. + * + * It might also be a requirement that we build with a special + * flag to allow the library to be used with threaded code, at + * least with HP's C compiler; hopefully doing so won't make it + * *not* work with *un*-threaded code. + */ +#elif defined(__linux__) || defined(linux) || defined(__linux) + /* + * We can't turn _GNU_SOURCE on because some versions of GNU Libc + * will give the GNU version of strerror_r(), which returns a + * string pointer and doesn't necessarily fill in the buffer, + * rather than the standard version of strerror_r(), which + * returns 0 or an errno and always fills in the buffer. We + * require both of the latter behaviors. + * + * So we try turning everything else on that we can. This includes + * defining _XOPEN_SOURCE as 600, because we want to force crypt() + * to be declared on systems that use GNU libc, such as most Linux + * distributions. + */ + #define _POSIX_C_SOURCE 200809L + #define _XOPEN_SOURCE 600 + + /* + * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get + * the BSD u_XXX types, such as u_int and u_short, defined. We + * define _DEFAULT_SOURCE first, so that newer versions of GNU libc + * don't whine about _BSD_SOURCE being deprecated; we still have + * to define _BSD_SOURCE to handle older versions of GNU libc that + * don't support _DEFAULT_SOURCE. + */ + #define _DEFAULT_SOURCE + #define _BSD_SOURCE +#endif + +#endif diff --git a/libpcap/gen_version_c.sh b/libpcap/gen_version_c.sh deleted file mode 100755 index d5a5e75bf..000000000 --- a/libpcap/gen_version_c.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh -echo '#include ' > "$2" -echo 'PCAP_API_DEF' >> "$2" -if grep GIT "$1" >/dev/null; then - read ver <"$1" - echo $ver | tr -d '\012' - date +_%Y_%m_%d -else - cat "$1" -fi | sed -e 's/.*/char pcap_version[] = "&";/' >> "$2" - diff --git a/libpcap/gen_version_header.sh b/libpcap/gen_version_header.sh deleted file mode 100755 index 6b4b82da1..000000000 --- a/libpcap/gen_version_header.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/sh -print_version_string() -{ - if grep GIT "$1" >/dev/null - then - read ver <"$1" - echo $ver | tr -d '\012' - date +_%Y_%m_%d - else - cat "$1" - fi -} -if test $# != 3 -then - echo "Usage: gen_version_header.sh