From d109bf9e4b609b5a0626b433e56db4a47dc530bb Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 18 May 2018 12:21:19 +0000 Subject: [PATCH] Import vendor revision 77da77c36e5d958f9b8d6729876a33f670de031f from: https://github.com/the-tcpdump-group/libpcap.git This among other minor fixes adds support for sniffing RDMA devices. Sponsored by: Mellanox Technologies --- CHANGES | 27 + CMakeLists.txt | 2354 ++++++++++++-- CONTRIBUTING | 29 + CREDITS | 2 +- GenVersion.bat | 23 - INSTALL.txt | 25 +- Makefile.in | 265 +- README | 55 +- README.macosx => README.macos | 14 +- README.septel | 2 +- README.sita | 2 +- SUNOS4/nit_if.o.sparc | Bin 5212 -> 0 bytes SUNOS4/nit_if.o.sun3 | Bin 4267 -> 0 bytes SUNOS4/nit_if.o.sun4c.4.0.3c | Bin 5291 -> 0 bytes VERSION | 2 +- Win32/Include/Gnuc.h | 8 - Win32/Include/net/if.h | 230 -- Win32/Prj/wpcap.vcxproj | 13 +- Win32/Prj/wpcap.vcxproj.filters | 2 +- aclocal.m4 | 393 +-- bpf_dump.c | 7 +- bpf/net/bpf_filter.c => bpf_filter.c | 289 +- bpf_image.c | 158 +- chmod_bpf | 2 +- cmake/Modules/FindDAG.cmake | 32 + cmake/Modules/FindFseeko.cmake | 85 + cmake/Modules/FindLFS.cmake | 153 + cmake/Modules/FindPacket.cmake | 81 + cmake/Modules/FindPthreads-w32.cmake | 152 + cmake/Modules/FindSNF.cmake | 24 + cmake/Modules/FindTC.cmake | 24 + {config => cmake}/have_siocglifconf.c | 0 cmake/preconfigure.cmake | 55 - cmake_uninstall.cmake.in | 21 + cmakeconfig.h.in | 229 +- config.h.in | 203 +- configure | 4013 +++++++++++++++--------- configure.ac | 1442 ++++++--- diag-control.h | 215 ++ dlpisubs.c | 18 +- etherent.c | 79 +- extract.h | 16 +- fad-getad.c | 40 +- fad-gifc.c | 89 +- fad-glifc.c | 73 +- fad-helpers.c | 884 ------ fmtutils.c | 131 + fmtutils.h | 50 + ftmacros.h | 115 + gen_version_c.sh | 11 - gen_version_header.sh | 19 - gencode.c | 807 +++-- gencode.h | 42 +- grammar.y | 63 +- inet.c | 403 --- libpcap.pc.in | 18 + missing/getopt.c | 5 +- missing/getopt.h | 2 +- missing/strtok_r.c | 2 +- msdos/common.dj | 86 - msdos/makefile | 6 +- msdos/makefile.dj | 2 +- msdos/makefile.wc | 4 +- msdos/ndis2.c | 860 ----- msdos/ndis2.h | 559 ---- msdos/ndis_0.asm | 188 -- nametoaddr.c | 421 ++- nomkdep | 6 + optimize.c | 270 +- optimize.h | 28 + pcap-bpf.c | 606 ++-- pcap-bt-linux.c | 83 +- pcap-bt-linux.h | 2 +- pcap-bt-monitor-linux.c | 48 +- pcap-bt-monitor-linux.h | 2 +- pcap-common.c | 132 +- pcap-common.h | 24 + pcap-config.in | 9 +- pcap-dag.c | 741 +++-- pcap-dag.h | 2 +- pcap-dbus.c | 86 +- pcap-dbus.h | 2 +- pcap-dll.rc | 36 + pcap-dlpi.c | 246 +- pcap-dos.c | 70 +- pcap-enet.c | 2 +- pcap-filter.manmisc.in | 38 +- pcap-int.h | 156 +- pcap-libdlpi.c | 72 +- pcap-linux.c | 850 +++-- pcap-netfilter-linux.c | 205 +- pcap-netfilter-linux.h | 2 +- pcap-netmap.c | 306 ++ pcap-netmap.h | 2 + pcap-new.c | 1095 +------ pcap-nit.c | 63 +- pcap-win32.c => pcap-npf.c | 1144 +++++-- pcap-null.c | 30 +- pcap-pf.c | 115 +- pcap-rdmasniff.c | 436 +++ pcap-rdmasniff.h | 2 + pcap-rpcap-int.h | 75 + pcap-rpcap.c | 3413 +++++++++++++------- pcap-rpcap.h | 478 +-- pcap-septel.c | 70 +- pcap-septel.h | 2 +- pcap-sita.c | 72 +- pcap-snf.c | 353 ++- pcap-snf.h | 2 +- pcap-snit.c | 104 +- pcap-snoop.c | 80 +- pcap-stdinc.h | 126 - pcap-tc.c | 71 +- pcap-tc.h | 2 +- pcap-tstamp.manmisc.in | 6 +- pcap-types.h | 50 + pcap-usb-linux.c | 461 ++- pcap-usb-linux.h | 2 +- pcap.3pcap.in | 88 +- pcap.c | 2413 +++++++++++--- pcap/bluetooth.h | 9 +- pcap/bpf.h | 8 +- pcap/can_socketcan.h | 12 +- pcap/compiler-tests.h | 163 + pcap/dlt.h | 99 +- pcap/export-defs.h | 108 - pcap/funcattrs.h | 261 ++ pcap/namedb.h | 2 - pcap/nflog.h | 28 +- pcap/pcap-inttypes.h | 117 + pcap/pcap.h | 469 ++- pcap/sll.h | 12 +- pcap/usb.h | 54 +- pcap/vlan.h | 6 +- pcap_breakloop.3pcap | 16 +- pcap_compile.3pcap.in | 10 + pcap_dump_ftell.3pcap | 17 +- pcap_dump_open.3pcap.in | 4 +- pcap_fileno.3pcap | 2 +- pcap_findalldevs.3pcap | 24 + pcap_get_required_select_timeout.3pcap | 84 + pcap_get_selectable_fd.3pcap | 96 +- pcap_lookupdev.3pcap | 22 +- pcap_loop.3pcap | 18 +- pcap_major_version.3pcap | 2 +- pcap_next_ex.3pcap | 27 +- pcap_open_dead.3pcap.in | 2 +- pcap_open_live.3pcap | 7 +- pcap_open_offline.3pcap.in | 2 +- pcap_set_protocol.3pcap | 67 + pcap_set_timeout.3pcap | 19 +- pcap_set_tstamp_type.3pcap.in | 2 +- pcap_version.h.in | 13 - portability.h | 114 +- remote-ext.h | 467 --- rpcap-protocol.c | 195 ++ rpcap-protocol.h | 450 +++ savefile.c | 69 +- scanner.l | 93 +- sf-pcap.c | 302 +- sf-pcap-ng.c => sf-pcapng.c | 172 +- sf-pcap-ng.h => sf-pcapng.h | 8 +- sockutils.c | 485 ++- sockutils.h | 79 +- tests/CMakeLists.txt | 42 - tests/can_set_rfmon_test.c | 92 - tests/capturetest.c | 334 -- tests/filtertest.c | 364 --- tests/findalldevstest.c | 161 - tests/opentest.c | 273 -- tests/reactivatetest.c | 84 - tests/selpolltest.c | 407 --- tests/shb-option-too-long.pcapng | Bin 0 -> 180 bytes tests/valgrindtest.c | 470 --- varattrs.h | 59 + 175 files changed, 21177 insertions(+), 15728 deletions(-) create mode 100644 CONTRIBUTING delete mode 100644 GenVersion.bat rename README.macosx => README.macos (86%) delete mode 100644 SUNOS4/nit_if.o.sparc delete mode 100644 SUNOS4/nit_if.o.sun3 delete mode 100644 SUNOS4/nit_if.o.sun4c.4.0.3c delete mode 100644 Win32/Include/Gnuc.h delete mode 100644 Win32/Include/net/if.h rename bpf/net/bpf_filter.c => bpf_filter.c (68%) create mode 100644 cmake/Modules/FindDAG.cmake create mode 100644 cmake/Modules/FindFseeko.cmake create mode 100644 cmake/Modules/FindLFS.cmake create mode 100644 cmake/Modules/FindPacket.cmake create mode 100644 cmake/Modules/FindPthreads-w32.cmake create mode 100644 cmake/Modules/FindSNF.cmake create mode 100644 cmake/Modules/FindTC.cmake rename {config => cmake}/have_siocglifconf.c (100%) delete mode 100644 cmake/preconfigure.cmake create mode 100644 cmake_uninstall.cmake.in create mode 100644 diag-control.h delete mode 100644 fad-helpers.c create mode 100644 fmtutils.c create mode 100644 fmtutils.h create mode 100644 ftmacros.h delete mode 100755 gen_version_c.sh delete mode 100755 gen_version_header.sh delete mode 100644 inet.c create mode 100644 libpcap.pc.in delete mode 100644 msdos/common.dj delete mode 100644 msdos/ndis2.c delete mode 100644 msdos/ndis2.h delete mode 100644 msdos/ndis_0.asm create mode 100644 nomkdep create mode 100644 optimize.h create mode 100644 pcap-dll.rc create mode 100644 pcap-netmap.c create mode 100644 pcap-netmap.h rename pcap-win32.c => pcap-npf.c (57%) create mode 100644 pcap-rdmasniff.c create mode 100644 pcap-rdmasniff.h create mode 100644 pcap-rpcap-int.h delete mode 100644 pcap-stdinc.h create mode 100644 pcap-types.h create mode 100644 pcap/compiler-tests.h delete mode 100644 pcap/export-defs.h create mode 100644 pcap/funcattrs.h create mode 100644 pcap/pcap-inttypes.h create mode 100644 pcap_get_required_select_timeout.3pcap create mode 100644 pcap_set_protocol.3pcap delete mode 100644 pcap_version.h.in delete mode 100644 remote-ext.h create mode 100644 rpcap-protocol.c create mode 100644 rpcap-protocol.h rename sf-pcap-ng.c => sf-pcapng.c (88%) rename sf-pcap-ng.h => sf-pcapng.h (90%) delete mode 100644 tests/CMakeLists.txt delete mode 100644 tests/can_set_rfmon_test.c delete mode 100644 tests/capturetest.c delete mode 100644 tests/filtertest.c delete mode 100644 tests/findalldevstest.c delete mode 100644 tests/opentest.c delete mode 100644 tests/reactivatetest.c delete mode 100644 tests/selpolltest.c create mode 100644 tests/shb-option-too-long.pcapng delete mode 100644 tests/valgrindtest.c create mode 100644 varattrs.h diff --git a/CHANGES b/CHANGES index 178409659305..8c72dbe9cd42 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,30 @@ +Wednesday, Jan. 25, 2017 guy@alum.mit.edu + Summary for 1.9.0 libpcap release + 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/CMakeLists.txt b/CMakeLists.txt index 0ed8b61291a6..ce6915512045 100644 --- a/CMakeLists.txt +++ b/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() + +# 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() -file(GLOB PROJECT_SOURCE_LIST_CORE_H +# +# 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,489 @@ 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.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) + +# 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/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 000000000000..a3c2bd68d027 --- /dev/null +++ b/CONTRIBUTING @@ -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](http://www.tcpdump.org/#mailing-lists) +to the mailing list tcpdump-workers@lists.tcpdump.org and ask! diff --git a/CREDITS b/CREDITS index b40152f5e54b..b959c77c07e8 100644 --- a/CREDITS +++ b/CREDITS @@ -64,7 +64,7 @@ Additional people who have contributed patches: George Neville-Neil Gianluca Varenni Gilbert Hoyek - Gisle Vanem + Gisle Vanem Graeme Hewson Gregor Maier Greg Stark diff --git a/GenVersion.bat b/GenVersion.bat deleted file mode 100644 index babf3737efa5..000000000000 --- a/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/INSTALL.txt b/INSTALL.txt index f305aa2b7929..e39c122a341b 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -250,28 +250,13 @@ 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 LICENSE - the license under which tcpdump is distributed @@ -281,12 +266,11 @@ 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.macos - notes on using libpcap on macOS 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 VERSION - version of this release acconfig.h - support for post-2.13 autoconf aclocal.m4 - autoconf macros @@ -314,7 +298,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 +330,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 +344,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/Makefile.in b/Makefile.in index e71d973ca448..6fcd3afc4e00 100644 --- a/Makefile.in +++ b/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,9 +63,13 @@ 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@ @@ -79,13 +86,14 @@ YACC = @YACC@ @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) @@ -100,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 \ @@ -113,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) \ +CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \ $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ - lex.yy.c pcap-config + lex.yy.c pcap-config libpcap.pc MAN1 = pcap-config.1 @@ -191,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 \ @@ -207,6 +205,7 @@ MAN3PCAP_NOEXPAND = \ pcap_set_datalink.3pcap \ pcap_set_immediate_mode.3pcap \ pcap_set_promisc.3pcap \ + pcap_set_protocol.3pcap \ pcap_set_rfmon.3pcap \ pcap_set_snaplen.3pcap \ pcap_set_timeout.3pcap \ @@ -231,13 +230,11 @@ MANMISC = \ pcap-tstamp.manmisc.in EXTRA_DIST = \ - $(TESTS_SRC) \ CHANGES \ ChmodBPF/ChmodBPF \ ChmodBPF/StartupParameters.plist \ CREDITS \ CMakeLists.txt \ - GenVersion.bat \ INSTALL.txt \ LICENSE \ Makefile.in \ @@ -247,22 +244,25 @@ EXTRA_DIST = \ README.dag \ README.hpux \ README.linux \ - README.macosx \ + README.macos \ 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 \ + CONTRIBUTING \ 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 \ @@ -273,9 +273,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 \ @@ -286,6 +283,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 \ @@ -293,18 +291,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 \ @@ -316,6 +311,7 @@ EXTRA_DIST = \ pcap-dag.h \ pcap-dbus.c \ pcap-dbus.h \ + pcap-dll.rc \ pcap-dlpi.c \ pcap-dos.c \ pcap-dos.h \ @@ -327,11 +323,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 \ @@ -345,20 +346,47 @@ 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.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 +all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config libpcap.a: $(OBJ) @rm -f $@ @@ -371,20 +399,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 @@ -434,7 +460,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 # @@ -455,8 +481,6 @@ scanner.h: scanner.c 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 @@ -466,43 +490,20 @@ grammar.h: 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 @@ -513,7 +514,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 @@ -521,36 +531,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) ] || \ @@ -571,6 +566,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 @@ -671,11 +669,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 @@ -723,15 +725,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) @@ -748,5 +757,7 @@ releasetar: 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/README b/README index 9f65948d4ef2..24fdc80d6989 100644 --- a/README +++ b/README @@ -1,19 +1,16 @@ +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 in the libpcap source tree root. + 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. - formerly from Lawrence Berkeley National Laboratory Network Research Group ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z @@ -43,15 +40,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,13 +59,13 @@ 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 @@ -87,20 +84,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/README.macosx b/README.macos similarity index 86% rename from README.macosx rename to README.macos index 3dc92117123c..3cceb23329a1 100644 --- a/README.macosx +++ b/README.macos @@ -1,5 +1,5 @@ -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 +As with other systems using BPF, macOS 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 @@ -12,16 +12,16 @@ 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 +On macOS, the BPF devices live on devfs, but the macOS 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 "startup item" for older versions of macOS; - a launchd daemon for Tiger and later versions of Mac OS X; + a launchd daemon for Tiger and later versions of macOS; 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 diff --git a/README.septel b/README.septel index 483de6a7f969..fa2c0c9a40d9 100644 --- a/README.septel +++ b/README.septel @@ -40,7 +40,7 @@ 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 +0x2d for technical reason. So this change in system.txt is crucial 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 diff --git a/README.sita b/README.sita index 014d51d98d98..5a65822ecedb 100644 --- a/README.sita +++ b/README.sita @@ -1,5 +1,5 @@ The following instructions apply if you have a Linux platform and want -libpcap to support the 'ACN' WAN/LAN router product from from SITA +libpcap to support the 'ACN' WAN/LAN router product from SITA (http://www.sita.aero) This might also work on non-Linux Unix-compatible platforms, but that diff --git a/SUNOS4/nit_if.o.sparc b/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/SUNOS4/nit_if.o.sun3 b/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/Win32/Prj/wpcap.vcxproj b/Win32/Prj/wpcap.vcxproj index c923357aa9a5..43b7099b7707 100644 --- a/Win32/Prj/wpcap.vcxproj +++ b/Win32/Prj/wpcap.vcxproj @@ -100,7 +100,7 @@ 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) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) 0x0409 @@ -125,7 +125,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.ytrue 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) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) 0x0409 @@ -151,7 +151,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.ytrue 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) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) EnableFastChecks @@ -177,7 +177,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.yLevel3 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) + HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions) EnableFastChecks @@ -198,7 +198,6 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - @@ -212,7 +211,7 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - + @@ -231,4 +230,4 @@ win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y - \ No newline at end of file + diff --git a/Win32/Prj/wpcap.vcxproj.filters b/Win32/Prj/wpcap.vcxproj.filters index 72f1492c0222..6e06ccbce11d 100644 --- a/Win32/Prj/wpcap.vcxproj.filters +++ b/Win32/Prj/wpcap.vcxproj.filters @@ -43,7 +43,7 @@ Source Files - + Source Files diff --git a/aclocal.m4 b/aclocal.m4 index 83f5761f0b13..2b63c8842d5f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -384,8 +384,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 +394,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 +403,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 +418,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 +431,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 +469,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 +491,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 +506,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 +532,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 +540,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 +563,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 +689,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 +847,16 @@ 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) + AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code) fi AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT() # @@ -1020,234 +945,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/bpf_dump.c b/bpf_dump.c index d5ab61e5e8ff..a9c91169fbbb 100644 --- a/bpf_dump.c +++ b/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/bpf/net/bpf_filter.c b/bpf_filter.c similarity index 68% rename from bpf/net/bpf_filter.c rename to bpf_filter.c index 01a1b64e7197..615ed3fc3d0f 100644 --- a/bpf/net/bpf_filter.c +++ b/bpf_filter.c @@ -39,47 +39,21 @@ */ #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 +#include "pcap-types.h" +#ifndef _WIN32 #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 @@ -117,84 +91,6 @@ (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 @@ -220,27 +116,12 @@ enum { * 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; +bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p, + u_int wirelen, u_int buflen, 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) /* @@ -250,16 +131,12 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) A = 0; X = 0; --pc; - while (1) { + for (;;) { ++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; @@ -269,16 +146,7 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) 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; @@ -286,65 +154,37 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) 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) { - 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; +#if defined(SKF_AD_VLAN_TAG_PRESENT) + case SKF_AD_OFF + SKF_AD_VLAN_TAG: + if (!aux_data) + return 0; + A = aux_data->vlan_tag; + break; - case BPF_S_ANC_VLAN_TAG_PRESENT: - if (aux_data) - A = aux_data->vlan_tag_present; - break; - } + case SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT: + if (!aux_data) + return 0; + A = aux_data->vlan_tag_present; + break; #endif - continue; + default: + k = pc->k; + if (k >= buflen) { + return 0; + } + A = p[k]; + break; } + continue; + case BPF_LD|BPF_W|BPF_LEN: A = wirelen; continue; @@ -357,16 +197,7 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) 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; @@ -375,16 +206,7 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) 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; @@ -392,16 +214,7 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) 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; @@ -409,16 +222,7 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) 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; @@ -448,18 +252,11 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) 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: @@ -599,11 +396,8 @@ bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data) } 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; +bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen, + u_int buflen) { return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL); } @@ -621,22 +415,13 @@ bpf_filter(pc, p, wirelen, buflen) * Otherwise, a bogus program could easily crash the system. */ int -bpf_validate(f, len) - const struct bpf_insn *f; - int len; +bpf_validate(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]; @@ -657,14 +442,6 @@ bpf_validate(f, len) * 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) @@ -736,11 +513,7 @@ bpf_validate(f, len) 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: diff --git a/bpf_image.c b/bpf_image.c index 01ec536dfd62..ab41d1ef98bd 100644 --- a/bpf_image.c +++ b/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/chmod_bpf b/chmod_bpf index 0a30d99301e4..946fec37f2c8 100755 --- a/chmod_bpf +++ b/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/cmake/Modules/FindDAG.cmake b/cmake/Modules/FindDAG.cmake new file mode 100644 index 000000000000..ef1352844558 --- /dev/null +++ b/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/cmake/Modules/FindFseeko.cmake b/cmake/Modules/FindFseeko.cmake new file mode 100644 index 000000000000..ca53a5a61425 --- /dev/null +++ b/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/cmake/Modules/FindLFS.cmake b/cmake/Modules/FindLFS.cmake new file mode 100644 index 000000000000..be5f0d4875a8 --- /dev/null +++ b/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/cmake/Modules/FindPacket.cmake b/cmake/Modules/FindPacket.cmake new file mode 100644 index 000000000000..1311cdb94f15 --- /dev/null +++ b/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/cmake/Modules/FindPthreads-w32.cmake b/cmake/Modules/FindPthreads-w32.cmake new file mode 100644 index 000000000000..ba2a78c2e404 --- /dev/null +++ b/cmake/Modules/FindPthreads-w32.cmake @@ -0,0 +1,152 @@ +# ============================================================================== +# This is a heavily modified version of FindPthreads.cmake for the pcap project. +# It's meant to find Pthreads-w32, an implementation of the +# Threads component of the POSIX 1003.1c 1995 Standard (or later) +# for Microsoft's WIndows. +# +# Apart from this notice, this module "enjoys" the following modifications: +# +# - changed its name to FindPthreads-w32.cmake to not conflict with FindThreads.cmake +# +# - users may be able to use the environment variable PTHREADS_ROOT to point +# cmake to the *root* of their Pthreads-w32 installation. +# Alternatively, PTHREADS_ROOT may also be set from cmake command line or GUI +# (-DPTHREADS_ROOT=/path/to/Pthreads-w32) +# Two other variables that can be defined in a similar fashion are +# PTHREAD_INCLUDE_PATH and PTHREAD_LIBRARY_PATH. +# +# - added some additional status/error messages +# +# - changed formating (uppercase to lowercare + indentation) +# +# - removed some stuff +# +# - when searching for Pthreads-win32 libraries, the directory structure of the +# pre-build binaries folder found in the pthreads-win32 CVS code repository is +# considered (e.i /Pre-built.2/lib/x64 /Pre-built.2/lib/x86) +# +# Send suggestion, patches, gifts and praises to pcap's developers. +# ============================================================================== +# +# Find the Pthreads library +# This module searches for the Pthreads-win32 library (including the +# pthreads-win32 port). +# +# This module defines these variables: +# +# PTHREADS_FOUND - True if the Pthreads library was found +# PTHREADS_LIBRARY - The location of the Pthreads library +# PTHREADS_INCLUDE_DIR - The include directory of the Pthreads library +# PTHREADS_DEFINITIONS - Preprocessor definitions to define (HAVE_PTHREAD_H is a fairly common one) +# +# This module responds to the PTHREADS_EXCEPTION_SCHEME +# variable on Win32 to allow the user to control the +# library linked against. The Pthreads-win32 port +# provides the ability to link against a version of the +# library with exception handling. +# IT IS NOT RECOMMENDED THAT YOU CHANGE PTHREADS_EXCEPTION_SCHEME +# TO ANYTHING OTHER THAN "C" because most POSIX thread implementations +# do not support stack unwinding. +# +# PTHREADS_EXCEPTION_SCHEME +# C = no exceptions (default) +# (NOTE: This is the default scheme on most POSIX thread +# implementations and what you should probably be using) +# CE = C++ Exception Handling +# SE = Structure Exception Handling (MSVC only) +# + +# +# Define a default exception scheme to link against +# and validate user choice. +# +# +if(NOT DEFINED PTHREADS_EXCEPTION_SCHEME) + # Assign default if needed + set(PTHREADS_EXCEPTION_SCHEME "C") +else(NOT DEFINED PTHREADS_EXCEPTION_SCHEME) + # Validate + if(NOT PTHREADS_EXCEPTION_SCHEME STREQUAL "C" AND + NOT PTHREADS_EXCEPTION_SCHEME STREQUAL "CE" AND + NOT PTHREADS_EXCEPTION_SCHEME STREQUAL "SE") + + message(FATAL_ERROR "See documentation for FindPthreads.cmake, only C, CE, and SE modes are allowed") + + endif(NOT PTHREADS_EXCEPTION_SCHEME STREQUAL "C" AND + NOT PTHREADS_EXCEPTION_SCHEME STREQUAL "CE" AND + NOT PTHREADS_EXCEPTION_SCHEME STREQUAL "SE") + + if(NOT MSVC AND PTHREADS_EXCEPTION_SCHEME STREQUAL "SE") + message(FATAL_ERROR "Structured Exception Handling is only allowed for MSVC") + endif(NOT MSVC AND PTHREADS_EXCEPTION_SCHEME STREQUAL "SE") + +endif(NOT DEFINED PTHREADS_EXCEPTION_SCHEME) + +if(PTHREADS_ROOT) + set(PTHREADS_ROOT PATHS ${PTHREADS_ROOT} NO_DEFAULT_PATH) +else() + set(PTHREADS_ROOT $ENV{PTHREADS_ROOT}) +endif(PTHREADS_ROOT) + +# +# Find the header file +# +find_path(PTHREADS_INCLUDE_DIR + NAMES pthread.h + HINTS + $ENV{PTHREAD_INCLUDE_PATH} + ${PTHREADS_ROOT}/include +) + +if(PTHREADS_INCLUDE_DIR) + message(STATUS "Found pthread.h: ${PTHREADS_INCLUDE_DIR}") +# else() +# message(FATAL_ERROR "Could not find pthread.h. See README.Win32 for more information.") +endif(PTHREADS_INCLUDE_DIR) + +# +# Find the library +# +set(names) +if(MSVC) + set(names + pthreadV${PTHREADS_EXCEPTION_SCHEME}2 + libpthread + ) +elseif(MINGW) + set(names + pthreadG${PTHREADS_EXCEPTION_SCHEME}2 + pthread + ) +endif(MSVC) + +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(SUBDIR "/x86") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(SUBDIR "/x64") +endif() + +find_library(PTHREADS_LIBRARY NAMES ${names} + DOC "The Portable Threads Library" + HINTS + ${CMAKE_SOURCE_DIR}/lib + $ENV{PTHREAD_LIBRARY_PATH} + ${PTHREADS_ROOT} + C:/MinGW/lib/ + PATH_SUFFIXES lib/${SUBDIR} +) + +if(PTHREADS_LIBRARY) +message(STATUS "Found PTHREADS library: ${PTHREADS_LIBRARY} (PTHREADS Exception Scheme: ${PTHREADS_EXCEPTION_SCHEME})") +# else() +# message(FATAL_ERROR "Could not find PTHREADS LIBRARY. See README.Win32 for more information.") +endif(PTHREADS_LIBRARY) + +if(PTHREADS_INCLUDE_DIR AND PTHREADS_LIBRARY) + set(PTHREADS_DEFINITIONS -DHAVE_PTHREAD_H) + set(PTHREADS_INCLUDE_DIRS ${PTHREADS_INCLUDE_DIR}) + set(PTHREADS_LIBRARIES ${PTHREADS_LIBRARY}) + set(PTHREADS_FOUND TRUE) +endif(PTHREADS_INCLUDE_DIR AND PTHREADS_LIBRARY) + +mark_as_advanced(PTHREADS_INCLUDE_DIR PTHREADS_LIBRARY) diff --git a/cmake/Modules/FindSNF.cmake b/cmake/Modules/FindSNF.cmake new file mode 100644 index 000000000000..76dcced417fe --- /dev/null +++ b/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/cmake/Modules/FindTC.cmake b/cmake/Modules/FindTC.cmake new file mode 100644 index 000000000000..bb24c6671aa3 --- /dev/null +++ b/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/config/have_siocglifconf.c b/cmake/have_siocglifconf.c similarity index 100% rename from config/have_siocglifconf.c rename to cmake/have_siocglifconf.c diff --git a/cmake/preconfigure.cmake b/cmake/preconfigure.cmake deleted file mode 100644 index c8c92a48edd7..000000000000 --- a/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/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 000000000000..2037e365393a --- /dev/null +++ b/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/cmakeconfig.h.in b/cmakeconfig.h.in index 94edb5f44c5a..6760cec76834 100644 --- a/cmakeconfig.h.in +++ b/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/config.h.in b/config.h.in index e85b2a3f5617..b1a20a44131c 100644 --- a/config.h.in +++ b/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/configure b/configure index 4c64875e3e69..ef4bc9f2cc06 100755 --- a/configure +++ b/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,17 +623,26 @@ 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 @@ -645,6 +654,7 @@ V_RPATH_OPT V_SONAME_OPT V_SHLIB_OPT V_SHLIB_CMD +V_SHLIB_CCOPT V_PCAP V_LEX V_INCLS @@ -661,8 +671,8 @@ YACC LEXLIB LEX_OUTPUT_ROOT LEX -HAVE_LINUX_TPACKET_AUXDATA -VALGRINDTEST +PCAP_SUPPORT_PACKET_RING +VALGRINDTEST_SRC LIBOBJS EGREP GREP @@ -734,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 @@ -745,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 @@ -803,7 +816,7 @@ sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' @@ -1303,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]... @@ -1351,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] @@ -1368,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: @@ -1377,20 +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 + --disable-universal don't build universal on macOS --enable-shared build shared libraries [default=yes, if support available] - --enable-usb enable nusb support [default=yes, if support + --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-packet-ring enable Linux packet ring support [default=yes] + --enable-rdma enable RDMA capture support [default=yes, if support + available] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1500,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. @@ -1552,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. @@ -1749,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 @@ -1961,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 $@ @@ -2314,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 @@ -2527,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' @@ -3316,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 + + @@ -3605,7 +3865,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; @@ -3643,13 +3903,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" @@ -3665,7 +3925,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. @@ -3680,7 +3940,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; @@ -3706,7 +3966,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," @@ -3714,7 +3974,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 " @@ -3737,7 +3997,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 " @@ -3809,140 +4069,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' @@ -4341,397 +4738,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 << 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 : - 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 << 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=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 - -{ $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" @@ -4744,25 +4751,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 @@ -4817,50 +4811,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 @@ -4931,7 +4881,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" @@ -4991,78 +4941,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 @@ -5076,93 +5010,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. */ @@ -5172,30 +5067,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 @@ -5257,14 +5158,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. # @@ -5281,20 +5436,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 " @@ -5308,63 +5578,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 : @@ -5376,16 +5610,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. @@ -5412,7 +5783,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; @@ -5433,80 +5804,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; } @@ -5640,73 +6140,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) @@ -5738,6 +6190,8 @@ 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 @@ -5746,10 +6200,18 @@ fi 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. @@ -5959,73 +6421,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) @@ -6045,46 +6484,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 : @@ -6126,10 +6535,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 @@ -6171,33 +6580,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 () { @@ -6214,119 +6624,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. @@ -6389,12 +6771,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 @@ -6408,25 +6786,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 @@ -6468,9 +6849,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 @@ -6562,12 +6990,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; } @@ -6615,7 +7048,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 @@ -6623,8 +7059,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 @@ -6980,6 +7414,182 @@ $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; } + # # Look for {f}lex. # @@ -7238,13 +7848,17 @@ if test $tcpdump_cv_capable_yacc = insufficient ; then 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). +# 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*) @@ -7389,6 +8003,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 ;; @@ -7398,6 +8013,7 @@ hpux10.0*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -7407,6 +8023,7 @@ hpux10.1*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -7436,7 +8053,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 @@ -7458,7 +8077,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 @@ -7504,11 +8126,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 @@ -8060,6 +8701,310 @@ else $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; } + CFLAGS="$save_CFLAGS" + V_CCOPT="$V_CCOPT -Wdocumentation" + +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; } + CFLAGS="$save_CFLAGS" + V_CCOPT="$V_CCOPT -Wcomma" + +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; } + CFLAGS="$save_CFLAGS" + V_CCOPT="$V_CCOPT -Wmissing-noreturn" + +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; } + CFLAGS="$save_CFLAGS" + V_CCOPT="$V_CCOPT -Wmissing-variable-declarations" + +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; } + CFLAGS="$save_CFLAGS" + V_CCOPT="$V_CCOPT -Wunused-parameter" + +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; } + CFLAGS="$save_CFLAGS" + V_CCOPT="$V_CCOPT -Wformat-nonliteral" + +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 -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; } + CFLAGS="$save_CFLAGS" + V_CCOPT="$V_CCOPT -Wunreachable-code" + +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 @@ -8135,8 +9080,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" @@ -8148,7 +9096,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 @@ -8158,7 +9106,7 @@ $as_echo "no" >&6; } # We can't run mkdep, so have "make depend" do # nothing. # - MKDEP=: + MKDEP='${srcdir}/nomkdep' fi @@ -8184,108 +9132,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; } @@ -8382,8 +9290,12 @@ $as_echo "#define LBL_ALIGN 1" >>confdefs.h fi -rm -f net -ln -s ${srcdir}/bpf/net net + + + + + + @@ -8493,45 +9405,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*) @@ -8619,6 +9509,61 @@ 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; @@ -8639,112 +9584,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 ;; @@ -8774,20 +9709,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 # @@ -8904,38 +9839,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 @@ -9039,7 +10053,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 @@ -9547,7 +10561,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 @@ -9613,7 +10627,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\\" @@ -9758,6 +10772,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 @@ -10315,7 +11332,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/configure.ac b/configure.ac index da2f940da963..2a9c8e95e19e 100644 --- a/configure.ac +++ b/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) @@ -486,17 +744,25 @@ linux) # AC_ARG_WITH(libnl, AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]), - with_libnl=$withval,,) + with_libnl=$withval,with_libnl=if_available) 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,6 +1403,92 @@ 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}) + # # Look for {f}lex. # @@ -1184,13 +1533,17 @@ if test $tcpdump_cv_capable_yacc = insufficient ; then 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). +# 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*) @@ -1239,7 +1592,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 @@ -1327,6 +1680,7 @@ hpux9*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -1336,6 +1690,7 @@ hpux10.0*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -1345,6 +1700,7 @@ hpux10.1*) # # Use System V conventions for man pages. # + MAN_ADMIN_COMMANDS=1m MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; @@ -1378,7 +1734,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 @@ -1400,7 +1758,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 @@ -1424,11 +1785,30 @@ 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 @@ -1444,23 +1824,51 @@ 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) @@ -1472,9 +1880,15 @@ 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=yes, if support available@:>@])], +[AC_HELP_STRING([--enable-usb],[enable USB capture support @<:@default=yes, if support available@:>@])], [], [enable_usb=yes]) @@ -1518,25 +1932,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*) @@ -1582,9 +1985,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, @@ -1600,6 +2003,38 @@ fi AC_SUBST(PCAP_SUPPORT_NETFILTER) AC_SUBST(NETFILTER_SRC) +AC_ARG_ENABLE([netmap], +[AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])], + [], + [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@:>@])], [], @@ -1616,67 +2051,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 @@ -1702,20 +2137,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 # @@ -1774,32 +2209,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 @@ -1808,7 +2265,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 @@ -1817,5 +2274,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/diag-control.h b/diag-control.h new file mode 100644 index 000000000000..127703618633 --- /dev/null +++ b/diag-control.h @@ -0,0 +1,215 @@ +/* -*- 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. + */ + #if defined(_MSC_VER) + /* + * This is Microsoft Visual Studio; we can use + * __pragma(warning(disable:XXXX)) and __pragma(warning(push/pop)). + * + * Suppress unreachable code warnings. + */ + #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. + */ + #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/dlpisubs.c b/dlpisubs.c index fb94a6057675..5f6e41af80b5 100644 --- a/dlpisubs.c +++ b/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/etherent.c b/etherent.c index 5cfd1b4c3bbb..5f499613e088 100644 --- a/etherent.c +++ b/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/extract.h b/extract.h index face5b7e94cd..aa3ff99196e3 100644 --- a/extract.h +++ b/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/fad-getad.c b/fad-getad.c index b67b5cdcd46a..5236fbb94cda 100644 --- a/fad-getad.c +++ b/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/fad-gifc.c b/fad-gifc.c index 1b24af292985..6b1612747582 100644 --- a/fad-gifc.c +++ b/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/fad-glifc.c b/fad-glifc.c index 511481cf9636..f22f56d73eb7 100644 --- a/fad-glifc.c +++ b/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/fad-helpers.c b/fad-helpers.c deleted file mode 100644 index 4860bc55ca80..000000000000 --- a/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/fmtutils.c b/fmtutils.c new file mode 100644 index 000000000000..f1a8907327de --- /dev/null +++ b/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/fmtutils.h b/fmtutils.h new file mode 100644 index 000000000000..62c78fdba1b2 --- /dev/null +++ b/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/ftmacros.h b/ftmacros.h new file mode 100644 index 000000000000..de8da98e38b6 --- /dev/null +++ b/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/gen_version_c.sh b/gen_version_c.sh deleted file mode 100755 index d5a5e75bfec8..000000000000 --- a/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/gen_version_header.sh b/gen_version_header.sh deleted file mode 100755 index 6b4b82da1af7..000000000000 --- a/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