Snap for 8564071 from 27ba7a74f72b429a677c4e712e358b0286d32984 to mainline-extservices-release

Change-Id: Iff73ee4ebf82a6b7360a3b7a10e8bd76a3f339bb
diff --git a/.appveyor.yml b/.appveyor.yml
index 15e1824..001d50c 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -2,6 +2,10 @@
 
 clone_depth: 5
 
+branches:
+  except:
+    - coverity_scan
+
 matrix:
   fast_finish: true
 
@@ -11,8 +15,8 @@
   - 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://nmap.org/npcap/dist/npcap-sdk-1.07.zip
+  - 7z x .\npcap-sdk-1.07.zip -oc:\projects\libpcap\Win32\npcap-sdk-1.07
   - 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 @@
       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.07
       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 @@
       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.07
     - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
       GENERATOR: "Visual Studio 14 2015 Win64"
-      SDK: npcap-sdk-1.05
+      SDK: npcap-sdk-1.07
       AIRPCAP: -DDISABLE_AIRPCAP=YES
     - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
       GENERATOR: "Visual Studio 15 2017"
@@ -52,15 +56,15 @@
       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.07
       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.07
       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.07
       AIRPCAP: -DDISABLE_AIRPCAP=NO
     - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
       GENERATOR: "Visual Studio 16 2019"
@@ -75,17 +79,17 @@
     - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
       GENERATOR: "Visual Studio 16 2019"
       PLATFORM: Win32
-      SDK: npcap-sdk-1.05
+      SDK: npcap-sdk-1.07
       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.07
       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.07
       AIRPCAP: -DDISABLE_AIRPCAP=NO
 
 build_script:
diff --git a/.cirrus.yml b/.cirrus.yml
index 0f71d89..e150cbb 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -1,25 +1,80 @@
 # 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-11-4
+        cpu: 2
+        memory: 2G
+      - image_family: freebsd-12-2
+        cpu: 2
+        memory: 2G
+      - image_family: freebsd-13-0
+        cpu: 4
+        memory: 4G
+  env:
+    IGNORE_OSVERSION: yes
+    MAKEFLAGS: -j 4
+    MATRIX_CC: clang gcc48 gcc10
   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
+    - pkg install -qy autoconf gcc48 gcc10
+    - pkg install -qy bash cmake git # 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:
+    - 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
+    - apt-get -qy install cmake git # 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
+    COVERITY_SCAN_BRANCH_PATTERN: $CIRRUS_BRANCH
+    TRAVIS_BRANCH: $CIRRUS_BRANCH
+    TRAVIS_PULL_REQUEST: ${CIRRUS_BASE_BRANCH:+true}
+  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'
+    - ./.travis-coverity-scan-build.sh
diff --git a/.travis-coverity-scan-build.sh b/.travis-coverity-scan-build.sh
old mode 100644
new mode 100755
index 892dac1..7ea1dac
--- a/.travis-coverity-scan-build.sh
+++ b/.travis-coverity-scan-build.sh
@@ -3,14 +3,14 @@
 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"
+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_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`
+PLATFORM=$(uname)
 TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz
 TOOL_URL=https://scan.coverity.com/download/cxx/${PLATFORM}
 TOOL_BASE=/tmp/coverity-scan-analysis
@@ -19,98 +19,98 @@
 
 # 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"
+printf "\033[33;1mTesting '%s' condition... " "$COVERITY_SCAN_RUN_CONDITION"
+if eval [ "$COVERITY_SCAN_RUN_CONDITION" ]; then
+  printf "True.\033[0m\n"
 else
-  echo -e "False. Exit.\033[0m"
+  printf "False. Exit.\033[0m\n"
   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"
+  printf "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m\n"
   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"`
+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"
+  printf "\033[33;1mCoverity Scan configured to run on branch %s\033[0m\n" "$TRAVIS_BRANCH"
 else
-  echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m"
+  printf "\033[33;1mCoverity Scan NOT configured to run on branch %s\033[0m\n" "$TRAVIS_BRANCH"
   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`
+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"
+  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']"`
+  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"
+    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']"`
-    echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m"
+    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
-    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"
+  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
-  echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m"
+  printf "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m\n"
   mkdir -p $TOOL_BASE
-  pushd $TOOL_BASE
-  tar xzf $TOOL_ARCHIVE
-  popd
+  tar xzf "$TOOL_ARCHIVE" -C "$TOOL_BASE"
 fi
 
-TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'`
+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"
+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}"
-COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $COV_BUILD_OPTIONS $COVERITY_SCAN_BUILD_COMMAND
+# Do not quote COV_BUILD_OPTIONS so it collapses when it is empty and expands
+# when it is not.
+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"
+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`
+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"
+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
 
-echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m"
+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 project="$COVERITY_SCAN_PROJECT_NAME" \
+  --form token="$COVERITY_SCAN_TOKEN" \
   --form email=blackhole@blackhole.io \
   --form file=@$RESULTS_ARCHIVE \
-  --form version=$SHA \
+  --form version="$SHA" \
   --form description="$VERSION_SHA" \
   $UPLOAD_URL)
 status_code=$(echo "$response" | sed -n '$p')
-if [ "$status_code" != "201" ]; then
+if [ "$status_code" != "200" ] && [ "$status_code" != "201" ]; then
   TEXT=$(echo "$response" | sed '$d')
-  echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m"
+  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/.travis.yml b/.travis.yml
deleted file mode 100644
index b840a66..0000000
--- 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 4dd30f1..874e2f2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,110 +1,210 @@
+Wednesday, June 9, 2011:
+  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
-    Require, and assume, some level of C99 support in the C compiler
-    Require Visual Studio 2015 or later if using Visual Studio
     Add support for capturing on DPDK devices
-    rpcap: support rpcap-over-TLS
-    Windows: report the system error for PacketSetHwFilter() failures
     Label most APIs by the first release in which they're available
-    Add support for getting and setting packet time stamp types
-        with Npcap
-    Add pcap_init(), and add support for UTF-8 strings, including error
-        messages, on Windows
-    Improve man pages, including adding backward compatibility notes
-    Fix configure script issues, including with libnl on Linux
-    Fix CMake issues
-    Squelch complaints from Bison about "%define api.pure" being
-        deprecated
     Fix some memory leaks, including in pcap_compile()
-    Linux: handle systems without AF_INET or AF_UNIX socket support
-    Catch invalid IPv4 addresses in filters
-    AIX: fix loading of BPF kernel extension
-    rpcapd: fix core dumps with invalid configuration file
-    Show special Linux BPF offsets symbolically in bpf_image() and
-        bpf_dump()
-    Add some overflow checks in the optimizer
     Add pcap_datalink_val_to_description_or_dlt()
-    Windows: make the snapshot length work even if pcap_setfilter()
-        isn't called
-    Linux: get rid of Wireless Extensions for turning monitor mode on
     Handle the pcap private data in a fashion that makes fewer
        assumptions about memory layouts (might fix GitHub issue #940
        on ARM)
-    Fix "unknown ether proto 'aarp'"
-    Fix some issues found by cppcheck.
-    Linux: proper memory sync for PACKET_MMAP (may prevent GitHub issue
-        #898)
-    Remove undocumented and rather old "ether proto" protocols
     Fix some thread safety issues
-    Windows: add pcap_handle(), and deprecate pcap_fileno()
-    AirPcap: add AirPcap support in a module, rather than using
-        WinPcap/Npcap's support for it
-    Linux: drop support for libnl 1 and 2.
-    Linux: Require PF_PACKET support, and kernel 2.6.27 or later
-    Add DLT_LINUX_SLL2
-    Add a new filter "ifindex" for DLT_LINUX_SLL2 files and live
-        Linux captures
-    optimizer: add a hack to try to catch certain optimizer loops
-        (should prevent GitHub issue #112)
-    Probe CONFIGURATION descriptor of connected USB devices
-    macOS: cope with getting EPWROFF from SIOCGIFMEDIA
-    Linux: return error on interface going away, but not if it just went
-        down
-    Windows: fix compilation on Cygwin/MSYS
-    Linux: set socket protocol only after packet ring configured,
-        reducing bogus packet drop reports
     pcap_findalldevs(): don't sort interfaces by unit number
-    Linux: get ifdrop stats from sysfs.
-    Fix various security issues reported by Charles Smith at Tangible
-        Security
-    Fix various security issues reported by Include Security
-    rpcapd: on UN*X, don't tell the client why authentication failed
-    Linux: when adjusting BPF programs, do not subtract the
-        SLL[2]_HDR_LEN if the location is negative (special metadata
-        offset)
-    Preserve references to metadata when adjusting the program;
-        see https://github.com/the-tcpdump-group/tcpdump/issues/480#issuecomment-486827278
     Always return a list of supported time-stamp types, even if only
         host time stamps are supported
-    Linux: with a timeout of zero, wait indefinitely
-    Linux: clean up support for some non-GNU libc C libraries
     Increase the maximum snaplen for LINKTYPE_USBPCAP/DLT_USBPCAP
-    Fix handling of some ioctls that fail with "permission denied" even
-        when the ioctl isn't supported at all
-    Added support for ICMPv6 types 1-4 as tokens in filters
-    Windows: Report PCAP_ERROR_NO_SUCH_DEVICE for a non-existent device
-    Windows: return an appropriate error message for device removed or
-        device unusable due to a suspend/resume
-    BPF: treat both ENXIO (everybody but OpenBSD) and EIO (OpenBSD) as
-        meaning "the interface was removed"
-    BPF: report "the interface disappeared", not "the interface went
-        down", if the interface was removed during a capture
-    Linux, Windows: report a warning for unknown link-layer header types
-    Create the file in pcap_dump_open_append() if it doesn't exist
-    Linux, NPF: have pcap_breakloop() forcibly break out of a sleeping
-        capture loop
     Report the DLT description in error messages
-    Linux: Add support for DSA data link types
-    Linux USB: use the snapshot length to set the buffer size, and set
-        the len field to reflect the length in the URB (GitHub issue
-        #808)
-    rpcapd: allow rpcapd to rebind more rapidly (GitHub issue #765)
-    Windows: clean up building DLL
-    Fix compilation of pcap-tc.c
-    Add Haiku pcap implementation
-    Windows: handle CRT mismatch for pcap_dump_fopen()
-    Windows: map NdisMediumWirelessWan to DLT_RAW
-    rpcap: add some new authentication libpcap error codes for
-        specific errors
-    rpcap: 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)
-    rpcap: error handling cleanups
-    rpcapd: fix some inetd issues
-    Don't assume ARM supports unaligned accesses
-    Remove (unused) SITA support here.
-    Correctly handle pcapng captures with more than one IDB with a
-        snspshot length greater than the supported maximum
+    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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50bf171..b83fbbd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -319,7 +319,7 @@
     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)
@@ -405,6 +405,42 @@
 #
 # 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)
+{
+	int i = 17;
+	return __atomic_load_n(&i, __ATOMIC_RELAXED);
+}
+"
+            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)
+
+#
+# Now check for various system functions.
+#
 check_function_exists(strerror HAVE_STRERROR)
 check_function_exists(strerror_r HAVE_STRERROR_R)
 if(HAVE_STRERROR_R)
@@ -2072,7 +2108,7 @@
     # "%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()
@@ -2084,17 +2120,11 @@
 
 #
 # 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
 )
 
@@ -2510,14 +2540,14 @@
     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)
@@ -2596,17 +2626,19 @@
     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)
     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)
@@ -2624,22 +2656,22 @@
         # 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)
@@ -2649,7 +2681,6 @@
 # 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/INSTALL.md b/INSTALL.md
index ba8b8f9..feef03d 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -260,7 +260,7 @@
 	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
diff --git a/METADATA b/METADATA
index 5b6bbae..7a7b0b7 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.10.0.tar.gz"
+    value: "https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.10.1.tar.gz"
   }
-  version: "libpcap-1.10.0"
+  version: "libpcap-1.10.1"
   license_type: NOTICE
   last_upgrade_date {
     year: 2021
-    month: 1
-    day: 5
+    month: 8
+    day: 20
   }
 }
diff --git a/Makefile-devel-adds b/Makefile-devel-adds
index fea63bb..7cfd6c9 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 d8b8507..5d88ea7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -79,7 +79,7 @@
 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
@@ -530,7 +530,7 @@
 	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 +591,13 @@
 # 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 +729,7 @@
 	#
 
 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 +786,12 @@
 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 +799,8 @@
 	    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)
@@ -823,9 +823,12 @@
 	@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 build.sh build_matrix.sh
diff --git a/README.md b/README.md
index 1e3a245..d89e3bb 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 @@
 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 @@
 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 @@
 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 aae24c2..65e166b 100644
--- a/TODO
+++ b/TODO
@@ -31,5 +31,3 @@
   + 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 81c871d..4dae298 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.10.0
+1.10.1
diff --git a/aclocal.m4 b/aclocal.m4
index 786423b..2fd29fe 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -662,6 +662,48 @@
     fi
     AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
 
+FFF
+
+#
+# Test whether we have __atomic_load_n() and __atomic_store_n().
+#
+# 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
diff --git a/bpf_filter.c b/bpf_filter.c
index 22d2558..8691d0d 100644
--- a/bpf_filter.c
+++ b/bpf_filter.c
@@ -87,11 +87,11 @@
 #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 0000000..e14ea68
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+
+# This script runs one build with setup environment variables: CC, CMAKE and
+# REMOTE (default: CC=gcc, CMAKE=no, REMOTE=no).
+
+set -e
+
+# CC: gcc or clang
+CC=${CC:-gcc}
+# GCC and Clang recognize --version and print to stdout. Sun compilers
+# recognize -V and print to stderr.
+"$CC" --version 2>/dev/null || "$CC" -V || :
+# CMAKE: no or yes
+CMAKE=${CMAKE:-no}
+# REMOTE: no or yes
+REMOTE=${REMOTE:-no}
+# Install directory prefix
+if [ -z "$PREFIX" ]; then
+    PREFIX=$(mktemp -d -t libpcap_build_XXXXXXXX)
+    echo "PREFIX set to '$PREFIX'"
+    DELETE_PREFIX=yes
+fi
+
+travis_fold() {
+    local action=${1:?}
+    local name=${2:?}
+    if [ "$TRAVIS" != true ]; then return; fi
+    echo -ne "travis_fold:$action:$LABEL.script.$name\\r"
+    sleep 1
+}
+
+# Run a command after displaying it
+run_after_echo() {
+    echo -n '$ '
+    echo "$@"
+    # shellcheck disable=SC2068
+    $@
+}
+
+# LABEL is needed to build the travis fold labels
+LABEL="$CC.$CMAKE.$REMOTE"
+if [ "$CMAKE" = no ]; then
+    echo '$ ./configure [...]'
+    travis_fold start configure
+    ./configure --prefix="$PREFIX" --enable-remote="$REMOTE"
+    travis_fold end configure
+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
+    rm -rf CMakeFiles/ CMakeCache.txt
+    [ ! -d build ] && mkdir build
+    cd build
+    echo '$ cmake [...]'
+    travis_fold start cmake
+    cmake -DCMAKE_INSTALL_PREFIX="$PREFIX" -DENABLE_REMOTE="$REMOTE" ..
+    travis_fold end cmake
+fi
+run_after_echo "make -s clean"
+run_after_echo "make -s"
+run_after_echo "make -s testprogs"
+echo '$ make install'
+travis_fold start make_install
+make install
+travis_fold end make_install
+if [ "$CMAKE" = no ]; then
+    run_after_echo "testprogs/findalldevstest"
+else
+    run_after_echo "run/findalldevstest"
+fi
+if [ "$CMAKE" = no ]; then
+    system=$(uname -s)
+    if [ "$system" = Darwin ] || [ "$system" = Linux ]; then
+        run_after_echo "make releasetar"
+    fi
+fi
+if [ "$TRAVIS" = true ]; then
+    echo '$ cat Makefile [...]'
+    travis_fold start cat_makefile
+    sed '/^# DO NOT DELETE THIS LINE -- mkdep uses it.$/q' < Makefile
+    travis_fold end cat_makefile
+    echo '$ cat config.h'
+    travis_fold start cat_config_h
+    cat config.h
+    travis_fold end cat_config_h
+    if [ "$CMAKE" = no ]; then
+        echo '$ cat config.log'
+        travis_fold start cat_config_log
+        cat config.log
+        travis_fold end cat_config_log
+    fi
+fi
+if [ "$DELETE_PREFIX" = yes ]; then
+    rm -rf "$PREFIX"
+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 0000000..9b4fad5
--- /dev/null
+++ b/build_matrix.sh
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+
+# This script executes the matrix loops, exclude tests and cleaning.
+# The matrix can be configured with environment variables MATRIX_CC,
+# MATRIX_CMAKE and MATRIX_REMOTE (default: MATRIX_CC='gcc clang',
+# MATRIX_CMAKE='no yes', MATRIX_REMOTE='no yes').
+# It calls the build.sh script which runs one build with setup environment
+# variables : CC, CMAKE and REMOTE (default: CC=gcc, CMAKE=no, REMOTE=no).
+
+set -e
+
+# ANSI color escape sequences
+ANSI_MAGENTA="\\033[35;1m"
+ANSI_RESET="\\033[0m"
+uname -a
+date
+# Install directory prefix
+if [ -z "$PREFIX" ]; then
+    PREFIX=$(mktemp -d -t libpcap_build_matrix_XXXXXXXX)
+    echo "PREFIX set to '$PREFIX'"
+    export PREFIX
+fi
+COUNT=0
+
+travis_fold() {
+    local action=${1:?}
+    local name=${2:?}
+    if [ "$TRAVIS" != true ]; then return; fi
+    echo -ne "travis_fold:$action:$LABEL.script.$name\\r"
+    sleep 1
+}
+
+# Display text in magenta
+echo_magenta() {
+    echo -ne "$ANSI_MAGENTA"
+    echo "$@"
+    echo -ne "$ANSI_RESET"
+}
+
+touch .devel configure
+for CC in ${MATRIX_CC:-gcc clang}; do
+    export CC
+    # Exclude gcc on macOS (it is just an alias for clang).
+    if [ "$CC" = gcc ] && [ "$(uname -s)" = Darwin ]; then
+        echo '(skipped)'
+        continue
+    fi
+    for CMAKE in ${MATRIX_CMAKE:-no yes}; do
+        export CMAKE
+        for REMOTE in ${MATRIX_REMOTE:-no yes}; do
+            export REMOTE
+            COUNT=$((COUNT+1))
+            echo_magenta "===== SETUP $COUNT: CC=$CC CMAKE=$CMAKE REMOTE=$REMOTE ====="
+            # LABEL is needed to build the travis fold labels
+            LABEL="$CC.$CMAKE.$REMOTE"
+            # Run one build with setup environment variables: CC, CMAKE and REMOTE
+            ./build.sh
+            echo 'Cleaning...'
+            travis_fold start cleaning
+            if [ "$CMAKE" = yes ]; then rm -rf build; else make distclean; fi
+            rm -rf "${PREFIX:?}"/*
+            git status -suall
+            # Cancel changes in configure
+            git checkout configure
+            travis_fold end cleaning
+        done
+    done
+done
+rm -rf "$PREFIX"
+echo_magenta "Tested setup count: $COUNT"
+# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
diff --git a/cmake/Modules/FindPacket.cmake b/cmake/Modules/FindPacket.cmake
index 900c8e3..7253d22 100644
--- a/cmake/Modules/FindPacket.cmake
+++ b/cmake/Modules/FindPacket.cmake
@@ -63,8 +63,26 @@
   # 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
diff --git a/cmake/Modules/Finddpdk.cmake b/cmake/Modules/Finddpdk.cmake
index 50eafd9..c51b1f3 100644
--- a/cmake/Modules/Finddpdk.cmake
+++ b/cmake/Modules/Finddpdk.cmake
@@ -21,13 +21,13 @@
 )
   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 192209c..ee51ac6 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -259,6 +259,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 7f74817..1972fda 100755
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2020 Free Software Foundation, Inc.
+#   Copyright 1992-2021 Free Software Foundation, Inc.
 
-timestamp='2020-12-22'
+timestamp='2021-01-25'
 
 # 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
@@ -50,7 +50,7 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2020 Free Software Foundation, Inc.
+Copyright 1992-2021 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."
@@ -188,10 +188,9 @@
 	#
 	# 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
 	    aarch64eb) machine=aarch64_be-unknown ;;
@@ -1087,7 +1086,7 @@
     ppcle:Linux:*:*)
 	echo powerpcle-unknown-linux-"$LIBC"
 	exit ;;
-    riscv32:Linux:*:* | riscv64:Linux:*:*)
+    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
 	echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
 	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
@@ -1483,8 +1482,8 @@
     i*86:rdos:*:*)
 	echo "$UNAME_MACHINE"-pc-rdos
 	exit ;;
-    i*86:AROS:*:*)
-	echo "$UNAME_MACHINE"-pc-aros
+    *:AROS:*:*)
+	echo "$UNAME_MACHINE"-unknown-aros
 	exit ;;
     x86_64:VMkernel:*:*)
 	echo "$UNAME_MACHINE"-unknown-esx
diff --git a/config.h b/config.h
index aa23c6a..8f73307 100644
--- a/config.h
+++ b/config.h
@@ -59,7 +59,9 @@
 /* #undef HAVE_GETSPNAM */
 
 /* Define to 1 if you have a GNU-style `strerror_r' function. */
-#define HAVE_GNU_STRERROR_R /**/
+#ifndef ANDROID_HOST_MUSL
+#define HAVE_GNU_STRERROR_R 1
+#endif
 
 /* on HP-UX 10.20 or later */
 /* #undef HAVE_HPUX10_20_OR_LATER */
diff --git a/config.h.in b/config.h.in
index 00618ae..a1e371a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -262,6 +262,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 90bb8ae..7f7d0b0 100755
--- a/config.sub
+++ b/config.sub
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2020 Free Software Foundation, Inc.
+#   Copyright 1992-2021 Free Software Foundation, Inc.
 
-timestamp='2020-12-22'
+timestamp='2021-03-10'
 
 # 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
@@ -67,7 +67,7 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2020 Free Software Foundation, Inc.
+Copyright 1992-2021 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."
@@ -1230,7 +1230,7 @@
 			| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
 			| pru \
 			| pyramid \
-			| riscv | riscv32 | riscv64 \
+			| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
 			| rl78 | romp | rs6000 | rx \
 			| s390 | s390x \
 			| score \
@@ -1683,11 +1683,14 @@
 
 # Now, validate our (potentially fixed-up) OS.
 case $os in
-	# Sometimes we do "kernel-abi", so those need to count as OSes.
+	# Sometimes we do "kernel-libc", so those need to count as OSes.
 	musl* | newlib* | uclibc*)
 		;;
-	# Likewise for "kernel-libc"
-	eabi | eabihf | gnueabi | gnueabihf)
+	# 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.
@@ -1709,7 +1712,7 @@
 	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
 	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
 	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
-	     | chorusrdb* | cegcc* | glidix* \
+	     | chorusrdb* | cegcc* | glidix* | serenity* \
 	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
 	     | midipix* | mingw32* | mingw64* | mint* \
 	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
@@ -1751,6 +1754,8 @@
 		;;
 	kfreebsd*-gnu* | kopensolaris*-gnu*)
 		;;
+	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
+		;;
 	nto-qnx*)
 		;;
 	os2-emx)
diff --git a/configure b/configure
index fd57219..15a5e68 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.
+# Generated by GNU Autoconf 2.69 for pcap 1.10.1.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@
 # Identity of this package.
 PACKAGE_NAME='pcap'
 PACKAGE_TARNAME='pcap'
-PACKAGE_VERSION='1.10.0'
-PACKAGE_STRING='pcap 1.10.0'
+PACKAGE_VERSION='1.10.1'
+PACKAGE_STRING='pcap 1.10.1'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -666,8 +666,7 @@
 AR
 RANLIB
 REENTRANT_PARSER
-YFLAGS
-YACC
+BISON_BYACC
 LEXLIB
 LEX_OUTPUT_ROOT
 LEX
@@ -779,9 +778,7 @@
 CXX
 CXXFLAGS
 CCC
-CPP
-YACC
-YFLAGS'
+CPP'
 
 
 # Initialize some variables set by options.
@@ -1332,7 +1329,7 @@
   # 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 to adapt to many kinds of systems.
+\`configure' configures pcap 1.10.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1399,7 +1396,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pcap 1.10.0:";;
+     short | recursive ) echo "Configuration of pcap 1.10.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1466,12 +1463,6 @@
   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.
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -1539,7 +1530,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pcap configure 1.10.0
+pcap configure 1.10.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1629,52 +1620,6 @@
 
 } # 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.
@@ -2099,7 +2044,7 @@
 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, which was
+It was created by pcap $as_me 1.10.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4512,6 +4457,125 @@
 _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.
 #
@@ -8526,18 +8590,27 @@
 
 #
 # 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
@@ -8546,7 +8619,7 @@
   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
@@ -8556,46 +8629,118 @@
 
 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
 	#
-	# 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.
+	# We found Bison.
 	#
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc" >&5
+	# Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
+	# "%pure-parser".
+	#
+	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.
+	#
+	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 $? "$YACC is insufficient to compile libpcap.
+ libpcap requires Bison, a newer version of Berkeley YACC with support
+ for reentrant parsers, or another YACC compatible with them." "$LINENO" 5
+		fi
+	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
@@ -8605,24 +8750,8 @@
 	# "%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
 
 
 #
@@ -12397,7 +12526,7 @@
 # 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, which was
+This file was extended by pcap $as_me 1.10.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -12463,7 +12592,7 @@
 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
+pcap config.status 1.10.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 2ad28bb..edb25ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@
 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.
@@ -1739,27 +1740,68 @@
 
 #
 # 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)
+BISON_BYACC=""
+#
+# Look for Bison.
+#
+AC_CHECK_PROGS(BISON_BYACC, bison)
+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.
+	# We found Bison.
 	#
-	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.
+	# Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
+	# "%pure-parser".
+	#
+	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.
+	#
+	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([$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
+	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
@@ -1769,24 +1811,8 @@
 	# "%pure-parser".
 	#
 	REENTRANT_PARSER="%pure-parser"
-	;;
-
-*)
-	#
-	# 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
+fi
+AC_SUBST(BISON_BYACC)
 AC_SUBST(REENTRANT_PARSER)
 
 #
diff --git a/doc/README.linux.md b/doc/README.linux
similarity index 100%
rename from doc/README.linux.md
rename to doc/README.linux
diff --git a/ftmacros.h b/ftmacros.h
index 3fafab8..3cd7505 100644
--- a/ftmacros.h
+++ b/ftmacros.h
@@ -105,9 +105,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 2978859..efdcb98 100644
--- a/gencode.c
+++ b/gencode.c
@@ -48,6 +48,20 @@
 #include "pcap-dos.h"
 #endif
 
+#ifdef HAVE_NET_PFVAR_H
+/*
+ * In NetBSD <net/if.h> includes <net/dlt.h>, which is an older version of
+ * "pcap/dlt.h" with a lower value of DLT_MATCHING_MAX. Include the headers
+ * below before "pcap-int.h", which eventually includes "pcap/dlt.h", which
+ * redefines DLT_MATCHING_MAX from what this version of NetBSD has to what
+ * this version of libpcap has.
+ */
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/pfvar.h>
+#include <net/if_pflog.h>
+#endif /* HAVE_NET_PFVAR_H */
+
 #include "pcap-int.h"
 
 #include "extract.h"
@@ -73,13 +87,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
@@ -6080,7 +6087,18 @@
 	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
diff --git a/grammar.y.in b/grammar.y.in
index fe56515..2fbd861 100644
--- a/grammar.y.in
+++ b/grammar.y.in
@@ -650,7 +650,7 @@
 						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/pcap-airpcap.c b/pcap-airpcap.c
index 703f23a..d986ad9 100644
--- a/pcap-airpcap.c
+++ b/pcap-airpcap.c
@@ -158,7 +158,7 @@
 	 *	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)
@@ -974,7 +974,14 @@
 	 * 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-bt-linux.c b/pcap-bt-linux.c
index 2969ff8..8e70feb 100644
--- a/pcap-bt-linux.c
+++ b/pcap-bt-linux.c
@@ -341,6 +341,10 @@
 	} 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 ad4fc37..206e65b 100644
--- a/pcap-bt-monitor-linux.c
+++ b/pcap-bt-monitor-linux.c
@@ -127,6 +127,10 @@
     } 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-filter.manmisc.in b/pcap-filter.manmisc.in
index e0f883d..b429690 100644
--- a/pcap-filter.manmisc.in
+++ b/pcap-filter.manmisc.in
@@ -18,7 +18,7 @@
 .\" 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@ "6 February 2021"
 .SH NAME
 pcap-filter \- packet filter syntax
 .br
@@ -246,7 +246,7 @@
 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.
+destination port value between \fIport1\fP and \fIport2\fP (both inclusive).
 .I port1
 and
 .I port2
@@ -256,10 +256,10 @@
 .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:
diff --git a/pcap-int.h b/pcap-int.h
index 3c18dae..dc18d50 100644
--- a/pcap-int.h
+++ b/pcap-int.h
@@ -40,9 +40,18 @@
 
 #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"
+
 /*
  * Version string.
  * Uses PACKAGE_VERSION from config.h.
@@ -80,11 +89,6 @@
  */
 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 +437,6 @@
 
 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 +592,7 @@
  * 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 +602,7 @@
  * 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.
diff --git a/pcap-linux.c b/pcap-linux.c
index 7481689..878f27f 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -117,6 +117,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) \
@@ -3880,7 +3893,7 @@
 	}
 
 	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;
diff --git a/pcap-npf.c b/pcap-npf.c
index f12c701..52aee78 100644
--- a/pcap-npf.c
+++ b/pcap-npf.c
@@ -543,27 +543,53 @@
 		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,
@@ -874,7 +900,8 @@
 
 	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 +939,27 @@
 	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)
 {
@@ -1175,19 +1223,51 @@
 
 		if (PacketSetHwFilter(pw->adapter,NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)
 		{
-			pcap_fmt_errmsg_for_win32_err(p->errbuf,
-			    PCAP_ERRBUF_SIZE, GetLastError(),
-			    "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 |
@@ -1195,10 +1275,19 @@
 			NDIS_PACKET_TYPE_BROADCAST |
 			NDIS_PACKET_TYPE_MULTICAST) == FALSE)
 		{
-			pcap_fmt_errmsg_for_win32_err(p->errbuf,
-			    PCAP_ERRBUF_SIZE, GetLastError(),
-			    "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;
+			}
 		}
 	}
 
@@ -1509,7 +1598,7 @@
 			}
 			if (modes[0] != num_ts_modes) {
 				snprintf(ebuf, PCAP_ERRBUF_SIZE,
-				    "First PacketGetTimestampModes() call gives %lu modes, second call gives %u modes",
+				    "First PacketGetTimestampModes() call gives %lu modes, second call gives %lu modes",
 				    num_ts_modes, modes[0]);
 				free(modes);
 				pcap_close(p);
diff --git a/pcap-rpcap.c b/pcap-rpcap.c
index a2612e9..0c6c558 100644
--- a/pcap-rpcap.c
+++ b/pcap-rpcap.c
@@ -1003,11 +1003,10 @@
 	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;
 	}
@@ -2992,10 +2991,10 @@
 	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;
 	}
 
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index 3596428..ee8834f 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 @@
 
 /* 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 @@
 	DIR* dir;
 	int n;
 	char* name;
-	size_t len;
 
-	if (have_binary_usbmon()) {
+	/*
+	 * 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) {
 		/*
-		 * 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.
+		 * This "shouldn't happen".  Just give up if it
+		 * does.
 		 */
-		pcap_strlcpy(usb_mon_dir, LINUX_USB_MON_DEV, sizeof usb_mon_dir);
-		usb_mon_prefix = strrchr(usb_mon_dir, '/');
-		if (usb_mon_prefix == NULL) {
-			/*
-			 * This "shouldn't happen".  Just give up if it
-			 * does.
-			 */
-			return 0;
-		}
-		*usb_mon_prefix++ = '\0';
-		usb_mon_prefix_len = strlen(usb_mon_prefix);
-
-		/*
-		 * Open the directory and scan it.
-		 */
-		dir = opendir(usb_mon_dir);
-		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;
-
-				ret = usb_dev_add(devlistp, n, err_str);
-			}
-
-			closedir(dir);
-			return 0;
-		}
-
-		/* 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);
-			}
-
-			closedir(dir);
-			return ret;
-		}
-
-		/* neither of them worked */
 		return 0;
 	}
+	*usb_mon_prefix++ = '\0';
+	usb_mon_prefix_len = strlen(usb_mon_prefix);
+
+	/*
+	 * Open the directory and scan it.
+	 */
+	dir = opendir(usb_mon_dir);
+	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;
 }
 
 /*
@@ -630,7 +476,6 @@
 {
 	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,168 +508,99 @@
 		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) {
+			return PCAP_ERROR_NO_SUCH_DEVICE;
 
-			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;
-
-			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;
-		}
+			return PCAP_ERROR_PERM_DENIED;
 
-		/* 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
-
+		default:
 			/*
-			 * "handle->fd" is a real file, so
-			 * "select()" and "poll()" work on it.
+			 * Something went wrong.
 			 */
-			handle->selectable_fd = handle->fd;
-			return 0;
-		}
-
-		/*
-		 * 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);
+			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)
+	{
+		/*
+		 * Monitor mode doesn't apply to USB devices.
+		 */
+		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->stats_op = usb_stats_linux;
-		handle->read_op = usb_read_linux;
+		handle->selectable_fd = handle->fd;
+		return 0;
 	}
 
 	/*
+	 * 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()"
 	 * work on it.
 	 */
@@ -842,219 +618,6 @@
 	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 @@
 }
 
 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 @@
 	return 0;
 }
 
-
 static int
 usb_stats_linux_bin(pcap_t *handle, struct pcap_stat *stats)
 {
diff --git a/pcap/bpf.h b/pcap/bpf.h
index ccb93cc..54373af 100644
--- a/pcap/bpf.h
+++ b/pcap/bpf.h
@@ -81,6 +81,8 @@
 
 #include <pcap/funcattrs.h>
 
+#include <pcap/dlt.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -117,10 +119,6 @@
 	struct bpf_insn *bf_insns;
 };
 
-#include <pcap/dlt.h>
-
-#ifndef __LINUX_FILTER_H__
-
 /*
  * The instruction encodings.
  *
@@ -241,8 +239,6 @@
 /*				0xf0	reserved */
 /*				0xf8	reserved */
 
-#endif /* __LINUX_FILTER_H__ */
-
 /*
  * The instruction data structure.
  */
@@ -253,16 +249,25 @@
 	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);
 
diff --git a/pcap/funcattrs.h b/pcap/funcattrs.h
index cdc083d..a2ca542 100644
--- a/pcap/funcattrs.h
+++ b/pcap/funcattrs.h
@@ -189,7 +189,8 @@
 #define PCAP_AVAILABLE_1_7	PCAP_AVAILABLE_MACOS(10.12)
 #define PCAP_AVAILABLE_1_8	PCAP_AVAILABLE_MACOS(10.13) /* only Windows adds routines to the API; XXX - what version first had it? */
 #define PCAP_AVAILABLE_1_9	PCAP_AVAILABLE_MACOS(10.13)
-#define PCAP_AVAILABLE_1_10	/* not released yet, so not in macOS yet */
+#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
@@ -208,6 +209,7 @@
 #define PCAP_AVAILABLE_1_8
 #define PCAP_AVAILABLE_1_9
 #define PCAP_AVAILABLE_1_10
+#define PCAP_AVAILABLE_1_11
 #endif /* __APPLE__ */
 
 /*
diff --git a/portability.h b/portability.h
index d606368..84d0778 100644
--- a/portability.h
+++ b/portability.h
@@ -112,6 +112,30 @@
 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/daemon.c b/rpcapd/daemon.c
index 620dec3..e2b20a9 100644
--- a/rpcapd/daemon.c
+++ b/rpcapd/daemon.c
@@ -375,7 +375,7 @@
 				// 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)
@@ -2421,7 +2421,7 @@
 	// 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);
diff --git a/sf-pcapng.c b/sf-pcapng.c
index f7f413d..3fd366c 100644
--- a/sf-pcapng.c
+++ b/sf-pcapng.c
@@ -101,7 +101,8 @@
 
 /*
  * 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 @@
 		 * 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);
diff --git a/sockutils.c b/sockutils.c
index c1ec9a5..ca16bbf 100644
--- a/sockutils.c
+++ b/sockutils.c
@@ -527,7 +527,7 @@
 }
 
 /*
- * 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*
diff --git a/testprogs/findalldevstest-perf.c b/testprogs/findalldevstest-perf.c
index 4087566..16f53cd 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 092fd04..0629320 100644
--- a/testprogs/findalldevstest.c
+++ b/testprogs/findalldevstest.c
@@ -321,12 +321,12 @@
 #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 569c829..ab7f8f4 100644
--- a/testprogs/selpolltest.c
+++ b/testprogs/selpolltest.c
@@ -74,7 +74,7 @@
 	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;