aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-03-08 15:18:24 -0800
committerGuy Harris <gharris@sonic.net>2022-03-08 15:18:24 -0800
commitf6fb59b11d20222d4648cdceeaadf6ce971a7a9a (patch)
tree82d4be40231a93047587a9cd52777b77528e188d
parentcc9e70b80e0a33130fcb24fbab13a40666976d7f (diff)
parente75cc82c46e0f1208fbac03530da6a30976c7fd6 (diff)
Merge branch 'master' into pcap-options
-rw-r--r--.appveyor.yml26
-rwxr-xr-x.ci-coverity-scan-build.sh91
-rw-r--r--.cirrus.yml83
-rw-r--r--.gitignore2
-rw-r--r--.travis-coverity-scan-build.sh116
-rw-r--r--.travis.yml135
-rw-r--r--CHANGES312
-rw-r--r--CMakeLists.txt202
-rw-r--r--CONTRIBUTING.md6
-rw-r--r--CREDITS74
-rw-r--r--INSTALL.md228
-rw-r--r--Makefile-devel-adds4
-rw-r--r--Makefile.in61
-rw-r--r--README.md63
-rw-r--r--TODO2
-rw-r--r--VERSION2
-rw-r--r--Win32/Prj/wpcap.sln28
-rw-r--r--Win32/Prj/wpcap.vcxproj233
-rw-r--r--Win32/Prj/wpcap.vcxproj.filters107
-rw-r--r--aclocal.m4226
-rw-r--r--bpf_filter.c4
-rwxr-xr-xbuild.sh118
-rw-r--r--build_common.sh280
-rwxr-xr-xbuild_matrix.sh63
-rw-r--r--charconv.c1
-rw-r--r--charconv.h6
-rw-r--r--cmake/Modules/FindAirPcap.cmake24
-rw-r--r--cmake/Modules/FindPacket.cmake46
-rw-r--r--cmake/Modules/Finddpdk.cmake4
-rw-r--r--cmakeconfig.h.in12
-rwxr-xr-xconfig.guess1494
-rw-r--r--config.h.in12
-rwxr-xr-xconfig.sub1686
-rwxr-xr-xconfigure2407
-rw-r--r--configure.ac535
-rw-r--r--diag-control.h40
-rw-r--r--dlpisubs.c7
-rw-r--r--doc/DLT_ALLOCATE_HOWTO.md29
-rw-r--r--doc/README.Win32.md2
-rw-r--r--doc/README.aix22
-rw-r--r--doc/README.capture-module354
-rw-r--r--doc/README.dag2
-rw-r--r--doc/README.linux (renamed from doc/README.linux.md)0
-rw-r--r--doc/README.septel2
-rw-r--r--doc/README.sita2
-rw-r--r--doc/README.solaris.md44
-rw-r--r--doc/README.tru6449
-rw-r--r--ftmacros.h20
-rw-r--r--gencode.c186
-rw-r--r--gencode.h6
-rw-r--r--grammar.y.in130
-rw-r--r--ieee80211.h4
-rw-r--r--nametoaddr.c7
-rw-r--r--optimize.c10
-rw-r--r--pcap-airpcap.c14
-rw-r--r--pcap-bpf.c5
-rw-r--r--pcap-bt-linux.c12
-rw-r--r--pcap-bt-monitor-linux.c4
-rw-r--r--pcap-common.c164
-rw-r--r--pcap-config.12
-rw-r--r--pcap-config.in17
-rw-r--r--pcap-dag.c13
-rw-r--r--pcap-dll.rc6
-rw-r--r--pcap-dos.c18
-rw-r--r--pcap-dpdk.c20
-rw-r--r--pcap-filter.manmisc.in55
-rw-r--r--pcap-haiku.cpp20
-rw-r--r--pcap-int.h44
-rw-r--r--pcap-linux.c188
-rw-r--r--pcap-netfilter-linux.c10
-rw-r--r--pcap-new.c7
-rw-r--r--pcap-nit.c3
-rw-r--r--pcap-npf.c523
-rw-r--r--pcap-pf.c3
-rw-r--r--pcap-rdmasniff.c22
-rw-r--r--pcap-rpcap.c162
-rw-r--r--pcap-sita.c2
-rw-r--r--pcap-snf.c18
-rw-r--r--pcap-snit.c3
-rw-r--r--pcap-tc.c2
-rw-r--r--pcap-usb-linux.c780
-rw-r--r--pcap.3pcap.in26
-rw-r--r--pcap.c91
-rw-r--r--pcap/bpf.h38
-rw-r--r--pcap/can_socketcan.h7
-rw-r--r--pcap/compiler-tests.h50
-rw-r--r--pcap/dlt.h125
-rw-r--r--pcap/funcattrs.h106
-rw-r--r--pcap/pcap-inttypes.h85
-rw-r--r--pcap/pcap.h253
-rw-r--r--pcap_compile.3pcap.in2
-rw-r--r--pcap_datalink_val_to_name.3pcap9
-rw-r--r--pcap_dump_ftell.3pcap6
-rw-r--r--pcap_dump_open.3pcap.in2
-rw-r--r--pcap_findalldevs.3pcap4
-rw-r--r--pcap_get_required_select_timeout.3pcap5
-rw-r--r--pcap_get_tstamp_precision.3pcap.in2
-rw-r--r--pcap_init.3pcap4
-rw-r--r--pcap_inject.3pcap14
-rw-r--r--pcap_list_tstamp_types.3pcap.in4
-rw-r--r--pcap_loop.3pcap20
-rw-r--r--pcap_next_ex.3pcap11
-rw-r--r--pcap_open_dead.3pcap.in6
-rw-r--r--pcap_open_offline.3pcap.in4
-rw-r--r--pcap_set_datalink.3pcap8
-rw-r--r--pcap_set_immediate_mode.3pcap.in2
-rw-r--r--pcap_set_tstamp_precision.3pcap.in2
-rw-r--r--pcap_set_tstamp_type.3pcap.in2
-rw-r--r--pcap_setdirection.3pcap8
-rw-r--r--pcap_setfilter.3pcap8
-rw-r--r--pcap_setnonblock.3pcap7
-rw-r--r--pcap_stats.3pcap9
-rw-r--r--pflog.h157
-rw-r--r--portability.h24
-rw-r--r--rpcapd/CMakeLists.txt21
-rw-r--r--rpcapd/daemon.c75
-rw-r--r--rpcapd/rpcapd.c3
-rw-r--r--savefile.c41
-rw-r--r--scanner.l11
-rw-r--r--sf-pcap.c63
-rw-r--r--sf-pcapng.c27
-rw-r--r--sockutils.c25
-rw-r--r--sockutils.h2
-rw-r--r--testprogs/CMakeLists.txt5
-rw-r--r--testprogs/findalldevstest-perf.c3
-rw-r--r--testprogs/findalldevstest.c4
-rw-r--r--testprogs/selpolltest.c2
127 files changed, 7861 insertions, 5248 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 15e1824e..fe3f547e 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -2,6 +2,10 @@ version: '{build}'
clone_depth: 5
+branches:
+ except:
+ - coverity_scan
+
matrix:
fast_finish: true
@@ -11,8 +15,8 @@ install:
- win_bison --version
- appveyor DownloadFile https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip
- 7z x .\WpdPack_4_1_2.zip -oc:\projects\libpcap\Win32
- - appveyor DownloadFile https://nmap.org/npcap/dist/npcap-sdk-1.05.zip
- - 7z x .\npcap-sdk-1.05.zip -oc:\projects\libpcap\Win32\npcap-sdk-1.05
+ - appveyor DownloadFile https://npcap.com/dist/npcap-sdk-1.12.zip
+ - 7z x .\npcap-sdk-1.12.zip -oc:\projects\libpcap\Win32\npcap-sdk-1.12
- appveyor DownloadFile https://support.riverbed.com/bin/support/download?sid=l3vk3eu649usgu3rj60uncjqqu -FileName AirPcap_Devpack.zip
- 7z x .\AirPcap_Devpack.zip -oc:\projects\libpcap\Win32
@@ -25,7 +29,7 @@ environment:
MINGW_ROOT: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "MinGW Makefiles"
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
MINGW_ROOT: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
@@ -38,10 +42,10 @@ environment:
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "Visual Studio 14 2015"
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: "Visual Studio 14 2015 Win64"
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017"
@@ -52,15 +56,15 @@ environment:
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017"
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017 Win64"
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATOR: "Visual Studio 15 2017 Win64"
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=NO
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
@@ -75,17 +79,17 @@ environment:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: Win32
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: x64
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=YES
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: "Visual Studio 16 2019"
PLATFORM: x64
- SDK: npcap-sdk-1.05
+ SDK: npcap-sdk-1.12
AIRPCAP: -DDISABLE_AIRPCAP=NO
build_script:
diff --git a/.ci-coverity-scan-build.sh b/.ci-coverity-scan-build.sh
new file mode 100755
index 00000000..686806a3
--- /dev/null
+++ b/.ci-coverity-scan-build.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+set -e
+
+# Environment check
+printf "\033[33;1mNote: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com\033[0m\n"
+[ -z "$COVERITY_SCAN_PROJECT_NAME" ] && echo "ERROR: COVERITY_SCAN_PROJECT_NAME must be set" && exit 1
+#[ -z "$COVERITY_SCAN_NOTIFICATION_EMAIL" ] && echo "ERROR: COVERITY_SCAN_NOTIFICATION_EMAIL must be set" && exit 1
+[ -z "$COVERITY_SCAN_BUILD_COMMAND" ] && echo "ERROR: COVERITY_SCAN_BUILD_COMMAND must be set" && exit 1
+[ -z "$COVERITY_SCAN_TOKEN" ] && echo "ERROR: COVERITY_SCAN_TOKEN must be set" && exit 1
+
+PLATFORM=$(uname)
+TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz
+TOOL_URL=https://scan.coverity.com/download/cxx/${PLATFORM}
+TOOL_BASE=/tmp/coverity-scan-analysis
+UPLOAD_URL="https://scan.coverity.com/builds"
+SCAN_URL="https://scan.coverity.com"
+
+# Verify upload is permitted
+AUTH_RES=$(curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted)
+if [ "$AUTH_RES" = "Access denied" ]; then
+ printf "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m\n"
+ exit 1
+else
+ AUTH=$(echo "$AUTH_RES" | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']")
+ if [ "$AUTH" = "true" ]; then
+ printf "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m\n"
+ else
+ WHEN=$(echo "$AUTH_RES" | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']")
+ printf "\033[33;1mCoverity Scan analysis NOT authorized until %s.\033[0m\n" "$WHEN"
+ exit 0
+ fi
+fi
+
+if [ ! -d $TOOL_BASE ]; then
+ # Download Coverity Scan Analysis Tool
+ if [ ! -e "$TOOL_ARCHIVE" ]; then
+ printf "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m\n"
+ wget -nv -O "$TOOL_ARCHIVE" "$TOOL_URL" --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
+ fi
+
+ # Extract Coverity Scan Analysis Tool
+ printf "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m\n"
+ mkdir -p $TOOL_BASE
+ tar xzf "$TOOL_ARCHIVE" -C "$TOOL_BASE"
+fi
+
+TOOL_DIR=$(find $TOOL_BASE -type d -name 'cov-analysis*')
+export PATH=$TOOL_DIR/bin:$PATH
+
+# Build
+printf "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m\n"
+COV_BUILD_OPTIONS=""
+#COV_BUILD_OPTIONS="--return-emit-failures 8 --parse-error-threshold 85"
+RESULTS_DIR="cov-int"
+eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}"
+# Do not quote COV_BUILD_OPTIONS so it collapses when it is empty and expands
+# when it is not.
+# shellcheck disable=SC2086
+COVERITY_UNSUPPORTED=1 cov-build --dir "$RESULTS_DIR" $COV_BUILD_OPTIONS "$COVERITY_SCAN_BUILD_COMMAND"
+cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt 2>&1
+
+# Upload results
+printf "\033[33;1mTarring Coverity Scan Analysis results...\033[0m\n"
+RESULTS_ARCHIVE=analysis-results.tgz
+tar czf $RESULTS_ARCHIVE $RESULTS_DIR
+SHA=$(git rev-parse --short HEAD)
+VERSION_SHA=$(cat VERSION)#$SHA
+
+# Verify Coverity Scan script test mode
+if [ "${coverity_scan_script_test_mode:-false}" = true ]; then
+ printf "\033[33;1mCoverity Scan configured in script test mode. Exit.\033[0m\n"
+ exit 0
+fi
+
+printf "\033[33;1mUploading Coverity Scan Analysis results...\033[0m\n"
+response=$(curl \
+ --silent --write-out "\n%{http_code}\n" \
+ --form project="$COVERITY_SCAN_PROJECT_NAME" \
+ --form token="$COVERITY_SCAN_TOKEN" \
+ --form email=blackhole@blackhole.io \
+ --form file=@$RESULTS_ARCHIVE \
+ --form version="$SHA" \
+ --form description="$VERSION_SHA" \
+ $UPLOAD_URL)
+status_code=$(echo "$response" | sed -n '$p')
+if [ "$status_code" != "200" ] && [ "$status_code" != "201" ]; then
+ TEXT=$(echo "$response" | sed '$d')
+ printf "\033[33;1mCoverity Scan upload failed with HTTP status code '%s': %s.\033[0m\n" "$status_code" "$TEXT"
+ exit 1
+fi
diff --git a/.cirrus.yml b/.cirrus.yml
index 0f71d89f..5cbb9bea 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -1,25 +1,74 @@
# The internal git client reads CIRRUS_CLONE_DEPTH.
env:
CIRRUS_CLONE_DEPTH: 3
- MAXJOBS: 2
- IGNORE_OSVERSION: yes
-task:
+freebsd_task:
+ name: freebsd-amd64
+ only_if: $CIRRUS_BRANCH != 'coverity_scan'
freebsd_instance:
- image_family: $IMAGE_FAMILY
- env:
matrix:
- - IMAGE_FAMILY: freebsd-11-4
- - IMAGE_FAMILY: freebsd-12-2
- - IMAGE_FAMILY: freebsd-13-0-snap
+ - image_family: freebsd-12-3
+ cpu: 2
+ memory: 2G
+ - image_family: freebsd-13-0
+ cpu: 4
+ memory: 4G
+ env:
+ IGNORE_OSVERSION: yes
+ MAKEFLAGS: -j 4
+ MATRIX_CC: clang gcc11
+ script:
+ - pkg install -qy autoconf gcc11
+ - pkg install -qy cmake git-tiny # for build_matrix.sh and build.sh
+ - ./build_matrix.sh
+
+linux_task:
+ name: linux-amd64
+ only_if: $CIRRUS_BRANCH != 'coverity_scan'
+ container:
+ image: ubuntu:20.04
+ cpu: 2
+ memory: 1G
+ env:
+ DEBIAN_FRONTEND: noninteractive
+ MAKEFLAGS: -j 3
script:
- - freebsd-version
- - pkg install -qy autoconf
- - touch .devel
- - ./configure --enable-remote --prefix=/tmp
- - make -s all
- - make -s testprogs
- - make install
- - make releasetar
- - testprogs/findalldevstest
+ - apt-get -qy update
+ - apt-get -qy install libdbus-1-dev libbluetooth-dev libnl-genl-3-dev libibverbs-dev
+ - apt-get -qy install flex bison autoconf make clang gcc valgrind
+ - apt-get -qy install cmake git bc # for build_matrix.sh and build.sh
+ - apt list --installed 'lib*-dev'
+ - ./build_matrix.sh
+macos_task:
+ name: macos-amd64
+ only_if: $CIRRUS_BRANCH != 'coverity_scan'
+ macos_instance:
+ image: big-sur-xcode
+ env:
+ MAKEFLAGS: '-j 12' # macOS VMs always run on 12 cores
+ script:
+ - brew update >/dev/null
+ - ./build_matrix.sh
+
+coverity_task:
+ name: Coverity Scan
+ only_if: $CIRRUS_BRANCH == 'coverity_scan'
+ container:
+ image: ubuntu:20.04
+ cpu: 2
+ memory: 2G
+ env:
+ DEBIAN_FRONTEND: noninteractive
+ MAKEFLAGS: -j 3
+ COVERITY_SCAN_PROJECT_NAME: $CIRRUS_REPO_FULL_NAME
+ COVERITY_SCAN_TOKEN: ENCRYPTED[58bfbfcf624e5b7b85fb9df95dd0b3f9f93642824e6ae94616e4d345af4848580932a6ece02337fee112194b29ce6593]
+ COVERITY_SCAN_BUILD_COMMAND_PREPEND: ./configure --enable-remote
+ COVERITY_SCAN_BUILD_COMMAND: make
+ script:
+ - apt-get -qy update
+ - apt-get -qy install libdbus-1-dev libbluetooth-dev libnl-genl-3-dev libibverbs-dev
+ - apt-get -qy install flex bison autoconf make gcc
+ - apt-get -qy install git curl wget ruby rubygems ruby-json # for the coverity script
+ - apt list --installed 'lib*-dev'
+ - ./.ci-coverity-scan-build.sh
diff --git a/.gitignore b/.gitignore
index a590eecc..df7b4405 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.DS_Store
Makefile
*~
*.o
@@ -22,6 +23,7 @@ valgrindtest
reactivatetest
grammar.c
grammar.h
+grammar.y
libpcap.a
libpcap.*.dylib
libpcap.pc
diff --git a/.travis-coverity-scan-build.sh b/.travis-coverity-scan-build.sh
deleted file mode 100644
index 892dac1e..00000000
--- a/.travis-coverity-scan-build.sh
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/bin/sh
-
-set -e
-
-# Environment check
-echo -e "\033[33;1mNote: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com\033[0m"
-[ -z "$COVERITY_SCAN_PROJECT_NAME" ] && echo "ERROR: COVERITY_SCAN_PROJECT_NAME must be set" && exit 1
-#[ -z "$COVERITY_SCAN_NOTIFICATION_EMAIL" ] && echo "ERROR: COVERITY_SCAN_NOTIFICATION_EMAIL must be set" && exit 1
-[ -z "$COVERITY_SCAN_BRANCH_PATTERN" ] && echo "ERROR: COVERITY_SCAN_BRANCH_PATTERN must be set" && exit 1
-[ -z "$COVERITY_SCAN_BUILD_COMMAND" ] && echo "ERROR: COVERITY_SCAN_BUILD_COMMAND must be set" && exit 1
-[ -z "$COVERITY_SCAN_TOKEN" ] && echo "ERROR: COVERITY_SCAN_TOKEN must be set" && exit 1
-
-PLATFORM=`uname`
-TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz
-TOOL_URL=https://scan.coverity.com/download/cxx/${PLATFORM}
-TOOL_BASE=/tmp/coverity-scan-analysis
-UPLOAD_URL="https://scan.coverity.com/builds"
-SCAN_URL="https://scan.coverity.com"
-
-# Verify Coverity Scan run condition
-COVERITY_SCAN_RUN_CONDITION=${coverity_scan_run_condition:-true}
-echo -ne "\033[33;1mTesting '${COVERITY_SCAN_RUN_CONDITION}' condition... "
-if eval [ $COVERITY_SCAN_RUN_CONDITION ]; then
- echo -e "True.\033[0m"
-else
- echo -e "False. Exit.\033[0m"
- exit 0
-fi
-
-# Do not run on pull requests
-if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then
- echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m"
- exit 0
-fi
-
-# Verify this branch should run
-IS_COVERITY_SCAN_BRANCH=`ruby -e "puts '${TRAVIS_BRANCH}' =~ /\\A$COVERITY_SCAN_BRANCH_PATTERN\\z/ ? 1 : 0"`
-if [ "$IS_COVERITY_SCAN_BRANCH" = "1" ]; then
- echo -e "\033[33;1mCoverity Scan configured to run on branch ${TRAVIS_BRANCH}\033[0m"
-else
- echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m"
- exit 1
-fi
-
-# Verify upload is permitted
-AUTH_RES=`curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted`
-if [ "$AUTH_RES" = "Access denied" ]; then
- echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m"
- exit 1
-else
- AUTH=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']"`
- if [ "$AUTH" = "true" ]; then
- echo -e "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m"
- else
- WHEN=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']"`
- echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m"
- exit 0
- fi
-fi
-
-if [ ! -d $TOOL_BASE ]; then
- # Download Coverity Scan Analysis Tool
- if [ ! -e $TOOL_ARCHIVE ]; then
- echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m"
- wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
- fi
-
- # Extract Coverity Scan Analysis Tool
- echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m"
- mkdir -p $TOOL_BASE
- pushd $TOOL_BASE
- tar xzf $TOOL_ARCHIVE
- popd
-fi
-
-TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'`
-export PATH=$TOOL_DIR/bin:$PATH
-
-# Build
-echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m"
-COV_BUILD_OPTIONS=""
-#COV_BUILD_OPTIONS="--return-emit-failures 8 --parse-error-threshold 85"
-RESULTS_DIR="cov-int"
-eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}"
-COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $COV_BUILD_OPTIONS $COVERITY_SCAN_BUILD_COMMAND
-cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt 2>&1
-
-# Upload results
-echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m"
-RESULTS_ARCHIVE=analysis-results.tgz
-tar czf $RESULTS_ARCHIVE $RESULTS_DIR
-SHA=`git rev-parse --short HEAD`
-VERSION_SHA=$(cat VERSION)#$SHA
-
-# Verify Coverity Scan script test mode
-if [ "$coverity_scan_script_test_mode" = true ]; then
- echo -e "\033[33;1mCoverity Scan configured in script test mode. Exit.\033[0m"
- exit 0
-fi
-
-echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m"
-response=$(curl \
- --silent --write-out "\n%{http_code}\n" \
- --form project=$COVERITY_SCAN_PROJECT_NAME \
- --form token=$COVERITY_SCAN_TOKEN \
- --form email=blackhole@blackhole.io \
- --form file=@$RESULTS_ARCHIVE \
- --form version=$SHA \
- --form description="$VERSION_SHA" \
- $UPLOAD_URL)
-status_code=$(echo "$response" | sed -n '$p')
-if [ "$status_code" != "201" ]; then
- TEXT=$(echo "$response" | sed '$d')
- echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m"
- exit 1
-fi
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index b840a66d..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,135 +0,0 @@
-language: c
-
-#
-# Try building on these 4 architectures; all are 64-bit, and all but
-# "s390x", a/k/a z/Architecture, are little-endian.
-#
-arch:
- - amd64
- - ppc64le
- - s390x
- - arm64
-
-os:
- - linux
- - osx
-
-dist: bionic
-
-compiler:
- - gcc
- - clang
-
-#
-# Linux runs on all of the architectures listed above; macOS currently
-# runs only on 64-bit x86, although the Spaceshipologists are all in a
-# tizzy about the possibility of Arm-based Macs. Suppress the macOS
-# builds that don't work.
-#
-# In addition, with newer versions of macOS, Apple ships a "gcc" that's
-# just another front end to Clang, presumably for backwards
-# compatibility with build scripts etc. that expect the compiler to be
-# "gcc", so don't bother doing "gcc" builds on macOS.
-#
-jobs:
- exclude:
- - arch: ppc64le
- os: osx
- - arch: s390x
- os: osx
- - arch: arm64
- os: osx
- - compiler: gcc
- os: osx
-
-cache: ccache
-
-env:
- global:
- # encrypted COVERITY_SCAN_TOKEN from
- # https://scan.coverity.com/projects/<project_id>/submit_build?tab=travis_ci
- - secure: "SwNcek+I4lMVcnb5EGGmNm6ljWN6C/mnXzBr82a5rEQNKxAoJfdvvPpKIp0iEfg5j0PtYlcRHoIDyVZ/6QM/WEw0wrio9Z0cio9hkOS6kV8g2QouXfnoNtKJ5nNso7UD2GPJ9+M0GIR1GZ0Edvxr81sHlNAkpVKydYGBwCIMGyg="
- # Coverity run condition (avoid matrix multiple runs), need customized
- # build script. Need an update if new matrix cases.
- - coverity_scan_run_condition='"$TRAVIS_CPU_ARCH" = amd64 -a "$TRAVIS_OS_NAME" = linux -a "$CC" = gcc -a "$REMOTE" = enable -a "$CMAKE" = no'
- # Coverity script test mode (if true no uploading, avoid reaching the quota)
- # usual processing: false.
- - coverity_scan_script_test_mode=false
- - MAKEFLAGS='-j 2' # Travis CI VMs come with 2 cores
- matrix:
- - REMOTE=disable CMAKE=no
- - ENABLE_REMOTE="" CMAKE=yes
- - REMOTE=enable CMAKE=no
- - ENABLE_REMOTE="-DENABLE_REMOTE=ON" CMAKE=yes
-
-matrix:
- fast_finish: true
-
-addons:
- coverity_scan:
- # customized build script URL
- # TRAVIS_REPO_SLUG: owner_name/repo_name of repository currently being built
- # TRAVIS_BRANCH: name of the branch currently being built
- build_script_url: https://raw.githubusercontent.com/$TRAVIS_REPO_SLUG/$TRAVIS_BRANCH/.travis-coverity-scan-build.sh
- # project metadata
- project:
- name: $TRAVIS_REPO_SLUG
- # Where email notification of build analysis results will be sent
- #notification_email: tcpdump-workers@lists.tcpdump.org
- # Commands to prepare for build_command
- build_command_prepend: ./configure --enable-remote
- # This command will be added as an argument to "cov-build" to compile
- # the project for analysis
- build_command: make
- # Pattern to match selecting branches that will run analysis
- branch_pattern: coverity_scan
- apt:
- packages:
- - libdbus-1-dev
- - libbluetooth-dev
- - libnl-genl-3-dev
- - libibverbs-dev
-
-git:
- quiet: true
- depth: 3
-
-before_install:
- - uname -a
- - date
- - if [ "$TRAVIS_OS_NAME" = linux ]; then apt list --installed 'lib*-dev'; fi
-
-install:
-
-before_script:
-
-script:
- - if [ "$COVERITY_SCAN_BRANCH" = 1 ]; then echo "Coverity build - nothing more to do"; exit 0; fi
- - touch .devel configure
- - if [ "$CMAKE" = no ]; then echo '$ ./configure [...]' && echo travis_fold:start:script.configure; fi
- - if [ "$CMAKE" = no ]; then ./configure --prefix=/tmp "--${REMOTE}-remote"; fi
- - if [ "$CMAKE" = no ]; then echo -n travis_fold:end:script.configure; fi
- - if [ "$CMAKE" = yes ]; then mkdir build; fi
- - if [ "$CMAKE" = yes ]; then cd build; fi
- - if [ "$CMAKE" = yes ]; then echo travis_fold:start:script.cmake; fi
- - if [ "$CMAKE" = yes ]; then cmake -DCMAKE_INSTALL_PREFIX=/tmp $ENABLE_REMOTE ..; fi
- - if [ "$CMAKE" = yes ]; then echo -n travis_fold:end:script.cmake; fi
- - make -s
- - make -s testprogs
- - echo '$ make install [...]' && echo travis_fold:start:script.make_install
- - PATH=$PATH make install
- - echo -n travis_fold:end:script.make_install
- - if [ "$CMAKE" = no ]; then testprogs/findalldevstest; fi
- - if [ "$CMAKE" = yes ]; then run/findalldevstest; fi
- - if [ "$CMAKE" = no ]; then make releasetar; fi
- - echo '$ cat Makefile [...]'; echo travis_fold:start:script.cat_makefile
- - if [ "$CMAKE" = no ]; then cat Makefile | sed -n '1,/DO NOT DELETE THIS LINE -- mkdep uses it/p'; fi
- - if [ "$CMAKE" = yes ]; then cat Makefile; fi
- - echo -n travis_fold:end:script.cat_makefile
- - echo '$ cat config.h'; echo travis_fold:start:script.cat_config_h
- - cat config.h
- - echo -n travis_fold:end:script.cat_config_h
- - if [ "$CMAKE" = no ]; then echo '$ cat config.log'; echo travis_fold:start:script.cat_config_log; fi
- - if [ "$CMAKE" = no ]; then cat config.log; fi
- - if [ "$CMAKE" = no ]; then echo -n travis_fold:end:script.cat_config_log; fi
- - if [ "$TRAVIS_OS_NAME" = osx ]; then sleep 10; fi
diff --git a/CHANGES b/CHANGES
index 90fcf494..4f5a8b07 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,314 @@
+Monthday, Month DD, YYYY:
+ Summary for 1.11.0 libpcap release (so far!)
+ Link-layer types:
+ Add LINKTYPE_ETW/DLT_ETW.
+ Add LINKTYPE_NETANALYZER_NG/DLT_NETANALYZER_NG (pull request
+ #1008).
+ Add LINKTYPE_ZBOSS_NCP/DLT_ZBOSS_NCP.
+ Packet filtering:
+ Add support for Block Ack Req and Block Ack frame types (pull
+ request #1039).
+
+Monthday, Month DD, YYYY:
+ Summary for 1.10.2 libpcap release (so far!)
+ Source code:
+ Use __builtin_unreachable() in PCAP_UNREACHABLE.
+ Use AS_HELP_STRING macro instead of AC_HELP_STRING in the
+ configure scripts, to avoid deprecation warnings.
+ Savefiles:
+ Fix pcap_dispatch() to return number of packets processed, rather
+ than 0, even at EOF.
+ If we get an error writing the packet header, don't write the
+ packet data.
+ Put PFLOG UID and PID values in the header into host byte order
+ when reading a LINKTYPE_PFLOG file.
+ Put CAN ID field in CAN pseudo-headers for LINUX_SLL2, as we do
+ for LINUX_SLL.
+ Capture:
+ Never process more than INT_MAX packets in a pcap_dispatch() call,
+ to avoid integer overflow (issue #1087).
+ Packet filtering:
+ Get PFLOG header length from the length value in the header.
+ Support all the direction, reason, and action types supported by
+ all systems that sypport PFLOG.
+ Don't require PFLOG support on the target machine in order to
+ support PFLOG filtering (also fixes issue #1076).
+ Linux:
+ Fix memory leak in capture device open (pull request #1038).
+ Fix detection of CAN/CAN FD packets in direction check (issue
+ #1051).
+ Fix double-free crashes on errors such as running on a kernel with
+ CONFIG_PACKET_MMAP not configured (issue #1054).
+ Use DLT_CAN_SOCKETCAN for CANbus interfaces (issue #1052; includes
+ changes from pull request #1035).
+ Make sure the CANFD_FDF can be relied on to indicate whether a
+ CANbus packet is a CAN frame or a CAN FD frame
+ Improve error message for "out of memory" errors for kernel
+ filters (see issue #1089).
+ NetBSD:
+ Fix handling of LINKTYPE_HDLC/DLT_HDLC.
+ rpcap:
+ Fix unaligned accesses in rpcapd (pull request #1037).
+ Fix code to process port number.
+ Clean up findalldevs code in rpcapd.
+ Clean up bufferizing code.
+ Windows:
+ Add support for NdisMediumIP (pull request #1027).
+ Don't require applications using pcap to be built with VS 2015 or
+ later.
+ Use the correct string for the DLL VersionInfo.
+ Correctly handle ERROR_INVALID_FUNCTION from
+ PacketGetTimestampModes() (indicate that WinPcap or an older
+ version of Npcap is probably installed).
+ Fix use-after-free in some cases when a pcap_t is closed.
+ Make sure an error is returned by pcap_create_interface() if
+ PacketOpenAdapter() fails.
+ Return an error if the driver reports 0 timestamp modes supported.
+ Close the ADAPTER handle for some errors in
+ pcap_create_interface().
+ Get rid of old umaintained VS project files.
+ Fix deprecation warning for pcap_handle().
+ Npcap is now at npcap.com, not npcap.org.
+ Haiku:
+ Implement pcap_lib_version(), as now required.
+ Handle negative or too-large snaplen values.
+ Building and testing:
+ Handle some Autoconf/make errors better.
+ Fix "make releasetar" on AIX, OpenBSD and Solaris.
+ Fix compiling on Solaris 9/SPARC and 11/AMD64.
+ Address assorted compiler warnings.
+ Fix cross-building on Linux for Windows with mingw32 for Win64
+ (pull request #1031).
+ Properly set installation directory on Windows when not compiling
+ with MSVC.
+ Fix configure script checks for compiler flags.
+ Give more details if check for usable (F)Lex fails.
+ Fix compiling with GCC 4.6.4.
+ Don't use add_compile_options() with CMake, as we currently don't
+ require 2.8.12, where it first appeared.
+ Don't provide -L/usr/lib for pkg-config --libs in pkg-config.
+ Fix error message for inadequate Bison/Berkeley YACC.
+ Documentation:
+ Add README.solaris.md.
+ Add SCTP to pcap-filter(7).
+ Note that = and == are the same operator in filters (issue #1044).
+ Update INSTALL.md.
+ Update and clean up CONTRIBUTING.md.
+ Trim documentation of support for now-dead UN*Xe and older
+ versions of other UN*Xes.
+ Move the "how to allocate a LINKTYPE_/DLT_ value" documentation to
+ the web site.
+ Clean up man pages.
+ Move README.capture-module to the web site.
+
+Wednesday, June 9, 2021:
+ Summary for 1.10.1 libpcap release:
+ Packet filtering:
+ Fix "type XXX subtype YYY" giving a parse error
+ Source code:
+ Add PCAP_AVAILABLE_1_11.
+ Building and testing:
+ Rename struct bpf_aux_data to avoid NetBSD compile errors
+ Squelch some compiler warnings
+ Squelch some Bison warnings
+ Fix cross-builds with older kernels lacking BPF_MOD and BPF_XOR
+ Fix Bison detection for minor version 0.
+ Fix parallel build with FreeBSD make.
+ Get DLT_MATCHING_MAX right in gencode.c on NetBSD.
+ Define timeradd() and timersub() if necessary.
+ Fix Cygwin/MSYS target directories.
+ Fix symlinking with DESTDIR.
+ Fix generation of libpcap.pc with CMake when not building a shared
+ library.
+ Check for Arm64 as well as x86-64 when looking for packet.lib on
+ Windows.
+ Documentation:
+ Refine Markdown in README.md.
+ Improve the description of portrange in filters.
+ README.linux.md isn't Markdown, rename it just README.linux.
+ pcapng:
+ Support reading version 1.2, which some writers produce, and which
+ is the same as 1.0 (some new block types were added, but
+ that's not sufficient reason to bump the minor version number,
+ as code that understands those new block types can handle them
+ in a 1.0 file)
+ Linux:
+ Drop support for text-mode USB captures, as we require a 2.6.27
+ or later kernel (credit to Chaoyuan Peng for noting the
+ sscanf vulnerabilities in the text-mode code that got me to
+ realize that we didn't need this code any more)
+ Bluetooth: fix non-blocking mode.
+ Don't assume that all compilers used to build for Linux support
+ the __atomic builtins
+ Windows:
+ Add more information in "interface disappeared" error messages, in
+ the hopes of trying to figure out the cause.
+ Treat ERROR_DEVICE_REMOVED as "device was removed".
+ Indicate in the error message which "device was removed" error
+ occurred.
+ Report the Windows error status if PacketSendPacket() fails.
+ Use %lu for ULONGs in error message formats.
+ Don't treat the inability to find airpcap.dll as an error.
+ Ignore spurious error reports by Microsoft Surface mobile
+ telephony modem driver
+ rpcap:
+ Clean up error checking and error messages for server address
+ lookup.
+
+Tuesday, December 29, 2020
+ Summary for 1.10.0 libpcap release
+ Add support for capturing on DPDK devices
+ Label most APIs by the first release in which they're available
+ Fix some memory leaks, including in pcap_compile()
+ Add pcap_datalink_val_to_description_or_dlt()
+ Handle the pcap private data in a fashion that makes fewer
+ assumptions about memory layouts (might fix GitHub issue #940
+ on ARM)
+ Fix some thread safety issues
+ pcap_findalldevs(): don't sort interfaces by unit number
+ Always return a list of supported time-stamp types, even if only
+ host time stamps are supported
+ Increase the maximum snaplen for LINKTYPE_USBPCAP/DLT_USBPCAP
+ Report the DLT description in error messages
+ Add pcap_init() for first-time initialization and global option
+ setting; it's not required, but may be used
+ Remove (unused) SITA support
+ Capture file reading:
+ Correctly handle pcapng captures with more than one IDB with a
+ snspshot length greater than the supported maximum
+ Capture file writing:
+ Create the file in pcap_dump_open_append() if it doesn't exist
+ Packet filtering:
+ Fix "unknown ether proto 'aarp'"
+ Add a new filter "ifindex" for DLT_LINUX_SLL2 files on all
+ platforms and live Linux captures
+ Add a hack to the optimizer to try to catch certain optimizer
+ loops (should prevent GitHub issue #112)
+ Show special Linux BPF offsets symbolically in bpf_image() and
+ bpf_dump()
+ Added support for ICMPv6 types 1-4 as tokens with names
+ Remove undocumented and rather old "ether proto" protocols
+ Catch invalid IPv4 addresses in filters
+ Don't assume ARM supports unaligned accesses
+ Security and other issues found by analysis:
+ Fix various security issues reported by Charles Smith at Tangible
+ Security
+ Fix various security issues reported by Include Security
+ Fix some issues found by cppcheck.
+ Add some overflow checks in the optimizer
+ rpcap:
+ Support rpcap-over-TLS
+ Redo protocol version negotiation to avoid problems with old
+ servers (it still works with servers using the old negotiation,
+ as well as servers not supporting negotiation)
+ Error handling cleanups
+ Add some new authentication libpcap error codes for specific
+ errors
+ Fix some inetd issues in rpcapd
+ Fix rpcapd core dumps with invalid configuration file
+ On UN*X, don't have rpcapd tell the client why authentication
+ failed, so a brute-force attacker can't distinguish between
+ "unknown user name" and "known user name, wrong password"
+ Allow rpcapd to rebind more rapidly (GitHub issue #765)
+ Documentation:
+ Improve man pages, including adding backward compatibility notes
+ Building and testing:
+ Require, and assume, some level of C99 support in the C compiler
+ Require Visual Studio 2015 or later if using Visual Studio
+ Fix configure script issues, including with libnl on Linux
+ Fix CMake issues
+ Squelch complaints from Bison about "%define api.pure" being
+ deprecated
+ Fix compilation of pcap-tc.c
+ Linux:
+ Require PF_PACKET support, and kernel 2.6.27 or later
+ Handle systems without AF_INET or AF_UNIX socket support
+ Get rid of Wireless Extensions for turning monitor mode on
+ Proper memory sync for PACKET_MMAP (may prevent GitHub issue
+ #898)
+ Drop support for libnl 1 and 2.
+ Return error on interface going away, but not if it just went
+ down but is still present
+ Set socket protocol only after packet ring configured,
+ reducing bogus packet drop reports
+ Get ifdrop stats from sysfs.
+ When adjusting BPF programs, do not subtract the
+ SLL[2]_HDR_LEN if the location is negative (special metadata
+ offset), to preserve references to metadata; see
+ https://github.com/the-tcpdump-group/tcpdump/issues/480#issuecomment-486827278
+ Report a warning for unknown ARPHRD types
+ Have pcap_breakloop() forcibly break out of a sleeping
+ capture loop
+ Add support for DSA data link types
+ For raw USB bus capture, use the snapshot length to set the
+ buffer size, and set the len field to reflect the length
+ in the URB (GitHub issue #808)
+ With a timeout of zero, wait indefinitely
+ Clean up support for some non-GNU libc C libraries
+ Add DLT_LINUX_SLL2 for cooked-mode captures
+ Probe CONFIGURATION descriptor of connected USB devices
+ Treat EPERM on ethtool ioctls as meaning "not supported", as
+ permissions checks are done before checking whether the
+ ioctl is supported at all
+ macOS:
+ Cope with getting EPWROFF from SIOCGIFMEDIA
+ Treat EPERM on SIOCGIFMEDIA as meaning "not supported", as
+ permissions checks are done before checking whether the
+ ioctl is supported at all
+ Treat ENXIO when reading packets as meaning "the interface
+ was removed"
+ Report "the interface disappeared", not "the interface went
+ down", if the interface was removed during a capture
+ FreeBSD:
+ Treat ENXIO as meaning "the interface was removed"
+ Report "the interface disappeared", not "the interface went
+ down", if the interface was removed during a capture
+ NetBSD:
+ Treat ENXIO as meaning "the interface was removed"
+ Report "the interface disappeared", not "the interface went
+ down", if the interface was removed during a capture
+ OpenBSD:
+ Treat EIO as meaning "the interface was removed"
+ Report "the interface disappeared", not "the interface went
+ down", if the interface was removed during a capture
+ DragonFly BSD:
+ Treat ENXIO as meaning "the interface was removed"
+ Report "the interface disappeared", not "the interface went
+ down", if the interface was removed during a capture
+ Solaris:
+ Treat ENXIO as meaning "the interface was removed"
+ Report "the interface disappeared", not "the interface went
+ down", if the interface was removed during a capture
+ AIX:
+ Fix loading of BPF kernel extension
+ Treat ENXIO as meaning "the interface was removed"
+ Report "the interface disappeared", not "the interface went
+ down", if the interface was removed during a capture
+ Windows:
+ Make the snapshot length work even if pcap_setfilter()
+ isn't called
+ Fix compilation on Cygwin/MSYS
+ Add pcap_handle(), and deprecate pcap_fileno()
+ Report PCAP_ERROR_NO_SUCH_DEVICE for a non-existent device
+ Return an appropriate error message for device removed or
+ device unusable due to a suspend/resume
+ Report a warning for unknown NdisMedium types
+ Have pcap_breakloop() forcibly break out of a sleeping
+ capture loop
+ Clean up building DLL
+ Handle CRT mismatch for pcap_dump_fopen()
+ Map NdisMediumWirelessWan to DLT_RAW
+ Add AirPcap support in a module, rather than using
+ WinPcap/Npcap's support for it
+ Report the system error for PacketSetHwFilter() failures
+ Add support for getting and setting packet time stamp types
+ with Npcap
+ Have pcap_init() allow selecting whether the API should use
+ local code page strings or UTF-8 strings (including error
+ messages)
+ Haiku:
+ Add capture support
+
Sunday, July 22, 2018
Summary for 1.9.1 libpcap release
Mention pcap_get_required_select_timeout() in the main pcap man page
@@ -67,7 +378,6 @@ Sunday, July 22, 2018
Boost the TPACKET_V3 timeout to the maximum if a timeout of 0 was
specified
Five CVE-2019-15161, CVE-2019-15162, CVE-2019-15163, CVE-2019-15164, CVE-2019-15165
- Fixes for CVE-2018-16301, errors in pcapng reading.
PCAPNG reader applies some sanity checks before doing malloc().
Sunday, June 24, 2018, by mcr@sandelman.ca
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2241d5b1..b6474b16 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -141,15 +141,17 @@ endif(MSVC)
#
# If we're building with MinGW, we need to specify _WIN32_WINNT as
-# 0x0600 ("NT 6.0", a/k/a Vista/Windows Server 2008) in order to
-# get the full IPv6 API, including inet_ntop().
+# 0x0600 ("NT 6.0", a/k/a Vista/Windows Server 2008) or higher
+# in order to get the full IPv6 API, including inet_ntop(), and we
+# need to specify it as 0x0601 ("NT 6.1", a/k/a Windows 7) or higher
+# in order to get NdisMediumIP.
#
# NOTE: pcap does *NOT* work with msvcrt.dll; it must link with
# a newer version of the C library, i.e. Visual Studio 2015 or
# later, as it depends on C99 features introduced in VS 2015.
#
if(MINGW)
- add_definitions(-D_WIN32_WINNT=0x0600)
+ add_definitions(-D_WIN32_WINNT=0x0601)
endif(MINGW)
#
@@ -304,22 +306,22 @@ if(WIN32)
endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/../../Common)
find_package(Packet)
- if(PACKET_FOUND)
+ if(Packet_FOUND)
set(HAVE_PACKET32 TRUE)
- include_directories(${PACKET_INCLUDE_DIRS})
+ include_directories(${Packet_INCLUDE_DIRS})
#
# Check whether we have the NPcap PacketIsLoopbackAdapter()
# function.
#
cmake_push_check_state()
- set(CMAKE_REQUIRED_LIBRARIES ${PACKET_LIBRARIES})
+ set(CMAKE_REQUIRED_LIBRARIES ${Packet_LIBRARIES})
check_function_exists(PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER)
check_function_exists(PacketGetTimestampModes HAVE_PACKET_GET_TIMESTAMP_MODES)
cmake_pop_check_state()
- endif(PACKET_FOUND)
+ endif(Packet_FOUND)
message(STATUS "checking for Npcap's version.h")
- check_symbol_exists(WINPCAP_PRODUCT_NAME "../../version.h" HAVE_VERSION_H)
+ check_symbol_exists(WINPCAP_PRODUCT_NAME "${CMAKE_SOURCE_DIR}/../../version.h" HAVE_VERSION_H)
if(HAVE_VERSION_H)
message(STATUS "HAVE version.h")
else(HAVE_VERSION_H)
@@ -380,30 +382,47 @@ if(NOT WIN32)
check_include_file(sys/select.h HAVE_SYS_SELECT_H)
check_include_file(netpacket/packet.h HAVE_NETPACKET_PACKET_H)
- check_include_files("sys/types.h;sys/socket.h;net/if.h;net/pfvar.h" HAVE_NET_PFVAR_H)
- if(HAVE_NET_PFVAR_H)
- #
- # Check for various PF actions.
- #
- check_c_source_compiles(
-"#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/pfvar.h>
+ check_include_file(netinet/if_ether.h HAVE_NETINET_IF_ETHER_H)
+endif(NOT WIN32)
-int
+#
+# Functions.
+#
+# First, check for the __atomic_load_n() and __atomic_store_n()
+# builtins.
+#
+# We can't use check_function_exists(), as it tries to declare
+# the function, and attempting to declare a compiler builtin
+# can produce an error.
+#
+# We don't use check_symbol_exists(), as it expects a header
+# file to be specified to declare the function, but there isn't
+# such a header file.
+#
+# So we use check_c_source_compiles().
+#
+check_c_source_compiles(
+"int
main(void)
{
- return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;
+ int i = 17;
+ return __atomic_load_n(&i, __ATOMIC_RELAXED);
}
"
- HAVE_PF_NAT_THROUGH_PF_NORDR)
- endif(HAVE_NET_PFVAR_H)
- check_include_file(netinet/if_ether.h HAVE_NETINET_IF_ETHER_H)
-endif(NOT WIN32)
+ HAVE___ATOMIC_LOAD_N)
+check_c_source_compiles(
+"int
+main(void)
+{
+ int i;
+ __atomic_store_n(&i, 17, __ATOMIC_RELAXED);
+ return 0;
+}
+"
+ HAVE___ATOMIC_STORE_N)
#
-# Functions.
+# Now check for various system functions.
#
check_function_exists(strerror HAVE_STRERROR)
check_function_exists(strerror_r HAVE_STRERROR_R)
@@ -1235,7 +1254,7 @@ if(WIN32)
#
# Link with packet.dll before Winsock2.
#
- set(PCAP_LINK_LIBRARIES ${PACKET_LIBRARIES} ${PCAP_LINK_LIBRARIES})
+ set(PCAP_LINK_LIBRARIES ${Packet_LIBRARIES} ${PCAP_LINK_LIBRARIES})
elseif(PCAP_TYPE STREQUAL "null")
else()
message(FATAL_ERROR "${PCAP_TYPE} is not a valid pcap type")
@@ -1794,7 +1813,7 @@ if(NOT DISABLE_SNF)
endif()
# Check for Riverbed AirPcap support.
-if(NOT DISABLE_AIRPCAP)
+if(NOT DISABLE_AirPcap)
#
# Try to find the AirPcap header file and library.
#
@@ -1803,14 +1822,14 @@ if(NOT DISABLE_AIRPCAP)
#
# Did we succeed?
#
- if(AIRPCAP_FOUND)
+ if(AirPcap_FOUND)
#
# Yes.
#
- include_directories(AFTER ${AIRPCAP_INCLUDE_DIRS})
+ include_directories(AFTER ${AirPcap_INCLUDE_DIRS})
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-airpcap.c)
set(HAVE_AIRPCAP_API TRUE)
- set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${AIRPCAP_LIBRARIES})
+ set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${AirPcap_LIBRARIES})
endif()
endif()
@@ -2016,6 +2035,19 @@ if(NOT MSVC)
endif(NOT MSVC)
#
+# Extra compiler options for the build matrix scripts to request -Werror or
+# its equivalent if required. The CMake variable name cannot be CFLAGS
+# because that is already used for a different purpose in CMake. Example
+# usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ...
+#
+if(NOT "${EXTRA_CFLAGS}" STREQUAL "")
+ foreach(_extra_cflag ${EXTRA_CFLAGS})
+ check_and_add_compiler_option("${_extra_cflag}")
+ endforeach(_extra_cflag)
+ message(STATUS "Added extra compile options (${EXTRA_CFLAGS})")
+endif()
+
+#
# Flex/Lex and YACC/Berkeley YACC/Bison.
# From a mail message to the CMake mailing list by Andy Cedilnik of
# Kitware.
@@ -2073,7 +2105,7 @@ else()
# "%pure-parser".
#
execute_process(COMMAND ${YACC_EXECUTABLE} -V OUTPUT_VARIABLE bison_full_version)
- string(REGEX MATCH "[1-9][0-9]*[.][1-9][0-9]*" bison_major_minor ${bison_full_version})
+ string(REGEX MATCH "[1-9][0-9]*[.][0-9]+" bison_major_minor ${bison_full_version})
if (bison_major_minor VERSION_LESS "2.4")
set(REENTRANT_PARSER "%pure-parser")
else()
@@ -2085,17 +2117,11 @@ message(STATUS "Parser generator: ${YACC_EXECUTABLE}")
#
# Create custom command for the scanner.
-# 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")
-endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h
SOURCE ${pcap_BINARY_DIR}/grammar.y
- COMMAND ${YACC_EXECUTABLE} ${YACC_COMPATIBILITY_FLAG} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_BINARY_DIR}/grammar.y
+ COMMAND ${YACC_EXECUTABLE} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_BINARY_DIR}/grammar.y
DEPENDS ${pcap_BINARY_DIR}/grammar.y
)
@@ -2416,13 +2442,10 @@ if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
# captures.)
#
set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386;ppc")
- else()
+ elseif(SYSTEM_VERSION_MAJOR GREATER 10 AND SYSTEM_VERSION_MAJOR LESS 19)
#
- # Post-Snow Leopard. Build for x86-64 and 32-bit x86,
- # with x86-64 first. (That's what Apple does)
- # XXX - update if and when Apple drops support
- # for 32-bit x86 code and if and when Apple adds
- # ARM-based Macs. (You're on your own for iOS etc.)
+ # Post-Snow Leopard, pre-Catalina. Build for x86-64
+ # and 32-bit x86, with x86-64 first. (That's what Apple does)
#
# First, check whether we're building with OpenSSL.
# If so, don't bother trying to build fat.
@@ -2465,6 +2488,61 @@ main(void)
endif()
endif()
endif()
+ elseif(SYSTEM_VERSION_MAJOR EQUAL 19)
+ #
+ # Catalina. Build libraries and executables
+ # only for x86-64. (That's what Apple does;
+ # 32-bit x86 binaries are not supported on
+ # Catalina.)
+ #
+ set(OSX_LIBRARY_ARCHITECTURES "x86_64")
+ else()
+ #
+ # Post-Catalina. Build libraries and
+ # executables for x86-64 and ARM64.
+ # (That's what Apple does, except they
+ # build for arm64e, which may include
+ # some of the pointer-checking extensions.)
+ #
+ # If we're building with libssl, make sure
+ # we can build fat with it (i.e., that it
+ # was built fat); if we can't, don't set
+ # the target architectures, and just
+ # build for the host we're on.
+ #
+ # Otherwise, just add both of them.
+ #
+ if(HAVE_OPENSSL)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_FLAGS "-arch x86_64 -arch arm64")
+ set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
+ set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
+ #
+ # We must test whether this compiles and links, so
+ # check_symbol_exists() isn't sufficient.
+ #
+ # SSL_library_init() may be a macro that's #defined
+ # to be the real function to call, so we have to
+ # include <openssl/ssl.h>, and check_function_exists()
+ # isn't sufficient.
+ #
+ check_c_source_compiles(
+"#include <openssl/ssl.h>
+int
+main(void)
+{
+ SSL_library_init();
+ return 0;
+}
+"
+ FAT_SSL_BUILDS_SUPPORTED)
+ cmake_pop_check_state()
+ if(FAT_SSL_BUILDS_SUPPORTED)
+ set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64")
+ endif()
+ else()
+ set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64")
+ endif()
endif()
if(BUILD_SHARED_LIBS)
set_target_properties(${LIBRARY_NAME} PROPERTIES
@@ -2511,14 +2589,14 @@ function(install_manpage_symlink SOURCE TARGET MANDIR)
endif(MINGW)
install(CODE
- "message(STATUS \"Symlinking: ${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\")
+ "message(STATUS \"Symlinking: \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\")
execute_process(
COMMAND \"${CMAKE_COMMAND}\" \"-E\" \"remove\" \"${TARGET}\"
- WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${MANDIR}
+ WORKING_DIRECTORY \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${MANDIR}
)
execute_process(
COMMAND ${LINK_COMMAND}
- WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${MANDIR}
+ WORKING_DIRECTORY \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${MANDIR}
RESULT_VARIABLE EXIT_STATUS
)
if(NOT EXIT_STATUS EQUAL 0)
@@ -2597,17 +2675,24 @@ set(MANMISC_EXPAND
pcap-tstamp.manmisc.in
)
-if(NOT BUILD_SHARED_LIBS)
- unset(LIBRARY_NAME)
-endif(NOT BUILD_SHARED_LIBS)
+if(BUILD_SHARED_LIBS)
+ set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME}" "${LIBRARY_NAME_STATIC}")
+else(BUILD_SHARED_LIBS)
+ set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME_STATIC}")
+endif(BUILD_SHARED_LIBS)
-if(WIN32)
+if(WIN32 OR CYGWIN OR MSYS)
+ #
+ # XXX - according to the CMake documentation, WIN32 is set if
+ # the target is Windows; would there ever be a case where
+ # CYGWIN or MSYS are set but WIN32 *isn't* set?
+ #
if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
#
# Install 64-bit code built with MSVC in the x64 subdirectories,
# as that's where it expects it to be.
#
- install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC}
+ install(TARGETS ${LIBRARIES_TO_INSTALL}
RUNTIME DESTINATION bin/x64
LIBRARY DESTINATION lib/x64
ARCHIVE DESTINATION lib/x64)
@@ -2625,22 +2710,22 @@ if(WIN32)
# in the top-level directories, as those are where they
# expect it to be.
#
- install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC}
+ install(TARGETS ${LIBRARIES_TO_INSTALL}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
- if(NOT MINGW)
+ if(MSVC)
install(FILES $<TARGET_FILE_DIR:${LIBRARY_NAME_STATIC}>/${LIBRARY_NAME_STATIC}.pdb
DESTINATION bin OPTIONAL)
if(BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:${LIBRARY_NAME}>
DESTINATION bin OPTIONAL)
endif(BUILD_SHARED_LIBS)
- endif(NOT MINGW)
+ endif(MSVC)
endif(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
-else(WIN32)
- install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
-endif(WIN32)
+else(WIN32 OR CYGWIN OR MSYS)
+ install(TARGETS ${LIBRARIES_TO_INSTALL} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
+endif(WIN32 OR CYGWIN OR MSYS)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pcap/ DESTINATION include/pcap)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap.h DESTINATION include)
@@ -2650,7 +2735,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap-namedb.h DESTINATION include)
# On UN*X, and on Windows when not using MSVC, generate libpcap.pc and
# pcap-config and process man pages and arrange that they be installed.
if(NOT MSVC)
- set(PACKAGE_NAME ${LIBRARY_NAME})
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(includedir "\${prefix}/include")
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 69b59726..fb22c5e3 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -14,10 +14,10 @@ above), please navigate to https://github.com/the-tcpdump-group/libpcap/issues
and check if the problem has already been reported. If it has not, please open
a new issue and provide the following details:
-* libpcap version (e.g. from tcpdump --version)
+* libpcap version (e.g. from `tcpdump --version`)
* operating system name and version and any other details that may be relevant
- (uname -a, compiler name and version, CPU type etc.)
-* configure flags if any were used
+ (`uname -a`, compiler name and version, CPU type etc.)
+* `configure` or `cmake` flags if any were used
* statement of the problem
* steps to reproduce
diff --git a/CREDITS b/CREDITS
index f7abc1f3..b9ab9317 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3,29 +3,42 @@ This file lists people who have contributed to libpcap.
The current maintainers (in alphabetical order):
Denis Ovsienko <denis at ovsienko dot info>
Francois-Xavier Le Bail <devel dot fx dot lebail at orange dot fr>
- Guy Harris <guy at alum dot mit dot edu>
+ Guy Harris <gharris at sonic dot net>
Michael Richardson <mcr at sandelman dot ottawa dot on dot ca>
Additional people who have contributed patches (in alphabetical order):
+ Adrian Budau <adbudau at bitdefender dot com>
Akos Vandra <axos88 at gmail dot com>
Alan Bawden <Alan at LCS dot MIT dot EDU>
Albert Chin <china at thewrittenword dot com>
+ Alexander Galanin <al at galanin dot nnov dot ru>
Alexander 'Leo' Bergolth <Leo dot Bergolth at wu-wien dot ac dot at>
Alexey Kuznetsov <kuznet at ms2 dot inr dot ac dot ru>
+ Alex Smith <44322503+MadAlexUK at users dot noreply dot github dot com>
+ Alfredo Alvarez Fernandez <alfredoalvarezernandez at gmail dot com>
Ali Abdulkadir <autostart dot ini at gmail dot com>
Alon Bar-Lev <alonbl at sourceforge dot net>
+ Anders Broman <anders dot broman at ericsson dot com>
Andres Perera <andres dot p at zoho dot com>
Andrew Brown <atatat at atatdot dot net>
<andy-1 at sourceforge dot net>
Ani Sinha <ani at aristanetworks dot com>
+ Anthony Kirby <Anthony dot Kirby at nominet dot uk>
Antti Kantee <pooka at netbsd dot org>
Arien Vijn <arienvijn at sourceforge dot net>
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
Assar Westerlund <assar at sics dot se>
+ Atzm Watanabe <atzm at atzm dot org>
+ Baptiste Peugnez <baptiste dot peugnez at cea dot fr>
+ Baruch Siach <baruch at tkos dot co dot il>
Bill Parker <wp02855 at gmail dot com>
+ blazeable <blazeable at blazeable dot eu>
+ bleader <bleader at ratonland dot org>
Brent Cook <brent at boundary dot com>
Brian Ginsbach <ginsbach at cray dot com>
+ B. Scott Michel <scooter dot phd at gmail dot com>
+ Cedric Cellier <rixed at happyleptic dot org>
Charles M. Hannum <mycroft at netbsd dot org>
Chris G. Demetriou <cgd at netbsd dot org>
Chris Lightfoot <cwrl at users dot sourceforge dot net>
@@ -34,15 +47,22 @@ Additional people who have contributed patches (in alphabetical order):
Christian Bell <csbell at myri dot com>
Christian Peron <csjp at freebsd dot org>
Christian Svensson <blue at cmd dot nu>
+ Christopher K Lee <christopher dot lee at cspi dot com>
+ Daniel Borkmann <dborkman at redhat dot com>
Daniele Orlandi <daniele at orlandi dot com>
+ Daniel Lublin <daniel at lublin dot se>
+ Daniel Miller <dmiller at nmap dot org>
+ Dario Lombardo <lomato at gmail dot com>
Darren Lim <darren dot lim at endace dot com>
Darren Reed <darrenr at sun dot com>
+ Dave Barach <dave at barachs dot net>
David Clark <david dot clark at datasoft dot com>
David Kaelbling <drk at sgi dot com>
David Ward <david dot ward at ll dot mit dot edu>
David Young <dyoung at ojctech dot com>
Dean Gaudet <dean at arctic dot org>
dhruv <rsrivat at sourceforge dot net>
+ Dmytro Ovdiienko <dmitriy dot ovdienko at gmail dot com>
Don Ebright <Don dot Ebright at compuware dot com>
Dug Song <dugsong at monkey dot org>
Dustin Spicuzza <dustin at virtualroadside dot com>
@@ -50,8 +70,12 @@ Additional people who have contributed patches (in alphabetical order):
Edward Sheldrake <ejs1920 at sourceforge dot net>
Eric Anderson <anderse at hpl dot hp dot com>
Erik de Castro Lopo <erik dot de dot castro dot lopo at sensorynetworks dot com>
+ Fedor Sakharov <fedor dot sakharov at gmail dot com>
+ Felix Janda <felix dot janda at posteo dot de>
Felix Obenhuber <felix at obenhuber dot de>
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
+ Florian Fainelli <f dot fainelli at gmail dot com>
+ François Revol <revol at free dot fr>
Franz Schaefer <schaefer at mond dot at>
frederich <frederich at sourceforge dot net>
Fulko Hew <fulko dot hew at gmail dot com>
@@ -59,6 +83,7 @@ Additional people who have contributed patches (in alphabetical order):
Gabor Tatarka <gabor dot tatarka at ericsson dot com>
Garrett Cooper <yaberauneya at sourceforge dot net>
George Neville-Neil <gnn at freebsd dot org>
+ Gerald Combs <gerald at zing dot org>
Gerard Garcia <nouboh at gmail dot com>
Gianluca Varenni <gianluca dot varenni at gmail dot com>
Gilbert Hoyek <gil_hoyek at hotmail dot com>
@@ -71,47 +96,64 @@ Additional people who have contributed patches (in alphabetical order):
Gustavo Zacarias <gustavo at zacarias dot com dot ar>
Hagen Paul Pfeifer <hagen at jauu dot net>
Henri Doreau <hdoreau at sourceforge dot net>
+ Hiroaki KAWAI <kawai at stratosphere dot co dot jp>
Hyung Sik Yoon <hsyn at kr dot ibm dot com>
Igor Khristophorov <igor at atdot dot org>
+ Jakub Sitnicki <jsitnicki at gmail dot com>
Jakub Zawadzki <darkjames at darkjames dot pl>
+ James Ko <jck at exegin dot com>
Jan-Philip Velders <jpv at veldersjes dot net>
Jason R. Thorpe <thorpej at netbsd dot org>
Javier Achirica <achirica at ttd dot net>
Jean-Louis Charton <Jean-Louis dot CHARTON at oikialog dot com>
Jean Tourrilhes <jt at hpl dot hp dot com>
Jefferson Ogata <jogata at nodc dot noaa dot gov>
+ Jerome Duval <jerome dot duval at gmail dot com>
Jesper Dangaard Brouer <hawk at comx dot dk>
Jesper Peterson <jesper at endace dot com>
Jesse Gross <jesse at nicira dot com>
+ JHA <jon dot anderson at oracle dot com>
+ jingyu yang <jingleyang at users dot noreply dot github dot com>
Jiri Slaby <jirislaby at gmail dot com>
+ João Valverde <joao dot valverde at tecnico dot ulisboa dot pt>
Joerg Mayer <jmayer at loplof dot de>
John Bankier <jbankier at rainfinity dot com>
Jon Lindgren <jonl at yubyub dot net>
Jon Smirl <jonsmirl at gmail dot com>
Jorge Boncompte [DTI2] <jorge at dti2 dot net>
+ jromanr <jromanr at hotmail dot com>
Juergen Schoenwaelder <schoenw at ibr dot cs dot tu-bs dot de>
Julien Moutinho <julm at savines dot alpes dot fr dot eu dot org>
Jung-uk Kim <jkim at FreeBSD dot org>
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
+ Kevin Boulain <kevin dot boulain at securactive dot net>
Klaus Klein <kleink at netbsd dot org>
Koryn Grant <koryn at endace dot com>
Kris Katterjohn <katterjohn at gmail dot com>
Krzysztof Halasa <khc at pm dot waw dot pl>
Lennert Buytenhek <buytenh at wantstofly dot org>
+ lixiaoyan <lixiaoyan at google dot com>
Lorenzo Cavallaro <sullivan at sikurezza dot org>
Loris Degioanni <loris at netgroup-serv dot polito dot it>
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
Luis MartinGarcia <luis dot mgarc at gmail dot com>
+ lxy <391861737 at qq dot com>
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
Mansour Behabadi <mansour at oxplot dot com>
Marcus Felipe Pereira <marcus at task dot com dot br>
+ Mario J. Rugiero <mrugiero at gmail dot com>
Mark C. Brown <mbrown at hp dot com>
Mark Johnston <markjdb at gmail dot com>
+ Mark Marshall <mark dot marshall at omicronenergy dot com>
Mark Pizzolato <List-tcpdump-workers at subscriptions dot pizzolato dot net>
Markus Mayer <markus_mayer at sourceforge dot net>
Martin Husemann <martin at netbsd dot org>
Márton Németh <nm127 at freemail dot hu>
+ Matt Eaton <agnosticdev at gmail dot com>
Matthew Luckie <mjl at luckie dot org dot nz>
+ Matthias Hannig <matthias at hannig dot cc>
+ Matwey V. Kornilov <matwey dot kornilov at gmail dot com>
+ maxice8 <thinkabit dot ukim at gmail dot com>
Max Laier <max at love2party dot net>
Michal Kubecek <mkubecek at suse dot cz>
Michal Labedzki <michal dot labedzki at tieto dot com>
@@ -119,25 +161,36 @@ Additional people who have contributed patches (in alphabetical order):
Mike Frysinger <vapier at gmail dot com>
Mike Kershaw <dragorn at kismetwireless dot net>
Mike Wiacek <mike at iroot dot net>
+ Milosz Kaniewski <milosz dot kaniewski at gmail dot com>
Miroslav Lichvar <mlichvar at redhat dot com>
Monroe Williams <monroe at pobox dot com>
+ Myricom Help <myri at users dot noreply dot github dot com>
+ Nan Xiao <nan at chinadtrace dot org>
+ Nick Kelsey <nickk at silicondust dot com>
Nicolas Dade <ndade at nsd dot dyndns dot org>
Niko Delarich <niko dot delarich at gmail dot com>
N. Leiten <nleiten at sourceforge dot net>
+ nnposter <nnposter at users dot noreply dot github dot com>
<nvercamm at sourceforge dot net>
Octavian Cerna <tavy at ylabs dot com>
Olaf Kirch <okir at caldera dot de>
Ollie Wild <aaw at users dot sourceforge dot net>
+ Ondřej Hošek <ondra dot hosek at gmail dot com>
Onno van der Linden <onno at simplex dot nl>
+ Orgad Shaneh <orgad dot shaneh at audiocodes dot com>
+ Ørjan Malde <red at foxi dot me>
Paolo Abeni <pabeni at redhat dot com>
Patrick Marie <mycroft at virgaria dot org>
- Patrick McHardy <kaber at trash not net>
+ Patrick McHardy <kaber at trash dot net>
Paul Mundt <lethal at linux-sh dot org>
Pavel Kankovsky <kan at dcit dot cz>
+ Pawel Brzezinski <pawel dot brzezinski at harman dot com>
Pawel Pokrywka <publicpp at gmail dot com>
Peter Fales <peter at fales-lorenz dot net>
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
Peter Volkov <pva at gentoo dot org>
+ Petr Vorel <pvorel at suse dot cz>
+ Philippe Antoine <contact at catenacyber dot fr>
Phil Wood <cpw at lanl dot gov>
Rafal Maszkowski <rzm at icm dot edu dot pl>
<rcb-isis at users dot sourceforge dot net>
@@ -145,9 +198,9 @@ Additional people who have contributed patches (in alphabetical order):
Rick Jones <raj at cup dot hp dot com>
Robert Edmonds <stu-42 at sourceforge dot net>
Roberto Mariani <jelot-tcpdump at jelot dot it>
- Rongxi Li <rongxi dot li at chaitin dot com>
Roland Dreier <roland at purestorage dot com>
Romain Francoise <rfrancoise at debian dot org>
+ Rongxi Li <rongxi dot li at chaitin dot com>
Sagun Shakya <sagun dot shakya at sun dot com>
Scott Barron <sb125499 at ohiou dot edu>
Scott Gifford <sgifford at tir dot com>
@@ -156,22 +209,37 @@ Additional people who have contributed patches (in alphabetical order):
Sebastien Roy <Sebastien dot Roy at Sun dot COM>
Sepherosa Ziehau <sepherosa at gmail dot com>
Shaun Clowes <delius at progsoc dot uts dot edu dot au>
+ solofox <wensg100 at sina dot com>
Solomon Peachy <pizza at shaftnet dot org>
Stefan Hudson <hudson at mbay dot net>
Stephen Donnelly <stephen at endace dot com>
+ Steve Karg <skarg at users dot sourceforge dot net>
+ stubbfel <stubbfel at gmail dot com>
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
Tanaka Shin-ya <zstanaka at archer dot livedoor dot com>
+ Thomas Habets <habets at google dot com>
+ Thomas Petazzoni <thomas dot petazzoni at free-electrons dot com>
Tobias Poschwatta <posch at sourceforge dot net>
+ Tomasz Moń <desowin at gmail dot com>
+ Tommy Beadle <tbeadle at arbor dot net>
Tony Li <tli at procket dot com>
Torsten Landschoff <torsten at debian dot org>
+ Tymoteusz Blazejczyk <tymoteusz dot blazejczyk at intel dot com>
Uns Lider <unslider at miranda dot org>
Uwe Girlich <Uwe dot Girlich at philosys dot de>
+ Vitaly Lavrov <vel21ripn at gmail dot com>
+ Vivien Didelot <vivien dot didelot at gmail dot com>
+ Vladimir Gladkov <vovkos at gmail dot com>
+ Vladimir Marek <vlmarek at volny dot cz>
+ Walter Schell <walterschell at users dot noreply dot github dot com>
Wesley Shields <wxs at FreeBSD dot org>
Xianjie Zhang <xzhang at cup dot hp dot com>
Xin Li <delphij at FreeBSD dot org>
Xue Jiang Qing <xuejianqing at star-net dot cn>
+ Yang Luo <hsluoyz at qq dot com>
Yen Yen Lim
Yoann Vandoorselaere <yoann at prelude-ids dot org>
+ Yogesh Prasad <yogesh dot prasad at rockwellcollins dot com>
Yvan Vanhullebus <vanhu at sourceforge dot net>
The original LBL crew:
diff --git a/INSTALL.md b/INSTALL.md
index ba8b8f92..d3c636ad 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,7 +1,8 @@
-To build libpcap, run "./configure" (a shell script). The configure
+# libpcap installation notes
+To build libpcap, run `./configure` (a shell script). The configure
script will determine your system attributes and generate an
-appropriate Makefile from Makefile.in. Next run "make". If everything
-goes well you can su to root and run "make install". However, you need
+appropriate `Makefile` from `Makefile.in`. Next run `make`. If everything
+goes well, you can `su` to root and run `make install`. However, you need
not install libpcap if you just want to build tcpdump; just make sure
the tcpdump and libpcap directory trees have the same parent
directory.
@@ -16,90 +17,56 @@ does support packet capture but libpcap does not support that
particular type. (If you have HP-UX, see below.) If your system uses a
packet capture not supported by libpcap, please send us patches; don't
forget to include an autoconf fragment suitable for use in
-configure.ac.
+`configure.ac`.
It is possible to override the default packet capture type, although
-the circumstance where this works are limited. For example if you have
-installed bpf under SunOS 4 and wish to build a snit libpcap:
-
- ./configure --with-pcap=snit
-
-Another example is to force a supported packet capture type in the case
+the circumstances where this works are limited. One possible reason to
+do that would be to force a supported packet capture type in the case
where the configure scripts fails to detect it.
-You will need an ANSI C compiler to build libpcap. The configure script
-will abort if your compiler is not ANSI compliant. If this happens, use
-the generally available GNU C compiler (GCC).
+You will need a C99 compiler to build libpcap. The configure script
+will abort if your compiler is not C99 compliant. If this happens, use
+the generally available GNU C compiler (GCC) or Clang.
You will need either Flex 2.5.31 or later, or a version of Lex
compatible with it (if any exist), to build libpcap. The configure
script will abort if there isn't any such program. If you have an older
version of Flex, or don't have a compatible version of Lex, the current
-version of flex is available at flex.sourceforge.net.
+version of Flex is available [here](https://github.com/westes/flex).
You will need either Bison, Berkeley YACC, or a version of YACC
compatible with them (if any exist), to build libpcap. The configure
script will abort if there isn't any such program. If you don't have
-any such program, the current version of Bison can be found at
-https://ftp.gnu.org/gnu/bison/ and the current version of Berkeley YACC
-can be found at https://invisible-island.net/byacc/.
+any such program, the current version of Bison can be found
+[here](https://ftp.gnu.org/gnu/bison/) and the current version of Berkeley YACC
+can be found [here](https://invisible-island.net/byacc/).
Sometimes the stock C compiler does not interact well with Flex and
-Bison. The list of problems includes undefined references for alloca.
+Bison. The list of problems includes undefined references for alloca(3).
You can get around this by installing GCC.
-If you use Solaris, there is a bug with bufmod(7) that is fixed in
-Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the
-broken bufmod(7) results in data be truncated from the FRONT of the
-packet instead of the end. The work around is to not set a snapshot
-length but this results in performance problems since the entire packet
-is copied to user space. If you must run an older version of Solaris,
-there is a patch available from Sun; ask for bugid 1149065. After
-installing the patch, use "setenv BUFMOD_FIXED" to enable use of
-bufmod(7). However, we recommend you run a more current release of
-Solaris.
+## Linux specifics
+On Linux, libpcap will not work if the kernel does not have the packet
+socket option enabled; see [this file](doc/README.linux) for more
+information.
+## Solaris specifics
If you use the SPARCompiler, you must be careful to not use the
-/usr/ucb/cc interface. If you do, you will get bogus warnings and
-perhaps errors. Either make sure your path has /opt/SUNWspro/bin
-before /usr/ucb or else:
+`/usr/ucb/cc` interface. If you do, you will get bogus warnings and
+perhaps errors. Either make sure your path has `/opt/SUNWspro/bin`
+before `/usr/ucb` or else:
setenv CC /opt/SUNWspro/bin/cc
-before running configure. (You might have to do a "make distclean"
-if you already ran configure once).
+before running configure. (You might have to do a `make distclean`
+if you already ran `configure` once).
-If you are trying to do packet capture with a FORE ATM card, you may or
-may not be able to. They usually only release their driver in object
-code so unless their driver supports packet capture, there's not much
-libpcap can do.
-
-If you get an error like:
-
- tcpdump: recv_ack: bind error 0x???
-
-when using DLPI, look for the DL_ERROR_ACK error return values, usually
-in /usr/include/sys/dlpi.h, and find the corresponding value.
-
-Under {DEC OSF/1, Digital UNIX, Tru64 UNIX}, packet capture must be
-enabled before it can be used. For instructions on how to enable packet
-filter support, see:
-
- ftp://ftp.digital.com/pub/Digital/dec-faq/Digital-UNIX
-
-Look for the "How do I configure the Berkeley Packet Filter and capture
-tcpdump traces?" item.
-
-Once you enable packet filter support, your OSF system will support bpf
-natively.
-
-Under Ultrix, packet capture must be enabled before it can be used. For
-instructions on how to enable packet filter support, see:
-
- ftp://ftp.digital.com/pub/Digital/dec-faq/ultrix
+See [this file](doc/README.solaris.md) for more up to date
+Solaris-related information.
+## HP-UX specifics
If you use HP-UX, you must have at least version 9 and either the
-version of cc that supports ANSI C (cc -Aa) or else use the GNU C
+version of `cc` that supports C99 (`cc -AC99`) or else use the GNU C
compiler. You must also buy the optional streams package. If you don't
have:
@@ -113,10 +80,10 @@ need to install the "9.X LAN and DLPI drivers cumulative" patch
The DLPI streams package is standard starting with HP-UX 10.
The HP implementation of DLPI is a little bit eccentric. Unlike
-Solaris, you must attach /dev/dlpi instead of the specific /dev/*
+Solaris, you must attach `/dev/dlpi` instead of the specific `/dev/*`
network pseudo device entry in order to capture packets. The PPA is
based on the ifnet "index" number. Under HP-UX 9, it is necessary to
-read /dev/kmem and the kernel symbol file (/hp-ux). Under HP-UX 10,
+read `/dev/kmem` and the kernel symbol file (`/hp-ux`). Under HP-UX 10,
DLPI can provide information for determining the PPA. It does not seem
to be possible to trace the loopback interface. Unlike other DLPI
implementations, PHYS implies MULTI and SAP and you get an error if you
@@ -137,117 +104,34 @@ doing
echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem
-You would have to arrange that this happen on reboots; the right way to
+You would have to arrange that this happens on reboots; the right way to
do that would probably be to put it into an executable script file
-"/sbin/init.d/outbound_promisc" and making
-"/sbin/rc2.d/S350outbound_promisc" a symbolic link to that script.
+`/sbin/init.d/outbound_promisc` and making
+`/sbin/rc2.d/S350outbound_promisc` a symbolic link to that script.
Finally, testing shows that there can't be more than one simultaneous
DLPI user per network interface.
-If you use Linux, this version of libpcap is known to compile and run
-under Red Hat 4.0 with the 2.0.25 kernel. It may work with earlier 2.X
-versions but is guaranteed not to work with 1.X kernels. Running more
-than one libpcap program at a time, on a system with a 2.0.X kernel, can
-cause problems since promiscuous mode is implemented by twiddling the
-interface flags from the libpcap application; the packet capture
-mechanism in the 2.2 and later kernels doesn't have this problem. Also,
-packet timestamps aren't very good. This appears to be due to haphazard
-handling of the timestamp in the kernel.
-
-Note well: there is rumoured to be a version of tcpdump floating around
-called 3.0.3 that includes libpcap and is supposed to support Linux.
-You should be advised that neither the Network Research Group at LBNL
-nor the Tcpdump Group ever generated a release with this version number.
-The LBNL Network Research Group notes with interest that a standard
-cracker trick to get people to install trojans is to distribute bogus
-packages that have a version number higher than the current release.
-They also noted with annoyance that 90% of the Linux related bug reports
-they got are due to changes made to unofficial versions of their page.
-If you are having trouble but aren't using a version that came from
-tcpdump.org, please try that before submitting a bug report!
-
-On Linux, libpcap will not work if the kernel does not have the packet
-socket option enabled; see the README.linux file for information about
-this.
-
-If you use AIX, you may not be able to build libpcap from this release.
-We do not have an AIX system in house so it's impossible for us to test
-AIX patches submitted to us. We are told that you must link against
-/lib/pse.exp, that you must use AIX cc or a GNU C compiler newer than
-2.7.2, and that you may need to run strload before running a libpcap
-application.
+See [this file](doc/README.hpux) for more information specific to HP-UX.
-Read the README.aix file for information on installing libpcap and
+## AIX specifics
+See [this file](doc/README.aix) for information on installing libpcap and
configuring your system to be able to support libpcap.
-If you use NeXTSTEP, you will not be able to build libpcap from this
-release.
-
-If you use SINIX, you should be able to build libpcap from this
-release. It is known to compile and run on SINIX-Y/N 5.42 with the C-DS
-V1.0 or V1.1 compiler. But note that in some releases of SINIX, yacc
-emits incorrect code; if grammar.y fails to compile, change every
-occurrence of:
-
- #ifdef YYDEBUG
-
-to:
- #if YYDEBUG
-
-Another workaround is to use flex and bison.
-
-If you use SCO, you might have trouble building libpcap from this
-release. We do not have a machine running SCO and have not had reports
-of anyone successfully building on it; the current release of libpcap
-does not compile on SCO OpenServer 5. Although SCO apparently supports
-DLPI to some extent, the DLPI in OpenServer 5 is very non-standard, and
-it appears that completely new code would need to be written to capture
-network traffic. SCO do not appear to provide tcpdump binaries for
-OpenServer 5 or OpenServer 6 as part of SCO Skunkware:
-
- http://www.sco.com/skunkware/
-
-If you use UnixWare, you might be able to build libpcap from this
-release, or you might not. We do not have a machine running UnixWare,
-so we have not tested it; however, SCO provide packages for libpcap
-0.6.2 and tcpdump 3.7.1 in the UnixWare 7/Open UNIX 8 part of SCO
-Skunkware, and the source package for libpcap 0.6.2 is not changed from
-the libpcap 0.6.2 source release, so this release of libpcap might also
-build without changes on UnixWare 7.
-
-If linking tcpdump fails with "Undefined: _alloca" when using bison on
-a Sun4, your version of Bison is broken. In any case version 1.16 or
-higher is recommended (1.14 is known to cause problems 1.16 is known to
-work). Either pick up a current version from:
-
- https://ftp.gnu.org/gnu/bison/
-
-or hack around it by inserting the lines:
-
- #ifdef __GNUC__
- #define alloca __builtin_alloca
- #else
- #ifdef sparc
- #include <alloca.h>
- #else
- char *alloca ();
- #endif
- #endif
-
-right after the (100 line!) GNU license comment in bison.simple, remove
-grammar.[co] and fire up make again.
+## other specifics
+If you are trying to do packet capture with a FORE ATM card, you may or
+may not be able to. They usually only release their driver in object
+code so unless their driver supports packet capture, there's not much
+libpcap can do.
-If you use SunOS 4, your kernel must support streams NIT. If you run a
-libpcap program and it dies with:
+If you get an error like:
- /dev/nit: No such device
+ tcpdump: recv_ack: bind error 0x???
-You must add streams NIT support to your kernel configuration, run
-config and boot the new kernel.
+when using DLPI, look for the DL_ERROR_ACK error return values, usually
+in `/usr/include/sys/dlpi.h`, and find the corresponding value.
-FILES
------
+## Description of files
CHANGES - description of differences between releases
ChmodBPF/* - macOS startup item to set ownership and permissions on /dev/bpf*
CMakeLists.txt - CMake file
@@ -260,14 +144,13 @@ FILES
doc/README.aix - notes on using libpcap on AIX
doc/README.dag - notes on using libpcap to capture on Endace DAG devices
doc/README.hpux - notes on using libpcap on HP-UX
- doc/README.linux.md - notes on using libpcap on Linux
+ doc/README.linux - notes on using libpcap on Linux
doc/README.macos - notes on using libpcap on macOS
doc/README.septel - notes on using libpcap to capture on Intel/Septel devices
doc/README.sita - notes on using libpcap to capture on SITA devices
- doc/README.tru64 - notes on using libpcap on Digital/Tru64 UNIX
+ doc/README.solaris.md - notes on using libpcap on Solaris
doc/README.Win32.md - notes on using libpcap on Win32 systems (with Npcap)
VERSION - version of this release
- acconfig.h - support for post-2.13 autoconf
aclocal.m4 - autoconf macros
arcnet.h - ARCNET definitions
atmuni31.h - ATM Q.2931 definitions
@@ -286,8 +169,8 @@ FILES
fad-getad.c - pcap_findalldevs() for systems with getifaddrs()
fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST
fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF
- filtertest.c - test program for BPF compiler
- findalldevstest.c - test program for pcap_findalldevs()
+ testprogs/filtertest.c - test program for BPF compiler
+ testprogs/findalldevstest.c - test program for pcap_findalldevs()
gencode.c - BPF code generation routines
gencode.h - BPF code generation definitions
grammar.y - filter string grammar
@@ -300,7 +183,6 @@ FILES
msdos/* - drivers for MS-DOS capture support
nametoaddr.c - hostname to address routines
nlpid.h - OSI network layer protocol identifier definitions
- net - symlink to bpf/net
optimize.c - BPF optimization routines
pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header
pcap/bpf.h - BPF definitions
@@ -323,17 +205,14 @@ FILES
pcap-linux.c - Linux packet socket support
pcap-namedb.h - header for backwards compatibility
pcap-nit.c - SunOS Network Interface Tap support
- pcap-nit.h - SunOS Network Interface Tap definitions
pcap-npf.c - Npcap capture support
pcap-null.c - dummy monitor support (allows offline use of libpcap)
pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support
- pcap-pf.h - Ultrix and Digital/Tru64 UNIX Packet Filter definitions
pcap-septel.c - Intel/Septel device capture support
pcap-septel.h - Intel/Septel device capture support
pcap-sita.c - SITA device capture support
pcap-sita.h - SITA device capture support
pcap-sita.html - SITA device capture documentation
- pcap-stdinc.h - includes and #defines for compiling on Win32 systems
pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support
pcap-snoop.c - IRIX Snoop network monitoring support
pcap-usb-linux.c - USB capture support for Linux
@@ -342,10 +221,9 @@ FILES
pcap.c - pcap utility routines
pcap.h - header for backwards compatibility
pcap_*.3pcap - manual entries for library functions
- pcap-filter.4 - manual entry for filter syntax
- pcap-linktype.4 - manual entry for link-layer header types
+ pcap-filter.manmisc.in - manual entry for filter syntax
+ pcap-linktype.manmisc.in - manual entry for link-layer header types
ppp.h - Point to Point Protocol definitions
savefile.c - offline support
scanner.l - filter string scanner
sunatmpos.h - definitions for SunATM capturing
- Win32 - headers and routines for building on Win32 systems
diff --git a/Makefile-devel-adds b/Makefile-devel-adds
index fea63bbc..7cfd6c91 100644
--- a/Makefile-devel-adds
+++ b/Makefile-devel-adds
@@ -3,12 +3,12 @@
# From autoconf.info . Works best with GNU Make.
#
${srcdir}/configure: configure.ac aclocal.m4
- cd ${srcdir} && autoconf
+ (cd ${srcdir} && autoconf)
# autoheader might not change config.h.in, so touch a stamp file.
${srcdir}/config.h.in: ${srcdir}/stamp-h.in
${srcdir}/stamp-h.in: configure.ac aclocal.m4
- cd ${srcdir} && autoheader
+ (cd ${srcdir} && autoheader)
echo timestamp > ${srcdir}/stamp-h.in
config.h: stamp-h
diff --git a/Makefile.in b/Makefile.in
index 07ff8c16..70605ddf 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -79,7 +79,7 @@ INSTALL_DATA = @INSTALL_DATA@
RANLIB = @RANLIB@
LEX = @LEX@
-YACC = @YACC@
+BISON_BYACC = @BISON_BYACC@
# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
# Also, gcc does not remove the .o before forking 'as', which can be a
@@ -149,6 +149,7 @@ HDR = $(PUBHDR) \
pcap-int.h \
pcap-rpcap.h \
pcap-types.h \
+ pflog.h \
portability.h \
ppp.h \
rpcap-protocol.h \
@@ -252,7 +253,15 @@ EXTRA_DIST = \
Makefile.in \
Makefile-devel-adds \
README.md \
- doc \
+ doc/README.Win32.md \
+ doc/README.aix \
+ doc/README.dag \
+ doc/README.hpux \
+ doc/README.linux \
+ doc/README.macos \
+ doc/README.septel \
+ doc/README.sita \
+ doc/README.solaris.md \
CONTRIBUTING.md \
TODO \
VERSION \
@@ -410,10 +419,7 @@ EXTRA_DIST = \
testprogs/valgrindtest.c \
testprogs/visopts.py \
testprogs/writecaptest.c \
- tests/shb-option-too-long.pcapng \
- Win32/Prj/wpcap.sln \
- Win32/Prj/wpcap.vcxproj \
- Win32/Prj/wpcap.vcxproj.filters
+ tests/shb-option-too-long.pcapng
all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config
@@ -530,7 +536,7 @@ grammar.y: $(srcdir)/grammar.y.in ./config.status
mv $@.tmp $@
grammar.c: grammar.y
- $(YACC) -p pcap_ -o grammar.c -d $<
+ $(BISON_BYACC) -p pcap_ -o grammar.c -d $<
grammar.h: grammar.c
## Recover from the removal of $@
@if test -f $@; then :; else \
@@ -591,13 +597,13 @@ pcap-config: $(srcdir)/pcap-config.in ./config.status
# Remote pcap daemon.
#
build-rpcapd: libpcap.a
- cd rpcapd; $(MAKE)
+ (cd rpcapd; $(MAKE))
#
# Test programs - not built by default, and not installed.
#
testprogs: FORCE
- cd testprogs; $(MAKE)
+ (cd testprogs; $(MAKE))
FORCE:
@@ -729,7 +735,7 @@ install-archive-shareda:
#
install-rpcapd:
- cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install
+ (cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install)
uninstall: uninstall-shared uninstall-rpcapd
rm -f $(DESTDIR)$(libdir)/libpcap.a
@@ -786,12 +792,12 @@ uninstall-shared-shareda:
uninstall-shared-none:
uninstall-rpcapd:
- cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall
+ (cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall)
clean:
rm -f $(CLEANFILES)
- cd rpcapd; $(MAKE) clean
- cd testprogs; $(MAKE) clean
+ (cd rpcapd; $(MAKE) clean)
+ (cd testprogs; $(MAKE) clean)
distclean: clean
rm -f Makefile grammar.y config.cache config.log config.status \
@@ -799,8 +805,8 @@ distclean: clean
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
+ (cd rpcapd; $(MAKE) distclean)
+ (cd testprogs; $(MAKE) distclean)
extags: $(TAGFILES)
ctags $(TAGFILES)
@@ -809,23 +815,30 @@ tags: $(TAGFILES)
ctags -wtd $(TAGFILES)
releasetar:
- @autoreconf -f; \
- name=$(PROG)-`cat VERSION` ; \
- mkdir $$name; \
- tar -c --exclude='*~' -f - $(COMMON_C_SRC) $(HDR) $(MAN1) \
+ @autoreconf -f && \
+ name=$(PROG)-`cat VERSION` && \
+ mkdir $$name && \
+ tar cf - $(COMMON_C_SRC) $(HDR) $(MAN1) \
+ $(MAN3PCAP_EXPAND) $(MAN3PCAP_NOEXPAND) $(MANFILE) \
+ $(MANMISC) $(EXTRA_DIST) >/dev/null && \
+ tar cf - $(COMMON_C_SRC) $(HDR) $(MAN1) \
$(MAN3PCAP_EXPAND) $(MAN3PCAP_NOEXPAND) $(MANFILE) \
$(MANMISC) $(EXTRA_DIST) | \
- (cd $$name; tar xf -); \
- tar -c -z -f $$name.tar.gz $$name; \
+ (cd $$name; tar xf -) && \
+ tar cf - $$name >/dev/null && \
+ tar cf - $$name | gzip >$$name.tar.gz && \
rm -rf $$name
rc1 rc2 rc3 rc4 rc5:
@VER=`cat $(srcdir)/VERSION`; \
sed -i "s/$$VER/$${VER}$@/" VERSION ; \
make releasetar; \
- git checkout VERSION
+ git checkout VERSION configure
depend: $(GENERATED_C_SRC) $(GENHDR)
$(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC)
- cd rpcapd; $(MAKE) depend
- cd testprogs; $(MAKE) depend
+ (cd rpcapd; $(MAKE) depend)
+ (cd testprogs; $(MAKE) depend)
+
+shellcheck:
+ shellcheck -f gcc -e SC2006 build.sh build_matrix.sh build_common.sh
diff --git a/README.md b/README.md
index 1e3a245b..d89e3bb6 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,13 @@
-LIBPCAP 1.x.y
-=============
+# LIBPCAP 1.x.y by [The Tcpdump Group](https://www.tcpdump.org)
-[![Build Status](https://travis-ci.org/the-tcpdump-group/tcpdump.svg?branch=master)](https://travis-ci.org/the-tcpdump-group/libpcap)
-
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/the-tcpdump-group/tcpdump?branch=master&svg=true)](https://ci.appveyor.com/project/guyharris/libpcap)
-
-Now maintained by "The Tcpdump Group"
-
- https://www.tcpdump.org
-
-formerly from Lawrence Berkeley National Laboratory
- Network Research Group <libpcap@ee.lbl.gov>
- ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
-
-To report a security issue please send an e-mail to security@tcpdump.org.
+**To report a security issue please send an e-mail to security@tcpdump.org.**
To report bugs and other problems, contribute patches, request a
-feature, provide generic feedback etc please see the file
-[CONTRIBUTING.md](CONTRIBUTING.md) in the libpcap source tree root.
+feature, provide generic feedback etc please see the
+[guidelines for contributing](CONTRIBUTING.md).
-The directory doc/ has README files about specific operating systems and
-options.
+The [documentation directory](doc/) has README files about specific
+operating systems and options.
Anonymous Git is available via:
@@ -36,7 +23,14 @@ require this functionality, we've created this system-independent API
to ease in porting and to alleviate the need for several
system-dependent packet capture modules in each application.
-For some platforms there are README.{system} files that discuss issues
+```text
+formerly from Lawrence Berkeley National Laboratory
+ Network Research Group <libpcap@ee.lbl.gov>
+ ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
+```
+
+### Support for particular platforms and BPF
+For some platforms there are `README.{system}` files that discuss issues
with the OS's interface for packet capture on those platforms, such as
how to enable support for that interface in the OS, if it's not built in
by default.
@@ -44,18 +38,10 @@ by default.
The libpcap interface supports a filtering mechanism based on the
architecture in the BSD packet filter. BPF is described in the 1993
Winter Usenix paper ``The BSD Packet Filter: A New Architecture for
-User-level Packet Capture''. A compressed PostScript version can be
-found at
-
- https://www.tcpdump.org/papers/bpf-usenix93.ps.Z
-
-and a gzipped version can be found at
-
- https://www.tcpdump.org/papers/bpf-usenix93.ps.gz
-
-A PDF version can be found at
-
- https://www.tcpdump.org/papers/bpf-usenix93.pdf
+User-level Packet Capture''
+([compressed PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.Z),
+[gzipped PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.gz),
+[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.
@@ -70,22 +56,21 @@ 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:
-
- https://www.tcpdump.org/other/bpfext42.tar.Z
+kernel source and/or object patches available
+[here](https://www.tcpdump.org/other/bpfext42.tar.Z).
Linux has a number of BPF based systems, and libpcap does not support
any of the eBPF mechanisms as yet, although it supports many of the
memory mapped receive mechanisms.
-See the [README.linux](doc/README.linux.md) file for more information.
+See the [Linux-specific README](doc/README.linux) for more information.
-Note to Linux distributions and *BSD systems that include libpcap:
+### Note to Linux distributions and *BSD systems that include libpcap:
There's now a rule to make a shared library, which should work on Linux
and *BSD, among other platforms.
-It sets the soname of the library to "libpcap.so.1"; this is what it
-should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as
+It sets the soname of the library to `libpcap.so.1`; this is what it
+should be, **NOT** `libpcap.so.1.x` or `libpcap.so.1.x.y` or something such as
that.
We've been maintaining binary compatibility between libpcap releases for
diff --git a/TODO b/TODO
index aae24c22..65e166b6 100644
--- a/TODO
+++ b/TODO
@@ -31,5 +31,3 @@ Less urgent items
+ too many functions. There are a lot of functions for everything which
violates the KISS principle. Why do we need pcap_strerror, pcap_perror
and pcap_geterr?
- + the manpage has a brief description of each function but where is the
- big picture? Seems like you need to buy UNP for that...
diff --git a/VERSION b/VERSION
index d2d169e2..30da3206 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.10.0-PRE-GIT
+1.11.0-PRE-GIT
diff --git a/Win32/Prj/wpcap.sln b/Win32/Prj/wpcap.sln
deleted file mode 100644
index 5a9fce98..00000000
--- a/Win32/Prj/wpcap.sln
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.40629.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap", "wpcap.vcxproj", "{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.ActiveCfg = Debug|Win32
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.Build.0 = Debug|Win32
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.ActiveCfg = Debug|x64
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.Build.0 = Debug|x64
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.ActiveCfg = Release|Win32
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.Build.0 = Release|Win32
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.ActiveCfg = Release|x64
- {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Win32/Prj/wpcap.vcxproj b/Win32/Prj/wpcap.vcxproj
deleted file mode 100644
index 43b7099b..00000000
--- a/Win32/Prj/wpcap.vcxproj
+++ /dev/null
@@ -1,233 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <SccProjectName />
- <SccLocalPath />
- <ProjectGuid>{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}</ProjectGuid>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
- <UseOfMfc>false</UseOfMfc>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
- <UseOfMfc>false</UseOfMfc>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
- <UseOfMfc>false</UseOfMfc>
- <CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <PlatformToolset>v120</PlatformToolset>
- <UseOfMfc>false</UseOfMfc>
- <CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <OutDir>.\Release\</OutDir>
- <IntDir>.\Release\</IntDir>
- <LinkIncremental>false</LinkIncremental>
- <IncludePath>../../../;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <IncludePath>../../../;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <OutDir>.\Debug\</OutDir>
- <IntDir>.\Debug\</IntDir>
- <LinkIncremental>true</LinkIncremental>
- <IncludePath>../../../;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- <IncludePath>../../../;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <InlineFunctionExpansion>Default</InlineFunctionExpansion>
- <StringPooling>true</StringPooling>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <Optimization>MaxSpeed</Optimization>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <WarningLevel>Level3</WarningLevel>
- <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <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)</PreprocessorDefinitions>
- </ClCompile>
- <ResourceCompile>
- <Culture>0x0409</Culture>
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <PreBuildEvent>
- <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
-win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
-win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <InlineFunctionExpansion>Default</InlineFunctionExpansion>
- <StringPooling>true</StringPooling>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <Optimization>MaxSpeed</Optimization>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <WarningLevel>Level3</WarningLevel>
- <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <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)</PreprocessorDefinitions>
- </ClCompile>
- <ResourceCompile>
- <Culture>0x0409</Culture>
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <PreBuildEvent>
- <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
-win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
-win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <InlineFunctionExpansion>Default</InlineFunctionExpansion>
- <FunctionLevelLinking>false</FunctionLevelLinking>
- <Optimization>Disabled</Optimization>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <WarningLevel>Level3</WarningLevel>
- <MinimalRebuild>true</MinimalRebuild>
- <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <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)</PreprocessorDefinitions>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- </ClCompile>
- <ResourceCompile>
- <Culture>0x0409</Culture>
- <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <PreBuildEvent>
- <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
-win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
-win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <InlineFunctionExpansion>Default</InlineFunctionExpansion>
- <FunctionLevelLinking>false</FunctionLevelLinking>
- <Optimization>Disabled</Optimization>
- <SuppressStartupBanner>true</SuppressStartupBanner>
- <WarningLevel>Level3</WarningLevel>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <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)</PreprocessorDefinitions>
- <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
- </ClCompile>
- <ResourceCompile>
- <Culture>0x0409</Culture>
- <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ResourceCompile>
- <Link>
- <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <PreBuildEvent>
- <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h
-win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l
-win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command>
- </PreBuildEvent>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\bpf\net\bpf_filter.c" />
- <ClCompile Include="..\..\bpf_dump.c" />
- <ClCompile Include="..\..\bpf_image.c" />
- <ClCompile Include="..\..\etherent.c" />
- <ClCompile Include="..\..\gencode.c" />
- <ClCompile Include="..\..\grammar.c" />
- <ClCompile Include="..\..\inet.c" />
- <ClCompile Include="..\..\missing\win_snprintf.c" />
- <ClCompile Include="..\..\nametoaddr.c" />
- <ClCompile Include="..\..\optimize.c" />
- <ClCompile Include="..\..\pcap-common.c" />
- <ClCompile Include="..\..\pcap-new.c" />
- <ClCompile Include="..\..\pcap-rpcap.c" />
- <ClCompile Include="..\..\pcap-win32.c" />
- <ClCompile Include="..\..\pcap.c" />
- <ClCompile Include="..\..\savefile.c" />
- <ClCompile Include="..\..\scanner.c" />
- <ClCompile Include="..\..\sf-pcapng.c" />
- <ClCompile Include="..\..\sf-pcap.c" />
- <ClCompile Include="..\..\sockutils.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\pcap-common.h" />
- <ClInclude Include="..\..\pcap-int.h" />
- <ClInclude Include="..\..\pcap-rpcap.h" />
- <ClInclude Include="..\..\pcap-stdinc.h" />
- <ClInclude Include="..\..\pcap.h" />
- <ClInclude Include="..\..\remote-ext.h" />
- <ClInclude Include="..\..\sockutils.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="..\..\..\Win32-Extensions\version.rc" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/Win32/Prj/wpcap.vcxproj.filters b/Win32/Prj/wpcap.vcxproj.filters
deleted file mode 100644
index 879bb059..00000000
--- a/Win32/Prj/wpcap.vcxproj.filters
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <ClCompile Include="..\..\bpf_dump.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\bpf\net\bpf_filter.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\bpf_image.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\etherent.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\gencode.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\grammar.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\inet.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\nametoaddr.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\optimize.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\pcap.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\pcap-win32.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\savefile.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\scanner.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\sf-pcap.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\sf-pcapng.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\pcap-common.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\fad-helpers.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\missing\win_snprintf.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\pcap-new.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\pcap-rpcap.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\sockutils.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <Filter Include="Header Files">
- <UniqueIdentifier>{c51dce5e-0da9-4e33-a235-d5c76c76485c}</UniqueIdentifier>
- </Filter>
- <Filter Include="Source Files">
- <UniqueIdentifier>{5ec9fd4b-10b5-4527-b249-56b53d844fb1}</UniqueIdentifier>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{c90886f0-8973-436b-a7a1-b9e881544f9a}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\pcap-stdinc.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\pcap-common.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\pcap.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\pcap-int.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\pcap-rpcap.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\remote-ext.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\sockutils.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="..\..\..\Win32-Extensions\version.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project>
diff --git a/aclocal.m4 b/aclocal.m4
index 786423bf..7da6eace 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -232,36 +232,6 @@ AC_DEFUN(AC_LBL_C_INIT,
])
dnl
-dnl Check whether, if you pass an unknown warning option to the
-dnl compiler, it fails or just prints a warning message and succeeds.
-dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
-dnl to force an error if it would otherwise just print a warning message
-dnl and succeed.
-dnl
-AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
- [
- AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
- AC_TRY_COMPILE(
- [],
- [return 0],
- [
- AC_MSG_RESULT([no])
- #
- # We're assuming this is clang, where
- # -Werror=unknown-warning-option is the appropriate
- # option to force the compiler to fail.
- #
- ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
- ],
- [
- AC_MSG_RESULT([yes])
- ])
- CFLAGS="$save_CFLAGS"
- ])
-
-dnl
dnl Check whether the compiler option specified as the second argument
dnl is supported by the compiler and, if so, add it to the macro
dnl specified as the first argument
@@ -278,21 +248,35 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
[
AC_MSG_CHECKING([whether the compiler supports the $2 option])
save_CFLAGS="$CFLAGS"
- if expr "x$2" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
- elif expr "x$2" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror $2"
- elif expr "x$2" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror $2"
- else
- CFLAGS="$CFLAGS $2"
- fi
- AC_TRY_COMPILE(
- [],
- [return 0],
+ CFLAGS="$CFLAGS $2"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([[int main(void) { return 0; }]])],
[
AC_MSG_RESULT([yes])
can_add_to_cflags=yes
@@ -332,6 +316,7 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
AC_MSG_RESULT([no])
CFLAGS="$save_CFLAGS"
])
+ ac_c_werror_flag="$save_ac_c_werror_flag"
])
dnl
@@ -662,6 +647,46 @@ AC_DEFUN(AC_LBL_C_INLINE,
fi
AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
+#
+# Test whether we have __atomic_load_n() and __atomic_store_n().
+#
+# We use AC_TRY_LINK because AC_TRY_COMPILE will succeed, as the
+# compiler will just think that those functions are undefined,
+# and perhaps warn about that, but not fail to compile.
+#
+AC_DEFUN(AC_PCAP_C___ATOMICS,
+ [
+ AC_MSG_CHECKING(for __atomic_load_n)
+ AC_CACHE_VAL(ac_cv_have___atomic_load_n,
+ AC_TRY_LINK([],
+ [
+ int i = 17;
+ int j;
+ j = __atomic_load_n(&i, __ATOMIC_RELAXED);
+ ],
+ ac_have___atomic_load_n=yes,
+ ac_have___atomic_load_n=no))
+ AC_MSG_RESULT($ac_have___atomic_load_n)
+ if test $ac_have___atomic_load_n = yes ; then
+ AC_DEFINE(HAVE___ATOMIC_LOAD_N, 1,
+ [define if __atomic_load_n is supported by the compiler])
+ fi
+
+ AC_MSG_CHECKING(for __atomic_store_n)
+ AC_CACHE_VAL(ac_cv_have___atomic_store_n,
+ AC_TRY_LINK([],
+ [
+ int i;
+ __atomic_store_n(&i, 17, __ATOMIC_RELAXED);
+ ],
+ ac_have___atomic_store_n=yes,
+ ac_have___atomic_store_n=no))
+ AC_MSG_RESULT($ac_have___atomic_store_n)
+ if test $ac_have___atomic_store_n = yes ; then
+ AC_DEFINE(HAVE___ATOMIC_STORE_N, 1,
+ [define if __atomic_store_n is supported by the compiler])
+ fi])
+
dnl
dnl If using gcc, make sure we have ANSI ioctl definitions
dnl
@@ -777,7 +802,6 @@ AC_DEFUN(AC_LBL_DEVEL,
# Skip all the warning option stuff on some compilers.
#
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
- AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
AC_LBL_CHECK_COMPILER_OPT($1, -W)
AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
@@ -1076,13 +1100,8 @@ dnl Since: 0.18
dnl
dnl Check to see whether a particular set of modules exists. Similar to
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
-dnl
-dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-dnl only at the first occurrence in configure.ac, so if the first place
-dnl it's called might be skipped (such as if it is within an "if", you
-dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+[
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
@@ -1111,7 +1130,7 @@ dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl ---------------------------
dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+[
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
@@ -1124,37 +1143,42 @@ dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl --------------------------------------------------------------
dnl Since: 0.4.0
-dnl
-dnl Note that if there is a possibility the first call to
-dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
-dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
-AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+[
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl
pkg_failed=no
-AC_MSG_CHECKING([for $1])
-
-_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
-_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+AC_MSG_CHECKING([for $2 with pkg-config])
+PKG_CHECK_EXISTS($2,
+ [
+ #
+ # The package was found, so try to get its C flags and
+ # libraries.
+ #
+ _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+ _PKG_CONFIG([$1][_LIBS], [libs], [$2])
-m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+ m4_define([_PKG_TEXT], [
+Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
-if test $pkg_failed = yes; then
- AC_MSG_RESULT([no])
- _PKG_SHORT_ERRORS_SUPPORTED
- if test $_pkg_short_errors_supported = yes; then
- $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
- else
- $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
- fi
- # Put the nasty error message in config.log where it belongs
- echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
-
- m4_default([$4], [AC_MSG_ERROR(
+ if test $pkg_failed = yes; then
+ #
+ # That failed - report an error.
+ #
+ AC_MSG_RESULT([error])
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
@@ -1164,23 +1188,27 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
-elif test $pkg_failed = untried; then
- AC_MSG_RESULT([no])
- m4_default([$4], [AC_MSG_FAILURE(
-[The pkg-config script could not be found or is too old. Make sure it
-is in your PATH or set the PKG_CONFIG environment variable to the full
-path to pkg-config.
-
-_PKG_TEXT
-
-To get pkg-config, see <https://pkg-config.freedesktop.org/>.])[]dnl
- ])
-else
- $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
- $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
- AC_MSG_RESULT([yes])
- $3
-fi[]dnl
+ elif test $pkg_failed = untried; then
+ #
+ # We don't have pkg-config, so it didn't work.
+ #
+ AC_MSG_RESULT([not found (pkg-config not found)])
+ else
+ #
+ # We found the package.
+ #
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([found])
+ $3
+ fi[]dnl
+ ],
+ [
+ #
+ # The package isn't present.
+ #
+ AC_MSG_RESULT([not found])
+ ])
])dnl PKG_CHECK_MODULES
@@ -1192,13 +1220,8 @@ dnl
dnl Checks for existence of MODULES and gathers its build flags with
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
dnl and VARIABLE-PREFIX_LIBS from --libs.
-dnl
-dnl Note that if there is a possibility the first call to
-dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
-dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
-dnl configure.ac.
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+[
_save_PKG_CONFIG=$PKG_CONFIG
PKG_CONFIG="$PKG_CONFIG --static"
PKG_CHECK_MODULES($@)
@@ -1257,7 +1280,7 @@ dnl Since: 0.28
dnl
dnl Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+[
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
@@ -1265,4 +1288,3 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR
-
diff --git a/bpf_filter.c b/bpf_filter.c
index 22d25587..8691d0d1 100644
--- a/bpf_filter.c
+++ b/bpf_filter.c
@@ -87,11 +87,11 @@ enum {
#if defined(SKF_AD_VLAN_TAG_PRESENT)
u_int
pcap_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)
+ u_int wirelen, u_int buflen, const struct pcap_bpf_aux_data *aux_data)
#else
u_int
pcap_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 _U_)
+ u_int wirelen, u_int buflen, const struct pcap_bpf_aux_data *aux_data _U_)
#endif
{
register uint32_t A, X;
diff --git a/build.sh b/build.sh
new file mode 100755
index 00000000..afcd3c84
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,118 @@
+#!/bin/sh -e
+
+# This script runs one build with setup environment variables: CC, CMAKE and
+# REMOTE.
+: "${CC:=gcc}"
+: "${CMAKE:=no}"
+: "${REMOTE:=no}"
+: "${LIBPCAP_TAINTED:=no}"
+: "${MAKE_BIN:=make}"
+
+. ./build_common.sh
+# Install directory prefix
+if [ -z "$PREFIX" ]; then
+ PREFIX=`mktempdir libpcap_build`
+ echo "PREFIX set to '$PREFIX'"
+ DELETE_PREFIX=yes
+fi
+
+print_cc_version
+
+# The norm is to compile without any warnings, but libpcap builds on some OSes
+# are not warning-free for one or another reason. If you manage to fix one of
+# these cases, please remember to remove respective exemption below to help any
+# later warnings in the same matrix subset trigger an error.
+# shellcheck disable=SC2221,SC2222
+case `cc_id`/`os_id` in
+gcc-*/Linux-*)
+ # This warning is a bit odd. It is steadily present in Cirrus CI, but not
+ # in Buildbot. On my Linux system with the same exact distribution and GCC
+ # as Cirrus CI it reproduces only if GCC receives the "-g" flag:
+ # make CFLAGS=-g -- does not reproduce
+ # CFLAGS=-g make -- reproduces
+ # make -- reproduces
+ #
+ # pcap-linux.c:947:8: warning: ignoring return value of 'write', declared
+ # with attribute warn_unused_result [-Wunused-result]
+ #
+ # And even this way it does not make GCC exit with an error when it has
+ # reported the warning and has received the "-Werror" flag. So let's keep
+ # this block no-op for now.
+ ;;
+clang-*/NetBSD-*)
+ # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision:
+ # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+ # [-Wshorten-64-to-32]
+ # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision:
+ # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+ # [-Wshorten-64-to-32]
+ # pcap-bpf.c:1274:39: warning: implicit conversion loses integer precision:
+ # 'long' to 'suseconds_t' (aka 'int') [-Wshorten-64-to-32]
+ LIBPCAP_TAINTED=yes
+ ;;
+clang-*/SunOS-5.11)
+ # (Solaris 11 and OpenIndiana)
+ # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision:
+ # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+ # [-Wshorten-64-to-32]
+ # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision:
+ # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+ # [-Wshorten-64-to-32]
+ # fad-getad.c:266:52: warning: implicit conversion loses integer precision:
+ # 'uint64_t'(aka 'unsigned long') to 'bpf_u_int32' (aka 'unsigned int')
+ # [-Wshorten-64-to-32]
+ # (Solaris 11)
+ # pcap-bpf.c:1843:22: warning: implicit conversion loses integer precision:
+ # 'long' to 'int' [-Wshorten-64-to-32]
+ # (OpenIndiana)
+ # rpcapd.c:393:18: warning: this function declaration is not a prototype
+ # [-Wstrict-prototypes]
+ [ "`uname -p`" = i386 ] && LIBPCAP_TAINTED=yes
+ ;;
+suncc-5.1[45]/SunOS-5.11)
+ # "scanner.l", line 257: warning: statement not reached
+ # (186 warnings for scanner.l)
+ #
+ # "./filtertest.c", line 259: warning: statement not reached
+ # "./filtertest.c", line 276: warning: statement not reached
+ # "./filtertest.c", line 281: warning: statement not reached
+ LIBPCAP_TAINTED=yes
+ ;;
+esac
+[ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
+
+if [ "$CMAKE" = no ]; then
+ run_after_echo ./configure --prefix="$PREFIX" --enable-remote="$REMOTE"
+else
+ # Remove the leftovers from any earlier in-source builds, so this
+ # out-of-source build does not break because of that.
+ # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#what-is-an-out-of-source-build
+ run_after_echo rm -rf CMakeFiles/ CMakeCache.txt
+ [ ! -d build ] && run_after_echo mkdir build
+ run_after_echo cd build
+ run_after_echo cmake ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
+ -DCMAKE_INSTALL_PREFIX="$PREFIX" -DENABLE_REMOTE="$REMOTE" ..
+fi
+run_after_echo "$MAKE_BIN" -s clean
+if [ "$CMAKE" = no ]; then
+ run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
+ run_after_echo "$MAKE_BIN" -s testprogs ${CFLAGS:+CFLAGS="$CFLAGS"}
+else
+ # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
+ run_after_echo "$MAKE_BIN"
+ run_after_echo "$MAKE_BIN" testprogs
+fi
+run_after_echo "$MAKE_BIN" install
+# VALGRIND_CMD is meant either to collapse or to expand.
+# shellcheck disable=SC2086
+if [ "$CMAKE" = no ]; then
+ run_after_echo $VALGRIND_CMD testprogs/findalldevstest
+ run_after_echo "$MAKE_BIN" releasetar
+else
+ run_after_echo $VALGRIND_CMD run/findalldevstest
+fi
+handle_matrix_debug
+if [ "$DELETE_PREFIX" = yes ]; then
+ run_after_echo rm -rf "$PREFIX"
+fi
+# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
diff --git a/build_common.sh b/build_common.sh
new file mode 100644
index 00000000..f65e6209
--- /dev/null
+++ b/build_common.sh
@@ -0,0 +1,280 @@
+#!/bin/sh -e
+
+# The only purpose of the above shebang is to orient shellcheck right.
+# To make CI scripts maintenance simpler, copies of this file in the
+# libpcap, tcpdump and tcpslice git repositories should be identical.
+# Please mind that Solaris /bin/sh before 11 does not support the $()
+# command substitution syntax, hence the "-e SC2006" flag in Makefile.
+
+# A poor man's mktemp(1) for OSes that don't have one (e.g. AIX 7, Solaris 9).
+mktempdir_diy() {
+ while true; do
+ # /bin/sh implements $RANDOM in AIX 7, but not in Solaris before 11,
+ # thus use dd and od instead.
+ mktempdir_diy_suffix=`dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -t x -A n | head -1 | tr -d '\t '`
+ [ -z "$mktempdir_diy_suffix" ] && return 1
+ mktempdir_diy_path="${TMPDIR:-/tmp}/${1:?}.${mktempdir_diy_suffix}"
+ # "test -e" would be more appropriate, but it is not available in
+ # Solaris /bin/sh before 11.
+ if [ ! -d "$mktempdir_diy_path" ]; then
+ mkdir "$mktempdir_diy_path"
+ chmod go= "$mktempdir_diy_path"
+ echo "$mktempdir_diy_path"
+ break
+ fi
+ # Try again (very unlikely, just in case).
+ done
+}
+
+mktempdir() {
+ mktempdir_prefix=${1:-tmp}
+ case `os_id` in
+ Darwin-*|FreeBSD-*|NetBSD-*)
+ # In these operating systems mktemp(1) always appends an implicit
+ # ".XXXXXXXX" suffix to the requested template when creating a
+ # temporary directory.
+ mktemp -d -t "$mktempdir_prefix"
+ ;;
+ SunOS-5.10|SunOS-5.11)
+ # Although the suffix is optional, specify it for consistent results.
+ mktemp -d -t "${mktempdir_prefix}.XXXXXXXX"
+ ;;
+ SunOS-*|AIX-*)
+ mktempdir_diy "$mktempdir_prefix"
+ ;;
+ *)
+ # At least Linux and OpenBSD implementations require explicit trailing
+ # X'es in the template, so make it the same suffix as above.
+ mktemp -d -t "${mktempdir_prefix}.XXXXXXXX"
+ ;;
+ esac
+}
+
+print_sysinfo() {
+ uname -a
+ printf 'OS identification: '
+ os_id
+ date
+}
+
+# Try to make the current C compiler print its version information (usually
+# multi-line) to stdout.
+cc_version_nocache() {
+ : "${CC:?}"
+ case `basename "$CC"` in
+ gcc*|egcc*|clang*)
+ # GCC and Clang recognize --version, print to stdout and exit with 0.
+ "$CC" --version
+ ;;
+ xl*)
+ # XL C 12.1 and 13.1 recognize "-qversion", print to stdout and exit
+ # with 0. XL C 12.1 on an unknown command-line flag displays its man
+ # page and waits.
+ # XL C 16.1 recognizes "-qversion" and "--version", prints to stdout
+ # and exits with 0. Community Edition also prints a banner to stderr.
+ "$CC" -qversion 2>/dev/null
+ ;;
+ sun*)
+ # Sun compilers recognize -V, print to stderr and exit with an error.
+ "$CC" -V 2>&1 || :
+ ;;
+ cc)
+ case `os_id` in
+ SunOS-*)
+ # Most likely Sun C.
+ "$CC" -V 2>&1 || :
+ ;;
+ Darwin-*)
+ # Most likely Clang.
+ "$CC" --version
+ ;;
+ Linux-*|FreeBSD-*|NetBSD-*|OpenBSD-*)
+ # Most likely Clang or GCC.
+ "$CC" --version
+ ;;
+ esac
+ ;;
+ *)
+ "$CC" --version || "$CC" -V || :
+ ;;
+ esac
+}
+
+cc_version() {
+ echo "${cc_version_cached:=`cc_version_nocache`}"
+}
+
+print_cc_version() {
+ cc_version
+ printf 'Compiler identification: '
+ cc_id
+}
+
+# For the current C compiler try to print a short and uniform identification
+# string (such as "gcc-9.3.0") that is convenient to use in a case statement.
+cc_id_nocache() {
+ cc_id_firstline=`cc_version | head -1`
+ : "${cc_id_firstline:?}"
+
+ cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^.*clang version \([0-9\.]*\).*$/clang-\1/'`
+ if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+ echo "$cc_id_guessed"
+ return
+ fi
+
+ cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^IBM XL C.*, V\([0-9\.]*\).*$/xlc-\1/'`
+ if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+ echo "$cc_id_guessed"
+ return
+ fi
+
+ cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^.* Sun C \([0-9\.]*\) .*$/suncc-\1/'`
+ if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+ echo "$cc_id_guessed"
+ return
+ fi
+
+ # OpenBSD default GCC:
+ # "gcc (GCC) 4.2.1 20070719"
+ # RedHat GCC:
+ # "gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2)"
+ # "gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1)"
+ # other GCC packages:
+ # "sparc-sun-solaris2.9-gcc (GCC) 4.2.0 (gccfss)"
+ # "gcc (GCC) 5.5.0"
+ # "gcc (nb4 20200810) 7.5.0"
+ # "gcc (OpenIndiana 7.5.0-il-0) 7.5.0"
+ # "gcc (Debian 8.3.0-6) 8.3.0"
+ # "gcc (Raspbian 8.3.0-6+rpi1) 8.3.0"
+ # "egcc (GCC) 8.4.0"
+ # "gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0"
+ # "gcc (FreeBSD Ports Collection) 10.3.0"
+ cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^.* (.*) \([0-9\.]*\).*$/gcc-\1/'`
+ if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+ echo "$cc_id_guessed"
+ return
+ fi
+}
+
+cc_id() {
+ echo "${cc_id_cached:=`cc_id_nocache`}"
+}
+
+# Call this function each time CC has changed.
+discard_cc_cache() {
+ cc_version_cached=
+ cc_id_cached=
+}
+
+# For the current C compiler try to print CFLAGS value that tells to treat
+# warnings as errors.
+cc_werr_cflags() {
+ case `cc_id` in
+ gcc-*|clang-*)
+ echo '-Werror'
+ ;;
+ xlc-*)
+ # XL C 12.1 and 13.1 recognize "-qhalt=w". XL C 16.1 recognizes that
+ # and "-Werror".
+ echo '-qhalt=w'
+ ;;
+ suncc-*)
+ echo '-errwarn=%all'
+ ;;
+ esac
+}
+
+# Tell whether "gcc" is a symlink to Clang (this is the case on macOS).
+gcc_is_clang_in_disguise() {
+ case `cc_id`/`basename "${CC:?}"` in
+ clang-*/gcc)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
+os_id() {
+ # OS does not change between builds or in the middle of a build, so it is
+ # fine to cache uname output.
+ : "${os_id_sysname:=`uname -s`}"
+ printf '%s-' "$os_id_sysname"
+ : "${os_id_release:=`uname -r`}"
+ case "$os_id_sysname" in
+ AIX)
+ : "${os_id_version:=`uname -v`}"
+ echo "${os_id_version}.${os_id_release}"
+ ;;
+ Darwin|NetBSD|OpenBSD|SunOS)
+ echo "$os_id_release"
+ ;;
+ FreeBSD|Linux)
+ # Meaningful version is usually the substring before the first dash.
+ echo "$os_id_release" | sed 's/^\([0-9\.]*\).*$/\1/'
+ ;;
+ *)
+ echo 'UNKNOWN'
+ ;;
+ esac
+}
+
+increment() {
+ # No arithmetic expansion in Solaris /bin/sh before 11.
+ echo "${1:?} + 1" | bc
+}
+
+# Display text in magenta.
+echo_magenta() {
+ # ANSI magenta, the imploded text, ANSI reset, newline.
+ printf '\033[35;1m%s\033[0m\n' "$*"
+}
+
+# Run a command after displaying it.
+run_after_echo() {
+ : "${1:?}" # Require at least one argument.
+ printf '$ %s\n' "$*"
+ "$@"
+}
+
+print_so_deps() {
+ case `os_id` in
+ Darwin-*)
+ run_after_echo otool -L "${1:?}"
+ ;;
+ *)
+ run_after_echo ldd "${1:?}"
+ ;;
+ esac
+}
+
+# Beware that setting MATRIX_DEBUG for tcpdump or tcpslice will produce A LOT
+# of additional output there and in any nested libpcap builds. Multiplied by
+# the matrix size, the full output log size might exceed limits of some CI
+# systems (as it had previously happened with Travis CI). Use with caution on
+# a reduced matrix.
+handle_matrix_debug() {
+ [ "$MATRIX_DEBUG" != yes ] && return
+ echo '$ cat Makefile [...]'
+ sed '/^# DO NOT DELETE THIS LINE -- mkdep uses it.$/q' <Makefile
+ run_after_echo cat config.h
+ [ "$CMAKE" = yes ] || run_after_echo cat config.log
+}
+
+purge_directory() {
+ if [ "`os_id`" = SunOS-5.11 ]; then
+ # In Solaris 11 /bin/sh the pathname expansion of "*" always includes
+ # "." and "..", so the straightforward rm would always fail.
+ (
+ cd "${1:?}"
+ for pd_each in *; do
+ if [ "$pd_each" != . ] && [ "$pd_each" != .. ]; then
+ rm -rf "$pd_each"
+ fi
+ done
+ )
+ else
+ rm -rf "${1:?}"/*
+ fi
+}
+
+# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
diff --git a/build_matrix.sh b/build_matrix.sh
new file mode 100755
index 00000000..60065966
--- /dev/null
+++ b/build_matrix.sh
@@ -0,0 +1,63 @@
+#!/bin/sh -e
+
+# This script executes the matrix loops, exclude tests and cleaning.
+# The matrix can be configured with the following environment variables: MATRIX_CC,
+# MATRIX_CMAKE and MATRIX_REMOTE.
+: "${MATRIX_CC:=gcc clang}"
+: "${MATRIX_CMAKE:=no yes}"
+: "${MATRIX_REMOTE:=no yes}"
+# Set this variable to "yes" before calling this script to disregard all
+# warnings in a particular environment (CI or a local working copy). Set it
+# to "yes" in this script or in build.sh when a matrix subset is known to be
+# not warning-free because of the OS, the compiler or whatever other factor
+# that the scripts can detect both in and out of CI.
+: "${LIBPCAP_TAINTED:=no}"
+# Some OSes have native make without parallel jobs support and sometimes have
+# GNU Make available as "gmake".
+: "${MAKE_BIN:=make}"
+# It calls the build.sh script which runs one build with setup environment
+# variables: CC, CMAKE and REMOTE.
+
+. ./build_common.sh
+print_sysinfo
+# Install directory prefix
+if [ -z "$PREFIX" ]; then
+ PREFIX=`mktempdir libpcap_build_matrix`
+ echo "PREFIX set to '$PREFIX'"
+ export PREFIX
+fi
+COUNT=0
+export LIBPCAP_TAINTED
+if command -v valgrind >/dev/null 2>&1; then
+ VALGRIND_CMD="valgrind --leak-check=full --error-exitcode=1"
+ export VALGRIND_CMD
+fi
+
+touch .devel configure
+for CC in $MATRIX_CC; do
+ export CC
+ discard_cc_cache
+ if gcc_is_clang_in_disguise; then
+ echo '(skipped)'
+ continue
+ fi
+ for CMAKE in $MATRIX_CMAKE; do
+ export CMAKE
+ for REMOTE in $MATRIX_REMOTE; do
+ export REMOTE
+ COUNT=`increment $COUNT`
+ echo_magenta "===== SETUP $COUNT: CC=$CC CMAKE=$CMAKE REMOTE=$REMOTE =====" >&2
+ # Run one build with setup environment variables: CC, CMAKE and REMOTE
+ run_after_echo ./build.sh
+ echo 'Cleaning...'
+ if [ "$CMAKE" = yes ]; then rm -rf build; else "$MAKE_BIN" distclean; fi
+ purge_directory "$PREFIX"
+ run_after_echo git status -suall
+ # Cancel changes in configure
+ run_after_echo git checkout configure
+ done
+ done
+done
+run_after_echo rm -rf "$PREFIX"
+echo_magenta "Tested setup count: $COUNT" >&2
+# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
diff --git a/charconv.c b/charconv.c
index 4ede5720..5f97509a 100644
--- a/charconv.c
+++ b/charconv.c
@@ -34,6 +34,7 @@
#ifdef _WIN32
#include <stdio.h>
+#include <errno.h>
#include <pcap/pcap.h> /* Needed for PCAP_ERRBUF_SIZE */
diff --git a/charconv.h b/charconv.h
index a37d424b..93103d46 100644
--- a/charconv.h
+++ b/charconv.h
@@ -32,8 +32,8 @@
* SUCH DAMAGE.
*/
-#ifndef charonv_h
-#define charonv_h
+#ifndef charconv_h
+#define charconv_h
#ifdef _WIN32
extern wchar_t *cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags);
@@ -41,4 +41,4 @@ extern char *utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string);
extern void utf_8_to_acp_truncated(char *);
#endif
-#endif
+#endif /* charconv_h */
diff --git a/cmake/Modules/FindAirPcap.cmake b/cmake/Modules/FindAirPcap.cmake
index 8198f70f..56c71b7b 100644
--- a/cmake/Modules/FindAirPcap.cmake
+++ b/cmake/Modules/FindAirPcap.cmake
@@ -6,14 +6,14 @@
#
# This module defines the following variables:
#
-# AIRPCAP_INCLUDE_DIR - absolute path to the directory containing airpcap.h.
+# AirPcap_INCLUDE_DIR - absolute path to the directory containing airpcap.h.
#
-# AIRPCAP_LIBRARY - relative or absolute path to the AirPcap library to
+# AirPcap_LIBRARY - relative or absolute path to the AirPcap library to
# link with. An absolute path is will be used if the
# AirPcap library is not located in the compiler's
# default search path.
-# AIRPCAP_FOUND - TRUE if the AirPcap library *and* header are found.
+# AirPcap_FOUND - TRUE if the AirPcap library *and* header are found.
#
# Hints and Backward Compatibility
# ================================
@@ -46,24 +46,24 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
endif()
# Find the header
-find_path(AIRPCAP_INCLUDE_DIR airpcap.h
+find_path(AirPcap_INCLUDE_DIR airpcap.h
PATH_SUFFIXES include
)
# Find the library
-find_library(AIRPCAP_LIBRARY
+find_library(AirPcap_LIBRARY
NAMES airpcap
)
-# Set AIRPCAP_FOUND to TRUE if AIRPCAP_INCLUDE_DIR and AIRPCAP_LIBRARY are TRUE.
+# Set AirPcap_FOUND to TRUE if AirPcap_INCLUDE_DIR and AirPcap_LIBRARY are TRUE.
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(AIRPCAP
+find_package_handle_standard_args(AirPcap
DEFAULT_MSG
- AIRPCAP_INCLUDE_DIR
- AIRPCAP_LIBRARY
+ AirPcap_INCLUDE_DIR
+ AirPcap_LIBRARY
)
-mark_as_advanced(AIRPCAP_INCLUDE_DIR AIRPCAP_LIBRARY)
+mark_as_advanced(AirPcap_INCLUDE_DIR AirPcap_LIBRARY)
-set(AIRPCAP_INCLUDE_DIRS ${AIRPCAP_INCLUDE_DIR})
-set(AIRPCAP_LIBRARIES ${AIRPCAP_LIBRARY})
+set(AirPcap_INCLUDE_DIRS ${AirPcap_INCLUDE_DIR})
+set(AirPcap_LIBRARIES ${AirPcap_LIBRARY})
diff --git a/cmake/Modules/FindPacket.cmake b/cmake/Modules/FindPacket.cmake
index 900c8e3f..8224cd3f 100644
--- a/cmake/Modules/FindPacket.cmake
+++ b/cmake/Modules/FindPacket.cmake
@@ -28,14 +28,14 @@
#
# This module defines the following variables:
#
-# PACKET_INCLUDE_DIR - absolute path to the directory containing Packet32.h.
+# Packet_INCLUDE_DIR - absolute path to the directory containing Packet32.h.
#
-# PACKET_LIBRARY - relative or absolute path to the Packet library to
+# Packet_LIBRARY - relative or absolute path to the Packet library to
# link with. An absolute path is will be used if the
# Packet library is not located in the compiler's
# default search path.
-# PACKET_FOUND - TRUE if the Packet library *and* header are found.
+# Packet_FOUND - TRUE if the Packet library *and* header are found.
#
# Hints and Backward Compatibility
# ================================
@@ -63,29 +63,47 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE
# inherits the correct value.
#
- set(CMAKE_C_LIBRARY_ARCHITECTURE "x64")
- set(CMAKE_LIBRARY_ARCHITECTURE "x64")
+ set(archdetect_c_code "
+ #ifndef _M_ARM64
+ #error Not ARM64
+ #endif
+ int main() { return 0; }
+ ")
+
+ file(WRITE "${CMAKE_BINARY_DIR}/archdetect.c" "${archdetect_c_code}")
+ try_compile(
+ IsArm64
+ "${CMAKE_BINARY_DIR}/archdetect"
+ "${CMAKE_BINARY_DIR}/archdetect.c"
+ )
+ if(IsArm64)
+ set(CMAKE_C_LIBRARY_ARCHITECTURE "ARM64")
+ set(CMAKE_LIBRARY_ARCHITECTURE "ARM64")
+ else()
+ set(CMAKE_C_LIBRARY_ARCHITECTURE "x64")
+ set(CMAKE_LIBRARY_ARCHITECTURE "x64")
+ endif()
endif()
# Find the header
-find_path(PACKET_INCLUDE_DIR Packet32.h
+find_path(Packet_INCLUDE_DIR Packet32.h
PATH_SUFFIXES include Include
)
# Find the library
-find_library(PACKET_LIBRARY
+find_library(Packet_LIBRARY
NAMES Packet packet
)
-# Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE.
+# Set Packet_FOUND to TRUE if Packet_INCLUDE_DIR and Packet_LIBRARY are TRUE.
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(PACKET
+find_package_handle_standard_args(Packet
DEFAULT_MSG
- PACKET_INCLUDE_DIR
- PACKET_LIBRARY
+ Packet_INCLUDE_DIR
+ Packet_LIBRARY
)
-mark_as_advanced(PACKET_INCLUDE_DIR PACKET_LIBRARY)
+mark_as_advanced(Packet_INCLUDE_DIR Packet_LIBRARY)
-set(PACKET_INCLUDE_DIRS ${PACKET_INCLUDE_DIR})
-set(PACKET_LIBRARIES ${PACKET_LIBRARY})
+set(Packet_INCLUDE_DIRS ${Packet_INCLUDE_DIR})
+set(Packet_LIBRARIES ${Packet_LIBRARY})
diff --git a/cmake/Modules/Finddpdk.cmake b/cmake/Modules/Finddpdk.cmake
index 50eafd90..c51b1f32 100644
--- a/cmake/Modules/Finddpdk.cmake
+++ b/cmake/Modules/Finddpdk.cmake
@@ -21,13 +21,13 @@ if(NOT dpdk_INCLUDE_DIRS)
)
find_path(dpdk_common_INCLUDE_DIR rte_common.h
HINTS
- ENC DPDK_DIR
+ ENV DPDK_DIR
PATH_SUFFIXES
dpdk
include
)
set(dpdk_INCLUDE_DIRS "${dpdk_config_INCLUDE_DIR}")
- if(NOT dpdk_config_INCLUDE_DIR EQUAL dpdk_common_INCLUDE_DIR)
+ if(NOT dpdk_config_INCLUDE_DIR STREQUAL dpdk_common_INCLUDE_DIR)
list(APPEND dpdk_INCLUDE_DIRS "${dpdk_common_INCLUDE_DIR}")
endif()
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 192209cb..1dc2491f 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -117,9 +117,6 @@
/* Define to 1 if you have the <net/pfilt.h> header file. */
#cmakedefine HAVE_NET_PFILT_H 1
-/* Define to 1 if you have the <net/pfvar.h> header file. */
-#cmakedefine HAVE_NET_PFVAR_H 1
-
/* Define to 1 if you have the <net/raw.h> header file. */
#cmakedefine HAVE_NET_RAW_H 1
@@ -138,9 +135,6 @@
/* Define to 1 if you have a POSIX-style `strerror_r' function. */
#cmakedefine HAVE_POSIX_STRERROR_R 1
-/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
-#cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1
-
/* define if you have the Septel API */
#cmakedefine HAVE_SEPTEL_API 1
@@ -259,6 +253,12 @@
/* Define to 1 if you have the `_wcserror_s' function. */
#cmakedefine HAVE__WCSERROR_S 1
+/* define if __atomic_load_n is supported by the compiler */
+#cmakedefine HAVE___ATOMIC_LOAD_N 1
+
+/* define if __atomic_store_n is supported by the compiler */
+#cmakedefine HAVE___ATOMIC_STORE_N 1
+
/* Define to 1 if you have the `PacketGetTimestampModes' function. */
#cmakedefine HAVE_PACKET_GET_TIMESTAMP_MODES 1
diff --git a/config.guess b/config.guess
index 2b79f6d8..7f76b622 100755
--- a/config.guess
+++ b/config.guess
@@ -1,12 +1,14 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2018 Free Software Foundation, Inc.
+# Copyright 1992-2022 Free Software Foundation, Inc.
-timestamp='2018-07-06'
+# shellcheck disable=SC2006,SC2268 # see below for rationale
+
+timestamp='2022-01-09'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -27,11 +29,19 @@ timestamp='2018-07-06'
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
-# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
#
# Please send patches to <config-patches@gnu.org>.
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX. However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
+
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
@@ -50,7 +60,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -84,7 +94,8 @@ if test $# != 0; then
exit 1
fi
-trap 'exit 1' 1 2 15
+# Just in case it came from the environment.
+GUESS=
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
@@ -96,73 +107,90 @@ trap 'exit 1' 1 2 15
# Portable tmp directory creation inspired by the Autoconf team.
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp 2>/dev/null) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
- ,,) echo "int x;" > "$dummy.c" ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
+tmp=
+# shellcheck disable=SC2172
+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
+
+set_cc_for_build() {
+ # prevent multiple calls if $tmp is already set
+ test "$tmp" && return 0
+ : "${TMPDIR=/tmp}"
+ # shellcheck disable=SC2039,SC3028
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
+ dummy=$tmp/dummy
+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
+ ,,) echo "int x;" > "$dummy.c"
+ for driver in cc gcc c89 c99 ; do
+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
+ CC_FOR_BUILD=$driver
+ break
+ fi
+ done
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+ esac
+}
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+if test -f /.attbin/uname ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-case "$UNAME_SYSTEM" in
+case $UNAME_SYSTEM in
Linux|GNU|GNU/*)
- # If the system lacks a compiler, then just pick glibc.
- # We could probably try harder.
- LIBC=gnu
+ LIBC=unknown
- eval "$set_cc_for_build"
+ set_cc_for_build
cat <<-EOF > "$dummy.c"
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
- #else
+ #elif defined(__GLIBC__)
LIBC=gnu
+ #else
+ #include <stdarg.h>
+ /* First heuristic to detect musl libc. */
+ #ifdef __DEFINED_va_list
+ LIBC=musl
+ #endif
#endif
EOF
- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+ cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ eval "$cc_set_libc"
- # If ldd exists, use it to detect musl libc.
- if command -v ldd >/dev/null && \
- ldd --version 2>&1 | grep -q ^musl
- then
- LIBC=musl
+ # Second heuristic to detect musl libc.
+ if [ "$LIBC" = unknown ] &&
+ command -v ldd >/dev/null &&
+ ldd --version 2>&1 | grep -q ^musl; then
+ LIBC=musl
+ fi
+
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ if [ "$LIBC" = unknown ]; then
+ LIBC=gnu
fi
;;
esac
# Note: order is significant - the case branches are not exclusive.
-case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
+case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
@@ -174,12 +202,12 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
- "/sbin/$sysctl" 2>/dev/null || \
- "/usr/sbin/$sysctl" 2>/dev/null || \
+ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
+ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
echo unknown)`
- case "$UNAME_MACHINE_ARCH" in
+ case $UNAME_MACHINE_ARCH in
+ aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
@@ -188,18 +216,18 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
earmv*)
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
- machine="${arch}${endian}"-unknown
+ machine=${arch}${endian}-unknown
;;
- *) machine="$UNAME_MACHINE_ARCH"-unknown ;;
+ *) machine=$UNAME_MACHINE_ARCH-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently (or will in the future) and ABI.
- case "$UNAME_MACHINE_ARCH" in
+ case $UNAME_MACHINE_ARCH in
earm*)
os=netbsdelf
;;
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval "$set_cc_for_build"
+ set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
@@ -215,7 +243,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
;;
esac
# Determine ABI tags.
- case "$UNAME_MACHINE_ARCH" in
+ case $UNAME_MACHINE_ARCH in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
@@ -226,7 +254,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
- case "$UNAME_VERSION" in
+ case $UNAME_VERSION in
Debian*)
release='-gnu'
;;
@@ -237,45 +265,57 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "$machine-${os}${release}${abi-}"
- exit ;;
+ GUESS=$machine-${os}${release}${abi-}
+ ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
- echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
+ ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
+ ;;
+ *:SecBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
+ GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
+ ;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
- echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
+ ;;
*:MidnightBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
+ ;;
*:ekkoBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
+ ;;
*:SolidBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
+ ;;
+ *:OS108:*:*)
+ GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
+ ;;
macppc:MirBSD:*:*)
- echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
+ ;;
*:MirBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
+ ;;
*:Sortix:*:*)
- echo "$UNAME_MACHINE"-unknown-sortix
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-sortix
+ ;;
+ *:Twizzler:*:*)
+ GUESS=$UNAME_MACHINE-unknown-twizzler
+ ;;
*:Redox:*:*)
- echo "$UNAME_MACHINE"-unknown-redox
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-redox
+ ;;
mips:OSF1:*.*)
- echo mips-dec-osf1
- exit ;;
+ GUESS=mips-dec-osf1
+ ;;
alpha:OSF1:*:*)
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ trap '' 0
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -289,7 +329,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
+ case $ALPHA_CPU_TYPE in
"EV4 (21064)")
UNAME_MACHINE=alpha ;;
"EV4.5 (21064)")
@@ -326,117 +366,121 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
- # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
- exitcode=$?
- trap '' 0
- exit $exitcode ;;
+ OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
+ ;;
Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
+ GUESS=m68k-unknown-sysv4
+ ;;
*:[Aa]miga[Oo][Ss]:*:*)
- echo "$UNAME_MACHINE"-unknown-amigaos
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-amigaos
+ ;;
*:[Mm]orph[Oo][Ss]:*:*)
- echo "$UNAME_MACHINE"-unknown-morphos
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-morphos
+ ;;
*:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
+ GUESS=i370-ibm-openedition
+ ;;
*:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
+ GUESS=s390-ibm-zvmoe
+ ;;
*:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
+ GUESS=powerpc-ibm-os400
+ ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix"$UNAME_RELEASE"
- exit ;;
+ GUESS=arm-acorn-riscix$UNAME_RELEASE
+ ;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
+ GUESS=arm-unknown-riscos
+ ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
+ GUESS=hppa1.1-hitachi-hiuxmpp
+ ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
+ case `(/bin/universe) 2>/dev/null` in
+ att) GUESS=pyramid-pyramid-sysv3 ;;
+ *) GUESS=pyramid-pyramid-bsd ;;
+ esac
+ ;;
NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
+ GUESS=pyramid-pyramid-svr4
+ ;;
DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
+ GUESS=sparc-icl-nx6
+ ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
+ sparc) GUESS=sparc-icl-nx7 ;;
+ esac
+ ;;
s390x:SunOS:*:*)
- echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
+ ;;
sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-hal-solaris2$SUN_REL
+ ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-sun-solaris2$SUN_REL
+ ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
- echo i386-pc-auroraux"$UNAME_RELEASE"
- exit ;;
+ GUESS=i386-pc-auroraux$UNAME_RELEASE
+ ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
- if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH=x86_64
fi
fi
- echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
+ ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-sun-solaris3$SUN_REL
+ ;;
sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
+ case `/usr/bin/arch -k` in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
+ GUESS=sparc-sun-sunos$SUN_REL
+ ;;
sun3*:SunOS:*:*)
- echo m68k-sun-sunos"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
+ ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
- case "`/bin/arch`" in
+ case `/bin/arch` in
sun3)
- echo m68k-sun-sunos"$UNAME_RELEASE"
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
;;
sun4)
- echo sparc-sun-sunos"$UNAME_RELEASE"
+ GUESS=sparc-sun-sunos$UNAME_RELEASE
;;
esac
- exit ;;
+ ;;
aushp:SunOS:*:*)
- echo sparc-auspex-sunos"$UNAME_RELEASE"
- exit ;;
+ GUESS=sparc-auspex-sunos$UNAME_RELEASE
+ ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
@@ -446,43 +490,43 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-milan-mint$UNAME_RELEASE
+ ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-hades-mint$UNAME_RELEASE
+ ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-unknown-mint$UNAME_RELEASE
+ ;;
m68k:machten:*:*)
- echo m68k-apple-machten"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-apple-machten$UNAME_RELEASE
+ ;;
powerpc:machten:*:*)
- echo powerpc-apple-machten"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-apple-machten$UNAME_RELEASE
+ ;;
RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
+ GUESS=mips-dec-mach_bsd4.3
+ ;;
RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-dec-ultrix$UNAME_RELEASE
+ ;;
VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix"$UNAME_RELEASE"
- exit ;;
+ GUESS=vax-dec-ultrix$UNAME_RELEASE
+ ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix"$UNAME_RELEASE"
- exit ;;
+ GUESS=clipper-intergraph-clix$UNAME_RELEASE
+ ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
@@ -508,78 +552,79 @@ EOF
dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
{ echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-mips-riscos$UNAME_RELEASE
+ ;;
Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
+ GUESS=powerpc-motorola-powermax
+ ;;
Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
+ GUESS=powerpc-harris-powermax
+ ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
+ GUESS=powerpc-harris-powermax
+ ;;
Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
+ GUESS=powerpc-harris-powerunix
+ ;;
m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
+ GUESS=m88k-harris-cxux7
+ ;;
m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
+ GUESS=m88k-motorola-sysv4
+ ;;
m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
+ GUESS=m88k-motorola-sysv3
+ ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
+ if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
then
- if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
- [ "$TARGET_BINARY_INTERFACE"x = x ]
+ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
+ test "$TARGET_BINARY_INTERFACE"x = x
then
- echo m88k-dg-dgux"$UNAME_RELEASE"
+ GUESS=m88k-dg-dgux$UNAME_RELEASE
else
- echo m88k-dg-dguxbcs"$UNAME_RELEASE"
+ GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
fi
else
- echo i586-dg-dgux"$UNAME_RELEASE"
+ GUESS=i586-dg-dgux$UNAME_RELEASE
fi
- exit ;;
+ ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
+ GUESS=m88k-dolphin-sysv3
+ ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
+ GUESS=m88k-motorola-sysv3
+ ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
+ GUESS=m88k-tektronix-sysv3
+ ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
+ GUESS=m68k-tektronix-bsd
+ ;;
*:IRIX*:*:*)
- echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
- exit ;;
+ IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
+ GUESS=mips-sgi-irix$IRIX_REL
+ ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
+ GUESS=i386-ibm-aix
+ ;;
ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
+ if test -x /usr/bin/oslevel ; then
IBM_REV=`/usr/bin/oslevel`
else
- IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
- echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
- exit ;;
+ GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
+ ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h>
@@ -593,16 +638,16 @@ EOF
EOF
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
then
- echo "$SYSTEM_NAME"
+ GUESS=$SYSTEM_NAME
else
- echo rs6000-ibm-aix3.2.5
+ GUESS=rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
+ GUESS=rs6000-ibm-aix3.2.4
else
- echo rs6000-ibm-aix3.2
+ GUESS=rs6000-ibm-aix3.2
fi
- exit ;;
+ ;;
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
@@ -610,57 +655,57 @@ EOF
else
IBM_ARCH=powerpc
fi
- if [ -x /usr/bin/lslpp ] ; then
- IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+ if test -x /usr/bin/lslpp ; then
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
- IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
- echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
- exit ;;
+ GUESS=$IBM_ARCH-ibm-aix$IBM_REV
+ ;;
*:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
+ GUESS=rs6000-ibm-aix
+ ;;
ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
+ GUESS=romp-ibm-bsd4.4
+ ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
+ GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to
+ ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
+ GUESS=rs6000-bull-bosx
+ ;;
DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
+ GUESS=m68k-bull-sysv3
+ ;;
9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
+ GUESS=m68k-hp-bsd
+ ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
+ GUESS=m68k-hp-bsd4.4
+ ;;
9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
- case "$UNAME_MACHINE" in
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+ case $UNAME_MACHINE in
9000/31?) HP_ARCH=m68000 ;;
9000/[34]??) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
+ if test -x /usr/bin/getconf; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "$sc_cpu_version" in
+ case $sc_cpu_version in
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
- case "$sc_kernel_bits" in
+ case $sc_kernel_bits in
32) HP_ARCH=hppa2.0n ;;
64) HP_ARCH=hppa2.0w ;;
'') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
esac ;;
esac
fi
- if [ "$HP_ARCH" = "" ]; then
- eval "$set_cc_for_build"
+ if test "$HP_ARCH" = ""; then
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#define _HPUX_SOURCE
@@ -698,9 +743,9 @@ EOF
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
- if [ "$HP_ARCH" = hppa2.0w ]
+ if test "$HP_ARCH" = hppa2.0w
then
- eval "$set_cc_for_build"
+ set_cc_for_build
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
@@ -719,14 +764,14 @@ EOF
HP_ARCH=hppa64
fi
fi
- echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
- exit ;;
+ GUESS=$HP_ARCH-hp-hpux$HPUX_REV
+ ;;
ia64:HP-UX:*:*)
- HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux"$HPUX_REV"
- exit ;;
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+ GUESS=ia64-hp-hpux$HPUX_REV
+ ;;
3050*:HI-UX:*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#include <unistd.h>
int
@@ -754,36 +799,36 @@ EOF
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
{ echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
+ GUESS=unknown-hitachi-hiuxwe2
+ ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
- echo hppa1.1-hp-bsd
- exit ;;
+ GUESS=hppa1.1-hp-bsd
+ ;;
9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
+ GUESS=hppa1.0-hp-bsd
+ ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
+ GUESS=hppa1.0-hp-mpeix
+ ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
- echo hppa1.1-hp-osf
- exit ;;
+ GUESS=hppa1.1-hp-osf
+ ;;
hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
+ GUESS=hppa1.0-hp-osf
+ ;;
i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo "$UNAME_MACHINE"-unknown-osf1mk
+ if test -x /usr/sbin/sysversion ; then
+ GUESS=$UNAME_MACHINE-unknown-osf1mk
else
- echo "$UNAME_MACHINE"-unknown-osf1
+ GUESS=$UNAME_MACHINE-unknown-osf1
fi
- exit ;;
+ ;;
parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
+ GUESS=hppa1.1-hp-lites
+ ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
+ GUESS=c1-convex-bsd
+ ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
@@ -791,17 +836,18 @@ EOF
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
+ GUESS=c34-convex-bsd
+ ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
+ GUESS=c38-convex-bsd
+ ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
+ GUESS=c4-convex-bsd
+ ;;
CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=ymp-cray-unicos$CRAY_REL
+ ;;
CRAY*[A-Z]90:*:*:*)
echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
@@ -809,103 +855,129 @@ EOF
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
- echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=t90-cray-unicos$CRAY_REL
+ ;;
CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=alphaev5-cray-unicosmk$CRAY_REL
+ ;;
CRAY*SV1:*:*:*)
- echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=sv1-cray-unicos$CRAY_REL
+ ;;
*:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=craynv-cray-unicosmp$CRAY_REL
+ ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
+ GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+ ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
+ GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+ ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
+ ;;
sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi"$UNAME_RELEASE"
- exit ;;
+ GUESS=sparc-unknown-bsdi$UNAME_RELEASE
+ ;;
*:BSD/OS:*:*)
- echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
+ ;;
+ arm:FreeBSD:*:*)
+ UNAME_PROCESSOR=`uname -p`
+ set_cc_for_build
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
+ else
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
+ fi
+ ;;
*:FreeBSD:*:*)
UNAME_PROCESSOR=`/usr/bin/uname -p`
- case "$UNAME_PROCESSOR" in
+ case $UNAME_PROCESSOR in
amd64)
UNAME_PROCESSOR=x86_64 ;;
i386)
UNAME_PROCESSOR=i586 ;;
esac
- echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
- exit ;;
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
+ ;;
i*:CYGWIN*:*)
- echo "$UNAME_MACHINE"-pc-cygwin
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-cygwin
+ ;;
*:MINGW64*:*)
- echo "$UNAME_MACHINE"-pc-mingw64
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-mingw64
+ ;;
*:MINGW*:*)
- echo "$UNAME_MACHINE"-pc-mingw32
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-mingw32
+ ;;
*:MSYS*:*)
- echo "$UNAME_MACHINE"-pc-msys
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-msys
+ ;;
i*:PW*:*)
- echo "$UNAME_MACHINE"-pc-pw32
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-pw32
+ ;;
+ *:SerenityOS:*:*)
+ GUESS=$UNAME_MACHINE-pc-serenity
+ ;;
*:Interix*:*)
- case "$UNAME_MACHINE" in
+ case $UNAME_MACHINE in
x86)
- echo i586-pc-interix"$UNAME_RELEASE"
- exit ;;
+ GUESS=i586-pc-interix$UNAME_RELEASE
+ ;;
authenticamd | genuineintel | EM64T)
- echo x86_64-unknown-interix"$UNAME_RELEASE"
- exit ;;
+ GUESS=x86_64-unknown-interix$UNAME_RELEASE
+ ;;
IA64)
- echo ia64-unknown-interix"$UNAME_RELEASE"
- exit ;;
+ GUESS=ia64-unknown-interix$UNAME_RELEASE
+ ;;
esac ;;
i*:UWIN*:*)
- echo "$UNAME_MACHINE"-pc-uwin
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-uwin
+ ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit ;;
+ GUESS=x86_64-pc-cygwin
+ ;;
prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=powerpcle-unknown-solaris2$SUN_REL
+ ;;
*:GNU:*:*)
# the GNU system
- echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
- exit ;;
+ GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
+ GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
+ ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
- echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
- exit ;;
+ GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
+ ;;
*:Minix:*:*)
- echo "$UNAME_MACHINE"-unknown-minix
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-minix
+ ;;
aarch64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
@@ -916,183 +988,225 @@ EOF
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
- arc:Linux:*:* | arceb:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
arm*:Linux:*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
else
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
fi
fi
- exit ;;
+ ;;
avr32*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
cris:Linux:*:*)
- echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+ ;;
crisv32:Linux:*:*)
- echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+ ;;
e2k:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
frv:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
hexagon:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
i*86:Linux:*:*)
- echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-linux-$LIBC
+ ;;
ia64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
k1om:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
m32r*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
m68*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
mips:Linux:*:* | mips64:Linux:*:*)
- eval "$set_cc_for_build"
+ set_cc_for_build
+ IS_GLIBC=0
+ test x"${LIBC}" = xgnu && IS_GLIBC=1
sed 's/^ //' << EOF > "$dummy.c"
#undef CPU
- #undef ${UNAME_MACHINE}
- #undef ${UNAME_MACHINE}el
+ #undef mips
+ #undef mipsel
+ #undef mips64
+ #undef mips64el
+ #if ${IS_GLIBC} && defined(_ABI64)
+ LIBCABI=gnuabi64
+ #else
+ #if ${IS_GLIBC} && defined(_ABIN32)
+ LIBCABI=gnuabin32
+ #else
+ LIBCABI=${LIBC}
+ #endif
+ #endif
+
+ #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+ CPU=mipsisa64r6
+ #else
+ #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
+ CPU=mipsisa32r6
+ #else
+ #if defined(__mips64)
+ CPU=mips64
+ #else
+ CPU=mips
+ #endif
+ #endif
+ #endif
+
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=${UNAME_MACHINE}el
+ MIPS_ENDIAN=el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=${UNAME_MACHINE}
+ MIPS_ENDIAN=
#else
- CPU=
+ MIPS_ENDIAN=
#endif
#endif
EOF
- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
- test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
+ cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
+ eval "$cc_set_vars"
+ test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
;;
mips64el:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
openrisc*:Linux:*:*)
- echo or1k-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=or1k-unknown-linux-$LIBC
+ ;;
or32:Linux:*:* | or1k*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
padre:Linux:*:*)
- echo sparc-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=sparc-unknown-linux-$LIBC
+ ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=hppa64-unknown-linux-$LIBC
+ ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
- PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
- *) echo hppa-unknown-linux-"$LIBC" ;;
+ PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
+ PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
+ *) GUESS=hppa-unknown-linux-$LIBC ;;
esac
- exit ;;
+ ;;
ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpc64-unknown-linux-$LIBC
+ ;;
ppc:Linux:*:*)
- echo powerpc-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpc-unknown-linux-$LIBC
+ ;;
ppc64le:Linux:*:*)
- echo powerpc64le-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpc64le-unknown-linux-$LIBC
+ ;;
ppcle:Linux:*:*)
- echo powerpcle-unknown-linux-"$LIBC"
- exit ;;
- riscv32:Linux:*:* | riscv64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpcle-unknown-linux-$LIBC
+ ;;
+ riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
s390:Linux:*:* | s390x:Linux:*:*)
- echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
+ ;;
sh64*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
sh*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
tile*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
vax:Linux:*:*)
- echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-dec-linux-$LIBC
+ ;;
x86_64:Linux:*:*)
- echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
- exit ;;
+ set_cc_for_build
+ LIBCABI=$LIBC
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_X32 >/dev/null
+ then
+ LIBCABI=${LIBC}x32
+ fi
+ fi
+ GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
+ ;;
xtensa*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
+ GUESS=i386-sequent-sysv4
+ ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
- echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
+ ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
- echo "$UNAME_MACHINE"-pc-os2-emx
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-os2-emx
+ ;;
i*86:XTS-300:*:STOP)
- echo "$UNAME_MACHINE"-unknown-stop
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-stop
+ ;;
i*86:atheos:*:*)
- echo "$UNAME_MACHINE"-unknown-atheos
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-atheos
+ ;;
i*86:syllable:*:*)
- echo "$UNAME_MACHINE"-pc-syllable
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-syllable
+ ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
- echo i386-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=i386-unknown-lynxos$UNAME_RELEASE
+ ;;
i*86:*DOS:*:*)
- echo "$UNAME_MACHINE"-pc-msdosdjgpp
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-msdosdjgpp
+ ;;
i*86:*:4.*:*)
UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
else
- echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
fi
- exit ;;
+ ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
@@ -1100,12 +1214,12 @@ EOF
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
- echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
@@ -1115,11 +1229,11 @@ EOF
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
- echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
else
- echo "$UNAME_MACHINE"-pc-sysv32
+ GUESS=$UNAME_MACHINE-pc-sysv32
fi
- exit ;;
+ ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
@@ -1127,31 +1241,31 @@ EOF
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configure will decide that
# this is a cross-build.
- echo i586-pc-msdosdjgpp
- exit ;;
+ GUESS=i586-pc-msdosdjgpp
+ ;;
Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
+ GUESS=i386-pc-mach3
+ ;;
paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
+ GUESS=i860-intel-osf1
+ ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
+ GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4
+ GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4
fi
- exit ;;
+ ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
- echo m68010-convergent-sysv
- exit ;;
+ GUESS=m68010-convergent-sysv
+ ;;
mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
+ GUESS=m68k-convergent-sysv
+ ;;
M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
+ GUESS=m68k-diab-dnix
+ ;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
@@ -1176,249 +1290,404 @@ EOF
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-unknown-lynxos$UNAME_RELEASE
+ ;;
mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
+ GUESS=m68k-atari-sysv4
+ ;;
TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=sparc-unknown-lynxos$UNAME_RELEASE
+ ;;
rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
+ ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
- echo powerpc-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
+ ;;
SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-dde-sysv$UNAME_RELEASE
+ ;;
RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
+ GUESS=mips-sni-sysv4
+ ;;
RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
+ GUESS=mips-sni-sysv4
+ ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo "$UNAME_MACHINE"-sni-sysv4
+ GUESS=$UNAME_MACHINE-sni-sysv4
else
- echo ns32k-sni-sysv
+ GUESS=ns32k-sni-sysv
fi
- exit ;;
+ ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
+ GUESS=i586-unisys-sysv4
+ ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
+ GUESS=hppa1.1-stratus-sysv4
+ ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
+ GUESS=i860-stratus-sysv4
+ ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
- echo "$UNAME_MACHINE"-stratus-vos
- exit ;;
+ GUESS=$UNAME_MACHINE-stratus-vos
+ ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
+ GUESS=hppa1.1-stratus-vos
+ ;;
mc68*:A/UX:*:*)
- echo m68k-apple-aux"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-apple-aux$UNAME_RELEASE
+ ;;
news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
+ GUESS=mips-sony-newsos6
+ ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv"$UNAME_RELEASE"
+ if test -d /usr/nec; then
+ GUESS=mips-nec-sysv$UNAME_RELEASE
else
- echo mips-unknown-sysv"$UNAME_RELEASE"
+ GUESS=mips-unknown-sysv$UNAME_RELEASE
fi
- exit ;;
+ ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
+ GUESS=powerpc-be-beos
+ ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
+ GUESS=powerpc-apple-beos
+ ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
+ GUESS=i586-pc-beos
+ ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
- echo i586-pc-haiku
- exit ;;
+ GUESS=i586-pc-haiku
+ ;;
x86_64:Haiku:*:*)
- echo x86_64-unknown-haiku
- exit ;;
+ GUESS=x86_64-unknown-haiku
+ ;;
SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx4-nec-superux$UNAME_RELEASE
+ ;;
SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx5-nec-superux$UNAME_RELEASE
+ ;;
SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx6-nec-superux$UNAME_RELEASE
+ ;;
SX-7:SUPER-UX:*:*)
- echo sx7-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx7-nec-superux$UNAME_RELEASE
+ ;;
SX-8:SUPER-UX:*:*)
- echo sx8-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx8-nec-superux$UNAME_RELEASE
+ ;;
SX-8R:SUPER-UX:*:*)
- echo sx8r-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx8r-nec-superux$UNAME_RELEASE
+ ;;
SX-ACE:SUPER-UX:*:*)
- echo sxace-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sxace-nec-superux$UNAME_RELEASE
+ ;;
Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
+ ;;
*:Rhapsody:*:*)
- echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
+ ;;
+ arm64:Darwin:*:*)
+ GUESS=aarch64-apple-darwin$UNAME_RELEASE
+ ;;
*:Darwin:*:*)
- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- eval "$set_cc_for_build"
- if test "$UNAME_PROCESSOR" = unknown ; then
- UNAME_PROCESSOR=powerpc
+ UNAME_PROCESSOR=`uname -p`
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ if command -v xcode-select > /dev/null 2> /dev/null && \
+ ! xcode-select --print-path > /dev/null 2> /dev/null ; then
+ # Avoid executing cc if there is no toolchain installed as
+ # cc will be a stub that puts up a graphical alert
+ # prompting the user to install developer tools.
+ CC_FOR_BUILD=no_compiler_found
+ else
+ set_cc_for_build
fi
- if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
- if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
- grep IS_64BIT_ARCH >/dev/null
- then
- case $UNAME_PROCESSOR in
- i386) UNAME_PROCESSOR=x86_64 ;;
- powerpc) UNAME_PROCESSOR=powerpc64 ;;
- esac
- fi
- # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
- if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
- grep IS_PPC >/dev/null
- then
- UNAME_PROCESSOR=powerpc
- fi
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_PPC >/dev/null
+ then
+ UNAME_PROCESSOR=powerpc
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
- # Avoid executing cc on OS X 10.9, as it ships with a stub
- # that puts up a graphical alert prompting to install
- # developer tools. Any system running Mac OS X 10.7 or
- # later (Darwin 11 and later) is required to have a 64-bit
- # processor. This is not true of the ARM version of Darwin
- # that Apple uses in portable devices.
- UNAME_PROCESSOR=x86_64
+ # uname -m returns i386 or x86_64
+ UNAME_PROCESSOR=$UNAME_MACHINE
fi
- echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
+ ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
- echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
+ ;;
*:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
+ GUESS=i386-pc-qnx
+ ;;
NEO-*:NONSTOP_KERNEL:*:*)
- echo neo-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=neo-tandem-nsk$UNAME_RELEASE
+ ;;
NSE-*:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nse-tandem-nsk$UNAME_RELEASE
+ ;;
NSR-*:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nsr-tandem-nsk$UNAME_RELEASE
+ ;;
NSV-*:NONSTOP_KERNEL:*:*)
- echo nsv-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nsv-tandem-nsk$UNAME_RELEASE
+ ;;
NSX-*:NONSTOP_KERNEL:*:*)
- echo nsx-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nsx-tandem-nsk$UNAME_RELEASE
+ ;;
*:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
+ GUESS=mips-compaq-nonstopux
+ ;;
BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
+ GUESS=bs2000-siemens-sysv
+ ;;
DS/*:UNIX_System_V:*:*)
- echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
+ ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
- if test "$cputype" = 386; then
+ if test "${cputype-}" = 386; then
UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
+ elif test "x${cputype-}" != x; then
+ UNAME_MACHINE=$cputype
fi
- echo "$UNAME_MACHINE"-unknown-plan9
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-plan9
+ ;;
*:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
+ GUESS=pdp10-unknown-tops10
+ ;;
*:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
+ GUESS=pdp10-unknown-tenex
+ ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
+ GUESS=pdp10-dec-tops20
+ ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
+ GUESS=pdp10-xkl-tops20
+ ;;
*:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
+ GUESS=pdp10-unknown-tops20
+ ;;
*:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
+ GUESS=pdp10-unknown-its
+ ;;
SEI:*:*:SEIUX)
- echo mips-sei-seiux"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-sei-seiux$UNAME_RELEASE
+ ;;
*:DragonFly:*:*)
- echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
- exit ;;
+ DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
+ ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "$UNAME_MACHINE" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
+ case $UNAME_MACHINE in
+ A*) GUESS=alpha-dec-vms ;;
+ I*) GUESS=ia64-dec-vms ;;
+ V*) GUESS=vax-dec-vms ;;
esac ;;
*:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
+ GUESS=i386-pc-xenix
+ ;;
i*86:skyos:*:*)
- echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
- exit ;;
+ SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
+ GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
+ ;;
i*86:rdos:*:*)
- echo "$UNAME_MACHINE"-pc-rdos
- exit ;;
- i*86:AROS:*:*)
- echo "$UNAME_MACHINE"-pc-aros
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-rdos
+ ;;
+ i*86:Fiwix:*:*)
+ GUESS=$UNAME_MACHINE-pc-fiwix
+ ;;
+ *:AROS:*:*)
+ GUESS=$UNAME_MACHINE-unknown-aros
+ ;;
x86_64:VMkernel:*:*)
- echo "$UNAME_MACHINE"-unknown-esx
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-esx
+ ;;
amd64:Isilon\ OneFS:*:*)
- echo x86_64-unknown-onefs
- exit ;;
+ GUESS=x86_64-unknown-onefs
+ ;;
+ *:Unleashed:*:*)
+ GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
+ ;;
esac
+# Do we have a guess based on uname results?
+if test "x$GUESS" != x; then
+ echo "$GUESS"
+ exit
+fi
+
+# No uname command or uname output not recognized.
+set_cc_for_build
+cat > "$dummy.c" <<EOF
+#ifdef _SEQUENT_
+#include <sys/types.h>
+#include <sys/utsname.h>
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#include <signal.h>
+#if defined(_SIZE_T_) || defined(SIGLOST)
+#include <sys/utsname.h>
+#endif
+#endif
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+#include <sys/param.h>
+#if defined (BSD)
+#if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+#else
+#if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#else
+ printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#endif
+#else
+ printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#else
+#if defined(_SIZE_T_) || defined(SIGLOST)
+ struct utsname un;
+ uname (&un);
+ printf ("vax-dec-ultrix%s\n", un.release); exit (0);
+#else
+ printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
+#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
+#if defined(_SIZE_T_) || defined(SIGLOST)
+ struct utsname *un;
+ uname (&un);
+ printf ("mips-dec-ultrix%s\n", un.release); exit (0);
+#else
+ printf ("mips-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
+
echo "$0: unable to guess system type" >&2
-case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+case $UNAME_MACHINE:$UNAME_SYSTEM in
mips:Linux | mips64:Linux)
# If we got here on MIPS GNU/Linux, output extra information.
cat >&2 <<EOF
@@ -1435,9 +1704,17 @@ This script (version $timestamp), has failed to recognize the
operating system you are using. If your script is old, overwrite *all*
copies of config.guess and config.sub with the latest versions from:
- https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
and
- https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
+EOF
+
+our_year=`echo $timestamp | sed 's,-.*,,'`
+thisyear=`date +%Y`
+# shellcheck disable=SC2003
+script_age=`expr "$thisyear" - "$our_year"`
+if test "$script_age" -lt 3 ; then
+ cat >&2 <<EOF
If $0 has already been updated, send the following data and any
information you think might be pertinent to config-patches@gnu.org to
@@ -1465,6 +1742,7 @@ UNAME_RELEASE = "$UNAME_RELEASE"
UNAME_SYSTEM = "$UNAME_SYSTEM"
UNAME_VERSION = "$UNAME_VERSION"
EOF
+fi
exit 1
diff --git a/config.h.in b/config.h.in
index 00618aec..3eb90a8b 100644
--- a/config.h.in
+++ b/config.h.in
@@ -132,9 +132,6 @@
/* Define to 1 if you have the <net/pfilt.h> header file. */
#undef HAVE_NET_PFILT_H
-/* Define to 1 if you have the <net/pfvar.h> header file. */
-#undef HAVE_NET_PFVAR_H
-
/* Define to 1 if you have the <net/raw.h> header file. */
#undef HAVE_NET_RAW_H
@@ -144,9 +141,6 @@
/* if there's an os_proto.h for this platform, to use additional prototypes */
#undef HAVE_OS_PROTO_H
-/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
-#undef HAVE_PF_NAT_THROUGH_PF_NORDR
-
/* Define to 1 if you have a POSIX-style `strerror_r' function. */
#undef HAVE_POSIX_STRERROR_R
@@ -262,6 +256,12 @@
/* Define to 1 if you have the `_wcserror_s' function. */
#undef HAVE__WCSERROR_S
+/* define if __atomic_load_n is supported by the compiler */
+#undef HAVE___ATOMIC_LOAD_N
+
+/* define if __atomic_store_n is supported by the compiler */
+#undef HAVE___ATOMIC_STORE_N
+
/* IPv6 */
#undef INET6
diff --git a/config.sub b/config.sub
index c95acc68..dba16e84 100755
--- a/config.sub
+++ b/config.sub
@@ -1,12 +1,14 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2018 Free Software Foundation, Inc.
+# Copyright 1992-2022 Free Software Foundation, Inc.
-timestamp='2018-07-03'
+# shellcheck disable=SC2006,SC2268 # see below for rationale
+
+timestamp='2022-01-03'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -33,7 +35,7 @@ timestamp='2018-07-03'
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
-# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
@@ -50,6 +52,13 @@ timestamp='2018-07-03'
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX. However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
@@ -67,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -89,7 +98,7 @@ while test $# -gt 0 ; do
- ) # Use stdin as input.
break ;;
-* )
- echo "$me: invalid option $1$help"
+ echo "$me: invalid option $1$help" >&2
exit 1 ;;
*local*)
@@ -111,9 +120,12 @@ case $# in
esac
# Split fields of configuration type
-IFS="-" read -r field1 field2 field3 field4 <<EOF
+# shellcheck disable=SC2162
+saved_IFS=$IFS
+IFS="-" read field1 field2 field3 field4 <<EOF
$1
EOF
+IFS=$saved_IFS
# Separate into logical components for further validation
case $1 in
@@ -123,55 +135,68 @@ case $1 in
;;
*-*-*-*)
basic_machine=$field1-$field2
- os=$field3-$field4
+ basic_os=$field3-$field4
;;
*-*-*)
# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
# parts
maybe_os=$field2-$field3
case $maybe_os in
- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \
- | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
+ nto-qnx* | linux-* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
| storm-chaos* | os2-emx* | rtmk-nova*)
basic_machine=$field1
- os=$maybe_os
+ basic_os=$maybe_os
;;
android-linux)
basic_machine=$field1-unknown
- os=linux-android
+ basic_os=linux-android
;;
*)
basic_machine=$field1-$field2
- os=$field3
+ basic_os=$field3
;;
esac
;;
*-*)
- # Second component is usually, but not always the OS
- case $field2 in
- # Prevent following clause from handling this valid os
- sun*os*)
- basic_machine=$field1
- os=$field2
- ;;
- # Manufacturers
- dec* | mips* | sequent* | encore* | pc532* | sgi* | sony* \
- | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
- | unicom* | ibm* | next | hp | isi* | apollo | altos* \
- | convergent* | ncr* | news | 32* | 3600* | 3100* | hitachi* \
- | c[123]* | convex* | sun | crds | omron* | dg | ultra | tti* \
- | harris | dolphin | highlevel | gould | cbm | ns | masscomp \
- | apple | axis | knuth | cray | microblaze* \
- | sim | cisco | oki | wec | wrs | winbond)
- basic_machine=$field1-$field2
- os=
- ;;
- *)
- basic_machine=$field1
- os=$field2
- ;;
+ # A lone config we happen to match not fitting any pattern
+ case $field1-$field2 in
+ decstation-3100)
+ basic_machine=mips-dec
+ basic_os=
+ ;;
+ *-*)
+ # Second component is usually, but not always the OS
+ case $field2 in
+ # Prevent following clause from handling this valid os
+ sun*os*)
+ basic_machine=$field1
+ basic_os=$field2
+ ;;
+ zephyr*)
+ basic_machine=$field1-unknown
+ basic_os=$field2
+ ;;
+ # Manufacturers
+ dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
+ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
+ | unicom* | ibm* | next | hp | isi* | apollo | altos* \
+ | convergent* | ncr* | news | 32* | 3600* | 3100* \
+ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
+ | ultra | tti* | harris | dolphin | highlevel | gould \
+ | cbm | ns | masscomp | apple | axis | knuth | cray \
+ | microblaze* | sim | cisco \
+ | oki | wec | wrs | winbond)
+ basic_machine=$field1-$field2
+ basic_os=
+ ;;
+ *)
+ basic_machine=$field1
+ basic_os=$field2
+ ;;
+ esac
+ ;;
esac
;;
*)
@@ -180,1105 +205,1100 @@ case $1 in
case $field1 in
386bsd)
basic_machine=i386-pc
- os=bsd
+ basic_os=bsd
;;
a29khif)
basic_machine=a29k-amd
- os=udi
+ basic_os=udi
;;
adobe68k)
basic_machine=m68010-adobe
- os=scout
+ basic_os=scout
+ ;;
+ alliant)
+ basic_machine=fx80-alliant
+ basic_os=
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ basic_os=
;;
am29k)
basic_machine=a29k-none
- os=bsd
+ basic_os=bsd
;;
amdahl)
basic_machine=580-amdahl
- os=sysv
+ basic_os=sysv
+ ;;
+ amiga)
+ basic_machine=m68k-unknown
+ basic_os=
;;
amigaos | amigados)
basic_machine=m68k-unknown
- os=amigaos
+ basic_os=amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
- os=sysv4
+ basic_os=sysv4
;;
apollo68)
basic_machine=m68k-apollo
- os=sysv
+ basic_os=sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
- os=bsd
+ basic_os=bsd
;;
aros)
basic_machine=i386-pc
- os=aros
+ basic_os=aros
;;
aux)
basic_machine=m68k-apple
- os=aux
+ basic_os=aux
;;
balance)
basic_machine=ns32k-sequent
- os=dynix
+ basic_os=dynix
;;
blackfin)
basic_machine=bfin-unknown
- os=linux
+ basic_os=linux
;;
cegcc)
basic_machine=arm-unknown
- os=cegcc
+ basic_os=cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ basic_os=bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ basic_os=bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ basic_os=bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ basic_os=bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ basic_os=bsd
;;
cray)
basic_machine=j90-cray
- os=unicos
+ basic_os=unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ basic_os=
;;
- craynv)
- basic_machine=craynv-cray
- os=unicosmp
+ da30)
+ basic_machine=m68k-da30
+ basic_os=
+ ;;
+ decstation | pmax | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ basic_os=
;;
delta88)
basic_machine=m88k-motorola
- os=sysv3
+ basic_os=sysv3
;;
dicos)
basic_machine=i686-pc
- os=dicos
+ basic_os=dicos
;;
djgpp)
basic_machine=i586-pc
- os=msdosdjgpp
+ basic_os=msdosdjgpp
;;
ebmon29k)
basic_machine=a29k-amd
- os=ebmon
+ basic_os=ebmon
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
- os=ose
+ basic_os=ose
;;
gmicro)
basic_machine=tron-gmicro
- os=sysv
+ basic_os=sysv
;;
go32)
basic_machine=i386-pc
- os=go32
+ basic_os=go32
;;
h8300hms)
basic_machine=h8300-hitachi
- os=hms
+ basic_os=hms
;;
h8300xray)
basic_machine=h8300-hitachi
- os=xray
+ basic_os=xray
;;
h8500hms)
basic_machine=h8500-hitachi
- os=hms
+ basic_os=hms
;;
harris)
basic_machine=m88k-harris
- os=sysv3
+ basic_os=sysv3
;;
- hp300bsd)
+ hp300 | hp300hpux)
basic_machine=m68k-hp
- os=bsd
+ basic_os=hpux
;;
- hp300hpux)
+ hp300bsd)
basic_machine=m68k-hp
- os=hpux
+ basic_os=bsd
;;
hppaosf)
basic_machine=hppa1.1-hp
- os=osf
+ basic_os=osf
;;
hppro)
basic_machine=hppa1.1-hp
- os=proelf
+ basic_os=proelf
;;
i386mach)
basic_machine=i386-mach
- os=mach
- ;;
- vsta)
- basic_machine=i386-unknown
- os=vsta
+ basic_os=mach
;;
isi68 | isi)
basic_machine=m68k-isi
- os=sysv
+ basic_os=sysv
;;
m68knommu)
basic_machine=m68k-unknown
- os=linux
+ basic_os=linux
;;
magnum | m3230)
basic_machine=mips-mips
- os=sysv
+ basic_os=sysv
;;
merlin)
basic_machine=ns32k-utek
- os=sysv
+ basic_os=sysv
;;
mingw64)
basic_machine=x86_64-pc
- os=mingw64
+ basic_os=mingw64
;;
mingw32)
basic_machine=i686-pc
- os=mingw32
+ basic_os=mingw32
;;
mingw32ce)
basic_machine=arm-unknown
- os=mingw32ce
+ basic_os=mingw32ce
;;
monitor)
basic_machine=m68k-rom68k
- os=coff
+ basic_os=coff
;;
morphos)
basic_machine=powerpc-unknown
- os=morphos
+ basic_os=morphos
;;
moxiebox)
basic_machine=moxie-unknown
- os=moxiebox
+ basic_os=moxiebox
;;
msdos)
basic_machine=i386-pc
- os=msdos
+ basic_os=msdos
;;
msys)
basic_machine=i686-pc
- os=msys
+ basic_os=msys
;;
mvs)
basic_machine=i370-ibm
- os=mvs
+ basic_os=mvs
;;
nacl)
basic_machine=le32-unknown
- os=nacl
+ basic_os=nacl
;;
ncr3000)
basic_machine=i486-ncr
- os=sysv4
+ basic_os=sysv4
;;
netbsd386)
- basic_machine=i386-unknown
- os=netbsd
+ basic_machine=i386-pc
+ basic_os=netbsd
;;
netwinder)
basic_machine=armv4l-rebel
- os=linux
+ basic_os=linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
- os=newsos
+ basic_os=newsos
;;
news1000)
basic_machine=m68030-sony
- os=newsos
+ basic_os=newsos
;;
necv70)
basic_machine=v70-nec
- os=sysv
+ basic_os=sysv
;;
nh3000)
basic_machine=m68k-harris
- os=cxux
+ basic_os=cxux
;;
nh[45]000)
basic_machine=m88k-harris
- os=cxux
+ basic_os=cxux
;;
nindy960)
basic_machine=i960-intel
- os=nindy
+ basic_os=nindy
;;
mon960)
basic_machine=i960-intel
- os=mon960
+ basic_os=mon960
;;
nonstopux)
basic_machine=mips-compaq
- os=nonstopux
+ basic_os=nonstopux
;;
os400)
basic_machine=powerpc-ibm
- os=os400
+ basic_os=os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
- os=ose
+ basic_os=ose
;;
os68k)
basic_machine=m68k-none
- os=os68k
+ basic_os=os68k
;;
paragon)
basic_machine=i860-intel
- os=osf
+ basic_os=osf
;;
parisc)
basic_machine=hppa-unknown
- os=linux
+ basic_os=linux
+ ;;
+ psp)
+ basic_machine=mipsallegrexel-sony
+ basic_os=psp
;;
pw32)
basic_machine=i586-unknown
- os=pw32
+ basic_os=pw32
;;
rdos | rdos64)
basic_machine=x86_64-pc
- os=rdos
+ basic_os=rdos
;;
rdos32)
basic_machine=i386-pc
- os=rdos
+ basic_os=rdos
;;
rom68k)
basic_machine=m68k-rom68k
- os=coff
+ basic_os=coff
;;
sa29200)
basic_machine=a29k-amd
- os=udi
+ basic_os=udi
;;
sei)
basic_machine=mips-sei
- os=seiux
+ basic_os=seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ basic_os=
;;
sps7)
basic_machine=m68k-bull
- os=sysv2
+ basic_os=sysv2
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ basic_os=
;;
stratus)
basic_machine=i860-stratus
- os=sysv4
+ basic_os=sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ basic_os=
;;
sun2os3)
basic_machine=m68000-sun
- os=sunos3
+ basic_os=sunos3
;;
sun2os4)
basic_machine=m68000-sun
- os=sunos4
+ basic_os=sunos4
+ ;;
+ sun3)
+ basic_machine=m68k-sun
+ basic_os=
;;
sun3os3)
basic_machine=m68k-sun
- os=sunos3
+ basic_os=sunos3
;;
sun3os4)
basic_machine=m68k-sun
- os=sunos4
+ basic_os=sunos4
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ basic_os=
;;
sun4os3)
basic_machine=sparc-sun
- os=sunos3
+ basic_os=sunos3
;;
sun4os4)
basic_machine=sparc-sun
- os=sunos4
+ basic_os=sunos4
;;
sun4sol2)
basic_machine=sparc-sun
- os=solaris2
+ basic_os=solaris2
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ basic_os=
;;
sv1)
basic_machine=sv1-cray
- os=unicos
+ basic_os=unicos
;;
symmetry)
basic_machine=i386-sequent
- os=dynix
+ basic_os=dynix
;;
t3e)
basic_machine=alphaev5-cray
- os=unicos
+ basic_os=unicos
;;
t90)
basic_machine=t90-cray
- os=unicos
+ basic_os=unicos
;;
toad1)
basic_machine=pdp10-xkl
- os=tops20
+ basic_os=tops20
;;
tpf)
basic_machine=s390x-ibm
- os=tpf
+ basic_os=tpf
;;
udi29k)
basic_machine=a29k-amd
- os=udi
+ basic_os=udi
;;
ultra3)
basic_machine=a29k-nyu
- os=sym1
+ basic_os=sym1
;;
v810 | necv810)
basic_machine=v810-nec
- os=none
+ basic_os=none
;;
vaxv)
basic_machine=vax-dec
- os=sysv
+ basic_os=sysv
;;
vms)
basic_machine=vax-dec
- os=vms
+ basic_os=vms
+ ;;
+ vsta)
+ basic_machine=i386-pc
+ basic_os=vsta
;;
vxworks960)
basic_machine=i960-wrs
- os=vxworks
+ basic_os=vxworks
;;
vxworks68)
basic_machine=m68k-wrs
- os=vxworks
+ basic_os=vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
- os=vxworks
+ basic_os=vxworks
;;
xbox)
basic_machine=i686-pc
- os=mingw32
+ basic_os=mingw32
;;
ymp)
basic_machine=ymp-cray
- os=unicos
+ basic_os=unicos
;;
*)
basic_machine=$1
- os=
+ basic_os=
;;
esac
;;
esac
-# Decode aliases for certain CPU-COMPANY combinations.
+# Decode 1-component or ad-hoc basic machines
case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | aarch64 | aarch64_be \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arceb \
- | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \
- | avr | avr32 \
- | ba \
- | be32 | be64 \
- | bfin \
- | c4x | c8051 | clipper | csky \
- | d10v | d30v | dlx | dsp16xx \
- | e2k | epiphany \
- | fido | fr30 | frv | ft32 \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | hexagon \
- | i370 | i860 | i960 | ia16 | ia64 \
- | ip2k | iq2000 \
- | k1om \
- | le32 | le64 \
- | lm32 \
- | m32c | m32r | m32rle | m68000 | m68k | m88k \
- | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64octeon | mips64octeonel \
- | mips64orion | mips64orionel \
- | mips64r5900 | mips64r5900el \
- | mips64vr | mips64vrel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa32r6 | mipsisa32r6el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64r6 | mipsisa64r6el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipsr5900 | mipsr5900el \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | moxie \
- | mt \
- | msp430 \
- | nds32 | nds32le | nds32be \
- | nfp \
- | nios | nios2 | nios2eb | nios2el \
- | ns16k | ns32k \
- | open8 | or1k | or1knd | or32 \
- | pdp10 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle \
- | pru \
- | pyramid \
- | riscv | riscv32 | riscv64 \
- | rl78 | rx \
- | score \
- | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
- | spu \
- | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
- | ubicom32 \
- | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
- | visium \
- | wasm32 \
- | x86 | xc16x | xstormy16 | xtensa \
- | z8k | z80)
- basic_machine=$basic_machine-unknown
- ;;
- c54x)
- basic_machine=tic54x-unknown
- ;;
- c55x)
- basic_machine=tic55x-unknown
- ;;
- c6x)
- basic_machine=tic6x-unknown
- ;;
- leon|leon[3-9])
- basic_machine=sparc-$basic_machine
- ;;
- m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
- basic_machine=$basic_machine-unknown
- os=${os:-none}
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
+ # Here we handle the default manufacturer of certain CPU types. It is in
+ # some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ cpu=hppa1.1
+ vendor=winbond
;;
- m9s12z | m68hcs12z | hcs12z | s12z)
- basic_machine=s12z-unknown
- os=${os:-none}
+ op50n)
+ cpu=hppa1.1
+ vendor=oki
;;
- ms1)
- basic_machine=mt-unknown
+ op60c)
+ cpu=hppa1.1
+ vendor=oki
;;
- strongarm | thumb | xscale)
- basic_machine=arm-unknown
+ ibm*)
+ cpu=i370
+ vendor=ibm
;;
- xgate)
- basic_machine=$basic_machine-unknown
- os=${os:-none}
+ orion105)
+ cpu=clipper
+ vendor=highlevel
;;
- xscaleeb)
- basic_machine=armeb-unknown
+ mac | mpw | mac-mpw)
+ cpu=m68k
+ vendor=apple
;;
-
- xscaleel)
- basic_machine=armel-unknown
+ pmac | pmac-mpw)
+ cpu=powerpc
+ vendor=apple
;;
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- basic_machine=$basic_machine-pc
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | aarch64-* | aarch64_be-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* | avr32-* \
- | ba-* \
- | be32-* | be64-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* \
- | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | e2k-* | elxsi-* \
- | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | hexagon-* \
- | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
- | ip2k-* | iq2000-* \
- | k1om-* \
- | le32-* | le64-* \
- | lm32-* \
- | m32c-* | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
- | microblaze-* | microblazeel-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64octeon-* | mips64octeonel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64r5900-* | mips64r5900el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa32r6-* | mipsisa32r6el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64r6-* | mipsisa64r6el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipsr5900-* | mipsr5900el-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | mt-* \
- | msp430-* \
- | nds32-* | nds32le-* | nds32be-* \
- | nfp-* \
- | nios-* | nios2-* | nios2eb-* | nios2el-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | open8-* \
- | or1k*-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
- | pru-* \
- | pyramid-* \
- | riscv-* | riscv32-* | riscv64-* \
- | rl78-* | romp-* | rs6000-* | rx-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
- | tahoe-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tile*-* \
- | tron-* \
- | ubicom32-* \
- | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
- | vax-* \
- | visium-* \
- | wasm32-* \
- | we32k-* \
- | x86-* | x86_64-* | xc16x-* | xps100-* \
- | xstormy16-* | xtensa*-* \
- | ymp-* \
- | z8k-* | z80-*)
- ;;
- # Recognize the basic CPU types without company name, with glob match.
- xtensa*)
- basic_machine=$basic_machine-unknown
- ;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
+ cpu=m68000
+ vendor=att
;;
3b*)
- basic_machine=we32k-att
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
- amd64-*)
- basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- asmjs)
- basic_machine=asmjs-unknown
- ;;
- blackfin-*)
- basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=linux
+ cpu=we32k
+ vendor=att
;;
bluegene*)
- basic_machine=powerpc-ibm
- os=cnk
- ;;
- c54x-*)
- basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- c55x-*)
- basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- c6x-*)
- basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- ;;
- c90)
- basic_machine=c90-cray
- os=${os:-unicos}
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=bsd
- ;;
- cr16 | cr16-*)
- basic_machine=cr16-unknown
- os=${os:-elf}
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=${os:-elf}
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
+ cpu=powerpc
+ vendor=ibm
+ basic_os=cnk
;;
decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=tops10
+ cpu=pdp10
+ vendor=dec
+ basic_os=tops10
;;
decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=tops20
+ cpu=pdp10
+ vendor=dec
+ basic_os=tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=${os:-bosx}
+ cpu=m68k
+ vendor=motorola
;;
dpx2*)
- basic_machine=m68k-bull
- os=sysv3
- ;;
- e500v[12])
- basic_machine=powerpc-unknown
- os=$os"spe"
- ;;
- e500v[12]-*)
- basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=$os"spe"
+ cpu=m68k
+ vendor=bull
+ basic_os=sysv3
;;
encore | umax | mmax)
- basic_machine=ns32k-encore
+ cpu=ns32k
+ vendor=encore
;;
elxsi)
- basic_machine=elxsi-elxsi
- os=${os:-bsd}
+ cpu=elxsi
+ vendor=elxsi
+ basic_os=${basic_os:-bsd}
;;
fx2800)
- basic_machine=i860-alliant
+ cpu=i860
+ vendor=alliant
;;
genix)
- basic_machine=ns32k-ns
+ cpu=ns32k
+ vendor=ns
;;
h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=hiuxwe2
- ;;
- hp300-*)
- basic_machine=m68k-hp
+ cpu=hppa1.1
+ vendor=hitachi
+ basic_os=hiuxwe2
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
+ cpu=hppa1.0
+ vendor=hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
+ cpu=m68000
+ vendor=hp
;;
hp9k3[2-9][0-9])
- basic_machine=m68k-hp
+ cpu=m68k
+ vendor=hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
+ cpu=hppa1.0
+ vendor=hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
+ cpu=hppa1.1
+ vendor=hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
+ cpu=hppa1.1
+ vendor=hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
+ cpu=hppa1.1
+ vendor=hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
+ cpu=hppa1.1
+ vendor=hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
+ cpu=hppa1.0
+ vendor=hp
;;
i*86v32)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=sysv32
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=sysv32
;;
i*86v4*)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=sysv4
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=sysv4
;;
i*86v)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=sysv
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=sysv
;;
i*86sol2)
- basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
- os=solaris2
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
+ vendor=pc
+ basic_os=solaris2
;;
j90 | j90-cray)
- basic_machine=j90-cray
- os=${os:-unicos}
+ cpu=j90
+ vendor=cray
+ basic_os=${basic_os:-unicos}
;;
iris | iris4d)
- basic_machine=mips-sgi
- case $os in
+ cpu=mips
+ vendor=sgi
+ case $basic_os in
irix*)
;;
*)
- os=irix4
+ basic_os=irix4
;;
esac
;;
- leon-*|leon[3-9]-*)
- basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
- ;;
- m68knommu-*)
- basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=linux
- ;;
- microblaze*)
- basic_machine=microblaze-xilinx
- ;;
miniframe)
- basic_machine=m68000-convergent
+ cpu=m68000
+ vendor=convergent
;;
*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=mint
- ;;
- mips3*-*)
- basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
- ;;
- ms1-*)
- basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
+ cpu=m68k
+ vendor=atari
+ basic_os=mint
;;
news-3600 | risc-news)
- basic_machine=mips-sony
- os=newsos
+ cpu=mips
+ vendor=sony
+ basic_os=newsos
;;
next | m*-next)
- basic_machine=m68k-next
- case $os in
- nextstep* )
+ cpu=m68k
+ vendor=next
+ case $basic_os in
+ openstep*)
+ ;;
+ nextstep*)
;;
ns2*)
- os=nextstep2
+ basic_os=nextstep2
;;
*)
- os=nextstep3
+ basic_os=nextstep3
;;
esac
;;
np1)
- basic_machine=np1-gould
+ cpu=np1
+ vendor=gould
;;
- neo-tandem)
- basic_machine=neo-tandem
+ op50n-* | op60c-*)
+ cpu=hppa1.1
+ vendor=oki
+ basic_os=proelf
;;
- nse-tandem)
- basic_machine=nse-tandem
+ pa-hitachi)
+ cpu=hppa1.1
+ vendor=hitachi
+ basic_os=hiuxwe2
;;
- nsr-tandem)
- basic_machine=nsr-tandem
+ pbd)
+ cpu=sparc
+ vendor=tti
;;
- nsv-tandem)
- basic_machine=nsv-tandem
+ pbb)
+ cpu=m68k
+ vendor=tti
;;
- nsx-tandem)
- basic_machine=nsx-tandem
+ pc532)
+ cpu=ns32k
+ vendor=pc532
;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=proelf
+ pn)
+ cpu=pn
+ vendor=gould
;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
+ power)
+ cpu=power
+ vendor=ibm
;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=hiuxwe2
+ ps2)
+ cpu=i386
+ vendor=ibm
;;
- parisc-*)
- basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
- os=linux
+ rm[46]00)
+ cpu=mips
+ vendor=siemens
;;
- pbd)
- basic_machine=sparc-tti
+ rtpc | rtpc-*)
+ cpu=romp
+ vendor=ibm
;;
- pbb)
- basic_machine=m68k-tti
+ sde)
+ cpu=mipsisa32
+ vendor=sde
+ basic_os=${basic_os:-elf}
;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
+ simso-wrs)
+ cpu=sparclite
+ vendor=wrs
+ basic_os=vxworks
;;
- pc98)
- basic_machine=i386-pc
+ tower | tower-32)
+ cpu=m68k
+ vendor=ncr
;;
- pc98-*)
- basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ vpp*|vx|vx-*)
+ cpu=f301
+ vendor=fujitsu
;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
+ w65)
+ cpu=w65
+ vendor=wdc
;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
+ w89k-*)
+ cpu=hppa1.1
+ vendor=winbond
+ basic_os=proelf
;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
+ none)
+ cpu=none
+ vendor=none
;;
- pentium4)
- basic_machine=i786-pc
+ leon|leon[3-9])
+ cpu=sparc
+ vendor=$basic_machine
;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ leon-*|leon[3-9]-*)
+ cpu=sparc
+ vendor=`echo "$basic_machine" | sed 's/-.*//'`
;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+
+ *-*)
+ # shellcheck disable=SC2162
+ saved_IFS=$IFS
+ IFS="-" read cpu vendor <<EOF
+$basic_machine
+EOF
+ IFS=$saved_IFS
;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ cpu=$basic_machine
+ vendor=pc
;;
- pentium4-*)
- basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ # These rules are duplicated from below for sake of the special case above;
+ # i.e. things that normalized to x86 arches should also default to "pc"
+ pc98)
+ cpu=i386
+ vendor=pc
;;
- pn)
- basic_machine=pn-gould
+ x64 | amd64)
+ cpu=x86_64
+ vendor=pc
;;
- power) basic_machine=power-ibm
+ # Recognize the basic CPU types without company name.
+ *)
+ cpu=$basic_machine
+ vendor=unknown
;;
- ppc | ppcbe) basic_machine=powerpc-unknown
+esac
+
+unset -v basic_machine
+
+# Decode basic machines in the full and proper CPU-Company form.
+case $cpu-$vendor in
+ # Here we handle the default manufacturer of certain CPU types in canonical form. It is in
+ # some cases the only manufacturer, in others, it is the most popular.
+ craynv-unknown)
+ vendor=cray
+ basic_os=${basic_os:-unicosmp}
;;
- ppc-* | ppcbe-*)
- basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ c90-unknown | c90-cray)
+ vendor=cray
+ basic_os=${Basic_os:-unicos}
;;
- ppcle | powerpclittle)
- basic_machine=powerpcle-unknown
+ fx80-unknown)
+ vendor=alliant
;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ romp-unknown)
+ vendor=ibm
;;
- ppc64) basic_machine=powerpc64-unknown
+ mmix-unknown)
+ vendor=knuth
;;
- ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ microblaze-unknown | microblazeel-unknown)
+ vendor=xilinx
;;
- ppc64le | powerpc64little)
- basic_machine=powerpc64le-unknown
+ rs6000-unknown)
+ vendor=ibm
;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ vax-unknown)
+ vendor=dec
;;
- ps2)
- basic_machine=i386-ibm
+ pdp11-unknown)
+ vendor=dec
;;
- rm[46]00)
- basic_machine=mips-siemens
+ we32k-unknown)
+ vendor=att
;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
+ cydra-unknown)
+ vendor=cydrome
;;
- s390 | s390-*)
- basic_machine=s390-ibm
+ i370-ibm*)
+ vendor=ibm
;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
+ orion-unknown)
+ vendor=highlevel
;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
+ xps-unknown | xps100-unknown)
+ cpu=xps100
+ vendor=honeywell
;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
+
+ # Here we normalize CPU types with a missing or matching vendor
+ armh-unknown | armh-alt)
+ cpu=armv7l
+ vendor=alt
+ basic_os=${basic_os:-linux-gnueabihf}
;;
- sde)
- basic_machine=mipsisa32-sde
- os=${os:-elf}
+ dpx20-unknown | dpx20-bull)
+ cpu=rs6000
+ vendor=bull
+ basic_os=${basic_os:-bosx}
;;
- sequent)
- basic_machine=i386-sequent
+
+ # Here we normalize CPU types irrespective of the vendor
+ amd64-*)
+ cpu=x86_64
;;
- sh5el)
- basic_machine=sh5le-unknown
+ blackfin-*)
+ cpu=bfin
+ basic_os=linux
;;
- simso-wrs)
- basic_machine=sparclite-wrs
- os=vxworks
+ c54x-*)
+ cpu=tic54x
;;
- spur)
- basic_machine=spur-unknown
+ c55x-*)
+ cpu=tic55x
;;
- st2000)
- basic_machine=m68k-tandem
+ c6x-*)
+ cpu=tic6x
;;
- strongarm-* | thumb-*)
- basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+ e500v[12]-*)
+ cpu=powerpc
+ basic_os=${basic_os}"spe"
;;
- sun2)
- basic_machine=m68000-sun
+ mips3*-*)
+ cpu=mips64
;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
+ ms1-*)
+ cpu=mt
;;
- sun4)
- basic_machine=sparc-sun
+ m68knommu-*)
+ cpu=m68k
+ basic_os=linux
;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
+ m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
+ cpu=s12z
;;
- tile*)
- basic_machine=$basic_machine-unknown
- os=linux-gnu
+ openrisc-*)
+ cpu=or32
;;
- tx39)
- basic_machine=mipstx39-unknown
+ parisc-*)
+ cpu=hppa
+ basic_os=linux
;;
- tx39el)
- basic_machine=mipstx39el-unknown
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ cpu=i586
;;
- tower | tower-32)
- basic_machine=m68k-ncr
+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
+ cpu=i686
;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ cpu=i686
;;
- w65*)
- basic_machine=w65-wdc
- os=none
+ pentium4-*)
+ cpu=i786
;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=proelf
+ pc98-*)
+ cpu=i386
;;
- x64)
- basic_machine=x86_64-pc
+ ppc-* | ppcbe-*)
+ cpu=powerpc
;;
- xps | xps100)
- basic_machine=xps100-honeywell
+ ppcle-* | powerpclittle-*)
+ cpu=powerpcle
;;
- xscale-* | xscalee[bl]-*)
- basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
+ ppc64-*)
+ cpu=powerpc64
;;
- none)
- basic_machine=none-none
- os=${os:-none}
+ ppc64le-* | powerpc64little-*)
+ cpu=powerpc64le
;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
+ sb1-*)
+ cpu=mipsisa64sb1
;;
- op50n)
- basic_machine=hppa1.1-oki
+ sb1el-*)
+ cpu=mipsisa64sb1el
;;
- op60c)
- basic_machine=hppa1.1-oki
+ sh5e[lb]-*)
+ cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
;;
- romp)
- basic_machine=romp-ibm
+ spur-*)
+ cpu=spur
;;
- mmix)
- basic_machine=mmix-knuth
+ strongarm-* | thumb-*)
+ cpu=arm
;;
- rs6000)
- basic_machine=rs6000-ibm
+ tx39-*)
+ cpu=mipstx39
;;
- vax)
- basic_machine=vax-dec
+ tx39el-*)
+ cpu=mipstx39el
;;
- pdp11)
- basic_machine=pdp11-dec
+ x64-*)
+ cpu=x86_64
;;
- we32k)
- basic_machine=we32k-att
+ xscale-* | xscalee[bl]-*)
+ cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
;;
- sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
+ arm64-* | aarch64le-*)
+ cpu=aarch64
;;
- cydra)
- basic_machine=cydra-cydrome
+
+ # Recognize the canonical CPU Types that limit and/or modify the
+ # company names they are paired with.
+ cr16-*)
+ basic_os=${basic_os:-elf}
;;
- orion)
- basic_machine=orion-highlevel
+ crisv32-* | etraxfs*-*)
+ cpu=crisv32
+ vendor=axis
;;
- orion105)
- basic_machine=clipper-highlevel
+ cris-* | etrax*-*)
+ cpu=cris
+ vendor=axis
;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
+ crx-*)
+ basic_os=${basic_os:-elf}
;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
+ neo-tandem)
+ cpu=neo
+ vendor=tandem
+ ;;
+ nse-tandem)
+ cpu=nse
+ vendor=tandem
;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
+ nsr-tandem)
+ cpu=nsr
+ vendor=tandem
+ ;;
+ nsv-tandem)
+ cpu=nsv
+ vendor=tandem
+ ;;
+ nsx-tandem)
+ cpu=nsx
+ vendor=tandem
+ ;;
+ mipsallegrexel-sony)
+ cpu=mipsallegrexel
+ vendor=sony
;;
+ tile*-*)
+ basic_os=${basic_os:-linux-gnu}
+ ;;
+
*)
- echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
- exit 1
+ # Recognize the canonical CPU types that are allowed with any
+ # company name.
+ case $cpu in
+ 1750a | 580 \
+ | a29k \
+ | aarch64 | aarch64_be \
+ | abacus \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
+ | alphapca5[67] | alpha64pca5[67] \
+ | am33_2.0 \
+ | amdgcn \
+ | arc | arceb | arc32 | arc64 \
+ | arm | arm[lb]e | arme[lb] | armv* \
+ | avr | avr32 \
+ | asmjs \
+ | ba \
+ | be32 | be64 \
+ | bfin | bpf | bs2000 \
+ | c[123]* | c30 | [cjt]90 | c4x \
+ | c8051 | clipper | craynv | csky | cydra \
+ | d10v | d30v | dlx | dsp16xx \
+ | e2k | elxsi | epiphany \
+ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
+ | h8300 | h8500 \
+ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | hexagon \
+ | i370 | i*86 | i860 | i960 | ia16 | ia64 \
+ | ip2k | iq2000 \
+ | k1om \
+ | le32 | le64 \
+ | lm32 \
+ | loongarch32 | loongarch64 | loongarchx32 \
+ | m32c | m32r | m32rle \
+ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
+ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
+ | m88110 | m88k | maxq | mb | mcore | mep | metag \
+ | microblaze | microblazeel \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64eb | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa32r3 | mipsisa32r3el \
+ | mipsisa32r5 | mipsisa32r5el \
+ | mipsisa32r6 | mipsisa32r6el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64r3 | mipsisa64r3el \
+ | mipsisa64r5 | mipsisa64r5el \
+ | mipsisa64r6 | mipsisa64r6el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
+ | mipstx39 | mipstx39el \
+ | mmix \
+ | mn10200 | mn10300 \
+ | moxie \
+ | mt \
+ | msp430 \
+ | nds32 | nds32le | nds32be \
+ | nfp \
+ | nios | nios2 | nios2eb | nios2el \
+ | none | np1 | ns16k | ns32k | nvptx \
+ | open8 \
+ | or1k* \
+ | or32 \
+ | orion \
+ | picochip \
+ | pdp10 | pdp11 | pj | pjl | pn | power \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
+ | pru \
+ | pyramid \
+ | riscv | riscv32 | riscv32be | riscv64 | riscv64be \
+ | rl78 | romp | rs6000 | rx \
+ | s390 | s390x \
+ | score \
+ | sh | shl \
+ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
+ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
+ | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
+ | spu \
+ | tahoe \
+ | thumbv7* \
+ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
+ | tron \
+ | ubicom32 \
+ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
+ | vax \
+ | visium \
+ | w65 \
+ | wasm32 | wasm64 \
+ | we32k \
+ | x86 | x86_64 | xc16x | xgate | xps100 \
+ | xstormy16 | xtensa* \
+ | ymp \
+ | z8k | z80)
+ ;;
+
+ *)
+ echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
+ exit 1
+ ;;
+ esac
;;
esac
# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
+case $vendor in
+ digital*)
+ vendor=dec
;;
- *-commodore*)
- basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
+ commodore*)
+ vendor=cbm
;;
*)
;;
@@ -1286,8 +1306,49 @@ esac
# Decode manufacturer-specific aliases for certain operating systems.
-if [ x$os != x ]
+if test x$basic_os != x
then
+
+# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
+# set os.
+case $basic_os in
+ gnu/linux*)
+ kernel=linux
+ os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
+ ;;
+ os2-emx)
+ kernel=os2
+ os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
+ ;;
+ nto-qnx*)
+ kernel=nto
+ os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
+ ;;
+ *-*)
+ # shellcheck disable=SC2162
+ saved_IFS=$IFS
+ IFS="-" read kernel os <<EOF
+$basic_os
+EOF
+ IFS=$saved_IFS
+ ;;
+ # Default OS when just kernel was specified
+ nto*)
+ kernel=nto
+ os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
+ ;;
+ linux*)
+ kernel=linux
+ os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
+ ;;
+ *)
+ kernel=
+ os=$basic_os
+ ;;
+esac
+
+# Now, normalize the OS (knowing we just have one component, it's not a kernel,
+# etc.)
case $os in
# First match some system type aliases that might get confused
# with valid system types.
@@ -1299,7 +1360,7 @@ case $os in
os=cnk
;;
solaris1 | solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
;;
solaris)
os=solaris2
@@ -1307,9 +1368,6 @@ case $os in
unixware*)
os=sysv4.2uw
;;
- gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
# es1800 is here to avoid being matched by es* (a different OS)
es1800*)
os=ose
@@ -1331,12 +1389,9 @@ case $os in
os=sco3.2v4
;;
sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
;;
- sco3.2v[4-9]* | sco5v6*)
- # Don't forget version if it is 3.2v4 or newer.
- ;;
- scout)
+ sco*v* | scout)
# Don't match below
;;
sco*)
@@ -1345,77 +1400,25 @@ case $os in
psos*)
os=psos
;;
- # Now accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST end in a * to match a version number.
- # sysv* is not here because it comes later, after sysvr4.
- gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
- | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
- | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
- | sym* | kopensolaris* | plan9* \
- | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
- | aos* | aros* | cloudabi* | sortix* \
- | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
- | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \
- | knetbsd* | mirbsd* | netbsd* \
- | bitrig* | openbsd* | solidbsd* | libertybsd* \
- | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
- | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
- | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
- | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
- | chorusrdb* | cegcc* | glidix* \
- | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
- | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
- | linux-newlib* | linux-musl* | linux-uclibc* \
- | uxpv* | beos* | mpeix* | udk* | moxiebox* \
- | interix* | uwin* | mks* | rhapsody* | darwin* \
- | openstep* | oskit* | conix* | pw32* | nonstopux* \
- | storm-chaos* | tops10* | tenex* | tops20* | its* \
- | os2* | vos* | palmos* | uclinux* | nucleus* \
- | morphos* | superux* | rtmk* | windiss* \
- | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
- | skyos* | haiku* | rdos* | toppers* | drops* | es* \
- | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
- | midnightbsd*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
qnx*)
- case $basic_machine in
- x86-* | i*86-*)
- ;;
- *)
- os=nto-$os
- ;;
- esac
+ os=qnx
;;
hiux*)
os=hiuxwe2
;;
- nto-qnx*)
- ;;
- nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- sim | xray | os68k* | v88r* \
- | windows* | osx | abug | netware* | os9* \
- | macos* | mpw* | magic* | mmixware* | mon960* | lnews*)
- ;;
- linux-dietlibc)
- os=linux-dietlibc
- ;;
- linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
lynx*178)
os=lynxos178
;;
lynx*5)
os=lynxos5
;;
+ lynxos*)
+ # don't get caught up in next wildcard
+ ;;
lynx*)
os=lynxos
;;
- mac*)
+ mac[0-9]*)
os=`echo "$os" | sed -e 's|mac|macos|'`
;;
opened*)
@@ -1460,12 +1463,9 @@ case $os in
ns2)
os=nextstep2
;;
- nsk*)
- os=nsk
- ;;
# Preserve the version number of sinix5.
sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
+ os=`echo "$os" | sed -e 's|sinix|sysv|'`
;;
sinix*)
os=sysv4
@@ -1488,18 +1488,12 @@ case $os in
sysvr4)
os=sysv4
;;
- # This must come after sysvr4.
- sysv*)
- ;;
ose*)
os=ose
;;
*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
os=mint
;;
- zvmoe)
- os=zvmoe
- ;;
dicos*)
os=dicos
;;
@@ -1507,7 +1501,7 @@ case $os in
# Until real need of OS specific support for
# particular features comes up, bare metal
# configurations are quite functional.
- case $basic_machine in
+ case $cpu in
arm*)
os=eabi
;;
@@ -1516,19 +1510,11 @@ case $os in
;;
esac
;;
- nacl*)
- ;;
- ios)
- ;;
- none)
- ;;
- *-eabi)
- ;;
*)
- echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
- exit 1
+ # No normalization, but not necessarily accepted, that comes below.
;;
esac
+
else
# Here we handle the default operating systems that come with various machines.
@@ -1541,7 +1527,8 @@ else
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
-case $basic_machine in
+kernel=
+case $cpu-$vendor in
score-*)
os=elf
;;
@@ -1552,7 +1539,8 @@ case $basic_machine in
os=riscix1.2
;;
arm*-rebel)
- os=linux
+ kernel=linux
+ os=gnu
;;
arm*-semi)
os=aout
@@ -1718,86 +1706,180 @@ case $basic_machine in
os=none
;;
esac
+
fi
+# Now, validate our (potentially fixed-up) OS.
+case $os in
+ # Sometimes we do "kernel-libc", so those need to count as OSes.
+ musl* | newlib* | relibc* | uclibc*)
+ ;;
+ # Likewise for "kernel-abi"
+ eabi* | gnueabi*)
+ ;;
+ # VxWorks passes extra cpu info in the 4th filed.
+ simlinux | simwindows | spe)
+ ;;
+ # Now accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST end in a * to match a version number.
+ gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
+ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
+ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
+ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
+ | hiux* | abug | nacl* | netware* | windows* \
+ | os9* | macos* | osx* | ios* \
+ | mpw* | magic* | mmixware* | mon960* | lnews* \
+ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
+ | aos* | aros* | cloudabi* | sortix* | twizzler* \
+ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
+ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
+ | mirbsd* | netbsd* | dicos* | openedition* | ose* \
+ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
+ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
+ | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
+ | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
+ | udi* | lites* | ieee* | go32* | aux* | hcos* \
+ | chorusrdb* | cegcc* | glidix* | serenity* \
+ | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
+ | midipix* | mingw32* | mingw64* | mint* \
+ | uxpv* | beos* | mpeix* | udk* | moxiebox* \
+ | interix* | uwin* | mks* | rhapsody* | darwin* \
+ | openstep* | oskit* | conix* | pw32* | nonstopux* \
+ | storm-chaos* | tops10* | tenex* | tops20* | its* \
+ | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
+ | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
+ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
+ | skyos* | haiku* | rdos* | toppers* | drops* | es* \
+ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
+ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
+ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
+ | fiwix* )
+ ;;
+ # This one is extra strict with allowed versions
+ sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ ;;
+ none)
+ ;;
+ *)
+ echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# As a final step for OS-related things, validate the OS-kernel combination
+# (given a valid OS), if there is a kernel.
+case $kernel-$os in
+ linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
+ | linux-musl* | linux-relibc* | linux-uclibc* )
+ ;;
+ uclinux-uclibc* )
+ ;;
+ -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
+ # These are just libc implementations, not actual OSes, and thus
+ # require a kernel.
+ echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
+ exit 1
+ ;;
+ kfreebsd*-gnu* | kopensolaris*-gnu*)
+ ;;
+ vxworks-simlinux | vxworks-simwindows | vxworks-spe)
+ ;;
+ nto-qnx*)
+ ;;
+ os2-emx)
+ ;;
+ *-eabi* | *-gnueabi*)
+ ;;
+ -*)
+ # Blank kernel with real OS is always fine.
+ ;;
+ *-*)
+ echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
+ exit 1
+ ;;
+esac
+
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- riscix*)
+case $vendor in
+ unknown)
+ case $cpu-$os in
+ *-riscix*)
vendor=acorn
;;
- sunos*)
+ *-sunos*)
vendor=sun
;;
- cnk*|-aix*)
+ *-cnk* | *-aix*)
vendor=ibm
;;
- beos*)
+ *-beos*)
vendor=be
;;
- hpux*)
+ *-hpux*)
vendor=hp
;;
- mpeix*)
+ *-mpeix*)
vendor=hp
;;
- hiux*)
+ *-hiux*)
vendor=hitachi
;;
- unos*)
+ *-unos*)
vendor=crds
;;
- dgux*)
+ *-dgux*)
vendor=dg
;;
- luna*)
+ *-luna*)
vendor=omron
;;
- genix*)
+ *-genix*)
vendor=ns
;;
- clix*)
+ *-clix*)
vendor=intergraph
;;
- mvs* | opened*)
+ *-mvs* | *-opened*)
+ vendor=ibm
+ ;;
+ *-os400*)
vendor=ibm
;;
- os400*)
+ s390-* | s390x-*)
vendor=ibm
;;
- ptx*)
+ *-ptx*)
vendor=sequent
;;
- tpf*)
+ *-tpf*)
vendor=ibm
;;
- vxsim* | vxworks* | windiss*)
+ *-vxsim* | *-vxworks* | *-windiss*)
vendor=wrs
;;
- aux*)
+ *-aux*)
vendor=apple
;;
- hms*)
+ *-hms*)
vendor=hitachi
;;
- mpw* | macos*)
+ *-mpw* | *-macos*)
vendor=apple
;;
- *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
vendor=atari
;;
- vos*)
+ *-vos*)
vendor=stratus
;;
esac
- basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
;;
esac
-echo "$basic_machine-$os"
+echo "$cpu-$vendor-${kernel:+$kernel-}$os"
exit
# Local variables:
diff --git a/configure b/configure
index d85be30f..c5db50b9 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 for pcap 1.10.0-PRE-GIT.
+# Generated by GNU Autoconf 2.69 for pcap 1.11.0-PRE-GIT.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='pcap'
PACKAGE_TARNAME='pcap'
-PACKAGE_VERSION='1.10.0-PRE-GIT'
-PACKAGE_STRING='pcap 1.10.0-PRE-GIT'
+PACKAGE_VERSION='1.11.0-PRE-GIT'
+PACKAGE_STRING='pcap 1.11.0-PRE-GIT'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -625,8 +625,12 @@ INSTALL_SCRIPT
INSTALL_PROGRAM
PCAP_SUPPORT_RDMASNIFF
PCAP_SUPPORT_DBUS
+DBUS_LIBS
+DBUS_CFLAGS
PCAP_SUPPORT_BT
PCAP_SUPPORT_DPDK
+DPDK_LIBS
+DPDK_CFLAGS
PCAP_SUPPORT_NETMAP
PCAP_SUPPORT_NETFILTER
PCAP_SUPPORT_LINUX_USBMON
@@ -666,12 +670,18 @@ LN_S
AR
RANLIB
REENTRANT_PARSER
-YFLAGS
-YACC
+BISON_BYACC
LEXLIB
LEX_OUTPUT_ROOT
LEX
-PKGCONFIG
+OPENSSL_LIBS
+OPENSSL_CFLAGS
+LIBNL_LIBS
+LIBNL_CFLAGS
+BREW
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
VALGRINDTEST_SRC
LIBOBJS
EGREP
@@ -779,8 +789,17 @@ CXX
CXXFLAGS
CCC
CPP
-YACC
-YFLAGS'
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+LIBNL_CFLAGS
+LIBNL_LIBS
+OPENSSL_CFLAGS
+OPENSSL_LIBS
+DPDK_CFLAGS
+DPDK_LIBS
+DBUS_CFLAGS
+DBUS_LIBS'
# Initialize some variables set by options.
@@ -1321,7 +1340,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures pcap 1.10.0-PRE-GIT to adapt to many kinds of systems.
+\`configure' configures pcap 1.11.0-PRE-GIT to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1387,7 +1406,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of pcap 1.10.0-PRE-GIT:";;
+ short | recursive ) echo "Configuration of pcap 1.11.0-PRE-GIT:";;
esac
cat <<\_ACEOF
@@ -1399,7 +1418,6 @@ Optional Features:
--disable-protochain disable \"protochain\" insn
--enable-ipv6 build IPv6-capable version [default=yes]
--enable-remote enable remote packet capture [default=no]
- --disable-remote disable remote packet capture
--enable-optimizer-dbg build optimizer debugging code
--enable-yydebug build parser debugging code
--disable-universal don't build universal on macOS
@@ -1454,12 +1472,22 @@ Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CPP C preprocessor
- YACC The `Yet Another Compiler Compiler' implementation to use.
- Defaults to the first program found out of: `bison -y', `byacc',
- `yacc'.
- YFLAGS The list of arguments that will be passed by default to $YACC.
- This script will default YFLAGS to the empty string to avoid a
- default value of `-d' given by some make applications.
+ PKG_CONFIG path to pkg-config utility
+ PKG_CONFIG_PATH
+ directories to add to pkg-config's search path
+ PKG_CONFIG_LIBDIR
+ path overriding pkg-config's built-in search path
+ LIBNL_CFLAGS
+ C compiler flags for libnl-genl-3.0, overriding pkg-config
+ LIBNL_LIBS linker flags for libnl-genl-3.0, overriding pkg-config
+ OPENSSL_CFLAGS
+ C compiler flags for openssl, overriding pkg-config
+ OPENSSL_LIBS
+ linker flags for openssl, overriding pkg-config
+ DPDK_CFLAGS C compiler flags for libdpdk, overriding pkg-config
+ DPDK_LIBS linker flags for libdpdk, overriding pkg-config
+ DBUS_CFLAGS C compiler flags for dbus-1, overriding pkg-config
+ DBUS_LIBS linker flags for dbus-1, overriding pkg-config
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -1527,7 +1555,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-pcap configure 1.10.0-PRE-GIT
+pcap configure 1.11.0-PRE-GIT
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1617,52 +1645,6 @@ fi
} # ac_fn_cxx_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.
@@ -2087,7 +2069,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by pcap $as_me 1.10.0-PRE-GIT, which was
+It was created by pcap $as_me 1.11.0-PRE-GIT, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3910,28 +3892,36 @@ esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5
$as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden"
- elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
- elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
- else
- CFLAGS="$CFLAGS -fvisibility=hidden"
- fi
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -3987,6 +3977,7 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
else
V_INCLS="$V_INCLS -I/usr/local/include"
@@ -4010,28 +4001,36 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5
$as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden"
- elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
- elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
- else
- CFLAGS="$CFLAGS -fvisibility=hidden"
- fi
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -4087,6 +4086,7 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
;;
@@ -4172,28 +4172,36 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -xldscope=hidden option" >&5
$as_echo_n "checking whether the compiler supports the -xldscope=hidden option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-xldscope=hidden" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -xldscope=hidden"
- elif expr "x-xldscope=hidden" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -xldscope=hidden"
- elif expr "x-xldscope=hidden" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -xldscope=hidden"
- else
- CFLAGS="$CFLAGS -xldscope=hidden"
- fi
+ CFLAGS="$CFLAGS -xldscope=hidden"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -4249,6 +4257,7 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
;;
@@ -4500,6 +4509,125 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load_n" >&5
+$as_echo_n "checking for __atomic_load_n... " >&6; }
+ if ${ac_cv_have___atomic_load_n+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# 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
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ int i = 17;
+ int j;
+ j = __atomic_load_n(&i, __ATOMIC_RELAXED);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_have___atomic_load_n=yes
+else
+ ac_have___atomic_load_n=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_load_n" >&5
+$as_echo "$ac_have___atomic_load_n" >&6; }
+ if test $ac_have___atomic_load_n = yes ; then
+
+$as_echo "#define HAVE___ATOMIC_LOAD_N 1" >>confdefs.h
+
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_store_n" >&5
+$as_echo_n "checking for __atomic_store_n... " >&6; }
+ if ${ac_cv_have___atomic_store_n+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ int i;
+ __atomic_store_n(&i, 17, __ATOMIC_RELAXED);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_have___atomic_store_n=yes
+else
+ ac_have___atomic_store_n=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_store_n" >&5
+$as_echo "$ac_have___atomic_store_n" >&6; }
+ if test $ac_have___atomic_store_n = yes ; then
+
+$as_echo "#define HAVE___ATOMIC_STORE_N 1" >>confdefs.h
+
+ fi
+
#
# Try to arrange for large file support.
#
@@ -5194,55 +5322,6 @@ fi
done
-for ac_header in net/pfvar.h
-do :
- ac_fn_c_check_header_compile "$LINENO" "net/pfvar.h" "ac_cv_header_net_pfvar_h" "#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-"
-if test "x$ac_cv_header_net_pfvar_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_NET_PFVAR_H 1
-_ACEOF
-
-fi
-
-done
-
-if test "$ac_cv_header_net_pfvar_h" = yes; then
- #
- # Check for various PF actions.
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether net/pfvar.h defines PF_NAT through PF_NORDR" >&5
-$as_echo_n "checking whether net/pfvar.h defines PF_NAT through PF_NORDR... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
- #include <sys/socket.h>
- #include <net/if.h>
- #include <net/pfvar.h>
-int
-main ()
-{
-return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;
- ;
- 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_PF_NAT_THROUGH_PF_NORDR 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
-fi
case "$host_os" in
haiku*)
@@ -6621,24 +6700,78 @@ $as_echo "$V_PCAP" >&6; }
#
# Do we have pkg-config?
#
-# Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
+
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_PKGCONFIG+:} false; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -n "$PKGCONFIG"; then
- ac_cv_prog_PKGCONFIG="$PKGCONFIG" # Let the user override the test.
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+ ac_pt_PKG_CONFIG=$PKG_CONFIG
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+ case $ac_pt_PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_PKGCONFIG="pkg-config"
+ ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -6646,13 +6779,85 @@ done
done
IFS=$as_save_IFS
- test -z "$ac_cv_prog_PKGCONFIG" && ac_cv_prog_PKGCONFIG="no"
+ ;;
+esac
fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
fi
-PKGCONFIG=$ac_cv_prog_PKGCONFIG
-if test -n "$PKGCONFIG"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKGCONFIG" >&5
-$as_echo "$PKGCONFIG" >&6; }
+
+ if test "x$ac_pt_PKG_CONFIG" = x; then
+ PKG_CONFIG=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ PKG_CONFIG=$ac_pt_PKG_CONFIG
+ fi
+else
+ PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=0.9.0
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ PKG_CONFIG=""
+ fi
+fi
+
+#
+# Do we have the brew command from Homebrew?
+#
+# Extract the first word of "brew", so it can be a program name with args.
+set dummy brew; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_BREW+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $BREW in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_BREW="$BREW" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_BREW="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+BREW=$ac_cv_path_BREW
+if test -n "$BREW"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BREW" >&5
+$as_echo "$BREW" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
@@ -6896,29 +7101,129 @@ fi
if test x$with_libnl != xno ; then
- if test "x$PKGCONFIG" != "xno"; then
- #
- # We have pkg-config; see if we have libnl-genl-3.0
- # as a package.
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnl-genl-3.0 with pkg-config" >&5
+ #
+ # Check for libnl-genl-3.0 with pkg-config.
+ #
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnl-genl-3.0 with pkg-config" >&5
$as_echo_n "checking for libnl-genl-3.0 with pkg-config... " >&6; }
- if "$PKGCONFIG" libnl-genl-3.0; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+
+ #
+ # The package was found, so try to get its C flags and
+ # libraries.
+ #
+ if test -n "$LIBNL_CFLAGS"; then
+ pkg_cv_LIBNL_CFLAGS="$LIBNL_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_LIBNL_CFLAGS=`$PKG_CONFIG --cflags "libnl-genl-3.0" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+ if test -n "$LIBNL_LIBS"; then
+ pkg_cv_LIBNL_LIBS="$LIBNL_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_LIBNL_LIBS=`$PKG_CONFIG --libs "libnl-genl-3.0" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+ if test $pkg_failed = yes; then
+ #
+ # That failed - report an error.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5
+$as_echo "error" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ LIBNL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnl-genl-3.0" 2>&1`
+ else
+ LIBNL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnl-genl-3.0" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$LIBNL_PKG_ERRORS" >&5
+
+ as_fn_error $? "Package requirements (libnl-genl-3.0) were not met:
+
+$LIBNL_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+
+Alternatively, you may set the environment variables LIBNL_CFLAGS
+and LIBNL_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+ elif test $pkg_failed = untried; then
+ #
+ # We don't have pkg-config, so it didn't work.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5
+$as_echo "not found (pkg-config not found)" >&6; }
+ else
+ #
+ # We found the package.
+ #
+ LIBNL_CFLAGS=$pkg_cv_LIBNL_CFLAGS
+ LIBNL_LIBS=$pkg_cv_LIBNL_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
- pkg_config_found_libnl=yes
- libnl_genl_cflags=`"$PKGCONFIG" --cflags libnl-genl-3.0`
- V_INCLS="$V_INCLS ${libnl_genl_cflags}"
- libnl_genl_libs=`"$PKGCONFIG" --libs libnl-genl-3.0`
- LIBS="${libnl_genl_libs} $LIBS"
+
+ pkg_config_found_libnl=yes
+ V_INCLS="$V_INCLS $LIBNL_CFLAGS"
+ LIBS="$LIBNL_LIBS $LIBS"
$as_echo "#define HAVE_LIBNL 1" >>confdefs.h
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+
+ fi
+else
+
+ #
+ # The package isn't present.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
- fi
- fi
+
+fi
+
if test x$pkg_config_found_libnl != xyes; then
#
@@ -8154,18 +8459,205 @@ fi
# Optionally, we may want to support SSL.
# Check for OpenSSL/libressl.
#
- # First, try looking for it as a regular system library.
- # Make sure we can find SSL_library_init() using the
- # standard headers, just in case we're running a version
- # of macOS that ships with the OpenSSL library but not
- # the OpenSSL headers, and have also installed another
- # version of OpenSSL with headers.
+ # First, try looking for it with pkg-config, if we have it.
#
- save_LIBS="$LIBS"
- LIBS="-lssl -lcrypto"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have a system OpenSSL/libressl that we can use" >&5
-$as_echo_n "checking whether we have a system OpenSSL/libressl that we can use... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ # Homebrew's pkg-config does not, by default, look for
+ # pkg-config files for packages it has installed.
+ # Furthermore, at least for OpenSSL, they appear to be
+ # dumped in package-specific directories whose paths are
+ # not only package-specific but package-version-specific.
+ #
+ # So the only way to find openssl is to get the value of
+ # PKG_CONFIG_PATH from "brew --env openssl" and add that
+ # to PKG_CONFIG_PATH. (No, we can't just assume it's under
+ # /usr/local; Homebrew have conveniently chosen to put it
+ # under /opt/homebrew on ARM.)
+ #
+ # That's the nice thing about Homebrew - it makes things easier!
+ # Thanks!
+ #
+ save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
+ if test -n "$BREW"; then
+ openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
+ PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
+ fi
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl with pkg-config" >&5
+$as_echo_n "checking for openssl with pkg-config... " >&6; }
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "openssl") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+
+ #
+ # The package was found, so try to get its C flags and
+ # libraries.
+ #
+ if test -n "$OPENSSL_CFLAGS"; then
+ pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "openssl") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+ if test -n "$OPENSSL_LIBS"; then
+ pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "openssl") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+ if test $pkg_failed = yes; then
+ #
+ # That failed - report an error.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5
+$as_echo "error" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl" 2>&1`
+ else
+ OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$OPENSSL_PKG_ERRORS" >&5
+
+ as_fn_error $? "Package requirements (openssl) were not met:
+
+$OPENSSL_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+
+Alternatively, you may set the environment variables OPENSSL_CFLAGS
+and OPENSSL_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+ elif test $pkg_failed = untried; then
+ #
+ # We don't have pkg-config, so it didn't work.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5
+$as_echo "not found (pkg-config not found)" >&6; }
+ else
+ #
+ # We found the package.
+ #
+ OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS
+ OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+$as_echo "found" >&6; }
+
+ #
+ # We found OpenSSL/libressl.
+ #
+ HAVE_OPENSSL=yes
+
+ fi
+else
+
+ #
+ # The package isn't present.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+
+fi
+
+ PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
+
+ #
+ # If it wasn't found, and we have Homebrew installed, see
+ # if it's in Homebrew.
+ #
+ if test "x$HAVE_OPENSSL" != "xyes" -a -n "$BREW"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl in Homebrew" >&5
+$as_echo_n "checking for openssl in Homebrew... " >&6; }
+ #
+ # The brew man page lies when it speaks of
+ # $BREW --prefix --installed <formula>
+ # outputting nothing. In Homebrew 3.3.16,
+ # it produces output regardless of whether
+ # the formula is installed or not, so we
+ # send the standard output and error to
+ # the bit bucket.
+ #
+ if $BREW --prefix --installed openssl >/dev/null 2>&1; then
+ #
+ # Yes. Get the include directory and library
+ # directory. (No, we can't just assume it's
+ # under /usr/local; Homebrew have conveniently
+ # chosen to put it under /opt/homebrew on ARM.)
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ HAVE_OPENSSL=yes
+ openssl_path=`$BREW --prefix openssl`
+ OPENSSL_CFLAGS="-I$openssl_path/include"
+ OPENSSL_LIBS="-L$openssl_path/lib -lssl -lcrypto"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+
+ #
+ # If it wasn't found, and /usr/local/include and /usr/local/lib
+ # exist, check if it's in /usr/local. (We check whether they
+ # exist because, if they don't exist, the compiler will warn
+ # about that and then ignore the argument, so they test
+ # using just the system header files and libraries.)
+ #
+ # We include the standard include file to 1) make sure that
+ # it's installed (if it's just a shared library for the
+ # benefit of existing programs, that's not useful) and 2)
+ # because SSL_library_init() is a library routine in some
+ # versions and a #defined wrapper around OPENSSL_init_ssl()
+ # in others.
+ #
+ if test "x$HAVE_OPENSSL" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS -I/usr/local/include"
+ LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have OpenSSL/libressl in /usr/local that we can use" >&5
+$as_echo_n "checking whether we have OpenSSL/libressl in /usr/local that we can use... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <openssl/ssl.h>
@@ -8183,10 +8675,11 @@ return 0;
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- HAVE_OPENSSL=yes
- OPENSSL_LIBS="-lssl -lcrypto"
+ HAVE_OPENSSL=yes
+ OPENSSL_CFLAGS="-I/usr/local/include"
+ OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -8194,46 +8687,25 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- LIBS="$save_LIBS"
-
- #
- # If we didn't find it, check for it with pkg-config.
- #
- if test "x$HAVE_OPENSSL" != "xyes"; then
- if test "x$PKGCONFIG" != "xno"; then
- #
- # We have pkg-config; see if we have OpenSSL/
- # libressl installed as a package.
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL/libressl with pkg-config" >&5
-$as_echo_n "checking for OpenSSL/libressl with pkg-config... " >&6; }
- if "$PKGCONFIG" openssl; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
-$as_echo "found" >&6; }
- HAVE_OPENSSL=yes
- OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl`
- OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl`
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
- fi
- fi
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
fi
#
- # If we didn't find it, check for it under /usr/local/opt/openssl;
- # that's where Homebrew puts it on macOS. Feel free to add other
- # -L directories as necessary; the "system library" check should
- # also handle "add-on library under /usr/local", so that shouldn't
- # be necessary here.
+ # If it wasn't found, check if it's a system library.
+ #
+ # We include the standard include file to 1) make sure that
+ # it's installed (if it's just a shared library for the
+ # benefit of existing programs, that's not useful) and 2)
+ # because SSL_library_init() is a library routine in some
+ # versions and a #defined wrapper around OPENSSL_init_ssl()
+ # in others.
#
if test "x$HAVE_OPENSSL" != "xyes"; then
- save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
- CFLAGS="$CFLAGS -L/usr/local/opt/openssl/include"
- LIBS="$LIBS -L/usr/local/opt/openssl/lib -lssl -lcrypto"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have OpenSSL/libressl in /usr/local/opt that we can use" >&5
-$as_echo_n "checking whether we have OpenSSL/libressl in /usr/local/opt that we can use... " >&6; }
+ LIBS="$LIBS -lssl -lcrypto"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have a system OpenSSL/libressl that we can use" >&5
+$as_echo_n "checking whether we have a system OpenSSL/libressl that we can use... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -8255,8 +8727,7 @@ if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
HAVE_OPENSSL=yes
- OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
- OPENSSL_LIBS="-L/usr/local/opt/openssl/lib -lssl -lcrypto"
+ OPENSSL_LIBS="-lssl -lcrypto"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -8264,7 +8735,6 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
fi
@@ -8509,23 +8979,38 @@ fi
$as_echo "$tcpdump_cv_capable_lex" >&6; }
if test $tcpdump_cv_capable_lex = insufficient ; then
as_fn_error $? "$LEX is insufficient to compile libpcap.
- libpcap requires Flex 2.5.31 or later, or a compatible version of lex." "$LINENO" 5
+ libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
+ If a suitable version of Lex/Flex is available as a non-standard command
+ and/or not in the PATH, you can specify it using the LEX environment
+ variable. That said, on some systems the error can mean that Flex/Lex is
+ actually acceptable, but m4 is not. Likewise, if a suitable version of
+ m4 (such as GNU M4) is available but has not been detected, you can
+ specify it using the M4 environment variable." "$LINENO" 5
fi
#
# Look for yacc/bison/byacc.
+# If it's Bison, we do not want -y, as 1) we will be using -o to cause
+# the output for XXX.y to be written to XXX.c and 2) we don't want
+# it to issue warnings about stuff not supported by POSIX YACC - we
+# want to use that stuff, and don't care whether plain YACC supports
+# it or not, we require either Bison or Berkeley YACC.
#
-for ac_prog in 'bison -y' byacc
+BISON_BYACC=""
+#
+# Look for Bison.
+#
+for ac_prog in bison
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_YACC+:} false; then :
+if ${ac_cv_prog_BISON_BYACC+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -n "$YACC"; then
- ac_cv_prog_YACC="$YACC" # Let the user override the test.
+ if test -n "$BISON_BYACC"; then
+ ac_cv_prog_BISON_BYACC="$BISON_BYACC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -8534,7 +9019,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_YACC="$ac_prog"
+ ac_cv_prog_BISON_BYACC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -8544,46 +9029,118 @@ IFS=$as_save_IFS
fi
fi
-YACC=$ac_cv_prog_YACC
-if test -n "$YACC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5
-$as_echo "$YACC" >&6; }
+BISON_BYACC=$ac_cv_prog_BISON_BYACC
+if test -n "$BISON_BYACC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON_BYACC" >&5
+$as_echo "$BISON_BYACC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
- test -n "$YACC" && break
+ test -n "$BISON_BYACC" && break
done
-test -n "$YACC" || YACC="yacc"
-
-
-case "$YACC" in
-*yacc)
+if test x"$BISON_BYACC" != x; then
+ #
+ # We found Bison.
+ #
+ # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
+ # "%pure-parser".
#
- # Make sure this is Berkeley YACC, not AT&T YACC; the latter
- # doesn't support reentrant parsers. Run it with "-V";
- # that succeeds and reports the version number with
- # Berkeley YACC, but will (probably) fail with various
- # vendor flavors of AT&T YACC.
+ bison_major_version=`$BISON_BYACC -V | sed -n 's/.* \([1-9][0-9]*\)\.[0-9][0-9.]*/\1/p'`
+ bison_minor_version=`$BISON_BYACC -V | sed -n 's/.* [1-9][0-9]*\.\([0-9]+\).*/\1/p'`
+ if test "$bison_major_version" -lt 2 -o \
+ \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
+ then
+ REENTRANT_PARSER="%pure-parser"
+ else
+ REENTRANT_PARSER="%define api.pure"
+ fi
+else
+ #
+ # We didn't find Bison; check for Berkeley YACC, under the
+ # names byacc and yacc.
#
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc" >&5
+ for ac_prog in byacc yacc
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_BISON_BYACC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$BISON_BYACC"; then
+ ac_cv_prog_BISON_BYACC="$BISON_BYACC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_BISON_BYACC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+BISON_BYACC=$ac_cv_prog_BISON_BYACC
+if test -n "$BISON_BYACC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON_BYACC" >&5
+$as_echo "$BISON_BYACC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$BISON_BYACC" && break
+done
+
+ if test x"$BISON_BYACC" != x; then
+ #
+ # Make sure this is Berkeley YACC, not AT&T YACC;
+ # the latter doesn't support reentrant parsers.
+ # Run it with "-V"; that succeeds and reports the
+ # version number with Berkeley YACC, but will
+ # (probably) fail with various vendor flavors
+ # of AT&T YACC.
+ #
+ # Hopefully this also eliminates any versions
+ # of Berkeley YACC that don't support reentrant
+ # parsers, if there are any.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc" >&5
$as_echo_n "checking for capable yacc... " >&6; }
if ${tcpdump_cv_capable_yacc+:} false; then :
$as_echo_n "(cached) " >&6
else
- if $YACC -V >/dev/null 2>&1; then
- tcpdump_cv_capable_yacc=yes
- else
- tcpdump_cv_capable_yacc=insufficient
- fi
+ if $BISON_BYACC -V >/dev/null 2>&1; then
+ tcpdump_cv_capable_yacc=yes
+ else
+ tcpdump_cv_capable_yacc=insufficient
+ fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_yacc" >&5
$as_echo "$tcpdump_cv_capable_yacc" >&6; }
- if test $tcpdump_cv_capable_yacc = insufficient ; then
- as_fn_error $? "$YACC is insufficient to compile libpcap.
+ if test $tcpdump_cv_capable_yacc = insufficient ; then
+ as_fn_error $? "$BISON_BYACC is insufficient to compile libpcap.
+ libpcap requires Bison, a newer version of Berkeley YACC with support
+ for reentrant parsers, or another YACC compatible with them." "$LINENO" 5
+ fi
+ else
+ #
+ # OK, we found neither byacc nor yacc.
+ #
+ as_fn_error $? "Neither bison, byacc, nor yacc was found.
libpcap requires Bison, a newer version of Berkeley YACC with support
for reentrant parsers, or another YACC compatible with them." "$LINENO" 5
fi
@@ -8593,24 +9150,8 @@ $as_echo "$tcpdump_cv_capable_yacc" >&6; }
# "%pure-parser".
#
REENTRANT_PARSER="%pure-parser"
- ;;
+fi
-*)
- #
- # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
- # "%pure-parser".
- #
- bison_major_version=`$YACC -V | sed -n 's/.* \([1-9][0-9]*\)\.[1-9][0-9.]*/\1/p'`
- bison_minor_version=`$YACC -V | sed -n 's/.* [1-9][0-9]*\.\([1-9][0-9]*\).*/\1/p'`
- if test "$bison_major_version" -lt 2 -o \
- \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
- then
- REENTRANT_PARSER="%pure-parser"
- else
- REENTRANT_PARSER="%define api.pure"
- fi
- ;;
-esac
#
@@ -8710,7 +9251,7 @@ fi
V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
;;
- darwin8.[456]|darwin.[456].*)
+ darwin8.[456]|darwin8.[456].*)
#
# Tiger, subsequent to Intel support but prior
# to x86-64 support. Build libraries and
@@ -8775,22 +9316,18 @@ fi
V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
;;
- darwin*)
+ darwin1[1-8]*)
+ #
+ # Post-Snow Leopard, pre-Catalina. Build
+ # libraries for x86-64 and 32-bit x86, with
+ # x86-64 first, and build executables only for
+ # x86-64. (That's what Apple does.) This
+ # requires no special flags for programs.
#
- # Post-Snow Leopard. Build libraries for x86-64
- # and 32-bit x86, with x86-64 first, and build
- # executables only for x86-64. (That's what
- # Apple does.) This requires no special flags
- # for programs.
- # XXX - update if and when Apple drops support
- # for 32-bit x86 code and if and when Apple adds
- # ARM-based Macs. (You're on your own for iOS
- # etc.)
- #
- # XXX - check whether we *can* build for
- # i386 and, if not, suggest that the user
- # install the /usr/include headers if they
- # want to build fat.
+ # We check whether we *can* build for i386 and,
+ # if not, suggest that the user install the
+ # /usr/include headers if they want to build
+ # fat.
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether building for 32-bit x86 is supported" >&5
$as_echo_n "checking whether building for 32-bit x86 is supported... " >&6; }
@@ -8860,6 +9397,84 @@ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS="$save_CFLAGS"
;;
+
+ darwin19*)
+ #
+ # Catalina. Build libraries and executables
+ # only for x86-64. (That's what Apple does;
+ # 32-bit x86 binaries are not supported on
+ # Catalina.)
+ #
+ V_LIB_CCOPT_FAT="-arch x86_64"
+ V_LIB_LDFLAGS_FAT="-arch x86_64"
+ V_PROG_CCOPT_FAT="-arch x86_64"
+ V_PROG_LDFLAGS_FAT="-arch x86_64"
+ ;;
+
+ darwin*)
+ #
+ # Post-Catalina. Build libraries and
+ # executables for x86-64 and ARM64.
+ # (That's what Apple does, except they
+ # build for arm64e, which may include
+ # some of the pointer-checking extensions.)
+ #
+ # If we're building with libssl, make sure
+ # we can build fat with it (i.e., that it
+ # was built fat); if we can't, don't set
+ # the target architectures, and just
+ # build for the host we're on.
+ #
+ # Otherwise, just add both of them.
+ #
+ if test "$HAVE_OPENSSL" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether building fat with libssl is supported" >&5
+$as_echo_n "checking whether building fat with libssl is supported... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS -arch x86_64 -arch arm64"
+ LDFLAGS="$LDFLAGS $OPENSSL_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <openssl/ssl.h>
+
+int
+main ()
+{
+
+ SSL_library_init();
+ return 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+ V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS="$save_CFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ else
+ V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+ V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+ fi
+ ;;
esac
fi
;;
@@ -9239,67 +9854,39 @@ rm -f os-proto.h
#
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5
-$as_echo_n "checking whether the compiler fails when given an unknown warning option... " >&6; }
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
- 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: no" >&5
-$as_echo "no" >&6; }
- #
- # We're assuming this is clang, where
- # -Werror=unknown-warning-option is the appropriate
- # option to force the compiler to fail.
- #
- ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
-
-else
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
-
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5
$as_echo_n "checking whether the compiler supports the -W option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-W" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W"
- elif expr "x-W" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -W"
- elif expr "x-W" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -W"
- else
- CFLAGS="$CFLAGS -W"
- fi
+ CFLAGS="$CFLAGS -W"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9355,33 +9942,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5
$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wall" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall"
- elif expr "x-Wall" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wall"
- elif expr "x-Wall" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wall"
- else
- CFLAGS="$CFLAGS -Wall"
- fi
+ CFLAGS="$CFLAGS -Wall"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9437,33 +10033,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcomma option" >&5
$as_echo_n "checking whether the compiler supports the -Wcomma option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wcomma" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wcomma"
- elif expr "x-Wcomma" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wcomma"
- elif expr "x-Wcomma" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wcomma"
- else
- CFLAGS="$CFLAGS -Wcomma"
- fi
+ CFLAGS="$CFLAGS -Wcomma"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9519,33 +10124,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdocumentation option" >&5
$as_echo_n "checking whether the compiler supports the -Wdocumentation option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wdocumentation" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdocumentation"
- elif expr "x-Wdocumentation" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wdocumentation"
- elif expr "x-Wdocumentation" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wdocumentation"
- else
- CFLAGS="$CFLAGS -Wdocumentation"
- fi
+ CFLAGS="$CFLAGS -Wdocumentation"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9601,33 +10215,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wformat-nonliteral option" >&5
$as_echo_n "checking whether the compiler supports the -Wformat-nonliteral option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wformat-nonliteral" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wformat-nonliteral"
- elif expr "x-Wformat-nonliteral" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wformat-nonliteral"
- elif expr "x-Wformat-nonliteral" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wformat-nonliteral"
- else
- CFLAGS="$CFLAGS -Wformat-nonliteral"
- fi
+ CFLAGS="$CFLAGS -Wformat-nonliteral"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9683,33 +10306,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-noreturn option" >&5
$as_echo_n "checking whether the compiler supports the -Wmissing-noreturn option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wmissing-noreturn" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-noreturn"
- elif expr "x-Wmissing-noreturn" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wmissing-noreturn"
- elif expr "x-Wmissing-noreturn" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wmissing-noreturn"
- else
- CFLAGS="$CFLAGS -Wmissing-noreturn"
- fi
+ CFLAGS="$CFLAGS -Wmissing-noreturn"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9765,33 +10397,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5
$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
- elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
- elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
- else
- CFLAGS="$CFLAGS -Wmissing-prototypes"
- fi
+ CFLAGS="$CFLAGS -Wmissing-prototypes"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9847,33 +10488,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-variable-declarations option" >&5
$as_echo_n "checking whether the compiler supports the -Wmissing-variable-declarations option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wmissing-variable-declarations" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-variable-declarations"
- elif expr "x-Wmissing-variable-declarations" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wmissing-variable-declarations"
- elif expr "x-Wmissing-variable-declarations" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wmissing-variable-declarations"
- else
- CFLAGS="$CFLAGS -Wmissing-variable-declarations"
- fi
+ CFLAGS="$CFLAGS -Wmissing-variable-declarations"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -9929,33 +10579,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-arith option" >&5
$as_echo_n "checking whether the compiler supports the -Wpointer-arith option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wpointer-arith" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-arith"
- elif expr "x-Wpointer-arith" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wpointer-arith"
- elif expr "x-Wpointer-arith" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wpointer-arith"
- else
- CFLAGS="$CFLAGS -Wpointer-arith"
- fi
+ CFLAGS="$CFLAGS -Wpointer-arith"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10011,33 +10670,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-sign option" >&5
$as_echo_n "checking whether the compiler supports the -Wpointer-sign option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wpointer-sign" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-sign"
- elif expr "x-Wpointer-sign" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wpointer-sign"
- elif expr "x-Wpointer-sign" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wpointer-sign"
- else
- CFLAGS="$CFLAGS -Wpointer-sign"
- fi
+ CFLAGS="$CFLAGS -Wpointer-sign"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10093,33 +10761,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5
$as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wshadow" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow"
- elif expr "x-Wshadow" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wshadow"
- elif expr "x-Wshadow" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wshadow"
- else
- CFLAGS="$CFLAGS -Wshadow"
- fi
+ CFLAGS="$CFLAGS -Wshadow"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10175,33 +10852,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wsign-compare option" >&5
$as_echo_n "checking whether the compiler supports the -Wsign-compare option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wsign-compare" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wsign-compare"
- elif expr "x-Wsign-compare" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wsign-compare"
- elif expr "x-Wsign-compare" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wsign-compare"
- else
- CFLAGS="$CFLAGS -Wsign-compare"
- fi
+ CFLAGS="$CFLAGS -Wsign-compare"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10257,33 +10943,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5
$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
- elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
- elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
- else
- CFLAGS="$CFLAGS -Wstrict-prototypes"
- fi
+ CFLAGS="$CFLAGS -Wstrict-prototypes"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10339,33 +11034,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunused-parameter option" >&5
$as_echo_n "checking whether the compiler supports the -Wunused-parameter option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wunused-parameter" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wunused-parameter"
- elif expr "x-Wunused-parameter" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wunused-parameter"
- elif expr "x-Wunused-parameter" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wunused-parameter"
- else
- CFLAGS="$CFLAGS -Wunused-parameter"
- fi
+ CFLAGS="$CFLAGS -Wunused-parameter"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10421,33 +11125,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5
$as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused"
- elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
- elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
- else
- CFLAGS="$CFLAGS -Wused-but-marked-unused"
- fi
+ CFLAGS="$CFLAGS -Wused-but-marked-unused"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10503,6 +11216,7 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
# Warns about safeguards added in case the enums are
# extended
@@ -10535,28 +11249,36 @@ 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
+ CFLAGS="$CFLAGS -Wunreachable-code"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10619,33 +11341,42 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshorten-64-to-32 option" >&5
$as_echo_n "checking whether the compiler supports the -Wshorten-64-to-32 option... " >&6; }
save_CFLAGS="$CFLAGS"
- if expr "x-Wshorten-64-to-32" : "x-W.*" >/dev/null
- then
- CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshorten-64-to-32"
- elif expr "x-Wshorten-64-to-32" : "x-f.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wshorten-64-to-32"
- elif expr "x-Wshorten-64-to-32" : "x-m.*" >/dev/null
- then
- CFLAGS="$CFLAGS -Werror -Wshorten-64-to-32"
- else
- CFLAGS="$CFLAGS -Wshorten-64-to-32"
- fi
+ CFLAGS="$CFLAGS -Wshorten-64-to-32"
+ #
+ # XXX - yes, this depends on the way AC_LANG_WERROR works,
+ # but no mechanism is provided to turn AC_LANG_WERROR on
+ # *and then turn it back off*, so that we *only* do it when
+ # testing compiler options - 15 years after somebody asked
+ # for it:
+ #
+ # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror
+ #
+ save_ac_c_werror_flag="$ac_c_werror_flag"
+ ac_c_werror_flag=yes
+ #
+ # We use AC_LANG_SOURCE() so that we can control the complete
+ # content of the program being compiled. We do not, for example,
+ # want the default "int main()" that AC_LANG_PROGRAM() generates,
+ # as it will generate a warning with -Wold-style-definition, meaning
+ # that we would treat it as not working, as the test will fail if
+ # *any* error output, including a warning due to the flag we're
+ # testing, is generated; see
+ #
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us
+ #
+ # This may, as per those two messages, be fixed in autoonf 2.70,
+ # but we only require 2.64 or newer for now.
+ #
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-int
-main ()
-{
-return 0
- ;
- return 0;
-}
+int main(void) { return 0; }
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
@@ -10701,6 +11432,7 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag="$save_ac_c_werror_flag"
fi
@@ -11185,26 +11917,121 @@ fi
if test "$want_dpdk" != no; then
- if test "x$PKGCONFIG" != "xno"
- then
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdpdk with pkg-config" >&5
+$as_echo_n "checking for libdpdk with pkg-config... " >&6; }
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdpdk\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+
+ #
+ # The package was found, so try to get its C flags and
+ # libraries.
+ #
+ if test -n "$DPDK_CFLAGS"; then
+ pkg_cv_DPDK_CFLAGS="$DPDK_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdpdk\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_DPDK_CFLAGS=`$PKG_CONFIG --cflags "libdpdk" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+ if test -n "$DPDK_LIBS"; then
+ pkg_cv_DPDK_LIBS="$DPDK_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdpdk\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_DPDK_LIBS=`$PKG_CONFIG --libs "libdpdk" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+ if test $pkg_failed = yes; then
#
- # We have pkg-config; see if we have DPDK installed
- # as a package.
+ # That failed - report an error.
#
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DPDK with pkg-config" >&5
-$as_echo_n "checking for DPDK with pkg-config... " >&6; }
- if "$PKGCONFIG" libdpdk
- then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5
+$as_echo "error" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ DPDK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdpdk" 2>&1`
+ else
+ DPDK_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdpdk" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$DPDK_PKG_ERRORS" >&5
+
+ as_fn_error $? "Package requirements (libdpdk) were not met:
+
+$DPDK_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+
+Alternatively, you may set the environment variables DPDK_CFLAGS
+and DPDK_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details." "$LINENO" 5
+ elif test $pkg_failed = untried; then
+ #
+ # We don't have pkg-config, so it didn't work.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5
+$as_echo "not found (pkg-config not found)" >&6; }
+ else
+ #
+ # We found the package.
+ #
+ DPDK_CFLAGS=$pkg_cv_DPDK_CFLAGS
+ DPDK_LIBS=$pkg_cv_DPDK_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
- found_dpdk_with_pkg_config=yes
- DPDK_CFLAGS=`"$PKGCONFIG" --cflags libdpdk`
- DPDK_LDFLAGS=`"$PKGCONFIG" --libs libdpdk`
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
- fi
+
+ found_dpdk_with_pkg_config=yes
+
fi
+else
+
+ #
+ # The package isn't present.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+
+fi
+
#
# If we didn't find it with pkg-config, try checking for
@@ -11600,28 +12427,116 @@ if test "x$enable_dbus" != "xno"; then
fi
if test "x$enable_dbus" != "xno"; then
- if test "x$PKGCONFIG" != "xno"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5
-$as_echo_n "checking for D-Bus... " >&6; }
- if "$PKGCONFIG" dbus-1; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
- DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $DBUS_CFLAGS"
- LIBS="$LIBS $DBUS_LIBS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbus-1 with pkg-config" >&5
+$as_echo_n "checking for dbus-1 with pkg-config... " >&6; }
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+
+ #
+ # The package was found, so try to get its C flags and
+ # libraries.
+ #
+ if test -n "$DBUS_CFLAGS"; then
+ pkg_cv_DBUS_CFLAGS="$DBUS_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "dbus-1" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+ if test -n "$DBUS_LIBS"; then
+ pkg_cv_DBUS_LIBS="$DBUS_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "dbus-1" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+ if test $pkg_failed = yes; then
+ #
+ # That failed - report an error.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5
+$as_echo "error" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-1" 2>&1`
+ else
+ DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-1" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$DBUS_PKG_ERRORS" >&5
+
+
+ if test "x$enable_dbus" = "xyes"; then
+ as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5
+ fi
+
+ elif test $pkg_failed = untried; then
+ #
+ # We don't have pkg-config, so it didn't work.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5
+$as_echo "not found (pkg-config not found)" >&6; }
+ else
+ #
+ # We found the package.
+ #
+ DBUS_CFLAGS=$pkg_cv_DBUS_CFLAGS
+ DBUS_LIBS=$pkg_cv_DBUS_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+$as_echo "found" >&6; }
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $DBUS_CFLAGS"
+ LIBS="$LIBS $DBUS_LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5
$as_echo_n "checking whether the D-Bus library defines dbus_connection_read_write... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h>
- #include <time.h>
- #include <sys/time.h>
+ #include <time.h>
+ #include <sys/time.h>
- #include <dbus/dbus.h>
+ #include <dbus/dbus.h>
int
main ()
{
@@ -11632,35 +12547,39 @@ return dbus_connection_read_write(NULL, 0);
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h
- MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
- V_INCLS="$V_INCLS $DBUS_CFLAGS"
+ MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
+ V_INCLS="$V_INCLS $DBUS_CFLAGS"
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- if test "x$enable_dbus" = "xyes"; then
- as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5
- fi
- LIBS="$save_LIBS"
+ if test "x$enable_dbus" = "xyes"; then
+ as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5
+ fi
+ LIBS="$save_LIBS"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- if test "x$enable_dbus" = "xyes"; then
- as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5
- fi
- fi
+ CFLAGS="$save_CFLAGS"
+
fi
+else
+
+ #
+ # The package isn't present.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+
+fi
+
fi
@@ -12385,7 +13304,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 pcap $as_me 1.10.0-PRE-GIT, which was
+This file was extended by pcap $as_me 1.11.0-PRE-GIT, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12451,7 +13370,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="\\
-pcap config.status 1.10.0-PRE-GIT
+pcap config.status 1.11.0-PRE-GIT
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -13160,7 +14079,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
"default-1":C) if test -f .devel; then
echo timestamp > stamp-h
cat $srcdir/Makefile-devel-adds >> Makefile
- make depend
+ make depend || exit 1
fi ;;
esac
diff --git a/configure.ac b/configure.ac
index 2ad28bbe..01b599d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ esac
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_LBL_SHLIBS_INIT
AC_LBL_C_INLINE
+AC_PCAP_C___ATOMICS
#
# Try to arrange for large file support.
@@ -62,27 +63,6 @@ dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
dnl
AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
AC_CHECK_HEADERS(netpacket/packet.h)
-AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>])
-if test "$ac_cv_header_net_pfvar_h" = yes; then
- #
- # Check for various PF actions.
- #
- AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
- AC_TRY_COMPILE(
- [#include <sys/types.h>
- #include <sys/socket.h>
- #include <net/if.h>
- #include <net/pfvar.h>],
- [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
- [
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
- [define if net/pfvar.h defines PF_NAT through PF_NORDR])
- ],
- AC_MSG_RESULT(no))
-fi
case "$host_os" in
haiku*)
@@ -571,7 +551,7 @@ AC_CHECK_HEADER(pthread.h,
dnl to pacify those who hate protochain insn
AC_MSG_CHECKING(if --disable-protochain option is specified)
AC_ARG_ENABLE(protochain,
-AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
+AS_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
case "x$enable_protochain" in
xyes) enable_protochain=enabled ;;
xno) enable_protochain=disabled ;;
@@ -591,7 +571,7 @@ AC_MSG_RESULT(${enable_protochain})
VALGRINDTEST_SRC=
AC_ARG_WITH(pcap,
-AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
+AS_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
if test ! -z "$with_pcap" ; then
V_PCAP="$withval"
else
@@ -733,7 +713,12 @@ AC_SUBST(VALGRINDTEST_SRC)
#
# Do we have pkg-config?
#
-AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
+PKG_PROG_PKG_CONFIG
+
+#
+# Do we have the brew command from Homebrew?
+#
+AC_PATH_PROG([BREW], [brew])
#
# Handle each capture type.
@@ -859,28 +844,20 @@ linux)
# let's drop support for older versions of libnl, too.
#
AC_ARG_WITH(libnl,
- AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
+ AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
with_libnl=$withval,with_libnl=if_available)
if test x$with_libnl != xno ; then
- if test "x$PKGCONFIG" != "xno"; then
- #
- # We have pkg-config; see if we have libnl-genl-3.0
- # as a package.
- #
- AC_MSG_CHECKING([for libnl-genl-3.0 with pkg-config])
- if "$PKGCONFIG" libnl-genl-3.0; then
- AC_MSG_RESULT([found])
- pkg_config_found_libnl=yes
- libnl_genl_cflags=`"$PKGCONFIG" --cflags libnl-genl-3.0`
- V_INCLS="$V_INCLS ${libnl_genl_cflags}"
- libnl_genl_libs=`"$PKGCONFIG" --libs libnl-genl-3.0`
- LIBS="${libnl_genl_libs} $LIBS"
- AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
- else
- AC_MSG_RESULT([not found])
- fi
- fi
+ #
+ # Check for libnl-genl-3.0 with pkg-config.
+ #
+ PKG_CHECK_MODULES(LIBNL, libnl-genl-3.0,
+ [
+ pkg_config_found_libnl=yes
+ V_INCLS="$V_INCLS $LIBNL_CFLAGS"
+ LIBS="$LIBNL_LIBS $LIBS"
+ AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
+ ])
if test x$pkg_config_found_libnl != xyes; then
#
@@ -1124,7 +1101,7 @@ AC_CHECK_TYPES(socklen_t,,,
])
AC_ARG_ENABLE(ipv6,
-AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
+AS_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
[],
[enable_ipv6=yes])
if test "$enable_ipv6" != "no"; then
@@ -1137,7 +1114,7 @@ fi
# Check for Endace DAG card support.
AC_ARG_WITH([dag],
-AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
+AS_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -1170,7 +1147,7 @@ AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in
])
AC_ARG_WITH([dag-includes],
-AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
+AS_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
[
# User wants DAG support and has specified a header directory, so use the provided value.
want_dag=yes
@@ -1178,7 +1155,7 @@ AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not
],[])
AC_ARG_WITH([dag-libraries],
-AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
+AS_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
[
# User wants DAG support and has specified a library directory, so use the provided value.
want_dag=yes
@@ -1273,7 +1250,7 @@ if test "$want_dag" != no; then
fi
AC_ARG_WITH(septel,
-AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
+AS_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -1350,7 +1327,7 @@ fi
# Check for Myricom SNF support.
AC_ARG_WITH([snf],
-AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
+AS_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -1383,7 +1360,7 @@ AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in
])
AC_ARG_WITH([snf-includes],
-AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
+AS_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
[
# User wants SNF with specific header directory
want_snf=yes
@@ -1391,7 +1368,7 @@ AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not
],[])
AC_ARG_WITH([snf-libraries],
-AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
+AS_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
[
# User wants SNF with specific lib directory
want_snf=yes
@@ -1463,7 +1440,7 @@ fi
# Check for Riverbed TurboCap support.
AC_ARG_WITH([turbocap],
-AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
+AS_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -1540,10 +1517,11 @@ dnl It's off by default, as that increases the attack surface of
dnl libpcap, exposing it to malicious servers.
dnl
AC_MSG_CHECKING([whether to enable remote packet capture])
-AC_ARG_ENABLE(remote,
-[ --enable-remote enable remote packet capture @<:@default=no@:>@
- --disable-remote disable remote packet capture],,
- enableval=no)
+AC_ARG_ENABLE([remote],
+ [AS_HELP_STRING([--enable-remote],
+ [enable remote packet capture @<:@default=no@:>@])],
+ [],
+ [enableval=no])
case "$enableval" in
yes) AC_MSG_RESULT(yes)
AC_WARN([Remote packet capture may expose libpcap-based applications])
@@ -1598,66 +1576,89 @@ yes) AC_MSG_RESULT(yes)
# Optionally, we may want to support SSL.
# Check for OpenSSL/libressl.
#
- # First, try looking for it as a regular system library.
- # Make sure we can find SSL_library_init() using the
- # standard headers, just in case we're running a version
- # of macOS that ships with the OpenSSL library but not
- # the OpenSSL headers, and have also installed another
- # version of OpenSSL with headers.
+ # First, try looking for it with pkg-config, if we have it.
#
- save_LIBS="$LIBS"
- LIBS="-lssl -lcrypto"
- AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
- AC_TRY_LINK(
- [
-#include <openssl/ssl.h>
- ],
- [
-SSL_library_init();
-return 0;
- ],
+ # Homebrew's pkg-config does not, by default, look for
+ # pkg-config files for packages it has installed.
+ # Furthermore, at least for OpenSSL, they appear to be
+ # dumped in package-specific directories whose paths are
+ # not only package-specific but package-version-specific.
+ #
+ # So the only way to find openssl is to get the value of
+ # PKG_CONFIG_PATH from "brew --env openssl" and add that
+ # to PKG_CONFIG_PATH. (No, we can't just assume it's under
+ # /usr/local; Homebrew have conveniently chosen to put it
+ # under /opt/homebrew on ARM.)
+ #
+ # That's the nice thing about Homebrew - it makes things easier!
+ # Thanks!
+ #
+ save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
+ if test -n "$BREW"; then
+ openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
+ PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
+ fi
+ PKG_CHECK_MODULES(OPENSSL, openssl,
[
- AC_MSG_RESULT(yes)
+ #
+ # We found OpenSSL/libressl.
+ #
HAVE_OPENSSL=yes
- OPENSSL_LIBS="-lssl -lcrypto"
- ],
- AC_MSG_RESULT(no))
- LIBS="$save_LIBS"
+ ])
+ PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
#
- # If we didn't find it, check for it with pkg-config.
+ # If it wasn't found, and we have Homebrew installed, see
+ # if it's in Homebrew.
#
- if test "x$HAVE_OPENSSL" != "xyes"; then
- if test "x$PKGCONFIG" != "xno"; then
+ if test "x$HAVE_OPENSSL" != "xyes" -a -n "$BREW"; then
+ AC_MSG_CHECKING(for openssl in Homebrew)
+ #
+ # The brew man page lies when it speaks of
+ # $BREW --prefix --installed <formula>
+ # outputting nothing. In Homebrew 3.3.16,
+ # it produces output regardless of whether
+ # the formula is installed or not, so we
+ # send the standard output and error to
+ # the bit bucket.
+ #
+ if $BREW --prefix --installed openssl >/dev/null 2>&1; then
#
- # We have pkg-config; see if we have OpenSSL/
- # libressl installed as a package.
+ # Yes. Get the include directory and library
+ # directory. (No, we can't just assume it's
+ # under /usr/local; Homebrew have conveniently
+ # chosen to put it under /opt/homebrew on ARM.)
#
- AC_MSG_CHECKING([for OpenSSL/libressl with pkg-config])
- if "$PKGCONFIG" openssl; then
- AC_MSG_RESULT([found])
- HAVE_OPENSSL=yes
- OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl`
- OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl`
- else
- AC_MSG_RESULT([not found])
- fi
+ AC_MSG_RESULT(yes)
+ HAVE_OPENSSL=yes
+ openssl_path=`$BREW --prefix openssl`
+ OPENSSL_CFLAGS="-I$openssl_path/include"
+ OPENSSL_LIBS="-L$openssl_path/lib -lssl -lcrypto"
+ else
+ AC_MSG_RESULT(no)
fi
fi
#
- # If we didn't find it, check for it under /usr/local/opt/openssl;
- # that's where Homebrew puts it on macOS. Feel free to add other
- # -L directories as necessary; the "system library" check should
- # also handle "add-on library under /usr/local", so that shouldn't
- # be necessary here.
+ # If it wasn't found, and /usr/local/include and /usr/local/lib
+ # exist, check if it's in /usr/local. (We check whether they
+ # exist because, if they don't exist, the compiler will warn
+ # about that and then ignore the argument, so they test
+ # using just the system header files and libraries.)
#
- if test "x$HAVE_OPENSSL" != "xyes"; then
+ # We include the standard include file to 1) make sure that
+ # it's installed (if it's just a shared library for the
+ # benefit of existing programs, that's not useful) and 2)
+ # because SSL_library_init() is a library routine in some
+ # versions and a #defined wrapper around OPENSSL_init_ssl()
+ # in others.
+ #
+ if test "x$HAVE_OPENSSL" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
- CFLAGS="$CFLAGS -L/usr/local/opt/openssl/include"
- LIBS="$LIBS -L/usr/local/opt/openssl/lib -lssl -lcrypto"
- AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local/opt that we can use)
+ CFLAGS="$CFLAGS -I/usr/local/include"
+ LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto"
+ AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local that we can use)
AC_TRY_LINK(
[
#include <openssl/ssl.h>
@@ -1669,8 +1670,8 @@ return 0;
[
AC_MSG_RESULT(yes)
HAVE_OPENSSL=yes
- OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
- OPENSSL_LIBS="-L/usr/local/opt/openssl/lib -lssl -lcrypto"
+ OPENSSL_CFLAGS="-I/usr/local/include"
+ OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto"
],
AC_MSG_RESULT(no))
CFLAGS="$save_CFLAGS"
@@ -1678,6 +1679,37 @@ return 0;
fi
#
+ # If it wasn't found, check if it's a system library.
+ #
+ # We include the standard include file to 1) make sure that
+ # it's installed (if it's just a shared library for the
+ # benefit of existing programs, that's not useful) and 2)
+ # because SSL_library_init() is a library routine in some
+ # versions and a #defined wrapper around OPENSSL_init_ssl()
+ # in others.
+ #
+ if test "x$HAVE_OPENSSL" != "xyes"; then
+ save_LIBS="$LIBS"
+ LIBS="$LIBS -lssl -lcrypto"
+ AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
+ AC_TRY_LINK(
+ [
+#include <openssl/ssl.h>
+ ],
+ [
+SSL_library_init();
+return 0;
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ HAVE_OPENSSL=yes
+ OPENSSL_LIBS="-lssl -lcrypto"
+ ],
+ AC_MSG_RESULT(no))
+ LIBS="$save_LIBS"
+ fi
+
+ #
# OK, did we find it?
#
if test "x$HAVE_OPENSSL" = "xyes"; then
@@ -1700,7 +1732,7 @@ esac
AC_MSG_CHECKING(whether to build optimizer debugging code)
AC_ARG_ENABLE(optimizer-dbg,
-AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
+AS_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
if test "$enable_optimizer_dbg" = "yes"; then
AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
fi
@@ -1708,7 +1740,7 @@ AC_MSG_RESULT(${enable_optimizer_dbg-no})
AC_MSG_CHECKING(whether to build parser debugging code)
AC_ARG_ENABLE(yydebug,
-AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
+AS_HELP_STRING([--enable-yydebug],[build parser debugging code]))
if test "$enable_yydebug" = "yes"; then
AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
fi
@@ -1734,50 +1766,37 @@ AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
fi)
if test $tcpdump_cv_capable_lex = insufficient ; then
AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
- libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
+ libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
+ If a suitable version of Lex/Flex is available as a non-standard command
+ and/or not in the PATH, you can specify it using the LEX environment
+ variable. That said, on some systems the error can mean that Flex/Lex is
+ actually acceptable, but m4 is not. Likewise, if a suitable version of
+ m4 (such as GNU M4) is available but has not been detected, you can
+ specify it using the M4 environment variable.])
fi
#
# Look for yacc/bison/byacc.
+# If it's Bison, we do not want -y, as 1) we will be using -o to cause
+# the output for XXX.y to be written to XXX.c and 2) we don't want
+# it to issue warnings about stuff not supported by POSIX YACC - we
+# want to use that stuff, and don't care whether plain YACC supports
+# it or not, we require either Bison or Berkeley YACC.
#
-AC_PROG_YACC
-
-case "$YACC" in
-
-*yacc)
- #
- # Make sure this is Berkeley YACC, not AT&T YACC; the latter
- # doesn't support reentrant parsers. Run it with "-V";
- # that succeeds and reports the version number with
- # Berkeley YACC, but will (probably) fail with various
- # vendor flavors of AT&T YACC.
- #
- AC_CACHE_CHECK([for capable yacc], tcpdump_cv_capable_yacc,
- if $YACC -V >/dev/null 2>&1; then
- tcpdump_cv_capable_yacc=yes
- else
- tcpdump_cv_capable_yacc=insufficient
- fi)
- if test $tcpdump_cv_capable_yacc = insufficient ; then
- AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
- libpcap requires Bison, a newer version of Berkeley YACC with support
- for reentrant parsers, or another YACC compatible with them.])
- fi
-
- #
- # Berkeley YACC doesn't support "%define api.pure", so use
- # "%pure-parser".
+BISON_BYACC=""
+#
+# Look for Bison.
+#
+AC_CHECK_PROGS(BISON_BYACC, bison)
+if test x"$BISON_BYACC" != x; then
#
- REENTRANT_PARSER="%pure-parser"
- ;;
-
-*)
+ # We found Bison.
#
# Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
# "%pure-parser".
#
- bison_major_version=`$YACC -V | sed -n 's/.* \(@<:@1-9@:>@@<:@0-9@:>@*\)\.@<:@1-9@:>@@<:@0-9.@:>@*/\1/p'`
- bison_minor_version=`$YACC -V | sed -n 's/.* @<:@1-9@:>@@<:@0-9@:>@*\.\(@<:@1-9@:>@@<:@0-9@:>@*\).*/\1/p'`
+ bison_major_version=`$BISON_BYACC -V | sed -n 's/.* \(@<:@1-9@:>@@<:@0-9@:>@*\)\.@<:@0-9@:>@@<:@0-9.@:>@*/\1/p'`
+ bison_minor_version=`$BISON_BYACC -V | sed -n 's/.* @<:@1-9@:>@@<:@0-9@:>@*\.\(@<:@0-9@:>@+\).*/\1/p'`
if test "$bison_major_version" -lt 2 -o \
\( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
then
@@ -1785,8 +1804,52 @@ case "$YACC" in
else
REENTRANT_PARSER="%define api.pure"
fi
- ;;
-esac
+else
+ #
+ # We didn't find Bison; check for Berkeley YACC, under the
+ # names byacc and yacc.
+ #
+ AC_CHECK_PROGS(BISON_BYACC, byacc yacc)
+ if test x"$BISON_BYACC" != x; then
+ #
+ # Make sure this is Berkeley YACC, not AT&T YACC;
+ # the latter doesn't support reentrant parsers.
+ # Run it with "-V"; that succeeds and reports the
+ # version number with Berkeley YACC, but will
+ # (probably) fail with various vendor flavors
+ # of AT&T YACC.
+ #
+ # Hopefully this also eliminates any versions
+ # of Berkeley YACC that don't support reentrant
+ # parsers, if there are any.
+ #
+ AC_CACHE_CHECK([for capable yacc], tcpdump_cv_capable_yacc,
+ if $BISON_BYACC -V >/dev/null 2>&1; then
+ tcpdump_cv_capable_yacc=yes
+ else
+ tcpdump_cv_capable_yacc=insufficient
+ fi)
+ if test $tcpdump_cv_capable_yacc = insufficient ; then
+ AC_MSG_ERROR([$BISON_BYACC is insufficient to compile libpcap.
+ libpcap requires Bison, a newer version of Berkeley YACC with support
+ for reentrant parsers, or another YACC compatible with them.])
+ fi
+ else
+ #
+ # OK, we found neither byacc nor yacc.
+ #
+ AC_MSG_ERROR([Neither bison, byacc, nor yacc was found.
+ libpcap requires Bison, a newer version of Berkeley YACC with support
+ for reentrant parsers, or another YACC compatible with them.])
+ fi
+
+ #
+ # Berkeley YACC doesn't support "%define api.pure", so use
+ # "%pure-parser".
+ #
+ REENTRANT_PARSER="%pure-parser"
+fi
+AC_SUBST(BISON_BYACC)
AC_SUBST(REENTRANT_PARSER)
#
@@ -1850,7 +1913,7 @@ darwin*)
DYEXT="dylib"
V_CCOPT="$V_CCOPT -fno-common"
AC_ARG_ENABLE(universal,
- AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
+ AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
if test "$enable_universal" != "no"; then
case "$host_os" in
@@ -1880,7 +1943,7 @@ darwin*)
V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
;;
- darwin8.[[456]]|darwin.[[456]].*)
+ darwin8.[[456]]|darwin8.[[456]].*)
#
# Tiger, subsequent to Intel support but prior
# to x86-64 support. Build libraries and
@@ -1945,22 +2008,18 @@ darwin*)
V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
;;
- darwin*)
+ darwin1[[1-8]]*)
#
- # Post-Snow Leopard. Build libraries for x86-64
- # and 32-bit x86, with x86-64 first, and build
- # executables only for x86-64. (That's what
- # Apple does.) This requires no special flags
- # for programs.
- # XXX - update if and when Apple drops support
- # for 32-bit x86 code and if and when Apple adds
- # ARM-based Macs. (You're on your own for iOS
- # etc.)
+ # Post-Snow Leopard, pre-Catalina. Build
+ # libraries for x86-64 and 32-bit x86, with
+ # x86-64 first, and build executables only for
+ # x86-64. (That's what Apple does.) This
+ # requires no special flags for programs.
#
- # XXX - check whether we *can* build for
- # i386 and, if not, suggest that the user
- # install the /usr/include headers if they
- # want to build fat.
+ # We check whether we *can* build for i386 and,
+ # if not, suggest that the user install the
+ # /usr/include headers if they want to build
+ # fat.
#
AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
save_CFLAGS="$CFLAGS"
@@ -2012,6 +2071,68 @@ darwin*)
])
CFLAGS="$save_CFLAGS"
;;
+
+ darwin19*)
+ #
+ # Catalina. Build libraries and executables
+ # only for x86-64. (That's what Apple does;
+ # 32-bit x86 binaries are not supported on
+ # Catalina.)
+ #
+ V_LIB_CCOPT_FAT="-arch x86_64"
+ V_LIB_LDFLAGS_FAT="-arch x86_64"
+ V_PROG_CCOPT_FAT="-arch x86_64"
+ V_PROG_LDFLAGS_FAT="-arch x86_64"
+ ;;
+
+ darwin*)
+ #
+ # Post-Catalina. Build libraries and
+ # executables for x86-64 and ARM64.
+ # (That's what Apple does, except they
+ # build for arm64e, which may include
+ # some of the pointer-checking extensions.)
+ #
+ # If we're building with libssl, make sure
+ # we can build fat with it (i.e., that it
+ # was built fat); if we can't, don't set
+ # the target architectures, and just
+ # build for the host we're on.
+ #
+ # Otherwise, just add both of them.
+ #
+ if test "$HAVE_OPENSSL" = yes; then
+ AC_MSG_CHECKING(whether building fat with libssl is supported)
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS -arch x86_64 -arch arm64"
+ LDFLAGS="$LDFLAGS $OPENSSL_LIBS"
+ AC_TRY_LINK(
+ [
+ #include <openssl/ssl.h>
+ ],
+ [
+ SSL_library_init();
+ return 0;
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+ V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+ ],
+ [AC_MSG_RESULT(no)]
+ )
+ CFLAGS="$save_CFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ else
+ V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+ V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
+ V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
+ fi
+ ;;
esac
fi
;;
@@ -2157,7 +2278,7 @@ solaris*)
esac
AC_ARG_ENABLE(shared,
-AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
+AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
test "x$enable_shared" = "xno" && DYEXT="none"
AC_PROG_RANLIB
@@ -2239,7 +2360,7 @@ AC_SUBST(EXTRA_NETWORK_LIBS)
# Various Linux-specific mechanisms.
#
AC_ARG_ENABLE([usb],
-[AC_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])],
+[AS_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])],
[],
[enable_usb=yes])
@@ -2332,7 +2453,7 @@ AC_SUBST(PCAP_SUPPORT_LINUX_USBMON)
AC_SUBST(PCAP_SUPPORT_NETFILTER)
AC_ARG_ENABLE([netmap],
-[AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
+[AS_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
[],
[enable_netmap=yes])
@@ -2363,7 +2484,7 @@ fi
# Check for DPDK support.
AC_ARG_WITH([dpdk],
-AC_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
+AS_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
[
if test "$withval" = no
then
@@ -2397,23 +2518,10 @@ AC_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in direc
])
if test "$want_dpdk" != no; then
- if test "x$PKGCONFIG" != "xno"
- then
- #
- # We have pkg-config; see if we have DPDK installed
- # as a package.
- #
- AC_MSG_CHECKING([for DPDK with pkg-config])
- if "$PKGCONFIG" libdpdk
- then
- AC_MSG_RESULT([found])
- found_dpdk_with_pkg_config=yes
- DPDK_CFLAGS=`"$PKGCONFIG" --cflags libdpdk`
- DPDK_LDFLAGS=`"$PKGCONFIG" --libs libdpdk`
- else
- AC_MSG_RESULT([not found])
- fi
- fi
+ PKG_CHECK_MODULES(DPDK, libdpdk,
+ [
+ found_dpdk_with_pkg_config=yes
+ ])
#
# If we didn't find it with pkg-config, try checking for
@@ -2601,7 +2709,7 @@ fi
AC_SUBST(PCAP_SUPPORT_DPDK)
AC_ARG_ENABLE([bluetooth],
-[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
+[AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
[],
[enable_bluetooth=ifsupportavailable])
@@ -2684,7 +2792,7 @@ if test "x$enable_bluetooth" != "xno" ; then
fi
AC_ARG_ENABLE([dbus],
-[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
+[AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
[],
[enable_dbus=ifavailable])
@@ -2727,51 +2835,46 @@ if test "x$enable_dbus" != "xno"; then
fi
if test "x$enable_dbus" != "xno"; then
- if test "x$PKGCONFIG" != "xno"; then
- AC_MSG_CHECKING([for D-Bus])
- if "$PKGCONFIG" dbus-1; then
- AC_MSG_RESULT([yes])
- DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
- DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $DBUS_CFLAGS"
- LIBS="$LIBS $DBUS_LIBS"
- AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
- AC_TRY_LINK(
- [#include <string.h>
+ PKG_CHECK_MODULES(DBUS, dbus-1,
+ [
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $DBUS_CFLAGS"
+ LIBS="$LIBS $DBUS_LIBS"
+ AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
+ AC_TRY_LINK(
+ [#include <string.h>
- #include <time.h>
- #include <sys/time.h>
+ #include <time.h>
+ #include <sys/time.h>
- #include <dbus/dbus.h>],
- [return dbus_connection_read_write(NULL, 0);],
- [
- AC_MSG_RESULT([yes])
- AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
- MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
- V_INCLS="$V_INCLS $DBUS_CFLAGS"
- ],
- [
- AC_MSG_RESULT([no])
- if test "x$enable_dbus" = "xyes"; then
- AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
- fi
- LIBS="$save_LIBS"
- ])
- CFLAGS="$save_CFLAGS"
- else
+ #include <dbus/dbus.h>],
+ [return dbus_connection_read_write(NULL, 0);],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
+ MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
+ V_INCLS="$V_INCLS $DBUS_CFLAGS"
+ ],
+ [
AC_MSG_RESULT([no])
if test "x$enable_dbus" = "xyes"; then
- AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
+ AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
fi
+ LIBS="$save_LIBS"
+ ])
+ CFLAGS="$save_CFLAGS"
+ ],
+ [
+ if test "x$enable_dbus" = "xyes"; then
+ AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
fi
- fi
+ ])
AC_SUBST(PCAP_SUPPORT_DBUS)
fi
AC_ARG_ENABLE([rdma],
-[AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
+[AS_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
[],
[enable_rdma=ifavailable])
@@ -2826,7 +2929,7 @@ AC_CONFIG_HEADER(config.h)
AC_OUTPUT_COMMANDS([if test -f .devel; then
echo timestamp > stamp-h
cat $srcdir/Makefile-devel-adds >> Makefile
- make depend
+ make depend || exit 1
fi])
AC_OUTPUT(Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc
pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
diff --git a/diag-control.h b/diag-control.h
index aa0e6aad..d1622aa6 100644
--- a/diag-control.h
+++ b/diag-control.h
@@ -121,6 +121,8 @@
__pragma(warning(disable:4996))
#define DIAG_ON_DEPRECATION \
__pragma(warning(pop))
+ #define DIAG_OFF_FORMAT_TRUNCATION
+ #define DIAG_ON_FORMAT_TRUNCATION
#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
/*
* This is Clang 2.8 or later; we can use "clang diagnostic
@@ -160,6 +162,8 @@
PCAP_DO_PRAGMA(clang diagnostic ignored "-Wdeprecated-declarations")
#define DIAG_ON_DEPRECATION \
PCAP_DO_PRAGMA(clang diagnostic pop)
+ #define DIAG_OFF_FORMAT_TRUNCATION
+ #define DIAG_ON_FORMAT_TRUNCATION
#elif PCAP_IS_AT_LEAST_GNUC_VERSION(4,6)
/*
* This is GCC 4.6 or later, or a compiler claiming to be that.
@@ -188,6 +192,22 @@
PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
#define DIAG_ON_DEPRECATION \
PCAP_DO_PRAGMA(GCC diagnostic pop)
+
+ /*
+ * Suppress format-truncation= warnings.
+ * GCC 7.1 had introduced this warning option. Earlier versions (at least
+ * one particular copy of GCC 4.6.4) treat the request as a warning.
+ */
+ #if PCAP_IS_AT_LEAST_GNUC_VERSION(7,1)
+ #define DIAG_OFF_FORMAT_TRUNCATION \
+ PCAP_DO_PRAGMA(GCC diagnostic push) \
+ PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wformat-truncation=")
+ #define DIAG_ON_FORMAT_TRUNCATION \
+ PCAP_DO_PRAGMA(GCC diagnostic pop)
+ #else
+ #define DIAG_OFF_FORMAT_TRUNCATION
+ #define DIAG_ON_FORMAT_TRUNCATION
+ #endif
#else
/*
* Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later
@@ -200,6 +220,8 @@
#define DIAG_ON_NARROWING
#define DIAG_OFF_DEPRECATION
#define DIAG_ON_DEPRECATION
+ #define DIAG_OFF_FORMAT_TRUNCATION
+ #define DIAG_ON_FORMAT_TRUNCATION
#endif
#ifdef YYBYACC
@@ -269,7 +291,7 @@
__pragma(warning(disable:4127)) \
__pragma(warning(disable:4242)) \
__pragma(warning(disable:4244)) \
- __pragma(warning(disable:4702))
+ __pragma(warning(disable:4702))
#elif PCAP_IS_AT_LEAST_CLANG_VERSION(2,8)
/*
* This is Clang 2.8 or later; we can use "clang diagnostic
@@ -294,4 +316,20 @@
#endif
#endif
+/*
+ * GCC needs this on AIX for longjmp().
+ */
+#if PCAP_IS_AT_LEAST_GNUC_VERSION(5,1)
+ /*
+ * Beware that the effect of this builtin is more than just squelching the
+ * warning! GCC trusts it enough for the process to segfault if the control
+ * flow reaches the builtin (an infinite empty loop in the same context would
+ * squelch the warning and ruin the process too, albeit in a different way).
+ * So please remember to use this very carefully.
+ */
+ #define PCAP_UNREACHABLE __builtin_unreachable();
+#else
+ #define PCAP_UNREACHABLE
+#endif
+
#endif /* _diag_control_h */
diff --git a/dlpisubs.c b/dlpisubs.c
index 2ef09315..6815b0ec 100644
--- a/dlpisubs.c
+++ b/dlpisubs.c
@@ -146,7 +146,12 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
#endif
#endif
- /* Loop through packets */
+ /*
+ * Loop through packets.
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
+ */
ep = bufp + len;
n = 0;
diff --git a/doc/DLT_ALLOCATE_HOWTO.md b/doc/DLT_ALLOCATE_HOWTO.md
deleted file mode 100644
index ff77128e..00000000
--- a/doc/DLT_ALLOCATE_HOWTO.md
+++ /dev/null
@@ -1,29 +0,0 @@
-DLT and LINKTYPE allocation
-===========================
-
-DLT_ types live in pcap/dlt.h. They can be requested by the community on a
-First-Come First-Served basis [i.e. https://tools.ietf.org/html/rfc8126#section-4.4 ]
-(Although libpcap is not at this time an IETF specification, there have been
-some as yet-incomplete efforts to do this).
-
-The Tcpdump Group prefers to link to an open specification on the new DLT_
-type, but they are available for closed, proprietary projects as well.
-In that case, a stable email address suffices so that someone who finds
-an unknown DLT_ type can investigate.
-We prefer to give out unambiguous numbers, and we try to do it as quickly
-as possible, but DLT_USERx is available while you wait.
-
-Note that DLT_ types are, in theory, private to the capture mechanism and can
-in some cases be operating system specific, and so a second set of values,
-LINKTYPE_ is allocated for actually writing to pcap files. As much as
-possible going forward, the DLT_ and LINKTYPE_ value are identical, however,
-this was not always the case. See pcap-common.c.
-
-The LINKTYPE_ values are not exported, but are in pcap-common.c only.
-
-DEVELOPER NOTES
----------------
-
-When allocating a new DLT_ value, a corresponding value needs to be
-added to pcap-common.c.
-It is not necessary to copy the comments from dlt.h to pcap-common.c.
diff --git a/doc/README.Win32.md b/doc/README.Win32.md
index 626f89ba..7ba7c22d 100644
--- a/doc/README.Win32.md
+++ b/doc/README.Win32.md
@@ -28,7 +28,7 @@ Windows Vista, which is the earliest version supported by Npcap.
Npcap and its SDK can be downloaded from its home page:
- https://npcap.org
+ https://npcap.com
The SDK is a ZIP archive; create a folder on your C: drive, e.g.
C:\npcap-sdk, and put the contents of the ZIP archive into that folder.
diff --git a/doc/README.aix b/doc/README.aix
index 9e9a23d3..86899947 100644
--- a/doc/README.aix
+++ b/doc/README.aix
@@ -1,3 +1,25 @@
+# Compiling libpcap on AIX
+
+* Autoconf is expected to work everywhere.
+* Neither AIX lex nor AIX yacc nor AIX m4 are suitable.
+
+## AIX 7.1
+
+* libpcap build fails with rpcapd enabled.
+* GNU M4 1.4.17 works.
+* flex 2.6.4 and GNU Bison 3.5.1 work.
+* CMake 3.16.0 works.
+* GCC 8.3.0 works, XL C 12.1.0 works.
+
+## AIX 7.2
+
+* libpcap build fails with rpcapd enabled.
+* GNU M4 1.4.17 works.
+* flex 2.5.35 and GNU Bison 3.0.4 work.
+* GCC 7.2.0 works, XL C 13.1.3 works.
+
+## Other AIX-related information
+
Using BPF:
(1) AIX 4.x's version of BPF is undocumented and somewhat unstandard; the
diff --git a/doc/README.capture-module b/doc/README.capture-module
index e13eaf31..b2bf2c09 100644
--- a/doc/README.capture-module
+++ b/doc/README.capture-module
@@ -1,353 +1 @@
- How to write a libpcap module
-
-WARNING: this document describes an unstable interface; future releases
-of libpcap may, and some probably will, change the interface in an
-incompatible fashion. If you submit your module to the libpcap
-developers for inclusion in libpcap, not only does that make it more
-likely that it will be available in the libpcap provided by operating
-system vendors (such as Linux distributions), but it also means that we
-will attempt to update it to handle future changes to this interface.
-If we add new capabilities, we may have to ask you how to provide those
-additional capabilities if you're using an underlying mechanism for
-which we have neither the source code nor the documentation.
-
-NOTE: this document assumes familiarity with the entire libpcap API.
-
-TODO: more routines, more stuff that the activate routine has to do
-(such as setting the list of DLT_s), convert to Markdown?
-
-On Linux, *BSD, macOS, Solaris, AIX, HP-UX, IRIX, and Tru64 UNIX,
-Libpcap supports capturing on network interfaces as supported by the
-operating system networking stack, using the native packet capture
-mechanism provided by the OS. On Windows, it supports it with the help
-of the driver and library supplied by WinPcap and Npcap.
-
-In addition, it also supports capturing on other types of devices, such
-as:
-
- specialized capture cards, such as Endace DAG cards;
-
- network adapters that provide special high-performance code
- paths, such as CSPI Myricom adapters;
-
- buses such as USB;
-
- software communication channels such as D-Bus and Linux netlink;
-
- etc..
-
-Support for those devices is provided by modules compiled into libpcap.
-
-If you want to add such a module, you would first have to check the list
-of link-layer header types supported by libpcap, to see if one of those
-would be sufficient for your device. The current version of the list
-can be found at
-
- https://www.tcpdump.org/linktypes.html
-
-If none of those would work for your device, please read
-doc/DLT_ALLOCATE_HOWTO.md and the introductory paragraphs on the Web
-page mentioned above, and then send a request for the new link-layer
-header type to tcpdump-workers@lists.tcpdump.org.
-
-Once you have a link-layer header type value or values that you can use,
-you can add new module.
-
-The module should be a C source file, with a name of the form
-pcap-{MOD}.c, where {MOD} is a name appropriate for your device; for
-example, the support for DAG cards is in pcap-dag.c, and the support for
-capturing USB traffic on Linux is pcap-usb-linux.c.
-
-Your module is assumed to support one or more named devices. The names
-should be relatively short names, containing only lower-case
-alphanumeric characters, consisting of a prefix that ends with an
-alphabetic character and, if there can be more than one device instance,
-possibly followed by a numerical device ID, such as "mydevice" or
-"mydevice0"/"mydevice1"/.... If you have more than one type of device
-that you can support, you can have more than one prefix, each of which
-can be followed by a numerical device ID.
-
-The two exported functions that your module must provide are routines to
-provide a list of device instances and a program to initialize a
-created-but-not-activated pcap_t for an instance of one of your devices.
-
-The "list of device instances" routine takes, as arguments:
-
- a pointer to a pcap_if_list_t;
-
- a pointer to an error message buffer.
-
-The error message buffer may be assumed to be PCAP_ERRBUF_SIZE bytes
-large, but must not be assumed to be larger. By convention, the routine
-typically has a name containing "findalldevs".
-
-The routine should attempt to determine what device instances are
-available and add them to the list pointed to by the first argument;
-this may be impossible for some modules, but, for those modules, it may
-be difficult to capture on the devices using Wirehshark (although it
-should be possible to capture on them using tcpdump, TShark, or other
-programs that take a device name on the command line), so we recommend
-that your routine provide the list of devices if possible. If it
-cannot, it should just immediately return 0.
-
-The routine should add devices to the list by calling the add_dev()
-routine in libpcap, declared in the pcap-int.h header. It takes, as
-arguments:
-
- the pointer to the pcap_if_list_t passed as an argument to the
- routine;
-
- the device name, as described above;
-
- a 32-bit word of flags, as provided by pcap_findalldevs();
-
- a text description of the device, or NULL if there is no
- description;
-
- the error message buffer pointer provided to the routine.
-
-add_dev() will, if it succeeds, return a pointer to a pcap_if_t that was
-added to the list of devices. If it fails, it will return NULL; in this
-case, the error message buffer has been filled in with an error string,
-and your routine must return -1 to indicate the error.
-
-If your routine succeeds, it must return 0. If it fails, it must fill
-in the error message buffer with an error string and return -1.
-
-The "initialize the pcap_t" routine takes, as arguments:
-
- a pointer to a device name;
-
- a pointer to an error message buffer;
-
- a pointer to an int.
-
-It returns a pointer to a pcap_t.
-
-Your module will probably need, for each pcap_t for an opened device, a
-private data structure to maintain its own information about the opened
-device. These should be allocated per opened instance, not per device;
-if, for example, mydevice0 can be captured on by more than one program
-at the same time, there will be more than one pcap_t opened for
-mydevice0, and so there will be separate private data structures for
-each pcap_t. If you need to maintain per-device, rather than per-opened
-instance information, you will have to maintain that yourself.
-
-The routine should first check the device to see whether it looks like a
-device that this module would handle; for example, it should begin with
-one of the device name prefixes for your module and, if your devices
-have instance numbers, be followed by a number. If it is not one of
-those devices, you must set the integer pointed to by the third
-argument to 0, to indicate that this is *not* one of the devices for
-your module, and return NULL.
-
-If it *is* one of those devices, it should call pcap_create_common,
-passing to it the error message buffer as the first argument and the
-size of the per-opened instance data structure as the second argument.
-If it fails, it will return NULL; you must return NULL in this case.
-
-If it succeeds, the pcap_t pointed to by the return value has been
-partially initialized, but you will need to complete the process. It
-has a "priv" member, which is a void * that points to the private data
-structure attached to it; that structure has been initialized to zeroes.
-
-What you need to set are some function pointers to your routines to
-handle certain operations:
-
- activate_op
- the routine called when pcap_activate() is done on the
- pcap_t
-
- can_set_rfmon_op
- the routine called when pcap_can_set_rfmon() is done on
- the pcap_t - if your device doesn't support 802.11
- monitor mode, you can leave this as initialized by
- pcap_create_common(), as that routine will return "no,
- monitor mode isn't supported".
-
-Once you've set the activate_op and, if necessary, the can_set_rfmon_op,
-you must return the pcap_t * that was returned to you.
-
-Your activate routine takes, as an argument, a pointer to the pcap_t
-being activated, and returns an int.
-
-The perameters set for the device in the pcap_create() call, and after
-that call(), are mostly in the opt member of the pcap_t:
-
- device
- the name of the device
-
- timeout
- the buffering timeout, in milliseconds
-
- buffer_size
- the buffer size to use
-
- promisc
- 1 if promiscuous mode is to be used, 0 otherwise
-
- rfmon
- 1 if monitor mode is to be used, 0 otherwise
-
- immediate
- 1 if the device should be in immediate mode, 0 otherwise
-
- nonblock
- 1 if the device should be in non-blocking mode, 0
- otherwise
-
- tstamp_type
- the type of time stamp to supply
-
- tstamp_precision
- the time stamp precision to supply
-
-The snapshot member of the pcap_t structure will contain the snapshot
-length to be used.
-
-Your routine should attempt to set up the device for capturing. If it
-fails, it must return an error indication which is one of the PCAP_ERROR
-values. For PCAP_ERROR, it must also set the errbuf member of the
-pcap_t to an error string. For PCAP_ERROR_NO_SUCH_DEVICE and
-PCAP_ERROR_PERM_DENIED, it may set it to an error string providing
-additional information that may be useful for debugging, or may just
-leave it as a null string.
-
-If it succeeds, it must set certain function pointers in the pcap_t
-structure:
-
- read_op
- called whenever packets are to be read
-
- inject_op
- called whenever packets are to be injected
-
- setfilter_op
- called whenever pcap_setfilter() is called
-
- setdirection_op
- called whenever pcap_setdirection() is called
-
- set_datalink_op
- called whnever pcap_set_datalink() is called
-
- getnonblock_op
- called whenever pcap_getnonblock() is called
-
- setnonblock_op
- called whenever pcap_setnonblock() is called
-
- stats_op
- called whenever pcap_stats() is called
-
- cleanup_op
- called if the activate routine fails or pcap_close() is
- called
-
-and must also set the linktype member to the DLT_ value for the device.
-
-On UN*Xes, if the device supports waiting for packets to arrive with
-select()/poll()/epoll()/kqueues etc., it should set the selectable_fd
-member of the structure to the descriptor you would use with those
-calls. If it does not, then, if that's because the device polls for
-packets rather than receiving interrupts or other signals when packets
-arrive, it should have a struct timeval in the private data structure,
-set the value of that struct timeval to the poll timeout, and set the
-required_select_timeout member of the pcap_t to point to the struct
-timeval.
-
-The read_op routine is called when pcap_dispatch(), pcap_loop(),
-pcap_next(), or pcap_next_ex() is called. It is passed the same
-arguments as pcap_dispatch() is called.
-
-The routine should first check if the break_loop member of the pcap_t is
-non-zero and, if so, set that member to zero and return
-PCAP_ERROR_BREAK.
-
-Then, if the pcap_t is in blocking mode (as opposed to non-blocking
-mode), and there are no packets immediately available to be passed to
-the callback, it should block waiting for packets to arrive, using the
-buffering timeout, first, and read packets from the device if necessary.
-
-Then it should loop through the available packets, calling the callback
-routine for each packet:
-
- If the PACKET_COUNT_IS_UNLIMITED() macro evaluates to true when
- passed the packet count argument, the loop should continue until
- there are no more packets immediately available or the
- break_loop member of the pcap_t is non-zero. If the break_loop
- member is fount to be non-zero, it should set that member to
- zero and return PCAP_ERROR_BREAK.
-
- If it doesn't evaluat to true, then the loop should also
- terminate if the specified number of packets have been delivered
- to the callback.
-
-Note that there is *NO* requirement that the packet header or data
-provided to the callback remain available, or valid, after the callback
-routine returns; if the callback needs to save the data for other code
-to use, it must make a copy of that data. This means that the module is
-free to, for example, overwrite the buffer into which it read the
-packet, or release back to the kernel a packet in a memory-mapped
-buffer shared between the kernel and userland, after the callback
-returns.
-
-If an error occurs when reading packets from the device, it must set the
-errbuf member of the pcap_t to an error string and return PCAP_ERROR.
-
-If no error occurs, it must return the number of packets that were
-supplied to the callback routine.
-
-The inject routine is passed a pointer to the pcap_t, a buffer
-containing the contents of the packet to inject, and the number of bytes
-in the packet. If the device doesn't support packet injection, the
-routine must set the errbuf member of the pcap_t to a message indicating
-that packet injection isn't supported and return PCAP_ERROR. Otherwise,
-it should attempt to inject the packet; if the attempt fails, it must
-set the errbuf member of the pcap_t to an error message and return
-PCAP_ERROR. Otherwise, it should return the number of bytes injected.
-
-The setfilter routine is passed a pointer to the pcap_t and a pointer
-to a struct bpf_program containing a BPF program to be used as a filter.
-If the mechanism used by your module can perform filtering with a BPF
-program, it would attempt to set that filter to the specified program.
-
-If that failed because the program was too large, or used BPF features
-not supported by that mechanism, the module should fall back on
-filtering in userland by saving a copy of the filter with a call to
-install_bpf_program(), setting a flag in the private data instructure
-indicating that filtering is being done by the module and, in the read
-routine's main loop, checking the flag and, if it's set, calling
-pcap_filter(), passing it the fcode.bf_insns member of the pcap_t, the
-raw packet data, the on-the-wire length of the packet, and the captured
-length of the packet, and only passing the packet to the callback
-routine, and counting it, if pcap_filter() returns a non-zero value.
-(If the flag is not set, all packets should be passed to the callback
-routine and counted, as the filtering is being done by the mechanism
-used by the module.) If install_bpf_program() returns a negative value,
-the routine should return PCAP_ERROR.
-
-If the attempt to set the filter failed for any other reason, the
-routine must set the errbuf member of the pcap_t to an error message and
-return PCAP_ERROR.
-
-If the attempt to set the filter succeeded, or it failed because the
-mechanism used by the module rejected it and the call to
-install_bpf_program() succeeded, the routine should return 0.
-
-If the mechanism the module uses doesn't support filtering, the pointer
-to the setfilter routine can just be set to point to
-install_bpf_program; the module does not need a routine of its own to
-handle that.
-
-The setdirection routine is passed a pointer to the pcap_t and a
-pcap_direction_t indicating which packet directions should be accepted.
-If the module can't arrange to handle only incoming packets or only
-outgoing packets, it can set the pointer to the setdirection routine to
-NULL, and calls to pcap_setdirection() will fail with an error message
-indicating that setting the direction isn't supported.
-
-XXX describe set_datalink, including what the activate routine has to do
-XXX
-
-XXX describe the rest of the routines XXX
+This document has moved to https://www.tcpdump.org/libpcap-module-HOWTO.html
diff --git a/doc/README.dag b/doc/README.dag
index 13332c62..fd2c4b74 100644
--- a/doc/README.dag
+++ b/doc/README.dag
@@ -22,7 +22,7 @@ If 'configure' reports that there is no DAG API, the directory may have been
incorrectly specified or the DAG software was not built before configuring
libpcap.
-See also the libpcap INSTALL.txt file for further libpcap configuration
+See also the libpcap INSTALL.md file for further libpcap configuration
options.
Building libpcap at this stage will include support for both the native packet
diff --git a/doc/README.linux.md b/doc/README.linux
index 143dff65..143dff65 100644
--- a/doc/README.linux.md
+++ b/doc/README.linux
diff --git a/doc/README.septel b/doc/README.septel
index 203ec1a6..d7fb5c7c 100644
--- a/doc/README.septel
+++ b/doc/README.septel
@@ -25,7 +25,7 @@ If 'configure' reports that there is no Septel API, the directory may have been
incorrectly specified or the Septel software was not built before configuring
libpcap.
-See also the libpcap INSTALL.txt file for further libpcap configuration
+See also the libpcap INSTALL.md file for further libpcap configuration
options.
Building libpcap at this stage will include support for both the native
diff --git a/doc/README.sita b/doc/README.sita
index 37003f53..c85e0d8c 100644
--- a/doc/README.sita
+++ b/doc/README.sita
@@ -12,7 +12,7 @@ libpcap to support the 'ACN' WAN/LAN router product from SITA
This might also work on non-Linux Unix-compatible platforms, but that
has not been tested.
-See also the libpcap INSTALL.txt file for further libpcap configuration
+See also the libpcap INSTALL.md file for further libpcap configuration
options.
These additions/extensions have been made to PCAP to allow it to
diff --git a/doc/README.solaris.md b/doc/README.solaris.md
new file mode 100644
index 00000000..07456712
--- /dev/null
+++ b/doc/README.solaris.md
@@ -0,0 +1,44 @@
+# Compiling libpcap on Solaris and related OSes
+
+* Autoconf works everywhere.
+* Neither Solaris lex nor Solaris yacc are suitable.
+* Neither OpenIndiana lex nor OpenIndiana yacc are suitable.
+* Solaris m4 and OpenIndiana m4 are suitable.
+
+## OpenIndiana 2021.04/AMD64
+
+* flex 2.6.4 and GNU Bison 3.7.6 work.
+* CMake 3.21.1 works.
+* GCC 7.5.0 and GCC 10.3.0 work, Clang 9.0.1 works.
+
+For reference, the tests were done using a system installed from
+`OI-hipster-text-20210430.iso` plus the following packages:
+```shell
+xargs -L1 pkg install <<ENDOFTEXT
+developer/build/autoconf
+developer/parser/bison
+developer/lexer/flex
+developer/build/cmake
+developer/gcc-10
+developer/clang-90
+ENDOFTEXT
+```
+
+## Solaris 11/SPARC
+
+* flex 2.6.4 and GNU Bison 3.7.1 work.
+* CMake 3.14.3 works.
+* Sun C 5.13, Sun C 5.14 and Sun C 5.15 work; GCC 5.5.0 and GCC 7.3.0 work.
+
+## Solaris 10/SPARC
+
+* libpcap build fails with rpcapd enabled.
+* flex 2.6.4 and GNU Bison 3.7.1 work.
+* CMake 3.14.3 works.
+* Sun C 5.13 works, GCC 5.5.0 works.
+
+## Solaris 9/SPARC
+
+* flex 2.5.35 and GNU Bison 3.0.2 work.
+* CMake 2.8.9 does not work.
+* Neither Sun C 5.8 nor Sun C 5.9 work, GCC 4.6.4 works.
diff --git a/doc/README.tru64 b/doc/README.tru64
deleted file mode 100644
index 2420d9e1..00000000
--- a/doc/README.tru64
+++ /dev/null
@@ -1,49 +0,0 @@
-The following instructions are applicable to Tru64 UNIX
-(formerly Digital UNIX (formerly DEC OSF/1)) version 4.0, and
-probably to later versions as well; at least some options apply to
-Digital UNIX 3.2 - perhaps all do.
-
-In order to use kernel packet filtering on this system, you have
-to configure it in such a way:
-
-Kernel configuration
---------------------
-
-The packet filtering kernel option must be enabled at kernel
-installation. If it was not the case, you can rebuild the kernel with
-"doconfig -c" after adding the following line in the kernel
-configuration file (/sys/conf/<HOSTNAME>):
-
- option PACKETFILTER
-
-or use "doconfig" without any arguments to add the packet filter driver
-option via the kernel option menu (see the system administration
-documentation for information on how to do this).
-
-Device configuration
---------------------
-
-Devices used for packet filtering must be created thanks to
-the following command (executed in the /dev directory):
-
- ./MAKEDEV pfilt
-
-Interface configuration
------------------------
-
-In order to capture all packets on a network, you may want to allow
-applications to put the interface on that network into "local copy"
-mode, so that tcpdump can see packets sent by the host on which it's
-running as well as packets received by that host, and to put the
-interface into "promiscuous" mode, so that tcpdump can see packets on
-the network segment not sent to the host on which it's running, by using
-the pfconfig(1) command:
-
- pfconfig +c +p <network_device>
-
-or allow application to put any interface into "local copy" or
-"promiscuous" mode by using the command:
-
- pfconfig +c +p -a
-
-Note: all instructions given require root privileges.
diff --git a/ftmacros.h b/ftmacros.h
index 3fafab80..7975463b 100644
--- a/ftmacros.h
+++ b/ftmacros.h
@@ -45,7 +45,12 @@
* namespace to the maximum extent possible"?
*/
#if defined(sun) || defined(__sun)
- #define __EXTENSIONS__
+ /*
+ * On Solaris Clang defines __EXTENSIONS__ automatically.
+ */
+ #ifndef __EXTENSIONS__
+ #define __EXTENSIONS__
+ #endif
/*
* We also need to define _XPG4_2 in order to get
@@ -105,9 +110,18 @@
* 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.
+ *
+ * But, if it's already defined, don't define it, so that we don't
+ * get a warning of it being redefined if it's defined as, for
+ * example, 1.
*/
- #define _DEFAULT_SOURCE
- #define _BSD_SOURCE
+ #ifndef _DEFAULT_SOURCE
+ #define _DEFAULT_SOURCE
+ #endif
+ /* Avoid redefining _BSD_SOURCE if it's already defined as for ex. 1 */
+ #ifndef _BSD_SOURCE
+ #define _BSD_SOURCE
+ #endif
#endif
#endif
diff --git a/gencode.c b/gencode.c
index 29788598..02c4bd58 100644
--- a/gencode.c
+++ b/gencode.c
@@ -59,12 +59,13 @@
#include "ieee80211.h"
#include "atmuni31.h"
#include "sunatmpos.h"
+#include "pflog.h"
#include "ppp.h"
#include "pcap/sll.h"
#include "pcap/ipnet.h"
#include "arcnet.h"
+#include "diag-control.h"
-#include "grammar.h"
#include "scanner.h"
#if defined(linux)
@@ -73,13 +74,6 @@
#include <linux/filter.h>
#endif
-#ifdef HAVE_NET_PFVAR_H
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/pfvar.h>
-#include <net/if_pflog.h>
-#endif
-
#ifndef offsetof
#define offsetof(s, e) ((size_t)&((s *)0)->e)
#endif
@@ -468,6 +462,9 @@ bpf_error(compiler_state_t *cstate, const char *fmt, ...)
va_end(ap);
longjmp(cstate->top_ctx, 1);
/*NOTREACHED*/
+#ifdef _AIX
+ PCAP_UNREACHABLE
+#endif /* _AIX */
}
static int init_linktype(compiler_state_t *, pcap_t *);
@@ -514,6 +511,7 @@ static inline struct block *gen_false(compiler_state_t *);
static struct block *gen_ether_linktype(compiler_state_t *, bpf_u_int32);
static struct block *gen_ipnet_linktype(compiler_state_t *, bpf_u_int32);
static struct block *gen_linux_sll_linktype(compiler_state_t *, bpf_u_int32);
+static struct slist *gen_load_pflog_llprefixlen(compiler_state_t *);
static struct slist *gen_load_prism_llprefixlen(compiler_state_t *);
static struct slist *gen_load_avs_llprefixlen(compiler_state_t *);
static struct slist *gen_load_radiotap_llprefixlen(compiler_state_t *);
@@ -1258,6 +1256,7 @@ init_linktype(compiler_state_t *cstate, pcap_t *p)
case DLT_PPP:
case DLT_PPP_PPPD:
case DLT_C_HDLC: /* BSD/OS Cisco HDLC */
+ case DLT_HDLC: /* NetBSD (Cisco) HDLC */
case DLT_PPP_SERIAL: /* NetBSD sync/async serial PPP */
cstate->off_linktype.constant_part = 2; /* skip HDLC-like framing */
cstate->off_linkpl.constant_part = 4; /* skip HDLC-like framing and protocol field */
@@ -1506,14 +1505,13 @@ init_linktype(compiler_state_t *cstate, pcap_t *p)
cstate->off_nl_nosnap = 0; /* XXX - what does it do with 802.3 packets? */
break;
-#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
cstate->off_linktype.constant_part = 0;
- cstate->off_linkpl.constant_part = PFLOG_HDRLEN;
+ cstate->off_linkpl.constant_part = 0; /* link-layer header is variable-length */
+ cstate->off_linkpl.is_variable = 1;
cstate->off_nl = 0;
cstate->off_nl_nosnap = 0; /* no 802.2 LLC */
break;
-#endif
case DLT_JUNIPER_MFR:
case DLT_JUNIPER_MLFR:
@@ -1715,7 +1713,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p)
cstate->off_nl = OFFSET_NOT_SET;
cstate->off_nl_nosnap = OFFSET_NOT_SET;
} else {
- bpf_set_error(cstate, "unknown data link type %d", cstate->linktype);
+ bpf_set_error(cstate, "unknown data link type %d (min %d, max %d)",
+ cstate->linktype, DLT_MATCHING_MIN, DLT_MATCHING_MAX);
return (-1);
}
break;
@@ -2337,6 +2336,59 @@ gen_linux_sll_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto)
}
}
+/*
+ * Load a value relative to the beginning of the link-layer header after the
+ * pflog header.
+ */
+static struct slist *
+gen_load_pflog_llprefixlen(compiler_state_t *cstate)
+{
+ struct slist *s1, *s2;
+
+ /*
+ * Generate code to load the length of the pflog header into
+ * the register assigned to hold that length, if one has been
+ * assigned. (If one hasn't been assigned, no code we've
+ * generated uses that prefix, so we don't need to generate any
+ * code to load it.)
+ */
+ if (cstate->off_linkpl.reg != -1) {
+ /*
+ * The length is in the first byte of the header.
+ */
+ s1 = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
+ s1->s.k = 0;
+
+ /*
+ * Round it up to a multiple of 4.
+ * Add 3, and clear the lower 2 bits.
+ */
+ s2 = new_stmt(cstate, BPF_ALU|BPF_ADD|BPF_K);
+ s2->s.k = 3;
+ sappend(s1, s2);
+ s2 = new_stmt(cstate, BPF_ALU|BPF_AND|BPF_K);
+ s2->s.k = 0xfffffffc;
+ sappend(s1, s2);
+
+ /*
+ * Now allocate a register to hold that value and store
+ * it.
+ */
+ s2 = new_stmt(cstate, BPF_ST);
+ s2->s.k = cstate->off_linkpl.reg;
+ sappend(s1, s2);
+
+ /*
+ * Now move it into the X register.
+ */
+ s2 = new_stmt(cstate, BPF_MISC|BPF_TAX);
+ sappend(s1, s2);
+
+ return (s1);
+ } else
+ return (NULL);
+}
+
static struct slist *
gen_load_prism_llprefixlen(compiler_state_t *cstate)
{
@@ -2924,6 +2976,10 @@ insert_compute_vloffsets(compiler_state_t *cstate, struct block *b)
case DLT_PPI:
s = gen_load_802_11_header_len(cstate, s, b->stmts);
break;
+
+ case DLT_PFLOG:
+ s = gen_load_pflog_llprefixlen(cstate);
+ break;
}
/*
@@ -3159,6 +3215,7 @@ gen_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto)
/*NOTREACHED*/
case DLT_C_HDLC:
+ case DLT_HDLC:
switch (ll_proto) {
case LLCSAP_ISONS:
@@ -3388,7 +3445,6 @@ gen_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto)
return gen_false(cstate);
}
-#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
/*
* af field is host byte order in contrast to the rest of
@@ -3403,7 +3459,6 @@ gen_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto)
else
return gen_false(cstate);
/*NOTREACHED*/
-#endif /* HAVE_NET_PFVAR_H */
case DLT_ARCNET:
case DLT_ARCNET_LINUX:
@@ -6080,7 +6135,18 @@ gen_protochain(compiler_state_t *cstate, bpf_u_int32 v, int proto)
if (cstate->off_linkpl.is_variable)
bpf_error(cstate, "'protochain' not supported with variable length headers");
- cstate->no_optimize = 1; /* this code is not compatible with optimizer yet */
+ /*
+ * To quote a comment in optimize.c:
+ *
+ * "These data structures are used in a Cocke and Shwarz style
+ * value numbering scheme. Since the flowgraph is acyclic,
+ * exit values can be propagated from a node's predecessors
+ * provided it is uniquely defined."
+ *
+ * "Acyclic" means "no backward branches", which means "no
+ * loops", so we have to turn the optimizer off.
+ */
+ cstate->no_optimize = 1;
/*
* s[0] is a dummy entry to protect other BPF insn from damage
@@ -6532,6 +6598,7 @@ gen_proto(compiler_state_t *cstate, bpf_u_int32 v, int proto, int dir)
/*NOTREACHED*/
case DLT_C_HDLC:
+ case DLT_HDLC:
/*
* Cisco uses an Ethertype lookalike - for OSI,
* it's 0xfefe.
@@ -8282,12 +8349,10 @@ gen_inbound(compiler_state_t *cstate, int dir)
}
break;
-#ifdef HAVE_NET_PFVAR_H
case DLT_PFLOG:
b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, dir), BPF_B,
((dir == 0) ? PF_IN : PF_OUT));
break;
-#endif
case DLT_PPP_PPPD:
if (dir) {
@@ -8378,7 +8443,6 @@ gen_inbound(compiler_state_t *cstate, int dir)
return (b0);
}
-#ifdef HAVE_NET_PFVAR_H
/* PF firewall log matched interface */
struct block *
gen_pf_ifname(compiler_state_t *cstate, const char *ifname)
@@ -8529,91 +8593,6 @@ gen_pf_action(compiler_state_t *cstate, int action)
(bpf_u_int32)action);
return (b0);
}
-#else /* !HAVE_NET_PFVAR_H */
-struct block *
-gen_pf_ifname(compiler_state_t *cstate, const char *ifname _U_)
-{
- /*
- * Catch errors reported by us and routines below us, and return NULL
- * on an error.
- */
- if (setjmp(cstate->top_ctx))
- return (NULL);
-
- bpf_error(cstate, "libpcap was compiled without pf support");
- /*NOTREACHED*/
-}
-
-struct block *
-gen_pf_ruleset(compiler_state_t *cstate, char *ruleset _U_)
-{
- /*
- * Catch errors reported by us and routines below us, and return NULL
- * on an error.
- */
- if (setjmp(cstate->top_ctx))
- return (NULL);
-
- bpf_error(cstate, "libpcap was compiled on a machine without pf support");
- /*NOTREACHED*/
-}
-
-struct block *
-gen_pf_rnr(compiler_state_t *cstate, int rnr _U_)
-{
- /*
- * Catch errors reported by us and routines below us, and return NULL
- * on an error.
- */
- if (setjmp(cstate->top_ctx))
- return (NULL);
-
- bpf_error(cstate, "libpcap was compiled on a machine without pf support");
- /*NOTREACHED*/
-}
-
-struct block *
-gen_pf_srnr(compiler_state_t *cstate, int srnr _U_)
-{
- /*
- * Catch errors reported by us and routines below us, and return NULL
- * on an error.
- */
- if (setjmp(cstate->top_ctx))
- return (NULL);
-
- bpf_error(cstate, "libpcap was compiled on a machine without pf support");
- /*NOTREACHED*/
-}
-
-struct block *
-gen_pf_reason(compiler_state_t *cstate, int reason _U_)
-{
- /*
- * Catch errors reported by us and routines below us, and return NULL
- * on an error.
- */
- if (setjmp(cstate->top_ctx))
- return (NULL);
-
- bpf_error(cstate, "libpcap was compiled on a machine without pf support");
- /*NOTREACHED*/
-}
-
-struct block *
-gen_pf_action(compiler_state_t *cstate, int action _U_)
-{
- /*
- * Catch errors reported by us and routines below us, and return NULL
- * on an error.
- */
- if (setjmp(cstate->top_ctx))
- return (NULL);
-
- bpf_error(cstate, "libpcap was compiled on a machine without pf support");
- /*NOTREACHED*/
-}
-#endif /* HAVE_NET_PFVAR_H */
/* IEEE 802.11 wireless header */
struct block *
@@ -9077,6 +9056,7 @@ gen_mpls(compiler_state_t *cstate, bpf_u_int32 label_num_arg,
switch (cstate->linktype) {
case DLT_C_HDLC: /* fall through */
+ case DLT_HDLC:
case DLT_EN10MB:
case DLT_NETANALYZER:
case DLT_NETANALYZER_TRANSPARENT:
diff --git a/gencode.h b/gencode.h
index 053e85f9..9631dd02 100644
--- a/gencode.h
+++ b/gencode.h
@@ -19,7 +19,11 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#ifndef gencode_h
+#define gencode_h
+
#include "pcap/funcattrs.h"
+#include "pcap/bpf.h" /* bpf_u_int32 and BPF_MEMWORDS */
/*
* ATM support:
@@ -400,3 +404,5 @@ int pcap_parse(void *, compiler_state_t *);
/* XXX */
#define JT(b) ((b)->et.succ)
#define JF(b) ((b)->ef.succ)
+
+#endif /* gencode_h */
diff --git a/grammar.y.in b/grammar.y.in
index fe565155..2360d3c7 100644
--- a/grammar.y.in
+++ b/grammar.y.in
@@ -71,6 +71,13 @@
#include <config.h>
#endif
+/*
+ * grammar.h requires gencode.h and sometimes breaks in a polluted namespace
+ * (see ftmacros.h), so include it early.
+ */
+#include "gencode.h"
+#include "grammar.h"
+
#include <stdlib.h>
#ifndef _WIN32
@@ -92,17 +99,11 @@ struct rtentry;
#include "pcap-int.h"
-#include "gencode.h"
-#include "grammar.h"
#include "scanner.h"
-#ifdef HAVE_NET_PFVAR_H
-#include <net/if.h>
-#include <net/pfvar.h>
-#include <net/if_pflog.h>
-#endif
#include "llc.h"
#include "ieee80211.h"
+#include "pflog.h"
#include <pcap/namedb.h>
#ifdef HAVE_OS_PROTO_H
@@ -171,6 +172,8 @@ static const struct tok ieee80211_mgt_subtypes[] = {
{ 0, NULL }
};
static const struct tok ieee80211_ctl_subtypes[] = {
+ { IEEE80211_FC0_SUBTYPE_BAR, "bar" },
+ { IEEE80211_FC0_SUBTYPE_BA, "ba" },
{ IEEE80211_FC0_SUBTYPE_PS_POLL, "ps-poll" },
{ IEEE80211_FC0_SUBTYPE_RTS, "rts" },
{ IEEE80211_FC0_SUBTYPE_CTS, "cts" },
@@ -254,60 +257,87 @@ yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg)
bpf_set_error(cstate, "can't parse filter expression: %s", msg);
}
-#ifdef HAVE_NET_PFVAR_H
+static const struct tok pflog_reasons[] = {
+ { PFRES_MATCH, "match" },
+ { PFRES_BADOFF, "bad-offset" },
+ { PFRES_FRAG, "fragment" },
+ { PFRES_SHORT, "short" },
+ { PFRES_NORM, "normalize" },
+ { PFRES_MEMORY, "memory" },
+ { PFRES_TS, "bad-timestamp" },
+ { PFRES_CONGEST, "congestion" },
+ { PFRES_IPOPTIONS, "ip-option" },
+ { PFRES_PROTCKSUM, "proto-cksum" },
+ { PFRES_BADSTATE, "state-mismatch" },
+ { PFRES_STATEINS, "state-insert" },
+ { PFRES_MAXSTATES, "state-limit" },
+ { PFRES_SRCLIMIT, "src-limit" },
+ { PFRES_SYNPROXY, "synproxy" },
+#if defined(__FreeBSD__)
+ { PFRES_MAPFAILED, "map-failed" },
+#elif defined(__NetBSD__)
+ { PFRES_STATELOCKED, "state-locked" },
+#elif defined(__OpenBSD__)
+ { PFRES_TRANSLATE, "translate" },
+ { PFRES_NOROUTE, "no-route" },
+#elif defined(__APPLE__)
+ { PFRES_DUMMYNET, "dummynet" },
+#endif
+ { 0, NULL }
+};
+
static int
pfreason_to_num(compiler_state_t *cstate, const char *reason)
{
- const char *reasons[] = PFRES_NAMES;
int i;
- for (i = 0; reasons[i]; i++) {
- if (pcap_strcasecmp(reason, reasons[i]) == 0)
- return (i);
- }
- bpf_set_error(cstate, "unknown PF reason \"%s\"", reason);
- return (-1);
+ i = str2tok(reason, pflog_reasons);
+ if (i == -1)
+ bpf_set_error(cstate, "unknown PF reason \"%s\"", reason);
+ return (i);
}
-static int
-pfaction_to_num(compiler_state_t *cstate, const char *action)
-{
- if (pcap_strcasecmp(action, "pass") == 0 ||
- pcap_strcasecmp(action, "accept") == 0)
- return (PF_PASS);
- else if (pcap_strcasecmp(action, "drop") == 0 ||
- pcap_strcasecmp(action, "block") == 0)
- return (PF_DROP);
-#if HAVE_PF_NAT_THROUGH_PF_NORDR
- else if (pcap_strcasecmp(action, "rdr") == 0)
- return (PF_RDR);
- else if (pcap_strcasecmp(action, "nat") == 0)
- return (PF_NAT);
- else if (pcap_strcasecmp(action, "binat") == 0)
- return (PF_BINAT);
- else if (pcap_strcasecmp(action, "nordr") == 0)
- return (PF_NORDR);
+static const struct tok pflog_actions[] = {
+ { PF_PASS, "pass" },
+ { PF_PASS, "accept" }, /* alias for "pass" */
+ { PF_DROP, "drop" },
+ { PF_DROP, "block" }, /* alias for "drop" */
+ { PF_SCRUB, "scrub" },
+ { PF_NOSCRUB, "noscrub" },
+ { PF_NAT, "nat" },
+ { PF_NONAT, "nonat" },
+ { PF_BINAT, "binat" },
+ { PF_NOBINAT, "nobinat" },
+ { PF_RDR, "rdr" },
+ { PF_NORDR, "nordr" },
+ { PF_SYNPROXY_DROP, "synproxy-drop" },
+#if defined(__FreeBSD__)
+ { PF_DEFER, "defer" },
+#elif defined(__OpenBSD__)
+ { PF_DEFER, "defer" },
+ { PF_MATCH, "match" },
+ { PF_DIVERT, "divert" },
+ { PF_RT, "rt" },
+ { PF_AFRT, "afrt" },
+#elif defined(__APPLE__)
+ { PF_DUMMYNET, "dummynet" },
+ { PF_NODUMMYNET, "nodummynet" },
+ { PF_NAT64, "nat64" },
+ { PF_NONAT64, "nonat64" },
#endif
- else {
- bpf_set_error(cstate, "unknown PF action \"%s\"", action);
- return (-1);
- }
-}
-#else /* !HAVE_NET_PFVAR_H */
-static int
-pfreason_to_num(compiler_state_t *cstate, const char *reason _U_)
-{
- bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
- return (-1);
-}
+ { 0, NULL },
+};
static int
-pfaction_to_num(compiler_state_t *cstate, const char *action _U_)
+pfaction_to_num(compiler_state_t *cstate, const char *action)
{
- bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
- return (-1);
+ int i;
+
+ i = str2tok(action, pflog_actions);
+ if (i == -1)
+ bpf_set_error(cstate, "unknown PF action \"%s\"", action);
+ return (i);
}
-#endif /* HAVE_NET_PFVAR_H */
/*
* For calls that might return an "an error occurred" value.
@@ -650,7 +680,7 @@ subtype: NUM { if (($1 & (~IEEE80211_FC0_SUBTYPE_MASK)) != 0) {
bpf_set_error(cstate, "unknown 802.11 type");
YYABORT;
}
- if (-1 == ieee80211_type_subtypes[i].type) {
+ if ($<i>-1 == ieee80211_type_subtypes[i].type) {
types = ieee80211_type_subtypes[i].tok;
break;
}
diff --git a/ieee80211.h b/ieee80211.h
index 473803d8..8b2641f3 100644
--- a/ieee80211.h
+++ b/ieee80211.h
@@ -62,6 +62,8 @@
#define IEEE80211_FC0_SUBTYPE_AUTH 0xb0
#define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0
/* for TYPE_CTL */
+#define IEEE80211_FC0_SUBTYPE_BAR 0x80
+#define IEEE80211_FC0_SUBTYPE_BA 0x90
#define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0
#define IEEE80211_FC0_SUBTYPE_RTS 0xb0
#define IEEE80211_FC0_SUBTYPE_CTS 0xc0
@@ -124,7 +126,7 @@
"reserved#2", "reserved#3", \
"reserved#3", "reserved#5", \
"reserved#6", "reserved#7", \
- "reserved#8", "reserved#9", \
+ "bar", "ba", \
"ps-poll", "rts", \
"cts", "ack", \
"cf-end", "cf-end-ack" \
diff --git a/nametoaddr.c b/nametoaddr.c
index c944ad36..55f93897 100644
--- a/nametoaddr.c
+++ b/nametoaddr.c
@@ -785,9 +785,14 @@ pcap_ether_hostton(const char *name)
{
register u_char *ap;
u_char a[6];
+ char namebuf[1024];
+ /*
+ * In AIX 7.1 and 7.2: int ether_hostton(char *, struct ether_addr *);
+ */
+ pcap_strlcpy(namebuf, name, sizeof(namebuf));
ap = NULL;
- if (ether_hostton(name, (struct ether_addr *)a) == 0) {
+ if (ether_hostton(namebuf, (struct ether_addr *)a) == 0) {
ap = (u_char *)malloc(6);
if (ap != NULL)
memcpy((char *)ap, (char *)a, 6);
diff --git a/optimize.c b/optimize.c
index 610a0303..6fefeada 100644
--- a/optimize.c
+++ b/optimize.c
@@ -32,13 +32,14 @@
#include <memory.h>
#include <setjmp.h>
#include <string.h>
-
+#include <limits.h> /* for SIZE_MAX */
#include <errno.h>
#include "pcap-int.h"
#include "gencode.h"
#include "optimize.h"
+#include "diag-control.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
@@ -2421,6 +2422,9 @@ opt_error(opt_state_t *opt_state, const char *fmt, ...)
}
longjmp(opt_state->top_ctx, 1);
/* NOTREACHED */
+#ifdef _AIX
+ PCAP_UNREACHABLE
+#endif /* _AIX */
}
/*
@@ -2895,7 +2899,6 @@ icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp,
if (fp == NULL) {
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
"malloc");
- free(fp);
return NULL;
}
memset((char *)fp, 0, sizeof(*fp) * n);
@@ -2925,6 +2928,9 @@ conv_error(conv_state_t *conv_state, const char *fmt, ...)
va_end(ap);
longjmp(conv_state->top_ctx, 1);
/* NOTREACHED */
+#ifdef _AIX
+ PCAP_UNREACHABLE
+#endif /* _AIX */
}
/*
diff --git a/pcap-airpcap.c b/pcap-airpcap.c
index 703f23ac..510e4c4e 100644
--- a/pcap-airpcap.c
+++ b/pcap-airpcap.c
@@ -158,7 +158,7 @@ load_airpcap_functions(void)
* AIRPCAP_API_LOADING, in which case *we're* the
* ones loading it, and should now try to do so.
*/
- if (current_status == AIRPCAP_API_LOADED)
+ if (current_status == AIRPCAP_API_LOADED)
return AIRPCAP_API_LOADED;
if (current_status == AIRPCAP_API_CANNOT_LOAD)
@@ -627,6 +627,9 @@ airpcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
/*
* Loop through each packet.
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
*/
#define bhp ((AirpcapBpfHeader *)bp)
n = 0;
@@ -974,7 +977,14 @@ airpcap_create(const char *device, char *ebuf, int *is_ours)
* so do so if we haven't already tried to do so.
*/
if (load_airpcap_functions() != AIRPCAP_API_LOADED) {
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "Couldn't load AirPcap DLL\n");
+ /*
+ * We assume this means that we don't have the AirPcap
+ * software installed, which probably means we don't
+ * have an AirPcap device.
+ *
+ * Don't treat that as an error.
+ */
+ *is_ours = 0;
return (NULL);
}
diff --git a/pcap-bpf.c b/pcap-bpf.c
index f0ccb965..c9967ee0 100644
--- a/pcap-bpf.c
+++ b/pcap-bpf.c
@@ -1177,6 +1177,9 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
/*
* Loop through each packet.
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
*/
#ifdef BIOCSTSTAMP
#define bhp ((struct bpf_xhdr *)bp)
@@ -2968,7 +2971,7 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
}
#else
static int
-get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
+get_if_flags(const char *name _U_, bpf_u_int32 *flags, char *errbuf _U_)
{
/*
* Nothing we can do other than mark loopback devices as "the
diff --git a/pcap-bt-linux.c b/pcap-bt-linux.c
index 2969ff8d..37c80565 100644
--- a/pcap-bt-linux.c
+++ b/pcap-bt-linux.c
@@ -98,6 +98,14 @@ bt_findalldevs(pcap_if_list_t *devlistp, char *err_str)
goto done;
}
+ /*
+ * Zero the complete header, which is larger than dev_num because of tail
+ * padding, to silence Valgrind, which overshoots validating that dev_num
+ * has been set.
+ * https://github.com/the-tcpdump-group/libpcap/issues/1083
+ * https://bugs.kde.org/show_bug.cgi?id=448464
+ */
+ memset(dev_list, 0, sizeof(*dev_list));
dev_list->dev_num = HCI_MAX_DEV;
if (ioctl(sock, HCIGETDEVLIST, (void *) dev_list) < 0)
@@ -341,6 +349,10 @@ bt_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char
} while ((ret == -1) && (errno == EINTR));
if (ret < 0) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* Nonblocking mode, no data */
+ return 0;
+ }
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
errno, "Can't receive packet");
return -1;
diff --git a/pcap-bt-monitor-linux.c b/pcap-bt-monitor-linux.c
index ad4fc375..206e65b5 100644
--- a/pcap-bt-monitor-linux.c
+++ b/pcap-bt-monitor-linux.c
@@ -127,6 +127,10 @@ bt_monitor_read(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_ch
} while ((ret == -1) && (errno == EINTR));
if (ret < 0) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* Nonblocking mode, no data */
+ return 0;
+ }
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
errno, "Can't receive packet");
return -1;
diff --git a/pcap-common.c b/pcap-common.c
index 51d0666f..fcfe8bff 100644
--- a/pcap-common.c
+++ b/pcap-common.c
@@ -34,6 +34,8 @@
#include "pcap/nflog.h"
#include "pcap/can_socketcan.h"
+#include "pflog.h"
+
#include "pcap-common.h"
/*
@@ -168,11 +170,20 @@
#define LINKTYPE_ENC 109 /* OpenBSD IPSEC enc */
/*
- * These three types are reserved for future use.
+ * These two types are reserved for future use.
*/
#define LINKTYPE_LANE8023 110 /* ATM LANE + 802.3 */
#define LINKTYPE_HIPPI 111 /* NetBSD HIPPI */
-#define LINKTYPE_HDLC 112 /* NetBSD HDLC framing */
+
+/*
+ * Used for NetBSD DLT_HDLC; from looking at the one driver in NetBSD
+ * that uses it, it's Cisco HDLC, so it's the same as DLT_C_HDLC/
+ * LINKTYPE_C_HDLC, but we define a separate value to avoid some
+ * compatibility issues with programs on NetBSD.
+ *
+ * All code should treat LINKTYPE_NETBSD_HDLC and LINKTYPE_C_HDLC the same.
+ */
+#define LINKTYPE_NETBSD_HDLC 112 /* NetBSD HDLC framing */
#define LINKTYPE_LINUX_SLL 113 /* Linux cooked socket capture */
#define LINKTYPE_LTALK 114 /* Apple LocalTalk hardware */
@@ -1191,7 +1202,33 @@
*/
#define LINKTYPE_ATSC_ALP 289
-#define LINKTYPE_MATCHING_MAX 289 /* highest value in the "matching" range */
+/*
+ * Event Tracing for Windows messages.
+ */
+#define LINKTYPE_ETW 290
+
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH
+ * netANALYZER NG hardware and software.
+ *
+ * The specification for this footer can be found at:
+ * https://kb.hilscher.com/x/brDJBw
+ *
+ * Requested by Jan Adam <jadam@hilscher.com>
+ */
+#define LINKTYPE_NETANALYZER_NG 291
+
+/*
+ * Serial NCP (Network Co-Processor) protocol for Zigbee stack ZBOSS
+ * by DSR.
+ * ZBOSS NCP protocol description: https://cloud.dsr-corporation.com/index.php/s/3isHzaNTTgtJebn
+ * Header in pcap file: https://cloud.dsr-corporation.com/index.php/s/fiqSDorAAAZrsYB
+ *
+ * Requested by Eugene Exarevsky <eugene.exarevsky@dsr-corporation.com>
+ */
+#define LINKTYPE_ZBOSS_NCP 292
+
+#define LINKTYPE_MATCHING_MAX 292 /* highest value in the "matching" range */
/*
* The DLT_ and LINKTYPE_ values in the "matching" range should be the
@@ -1238,6 +1275,7 @@ static struct linktype_map {
{ DLT_RAW, LINKTYPE_RAW },
{ DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS },
{ DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS },
+ { DLT_HDLC, LINKTYPE_NETBSD_HDLC },
/* BSD/OS Cisco HDLC */
{ DLT_C_HDLC, LINKTYPE_C_HDLC },
@@ -1393,11 +1431,75 @@ max_snaplen_for_dlt(int dlt)
}
/*
+ * Most versions of the DLT_PFLOG pseudo-header have UID and PID fields
+ * that are saved in host byte order.
+ *
+ * When reading a DLT_PFLOG packet, we need to convert those fields from
+ * the byte order of the host that wrote the file to this host's byte
+ * order.
+ */
+static void
+swap_pflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
+{
+ u_int caplen = hdr->caplen;
+ u_int length = hdr->len;
+ u_int pfloghdr_length;
+ struct pfloghdr *pflhdr = (struct pfloghdr *)buf;
+
+ if (caplen < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid) ||
+ length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) {
+ /* Not enough data to have the uid field */
+ return;
+ }
+
+ pfloghdr_length = pflhdr->length;
+
+ if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) {
+ /* Header doesn't include uid field */
+ return;
+ }
+ pflhdr->uid = SWAPLONG(pflhdr->uid);
+
+ if (caplen < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid) ||
+ length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) {
+ /* Not enough data to have the pid field */
+ return;
+ }
+ if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) {
+ /* Header doesn't include pid field */
+ return;
+ }
+ pflhdr->pid = SWAPLONG(pflhdr->pid);
+
+ if (caplen < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid) ||
+ length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) {
+ /* Not enough data to have the rule_uid field */
+ return;
+ }
+ if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) {
+ /* Header doesn't include rule_uid field */
+ return;
+ }
+ pflhdr->rule_uid = SWAPLONG(pflhdr->rule_uid);
+
+ if (caplen < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid) ||
+ length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) {
+ /* Not enough data to have the rule_pid field */
+ return;
+ }
+ if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) {
+ /* Header doesn't include rule_pid field */
+ return;
+ }
+ pflhdr->rule_pid = SWAPLONG(pflhdr->rule_pid);
+}
+
+/*
* DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or
* LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload,
* with the CAN ID being in host byte order.
*
- * When reading a DLT_LINUX_SLL capture file, we need to check for those
+ * When reading a DLT_LINUX_SLL packet, we need to check for those
* packets and convert the CAN ID from the byte order of the host that
* wrote the file to this host's byte order.
*/
@@ -1433,13 +1535,47 @@ swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf)
}
/*
+ * The same applies for DLT_LINUX_SLL2.
+ */
+static void
+swap_linux_sll2_header(const struct pcap_pkthdr *hdr, u_char *buf)
+{
+ u_int caplen = hdr->caplen;
+ u_int length = hdr->len;
+ struct sll2_header *shdr = (struct sll2_header *)buf;
+ uint16_t protocol;
+ pcap_can_socketcan_hdr *chdr;
+
+ if (caplen < (u_int) sizeof(struct sll2_header) ||
+ length < (u_int) sizeof(struct sll2_header)) {
+ /* Not enough data to have the protocol field */
+ return;
+ }
+
+ protocol = EXTRACT_BE_U_2(&shdr->sll2_protocol);
+ if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
+ return;
+
+ /*
+ * SocketCAN packet; fix up the packet's header.
+ */
+ chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll2_header));
+ if (caplen < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id) ||
+ length < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id)) {
+ /* Not enough data to have the CAN ID */
+ return;
+ }
+ chdr->can_id = SWAPLONG(chdr->can_id);
+}
+
+/*
* The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
* byte order when capturing (it's supplied directly from a
* memory-mapped buffer shared by the kernel).
*
- * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
- * we need to convert it from the byte order of the host that wrote
- * the file to this host's byte order.
+ * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED packet, we
+ * need to convert it from the byte order of the host that wrote the
+ * file to this host's byte order.
*/
static void
swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
@@ -1587,9 +1723,9 @@ swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
* byte order but the values are either big-endian or are a raw byte
* sequence that's the same regardless of the host's byte order.
*
- * When reading a DLT_NFLOG capture file, we need to convert the type
- * and length values from the byte order of the host that wrote the
- * file to the byte order of this host.
+ * When reading a DLT_NFLOG packet, we need to convert the type and
+ * length values from the byte order of the host that wrote the file
+ * to the byte order of this host.
*/
static void
swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
@@ -1657,10 +1793,18 @@ swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data)
*/
switch (linktype) {
+ case DLT_PFLOG:
+ swap_pflog_header(hdr, data);
+ break;
+
case DLT_LINUX_SLL:
swap_linux_sll_header(hdr, data);
break;
+ case DLT_LINUX_SLL2:
+ swap_linux_sll2_header(hdr, data);
+ break;
+
case DLT_USB_LINUX:
swap_linux_usb_header(hdr, data, 0);
break;
diff --git a/pcap-config.1 b/pcap-config.1
index fe8d799c..87ab0acc 100644
--- a/pcap-config.1
+++ b/pcap-config.1
@@ -68,5 +68,5 @@ dynamically-linked version of libpcap; the
.B \-\-static
flag causes it to write flags appropriate for compiling with a
statically-linked version of libpcap.
-.SH "SEE ALSO"
+.SH SEE ALSO
.BR pcap (3PCAP)
diff --git a/pcap-config.in b/pcap-config.in
index 54ca42f0..44fb657a 100644
--- a/pcap-config.in
+++ b/pcap-config.in
@@ -41,6 +41,13 @@ do
esac
shift
done
+#
+# If libdir isn't /usr/lib, add it to the link-time linker path.
+#
+if [ "$libdir" != "/usr/lib" ]
+then
+ LPATH=-L$libdir
+fi
if [ "$V_RPATH_OPT" != "" ]
then
#
@@ -59,16 +66,16 @@ then
#
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
then
- echo "-I$includedir -L$libdir -lpcap $LIBS"
+ echo "-I$includedir $LPATH -lpcap $LIBS"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
- echo "-I$includedir -L$libdir $LIBS"
+ echo "-I$includedir $LPATH $LIBS"
elif [ "$show_cflags" = 1 ]
then
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
- echo "-L$libdir -lpcap $LIBS"
+ echo "$LPATH -lpcap $LIBS"
elif [ "$show_additional_libs" = 1 ]
then
echo "$LIBS"
@@ -80,7 +87,7 @@ else
#
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
then
- echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
+ echo "-I$includedir $LPATH $RPATH -l$PACKAGE_NAME"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
echo "-I$includedir"
@@ -89,6 +96,6 @@ else
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
- echo "-L$libdir $RPATH -l$PACKAGE_NAME"
+ echo "$LPATH $RPATH -l$PACKAGE_NAME"
fi
fi
diff --git a/pcap-dag.c b/pcap-dag.c
index b207dd84..108f029a 100644
--- a/pcap-dag.c
+++ b/pcap-dag.c
@@ -213,7 +213,7 @@ static int dag_get_datalink(pcap_t *p);
static int dag_setnonblock(pcap_t *p, int nonblock);
static void
-delete_pcap_dag(pcap_t *p)
+delete_pcap_dag(const pcap_t *p)
{
pcap_dag_node_t *curr = NULL, *prev = NULL;
@@ -299,7 +299,7 @@ new_pcap_dag(pcap_t *p)
}
static unsigned int
-dag_erf_ext_header_count(uint8_t * erf, size_t len)
+dag_erf_ext_header_count(const uint8_t *erf, size_t len)
{
uint32_t hdr_num = 0;
uint8_t hdr_type;
@@ -391,7 +391,12 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
- /* Process the packets. */
+ /*
+ * Process the packets.
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
+ */
while (pd->dag_mem_top - pd->dag_mem_bottom >= dag_record_size) {
unsigned short packet_len = 0;
@@ -945,7 +950,7 @@ static int dag_activate(pcap_t* p)
* Did the user request that they not be stripped?
*/
if ((s = getenv("ERF_DONT_STRIP_FCS")) != NULL) {
- /* Yes. Note the number of bytes that will be
+ /* Yes. Note the number of 16-bit words that will be
supplied. */
p->linktype_ext = LT_FCS_DATALINK_EXT(pd->dag_fcs_bits/16);
diff --git a/pcap-dll.rc b/pcap-dll.rc
index fc4f42b2..85de542f 100644
--- a/pcap-dll.rc
+++ b/pcap-dll.rc
@@ -20,12 +20,12 @@
VALUE "Comments", "https://github.com/the-tcpdump-group/libpcap/"
VALUE "CompanyName", "The TCPdump Group"
VALUE "FileDescription", "System-Independent Interface for User-Level Packet Capture"
- VALUE "FileVersion", "PACKAGE_VERSION_DLL"
+ VALUE "FileVersion", PACKAGE_VERSION
VALUE "InternalName", PACKAGE_NAME
VALUE "LegalCopyright", "Copyright (c) The TCPdump Group"
VALUE "LegalTrademarks", ""
- VALUE "OriginalFilename", "wpcap.dll"
- VALUE "ProductName", PACKAGE_NAME
+ VALUE "OriginalFilename", PACKAGE_NAME ".dll"
+ VALUE "ProductName", "libpcap"
VALUE "ProductVersion", PACKAGE_VERSION
END
END
diff --git a/pcap-dos.c b/pcap-dos.c
index cdd60ea4..e2b3fb74 100644
--- a/pcap-dos.c
+++ b/pcap-dos.c
@@ -12,6 +12,7 @@
#include <signal.h>
#include <float.h>
#include <fcntl.h>
+#include <limits.h> /* for INT_MAX */
#include <io.h>
#if defined(USE_32BIT_DRIVERS)
@@ -355,7 +356,22 @@ pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
{
int rc, num = 0;
- while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt))
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(cnt))
+ cnt = INT_MAX;
+
+ while (num <= cnt)
{
if (p->fd <= 0)
return (-1);
diff --git a/pcap-dpdk.c b/pcap-dpdk.c
index 765abe59..94c33092 100644
--- a/pcap-dpdk.c
+++ b/pcap-dpdk.c
@@ -85,6 +85,7 @@ env DPDK_CFG="--log-level=debug -l0 -dlibrte_pmd_e1000.so -dlibrte_pmd_ixgbe.so
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h> /* for INT_MAX */
#include <time.h>
#include <sys/time.h>
@@ -331,13 +332,28 @@ static int pcap_dpdk_dispatch(pcap_t *p, int max_cnt, pcap_handler cb, u_char *c
u_char *large_buffer=NULL;
int timeout_ms = p->opt.timeout;
- if ( !PACKET_COUNT_IS_UNLIMITED(max_cnt) && max_cnt < MAX_PKT_BURST){
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(max_cnt))
+ max_cnt = INT_MAX;
+
+ if (max_cnt < MAX_PKT_BURST){
burst_cnt = max_cnt;
}else{
burst_cnt = MAX_PKT_BURST;
}
- while( PACKET_COUNT_IS_UNLIMITED(max_cnt) || pkt_cnt < max_cnt){
+ while( pkt_cnt < max_cnt){
if (p->break_loop){
p->break_loop = 0;
return PCAP_ERROR_BREAK;
diff --git a/pcap-filter.manmisc.in b/pcap-filter.manmisc.in
index e0f883d5..5fce8043 100644
--- a/pcap-filter.manmisc.in
+++ b/pcap-filter.manmisc.in
@@ -18,14 +18,14 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP-FILTER @MAN_MISC_INFO@ "2 September 2020"
+.TH PCAP-FILTER @MAN_MISC_INFO@ "4 January 2022"
.SH NAME
pcap-filter \- packet filter syntax
.br
.ad
.SH DESCRIPTION
.LP
-.BR pcap_compile ()
+.BR pcap_compile (3PCAP)
is used to compile a string into a filter program.
The resulting filter program can then be applied to
some stream of packets to determine which packets will be supplied to
@@ -88,7 +88,7 @@ qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
.I proto
qualifiers restrict the match to a particular protocol.
Possible
-protos are:
+protocols are:
.BR ether ,
.BR fddi ,
.BR tr ,
@@ -98,18 +98,19 @@ protos are:
.BR arp ,
.BR rarp ,
.BR decnet ,
+.BR sctp ,
.B tcp
and
.BR udp .
E.g., `\fBether src\fP foo', `\fBarp net\fP 128.3', `\fBtcp port\fP 21',
`\fBudp portrange\fP 7000-7009', `\fBwlan addr2\fP 0:2:3:4:5:6'.
-If there is
-no proto qualifier, all protocols consistent with the type are
-assumed.
-E.g., `\fBsrc\fP foo' means `\fB(ip or arp or rarp) src\fP foo'
-(except the latter is not legal syntax), `\fBnet\fP bar' means `\fB(ip or
-arp or rarp) net\fP bar' and `\fBport\fP 53' means `\fB(tcp or udp)
-port\fP 53'.
+If there is no
+.I proto
+qualifier, all protocols consistent with the type are assumed.
+E.g., `\fBsrc\fP foo' means `\fB(ip or arp or rarp) src\fP foo',
+`\fBnet\fP bar' means `\fB(ip or arp or rarp) net\fP bar' and
+`\fBport\fP 53' means `\fB(tcp or udp or sctp) port\fP 53'
+(note that these examples use invalid syntax to illustrate the principle).
.LP
[\fBfddi\fP is actually an alias for \fBether\fP; the parser treats them
identically as meaning ``the data link level used on the specified
@@ -228,7 +229,7 @@ True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR
bits wide.
May be qualified with \fBsrc\fR or \fBdst\fR.
.IP "\fBdst port \fIport\fR"
-True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or IPv6 UDP and has a
+True if the packet is IPv4/v6 TCP, UDP or SCTP and has a
destination port value of \fIport\fP.
The \fIport\fP can be a number or a name used in /etc/services (see
.BR tcp (4P)
@@ -245,8 +246,8 @@ True if the packet has a source port value of \fIport\fP.
.IP "\fBport \fIport\fR"
True if either the source or destination port of the packet is \fIport\fP.
.IP "\fBdst portrange \fIport1-port2\fR"
-True if the packet is IPv4 TCP, IPv4 UDP, IPv6 TCP or IPv6 UDP and has a
-destination port value between \fIport1\fP and \fIport2\fP.
+True if the packet is IPv4/v6 TCP, UDP or SCTP and has a
+destination port value between \fIport1\fP and \fIport2\fP (both inclusive).
.I port1
and
.I port2
@@ -256,13 +257,13 @@ parameter for
.BR port .
.IP "\fBsrc portrange \fIport1-port2\fR"
True if the packet has a source port value between \fIport1\fP and
-\fIport2\fP.
+\fIport2\fP (both inclusive).
.IP "\fBportrange \fIport1-port2\fR"
True if either the source or destination port of the packet is between
-\fIport1\fP and \fIport2\fP.
+\fIport1\fP and \fIport2\fP (both inclusive).
.IP
Any of the above port or port range expressions can be prepended with
-the keywords, \fBtcp\fP or \fBudp\fP, as in:
+the keywords, \fBtcp\fP, \fBudp\fP or \fBsctp\fP, as in:
.in +.5i
.nf
\fBtcp src port \fIport\fR
@@ -291,9 +292,9 @@ True if the packet is an IPv4 packet (see
of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
\fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
-\fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
-Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
-keywords and must be escaped via backslash (\\).
+\fBesp\fP, \fBvrrp\fP, \fBsctp\fP, \fBudp\fP, or \fBtcp\fP.
+Note that the identifiers \fBtcp\fP, \fBudp\fP, \fBsctp\fP and \fBicmp\fP
+are also keywords and must be escaped via backslash (\\).
Note that this primitive does not chase the protocol header chain.
.IP "\fBip6 proto \fIprotocol\fR"
True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
@@ -302,11 +303,11 @@ Note that this primitive does not chase the protocol header chain.
True if the packet is an IPv4 or IPv6 packet of protocol type
\fIprotocol\fP. Note that this primitive does not chase the protocol
header chain.
-.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
+.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR, \fBsctp\fR"
Abbreviations for:
.in +.5i
.nf
-\fBproto \\\fIprotocol\fR\fB
+\fBproto \\\fIprotocol\fR
.fi
.in -.5i
where \fIprotocol\fR is one of the above protocols.
@@ -630,6 +631,8 @@ then valid \fIwlan_subtype\fRs are:
.IP
If the specified \fIwlan_type\fR is \fBctl\fP,
then valid \fIwlan_subtype\fRs are:
+\fBbar\fP,
+\fBba\fP,
\fBps-poll\fP,
\fBrts\fP,
\fBcts\fP,
@@ -816,8 +819,8 @@ True if the packet is an ATM packet, for SunATM on Solaris, and is
on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
Release, or Release Done message.
.IP "\fIexpr relop expr\fR"
-True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =,
-!=, and \fIexpr\fR is an arithmetic expression composed of integer
+True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =
+or ==, !=, and \fIexpr\fR is an arithmetic expression composed of integer
constants (expressed in standard C syntax), the normal binary operators
[+, -, *, /, %, &, |, ^, <<, >>], a length operator, and special packet data
accessors. Note that all comparisons are unsigned, so that, for example,
@@ -836,7 +839,7 @@ To access data inside the packet, use the following syntax:
.fi
.in -.5i
\fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link,
-ip, arp, rarp, tcp, udp, icmp, ip6\fR or \fBradio\fR, and
+ip, arp, rarp, tcp, udp, sctp, icmp, ip6\fR or \fBradio\fR, and
indicates the protocol layer for the index operation.
(\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the
link layer. \fBradio\fR refers to the "radio header" added to some
@@ -1033,10 +1036,10 @@ icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
icmp6[icmp6type] != icmp6-echo and icmp6[icmp6type] != icmp6-echoreply
.fi
.RE
-.SH "SEE ALSO"
+.SH SEE ALSO
.BR pcap (3PCAP)
.SH BUGS
-To report a security issue please send an e-mail to security@tcpdump.org.
+To report a security issue please send an e-mail to \%security@tcpdump.org.
.LP
To report bugs and other problems, contribute patches, request a
feature, provide generic feedback etc please see the file
diff --git a/pcap-haiku.cpp b/pcap-haiku.cpp
index 701cac38..8b0009c5 100644
--- a/pcap-haiku.cpp
+++ b/pcap-haiku.cpp
@@ -160,6 +160,17 @@ pcap_activate_haiku(pcap_t *handle)
handle->getnonblock_op = pcap_getnonblock_fd;
handle->setnonblock_op = pcap_setnonblock_fd;
+ /*
+ * Turn a negative snapshot value (invalid), a snapshot value of
+ * 0 (unspecified), or a value bigger than the normal maximum
+ * value, into the maximum allowed value.
+ *
+ * If some application really *needs* a bigger snapshot
+ * length, we should just increase MAXIMUM_SNAPLEN.
+ */
+ if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN)
+ handle->snapshot = MAXIMUM_SNAPLEN;
+
handlep->device = strdup(device);
if (handlep->device == NULL) {
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
@@ -280,3 +291,12 @@ pcap_platform_finddevs(pcap_if_list_t* _allDevices, char* errorBuffer)
return pcap_findalldevs_interfaces(_allDevices, errorBuffer, can_be_bound,
get_if_flags);
}
+
+/*
+ * Libpcap version string.
+ */
+extern "C" const char *
+pcap_lib_version(void)
+{
+ return (PCAP_VERSION_STRING);
+}
diff --git a/pcap-int.h b/pcap-int.h
index 3c18dae8..f1b97ce6 100644
--- a/pcap-int.h
+++ b/pcap-int.h
@@ -40,9 +40,36 @@
#include <pcap/pcap.h>
+#ifdef MSDOS
+ #include <fcntl.h>
+ #include <io.h>
+#endif
+
#include "varattrs.h"
#include "fmtutils.h"
+#include <stdarg.h>
+
+#include "portability.h"
+
+/*
+ * If we're compiling with Visual Studio, make sure we have at least
+ * VS 2015 or later, so we have sufficient C99 support.
+ *
+ * XXX - verify that we have at least C99 support on UN*Xes?
+ *
+ * What about MinGW or various DOS toolchains? We're currently assuming
+ * sufficient C99 support there.
+ */
+#if defined(_MSC_VER)
+ /*
+ * Compiler is MSVC. Make sure we have VS 2015 or later.
+ */
+ #if _MSC_VER < 1900
+ #error "Building libpcap requires VS 2015 or later"
+ #endif
+#endif
+
/*
* Version string.
* Uses PACKAGE_VERSION from config.h.
@@ -80,11 +107,6 @@ extern int pcap_new_api;
*/
extern int pcap_utf_8_mode;
-#ifdef MSDOS
- #include <fcntl.h>
- #include <io.h>
-#endif
-
/*
* Swap byte ordering of unsigned long long timestamp on a big endian
* machine.
@@ -433,10 +455,6 @@ struct oneshot_userdata {
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
-#include <stdarg.h>
-
-#include "portability.h"
-
/*
* Does the packet count argument to a module's read routine say
* "supply packets until you run out of packets"?
@@ -592,7 +610,7 @@ pcap_funcptr_t pcap_find_function(pcap_code_handle_t, const char *);
* Linux kernel when the kernel rejects the filter (requiring us to
* run it in userland). It contains VLAN tag information.
*/
-struct bpf_aux_data {
+struct pcap_bpf_aux_data {
u_short vlan_tag_present;
u_short vlan_tag;
};
@@ -602,7 +620,7 @@ struct bpf_aux_data {
* argument.
*/
u_int pcap_filter_with_aux_data(const struct bpf_insn *,
- const u_char *, u_int, u_int, const struct bpf_aux_data *);
+ const u_char *, u_int, u_int, const struct pcap_bpf_aux_data *);
/*
* Filtering routine that doesn't.
@@ -633,9 +651,9 @@ int pcap_strcasecmp(const char *, const char *);
* rpcaps://).
*/
int pcap_createsrcstr_ex(char *, int, const char *, const char *,
- const char *, unsigned char, char *);
+ const char *, const char *, unsigned char, char *);
int pcap_parsesrcstr_ex(const char *, int *, char *, char *,
- char *, unsigned char *, char *);
+ char *, char *, unsigned char *, char *);
#ifdef YYDEBUG
extern int pcap_debug;
diff --git a/pcap-linux.c b/pcap-linux.c
index 74816892..701112c2 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -100,6 +100,7 @@
#include "pcap-int.h"
#include "pcap/sll.h"
#include "pcap/vlan.h"
+#include "pcap/can_socketcan.h"
#include "diag-control.h"
@@ -117,6 +118,19 @@
# define HAVE_TPACKET3
#endif /* TPACKET3_HDRLEN */
+/*
+ * Not all compilers that are used to compile code to run on Linux have
+ * these builtins. For example, older versions of GCC don't, and at
+ * least some people are doing cross-builds for MIPS with older versions
+ * of GCC.
+ */
+#ifndef HAVE___ATOMIC_LOAD_N
+#define __atomic_load_n(ptr, memory_model) (*(ptr))
+#endif
+#ifndef HAVE___ATOMIC_STORE_N
+#define __atomic_store_n(ptr, val, memory_model) *(ptr) = (val)
+#endif
+
#define packet_mmap_acquire(pkt) \
(__atomic_load_n(&pkt->tp_status, __ATOMIC_ACQUIRE) != TP_STATUS_KERNEL)
#define packet_mmap_release(pkt) \
@@ -305,10 +319,8 @@ static int iface_get_arptype(int fd, const char *device, char *ebuf);
static int iface_bind(int fd, int ifindex, char *ebuf, int protocol);
static int enter_rfmon_mode(pcap_t *handle, int sock_fd,
const char *device);
-#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP)
-static int iface_ethtool_get_ts_info(const char *device, pcap_t *handle,
+static int iface_get_ts_types(const char *device, pcap_t *handle,
char *ebuf);
-#endif
static int iface_get_offload(pcap_t *handle);
static int fix_program(pcap_t *handle, struct sock_fprog *fcode);
@@ -335,15 +347,13 @@ pcap_create_interface(const char *device, char *ebuf)
handle->activate_op = pcap_activate_linux;
handle->can_set_rfmon_op = pcap_can_set_rfmon_linux;
-#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP)
/*
* See what time stamp types we support.
*/
- if (iface_ethtool_get_ts_info(device, handle, ebuf) == -1) {
+ if (iface_get_ts_types(device, handle, ebuf) == -1) {
pcap_close(handle);
return NULL;
}
-#endif
/*
* We claim that we support microsecond and nanosecond time
@@ -1131,9 +1141,12 @@ linux_check_direction(const pcap_t *handle, const struct sockaddr_ll *sll)
* easily distinguish packets looped back by the CAN
* layer than those received by the CAN layer, so we
* eliminate this packet instead.
+ *
+ * We check whether this is a CAN or CAN FD frame
+ * by checking whether the device's hardware type
+ * is ARPHRD_CAN.
*/
- if ((sll->sll_protocol == LINUX_SLL_P_CAN ||
- sll->sll_protocol == LINUX_SLL_P_CANFD) &&
+ if (sll->sll_hatype == ARPHRD_CAN &&
handle->direction != PCAP_D_OUT)
return 0;
@@ -1599,8 +1612,8 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
}
}
fclose(fh);
- free(pathstr);
}
+ free(pathstr);
}
#ifdef ETHTOOL_GLINK
@@ -1869,14 +1882,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype,
#define ARPHRD_CAN 280
#endif
case ARPHRD_CAN:
- /*
- * Map this to DLT_LINUX_SLL; that way, CAN frames will
- * have ETH_P_CAN/LINUX_SLL_P_CAN as the protocol and
- * CAN FD frames will have ETH_P_CANFD/LINUX_SLL_P_CANFD
- * as the protocol, so they can be distinguished by the
- * protocol in the SLL header.
- */
- handle->linktype = DLT_LINUX_SLL;
+ handle->linktype = DLT_CAN_SOCKETCAN;
break;
#ifndef ARPHRD_IEEE802_TR
@@ -2665,6 +2671,7 @@ setup_mmapped(pcap_t *handle, int *status)
ret = prepare_tpacket_socket(handle);
if (ret == -1) {
free(handlep->oneshot_buffer);
+ handlep->oneshot_buffer = NULL;
*status = PCAP_ERROR;
return ret;
}
@@ -2675,6 +2682,7 @@ setup_mmapped(pcap_t *handle, int *status)
* fail. create_ring() has set *status.
*/
free(handlep->oneshot_buffer);
+ handlep->oneshot_buffer = NULL;
return -1;
}
@@ -3759,6 +3767,7 @@ static int pcap_handle_packet_mmap(
unsigned char *bp;
struct sockaddr_ll *sll;
struct pcap_pkthdr pcaphdr;
+ pcap_can_socketcan_hdr *canhdr;
unsigned int snaplen = tp_snaplen;
struct utsname utsname;
@@ -3877,10 +3886,72 @@ static int pcap_handle_packet_mmap(
snaplen += sizeof(struct sll_header);
}
+ } else {
+ /*
+ * If this is a packet from a CAN device, so that
+ * sll->sll_hatype is ARPHRD_CAN, then, as we're
+ * not capturing in cooked mode, its link-layer
+ * type is DLT_CAN_SOCKETCAN. Fix up the header
+ * provided by the code below us to match what
+ * DLT_CAN_SOCKETCAN is expected to provide.
+ */
+ if (sll->sll_hatype == ARPHRD_CAN) {
+ /*
+ * DLT_CAN_SOCKETCAN is specified as having the
+ * CAN ID and flags in network byte order, but
+ * capturing on a CAN device provides it in host
+ * byte order. Convert it to network byte order.
+ */
+ canhdr = (pcap_can_socketcan_hdr *)bp;
+ canhdr->can_id = htonl(canhdr->can_id);
+
+ /*
+ * In addition, set the CANFD_FDF flag if
+ * the protocol is LINUX_SLL_P_CANFD, as
+ * the protocol field itself isn't in
+ * the packet to indicate that it's a
+ * CAN FD packet.
+ */
+ uint16_t protocol = ntohs(sll->sll_protocol);
+ if (protocol == LINUX_SLL_P_CANFD) {
+ canhdr->fd_flags |= CANFD_FDF;
+
+ /*
+ * Zero out all the unknown bits in
+ * fd_flags and clear the reserved
+ * fields, so that a program reading
+ * this can assume that CANFD_FDF
+ * is set because we set it, not
+ * because some uninitialized crap
+ * was provided in the fd_flags
+ * field.
+ *
+ * (At least some LINKTYPE_CAN_SOCKETCAN
+ * files attached to Wireshark bugs
+ * had uninitialized junk there, so it
+ * does happen.)
+ *
+ * Update this if Linux adds more flag
+ * bits to the fd_flags field or uses
+ * either of the reserved fields for
+ * FD frames.
+ */
+ canhdr->fd_flags &= ~(CANFD_FDF|CANFD_ESI|CANFD_BRS);
+ canhdr->reserved1 = 0;
+ canhdr->reserved2 = 0;
+ } else {
+ /*
+ * Clear CANFD_FDF if it's set (probably
+ * again meaning that that field is
+ * uninitialized junk).
+ */
+ canhdr->fd_flags &= ~CANFD_FDF;
+ }
+ }
}
if (handlep->filter_in_userland && handle->fcode.bf_insns) {
- struct bpf_aux_data aux_data;
+ struct pcap_bpf_aux_data aux_data;
aux_data.vlan_tag_present = tp_vlan_tci_valid;
aux_data.vlan_tag = tp_vlan_tci & 0x0fff;
@@ -3989,9 +4060,22 @@ pcap_read_linux_mmap_v2(pcap_t *handle, int max_packets, pcap_handler callback,
}
}
- /* non-positive values of max_packets are used to require all
- * packets currently available in the ring */
- while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) {
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(max_packets))
+ max_packets = INT_MAX;
+
+ while (pkts < max_packets) {
/*
* Get the current ring buffer frame, and break if
* it's still owned by the kernel.
@@ -4084,9 +4168,22 @@ again:
return pkts;
}
- /* non-positive values of max_packets are used to require all
- * packets currently available in the ring */
- while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) {
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(max_packets))
+ max_packets = INT_MAX;
+
+ while (pkts < max_packets) {
int packets_to_read;
if (handlep->current_packet == NULL) {
@@ -4099,12 +4196,12 @@ again:
}
packets_to_read = handlep->packets_left;
- if (!PACKET_COUNT_IS_UNLIMITED(max_packets) &&
- packets_to_read > (max_packets - pkts)) {
+ if (packets_to_read > (max_packets - pkts)) {
/*
- * We've been given a maximum number of packets
- * to process, and there are more packets in
- * this buffer than that. Only process enough
+ * There are more packets in the buffer than
+ * the number of packets we have left to
+ * process to get up to the maximum number
+ * of packets to process. Only process enough
* of them to get us up to that maximum.
*/
packets_to_read = max_packets - pkts;
@@ -4309,7 +4406,18 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
* the filter for a reason other than "this kernel
* isn't configured to support socket filters.
*/
- if (errno != ENOPROTOOPT && errno != EOPNOTSUPP) {
+ if (errno == ENOMEM) {
+ /*
+ * Either a kernel memory allocation
+ * failure occurred, or there's too
+ * much "other/option memory" allocated
+ * for this socket. Suggest that they
+ * increase the "other/option memory"
+ * limit.
+ */
+ fprintf(stderr,
+ "Warning: Couldn't allocate kernel memory for filter: try increasing net.core.optmem_max with sysctl\n");
+ } else if (errno != ENOPROTOOPT && errno != EOPNOTSUPP) {
fprintf(stderr,
"Warning: Kernel filter failed: %s\n",
pcap_strerror(errno));
@@ -4668,12 +4776,12 @@ iface_set_all_ts_types(pcap_t *handle, char *ebuf)
return 0;
}
-#ifdef ETHTOOL_GET_TS_INFO
/*
- * Get a list of time stamping capabilities.
+ * Get a list of time stamp types.
*/
+#ifdef ETHTOOL_GET_TS_INFO
static int
-iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
+iface_get_ts_types(const char *device, pcap_t *handle, char *ebuf)
{
int fd;
struct ifreq ifr;
@@ -4760,6 +4868,8 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
* report HWTSTAMP_FILTER_ALL but map it to only
* time stamping a few PTP packets. See
* http://marc.info/?l=linux-netdev&m=146318183529571&w=2
+ *
+ * Maybe that got fixed later.
*/
handle->tstamp_type_list = NULL;
return 0;
@@ -4791,7 +4901,7 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
}
#else /* ETHTOOL_GET_TS_INFO */
static int
-iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
+iface_get_ts_types(const char *device, pcap_t *handle, char *ebuf)
{
/*
* This doesn't apply to the "any" device; you can't say "turn on
@@ -4814,7 +4924,15 @@ iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
return 0;
}
#endif /* ETHTOOL_GET_TS_INFO */
-
+#else /* defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) */
+static int
+iface_get_ts_types(const char *device _U_, pcap_t *p _U_, char *ebuf _U_)
+{
+ /*
+ * Nothing to fetch, so it always "succeeds".
+ */
+ return 0;
+}
#endif /* defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP) */
/*
diff --git a/pcap-netfilter-linux.c b/pcap-netfilter-linux.c
index 17f528fc..33204a54 100644
--- a/pcap-netfilter-linux.c
+++ b/pcap-netfilter-linux.c
@@ -33,6 +33,7 @@
#endif
#include "pcap-int.h"
+#include "diag-control.h"
#ifdef NEED_STRERROR_H
#include "strerror.h"
@@ -135,6 +136,13 @@ netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_c
bp = (unsigned char *)handle->buffer;
} else
bp = handle->bp;
+
+ /*
+ * Loop through each message.
+ *
+ * This assumes that a single buffer of message will have
+ * <= INT_MAX packets, so the message count doesn't overflow.
+ */
ep = bp + len;
while (bp < ep) {
const struct nlmsghdr *nlh = (const struct nlmsghdr *) bp;
@@ -343,7 +351,9 @@ netfilter_send_config_msg(const pcap_t *handle, uint16_t msg_type, int ack, u_in
static unsigned int seq_id;
if (!seq_id)
+DIAG_OFF_NARROWING
seq_id = time(NULL);
+DIAG_ON_NARROWING
++seq_id;
nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg));
diff --git a/pcap-new.c b/pcap-new.c
index 7c006595..77b08ae1 100644
--- a/pcap-new.c
+++ b/pcap-new.c
@@ -36,6 +36,7 @@
#endif
#include "ftmacros.h"
+#include "diag-control.h"
/*
* sockutils.h may include <crtdbg.h> on Windows, and pcap-int.h will
@@ -237,7 +238,9 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
if (filedata == NULL)
{
+ DIAG_OFF_FORMAT_TRUNCATION
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path);
+ DIAG_ON_FORMAT_TRUNCATION
return -1;
}
#endif
@@ -253,7 +256,9 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
#else
if (pathlen + strlen(filedata->d_name) >= sizeof(filename))
continue;
+ DIAG_OFF_FORMAT_TRUNCATION
snprintf(filename, sizeof(filename), "%s%s", path, filedata->d_name);
+ DIAG_ON_FORMAT_TRUNCATION
#endif
fp = pcap_open_offline(filename, errbuf);
@@ -444,6 +449,7 @@ pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout,
return fp;
fail:
+ DIAG_OFF_FORMAT_TRUNCATION
if (status == PCAP_ERROR)
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
name, fp->errbuf);
@@ -455,6 +461,7 @@ fail:
else
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
name, pcap_statustostr(status));
+ DIAG_ON_FORMAT_TRUNCATION
pcap_close(fp);
return NULL;
}
diff --git a/pcap-nit.c b/pcap-nit.c
index cfd95191..6f4f8dd8 100644
--- a/pcap-nit.c
+++ b/pcap-nit.c
@@ -125,6 +125,9 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
* Loop through each packet. The increment expression
* rounds up to the next int boundary past the end of
* the previous packet.
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
*/
n = 0;
ep = bp + cc;
diff --git a/pcap-npf.c b/pcap-npf.c
index 201597d8..b6cd8861 100644
--- a/pcap-npf.c
+++ b/pcap-npf.c
@@ -36,6 +36,7 @@
#endif
#include <errno.h>
+#include <limits.h> /* for INT_MAX */
#define PCAP_DONT_INCLUDE_PCAP_BPF_H
#include <Packet32.h>
#include <pcap-int.h>
@@ -445,6 +446,31 @@ pcap_setuserbuffer_npf(pcap_t *p, int size)
return (0);
}
+#ifdef HAVE_NPCAP_PACKET_API
+/*
+ * Kernel dump mode isn't supported in Npcap; calls to PacketSetDumpName(),
+ * PacketSetDumpLimits(), and PacketIsDumpEnded() will get compile-time
+ * deprecation warnings.
+ *
+ * Avoid calling them; just return errors indicating that kernel dump
+ * mode isn't supported in Npcap.
+ */
+static int
+pcap_live_dump_npf(pcap_t *p, char *filename _U_, int maxsize _U_,
+ int maxpacks _U_)
+{
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "Npcap doesn't support kernel dump mode");
+ return (-1);
+}
+static int
+pcap_live_dump_ended_npf(pcap_t *p, int sync)
+{
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "Npcap doesn't support kernel dump mode");
+ return (-1);
+}
+#else /* HAVE_NPCAP_PACKET_API */
static int
pcap_live_dump_npf(pcap_t *p, char *filename, int maxsize, int maxpacks)
{
@@ -485,6 +511,7 @@ pcap_live_dump_ended_npf(pcap_t *p, int sync)
return (PacketIsDumpEnded(pw->adapter, (BOOLEAN)sync));
}
+#endif /* HAVE_NPCAP_PACKET_API */
#ifdef HAVE_AIRPCAP_API
static PAirpcapHandle
@@ -543,27 +570,53 @@ pcap_read_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
if (!PacketReceivePacket(pw->adapter, &Packet, TRUE)) {
/*
* Did the device go away?
- * If so, the error we get is ERROR_GEN_FAILURE.
+ * If so, the error we get can either be
+ * ERROR_GEN_FAILURE or ERROR_DEVICE_REMOVED.
*/
DWORD errcode = GetLastError();
- if (errcode == ERROR_GEN_FAILURE) {
+ if (errcode == ERROR_GEN_FAILURE ||
+ errcode == ERROR_DEVICE_REMOVED) {
/*
* The device on which we're capturing
* went away, or it became unusable
* by NPF due to a suspend/resume.
*
+ * ERROR_GEN_FAILURE comes from
+ * STATUS_UNSUCCESSFUL, as well as some
+ * other NT status codes that the Npcap
+ * driver is unlikely to return.
* XXX - hopefully no other error
* conditions are indicated by this.
*
+ * ERROR_DEVICE_REMOVED comes from
+ * STATUS_DEVICE_REMOVED.
+ *
+ * We report the Windows status code
+ * name and the corresponding NT status
+ * code name, for the benefit of attempts
+ * to debug cases where this error is
+ * reported when the device *wasn't*
+ * removed, either because it's not
+ * removable, it's removable but wasn't
+ * removed, or it's a device that doesn't
+ * correspond to a physical device.
+ *
* XXX - we really should return an
* appropriate error for that, but
* pcap_dispatch() etc. aren't
* documented as having error returns
* other than PCAP_ERROR or PCAP_ERROR_BREAK.
*/
+ const char *errcode_msg;
+
+ if (errcode == ERROR_GEN_FAILURE)
+ errcode_msg = "ERROR_GEN_FAILURE/STATUS_UNSUCCESSFUL";
+ else
+ errcode_msg = "ERROR_DEVICE_REMOVED/STATUS_DEVICE_REMOVED";
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "The interface disappeared");
+ "The interface disappeared (error code %s)",
+ errcode_msg);
} else {
pcap_fmt_errmsg_for_win32_err(p->errbuf,
PCAP_ERRBUF_SIZE, errcode,
@@ -581,6 +634,9 @@ pcap_read_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
/*
* Loop through each packet.
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
*/
#define bhp ((struct bpf_hdr *)bp)
n = 0;
@@ -741,6 +797,21 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
endofbuf = (char*)header + cc;
/*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(cnt))
+ cnt = INT_MAX;
+
+ /*
* Cycle through the packets
*/
do
@@ -874,7 +945,8 @@ pcap_inject_npf(pcap_t *p, const void *buf, int size)
PacketInitPacket(&pkt, (PVOID)buf, size);
if(PacketSendPacket(pw->adapter,&pkt,TRUE) == FALSE) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send error: PacketSendPacket failed");
+ pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+ GetLastError(), "send error: PacketSendPacket failed");
return (-1);
}
@@ -912,6 +984,27 @@ pcap_breakloop_npf(pcap_t *p)
SetEvent(PacketGetReadEvent(pw->adapter));
}
+/*
+ * Vendor-specific error codes.
+ *
+ * These are NTSTATUS values:
+ *
+ * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781
+ *
+ * with the "Customer" bit set. If a driver returns them, they are not
+ * mapped to Windows error values in userland; they're returned by
+ * GetLastError().
+ *
+ * Attempting to set non-promiscuous mode on a Microsoft Surface Pro's
+ * Mobile Broadband Adapter returns an error; that error can safely be
+ * ignored, as it's always in non-promiscuous mode.
+ *
+ * It is likely that there are other devices which throw spurious errors,
+ * at which point this will need refactoring to efficiently check against
+ * a list, but for now we can just check this one value.
+ */
+#define NPF_SURFACE_MOBILE_NONPROMISC 0xe00000bb
+
static int
pcap_activate_npf(pcap_t *p)
{
@@ -1004,10 +1097,9 @@ pcap_activate_npf(pcap_t *p)
/*Set the linktype*/
switch (type.LinkType)
{
- case NdisMediumWan:
- p->linktype = DLT_EN10MB;
- break;
-
+ /*
+ * NDIS-defined medium types.
+ */
case NdisMedium802_3:
p->linktype = DLT_EN10MB;
/*
@@ -1031,12 +1123,19 @@ pcap_activate_npf(pcap_t *p)
}
break;
+ case NdisMedium802_5:
+ /*
+ * Token Ring.
+ */
+ p->linktype = DLT_IEEE802;
+ break;
+
case NdisMediumFddi:
p->linktype = DLT_FDDI;
break;
- case NdisMedium802_5:
- p->linktype = DLT_IEEE802;
+ case NdisMediumWan:
+ p->linktype = DLT_EN10MB;
break;
case NdisMediumArcnetRaw:
@@ -1051,18 +1150,29 @@ pcap_activate_npf(pcap_t *p)
p->linktype = DLT_ATM_RFC1483;
break;
- case NdisMediumCHDLC:
- p->linktype = DLT_CHDLC;
+ case NdisMediumWirelessWan:
+ p->linktype = DLT_RAW;
break;
- case NdisMediumPPPSerial:
- p->linktype = DLT_PPP_SERIAL;
+ case NdisMediumIP:
+ p->linktype = DLT_RAW;
break;
+ /*
+ * Npcap-defined medium types.
+ */
case NdisMediumNull:
p->linktype = DLT_NULL;
break;
+ case NdisMediumCHDLC:
+ p->linktype = DLT_CHDLC;
+ break;
+
+ case NdisMediumPPPSerial:
+ p->linktype = DLT_PPP_SERIAL;
+ break;
+
case NdisMediumBare80211:
p->linktype = DLT_IEEE802_11;
break;
@@ -1075,10 +1185,6 @@ pcap_activate_npf(pcap_t *p)
p->linktype = DLT_PPI;
break;
- case NdisMediumWirelessWan:
- p->linktype = DLT_RAW;
- break;
-
default:
/*
* An unknown medium type is assumed to supply Ethernet
@@ -1175,17 +1281,51 @@ pcap_activate_npf(pcap_t *p)
if (PacketSetHwFilter(pw->adapter,NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "failed to set hardware filter to promiscuous mode");
- goto bad;
+ DWORD errcode = GetLastError();
+
+ /*
+ * Suppress spurious error generated by non-compiant
+ * MS Surface mobile adapters.
+ *
+ * If we knew that this meant "promiscuous mode
+ * isn't supported", we could add a "promiscuous
+ * mode isn't supported" error code and return
+ * that, but:
+ *
+ * 1) we don't know that it means that
+ * rather than meaning "we reject attempts
+ * to set the filter, even though the NDIS
+ * specifications say you shouldn't do that"
+ *
+ * and
+ *
+ * 2) other interface types that don't
+ * support promiscuous mode, at least
+ * on UN*Xes, just silently ignore
+ * attempts to set promiscuous mode
+ *
+ * and rejecting it with an error could disrupt
+ * attempts to capture, as many programs (tcpdump,
+ * *shark) default to promiscuous mode.
+ */
+ if (errcode != NPF_SURFACE_MOBILE_NONPROMISC)
+ {
+ pcap_fmt_errmsg_for_win32_err(p->errbuf,
+ PCAP_ERRBUF_SIZE, errcode,
+ "failed to set hardware filter to promiscuous mode");
+ goto bad;
+ }
}
}
else
{
- /* NDIS_PACKET_TYPE_ALL_LOCAL selects "All packets sent by installed
- * protocols and all packets indicated by the NIC" but if no protocol
- * drivers (like TCP/IP) are installed, NDIS_PACKET_TYPE_DIRECTED,
- * NDIS_PACKET_TYPE_BROADCAST, and NDIS_PACKET_TYPE_MULTICAST are needed to
- * capture incoming frames.
+ /*
+ * NDIS_PACKET_TYPE_ALL_LOCAL selects "All packets sent by
+ * installed protocols and all packets indicated by the NIC",
+ * but if no protocol drivers (like TCP/IP) are installed,
+ * NDIS_PACKET_TYPE_DIRECTED, NDIS_PACKET_TYPE_BROADCAST,
+ * and NDIS_PACKET_TYPE_MULTICAST are needed to capture
+ * incoming frames.
*/
if (PacketSetHwFilter(pw->adapter,
NDIS_PACKET_TYPE_ALL_LOCAL |
@@ -1193,8 +1333,19 @@ pcap_activate_npf(pcap_t *p)
NDIS_PACKET_TYPE_BROADCAST |
NDIS_PACKET_TYPE_MULTICAST) == FALSE)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "failed to set hardware filter to non-promiscuous mode");
- goto bad;
+ DWORD errcode = GetLastError();
+
+ /*
+ * Suppress spurious error generated by non-compiant
+ * MS Surface mobile adapters.
+ */
+ if (errcode != NPF_SURFACE_MOBILE_NONPROMISC)
+ {
+ pcap_fmt_errmsg_for_win32_err(p->errbuf,
+ PCAP_ERRBUF_SIZE, errcode,
+ "failed to set hardware filter to non-promiscuous mode");
+ goto bad;
+ }
}
}
@@ -1405,40 +1556,48 @@ pcap_can_set_rfmon_npf(pcap_t *p)
return (PacketIsMonitorModeSupported(p->opt.device) == 1);
}
-pcap_t *
-pcap_create_interface(const char *device _U_, char *ebuf)
-{
- pcap_t *p;
+/*
+ * Get a list of time stamp types.
+ */
#ifdef HAVE_PACKET_GET_TIMESTAMP_MODES
- char *device_copy;
- ADAPTER *adapter;
+static int
+get_ts_types(const char *device, pcap_t *p, char *ebuf)
+{
+ char *device_copy = NULL;
+ ADAPTER *adapter = NULL;
ULONG num_ts_modes;
BOOL ret;
- DWORD error;
- ULONG *modes;
-#endif
+ DWORD error = ERROR_SUCCESS;
+ ULONG *modes = NULL;
+ int status = 0;
- p = PCAP_CREATE_COMMON(ebuf, struct pcap_win);
- if (p == NULL)
- return (NULL);
+ do {
+ /*
+ * First, find out how many time stamp modes we have.
+ * To do that, we have to open the adapter.
+ *
+ * XXX - PacketOpenAdapter() takes a non-const pointer
+ * as an argument, so we make a copy of the argument and
+ * pass that to it.
+ */
+ device_copy = strdup(device);
+ if (device_copy == NULL) {
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno, "malloc");
+ status = -1;
+ break;
+ }
- p->activate_op = pcap_activate_npf;
- p->can_set_rfmon_op = pcap_can_set_rfmon_npf;
+ adapter = PacketOpenAdapter(device_copy);
+ if (adapter == NULL)
+ {
+ error = GetLastError();
+ /* If we can't open the device now, we won't be able to later, either. */
+ pcap_fmt_errmsg_for_win32_err(ebuf, PCAP_ERRBUF_SIZE,
+ error, "Error opening adapter");
+ status = -1;
+ break;
+ }
-#ifdef HAVE_PACKET_GET_TIMESTAMP_MODES
- /*
- * First, find out how many time stamp modes we have.
- * To do that, we have to open the adapter.
- *
- * XXX - PacketOpenAdapter() takes a non-const pointer
- * as an argument, so we make a copy of the argument and
- * pass that to it.
- */
- device_copy = strdup(device);
- adapter = PacketOpenAdapter(device_copy);
- free(device_copy);
- if (adapter != NULL)
- {
/*
* Get the total number of time stamp modes.
*
@@ -1471,115 +1630,185 @@ pcap_create_interface(const char *device _U_, char *ebuf)
error = GetLastError();
if (error != ERROR_MORE_DATA) {
/*
+ * No, did it fail with ERROR_INVALID_FUNCTION?
+ */
+ if (error == ERROR_INVALID_FUNCTION) {
+ /*
+ * This is probably due to
+ * the driver with which Packet.dll
+ * communicates being older, or
+ * being a WinPcap driver, so
+ * that it doesn't support
+ * BIOCGTIMESTAMPMODES.
+ *
+ * Tell the user to try uninstalling
+ * Npcap - and WinPcap if installed -
+ * and re-installing it, to flush
+ * out all older drivers.
+ */
+ snprintf(ebuf, PCAP_ERRBUF_SIZE,
+ "PacketGetTimestampModes() failed with ERROR_INVALID_FUNCTION; try uninstalling Npcap, and WinPcap if installed, and re-installing it from npcap.com");
+ status = -1;
+ break;
+ }
+
+ /*
* No, some other error. Fail.
*/
pcap_fmt_errmsg_for_win32_err(ebuf,
- PCAP_ERRBUF_SIZE, GetLastError(),
+ PCAP_ERRBUF_SIZE, error,
"Error calling PacketGetTimestampModes");
- pcap_close(p);
- return (NULL);
+ status = -1;
+ break;
}
+ }
+ /* else (ret == TRUE)
+ * Unexpected success. Let's act like we got ERROR_MORE_DATA.
+ * If it doesn't work, we'll hit some other error condition farther on.
+ */
- /*
- * Yes, so we now know how many types to fetch.
- *
- * The buffer needs to have one ULONG for the
- * count and num_ts_modes ULONGs for the
- * num_ts_modes time stamp types.
- */
- modes = (ULONG *)malloc((1 + num_ts_modes) * sizeof(ULONG));
- if (modes == NULL) {
- /* Out of memory. */
- /* XXX SET ebuf */
- pcap_close(p);
- return (NULL);
- }
- modes[0] = 1 + num_ts_modes;
- if (!PacketGetTimestampModes(adapter, modes)) {
- pcap_fmt_errmsg_for_win32_err(ebuf,
- PCAP_ERRBUF_SIZE, GetLastError(),
- "Error calling PacketGetTimestampModes");
- free(modes);
- pcap_close(p);
- return (NULL);
- }
- if (modes[0] != num_ts_modes) {
- snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "First PacketGetTimestampModes() call gives %lu modes, second call gives %u modes",
- num_ts_modes, modes[0]);
- free(modes);
- pcap_close(p);
- return (NULL);
- }
- if (num_ts_modes != 0) {
- u_int num_ts_types;
+ /* If the driver reports no modes supported *and*
+ * ERROR_MORE_DATA, something is seriously wrong.
+ * We *could* ignore the error and continue without supporting
+ * settable timestamp modes, but that would hide a bug.
+ */
+ if (num_ts_modes == 0) {
+ snprintf(ebuf, PCAP_ERRBUF_SIZE,
+ "PacketGetTimestampModes() reports 0 modes supported.");
+ status = -1;
+ break;
+ }
+ /*
+ * Yes, so we now know how many types to fetch.
+ *
+ * The buffer needs to have one ULONG for the
+ * count and num_ts_modes ULONGs for the
+ * num_ts_modes time stamp types.
+ */
+ modes = (ULONG *)malloc((1 + num_ts_modes) * sizeof(ULONG));
+ if (modes == NULL) {
+ /* Out of memory. */
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno, "malloc");
+ status = -1;
+ break;
+ }
+ modes[0] = 1 + num_ts_modes;
+ if (!PacketGetTimestampModes(adapter, modes)) {
+ pcap_fmt_errmsg_for_win32_err(ebuf,
+ PCAP_ERRBUF_SIZE, GetLastError(),
+ "Error calling PacketGetTimestampModes");
+ status = -1;
+ break;
+ }
+ if (modes[0] != num_ts_modes) {
+ snprintf(ebuf, PCAP_ERRBUF_SIZE,
+ "First PacketGetTimestampModes() call gives %lu modes, second call gives %lu modes",
+ num_ts_modes, modes[0]);
+ status = -1;
+ break;
+ }
+
+ /*
+ * Allocate a buffer big enough for
+ * PCAP_TSTAMP_HOST (default) plus
+ * the explicitly specified modes.
+ */
+ p->tstamp_type_list = malloc((1 + num_ts_modes) * sizeof(u_int));
+ if (p->tstamp_type_list == NULL) {
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno, "malloc");
+ status = -1;
+ break;
+ }
+ u_int num_ts_types = 0;
+ p->tstamp_type_list[num_ts_types] =
+ PCAP_TSTAMP_HOST;
+ num_ts_types++;
+ for (ULONG i = 0; i < num_ts_modes; i++) {
+ switch (modes[i + 1]) {
+
+ case TIMESTAMPMODE_SINGLE_SYNCHRONIZATION:
/*
- * Allocate a buffer big enough for
- * PCAP_TSTAMP_HOST (default) plus
- * the explicitly specified modes.
+ * Better than low-res,
+ * but *not* synchronized
+ * with the OS clock.
*/
- p->tstamp_type_list = malloc((1 + modes[0]) * sizeof(u_int));
- if (p->tstamp_type_list == NULL) {
- /* XXX SET ebuf */
- free(modes);
- pcap_close(p);
- return (NULL);
- }
- num_ts_types = 0;
p->tstamp_type_list[num_ts_types] =
- PCAP_TSTAMP_HOST;
+ PCAP_TSTAMP_HOST_HIPREC_UNSYNCED;
num_ts_types++;
- for (ULONG i = 0; i < modes[0]; i++) {
- switch (modes[i + 1]) {
-
- case TIMESTAMPMODE_SINGLE_SYNCHRONIZATION:
- /*
- * Better than low-res,
- * but *not* synchronized
- * with the OS clock.
- */
- p->tstamp_type_list[num_ts_types] =
- PCAP_TSTAMP_HOST_HIPREC_UNSYNCED;
- num_ts_types++;
- break;
-
- case TIMESTAMPMODE_QUERYSYSTEMTIME:
- /*
- * Low-res, but synchronized
- * with the OS clock.
- */
- p->tstamp_type_list[num_ts_types] =
- PCAP_TSTAMP_HOST_LOWPREC;
- num_ts_types++;
- break;
-
- case TIMESTAMPMODE_QUERYSYSTEMTIME_PRECISE:
- /*
- * High-res, and synchronized
- * with the OS clock.
- */
- p->tstamp_type_list[num_ts_types] =
- PCAP_TSTAMP_HOST_HIPREC;
- num_ts_types++;
- break;
-
- default:
- /*
- * Unknown, so we can't
- * report it.
- */
- break;
- }
- }
- p->tstamp_type_count = num_ts_types;
- free(modes);
+ break;
+
+ case TIMESTAMPMODE_QUERYSYSTEMTIME:
+ /*
+ * Low-res, but synchronized
+ * with the OS clock.
+ */
+ p->tstamp_type_list[num_ts_types] =
+ PCAP_TSTAMP_HOST_LOWPREC;
+ num_ts_types++;
+ break;
+
+ case TIMESTAMPMODE_QUERYSYSTEMTIME_PRECISE:
+ /*
+ * High-res, and synchronized
+ * with the OS clock.
+ */
+ p->tstamp_type_list[num_ts_types] =
+ PCAP_TSTAMP_HOST_HIPREC;
+ num_ts_types++;
+ break;
+
+ default:
+ /*
+ * Unknown, so we can't
+ * report it.
+ */
+ break;
}
}
+ p->tstamp_type_count = num_ts_types;
+ } while (0);
+
+ /* Clean up temporary allocations */
+ if (device_copy != NULL) {
+ free(device_copy);
+ }
+ if (modes != NULL) {
+ free(modes);
+ }
+ if (adapter != NULL) {
PacketCloseAdapter(adapter);
}
+
+ return status;
+}
+#else /* HAVE_PACKET_GET_TIMESTAMP_MODES */
+static int
+get_ts_types(const char *device _U_, pcap_t *p _U_, char *ebuf _U_)
+{
+ /*
+ * Nothing to fetch, so it always "succeeds".
+ */
+ return 0;
+}
#endif /* HAVE_PACKET_GET_TIMESTAMP_MODES */
+pcap_t *
+pcap_create_interface(const char *device _U_, char *ebuf)
+{
+ pcap_t *p;
+
+ p = PCAP_CREATE_COMMON(ebuf, struct pcap_win);
+ if (p == NULL)
+ return (NULL);
+
+ p->activate_op = pcap_activate_npf;
+ p->can_set_rfmon_op = pcap_can_set_rfmon_npf;
+
+ if (get_ts_types(device, p, ebuf) == -1) {
+ pcap_close(p);
+ return (NULL);
+ }
return (p);
}
diff --git a/pcap-pf.c b/pcap-pf.c
index 4563a225..bd27933e 100644
--- a/pcap-pf.c
+++ b/pcap-pf.c
@@ -133,6 +133,9 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user)
bp = pc->bp;
/*
* Loop through each packet.
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
*/
n = 0;
pad = pc->fddipad;
diff --git a/pcap-rdmasniff.c b/pcap-rdmasniff.c
index 224821de..d63ca898 100644
--- a/pcap-rdmasniff.c
+++ b/pcap-rdmasniff.c
@@ -38,6 +38,7 @@
#include <infiniband/verbs.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h> /* for INT_MAX */
#include <sys/time.h>
#if !defined(IBV_FLOW_ATTR_SNIFFER)
@@ -136,15 +137,30 @@ rdmasniff_read(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
priv->cq_event = 1;
}
- while (count < max_packets || PACKET_COUNT_IS_UNLIMITED(max_packets)) {
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(max_packets))
+ max_packets = INT_MAX;
+
+ while (count < max_packets) {
if (ibv_poll_cq(priv->cq, 1, &wc) != 1) {
priv->cq_event = 0;
break;
}
if (wc.status != IBV_WC_SUCCESS) {
- fprintf(stderr, "failed WC wr_id %lld status %d/%s\n",
- (unsigned long long) wc.wr_id,
+ fprintf(stderr, "failed WC wr_id %" PRIu64 " status %d/%s\n",
+ wc.wr_id,
wc.status, ibv_wc_status_str(wc.status));
continue;
}
diff --git a/pcap-rpcap.c b/pcap-rpcap.c
index a2612e99..062f1107 100644
--- a/pcap-rpcap.c
+++ b/pcap-rpcap.c
@@ -36,11 +36,13 @@
#endif
#include "ftmacros.h"
+#include "diag-control.h"
#include <string.h> /* for strlen(), ... */
#include <stdlib.h> /* for malloc(), free(), ... */
#include <stdarg.h> /* for functions with variable number of arguments */
#include <errno.h> /* for the errno variable */
+#include <limits.h> /* for INT_MAX */
#include "sockutils.h"
#include "pcap-int.h"
#include "rpcap-protocol.h"
@@ -644,6 +646,21 @@ static int pcap_read_rpcap(pcap_t *p, int cnt, pcap_handler callback, u_char *us
}
}
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(cnt))
+ cnt = INT_MAX;
+
while (n < cnt || PACKET_COUNT_IS_UNLIMITED(cnt))
{
/*
@@ -1003,11 +1020,10 @@ rpcap_remoteact_getsock(const char *host, int *error, char *errbuf)
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- retval = getaddrinfo(host, "0", &hints, &addrinfo);
+ retval = sock_initaddress(host, "0", &hints, &addrinfo, errbuf,
+ PCAP_ERRBUF_SIZE);
if (retval != 0)
{
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "getaddrinfo() %s",
- gai_strerror(retval));
*error = 1;
return NULL;
}
@@ -1060,7 +1076,7 @@ static int pcap_startcapture_remote(pcap_t *fp)
struct pcap_rpcap *pr = fp->priv; /* structure used when doing a remote live capture */
char sendbuf[RPCAP_NETBUF_SIZE]; /* temporary buffer in which data to be sent is buffered */
int sendbufidx = 0; /* index which keeps the number of bytes currently buffered */
- char portdata[PCAP_BUF_SIZE]; /* temp variable needed to keep the network port for the data connection */
+ uint16 portdata = 0; /* temp variable needed to keep the network port for the data connection */
uint32 plen;
int active = 0; /* '1' if we're in active mode */
struct activehosts *temp; /* temp var needed to scan the host list chain, to detect if we're in active mode */
@@ -1073,6 +1089,8 @@ static int pcap_startcapture_remote(pcap_t *fp)
struct sockaddr_storage saddr; /* temp, needed to retrieve the network data port chosen on the local machine */
socklen_t saddrlen; /* temp, needed to retrieve the network data port chosen on the local machine */
int ai_family; /* temp, keeps the address family used by the control connection */
+ struct sockaddr_in *sin4;
+ struct sockaddr_in6 *sin6;
/* RPCAP-related variables*/
struct rpcap_header header; /* header of the RPCAP packet */
@@ -1086,7 +1104,9 @@ static int pcap_startcapture_remote(pcap_t *fp)
uint32 server_sockbufsize;
// Take the opportunity to clear pr->data_ssl before any goto error,
- // as it seems pr->priv is not zeroed after its malloced.
+ // as it seems p->priv is not zeroed after its malloced.
+ // XXX - it now should be, as it's allocated by pcap_alloc_pcap_t(),
+ // which does a calloc().
pr->data_ssl = NULL;
/*
@@ -1171,11 +1191,22 @@ static int pcap_startcapture_remote(pcap_t *fp)
goto error_nodiscard;
}
- /* Get the local port the system picked up */
- if (getnameinfo((struct sockaddr *) &saddr, saddrlen, NULL,
- 0, portdata, sizeof(portdata), NI_NUMERICSERV))
- {
- sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE);
+ switch (saddr.ss_family) {
+
+ case AF_INET:
+ sin4 = (struct sockaddr_in *)&saddr;
+ portdata = sin4->sin_port;
+ break;
+
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6 *)&saddr;
+ portdata = sin6->sin6_port;
+ break;
+
+ default:
+ snprintf(fp->errbuf, PCAP_ERRBUF_SIZE,
+ "Local address has unknown address family %u",
+ saddr.ss_family);
goto error_nodiscard;
}
}
@@ -1208,8 +1239,7 @@ static int pcap_startcapture_remote(pcap_t *fp)
/* portdata on the openreq is meaningful only if we're in active mode */
if ((active) || (pr->rmt_flags & PCAP_OPENFLAG_DATATX_UDP))
{
- sscanf(portdata, "%d", (int *)&(startcapreq->portdata)); /* cast to avoid a compiler warning */
- startcapreq->portdata = htons(startcapreq->portdata);
+ startcapreq->portdata = portdata;
}
startcapreq->snaplen = htonl(fp->snapshot);
@@ -1258,13 +1288,15 @@ static int pcap_startcapture_remote(pcap_t *fp)
{
if (!active)
{
+ char portstring[PCAP_BUF_SIZE];
+
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = ai_family; /* Use the same address family of the control socket */
hints.ai_socktype = (pr->rmt_flags & PCAP_OPENFLAG_DATATX_UDP) ? SOCK_DGRAM : SOCK_STREAM;
- snprintf(portdata, PCAP_BUF_SIZE, "%d", ntohs(startcapreply.portdata));
+ snprintf(portstring, PCAP_BUF_SIZE, "%d", ntohs(startcapreply.portdata));
/* Let's the server pick up a free network port for us */
- if (sock_initaddress(host, portdata, &hints, &addrinfo, fp->errbuf, PCAP_ERRBUF_SIZE) == -1)
+ if (sock_initaddress(host, portstring, &hints, &addrinfo, fp->errbuf, PCAP_ERRBUF_SIZE) == -1)
goto error;
if ((sockdata = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, fp->errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
@@ -2110,6 +2142,79 @@ novers:
return -1;
}
+/* non-alphanumeric unreserved characters plus sub-delims (RFC3986) */
+static const char userinfo_allowed_symbols[] = "-._~!&'()*+,;=";
+
+/*
+ * This function is a thin wrapper around rpcap_doauth which will use an auth
+ * struct created from a username and password parsed out of the userinfo
+ * portion of a URI.
+ */
+static int rpcap_doauth_userinfo(SOCKET sockctrl, SSL *ssl, uint8 *ver, const char *userinfo, char *errbuf)
+{
+ struct pcap_rmtauth auth;
+ const char *ptr;
+ char *buf, username[256], password[256];
+
+ auth.type = RPCAP_RMTAUTH_PWD;
+ auth.username = username;
+ auth.password = password;
+ buf = username;
+
+ username[0] = password[0] = '\0';
+
+ if ((ptr = userinfo) != NULL)
+ {
+ for (int pos = -1; (buf[++pos] = *ptr) != '\0'; ++ptr)
+ {
+ /* handle %xx encoded characters */
+ if (*ptr == '%')
+ {
+ /* the pedantic thing to do here would be throwing an error on
+ * a sequence like `%hi', however a lot of common tools just accept
+ * such malarkey, so... probably it will be fine? */
+ if (sscanf(ptr, "%%%02hhx", (unsigned char *)(buf+pos)) == 1)
+ ptr += 2;
+ /* other implementations aside, rejecting null bytes seems prudent */
+ if (buf[pos] == '\0')
+ {
+ snprintf(errbuf, PCAP_ERRBUF_SIZE, "Invalid escape `%%00` in userinfo");
+ return -1;
+ }
+ }
+ else if (*ptr == ':' && buf == username)
+ {
+ /* terminate username string and switch to password string */
+ buf[pos] = '\0';
+ buf = password;
+ pos = -1;
+ }
+ /* constrain to characters allowed by RFC3986 */
+ else if (*ptr >= 'A' && *ptr <= 'Z')
+ continue;
+ else if (*ptr >= 'a' && *ptr <= 'z')
+ continue;
+ else if (*ptr >= '0' && *ptr <= '9')
+ continue;
+ else if (*ptr < ' ' || *ptr > '~')
+ {
+ snprintf(errbuf, PCAP_ERRBUF_SIZE, "Invalid character `\\%o` in userinfo", *ptr);
+ return -1;
+ }
+ else if (strchr(userinfo_allowed_symbols, *ptr) == NULL)
+ {
+ snprintf(errbuf, PCAP_ERRBUF_SIZE, "Invalid character `%c` in userinfo", *ptr);
+ return -1;
+ }
+ }
+
+ return rpcap_doauth(sockctrl, ssl, ver, &auth, errbuf);
+ }
+
+ return rpcap_doauth(sockctrl, ssl, ver, NULL, errbuf);
+}
+
+
/* We don't currently support non-blocking mode. */
static int
pcap_getnonblock_rpcap(pcap_t *p)
@@ -2134,15 +2239,18 @@ rpcap_setup_session(const char *source, struct pcap_rmtauth *auth,
char *iface, char *errbuf)
{
int type;
+ int auth_result;
+ char userinfo[512]; /* 256 characters each for username and password */
struct activehosts *activeconn; /* active connection, if there is one */
int error; /* 1 if rpcap_remoteact_getsock got an error */
+ userinfo[0] = '\0';
/*
* Determine the type of the source (NULL, file, local, remote).
* You must have a valid source string even if we're in active mode,
* because otherwise the call to the following function will fail.
*/
- if (pcap_parsesrcstr_ex(source, &type, host, port, iface, uses_sslp,
+ if (pcap_parsesrcstr_ex(source, &type, userinfo, host, port, iface, uses_sslp,
errbuf) == -1)
return -1;
@@ -2247,8 +2355,18 @@ rpcap_setup_session(const char *source, struct pcap_rmtauth *auth,
#endif
}
- if (rpcap_doauth(*sockctrlp, *sslp, protocol_versionp, auth,
- errbuf) == -1)
+ if (auth == NULL && *userinfo != '\0')
+ {
+ auth_result = rpcap_doauth_userinfo(*sockctrlp, *sslp, protocol_versionp,
+ userinfo, errbuf);
+ }
+ else
+ {
+ auth_result = rpcap_doauth(*sockctrlp, *sslp, protocol_versionp, auth,
+ errbuf);
+ }
+
+ if (auth_result == -1)
{
#ifdef HAVE_OPENSSL
if (*sslp)
@@ -2592,7 +2710,7 @@ pcap_findalldevs_ex_remote(const char *source, struct pcap_rmtauth *auth, pcap_i
/* Create the new device identifier */
if (pcap_createsrcstr_ex(tmpstring2, PCAP_SRC_IFREMOTE,
- host, port, tmpstring, uses_ssl, errbuf) == -1)
+ NULL, host, port, tmpstring, uses_ssl, errbuf) == -1)
goto error;
dev->name = strdup(tmpstring2);
@@ -2992,10 +3110,10 @@ int pcap_remoteact_close(const char *host, char *errbuf)
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- retval = getaddrinfo(host, "0", &hints, &addrinfo);
+ retval = sock_initaddress(host, "0", &hints, &addrinfo, errbuf,
+ PCAP_ERRBUF_SIZE);
if (retval != 0)
{
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "getaddrinfo() %s", gai_strerror(retval));
return -1;
}
@@ -3352,7 +3470,9 @@ static void rpcap_msg_err(SOCKET sockctrl, SSL *ssl, uint32 plen, char *remote_e
PCAP_ERRBUF_SIZE) == -1)
{
// Network error.
+ DIAG_OFF_FORMAT_TRUNCATION
snprintf(remote_errbuf, PCAP_ERRBUF_SIZE, "Read of error message from client failed: %s", errbuf);
+ DIAG_ON_FORMAT_TRUNCATION
return;
}
@@ -3387,7 +3507,9 @@ static void rpcap_msg_err(SOCKET sockctrl, SSL *ssl, uint32 plen, char *remote_e
PCAP_ERRBUF_SIZE) == -1)
{
// Network error.
+ DIAG_OFF_FORMAT_TRUNCATION
snprintf(remote_errbuf, PCAP_ERRBUF_SIZE, "Read of error message from client failed: %s", errbuf);
+ DIAG_ON_FORMAT_TRUNCATION
return;
}
diff --git a/pcap-sita.c b/pcap-sita.c
index c53f3235..16475729 100644
--- a/pcap-sita.c
+++ b/pcap-sita.c
@@ -441,7 +441,7 @@ static char *translate_IOP_to_pcap_name(unit_t *u, char *IOPname, bpf_u_int32 if
iface->iftype = iftype; /* remember the interface type of this interface */
- iface->IOPname = strdup(IOPnam); /* copy it and stick it into the structure */
+ iface->IOPname = strdup(IOPname); /* copy it and stick it into the structure */
if (iface->IOPname == NULL) { /* oops, we didn't get the memory requested */
fprintf(stderr, "Error...couldn't allocate memory for IOPname...value of errno is: %d\n", errno);
return NULL;
diff --git a/pcap-snf.c b/pcap-snf.c
index a9162eba..b885e026 100644
--- a/pcap-snf.c
+++ b/pcap-snf.c
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <limits.h> /* for INT_MAX */
#ifndef _WIN32
#include <netinet/in.h>
@@ -139,9 +140,24 @@ snf_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
if (!p)
return -1;
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(cnt))
+ cnt = INT_MAX;
+
n = 0;
timeout = ps->snf_timeout;
- while (n < cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) {
+ while (n < cnt) {
/*
* Has "pcap_breakloop()" been called?
*/
diff --git a/pcap-snit.c b/pcap-snit.c
index ca6222cf..ff0cb59a 100644
--- a/pcap-snit.c
+++ b/pcap-snit.c
@@ -139,6 +139,9 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
/*
* loop through each snapshot in the chunk
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
*/
n = 0;
ep = bp + cc;
diff --git a/pcap-tc.c b/pcap-tc.c
index 9902633a..aa28f0fe 100644
--- a/pcap-tc.c
+++ b/pcap-tc.c
@@ -1124,7 +1124,7 @@ TcSetMode(pcap_t *p, int mode)
{
if (mode != MODE_CAPT)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Mode %u not supported by TurboCap devices. TurboCap only supports capture.", mode);
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Mode %d not supported by TurboCap devices. TurboCap only supports capture.", mode);
return -1;
}
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index 3596428e..f15c80b6 100644
--- a/pcap-usb-linux.c
+++ b/pcap-usb-linux.c
@@ -71,10 +71,6 @@
#endif /* HAVE_LINUX_USBDEVICE_FS_H */
#define USB_IFACE "usbmon"
-#define USB_TEXT_DIR_OLD "/sys/kernel/debug/usbmon"
-#define USB_TEXT_DIR "/sys/kernel/debug/usb/usbmon"
-#define SYS_USB_BUS_DIR "/sys/bus/usb/devices"
-#define PROC_USB_BUS_DIR "/proc/bus/usb"
#define USB_LINE_LEN 4096
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -132,99 +128,13 @@ struct pcap_usb_linux {
/* forward declaration */
static int usb_activate(pcap_t *);
-static int usb_stats_linux(pcap_t *, struct pcap_stat *);
static int usb_stats_linux_bin(pcap_t *, struct pcap_stat *);
-static int usb_read_linux(pcap_t *, int , pcap_handler , u_char *);
static int usb_read_linux_bin(pcap_t *, int , pcap_handler , u_char *);
static int usb_read_linux_mmap(pcap_t *, int , pcap_handler , u_char *);
static int usb_inject_linux(pcap_t *, const void *, int);
static int usb_setdirection_linux(pcap_t *, pcap_direction_t);
static void usb_cleanup_linux_mmap(pcap_t *);
-static int
-have_binary_usbmon(void)
-{
- struct utsname utsname;
- char *version_component, *endp;
- long major, minor, subminor;
-
- if (uname(&utsname) == 0) {
- /*
- * 2.6.21 is the first release with the binary-mode
- * USB monitoring.
- */
- version_component = utsname.release;
- major = strtol(version_component, &endp, 10);
- if (endp != version_component && *endp == '.') {
- /*
- * OK, that was a valid major version.
- * Is it 3 or greater? If so, we have binary
- * mode support.
- */
- if (major >= 3)
- return 1;
-
- /*
- * Is it 1 or less? If so, we don't have binary
- * mode support. (In fact, we don't have any
- * USB monitoring....)
- */
- if (major <= 1)
- return 0;
- }
-
- /*
- * OK, this is a 2.x kernel.
- * What's the minor version?
- */
- version_component = endp + 1;
- minor = strtol(version_component, &endp, 10);
- if (endp != version_component &&
- (*endp == '.' || *endp == '\0')) {
- /*
- * OK, that was a valid minor version.
- * Is is 2.6 or later? (There shouldn't be a
- * "later", as 2.6.x went to 3.x, but we'll
- * check anyway.)
- */
- if (minor < 6) {
- /*
- * No, so no binary support (did 2.4 have
- * any USB monitoring at all?)
- */
- return 0;
- }
-
- /*
- * OK, this is a 2.6.x kernel.
- * What's the subminor version?
- */
- version_component = endp + 1;
- subminor = strtol(version_component, &endp, 10);
- if (endp != version_component &&
- (*endp == '.' || *endp == '\0')) {
- /*
- * OK, that was a valid subminor version.
- * Is it 21 or greater?
- */
- if (subminor >= 21) {
- /*
- * Yes - we have binary mode
- * support.
- */
- return 1;
- }
- }
- }
- }
-
- /*
- * Either uname() failed, in which case we just say "no binary
- * mode support", or we don't have binary mode support.
- */
- return 0;
-}
-
/* facility to add an USB device to the device list*/
static int
usb_dev_add(pcap_if_list_t *devlistp, int n, char *err_str)
@@ -271,115 +181,51 @@ usb_findalldevs(pcap_if_list_t *devlistp, char *err_str)
DIR* dir;
int n;
char* name;
- size_t len;
-
- if (have_binary_usbmon()) {
- /*
- * We have binary-mode support.
- * What do the device names look like?
- * Split LINUX_USB_MON_DEV into a directory that we'll
- * scan and a file name prefix that we'll check for.
- */
- pcap_strlcpy(usb_mon_dir, LINUX_USB_MON_DEV, sizeof usb_mon_dir);
- usb_mon_prefix = strrchr(usb_mon_dir, '/');
- if (usb_mon_prefix == NULL) {
- /*
- * This "shouldn't happen". Just give up if it
- * does.
- */
- return 0;
- }
- *usb_mon_prefix++ = '\0';
- usb_mon_prefix_len = strlen(usb_mon_prefix);
+ /*
+ * We require 2.6.27 or later kernels, so we have binary-mode support.
+ * What do the device names look like?
+ * Split LINUX_USB_MON_DEV into a directory that we'll
+ * scan and a file name prefix that we'll check for.
+ */
+ pcap_strlcpy(usb_mon_dir, LINUX_USB_MON_DEV, sizeof usb_mon_dir);
+ usb_mon_prefix = strrchr(usb_mon_dir, '/');
+ if (usb_mon_prefix == NULL) {
/*
- * Open the directory and scan it.
+ * This "shouldn't happen". Just give up if it
+ * does.
*/
- dir = opendir(usb_mon_dir);
- if (dir != NULL) {
- while ((ret == 0) && ((data = readdir(dir)) != 0)) {
- name = data->d_name;
-
- /*
- * Is this a usbmon device?
- */
- if (strncmp(name, usb_mon_prefix, usb_mon_prefix_len) != 0)
- continue; /* no */
-
- /*
- * What's the device number?
- */
- if (sscanf(&name[usb_mon_prefix_len], "%d", &n) == 0)
- continue; /* failed */
-
- ret = usb_dev_add(devlistp, n, err_str);
- }
-
- closedir(dir);
- }
return 0;
- } else {
- /*
- * We have only text mode support.
- * We don't look for the text devices because we can't
- * look for them without root privileges, and we don't
- * want to require root privileges to enumerate devices
- * (we want to let the user to try a device and get
- * an error, rather than seeing no devices and asking
- * "why am I not seeing devices" and forcing a long
- * process of poking to figure out whether it's "no
- * privileges" or "your kernel is too old" or "the
- * usbmon module isn't loaded" or...).
- *
- * Instead, we look to see what buses we have.
- * If the kernel is so old that it doesn't have
- * binary-mode support, it's also so old that
- * it doesn't have a "scan all buses" device.
- *
- * First, try scanning sysfs USB bus directory.
- */
- dir = opendir(SYS_USB_BUS_DIR);
- if (dir != NULL) {
- while ((ret == 0) && ((data = readdir(dir)) != 0)) {
- name = data->d_name;
-
- if (strncmp(name, "usb", 3) != 0)
- continue;
-
- if (sscanf(&name[3], "%d", &n) == 0)
- continue;
+ }
+ *usb_mon_prefix++ = '\0';
+ usb_mon_prefix_len = strlen(usb_mon_prefix);
- ret = usb_dev_add(devlistp, n, err_str);
- }
+ /*
+ * Open the directory and scan it.
+ */
+ dir = opendir(usb_mon_dir);
+ if (dir != NULL) {
+ while ((ret == 0) && ((data = readdir(dir)) != 0)) {
+ name = data->d_name;
- closedir(dir);
- return 0;
- }
+ /*
+ * Is this a usbmon device?
+ */
+ if (strncmp(name, usb_mon_prefix, usb_mon_prefix_len) != 0)
+ continue; /* no */
- /* That didn't work; try scanning procfs USB bus directory. */
- dir = opendir(PROC_USB_BUS_DIR);
- if (dir != NULL) {
- while ((ret == 0) && ((data = readdir(dir)) != 0)) {
- name = data->d_name;
- len = strlen(name);
-
- /* if this file name does not end with a number it's not of our interest */
- if ((len < 1) || !PCAP_ISDIGIT(name[--len]))
- continue;
- while (PCAP_ISDIGIT(name[--len]));
- if (sscanf(&name[len+1], "%d", &n) != 1)
- continue;
-
- ret = usb_dev_add(devlistp, n, err_str);
- }
+ /*
+ * What's the device number?
+ */
+ if (sscanf(&name[usb_mon_prefix_len], "%d", &n) == 0)
+ continue; /* failed */
- closedir(dir);
- return ret;
+ ret = usb_dev_add(devlistp, n, err_str);
}
- /* neither of them worked */
- return 0;
+ closedir(dir);
}
+ return 0;
}
/*
@@ -630,7 +476,6 @@ usb_activate(pcap_t* handle)
{
struct pcap_usb_linux *handlep = handle->priv;
char full_path[USB_LINE_LEN];
- int ret;
/*
* Turn a negative snapshot value (invalid), a snapshot value of
@@ -663,166 +508,97 @@ usb_activate(pcap_t* handle)
return PCAP_ERROR;
}
- if (have_binary_usbmon())
+ /*
+ * We require 2.6.27 or later kernels, so we have binary-mode support.
+ * Try to open the binary interface.
+ */
+ snprintf(full_path, USB_LINE_LEN, LINUX_USB_MON_DEV"%d", handlep->bus_index);
+ handle->fd = open(full_path, O_RDONLY, 0);
+ if (handle->fd < 0)
{
/*
- * We have binary-mode support.
- * Try to open the binary interface.
+ * The attempt failed; why?
*/
- snprintf(full_path, USB_LINE_LEN, LINUX_USB_MON_DEV"%d", handlep->bus_index);
- handle->fd = open(full_path, O_RDONLY, 0);
- if (handle->fd < 0)
- {
+ switch (errno) {
+
+ case ENOENT:
/*
- * The attempt failed; why?
+ * The device doesn't exist.
+ * That could either mean that there's
+ * no support for monitoring USB buses
+ * (which probably means "the usbmon
+ * module isn't loaded") or that there
+ * is but that *particular* device
+ * doesn't exist (no "scan all buses"
+ * device if the bus index is 0, no
+ * such bus if the bus index isn't 0).
*/
- switch (errno) {
-
- case ENOENT:
- /*
- * The device doesn't exist.
- * That could either mean that there's
- * no support for monitoring USB buses
- * (which probably means "the usbmon
- * module isn't loaded") or that there
- * is but that *particular* device
- * doesn't exist (no "scan all buses"
- * device if the bus index is 0, no
- * such bus if the bus index isn't 0).
- */
- return PCAP_ERROR_NO_SUCH_DEVICE;
-
- case EACCES:
- /*
- * We didn't have permission to open it.
- */
- return PCAP_ERROR_PERM_DENIED;
+ return PCAP_ERROR_NO_SUCH_DEVICE;
- default:
- /*
- * Something went wrong.
- */
- pcap_fmt_errmsg_for_errno(handle->errbuf,
- PCAP_ERRBUF_SIZE, errno,
- "Can't open USB bus file %s", full_path);
- return PCAP_ERROR;
- }
- }
-
- if (handle->opt.rfmon)
- {
+ case EACCES:
/*
- * Monitor mode doesn't apply to USB devices.
+ * We didn't have permission to open it.
*/
- close(handle->fd);
- return PCAP_ERROR_RFMON_NOTSUP;
- }
-
- /* try to use fast mmap access */
- if (usb_mmap(handle))
- {
- /* We succeeded. */
- handle->linktype = DLT_USB_LINUX_MMAPPED;
- handle->stats_op = usb_stats_linux_bin;
- handle->read_op = usb_read_linux_mmap;
- handle->cleanup_op = usb_cleanup_linux_mmap;
-#ifdef HAVE_LINUX_USBDEVICE_FS_H
- probe_devices(handlep->bus_index);
-#endif
+ return PCAP_ERROR_PERM_DENIED;
+ default:
/*
- * "handle->fd" is a real file, so
- * "select()" and "poll()" work on it.
+ * Something went wrong.
*/
- handle->selectable_fd = handle->fd;
- return 0;
+ pcap_fmt_errmsg_for_errno(handle->errbuf,
+ PCAP_ERRBUF_SIZE, errno,
+ "Can't open USB bus file %s", full_path);
+ return PCAP_ERROR;
}
+ }
+ if (handle->opt.rfmon)
+ {
/*
- * We failed; try plain binary interface access.
- *
- * Attempt to set the ring size as appropriate for
- * the snapshot length, reducing the snapshot length
- * if that'd make the ring bigger than the kernel
- * supports.
+ * Monitor mode doesn't apply to USB devices.
*/
- if (usb_set_ring_size(handle, (int)sizeof(pcap_usb_header)) == -1) {
- /* Failed. */
- close(handle->fd);
- return PCAP_ERROR;
- }
+ close(handle->fd);
+ return PCAP_ERROR_RFMON_NOTSUP;
+ }
+
+ /* try to use fast mmap access */
+ if (usb_mmap(handle))
+ {
+ /* We succeeded. */
+ handle->linktype = DLT_USB_LINUX_MMAPPED;
handle->stats_op = usb_stats_linux_bin;
- handle->read_op = usb_read_linux_bin;
+ handle->read_op = usb_read_linux_mmap;
+ handle->cleanup_op = usb_cleanup_linux_mmap;
#ifdef HAVE_LINUX_USBDEVICE_FS_H
probe_devices(handlep->bus_index);
#endif
- }
- else {
+
/*
- * We don't have binary mode support.
- * Try opening the text-mode device.
+ * "handle->fd" is a real file, so
+ * "select()" and "poll()" work on it.
*/
- snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR"/%dt", handlep->bus_index);
- handle->fd = open(full_path, O_RDONLY, 0);
- if (handle->fd < 0)
- {
- if (errno == ENOENT)
- {
- /*
- * Not found at the new location; try
- * the old location.
- */
- snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handlep->bus_index);
- handle->fd = open(full_path, O_RDONLY, 0);
- }
- if (handle->fd < 0) {
- if (errno == ENOENT)
- {
- /*
- * The problem is that the file
- * doesn't exist. Report that as
- * "no such device". (That could
- * mean "no such USB bus" or
- * "monitoring not supported".)
- */
- ret = PCAP_ERROR_NO_SUCH_DEVICE;
- }
- else if (errno == EACCES)
- {
- /*
- * The problem is that we don't
- * have sufficient permission to
- * open the file. Report that.
- */
- ret = PCAP_ERROR_PERM_DENIED;
- }
- else
- {
- /*
- * Some other error.
- */
- ret = PCAP_ERROR;
- }
- pcap_fmt_errmsg_for_errno(handle->errbuf,
- PCAP_ERRBUF_SIZE, errno,
- "Can't open USB bus file %s",
- full_path);
- return ret;
- }
- }
-
- if (handle->opt.rfmon)
- {
- /*
- * Monitor mode doesn't apply to USB devices.
- */
- close(handle->fd);
- return PCAP_ERROR_RFMON_NOTSUP;
- }
+ handle->selectable_fd = handle->fd;
+ return 0;
+ }
- handle->stats_op = usb_stats_linux;
- handle->read_op = usb_read_linux;
+ /*
+ * We failed; try plain binary interface access.
+ *
+ * Attempt to set the ring size as appropriate for
+ * the snapshot length, reducing the snapshot length
+ * if that'd make the ring bigger than the kernel
+ * supports.
+ */
+ if (usb_set_ring_size(handle, (int)sizeof(pcap_usb_header)) == -1) {
+ /* Failed. */
+ close(handle->fd);
+ return PCAP_ERROR;
}
+ handle->stats_op = usb_stats_linux_bin;
+ handle->read_op = usb_read_linux_bin;
+#ifdef HAVE_LINUX_USBDEVICE_FS_H
+ probe_devices(handlep->bus_index);
+#endif
/*
* "handle->fd" is a real file, so "select()" and "poll()"
@@ -842,219 +618,6 @@ usb_activate(pcap_t* handle)
return 0;
}
-static inline int
-ascii_to_int(char c)
-{
- return c < 'A' ? c- '0': ((c<'a') ? c - 'A' + 10: c-'a'+10);
-}
-
-/*
- * see <linux-kernel-source>/Documentation/usb/usbmon.txt and
- * <linux-kernel-source>/drivers/usb/mon/mon_text.c for urb string
- * format description
- */
-static int
-usb_read_linux(pcap_t *handle, int max_packets _U_, pcap_handler callback, u_char *user)
-{
- /* see:
- * /usr/src/linux/Documentation/usb/usbmon.txt
- * for message format
- */
- struct pcap_usb_linux *handlep = handle->priv;
- unsigned timestamp;
- int tag, cnt, ep_num, dev_addr, dummy, ret, urb_len, data_len;
- ssize_t read_ret;
- char etype, pipeid1, pipeid2, status[16], urb_tag, line[USB_LINE_LEN];
- char *string = line;
- u_char * rawdata = handle->buffer;
- struct pcap_pkthdr pkth;
- pcap_usb_header* uhdr = (pcap_usb_header*)handle->buffer;
- u_char urb_transfer=0;
- int incoming=0;
-
- /* ignore interrupt system call errors */
- do {
- read_ret = read(handle->fd, line, USB_LINE_LEN - 1);
- if (handle->break_loop)
- {
- handle->break_loop = 0;
- return -2;
- }
- } while ((read_ret == -1) && (errno == EINTR));
- if (read_ret < 0)
- {
- if (errno == EAGAIN)
- return 0; /* no data there */
-
- pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
- errno, "Can't read from fd %d", handle->fd);
- return -1;
- }
-
- /* read urb header; %n argument may increment return value, but it's
- * not mandatory, so does not count on it*/
- string[read_ret] = 0;
- ret = sscanf(string, "%x %d %c %c%c:%d:%d %s%n", &tag, &timestamp, &etype,
- &pipeid1, &pipeid2, &dev_addr, &ep_num, status,
- &cnt);
- if (ret < 8)
- {
- char string_truncated[181];
-
- strncpy(string_truncated, string, sizeof(string_truncated));
- string_truncated[sizeof(string_truncated) - 1] = 0;
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't parse USB bus message '%s', too few tokens (expected 8 got %d)",
- string_truncated, ret);
- return -1;
- }
- uhdr->id = tag;
- uhdr->device_address = dev_addr;
- uhdr->bus_id = handlep->bus_index;
- uhdr->status = 0;
- string += cnt;
-
- /* don't use usbmon provided timestamp, since it have low precision*/
- if (gettimeofday(&pkth.ts, NULL) < 0)
- {
- pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
- errno, "Can't get timestamp for message '%s'", string);
- return -1;
- }
- uhdr->ts_sec = pkth.ts.tv_sec;
- uhdr->ts_usec = (int32_t)pkth.ts.tv_usec;
-
- /* parse endpoint information */
- if (pipeid1 == 'C')
- urb_transfer = URB_CONTROL;
- else if (pipeid1 == 'Z')
- urb_transfer = URB_ISOCHRONOUS;
- else if (pipeid1 == 'I')
- urb_transfer = URB_INTERRUPT;
- else if (pipeid1 == 'B')
- urb_transfer = URB_BULK;
- if (pipeid2 == 'i') {
- ep_num |= URB_TRANSFER_IN;
- incoming = 1;
- }
- if (etype == 'C')
- incoming = !incoming;
-
- /* direction check*/
- if (incoming)
- {
- if (handle->direction == PCAP_D_OUT)
- return 0;
- }
- else
- if (handle->direction == PCAP_D_IN)
- return 0;
- uhdr->event_type = etype;
- uhdr->transfer_type = urb_transfer;
- uhdr->endpoint_number = ep_num;
- pkth.caplen = sizeof(pcap_usb_header);
- rawdata += sizeof(pcap_usb_header);
-
- /* check if this is a setup packet */
- ret = sscanf(status, "%d", &dummy);
- if (ret != 1)
- {
- /* this a setup packet, setup data can be filled with underscore if
- * usbmon has not been able to read them, so we must parse this fields as
- * strings */
- pcap_usb_setup* shdr;
- char str1[3], str2[3], str3[5], str4[5], str5[5];
- ret = sscanf(string, "%s %s %s %s %s%n", str1, str2, str3, str4,
- str5, &cnt);
- if (ret < 5)
- {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't parse USB bus message '%s', too few tokens (expected 5 got %d)",
- string, ret);
- return -1;
- }
- string += cnt;
-
- /* try to convert to corresponding integer */
- shdr = &uhdr->setup;
- shdr->bmRequestType = strtoul(str1, 0, 16);
- shdr->bRequest = strtoul(str2, 0, 16);
- shdr->wValue = htols(strtoul(str3, 0, 16));
- shdr->wIndex = htols(strtoul(str4, 0, 16));
- shdr->wLength = htols(strtoul(str5, 0, 16));
-
- uhdr->setup_flag = 0;
- }
- else
- uhdr->setup_flag = 1;
-
- /* read urb data */
- ret = sscanf(string, " %d%n", &urb_len, &cnt);
- if (ret < 1)
- {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't parse urb length from '%s'", string);
- return -1;
- }
- string += cnt;
-
- /* urb tag is not present if urb length is 0, so we can stop here
- * text parsing */
- pkth.len = urb_len+pkth.caplen;
- uhdr->urb_len = urb_len;
- uhdr->data_flag = 1;
- data_len = 0;
- if (uhdr->urb_len == 0)
- goto got;
-
- /* check for data presence; data is present if and only if urb tag is '=' */
- if (sscanf(string, " %c", &urb_tag) != 1)
- {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't parse urb tag from '%s'", string);
- return -1;
- }
-
- if (urb_tag != '=')
- goto got;
-
- /* skip urb tag and following space */
- string += 3;
-
- /* if we reach this point we got some urb data*/
- uhdr->data_flag = 0;
-
- /* read all urb data; if urb length is greater then the usbmon internal
- * buffer length used by the kernel to spool the URB, we get only
- * a partial information.
- * At least until linux 2.6.17 there is no way to set usbmon intenal buffer
- * length and default value is 130. */
- while ((string[0] != 0) && (string[1] != 0) && (pkth.caplen < (bpf_u_int32)handle->snapshot))
- {
- rawdata[0] = ascii_to_int(string[0]) * 16 + ascii_to_int(string[1]);
- rawdata++;
- string+=2;
- if (string[0] == ' ')
- string++;
- pkth.caplen++;
- data_len++;
- }
-
-got:
- uhdr->data_len = data_len;
- if (pkth.caplen > (bpf_u_int32)handle->snapshot)
- pkth.caplen = (bpf_u_int32)handle->snapshot;
-
- if (handle->fcode.bf_insns == NULL ||
- pcap_filter(handle->fcode.bf_insns, handle->buffer,
- pkth.len, pkth.caplen)) {
- handlep->packets_read++;
- callback(user, &pkth, handle->buffer);
- return 1;
- }
- return 0; /* didn't pass filter */
-}
-
static int
usb_inject_linux(pcap_t *handle, const void *buf _U_, int size _U_)
{
@@ -1064,85 +627,6 @@ usb_inject_linux(pcap_t *handle, const void *buf _U_, int size _U_)
}
static int
-usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
-{
- struct pcap_usb_linux *handlep = handle->priv;
- int dummy, cnt;
- ssize_t ret, consumed;
- char string[USB_LINE_LEN];
- char token[USB_LINE_LEN];
- char * ptr = string;
- int fd;
-
- snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handlep->bus_index);
- fd = open(string, O_RDONLY, 0);
- if (fd < 0)
- {
- if (errno == ENOENT)
- {
- /*
- * Not found at the new location; try the old
- * location.
- */
- snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handlep->bus_index);
- fd = open(string, O_RDONLY, 0);
- }
- if (fd < 0) {
- pcap_fmt_errmsg_for_errno(handle->errbuf,
- PCAP_ERRBUF_SIZE, errno,
- "Can't open USB stats file %s", string);
- return -1;
- }
- }
-
- /* read stats line */
- do {
- ret = read(fd, string, USB_LINE_LEN-1);
- } while ((ret == -1) && (errno == EINTR));
- close(fd);
-
- if (ret < 0)
- {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't read stats from fd %d ", fd);
- return -1;
- }
- string[ret] = 0;
-
- stats->ps_recv = handlep->packets_read;
- stats->ps_drop = 0; /* unless we find text_lost */
- stats->ps_ifdrop = 0;
-
- /* extract info on dropped urbs */
- for (consumed=0; consumed < ret; ) {
- /* from the sscanf man page:
- * The C standard says: "Execution of a %n directive does
- * not increment the assignment count returned at the completion
- * of execution" but the Corrigendum seems to contradict this.
- * Do not make any assumptions on the effect of %n conversions
- * on the return value and explicitly check for cnt assignmet*/
- int ntok;
-
- cnt = -1;
- ntok = sscanf(ptr, "%s%n", token, &cnt);
- if ((ntok < 1) || (cnt < 0))
- break;
- consumed += cnt;
- ptr += cnt;
- if (strcmp(token, "text_lost") == 0)
- ntok = sscanf(ptr, "%d%n", &stats->ps_drop, &cnt);
- else
- ntok = sscanf(ptr, "%d%n", &dummy, &cnt);
- if ((ntok != 1) || (cnt < 0))
- break;
- consumed += cnt;
- ptr += cnt;
- }
-
- return 0;
-}
-
-static int
usb_setdirection_linux(pcap_t *p, pcap_direction_t d)
{
/*
@@ -1153,7 +637,6 @@ usb_setdirection_linux(pcap_t *p, pcap_direction_t d)
return 0;
}
-
static int
usb_stats_linux_bin(pcap_t *handle, struct pcap_stat *stats)
{
@@ -1284,13 +767,40 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
for (;;) {
int i, ret;
- int limit = max_packets - packets;
- if (limit <= 0)
- limit = VEC_SIZE;
- if (limit > VEC_SIZE)
+ int limit;
+
+ if (PACKET_COUNT_IS_UNLIMITED(max_packets)) {
+ /*
+ * There's no limit on the number of packets
+ * to process, so try to fetch VEC_SIZE packets.
+ */
limit = VEC_SIZE;
+ } else {
+ /*
+ * Try to fetch as many packets as we have left
+ * to process, or VEC_SIZE packets, whichever
+ * is less.
+ *
+ * At this point, max_packets > 0 (otherwise,
+ * PACKET_COUNT_IS_UNLIMITED(max_packets)
+ * would be true) and max_packets > packets
+ * (packet starts out as 0, and the test
+ * at the bottom of the loop exits if
+ * max_packets <= packets), so limit is
+ * guaranteed to be > 0.
+ */
+ limit = max_packets - packets;
+ if (limit > VEC_SIZE)
+ limit = VEC_SIZE;
+ }
- /* try to fetch as many events as possible*/
+ /*
+ * Try to fetch as many events as possible, up to
+ * the limit, and flush the events we've processed
+ * earlier (nflush) - MON_IOCX_MFETCH does both
+ * (presumably to reduce the number of system
+ * calls in loops like this).
+ */
fetch.offvec = vec;
fetch.nfetch = limit;
fetch.nflush = nflush;
@@ -1317,6 +827,20 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
/* keep track of processed events, we will flush them later */
nflush = fetch.nfetch;
for (i=0; i<fetch.nfetch; ++i) {
+ /*
+ * XXX - we can't check break_loop here, as
+ * we read the indices of packets into a
+ * local variable, so if we're later called
+ * to fetch more packets, those packets will
+ * not be seen - and won't be flushed, either.
+ *
+ * Instead, we would have to keep the array
+ * of indices in our private data, along
+ * with the count of packets to flush - or
+ * would have to flush the already-processed
+ * packets if we break out of the loop here.
+ */
+
/* discard filler */
hdr = (pcap_usb_header_mmapped*) &handlep->mmapbuf[vec[i]];
if (hdr->event_type == '@')
@@ -1376,8 +900,12 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
}
}
- /* with max_packets specifying "unlimited" we stop after the first chunk*/
- if (PACKET_COUNT_IS_UNLIMITED(max_packets) || (packets == max_packets))
+ /*
+ * If max_packets specifiesg "unlimited", we stop after
+ * the first chunk.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(max_packets) ||
+ (packets >= max_packets))
break;
}
diff --git a/pcap.3pcap.in b/pcap.3pcap.in
index 492c227e..a43f7a09 100644
--- a/pcap.3pcap.in
+++ b/pcap.3pcap.in
@@ -272,7 +272,7 @@ On some platforms, the time stamp given to packets on live captures can
come from different sources that can have different resolutions or that
can have different relationships to the time values for the current time
supplied by routines on the native operating system. See
-.BR pcap-tstamp (@MAN_MISC_INFO@)
+.BR \%pcap-tstamp (@MAN_MISC_INFO@)
for a list of time stamp types.
.IP
The time stamp type is set with
@@ -784,17 +784,17 @@ get the state of non-blocking mode for a
attempt to get a descriptor for a
.B pcap_t
that can be used in calls such as
-.BR select (2)
+.BR select ()
and
-.BR poll (2)
+.BR poll ()
.TP
.BR pcap_get_required_select_timeout (3PCAP)
attempt to get a timeout required for using a
.B pcap_t
in calls such as
-.BR select (2)
+.BR select ()
and
-.BR poll (2)
+.BR poll ()
.RE
.SS Filters
In order to cause only certain packets to be returned when reading
@@ -804,7 +804,7 @@ copying ``uninteresting'' packets from the kernel to user mode.
.PP
A filter can be specified as a text string; the syntax and semantics of
the string are as described by
-.BR pcap-filter (@MAN_MISC_INFO@).
+.BR \%pcap-filter (@MAN_MISC_INFO@).
A filter string is compiled into a program in a pseudo-machine-language
by
.BR pcap_compile ()
@@ -894,13 +894,19 @@ call
.BR pcap_dump_open (3PCAP)
open a
.B pcap_dumper_t
-for a ``savefile``, given a pathname
+for a ``savefile``, given a pathname, replacing any existing data
+.TP
+.BR pcap_dump_open_append (3PCAP)
+open a
+.B pcap_dumper_t
+for a ``savefile``, given a pathname, appending to the existing data
.TP
.BR pcap_dump_fopen (3PCAP)
open a
.B pcap_dumper_t
for a ``savefile``, given a
-.B "FILE\ *"
+.BR "FILE\ *" ,
+assuming an empty file
.TP
.BR pcap_dump_close (3PCAP)
close a
@@ -1027,7 +1033,7 @@ script or some other configuration script to check whether the libpcap
.BR autoconf (1),
.BR tcpdump (1),
.BR tcpslice (1),
-.BR pcap-filter (@MAN_MISC_INFO@),
+.BR \%pcap-filter (@MAN_MISC_INFO@),
.BR pfconfig (8),
.BR usermod (@MAN_ADMIN_COMMANDS@)
.SH AUTHORS
@@ -1044,7 +1050,7 @@ The current version is available from "The Tcpdump Group"'s Web site at
.I https://www.tcpdump.org/
.RE
.SH BUGS
-To report a security issue please send an e-mail to security@tcpdump.org.
+To report a security issue please send an e-mail to \%security@tcpdump.org.
.LP
To report bugs and other problems, contribute patches, request a
feature, provide generic feedback etc please see the file
diff --git a/pcap.c b/pcap.c
index 58ef71d2..92ec0706 100644
--- a/pcap.c
+++ b/pcap.c
@@ -622,7 +622,9 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
* Return codes for pcap_offline_read() are:
* - 0: EOF
* - -1: error
- * - >1: OK
+ * - >0: OK - result is number of packets read, so
+ * it will be 1 in this case, as we've passed
+ * a maximum packet count of 1
* The first one ('0') conflicts with the return code of
* 0 from pcap_read() meaning "no packets arrived before
* the timeout expired", so we map it to -2 so you can
@@ -641,7 +643,9 @@ pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
* - 0: timeout
* - -1: error
* - -2: loop was broken out of with pcap_breakloop()
- * - >1: OK
+ * - >0: OK, result is number of packets captured, so
+ * it will be 1 in this case, as we've passed
+ * a maximum packet count of 1
* The first one ('0') conflicts with the return code of 0 from
* pcap_offline_read() meaning "end of file".
*/
@@ -2059,8 +2063,8 @@ pcap_parse_source(const char *source, char **schemep, char **userinfop,
}
int
-pcap_createsrcstr_ex(char *source, int type, const char *host, const char *port,
- const char *name, unsigned char uses_ssl, char *errbuf)
+pcap_createsrcstr_ex(char *source, int type, const char *userinfo, const char *host,
+ const char *port, const char *name, unsigned char uses_ssl, char *errbuf)
{
switch (type) {
@@ -2080,6 +2084,11 @@ pcap_createsrcstr_ex(char *source, int type, const char *host, const char *port,
(uses_ssl ? "rpcaps://" : PCAP_SRC_IF_STRING),
PCAP_BUF_SIZE);
if (host != NULL && *host != '\0') {
+ if (userinfo != NULL && *userinfo != '\0') {
+ pcap_strlcat(source, userinfo, PCAP_BUF_SIZE);
+ pcap_strlcat(source, "@", PCAP_BUF_SIZE);
+ }
+
if (strchr(host, ':') != NULL) {
/*
* The host name contains a colon, so it's
@@ -2129,16 +2138,18 @@ int
pcap_createsrcstr(char *source, int type, const char *host, const char *port,
const char *name, char *errbuf)
{
- return (pcap_createsrcstr_ex(source, type, host, port, name, 0, errbuf));
+ return (pcap_createsrcstr_ex(source, type, NULL, host, port, name, 0, errbuf));
}
int
-pcap_parsesrcstr_ex(const char *source, int *type, char *host, char *port,
- char *name, unsigned char *uses_ssl, char *errbuf)
+pcap_parsesrcstr_ex(const char *source, int *type, char *userinfo, char *host,
+ char *port, char *name, unsigned char *uses_ssl, char *errbuf)
{
char *scheme, *tmpuserinfo, *tmphost, *tmpport, *tmppath;
/* Initialization stuff */
+ if (userinfo)
+ *userinfo = '\0';
if (host)
*host = '\0';
if (port)
@@ -2187,13 +2198,10 @@ pcap_parsesrcstr_ex(const char *source, int *type, char *host, char *port,
* pcap_parse_source() has already handled the case of
* rpcap[s]://device
*/
- if (host && tmphost) {
- if (tmpuserinfo)
- snprintf(host, PCAP_BUF_SIZE, "%s@%s",
- tmpuserinfo, tmphost);
- else
- pcap_strlcpy(host, tmphost, PCAP_BUF_SIZE);
- }
+ if (userinfo && tmpuserinfo)
+ pcap_strlcpy(userinfo, tmpuserinfo, PCAP_BUF_SIZE);
+ if (host && tmphost)
+ pcap_strlcpy(host, tmphost, PCAP_BUF_SIZE);
if (port && tmpport)
pcap_strlcpy(port, tmpport, PCAP_BUF_SIZE);
if (name && tmppath)
@@ -2244,7 +2252,7 @@ int
pcap_parsesrcstr(const char *source, int *type, char *host, char *port,
char *name, char *errbuf)
{
- return (pcap_parsesrcstr_ex(source, type, host, port, name, NULL, errbuf));
+ return (pcap_parsesrcstr_ex(source, type, NULL, host, port, name, NULL, errbuf));
}
#endif
@@ -2849,15 +2857,27 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *er
goto fail;
return (p);
fail:
- if (status == PCAP_ERROR)
+ if (status == PCAP_ERROR) {
+ /*
+ * Another buffer is a bit cumbersome, but it avoids -Wformat-truncation.
+ */
+ char trimbuf[PCAP_ERRBUF_SIZE - 5]; /* 2 bytes shorter */
+
+ pcap_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf));
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %.*s", device,
- PCAP_ERRBUF_SIZE - 3, p->errbuf);
- else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
+ PCAP_ERRBUF_SIZE - 3, trimbuf);
+ } else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
status == PCAP_ERROR_PERM_DENIED ||
- status == PCAP_ERROR_PROMISC_PERM_DENIED)
+ status == PCAP_ERROR_PROMISC_PERM_DENIED) {
+ /*
+ * Idem.
+ */
+ char trimbuf[PCAP_ERRBUF_SIZE - 8]; /* 2 bytes shorter */
+
+ pcap_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf));
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%.*s)", device,
- pcap_statustostr(status), PCAP_ERRBUF_SIZE - 6, p->errbuf);
- else
+ pcap_statustostr(status), PCAP_ERRBUF_SIZE - 6, trimbuf);
+ } else
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
pcap_statustostr(status));
pcap_close(p);
@@ -3301,6 +3321,9 @@ static struct dlt_choice dlt_choices[] = {
DLT_CHOICE(Z_WAVE_SERIAL, "Z-Wave serial frames between host and chip"),
DLT_CHOICE(USB_2_0, "USB 2.0/1.1/1.0 as transmitted over the cable"),
DLT_CHOICE(ATSC_ALP, "ATSC Link-Layer Protocol packets"),
+ DLT_CHOICE(ETW, "Event Tracing for Windows messages"),
+ DLT_CHOICE(NETANALYZER_NG, "Hilscher netANALYZER NG pseudo-footer"),
+ DLT_CHOICE(ZBOSS_NCP, "ZBOSS NCP protocol with pseudo-header"),
DLT_CHOICE_SENTINEL
};
@@ -3350,7 +3373,7 @@ pcap_datalink_val_to_description_or_dlt(int dlt)
if (description != NULL) {
return description;
} else {
- (void)snprintf(unkbuf, sizeof(unkbuf), "DLT %u", dlt);
+ (void)snprintf(unkbuf, sizeof(unkbuf), "DLT %d", dlt);
return unkbuf;
}
}
@@ -3461,14 +3484,14 @@ pcap_fileno(pcap_t *p)
/*
* This is a bogus and now-deprecated API; we
* squelch the narrowing warning for the cast
- * from HANDLE to DWORD. If Windows programmmers
+ * from HANDLE to intptr_t. If Windows programmmers
* need to get at the HANDLE for a pcap_t, *if*
* there is one, they should request such a
* routine (and be prepared for it to return
* INVALID_HANDLE_VALUE).
*/
DIAG_OFF_NARROWING
- return ((int)(DWORD)p->handle);
+ return ((int)(intptr_t)p->handle);
DIAG_ON_NARROWING
} else
return (PCAP_ERROR);
@@ -3986,6 +4009,10 @@ pcap_breakloop_common(pcap_t *p)
void
pcap_cleanup_live_common(pcap_t *p)
{
+ if (p->opt.device != NULL) {
+ free(p->opt.device);
+ p->opt.device = NULL;
+ }
if (p->buffer != NULL) {
free(p->buffer);
p->buffer = NULL;
@@ -4064,8 +4091,6 @@ pcap_inject(pcap_t *p, const void *buf, size_t size)
void
pcap_close(pcap_t *p)
{
- if (p->opt.device != NULL)
- free(p->opt.device);
p->cleanup_op(p);
free(p);
}
@@ -4080,8 +4105,18 @@ pcap_close(pcap_t *p)
// C:\Windows\System32) to the relative path of the DLL, so that the DLL
// is always loaded from an absolute path (it's no longer possible to
// load modules from the application folder).
-// This solves the DLL Hijacking issue discovered in August 2010
-// http://blog.metasploit.com/2010/08/exploiting-dll-hijacking-flaws.html
+// This solves the DLL Hijacking issue discovered in August 2010:
+//
+// https://blog.rapid7.com/2010/08/23/exploiting-dll-hijacking-flaws/
+// https://blog.rapid7.com/2010/08/23/application-dll-load-hijacking/
+// (the purported Rapid7 blog post link in the first of those two links
+// is broken; the second of those links works.)
+//
+// If any links there are broken from all the content shuffling Rapid&
+// did, see archived versions of the posts at their original homes, at
+//
+// https://web.archive.org/web/20110122175058/http://blog.metasploit.com/2010/08/exploiting-dll-hijacking-flaws.html
+// https://web.archive.org/web/20100828112111/http://blog.rapid7.com/?p=5325
//
pcap_code_handle_t
pcap_load_code(const char *name)
diff --git a/pcap/bpf.h b/pcap/bpf.h
index 95ea2abc..f8132582 100644
--- a/pcap/bpf.h
+++ b/pcap/bpf.h
@@ -79,7 +79,15 @@
#if !defined(_NET_BPF_H_) && !defined(_NET_BPF_H_INCLUDED) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h)
#define lib_pcap_bpf_h
+/* u_char, u_short and u_int */
+#if defined(_WIN32)
+ #include <winsock2.h>
+#elif defined(HAVE_SYS_TYPES_H)
+ #include <sys/types.h>
+#endif
+
#include <pcap/funcattrs.h>
+#include <pcap/dlt.h>
#ifdef __cplusplus
extern "C" {
@@ -117,10 +125,6 @@ struct bpf_program {
struct bpf_insn *bf_insns;
};
-#include <pcap/dlt.h>
-
-#ifndef __LINUX_FILTER_H__
-
/*
* The instruction encodings.
*
@@ -241,8 +245,6 @@ struct bpf_program {
/* 0xf0 reserved */
/* 0xf8 reserved */
-#endif /* __LINUX_FILTER_H__ */
-
/*
* The instruction data structure.
*/
@@ -253,19 +255,35 @@ struct bpf_insn {
bpf_u_int32 k;
};
-#ifndef __LINUX_FILTER_H__
-
/*
* Macros for insn array initializers.
+ *
+ * In case somebody's included <linux/filter.h>, or something else that
+ * gives the kernel's definitions of BPF statements, get rid of its
+ * definitions, so we can supply ours instead. If some kernel's
+ * definitions aren't *binary-compatible* with what BPF has had
+ * since it first sprung from the brows of Van Jacobson and Steve
+ * McCanne, that kernel should be fixed.
*/
+#ifdef BPF_STMT
+#undef BPF_STMT
+#endif
#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
+#ifdef BPF_JUMP
+#undef BPF_JUMP
+#endif
#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
-#endif /* __LINUX_FILTER_H__ */
-
+PCAP_AVAILABLE_0_4
PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
+
+PCAP_AVAILABLE_0_6
PCAP_API int bpf_validate(const struct bpf_insn *f, int len);
+
+PCAP_AVAILABLE_0_4
PCAP_API char *bpf_image(const struct bpf_insn *, int);
+
+PCAP_AVAILABLE_0_6
PCAP_API void bpf_dump(const struct bpf_program *, int);
/*
diff --git a/pcap/can_socketcan.h b/pcap/can_socketcan.h
index 332d9ff5..0cb3584a 100644
--- a/pcap/can_socketcan.h
+++ b/pcap/can_socketcan.h
@@ -48,9 +48,14 @@
typedef struct {
uint32_t can_id;
uint8_t payload_length;
- uint8_t pad;
+ uint8_t fd_flags;
uint8_t reserved1;
uint8_t reserved2;
} pcap_can_socketcan_hdr;
+/* Bits in the fd_flags field */
+#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
+#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
+#define CANFD_FDF 0x04 /* mark CAN FD for dual use of CAN format */
+
#endif
diff --git a/pcap/compiler-tests.h b/pcap/compiler-tests.h
index a69c2b09..2d98a707 100644
--- a/pcap/compiler-tests.h
+++ b/pcap/compiler-tests.h
@@ -80,9 +80,11 @@
*/
#if ! defined(__GNUC__)
-#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
+ /* Not GCC and not "just like GCC" */
+ #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
#else
-#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \
+ /* GCC or "just like GCC" */
+ #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \
(__GNUC__ > (major) || \
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
#endif
@@ -92,9 +94,11 @@
*/
#if !defined(__clang__)
-#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
+ /* Not Clang */
+ #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
#else
-#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \
+ /* Clang */
+ #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \
(__clang_major__ > (major) || \
(__clang_major__ == (major) && __clang_minor__ >= (minor)))
#endif
@@ -118,13 +122,15 @@
*/
#if ! defined(__SUNPRO_C)
-#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
+ /* Not Sun/Oracle C */
+ #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
#else
-#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
+ /* Sun/Oracle C */
+ #define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
(((minor) >= 10) ? \
(((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
(((major) << 8) | ((minor) << 4)))
-#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \
+ #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \
(__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor)))
#endif
@@ -133,13 +139,31 @@
*
* The version number in __xlC__ has the major version in the
* upper 8 bits and the minor version in the lower 8 bits.
+ * On AIX __xlC__ is always defined, __ibmxl__ becomes defined in XL C 16.1.
+ * On Linux since XL C 13.1.6 __xlC__ is not defined by default anymore, but
+ * __ibmxl__ is defined since at least XL C 13.1.1.
*/
-#if ! defined(__xlC__)
-#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
+#if ! defined(__xlC__) && ! defined(__ibmxl__)
+ /* Not XL C */
+ #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
#else
-#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
+ /* XL C */
+ #if defined(__ibmxl__)
+ /*
+ * Later Linux version of XL C; use __ibmxl_version__ to test
+ * the version.
+ */
+ #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
+ (__ibmxl_version__ > (major) || \
+ (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor)))
+ #else /* __ibmxl__ */
+ /*
+ * __ibmxl__ not defined; use __xlC__ to test the version.
+ */
+ #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
(__xlC__ >= (((major) << 8) | (minor)))
+ #endif /* __ibmxl__ */
#endif
/*
@@ -154,9 +178,11 @@
*/
#if ! defined(__HP_aCC)
-#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
+ /* Not HP C */
+ #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
#else
-#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \
+ /* HP C */
+ #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \
(__HP_aCC >= ((major)*10000 + (minor)*100))
#endif
diff --git a/pcap/dlt.h b/pcap/dlt.h
index eaba34f3..1d255d60 100644
--- a/pcap/dlt.h
+++ b/pcap/dlt.h
@@ -105,6 +105,67 @@
#endif
/*
+ * NetBSD uses 15 for HIPPI.
+ *
+ * From a quick look at sys/net/if_hippi.h and sys/net/if_hippisubr.c
+ * in an older version of NetBSD , the header appears to be:
+ *
+ * a 1-byte ULP field (ULP-id)?
+ *
+ * a 1-byte flags field;
+ *
+ * a 2-byte "offsets" field;
+ *
+ * a 4-byte "D2 length" field (D2_Size?);
+ *
+ * a 4-byte "destination switch" field (or a 1-byte field
+ * containing the Forwarding Class, Double_Wide, and Message_Type
+ * sub fields, followed by a 3-byte Destination_Switch_Address
+ * field?, HIPPI-LE 3.4-style?);
+ *
+ * a 4-byte "source switch" field (or a 1-byte field containing the
+ * Destination_Address_type and Source_Address_Type fields, followed
+ * by a 3-byte Source_Switch_Address field, HIPPI-LE 3.4-style?);
+ *
+ * a 2-byte reserved field;
+ *
+ * a 6-byte destination address field;
+ *
+ * a 2-byte "local admin" field;
+ *
+ * a 6-byte source address field;
+ *
+ * followed by an 802.2 LLC header.
+ *
+ * This looks somewhat like something derived from the HIPPI-FP 4.4
+ * Header_Area, followed an HIPPI-FP 4.4 D1_Area containing a D1 data set
+ * with the header in HIPPI-LE 3.4 (ANSI X3.218-1993), followed by an
+ * HIPPI-FP 4.4 D2_Area (with no Offset) containing the 802.2 LLC header
+ * and payload? Or does the "offsets" field contain the D2_Offset,
+ * with that many bytes of offset before the payload?
+ *
+ * See http://wotug.org/parallel/standards/hippi/ for an archive of
+ * HIPPI specifications.
+ *
+ * RFC 2067 imposes some additional restrictions. It says that the
+ * Offset is always zero
+ *
+ * HIPPI is long-gone, and the source files found in an older version
+ * of NetBSD don't appear to be in the main CVS branch, so we may never
+ * see a capture with this link-layer type.
+ */
+#if defined(__NetBSD__)
+#define DLT_HIPPI 15 /* HIPPI */
+#endif
+
+/*
+ * NetBSD uses 16 for DLT_HDLC; see below.
+ * BSD/OS uses it for PPP; see above.
+ * As far as I know, no other OS uses it for anything; don't use it
+ * for anything else.
+ */
+
+/*
* 17 was used for DLT_PFLOG in OpenBSD; it no longer is.
*
* It was DLT_LANE8023 in SuSE 6.3, so we defined LINKTYPE_PFLOG
@@ -219,7 +280,8 @@
* that the AF_ type in the link-layer header is in network byte order.
*
* DLT_LOOP is 12 in OpenBSD, but that's DLT_RAW in other OSes, so
- * we don't use 12 for it in OSes other than OpenBSD.
+ * we don't use 12 for it in OSes other than OpenBSD; instead, we
+ * use the same value as LINKTYPE_LOOP.
*/
#ifdef __OpenBSD__
#define DLT_LOOP 12
@@ -230,7 +292,7 @@
/*
* Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
* DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other
- * than OpenBSD.
+ * than OpenBSD; instead, we use the same value as LINKTYPE_ENC.
*/
#ifdef __OpenBSD__
#define DLT_ENC 13
@@ -239,13 +301,23 @@
#endif
/*
- * Values between 110 and 112 are reserved for use in capture file headers
+ * Values 110 and 111 are reserved for use in capture file headers
* as link-layer types corresponding to DLT_ types that might differ
* between platforms; don't use those values for new DLT_ types
* other than the corresponding DLT_ types.
*/
/*
+ * NetBSD uses 16 for (Cisco) "HDLC framing". For other platforms,
+ * we define it to have the same value as LINKTYPE_NETBSD_HDLC.
+ */
+#if defined(__NetBSD__)
+#define DLT_HDLC 16 /* Cisco HDLC */
+#else
+#define DLT_HDLC 112
+#endif
+
+/*
* Linux cooked sockets.
*/
#define DLT_LINUX_SLL 113
@@ -1481,6 +1553,32 @@
#define DLT_ATSC_ALP 289
/*
+ * Event Tracing for Windows messages.
+ */
+#define DLT_ETW 290
+
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH
+ * netANALYZER NG hardware and software.
+ *
+ * The specification for this footer can be found at:
+ * https://kb.hilscher.com/x/brDJBw
+ *
+ * Requested by Jan Adam <jadam@hilscher.com>
+ */
+#define DLT_NETANALYZER_NG 291
+
+/*
+ * Serial NCP (Network Co-Processor) protocol for Zigbee stack ZBOSS
+ * by DSR.
+ * ZBOSS NCP protocol description: https://cloud.dsr-corporation.com/index.php/s/3isHzaNTTgtJebn
+ * Header in pcap file: https://cloud.dsr-corporation.com/index.php/s/fiqSDorAAAZrsYB
+ *
+ * Requested by Eugene Exarevsky <eugene.exarevsky@dsr-corporation.com>
+ */
+#define DLT_ZBOSS_NCP 292
+
+/*
* In case the code that includes this file (directly or indirectly)
* has also included OS files that happen to define DLT_MATCHING_MAX,
* with a different value (perhaps because that OS hasn't picked up
@@ -1490,25 +1588,6 @@
#ifdef DLT_MATCHING_MAX
#undef DLT_MATCHING_MAX
#endif
-#define DLT_MATCHING_MAX 289 /* highest value in the "matching" range */
-
-/*
- * DLT and savefile link type values are split into a class and
- * a member of that class. A class value of 0 indicates a regular
- * DLT_/LINKTYPE_ value.
- */
-#define DLT_CLASS(x) ((x) & 0x03ff0000)
-
-/*
- * NetBSD-specific generic "raw" link type. The class value indicates
- * that this is the generic raw type, and the lower 16 bits are the
- * address family we're dealing with. Those values are NetBSD-specific;
- * do not assume that they correspond to AF_ values for your operating
- * system.
- */
-#define DLT_CLASS_NETBSD_RAWAF 0x02240000
-#define DLT_NETBSD_RAWAF(af) (DLT_CLASS_NETBSD_RAWAF | (af))
-#define DLT_NETBSD_RAWAF_AF(x) ((x) & 0x0000ffff)
-#define DLT_IS_NETBSD_RAWAF(x) (DLT_CLASS(x) == DLT_CLASS_NETBSD_RAWAF)
+#define DLT_MATCHING_MAX 292 /* highest value in the "matching" range */
#endif /* !defined(lib_pcap_dlt_h) */
diff --git a/pcap/funcattrs.h b/pcap/funcattrs.h
index 0d1a4405..5dbc428c 100644
--- a/pcap/funcattrs.h
+++ b/pcap/funcattrs.h
@@ -118,14 +118,14 @@
#if PCAP_IS_AT_LEAST_GNUC_VERSION(3,4) \
|| PCAP_IS_AT_LEAST_XL_C_VERSION(12,0)
/*
- * GCC 3.4 or later, or some compiler asserting compatibility with
- * GCC 3.4 or later, or XL C 13.0 or later, so we have
+ * GCC 3.4 and later, or some compiler asserting compatibility with
+ * GCC 3.4 and later, or XL C 13.0 and later, so we have
* __attribute__((visibility()).
*/
#define PCAP_API_DEF __attribute__((visibility("default")))
#elif PCAP_IS_AT_LEAST_SUNC_VERSION(5,5)
/*
- * Sun C 5.5 or later, so we have __global.
+ * Sun C 5.5 and later, so we have __global.
* (Sun C 5.9 and later also have __attribute__((visibility()),
* but there's no reason to prefer it with Sun C.)
*/
@@ -147,6 +147,88 @@
#define PCAP_API PCAP_API_DEF extern
/*
+ * Definitions to 1) indicate what version of libpcap first had a given
+ * API and 2) allow upstream providers whose build environments allow
+ * APIs to be designated as "first available in this release" to do so
+ * by appropriately defining them.
+ *
+ * Yes, that's you, Apple. :-) Please define PCAP_AVAILABLE_MACOS()
+ * as necessary to make various APIs "weak exports" to make it easier
+ * for software that's distributed in binary form and that uses libpcap
+ * to run on multiple macOS versions and use new APIs when available.
+ * (Yes, such third-party software exists - Wireshark provides binary
+ * packages for macOS, for example. tcpdump doesn't count, as that's
+ * provided by Apple, so each release can come with a version compiled
+ * to use the APIs present in that release.)
+ *
+ * The non-macOS versioning is based on
+ *
+ * https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
+ *
+ * If there are any corrections, please submit it upstream to the
+ * libpcap maintainers, preferably as a pull request on
+ *
+ * https://github.com/the-tcpdump-group/libpcap
+ *
+ * We don't define it ourselves because, if you're building and
+ * installing libpcap on macOS yourself, the APIs will be available
+ * no matter what OS version you're installing it on.
+ *
+ * For other platforms, we don't define them, leaving it up to
+ * others to do so based on their OS versions, if appropriate.
+ *
+ * We start with libpcap 0.4, as that was the last LBL release, and
+ * I've never seen earlier releases.
+ */
+#ifdef __APPLE__
+#include <Availability.h>
+/*
+ * When building as part of macOS, define this as __API_AVAILABLE(__VA_ARGS__).
+ *
+ * XXX - if there's some #define to indicate that this is being built
+ * as part of the macOS build process, we could make that Just Work.
+ */
+#define PCAP_AVAILABLE(...)
+#define PCAP_AVAILABLE_0_4 PCAP_AVAILABLE(macos(10.0)) /* Did any version of Mac OS X ship with this? */
+#define PCAP_AVAILABLE_0_5 PCAP_AVAILABLE(macos(10.0)) /* Did any version of Mac OS X ship with this? */
+#define PCAP_AVAILABLE_0_6 PCAP_AVAILABLE(macos(10.1))
+#define PCAP_AVAILABLE_0_7 PCAP_AVAILABLE(macos(10.4))
+#define PCAP_AVAILABLE_0_8 PCAP_AVAILABLE(macos(10.4))
+#define PCAP_AVAILABLE_0_9 PCAP_AVAILABLE(macos(10.5), ios(1.0))
+#define PCAP_AVAILABLE_1_0 PCAP_AVAILABLE(macos(10.6), ios(4.0))
+/* #define PCAP_AVAILABLE_1_1 no routines added to the API */
+#define PCAP_AVAILABLE_1_2 PCAP_AVAILABLE(macos(10.9), ios(6.0))
+/* #define PCAP_AVAILABLE_1_3 no routines added to the API */
+/* #define PCAP_AVAILABLE_1_4 no routines added to the API */
+#define PCAP_AVAILABLE_1_5 PCAP_AVAILABLE(macos(10.10), ios(7.0), watchos(1.0))
+/* #define PCAP_AVAILABLE_1_6 no routines added to the API */
+#define PCAP_AVAILABLE_1_7 PCAP_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
+#define PCAP_AVAILABLE_1_8 PCAP_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) /* only Windows adds routines to the API; XXX - what version first had it? */
+#define PCAP_AVAILABLE_1_9 PCAP_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
+#define PCAP_AVAILABLE_1_10 /* not in macOS yet */
+#define PCAP_AVAILABLE_1_11 /* not released yet, so not in macOS yet */
+#else /* __APPLE__ */
+#define PCAP_AVAILABLE_0_4
+#define PCAP_AVAILABLE_0_5
+#define PCAP_AVAILABLE_0_6
+#define PCAP_AVAILABLE_0_7
+#define PCAP_AVAILABLE_0_8
+#define PCAP_AVAILABLE_0_9
+#define PCAP_AVAILABLE_1_0
+/* #define PCAP_AVAILABLE_1_1 no routines added to the API */
+#define PCAP_AVAILABLE_1_2
+/* #define PCAP_AVAILABLE_1_3 no routines added to the API */
+/* #define PCAP_AVAILABLE_1_4 no routines added to the API */
+#define PCAP_AVAILABLE_1_5
+/* #define PCAP_AVAILABLE_1_6 no routines added to the API */
+#define PCAP_AVAILABLE_1_7
+#define PCAP_AVAILABLE_1_8
+#define PCAP_AVAILABLE_1_9
+#define PCAP_AVAILABLE_1_10
+#define PCAP_AVAILABLE_1_11
+#endif /* __APPLE__ */
+
+/*
* PCAP_NORETURN, before a function declaration, means "this function
* never returns". (It must go before the function declaration, e.g.
* "extern PCAP_NORETURN func(...)" rather than after the function
@@ -164,11 +246,11 @@
|| PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
|| PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
/*
- * Compiler with support for __attribute((noreturn)), or GCC 2.5 or
- * later, or some compiler asserting compatibility with GCC 2.5 or
- * later, or Solaris Studio 12 (Sun C 5.9) or later, or IBM XL C 10.1
- * or later (do any earlier versions of XL C support this?), or HP aCC
- * A.06.10 or later.
+ * Compiler with support for __attribute((noreturn)), or GCC 2.5 and
+ * later, or some compiler asserting compatibility with GCC 2.5 and
+ * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
+ * and later (do any earlier versions of XL C support this?), or HP aCC
+ * A.06.10 and later.
*/
#define PCAP_NORETURN __attribute((noreturn))
#define PCAP_NORETURN_DEF __attribute((noreturn))
@@ -194,8 +276,8 @@
|| PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
|| PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
/*
- * Compiler with support for it, or GCC 2.3 or later, or some compiler
- * asserting compatibility with GCC 2.3 or later, or IBM XL C 10.1
+ * Compiler with support for it, or GCC 2.3 and later, or some compiler
+ * asserting compatibility with GCC 2.3 and later, or IBM XL C 10.1
* and later (do any earlier versions of XL C support this?),
* or HP aCC A.06.10 and later.
*/
@@ -218,7 +300,7 @@
|| PCAP_IS_AT_LEAST_SUNC_VERSION(5,13)
/*
* Compiler that supports __has_attribute and __attribute__((deprecated)),
- * or GCC 4.5 or later, or Sun/Oracle C 12.4 (Sun C 5.13) or later.
+ * or GCC 4.5 and later, or Sun/Oracle C 12.4 (Sun C 5.13) and later.
*
* Those support __attribute__((deprecated(msg))) (we assume, perhaps
* incorrectly, that anything that supports __has_attribute() is
@@ -236,7 +318,7 @@
#elif defined(_MSC_VER) && !defined(BUILDING_PCAP)
/*
* MSVC, and we're not building libpcap itself; it's VS 2015
- * or later, so we have the deprecated pragma.
+ * and later, so we have the deprecated pragma.
*
* If we *are* building libpcap, we don't want this, as it'll warn
* us even if we *define* the function.
diff --git a/pcap/pcap-inttypes.h b/pcap/pcap-inttypes.h
index 1cfa0bfc..8c7b4f65 100644
--- a/pcap/pcap-inttypes.h
+++ b/pcap/pcap-inttypes.h
@@ -32,8 +32,8 @@
#define pcap_pcap_inttypes_h
/*
- * If we're compiling with Visual Studio, make sure we have at least
- * VS 2015 or later, so we have sufficient C99 support.
+ * If we're compiling with Visual Studio, make sure the C99 integer
+ * types are defined, by hook or by crook.
*
* XXX - verify that we have at least C99 support on UN*Xes?
*
@@ -42,39 +42,60 @@
*/
#if defined(_MSC_VER)
/*
- * Compiler is MSVC. Make sure we have VS 2015 or later.
+ * Compiler is MSVC.
*/
- #if _MSC_VER < 1900
- #error "Building libpcap requires VS 2015 or later"
+ #if _MSC_VER >= 1800
+ /*
+ * VS 2013 or newer; we have <inttypes.h>.
+ */
+ #include <inttypes.h>
+ #else
+ /*
+ * Earlier VS; we have to define this stuff ourselves.
+ * We don't support building libpcap with earlier versions of VS,
+ * but SDKs for Npcap have to support building applications using
+ * earlier versions of VS, so we work around this by defining
+ * those types ourselves, as some files use them.
+ */
+ typedef unsigned char uint8_t;
+ typedef signed char int8_t;
+ typedef unsigned short uint16_t;
+ typedef signed short int16_t;
+ typedef unsigned int uint32_t;
+ typedef signed int int32_t;
+ #ifdef _MSC_EXTENSIONS
+ typedef unsigned _int64 uint64_t;
+ typedef _int64 int64_t;
+ #else /* _MSC_EXTENSIONS */
+ typedef unsigned long long uint64_t;
+ typedef long long int64_t;
+ #endif
#endif
-#endif
-
-/*
- * Include <inttypes.h> to get the integer types and PRi[doux]64 values
- * defined.
- *
- * If the compiler is MSVC, we require VS 2015 or newer, so we
- * have <inttypes.h> - and support for %zu in the formatted
- * printing functions.
- *
- * If the compiler is MinGW, we assume we have <inttypes.h> - and
- * support for %zu in the formatted printing functions.
- *
- * If the target is UN*X, we assume we have a C99-or-later development
- * environment, and thus have <inttypes.h> - and support for %zu in
- * the formatted printing functions.
- *
- * If the target is MS-DOS, we assume we have <inttypes.h> - and support
- * for %zu in the formatted printing functions.
- *
- * I.e., assume we have <inttypes.h> and that it suffices.
- */
+#else /* defined(_MSC_VER) */
+ /*
+ * Not Visual Studio.
+ * Include <inttypes.h> to get the integer types and PRi[doux]64 values
+ * defined.
+ *
+ * If the compiler is MinGW, we assume we have <inttypes.h> - and
+ * support for %zu in the formatted printing functions.
+ *
+ * If the target is UN*X, we assume we have a C99-or-later development
+ * environment, and thus have <inttypes.h> - and support for %zu in
+ * the formatted printing functions.
+ *
+ * If the target is MS-DOS, we assume we have <inttypes.h> - and support
+ * for %zu in the formatted printing functions.
+ *
+ * I.e., assume we have <inttypes.h> and that it suffices.
+ */
-/*
- * XXX - somehow make sure we have enough C99 support with other
- * compilers and support libraries?
- */
+ /*
+ * XXX - somehow make sure we have enough C99 support with other
+ * compilers and support libraries?
+ */
-#include <inttypes.h>
+ #include <inttypes.h>
+#endif /* defined(_MSC_VER) */
#endif /* pcap/pcap-inttypes.h */
diff --git a/pcap/pcap.h b/pcap/pcap.h
index 6c65dc30..13ebfdbd 100644
--- a/pcap/pcap.h
+++ b/pcap/pcap.h
@@ -215,11 +215,59 @@ struct pcap_file_header {
};
/*
- * Macros for the value returned by pcap_datalink_ext().
- *
- * If LT_FCS_LENGTH_PRESENT(x) is true, the LT_FCS_LENGTH(x) macro
- * gives the FCS length of packets in the capture.
+ * Subfields of the field containing the link-layer header type.
+ *
+ * Link-layer header types are assigned for both pcap and
+ * pcapng, and the same value must work with both. In pcapng,
+ * the link-layer header type field in an Interface Description
+ * Block is 16 bits, so only the bottommost 16 bits of the
+ * link-layer header type in a pcap file can be used for the
+ * header type value.
+ *
+ * In libpcap, the upper 16 bits, from the top down, are divided into:
+ *
+ * A 4-bit "FCS length" field, to allow the FCS length to
+ * be specified, just as it can be specified in the if_fcslen
+ * field of the pcapng IDB. The field is in units of 16 bits,
+ * i.e. 1 means 16 bits of FCS, 2 means 32 bits of FCS, etc..
+ *
+ * A reserved bit, which must be zero.
+ *
+ * An "FCS length present" flag; if 0, the "FCS length" field
+ * should be ignored, and if 1, the "FCS length" field should
+ * be used.
+ *
+ * 10 reserved bits, which must be zero. They were originally
+ * intended to be used as a "class" field, allowing additional
+ * classes of link-layer types to be defined, with a class value
+ * of 0 indicating that the link-layer type is a LINKTYPE_ value.
+ * A value of 0x224 was, at one point, used by NetBSD to define
+ * "raw" packet types, with the lower 16 bits containing a
+ * NetBSD AF_ value; see
+ *
+ * https://marc.info/?l=tcpdump-workers&m=98296750229149&w=2
+ *
+ * It's unknown whether those were ever used in capture files,
+ * or if the intent was just to use it as a link-layer type
+ * for BPF programs; NetBSD's libpcap used to support them in
+ * the BPF code generator, but it no longer does so. If it
+ * was ever used in capture files, or if classes other than
+ * "LINKTYPE_ value" are ever useful in capture files, we could
+ * re-enable this, and use the reserved 16 bits following the
+ * link-layer type in pcapng files to hold the class information
+ * there. (Note, BTW, that LINKTYPE_RAW/DLT_RAW is now being
+ * interpreted by libpcap, tcpdump, and Wireshark as "raw IP",
+ * including both IPv4 and IPv6, with the version number in the
+ * header being checked to see which it is, not just "raw IPv4";
+ * there are LINKTYPE_IPV4/DLT_IPV4 and LINKTYPE_IPV6/DLT_IPV6
+ * values if "these are IPv{4,6} and only IPv{4,6} packets"
+ * types are needed.)
+ *
+ * Or we might be able to use it for other purposes.
*/
+#define LT_LINKTYPE(x) ((x) & 0x0000FFFF)
+#define LT_LINKTYPE_EXT(x) ((x) & 0xFFFF0000)
+#define LT_RESERVED1(x) ((x) & 0x03FF0000)
#define LT_FCS_LENGTH_PRESENT(x) ((x) & 0x04000000)
#define LT_FCS_LENGTH(x) (((x) & 0xF0000000) >> 28)
#define LT_FCS_DATALINK_EXT(x) ((((x) & 0xF) << 28) | 0x04000000)
@@ -382,6 +430,7 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
#define PCAP_CHAR_ENC_LOCAL 0x00000000U /* strings are in the local character encoding */
#define PCAP_CHAR_ENC_UTF_8 0x00000001U /* strings are in UTF-8 */
+PCAP_AVAILABLE_1_10
PCAP_API int pcap_init(unsigned int, char *);
/*
@@ -389,31 +438,66 @@ PCAP_API int pcap_init(unsigned int, char *);
* thread-safe, can behave weirdly with WinPcap). Callers
* should use pcap_findalldevs() and use the first device.
*/
+PCAP_AVAILABLE_0_4
PCAP_API char *pcap_lookupdev(char *)
PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device");
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
+PCAP_AVAILABLE_1_0
PCAP_API pcap_t *pcap_create(const char *, char *);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_set_snaplen(pcap_t *, int);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_set_promisc(pcap_t *, int);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_can_set_rfmon(pcap_t *);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_set_rfmon(pcap_t *, int);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_set_timeout(pcap_t *, int);
+
+PCAP_AVAILABLE_1_2
PCAP_API int pcap_set_tstamp_type(pcap_t *, int);
+
+PCAP_AVAILABLE_1_5
PCAP_API int pcap_set_immediate_mode(pcap_t *, int);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_set_buffer_size(pcap_t *, int);
+
+PCAP_AVAILABLE_1_5
PCAP_API int pcap_set_tstamp_precision(pcap_t *, int);
+
+PCAP_AVAILABLE_1_5
PCAP_API int pcap_get_tstamp_precision(pcap_t *);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_activate(pcap_t *);
+PCAP_AVAILABLE_1_2
PCAP_API int pcap_list_tstamp_types(pcap_t *, int **);
+
+PCAP_AVAILABLE_1_2
PCAP_API void pcap_free_tstamp_types(int *);
+
+PCAP_AVAILABLE_1_2
PCAP_API int pcap_tstamp_type_name_to_val(const char *);
+
+PCAP_AVAILABLE_1_2
PCAP_API const char *pcap_tstamp_type_val_to_name(int);
+
+PCAP_AVAILABLE_1_2
PCAP_API const char *pcap_tstamp_type_val_to_description(int);
#ifdef __linux__
+PCAP_AVAILABLE_1_9
PCAP_API int pcap_set_protocol_linux(pcap_t *, int);
#endif
@@ -475,13 +559,25 @@ PCAP_API int pcap_set_protocol_linux(pcap_t *, int);
#define PCAP_TSTAMP_PRECISION_MICRO 0 /* use timestamps with microsecond precision, default */
#define PCAP_TSTAMP_PRECISION_NANO 1 /* use timestamps with nanosecond precision */
+PCAP_AVAILABLE_0_4
PCAP_API pcap_t *pcap_open_live(const char *, int, int, int, char *);
+
+PCAP_AVAILABLE_0_6
PCAP_API pcap_t *pcap_open_dead(int, int);
+
+PCAP_AVAILABLE_1_5
PCAP_API pcap_t *pcap_open_dead_with_tstamp_precision(int, int, u_int);
+
+PCAP_AVAILABLE_1_5
PCAP_API pcap_t *pcap_open_offline_with_tstamp_precision(const char *, u_int, char *);
+
+PCAP_AVAILABLE_0_4
PCAP_API pcap_t *pcap_open_offline(const char *, char *);
+
#ifdef _WIN32
+ PCAP_AVAILABLE_1_5
PCAP_API pcap_t *pcap_hopen_offline_with_tstamp_precision(intptr_t, u_int, char *);
+
PCAP_API pcap_t *pcap_hopen_offline(intptr_t, char *);
/*
* If we're building libpcap, these are internal routines in savefile.c,
@@ -503,51 +599,126 @@ PCAP_API pcap_t *pcap_open_offline(const char *, char *);
pcap_hopen_offline(_get_osfhandle(_fileno(f)), b)
#endif
#else /*_WIN32*/
+ PCAP_AVAILABLE_1_5
PCAP_API pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *, u_int, char *);
+
+ PCAP_AVAILABLE_0_9
PCAP_API pcap_t *pcap_fopen_offline(FILE *, char *);
#endif /*_WIN32*/
+PCAP_AVAILABLE_0_4
PCAP_API void pcap_close(pcap_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
+
+PCAP_AVAILABLE_0_4
PCAP_API const u_char *pcap_next(pcap_t *, struct pcap_pkthdr *);
+
+PCAP_AVAILABLE_0_8
PCAP_API int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
+
+PCAP_AVAILABLE_0_8
PCAP_API void pcap_breakloop(pcap_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_stats(pcap_t *, struct pcap_stat *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_setfilter(pcap_t *, struct bpf_program *);
+
+PCAP_AVAILABLE_0_9
PCAP_API int pcap_setdirection(pcap_t *, pcap_direction_t);
+
+PCAP_AVAILABLE_0_7
PCAP_API int pcap_getnonblock(pcap_t *, char *);
+
+PCAP_AVAILABLE_0_7
PCAP_API int pcap_setnonblock(pcap_t *, int, char *);
+
+PCAP_AVAILABLE_0_9
PCAP_API int pcap_inject(pcap_t *, const void *, size_t);
+
+PCAP_AVAILABLE_0_8
PCAP_API int pcap_sendpacket(pcap_t *, const u_char *, int);
+
+PCAP_AVAILABLE_1_0
PCAP_API const char *pcap_statustostr(int);
+
+PCAP_AVAILABLE_0_4
PCAP_API const char *pcap_strerror(int);
+
+PCAP_AVAILABLE_0_4
PCAP_API char *pcap_geterr(pcap_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API void pcap_perror(pcap_t *, const char *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_compile(pcap_t *, struct bpf_program *, const char *, int,
bpf_u_int32);
+
+PCAP_AVAILABLE_0_5
PCAP_API int pcap_compile_nopcap(int, int, struct bpf_program *,
const char *, int, bpf_u_int32);
+
+/* XXX - this took two arguments in 0.4 and 0.5 */
+PCAP_AVAILABLE_0_6
PCAP_API void pcap_freecode(struct bpf_program *);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_offline_filter(const struct bpf_program *,
const struct pcap_pkthdr *, const u_char *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_datalink(pcap_t *);
+
+PCAP_AVAILABLE_1_0
PCAP_API int pcap_datalink_ext(pcap_t *);
+
+PCAP_AVAILABLE_0_8
PCAP_API int pcap_list_datalinks(pcap_t *, int **);
+
+PCAP_AVAILABLE_0_8
PCAP_API int pcap_set_datalink(pcap_t *, int);
+
+PCAP_AVAILABLE_0_8
PCAP_API void pcap_free_datalinks(int *);
+
+PCAP_AVAILABLE_0_8
PCAP_API int pcap_datalink_name_to_val(const char *);
+
+PCAP_AVAILABLE_0_8
PCAP_API const char *pcap_datalink_val_to_name(int);
+
+PCAP_AVAILABLE_0_8
PCAP_API const char *pcap_datalink_val_to_description(int);
+
+PCAP_AVAILABLE_1_10
PCAP_API const char *pcap_datalink_val_to_description_or_dlt(int);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_snapshot(pcap_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_is_swapped(pcap_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_major_version(pcap_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_minor_version(pcap_t *);
+
+PCAP_AVAILABLE_1_9
PCAP_API int pcap_bufsize(pcap_t *);
/* XXX */
+PCAP_AVAILABLE_0_4
PCAP_API FILE *pcap_file(pcap_t *);
+
#ifdef _WIN32
/*
* This probably shouldn't have been kept in WinPcap; most if not all
@@ -556,9 +727,11 @@ PCAP_API FILE *pcap_file(pcap_t *);
* with a pcap_t (there's no guarantee that there is one), we can add
* a Windows-only pcap_handle() API that returns the HANDLE.
*/
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_fileno(pcap_t *)
-PCAP_DEPRECATED(pcap_fileno, "use 'pcap_handle'");
+PCAP_DEPRECATED(pcap_fileno, "request a 'pcap_handle' that returns a HANDLE if you need it");
#else /* _WIN32 */
+PCAP_AVAILABLE_0_4
PCAP_API int pcap_fileno(pcap_t *);
#endif /* _WIN32 */
@@ -566,9 +739,13 @@ PCAP_API int pcap_fileno(pcap_t *);
PCAP_API int pcap_wsockinit(void);
#endif
+PCAP_AVAILABLE_0_4
PCAP_API pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
+
#ifdef _WIN32
+ PCAP_AVAILABLE_0_9
PCAP_API pcap_dumper_t *pcap_dump_hopen(pcap_t *, intptr_t);
+
/*
* If we're building libpcap, this is an internal routine in sf-pcap.c, so
* we must not define it as a macro.
@@ -587,17 +764,35 @@ PCAP_API pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
pcap_dump_hopen(p, _get_osfhandle(_fileno(f)))
#endif
#else /*_WIN32*/
+ PCAP_AVAILABLE_0_9
PCAP_API pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
#endif /*_WIN32*/
+
+PCAP_AVAILABLE_1_7
PCAP_API pcap_dumper_t *pcap_dump_open_append(pcap_t *, const char *);
+
+PCAP_AVAILABLE_0_8
PCAP_API FILE *pcap_dump_file(pcap_dumper_t *);
+
+PCAP_AVAILABLE_0_9
PCAP_API long pcap_dump_ftell(pcap_dumper_t *);
+
+PCAP_AVAILABLE_1_9
PCAP_API int64_t pcap_dump_ftell64(pcap_dumper_t *);
+
+PCAP_AVAILABLE_0_8
PCAP_API int pcap_dump_flush(pcap_dumper_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API void pcap_dump_close(pcap_dumper_t *);
+
+PCAP_AVAILABLE_0_4
PCAP_API void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
+PCAP_AVAILABLE_0_7
PCAP_API int pcap_findalldevs(pcap_if_t **, char *);
+
+PCAP_AVAILABLE_0_7
PCAP_API void pcap_freealldevs(pcap_if_t *);
/*
@@ -615,6 +810,7 @@ PCAP_API void pcap_freealldevs(pcap_if_t *);
*
* On Windows, the string is constructed at run time.
*/
+PCAP_AVAILABLE_0_8
PCAP_API const char *pcap_lib_version(void);
#if defined(_WIN32)
@@ -650,7 +846,10 @@ PCAP_API const char *pcap_lib_version(void);
PCAP_API HANDLE pcap_getevent(pcap_t *p);
+ PCAP_AVAILABLE_1_8
PCAP_API int pcap_oid_get_request(pcap_t *, bpf_u_int32, void *, size_t *);
+
+ PCAP_AVAILABLE_1_8
PCAP_API int pcap_oid_set_request(pcap_t *, bpf_u_int32, const void *, size_t *);
PCAP_API pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);
@@ -693,7 +892,10 @@ PCAP_API const char *pcap_lib_version(void);
* UN*X definitions
*/
+ PCAP_AVAILABLE_0_8
PCAP_API int pcap_get_selectable_fd(pcap_t *);
+
+ PCAP_AVAILABLE_1_9
PCAP_API const struct timeval *pcap_get_required_select_timeout(pcap_t *);
#endif /* _WIN32/MSDOS/UN*X */
@@ -722,18 +924,21 @@ PCAP_API const char *pcap_lib_version(void);
#define PCAP_SRC_IFREMOTE 4 /* interface on a remote host, using RPCAP */
/*
- * The formats allowed by pcap_open() are the following:
+ * The formats allowed by pcap_open() are the following (optional parts in []):
* - file://path_and_filename [opens a local file]
- * - rpcap://devicename [opens the selected device devices available on the local host, without using the RPCAP protocol]
- * - rpcap://host/devicename [opens the selected device available on a remote host]
- * - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP]
+ * - rpcap://devicename [opens the selected device available on the local host, without using the RPCAP protocol]
+ * - rpcap://[username:password@]host[:port]/devicename [opens the selected device available on a remote host]
+ * - username and password, if present, will be used to authenticate to the remote host
+ * - port, if present, will specify a port for RPCAP rather than using the default
* - adaptername [to open a local adapter; kept for compatibility, but it is strongly discouraged]
* - (NULL) [to open the first local adapter; kept for compatibility, but it is strongly discouraged]
*
- * The formats allowed by the pcap_findalldevs_ex() are the following:
+ * The formats allowed by the pcap_findalldevs_ex() are the following (optional parts in []):
* - file://folder/ [lists all the files in the given folder]
* - rpcap:// [lists all local adapters]
- * - rpcap://host:port/ [lists the devices available on a remote host]
+ * - rpcap://[username:password@]host[:port]/ [lists the devices available on a remote host]
+ * - username and password, if present, will be used to authenticate to the remote host
+ * - port, if present, will specify a port for RPCAP rather than using the default
*
* In all the above, "rpcaps://" can be substituted for "rpcap://" to enable
* SSL (if it has been compiled in).
@@ -750,6 +955,7 @@ PCAP_API const char *pcap_lib_version(void);
* Here you find some allowed examples:
* - rpcap://host.foo.bar/devicename [everything literal, no port number]
* - rpcap://host.foo.bar:1234/devicename [everything literal, with port number]
+ * - rpcap://root:hunter2@host.foo.bar/devicename [everything literal, with username/password]
* - rpcap://10.11.12.13/devicename [IPv4 numeric, no port number]
* - rpcap://10.11.12.13:1234/devicename [IPv4 numeric, with port number]
* - rpcap://[10.11.12.13]:1234/devicename [IPv4 numeric with IPv6 format, with port number]
@@ -859,10 +1065,11 @@ PCAP_API const char *pcap_lib_version(void);
* authentication is successful (and the user has the right to open network
* devices) the RPCAP connection will continue; otherwise it will be dropped.
*
- * *******NOTE********: the username and password are sent over the network
- * to the capture server *IN CLEAR TEXT*. Don't use this on a network
- * that you don't completely control! (And be *really* careful in your
- * definition of "completely"!)
+ * *******NOTE********: unless TLS is being used, the username and password
+ * are sent over the network to the capture server *IN CLEAR TEXT*. Don't
+ * use this, without TLS (i.e., with rpcap:// rather than rpcaps://) on
+ * a network that you don't completely control! (And be *really* careful
+ * in your definition of "completely"!)
*/
#define RPCAP_RMTAUTH_PWD 1
@@ -926,10 +1133,15 @@ struct pcap_rmtauth
* For opening a remote capture, pcap_open() is currently the only
* API available.
*/
+PCAP_AVAILABLE_1_9
PCAP_API pcap_t *pcap_open(const char *source, int snaplen, int flags,
int read_timeout, struct pcap_rmtauth *auth, char *errbuf);
+
+PCAP_AVAILABLE_1_9
PCAP_API int pcap_createsrcstr(char *source, int type, const char *host,
const char *port, const char *name, char *errbuf);
+
+PCAP_AVAILABLE_1_9
PCAP_API int pcap_parsesrcstr(const char *source, int *type, char *host,
char *port, char *name, char *errbuf);
@@ -952,6 +1164,7 @@ PCAP_API int pcap_parsesrcstr(const char *source, int *type, char *host,
* For listing remote capture devices, pcap_findalldevs_ex() is currently
* the only API available.
*/
+PCAP_AVAILABLE_1_9
PCAP_API int pcap_findalldevs_ex(const char *source,
struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf);
@@ -1022,6 +1235,7 @@ struct pcap_samp
/*
* New functions.
*/
+PCAP_AVAILABLE_1_9
PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
/*
@@ -1031,15 +1245,24 @@ PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
/* Maximum length of an host name (needed for the RPCAP active mode) */
#define RPCAP_HOSTLIST_SIZE 1024
+PCAP_AVAILABLE_1_9
PCAP_API SOCKET pcap_remoteact_accept(const char *address, const char *port,
const char *hostlist, char *connectinghost,
struct pcap_rmtauth *auth, char *errbuf);
+
+PCAP_AVAILABLE_1_10
PCAP_API SOCKET pcap_remoteact_accept_ex(const char *address, const char *port,
const char *hostlist, char *connectinghost,
struct pcap_rmtauth *auth, int uses_ssl, char *errbuf);
+
+PCAP_AVAILABLE_1_9
PCAP_API int pcap_remoteact_list(char *hostlist, char sep, int size,
char *errbuf);
+
+PCAP_AVAILABLE_1_9
PCAP_API int pcap_remoteact_close(const char *host, char *errbuf);
+
+PCAP_AVAILABLE_1_9
PCAP_API void pcap_remoteact_cleanup(void);
enum pcap_option_name { /* never renumber this */
diff --git a/pcap_compile.3pcap.in b/pcap_compile.3pcap.in
index 8238e54f..f9fa483b 100644
--- a/pcap_compile.3pcap.in
+++ b/pcap_compile.3pcap.in
@@ -37,7 +37,7 @@ const char *str, int optimize, bpf_u_int32 netmask);
is used to compile the string
.I str
into a filter program. See
-.BR pcap-filter (@MAN_MISC_INFO@)
+.BR \%pcap-filter (@MAN_MISC_INFO@)
for the syntax of that string.
.I program
is a pointer to a
diff --git a/pcap_datalink_val_to_name.3pcap b/pcap_datalink_val_to_name.3pcap
index 119e8b05..bbfa3f80 100644
--- a/pcap_datalink_val_to_name.3pcap
+++ b/pcap_datalink_val_to_name.3pcap
@@ -63,5 +63,14 @@ If the type value does not correspond to a known
.B DLT_
value, the string "DLT n" is returned, where n is the value of
the dlt argument.
+.SH BACKWARD COMPATIBILITY
+The
+.BR pcap_datalink_val_to_description_or_dlt ()
+function first became available in libpcap release 1.10.0. In previous
+releases,
+.BR pcap_datalink_val_to_description ()
+would have to be called and, if it returned
+.BR NULL ,
+a default string would have to be constructed.
.SH SEE ALSO
.BR pcap (3PCAP)
diff --git a/pcap_dump_ftell.3pcap b/pcap_dump_ftell.3pcap
index 58df7a44..062d6095 100644
--- a/pcap_dump_ftell.3pcap
+++ b/pcap_dump_ftell.3pcap
@@ -54,5 +54,11 @@ but that fit in a
are supported, this will return the file offset without truncation.
.B PCAP_ERROR
is returned on error.
+.SH BACKWARD COMPATIBILITY
+The function
+.BR pcap_dump_ftell64 ()
+became available in libpcap release 1.9.0. In previous releases, there
+was no mechanism to obtain a file offset that is too large to fit in a
+.BR long .
.SH SEE ALSO
.BR pcap (3PCAP)
diff --git a/pcap_dump_open.3pcap.in b/pcap_dump_open.3pcap.in
index fddecb8d..555484ff 100644
--- a/pcap_dump_open.3pcap.in
+++ b/pcap_dump_open.3pcap.in
@@ -81,7 +81,7 @@ order as the host opening the file, and has the same time stamp
precision, link-layer header type, and snapshot length as
.IR p ,
it will write new packets at the end of the file.
-.SH RETURN VALUES
+.SH RETURN VALUE
A pointer to a
.B pcap_dumper_t
structure to use in subsequent
diff --git a/pcap_findalldevs.3pcap b/pcap_findalldevs.3pcap
index 41c98fe1..0dcc0af6 100644
--- a/pcap_findalldevs.3pcap
+++ b/pcap_findalldevs.3pcap
@@ -204,7 +204,9 @@ returns
on success and
.B PCAP_ERROR
on failure; as indicated, finding no
-devices is considered success, rather than failure, so 0 will be
+devices is considered success, rather than failure, so
+.B 0
+will be
returned in that case. If
.B PCAP_ERROR
is returned,
diff --git a/pcap_get_required_select_timeout.3pcap b/pcap_get_required_select_timeout.3pcap
index e70bc02a..37af1803 100644
--- a/pcap_get_required_select_timeout.3pcap
+++ b/pcap_get_required_select_timeout.3pcap
@@ -135,10 +135,11 @@ releases,
.BR epoll_wait (),
and
.BR kevent ()
-cannot be used on any capture source for which
+could not be used for devices that don't provide a selectable file
+descriptor (in other words, on any capture source for that
.BR pcap_get_selectable_fd ()
returns
-.BR \-1 .
+.BR \-1 ).
.PP
In libpcap release 1.10.0 and later, the timeout value can change from
call to call, so
diff --git a/pcap_get_tstamp_precision.3pcap.in b/pcap_get_tstamp_precision.3pcap.in
index 7dbb5690..46451446 100644
--- a/pcap_get_tstamp_precision.3pcap.in
+++ b/pcap_get_tstamp_precision.3pcap.in
@@ -53,4 +53,4 @@ in seconds and microseconds.
.SH SEE ALSO
.BR pcap (3PCAP),
.BR pcap_set_tstamp_precision (3PCAP),
-.BR pcap-tstamp (@MAN_MISC_INFO@)
+.BR \%pcap-tstamp (@MAN_MISC_INFO@)
diff --git a/pcap_init.3pcap b/pcap_init.3pcap
index ba34cc45..543f0833 100644
--- a/pcap_init.3pcap
+++ b/pcap_init.3pcap
@@ -91,5 +91,9 @@ is filled in with an appropriate error message.
is assumed to be able to hold at least
.B PCAP_ERRBUF_SIZE
chars.
+.SH BACKWARD COMPATIBILITY
+This function became available in libpcap release 1.10.0. In previous
+releases, on Windows, all strings supplied as arguments, and all strings
+returned to the caller, are in the local character encoding.
.SH SEE ALSO
.BR pcap (3PCAP)
diff --git a/pcap_inject.3pcap b/pcap_inject.3pcap
index 6b4554e7..83eae1c3 100644
--- a/pcap_inject.3pcap
+++ b/pcap_inject.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_INJECT 3PCAP "25 July 2018"
+.TH PCAP_INJECT 3PCAP "5 March 2022"
.SH NAME
pcap_inject, pcap_sendpacket \- transmit a packet
.SH SYNOPSIS
@@ -74,16 +74,20 @@ comes from OpenBSD;
comes from WinPcap/Npcap. Both are provided for compatibility.)
.SH RETURN VALUE
.BR pcap_inject ()
-returns the number of bytes written on success and
+returns the number of bytes written on success,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated, and
.B PCAP_ERROR
-on failure.
+on other errors.
.PP
.BR pcap_sendpacket ()
returns
.B 0
-on success and
+on success,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated, and
.B PCAP_ERROR
-on failure.
+on other errors.
.PP
If
.B PCAP_ERROR
diff --git a/pcap_list_tstamp_types.3pcap.in b/pcap_list_tstamp_types.3pcap.in
index 74ef00ac..8b6174f4 100644
--- a/pcap_list_tstamp_types.3pcap.in
+++ b/pcap_list_tstamp_types.3pcap.in
@@ -42,7 +42,7 @@ allocates an array to hold the list and sets
.I *tstamp_typesp
to point to the array.
See
-.BR pcap-tstamp (@MAN_MISC_INFO@)
+.BR \%pcap-tstamp (@MAN_MISC_INFO@)
for a list of all the time stamp types.
.PP
The caller is responsible for freeing the array with
@@ -79,4 +79,4 @@ type offered by a capture source is available.
.SH SEE ALSO
.BR pcap (3PCAP),
.BR pcap_tstamp_type_val_to_name (3PCAP),
-.BR pcap-tstamp (@MAN_MISC_INFO@)
+.BR \%pcap-tstamp (@MAN_MISC_INFO@)
diff --git a/pcap_loop.3pcap b/pcap_loop.3pcap
index 3d741efa..0c595262 100644
--- a/pcap_loop.3pcap
+++ b/pcap_loop.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_LOOP 3PCAP "22 August 2020"
+.TH PCAP_LOOP 3PCAP "5 March 2022"
.SH NAME
pcap_loop, pcap_dispatch \- process packets from a live capture or savefile
.SH SYNOPSIS
@@ -164,12 +164,15 @@ if
.I cnt
is exhausted or if, when reading from a ``savefile'', no more packets
are available. It returns
-.B PCAP_ERROR
-if an error occurs or
.B PCAP_ERROR_BREAK
if the loop terminated due to a call to
.BR pcap_breakloop ()
-before any packets were processed.
+before any packets were processed,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated,
+or
+.B PCAP_ERROR
+if another error occurs.
It does
.B not
return when live packet buffer timeouts occur; instead, it attempts to
@@ -184,12 +187,15 @@ packets arrive, the timeout expires before any packets arrive, or if the
file descriptor for the capture device is in non-blocking mode and no
packets were available to be read) or if no more packets are available
in a ``savefile.'' It returns
-.B PCAP_ERROR
-if an error occurs or
.B PCAP_ERROR_BREAK
if the loop terminated due to a call to
.BR pcap_breakloop ()
-before any packets were processed.
+before any packets were processed,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated,
+or
+.B PCAP_ERROR
+if another error occurs.
.ft B
If your application uses pcap_breakloop(),
make sure that you explicitly check for PCAP_ERROR and PCAP_ERROR_BREAK,
diff --git a/pcap_next_ex.3pcap b/pcap_next_ex.3pcap
index 2bd1a427..4d2c43e8 100644
--- a/pcap_next_ex.3pcap
+++ b/pcap_next_ex.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_NEXT_EX 3PCAP "25 July 2018"
+.TH PCAP_NEXT_EX 3PCAP "5 March 2022"
.SH NAME
pcap_next_ex, pcap_next \- read the next packet from a pcap_t
.SH SYNOPSIS
@@ -120,12 +120,15 @@ if the packet was read without problems,
.B 0
if packets are
being read from a live capture and the packet buffer timeout expired,
-.B PCAP_ERROR
-if an error occurred while reading the packet, and
.B PCAP_ERROR_BREAK
if packets
are being read from a ``savefile'' and there are no more packets to read
-from the savefile. If
+from the savefile,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated,
+or
+.B PCAP_ERROR
+if an error occurred while reading the packet. If
.B PCAP_ERROR
is returned,
.BR pcap_geterr (3PCAP)
diff --git a/pcap_open_dead.3pcap.in b/pcap_open_dead.3pcap.in
index e28d5bda..ced7d6cf 100644
--- a/pcap_open_dead.3pcap.in
+++ b/pcap_open_dead.3pcap.in
@@ -74,6 +74,12 @@ seconds and microseconds, and
should be specified if the packets to be written have time stamps in
seconds and nanoseconds. Its value does not affect
.BR pcap_compile (3PCAP).
+.SH BACKWARD COMPATIBILITY
+The
+.BR pcap_open_dead_with_tstamp_precision ()
+function became available in libpcap release 1.5.1. In previous
+releases, there was no mechanism to open a savefile for writing with
+time stamps given in seconds and nanoseconds.
.SH SEE ALSO
.BR pcap (3PCAP),
.BR \%pcap-linktype (@MAN_MISC_INFO@)
diff --git a/pcap_open_offline.3pcap.in b/pcap_open_offline.3pcap.in
index 5e878fea..e48bf25e 100644
--- a/pcap_open_offline.3pcap.in
+++ b/pcap_open_offline.3pcap.in
@@ -50,7 +50,7 @@ are called to open a ``savefile'' for reading.
.I fname
specifies the name of the file to open. The file can have the pcap file
format as described in
-.BR pcap-savefile (@MAN_FILE_FORMATS@),
+.BR \%pcap-savefile (@MAN_FILE_FORMATS@),
which is the file format used by, among other programs,
.BR tcpdump (1)
and
@@ -114,4 +114,4 @@ became available in libpcap release 1.5.1. In previous releases, time
stamps from a savefile are always given in seconds and microseconds.
.SH SEE ALSO
.BR pcap (3PCAP),
-.BR pcap-savefile (@MAN_FILE_FORMATS@)
+.BR \%pcap-savefile (@MAN_FILE_FORMATS@)
diff --git a/pcap_set_datalink.3pcap b/pcap_set_datalink.3pcap
index 14e9d209..fd907913 100644
--- a/pcap_set_datalink.3pcap
+++ b/pcap_set_datalink.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_SET_DATALINK 3PCAP "25 July 2018"
+.TH PCAP_SET_DATALINK 3PCAP "5 March 2022"
.SH NAME
pcap_set_datalink \- set the link-layer header type to be used by a
capture device
@@ -40,9 +40,11 @@ to the type specified by
.BR pcap_set_datalink ()
returns
.B 0
-on success and
+on success,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated, or
.B PCAP_ERROR
-on failure. If
+on other errors. If
.B PCAP_ERROR
is returned,
.BR pcap_geterr (3PCAP)
diff --git a/pcap_set_immediate_mode.3pcap.in b/pcap_set_immediate_mode.3pcap.in
index e493d55a..95c9cffb 100644
--- a/pcap_set_immediate_mode.3pcap.in
+++ b/pcap_set_immediate_mode.3pcap.in
@@ -70,7 +70,7 @@ don't assume it's sufficient);
.IP
on Digital UNIX/Tru64 UNIX, immediate mode must be turned on by doing a
.B BIOCMBIC
-.BR ioctl ,
+.BR ioctl (),
as documented in
.BR packetfilter (7),
to clear the
diff --git a/pcap_set_tstamp_precision.3pcap.in b/pcap_set_tstamp_precision.3pcap.in
index eb449d5d..1889f43d 100644
--- a/pcap_set_tstamp_precision.3pcap.in
+++ b/pcap_set_tstamp_precision.3pcap.in
@@ -65,4 +65,4 @@ in seconds and microseconds.
.SH SEE ALSO
.BR pcap (3PCAP),
.BR pcap_get_tstamp_precision (3PCAP),
-.BR pcap-tstamp (@MAN_MISC_INFO@)
+.BR \%pcap-tstamp (@MAN_MISC_INFO@)
diff --git a/pcap_set_tstamp_type.3pcap.in b/pcap_set_tstamp_type.3pcap.in
index e19d6e5f..cd2dc71c 100644
--- a/pcap_set_tstamp_type.3pcap.in
+++ b/pcap_set_tstamp_type.3pcap.in
@@ -45,7 +45,7 @@ that has not yet been activated by
will give a list of the time stamp types supported by a given capture
device.
See
-.BR pcap-tstamp (@MAN_MISC_INFO@)
+.BR \%pcap-tstamp (@MAN_MISC_INFO@)
for a list of all the time stamp types.
.SH RETURN VALUE
.BR pcap_set_tstamp_type ()
diff --git a/pcap_setdirection.3pcap b/pcap_setdirection.3pcap
index 7b388450..04278e84 100644
--- a/pcap_setdirection.3pcap
+++ b/pcap_setdirection.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_SETDIRECTION 3PCAP "25 July 2018"
+.TH PCAP_SETDIRECTION 3PCAP "5 March 2022"
.SH NAME
pcap_setdirection \- set the direction for which packets will be captured
.SH SYNOPSIS
@@ -59,9 +59,11 @@ This operation is not supported if a ``savefile'' is being read.
.BR pcap_setdirection ()
returns
.B 0
-on success and
+on success,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated, or
.B PCAP_ERROR
-on failure. If
+on other errors. If
.B PCAP_ERROR
is returned,
.BR pcap_geterr (3PCAP)
diff --git a/pcap_setfilter.3pcap b/pcap_setfilter.3pcap
index 1e3c5a59..e063ae0e 100644
--- a/pcap_setfilter.3pcap
+++ b/pcap_setfilter.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_SETFILTER 3PCAP "25 July 2018"
+.TH PCAP_SETFILTER 3PCAP "5 March 2022"
.SH NAME
pcap_setfilter \- set the filter
.SH SYNOPSIS
@@ -42,9 +42,11 @@ struct, usually the result of a call to
.BR pcap_setfilter ()
returns
.B 0
-on success and
+on success,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated, or
.B PCAP_ERROR
-on failure. If
+on other errors. If
.B PCAP_ERROR
is returned,
.BR pcap_geterr (3PCAP)
diff --git a/pcap_setnonblock.3pcap b/pcap_setnonblock.3pcap
index 65cfea28..f194b949 100644
--- a/pcap_setnonblock.3pcap
+++ b/pcap_setnonblock.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_SETNONBLOCK 3PCAP "25 July 2018"
+.TH PCAP_SETNONBLOCK 3PCAP "5 March 2022"
.SH NAME
pcap_setnonblock, pcap_getnonblock \- set or get the state of
non-blocking mode on a capture device
@@ -87,7 +87,10 @@ returns the current ``non-blocking'' state of the capture descriptor; it
always returns
.B 0
on ``savefiles''.
-If there is an error,
+If called on a capture handle that has been created but not activated,
+.B PCAP_ERROR_NOT_ACTIVATED
+is returned.
+If there is another error,
.B PCAP_ERROR
is returned and
.I errbuf
diff --git a/pcap_stats.3pcap b/pcap_stats.3pcap
index aa03013c..98be9bd7 100644
--- a/pcap_stats.3pcap
+++ b/pcap_stats.3pcap
@@ -17,7 +17,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_STATS 3PCAP "25 July 2018"
+.TH PCAP_STATS 3PCAP "5 March 2022"
.SH NAME
pcap_stats \- get capture statistics
.SH SYNOPSIS
@@ -85,9 +85,12 @@ that the interface did not drop any packets.
.BR pcap_stats ()
returns
.B 0
-on success and returns
+on success,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated,
+or
.B PCAP_ERROR
-if there is an error or if
+if there is another error or if
.I p
doesn't support packet statistics. If
.B PCAP_ERROR
diff --git a/pflog.h b/pflog.h
new file mode 100644
index 00000000..0d3f899b
--- /dev/null
+++ b/pflog.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pflog headers, at least as they exist now.
+ */
+#define PFLOG_IFNAMSIZ 16
+#define PFLOG_RULESET_NAME_SIZE 16
+
+/*
+ * Direction values.
+ */
+#define PF_INOUT 0
+#define PF_IN 1
+#define PF_OUT 2
+#if defined(__OpenBSD__)
+#define PF_FWD 3
+#endif
+
+/*
+ * Reason values.
+ */
+#define PFRES_MATCH 0
+#define PFRES_BADOFF 1
+#define PFRES_FRAG 2
+#define PFRES_SHORT 3
+#define PFRES_NORM 4
+#define PFRES_MEMORY 5
+#define PFRES_TS 6
+#define PFRES_CONGEST 7
+#define PFRES_IPOPTIONS 8
+#define PFRES_PROTCKSUM 9
+#define PFRES_BADSTATE 10
+#define PFRES_STATEINS 11
+#define PFRES_MAXSTATES 12
+#define PFRES_SRCLIMIT 13
+#define PFRES_SYNPROXY 14
+#if defined(__FreeBSD__)
+#define PFRES_MAPFAILED 15
+#elif defined(__NetBSD__)
+#define PFRES_STATELOCKED 15
+#elif defined(__OpenBSD__)
+#define PFRES_TRANSLATE 15
+#define PFRES_NOROUTE 16
+#elif defined(__APPLE__)
+#define PFRES_DUMMYNET 15
+#endif
+
+/*
+ * Action vaues.
+ */
+#define PF_PASS 0
+#define PF_DROP 1
+#define PF_SCRUB 2
+#define PF_NOSCRUB 3
+#define PF_NAT 4
+#define PF_NONAT 5
+#define PF_BINAT 6
+#define PF_NOBINAT 7
+#define PF_RDR 8
+#define PF_NORDR 9
+#define PF_SYNPROXY_DROP 10
+#if defined(__FreeBSD__)
+#define PF_DEFER 11
+#elif defined(__OpenBSD__)
+#define PF_DEFER 11
+#define PF_MATCH 12
+#define PF_DIVERT 13
+#define PF_RT 14
+#define PF_AFRT 15
+#elif defined(__APPLE__)
+#define PF_DUMMYNET 11
+#define PF_NODUMMYNET 12
+#define PF_NAT64 13
+#define PF_NONAT64 14
+#endif
+
+struct pf_addr {
+ union {
+ struct in_addr v4;
+ struct in6_addr v6;
+ uint8_t addr8[16];
+ uint16_t addr16[8];
+ uint32_t addr32[4];
+ } pfa; /* 128-bit address */
+#define v4 pfa.v4
+#define v6 pfa.v6
+#define addr8 pfa.addr8
+#define addr16 pfa.addr16
+#define addr32 pfa.addr32
+};
+
+struct pfloghdr {
+ uint8_t length;
+ uint8_t af;
+ uint8_t action;
+ uint8_t reason;
+ char ifname[PFLOG_IFNAMSIZ];
+ char ruleset[PFLOG_RULESET_NAME_SIZE];
+ uint32_t rulenr;
+ uint32_t subrulenr;
+ uint32_t uid;
+ int32_t pid;
+ uint32_t rule_uid;
+ int32_t rule_pid;
+ uint8_t dir;
+#if defined(__OpenBSD__)
+ uint8_t rewritten;
+ uint8_t naf;
+ uint8_t pad[1];
+#else
+ uint8_t pad[3];
+#endif
+#if defined(__FreeBSD__)
+ uint32_t ridentifier;
+ uint8_t reserve;
+ uint8_t pad2[3];
+#elif defined(__OpenBSD__)
+ struct pf_addr saddr;
+ struct pf_addr daddr;
+ uint16_t sport;
+ uint16_t dport;
+#endif
+};
+
+
+
diff --git a/portability.h b/portability.h
index d606368d..84d0778a 100644
--- a/portability.h
+++ b/portability.h
@@ -112,6 +112,30 @@ extern int pcap_asprintf(char **, PCAP_FORMAT_STRING(const char *), ...)
extern int pcap_vasprintf(char **, const char *, va_list ap);
#endif
+/* For Solaris before 11. */
+#ifndef timeradd
+#define timeradd(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
+ if ((result)->tv_usec >= 1000000) { \
+ ++(result)->tv_sec; \
+ (result)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#endif /* timeradd */
+#ifndef timersub
+#define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif /* timersub */
+
#ifdef HAVE_STRTOK_R
#define pcap_strtok_r strtok_r
#else
diff --git a/rpcapd/CMakeLists.txt b/rpcapd/CMakeLists.txt
index f2bd12dc..72f0c096 100644
--- a/rpcapd/CMakeLists.txt
+++ b/rpcapd/CMakeLists.txt
@@ -135,15 +135,28 @@ if(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT))
set(MANFILE_EXPAND rpcapd-config.manfile.in)
- if(NOT MSVC)
- install(TARGETS rpcapd DESTINATION sbin)
- else(NOT MSVC)
+ if(WIN32)
+ #
+ # XXX - where should the install target put rpcapd on Windows?
+ #
+ # Note that if an installer package is being produced
+ # from the results of the build, the installer package
+ # will determine where it goes.
+ #
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
install(TARGETS rpcapd DESTINATION bin/amd64)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
install(TARGETS rpcapd DESTINATION bin)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
- endif(NOT MSVC)
+ else(WIN32)
+ #
+ # On UN*X, we put it in the sbin directory.
+ #
+ # XXX - the Linux Filesystem Hierarchy Standard says /usr/sbin
+ # is for daemons, but some other systems use /usr/libexec instead.
+ #
+ install(TARGETS rpcapd DESTINATION sbin)
+ endif(WIN32)
# On UN*X, and on Windows when not using MSVC, generate process man
# pages and arrange that they be installed.
diff --git a/rpcapd/daemon.c b/rpcapd/daemon.c
index 620dec31..362f4b9b 100644
--- a/rpcapd/daemon.c
+++ b/rpcapd/daemon.c
@@ -375,7 +375,7 @@ daemon_serviceloop(SOCKET sockctrl, int isactive, char *passiveClients,
// Immediate EOF
goto end;
}
- plen = (tls_header.length_hi << 8) | tls_header.length_lo;
+ plen = (tls_header.length_hi << 8U) | tls_header.length_lo;
// Discard the rest of the message.
if (rpcapd_discard(sockctrl, NULL, plen) == -1)
@@ -1602,7 +1602,6 @@ daemon_msg_findallif_req(uint8 ver, struct daemon_slpars *pars, uint32 plen)
pcap_if_t *alldevs = NULL; // pointer to the header of the interface chain
pcap_if_t *d; // temp pointer needed to scan the interface chain
struct pcap_addr *address; // pcap structure that keeps a network address of an interface
- struct rpcap_findalldevs_if *findalldevs_if;// rpcap structure that packet all the data of an interface together
uint32 replylen; // length of reply payload
uint16 nif = 0; // counts the number of interface listed
@@ -1703,13 +1702,17 @@ daemon_msg_findallif_req(uint8 ver, struct daemon_slpars *pars, uint32 plen)
{
uint16 lname, ldescr;
- findalldevs_if = (struct rpcap_findalldevs_if *) &sendbuf[sendbufidx];
-
- if (sock_bufferize(NULL, sizeof(struct rpcap_findalldevs_if), NULL,
- &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
- goto error;
-
- memset(findalldevs_if, 0, sizeof(struct rpcap_findalldevs_if));
+ // Note: the findalldevs_if entries are *not* neatly
+ // aligned on 4-byte boundaries, because they're
+ // preceded by strings that aren't padded to 4-byte
+ // boundaries, so we cannot just cast output buffer
+ // boundaries to struct rpcap_findalldevs_if pointers
+ // and store into them - we must fill in a structure and
+ // then copy the structure to the buffer, as not all
+ // systems support unaligned access (some, such as
+ // SPARC, crash; others, such as Arm, may just ignore
+ // the lower-order bits).
+ struct rpcap_findalldevs_if findalldevs_if;
/*
* We've already established that the string lengths
@@ -1724,10 +1727,11 @@ daemon_msg_findallif_req(uint8 ver, struct daemon_slpars *pars, uint32 plen)
else
lname = 0;
- findalldevs_if->desclen = htons(ldescr);
- findalldevs_if->namelen = htons(lname);
- findalldevs_if->flags = htonl(d->flags);
+ findalldevs_if.desclen = htons(ldescr);
+ findalldevs_if.namelen = htons(lname);
+ findalldevs_if.flags = htonl(d->flags);
+ uint16_t naddrs = 0;
for (address = d->addresses; address != NULL; address = address->next)
{
/*
@@ -1739,14 +1743,20 @@ daemon_msg_findallif_req(uint8 ver, struct daemon_slpars *pars, uint32 plen)
#ifdef AF_INET6
case AF_INET6:
#endif
- findalldevs_if->naddr++;
+ naddrs++;
break;
default:
break;
}
}
- findalldevs_if->naddr = htons(findalldevs_if->naddr);
+ findalldevs_if.naddr = htons(naddrs);
+ findalldevs_if.dummy = 0;
+
+ if (sock_bufferize(&findalldevs_if, sizeof(struct rpcap_findalldevs_if), sendbuf,
+ &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_BUFFERIZE, errmsgbuf,
+ PCAP_ERRBUF_SIZE) == -1)
+ goto error;
if (sock_bufferize(d->name, lname, sendbuf, &sendbufidx,
RPCAP_NETBUF_SIZE, SOCKBUF_BUFFERIZE, errmsgbuf,
@@ -2337,7 +2347,7 @@ daemon_unpackapplyfilter(SOCKET sockctrl, SSL *ctrl_ssl, struct session *session
if (bf_prog.bf_len > RPCAP_BPF_MAXINSNS)
{
snprintf(errmsgbuf, PCAP_ERRBUF_SIZE,
- "Filter program is larger than the maximum size of %u instructions",
+ "Filter program is larger than the maximum size of %d instructions",
RPCAP_BPF_MAXINSNS);
return -2;
}
@@ -2421,7 +2431,7 @@ daemon_msg_updatefilter_req(uint8 ver, struct daemon_slpars *pars,
// A response is needed, otherwise the other host does not know that everything went well
rpcap_createhdr(&header, ver, RPCAP_MSG_UPDATEFILTER_REPLY, 0, 0);
- if (sock_send(pars->sockctrl, pars->ssl, (char *) &header, sizeof (struct rpcap_header), pcap_geterr(session->fp), PCAP_ERRBUF_SIZE))
+ if (sock_send(pars->sockctrl, pars->ssl, (char *) &header, sizeof (struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE))
{
// That failed; log a message and give up.
rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -2818,19 +2828,25 @@ daemon_seraddr(struct sockaddr_storage *sockaddrin, struct rpcap_sockaddr *socka
if (sockaddrin == NULL) return;
// Warning: we support only AF_INET and AF_INET6
+ //
+ // Note: as noted above, the output structures are not
+ // neatly aligned on 4-byte boundaries, so we must fill
+ // in an aligned structure and then copy it to the output
+ // buffer with memcpy().
switch (sockaddrin->ss_family)
{
case AF_INET:
{
struct sockaddr_in *sockaddrin_ipv4;
- struct rpcap_sockaddr_in *sockaddrout_ipv4;
+ struct rpcap_sockaddr_in sockaddrout_ipv4;
sockaddrin_ipv4 = (struct sockaddr_in *) sockaddrin;
- sockaddrout_ipv4 = (struct rpcap_sockaddr_in *) sockaddrout;
- sockaddrout_ipv4->family = htons(RPCAP_AF_INET);
- sockaddrout_ipv4->port = htons(sockaddrin_ipv4->sin_port);
- memcpy(&sockaddrout_ipv4->addr, &sockaddrin_ipv4->sin_addr, sizeof(sockaddrout_ipv4->addr));
- memset(sockaddrout_ipv4->zero, 0, sizeof(sockaddrout_ipv4->zero));
+
+ sockaddrout_ipv4.family = htons(RPCAP_AF_INET);
+ sockaddrout_ipv4.port = htons(sockaddrin_ipv4->sin_port);
+ memcpy(&sockaddrout_ipv4.addr, &sockaddrin_ipv4->sin_addr, sizeof(sockaddrout_ipv4.addr));
+ memset(sockaddrout_ipv4.zero, 0, sizeof(sockaddrout_ipv4.zero));
+ memcpy(sockaddrout, &sockaddrout_ipv4, sizeof(struct rpcap_sockaddr_in));
break;
}
@@ -2838,15 +2854,16 @@ daemon_seraddr(struct sockaddr_storage *sockaddrin, struct rpcap_sockaddr *socka
case AF_INET6:
{
struct sockaddr_in6 *sockaddrin_ipv6;
- struct rpcap_sockaddr_in6 *sockaddrout_ipv6;
+ struct rpcap_sockaddr_in6 sockaddrout_ipv6;
sockaddrin_ipv6 = (struct sockaddr_in6 *) sockaddrin;
- sockaddrout_ipv6 = (struct rpcap_sockaddr_in6 *) sockaddrout;
- sockaddrout_ipv6->family = htons(RPCAP_AF_INET6);
- sockaddrout_ipv6->port = htons(sockaddrin_ipv6->sin6_port);
- sockaddrout_ipv6->flowinfo = htonl(sockaddrin_ipv6->sin6_flowinfo);
- memcpy(&sockaddrout_ipv6->addr, &sockaddrin_ipv6->sin6_addr, sizeof(sockaddrout_ipv6->addr));
- sockaddrout_ipv6->scope_id = htonl(sockaddrin_ipv6->sin6_scope_id);
+
+ sockaddrout_ipv6.family = htons(RPCAP_AF_INET6);
+ sockaddrout_ipv6.port = htons(sockaddrin_ipv6->sin6_port);
+ sockaddrout_ipv6.flowinfo = htonl(sockaddrin_ipv6->sin6_flowinfo);
+ memcpy(&sockaddrout_ipv6.addr, &sockaddrin_ipv6->sin6_addr, sizeof(sockaddrout_ipv6.addr));
+ sockaddrout_ipv6.scope_id = htonl(sockaddrin_ipv6->sin6_scope_id);
+ memcpy(sockaddrout, &sockaddrout_ipv6, sizeof(struct rpcap_sockaddr_in6));
break;
}
#endif
diff --git a/rpcapd/rpcapd.c b/rpcapd/rpcapd.c
index b91a401e..19da87f8 100644
--- a/rpcapd/rpcapd.c
+++ b/rpcapd/rpcapd.c
@@ -35,6 +35,7 @@
#endif
#include "ftmacros.h"
+#include "diag-control.h"
#include <errno.h> // for the errno variable
#include <string.h> // for strtok, etc
@@ -1361,9 +1362,11 @@ main_active(void *ptr)
{
rpcapd_log(LOGPRIO_DEBUG, "%s", errbuf);
+ DIAG_OFF_FORMAT_TRUNCATION
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error connecting to host %s, port %s, using protocol %s",
activepars->address, activepars->port, (hints.ai_family == AF_INET) ? "IPv4":
(hints.ai_family == AF_INET6) ? "IPv6" : "Unspecified");
+ DIAG_ON_FORMAT_TRUNCATION
rpcapd_log(LOGPRIO_DEBUG, "%s", errbuf);
diff --git a/savefile.c b/savefile.c
index d04b917a..2b42b9b4 100644
--- a/savefile.c
+++ b/savefile.c
@@ -350,7 +350,7 @@ pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision,
if (fname[0] == '-' && fname[1] == '\0')
{
fp = stdin;
- if (stdin == NULL) {
+ if (fp == NULL) {
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"The standard input is not open");
return (NULL);
@@ -618,12 +618,27 @@ int
pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
struct bpf_insn *fcode;
- int status = 0;
int n = 0;
u_char *data;
- while (status == 0) {
+ /*
+ * This can conceivably process more than INT_MAX packets,
+ * which would overflow the packet count, causing it either
+ * to look like a negative number, and thus cause us to
+ * return a value that looks like an error, or overflow
+ * back into positive territory, and thus cause us to
+ * return a too-low count.
+ *
+ * Therefore, if the packet count is unlimited, we clip
+ * it at INT_MAX; this routine is not expected to
+ * process packets indefinitely, so that's not an issue.
+ */
+ if (PACKET_COUNT_IS_UNLIMITED(cnt))
+ cnt = INT_MAX;
+
+ for (;;) {
struct pcap_pkthdr h;
+ int status;
/*
* Has "pcap_breakloop()" been called?
@@ -643,16 +658,28 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
status = p->next_packet_op(p, &h, &data);
- if (status) {
- if (status == 1)
- return (0);
+ if (status < 0) {
+ /*
+ * Error. Pass it back to the caller.
+ */
return (status);
}
+ if (status == 0) {
+ /*
+ * EOF. Nothing more to process;
+ */
+ break;
+ }
+ /*
+ * OK, we've read a packet; run it through the filter
+ * and, if it passes, process it.
+ */
if ((fcode = p->fcode.bf_insns) == NULL ||
pcap_filter(fcode, data, h.len, h.caplen)) {
(*callback)(user, &h, data);
- if (++n >= cnt && cnt > 0)
+ n++; /* count the packet */
+ if (n >= cnt)
break;
}
}
diff --git a/scanner.l b/scanner.l
index 06b9acc1..85fe395a 100644
--- a/scanner.l
+++ b/scanner.l
@@ -24,6 +24,13 @@
*/
#include <pcap/pcap-inttypes.h>
+/*
+ * grammar.h requires gencode.h and sometimes breaks in a polluted namespace
+ * (see ftmacros.h), so include it early.
+ */
+#include "gencode.h"
+#include "grammar.h"
+
#include "diag-control.h"
}
@@ -89,10 +96,6 @@
#include "pcap-int.h"
-#include "gencode.h"
-
-#include "grammar.h"
-
/*
* Earlier versions of Flex don't declare these, so we declare them
* ourselves to squelch warnings.
diff --git a/sf-pcap.c b/sf-pcap.c
index d8443e98..78437031 100644
--- a/sf-pcap.c
+++ b/sf-pcap.c
@@ -96,18 +96,6 @@
*/
#define NSEC_TCPDUMP_MAGIC 0xa1b23c4d
-/*
- * Mechanism for storing information about a capture in the upper
- * 6 bits of a linktype value in a capture file.
- *
- * LT_LINKTYPE_EXT(x) extracts the additional information.
- *
- * The rest of the bits are for a value describing the link-layer
- * value. LT_LINKTYPE(x) extracts that value.
- */
-#define LT_LINKTYPE(x) ((x) & 0x03FFFFFF)
-#define LT_LINKTYPE_EXT(x) ((x) & 0xFC000000)
-
static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap);
#ifdef _WIN32
@@ -237,6 +225,17 @@ pcap_check_header(const uint8_t *magic, FILE *fp, u_int precision, char *errbuf,
}
/*
+ * Check the main reserved field.
+ */
+ if (LT_RESERVED1(hdr.linktype) != 0) {
+ snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "savefile linktype reserved field not zero (0x%08x)",
+ LT_RESERVED1(hdr.linktype));
+ *err = 1;
+ return NULL;
+ }
+
+ /*
* OK, this is a good pcap file.
* Allocate a pcap_t for it.
*/
@@ -434,7 +433,7 @@ grow_buffer(pcap_t *p, u_int bufsize)
/*
* Read and return the next packet from the savefile. Return the header
- * in hdr and a pointer to the contents in data. Return 0 on success, 1
+ * in hdr and a pointer to the contents in data. Return 1 on success, 0
* if there were no more packets, and -1 on an error.
*/
static int
@@ -467,7 +466,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
return (-1);
}
/* EOF */
- return (1);
+ return (0);
}
}
@@ -622,7 +621,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
* the read finished.
*/
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "truncated dump file; tried to read %u captured bytes, only got %zu",
+ "truncated dump file; tried to read %d captured bytes, only got %zu",
p->snapshot, amt_read);
}
return (-1);
@@ -709,7 +708,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
if (p->swapped)
swap_pseudo_headers(p->linktype, hdr, *data);
- return (0);
+ return (1);
}
static int
@@ -749,6 +748,24 @@ pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
f = (FILE *)user;
/*
+ * If the output file handle is in an error state, don't write
+ * anything.
+ *
+ * While in principle a file handle can return from an error state
+ * to a normal state (for example if a disk that is full has space
+ * freed), we have possibly left a broken file already, and won't
+ * be able to clean it up. The safest option is to do nothing.
+ *
+ * Note that if we could guarantee that fwrite() was atomic we
+ * might be able to insure that we don't produce a corrupted file,
+ * but the standard defines fwrite() as a series of fputc() calls,
+ * so we really have no insurance that things are not fubared.
+ *
+ * http://pubs.opengroup.org/onlinepubs/009695399/functions/fwrite.html
+ */
+ if (ferror(f))
+ return;
+ /*
* Better not try writing pcap files after
* 2038-01-19 03:14:07 UTC; switch to pcapng.
*/
@@ -756,9 +773,17 @@ pcap_dump(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
sf_hdr.ts.tv_usec = (bpf_int32)h->ts.tv_usec;
sf_hdr.caplen = h->caplen;
sf_hdr.len = h->len;
- /* XXX we should check the return status */
- (void)fwrite(&sf_hdr, sizeof(sf_hdr), 1, f);
- (void)fwrite(sp, h->caplen, 1, f);
+ /*
+ * We only write the packet if we can write the header properly.
+ *
+ * This doesn't prevent us from having corrupted output, and if we
+ * for some reason don't get a complete write we don't have any
+ * way to set ferror() to prevent future writes from being
+ * attempted, but it is better than nothing.
+ */
+ if (fwrite(&sf_hdr, sizeof(sf_hdr), 1, f) == 1) {
+ (void)fwrite(sp, h->caplen, 1, f);
+ }
}
static pcap_dumper_t *
diff --git a/sf-pcapng.c b/sf-pcapng.c
index f7f413d3..9e0a72e5 100644
--- a/sf-pcapng.c
+++ b/sf-pcapng.c
@@ -101,7 +101,8 @@ struct section_header_block {
/*
* Current version number. If major_version isn't PCAP_NG_VERSION_MAJOR,
- * that means that this code can't read the file.
+ * or if minor_version isn't PCAP_NG_VERSION_MINOR or 2, that means that
+ * this code can't read the file.
*/
#define PCAP_NG_VERSION_MAJOR 1
#define PCAP_NG_VERSION_MINOR 0
@@ -962,9 +963,23 @@ pcap_ng_check_header(const uint8_t *magic, FILE *fp, u_int precision,
* XXX - we don't care about the section length.
*/
}
- /* currently only SHB version 1.0 is supported */
+ /* Currently only SHB versions 1.0 and 1.2 are supported;
+ version 1.2 is treated as being the same as version 1.0.
+ See the current version of the pcapng specification.
+
+ Version 1.2 is written by some programs that write additional
+ block types (which can be read by any code that handles them,
+ regardless of whether the minor version if 0 or 2, so that's
+ not a reason to change the minor version number).
+
+ XXX - the pcapng specification says that readers should
+ just ignore sections with an unsupported version number;
+ presumably they can also report an error if they skip
+ all the way to the end of the file without finding
+ any versions that they support. */
if (! (shbp->major_version == PCAP_NG_VERSION_MAJOR &&
- shbp->minor_version == PCAP_NG_VERSION_MINOR)) {
+ (shbp->minor_version == PCAP_NG_VERSION_MINOR ||
+ shbp->minor_version == 2))) {
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"unsupported pcapng savefile version %u.%u",
shbp->major_version, shbp->minor_version);
@@ -1079,7 +1094,7 @@ pcap_ng_cleanup(pcap_t *p)
/*
* Read and return the next packet from the savefile. Return the header
- * in hdr and a pointer to the contents in data. Return 0 on success, 1
+ * in hdr and a pointer to the contents in data. Return 1 on success, 0
* if there were no more packets, and -1 on an error.
*/
static int
@@ -1108,7 +1123,7 @@ pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
*/
status = read_block(fp, p, &cursor, p->errbuf);
if (status == 0)
- return (1); /* EOF */
+ return (0); /* EOF */
if (status == -1)
return (-1); /* error */
switch (cursor.block_type) {
@@ -1499,5 +1514,5 @@ found:
if (p->swapped)
swap_pseudo_headers(p->linktype, hdr, *data);
- return (0);
+ return (1);
}
diff --git a/sockutils.c b/sockutils.c
index c1ec9a5a..d9762dd5 100644
--- a/sockutils.c
+++ b/sockutils.c
@@ -527,7 +527,7 @@ int sock_close(SOCKET sock, char *errbuf, int errbuflen)
}
/*
- * gai_errstring() has some problems:
+ * gai_strerror() has some problems:
*
* 1) on Windows, Microsoft explicitly says it's not thread-safe;
* 2) on UN*X, the Single UNIX Specification doesn't say it *is*
@@ -882,11 +882,11 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size,
}
/*
- * \brief It copies the amount of data contained into 'buffer' into 'tempbuf'.
+ * \brief It copies the amount of data contained in 'data' into 'outbuf'.
* and it checks for buffer overflows.
*
- * This function basically copies 'size' bytes of data contained into 'buffer'
- * into 'tempbuf', starting at offset 'offset'. Before that, it checks that the
+ * This function basically copies 'size' bytes of data contained in 'data'
+ * into 'outbuf', starting at offset 'offset'. Before that, it checks that the
* resulting buffer will not be larger than 'totsize'. Finally, it updates
* the 'offset' variable in order to point to the first empty location of the buffer.
*
@@ -895,25 +895,24 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size,
* 'offset' variable. This mode can be useful when the buffer already contains the
* data (maybe because the producer writes directly into the target buffer), so
* only the buffer overflow check has to be made.
- * In this case, both 'buffer' and 'tempbuf' can be NULL values.
+ * In this case, both 'data' and 'outbuf' can be NULL values.
*
* This function is useful in case the userland application does not know immediately
* all the data it has to write into the socket. This function provides a way to create
* the "stream" step by step, appending the new data to the old one. Then, when all the
* data has been bufferized, the application can call the sock_send() function.
*
- * \param buffer: a char pointer to a user-allocated buffer that keeps the data
- * that has to be copied.
+ * \param data: a void pointer to the data that has to be copied.
*
* \param size: number of bytes that have to be copied.
*
- * \param tempbuf: user-allocated buffer (of size 'totsize') in which data
+ * \param outbuf: user-allocated buffer (of size 'totsize') into which data
* has to be copied.
*
- * \param offset: an index into 'tempbuf' which keeps the location of its first
+ * \param offset: an index into 'outbuf' which keeps the location of its first
* empty location.
*
- * \param totsize: total size of the buffer in which data is being copied.
+ * \param totsize: total size of the buffer into which data is being copied.
*
* \param checkonly: '1' if we do not want to copy data into the buffer and we
* want just do a buffer ovreflow control, '0' if data has to be copied as well.
@@ -926,7 +925,7 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size,
* larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
*
* \return '0' if everything is fine, '-1' if some errors occurred. The error message
- * is returned in the 'errbuf' variable. When the function returns, 'tempbuf' will
+ * is returned in the 'errbuf' variable. When the function returns, 'outbuf' will
* have the new string appended, and 'offset' will keep the length of that buffer.
* In case of 'checkonly == 1', data is not copied, but 'offset' is updated in any case.
*
@@ -936,7 +935,7 @@ int sock_send(SOCKET sock, SSL *ssl _U_NOSSL_, const char *buffer, size_t size,
* \warning In case of 'checkonly', be carefully to call this function *before* copying
* the data into the buffer. Otherwise, the control about the buffer overflow is useless.
*/
-int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen)
+int sock_bufferize(const void *data, int size, char *outbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen)
{
if ((*offset + size) > totsize)
{
@@ -946,7 +945,7 @@ int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int
}
if (!checkonly)
- memcpy(tempbuf + (*offset), buffer, size);
+ memcpy(outbuf + (*offset), data, size);
(*offset) += size;
diff --git a/sockutils.h b/sockutils.h
index e748662e..5e3ac49c 100644
--- a/sockutils.h
+++ b/sockutils.h
@@ -141,7 +141,7 @@ int sock_close(SOCKET sock, char *errbuf, int errbuflen);
int sock_send(SOCKET sock, SSL *, const char *buffer, size_t size,
char *errbuf, int errbuflen);
-int sock_bufferize(const char *buffer, int size, char *tempbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen);
+int sock_bufferize(const void *data, int size, char *outbuf, int *offset, int totsize, int checkonly, char *errbuf, int errbuflen);
int sock_discard(SOCKET sock, SSL *, int size, char *errbuf, int errbuflen);
int sock_check_hostlist(char *hostlist, const char *sep, struct sockaddr_storage *from, char *errbuf, int errbuflen);
int sock_cmpaddr(struct sockaddr_storage *first, struct sockaddr_storage *second);
diff --git a/testprogs/CMakeLists.txt b/testprogs/CMakeLists.txt
index bf573613..567f42aa 100644
--- a/testprogs/CMakeLists.txt
+++ b/testprogs/CMakeLists.txt
@@ -41,7 +41,10 @@ endif()
add_test_executable(threadsignaltest ${CMAKE_THREAD_LIBS_INIT})
-if(NOT WIN32)
+# Same as in configure.ac.
+if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
+ CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
+ CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_test_executable(valgrindtest)
endif()
diff --git a/testprogs/findalldevstest-perf.c b/testprogs/findalldevstest-perf.c
index 40875666..16f53cdc 100644
--- a/testprogs/findalldevstest-perf.c
+++ b/testprogs/findalldevstest-perf.c
@@ -18,10 +18,7 @@
#include "varattrs.h"
#include "pcap/funcattrs.h"
-
-#ifdef _WIN32
#include "portability.h"
-#endif
int main(int argc _U_, char **argv _U_)
{
diff --git a/testprogs/findalldevstest.c b/testprogs/findalldevstest.c
index 092fd045..06293209 100644
--- a/testprogs/findalldevstest.c
+++ b/testprogs/findalldevstest.c
@@ -321,12 +321,12 @@ static int ifprint(pcap_if_t *d)
#define IPTOSBUFFERS 12
static char *iptos(bpf_u_int32 in)
{
- static char output[IPTOSBUFFERS][3*4+3+1];
+ static char output[IPTOSBUFFERS][sizeof("255.255.255.255")];
static short which;
u_char *p;
p = (u_char *)&in;
which = (which + 1 == IPTOSBUFFERS ? 0 : which + 1);
- sprintf(output[which], "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+ snprintf(output[which], sizeof(output[which]), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
return output[which];
}
diff --git a/testprogs/selpolltest.c b/testprogs/selpolltest.c
index 569c8294..ab7f8f46 100644
--- a/testprogs/selpolltest.c
+++ b/testprogs/selpolltest.c
@@ -74,7 +74,7 @@ main(int argc, char **argv)
struct bpf_program fcode;
char ebuf[PCAP_ERRBUF_SIZE];
pcap_if_t *devlist;
- int selectable_fd;
+ int selectable_fd = -1;
const struct timeval *required_timeout;
int status;
int packet_count;