Merge "Upgrade to libpcap 1.9.1"
diff --git a/.appveyor.yml b/.appveyor.yml
new file mode 100644
index 0000000..a644151
--- /dev/null
+++ b/.appveyor.yml
@@ -0,0 +1,36 @@
+version: '{build}'
+
+clone_depth: 5
+
+matrix:
+  fast_finish: true
+
+install:
+  - cinst winflexbison
+  - win_flex --version
+  - win_bison --version
+  - appveyor DownloadFile http://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-0.1.zip
+  - 7z x .\npcap-sdk-0.1.zip -oc:\projects\libpcap\Win32
+
+environment:
+  matrix:
+    - GENERATOR: "Visual Studio 12 2013"
+      SDK: WpdPack
+    - GENERATOR: "Visual Studio 12 2013 Win64"
+      SDK: WpdPack
+    - GENERATOR: "Visual Studio 12 2013"
+      SDK: npcap-sdk-0.1
+    - GENERATOR: "Visual Studio 12 2013 Win64"
+      SDK: npcap-sdk-0.1
+
+build_script:
+  #
+  # Appveyor defaults to cmd.exe, so use cmd.exe syntax.
+  #
+  - type NUL >.devel
+  - md build
+  - cd build
+  - cmake -DCMAKE_PREFIX_PATH=c:\projects\libpcap\Win32\%SDK% -G"%GENERATOR%" ..
+  - msbuild /m /nologo /p:Configuration=Release pcap.sln
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..a7ff19e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,5 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# things that only make sense on github.com
+.github export-ignore
diff --git a/.travis-coverity-scan-build.sh b/.travis-coverity-scan-build.sh
new file mode 100644
index 0000000..892dac1
--- /dev/null
+++ b/.travis-coverity-scan-build.sh
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+set -e
+
+# Environment check
+echo -e "\033[33;1mNote: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com\033[0m"
+[ -z "$COVERITY_SCAN_PROJECT_NAME" ] && echo "ERROR: COVERITY_SCAN_PROJECT_NAME must be set" && exit 1
+#[ -z "$COVERITY_SCAN_NOTIFICATION_EMAIL" ] && echo "ERROR: COVERITY_SCAN_NOTIFICATION_EMAIL must be set" && exit 1
+[ -z "$COVERITY_SCAN_BRANCH_PATTERN" ] && echo "ERROR: COVERITY_SCAN_BRANCH_PATTERN must be set" && exit 1
+[ -z "$COVERITY_SCAN_BUILD_COMMAND" ] && echo "ERROR: COVERITY_SCAN_BUILD_COMMAND must be set" && exit 1
+[ -z "$COVERITY_SCAN_TOKEN" ] && echo "ERROR: COVERITY_SCAN_TOKEN must be set" && exit 1
+
+PLATFORM=`uname`
+TOOL_ARCHIVE=/tmp/cov-analysis-${PLATFORM}.tgz
+TOOL_URL=https://scan.coverity.com/download/cxx/${PLATFORM}
+TOOL_BASE=/tmp/coverity-scan-analysis
+UPLOAD_URL="https://scan.coverity.com/builds"
+SCAN_URL="https://scan.coverity.com"
+
+# Verify Coverity Scan run condition
+COVERITY_SCAN_RUN_CONDITION=${coverity_scan_run_condition:-true}
+echo -ne "\033[33;1mTesting '${COVERITY_SCAN_RUN_CONDITION}' condition... "
+if eval [ $COVERITY_SCAN_RUN_CONDITION ]; then
+  echo -e "True.\033[0m"
+else
+  echo -e "False. Exit.\033[0m"
+  exit 0
+fi
+
+# Do not run on pull requests
+if [ "${TRAVIS_PULL_REQUEST}" = "true" ]; then
+  echo -e "\033[33;1mINFO: Skipping Coverity Analysis: branch is a pull request.\033[0m"
+  exit 0
+fi
+
+# Verify this branch should run
+IS_COVERITY_SCAN_BRANCH=`ruby -e "puts '${TRAVIS_BRANCH}' =~ /\\A$COVERITY_SCAN_BRANCH_PATTERN\\z/ ? 1 : 0"`
+if [ "$IS_COVERITY_SCAN_BRANCH" = "1" ]; then
+  echo -e "\033[33;1mCoverity Scan configured to run on branch ${TRAVIS_BRANCH}\033[0m"
+else
+  echo -e "\033[33;1mCoverity Scan NOT configured to run on branch ${TRAVIS_BRANCH}\033[0m"
+  exit 1
+fi
+
+# Verify upload is permitted
+AUTH_RES=`curl -s --form project="$COVERITY_SCAN_PROJECT_NAME" --form token="$COVERITY_SCAN_TOKEN" $SCAN_URL/api/upload_permitted`
+if [ "$AUTH_RES" = "Access denied" ]; then
+  echo -e "\033[33;1mCoverity Scan API access denied. Check COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN.\033[0m"
+  exit 1
+else
+  AUTH=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['upload_permitted']"`
+  if [ "$AUTH" = "true" ]; then
+    echo -e "\033[33;1mCoverity Scan analysis authorized per quota.\033[0m"
+  else
+    WHEN=`echo $AUTH_RES | ruby -e "require 'rubygems'; require 'json'; puts JSON[STDIN.read]['next_upload_permitted_at']"`
+    echo -e "\033[33;1mCoverity Scan analysis NOT authorized until $WHEN.\033[0m"
+    exit 0
+  fi
+fi
+
+if [ ! -d $TOOL_BASE ]; then
+  # Download Coverity Scan Analysis Tool
+  if [ ! -e $TOOL_ARCHIVE ]; then
+    echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m"
+    wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
+  fi
+
+  # Extract Coverity Scan Analysis Tool
+  echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m"
+  mkdir -p $TOOL_BASE
+  pushd $TOOL_BASE
+  tar xzf $TOOL_ARCHIVE
+  popd
+fi
+
+TOOL_DIR=`find $TOOL_BASE -type d -name 'cov-analysis*'`
+export PATH=$TOOL_DIR/bin:$PATH
+
+# Build
+echo -e "\033[33;1mRunning Coverity Scan Analysis Tool...\033[0m"
+COV_BUILD_OPTIONS=""
+#COV_BUILD_OPTIONS="--return-emit-failures 8 --parse-error-threshold 85"
+RESULTS_DIR="cov-int"
+eval "${COVERITY_SCAN_BUILD_COMMAND_PREPEND}"
+COVERITY_UNSUPPORTED=1 cov-build --dir $RESULTS_DIR $COV_BUILD_OPTIONS $COVERITY_SCAN_BUILD_COMMAND
+cov-import-scm --dir $RESULTS_DIR --scm git --log $RESULTS_DIR/scm_log.txt 2>&1
+
+# Upload results
+echo -e "\033[33;1mTarring Coverity Scan Analysis results...\033[0m"
+RESULTS_ARCHIVE=analysis-results.tgz
+tar czf $RESULTS_ARCHIVE $RESULTS_DIR
+SHA=`git rev-parse --short HEAD`
+VERSION_SHA=$(cat VERSION)#$SHA
+
+# Verify Coverity Scan script test mode
+if [ "$coverity_scan_script_test_mode" = true ]; then
+  echo -e "\033[33;1mCoverity Scan configured in script test mode. Exit.\033[0m"
+  exit 0
+fi
+
+echo -e "\033[33;1mUploading Coverity Scan Analysis results...\033[0m"
+response=$(curl \
+  --silent --write-out "\n%{http_code}\n" \
+  --form project=$COVERITY_SCAN_PROJECT_NAME \
+  --form token=$COVERITY_SCAN_TOKEN \
+  --form email=blackhole@blackhole.io \
+  --form file=@$RESULTS_ARCHIVE \
+  --form version=$SHA \
+  --form description="$VERSION_SHA" \
+  $UPLOAD_URL)
+status_code=$(echo "$response" | sed -n '$p')
+if [ "$status_code" != "201" ]; then
+  TEXT=$(echo "$response" | sed '$d')
+  echo -e "\033[33;1mCoverity Scan upload failed: $TEXT.\033[0m"
+  exit 1
+fi
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..086765f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,85 @@
+sudo: false
+language: c
+
+os:
+  - linux
+  - osx
+
+compiler:
+  - gcc
+  - clang
+
+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_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
+  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:
+      - libusb-1.0-0-dev
+      - libdbus-glib-1-dev
+      - libbluetooth-dev
+      - libnl-genl-3-dev
+      - libibverbs-dev
+
+git:
+  quiet: true
+  depth: 3
+
+before_install:
+  - uname -a
+  - date
+
+install:
+
+before_script:
+
+script:
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then touch .devel configure; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = no ]; then echo '$ ./configure [...]' && echo -n travis_fold:start:script.configure; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = no ]; then ./configure --prefix=/tmp "--${REMOTE}-remote"; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = yes ]; then mkdir build; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = yes ]; then cd build; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = yes ]; then cmake -DCMAKE_INSTALL_PREFIX=/tmp $ENABLE_REMOTE ..; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then echo -n travis_fold:end:script.configure; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make -s all; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then make -s testprogs; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then echo '$ make install [...]' && echo -n travis_fold:start:script.make_install; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then PATH=$PATH make install; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then echo -n travis_fold:end:script.make_install; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = no ]; then testprogs/findalldevstest; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = yes ]; then run/findalldevstest; fi
+  - if [ "$COVERITY_SCAN_BRANCH" != 1 -a "$CMAKE" = no ]; then make releasetar; fi
diff --git a/Android.bp b/Android.bp
index eb0ea10..b00facb 100644
--- a/Android.bp
+++ b/Android.bp
@@ -65,6 +65,11 @@
     ],
 
     target: {
+        linux: {
+            srcs: [
+                "missing/strlcpy.c",
+            ],
+        },
         darwin: {
             enabled: false,
         },
diff --git a/CHANGES b/CHANGES
index 4607f14..89e739c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,75 @@
+Sunday, July 22, 2018
+  Summary for 1.9.1 libpcap release
+    Mention pcap_get_required_select_timeout() in the main pcap man page
+    Fix pcap-usb-linux.c build on systems with musl
+    Fix assorted man page and other documentation issues
+    Plug assorted memory leaks
+    Documentation changes to use https:
+    Changes to how time stamp calculations are done
+    Lots of tweaks to make newer compilers happier and warning-free and
+        to fix instances of C undefined behavior
+    Warn if AC_PROG_CC_C99 can't enable C99 support
+    Rename pcap_set_protocol() to  pcap_set_protocol_linux().
+    Align pcap_t private data on an 8-byte boundary.
+    Fix various error messages
+    Use 64-bit clean API in dag_findalldevs()
+    Fix cleaning up after some errors
+    Work around some ethtool ioctl bugs in newer Linux kernels (GitHub
+        issue #689)
+    Add backwards compatibility sections to some man pages (GitHub issue
+        #745)
+    Fix autotool configuration on AIX and macOS
+    Don't export bpf_filter_with_aux_data() or struct bpf_aux_data;
+        they're internal-only and subject to change
+    Fix pcapng block size checking
+    On macOS, don't build rpcapd or test programs any fatter than they
+        need to be
+    Fix reading of capture statistics for Linux USB
+    Fix packet size values for Linux USB packets (GitHub issue #808)
+    Check only VID in VLAN test in filterss (GitHub issue #461)
+    Fix pcap_list_datalinks on 802.11 devices on macOS
+    Fix overflows with very large snapshot length in pcap file
+    Improve parsing of rpcapd configuration file (GitHub issue #767)
+    Handle systems without strlcpy() or strlcat() better
+    Fix crashes and other errors with invalid filter expressions
+    Fix use of uninitialized file descriptor in remote capture
+    Fix some CMake issues
+    Fix some divide-by-zero issues with the filter compiler
+    Work around a GNU libc bug in pcap_nametonetaddr()
+    Add support for DLT_LINUX_SLL2
+    Fix handling of the packet-count argument for Myricom SNF devices
+    Fix --disable-rdma in configure script (GitHub issue #782)
+    Fix compilation of TurboCap support (GitHub issue #764)
+    Constify first argument to pcap_findalldevs_ex()
+    Fix a number of issues when running rpcapd as an inetd-style daemon
+    Fix CMake issues with D-Bus libraries
+    In rpcapd, clean up termination of a capture session
+    Redo remote capture protocol negotiation
+    In rpcapd, report the same error for "invalid user name" and
+        "invalid password", to make brute-forcing harder
+    For remote captures, add an error code for "the server requires TLS"
+    Fix pcap_dump_fopen() on Windows to avoid clashes between
+        {Win,N}Pcap and application C runtimes
+    Fix exporting of functions from Windows DLLs (GitHub issue #810)
+    Fix building as part of Npcap
+    Allow rpcapd to rebind more rapidly
+    Fix building shared libpcap library on midipix (midipix.org)
+    Fix hack to detect UTF-16LE adapter names on Windows not to go past
+        the end of the string
+    Fix handling of "wireless WAN" (mobile phone network modems) on
+        Windows with WinPcap/Npcap (GitHub issue #824)
+    Have pcap_dump_open_append() create the dump file if it doesn't
+        exists (GitHub issue #247)
+    Fix the maxmum snapshot length for DLT_USBPCAP
+    Use -fPIC when building for 64-bit SPARC on Linux (GitHub issue #837)
+    Fix CMake 64-bit library installation directory on some Linux
+        distributions
+    Boost the TPACKET_V3 timeout to the maximum if a timeout of 0 was
+        specified
+    Five CVE-2019-15161, CVE-2019-15162, CVE-2019-15163, CVE-2019-15164, CVE-2019-15165
+    Fixes for CVE-2018-16301, errors in pcapng reading.
+    PCAPNG reader applies some sanity checks before doing malloc().
+
 Sunday, June 24, 2018, by mcr@sandelman.ca
   Summary for 1.9.0 libpcap release
     Added testing system to libpcap, independent of tcpdump
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 905ba61..55b93f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,7 @@
     cmake_policy(SET CMP0042 OLD)
 endif()
 
-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
 
 project(pcap)
 
@@ -136,83 +136,6 @@
 endif()
 
 #
-# By default, build universal with the appropriate set of architectures
-# for the OS on which we're doing the build.
-#
-if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
-    #
-    # Get the major version of Darwin.
-    #
-    string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}")
-
-    if(SYSTEM_VERSION_MAJOR LESS 8)
-        #
-        # Pre-Tiger.  Build only for 32-bit PowerPC.
-        #
-        set(CMAKE_OSX_ARCHITECTURES "ppc")
-    elseif(SYSTEM_VERSION_MAJOR EQUAL 8)
-        #
-        # Tiger.  Is this prior to, or with, Intel support?
-        #
-        # Get the minor version of Darwin.
-        #
-        string(REPLACE "${SYSTEM_VERSION_MAJOR}." "" SYSTEM_MINOR_AND_PATCH_VERSION ${CMAKE_SYSTEM_VERSION})
-        string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MINOR "${SYSTEM_MINOR_AND_PATCH_VERSION}")
-        if(SYSTEM_VERSION_MINOR LESS 4)
-            #
-            # Prior to Intel support.  Build for 32-bit
-            # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
-            # first.  (I'm guessing that's what Apple does.)
-            #
-            set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64")
-        elseif(SYSTEM_VERSION_MINOR LESS 7)
-            #
-            # With Intel support but prior to x86-64 support.
-            # Build for 32-bit PowerPC, 64-bit PowerPC, and x86,
-            # with 32-bit PowerPC first.
-            # (I'm guessing that's what Apple does.)
-            #
-            set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64;i386")
-        else()
-            #
-            # With Intel support including x86-64 support.
-            # Build for 32-bit PowerPC, 64-bit PowerPC, x86,
-            # and x86-64, with 32-bit PowerPC first.
-            # (I'm guessing that's what Apple does.)
-            #
-            set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64;i386;x86_64")
-        endif()
-    elseif(SYSTEM_VERSION_MAJOR EQUAL 9)
-        #
-        # Leopard.  Build for 32-bit PowerPC, 64-bit
-        # PowerPC, x86, and x86-64, with 32-bit PowerPC
-        # first.  (That's what Apple does.)
-        #
-        set(CMAKE_OSX_ARCHITECTURES "ppc;ppc64;i386;x86_64")
-    elseif(SYSTEM_VERSION_MAJOR EQUAL 10)
-        #
-        # Snow Leopard.  Build for x86-64, x86, and
-        # 32-bit PowerPC, with x86-64 first.  (That's
-        # what Apple does, even though Snow Leopard
-        # doesn't run on PPC, so PPC libpcap runs under
-        # Rosetta, and Rosetta doesn't support BPF
-        # ioctls, so PPC programs can't do live
-        # captures.)
-        #
-        set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc")
-    else()
-        #
-        # Post-Snow Leopard.  Build for x86-64 and
-        # x86, with x86-64 first.  (That's probably what
-        # Apple does, given that Rosetta is gone.)
-        # XXX - update if and when Apple drops support
-        # for 32-bit x86 code.
-        #
-        set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
-    endif()
-endif()
-
-#
 # Additional capture modules.
 #
 option(DISABLE_USB "Disable USB sniffing support" OFF)
@@ -233,7 +156,7 @@
 option(DISABLE_DAG "Disable Endace DAG card support" OFF)
 
 option(DISABLE_SEPTEL "Disable Septel card support" OFF)
-set(SEPTEL_ROOT "${CMAKE_SOURCE_DIR}/../septel" CACHE PATH "Path to directory with include and lib subdirectories for Septel API")
+set(SEPTEL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../septel" CACHE PATH "Path to directory with include and lib subdirectories for Septel API")
 
 option(DISABLE_SNF "Disable Myricom SNF support" OFF)
 
@@ -289,6 +212,7 @@
 
 include(CheckFunctionExists)
 include(CMakePushCheckState)
+include(CheckSymbolExists)
 
 if(WIN32)
 
@@ -310,6 +234,14 @@
         cmake_pop_check_state()
     endif(PACKET_FOUND)
 
+    message(STATUS "checking for Npcap's version.h")
+    check_symbol_exists(WINPCAP_PRODUCT_NAME "../../version.h" HAVE_VERSION_H)
+    if(HAVE_VERSION_H)
+	    message(STATUS "HAVE version.h")
+    else(HAVE_VERSION_H)
+	    message(STATUS "MISSING version.h")
+    endif(HAVE_VERSION_H)
+
 endif(WIN32)
 
 if(MSVC)
@@ -344,6 +276,11 @@
 include(CheckTypeSize)
 
 #
+# Tests are a bit expensive with Visual Studio on Windows, so, on
+# Windows, we skip tests for UN*X-only headers and functions.
+#
+
+#
 # Header files.
 #
 check_include_file(inttypes.h HAVE_INTTYPES_H)
@@ -395,12 +332,44 @@
 #
 check_function_exists(strerror HAVE_STRERROR)
 check_function_exists(strerror_r HAVE_STRERROR_R)
-check_function_exists(strerror_s HAVE_STRERROR_S)
+if(HAVE_STRERROR_R)
+    #
+    # We have strerror_r; if we define _GNU_SOURCE, is it a
+    # POSIX-compliant strerror_r() or a GNU strerror_r()?
+    #
+    check_c_source_compiles(
+"#define _GNU_SOURCE
+#include <string.h>
+
+/* Define it GNU-style; that will cause an error if it's not GNU-style */
+extern char *strerror_r(int, char *, size_t);
+
+int
+main(void)
+{
+	return 0;
+}
+"
+            HAVE_GNU_STRERROR_R)
+    if(NOT HAVE_GNU_STRERROR_R)
+        set(HAVE_POSIX_STRERROR_R YES)
+    endif(NOT HAVE_GNU_STRERROR_R)
+else(HAVE_STRERROR_R)
+    #
+    # We don't have strerror_r; do we have strerror_s?
+    #
+    check_function_exists(strerror_s HAVE_STRERROR_S)
+endif(HAVE_STRERROR_R)
 check_function_exists(strlcpy HAVE_STRLCPY)
 check_function_exists(strlcat HAVE_STRLCAT)
 check_function_exists(snprintf HAVE_SNPRINTF)
 check_function_exists(vsnprintf HAVE_VSNPRINTF)
+check_function_exists(asprintf HAVE_ASPRINTF)
+check_function_exists(vasprintf HAVE_VASPRINTF)
 check_function_exists(strtok_r HAVE_STRTOK_R)
+if(NOT WIN32)
+    check_function_exists(vsyslog HAVE_VSYSLOG)
+endif()
 
 #
 # These tests are for network applications that need socket functions
@@ -429,7 +398,6 @@
 #
 set(PCAP_LINK_LIBRARIES "")
 include(CheckLibraryExists)
-include(CheckSymbolExists)
 if(WIN32)
     #
     # We need winsock2.h and ws2tcpip.h.
@@ -865,11 +833,61 @@
 )
 
 if(WIN32)
-    set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/win_snprintf.c)
+    #
+    # For now, we assume we don't have snprintf() or that it's not one
+    # that behaves enough like C99's snprintf() for our purposes (i.e.,
+    # it doesn't null-terminate the string if it truncates it to fit in
+    # the buffer), so we have to provide our own (a wrapper around
+    # _snprintf() that null-terminates the buffer).
+    #
+    # We also assume we don't have asprintf(), and provide an implementation
+    # that uses _vscprintf() to determine how big the string needs to be.
+    #
+    set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C}
+        missing/win_snprintf.c missing/win_asprintf.c)
 else()
+    #
+    # Either:
+    #
+    #	we have snprintf() and vsnprintf(), and have asprintf() and
+    #	vasprintf();
+    #
+    #	we have snprintf() and vsnprintf(), but don't have asprintf()
+    #	or vasprintf();
+    #
+    #	we have neither snprintf() nor vsnprintf(), and don't have
+    #	asprintf() or vasprintf(), either.
+    #
+    # We assume that if we have asprintf() we have vasprintf(), as well
+    # as snprintf() and vsnprintf(), and that if we have snprintf() we
+    # have vsnprintf().
+    #
+    # For the first case, we don't need any replacement routines.
+    # For the second case, we need replacement asprintf()/vasprintf()
+    # routines.
+    # For the third case, we need replacement snprintf()/vsnprintf() and
+    # asprintf()/vasprintf() routines.
+    #
     if(NOT HAVE_SNPRINTF)
+        #
+        # We assume we have none of them; missing/snprintf.c supplies
+        # all of them.
+        #
         set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c)
-    endif(NOT HAVE_SNPRINTF)
+    elif(NOT HAVE_ASPRINTF)
+        #
+        # We assume we have snprintf()/vsnprintf() but lack
+        # asprintf()/vasprintf(); missing/asprintf.c supplies
+        # the latter (using vsnprintf()).
+        #
+        set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/asprintf.c)
+    endif()
+    if(NOT HAVE_STRLCAT)
+        set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strlcat.c)
+    endif(NOT HAVE_STRLCAT)
+    if(NOT HAVE_STRLCPY)
+        set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strlcpy.c)
+    endif(NOT HAVE_STRLCPY)
     if(NOT HAVE_STRTOK_R)
         set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strtok_r.c)
     endif(NOT HAVE_STRTOK_R)
@@ -931,13 +949,16 @@
             # as it's a Linux, it should use packet sockets,
             # instead.
             #
-            #
             # We need:
             #
             #  sys/types.h, because FreeBSD 10's net/bpf.h
             #  requires that various BSD-style integer types
             #  be defined;
             #
+            #  sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
+            #  doesn't include it but does use struct timeval
+            #  in ioctl definitions;
+            #
             #  sys/ioctl.h and, if we have it, sys/ioccom.h,
             #  because net/bpf.h defines ioctls;
             #
@@ -952,9 +973,9 @@
             # of those headers itself.
             #
             if(HAVE_SYS_IOCCOM_H)
-                check_symbol_exists(BIOCSETIF "sys/types.h;sys/ioctl.h;sys/socket.h;sys/ioccom.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF)
+                check_symbol_exists(BIOCSETIF "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;sys/ioccom.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF)
             else(HAVE_SYS_IOCCOM_H)
-                check_symbol_exists(BIOCSETIF "sys/types.h;sys/ioctl.h;sys/socket.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF)
+                check_symbol_exists(BIOCSETIF "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF)
             endif(HAVE_SYS_IOCCOM_H)
         endif(HAVE_NET_BPF_H)
         check_include_file(net/pfilt.h HAVE_NET_PFILT_H)
@@ -1436,7 +1457,28 @@
         set(PCAP_SUPPORT_DBUS TRUE)
         set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dbus.c)
         include_directories(${DBUS_INCLUDE_DIRS})
-        set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DBUS_LIBRARIES})
+
+        #
+        # This "helpfully" supplies DBUS_LIBRARIES as a bunch of
+        # library names - not paths - and DBUS_LIBRARY_DIRS as
+        # a bunch of directories.
+        #
+        # CMake *really* doesn't like the notion of specifying "here are
+        # the directories in which to look for libraries" except in
+        # find_library() calls; it *really* prefers using full paths to
+        # library files, rather than library names.
+        #
+        # Find the libraries and add their full paths.
+        #
+        set(DBUS_LIBRARY_FULLPATHS)
+        foreach(_lib IN LISTS DBUS_LIBRARIES)
+            #
+            # Try to find this library, so we get its full path.
+            #
+            find_library(_libfullpath ${_lib} HINTS ${DBUS_LIBRARY_DIRS})
+            list(APPEND DBUS_LIBRARY_FULLPATHS ${_libfullpath})
+        endforeach()
+        set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DBUS_LIBRARY_FULLPATHS})
     endif(DBUS_FOUND)
 endif(NOT DISABLE_DBUS)
 
@@ -1582,7 +1624,7 @@
     # the check.
     #
     cmake_push_check_state()
-    set(CMAKE_REQUIRED_INCLUDES ${CMAKE_SOURCE_DIR})
+    set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
     check_struct_has_member("struct msghdr" msg_control "ftmacros.h;sys/socket.h" HAVE_STRUCT_MSGHDR_MSG_CONTROL)
     check_struct_has_member("struct msghdr" msg_flags "ftmacros.h;sys/socket.h" HAVE_STRUCT_MSGHDR_MSG_FLAGS)
     cmake_pop_check_state()
@@ -1597,7 +1639,7 @@
 #
 # Check and add warning options if we have a .devel file.
 #
-if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel)
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel)
     #
     # Warning options.
     #
@@ -1808,10 +1850,12 @@
 
 #
 # Assume, by default, no support for shared libraries and V7/BSD
-# convention for man pages (file formats in section 5, miscellaneous
-# info in section 7, administrative commands and daemons in section 8).
+# convention for man pages (devices in section 4, file formats in
+# section 5, miscellaneous info in section 7, administrative commands
+# and daemons in section 8).  Individual cases can override this.
 # Individual cases can override this.
 #
+set(MAN_DEVICES 4)
 set(MAN_FILE_FORMATS 5)
 set(MAN_MISC_INFO 7)
 set(MAN_ADMIN_COMMANDS 8)
@@ -1869,6 +1913,7 @@
     #
     set(MAN_FILE_FORMATS 4)
     set(MAN_MISC_INFO 5)
+    set(MAN_DEVICES 7)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
     #
     # SunOS 5.x.
@@ -1892,6 +1937,7 @@
         set(MAN_ADMIN_COMMANDS 1m)
         set(MAN_FILE_FORMATS 4)
         set(MAN_MISC_INFO 5)
+        set(MAN_DEVICES 7D)
     endif()
 endif()
 
@@ -1944,6 +1990,16 @@
     add_dependencies(${LIBRARY_NAME} SerializeTarget)
     set_target_properties(${LIBRARY_NAME} PROPERTIES
         COMPILE_DEFINITIONS BUILDING_PCAP)
+    #
+    # No matter what the library is called - it might be called "wpcap"
+    # in a Windows build - the symbol to define to indicate that we're
+    # building the library, rather than a program using the library,
+    # and thus that we're exporting functions defined in our public
+    # header files, rather than importing those functions, is
+    # pcap_EXPORTS.
+    #
+    set_target_properties(${LIBRARY_NAME} PROPERTIES
+        DEFINE_SYMBOL pcap_EXPORTS)
 endif(BUILD_SHARED_LIBS)
 
 add_library(${LIBRARY_NAME}_static STATIC
@@ -2020,6 +2076,118 @@
     set_target_properties(${LIBRARY_NAME}_static PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
 endif()
 
+#
+# On macOS, build libpcap for the appropriate architectures, if
+# CMAKE_OSX_ARCHITECTURES isn't set (if it is, let that control
+# the architectures for which to build it).
+#
+if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
+    #
+    # Get the major version of Darwin.
+    #
+    string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}")
+
+    if(SYSTEM_VERSION_MAJOR LESS 8)
+        #
+        # Pre-Tiger.  Build only for 32-bit PowerPC.
+        #
+        set(OSX_LIBRARY_ARCHITECTURES "ppc")
+    elseif(SYSTEM_VERSION_MAJOR EQUAL 8)
+        #
+        # Tiger.  Is this prior to, or with, Intel support?
+        #
+        # Get the minor version of Darwin.
+        #
+        string(REPLACE "${SYSTEM_VERSION_MAJOR}." "" SYSTEM_MINOR_AND_PATCH_VERSION ${CMAKE_SYSTEM_VERSION})
+        string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MINOR "${SYSTEM_MINOR_AND_PATCH_VERSION}")
+        if(SYSTEM_VERSION_MINOR LESS 4)
+            #
+            # Prior to Intel support.  Build for 32-bit
+            # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
+            # first.  (I'm guessing that's what Apple does.)
+            #
+            set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64")
+        elseif(SYSTEM_VERSION_MINOR LESS 7)
+            #
+            # With Intel support but prior to x86-64 support.
+            # Build for 32-bit PowerPC, 64-bit PowerPC, and 32-bit x86,
+            # with 32-bit PowerPC first.
+            # (I'm guessing that's what Apple does.)
+            #
+            set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64;i386")
+        else()
+            #
+            # With Intel support including x86-64 support.
+            # Build for 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
+            # and x86-64, with 32-bit PowerPC first.
+            # (I'm guessing that's what Apple does.)
+            #
+            set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64;i386;x86_64")
+        endif()
+    elseif(SYSTEM_VERSION_MAJOR EQUAL 9)
+        #
+        # Leopard.  Build for 32-bit PowerPC, 64-bit
+        # PowerPC, 32-bit x86, and x86-64, with 32-bit PowerPC
+        # first.  (That's what Apple does.)
+        #
+        set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64;i386;x86_64")
+    elseif(SYSTEM_VERSION_MAJOR EQUAL 10)
+        #
+        # Snow Leopard.  Build for x86-64, 32-bit x86, and
+        # 32-bit PowerPC, with x86-64 first.  (That's
+        # what Apple does, even though Snow Leopard
+        # doesn't run on PPC, so PPC libpcap runs under
+        # Rosetta, and Rosetta doesn't support BPF
+        # ioctls, so PPC programs can't do live
+        # captures.)
+        #
+        set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386;ppc")
+    else()
+        #
+        # Post-Snow Leopard.  Build for x86-64 and 32-bit x86,
+        # with x86-64 first.  (That's what Apple does)
+        # XXX - update if and when Apple drops support
+        # for 32-bit x86 code and if and when Apple adds
+        # ARM-based Macs.  (You're on your own for iOS etc.)
+        #
+        # XXX - check whether we *can* build for i386 and, if not,
+        # suggest that the user install the /usr/include headers if
+        # they want to build fat.
+        #
+        cmake_push_check_state()
+        set(CMAKE_REQUIRED_FLAGS "-arch i386")
+        check_c_source_compiles(
+"int
+main(void)
+{
+    return 0;
+}
+"
+                   X86_32_BIT_SUPPORTED)
+        cmake_pop_check_state()
+        if(X86_32_BIT_SUPPORTED)
+            set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386")
+        else()
+            set(OSX_LIBRARY_ARCHITECTURES "x86_64")
+            if(SYSTEM_VERSION_MAJOR LESS 18)
+                #
+                # Pre-Mojave; the command-line tools should be sufficient to
+                # enable 32-bit x86 builds.
+                #
+                message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools")
+            else()
+                message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package")
+            endif()
+        endif()
+    endif()
+    if(BUILD_SHARED_LIBS)
+        set_target_properties(${LIBRARY_NAME} PROPERTIES
+            OSX_ARCHITECTURES "${OSX_LIBRARY_ARCHITECTURES}")
+    endif(BUILD_SHARED_LIBS)
+    set_target_properties(${LIBRARY_NAME}_static PROPERTIES
+        OSX_ARCHITECTURES "${OSX_LIBRARY_ARCHITECTURES}")
+endif()
+
 ######################################
 # Write out the config.h file
 ######################################
@@ -2079,6 +2247,7 @@
     pcap_list_tstamp_types.3pcap.in
     pcap_open_dead.3pcap.in
     pcap_open_offline.3pcap.in
+    pcap_set_immediate_mode.3pcap.in
     pcap_set_tstamp_precision.3pcap.in
     pcap_set_tstamp_type.3pcap.in
 )
@@ -2114,7 +2283,6 @@
     pcap_open_live.3pcap
     pcap_set_buffer_size.3pcap
     pcap_set_datalink.3pcap
-    pcap_set_immediate_mode.3pcap
     pcap_set_promisc.3pcap
     pcap_set_protocol_linux.3pcap
     pcap_set_rfmon.3pcap
@@ -2179,7 +2347,7 @@
         endif(NOT MINGW)
     endif(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
 else(WIN32)
-    install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} DESTINATION lib)
+    install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 endif(WIN32)
 
 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pcap/ DESTINATION include/pcap)
@@ -2225,8 +2393,8 @@
     foreach(LIB ${PCAP_LINK_LIBRARIES})
         set(LIBS "${LIBS} -l${LIB}")
     endforeach(LIB)
-    configure_file(${CMAKE_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY)
-    configure_file(${CMAKE_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY)
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY)
+    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY)
     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pcap-config DESTINATION bin)
     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc DESTINATION lib/pkgconfig)
 
@@ -2238,17 +2406,17 @@
     #
     set(MAN1 "")
     foreach(MANPAGE ${MAN1_NOEXPAND})
-        set(MAN1 ${MAN1} ${CMAKE_SOURCE_DIR}/${MANPAGE})
+        set(MAN1 ${MAN1} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE})
     endforeach(MANPAGE)
     install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
 
     set(MAN3PCAP "")
     foreach(MANPAGE ${MAN3PCAP_NOEXPAND})
-        set(MAN3PCAP ${MAN3PCAP} ${CMAKE_SOURCE_DIR}/${MANPAGE})
+        set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE})
     endforeach(MANPAGE)
     foreach(TEMPLATE_MANPAGE ${MAN3PCAP_EXPAND})
         string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE})
-        configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
+        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
         set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
     endforeach(TEMPLATE_MANPAGE)
     install(FILES ${MAN3PCAP} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
@@ -2272,7 +2440,7 @@
     set(MANFILE "")
     foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND})
         string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE})
-        configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
+        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
         set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
     endforeach(TEMPLATE_MANPAGE)
     install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS})
@@ -2280,7 +2448,7 @@
     set(MANMISC "")
     foreach(TEMPLATE_MANPAGE ${MANMISC_EXPAND})
         string(REPLACE ".manmisc.in" ".${MAN_MISC_INFO}" MANPAGE ${TEMPLATE_MANPAGE})
-        configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
+        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
         set(MANMISC ${MANMISC} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
     endforeach(TEMPLATE_MANPAGE)
     install(FILES ${MANMISC} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_MISC_INFO})
diff --git a/CREDITS b/CREDITS
index 8b7e7ce..f7abc1f 100644
--- a/CREDITS
+++ b/CREDITS
@@ -129,7 +129,7 @@
     Olaf Kirch                    <okir at caldera dot de>
     Ollie Wild                    <aaw at users dot sourceforge dot net>
     Onno van der Linden           <onno at simplex dot nl>
-    Paolo Abeni                   <paolo dot abeni at email dot it> and redhat dot com
+    Paolo Abeni                   <pabeni at redhat dot com>
     Patrick Marie                 <mycroft at virgaria dot org>
     Patrick McHardy               <kaber at trash not net>
     Paul Mundt                    <lethal at linux-sh dot org>
diff --git a/INSTALL.md b/INSTALL.md
index 96c87a2..3a303fe 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -266,15 +266,14 @@
 doc/README.septel   - notes on using libpcap to capture on Intel/Septel devices
 doc/README.sita	- notes on using libpcap to capture on SITA devices
 doc/README.tru64	- notes on using libpcap on Digital/Tru64 UNIX
-doc/README.Win32	- notes on using libpcap on Win32 systems (with WinPcap)
+doc/README.Win32	- notes on using libpcap on Win32 systems (with Npcap)
 VERSION		- version of this release
 acconfig.h	- support for post-2.13 autoconf
 aclocal.m4	- autoconf macros
 arcnet.h	- ARCNET definitions
 atmuni31.h	- ATM Q.2931 definitions
-bpf/net		- copy of bpf_filter.c
 bpf_dump.c	- BPF program printing routines
-bpf_filter.c	- symlink to bpf/net/bpf_filter.c
+bpf_filter.c	- BPF filtering routines
 bpf_image.c	- BPF disassembly routine
 config.guess	- autoconf support
 config.h.in	- autoconf input
diff --git a/METADATA b/METADATA
index 7137657..1515513 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.9.0.tar.gz"
+    value: "https://github.com/the-tcpdump-group/libpcap/archive/libpcap-1.9.1.tar.gz"
   }
-  version: "libcap-1.9.0"
+  version: "libcap-1.9.1"
   license_type: RESTRICTED
   last_upgrade_date {
-    year: 2018
-    month: 7
-    day: 22
+    year: 2020
+    month: 4
+    day: 23
   }
 }
diff --git a/Makefile.in b/Makefile.in
index dff75ec..5a6b165 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -69,7 +69,7 @@
 EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@
 
 # Standard CFLAGS for building members of a shared library
-FULL_CFLAGS = $(CCOPT) $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
+FULL_CFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
 
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -117,6 +117,7 @@
 	pcap/nflog.h \
 	pcap/pcap.h \
 	pcap/sll.h \
+	pcap/socket.h \
 	pcap/vlan.h \
 	pcap/usb.h
 
@@ -168,6 +169,7 @@
 	pcap_list_tstamp_types.3pcap.in \
 	pcap_open_dead.3pcap.in \
 	pcap_open_offline.3pcap.in \
+	pcap_set_immediate_mode.3pcap.in \
 	pcap_set_tstamp_precision.3pcap.in \
 	pcap_set_tstamp_type.3pcap.in
 
@@ -203,7 +205,6 @@
 	pcap_open_live.3pcap \
 	pcap_set_buffer_size.3pcap \
 	pcap_set_datalink.3pcap \
-	pcap_set_immediate_mode.3pcap \
 	pcap_set_promisc.3pcap \
 	pcap_set_protocol_linux.3pcap \
 	pcap_set_rfmon.3pcap \
@@ -276,10 +277,14 @@
 	lbl/os-sunos4.h \
 	lbl/os-ultrix4.h \
 	libpcap.pc.in \
+	missing/asprintf.c \
 	missing/getopt.c \
 	missing/getopt.h \
 	missing/snprintf.c \
+	missing/strlcat.c \
+	missing/strlcpy.c \
 	missing/strtok_r.c \
+	missing/win_asprintf.c \
 	missing/win_snprintf.c \
 	mkdep \
 	msdos/bin2c.c \
@@ -347,12 +352,13 @@
 	rpcapd/fileconf.c \
 	rpcapd/fileconf.h \
 	rpcapd/log.h \
-	rpcapd/log-stderr.c \
+	rpcapd/log.c \
 	rpcapd/org.tcpdump.rpcapd.plist \
 	rpcapd/rpcapd.c \
 	rpcapd/rpcapd.h \
 	rpcapd/rpcapd.inetd.conf \
 	rpcapd/rpcapd.manadmin.in \
+	rpcapd/rpcapd-config.manfile.in \
 	rpcapd/rpcapd.rc \
 	rpcapd/rpcapd.socket \
 	rpcapd/rpcapd.xinetd.conf \
@@ -417,7 +423,7 @@
 	MAJOR_VER=A; \
 	COMPAT_VER=1; \
 	CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
-	$(CC) -dynamiclib -undefined error $(LDFLAGS) \
+	$(CC) -dynamiclib -undefined error $(LDFLAGS) @V_LIB_LDFLAGS_FAT@ \
 	    -o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
 	    -install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
 	    -compatibility_version $$COMPAT_VER \
@@ -489,9 +495,18 @@
 gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
 	$(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
 
+asprintf.o: $(srcdir)/missing/asprintf.c
+	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/asprintf.c
+
 snprintf.o: $(srcdir)/missing/snprintf.c
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
 
+strlcat.o: $(srcdir)/missing/strlcat.c
+	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
+
+strlcpy.o: $(srcdir)/missing/strlcpy.c
+	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
+
 strtok_r.o: $(srcdir)/missing/strtok_r.c
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
 
@@ -575,6 +590,9 @@
 	rm -f pcap_datalink_val_to_description.3pcap && \
 	$(LN_S) pcap_datalink_val_to_name.3pcap \
 		 pcap_datalink_val_to_description.3pcap && \
+	rm -f pcap_datalink_val_to_description_or_dlt.3pcap && \
+	$(LN_S) pcap_datalink_val_to_name.3pcap \
+		 pcap_datalink_val_to_description_or_dlt.3pcap && \
 	rm -f pcap_dump_fopen.3pcap && \
 	$(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
 	rm -f pcap_freealldevs.3pcap && \
diff --git a/VERSION b/VERSION
index f8e233b..9ab8337 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.9.0
+1.9.1
diff --git a/aclocal.m4 b/aclocal.m4
index ac163d4..aa91e84 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -484,7 +484,7 @@
 	    aix*)
 		    ;;
 
-	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
+	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|midipix*)
 	    	    #
 		    # Platforms where the linker is the GNU linker
 		    # or accepts command-line arguments like
@@ -501,7 +501,7 @@
 		    sparc64*)
 			case "$host_os" in
 
-			freebsd*|openbsd*)
+			freebsd*|openbsd*|linux*)
 			    PIC_OPT=-fPIC
 			    ;;
 			esac
@@ -878,22 +878,23 @@
 	    #
 	    if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
 		    AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
+		    AC_LBL_CHECK_COMPILER_OPT($1, -W)
 		    AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
 		    AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
 		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter)
+		    AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
 		    # Warns about safeguards added in case the enums are
 		    # extended
 		    # AC_LBL_CHECK_COMPILER_OPT($1, -Wcovered-switch-default)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter)
-		    AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
 		    #
 		    # This can cause problems with ntohs(), ntohl(),
 		    # htons(), and htonl() on some platforms, such
diff --git a/bpf_filter.c b/bpf_filter.c
index 615ed3f..33872ff 100644
--- a/bpf_filter.c
+++ b/bpf_filter.c
@@ -51,7 +51,7 @@
 #include <sys/time.h>
 #endif /* _WIN32 */
 
-#include <pcap/bpf.h>
+#include <pcap-int.h>
 
 #include <stdlib.h>
 
@@ -328,11 +328,17 @@
 			continue;
 
 		case BPF_ALU|BPF_LSH|BPF_X:
-			A <<= X;
+			if (X < 32)
+				A <<= X;
+			else
+				A = 0;
 			continue;
 
 		case BPF_ALU|BPF_RSH|BPF_X:
-			A >>= X;
+			if (X < 32)
+				A >>= X;
+			else
+				A = 0;
 			continue;
 
 		case BPF_ALU|BPF_ADD|BPF_K:
@@ -378,10 +384,13 @@
 		case BPF_ALU|BPF_NEG:
 			/*
 			 * Most BPF arithmetic is unsigned, but negation
-			 * can't be unsigned; throw some casts to
-			 * specify what we're trying to do.
+			 * can't be unsigned; respecify it as subtracting
+			 * the accumulator from 0U, so that 1) we don't
+			 * get compiler warnings about negating an unsigned
+			 * value and 2) don't get UBSan warnings about
+			 * the result of negating 0x80000000 being undefined.
 			 */
-			A = (u_int32)(-(int32)A);
+			A = (0U - A);
 			continue;
 
 		case BPF_MISC|BPF_TAX:
diff --git a/cmake/Modules/FindPacket.cmake b/cmake/Modules/FindPacket.cmake
index 1311cdb..f114875 100644
--- a/cmake/Modules/FindPacket.cmake
+++ b/cmake/Modules/FindPacket.cmake
@@ -49,9 +49,17 @@
 #
 
 # The 64-bit Packet.lib is located under /x64
-set(64BIT_SUBDIR "")
 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-  set(64BIT_SUBDIR "/x64")
+  #
+  # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level
+  # directory contains 32-bit libraries; the 64-bit libraries are in the
+  # Lib/x64 directory.
+  #
+  # The only way to *FORCE* CMake to look in the Lib/x64 directory
+  # without searching in the Lib directory first appears to be to set
+  # CMAKE_LIBRARY_ARCHITECTURE to "x64".
+  #
+  set(CMAKE_LIBRARY_ARCHITECTURE "x64")
 endif()
 
 # Find the header
@@ -64,7 +72,6 @@
 find_library(PACKET_LIBRARY
   NAMES Packet packet
   HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR
-  PATH_SUFFIXES Lib${64BIT_SUBDIR} lib${64BIT_SUBDIR}
 )
 
 # Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE.
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 6760cec..1639925 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -15,6 +15,9 @@
 /* define if we have the AIX getprotobyname_r() */
 #cmakedefine HAVE_AIX_GETPROTOBYNAME_R 1
 
+/* Define to 1 if you have the `asprintf' function. */
+#cmakedefine HAVE_ASPRINTF 1
+
 /* define if you have the DAG API */
 #cmakedefine HAVE_DAG_API 1
 
@@ -48,6 +51,9 @@
 /* Define to 1 if you have the `getspnam' function. */
 #cmakedefine HAVE_GETSPNAM 1
 
+/* Define to 1 if you have a GNU-style `strerror_r' function. */
+#cmakedefine HAVE_GNU_STRERROR_R 1
+
 /* on HP-UX 10.20 or later */
 #cmakedefine HAVE_HPUX10_20_OR_LATER 1
 
@@ -138,9 +144,15 @@
 /* if there's an os_proto.h for this platform, to use additional prototypes */
 #cmakedefine HAVE_OS_PROTO_H 1
 
-/* Define to 1 if Packet32 API (WinPcap NPF driver) is available */
+/* Define to 1 if Packet32 API (Npcap driver) is available */
 #cmakedefine HAVE_PACKET32 1
 
+/* Define to 1 if NPcap's version.h is available */
+#cmakedefine HAVE_VERSION_H 1
+
+/* Define to 1 if you have a POSIX-style `strerror_r' function. */
+#cmakedefine HAVE_POSIX_STRERROR_R 1
+
 /* define if net/pfvar.h defines PF_NAT through PF_NORDR */
 #cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1
 
@@ -174,9 +186,6 @@
 /* Define to 1 if you have the `strerror' function. */
 #cmakedefine HAVE_STRERROR 1
 
-/* Define to 1 if you have the `strerror_r' function. */
-#cmakedefine HAVE_STRERROR_R 1
-
 /* Define to 1 if you have the `strerror_s' function. */
 #cmakedefine HAVE_STRERROR_S 1
 
@@ -256,9 +265,15 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #cmakedefine HAVE_UNISTD_H 1
 
+/* Define to 1 if you have the `vasprintf' function. */
+#cmakedefine HAVE_VASPRINTF 1
+
 /* Define to 1 if you have the `vsnprintf' function. */
 #cmakedefine HAVE_VSNPRINTF 1
 
+/* Define to 1 if you have the `vsyslog' function. */
+#undef HAVE_VSYSLOG
+
 /* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */
 #cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1
 
diff --git a/config.h b/config.h
index 4bae2ec..aa23c6a 100644
--- a/config.h
+++ b/config.h
@@ -16,6 +16,9 @@
 /* define if we have the AIX getprotobyname_r() */
 /* #undef HAVE_AIX_GETPROTOBYNAME_R */
 
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
 /* Define to 1 if you have the <dagapi.h> header file. */
 /* #undef HAVE_DAGAPI_H */
 
@@ -55,6 +58,9 @@
 /* Define to 1 if you have the `getspnam' function. */
 /* #undef HAVE_GETSPNAM */
 
+/* Define to 1 if you have a GNU-style `strerror_r' function. */
+#define HAVE_GNU_STRERROR_R /**/
+
 /* on HP-UX 10.20 or later */
 /* #undef HAVE_HPUX10_20_OR_LATER */
 
@@ -151,6 +157,9 @@
 /* define if net/pfvar.h defines PF_NAT through PF_NORDR */
 /* #undef HAVE_PF_NAT_THROUGH_PF_NORDR */
 
+/* Define to 1 if you have a POSIX-style `strerror_r' function. */
+#define HAVE_POSIX_STRERROR_R 1
+
 /* define if you have the Septel API */
 /* #undef HAVE_SEPTEL_API */
 
@@ -181,9 +190,6 @@
 /* Define to 1 if you have the `strerror' function. */
 #define HAVE_STRERROR 1
 
-/* Define to 1 if you have the `strerror_r' function. */
-#define HAVE_STRERROR_R 1
-
 /* Define to 1 if you have the `strerror_s' function. */
 /* #undef HAVE_STRERROR_S */
 
@@ -267,9 +273,15 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #define HAVE_UNISTD_H 1
 
+/* Define to 1 if you have the `vasprintf' function. */
+#define HAVE_VASPRINTF 1
+
 /* Define to 1 if you have the `vsnprintf' function. */
 #define HAVE_VSNPRINTF 1
 
+/* Define to 1 if you have the `vsyslog' function. */
+#define HAVE_VSYSLOG 1
+
 /* IPv6 */
 #define INET6 1
 
@@ -298,7 +310,7 @@
 #define PACKAGE_NAME "pcap"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "pcap 1.9.0-PRE-GIT"
+#define PACKAGE_STRING "pcap 1.9.1"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "pcap"
@@ -307,7 +319,7 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "1.9.0-PRE-GIT"
+#define PACKAGE_VERSION "1.9.1"
 
 /* target host supports Bluetooth sniffing */
 /* #undef PCAP_SUPPORT_BT */
diff --git a/config.h.in b/config.h.in
index b1a20a4..94db7bb 100644
--- a/config.h.in
+++ b/config.h.in
@@ -15,6 +15,9 @@
 /* define if we have the AIX getprotobyname_r() */
 #undef HAVE_AIX_GETPROTOBYNAME_R
 
+/* Define to 1 if you have the `asprintf' function. */
+#undef HAVE_ASPRINTF
+
 /* Define to 1 if you have the <dagapi.h> header file. */
 #undef HAVE_DAGAPI_H
 
@@ -54,6 +57,9 @@
 /* Define to 1 if you have the `getspnam' function. */
 #undef HAVE_GETSPNAM
 
+/* Define to 1 if you have a GNU-style `strerror_r' function. */
+#undef HAVE_GNU_STRERROR_R
+
 /* on HP-UX 10.20 or later */
 #undef HAVE_HPUX10_20_OR_LATER
 
@@ -150,6 +156,9 @@
 /* define if net/pfvar.h defines PF_NAT through PF_NORDR */
 #undef HAVE_PF_NAT_THROUGH_PF_NORDR
 
+/* Define to 1 if you have a POSIX-style `strerror_r' function. */
+#undef HAVE_POSIX_STRERROR_R
+
 /* define if you have the Septel API */
 #undef HAVE_SEPTEL_API
 
@@ -180,9 +189,6 @@
 /* Define to 1 if you have the `strerror' function. */
 #undef HAVE_STRERROR
 
-/* Define to 1 if you have the `strerror_r' function. */
-#undef HAVE_STRERROR_R
-
 /* Define to 1 if you have the `strerror_s' function. */
 #undef HAVE_STRERROR_S
 
@@ -262,9 +268,15 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
+
 /* Define to 1 if you have the `vsnprintf' function. */
 #undef HAVE_VSNPRINTF
 
+/* Define to 1 if you have the `vsyslog' function. */
+#undef HAVE_VSYSLOG
+
 /* IPv6 */
 #undef INET6
 
diff --git a/configure b/configure
index 9a8c158..fa15fc7 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.9.0-PRE-GIT.
+# Generated by GNU Autoconf 2.69 for pcap 1.9.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.9.0-PRE-GIT'
-PACKAGE_STRING='pcap 1.9.0-PRE-GIT'
+PACKAGE_VERSION='1.9.1'
+PACKAGE_STRING='pcap 1.9.1'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -645,6 +645,7 @@
 MAN_ADMIN_COMMANDS
 MAN_MISC_INFO
 MAN_FILE_FORMATS
+MAN_DEVICES
 DYEXT
 SSRC
 ADDLARCHIVEOBJS
@@ -660,6 +661,10 @@
 V_INCLS
 V_FINDALLDEVS
 V_DEFS
+V_PROG_LDFLAGS_FAT
+V_PROG_CCOPT_FAT
+V_LIB_LDFLAGS_FAT
+V_LIB_CCOPT_FAT
 V_CCOPT
 MKDEP
 DEPENDENCY_CFLAG
@@ -716,6 +721,7 @@
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -814,6 +820,7 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1066,6 +1073,15 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1203,7 +1219,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1316,7 +1332,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.9.0-PRE-GIT to adapt to many kinds of systems.
+\`configure' configures pcap 1.9.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1356,6 +1372,7 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1382,7 +1399,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of pcap 1.9.0-PRE-GIT:";;
+     short | recursive ) echo "Configuration of pcap 1.9.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1520,7 +1537,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-pcap configure 1.9.0-PRE-GIT
+pcap configure 1.9.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2042,7 +2059,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.9.0-PRE-GIT, which was
+It was created by pcap $as_me 1.9.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3576,6 +3593,10 @@
 fi
 
 
+if test "$ac_cv_prog_cc_c99" = "no"; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The C compiler does not support C99; there may be compiler errors" >&5
+$as_echo "$as_me: WARNING: The C compiler does not support C99; there may be compiler errors" >&2;}
+fi
 
 
 
@@ -3997,7 +4018,7 @@
 	    aix*)
 		    ;;
 
-	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
+	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|midipix*)
 	    	    #
 		    # Platforms where the linker is the GNU linker
 		    # or accepts command-line arguments like
@@ -4014,7 +4035,7 @@
 		    sparc64*)
 			case "$host_os" in
 
-			freebsd*|openbsd*)
+			freebsd*|openbsd*|linux*)
 			    PIC_OPT=-fPIC
 			    ;;
 			esac
@@ -4214,7 +4235,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -4260,7 +4281,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -4284,7 +4305,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -4329,7 +4350,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -4353,7 +4374,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -4998,19 +5019,120 @@
 	    fi
     fi
 
-for ac_func in strerror strerror_r strerror_s strlcpy strlcat
+for ac_func in strerror
 do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  ac_fn_c_check_func "$LINENO" "strerror" "ac_cv_func_strerror"
+if test "x$ac_cv_func_strerror" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+#define HAVE_STRERROR 1
+_ACEOF
+
+fi
+done
+
+ac_fn_c_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r"
+if test "x$ac_cv_func_strerror_r" = xyes; then :
+
+	#
+	# We have strerror_r; if we define _GNU_SOURCE, is it a
+	# POSIX-compliant strerror_r() or a GNU strerror_r()?
+	#
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror_r is GNU-style" >&5
+$as_echo_n "checking whether strerror_r is GNU-style... " >&6; }
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+		#define _GNU_SOURCE
+#include <string.h>
+
+/* Define it GNU-style; that will cause an error if it's not GNU-style */
+extern char *strerror_r(int, char *, size_t);
+
+int
+main(void)
+{
+	return 0;
+}
+
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+	        # GNU-style
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GNU_STRERROR_R /**/" >>confdefs.h
+
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define HAVE_POSIX_STRERROR_R /**/" >>confdefs.h
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+else
+
+	#
+	# We don't have strerror_r; do we have strerror_s?
+	#
+	for ac_func in strerror_s
+do :
+  ac_fn_c_check_func "$LINENO" "strerror_s" "ac_cv_func_strerror_s"
+if test "x$ac_cv_func_strerror_s" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STRERROR_S 1
 _ACEOF
 
 fi
 done
 
 
+fi
+
+
+#
+# Thanks, IBM, for not providing vsyslog() in AIX!
+#
+for ac_func in vsyslog
+do :
+  ac_fn_c_check_func "$LINENO" "vsyslog" "ac_cv_func_vsyslog"
+if test "x$ac_cv_func_vsyslog" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_VSYSLOG 1
+_ACEOF
+
+fi
+done
+
+
+#
+# Either:
+#
+#	we have snprintf() and vsnprintf(), and have asprintf() and
+#	vasprintf();
+#
+#	we have snprintf() and vsnprintf(), but don't have asprintf()
+#	or vasprintf();
+#
+#	we have neither snprintf() nor vsnprintf(), and don't have
+#	asprintf() or vasprintf(), either.
+#
+# We assume that if we have asprintf() we have vasprintf(), as well
+# as snprintf() and vsnprintf(), and that if we have snprintf() we
+# have vsnprintf().
+#
+# For the first case, we don't need any replacement routines.
+# For the second case, we need replacement asprintf()/vasprintf()
+# routines.
+# For the third case, we need replacement snprintf()/vsnprintf() and
+# asprintf()/vasprintf() routines.
+#
 needsnprintf=no
 for ac_func in vsnprintf snprintf
 do :
@@ -5026,13 +5148,90 @@
 fi
 done
 
+needasprintf=no
+for ac_func in vasprintf asprintf
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  needasprintf=yes
+fi
+done
+
 if test $needsnprintf = yes; then
+	#
+	# We assume we have none of them; missing/snprintf.c supplies
+	# all of them.
+	#
 	case " $LIBOBJS " in
   *" snprintf.$ac_objext "* ) ;;
   *) LIBOBJS="$LIBOBJS snprintf.$ac_objext"
  ;;
 esac
 
+elif test $needasprintf = yes; then
+	#
+	# We assume we have snprintf()/vsnprintf() but lack
+	# asprintf()/vasprintf(); missing/asprintf.c supplies
+	# the latter (using vsnprintf()).
+	#
+	case " $LIBOBJS " in
+  *" asprintf.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS asprintf.$ac_objext"
+ ;;
+esac
+
+fi
+
+needstrlcat=no
+for ac_func in strlcat
+do :
+  ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
+if test "x$ac_cv_func_strlcat" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STRLCAT 1
+_ACEOF
+
+else
+  needstrlcat=yes
+fi
+done
+
+if test $needstrlcat = yes; then
+	case " $LIBOBJS " in
+  *" strlcat.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS strlcat.$ac_objext"
+ ;;
+esac
+
+fi
+
+needstrlcpy=no
+for ac_func in strlcpy
+do :
+  ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy"
+if test "x$ac_cv_func_strlcpy" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STRLCPY 1
+_ACEOF
+
+else
+  needstrlcpy=yes
+fi
+done
+
+if test $needstrlcpy = yes; then
+	case " $LIBOBJS " in
+  *" strlcpy.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext"
+ ;;
+esac
+
 fi
 
 needstrtok_r=no
@@ -5962,6 +6161,10 @@
 		#  requires that various BSD-style integer types
 		#  be defined;
 		#
+		#  sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
+		#  doesn't include it but does use struct timeval
+		#  in ioctl definitions;
+		#
 		#  sys/ioctl.h and, if we have it, sys/ioccom.h,
 		#  because net/bpf.h defines ioctls;
 		#
@@ -5984,6 +6187,7 @@
 /* end confdefs.h.  */
 
 #include <sys/types.h>
+#include <sys/time.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #ifdef HAVE_SYS_IOCCOM_H
@@ -7969,11 +8173,12 @@
 # Do various checks for various OSes and versions of those OSes.
 #
 # Assume, by default, no support for shared libraries and V7/BSD
-# convention for man pages (file formats in section 5, miscellaneous
-# info in section 7, administrative commands and daemons in section 8).
-# Individual cases can override this.
+# convention for man pages (devices in section 4, file formats in
+# section 5, miscellaneous info in section 7, administrative commands
+# and daemons in section 8).  Individual cases can override this.
 #
 DYEXT="none"
+MAN_DEVICES=4
 MAN_FILE_FORMATS=5
 MAN_MISC_INFO=7
 MAN_ADMIN_COMMANDS=8
@@ -8035,79 +8240,168 @@
 	if test "$enable_universal" != "no"; then
 		case "$host_os" in
 
-		darwin0-7.*)
+		darwin[0-7].*)
 			#
 			# Pre-Tiger.  Build only for 32-bit PowerPC; no
 			# need for any special compiler or linker flags.
 			#
 			;;
 
-		darwin8.0123*)
+		darwin8.[0123]|darwin8.[0123].*)
 			#
-			# Tiger, prior to Intel support.  Build for 32-bit
-			# PowerPC and 64-bit PowerPC, with 32-bit PowerPC
-			# first.  (I'm guessing that's what Apple does.)
-			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
-			;;
-
-		darwin8.456*)
-			#
-			# Tiger, subsequent to Intel support but prior to
-			# x86-64 support.  Build for 32-bit PowerPC, 64-bit
-			# PowerPC, and x86, with 32-bit PowerPC first.
+			# Tiger, prior to Intel support.  Build
+			# libraries and executables for 32-bit PowerPC
+			# and 64-bit PowerPC, with 32-bit PowerPC first.
 			# (I'm guessing that's what Apple does.)
 			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
+			# (The double brackets are needed because
+			# autotools/m4 use brackets as a quoting
+			# character; the double brackets turn into
+			# single brackets in the generated configure
+			# file.)
+			#
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
+			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
+			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
+			;;
+
+		darwin8.[456]|darwin.[456].*)
+			#
+			# Tiger, subsequent to Intel support but prior
+			# to x86-64 support.  Build libraries and
+			# executables for 32-bit PowerPC, 64-bit
+			# PowerPC, and 32-bit x86, with 32-bit PowerPC
+			# first.  (I'm guessing that's what Apple does.)
+			#
+			# (The double brackets are needed because
+			# autotools/m4 use brackets as a quoting
+			# character; the double brackets turn into
+			# single brackets in the generated configure
+			# file.)
+			#
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
+			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
+			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
 			;;
 
 		darwin8.*)
 			#
 			# All other Tiger, so subsequent to x86-64
-			# support. Build for 32-bit PowerPC, 64-bit
-			# PowerPC, x86, and x86-64, and with 32-bit PowerPC
-			# first.  (I'm guessing that's what Apple does.)
+			# support.  Build libraries and executables for
+			# 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
+			# and x86-64, with 32-bit PowerPC first.  (I'm
+			# guessing that's what Apple does.)
 			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
 			;;
 
 		darwin9.*)
 			#
-			# Leopard.  Build for 32-bit PowerPC, 64-bit
-			# PowerPC, x86, and x86-64, with 32-bit PowerPC
-			# first.  (That's what Apple does.)
+			# Leopard.  Build libraries for 32-bit PowerPC,
+			# 64-bit PowerPC, 32-bit x86, and x86-64, with
+			# 32-bit PowerPC first, and build executables
+			# for 32-bit x86 and 32-bit PowerPC, with 32-bit
+			# x86 first.  (That's what Apple does.)
 			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
+			V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
 			;;
 
 		darwin10.*)
 			#
-			# Snow Leopard.  Build for x86-64, x86, and
-			# 32-bit PowerPC, with x86-64 first.  (That's
-			# what Apple does, even though Snow Leopard
-			# doesn't run on PPC, so PPC libpcap runs under
-			# Rosetta, and Rosetta doesn't support BPF
-			# ioctls, so PPC programs can't do live
-			# captures.)
+			# Snow Leopard.  Build libraries for x86-64,
+			# 32-bit x86, and 32-bit PowerPC, with x86-64
+			# first, and build executables for x86-64 and
+			# 32-bit x86, with x86-64 first.  (That's what
+			# Apple does, even though Snow Leopard doesn't
+			# run on PPC, so PPC libpcap runs under Rosetta,
+			# and Rosetta doesn't support BPF ioctls, so PPC
+			# programs can't do live captures.)
 			#
-			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
-			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
+			V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
+			V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
+			V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
+			V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
 			;;
 
 		darwin*)
 			#
-			# Post-Snow Leopard.  Build for x86-64 and
-			# x86, with x86-64 first.  (That's probably what
-			# Apple does, given that Rosetta is gone.)
+			# Post-Snow Leopard.  Build libraries for x86-64
+			# and 32-bit x86, with x86-64 first, and build
+			# executables only for x86-64.  (That's what
+			# Apple does.)  This requires no special flags
+			# for programs.
 			# XXX - update if and when Apple drops support
-			# for 32-bit x86 code.
+			# for 32-bit x86 code and if and when Apple adds
+			# ARM-based Macs.  (You're on your own for iOS
+			# etc.)
 			#
-			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
-			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
+			# XXX - check whether we *can* build for
+			# i386 and, if not, suggest that the user
+			# install the /usr/include headers if they
+			# want to build fat.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether building for 32-bit x86 is supported" >&5
+$as_echo_n "checking whether building for 32-bit x86 is supported... " >&6; }
+			save_CFLAGS="$CFLAGS"
+			CFLAGS="$CFLAGS -arch i386"
+			cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+				V_LIB_CCOPT_FAT="-arch x86_64 -arch i386"
+				V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386"
+
+else
+
+				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+				V_LIB_CCOPT_FAT="-arch x86_64"
+				V_LIB_LDFLAGS_FAT="-arch x86_64"
+				case "$host_os" in
+
+				darwin18.*)
+					#
+					# Mojave; you need to install the
+					# /usr/include headers to get
+					# 32-bit x86 builds to work.
+					#
+					{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package" >&5
+$as_echo "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package" >&2;}
+					;;
+
+				*)
+					#
+					# Pre-Mojave; the command-line
+					# tools should be sufficient to
+					# enable 32-bit x86 builds.
+					#
+					{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools" >&5
+$as_echo "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installing the command-line tools" >&2;}
+					;;
+				esac
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+			CFLAGS="$save_CFLAGS"
 			;;
 		esac
 	fi
@@ -8179,7 +8473,7 @@
 	MAN_MISC_INFO=5
 	;;
 
-linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
+linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|midipix*)
 	DYEXT="so"
 
 	#
@@ -8202,6 +8496,7 @@
 	#
 	MAN_FILE_FORMATS=4
 	MAN_MISC_INFO=5
+	MAN_DEVICES=7
 	;;
 
 sinix*)
@@ -8267,6 +8562,7 @@
 		MAN_ADMIN_COMMANDS=1m
 		MAN_FILE_FORMATS=4
 		MAN_MISC_INFO=5
+		MAN_DEVICES=7D
 	esac
 	;;
 esac
@@ -8522,6 +8818,88 @@
 	CFLAGS="$save_CFLAGS"
 
 
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5
+$as_echo_n "checking whether the compiler supports the -W option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-W" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W"
+	elif expr "x-W" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -W"
+	elif expr "x-W" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -W"
+	else
+	    CFLAGS="$CFLAGS -W"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -W " >&5
+$as_echo_n "checking whether -W ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -W"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5
 $as_echo_n "checking whether the compiler supports the -Wall option... " >&6; }
 	save_CFLAGS="$CFLAGS"
@@ -8604,580 +8982,6 @@
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wsign-compare option" >&5
-$as_echo_n "checking whether the compiler supports the -Wsign-compare option... " >&6; }
-	save_CFLAGS="$CFLAGS"
-	if expr "x-Wsign-compare" : "x-W.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wsign-compare"
-	elif expr "x-Wsign-compare" : "x-f.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wsign-compare"
-	elif expr "x-Wsign-compare" : "x-m.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wsign-compare"
-	else
-	    CFLAGS="$CFLAGS -Wsign-compare"
-	fi
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		can_add_to_cflags=yes
-		#
-		# The compile supports this; do we have some C code for
-		# which the warning should *not* appear?
-		# We test the fourth argument because the third argument
-		# could contain quotes, breaking the test.
-		#
-		if test "x" != "x"
-		then
-		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wsign-compare " >&5
-$as_echo_n "checking whether -Wsign-compare ... " >&6; }
-		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			#
-			# Not a problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
-			#
-			# A problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-			can_add_to_cflags=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-		fi
-		CFLAGS="$save_CFLAGS"
-		if test x"$can_add_to_cflags" = "xyes"
-		then
-		    V_CCOPT="$V_CCOPT -Wsign-compare"
-		fi
-
-else
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		CFLAGS="$save_CFLAGS"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5
-$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; }
-	save_CFLAGS="$CFLAGS"
-	if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
-	elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
-	elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
-	else
-	    CFLAGS="$CFLAGS -Wmissing-prototypes"
-	fi
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		can_add_to_cflags=yes
-		#
-		# The compile supports this; do we have some C code for
-		# which the warning should *not* appear?
-		# We test the fourth argument because the third argument
-		# could contain quotes, breaking the test.
-		#
-		if test "x" != "x"
-		then
-		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-prototypes " >&5
-$as_echo_n "checking whether -Wmissing-prototypes ... " >&6; }
-		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			#
-			# Not a problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
-			#
-			# A problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-			can_add_to_cflags=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-		fi
-		CFLAGS="$save_CFLAGS"
-		if test x"$can_add_to_cflags" = "xyes"
-		then
-		    V_CCOPT="$V_CCOPT -Wmissing-prototypes"
-		fi
-
-else
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		CFLAGS="$save_CFLAGS"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5
-$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; }
-	save_CFLAGS="$CFLAGS"
-	if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
-	elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
-	elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
-	else
-	    CFLAGS="$CFLAGS -Wstrict-prototypes"
-	fi
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		can_add_to_cflags=yes
-		#
-		# The compile supports this; do we have some C code for
-		# which the warning should *not* appear?
-		# We test the fourth argument because the third argument
-		# could contain quotes, breaking the test.
-		#
-		if test "x" != "x"
-		then
-		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wstrict-prototypes " >&5
-$as_echo_n "checking whether -Wstrict-prototypes ... " >&6; }
-		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			#
-			# Not a problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
-			#
-			# A problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-			can_add_to_cflags=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-		fi
-		CFLAGS="$save_CFLAGS"
-		if test x"$can_add_to_cflags" = "xyes"
-		then
-		    V_CCOPT="$V_CCOPT -Wstrict-prototypes"
-		fi
-
-else
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		CFLAGS="$save_CFLAGS"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5
-$as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; }
-	save_CFLAGS="$CFLAGS"
-	if expr "x-Wshadow" : "x-W.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow"
-	elif expr "x-Wshadow" : "x-f.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wshadow"
-	elif expr "x-Wshadow" : "x-m.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wshadow"
-	else
-	    CFLAGS="$CFLAGS -Wshadow"
-	fi
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		can_add_to_cflags=yes
-		#
-		# The compile supports this; do we have some C code for
-		# which the warning should *not* appear?
-		# We test the fourth argument because the third argument
-		# could contain quotes, breaking the test.
-		#
-		if test "x" != "x"
-		then
-		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wshadow " >&5
-$as_echo_n "checking whether -Wshadow ... " >&6; }
-		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			#
-			# Not a problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
-			#
-			# A problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-			can_add_to_cflags=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-		fi
-		CFLAGS="$save_CFLAGS"
-		if test x"$can_add_to_cflags" = "xyes"
-		then
-		    V_CCOPT="$V_CCOPT -Wshadow"
-		fi
-
-else
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		CFLAGS="$save_CFLAGS"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdeclaration-after-statement option" >&5
-$as_echo_n "checking whether the compiler supports the -Wdeclaration-after-statement option... " >&6; }
-	save_CFLAGS="$CFLAGS"
-	if expr "x-Wdeclaration-after-statement" : "x-W.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdeclaration-after-statement"
-	elif expr "x-Wdeclaration-after-statement" : "x-f.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
-	elif expr "x-Wdeclaration-after-statement" : "x-m.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
-	else
-	    CFLAGS="$CFLAGS -Wdeclaration-after-statement"
-	fi
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		can_add_to_cflags=yes
-		#
-		# The compile supports this; do we have some C code for
-		# which the warning should *not* appear?
-		# We test the fourth argument because the third argument
-		# could contain quotes, breaking the test.
-		#
-		if test "x" != "x"
-		then
-		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wdeclaration-after-statement " >&5
-$as_echo_n "checking whether -Wdeclaration-after-statement ... " >&6; }
-		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			#
-			# Not a problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
-			#
-			# A problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-			can_add_to_cflags=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-		fi
-		CFLAGS="$save_CFLAGS"
-		if test x"$can_add_to_cflags" = "xyes"
-		then
-		    V_CCOPT="$V_CCOPT -Wdeclaration-after-statement"
-		fi
-
-else
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		CFLAGS="$save_CFLAGS"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5
-$as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; }
-	save_CFLAGS="$CFLAGS"
-	if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused"
-	elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
-	elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
-	else
-	    CFLAGS="$CFLAGS -Wused-but-marked-unused"
-	fi
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		can_add_to_cflags=yes
-		#
-		# The compile supports this; do we have some C code for
-		# which the warning should *not* appear?
-		# We test the fourth argument because the third argument
-		# could contain quotes, breaking the test.
-		#
-		if test "x" != "x"
-		then
-		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wused-but-marked-unused " >&5
-$as_echo_n "checking whether -Wused-but-marked-unused ... " >&6; }
-		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			#
-			# Not a problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
-			#
-			# A problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-			can_add_to_cflags=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-		fi
-		CFLAGS="$save_CFLAGS"
-		if test x"$can_add_to_cflags" = "xyes"
-		then
-		    V_CCOPT="$V_CCOPT -Wused-but-marked-unused"
-		fi
-
-else
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		CFLAGS="$save_CFLAGS"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdocumentation option" >&5
-$as_echo_n "checking whether the compiler supports the -Wdocumentation option... " >&6; }
-	save_CFLAGS="$CFLAGS"
-	if expr "x-Wdocumentation" : "x-W.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdocumentation"
-	elif expr "x-Wdocumentation" : "x-f.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wdocumentation"
-	elif expr "x-Wdocumentation" : "x-m.*" >/dev/null
-	then
-	    CFLAGS="$CFLAGS -Werror -Wdocumentation"
-	else
-	    CFLAGS="$CFLAGS -Wdocumentation"
-	fi
-	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-return 0
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-		can_add_to_cflags=yes
-		#
-		# The compile supports this; do we have some C code for
-		# which the warning should *not* appear?
-		# We test the fourth argument because the third argument
-		# could contain quotes, breaking the test.
-		#
-		if test "x" != "x"
-		then
-		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wdocumentation " >&5
-$as_echo_n "checking whether -Wdocumentation ... " >&6; }
-		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-			#
-			# Not a problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
-			#
-			# A problem.
-			#
-			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-			can_add_to_cflags=no
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-		fi
-		CFLAGS="$save_CFLAGS"
-		if test x"$can_add_to_cflags" = "xyes"
-		then
-		    V_CCOPT="$V_CCOPT -Wdocumentation"
-		fi
-
-else
-
-		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-		CFLAGS="$save_CFLAGS"
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcomma option" >&5
 $as_echo_n "checking whether the compiler supports the -Wcomma option... " >&6; }
 	save_CFLAGS="$CFLAGS"
@@ -9260,6 +9064,252 @@
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdeclaration-after-statement option" >&5
+$as_echo_n "checking whether the compiler supports the -Wdeclaration-after-statement option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-Wdeclaration-after-statement" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdeclaration-after-statement"
+	elif expr "x-Wdeclaration-after-statement" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+	elif expr "x-Wdeclaration-after-statement" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+	else
+	    CFLAGS="$CFLAGS -Wdeclaration-after-statement"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wdeclaration-after-statement " >&5
+$as_echo_n "checking whether -Wdeclaration-after-statement ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -Wdeclaration-after-statement"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdocumentation option" >&5
+$as_echo_n "checking whether the compiler supports the -Wdocumentation option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-Wdocumentation" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdocumentation"
+	elif expr "x-Wdocumentation" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wdocumentation"
+	elif expr "x-Wdocumentation" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wdocumentation"
+	else
+	    CFLAGS="$CFLAGS -Wdocumentation"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wdocumentation " >&5
+$as_echo_n "checking whether -Wdocumentation ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -Wdocumentation"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wformat-nonliteral option" >&5
+$as_echo_n "checking whether the compiler supports the -Wformat-nonliteral option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-Wformat-nonliteral" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wformat-nonliteral"
+	elif expr "x-Wformat-nonliteral" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wformat-nonliteral"
+	elif expr "x-Wformat-nonliteral" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wformat-nonliteral"
+	else
+	    CFLAGS="$CFLAGS -Wformat-nonliteral"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wformat-nonliteral " >&5
+$as_echo_n "checking whether -Wformat-nonliteral ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -Wformat-nonliteral"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-noreturn option" >&5
 $as_echo_n "checking whether the compiler supports the -Wmissing-noreturn option... " >&6; }
 	save_CFLAGS="$CFLAGS"
@@ -9341,9 +9391,88 @@
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-		    # Warns about safeguards added in case the enums are
-		    # extended
-		    # AC_LBL_CHECK_COMPILER_OPT(V_CCOPT, -Wcovered-switch-default)
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5
+$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
+	elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+	elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+	else
+	    CFLAGS="$CFLAGS -Wmissing-prototypes"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wmissing-prototypes " >&5
+$as_echo_n "checking whether -Wmissing-prototypes ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -Wmissing-prototypes"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-variable-declarations option" >&5
 $as_echo_n "checking whether the compiler supports the -Wmissing-variable-declarations option... " >&6; }
@@ -9427,6 +9556,252 @@
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5
+$as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-Wshadow" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow"
+	elif expr "x-Wshadow" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wshadow"
+	elif expr "x-Wshadow" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wshadow"
+	else
+	    CFLAGS="$CFLAGS -Wshadow"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wshadow " >&5
+$as_echo_n "checking whether -Wshadow ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -Wshadow"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wsign-compare option" >&5
+$as_echo_n "checking whether the compiler supports the -Wsign-compare option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-Wsign-compare" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wsign-compare"
+	elif expr "x-Wsign-compare" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wsign-compare"
+	elif expr "x-Wsign-compare" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wsign-compare"
+	else
+	    CFLAGS="$CFLAGS -Wsign-compare"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wsign-compare " >&5
+$as_echo_n "checking whether -Wsign-compare ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -Wsign-compare"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5
+$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; }
+	save_CFLAGS="$CFLAGS"
+	if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
+	elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+	elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null
+	then
+	    CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+	else
+	    CFLAGS="$CFLAGS -Wstrict-prototypes"
+	fi
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		can_add_to_cflags=yes
+		#
+		# The compile supports this; do we have some C code for
+		# which the warning should *not* appear?
+		# We test the fourth argument because the third argument
+		# could contain quotes, breaking the test.
+		#
+		if test "x" != "x"
+		then
+		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wstrict-prototypes " >&5
+$as_echo_n "checking whether -Wstrict-prototypes ... " >&6; }
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+			#
+			# Not a problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+else
+
+			#
+			# A problem.
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+			can_add_to_cflags=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+		fi
+		CFLAGS="$save_CFLAGS"
+		if test x"$can_add_to_cflags" = "xyes"
+		then
+		    V_CCOPT="$V_CCOPT -Wstrict-prototypes"
+		fi
+
+else
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunused-parameter option" >&5
 $as_echo_n "checking whether the compiler supports the -Wunused-parameter option... " >&6; }
 	save_CFLAGS="$CFLAGS"
@@ -9509,20 +9884,20 @@
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wformat-nonliteral option" >&5
-$as_echo_n "checking whether the compiler supports the -Wformat-nonliteral option... " >&6; }
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5
+$as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; }
 	save_CFLAGS="$CFLAGS"
-	if expr "x-Wformat-nonliteral" : "x-W.*" >/dev/null
+	if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null
 	then
-	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wformat-nonliteral"
-	elif expr "x-Wformat-nonliteral" : "x-f.*" >/dev/null
+	    CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused"
+	elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null
 	then
-	    CFLAGS="$CFLAGS -Werror -Wformat-nonliteral"
-	elif expr "x-Wformat-nonliteral" : "x-m.*" >/dev/null
+	    CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
+	elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null
 	then
-	    CFLAGS="$CFLAGS -Werror -Wformat-nonliteral"
+	    CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
 	else
-	    CFLAGS="$CFLAGS -Wformat-nonliteral"
+	    CFLAGS="$CFLAGS -Wused-but-marked-unused"
 	fi
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -9549,8 +9924,8 @@
 		if test "x" != "x"
 		then
 		    CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wformat-nonliteral " >&5
-$as_echo_n "checking whether -Wformat-nonliteral ... " >&6; }
+		    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wused-but-marked-unused " >&5
+$as_echo_n "checking whether -Wused-but-marked-unused ... " >&6; }
 		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -9578,7 +9953,7 @@
 		CFLAGS="$save_CFLAGS"
 		if test x"$can_add_to_cflags" = "xyes"
 		then
-		    V_CCOPT="$V_CCOPT -Wformat-nonliteral"
+		    V_CCOPT="$V_CCOPT -Wused-but-marked-unused"
 		fi
 
 else
@@ -9590,6 +9965,9 @@
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
+		    # Warns about safeguards added in case the enums are
+		    # extended
+		    # AC_LBL_CHECK_COMPILER_OPT(V_CCOPT, -Wcovered-switch-default)
 		    #
 		    # This can cause problems with ntohs(), ntohl(),
 		    # htons(), and htonl() on some platforms, such
@@ -10010,6 +10388,11 @@
 
 
 
+
+
+
+
+
 # Check whether --enable-usb was given.
 if test "${enable_usb+set}" = set; then :
   enableval=$enable_usb;
@@ -10538,17 +10921,17 @@
 if test "${enable_rdma+set}" = set; then :
   enableval=$enable_rdma;
 else
-  enable_rdmasniff=ifavailable
+  enable_rdma=ifavailable
 fi
 
 
 if test "xxx_only" = yes; then
 	# User requested something-else-only pcap, so they don't
 	# want RDMA support.
-	enable_rdmasniff=no
+	enable_rdma=no
 fi
 
-if test "x$enable_rdmasniff" != "xno"; then
+if test "x$enable_rdma" != "xno"; then
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ibv_get_device_list in -libverbs" >&5
 $as_echo_n "checking for ibv_get_device_list in -libverbs... " >&6; }
 if ${ac_cv_lib_ibverbs_ibv_get_device_list+:} false; then :
@@ -10748,7 +11131,7 @@
 
 ac_config_commands="$ac_config_commands default-1"
 
-ac_config_files="$ac_config_files Makefile pcap-filter.manmisc pcap-linktype.manmisc pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap rpcapd/Makefile rpcapd/rpcapd.manadmin testprogs/Makefile"
+ac_config_files="$ac_config_files Makefile pcap-filter.manmisc pcap-linktype.manmisc pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile testprogs/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -11256,7 +11639,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.9.0-PRE-GIT, which was
+This file was extended by pcap $as_me 1.9.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -11322,7 +11705,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.9.0-PRE-GIT
+pcap config.status 1.9.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -11465,10 +11848,12 @@
     "pcap_list_tstamp_types.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_list_tstamp_types.3pcap" ;;
     "pcap_open_dead.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_open_dead.3pcap" ;;
     "pcap_open_offline.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_open_offline.3pcap" ;;
+    "pcap_set_immediate_mode.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_set_immediate_mode.3pcap" ;;
     "pcap_set_tstamp_precision.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_set_tstamp_precision.3pcap" ;;
     "pcap_set_tstamp_type.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_set_tstamp_type.3pcap" ;;
     "rpcapd/Makefile") CONFIG_FILES="$CONFIG_FILES rpcapd/Makefile" ;;
     "rpcapd/rpcapd.manadmin") CONFIG_FILES="$CONFIG_FILES rpcapd/rpcapd.manadmin" ;;
+    "rpcapd/rpcapd-config.manfile") CONFIG_FILES="$CONFIG_FILES rpcapd/rpcapd-config.manfile" ;;
     "testprogs/Makefile") CONFIG_FILES="$CONFIG_FILES testprogs/Makefile" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
diff --git a/configure.ac b/configure.ac
index eff6eb8..eba2723 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,9 @@
 # At minimum, we want C++/C99-style // comments.
 #
 AC_PROG_CC_C99
+if test "$ac_cv_prog_cc_c99" = "no"; then
+	AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
+fi
 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
 AC_LBL_SHLIBS_INIT
 AC_LBL_C_INLINE
@@ -83,13 +86,109 @@
 
 AC_LBL_FIXINCLUDES
 
-AC_CHECK_FUNCS(strerror strerror_r strerror_s strlcpy strlcat)
+AC_CHECK_FUNCS(strerror)
+AC_CHECK_FUNC(strerror_r,
+    [
+	#
+	# We have strerror_r; if we define _GNU_SOURCE, is it a
+	# POSIX-compliant strerror_r() or a GNU strerror_r()?
+	#
+	AC_MSG_CHECKING(whether strerror_r is GNU-style)
+	AC_COMPILE_IFELSE(
+	    [
+		AC_LANG_SOURCE(
+#define _GNU_SOURCE
+#include <string.h>
 
+/* Define it GNU-style; that will cause an error if it's not GNU-style */
+extern char *strerror_r(int, char *, size_t);
+
+int
+main(void)
+{
+	return 0;
+}
+)
+	    ],
+	    [
+	        # GNU-style
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_GNU_STRERROR_R,,
+		    [Define to 1 if you have a GNU-style `strerror_r' function.])
+	    ],
+	    [
+		AC_MSG_RESULT(no)
+		AC_DEFINE(HAVE_POSIX_STRERROR_R,,
+		    [Define to 1 if you have a POSIX-style `strerror_r' function.])
+	    ])
+    ],
+    [
+	#
+	# We don't have strerror_r; do we have strerror_s?
+	#
+	AC_CHECK_FUNCS(strerror_s)
+    ])
+
+#
+# Thanks, IBM, for not providing vsyslog() in AIX!
+#
+AC_CHECK_FUNCS(vsyslog)
+
+#
+# Either:
+#
+#	we have snprintf() and vsnprintf(), and have asprintf() and
+#	vasprintf();
+#
+#	we have snprintf() and vsnprintf(), but don't have asprintf()
+#	or vasprintf();
+#
+#	we have neither snprintf() nor vsnprintf(), and don't have
+#	asprintf() or vasprintf(), either.
+#
+# We assume that if we have asprintf() we have vasprintf(), as well
+# as snprintf() and vsnprintf(), and that if we have snprintf() we
+# have vsnprintf().
+#
+# For the first case, we don't need any replacement routines.
+# For the second case, we need replacement asprintf()/vasprintf()
+# routines.
+# For the third case, we need replacement snprintf()/vsnprintf() and
+# asprintf()/vasprintf() routines.
+#
 needsnprintf=no
 AC_CHECK_FUNCS(vsnprintf snprintf,,
 	[needsnprintf=yes])
+needasprintf=no
+AC_CHECK_FUNCS(vasprintf asprintf,,
+	[needasprintf=yes])
 if test $needsnprintf = yes; then
+	#
+	# We assume we have none of them; missing/snprintf.c supplies
+	# all of them.
+	#
 	AC_LIBOBJ([snprintf])
+elif test $needasprintf = yes; then
+	#
+	# We assume we have snprintf()/vsnprintf() but lack
+	# asprintf()/vasprintf(); missing/asprintf.c supplies
+	# the latter (using vsnprintf()).
+	#
+	AC_LIBOBJ([asprintf])
+fi
+
+needstrlcat=no
+AC_CHECK_FUNCS(strlcat,,
+	[needstrlcat=yes])
+if test $needstrlcat = yes; then
+	AC_LIBOBJ([strlcat])
+fi
+
+needstrlcpy=no
+AC_CHECK_FUNCS(strlcpy,,
+	[needstrlcpy=yes])
+if test $needstrlcpy = yes; then
+	AC_LIBOBJ([strlcpy])
 fi
 
 needstrtok_r=no
@@ -550,6 +649,10 @@
 		#  requires that various BSD-style integer types
 		#  be defined;
 		#
+		#  sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
+		#  doesn't include it but does use struct timeval
+		#  in ioctl definitions;
+		#
 		#  sys/ioctl.h and, if we have it, sys/ioccom.h,
 		#  because net/bpf.h defines ioctls;
 		#
@@ -568,6 +671,7 @@
 			AC_TRY_COMPILE(
 [
 #include <sys/types.h>
+#include <sys/time.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #ifdef HAVE_SYS_IOCCOM_H
@@ -1537,11 +1641,12 @@
 # Do various checks for various OSes and versions of those OSes.
 #
 # Assume, by default, no support for shared libraries and V7/BSD
-# convention for man pages (file formats in section 5, miscellaneous
-# info in section 7, administrative commands and daemons in section 8).
-# Individual cases can override this.
+# convention for man pages (devices in section 4, file formats in
+# section 5, miscellaneous info in section 7, administrative commands
+# and daemons in section 8).  Individual cases can override this.
 #
 DYEXT="none"
+MAN_DEVICES=4
 MAN_FILE_FORMATS=5
 MAN_MISC_INFO=7
 MAN_ADMIN_COMMANDS=8
@@ -1597,79 +1702,151 @@
 	if test "$enable_universal" != "no"; then
 		case "$host_os" in
 
-		darwin[0-7].*)
+		darwin[[0-7]].*)
 			#
 			# Pre-Tiger.  Build only for 32-bit PowerPC; no
 			# need for any special compiler or linker flags.
 			#
 			;;
 
-		darwin8.[0123]*)
+		darwin8.[[0123]]|darwin8.[[0123]].*)
 			#
-			# Tiger, prior to Intel support.  Build for 32-bit
-			# PowerPC and 64-bit PowerPC, with 32-bit PowerPC
-			# first.  (I'm guessing that's what Apple does.)
-			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
-			;;
-
-		darwin8.[456]*)
-			#
-			# Tiger, subsequent to Intel support but prior to
-			# x86-64 support.  Build for 32-bit PowerPC, 64-bit
-			# PowerPC, and x86, with 32-bit PowerPC first.
+			# Tiger, prior to Intel support.  Build
+			# libraries and executables for 32-bit PowerPC
+			# and 64-bit PowerPC, with 32-bit PowerPC first.
 			# (I'm guessing that's what Apple does.)
 			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
+			# (The double brackets are needed because
+			# autotools/m4 use brackets as a quoting
+			# character; the double brackets turn into
+			# single brackets in the generated configure
+			# file.)
+			#
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
+			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
+			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
+			;;
+
+		darwin8.[[456]]|darwin.[[456]].*)
+			#
+			# Tiger, subsequent to Intel support but prior
+			# to x86-64 support.  Build libraries and
+			# executables for 32-bit PowerPC, 64-bit
+			# PowerPC, and 32-bit x86, with 32-bit PowerPC
+			# first.  (I'm guessing that's what Apple does.)
+			#
+			# (The double brackets are needed because
+			# autotools/m4 use brackets as a quoting
+			# character; the double brackets turn into
+			# single brackets in the generated configure
+			# file.)
+			#
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
+			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
+			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
 			;;
 
 		darwin8.*)
 			#
 			# All other Tiger, so subsequent to x86-64
-			# support. Build for 32-bit PowerPC, 64-bit
-			# PowerPC, x86, and x86-64, and with 32-bit PowerPC
-			# first.  (I'm guessing that's what Apple does.)
+			# support.  Build libraries and executables for
+			# 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
+			# and x86-64, with 32-bit PowerPC first.  (I'm
+			# guessing that's what Apple does.)
 			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
 			;;
 
 		darwin9.*)
 			#
-			# Leopard.  Build for 32-bit PowerPC, 64-bit
-			# PowerPC, x86, and x86-64, with 32-bit PowerPC
-			# first.  (That's what Apple does.)
+			# Leopard.  Build libraries for 32-bit PowerPC,
+			# 64-bit PowerPC, 32-bit x86, and x86-64, with
+			# 32-bit PowerPC first, and build executables
+			# for 32-bit x86 and 32-bit PowerPC, with 32-bit
+			# x86 first.  (That's what Apple does.)
 			#
-			V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
-			LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
+			V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
+			V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
 			;;
 
 		darwin10.*)
 			#
-			# Snow Leopard.  Build for x86-64, x86, and
-			# 32-bit PowerPC, with x86-64 first.  (That's
-			# what Apple does, even though Snow Leopard
-			# doesn't run on PPC, so PPC libpcap runs under
-			# Rosetta, and Rosetta doesn't support BPF
-			# ioctls, so PPC programs can't do live
-			# captures.)
+			# Snow Leopard.  Build libraries for x86-64,
+			# 32-bit x86, and 32-bit PowerPC, with x86-64
+			# first, and build executables for x86-64 and
+			# 32-bit x86, with x86-64 first.  (That's what
+			# Apple does, even though Snow Leopard doesn't
+			# run on PPC, so PPC libpcap runs under Rosetta,
+			# and Rosetta doesn't support BPF ioctls, so PPC
+			# programs can't do live captures.)
 			#
-			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386 -arch ppc"
-			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
+			V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
+			V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
+			V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
+			V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
 			;;
 
 		darwin*)
 			#
-			# Post-Snow Leopard.  Build for x86-64 and
-			# x86, with x86-64 first.  (That's probably what
-			# Apple does, given that Rosetta is gone.)
+			# Post-Snow Leopard.  Build libraries for x86-64
+			# and 32-bit x86, with x86-64 first, and build
+			# executables only for x86-64.  (That's what
+			# Apple does.)  This requires no special flags
+			# for programs.
 			# XXX - update if and when Apple drops support
-			# for 32-bit x86 code.
+			# for 32-bit x86 code and if and when Apple adds
+			# ARM-based Macs.  (You're on your own for iOS
+			# etc.)
 			#
-			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
-			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
+			# XXX - check whether we *can* build for
+			# i386 and, if not, suggest that the user
+			# install the /usr/include headers if they
+			# want to build fat.
+			#
+			AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
+			save_CFLAGS="$CFLAGS"
+			CFLAGS="$CFLAGS -arch i386"
+			AC_TRY_COMPILE(
+			    [],
+			    [return 0;],
+			    [
+				AC_MSG_RESULT(yes)
+				V_LIB_CCOPT_FAT="-arch x86_64 -arch i386"
+				V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386"
+			    ],
+			    [
+				AC_MSG_RESULT(no)
+				V_LIB_CCOPT_FAT="-arch x86_64"
+				V_LIB_LDFLAGS_FAT="-arch x86_64"
+				case "$host_os" in
+
+				darwin18.*)
+					#
+					# Mojave; you need to install the
+					# /usr/include headers to get
+					# 32-bit x86 builds to work.
+					#
+					AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package])
+					;;
+
+				*)
+					#
+					# Pre-Mojave; the command-line
+					# tools should be sufficient to
+					# enable 32-bit x86 builds.
+					#
+					AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
+					;;
+				esac
+			    ])
+			CFLAGS="$save_CFLAGS"
 			;;
 		esac
 	fi
@@ -1743,7 +1920,7 @@
 	MAN_MISC_INFO=5
 	;;
 
-linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*)
+linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|midipix*)
 	DYEXT="so"
 
 	#
@@ -1766,6 +1943,7 @@
 	#
 	MAN_FILE_FORMATS=4
 	MAN_MISC_INFO=5
+	MAN_DEVICES=7
 	;;
 
 sinix*)
@@ -1809,6 +1987,7 @@
 		MAN_ADMIN_COMMANDS=1m
 		MAN_FILE_FORMATS=4
 		MAN_MISC_INFO=5
+		MAN_DEVICES=7D
 	esac
 	;;
 esac
@@ -1864,6 +2043,10 @@
 AC_LBL_UNALIGNED_ACCESS
 
 AC_SUBST(V_CCOPT)
+AC_SUBST(V_LIB_CCOPT_FAT)
+AC_SUBST(V_LIB_LDFLAGS_FAT)
+AC_SUBST(V_PROG_CCOPT_FAT)
+AC_SUBST(V_PROG_LDFLAGS_FAT)
 AC_SUBST(V_DEFS)
 AC_SUBST(V_FINDALLDEVS)
 AC_SUBST(V_INCLS)
@@ -1879,6 +2062,7 @@
 AC_SUBST(ADDLARCHIVEOBJS)
 AC_SUBST(SSRC)
 AC_SUBST(DYEXT)
+AC_SUBST(MAN_DEVICES)
 AC_SUBST(MAN_FILE_FORMATS)
 AC_SUBST(MAN_MISC_INFO)
 AC_SUBST(MAN_ADMIN_COMMANDS)
@@ -2213,15 +2397,15 @@
 AC_ARG_ENABLE([rdma],
 [AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
     [],
-    [enable_rdmasniff=ifavailable])
+    [enable_rdma=ifavailable])
 
 if test "xxx_only" = yes; then
 	# User requested something-else-only pcap, so they don't
 	# want RDMA support.
-	enable_rdmasniff=no
+	enable_rdma=no
 fi
 
-if test "x$enable_rdmasniff" != "xno"; then
+if test "x$enable_rdma" != "xno"; then
 	AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
 		AC_CHECK_HEADER(infiniband/verbs.h, [
 			#
@@ -2274,7 +2458,8 @@
 	pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
 	pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
 	pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
-	pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap
-	pcap_set_tstamp_type.3pcap rpcapd/Makefile rpcapd/rpcapd.manadmin
+	pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
+	pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
+	rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile
 	testprogs/Makefile)
 exit 0
diff --git a/doc/README.Win32 b/doc/README.Win32
deleted file mode 100644
index 0a42dab..0000000
--- a/doc/README.Win32
+++ /dev/null
@@ -1,46 +0,0 @@
-Under Win32, libpcap is integrated in the WinPcap packet capture system.
-WinPcap provides a framework that allows libpcap to capture the packets
-under Windows 95, Windows 98, Windows ME, Windows NT 4, Windows 2000
-and Windows XP.
-WinPcap binaries and source code can be found at http://winpcap.polito.it:
-they include also a developer's pack with all the necessary to compile
-libpcap-based applications under Windows.
-
-How to compile libpcap with Visual Studio
------------------------------------------
-
-In order to compile libpcap you will need:
-
-- version 6 (or higher) of Microsoft Visual Studio
-- The November 2001 (or later) edition of Microsoft Platform
-Software Development Kit (SDK), that contains some necessary includes
-for IPv6 support. You can download it from http://www.microsoft.com/sdk
-- the latest WinPcap sources from http://winpcap.polito.it/install
-
-The WinPcap source code already contains a recent (usually the latest
-stable) version of libpcap. If you need to compile a different one,
-simply download it from www.tcpdump.org and copy the sources in the
-winpcap\wpcap\libpcap folder of the WinPcap distribution. If you want to
-compile a libpcap source retrieved from the tcpdump.org Git, you will
-have to create the scanner and the grammar by hand (with lex and yacc)
-or with the cygnus makefile, since The Visual Studio project is not able
-to build them.
-
-Open the project file winpcap\wpcap\prj\wpcap.dsw with Visual Studio and
-build wpcap.dll. wpcap.lib, the library file to link with the applications,
-will be generated in winpcap\wpcap\lib\. wpcap.dll will be generated in
-winpcap\wpcap\prj\release or winpcap\wpcap\prj\debug depending on the type
-of binary that is being created.
-
-How to compile libpcap with Cygnus
-----------------------------------
-
-To build wpcap.dll, cd to the directory WPCAP/PRJ of the WinPcap source code
-distribution and type "make". libwpcap.a, the library file to link with the
-applications, will be generated in winpcap\wpcap\lib\. wpcap.dll will be
-generated in winpcap\wpcap\prj.
-
-Remember, you CANNOT use the MSVC-generated .lib files with gcc, use
-libwpcap.a instead.
-
-"make install" installs wpcap.dll in the Windows system folder.
diff --git a/doc/README.Win32.md b/doc/README.Win32.md
new file mode 100644
index 0000000..8de25c8
--- /dev/null
+++ b/doc/README.Win32.md
@@ -0,0 +1,3 @@
+Win32 used to build with Visual Studio 6, but we now use cmake.
+
+This file needs to be adopted by a windows expert developer.
diff --git a/doc/README.dag b/doc/README.dag
index accae7c..7ea2504 100644
--- a/doc/README.dag
+++ b/doc/README.dag
@@ -5,7 +5,7 @@
 
 1) Install and build the DAG software distribution by following the
 instructions supplied with that package. Current Endace customers can download
-the DAG software distibution from https://www.endace.com
+the DAG software distribution from https://www.endace.com
 
 2) Configure libcap. To allow the 'configure' script to locate the DAG
 software distribution use the '--with-dag' option:
@@ -88,7 +88,7 @@
 as dag0. These are visible via pcap_findalldevs().
 
 libpcap now does NOT set the card's hardware snaplen (slen). This must now be
-set using the appropriate DAG coniguration program, e.g. dagthree, dagfour,
+set using the appropriate DAG configuration program, e.g. dagthree, dagfour,
 dagsix, dagconfig. This is because the snaplen is currently shared between
 all of the streams. In future this may change if per-stream slen is
 implemented.
diff --git a/doc/README.linux.md b/doc/README.linux.md
index ffcb928..ddca4fe 100644
--- a/doc/README.linux.md
+++ b/doc/README.linux.md
@@ -97,9 +97,9 @@
 2.2.x
 =====
 ps_recv   Number of packets that were accepted by the pcap filter
-ps_drop   Always 0, this statistic is not gatherd on this platform
+ps_drop   Always 0, this statistic is not gathered on this platform
 
-2.4.x
+2.4.x and later
 =====
 ps_recv   Number of packets that were accepted by the pcap filter
 ps_drop   Number of packets that had passed filtering but were not
diff --git a/fmtutils.c b/fmtutils.c
index f1a8907..091e0d3 100644
--- a/fmtutils.c
+++ b/fmtutils.c
@@ -65,11 +65,6 @@
 	size_t msglen;
 	char *p;
 	size_t errbuflen_remaining;
-#if defined(HAVE_STRERROR_S)
-	errno_t err;
-#elif defined(HAVE_STRERROR_R)
-	int err;
-#endif
 
 	va_start(ap, fmt);
 	pcap_vsnprintf(errbuf, errbuflen, fmt, ap);
@@ -96,7 +91,10 @@
 	 * Now append the string for the error code.
 	 */
 #if defined(HAVE_STRERROR_S)
-	err = strerror_s(p, errbuflen_remaining, errnum);
+	/*
+	 * We have a Windows-style strerror_s().
+	 */
+	errno_t err = strerror_s(p, errbuflen_remaining, errnum);
 	if (err != 0) {
 		/*
 		 * It doesn't appear to be documented anywhere obvious
@@ -104,8 +102,24 @@
 		 */
 		pcap_snprintf(p, errbuflen_remaining, "Error %d", errnum);
 	}
-#elif defined(HAVE_STRERROR_R)
-	err = strerror_r(errnum, p, errbuflen_remaining);
+#elif defined(HAVE_GNU_STRERROR_R)
+	/*
+	 * We have a GNU-style strerror_r(), which is *not* guaranteed to
+	 * do anything to the buffer handed to it, and which returns a
+	 * pointer to the error string, which may or may not be in
+	 * the buffer.
+	 *
+	 * It is, however, guaranteed to succeed.
+	 */
+	char strerror_buf[PCAP_ERRBUF_SIZE];
+	char *errstring = strerror_r(errnum, strerror_buf, PCAP_ERRBUF_SIZE);
+	pcap_snprintf(p, errbuflen_remaining, "%s", errstring);
+#elif defined(HAVE_POSIX_STRERROR_R)
+	/*
+	 * We have a POSIX-style strerror_r(), which is guaranteed to fill
+	 * in the buffer, but is not guaranteed to succeed.
+	 */
+	int err = strerror_r(errnum, p, errbuflen_remaining);
 	if (err == EINVAL) {
 		/*
 		 * UNIX 03 says this isn't guaranteed to produce a
@@ -129,3 +143,72 @@
 	pcap_snprintf(p, errbuflen_remaining, "%s", pcap_strerror(errnum));
 #endif
 }
+
+#ifdef _WIN32
+/*
+ * Generate an error message based on a format, arguments, and a
+ * Win32 error, with a message for the Win32 error after the formatted output.
+ */
+void
+pcap_fmt_errmsg_for_win32_err(char *errbuf, size_t errbuflen, DWORD errnum,
+    const char *fmt, ...)
+{
+	va_list ap;
+	size_t msglen;
+	char *p;
+	size_t errbuflen_remaining;
+	DWORD retval;
+	char win32_errbuf[PCAP_ERRBUF_SIZE+1];
+
+	va_start(ap, fmt);
+	pcap_vsnprintf(errbuf, errbuflen, fmt, ap);
+	va_end(ap);
+	msglen = strlen(errbuf);
+
+	/*
+	 * Do we have enough space to append ": "?
+	 * Including the terminating '\0', that's 3 bytes.
+	 */
+	if (msglen + 3 > errbuflen) {
+		/* No - just give them what we've produced. */
+		return;
+	}
+	p = errbuf + msglen;
+	errbuflen_remaining = errbuflen - msglen;
+	*p++ = ':';
+	*p++ = ' ';
+	*p = '\0';
+	msglen += 2;
+	errbuflen_remaining -= 2;
+
+	/*
+	 * Now append the string for the error code.
+	 *
+	 * XXX - what language ID to use?
+	 *
+	 * For UN*Xes, pcap_strerror() may or may not return localized
+	 * strings.
+	 *
+	 * We currently don't have localized messages for libpcap, but
+	 * we might want to do so.  On the other hand, if most of these
+	 * messages are going to be read by libpcap developers and
+	 * perhaps by developers of libpcap-based applications, English
+	 * might be a better choice, so the developer doesn't have to
+	 * get the message translated if it's in a language they don't
+	 * happen to understand.
+	 */
+	retval = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_MAX_WIDTH_MASK,
+	    NULL, errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+	    win32_errbuf, PCAP_ERRBUF_SIZE, NULL);
+	if (retval == 0) {
+		/*
+		 * Failed.
+		 */
+		pcap_snprintf(p, errbuflen_remaining,
+		    "Couldn't get error message for error (%lu)", errnum);
+		return;
+	}
+
+	pcap_snprintf(p, errbuflen_remaining, "%s (%lu)", win32_errbuf, errnum);
+}
+#endif
diff --git a/fmtutils.h b/fmtutils.h
index 62c78fd..838948b 100644
--- a/fmtutils.h
+++ b/fmtutils.h
@@ -43,6 +43,11 @@
 void	pcap_fmt_errmsg_for_errno(char *, size_t, int,
     PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5);
 
+#ifdef _WIN32
+void	pcap_fmt_errmsg_for_win32_err(char *, size_t, DWORD,
+    PCAP_FORMAT_STRING(const char *), ...) PCAP_PRINTFLIKE(4, 5);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/ftmacros.h b/ftmacros.h
index de8da98..cd3daeb 100644
--- a/ftmacros.h
+++ b/ftmacros.h
@@ -85,20 +85,14 @@
    */
 #elif defined(__linux__) || defined(linux) || defined(__linux)
   /*
-   * We can't turn _GNU_SOURCE on because some versions of GNU Libc
-   * will give the GNU version of strerror_r(), which returns a
-   * string pointer and doesn't necessarily fill in the buffer,
-   * rather than the standard version of strerror_r(), which
-   * returns 0 or an errno and always fills in the buffer.  We
-   * require both of the latter behaviors.
+   * Turn on _GNU_SOURCE to get everything GNU libc has to offer,
+   * including asprintf().
    *
-   * So we try turning everything else on that we can.  This includes
-   * defining _XOPEN_SOURCE as 600, because we want to force crypt()
-   * to be declared on systems that use GNU libc, such as most Linux
-   * distributions.
+   * Unfortunately, one thing it has to offer is a strerror_r()
+   * that's not POSIX-compliant, but we deal with that in
+   * pcap_fmt_errmsg_for_errno().
    */
-  #define _POSIX_C_SOURCE 200809L
-  #define _XOPEN_SOURCE 600
+  #define _GNU_SOURCE
 
   /*
    * We turn on both _DEFAULT_SOURCE and _BSD_SOURCE to try to get
diff --git a/gencode.c b/gencode.c
index 959a56e..e3425cd 100644
--- a/gencode.c
+++ b/gencode.c
@@ -50,6 +50,8 @@
 
 #include "pcap-int.h"
 
+#include "extract.h"
+
 #include "ethertype.h"
 #include "nlpid.h"
 #include "llc.h"
@@ -277,6 +279,13 @@
 	struct addrinfo *ai;
 
 	/*
+	 * Another thing that's allocated is the result of pcap_ether_aton();
+	 * it must be freed with free().  This variable points to any
+	 * address that would need to be freed.
+	 */
+	u_char *e;
+
+	/*
 	 * Various code constructs need to know the layout of the packet.
 	 * These values give the necessary offsets from the beginning
 	 * of the packet data.
@@ -417,35 +426,49 @@
 	int cur_chunk;
 };
 
-void PCAP_NORETURN
-bpf_syntax_error(compiler_state_t *cstate, const char *msg)
+/*
+ * For use by routines outside this file.
+ */
+/* VARARGS */
+void
+bpf_set_error(compiler_state_t *cstate, const char *fmt, ...)
 {
-	bpf_error(cstate, "syntax error in filter expression: %s", msg);
-	/* NOTREACHED */
+	va_list ap;
+
+	va_start(ap, fmt);
+	(void)pcap_vsnprintf(cstate->bpf_pcap->errbuf, PCAP_ERRBUF_SIZE,
+	    fmt, ap);
+	va_end(ap);
 }
 
+/*
+ * For use *ONLY* in routines in this file.
+ */
+static void PCAP_NORETURN bpf_error(compiler_state_t *, const char *, ...)
+    PCAP_PRINTFLIKE(2, 3);
+
 /* VARARGS */
-void PCAP_NORETURN
+static void PCAP_NORETURN
 bpf_error(compiler_state_t *cstate, const char *fmt, ...)
 {
 	va_list ap;
 
 	va_start(ap, fmt);
-	if (cstate->bpf_pcap != NULL)
-		(void)pcap_vsnprintf(pcap_geterr(cstate->bpf_pcap),
-		    PCAP_ERRBUF_SIZE, fmt, ap);
+	(void)pcap_vsnprintf(cstate->bpf_pcap->errbuf, PCAP_ERRBUF_SIZE,
+	    fmt, ap);
 	va_end(ap);
 	longjmp(cstate->top_ctx, 1);
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
-static void init_linktype(compiler_state_t *, pcap_t *);
+static int init_linktype(compiler_state_t *, pcap_t *);
 
 static void init_regs(compiler_state_t *);
 static int alloc_reg(compiler_state_t *);
 static void free_reg(compiler_state_t *, int);
 
 static void initchunks(compiler_state_t *cstate);
+static void *newchunk_nolongjmp(compiler_state_t *cstate, size_t);
 static void *newchunk(compiler_state_t *cstate, size_t);
 static void freechunks(compiler_state_t *cstate);
 static inline struct block *new_block(compiler_state_t *cstate, int);
@@ -543,6 +566,9 @@
 static struct block *gen_geneve_ll_check(compiler_state_t *cstate);
 
 static struct block *gen_ppi_dlt_check(compiler_state_t *);
+static struct block *gen_atmfield_code_internal(compiler_state_t *, int,
+    bpf_int32, bpf_u_int32, int);
+static struct block *gen_atmtype_llc(compiler_state_t *);
 static struct block *gen_msg_abbrev(compiler_state_t *, int type);
 
 static void
@@ -558,7 +584,7 @@
 }
 
 static void *
-newchunk(compiler_state_t *cstate, size_t n)
+newchunk_nolongjmp(compiler_state_t *cstate, size_t n)
 {
 	struct chunk *cp;
 	int k;
@@ -576,21 +602,40 @@
 	if (n > cp->n_left) {
 		++cp;
 		k = ++cstate->cur_chunk;
-		if (k >= NCHUNKS)
-			bpf_error(cstate, "out of memory");
+		if (k >= NCHUNKS) {
+			bpf_set_error(cstate, "out of memory");
+			return (NULL);
+		}
 		size = CHUNK0SIZE << k;
 		cp->m = (void *)malloc(size);
-		if (cp->m == NULL)
-			bpf_error(cstate, "out of memory");
+		if (cp->m == NULL) {
+			bpf_set_error(cstate, "out of memory");
+			return (NULL);
+		}
 		memset((char *)cp->m, 0, size);
 		cp->n_left = size;
-		if (n > size)
-			bpf_error(cstate, "out of memory");
+		if (n > size) {
+			bpf_set_error(cstate, "out of memory");
+			return (NULL);
+		}
 	}
 	cp->n_left -= n;
 	return (void *)((char *)cp->m + cp->n_left);
 }
 
+static void *
+newchunk(compiler_state_t *cstate, size_t n)
+{
+	void *p;
+
+	p = newchunk_nolongjmp(cstate, n);
+	if (p == NULL) {
+		longjmp(cstate->top_ctx, 1);
+		/*NOTREACHED*/
+	}
+	return (p);
+}
+
 static void
 freechunks(compiler_state_t *cstate)
 {
@@ -603,14 +648,19 @@
 
 /*
  * A strdup whose allocations are freed after code generation is over.
+ * This is used by the lexical analyzer, so it can't longjmp; it just
+ * returns NULL on an allocation error, and the callers must check
+ * for it.
  */
 char *
 sdup(compiler_state_t *cstate, const char *s)
 {
 	size_t n = strlen(s) + 1;
-	char *cp = newchunk(cstate, n);
+	char *cp = newchunk_nolongjmp(cstate, n);
 
-	strlcpy(cp, s, n);
+	if (cp == NULL)
+		return (NULL);
+	pcap_strlcpy(cp, s, n);
 	return (cp);
 }
 
@@ -662,7 +712,7 @@
 	compiler_state_t cstate;
 	const char * volatile xbuf = buf;
 	yyscan_t scanner = NULL;
-	YY_BUFFER_STATE in_buffer = NULL;
+	volatile YY_BUFFER_STATE in_buffer = NULL;
 	u_int len;
 	int  rc;
 
@@ -697,7 +747,7 @@
 	 * filter for this pcap_t; we might be running it from userland
 	 * on captured packets to do packet classification.  We really
 	 * need a better way of handling this, but this is all that
-	 * the WinPcap code did.
+	 * the WinPcap remote capture code did.
 	 */
 	if (p->save_current_filter_op != NULL)
 		(p->save_current_filter_op)(p, buf);
@@ -708,20 +758,12 @@
 #ifdef INET6
 	cstate.ai = NULL;
 #endif
+	cstate.e = NULL;
 	cstate.ic.root = NULL;
 	cstate.ic.cur_mark = 0;
 	cstate.bpf_pcap = p;
 	init_regs(&cstate);
 
-	if (setjmp(cstate.top_ctx)) {
-#ifdef INET6
-		if (cstate.ai != NULL)
-			freeaddrinfo(cstate.ai);
-#endif
-		rc = -1;
-		goto quit;
-	}
-
 	cstate.netmask = mask;
 
 	cstate.snaplen = pcap_snapshot(p);
@@ -743,19 +785,53 @@
 	 */
 	pcap_set_extra(&cstate, scanner);
 
-	init_linktype(&cstate, p);
-	(void)pcap_parse(scanner, &cstate);
+	if (init_linktype(&cstate, p) == -1) {
+		rc = -1;
+		goto quit;
+	}
+	if (pcap_parse(scanner, &cstate) != 0) {
+#ifdef INET6
+		if (cstate.ai != NULL)
+			freeaddrinfo(cstate.ai);
+#endif
+		if (cstate.e != NULL)
+			free(cstate.e);
+		rc = -1;
+		goto quit;
+	}
 
-	if (cstate.ic.root == NULL)
+	if (cstate.ic.root == NULL) {
+		/*
+		 * Catch errors reported by gen_retblk().
+		 */
+		if (setjmp(cstate.top_ctx)) {
+			rc = -1;
+			goto quit;
+		}
 		cstate.ic.root = gen_retblk(&cstate, cstate.snaplen);
+	}
 
 	if (optimize && !cstate.no_optimize) {
-		bpf_optimize(&cstate, &cstate.ic);
+		if (bpf_optimize(&cstate.ic, p->errbuf) == -1) {
+			/* Failure */
+			rc = -1;
+			goto quit;
+		}
 		if (cstate.ic.root == NULL ||
-		    (cstate.ic.root->s.code == (BPF_RET|BPF_K) && cstate.ic.root->s.k == 0))
-			bpf_error(&cstate, "expression rejects all packets");
+		    (cstate.ic.root->s.code == (BPF_RET|BPF_K) && cstate.ic.root->s.k == 0)) {
+			(void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+			    "expression rejects all packets");
+			rc = -1;
+			goto quit;
+		}
 	}
-	program->bf_insns = icode_to_fcode(&cstate, &cstate.ic, cstate.ic.root, &len);
+	program->bf_insns = icode_to_fcode(&cstate.ic,
+	    cstate.ic.root, &len, p->errbuf);
+	if (program->bf_insns == NULL) {
+		/* Failure */
+		rc = -1;
+		goto quit;
+	}
 	program->bf_len = len;
 
 	rc = 0;  /* We're all okay */
@@ -851,12 +927,19 @@
 	*p = b1;
 }
 
-void
+int
 finish_parse(compiler_state_t *cstate, struct block *p)
 {
 	struct block *ppi_dlt_check;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return -1
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (-1);
+
+	/*
 	 * Insert before the statements of the first (root) block any
 	 * statements needed to load the lengths of any variable-length
 	 * headers into registers.
@@ -898,6 +981,7 @@
 	p->sense = !p->sense;
 	backpatch(p, gen_retblk(cstate, 0));
 	cstate->ic.root = p->head;
+	return (0);
 }
 
 void
@@ -975,13 +1059,22 @@
 {
 	register struct block *b, *tmp;
 
+	/*
+	 * XXX - the actual *instructions* do unsigned comparisons on
+	 * most platforms, and the load instructions don't do sign
+	 * extension, so gen_cmp() should really take an unsigned
+	 * value argument.
+	 *
+	 * As the load instructons also don't do sign-extension, we
+	 * fetch the values from the byte array as unsigned.  We don't
+	 * want to use the signed versions of the extract calls.
+	 */
 	b = NULL;
 	while (size >= 4) {
 		register const u_char *p = &v[size - 4];
-		bpf_int32 w = ((bpf_int32)p[0] << 24) |
-		    ((bpf_int32)p[1] << 16) | ((bpf_int32)p[2] << 8) | p[3];
 
-		tmp = gen_cmp(cstate, offrel, offset + size - 4, BPF_W, w);
+		tmp = gen_cmp(cstate, offrel, offset + size - 4, BPF_W,
+		    (bpf_int32)EXTRACT_32BITS(p));
 		if (b != NULL)
 			gen_and(b, tmp);
 		b = tmp;
@@ -989,9 +1082,9 @@
 	}
 	while (size >= 2) {
 		register const u_char *p = &v[size - 2];
-		bpf_int32 w = ((bpf_int32)p[0] << 8) | p[1];
 
-		tmp = gen_cmp(cstate, offrel, offset + size - 2, BPF_H, w);
+		tmp = gen_cmp(cstate, offrel, offset + size - 2, BPF_H,
+		    (bpf_int32)EXTRACT_16BITS(p));
 		if (b != NULL)
 			gen_and(b, tmp);
 		b = tmp;
@@ -1036,7 +1129,7 @@
 	return b;
 }
 
-static void
+static int
 init_linktype(compiler_state_t *cstate, pcap_t *p)
 {
 	cstate->pcap_fddipad = p->fddipad;
@@ -1241,6 +1334,7 @@
 		cstate->off_linkhdr.is_variable = 1;
 		/* Fall through, 802.11 doesn't have a variable link
 		 * prefix but is otherwise the same. */
+		/* FALLTHROUGH */
 
 	case DLT_IEEE802_11:
 		/*
@@ -1330,13 +1424,20 @@
 		cstate->off_nl_nosnap = 0;	/* no 802.2 LLC */
 		break;
 
-	case DLT_LINUX_SLL:	/* fake header for Linux cooked socket */
+	case DLT_LINUX_SLL:	/* fake header for Linux cooked socket v1 */
 		cstate->off_linktype.constant_part = 14;
 		cstate->off_linkpl.constant_part = 16;
 		cstate->off_nl = 0;
 		cstate->off_nl_nosnap = 0;	/* no 802.2 LLC */
 		break;
 
+	case DLT_LINUX_SLL2:	/* fake header for Linux cooked socket v2 */
+		cstate->off_linktype.constant_part = 0;
+		cstate->off_linkpl.constant_part = 20;
+		cstate->off_nl = 0;
+		cstate->off_nl_nosnap = 0;	/* no 802.2 LLC */
+		break;
+
 	case DLT_LTALK:
 		/*
 		 * LocalTalk does have a 1-byte type field in the LLAP header,
@@ -1612,12 +1713,14 @@
 			cstate->off_nl = OFFSET_NOT_SET;
 			cstate->off_nl_nosnap = OFFSET_NOT_SET;
 		} else {
-			bpf_error(cstate, "unknown data link type %d", cstate->linktype);
+			bpf_set_error(cstate, "unknown data link type %d", cstate->linktype);
+			return (-1);
 		}
 		break;
 	}
 
 	cstate->off_outermostlinkhdr = cstate->off_prevlinkhdr = cstate->off_linkhdr;
+	return (0);
 }
 
 /*
@@ -1669,6 +1772,19 @@
 {
 	struct slist *s, *s2;
 
+	/*
+	 * Squelch warnings from compilers that *don't* assume that
+	 * offrel always has a valid enum value and therefore don't
+	 * assume that we'll always go through one of the case arms.
+	 *
+	 * If we have a default case, compilers that *do* assume that
+	 * will then complain about the default case code being
+	 * unreachable.
+	 *
+	 * Damned if you do, damned if you don't.
+	 */
+	s = NULL;
+
 	switch (offrel) {
 
 	case OR_PACKET:
@@ -1732,10 +1848,6 @@
 	case OR_TRAN_IPV6:
 		s = gen_load_absoffsetrel(cstate, &cstate->off_linkpl, cstate->off_nl + 40 + offset, size);
 		break;
-
-	default:
-		abort();
-		/* NOTREACHED */
 	}
 	return s;
 }
@@ -2059,12 +2171,12 @@
 
 	case ETHERTYPE_IP:
 		return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B, (bpf_int32)IPH_AF_INET);
-		/* NOTREACHED */
+		/*NOTREACHED*/
 
 	case ETHERTYPE_IPV6:
 		return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_B,
 		    (bpf_int32)IPH_AF_INET6);
-		/* NOTREACHED */
+		/*NOTREACHED*/
 
 	default:
 		break;
@@ -3041,7 +3153,7 @@
 
 		default:
 			bpf_error(cstate, "unsupported protocol over mpls");
-			/* NOTREACHED */
+			/*NOTREACHED*/
 		}
 	}
 
@@ -3062,7 +3174,6 @@
 			gen_and(b0, b1);
 		return b1;
 		/*NOTREACHED*/
-		break;
 
 	case DLT_C_HDLC:
 		switch (proto) {
@@ -3074,9 +3185,7 @@
 		default:
 			return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
 			/*NOTREACHED*/
-			break;
 		}
-		break;
 
 	case DLT_IEEE802_11:
 	case DLT_PRISM_HEADER:
@@ -3095,7 +3204,6 @@
 		gen_and(b0, b1);
 		return b1;
 		/*NOTREACHED*/
-		break;
 
 	case DLT_FDDI:
 		/*
@@ -3103,7 +3211,6 @@
 		 */
 		return gen_llc_linktype(cstate, proto);
 		/*NOTREACHED*/
-		break;
 
 	case DLT_IEEE802:
 		/*
@@ -3111,14 +3218,12 @@
 		 */
 		return gen_llc_linktype(cstate, proto);
 		/*NOTREACHED*/
-		break;
 
 	case DLT_ATM_RFC1483:
 	case DLT_ATM_CLIP:
 	case DLT_IP_OVER_FC:
 		return gen_llc_linktype(cstate, proto);
 		/*NOTREACHED*/
-		break;
 
 	case DLT_SUNATM:
 		/*
@@ -3128,17 +3233,15 @@
 		 *
 		 * Check for LLC encapsulation and then check the protocol.
 		 */
-		b0 = gen_atmfield_code(cstate, A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
+		b0 = gen_atmfield_code_internal(cstate, A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
 		b1 = gen_llc_linktype(cstate, proto);
 		gen_and(b0, b1);
 		return b1;
 		/*NOTREACHED*/
-		break;
 
 	case DLT_LINUX_SLL:
 		return gen_linux_sll_linktype(cstate, proto);
 		/*NOTREACHED*/
-		break;
 
 	case DLT_SLIP:
 	case DLT_SLIP_BSDOS:
@@ -3164,7 +3267,6 @@
 			return gen_false(cstate);	/* always false */
 		}
 		/*NOTREACHED*/
-		break;
 
 	case DLT_IPV4:
 		/*
@@ -3176,7 +3278,6 @@
 		/* Checking for something other than IPv4; always false */
 		return gen_false(cstate);
 		/*NOTREACHED*/
-		break;
 
 	case DLT_IPV6:
 		/*
@@ -3188,7 +3289,6 @@
 		/* Checking for something other than IPv6; always false */
 		return gen_false(cstate);
 		/*NOTREACHED*/
-		break;
 
 	case DLT_PPP:
 	case DLT_PPP_PPPD:
@@ -3201,7 +3301,6 @@
 		proto = ethertype_to_ppptype(proto);
 		return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
 		/*NOTREACHED*/
-		break;
 
 	case DLT_PPP_BSDOS:
 		/*
@@ -3228,7 +3327,6 @@
 				(bpf_int32)proto);
 		}
 		/*NOTREACHED*/
-		break;
 
 	case DLT_NULL:
 	case DLT_LOOP:
@@ -3323,7 +3421,6 @@
 		else
 			return gen_false(cstate);
 		/*NOTREACHED*/
-		break;
 #endif /* HAVE_NET_PFVAR_H */
 
 	case DLT_ARCNET:
@@ -3366,7 +3463,6 @@
 					(bpf_int32)ARCTYPE_ATALK));
 		}
 		/*NOTREACHED*/
-		break;
 
 	case DLT_LTALK:
 		switch (proto) {
@@ -3376,7 +3472,6 @@
 			return gen_false(cstate);
 		}
 		/*NOTREACHED*/
-		break;
 
 	case DLT_FRELAY:
 		/*
@@ -3420,7 +3515,6 @@
 			return gen_false(cstate);
 		}
 		/*NOTREACHED*/
-		break;
 
 	case DLT_MFR:
 		bpf_error(cstate, "Multi-link Frame Relay link-layer type filtering not implemented");
@@ -3511,7 +3605,8 @@
 	case DLT_RAIF1:
 		bpf_error(cstate, "RAIF1 link-layer type filtering not implemented");
 
-	case DLT_IPMB:
+	case DLT_IPMB_KONTRON:
+	case DLT_IPMB_LINUX:
 		bpf_error(cstate, "IPMB link-layer type filtering not implemented");
 
 	case DLT_AX25_KISS:
@@ -3538,20 +3633,16 @@
 			 * above.)
 			 */
 			return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, (bpf_int32)proto);
+			/*NOTREACHED */
 		} else {
 			/*
 			 * No; report an error.
 			 */
-			description = pcap_datalink_val_to_description(cstate->linktype);
-			if (description != NULL) {
-				bpf_error(cstate, "%s link-layer type filtering not implemented",
-				    description);
-			} else {
-				bpf_error(cstate, "DLT %u link-layer type filtering not implemented",
-				    cstate->linktype);
-			}
+			description = pcap_datalink_val_to_description_or_dlt(cstate->linktype);
+			bpf_error(cstate, "%s link-layer type filtering not implemented",
+			    description);
+			/*NOTREACHED */
 		}
-		break;
 	}
 }
 
@@ -3581,8 +3672,8 @@
 /*
  * Generate code to match frames with an LLC header.
  */
-struct block *
-gen_llc(compiler_state_t *cstate)
+static struct block *
+gen_llc_internal(compiler_state_t *cstate)
 {
 	struct block *b0, *b1;
 
@@ -3609,7 +3700,7 @@
 		/*
 		 * We check for LLC traffic.
 		 */
-		b0 = gen_atmtype_abbrev(cstate, A_LLC);
+		b0 = gen_atmtype_llc(cstate);
 		return b0;
 
 	case DLT_IEEE802:	/* Token Ring */
@@ -3647,21 +3738,42 @@
 		return b0;
 
 	default:
-		bpf_error(cstate, "'llc' not supported for linktype %d", cstate->linktype);
-		/* NOTREACHED */
+		bpf_error(cstate, "'llc' not supported for %s",
+			  pcap_datalink_val_to_description_or_dlt(cstate->linktype));
+		/*NOTREACHED*/
 	}
 }
 
 struct block *
+gen_llc(compiler_state_t *cstate)
+{
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	return gen_llc_internal(cstate);
+}
+
+struct block *
 gen_llc_i(compiler_state_t *cstate)
 {
 	struct block *b0, *b1;
 	struct slist *s;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Check whether this is an LLC frame.
 	 */
-	b0 = gen_llc(cstate);
+	b0 = gen_llc_internal(cstate);
 
 	/*
 	 * Load the control byte and test the low-order bit; it must
@@ -3682,9 +3794,16 @@
 	struct block *b0, *b1;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Check whether this is an LLC frame.
 	 */
-	b0 = gen_llc(cstate);
+	b0 = gen_llc_internal(cstate);
 
 	/*
 	 * Now compare the low-order 2 bit of the control byte against
@@ -3701,9 +3820,16 @@
 	struct block *b0, *b1;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Check whether this is an LLC frame.
 	 */
-	b0 = gen_llc(cstate);
+	b0 = gen_llc_internal(cstate);
 
 	/*
 	 * Now compare the low-order 2 bit of the control byte against
@@ -3720,9 +3846,16 @@
 	struct block *b0, *b1;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Check whether this is an LLC frame.
 	 */
-	b0 = gen_llc(cstate);
+	b0 = gen_llc_internal(cstate);
 
 	/*
 	 * Now check for an S frame with the appropriate type.
@@ -3738,9 +3871,16 @@
 	struct block *b0, *b1;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Check whether this is an LLC frame.
 	 */
-	b0 = gen_llc(cstate);
+	b0 = gen_llc_internal(cstate);
 
 	/*
 	 * Now check for a U frame with the appropriate type.
@@ -3860,8 +4000,8 @@
 		gen_and(b0, b1);
 		return b1;
 
-	case Q_OR:
 	case Q_DEFAULT:
+	case Q_OR:
 		b0 = gen_hostop(cstate, addr, mask, Q_SRC, proto, src_off, dst_off);
 		b1 = gen_hostop(cstate, addr, mask, Q_DST, proto, src_off, dst_off);
 		gen_or(b0, b1);
@@ -3869,30 +4009,31 @@
 
 	case Q_ADDR1:
 		bpf_error(cstate, "'addr1' and 'address1' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR2:
 		bpf_error(cstate, "'addr2' and 'address2' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR3:
 		bpf_error(cstate, "'addr3' and 'address3' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR4:
 		bpf_error(cstate, "'addr4' and 'address4' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_RA:
 		bpf_error(cstate, "'ra' is not a valid qualifier for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_TA:
 		bpf_error(cstate, "'ta' is not a valid qualifier for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	default:
 		abort();
+		/*NOTREACHED*/
 	}
 	b0 = gen_linktype(cstate, proto);
 	b1 = gen_mcmp(cstate, OR_LINKPL, offset, BPF_W, (bpf_int32)addr, mask);
@@ -3925,8 +4066,8 @@
 		gen_and(b0, b1);
 		return b1;
 
-	case Q_OR:
 	case Q_DEFAULT:
+	case Q_OR:
 		b0 = gen_hostop6(cstate, addr, mask, Q_SRC, proto, src_off, dst_off);
 		b1 = gen_hostop6(cstate, addr, mask, Q_DST, proto, src_off, dst_off);
 		gen_or(b0, b1);
@@ -3934,30 +4075,31 @@
 
 	case Q_ADDR1:
 		bpf_error(cstate, "'addr1' and 'address1' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR2:
 		bpf_error(cstate, "'addr2' and 'address2' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR3:
 		bpf_error(cstate, "'addr3' and 'address3' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR4:
 		bpf_error(cstate, "'addr4' and 'address4' are not valid qualifiers for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_RA:
 		bpf_error(cstate, "'ra' is not a valid qualifier for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	case Q_TA:
 		bpf_error(cstate, "'ta' is not a valid qualifier for addresses other than 802.11 MAC addresses");
-		break;
+		/*NOTREACHED*/
 
 	default:
 		abort();
+		/*NOTREACHED*/
 	}
 	/* this order is important */
 	a = (uint32_t *)addr;
@@ -4002,30 +4144,30 @@
 
 	case Q_ADDR1:
 		bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11 with 802.11 headers");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR2:
 		bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11 with 802.11 headers");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR3:
 		bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11 with 802.11 headers");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR4:
 		bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11 with 802.11 headers");
-		break;
+		/*NOTREACHED*/
 
 	case Q_RA:
 		bpf_error(cstate, "'ra' is only supported on 802.11 with 802.11 headers");
-		break;
+		/*NOTREACHED*/
 
 	case Q_TA:
 		bpf_error(cstate, "'ta' is only supported on 802.11 with 802.11 headers");
-		break;
+		/*NOTREACHED*/
 	}
 	abort();
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -4058,30 +4200,30 @@
 
 	case Q_ADDR1:
 		bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR2:
 		bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR3:
 		bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR4:
 		bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_RA:
 		bpf_error(cstate, "'ra' is only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_TA:
 		bpf_error(cstate, "'ta' is only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 	}
 	abort();
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -4114,30 +4256,30 @@
 
 	case Q_ADDR1:
 		bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR2:
 		bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR3:
 		bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR4:
 		bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_RA:
 		bpf_error(cstate, "'ra' is only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_TA:
 		bpf_error(cstate, "'ta' is only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 	}
 	abort();
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -4426,6 +4568,68 @@
 		gen_and(b1, b0);
 		return b0;
 
+	case Q_AND:
+		b0 = gen_wlanhostop(cstate, eaddr, Q_SRC);
+		b1 = gen_wlanhostop(cstate, eaddr, Q_DST);
+		gen_and(b0, b1);
+		return b1;
+
+	case Q_DEFAULT:
+	case Q_OR:
+		b0 = gen_wlanhostop(cstate, eaddr, Q_SRC);
+		b1 = gen_wlanhostop(cstate, eaddr, Q_DST);
+		gen_or(b0, b1);
+		return b1;
+
+	/*
+	 * XXX - add BSSID keyword?
+	 */
+	case Q_ADDR1:
+		return (gen_bcmp(cstate, OR_LINKHDR, 4, 6, eaddr));
+
+	case Q_ADDR2:
+		/*
+		 * Not present in CTS or ACK control frames.
+		 */
+		b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
+			IEEE80211_FC0_TYPE_MASK);
+		gen_not(b0);
+		b1 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS,
+			IEEE80211_FC0_SUBTYPE_MASK);
+		gen_not(b1);
+		b2 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK,
+			IEEE80211_FC0_SUBTYPE_MASK);
+		gen_not(b2);
+		gen_and(b1, b2);
+		gen_or(b0, b2);
+		b1 = gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
+		gen_and(b2, b1);
+		return b1;
+
+	case Q_ADDR3:
+		/*
+		 * Not present in control frames.
+		 */
+		b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
+			IEEE80211_FC0_TYPE_MASK);
+		gen_not(b0);
+		b1 = gen_bcmp(cstate, OR_LINKHDR, 16, 6, eaddr);
+		gen_and(b0, b1);
+		return b1;
+
+	case Q_ADDR4:
+		/*
+		 * Present only if the direction mask has both "From DS"
+		 * and "To DS" set.  Neither control frames nor management
+		 * frames should have both of those set, so we don't
+		 * check the frame type.
+		 */
+		b0 = gen_mcmp(cstate, OR_LINKHDR, 1, BPF_B,
+			IEEE80211_FC1_DIR_DSTODS, IEEE80211_FC1_DIR_MASK);
+		b1 = gen_bcmp(cstate, OR_LINKHDR, 24, 6, eaddr);
+		gen_and(b0, b1);
+		return b1;
+
 	case Q_RA:
 		/*
 		 * Not present in management frames; addr1 in other
@@ -4496,71 +4700,9 @@
 		b1 = gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
 		gen_and(b2, b1);
 		return b1;
-
-	/*
-	 * XXX - add BSSID keyword?
-	 */
-	case Q_ADDR1:
-		return (gen_bcmp(cstate, OR_LINKHDR, 4, 6, eaddr));
-
-	case Q_ADDR2:
-		/*
-		 * Not present in CTS or ACK control frames.
-		 */
-		b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
-			IEEE80211_FC0_TYPE_MASK);
-		gen_not(b0);
-		b1 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_CTS,
-			IEEE80211_FC0_SUBTYPE_MASK);
-		gen_not(b1);
-		b2 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_SUBTYPE_ACK,
-			IEEE80211_FC0_SUBTYPE_MASK);
-		gen_not(b2);
-		gen_and(b1, b2);
-		gen_or(b0, b2);
-		b1 = gen_bcmp(cstate, OR_LINKHDR, 10, 6, eaddr);
-		gen_and(b2, b1);
-		return b1;
-
-	case Q_ADDR3:
-		/*
-		 * Not present in control frames.
-		 */
-		b0 = gen_mcmp(cstate, OR_LINKHDR, 0, BPF_B, IEEE80211_FC0_TYPE_CTL,
-			IEEE80211_FC0_TYPE_MASK);
-		gen_not(b0);
-		b1 = gen_bcmp(cstate, OR_LINKHDR, 16, 6, eaddr);
-		gen_and(b0, b1);
-		return b1;
-
-	case Q_ADDR4:
-		/*
-		 * Present only if the direction mask has both "From DS"
-		 * and "To DS" set.  Neither control frames nor management
-		 * frames should have both of those set, so we don't
-		 * check the frame type.
-		 */
-		b0 = gen_mcmp(cstate, OR_LINKHDR, 1, BPF_B,
-			IEEE80211_FC1_DIR_DSTODS, IEEE80211_FC1_DIR_MASK);
-		b1 = gen_bcmp(cstate, OR_LINKHDR, 24, 6, eaddr);
-		gen_and(b0, b1);
-		return b1;
-
-	case Q_AND:
-		b0 = gen_wlanhostop(cstate, eaddr, Q_SRC);
-		b1 = gen_wlanhostop(cstate, eaddr, Q_DST);
-		gen_and(b0, b1);
-		return b1;
-
-	case Q_DEFAULT:
-	case Q_OR:
-		b0 = gen_wlanhostop(cstate, eaddr, Q_SRC);
-		b1 = gen_wlanhostop(cstate, eaddr, Q_DST);
-		gen_or(b0, b1);
-		return b1;
 	}
 	abort();
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -4595,30 +4737,30 @@
 
 	case Q_ADDR1:
 		bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR2:
 		bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR3:
 		bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_ADDR4:
 		bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_RA:
 		bpf_error(cstate, "'ra' is only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 
 	case Q_TA:
 		bpf_error(cstate, "'ta' is only supported on 802.11");
-		break;
+		/*NOTREACHED*/
 	}
 	abort();
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -4665,19 +4807,41 @@
 		gen_and(b0, b1);
 		return b1;
 
-	case Q_OR:
 	case Q_DEFAULT:
+	case Q_OR:
 		/* Inefficient because we do our Calvinball dance twice */
 		b0 = gen_dnhostop(cstate, addr, Q_SRC);
 		b1 = gen_dnhostop(cstate, addr, Q_DST);
 		gen_or(b0, b1);
 		return b1;
 
-	case Q_ISO:
-		bpf_error(cstate, "ISO host filtering not implemented");
+	case Q_ADDR1:
+		bpf_error(cstate, "'addr1' and 'address1' are not valid qualifiers for addresses other than 802.11 MAC addresses");
+		/*NOTREACHED*/
+
+	case Q_ADDR2:
+		bpf_error(cstate, "'addr2' and 'address2' are not valid qualifiers for addresses other than 802.11 MAC addresses");
+		/*NOTREACHED*/
+
+	case Q_ADDR3:
+		bpf_error(cstate, "'addr3' and 'address3' are not valid qualifiers for addresses other than 802.11 MAC addresses");
+		/*NOTREACHED*/
+
+	case Q_ADDR4:
+		bpf_error(cstate, "'addr4' and 'address4' are not valid qualifiers for addresses other than 802.11 MAC addresses");
+		/*NOTREACHED*/
+
+	case Q_RA:
+		bpf_error(cstate, "'ra' is not a valid qualifier for addresses other than 802.11 MAC addresses");
+		/*NOTREACHED*/
+
+	case Q_TA:
+		bpf_error(cstate, "'ta' is not a valid qualifier for addresses other than 802.11 MAC addresses");
+		/*NOTREACHED*/
 
 	default:
 		abort();
+		/*NOTREACHED*/
 	}
 	b0 = gen_linktype(cstate, ETHERTYPE_DN);
 	/* Check for pad = 1, long header case */
@@ -4769,6 +4933,9 @@
 		}
 		return b0;
 
+	case Q_LINK:
+		bpf_error(cstate, "link-layer modifier applied to %s", typestr);
+
 	case Q_IP:
 		return gen_hostop(cstate, addr, mask, dir, ETHERTYPE_IP, 12, 16);
 
@@ -4778,12 +4945,12 @@
 	case Q_ARP:
 		return gen_hostop(cstate, addr, mask, dir, ETHERTYPE_ARP, 14, 24);
 
-	case Q_TCP:
-		bpf_error(cstate, "'tcp' modifier applied to %s", typestr);
-
 	case Q_SCTP:
 		bpf_error(cstate, "'sctp' modifier applied to %s", typestr);
 
+	case Q_TCP:
+		bpf_error(cstate, "'tcp' modifier applied to %s", typestr);
+
 	case Q_UDP:
 		bpf_error(cstate, "'udp' modifier applied to %s", typestr);
 
@@ -4796,36 +4963,24 @@
 	case Q_IGRP:
 		bpf_error(cstate, "'igrp' modifier applied to %s", typestr);
 
-	case Q_PIM:
-		bpf_error(cstate, "'pim' modifier applied to %s", typestr);
-
-	case Q_VRRP:
-		bpf_error(cstate, "'vrrp' modifier applied to %s", typestr);
-
-	case Q_CARP:
-		bpf_error(cstate, "'carp' modifier applied to %s", typestr);
-
 	case Q_ATALK:
-		bpf_error(cstate, "ATALK host filtering not implemented");
-
-	case Q_AARP:
-		bpf_error(cstate, "AARP host filtering not implemented");
+		bpf_error(cstate, "AppleTalk host filtering not implemented");
 
 	case Q_DECNET:
 		return gen_dnhostop(cstate, addr, dir);
 
-	case Q_SCA:
-		bpf_error(cstate, "SCA host filtering not implemented");
-
 	case Q_LAT:
 		bpf_error(cstate, "LAT host filtering not implemented");
 
-	case Q_MOPDL:
-		bpf_error(cstate, "MOPDL host filtering not implemented");
+	case Q_SCA:
+		bpf_error(cstate, "SCA host filtering not implemented");
 
 	case Q_MOPRC:
 		bpf_error(cstate, "MOPRC host filtering not implemented");
 
+	case Q_MOPDL:
+		bpf_error(cstate, "MOPDL host filtering not implemented");
+
 	case Q_IPV6:
 		bpf_error(cstate, "'ip6' modifier applied to ip host");
 
@@ -4838,6 +4993,15 @@
 	case Q_ESP:
 		bpf_error(cstate, "'esp' modifier applied to %s", typestr);
 
+	case Q_PIM:
+		bpf_error(cstate, "'pim' modifier applied to %s", typestr);
+
+	case Q_VRRP:
+		bpf_error(cstate, "'vrrp' modifier applied to %s", typestr);
+
+	case Q_AARP:
+		bpf_error(cstate, "AARP host filtering not implemented");
+
 	case Q_ISO:
 		bpf_error(cstate, "ISO host filtering not implemented");
 
@@ -4859,13 +5023,37 @@
 	case Q_NETBEUI:
 		bpf_error(cstate, "'netbeui' modifier applied to %s", typestr);
 
+	case Q_ISIS_L1:
+		bpf_error(cstate, "'l1' modifier applied to %s", typestr);
+
+	case Q_ISIS_L2:
+		bpf_error(cstate, "'l2' modifier applied to %s", typestr);
+
+	case Q_ISIS_IIH:
+		bpf_error(cstate, "'iih' modifier applied to %s", typestr);
+
+	case Q_ISIS_SNP:
+		bpf_error(cstate, "'snp' modifier applied to %s", typestr);
+
+	case Q_ISIS_CSNP:
+		bpf_error(cstate, "'csnp' modifier applied to %s", typestr);
+
+	case Q_ISIS_PSNP:
+		bpf_error(cstate, "'psnp' modifier applied to %s", typestr);
+
+	case Q_ISIS_LSP:
+		bpf_error(cstate, "'lsp' modifier applied to %s", typestr);
+
 	case Q_RADIO:
 		bpf_error(cstate, "'radio' modifier applied to %s", typestr);
 
+	case Q_CARP:
+		bpf_error(cstate, "'carp' modifier applied to %s", typestr);
+
 	default:
 		abort();
 	}
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 #ifdef INET6
@@ -4898,93 +5086,114 @@
 		bpf_error(cstate, "'arp' modifier applied to ip6 %s", typestr);
 
 	case Q_SCTP:
-		bpf_error(cstate, "'sctp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'sctp' modifier applied to ip6 %s", typestr);
 
 	case Q_TCP:
-		bpf_error(cstate, "'tcp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'tcp' modifier applied to ip6 %s", typestr);
 
 	case Q_UDP:
-		bpf_error(cstate, "'udp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'udp' modifier applied to ip6 %s", typestr);
 
 	case Q_ICMP:
-		bpf_error(cstate, "'icmp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'icmp' modifier applied to ip6 %s", typestr);
 
 	case Q_IGMP:
-		bpf_error(cstate, "'igmp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'igmp' modifier applied to ip6 %s", typestr);
 
 	case Q_IGRP:
-		bpf_error(cstate, "'igrp' modifier applied to %s", typestr);
-
-	case Q_PIM:
-		bpf_error(cstate, "'pim' modifier applied to %s", typestr);
-
-	case Q_VRRP:
-		bpf_error(cstate, "'vrrp' modifier applied to %s", typestr);
-
-	case Q_CARP:
-		bpf_error(cstate, "'carp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'igrp' modifier applied to ip6 %s", typestr);
 
 	case Q_ATALK:
-		bpf_error(cstate, "ATALK host filtering not implemented");
-
-	case Q_AARP:
-		bpf_error(cstate, "AARP host filtering not implemented");
+		bpf_error(cstate, "AppleTalk modifier applied to ip6 %s", typestr);
 
 	case Q_DECNET:
 		bpf_error(cstate, "'decnet' modifier applied to ip6 %s", typestr);
 
-	case Q_SCA:
-		bpf_error(cstate, "SCA host filtering not implemented");
-
 	case Q_LAT:
-		bpf_error(cstate, "LAT host filtering not implemented");
+		bpf_error(cstate, "'lat' modifier applied to ip6 %s", typestr);
 
-	case Q_MOPDL:
-		bpf_error(cstate, "MOPDL host filtering not implemented");
+	case Q_SCA:
+		bpf_error(cstate, "'sca' modifier applied to ip6 %s", typestr);
 
 	case Q_MOPRC:
-		bpf_error(cstate, "MOPRC host filtering not implemented");
+		bpf_error(cstate, "'moprc' modifier applied to ip6 %s", typestr);
+
+	case Q_MOPDL:
+		bpf_error(cstate, "'mopdl' modifier applied to ip6 %s", typestr);
 
 	case Q_IPV6:
 		return gen_hostop6(cstate, addr, mask, dir, ETHERTYPE_IPV6, 8, 24);
 
 	case Q_ICMPV6:
-		bpf_error(cstate, "'icmp6' modifier applied to %s", typestr);
+		bpf_error(cstate, "'icmp6' modifier applied to ip6 %s", typestr);
 
 	case Q_AH:
-		bpf_error(cstate, "'ah' modifier applied to %s", typestr);
+		bpf_error(cstate, "'ah' modifier applied to ip6 %s", typestr);
 
 	case Q_ESP:
-		bpf_error(cstate, "'esp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'esp' modifier applied to ip6 %s", typestr);
+
+	case Q_PIM:
+		bpf_error(cstate, "'pim' modifier applied to ip6 %s", typestr);
+
+	case Q_VRRP:
+		bpf_error(cstate, "'vrrp' modifier applied to ip6 %s", typestr);
+
+	case Q_AARP:
+		bpf_error(cstate, "'aarp' modifier applied to ip6 %s", typestr);
 
 	case Q_ISO:
-		bpf_error(cstate, "ISO host filtering not implemented");
+		bpf_error(cstate, "'iso' modifier applied to ip6 %s", typestr);
 
 	case Q_ESIS:
-		bpf_error(cstate, "'esis' modifier applied to %s", typestr);
+		bpf_error(cstate, "'esis' modifier applied to ip6 %s", typestr);
 
 	case Q_ISIS:
-		bpf_error(cstate, "'isis' modifier applied to %s", typestr);
+		bpf_error(cstate, "'isis' modifier applied to ip6 %s", typestr);
 
 	case Q_CLNP:
-		bpf_error(cstate, "'clnp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'clnp' modifier applied to ip6 %s", typestr);
 
 	case Q_STP:
-		bpf_error(cstate, "'stp' modifier applied to %s", typestr);
+		bpf_error(cstate, "'stp' modifier applied to ip6 %s", typestr);
 
 	case Q_IPX:
-		bpf_error(cstate, "IPX host filtering not implemented");
+		bpf_error(cstate, "'ipx' modifier applied to ip6 %s", typestr);
 
 	case Q_NETBEUI:
-		bpf_error(cstate, "'netbeui' modifier applied to %s", typestr);
+		bpf_error(cstate, "'netbeui' modifier applied to ip6 %s", typestr);
+
+	case Q_ISIS_L1:
+		bpf_error(cstate, "'l1' modifier applied to ip6 %s", typestr);
+
+	case Q_ISIS_L2:
+		bpf_error(cstate, "'l2' modifier applied to ip6 %s", typestr);
+
+	case Q_ISIS_IIH:
+		bpf_error(cstate, "'iih' modifier applied to ip6 %s", typestr);
+
+	case Q_ISIS_SNP:
+		bpf_error(cstate, "'snp' modifier applied to ip6 %s", typestr);
+
+	case Q_ISIS_CSNP:
+		bpf_error(cstate, "'csnp' modifier applied to ip6 %s", typestr);
+
+	case Q_ISIS_PSNP:
+		bpf_error(cstate, "'psnp' modifier applied to ip6 %s", typestr);
+
+	case Q_ISIS_LSP:
+		bpf_error(cstate, "'lsp' modifier applied to ip6 %s", typestr);
 
 	case Q_RADIO:
-		bpf_error(cstate, "'radio' modifier applied to %s", typestr);
+		bpf_error(cstate, "'radio' modifier applied to ip6 %s", typestr);
+
+	case Q_CARP:
+		bpf_error(cstate, "'carp' modifier applied to ip6 %s", typestr);
 
 	default:
 		abort();
 	}
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 #endif
 
@@ -5091,12 +5300,12 @@
 		return b1;
 	}
 	bpf_error(cstate, "illegal modifier of 'gateway'");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 #endif
 
-struct block *
-gen_proto_abbrev(compiler_state_t *cstate, int proto)
+static struct block *
+gen_proto_abbrev_internal(compiler_state_t *cstate, int proto)
 {
 	struct block *b0;
 	struct block *b1;
@@ -5335,6 +5544,19 @@
 	return b1;
 }
 
+struct block *
+gen_proto_abbrev(compiler_state_t *cstate, int proto)
+{
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	return gen_proto_abbrev_internal(cstate, proto);
+}
+
 static struct block *
 gen_ipfrag(compiler_state_t *cstate)
 {
@@ -5391,21 +5613,46 @@
 		b1 = gen_portatom(cstate, 2, (bpf_int32)port);
 		break;
 
-	case Q_OR:
-	case Q_DEFAULT:
-		tmp = gen_portatom(cstate, 0, (bpf_int32)port);
-		b1 = gen_portatom(cstate, 2, (bpf_int32)port);
-		gen_or(tmp, b1);
-		break;
-
 	case Q_AND:
 		tmp = gen_portatom(cstate, 0, (bpf_int32)port);
 		b1 = gen_portatom(cstate, 2, (bpf_int32)port);
 		gen_and(tmp, b1);
 		break;
 
+	case Q_DEFAULT:
+	case Q_OR:
+		tmp = gen_portatom(cstate, 0, (bpf_int32)port);
+		b1 = gen_portatom(cstate, 2, (bpf_int32)port);
+		gen_or(tmp, b1);
+		break;
+
+	case Q_ADDR1:
+		bpf_error(cstate, "'addr1' and 'address1' are not valid qualifiers for ports");
+		/*NOTREACHED*/
+
+	case Q_ADDR2:
+		bpf_error(cstate, "'addr2' and 'address2' are not valid qualifiers for ports");
+		/*NOTREACHED*/
+
+	case Q_ADDR3:
+		bpf_error(cstate, "'addr3' and 'address3' are not valid qualifiers for ports");
+		/*NOTREACHED*/
+
+	case Q_ADDR4:
+		bpf_error(cstate, "'addr4' and 'address4' are not valid qualifiers for ports");
+		/*NOTREACHED*/
+
+	case Q_RA:
+		bpf_error(cstate, "'ra' is not a valid qualifier for ports");
+		/*NOTREACHED*/
+
+	case Q_TA:
+		bpf_error(cstate, "'ta' is not a valid qualifier for ports");
+		/*NOTREACHED*/
+
 	default:
 		abort();
+		/*NOTREACHED*/
 	}
 	gen_and(b0, b1);
 
@@ -5476,19 +5723,19 @@
 		b1 = gen_portatom6(cstate, 2, (bpf_int32)port);
 		break;
 
-	case Q_OR:
-	case Q_DEFAULT:
-		tmp = gen_portatom6(cstate, 0, (bpf_int32)port);
-		b1 = gen_portatom6(cstate, 2, (bpf_int32)port);
-		gen_or(tmp, b1);
-		break;
-
 	case Q_AND:
 		tmp = gen_portatom6(cstate, 0, (bpf_int32)port);
 		b1 = gen_portatom6(cstate, 2, (bpf_int32)port);
 		gen_and(tmp, b1);
 		break;
 
+	case Q_DEFAULT:
+	case Q_OR:
+		tmp = gen_portatom6(cstate, 0, (bpf_int32)port);
+		b1 = gen_portatom6(cstate, 2, (bpf_int32)port);
+		gen_or(tmp, b1);
+		break;
+
 	default:
 		abort();
 	}
@@ -5573,21 +5820,46 @@
 		b1 = gen_portrangeatom(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
 		break;
 
-	case Q_OR:
-	case Q_DEFAULT:
-		tmp = gen_portrangeatom(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
-		b1 = gen_portrangeatom(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
-		gen_or(tmp, b1);
-		break;
-
 	case Q_AND:
 		tmp = gen_portrangeatom(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
 		b1 = gen_portrangeatom(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
 		gen_and(tmp, b1);
 		break;
 
+	case Q_DEFAULT:
+	case Q_OR:
+		tmp = gen_portrangeatom(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
+		b1 = gen_portrangeatom(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
+		gen_or(tmp, b1);
+		break;
+
+	case Q_ADDR1:
+		bpf_error(cstate, "'addr1' and 'address1' are not valid qualifiers for port ranges");
+		/*NOTREACHED*/
+
+	case Q_ADDR2:
+		bpf_error(cstate, "'addr2' and 'address2' are not valid qualifiers for port ranges");
+		/*NOTREACHED*/
+
+	case Q_ADDR3:
+		bpf_error(cstate, "'addr3' and 'address3' are not valid qualifiers for port ranges");
+		/*NOTREACHED*/
+
+	case Q_ADDR4:
+		bpf_error(cstate, "'addr4' and 'address4' are not valid qualifiers for port ranges");
+		/*NOTREACHED*/
+
+	case Q_RA:
+		bpf_error(cstate, "'ra' is not a valid qualifier for port ranges");
+		/*NOTREACHED*/
+
+	case Q_TA:
+		bpf_error(cstate, "'ta' is not a valid qualifier for port ranges");
+		/*NOTREACHED*/
+
 	default:
 		abort();
+		/*NOTREACHED*/
 	}
 	gen_and(b0, b1);
 
@@ -5669,19 +5941,19 @@
 		b1 = gen_portrangeatom6(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
 		break;
 
-	case Q_OR:
-	case Q_DEFAULT:
-		tmp = gen_portrangeatom6(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
-		b1 = gen_portrangeatom6(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
-		gen_or(tmp, b1);
-		break;
-
 	case Q_AND:
 		tmp = gen_portrangeatom6(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
 		b1 = gen_portrangeatom6(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
 		gen_and(tmp, b1);
 		break;
 
+	case Q_DEFAULT:
+	case Q_OR:
+		tmp = gen_portrangeatom6(cstate, 0, (bpf_int32)port1, (bpf_int32)port2);
+		b1 = gen_portrangeatom6(cstate, 2, (bpf_int32)port1, (bpf_int32)port2);
+		gen_or(tmp, b1);
+		break;
+
 	default:
 		abort();
 	}
@@ -6116,6 +6388,9 @@
 		gen_or(b0, b1);
 		return b1;
 
+	case Q_LINK:
+		return gen_linktype(cstate, v);
+
 	case Q_IP:
 		/*
 		 * For FDDI, RFC 1188 says that SNAP encapsulation is used,
@@ -6141,6 +6416,104 @@
 		gen_and(b0, b1);
 		return b1;
 
+	case Q_ARP:
+		bpf_error(cstate, "arp does not encapsulate another protocol");
+		/*NOTREACHED*/
+
+	case Q_RARP:
+		bpf_error(cstate, "rarp does not encapsulate another protocol");
+		/*NOTREACHED*/
+
+	case Q_SCTP:
+		bpf_error(cstate, "'sctp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_TCP:
+		bpf_error(cstate, "'tcp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_UDP:
+		bpf_error(cstate, "'udp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ICMP:
+		bpf_error(cstate, "'icmp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_IGMP:
+		bpf_error(cstate, "'igmp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_IGRP:
+		bpf_error(cstate, "'igrp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ATALK:
+		bpf_error(cstate, "AppleTalk encapsulation is not specifiable");
+		/*NOTREACHED*/
+
+	case Q_DECNET:
+		bpf_error(cstate, "DECNET encapsulation is not specifiable");
+		/*NOTREACHED*/
+
+	case Q_LAT:
+		bpf_error(cstate, "LAT does not encapsulate another protocol");
+		/*NOTREACHED*/
+
+	case Q_SCA:
+		bpf_error(cstate, "SCA does not encapsulate another protocol");
+		/*NOTREACHED*/
+
+	case Q_MOPRC:
+		bpf_error(cstate, "MOPRC does not encapsulate another protocol");
+		/*NOTREACHED*/
+
+	case Q_MOPDL:
+		bpf_error(cstate, "MOPDL does not encapsulate another protocol");
+		/*NOTREACHED*/
+
+	case Q_IPV6:
+		b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
+#ifndef CHASE_CHAIN
+		/*
+		 * Also check for a fragment header before the final
+		 * header.
+		 */
+		b2 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, IPPROTO_FRAGMENT);
+		b1 = gen_cmp(cstate, OR_LINKPL, 40, BPF_B, (bpf_int32)v);
+		gen_and(b2, b1);
+		b2 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, (bpf_int32)v);
+		gen_or(b2, b1);
+#else
+		b1 = gen_protochain(cstate, v, Q_IPV6);
+#endif
+		gen_and(b0, b1);
+		return b1;
+
+	case Q_ICMPV6:
+		bpf_error(cstate, "'icmp6 proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_AH:
+		bpf_error(cstate, "'ah proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ESP:
+		bpf_error(cstate, "'ah proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_PIM:
+		bpf_error(cstate, "'pim proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_VRRP:
+		bpf_error(cstate, "'vrrp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_AARP:
+		bpf_error(cstate, "'aarp proto' is bogus");
+		/*NOTREACHED*/
+
 	case Q_ISO:
 		switch (cstate->linktype) {
 
@@ -6165,7 +6538,6 @@
 			 */
 			return gen_cmp(cstate, OR_LINKHDR, 2, BPF_H, (0x03<<8) | v);
 			/*NOTREACHED*/
-			break;
 
 		case DLT_C_HDLC:
 			/*
@@ -6185,6 +6557,10 @@
 			return b1;
 		}
 
+	case Q_ESIS:
+		bpf_error(cstate, "'esis proto' is bogus");
+		/*NOTREACHED*/
+
 	case Q_ISIS:
 		b0 = gen_proto(cstate, ISO10589_ISIS, Q_ISO, Q_DEFAULT);
 		/*
@@ -6195,121 +6571,63 @@
 		gen_and(b0, b1);
 		return b1;
 
-	case Q_ARP:
-		bpf_error(cstate, "arp does not encapsulate another protocol");
-		/* NOTREACHED */
-
-	case Q_RARP:
-		bpf_error(cstate, "rarp does not encapsulate another protocol");
-		/* NOTREACHED */
-
-	case Q_ATALK:
-		bpf_error(cstate, "atalk encapsulation is not specifiable");
-		/* NOTREACHED */
-
-	case Q_DECNET:
-		bpf_error(cstate, "decnet encapsulation is not specifiable");
-		/* NOTREACHED */
-
-	case Q_SCA:
-		bpf_error(cstate, "sca does not encapsulate another protocol");
-		/* NOTREACHED */
-
-	case Q_LAT:
-		bpf_error(cstate, "lat does not encapsulate another protocol");
-		/* NOTREACHED */
-
-	case Q_MOPRC:
-		bpf_error(cstate, "moprc does not encapsulate another protocol");
-		/* NOTREACHED */
-
-	case Q_MOPDL:
-		bpf_error(cstate, "mopdl does not encapsulate another protocol");
-		/* NOTREACHED */
-
-	case Q_LINK:
-		return gen_linktype(cstate, v);
-
-	case Q_UDP:
-		bpf_error(cstate, "'udp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_TCP:
-		bpf_error(cstate, "'tcp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_SCTP:
-		bpf_error(cstate, "'sctp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_ICMP:
-		bpf_error(cstate, "'icmp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_IGMP:
-		bpf_error(cstate, "'igmp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_IGRP:
-		bpf_error(cstate, "'igrp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_PIM:
-		bpf_error(cstate, "'pim proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_VRRP:
-		bpf_error(cstate, "'vrrp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_CARP:
-		bpf_error(cstate, "'carp proto' is bogus");
-		/* NOTREACHED */
-
-	case Q_IPV6:
-		b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
-#ifndef CHASE_CHAIN
-		/*
-		 * Also check for a fragment header before the final
-		 * header.
-		 */
-		b2 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, IPPROTO_FRAGMENT);
-		b1 = gen_cmp(cstate, OR_LINKPL, 40, BPF_B, (bpf_int32)v);
-		gen_and(b2, b1);
-		b2 = gen_cmp(cstate, OR_LINKPL, 6, BPF_B, (bpf_int32)v);
-		gen_or(b2, b1);
-#else
-		b1 = gen_protochain(cstate, v, Q_IPV6);
-#endif
-		gen_and(b0, b1);
-		return b1;
-
-	case Q_ICMPV6:
-		bpf_error(cstate, "'icmp6 proto' is bogus");
-
-	case Q_AH:
-		bpf_error(cstate, "'ah proto' is bogus");
-
-	case Q_ESP:
-		bpf_error(cstate, "'ah proto' is bogus");
+	case Q_CLNP:
+		bpf_error(cstate, "'clnp proto' is not supported");
+		/*NOTREACHED*/
 
 	case Q_STP:
 		bpf_error(cstate, "'stp proto' is bogus");
+		/*NOTREACHED*/
 
 	case Q_IPX:
 		bpf_error(cstate, "'ipx proto' is bogus");
+		/*NOTREACHED*/
 
 	case Q_NETBEUI:
 		bpf_error(cstate, "'netbeui proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ISIS_L1:
+		bpf_error(cstate, "'l1 proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ISIS_L2:
+		bpf_error(cstate, "'l2 proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ISIS_IIH:
+		bpf_error(cstate, "'iih proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ISIS_SNP:
+		bpf_error(cstate, "'snp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ISIS_CSNP:
+		bpf_error(cstate, "'csnp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ISIS_PSNP:
+		bpf_error(cstate, "'psnp proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_ISIS_LSP:
+		bpf_error(cstate, "'lsp proto' is bogus");
+		/*NOTREACHED*/
 
 	case Q_RADIO:
 		bpf_error(cstate, "'radio proto' is bogus");
+		/*NOTREACHED*/
+
+	case Q_CARP:
+		bpf_error(cstate, "'carp proto' is bogus");
+		/*NOTREACHED*/
 
 	default:
 		abort();
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
@@ -6331,6 +6649,13 @@
 	int port, real_proto;
 	int port1, port2;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (q.addr) {
 
 	case Q_NET:
@@ -6609,10 +6934,10 @@
 
 	case Q_UNDEF:
 		syntax(cstate);
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 	abort();
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
@@ -6622,6 +6947,13 @@
 	register int nlen, mlen;
 	bpf_u_int32 n, m;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	nlen = __pcap_atoin(s1, &n);
 	/* Promote short ipaddr */
 	n <<= 32 - nlen;
@@ -6657,19 +6989,28 @@
 
 	default:
 		bpf_error(cstate, "Mask syntax for networks only");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
 gen_ncode(compiler_state_t *cstate, const char *s, bpf_u_int32 v, struct qual q)
 {
 	bpf_u_int32 mask;
-	int proto = q.proto;
-	int dir = q.dir;
+	int proto;
+	int dir;
 	register int vlen;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	proto = q.proto;
+	dir = q.dir;
 	if (s == NULL)
 		vlen = 32;
 	else if (q.proto == Q_DECNET) {
@@ -6750,7 +7091,7 @@
 
 	case Q_GATEWAY:
 		bpf_error(cstate, "'gateway' requires a name");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 
 	case Q_PROTO:
 		return gen_proto(cstate, (int)v, proto, dir);
@@ -6760,13 +7101,13 @@
 
 	case Q_UNDEF:
 		syntax(cstate);
-		/* NOTREACHED */
+		/*NOTREACHED*/
 
 	default:
 		abort();
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 #ifdef INET6
@@ -6780,6 +7121,13 @@
 	struct block *b;
 	uint32_t *a, *m;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if (s2)
 		bpf_error(cstate, "no mask %s supported", s2);
 
@@ -6823,45 +7171,64 @@
 
 	default:
 		bpf_error(cstate, "invalid qualifier against IPv6 address");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 }
 #endif /*INET6*/
 
 struct block *
-gen_ecode(compiler_state_t *cstate, const u_char *eaddr, struct qual q)
+gen_ecode(compiler_state_t *cstate, const char *s, struct qual q)
 {
 	struct block *b, *tmp;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) {
+		cstate->e = pcap_ether_aton(s);
+		if (cstate->e == NULL)
+			bpf_error(cstate, "malloc");
 		switch (cstate->linktype) {
 		case DLT_EN10MB:
 		case DLT_NETANALYZER:
 		case DLT_NETANALYZER_TRANSPARENT:
 			tmp = gen_prevlinkhdr_check(cstate);
-			b = gen_ehostop(cstate, eaddr, (int)q.dir);
+			b = gen_ehostop(cstate, cstate->e, (int)q.dir);
 			if (tmp != NULL)
 				gen_and(tmp, b);
-			return b;
+			break;
 		case DLT_FDDI:
-			return gen_fhostop(cstate, eaddr, (int)q.dir);
+			b = gen_fhostop(cstate, cstate->e, (int)q.dir);
+			break;
 		case DLT_IEEE802:
-			return gen_thostop(cstate, eaddr, (int)q.dir);
+			b = gen_thostop(cstate, cstate->e, (int)q.dir);
+			break;
 		case DLT_IEEE802_11:
 		case DLT_PRISM_HEADER:
 		case DLT_IEEE802_11_RADIO_AVS:
 		case DLT_IEEE802_11_RADIO:
 		case DLT_PPI:
-			return gen_wlanhostop(cstate, eaddr, (int)q.dir);
-		case DLT_IP_OVER_FC:
-			return gen_ipfchostop(cstate, eaddr, (int)q.dir);
-		default:
-			bpf_error(cstate, "ethernet addresses supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
+			b = gen_wlanhostop(cstate, cstate->e, (int)q.dir);
 			break;
+		case DLT_IP_OVER_FC:
+			b = gen_ipfchostop(cstate, cstate->e, (int)q.dir);
+			break;
+		default:
+			free(cstate->e);
+			cstate->e = NULL;
+			bpf_error(cstate, "ethernet addresses supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
+			/*NOTREACHED*/
 		}
+		free(cstate->e);
+		cstate->e = NULL;
+		return (b);
 	}
 	bpf_error(cstate, "ethernet address used in non-ether expression");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 void
@@ -6903,8 +7270,8 @@
  * (1, 2, or 4) at that offset into that register, making it the register
  * for "index".
  */
-struct arth *
-gen_load(compiler_state_t *cstate, int proto, struct arth *inst, int size)
+static struct arth *
+gen_load_internal(compiler_state_t *cstate, int proto, struct arth *inst, int size)
 {
 	struct slist *s, *tmp;
 	struct block *b;
@@ -7050,7 +7417,7 @@
 		 * Do the computation only if the packet contains
 		 * the protocol in question.
 		 */
-		b = gen_proto_abbrev(cstate, proto);
+		b = gen_proto_abbrev_internal(cstate, proto);
 		if (inst->b)
 			gen_and(inst->b, b);
 		inst->b = b;
@@ -7108,10 +7475,10 @@
 		 * if this is an IP datagram and is the first or
 		 * only fragment of that datagram.
 		 */
-		gen_and(gen_proto_abbrev(cstate, proto), b = gen_ipfrag(cstate));
+		gen_and(gen_proto_abbrev_internal(cstate, proto), b = gen_ipfrag(cstate));
 		if (inst->b)
 			gen_and(inst->b, b);
-		gen_and(gen_proto_abbrev(cstate, Q_IP), b);
+		gen_and(gen_proto_abbrev_internal(cstate, Q_IP), b);
 		inst->b = b;
 		break;
 	case Q_ICMPV6:
@@ -7119,7 +7486,7 @@
         * Do the computation only if the packet contains
         * the protocol in question.
         */
-        b = gen_proto_abbrev(cstate, Q_IPV6);
+        b = gen_proto_abbrev_internal(cstate, Q_IPV6);
         if (inst->b) {
             gen_and(inst->b, b);
         }
@@ -7176,8 +7543,21 @@
 	return inst;
 }
 
-struct block *
-gen_relation(compiler_state_t *cstate, int code, struct arth *a0,
+struct arth *
+gen_load(compiler_state_t *cstate, int proto, struct arth *inst, int size)
+{
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	return gen_load_internal(cstate, proto, inst, size);
+}
+
+static struct block *
+gen_relation_internal(compiler_state_t *cstate, int code, struct arth *a0,
     struct arth *a1, int reversed)
 {
 	struct slist *s0, *s1, *s2;
@@ -7220,13 +7600,36 @@
 	return b;
 }
 
+struct block *
+gen_relation(compiler_state_t *cstate, int code, struct arth *a0,
+    struct arth *a1, int reversed)
+{
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	return gen_relation_internal(cstate, code, a0, a1, reversed);
+}
+
 struct arth *
 gen_loadlen(compiler_state_t *cstate)
 {
-	int regno = alloc_reg(cstate);
-	struct arth *a = (struct arth *)newchunk(cstate, sizeof(*a));
+	int regno;
+	struct arth *a;
 	struct slist *s;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	regno = alloc_reg(cstate);
+	a = (struct arth *)newchunk(cstate, sizeof(*a));
 	s = new_stmt(cstate, BPF_LD|BPF_LEN);
 	s->next = new_stmt(cstate, BPF_ST);
 	s->next->s.k = regno;
@@ -7236,8 +7639,8 @@
 	return a;
 }
 
-struct arth *
-gen_loadi(compiler_state_t *cstate, int val)
+static struct arth *
+gen_loadi_internal(compiler_state_t *cstate, int val)
 {
 	struct arth *a;
 	struct slist *s;
@@ -7258,10 +7661,36 @@
 }
 
 struct arth *
-gen_neg(compiler_state_t *cstate, struct arth *a)
+gen_loadi(compiler_state_t *cstate, int val)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	return gen_loadi_internal(cstate, val);
+}
+
+/*
+ * The a_arg dance is to avoid annoying whining by compilers that
+ * a might be clobbered by longjmp - yeah, it might, but *WHO CARES*?
+ * It's not *used* after setjmp returns.
+ */
+struct arth *
+gen_neg(compiler_state_t *cstate, struct arth *a_arg)
+{
+	struct arth *a = a_arg;
 	struct slist *s;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	s = xfer_to_a(cstate, a);
 	sappend(a->s, s);
 	s = new_stmt(cstate, BPF_ALU|BPF_NEG);
@@ -7274,15 +7703,31 @@
 	return a;
 }
 
+/*
+ * The a0_arg dance is to avoid annoying whining by compilers that
+ * a0 might be clobbered by longjmp - yeah, it might, but *WHO CARES*?
+ * It's not *used* after setjmp returns.
+ */
 struct arth *
-gen_arth(compiler_state_t *cstate, int code, struct arth *a0,
+gen_arth(compiler_state_t *cstate, int code, struct arth *a0_arg,
     struct arth *a1)
 {
+	struct arth *a0 = a0_arg;
 	struct slist *s0, *s1, *s2;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Disallow division by, or modulus by, zero; we do this here
 	 * so that it gets done even if the optimizer is disabled.
+	 *
+	 * Also disallow shifts by a value greater than 31; we do this
+	 * here, for the same reason.
 	 */
 	if (code == BPF_DIV) {
 		if (a1->s->s.code == (BPF_LD|BPF_IMM) && a1->s->s.k == 0)
@@ -7290,6 +7735,15 @@
 	} else if (code == BPF_MOD) {
 		if (a1->s->s.code == (BPF_LD|BPF_IMM) && a1->s->s.k == 0)
 			bpf_error(cstate, "modulus by zero");
+	} else if (code == BPF_LSH || code == BPF_RSH) {
+		/*
+		 * XXX - we need to make up our minds as to what integers
+		 * are signed and what integers are unsigned in BPF programs
+		 * and in our IR.
+		 */
+		if (a1->s->s.code == (BPF_LD|BPF_IMM) &&
+		    (a1->s->s.k < 0 || a1->s->s.k > 31))
+			bpf_error(cstate, "shift by more than 31 bits");
 	}
 	s0 = xfer_to_x(cstate, a1);
 	s1 = xfer_to_a(cstate, a0);
@@ -7337,7 +7791,7 @@
 		}
 	}
 	bpf_error(cstate, "too many registers needed to evaluate expression");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -7367,6 +7821,13 @@
 struct block *
 gen_greater(compiler_state_t *cstate, int n)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	return gen_len(cstate, BPF_JGE, n);
 }
 
@@ -7378,6 +7839,13 @@
 {
 	struct block *b;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	b = gen_len(cstate, BPF_JGT, n);
 	gen_not(b);
 
@@ -7400,6 +7868,13 @@
 	struct block *b;
 	struct slist *s;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (op) {
 	default:
 		abort();
@@ -7440,6 +7915,13 @@
 	struct block *b0, *b1, *b2;
 	static const u_char ebroadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (proto) {
 
 	case Q_DEFAULT:
@@ -7471,7 +7953,7 @@
 		default:
 			bpf_error(cstate, "not a broadcast link");
 		}
-		break;
+ 		/*NOTREACHED*/
 
 	case Q_IP:
 		/*
@@ -7491,7 +7973,7 @@
 		return b2;
 	}
 	bpf_error(cstate, "only link-layer/IP broadcast filters supported");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -7518,6 +8000,13 @@
 	register struct block *b0, *b1, *b2;
 	register struct slist *s;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (proto) {
 
 	case Q_DEFAULT:
@@ -7686,7 +8175,7 @@
 		return b1;
 	}
 	bpf_error(cstate, "link-layer multicast filters supported only on ethernet/FDDI/token ring/ARCNET/802.11/ATM LANE/Fibre Channel");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 /*
@@ -7704,13 +8193,20 @@
 	register struct block *b0;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Only some data link types support inbound/outbound qualifiers.
 	 */
 	switch (cstate->linktype) {
 	case DLT_SLIP:
-		b0 = gen_relation(cstate, BPF_JEQ,
-			  gen_load(cstate, Q_LINK, gen_loadi(cstate, 0), 1),
-			  gen_loadi(cstate, 0),
+		b0 = gen_relation_internal(cstate, BPF_JEQ,
+			  gen_load_internal(cstate, Q_LINK, gen_loadi_internal(cstate, 0), 1),
+			  gen_loadi_internal(cstate, 0),
 			  dir);
 		break;
 
@@ -7733,6 +8229,15 @@
 		}
 		break;
 
+	case DLT_LINUX_SLL2:
+		/* match outgoing packets */
+		b0 = gen_cmp(cstate, OR_LINKHDR, 10, BPF_B, LINUX_SLL_OUTGOING);
+		if (!dir) {
+			/* to filter on inbound traffic, invert the match */
+			gen_not(b0);
+		}
+		break;
+
 #ifdef HAVE_NET_PFVAR_H
 	case DLT_PFLOG:
 		b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, dir), BPF_B,
@@ -7809,10 +8314,10 @@
 		 */
 		if (cstate->bpf_pcap->rfile != NULL) {
 			/* We have a FILE *, so this is a savefile */
-			bpf_error(cstate, "inbound/outbound not supported on linktype %d when reading savefiles",
-			    cstate->linktype);
+			bpf_error(cstate, "inbound/outbound not supported on %s when reading savefiles",
+			    pcap_datalink_val_to_description_or_dlt(cstate->linktype));
 			b0 = NULL;
-			/* NOTREACHED */
+			/*NOTREACHED*/
 		}
 		/* match outgoing packets */
 		b0 = gen_cmp(cstate, OR_LINKHDR, SKF_AD_OFF + SKF_AD_PKTTYPE, BPF_H,
@@ -7822,9 +8327,9 @@
 			gen_not(b0);
 		}
 #else /* defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */
-		bpf_error(cstate, "inbound/outbound not supported on linktype %d",
-		    cstate->linktype);
-		/* NOTREACHED */
+		bpf_error(cstate, "inbound/outbound not supported on %s",
+		    pcap_datalink_val_to_description_or_dlt(cstate->linktype));
+		/*NOTREACHED*/
 #endif /* defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */
 	}
 	return (b0);
@@ -7838,18 +8343,26 @@
 	struct block *b0;
 	u_int len, off;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if (cstate->linktype != DLT_PFLOG) {
 		bpf_error(cstate, "ifname supported only on PF linktype");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 	len = sizeof(((struct pfloghdr *)0)->ifname);
 	off = offsetof(struct pfloghdr, ifname);
 	if (strlen(ifname) >= len) {
 		bpf_error(cstate, "ifname interface names can only be %d characters",
 		    len-1);
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
-	b0 = gen_bcmp(cstate, OR_LINKHDR, off, strlen(ifname), (const u_char *)ifname);
+	b0 = gen_bcmp(cstate, OR_LINKHDR, off, (u_int)strlen(ifname),
+	    (const u_char *)ifname);
 	return (b0);
 }
 
@@ -7859,19 +8372,26 @@
 {
 	struct block *b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if (cstate->linktype != DLT_PFLOG) {
 		bpf_error(cstate, "ruleset supported only on PF linktype");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	if (strlen(ruleset) >= sizeof(((struct pfloghdr *)0)->ruleset)) {
 		bpf_error(cstate, "ruleset names can only be %ld characters",
 		    (long)(sizeof(((struct pfloghdr *)0)->ruleset) - 1));
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	b0 = gen_bcmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, ruleset),
-	    strlen(ruleset), (const u_char *)ruleset);
+	    (u_int)strlen(ruleset), (const u_char *)ruleset);
 	return (b0);
 }
 
@@ -7881,9 +8401,16 @@
 {
 	struct block *b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if (cstate->linktype != DLT_PFLOG) {
 		bpf_error(cstate, "rnr supported only on PF linktype");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, rulenr), BPF_W,
@@ -7897,9 +8424,16 @@
 {
 	struct block *b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if (cstate->linktype != DLT_PFLOG) {
 		bpf_error(cstate, "srnr supported only on PF linktype");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, subrulenr), BPF_W,
@@ -7913,9 +8447,16 @@
 {
 	struct block *b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if (cstate->linktype != DLT_PFLOG) {
 		bpf_error(cstate, "reason supported only on PF linktype");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, reason), BPF_B,
@@ -7929,9 +8470,16 @@
 {
 	struct block *b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	if (cstate->linktype != DLT_PFLOG) {
 		bpf_error(cstate, "action supported only on PF linktype");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	b0 = gen_cmp(cstate, OR_LINKHDR, offsetof(struct pfloghdr, action), BPF_B,
@@ -7942,43 +8490,85 @@
 struct block *
 gen_pf_ifname(compiler_state_t *cstate, const char *ifname _U_)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	bpf_error(cstate, "libpcap was compiled without pf support");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
 gen_pf_ruleset(compiler_state_t *cstate, char *ruleset _U_)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
 gen_pf_rnr(compiler_state_t *cstate, int rnr _U_)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
 gen_pf_srnr(compiler_state_t *cstate, int srnr _U_)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
 gen_pf_reason(compiler_state_t *cstate, int reason _U_)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 struct block *
 gen_pf_action(compiler_state_t *cstate, int action _U_)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 #endif /* HAVE_NET_PFVAR_H */
 
@@ -7988,6 +8578,13 @@
 {
 	struct block *b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (cstate->linktype) {
 
 	case DLT_IEEE802_11:
@@ -8000,7 +8597,7 @@
 
 	default:
 		bpf_error(cstate, "802.11 link-layer types supported only on 802.11");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	return (b0);
@@ -8011,6 +8608,13 @@
 {
 	struct block *b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (cstate->linktype) {
 
 	case DLT_IEEE802_11:
@@ -8021,7 +8625,7 @@
 
 	default:
 		bpf_error(cstate, "frame direction supported only with 802.11 headers");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 
 	b0 = gen_mcmp(cstate, OR_LINKHDR, 1, BPF_B, (bpf_int32)fcdir,
@@ -8031,24 +8635,37 @@
 }
 
 struct block *
-gen_acode(compiler_state_t *cstate, const u_char *eaddr, struct qual q)
+gen_acode(compiler_state_t *cstate, const char *s, struct qual q)
 {
+	struct block *b;
+
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (cstate->linktype) {
 
 	case DLT_ARCNET:
 	case DLT_ARCNET_LINUX:
 		if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) &&
-		    q.proto == Q_LINK)
-			return (gen_ahostop(cstate, eaddr, (int)q.dir));
-		else {
+		    q.proto == Q_LINK) {
+			cstate->e = pcap_ether_aton(s);
+			if (cstate->e == NULL)
+				bpf_error(cstate, "malloc");
+			b = gen_ahostop(cstate, cstate->e, (int)q.dir);
+			free(cstate->e);
+			cstate->e = NULL;
+			return (b);
+		} else
 			bpf_error(cstate, "ARCnet address used in non-arc expression");
-			/* NOTREACHED */
-		}
-		break;
+ 		/*NOTREACHED*/
 
 	default:
 		bpf_error(cstate, "aid supported only on ARCnet");
-		/* NOTREACHED */
+		/*NOTREACHED*/
 	}
 }
 
@@ -8080,30 +8697,30 @@
 
 	case Q_ADDR1:
 		bpf_error(cstate, "'addr1' and 'address1' are only supported on 802.11");
-		break;
+ 		/*NOTREACHED*/
 
 	case Q_ADDR2:
 		bpf_error(cstate, "'addr2' and 'address2' are only supported on 802.11");
-		break;
+ 		/*NOTREACHED*/
 
 	case Q_ADDR3:
 		bpf_error(cstate, "'addr3' and 'address3' are only supported on 802.11");
-		break;
+ 		/*NOTREACHED*/
 
 	case Q_ADDR4:
 		bpf_error(cstate, "'addr4' and 'address4' are only supported on 802.11");
-		break;
+ 		/*NOTREACHED*/
 
 	case Q_RA:
 		bpf_error(cstate, "'ra' is only supported on 802.11");
-		break;
+ 		/*NOTREACHED*/
 
 	case Q_TA:
 		bpf_error(cstate, "'ta' is only supported on 802.11");
-		break;
+ 		/*NOTREACHED*/
 	}
 	abort();
-	/* NOTREACHED */
+	/*NOTREACHED*/
 }
 
 static struct block *
@@ -8123,19 +8740,24 @@
 }
 
 static struct block *
-gen_vlan_vid_test(compiler_state_t *cstate, int vlan_num)
+gen_vlan_vid_test(compiler_state_t *cstate, bpf_u_int32 vlan_num)
 {
+	if (vlan_num > 0x0fff) {
+		bpf_error(cstate, "VLAN tag %u greater than maximum %u",
+		    vlan_num, 0x0fff);
+	}
 	return gen_mcmp(cstate, OR_LINKPL, 0, BPF_H, (bpf_int32)vlan_num, 0x0fff);
 }
 
 static struct block *
-gen_vlan_no_bpf_extensions(compiler_state_t *cstate, int vlan_num)
+gen_vlan_no_bpf_extensions(compiler_state_t *cstate, bpf_u_int32 vlan_num,
+    int has_vlan_tag)
 {
 	struct block *b0, *b1;
 
 	b0 = gen_vlan_tpid_test(cstate);
 
-	if (vlan_num >= 0) {
+	if (has_vlan_tag) {
 		b1 = gen_vlan_vid_test(cstate, vlan_num);
 		gen_and(b0, b1);
 		b0 = b1;
@@ -8218,12 +8840,15 @@
 	sappend(s, s2);
 	sjeq->s.jt = s2;
 
-	/* jump to the test in b_vid (bypass loading VID from packet data) */
+	/* Jump to the test in b_vid. We need to jump one instruction before
+	 * the end of the b_vid block so that we only skip loading the TCI
+	 * from packet data and not the 'and' instruction extractging VID.
+	 */
 	cnt = 0;
 	for (s2 = b_vid->stmts; s2; s2 = s2->next)
 		cnt++;
 	s2 = new_stmt(cstate, JMP(BPF_JA));
-	s2->s.k = cnt;
+	s2->s.k = cnt - 1;
 	sappend(s, s2);
 
 	/* insert our statements at the beginning of b_vid */
@@ -8240,7 +8865,8 @@
  * update variable part of the offsets
  */
 static struct block *
-gen_vlan_bpf_extensions(compiler_state_t *cstate, int vlan_num)
+gen_vlan_bpf_extensions(compiler_state_t *cstate, bpf_u_int32 vlan_num,
+    int has_vlan_tag)
 {
         struct block *b0, *b_tpid, *b_vid = NULL;
         struct slist *s;
@@ -8265,14 +8891,14 @@
 	 * function but gen_vlan_bpf_extensions() isn't called in that case.
 	 */
 	b_tpid = gen_vlan_tpid_test(cstate);
-	if (vlan_num >= 0)
+	if (has_vlan_tag)
 		b_vid = gen_vlan_vid_test(cstate, vlan_num);
 
 	gen_vlan_patch_tpid_test(cstate, b_tpid);
 	gen_or(b0, b_tpid);
 	b0 = b_tpid;
 
-	if (vlan_num >= 0) {
+	if (has_vlan_tag) {
 		gen_vlan_patch_vid_test(cstate, b_vid);
 		gen_and(b0, b_vid);
 		b0 = b_vid;
@@ -8286,10 +8912,17 @@
  * support IEEE 802.1Q VLAN trunk over ethernet
  */
 struct block *
-gen_vlan(compiler_state_t *cstate, int vlan_num)
+gen_vlan(compiler_state_t *cstate, bpf_u_int32 vlan_num, int has_vlan_tag)
 {
 	struct	block	*b0;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	/* can't check for VLAN-encapsulated packets inside MPLS */
 	if (cstate->label_stack_depth > 0)
 		bpf_error(cstate, "no VLAN match after MPLS");
@@ -8340,24 +8973,27 @@
 			 * Do we need special VLAN handling?
 			 */
 			if (cstate->bpf_pcap->bpf_codegen_flags & BPF_SPECIAL_VLAN_HANDLING)
-				b0 = gen_vlan_bpf_extensions(cstate, vlan_num);
+				b0 = gen_vlan_bpf_extensions(cstate, vlan_num,
+				    has_vlan_tag);
 			else
-				b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num);
+				b0 = gen_vlan_no_bpf_extensions(cstate,
+				    vlan_num, has_vlan_tag);
 		} else
 #endif
-			b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num);
+			b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num,
+			    has_vlan_tag);
                 break;
 
 	case DLT_IEEE802_11:
 	case DLT_PRISM_HEADER:
 	case DLT_IEEE802_11_RADIO_AVS:
 	case DLT_IEEE802_11_RADIO:
-		b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num);
+		b0 = gen_vlan_no_bpf_extensions(cstate, vlan_num, has_vlan_tag);
 		break;
 
 	default:
-		bpf_error(cstate, "no VLAN support for data link type %d",
-		      cstate->linktype);
+		bpf_error(cstate, "no VLAN support for %s",
+		      pcap_datalink_val_to_description_or_dlt(cstate->linktype));
 		/*NOTREACHED*/
 	}
 
@@ -8368,12 +9004,25 @@
 
 /*
  * support for MPLS
+ *
+ * The label_num_arg dance is to avoid annoying whining by compilers that
+ * label_num might be clobbered by longjmp - yeah, it might, but *WHO CARES*?
+ * It's not *used* after setjmp returns.
  */
 struct block *
-gen_mpls(compiler_state_t *cstate, int label_num)
+gen_mpls(compiler_state_t *cstate, bpf_u_int32 label_num_arg,
+    int has_label_num)
 {
+	volatile bpf_u_int32 label_num = label_num_arg;
 	struct	block	*b0, *b1;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
         if (cstate->label_stack_depth > 0) {
             /* just match the bottom-of-stack bit clear */
             b0 = gen_mcmp(cstate, OR_PREVMPLSHDR, 2, BPF_B, 0, 0x01);
@@ -8400,15 +9049,18 @@
                      * leave it for now */
 
             default:
-                    bpf_error(cstate, "no MPLS support for data link type %d",
-                          cstate->linktype);
+                    bpf_error(cstate, "no MPLS support for %s",
+                          pcap_datalink_val_to_description_or_dlt(cstate->linktype));
                     /*NOTREACHED*/
-                    break;
             }
         }
 
 	/* If a specific MPLS label is requested, check it */
-	if (label_num >= 0) {
+	if (has_label_num) {
+		if (label_num > 0xFFFFF) {
+			bpf_error(cstate, "MPLS label %u greater than maximum %u",
+			    label_num, 0xFFFFF);
+		}
 		label_num = label_num << 12; /* label is shifted 12 bits on the wire */
 		b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_W, (bpf_int32)label_num,
 		    0xfffff000); /* only compare the first 20 bits */
@@ -8442,22 +9094,40 @@
 struct block *
 gen_pppoed(compiler_state_t *cstate)
 {
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	/* check for PPPoE discovery */
 	return gen_linktype(cstate, (bpf_int32)ETHERTYPE_PPPOED);
 }
 
 struct block *
-gen_pppoes(compiler_state_t *cstate, int sess_num)
+gen_pppoes(compiler_state_t *cstate, bpf_u_int32 sess_num, int has_sess_num)
 {
 	struct block *b0, *b1;
 
 	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	/*
 	 * Test against the PPPoE session link-layer type.
 	 */
 	b0 = gen_linktype(cstate, (bpf_int32)ETHERTYPE_PPPOES);
 
 	/* If a specific session is requested, check PPPoE session id */
-	if (sess_num >= 0) {
+	if (has_sess_num) {
+		if (sess_num > 0x0000ffff) {
+			bpf_error(cstate, "PPPoE session number %u greater than maximum %u",
+			    sess_num, 0x0000ffff);
+		}
 		b1 = gen_mcmp(cstate, OR_LINKPL, 0, BPF_W,
 		    (bpf_int32)sess_num, 0x0000ffff);
 		gen_and(b0, b1);
@@ -8469,29 +9139,8 @@
 	 * the PPP packet, and note that this is PPPoE rather than
 	 * raw PPP.
 	 *
-	 * XXX - this is a bit of a kludge.  If we were to split the
-	 * compiler into a parser that parses an expression and
-	 * generates an expression tree, and a code generator that
-	 * takes an expression tree (which could come from our
-	 * parser or from some other parser) and generates BPF code,
-	 * we could perhaps make the offsets parameters of routines
-	 * and, in the handler for an "AND" node, pass to subnodes
-	 * other than the PPPoE node the adjusted offsets.
-	 *
-	 * This would mean that "pppoes" would, instead of changing the
-	 * behavior of *all* tests after it, change only the behavior
-	 * of tests ANDed with it.  That would change the documented
-	 * semantics of "pppoes", which might break some expressions.
-	 * However, it would mean that "(pppoes and ip) or ip" would check
-	 * both for VLAN-encapsulated IP and IP-over-Ethernet, rather than
-	 * checking only for VLAN-encapsulated IP, so that could still
-	 * be considered worth doing; it wouldn't break expressions
-	 * that are of the form "pppoes and ..." which I suspect are the
-	 * most common expressions involving "pppoes".  "pppoes or ..."
-	 * doesn't necessarily do what the user would really want, now,
-	 * as all the "or ..." tests would be done assuming PPPoE, even
-	 * though the "or" could be viewed as meaning "or, if this isn't
-	 * a PPPoE packet...".
+	 * XXX - this is a bit of a kludge.  See the comments in
+	 * gen_vlan().
 	 *
 	 * The "network-layer" protocol is PPPoE, which has a 6-byte
 	 * PPPoE header, followed by a PPP packet.
@@ -8521,7 +9170,7 @@
 static struct block *
 gen_geneve_check(compiler_state_t *cstate,
     struct block *(*gen_portfn)(compiler_state_t *, int, int, int),
-    enum e_offrel offrel, int vni)
+    enum e_offrel offrel, bpf_u_int32 vni, int has_vni)
 {
 	struct block *b0, *b1;
 
@@ -8534,7 +9183,11 @@
 	gen_and(b0, b1);
 	b0 = b1;
 
-	if (vni >= 0) {
+	if (has_vni) {
+		if (vni > 0xffffff) {
+			bpf_error(cstate, "Geneve VNI %u greater than maximum %u",
+			    vni, 0xffffff);
+		}
 		vni <<= 8; /* VNI is in the upper 3 bytes */
 		b1 = gen_mcmp(cstate, offrel, 12, BPF_W, (bpf_int32)vni,
 			      0xffffff00);
@@ -8551,12 +9204,12 @@
  *   needed) into register A to be used later to compute
  *   the inner packet offsets. */
 static struct block *
-gen_geneve4(compiler_state_t *cstate, int vni)
+gen_geneve4(compiler_state_t *cstate, bpf_u_int32 vni, int has_vni)
 {
 	struct block *b0, *b1;
 	struct slist *s, *s1;
 
-	b0 = gen_geneve_check(cstate, gen_port, OR_TRAN_IPV4, vni);
+	b0 = gen_geneve_check(cstate, gen_port, OR_TRAN_IPV4, vni, has_vni);
 
 	/* Load the IP header length into A. */
 	s = gen_loadx_iphdrlen(cstate);
@@ -8577,12 +9230,12 @@
 }
 
 static struct block *
-gen_geneve6(compiler_state_t *cstate, int vni)
+gen_geneve6(compiler_state_t *cstate, bpf_u_int32 vni, int has_vni)
 {
 	struct block *b0, *b1;
 	struct slist *s, *s1;
 
-	b0 = gen_geneve_check(cstate, gen_port6, OR_TRAN_IPV6, vni);
+	b0 = gen_geneve_check(cstate, gen_port6, OR_TRAN_IPV6, vni, has_vni);
 
 	/* Load the IP header length. We need to account for a
 	 * variable length link prefix if there is one. */
@@ -8755,13 +9408,20 @@
 
 /* Check to see if this is a Geneve packet. */
 struct block *
-gen_geneve(compiler_state_t *cstate, int vni)
+gen_geneve(compiler_state_t *cstate, bpf_u_int32 vni, int has_vni)
 {
 	struct block *b0, *b1;
 	struct slist *s;
 
-	b0 = gen_geneve4(cstate, vni);
-	b1 = gen_geneve6(cstate, vni);
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	b0 = gen_geneve4(cstate, vni, has_vni);
+	b1 = gen_geneve6(cstate, vni, has_vni);
 
 	gen_or(b0, b1);
 	b0 = b1;
@@ -8811,9 +9471,9 @@
 	return b0;
 }
 
-struct block *
-gen_atmfield_code(compiler_state_t *cstate, int atmfield, bpf_int32 jvalue,
-    bpf_u_int32 jtype, int reverse)
+static struct block *
+gen_atmfield_code_internal(compiler_state_t *cstate, int atmfield,
+    bpf_int32 jvalue, bpf_u_int32 jtype, int reverse)
 {
 	struct block *b0;
 
@@ -8866,28 +9526,80 @@
 	return b0;
 }
 
+static struct block *
+gen_atmtype_metac(compiler_state_t *cstate)
+{
+	struct block *b0, *b1;
+
+	b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
+	b1 = gen_atmfield_code_internal(cstate, A_VCI, 1, BPF_JEQ, 0);
+	gen_and(b0, b1);
+	return b1;
+}
+
+static struct block *
+gen_atmtype_sc(compiler_state_t *cstate)
+{
+	struct block *b0, *b1;
+
+	b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
+	b1 = gen_atmfield_code_internal(cstate, A_VCI, 5, BPF_JEQ, 0);
+	gen_and(b0, b1);
+	return b1;
+}
+
+static struct block *
+gen_atmtype_llc(compiler_state_t *cstate)
+{
+	struct block *b0;
+
+	b0 = gen_atmfield_code_internal(cstate, A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
+	cstate->linktype = cstate->prevlinktype;
+	return b0;
+}
+
+struct block *
+gen_atmfield_code(compiler_state_t *cstate, int atmfield,
+    bpf_int32 jvalue, bpf_u_int32 jtype, int reverse)
+{
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	return gen_atmfield_code_internal(cstate, atmfield, jvalue, jtype,
+	    reverse);
+}
+
 struct block *
 gen_atmtype_abbrev(compiler_state_t *cstate, int type)
 {
 	struct block *b0, *b1;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (type) {
 
 	case A_METAC:
 		/* Get all packets in Meta signalling Circuit */
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'metac' supported only on raw ATM");
-		b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
-		b1 = gen_atmfield_code(cstate, A_VCI, 1, BPF_JEQ, 0);
-		gen_and(b0, b1);
+		b1 = gen_atmtype_metac(cstate);
 		break;
 
 	case A_BCC:
 		/* Get all packets in Broadcast Circuit*/
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'bcc' supported only on raw ATM");
-		b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
-		b1 = gen_atmfield_code(cstate, A_VCI, 2, BPF_JEQ, 0);
+		b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_VCI, 2, BPF_JEQ, 0);
 		gen_and(b0, b1);
 		break;
 
@@ -8895,8 +9607,8 @@
 		/* Get all cells in Segment OAM F4 circuit*/
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'oam4sc' supported only on raw ATM");
-		b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
-		b1 = gen_atmfield_code(cstate, A_VCI, 3, BPF_JEQ, 0);
+		b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_VCI, 3, BPF_JEQ, 0);
 		gen_and(b0, b1);
 		break;
 
@@ -8904,8 +9616,8 @@
 		/* Get all cells in End-to-End OAM F4 Circuit*/
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'oam4ec' supported only on raw ATM");
-		b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
-		b1 = gen_atmfield_code(cstate, A_VCI, 4, BPF_JEQ, 0);
+		b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_VCI, 4, BPF_JEQ, 0);
 		gen_and(b0, b1);
 		break;
 
@@ -8913,17 +9625,15 @@
 		/*  Get all packets in connection Signalling Circuit */
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'sc' supported only on raw ATM");
-		b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
-		b1 = gen_atmfield_code(cstate, A_VCI, 5, BPF_JEQ, 0);
-		gen_and(b0, b1);
+		b1 = gen_atmtype_sc(cstate);
 		break;
 
 	case A_ILMIC:
 		/* Get all packets in ILMI Circuit */
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'ilmic' supported only on raw ATM");
-		b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
-		b1 = gen_atmfield_code(cstate, A_VCI, 16, BPF_JEQ, 0);
+		b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_VCI, 16, BPF_JEQ, 0);
 		gen_and(b0, b1);
 		break;
 
@@ -8931,7 +9641,7 @@
 		/* Get all LANE packets */
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'lane' supported only on raw ATM");
-		b1 = gen_atmfield_code(cstate, A_PROTOTYPE, PT_LANE, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_PROTOTYPE, PT_LANE, BPF_JEQ, 0);
 
 		/*
 		 * Arrange that all subsequent tests assume LANE
@@ -8954,8 +9664,7 @@
 		/* Get all LLC-encapsulated packets */
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'llc' supported only on raw ATM");
-		b1 = gen_atmfield_code(cstate, A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
-		cstate->linktype = cstate->prevlinktype;
+		b1 = gen_atmtype_llc(cstate);
 		break;
 
 	default:
@@ -8976,6 +9685,13 @@
 {
 	struct block *b0, *b1;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (type) {
 
 	case M_FISU:
@@ -9038,17 +9754,34 @@
 	return b0;
 }
 
+/*
+ * The jvalue_arg dance is to avoid annoying whining by compilers that
+ * jvalue might be clobbered by longjmp - yeah, it might, but *WHO CARES*?
+ * It's not *used* after setjmp returns.
+ */
 struct block *
-gen_mtp3field_code(compiler_state_t *cstate, int mtp3field, bpf_u_int32 jvalue,
-    bpf_u_int32 jtype, int reverse)
+gen_mtp3field_code(compiler_state_t *cstate, int mtp3field,
+    bpf_u_int32 jvalue_arg, bpf_u_int32 jtype, int reverse)
 {
+	volatile bpf_u_int32 jvalue = jvalue_arg;
 	struct block *b0;
 	bpf_u_int32 val1 , val2 , val3;
-	u_int newoff_sio = cstate->off_sio;
-	u_int newoff_opc = cstate->off_opc;
-	u_int newoff_dpc = cstate->off_dpc;
-	u_int newoff_sls = cstate->off_sls;
+	u_int newoff_sio;
+	u_int newoff_opc;
+	u_int newoff_dpc;
+	u_int newoff_sls;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
+	newoff_sio = cstate->off_sio;
+	newoff_opc = cstate->off_opc;
+	newoff_dpc = cstate->off_dpc;
+	newoff_sls = cstate->off_sls;
 	switch (mtp3field) {
 
 	case MH_SIO:
@@ -9067,7 +9800,9 @@
 		break;
 
 	case MH_OPC:
-		newoff_opc+=3;
+		newoff_opc += 3;
+
+		/* FALLTHROUGH */
         case M_OPC:
 	        if (cstate->off_opc == OFFSET_NOT_SET)
 			bpf_error(cstate, "'opc' supported only on SS7");
@@ -9111,7 +9846,9 @@
 		break;
 
 	case MH_SLS:
-	  newoff_sls+=3;
+		newoff_sls += 3;
+		/* FALLTHROUGH */
+
 	case M_SLS:
 	        if (cstate->off_sls == OFFSET_NOT_SET)
 			bpf_error(cstate, "'sls' supported only on SS7");
@@ -9144,27 +9881,27 @@
 	switch (type) {
 
 	case A_SETUP:
-		b1 = gen_atmfield_code(cstate, A_MSGTYPE, SETUP, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_MSGTYPE, SETUP, BPF_JEQ, 0);
 		break;
 
 	case A_CALLPROCEED:
-		b1 = gen_atmfield_code(cstate, A_MSGTYPE, CALL_PROCEED, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_MSGTYPE, CALL_PROCEED, BPF_JEQ, 0);
 		break;
 
 	case A_CONNECT:
-		b1 = gen_atmfield_code(cstate, A_MSGTYPE, CONNECT, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_MSGTYPE, CONNECT, BPF_JEQ, 0);
 		break;
 
 	case A_CONNECTACK:
-		b1 = gen_atmfield_code(cstate, A_MSGTYPE, CONNECT_ACK, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_MSGTYPE, CONNECT_ACK, BPF_JEQ, 0);
 		break;
 
 	case A_RELEASE:
-		b1 = gen_atmfield_code(cstate, A_MSGTYPE, RELEASE, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_MSGTYPE, RELEASE, BPF_JEQ, 0);
 		break;
 
 	case A_RELEASE_DONE:
-		b1 = gen_atmfield_code(cstate, A_MSGTYPE, RELEASE_DONE, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_MSGTYPE, RELEASE_DONE, BPF_JEQ, 0);
 		break;
 
 	default:
@@ -9178,22 +9915,34 @@
 {
 	struct block *b0, *b1;
 
+	/*
+	 * Catch errors reported by us and routines below us, and return NULL
+	 * on an error.
+	 */
+	if (setjmp(cstate->top_ctx))
+		return (NULL);
+
 	switch (type) {
 
 	case A_OAM:
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'oam' supported only on raw ATM");
-		b1 = gen_atmmulti_abbrev(cstate, A_OAMF4);
+		/* OAM F4 type */
+		b0 = gen_atmfield_code_internal(cstate, A_VCI, 3, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_VCI, 4, BPF_JEQ, 0);
+		gen_or(b0, b1);
+		b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
+		gen_and(b0, b1);
 		break;
 
 	case A_OAMF4:
 		if (!cstate->is_atm)
 			bpf_error(cstate, "'oamf4' supported only on raw ATM");
 		/* OAM F4 type */
-		b0 = gen_atmfield_code(cstate, A_VCI, 3, BPF_JEQ, 0);
-		b1 = gen_atmfield_code(cstate, A_VCI, 4, BPF_JEQ, 0);
+		b0 = gen_atmfield_code_internal(cstate, A_VCI, 3, BPF_JEQ, 0);
+		b1 = gen_atmfield_code_internal(cstate, A_VCI, 4, BPF_JEQ, 0);
 		gen_or(b0, b1);
-		b0 = gen_atmfield_code(cstate, A_VPI, 0, BPF_JEQ, 0);
+		b0 = gen_atmfield_code_internal(cstate, A_VPI, 0, BPF_JEQ, 0);
 		gen_and(b0, b1);
 		break;
 
@@ -9215,7 +9964,7 @@
 		gen_or(b0, b1);
 		b0 = gen_msg_abbrev(cstate, A_RELEASE_DONE);
 		gen_or(b0, b1);
-		b0 = gen_atmtype_abbrev(cstate, A_SC);
+		b0 = gen_atmtype_sc(cstate);
 		gen_and(b0, b1);
 		break;
 
@@ -9231,7 +9980,7 @@
 		gen_or(b0, b1);
 		b0 = gen_msg_abbrev(cstate, A_RELEASE_DONE);
 		gen_or(b0, b1);
-		b0 = gen_atmtype_abbrev(cstate, A_METAC);
+		b0 = gen_atmtype_metac(cstate);
 		gen_and(b0, b1);
 		break;
 
diff --git a/gencode.h b/gencode.h
index 88def5a..cc21e04 100644
--- a/gencode.h
+++ b/gencode.h
@@ -113,16 +113,14 @@
 #define Q_ISIS_L2       32
 /* PDU types */
 #define Q_ISIS_IIH      33
-#define Q_ISIS_LAN_IIH  34
-#define Q_ISIS_PTP_IIH  35
-#define Q_ISIS_SNP      36
-#define Q_ISIS_CSNP     37
-#define Q_ISIS_PSNP     38
-#define Q_ISIS_LSP      39
+#define Q_ISIS_SNP      34
+#define Q_ISIS_CSNP     35
+#define Q_ISIS_PSNP     36
+#define Q_ISIS_LSP      37
 
-#define Q_RADIO		40
+#define Q_RADIO		38
 
-#define Q_CARP		41
+#define Q_CARP		39
 
 /* Directional qualifiers. */
 
@@ -299,8 +297,8 @@
 void gen_not(struct block *);
 
 struct block *gen_scode(compiler_state_t *, const char *, struct qual);
-struct block *gen_ecode(compiler_state_t *, const u_char *, struct qual);
-struct block *gen_acode(compiler_state_t *, const u_char *, struct qual);
+struct block *gen_ecode(compiler_state_t *, const char *, struct qual);
+struct block *gen_acode(compiler_state_t *, const char *, struct qual);
 struct block *gen_mcode(compiler_state_t *, const char *, const char *,
     unsigned int, struct qual);
 #ifdef INET6
@@ -326,13 +324,13 @@
 struct block *gen_llc_s_subtype(compiler_state_t *, bpf_u_int32);
 struct block *gen_llc_u_subtype(compiler_state_t *, bpf_u_int32);
 
-struct block *gen_vlan(compiler_state_t *, int);
-struct block *gen_mpls(compiler_state_t *, int);
+struct block *gen_vlan(compiler_state_t *, bpf_u_int32, int);
+struct block *gen_mpls(compiler_state_t *, bpf_u_int32, int);
 
 struct block *gen_pppoed(compiler_state_t *);
-struct block *gen_pppoes(compiler_state_t *, int);
+struct block *gen_pppoes(compiler_state_t *, bpf_u_int32, int);
 
-struct block *gen_geneve(compiler_state_t *, int);
+struct block *gen_geneve(compiler_state_t *, bpf_u_int32, int);
 
 struct block *gen_atmfield_code(compiler_state_t *, int, bpf_int32,
     bpf_u_int32, int);
@@ -343,29 +341,11 @@
 struct block *gen_mtp3field_code(compiler_state_t *, int, bpf_u_int32,
     bpf_u_int32, int);
 
-#ifndef HAVE_NET_PFVAR_H
-PCAP_NORETURN
-#endif
 struct block *gen_pf_ifname(compiler_state_t *, const char *);
-#ifndef HAVE_NET_PFVAR_H
-PCAP_NORETURN
-#endif
 struct block *gen_pf_rnr(compiler_state_t *, int);
-#ifndef HAVE_NET_PFVAR_H
-PCAP_NORETURN
-#endif
 struct block *gen_pf_srnr(compiler_state_t *, int);
-#ifndef HAVE_NET_PFVAR_H
-PCAP_NORETURN
-#endif
 struct block *gen_pf_ruleset(compiler_state_t *, char *);
-#ifndef HAVE_NET_PFVAR_H
-PCAP_NORETURN
-#endif
 struct block *gen_pf_reason(compiler_state_t *, int);
-#ifndef HAVE_NET_PFVAR_H
-PCAP_NORETURN
-#endif
 struct block *gen_pf_action(compiler_state_t *, int);
 
 struct block *gen_p80211_type(compiler_state_t *, int, int);
@@ -386,16 +366,15 @@
 	int cur_mark;
 };
 
-void bpf_optimize(compiler_state_t *, struct icode *ic);
-void PCAP_NORETURN bpf_syntax_error(compiler_state_t *, const char *);
-void PCAP_NORETURN bpf_error(compiler_state_t *, const char *, ...)
+int bpf_optimize(struct icode *, char *);
+void bpf_set_error(compiler_state_t *, const char *, ...)
     PCAP_PRINTFLIKE(2, 3);
 
-void finish_parse(compiler_state_t *, struct block *);
+int finish_parse(compiler_state_t *, struct block *);
 char *sdup(compiler_state_t *, const char *);
 
-struct bpf_insn *icode_to_fcode(compiler_state_t *, struct icode *,
-    struct block *, u_int *);
+struct bpf_insn *icode_to_fcode(struct icode *, struct block *, u_int *,
+    char *);
 void sappend(struct slist *, struct slist *);
 
 /*
diff --git a/grammar.c b/grammar.c
index 2be760b..f7697e2 100644
--- a/grammar.c
+++ b/grammar.c
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4.  */
+/* A Bison parser, made by GNU Bison 3.5.1.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
+   Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -40,11 +41,14 @@
    define necessary library symbols; they are noted "INFRINGES ON
    USER NAME SPACE" below.  */
 
+/* Undocumented macros, especially those whose name start with YY_,
+   are private implementation details.  Do not rely on them.  */
+
 /* Identify Bison output.  */
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.5.1"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -66,9 +70,8 @@
 #define yydebug         pcap_debug
 #define yynerrs         pcap_nerrs
 
-
-/* Copy the first part of user declarations.  */
-#line 26 "grammar.y" /* yacc.c:339  */
+/* First part of user prologue.  */
+#line 26 "grammar.y"
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
@@ -262,13 +265,12 @@
 	return (-1);
 }
 
-static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
+static const struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
 
-static PCAP_NORETURN_DEF void
+static void
 yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg)
 {
-	bpf_syntax_error(cstate, msg);
-	/* NOTREACHED */
+	bpf_set_error(cstate, "can't parse filter expression: %s", msg);
 }
 
 #ifdef HAVE_NET_PFVAR_H
@@ -282,8 +284,8 @@
 		if (pcap_strcasecmp(reason, reasons[i]) == 0)
 			return (i);
 	}
-	bpf_error(cstate, "unknown PF reason");
-	/*NOTREACHED*/
+	bpf_set_error(cstate, "unknown PF reason");
+	return (-1);
 }
 
 static int
@@ -306,35 +308,54 @@
 		return (PF_NORDR);
 #endif
 	else {
-		bpf_error(cstate, "unknown PF action");
-		/*NOTREACHED*/
+		bpf_set_error(cstate, "unknown PF action");
+		return (-1);
 	}
 }
 #else /* !HAVE_NET_PFVAR_H */
-static PCAP_NORETURN_DEF int
+static int
 pfreason_to_num(compiler_state_t *cstate, const char *reason _U_)
 {
-	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/*NOTREACHED*/
+	bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
+	return (-1);
 }
 
-static PCAP_NORETURN_DEF int
+static int
 pfaction_to_num(compiler_state_t *cstate, const char *action _U_)
 {
-	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/*NOTREACHED*/
+	bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
+	return (-1);
 }
 #endif /* HAVE_NET_PFVAR_H */
 
+/*
+ * For calls that might return an "an error occurred" value.
+ */
+#define CHECK_INT_VAL(val)	if (val == -1) YYABORT
+#define CHECK_PTR_VAL(val)	if (val == NULL) YYABORT
+
 DIAG_OFF_BISON_BYACC
 
-#line 332 "grammar.c" /* yacc.c:339  */
+#line 340 "grammar.c"
 
-# ifndef YY_NULLPTR
-#  if defined __cplusplus && 201103L <= __cplusplus
-#   define YY_NULLPTR nullptr
+# ifndef YY_CAST
+#  ifdef __cplusplus
+#   define YY_CAST(Type, Val) static_cast<Type> (Val)
+#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
 #  else
-#   define YY_NULLPTR 0
+#   define YY_CAST(Type, Val) ((Type) (Val))
+#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
+#  endif
+# endif
+# ifndef YY_NULLPTR
+#  if defined __cplusplus
+#   if 201103L <= __cplusplus
+#    define YY_NULLPTR nullptr
+#   else
+#    define YY_NULLPTR 0
+#   endif
+#  else
+#   define YY_NULLPTR ((void*)0)
 #  endif
 # endif
 
@@ -346,8 +367,8 @@
 # define YYERROR_VERBOSE 0
 #endif
 
-/* In a future release of Bison, this section will be replaced
-   by #include "grammar.h".  */
+/* Use api.header.include to #include this header
+   instead of duplicating it here.  */
 #ifndef YY_PCAP_GRAMMAR_H_INCLUDED
 # define YY_PCAP_GRAMMAR_H_INCLUDED
 /* Debug traces.  */
@@ -479,9 +500,10 @@
     HOPC = 371,
     HDPC = 372,
     HSLS = 373,
-    OR = 374,
-    AND = 375,
-    UMINUS = 376
+    LEX_ERROR = 374,
+    OR = 375,
+    AND = 376,
+    UMINUS = 377
   };
 #endif
 /* Tokens.  */
@@ -601,20 +623,19 @@
 #define HOPC 371
 #define HDPC 372
 #define HSLS 373
-#define OR 374
-#define AND 375
-#define UMINUS 376
+#define LEX_ERROR 374
+#define OR 375
+#define AND 376
+#define UMINUS 377
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
 union YYSTYPE
 {
-#line 286 "grammar.y" /* yacc.c:355  */
+#line 291 "grammar.y"
 
 	int i;
 	bpf_u_int32 h;
-	u_char *e;
 	char *s;
 	struct stmt *stmt;
 	struct arth *a;
@@ -626,9 +647,9 @@
 	} blk;
 	struct block *rblk;
 
-#line 630 "grammar.c" /* yacc.c:355  */
-};
+#line 651 "grammar.c"
 
+};
 typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
@@ -640,36 +661,81 @@
 
 #endif /* !YY_PCAP_GRAMMAR_H_INCLUDED  */
 
-/* Copy the second part of user declarations.  */
 
-#line 646 "grammar.c" /* yacc.c:358  */
 
 #ifdef short
 # undef short
 #endif
 
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
+/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
+   <limits.h> and (if available) <stdint.h> are included
+   so that the code can choose integer types of a good width.  */
+
+#ifndef __PTRDIFF_MAX__
+# include <limits.h> /* INFRINGES ON USER NAME SPACE */
+# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
+#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
+#  define YY_STDINT_H
+# endif
 #endif
 
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
+/* Narrow types that promote to a signed type and that can represent a
+   signed or unsigned integer of at least N bits.  In tables they can
+   save space and decrease cache pressure.  Promoting to a signed type
+   helps avoid bugs in integer arithmetic.  */
+
+#ifdef __INT_LEAST8_MAX__
+typedef __INT_LEAST8_TYPE__ yytype_int8;
+#elif defined YY_STDINT_H
+typedef int_least8_t yytype_int8;
 #else
 typedef signed char yytype_int8;
 #endif
 
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
+#ifdef __INT_LEAST16_MAX__
+typedef __INT_LEAST16_TYPE__ yytype_int16;
+#elif defined YY_STDINT_H
+typedef int_least16_t yytype_int16;
 #else
-typedef unsigned short int yytype_uint16;
+typedef short yytype_int16;
 #endif
 
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
+#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
+typedef __UINT_LEAST8_TYPE__ yytype_uint8;
+#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
+       && UINT_LEAST8_MAX <= INT_MAX)
+typedef uint_least8_t yytype_uint8;
+#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
+typedef unsigned char yytype_uint8;
 #else
-typedef short int yytype_int16;
+typedef short yytype_uint8;
+#endif
+
+#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
+typedef __UINT_LEAST16_TYPE__ yytype_uint16;
+#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
+       && UINT_LEAST16_MAX <= INT_MAX)
+typedef uint_least16_t yytype_uint16;
+#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
+typedef unsigned short yytype_uint16;
+#else
+typedef int yytype_uint16;
+#endif
+
+#ifndef YYPTRDIFF_T
+# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
+#  define YYPTRDIFF_T __PTRDIFF_TYPE__
+#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
+# elif defined PTRDIFF_MAX
+#  ifndef ptrdiff_t
+#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+#  endif
+#  define YYPTRDIFF_T ptrdiff_t
+#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
+# else
+#  define YYPTRDIFF_T long
+#  define YYPTRDIFF_MAXIMUM LONG_MAX
+# endif
 #endif
 
 #ifndef YYSIZE_T
@@ -677,15 +743,27 @@
 #  define YYSIZE_T __SIZE_TYPE__
 # elif defined size_t
 #  define YYSIZE_T size_t
-# elif ! defined YYSIZE_T
+# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
 #  define YYSIZE_T size_t
 # else
-#  define YYSIZE_T unsigned int
+#  define YYSIZE_T unsigned
 # endif
 #endif
 
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+#define YYSIZE_MAXIMUM                                  \
+  YY_CAST (YYPTRDIFF_T,                                 \
+           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
+            ? YYPTRDIFF_MAXIMUM                         \
+            : YY_CAST (YYSIZE_T, -1)))
+
+#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
+
+/* Stored state numbers (used for stacks). */
+typedef yytype_int16 yy_state_t;
+
+/* State numbers in computations.  */
+typedef int yy_state_fast_t;
 
 #ifndef YY_
 # if defined YYENABLE_NLS && YYENABLE_NLS
@@ -699,30 +777,19 @@
 # endif
 #endif
 
-#ifndef YY_ATTRIBUTE
-# if (defined __GNUC__                                               \
-      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
-     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
-#  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+#ifndef YY_ATTRIBUTE_PURE
+# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
+#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
 # else
-#  define YY_ATTRIBUTE(Spec) /* empty */
+#  define YY_ATTRIBUTE_PURE
 # endif
 #endif
 
-#ifndef YY_ATTRIBUTE_PURE
-# define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
-#endif
-
 #ifndef YY_ATTRIBUTE_UNUSED
-# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
-#endif
-
-#if !defined _Noreturn \
-     && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-#  define _Noreturn __declspec (noreturn)
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
 # else
-#  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
+#  define YY_ATTRIBUTE_UNUSED
 # endif
 #endif
 
@@ -733,13 +800,13 @@
 # define YYUSE(E) /* empty */
 #endif
 
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
-    _Pragma ("GCC diagnostic push") \
-    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
+    _Pragma ("GCC diagnostic push")                                     \
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
     _Pragma ("GCC diagnostic pop")
 #else
 # define YY_INITIAL_VALUE(Value) Value
@@ -752,6 +819,20 @@
 # define YY_INITIAL_VALUE(Value) /* Nothing. */
 #endif
 
+#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
+# define YY_IGNORE_USELESS_CAST_BEGIN                          \
+    _Pragma ("GCC diagnostic push")                            \
+    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
+# define YY_IGNORE_USELESS_CAST_END            \
+    _Pragma ("GCC diagnostic pop")
+#endif
+#ifndef YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_END
+#endif
+
+
+#define YY_ASSERT(E) ((void) (0 && (E)))
 
 #if ! defined yyoverflow || YYERROR_VERBOSE
 
@@ -828,17 +909,17 @@
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
 {
-  yytype_int16 yyss_alloc;
+  yy_state_t yyss_alloc;
   YYSTYPE yyvs_alloc;
 };
 
 /* The size of the maximum gap between one aligned stack and the next.  */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
 
 /* The size of an array large to enough to hold all stacks, each with
    N elements.  */
 # define YYSTACK_BYTES(N) \
-     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
       + YYSTACK_GAP_MAXIMUM)
 
 # define YYCOPY_NEEDED 1
@@ -851,11 +932,11 @@
 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
     do                                                                  \
       {                                                                 \
-        YYSIZE_T yynewbytes;                                            \
+        YYPTRDIFF_T yynewbytes;                                         \
         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
         Stack = &yyptr->Stack_alloc;                                    \
-        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
-        yyptr += yynewbytes / sizeof (*yyptr);                          \
+        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
+        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
       }                                                                 \
     while (0)
 
@@ -867,12 +948,12 @@
 # ifndef YYCOPY
 #  if defined __GNUC__ && 1 < __GNUC__
 #   define YYCOPY(Dst, Src, Count) \
-      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
+      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
 #  else
 #   define YYCOPY(Dst, Src, Count)              \
       do                                        \
         {                                       \
-          YYSIZE_T yyi;                         \
+          YYPTRDIFF_T yyi;                      \
           for (yyi = 0; yyi < (Count); yyi++)   \
             (Dst)[yyi] = (Src)[yyi];            \
         }                                       \
@@ -884,10 +965,10 @@
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  3
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   788
+#define YYLAST   775
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  139
+#define YYNTOKENS  140
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  47
 /* YYNRULES -- Number of rules.  */
@@ -895,31 +976,32 @@
 /* YYNSTATES -- Number of states.  */
 #define YYNSTATES  294
 
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
-   by yylex, with out-of-bounds checking.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   376
+#define YYMAXUTOK   377
 
+
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+   as returned by yylex, with out-of-bounds checking.  */
 #define YYTRANSLATE(YYX)                                                \
-  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+  (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
-   as returned by yylex, without out-of-bounds checking.  */
+   as returned by yylex.  */
 static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,   121,     2,     2,     2,   137,   123,     2,
-     130,   129,   126,   124,     2,   125,     2,   127,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,   136,     2,
-     133,   132,   131,     2,     2,     2,     2,     2,     2,     2,
+       2,     2,     2,   122,     2,     2,     2,   138,   124,     2,
+     131,   130,   127,   125,     2,   126,     2,   128,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,   137,     2,
+     134,   133,   132,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,   134,     2,   135,   138,     2,     2,     2,     2,     2,
+       2,   135,     2,   136,   139,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,   122,     2,     2,     2,     2,     2,
+       2,     2,     2,     2,   123,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -944,36 +1026,36 @@
       85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
       95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
      105,   106,   107,   108,   109,   110,   111,   112,   113,   114,
-     115,   116,   117,   118,   119,   120,   128
+     115,   116,   117,   118,   119,   120,   121,   129
 };
 
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
-static const yytype_uint16 yyrline[] =
+static const yytype_int16 yyrline[] =
 {
-       0,   360,   360,   364,   366,   368,   369,   370,   371,   372,
-     374,   376,   378,   379,   381,   383,   384,   386,   388,   401,
-     410,   419,   428,   437,   439,   441,   443,   444,   445,   447,
-     449,   451,   452,   454,   455,   456,   457,   458,   459,   461,
-     462,   463,   464,   466,   468,   469,   470,   471,   472,   473,
-     476,   477,   480,   481,   482,   483,   484,   485,   486,   487,
-     488,   489,   490,   491,   494,   495,   496,   497,   500,   502,
-     503,   504,   505,   506,   507,   508,   509,   510,   511,   512,
-     513,   514,   515,   516,   517,   518,   519,   520,   521,   522,
-     523,   524,   525,   526,   527,   528,   529,   530,   531,   532,
-     533,   534,   535,   536,   537,   538,   539,   540,   542,   543,
-     544,   545,   546,   547,   548,   549,   550,   551,   552,   553,
-     554,   555,   556,   557,   558,   559,   560,   563,   564,   565,
-     566,   567,   568,   571,   576,   579,   583,   586,   587,   593,
-     594,   614,   630,   631,   652,   655,   656,   669,   670,   673,
-     676,   677,   678,   680,   681,   682,   684,   685,   687,   688,
-     689,   690,   691,   692,   693,   694,   695,   696,   697,   698,
-     699,   700,   701,   703,   704,   705,   706,   707,   709,   710,
-     712,   713,   714,   715,   716,   717,   718,   720,   721,   722,
-     723,   726,   727,   729,   730,   731,   732,   734,   741,   742,
-     745,   746,   747,   748,   749,   750,   753,   754,   755,   756,
-     757,   758,   759,   760,   762,   763,   764,   765,   767,   780,
-     781
+       0,   362,   362,   366,   368,   370,   371,   372,   373,   374,
+     376,   378,   380,   381,   383,   385,   386,   388,   390,   409,
+     420,   431,   432,   433,   435,   437,   439,   440,   441,   443,
+     445,   447,   448,   450,   451,   452,   453,   454,   462,   464,
+     465,   466,   467,   469,   471,   472,   473,   474,   475,   476,
+     479,   480,   483,   484,   485,   486,   487,   488,   489,   490,
+     491,   492,   493,   494,   497,   498,   499,   500,   503,   505,
+     506,   507,   508,   509,   510,   511,   512,   513,   514,   515,
+     516,   517,   518,   519,   520,   521,   522,   523,   524,   525,
+     526,   527,   528,   529,   530,   531,   532,   533,   534,   535,
+     536,   537,   538,   539,   540,   541,   542,   543,   545,   546,
+     547,   548,   549,   550,   551,   552,   553,   554,   555,   556,
+     557,   558,   559,   560,   561,   562,   563,   566,   567,   568,
+     569,   570,   571,   574,   579,   582,   586,   589,   590,   599,
+     600,   623,   640,   641,   665,   668,   669,   685,   686,   689,
+     692,   693,   694,   696,   697,   698,   700,   701,   703,   704,
+     705,   706,   707,   708,   709,   710,   711,   712,   713,   714,
+     715,   716,   717,   719,   720,   721,   722,   723,   725,   726,
+     728,   729,   730,   731,   732,   733,   734,   736,   737,   738,
+     739,   742,   743,   745,   746,   747,   748,   750,   757,   758,
+     761,   762,   763,   764,   765,   766,   769,   770,   771,   772,
+     773,   774,   775,   776,   778,   779,   780,   781,   783,   796,
+     797
 };
 #endif
 
@@ -996,23 +1078,23 @@
   "NETBEUI", "LANE", "LLC", "METAC", "BCC", "SC", "ILMIC", "OAMF4EC",
   "OAMF4SC", "OAM", "OAMF4", "CONNECTMSG", "METACONNECT", "VPI", "VCI",
   "RADIO", "FISU", "LSSU", "MSU", "HFISU", "HLSSU", "HMSU", "SIO", "OPC",
-  "DPC", "SLS", "HSIO", "HOPC", "HDPC", "HSLS", "OR", "AND", "'!'", "'|'",
-  "'&'", "'+'", "'-'", "'*'", "'/'", "UMINUS", "')'", "'('", "'>'", "'='",
-  "'<'", "'['", "']'", "':'", "'%'", "'^'", "$accept", "prog", "null",
-  "expr", "and", "or", "id", "nid", "not", "paren", "pid", "qid", "term",
-  "head", "rterm", "pqual", "dqual", "aqual", "ndaqual", "pname", "other",
-  "pfvar", "p80211", "type", "subtype", "type_subtype", "pllc", "dir",
-  "reason", "action", "relop", "irelop", "arth", "narth", "byteop", "pnum",
-  "atmtype", "atmmultitype", "atmfield", "atmvalue", "atmfieldvalue",
-  "atmlistvalue", "mtp2type", "mtp3field", "mtp3value", "mtp3fieldvalue",
-  "mtp3listvalue", YY_NULLPTR
+  "DPC", "SLS", "HSIO", "HOPC", "HDPC", "HSLS", "LEX_ERROR", "OR", "AND",
+  "'!'", "'|'", "'&'", "'+'", "'-'", "'*'", "'/'", "UMINUS", "')'", "'('",
+  "'>'", "'='", "'<'", "'['", "']'", "':'", "'%'", "'^'", "$accept",
+  "prog", "null", "expr", "and", "or", "id", "nid", "not", "paren", "pid",
+  "qid", "term", "head", "rterm", "pqual", "dqual", "aqual", "ndaqual",
+  "pname", "other", "pfvar", "p80211", "type", "subtype", "type_subtype",
+  "pllc", "dir", "reason", "action", "relop", "irelop", "arth", "narth",
+  "byteop", "pnum", "atmtype", "atmmultitype", "atmfield", "atmvalue",
+  "atmfieldvalue", "atmlistvalue", "mtp2type", "mtp3field", "mtp3value",
+  "mtp3fieldvalue", "mtp3listvalue", YY_NULLPTR
 };
 #endif
 
 # ifdef YYPRINT
 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
    (internal) symbol number NUM (which must be that of a token).  */
-static const yytype_uint16 yytoknum[] =
+static const yytype_int16 yytoknum[] =
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
@@ -1026,55 +1108,55 @@
      345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
      355,   356,   357,   358,   359,   360,   361,   362,   363,   364,
      365,   366,   367,   368,   369,   370,   371,   372,   373,   374,
-     375,    33,   124,    38,    43,    45,    42,    47,   376,    41,
-      40,    62,    61,    60,    91,    93,    58,    37,    94
+     375,   376,    33,   124,    38,    43,    45,    42,    47,   377,
+      41,    40,    62,    61,    60,    91,    93,    58,    37,    94
 };
 # endif
 
-#define YYPACT_NINF -216
+#define YYPACT_NINF (-216)
 
-#define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-216)))
+#define yypact_value_is_default(Yyn) \
+  ((Yyn) == YYPACT_NINF)
 
-#define YYTABLE_NINF -42
+#define YYTABLE_NINF (-42)
 
-#define yytable_value_is_error(Yytable_value) \
+#define yytable_value_is_error(Yyn) \
   0
 
   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
      STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-    -216,    24,   257,  -216,     0,    12,    17,  -216,  -216,  -216,
+    -216,    32,   257,  -216,    -1,    12,    28,  -216,  -216,  -216,
     -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
-    -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,    16,
-      25,    29,    72,   -18,    55,  -216,  -216,  -216,  -216,  -216,
-    -216,   -25,   -25,  -216,   -25,   -25,  -216,  -216,  -216,  -216,
+    -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,    25,
+      37,    31,    43,   -25,    48,  -216,  -216,  -216,  -216,  -216,
+    -216,   -36,   -36,  -216,   -36,   -36,  -216,  -216,  -216,  -216,
     -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
     -216,   -24,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
     -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
     -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
-     604,  -216,   -30,   489,   489,  -216,   125,  -216,   734,     3,
-    -216,  -216,  -216,   183,  -216,  -216,  -216,  -216,    -5,  -216,
-      39,  -216,  -216,   -54,  -216,  -216,  -216,  -216,  -216,  -216,
-    -216,  -216,  -216,   -25,  -216,  -216,  -216,  -216,  -216,  -216,
-     604,   -16,  -108,  -216,  -216,   373,   373,  -216,  -103,   -10,
-       2,  -216,  -216,    -7,    11,  -216,  -216,  -216,   125,   125,
-    -216,    -3,    21,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
-    -216,  -216,   -12,    77,    -9,  -216,  -216,  -216,  -216,  -216,
-    -216,    78,  -216,  -216,  -216,   604,  -216,  -216,  -216,   604,
-     604,   604,   604,   604,   604,   604,   604,  -216,  -216,  -216,
-     604,   604,   604,   604,  -216,   111,   113,   114,  -216,  -216,
-    -216,   115,   124,   126,  -216,  -216,  -216,  -216,  -216,  -216,
-    -216,   131,     2,   575,  -216,   373,   373,  -216,    10,  -216,
-    -216,  -216,  -216,  -216,   112,   137,   138,  -216,  -216,    47,
-     -30,     2,   173,   176,   178,   186,  -216,  -216,   143,  -216,
-    -216,  -216,  -216,  -216,  -216,   127,   -64,   -64,   580,   598,
-    -104,  -104,  -108,  -108,   575,   575,   575,   575,  -216,   -98,
-    -216,  -216,  -216,   -47,  -216,  -216,  -216,   -49,  -216,  -216,
-    -216,  -216,   125,   125,  -216,  -216,  -216,  -216,    -1,  -216,
-     156,  -216,   111,  -216,   115,  -216,  -216,  -216,  -216,  -216,
-      59,  -216,  -216,  -216
+     607,  -216,    54,   491,   491,  -216,   -34,  -216,   721,     2,
+    -216,  -216,  -216,   105,  -216,  -216,  -216,  -216,    17,  -216,
+      21,  -216,  -216,    33,  -216,  -216,  -216,  -216,  -216,  -216,
+    -216,  -216,  -216,   -36,  -216,  -216,  -216,  -216,  -216,  -216,
+     607,     6,    38,  -216,  -216,   374,   374,  -216,  -100,   -20,
+      29,  -216,  -216,    11,     8,  -216,  -216,  -216,   -34,   -34,
+    -216,    60,    65,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
+    -216,  -216,    -6,   109,     1,  -216,  -216,  -216,  -216,  -216,
+    -216,    80,  -216,  -216,  -216,   607,  -216,  -216,  -216,   607,
+     607,   607,   607,   607,   607,   607,   607,  -216,  -216,  -216,
+     607,   607,   607,   607,  -216,   127,   135,   147,  -216,  -216,
+    -216,   156,   157,   158,  -216,  -216,  -216,  -216,  -216,  -216,
+    -216,   159,    29,   181,  -216,   374,   374,  -216,    10,  -216,
+    -216,  -216,  -216,  -216,   136,   161,   162,  -216,  -216,    74,
+      54,    29,   201,   202,   204,   205,  -216,  -216,   163,  -216,
+    -216,  -216,  -216,  -216,  -216,    64,   -56,   -56,   578,   582,
+     -77,   -77,    38,    38,   181,   181,   181,   181,  -216,   -97,
+    -216,  -216,  -216,   -83,  -216,  -216,  -216,   -54,  -216,  -216,
+    -216,  -216,   -34,   -34,  -216,  -216,  -216,  -216,     4,  -216,
+     172,  -216,   127,  -216,   156,  -216,  -216,  -216,  -216,  -216,
+      75,  -216,  -216,  -216
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -1117,11 +1199,11 @@
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -216,  -216,  -216,   193,   -34,  -215,   -90,  -135,     7,    -2,
-    -216,  -216,   -80,  -216,  -216,  -216,  -216,    26,  -216,     9,
+    -216,  -216,  -216,   210,   -15,  -215,   -90,  -135,     7,    -2,
+    -216,  -216,   -80,  -216,  -216,  -216,  -216,    45,  -216,     9,
     -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,  -216,
-     -43,     5,   -26,   -92,  -216,   -37,  -216,  -216,  -216,  -216,
-    -175,  -216,  -216,  -216,  -216,  -174,  -216
+      50,    63,   -66,   -78,  -216,   -37,  -216,  -216,  -216,  -216,
+    -178,  -216,  -216,  -216,  -216,  -179,  -216
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
@@ -1139,175 +1221,173 @@
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_int16 yytable[] =
 {
-      94,   224,   139,   -41,   124,   125,   146,   126,   127,    93,
-     -13,    99,    26,   137,   228,   273,   133,   134,   128,   118,
-     258,   133,   185,   186,     3,   236,   221,   262,   241,   190,
-     191,   281,   194,   190,   191,   129,   287,   111,   139,   123,
-     123,   119,   123,   123,   282,   214,   219,   237,   284,   112,
-     242,   176,   177,   178,   113,   217,   220,   140,   288,   150,
-     183,   184,   185,   186,   132,   196,   116,   202,   206,   207,
-     -29,   -29,   133,   190,   191,   114,   200,   208,   209,   210,
-     223,   228,   283,   153,   115,   155,   212,   156,   157,   133,
-     134,    94,    94,   140,   149,   176,   177,   178,   218,   218,
-      93,    93,    99,    99,   213,    91,   195,   291,   201,   117,
-     292,   150,   231,   197,   121,   203,   232,   233,   175,   222,
-     225,   123,   -41,   -41,   139,    91,   187,   188,   189,   -13,
-     -13,   223,   -41,   216,   216,   137,   239,   175,   226,   -13,
-     234,   235,   215,   215,    99,    99,   149,   123,   194,   245,
-     260,   261,   200,   246,   247,   248,   249,   250,   251,   252,
-     253,   264,    26,   265,   254,   255,   256,   257,   266,    91,
-     187,   188,   189,   268,   269,   270,   271,   274,   218,   267,
-     275,   276,   285,   286,   141,   142,   143,   144,   145,   277,
-     278,   179,   180,   290,   293,    92,   272,   244,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,   216,    94,     0,     0,     0,     0,     0,
-       0,     0,   215,   215,    99,    99,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,   150,   150,     0,     0,   176,
-     177,   178,     0,     0,     0,     0,    89,   179,   180,   181,
-     182,   183,   184,   185,   186,    91,     0,    -3,     0,     0,
-       0,     0,   279,   280,   190,   191,     0,     0,     4,     5,
+      94,    26,   -41,    26,   124,   125,   146,   126,   127,    93,
+     -13,    99,   118,   137,   228,   273,   139,   258,   128,   224,
+     133,   134,   262,   133,   132,   141,   142,   143,   144,   145,
+     221,   236,     3,   281,   119,   129,   111,   133,   241,   123,
+     123,   287,   123,   123,   282,   214,   219,   283,   284,   112,
+     185,   186,   139,   237,   194,   217,   220,   140,   200,   150,
+     242,   190,   191,   288,   213,   113,   -29,   -29,   116,   183,
+     184,   185,   186,   176,   177,   178,   223,   176,   177,   178,
+     117,   228,   190,   191,   114,   153,   212,   155,    89,   156,
+     157,    94,    94,   140,   149,    91,   115,    91,   218,   218,
+      93,    93,    99,    99,   291,   292,   195,   121,   201,   245,
+     222,   150,   231,   246,   247,   248,   249,   250,   251,   252,
+     253,   123,   -41,   -41,   254,   255,   256,   257,   179,   180,
+     -13,   -13,   -41,   216,   216,   137,   226,   175,   139,   225,
+     -13,   175,   215,   215,    99,    99,   149,   123,    91,   187,
+     188,   189,    91,   187,   188,   189,   206,   207,   196,   223,
+     202,   176,   177,   178,   194,   208,   209,   210,   239,   179,
+     180,   197,   260,   203,   133,   134,   190,   191,   218,   267,
+     232,   233,   285,   286,   261,   234,   235,   181,   182,   183,
+     184,   185,   186,   200,   264,   265,   266,   268,   269,   270,
+     279,   280,   190,   191,   271,   274,   275,   276,   277,   290,
+     278,   293,    92,   216,    94,   272,   244,     0,     0,     0,
+       0,     0,   215,   215,    99,    99,     0,     0,   181,   182,
+     183,   184,   185,   186,     0,   150,   150,   187,   188,   189,
+       0,     0,     0,   190,   191,   179,   180,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    -3,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     4,     5,
      149,   149,     6,     7,     8,     9,    10,    11,    12,    13,
       14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
       24,    25,     0,     0,    26,    27,    28,    29,    30,    31,
-      32,    33,    34,     0,     0,   181,   182,   183,   184,   185,
-     186,     0,    35,     0,   187,   188,   189,     0,     0,     0,
-     190,   191,     0,    36,    37,    38,    39,    40,    41,    42,
+      32,    33,    34,     0,   181,   182,   183,   184,   185,   186,
+       0,     0,    35,     0,     0,     0,     0,     0,     0,   190,
+     191,     0,     0,    36,    37,    38,    39,    40,    41,    42,
       43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
       53,    54,    55,    56,    57,    58,    59,    60,    61,    62,
       63,    64,    65,    66,    67,    68,    69,    70,    71,    72,
       73,    74,    75,    76,    77,    78,    79,    80,    81,    82,
-      83,    84,    85,    86,    87,    88,     0,     0,    89,     0,
-       0,     0,    90,     0,     4,     5,     0,    91,     6,     7,
-       8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
-      18,    19,    20,    21,    22,    23,    24,    25,     0,     0,
-      26,    27,    28,    29,    30,    31,    32,    33,    34,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,    35,     0,
-       0,     0,   141,   142,   143,   144,   145,     0,     0,    36,
-      37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
-      47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
-      57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
-      67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
-      77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
-      87,    88,     0,     0,    89,     0,     0,     0,    90,     0,
-       4,     5,     0,    91,     6,     7,     8,     9,    10,    11,
-      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
-      22,    23,    24,    25,     0,     0,    26,    27,    28,    29,
-      30,    31,    32,    33,    34,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    35,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    36,    37,    38,    39,    40,
-      41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
-      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
-      61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
-      71,    72,    73,    74,    75,    76,    77,    78,    79,    80,
-      81,    82,    83,    84,    85,    86,    87,    88,     0,     0,
-      89,     0,     0,     0,    90,     0,     0,     0,     0,    91,
+      83,    84,    85,    86,    87,    88,     0,     0,     0,    89,
+       0,     0,     0,    90,     0,     4,     5,     0,    91,     6,
        7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
-      17,    18,    19,    20,    21,    22,    23,    24,    25,   179,
-     180,    26,     0,     0,   179,   180,     0,     0,     0,     0,
+      17,    18,    19,    20,    21,    22,    23,    24,    25,     0,
+       0,    26,    27,    28,    29,    30,    31,    32,    33,    34,
        0,     0,     0,     0,     0,     0,     0,     0,     0,    35,
-       0,     0,   179,   180,     0,     0,     0,     0,     0,     0,
-      36,    37,    38,    39,    40,     0,     0,     0,     0,     0,
+       0,     0,     0,   141,   142,   143,   144,   145,     0,     0,
+      36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
       46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
-      56,    57,    58,    59,     0,     0,     0,   181,   182,   183,
-     184,   185,   186,   182,   183,   184,   185,   186,    74,     0,
-       0,     0,   190,   191,     0,     0,     0,   190,   191,     0,
-       0,     0,   183,   184,   185,   186,     0,     0,     0,    90,
-       0,     0,     0,     0,    91,   190,   191,   151,   152,   153,
-     154,   155,     0,   156,   157,     0,     0,   158,   159,     0,
+      56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
+      66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
+      76,    77,    78,    79,    80,    81,    82,    83,    84,    85,
+      86,    87,    88,     0,     0,     0,    89,     0,     0,     0,
+      90,     0,     4,     5,     0,    91,     6,     7,     8,     9,
+      10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
+      20,    21,    22,    23,    24,    25,     0,     0,    26,    27,
+      28,    29,    30,    31,    32,    33,    34,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,    35,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,    36,    37,    38,
+      39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
+      49,    50,    51,    52,    53,    54,    55,    56,    57,    58,
+      59,    60,    61,    62,    63,    64,    65,    66,    67,    68,
+      69,    70,    71,    72,    73,    74,    75,    76,    77,    78,
+      79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
+       0,     0,     0,    89,     0,     0,     0,    90,     0,     0,
+       0,     0,    91,     7,     8,     9,    10,    11,    12,    13,
+      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,   179,   180,    26,     0,   179,   180,     0,     0,
        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,   160,
-     161,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-     162,   163,   164,   165,   166,   167,   168,   169,   170
+       0,     0,    35,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,    36,    37,    38,    39,    40,     0,     0,
+       0,     0,     0,    46,    47,    48,    49,    50,    51,    52,
+      53,    54,    55,    56,    57,    58,    59,     0,     0,     0,
+       0,     0,   182,   183,   184,   185,   186,   183,   184,   185,
+     186,    74,     0,     0,     0,     0,   190,   191,     0,     0,
+     190,   191,     0,     0,   151,   152,   153,   154,   155,     0,
+     156,   157,     0,    90,   158,   159,     0,     0,    91,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,   160,   161,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,   162,   163,   164,
+     165,   166,   167,   168,   169,   170
 };
 
 static const yytype_int16 yycheck[] =
 {
-       2,     8,    94,     0,    41,    42,    96,    44,    45,     2,
-       0,     2,    37,    93,   149,   230,   119,   120,    42,    37,
-     195,   119,   126,   127,     0,    37,   129,   201,    37,   137,
-     138,   129,    37,   137,   138,    59,    37,    37,   130,    41,
-      42,    59,    44,    45,   259,   135,   136,    59,   263,    37,
-      59,    56,    57,    58,    37,   135,   136,    94,    59,    96,
-     124,   125,   126,   127,    90,   108,    37,   110,   122,   123,
-     119,   120,   119,   137,   138,    59,    37,   131,   132,   133,
-     129,   216,   129,     5,    59,     7,   123,     9,    10,   119,
-     120,    93,    94,   130,    96,    56,    57,    58,   135,   136,
-      93,    94,    93,    94,   130,   130,   108,   282,   110,    37,
-     284,   148,   149,   108,    59,   110,   119,   120,   134,   129,
-     127,   123,   119,   120,   216,   130,   131,   132,   133,   119,
-     120,   129,   129,   135,   136,   215,    59,   134,   127,   129,
-     119,   120,   135,   136,   135,   136,   148,   149,    37,   175,
-      37,    37,    37,   179,   180,   181,   182,   183,   184,   185,
-     186,    37,    37,    37,   190,   191,   192,   193,    37,   130,
-     131,   132,   133,    61,    37,    37,   129,     4,   215,   216,
-       4,     3,   272,   273,    59,    60,    61,    62,    63,     3,
-      47,    64,    65,    37,   135,     2,   230,   171,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,   215,   216,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,   215,   216,   215,   216,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,   272,   273,    -1,    -1,    56,
-      57,    58,    -1,    -1,    -1,    -1,   121,    64,    65,   122,
-     123,   124,   125,   126,   127,   130,    -1,     0,    -1,    -1,
-      -1,    -1,   135,   136,   137,   138,    -1,    -1,    11,    12,
+       2,    37,     0,    37,    41,    42,    96,    44,    45,     2,
+       0,     2,    37,    93,   149,   230,    94,   195,    42,     8,
+     120,   121,   201,   120,    90,    59,    60,    61,    62,    63,
+     130,    37,     0,   130,    59,    59,    37,   120,    37,    41,
+      42,    37,    44,    45,   259,   135,   136,   130,   263,    37,
+     127,   128,   130,    59,    37,   135,   136,    94,    37,    96,
+      59,   138,   139,    59,   130,    37,   120,   121,    37,   125,
+     126,   127,   128,    56,    57,    58,   130,    56,    57,    58,
+      37,   216,   138,   139,    59,     5,   123,     7,   122,     9,
+      10,    93,    94,   130,    96,   131,    59,   131,   135,   136,
+      93,    94,    93,    94,   282,   284,   108,    59,   110,   175,
+     130,   148,   149,   179,   180,   181,   182,   183,   184,   185,
+     186,   123,   120,   121,   190,   191,   192,   193,    64,    65,
+     120,   121,   130,   135,   136,   215,   128,   135,   216,   128,
+     130,   135,   135,   136,   135,   136,   148,   149,   131,   132,
+     133,   134,   131,   132,   133,   134,   123,   124,   108,   130,
+     110,    56,    57,    58,    37,   132,   133,   134,    59,    64,
+      65,   108,    37,   110,   120,   121,   138,   139,   215,   216,
+     120,   121,   272,   273,    37,   120,   121,   123,   124,   125,
+     126,   127,   128,    37,    37,    37,    37,    61,    37,    37,
+     136,   137,   138,   139,   130,     4,     4,     3,     3,    37,
+      47,   136,     2,   215,   216,   230,   171,    -1,    -1,    -1,
+      -1,    -1,   215,   216,   215,   216,    -1,    -1,   123,   124,
+     125,   126,   127,   128,    -1,   272,   273,   132,   133,   134,
+      -1,    -1,    -1,   138,   139,    64,    65,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,     0,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    11,    12,
      272,   273,    15,    16,    17,    18,    19,    20,    21,    22,
       23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
       33,    34,    -1,    -1,    37,    38,    39,    40,    41,    42,
-      43,    44,    45,    -1,    -1,   122,   123,   124,   125,   126,
-     127,    -1,    55,    -1,   131,   132,   133,    -1,    -1,    -1,
-     137,   138,    -1,    66,    67,    68,    69,    70,    71,    72,
+      43,    44,    45,    -1,   123,   124,   125,   126,   127,   128,
+      -1,    -1,    55,    -1,    -1,    -1,    -1,    -1,    -1,   138,
+     139,    -1,    -1,    66,    67,    68,    69,    70,    71,    72,
       73,    74,    75,    76,    77,    78,    79,    80,    81,    82,
       83,    84,    85,    86,    87,    88,    89,    90,    91,    92,
       93,    94,    95,    96,    97,    98,    99,   100,   101,   102,
      103,   104,   105,   106,   107,   108,   109,   110,   111,   112,
-     113,   114,   115,   116,   117,   118,    -1,    -1,   121,    -1,
-      -1,    -1,   125,    -1,    11,    12,    -1,   130,    15,    16,
-      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
-      27,    28,    29,    30,    31,    32,    33,    34,    -1,    -1,
-      37,    38,    39,    40,    41,    42,    43,    44,    45,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    55,    -1,
-      -1,    -1,    59,    60,    61,    62,    63,    -1,    -1,    66,
-      67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
-      77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
-      87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
-      97,    98,    99,   100,   101,   102,   103,   104,   105,   106,
-     107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
-     117,   118,    -1,    -1,   121,    -1,    -1,    -1,   125,    -1,
-      11,    12,    -1,   130,    15,    16,    17,    18,    19,    20,
-      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
-      31,    32,    33,    34,    -1,    -1,    37,    38,    39,    40,
-      41,    42,    43,    44,    45,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    55,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    66,    67,    68,    69,    70,
-      71,    72,    73,    74,    75,    76,    77,    78,    79,    80,
-      81,    82,    83,    84,    85,    86,    87,    88,    89,    90,
-      91,    92,    93,    94,    95,    96,    97,    98,    99,   100,
-     101,   102,   103,   104,   105,   106,   107,   108,   109,   110,
-     111,   112,   113,   114,   115,   116,   117,   118,    -1,    -1,
-     121,    -1,    -1,    -1,   125,    -1,    -1,    -1,    -1,   130,
+     113,   114,   115,   116,   117,   118,    -1,    -1,    -1,   122,
+      -1,    -1,    -1,   126,    -1,    11,    12,    -1,   131,    15,
       16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
-      26,    27,    28,    29,    30,    31,    32,    33,    34,    64,
-      65,    37,    -1,    -1,    64,    65,    -1,    -1,    -1,    -1,
+      26,    27,    28,    29,    30,    31,    32,    33,    34,    -1,
+      -1,    37,    38,    39,    40,    41,    42,    43,    44,    45,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    55,
-      -1,    -1,    64,    65,    -1,    -1,    -1,    -1,    -1,    -1,
-      66,    67,    68,    69,    70,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    59,    60,    61,    62,    63,    -1,    -1,
+      66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
       76,    77,    78,    79,    80,    81,    82,    83,    84,    85,
-      86,    87,    88,    89,    -1,    -1,    -1,   122,   123,   124,
-     125,   126,   127,   123,   124,   125,   126,   127,   104,    -1,
-      -1,    -1,   137,   138,    -1,    -1,    -1,   137,   138,    -1,
-      -1,    -1,   124,   125,   126,   127,    -1,    -1,    -1,   125,
-      -1,    -1,    -1,    -1,   130,   137,   138,     3,     4,     5,
-       6,     7,    -1,     9,    10,    -1,    -1,    13,    14,    -1,
+      86,    87,    88,    89,    90,    91,    92,    93,    94,    95,
+      96,    97,    98,    99,   100,   101,   102,   103,   104,   105,
+     106,   107,   108,   109,   110,   111,   112,   113,   114,   115,
+     116,   117,   118,    -1,    -1,    -1,   122,    -1,    -1,    -1,
+     126,    -1,    11,    12,    -1,   131,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
+      29,    30,    31,    32,    33,    34,    -1,    -1,    37,    38,
+      39,    40,    41,    42,    43,    44,    45,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    66,    67,    68,
+      69,    70,    71,    72,    73,    74,    75,    76,    77,    78,
+      79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
+      89,    90,    91,    92,    93,    94,    95,    96,    97,    98,
+      99,   100,   101,   102,   103,   104,   105,   106,   107,   108,
+     109,   110,   111,   112,   113,   114,   115,   116,   117,   118,
+      -1,    -1,    -1,   122,    -1,    -1,    -1,   126,    -1,    -1,
+      -1,    -1,   131,    16,    17,    18,    19,    20,    21,    22,
+      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
+      33,    34,    64,    65,    37,    -1,    64,    65,    -1,    -1,
       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    35,
-      36,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      46,    47,    48,    49,    50,    51,    52,    53,    54
+      -1,    -1,    55,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    66,    67,    68,    69,    70,    -1,    -1,
+      -1,    -1,    -1,    76,    77,    78,    79,    80,    81,    82,
+      83,    84,    85,    86,    87,    88,    89,    -1,    -1,    -1,
+      -1,    -1,   124,   125,   126,   127,   128,   125,   126,   127,
+     128,   104,    -1,    -1,    -1,    -1,   138,   139,    -1,    -1,
+     138,   139,    -1,    -1,     3,     4,     5,     6,     7,    -1,
+       9,    10,    -1,   126,    13,    14,    -1,    -1,   131,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    35,    36,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    46,    47,    48,
+      49,    50,    51,    52,    53,    54
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
      symbol of state STATE-NUM.  */
 static const yytype_uint8 yystos[] =
 {
-       0,   140,   141,     0,    11,    12,    15,    16,    17,    18,
+       0,   141,   142,     0,    11,    12,    15,    16,    17,    18,
       19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
       29,    30,    31,    32,    33,    34,    37,    38,    39,    40,
       41,    42,    43,    44,    45,    55,    66,    67,    68,    69,
@@ -1315,60 +1395,60 @@
       80,    81,    82,    83,    84,    85,    86,    87,    88,    89,
       90,    91,    92,    93,    94,    95,    96,    97,    98,    99,
      100,   101,   102,   103,   104,   105,   106,   107,   108,   109,
-     110,   111,   112,   113,   114,   115,   116,   117,   118,   121,
-     125,   130,   142,   147,   148,   151,   152,   153,   154,   158,
-     159,   160,   165,   171,   172,   174,   175,   176,   177,   181,
-     182,    37,    37,    37,    59,    59,    37,    37,    37,    59,
-     167,    59,   168,   148,   174,   174,   174,   174,    42,    59,
-     148,   158,   171,   119,   120,   143,   144,   151,   142,   172,
-     174,    59,    60,    61,    62,    63,   145,   146,   147,   148,
-     174,     3,     4,     5,     6,     7,     9,    10,    13,    14,
+     110,   111,   112,   113,   114,   115,   116,   117,   118,   122,
+     126,   131,   143,   148,   149,   152,   153,   154,   155,   159,
+     160,   161,   166,   172,   173,   175,   176,   177,   178,   182,
+     183,    37,    37,    37,    59,    59,    37,    37,    37,    59,
+     168,    59,   169,   149,   175,   175,   175,   175,    42,    59,
+     149,   159,   172,   120,   121,   144,   145,   152,   143,   173,
+     175,    59,    60,    61,    62,    63,   146,   147,   148,   149,
+     175,     3,     4,     5,     6,     7,     9,    10,    13,    14,
       35,    36,    46,    47,    48,    49,    50,    51,    52,    53,
-      54,   155,   156,   157,   161,   134,    56,    57,    58,    64,
-      65,   122,   123,   124,   125,   126,   127,   131,   132,   133,
-     137,   138,   169,   170,    37,   148,   169,   170,   178,   179,
-      37,   148,   169,   170,   183,   184,   122,   123,   131,   132,
-     133,   173,   174,   171,   145,   147,   148,   151,   174,   145,
-     151,   129,   129,   129,     8,   127,   127,   145,   146,   149,
-     150,   174,   119,   120,   119,   120,    37,    59,   162,    59,
-     164,    37,    59,   166,   156,   171,   171,   171,   171,   171,
-     171,   171,   171,   171,   171,   171,   171,   171,   179,   180,
-      37,    37,   184,   185,    37,    37,    37,   174,    61,    37,
-      37,   129,   143,   144,     4,     4,     3,     3,    47,   135,
-     136,   129,   144,   129,   144,   145,   145,    37,    59,   163,
-      37,   179,   184,   135
+      54,   156,   157,   158,   162,   135,    56,    57,    58,    64,
+      65,   123,   124,   125,   126,   127,   128,   132,   133,   134,
+     138,   139,   170,   171,    37,   149,   170,   171,   179,   180,
+      37,   149,   170,   171,   184,   185,   123,   124,   132,   133,
+     134,   174,   175,   172,   146,   148,   149,   152,   175,   146,
+     152,   130,   130,   130,     8,   128,   128,   146,   147,   150,
+     151,   175,   120,   121,   120,   121,    37,    59,   163,    59,
+     165,    37,    59,   167,   157,   172,   172,   172,   172,   172,
+     172,   172,   172,   172,   172,   172,   172,   172,   180,   181,
+      37,    37,   185,   186,    37,    37,    37,   175,    61,    37,
+      37,   130,   144,   145,     4,     4,     3,     3,    47,   136,
+     137,   130,   145,   130,   145,   146,   146,    37,    59,   164,
+      37,   180,   185,   136
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,   139,   140,   140,   141,   142,   142,   142,   142,   142,
-     143,   144,   145,   145,   145,   146,   146,   146,   146,   146,
-     146,   146,   146,   146,   147,   148,   149,   149,   149,   150,
-     150,   151,   151,   152,   152,   152,   152,   152,   152,   153,
-     153,   153,   153,   153,   153,   153,   153,   153,   153,   153,
-     154,   154,   155,   155,   155,   155,   155,   155,   155,   155,
-     155,   155,   155,   155,   156,   156,   156,   156,   157,   158,
-     158,   158,   158,   158,   158,   158,   158,   158,   158,   158,
-     158,   158,   158,   158,   158,   158,   158,   158,   158,   158,
-     158,   158,   158,   158,   158,   158,   158,   158,   158,   158,
-     158,   158,   158,   158,   158,   158,   158,   158,   159,   159,
+       0,   140,   141,   141,   142,   143,   143,   143,   143,   143,
+     144,   145,   146,   146,   146,   147,   147,   147,   147,   147,
+     147,   147,   147,   147,   148,   149,   150,   150,   150,   151,
+     151,   152,   152,   153,   153,   153,   153,   153,   153,   154,
+     154,   154,   154,   154,   154,   154,   154,   154,   154,   154,
+     155,   155,   156,   156,   156,   156,   156,   156,   156,   156,
+     156,   156,   156,   156,   157,   157,   157,   157,   158,   159,
      159,   159,   159,   159,   159,   159,   159,   159,   159,   159,
-     159,   159,   159,   159,   159,   159,   159,   160,   160,   160,
-     160,   160,   160,   161,   161,   161,   161,   162,   162,   163,
-     163,   164,   165,   165,   165,   166,   166,   167,   167,   168,
-     169,   169,   169,   170,   170,   170,   171,   171,   172,   172,
-     172,   172,   172,   172,   172,   172,   172,   172,   172,   172,
-     172,   172,   172,   173,   173,   173,   173,   173,   174,   174,
-     175,   175,   175,   175,   175,   175,   175,   176,   176,   176,
-     176,   177,   177,   178,   178,   178,   178,   179,   180,   180,
-     181,   181,   181,   181,   181,   181,   182,   182,   182,   182,
-     182,   182,   182,   182,   183,   183,   183,   183,   184,   185,
-     185
+     159,   159,   159,   159,   159,   159,   159,   159,   159,   159,
+     159,   159,   159,   159,   159,   159,   159,   159,   159,   159,
+     159,   159,   159,   159,   159,   159,   159,   159,   160,   160,
+     160,   160,   160,   160,   160,   160,   160,   160,   160,   160,
+     160,   160,   160,   160,   160,   160,   160,   161,   161,   161,
+     161,   161,   161,   162,   162,   162,   162,   163,   163,   164,
+     164,   165,   166,   166,   166,   167,   167,   168,   168,   169,
+     170,   170,   170,   171,   171,   171,   172,   172,   173,   173,
+     173,   173,   173,   173,   173,   173,   173,   173,   173,   173,
+     173,   173,   173,   174,   174,   174,   174,   174,   175,   175,
+     176,   176,   176,   176,   176,   176,   176,   177,   177,   177,
+     177,   178,   178,   179,   179,   179,   179,   180,   181,   181,
+     182,   182,   182,   182,   182,   182,   183,   183,   183,   183,
+     183,   183,   183,   183,   184,   184,   184,   184,   185,   186,
+     186
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
-static const yytype_uint8 yyr2[] =
+static const yytype_int8 yyr2[] =
 {
        0,     2,     2,     1,     0,     1,     3,     3,     3,     3,
        1,     1,     1,     1,     3,     1,     3,     3,     1,     3,
@@ -1408,22 +1488,22 @@
 
 #define YYRECOVERING()  (!!yyerrstatus)
 
-#define YYBACKUP(Token, Value)                                  \
-do                                                              \
-  if (yychar == YYEMPTY)                                        \
-    {                                                           \
-      yychar = (Token);                                         \
-      yylval = (Value);                                         \
-      YYPOPSTACK (yylen);                                       \
-      yystate = *yyssp;                                         \
-      goto yybackup;                                            \
-    }                                                           \
-  else                                                          \
-    {                                                           \
-      yyerror (yyscanner, cstate, YY_("syntax error: cannot back up")); \
-      YYERROR;                                                  \
-    }                                                           \
-while (0)
+#define YYBACKUP(Token, Value)                                    \
+  do                                                              \
+    if (yychar == YYEMPTY)                                        \
+      {                                                           \
+        yychar = (Token);                                         \
+        yylval = (Value);                                         \
+        YYPOPSTACK (yylen);                                       \
+        yystate = *yyssp;                                         \
+        goto yybackup;                                            \
+      }                                                           \
+    else                                                          \
+      {                                                           \
+        yyerror (yyscanner, cstate, YY_("syntax error: cannot back up")); \
+        YYERROR;                                                  \
+      }                                                           \
+  while (0)
 
 /* Error token number */
 #define YYTERROR        1
@@ -1463,39 +1543,41 @@
 } while (0)
 
 
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT.  |
-`----------------------------------------*/
+/*-----------------------------------.
+| Print this symbol's value on YYO.  |
+`-----------------------------------*/
 
 static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, compiler_state_t *cstate)
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, compiler_state_t *cstate)
 {
-  FILE *yyo = yyoutput;
-  YYUSE (yyo);
+  FILE *yyoutput = yyo;
+  YYUSE (yyoutput);
   YYUSE (yyscanner);
   YYUSE (cstate);
   if (!yyvaluep)
     return;
 # ifdef YYPRINT
   if (yytype < YYNTOKENS)
-    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+    YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
 # endif
+  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
   YYUSE (yytype);
+  YY_IGNORE_MAYBE_UNINITIALIZED_END
 }
 
 
-/*--------------------------------.
-| Print this symbol on YYOUTPUT.  |
-`--------------------------------*/
+/*---------------------------.
+| Print this symbol on YYO.  |
+`---------------------------*/
 
 static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, compiler_state_t *cstate)
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, compiler_state_t *cstate)
 {
-  YYFPRINTF (yyoutput, "%s %s (",
+  YYFPRINTF (yyo, "%s %s (",
              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
 
-  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, cstate);
-  YYFPRINTF (yyoutput, ")");
+  yy_symbol_value_print (yyo, yytype, yyvaluep, yyscanner, cstate);
+  YYFPRINTF (yyo, ")");
 }
 
 /*------------------------------------------------------------------.
@@ -1504,7 +1586,7 @@
 `------------------------------------------------------------------*/
 
 static void
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
 {
   YYFPRINTF (stderr, "Stack now");
   for (; yybottom <= yytop; yybottom++)
@@ -1527,20 +1609,20 @@
 `------------------------------------------------*/
 
 static void
-yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, void *yyscanner, compiler_state_t *cstate)
+yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule, void *yyscanner, compiler_state_t *cstate)
 {
-  unsigned long int yylno = yyrline[yyrule];
+  int yylno = yyrline[yyrule];
   int yynrhs = yyr2[yyrule];
   int yyi;
-  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
              yyrule - 1, yylno);
   /* The symbols being reduced.  */
   for (yyi = 0; yyi < yynrhs; yyi++)
     {
       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
       yy_symbol_print (stderr,
-                       yystos[yyssp[yyi + 1 - yynrhs]],
-                       &(yyvsp[(yyi + 1) - (yynrhs)])
+                       yystos[+yyssp[yyi + 1 - yynrhs]],
+                       &yyvsp[(yyi + 1) - (yynrhs)]
                                               , yyscanner, cstate);
       YYFPRINTF (stderr, "\n");
     }
@@ -1584,13 +1666,13 @@
 
 # ifndef yystrlen
 #  if defined __GLIBC__ && defined _STRING_H
-#   define yystrlen strlen
+#   define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
 #  else
 /* Return the length of YYSTR.  */
-static YYSIZE_T
+static YYPTRDIFF_T
 yystrlen (const char *yystr)
 {
-  YYSIZE_T yylen;
+  YYPTRDIFF_T yylen;
   for (yylen = 0; yystr[yylen]; yylen++)
     continue;
   return yylen;
@@ -1626,12 +1708,12 @@
    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
    null, do not copy; instead, return the length of what the result
    would have been.  */
-static YYSIZE_T
+static YYPTRDIFF_T
 yytnamerr (char *yyres, const char *yystr)
 {
   if (*yystr == '"')
     {
-      YYSIZE_T yyn = 0;
+      YYPTRDIFF_T yyn = 0;
       char const *yyp = yystr;
 
       for (;;)
@@ -1644,7 +1726,10 @@
           case '\\':
             if (*++yyp != '\\')
               goto do_not_strip_quotes;
-            /* Fall through.  */
+            else
+              goto append;
+
+          append:
           default:
             if (yyres)
               yyres[yyn] = *yyp;
@@ -1659,10 +1744,10 @@
     do_not_strip_quotes: ;
     }
 
-  if (! yyres)
+  if (yyres)
+    return yystpcpy (yyres, yystr) - yyres;
+  else
     return yystrlen (yystr);
-
-  return yystpcpy (yyres, yystr) - yyres;
 }
 # endif
 
@@ -1675,19 +1760,19 @@
    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
    required number of bytes is too large to store.  */
 static int
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
-                yytype_int16 *yyssp, int yytoken)
+yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
+                yy_state_t *yyssp, int yytoken)
 {
-  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
-  YYSIZE_T yysize = yysize0;
   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   /* Internationalized format string. */
   const char *yyformat = YY_NULLPTR;
-  /* Arguments of yyformat. */
+  /* Arguments of yyformat: reported tokens (one for the "unexpected",
+     one per "expected"). */
   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
-  /* Number of reported tokens (one for the "unexpected", one per
-     "expected"). */
+  /* Actual size of YYARG. */
   int yycount = 0;
+  /* Cumulated lengths of YYARG.  */
+  YYPTRDIFF_T yysize = 0;
 
   /* There are many possibilities here to consider:
      - If this state is a consistent state with a default action, then
@@ -1714,7 +1799,9 @@
   */
   if (yytoken != YYEMPTY)
     {
-      int yyn = yypact[*yyssp];
+      int yyn = yypact[+*yyssp];
+      YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
+      yysize = yysize0;
       yyarg[yycount++] = yytname[yytoken];
       if (!yypact_value_is_default (yyn))
         {
@@ -1739,11 +1826,12 @@
                   }
                 yyarg[yycount++] = yytname[yyx];
                 {
-                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
-                  if (! (yysize <= yysize1
-                         && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+                  YYPTRDIFF_T yysize1
+                    = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
+                  if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+                    yysize = yysize1;
+                  else
                     return 2;
-                  yysize = yysize1;
                 }
               }
         }
@@ -1755,6 +1843,7 @@
       case N:                               \
         yyformat = S;                       \
       break
+    default: /* Avoid compiler warnings. */
       YYCASE_(0, YY_("syntax error"));
       YYCASE_(1, YY_("syntax error, unexpected %s"));
       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -1765,10 +1854,13 @@
     }
 
   {
-    YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
-    if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+    /* Don't count the "%s"s in the final size, but reserve room for
+       the terminator.  */
+    YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
+    if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+      yysize = yysize1;
+    else
       return 2;
-    yysize = yysize1;
   }
 
   if (*yymsg_alloc < yysize)
@@ -1794,8 +1886,8 @@
         }
       else
         {
-          yyp++;
-          yyformat++;
+          ++yyp;
+          ++yyformat;
         }
   }
   return 0;
@@ -1844,7 +1936,7 @@
     /* Number of syntax errors so far.  */
     int yynerrs;
 
-    int yystate;
+    yy_state_fast_t yystate;
     /* Number of tokens to shift before error messages enabled.  */
     int yyerrstatus;
 
@@ -1856,16 +1948,16 @@
        to reallocate them elsewhere.  */
 
     /* The state stack.  */
-    yytype_int16 yyssa[YYINITDEPTH];
-    yytype_int16 *yyss;
-    yytype_int16 *yyssp;
+    yy_state_t yyssa[YYINITDEPTH];
+    yy_state_t *yyss;
+    yy_state_t *yyssp;
 
     /* The semantic value stack.  */
     YYSTYPE yyvsa[YYINITDEPTH];
     YYSTYPE *yyvs;
     YYSTYPE *yyvsp;
 
-    YYSIZE_T yystacksize;
+    YYPTRDIFF_T yystacksize;
 
   int yyn;
   int yyresult;
@@ -1879,7 +1971,7 @@
   /* Buffer for error messages, and its allocated size.  */
   char yymsgbuf[128];
   char *yymsg = yymsgbuf;
-  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+  YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
 #endif
 
 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
@@ -1900,46 +1992,54 @@
   yychar = YYEMPTY; /* Cause a token to be read.  */
   goto yysetstate;
 
+
 /*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate.  |
+| yynewstate -- push a new state, which is found in yystate.  |
 `------------------------------------------------------------*/
- yynewstate:
+yynewstate:
   /* In all cases, when you get here, the value and location stacks
      have just been pushed.  So pushing a state here evens the stacks.  */
   yyssp++;
 
- yysetstate:
-  *yyssp = yystate;
+
+/*--------------------------------------------------------------------.
+| yysetstate -- set current state (the top of the stack) to yystate.  |
+`--------------------------------------------------------------------*/
+yysetstate:
+  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
+  YY_IGNORE_USELESS_CAST_BEGIN
+  *yyssp = YY_CAST (yy_state_t, yystate);
+  YY_IGNORE_USELESS_CAST_END
 
   if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+    goto yyexhaustedlab;
+#else
     {
       /* Get the current used size of the three stacks, in elements.  */
-      YYSIZE_T yysize = yyssp - yyss + 1;
+      YYPTRDIFF_T yysize = yyssp - yyss + 1;
 
-#ifdef yyoverflow
+# if defined yyoverflow
       {
         /* Give user a chance to reallocate the stack.  Use copies of
            these so that the &'s don't force the real ones into
            memory.  */
+        yy_state_t *yyss1 = yyss;
         YYSTYPE *yyvs1 = yyvs;
-        yytype_int16 *yyss1 = yyss;
 
         /* Each stack pointer address is followed by the size of the
            data in use in that stack, in bytes.  This used to be a
            conditional around just the two extra args, but that might
            be undefined if yyoverflow is a macro.  */
         yyoverflow (YY_("memory exhausted"),
-                    &yyss1, yysize * sizeof (*yyssp),
-                    &yyvs1, yysize * sizeof (*yyvsp),
+                    &yyss1, yysize * YYSIZEOF (*yyssp),
+                    &yyvs1, yysize * YYSIZEOF (*yyvsp),
                     &yystacksize);
-
         yyss = yyss1;
         yyvs = yyvs1;
       }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
-      goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
       /* Extend the stack our own way.  */
       if (YYMAXDEPTH <= yystacksize)
         goto yyexhaustedlab;
@@ -1948,42 +2048,43 @@
         yystacksize = YYMAXDEPTH;
 
       {
-        yytype_int16 *yyss1 = yyss;
+        yy_state_t *yyss1 = yyss;
         union yyalloc *yyptr =
-          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+          YY_CAST (union yyalloc *,
+                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
         if (! yyptr)
           goto yyexhaustedlab;
         YYSTACK_RELOCATE (yyss_alloc, yyss);
         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-#  undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
         if (yyss1 != yyssa)
           YYSTACK_FREE (yyss1);
       }
 # endif
-#endif /* no yyoverflow */
 
       yyssp = yyss + yysize - 1;
       yyvsp = yyvs + yysize - 1;
 
-      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
-                  (unsigned long int) yystacksize));
+      YY_IGNORE_USELESS_CAST_BEGIN
+      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
+                  YY_CAST (long, yystacksize)));
+      YY_IGNORE_USELESS_CAST_END
 
       if (yyss + yystacksize - 1 <= yyssp)
         YYABORT;
     }
-
-  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
 
   if (yystate == YYFINAL)
     YYACCEPT;
 
   goto yybackup;
 
+
 /*-----------.
 | yybackup.  |
 `-----------*/
 yybackup:
-
   /* Do appropriate processing given the current state.  Read a
      lookahead token if we need one and don't already have one.  */
 
@@ -2033,15 +2134,13 @@
 
   /* Shift the lookahead token.  */
   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
-  /* Discard the shifted token.  */
-  yychar = YYEMPTY;
-
   yystate = yyn;
   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
   *++yyvsp = yylval;
   YY_IGNORE_MAYBE_UNINITIALIZED_END
 
+  /* Discard the shifted token.  */
+  yychar = YYEMPTY;
   goto yynewstate;
 
 
@@ -2056,7 +2155,7 @@
 
 
 /*-----------------------------.
-| yyreduce -- Do a reduction.  |
+| yyreduce -- do a reduction.  |
 `-----------------------------*/
 yyreduce:
   /* yyn is the number of a rule to reduce with.  */
@@ -2076,852 +2175,857 @@
   YY_REDUCE_PRINT (yyn);
   switch (yyn)
     {
-        case 2:
-#line 361 "grammar.y" /* yacc.c:1646  */
-    {
-	finish_parse(cstate, (yyvsp[0].blk).b);
+  case 2:
+#line 363 "grammar.y"
+{
+	CHECK_INT_VAL(finish_parse(cstate, (yyvsp[0].blk).b));
 }
-#line 2085 "grammar.c" /* yacc.c:1646  */
+#line 2184 "grammar.c"
     break;
 
   case 4:
-#line 366 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).q = qerr; }
-#line 2091 "grammar.c" /* yacc.c:1646  */
+#line 368 "grammar.y"
+                                { (yyval.blk).q = qerr; }
+#line 2190 "grammar.c"
     break;
 
   case 6:
-#line 369 "grammar.y" /* yacc.c:1646  */
-    { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2097 "grammar.c" /* yacc.c:1646  */
+#line 371 "grammar.y"
+                                { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2196 "grammar.c"
     break;
 
   case 7:
-#line 370 "grammar.y" /* yacc.c:1646  */
-    { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2103 "grammar.c" /* yacc.c:1646  */
+#line 372 "grammar.y"
+                                { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2202 "grammar.c"
     break;
 
   case 8:
-#line 371 "grammar.y" /* yacc.c:1646  */
-    { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2109 "grammar.c" /* yacc.c:1646  */
+#line 373 "grammar.y"
+                                { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2208 "grammar.c"
     break;
 
   case 9:
-#line 372 "grammar.y" /* yacc.c:1646  */
-    { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2115 "grammar.c" /* yacc.c:1646  */
+#line 374 "grammar.y"
+                                { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2214 "grammar.c"
     break;
 
   case 10:
-#line 374 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk) = (yyvsp[-1].blk); }
-#line 2121 "grammar.c" /* yacc.c:1646  */
+#line 376 "grammar.y"
+                                { (yyval.blk) = (yyvsp[-1].blk); }
+#line 2220 "grammar.c"
     break;
 
   case 11:
-#line 376 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk) = (yyvsp[-1].blk); }
-#line 2127 "grammar.c" /* yacc.c:1646  */
+#line 378 "grammar.y"
+                                { (yyval.blk) = (yyvsp[-1].blk); }
+#line 2226 "grammar.c"
     break;
 
   case 13:
-#line 379 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_ncode(cstate, NULL, (bpf_u_int32)(yyvsp[0].i),
-						   (yyval.blk).q = (yyvsp[-1].blk).q); }
-#line 2134 "grammar.c" /* yacc.c:1646  */
+#line 381 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, NULL, (bpf_u_int32)(yyvsp[0].i),
+						   (yyval.blk).q = (yyvsp[-1].blk).q))); }
+#line 2233 "grammar.c"
     break;
 
   case 14:
-#line 381 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk) = (yyvsp[-1].blk); }
-#line 2140 "grammar.c" /* yacc.c:1646  */
+#line 383 "grammar.y"
+                                { (yyval.blk) = (yyvsp[-1].blk); }
+#line 2239 "grammar.c"
     break;
 
   case 15:
-#line 383 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_scode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q); }
-#line 2146 "grammar.c" /* yacc.c:1646  */
+#line 385 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_scode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); }
+#line 2245 "grammar.c"
     break;
 
   case 16:
-#line 384 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), NULL, (yyvsp[0].i),
-				    (yyval.blk).q = (yyvsp[-3].blk).q); }
-#line 2153 "grammar.c" /* yacc.c:1646  */
+#line 386 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[-2].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), NULL, (yyvsp[0].i),
+				    (yyval.blk).q = (yyvsp[-3].blk).q))); }
+#line 2252 "grammar.c"
     break;
 
   case 17:
-#line 386 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), (yyvsp[0].s), 0,
-				    (yyval.blk).q = (yyvsp[-3].blk).q); }
-#line 2160 "grammar.c" /* yacc.c:1646  */
+#line 388 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[-2].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), (yyvsp[0].s), 0,
+				    (yyval.blk).q = (yyvsp[-3].blk).q))); }
+#line 2259 "grammar.c"
     break;
 
   case 18:
-#line 388 "grammar.y" /* yacc.c:1646  */
-    {
+#line 390 "grammar.y"
+                                {
+				  CHECK_PTR_VAL((yyvsp[0].s));
 				  /* Decide how to parse HID based on proto */
 				  (yyval.blk).q = (yyvsp[-1].blk).q;
-				  if ((yyval.blk).q.addr == Q_PORT)
-				  	bpf_error(cstate, "'port' modifier applied to ip host");
-				  else if ((yyval.blk).q.addr == Q_PORTRANGE)
-				  	bpf_error(cstate, "'portrange' modifier applied to ip host");
-				  else if ((yyval.blk).q.addr == Q_PROTO)
-				  	bpf_error(cstate, "'proto' modifier applied to ip host");
-				  else if ((yyval.blk).q.addr == Q_PROTOCHAIN)
-				  	bpf_error(cstate, "'protochain' modifier applied to ip host");
-				  (yyval.blk).b = gen_ncode(cstate, (yyvsp[0].s), 0, (yyval.blk).q);
+				  if ((yyval.blk).q.addr == Q_PORT) {
+				  	bpf_set_error(cstate, "'port' modifier applied to ip host");
+				  	YYABORT;
+				  } else if ((yyval.blk).q.addr == Q_PORTRANGE) {
+				  	bpf_set_error(cstate, "'portrange' modifier applied to ip host");
+				  	YYABORT;
+				  } else if ((yyval.blk).q.addr == Q_PROTO) {
+				  	bpf_set_error(cstate, "'proto' modifier applied to ip host");
+				  	YYABORT;
+				  } else if ((yyval.blk).q.addr == Q_PROTOCHAIN) {
+				  	bpf_set_error(cstate, "'protochain' modifier applied to ip host");
+				  	YYABORT;
+				  }
+				  CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, (yyvsp[0].s), 0, (yyval.blk).q)));
 				}
-#line 2178 "grammar.c" /* yacc.c:1646  */
+#line 2283 "grammar.c"
     break;
 
   case 19:
-#line 401 "grammar.y" /* yacc.c:1646  */
-    {
+#line 409 "grammar.y"
+                                {
+				  CHECK_PTR_VAL((yyvsp[-2].s));
 #ifdef INET6
-				  (yyval.blk).b = gen_mcode6(cstate, (yyvsp[-2].s), NULL, (yyvsp[0].i),
-				    (yyval.blk).q = (yyvsp[-3].blk).q);
+				  CHECK_PTR_VAL(((yyval.blk).b = gen_mcode6(cstate, (yyvsp[-2].s), NULL, (yyvsp[0].i),
+				    (yyval.blk).q = (yyvsp[-3].blk).q)));
 #else
-				  bpf_error(cstate, "'ip6addr/prefixlen' not supported "
+				  bpf_set_error(cstate, "'ip6addr/prefixlen' not supported "
 					"in this configuration");
+				  YYABORT;
 #endif /*INET6*/
 				}
-#line 2192 "grammar.c" /* yacc.c:1646  */
+#line 2299 "grammar.c"
     break;
 
   case 20:
-#line 410 "grammar.y" /* yacc.c:1646  */
-    {
+#line 420 "grammar.y"
+                                {
+				  CHECK_PTR_VAL((yyvsp[0].s));
 #ifdef INET6
-				  (yyval.blk).b = gen_mcode6(cstate, (yyvsp[0].s), 0, 128,
-				    (yyval.blk).q = (yyvsp[-1].blk).q);
+				  CHECK_PTR_VAL(((yyval.blk).b = gen_mcode6(cstate, (yyvsp[0].s), 0, 128,
+				    (yyval.blk).q = (yyvsp[-1].blk).q)));
 #else
-				  bpf_error(cstate, "'ip6addr' not supported "
+				  bpf_set_error(cstate, "'ip6addr' not supported "
 					"in this configuration");
+				  YYABORT;
 #endif /*INET6*/
 				}
-#line 2206 "grammar.c" /* yacc.c:1646  */
+#line 2315 "grammar.c"
     break;
 
   case 21:
-#line 419 "grammar.y" /* yacc.c:1646  */
-    {
-				  (yyval.blk).b = gen_ecode(cstate, (yyvsp[0].e), (yyval.blk).q = (yyvsp[-1].blk).q);
-				  /*
-				   * $1 was allocated by "pcap_ether_aton()",
-				   * so we must free it now that we're done
-				   * with it.
-				   */
-				  free((yyvsp[0].e));
-				}
-#line 2220 "grammar.c" /* yacc.c:1646  */
+#line 431 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_ecode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); }
+#line 2321 "grammar.c"
     break;
 
   case 22:
-#line 428 "grammar.y" /* yacc.c:1646  */
-    {
-				  (yyval.blk).b = gen_acode(cstate, (yyvsp[0].e), (yyval.blk).q = (yyvsp[-1].blk).q);
-				  /*
-				   * $1 was allocated by "pcap_ether_aton()",
-				   * so we must free it now that we're done
-				   * with it.
-				   */
-				  free((yyvsp[0].e));
-				}
-#line 2234 "grammar.c" /* yacc.c:1646  */
+#line 432 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_acode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); }
+#line 2327 "grammar.c"
     break;
 
   case 23:
-#line 437 "grammar.y" /* yacc.c:1646  */
-    { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2240 "grammar.c" /* yacc.c:1646  */
+#line 433 "grammar.y"
+                                { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2333 "grammar.c"
     break;
 
   case 24:
-#line 439 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk) = (yyvsp[-1].blk); }
-#line 2246 "grammar.c" /* yacc.c:1646  */
+#line 435 "grammar.y"
+                                { (yyval.blk) = (yyvsp[-1].blk); }
+#line 2339 "grammar.c"
     break;
 
   case 25:
-#line 441 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk) = (yyvsp[-1].blk); }
-#line 2252 "grammar.c" /* yacc.c:1646  */
+#line 437 "grammar.y"
+                                { (yyval.blk) = (yyvsp[-1].blk); }
+#line 2345 "grammar.c"
     break;
 
   case 27:
-#line 444 "grammar.y" /* yacc.c:1646  */
-    { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2258 "grammar.c" /* yacc.c:1646  */
+#line 440 "grammar.y"
+                                { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2351 "grammar.c"
     break;
 
   case 28:
-#line 445 "grammar.y" /* yacc.c:1646  */
-    { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2264 "grammar.c" /* yacc.c:1646  */
+#line 441 "grammar.y"
+                                { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2357 "grammar.c"
     break;
 
   case 29:
-#line 447 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_ncode(cstate, NULL, (bpf_u_int32)(yyvsp[0].i),
-						   (yyval.blk).q = (yyvsp[-1].blk).q); }
-#line 2271 "grammar.c" /* yacc.c:1646  */
+#line 443 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, NULL, (bpf_u_int32)(yyvsp[0].i),
+						   (yyval.blk).q = (yyvsp[-1].blk).q))); }
+#line 2364 "grammar.c"
     break;
 
   case 32:
-#line 452 "grammar.y" /* yacc.c:1646  */
-    { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 2277 "grammar.c" /* yacc.c:1646  */
+#line 448 "grammar.y"
+                                { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 2370 "grammar.c"
     break;
 
   case 33:
-#line 454 "grammar.y" /* yacc.c:1646  */
-    { QSET((yyval.blk).q, (yyvsp[-2].i), (yyvsp[-1].i), (yyvsp[0].i)); }
-#line 2283 "grammar.c" /* yacc.c:1646  */
+#line 450 "grammar.y"
+                                { QSET((yyval.blk).q, (yyvsp[-2].i), (yyvsp[-1].i), (yyvsp[0].i)); }
+#line 2376 "grammar.c"
     break;
 
   case 34:
-#line 455 "grammar.y" /* yacc.c:1646  */
-    { QSET((yyval.blk).q, (yyvsp[-1].i), (yyvsp[0].i), Q_DEFAULT); }
-#line 2289 "grammar.c" /* yacc.c:1646  */
+#line 451 "grammar.y"
+                                { QSET((yyval.blk).q, (yyvsp[-1].i), (yyvsp[0].i), Q_DEFAULT); }
+#line 2382 "grammar.c"
     break;
 
   case 35:
-#line 456 "grammar.y" /* yacc.c:1646  */
-    { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); }
-#line 2295 "grammar.c" /* yacc.c:1646  */
+#line 452 "grammar.y"
+                                { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); }
+#line 2388 "grammar.c"
     break;
 
   case 36:
-#line 457 "grammar.y" /* yacc.c:1646  */
-    { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTO); }
-#line 2301 "grammar.c" /* yacc.c:1646  */
+#line 453 "grammar.y"
+                                { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTO); }
+#line 2394 "grammar.c"
     break;
 
   case 37:
-#line 458 "grammar.y" /* yacc.c:1646  */
-    { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTOCHAIN); }
-#line 2307 "grammar.c" /* yacc.c:1646  */
+#line 454 "grammar.y"
+                                {
+#ifdef NO_PROTOCHAIN
+				  bpf_set_error(cstate, "protochain not supported");
+				  YYABORT;
+#else
+				  QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTOCHAIN);
+#endif
+				}
+#line 2407 "grammar.c"
     break;
 
   case 38:
-#line 459 "grammar.y" /* yacc.c:1646  */
-    { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); }
-#line 2313 "grammar.c" /* yacc.c:1646  */
+#line 462 "grammar.y"
+                                { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); }
+#line 2413 "grammar.c"
     break;
 
   case 39:
-#line 461 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk) = (yyvsp[0].blk); }
-#line 2319 "grammar.c" /* yacc.c:1646  */
+#line 464 "grammar.y"
+                                { (yyval.blk) = (yyvsp[0].blk); }
+#line 2419 "grammar.c"
     break;
 
   case 40:
-#line 462 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = (yyvsp[-2].blk).q; }
-#line 2325 "grammar.c" /* yacc.c:1646  */
+#line 465 "grammar.y"
+                                { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = (yyvsp[-2].blk).q; }
+#line 2425 "grammar.c"
     break;
 
   case 41:
-#line 463 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_proto_abbrev(cstate, (yyvsp[0].i)); (yyval.blk).q = qerr; }
-#line 2331 "grammar.c" /* yacc.c:1646  */
+#line 466 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_proto_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; }
+#line 2431 "grammar.c"
     break;
 
   case 42:
-#line 464 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 0);
+#line 467 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 0)));
 				  (yyval.blk).q = qerr; }
-#line 2338 "grammar.c" /* yacc.c:1646  */
+#line 2438 "grammar.c"
     break;
 
   case 43:
-#line 466 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 1);
+#line 469 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 1)));
 				  (yyval.blk).q = qerr; }
-#line 2345 "grammar.c" /* yacc.c:1646  */
+#line 2445 "grammar.c"
     break;
 
   case 44:
-#line 468 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = (yyvsp[0].rblk); (yyval.blk).q = qerr; }
-#line 2351 "grammar.c" /* yacc.c:1646  */
+#line 471 "grammar.y"
+                                { (yyval.blk).b = (yyvsp[0].rblk); (yyval.blk).q = qerr; }
+#line 2451 "grammar.c"
     break;
 
   case 45:
-#line 469 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_atmtype_abbrev(cstate, (yyvsp[0].i)); (yyval.blk).q = qerr; }
-#line 2357 "grammar.c" /* yacc.c:1646  */
+#line 472 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_atmtype_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; }
+#line 2457 "grammar.c"
     break;
 
   case 46:
-#line 470 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_atmmulti_abbrev(cstate, (yyvsp[0].i)); (yyval.blk).q = qerr; }
-#line 2363 "grammar.c" /* yacc.c:1646  */
+#line 473 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_atmmulti_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; }
+#line 2463 "grammar.c"
     break;
 
   case 47:
-#line 471 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; }
-#line 2369 "grammar.c" /* yacc.c:1646  */
+#line 474 "grammar.y"
+                                { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; }
+#line 2469 "grammar.c"
     break;
 
   case 48:
-#line 472 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_mtp2type_abbrev(cstate, (yyvsp[0].i)); (yyval.blk).q = qerr; }
-#line 2375 "grammar.c" /* yacc.c:1646  */
+#line 475 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp2type_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; }
+#line 2475 "grammar.c"
     break;
 
   case 49:
-#line 473 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; }
-#line 2381 "grammar.c" /* yacc.c:1646  */
+#line 476 "grammar.y"
+                                { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; }
+#line 2481 "grammar.c"
     break;
 
   case 51:
-#line 477 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_DEFAULT; }
-#line 2387 "grammar.c" /* yacc.c:1646  */
+#line 480 "grammar.y"
+                                { (yyval.i) = Q_DEFAULT; }
+#line 2487 "grammar.c"
     break;
 
   case 52:
-#line 480 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_SRC; }
-#line 2393 "grammar.c" /* yacc.c:1646  */
+#line 483 "grammar.y"
+                                { (yyval.i) = Q_SRC; }
+#line 2493 "grammar.c"
     break;
 
   case 53:
-#line 481 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_DST; }
-#line 2399 "grammar.c" /* yacc.c:1646  */
+#line 484 "grammar.y"
+                                { (yyval.i) = Q_DST; }
+#line 2499 "grammar.c"
     break;
 
   case 54:
-#line 482 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_OR; }
-#line 2405 "grammar.c" /* yacc.c:1646  */
+#line 485 "grammar.y"
+                                { (yyval.i) = Q_OR; }
+#line 2505 "grammar.c"
     break;
 
   case 55:
-#line 483 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_OR; }
-#line 2411 "grammar.c" /* yacc.c:1646  */
+#line 486 "grammar.y"
+                                { (yyval.i) = Q_OR; }
+#line 2511 "grammar.c"
     break;
 
   case 56:
-#line 484 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_AND; }
-#line 2417 "grammar.c" /* yacc.c:1646  */
+#line 487 "grammar.y"
+                                { (yyval.i) = Q_AND; }
+#line 2517 "grammar.c"
     break;
 
   case 57:
-#line 485 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_AND; }
-#line 2423 "grammar.c" /* yacc.c:1646  */
+#line 488 "grammar.y"
+                                { (yyval.i) = Q_AND; }
+#line 2523 "grammar.c"
     break;
 
   case 58:
-#line 486 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ADDR1; }
-#line 2429 "grammar.c" /* yacc.c:1646  */
+#line 489 "grammar.y"
+                                { (yyval.i) = Q_ADDR1; }
+#line 2529 "grammar.c"
     break;
 
   case 59:
-#line 487 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ADDR2; }
-#line 2435 "grammar.c" /* yacc.c:1646  */
+#line 490 "grammar.y"
+                                { (yyval.i) = Q_ADDR2; }
+#line 2535 "grammar.c"
     break;
 
   case 60:
-#line 488 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ADDR3; }
-#line 2441 "grammar.c" /* yacc.c:1646  */
+#line 491 "grammar.y"
+                                { (yyval.i) = Q_ADDR3; }
+#line 2541 "grammar.c"
     break;
 
   case 61:
-#line 489 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ADDR4; }
-#line 2447 "grammar.c" /* yacc.c:1646  */
+#line 492 "grammar.y"
+                                { (yyval.i) = Q_ADDR4; }
+#line 2547 "grammar.c"
     break;
 
   case 62:
-#line 490 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_RA; }
-#line 2453 "grammar.c" /* yacc.c:1646  */
+#line 493 "grammar.y"
+                                { (yyval.i) = Q_RA; }
+#line 2553 "grammar.c"
     break;
 
   case 63:
-#line 491 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_TA; }
-#line 2459 "grammar.c" /* yacc.c:1646  */
+#line 494 "grammar.y"
+                                { (yyval.i) = Q_TA; }
+#line 2559 "grammar.c"
     break;
 
   case 64:
-#line 494 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_HOST; }
-#line 2465 "grammar.c" /* yacc.c:1646  */
+#line 497 "grammar.y"
+                                { (yyval.i) = Q_HOST; }
+#line 2565 "grammar.c"
     break;
 
   case 65:
-#line 495 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_NET; }
-#line 2471 "grammar.c" /* yacc.c:1646  */
+#line 498 "grammar.y"
+                                { (yyval.i) = Q_NET; }
+#line 2571 "grammar.c"
     break;
 
   case 66:
-#line 496 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_PORT; }
-#line 2477 "grammar.c" /* yacc.c:1646  */
+#line 499 "grammar.y"
+                                { (yyval.i) = Q_PORT; }
+#line 2577 "grammar.c"
     break;
 
   case 67:
-#line 497 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_PORTRANGE; }
-#line 2483 "grammar.c" /* yacc.c:1646  */
+#line 500 "grammar.y"
+                                { (yyval.i) = Q_PORTRANGE; }
+#line 2583 "grammar.c"
     break;
 
   case 68:
-#line 500 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_GATEWAY; }
-#line 2489 "grammar.c" /* yacc.c:1646  */
+#line 503 "grammar.y"
+                                { (yyval.i) = Q_GATEWAY; }
+#line 2589 "grammar.c"
     break;
 
   case 69:
-#line 502 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_LINK; }
-#line 2495 "grammar.c" /* yacc.c:1646  */
+#line 505 "grammar.y"
+                                { (yyval.i) = Q_LINK; }
+#line 2595 "grammar.c"
     break;
 
   case 70:
-#line 503 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_IP; }
-#line 2501 "grammar.c" /* yacc.c:1646  */
+#line 506 "grammar.y"
+                                { (yyval.i) = Q_IP; }
+#line 2601 "grammar.c"
     break;
 
   case 71:
-#line 504 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ARP; }
-#line 2507 "grammar.c" /* yacc.c:1646  */
+#line 507 "grammar.y"
+                                { (yyval.i) = Q_ARP; }
+#line 2607 "grammar.c"
     break;
 
   case 72:
-#line 505 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_RARP; }
-#line 2513 "grammar.c" /* yacc.c:1646  */
+#line 508 "grammar.y"
+                                { (yyval.i) = Q_RARP; }
+#line 2613 "grammar.c"
     break;
 
   case 73:
-#line 506 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_SCTP; }
-#line 2519 "grammar.c" /* yacc.c:1646  */
+#line 509 "grammar.y"
+                                { (yyval.i) = Q_SCTP; }
+#line 2619 "grammar.c"
     break;
 
   case 74:
-#line 507 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_TCP; }
-#line 2525 "grammar.c" /* yacc.c:1646  */
+#line 510 "grammar.y"
+                                { (yyval.i) = Q_TCP; }
+#line 2625 "grammar.c"
     break;
 
   case 75:
-#line 508 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_UDP; }
-#line 2531 "grammar.c" /* yacc.c:1646  */
+#line 511 "grammar.y"
+                                { (yyval.i) = Q_UDP; }
+#line 2631 "grammar.c"
     break;
 
   case 76:
-#line 509 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ICMP; }
-#line 2537 "grammar.c" /* yacc.c:1646  */
+#line 512 "grammar.y"
+                                { (yyval.i) = Q_ICMP; }
+#line 2637 "grammar.c"
     break;
 
   case 77:
-#line 510 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_IGMP; }
-#line 2543 "grammar.c" /* yacc.c:1646  */
+#line 513 "grammar.y"
+                                { (yyval.i) = Q_IGMP; }
+#line 2643 "grammar.c"
     break;
 
   case 78:
-#line 511 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_IGRP; }
-#line 2549 "grammar.c" /* yacc.c:1646  */
+#line 514 "grammar.y"
+                                { (yyval.i) = Q_IGRP; }
+#line 2649 "grammar.c"
     break;
 
   case 79:
-#line 512 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_PIM; }
-#line 2555 "grammar.c" /* yacc.c:1646  */
+#line 515 "grammar.y"
+                                { (yyval.i) = Q_PIM; }
+#line 2655 "grammar.c"
     break;
 
   case 80:
-#line 513 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_VRRP; }
-#line 2561 "grammar.c" /* yacc.c:1646  */
+#line 516 "grammar.y"
+                                { (yyval.i) = Q_VRRP; }
+#line 2661 "grammar.c"
     break;
 
   case 81:
-#line 514 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_CARP; }
-#line 2567 "grammar.c" /* yacc.c:1646  */
+#line 517 "grammar.y"
+                                { (yyval.i) = Q_CARP; }
+#line 2667 "grammar.c"
     break;
 
   case 82:
-#line 515 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ATALK; }
-#line 2573 "grammar.c" /* yacc.c:1646  */
+#line 518 "grammar.y"
+                                { (yyval.i) = Q_ATALK; }
+#line 2673 "grammar.c"
     break;
 
   case 83:
-#line 516 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_AARP; }
-#line 2579 "grammar.c" /* yacc.c:1646  */
+#line 519 "grammar.y"
+                                { (yyval.i) = Q_AARP; }
+#line 2679 "grammar.c"
     break;
 
   case 84:
-#line 517 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_DECNET; }
-#line 2585 "grammar.c" /* yacc.c:1646  */
+#line 520 "grammar.y"
+                                { (yyval.i) = Q_DECNET; }
+#line 2685 "grammar.c"
     break;
 
   case 85:
-#line 518 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_LAT; }
-#line 2591 "grammar.c" /* yacc.c:1646  */
+#line 521 "grammar.y"
+                                { (yyval.i) = Q_LAT; }
+#line 2691 "grammar.c"
     break;
 
   case 86:
-#line 519 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_SCA; }
-#line 2597 "grammar.c" /* yacc.c:1646  */
+#line 522 "grammar.y"
+                                { (yyval.i) = Q_SCA; }
+#line 2697 "grammar.c"
     break;
 
   case 87:
-#line 520 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_MOPDL; }
-#line 2603 "grammar.c" /* yacc.c:1646  */
+#line 523 "grammar.y"
+                                { (yyval.i) = Q_MOPDL; }
+#line 2703 "grammar.c"
     break;
 
   case 88:
-#line 521 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_MOPRC; }
-#line 2609 "grammar.c" /* yacc.c:1646  */
+#line 524 "grammar.y"
+                                { (yyval.i) = Q_MOPRC; }
+#line 2709 "grammar.c"
     break;
 
   case 89:
-#line 522 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_IPV6; }
-#line 2615 "grammar.c" /* yacc.c:1646  */
+#line 525 "grammar.y"
+                                { (yyval.i) = Q_IPV6; }
+#line 2715 "grammar.c"
     break;
 
   case 90:
-#line 523 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ICMPV6; }
-#line 2621 "grammar.c" /* yacc.c:1646  */
+#line 526 "grammar.y"
+                                { (yyval.i) = Q_ICMPV6; }
+#line 2721 "grammar.c"
     break;
 
   case 91:
-#line 524 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_AH; }
-#line 2627 "grammar.c" /* yacc.c:1646  */
+#line 527 "grammar.y"
+                                { (yyval.i) = Q_AH; }
+#line 2727 "grammar.c"
     break;
 
   case 92:
-#line 525 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ESP; }
-#line 2633 "grammar.c" /* yacc.c:1646  */
+#line 528 "grammar.y"
+                                { (yyval.i) = Q_ESP; }
+#line 2733 "grammar.c"
     break;
 
   case 93:
-#line 526 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISO; }
-#line 2639 "grammar.c" /* yacc.c:1646  */
+#line 529 "grammar.y"
+                                { (yyval.i) = Q_ISO; }
+#line 2739 "grammar.c"
     break;
 
   case 94:
-#line 527 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ESIS; }
-#line 2645 "grammar.c" /* yacc.c:1646  */
+#line 530 "grammar.y"
+                                { (yyval.i) = Q_ESIS; }
+#line 2745 "grammar.c"
     break;
 
   case 95:
-#line 528 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS; }
-#line 2651 "grammar.c" /* yacc.c:1646  */
+#line 531 "grammar.y"
+                                { (yyval.i) = Q_ISIS; }
+#line 2751 "grammar.c"
     break;
 
   case 96:
-#line 529 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS_L1; }
-#line 2657 "grammar.c" /* yacc.c:1646  */
+#line 532 "grammar.y"
+                                { (yyval.i) = Q_ISIS_L1; }
+#line 2757 "grammar.c"
     break;
 
   case 97:
-#line 530 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS_L2; }
-#line 2663 "grammar.c" /* yacc.c:1646  */
+#line 533 "grammar.y"
+                                { (yyval.i) = Q_ISIS_L2; }
+#line 2763 "grammar.c"
     break;
 
   case 98:
-#line 531 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS_IIH; }
-#line 2669 "grammar.c" /* yacc.c:1646  */
+#line 534 "grammar.y"
+                                { (yyval.i) = Q_ISIS_IIH; }
+#line 2769 "grammar.c"
     break;
 
   case 99:
-#line 532 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS_LSP; }
-#line 2675 "grammar.c" /* yacc.c:1646  */
+#line 535 "grammar.y"
+                                { (yyval.i) = Q_ISIS_LSP; }
+#line 2775 "grammar.c"
     break;
 
   case 100:
-#line 533 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS_SNP; }
-#line 2681 "grammar.c" /* yacc.c:1646  */
+#line 536 "grammar.y"
+                                { (yyval.i) = Q_ISIS_SNP; }
+#line 2781 "grammar.c"
     break;
 
   case 101:
-#line 534 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS_PSNP; }
-#line 2687 "grammar.c" /* yacc.c:1646  */
+#line 537 "grammar.y"
+                                { (yyval.i) = Q_ISIS_PSNP; }
+#line 2787 "grammar.c"
     break;
 
   case 102:
-#line 535 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_ISIS_CSNP; }
-#line 2693 "grammar.c" /* yacc.c:1646  */
+#line 538 "grammar.y"
+                                { (yyval.i) = Q_ISIS_CSNP; }
+#line 2793 "grammar.c"
     break;
 
   case 103:
-#line 536 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_CLNP; }
-#line 2699 "grammar.c" /* yacc.c:1646  */
+#line 539 "grammar.y"
+                                { (yyval.i) = Q_CLNP; }
+#line 2799 "grammar.c"
     break;
 
   case 104:
-#line 537 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_STP; }
-#line 2705 "grammar.c" /* yacc.c:1646  */
+#line 540 "grammar.y"
+                                { (yyval.i) = Q_STP; }
+#line 2805 "grammar.c"
     break;
 
   case 105:
-#line 538 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_IPX; }
-#line 2711 "grammar.c" /* yacc.c:1646  */
+#line 541 "grammar.y"
+                                { (yyval.i) = Q_IPX; }
+#line 2811 "grammar.c"
     break;
 
   case 106:
-#line 539 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_NETBEUI; }
-#line 2717 "grammar.c" /* yacc.c:1646  */
+#line 542 "grammar.y"
+                                { (yyval.i) = Q_NETBEUI; }
+#line 2817 "grammar.c"
     break;
 
   case 107:
-#line 540 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = Q_RADIO; }
-#line 2723 "grammar.c" /* yacc.c:1646  */
+#line 543 "grammar.y"
+                                { (yyval.i) = Q_RADIO; }
+#line 2823 "grammar.c"
     break;
 
   case 108:
-#line 542 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_broadcast(cstate, (yyvsp[-1].i)); }
-#line 2729 "grammar.c" /* yacc.c:1646  */
+#line 545 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_broadcast(cstate, (yyvsp[-1].i)))); }
+#line 2829 "grammar.c"
     break;
 
   case 109:
-#line 543 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_multicast(cstate, (yyvsp[-1].i)); }
-#line 2735 "grammar.c" /* yacc.c:1646  */
+#line 546 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_multicast(cstate, (yyvsp[-1].i)))); }
+#line 2835 "grammar.c"
     break;
 
   case 110:
-#line 544 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_less(cstate, (yyvsp[0].i)); }
-#line 2741 "grammar.c" /* yacc.c:1646  */
+#line 547 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_less(cstate, (yyvsp[0].i)))); }
+#line 2841 "grammar.c"
     break;
 
   case 111:
-#line 545 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_greater(cstate, (yyvsp[0].i)); }
-#line 2747 "grammar.c" /* yacc.c:1646  */
+#line 548 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_greater(cstate, (yyvsp[0].i)))); }
+#line 2847 "grammar.c"
     break;
 
   case 112:
-#line 546 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_byteop(cstate, (yyvsp[-1].i), (yyvsp[-2].i), (yyvsp[0].i)); }
-#line 2753 "grammar.c" /* yacc.c:1646  */
+#line 549 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_byteop(cstate, (yyvsp[-1].i), (yyvsp[-2].i), (yyvsp[0].i)))); }
+#line 2853 "grammar.c"
     break;
 
   case 113:
-#line 547 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_inbound(cstate, 0); }
-#line 2759 "grammar.c" /* yacc.c:1646  */
+#line 550 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_inbound(cstate, 0))); }
+#line 2859 "grammar.c"
     break;
 
   case 114:
-#line 548 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_inbound(cstate, 1); }
-#line 2765 "grammar.c" /* yacc.c:1646  */
+#line 551 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_inbound(cstate, 1))); }
+#line 2865 "grammar.c"
     break;
 
   case 115:
-#line 549 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_vlan(cstate, (yyvsp[0].i)); }
-#line 2771 "grammar.c" /* yacc.c:1646  */
+#line 552 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_vlan(cstate, (bpf_u_int32)(yyvsp[0].i), 1))); }
+#line 2871 "grammar.c"
     break;
 
   case 116:
-#line 550 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_vlan(cstate, -1); }
-#line 2777 "grammar.c" /* yacc.c:1646  */
+#line 553 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_vlan(cstate, 0, 0))); }
+#line 2877 "grammar.c"
     break;
 
   case 117:
-#line 551 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_mpls(cstate, (yyvsp[0].i)); }
-#line 2783 "grammar.c" /* yacc.c:1646  */
+#line 554 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_mpls(cstate, (bpf_u_int32)(yyvsp[0].i), 1))); }
+#line 2883 "grammar.c"
     break;
 
   case 118:
-#line 552 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_mpls(cstate, -1); }
-#line 2789 "grammar.c" /* yacc.c:1646  */
+#line 555 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_mpls(cstate, 0, 0))); }
+#line 2889 "grammar.c"
     break;
 
   case 119:
-#line 553 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pppoed(cstate); }
-#line 2795 "grammar.c" /* yacc.c:1646  */
+#line 556 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoed(cstate))); }
+#line 2895 "grammar.c"
     break;
 
   case 120:
-#line 554 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pppoes(cstate, (yyvsp[0].i)); }
-#line 2801 "grammar.c" /* yacc.c:1646  */
+#line 557 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoes(cstate, (bpf_u_int32)(yyvsp[0].i), 1))); }
+#line 2901 "grammar.c"
     break;
 
   case 121:
-#line 555 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pppoes(cstate, -1); }
-#line 2807 "grammar.c" /* yacc.c:1646  */
+#line 558 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoes(cstate, 0, 0))); }
+#line 2907 "grammar.c"
     break;
 
   case 122:
-#line 556 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_geneve(cstate, (yyvsp[0].i)); }
-#line 2813 "grammar.c" /* yacc.c:1646  */
+#line 559 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_geneve(cstate, (bpf_u_int32)(yyvsp[0].i), 1))); }
+#line 2913 "grammar.c"
     break;
 
   case 123:
-#line 557 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_geneve(cstate, -1); }
-#line 2819 "grammar.c" /* yacc.c:1646  */
+#line 560 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_geneve(cstate, 0, 0))); }
+#line 2919 "grammar.c"
     break;
 
   case 124:
-#line 558 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = (yyvsp[0].rblk); }
-#line 2825 "grammar.c" /* yacc.c:1646  */
+#line 561 "grammar.y"
+                                { (yyval.rblk) = (yyvsp[0].rblk); }
+#line 2925 "grammar.c"
     break;
 
   case 125:
-#line 559 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = (yyvsp[0].rblk); }
-#line 2831 "grammar.c" /* yacc.c:1646  */
+#line 562 "grammar.y"
+                                { (yyval.rblk) = (yyvsp[0].rblk); }
+#line 2931 "grammar.c"
     break;
 
   case 126:
-#line 560 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = (yyvsp[0].rblk); }
-#line 2837 "grammar.c" /* yacc.c:1646  */
+#line 563 "grammar.y"
+                                { (yyval.rblk) = (yyvsp[0].rblk); }
+#line 2937 "grammar.c"
     break;
 
   case 127:
-#line 563 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pf_ifname(cstate, (yyvsp[0].s)); }
-#line 2843 "grammar.c" /* yacc.c:1646  */
+#line 566 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.rblk) = gen_pf_ifname(cstate, (yyvsp[0].s)))); }
+#line 2943 "grammar.c"
     break;
 
   case 128:
-#line 564 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pf_ruleset(cstate, (yyvsp[0].s)); }
-#line 2849 "grammar.c" /* yacc.c:1646  */
+#line 567 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.rblk) = gen_pf_ruleset(cstate, (yyvsp[0].s)))); }
+#line 2949 "grammar.c"
     break;
 
   case 129:
-#line 565 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pf_rnr(cstate, (yyvsp[0].i)); }
-#line 2855 "grammar.c" /* yacc.c:1646  */
+#line 568 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_rnr(cstate, (yyvsp[0].i)))); }
+#line 2955 "grammar.c"
     break;
 
   case 130:
-#line 566 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pf_srnr(cstate, (yyvsp[0].i)); }
-#line 2861 "grammar.c" /* yacc.c:1646  */
+#line 569 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_srnr(cstate, (yyvsp[0].i)))); }
+#line 2961 "grammar.c"
     break;
 
   case 131:
-#line 567 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pf_reason(cstate, (yyvsp[0].i)); }
-#line 2867 "grammar.c" /* yacc.c:1646  */
+#line 570 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_reason(cstate, (yyvsp[0].i)))); }
+#line 2967 "grammar.c"
     break;
 
   case 132:
-#line 568 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_pf_action(cstate, (yyvsp[0].i)); }
-#line 2873 "grammar.c" /* yacc.c:1646  */
+#line 571 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_action(cstate, (yyvsp[0].i)))); }
+#line 2973 "grammar.c"
     break;
 
   case 133:
-#line 572 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_p80211_type(cstate, (yyvsp[-2].i) | (yyvsp[0].i),
+#line 575 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[-2].i) | (yyvsp[0].i),
 					IEEE80211_FC0_TYPE_MASK |
-					IEEE80211_FC0_SUBTYPE_MASK);
+					IEEE80211_FC0_SUBTYPE_MASK)));
 				}
-#line 2882 "grammar.c" /* yacc.c:1646  */
+#line 2982 "grammar.c"
     break;
 
   case 134:
-#line 576 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i),
-					IEEE80211_FC0_TYPE_MASK);
+#line 579 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i),
+					IEEE80211_FC0_TYPE_MASK)));
 				}
-#line 2890 "grammar.c" /* yacc.c:1646  */
+#line 2990 "grammar.c"
     break;
 
   case 135:
-#line 579 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i),
+#line 582 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i),
 					IEEE80211_FC0_TYPE_MASK |
-					IEEE80211_FC0_SUBTYPE_MASK);
+					IEEE80211_FC0_SUBTYPE_MASK)));
 				}
-#line 2899 "grammar.c" /* yacc.c:1646  */
+#line 2999 "grammar.c"
     break;
 
   case 136:
-#line 583 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_p80211_fcdir(cstate, (yyvsp[0].i)); }
-#line 2905 "grammar.c" /* yacc.c:1646  */
+#line 586 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_fcdir(cstate, (yyvsp[0].i)))); }
+#line 3005 "grammar.c"
     break;
 
   case 138:
-#line 587 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = str2tok((yyvsp[0].s), ieee80211_types);
-				  if ((yyval.i) == -1)
-				  	bpf_error(cstate, "unknown 802.11 type name");
+#line 590 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s));
+				  (yyval.i) = str2tok((yyvsp[0].s), ieee80211_types);
+				  if ((yyval.i) == -1) {
+				  	bpf_set_error(cstate, "unknown 802.11 type name");
+				  	YYABORT;
+				  }
 				}
-#line 2914 "grammar.c" /* yacc.c:1646  */
+#line 3017 "grammar.c"
     break;
 
   case 140:
-#line 594 "grammar.y" /* yacc.c:1646  */
-    { const struct tok *types = NULL;
+#line 600 "grammar.y"
+                                { const struct tok *types = NULL;
 				  int i;
+				  CHECK_PTR_VAL((yyvsp[0].s));
 				  for (i = 0;; i++) {
 				  	if (ieee80211_type_subtypes[i].tok == NULL) {
 				  		/* Ran out of types */
-						bpf_error(cstate, "unknown 802.11 type");
-						break;
+						bpf_set_error(cstate, "unknown 802.11 type");
+						YYABORT;
 					}
 					if ((yyvsp[(-1) - (1)].i) == ieee80211_type_subtypes[i].type) {
 						types = ieee80211_type_subtypes[i].tok;
@@ -2930,20 +3034,23 @@
 				  }
 
 				  (yyval.i) = str2tok((yyvsp[0].s), types);
-				  if ((yyval.i) == -1)
-					bpf_error(cstate, "unknown 802.11 subtype name");
+				  if ((yyval.i) == -1) {
+					bpf_set_error(cstate, "unknown 802.11 subtype name");
+					YYABORT;
+				  }
 				}
-#line 2937 "grammar.c" /* yacc.c:1646  */
+#line 3043 "grammar.c"
     break;
 
   case 141:
-#line 614 "grammar.y" /* yacc.c:1646  */
-    { int i;
+#line 623 "grammar.y"
+                                { int i;
+				  CHECK_PTR_VAL((yyvsp[0].s));
 				  for (i = 0;; i++) {
 				  	if (ieee80211_type_subtypes[i].tok == NULL) {
 				  		/* Ran out of types */
-						bpf_error(cstate, "unknown 802.11 type name");
-						break;
+						bpf_set_error(cstate, "unknown 802.11 type name");
+						YYABORT;
 					}
 					(yyval.i) = str2tok((yyvsp[0].s), ieee80211_type_subtypes[i].tok);
 					if ((yyval.i) != -1) {
@@ -2952,49 +3059,53 @@
 					}
 				  }
 				}
-#line 2956 "grammar.c" /* yacc.c:1646  */
+#line 3063 "grammar.c"
     break;
 
   case 142:
-#line 630 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_llc(cstate); }
-#line 2962 "grammar.c" /* yacc.c:1646  */
+#line 640 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_llc(cstate))); }
+#line 3069 "grammar.c"
     break;
 
   case 143:
-#line 631 "grammar.y" /* yacc.c:1646  */
-    { if (pcap_strcasecmp((yyvsp[0].s), "i") == 0)
-					(yyval.rblk) = gen_llc_i(cstate);
-				  else if (pcap_strcasecmp((yyvsp[0].s), "s") == 0)
-					(yyval.rblk) = gen_llc_s(cstate);
-				  else if (pcap_strcasecmp((yyvsp[0].s), "u") == 0)
-					(yyval.rblk) = gen_llc_u(cstate);
-				  else {
+#line 641 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s));
+				  if (pcap_strcasecmp((yyvsp[0].s), "i") == 0) {
+					CHECK_PTR_VAL(((yyval.rblk) = gen_llc_i(cstate)));
+				  } else if (pcap_strcasecmp((yyvsp[0].s), "s") == 0) {
+					CHECK_PTR_VAL(((yyval.rblk) = gen_llc_s(cstate)));
+				  } else if (pcap_strcasecmp((yyvsp[0].s), "u") == 0) {
+					CHECK_PTR_VAL(((yyval.rblk) = gen_llc_u(cstate)));
+				  } else {
 					int subtype;
 
 					subtype = str2tok((yyvsp[0].s), llc_s_subtypes);
-					if (subtype != -1)
-						(yyval.rblk) = gen_llc_s_subtype(cstate, subtype);
-					else {
+					if (subtype != -1) {
+						CHECK_PTR_VAL(((yyval.rblk) = gen_llc_s_subtype(cstate, subtype)));
+					} else {
 						subtype = str2tok((yyvsp[0].s), llc_u_subtypes);
-						if (subtype == -1)
-					  		bpf_error(cstate, "unknown LLC type name \"%s\"", (yyvsp[0].s));
-						(yyval.rblk) = gen_llc_u_subtype(cstate, subtype);
+						if (subtype == -1) {
+					  		bpf_set_error(cstate, "unknown LLC type name \"%s\"", (yyvsp[0].s));
+					  		YYABORT;
+					  	}
+						CHECK_PTR_VAL(((yyval.rblk) = gen_llc_u_subtype(cstate, subtype)));
 					}
 				  }
 				}
-#line 2987 "grammar.c" /* yacc.c:1646  */
+#line 3097 "grammar.c"
     break;
 
   case 144:
-#line 652 "grammar.y" /* yacc.c:1646  */
-    { (yyval.rblk) = gen_llc_s_subtype(cstate, LLC_RNR); }
-#line 2993 "grammar.c" /* yacc.c:1646  */
+#line 665 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.rblk) = gen_llc_s_subtype(cstate, LLC_RNR))); }
+#line 3103 "grammar.c"
     break;
 
   case 146:
-#line 656 "grammar.y" /* yacc.c:1646  */
-    { if (pcap_strcasecmp((yyvsp[0].s), "nods") == 0)
+#line 669 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s));
+				  if (pcap_strcasecmp((yyvsp[0].s), "nods") == 0)
 					(yyval.i) = IEEE80211_FC1_DIR_NODS;
 				  else if (pcap_strcasecmp((yyvsp[0].s), "tods") == 0)
 					(yyval.i) = IEEE80211_FC1_DIR_TODS;
@@ -3002,416 +3113,418 @@
 					(yyval.i) = IEEE80211_FC1_DIR_FROMDS;
 				  else if (pcap_strcasecmp((yyvsp[0].s), "dstods") == 0)
 					(yyval.i) = IEEE80211_FC1_DIR_DSTODS;
-				  else
-					bpf_error(cstate, "unknown 802.11 direction");
+				  else {
+					bpf_set_error(cstate, "unknown 802.11 direction");
+					YYABORT;
+				  }
 				}
-#line 3009 "grammar.c" /* yacc.c:1646  */
+#line 3122 "grammar.c"
     break;
 
   case 147:
-#line 669 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = (yyvsp[0].i); }
-#line 3015 "grammar.c" /* yacc.c:1646  */
+#line 685 "grammar.y"
+                                { (yyval.i) = (yyvsp[0].i); }
+#line 3128 "grammar.c"
     break;
 
   case 148:
-#line 670 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = pfreason_to_num(cstate, (yyvsp[0].s)); }
-#line 3021 "grammar.c" /* yacc.c:1646  */
+#line 686 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_INT_VAL(((yyval.i) = pfreason_to_num(cstate, (yyvsp[0].s)))); }
+#line 3134 "grammar.c"
     break;
 
   case 149:
-#line 673 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = pfaction_to_num(cstate, (yyvsp[0].s)); }
-#line 3027 "grammar.c" /* yacc.c:1646  */
+#line 689 "grammar.y"
+                                { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_INT_VAL(((yyval.i) = pfaction_to_num(cstate, (yyvsp[0].s)))); }
+#line 3140 "grammar.c"
     break;
 
   case 150:
-#line 676 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = BPF_JGT; }
-#line 3033 "grammar.c" /* yacc.c:1646  */
+#line 692 "grammar.y"
+                                { (yyval.i) = BPF_JGT; }
+#line 3146 "grammar.c"
     break;
 
   case 151:
-#line 677 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = BPF_JGE; }
-#line 3039 "grammar.c" /* yacc.c:1646  */
+#line 693 "grammar.y"
+                                { (yyval.i) = BPF_JGE; }
+#line 3152 "grammar.c"
     break;
 
   case 152:
-#line 678 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = BPF_JEQ; }
-#line 3045 "grammar.c" /* yacc.c:1646  */
+#line 694 "grammar.y"
+                                { (yyval.i) = BPF_JEQ; }
+#line 3158 "grammar.c"
     break;
 
   case 153:
-#line 680 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = BPF_JGT; }
-#line 3051 "grammar.c" /* yacc.c:1646  */
+#line 696 "grammar.y"
+                                { (yyval.i) = BPF_JGT; }
+#line 3164 "grammar.c"
     break;
 
   case 154:
-#line 681 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = BPF_JGE; }
-#line 3057 "grammar.c" /* yacc.c:1646  */
+#line 697 "grammar.y"
+                                { (yyval.i) = BPF_JGE; }
+#line 3170 "grammar.c"
     break;
 
   case 155:
-#line 682 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = BPF_JEQ; }
-#line 3063 "grammar.c" /* yacc.c:1646  */
+#line 698 "grammar.y"
+                                { (yyval.i) = BPF_JEQ; }
+#line 3176 "grammar.c"
     break;
 
   case 156:
-#line 684 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_loadi(cstate, (yyvsp[0].i)); }
-#line 3069 "grammar.c" /* yacc.c:1646  */
+#line 700 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.a) = gen_loadi(cstate, (yyvsp[0].i)))); }
+#line 3182 "grammar.c"
     break;
 
   case 158:
-#line 687 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_load(cstate, (yyvsp[-3].i), (yyvsp[-1].a), 1); }
-#line 3075 "grammar.c" /* yacc.c:1646  */
+#line 703 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_load(cstate, (yyvsp[-3].i), (yyvsp[-1].a), 1))); }
+#line 3188 "grammar.c"
     break;
 
   case 159:
-#line 688 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_load(cstate, (yyvsp[-5].i), (yyvsp[-3].a), (yyvsp[-1].i)); }
-#line 3081 "grammar.c" /* yacc.c:1646  */
+#line 704 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_load(cstate, (yyvsp[-5].i), (yyvsp[-3].a), (yyvsp[-1].i)))); }
+#line 3194 "grammar.c"
     break;
 
   case 160:
-#line 689 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_ADD, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3087 "grammar.c" /* yacc.c:1646  */
+#line 705 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_ADD, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3200 "grammar.c"
     break;
 
   case 161:
-#line 690 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_SUB, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3093 "grammar.c" /* yacc.c:1646  */
+#line 706 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_SUB, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3206 "grammar.c"
     break;
 
   case 162:
-#line 691 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_MUL, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3099 "grammar.c" /* yacc.c:1646  */
+#line 707 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_MUL, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3212 "grammar.c"
     break;
 
   case 163:
-#line 692 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_DIV, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3105 "grammar.c" /* yacc.c:1646  */
+#line 708 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_DIV, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3218 "grammar.c"
     break;
 
   case 164:
-#line 693 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_MOD, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3111 "grammar.c" /* yacc.c:1646  */
+#line 709 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_MOD, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3224 "grammar.c"
     break;
 
   case 165:
-#line 694 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_AND, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3117 "grammar.c" /* yacc.c:1646  */
+#line 710 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_AND, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3230 "grammar.c"
     break;
 
   case 166:
-#line 695 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_OR, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3123 "grammar.c" /* yacc.c:1646  */
+#line 711 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_OR, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3236 "grammar.c"
     break;
 
   case 167:
-#line 696 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_XOR, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3129 "grammar.c" /* yacc.c:1646  */
+#line 712 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_XOR, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3242 "grammar.c"
     break;
 
   case 168:
-#line 697 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_LSH, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3135 "grammar.c" /* yacc.c:1646  */
+#line 713 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_LSH, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3248 "grammar.c"
     break;
 
   case 169:
-#line 698 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_arth(cstate, BPF_RSH, (yyvsp[-2].a), (yyvsp[0].a)); }
-#line 3141 "grammar.c" /* yacc.c:1646  */
+#line 714 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_RSH, (yyvsp[-2].a), (yyvsp[0].a)))); }
+#line 3254 "grammar.c"
     break;
 
   case 170:
-#line 699 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_neg(cstate, (yyvsp[0].a)); }
-#line 3147 "grammar.c" /* yacc.c:1646  */
+#line 715 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_neg(cstate, (yyvsp[0].a)))); }
+#line 3260 "grammar.c"
     break;
 
   case 171:
-#line 700 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = (yyvsp[-1].a); }
-#line 3153 "grammar.c" /* yacc.c:1646  */
+#line 716 "grammar.y"
+                                        { (yyval.a) = (yyvsp[-1].a); }
+#line 3266 "grammar.c"
     break;
 
   case 172:
-#line 701 "grammar.y" /* yacc.c:1646  */
-    { (yyval.a) = gen_loadlen(cstate); }
-#line 3159 "grammar.c" /* yacc.c:1646  */
+#line 717 "grammar.y"
+                                        { CHECK_PTR_VAL(((yyval.a) = gen_loadlen(cstate))); }
+#line 3272 "grammar.c"
     break;
 
   case 173:
-#line 703 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = '&'; }
-#line 3165 "grammar.c" /* yacc.c:1646  */
+#line 719 "grammar.y"
+                                { (yyval.i) = '&'; }
+#line 3278 "grammar.c"
     break;
 
   case 174:
-#line 704 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = '|'; }
-#line 3171 "grammar.c" /* yacc.c:1646  */
+#line 720 "grammar.y"
+                                { (yyval.i) = '|'; }
+#line 3284 "grammar.c"
     break;
 
   case 175:
-#line 705 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = '<'; }
-#line 3177 "grammar.c" /* yacc.c:1646  */
+#line 721 "grammar.y"
+                                { (yyval.i) = '<'; }
+#line 3290 "grammar.c"
     break;
 
   case 176:
-#line 706 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = '>'; }
-#line 3183 "grammar.c" /* yacc.c:1646  */
+#line 722 "grammar.y"
+                                { (yyval.i) = '>'; }
+#line 3296 "grammar.c"
     break;
 
   case 177:
-#line 707 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = '='; }
-#line 3189 "grammar.c" /* yacc.c:1646  */
+#line 723 "grammar.y"
+                                { (yyval.i) = '='; }
+#line 3302 "grammar.c"
     break;
 
   case 179:
-#line 710 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = (yyvsp[-1].i); }
-#line 3195 "grammar.c" /* yacc.c:1646  */
+#line 726 "grammar.y"
+                                { (yyval.i) = (yyvsp[-1].i); }
+#line 3308 "grammar.c"
     break;
 
   case 180:
-#line 712 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_LANE; }
-#line 3201 "grammar.c" /* yacc.c:1646  */
+#line 728 "grammar.y"
+                                { (yyval.i) = A_LANE; }
+#line 3314 "grammar.c"
     break;
 
   case 181:
-#line 713 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_METAC;	}
-#line 3207 "grammar.c" /* yacc.c:1646  */
+#line 729 "grammar.y"
+                                { (yyval.i) = A_METAC;	}
+#line 3320 "grammar.c"
     break;
 
   case 182:
-#line 714 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_BCC; }
-#line 3213 "grammar.c" /* yacc.c:1646  */
+#line 730 "grammar.y"
+                                { (yyval.i) = A_BCC; }
+#line 3326 "grammar.c"
     break;
 
   case 183:
-#line 715 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_OAMF4EC; }
-#line 3219 "grammar.c" /* yacc.c:1646  */
+#line 731 "grammar.y"
+                                { (yyval.i) = A_OAMF4EC; }
+#line 3332 "grammar.c"
     break;
 
   case 184:
-#line 716 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_OAMF4SC; }
-#line 3225 "grammar.c" /* yacc.c:1646  */
+#line 732 "grammar.y"
+                                { (yyval.i) = A_OAMF4SC; }
+#line 3338 "grammar.c"
     break;
 
   case 185:
-#line 717 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_SC; }
-#line 3231 "grammar.c" /* yacc.c:1646  */
+#line 733 "grammar.y"
+                                { (yyval.i) = A_SC; }
+#line 3344 "grammar.c"
     break;
 
   case 186:
-#line 718 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_ILMIC; }
-#line 3237 "grammar.c" /* yacc.c:1646  */
+#line 734 "grammar.y"
+                                { (yyval.i) = A_ILMIC; }
+#line 3350 "grammar.c"
     break;
 
   case 187:
-#line 720 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_OAM; }
-#line 3243 "grammar.c" /* yacc.c:1646  */
+#line 736 "grammar.y"
+                                { (yyval.i) = A_OAM; }
+#line 3356 "grammar.c"
     break;
 
   case 188:
-#line 721 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_OAMF4; }
-#line 3249 "grammar.c" /* yacc.c:1646  */
+#line 737 "grammar.y"
+                                { (yyval.i) = A_OAMF4; }
+#line 3362 "grammar.c"
     break;
 
   case 189:
-#line 722 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_CONNECTMSG; }
-#line 3255 "grammar.c" /* yacc.c:1646  */
+#line 738 "grammar.y"
+                                { (yyval.i) = A_CONNECTMSG; }
+#line 3368 "grammar.c"
     break;
 
   case 190:
-#line 723 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = A_METACONNECT; }
-#line 3261 "grammar.c" /* yacc.c:1646  */
+#line 739 "grammar.y"
+                                { (yyval.i) = A_METACONNECT; }
+#line 3374 "grammar.c"
     break;
 
   case 191:
-#line 726 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).atmfieldtype = A_VPI; }
-#line 3267 "grammar.c" /* yacc.c:1646  */
+#line 742 "grammar.y"
+                                { (yyval.blk).atmfieldtype = A_VPI; }
+#line 3380 "grammar.c"
     break;
 
   case 192:
-#line 727 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).atmfieldtype = A_VCI; }
-#line 3273 "grammar.c" /* yacc.c:1646  */
+#line 743 "grammar.y"
+                                { (yyval.blk).atmfieldtype = A_VCI; }
+#line 3386 "grammar.c"
     break;
 
   case 194:
-#line 730 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (bpf_int32)(yyvsp[0].i), (bpf_u_int32)(yyvsp[-1].i), 0); }
-#line 3279 "grammar.c" /* yacc.c:1646  */
+#line 746 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (bpf_int32)(yyvsp[0].i), (bpf_u_int32)(yyvsp[-1].i), 0))); }
+#line 3392 "grammar.c"
     break;
 
   case 195:
-#line 731 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (bpf_int32)(yyvsp[0].i), (bpf_u_int32)(yyvsp[-1].i), 1); }
-#line 3285 "grammar.c" /* yacc.c:1646  */
+#line 747 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (bpf_int32)(yyvsp[0].i), (bpf_u_int32)(yyvsp[-1].i), 1))); }
+#line 3398 "grammar.c"
     break;
 
   case 196:
-#line 732 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; }
-#line 3291 "grammar.c" /* yacc.c:1646  */
+#line 748 "grammar.y"
+                                 { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; }
+#line 3404 "grammar.c"
     break;
 
   case 197:
-#line 734 "grammar.y" /* yacc.c:1646  */
-    {
+#line 750 "grammar.y"
+                   {
 	(yyval.blk).atmfieldtype = (yyvsp[-1].blk).atmfieldtype;
 	if ((yyval.blk).atmfieldtype == A_VPI ||
 	    (yyval.blk).atmfieldtype == A_VCI)
-		(yyval.blk).b = gen_atmfield_code(cstate, (yyval.blk).atmfieldtype, (bpf_int32) (yyvsp[0].i), BPF_JEQ, 0);
+		CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyval.blk).atmfieldtype, (bpf_int32) (yyvsp[0].i), BPF_JEQ, 0)));
 	}
-#line 3302 "grammar.c" /* yacc.c:1646  */
+#line 3415 "grammar.c"
     break;
 
   case 199:
-#line 742 "grammar.y" /* yacc.c:1646  */
-    { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 3308 "grammar.c" /* yacc.c:1646  */
+#line 758 "grammar.y"
+                                        { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 3421 "grammar.c"
     break;
 
   case 200:
-#line 745 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = M_FISU; }
-#line 3314 "grammar.c" /* yacc.c:1646  */
+#line 761 "grammar.y"
+                                { (yyval.i) = M_FISU; }
+#line 3427 "grammar.c"
     break;
 
   case 201:
-#line 746 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = M_LSSU; }
-#line 3320 "grammar.c" /* yacc.c:1646  */
+#line 762 "grammar.y"
+                                { (yyval.i) = M_LSSU; }
+#line 3433 "grammar.c"
     break;
 
   case 202:
-#line 747 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = M_MSU; }
-#line 3326 "grammar.c" /* yacc.c:1646  */
+#line 763 "grammar.y"
+                                { (yyval.i) = M_MSU; }
+#line 3439 "grammar.c"
     break;
 
   case 203:
-#line 748 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = MH_FISU; }
-#line 3332 "grammar.c" /* yacc.c:1646  */
+#line 764 "grammar.y"
+                                { (yyval.i) = MH_FISU; }
+#line 3445 "grammar.c"
     break;
 
   case 204:
-#line 749 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = MH_LSSU; }
-#line 3338 "grammar.c" /* yacc.c:1646  */
+#line 765 "grammar.y"
+                                { (yyval.i) = MH_LSSU; }
+#line 3451 "grammar.c"
     break;
 
   case 205:
-#line 750 "grammar.y" /* yacc.c:1646  */
-    { (yyval.i) = MH_MSU; }
-#line 3344 "grammar.c" /* yacc.c:1646  */
+#line 766 "grammar.y"
+                                { (yyval.i) = MH_MSU; }
+#line 3457 "grammar.c"
     break;
 
   case 206:
-#line 753 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = M_SIO; }
-#line 3350 "grammar.c" /* yacc.c:1646  */
+#line 769 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = M_SIO; }
+#line 3463 "grammar.c"
     break;
 
   case 207:
-#line 754 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = M_OPC; }
-#line 3356 "grammar.c" /* yacc.c:1646  */
+#line 770 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = M_OPC; }
+#line 3469 "grammar.c"
     break;
 
   case 208:
-#line 755 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = M_DPC; }
-#line 3362 "grammar.c" /* yacc.c:1646  */
+#line 771 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = M_DPC; }
+#line 3475 "grammar.c"
     break;
 
   case 209:
-#line 756 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = M_SLS; }
-#line 3368 "grammar.c" /* yacc.c:1646  */
+#line 772 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = M_SLS; }
+#line 3481 "grammar.c"
     break;
 
   case 210:
-#line 757 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = MH_SIO; }
-#line 3374 "grammar.c" /* yacc.c:1646  */
+#line 773 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = MH_SIO; }
+#line 3487 "grammar.c"
     break;
 
   case 211:
-#line 758 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = MH_OPC; }
-#line 3380 "grammar.c" /* yacc.c:1646  */
+#line 774 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = MH_OPC; }
+#line 3493 "grammar.c"
     break;
 
   case 212:
-#line 759 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = MH_DPC; }
-#line 3386 "grammar.c" /* yacc.c:1646  */
+#line 775 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = MH_DPC; }
+#line 3499 "grammar.c"
     break;
 
   case 213:
-#line 760 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).mtp3fieldtype = MH_SLS; }
-#line 3392 "grammar.c" /* yacc.c:1646  */
+#line 776 "grammar.y"
+                                { (yyval.blk).mtp3fieldtype = MH_SLS; }
+#line 3505 "grammar.c"
     break;
 
   case 215:
-#line 763 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (u_int)(yyvsp[0].i), (u_int)(yyvsp[-1].i), 0); }
-#line 3398 "grammar.c" /* yacc.c:1646  */
+#line 779 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (u_int)(yyvsp[0].i), (u_int)(yyvsp[-1].i), 0))); }
+#line 3511 "grammar.c"
     break;
 
   case 216:
-#line 764 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (u_int)(yyvsp[0].i), (u_int)(yyvsp[-1].i), 1); }
-#line 3404 "grammar.c" /* yacc.c:1646  */
+#line 780 "grammar.y"
+                                { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (u_int)(yyvsp[0].i), (u_int)(yyvsp[-1].i), 1))); }
+#line 3517 "grammar.c"
     break;
 
   case 217:
-#line 765 "grammar.y" /* yacc.c:1646  */
-    { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; }
-#line 3410 "grammar.c" /* yacc.c:1646  */
+#line 781 "grammar.y"
+                                  { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; }
+#line 3523 "grammar.c"
     break;
 
   case 218:
-#line 767 "grammar.y" /* yacc.c:1646  */
-    {
+#line 783 "grammar.y"
+                    {
 	(yyval.blk).mtp3fieldtype = (yyvsp[-1].blk).mtp3fieldtype;
 	if ((yyval.blk).mtp3fieldtype == M_SIO ||
 	    (yyval.blk).mtp3fieldtype == M_OPC ||
@@ -3421,19 +3534,20 @@
 	    (yyval.blk).mtp3fieldtype == MH_OPC ||
 	    (yyval.blk).mtp3fieldtype == MH_DPC ||
 	    (yyval.blk).mtp3fieldtype == MH_SLS)
-		(yyval.blk).b = gen_mtp3field_code(cstate, (yyval.blk).mtp3fieldtype, (u_int) (yyvsp[0].i), BPF_JEQ, 0);
+		CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyval.blk).mtp3fieldtype, (u_int) (yyvsp[0].i), BPF_JEQ, 0)));
 	}
-#line 3427 "grammar.c" /* yacc.c:1646  */
+#line 3540 "grammar.c"
     break;
 
   case 220:
-#line 781 "grammar.y" /* yacc.c:1646  */
-    { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
-#line 3433 "grammar.c" /* yacc.c:1646  */
+#line 797 "grammar.y"
+                                          { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); }
+#line 3546 "grammar.c"
     break;
 
 
-#line 3437 "grammar.c" /* yacc.c:1646  */
+#line 3550 "grammar.c"
+
       default: break;
     }
   /* User semantic actions sometimes alter yychar, and that requires
@@ -3458,14 +3572,13 @@
   /* Now 'shift' the result of the reduction.  Determine what state
      that goes to, based on the state we popped back to and the rule
      number reduced by.  */
-
-  yyn = yyr1[yyn];
-
-  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
-  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
-    yystate = yytable[yystate];
-  else
-    yystate = yydefgoto[yyn - YYNTOKENS];
+  {
+    const int yylhs = yyr1[yyn] - YYNTOKENS;
+    const int yyi = yypgoto[yylhs] + *yyssp;
+    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+               ? yytable[yyi]
+               : yydefgoto[yylhs]);
+  }
 
   goto yynewstate;
 
@@ -3497,7 +3610,7 @@
           {
             if (yymsg != yymsgbuf)
               YYSTACK_FREE (yymsg);
-            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+            yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
             if (!yymsg)
               {
                 yymsg = yymsgbuf;
@@ -3548,12 +3661,10 @@
 | yyerrorlab -- error raised explicitly by YYERROR.  |
 `---------------------------------------------------*/
 yyerrorlab:
-
-  /* Pacify compilers like GCC when the user code never invokes
-     YYERROR and the label yyerrorlab therefore never appears in user
-     code.  */
-  if (/*CONSTCOND*/ 0)
-     goto yyerrorlab;
+  /* Pacify compilers when the user code never invokes YYERROR and the
+     label yyerrorlab therefore never appears in user code.  */
+  if (0)
+    YYERROR;
 
   /* Do not reclaim the symbols of the rule whose action triggered
      this YYERROR.  */
@@ -3615,6 +3726,7 @@
   yyresult = 0;
   goto yyreturn;
 
+
 /*-----------------------------------.
 | yyabortlab -- YYABORT comes here.  |
 `-----------------------------------*/
@@ -3622,6 +3734,7 @@
   yyresult = 1;
   goto yyreturn;
 
+
 #if !defined yyoverflow || YYERROR_VERBOSE
 /*-------------------------------------------------.
 | yyexhaustedlab -- memory exhaustion comes here.  |
@@ -3632,6 +3745,10 @@
   /* Fall through.  */
 #endif
 
+
+/*-----------------------------------------------------.
+| yyreturn -- parsing is finished, return the result.  |
+`-----------------------------------------------------*/
 yyreturn:
   if (yychar != YYEMPTY)
     {
@@ -3648,7 +3765,7 @@
   while (yyssp != yyss)
     {
       yydestruct ("Cleanup: popping",
-                  yystos[*yyssp], yyvsp, yyscanner, cstate);
+                  yystos[+*yyssp], yyvsp, yyscanner, cstate);
       YYPOPSTACK (1);
     }
 #ifndef yyoverflow
@@ -3661,5 +3778,5 @@
 #endif
   return yyresult;
 }
-#line 783 "grammar.y" /* yacc.c:1906  */
+#line 799 "grammar.y"
 
diff --git a/grammar.h b/grammar.h
index 286cc79..b4cfd19 100644
--- a/grammar.h
+++ b/grammar.h
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4.  */
+/* A Bison parser, made by GNU Bison 3.5.1.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
+   Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,6 +31,9 @@
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 
+/* Undocumented macros, especially those whose name start with YY_,
+   are private implementation details.  Do not rely on them.  */
+
 #ifndef YY_PCAP_GRAMMAR_H_INCLUDED
 # define YY_PCAP_GRAMMAR_H_INCLUDED
 /* Debug traces.  */
@@ -161,9 +165,10 @@
     HOPC = 371,
     HDPC = 372,
     HSLS = 373,
-    OR = 374,
-    AND = 375,
-    UMINUS = 376
+    LEX_ERROR = 374,
+    OR = 375,
+    AND = 376,
+    UMINUS = 377
   };
 #endif
 /* Tokens.  */
@@ -283,20 +288,19 @@
 #define HOPC 371
 #define HDPC 372
 #define HSLS 373
-#define OR 374
-#define AND 375
-#define UMINUS 376
+#define LEX_ERROR 374
+#define OR 375
+#define AND 376
+#define UMINUS 377
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
 union YYSTYPE
 {
-#line 286 "grammar.y" /* yacc.c:1909  */
+#line 291 "grammar.y"
 
 	int i;
 	bpf_u_int32 h;
-	u_char *e;
 	char *s;
 	struct stmt *stmt;
 	struct arth *a;
@@ -308,9 +312,9 @@
 	} blk;
 	struct block *rblk;
 
-#line 312 "grammar.h" /* yacc.c:1909  */
-};
+#line 316 "grammar.h"
 
+};
 typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
diff --git a/grammar.y b/grammar.y
index be80e2b..32cb19c 100644
--- a/grammar.y
+++ b/grammar.y
@@ -216,13 +216,12 @@
 	return (-1);
 }
 
-static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
+static const struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
 
-static PCAP_NORETURN_DEF void
+static void
 yyerror(void *yyscanner _U_, compiler_state_t *cstate, const char *msg)
 {
-	bpf_syntax_error(cstate, msg);
-	/* NOTREACHED */
+	bpf_set_error(cstate, "can't parse filter expression: %s", msg);
 }
 
 #ifdef HAVE_NET_PFVAR_H
@@ -236,8 +235,8 @@
 		if (pcap_strcasecmp(reason, reasons[i]) == 0)
 			return (i);
 	}
-	bpf_error(cstate, "unknown PF reason");
-	/*NOTREACHED*/
+	bpf_set_error(cstate, "unknown PF reason");
+	return (-1);
 }
 
 static int
@@ -260,33 +259,38 @@
 		return (PF_NORDR);
 #endif
 	else {
-		bpf_error(cstate, "unknown PF action");
-		/*NOTREACHED*/
+		bpf_set_error(cstate, "unknown PF action");
+		return (-1);
 	}
 }
 #else /* !HAVE_NET_PFVAR_H */
-static PCAP_NORETURN_DEF int
+static int
 pfreason_to_num(compiler_state_t *cstate, const char *reason _U_)
 {
-	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/*NOTREACHED*/
+	bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
+	return (-1);
 }
 
-static PCAP_NORETURN_DEF int
+static int
 pfaction_to_num(compiler_state_t *cstate, const char *action _U_)
 {
-	bpf_error(cstate, "libpcap was compiled on a machine without pf support");
-	/*NOTREACHED*/
+	bpf_set_error(cstate, "libpcap was compiled on a machine without pf support");
+	return (-1);
 }
 #endif /* HAVE_NET_PFVAR_H */
 
+/*
+ * For calls that might return an "an error occurred" value.
+ */
+#define CHECK_INT_VAL(val)	if (val == -1) YYABORT
+#define CHECK_PTR_VAL(val)	if (val == NULL) YYABORT
+
 DIAG_OFF_BISON_BYACC
 %}
 
 %union {
 	int i;
 	bpf_u_int32 h;
-	u_char *e;
 	char *s;
 	struct stmt *stmt;
 	struct arth *a;
@@ -340,11 +344,9 @@
 %token	RADIO
 %token	FISU LSSU MSU HFISU HLSSU HMSU
 %token	SIO OPC DPC SLS HSIO HOPC HDPC HSLS
+%token	LEX_ERROR
 
-
-%type	<s> ID
-%type	<e> EID
-%type	<e> AID
+%type	<s> ID EID AID
 %type	<s> HID HID6
 %type	<i> NUM action reason type subtype type_subtype dir
 
@@ -359,7 +361,7 @@
 %%
 prog:	  null expr
 {
-	finish_parse(cstate, $2.b);
+	CHECK_INT_VAL(finish_parse(cstate, $2.b));
 }
 	| null
 	;
@@ -376,64 +378,58 @@
 or:	  OR			{ $$ = $<blk>0; }
 	;
 id:	  nid
-	| pnum			{ $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
-						   $$.q = $<blk>0.q); }
+	| pnum			{ CHECK_PTR_VAL(($$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
+						   $$.q = $<blk>0.q))); }
 	| paren pid ')'		{ $$ = $2; }
 	;
-nid:	  ID			{ $$.b = gen_scode(cstate, $1, $$.q = $<blk>0.q); }
-	| HID '/' NUM		{ $$.b = gen_mcode(cstate, $1, NULL, $3,
-				    $$.q = $<blk>0.q); }
-	| HID NETMASK HID	{ $$.b = gen_mcode(cstate, $1, $3, 0,
-				    $$.q = $<blk>0.q); }
+nid:	  ID			{ CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$.q = $<blk>0.q))); }
+	| HID '/' NUM		{ CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_mcode(cstate, $1, NULL, $3,
+				    $$.q = $<blk>0.q))); }
+	| HID NETMASK HID	{ CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_mcode(cstate, $1, $3, 0,
+				    $$.q = $<blk>0.q))); }
 	| HID			{
+				  CHECK_PTR_VAL($1);
 				  /* Decide how to parse HID based on proto */
 				  $$.q = $<blk>0.q;
-				  if ($$.q.addr == Q_PORT)
-				  	bpf_error(cstate, "'port' modifier applied to ip host");
-				  else if ($$.q.addr == Q_PORTRANGE)
-				  	bpf_error(cstate, "'portrange' modifier applied to ip host");
-				  else if ($$.q.addr == Q_PROTO)
-				  	bpf_error(cstate, "'proto' modifier applied to ip host");
-				  else if ($$.q.addr == Q_PROTOCHAIN)
-				  	bpf_error(cstate, "'protochain' modifier applied to ip host");
-				  $$.b = gen_ncode(cstate, $1, 0, $$.q);
+				  if ($$.q.addr == Q_PORT) {
+				  	bpf_set_error(cstate, "'port' modifier applied to ip host");
+				  	YYABORT;
+				  } else if ($$.q.addr == Q_PORTRANGE) {
+				  	bpf_set_error(cstate, "'portrange' modifier applied to ip host");
+				  	YYABORT;
+				  } else if ($$.q.addr == Q_PROTO) {
+				  	bpf_set_error(cstate, "'proto' modifier applied to ip host");
+				  	YYABORT;
+				  } else if ($$.q.addr == Q_PROTOCHAIN) {
+				  	bpf_set_error(cstate, "'protochain' modifier applied to ip host");
+				  	YYABORT;
+				  }
+				  CHECK_PTR_VAL(($$.b = gen_ncode(cstate, $1, 0, $$.q)));
 				}
 	| HID6 '/' NUM		{
+				  CHECK_PTR_VAL($1);
 #ifdef INET6
-				  $$.b = gen_mcode6(cstate, $1, NULL, $3,
-				    $$.q = $<blk>0.q);
+				  CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, NULL, $3,
+				    $$.q = $<blk>0.q)));
 #else
-				  bpf_error(cstate, "'ip6addr/prefixlen' not supported "
+				  bpf_set_error(cstate, "'ip6addr/prefixlen' not supported "
 					"in this configuration");
+				  YYABORT;
 #endif /*INET6*/
 				}
 	| HID6			{
+				  CHECK_PTR_VAL($1);
 #ifdef INET6
-				  $$.b = gen_mcode6(cstate, $1, 0, 128,
-				    $$.q = $<blk>0.q);
+				  CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, 0, 128,
+				    $$.q = $<blk>0.q)));
 #else
-				  bpf_error(cstate, "'ip6addr' not supported "
+				  bpf_set_error(cstate, "'ip6addr' not supported "
 					"in this configuration");
+				  YYABORT;
 #endif /*INET6*/
 				}
-	| EID			{
-				  $$.b = gen_ecode(cstate, $1, $$.q = $<blk>0.q);
-				  /*
-				   * $1 was allocated by "pcap_ether_aton()",
-				   * so we must free it now that we're done
-				   * with it.
-				   */
-				  free($1);
-				}
-	| AID			{
-				  $$.b = gen_acode(cstate, $1, $$.q = $<blk>0.q);
-				  /*
-				   * $1 was allocated by "pcap_ether_aton()",
-				   * so we must free it now that we're done
-				   * with it.
-				   */
-				  free($1);
-				}
+	| EID			{ CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_ecode(cstate, $1, $$.q = $<blk>0.q))); }
+	| AID			{ CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_acode(cstate, $1, $$.q = $<blk>0.q))); }
 	| not id		{ gen_not($2.b); $$ = $2; }
 	;
 not:	  '!'			{ $$ = $<blk>0; }
@@ -444,8 +440,8 @@
 	| qid and id		{ gen_and($1.b, $3.b); $$ = $3; }
 	| qid or id		{ gen_or($1.b, $3.b); $$ = $3; }
 	;
-qid:	  pnum			{ $$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
-						   $$.q = $<blk>0.q); }
+qid:	  pnum			{ CHECK_PTR_VAL(($$.b = gen_ncode(cstate, NULL, (bpf_u_int32)$1,
+						   $$.q = $<blk>0.q))); }
 	| pid
 	;
 term:	  rterm
@@ -455,21 +451,28 @@
 	| pqual dqual		{ QSET($$.q, $1, $2, Q_DEFAULT); }
 	| pqual aqual		{ QSET($$.q, $1, Q_DEFAULT, $2); }
 	| pqual PROTO		{ QSET($$.q, $1, Q_DEFAULT, Q_PROTO); }
-	| pqual PROTOCHAIN	{ QSET($$.q, $1, Q_DEFAULT, Q_PROTOCHAIN); }
+	| pqual PROTOCHAIN	{
+#ifdef NO_PROTOCHAIN
+				  bpf_set_error(cstate, "protochain not supported");
+				  YYABORT;
+#else
+				  QSET($$.q, $1, Q_DEFAULT, Q_PROTOCHAIN);
+#endif
+				}
 	| pqual ndaqual		{ QSET($$.q, $1, Q_DEFAULT, $2); }
 	;
 rterm:	  head id		{ $$ = $2; }
 	| paren expr ')'	{ $$.b = $2.b; $$.q = $1.q; }
-	| pname			{ $$.b = gen_proto_abbrev(cstate, $1); $$.q = qerr; }
-	| arth relop arth	{ $$.b = gen_relation(cstate, $2, $1, $3, 0);
+	| pname			{ CHECK_PTR_VAL(($$.b = gen_proto_abbrev(cstate, $1))); $$.q = qerr; }
+	| arth relop arth	{ CHECK_PTR_VAL(($$.b = gen_relation(cstate, $2, $1, $3, 0)));
 				  $$.q = qerr; }
-	| arth irelop arth	{ $$.b = gen_relation(cstate, $2, $1, $3, 1);
+	| arth irelop arth	{ CHECK_PTR_VAL(($$.b = gen_relation(cstate, $2, $1, $3, 1)));
 				  $$.q = qerr; }
 	| other			{ $$.b = $1; $$.q = qerr; }
-	| atmtype		{ $$.b = gen_atmtype_abbrev(cstate, $1); $$.q = qerr; }
-	| atmmultitype		{ $$.b = gen_atmmulti_abbrev(cstate, $1); $$.q = qerr; }
+	| atmtype		{ CHECK_PTR_VAL(($$.b = gen_atmtype_abbrev(cstate, $1))); $$.q = qerr; }
+	| atmmultitype		{ CHECK_PTR_VAL(($$.b = gen_atmmulti_abbrev(cstate, $1))); $$.q = qerr; }
 	| atmfield atmvalue	{ $$.b = $2.b; $$.q = qerr; }
-	| mtp2type		{ $$.b = gen_mtp2type_abbrev(cstate, $1); $$.q = qerr; }
+	| mtp2type		{ CHECK_PTR_VAL(($$.b = gen_mtp2type_abbrev(cstate, $1))); $$.q = qerr; }
 	| mtp3field mtp3value	{ $$.b = $2.b; $$.q = qerr; }
 	;
 /* protocol level qualifiers */
@@ -539,65 +542,69 @@
 	| NETBEUI		{ $$ = Q_NETBEUI; }
 	| RADIO			{ $$ = Q_RADIO; }
 	;
-other:	  pqual TK_BROADCAST	{ $$ = gen_broadcast(cstate, $1); }
-	| pqual TK_MULTICAST	{ $$ = gen_multicast(cstate, $1); }
-	| LESS NUM		{ $$ = gen_less(cstate, $2); }
-	| GREATER NUM		{ $$ = gen_greater(cstate, $2); }
-	| CBYTE NUM byteop NUM	{ $$ = gen_byteop(cstate, $3, $2, $4); }
-	| INBOUND		{ $$ = gen_inbound(cstate, 0); }
-	| OUTBOUND		{ $$ = gen_inbound(cstate, 1); }
-	| VLAN pnum		{ $$ = gen_vlan(cstate, $2); }
-	| VLAN			{ $$ = gen_vlan(cstate, -1); }
-	| MPLS pnum		{ $$ = gen_mpls(cstate, $2); }
-	| MPLS			{ $$ = gen_mpls(cstate, -1); }
-	| PPPOED		{ $$ = gen_pppoed(cstate); }
-	| PPPOES pnum		{ $$ = gen_pppoes(cstate, $2); }
-	| PPPOES		{ $$ = gen_pppoes(cstate, -1); }
-	| GENEVE pnum		{ $$ = gen_geneve(cstate, $2); }
-	| GENEVE		{ $$ = gen_geneve(cstate, -1); }
+other:	  pqual TK_BROADCAST	{ CHECK_PTR_VAL(($$ = gen_broadcast(cstate, $1))); }
+	| pqual TK_MULTICAST	{ CHECK_PTR_VAL(($$ = gen_multicast(cstate, $1))); }
+	| LESS NUM		{ CHECK_PTR_VAL(($$ = gen_less(cstate, $2))); }
+	| GREATER NUM		{ CHECK_PTR_VAL(($$ = gen_greater(cstate, $2))); }
+	| CBYTE NUM byteop NUM	{ CHECK_PTR_VAL(($$ = gen_byteop(cstate, $3, $2, $4))); }
+	| INBOUND		{ CHECK_PTR_VAL(($$ = gen_inbound(cstate, 0))); }
+	| OUTBOUND		{ CHECK_PTR_VAL(($$ = gen_inbound(cstate, 1))); }
+	| VLAN pnum		{ CHECK_PTR_VAL(($$ = gen_vlan(cstate, (bpf_u_int32)$2, 1))); }
+	| VLAN			{ CHECK_PTR_VAL(($$ = gen_vlan(cstate, 0, 0))); }
+	| MPLS pnum		{ CHECK_PTR_VAL(($$ = gen_mpls(cstate, (bpf_u_int32)$2, 1))); }
+	| MPLS			{ CHECK_PTR_VAL(($$ = gen_mpls(cstate, 0, 0))); }
+	| PPPOED		{ CHECK_PTR_VAL(($$ = gen_pppoed(cstate))); }
+	| PPPOES pnum		{ CHECK_PTR_VAL(($$ = gen_pppoes(cstate, (bpf_u_int32)$2, 1))); }
+	| PPPOES		{ CHECK_PTR_VAL(($$ = gen_pppoes(cstate, 0, 0))); }
+	| GENEVE pnum		{ CHECK_PTR_VAL(($$ = gen_geneve(cstate, (bpf_u_int32)$2, 1))); }
+	| GENEVE		{ CHECK_PTR_VAL(($$ = gen_geneve(cstate, 0, 0))); }
 	| pfvar			{ $$ = $1; }
 	| pqual p80211		{ $$ = $2; }
 	| pllc			{ $$ = $1; }
 	;
 
-pfvar:	  PF_IFNAME ID		{ $$ = gen_pf_ifname(cstate, $2); }
-	| PF_RSET ID		{ $$ = gen_pf_ruleset(cstate, $2); }
-	| PF_RNR NUM		{ $$ = gen_pf_rnr(cstate, $2); }
-	| PF_SRNR NUM		{ $$ = gen_pf_srnr(cstate, $2); }
-	| PF_REASON reason	{ $$ = gen_pf_reason(cstate, $2); }
-	| PF_ACTION action	{ $$ = gen_pf_action(cstate, $2); }
+pfvar:	  PF_IFNAME ID		{ CHECK_PTR_VAL($2); CHECK_PTR_VAL(($$ = gen_pf_ifname(cstate, $2))); }
+	| PF_RSET ID		{ CHECK_PTR_VAL($2); CHECK_PTR_VAL(($$ = gen_pf_ruleset(cstate, $2))); }
+	| PF_RNR NUM		{ CHECK_PTR_VAL(($$ = gen_pf_rnr(cstate, $2))); }
+	| PF_SRNR NUM		{ CHECK_PTR_VAL(($$ = gen_pf_srnr(cstate, $2))); }
+	| PF_REASON reason	{ CHECK_PTR_VAL(($$ = gen_pf_reason(cstate, $2))); }
+	| PF_ACTION action	{ CHECK_PTR_VAL(($$ = gen_pf_action(cstate, $2))); }
 	;
 
 p80211:   TYPE type SUBTYPE subtype
-				{ $$ = gen_p80211_type(cstate, $2 | $4,
+				{ CHECK_PTR_VAL(($$ = gen_p80211_type(cstate, $2 | $4,
 					IEEE80211_FC0_TYPE_MASK |
-					IEEE80211_FC0_SUBTYPE_MASK);
+					IEEE80211_FC0_SUBTYPE_MASK)));
 				}
-	| TYPE type		{ $$ = gen_p80211_type(cstate, $2,
-					IEEE80211_FC0_TYPE_MASK);
+	| TYPE type		{ CHECK_PTR_VAL(($$ = gen_p80211_type(cstate, $2,
+					IEEE80211_FC0_TYPE_MASK)));
 				}
-	| SUBTYPE type_subtype	{ $$ = gen_p80211_type(cstate, $2,
+	| SUBTYPE type_subtype	{ CHECK_PTR_VAL(($$ = gen_p80211_type(cstate, $2,
 					IEEE80211_FC0_TYPE_MASK |
-					IEEE80211_FC0_SUBTYPE_MASK);
+					IEEE80211_FC0_SUBTYPE_MASK)));
 				}
-	| DIR dir		{ $$ = gen_p80211_fcdir(cstate, $2); }
+	| DIR dir		{ CHECK_PTR_VAL(($$ = gen_p80211_fcdir(cstate, $2))); }
 	;
 
 type:	  NUM
-	| ID			{ $$ = str2tok($1, ieee80211_types);
-				  if ($$ == -1)
-				  	bpf_error(cstate, "unknown 802.11 type name");
+	| ID			{ CHECK_PTR_VAL($1);
+				  $$ = str2tok($1, ieee80211_types);
+				  if ($$ == -1) {
+				  	bpf_set_error(cstate, "unknown 802.11 type name");
+				  	YYABORT;
+				  }
 				}
 	;
 
 subtype:  NUM
 	| ID			{ const struct tok *types = NULL;
 				  int i;
+				  CHECK_PTR_VAL($1);
 				  for (i = 0;; i++) {
 				  	if (ieee80211_type_subtypes[i].tok == NULL) {
 				  		/* Ran out of types */
-						bpf_error(cstate, "unknown 802.11 type");
-						break;
+						bpf_set_error(cstate, "unknown 802.11 type");
+						YYABORT;
 					}
 					if ($<i>-1 == ieee80211_type_subtypes[i].type) {
 						types = ieee80211_type_subtypes[i].tok;
@@ -606,17 +613,20 @@
 				  }
 
 				  $$ = str2tok($1, types);
-				  if ($$ == -1)
-					bpf_error(cstate, "unknown 802.11 subtype name");
+				  if ($$ == -1) {
+					bpf_set_error(cstate, "unknown 802.11 subtype name");
+					YYABORT;
+				  }
 				}
 	;
 
 type_subtype:	ID		{ int i;
+				  CHECK_PTR_VAL($1);
 				  for (i = 0;; i++) {
 				  	if (ieee80211_type_subtypes[i].tok == NULL) {
 				  		/* Ran out of types */
-						bpf_error(cstate, "unknown 802.11 type name");
-						break;
+						bpf_set_error(cstate, "unknown 802.11 type name");
+						YYABORT;
 					}
 					$$ = str2tok($1, ieee80211_type_subtypes[i].tok);
 					if ($$ != -1) {
@@ -627,33 +637,37 @@
 				}
 		;
 
-pllc:	LLC			{ $$ = gen_llc(cstate); }
-	| LLC ID		{ if (pcap_strcasecmp($2, "i") == 0)
-					$$ = gen_llc_i(cstate);
-				  else if (pcap_strcasecmp($2, "s") == 0)
-					$$ = gen_llc_s(cstate);
-				  else if (pcap_strcasecmp($2, "u") == 0)
-					$$ = gen_llc_u(cstate);
-				  else {
+pllc:	LLC			{ CHECK_PTR_VAL(($$ = gen_llc(cstate))); }
+	| LLC ID		{ CHECK_PTR_VAL($2);
+				  if (pcap_strcasecmp($2, "i") == 0) {
+					CHECK_PTR_VAL(($$ = gen_llc_i(cstate)));
+				  } else if (pcap_strcasecmp($2, "s") == 0) {
+					CHECK_PTR_VAL(($$ = gen_llc_s(cstate)));
+				  } else if (pcap_strcasecmp($2, "u") == 0) {
+					CHECK_PTR_VAL(($$ = gen_llc_u(cstate)));
+				  } else {
 					int subtype;
 
 					subtype = str2tok($2, llc_s_subtypes);
-					if (subtype != -1)
-						$$ = gen_llc_s_subtype(cstate, subtype);
-					else {
+					if (subtype != -1) {
+						CHECK_PTR_VAL(($$ = gen_llc_s_subtype(cstate, subtype)));
+					} else {
 						subtype = str2tok($2, llc_u_subtypes);
-						if (subtype == -1)
-					  		bpf_error(cstate, "unknown LLC type name \"%s\"", $2);
-						$$ = gen_llc_u_subtype(cstate, subtype);
+						if (subtype == -1) {
+					  		bpf_set_error(cstate, "unknown LLC type name \"%s\"", $2);
+					  		YYABORT;
+					  	}
+						CHECK_PTR_VAL(($$ = gen_llc_u_subtype(cstate, subtype)));
 					}
 				  }
 				}
 				/* sigh, "rnr" is already a keyword for PF */
-	| LLC PF_RNR		{ $$ = gen_llc_s_subtype(cstate, LLC_RNR); }
+	| LLC PF_RNR		{ CHECK_PTR_VAL(($$ = gen_llc_s_subtype(cstate, LLC_RNR))); }
 	;
 
 dir:	  NUM
-	| ID			{ if (pcap_strcasecmp($1, "nods") == 0)
+	| ID			{ CHECK_PTR_VAL($1);
+				  if (pcap_strcasecmp($1, "nods") == 0)
 					$$ = IEEE80211_FC1_DIR_NODS;
 				  else if (pcap_strcasecmp($1, "tods") == 0)
 					$$ = IEEE80211_FC1_DIR_TODS;
@@ -661,16 +675,18 @@
 					$$ = IEEE80211_FC1_DIR_FROMDS;
 				  else if (pcap_strcasecmp($1, "dstods") == 0)
 					$$ = IEEE80211_FC1_DIR_DSTODS;
-				  else
-					bpf_error(cstate, "unknown 802.11 direction");
+				  else {
+					bpf_set_error(cstate, "unknown 802.11 direction");
+					YYABORT;
+				  }
 				}
 	;
 
 reason:	  NUM			{ $$ = $1; }
-	| ID			{ $$ = pfreason_to_num(cstate, $1); }
+	| ID			{ CHECK_PTR_VAL($1); CHECK_INT_VAL(($$ = pfreason_to_num(cstate, $1))); }
 	;
 
-action:	  ID			{ $$ = pfaction_to_num(cstate, $1); }
+action:	  ID			{ CHECK_PTR_VAL($1); CHECK_INT_VAL(($$ = pfaction_to_num(cstate, $1))); }
 	;
 
 relop:	  '>'			{ $$ = BPF_JGT; }
@@ -681,24 +697,24 @@
 	| '<'			{ $$ = BPF_JGE; }
 	| NEQ			{ $$ = BPF_JEQ; }
 	;
-arth:	  pnum			{ $$ = gen_loadi(cstate, $1); }
+arth:	  pnum			{ CHECK_PTR_VAL(($$ = gen_loadi(cstate, $1))); }
 	| narth
 	;
-narth:	  pname '[' arth ']'		{ $$ = gen_load(cstate, $1, $3, 1); }
-	| pname '[' arth ':' NUM ']'	{ $$ = gen_load(cstate, $1, $3, $5); }
-	| arth '+' arth			{ $$ = gen_arth(cstate, BPF_ADD, $1, $3); }
-	| arth '-' arth			{ $$ = gen_arth(cstate, BPF_SUB, $1, $3); }
-	| arth '*' arth			{ $$ = gen_arth(cstate, BPF_MUL, $1, $3); }
-	| arth '/' arth			{ $$ = gen_arth(cstate, BPF_DIV, $1, $3); }
-	| arth '%' arth			{ $$ = gen_arth(cstate, BPF_MOD, $1, $3); }
-	| arth '&' arth			{ $$ = gen_arth(cstate, BPF_AND, $1, $3); }
-	| arth '|' arth			{ $$ = gen_arth(cstate, BPF_OR, $1, $3); }
-	| arth '^' arth			{ $$ = gen_arth(cstate, BPF_XOR, $1, $3); }
-	| arth LSH arth			{ $$ = gen_arth(cstate, BPF_LSH, $1, $3); }
-	| arth RSH arth			{ $$ = gen_arth(cstate, BPF_RSH, $1, $3); }
-	| '-' arth %prec UMINUS		{ $$ = gen_neg(cstate, $2); }
+narth:	  pname '[' arth ']'		{ CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, 1))); }
+	| pname '[' arth ':' NUM ']'	{ CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, $5))); }
+	| arth '+' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_ADD, $1, $3))); }
+	| arth '-' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_SUB, $1, $3))); }
+	| arth '*' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_MUL, $1, $3))); }
+	| arth '/' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_DIV, $1, $3))); }
+	| arth '%' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_MOD, $1, $3))); }
+	| arth '&' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_AND, $1, $3))); }
+	| arth '|' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_OR, $1, $3))); }
+	| arth '^' arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_XOR, $1, $3))); }
+	| arth LSH arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_LSH, $1, $3))); }
+	| arth RSH arth			{ CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_RSH, $1, $3))); }
+	| '-' arth %prec UMINUS		{ CHECK_PTR_VAL(($$ = gen_neg(cstate, $2))); }
 	| paren narth ')'		{ $$ = $2; }
-	| LEN				{ $$ = gen_loadlen(cstate); }
+	| LEN				{ CHECK_PTR_VAL(($$ = gen_loadlen(cstate))); }
 	;
 byteop:	  '&'			{ $$ = '&'; }
 	| '|'			{ $$ = '|'; }
@@ -727,15 +743,15 @@
 	| VCI			{ $$.atmfieldtype = A_VCI; }
 	;
 atmvalue: atmfieldvalue
-	| relop NUM		{ $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
-	| irelop NUM		{ $$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1); }
+	| relop NUM		{ CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0))); }
+	| irelop NUM		{ CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 1))); }
 	| paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
 	;
 atmfieldvalue: NUM {
 	$$.atmfieldtype = $<blk>0.atmfieldtype;
 	if ($$.atmfieldtype == A_VPI ||
 	    $$.atmfieldtype == A_VCI)
-		$$.b = gen_atmfield_code(cstate, $$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
+		CHECK_PTR_VAL(($$.b = gen_atmfield_code(cstate, $$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0)));
 	}
 	;
 atmlistvalue: atmfieldvalue
@@ -760,8 +776,8 @@
 	| HSLS                  { $$.mtp3fieldtype = MH_SLS; }
 	;
 mtp3value: mtp3fieldvalue
-	| relop NUM		{ $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
-	| irelop NUM		{ $$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
+	| relop NUM		{ CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0))); }
+	| irelop NUM		{ CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1))); }
 	| paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
 	;
 mtp3fieldvalue: NUM {
@@ -774,7 +790,7 @@
 	    $$.mtp3fieldtype == MH_OPC ||
 	    $$.mtp3fieldtype == MH_DPC ||
 	    $$.mtp3fieldtype == MH_SLS)
-		$$.b = gen_mtp3field_code(cstate, $$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
+		CHECK_PTR_VAL(($$.b = gen_mtp3field_code(cstate, $$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0)));
 	}
 	;
 mtp3listvalue: mtp3fieldvalue
diff --git a/libpcap.pc b/libpcap.pc
new file mode 100755
index 0000000..e78cc99
--- /dev/null
+++ b/libpcap.pc
@@ -0,0 +1,18 @@
+#
+# pkg-config file for libpcap.
+#
+# These variables come from the configure script, so includedir and
+# libdir may be defined in terms of prefix and exec_prefix, so the
+# latter must be defined as well.
+#
+prefix="/usr/local"
+exec_prefix="${prefix}"
+includedir="${prefix}/include"
+libdir="${exec_prefix}/lib"
+
+Name: libpcap
+Description: Platform-independent network traffic capture library
+Version: 1.9.1
+Libs: -L${libdir} -lpcap
+Libs.private: 
+Cflags: -I${includedir}
diff --git a/libpcap.so.1.9.1 b/libpcap.so.1.9.1
new file mode 100755
index 0000000..c80ec87
--- /dev/null
+++ b/libpcap.so.1.9.1
Binary files differ
diff --git a/missing/asprintf.c b/missing/asprintf.c
new file mode 100644
index 0000000..3aa55ed
--- /dev/null
+++ b/missing/asprintf.c
@@ -0,0 +1,101 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "portability.h"
+
+/*
+ * vasprintf() and asprintf() for platforms with a C99-compliant
+ * snprintf() - so that, if you format into a 1-byte buffer, it
+ * will return how many characters it would have produced had
+ * it been given an infinite-sized buffer.
+ */
+int
+pcap_vasprintf(char **strp, const char *format, va_list args)
+{
+	char buf;
+	int len;
+	size_t str_size;
+	char *str;
+	int ret;
+
+	/*
+	 * XXX - the C99 standard says, in section 7.19.6.5 "Thes
+	 * nprintf function":
+	 *
+	 *    The snprintf function is equivalent to fprintf, except that
+	 *    the output is written into an array (specified by argument s)
+	 *    rather than to a stream.  If n is zero, nothing is written,
+	 *    and s may be a null pointer.  Otherwise, output characters
+	 *    beyond the n-1st are discarded rather than being written
+	 *    to the array, and a null character is written at the end
+	 *    of the characters actually written into the array.
+	 *
+	 *        ...
+	 *
+	 *    The snprintf function returns the number of characters that
+	 *    would have been written had n been sufficiently large, not
+	 *    counting the terminating null character, or a negative value
+	 *    if an encoding error occurred. Thus, the null-terminated
+	 *    output has been completely written if and only if the returned
+	 *    value is nonnegative and less than n.
+	 *
+	 * That doesn't make it entirely clear whether, if a null buffer
+	 * pointer and a zero count are passed, it will return the number
+	 * of characters that would have been written had a buffer been
+	 * passed.
+	 *
+	 * And, even if C99 *does*, in fact, say it has to work, it
+	 * doesn't work in Solaris 8, for example - it returns -1 for
+	 * NULL/0, but returns the correct character count for a 1-byte
+	 * buffer.
+	 *
+	 * So we pass a one-character pointer in order to find out how
+	 * many characters this format and those arguments will need
+	 * without actually generating any more of those characters
+	 * than we need.
+	 *
+	 * (The fact that it might happen to work with GNU libc or with
+	 * various BSD libcs is completely uninteresting, as those tend
+	 * to have asprintf() already and thus don't even *need* this
+	 * code; this is for use in those UN*Xes that *don't* have
+	 * asprintf().)
+	 */
+	len = vsnprintf(&buf, sizeof buf, format, args);
+	if (len == -1) {
+		*strp = NULL;
+		return (-1);
+	}
+	str_size = len + 1;
+	str = malloc(str_size);
+	if (str == NULL) {
+		*strp = NULL;
+		return (-1);
+	}
+	ret = vsnprintf(str, str_size, format, args);
+	if (ret == -1) {
+		free(str);
+		*strp = NULL;
+		return (-1);
+	}
+	*strp = str;
+	/*
+	 * vsnprintf() shouldn't truncate the string, as we have
+	 * allocated a buffer large enough to hold the string, so its
+	 * return value should be the number of characters written.
+	 */
+	return (ret);
+}
+
+int
+pcap_asprintf(char **strp, const char *format, ...)
+{
+	va_list args;
+	int ret;
+
+	va_start(args, format);
+	ret = pcap_vasprintf(strp, format, args);
+	va_end(args);
+	return (ret);
+}
+
diff --git a/missing/snprintf.c b/missing/snprintf.c
index 99f0bdf..672aeb8 100644
--- a/missing/snprintf.c
+++ b/missing/snprintf.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995-1999 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -31,6 +31,10 @@
  * SUCH DAMAGE.
  */
 
+/*
+ * We use this for platforms that don't have snprintf() at all.
+ */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -42,7 +46,7 @@
 #include <ctype.h>
 #include <sys/types.h>
 
-#include <pcap-int.h>
+#include "portability.h"
 
 enum format_flags {
     minus_flag     =  1,
@@ -525,6 +529,7 @@
 
   va_start(args, format);
   val = pcap_vasnprintf (ret, max_sz, format, args);
+  va_end(args);
 
 #ifdef PARANOIA
   {
@@ -534,14 +539,15 @@
     if (tmp == NULL)
       abort ();
 
+    va_start(args, format);
     ret2 = pcap_vsprintf (tmp, format, args);
+    va_end(args);
     if (val != ret2 || strcmp(*ret, tmp))
       abort ();
     free (tmp);
   }
 #endif
 
-  va_end(args);
   return val;
 }
 #endif
diff --git a/missing/strlcat.c b/missing/strlcat.c
new file mode 100644
index 0000000..bb78a3d
--- /dev/null
+++ b/missing/strlcat.c
@@ -0,0 +1,61 @@
+/*	$OpenBSD: pcap_strlcat.c,v 1.15 2015/03/02 21:41:08 millert Exp $	*/
+
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+#include <string.h>
+
+#include "portability.h"
+
+/*
+ * Appends src to string dst of size dsize (unlike strncat, dsize is the
+ * full size of dst, not space left).  At most dsize-1 characters
+ * will be copied.  Always NUL terminates (unless dsize <= strlen(dst)).
+ * Returns strlen(src) + MIN(dsize, strlen(initial dst)).
+ * If retval >= dsize, truncation occurred.
+ */
+size_t
+pcap_strlcat(char * restrict dst, const char * restrict src, size_t dsize)
+{
+	const char *odst = dst;
+	const char *osrc = src;
+	size_t n = dsize;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end. */
+	while (n-- != 0 && *dst != '\0')
+		dst++;
+	dlen = dst - odst;
+	n = dsize - dlen;
+
+	if (n-- == 0)
+		return(dlen + strlen(src));
+	while (*src != '\0') {
+		if (n != 0) {
+			*dst++ = *src;
+			n--;
+		}
+		src++;
+	}
+	*dst = '\0';
+
+	return(dlen + (src - osrc));	/* count does not include NUL */
+}
diff --git a/missing/strlcpy.c b/missing/strlcpy.c
new file mode 100644
index 0000000..c552e0d
--- /dev/null
+++ b/missing/strlcpy.c
@@ -0,0 +1,56 @@
+/*	$OpenBSD: pcap_strlcpy.c,v 1.12 2015/01/15 03:54:12 millert Exp $	*/
+
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stddef.h>
+#include <string.h>
+
+#include "portability.h"
+
+/*
+ * Copy string src to buffer dst of size dsize.  At most dsize-1
+ * chars will be copied.  Always NUL terminates (unless dsize == 0).
+ * Returns strlen(src); if retval >= dsize, truncation occurred.
+ */
+size_t
+pcap_strlcpy(char * restrict dst, const char * restrict src, size_t dsize)
+{
+	const char *osrc = src;
+	size_t nleft = dsize;
+
+	/* Copy as many bytes as will fit. */
+	if (nleft != 0) {
+		while (--nleft != 0) {
+			if ((*dst++ = *src++) == '\0')
+				break;
+		}
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src. */
+	if (nleft == 0) {
+		if (dsize != 0)
+			*dst = '\0';		/* NUL-terminate dst */
+		while (*src++)
+			;
+	}
+
+	return(src - osrc - 1);	/* count does not include NUL */
+}
diff --git a/missing/win_asprintf.c b/missing/win_asprintf.c
new file mode 100644
index 0000000..cce6296
--- /dev/null
+++ b/missing/win_asprintf.c
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "portability.h"
+
+int
+pcap_vasprintf(char **strp, const char *format, va_list args)
+{
+	int len;
+	size_t str_size;
+	char *str;
+	int ret;
+
+	len = _vscprintf(format, args);
+	if (len == -1) {
+		*strp = NULL;
+		return (-1);
+	}
+	str_size = len + 1;
+	str = malloc(str_size);
+	if (str == NULL) {
+		*strp = NULL;
+		return (-1);
+	}
+	ret = pcap_vsnprintf(str, str_size, format, args);
+	if (ret == -1) {
+		free(str);
+		*strp = NULL;
+		return (-1);
+	}
+	*strp = str;
+	/*
+	 * pcap_vsnprintf() shouldn't truncate the string, as we have
+	 * allocated a buffer large enough to hold the string, so its
+	 * return value should be the number of characters printed.
+	 */
+	return (ret);
+}
+
+int
+pcap_asprintf(char **strp, const char *format, ...)
+{
+	va_list args;
+	int ret;
+
+	va_start(args, format);
+	ret = pcap_vasprintf(strp, format, args);
+	va_end(args);
+	return (ret);
+}
diff --git a/missing/win_snprintf.c b/missing/win_snprintf.c
index 65a8ea1..f422403 100644
--- a/missing/win_snprintf.c
+++ b/missing/win_snprintf.c
@@ -1,6 +1,8 @@
 #include <stdio.h>
 #include <stdarg.h>
 
+#include "portability.h"
+
 int
 pcap_vsnprintf(char *str, size_t str_size, const char *format, va_list args)
 {
@@ -13,6 +15,16 @@
 	 * that str is null-terminated, but C99's vsnprintf()
 	 * and snprintf() do, and we want to offer C99 behavior,
 	 * so forcibly null-terminate the string.
+	 *
+	 * We don't, however, offer C99 behavior for the return
+	 * value; _vsnprintf_s() returns -1, not the number of
+	 * characters that would have been put into the buffer
+	 * had it been large enough, if the string is truncated.
+	 * The only way to get that value is to use _vscprintf();
+	 * getting that count isn't worth the re-formatting.
+	 *
+	 * XXX - does _vsnprintf_s() return -1 on a formatting
+	 * error?
 	 */
 	str[str_size - 1] = '\0';
 	return (ret);
diff --git a/nametoaddr.c b/nametoaddr.c
index 194ff45..7c48bd3 100644
--- a/nametoaddr.c
+++ b/nametoaddr.c
@@ -231,7 +231,22 @@
 	int h_errnoval;
 	int err;
 
-	err = getnetbyname_r(name, &result_buf, buf, sizeof buf, &np,
+	/*
+	 * Apparently, the man page at
+	 *
+	 *    http://man7.org/linux/man-pages/man3/getnetbyname_r.3.html
+	 *
+	 * lies when it says
+	 *
+	 *    If the function call successfully obtains a network record,
+	 *    then *result is set pointing to result_buf; otherwise, *result
+	 *    is set to NULL.
+	 *
+	 * and, in fact, at least in some versions of GNU libc, it does
+	 * *not* always get set if getnetbyname_r() succeeds.
+	 */
+	np = NULL;
+ 	err = getnetbyname_r(name, &result_buf, buf, sizeof buf, &np,
 	    &h_errnoval);
 	if (err != 0) {
 		/*
diff --git a/optimize.c b/optimize.c
index 7c6424b..448452d 100644
--- a/optimize.c
+++ b/optimize.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <memory.h>
+#include <setjmp.h>
 #include <string.h>
 
 #include <errno.h>
@@ -227,6 +228,16 @@
 
 typedef struct {
 	/*
+	 * Place to longjmp to on an error.
+	 */
+	jmp_buf top_ctx;
+
+	/*
+	 * The buffer into which to put error message.
+	 */
+	char *errbuf;
+
+	/*
 	 * A flag to indicate that further optimization is needed.
 	 * Iterative passes are continued until a given pass yields no
 	 * branch movement.
@@ -252,19 +263,19 @@
  * True if a is in uset {p}
  */
 #define SET_MEMBER(p, a) \
-((p)[(unsigned)(a) / BITS_PER_WORD] & (1 << ((unsigned)(a) % BITS_PER_WORD)))
+((p)[(unsigned)(a) / BITS_PER_WORD] & ((bpf_u_int32)1 << ((unsigned)(a) % BITS_PER_WORD)))
 
 /*
  * Add 'a' to uset p.
  */
 #define SET_INSERT(p, a) \
-(p)[(unsigned)(a) / BITS_PER_WORD] |= (1 << ((unsigned)(a) % BITS_PER_WORD))
+(p)[(unsigned)(a) / BITS_PER_WORD] |= ((bpf_u_int32)1 << ((unsigned)(a) % BITS_PER_WORD))
 
 /*
  * Delete 'a' from uset p.
  */
 #define SET_DELETE(p, a) \
-(p)[(unsigned)(a) / BITS_PER_WORD] &= ~(1 << ((unsigned)(a) % BITS_PER_WORD))
+(p)[(unsigned)(a) / BITS_PER_WORD] &= ~((bpf_u_int32)1 << ((unsigned)(a) % BITS_PER_WORD))
 
 /*
  * a := a intersect b
@@ -312,6 +323,16 @@
 
 typedef struct {
 	/*
+	 * Place to longjmp to on an error.
+	 */
+	jmp_buf top_ctx;
+
+	/*
+	 * The buffer into which to put error message.
+	 */
+	char *errbuf;
+
+	/*
 	 * Some pointers used to convert the basic block form of the code,
 	 * into the array form that BPF requires.  'fstart' will point to
 	 * the malloc'd array while 'ftail' is used during the recursive
@@ -321,14 +342,16 @@
 	struct bpf_insn *ftail;
 } conv_state_t;
 
-static void opt_init(compiler_state_t *, opt_state_t *, struct icode *);
+static void opt_init(opt_state_t *, struct icode *);
 static void opt_cleanup(opt_state_t *);
+static void PCAP_NORETURN opt_error(opt_state_t *, const char *, ...)
+    PCAP_PRINTFLIKE(2, 3);
 
 static void intern_blocks(opt_state_t *, struct icode *);
 
 static void find_inedges(opt_state_t *, struct block *);
 #ifdef BDEBUG
-static void opt_dump(compiler_state_t *, struct icode *);
+static void opt_dump(opt_state_t *, struct icode *);
 #endif
 
 #ifndef MAX
@@ -699,8 +722,7 @@
  * (Unary operators are handled elsewhere.)
  */
 static void
-fold_op(compiler_state_t *cstate, opt_state_t *opt_state,
-    struct stmt *s, int v0, int v1)
+fold_op(opt_state_t *opt_state, struct stmt *s, int v0, int v1)
 {
 	bpf_u_int32 a, b;
 
@@ -722,13 +744,13 @@
 
 	case BPF_DIV:
 		if (b == 0)
-			bpf_error(cstate, "division by zero");
+			opt_error(opt_state, "division by zero");
 		a /= b;
 		break;
 
 	case BPF_MOD:
 		if (b == 0)
-			bpf_error(cstate, "modulus by zero");
+			opt_error(opt_state, "modulus by zero");
 		a %= b;
 		break;
 
@@ -745,11 +767,39 @@
 		break;
 
 	case BPF_LSH:
-		a <<= b;
+		/*
+		 * A left shift of more than the width of the type
+		 * is undefined in C; we'll just treat it as shifting
+		 * all the bits out.
+		 *
+		 * XXX - the BPF interpreter doesn't check for this,
+		 * so its behavior is dependent on the behavior of
+		 * the processor on which it's running.  There are
+		 * processors on which it shifts all the bits out
+		 * and processors on which it does no shift.
+		 */
+		if (b < 32)
+			a <<= b;
+		else
+			a = 0;
 		break;
 
 	case BPF_RSH:
-		a >>= b;
+		/*
+		 * A right shift of more than the width of the type
+		 * is undefined in C; we'll just treat it as shifting
+		 * all the bits out.
+		 *
+		 * XXX - the BPF interpreter doesn't check for this,
+		 * so its behavior is dependent on the behavior of
+		 * the processor on which it's running.  There are
+		 * processors on which it shifts all the bits out
+		 * and processors on which it does no shift.
+		 */
+		if (b < 32)
+			a >>= b;
+		else
+			a = 0;
 		break;
 
 	default:
@@ -1041,8 +1091,7 @@
  * evaluation and code transformations weren't folded together.
  */
 static void
-opt_stmt(compiler_state_t *cstate, opt_state_t *opt_state,
-    struct stmt *s, int val[], int alter)
+opt_stmt(opt_state_t *opt_state, struct stmt *s, int val[], int alter)
 {
 	int op;
 	int v;
@@ -1094,7 +1143,23 @@
 	case BPF_ALU|BPF_NEG:
 		if (alter && opt_state->vmap[val[A_ATOM]].is_const) {
 			s->code = BPF_LD|BPF_IMM;
-			s->k = -opt_state->vmap[val[A_ATOM]].const_val;
+			/*
+			 * Do this negation as unsigned arithmetic; that's
+			 * what modern BPF engines do, and it guarantees
+			 * that all possible values can be negated.  (Yeah,
+			 * negating 0x80000000, the minimum signed 32-bit
+			 * two's-complement value, results in 0x80000000,
+			 * so it's still negative, but we *should* be doing
+			 * all unsigned arithmetic here, to match what
+			 * modern BPF engines do.)
+			 *
+			 * Express it as 0U - (unsigned value) so that we
+			 * don't get compiler warnings about negating an
+			 * unsigned value and don't get UBSan warnings
+			 * about the result of negating 0x80000000 being
+			 * undefined.
+			 */
+			s->k = 0U - (bpf_u_int32)(opt_state->vmap[val[A_ATOM]].const_val);
 			val[A_ATOM] = K(s->k);
 		}
 		else
@@ -1114,9 +1179,17 @@
 		op = BPF_OP(s->code);
 		if (alter) {
 			if (s->k == 0) {
-				/* don't optimize away "sub #0"
+				/*
+				 * Optimize operations where the constant
+				 * is zero.
+				 *
+				 * Don't optimize away "sub #0"
 				 * as it may be needed later to
-				 * fixup the generated math code */
+				 * fixup the generated math code.
+				 *
+				 * Fail if we're dividing by zero or taking
+				 * a modulus by zero.
+				 */
 				if (op == BPF_ADD ||
 				    op == BPF_LSH || op == BPF_RSH ||
 				    op == BPF_OR || op == BPF_XOR) {
@@ -1128,9 +1201,15 @@
 					val[A_ATOM] = K(s->k);
 					break;
 				}
+				if (op == BPF_DIV)
+					opt_error(opt_state,
+					    "division by zero");
+				if (op == BPF_MOD)
+					opt_error(opt_state,
+					    "modulus by zero");
 			}
 			if (opt_state->vmap[val[A_ATOM]].is_const) {
-				fold_op(cstate, opt_state, s, val[A_ATOM], K(s->k));
+				fold_op(opt_state, s, val[A_ATOM], K(s->k));
 				val[A_ATOM] = K(s->k);
 				break;
 			}
@@ -1151,12 +1230,22 @@
 		op = BPF_OP(s->code);
 		if (alter && opt_state->vmap[val[X_ATOM]].is_const) {
 			if (opt_state->vmap[val[A_ATOM]].is_const) {
-				fold_op(cstate, opt_state, s, val[A_ATOM], val[X_ATOM]);
+				fold_op(opt_state, s, val[A_ATOM], val[X_ATOM]);
 				val[A_ATOM] = K(s->k);
 			}
 			else {
 				s->code = BPF_ALU|BPF_K|op;
 				s->k = opt_state->vmap[val[X_ATOM]].const_val;
+				/*
+				 * XXX - we need to make up our minds
+				 * as to what integers are signed and
+				 * what integers are unsigned in BPF
+				 * programs and in our IR.
+				 */
+				if ((op == BPF_LSH || op == BPF_RSH) &&
+				    (s->k < 0 || s->k > 31))
+					opt_error(opt_state,
+					    "shift by more than 31 bits");
 				opt_state->done = 0;
 				val[A_ATOM] =
 					F(opt_state, s->code, val[A_ATOM], K(s->k));
@@ -1275,8 +1364,7 @@
 }
 
 static void
-opt_blk(compiler_state_t *cstate, opt_state_t *opt_state,
-    struct block *b, int do_stmts)
+opt_blk(opt_state_t *opt_state, struct block *b, int do_stmts)
 {
 	struct slist *s;
 	struct edge *p;
@@ -1326,7 +1414,7 @@
 	aval = b->val[A_ATOM];
 	xval = b->val[X_ATOM];
 	for (s = b->stmts; s; s = s->next)
-		opt_stmt(cstate, opt_state, &s->s, b->val, do_stmts);
+		opt_stmt(opt_state, &s->s, b->val, do_stmts);
 
 	/*
 	 * This is a special case: if we don't use anything from this
@@ -1480,7 +1568,7 @@
 
 		while (x != 0) {
 			k = lowest_set_bit(x);
-			x &=~ (1 << k);
+			x &=~ ((bpf_u_int32)1 << k);
 			k += i * BITS_PER_WORD;
 
 			target = fold_edge(ep->succ, opt_state->edges[k]);
@@ -1687,8 +1775,7 @@
 }
 
 static void
-opt_blks(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic,
-    int do_stmts)
+opt_blks(opt_state_t *opt_state, struct icode *ic, int do_stmts)
 {
 	int i, maxlevel;
 	struct block *p;
@@ -1699,7 +1786,7 @@
 	find_inedges(opt_state, ic->root);
 	for (i = maxlevel; i >= 0; --i)
 		for (p = opt_state->levels[i]; p; p = p->link)
-			opt_blk(cstate, opt_state, p, do_stmts);
+			opt_blk(opt_state, p, do_stmts);
 
 	if (do_stmts)
 		/*
@@ -1777,14 +1864,13 @@
 }
 
 static void
-opt_loop(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic,
-    int do_stmts)
+opt_loop(opt_state_t *opt_state, struct icode *ic, int do_stmts)
 {
 
 #ifdef BDEBUG
 	if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) {
 		printf("opt_loop(root, %d) begin\n", do_stmts);
-		opt_dump(cstate, ic);
+		opt_dump(opt_state, ic);
 	}
 #endif
 	do {
@@ -1794,11 +1880,11 @@
 		find_closure(opt_state, ic->root);
 		find_ud(opt_state, ic->root);
 		find_edom(opt_state, ic->root);
-		opt_blks(cstate, opt_state, ic, do_stmts);
+		opt_blks(opt_state, ic, do_stmts);
 #ifdef BDEBUG
 		if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) {
 			printf("opt_loop(root, %d) bottom, done=%d\n", do_stmts, opt_state->done);
-			opt_dump(cstate, ic);
+			opt_dump(opt_state, ic);
 		}
 #endif
 	} while (!opt_state->done);
@@ -1806,30 +1892,38 @@
 
 /*
  * Optimize the filter code in its dag representation.
+ * Return 0 on success, -1 on error.
  */
-void
-bpf_optimize(compiler_state_t *cstate, struct icode *ic)
+int
+bpf_optimize(struct icode *ic, char *errbuf)
 {
 	opt_state_t opt_state;
 
-	opt_init(cstate, &opt_state, ic);
-	opt_loop(cstate, &opt_state, ic, 0);
-	opt_loop(cstate, &opt_state, ic, 1);
+	memset(&opt_state, 0, sizeof(opt_state));
+	opt_state.errbuf = errbuf;
+	if (setjmp(opt_state.top_ctx)) {
+		opt_cleanup(&opt_state);
+		return -1;
+	}
+	opt_init(&opt_state, ic);
+	opt_loop(&opt_state, ic, 0);
+	opt_loop(&opt_state, ic, 1);
 	intern_blocks(&opt_state, ic);
 #ifdef BDEBUG
 	if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) {
 		printf("after intern_blocks()\n");
-		opt_dump(cstate, ic);
+		opt_dump(&opt_state, ic);
 	}
 #endif
 	opt_root(&ic->root);
 #ifdef BDEBUG
 	if (pcap_optimizer_debug > 1 || pcap_print_dot_graph) {
 		printf("after opt_root()\n");
-		opt_dump(cstate, ic);
+		opt_dump(&opt_state, ic);
 	}
 #endif
 	opt_cleanup(&opt_state);
+	return 0;
 }
 
 static void
@@ -1944,6 +2038,24 @@
 }
 
 /*
+ * For optimizer errors.
+ */
+static void PCAP_NORETURN
+opt_error(opt_state_t *opt_state, const char *fmt, ...)
+{
+	va_list ap;
+
+	if (opt_state->errbuf != NULL) {
+		va_start(ap, fmt);
+		(void)pcap_vsnprintf(opt_state->errbuf,
+		    PCAP_ERRBUF_SIZE, fmt, ap);
+		va_end(ap);
+	}
+	longjmp(opt_state->top_ctx, 1);
+	/* NOTREACHED */
+}
+
+/*
  * Return the number of stmts in 's'.
  */
 static u_int
@@ -2027,7 +2139,7 @@
  * from the total number of blocks and/or statements.
  */
 static void
-opt_init(compiler_state_t *cstate, opt_state_t *opt_state, struct icode *ic)
+opt_init(opt_state_t *opt_state, struct icode *ic)
 {
 	bpf_u_int32 *p;
 	int i, n, max_stmts;
@@ -2040,22 +2152,24 @@
 	n = count_blocks(ic, ic->root);
 	opt_state->blocks = (struct block **)calloc(n, sizeof(*opt_state->blocks));
 	if (opt_state->blocks == NULL)
-		bpf_error(cstate, "malloc");
+		opt_error(opt_state, "malloc");
 	unMarkAll(ic);
 	opt_state->n_blocks = 0;
 	number_blks_r(opt_state, ic, ic->root);
 
 	opt_state->n_edges = 2 * opt_state->n_blocks;
 	opt_state->edges = (struct edge **)calloc(opt_state->n_edges, sizeof(*opt_state->edges));
-	if (opt_state->edges == NULL)
-		bpf_error(cstate, "malloc");
+	if (opt_state->edges == NULL) {
+		opt_error(opt_state, "malloc");
+	}
 
 	/*
 	 * The number of levels is bounded by the number of nodes.
 	 */
 	opt_state->levels = (struct block **)calloc(opt_state->n_blocks, sizeof(*opt_state->levels));
-	if (opt_state->levels == NULL)
-		bpf_error(cstate, "malloc");
+	if (opt_state->levels == NULL) {
+		opt_error(opt_state, "malloc");
+	}
 
 	opt_state->edgewords = opt_state->n_edges / (8 * sizeof(bpf_u_int32)) + 1;
 	opt_state->nodewords = opt_state->n_blocks / (8 * sizeof(bpf_u_int32)) + 1;
@@ -2063,8 +2177,9 @@
 	/* XXX */
 	opt_state->space = (bpf_u_int32 *)malloc(2 * opt_state->n_blocks * opt_state->nodewords * sizeof(*opt_state->space)
 				 + opt_state->n_edges * opt_state->edgewords * sizeof(*opt_state->space));
-	if (opt_state->space == NULL)
-		bpf_error(cstate, "malloc");
+	if (opt_state->space == NULL) {
+		opt_error(opt_state, "malloc");
+	}
 	p = opt_state->space;
 	opt_state->all_dom_sets = p;
 	for (i = 0; i < n; ++i) {
@@ -2101,9 +2216,13 @@
 	 */
 	opt_state->maxval = 3 * max_stmts;
 	opt_state->vmap = (struct vmapinfo *)calloc(opt_state->maxval, sizeof(*opt_state->vmap));
+	if (opt_state->vmap == NULL) {
+		opt_error(opt_state, "malloc");
+	}
 	opt_state->vnode_base = (struct valnode *)calloc(opt_state->maxval, sizeof(*opt_state->vnode_base));
-	if (opt_state->vmap == NULL || opt_state->vnode_base == NULL)
-		bpf_error(cstate, "malloc");
+	if (opt_state->vnode_base == NULL) {
+		opt_error(opt_state, "malloc");
+	}
 }
 
 /*
@@ -2115,6 +2234,9 @@
 int bids[NBIDS];
 #endif
 
+static void PCAP_NORETURN conv_error(conv_state_t *, const char *, ...)
+    PCAP_PRINTFLIKE(2, 3);
+
 /*
  * Returns true if successful.  Returns false if a branch has
  * an offset that is too large.  If so, we have marked that
@@ -2122,8 +2244,7 @@
  * properly.
  */
 static int
-convert_code_r(compiler_state_t *cstate, conv_state_t *conv_state,
-    struct icode *ic, struct block *p)
+convert_code_r(conv_state_t *conv_state, struct icode *ic, struct block *p)
 {
 	struct bpf_insn *dst;
 	struct slist *src;
@@ -2136,9 +2257,9 @@
 		return (1);
 	Mark(ic, p);
 
-	if (convert_code_r(cstate, conv_state, ic, JF(p)) == 0)
+	if (convert_code_r(conv_state, ic, JF(p)) == 0)
 		return (0);
-	if (convert_code_r(cstate, conv_state, ic, JT(p)) == 0)
+	if (convert_code_r(conv_state, ic, JT(p)) == 0)
 		return (0);
 
 	slen = slength(p->stmts);
@@ -2151,7 +2272,7 @@
 	if (slen) {
 		offset = (struct slist **)calloc(slen, sizeof(struct slist *));
 		if (!offset) {
-			bpf_error(cstate, "not enough core");
+			conv_error(conv_state, "not enough core");
 			/*NOTREACHED*/
 		}
 	}
@@ -2175,7 +2296,8 @@
 		if (BPF_CLASS(src->s.code) != BPF_JMP || src->s.code == (BPF_JMP|BPF_JA)) {
 #if 0
 			if (src->s.jt || src->s.jf) {
-				bpf_error(cstate, "illegal jmp destination");
+				free(offset);
+				conv_error(conv_state, "illegal jmp destination");
 				/*NOTREACHED*/
 			}
 #endif
@@ -2195,7 +2317,8 @@
 #endif
 
 		if (!src->s.jt || !src->s.jf) {
-			bpf_error(cstate, ljerr, "no jmp destination", off);
+			free(offset);
+			conv_error(conv_state, ljerr, "no jmp destination", off);
 			/*NOTREACHED*/
 		}
 
@@ -2203,12 +2326,14 @@
 		for (i = 0; i < slen; i++) {
 			if (offset[i] == src->s.jt) {
 				if (jt) {
-					bpf_error(cstate, ljerr, "multiple matches", off);
+					free(offset);
+					conv_error(conv_state, ljerr, "multiple matches", off);
 					/*NOTREACHED*/
 				}
 
 				if (i - off - 1 >= 256) {
-					bpf_error(cstate, ljerr, "out-of-range jump", off);
+					free(offset);
+					conv_error(conv_state, ljerr, "out-of-range jump", off);
 					/*NOTREACHED*/
 				}
 				dst->jt = (u_char)(i - off - 1);
@@ -2216,11 +2341,13 @@
 			}
 			if (offset[i] == src->s.jf) {
 				if (jf) {
-					bpf_error(cstate, ljerr, "multiple matches", off);
+					free(offset);
+					conv_error(conv_state, ljerr, "multiple matches", off);
 					/*NOTREACHED*/
 				}
 				if (i - off - 1 >= 256) {
-					bpf_error(cstate, ljerr, "out-of-range jump", off);
+					free(offset);
+					conv_error(conv_state, ljerr, "out-of-range jump", off);
 					/*NOTREACHED*/
 				}
 				dst->jf = (u_char)(i - off - 1);
@@ -2228,7 +2355,8 @@
 			}
 		}
 		if (!jt || !jf) {
-			bpf_error(cstate, ljerr, "no destination found", off);
+			free(offset);
+			conv_error(conv_state, ljerr, "no destination found", off);
 			/*NOTREACHED*/
 		}
 	    }
@@ -2257,7 +2385,7 @@
 		    }
 		    /* branch if T to following jump */
 		    if (extrajmps >= 256) {
-			bpf_error(cstate, "too many extra jumps");
+			conv_error(conv_state, "too many extra jumps");
 			/*NOTREACHED*/
 		    }
 		    dst->jt = (u_char)extrajmps;
@@ -2278,7 +2406,7 @@
 		    /* branch if F to following jump */
 		    /* if two jumps are inserted, F goes to second one */
 		    if (extrajmps >= 256) {
-			bpf_error(cstate, "too many extra jumps");
+			conv_error(conv_state, "too many extra jumps");
 			/*NOTREACHED*/
 		    }
 		    dst->jf = (u_char)extrajmps;
@@ -2312,13 +2440,20 @@
  * done with the filter program.  See the pcap man page.
  */
 struct bpf_insn *
-icode_to_fcode(compiler_state_t *cstate, struct icode *ic,
-    struct block *root, u_int *lenp)
+icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp, 
+    char *errbuf)
 {
 	u_int n;
 	struct bpf_insn *fp;
 	conv_state_t conv_state;
 
+	conv_state.fstart = NULL;
+	conv_state.errbuf = errbuf;
+	if (setjmp(conv_state.top_ctx) != 0) {
+		free(conv_state.fstart);
+		return NULL;
+	}
+
 	/*
 	 * Loop doing convert_code_r() until no branches remain
 	 * with too-large offsets.
@@ -2328,14 +2463,18 @@
 	    n = *lenp = count_stmts(ic, root);
 
 	    fp = (struct bpf_insn *)malloc(sizeof(*fp) * n);
-	    if (fp == NULL)
-		    bpf_error(cstate, "malloc");
+	    if (fp == NULL) {
+		(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+		    "malloc");
+		free(fp);
+		return NULL;
+	    }
 	    memset((char *)fp, 0, sizeof(*fp) * n);
 	    conv_state.fstart = fp;
 	    conv_state.ftail = fp + n;
 
 	    unMarkAll(ic);
-	    if (convert_code_r(cstate, &conv_state, ic, root))
+	    if (convert_code_r(&conv_state, ic, root))
 		break;
 	    free(fp);
 	}
@@ -2344,6 +2483,22 @@
 }
 
 /*
+ * For iconv_to_fconv() errors.
+ */
+static void PCAP_NORETURN
+conv_error(conv_state_t *conv_state, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	(void)pcap_vsnprintf(conv_state->errbuf,
+	    PCAP_ERRBUF_SIZE, fmt, ap);
+	va_end(ap);
+	longjmp(conv_state->top_ctx, 1);
+	/* NOTREACHED */
+}
+
+/*
  * Make a copy of a BPF program and put it in the "fcode" member of
  * a "pcap_t".
  *
@@ -2452,14 +2607,16 @@
  *  After install graphviz on http://www.graphviz.org/, save it as bpf.dot
  *  and run `dot -Tpng -O bpf.dot' to draw the graph.
  */
-static void
-dot_dump(compiler_state_t *cstate, struct icode *ic)
+static int
+dot_dump(struct icode *ic, char *errbuf)
 {
 	struct bpf_program f;
 	FILE *out = stdout;
 
 	memset(bids, 0, sizeof bids);
-	f.bf_insns = icode_to_fcode(cstate, ic, ic->root, &f.bf_len);
+	f.bf_insns = icode_to_fcode(ic, ic->root, &f.bf_len, errbuf);
+	if (f.bf_insns == NULL)
+		return -1;
 
 	fprintf(out, "digraph BPF {\n");
 	unMarkAll(ic);
@@ -2469,30 +2626,39 @@
 	fprintf(out, "}\n");
 
 	free((char *)f.bf_insns);
+	return 0;
 }
 
-static void
-plain_dump(compiler_state_t *cstate, struct icode *ic)
+static int
+plain_dump(struct icode *ic, char *errbuf)
 {
 	struct bpf_program f;
 
 	memset(bids, 0, sizeof bids);
-	f.bf_insns = icode_to_fcode(cstate, ic, ic->root, &f.bf_len);
+	f.bf_insns = icode_to_fcode(ic, ic->root, &f.bf_len, errbuf);
+	if (f.bf_insns == NULL)
+		return -1;
 	bpf_dump(&f, 1);
 	putchar('\n');
 	free((char *)f.bf_insns);
+	return 0;
 }
 
 static void
-opt_dump(compiler_state_t *cstate, struct icode *ic)
+opt_dump(opt_state_t *opt_state, struct icode *ic)
 {
+	int status;
+	char errbuf[PCAP_ERRBUF_SIZE];
+
 	/*
 	 * If the CFG, in DOT format, is requested, output it rather than
 	 * the code that would be generated from that graph.
 	 */
 	if (pcap_print_dot_graph)
-		dot_dump(cstate, ic);
+		status = dot_dump(ic, errbuf);
 	else
-		plain_dump(cstate, ic);
+		status = plain_dump(ic, errbuf);
+	if (status == -1)
+		opt_error(opt_state, "opt_dump: icode_to_fcode failed: %s", errbuf);
 }
 #endif
diff --git a/pcap-bpf.c b/pcap-bpf.c
index 6ce383b..4f1a0af 100644
--- a/pcap-bpf.c
+++ b/pcap-bpf.c
@@ -206,7 +206,7 @@
 #  endif
 
 #  if defined(__APPLE__)
-static void remove_en(pcap_t *);
+static void remove_non_802_11(pcap_t *);
 static void remove_802_11(pcap_t *);
 #  endif
 
@@ -737,10 +737,10 @@
 }
 #endif
 
+#if defined(__APPLE__)
 static int
 pcap_can_set_rfmon_bpf(pcap_t *p)
 {
-#if defined(__APPLE__)
 	struct utsname osinfo;
 	struct ifreq ifr;
 	int fd;
@@ -799,8 +799,8 @@
 			    errno, "socket");
 			return (PCAP_ERROR);
 		}
-		strlcpy(ifr.ifr_name, "wlt", sizeof(ifr.ifr_name));
-		strlcat(ifr.ifr_name, p->opt.device + 2, sizeof(ifr.ifr_name));
+		pcap_strlcpy(ifr.ifr_name, "wlt", sizeof(ifr.ifr_name));
+		pcap_strlcat(ifr.ifr_name, p->opt.device + 2, sizeof(ifr.ifr_name));
 		if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) {
 			/*
 			 * No such device?
@@ -880,7 +880,11 @@
 	close(fd);
 #endif /* BIOCGDLTLIST */
 	return (0);
+}
 #elif defined(HAVE_BSD_IEEE80211)
+static int
+pcap_can_set_rfmon_bpf(pcap_t *p)
+{
 	int ret;
 
 	ret = monitor_mode(p, 0);
@@ -889,10 +893,14 @@
 	if (ret == 0)
 		return (1);	/* success */
 	return (ret);
-#else
-	return (0);
-#endif
 }
+#else
+static int
+pcap_can_set_rfmon_bpf(pcap_t *p _U_)
+{
+	return (0);
+}
+#endif
 
 static int
 pcap_stats_bpf(pcap_t *p, struct pcap_stat *ps)
@@ -1012,18 +1020,21 @@
 			case EWOULDBLOCK:
 				return (0);
 
-			case ENXIO:
+			case ENXIO:	/* FreeBSD, DragonFly BSD, and Darwin */
+			case EIO:	/* OpenBSD */
+					/* NetBSD appears not to return an error in this case */
 				/*
 				 * The device on which we're capturing
 				 * went away.
 				 *
 				 * XXX - we should really return
-				 * PCAP_ERROR_IFACE_NOT_UP, but
-				 * pcap_dispatch() etc. aren't
-				 * defined to retur that.
+				 * an appropriate error for that,
+				 * but pcap_dispatch() etc. aren't
+				 * documented as having error returns
+				 * other than PCAP_ERROR or PCAP_ERROR_BREAK.
 				 */
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-				    "The interface went down");
+				    "The interface disappeared");
 				return (PCAP_ERROR);
 
 #if defined(sun) && !defined(BSD) && !defined(__svr4__) && !defined(__SVR4)
@@ -1358,8 +1369,8 @@
 
 	/* Check if the driver is loaded */
 	memset(&cfg_ld, 0x0, sizeof(cfg_ld));
+	pcap_snprintf(buf, sizeof(buf), "%s/%s", DRIVER_PATH, BPF_NAME);
 	cfg_ld.path = buf;
-	pcap_snprintf(cfg_ld.path, sizeof(cfg_ld.path), "%s/%s", DRIVER_PATH, BPF_NAME);
 	if ((sysconfig(SYS_QUERYLOAD, (void *)&cfg_ld, sizeof(cfg_ld)) == -1) ||
 	    (cfg_ld.kmid == 0)) {
 		/* Driver isn't loaded, load it now */
@@ -1469,7 +1480,7 @@
 
 				s = socket(AF_LOCAL, SOCK_DGRAM, 0);
 				if (s >= 0) {
-					strlcpy(ifr.ifr_name, pb->device,
+					pcap_strlcpy(ifr.ifr_name, pb->device,
 					    sizeof(ifr.ifr_name));
 					ioctl(s, SIOCIFDESTROY, &ifr);
 					close(s);
@@ -1532,9 +1543,9 @@
 			 */
 			fd = socket(AF_INET, SOCK_DGRAM, 0);
 			if (fd != -1) {
-				strlcpy(ifr.ifr_name, "en",
+				pcap_strlcpy(ifr.ifr_name, "en",
 				    sizeof(ifr.ifr_name));
-				strlcat(ifr.ifr_name, p->opt.device + 3,
+				pcap_strlcat(ifr.ifr_name, p->opt.device + 3,
 				    sizeof(ifr.ifr_name));
 				if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) {
 					/*
@@ -1721,7 +1732,7 @@
 			goto bad;
 		}
 		znamelen = zonesep - p->opt.device;
-		(void) strlcpy(path_zname, p->opt.device, znamelen + 1);
+		(void) pcap_strlcpy(path_zname, p->opt.device, znamelen + 1);
 		ifr.lifr_zoneid = getzoneidbyname(path_zname);
 		if (ifr.lifr_zoneid == -1) {
 			pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
@@ -1786,7 +1797,7 @@
 					 */
 					sockfd = socket(AF_INET, SOCK_DGRAM, 0);
 					if (sockfd != -1) {
-						strlcpy(ifrname,
+						pcap_strlcpy(ifrname,
 						    p->opt.device, ifnamsiz);
 						if (ioctl(sockfd, SIOCGIFFLAGS,
 						    (char *)&ifr) < 0) {
@@ -1888,7 +1899,7 @@
 			/*
 			 * Create the interface.
 			 */
-			strlcpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name));
+			pcap_strlcpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name));
 			if (ioctl(s, SIOCIFCREATE2, &ifr) < 0) {
 				if (errno == EINVAL) {
 					pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
@@ -2187,7 +2198,7 @@
 					 * of link-layer types, as selecting
 					 * it will keep monitor mode off.
 					 */
-					remove_en(p);
+					remove_non_802_11(p);
 
 					/*
 					 * If the new mode we want isn't
@@ -2748,12 +2759,21 @@
 	strncpy(req.ifm_name, name, sizeof(req.ifm_name));
 	if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) {
 		if (errno == EOPNOTSUPP || errno == EINVAL || errno == ENOTTY ||
-		    errno == ENODEV) {
+		    errno == ENODEV || errno == EPERM) {
 			/*
 			 * Not supported, so we can't provide any
 			 * additional information.  Assume that
 			 * this means that "connected" vs.
 			 * "disconnected" doesn't apply.
+			 *
+			 * The ioctl routine for Apple's pktap devices,
+			 * annoyingly, checks for "are you root?" before
+			 * checking whether the ioctl is valid, so it
+			 * returns EPERM, rather than ENOTSUP, for the
+			 * invalid SIOCGIFMEDIA, unless you're root.
+			 * So, just as we do for some ethtool ioctls
+			 * on Linux, which makes the same mistake, we
+			 * also treat EPERM as meaning "not supported".
 			 */
 			*flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
 			close(sock);
@@ -2890,7 +2910,7 @@
 
 		default:
 			pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
-			    errno, "SIOCGIFMEDIA 1");
+			    errno, "SIOCGIFMEDIA");
 			close(sock);
 			return (PCAP_ERROR);
 		}
@@ -3032,8 +3052,12 @@
 				new_dlt = bdlp->bfl_list[i];
 			break;
 
+#ifdef DLT_PRISM_HEADER
 		case DLT_PRISM_HEADER:
+#endif
+#ifdef DLT_AIRONET_HEADER
 		case DLT_AIRONET_HEADER:
+#endif
 		case DLT_IEEE802_11_RADIO_AVS:
 			/*
 			 * 802.11 with radio, but not radiotap.
@@ -3068,24 +3092,25 @@
 
 #if defined(__APPLE__) && defined(BIOCGDLTLIST)
 /*
- * Remove DLT_EN10MB from the list of DLT_ values, as we're in monitor mode,
- * and DLT_EN10MB isn't supported in monitor mode.
+ * Remove non-802.11 header types from the list of DLT_ values, as we're in
+ * monitor mode, and those header types aren't supported in monitor mode.
  */
 static void
-remove_en(pcap_t *p)
+remove_non_802_11(pcap_t *p)
 {
 	int i, j;
 
 	/*
-	 * Scan the list of DLT_ values and discard DLT_EN10MB.
+	 * Scan the list of DLT_ values and discard non-802.11 ones.
 	 */
 	j = 0;
 	for (i = 0; i < p->dlt_count; i++) {
 		switch (p->dlt_list[i]) {
 
 		case DLT_EN10MB:
+		case DLT_RAW:
 			/*
-			 * Don't offer this one.
+			 * Not 802.11.  Don't offer this one.
 			 */
 			continue;
 
@@ -3127,10 +3152,17 @@
 		switch (p->dlt_list[i]) {
 
 		case DLT_IEEE802_11:
+#ifdef DLT_PRISM_HEADER
 		case DLT_PRISM_HEADER:
+#endif
+#ifdef DLT_AIRONET_HEADER
 		case DLT_AIRONET_HEADER:
+#endif
 		case DLT_IEEE802_11_RADIO:
 		case DLT_IEEE802_11_RADIO_AVS:
+#ifdef DLT_PPI
+		case DLT_PPI:
+#endif
 			/*
 			 * 802.11.  Don't offer this one.
 			 */
@@ -3222,10 +3254,10 @@
  * Set direction flag: Which packets do we accept on a forwarding
  * single device? IN, OUT or both?
  */
+#if defined(BIOCSDIRECTION)
 static int
 pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d)
 {
-#if defined(BIOCSDIRECTION)
 	u_int direction;
 
 	direction = (d == PCAP_D_IN) ? BPF_D_IN :
@@ -3238,7 +3270,11 @@
 		return (-1);
 	}
 	return (0);
+}
 #elif defined(BIOCSSEESENT)
+static int
+pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d)
+{
 	u_int seesent;
 
 	/*
@@ -3258,25 +3294,35 @@
 		return (-1);
 	}
 	return (0);
+}
 #else
+static int
+pcap_setdirection_bpf(pcap_t *p, pcap_direction_t d _U_)
+{
 	(void) pcap_snprintf(p->errbuf, sizeof(p->errbuf),
 	    "This system doesn't support BIOCSSEESENT, so the direction can't be set");
 	return (-1);
-#endif
 }
+#endif
 
+#ifdef BIOCSDLT
 static int
 pcap_set_datalink_bpf(pcap_t *p, int dlt)
 {
-#ifdef BIOCSDLT
 	if (ioctl(p->fd, BIOCSDLT, &dlt) == -1) {
 		pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
 		    errno, "Cannot set DLT %d", dlt);
 		return (-1);
 	}
-#endif
 	return (0);
 }
+#else
+static int
+pcap_set_datalink_bpf(pcap_t *p _U_, int dlt _U_)
+{
+	return (0);
+}
+#endif
 
 /*
  * Platform-specific information.
diff --git a/pcap-bt-linux.c b/pcap-bt-linux.c
index 07ed1c7..9c8712e 100644
--- a/pcap-bt-linux.c
+++ b/pcap-bt-linux.c
@@ -74,13 +74,14 @@
 {
 	struct hci_dev_list_req *dev_list;
 	struct hci_dev_req *dev_req;
-	int i, sock;
+	int sock;
+	unsigned i;
 	int ret = 0;
 
 	sock  = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
 	if (sock < 0)
 	{
-		/* if bluetooth is not supported this this is not fatal*/
+		/* if bluetooth is not supported this is not fatal*/
 		if (errno == EAFNOSUPPORT)
 			return 0;
 		pcap_fmt_errmsg_for_errno(err_str, PCAP_ERRBUF_SIZE,
@@ -109,10 +110,10 @@
 
 	dev_req = dev_list->dev_req;
 	for (i = 0; i < dev_list->dev_num; i++, dev_req++) {
-		char dev_name[20], dev_descr[30];
+		char dev_name[20], dev_descr[40];
 
-		pcap_snprintf(dev_name, 20, BT_IFACE"%d", dev_req->dev_id);
-		pcap_snprintf(dev_descr, 30, "Bluetooth adapter number %d", i);
+		pcap_snprintf(dev_name, sizeof(dev_name), BT_IFACE"%u", dev_req->dev_id);
+		pcap_snprintf(dev_descr, sizeof(dev_descr), "Bluetooth adapter number %u", i);
 
 		/*
 		 * Bluetooth is a wireless technology.
@@ -379,8 +380,8 @@
 static int
 bt_inject_linux(pcap_t *handle, const void *buf _U_, size_t size _U_)
 {
-	pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
-    		"bluetooth devices");
+	pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+	    "Packet injection is not supported on Bluetooth devices");
 	return (-1);
 }
 
diff --git a/pcap-bt-monitor-linux.c b/pcap-bt-monitor-linux.c
index c222c10..a693949 100644
--- a/pcap-bt-monitor-linux.c
+++ b/pcap-bt-monitor-linux.c
@@ -149,7 +149,8 @@
 static int
 bt_monitor_inject(pcap_t *handle, const void *buf _U_, size_t size _U_)
 {
-    pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported yet");
+    pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+        "Packet injection is not supported yet on Bluetooth monitor devices");
     return -1;
 }
 
diff --git a/pcap-common.c b/pcap-common.c
index b379d8f..2a745f0 100644
--- a/pcap-common.c
+++ b/pcap-common.c
@@ -514,11 +514,20 @@
 #define LINKTYPE_RAIF1		198
 
 /*
- * IPMB packet for IPMI, beginning with the I2C slave address, followed
- * by the netFn and LUN, etc..  Requested by Chanthy Toeung
- * <chanthy.toeung@ca.kontron.com>.
+ * IPMB packet for IPMI, beginning with a 2-byte header, followed by
+ * the I2C slave address, followed by the netFn and LUN, etc..
+ * Requested by Chanthy Toeung <chanthy.toeung@ca.kontron.com>.
+ *
+ * XXX - its DLT_ value used to be called DLT_IPMB, back when we got the
+ * impression from the email thread requesting it that the packet
+ * had no extra 2-byte header.  We've renamed it; if anybody used
+ * DLT_IPMB and assumed no 2-byte header, this will cause the compile
+ * to fail, at which point we'll have to figure out what to do about
+ * the two header types using the same DLT_/LINKTYPE_ value.  If that
+ * doesn't happen, we'll assume nobody used it and that the redefinition
+ * is safe.
  */
-#define LINKTYPE_IPMB		199
+#define LINKTYPE_IPMB_KONTRON	199
 
 /*
  * Juniper-private data link type, as per request from
@@ -549,15 +558,35 @@
  */
 #define LINKTYPE_LAPD		203
 
+
 /*
- * Variants of various link-layer headers, with a one-byte direction
- * pseudo-header prepended - zero means "received by this host",
- * non-zero (any non-zero value) means "sent by this host" - as per
- * Will Barker <w.barker@zen.co.uk>.
+ * PPP, with a one-byte direction pseudo-header prepended - zero means
+ * "received by this host", non-zero (any non-zero value) means "sent by
+ * this host" - as per Will Barker <w.barker@zen.co.uk>.
  */
-#define LINKTYPE_PPP_WITH_DIR	204	/* PPP */
+#define LINKTYPE_PPP_WITH_DIR	204	/* Don't confuse with LINKTYPE_PPP_PPPD */
+
+/*
+ * Cisco HDLC, with a one-byte direction pseudo-header prepended - zero
+ * means "received by this host", non-zero (any non-zero value) means
+ * "sent by this host" - as per Will Barker <w.barker@zen.co.uk>.
+ */
 #define LINKTYPE_C_HDLC_WITH_DIR 205	/* Cisco HDLC */
+
+/*
+ * Frame Relay, with a one-byte direction pseudo-header prepended - zero
+ * means "received by this host" (DCE -> DTE), non-zero (any non-zero
+ * value) means "sent by this host" (DTE -> DCE) - as per Will Barker
+ * <w.barker@zen.co.uk>.
+ */
 #define LINKTYPE_FRELAY_WITH_DIR 206	/* Frame Relay */
+
+/*
+ * LAPB, with a one-byte direction pseudo-header prepended - zero means
+ * "received by this host" (DCE -> DTE), non-zero (any non-zero value)
+ * means "sent by this host" (DTE -> DCE)- as per Will Barker
+ * <w.barker@zen.co.uk>.
+ */
 #define LINKTYPE_LAPB_WITH_DIR	207	/* LAPB */
 
 /*
@@ -1081,7 +1110,12 @@
  */
 #define LINKTYPE_DISPLAYPORT_AUX	275
 
-#define LINKTYPE_MATCHING_MAX	275		/* highest value in the "matching" range */
+/*
+ * Linux cooked sockets v2.
+ */
+#define LINKTYPE_LINUX_SLL2	276
+
+#define LINKTYPE_MATCHING_MAX	276		/* highest value in the "matching" range */
 
 /*
  * The DLT_ and LINKTYPE_ values in the "matching" range should be the
@@ -1240,18 +1274,30 @@
 /*
  * Return the maximum snapshot length for a given DLT_ value.
  *
- * For most link-layer types, we use MAXIMUM_SNAPLEN, but for DLT_DBUS,
- * the maximum is 134217728, as per
+ * For most link-layer types, we use MAXIMUM_SNAPLEN.
+ *
+ * For DLT_DBUS, the maximum is 128MiB, as per
  *
  *    https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
+ *
+ * For DLT_USBPCAP, the maximum is 1MiB, as per
+ *
+ *    https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=15985
  */
 u_int
 max_snaplen_for_dlt(int dlt)
 {
-	if (dlt == DLT_DBUS)
-		return 134217728;
-	else
+	switch (dlt) {
+
+	case DLT_DBUS:
+		return 128*1024*1024;
+
+	case DLT_USBPCAP:
+		return 1024*1024;
+
+	default:
 		return MAXIMUM_SNAPLEN;
+	}
 }
 
 /*
diff --git a/pcap-config b/pcap-config
new file mode 100755
index 0000000..29380c4
--- /dev/null
+++ b/pcap-config
@@ -0,0 +1,94 @@
+#! /bin/sh
+
+#
+# Script to give the appropriate compiler flags and linker flags
+# to use when building code that uses libpcap.
+#
+# These variables come from the configure script, so includedir and
+# libdir may be defined in terms of prefix and exec_prefix, so the
+# latter must be defined as well.
+#
+prefix="/usr/local"
+exec_prefix="${prefix}"
+includedir="${prefix}/include"
+libdir="${exec_prefix}/lib"
+V_RPATH_OPT="-Wl,-rpath,"
+LIBS=""
+PACKAGE_NAME="pcap"
+
+static=0
+show_cflags=0
+show_libs=0
+while [ "$#" != 0 ]
+do
+	case "$1" in
+
+	--static)
+		static=1
+		;;
+
+	--cflags)
+		show_cflags=1
+		;;
+
+	--libs)
+		show_libs=1
+		;;
+
+	--additional-libs)
+		show_additional_libs=1
+		;;
+	esac
+	shift
+done
+if [ "$V_RPATH_OPT" != "" ]
+then
+	#
+	# If libdir isn't /usr/lib, add it to the run-time linker path.
+	#
+	if [ "$libdir" != "/usr/lib" ]
+	then
+		RPATH=$V_RPATH_OPT$libdir
+	fi
+fi
+if [ "$static" = 1 ]
+then
+	#
+	# Include LIBS so that the flags include libraries containing
+	# routines that libpcap uses.
+	#
+	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
+	then
+		echo "-I$includedir -L$libdir -lpcap $LIBS"
+	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
+	then
+		echo "-I$includedir -L$libdir $LIBS"
+	elif [ "$show_cflags" = 1 ]
+	then
+		echo "-I$includedir"
+	elif [ "$show_libs" = 1 ]
+	then
+		echo "-L$libdir -lpcap $LIBS"
+	elif [ "$show_additional_libs" = 1 ]
+	then
+		echo "$LIBS"
+	fi
+else
+	#
+	# Omit LIBS - libpcap is assumed to be linked with those
+	# libraries, so there's no need to do so explicitly.
+	#
+	if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
+	then
+		echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
+	elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
+	then
+		echo "-I$includedir"
+	elif [ "$show_cflags" = 1 ]
+	then
+		echo "-I$includedir"
+	elif [ "$show_libs" = 1 ]
+	then
+		echo "-L$libdir $RPATH -l$PACKAGE_NAME"
+	fi
+fi
diff --git a/pcap-dag.c b/pcap-dag.c
index 6b7c791..e076676 100644
--- a/pcap-dag.c
+++ b/pcap-dag.c
@@ -1,14 +1,6 @@
 /*
  * pcap-dag.c: Packet capture interface for Endace DAG cards.
  *
- * The functionality of this code attempts to mimic that of pcap-linux as much
- * as possible.  This code is compiled in several different ways depending on
- * whether DAG_ONLY and HAVE_DAG_API are defined.  If HAVE_DAG_API is not
- * defined it should not get compiled in, otherwise if DAG_ONLY is defined then
- * the 'dag_' function calls are renamed to 'pcap_' equivalents.  If DAG_ONLY
- * is not defined then nothing is altered - the dag_ functions will be
- * called as required from their pcap-linux/bpf equivalents.
- *
  * Authors: Richard Littin, Sean Irvine ({richard,sean}@reeltwo.com)
  * Modifications: Jesper Peterson
  *                Koryn Grant
@@ -258,12 +250,18 @@
 
 	if(pd->dag_ref != NULL) {
 		dag_config_dispose(pd->dag_ref);
+		/*
+		 * Note: we don't need to call close(p->fd) or
+		 * dag_close(p->fd), as dag_config_dispose(pd->dag_ref)
+		 * does this.
+		 *
+		 * Set p->fd to -1 to make sure that's not done.
+		 */
 		p->fd = -1;
 		pd->dag_ref = NULL;
 	}
 	delete_pcap_dag(p);
 	pcap_cleanup_live_common(p);
-	/* Note: don't need to call close(p->fd) or dag_close(p->fd) as dag_config_dispose(pd->dag_ref) does this. */
 }
 
 static void
@@ -722,7 +720,7 @@
 static int
 dag_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
 {
-	strlcpy(p->errbuf, "Sending packets isn't supported on DAG cards",
+	pcap_strlcpy(p->errbuf, "Sending packets isn't supported on DAG cards",
 	    PCAP_ERRBUF_SIZE);
 	return (-1);
 }
@@ -746,18 +744,20 @@
 	daginf_t* daginf;
 	char * newDev = NULL;
 	char * device = p->opt.device;
+	int ret;
 	dag_size_t mindata;
 	struct timeval maxwait;
 	struct timeval poll;
 
 	if (device == NULL) {
 		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "device is NULL");
-		return -1;
+		return PCAP_ERROR;
 	}
 
 	/* Initialize some components of the pcap structure. */
 	newDev = (char *)malloc(strlen(device) + 16);
 	if (newDev == NULL) {
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "Can't allocate string for device name");
 		goto fail;
@@ -765,6 +765,13 @@
 
 	/* Parse input name to get dag device and stream number if provided */
 	if (dag_parse_name(device, newDev, strlen(device) + 16, &pd->dag_stream) < 0) {
+		/*
+		 * XXX - it'd be nice if this indicated what was wrong
+		 * with the name.  Does this reliably set errno?
+		 * Should this return PCAP_ERROR_NO_SUCH_DEVICE in some
+		 * cases?
+		 */
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "dag_parse_name");
 		goto fail;
@@ -772,25 +779,40 @@
 	device = newDev;
 
 	if (pd->dag_stream%2) {
+		ret = PCAP_ERROR;
 		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: tx (even numbered) streams not supported for capture");
 		goto fail;
 	}
 
 	/* setup device parameters */
 	if((pd->dag_ref = dag_config_init((char *)device)) == NULL) {
+		/*
+		 * XXX - does this reliably set errno?
+		 */
+		if (errno == ENOENT)
+			ret = PCAP_ERROR_NO_SUCH_DEVICE;
+		else if (errno == EPERM || errno == EACCES)
+			ret = PCAP_ERROR_PERM_DENIED;
+		else
+			ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "dag_config_init %s", device);
 		goto fail;
 	}
 
 	if((p->fd = dag_config_get_card_fd(pd->dag_ref)) < 0) {
+		/*
+		 * XXX - does this reliably set errno?
+		 */
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "dag_config_get_card_fd %s", device);
-		goto fail;
+		goto failclose;
 	}
 
 	/* Open requested stream. Can fail if already locked or on error */
 	if (dag_attach_stream64(p->fd, pd->dag_stream, 0, 0) < 0) {
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "dag_attach_stream");
 		goto failclose;
@@ -809,6 +831,7 @@
 	 */
 	if (dag_get_stream_poll64(p->fd, pd->dag_stream,
 				&mindata, &maxwait, &poll) < 0) {
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "dag_get_stream_poll");
 		goto faildetach;
@@ -853,6 +876,7 @@
 
 	if (dag_set_stream_poll64(p->fd, pd->dag_stream,
 				mindata, &maxwait, &poll) < 0) {
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "dag_set_stream_poll");
 		goto faildetach;
@@ -875,6 +899,7 @@
 #endif
 
 	if(dag_start_stream(p->fd, pd->dag_stream) < 0) {
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "dag_start_stream %s", device);
 		goto faildetach;
@@ -910,6 +935,7 @@
 			if ((n = atoi(s)) == 0 || n == 16 || n == 32) {
 				pd->dag_fcs_bits = n;
 			} else {
+				ret = PCAP_ERROR;
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 					"pcap_activate %s: bad ERF_FCS_BITS value (%d) in environment", device, n);
 				goto failstop;
@@ -932,12 +958,15 @@
 	pd->dag_timeout	= p->opt.timeout;
 
 	p->linktype = -1;
-	if (dag_get_datalink(p) < 0)
+	if (dag_get_datalink(p) < 0) {
+		ret = PCAP_ERROR;
 		goto failstop;
+	}
 
 	p->bufsize = 0;
 
 	if (new_pcap_dag(p) < 0) {
+		ret = PCAP_ERROR;
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "new_pcap_dag %s", device);
 		goto failstop;
@@ -977,6 +1006,14 @@
 
 failclose:
 	dag_config_dispose(pd->dag_ref);
+	/*
+	 * Note: we don't need to call close(p->fd) or dag_close(p->fd),
+	 * as dag_config_dispose(pd->dag_ref) does this.
+	 *
+	 * Set p->fd to -1 to make sure that's not done.
+	 */
+	p->fd = -1;
+	pd->dag_ref = NULL;
 	delete_pcap_dag(p);
 
 fail:
@@ -985,7 +1022,7 @@
 		free((char *)newDev);
 	}
 
-	return PCAP_ERROR;
+	return ret;
 }
 
 pcap_t *dag_create(const char *device, char *ebuf, int *is_ours)
@@ -1137,7 +1174,7 @@
 			}
 			rxstreams = dag_rx_get_stream_count(dagfd);
 			for(stream=0;stream<DAG_STREAM_MAX;stream+=2) {
-				if (0 == dag_attach_stream(dagfd, stream, 0, 0)) {
+				if (0 == dag_attach_stream64(dagfd, stream, 0, 0)) {
 					dag_detach_stream(dagfd, stream);
 
 					pcap_snprintf(name,  10, "dag%d:%d", c, stream);
diff --git a/pcap-dlpi.c b/pcap-dlpi.c
index 430051e..3ed8fa7 100644
--- a/pcap-dlpi.c
+++ b/pcap-dlpi.c
@@ -307,7 +307,7 @@
 	 * it should check "p->linktype" and reject the send request if
 	 * it's anything other than DLT_EN10MB.
 	 */
-	strlcpy(p->errbuf, "send: Not supported on this version of this OS",
+	pcap_strlcpy(p->errbuf, "send: Not supported on this version of this OS",
 	    PCAP_ERRBUF_SIZE);
 	ret = -1;
 #endif /* raw mode */
@@ -363,9 +363,9 @@
 	*/
 	cp = strrchr(name, '/');
 	if (cp == NULL)
-		strlcpy(dname, name, sizeof(dname));
+		pcap_strlcpy(dname, name, sizeof(dname));
 	else
-		strlcpy(dname, cp + 1, sizeof(dname));
+		pcap_strlcpy(dname, cp + 1, sizeof(dname));
 
 	/*
 	 * Split the device name into a device type name and a unit number;
@@ -415,7 +415,7 @@
 	 * device name.
 	 */
 	if (*name == '/')
-		strlcpy(dname, name, sizeof(dname));
+		pcap_strlcpy(dname, name, sizeof(dname));
 	else
 		pcap_snprintf(dname, sizeof(dname), "%s/%s", PCAP_DEV_PREFIX,
 		    name);
@@ -432,7 +432,7 @@
 	 * Make a copy of the device pathname, and then remove the unit
 	 * number from the device pathname.
 	 */
-	strlcpy(dname2, dname, sizeof(dname));
+	pcap_strlcpy(dname2, dname, sizeof(dname));
 	*cp = '\0';
 
 	/* Try device without unit number */
@@ -968,7 +968,7 @@
 		*ebuf = '\0';
 		hpsap++;
 		if (hpsap > 100) {
-			strlcpy(ebuf,
+			pcap_strlcpy(ebuf,
 			    "All SAPs from 22 through 100 are in use",
 			    PCAP_ERRBUF_SIZE);
 			return (-1);
@@ -1547,7 +1547,7 @@
 	*minorp = 0;
 	*microp = 0;
 	if (sysinfo(SI_RELEASE, buf, bufsize) < 0) {
-		strlcpy(buf, "?", bufsize);
+		pcap_strlcpy(buf, "?", bufsize);
 		return;
 	}
 	cp = buf;
diff --git a/pcap-dos.c b/pcap-dos.c
index b1b9ecd..c159b55 100644
--- a/pcap-dos.c
+++ b/pcap-dos.c
@@ -413,14 +413,14 @@
 
   if (!dev || !dev->get_stats)
   {
-    strlcpy (p->errbuf, "detailed device statistics not available",
+    pcap_strlcpy (p->errbuf, "detailed device statistics not available",
              PCAP_ERRBUF_SIZE);
     return (-1);
   }
 
   if (!strnicmp(dev->name,"pkt",3))
   {
-    strlcpy (p->errbuf, "pktdrvr doesn't have detailed statistics",
+    pcap_strlcpy (p->errbuf, "pktdrvr doesn't have detailed statistics",
              PCAP_ERRBUF_SIZE);
     return (-1);
   }
diff --git a/pcap-filter.manmisc b/pcap-filter.manmisc
index 3548691..d8385f5 100644
--- a/pcap-filter.manmisc
+++ b/pcap-filter.manmisc
@@ -29,11 +29,11 @@
 is used to compile a string into a filter program.
 The resulting filter program can then be applied to
 some stream of packets to determine which packets will be supplied to
-.BR pcap_loop() ,
-.BR pcap_dispatch() ,
-.BR pcap_next() ,
+.BR pcap_loop(3PCAP) ,
+.BR pcap_dispatch(3PCAP) ,
+.BR pcap_next(3PCAP) ,
 or
-.BR pcap_next_ex() .
+.BR pcap_next_ex(3PCAP) .
 .LP
 The \fIfilter expression\fP consists of one or more
 .IR primitives .
@@ -86,12 +86,6 @@
 and
 .B addr4
 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
-For some link layers, such as SLIP and the ``cooked'' Linux capture mode
-used for the ``any'' device and for some other device types, the
-.B inbound
-and
-.B outbound
-qualifiers can be used to specify a desired direction.
 .IP \fIproto\fP
 .I proto
 qualifiers restrict the match to a particular protocol.
@@ -466,8 +460,6 @@
 FDDI packets (no check is done for LLC frames);
 .IP
 LLC-encapsulated ATM packets, for SunATM on Solaris.
-.IP
-
 .IP "\fBllc\fP \Fitype\fR"
 True if the packet has an 802.2 LLC header and has the specified
 .IR type .
@@ -514,6 +506,16 @@
 \fBfrmr\fR
 Frame Reject (FRMR) U PDUs
 .RE
+.IP \fBinbound\fP
+Packet was received by the host performing the capture rather than being
+sent by that host.  This is only supported for certain link-layer types,
+such as SLIP and the ``cooked'' Linux capture mode
+used for the ``any'' device and for some other device types.
+.IP \fBoutbound\fP
+Packet was sent by the host performing the capture rather than being
+received by that host.  This is only supported for certain link-layer types,
+such as SLIP and the ``cooked'' Linux capture mode
+used for the ``any'' device and for some other device types.
 .IP "\fBifname \fIinterface\fR"
 True if the packet was logged as coming from the specified interface (applies
 only to packets logged by OpenBSD's or FreeBSD's
diff --git a/pcap-filter.manmisc.in b/pcap-filter.manmisc.in
index 3232f7e..777e735 100644
--- a/pcap-filter.manmisc.in
+++ b/pcap-filter.manmisc.in
@@ -29,11 +29,11 @@
 is used to compile a string into a filter program.
 The resulting filter program can then be applied to
 some stream of packets to determine which packets will be supplied to
-.BR pcap_loop() ,
-.BR pcap_dispatch() ,
-.BR pcap_next() ,
+.BR pcap_loop(3PCAP) ,
+.BR pcap_dispatch(3PCAP) ,
+.BR pcap_next(3PCAP) ,
 or
-.BR pcap_next_ex() .
+.BR pcap_next_ex(3PCAP) .
 .LP
 The \fIfilter expression\fP consists of one or more
 .IR primitives .
@@ -86,12 +86,6 @@
 and
 .B addr4
 qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
-For some link layers, such as SLIP and the ``cooked'' Linux capture mode
-used for the ``any'' device and for some other device types, the
-.B inbound
-and
-.B outbound
-qualifiers can be used to specify a desired direction.
 .IP \fIproto\fP
 .I proto
 qualifiers restrict the match to a particular protocol.
@@ -466,8 +460,6 @@
 FDDI packets (no check is done for LLC frames);
 .IP
 LLC-encapsulated ATM packets, for SunATM on Solaris.
-.IP
-
 .IP "\fBllc\fP \Fitype\fR"
 True if the packet has an 802.2 LLC header and has the specified
 .IR type .
@@ -514,6 +506,16 @@
 \fBfrmr\fR
 Frame Reject (FRMR) U PDUs
 .RE
+.IP \fBinbound\fP
+Packet was received by the host performing the capture rather than being
+sent by that host.  This is only supported for certain link-layer types,
+such as SLIP and the ``cooked'' Linux capture mode
+used for the ``any'' device and for some other device types.
+.IP \fBoutbound\fP
+Packet was sent by the host performing the capture rather than being
+received by that host.  This is only supported for certain link-layer types,
+such as SLIP and the ``cooked'' Linux capture mode
+used for the ``any'' device and for some other device types.
 .IP "\fBifname \fIinterface\fR"
 True if the packet was logged as coming from the specified interface (applies
 only to packets logged by OpenBSD's or FreeBSD's
diff --git a/pcap-int.h b/pcap-int.h
index 5888df7..5295f8f 100644
--- a/pcap-int.h
+++ b/pcap-int.h
@@ -86,7 +86,12 @@
  *    2) small enough not to cause attempts to allocate huge amounts of
  *       memory; some applications might use the snapshot length in a
  *       savefile header to control the size of the buffer they allocate,
- *       so a size of, say, 2^31-1 might not work well.
+ *       so a size of, say, 2^31-1 might not work well.  (libpcap uses it
+ *       as a hint, but doesn't start out allocating a buffer bigger than
+ *       2 KiB, and grows the buffer as necessary, but not beyond the
+ *       per-linktype maximum snapshot length.  Other code might naively
+ *       use it; we want to avoid writing a too-large snapshot length,
+ *       in order not to cause that code problems.)
  *
  * We don't enforce this in pcap_set_snaplen(), but we use it internally.
  */
@@ -472,14 +477,39 @@
  * "pcap_open_offline_common()" allocates and fills in a pcap_t, for use
  * by pcap_open_offline routines.
  *
+ * "pcap_adjust_snapshot()" adjusts the snapshot to be non-zero and
+ * fit within an int.
+ *
  * "sf_cleanup()" closes the file handle associated with a pcap_t, if
  * appropriate, and frees all data common to all modules for handling
  * savefile types.
  */
 pcap_t	*pcap_open_offline_common(char *ebuf, size_t size);
+bpf_u_int32 pcap_adjust_snapshot(bpf_u_int32 linktype, bpf_u_int32 snaplen);
 void	sf_cleanup(pcap_t *p);
 
 /*
+ * Internal interfaces for doing user-mode filtering of packets and
+ * validating filter programs.
+ */
+/*
+ * Auxiliary data, for use when interpreting a filter intended for the
+ * Linux kernel when the kernel rejects the filter (requiring us to
+ * run it in userland).  It contains VLAN tag information.
+ */
+struct bpf_aux_data {
+	u_short vlan_tag_present;
+	u_short vlan_tag;
+};
+
+/*
+ * Filtering routine that takes the auxiliary data as an additional
+ * argument.
+ */
+u_int	bpf_filter_with_aux_data(const struct bpf_insn *,
+    const u_char *, u_int, u_int, const struct bpf_aux_data *);
+
+/*
  * Internal interfaces for both "pcap_create()" and routines that
  * open savefiles.
  *
@@ -488,10 +518,6 @@
  */
 void	pcap_oneshot(u_char *, const struct pcap_pkthdr *, const u_char *);
 
-#ifdef _WIN32
-void	pcap_win32_err_to_str(DWORD, char *);
-#endif
-
 int	install_bpf_program(pcap_t *, struct bpf_program *);
 
 int	pcap_strcasecmp(const char *, const char *);
diff --git a/pcap-libdlpi.c b/pcap-libdlpi.c
index a0d1669..a38da8b 100644
--- a/pcap-libdlpi.c
+++ b/pcap-libdlpi.c
@@ -80,7 +80,7 @@
 		lwp->lw_err = ENOMEM;
 		return (B_TRUE);
 	}
-	(void) strlcpy(entry->linkname, linkname, DLPI_LINKNAME_MAX);
+	(void) pcap_strlcpy(entry->linkname, linkname, DLPI_LINKNAME_MAX);
 
 	if (lwp->lw_list == NULL) {
 		lwp->lw_list = entry;
diff --git a/pcap-linktype.manmisc b/pcap-linktype.manmisc
index 20f2ea2..a0dc167 100644
--- a/pcap-linktype.manmisc
+++ b/pcap-linktype.manmisc
@@ -45,4 +45,4 @@
 The link-layer header types supported by libpcap are described at
 https://www.tcpdump.org/linktypes.html.
 .SH SEE ALSO
-pcap_datalink(3PCAP)
+pcap(3PCAP)
diff --git a/pcap-linktype.manmisc.in b/pcap-linktype.manmisc.in
index 68919a7..777e9dc 100644
--- a/pcap-linktype.manmisc.in
+++ b/pcap-linktype.manmisc.in
@@ -45,4 +45,4 @@
 The link-layer header types supported by libpcap are described at
 https://www.tcpdump.org/linktypes.html.
 .SH SEE ALSO
-pcap_datalink(3PCAP)
+pcap(3PCAP)
diff --git a/pcap-linux.c b/pcap-linux.c
index 49144b6..70334b3 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -339,9 +339,6 @@
 static int get_if_flags(const char *, bpf_u_int32 *, char *);
 static int is_wifi(int, const char *);
 static void map_arphrd_to_dlt(pcap_t *, int, int, const char *, int);
-#ifdef HAVE_PF_PACKET_SOCKETS
-static short int map_packet_type_to_sll_type(short int);
-#endif
 static int pcap_activate_linux(pcap_t *);
 static int activate_old(pcap_t *);
 static int activate_new(pcap_t *);
@@ -486,7 +483,7 @@
 #ifdef SO_ATTACH_FILTER
 static int	fix_program(pcap_t *handle, struct sock_fprog *fcode,
     int is_mapped);
-static int	fix_offset(struct bpf_insn *p);
+static int	fix_offset(pcap_t *handle, struct bpf_insn *p);
 static int	set_kernel_filter(pcap_t *handle, struct sock_fprog *fcode);
 static int	reset_kernel_filter(pcap_t *handle);
 
@@ -977,7 +974,7 @@
 	 * Now configure the monitor interface up.
 	 */
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, handlep->mondevice, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, handlep->mondevice, sizeof(ifr.ifr_name));
 	if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) == -1) {
 		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "%s: Can't get flags for %s", device,
@@ -1038,7 +1035,7 @@
 	ifbond ifb;
 
 	memset(&ifr, 0, sizeof ifr);
-	strlcpy(ifr.ifr_name, device, sizeof ifr.ifr_name);
+	pcap_strlcpy(ifr.ifr_name, device, sizeof ifr.ifr_name);
 	memset(&ifb, 0, sizeof ifb);
 	ifr.ifr_data = (caddr_t)&ifb;
 	if (ioctl(fd, BOND_INFO_QUERY_IOCTL, &ifr) == 0)
@@ -1127,7 +1124,7 @@
 	/*
 	 * Attempt to get the current mode.
 	 */
-	strlcpy(ireq.ifr_ifrn.ifrn_name, handle->opt.device,
+	pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, handle->opt.device,
 	    sizeof ireq.ifr_ifrn.ifrn_name);
 	if (ioctl(sock_fd, SIOCGIWMODE, &ireq) != -1) {
 		/*
@@ -1160,16 +1157,16 @@
 linux_if_drops(const char * if_name)
 {
 	char buffer[512];
-	char * bufptr;
-	FILE * file;
-	int field_to_convert = 3, if_name_sz = strlen(if_name);
+	FILE *file;
+	char *bufptr, *nameptr, *colonptr;
+	int field_to_convert = 3;
 	long int dropped_pkts = 0;
 
 	file = fopen("/proc/net/dev", "r");
 	if (!file)
 		return 0;
 
-	while (!dropped_pkts && fgets( buffer, sizeof(buffer), file ))
+	while (fgets(buffer, sizeof(buffer), file) != NULL)
 	{
 		/* 	search for 'bytes' -- if its in there, then
 			that means we need to grab the fourth field. otherwise
@@ -1180,26 +1177,71 @@
 			continue;
 		}
 
-		/* find iface and make sure it actually matches -- space before the name and : after it */
-		if ((bufptr = strstr(buffer, if_name)) &&
-			(bufptr == buffer || *(bufptr-1) == ' ') &&
-			*(bufptr + if_name_sz) == ':')
+		/*
+		 * See whether this line corresponds to this device.
+		 * The line should have zero or more leading blanks,
+		 * followed by a device name, followed by a colon,
+		 * followed by the statistics.
+		 */
+		bufptr = buffer;
+		/* Skip leading blanks */
+		while (*bufptr == ' ')
+			bufptr++;
+		nameptr = bufptr;
+		/* Look for the colon */
+		colonptr = strchr(nameptr, ':');
+		if (colonptr == NULL)
 		{
-			bufptr = bufptr + if_name_sz + 1;
+			/*
+			 * Not found; this could, for example, be the
+			 * header line.
+			 */
+			continue;
+		}
+		/* Null-terminate the interface name. */
+		*colonptr = '\0';
+		if (strcmp(if_name, nameptr) == 0)
+		{
+			/*
+			 * OK, this line has the statistics for the interface.
+			 * Skip past the interface name.
+			 */
+			bufptr = colonptr + 1;
 
 			/* grab the nth field from it */
-			while( --field_to_convert && *bufptr != '\0')
+			while (--field_to_convert && *bufptr != '\0')
 			{
-				while (*bufptr != '\0' && *(bufptr++) == ' ');
-				while (*bufptr != '\0' && *(bufptr++) != ' ');
+				/*
+				 * This isn't the field we want.
+				 * First, skip any leading blanks before
+				 * the field.
+				 */
+				while (*bufptr == ' ')
+					bufptr++;
+
+				/*
+				 * Now skip the non-blank characters of
+				 * the field.
+				 */
+				while (*bufptr != '\0' && *bufptr != ' ')
+					bufptr++;
 			}
 
-			/* get rid of any final spaces */
-			while (*bufptr != '\0' && *bufptr == ' ') bufptr++;
+			if (field_to_convert == 0)
+			{
+				/*
+				 * We've found the field we want.
+				 * Skip any leading blanks before it.
+				 */
+				while (*bufptr == ' ')
+					bufptr++;
 
-			if (*bufptr != '\0')
-				dropped_pkts = strtol(bufptr, NULL, 10);
-
+				/*
+				 * Now extract the value, if we have one.
+				 */
+				if (*bufptr != '\0')
+					dropped_pkts = strtol(bufptr, NULL, 10);
+			}
 			break;
 		}
 	}
@@ -1250,7 +1292,7 @@
 			 * in 2.0[.x] kernels.
 			 */
 			memset(&ifr, 0, sizeof(ifr));
-			strlcpy(ifr.ifr_name, handlep->device,
+			pcap_strlcpy(ifr.ifr_name, handlep->device,
 			    sizeof(ifr.ifr_name));
 			if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) == -1) {
 				fprintf(stderr,
@@ -1314,7 +1356,7 @@
 			 */
 			oldflags = 0;
 			memset(&ifr, 0, sizeof(ifr));
-			strlcpy(ifr.ifr_name, handlep->device,
+			pcap_strlcpy(ifr.ifr_name, handlep->device,
 			    sizeof(ifr.ifr_name));
 			if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) != -1) {
 				if (ifr.ifr_flags & IFF_UP) {
@@ -1328,7 +1370,7 @@
 			/*
 			 * Now restore the mode.
 			 */
-			strlcpy(ireq.ifr_ifrn.ifrn_name, handlep->device,
+			pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, handlep->device,
 			    sizeof ireq.ifr_ifrn.ifrn_name);
 			ireq.u.mode = handlep->oldmode;
 			if (ioctl(handle->fd, SIOCSIWMODE, &ireq) == -1) {
@@ -1538,7 +1580,8 @@
 	if (handlep->device == NULL) {
 		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "strdup");
-		return PCAP_ERROR;
+		status = PCAP_ERROR;
+		goto fail;
 	}
 
 	/* copy timeout value */
@@ -1602,11 +1645,10 @@
 			/*
 			 * We failed to set up to use it, or the kernel
 			 * supports it, but we failed to enable it.
-			 * ret has been set to the error status to
+			 * status has been set to the error status to
 			 * return and, if it's PCAP_ERROR, handle->errbuf
 			 * contains the error message.
 			 */
-			status = ret;
 			goto fail;
 		}
 	}
@@ -1750,7 +1792,6 @@
 	int			offset;
 #ifdef HAVE_PF_PACKET_SOCKETS
 	struct sockaddr_ll	from;
-	struct sll_header	*hdrp;
 #else
 	struct sockaddr		from;
 #endif
@@ -1774,9 +1815,12 @@
 	 * If this is a cooked device, leave extra room for a
 	 * fake packet header.
 	 */
-	if (handlep->cooked)
-		offset = SLL_HDR_LEN;
-	else
+	if (handlep->cooked) {
+		if (handle->linktype == DLT_LINUX_SLL2)
+			offset = SLL2_HDR_LEN;
+		else
+			offset = SLL_HDR_LEN;
+	} else
 		offset = 0;
 #else
 	/*
@@ -1906,17 +1950,37 @@
 		 * Add the length of the fake header to the length
 		 * of packet data we read.
 		 */
-		packet_len += SLL_HDR_LEN;
+		if (handle->linktype == DLT_LINUX_SLL2) {
+			struct sll2_header	*hdrp;
 
-		hdrp = (struct sll_header *)bp;
-		hdrp->sll_pkttype = map_packet_type_to_sll_type(from.sll_pkttype);
-		hdrp->sll_hatype = htons(from.sll_hatype);
-		hdrp->sll_halen = htons(from.sll_halen);
-		memcpy(hdrp->sll_addr, from.sll_addr,
-		    (from.sll_halen > SLL_ADDRLEN) ?
-		      SLL_ADDRLEN :
-		      from.sll_halen);
-		hdrp->sll_protocol = from.sll_protocol;
+			packet_len += SLL2_HDR_LEN;
+
+			hdrp = (struct sll2_header *)bp;
+			hdrp->sll2_protocol = from.sll_protocol;
+			hdrp->sll2_reserved_mbz = 0;
+			hdrp->sll2_if_index = htonl(from.sll_ifindex);
+			hdrp->sll2_hatype = htons(from.sll_hatype);
+			hdrp->sll2_pkttype = from.sll_pkttype;
+			hdrp->sll2_halen = from.sll_halen;
+			memcpy(hdrp->sll2_addr, from.sll_addr,
+			    (from.sll_halen > SLL_ADDRLEN) ?
+			      SLL_ADDRLEN :
+			      from.sll_halen);
+		} else {
+			struct sll_header	*hdrp;
+
+			packet_len += SLL_HDR_LEN;
+
+			hdrp = (struct sll_header *)bp;
+			hdrp->sll_pkttype = htons(from.sll_pkttype);
+			hdrp->sll_hatype = htons(from.sll_hatype);
+			hdrp->sll_halen = htons(from.sll_halen);
+			memcpy(hdrp->sll_addr, from.sll_addr,
+			    (from.sll_halen > SLL_ADDRLEN) ?
+			      SLL_ADDRLEN :
+			      from.sll_halen);
+			hdrp->sll_protocol = from.sll_protocol;
+		}
 	}
 
 	/*
@@ -2121,7 +2185,7 @@
 			/*
 			 * We don't support sending on the "any" device.
 			 */
-			strlcpy(handle->errbuf,
+			pcap_strlcpy(handle->errbuf,
 			    "Sending packets isn't supported on the \"any\" device",
 			    PCAP_ERRBUF_SIZE);
 			return (-1);
@@ -2129,13 +2193,13 @@
 
 		if (handlep->cooked) {
 			/*
-			 * We don't support sending on the "any" device.
+			 * We don't support sending on cooked-mode sockets.
 			 *
 			 * XXX - how do you send on a bound cooked-mode
 			 * socket?
 			 * Is a "sendto()" required there?
 			 */
-			strlcpy(handle->errbuf,
+			pcap_strlcpy(handle->errbuf,
 			    "Sending packets isn't supported in cooked mode",
 			    PCAP_ERRBUF_SIZE);
 			return (-1);
@@ -2349,7 +2413,7 @@
 	/*
 	 * Get the flags for this interface.
 	 */
-	strlcpy(ifrflags.ifr_name, name, sizeof(ifrflags.ifr_name));
+	pcap_strlcpy(ifrflags.ifr_name, name, sizeof(ifrflags.ifr_name));
 	if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
 		if (errno == ENXIO || errno == ENODEV)
 			return (0);	/* device doesn't actually exist - ignore it */
@@ -2708,7 +2772,7 @@
 
 #ifdef ETHTOOL_GLINK
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
 	info.cmd = ETHTOOL_GLINK;
 	ifr.ifr_data = (caddr_t)&info;
 	if (ioctl(sock, SIOCETHTOOL, &ifr) == -1) {
@@ -2836,7 +2900,7 @@
 	if (!handle)
 		return -1;
 	if (!filter) {
-	        strlcpy(handle->errbuf, "setfilter: No filter specified",
+	        pcap_strlcpy(handle->errbuf, "setfilter: No filter specified",
 			PCAP_ERRBUF_SIZE);
 		return -1;
 	}
@@ -3025,41 +3089,6 @@
 	return -1;
 }
 
-#ifdef HAVE_PF_PACKET_SOCKETS
-/*
- * Map the PACKET_ value to a LINUX_SLL_ value; we
- * want the same numerical value to be used in
- * the link-layer header even if the numerical values
- * for the PACKET_ #defines change, so that programs
- * that look at the packet type field will always be
- * able to handle DLT_LINUX_SLL captures.
- */
-static short int
-map_packet_type_to_sll_type(short int sll_pkttype)
-{
-	switch (sll_pkttype) {
-
-	case PACKET_HOST:
-		return htons(LINUX_SLL_HOST);
-
-	case PACKET_BROADCAST:
-		return htons(LINUX_SLL_BROADCAST);
-
-	case PACKET_MULTICAST:
-		return  htons(LINUX_SLL_MULTICAST);
-
-	case PACKET_OTHERHOST:
-		return htons(LINUX_SLL_OTHERHOST);
-
-	case PACKET_OUTGOING:
-		return htons(LINUX_SLL_OUTGOING);
-
-	default:
-		return -1;
-	}
-}
-#endif
-
 static int
 is_wifi(int sock_fd
 #ifndef IW_MODE_MONITOR
@@ -3558,6 +3587,45 @@
 
 /* ===== Functions to interface to the newer kernels ================== */
 
+#ifdef PACKET_RESERVE
+static void
+set_dlt_list_cooked(pcap_t *handle, int sock_fd)
+{
+	socklen_t		len;
+	unsigned int		tp_reserve;
+
+	/*
+	 * If we can't do PACKET_RESERVE, we can't reserve extra space
+	 * for a DLL_LINUX_SLL2 header, so we can't support DLT_LINUX_SLL2.
+	 */
+	len = sizeof(tp_reserve);
+	if (getsockopt(sock_fd, SOL_PACKET, PACKET_RESERVE, &tp_reserve,
+	    &len) == 0) {
+	    	/*
+	    	 * Yes, we can do DLL_LINUX_SLL2.
+	    	 */
+		handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
+		/*
+		 * If that fails, just leave the list empty.
+		 */
+		if (handle->dlt_list != NULL) {
+			handle->dlt_list[0] = DLT_LINUX_SLL;
+			handle->dlt_list[1] = DLT_LINUX_SLL2;
+			handle->dlt_count = 2;
+		}
+	}
+}
+#else
+/*
+ * The build environment doesn't define PACKET_RESERVE, so we can't reserve
+ * extra space for a DLL_LINUX_SLL2 header, so we can't support DLT_LINUX_SLL2.
+ */
+static void
+set_dlt_list_cooked(pcap_t *handle _U_, int sock_fd _U_)
+{
+}
+#endif
+
 /*
  * Try to open a packet socket using the new kernel PF_PACKET interface.
  * Returns 1 on success, 0 on an error that means the new interface isn't
@@ -3573,7 +3641,7 @@
 	const char		*device = handle->opt.device;
 	int			is_any_device = (strcmp(device, "any") == 0);
 	int			protocol = pcap_protocol(handle);
-	int			sock_fd = -1, arptype;
+	int			sock_fd = -1, arptype, ret;
 #ifdef HAVE_PACKET_AUXDATA
 	int			val;
 #endif
@@ -3602,21 +3670,21 @@
 			 */
 			return 0;
 		}
-
-		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
-		    errno, "socket");
 		if (errno == EPERM || errno == EACCES) {
 			/*
 			 * You don't have permission to open the
 			 * socket.
 			 */
-			return PCAP_ERROR_PERM_DENIED;
+			ret = PCAP_ERROR_PERM_DENIED;
 		} else {
 			/*
 			 * Other error.
 			 */
-			return PCAP_ERROR;
+			ret = PCAP_ERROR;
 		}
+		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
+		    errno, "socket");
+		return ret;
 	}
 
 	/* It seems the kernel supports the new interface. */
@@ -3711,20 +3779,21 @@
 			}
 			sock_fd = socket(PF_PACKET, SOCK_DGRAM, protocol);
 			if (sock_fd == -1) {
-				pcap_fmt_errmsg_for_errno(handle->errbuf,
-				    PCAP_ERRBUF_SIZE, errno, "socket");
 				if (errno == EPERM || errno == EACCES) {
 					/*
 					 * You don't have permission to
 					 * open the socket.
 					 */
-					return PCAP_ERROR_PERM_DENIED;
+					ret = PCAP_ERROR_PERM_DENIED;
 				} else {
 					/*
 					 * Other error.
 					 */
-					return PCAP_ERROR;
+					ret = PCAP_ERROR;
 				}
+				pcap_fmt_errmsg_for_errno(handle->errbuf,
+				    PCAP_ERRBUF_SIZE, errno, "socket");
+				return ret;
 			}
 			handlep->cooked = 1;
 
@@ -3737,6 +3806,7 @@
 				free(handle->dlt_list);
 				handle->dlt_list = NULL;
 				handle->dlt_count = 0;
+				set_dlt_list_cooked(handle, sock_fd);
 			}
 
 			if (handle->linktype == -1) {
@@ -3797,6 +3867,9 @@
 		 */
 		handlep->cooked = 1;
 		handle->linktype = DLT_LINUX_SLL;
+		handle->dlt_list = NULL;
+		handle->dlt_count = 0;
+		set_dlt_list_cooked(handle, sock_fd);
 
 		/*
 		 * We're not bound to a device.
@@ -3837,7 +3910,7 @@
 		if (setsockopt(sock_fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
 		    &mr, sizeof(mr)) == -1) {
 			pcap_fmt_errmsg_for_errno(handle->errbuf,
-			    PCAP_ERRBUF_SIZE, errno, "setsockopt");
+			    PCAP_ERRBUF_SIZE, errno, "setsockopt (PACKET_ADD_MEMBERSHIP)");
 			close(sock_fd);
 			return PCAP_ERROR;
 		}
@@ -3850,7 +3923,7 @@
 	if (setsockopt(sock_fd, SOL_PACKET, PACKET_AUXDATA, &val,
 		       sizeof(val)) == -1 && errno != ENOPROTOOPT) {
 		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
-		    errno, "setsockopt");
+		    errno, "setsockopt (PACKET_AUXDATA)");
 		close(sock_fd);
 		return PCAP_ERROR;
 	}
@@ -3870,10 +3943,14 @@
 	 * large enough to hold a "cooked mode" header plus
 	 * 1 byte of packet data (so we don't pass a byte
 	 * count of 0 to "recvfrom()").
+	 * XXX - we don't know whether this will be DLT_LINUX_SLL
+	 * or DLT_LINUX_SLL2, so make sure it's big enough for
+	 * a DLT_LINUX_SLL2 "cooked mode" header; a snapshot length
+	 * that small is silly anyway.
 	 */
 	if (handlep->cooked) {
-		if (handle->snapshot < SLL_HDR_LEN + 1)
-			handle->snapshot = SLL_HDR_LEN + 1;
+		if (handle->snapshot < SLL2_HDR_LEN + 1)
+			handle->snapshot = SLL2_HDR_LEN + 1;
 	}
 	handle->bufsize = handle->snapshot;
 
@@ -3940,7 +4017,7 @@
 
 	return 1;
 #else /* HAVE_PF_PACKET_SOCKETS */
-	strlcpy(ebuf,
+	pcap_strlcpy(ebuf,
 		"New packet capturing interface not supported by build "
 		"environment", PCAP_ERRBUF_SIZE);
 	return 0;
@@ -4070,10 +4147,20 @@
 	/*
 	 * Probe whether kernel supports the specified TPACKET version;
 	 * this also gets the length of the header for that version.
+	 *
+	 * This socket option was introduced in 2.6.27, which was
+	 * also the first release with TPACKET_V2 support.
 	 */
 	if (getsockopt(handle->fd, SOL_PACKET, PACKET_HDRLEN, &val, &len) < 0) {
-		if (errno == ENOPROTOOPT || errno == EINVAL)
+		if (errno == ENOPROTOOPT || errno == EINVAL) {
+			/*
+			 * ENOPROTOOPT means the kernel is too old to
+			 * support PACKET_HDRLEN at all, which means
+			 * it either doesn't support TPACKET at all
+			 * or supports  only TPACKET_V1.
+			 */
 			return 1;	/* no */
+		}
 
 		/* Failed to even find out; this is a fatal error. */
 		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
@@ -4092,7 +4179,10 @@
 	}
 	handlep->tp_version = version;
 
-	/* Reserve space for VLAN tag reconstruction */
+	/*
+	 * Reserve space for VLAN tag reconstruction.
+	 * This option was also introduced in 2.6.27.
+	 */
 	val = VLAN_TAG_LEN;
 	if (setsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE, &val,
 			   sizeof(val)) < 0) {
@@ -4203,7 +4293,10 @@
 #endif /* HAVE_TPACKET2 */
 
 	/*
-	 * OK, we're using TPACKET_V1, as that's all the kernel supports.
+	 * OK, we're using TPACKET_V1, as either that's all the kernel
+	 * supports or it doesn't support TPACKET at all.  In the latter
+	 * case, create_ring() will fail, and we'll fall back on non-
+	 * memory-mapped capture.
 	 */
 	handlep->tp_version = TPACKET_V1;
 	handlep->tp_hdrlen = sizeof(struct tpacket_hdr);
@@ -4359,7 +4452,7 @@
 		if (getsockopt(handle->fd, SOL_SOCKET, SO_TYPE, &sk_type,
 		    &len) < 0) {
 			pcap_fmt_errmsg_for_errno(handle->errbuf,
-			    PCAP_ERRBUF_SIZE, errno, "getsockopt");
+			    PCAP_ERRBUF_SIZE, errno, "getsockopt (SO_TYPE)");
 			*status = PCAP_ERROR;
 			return -1;
 		}
@@ -4374,14 +4467,50 @@
 				 * as best we can.
 				 */
 				pcap_fmt_errmsg_for_errno(handle->errbuf,
-				    PCAP_ERRBUF_SIZE, errno, "getsockopt");
+				    PCAP_ERRBUF_SIZE, errno,
+				    "getsockopt (PACKET_RESERVE)");
 				*status = PCAP_ERROR;
 				return -1;
 			}
-			tp_reserve = 0;	/* older kernel, reserve not supported */
+			/*
+			 * Older kernel, so we can't use PACKET_RESERVE;
+			 * this means we can't reserver extra space
+			 * for a DLT_LINUX_SLL2 header.
+			 */
+			tp_reserve = 0;
+		} else {
+			/*
+			 * We can reserve extra space for a DLT_LINUX_SLL2
+			 * header.  Do so.
+			 *
+			 * XXX - we assume that the kernel is still adding
+			 * 16 bytes of extra space; that happens to
+			 * correspond to SLL_HDR_LEN (whether intentionally
+			 * or not - the kernel code has a raw "16" in
+			 * the expression), so we subtract SLL_HDR_LEN
+			 * from SLL2_HDR_LEN to get the additional space
+			 * needed.
+			 *
+			 * XXX - should we use TPACKET_ALIGN(SLL2_HDR_LEN - SLL_HDR_LEN)?
+			 */
+			tp_reserve += SLL2_HDR_LEN - SLL_HDR_LEN;
+			len = sizeof(tp_reserve);
+			if (setsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE,
+			    &tp_reserve, len) < 0) {
+				pcap_fmt_errmsg_for_errno(handle->errbuf,
+				    PCAP_ERRBUF_SIZE, errno,
+				    "setsockopt (PACKET_RESERVE)");
+				*status = PCAP_ERROR;
+				return -1;
+			}
 		}
 #else
-		tp_reserve = 0;	/* older kernel, reserve not supported */
+		/*
+		 * Build environment for an older kernel, so we can't
+		 * use PACKET_RESERVE; this means we can't reserve
+		 * extra space for a DLT_LINUX_SLL2 header.
+		 */
+		tp_reserve = 0;
 #endif
 		maclen = (sk_type == SOCK_DGRAM) ? 0 : MAX_LINKHEADER_SIZE;
 			/* XXX: in the kernel maclen is calculated from
@@ -4425,6 +4554,49 @@
 
 #ifdef HAVE_TPACKET3
 	case TPACKET_V3:
+		/*
+		 * If we have TPACKET_V3, we have PACKET_RESERVE.
+		 */
+		len = sizeof(tp_reserve);
+		if (getsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE,
+		    &tp_reserve, &len) < 0) {
+			/*
+			 * Even ENOPROTOOPT is an error - we wouldn't
+			 * be here if the kernel didn't support
+			 * TPACKET_V3, which means it supports
+			 * PACKET_RESERVE.
+			 */
+			pcap_fmt_errmsg_for_errno(handle->errbuf,
+			    PCAP_ERRBUF_SIZE, errno,
+			    "getsockopt (PACKET_RESERVE)");
+			*status = PCAP_ERROR;
+			return -1;
+		}
+		/*
+		 * We can reserve extra space for a DLT_LINUX_SLL2
+		 * header.  Do so.
+		 *
+		 * XXX - we assume that the kernel is still adding
+		 * 16 bytes of extra space; that happens to
+		 * correspond to SLL_HDR_LEN (whether intentionally
+		 * or not - the kernel code has a raw "16" in
+		 * the expression), so we subtract SLL_HDR_LEN
+		 * from SLL2_HDR_LEN to get the additional space
+		 * needed.
+		 *
+		 * XXX - should we use TPACKET_ALIGN(SLL2_HDR_LEN - SLL_HDR_LEN)?
+		 */
+		tp_reserve += SLL2_HDR_LEN - SLL_HDR_LEN;
+		len = sizeof(tp_reserve);
+		if (setsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE,
+                    &tp_reserve, len) < 0) {
+			pcap_fmt_errmsg_for_errno(handle->errbuf,
+			    PCAP_ERRBUF_SIZE, errno,
+			    "setsockopt (PACKET_RESERVE)");
+			*status = PCAP_ERROR;
+			return -1;
+		}
+
 		/* The "frames" for this are actually buffers that
 		 * contain multiple variable-sized frames.
 		 *
@@ -4496,7 +4668,7 @@
 		hwconfig.rx_filter = HWTSTAMP_FILTER_ALL;
 
 		memset(&ifr, 0, sizeof(ifr));
-		strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name));
+		pcap_strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name));
 		ifr.ifr_data = (void *)&hwconfig;
 
 		if (ioctl(handle->fd, SIOCSHWTSTAMP, &ifr) < 0) {
@@ -4580,7 +4752,26 @@
 
 #ifdef HAVE_TPACKET3
 	/* timeout value to retire block - use the configured buffering timeout, or default if <0. */
-	req.tp_retire_blk_tov = (handlep->timeout>=0)?handlep->timeout:0;
+	if (handlep->timeout > 0) {
+		/* Use the user specified timeout as the block timeout */
+		req.tp_retire_blk_tov = handlep->timeout;
+	} else if (handlep->timeout == 0) {
+		/*
+		 * In pcap, this means "infinite timeout"; TPACKET_V3
+		 * doesn't support that, so just set it to UINT_MAX
+		 * milliseconds.  In the TPACKET_V3 loop, if the
+		 * timeout is 0, and we haven't yet seen any packets,
+		 * and we block and still don't have any packets, we
+		 * keep blocking until we do.
+		 */
+		req.tp_retire_blk_tov = UINT_MAX;
+	} else {
+		/*
+		 * XXX - this is not valid; use 0, meaning "have the
+		 * kernel pick a default", for now.
+		 */
+		req.tp_retire_blk_tov = 0;
+	}
 	/* private data not used */
 	req.tp_sizeof_priv = 0;
 	/* Rx ring - feature request bits - none (rxhash will not be filled) */
@@ -4908,13 +5099,27 @@
 	struct sockaddr_ll *sll;
 	struct pcap_pkthdr pcaphdr;
 	unsigned int snaplen = tp_snaplen;
+	struct utsname utsname;
 
 	/* perform sanity check on internal offset. */
 	if (tp_mac + tp_snaplen > handle->bufsize) {
-		pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
-			"corrupted frame on kernel ring mac "
-			"offset %u + caplen %u > frame len %d",
-			tp_mac, tp_snaplen, handle->bufsize);
+		/*
+		 * Report some system information as a debugging aid.
+		 */
+		if (uname(&utsname) != -1) {
+			pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+				"corrupted frame on kernel ring mac "
+				"offset %u + caplen %u > frame len %d "
+				"(kernel %.32s version %s, machine %.16s)",
+				tp_mac, tp_snaplen, handle->bufsize,
+				utsname.release, utsname.version,
+				utsname.machine);
+		} else {
+			pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+				"corrupted frame on kernel ring mac "
+				"offset %u + caplen %u > frame len %d",
+				tp_mac, tp_snaplen, handle->bufsize);
+		}
 		return -1;
 	}
 
@@ -4932,44 +5137,85 @@
 	/* if required build in place the sll header*/
 	sll = (void *)frame + TPACKET_ALIGN(handlep->tp_hdrlen);
 	if (handlep->cooked) {
-		struct sll_header *hdrp;
+		if (handle->linktype == DLT_LINUX_SLL2) {
+			struct sll2_header *hdrp;
 
-		/*
-		 * The kernel should have left us with enough
-		 * space for an sll header; back up the packet
-		 * data pointer into that space, as that'll be
-		 * the beginning of the packet we pass to the
-		 * callback.
-		 */
-		bp -= SLL_HDR_LEN;
+			/*
+			 * The kernel should have left us with enough
+			 * space for an sll header; back up the packet
+			 * data pointer into that space, as that'll be
+			 * the beginning of the packet we pass to the
+			 * callback.
+			 */
+			bp -= SLL2_HDR_LEN;
 
-		/*
-		 * Let's make sure that's past the end of
-		 * the tpacket header, i.e. >=
-		 * ((u_char *)thdr + TPACKET_HDRLEN), so we
-		 * don't step on the header when we construct
-		 * the sll header.
-		 */
-		if (bp < (u_char *)frame +
-				   TPACKET_ALIGN(handlep->tp_hdrlen) +
-				   sizeof(struct sockaddr_ll)) {
-			pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
-				"cooked-mode frame doesn't have room for sll header");
-			return -1;
+			/*
+			 * Let's make sure that's past the end of
+			 * the tpacket header, i.e. >=
+			 * ((u_char *)thdr + TPACKET_HDRLEN), so we
+			 * don't step on the header when we construct
+			 * the sll header.
+			 */
+			if (bp < (u_char *)frame +
+					   TPACKET_ALIGN(handlep->tp_hdrlen) +
+					   sizeof(struct sockaddr_ll)) {
+				pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+					"cooked-mode frame doesn't have room for sll header");
+				return -1;
+			}
+
+			/*
+			 * OK, that worked; construct the sll header.
+			 */
+			hdrp = (struct sll2_header *)bp;
+			hdrp->sll2_protocol = sll->sll_protocol;
+			hdrp->sll2_reserved_mbz = 0;
+			hdrp->sll2_if_index = htonl(sll->sll_ifindex);
+			hdrp->sll2_hatype = htons(sll->sll_hatype);
+			hdrp->sll2_pkttype = sll->sll_pkttype;
+			hdrp->sll2_halen = sll->sll_halen;
+			memcpy(hdrp->sll2_addr, sll->sll_addr, SLL_ADDRLEN);
+
+			snaplen += sizeof(struct sll2_header);
+		} else {
+			struct sll_header *hdrp;
+
+			/*
+			 * The kernel should have left us with enough
+			 * space for an sll header; back up the packet
+			 * data pointer into that space, as that'll be
+			 * the beginning of the packet we pass to the
+			 * callback.
+			 */
+			bp -= SLL_HDR_LEN;
+
+			/*
+			 * Let's make sure that's past the end of
+			 * the tpacket header, i.e. >=
+			 * ((u_char *)thdr + TPACKET_HDRLEN), so we
+			 * don't step on the header when we construct
+			 * the sll header.
+			 */
+			if (bp < (u_char *)frame +
+					   TPACKET_ALIGN(handlep->tp_hdrlen) +
+					   sizeof(struct sockaddr_ll)) {
+				pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+					"cooked-mode frame doesn't have room for sll header");
+				return -1;
+			}
+
+			/*
+			 * OK, that worked; construct the sll header.
+			 */
+			hdrp = (struct sll_header *)bp;
+			hdrp->sll_pkttype = htons(sll->sll_pkttype);
+			hdrp->sll_hatype = htons(sll->sll_hatype);
+			hdrp->sll_halen = htons(sll->sll_halen);
+			memcpy(hdrp->sll_addr, sll->sll_addr, SLL_ADDRLEN);
+			hdrp->sll_protocol = sll->sll_protocol;
+
+			snaplen += sizeof(struct sll_header);
 		}
-
-		/*
-		 * OK, that worked; construct the sll header.
-		 */
-		hdrp = (struct sll_header *)bp;
-		hdrp->sll_pkttype = map_packet_type_to_sll_type(
-						sll->sll_pkttype);
-		hdrp->sll_hatype = htons(sll->sll_hatype);
-		hdrp->sll_halen = htons(sll->sll_halen);
-		memcpy(hdrp->sll_addr, sll->sll_addr, SLL_ADDRLEN);
-		hdrp->sll_protocol = sll->sll_protocol;
-
-		snaplen += sizeof(struct sll_header);
 	}
 
 	if (handlep->filter_in_userland && handle->fcode.bf_insns) {
@@ -4998,8 +5244,13 @@
 	/* if required build in place the sll header*/
 	if (handlep->cooked) {
 		/* update packet len */
-		pcaphdr.caplen += SLL_HDR_LEN;
-		pcaphdr.len += SLL_HDR_LEN;
+		if (handle->linktype == DLT_LINUX_SLL2) {
+			pcaphdr.caplen += SLL2_HDR_LEN;
+			pcaphdr.len += SLL2_HDR_LEN;
+		} else {
+			pcaphdr.caplen += SLL_HDR_LEN;
+			pcaphdr.len += SLL_HDR_LEN;
+		}
 	}
 
 #if defined(HAVE_TPACKET2) || defined(HAVE_TPACKET3)
@@ -5521,7 +5772,7 @@
 	struct ifreq	ifr;
 
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 
 	if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1) {
 		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
@@ -5570,7 +5821,7 @@
 
 	if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &errlen) == -1) {
 		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
-		    errno, "getsockopt");
+		    errno, "getsockopt (SO_ERROR)");
 		return 0;
 	}
 
@@ -5602,19 +5853,22 @@
 has_wext(int sock_fd, const char *device, char *ebuf)
 {
 	struct iwreq ireq;
+	int ret;
 
 	if (is_bonding_device(sock_fd, device))
 		return 0;	/* bonding device, so don't even try */
 
-	strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+	pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 	    sizeof ireq.ifr_ifrn.ifrn_name);
 	if (ioctl(sock_fd, SIOCGIWNAME, &ireq) >= 0)
 		return 1;	/* yes */
+	if (errno == ENODEV)
+		ret = PCAP_ERROR_NO_SUCH_DEVICE;
+	else
+		ret = 0;
 	pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE, errno,
 	    "%s: SIOCGIWNAME", device);
-	if (errno == ENODEV)
-		return PCAP_ERROR_NO_SUCH_DEVICE;
-	return 0;
+	return ret;
 }
 
 /*
@@ -5743,7 +5997,7 @@
 	 * return EOPNOTSUPP.
 	 */
 	memset(&ireq, 0, sizeof ireq);
-	strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+	pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 	    sizeof ireq.ifr_ifrn.ifrn_name);
 	ireq.u.data.pointer = (void *)args;
 	ireq.u.data.length = 0;
@@ -5943,7 +6197,7 @@
 	/*
 	 * Get the old mode.
 	 */
-	strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+	pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 	    sizeof ireq.ifr_ifrn.ifrn_name);
 	if (ioctl(sock_fd, SIOCGIWMODE, &ireq) == -1) {
 		/*
@@ -5999,7 +6253,7 @@
 		 * If it fails, just fall back on SIOCSIWMODE.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		ireq.u.data.length = 1;	/* 1 argument */
 		args[0] = 3;	/* request Prism header */
@@ -6031,7 +6285,7 @@
 	 * might get EBUSY.
 	 */
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 	if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) == -1) {
 		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "%s: Can't get flags", device);
@@ -6052,7 +6306,7 @@
 	/*
 	 * Then turn monitor mode on.
 	 */
-	strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+	pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 	    sizeof ireq.ifr_ifrn.ifrn_name);
 	ireq.u.mode = IW_MODE_MONITOR;
 	if (ioctl(sock_fd, SIOCSIWMODE, &ireq) == -1) {
@@ -6092,7 +6346,7 @@
 		 * Try to select the radiotap header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 3;	/* request radiotap header */
 		memcpy(ireq.u.name, args, sizeof (int));
@@ -6103,7 +6357,7 @@
 		 * That failed.  Try to select the AVS header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 2;	/* request AVS header */
 		memcpy(ireq.u.name, args, sizeof (int));
@@ -6114,7 +6368,7 @@
 		 * That failed.  Try to select the Prism header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 1;	/* request Prism header */
 		memcpy(ireq.u.name, args, sizeof (int));
@@ -6132,7 +6386,7 @@
 		 * Select the Prism header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 3;	/* request Prism header */
 		memcpy(ireq.u.name, args, sizeof (int));
@@ -6144,7 +6398,7 @@
 		 * Get the current channel.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		if (ioctl(sock_fd, SIOCGIWFREQ, &ireq) == -1) {
 			pcap_fmt_errmsg_for_errno(handle->errbuf,
@@ -6158,7 +6412,7 @@
 		 * current value.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 1;		/* request Prism header */
 		args[1] = channel;	/* set channel */
@@ -6172,7 +6426,7 @@
 		 * Prism header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 0;	/* disallow transmitting */
 		memcpy(ireq.u.name, args, sizeof (int));
@@ -6184,7 +6438,7 @@
 		 * Force the Prism header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 1;	/* request Prism header */
 		memcpy(ireq.u.name, args, sizeof (int));
@@ -6196,7 +6450,7 @@
 		 * Force the Prism header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		ireq.u.data.length = 1;	/* 1 argument */
 		ireq.u.data.pointer = "1";
@@ -6209,7 +6463,7 @@
 		 * Force the Prism header.
 		 */
 		memset(&ireq, 0, sizeof ireq);
-		strlcpy(ireq.ifr_ifrn.ifrn_name, device,
+		pcap_strlcpy(ireq.ifr_ifrn.ifrn_name, device,
 		    sizeof ireq.ifr_ifrn.ifrn_name);
 		args[0] = 1;	/* request Prism header */
 		memcpy(ireq.u.name, args, sizeof (int));
@@ -6357,7 +6611,7 @@
 	}
 
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 	memset(&info, 0, sizeof(info));
 	info.cmd = ETHTOOL_GET_TS_INFO;
 	ifr.ifr_data = (caddr_t)&info;
@@ -6471,21 +6725,35 @@
  * if SIOCETHTOOL isn't defined, or we don't have any #defines for any
  * of the types of offloading, there's nothing we can do to check, so
  * we just say "no, we don't".
+ *
+ * We treat EOPNOTSUPP, EINVAL and, if eperm_ok is true, EPERM as
+ * indications that the operation isn't supported.  We do EPERM
+ * weirdly because the SIOCETHTOOL code in later kernels 1) doesn't
+ * support ETHTOOL_GUFO, 2) also doesn't include it in the list
+ * of ethtool operations that don't require CAP_NET_ADMIN privileges,
+ * and 3) does the "is this permitted" check before doing the "is
+ * this even supported" check, so it fails with "this is not permitted"
+ * rather than "this is not even supported".  To work around this
+ * annoyance, we only treat EPERM as an error for the first feature,
+ * and assume that they all do the same permission checks, so if the
+ * first one is allowed all the others are allowed if supported.
  */
 #if defined(SIOCETHTOOL) && (defined(ETHTOOL_GTSO) || defined(ETHTOOL_GUFO) || defined(ETHTOOL_GGSO) || defined(ETHTOOL_GFLAGS) || defined(ETHTOOL_GGRO))
 static int
-iface_ethtool_flag_ioctl(pcap_t *handle, int cmd, const char *cmdname)
+iface_ethtool_flag_ioctl(pcap_t *handle, int cmd, const char *cmdname,
+    int eperm_ok)
 {
 	struct ifreq	ifr;
 	struct ethtool_value eval;
 
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name));
 	eval.cmd = cmd;
 	eval.data = 0;
 	ifr.ifr_data = (caddr_t)&eval;
 	if (ioctl(handle->fd, SIOCETHTOOL, &ifr) == -1) {
-		if (errno == EOPNOTSUPP || errno == EINVAL) {
+		if (errno == EOPNOTSUPP || errno == EINVAL ||
+		    (errno == EPERM && eperm_ok)) {
 			/*
 			 * OK, let's just return 0, which, in our
 			 * case, either means "no, what we're asking
@@ -6502,34 +6770,41 @@
 	return eval.data;
 }
 
+/*
+ * XXX - it's annoying that we have to check for offloading at all, but,
+ * given that we have to, it's still annoying that we have to check for
+ * particular types of offloading, especially that shiny new types of
+ * offloading may be added - and, worse, may not be checkable with
+ * a particular ETHTOOL_ operation; ETHTOOL_GFEATURES would, in
+ * theory, give those to you, but the actual flags being used are
+ * opaque (defined in a non-uapi header), and there doesn't seem to
+ * be any obvious way to ask the kernel what all the offloading flags
+ * are - at best, you can ask for a set of strings(!) to get *names*
+ * for various flags.  (That whole mechanism appears to have been
+ * designed for the sole purpose of letting ethtool report flags
+ * by name and set flags by name, with the names having no semantics
+ * ethtool understands.)
+ */
 static int
 iface_get_offload(pcap_t *handle)
 {
 	int ret;
 
 #ifdef ETHTOOL_GTSO
-	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GTSO, "ETHTOOL_GTSO");
+	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GTSO, "ETHTOOL_GTSO", 0);
 	if (ret == -1)
 		return -1;
 	if (ret)
 		return 1;	/* TCP segmentation offloading on */
 #endif
 
-#ifdef ETHTOOL_GUFO
-	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GUFO, "ETHTOOL_GUFO");
-	if (ret == -1)
-		return -1;
-	if (ret)
-		return 1;	/* UDP fragmentation offloading on */
-#endif
-
 #ifdef ETHTOOL_GGSO
 	/*
 	 * XXX - will this cause large unsegmented packets to be
 	 * handed to PF_PACKET sockets on transmission?  If not,
 	 * this need not be checked.
 	 */
-	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GGSO, "ETHTOOL_GGSO");
+	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GGSO, "ETHTOOL_GGSO", 0);
 	if (ret == -1)
 		return -1;
 	if (ret)
@@ -6537,7 +6812,7 @@
 #endif
 
 #ifdef ETHTOOL_GFLAGS
-	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GFLAGS, "ETHTOOL_GFLAGS");
+	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GFLAGS, "ETHTOOL_GFLAGS", 0);
 	if (ret == -1)
 		return -1;
 	if (ret & ETH_FLAG_LRO)
@@ -6550,13 +6825,27 @@
 	 * handed to PF_PACKET sockets on receipt?  If not,
 	 * this need not be checked.
 	 */
-	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GGRO, "ETHTOOL_GGRO");
+	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GGRO, "ETHTOOL_GGRO", 0);
 	if (ret == -1)
 		return -1;
 	if (ret)
 		return 1;	/* generic (large) receive offloading on */
 #endif
 
+#ifdef ETHTOOL_GUFO
+	/*
+	 * Do this one last, as support for it was removed in later
+	 * kernels, and it fails with EPERM on those kernels rather
+	 * than with EOPNOTSUPP (see explanation in comment for
+	 * iface_ethtool_flag_ioctl()).
+	 */
+	ret = iface_ethtool_flag_ioctl(handle, ETHTOOL_GUFO, "ETHTOOL_GUFO", 1);
+	if (ret == -1)
+		return -1;
+	if (ret)
+		return 1;	/* UDP fragmentation offloading on */
+#endif
+
 	return 0;
 }
 #else /* SIOCETHTOOL */
@@ -6592,8 +6881,17 @@
 	struct utsname	utsname;
 	int		mtu;
 
-	/* Open the socket */
+	/*
+	 * PF_INET/SOCK_PACKET sockets must be bound to a device, so we
+	 * can't support the "any" device.
+	 */
+	if (strcmp(device, "any") == 0) {
+		pcap_strlcpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems",
+			PCAP_ERRBUF_SIZE);
+		return PCAP_ERROR;
+	}
 
+	/* Open the socket */
 	handle->fd = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
 	if (handle->fd == -1) {
 		err = errno;
@@ -6620,12 +6918,6 @@
 	handlep->cooked = 0;
 
 	/* Bind to the given device */
-
-	if (strcmp(device, "any") == 0) {
-		strlcpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems",
-			PCAP_ERRBUF_SIZE);
-		return PCAP_ERROR;
-	}
 	if (iface_bind_old(handle->fd, device, handle->errbuf) == -1)
 		return PCAP_ERROR;
 
@@ -6651,7 +6943,7 @@
 
 	if (handle->opt.promisc) {
 		memset(&ifr, 0, sizeof(ifr));
-		strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+		pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 		if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) == -1) {
 			pcap_fmt_errmsg_for_errno(handle->errbuf,
 			    PCAP_ERRBUF_SIZE, errno, "SIOCGIFFLAGS");
@@ -6757,6 +7049,17 @@
 		 *
 		 * We can safely pass "recvfrom()" a byte count
 		 * based on the snapshot length.
+		 *
+		 * XXX - this "should not happen", as 2.2[.x]
+		 * kernels all have PF_PACKET sockets, and there's
+		 * no configuration option to disable them without
+		 * disabling SOCK_PACKET sockets, because
+		 * SOCK_PACKET sockets are implemented in the same
+		 * source file, net/packet/af_packet.c.  There *is*
+		 * an option to disable SOCK_PACKET sockets so that
+		 * you only have PF_PACKET sockets, and the kernel
+		 * will log warning messages for code that uses
+		 * "obsolete (PF_INET,SOCK_PACKET)".
 		 */
 		handle->bufsize = (u_int)handle->snapshot;
 	}
@@ -6788,7 +7091,7 @@
 	socklen_t	errlen = sizeof(err);
 
 	memset(&saddr, 0, sizeof(saddr));
-	strlcpy(saddr.sa_data, device, sizeof(saddr.sa_data));
+	pcap_strlcpy(saddr.sa_data, device, sizeof(saddr.sa_data));
 	if (bind(fd, &saddr, sizeof(saddr)) == -1) {
 		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
 		    errno, "bind");
@@ -6799,7 +7102,7 @@
 
 	if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &errlen) == -1) {
 		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
-		    errno, "getsockopt");
+		    errno, "getsockopt (SO_ERROR)");
 		return -1;
 	}
 
@@ -6827,7 +7130,7 @@
 		return BIGGER_THAN_ALL_MTUS;
 
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 
 	if (ioctl(fd, SIOCGIFMTU, &ifr) == -1) {
 		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
@@ -6845,20 +7148,22 @@
 iface_get_arptype(int fd, const char *device, char *ebuf)
 {
 	struct ifreq	ifr;
+	int		ret;
 
 	memset(&ifr, 0, sizeof(ifr));
-	strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+	pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 
 	if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) {
-		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
-		    errno, "SIOCGIFHWADDR");
 		if (errno == ENODEV) {
 			/*
 			 * No such device.
 			 */
-			return PCAP_ERROR_NO_SUCH_DEVICE;
-		}
-		return PCAP_ERROR;
+			ret = PCAP_ERROR_NO_SUCH_DEVICE;
+		} else
+			ret = PCAP_ERROR;
+		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+		    errno, "SIOCGIFHWADDR");
+		return ret;
 	}
 
 	return ifr.ifr_hwaddr.sa_family;
@@ -6950,7 +7255,7 @@
 					 * Yes, so we need to fix this
 					 * instruction.
 					 */
-					if (fix_offset(p) < 0) {
+					if (fix_offset(handle, p) < 0) {
 						/*
 						 * We failed to do so.
 						 * Return 0, so our caller
@@ -6968,38 +7273,80 @@
 }
 
 static int
-fix_offset(struct bpf_insn *p)
+fix_offset(pcap_t *handle, struct bpf_insn *p)
 {
 	/*
-	 * What's the offset?
+	 * Existing references to auxiliary data shouldn't be adjusted.
+	 *
+	 * Note that SKF_AD_OFF is negative, but p->k is unsigned, so
+	 * we use >= and cast SKF_AD_OFF to unsigned.
 	 */
-	if (p->k >= SLL_HDR_LEN) {
+	if (p->k >= (bpf_u_int32)SKF_AD_OFF)
+		return 0;
+	if (handle->linktype == DLT_LINUX_SLL2) {
 		/*
-		 * It's within the link-layer payload; that starts at an
-		 * offset of 0, as far as the kernel packet filter is
-		 * concerned, so subtract the length of the link-layer
-		 * header.
+		 * What's the offset?
 		 */
-		p->k -= SLL_HDR_LEN;
-	} else if (p->k == 0) {
+		if (p->k >= SLL2_HDR_LEN) {
+			/*
+			 * It's within the link-layer payload; that starts
+			 * at an offset of 0, as far as the kernel packet
+			 * filter is concerned, so subtract the length of
+			 * the link-layer header.
+			 */
+			p->k -= SLL2_HDR_LEN;
+		} else if (p->k == 0) {
+			/*
+			 * It's the protocol field; map it to the
+			 * special magic kernel offset for that field.
+			 */
+			p->k = SKF_AD_OFF + SKF_AD_PROTOCOL;
+		} else if (p->k == 10) {
+			/*
+			 * It's the packet type field; map it to the
+			 * special magic kernel offset for that field.
+			 */
+			p->k = SKF_AD_OFF + SKF_AD_PKTTYPE;
+		} else if ((bpf_int32)(p->k) > 0) {
+			/*
+			 * It's within the header, but it's not one of
+			 * those fields; we can't do that in the kernel,
+			 * so punt to userland.
+			 */
+			return -1;
+		}
+	} else {
 		/*
-		 * It's the packet type field; map it to the special magic
-		 * kernel offset for that field.
+		 * What's the offset?
 		 */
-		p->k = SKF_AD_OFF + SKF_AD_PKTTYPE;
-	} else if (p->k == 14) {
-		/*
-		 * It's the protocol field; map it to the special magic
-		 * kernel offset for that field.
-		 */
-		p->k = SKF_AD_OFF + SKF_AD_PROTOCOL;
-	} else if ((bpf_int32)(p->k) > 0) {
-		/*
-		 * It's within the header, but it's not one of those
-		 * fields; we can't do that in the kernel, so punt
-		 * to userland.
-		 */
-		return -1;
+		if (p->k >= SLL_HDR_LEN) {
+			/*
+			 * It's within the link-layer payload; that starts
+			 * at an offset of 0, as far as the kernel packet
+			 * filter is concerned, so subtract the length of
+			 * the link-layer header.
+			 */
+			p->k -= SLL_HDR_LEN;
+		} else if (p->k == 0) {
+			/*
+			 * It's the packet type field; map it to the
+			 * special magic kernel offset for that field.
+			 */
+			p->k = SKF_AD_OFF + SKF_AD_PKTTYPE;
+		} else if (p->k == 14) {
+			/*
+			 * It's the protocol field; map it to the
+			 * special magic kernel offset for that field.
+			 */
+			p->k = SKF_AD_OFF + SKF_AD_PROTOCOL;
+		} else if ((bpf_int32)(p->k) > 0) {
+			/*
+			 * It's within the header, but it's not one of
+			 * those fields; we can't do that in the kernel,
+			 * so punt to userland.
+			 */
+			return -1;
+		}
 	}
 	return 0;
 }
diff --git a/pcap-netfilter-linux.c b/pcap-netfilter-linux.c
index d5c5dcd..91bad37 100644
--- a/pcap-netfilter-linux.c
+++ b/pcap-netfilter-linux.c
@@ -301,7 +301,8 @@
 static int
 netfilter_inject_linux(pcap_t *handle, const void *buf _U_, size_t size _U_)
 {
-	pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on netfilter devices");
+	pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+	    "Packet injection is not supported on netfilter devices");
 	return (-1);
 }
 
@@ -315,6 +316,7 @@
 netfilter_send_config_msg(const pcap_t *handle, uint16_t msg_type, int ack, u_int8_t family, u_int16_t res_id, const struct my_nfattr *mynfa)
 {
 	char buf[1024] __attribute__ ((aligned));
+	memset(buf, 0, sizeof(buf));
 
 	struct nlmsghdr *nlh = (struct nlmsghdr *) buf;
 	struct nfgenmsg *nfg = (struct nfgenmsg *) (buf + sizeof(struct nlmsghdr));
diff --git a/pcap-netmap.c b/pcap-netmap.c
index f150563..b2301a7 100644
--- a/pcap-netmap.c
+++ b/pcap-netmap.c
@@ -67,7 +67,7 @@
 {
 	struct pcap_netmap *pn = p->priv;
 
-	ps->ps_recv = pn->rx_pkts;
+	ps->ps_recv = (u_int)pn->rx_pkts;
 	ps->ps_drop = 0;
 	ps->ps_ifdrop = 0;
 	return 0;
diff --git a/pcap-new.c b/pcap-new.c
index 6fa52e6..e61cf6a 100644
--- a/pcap-new.c
+++ b/pcap-new.c
@@ -35,6 +35,8 @@
 #include <config.h>
 #endif
 
+#include "ftmacros.h"
+
 /*
  * sockutils.h may include <crtdbg.h> on Windows, and pcap-int.h will
  * include portability.h, and portability.h, on Windows, expects that
@@ -54,11 +56,14 @@
 
 /* String identifier to be used in the pcap_findalldevs_ex() */
 #define PCAP_TEXT_SOURCE_FILE "File"
+#define PCAP_TEXT_SOURCE_FILE_LEN (sizeof PCAP_TEXT_SOURCE_FILE - 1)
 /* String identifier to be used in the pcap_findalldevs_ex() */
 #define PCAP_TEXT_SOURCE_ADAPTER "Network adapter"
+#define PCAP_TEXT_SOURCE_ADAPTER_LEN (sizeof "Network adapter" - 1)
 
 /* String identifier to be used in the pcap_findalldevs_ex() */
 #define PCAP_TEXT_SOURCE_ON_LOCAL_HOST "on local host"
+#define PCAP_TEXT_SOURCE_ON_LOCAL_HOST_LEN (sizeof PCAP_TEXT_SOURCE_ON_LOCAL_HOST + 1)
 
 /****************************************************
  *                                                  *
@@ -66,10 +71,12 @@
  *                                                  *
  ****************************************************/
 
-int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf)
+int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf)
 {
 	int type;
 	char name[PCAP_BUF_SIZE], path[PCAP_BUF_SIZE], filename[PCAP_BUF_SIZE];
+	size_t pathlen;
+	size_t stringlen;
 	pcap_t *fp;
 	char tmpstring[PCAP_BUF_SIZE + 1];		/* Needed to convert names and descriptions from 'old' syntax to the 'new' one */
 	pcap_if_t *lastdev;	/* Last device in the pcap_if_t list */
@@ -113,7 +120,7 @@
 		if (*alldevs == NULL)
 		{
 			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-				"No interfaces found! Make sure libpcap/WinPcap is properly installed"
+				"No interfaces found! Make sure libpcap/Npcap is properly installed"
 				" on the local machine.");
 			return -1;
 		}
@@ -123,6 +130,8 @@
 		dev = *alldevs;
 		while (dev)
 		{
+			char *localdesc, *desc;
+
 			/* Create the new device identifier */
 			if (pcap_createsrcstr(tmpstring, PCAP_SRC_IFLOCAL, NULL, NULL, dev->name, errbuf) == -1)
 				return -1;
@@ -141,20 +150,16 @@
 				return -1;
 			}
 
-			/* Create the new device description */
+			/*
+			 * Create the description.
+			 */
 			if ((dev->description == NULL) || (dev->description[0] == 0))
-				pcap_snprintf(tmpstring, sizeof(tmpstring) - 1, "%s '%s' %s", PCAP_TEXT_SOURCE_ADAPTER,
-				dev->name, PCAP_TEXT_SOURCE_ON_LOCAL_HOST);
+				localdesc = dev->name;
 			else
-				pcap_snprintf(tmpstring, sizeof(tmpstring) - 1, "%s '%s' %s", PCAP_TEXT_SOURCE_ADAPTER,
-				dev->description, PCAP_TEXT_SOURCE_ON_LOCAL_HOST);
-
-			/* Delete the old pointer */
-			free(dev->description);
-
-			/* Make a copy of the description */
-			dev->description = strdup(tmpstring);
-			if (dev->description == NULL)
+				localdesc = dev->description;
+			if (pcap_asprintf(&desc, "%s '%s' %s",
+			    PCAP_TEXT_SOURCE_ADAPTER, localdesc,
+			    PCAP_TEXT_SOURCE_ON_LOCAL_HOST) == -1)
 			{
 				pcap_fmt_errmsg_for_errno(errbuf,
 				    PCAP_ERRBUF_SIZE, errno,
@@ -163,6 +168,10 @@
 				return -1;
 			}
 
+			/* Now overwrite the description */
+			free(dev->description);
+			dev->description = desc;
+
 			dev = dev->next;
 		}
 
@@ -170,7 +179,6 @@
 
 	case PCAP_SRC_FILE:
 	{
-		size_t stringlen;
 #ifdef _WIN32
 		WIN32_FIND_DATA filedata;
 		HANDLE filehandle;
@@ -202,6 +210,7 @@
 
 		/* Save the path for future reference */
 		pcap_snprintf(path, sizeof(path), "%s", name);
+		pathlen = strlen(path);
 
 #ifdef _WIN32
 		/* To perform directory listing, Win32 must have an 'asterisk' as ending char */
@@ -236,10 +245,14 @@
 		/* Add all files we find to the list. */
 		do
 		{
-
 #ifdef _WIN32
+			/* Skip the file if the pathname won't fit in the buffer */
+			if (pathlen + strlen(filedata.cFileName) >= sizeof(filename))
+				continue;
 			pcap_snprintf(filename, sizeof(filename), "%s%s", path, filedata.cFileName);
 #else
+			if (pathlen + strlen(filedata->d_name) >= sizeof(filename))
+				continue;
 			pcap_snprintf(filename, sizeof(filename), "%s%s", path, filedata->d_name);
 #endif
 
@@ -287,9 +300,7 @@
 					return -1;
 				}
 
-				stringlen = strlen(tmpstring);
-
-				dev->name = (char *)malloc(stringlen + 1);
+				dev->name = strdup(tmpstring);
 				if (dev->name == NULL)
 				{
 					pcap_fmt_errmsg_for_errno(errbuf,
@@ -299,19 +310,12 @@
 					return -1;
 				}
 
-				strlcpy(dev->name, tmpstring, stringlen);
-
-				dev->name[stringlen] = 0;
-
-				/* Create the description */
-				pcap_snprintf(tmpstring, sizeof(tmpstring) - 1, "%s '%s' %s", PCAP_TEXT_SOURCE_FILE,
-					filename, PCAP_TEXT_SOURCE_ON_LOCAL_HOST);
-
-				stringlen = strlen(tmpstring);
-
-				dev->description = (char *)malloc(stringlen + 1);
-
-				if (dev->description == NULL)
+				/*
+				 * Create the description.
+				 */
+				if (pcap_asprintf(&dev->description,
+				    "%s '%s' %s", PCAP_TEXT_SOURCE_FILE,
+				    filename, PCAP_TEXT_SOURCE_ON_LOCAL_HOST) == -1)
 				{
 					pcap_fmt_errmsg_for_errno(errbuf,
 					    PCAP_ERRBUF_SIZE, errno,
@@ -320,9 +324,6 @@
 					return -1;
 				}
 
-				/* Copy the new device description into the correct memory location */
-				strlcpy(dev->description, tmpstring, stringlen + 1);
-
 				pcap_close(fp);
 			}
 		}
@@ -345,7 +346,7 @@
 		return pcap_findalldevs_ex_remote(source, auth, alldevs, errbuf);
 
 	default:
-		strlcpy(errbuf, "Source type not supported", PCAP_ERRBUF_SIZE);
+		pcap_strlcpy(errbuf, "Source type not supported", PCAP_ERRBUF_SIZE);
 		return -1;
 	}
 }
@@ -357,6 +358,16 @@
 	pcap_t *fp;
 	int status;
 
+	/*
+	 * A null device name is equivalent to the "any" device -
+	 * which might not be supported on this platform, but
+	 * this means that you'll get a "not supported" error
+	 * rather than, say, a crash when we try to dereference
+	 * the null pointer.
+	 */
+	if (source == NULL)
+		source = "any";
+
 	if (strlen(source) > PCAP_BUF_SIZE)
 	{
 		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "The source string is too long. Cannot handle it correctly.");
@@ -389,7 +400,7 @@
 		return pcap_open_rpcap(source, snaplen, flags, read_timeout, auth, errbuf);
 
 	default:
-		strlcpy(errbuf, "Source type not supported", PCAP_ERRBUF_SIZE);
+		pcap_strlcpy(errbuf, "Source type not supported", PCAP_ERRBUF_SIZE);
 		return NULL;
 	}
 
diff --git a/pcap-npf.c b/pcap-npf.c
index a9ff0ff..da4641f 100644
--- a/pcap-npf.c
+++ b/pcap-npf.c
@@ -70,7 +70,7 @@
 #define SWAPS(_X) ((_X & 0xff) << 8) | (_X >> 8)
 
 /*
- * Private data for capturing on WinPcap devices.
+ * Private data for capturing on WinPcap/Npcap devices.
  */
 struct pcap_win {
 	ADAPTER *adapter;		/* the packet32 ADAPTER for the device */
@@ -166,11 +166,8 @@
 	oid_data_arg->Oid = oid;
 	oid_data_arg->Length = (ULONG)(*lenp);	/* XXX - check for ridiculously large value? */
 	if (!PacketRequest(adapter, FALSE, oid_data_arg)) {
-		char errmsgbuf[PCAP_ERRBUF_SIZE+1];
-
-		pcap_win32_err_to_str(GetLastError(), errmsgbuf);
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-		    "Error calling PacketRequest: %s", errmsgbuf);
+		pcap_fmt_errmsg_for_win32_err(errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "Error calling PacketRequest");
 		free(oid_data_arg);
 		return (-1);
 	}
@@ -193,7 +190,6 @@
 {
 	struct pcap_win *pw = p->priv;
 	struct bpf_stat bstats;
-	char errbuf[PCAP_ERRBUF_SIZE+1];
 
 	/*
 	 * Try to get statistics.
@@ -209,9 +205,8 @@
 	 * to us.
 	 */
 	if (!PacketGetStats(pw->adapter, &bstats)) {
-		pcap_win32_err_to_str(GetLastError(), errbuf);
-		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-		    "PacketGetStats error: %s", errbuf);
+		pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "PacketGetStats error");
 		return (-1);
 	}
 	ps->ps_recv = bstats.bs_recv;
@@ -256,7 +251,6 @@
 {
 	struct pcap_win *pw = p->priv;
 	struct bpf_stat bstats;
-	char errbuf[PCAP_ERRBUF_SIZE+1];
 
 	*pcap_stat_size = sizeof (p->stat);
 
@@ -268,9 +262,8 @@
 	 * same layout, but let's not cheat.)
 	 */
 	if (!PacketGetStatsEx(pw->adapter, &bstats)) {
-		pcap_win32_err_to_str(GetLastError(), errbuf);
-		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-		    "PacketGetStatsEx error: %s", errbuf);
+		pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "PacketGetStatsEx error");
 		return (NULL);
 	}
 	p->stat.ps_recv = bstats.bs_recv;
@@ -347,7 +340,6 @@
 {
 	struct pcap_win *pw = p->priv;
 	PACKET_OID_DATA *oid_data_arg;
-	char errbuf[PCAP_ERRBUF_SIZE+1];
 
 	/*
 	 * Allocate a PACKET_OID_DATA structure to hand to PacketRequest().
@@ -367,9 +359,8 @@
 	oid_data_arg->Length = (ULONG)(*lenp);	/* XXX - check for ridiculously large value? */
 	memcpy(oid_data_arg->Data, data, *lenp);
 	if (!PacketRequest(pw->adapter, TRUE, oid_data_arg)) {
-		pcap_win32_err_to_str(GetLastError(), errbuf);
-		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-		    "Error calling PacketRequest: %s", errbuf);
+		pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "Error calling PacketRequest");
 		free(oid_data_arg);
 		return (PCAP_ERROR);
 	}
@@ -391,7 +382,6 @@
 {
 	struct pcap_win *pw = p->priv;
 	u_int res;
-	char errbuf[PCAP_ERRBUF_SIZE+1];
 
 	if (pw->adapter==NULL) {
 		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
@@ -405,9 +395,8 @@
 		(BOOLEAN)sync);
 
 	if(res != queue->len){
-		pcap_win32_err_to_str(GetLastError(), errbuf);
-		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-		    "Error opening adapter: %s", errbuf);
+		pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "Error opening adapter");
 	}
 
 	return (res);
@@ -534,7 +523,34 @@
 		 */
 		PacketInitPacket(&Packet, (BYTE *)p->buffer, p->bufsize);
 		if (!PacketReceivePacket(pw->adapter, &Packet, TRUE)) {
-			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "read error: PacketReceivePacket failed");
+			/*
+			 * Did the device go away?
+			 * If so, the error we get is ERROR_GEN_FAILURE.
+			 */
+			DWORD errcode = GetLastError();
+
+			if (errcode == ERROR_GEN_FAILURE) {
+				/*
+				 * The device on which we're capturing
+				 * went away, or it became unusable
+				 * by NPF due to a suspend/resume.
+				 *
+				 * XXX - hopefully no other error
+				 * conditions are indicated by this.
+				 *
+				 * 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.
+				 */
+				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+				    "The interface disappeared");
+			} else {
+				pcap_fmt_errmsg_for_win32_err(p->errbuf,
+				    PCAP_ERRBUF_SIZE, errcode,
+				    "PacketReceivePacket error");
+			}
 			return (PCAP_ERROR);
 		}
 
@@ -873,7 +889,7 @@
 	struct pcap_win *pw = p->priv;
 	NetType type;
 	int res;
-	char errbuf[PCAP_ERRBUF_SIZE+1];
+	int status = 0;
 
 	if (p->opt.rfmon) {
 		/*
@@ -912,23 +928,35 @@
 
 	if (pw->adapter == NULL)
 	{
-		/* Adapter detected but we are not able to open it. Return failure. */
-		pcap_win32_err_to_str(GetLastError(), errbuf);
-		if (pw->rfmon_selfstart)
-		{
-			PacketSetMonitorMode(p->opt.device, 0);
+		DWORD errcode = GetLastError();
+
+		/*
+		 * What error did we get when trying to open the adapter?
+		 */
+		if (errcode == ERROR_BAD_UNIT) {
+			/*
+			 * There's no such device.
+			 */
+			return (PCAP_ERROR_NO_SUCH_DEVICE);
+		} else {
+			/*
+			 * Unknown - report details.
+			 */
+			pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+			    errcode, "Error opening adapter");
+			if (pw->rfmon_selfstart)
+			{
+				PacketSetMonitorMode(p->opt.device, 0);
+			}
+			return (PCAP_ERROR);
 		}
-		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-		    "Error opening adapter: %s", errbuf);
-		return (PCAP_ERROR);
 	}
 
 	/*get network type*/
 	if(PacketGetNetType (pw->adapter,&type) == FALSE)
 	{
-		pcap_win32_err_to_str(GetLastError(), errbuf);
-		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-		    "Cannot determine the network type: %s", errbuf);
+		pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "Cannot determine the network type");
 		goto bad;
 	}
 
@@ -1006,8 +1034,29 @@
 		p->linktype = DLT_PPI;
 		break;
 
+#ifdef NdisMediumWirelessWan
+	case NdisMediumWirelessWan:
+		p->linktype = DLT_RAW;
+		break;
+#endif
+
 	default:
-		p->linktype = DLT_EN10MB;			/*an unknown adapter is assumed to be ethernet*/
+		/*
+		 * An unknown medium type is assumed to supply Ethernet
+		 * headers; if not, the user will have to report it,
+		 * so that the medium type and link-layer header type
+		 * can be determined.  If we were to fail here, we
+		 * might get the link-layer type in the error, but
+		 * the user wouldn't get a capture, so we wouldn't
+		 * be able to determine the link-layer type; we report
+		 * a warning with the link-layer type, so at least
+		 * some programs will report the warning.
+		 */
+		p->linktype = DLT_EN10MB;
+		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+		    "Unknown NdisMedium value %d, defaulting to DLT_EN10MB",
+		    type.LinkType);
+		status = PCAP_WARNING;
 		break;
 	}
 
@@ -1085,10 +1134,9 @@
 			/* tell the driver to copy the buffer as soon as data arrives */
 			if(PacketSetMinToCopy(pw->adapter,0)==FALSE)
 			{
-				pcap_win32_err_to_str(GetLastError(), errbuf);
-				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-				    "Error calling PacketSetMinToCopy: %s",
-				    errbuf);
+				pcap_fmt_errmsg_for_win32_err(p->errbuf,
+				    PCAP_ERRBUF_SIZE, GetLastError(),
+				    "Error calling PacketSetMinToCopy");
 				goto bad;
 			}
 		}
@@ -1097,10 +1145,9 @@
 			/* tell the driver to copy the buffer only if it contains at least 16K */
 			if(PacketSetMinToCopy(pw->adapter,16000)==FALSE)
 			{
-				pcap_win32_err_to_str(GetLastError(), errbuf);
-				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-				    "Error calling PacketSetMinToCopy: %s",
-				    errbuf);
+				pcap_fmt_errmsg_for_win32_err(p->errbuf,
+				    PCAP_ERRBUF_SIZE, GetLastError(),
+				    "Error calling PacketSetMinToCopy");
 				goto bad;
 			}
 		}
@@ -1221,7 +1268,7 @@
 	 */
 	p->handle = pw->adapter->hFile;
 
-	return (0);
+	return (status);
 bad:
 	pcap_cleanup_npf(p);
 	return (PCAP_ERROR);
@@ -1316,7 +1363,7 @@
 
 	if(!fp)
 	{
-		strlcpy(p->errbuf, "setfilter: No filter specified", sizeof(p->errbuf));
+		pcap_strlcpy(p->errbuf, "setfilter: No filter specified", sizeof(p->errbuf));
 		return (-1);
 	}
 
@@ -1345,7 +1392,6 @@
 {
 	struct pcap_win *pw = p->priv;
 	int newtimeout;
-	char win_errbuf[PCAP_ERRBUF_SIZE+1];
 
 	if (nonblock) {
 		/*
@@ -1365,9 +1411,8 @@
 		newtimeout = p->opt.timeout;
 	}
 	if (!PacketSetReadTimeout(pw->adapter, newtimeout)) {
-		pcap_win32_err_to_str(GetLastError(), win_errbuf);
-		pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-		    "PacketSetReadTimeout: %s", win_errbuf);
+		pcap_fmt_errmsg_for_win32_err(p->errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "PacketSetReadTimeout");
 		return (-1);
 	}
 	pw->nonblock = (newtimeout == -1);
@@ -1684,7 +1729,6 @@
 	char *AdaptersName;
 	ULONG NameLength;
 	char *name;
-	char our_errbuf[PCAP_ERRBUF_SIZE+1];
 
 	/*
 	 * Find out how big a buffer we need.
@@ -1710,9 +1754,8 @@
 
 		if (last_error != ERROR_INSUFFICIENT_BUFFER)
 		{
-			pcap_win32_err_to_str(last_error, our_errbuf);
-			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-			    "PacketGetAdapterNames: %s", our_errbuf);
+			pcap_fmt_errmsg_for_win32_err(errbuf, PCAP_ERRBUF_SIZE,
+			    last_error, "PacketGetAdapterNames");
 			return (-1);
 		}
 	}
@@ -1727,9 +1770,8 @@
 	}
 
 	if (!PacketGetAdapterNames(AdaptersName, &NameLength)) {
-		pcap_win32_err_to_str(GetLastError(), our_errbuf);
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "PacketGetAdapterNames: %s",
-		    our_errbuf);
+		pcap_fmt_errmsg_for_win32_err(errbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "PacketGetAdapterNames");
 		free(AdaptersName);
 		return (-1);
 	}
@@ -1818,7 +1860,6 @@
 {
 	DWORD dwVersion;
 	DWORD dwWindowsMajorVersion;
-	char our_errbuf[PCAP_ERRBUF_SIZE+1];
 
 #pragma warning (push)
 #pragma warning (disable: 4996) /* disable MSVC's GetVersion() deprecated warning here */
@@ -1860,9 +1901,8 @@
 
 		if ( !PacketGetAdapterNames((PTSTR)TAdaptersName,&NameLength) )
 		{
-			pcap_win32_err_to_str(GetLastError(), our_errbuf);
-			(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-				"PacketGetAdapterNames: %s", our_errbuf);
+			pcap_fmt_errmsg_for_win32_err(errbuf, PCAP_ERRBUF_SIZE,
+			    GetLastError(), "PacketGetAdapterNames");
 			free(TAdaptersName);
 			return NULL;
 		}
@@ -2000,59 +2040,48 @@
  * tree.  Include version.h from that source tree to get the WinPcap/Npcap
  * version.
  *
- * XXX - it'd be nice if we could somehow generate the WinPcap version number
- * when building WinPcap.  (It'd be nice to do so for the packet.dll version
- * number as well.)
+ * XXX - it'd be nice if we could somehow generate the WinPcap/Npcap version
+ * number when building as part of WinPcap/Npcap.  (It'd be nice to do so
+ * for the packet.dll version number as well.)
  */
 #include "../../version.h"
 
 static const char pcap_version_string[] =
 	WINPCAP_PRODUCT_NAME " version " WINPCAP_VER_STRING ", based on " PCAP_VERSION_STRING;
-static const char pcap_version_string_packet_dll_fmt[] =
-	WINPCAP_PRODUCT_NAME " version " WINPCAP_VER_STRING " (packet.dll version %s), based on " PCAP_VERSION_STRING;
 
 const char *
 pcap_lib_version(void)
 {
-	char *packet_version_string;
-	size_t full_pcap_version_string_len;
-	char *full_pcap_version_string;
-
 	if (pcap_lib_version_string == NULL) {
 		/*
 		 * Generate the version string.
 		 */
-		packet_version_string = PacketGetVersion();
+		char *packet_version_string = PacketGetVersion();
+
 		if (strcmp(WINPCAP_VER_STRING, packet_version_string) == 0) {
 			/*
-			 * WinPcap version string and packet.dll version
-			 * string are the same; just report the WinPcap
+			 * WinPcap/Npcap version string and packet.dll version
+			 * string are the same; just report the WinPcap/Npcap
 			 * version.
 			 */
 			pcap_lib_version_string = pcap_version_string;
 		} else {
 			/*
-			 * WinPcap version string and packet.dll version
+			 * WinPcap/Npcap version string and packet.dll version
 			 * string are different; that shouldn't be the
 			 * case (the two libraries should come from the
-			 * same version of WinPcap), so we report both
+			 * same version of WinPcap/Npcap), so we report both
 			 * versions.
-			 *
-			 * The -2 is for the %s in the format string,
-			 * which will be replaced by packet_version_string.
 			 */
-			full_pcap_version_string_len =
-			    (sizeof pcap_version_string_packet_dll_fmt - 2) +
-			    strlen(packet_version_string);
-			full_pcap_version_string = malloc(full_pcap_version_string_len);
-			if (full_pcap_version_string == NULL)
-				return (NULL);
-			pcap_snprintf(full_pcap_version_string,
-			    full_pcap_version_string_len,
-			    pcap_version_string_packet_dll_fmt,
-			    packet_version_string);
+			char *full_pcap_version_string;
+
+			if (pcap_asprintf(&full_pcap_version_string,
+			    WINPCAP_PRODUCT_NAME " version " WINPCAP_VER_STRING " (packet.dll version %s), based on " PCAP_VERSION_STRING,
+			    packet_version_string) != -1) {
+				/* Success */
+				pcap_lib_version_string = full_pcap_version_string;
+			}
 		}
-		pcap_lib_version_string = full_pcap_version_string;
 	}
 	return (pcap_lib_version_string);
 }
@@ -2063,35 +2092,22 @@
  * libpcap being built for Windows, not as part of a WinPcap/Npcap source
  * tree.
  */
-static const char pcap_version_string_packet_dll_fmt[] =
-	PCAP_VERSION_STRING " (packet.dll version %s)";
 const char *
 pcap_lib_version(void)
 {
-	char *packet_version_string;
-	size_t full_pcap_version_string_len;
-	char *full_pcap_version_string;
-
 	if (pcap_lib_version_string == NULL) {
 		/*
 		 * Generate the version string.  Report the packet.dll
 		 * version.
-		 *
-		 * The -2 is for the %s in the format string, which will
-		 * be replaced by packet_version_string.
 		 */
-		packet_version_string = PacketGetVersion();
-		full_pcap_version_string_len =
-		    (sizeof pcap_version_string_packet_dll_fmt - 2) +
-		    strlen(packet_version_string);
-		full_pcap_version_string = malloc(full_pcap_version_string_len);
-		if (full_pcap_version_string == NULL)
-			return (NULL);
-		pcap_snprintf(full_pcap_version_string,
-		    full_pcap_version_string_len,
-		    pcap_version_string_packet_dll_fmt,
-		    packet_version_string);
-		pcap_lib_version_string = full_pcap_version_string;
+		char *full_pcap_version_string;
+
+		if (pcap_asprintf(&full_pcap_version_string,
+		    PCAP_VERSION_STRING " (packet.dll version %s)",
+		    PacketGetVersion()) != -1) {
+			/* Success */
+			pcap_lib_version_string = full_pcap_version_string;
+		}
 	}
 	return (pcap_lib_version_string);
 }
diff --git a/pcap-null.c b/pcap-null.c
index 92a5e2d..2ae27bf 100644
--- a/pcap-null.c
+++ b/pcap-null.c
@@ -32,12 +32,12 @@
 pcap_t *
 pcap_create_interface(const char *device _U_, char *ebuf)
 {
-	(void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
+	(void)pcap_strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
 	return (NULL);
 }
 
 int
-pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf)
+pcap_platform_finddevs(pcap_if_list_t *devlistp _U_, char *errbuf _U_)
 {
 	/*
 	 * There are no interfaces on which we can capture.
@@ -50,7 +50,7 @@
 pcap_lookupnet(const char *device _U_, bpf_u_int32 *netp _U_,
     bpf_u_int32 *maskp _U_, char *errbuf)
 {
-	(void)strlcpy(errbuf, nosup, PCAP_ERRBUF_SIZE);
+	(void)pcap_strlcpy(errbuf, nosup, PCAP_ERRBUF_SIZE);
 	return (-1);
 }
 #endif
diff --git a/pcap-rpcap.c b/pcap-rpcap.c
index e9d6245..705f06f 100644
--- a/pcap-rpcap.c
+++ b/pcap-rpcap.c
@@ -155,7 +155,6 @@
 static int pcap_setfilter_rpcap(pcap_t *fp, struct bpf_program *prog);
 static int pcap_setsampling_remote(pcap_t *fp);
 static int pcap_startcapture_remote(pcap_t *fp);
-static int rpcap_sendauth(SOCKET sock, uint8 *ver, struct pcap_rmtauth *auth, char *errbuf);
 static int rpcap_recv_msg_header(SOCKET sock, struct rpcap_header *header, char *errbuf);
 static int rpcap_check_msg_ver(SOCKET sock, uint8 expected_ver, struct rpcap_header *header, char *errbuf);
 static int rpcap_check_msg_type(SOCKET sock, uint8 request_type, struct rpcap_header *header, uint16 *errcode, char *errbuf);
@@ -409,7 +408,7 @@
 			return 0;
 		}
 #endif
-		sock_geterror("select(): ", p->errbuf, PCAP_ERRBUF_SIZE);
+		sock_geterror("select()", p->errbuf, PCAP_ERRBUF_SIZE);
 		return -1;
 	}
 
@@ -763,6 +762,8 @@
 		pr->currentfilter = NULL;
 	}
 
+	pcap_cleanup_live_common(fp);
+
 	/* To avoid inconsistencies in the number of sock_init() */
 	sock_cleanup();
 }
@@ -1069,7 +1070,7 @@
 	saddrlen = sizeof(struct sockaddr_storage);
 	if (getpeername(pr->rmt_sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1)
 	{
-		sock_geterror("getsockname(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+		sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE);
 		goto error_nodiscard;
 	}
 	ai_family = ((struct sockaddr_storage *) &saddr)->ss_family;
@@ -1078,7 +1079,7 @@
 	if (getnameinfo((struct sockaddr *) &saddr, saddrlen, host,
 		sizeof(host), NULL, 0, NI_NUMERICHOST))
 	{
-		sock_geterror("getnameinfo(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+		sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE);
 		goto error_nodiscard;
 	}
 
@@ -1116,7 +1117,7 @@
 		saddrlen = sizeof(struct sockaddr_storage);
 		if (getsockname(sockdata, (struct sockaddr *) &saddr, &saddrlen) == -1)
 		{
-			sock_geterror("getsockname(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			goto error_nodiscard;
 		}
 
@@ -1124,7 +1125,7 @@
 		if (getnameinfo((struct sockaddr *) &saddr, saddrlen, NULL,
 			0, portdata, sizeof(portdata), NI_NUMERICSERV))
 		{
-			sock_geterror("getnameinfo(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			goto error_nodiscard;
 		}
 	}
@@ -1234,7 +1235,7 @@
 
 			if (socktemp == INVALID_SOCKET)
 			{
-				sock_geterror("accept(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+				sock_geterror("accept()", fp->errbuf, PCAP_ERRBUF_SIZE);
 				goto error;
 			}
 
@@ -1260,8 +1261,8 @@
 	res = getsockopt(sockdata, SOL_SOCKET, SO_RCVBUF, (char *)&sockbufsize, &itemp);
 	if (res == -1)
 	{
-		sock_geterror("pcap_startcapture_remote()", fp->errbuf, PCAP_ERRBUF_SIZE);
-		SOCK_DEBUG_MESSAGE(fp->errbuf);
+		sock_geterror("pcap_startcapture_remote(): getsockopt() failed", fp->errbuf, PCAP_ERRBUF_SIZE);
+		goto error;
 	}
 
 	/*
@@ -1612,21 +1613,19 @@
 		char peeraddress[128];
 		char peerctrlport[128];
 		char *newfilter;
-		const int newstringsize = 1024;
-		size_t currentfiltersize;
 
 		/* Get the name/port of our peer */
 		saddrlen = sizeof(struct sockaddr_storage);
 		if (getpeername(pr->rmt_sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1)
 		{
-			sock_geterror("getpeername(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getpeername()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			return -1;
 		}
 
 		if (getnameinfo((struct sockaddr *) &saddr, saddrlen, peeraddress,
 			sizeof(peeraddress), peerctrlport, sizeof(peerctrlport), NI_NUMERICHOST | NI_NUMERICSERV))
 		{
-			sock_geterror("getnameinfo(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			return -1;
 		}
 
@@ -1634,7 +1633,7 @@
 		/* Get the name/port of the current host */
 		if (getsockname(pr->rmt_sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1)
 		{
-			sock_geterror("getsockname(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			return -1;
 		}
 
@@ -1642,43 +1641,60 @@
 		if (getnameinfo((struct sockaddr *) &saddr, saddrlen, myaddress,
 			sizeof(myaddress), myctrlport, sizeof(myctrlport), NI_NUMERICHOST | NI_NUMERICSERV))
 		{
-			sock_geterror("getnameinfo(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			return -1;
 		}
 
 		/* Let's now check the data port */
 		if (getsockname(pr->rmt_sockdata, (struct sockaddr *) &saddr, &saddrlen) == -1)
 		{
-			sock_geterror("getsockname(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getsockname()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			return -1;
 		}
 
 		/* Get the local port the system picked up */
 		if (getnameinfo((struct sockaddr *) &saddr, saddrlen, NULL, 0, mydataport, sizeof(mydataport), NI_NUMERICSERV))
 		{
-			sock_geterror("getnameinfo(): ", fp->errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getnameinfo()", fp->errbuf, PCAP_ERRBUF_SIZE);
 			return -1;
 		}
 
-		currentfiltersize = pr->currentfilter ? strlen(pr->currentfilter) : 0;
-
-		newfilter = (char *)malloc(currentfiltersize + newstringsize + 1);
-
-		if (currentfiltersize)
+		if (pr->currentfilter && pr->currentfilter[0] != '\0')
 		{
-			pcap_snprintf(newfilter, currentfiltersize + newstringsize,
-				"(%s) and not (host %s and host %s and port %s and port %s) and not (host %s and host %s and port %s)",
-				pr->currentfilter, myaddress, peeraddress, myctrlport, peerctrlport, myaddress, peeraddress, mydataport);
+			/*
+			 * We have a current filter; add items to it to
+			 * filter out this rpcap session.
+			 */
+			if (pcap_asprintf(&newfilter,
+			    "(%s) and not (host %s and host %s and port %s and port %s) and not (host %s and host %s and port %s)",
+			    pr->currentfilter, myaddress, peeraddress,
+			    myctrlport, peerctrlport, myaddress, peeraddress,
+			    mydataport) == -1)
+			{
+				/* Failed. */
+				pcap_snprintf(fp->errbuf, PCAP_ERRBUF_SIZE,
+				    "Can't allocate memory for new filter");
+				return -1;
+			}
 		}
 		else
 		{
-			pcap_snprintf(newfilter, currentfiltersize + newstringsize,
-				"not (host %s and host %s and port %s and port %s) and not (host %s and host %s and port %s)",
-				myaddress, peeraddress, myctrlport, peerctrlport, myaddress, peeraddress, mydataport);
+			/*
+			 * We have no current filter; construct a filter to
+			 * filter out this rpcap session.
+			 */
+			if (pcap_asprintf(&newfilter,
+			    "not (host %s and host %s and port %s and port %s) and not (host %s and host %s and port %s)",
+			    myaddress, peeraddress, myctrlport, peerctrlport,
+			    myaddress, peeraddress, mydataport) == -1)
+			{
+				/* Failed. */
+				pcap_snprintf(fp->errbuf, PCAP_ERRBUF_SIZE,
+				    "Can't allocate memory for new filter");
+				return -1;
+			}
 		}
 
-		newfilter[currentfiltersize + newstringsize] = 0;
-
 		/*
 		 * This is only an hack to prevent the save_current_filter
 		 * routine, which will be called when we call pcap_compile(),
@@ -1785,16 +1801,25 @@
 
 /*
  * This function performs authentication and protocol version
- * negotiation.  It first tries to authenticate with the maximum
- * version we support and, if that fails with an "I don't support
- * that version" error from the server, and the version number in
- * the reply from the server is one we support, tries again with
- * that version.
+ * negotiation.  It is required in order to open the connection
+ * with the other end party.
+ *
+ * It sends authentication parameters on the control socket and
+ * reads the reply.  If the reply is a success indication, it
+ * checks whether the reply includes minimum and maximum supported
+ * versions from the server; if not, it assumes both are 0, as
+ * that means it's an older server that doesn't return supported
+ * version numbers in authentication replies, so it only supports
+ * version 0.  It then tries to determine the maximum version
+ * supported both by us and by the server.  If it can find such a
+ * version, it sets us up to use that version; otherwise, it fails,
+ * indicating that there is no version supported by us and by the
+ * server.
  *
  * \param sock: the socket we are currently using.
  *
- * \param ver: pointer to variable holding protocol version number to send
- * and to set to the protocol version number in the reply.
+ * \param ver: pointer to variable to which to set the protocol version
+ * number we selected.
  *
  * \param auth: authentication parameters that have to be sent.
  *
@@ -1808,95 +1833,16 @@
  */
 static int rpcap_doauth(SOCKET sockctrl, uint8 *ver, struct pcap_rmtauth *auth, char *errbuf)
 {
-	int status;
-
-	/*
-	 * Send authentication to the remote machine.
-	 *
-	 * First try with the maximum version number we support.
-	 */
-	*ver = RPCAP_MAX_VERSION;
-	status = rpcap_sendauth(sockctrl, ver, auth, errbuf);
-	if (status == 0)
-	{
-		//
-		// Success.
-		//
-		return 0;
-	}
-	if (status == -1)
-	{
-		/* Unrecoverable error. */
-		return -1;
-	}
-
-	/*
-	 * The server doesn't support the version we used in the initial
-	 * message, and it sent us back a reply either with the maximum
-	 * version they do support, or with the version we sent, and we
-	 * support that version.  *ver has been set to that version; try
-	 * authenticating again with that version.
-	 */
-	status = rpcap_sendauth(sockctrl, ver, auth, errbuf);
-	if (status == 0)
-	{
-		//
-		// Success.
-		//
-		return 0;
-	}
-	if (status == -1)
-	{
-		/* Unrecoverable error. */
-		return -1;
-	}
-	if (status == -2)
-	{
-		/*
-		 * The server doesn't support that version, which
-		 * means there is no version we both support, so
-		 * this is a fatal error.
-		 */
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "The server doesn't support any protocol version that we support");
-		return -1;
-	}
-	pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "rpcap_sendauth() returned %d", status);
-	return -1;
-}
-
-/*
- * This function sends the authentication message.
- *
- * It sends the authentication parameters on the control socket.
- * It is required in order to open the connection with the other end party.
- *
- * \param sock: the socket we are currently using.
- *
- * \param ver: pointer to variable holding protocol version number to send
- * and to set to the protocol version number in the reply.
- *
- * \param auth: authentication parameters that have to be sent.
- *
- * \param errbuf: a pointer to a user-allocated buffer (of size
- * PCAP_ERRBUF_SIZE) that will contain the error message (in case there
- * is one). It could be a network problem or the fact that the authorization
- * failed.
- *
- * \return '0' if everything is fine, '-2' if the server didn't reply with
- * the protocol version we requested but replied with a version we do
- * support, or '-1' for other errors.  For errors, an error message string
- * is returned in the 'errbuf' variable.
- */
-static int rpcap_sendauth(SOCKET sock, uint8 *ver, struct pcap_rmtauth *auth, char *errbuf)
-{
 	char sendbuf[RPCAP_NETBUF_SIZE];	/* temporary buffer in which data that has to be sent is buffered */
 	int sendbufidx = 0;			/* index which keeps the number of bytes currently buffered */
 	uint16 length;				/* length of the payload of this message */
-	uint16 errcode;
 	struct rpcap_auth *rpauth;
 	uint16 auth_type;
 	struct rpcap_header header;
 	size_t str_length;
+	uint32 plen;
+	struct rpcap_authreply authreply;	/* authentication reply message */
+	uint8 ourvers;
 
 	if (auth)
 	{
@@ -1943,12 +1889,11 @@
 		length = sizeof(struct rpcap_auth);
 	}
 
-
 	if (sock_bufferize(NULL, sizeof(struct rpcap_header), NULL,
 		&sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errbuf, PCAP_ERRBUF_SIZE))
 		return -1;
 
-	rpcap_createhdr((struct rpcap_header *) sendbuf, *ver,
+	rpcap_createhdr((struct rpcap_header *) sendbuf, 0,
 	    RPCAP_MSG_AUTH_REQ, 0, length);
 
 	rpauth = (struct rpcap_auth *) &sendbuf[sendbufidx];
@@ -1985,62 +1930,104 @@
 		rpauth->slen2 = htons(rpauth->slen2);
 	}
 
-	if (sock_send(sock, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) < 0)
+	if (sock_send(sockctrl, sendbuf, sendbufidx, errbuf,
+	    PCAP_ERRBUF_SIZE) < 0)
 		return -1;
 
-	/* Receive the reply */
-	if (rpcap_recv_msg_header(sock, &header, errbuf) == -1)
+	/* Receive and process the reply message header */
+	if (rpcap_process_msg_header(sockctrl, 0, RPCAP_MSG_AUTH_REQ,
+	    &header, errbuf) == -1)
 		return -1;
 
-	if (rpcap_check_msg_type(sock, RPCAP_MSG_AUTH_REQ, &header,
-	    &errcode, errbuf) == -1)
+	/*
+	 * OK, it's an authentication reply, so we're logged in.
+	 *
+	 * Did it send any additional information?
+	 */
+	plen = header.plen;
+	if (plen != 0)
 	{
-		/* Error message - or something else, which is a protocol error. */
-		if (header.type == RPCAP_MSG_ERROR &&
-		    errcode == PCAP_ERR_WRONGVER)
+		/* Yes - is it big enough to be version information? */
+		if (plen < sizeof(struct rpcap_authreply))
 		{
-			/*
-			 * The server didn't support the version we sent,
-			 * and replied with the maximum version it supports
-			 * if our version was too big or with the version
-			 * we sent if out version was too small.
-			 *
-			 * Do we also support it?
-			 */
-			if (!RPCAP_VERSION_IS_SUPPORTED(header.ver))
-			{
-				/*
-				 * No, so there's no version we both support.
-				 * This is an unrecoverable error.
-				 */
-				pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "The server doesn't support any protocol version that we support");
-				return -1;
-			}
-
-			/*
-			 * OK, use that version, and tell our caller to
-			 * try again.
-			 */
-			*ver = header.ver;
-			return -2;
+			/* No - discard it and fail. */
+			(void)rpcap_discard(sockctrl, plen, NULL);
+			return -1;
 		}
 
+		/* Read the reply body */
+		if (rpcap_recv(sockctrl, (char *)&authreply,
+		    sizeof(struct rpcap_authreply), &plen, errbuf) == -1)
+		{
+			(void)rpcap_discard(sockctrl, plen, NULL);
+			return -1;
+		}
+
+		/* Discard the rest of the message, if there is any. */
+		if (rpcap_discard(sockctrl, plen, errbuf) == -1)
+			return -1;
+
 		/*
-		 * Other error - unrecoverable.
+		 * Check the minimum and maximum versions for sanity;
+		 * the minimum must be <= the maximum.
 		 */
-		return -1;
+		if (authreply.minvers > authreply.maxvers)
+		{
+			/*
+			 * Bogus - give up on this server.
+			 */
+			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+			    "The server's minimum supported protocol version is greater than its maximum supported protocol version");
+			return -1;
+		}
+	}
+	else
+	{
+		/* No - it supports only version 0. */
+		authreply.minvers = 0;
+		authreply.maxvers = 0;
 	}
 
 	/*
-	 * OK, it's an authentication reply, so they're OK with the
-	 * protocol version we sent.
-	 *
-	 * Discard the rest of it.
+	 * OK, let's start with the maximum version the server supports.
 	 */
-	if (rpcap_discard(sock, header.plen, errbuf) == -1)
-		return -1;
+	ourvers = authreply.maxvers;
 
+#if RPCAP_MIN_VERSION != 0
+	/*
+	 * If that's less than the minimum version we support, we
+	 * can't communicate.
+	 */
+	if (ourvers < RPCAP_MIN_VERSION)
+		goto novers;
+#endif
+
+	/*
+	 * If that's greater than the maximum version we support,
+	 * choose the maximum version we support.
+	 */
+	if (ourvers > RPCAP_MAX_VERSION)
+	{
+		ourvers = RPCAP_MAX_VERSION;
+
+		/*
+		 * If that's less than the minimum version they
+		 * support, we can't communicate.
+		 */
+		if (ourvers < authreply.minvers)
+			goto novers;
+	}
+
+	*ver = ourvers;
 	return 0;
+
+novers:
+	/*
+	 * There is no version we both support; that is a fatal error.
+	 */
+	pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+	    "The server doesn't support any protocol version that we support");
+	return -1;
 }
 
 /* We don't currently support non-blocking mode. */
@@ -2060,6 +2047,103 @@
 	return (-1);
 }
 
+static int
+rpcap_setup_session(const char *source, struct pcap_rmtauth *auth,
+    int *activep, SOCKET *sockctrlp, uint8 *protocol_versionp,
+    char *host, char *port, char *iface, char *errbuf)
+{
+	int type;
+	struct activehosts *activeconn;		/* active connection, if there is one */
+	int error;				/* 1 if rpcap_remoteact_getsock got an error */
+
+	/*
+	 * Determine the type of the source (NULL, file, local, remote).
+	 * You must have a valid source string even if we're in active mode,
+	 * because otherwise the call to the following function will fail.
+	 */
+	if (pcap_parsesrcstr(source, &type, host, port, iface, errbuf) == -1)
+		return -1;
+
+	/*
+	 * It must be remote.
+	 */
+	if (type != PCAP_SRC_IFREMOTE)
+	{
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+		    "Non-remote interface passed to remote capture routine");
+		return -1;
+	}
+
+	/* Warning: this call can be the first one called by the user. */
+	/* For this reason, we have to initialize the WinSock support. */
+	if (sock_init(errbuf, PCAP_ERRBUF_SIZE) == -1)
+		return -1;
+
+	/* Check for active mode */
+	activeconn = rpcap_remoteact_getsock(host, &error, errbuf);
+	if (activeconn != NULL)
+	{
+		*activep = 1;
+		*sockctrlp = activeconn->sockctrl;
+		*protocol_versionp = activeconn->protocol_version;
+	}
+	else
+	{
+		*activep = 0;
+		struct addrinfo hints;		/* temp variable needed to resolve hostnames into to socket representation */
+		struct addrinfo *addrinfo;	/* temp variable needed to resolve hostnames into to socket representation */
+
+		if (error)
+		{
+			/*
+			 * Call failed.
+			 */
+			return -1;
+		}
+
+		/*
+		 * We're not in active mode; let's try to open a new
+		 * control connection.
+		 */
+		memset(&hints, 0, sizeof(struct addrinfo));
+		hints.ai_family = PF_UNSPEC;
+		hints.ai_socktype = SOCK_STREAM;
+
+		if (port[0] == 0)
+		{
+			/* the user chose not to specify the port */
+			if (sock_initaddress(host, RPCAP_DEFAULT_NETPORT,
+			    &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
+				return -1;
+		}
+		else
+		{
+			if (sock_initaddress(host, port, &hints, &addrinfo,
+			    errbuf, PCAP_ERRBUF_SIZE) == -1)
+				return -1;
+		}
+
+		if ((*sockctrlp = sock_open(addrinfo, SOCKOPEN_CLIENT, 0,
+		    errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
+		{
+			freeaddrinfo(addrinfo);
+			return -1;
+		}
+
+		/* addrinfo is no longer used */
+		freeaddrinfo(addrinfo);
+		addrinfo = NULL;
+
+		if (rpcap_doauth(*sockctrlp, protocol_versionp, auth,
+		    errbuf) == -1)
+		{
+			sock_close(*sockctrlp, NULL, 0);
+			return -1;
+		}
+	}
+	return 0;
+}
+
 /*
  * This function opens a remote adapter by opening an RPCAP connection and
  * so on.
@@ -2105,15 +2189,12 @@
 	char *source_str;
 	struct pcap_rpcap *pr;		/* structure used when doing a remote live capture */
 	char host[PCAP_BUF_SIZE], ctrlport[PCAP_BUF_SIZE], iface[PCAP_BUF_SIZE];
-	struct activehosts *activeconn;		/* active connection, if there is one */
-	int error;				/* '1' if rpcap_remoteact_getsock returned an error */
 	SOCKET sockctrl;
 	uint8 protocol_version;			/* negotiated protocol version */
 	int active;
 	uint32 plen;
 	char sendbuf[RPCAP_NETBUF_SIZE];	/* temporary buffer in which data to be sent is buffered */
 	int sendbufidx = 0;			/* index which keeps the number of bytes currently buffered */
-	int retval;				/* store the return value of the functions */
 
 	/* RPCAP-related variables */
 	struct rpcap_header header;		/* header of the RPCAP packet */
@@ -2152,100 +2233,16 @@
 	pr->rmt_flags = flags;
 
 	/*
-	 * determine the type of the source (NULL, file, local, remote)
-	 * You must have a valid source string even if we're in active mode, because otherwise
-	 * the call to the following function will fail.
+	 * Attempt to set up the session with the server.
 	 */
-	if (pcap_parsesrcstr(fp->opt.device, &retval, host, ctrlport, iface, errbuf) == -1)
+	if (rpcap_setup_session(fp->opt.device, auth, &active, &sockctrl,
+	    &protocol_version, host, ctrlport, iface, errbuf) == -1)
 	{
+		/* Session setup failed. */
 		pcap_close(fp);
 		return NULL;
 	}
 
-	if (retval != PCAP_SRC_IFREMOTE)
-	{
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "This function is able to open only remote interfaces");
-		pcap_close(fp);
-		return NULL;
-	}
-
-	/*
-	 * Warning: this call can be the first one called by the user.
-	 * For this reason, we have to initialize the WinSock support.
-	 */
-	if (sock_init(errbuf, PCAP_ERRBUF_SIZE) == -1)
-	{
-		pcap_close(fp);
-		return NULL;
-	}
-
-	/* Check for active mode */
-	activeconn = rpcap_remoteact_getsock(host, &error, errbuf);
-	if (activeconn != NULL)
-	{
-		sockctrl = activeconn->sockctrl;
-		protocol_version = activeconn->protocol_version;
-		active = 1;
-	}
-	else
-	{
-		struct addrinfo hints;			/* temp, needed to open a socket connection */
-		struct addrinfo *addrinfo;		/* temp, needed to open a socket connection */
-
-		if (error)
-		{
-			/*
-			 * Call failed.
-			 */
-			pcap_close(fp);
-			return NULL;
-		}
-
-		/*
-		 * We're not in active mode; let's try to open a new
-		 * control connection.
-		 */
-		memset(&hints, 0, sizeof(struct addrinfo));
-		hints.ai_family = PF_UNSPEC;
-		hints.ai_socktype = SOCK_STREAM;
-
-		if (ctrlport[0] == 0)
-		{
-			/* the user chose not to specify the port */
-			if (sock_initaddress(host, RPCAP_DEFAULT_NETPORT, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
-			{
-				pcap_close(fp);
-				return NULL;
-			}
-		}
-		else
-		{
-			if (sock_initaddress(host, ctrlport, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
-			{
-				pcap_close(fp);
-				return NULL;
-			}
-		}
-
-		if ((sockctrl = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
-		{
-			freeaddrinfo(addrinfo);
-			pcap_close(fp);
-			return NULL;
-		}
-
-		/* addrinfo is no longer used */
-		freeaddrinfo(addrinfo);
-
-		if (rpcap_doauth(sockctrl, &protocol_version, auth, errbuf) == -1)
-		{
-			sock_close(sockctrl, NULL, 0);
-			pcap_close(fp);
-			return NULL;
-		}
-		active = 0;
-	}
-
 	/*
 	 * Now it's time to start playing with the RPCAP protocol
 	 * RPCAP open command: create the request message
@@ -2277,7 +2274,7 @@
 		goto error;
 
 	/* Discard the rest of the message, if there is any. */
-	if (rpcap_discard(pr->rmt_sockctrl, plen, errbuf) == -1)
+	if (rpcap_discard(sockctrl, plen, errbuf) == -1)
 		goto error_nodiscard;
 
 	/* Set proper fields into the pcap_t struct */
@@ -2315,7 +2312,7 @@
 	 * We already reported an error; if this gets an error, just
 	 * drive on.
 	 */
-	(void)rpcap_discard(pr->rmt_sockctrl, plen, NULL);
+	(void)rpcap_discard(sockctrl, plen, NULL);
 
 error_nodiscard:
 	if (!active)
@@ -2327,8 +2324,10 @@
 
 /* String identifier to be used in the pcap_findalldevs_ex() */
 #define PCAP_TEXT_SOURCE_ADAPTER "Network adapter"
+#define PCAP_TEXT_SOURCE_ADAPTER_LEN (sizeof PCAP_TEXT_SOURCE_ADAPTER - 1)
 /* String identifier to be used in the pcap_findalldevs_ex() */
 #define PCAP_TEXT_SOURCE_ON_REMOTE_HOST "on remote node"
+#define PCAP_TEXT_SOURCE_ON_REMOTE_HOST_LEN (sizeof PCAP_TEXT_SOURCE_ON_REMOTE_HOST - 1)
 
 static void
 freeaddr(struct pcap_addr *addr)
@@ -2341,10 +2340,8 @@
 }
 
 int
-pcap_findalldevs_ex_remote(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf)
+pcap_findalldevs_ex_remote(const char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf)
 {
-	struct activehosts *activeconn;	/* active connection, if there is one */
-	int error;			/* '1' if rpcap_remoteact_getsock returned an error */
 	uint8 protocol_version;		/* protocol version */
 	SOCKET sockctrl;		/* socket descriptor of the control connection */
 	uint32 plen;
@@ -2352,7 +2349,6 @@
 	int i, j;		/* temp variables */
 	int nif;		/* Number of interfaces listed */
 	int active;			/* 'true' if we the other end-party is in active mode */
-	int type;
 	char host[PCAP_BUF_SIZE], port[PCAP_BUF_SIZE];
 	char tmpstring[PCAP_BUF_SIZE + 1];		/* Needed to convert names and descriptions from 'old' syntax to the 'new' one */
 	pcap_if_t *lastdev;	/* Last device in the pcap_if_t list */
@@ -2362,72 +2358,14 @@
 	(*alldevs) = NULL;
 	lastdev = NULL;
 
-	/* Retrieve the needed data for getting adapter list */
-	if (pcap_parsesrcstr(source, &type, host, port, NULL, errbuf) == -1)
-		return -1;
-
-	/* Warning: this call can be the first one called by the user. */
-	/* For this reason, we have to initialize the WinSock support. */
-	if (sock_init(errbuf, PCAP_ERRBUF_SIZE) == -1)
-		return -1;
-
-	/* Check for active mode */
-	activeconn = rpcap_remoteact_getsock(host, &error, errbuf);
-	if (activeconn != NULL)
+	/*
+	 * Attempt to set up the session with the server.
+	 */
+	if (rpcap_setup_session(source, auth, &active, &sockctrl,
+	    &protocol_version, host, port, NULL, errbuf) == -1)
 	{
-		sockctrl = activeconn->sockctrl;
-		protocol_version = activeconn->protocol_version;
-		active = 1;
-	}
-	else
-	{
-		struct addrinfo hints;		/* temp variable needed to resolve hostnames into to socket representation */
-		struct addrinfo *addrinfo;	/* temp variable needed to resolve hostnames into to socket representation */
-
-		if (error)
-		{
-			/*
-			 * Call failed.
-			 */
-			return -1;
-		}
-
-		/*
-		 * We're not in active mode; let's try to open a new
-		 * control connection.
-		 */
-		memset(&hints, 0, sizeof(struct addrinfo));
-		hints.ai_family = PF_UNSPEC;
-		hints.ai_socktype = SOCK_STREAM;
-
-		if (port[0] == 0)
-		{
-			/* the user chose not to specify the port */
-			if (sock_initaddress(host, RPCAP_DEFAULT_NETPORT, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
-				return -1;
-		}
-		else
-		{
-			if (sock_initaddress(host, port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
-				return -1;
-		}
-
-		if ((sockctrl = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
-		{
-			freeaddrinfo(addrinfo);
-			return -1;
-		}
-
-		/* addrinfo is no longer used */
-		freeaddrinfo(addrinfo);
-		addrinfo = NULL;
-
-		if (rpcap_doauth(sockctrl, &protocol_version, auth, errbuf) == -1)
-		{
-			sock_close(sockctrl, NULL, 0);
-			return -1;
-		}
-		active = 0;
+		/* Session setup failed. */
+		return -1;
 	}
 
 	/* RPCAP findalldevs command */
@@ -2453,7 +2391,6 @@
 	{
 		struct rpcap_findalldevs_if findalldevs_if;
 		char tmpstring2[PCAP_BUF_SIZE + 1];		/* Needed to convert names and descriptions from 'old' syntax to the 'new' one */
-		size_t stringlen;
 		struct pcap_addr *addr, *prevaddr;
 
 		tmpstring2[PCAP_BUF_SIZE] = 0;
@@ -2515,21 +2452,17 @@
 			tmpstring[findalldevs_if.namelen] = 0;
 
 			/* Create the new device identifier */
-			if (pcap_createsrcstr(tmpstring2, PCAP_SRC_IFREMOTE, host, port, tmpstring, errbuf) == -1)
-				return -1;
+			if (pcap_createsrcstr(tmpstring2, PCAP_SRC_IFREMOTE,
+			    host, port, tmpstring, errbuf) == -1)
+				goto error;
 
-			stringlen = strlen(tmpstring2);
-
-			dev->name = (char *)malloc(stringlen + 1);
+			dev->name = strdup(tmpstring2);
 			if (dev->name == NULL)
 			{
 				pcap_fmt_errmsg_for_errno(errbuf,
 				    PCAP_ERRBUF_SIZE, errno, "malloc() failed");
 				goto error;
 			}
-
-			/* Copy the new device name into the correct memory location */
-			strlcpy(dev->name, tmpstring2, stringlen + 1);
 		}
 
 		if (findalldevs_if.desclen)
@@ -2547,22 +2480,14 @@
 
 			tmpstring[findalldevs_if.desclen] = 0;
 
-			pcap_snprintf(tmpstring2, sizeof(tmpstring2) - 1, "%s '%s' %s %s", PCAP_TEXT_SOURCE_ADAPTER,
-				tmpstring, PCAP_TEXT_SOURCE_ON_REMOTE_HOST, host);
-
-			stringlen = strlen(tmpstring2);
-
-			dev->description = (char *)malloc(stringlen + 1);
-
-			if (dev->description == NULL)
+			if (pcap_asprintf(&dev->description,
+			    "%s '%s' %s %s", PCAP_TEXT_SOURCE_ADAPTER,
+			    tmpstring, PCAP_TEXT_SOURCE_ON_REMOTE_HOST, host) == -1)
 			{
 				pcap_fmt_errmsg_for_errno(errbuf,
 				    PCAP_ERRBUF_SIZE, errno, "malloc() failed");
 				goto error;
 			}
-
-			/* Copy the new device description into the correct memory location */
-			strlcpy(dev->description, tmpstring2, stringlen + 1);
 		}
 
 		dev->flags = ntohl(findalldevs_if.flags);
@@ -2731,7 +2656,6 @@
 	{
 		if (sock_initaddress(address, RPCAP_DEFAULT_NETPORT_ACTIVE, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
 		{
-			SOCK_DEBUG_MESSAGE(errbuf);
 			return (SOCKET)-2;
 		}
 	}
@@ -2739,7 +2663,6 @@
 	{
 		if (sock_initaddress(address, port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
 		{
-			SOCK_DEBUG_MESSAGE(errbuf);
 			return (SOCKET)-2;
 		}
 	}
@@ -2747,7 +2670,6 @@
 
 	if ((sockmain = sock_open(addrinfo, SOCKOPEN_SERVER, 1, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
 	{
-		SOCK_DEBUG_MESSAGE(errbuf);
 		freeaddrinfo(addrinfo);
 		return (SOCKET)-2;
 	}
@@ -2765,14 +2687,14 @@
 
 	if (sockctrl == INVALID_SOCKET)
 	{
-		sock_geterror("accept(): ", errbuf, PCAP_ERRBUF_SIZE);
+		sock_geterror("accept()", errbuf, PCAP_ERRBUF_SIZE);
 		return (SOCKET)-2;
 	}
 
 	/* Get the numeric for of the name of the connecting host */
 	if (getnameinfo((struct sockaddr *) &from, fromlen, connectinghost, RPCAP_HOSTLIST_SIZE, NULL, 0, NI_NUMERICHOST))
 	{
-		sock_geterror("getnameinfo(): ", errbuf, PCAP_ERRBUF_SIZE);
+		sock_geterror("getnameinfo()", errbuf, PCAP_ERRBUF_SIZE);
 		rpcap_senderror(sockctrl, 0, PCAP_ERR_REMOTEACCEPT, errbuf, NULL);
 		sock_close(sockctrl, NULL, 0);
 		return (SOCKET)-1;
@@ -2971,7 +2893,7 @@
 			/*	if (getnameinfo( (struct sockaddr *) &temp->host, sizeof (struct sockaddr_storage), hoststr, */
 			/*		RPCAP_HOSTLIST_SIZE, NULL, 0, NI_NUMERICHOST) ) */
 		{
-			/*	sock_geterror("getnameinfo(): ", errbuf, PCAP_ERRBUF_SIZE); */
+			/*	sock_geterror("getnameinfo()", errbuf, PCAP_ERRBUF_SIZE); */
 			return -1;
 		}
 
@@ -2984,7 +2906,7 @@
 			return -1;
 		}
 
-		strlcat(hostlist, hoststr, PCAP_ERRBUF_SIZE);
+		pcap_strlcat(hostlist, hoststr, PCAP_ERRBUF_SIZE);
 		hostlist[len - 1] = sep;
 		hostlist[len] = 0;
 
diff --git a/pcap-rpcap.h b/pcap-rpcap.h
index be31c40..6ad6d98 100644
--- a/pcap-rpcap.h
+++ b/pcap-rpcap.h
@@ -43,7 +43,7 @@
 /*
  * Internal interfaces for "pcap_findalldevs_ex()".
  */
-int	pcap_findalldevs_ex_remote(char *source, struct pcap_rmtauth *auth,
-   pcap_if_t **alldevs, char *errbuf);
+int	pcap_findalldevs_ex_remote(const char *source,
+    struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf);
 
 #endif
diff --git a/pcap-savefile.manfile b/pcap-savefile.manfile
index f07d849..c2de543 100644
--- a/pcap-savefile.manfile
+++ b/pcap-savefile.manfile
@@ -130,4 +130,4 @@
 will be equal if the number of bytes of packet data are less than or
 equal to the snapshot length.
 .SH SEE ALSO
-pcap(3PCAP), pcap-linktype(7)
+pcap(3PCAP)
diff --git a/pcap-savefile.manfile.in b/pcap-savefile.manfile.in
index 451dd90..748d7af 100644
--- a/pcap-savefile.manfile.in
+++ b/pcap-savefile.manfile.in
@@ -130,4 +130,4 @@
 will be equal if the number of bytes of packet data are less than or
 equal to the snapshot length.
 .SH SEE ALSO
-pcap(3PCAP), pcap-linktype(@MAN_MISC_INFO@)
+pcap(3PCAP)
diff --git a/pcap-septel.c b/pcap-septel.c
index 0471153..24cb47b 100644
--- a/pcap-septel.c
+++ b/pcap-septel.c
@@ -1,15 +1,6 @@
 /*
  * pcap-septel.c: Packet capture interface for Intel/Septel card.
  *
- * The functionality of this code attempts to mimic that of pcap-linux as much
- * as possible.  This code is compiled in several different ways depending on
- * whether SEPTEL_ONLY and HAVE_SEPTEL_API are defined.  If HAVE_SEPTEL_API is
- * not defined it should not get compiled in, otherwise if SEPTEL_ONLY is
- * defined then the 'septel_' function calls are renamed to 'pcap_'
- * equivalents.  If SEPTEL_ONLY is not defined then nothing is altered - the
- * septel_ functions will be called as required from their
- * pcap-linux/equivalents.
- *
  * Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY
  * (+961 3 485243)
  */
@@ -182,7 +173,7 @@
 static int
 septel_inject(pcap_t *handle, const void *buf _U_, size_t size _U_)
 {
-  strlcpy(handle->errbuf, "Sending packets isn't supported on Septel cards",
+  pcap_strlcpy(handle->errbuf, "Sending packets isn't supported on Septel cards",
           PCAP_ERRBUF_SIZE);
   return (-1);
 }
diff --git a/pcap-sita.c b/pcap-sita.c
index 7c42791..b9dda9c 100644
--- a/pcap-sita.c
+++ b/pcap-sita.c
@@ -884,7 +884,7 @@
 }
 
 static int pcap_inject_acn(pcap_t *p, const void *buf _U_, size_t size _U_) {
-	strlcpy(p->errbuf, "Sending packets isn't supported on ACN adapters",
+	pcap_strlcpy(p->errbuf, "Sending packets isn't supported on ACN adapters",
 	    PCAP_ERRBUF_SIZE);
 	return (-1);
 }
diff --git a/pcap-sita.html b/pcap-sita.html
index 97408d8..4a8fe1a 100644
--- a/pcap-sita.html
+++ b/pcap-sita.html
@@ -411,7 +411,7 @@
 					<TR>
 						<TD VALIGN=TOP>Interface ID</TD>
 						<TD VALIGN=TOP ALIGN=CENTER>1</TD>
-						<TD VALIGN=TOP>A NULL to indicate an an empty 'interface ID'.</TD>
+						<TD VALIGN=TOP>A NULL to indicate an empty 'interface ID'.</TD>
 					</TR>
 				</TABLE>
 			</TD>
diff --git a/pcap-snf.c b/pcap-snf.c
index 4eae0b3..50d92cd 100644
--- a/pcap-snf.c
+++ b/pcap-snf.c
@@ -182,8 +182,8 @@
 			hdr.caplen = caplen;
 			hdr.len = req.length;
 			callback(user, &hdr, req.pkt_addr);
+			n++;
 		}
-		n++;
 
 		/* After one successful packet is received, we won't block
 		* again for that timeout. */
@@ -237,7 +237,7 @@
 		return (-1);
 	}
 #else
-	strlcpy(p->errbuf, "Sending packets isn't supported with this snf version",
+	pcap_strlcpy(p->errbuf, "Sending packets isn't supported with this snf version",
 	    PCAP_ERRBUF_SIZE);
 	return (-1);
 #endif
diff --git a/pcap-tc.c b/pcap-tc.c
index 38c7024..65fb0e2 100644
--- a/pcap-tc.c
+++ b/pcap-tc.c
@@ -123,7 +123,7 @@
 static int TcGetNonBlock(pcap_t *p);
 static int TcSetNonBlock(pcap_t *p, int nonblock);
 static void TcCleanup(pcap_t *p);
-static int TcInject(pcap_t *p, const void *buf, size_t size);
+static int TcInject(pcap_t *p, const void *buf, int size);
 static int TcRead(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
 static int TcStats(pcap_t *p, struct pcap_stat *ps);
 static int TcSetFilter(pcap_t *p, struct bpf_program *fp);
@@ -440,7 +440,7 @@
 	PTC_PORT pPorts = NULL;
 	TC_STATUS status;
 	int result = 0;
-	pcap_if_t *dev, *cursor;
+	pcap_if_t *dev;
 	ULONG i;
 
 	do
@@ -472,22 +472,7 @@
 			dev = TcCreatePcapIfFromPort(pPorts[i]);
 
 			if (dev != NULL)
-			{
-				/*
-				 * append it at the end
-				 */
-				if (devlistp->beginning == NULL)
-				{
-					devlistp->beginning = dev;
-				}
-				else
-				{
-					for (cursor = devlistp->beginning;
-					    cursor->next != NULL;
-					    cursor = cursor->next);
-					cursor->next = dev;
-				}
-			}
+				add_dev(devlist, dev->name, dev->flags, dev->description, errbuf);
 		}
 
 		if (numPorts > 0)
@@ -846,7 +831,7 @@
 }
 
 /* Send a packet to the network */
-static int TcInject(pcap_t *p, const void *buf, size_t size)
+static int TcInject(pcap_t *p, const void *buf, int size)
 {
 	struct pcap_tc *pt = p->priv;
 	TC_STATUS status;
diff --git a/pcap-tstamp.manmisc b/pcap-tstamp.manmisc
index c8b7fed..22e0317 100644
--- a/pcap-tstamp.manmisc
+++ b/pcap-tstamp.manmisc
@@ -93,9 +93,9 @@
 call to specify the type of time stamp to be used on the device.
 The time stamp types are listed here; the first value is the #define to
 use in code, the second value is the value returned by
-.B pcap_tstamp_type_val_to_name()
+.B pcap_tstamp_type_val_to_name(3PCAP)
 and accepted by
-.BR pcap_tstamp_type_name_to_val() .
+.BR pcap_tstamp_type_name_to_val(3PCAP) .
 .RS 5
 .TP 5
 .BR PCAP_TSTAMP_HOST " - " host
@@ -149,9 +149,9 @@
 call will have microsecond resolution.
 .LP
 When opening a savefile, the
-.BR pcap_open_offline_with_tstamp_precision (3PCAP)
+.BR \%pcap_open_offline_with_tstamp_precision (3PCAP)
 and
-.BR pcap_fopen_offline_with_tstamp_precision (3PCAP)
+.BR \%pcap_fopen_offline_with_tstamp_precision (3PCAP)
 routines can be used to specify the resolution of time stamps to be read
 from the file; if the time stamps in the file have a lower resolution,
 the fraction-of-a-second portion of the time stamps will be scaled to
@@ -165,13 +165,4 @@
 reading a savefile, this does not indicate the actual precision of time
 stamps in the file.
 .SH SEE ALSO
-.na
-pcap_set_tstamp_type(3PCAP),
-pcap_list_tstamp_types(3PCAP),
-pcap_tstamp_type_val_to_name(3PCAP),
-pcap_tstamp_type_name_to_val(3PCAP),
-pcap_set_tstamp_precision(3PCAP),
-pcap_open_offline_with_tstamp_precision(3PCAP),
-\%pcap_fopen_offline_with_tstamp_precision(3PCAP),
-\%pcap_get_tstamp_precision(3PCAP)
-.ad
+pcap(3PCAP)
diff --git a/pcap-tstamp.manmisc.in b/pcap-tstamp.manmisc.in
index 38c5651..6437e80 100644
--- a/pcap-tstamp.manmisc.in
+++ b/pcap-tstamp.manmisc.in
@@ -93,9 +93,9 @@
 call to specify the type of time stamp to be used on the device.
 The time stamp types are listed here; the first value is the #define to
 use in code, the second value is the value returned by
-.B pcap_tstamp_type_val_to_name()
+.B pcap_tstamp_type_val_to_name(3PCAP)
 and accepted by
-.BR pcap_tstamp_type_name_to_val() .
+.BR pcap_tstamp_type_name_to_val(3PCAP) .
 .RS 5
 .TP 5
 .BR PCAP_TSTAMP_HOST " - " host
@@ -149,9 +149,9 @@
 call will have microsecond resolution.
 .LP
 When opening a savefile, the
-.BR pcap_open_offline_with_tstamp_precision (3PCAP)
+.BR \%pcap_open_offline_with_tstamp_precision (3PCAP)
 and
-.BR pcap_fopen_offline_with_tstamp_precision (3PCAP)
+.BR \%pcap_fopen_offline_with_tstamp_precision (3PCAP)
 routines can be used to specify the resolution of time stamps to be read
 from the file; if the time stamps in the file have a lower resolution,
 the fraction-of-a-second portion of the time stamps will be scaled to
@@ -165,13 +165,4 @@
 reading a savefile, this does not indicate the actual precision of time
 stamps in the file.
 .SH SEE ALSO
-.na
-pcap_set_tstamp_type(3PCAP),
-pcap_list_tstamp_types(3PCAP),
-pcap_tstamp_type_val_to_name(3PCAP),
-pcap_tstamp_type_name_to_val(3PCAP),
-pcap_set_tstamp_precision(3PCAP),
-pcap_open_offline_with_tstamp_precision(3PCAP),
-\%pcap_fopen_offline_with_tstamp_precision(3PCAP),
-\%pcap_get_tstamp_precision(3PCAP)
-.ad
+pcap(3PCAP)
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index 6f8adf6..b306dca 100644
--- a/pcap-usb-linux.c
+++ b/pcap-usb-linux.c
@@ -50,6 +50,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <string.h>
 #include <dirent.h>
 #include <byteswap.h>
@@ -241,7 +242,7 @@
 		 */
 		if (add_dev(devlistp, dev_name,
 		    PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE,
-		    "All USB buses", err_str) == NULL)
+		    "Raw USB traffic, all USB buses", err_str) == NULL)
 			return -1;
 	} else {
 		/*
@@ -250,7 +251,7 @@
 		 * PCAP_IF_CONNECTION_STATUS_CONNECTED or
 		 * PCAP_IF_CONNECTION_STATUS_DISCONNECTED?
 		 */
-		pcap_snprintf(dev_descr, 30, "USB bus number %d", n);
+		pcap_snprintf(dev_descr, 30, "Raw USB traffic, bus number %d", n);
 		if (add_dev(devlistp, dev_name, 0, dev_descr, err_str) == NULL)
 			return -1;
 	}
@@ -278,7 +279,7 @@
 		 * Split LINUX_USB_MON_DEV into a directory that we'll
 		 * scan and a file name prefix that we'll check for.
 		 */
-		strlcpy(usb_mon_dir, LINUX_USB_MON_DEV, sizeof usb_mon_dir);
+		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) {
 			/*
@@ -380,18 +381,102 @@
 	}
 }
 
+/*
+ * Matches what's in mon_bin.c in the Linux kernel.
+ */
+#define MIN_RING_SIZE	(8*1024)
+#define MAX_RING_SIZE	(1200*1024)
+
+static int
+usb_set_ring_size(pcap_t* handle, int header_size)
+{
+	/*
+	 * A packet from binary usbmon has:
+	 *
+	 *  1) a fixed-length header, of size header_size;
+	 *  2) descriptors, for isochronous transfers;
+	 *  3) the payload.
+	 *
+	 * The kernel buffer has a size, defaulting to 300KB, with a
+	 * minimum of 8KB and a maximum of 1200KB.  The size is set with
+	 * the MON_IOCT_RING_SIZE ioctl; the size passed in is rounded up
+	 * to a page size.
+	 *
+	 * No more than {buffer size}/5 bytes worth of payload is saved.
+	 * Therefore, if we subtract the fixed-length size from the
+	 * snapshot length, we have the biggest payload we want (we
+	 * don't worry about the descriptors - if we have descriptors,
+	 * we'll just discard the last bit of the payload to get it
+	 * to fit).  We multiply that result by 5 and set the buffer
+	 * size to that value.
+	 */
+	int ring_size;
+
+	if (handle->snapshot < header_size)
+		handle->snapshot = header_size;
+	/* The maximum snapshot size is small enough that this won't overflow */
+	ring_size = (handle->snapshot - header_size) * 5;
+
+	/*
+	 * Will this get an error?
+	 * (There's no wqy to query the minimum or maximum, so we just
+	 * copy the value from the kernel source.  We don't round it
+	 * up to a multiple of the page size.)
+	 */
+	if (ring_size > MAX_RING_SIZE) {
+		/*
+		 * Yes.  Lower the ring size to the maximum, and set the
+		 * snapshot length to the value that would give us a
+		 * maximum-size ring.
+		 */
+		ring_size = MAX_RING_SIZE;
+		handle->snapshot = header_size + (MAX_RING_SIZE/5);
+	} else if (ring_size < MIN_RING_SIZE) {
+		/*
+		 * Yes.  Raise the ring size to the minimum, but leave
+		 * the snapshot length unchanged, so we show the
+		 * callback no more data than specified by the
+		 * snapshot length.
+		 */
+		ring_size = MIN_RING_SIZE;
+	}
+
+	if (ioctl(handle->fd, MON_IOCT_RING_SIZE, ring_size) == -1) {
+		pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
+		    errno, "Can't set ring size from fd %d", handle->fd);
+		return -1;
+	}
+	return ring_size;
+}
+
 static
 int usb_mmap(pcap_t* handle)
 {
 	struct pcap_usb_linux *handlep = handle->priv;
-	int len = ioctl(handle->fd, MON_IOCQ_RING_SIZE);
-	if (len < 0)
+	int len;
+
+	/*
+	 * 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.
+	 */
+	len = usb_set_ring_size(handle, (int)sizeof(pcap_usb_header_mmapped));
+	if (len == -1) {
+		/* Failed.  Fall back on non-memory-mapped access. */
 		return 0;
+	}
 
 	handlep->mmapbuflen = len;
 	handlep->mmapbuf = mmap(0, handlep->mmapbuflen, PROT_READ,
 	    MAP_SHARED, handle->fd, 0);
-	return handlep->mmapbuf != MAP_FAILED;
+	if (handlep->mmapbuf == MAP_FAILED) {
+		/*
+		 * Failed.  We don't treat that as a fatal error, we
+		 * just try to fall back on non-memory-mapped access.
+		 */
+		return 0;
+	}
+	return 1;
 }
 
 #ifdef HAVE_LINUX_USBDEVICE_FS_H
@@ -514,6 +599,7 @@
 {
 	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
@@ -604,6 +690,7 @@
 		/* 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;
@@ -620,7 +707,19 @@
 			return 0;
 		}
 
-		/* can't mmap, use plain binary interface access */
+		/*
+		 * 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
@@ -646,38 +745,38 @@
 				handle->fd = open(full_path, O_RDONLY, 0);
 			}
 			if (handle->fd < 0) {
-				/*
-				 * Is the problem that we didn't have
-				 * sufficient permission to open it?
-				 */
-				if (errno == EACCES) {
+				if (errno == ENOENT)
+				{
 					/*
-					 * Yes - return that error.
+					 * 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".)
 					 */
-					return PCAP_ERROR_PERM_DENIED;
+					ret = PCAP_ERROR_NO_SUCH_DEVICE;
 				}
-
-				/*
-				 * No - was the problem something other
-				 * than "it doesn't exist"?
-				 */
-				if (errno != ENOENT) {
+				else if (errno == EACCES)
+				{
 					/*
-					 * Yes - return *that* error.
+					 * The problem is that we don't
+					 * have sufficient permission to
+					 * open the file.  Report that.
 					 */
-					pcap_fmt_errmsg_for_errno(handle->errbuf,
-					    PCAP_ERRBUF_SIZE, errno,
-					    "Can't open USB bus file %s",
-					    full_path);
-					return PCAP_ERROR;
+					ret = PCAP_ERROR_PERM_DENIED;
 				}
-
-				/*
-				 * No.  Report that as "no such device".
-				 * (That could mean "no such USB bus"
-				 * or "monitoring not supported".)
-				 */
-				return PCAP_ERROR_NO_SUCH_DEVICE;
+				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;
 			}
 		}
 
@@ -923,8 +1022,8 @@
 static int
 usb_inject_linux(pcap_t *handle, const void *buf _U_, size_t size _U_)
 {
-	pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
-		"USB devices");
+	pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+	    "Packet injection is not supported on USB devices");
 	return (-1);
 }
 
@@ -973,6 +1072,10 @@
 	}
 	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:
@@ -989,18 +1092,16 @@
 			break;
 		consumed += cnt;
 		ptr += cnt;
-		if (strcmp(token, "nreaders") == 0)
-			ret = sscanf(ptr, "%d", &stats->ps_drop);
+		if (strcmp(token, "text_lost") == 0)
+			ntok = sscanf(ptr, "%d%n", &stats->ps_drop, &cnt);
 		else
-			ret = sscanf(ptr, "%d", &dummy);
-		if (ntok != 1)
+			ntok = sscanf(ptr, "%d%n", &dummy, &cnt);
+		if ((ntok != 1) || (cnt < 0))
 			break;
 		consumed += cnt;
 		ptr += cnt;
 	}
 
-	stats->ps_recv = handlep->packets_read;
-	stats->ps_ifdrop = 0;
 	return 0;
 }
 
@@ -1069,13 +1170,44 @@
 		return -1;
 	}
 
-	/* we can get less that than really captured from kernel, depending on
-	 * snaplen, so adjust header accordingly */
+	/*
+	 * info.hdr->data_len is the number of bytes of isochronous
+	 * descriptors (if any) plus the number of bytes of data
+	 * provided.  There are no isochronous descriptors here,
+	 * because we're using the old 48-byte header.
+	 *
+	 * If info.hdr->data_flag is non-zero, there's no URB data;
+	 * info.hdr->urb_len is the size of the buffer into which
+	 * data is to be placed; it does not represent the amount
+	 * of data transferred.  If info.hdr->data_flag is zero,
+	 * there is URB data, and info.hdr->urb_len is the number
+	 * of bytes transmitted or received; it doesn't include
+	 * isochronous descriptors.
+	 *
+	 * The kernel may give us more data than the snaplen; if it did,
+	 * reduce the data length so that the total number of bytes we
+	 * tell our client we have is not greater than the snaplen.
+	 */
 	if (info.hdr->data_len < clen)
 		clen = info.hdr->data_len;
 	info.hdr->data_len = clen;
-	pkth.caplen = clen + sizeof(pcap_usb_header);
-	pkth.len = info.hdr->data_len + sizeof(pcap_usb_header);
+	pkth.caplen = sizeof(pcap_usb_header) + clen;
+	if (info.hdr->data_flag) {
+		/*
+		 * No data; just base the on-the-wire length on
+		 * info.hdr->data_len (so that it's >= the captured
+		 * length).
+		 */
+		pkth.len = sizeof(pcap_usb_header) + info.hdr->data_len;
+	} else {
+		/*
+		 * We got data; base the on-the-wire length on
+		 * info.hdr->urb_len, so that it includes data
+		 * discarded by the USB monitor device due to
+		 * its buffer being too small.
+		 */
+		pkth.len = sizeof(pcap_usb_header) + info.hdr->urb_len;
+	}
 	pkth.ts.tv_sec = info.hdr->ts_sec;
 	pkth.ts.tv_usec = info.hdr->ts_usec;
 
@@ -1102,12 +1234,12 @@
 	struct mon_bin_mfetch fetch;
 	int32_t vec[VEC_SIZE];
 	struct pcap_pkthdr pkth;
-	pcap_usb_header* hdr;
+	pcap_usb_header_mmapped* hdr;
 	int nflush = 0;
 	int packets = 0;
 	u_int clen, max_clen;
 
-	max_clen = handle->snapshot - sizeof(pcap_usb_header);
+	max_clen = handle->snapshot - sizeof(pcap_usb_header_mmapped);
 
 	for (;;) {
 		int i, ret;
@@ -1145,19 +1277,52 @@
 		nflush = fetch.nfetch;
 		for (i=0; i<fetch.nfetch; ++i) {
 			/* discard filler */
-			hdr = (pcap_usb_header*) &handlep->mmapbuf[vec[i]];
+			hdr = (pcap_usb_header_mmapped*) &handlep->mmapbuf[vec[i]];
 			if (hdr->event_type == '@')
 				continue;
 
-			/* we can get less that than really captured from kernel, depending on
-	 		* snaplen, so adjust header accordingly */
+			/*
+			 * hdr->data_len is the number of bytes of
+			 * isochronous descriptors (if any) plus the
+			 * number of bytes of data provided.
+			 *
+			 * If hdr->data_flag is non-zero, there's no
+			 * URB data; hdr->urb_len is the size of the
+			 * buffer into which data is to be placed; it does
+			 * not represent the amount of data transferred.
+			 * If hdr->data_flag is zero, there is URB data,
+			 * and hdr->urb_len is the number of bytes
+			 * transmitted or received; it doesn't include
+			 * isochronous descriptors.
+			 *
+			 * The kernel may give us more data than the
+			 * snaplen; if it did, reduce the data length
+			 * so that the total number of bytes we
+			 * tell our client we have is not greater than
+			 * the snaplen.
+			 */
 			clen = max_clen;
 			if (hdr->data_len < clen)
 				clen = hdr->data_len;
-
-			/* get packet info from header*/
-			pkth.caplen = clen + sizeof(pcap_usb_header_mmapped);
-			pkth.len = hdr->data_len + sizeof(pcap_usb_header_mmapped);
+			pkth.caplen = sizeof(pcap_usb_header_mmapped) + clen;
+			if (hdr->data_flag) {
+				/*
+				 * No data; just base the on-the-wire length
+				 * on hdr->data_len (so that it's >= the
+				 * captured length).
+				 */
+				pkth.len = sizeof(pcap_usb_header_mmapped) +
+				    hdr->data_len;
+			} else {
+				/*
+				 * We got data; base the on-the-wire length
+				 * on hdr->urb_len, so that it includes
+				 * data discarded by the USB monitor device
+				 * due to its buffer being too small.
+				 */
+				pkth.len = sizeof(pcap_usb_header_mmapped) +
+				    (hdr->ndesc * sizeof (usb_isodesc)) + hdr->urb_len;
+			}
 			pkth.ts.tv_sec = hdr->ts_sec;
 			pkth.ts.tv_usec = hdr->ts_usec;
 
diff --git a/pcap.3pcap b/pcap.3pcap
index c6b8891..238f7d3 100644
--- a/pcap.3pcap
+++ b/pcap.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP 3PCAP "20 April 2018"
+.TH PCAP 3PCAP "25 July 2018"
 .SH NAME
 pcap \- Packet Capture library
 .SH SYNOPSIS
@@ -191,6 +191,10 @@
 .IP
 The packet buffer timeout is set with
 .BR pcap_set_timeout ().
+.IP "immediate mode"
+In immediate mode, packets are always delivered as soon as they arrive,
+with no buffering.  Immediate mode is set with
+.BR pcap_set_immediate_mode ().
 .IP "buffer size"
 Packets that arrive for a capture are stored in a buffer, so that they
 do not have to be read by the application as soon as they arrive.  On
@@ -416,6 +420,11 @@
 .B pcap_t
 for live capture
 .TP
+.BR pcap_set_immediate_mode (3PCAP)
+set immediate mode for a not-yet-activated
+.B pcap_t
+for live capture
+.TP
 .BR pcap_set_buffer_size (3PCAP)
 set buffer size for a not-yet-activated
 .B pcap_t
@@ -632,9 +641,28 @@
 descriptors to be ready to read.  To obtain, for a handle, a descriptor
 that can be used in those routines, call
 .BR pcap_get_selectable_fd ().
+If the routine indicates that data is
+available to read on the descriptor, an attempt should be made to read
+from the device.
+.PP
 Not all handles have such a descriptor available;
 .BR pcap_get_selectable_fd ()
-will return \-1 if no such descriptor exists.  In addition, for various
+will return
+.B PCAP_ERROR
+if no such descriptor is available.  If no such
+descriptor is available, this may be because the device must be polled
+periodically for packets; in that case,
+.BR pcap_get_required_select_timeout ()
+will return a pointer to a
+.B struct timeval
+whose value can be used as a timeout in those routines.  When the
+routine returns, an attmept should be made to read packets from the
+device.  If
+.BR pcap_get_required_select_timeout ()
+returns NULL, no such timeout is available, and those routines cannot be
+used with the device.
+.PP
+In addition, for various
 reasons, one or more of those routines will not work properly with the
 descriptor; the documentation for
 .BR pcap_get_selectable_fd ()
@@ -693,6 +721,15 @@
 .BR select (2)
 and
 .BR poll (2)
+.TP
+.BR pcap_get_required_select_timeout (3PCAP)
+if no descriptor usable with
+.BR select (2)
+and
+.BR poll (2)
+is available for the
+.BR pcap_t ,
+attempt to get a timeout usable with those routines
 .RE
 .SS Filters
 In order to cause only certain packets to be returned when reading
@@ -890,7 +927,7 @@
 .BR pcap_lib_version (3PCAP)
 get library version string
 .RE
-.SH BACKWARDS COMPATIBILITY
+.SH BACKWARD COMPATIBILITY
 .PP
 In versions of libpcap prior to 1.0, the
 .B pcap.h
diff --git a/pcap.3pcap.in b/pcap.3pcap.in
index 4a222c7..8010140 100644
--- a/pcap.3pcap.in
+++ b/pcap.3pcap.in
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP 3PCAP "20 April 2018"
+.TH PCAP 3PCAP "25 July 2018"
 .SH NAME
 pcap \- Packet Capture library
 .SH SYNOPSIS
@@ -191,6 +191,10 @@
 .IP
 The packet buffer timeout is set with
 .BR pcap_set_timeout ().
+.IP "immediate mode"
+In immediate mode, packets are always delivered as soon as they arrive,
+with no buffering.  Immediate mode is set with
+.BR pcap_set_immediate_mode ().
 .IP "buffer size"
 Packets that arrive for a capture are stored in a buffer, so that they
 do not have to be read by the application as soon as they arrive.  On
@@ -416,6 +420,11 @@
 .B pcap_t
 for live capture
 .TP
+.BR pcap_set_immediate_mode (3PCAP)
+set immediate mode for a not-yet-activated
+.B pcap_t
+for live capture
+.TP
 .BR pcap_set_buffer_size (3PCAP)
 set buffer size for a not-yet-activated
 .B pcap_t
@@ -632,9 +641,28 @@
 descriptors to be ready to read.  To obtain, for a handle, a descriptor
 that can be used in those routines, call
 .BR pcap_get_selectable_fd ().
+If the routine indicates that data is
+available to read on the descriptor, an attempt should be made to read
+from the device.
+.PP
 Not all handles have such a descriptor available;
 .BR pcap_get_selectable_fd ()
-will return \-1 if no such descriptor exists.  In addition, for various
+will return
+.B PCAP_ERROR
+if no such descriptor is available.  If no such
+descriptor is available, this may be because the device must be polled
+periodically for packets; in that case,
+.BR pcap_get_required_select_timeout ()
+will return a pointer to a
+.B struct timeval
+whose value can be used as a timeout in those routines.  When the
+routine returns, an attmept should be made to read packets from the
+device.  If
+.BR pcap_get_required_select_timeout ()
+returns NULL, no such timeout is available, and those routines cannot be
+used with the device.
+.PP
+In addition, for various
 reasons, one or more of those routines will not work properly with the
 descriptor; the documentation for
 .BR pcap_get_selectable_fd ()
@@ -693,6 +721,15 @@
 .BR select (2)
 and
 .BR poll (2)
+.TP
+.BR pcap_get_required_select_timeout (3PCAP)
+if no descriptor usable with
+.BR select (2)
+and
+.BR poll (2)
+is available for the
+.BR pcap_t ,
+attempt to get a timeout usable with those routines
 .RE
 .SS Filters
 In order to cause only certain packets to be returned when reading
@@ -890,7 +927,7 @@
 .BR pcap_lib_version (3PCAP)
 get library version string
 .RE
-.SH BACKWARDS COMPATIBILITY
+.SH BACKWARD COMPATIBILITY
 .PP
 In versions of libpcap prior to 1.0, the
 .B pcap.h
diff --git a/pcap.c b/pcap.c
index 942c472..5c8b51a 100644
--- a/pcap.c
+++ b/pcap.c
@@ -139,7 +139,7 @@
 
 /*
  * Start WinSock.
- * Exported in case some applications using WinPcap called it,
+ * Exported in case some applications using WinPcap/Npcap called it,
  * even though it wasn't exported.
  */
 int
@@ -186,76 +186,165 @@
 PCAP_API char pcap_version[];
 PCAP_API_DEF char pcap_version[] = PACKAGE_VERSION;
 
-static int
-pcap_not_initialized(pcap_t *pcap)
+static void
+pcap_set_not_initialized_message(pcap_t *pcap)
 {
 	if (pcap->activated) {
 		/* A module probably forgot to set the function pointer */
 		(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
 		    "This operation isn't properly handled by that device");
-		return (PCAP_ERROR);
+		return;
 	}
 	/* in case the caller doesn't check for PCAP_ERROR_NOT_ACTIVATED */
 	(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
 	    "This handle hasn't been activated yet");
+}
+
+static int
+pcap_read_not_initialized(pcap_t *pcap, int cnt _U_, pcap_handler callback _U_,
+    u_char *user _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_inject_not_initialized(pcap_t *pcap, const void * buf _U_, size_t size _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_setfilter_not_initialized(pcap_t *pcap, struct bpf_program *fp _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_setdirection_not_initialized(pcap_t *pcap, pcap_direction_t d _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_set_datalink_not_initialized(pcap_t *pcap, int dlt _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_getnonblock_not_initialized(pcap_t *pcap)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_stats_not_initialized(pcap_t *pcap, struct pcap_stat *ps _U_)
+{
+	pcap_set_not_initialized_message(pcap);
 	/* this means 'not initialized' */
 	return (PCAP_ERROR_NOT_ACTIVATED);
 }
 
 #ifdef _WIN32
-static void *
-pcap_not_initialized_ptr(pcap_t *pcap)
+struct pcap_stat *
+pcap_stats_ex_not_initialized(pcap_t *pcap, int *pcap_stat_size _U_)
 {
-	if (pcap->activated) {
-		/* A module probably forgot to set the function pointer */
-		(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-		    "This operation isn't properly handled by that device");
-		return (NULL);
-	}
-	(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-	    "This handle hasn't been activated yet");
+	pcap_set_not_initialized_message(pcap);
 	return (NULL);
 }
 
+static int
+pcap_setbuff_not_initialized(pcap_t *pcap, int dim _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_setmode_not_initialized(pcap_t *pcap, int mode _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_setmintocopy_not_initialized(pcap_t *pcap, int size _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	/* this means 'not initialized' */
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
 static HANDLE
 pcap_getevent_not_initialized(pcap_t *pcap)
 {
-	if (pcap->activated) {
-		/* A module probably forgot to set the function pointer */
-		(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-		    "This operation isn't properly handled by that device");
-		return (INVALID_HANDLE_VALUE);
-	}
-	(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-	    "This handle hasn't been activated yet");
+	pcap_set_not_initialized_message(pcap);
 	return (INVALID_HANDLE_VALUE);
 }
 
+static int
+pcap_oid_get_request_not_initialized(pcap_t *pcap, bpf_u_int32 oid _U_,
+    void *data _U_, size_t *lenp _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_oid_set_request_not_initialized(pcap_t *pcap, bpf_u_int32 oid _U_,
+    const void *data _U_, size_t *lenp _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
 static u_int
 pcap_sendqueue_transmit_not_initialized(pcap_t *pcap, pcap_send_queue* queue, int sync)
 {
-	if (pcap->activated) {
-		/* A module probably forgot to set the function pointer */
-		(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-		    "This operation isn't properly handled by that device");
-		return (0);
-	}
-	(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-	    "This handle hasn't been activated yet");
+	pcap_set_not_initialized_message(pcap);
 	return (0);
 }
 
+static int
+pcap_setuserbuffer_not_initialized(pcap_t *pcap, int size _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_live_dump_not_initialized(pcap_t *pcap, char *filename _U_, int maxsize _U_,
+    int maxpacks _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
+static int
+pcap_live_dump_ended_not_initialized(pcap_t *pcap, int sync _U_)
+{
+	pcap_set_not_initialized_message(pcap);
+	return (PCAP_ERROR_NOT_ACTIVATED);
+}
+
 static PAirpcapHandle
 pcap_get_airpcap_handle_not_initialized(pcap_t *pcap)
 {
-	if (pcap->activated) {
-		/* A module probably forgot to set the function pointer */
-		(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-		    "This operation isn't properly handled by that device");
-		return (NULL);
-	}
-	(void)pcap_snprintf(pcap->errbuf, sizeof(pcap->errbuf),
-	    "This handle hasn't been activated yet");
+	pcap_set_not_initialized_message(pcap);
 	return (NULL);
 }
 #endif
@@ -296,8 +385,17 @@
 	if (p->tstamp_type_count == 0) {
 		/*
 		 * We don't support multiple time stamp types.
+		 * That means the only type we support is PCAP_TSTAMP_HOST;
+		 * set up a list containing only that type.
 		 */
-		*tstamp_typesp = NULL;
+		*tstamp_typesp = (int*)malloc(sizeof(**tstamp_typesp));
+		if (*tstamp_typesp == NULL) {
+			pcap_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
+			    errno, "malloc");
+			return (PCAP_ERROR);
+		}
+		**tstamp_typesp = PCAP_TSTAMP_HOST;
+		return (1);
 	} else {
 		*tstamp_typesp = (int*)calloc(sizeof(**tstamp_typesp),
 		    p->tstamp_type_count);
@@ -308,8 +406,8 @@
 		}
 		(void)memcpy(*tstamp_typesp, p->tstamp_type_list,
 		    sizeof(**tstamp_typesp) * p->tstamp_type_count);
+		return (p->tstamp_type_count);
 	}
-	return (p->tstamp_type_count);
 }
 
 /*
@@ -659,7 +757,7 @@
 	 * Get the description for the interface.
 	 */
 	memset(&ifrdesc, 0, sizeof ifrdesc);
-	strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
+	pcap_strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
 	s = socket(AF_INET, SOCK_DGRAM, 0);
 	if (s >= 0) {
 #ifdef __FreeBSD__
@@ -710,7 +808,7 @@
 		}
 #endif /* __FreeBSD__ */
 		close(s);
-		if (description != NULL && strlen(description) == 0) {
+		if (description != NULL && description[0] == '\0') {
 			/*
 			 * Description is empty, so discard it.
 			 */
@@ -741,20 +839,13 @@
 				 * OK, it's a valid number that's not
 				 * bigger than INT_MAX.  Construct
 				 * a description from it.
+				 * (If that fails, we don't worry about
+				 * it, we just return NULL.)
 				 */
-				static const char descr_prefix[] = "USB bus number ";
-				size_t descr_size;
-
-				/*
-				 * Allow enough room for a 32-bit bus number.
-				 * sizeof (descr_prefix) includes the
-				 * terminating NUL.
-				 */
-				descr_size = sizeof (descr_prefix) + 10;
-				description = malloc(descr_size);
-				if (description != NULL) {
-					pcap_snprintf(description, descr_size,
-					    "%s%ld", descr_prefix, busnum);
+				if (pcap_asprintf(&description,
+				    "USB bus number %ld", busnum) == -1) {
+					/* Failed. */
+					description = NULL;
 				}
 			}
 		}
@@ -1292,14 +1383,14 @@
 		 * on the list, there aren't any non-loopback devices,
 		 * so why not just supply it as the default device?
 		 */
-		(void)strlcpy(errbuf, "no suitable device found",
+		(void)pcap_strlcpy(errbuf, "no suitable device found",
 		    PCAP_ERRBUF_SIZE);
 		ret = NULL;
 	} else {
 		/*
 		 * Return the name of the first device on the list.
 		 */
-		(void)strlcpy(device, alldevs->name, sizeof(device));
+		(void)pcap_strlcpy(device, alldevs->name, sizeof(device));
 		ret = device;
 	}
 
@@ -1366,7 +1457,7 @@
 	/* XXX Work around Linux kernel bug */
 	ifr.ifr_addr.sa_family = AF_INET;
 #endif
-	(void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+	(void)pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 	if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) {
 		if (errno == EADDRNOTAVAIL) {
 			(void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
@@ -1385,7 +1476,7 @@
 	/* XXX Work around Linux kernel bug */
 	ifr.ifr_addr.sa_family = AF_INET;
 #endif
-	(void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+	(void)pcap_strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
 	if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
 		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "SIOCGIFNETMASK: %s", device);
@@ -1575,13 +1666,14 @@
 	 * the pathname.
 	 */
 	if (pcap_strcasecmp(scheme, "file") == 0) {
-		*schemep = scheme;
 		*pathp = strdup(colonp + 3);
 		if (*pathp == NULL) {
 			pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
 			    errno, "malloc");
+			free(scheme);
 			return (-1);
 		}
+		*schemep = scheme;
 		return (0);
 	}
 
@@ -1684,7 +1776,12 @@
 			 * Treat verything up to the closing square
 			 * bracket as the IP-Literal; we don't worry
 			 * about whether it's a valid IPv6address or
-			 * IPvFuture.
+			 * IPvFuture (or an IPv4address, for that
+			 * matter, just in case we get handed a
+			 * URL with an IPv4 IP-Literal, of the sort
+			 * that pcap_createsrcstr() used to generate,
+			 * and that pcap_parsesrcstr(), in the original
+			 * WinPcap code, accepted).
 			 */
 			bracketp = strchr(parsep, ']');
 			if (bracketp == NULL) {
@@ -1805,9 +1902,9 @@
 	switch (type) {
 
 	case PCAP_SRC_FILE:
-		strlcpy(source, PCAP_SRC_FILE_STRING, PCAP_BUF_SIZE);
+		pcap_strlcpy(source, PCAP_SRC_FILE_STRING, PCAP_BUF_SIZE);
 		if (name != NULL && *name != '\0') {
-			strlcat(source, name, PCAP_BUF_SIZE);
+			pcap_strlcat(source, name, PCAP_BUF_SIZE);
 			return (0);
 		} else {
 			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
@@ -1816,7 +1913,7 @@
 		}
 
 	case PCAP_SRC_IFREMOTE:
-		strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
+		pcap_strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
 		if (host != NULL && *host != '\0') {
 			if (strchr(host, ':') != NULL) {
 				/*
@@ -1824,18 +1921,18 @@
 				 * probably an IPv6 address, and needs to
 				 * be included in square brackets.
 				 */
-				strlcat(source, "[", PCAP_BUF_SIZE);
-				strlcat(source, host, PCAP_BUF_SIZE);
-				strlcat(source, "]", PCAP_BUF_SIZE);
+				pcap_strlcat(source, "[", PCAP_BUF_SIZE);
+				pcap_strlcat(source, host, PCAP_BUF_SIZE);
+				pcap_strlcat(source, "]", PCAP_BUF_SIZE);
 			} else
-				strlcat(source, host, PCAP_BUF_SIZE);
+				pcap_strlcat(source, host, PCAP_BUF_SIZE);
 
 			if (port != NULL && *port != '\0') {
-				strlcat(source, ":", PCAP_BUF_SIZE);
-				strlcat(source, port, PCAP_BUF_SIZE);
+				pcap_strlcat(source, ":", PCAP_BUF_SIZE);
+				pcap_strlcat(source, port, PCAP_BUF_SIZE);
 			}
 
-			strlcat(source, "/", PCAP_BUF_SIZE);
+			pcap_strlcat(source, "/", PCAP_BUF_SIZE);
 		} else {
 			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
 			    "The host name cannot be NULL.");
@@ -1843,15 +1940,15 @@
 		}
 
 		if (name != NULL && *name != '\0')
-			strlcat(source, name, PCAP_BUF_SIZE);
+			pcap_strlcat(source, name, PCAP_BUF_SIZE);
 
 		return (0);
 
 	case PCAP_SRC_IFLOCAL:
-		strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
+		pcap_strlcpy(source, PCAP_SRC_IF_STRING, PCAP_BUF_SIZE);
 
 		if (name != NULL && *name != '\0')
-			strlcat(source, name, PCAP_BUF_SIZE);
+			pcap_strlcat(source, name, PCAP_BUF_SIZE);
 
 		return (0);
 
@@ -1890,7 +1987,7 @@
 		 * Local device.
 		 */
 		if (name && tmppath)
-			strlcpy(name, tmppath, PCAP_BUF_SIZE);
+			pcap_strlcpy(name, tmppath, PCAP_BUF_SIZE);
 		if (type)
 			*type = PCAP_SRC_IFLOCAL;
 		free(tmppath);
@@ -1912,12 +2009,12 @@
 				pcap_snprintf(host, PCAP_BUF_SIZE, "%s@%s",
 				    tmpuserinfo, tmphost);
 			else
-				strlcpy(host, tmphost, PCAP_BUF_SIZE);
+				pcap_strlcpy(host, tmphost, PCAP_BUF_SIZE);
 		}
 		if (port && tmpport)
-			strlcpy(port, tmpport, PCAP_BUF_SIZE);
+			pcap_strlcpy(port, tmpport, PCAP_BUF_SIZE);
 		if (name && tmppath)
-			strlcpy(name, tmppath, PCAP_BUF_SIZE);
+			pcap_strlcpy(name, tmppath, PCAP_BUF_SIZE);
 		if (type)
 			*type = PCAP_SRC_IFREMOTE;
 		free(tmppath);
@@ -1933,7 +2030,7 @@
 		 * file://
 		 */
 		if (name && tmppath)
-			strlcpy(name, tmppath, PCAP_BUF_SIZE);
+			pcap_strlcpy(name, tmppath, PCAP_BUF_SIZE);
 		if (type)
 			*type = PCAP_SRC_FILE;
 		free(tmppath);
@@ -1949,7 +2046,7 @@
 	 * as a local device.
 	 */
 	if (name)
-		strlcpy(name, source, PCAP_BUF_SIZE);
+		pcap_strlcpy(name, source, PCAP_BUF_SIZE);
 	if (type)
 		*type = PCAP_SRC_IFLOCAL;
 	free(tmppath);
@@ -1981,11 +2078,28 @@
 	else {
 #ifdef _WIN32
 		/*
-		 * If the string appears to be little-endian UCS-2/UTF-16,
-		 * convert it to ASCII.
+		 * On Windows, for backwards compatibility reasons,
+		 * pcap_lookupdev() returns a pointer to a sequence of
+		 * pairs of UTF-16LE device names and local code page
+		 * description strings.
 		 *
-		 * XXX - to UTF-8 instead?  Or report an error if any
-		 * character isn't ASCII?
+		 * This means that if a program uses pcap_lookupdev()
+		 * to get a default device, and hands that to an API
+		 * that opens devices, we'll get handed a UTF-16LE
+		 * string, not a string in the local code page.
+		 *
+		 * To work around that, we check whether the string
+		 * looks as if it might be a UTF-16LE strinh and, if
+		 * so, convert it back to the local code page's
+		 * extended ASCII.
+		 *
+		 * XXX - you *cannot* reliably detect whether a
+		 * string is UTF-16LE or not; "a" could either
+		 * be a one-character ASCII string or the first
+		 * character of a UTF-16LE string.  This particular
+		 * version of this heuristic dates back to WinPcap
+		 * 4.1.1; PacketOpenAdapter() does uses the same
+		 * heuristic, with the exact same vulnerability.
 		 */
 		if (device[0] != '\0' && device[1] == '\0') {
 			size_t length;
@@ -2077,25 +2191,25 @@
 	 * an activated pcap_t to point to a routine that returns
 	 * a "this isn't activated" error.
 	 */
-	p->read_op = (read_op_t)pcap_not_initialized;
-	p->inject_op = (inject_op_t)pcap_not_initialized;
-	p->setfilter_op = (setfilter_op_t)pcap_not_initialized;
-	p->setdirection_op = (setdirection_op_t)pcap_not_initialized;
-	p->set_datalink_op = (set_datalink_op_t)pcap_not_initialized;
-	p->getnonblock_op = (getnonblock_op_t)pcap_not_initialized;
-	p->stats_op = (stats_op_t)pcap_not_initialized;
+	p->read_op = pcap_read_not_initialized;
+	p->inject_op = pcap_inject_not_initialized;
+	p->setfilter_op = pcap_setfilter_not_initialized;
+	p->setdirection_op = pcap_setdirection_not_initialized;
+	p->set_datalink_op = pcap_set_datalink_not_initialized;
+	p->getnonblock_op = pcap_getnonblock_not_initialized;
+	p->stats_op = pcap_stats_not_initialized;
 #ifdef _WIN32
-	p->stats_ex_op = (stats_ex_op_t)pcap_not_initialized_ptr;
-	p->setbuff_op = (setbuff_op_t)pcap_not_initialized;
-	p->setmode_op = (setmode_op_t)pcap_not_initialized;
-	p->setmintocopy_op = (setmintocopy_op_t)pcap_not_initialized;
+	p->stats_ex_op = pcap_stats_ex_not_initialized;
+	p->setbuff_op = pcap_setbuff_not_initialized;
+	p->setmode_op = pcap_setmode_not_initialized;
+	p->setmintocopy_op = pcap_setmintocopy_not_initialized;
 	p->getevent_op = pcap_getevent_not_initialized;
-	p->oid_get_request_op = (oid_get_request_op_t)pcap_not_initialized;
-	p->oid_set_request_op = (oid_set_request_op_t)pcap_not_initialized;
+	p->oid_get_request_op = pcap_oid_get_request_not_initialized;
+	p->oid_set_request_op = pcap_oid_set_request_not_initialized;
 	p->sendqueue_transmit_op = pcap_sendqueue_transmit_not_initialized;
-	p->setuserbuffer_op = (setuserbuffer_op_t)pcap_not_initialized;
-	p->live_dump_op = (live_dump_op_t)pcap_not_initialized;
-	p->live_dump_ended_op = (live_dump_ended_op_t)pcap_not_initialized;
+	p->setuserbuffer_op = pcap_setuserbuffer_not_initialized;
+	p->live_dump_op = pcap_live_dump_not_initialized;
+	p->live_dump_ended_op = pcap_live_dump_ended_not_initialized;
 	p->get_airpcap_handle_op = pcap_get_airpcap_handle_not_initialized;
 #endif
 
@@ -2133,7 +2247,7 @@
 	 * require 8-byte alignment even on platforms with 32-bit
 	 * integers.
 	 */
-#define PCAP_T_ALIGNED_SIZE	((sizeof(pcap_t) + 7) & ~0x7)
+#define PCAP_T_ALIGNED_SIZE	((sizeof(pcap_t) + 7U) & ~0x7U)
 	chunk = malloc(PCAP_T_ALIGNED_SIZE + size);
 	if (chunk == NULL) {
 		pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
@@ -2461,6 +2575,16 @@
 	int srctype;
 
 	/*
+	 * A null device name is equivalent to the "any" device -
+	 * which might not be supported on this platform, but
+	 * this means that you'll get a "not supported" error
+	 * rather than, say, a crash when we try to dereference
+	 * the null pointer.
+	 */
+	if (device == NULL)
+		device = "any";
+
+	/*
 	 * Retrofit - we have to make older applications compatible with
 	 * remote capture.
 	 * So we're calling pcap_open_remote() from here; this is a very
@@ -2531,13 +2655,13 @@
 	return (p);
 fail:
 	if (status == PCAP_ERROR)
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
-		    p->errbuf);
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %.*s", device,
+		    PCAP_ERRBUF_SIZE - 3, p->errbuf);
 	else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
 	    status == PCAP_ERROR_PERM_DENIED ||
 	    status == PCAP_ERROR_PROMISC_PERM_DENIED)
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", device,
-		    pcap_statustostr(status), p->errbuf);
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%.*s)", device,
+		    pcap_statustostr(status), PCAP_ERRBUF_SIZE - 6, p->errbuf);
 	else
 		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
 		    pcap_statustostr(status));
@@ -2850,7 +2974,7 @@
 	DLT_CHOICE(FRELAY, "Frame Relay"),
 	DLT_CHOICE(LOOP, "OpenBSD loopback"),
 	DLT_CHOICE(ENC, "OpenBSD encapsulated IP"),
-	DLT_CHOICE(LINUX_SLL, "Linux cooked"),
+	DLT_CHOICE(LINUX_SLL, "Linux cooked v1"),
 	DLT_CHOICE(LTALK, "Localtalk"),
 	DLT_CHOICE(PFLOG, "OpenBSD pflog file"),
 	DLT_CHOICE(PFSYNC, "Packet filter state syncing"),
@@ -2884,7 +3008,7 @@
 	DLT_CHOICE(GPF_T, "GPF-T"),
 	DLT_CHOICE(GPF_F, "GPF-F"),
 	DLT_CHOICE(JUNIPER_PIC_PEER, "Juniper PIC Peer"),
-	DLT_CHOICE(ERF_ETH,	"Ethernet with Endace ERF header"),
+	DLT_CHOICE(ERF_ETH, "Ethernet with Endace ERF header"),
 	DLT_CHOICE(ERF_POS, "Packet-over-SONET with Endace ERF header"),
 	DLT_CHOICE(LINUX_LAPD, "Linux vISDN LAPD"),
 	DLT_CHOICE(JUNIPER_ETHER, "Juniper Ethernet"),
@@ -2908,10 +3032,11 @@
 	DLT_CHOICE(SITA, "SITA pseudo-header"),
 	DLT_CHOICE(ERF, "Endace ERF header"),
 	DLT_CHOICE(RAIF1, "Ethernet with u10 Networks pseudo-header"),
-	DLT_CHOICE(IPMB, "IPMB"),
+	DLT_CHOICE(IPMB_KONTRON, "IPMB with Kontron pseudo-header"),
 	DLT_CHOICE(JUNIPER_ST, "Juniper Secure Tunnel"),
 	DLT_CHOICE(BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"),
 	DLT_CHOICE(AX25_KISS, "AX.25 with KISS header"),
+	DLT_CHOICE(IPMB_LINUX, "IPMB with Linux/Pigeon Point pseudo-header"),
 	DLT_CHOICE(IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
 	DLT_CHOICE(MPLS, "MPLS with label as link-layer header"),
 	DLT_CHOICE(LINUX_EVDEV, "Linux evdev events"),
@@ -2968,6 +3093,7 @@
 	DLT_CHOICE(DOCSIS31_XRA31, "Excentis XRA-31 DOCSIS 3.1 RF sniffer frames"),
 	DLT_CHOICE(ETHERNET_MPACKET, "802.3br mPackets"),
 	DLT_CHOICE(DISPLAYPORT_AUX, "DisplayPort AUX channel monitoring data"),
+	DLT_CHOICE(LINUX_SLL2, "Linux cooked v2"),
 	DLT_CHOICE_SENTINEL
 };
 
@@ -3007,6 +3133,21 @@
 	return (NULL);
 }
 
+const char *
+pcap_datalink_val_to_description_or_dlt(int dlt)
+{
+        static char unkbuf[40];
+        const char *description;
+
+        description = pcap_datalink_val_to_description(dlt);
+        if (description != NULL) {
+                return description;
+        } else {
+                (void)pcap_snprintf(unkbuf, sizeof(unkbuf), "DLT %u", dlt);
+                return unkbuf;
+        }
+}
+
 struct tstamp_type_choice {
 	const char *name;
 	const char *description;
@@ -3159,7 +3300,7 @@
 		 * We copy the error message to errbuf, so callers
 		 * can find it in either place.
 		 */
-		strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
+		pcap_strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
 	}
 	return (ret);
 }
@@ -3203,7 +3344,7 @@
 		 * We copy the error message to errbuf, so callers
 		 * can find it in either place.
 		 */
-		strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
+		pcap_strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
 	}
 	return (ret);
 }
@@ -3239,35 +3380,6 @@
 }
 #endif
 
-#ifdef _WIN32
-/*
- * Generate a string for a Win32-specific error (i.e. an error generated when
- * calling a Win32 API).
- * For errors occurred during standard C calls, we still use pcap_strerror()
- */
-void
-pcap_win32_err_to_str(DWORD error, char *errbuf)
-{
-	size_t errlen;
-	char *p;
-
-	FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, errbuf,
-	    PCAP_ERRBUF_SIZE, NULL);
-
-	/*
-	 * "FormatMessage()" "helpfully" sticks CR/LF at the end of the
-	 * message.  Get rid of it.
-	 */
-	errlen = strlen(errbuf);
-	if (errlen >= 2) {
-		errbuf[errlen - 1] = '\0';
-		errbuf[errlen - 2] = '\0';
-	}
-	p = strchr(errbuf, '\0');
-	pcap_snprintf (p, PCAP_ERRBUF_SIZE+1-(p-errbuf), " (%lu)", error);
-}
-#endif
-
 /*
  * Generate error strings for PCAP_ERROR_ and PCAP_WARNING_ values.
  */
@@ -3339,7 +3451,7 @@
 	errno_t err = strerror_s(errbuf, PCAP_ERRBUF_SIZE, errnum);
 
 	if (err != 0) /* err = 0 if successful */
-		strlcpy(errbuf, "strerror_s() error", PCAP_ERRBUF_SIZE);
+		pcap_strlcpy(errbuf, "strerror_s() error", PCAP_ERRBUF_SIZE);
 	return (errbuf);
 #else
 	return (strerror(errnum));
@@ -3561,7 +3673,7 @@
 			/*
 			 * "atexit()" failed; let our caller know.
 			 */
-			strlcpy(p->errbuf, "atexit failed", PCAP_ERRBUF_SIZE);
+			pcap_strlcpy(p->errbuf, "atexit failed", PCAP_ERRBUF_SIZE);
 			return (0);
 		}
 		did_atexit = 1;
diff --git a/pcap/bpf.h b/pcap/bpf.h
index 1a953a9..9d74895 100644
--- a/pcap/bpf.h
+++ b/pcap/bpf.h
@@ -239,16 +239,6 @@
 };
 
 /*
- * Auxiliary data, for use when interpreting a filter intended for the
- * Linux kernel when the kernel rejects the filter (requiring us to
- * run it in userland).  It contains VLAN tag information.
- */
-struct bpf_aux_data {
-	u_short vlan_tag_present;
-	u_short vlan_tag;
-};
-
-/*
  * Macros for insn array initializers.
  */
 #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
@@ -256,7 +246,6 @@
 
 PCAP_API int bpf_validate(const struct bpf_insn *, int);
 PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
-extern u_int bpf_filter_with_aux_data(const struct bpf_insn *, const u_char *, u_int, u_int, const struct bpf_aux_data *);
 
 /*
  * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
diff --git a/pcap/compiler-tests.h b/pcap/compiler-tests.h
index 5e17853..ea5962c 100644
--- a/pcap/compiler-tests.h
+++ b/pcap/compiler-tests.h
@@ -160,4 +160,4 @@
 	(__HP_aCC >= ((major)*10000 + (minor)*100))
 #endif
 
-#endif /* lib_pcap_funcattrs_h */
+#endif /* lib_pcap_compiler_tests_h */
diff --git a/pcap/dlt.h b/pcap/dlt.h
index 535fd50..8dacf02 100644
--- a/pcap/dlt.h
+++ b/pcap/dlt.h
@@ -246,7 +246,7 @@
  */
 
 /*
- * This is for Linux cooked sockets.
+ * Linux cooked sockets.
  */
 #define DLT_LINUX_SLL	113
 
@@ -769,11 +769,20 @@
 #define DLT_RAIF1		198
 
 /*
- * IPMB packet for IPMI, beginning with the I2C slave address, followed
- * by the netFn and LUN, etc..  Requested by Chanthy Toeung
- * <chanthy.toeung@ca.kontron.com>.
+ * IPMB packet for IPMI, beginning with a 2-byte header, followed by
+ * the I2C slave address, followed by the netFn and LUN, etc..
+ * Requested by Chanthy Toeung <chanthy.toeung@ca.kontron.com>.
+ *
+ * XXX - this used to be called DLT_IPMB, back when we got the
+ * impression from the email thread requesting it that the packet
+ * had no extra 2-byte header.  We've renamed it; if anybody used
+ * DLT_IPMB and assumed no 2-byte header, this will cause the compile
+ * to fail, at which point we'll have to figure out what to do about
+ * the two header types using the same DLT_/LINKTYPE_ value.  If that
+ * doesn't happen, we'll assume nobody used it and that the redefinition
+ * is safe.
  */
-#define DLT_IPMB		199
+#define DLT_IPMB_KONTRON	199
 
 /*
  * Juniper-private data link type, as per request from
@@ -805,15 +814,34 @@
 #define DLT_LAPD		203
 
 /*
- * Variants of various link-layer headers, with a one-byte direction
- * pseudo-header prepended - zero means "received by this host",
- * non-zero (any non-zero value) means "sent by this host" - as per
- * Will Barker <w.barker@zen.co.uk>.
+ * PPP, with a one-byte direction pseudo-header prepended - zero means
+ * "received by this host", non-zero (any non-zero value) means "sent by
+ * this host" - as per Will Barker <w.barker@zen.co.uk>.
  */
-#define DLT_PPP_WITH_DIR	204	/* PPP - don't confuse with DLT_PPP_WITH_DIRECTION */
-#define DLT_C_HDLC_WITH_DIR	205	/* Cisco HDLC */
-#define DLT_FRELAY_WITH_DIR	206	/* Frame Relay */
-#define DLT_LAPB_WITH_DIR	207	/* LAPB */
+#define DLT_PPP_WITH_DIR	204	/* Don't confuse with DLT_PPP_WITH_DIRECTION */
+
+/*
+ * Cisco HDLC, with a one-byte direction pseudo-header prepended - zero
+ * means "received by this host", non-zero (any non-zero value) means
+ * "sent by this host" - as per Will Barker <w.barker@zen.co.uk>.
+ */
+#define DLT_C_HDLC_WITH_DIR	205
+
+/*
+ * Frame Relay, with a one-byte direction pseudo-header prepended - zero
+ * means "received by this host" (DCE -> DTE), non-zero (any non-zero
+ * value) means "sent by this host" (DTE -> DCE) - as per Will Barker
+ * <w.barker@zen.co.uk>.
+ */
+#define DLT_FRELAY_WITH_DIR	206
+
+/*
+ * LAPB, with a one-byte direction pseudo-header prepended - zero means
+ * "received by this host" (DCE -> DTE), non-zero (any non-zero value)
+ * means "sent by this host" (DTE -> DCE)- as per Will Barker
+ * <w.barker@zen.co.uk>.
+ */
+#define DLT_LAPB_WITH_DIR	207
 
 /*
  * 208 is reserved for an as-yet-unspecified proprietary link-layer
@@ -1368,6 +1396,11 @@
 #define DLT_DISPLAYPORT_AUX	275
 
 /*
+ * Linux cooked sockets v2.
+ */
+#define DLT_LINUX_SLL2	276
+
+/*
  * In case the code that includes this file (directly or indirectly)
  * has also included OS files that happen to define DLT_MATCHING_MAX,
  * with a different value (perhaps because that OS hasn't picked up
@@ -1377,7 +1410,7 @@
 #ifdef DLT_MATCHING_MAX
 #undef DLT_MATCHING_MAX
 #endif
-#define DLT_MATCHING_MAX	275	/* highest value in the "matching" range */
+#define DLT_MATCHING_MAX	276	/* highest value in the "matching" range */
 
 /*
  * DLT and savefile link type values are split into a class and
diff --git a/pcap/funcattrs.h b/pcap/funcattrs.h
index a8b1932..e64da93 100644
--- a/pcap/funcattrs.h
+++ b/pcap/funcattrs.h
@@ -164,10 +164,11 @@
     || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
     || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
   /*
-   * Compiler with support for __attribute((noreturn)), or GCC 2.5 and
-   * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
-   * and later (do any earlier versions of XL C support this?), or
-   * HP aCC A.06.10 and later.
+   * Compiler with support for __attribute((noreturn)), or GCC 2.5 or
+   * later, or some compiler asserting compatibility with GCC 2.5 or
+   * later, or Solaris Studio 12 (Sun C 5.9) or later, or IBM XL C 10.1
+   * or later (do any earlier versions of XL C support this?), or HP aCC
+   * A.06.10 or later.
    */
   #define PCAP_NORETURN __attribute((noreturn))
   #define PCAP_NORETURN_DEF __attribute((noreturn))
@@ -193,7 +194,8 @@
     || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
     || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
   /*
-   * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
+   * Compiler with support for it, or GCC 2.3 or later, or some compiler
+   * asserting compatibility with GCC 2.3 or later, or IBM XL C 10.1
    * and later (do any earlier versions of XL C support this?),
    * or HP aCC A.06.10 and later.
    */
@@ -216,7 +218,7 @@
     || PCAP_IS_AT_LEAST_SUNC_VERSION(5,13)
   /*
    * Compiler that supports __has_attribute and __attribute__((deprecated)),
-   * or GCC 4.5 and later, or Sun/Oracle C 12.4 (Sun C 5.13) or later.
+   * or GCC 4.5 or later, or Sun/Oracle C 12.4 (Sun C 5.13) or later.
    *
    * Those support __attribute__((deprecated(msg))) (we assume, perhaps
    * incorrectly, that anything that supports __has_attribute() is
diff --git a/pcap/pcap-inttypes.h b/pcap/pcap-inttypes.h
index af2c23c..8b1eb8b 100644
--- a/pcap/pcap-inttypes.h
+++ b/pcap/pcap-inttypes.h
@@ -106,12 +106,23 @@
       #define PRIu64	"llu"
     #endif
   #endif
+
+  /*
+   * MSVC's support library doesn't support %zu to print a size_t until
+   * Visual Studio 2017, but supports %Iu earlier, so use that.
+   */
+  #define PRIsize	"Iu"
 #elif defined(__MINGW32__) || !defined(_WIN32)
   /*
    * Compiler is MinGW or target is UN*X or MS-DOS.  Just use
    * <inttypes.h>.
    */
   #include <inttypes.h>
+
+  /*
+   * Assume the support library supports %zu; it's required by C99.
+   */
+  #define PRIsize	"zu"
 #endif
 
 #endif /* pcap/pcap-inttypes.h */
diff --git a/pcap/pcap.h b/pcap/pcap.h
index bc87b3f..90614dd 100644
--- a/pcap/pcap.h
+++ b/pcap/pcap.h
@@ -84,6 +84,8 @@
   #include <sys/time.h>
 #endif /* _WIN32/MSDOS/UN*X */
 
+#include <pcap/socket.h>	/* for SOCKET, as the active-mode rpcap APIs use it */
+
 #ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H
 #include <pcap/bpf.h>
 #endif
@@ -468,6 +470,7 @@
 PCAP_API int	pcap_datalink_name_to_val(const char *);
 PCAP_API const char *pcap_datalink_val_to_name(int);
 PCAP_API const char *pcap_datalink_val_to_description(int);
+PCAP_API const char *pcap_datalink_val_to_description_or_dlt(int);
 PCAP_API int	pcap_snapshot(pcap_t *);
 PCAP_API int	pcap_is_swapped(pcap_t *);
 PCAP_API int	pcap_major_version(pcap_t *);
@@ -483,7 +486,28 @@
 #endif
 
 PCAP_API pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
-PCAP_API pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
+#ifdef _WIN32
+  PCAP_API pcap_dumper_t *pcap_dump_hopen(pcap_t *, intptr_t);
+  /*
+   * If we're building libpcap, this is an internal routine in sf-pcap.c, so
+   * we must not define it as a macro.
+   *
+   * If we're not building libpcap, given that the version of the C runtime
+   * with which libpcap was built might be different from the version
+   * of the C runtime with which an application using libpcap was built,
+   * and that a FILE structure may differ between the two versions of the
+   * C runtime, calls to _fileno() must use the version of _fileno() in
+   * the C runtime used to open the FILE *, not the version in the C
+   * runtime with which libpcap was built.  (Maybe once the Universal CRT
+   * rules the world, this will cease to be a problem.)
+   */
+  #ifndef BUILDING_PCAP
+    #define pcap_dump_fopen(p,f) \
+	pcap_dump_hopen(p, _get_osfhandle(_fileno(f)))
+  #endif
+#else /*_WIN32*/
+  PCAP_API pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
+#endif /*_WIN32*/
 PCAP_API pcap_dumper_t *pcap_dump_open_append(pcap_t *, const char *);
 PCAP_API FILE	*pcap_dump_file(pcap_dumper_t *);
 PCAP_API long	pcap_dump_ftell(pcap_dumper_t *);
@@ -858,8 +882,8 @@
  * For listing remote capture devices, pcap_findalldevs_ex() is currently
  * the only API available.
  */
-PCAP_API int	pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth,
-	    pcap_if_t **alldevs, char *errbuf);
+PCAP_API int	pcap_findalldevs_ex(const char *source,
+	    struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf);
 
 /*
  * Sampling methods.
@@ -937,27 +961,6 @@
 /* Maximum length of an host name (needed for the RPCAP active mode) */
 #define RPCAP_HOSTLIST_SIZE 1024
 
-/*
- * Some minor differences between UN*X sockets and and Winsock sockets.
- */
-#ifndef _WIN32
-  /*!
-   * \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's
-   * a file descriptor, and therefore a signed integer.
-   * We define SOCKET to be a signed integer on UN*X, so that it can
-   * be used on both platforms.
-   */
-  #define SOCKET int
-
-  /*!
-   * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET;
-   * in UN*X, it's -1.
-   * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on
-   * both platforms.
-   */
-  #define INVALID_SOCKET -1
-#endif
-
 PCAP_API SOCKET	pcap_remoteact_accept(const char *address, const char *port,
 	    const char *hostlist, char *connectinghost,
 	    struct pcap_rmtauth *auth, char *errbuf);
diff --git a/pcap/sll.h b/pcap/sll.h
index c4d0886..392faae 100644
--- a/pcap/sll.h
+++ b/pcap/sll.h
@@ -74,27 +74,44 @@
 #ifndef lib_pcap_sll_h
 #define lib_pcap_sll_h
 
+#include <pcap/pcap-inttypes.h>
+
 /*
  * A DLT_LINUX_SLL fake link-layer header.
  */
 #define SLL_HDR_LEN	16		/* total header length */
 #define SLL_ADDRLEN	8		/* length of address field */
 
-#include <pcap/pcap-inttypes.h>
-
 struct sll_header {
 	uint16_t sll_pkttype;		/* packet type */
 	uint16_t sll_hatype;		/* link-layer address type */
 	uint16_t sll_halen;		/* link-layer address length */
-	uint8_t sll_addr[SLL_ADDRLEN];	/* link-layer address */
+	uint8_t  sll_addr[SLL_ADDRLEN];	/* link-layer address */
 	uint16_t sll_protocol;		/* protocol */
 };
 
 /*
- * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
- * PACKET_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux, and so that they
- * don't change even if the PACKET_ values change.
+ * A DLT_LINUX_SLL2 fake link-layer header.
+ */
+#define SLL2_HDR_LEN	20		/* total header length */
+
+struct sll2_header {
+	uint16_t sll2_protocol;			/* protocol */
+	uint16_t sll2_reserved_mbz;		/* reserved - must be zero */
+	uint32_t sll2_if_index;			/* 1-based interface index */
+	uint16_t sll2_hatype;			/* link-layer address type */
+	uint8_t  sll2_pkttype;			/* packet type */
+	uint8_t  sll2_halen;			/* link-layer address length */
+	uint8_t  sll2_addr[SLL_ADDRLEN];	/* link-layer address */
+};
+
+/*
+ * The LINUX_SLL_ values for "sll_pkttype" and LINUX_SLL2_ values for
+ * "sll2_pkttype"; these correspond to the PACKET_ values on Linux,
+ * which are defined by a header under include/uapi in the current
+ * kernel source, and are thus not going to change on Linux.  We
+ * define them here so that they're available even on systems other
+ * than Linux.
  */
 #define LINUX_SLL_HOST		0
 #define LINUX_SLL_BROADCAST	1
@@ -103,10 +120,11 @@
 #define LINUX_SLL_OUTGOING	4
 
 /*
- * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
- * ETH_P_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux.  We assume, for now,
- * that the ETH_P_ values won't change in Linux; if they do, then:
+ * The LINUX_SLL_ values for "sll_protocol" and LINUX_SLL2_ values for
+ * "sll2_protocol"; these correspond to the ETH_P_ values on Linux, but
+ * are defined here so that they're available even on systems other than
+ * Linux.  We assume, for now, that the ETH_P_ values won't change in
+ * Linux; if they do, then:
  *
  *	if we don't translate them in "pcap-linux.c", capture files
  *	won't necessarily be readable if captured on a system that
diff --git a/pcap/socket.h b/pcap/socket.h
new file mode 100644
index 0000000..6f27cba
--- /dev/null
+++ b/pcap/socket.h
@@ -0,0 +1,93 @@
+/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
+/*
+ * Copyright (c) 1993, 1994, 1995, 1996, 1997
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the Computer Systems
+ *	Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lib_pcap_socket_h
+#define lib_pcap_socket_h
+
+/*
+ * Some minor differences between sockets on various platforms.
+ * We include whatever sockets are needed for Internet-protocol
+ * socket access on UN*X and Windows.
+ */
+#ifdef _WIN32
+  /* Need windef.h for defines used in winsock2.h under MingW32 */
+  #ifdef __MINGW32__
+    #include <windef.h>
+  #endif
+  #include <winsock2.h>
+  #include <ws2tcpip.h>
+
+  /*
+   * Winsock doesn't have this UN*X type; it's used in the UN*X
+   * sockets API.
+   *
+   * XXX - do we need to worry about UN*Xes so old that *they*
+   * don't have it, either?
+   */
+  typedef int socklen_t;
+
+  /*
+   * Winsock doesn't have this POSIX type; it's used for the
+   * tv_usec value of struct timeval.
+   */
+  typedef long suseconds_t;
+#else /* _WIN32 */
+  #include <sys/types.h>
+  #include <sys/socket.h>
+  #include <netdb.h>		/* for struct addrinfo/getaddrinfo() */
+  #include <netinet/in.h>	/* for sockaddr_in, in BSD at least */
+  #include <arpa/inet.h>
+
+  /*!
+   * \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's
+   * a file descriptor, and therefore a signed integer.
+   * We define SOCKET to be a signed integer on UN*X, so that it can
+   * be used on both platforms.
+   */
+  #ifndef SOCKET
+    #define SOCKET int
+  #endif
+
+  /*!
+   * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET;
+   * in UN*X, it's -1.
+   * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on
+   * both platforms.
+   */
+  #ifndef INVALID_SOCKET
+    #define INVALID_SOCKET -1
+  #endif
+#endif /* _WIN32 */
+
+#endif /* lib_pcap_socket_h */
diff --git a/pcap_activate.3pcap b/pcap_activate.3pcap
index ceb2aa7..162a929 100644
--- a/pcap_activate.3pcap
+++ b/pcap_activate.3pcap
@@ -50,15 +50,15 @@
 .TP
 .B PCAP_WARNING_TSTAMP_TYPE_NOTSUP
 The time stamp type specified in a previous
-.B pcap_set_tstamp_type()
+.B pcap_set_tstamp_type(3PCAP)
 call isn't supported by the capture source (the time stamp type is
 left as the default),
 .TP
 .B PCAP_WARNING
 Another warning condition occurred;
-.B pcap_geterr()
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display a message describing the warning
@@ -115,7 +115,7 @@
 should check for positive, negative, and zero return codes, and treat
 all positive return codes as warnings and all negative return
 codes as errors.
-.B pcap_statustostr()
+.B pcap_statustostr(3PCAP)
 can be called, with a warning or error code as an argument, to fetch a
 message describing the warning or error code.
 .SH SEE ALSO
diff --git a/pcap_breakloop.3pcap b/pcap_breakloop.3pcap
index 03b8d8d..cc000d2 100644
--- a/pcap_breakloop.3pcap
+++ b/pcap_breakloop.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_BREAKLOOP 3PCAP "8 November 2017"
+.TH PCAP_BREAKLOOP 3PCAP "25 July 2018"
 .SH NAME
 pcap_breakloop \- force a pcap_dispatch() or pcap_loop() call to return
 .SH SYNOPSIS
@@ -33,12 +33,13 @@
 .SH DESCRIPTION
 .B pcap_breakloop()
 sets a flag that will force
-.B pcap_dispatch()
+.B pcap_dispatch(3PCAP)
 or
-.B pcap_loop()
+.B pcap_loop(3PCAP)
 to return rather than looping; they will return the number of packets
-that have been processed so far, or \-2 if no packets have been
-processed so far.
+that have been processed so far, or
+.B PCAP_ERROR_BREAK
+if no packets have been processed so far.
 .PP
 This routine is safe to use inside a signal handler on UNIX or a console
 control handler on Windows, as it merely sets a flag that is checked
@@ -60,7 +61,7 @@
 .PP
 .ft B
 Note also that, in a multi-threaded application, if one thread is
-blocked in pcap_dispatch(), pcap_loop(), pcap_next(), or pcap_next_ex(),
+blocked in pcap_dispatch(), pcap_loop(), pcap_next(3PCAP), or pcap_next_ex(3PCAP),
 a call to pcap_breakloop() in a different thread will not unblock that
 thread.
 .ft R
@@ -99,12 +100,16 @@
 .B pcap_loop()
 after it is called; at most one more packet might be processed.
 .PP
-If \-2 is returned from
+If
+.B PCAP_ERROR_BREAK
+is returned from
 .B pcap_dispatch()
 or
 .BR pcap_loop() ,
 the flag is cleared, so a subsequent call will resume reading packets.
 If a positive number is returned, the flag is not cleared, so a
-subsequent call will return \-2 and clear the flag.
+subsequent call will return
+.B PCAP_ERROR_BREAK
+and clear the flag.
 .SH SEE ALSO
-pcap(3PCAP), pcap_loop(3PCAP), pcap_next_ex(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_can_set_rfmon.3pcap b/pcap_can_set_rfmon.3pcap
index eee004d..0baac7a 100644
--- a/pcap_can_set_rfmon.3pcap
+++ b/pcap_can_set_rfmon.3pcap
@@ -54,9 +54,9 @@
 .TP
 .B PCAP_ERROR
 Another error occurred.
-.B pcap_geterr()
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B \%pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display a message describing the error.
@@ -64,7 +64,7 @@
 Additional error codes may be added in the future; a program should
 check for 0, 1, and negative, return codes, and treat all negative
 return codes as errors.
-.B pcap_statustostr()
+.B pcap_statustostr(3PCAP)
 can be called, with a warning or error code as an argument, to fetch a
 message describing the warning or error code.
 .SH SEE ALSO
diff --git a/pcap_compile.3pcap b/pcap_compile.3pcap
index 181814b..1f1e44e 100644
--- a/pcap_compile.3pcap
+++ b/pcap_compile.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_COMPILE 3PCAP "24 March 2017"
+.TH PCAP_COMPILE 3PCAP "22 August 2018"
 .SH NAME
 pcap_compile \- compile a filter expression
 .SH SYNOPSIS
@@ -52,7 +52,9 @@
 the filter program.  If the netmask of the network on which packets are
 being captured isn't known to the program, or if packets are being
 captured on the Linux "any" pseudo-interface that can capture on more
-than one network, a value of PCAP_NETMASK_UNKNOWN can be supplied; tests
+than one network, a value of
+.B PCAP_NETMASK_UNKNOWN
+can be supplied; tests
 for IPv4 broadcast addresses will fail to compile, but all other tests in
 the filter program will be OK.
 .LP
@@ -67,14 +69,21 @@
 exclusion allowing only one thread to call it at any given time.
 .SH RETURN VALUE
 .B pcap_compile()
-returns 0 on success and \-1 on failure.
-If \-1 is returned,
-.B pcap_geterr()
+returns 0 on success and
+.B PCAP_ERROR
+on failure. If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
+.SH BACKWARD COMPATIBILITY
+.PP
+The
+.B PCAP_NETMASK_UNKNOWN
+constant became available in libpcap release 1.1.0.
 .SH SEE ALSO
 pcap(3PCAP), pcap_setfilter(3PCAP), pcap_freecode(3PCAP),
-pcap_geterr(3PCAP), pcap-filter(7)
diff --git a/pcap_compile.3pcap.in b/pcap_compile.3pcap.in
index 29ae8f8..824f52b 100644
--- a/pcap_compile.3pcap.in
+++ b/pcap_compile.3pcap.in
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_COMPILE 3PCAP "24 March 2017"
+.TH PCAP_COMPILE 3PCAP "22 August 2018"
 .SH NAME
 pcap_compile \- compile a filter expression
 .SH SYNOPSIS
@@ -52,7 +52,9 @@
 the filter program.  If the netmask of the network on which packets are
 being captured isn't known to the program, or if packets are being
 captured on the Linux "any" pseudo-interface that can capture on more
-than one network, a value of PCAP_NETMASK_UNKNOWN can be supplied; tests
+than one network, a value of
+.B PCAP_NETMASK_UNKNOWN
+can be supplied; tests
 for IPv4 broadcast addresses will fail to compile, but all other tests in
 the filter program will be OK.
 .LP
@@ -67,14 +69,21 @@
 exclusion allowing only one thread to call it at any given time.
 .SH RETURN VALUE
 .B pcap_compile()
-returns 0 on success and \-1 on failure.
-If \-1 is returned,
-.B pcap_geterr()
+returns 0 on success and
+.B PCAP_ERROR
+on failure. If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
+.SH BACKWARD COMPATIBILITY
+.PP
+The
+.B PCAP_NETMASK_UNKNOWN
+constant became available in libpcap release 1.1.0.
 .SH SEE ALSO
 pcap(3PCAP), pcap_setfilter(3PCAP), pcap_freecode(3PCAP),
-pcap_geterr(3PCAP), pcap-filter(@MAN_MISC_INFO@)
diff --git a/pcap_create.3pcap b/pcap_create.3pcap
index 3040b3b..5a15007 100644
--- a/pcap_create.3pcap
+++ b/pcap_create.3pcap
@@ -48,7 +48,7 @@
 can be used to capture packets from all interfaces.
 .PP
 The returned handle must be activated with
-.B pcap_activate()
+.B pcap_activate(3PCAP)
 before packets can be captured
 with it; options for the capture, such as promiscuous mode, can be set
 on the handle before activating it.
@@ -69,4 +69,4 @@
 .B PCAP_ERRBUF_SIZE
 chars.
 .SH SEE ALSO
-pcap(3PCAP), pcap_activate(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_datalink.3pcap b/pcap_datalink.3pcap
index 50508f8..9e8477e 100644
--- a/pcap_datalink.3pcap
+++ b/pcap_datalink.3pcap
@@ -37,9 +37,9 @@
 .IR p .
 .PP
 It must not be called on a pcap descriptor created by
-.B pcap_create()
+.B \%pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR \%pcap_activate(3PCAP) .
 .PP
 .I https://www.tcpdump.org/linktypes.html
 lists the values
diff --git a/pcap_datalink.3pcap.in b/pcap_datalink.3pcap.in
index a32f15e..2620368 100644
--- a/pcap_datalink.3pcap.in
+++ b/pcap_datalink.3pcap.in
@@ -37,9 +37,9 @@
 .IR p .
 .PP
 It must not be called on a pcap descriptor created by
-.B pcap_create()
+.B \%pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR \%pcap_activate(3PCAP) .
 .PP
 .I https://www.tcpdump.org/linktypes.html
 lists the values
diff --git a/pcap_datalink_name_to_val.3pcap b/pcap_datalink_name_to_val.3pcap
index e6419f2..dd4688f 100644
--- a/pcap_datalink_name_to_val.3pcap
+++ b/pcap_datalink_name_to_val.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_DATALINK_NAME_TO_VAL 3PCAP "12 October 2016"
+.TH PCAP_DATALINK_NAME_TO_VAL 3PCAP "25 July 2018"
 .SH NAME
 pcap_datalink_name_to_val \- get the link-layer header type value
 corresponding to a header type name
@@ -41,7 +41,9 @@
 translation is case-insensitive.
 .SH RETURN VALUE
 .B pcap_datalink_name_to_val()
-returns the type value on success and \-1 if the name is not a known
+returns the type value on success and
+.B PCAP_ERROR
+if the name is not a known
 type name..
 .SH SEE ALSO
 pcap(3PCAP)
diff --git a/pcap_datalink_val_to_name.3pcap b/pcap_datalink_val_to_name.3pcap
index fad350f..f42165f 100644
--- a/pcap_datalink_val_to_name.3pcap
+++ b/pcap_datalink_val_to_name.3pcap
@@ -19,7 +19,8 @@
 .\"
 .TH PCAP_DATALINK_VAL_TO_NAME 3PCAP "12 October 2016"
 .SH NAME
-pcap_datalink_val_to_name, pcap_datalink_val_to_description \- get a
+pcap_datalink_val_to_name, pcap_datalink_val_to_description,
+pcap_datalink_val_to_description_or_dlt \- get a
 name or description for a link-layer header type value
 .SH SYNOPSIS
 .nf
@@ -30,6 +31,7 @@
 .ft B
 const char *pcap_datalink_val_to_name(int dlt);
 const char *pcap_datalink_val_to_description(int dlt);
+const char *pcap_datalink_val_to_description_or_dlt(int dlt);
 .ft
 .fi
 .SH DESCRIPTION
@@ -52,3 +54,13 @@
 is returned if the type value does not correspond to a known
 .B DLT_
 value.
+.PP
+.B pcap_datalink_val_to_description_or_dlt()
+translates a link-layer header type value to a short description of that
+link-layer header type just like pcap_datalink_val_to_description.
+If the type value does not correspond to a known
+.B DLT_
+value, the string "DLT n" is returned, where n is the value of
+the dlt argument.
+.SH SEE ALSO
+pcap(3PCAP)
diff --git a/pcap_dump.3pcap b/pcap_dump.3pcap
index 6402b4b..7f201b7 100644
--- a/pcap_dump.3pcap
+++ b/pcap_dump.3pcap
@@ -35,11 +35,11 @@
 .SH DESCRIPTION
 .B pcap_dump()
 outputs a packet to the ``savefile'' opened with
-.BR pcap_dump_open() .
+.BR pcap_dump_open(3PCAP) .
 Note that its calling arguments are suitable for use with
-.B pcap_dispatch()
+.B pcap_dispatch(3PCAP)
 or
-.BR pcap_loop() .
+.BR pcap_loop(3PCAP) .
 If called directly, the
 .I user
 parameter is of type
@@ -47,5 +47,4 @@
 as returned by
 .BR pcap_dump_open() .
 .SH SEE ALSO
-pcap(3PCAP), pcap_dump_open(3PCAP), pcap_dispatch(3PCAP),
-pcap_loop(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_dump_file.3pcap b/pcap_dump_file.3pcap
index 8fea610..d207431 100644
--- a/pcap_dump_file.3pcap
+++ b/pcap_dump_file.3pcap
@@ -33,6 +33,6 @@
 .SH DESCRIPTION
 .B pcap_dump_file()
 returns the standard I/O stream of the ``savefile'' opened by
-.BR pcap_dump_open() .
+.BR pcap_dump_open(3PCAP) .
 .SH SEE ALSO
 pcap(3PCAP)
diff --git a/pcap_dump_flush.3pcap b/pcap_dump_flush.3pcap
index c8f110b..5d17474 100644
--- a/pcap_dump_flush.3pcap
+++ b/pcap_dump_flush.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_DUMP_FLUSH 3PCAP "3 January 2014"
+.TH PCAP_DUMP_FLUSH 3PCAP "25 July 2018"
 .SH NAME
 pcap_dump_flush \- flush to a savefile packets dumped
 .SH SYNOPSIS
@@ -34,10 +34,12 @@
 .B pcap_dump_flush()
 flushes the output buffer to the ``savefile,'' so that any packets
 written with
-.B pcap_dump()
+.B pcap_dump(3PCAP)
 but not yet written to the ``savefile'' will be written.
 .SH RETURN VALUE
 .B pcap_dump_flush()
-returns 0 on success and \-1 on failure.
+returns 0 on success and
+.B PCAP_ERROR
+on failure.
 .SH SEE ALSO
-pcap(3PCAP), pcap_dump_open(3PCAP), pcap_dump(3PCAP)
+pcap(3PCAP), pcap_dump_open(3PCAP)
diff --git a/pcap_dump_ftell.3pcap b/pcap_dump_ftell.3pcap
index ec621fb..20cb995 100644
--- a/pcap_dump_ftell.3pcap
+++ b/pcap_dump_ftell.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_DUMP_FTELL 3PCAP "29 September 2017"
+.TH PCAP_DUMP_FTELL 3PCAP "25 July 2018"
 .SH NAME
 pcap_dump_ftell, pcap_dump_ftell64 \- get the current file offset for a savefile being written
 .SH SYNOPSIS
@@ -36,11 +36,11 @@
 .B pcap_dump_ftell()
 returns the current file position for the ``savefile'', representing the
 number of bytes written by
-.B pcap_dump_open()
+.B pcap_dump_open(3PCAP)
 and
-.BR pcap_dump() .
-\-1 is returned on error.
-If the current file position does not fit in a
+.BR pcap_dump(3PCAP) .
+.B PCAP_ERROR
+is returned on error. If the current file position does not fit in a
 .BR long ,
 it will be truncated; this can happen on 32-bit UNIX-like systems with
 large file support and on Windows.
@@ -52,6 +52,7 @@
 but that fit in a
 .B int64_t
 are supported, this will return the file offset without truncation.
-\-1 is returned on error.
+.B PCAP_ERROR
+is returned on error.
 .SH SEE ALSO
-pcap(3PCAP), pcap_dump_open(3PCAP), pcap_dump(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_dump_open.3pcap b/pcap_dump_open.3pcap
index 03956ba..67e7715 100644
--- a/pcap_dump_open.3pcap
+++ b/pcap_dump_open.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_DUMP_OPEN 3PCAP "22 June 2018"
+.TH PCAP_DUMP_OPEN 3PCAP "22 August 2018"
 .SH NAME
 pcap_dump_open, pcap_dump_fopen \- open a file to which to write packets
 .SH SYNOPSIS
@@ -50,26 +50,26 @@
 is called to write data to an existing open stream
 .IR fp ;
 this stream will be closed by a subsequent call to
-.BR pcap_dump_close() .
+.BR pcap_dump_close(3PCAP) .
 Note that on Windows, that stream should be opened in binary mode.
 .PP
 .I p
 is a capture or ``savefile'' handle returned by an earlier call to
-.B pcap_create()
+.B pcap_create(3PCAP)
 and activated by an earlier call to
-.BR pcap_activate() ,
+.BR \%pcap_activate(3PCAP) ,
 or returned by an earlier call to
-.BR pcap_open_offline() ,
-.BR pcap_open_live() ,
+.BR \%pcap_open_offline(3PCAP) ,
+.BR pcap_open_live(3PCAP) ,
 or
-.BR pcap_open_dead() .
+.BR pcap_open_dead(3PCAP) .
 The time stamp precision, link-layer type, and snapshot length from
 .I p
 are used as the link-layer type and snapshot length of the output file.
 .PP
 .B pcap_dump_open_append()
 is like
-.B pcap_dump_open
+.B pcap_dump_open()
 but does not create the file if it does not exist and, if it does
 already exist, and is a pcap file with the same byte order as the host
 opening the file, and has the same time stamp precision, link-layer
@@ -80,19 +80,24 @@
 A pointer to a
 .B pcap_dumper_t
 structure to use in subsequent
-.B pcap_dump()
+.B pcap_dump(3PCAP)
 and
-.B pcap_dump_close()
+.B pcap_dump_close(3PCAP)
 calls is returned on success.
 .B NULL
 is returned on failure.
 If
 .B NULL
 is returned,
-.B pcap_geterr(\fIp\fB)
+.B pcap_geterr(3PCAP)
 can be used to get the error text.
+.SH BACKWARD COMPATIBILITY
+.PP
+The
+.B pcap_dump_open_append()
+function became available in libpcap release 1.7.2.  In previous
+releases, there is no support for appending packets to an existing
+savefile.
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
-\%pcap_open_offline(3PCAP), pcap_open_live(3PCAP), pcap_open_dead(3PCAP),
-pcap_dump(3PCAP), pcap_dump_close(3PCAP), pcap_geterr(3PCAP),
+pcap(3PCAP),
 \%pcap-savefile(5)
diff --git a/pcap_dump_open.3pcap.in b/pcap_dump_open.3pcap.in
index 5b37b47..b86696f 100644
--- a/pcap_dump_open.3pcap.in
+++ b/pcap_dump_open.3pcap.in
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_DUMP_OPEN 3PCAP "22 June 2018"
+.TH PCAP_DUMP_OPEN 3PCAP "22 August 2018"
 .SH NAME
 pcap_dump_open, pcap_dump_fopen \- open a file to which to write packets
 .SH SYNOPSIS
@@ -50,26 +50,26 @@
 is called to write data to an existing open stream
 .IR fp ;
 this stream will be closed by a subsequent call to
-.BR pcap_dump_close() .
+.BR pcap_dump_close(3PCAP) .
 Note that on Windows, that stream should be opened in binary mode.
 .PP
 .I p
 is a capture or ``savefile'' handle returned by an earlier call to
-.B pcap_create()
+.B pcap_create(3PCAP)
 and activated by an earlier call to
-.BR pcap_activate() ,
+.BR \%pcap_activate(3PCAP) ,
 or returned by an earlier call to
-.BR pcap_open_offline() ,
-.BR pcap_open_live() ,
+.BR \%pcap_open_offline(3PCAP) ,
+.BR pcap_open_live(3PCAP) ,
 or
-.BR pcap_open_dead() .
+.BR pcap_open_dead(3PCAP) .
 The time stamp precision, link-layer type, and snapshot length from
 .I p
 are used as the link-layer type and snapshot length of the output file.
 .PP
 .B pcap_dump_open_append()
 is like
-.B pcap_dump_open
+.B pcap_dump_open()
 but does not create the file if it does not exist and, if it does
 already exist, and is a pcap file with the same byte order as the host
 opening the file, and has the same time stamp precision, link-layer
@@ -80,19 +80,24 @@
 A pointer to a
 .B pcap_dumper_t
 structure to use in subsequent
-.B pcap_dump()
+.B pcap_dump(3PCAP)
 and
-.B pcap_dump_close()
+.B pcap_dump_close(3PCAP)
 calls is returned on success.
 .B NULL
 is returned on failure.
 If
 .B NULL
 is returned,
-.B pcap_geterr(\fIp\fB)
+.B pcap_geterr(3PCAP)
 can be used to get the error text.
+.SH BACKWARD COMPATIBILITY
+.PP
+The
+.B pcap_dump_open_append()
+function became available in libpcap release 1.7.2.  In previous
+releases, there is no support for appending packets to an existing
+savefile.
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
-\%pcap_open_offline(3PCAP), pcap_open_live(3PCAP), pcap_open_dead(3PCAP),
-pcap_dump(3PCAP), pcap_dump_close(3PCAP), pcap_geterr(3PCAP),
+pcap(3PCAP),
 \%pcap-savefile(@MAN_FILE_FORMATS@)
diff --git a/pcap_file.3pcap b/pcap_file.3pcap
index cd6b06b..981451b 100644
--- a/pcap_file.3pcap
+++ b/pcap_file.3pcap
@@ -34,13 +34,15 @@
 .B pcap_file()
 returns the standard I/O stream of the ``savefile,'' if a ``savefile''
 was opened with
-.BR pcap_open_offline() ,
-or NULL, if a network device was opened with
-.B pcap_create()
+.BR pcap_open_offline(3PCAP) ,
+or
+.BR NULL ,
+if a network device was opened with
+.B pcap_create(3PCAP)
 and
-.BR pcap_activate() ,
+.BR \%pcap_activate(3PCAP) ,
 or with
-.BR pcap_open_live() .
+.BR pcap_open_live(3PCAP) .
 .PP
 Note that the Packet Capture library is usually built with large file
 support, so the standard I/O stream of the ``savefile'' might refer to
@@ -50,8 +52,8 @@
 value of
 .B pcap_file()
 or the value returned by
-.B fileno()
+.B fileno(3)
 when passed the return value of
 .BR pcap_file() .
 .SH SEE ALSO
-pcap(3PCAP), pcap_open_offline(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_fileno.3pcap b/pcap_fileno.3pcap
index e8c9ac4..60ac129 100644
--- a/pcap_fileno.3pcap
+++ b/pcap_fileno.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_FILENO 3PCAP "7 April 2014"
+.TH PCAP_FILENO 3PCAP "25 July 2018"
 .SH NAME
 pcap_fileno \- get the file descriptor for a live capture
 .SH SYNOPSIS
@@ -35,32 +35,31 @@
 .I p
 refers to a network device that was opened for a live capture using
 a combination of
-.B pcap_create()
+.B pcap_create(3PCAP)
 and
-.BR pcap_activate() ,
+.BR pcap_activate(3PCAP) ,
 or using
-.BR pcap_open_live() ,
+.BR pcap_open_live(3PCAP) ,
 .B pcap_fileno()
 returns the file descriptor from which captured packets are read.
 .LP
 If
 .I p
 refers to a ``savefile'' that was opened using functions such as
-.BR pcap_open_offline()
+.BR pcap_open_offline(3PCAP)
 or
-.BR pcap_fopen_offline() ,
+.BR pcap_fopen_offline(3PCAP) ,
 a ``dead''
 .B pcap_t
 opened using
-.BR pcap_open_dead() ,
+.BR pcap_open_dead(3PCAP) ,
 or a
 .B pcap_t
 that was created with
 .B pcap_create()
 but that has not yet been activated with
 .BR pcap_activate() ,
-it returns \-1.
+it returns
+.BR PCAP_ERROR .
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
-pcap_open_live(3PCAP), pcap_open_offline(3PCAP),
-\%pcap_fopen_offline(3PCAP), pcap_open_dead(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_findalldevs.3pcap b/pcap_findalldevs.3pcap
index 14825ad..712e255 100644
--- a/pcap_findalldevs.3pcap
+++ b/pcap_findalldevs.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_FINDALLDEVS 3PCAP "29 April 2018"
+.TH PCAP_FINDALLDEVS 3PCAP "22 August 2018"
 .SH NAME
 pcap_findalldevs, pcap_freealldevs \- get a list of capture devices, and
 free that list
@@ -40,11 +40,11 @@
 .SH DESCRIPTION
 .B pcap_findalldevs()
 constructs a list of network devices that can be opened with
-.B pcap_create()
+.B pcap_create(3PCAP)
 and
-.B pcap_activate()
+.B pcap_activate(3PCAP)
 or with
-.BR pcap_open_live() .
+.BR pcap_open_live(3PCAP) .
 (Note that there may be network devices that cannot be opened by the
 process calling
 .BR pcap_findalldevs() ,
@@ -194,21 +194,38 @@
 .BR "struct sockaddr_in6".
 .PP
 The list of devices must be freed with
-.BR pcap_freealldevs() ,
+.BR pcap_freealldevs(3PCAP) ,
 which frees the list pointed to by
 .IR alldevs .
 .SH RETURN VALUE
 .B pcap_findalldevs()
-returns 0 on success and \-1 on failure; as indicated, finding no
+returns 0 on success and
+.B PCAP_ERROR
+on failure; as indicated, finding no
 devices is considered success, rather than failure, so 0 will be
-returned in that case.
-If \-1 is returned,
+returned in that case. If
+.B PCAP_ERROR
+is returned,
 .I errbuf
 is filled in with an appropriate error message.
 .I errbuf
 is assumed to be able to hold at least
 .B PCAP_ERRBUF_SIZE
 chars.
+.SH BACKWARD COMPATIBILITY
+.PP
+The
+.B PCAP_IF_UP
+and
+.B PCAP_IF_RUNNING
+constants became available in libpcap release 1.6.1.  The
+.BR PCAP_IF_WIRELESS ,
+.BR PCAP_IF_CONNECTION_STATUS ,
+.BR PCAP_IF_CONNECTION_STATUS_UNKNOWN ,
+.BR PCAP_IF_CONNECTION_STATUS_CONNECTED ,
+.BR PCAP_IF_CONNECTION_STATUS_DISCONNECTED ,
+and
+.B PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE
+constants became available in libpcap release 1.9.0.
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
-pcap_open_live(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_freecode.3pcap b/pcap_freecode.3pcap
index fac4b3d..4e71efa 100644
--- a/pcap_freecode.3pcap
+++ b/pcap_freecode.3pcap
@@ -35,9 +35,9 @@
 is used to free up allocated memory pointed to by a
 .I bpf_program
 struct generated by
-.B pcap_compile()
+.B pcap_compile(3PCAP)
 when that BPF program is no longer needed, for example after it
 has been made the filter program for a pcap structure by a call to
-.BR pcap_setfilter() .
+.BR pcap_setfilter(3PCAP) .
 .SH SEE ALSO
-pcap(3PCAP), pcap_compile(3PCAP), pcap_setfilter(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_get_required_select_timeout.3pcap b/pcap_get_required_select_timeout.3pcap
index bc33e5d..e58cb4e 100644
--- a/pcap_get_required_select_timeout.3pcap
+++ b/pcap_get_required_select_timeout.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_GET_REQUIRED_SELECT_TIMEOUT 3PCAP "20 January 2018"
+.TH PCAP_GET_REQUIRED_SELECT_TIMEOUT 3PCAP "25 July 2018"
 .SH NAME
 pcap_get_required_select_timeout \- get a file descriptor on which a
 select() can be done for a live capture
@@ -36,24 +36,27 @@
 returns, on UNIX, a pointer to a
 .B struct timeval
 containing a value that must be used as the minimum timeout in
-.BR select() ,
-.BR poll() ,
-.BR epoll_wait() ,
+.BR select(2) ,
+.BR poll(2) ,
+.BR epoll_wait(2) ,
 and
 .B kevent()
 calls if
-.B pcap_get_selectable_fd()
-returns \-1.
+.B pcap_get_selectable_fd(3PCAP)
+returns
+.BR PCAP_ERROR .
 .PP
 The timeout that should be used in those calls must be no larger than
 the smallest of all timeouts returned by
-.B pcap_get_required_select_timeout()
+.B \%pcap_get_required_select_timeout()
 for devices from which packets will be captured.
 .PP
 The device for which
 .B pcap_get_selectable_fd()
-returned \-1 must be put in non-blocking mode with
-.BR pcap_setnonblock() ,
+returned
+.B PCAP_ERROR
+must be put in non-blocking mode with
+.BR pcap_setnonblock(3PCAP) ,
 and an attempt must always be made to read packets from the device
 when the
 .BR select() ,
@@ -66,9 +69,9 @@
 Note that a device on which a read can be done without blocking may,
 on some platforms, not have any packets to read if the packet buffer
 timeout has expired.  A call to
-.B pcap_dispatch()
+.B pcap_dispatch(3PCAP)
 or
-.B pcap_next_ex()
+.B pcap_next_ex(3PCAP)
 will return 0 in this case, but will not block.
 .PP
 .B pcap_get_required_select_timeout()
@@ -79,6 +82,17 @@
 is returned if the timeout is required; otherwise
 .B NULL
 is returned.
+.SH BACKWARD COMPATIBILITY
+This function became available in libpcap release 1.9.0.  In previous
+releases,
+.BR select() ,
+.BR poll() ,
+.BR epoll_wait() ,
+and
+.B kevent()
+cannot be used on any capture source for which
+.B pcap_get_selectable_fd
+returns \-1.
 .SH SEE ALSO
 pcap(3PCAP), pcap_get_selectable_fd(3PCAP), select(2), poll(2),
 epoll_wait(2), kqueue(2)
diff --git a/pcap_get_selectable_fd.3pcap b/pcap_get_selectable_fd.3pcap
index f1ddfe2..7f43db3 100644
--- a/pcap_get_selectable_fd.3pcap
+++ b/pcap_get_selectable_fd.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_GET_SELECTABLE_FD 3PCAP "20 January 2018"
+.TH PCAP_GET_SELECTABLE_FD 3PCAP "25 July 2018"
 .SH NAME
 pcap_get_selectable_fd \- get a file descriptor on which a select() can
 be done for a live capture
@@ -36,32 +36,38 @@
 returns, on UNIX, a file descriptor number for a file descriptor on
 which one can
 do a
-.BR select() ,
-.BR poll() ,
-.BR epoll_wait() ,
+.BR select(2) ,
+.BR poll(2) ,
+.BR epoll_wait(2) ,
 .BR kevent() ,
 or other such call
 to wait for it to be possible to read packets without blocking, if such
-a descriptor exists, or \-1, if no such descriptor exists.
+a descriptor exists, or
+.BR PCAP_ERROR ,
+if no such descriptor exists.
 .PP
 Some network devices opened with
-.B pcap_create()
+.B pcap_create(3PCAP)
 and
-.BR pcap_activate() ,
+.BR pcap_activate(3PCAP) ,
 or with
-.BR pcap_open_live() ,
+.BR pcap_open_live(3PCAP) ,
 do not support those calls (for example, regular network devices on
-FreeBSD 4.3 and 4.4, and Endace DAG devices), so \-1 is returned for
+FreeBSD 4.3 and 4.4, and Endace DAG devices), so
+.B PCAP_ERROR
+is returned for
 those devices.  In that case, those calls must be given a timeout less
 than or equal to the timeout returned by
-.B pcap_get_required_select_timeout()
+.B pcap_get_required_select_timeout(3PCAP)
 for the device for which
 .B pcap_get_selectable_fd()
-returned \-1, the device must be put in non-blocking mode with a call to
-.BR pcap_setnonblock() ,
+returned
+.BR PCAP_ERROR ,
+the device must be put in non-blocking mode with a call to
+.BR \%pcap_setnonblock(3PCAP) ,
 and an attempt must always be made to read packets from the device
 when the call returns.  If
-.B pcap_get_required_select_timeout()
+.B \%pcap_get_required_select_timeout()
 returns
 .BR NULL ,
 it is not possible to wait for packets to arrive on the device in an
@@ -70,9 +76,9 @@
 Note that a device on which a read can be done without blocking may,
 on some platforms, not have any packets to read if the packet buffer
 timeout has expired.  A call to
-.B pcap_dispatch()
+.B pcap_dispatch(3PCAP)
 or
-.B pcap_next_ex()
+.B pcap_next_ex(3PCAP)
 will return 0 in this case, but will not block.
 .PP
 Note that in:
@@ -138,8 +144,8 @@
 .B pcap_get_selectable_fd()
 is not available on Windows.
 .SH RETURN VALUE
-A selectable file descriptor is returned if one exists; otherwise, \-1
+A selectable file descriptor is returned if one exists; otherwise,
+.B PCAP_ERROR
 is returned.
 .SH SEE ALSO
-pcap(3PCAP), pcap_get_required_select_timeout(3PCAP),
-pcap_setnonblock(3PCAP), select(2), poll(2), epoll_wait(2), kqueue(2)
+pcap(3PCAP), kqueue(2)
diff --git a/pcap_get_tstamp_precision.3pcap b/pcap_get_tstamp_precision.3pcap
index 709147a..9388a69 100644
--- a/pcap_get_tstamp_precision.3pcap
+++ b/pcap_get_tstamp_precision.3pcap
@@ -46,6 +46,10 @@
 which indicates
 that pcap captures contains time stamps in microseconds or nanoseconds
 respectively.
+.SH BACKWARD COMPATIBILITY
+This function became available in libpcap release 1.5.1.  In previous
+releases, time stamps from a capture device or savefile are always given
+in seconds and microseconds.
 .SH SEE ALSO
 pcap(3PCAP),
 pcap_set_tstamp_precision(3PCAP),
diff --git a/pcap_get_tstamp_precision.3pcap.in b/pcap_get_tstamp_precision.3pcap.in
index 285e770..2e72e0b 100644
--- a/pcap_get_tstamp_precision.3pcap.in
+++ b/pcap_get_tstamp_precision.3pcap.in
@@ -46,6 +46,10 @@
 which indicates
 that pcap captures contains time stamps in microseconds or nanoseconds
 respectively.
+.SH BACKWARD COMPATIBILITY
+This function became available in libpcap release 1.5.1.  In previous
+releases, time stamps from a capture device or savefile are always given
+in seconds and microseconds.
 .SH SEE ALSO
 pcap(3PCAP),
 pcap_set_tstamp_precision(3PCAP),
diff --git a/pcap_inject.3pcap b/pcap_inject.3pcap
index ff9792d..92a9263 100644
--- a/pcap_inject.3pcap
+++ b/pcap_inject.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_INJECT 3PCAP "3 January 2014"
+.TH PCAP_INJECT 3PCAP "25 July 2018"
 .SH NAME
 pcap_inject, pcap_sendpacket \- transmit a packet
 .SH SYNOPSIS
@@ -42,7 +42,7 @@
 Note that, even if you successfully open the network interface, you
 might not have permission to send packets on it, or it might not support
 sending packets; as
-.I pcap_open_live()
+.B pcap_open_live(3PCAP)
 doesn't have a flag to indicate whether to open for capturing, sending,
 or capturing and sending, you cannot request an open that supports
 sending and be notified at open time whether sending will be possible.
@@ -72,17 +72,23 @@
 comes from WinPcap.  Both are provided for compatibility.)
 .SH RETURN VALUE
 .B pcap_inject()
-returns the number of bytes written on success and \-1 on failure.
+returns the number of bytes written on success and
+.B PCAP_ERROR
+on failure.
 .PP
 .B pcap_sendpacket()
-returns 0 on success and \-1 on failure.
+returns 0 on success and
+.B PCAP_ERROR
+on failure.
 .PP
-If \-1 is returned,
-.B pcap_geterr()
+If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_is_swapped.3pcap b/pcap_is_swapped.3pcap
index 36691d3..67f762f 100644
--- a/pcap_is_swapped.3pcap
+++ b/pcap_is_swapped.3pcap
@@ -39,9 +39,9 @@
 (0).
 .PP
 It must not be called on a pcap descriptor created by
-.B pcap_create()
+.B \%pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR \%pcap_activate(3PCAP) .
 .SH RETURN VALUE
 .B pcap_is_swapped()
 returns true (1) or false (0) on success and
diff --git a/pcap_list_datalinks.3pcap b/pcap_list_datalinks.3pcap
index 1fde73d..c73c1d4 100644
--- a/pcap_list_datalinks.3pcap
+++ b/pcap_list_datalinks.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_LIST_DATALINKS 3PCAP "8 March 2015"
+.TH PCAP_LIST_DATALINKS 3PCAP "25 July 2018"
 .SH NAME
 pcap_list_datalinks, pcap_free_datalinks \- get a list of link-layer header
 types supported by a capture device, and free that list
@@ -47,9 +47,9 @@
 .IR dlt_list .
 .LP
 It must not be called on a pcap descriptor created by
-.B pcap_create()
+.B \%pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR \%pcap_activate(3PCAP) .
 .SH RETURN VALUE
 .B pcap_list_datalinks()
 returns the number of link-layer header types in the array on success,
@@ -57,17 +57,17 @@
 if called on a capture handle that has been created but not activated,
 and
 .B PCAP_ERROR
-(\-1) on other errors.
+on other errors.
 If
 .B PCAP_ERROR
 is returned,
-.B pcap_geterr()
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B \%pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP),
+pcap(3PCAP),
 pcap_datalink_val_to_name(3PCAP),
 pcap-linktype(7)
diff --git a/pcap_list_datalinks.3pcap.in b/pcap_list_datalinks.3pcap.in
index 9f52b63..60ba478 100644
--- a/pcap_list_datalinks.3pcap.in
+++ b/pcap_list_datalinks.3pcap.in
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_LIST_DATALINKS 3PCAP "8 March 2015"
+.TH PCAP_LIST_DATALINKS 3PCAP "25 July 2018"
 .SH NAME
 pcap_list_datalinks, pcap_free_datalinks \- get a list of link-layer header
 types supported by a capture device, and free that list
@@ -47,9 +47,9 @@
 .IR dlt_list .
 .LP
 It must not be called on a pcap descriptor created by
-.B pcap_create()
+.B \%pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR \%pcap_activate(3PCAP) .
 .SH RETURN VALUE
 .B pcap_list_datalinks()
 returns the number of link-layer header types in the array on success,
@@ -57,17 +57,17 @@
 if called on a capture handle that has been created but not activated,
 and
 .B PCAP_ERROR
-(\-1) on other errors.
+on other errors.
 If
 .B PCAP_ERROR
 is returned,
-.B pcap_geterr()
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B \%pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP),
+pcap(3PCAP),
 pcap_datalink_val_to_name(3PCAP),
 pcap-linktype(@MAN_MISC_INFO@)
diff --git a/pcap_list_tstamp_types.3pcap b/pcap_list_tstamp_types.3pcap
index 4afa36f..1d3fc9a 100644
--- a/pcap_list_tstamp_types.3pcap
+++ b/pcap_list_tstamp_types.3pcap
@@ -18,7 +18,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_LIST_TSTAMP_TYPES 3PCAP "22 August 2010"
+.TH PCAP_LIST_TSTAMP_TYPES 3PCAP "22 August 2018"
 .SH NAME
 pcap_list_tstamp_types, pcap_free_tstamp_types \- get a list of time
 stamp types supported by a capture device, and free that list
@@ -54,17 +54,28 @@
 returns the number of time stamp types in the array on success and
 .B PCAP_ERROR
 on failure.
-A return value of zero means that you cannot specify a time stamp type;
-you are limited to the capture device's default time stamp type.
+A return value of one means that the only time stamp type supported is
+the one in the list, which is the capture device's default time stamp
+type.  A return value of zero means that the only time stamp type
+supported is
+.BR PCAP_TSTAMP_HOST ,
+which is the capture device's default time stamp type (only older
+versions of libpcap will return that; newer versions will always return
+one or more types).
 If
 .B PCAP_ERROR
 is returned,
-.B pcap_geterr()
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
+.SH BACKWARD COMPATIBILITY
+.PP
+These functions became available in libpcap release 1.2.1.  In previous
+releases, the time stamp type cannot be set; only the default time stamp
+type offered by a capture source is available.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP), pcap_tstamp_type_val_to_name(3PCAP),
+pcap(3PCAP), pcap_tstamp_type_val_to_name(3PCAP),
 pcap-tstamp(7)
diff --git a/pcap_list_tstamp_types.3pcap.in b/pcap_list_tstamp_types.3pcap.in
index a139324..e2487f7 100644
--- a/pcap_list_tstamp_types.3pcap.in
+++ b/pcap_list_tstamp_types.3pcap.in
@@ -18,7 +18,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_LIST_TSTAMP_TYPES 3PCAP "22 August 2010"
+.TH PCAP_LIST_TSTAMP_TYPES 3PCAP "22 August 2018"
 .SH NAME
 pcap_list_tstamp_types, pcap_free_tstamp_types \- get a list of time
 stamp types supported by a capture device, and free that list
@@ -54,17 +54,28 @@
 returns the number of time stamp types in the array on success and
 .B PCAP_ERROR
 on failure.
-A return value of zero means that you cannot specify a time stamp type;
-you are limited to the capture device's default time stamp type.
+A return value of one means that the only time stamp type supported is
+the one in the list, which is the capture device's default time stamp
+type.  A return value of zero means that the only time stamp type
+supported is
+.BR PCAP_TSTAMP_HOST ,
+which is the capture device's default time stamp type (only older
+versions of libpcap will return that; newer versions will always return
+one or more types).
 If
 .B PCAP_ERROR
 is returned,
-.B pcap_geterr()
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
+.SH BACKWARD COMPATIBILITY
+.PP
+These functions became available in libpcap release 1.2.1.  In previous
+releases, the time stamp type cannot be set; only the default time stamp
+type offered by a capture source is available.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP), pcap_tstamp_type_val_to_name(3PCAP),
+pcap(3PCAP), pcap_tstamp_type_val_to_name(3PCAP),
 pcap-tstamp(@MAN_MISC_INFO@)
diff --git a/pcap_lookupdev.3pcap b/pcap_lookupdev.3pcap
index eb493ba..29f09e3 100644
--- a/pcap_lookupdev.3pcap
+++ b/pcap_lookupdev.3pcap
@@ -47,13 +47,13 @@
 .B pcap_lookupdev()
 returns a pointer to a string giving the name of a network device
 suitable for use with
-.B pcap_create()
+.B pcap_create(3PCAP)
 and
-.BR pcap_activate() ,
+.BR \%pcap_activate(3PCAP) ,
 or with
-.BR pcap_open_live() ,
+.BR pcap_open_live(3PCAP) ,
 and with
-.BR pcap_lookupnet() .
+.BR pcap_lookupnet(3PCAP) .
 If there is an error,
 .B NULL
 is returned and
@@ -64,8 +64,7 @@
 .B PCAP_ERRBUF_SIZE
 chars.
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
-pcap_open_live(3PCAP), pcap_lookupnet(3PCAP)
+pcap(3PCAP)
 .SH BUGS
 The pointer returned by
 .B pcap_lookupdev()
diff --git a/pcap_lookupnet.3pcap b/pcap_lookupnet.3pcap
index c38ff3a..f609445 100644
--- a/pcap_lookupnet.3pcap
+++ b/pcap_lookupnet.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_LOOKUPNET 3PCAP "3 January 2014"
+.TH PCAP_LOOKUPNET 3PCAP "25 July 2018"
 .SH NAME
 pcap_lookupnet \- find the IPv4 network number and netmask for a device
 .SH SYNOPSIS
@@ -51,8 +51,11 @@
 pointers.
 .SH RETURN VALUE
 .B pcap_lookupnet()
-returns 0 on success and \-1 on failure.
-If \-1 is returned,
+returns 0 on success and
+.B PCAP_ERROR
+on failure. If
+.B PCAP_ERROR
+is returned,
 .I errbuf
 is filled in with an appropriate error message.
 .I errbuf
diff --git a/pcap_loop.3pcap b/pcap_loop.3pcap
index 4679b46..0193714 100644
--- a/pcap_loop.3pcap
+++ b/pcap_loop.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_LOOP 3PCAP "20 January 2017"
+.TH PCAP_LOOP 3PCAP "25 July 2018"
 .SH NAME
 pcap_loop, pcap_dispatch \- process packets from a live capture or savefile
 .SH SYNOPSIS
@@ -47,7 +47,7 @@
 .I cnt
 packets are processed, the end of the ``savefile'' is
 reached when reading from a ``savefile'',
-.B pcap_breakloop()
+.B pcap_breakloop(3PCAP)
 is called, or an error occurs.
 It does
 .B not
@@ -123,7 +123,7 @@
 .PP
 The bytes of data from the packet begin with a link-layer header.  The
 format of the link-layer header is indicated by the return value of the
-.B pcap_datalink()
+.B pcap_datalink(3PCAP)
 routine when handed the
 .B pcap_t
 value also passed to
@@ -136,7 +136,7 @@
 can return and describes the packet formats that
 correspond to those values.  The value it returns will be valid for all
 packets received unless and until
-.B pcap_set_datalink()
+.B pcap_set_datalink(3PCAP)
 is called; after a successful call to
 .BR pcap_set_datalink() ,
 all subsequent packets will have a link-layer header of the type
@@ -160,8 +160,11 @@
 returns 0 if
 .I cnt
 is exhausted or if, when reading from a ``savefile'', no more packets
-are available.  It returns \-1 if an error occurs or \-2 if the loop
-terminated due to a call to
+are available.  It returns
+.B PCAP_ERROR
+if an error occurs or
+.B PCAP_ERROR_BREAK
+if the loop terminated due to a call to
 .B pcap_breakloop()
 before any packets were processed.
 It does
@@ -177,23 +180,27 @@
 packets arrive, the timeout expires before any packets arrive, or if the
 file descriptor for the capture device is in non-blocking mode and no
 packets were available to be read) or if no more packets are available
-in a ``savefile.'' It returns \-1 if an error occurs or \-2 if the loop
-terminated due to a call to
+in a ``savefile.'' It returns
+.B PCAP_ERROR
+if an error occurs or
+.B PCAP_ERROR_BREAK
+if the loop terminated due to a call to
 .B pcap_breakloop()
 before any packets were processed.
 .ft B
 If your application uses pcap_breakloop(),
-make sure that you explicitly check for \-1 and \-2, rather than just
-checking for a return value < 0.
+make sure that you explicitly check for PCAP_ERROR and PCAP_ERROR_BREAK,
+rather than just checking for a return value < 0.
 .ft R
 .PP
-If \-1 is returned,
-.B pcap_geterr()
+If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP), pcap_breakloop(3PCAP),
-pcap_datalink(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_next_ex.3pcap b/pcap_next_ex.3pcap
index 88e8314..f0eb82d 100644
--- a/pcap_next_ex.3pcap
+++ b/pcap_next_ex.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_NEXT_EX 3PCAP "20 January 2017"
+.TH PCAP_NEXT_EX 3PCAP "25 July 2018"
 .SH NAME
 pcap_next_ex, pcap_next \- read the next packet from a pcap_t
 .SH SYNOPSIS
@@ -49,9 +49,9 @@
 guaranteed to be valid after the next call to
 .BR pcap_next_ex() ,
 .BR pcap_next() ,
-.BR pcap_loop() ,
+.BR pcap_loop(3PCAP) ,
 or
-.BR pcap_dispatch() ;
+.BR pcap_dispatch(3PCAP) ;
 if the code needs them to remain valid, it must make a copy of them.
 .PP
 .B pcap_next()
@@ -78,7 +78,7 @@
 .PP
 The bytes of data from the packet begin with a link-layer header.  The
 format of the link-layer header is indicated by the return value of the
-.B pcap_datalink()
+.B pcap_datalink(PCAP)
 routine when handed the
 .B pcap_t
 value also passed to
@@ -91,7 +91,7 @@
 can return and describes the packet formats that
 correspond to those values.  The value it returns will be valid for all
 packets received unless and until
-.B pcap_set_datalink()
+.B pcap_set_datalink(3PCAP)
 is called; after a successful call to
 .BR pcap_set_datalink() ,
 all subsequent packets will have a link-layer header of the type
@@ -114,12 +114,17 @@
 .B pcap_next_ex()
 returns 1 if the packet was read without problems, 0 if packets are
 being read from a live capture and the packet buffer timeout expired,
-\-1 if an error occurred while reading the packet, and \-2 if packets
+.B PCAP_ERROR
+if an error occurred while reading the packet, and
+.B PCAP_ERROR_BREAK
+if packets
 are being read from a ``savefile'' and there are no more packets to read
-from the savefile.  If \-1 is returned,
-.B pcap_geterr()
+from the savefile.  If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
@@ -136,5 +141,4 @@
 more packets are available in a ``savefile.'' Unfortunately, there is no
 way to determine whether an error occurred or not.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP), pcap_dispatch(3PCAP),
-pcap_datalink(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_offline_filter.3pcap b/pcap_offline_filter.3pcap
index 08c0b66..724f836 100644
--- a/pcap_offline_filter.3pcap
+++ b/pcap_offline_filter.3pcap
@@ -39,7 +39,7 @@
 is a pointer to a
 .I bpf_program
 struct, usually the result of a call to
-.BR pcap_compile() .
+.BR pcap_compile(3PCAP) .
 .I h
 points to the
 .I pcap_pkthdr
@@ -52,4 +52,4 @@
 the packet doesn't match the filter and non-zero if the packet matches
 the filter.
 .SH SEE ALSO
-pcap(3PCAP), pcap_compile(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_open_dead.3pcap b/pcap_open_dead.3pcap
index 118c533..8522a2c 100644
--- a/pcap_open_dead.3pcap
+++ b/pcap_open_dead.3pcap
@@ -43,10 +43,10 @@
 structure to use when calling the other functions in libpcap.  It is
 typically used when just using libpcap for compiling BPF code; it can
 also be used if using
-.BR pcap_dump_open() ,
-.BR pcap_dump() ,
+.BR pcap_dump_open(3PCAP) ,
+.BR pcap_dump(3PCAP) ,
 and
-.B pcap_dump_close()
+.B pcap_dump_close(3PCAP)
 to write a savefile if there is no
 .B pcap_t
 that supplies the packets to be written.
@@ -73,7 +73,6 @@
 .B PCAP_TSTAMP_PRECISION_NANO
 should be specified if the packets to be written have time stamps in
 seconds and nanoseconds.  Its value does not affect
-.BR pcap_compile() .
+.BR pcap_compile(3PCAP) .
 .SH SEE ALSO
-pcap(3PCAP), pcap_compile(3PCAP), pcap_dump_open(3PCAP),
-\%pcap-linktype(7)
+pcap(3PCAP), \%pcap-linktype(7)
diff --git a/pcap_open_dead.3pcap.in b/pcap_open_dead.3pcap.in
index 621e75b..97a97f3 100644
--- a/pcap_open_dead.3pcap.in
+++ b/pcap_open_dead.3pcap.in
@@ -43,10 +43,10 @@
 structure to use when calling the other functions in libpcap.  It is
 typically used when just using libpcap for compiling BPF code; it can
 also be used if using
-.BR pcap_dump_open() ,
-.BR pcap_dump() ,
+.BR pcap_dump_open(3PCAP) ,
+.BR pcap_dump(3PCAP) ,
 and
-.B pcap_dump_close()
+.B pcap_dump_close(3PCAP)
 to write a savefile if there is no
 .B pcap_t
 that supplies the packets to be written.
@@ -73,7 +73,6 @@
 .B PCAP_TSTAMP_PRECISION_NANO
 should be specified if the packets to be written have time stamps in
 seconds and nanoseconds.  Its value does not affect
-.BR pcap_compile() .
+.BR pcap_compile(3PCAP) .
 .SH SEE ALSO
-pcap(3PCAP), pcap_compile(3PCAP), pcap_dump_open(3PCAP),
-\%pcap-linktype(@MAN_MISC_INFO@)
+pcap(3PCAP), \%pcap-linktype(@MAN_MISC_INFO@)
diff --git a/pcap_open_live.3pcap b/pcap_open_live.3pcap
index 942d4fc..3286e29 100644
--- a/pcap_open_live.3pcap
+++ b/pcap_open_live.3pcap
@@ -87,4 +87,4 @@
 .B PCAP_ERRBUF_SIZE
 chars.
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP)
+pcap_create(3PCAP), pcap_activate(3PCAP)
diff --git a/pcap_open_offline.3pcap b/pcap_open_offline.3pcap
index 3c59372..b50cea4 100644
--- a/pcap_open_offline.3pcap
+++ b/pcap_open_offline.3pcap
@@ -81,7 +81,8 @@
 .B pcap_fopen_offline_with_tstamp_precision()
 to read dumped data from an existing open stream
 .IR fp .
-.B pcap_fopen_offline_with_tstamp_precision() takes an additional
+.B pcap_fopen_offline_with_tstamp_precision()
+takes an additional
 .I precision
 argument as described above.
 Note that on Windows, that stream should be opened in binary mode.
@@ -105,5 +106,11 @@
 is assumed to be able to hold at least
 .B PCAP_ERRBUF_SIZE
 chars.
+.SH BACKWARD COMPATIBILITY
+.B pcap_open_offline_with_tstamp_precision
+and
+.B pcap_fopen_offline_with_tstamp_precision
+became available in libpcap release 1.5.1.  In previous releases, time
+stamps from a savefile are always given in seconds and microseconds.
 .SH SEE ALSO
 pcap(3PCAP), pcap-savefile(5)
diff --git a/pcap_open_offline.3pcap.in b/pcap_open_offline.3pcap.in
index d0cd161..2bfbbac 100644
--- a/pcap_open_offline.3pcap.in
+++ b/pcap_open_offline.3pcap.in
@@ -81,7 +81,8 @@
 .B pcap_fopen_offline_with_tstamp_precision()
 to read dumped data from an existing open stream
 .IR fp .
-.B pcap_fopen_offline_with_tstamp_precision() takes an additional
+.B pcap_fopen_offline_with_tstamp_precision()
+takes an additional
 .I precision
 argument as described above.
 Note that on Windows, that stream should be opened in binary mode.
@@ -105,5 +106,11 @@
 is assumed to be able to hold at least
 .B PCAP_ERRBUF_SIZE
 chars.
+.SH BACKWARD COMPATIBILITY
+.B pcap_open_offline_with_tstamp_precision
+and
+.B pcap_fopen_offline_with_tstamp_precision
+became available in libpcap release 1.5.1.  In previous releases, time
+stamps from a savefile are always given in seconds and microseconds.
 .SH SEE ALSO
 pcap(3PCAP), pcap-savefile(@MAN_FILE_FORMATS@)
diff --git a/pcap_set_datalink.3pcap b/pcap_set_datalink.3pcap
index 24d57a5..66cfdb1 100644
--- a/pcap_set_datalink.3pcap
+++ b/pcap_set_datalink.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_SET_DATALINK 3PCAP "3 January 2014"
+.TH PCAP_SET_DATALINK 3PCAP "25 July 2018"
 .SH NAME
 pcap_set_datalink \- set the link-layer header type to be used by a
 capture device
@@ -38,14 +38,16 @@
 .IR dlt .
 .SH RETURN VALUE
 .B pcap_set_datalink()
-returns 0 on success and \-1 on failure.
-If \-1 is returned,
-.B pcap_geterr()
+returns 0 on success and
+.B PCAP_ERROR
+on failure. If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP),
-pcap_datalink_name_to_val(3PCAP)
+pcap(3PCAP), pcap_datalink_name_to_val(3PCAP)
diff --git a/pcap_set_immediate_mode.3pcap b/pcap_set_immediate_mode.3pcap
index b3ad243..93a2797 100644
--- a/pcap_set_immediate_mode.3pcap
+++ b/pcap_set_immediate_mode.3pcap
@@ -18,7 +18,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "5 December 2013"
+.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "22 August 2018"
 .SH NAME
 pcap_set_immediate_mode \- set immediate mode for a not-yet-activated capture
 handle
@@ -34,7 +34,8 @@
 .SH DESCRIPTION
 .B pcap_set_immediate_mode()
 sets whether immediate mode should be set on a capture handle when
-the handle is activated.
+the handle is activated.  In immediate mode, packets are always
+delivered as soon as they arrive, with no buffering.
 If
 .I immediate_mode
 is non-zero, immediate mode will be set, otherwise it will not be set.
@@ -43,5 +44,52 @@
 returns 0 on success or
 .B PCAP_ERROR_ACTIVATED
 if called on a capture handle that has been activated.
+.SH BACKWARD COMPATIBILITY
+.PP
+This function became available in libpcap release 1.5.0.  In previous
+releases, if immediate delivery of packets is required:
+.IP
+on FreeBSD, NetBSD, OpenBSD, DragonFly BSD, macOS, and Solaris 11,
+immediate mode must be turned on with a
+.B BIOCIMMEDIATE
+.BR ioctl (2),
+as documented in
+.BR bpf(4) ,
+on the descriptor returned by
+.B pcap_fileno(3PCAP),
+after
+.BR pcap_activate(3PCAP)
+is called;
+.IP
+on Solaris 10 and earlier versions of Solaris, immediate mode must be
+turned on by using a read timeout of 0 when opening the device (this
+will not provide immediate delivery of packets on other platforms, so
+don't assume it's sufficient);
+.IP
+on Digital UNIX/Tru64 UNIX, immediate mode must be turned on by doing a
+.B BIOCMBIC
+.BR ioctl ,
+as documented in
+.BR packetfilter(7) ,
+to clear the
+.B ENBATCH
+flag on the descriptor returned by
+.B pcap_fileno(3PCAP),
+after
+.BR pcap_activate(3PCAP)
+is called;
+.IP
+on Windows, immediate mode must be turned on by calling
+.B pcap_setmintocopy()
+with a size of 0.
+.PP
+On Linux, with previous releases of libpcap, capture devices are always
+in immediate mode; however, in 1.5.0 and later, they are, by default,
+.B not
+in immediate mode, so if
+.B pcap_set_immediate_mode()
+is available, it should be used.
+.PP
+On other platforms, capture devices are always in immediate mode.
 .SH SEE ALSO
 pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP)
diff --git a/pcap_set_immediate_mode.3pcap.in b/pcap_set_immediate_mode.3pcap.in
new file mode 100644
index 0000000..2fe45c5
--- /dev/null
+++ b/pcap_set_immediate_mode.3pcap.in
@@ -0,0 +1,95 @@
+.\"
+.\" Copyright (c) 1994, 1996, 1997
+.\"	The Regents of the University of California.  All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that: (1) source code distributions
+.\" retain the above copyright notice and this paragraph in its entirety, (2)
+.\" distributions including binary code include the above copyright notice and
+.\" this paragraph in its entirety in the documentation or other materials
+.\" provided with the distribution, and (3) all advertising materials mentioning
+.\" features or use of this software display the following acknowledgement:
+.\" ``This product includes software developed by the University of California,
+.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+.\" the University nor the names of its contributors may be used to endorse
+.\" or promote products derived from this software without specific prior
+.\" written permission.
+.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\"
+.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "22 August 2018"
+.SH NAME
+pcap_set_immediate_mode \- set immediate mode for a not-yet-activated capture
+handle
+.SH SYNOPSIS
+.nf
+.ft B
+#include <pcap/pcap.h>
+.LP
+.ft B
+int pcap_set_immediate_mode(pcap_t *p, int immediate_mode);
+.ft
+.fi
+.SH DESCRIPTION
+.B pcap_set_immediate_mode()
+sets whether immediate mode should be set on a capture handle when
+the handle is activated.  In immediate mode, packets are always
+delivered as soon as they arrive, with no buffering.
+If
+.I immediate_mode
+is non-zero, immediate mode will be set, otherwise it will not be set.
+.SH RETURN VALUE
+.B pcap_set_immediate_mode()
+returns 0 on success or
+.B PCAP_ERROR_ACTIVATED
+if called on a capture handle that has been activated.
+.SH BACKWARD COMPATIBILITY
+.PP
+This function became available in libpcap release 1.5.0.  In previous
+releases, if immediate delivery of packets is required:
+.IP
+on FreeBSD, NetBSD, OpenBSD, DragonFly BSD, macOS, and Solaris 11,
+immediate mode must be turned on with a
+.B BIOCIMMEDIATE
+.BR ioctl (2),
+as documented in
+.BR bpf(@MAN_DEVICES@) ,
+on the descriptor returned by
+.B pcap_fileno(3PCAP),
+after
+.BR pcap_activate(3PCAP)
+is called;
+.IP
+on Solaris 10 and earlier versions of Solaris, immediate mode must be
+turned on by using a read timeout of 0 when opening the device (this
+will not provide immediate delivery of packets on other platforms, so
+don't assume it's sufficient);
+.IP
+on Digital UNIX/Tru64 UNIX, immediate mode must be turned on by doing a
+.B BIOCMBIC
+.BR ioctl ,
+as documented in
+.BR packetfilter(7) ,
+to clear the
+.B ENBATCH
+flag on the descriptor returned by
+.B pcap_fileno(3PCAP),
+after
+.BR pcap_activate(3PCAP)
+is called;
+.IP
+on Windows, immediate mode must be turned on by calling
+.B pcap_setmintocopy()
+with a size of 0.
+.PP
+On Linux, with previous releases of libpcap, capture devices are always
+in immediate mode; however, in 1.5.0 and later, they are, by default,
+.B not
+in immediate mode, so if
+.B pcap_set_immediate_mode()
+is available, it should be used.
+.PP
+On other platforms, capture devices are always in immediate mode.
+.SH SEE ALSO
+pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP)
diff --git a/pcap_set_protocol_linux.3pcap b/pcap_set_protocol_linux.3pcap
index 40eb8d2..873017b 100644
--- a/pcap_set_protocol_linux.3pcap
+++ b/pcap_set_protocol_linux.3pcap
@@ -48,7 +48,7 @@
 .LP
 It should not be used in portable code; instead, a filter should be
 specified with
-.BR pcap_setfilter() .
+.BR pcap_setfilter(3PCAP) .
 .LP
 If a given network interface provides a standard link-layer header, with
 a standard packet type, but provides some packet types with a different
@@ -62,6 +62,7 @@
 returns 0 on success or
 .B PCAP_ERROR_ACTIVATED
 if called on a capture handle that has been activated.
+.SH BACKWARD COMPATIBILITY
+This function became available in libpcap release 1.9.0.
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP), socket(2),
-pcap_setfilter(3PCAP)
+pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP)
diff --git a/pcap_set_timeout.3pcap b/pcap_set_timeout.3pcap
index cacf603..e67b813 100644
--- a/pcap_set_timeout.3pcap
+++ b/pcap_set_timeout.3pcap
@@ -49,5 +49,5 @@
 .B PCAP_ERROR_ACTIVATED
 if called on a capture handle that has been activated.
 .SH SEE ALSO
-pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
+pcap_create(3PCAP), pcap_activate(3PCAP),
 \%pcap_set_immediate_mode(3PCAP)
diff --git a/pcap_set_tstamp_precision.3pcap b/pcap_set_tstamp_precision.3pcap
index 773aa32..0600354 100644
--- a/pcap_set_tstamp_precision.3pcap
+++ b/pcap_set_tstamp_precision.3pcap
@@ -39,9 +39,9 @@
 descriptor to the type specified by
 .IR tstamp_precision .
 It must be called on a pcap descriptor created by
-.B pcap_create()
+.B pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR pcap_activate(3PCAP) .
 Two time stamp precisions are supported, microseconds and nanoseconds. One can
 use options
 .B PCAP_TSTAMP_PRECISION_MICRO and
@@ -50,11 +50,16 @@
 .SH RETURN VALUE
 .B pcap_set_tstamp_precision()
 returns 0 on success if the specified time stamp precision is expected to be
-supported by the operating system,
+supported by the capture device,
 .B PCAP_ERROR_TSTAMP_PRECISION_NOTSUP
-if operating system does not support requested time stamp precision,
+if the capture device does not support the requested time stamp
+precision,
 .B PCAP_ERROR_ACTIVATED
 if called on a capture handle that has been activated.
+.SH BACKWARD COMPATIBILITY
+This function became available in libpcap release 1.5.1.  In previous
+releases, time stamps from a capture device or savefile are always given
+in seconds and microseconds.
 .SH SEE ALSO
 pcap(3PCAP),
 pcap_get_tstamp_precision(3PCAP),
diff --git a/pcap_set_tstamp_precision.3pcap.in b/pcap_set_tstamp_precision.3pcap.in
index 57c4ea3..dc2b4b3 100644
--- a/pcap_set_tstamp_precision.3pcap.in
+++ b/pcap_set_tstamp_precision.3pcap.in
@@ -39,9 +39,9 @@
 descriptor to the type specified by
 .IR tstamp_precision .
 It must be called on a pcap descriptor created by
-.B pcap_create()
+.B pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR pcap_activate(3PCAP) .
 Two time stamp precisions are supported, microseconds and nanoseconds. One can
 use options
 .B PCAP_TSTAMP_PRECISION_MICRO and
@@ -50,11 +50,16 @@
 .SH RETURN VALUE
 .B pcap_set_tstamp_precision()
 returns 0 on success if the specified time stamp precision is expected to be
-supported by the operating system,
+supported by the capture device,
 .B PCAP_ERROR_TSTAMP_PRECISION_NOTSUP
-if operating system does not support requested time stamp precision,
+if the capture device does not support the requested time stamp
+precision,
 .B PCAP_ERROR_ACTIVATED
 if called on a capture handle that has been activated.
+.SH BACKWARD COMPATIBILITY
+This function became available in libpcap release 1.5.1.  In previous
+releases, time stamps from a capture device or savefile are always given
+in seconds and microseconds.
 .SH SEE ALSO
 pcap(3PCAP),
 pcap_get_tstamp_precision(3PCAP),
diff --git a/pcap_set_tstamp_type.3pcap b/pcap_set_tstamp_type.3pcap
index b797c1a..4754278 100644
--- a/pcap_set_tstamp_type.3pcap
+++ b/pcap_set_tstamp_type.3pcap
@@ -18,7 +18,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_SET_TSTAMP_TYPE 3PCAP "5 December 2014"
+.TH PCAP_SET_TSTAMP_TYPE 3PCAP "22 August 2018"
 .SH NAME
 pcap_set_tstamp_type \- set the time stamp type to be used by a
 capture device
@@ -38,10 +38,10 @@
 descriptor to the type specified by
 .IR tstamp_type .
 It must be called on a pcap descriptor created by
-.B pcap_create()
+.B pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
-.B pcap_list_tstamp_types()
+.BR pcap_activate(3PCAP) .
+.B pcap_list_tstamp_types(3PCAP)
 will give a list of the time stamp types supported by a given capture
 device.
 See
@@ -57,9 +57,14 @@
 .B PCAP_ERROR_ACTIVATED
 if called on a capture handle that has been activated, and
 .B PCAP_ERROR_CANTSET_TSTAMP_TYPE
-if the capture device doesn't support setting the time stamp type.
+if the capture device doesn't support setting the time stamp type (only
+older versions of libpcap will return that; newer versions will always
+allow the time stamp type to be set to the default type).
+.SH BACKWARD COMPATIBILITY
+.PP
+This function became available in libpcap release 1.2.1.  In previous
+releases, the time stamp type cannot be set; only the default time stamp
+type offered by a capture source is available.
 .SH SEE ALSO
 pcap(3PCAP),
-pcap_list_tstamp_types(3PCAP),
-pcap_tstamp_type_name_to_val(3PCAP),
-pcap-tstamp(7)
+pcap_tstamp_type_name_to_val(3PCAP)
diff --git a/pcap_set_tstamp_type.3pcap.in b/pcap_set_tstamp_type.3pcap.in
index 7899da3..9833f46 100644
--- a/pcap_set_tstamp_type.3pcap.in
+++ b/pcap_set_tstamp_type.3pcap.in
@@ -18,7 +18,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_SET_TSTAMP_TYPE 3PCAP "5 December 2014"
+.TH PCAP_SET_TSTAMP_TYPE 3PCAP "22 August 2018"
 .SH NAME
 pcap_set_tstamp_type \- set the time stamp type to be used by a
 capture device
@@ -38,10 +38,10 @@
 descriptor to the type specified by
 .IR tstamp_type .
 It must be called on a pcap descriptor created by
-.B pcap_create()
+.B pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
-.B pcap_list_tstamp_types()
+.BR pcap_activate(3PCAP) .
+.B pcap_list_tstamp_types(3PCAP)
 will give a list of the time stamp types supported by a given capture
 device.
 See
@@ -57,9 +57,14 @@
 .B PCAP_ERROR_ACTIVATED
 if called on a capture handle that has been activated, and
 .B PCAP_ERROR_CANTSET_TSTAMP_TYPE
-if the capture device doesn't support setting the time stamp type.
+if the capture device doesn't support setting the time stamp type (only
+older versions of libpcap will return that; newer versions will always
+allow the time stamp type to be set to the default type).
+.SH BACKWARD COMPATIBILITY
+.PP
+This function became available in libpcap release 1.2.1.  In previous
+releases, the time stamp type cannot be set; only the default time stamp
+type offered by a capture source is available.
 .SH SEE ALSO
 pcap(3PCAP),
-pcap_list_tstamp_types(3PCAP),
-pcap_tstamp_type_name_to_val(3PCAP),
-pcap-tstamp(@MAN_MISC_INFO@)
+pcap_tstamp_type_name_to_val(3PCAP)
diff --git a/pcap_setdirection.3pcap b/pcap_setdirection.3pcap
index 11945f5..f174b98 100644
--- a/pcap_setdirection.3pcap
+++ b/pcap_setdirection.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_SETDIRECTION 3PCAP "8 March 2015"
+.TH PCAP_SETDIRECTION 3PCAP "25 July 2018"
 .SH NAME
 pcap_setdirection \- set the direction for which packets will be captured
 .SH SYNOPSIS
@@ -57,13 +57,16 @@
 This operation is not supported if a ``savefile'' is being read.
 .SH RETURN VALUE
 .B pcap_setdirection()
-returns 0 on success and \-1 on failure.
-If \-1 is returned,
-.B pcap_geterr()
+returns 0 on success and
+.B PCAP_ERROR
+on failure. If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_setfilter.3pcap b/pcap_setfilter.3pcap
index 6efd253..8729693 100644
--- a/pcap_setfilter.3pcap
+++ b/pcap_setfilter.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_SETFILTER 3PCAP "7 April 2014"
+.TH PCAP_SETFILTER 3PCAP "25 July 2018"
 .SH NAME
 pcap_setfilter \- set the filter
 .SH SYNOPSIS
@@ -37,16 +37,19 @@
 is a pointer to a
 .I bpf_program
 struct, usually the result of a call to
-.BR pcap_compile() .
+.BR \%pcap_compile(3PCAP) .
 .SH RETURN VALUE
 .B pcap_setfilter()
-returns 0 on success and \-1 on failure.
-If \-1 is returned,
-.B pcap_geterr()
+returns 0 on success and
+.B PCAP_ERROR
+on failure. If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_compile(3PCAP), pcap_geterr(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_setnonblock.3pcap b/pcap_setnonblock.3pcap
index 6959127..e8adebe 100644
--- a/pcap_setnonblock.3pcap
+++ b/pcap_setnonblock.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_SETNONBLOCK 3PCAP "18 October 2014"
+.TH PCAP_SETNONBLOCK 3PCAP "25 July 2018"
 .SH NAME
 pcap_setnonblock, pcap_getnonblock \- set or get the state of
 non-blocking mode on a capture device
@@ -43,25 +43,27 @@
 of ``non-blocking'' mode, depending on whether the
 .I nonblock
 argument is non-zero or zero.  It has no effect on ``savefiles''.
-If there is an error, \-1 is returned and
+If there is an error,
+.B PCAP_ERROR
+is returned and
 .I errbuf
 is filled in with an appropriate error message; otherwise, 0 is
 returned.
 In
 ``non-blocking'' mode, an attempt to read from the capture descriptor
 with
-.B pcap_dispatch()
+.B pcap_dispatch(3PCAP)
 will, if no packets are currently available to be read, return 0
 immediately rather than blocking waiting for packets to arrive.
-.B pcap_loop()
+.B pcap_loop(3PCAP)
 and
-.B pcap_next()
+.B pcap_next(3PCAP)
 will not work in ``non-blocking'' mode.
 .PP
 When first activated with
-.B pcap_activate()
+.B pcap_activate(3PCAP)
 or opened with
-.B pcap_open_live() ,
+.B pcap_open_live(3PCAP) ,
 a capture handle is not in ``non-blocking mode''; a call to
 .B pcap_setnonblock()
 is required in order to put it into ``non-blocking'' mode.
@@ -69,7 +71,9 @@
 .B pcap_getnonblock()
 returns the current ``non-blocking'' state of the capture descriptor; it
 always returns 0 on ``savefiles''.
-If there is an error, \-1 is returned and
+If there is an error,
+.B PCAP_ERROR
+is returned and
 .I errbuf
 is filled in with an appropriate error message.
 .PP
@@ -78,4 +82,4 @@
 .B PCAP_ERRBUF_SIZE
 chars.
 .SH SEE ALSO
-pcap(3PCAP), pcap_loop(3PCAP), pcap_next_ex(3PCAP), pcap_geterr(3PCAP)
+pcap(3PCAP), pcap_next_ex(3PCAP), pcap_geterr(3PCAP)
diff --git a/pcap_snapshot.3pcap b/pcap_snapshot.3pcap
index 7af8c33..ee54bb0 100644
--- a/pcap_snapshot.3pcap
+++ b/pcap_snapshot.3pcap
@@ -33,16 +33,16 @@
 .SH DESCRIPTION
 .B pcap_snapshot()
 returns the snapshot length specified when
-.B pcap_set_snapshot()
+.B pcap_set_snaplen(3PCAP)
 or
-.B pcap_open_live()
+.B pcap_open_live(3PCAP)
 was called, for a live capture, or the snapshot length from the capture
 file, for a ``savefile''.
 .PP
 It must not be called on a pcap descriptor created by
-.B pcap_create()
+.B \%pcap_create(3PCAP)
 that has not yet been activated by
-.BR pcap_activate() .
+.BR \%pcap_activate(3PCAP) .
 .SH RETURN VALUE
 .B pcap_snapshot()
 returns the snapshot length on success and
diff --git a/pcap_stats.3pcap b/pcap_stats.3pcap
index 2dce4b5..465dada 100644
--- a/pcap_stats.3pcap
+++ b/pcap_stats.3pcap
@@ -17,7 +17,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_STATS 3PCAP "3 January 2014"
+.TH PCAP_STATS 3PCAP "25 July 2018"
 .SH NAME
 pcap_stats \- get capture statistics
 .SH SYNOPSIS
@@ -83,15 +83,18 @@
 that the interface did not drop any packets.
 .SH RETURN VALUE
 .B pcap_stats()
-returns 0 on success and returns \-1 if there is an error or if
+returns 0 on success and returns
+.B PCAP_ERROR
+if there is an error or if
 .I p
-doesn't support packet statistics.
-If \-1 is returned,
-.B pcap_geterr()
+doesn't support packet statistics. If
+.B PCAP_ERROR
+is returned,
+.B pcap_geterr(3PCAP)
 or
-.B pcap_perror()
+.B pcap_perror(3PCAP)
 may be called with
 .I p
 as an argument to fetch or display the error text.
 .SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP)
+pcap(3PCAP)
diff --git a/pcap_strerror.3pcap b/pcap_strerror.3pcap
index 7c7d53f..a5775f4 100644
--- a/pcap_strerror.3pcap
+++ b/pcap_strerror.3pcap
@@ -37,4 +37,4 @@
 isn't available.  It returns an error message string corresponding to
 .IR error .
 .SH SEE ALSO
-strerror(3)
+pcap(3PCAP)
diff --git a/pcap_tstamp_type_name_to_val.3pcap b/pcap_tstamp_type_name_to_val.3pcap
index ac2e35d..fdcc6c6 100644
--- a/pcap_tstamp_type_name_to_val.3pcap
+++ b/pcap_tstamp_type_name_to_val.3pcap
@@ -18,7 +18,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_TSTAMP_TYPE_NAME_TO_VAL 3PCAP "5 December 2014"
+.TH PCAP_TSTAMP_TYPE_NAME_TO_VAL 3PCAP "22 August 2018"
 .SH NAME
 pcap_tstamp_type_name_to_val \- get the time stamp type value
 corresponding to a time stamp type name
@@ -41,5 +41,8 @@
 returns time stamp type value on success and
 .B PCAP_ERROR
 on failure.
+.SH BACKWARD COMPATIBILITY
+.PP
+This function became available in libpcap release 1.2.1.
 .SH SEE ALSO
 pcap(3PCAP), pcap_tstamp_type_val_to_name(3PCAP)
diff --git a/pcap_tstamp_type_val_to_name.3pcap b/pcap_tstamp_type_val_to_name.3pcap
index 261554e..9374f48 100644
--- a/pcap_tstamp_type_val_to_name.3pcap
+++ b/pcap_tstamp_type_val_to_name.3pcap
@@ -18,7 +18,7 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH PCAP_TSTAMP_TYPE_VAL_TO_NAME 3PCAP "12 December 2013"
+.TH PCAP_TSTAMP_TYPE_VAL_TO_NAME 3PCAP "22 August 2018"
 .SH NAME
 pcap_tstamp_type_val_to_name, pcap_tstamp_type_val_to_description \- get
 a name or description for a time stamp type value
@@ -45,5 +45,8 @@
 stamp type.
 .B NULL
 is returned on failure.
+.SH BACKWARD COMPATIBILITY
+.PP
+These functions became available in libpcap release 1.2.1.
 .SH SEE ALSO
 pcap(3PCAP), pcap_tstamp_type_name_to_val(3PCAP)
diff --git a/portability.h b/portability.h
index b361254..543846e 100644
--- a/portability.h
+++ b/portability.h
@@ -38,6 +38,7 @@
  * Helpers for portability between Windows and UN*X and between different
  * flavors of UN*X.
  */
+#include <stdarg.h>	/* we declare varargs functions on some platforms */
 
 #include "pcap/funcattrs.h"
 
@@ -45,49 +46,45 @@
 extern "C" {
 #endif
 
-#ifndef HAVE_STRLCPY
- /*
-  * Macro that does the same thing as strlcpy().
-  */
- #if defined(_MSC_VER) || defined(__MINGW32__)
-  /*
-   * strncpy_s() is supported at least back to Visual
-   * Studio 2005.
-   */
-  #define strlcpy(x, y, z) \
-	strncpy_s((x), (z), (y), _TRUNCATE)
-
- #else
-  #define strlcpy(x, y, z) \
-	(strncpy((x), (y), (z)), \
-	 ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
-	 (void) strlen((y)))
- #endif
+#ifdef HAVE_STRLCAT
+  #define pcap_strlcat	strlcat
+#else
+  #if defined(_MSC_VER) || defined(__MINGW32__)
+    /*
+     * strncat_s() is supported at least back to Visual
+     * Studio 2005.
+     */
+    #define pcap_strlcat(x, y, z) \
+	strncat_s((x), (z), (y), _TRUNCATE)
+  #else
+    /*
+     * Define it ourselves.
+     */
+    extern size_t pcap_strlcat(char * restrict dst, const char * restrict src, size_t dstsize);
+  #endif
 #endif
 
-#ifndef HAVE_STRLCAT
- /*
-  * Macro that does the same thing as strlcat().
-  */
- #if defined(_MSC_VER) || defined(__MINGW32__)
-  /*
-   * strncat_s() is supported at least back to Visual
-   * Studio 2005.
-   */
-  #define strlcat(x, y, z) \
-	strncat_s((x), (z), (y), _TRUNCATE)
- #else
-  /*
-   * ANSI C says strncat() always null-terminates its first argument,
-   * so 1) we don't need to explicitly null-terminate the string
-   * ourselves and 2) we need to leave room for the null terminator.
-   */
-  #define strlcat(x, y, z) \
-	strncat((x), (y), (z) - strlen((x)) - 1)
- #endif
+#ifdef HAVE_STRLCPY
+  #define pcap_strlcpy	strlcpy
+#else
+  #if defined(_MSC_VER) || defined(__MINGW32__)
+    /*
+     * strncpy_s() is supported at least back to Visual
+     * Studio 2005.
+     */
+    #define pcap_strlcpy(x, y, z) \
+	strncpy_s((x), (z), (y), _TRUNCATE)
+  #else
+    /*
+     * Define it ourselves.
+     */
+    extern size_t pcap_strlcpy(char * restrict dst, const char * restrict src, size_t dstsize);
+  #endif
 #endif
 
 #ifdef _MSC_VER
+  #define isascii	__isascii
+
   /*
    * If <crtdbg.h> has been included, and _DEBUG is defined, and
    * __STDC__ is zero, <crtdbg.h> will define strdup() to call
@@ -134,6 +131,23 @@
 extern int pcap_vsnprintf(char *, size_t, const char *, va_list ap);
 #endif
 
+/*
+ * We also want asprintf(), for some cases where we use it to construct
+ * dynamically-allocated variable-length strings.
+ */
+#ifdef HAVE_ASPRINTF
+#define pcap_asprintf asprintf
+#else
+extern int pcap_asprintf(char **, PCAP_FORMAT_STRING(const char *), ...)
+    PCAP_PRINTFLIKE(2, 3);
+#endif
+
+#ifdef HAVE_VASPRINTF
+#define pcap_vasprintf vasprintf
+#else
+extern int pcap_vasprintf(char **, const char *, va_list ap);
+#endif
+
 #ifdef HAVE_STRTOK_R
   #define pcap_strtok_r	strtok_r
 #else
@@ -146,7 +160,6 @@
     /*
      * Define it ourselves.
      */
-    #define NEED_STRTOK_R
     extern char *pcap_strtok_r(char *, const char *, char **);
   #endif
 #endif /* HAVE_STRTOK_R */
diff --git a/post_update.sh b/post_update.sh
new file mode 100755
index 0000000..3cc1b1d
--- /dev/null
+++ b/post_update.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# $1 Path to the new version.
+# $2 Path to the old version.
+
+cp -a -n $2/config.h $1/
+cp -a $2/.gitignore $1/
+cp -a -n $2/pcap-netfilter-linux-android.h $1/
+cp -a -n $2/pcap-netfilter-linux-android.c $1/
+cp -a -n $2/grammar.c $1/
+cp -a -n $2/grammar.h $1/
+cp -a -n $2/scanner.c $1/
+cp -a -n $2/scanner.h $1/
+
diff --git a/rpcap-protocol.h b/rpcap-protocol.h
index 83ebdc5..8ae8b62 100644
--- a/rpcap-protocol.h
+++ b/rpcap-protocol.h
@@ -63,80 +63,20 @@
  *
  * Version negotiation is done as part of the authentication process:
  *
- * The client sends an authentication request, with the version number
- * in the request being the maximum version it supports.
+ * The client sends an authentication request, with a version number
+ * of 0.  All servers must accept authentication requests with a version
+ * number of 0, even if they don't support version 0 for any other
+ * requests.
  *
- * If the server supports that version, it attempts to authenticate the
- * client, and replies as appropriate, with the version number in the
- * reply being that version.
+ * The server attempts to authenticate the client.  If that succeeds,
+ * older servers - which only support version 0 - will send an
+ * authentication reply with no payload.  Newer servers - which might
+ * support other versions - will send an authentication reply with
+ * a payload giving the minimum and maximum versions it supports.
  *
- * If the server doesn't support that version because it's too large,
- * it replies with a RPCAP_MSG_ERROR message, with the maximum version
- * they support as the version number in the reply, and with the error
- * code being PCAP_ERR_WRONGVER.
- *
- * If the server doesn't support that version because it's too small,
- * it replies with a RPCAP_MSG_ERROR message, with that version as
- * the version number in the reply, and with the error code being
- * PCAP_ERR_WRONGVER.
- *
- * If the client supports that version, it retries the authentication
- * with that version and, if that fails for any reason, including
- * PCAP_ERR_WRONGVER, fails.  Otherwise, it fails, telling its caller
- * that there's no version that both support.
- *
- * This requires that the set of versions supported by a client or
- * server be a range of integers, with no gaps.  Thus:
- *
- * the client's version set is [Cmin, Cmax], with Cmin <= Cmax;
- *
- * the server's version set is [Smin, Smax], with Smin <= Smax;
- *
- * the client sends Cmax as the version number in the initial
- * authentication request;
- *
- * if the server doesn't support the version sent by the client,
- * either Smax < Cmax or Smin > Cmax (because the client sent Cmax
- * to the server, and the server doesn't support it);
- *
- * if Smax < Cmax:
- *
- *    the server sends Smax as the version number in the RPCAP_MSG_ERROR/
- *    PCAP_ERR_WRONGVER message - the client will accept this because
- *    Cmax != 0, as these numbers are unsigned, and this means that
- *    this isn't an old client that rejects all messages with a non-zero
- *    version number, it's a new client that accepts RPCAP_MSG_ERROR
- *    messages no matter what the version is;
- *
- *    if Smax >= Cmin, both the client and the server can use it, and
- *    the client retries with Smax;
- *
- *    if Smax < Cmin, there is no version the client and server can
- *    both support.
- *
- * if Smin > Cmax:
- *
- *    the server sends Cmax as the version number in the RPCAP_MSG_ERROR/
- *    PCAP_ERR_WRONGVER message - the client will accept this because
- *    Cmax is a valid client version number.
- *
- *    the client will retry with Cmax, get the same version failure,
- *    and report that there is no version the client and server can
- *    both support (as the version sets are disjoint).
- *
- * Old negotiation-unaware clients just send version 0 and, if they
- * get back PCAP_ERR_WRONGVER, treat it as a fatal error.  This
- * means they'll fail to talk to any server that can't handle
- * version 0, which is the appropriate thing to do, as they can
- * only use version 0.
- *
- * Old negotiation-unaware servers fail if they get a version other
- * than 0, sending back PCAP_ERR_WRONGVER with version 0, which is
- * the only version, and thus both the minimum and maximum version,
- * they support.  The client will either fail if it doesn't support
- * version 0, or will retry with version 0 and succeed, so it will
- * fail with servers that can't handle version 0 or will negotiate
- * version 0 with servers that can handle version 0.
+ * The client attempts to find the largest version number that is
+ * in both its range of supported versions and the server's supported
+ * versions.  If it fails, it gives up; otherwise, it uses that version.
  */
 #define RPCAP_MIN_VERSION 0
 #define RPCAP_MAX_VERSION 0
@@ -148,7 +88,8 @@
  * comparison will always succeed.
  */
 #if RPCAP_MIN_VERSION == 0
-#define RPCAP_VERSION_IS_SUPPORTED(v)	((v) <= RPCAP_MAX_VERSION)
+#define RPCAP_VERSION_IS_SUPPORTED(v)	\
+	((v) <= RPCAP_MAX_VERSION)
 #else
 #define RPCAP_VERSION_IS_SUPPORTED(v)	\
 	((v) >= RPCAP_MIN_VERSION && (v) <= RPCAP_MAX_VERSION)
@@ -176,6 +117,12 @@
  * for better alignment.
  * These structures have been created in order to be correctly aligned to
  * a 32-bit boundary, but be careful in any case.
+ *
+ * The layout of these structures MUST not be changed.  If a packet
+ * format is different in different versions of the protocol, versions
+ * of the structure should be provided for all the different versions or
+ * version ranges (if more than one version of the protocol has the same
+ * layout) that we support.
  */
 
 /*
@@ -199,6 +146,19 @@
 	uint32 plen;	/* Length of the payload of this RPCAP message */
 };
 
+/*
+ * Format of data that may appear at the end of an authentication reply,
+ * giving the minimum and maximum versions of the protocol that the
+ * server supports.
+ *
+ * Older servers don't provide this; they support only version 0.
+ */
+struct rpcap_authreply
+{
+	uint8 minvers;	/* Minimum version supported */
+	uint8 maxvers;	/* Maximum version supported */
+};
+
 /* Format of the message for the interface description (findalldevs command) */
 struct rpcap_findalldevs_if
 {
@@ -378,7 +338,12 @@
 	uint32 value;	/* Parameter related to the sampling method */
 };
 
-/* Messages field coding */
+/*
+ * Messages field coding.
+ *
+ * These values are used in messages sent over the network, and MUST
+ * not be changed.
+ */
 #define RPCAP_MSG_IS_REPLY		0x080	/* Flag indicating a reply */
 
 #define RPCAP_MSG_ERROR			1	/* Message that keeps an error notification */
@@ -410,24 +375,32 @@
 
 #define RPCAP_UPDATEFILTER_BPF 1			/* This code tells us that the filter is encoded with the BPF/NPF syntax */
 
-/* Network error codes */
-#define PCAP_ERR_NETW		1	/* Network error */
-#define PCAP_ERR_INITTIMEOUT	2	/* The RPCAP initial timeout has expired */
-#define PCAP_ERR_AUTH		3	/* Generic authentication error */
-#define PCAP_ERR_FINDALLIF	4	/* Generic findalldevs error */
-#define PCAP_ERR_NOREMOTEIF	5	/* The findalldevs was ok, but the remote end had no interfaces to list */
-#define PCAP_ERR_OPEN		6	/* Generic pcap_open error */
-#define PCAP_ERR_UPDATEFILTER	7	/* Generic updatefilter error */
-#define PCAP_ERR_GETSTATS	8	/* Generic pcap_stats error */
-#define PCAP_ERR_READEX		9	/* Generic pcap_next_ex error */
-#define PCAP_ERR_HOSTNOAUTH	10	/* The host is not authorized to connect to this server */
-#define PCAP_ERR_REMOTEACCEPT	11	/* Generic pcap_remoteaccept error */
-#define PCAP_ERR_STARTCAPTURE	12	/* Generic pcap_startcapture error */
-#define PCAP_ERR_ENDCAPTURE	13	/* Generic pcap_endcapture error */
-#define PCAP_ERR_RUNTIMETIMEOUT	14	/* The RPCAP run-time timeout has expired */
-#define PCAP_ERR_SETSAMPLING	15	/* Error during the settings of sampling parameters */
-#define PCAP_ERR_WRONGMSG	16	/* The other end endpoint sent a message which has not been recognized */
-#define PCAP_ERR_WRONGVER	17	/* The other end endpoint has a version number that is not compatible with our */
+/*
+ * Network error codes.
+ *
+ * These values are used in messages sent over the network, and MUST
+ * not be changed.
+ */
+#define PCAP_ERR_NETW			1	/* Network error */
+#define PCAP_ERR_INITTIMEOUT		2	/* The RPCAP initial timeout has expired */
+#define PCAP_ERR_AUTH			3	/* Generic authentication error */
+#define PCAP_ERR_FINDALLIF		4	/* Generic findalldevs error */
+#define PCAP_ERR_NOREMOTEIF		5	/* The findalldevs was ok, but the remote end had no interfaces to list */
+#define PCAP_ERR_OPEN			6	/* Generic pcap_open error */
+#define PCAP_ERR_UPDATEFILTER		7	/* Generic updatefilter error */
+#define PCAP_ERR_GETSTATS		8	/* Generic pcap_stats error */
+#define PCAP_ERR_READEX			9	/* Generic pcap_next_ex error */
+#define PCAP_ERR_HOSTNOAUTH		10	/* The host is not authorized to connect to this server */
+#define PCAP_ERR_REMOTEACCEPT		11	/* Generic pcap_remoteaccept error */
+#define PCAP_ERR_STARTCAPTURE		12	/* Generic pcap_startcapture error */
+#define PCAP_ERR_ENDCAPTURE		13	/* Generic pcap_endcapture error */
+#define PCAP_ERR_RUNTIMETIMEOUT		14	/* The RPCAP run-time timeout has expired */
+#define PCAP_ERR_SETSAMPLING		15	/* Error during the settings of sampling parameters */
+#define PCAP_ERR_WRONGMSG		16	/* The other end endpoint sent a message which has not been recognized */
+#define PCAP_ERR_WRONGVER		17	/* The other end endpoint has a version number that is not compatible with our */
+#define PCAP_ERR_AUTH_FAILED		18	/* The user couldn't be authenticated */
+#define PCAP_ERR_TLS_REQUIRED		19	/* The server requires TLS to connect */
+#define PCAP_ERR_AUTH_TYPE_NOTSUP	20	/* The authentication type isn't supported */
 
 /*
  * \brief Buffer used by socket functions to send-receive packets.
diff --git a/rpcapd/.gitignore b/rpcapd/.gitignore
index 50c27ab..aec4fdb 100644
--- a/rpcapd/.gitignore
+++ b/rpcapd/.gitignore
@@ -3,3 +3,4 @@
 *.o
 rpcapd
 rpcapd.manadmin
+rpcapd-config.manfile
diff --git a/rpcapd/CMakeLists.txt b/rpcapd/CMakeLists.txt
index b3b16e3..1821c85 100644
--- a/rpcapd/CMakeLists.txt
+++ b/rpcapd/CMakeLists.txt
@@ -59,7 +59,7 @@
   add_executable(rpcapd
     daemon.c
     fileconf.c
-    log-stderr.c
+    log.c
     rpcapd.c
     ${pcap_SOURCE_DIR}/rpcap-protocol.c
     ${pcap_SOURCE_DIR}/sockutils.c
@@ -71,6 +71,41 @@
     set_target_properties(rpcapd PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
   endif()
 
+  #
+  # By default, build rpcapd universal with the appropriate set of
+  # architectures for the OS on which we're doing the build.
+  #
+  if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
+    #
+    # Get the major version of Darwin.
+    #
+    string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}")
+
+    if(SYSTEM_VERSION_MAJOR EQUAL 9)
+      #
+      # Leopard.  Build for 32-bit x86 and 32-bit PowerPC, with
+      # 32-bit x86 first.
+      #
+      set(OSX_PROGRAM_ARCHITECTURES "i386;ppc")
+    elseif(SYSTEM_VERSION_MAJOR EQUAL 10)
+      #
+      # Snow Leopard.  Build for x86-64 and 32-bit x86, with
+      # x86-64 first.
+      #
+      set(OSX_PROGRAM_ARCHITECTURES "x86_64;i386")
+    else()
+      #
+      # Post-Snow Leopard.  Build only for x86-64.
+      # XXX - update if and when Apple adds ARM-based Macs.
+      # (You're on your own for iOS etc.)
+      #
+      set(OSX_PROGRAM_ARCHITECTURES "x86_64")
+    endif()
+
+    set_target_properties(rpcapd PROPERTIES
+      OSX_ARCHITECTURES "${OSX_PROGRAM_ARCHITECTURES}")
+  endif()
+
   if(WIN32)
     target_link_libraries(rpcapd ${LIBRARY_NAME}
       ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
@@ -92,6 +127,8 @@
 
   set(MANADMIN_EXPAND rpcapd.manadmin.in)
 
+  set(MANFILE_EXPAND rpcapd-config.manfile.in)
+
   if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
     install(TARGETS rpcapd DESTINATION bin/amd64)
   else(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -114,5 +151,13 @@
         set(MANADMIN ${MANADMIN} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
     endforeach(TEMPLATE_MANPAGE)
     install(FILES ${MANADMIN} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_ADMIN_COMMANDS})
+
+    set(MANFILE "")
+    foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND})
+        string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE})
+        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
+        set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
+    endforeach(TEMPLATE_MANPAGE)
+    install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS})
   endif(NOT MSVC)
 endif(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT))
diff --git a/rpcapd/Makefile.in b/rpcapd/Makefile.in
index d3e02c1..88e632a 100644
--- a/rpcapd/Makefile.in
+++ b/rpcapd/Makefile.in
@@ -66,7 +66,7 @@
 RPCAPD_LIBS = @RPCAPD_LIBS@
 
 # Standard CFLAGS
-FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
+FULL_CFLAGS = $(CCOPT) @V_PROG_CCOPT_FAT@ $(INCLS) $(DEFS) $(CFLAGS)
 
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -81,7 +81,7 @@
 
 SRC =	daemon.c \
 	fileconf.c \
-	log-stderr.c \
+	log.c \
 	rpcapd.c
 
 OBJ =	$(SRC:.c=.o) ../rpcap-protocol.o ../sockutils.o ../fmtutils.o
@@ -97,15 +97,19 @@
 MANADMIN = \
 	rpcapd.manadmin.in
 
+MANFILE = \
+	rpcapd-config.manfile.in
+
 rpcapd: $(OBJ) ../libpcap.a
-	$(CC) $(CCOPT) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) ../libpcap.a $(LIBS) $(RPCAPD_LIBS) $(PTHREAD_LIBS)
+	$(CC) $(CCOPT) $(CFLAGS) $(LDFLAGS) @V_PROG_LDFLAGS_FAT@ \
+	    -o $@ $(OBJ) ../libpcap.a $(LIBS) $(RPCAPD_LIBS) $(PTHREAD_LIBS)
 clean:
 	rm -f $(CLEANFILES)
 
 distclean: clean
 	rm -f Makefile config.cache config.log config.status \
 	    config.h stamp-h stamp-h.in
-	rm -f $(MANADMIN:.in=)
+	rm -f $(MANADMIN:.in=) $(MANFILE:.in=)
 	rm -rf autom4te.cache
 
 install: rpcapd
@@ -114,14 +118,21 @@
 	$(INSTALL_PROGRAM) rpcapd $(DESTDIR)$(sbindir)/rpcapd
 	[ -d $(DESTDIR)$(mandir)/man@MAN_ADMIN_COMMANDS@ ] || \
 	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_ADMIN_COMMANDS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_ADMIN_COMMANDS@)
+	[ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
+	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
 	for i in $(MANADMIN); do \
 		$(INSTALL_DATA) `echo $$i | sed 's/.manadmin.in/.manadmin/'` \
 		    $(DESTDIR)$(mandir)/man@MAN_ADMIN_COMMANDS@/`echo $$i | sed 's/.manadmin.in/.@MAN_ADMIN_COMMANDS@/'`; done
+	for i in $(MANFILE); do \
+		$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
+		    $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
 
 uninstall:
 	rm -f $(DESTDIR)$(sbindir)/rpcapd
 	for i in $(MANADMIN); do \
 		rm -f $(DESTDIR)$(mandir)/man@MAN_ADMIN_COMMANDS@/`echo $$i | sed 's/.manadmin.in/.@MAN_ADMIN_COMMANDS@/'`; done
+	for i in $(MANFILE); do \
+		rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
 
 tags: $(TAGFILES)
 	ctags -wtd $(TAGFILES)
diff --git a/rpcapd/daemon.c b/rpcapd/daemon.c
index 4bf42fd..209dba2 100644
--- a/rpcapd/daemon.c
+++ b/rpcapd/daemon.c
@@ -45,6 +45,7 @@
 #else
   #include <unistd.h>
   #include <pthread.h>
+  #include <signal.h>
   #include <sys/time.h>
   #include <sys/types.h>	// for select() and such
   #include <pwd.h>		// for password management
@@ -63,40 +64,50 @@
 #include "daemon.h"
 #include "log.h"
 
-#define RPCAP_TIMEOUT_INIT 90		/* Initial timeout for RPCAP connections (default: 90 sec) */
-#define RPCAP_TIMEOUT_RUNTIME 180	/* Run-time timeout for RPCAP connections (default: 3 min) */
-#define RPCAP_SUSPEND_WRONGAUTH 1	/* If the authentication is wrong, stops 1 sec before accepting a new auth message */
+//
+// Timeout, in seconds, when we're waiting for a client to send us an
+// authentication request; if they don't send us a request within that
+// interval, we drop the connection, so we don't stay stuck forever.
+//
+#define RPCAP_TIMEOUT_INIT 90
+
+//
+// Timeout, in seconds, when we're waiting for an authenticated client
+// to send us a request, if a capture isn't in progress; if they don't
+// send us a request within that interval, we drop the connection, so
+// we don't stay stuck forever.
+//
+#define RPCAP_TIMEOUT_RUNTIME 180
+
+//
+// Time, in seconds, that we wait after a failed authentication attempt
+// before processing the next request; this prevents a client from
+// rapidly trying different accounts or passwords.
+//
+#define RPCAP_SUSPEND_WRONGAUTH 1
 
 // Parameters for the service loop.
 struct daemon_slpars
 {
-	SOCKET sockctrl_in;	//!< SOCKET ID of the input side of the control connection
-	SOCKET sockctrl_out;	//!< SOCKET ID of the output side of the control connection
-	uint8 protocol_version;	//!< negotiated protocol version
+	SOCKET sockctrl;	//!< SOCKET ID of the control connection
 	int isactive;		//!< Not null if the daemon has to run in active mode
 	int nullAuthAllowed;	//!< '1' if we permit NULL authentication, '0' otherwise
 };
 
-/*
- * Data for a session managed by a thread.
- */
-struct session {
-	SOCKET sockctrl_out;
-	SOCKET sockdata;
-	uint8 protocol_version;
-	pcap_t *fp;
-	unsigned int TotCapt;
-};
-
 //
-// Structure to refer to a thread.
+// Data for a session managed by a thread.
 // It includes both a Boolean indicating whether we *have* a thread,
 // and a platform-dependent (UN*X vs. Windows) identifier for the
 // thread; on Windows, we could use an invalid handle to indicate
 // that we don't have a thread, but there *is* no portable "no thread"
 // value for a pthread_t on UN*X.
 //
-struct thread_handle {
+struct session {
+	SOCKET sockctrl;
+	SOCKET sockdata;
+	uint8 protocol_version;
+	pcap_t *fp;
+	unsigned int TotCapt;
 	int	have_thread;
 #ifdef _WIN32
 	HANDLE thread;
@@ -106,52 +117,68 @@
 };
 
 // Locally defined functions
-static int daemon_msg_err(SOCKET sockctrl_in, uint32 plen);
+static int daemon_msg_err(SOCKET sockctrl, uint32 plen);
 static int daemon_msg_auth_req(struct daemon_slpars *pars, uint32 plen);
 static int daemon_AuthUserPwd(char *username, char *password, char *errbuf);
 
-static int daemon_msg_findallif_req(struct daemon_slpars *pars, uint32 plen);
+static int daemon_msg_findallif_req(uint8 ver, struct daemon_slpars *pars,
+    uint32 plen);
 
-static int daemon_msg_open_req(struct daemon_slpars *pars, uint32 plen, char *source, size_t sourcelen);
-static int daemon_msg_startcap_req(struct daemon_slpars *pars, uint32 plen, struct thread_handle *threaddata, char *source, struct session **sessionp, struct rpcap_sampling *samp_param);
-static int daemon_msg_endcap_req(struct daemon_slpars *pars, struct session *session, struct thread_handle *threaddata);
+static int daemon_msg_open_req(uint8 ver, struct daemon_slpars *pars,
+    uint32 plen, char *source, size_t sourcelen);
+static int daemon_msg_startcap_req(uint8 ver, struct daemon_slpars *pars,
+    uint32 plen, char *source, struct session **sessionp,
+    struct rpcap_sampling *samp_param);
+static int daemon_msg_endcap_req(uint8 ver, struct daemon_slpars *pars,
+    struct session *session);
 
-static int daemon_msg_updatefilter_req(struct daemon_slpars *pars, struct session *session, uint32 plen);
-static int daemon_unpackapplyfilter(SOCKET sockctrl_in, struct session *session, uint32 *plenp, char *errbuf);
+static int daemon_msg_updatefilter_req(uint8 ver, struct daemon_slpars *pars,
+    struct session *session, uint32 plen);
+static int daemon_unpackapplyfilter(SOCKET sockctrl, struct session *session, uint32 *plenp, char *errbuf);
 
-static int daemon_msg_stats_req(struct daemon_slpars *pars, struct session *session, uint32 plen, struct pcap_stat *stats, unsigned int svrcapt);
+static int daemon_msg_stats_req(uint8 ver, struct daemon_slpars *pars,
+    struct session *session, uint32 plen, struct pcap_stat *stats,
+    unsigned int svrcapt);
 
-static int daemon_msg_setsampling_req(struct daemon_slpars *pars, uint32 plen, struct rpcap_sampling *samp_param);
+static int daemon_msg_setsampling_req(uint8 ver, struct daemon_slpars *pars,
+    uint32 plen, struct rpcap_sampling *samp_param);
 
 static void daemon_seraddr(struct sockaddr_storage *sockaddrin, struct rpcap_sockaddr *sockaddrout);
 #ifdef _WIN32
 static unsigned __stdcall daemon_thrdatamain(void *ptr);
 #else
 static void *daemon_thrdatamain(void *ptr);
+static void noop_handler(int sign);
 #endif
 
 static int rpcapd_recv_msg_header(SOCKET sock, struct rpcap_header *headerp);
 static int rpcapd_recv(SOCKET sock, char *buffer, size_t toread, uint32 *plen, char *errmsgbuf);
 static int rpcapd_discard(SOCKET sock, uint32 len);
+static void session_close(struct session *);
+
+static int is_url(const char *source);
 
 int
-daemon_serviceloop(SOCKET sockctrl_in, SOCKET sockctrl_out, int isactive, int nullAuthAllowed)
+daemon_serviceloop(SOCKET sockctrl, int isactive, char *passiveClients,
+    int nullAuthAllowed)
 {
 	struct daemon_slpars pars;		// service loop parameters
 	char errbuf[PCAP_ERRBUF_SIZE + 1];	// keeps the error string, prior to be printed
 	char errmsgbuf[PCAP_ERRBUF_SIZE + 1];	// buffer for errors to send to the client
+	int host_port_check_status;
 	int nrecv;
 	struct rpcap_header header;		// RPCAP message general header
 	uint32 plen;				// payload length from header
 	int authenticated = 0;			// 1 if the client has successfully authenticated
 	char source[PCAP_BUF_SIZE+1];		// keeps the string that contains the interface to open
 	int got_source = 0;			// 1 if we've gotten the source from an open request
+#ifndef _WIN32
+	struct sigaction action;
+#endif
 	struct session *session = NULL;		// struct session main variable
 	const char *msg_type_string;		// string for message type
 	int client_told_us_to_close = 0;	// 1 if the client told us to close the capture
 
-	struct thread_handle threaddata;	// 'read from daemon and send to client' thread
-
 	// needed to save the values of the statistics
 	struct pcap_stat stats;
 	unsigned int svrcapt;
@@ -163,31 +190,86 @@
 	struct timeval tv;			// maximum time the select() can block waiting for data
 	int retval;				// select() return value
 
+	*errbuf = 0;	// Initialize errbuf
+
 	// Set parameters structure
-	pars.sockctrl_in = sockctrl_in;
-	pars.sockctrl_out = sockctrl_out;
-	pars.protocol_version = 0;		// not yet known
+	pars.sockctrl = sockctrl;
 	pars.isactive = isactive;		// active mode
 	pars.nullAuthAllowed = nullAuthAllowed;
 
-	// We don't have a thread yet.
-	threaddata.have_thread = 0;
 	//
-	// We *shouldn't* have to initialize the thread indicator
-	// itself, because the compiler *should* realize that we
-	// only use this if have_thread isn't 0, but we *do* have
-	// to do it, because not all compilers *do* realize that.
+	// We have a connection.
 	//
-	// There is no "invalid thread handle" value for a UN*X
-	// pthread_t, so we just zero it out.
+	// If it's a passive mode connection, check whether the connecting
+	// host is among the ones allowed.
 	//
-#ifdef _WIN32
-	threaddata.thread = INVALID_HANDLE_VALUE;
-#else
-	memset(&threaddata.thread, 0, sizeof(threaddata.thread));
-#endif
+	// In either case, we were handed a copy of the host list; free it
+	// as soon as we're done with it.
+	//
+	if (pars.isactive)
+	{
+		// Nothing to do.
+		free(passiveClients);
+		passiveClients = NULL;
+	}
+	else
+	{
+		struct sockaddr_storage from;
+		socklen_t fromlen;
 
-	*errbuf = 0;	// Initialize errbuf
+		//
+		// Get the address of the other end of the connection.
+		//
+		fromlen = sizeof(struct sockaddr_storage);
+		if (getpeername(pars.sockctrl, (struct sockaddr *)&from,
+		    &fromlen) == -1)
+		{
+			sock_geterror("getpeername()", errmsgbuf, PCAP_ERRBUF_SIZE);
+			if (rpcap_senderror(pars.sockctrl, 0, PCAP_ERR_NETW, errmsgbuf, errbuf) == -1)
+				rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
+			goto end;
+		}
+
+		//
+		// Are they in the list of host/port combinations we allow?
+		//
+		host_port_check_status = sock_check_hostlist(passiveClients, RPCAP_HOSTLIST_SEP, &from, errmsgbuf, PCAP_ERRBUF_SIZE);
+		free(passiveClients);
+		passiveClients = NULL;
+		if (host_port_check_status < 0)
+		{
+			if (host_port_check_status == -2) {
+				//
+				// We got an error; log it.
+				//
+				rpcapd_log(LOGPRIO_ERROR, "%s", errmsgbuf);
+			}
+
+			//
+			// Sorry, we can't let you in.
+			//
+			if (rpcap_senderror(pars.sockctrl, 0, PCAP_ERR_HOSTNOAUTH, errmsgbuf, errbuf) == -1)
+				rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
+			goto end;
+		}
+	}
+
+#ifndef _WIN32
+	//
+	// Catch SIGUSR1, but do nothing.  We use it to interrupt the
+	// capture thread to break it out of a loop in which it's
+	// blocked waiting for packets to arrive.
+	//
+	// We don't want interrupted system calls to restart, so that
+	// the read routine for the pcap_t gets EINTR rather than
+	// restarting if it's blocked in a system call.
+	//
+	memset(&action, 0, sizeof (action));
+	action.sa_handler = noop_handler;
+	action.sa_flags = 0;
+	sigemptyset(&action.sa_mask);
+	sigaction(SIGUSR1, &action, NULL);
+#endif
 
 	//
 	// The client must first authenticate; loop until they send us a
@@ -198,10 +280,11 @@
 	while (!authenticated)
 	{
 		//
-		// If we're in active mode, we have to check for the
-		// initial timeout.
-		//
-		// XXX - do this on *every* trip through the loop?
+		// If we're not in active mode, we use select(), with a
+		// timeout, to wait for an authentication request; if
+		// the timeout expires, we drop the connection, so that
+		// a client can't just connect to us and leave us
+		// waiting forever.
 		//
 		if (!pars.isactive)
 		{
@@ -210,13 +293,13 @@
 			tv.tv_sec = RPCAP_TIMEOUT_INIT;
 			tv.tv_usec = 0;
 
-			FD_SET(pars.sockctrl_in, &rfds);
+			FD_SET(pars.sockctrl, &rfds);
 
-			retval = select(pars.sockctrl_in + 1, &rfds, NULL, NULL, &tv);
+			retval = select(pars.sockctrl + 1, &rfds, NULL, NULL, &tv);
 			if (retval == -1)
 			{
-				sock_geterror("select failed: ", errmsgbuf, PCAP_ERRBUF_SIZE);
-				if (rpcap_senderror(pars.sockctrl_out, 0, PCAP_ERR_NETW, errmsgbuf, errbuf) == -1)
+				sock_geterror("select() failed", errmsgbuf, PCAP_ERRBUF_SIZE);
+				if (rpcap_senderror(pars.sockctrl, 0, PCAP_ERR_NETW, errmsgbuf, errbuf) == -1)
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 				goto end;
 			}
@@ -225,7 +308,7 @@
 			// So, this was a fake connection. Drop it down
 			if (retval == 0)
 			{
-				if (rpcap_senderror(pars.sockctrl_out, 0, PCAP_ERR_INITTIMEOUT, "The RPCAP initial timeout has expired", errbuf) == -1)
+				if (rpcap_senderror(pars.sockctrl, 0, PCAP_ERR_INITTIMEOUT, "The RPCAP initial timeout has expired", errbuf) == -1)
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 				goto end;
 			}
@@ -234,7 +317,7 @@
 		//
 		// Read the message header from the client.
 		//
-		nrecv = rpcapd_recv_msg_header(pars.sockctrl_in, &header);
+		nrecv = rpcapd_recv_msg_header(pars.sockctrl, &header);
 		if (nrecv == -1)
 		{
 			// Fatal error.
@@ -249,49 +332,17 @@
 		plen = header.plen;
 
 		//
-		// Did the client specify a version we can handle?
+		// While we're in the authentication pharse, all requests
+		// must use version 0.
 		//
-		if (!RPCAP_VERSION_IS_SUPPORTED(header.ver))
+		if (header.ver != 0)
 		{
 			//
-			// Tell them it's not a valid protocol version.
+			// Send it back to them with their version.
 			//
-			uint8 reply_version;
-
-			//
-			// If RPCAP_MIN_VERSION is 0, no version is too
-			// old, as the oldest supported version is 0,
-			// and there are no negative versions.
-			//
-#if RPCAP_MIN_VERSION != 0
-			if (header.ver < RPCAP_MIN_VERSION)
-			{
-				//
-				// Their maximum version is too old;
-				// there *is* no version we can both
-				// handle, and they might reject
-				// an error with a version they don't
-				// understand, so reply with the
-				// version they sent.  That may
-				// make them retry with that version,
-				// but they'll give up on that
-				// failure.
-				//
-				reply_version = header.ver;
-			}
-			else
-#endif
-			{
-				//
-				// Their maximum version is too new,
-				// but they might be able to handle
-				// *our* maximum version, so reply
-				// with that version.
-				//
-				reply_version = RPCAP_MAX_VERSION;
-			}
-			if (rpcap_senderror(pars.sockctrl_out, reply_version,
-			    PCAP_ERR_WRONGVER, "RPCAP version number mismatch",
+			if (rpcap_senderror(pars.sockctrl, header.ver,
+			    PCAP_ERR_WRONGVER,
+			    "RPCAP version in requests in the authentication phase must be 0",
 			    errbuf) == -1)
 			{
 				// That failed; log a message and give up.
@@ -299,22 +350,12 @@
 				goto end;
 			}
 
-			// Discard the rest of the message.
-			if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
-			{
-				// Network error.
-				goto end;
-			}
-
-			// Let them try again.
-			continue;
+			// Discard the rest of the message and drop the
+			// connection.
+			(void)rpcapd_discard(pars.sockctrl, plen);
+			goto end;
 		}
 
-		//
-		// OK, we use the version the client specified.
-		//
-		pars.protocol_version = header.ver;
-
 		switch (header.type)
 		{
 			case RPCAP_MSG_AUTH_REQ:
@@ -344,7 +385,7 @@
 				// Discard the rest of the message, if
 				// there is anything more.
 				//
-				(void)rpcapd_discard(pars.sockctrl_in, plen);
+				(void)rpcapd_discard(pars.sockctrl, plen);
 				// We're done with this client.
 				goto end;
 
@@ -356,7 +397,7 @@
 				// an error message rather than a "let
 				// me log in" message, indicating that
 				// we're not allowed to connect to them?
-				(void)daemon_msg_err(pars.sockctrl_in, plen);
+				(void)daemon_msg_err(pars.sockctrl, plen);
 				goto end;
 
 			case RPCAP_MSG_FINDALLIF_REQ:
@@ -379,15 +420,14 @@
 				{
 					pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Message of type %u sent before authentication was completed", header.type);
 				}
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version, PCAP_ERR_WRONGMSG,
-				    errmsgbuf, errbuf) == -1)
+				if (rpcap_senderror(pars.sockctrl, header.ver,
+				    PCAP_ERR_WRONGMSG, errmsgbuf, errbuf) == -1)
 				{
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 					goto end;
 				}
 				// Discard the rest of the message.
-				if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
+				if (rpcapd_discard(pars.sockctrl, plen) == -1)
 				{
 					// Network error.
 					goto end;
@@ -415,15 +455,14 @@
 				{
 					pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Server-to-client message of type %u received from client", header.type);
 				}
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version, PCAP_ERR_WRONGMSG,
-				    errmsgbuf, errbuf) == -1)
+				if (rpcap_senderror(pars.sockctrl, header.ver,
+				    PCAP_ERR_WRONGMSG, errmsgbuf, errbuf) == -1)
 				{
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 					goto end;
 				}
 				// Discard the rest of the message.
-				if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
+				if (rpcapd_discard(pars.sockctrl, plen) == -1)
 				{
 					// Fatal error.
 					goto end;
@@ -435,15 +474,14 @@
 				// Unknown message type.
 				//
 				pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Unknown message type %u", header.type);
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version, PCAP_ERR_WRONGMSG,
-				    errmsgbuf, errbuf) == -1)
+				if (rpcap_senderror(pars.sockctrl, header.ver,
+				    PCAP_ERR_WRONGMSG, errmsgbuf, errbuf) == -1)
 				{
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 					goto end;
 				}
 				// Discard the rest of the message.
-				if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
+				if (rpcapd_discard(pars.sockctrl, plen) == -1)
 				{
 					// Fatal error.
 					goto end;
@@ -489,15 +527,14 @@
 			tv.tv_sec = RPCAP_TIMEOUT_RUNTIME;
 			tv.tv_usec = 0;
 
-			FD_SET(pars.sockctrl_in, &rfds);
+			FD_SET(pars.sockctrl, &rfds);
 
-			retval = select(pars.sockctrl_in + 1, &rfds, NULL, NULL, &tv);
+			retval = select(pars.sockctrl + 1, &rfds, NULL, NULL, &tv);
 			if (retval == -1)
 			{
-				sock_geterror("select failed: ", errmsgbuf, PCAP_ERRBUF_SIZE);
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version, PCAP_ERR_NETW,
-				    errmsgbuf, errbuf) == -1)
+				sock_geterror("select() failed", errmsgbuf, PCAP_ERRBUF_SIZE);
+				if (rpcap_senderror(pars.sockctrl, 0,
+				    PCAP_ERR_NETW, errmsgbuf, errbuf) == -1)
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 				goto end;
 			}
@@ -506,8 +543,7 @@
 			// So, this was a fake connection. Drop it down
 			if (retval == 0)
 			{
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version,
+				if (rpcap_senderror(pars.sockctrl, 0,
 				    PCAP_ERR_INITTIMEOUT,
 				    "The RPCAP initial timeout has expired",
 				    errbuf) == -1)
@@ -519,7 +555,7 @@
 		//
 		// Read the message header from the client.
 		//
-		nrecv = rpcapd_recv_msg_header(pars.sockctrl_in, &header);
+		nrecv = rpcapd_recv_msg_header(pars.sockctrl, &header);
 		if (nrecv == -1)
 		{
 			// Fatal error.
@@ -534,21 +570,20 @@
 		plen = header.plen;
 
 		//
-		// Did the client specify the version we negotiated?
+		// Did the client specify a protocol version that we
+		// support?
 		//
-		// For now, there's only one version.
-		//
-		if (header.ver != pars.protocol_version)
+		if (!RPCAP_VERSION_IS_SUPPORTED(header.ver))
 		{
 			//
-			// Tell them it's not the negotiated version.
+			// Tell them it's not a supported version.
 			// Send the error message with their version,
 			// so they don't reject it as having the wrong
 			// version.
 			//
-			if (rpcap_senderror(pars.sockctrl_out,
+			if (rpcap_senderror(pars.sockctrl,
 			    header.ver, PCAP_ERR_WRONGVER,
-			    "RPCAP version in message isn't the negotiated version",
+			    "RPCAP version in message isn't supported by the server",
 			    errbuf) == -1)
 			{
 				// That failed; log a message and give up.
@@ -557,7 +592,7 @@
 			}
 
 			// Discard the rest of the message.
-			(void)rpcapd_discard(pars.sockctrl_in, plen);
+			(void)rpcapd_discard(pars.sockctrl, plen);
 			// Give up on them.
 			goto end;
 		}
@@ -566,7 +601,7 @@
 		{
 			case RPCAP_MSG_ERROR:		// The other endpoint reported an error
 			{
-				(void)daemon_msg_err(pars.sockctrl_in, plen);
+				(void)daemon_msg_err(pars.sockctrl, plen);
 				// Do nothing; just exit; the error code is already into the errbuf
 				// XXX - actually exit....
 				break;
@@ -574,7 +609,7 @@
 
 			case RPCAP_MSG_FINDALLIF_REQ:
 			{
-				if (daemon_msg_findallif_req(&pars, plen) == -1)
+				if (daemon_msg_findallif_req(header.ver, &pars, plen) == -1)
 				{
 					// Fatal error; a message has
 					// been logged, so just give up.
@@ -594,7 +629,8 @@
 				// us multiple open requests, the last
 				// one wins.
 				//
-				retval = daemon_msg_open_req(&pars, plen, source, sizeof(source));
+				retval = daemon_msg_open_req(header.ver, &pars,
+				    plen, source, sizeof(source));
 				if (retval == -1)
 				{
 					// Fatal error; a message has
@@ -611,8 +647,8 @@
 				{
 					// They never told us what device
 					// to capture on!
-					if (rpcap_senderror(pars.sockctrl_out,
-					    pars.protocol_version,
+					if (rpcap_senderror(pars.sockctrl,
+					    header.ver,
 					    PCAP_ERR_STARTCAPTURE,
 					    "No capture device was specified",
 					    errbuf) == -1)
@@ -622,14 +658,15 @@
 						rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 						goto end;
 					}
-					if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
+					if (rpcapd_discard(pars.sockctrl, plen) == -1)
 					{
 						goto end;
 					}
 					break;
 				}
 
-				if (daemon_msg_startcap_req(&pars, plen, &threaddata, source, &session, &samp_param) == -1)
+				if (daemon_msg_startcap_req(header.ver, &pars,
+				    plen, source, &session, &samp_param) == -1)
 				{
 					// Fatal error; a message has
 					// been logged, so just give up.
@@ -642,7 +679,8 @@
 			{
 				if (session)
 				{
-					if (daemon_msg_updatefilter_req(&pars, session, plen) == -1)
+					if (daemon_msg_updatefilter_req(header.ver,
+					    &pars, session, plen) == -1)
 					{
 						// Fatal error; a message has
 						// been logged, so just give up.
@@ -651,9 +689,8 @@
 				}
 				else
 				{
-					if (rpcap_senderror(pars.sockctrl_out,
-					    pars.protocol_version,
-					    PCAP_ERR_UPDATEFILTER,
+					if (rpcap_senderror(pars.sockctrl,
+					    header.ver, PCAP_ERR_UPDATEFILTER,
 					    "Device not opened. Cannot update filter",
 					    errbuf) == -1)
 					{
@@ -673,13 +710,14 @@
 				// This is used only in case of active mode.
 				//
 				client_told_us_to_close = 1;
-				SOCK_DEBUG_MESSAGE("The other end system asked to close the connection.");
+				rpcapd_log(LOGPRIO_DEBUG, "The other end system asked to close the connection.");
 				goto end;
 			}
 
 			case RPCAP_MSG_STATS_REQ:
 			{
-				if (daemon_msg_stats_req(&pars, session, plen, &stats, svrcapt) == -1)
+				if (daemon_msg_stats_req(header.ver, &pars,
+				    session, plen, &stats, svrcapt) == -1)
 				{
 					// Fatal error; a message has
 					// been logged, so just give up.
@@ -705,7 +743,8 @@
 						svrcapt = 0;
 					}
 
-					if (daemon_msg_endcap_req(&pars, session, &threaddata) == -1)
+					if (daemon_msg_endcap_req(header.ver,
+					    &pars, session) == -1)
 					{
 						free(session);
 						session = NULL;
@@ -718,9 +757,8 @@
 				}
 				else
 				{
-					rpcap_senderror(pars.sockctrl_out,
-					    pars.protocol_version,
-					    PCAP_ERR_ENDCAPTURE,
+					rpcap_senderror(pars.sockctrl,
+					    header.ver, PCAP_ERR_ENDCAPTURE,
 					    "Device not opened. Cannot close the capture",
 					    errbuf);
 				}
@@ -729,7 +767,8 @@
 
 			case RPCAP_MSG_SETSAMPLING_REQ:
 			{
-				if (daemon_msg_setsampling_req(&pars, plen, &samp_param) == -1)
+				if (daemon_msg_setsampling_req(header.ver,
+				    &pars, plen, &samp_param) == -1)
 				{
 					// Fatal error; a message has
 					// been logged, so just give up.
@@ -745,8 +784,7 @@
 				// get to reauthenticate.
 				//
 				rpcapd_log(LOGPRIO_INFO, "The client sent an RPCAP_MSG_AUTH_REQ message after authentication was completed");
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version,
+				if (rpcap_senderror(pars.sockctrl, header.ver,
 				    PCAP_ERR_WRONGMSG,
 				    "RPCAP_MSG_AUTH_REQ request sent after authentication was completed",
 				    errbuf) == -1)
@@ -755,7 +793,7 @@
 					goto end;
 				}
 				// Discard the rest of the message.
-				if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
+				if (rpcapd_discard(pars.sockctrl, plen) == -1)
 				{
 					// Fatal error.
 					goto end;
@@ -785,15 +823,14 @@
 					rpcapd_log(LOGPRIO_INFO, "The client sent a server-to-client message of type %u", header.type);
 					pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Server-to-client message of type %u received from client", header.type);
 				}
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version, PCAP_ERR_WRONGMSG,
-				    errmsgbuf, errbuf) == -1)
+				if (rpcap_senderror(pars.sockctrl, header.ver,
+				    PCAP_ERR_WRONGMSG, errmsgbuf, errbuf) == -1)
 				{
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 					goto end;
 				}
 				// Discard the rest of the message.
-				if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
+				if (rpcapd_discard(pars.sockctrl, plen) == -1)
 				{
 					// Fatal error.
 					goto end;
@@ -806,15 +843,14 @@
 				//
 				rpcapd_log(LOGPRIO_INFO, "The client sent a message of type %u", header.type);
 				pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Unknown message type %u", header.type);
-				if (rpcap_senderror(pars.sockctrl_out,
-				    pars.protocol_version, PCAP_ERR_WRONGMSG,
-				    errbuf, errmsgbuf) == -1)
+				if (rpcap_senderror(pars.sockctrl, header.ver,
+				    PCAP_ERR_WRONGMSG, errbuf, errmsgbuf) == -1)
 				{
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 					goto end;
 				}
 				// Discard the rest of the message.
-				if (rpcapd_discard(pars.sockctrl_in, plen) == -1)
+				if (rpcapd_discard(pars.sockctrl, plen) == -1)
 				{
 					// Fatal error.
 					goto end;
@@ -825,58 +861,19 @@
 	}
 
 end:
-	// The child thread is about to end
-
-	// perform pcap_t cleanup, in case it has not been done
+	// The service loop is finishing up.
+	// If we have a capture session running, close it.
 	if (session)
 	{
-		if (threaddata.have_thread)
-		{
-#ifdef _WIN32
-			//
-			// Tell the data connection thread main capture
-			// loop to break out of that loop.
-			//
-			pcap_breakloop(session->fp);
-
-			//
-			// If it's currently blocked waiting for packets
-			// to arrive, try to wake it up, so it can see
-			// the "break out of the loop" indication.
-			//
-			SetEvent(pcap_getevent(session->fp));
-
-			//
-			// Wait for the thread to exit, so we don't close
-			// sockets out from under it.
-			//
-			// XXX - have a timeout, so we don't wait forever?
-			//
-			WaitForSingleObject(threaddata.thread, INFINITE);
-
-			//
-			// Release the thread handle, as we're done with
-			// it.
-			//
-			CloseHandle(threaddata.thread);
-#else
-			pthread_cancel(threaddata.thread);
-#endif
-			threaddata.have_thread = 0;
-		}
-		if (session->sockdata)
-		{
-			sock_close(session->sockdata, NULL, 0);
-			session->sockdata = 0;
-		}
-		pcap_close(session->fp);
+		session_close(session);
 		free(session);
 		session = NULL;
 	}
 
+	sock_close(sockctrl, NULL, 0);
+
 	// Print message and return
-	SOCK_DEBUG_MESSAGE("I'm exiting from the child loop");
-	SOCK_DEBUG_MESSAGE(errbuf);
+	rpcapd_log(LOGPRIO_DEBUG, "I'm exiting from the child loop");
 
 	return client_told_us_to_close;
 }
@@ -885,7 +882,7 @@
  * This handles the RPCAP_MSG_ERR message.
  */
 static int
-daemon_msg_err(SOCKET sockctrl_in, uint32 plen)
+daemon_msg_err(SOCKET sockctrl, uint32 plen)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];
 	char remote_errbuf[PCAP_ERRBUF_SIZE];
@@ -896,7 +893,7 @@
 		 * Message is too long; just read as much of it as we
 		 * can into the buffer provided, and discard the rest.
 		 */
-		if (sock_recv(sockctrl_in, remote_errbuf, PCAP_ERRBUF_SIZE - 1,
+		if (sock_recv(sockctrl, remote_errbuf, PCAP_ERRBUF_SIZE - 1,
 		    SOCK_RECEIVEALL_YES|SOCK_EOF_IS_ERROR, errbuf,
 		    PCAP_ERRBUF_SIZE) == -1)
 		{
@@ -904,7 +901,7 @@
 			rpcapd_log(LOGPRIO_ERROR, "Read from client failed: %s", errbuf);
 			return -1;
 		}
-		if (rpcapd_discard(sockctrl_in, plen - (PCAP_ERRBUF_SIZE - 1)) == -1)
+		if (rpcapd_discard(sockctrl, plen - (PCAP_ERRBUF_SIZE - 1)) == -1)
 		{
 			// Network error.
 			return -1;
@@ -922,7 +919,7 @@
 	}
 	else
 	{
-		if (sock_recv(sockctrl_in, remote_errbuf, plen,
+		if (sock_recv(sockctrl, remote_errbuf, plen,
 		    SOCK_RECEIVEALL_YES|SOCK_EOF_IS_ERROR, errbuf,
 		    PCAP_ERRBUF_SIZE) == -1)
 		{
@@ -968,11 +965,13 @@
 {
 	char errbuf[PCAP_ERRBUF_SIZE];		// buffer for network errors
 	char errmsgbuf[PCAP_ERRBUF_SIZE];	// buffer for errors to send to the client
-	struct rpcap_header header;		// RPCAP message general header
 	int status;
 	struct rpcap_auth auth;			// RPCAP authentication header
+	char sendbuf[RPCAP_NETBUF_SIZE];	// temporary buffer in which data to be sent is buffered
+	int sendbufidx = 0;			// index which keeps the number of bytes currently buffered
+	struct rpcap_authreply *authreply;	// authentication reply message
 
-	status = rpcapd_recv(pars->sockctrl_in, (char *) &auth, sizeof(struct rpcap_auth), &plen, errmsgbuf);
+	status = rpcapd_recv(pars->sockctrl, (char *) &auth, sizeof(struct rpcap_auth), &plen, errmsgbuf);
 	if (status == -1)
 	{
 		return -1;
@@ -989,8 +988,16 @@
 			if (!pars->nullAuthAllowed)
 			{
 				// Send the client an error reply.
-				pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Authentication failed; NULL authentication not permitted.");
-				goto error;
+				pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE,
+				    "Authentication failed; NULL authentication not permitted.");
+				if (rpcap_senderror(pars->sockctrl, 0,
+				    PCAP_ERR_AUTH_FAILED, errmsgbuf, errbuf) == -1)
+				{
+					// That failed; log a message and give up.
+					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
+					return -1;
+				}
+				goto error_noreply;
 			}
 			break;
 		}
@@ -1008,7 +1015,7 @@
 				    PCAP_ERRBUF_SIZE, errno, "malloc() failed");
 				goto error;
 			}
-			status = rpcapd_recv(pars->sockctrl_in, username, usernamelen, &plen, errmsgbuf);
+			status = rpcapd_recv(pars->sockctrl, username, usernamelen, &plen, errmsgbuf);
 			if (status == -1)
 			{
 				free(username);
@@ -1030,7 +1037,7 @@
 				free(username);
 				goto error;
 			}
-			status = rpcapd_recv(pars->sockctrl_in, passwd, passwdlen, &plen, errmsgbuf);
+			status = rpcapd_recv(pars->sockctrl, passwd, passwdlen, &plen, errmsgbuf);
 			if (status == -1)
 			{
 				free(username);
@@ -1053,9 +1060,8 @@
 				//
 				free(username);
 				free(passwd);
-				if (rpcap_senderror(pars->sockctrl_out,
-				    pars->protocol_version,
-				    PCAP_ERR_AUTH, errmsgbuf, errbuf) == -1)
+				if (rpcap_senderror(pars->sockctrl, 0,
+				    PCAP_ERR_AUTH_FAILED, errmsgbuf, errbuf) == -1)
 				{
 					// That failed; log a message and give up.
 					rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -1082,15 +1088,41 @@
 			}
 
 		default:
-			pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Authentication type not recognized.");
-			goto error;
+			pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE,
+			    "Authentication type not recognized.");
+			if (rpcap_senderror(pars->sockctrl, 0,
+			    PCAP_ERR_AUTH_TYPE_NOTSUP, errmsgbuf, errbuf) == -1)
+			{
+				// That failed; log a message and give up.
+				rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
+				return -1;
+			}
+			goto error_noreply;
 	}
 
 	// The authentication succeeded; let the client know.
-	rpcap_createhdr(&header, pars->protocol_version, RPCAP_MSG_AUTH_REPLY, 0, 0);
+	if (sock_bufferize(NULL, sizeof(struct rpcap_header), NULL, &sendbufidx,
+	    RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
+		goto error;
 
-	// Send the ok message back
-	if (sock_send(pars->sockctrl_out, (char *) &header, sizeof (struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE) == -1)
+	rpcap_createhdr((struct rpcap_header *) sendbuf, 0,
+	    RPCAP_MSG_AUTH_REPLY, 0, sizeof(struct rpcap_authreply));
+
+	authreply = (struct rpcap_authreply *) &sendbuf[sendbufidx];
+
+	if (sock_bufferize(NULL, sizeof(struct rpcap_authreply), NULL, &sendbufidx,
+	    RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
+		goto error;
+
+	//
+	// Indicate to our peer what versions we support.
+	//
+	memset(authreply, 0, sizeof(struct rpcap_authreply));
+	authreply->minvers = RPCAP_MIN_VERSION;
+	authreply->maxvers = RPCAP_MAX_VERSION;
+
+	// Send the reply.
+	if (sock_send(pars->sockctrl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
 		// That failed; log a messsage and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -1098,7 +1130,7 @@
 	}
 
 	// Check if all the data has been read; if not, discard the data in excess
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		return -1;
 	}
@@ -1106,8 +1138,8 @@
 	return 0;
 
 error:
-	if (rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-	    PCAP_ERR_AUTH, errmsgbuf, errbuf) == -1)
+	if (rpcap_senderror(pars->sockctrl, 0, PCAP_ERR_AUTH, errmsgbuf,
+	    errbuf) == -1)
 	{
 		// That failed; log a message and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -1116,7 +1148,7 @@
 
 error_noreply:
 	// Check if all the data has been read; if not, discard the data in excess
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		return -1;
 	}
@@ -1136,16 +1168,32 @@
 	 * policies, user right assignment)
 	 * However, it seems to me that if you run it as a service, this
 	 * right should be provided by default.
+	 *
+	 * XXX - hopefully, this returns errors such as ERROR_LOGON_FAILURE,
+	 * which merely indicates that the user name or password is
+	 * incorrect, not whether it's the user name or the password
+	 * that's incorrect, so a client that's trying to brute-force
+	 * accounts doesn't know whether it's the user name or the
+	 * password that's incorrect, so it doesn't know whether to
+	 * stop trying to log in with a given user name and move on
+	 * to another user name.
 	 */
+	DWORD error;
 	HANDLE Token;
+	char errmsgbuf[PCAP_ERRBUF_SIZE];	// buffer for errors to log
+
 	if (LogonUser(username, ".", password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &Token) == 0)
 	{
-		int error;
-
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed");
 		error = GetLastError();
-		FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, errbuf,
-			PCAP_ERRBUF_SIZE, NULL);
-
+		if (error != ERROR_LOGON_FAILURE)
+		{
+			// Some error other than an authentication error;
+			// log it.
+			pcap_fmt_errmsg_for_win32_err(errmsgbuf,
+			    PCAP_ERRBUF_SIZE, error, "LogonUser() failed");
+			rpcapd_log(LOGPRIO_ERROR, "%s", errmsgbuf);
+		}
 		return -1;
 	}
 
@@ -1153,12 +1201,10 @@
 	// I didn't test it.
 	if (ImpersonateLoggedOnUser(Token) == 0)
 	{
-		int error;
-
-		error = GetLastError();
-		FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, errbuf,
-			PCAP_ERRBUF_SIZE, NULL);
-
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed");
+		pcap_fmt_errmsg_for_win32_err(errmsgbuf, PCAP_ERRBUF_SIZE,
+		    GetLastError(), "ImpersonateLoggedOnUser() failed");
+		rpcapd_log(LOGPRIO_ERROR, "%s", errmsgbuf);
 		CloseHandle(Token);
 		return -1;
 	}
@@ -1186,16 +1232,18 @@
 	 * only password database or some other authentication mechanism,
 	 * behind its API.
 	 */
+	int error;
 	struct passwd *user;
 	char *user_password;
 #ifdef HAVE_GETSPNAM
 	struct spwd *usersp;
 #endif
+	char *crypt_password;
 
 	// This call is needed to get the uid
 	if ((user = getpwnam(username)) == NULL)
 	{
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed: no such user");
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed");
 		return -1;
 	}
 
@@ -1203,7 +1251,7 @@
 	// This call is needed to get the password; otherwise 'x' is returned
 	if ((usersp = getspnam(username)) == NULL)
 	{
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed: no such user");
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed");
 		return -1;
 	}
 	user_password = usersp->sp_pwdp;
@@ -1221,23 +1269,52 @@
 	user_password = user->pw_passwd;
 #endif
 
-	if (strcmp(user_password, (char *) crypt(password, user_password)) != 0)
+	//
+	// The Single UNIX Specification says that if crypt() fails it
+	// sets errno, but some implementatons that haven't been run
+	// through the SUS test suite might not do so.
+	//
+	errno = 0;
+	crypt_password = crypt(password, user_password);
+	if (crypt_password == NULL)
 	{
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed: password incorrect");
+		error = errno;
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed");
+		if (error == 0)
+		{
+			// It didn't set errno.
+			rpcapd_log(LOGPRIO_ERROR, "crypt() failed");
+		}
+		else
+		{
+			rpcapd_log(LOGPRIO_ERROR, "crypt() failed: %s",
+			    strerror(error));
+		}
+		return -1;
+	}
+	if (strcmp(user_password, crypt_password) != 0)
+	{
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Authentication failed");
 		return -1;
 	}
 
 	if (setuid(user->pw_uid))
 	{
+		error = errno;
 		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
-		    errno, "setuid");
+		    error, "setuid");
+		rpcapd_log(LOGPRIO_ERROR, "setuid() failed: %s",
+		    strerror(error));
 		return -1;
 	}
 
 /*	if (setgid(user->pw_gid))
 	{
+		error = errno;
 		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "setgid");
+		rpcapd_log(LOGPRIO_ERROR, "setgid() failed: %s",
+		    strerror(error));
 		return -1;
 	}
 */
@@ -1248,7 +1325,7 @@
 }
 
 static int
-daemon_msg_findallif_req(struct daemon_slpars *pars, uint32 plen)
+daemon_msg_findallif_req(uint8 ver, struct daemon_slpars *pars, uint32 plen)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];		// buffer for network errors
 	char errmsgbuf[PCAP_ERRBUF_SIZE];	// buffer for errors to send to the client
@@ -1258,10 +1335,11 @@
 	pcap_if_t *d;				// temp pointer needed to scan the interface chain
 	struct pcap_addr *address;		// pcap structure that keeps a network address of an interface
 	struct rpcap_findalldevs_if *findalldevs_if;// rpcap structure that packet all the data of an interface together
+	uint32 replylen;			// length of reply payload
 	uint16 nif = 0;				// counts the number of interface listed
 
 	// Discard the rest of the message; there shouldn't be any payload.
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		// Network error.
 		return -1;
@@ -1273,8 +1351,7 @@
 
 	if (alldevs == NULL)
 	{
-		if (rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-			PCAP_ERR_NOREMOTEIF,
+		if (rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_NOREMOTEIF,
 			"No interfaces found! Make sure libpcap/WinPcap is properly installed"
 			" and you have the right to access to the remote device.",
 			errbuf) == -1)
@@ -1285,17 +1362,19 @@
 		return 0;
 	}
 
-	// checks the number of interfaces and it computes the total length of the payload
+	// This checks the number of interfaces and computes the total
+	// length of the payload.
+	replylen = 0;
 	for (d = alldevs; d != NULL; d = d->next)
 	{
 		nif++;
 
 		if (d->description)
-			plen+= strlen(d->description);
+			replylen += strlen(d->description);
 		if (d->name)
-			plen+= strlen(d->name);
+			replylen += strlen(d->name);
 
-		plen+= sizeof(struct rpcap_findalldevs_if);
+		replylen += sizeof(struct rpcap_findalldevs_if);
 
 		for (address = d->addresses; address != NULL; address = address->next)
 		{
@@ -1308,7 +1387,7 @@
 #ifdef AF_INET6
 			case AF_INET6:
 #endif
-				plen+= (sizeof(struct rpcap_sockaddr) * 4);
+				replylen += (sizeof(struct rpcap_sockaddr) * 4);
 				break;
 
 			default:
@@ -1323,8 +1402,8 @@
 	    PCAP_ERRBUF_SIZE) == -1)
 		goto error;
 
-	rpcap_createhdr((struct rpcap_header *) sendbuf, pars->protocol_version,
-	    RPCAP_MSG_FINDALLIF_REPLY, nif, plen);
+	rpcap_createhdr((struct rpcap_header *) sendbuf, ver,
+	    RPCAP_MSG_FINDALLIF_REPLY, nif, replylen);
 
 	// send the interface list
 	for (d = alldevs; d != NULL; d = d->next)
@@ -1427,7 +1506,7 @@
 	pcap_freealldevs(alldevs);
 
 	// Send a final command that says "now send it!"
-	if (sock_send(pars->sockctrl_out, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
+	if (sock_send(pars->sockctrl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 		return -1;
@@ -1439,8 +1518,8 @@
 	if (alldevs)
 		pcap_freealldevs(alldevs);
 
-	if (rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-	    PCAP_ERR_FINDALLIF, errmsgbuf, errbuf) == -1)
+	if (rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_FINDALLIF,
+	    errmsgbuf, errbuf) == -1)
 	{
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 		return -1;
@@ -1453,7 +1532,8 @@
 	to discard excess data in the message, if present)
 */
 static int
-daemon_msg_open_req(struct daemon_slpars *pars, uint32 plen, char *source, size_t sourcelen)
+daemon_msg_open_req(uint8 ver, struct daemon_slpars *pars, uint32 plen,
+    char *source, size_t sourcelen)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];		// buffer for network errors
 	char errmsgbuf[PCAP_ERRBUF_SIZE];	// buffer for errors to send to the client
@@ -1469,7 +1549,7 @@
 		goto error;
 	}
 
-	nread = sock_recv(pars->sockctrl_in, source, plen,
+	nread = sock_recv(pars->sockctrl, source, plen,
 	    SOCK_RECEIVEALL_YES|SOCK_EOF_IS_ERROR, errbuf, PCAP_ERRBUF_SIZE);
 	if (nread == -1)
 	{
@@ -1479,8 +1559,13 @@
 	source[nread] = '\0';
 	plen -= nread;
 
-	// XXX - make sure it's *not* a URL; we don't support opening
-	// remote devices here.
+	// Is this a URL rather than a device?
+	// If so, reject it.
+	if (is_url(source))
+	{
+		pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE, "Source string refers to a remote device");
+		goto error;
+	}
 
 	// Open the selected device
 	// This is a fake open, since we do that only to get the needed parameters, then we close the device again
@@ -1496,7 +1581,7 @@
 	    RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
 		goto error;
 
-	rpcap_createhdr((struct rpcap_header *) sendbuf, pars->protocol_version,
+	rpcap_createhdr((struct rpcap_header *) sendbuf, ver,
 	    RPCAP_MSG_OPEN_REPLY, 0, sizeof(struct rpcap_openreply));
 
 	openreply = (struct rpcap_openreply *) &sendbuf[sendbufidx];
@@ -1513,7 +1598,7 @@
 	pcap_close(fp);
 
 	// Send the reply.
-	if (sock_send(pars->sockctrl_out, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
+	if (sock_send(pars->sockctrl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 		return -1;
@@ -1521,8 +1606,8 @@
 	return 0;
 
 error:
-	if (rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-	    PCAP_ERR_OPEN, errmsgbuf, errbuf) == -1)
+	if (rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_OPEN,
+	    errmsgbuf, errbuf) == -1)
 	{
 		// That failed; log a message and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -1530,7 +1615,7 @@
 	}
 
 	// Check if all the data has been read; if not, discard the data in excess
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		return -1;
 	}
@@ -1542,7 +1627,9 @@
 	to discard excess data in the message, if present)
 */
 static int
-daemon_msg_startcap_req(struct daemon_slpars *pars, uint32 plen, struct thread_handle *threaddata, char *source, struct session **sessionp, struct rpcap_sampling *samp_param _U_)
+daemon_msg_startcap_req(uint8 ver, struct daemon_slpars *pars, uint32 plen,
+    char *source, struct session **sessionp,
+    struct rpcap_sampling *samp_param _U_)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];		// buffer for network errors
 	char errmsgbuf[PCAP_ERRBUF_SIZE];	// buffer for errors to send to the client
@@ -1554,17 +1641,12 @@
 	int sendbufidx = 0;			// index which keeps the number of bytes currently buffered
 
 	// socket-related variables
-	SOCKET sockdata = INVALID_SOCKET;	// socket descriptor of the data connection
 	struct addrinfo hints;			// temp, needed to open a socket connection
 	struct addrinfo *addrinfo;		// temp, needed to open a socket connection
 	struct sockaddr_storage saddr;		// temp, needed to retrieve the network data port chosen on the local machine
 	socklen_t saddrlen;			// temp, needed to retrieve the network data port chosen on the local machine
 	int ret;				// return value from functions
 
-#ifndef _WIN32
-	pthread_attr_t detachedAttribute;	// temp, needed to set the created thread as detached
-#endif
-
 	// RPCAP-related variables
 	struct rpcap_startcapreq startcapreq;		// start capture request message
 	struct rpcap_startcapreply *startcapreply;	// start capture reply message
@@ -1572,7 +1654,7 @@
 
 	addrinfo = NULL;
 
-	status = rpcapd_recv(pars->sockctrl_in, (char *) &startcapreq,
+	status = rpcapd_recv(pars->sockctrl, (char *) &startcapreq,
 	    sizeof(struct rpcap_startcapreq), &plen, errmsgbuf);
 	if (status == -1)
 	{
@@ -1593,6 +1675,24 @@
 		goto error;
 	}
 
+	session->sockdata = INVALID_SOCKET;
+	// We don't have a thread yet.
+	session->have_thread = 0;
+	//
+	// We *shouldn't* have to initialize the thread indicator
+	// itself, because the compiler *should* realize that we
+	// only use this if have_thread isn't 0, but we *do* have
+	// to do it, because not all compilers *do* realize that.
+	//
+	// There is no "invalid thread handle" value for a UN*X
+	// pthread_t, so we just zero it out.
+	//
+#ifdef _WIN32
+	session->thread = INVALID_HANDLE_VALUE;
+#else
+	memset(&session->thread, 0, sizeof(session->thread));
+#endif
+
 	// Open the selected device
 	if ((session->fp = pcap_open_live(source,
 			ntohl(startcapreq.snaplen),
@@ -1624,9 +1724,9 @@
 	we want to connect to
 	*/
 	saddrlen = sizeof(struct sockaddr_storage);
-	if (getpeername(pars->sockctrl_in, (struct sockaddr *) &saddr, &saddrlen) == -1)
+	if (getpeername(pars->sockctrl, (struct sockaddr *) &saddr, &saddrlen) == -1)
 	{
-		sock_geterror("getpeername(): ", errmsgbuf, PCAP_ERRBUF_SIZE);
+		sock_geterror("getpeername()", errmsgbuf, PCAP_ERRBUF_SIZE);
 		goto error;
 	}
 
@@ -1643,14 +1743,14 @@
 		if (getnameinfo((struct sockaddr *) &saddr, saddrlen, peerhost,
 				sizeof(peerhost), NULL, 0, NI_NUMERICHOST))
 		{
-			sock_geterror("getnameinfo(): ", errmsgbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getnameinfo()", errmsgbuf, PCAP_ERRBUF_SIZE);
 			goto error;
 		}
 
 		if (sock_initaddress(peerhost, portdata, &hints, &addrinfo, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
 			goto error;
 
-		if ((sockdata = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errmsgbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
+		if ((session->sockdata = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errmsgbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
 			goto error;
 	}
 	else		// Data connection is opened by the client toward the server
@@ -1661,14 +1761,14 @@
 		if (sock_initaddress(NULL, "0", &hints, &addrinfo, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
 			goto error;
 
-		if ((sockdata = sock_open(addrinfo, SOCKOPEN_SERVER, 1 /* max 1 connection in queue */, errmsgbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
+		if ((session->sockdata = sock_open(addrinfo, SOCKOPEN_SERVER, 1 /* max 1 connection in queue */, errmsgbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
 			goto error;
 
 		// get the complete sockaddr structure used in the data connection
 		saddrlen = sizeof(struct sockaddr_storage);
-		if (getsockname(sockdata, (struct sockaddr *) &saddr, &saddrlen) == -1)
+		if (getsockname(session->sockdata, (struct sockaddr *) &saddr, &saddrlen) == -1)
 		{
-			sock_geterror("getsockname(): ", errmsgbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getsockname()", errmsgbuf, PCAP_ERRBUF_SIZE);
 			goto error;
 		}
 
@@ -1676,7 +1776,7 @@
 		if (getnameinfo((struct sockaddr *) &saddr, saddrlen, NULL,
 				0, portdata, sizeof(portdata), NI_NUMERICSERV))
 		{
-			sock_geterror("getnameinfo(): ", errmsgbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("getnameinfo()", errmsgbuf, PCAP_ERRBUF_SIZE);
 			goto error;
 		}
 	}
@@ -1686,11 +1786,11 @@
 	addrinfo = NULL;
 
 	// Needed to send an error on the ctrl connection
-	session->sockctrl_out = pars->sockctrl_out;
-	session->protocol_version = pars->protocol_version;
+	session->sockctrl = pars->sockctrl;
+	session->protocol_version = ver;
 
 	// Now I can set the filter
-	ret = daemon_unpackapplyfilter(pars->sockctrl_in, session, &plen, errmsgbuf);
+	ret = daemon_unpackapplyfilter(pars->sockctrl, session, &plen, errmsgbuf);
 	if (ret == -1)
 	{
 		// Fatal error.  A message has been logged; just give up.
@@ -1707,7 +1807,7 @@
 	    RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
 		goto error;
 
-	rpcap_createhdr((struct rpcap_header *) sendbuf, pars->protocol_version,
+	rpcap_createhdr((struct rpcap_header *) sendbuf, ver,
 	    RPCAP_MSG_STARTCAP_REPLY, 0, sizeof(struct rpcap_startcapreply));
 
 	startcapreply = (struct rpcap_startcapreply *) &sendbuf[sendbufidx];
@@ -1725,7 +1825,7 @@
 		startcapreply->portdata = htons(port);
 	}
 
-	if (sock_send(pars->sockctrl_out, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
+	if (sock_send(pars->sockctrl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
 		// That failed; log a message and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -1739,52 +1839,44 @@
 		// Connection creation
 		saddrlen = sizeof(struct sockaddr_storage);
 
-		socktemp = accept(sockdata, (struct sockaddr *) &saddr, &saddrlen);
+		socktemp = accept(session->sockdata, (struct sockaddr *) &saddr, &saddrlen);
 
 		if (socktemp == INVALID_SOCKET)
 		{
-			sock_geterror("accept(): ", errbuf, PCAP_ERRBUF_SIZE);
+			sock_geterror("accept()", errbuf, PCAP_ERRBUF_SIZE);
 			rpcapd_log(LOGPRIO_ERROR, "Accept of data connection failed: %s",
 			    errbuf);
 			goto error;
 		}
 
 		// Now that I accepted the connection, the server socket is no longer needed
-		sock_close(sockdata, NULL, 0);
-		sockdata = socktemp;
+		sock_close(session->sockdata, NULL, 0);
+		session->sockdata = socktemp;
 	}
 
-	session->sockdata = sockdata;
-
 	// Now we have to create a new thread to receive packets
 #ifdef _WIN32
-	threaddata->thread = (HANDLE)_beginthreadex(NULL, 0, daemon_thrdatamain,
+	session->thread = (HANDLE)_beginthreadex(NULL, 0, daemon_thrdatamain,
 	    (void *) session, 0, NULL);
-	if (threaddata->thread == 0)
+	if (session->thread == 0)
 	{
 		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error creating the data thread");
 		goto error;
 	}
 #else
-	/* GV we need this to create the thread as detached. */
-	/* GV otherwise, the thread handle is not destroyed  */
-	pthread_attr_init(&detachedAttribute);
-	pthread_attr_setdetachstate(&detachedAttribute, PTHREAD_CREATE_DETACHED);
-	ret = pthread_create(&threaddata->thread, &detachedAttribute,
-	    daemon_thrdatamain, (void *) session);
+	ret = pthread_create(&session->thread, NULL, daemon_thrdatamain,
+	    (void *) session);
 	if (ret != 0)
 	{
 		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
 		    ret, "Error creating the data thread");
-		pthread_attr_destroy(&detachedAttribute);
 		goto error;
 	}
-	pthread_attr_destroy(&detachedAttribute);
 #endif
-	threaddata->have_thread = 1;
+	session->have_thread = 1;
 
 	// Check if all the data has been read; if not, discard the data in excess
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 		goto fatal_error;
 
 	*sessionp = session;
@@ -1800,33 +1892,14 @@
 	if (addrinfo)
 		freeaddrinfo(addrinfo);
 
-	if (threaddata->have_thread)
-	{
-#ifdef _WIN32
-		if (session->fp)
-		{
-			pcap_breakloop(session->fp);
-			SetEvent(pcap_getevent(session->fp));
-		}
-		CloseHandle(threaddata->thread);
-#else
-		pthread_cancel(threaddata->thread);
-#endif
-		threaddata->have_thread = 0;
-	}
-
-	if (sockdata != INVALID_SOCKET)
-		sock_close(sockdata, NULL, 0);
-
 	if (session)
 	{
-		if (session->fp)
-			pcap_close(session->fp);
+		session_close(session);
 		free(session);
 	}
 
-	if (rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-	    PCAP_ERR_STARTCAPTURE, errmsgbuf, errbuf) == -1)
+	if (rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_STARTCAPTURE,
+	    errmsgbuf, errbuf) == -1)
 	{
 		// That failed; log a message and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -1834,7 +1907,7 @@
 	}
 
 	// Check if all the data has been read; if not, discard the data in excess
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		// Network error.
 		return -1;
@@ -1849,51 +1922,9 @@
 	//
 	*sessionp = NULL;
 
-	if (threaddata->have_thread)
-	{
-#ifdef _WIN32
-		if (session && session->fp)
-		{
-			//
-			// Tell the data connection thread main capture
-			// loop to break out of that loop.
-			//
-			pcap_breakloop(session->fp);
-
-			//
-			// If it's currently blocked waiting for packets
-			// to arrive, try to wake it up, so it can see
-			// the "break out of the loop" indication.
-			//
-			SetEvent(pcap_getevent(session->fp));
-		}
-
-		//
-		// Wait for the thread to exit, so we don't close
-		// sockets out from under it.
-		//
-		// XXX - have a timeout, so we don't wait forever?
-		//
-		WaitForSingleObject(threaddata->thread, INFINITE);
-
-		//
-		// Release the thread handle, as we're done with
-		// it.
-		//
-		CloseHandle(threaddata->thread);
-#else
-		pthread_cancel(threaddata->thread);
-#endif
-		threaddata->have_thread = 0;
-	}
-
-	if (sockdata != INVALID_SOCKET)
-		sock_close(sockdata, NULL, 0);
-
 	if (session)
 	{
-		if (session->fp)
-			pcap_close(session->fp);
+		session_close(session);
 		free(session);
 	}
 
@@ -1901,57 +1932,17 @@
 }
 
 static int
-daemon_msg_endcap_req(struct daemon_slpars *pars, struct session *session, struct thread_handle *threaddata)
+daemon_msg_endcap_req(uint8 ver, struct daemon_slpars *pars,
+    struct session *session)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];		// buffer for network errors
 	struct rpcap_header header;
 
-	if (threaddata->have_thread)
-	{
-#ifdef _WIN32
-		//
-		// Tell the data connection thread main capture loop to
-		// break out of that loop.
-		//
-		pcap_breakloop(session->fp);
+	session_close(session);
 
-		//
-		// If it's currently blocked waiting for packets to
-		// arrive, try to wake it up, so it can see the "break
-		// out of the loop" indication.
-		//
-		SetEvent(pcap_getevent(session->fp));
+	rpcap_createhdr(&header, ver, RPCAP_MSG_ENDCAP_REPLY, 0, 0);
 
-		//
-		// Wait for the thread to exit, so we don't close
-		// sockets out from under it.
-		//
-		// XXX - have a timeout, so we don't wait forever?
-		//
-		WaitForSingleObject(threaddata->thread, INFINITE);
-
-		//
-		// Release the thread handle, as we're done with
-		// it.
-		//
-		CloseHandle(threaddata->thread);
-#else
-		pthread_cancel(threaddata->thread);
-#endif
-		threaddata->have_thread = 0;
-	}
-	if (session->sockdata)
-	{
-		sock_close(session->sockdata, NULL, 0);
-		session->sockdata = 0;
-	}
-
-	pcap_close(session->fp);
-
-	rpcap_createhdr(&header, pars->protocol_version,
-	    RPCAP_MSG_ENDCAP_REPLY, 0, 0);
-
-	if (sock_send(pars->sockctrl_out, (char *) &header, sizeof(struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE) == -1)
+	if (sock_send(pars->sockctrl, (char *) &header, sizeof(struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
 		// That failed; log a message and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -1961,8 +1952,25 @@
 	return 0;
 }
 
+//
+// We impose a limit on the filter program size, so that, on Windows,
+// where there's only one server process with multiple threads, it's
+// harder to eat all the server address space by sending larger filter
+// programs.  (This isn't an issue on UN*X, where there are multiple
+// server processes, one per client connection.)
+//
+// We pick a value that limits each filter to 64K; that value is twice
+// the in-kernel limit for Linux and 16 times the in-kernel limit for
+// *BSD and macOS.
+//
+// It also prevents an overflow on 32-bit platforms when calculating
+// the total size of the filter program.  (It's not an issue on 64-bit
+// platforms with a 64-bit size_t, as the filter size is 32 bits.)
+//
+#define RPCAP_BPF_MAXINSNS	8192
+
 static int
-daemon_unpackapplyfilter(SOCKET sockctrl_in, struct session *session, uint32 *plenp, char *errmsgbuf)
+daemon_unpackapplyfilter(SOCKET sockctrl, struct session *session, uint32 *plenp, char *errmsgbuf)
 {
 	int status;
 	struct rpcap_filter filter;
@@ -1971,7 +1979,7 @@
 	struct bpf_program bf_prog;
 	unsigned int i;
 
-	status = rpcapd_recv(sockctrl_in, (char *) &filter,
+	status = rpcapd_recv(sockctrl, (char *) &filter,
 	    sizeof(struct rpcap_filter), plenp, errmsgbuf);
 	if (status == -1)
 	{
@@ -1990,6 +1998,13 @@
 		return -2;
 	}
 
+	if (bf_prog.bf_len > RPCAP_BPF_MAXINSNS)
+	{
+		pcap_snprintf(errmsgbuf, PCAP_ERRBUF_SIZE,
+		    "Filter program is larger than the maximum size of %u instructions",
+		    RPCAP_BPF_MAXINSNS);
+		return -2;
+	}
 	bf_insn = (struct bpf_insn *) malloc (sizeof(struct bpf_insn) * bf_prog.bf_len);
 	if (bf_insn == NULL)
 	{
@@ -2002,7 +2017,7 @@
 
 	for (i = 0; i < bf_prog.bf_len; i++)
 	{
-		status = rpcapd_recv(sockctrl_in, (char *) &insn,
+		status = rpcapd_recv(sockctrl, (char *) &insn,
 		    sizeof(struct rpcap_filterbpf_insn), plenp, errmsgbuf);
 		if (status == -1)
 		{
@@ -2037,14 +2052,15 @@
 }
 
 static int
-daemon_msg_updatefilter_req(struct daemon_slpars *pars, struct session *session, uint32 plen)
+daemon_msg_updatefilter_req(uint8 ver, struct daemon_slpars *pars,
+    struct session *session, uint32 plen)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];
 	char errmsgbuf[PCAP_ERRBUF_SIZE];	// buffer for errors to send to the client
 	int ret;				// status of daemon_unpackapplyfilter()
 	struct rpcap_header header;		// keeps the answer to the updatefilter command
 
-	ret = daemon_unpackapplyfilter(pars->sockctrl_in, session, &plen, errmsgbuf);
+	ret = daemon_unpackapplyfilter(pars->sockctrl, session, &plen, errmsgbuf);
 	if (ret == -1)
 	{
 		// Fatal error.  A message has been logged; just give up.
@@ -2057,17 +2073,16 @@
 	}
 
 	// Check if all the data has been read; if not, discard the data in excess
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		// Network error.
 		return -1;
 	}
 
 	// A response is needed, otherwise the other host does not know that everything went well
-	rpcap_createhdr(&header, pars->protocol_version,
-	    RPCAP_MSG_UPDATEFILTER_REPLY, 0, 0);
+	rpcap_createhdr(&header, ver, RPCAP_MSG_UPDATEFILTER_REPLY, 0, 0);
 
-	if (sock_send(pars->sockctrl_out, (char *) &header, sizeof (struct rpcap_header), pcap_geterr(session->fp), PCAP_ERRBUF_SIZE))
+	if (sock_send(pars->sockctrl, (char *) &header, sizeof (struct rpcap_header), pcap_geterr(session->fp), PCAP_ERRBUF_SIZE))
 	{
 		// That failed; log a messsage and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -2077,12 +2092,12 @@
 	return 0;
 
 error:
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		return -1;
 	}
-	rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-	    PCAP_ERR_UPDATEFILTER, errmsgbuf, NULL);
+	rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_UPDATEFILTER,
+	    errmsgbuf, NULL);
 
 	return 0;
 }
@@ -2091,7 +2106,8 @@
 	\brief Received the sampling parameters from remote host and it stores in the pcap_t structure.
 */
 static int
-daemon_msg_setsampling_req(struct daemon_slpars *pars, uint32 plen, struct rpcap_sampling *samp_param)
+daemon_msg_setsampling_req(uint8 ver, struct daemon_slpars *pars, uint32 plen,
+    struct rpcap_sampling *samp_param)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];		// buffer for network errors
 	char errmsgbuf[PCAP_ERRBUF_SIZE];
@@ -2099,7 +2115,7 @@
 	struct rpcap_sampling rpcap_samp;
 	int status;
 
-	status = rpcapd_recv(pars->sockctrl_in, (char *) &rpcap_samp, sizeof(struct rpcap_sampling), &plen, errmsgbuf);
+	status = rpcapd_recv(pars->sockctrl, (char *) &rpcap_samp, sizeof(struct rpcap_sampling), &plen, errmsgbuf);
 	if (status == -1)
 	{
 		return -1;
@@ -2114,17 +2130,16 @@
 	samp_param->value = ntohl(rpcap_samp.value);
 
 	// A response is needed, otherwise the other host does not know that everything went well
-	rpcap_createhdr(&header, pars->protocol_version,
-	    RPCAP_MSG_SETSAMPLING_REPLY, 0, 0);
+	rpcap_createhdr(&header, ver, RPCAP_MSG_SETSAMPLING_REPLY, 0, 0);
 
-	if (sock_send(pars->sockctrl_out, (char *) &header, sizeof (struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE) == -1)
+	if (sock_send(pars->sockctrl, (char *) &header, sizeof (struct rpcap_header), errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
 		// That failed; log a messsage and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 		return -1;
 	}
 
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		return -1;
 	}
@@ -2132,8 +2147,8 @@
 	return 0;
 
 error:
-	if (rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-	    PCAP_ERR_AUTH, errmsgbuf, errbuf) == -1)
+	if (rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_SETSAMPLING,
+	    errmsgbuf, errbuf) == -1)
 	{
 		// That failed; log a message and give up.
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
@@ -2141,7 +2156,7 @@
 	}
 
 	// Check if all the data has been read; if not, discard the data in excess
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		return -1;
 	}
@@ -2150,7 +2165,9 @@
 }
 
 static int
-daemon_msg_stats_req(struct daemon_slpars *pars, struct session *session, uint32 plen, struct pcap_stat *stats, unsigned int svrcapt)
+daemon_msg_stats_req(uint8 ver, struct daemon_slpars *pars,
+    struct session *session, uint32 plen, struct pcap_stat *stats,
+    unsigned int svrcapt)
 {
 	char errbuf[PCAP_ERRBUF_SIZE];		// buffer for network errors
 	char errmsgbuf[PCAP_ERRBUF_SIZE];	// buffer for errors to send to the client
@@ -2159,7 +2176,7 @@
 	struct rpcap_stats *netstats;		// statistics sent on the network
 
 	// Checks that the header does not contain other data; if so, discard it
-	if (rpcapd_discard(pars->sockctrl_in, plen) == -1)
+	if (rpcapd_discard(pars->sockctrl, plen) == -1)
 	{
 		// Network error.
 		return -1;
@@ -2169,7 +2186,7 @@
 	    &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1)
 		goto error;
 
-	rpcap_createhdr((struct rpcap_header *) sendbuf, pars->protocol_version,
+	rpcap_createhdr((struct rpcap_header *) sendbuf, ver,
 	    RPCAP_MSG_STATS_REPLY, 0, (uint16) sizeof(struct rpcap_stats));
 
 	netstats = (struct rpcap_stats *) &sendbuf[sendbufidx];
@@ -2203,7 +2220,7 @@
 	}
 
 	// Send the packet
-	if (sock_send(pars->sockctrl_out, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
+	if (sock_send(pars->sockctrl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
 		rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf);
 		return -1;
@@ -2212,8 +2229,8 @@
 	return 0;
 
 error:
-	rpcap_senderror(pars->sockctrl_out, pars->protocol_version,
-	    PCAP_ERR_GETSTATS, errmsgbuf, NULL);
+	rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_GETSTATS,
+	    errmsgbuf, NULL);
 	return 0;
 }
 
@@ -2234,6 +2251,9 @@
 	char *sendbuf;						// temporary buffer in which data to be sent is buffered
 	int sendbufidx;						// index which keeps the number of bytes currently buffered
 	int status;
+#ifndef _WIN32
+	sigset_t sigusr1;			// signal set with just SIGUSR1
+#endif
 
 	session = (struct session *) ptr;
 
@@ -2278,30 +2298,36 @@
 	}
 
 #ifndef _WIN32
-	// Modify thread params so that it can be killed at any time
-	retval = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
-	if (retval != 0)
-	{
-		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
-		    retval, "pthread_setcancelstate");
-		rpcapd_log(LOGPRIO_ERROR,
-		    "Can't set cancel state on data thread: %s", errbuf);
-		goto error;
-	}
-	retval = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
-	if (retval != 0)
-	{
-		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
-		    retval, "pthread_setcanceltype");
-		rpcapd_log(LOGPRIO_ERROR,
-		    "Can't set cancel type on data thread: %s", errbuf);
-		goto error;
-	}
+	//
+	// Set the signal set to include just SIGUSR1, and block that
+	// signal; we only want it unblocked when we're reading
+	// packets - we dn't want any other system calls, such as
+	// ones being used to send to the client or to log messages,
+	// to be interrupted.
+	//
+	sigemptyset(&sigusr1);
+	sigaddset(&sigusr1, SIGUSR1);
+	pthread_sigmask(SIG_BLOCK, &sigusr1, NULL);
 #endif
 
 	// Retrieve the packets
-	while ((retval = pcap_next_ex(session->fp, &pkt_header, (const u_char **) &pkt_data)) >= 0)	// cast to avoid a compiler warning
+	for (;;)
 	{
+#ifndef _WIN32
+		//
+		// Unblock SIGUSR1 while we might be waiting for packets.
+		//
+		pthread_sigmask(SIG_UNBLOCK, &sigusr1, NULL);
+#endif
+		retval = pcap_next_ex(session->fp, &pkt_header, (const u_char **) &pkt_data);	// cast to avoid a compiler warning
+#ifndef _WIN32
+		//
+		// Now block it again.
+		//
+		pthread_sigmask(SIG_BLOCK, &sigusr1, NULL);
+#endif
+		if (retval < 0)
+			break;		// error
 		if (retval == 0)	// Read timeout elapsed
 			continue;
 
@@ -2377,23 +2403,40 @@
 		}
 	}
 
-	if (retval == -1)
+	if (retval < 0 && retval != PCAP_ERROR_BREAK)
 	{
+		//
+		// Failed with an error other than "we were told to break
+		// out of the loop".
+		//
+		// The latter just means that the client told us to stop
+		// capturing, so there's no error to report.
+		//
 		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error reading the packets: %s", pcap_geterr(session->fp));
-		rpcap_senderror(session->sockctrl_out, session->protocol_version,
+		rpcap_senderror(session->sockctrl, session->protocol_version,
 		    PCAP_ERR_READEX, errbuf, NULL);
-		goto error;
 	}
 
 error:
- 	closesocket(session->sockdata);
-	session->sockdata = 0;
-
+	//
+	// The main thread will clean up the session structure.
+	//
 	free(sendbuf);
 
 	return 0;
 }
 
+#ifndef _WIN32
+//
+// Do-nothing handler for SIGUSR1; the sole purpose of SIGUSR1 is to
+// interrupt the data thread if it's blocked in a system call waiting
+// for packets to arrive.
+//
+static void noop_handler(int sign _U_)
+{
+}
+#endif
+
 /*!
 	\brief It serializes a network address.
 
@@ -2552,3 +2595,153 @@
 	}
 	return 0;
 }
+
+//
+// Shut down any packet-capture thread associated with the session,
+// close the SSL handle for the data socket if we have one, close
+// the data socket if we have one, and close the underlying packet
+// capture handle if we have one.
+//
+// We do not, of course, touch the controlling socket that's also
+// copied into the session, as the service loop might still use it.
+//
+static void session_close(struct session *session)
+{
+	if (session->have_thread)
+	{
+		//
+		// Tell the data connection thread main capture loop to
+		// break out of that loop.
+		//
+		// This may be sufficient to wake up a blocked thread,
+		// but it's not guaranteed to be sufficient.
+		//
+		pcap_breakloop(session->fp);
+
+#ifdef _WIN32
+		//
+		// Set the event on which a read would block, so that,
+		// if it's currently blocked waiting for packets to
+		// arrive, it'll wake up, so it can see the "break
+		// out of the loop" indication.  (pcap_breakloop()
+		// might do this, but older versions don't.  Setting
+		// it twice should, at worst, cause an extra wakeup,
+		// which shouldn't be a problem.)
+		//
+		// XXX - what about modules other than NPF?
+		//
+		SetEvent(pcap_getevent(session->fp));
+
+		//
+		// Wait for the thread to exit, so we don't close
+		// sockets out from under it.
+		//
+		// XXX - have a timeout, so we don't wait forever?
+		//
+		WaitForSingleObject(session->thread, INFINITE);
+
+		//
+		// Release the thread handle, as we're done with
+		// it.
+		//
+		CloseHandle(session->thread);
+		session->have_thread = 0;
+		session->thread = INVALID_HANDLE_VALUE;
+#else
+		//
+		// Send a SIGUSR1 signal to the thread, so that, if
+		// it's currently blocked waiting for packets to arrive,
+		// it'll wake up (we've turned off SA_RESTART for
+		// SIGUSR1, so that the system call in which it's blocked
+		// should return EINTR rather than restarting).
+		//
+		pthread_kill(session->thread, SIGUSR1);
+
+		//
+		// Wait for the thread to exit, so we don't close
+		// sockets out from under it.
+		//
+		// XXX - have a timeout, so we don't wait forever?
+		//
+		pthread_join(session->thread, NULL);
+		session->have_thread = 0;
+		memset(&session->thread, 0, sizeof(session->thread));
+#endif
+	}
+
+	if (session->sockdata != INVALID_SOCKET)
+	{
+		sock_close(session->sockdata, NULL, 0);
+		session->sockdata = INVALID_SOCKET;
+	}
+
+	if (session->fp)
+	{
+		pcap_close(session->fp);
+		session->fp = NULL;
+	}
+}
+
+//
+// Check whether a capture source string is a URL or not.
+// This includes URLs that refer to a local device; a scheme, followed
+// by ://, followed by *another* scheme and ://, is just silly, and
+// anybody who supplies that will get an error.
+//
+static int
+is_url(const char *source)
+{
+	char *colonp;
+
+	/*
+	 * RFC 3986 says:
+	 *
+	 *   URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
+	 *
+	 *   hier-part   = "//" authority path-abempty
+	 *               / path-absolute
+	 *               / path-rootless
+	 *               / path-empty
+	 *
+	 *   authority   = [ userinfo "@" ] host [ ":" port ]
+	 *
+	 *   userinfo    = *( unreserved / pct-encoded / sub-delims / ":" )
+	 *
+	 * Step 1: look for the ":" at the end of the scheme.
+	 * A colon in the source is *NOT* sufficient to indicate that
+	 * this is a URL, as interface names on some platforms might
+	 * include colons (e.g., I think some Solaris interfaces
+	 * might).
+	 */
+	colonp = strchr(source, ':');
+	if (colonp == NULL)
+	{
+		/*
+		 * The source is the device to open.  It's not a URL.
+		 */
+		return (0);
+	}
+
+	/*
+	 * All schemes must have "//" after them, i.e. we only support
+	 * hier-part   = "//" authority path-abempty, not
+	 * hier-part   = path-absolute
+	 * hier-part   = path-rootless
+	 * hier-part   = path-empty
+	 *
+	 * We need that in order to distinguish between a local device
+	 * name that happens to contain a colon and a URI.
+	 */
+	if (strncmp(colonp + 1, "//", 2) != 0)
+	{
+		/*
+		 * The source is the device to open.  It's not a URL.
+		 */
+		return (0);
+	}
+
+	/*
+	 * It's a URL.
+	 */
+	return (1);
+}
diff --git a/rpcapd/daemon.h b/rpcapd/daemon.h
index bd240b8..74e17da 100644
--- a/rpcapd/daemon.h
+++ b/rpcapd/daemon.h
@@ -35,9 +35,10 @@
 
 //
 // Returns 1 if the client closed the control connection explicitly, 0
-// otherwise; used in active mode only.
+// otherwise; the return value is used only by callers that call us
+// for active mode.
 //
-int daemon_serviceloop(SOCKET sockctrl_in, SOCKET sockctrl_out, int isactive,
+int daemon_serviceloop(SOCKET sockctrl, int isactive, char *passiveClients,
     int nullAuthAllowed);
 
 void sleep_secs(int secs);
diff --git a/rpcapd/fileconf.c b/rpcapd/fileconf.c
index ab1e9dd..2f15c01 100644
--- a/rpcapd/fileconf.c
+++ b/rpcapd/fileconf.c
@@ -39,102 +39,444 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <ctype.h>
 #include <signal.h>
 #include <pcap.h>		// for PCAP_ERRBUF_SIZE
 
-#include "sockutils.h"		// for SOCK_DEBUG_MESSAGE
 #include "portability.h"
 #include "rpcapd.h"
 #include "config_params.h"	// configuration file parameters
 #include "fileconf.h"
 #include "rpcap-protocol.h"
+#include "log.h"
 
-static int strrem(char *string, char chr);
+//
+// Parameter names.
+//
+#define PARAM_ACTIVECLIENT	"ActiveClient"
+#define PARAM_PASSIVECLIENT	"PassiveClient"
+#define PARAM_NULLAUTHPERMIT	"NullAuthPermit"
+
+static char *skipws(char *ptr);
 
 void fileconf_read(void)
 {
 	FILE *fp;
-	char msg[PCAP_ERRBUF_SIZE + 1];
-	int i;
+	unsigned int num_active_clients;
 
 	if ((fp = fopen(loadfile, "r")) != NULL)
 	{
 		char line[MAX_LINE + 1];
-		char *ptr;
+		unsigned int lineno;
 
 		hostlist[0] = 0;
-		i = 0;
+		num_active_clients = 0;
+		lineno = 0;
 
 		while (fgets(line, MAX_LINE, fp) != NULL)
 		{
-			if (line[0] == '\n') continue;	// Blank line
-			if (line[0] == '\r') continue;	// Blank line
-			if (line[0] == '#') continue;	// Comment
+			size_t linelen;
+			char *ptr;
+			char *param;
+			size_t result;
+			size_t toklen;
 
-			ptr = strstr(line, "ActiveClient");
-			if (ptr)
+			lineno++;
+
+			linelen = strlen(line);
+			if (line[linelen - 1] != '\n')
 			{
-				char *address, *port;
-				char *lasts;
+				int c;
 
-				ptr = strchr(ptr, '=') + 1;
-				address = pcap_strtok_r(ptr, RPCAP_HOSTLIST_SEP, &lasts);
+				//
+				// Either the line doesn't fit in
+				// the buffer, or we got an EOF
+				// before the EOL.  Assume it's the
+				// former.
+				//
+				rpcapd_log(LOGPRIO_ERROR,
+				    "%s, line %u is longer than %u characters",
+				    loadfile, lineno, MAX_LINE);
 
-				if ((address != NULL) && (i < MAX_ACTIVE_LIST))
+				//
+				// Eat characters until we get an NL.
+				//
+				while ((c = getc(fp)) != '\n')
 				{
-					port = pcap_strtok_r(NULL, RPCAP_HOSTLIST_SEP, &lasts);
-					strlcpy(activelist[i].address, address, MAX_LINE);
-
-					if (strcmp(port, "DEFAULT") == 0) // the user choose a custom port
-						strlcpy(activelist[i].port, RPCAP_DEFAULT_NETPORT_ACTIVE, MAX_LINE);
-					else
-						strlcpy(activelist[i].port, port, MAX_LINE);
-
-					activelist[i].address[MAX_LINE] = 0;
-					activelist[i].port[MAX_LINE] = 0;
+					if (c == EOF)
+						goto done;
 				}
+
+				//
+				// Try the next line.
+				//
+				continue;
+			}
+			ptr = line;
+
+			//
+			// Skip leading white space, if any.
+			//
+			ptr = skipws(ptr);
+			if (ptr == NULL)
+			{
+				// Blank line.
+				continue;
+			}
+
+			//
+			// Is the next character a "#"?  If so, this
+			// line is a comment; skip to the next line.
+			//
+			if (*ptr == '#')
+				continue;
+
+			//
+			// Is the next character alphabetic?  If not,
+			// this isn't a valid parameter name.
+			//
+			if (!isascii((unsigned char)*ptr) ||
+			    !isalpha((unsigned char)*ptr))
+			{
+				rpcapd_log(LOGPRIO_ERROR,
+				    "%s, line %u doesn't have a valid parameter name",
+				    loadfile, lineno);
+				continue;
+			}
+
+			//
+			// Grab the first token, which is made of
+			// alphanumerics, underscores, and hyphens.
+			// That's the name of the parameter being set.
+			//
+			param = ptr;
+			while (isascii((unsigned char)*ptr) &&
+			    (isalnum((unsigned char)*ptr) || *ptr == '-' || *ptr == '_'))
+				ptr++;
+
+			//
+			// Skip over white space, if any.
+			//
+			ptr = skipws(ptr);
+			if (ptr == NULL || *ptr != '=')
+			{
+				//
+				// We hit the end of the line before
+				// finding a non-white space character,
+				// or we found one but it's not an "=".
+				// That means there's no "=", so this
+				// line is invalid.  Complain and skip
+				// this line.
+				//
+				rpcapd_log(LOGPRIO_ERROR,
+				    "%s, line %u has a parameter but no =",
+				    loadfile, lineno);
+				continue;
+			}
+
+			//
+			// We found the '='; set it to '\0', and skip
+			// past it.
+			//
+			*ptr++ = '\0';
+
+			//
+			// Skip past any white space after the "=".
+			//
+			ptr = skipws(ptr);
+			if (ptr == NULL)
+			{
+				//
+				// The value is empty.
+				//
+				rpcapd_log(LOGPRIO_ERROR,
+				    "%s, line %u has a parameter but no value",
+				    loadfile, lineno);
+				continue;
+			}
+
+			//
+			// OK, what parameter is this?
+			//
+			if (strcmp(param, PARAM_ACTIVECLIENT) == 0) {
+				//
+				// Add this to the list of active clients.
+				//
+				char *address, *port;
+
+				//
+				// We can't have more than MAX_ACTIVE_LIST
+				// active clients.
+				//
+				if (num_active_clients >= MAX_ACTIVE_LIST)
+				{
+					//
+					// Too many entries for the active
+					// client list.  Complain and
+					// ignore it.
+					//
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has an %s parameter, but we already have %u active clients",
+					    loadfile, lineno, PARAM_ACTIVECLIENT,
+					    MAX_ACTIVE_LIST);
+					continue;
+				}
+
+				//
+				// Get the address.
+				// It's terminated by a host list separator
+				// *or* a #; there *shouldn't* be a #, as
+				// that starts a comment, and that would
+				// mean that we have no port.
+				//
+				address = ptr;
+				toklen = strcspn(ptr, RPCAP_HOSTLIST_SEP "#");
+				ptr += toklen;	// skip to the terminator
+				if (toklen == 0)
+				{
+					if (isascii((unsigned char)*ptr) &&
+					    (isspace((unsigned char)*ptr) || *ptr == '#' || *ptr == '\0'))
+					{
+						//
+						// The first character it saw
+						// was a whitespace character
+						// or a comment character.
+						// This means that there's
+						// no value.
+						//
+						rpcapd_log(LOGPRIO_ERROR,
+						    "%s, line %u has a parameter but no value",
+						    loadfile, lineno);
+					}
+					else
+					{
+						//
+						// This means that the first
+						// character it saw was a
+						// separator.  This means that
+						// there's no address in the
+						// value, just a port.
+						//
+						rpcapd_log(LOGPRIO_ERROR,
+						    "%s, line %u has an %s parameter with a value containing no address",
+						    loadfile, lineno, PARAM_ACTIVECLIENT);
+					}
+					continue;
+				}
+
+				//
+				// Null-terminate the address, and skip past
+				// it.
+				//
+				*ptr++ = '\0';
+
+				//
+				// Skip any white space following the
+				// separating character.
+				//
+				ptr = skipws(ptr);
+				if (ptr == NULL)
+				{
+					//
+					// The value is empty, so there's
+					// no port in the value.
+					//
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has an %s parameter with a value containing no port",
+					    loadfile, lineno, PARAM_ACTIVECLIENT);
+					continue;
+				}
+
+				//
+				// Get the port.
+				// We look for a white space character
+				// or a # as a terminator; the # introduces
+				// a comment that runs to the end of the
+				// line.
+				//
+				port = ptr;
+				toklen = strcspn(ptr, " \t#\r\n");
+				ptr += toklen;
+				if (toklen == 0)
+				{
+					//
+					// The value is empty, so there's
+					// no port in the value.
+					//
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has an %s parameter with a value containing no port",
+					    loadfile, lineno, PARAM_ACTIVECLIENT);
+					continue;
+				}
+
+				//
+				// Null-terminate the port, and skip past
+				// it.
+				//
+				*ptr++ = '\0';
+				result = pcap_strlcpy(activelist[num_active_clients].address, address, sizeof(activelist[num_active_clients].address));
+				if (result >= sizeof(activelist[num_active_clients].address))
+				{
+					//
+					// It didn't fit.
+					//
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has an %s parameter with an address with more than %u characters",
+					    loadfile, lineno, PARAM_ACTIVECLIENT,
+					    (unsigned int)(sizeof(activelist[num_active_clients].address) - 1));
+					continue;
+				}
+				if (strcmp(port, "DEFAULT") == 0) // the user choose a custom port
+					result = pcap_strlcpy(activelist[num_active_clients].port, RPCAP_DEFAULT_NETPORT_ACTIVE, sizeof(activelist[num_active_clients].port));
 				else
-					SOCK_DEBUG_MESSAGE("Only MAX_ACTIVE_LIST active connections are currently supported.");
+					result = pcap_strlcpy(activelist[num_active_clients].port, port, sizeof(activelist[num_active_clients].port));
+				if (result >= sizeof(activelist[num_active_clients].address))
+				{
+					//
+					// It didn't fit.
+					//
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has an %s parameter with an port with more than %u characters",
+					    loadfile, lineno, PARAM_ACTIVECLIENT,
+					    (unsigned int)(sizeof(activelist[num_active_clients].port) - 1));
+					continue;
+				}
 
-				i++;
-				continue;
+				num_active_clients++;
 			}
-
-			ptr = strstr(line, "PassiveClient");
-			if (ptr)
+			else if (strcmp(param, PARAM_PASSIVECLIENT) == 0)
 			{
-				ptr = strchr(ptr, '=') + 1;
-				strlcat(hostlist, ptr, MAX_HOST_LIST);
-				strlcat(hostlist, ",", MAX_HOST_LIST);
-				continue;
+				char *eos;
+				char *host;
+
+				//
+				// Get the host.
+				// We look for a white space character
+				// or a # as a terminator; the # introduces
+				// a comment that runs to the end of the
+				// line.
+				//
+				host = ptr;
+				toklen = strcspn(ptr, " \t#\r\n");
+				if (toklen == 0)
+				{
+					//
+					// The first character it saw
+					// was a whitespace character
+					// or a comment character.
+					// This means that there's
+					// no value.
+					//
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has a parameter but no value",
+					    loadfile, lineno);
+					continue;
+				}
+				ptr += toklen;
+				*ptr++ = '\0';
+
+				//
+				// Append this to the host list.
+				// Save the curren end-of-string for the
+				// host list, in case the new host doesn't
+				// fit, so that we can discard the partially-
+				// copied host name.
+				//
+				eos = hostlist + strlen(hostlist);
+				if (eos != hostlist)
+				{
+					//
+					// The list is not empty, so prepend
+					// a comma before adding this host.
+					//
+					result = pcap_strlcat(hostlist, ",", sizeof(hostlist));
+					if (result >= sizeof(hostlist))
+					{
+						//
+						// It didn't fit.  Discard
+						// the comma (which wasn't
+						// added, but...), complain,
+						// and ignore this line.
+						//
+						*eos = '\0';
+						rpcapd_log(LOGPRIO_ERROR,
+						    "%s, line %u has a %s parameter with a host name that doesn't fit",
+						    loadfile, lineno, PARAM_PASSIVECLIENT);
+						continue;
+					}
+				}
+				result = pcap_strlcat(hostlist, host, sizeof(hostlist));
+				if (result >= sizeof(hostlist))
+				{
+					//
+					// It didn't fit.  Discard the comma,
+					// complain, and ignore this line.
+					//
+					*eos = '\0';
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has a %s parameter with a host name that doesn't fit",
+					    loadfile, lineno, PARAM_PASSIVECLIENT);
+					continue;
+				}
 			}
-
-			ptr = strstr(line, "NullAuthPermit");
-			if (ptr)
+			else if (strcmp(param, PARAM_NULLAUTHPERMIT) == 0)
 			{
-				ptr = strstr(ptr, "YES");
-				if (ptr)
+				char *setting;
+
+				//
+				// Get the setting.
+				// We look for a white space character
+				// or a # as a terminator; the # introduces
+				// a comment that runs to the end of the
+				// line.
+				//
+				setting = ptr;
+				toklen = strcspn(ptr, " \t#\r\n");
+				ptr += toklen;
+				if (toklen == 0)
+				{
+					//
+					// The first character it saw
+					// was a whitespace character
+					// or a comment character.
+					// This means that there's
+					// no value.
+					//
+					rpcapd_log(LOGPRIO_ERROR,
+					    "%s, line %u has a parameter but no value",
+					    loadfile, lineno);
+					continue;
+				}
+				*ptr++ = '\0';
+
+				//
+				// XXX - should we complain if it's
+				// neither "yes" nor "no"?
+				//
+				if (strcmp(setting, "YES") == 0)
 					nullAuthAllowed = 1;
 				else
 					nullAuthAllowed = 0;
+			}
+			else
+			{
+				rpcapd_log(LOGPRIO_ERROR,
+				    "%s, line %u has an unknown parameter %s",
+				    loadfile, lineno, param);
 				continue;
 			}
 		}
 
+done:
 		// clear the remaining fields of the active list
-		while (i < MAX_ACTIVE_LIST)
+		for (int i = num_active_clients; i < MAX_ACTIVE_LIST; i++)
 		{
 			activelist[i].address[0] = 0;
 			activelist[i].port[0] = 0;
-			i++;
+			num_active_clients++;
 		}
 
-		// Remove all '\n' and '\r' from the strings
-		strrem(hostlist, '\r');
-		strrem(hostlist, '\n');
-
-		pcap_snprintf(msg, PCAP_ERRBUF_SIZE, "New passive host list: %s\n\n", hostlist);
-		SOCK_DEBUG_MESSAGE(msg);
+		rpcapd_log(LOGPRIO_DEBUG, "New passive host list: %s", hostlist);
 		fclose(fp);
 	}
 }
@@ -162,7 +504,7 @@
 		token = pcap_strtok_r(temphostlist, RPCAP_HOSTLIST_SEP, &lasts);
 		while(token != NULL)
 		{
-			fprintf(fp, "PassiveClient = %s\n", token);
+			fprintf(fp, "%s = %s\n", PARAM_PASSIVECLIENT, token);
 			token = pcap_strtok_r(NULL, RPCAP_HOSTLIST_SEP, &lasts);
 		}
 
@@ -175,18 +517,17 @@
 
 		while ((i < MAX_ACTIVE_LIST) && (activelist[i].address[0] != 0))
 		{
-			fprintf(fp, "ActiveClient = %s, %s\n", activelist[i].address, activelist[i].port);
+			fprintf(fp, "%s = %s, %s\n", PARAM_ACTIVECLIENT,
+			    activelist[i].address, activelist[i].port);
 			i++;
 		}
 
 		// Save if we want to permit NULL authentication
 		fprintf(fp, "\n\n");
-		fprintf(fp, "# Permit NULL authentication: YES or NOT\n\n");
+		fprintf(fp, "# Permit NULL authentication: YES or NO\n\n");
 
-		if (nullAuthAllowed)
-			fprintf(fp, "NullAuthPermit = YES\n");
-		else
-			fprintf(fp, "NullAuthPermit = NO\n");
+		fprintf(fp, "%s = %s\n", PARAM_NULLAUTHPERMIT,
+		    nullAuthAllowed ? "YES" : "NO");
 
 		fclose(fp);
 		return 0;
@@ -198,19 +539,19 @@
 
 }
 
-static int strrem(char *string, char chr)
+//
+// Skip over white space.
+// If we hit a CR or LF, return NULL, otherwise return a pointer to
+// the first non-white space character.  Replace white space characters
+// other than CR or LF with '\0', so that, if we're skipping white space
+// after a token, the token is null-terminated.
+//
+static char *skipws(char *ptr)
 {
-	char *pos;
-	int num = 0;
-	int len, i;
-
-	while ((pos = strchr(string, chr)) != NULL)
-	{
-		num++;
-		len = strlen(pos);
-		for (i = 0; i < len; i++)
-			pos[i] = pos[i+1];
+	while (isascii((unsigned char)*ptr) && isspace((unsigned char)*ptr)) {
+		if (*ptr == '\r' || *ptr == '\n')
+			return NULL;
+		*ptr++ = '\0';
 	}
-
-	return num;
+	return ptr;
 }
diff --git a/rpcapd/log-stderr.c b/rpcapd/log-stderr.c
deleted file mode 100644
index 5af6f2e..0000000
--- a/rpcapd/log-stderr.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include "log.h"
-
-void
-rpcapd_log_init(void)
-{
-}
-
-void
-rpcapd_log(log_priority priority, const char *message, ...)
-{
-	const char *tag;
-	va_list ap;
-
-	switch (priority) {
-
-	case LOGPRIO_INFO:
-		tag = "";
-		break;
-
-	case LOGPRIO_WARNING:
-		tag = "warning: ";
-		break;
-
-	case LOGPRIO_ERROR:
-		tag = "error: ";
-		break;
-
-	default:
-		abort();
-		/* NOTREACHED */
-	}
-
-	fprintf(stderr, "rpcapd: %s", tag);
-	va_start(ap, message);
-	vfprintf(stderr, message, ap);
-	va_end(ap);
-	putc('\n', stderr);
-}
diff --git a/rpcapd/log.c b/rpcapd/log.c
new file mode 100644
index 0000000..7b5fee5
--- /dev/null
+++ b/rpcapd/log.c
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 1993, 1994, 1995, 1996, 1998
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <syslog.h>
+#endif
+
+#include "portability.h"
+
+#include "log.h"
+
+static int log_to_systemlog;
+static int log_debug_messages;
+
+static void rpcapd_vlog_stderr(log_priority,
+    PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(2, 0);
+
+static void rpcapd_vlog_stderr(log_priority priority, const char *message, va_list ap)
+{
+	const char *tag;
+
+	/*
+	 * Squelch warnings from compilers that *don't* assume that
+	 * priority always has a valid enum value and therefore don't
+	 * assume that we'll always go through one of the case arms.
+	 *
+	 * If we have a default case, compilers that *do* assume that
+	 * will then complain about the default case code being
+	 * unreachable.
+	 *
+	 * Damned if you do, damned if you don't.
+	 */
+	tag = "";
+
+	switch (priority) {
+
+	case LOGPRIO_DEBUG:
+		tag = "DEBUG: ";
+		break;
+
+	case LOGPRIO_INFO:
+		tag = "";
+		break;
+
+	case LOGPRIO_WARNING:
+		tag = "warning: ";
+		break;
+
+	case LOGPRIO_ERROR:
+		tag = "error: ";
+		break;
+	}
+
+	fprintf(stderr, "rpcapd: %s", tag);
+	vfprintf(stderr, message, ap);
+	putc('\n', stderr);
+}
+
+static void rpcapd_vlog_systemlog(log_priority,
+    PCAP_FORMAT_STRING(const char *), va_list) PCAP_PRINTFLIKE(2, 0);
+
+#ifdef _WIN32
+#define MESSAGE_SUBKEY \
+    "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\rpcapd"
+
+static void rpcapd_vlog_systemlog(log_priority priority, const char *message,
+    va_list ap)
+{
+#if 0
+	static int initialized = 0;
+	HKEY hey_handle;
+	static HANDLE log_handle;
+	WORD eventlog_type;
+	DWORD event_id;
+	char msgbuf[1024];
+	char *strings[1];
+
+	if (!initialized) {
+		/*
+		 * Register our message stuff in the Registry.
+		 *
+		 * First, create the registry key for us.  If the key
+		 * already exists, this succeeds and returns a handle
+		 * for it.
+		 */
+		if (RegCreateKey(HKEY_LOCAL_MACHINE, MESSAGE_SUBKEY,
+		    &key_handle) != ERROR_SUCCESS) {
+			/*
+			 * Failed - give up and just log this message,
+			 * and all subsequent messages, to the
+			 * standard error.
+			 */
+			log_to_systemlog = 0;
+			initialized = 1;
+			rpcapd_vlog_stderr(priority, message, ap);
+			return;
+		}
+		log_handle = RegisterEventSource(NULL, "rpcapd");
+		initialized = 1;
+	}
+
+	switch (priority) {
+
+	case LOGPRIO_DEBUG:
+		//
+		// XXX - what *should* we do about debug messages?
+		//
+		eventlog_type = EVENTLOG_INFORMATION_TYPE;
+		event_id = RPCAPD_INFO_ID;
+		break;
+
+	case LOGPRIO_INFO:
+		eventlog_type = EVENTLOG_INFORMATION_TYPE;
+		event_id = RPCAPD_INFO_ID;
+		break;
+
+	case LOGPRIO_WARNING:
+		eventlog_type = EVENTLOG_WARNING_TYPE;
+		event_id = RPCAPD_WARNING_ID;
+		break;
+
+	case LOGPRIO_ERROR:
+		eventlog_type = EVENTLOG_ERROR_TYPE;
+		event_id = RPCAPD_ERROR_ID;
+		break;
+
+	default:
+		/* Don't do this. */
+		return;
+	}
+
+	vsprintf(msgbuf, message, ap);
+
+	strings[0] = msgbuf;
+	/*
+	 * If this fails, how are we going to report it?
+	 */
+	(void) ReportEvent(log_handle, eventlog_type, 0, event_id, NULL, 1, 0,
+	    strings, NULL);
+#else
+	rpcapd_vlog_stderr(priority, message, ap);
+#endif
+}
+#else
+static void rpcapd_vlog_systemlog(log_priority priority, const char *message,
+    va_list ap)
+{
+	static int initialized = 0;
+	int syslog_priority;
+
+	if (!initialized) {
+		//
+		// Open the log.
+		//
+		openlog("rpcapd", LOG_PID, LOG_DAEMON);
+		initialized = 1;
+	}
+
+	switch (priority) {
+
+	case LOGPRIO_DEBUG:
+		syslog_priority = LOG_DEBUG;
+		break;
+
+	case LOGPRIO_INFO:
+		syslog_priority = LOG_INFO;
+		break;
+
+	case LOGPRIO_WARNING:
+		syslog_priority = LOG_WARNING;
+		break;
+
+	case LOGPRIO_ERROR:
+		syslog_priority = LOG_ERR;
+		break;
+
+	default:
+		/* Don't do this. */
+		return;
+	}
+
+#ifdef HAVE_VSYSLOG
+	vsyslog(syslog_priority, message, ap);
+#else
+	/*
+	 * Thanks, IBM, for not providing vsyslog() in AIX!
+	 *
+	 * They also warn that the syslog functions shouldn't
+	 * be used in multithreaded programs, but the only thing
+	 * obvious that seems to make the syslog_r functions
+	 * better is that they have an additional argument
+	 * that points to the information that's static to
+	 * the syslog code in non-thread-safe versions.  Most
+	 * of that data is set by openlog(); since we already
+	 * do an openlog before doing logging, and don't
+	 * change that data afterwards, I suspect that, in
+	 * practice, the regular syslog routines are OK for
+	 * us (especially given that we'd end up having one
+	 * static struct syslog_data anyway, which means we'd
+	 * just be like the non-thread-safe version).
+	 */
+	char logbuf[1024+1];
+
+	pcap_vsnprintf(logbuf, sizeof logbuf, message, ap);
+	syslog(syslog_priority, "%s", logbuf);
+#endif
+}
+#endif
+
+void rpcapd_log_set(int log_to_systemlog_arg, int log_debug_messages_arg)
+{
+	log_debug_messages = log_debug_messages_arg;
+	log_to_systemlog = log_to_systemlog_arg;
+}
+
+void rpcapd_log(log_priority priority, const char *message, ...)
+{
+	va_list ap;
+
+	if (priority != LOGPRIO_DEBUG || log_debug_messages) {
+		va_start(ap, message);
+		if (log_to_systemlog)
+		{
+			rpcapd_vlog_systemlog(priority, message, ap);
+		}
+		else
+		{
+			rpcapd_vlog_stderr(priority, message, ap);
+		}
+		va_end(ap);
+	}
+}
diff --git a/rpcapd/log.h b/rpcapd/log.h
index b3806e1..28a6cee 100644
--- a/rpcapd/log.h
+++ b/rpcapd/log.h
@@ -1,8 +1,30 @@
+/*
+ * Copyright (c) 1993, 1994, 1995, 1996, 1998
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
 #include "pcap/funcattrs.h"
 
-extern void rpcapd_log_init(void);
+extern void rpcapd_log_set(int, int);
 
 typedef enum {
+	LOGPRIO_DEBUG,
 	LOGPRIO_INFO,
 	LOGPRIO_WARNING,
 	LOGPRIO_ERROR
diff --git a/rpcapd/rpcapd-config.manfile.in b/rpcapd/rpcapd-config.manfile.in
new file mode 100644
index 0000000..1a87529
--- /dev/null
+++ b/rpcapd/rpcapd-config.manfile.in
@@ -0,0 +1,78 @@
+.\" Copyright (c) 1994, 1996, 1997
+.\"	The Regents of the University of California.  All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that: (1) source code distributions
+.\" retain the above copyright notice and this paragraph in its entirety, (2)
+.\" distributions including binary code include the above copyright notice and
+.\" this paragraph in its entirety in the documentation or other materials
+.\" provided with the distribution, and (3) all advertising materials mentioning
+.\" features or use of this software display the following acknowledgement:
+.\" ``This product includes software developed by the University of California,
+.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+.\" the University nor the names of its contributors may be used to endorse
+.\" or promote products derived from this software without specific prior
+.\" written permission.
+.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\"
+.TH RPCAPD-CONFIG @MAN_FILE_FORMATS@ "6 January 2019"
+.SH NAME
+rpcapd-config \- rpcapd configuration file format
+.SH DESCRIPTION
+An 
+.B rpcapd
+configuration file allows parameters to be set for
+.BR rpcapd (@MAN_ADMIN_COMMANDS@).
+.LP
+A # introduces a comment that runs to the end of the line.  Blank lines,
+and lines with only a comment, are ignored.  Leading and trailing white
+space on a line are also ignored.
+.LP
+Lines that set a parameter are of the form
+.IP
+\fIparameter\fB=\fIvalue\fR
+.LP
+Whitespace preceding or following the = is ignored.
+.LP
+The
+.IR parameter s
+are:
+.TP
+.B ActiveClient
+.I value
+is a host name or IP addresse, followed by a comma,
+semicolon, or space, followed by a port name and address or
+.BR DEFAULT .
+.B DEFAULT
+specifies the default active mode port for rpcapd, port 2003.
+Each
+.B ActiveClient
+line adds the host and port to the list of clients to which the server
+should connect in active mode.
+.TP
+.B PassiveClient
+.I value
+is a host name or IP addresse, followed by a comma,
+semicolon, or space, followed by a port name and address or
+.BR DEFAULT .
+.B DEFAULT
+specifies the default passive mode port for rpcapd, port 2002.
+Each
+.B PassiveClient
+line adds the host and port to the list of clients addresses and ports
+that are allowed to connect to the server in passive mode.
+.TP
+.B NullAuthPermit
+.I value
+is either
+.B YES
+or
+.BR NO .
+.B YES
+means that null authentication is permitted;
+.B No
+means that it is not permitted.
+.SH SEE ALSO
+rpcapd(@MAN_ADMIN_COMMANDS@)
diff --git a/rpcapd/rpcapd.c b/rpcapd/rpcapd.c
index e8b3b1d..430acdc 100644
--- a/rpcapd/rpcapd.c
+++ b/rpcapd/rpcapd.c
@@ -121,7 +121,7 @@
 #ifndef _WIN32
 	"[-i] "
 #endif
-	"[-s <config_file>] [-f <config_file>]\n\n"
+        "[-D] [-s <config_file>] [-f <config_file>]\n\n"
 	"  -b <address>    the address to bind to (either numeric or literal).\n"
 	"                  Default: binds to all local IPv4 and IPv6 addresses\n\n"
 	"  -p <port>       the port to bind to.\n"
@@ -144,6 +144,7 @@
 #ifndef _WIN32
 	"  -i              run in inetd mode (UNIX only)\n\n"
 #endif
+	"  -D              log debugging messages\n\n"
 	"  -s <config_file> save the current configuration to file\n\n"
 	"  -f <config_file> load the current configuration from file; all switches\n"
 	"                  specified from the command line are ignored\n\n"
@@ -160,10 +161,12 @@
 int main(int argc, char *argv[])
 {
 	char savefile[MAX_LINE + 1];		// name of the file on which we have to save the configuration
+	int log_to_systemlog = 0;		// Non-zero if we should log to the "system log" rather than the standard error
 	int isdaemon = 0;			// Non-zero if the user wants to run this program as a daemon
 #ifndef _WIN32
 	int isrunbyinetd = 0;			// Non-zero if this is being run by inetd or something inetd-like
 #endif
+	int log_debug_messages = 0;		// Non-zero if the user wants debug messages logged
 	int retval;				// keeps the returning value from several functions
 	char errbuf[PCAP_ERRBUF_SIZE + 1];	// keeps the error string, prior to be printed
 #ifndef _WIN32
@@ -177,12 +180,6 @@
 	// Initialize errbuf
 	memset(errbuf, 0, sizeof(errbuf));
 
-	if (sock_init(errbuf, PCAP_ERRBUF_SIZE) == -1)
-	{
-		SOCK_DEBUG_MESSAGE(errbuf);
-		exit(-1);
-	}
-
 	strncpy(address, RPCAP_DEFAULT_NETADDR, MAX_LINE);
 	strncpy(port, RPCAP_DEFAULT_NETPORT, MAX_LINE);
 
@@ -194,10 +191,14 @@
 	mainhints.ai_socktype = SOCK_STREAM;
 
 	// Getting the proper command line options
-	while ((retval = getopt(argc, argv, "b:dhip:4l:na:s:f:v")) != -1)
+	while ((retval = getopt(argc, argv, "b:dDhip:4l:na:s:f:v")) != -1)
 	{
 		switch (retval)
 		{
+			case 'D':
+				log_debug_messages = 1;
+				rpcapd_log_set(log_to_systemlog, log_debug_messages);
+				break;
 			case 'b':
 				strncpy(address, optarg, MAX_LINE);
 				break;
@@ -209,6 +210,8 @@
 				break;
 			case 'd':
 				isdaemon = 1;
+				log_to_systemlog = 1;
+				rpcapd_log_set(log_to_systemlog, log_debug_messages);
 				break;
 			case 'i':
 #ifdef _WIN32
@@ -216,6 +219,8 @@
 				exit(1);
 #else
 				isrunbyinetd = 1;
+				log_to_systemlog = 1;
+				rpcapd_log_set(log_to_systemlog, log_debug_messages);
 #endif
 				break;
 			case 'n':
@@ -241,12 +246,12 @@
 				{
 					tmpport = pcap_strtok_r(NULL, RPCAP_HOSTLIST_SEP, &lasts);
 
-					strlcpy(activelist[i].address, tmpaddress, MAX_LINE);
+					pcap_strlcpy(activelist[i].address, tmpaddress, MAX_LINE);
 
 					if ((tmpport == NULL) || (strcmp(tmpport, "DEFAULT") == 0)) // the user choose a custom port
-						strlcpy(activelist[i].port, RPCAP_DEFAULT_NETPORT_ACTIVE, MAX_LINE);
+						pcap_strlcpy(activelist[i].port, RPCAP_DEFAULT_NETPORT_ACTIVE, MAX_LINE);
 					else
-						strlcpy(activelist[i].port, tmpport, MAX_LINE);
+						pcap_strlcpy(activelist[i].port, tmpport, MAX_LINE);
 
 					tmpaddress = pcap_strtok_r(NULL, RPCAP_HOSTLIST_SEP, &lasts);
 
@@ -254,38 +259,44 @@
 				}
 
 				if (i > MAX_ACTIVE_LIST)
-					SOCK_DEBUG_MESSAGE("Only MAX_ACTIVE_LIST active connections are currently supported.");
+					rpcapd_log(LOGPRIO_ERROR, "Only MAX_ACTIVE_LIST active connections are currently supported.");
 
 				// I don't initialize the remaining part of the structure, since
 				// it is already zeroed (it is a global var)
 				break;
 			}
 			case 'f':
-				strlcpy(loadfile, optarg, MAX_LINE);
+				pcap_strlcpy(loadfile, optarg, MAX_LINE);
 				break;
 			case 's':
-				strlcpy(savefile, optarg, MAX_LINE);
+				pcap_strlcpy(savefile, optarg, MAX_LINE);
 				break;
 			case 'h':
 				printusage();
 				exit(0);
-				break;
+				/*NOTREACHED*/
 			default:
 				exit(1);
-				break;
+				/*NOTREACHED*/
 		}
 	}
 
 #ifndef _WIN32
 	if (isdaemon && isrunbyinetd)
 	{
-		fprintf(stderr, "rpcapd: -d and -i can't be used together\n");
+		rpcapd_log(LOGPRIO_ERROR, "rpcapd: -d and -i can't be used together");
 		exit(1);
 	}
 #endif
 
+	if (sock_init(errbuf, PCAP_ERRBUF_SIZE) == -1)
+	{
+		rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
+		exit(-1);
+	}
+
 	if (savefile[0] && fileconf_save(savefile))
-		SOCK_DEBUG_MESSAGE("Error when saving the configuration to file");
+		rpcapd_log(LOGPRIO_DEBUG, "Error when saving the configuration to file");
 
 	// If the file does not exist, it keeps the settings provided by the command line
 	if (loadfile[0])
@@ -299,9 +310,9 @@
 	state_change_event = CreateEvent(NULL, FALSE, FALSE, NULL);
 	if (state_change_event == NULL)
 	{
-		sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-		rpcapd_log(LOGPRIO_ERROR, "Can't create state change event: %s",
-		    errbuf);
+		sock_geterror("Can't create state change event", errbuf,
+		    PCAP_ERRBUF_SIZE);
+		rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 		exit(2);
 	}
 
@@ -310,9 +321,9 @@
 	//
 	if (!SetConsoleCtrlHandler(main_ctrl_event, TRUE))
 	{
-		sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-		rpcapd_log(LOGPRIO_ERROR, "Can't set control handler: %s",
-		    errbuf);
+		sock_geterror("Can't set control handler", errbuf,
+		    PCAP_ERRBUF_SIZE);
+		rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 		exit(2);
 	}
 #else
@@ -339,36 +350,30 @@
 		// by inetd or something that can run network daemons
 		// as if it were inetd (xinetd, launchd, systemd, etc.).
 		//
-		// Our standard input is the input side of a connection,
-		// and our standard output is the output side of a
-		// connection.
+		// We assume that the program that launched us just
+		// duplicated a single socket for the connection
+		// to our standard input, output, and error, so we
+		// can just use the standard input as our control
+		// socket.
 		//
-		int sockctrl_in, sockctrl_out;
+		int sockctrl;
 		int devnull_fd;
 
 		//
-		// Duplicate the standard input and output, making them
-		// the input and output side of the control connection.
+		// Duplicate the standard input as the control socket.
 		//
-		sockctrl_in = dup(0);
-		if (sockctrl_in == -1)
+		sockctrl = dup(0);
+		if (sockctrl == -1)
 		{
-			sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-			rpcapd_log(LOGPRIO_ERROR, "Can't dup standard input: %s",
-			    errbuf);
-			exit(2);
-		}
-		sockctrl_out = dup(1);
-		if (sockctrl_out == -1)
-		{
-			sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-			rpcapd_log(LOGPRIO_ERROR, "Can't dup standard output: %s",
-			    errbuf);
+			sock_geterror("Can't dup standard input", errbuf,
+			    PCAP_ERRBUF_SIZE);
+			rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 			exit(2);
 		}
 
 		//
-		// Try to set the standard input and output to /dev/null.
+		// Try to set the standard input, output, and error
+		// to /dev/null.
 		//
 		devnull_fd = open("/dev/null", O_RDWR);
 		if (devnull_fd != -1)
@@ -378,6 +383,7 @@
 			//
 			(void)dup2(devnull_fd, 0);
 			(void)dup2(devnull_fd, 1);
+			(void)dup2(devnull_fd, 2);
 			close(devnull_fd);
 		}
 
@@ -386,7 +392,13 @@
 		// This is passive mode, so we don't care whether we were
 		// told by the client to close.
 		//
-		(void)daemon_serviceloop(sockctrl_in, sockctrl_out, 0,
+		char *hostlist_copy = strdup(hostlist);
+		if (hostlist_copy == NULL)
+		{
+			rpcapd_log(LOGPRIO_ERROR, "Out of memory copying the host/port list");
+			exit(0);
+		}
+		(void)daemon_serviceloop(sockctrl, 0, hostlist_copy,
 		    nullAuthAllowed);
 
 		//
@@ -443,7 +455,7 @@
 		// If this call succeeds, it is blocking on Win32
 		//
 		if (svc_start() != 1)
-			SOCK_DEBUG_MESSAGE("Unable to start the service");
+			rpcapd_log(LOGPRIO_DEBUG, "Unable to start the service");
 
 		// When the previous call returns, the entire application has to be stopped.
 		exit(0);
@@ -504,7 +516,7 @@
 		    (void *)&activelist[i], 0, NULL);
 		if (threadId == 0)
 		{
-			SOCK_DEBUG_MESSAGE("Error creating the active child threads");
+			rpcapd_log(LOGPRIO_DEBUG, "Error creating the active child threads");
 			continue;
 		}
 		CloseHandle(threadId);
@@ -539,7 +551,7 @@
 		//
 		if (sock_initaddress((address[0]) ? address : NULL, port, &mainhints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
 		{
-			SOCK_DEBUG_MESSAGE(errbuf);
+			rpcapd_log(LOGPRIO_DEBUG, "%s", errbuf);
 			return;
 		}
 
@@ -618,7 +630,7 @@
 	//
 	// We're done; exit.
 	//
-	SOCK_DEBUG_MESSAGE(PROGRAM_NAME " is closing.\n");
+	rpcapd_log(LOGPRIO_DEBUG, PROGRAM_NAME " is closing.\n");
 
 #ifndef _WIN32
 	//
@@ -662,8 +674,9 @@
 
 	if (!SetEvent(state_change_event))
 	{
-		sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-		rpcapd_log(LOGPRIO_ERROR, "SetEvent on shutdown event failed: %s", errbuf);
+		sock_geterror("SetEvent on shutdown event failed", errbuf,
+		    PCAP_ERRBUF_SIZE);
+		rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 	}
 }
 
@@ -762,7 +775,7 @@
 	// For reference, Stevens, pg 128
 
 	while ((pid = waitpid(-1, &exitstat, WNOHANG)) > 0)
-		SOCK_DEBUG_MESSAGE("Child terminated");
+		rpcapd_log(LOGPRIO_DEBUG, "Child terminated");
 
 	return;
 }
@@ -829,14 +842,16 @@
 		event = WSACreateEvent();
 		if (event == WSA_INVALID_EVENT)
 		{
-			sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-			rpcapd_log(LOGPRIO_ERROR, "Can't create socket event: %s", errbuf);
+			sock_geterror("Can't create socket event", errbuf,
+			    PCAP_ERRBUF_SIZE);
+			rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 			exit(2);
 		}
 		if (WSAEventSelect(sock_info->sock, event, FD_ACCEPT) == SOCKET_ERROR)
 		{
-			sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-			rpcapd_log(LOGPRIO_ERROR, "Can't setup socket event: %s", errbuf);
+			sock_geterror("Can't setup socket event", errbuf,
+			    PCAP_ERRBUF_SIZE);
+			rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 			exit(2);
 		}
 		events[i] = event;
@@ -853,8 +868,9 @@
 		    WSA_INFINITE, FALSE);
 		if (ret == WSA_WAIT_FAILED)
 		{
-			sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-			rpcapd_log(LOGPRIO_ERROR, "WSAWaitForMultipleEvents failed: %s", errbuf);
+			sock_geterror("WSAWaitForMultipleEvents failed", errbuf,
+			    PCAP_ERRBUF_SIZE);
+			rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 			exit(2);
 		}
 
@@ -892,8 +908,9 @@
 			if (WSAEnumNetworkEvents(sock_info->sock,
 			    events[i], &network_events) == SOCKET_ERROR)
 			{
-				sock_geterror(NULL, errbuf, PCAP_ERRBUF_SIZE);
-				rpcapd_log(LOGPRIO_ERROR, "WSAEnumNetworkEvents failed: %s", errbuf);
+				sock_geterror("WSAEnumNetworkEvents failed",
+				    errbuf, PCAP_ERRBUF_SIZE);
+				rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 				exit(2);
 			}
 			if (network_events.lNetworkEvents & FD_ACCEPT)
@@ -906,11 +923,11 @@
 					//
 					// Yes - report it and keep going.
 					//
-					sock_fmterror(NULL,
+					sock_fmterror("Socket error",
 					    network_events.iErrorCode[FD_ACCEPT_BIT],
 					    errbuf,
 					    PCAP_ERRBUF_SIZE);
-					rpcapd_log(LOGPRIO_ERROR, "Socket error: %s", errbuf);
+					rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 					continue;
 				}
 
@@ -1033,6 +1050,20 @@
 	sock_cleanup();
 }
 
+#ifdef _WIN32
+//
+// A structure to hold the parameters to the daemon service loop
+// thread on Windows.
+//
+// (On UN*X, there is no need for this explicit copy since the
+// fork "inherits" the parent stack.)
+//
+struct params_copy {
+	SOCKET sockctrl;
+	char *hostlist;
+};
+#endif
+
 //
 // Accept a connection and start a worker thread, on Windows, or a
 // worker process, on UN*X, to handle the connection.
@@ -1048,7 +1079,7 @@
 #ifdef _WIN32
 	HANDLE threadId;			// handle for the subthread
 	u_long off = 0;
-	SOCKET *sockctrl_temp;
+	struct params_copy *params_copy = NULL;
 #else
 	pid_t pid;
 #endif
@@ -1081,23 +1112,12 @@
 
 		// Don't check for errors here, since the error can be due to the fact that the thread
 		// has been killed
-		sock_geterror("accept(): ", errbuf, PCAP_ERRBUF_SIZE);
+		sock_geterror("accept()", errbuf, PCAP_ERRBUF_SIZE);
 		rpcapd_log(LOGPRIO_ERROR, "Accept of control connection from client failed: %s",
 		    errbuf);
 		return;
 	}
 
-	//
-	// We have a connection.
-	// Check whether the connecting host is among the ones allowed.
-	//
-	if (sock_check_hostlist(hostlist, RPCAP_HOSTLIST_SEP, &from, errbuf, PCAP_ERRBUF_SIZE) < 0)
-	{
-		rpcap_senderror(sockctrl, 0, PCAP_ERR_HOSTNOAUTH, errbuf, NULL);
-		sock_close(sockctrl, NULL, 0);
-		return;
-	}
-
 #ifdef _WIN32
 	//
 	// Put the socket back into blocking mode; doing WSAEventSelect()
@@ -1108,56 +1128,75 @@
 	// First, we have to un-WSAEventSelect() this socket, and then
 	// we can turn non-blocking mode off.
 	//
+	// If this fails, we aren't guaranteed that, for example, any
+	// of the error message will be sent - if it can't be put in
+	// the socket queue, the send will just fail.
+	//
+	// So we just log the message and close the connection.
+	//
 	if (WSAEventSelect(sockctrl, NULL, 0) == SOCKET_ERROR)
 	{
-		sock_geterror("ioctlsocket(FIONBIO): ", errbuf, PCAP_ERRBUF_SIZE);
-		rpcap_senderror(sockctrl, 0, PCAP_ERR_HOSTNOAUTH, errbuf, NULL);
+		sock_geterror("WSAEventSelect()", errbuf, PCAP_ERRBUF_SIZE);
+		rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 		sock_close(sockctrl, NULL, 0);
 		return;
 	}
 	if (ioctlsocket(sockctrl, FIONBIO, &off) == SOCKET_ERROR)
 	{
-		sock_geterror("ioctlsocket(FIONBIO): ", errbuf, PCAP_ERRBUF_SIZE);
-		rpcap_senderror(sockctrl, 0, PCAP_ERR_HOSTNOAUTH, errbuf, NULL);
+		sock_geterror("ioctlsocket(FIONBIO)", errbuf, PCAP_ERRBUF_SIZE);
+		rpcapd_log(LOGPRIO_ERROR, "%s", errbuf);
 		sock_close(sockctrl, NULL, 0);
 		return;
 	}
 
 	//
-	// Allocate a location to hold the value of sockctrl.
+	// Make a copy of the host list to pass to the new thread, so that
+	// if we update it in the main thread, it won't catch us in the
+	// middle of updating it.
+	//
+	// daemon_serviceloop() will free it once it's done with it.
+	//
+	char *hostlist_copy = strdup(hostlist);
+	if (hostlist_copy == NULL)
+	{
+		rpcapd_log(LOGPRIO_ERROR, "Out of memory copying the host/port list");
+		sock_close(sockctrl, NULL, 0);
+		return;
+	}
+
+	//
+	// Allocate a location to hold the values of sockctrl.
 	// It will be freed in the newly-created thread once it's
 	// finished with it.
-	// I guess we *could* just cast sockctrl to a void *, but that's
-	// a bit ugly.
 	//
-	sockctrl_temp = (SOCKET *)malloc(sizeof (SOCKET));
-	if (sockctrl_temp == NULL)
+	params_copy = malloc(sizeof(*params_copy));
+	if (params_copy == NULL)
 	{
-		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
-		    errno, "malloc() failed");
-		rpcap_senderror(sockctrl, 0, PCAP_ERR_OPEN, errbuf, NULL);
+		rpcapd_log(LOGPRIO_ERROR, "Out of memory allocating the parameter copy structure");
+		free(hostlist_copy);
 		sock_close(sockctrl, NULL, 0);
 		return;
 	}
-	*sockctrl_temp = sockctrl;
+	params_copy->sockctrl = sockctrl;
+	params_copy->hostlist = hostlist_copy;
 
 	threadId = (HANDLE)_beginthreadex(NULL, 0,
-	    main_passive_serviceloop_thread, (void *) sockctrl_temp, 0, NULL);
+	    main_passive_serviceloop_thread, (void *) params_copy, 0, NULL);
 	if (threadId == 0)
 	{
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error creating the child thread");
-		rpcap_senderror(sockctrl, 0, PCAP_ERR_OPEN, errbuf, NULL);
+		rpcapd_log(LOGPRIO_ERROR, "Error creating the child thread");
+		free(params_copy);
+		free(hostlist_copy);
 		sock_close(sockctrl, NULL, 0);
-		free(sockctrl_temp);
 		return;
 	}
 	CloseHandle(threadId);
-#else
+#else /* _WIN32 */
 	pid = fork();
 	if (pid == -1)
 	{
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error creating the child process");
-		rpcap_senderror(sockctrl, 0, PCAP_ERR_OPEN, errbuf, NULL);
+		rpcapd_log(LOGPRIO_ERROR, "Error creating the child process: %s",
+		    strerror(errno));
 		sock_close(sockctrl, NULL, 0);
 		return;
 	}
@@ -1190,18 +1229,22 @@
 		// This is passive mode, so we don't care whether we were
 		// told by the client to close.
 		//
-		(void)daemon_serviceloop(sockctrl, sockctrl, 0,
+		char *hostlist_copy = strdup(hostlist);
+		if (hostlist_copy == NULL)
+		{
+			rpcapd_log(LOGPRIO_ERROR, "Out of memory copying the host/port list");
+			exit(0);
+		}
+		(void)daemon_serviceloop(sockctrl, 0, hostlist_copy,
 		    nullAuthAllowed);
 
-		close(sockctrl);
-
 		exit(0);
 	}
 
 	// I am the parent
 	// Close the socket for this session (must be open only in the child)
 	closesocket(sockctrl);
-#endif
+#endif /* _WIN32 */
 }
 
 /*!
@@ -1235,10 +1278,9 @@
 	hints.ai_socktype = SOCK_STREAM;
 	hints.ai_family = activepars->ai_family;
 
-	pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Connecting to host %s, port %s, using protocol %s",
-			activepars->address, activepars->port, (hints.ai_family == AF_INET) ? "IPv4":
-			(hints.ai_family == AF_INET6) ? "IPv6" : "Unspecified");
-	SOCK_DEBUG_MESSAGE(errbuf);
+	rpcapd_log(LOGPRIO_DEBUG, "Connecting to host %s, port %s, using protocol %s",
+	    activepars->address, activepars->port, (hints.ai_family == AF_INET) ? "IPv4":
+	    (hints.ai_family == AF_INET6) ? "IPv6" : "Unspecified");
 
 	// Initialize errbuf
 	memset(errbuf, 0, sizeof(errbuf));
@@ -1246,7 +1288,7 @@
 	// Do the work
 	if (sock_initaddress(activepars->address, activepars->port, &hints, &addrinfo, errbuf, PCAP_ERRBUF_SIZE) == -1)
 	{
-		SOCK_DEBUG_MESSAGE(errbuf);
+		rpcapd_log(LOGPRIO_DEBUG, "%s", errbuf);
 		return 0;
 	}
 
@@ -1256,23 +1298,34 @@
 
 		if ((sockctrl = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
 		{
-			SOCK_DEBUG_MESSAGE(errbuf);
+			rpcapd_log(LOGPRIO_DEBUG, "%s", errbuf);
 
 			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error connecting to host %s, port %s, using protocol %s",
 					activepars->address, activepars->port, (hints.ai_family == AF_INET) ? "IPv4":
 					(hints.ai_family == AF_INET6) ? "IPv6" : "Unspecified");
 
-			SOCK_DEBUG_MESSAGE(errbuf);
+			rpcapd_log(LOGPRIO_DEBUG, "%s", errbuf);
 
 			sleep_secs(RPCAP_ACTIVE_WAIT);
 
 			continue;
 		}
 
-		activeclose = daemon_serviceloop(sockctrl, sockctrl, 1,
-		    nullAuthAllowed);
-
-		sock_close(sockctrl, NULL, 0);
+		char *hostlist_copy = strdup(hostlist);
+		if (hostlist_copy == NULL)
+		{
+			rpcapd_log(LOGPRIO_ERROR, "Out of memory copying the host/port list");
+			activeclose = 0;
+			sock_close(sockctrl, NULL, 0);
+		}
+		else
+		{
+			//
+			// daemon_serviceloop() will free the copy.
+			//
+			activeclose = daemon_serviceloop(sockctrl, 1,
+			    hostlist_copy, nullAuthAllowed);
+		}
 
 		// If the connection is closed by the user explicitely, don't try to connect to it again
 		// just exit the program
@@ -1290,9 +1343,7 @@
 //
 unsigned __stdcall main_passive_serviceloop_thread(void *ptr)
 {
-	SOCKET sockctrl;
-
-	sockctrl = *((SOCKET *)ptr);
+	struct params_copy params = *(struct params_copy *)ptr;
 	free(ptr);
 
 	//
@@ -1300,9 +1351,8 @@
 	// This is passive mode, so we don't care whether we were
 	// told by the client to close.
 	//
-	(void)daemon_serviceloop(sockctrl, sockctrl, 0, nullAuthAllowed);
-
-	sock_close(sockctrl, NULL, 0);
+	(void)daemon_serviceloop(params.sockctrl, 0, params.hostlist,
+	    nullAuthAllowed);
 
 	return 0;
 }
diff --git a/rpcapd/rpcapd.inetd.conf b/rpcapd/rpcapd.inetd.conf
index e4fad5e..86823f0 100644
--- a/rpcapd/rpcapd.inetd.conf
+++ b/rpcapd/rpcapd.inetd.conf
@@ -1,2 +1 @@
 2002 stream tcp nowait root /usr/local/sbin/rpcapd rpcapd -i
-
diff --git a/rpcapd/rpcapd.manadmin.in b/rpcapd/rpcapd.manadmin.in
index 92f676c..0a9d4e0 100644
--- a/rpcapd/rpcapd.manadmin.in
+++ b/rpcapd/rpcapd.manadmin.in
@@ -61,13 +61,15 @@
 .B \-d
 ] [
 .B \-i
-] [
-.B \-s
-.I config_file
 ]
 .br
 .ti +8
 [
+.B \-D
+] [
+.B \-s
+.I config_file
+] [
 .B \-f
 .I config_file
 ]
@@ -173,8 +175,9 @@
 .BI -l " host_list"
 Only allow hosts specified in the
 .I host_list
-file to connect to this server.
-Hosts are listed one per line.
+argument to connect to this server.
+.I host_list
+is a list of host names or IP addresses, separated by commas.
 We suggest that you use use host names rather than literal IP addresses
 in order to avoid problems with different address families.
 .TP
@@ -206,13 +209,20 @@
 .B \-i
 Run in inetd mode (UNIX only).
 .TP
+.B \-D
+Log debugging messages.
+.TP
 .BI \-s " config_file"
 Save the current configuration to
-.IR config_file .
+.I config_file
+in the format specified by
+.BR rpcapd-config (@MAN_FILE_FORMATS@).
 .TP
 .BI \-f " config_file"
 Load the current configuration from
-.IR config_file ;
+.I config_file
+in the format specified by
+.BR rpcapd-config (@MAN_FILE_FORMATS@);
 all switches specified from the command line are ignored.
 .TP
 .B \-h
@@ -220,4 +230,4 @@
 .br
 .ad
 .SH "SEE ALSO"
-pcap(3PCAP)
+pcap(3PCAP), rpcapd-config(@MAN_FILE_FORMATS@)
diff --git a/rpcapd/win32-svc.c b/rpcapd/win32-svc.c
index 8cc7dc9..3a19910 100644
--- a/rpcapd/win32-svc.c
+++ b/rpcapd/win32-svc.c
@@ -33,14 +33,14 @@
 
 #include "rpcapd.h"
 #include <pcap.h>		// for PCAP_ERRBUF_SIZE
-#include "sockutils.h"		// for SOCK_DEBUG_MESSAGE
+#include "fmtutils.h"
 #include "portability.h"
 #include "fileconf.h"
+#include "log.h"
 
 static SERVICE_STATUS_HANDLE service_status_handle;
 static SERVICE_STATUS service_status;
 
-void svc_geterr(char *str);
 static void WINAPI svc_main(DWORD argc, char **argv);
 static void update_svc_status(DWORD state, DWORD progress_indicator);
 
@@ -52,32 +52,19 @@
 		{ PROGRAM_NAME, svc_main },
 		{ NULL, NULL }
 	};
+	char string[PCAP_ERRBUF_SIZE];
 
 	// This call is blocking. A new thread is created which will launch
 	// the svc_main() function
-	if ( (rc = StartServiceCtrlDispatcher(ste)) == 0)
-		svc_geterr("StartServiceCtrlDispatcher()");
+	if ((rc = StartServiceCtrlDispatcher(ste)) == 0) {
+		pcap_fmt_errmsg_for_win32_err(string, sizeof (string),
+		    GetLastError(), "StartServiceCtrlDispatcher() failed");
+		rpcapd_log(LOGPRIO_ERROR, "%s", string);
+	}
 
 	return rc; // FALSE if this is not started as a service
 }
 
-void svc_geterr(char *str)
-{
-	char message[PCAP_ERRBUF_SIZE];
-	char string[PCAP_ERRBUF_SIZE];
-	int val;
-
-	val = GetLastError();
-	FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
-				  FORMAT_MESSAGE_MAX_WIDTH_MASK,
-				  NULL, val, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-				  (LPSTR) string, PCAP_ERRBUF_SIZE, NULL);
-
-	pcap_snprintf(message, PCAP_ERRBUF_SIZE, "%s failed with error %d: %s", str, val, string);
-
-	SOCK_DEBUG_MESSAGE(message);
-}
-
 void WINAPI svc_control_handler(DWORD Opcode)
 {
 	switch(Opcode)
diff --git a/savefile.c b/savefile.c
index ec44ef4..5b1e14c 100644
--- a/savefile.c
+++ b/savefile.c
@@ -43,6 +43,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h> /* for INT_MAX */
 
 #include "pcap-int.h"
 
@@ -52,12 +53,13 @@
 
 #include "sf-pcap.h"
 #include "sf-pcapng.h"
+#include "pcap-common.h"
 
 #ifdef _WIN32
 /*
  * These aren't exported on Windows, because they would only work if both
- * WinPcap and the code using it were to use the Universal CRT; otherwise,
- * a FILE structure in WinPcap and a FILE structure in the code using it
+ * WinPcap/Npcap and the code using it were to use the Universal CRT; otherwise,
+ * a FILE structure in WinPcap/Npcap and a FILE structure in the code using it
  * could be different if they're using different versions of the C runtime.
  *
  * Instead, pcap/pcap.h defines them as macros that wrap the hopen versions,
@@ -179,7 +181,7 @@
 static u_int
 sf_sendqueue_transmit(pcap_t *p, pcap_send_queue *queue, int sync)
 {
-	strlcpy(p->errbuf, "Sending packets isn't supported on savefiles",
+	pcap_strlcpy(p->errbuf, "Sending packets isn't supported on savefiles",
 	    PCAP_ERRBUF_SIZE);
 	return (0);
 }
@@ -218,7 +220,7 @@
 static int
 sf_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
 {
-	strlcpy(p->errbuf, "Sending packets isn't supported on savefiles",
+	pcap_strlcpy(p->errbuf, "Sending packets isn't supported on savefiles",
 	    PCAP_ERRBUF_SIZE);
 	return (-1);
 }
@@ -317,6 +319,7 @@
 	{
 		pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "_fdopen");
+		_close(fd);
 		return NULL;
 	}
 
@@ -331,7 +334,34 @@
 }
 #endif
 
-static pcap_t *(*check_headers[])(bpf_u_int32, FILE *, u_int, char *, int *) = {
+/*
+ * Given a link-layer header type and snapshot length, return a
+ * snapshot length to use when reading the file; it's guaranteed
+ * to be > 0 and <= INT_MAX.
+ *
+ * XXX - the only reason why we limit it to <= INT_MAX is so that
+ * it fits in p->snapshot, and the only reason that p->snapshot is
+ * signed is that pcap_snapshot() returns an int, not an unsigned int.
+ */
+bpf_u_int32
+pcap_adjust_snapshot(bpf_u_int32 linktype, bpf_u_int32 snaplen)
+{
+	if (snaplen == 0 || snaplen > INT_MAX) {
+		/*
+		 * Bogus snapshot length; use the maximum for this
+		 * link-layer type as a fallback.
+		 *
+		 * XXX - we don't clamp snapshot lengths that are
+		 * <= INT_MAX but > max_snaplen_for_dlt(linktype),
+		 * so a capture file could cause us to allocate
+		 * a Really Big Buffer.
+		 */
+		snaplen = max_snaplen_for_dlt(linktype);
+	}
+	return snaplen;
+}
+
+static pcap_t *(*check_headers[])(const uint8_t *, FILE *, u_int, char *, int *) = {
 	pcap_check_header,
 	pcap_ng_check_header
 };
@@ -346,7 +376,7 @@
     char *errbuf)
 {
 	register pcap_t *p;
-	bpf_u_int32 magic;
+	uint8_t magic[4];
 	size_t amt_read;
 	u_int i;
 	int err;
@@ -358,16 +388,15 @@
 	 * Windows Sniffer, and Microsoft Network Monitor) all have magic
 	 * numbers that are unique in their first 4 bytes.
 	 */
-	amt_read = fread((char *)&magic, 1, sizeof(magic), fp);
+	amt_read = fread(&magic, 1, sizeof(magic), fp);
 	if (amt_read != sizeof(magic)) {
 		if (ferror(fp)) {
 			pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
 			    errno, "error reading dump file");
 		} else {
 			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-			    "truncated dump file; tried to read %lu file header bytes, only got %lu",
-			    (unsigned long)sizeof(magic),
-			    (unsigned long)amt_read);
+			    "truncated dump file; tried to read %" PRIsize " file header bytes, only got %" PRIsize,
+			    sizeof(magic), amt_read);
 		}
 		return (NULL);
 	}
diff --git a/scanner.c b/scanner.c
index 2cf65c9..4b1572f 100644
--- a/scanner.c
+++ b/scanner.c
@@ -35,11 +35,233 @@
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
 
+#ifdef yy_create_buffer
+#define pcap__create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer pcap__create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define pcap__delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer pcap__delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define pcap__scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer pcap__scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define pcap__scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string pcap__scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define pcap__scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes pcap__scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define pcap__init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer pcap__init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define pcap__flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer pcap__flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define pcap__load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state pcap__load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define pcap__switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer pcap__switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define pcap_push_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state pcap_push_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define pcap_pop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state pcap_pop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define pcap_ensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack pcap_ensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define pcap_lex_ALREADY_DEFINED
+#else
+#define yylex pcap_lex
+#endif
+
+#ifdef yyrestart
+#define pcap_restart_ALREADY_DEFINED
+#else
+#define yyrestart pcap_restart
+#endif
+
+#ifdef yylex_init
+#define pcap_lex_init_ALREADY_DEFINED
+#else
+#define yylex_init pcap_lex_init
+#endif
+
+#ifdef yylex_init_extra
+#define pcap_lex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra pcap_lex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define pcap_lex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy pcap_lex_destroy
+#endif
+
+#ifdef yyget_debug
+#define pcap_get_debug_ALREADY_DEFINED
+#else
+#define yyget_debug pcap_get_debug
+#endif
+
+#ifdef yyset_debug
+#define pcap_set_debug_ALREADY_DEFINED
+#else
+#define yyset_debug pcap_set_debug
+#endif
+
+#ifdef yyget_extra
+#define pcap_get_extra_ALREADY_DEFINED
+#else
+#define yyget_extra pcap_get_extra
+#endif
+
+#ifdef yyset_extra
+#define pcap_set_extra_ALREADY_DEFINED
+#else
+#define yyset_extra pcap_set_extra
+#endif
+
+#ifdef yyget_in
+#define pcap_get_in_ALREADY_DEFINED
+#else
+#define yyget_in pcap_get_in
+#endif
+
+#ifdef yyset_in
+#define pcap_set_in_ALREADY_DEFINED
+#else
+#define yyset_in pcap_set_in
+#endif
+
+#ifdef yyget_out
+#define pcap_get_out_ALREADY_DEFINED
+#else
+#define yyget_out pcap_get_out
+#endif
+
+#ifdef yyset_out
+#define pcap_set_out_ALREADY_DEFINED
+#else
+#define yyset_out pcap_set_out
+#endif
+
+#ifdef yyget_leng
+#define pcap_get_leng_ALREADY_DEFINED
+#else
+#define yyget_leng pcap_get_leng
+#endif
+
+#ifdef yyget_text
+#define pcap_get_text_ALREADY_DEFINED
+#else
+#define yyget_text pcap_get_text
+#endif
+
+#ifdef yyget_lineno
+#define pcap_get_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno pcap_get_lineno
+#endif
+
+#ifdef yyset_lineno
+#define pcap_set_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno pcap_set_lineno
+#endif
+
+#ifdef yyget_column
+#define pcap_get_column_ALREADY_DEFINED
+#else
+#define yyget_column pcap_get_column
+#endif
+
+#ifdef yyset_column
+#define pcap_set_column_ALREADY_DEFINED
+#else
+#define yyset_column pcap_set_column
+#endif
+
+#ifdef yywrap
+#define pcap_wrap_ALREADY_DEFINED
+#else
+#define yywrap pcap_wrap
+#endif
+
+#ifdef yyget_lval
+#define pcap_get_lval_ALREADY_DEFINED
+#else
+#define yyget_lval pcap_get_lval
+#endif
+
+#ifdef yyset_lval
+#define pcap_set_lval_ALREADY_DEFINED
+#else
+#define yyset_lval pcap_set_lval
+#endif
+
+#ifdef yyalloc
+#define pcap_alloc_ALREADY_DEFINED
+#else
+#define yyalloc pcap_alloc
+#endif
+
+#ifdef yyrealloc
+#define pcap_realloc_ALREADY_DEFINED
+#else
+#define yyrealloc pcap_realloc
+#endif
+
+#ifdef yyfree
+#define pcap_free_ALREADY_DEFINED
+#else
+#define yyfree pcap_free
+#endif
+
 /* First, we deal with  platform-specific or compiler-specific issues. */
 
 /* begin standard C headers. */
@@ -110,10 +332,16 @@
 #define UINT32_MAX             (4294967295U)
 #endif
 
+#ifndef SIZE_MAX
+#define SIZE_MAX               (~(size_t)0)
+#endif
+
 #endif /* ! C99 */
 
 #endif /* ! FLEXINT_H */
 
+/* begin standard C++ headers. */
+
 /* TODO: this is always defined, so inline it */
 #define yyconst const
 
@@ -126,12 +354,10 @@
 /* Returned upon end-of-file. */
 #define YY_NULL 0
 
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index.  If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
+/* Promotes a possibly negative, possibly signed char to an
+ *   integer in range [0..255] for use as an array index.
  */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
 
 /* An opaque pointer. */
 #ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -155,20 +381,16 @@
  * definition of BEGIN.
  */
 #define BEGIN yyg->yy_start = 1 + 2 *
-
 /* Translate the current start state into a value that can be later handed
  * to BEGIN to return to the state.  The YYSTATE alias is for lex
  * compatibility.
  */
 #define YY_START ((yyg->yy_start - 1) / 2)
 #define YYSTATE YY_START
-
 /* Action number for EOF rule of a given start state. */
 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
 /* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE pcap_restart(yyin ,yyscanner )
-
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
 #define YY_END_OF_BUFFER_CHAR 0
 
 /* Size of default input buffer. */
@@ -201,7 +423,7 @@
 #define EOB_ACT_CONTINUE_SCAN 0
 #define EOB_ACT_END_OF_FILE 1
 #define EOB_ACT_LAST_MATCH 2
-
+    
     #define YY_LESS_LINENO(n)
     #define YY_LINENO_REWIND_TO(ptr)
     
@@ -218,7 +440,6 @@
 		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
 		} \
 	while ( 0 )
-
 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
 
 #ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -278,7 +499,7 @@
 	 * possible backing-up.
 	 *
 	 * When we actually see the EOF, we change the status to "new"
-	 * (via pcap_restart()), so that the user can continue scanning by
+	 * (via yyrestart()), so that the user can continue scanning by
 	 * just pointing yyin at a new input file.
 	 */
 #define YY_BUFFER_EOF_PENDING 2
@@ -295,73 +516,67 @@
 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
                           ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
                           : NULL)
-
 /* Same as previous macro, but useful when we know that the buffer stack is not
  * NULL or when we need an lvalue. For internal use only.
  */
 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
 
-void pcap_restart (FILE *input_file ,yyscan_t yyscanner );
-void pcap__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE pcap__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void pcap__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void pcap__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void pcap_pop_buffer_state (yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
 
-static void pcap_ensure_buffer_stack (yyscan_t yyscanner );
-static void pcap__load_buffer_state (yyscan_t yyscanner );
-static void pcap__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
+static void yy_load_buffer_state ( yyscan_t yyscanner );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
 
-#define YY_FLUSH_BUFFER pcap__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
 
-YY_BUFFER_STATE pcap__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE pcap__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE pcap__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
 
-void *pcap_alloc (yy_size_t ,yyscan_t yyscanner );
-void *pcap_realloc (void *,yy_size_t ,yyscan_t yyscanner );
-void pcap_free (void * ,yyscan_t yyscanner );
-
-#define yy_new_buffer pcap__create_buffer
-
+#define yy_new_buffer yy_create_buffer
 #define yy_set_interactive(is_interactive) \
 	{ \
 	if ( ! YY_CURRENT_BUFFER ){ \
-        pcap_ensure_buffer_stack (yyscanner); \
+        yyensure_buffer_stack (yyscanner); \
 		YY_CURRENT_BUFFER_LVALUE =    \
-            pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
 	} \
 	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
 	}
-
 #define yy_set_bol(at_bol) \
 	{ \
 	if ( ! YY_CURRENT_BUFFER ){\
-        pcap_ensure_buffer_stack (yyscanner); \
+        yyensure_buffer_stack (yyscanner); \
 		YY_CURRENT_BUFFER_LVALUE =    \
-            pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
 	} \
 	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
 	}
-
 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
 
 /* Begin user sect3 */
 
 #define pcap_wrap(yyscanner) (/*CONSTCOND*/1)
 #define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
+typedef flex_uint8_t YY_CHAR;
 
 typedef int yy_state_type;
 
 #define yytext_ptr yytext_r
 
-static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
-static int yy_get_next_buffer (yyscan_t yyscanner );
-static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);
+static int yy_get_next_buffer ( yyscan_t yyscanner );
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
 
 /* Done after the current pattern has been matched and before the
  * corresponding action - sets up yytext.
@@ -372,9 +587,8 @@
 	yyg->yy_hold_char = *yy_cp; \
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 184
-#define YY_END_OF_BUFFER 185
+#define YY_NUM_RULES 183
+#define YY_END_OF_BUFFER 184
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -382,201 +596,201 @@
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static yyconst flex_int16_t yy_accept[1729] =
+static const flex_int16_t yy_accept[1724] =
     {   0,
-        0,    0,  185,  182,  113,  113,  113,  114,  182,  114,
-      114,  114,  183,  123,  123,  114,  114,  114,  114,  180,
-      180,  182,  180,  180,  180,  180,  180,  180,  180,  180,
+        0,    0,  184,  182,  113,  113,  114,  182,  114,  114,
+      123,  123,  114,  114,  114,  114,  180,  180,  182,  180,
       180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  114,  182,  117,  121,   67,    0,  180,  123,
-        0,  180,  180,  180,    0,  125,  119,  116,  118,  115,
-      120,  180,  181,  181,  180,  180,  180,   20,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  180,  114,
+      117,  121,   67,    0,  180,  123,    0,  180,  180,  180,
+        0,  125,  119,  116,  118,  115,  120,  180,  181,  180,
+      180,  180,   20,  180,  180,  180,  180,  180,  180,  180,
       180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
       180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,    7,  180,   34,   35,
 
-      180,    7,  180,   34,   35,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,   92,
-      180,   68,  180,  180,  180,  180,  180,  180,   60,  180,
-      180,  180,  180,   86,  180,  180,  180,  180,  180,  180,
-       61,  180,    4,  180,  180,  180,  180,  180,  180,  180,
-       68,  121,  180,  124,  124,  180,  123,  180,    0,  125,
-      123,  125,  125,  125,  180,  180,  180,   67,    5,  180,
-       81,  180,  180,  180,  180,  180,  180,  180,   55,  107,
-        1,    0,  180,   21,  180,  180,  180,  180,  180,  180,
       180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-
-      180,  180,   36,  180,  180,   18,   43,    0,  180,   29,
-      180,   25,   70,  180,  180,   79,   37,  180,  100,  180,
-      180,  180,  180,  101,  180,   46,   69,   82,  106,  180,
-       14,  180,    3,  180,  180,  180,  180,  180,   94,  180,
-      180,   26,  180,  105,  180,  108,   38,    2,  180,   42,
-      180,    9,  180,   10,   89,  180,   88,  180,  180,    0,
-      180,  180,  124,  180,  180,  180,  180,  123,    0,  180,
-        0,  126,  125,  125,    0,  125,    0,  125,    0,  125,
-        0,   23,  180,  180,  180,  180,   64,   16,   41,  180,
-       39,  180,  180,  180,   30,  180,   98,  180,  180,  180,
-
-      111,  180,  180,  104,  110,   45,  109,  112,   11,  180,
-       12,   13,  180,  180,  180,   32,   78,  180,   62,    3,
-       99,   47,  180,  180,  180,   74,  180,  180,  180,  180,
-       48,  180,  180,   40,  180,    6,  180,   93,  180,    8,
-       95,  180,  180,    0,  180,   53,   73,   15,  180,  124,
-      124,  180,  124,  124,  124,  180,  123,  180,    0,  125,
-      180,    0,    0,  125,    0,  125,  126,  125,    0,    0,
-        0,    0,  125,  125,  125,  125,  125,    0,  180,   56,
-       57,   58,   59,  180,   22,  180,  180,  180,  180,   31,
-      180,  180,  180,  102,  103,    0,   19,  180,  180,  180,
-
-       87,  180,   33,  180,   80,   28,   27,  180,  180,   83,
-      180,  180,  180,   50,   17,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,    0,
-      180,  180,  124,  180,  180,  180,  180,  124,  124,  180,
-      123,  180,    0,    0,  125,  125,  125,    0,    0,  126,
-      125,  125,  126,  125,    0,    0,  125,  125,  125,  125,
-      125,    0,    0,    0,    0,  125,  125,    0,  125,    0,
-      125,    0,   97,  180,  180,  180,   24,  180,  180,   77,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,    0,
-      180,  180,  180,  180,  180,   70,  180,  180,  180,  180,
-
-      180,  180,  180,   75,   76,  180,   96,  180,  180,  180,
+      180,  180,  180,  180,   92,  180,   68,  180,  180,  180,
+      180,  180,  180,   60,  180,  180,  180,  180,   86,  180,
+      180,  180,  180,  180,  180,   61,  180,    4,  180,  180,
+      180,  180,  180,  180,  180,   68,  121,  180,  124,  124,
+      180,  123,  180,    0,  125,  123,  125,  125,  125,  180,
+      180,  180,   67,    5,  180,   81,  180,  180,  180,  180,
+      180,  180,  180,   55,  107,    1,    0,  180,   21,  180,
       180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  124,  124,  180,  124,  124,  124,  124,  180,  123,
-      180,    0,  125,  125,    0,  125,    0,    0,  125,    0,
-      125,  126,  125,    0,    0,    0,  125,  125,    0,  125,
-      126,  125,    0,    0,    0,    0,    0,    0,    0,  125,
-      125,  125,  125,  125,    0,  180,  180,  180,  180,   52,
-       63,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,   71,  180,  180,   44,   84,   85,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,   36,  180,  180,
 
-      180,  180,   54,  176,  179,  178,  172,  180,  174,  173,
-      177,  180,    0,  180,  180,  124,  180,  180,  180,  124,
-      180,  123,  180,    0,    0,  125,  125,  125,  125,  125,
-      125,    0,    0,  126,  125,  125,  125,    0,    0,  125,
-      125,  125,  125,  125,    0,    0,    0,    0,    0,    0,
+       18,   43,    0,  180,   29,  180,   25,   70,  180,  180,
+       79,   37,  180,  100,  180,  180,  180,  180,  101,  180,
+       46,   69,   82,  106,  180,   14,  180,    3,  180,  180,
+      180,  180,  180,   94,  180,  180,   26,  180,  105,  180,
+      108,   38,    2,  180,   42,  180,    9,  180,   10,   89,
+      180,   88,  180,  180,    0,  180,  180,  124,  180,  180,
+      180,  180,  123,    0,  180,    0,  126,  125,  125,    0,
+      125,    0,  125,    0,  125,    0,   23,  180,  180,  180,
+      180,   64,   16,   41,  180,   39,  180,  180,  180,   30,
+      180,   98,  180,  180,  180,  111,  180,  180,  104,  110,
+
+       45,  109,  112,   11,  180,   12,   13,  180,  180,  180,
+       32,   78,  180,   62,    3,   99,   47,  180,  180,  180,
+       74,  180,  180,  180,  180,   48,  180,  180,   40,  180,
+        6,  180,   93,  180,    8,   95,  180,  180,    0,  180,
+       53,   73,   15,  180,  124,  124,  180,  124,  124,  124,
+      180,  123,  180,    0,  125,  180,    0,    0,  125,    0,
+      125,  126,  125,    0,    0,    0,    0,  125,  125,  125,
+      125,  125,    0,  180,   56,   57,   58,   59,  180,   22,
+      180,  180,  180,  180,   31,  180,  180,  180,  102,  103,
+        0,   19,  180,  180,  180,   87,  180,   33,  180,   80,
+
+       28,   27,  180,  180,   83,  180,  180,  180,   50,   17,
+      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,    0,  180,  180,  124,  180,  180,
+      180,  180,  124,  124,  180,  123,  180,    0,    0,  125,
+      125,  125,    0,    0,  126,  125,  125,  126,  125,    0,
         0,  125,  125,  125,  125,  125,    0,    0,    0,    0,
-        0,  125,  125,    0,  125,    0,  125,    0,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  128,  127,  180,  180,   72,  180,  180,
+      125,  125,    0,  125,    0,  125,    0,   97,  180,  180,
+      180,   24,  180,  180,   77,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,    0,  180,  180,  180,  180,  180,
+       70,  180,  180,  180,  180,  180,  180,  180,   75,   76,
 
-      180,  175,  171,  180,  180,  124,  124,  124,  124,  180,
-      123,  180,    0,  125,  125,    0,  125,  125,    0,  125,
-        0,    0,  125,    0,  125,  126,  125,    0,    0,    0,
-      125,  125,    0,  125,  126,  125,    0,    0,    0,    0,
-        0,  125,  125,    0,  125,  126,  125,    0,  125,  125,
-        0,    0,    0,    0,    0,    0,    0,  125,  125,  125,
-      125,  125,    0,   65,  180,   55,  133,  140,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  145,  144,  180,   66,
-       49,  180,  180,    0,  180,  180,  180,  180,  180,  123,
-
-      180,    0,    0,  125,  125,  125,  125,  125,  125,  125,
-      125,  125,    0,    0,  126,  125,  125,  125,    0,    0,
-      125,  125,  125,  125,  125,    0,    0,    0,    0,    0,
-        0,    0,  125,  125,  125,  125,  125,    0,  125,  125,
-        0,    0,    0,    0,    0,    0,    0,  125,  125,  125,
-      125,  125,    0,    0,    0,    0,    0,    0,  125,  125,
-        0,  125,    0,  125,    0,   90,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  146,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,   51,  122,  122,
-      124,  124,  180,  123,  180,    0,  125,  125,    0,  125,
-
-      125,    0,  125,  125,    0,  125,    0,  122,  125,    0,
-      125,  126,  125,    0,    0,    0,  125,  125,    0,  125,
-      126,  125,    0,    0,    0,    0,    0,  125,  125,    0,
-      125,  126,  125,    0,    0,    0,    0,    0,    0,  125,
-      125,    0,  125,  126,  125,    0,  125,  125,  125,    0,
-        0,    0,    0,    0,    0,    0,  125,  125,  125,  125,
-      125,    0,  180,  180,  180,  180,  180,  180,  180,  180,
-      138,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,   91,  122,  122,  124,  180,  122,  122,    0,
-        0,  125,  125,  125,  125,  125,  125,  125,  125,  125,
-
-      125,  125,  125,    0,  122,  126,  125,  125,  125,    0,
-        0,  125,  125,  125,  125,  125,    0,    0,    0,    0,
-        0,    0,    0,  125,  125,  125,  125,  125,    0,  125,
-      125,    0,    0,    0,    0,    0,    0,    0,  125,  125,
-      125,  125,  125,    0,  125,  125,  125,    0,    0,    0,
+      180,   96,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  124,  124,  180,  124,
+      124,  124,  124,  180,  123,  180,    0,  125,  125,    0,
+      125,    0,    0,  125,    0,  125,  126,  125,    0,    0,
+        0,  125,  125,    0,  125,  126,  125,    0,    0,    0,
         0,    0,    0,    0,  125,  125,  125,  125,  125,    0,
-        0,    0,    0,    0,    0,  125,  125,    0,  125,    0,
-      125,    0,  180,  180,  180,  142,  180,  180,  180,  180,
-      180,  180,  180,  130,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  124,  180,  123,    0,  125,  125,
-
-        0,  125,  125,    0,  125,  125,    0,  125,  125,    0,
-      125,    0,    0,    0,  125,    0,    0,  125,  126,  125,
-        0,    0,    0,  125,  125,    0,  125,  126,  125,    0,
-        0,    0,    0,    0,  125,  125,    0,  125,  126,  125,
-        0,    0,    0,    0,    0,    0,  125,  125,    0,  125,
-      126,  125,    0,    0,    0,    0,    0,    0,  125,  125,
-        0,  125,  126,  125,    0,  125,  125,  125,    0,    0,
-        0,    0,    0,    0,    0,  125,  125,  125,  125,  125,
-        0,  180,  180,  180,  180,  132,  180,  180,  180,  136,
+      180,  180,  180,  180,   52,   63,  180,  180,  180,  180,
       180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,   71,  180,  180,
+       44,   84,   85,  180,  180,  180,  180,   54,  176,  179,
 
-      180,  180,  180,  122,    0,    0,  125,  125,  125,  125,
-      125,  125,  125,  125,  125,  125,  125,  125,  125,  125,
-      125,    0,    0,    0,  126,    0,    0,  125,    0,    0,
-      125,  125,  125,    0,    0,    0,    0,    0,    0,    0,
-      125,  125,  125,    0,  125,  125,    0,    0,    0,    0,
-        0,    0,    0,  125,  125,  125,    0,  125,  125,  125,
+      178,  172,  180,  174,  173,  177,  180,    0,  180,  180,
+      124,  180,  180,  180,  124,  180,  123,  180,    0,    0,
+      125,  125,  125,  125,  125,  125,    0,    0,  126,  125,
+      125,  125,    0,    0,  125,  125,  125,  125,  125,    0,
+        0,    0,    0,    0,    0,    0,  125,  125,  125,  125,
+      125,    0,    0,    0,    0,    0,  125,  125,    0,  125,
+        0,  125,    0,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  128,  127,
+      180,  180,   72,  180,  180,  180,  175,  171,  180,  180,
+
+      124,  124,  124,  124,  180,  123,  180,    0,  125,  125,
+        0,  125,  125,    0,  125,    0,    0,  125,    0,  125,
+      126,  125,    0,    0,    0,  125,  125,    0,  125,  126,
+      125,    0,    0,    0,    0,    0,  125,  125,    0,  125,
+      126,  125,    0,  125,  125,    0,    0,    0,    0,    0,
+        0,    0,  125,  125,  125,  125,  125,    0,   65,  180,
+       55,  133,  140,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  145,  144,  180,   66,   49,  180,  180,    0,  180,
+      180,  180,  180,  180,  123,  180,    0,    0,  125,  125,
+
+      125,  125,  125,  125,  125,  125,  125,    0,    0,  126,
+      125,  125,  125,    0,    0,  125,  125,  125,  125,  125,
         0,    0,    0,    0,    0,    0,    0,  125,  125,  125,
-        0,  125,  125,  125,    0,    0,    0,    0,    0,    0,
-        0,  125,  125,  125,    0,    0,    0,    0,    0,    0,
-      125,  125,    0,  125,    0,  125,    0,  129,  141,  143,
+      125,  125,    0,  125,  125,    0,    0,    0,    0,    0,
+        0,    0,  125,  125,  125,  125,  125,    0,    0,    0,
+        0,    0,    0,  125,  125,    0,  125,    0,  125,    0,
+       90,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  146,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,   51,  122,  122,  124,  124,  180,  123,  180,
+        0,  125,  125,    0,  125,  125,    0,  125,  125,    0,
 
-      137,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  155,  180,  180,  180,    0,    0,  125,
-        0,  125,    0,  125,  125,    0,  125,  125,    0,  125,
-      125,    0,  125,  125,    0,  125,    0,    0,    0,    0,
-      125,  125,    0,  125,    0,    0,  125,  125,  125,    0,
-        0,    0,    0,  125,  125,  125,    0,    0,    0,    0,
-        0,  125,  125,  125,    0,    0,    0,    0,    0,  125,
-      125,  125,    0,    0,    0,    0,    0,  125,  125,  125,
+      125,    0,  122,  125,    0,  125,  126,  125,    0,    0,
+        0,  125,  125,    0,  125,  126,  125,    0,    0,    0,
+        0,    0,  125,  125,    0,  125,  126,  125,    0,    0,
+        0,    0,    0,    0,  125,  125,    0,  125,  126,  125,
+        0,  125,  125,  125,    0,    0,    0,    0,    0,    0,
+        0,  125,  125,  125,  125,  125,    0,  180,  180,  180,
+      180,  180,  180,  180,  180,  138,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,   91,  122,  122,
+      124,  180,  122,  122,    0,    0,  125,  125,  125,  125,
+      125,  125,  125,  125,  125,  125,  125,  125,    0,  122,
+
+      126,  125,  125,  125,    0,    0,  125,  125,  125,  125,
+      125,    0,    0,    0,    0,    0,    0,    0,  125,  125,
+      125,  125,  125,    0,  125,  125,    0,    0,    0,    0,
+        0,    0,    0,  125,  125,  125,  125,  125,    0,  125,
+      125,  125,    0,    0,    0,    0,    0,    0,    0,  125,
+      125,  125,  125,  125,    0,    0,    0,    0,    0,    0,
+      125,  125,    0,  125,    0,  125,    0,  180,  180,  180,
+      142,  180,  180,  180,  180,  180,  180,  180,  130,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  180,  124,
+      180,  123,    0,  125,  125,    0,  125,  125,    0,  125,
+
+      125,    0,  125,  125,    0,  125,    0,    0,    0,  125,
+        0,    0,  125,  126,  125,    0,    0,    0,  125,  125,
+        0,  125,  126,  125,    0,    0,    0,    0,    0,  125,
+      125,    0,  125,  126,  125,    0,    0,    0,    0,    0,
+        0,  125,  125,    0,  125,  126,  125,    0,    0,    0,
+        0,    0,    0,  125,  125,    0,  125,  126,  125,    0,
       125,  125,  125,    0,    0,    0,    0,    0,    0,    0,
-      125,  125,  125,    0,  180,  180,  180,  180,  180,  180,
+      125,  125,  125,  125,  125,    0,  180,  180,  180,  180,
+      132,  180,  180,  180,  136,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  122,    0,
 
-      147,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,    0,    0,    0,  125,  125,  125,  125,  125,  125,
-        0,    0,    0,    0,  125,  125,    0,    0,    0,    0,
-      125,  125,  125,    0,    0,    0,    0,    0,  125,  125,
-      125,  125,    0,    0,    0,    0,    0,  125,  125,  125,
-      125,    0,    0,    0,    0,    0,  125,  125,  125,  125,
-        0,    0,    0,    0,    0,  125,    0,    0,    0,    0,
-        0,  125,  125,  125,  180,  180,  180,  139,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  125,  125,  125,  125,  125,  125,  125,  125,    0,
-
-        0,    0,    0,  125,  125,    0,    0,  125,    0,    0,
-        0,  125,    0,    0,    0,  125,    0,    0,    0,  125,
-        0,    0,    0,  125,  125,  125,  125,    0,    0,    0,
-        0,    0,  125,  134,  180,  131,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  156,  180,  125,
-        0,    0,  125,  125,    0,  125,  125,  125,    0,  125,
-      125,  125,    0,  125,  125,  125,    0,  125,  125,  125,
-        0,    0,    0,    0,  125,  135,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  152,  180,  125,  125,
+        0,  125,  125,  125,  125,  125,  125,  125,  125,  125,
+      125,  125,  125,  125,  125,  125,    0,    0,    0,  126,
+        0,    0,  125,    0,    0,  125,  125,  125,    0,    0,
+        0,    0,    0,    0,    0,  125,  125,  125,    0,  125,
+      125,    0,    0,    0,    0,    0,    0,    0,  125,  125,
+      125,    0,  125,  125,  125,    0,    0,    0,    0,    0,
+        0,    0,  125,  125,  125,    0,  125,  125,  125,    0,
         0,    0,    0,    0,    0,    0,  125,  125,  125,    0,
+        0,    0,    0,    0,    0,  125,  125,    0,  125,    0,
+      125,    0,  129,  141,  143,  137,  180,  180,  180,  180,
 
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  151,    0,  125,  125,  125,  125,  125,    0,  167,
-      180,  180,  180,  180,  180,  180,  180,  154,  180,  180,
-      125,  125,  166,  180,  180,  180,  180,  180,  180,  153,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  165,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  180,  180,  180,  164,  180,  180,  180,
-      180,  180,  170,  180,  180,  180,  180,  180,  180,  180,
-      180,  180,  180,  157,  180,  180,  180,  180,  180,  150,
+      180,  180,  180,  180,  180,  180,  180,  180,  155,  180,
+      180,  180,    0,    0,  125,    0,  125,    0,  125,  125,
+        0,  125,  125,    0,  125,  125,    0,  125,  125,    0,
+      125,    0,    0,    0,    0,  125,  125,    0,  125,    0,
+        0,  125,  125,  125,    0,    0,    0,    0,  125,  125,
+      125,    0,    0,    0,    0,    0,  125,  125,  125,    0,
+        0,    0,    0,    0,  125,  125,  125,    0,    0,    0,
+        0,    0,  125,  125,  125,  125,  125,  125,    0,    0,
+        0,    0,    0,    0,    0,  125,  125,  125,    0,  180,
+      180,  180,  180,  180,  180,  147,  180,  180,  180,  180,
 
-      180,  180,  168,  180,  180,  180,  180,  180,  180,  148,
-      180,  169,  180,  163,  180,  180,  180,  180,  158,  180,
-      160,  180,  180,  162,  159,  149,  161,    0
+      180,  180,  180,  180,  180,  180,    0,    0,    0,  125,
+      125,  125,  125,  125,  125,    0,    0,    0,    0,  125,
+      125,    0,    0,    0,    0,  125,  125,  125,    0,    0,
+        0,    0,    0,  125,  125,  125,  125,    0,    0,    0,
+        0,    0,  125,  125,  125,  125,    0,    0,    0,    0,
+        0,  125,  125,  125,  125,    0,    0,    0,    0,    0,
+      125,    0,    0,    0,    0,    0,  125,  125,  125,  180,
+      180,  180,  139,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  125,  125,  125,  125,
+      125,  125,  125,  125,    0,    0,    0,    0,  125,  125,
+
+        0,    0,  125,    0,    0,    0,  125,    0,    0,    0,
+      125,    0,    0,    0,  125,    0,    0,    0,  125,  125,
+      125,  125,    0,    0,    0,    0,    0,  125,  134,  180,
+      131,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  156,  180,  125,    0,    0,  125,  125,    0,
+      125,  125,  125,    0,  125,  125,  125,    0,  125,  125,
+      125,    0,  125,  125,  125,    0,    0,    0,    0,  125,
+      135,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  152,  180,  125,  125,    0,    0,    0,    0,    0,
+        0,  125,  125,  125,    0,  180,  180,  180,  180,  180,
+
+      180,  180,  180,  180,  180,  180,  151,    0,  125,  125,
+      125,  125,  125,    0,  167,  180,  180,  180,  180,  180,
+      180,  180,  154,  180,  180,  125,  125,  166,  180,  180,
+      180,  180,  180,  180,  153,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  165,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  180,  180,
+      180,  164,  180,  180,  180,  180,  180,  170,  180,  180,
+      180,  180,  180,  180,  180,  180,  180,  180,  157,  180,
+      180,  180,  180,  180,  150,  180,  180,  168,  180,  180,
+
+      180,  180,  180,  180,  148,  180,  169,  180,  163,  180,
+      180,  180,  180,  158,  180,  160,  180,  180,  162,  159,
+      149,  161,    0
     } ;
 
-static yyconst YY_CHAR yy_ec[256] =
+static const YY_CHAR yy_ec[256] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
         1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
@@ -587,11 +801,11 @@
        21,   22,    1,    1,   23,   23,   23,   23,   23,   23,
        24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
        24,   24,   24,   24,   24,   24,   24,   25,   24,   24,
-       26,   27,   26,    7,   28,    1,   29,   30,   31,   32,
+        7,   26,    7,    7,   27,    1,   28,   29,   30,   31,
 
-       33,   34,   35,   36,   37,   24,   38,   39,   40,   41,
-       42,   43,   44,   45,   46,   47,   48,   49,   50,   51,
-       52,   24,    1,   53,    1,    1,    1,    1,    1,    1,
+       32,   33,   34,   35,   36,   24,   37,   38,   39,   40,
+       41,   42,   43,   44,   45,   46,   47,   48,   49,   50,
+       51,   24,    1,   52,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -608,2250 +822,2198 @@
         1,    1,    1,    1,    1
     } ;
 
-static yyconst YY_CHAR yy_meta[54] =
+static const YY_CHAR yy_meta[53] =
     {   0,
-        1,    2,    2,    1,    2,    1,    1,    3,    2,    4,
-        5,    6,    6,    6,    6,    6,    6,    6,    7,    3,
-        3,    3,    8,    4,    9,    3,    1,    4,    8,    8,
-        8,    8,    8,    8,    4,    4,    4,    4,    4,    4,
-        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
-        9,    4,    3
+        1,    2,    2,    1,    2,    1,    1,    1,    2,    3,
+        4,    5,    5,    5,    5,    5,    5,    5,    6,    1,
+        1,    1,    7,    3,    8,    1,    3,    7,    7,    7,
+        7,    7,    7,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    8,
+        3,    1
     } ;
 
-static yyconst flex_uint16_t yy_base[2189] =
+static const flex_int16_t yy_base[2184] =
     {   0,
-        0,    0, 5455,   53, 7856, 7856,   57, 5433,   64,   81,
-     5445, 7856, 7856,   99,   30,  151,   46, 5430,   52,  168,
-      210,  168,  160,   44,  125,   60,   31,   58,  132,  170,
-      214,  217,  229,   59,  170,  222,  237,  243,  250, 5418,
-      255, 5410, 5380,  300, 7856,    0, 7856,  316,  339,  363,
-     5413,  387,    0,  394,    0,  428, 7856, 7856, 7856, 7856,
-     7856,  296,  316,    0, 5386, 5383, 5397,    0, 5395, 5383,
-     5396, 5378, 5366, 5360, 5361, 5362, 5360, 5344, 5352, 5337,
-     5350, 5331,  116, 5341, 5312, 5297, 5295, 5299, 5305, 5294,
-     5299, 5279, 5278,   56,   68, 5263, 5261,   80, 5265, 5259,
+        0,    0, 6066, 7626, 7626, 7626, 6044,    0, 7626, 6056,
+       43,   70, 6044,   43, 6040,   75,  110,  151,    0,   70,
+       85,  102,   67,   61,   77,  105,  113,  155,  158,  170,
+       70,  176,  165,  110,  189,  148, 6025,  184, 6016, 6001,
+     7626,    0, 7626,  225,  247,  270, 6030,  293,    0,  300,
+        0,  322, 7626, 7626, 7626, 7626, 7626,  344,    0, 6003,
+     6000, 6013,    0, 6008, 5996, 6007, 6001, 5986, 5960, 5946,
+     5947, 5946, 5939, 5948, 5923, 5926, 5906,  284, 5907, 5907,
+     5875, 5868, 5857, 5849, 5816, 5811, 5801, 5794,   89,   81,
+     5765, 5752,  109, 5704, 5698, 5705,  123,  211,    0,    0,
 
-     5267,   68,  166,    0,    0,   15,  122, 5255, 5264,  189,
-     5238, 5236, 5219, 5222, 5212, 5219, 5209, 5208, 5214,    0,
-     5212,    0, 5195, 5181, 5175, 5176, 5175, 5174,  128, 5185,
-     5168, 5167, 5160,  159, 5147,  201, 5144,   38, 5137, 5149,
-        0, 5133,    0, 5112, 5111, 5094, 5090, 5078, 5048, 5062,
-     7856, 7856,  453,  477,  236,  518,  542,  566, 5071,  573,
-     5078,  597,  248, 5054, 5029, 5034, 5025,    0,    0, 5030,
-        0, 5038, 5033, 5022, 5006, 5007, 5004, 5005, 5012,    0,
-        0, 5006, 4996,    0, 5008, 4988, 4976, 4990, 4989, 4992,
-     4988, 4972, 4971, 4953, 4969, 4952, 4956, 4951, 4952, 4965,
+       99,  168, 5686, 5695,  204, 5676, 5656, 5659, 5635, 5624,
+     5610, 5600, 5591, 5597,    0, 5584,    0, 5567, 5573, 5567,
+     5568, 5567, 5567,  200, 5549, 5532, 5543, 5536,  131, 5532,
+      327, 5519,  194, 5518, 5530,    0, 5513,    0, 5510, 5509,
+     5514, 5488, 5479, 5467, 5482, 7626, 7626,  363,  386,  180,
+      426,  449,  472, 5475,  479, 5482,  502,  241, 5472, 5446,
+     5430, 5421,    0,    0, 5426,    0, 5435, 5430, 5419, 5413,
+     5414, 5374, 5375, 5382,    0,    0, 5377, 5366,    0, 5378,
+     5373, 5346, 5360, 5359, 5362, 5358, 5342, 5325, 5321, 5337,
+     5319, 5304, 5299, 5300, 5294, 5277, 5257,    0, 5262, 5254,
 
-     4950, 4934,    0, 4939, 4933,    0,    0, 4937, 4927,    0,
-     4938,    0, 4935, 4907, 4912,    0,    0, 4901,    0, 4909,
-     4917,  244, 4899,    0, 4887, 4882,    0, 4877,    0, 4880,
-        0, 4861, 4864, 4857, 4845, 4850, 4843, 4839,    0, 4837,
-     4849,    0, 4838,    0, 4837,    0,    0,    0, 4819,    0,
-      153,  156, 4830,    0,    0, 4821,    0, 4818, 4818,  637,
-     4847,  660,  684, 4830,  691,  500,  281,  715, 4821,  739,
-     4820, 4819,  747,  290, 4818, 4816,  507,  788,  811, 4815,
-        0,    0, 4775,  350, 4778, 4783,    0,    0,    0, 4781,
-        0, 4777, 4762, 4746,    0, 4746,    0, 4740, 4739, 4740,
+        0,    0, 5258, 5216,    0, 5226,    0, 5222, 5191, 5196,
+        0,    0, 5166,    0, 5175, 5182,  201, 5163,    0, 5146,
+     5161,    0, 5156,    0, 5138,    0, 5120, 5123, 5116, 5101,
+     5085, 5076, 5053,    0, 5051, 5062,    0, 5051,    0, 5018,
+        0,    0,    0, 5013,    0,  223,  240, 5023,    0,    0,
+     5014,    0, 5011, 5001,  541, 5010,  563,  586, 5006,  593,
+      352,  260,  616, 4996,  639, 4995, 4994,  647,  271, 4982,
+     4961,  408,  687,  709, 4960,    0,    0, 4936,  374, 4937,
+     4930,    0,    0,    0, 4927,    0, 4924, 4925, 4908,    0,
+     4908,    0, 4900, 4900, 4901,    0, 4886, 4853,    0,    0,
 
-        0, 4722, 4721,    0,    0,    0,    0,    0,  614, 4728,
-        0,    0, 4736, 4715, 4700,    0,    0, 4698,    0,    0,
-        0,    0, 4713, 4704, 4710,    0, 4703, 4706, 4707, 4679,
-     4675, 4667, 4639,    0, 4632,    0, 4607,    0,  275,    0,
-        0, 4599, 4592,  817, 4585,    0,    0,    0,  856,  880,
-      293,  921, 4610, 4608,  405,  944,  968,  992, 4598,  999,
-      621, 4581, 4579, 1022,  770, 1046, 1069, 4562,    0, 4553,
-      427,  428, 1093, 4552, 1117,  333, 4551, 4550, 4519,    0,
-        0,    0,    0, 4491,    0, 4504, 4502, 4469, 4460,    0,
-     4477, 4472, 4463,    0,    0, 1136,  293, 4453, 4420, 4437,
+        0,    0,    0,  519, 4858,    0,    0, 4865, 4847, 4830,
+        0,    0, 4825,    0,    0,    0,    0, 4825, 4789, 4790,
+        0, 4783, 4765, 4780, 4751, 4727, 4737, 4726,    0, 4708,
+        0, 4707,    0,  250,    0,    0, 4699, 4693,  715, 4688,
+        0,    0,    0,  753,  776,  272,  816, 4714, 4712,  360,
+      838,  861,  884, 4702,  891,  415, 4683, 4681,  913,  526,
+      936,  958, 4661,    0, 4660,  423,  511,  981, 4658, 1004,
+      294, 4657, 4664, 4602,    0,    0,    0,    0, 4596,    0,
+     4609, 4586, 4548, 4528,    0, 4543, 4537, 4517,    0,    0,
+     1023,  516, 4506, 4494, 4497,    0, 4487,    0, 4491, 4483,
 
-        0, 4427,    0, 4429, 4422,    0,    0, 4420, 4394,  292,
-     4393, 4411,  387, 4408,    0, 4390, 4382, 4394, 4368, 4362,
-     4372, 4350, 4357, 4338, 4317, 4318, 4310, 4278, 4292, 1173,
-     4310, 1196, 1220, 4305, 1227,  777,  285, 1251,  334, 1291,
-     1314, 1338, 4294, 4293, 1346,  336, 4291, 4256, 4255, 4254,
-     1387,  363, 4252, 4251,  515,  631, 1428, 4250, 1452,  364,
-     4240, 4247, 4218,  840,    0,  371, 4214,  903, 1493, 1516,
-     4212,    0,    0, 4184, 4200, 4149,    0, 4158, 4140,    0,
-     4145, 4158, 4143, 4126, 4125,  380, 4109,  427, 4108, 1121,
-     4106, 4095, 4082, 4067, 4076,    0, 4066, 4077, 4025, 4028,
+        0,    0, 4492, 4457,  515, 4455, 4456,   73, 4451,    0,
+     4439, 4431, 4407, 4381, 4373, 4360, 4340, 4356, 4349, 4320,
+     4320, 4311, 4299, 4314, 1059, 4328, 1081, 1104, 4313, 1111,
+      669,  313, 1134,  324, 1173, 1195, 1218, 4295, 4286, 1226,
+      357, 4257, 4198, 4197, 4194, 1266,  358, 4193, 4160,  663,
+      683, 1306, 4159, 1329,  420, 4155, 4161, 4135,  737,    0,
+      394, 4134,  798, 1369, 1391, 4131,    0,    0, 4104, 4088,
+     4065,    0, 4055, 4039,    0, 4043, 4056, 4009, 4022, 4020,
+      703, 4005,  728, 3990, 1008, 3987, 3974, 3993, 3981, 3960,
+        0, 3948, 3958, 3949, 3954, 3942, 3911, 3908,    0,    0,
 
-     4026, 4015, 4014,    0,    0, 4018,    0, 3981, 3973, 3986,
-     3984, 3976, 3949, 3960, 3929, 3923, 3918, 3909, 3888, 3885,
-     1541, 1565,  423, 1606, 3892, 3888,  633, 1630, 1654, 1661,
-     1685, 3877, 1692, 1716, 1739, 3876, 3857, 3856, 1762,  910,
-     1786, 1809, 3852,    0, 1274,    0,  461, 3837, 1281, 1833,
-     1856, 3833,    0,  785,  824, 3820,  485,  853,  856, 1880,
-     3810, 1904,  424, 3809, 3798,  529, 3762, 3765, 3739,    0,
-        0, 3742, 3729, 3715, 3691, 3703, 3683, 3666, 3672, 3664,
-     3643, 3632, 3633, 3619, 3601,   56,  504,  646, 3609, 3575,
-     3584, 3582,    0, 3573, 3567,    0,    0,    0, 3580, 3552,
+     3911,    0, 3906, 3898, 3900, 3879, 3869, 3860, 3860, 3850,
+     3807, 3804, 3806, 3787, 3786, 1415, 1438,  421, 1478, 3779,
+     3765,  684, 1501, 1524, 1531, 1554, 3739, 1561, 1584, 1606,
+     3737, 3734, 3689, 1628,  805, 1651, 1673, 3668,    0, 1156,
+        0,  571, 3646, 1163, 1696, 1718, 3644,    0,  747,  750,
+     3651,  601,  813,  832, 1741, 3625, 1764,  425, 3624, 3631,
+      490, 3594, 3581, 3577,    0,    0, 3563, 3565, 3533, 3532,
+     3544, 3526, 3506, 3494, 3485, 3484, 3476, 3476, 3463, 3448,
+      227,  998, 1009, 3455, 3441, 3429, 3411,    0, 3398, 3371,
+        0,    0,    0, 3384, 3362, 3367, 3353,    0,    0,    0,
 
-     3533, 3519,    0,    0,    0,    0,    0, 3523,    0,    0,
-        0, 3512, 1944, 3547, 1967, 1991, 3514, 1998,  325, 2022,
-     2046, 2053, 2077, 3505, 3474, 2085,  452, 3434, 2126,  476,
-     3393, 3386, 3385, 3365, 2167,  513, 3345,  918,  938, 2208,
-     3344, 2232,  542, 3343, 3348, 1142, 1149, 3347, 3314, 1167,
-     1169, 2273, 3305, 2297,  543, 3304, 3310, 1369,    0, 1376,
-        0,  486, 3282, 1410, 2338, 2361, 3278,    0, 2384,  374,
-      115,  389,  150,  672,  205,  610, 3235,  550,  403,  313,
-      783,  553,  761,  522,  800,  451,  578,  893,  633,  829,
-      571, 1108, 1112, 3231, 3228, 1123, 3206, 3189, 1130, 1128,
+        0,    0, 3357,    0,    0,    0, 3346, 1803, 3358, 1825,
+     1848, 3356, 1855,  330, 1878, 1901, 1908, 1931, 3347, 3346,
+     1939,  426, 3343, 1979,  449, 3342, 3324, 3323, 3321, 2019,
+      498, 3320, 1031, 1035, 2059, 3319, 2082,  538, 3318, 3295,
+     1053, 1055, 3294, 3290, 1172, 1236, 2122, 3262, 2145,  564,
+     3261, 3267, 1250,    0, 1257,    0,  624, 3237, 1288, 2185,
+     2207, 3236,    0, 2229,  301,  407,  302,  246, 1012,  522,
+      700, 3191,  539,   19,  538,  661,  569,  790,  650,  682,
+      406,  757, 1015,  834,  887,  454,  999, 1054, 3189, 3188,
+     1168, 3186, 3184, 1214, 1017,  571, 3166, 3164, 2266, 2289,
 
-      593, 3186, 3185, 2422, 2459, 2495, 2531,  634, 2555,  258,
-     2563, 2587, 3194, 2594, 2618, 2641, 3193, 2665, 2688, 3191,
-     3188, 3185, 2711, 1417, 2735, 2758, 3184,    0, 1475,    0,
-      723, 3172, 1482, 2782, 2805, 3147,    0, 1588,    0, 1595,
-        0,  724, 3146, 1927, 2829, 2852, 3135,    0,  661, 1934,
-     3122, 1290, 1425, 3114, 3111, 1490, 1510, 2876, 3101, 2900,
-      662, 3090, 3061,  636,  803,  653, 1290, 1427, 1492, 2095,
-     1604,  708,  849,  937, 2122,  872, 1605, 1944,  804, 1187,
-     1242, 2099,  936,  960, 1532, 2101,  874,  938, 1015,  962,
-     1014, 2124, 2163, 2942, 1016, 2965, 1038, 2988, 2154, 3012,
+     2311, 2346,  617, 2369,  625, 2377, 2400, 3178, 2407, 2430,
+     2452, 3168, 2475, 2497, 3167, 3163, 3133, 2519, 1295, 2542,
+     2564, 3130,    0, 1351,    0, 1119, 3105, 1358, 2587, 2609,
+     3104,    0, 1460,    0, 1467,    0, 1142, 3103, 1786, 2632,
+     2654, 3093,    0,  706, 1793, 3078, 1303, 1366, 3075, 3071,
+     1385, 1415, 2677, 3052, 2700,  752, 3042, 3048,  518,  854,
+      663, 1172, 1305, 1368, 1949, 1476,  907,  832,  930, 1974,
+      702, 1477, 1803,  951, 1950, 1951, 1953,  974,  953, 1990,
+     1993,  769,  831,  952,  997, 1074, 2013, 2018, 2741, 1127,
+     2763, 1407, 2785, 2046, 2808, 2831, 3037, 3005, 2839,  810,
 
-     3036, 3052, 3051, 3044,  686, 3049, 3085,  967, 3047, 3126,
-      969, 3046, 3045, 3020, 3017, 3167,  970, 2967, 1541, 1733,
-     3208, 2966, 3232, 1022, 2947, 2953, 2096, 2163, 2951, 2950,
-     2164, 2182, 3273, 2909, 3297, 1042, 2908, 2915, 1043, 2255,
-     2913, 2183, 2184, 2911, 2892, 2205, 2249, 3338, 2882, 3362,
-     1045, 2881, 2886,    0, 2263,    0, 2320,    0,  756, 2857,
-     2327, 3403, 3426, 2853,    0, 1061, 1062, 1087, 1111, 2337,
-     1188, 1943, 1189, 1244, 2376, 1534, 2377, 2336, 1109, 1243,
-     2402, 2013, 1306, 2096, 2378, 1446, 2375, 1245, 3451, 3474,
-     3498, 1066, 3538, 3562, 3586, 2834, 3593, 3617, 3640, 2830,
+     3004, 2879,  860, 3001, 2919,  861, 2986, 2985, 2983, 2964,
+     2959,  862, 2961, 1600, 2016, 2999, 2960, 3022,  888, 2927,
+     2932, 2054, 2056, 2930, 2929, 2092, 2097, 3062, 2920, 3085,
+      978, 2908, 2895, 1058, 2111, 2892, 2119, 2155, 2890, 2889,
+     2156, 2160, 3125, 2880, 3148, 1081, 2868, 2855,    0, 2174,
+        0, 2251,    0, 1486, 2846, 2318, 3188, 3210, 2844,    0,
+     1188, 1323, 1432, 1577, 2184, 1578, 1802, 1621, 1622, 2243,
+     1645, 2244, 2058, 1666, 1689, 2155, 2329, 1870, 2710, 2246,
+     1668, 2202, 1384, 3234, 3256, 3279, 1082, 3318, 3341, 3364,
+     2842, 3371, 3394, 3416, 2841, 3439, 3461, 2840, 3484, 3506,
 
-     3664, 3687, 2811, 3711, 3734, 2810, 2806, 2791, 3757, 2445,
-     3781, 3804, 2789,    0, 2482,    0, 1008, 2787, 2502, 3828,
-     3851, 2744,    0, 2509,    0, 2516,    0, 1153, 2741, 2523,
-     3875, 3898, 2740,    0,    0, 2923,    0, 2930,    0, 1300,
-     2718, 3067, 3922, 3945, 2717,    0,    0, 1198, 3074, 2724,
-     2399, 2417, 2721, 2701, 2453, 2454, 3969, 2670, 3993, 1285,
-     2649, 2655, 2401, 2438, 3083, 2398, 1558, 2457, 2940, 1708,
-     3084, 1557, 1385, 1709, 1508, 1754, 1710, 1755, 1778, 3120,
-     1779, 3118, 1801, 1803, 1825, 4035, 4059, 4068, 1826, 2646,
-     2643, 4086, 1287, 2624, 4127, 1288, 2600, 4168, 1315, 2599,
+     2815, 2813, 2811, 3528, 2328, 3551, 3573, 2810,    0, 2335,
+        0, 1539, 2790, 2726, 3596, 3618, 2786,    0, 2861,    0,
+     2868,    0, 1863, 2766, 2901, 3641, 3663, 2728,    0,    0,
+     2908,    0, 2941,    0, 1916, 2708, 2948, 3686, 3708, 2707,
+        0,    0, 1108, 2981, 2713, 2263, 2266, 2692, 2691, 2446,
+     2491, 3731, 2682, 3754, 1110, 2680, 2686, 2245, 2328, 2958,
+     2327, 1712, 2738, 2976, 1711, 2998, 2725, 1734, 1758, 1757,
+     2777, 1818, 1955, 1431, 2694, 1871, 3016, 1956, 1995, 2121,
+     3795, 3818, 3827, 2222, 2660, 2659, 3844, 1167, 2655, 3884,
+     1169, 2637, 3924, 1170, 2635, 3964, 1301, 2616, 2614, 2592,
 
-     4209, 1345, 2597, 2596, 2595, 4249, 4273, 1427, 2594, 2635,
-     2682, 4314, 2572, 4338, 1429, 2571, 2578, 2938, 2942, 2577,
-     2576, 3096, 3142, 4379, 2566, 4403, 1489, 2540, 2544, 1600,
-     3156, 2542, 3151, 3164, 2541, 2540, 3183, 3184, 4444, 2531,
-     4468, 1603, 2468, 2469,    0, 1605, 3255, 2438, 3203, 3205,
-     2372, 2371, 3249, 3268, 4509, 2343, 4533, 1606, 2341, 2348,
-        0, 3320,    0, 3327,    0, 1396, 2306, 3385, 4574, 4597,
-     2299,    0, 3095, 3096, 3178, 1827, 3122, 2399, 1848, 3420,
-     2959, 1849, 1850, 1872, 3248, 3380, 1874, 1896, 3490, 2014,
-     3492, 1959, 2016, 3337, 4622, 4646, 4655, 2275, 4672, 4696,
+     4003, 4026, 1306, 2572, 2711, 2738, 4066, 2570, 4089, 1365,
+     2569, 2558, 2956, 2996, 2555, 2553, 3033, 3037, 4129, 2527,
+     4152, 1412, 2525, 2513, 1475, 3051, 2510, 3059, 3095, 2508,
+     2488, 3096, 3100, 4192, 2478, 4215, 1477, 2460, 2465,    0,
+     1501, 3114, 2463, 3122, 3158, 2462, 2441, 3159, 3163, 4255,
+     2413, 4278, 1503, 2412, 2418,    0, 3177,    0, 3301,    0,
+     1962, 2409, 3308, 4318, 4340, 2408,    0, 3158, 3764, 3765,
+     2223, 3078, 3317, 2283, 3204, 2735, 2423, 2424, 2224, 3768,
+     3318, 2445, 2282, 3837, 2490, 3839, 2468, 2513, 3771, 4364,
+     4387, 4396, 2384, 4412, 4435, 4457, 2383, 4480, 4502, 2380,
 
-     4719, 2263, 4743, 4766, 2239, 4790, 4813, 2234, 4837, 4860,
-     2198, 2194, 4884, 1630, 2192, 2145, 3523, 4925, 2144, 2107,
-        0, 3530,    0, 1615, 2106, 4016, 4949, 2103, 2060,    0,
-     4023,    0, 4075,    0, 1639, 2059, 4109, 4973, 2058, 2055,
-        0,    0, 4116,    0, 4150,    0, 1669, 2000, 4157, 4997,
-     1999, 1976,    0,    0, 4191,    0, 4198,    0, 1748, 1951,
-     4232, 5021, 1945, 1913,    0,    0, 1660, 4239, 1917, 3335,
-     3399, 1914, 1897, 3400, 3420, 5045, 1882, 5069, 1661, 1842,
-     1846, 2102, 2177, 2200, 2289, 2103, 2612, 4283, 2226, 2473,
-     4266, 2680, 4348, 4267, 4331, 3249, 3271, 4289, 4332, 3399,
+     4525, 4547, 2349, 4570, 4592, 2348, 2347, 4615, 1530, 2296,
+     2289, 3869, 4655, 2212, 2209,    0, 3906,    0, 1995, 2208,
+     3913, 4678, 2188, 2164,    0, 3946,    0, 3953,    0, 2005,
+     2160, 3986, 4701, 2153, 2130,    0,    0, 3993,    0, 4048,
+        0, 2035, 2101, 4055, 4724, 2100, 2097,    0,    0, 4111,
+        0, 4118,    0, 2385, 2067, 4174, 4747, 2064, 2037,    0,
+        0, 1531, 4181, 2014, 3204, 3410, 2010, 2008, 3455, 3500,
+     4770, 1996, 4793, 1532, 1960, 1964, 2512, 2535, 2557, 2580,
+     2558, 2604, 4225, 2602, 2603, 4209, 2800, 4288, 3838, 4272,
+     3861, 4002, 4065, 4608, 3843, 2626, 2648, 4609, 4834, 1955,
 
-     2610, 2611, 4396, 5111, 1815, 5128, 5152, 1662, 1814, 5193,
-     1689, 1811, 5234, 1736, 1795, 5275, 1879, 1791, 5316, 1880,
-     1747, 1744, 4365, 5357, 1741, 1698,    0, 1697, 3634, 3681,
-     5381, 1670, 1664, 1671, 3728, 4289, 1616, 1580, 4374, 4418,
-     5405, 1568, 1565, 1552, 1938, 4432, 1527, 4441, 4478, 1508,
-     1506, 4479, 4483, 5429, 1494, 1454, 1442,    0, 1940, 4497,
-     1438, 4506, 4543, 1437, 1400, 4544, 4548, 5453, 1390, 1389,
-     1363,    0, 1941, 4562, 1362, 4571, 4591,   83,  110, 4666,
-     4667, 5477,  195,  198,  225,    0, 4907,    0, 4914,    0,
-     2006,  307, 5092, 5501,    0,  348,    0, 2474, 2635, 2657,
+     4850, 4873, 1558, 1915, 4913, 1602, 1914, 4953, 1648, 1913,
+     4993, 1695, 1911, 5033, 1715, 1910, 1909, 4241, 5073, 1880,
+     1806,    0, 1804, 3769, 4002, 5096, 1767, 1747, 1707, 4063,
+     4126, 1706, 1686, 4189, 4250, 5119, 1658, 1652, 1622, 1738,
+     4304, 1619, 4314, 4334, 1617, 1615, 4406, 4407, 5142, 1587,
+     1567, 1574,    0, 1797, 4639, 1541, 4409, 4411, 1511, 1510,
+     4451, 4496, 5165, 1480, 1479, 1446,    0, 1799, 4646,  121,
+     4541, 4803,  145,  164, 4804, 4806, 5188,  168,  308,  373,
+        0, 4820,    0, 4895,    0, 3038,  393, 4902, 5211,    0,
+      450,    0, 2649, 2671, 2757, 2779, 2801, 4803, 4830, 4912,
 
-     2659, 2681, 3003, 5107, 5162, 4670, 2703, 4291, 4356, 2682,
-     4376, 4923, 4443, 2728, 2729, 5108, 5163, 5525, 1943,    0,
-      372, 5566,    0,  399, 5590,    0,  418, 5614,    0,  480,
-     5638,    0,  520, 5662,    0,  544, 4671, 4713, 5686,  551,
-      580,  582,  610,  604, 5180,    0, 2061,  624,  643, 5216,
-        0, 5223,    0, 2062,  696,  697,    0, 5257,    0, 5264,
-        0, 2109,  698,  720,    0, 5298,    0, 5305,    0, 2142,
-      721,  749,    0, 5339,    0, 5346,    0, 2193,  750,  752,
-        0, 1995, 5548,  762, 4760, 4807,  763,  798, 4854, 5086,
-     5710,  793,    0,  804, 4508, 2751, 2752, 2774, 2775, 5146,
+     4128, 3124, 4191, 4317, 3226, 4831, 4930, 4411, 2780, 3250,
+     4832, 4924, 5234, 1802,    0,  505, 5274,    0,  532, 5297,
+        0,  548, 5320,    0,  568, 5343,    0,  600, 5366,    0,
+      618, 4849, 4910, 5389,  619,  621,  622,  657,  650, 4975,
+        0, 3264,  672,  673, 4982,    0, 5015,    0, 3379,  692,
+      755,    0, 5022,    0, 5055,    0, 3777,  759,  761,    0,
+     5062,    0, 5256,    0, 3778,  779,  818,    0, 5263,    0,
+     5411,    0, 3782,  821,  864,    0, 1826, 5418,  904, 5070,
+     5271,  905,  924, 5426, 5427, 5467,  918,    0,  945, 5072,
+     3410, 3455, 3249, 3272, 5429, 2878, 3387, 3432, 3454, 5430,
 
-     2776, 2799, 2822, 2823, 5720, 2845, 5703, 5722, 2846, 3270,
-     3489, 5755,  820,  864,    0,    0,    0,    0,    0,    0,
-     5555,    0, 2282,  880,  887,    0, 5127, 5354,  897,  930,
-        0, 1997, 5739,  931, 5563, 5724,  934,  976,    0,    0,
-     2024, 5778,  985, 5752, 5772, 1012, 1039,    0,    0, 2151,
-     5792, 1063, 5787, 5788, 1102, 1103,    0,    0, 2181, 5802,
-     1107, 5800, 5810, 1132, 1160,    0,    0, 5814,    0, 5828,
-        0, 2347, 1176,    0, 5085, 3553, 2868, 2870, 3103, 5824,
-     5827, 5837, 5838, 5839, 5826, 3379, 5843, 2892, 4573, 5736,
-     2981,    0, 7856,    0,    0,    0,    0,    0,    0, 5845,
+     3499, 5431, 5432, 3409, 4313, 5433, 5490,  939,  983,    0,
+        0,    0,    0,    0,    0, 5432,    0, 4230,  986,  987,
+        0, 5442, 5462, 1014, 1015,    0, 1850, 5512, 1046, 5464,
+     5506, 1068, 1091,    0,    0, 1852, 5520, 1125, 5528, 5529,
+     1144, 1145,    0,    0, 1854, 5529, 1182, 5537, 5538, 1210,
+     1237,    0,    0, 1993, 5552, 1239, 5546, 5547, 1241, 1242,
+        0,    0, 5568,    0, 5577,    0, 4231, 1268,    0, 4927,
+     5588, 5590, 2918, 3500, 5589, 5592, 5593, 5594, 5595, 5591,
+     3545, 5596, 3567, 5273, 5599, 3522,    0, 7626,    0,    0,
+        0,    0,    0,    0, 5622, 5624, 1277, 1279,    0, 7626,
 
-     5847, 1190, 1235,    0, 7856, 5871,    0, 7856,    0, 5887,
-        0, 7856,    0, 5894,    0, 7856,    0, 5901,    0, 7856,
-        0, 5908,    0, 7856,    0, 2270, 5915, 1236, 5923, 5924,
-     1237, 2414,    0, 2980, 5086, 2982, 3004, 5926, 5356, 5565,
-     3201, 5849, 4287, 3005, 5927, 5106, 5850, 3006, 5928,    0,
-     5927,    0, 2272, 5954, 1240,    0, 2273, 5964, 1264,    0,
-     2338, 5971, 1306,    0, 2396, 5978, 1322,    0, 2531, 5985,
-     1356,    0, 5992,    0, 7856, 3177, 6001, 3442, 3444, 3467,
-     6002, 6004, 6005, 6008, 3491, 6006, 3378, 6007, 2532, 6007,
-     1357,    0,    0,    0,    0,    0,    0, 2533, 6043, 1361,
+     5627,    0, 7626,    0, 5638,    0, 7626,    0, 5645,    0,
+     7626,    0, 5652,    0, 7626,    0, 5663,    0, 7626,    0,
+     2030, 5670, 1281, 5678, 5679, 1282, 4293,    0, 3544, 5681,
+     3589, 3590, 5682, 5685, 5686, 3611, 5687, 5688, 3613, 5683,
+     5690, 5695, 3656, 5684,    0, 5730,    0, 2059, 5737, 1316,
+        0, 2093, 5744, 1319,    0, 2096, 5751, 1378,    0, 2159,
+     5758, 1382,    0, 2347, 5765, 1402,    0, 5772,    0, 7626,
+     3657, 5689, 3658, 3680, 3702, 5781, 5783, 5784, 5696, 3703,
+     5785, 3679, 5786, 2348, 5785, 1425,    0,    0,    0,    0,
+        0,    0, 2376, 5802, 1428, 5795, 5797, 5697, 5796, 3724,
 
-     6016, 6037, 5852, 6039, 3554, 6040, 3555, 3556, 6017, 6052,
-     6056, 3419,    0,    0,    0,    0,    0,    0,    0, 3466,
-     6059, 3611, 3658, 3705, 6060, 6062, 6063, 3468, 6065, 6066,
-        0,    0, 3609, 3610, 3634, 3656, 6067, 3680, 6068, 3681,
-     6073, 6082, 6092, 6095, 3727, 6101, 3728, 6103, 3749, 5102,
-     3773, 3774, 3797, 6106, 6111, 6115, 3775, 6116, 6122, 3820,
-     6123, 6126, 6128, 3822, 6114, 6142, 6148, 3844, 3845, 6152,
-     6153, 6154, 6155, 3869, 3890, 6158, 3891, 6162, 3914, 6163,
-     6167, 3915, 3916, 3938, 6169, 6177, 4737, 6191, 3939, 6182,
-     6194, 6197, 6198, 3961, 6204, 6203, 6205, 3963, 6206, 3985,
+     5815, 3725, 4083, 5817, 5818, 5821, 3701,    0,    0,    0,
+        0,    0,    0,    0, 3790, 5824, 4254, 4563, 5825, 5826,
+     5828, 5830, 3841, 5833, 5840,    0,    0, 3881, 4356, 4450,
+     4473, 5839, 4496, 5849, 3883, 5855, 5859, 5861, 5862, 4250,
+     5873, 4406, 5851, 4540, 5874, 4585, 4541, 4586, 5877, 5875,
+     5881, 5880, 5899, 5883, 4671, 5886, 5905, 5906, 3923, 5908,
+     5909, 5912, 4672, 4695, 5919, 5930, 5920, 5931, 4718, 4741,
+     5933, 3963, 5935, 4763, 5934, 5938, 4764, 4252, 5090, 5943,
+     5953, 5956, 5961, 5112, 5958, 5962, 5967, 5971, 4587, 5981,
+     5982, 5983, 5113, 5987, 4866, 5136, 5990, 4992, 5991, 5995,
 
-     4084, 6213, 3987, 6218, 6227, 4125, 4613, 6219, 4308, 4032,
-     6228, 4033, 4615, 4085, 6238, 6229, 6240, 4784, 4166, 6239,
-     4207, 6241, 6268, 4208, 4665, 4666, 4669, 7856, 6296, 6304,
-     6308, 6311, 6314, 6317, 6320, 6323, 6326, 6329, 6332, 6335,
-     6338, 6341, 6344, 6347, 6350, 6353, 6356, 6360, 6364, 6367,
-     6370, 6373, 6376, 6379, 6382, 6385, 6388, 6392, 6396, 6399,
-     6402, 6406, 6408, 6411, 6414, 6417, 6420, 6423, 6426, 6429,
-     6432, 6436, 6438, 6441, 6445, 6450, 6454, 6457, 6461, 6464,
-     6467, 6470, 6473, 6476, 6479, 6482, 6486, 6490, 6493, 6497,
-     6501, 6506, 6510, 6512, 6516, 6519, 6523, 6526, 6529, 6533,
+     5158, 5159, 6001, 5205, 5032, 6002, 5204, 5228, 5227, 6005,
+     6006, 6015, 6009, 5291, 6014, 5313, 6016, 6045, 5314, 5336,
+     5337, 5359, 7626, 6068, 6075, 6079, 6082, 6085, 6088, 6091,
+     6094, 6097, 6100, 6103, 6106, 6109, 6112, 6115, 6118, 6121,
+     6124, 6127, 6131, 6135, 6138, 6141, 6144, 6147, 6150, 6153,
+     6156, 6159, 6163, 6167, 6170, 6173, 6177, 6179, 6182, 6185,
+     6188, 6191, 6194, 6197, 6200, 6203, 6207, 6209, 6212, 6216,
+     6221, 6225, 6228, 6232, 6235, 6238, 6241, 6244, 6247, 6250,
+     6253, 6257, 6261, 6264, 6268, 6272, 6277, 6281, 6283, 6287,
+     6290, 6294, 6297, 6300, 6304, 6306, 6309, 6312, 6315, 6318,
 
-     6535, 6538, 6541, 6544, 6547, 6550, 6553, 6556, 6559, 6562,
-     6566, 6568, 6571, 6574, 6577, 6581, 6583, 6586, 6589, 6594,
-     6598, 6603, 6607, 6609, 6613, 6616, 6620, 6625, 6629, 6632,
-     6635, 6638, 6641, 6644, 6647, 6650, 6654, 6658, 6661, 6665,
-     6669, 6674, 6678, 6680, 6684, 6687, 6691, 6694, 6699, 6703,
-     6708, 6712, 6714, 6718, 6721, 6725, 6728, 6731, 6734, 6738,
-     6740, 6743, 6748, 6752, 6755, 6758, 6761, 6764, 6767, 6770,
-     6773, 6776, 6780, 6782, 6785, 6788, 6791, 6795, 6797, 6800,
-     6803, 6806, 6809, 6813, 6815, 6818, 6821, 6824, 6829, 6833,
-     6838, 6842, 6844, 6848, 6851, 6855, 6860, 6864, 6867, 6870,
+     6321, 6324, 6327, 6330, 6333, 6337, 6339, 6342, 6345, 6348,
+     6352, 6354, 6357, 6360, 6365, 6369, 6374, 6378, 6380, 6384,
+     6387, 6391, 6396, 6400, 6403, 6406, 6409, 6412, 6415, 6418,
+     6421, 6425, 6429, 6432, 6436, 6440, 6445, 6449, 6451, 6455,
+     6458, 6462, 6465, 6470, 6474, 6479, 6483, 6485, 6489, 6492,
+     6496, 6499, 6502, 6505, 6509, 6511, 6514, 6519, 6523, 6526,
+     6529, 6532, 6535, 6538, 6541, 6544, 6547, 6551, 6553, 6556,
+     6559, 6562, 6566, 6568, 6571, 6574, 6577, 6580, 6584, 6586,
+     6589, 6592, 6595, 6600, 6604, 6609, 6613, 6615, 6619, 6622,
+     6626, 6631, 6635, 6638, 6641, 6644, 6647, 6650, 6653, 6656,
 
-     6873, 6876, 6879, 6882, 6885, 6889, 6893, 6896, 6900, 6904,
-     6909, 6913, 6915, 6919, 6922, 6926, 6929, 6934, 6938, 6943,
-     6947, 6949, 6953, 6956, 6960, 6963, 6966, 6971, 6975, 6980,
-     6984, 6986, 6990, 6993, 6997, 7000, 7003, 7006, 7010, 7012,
-     7015, 7020, 7024, 7027, 7030, 7033, 7036, 7039, 7042, 7045,
-     7048, 7051, 7054, 7057, 7061, 7063, 7066, 7069, 7072, 7075,
-     7079, 7081, 7084, 7087, 7090, 7093, 7096, 7100, 7102, 7105,
-     7108, 7111, 7114, 7117, 7121, 7123, 7126, 7129, 7132, 7135,
-     7140, 7144, 7149, 7153, 7155, 7159, 7162, 7166, 7171, 7175,
-     7178, 7181, 7184, 7187, 7190, 7193, 7196, 7199, 7202, 7206,
+     6660, 6664, 6667, 6671, 6675, 6680, 6684, 6686, 6690, 6693,
+     6697, 6700, 6705, 6709, 6714, 6718, 6720, 6724, 6727, 6731,
+     6734, 6737, 6742, 6746, 6751, 6755, 6757, 6761, 6764, 6768,
+     6771, 6774, 6777, 6781, 6783, 6786, 6791, 6795, 6798, 6801,
+     6804, 6807, 6810, 6813, 6816, 6819, 6822, 6825, 6828, 6832,
+     6834, 6837, 6840, 6843, 6846, 6850, 6852, 6855, 6858, 6861,
+     6864, 6867, 6871, 6873, 6876, 6879, 6882, 6885, 6888, 6892,
+     6894, 6897, 6900, 6903, 6906, 6911, 6915, 6920, 6924, 6926,
+     6930, 6933, 6937, 6942, 6946, 6949, 6952, 6955, 6958, 6961,
+     6964, 6967, 6970, 6973, 6977, 6981, 6984, 6988, 6992, 6997,
 
-     7210, 7213, 7217, 7221, 7226, 7230, 7232, 7236, 7239, 7243,
-     7246, 7251, 7255, 7260, 7264, 7266, 7270, 7273, 7277, 7280,
-     7283, 7288, 7292, 7297, 7301, 7303, 7307, 7310, 7314, 7317,
-     7320, 7325, 7329, 7334, 7338, 7340, 7344, 7347, 7351, 7354,
-     7357, 7360, 7364, 7366, 7369, 7372, 7377, 7381, 7384, 7387,
-     7390, 7393, 7396, 7399, 7402, 7405, 7408, 7411, 7414, 7418,
-     7422, 7425, 7428, 7432, 7435, 7438, 7442, 7444, 7447, 7450,
-     7454, 7456, 7459, 7462, 7465, 7469, 7471, 7474, 7477, 7480,
-     7484, 7486, 7489, 7492, 7495, 7499, 7501, 7504, 7507, 7512,
-     7516, 7521, 7525, 7527, 7531, 7534, 7538, 7543, 7547, 7550,
+     7001, 7003, 7007, 7010, 7014, 7017, 7022, 7026, 7031, 7035,
+     7037, 7041, 7044, 7048, 7051, 7054, 7059, 7063, 7068, 7072,
+     7074, 7078, 7081, 7085, 7088, 7091, 7096, 7100, 7105, 7109,
+     7111, 7115, 7118, 7122, 7125, 7128, 7131, 7135, 7137, 7140,
+     7143, 7148, 7152, 7155, 7158, 7161, 7164, 7167, 7170, 7173,
+     7176, 7179, 7182, 7185, 7189, 7193, 7196, 7199, 7203, 7206,
+     7209, 7213, 7215, 7218, 7221, 7225, 7227, 7230, 7233, 7236,
+     7240, 7242, 7245, 7248, 7251, 7255, 7257, 7260, 7263, 7266,
+     7270, 7272, 7275, 7278, 7283, 7287, 7292, 7296, 7298, 7302,
+     7305, 7309, 7314, 7318, 7321, 7324, 7327, 7330, 7333, 7336,
 
-     7553, 7556, 7559, 7562, 7565, 7568, 7571, 7575, 7577, 7580,
-     7584, 7589, 7593, 7594, 7597, 7602, 7606, 7611, 7615, 7616,
-     7619, 7622, 7627, 7631, 7636, 7640, 7641, 7644, 7647, 7652,
-     7656, 7661, 7665, 7666, 7669, 7672, 7677, 7681, 7686, 7690,
-     7691, 7694, 7697, 7700, 7704, 7706, 7711, 7715, 7718, 7721,
-     7724, 7727, 7730, 7733, 7737, 7742, 7746, 7747, 7750, 7753,
-     7756, 7759, 7762, 7765, 7768, 7771, 7774, 7777, 7782, 7786,
-     7789, 7792, 7795, 7799, 7803, 7807, 7811, 7815, 7818, 7821,
-     7825, 7828, 7831, 7834, 7837, 7840, 7844, 7847
+     7339, 7342, 7346, 7348, 7351, 7355, 7360, 7364, 7365, 7368,
+     7373, 7377, 7382, 7386, 7387, 7390, 7393, 7398, 7402, 7407,
+     7411, 7412, 7415, 7418, 7423, 7427, 7432, 7436, 7437, 7440,
+     7443, 7448, 7452, 7457, 7461, 7462, 7465, 7468, 7471, 7475,
+     7477, 7482, 7486, 7489, 7492, 7495, 7498, 7501, 7504, 7508,
+     7513, 7517, 7518, 7521, 7524, 7527, 7530, 7533, 7536, 7539,
+     7542, 7545, 7548, 7553, 7557, 7560, 7563, 7566, 7570, 7574,
+     7578, 7582, 7586, 7589, 7592, 7596, 7599, 7602, 7605, 7608,
+     7611, 7615, 7618
     } ;
 
-static yyconst flex_int16_t yy_def[2189] =
+static const flex_int16_t yy_def[2184] =
     {   0,
-     1728,    1, 1728, 1728, 1728, 1728, 1728, 1728, 1729, 1728,
-     1728, 1728, 1728, 1728,   14, 1728, 1728, 1728, 1728,   14,
-       20, 1730,   20,   20,   20,   20,   20,   20,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21, 1728, 1728, 1728, 1731, 1728,   21,   21,   20,
-     1732,   50,   21,   21,   21, 1728, 1728, 1728, 1728, 1728,
-     1728,   49, 1730, 1730,   52,   52,   52,   21,   21,   21,
-       21,   52,   21,   21,   52,   21,   21,   21,   52,   21,
-       21,   21,   21,   21,   52,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+     1723,    1, 1723, 1723, 1723, 1723, 1723, 1724, 1723, 1723,
+     1723,   11, 1723, 1723, 1723, 1723,   11,   17, 1725,   17,
+       17,   17,   17,   17,   17,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18, 1723,
+     1723, 1726, 1723,   18,   18,   17, 1727,   46,   18,   18,
+       18, 1723, 1723, 1723, 1723, 1723, 1723,   45, 1725,   48,
+       48,   48,   18,   18,   18,   18,   48,   18,   18,   48,
+       18,   18,   18,   48,   18,   18,   18,   18,   18,   48,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
 
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-     1728, 1728,   21,   21,  154,   21,   21,  157, 1733, 1728,
-       54, 1728,  162, 1734,   21,   21,  158,   21,   21,   21,
-      158,   21,   21,   21,   21,   21,   21,  158,   21,   21,
-       21,   21,   21,   21,   21,  158,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18, 1723, 1723,   18,   18,  149,
+       18,   18,  152, 1728, 1723,   50, 1723,  157, 1729,   18,
+       18,  153,   18,   18,   18,  153,   18,   18,   18,   18,
+       18,   18,  153,   18,   18,   18,   18,   18,   18,   18,
+      153,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
 
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,  262,  263,  158, 1735,  268,
-     1736, 1737, 1728,  273, 1738, 1739, 1728, 1728, 1728, 1740,
-     1741,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+      257,  258,  153, 1730,  263, 1731, 1732, 1723,  268, 1733,
+     1734, 1723, 1723, 1723, 1735, 1736,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
 
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-      350,   21,  263,  265,  263,  265,  265,  357, 1742, 1728,
-      356, 1743, 1744, 1728, 1728, 1728, 1728, 1745, 1746, 1747,
-     1748, 1748, 1728, 1749, 1728,  375, 1750, 1741,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,  345,   18,  258,  260,  258,
+      260,  260,  352, 1737, 1723,  351, 1738, 1739, 1723, 1723,
+     1723, 1723, 1740, 1741, 1742, 1743, 1743, 1723, 1744, 1723,
+      370, 1745, 1736,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
 
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,  432,  433,  433,  438,  432,
-      357,  441, 1751, 1752, 1728,  445, 1753, 1728, 1754, 1755,
-     1728,  451, 1756, 1757, 1758, 1758, 1728, 1759, 1728,  459,
-     1760, 1746, 1728, 1728, 1761, 1762, 1728, 1728, 1728, 1728,
-     1763, 1764,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+      427,  428,  428,  433,  427,  352,  436, 1746, 1747, 1723,
+      440, 1748, 1723, 1749, 1750, 1723,  446, 1751, 1752, 1753,
+     1753, 1723, 1754, 1723,  454, 1755, 1741, 1723, 1723, 1756,
+     1757, 1723, 1723, 1723, 1723, 1758, 1759,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
 
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,  522,   21,  433,  435,  433,  433,  528,  441,
-      530, 1765, 1728, 1728, 1728, 1766, 1767, 1768, 1728, 1728,
-     1728, 1728, 1769, 1770, 1728, 1771, 1772, 1728, 1728, 1728,
-     1728, 1773, 1774, 1775, 1775, 1761, 1762, 1776, 1776, 1728,
-     1777, 1728,  562, 1778, 1779,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,  517,   18,  428,
+      430,  428,  428,  523,  436,  525, 1760, 1723, 1723, 1723,
+     1761, 1762, 1763, 1723, 1723, 1723, 1723, 1764, 1765, 1723,
+     1766, 1767, 1723, 1723, 1723, 1723, 1768, 1769, 1770, 1770,
+     1756, 1757, 1771, 1771, 1723, 1772, 1723,  557, 1773, 1774,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
 
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,  616,  616,
-      620,  530,  622, 1780, 1781, 1728,  626, 1782, 1728,  629,
-     1783, 1728, 1784, 1785, 1728,  635, 1786, 1787, 1787, 1728,
-     1788, 1728,  642, 1789, 1790, 1791, 1791, 1792, 1793, 1794,
-     1794, 1728, 1795, 1728,  654, 1796, 1797, 1728, 1798, 1728,
-     1799, 1800, 1728, 1728, 1728, 1728, 1801, 1802,  623,  669,
-      669,  669,  669,  669,  669,  669,  669,  669,  669,  669,
-      669,  669,  669,  669,  669,  669,  669,  669,  669,  669,
-      669,  669,  669,  669,  669,  669,  669,  669,  669,  669,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       18,   18,   18,  611,  611,  615,  525,  617, 1775, 1776,
+     1723,  621, 1777, 1723,  624, 1778, 1723, 1779, 1780, 1723,
+      630, 1781, 1782, 1782, 1723, 1783, 1723,  637, 1784, 1785,
+     1786, 1786, 1787, 1788, 1789, 1789, 1723, 1790, 1723,  649,
+     1791, 1792, 1723, 1793, 1723, 1794, 1795, 1723, 1723, 1723,
+     1723, 1796, 1797,  618,  664,  664,  664,  664,  664,  664,
+      664,  664,  664,  664,  664,  664,  664,  664,  664,  664,
+      664,  664,  664,  664,  664,  664,  664,  664,  664,  664,
+      664,  664,  664,  664,  664,  664,  664,  664,  618,  618,
 
-      669,  669,  669,  669,  669,  669,  706,  706,  706,  669,
-      706,  711, 1803, 1728, 1728, 1728, 1804, 1728, 1728, 1805,
-     1806, 1807, 1728, 1728, 1728, 1728, 1808, 1809, 1728, 1810,
-     1811, 1728, 1728, 1728, 1728, 1812, 1813, 1728, 1814, 1728,
-     1815, 1816, 1728, 1728, 1728, 1728, 1817, 1818, 1819, 1728,
-     1820, 1821, 1821, 1822, 1823, 1824, 1824, 1728, 1825, 1728,
-      760, 1826, 1827, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
-     1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
-     1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828,
-     1828, 1828, 1828, 1828, 1828,  794, 1828,  794,  798,  798,
+      664,  701,  701,  701,  664,  701,  706, 1798, 1723, 1723,
+     1723, 1799, 1723, 1723, 1800, 1801, 1802, 1723, 1723, 1723,
+     1723, 1803, 1804, 1723, 1805, 1806, 1723, 1723, 1723, 1723,
+     1807, 1808, 1723, 1809, 1723, 1810, 1811, 1723, 1723, 1723,
+     1723, 1812, 1813, 1814, 1723, 1815, 1816, 1816, 1817, 1818,
+     1819, 1819, 1723, 1820, 1723,  755, 1821, 1822, 1823, 1823,
+     1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823,
+     1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823,
+     1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823, 1823,
+      789, 1823,  789,  793,  793,  795, 1824, 1825, 1723,  799,
 
-      800, 1829, 1830, 1728,  804, 1831, 1728,  807, 1832, 1728,
-      810, 1833, 1728, 1834, 1835, 1728,  816, 1836, 1837, 1837,
-     1728, 1838, 1728,  823, 1839, 1840, 1841, 1841, 1842, 1843,
-     1844, 1844, 1728, 1845, 1728,  835, 1846, 1847, 1848, 1728,
-     1849, 1850, 1850, 1851, 1852, 1853, 1853, 1728, 1854, 1728,
-      850, 1855, 1856, 1857, 1728, 1858, 1728, 1859, 1860, 1728,
-     1728, 1728, 1728, 1861, 1862, 1863, 1863, 1863, 1863, 1863,
-     1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863,
-     1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863, 1863,  889,
-      889,  891,  889,  889,  894, 1864, 1728, 1728, 1728, 1865,
+     1826, 1723,  802, 1827, 1723,  805, 1828, 1723, 1829, 1830,
+     1723,  811, 1831, 1832, 1832, 1723, 1833, 1723,  818, 1834,
+     1835, 1836, 1836, 1837, 1838, 1839, 1839, 1723, 1840, 1723,
+      830, 1841, 1842, 1843, 1723, 1844, 1845, 1845, 1846, 1847,
+     1848, 1848, 1723, 1849, 1723,  845, 1850, 1851, 1852, 1723,
+     1853, 1723, 1854, 1855, 1723, 1723, 1723, 1723, 1856, 1857,
+     1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858,
+     1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858, 1858,
+     1858, 1858, 1858, 1858,  884,  884,  886,  884,  884,  889,
+     1859, 1723, 1723, 1723, 1860, 1723, 1723, 1861, 1723, 1723,
 
-     1728, 1728, 1866, 1728, 1728, 1867, 1868, 1869, 1728, 1728,
-     1728, 1728, 1870, 1871, 1728, 1872, 1873, 1728, 1728, 1728,
-     1728, 1874, 1875, 1728, 1876, 1728, 1877, 1878, 1728, 1728,
-     1728, 1728, 1879, 1880, 1881, 1728, 1882, 1728, 1883, 1884,
-     1728, 1728, 1728, 1728, 1885, 1886, 1887, 1888, 1728, 1889,
-     1890, 1890, 1891, 1892, 1893, 1893, 1728, 1894, 1728,  959,
-     1895, 1896, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897,
-     1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897,
-     1897, 1897, 1897, 1897, 1897, 1897,  986, 1897, 1897, 1898,
-     1899, 1728,  992, 1900, 1728,  995, 1901, 1728,  998, 1902,
+     1862, 1863, 1864, 1723, 1723, 1723, 1723, 1865, 1866, 1723,
+     1867, 1868, 1723, 1723, 1723, 1723, 1869, 1870, 1723, 1871,
+     1723, 1872, 1873, 1723, 1723, 1723, 1723, 1874, 1875, 1876,
+     1723, 1877, 1723, 1878, 1879, 1723, 1723, 1723, 1723, 1880,
+     1881, 1882, 1883, 1723, 1884, 1885, 1885, 1886, 1887, 1888,
+     1888, 1723, 1889, 1723,  954, 1890, 1891, 1892, 1892, 1892,
+     1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892,
+     1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892, 1892,
+     1892,  981, 1892, 1892, 1893, 1894, 1723,  987, 1895, 1723,
+      990, 1896, 1723,  993, 1897, 1723,  996, 1898, 1723, 1899,
 
-     1728, 1001, 1903, 1728, 1904, 1728, 1728, 1007, 1905, 1906,
-     1906, 1728, 1907, 1728, 1014, 1908, 1909, 1910, 1910, 1911,
-     1912, 1913, 1913, 1728, 1914, 1728, 1026, 1915, 1916, 1917,
-     1728, 1918, 1919, 1919, 1920, 1921, 1922, 1922, 1728, 1923,
-     1728, 1041, 1924, 1925, 1926, 1927, 1728, 1928, 1929, 1929,
-     1930, 1931, 1932, 1932, 1728, 1933, 1728, 1057, 1934, 1935,
-     1936, 1728, 1937, 1728, 1938, 1939, 1728, 1728, 1728, 1728,
-     1940, 1941, 1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942,
-     1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942, 1942,
-     1942, 1942, 1942, 1942, 1942, 1095, 1942, 1943, 1728, 1728,
+     1723, 1723, 1002, 1900, 1901, 1901, 1723, 1902, 1723, 1009,
+     1903, 1904, 1905, 1905, 1906, 1907, 1908, 1908, 1723, 1909,
+     1723, 1021, 1910, 1911, 1912, 1723, 1913, 1914, 1914, 1915,
+     1916, 1917, 1917, 1723, 1918, 1723, 1036, 1919, 1920, 1921,
+     1922, 1723, 1923, 1924, 1924, 1925, 1926, 1927, 1927, 1723,
+     1928, 1723, 1052, 1929, 1930, 1931, 1723, 1932, 1723, 1933,
+     1934, 1723, 1723, 1723, 1723, 1935, 1936, 1937, 1937, 1937,
+     1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937,
+     1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937, 1937,
+     1090, 1937, 1938, 1723, 1723, 1723, 1939, 1723, 1723, 1940,
 
-     1728, 1944, 1728, 1728, 1945, 1728, 1728, 1946, 1728, 1728,
-     1947, 1948, 1728, 1113, 1949, 1950, 1728, 1728, 1951, 1952,
-     1953, 1728, 1954, 1955, 1728, 1728, 1728, 1956, 1957, 1958,
-     1728, 1959, 1728, 1960, 1961, 1728, 1728, 1728, 1962, 1963,
-     1964, 1965, 1728, 1966, 1728, 1967, 1968, 1728, 1728, 1728,
-     1969, 1970, 1971, 1972, 1728, 1973, 1728, 1974, 1975, 1728,
-     1728, 1728, 1976, 1977, 1978, 1979, 1980, 1728, 1981, 1982,
-     1982, 1983, 1984, 1985, 1985, 1728, 1986, 1728, 1178, 1987,
-     1988, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989,
-     1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989, 1989,
+     1723, 1723, 1941, 1723, 1723, 1942, 1943, 1723, 1108, 1944,
+     1945, 1723, 1723, 1946, 1947, 1948, 1723, 1949, 1950, 1723,
+     1723, 1723, 1951, 1952, 1953, 1723, 1954, 1723, 1955, 1956,
+     1723, 1723, 1723, 1957, 1958, 1959, 1960, 1723, 1961, 1723,
+     1962, 1963, 1723, 1723, 1723, 1964, 1965, 1966, 1967, 1723,
+     1968, 1723, 1969, 1970, 1723, 1723, 1723, 1971, 1972, 1973,
+     1974, 1975, 1723, 1976, 1977, 1977, 1978, 1979, 1980, 1980,
+     1723, 1981, 1723, 1173, 1982, 1983, 1984, 1984, 1984, 1984,
+     1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984,
+     1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984, 1984, 1985,
 
-     1989, 1989, 1989, 1989, 1990, 1728, 1728, 1207, 1991, 1728,
-     1210, 1992, 1728, 1213, 1993, 1728, 1216, 1994, 1728, 1219,
-     1995, 1728, 1728, 1728, 1996, 1997, 1998, 1999, 2000, 2000,
-     1728, 2001, 2002, 2003, 2004, 2004, 2005, 2006, 2007, 2007,
-     1728, 2008, 2009, 2010, 2011, 1728, 2012, 2013, 2013, 2014,
-     2015, 2016, 2016, 1728, 2017, 2018, 2019, 2020, 2021, 1728,
-     2022, 2023, 2023, 2024, 2025, 2026, 2026, 1728, 2027, 2028,
-     2029, 2030, 2031, 1728, 2032, 2033, 2033, 2034, 2035, 2036,
-     2036, 1728, 2037, 2038, 2039, 2040, 1728, 2041, 1728, 2042,
-     2043, 1728, 1728, 1728, 2044, 2045, 2046, 2047, 2047, 2047,
+     1723, 1723, 1202, 1986, 1723, 1205, 1987, 1723, 1208, 1988,
+     1723, 1211, 1989, 1723, 1214, 1990, 1723, 1723, 1723, 1991,
+     1992, 1993, 1994, 1995, 1995, 1723, 1996, 1997, 1998, 1999,
+     1999, 2000, 2001, 2002, 2002, 1723, 2003, 2004, 2005, 2006,
+     1723, 2007, 2008, 2008, 2009, 2010, 2011, 2011, 1723, 2012,
+     2013, 2014, 2015, 2016, 1723, 2017, 2018, 2018, 2019, 2020,
+     2021, 2021, 1723, 2022, 2023, 2024, 2025, 2026, 1723, 2027,
+     2028, 2028, 2029, 2030, 2031, 2031, 1723, 2032, 2033, 2034,
+     2035, 1723, 2036, 1723, 2037, 2038, 1723, 1723, 1723, 2039,
+     2040, 2041, 2042, 2042, 2042, 2042, 2042, 2042, 2042, 2042,
 
-     2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
-     2047, 2047, 2047, 2047, 2047, 2047, 2047, 1728, 1318, 2048,
-     2049, 1728, 2050, 2051, 1728, 2052, 2053, 1728, 2054, 2055,
-     1728, 2056, 2057, 1728, 2058, 2059, 2060, 2060, 1728, 2061,
-     2062, 2063, 2064, 2065, 1728, 2066, 2067, 1728, 2068, 1728,
-     2069, 1728, 2070, 2071, 1728, 2072, 2073, 1728, 2074, 1728,
-     2075, 2076, 1728, 2077, 2078, 1728, 2079, 1728, 2080, 2081,
-     1728, 2082, 2083, 1728, 2084, 1728, 2085, 2086, 1728, 2087,
-     2088, 2089, 1728, 2090, 2091, 2091, 2092, 2093, 2094, 2094,
-     1728, 2095, 2096, 2097, 2098, 2098, 2098, 2098, 2098, 2098,
+     2042, 2042, 2042, 2042, 2042, 2042, 2042, 2042, 2042, 2042,
+     2042, 2042, 1723, 1313, 2043, 2044, 1723, 2045, 2046, 1723,
+     2047, 2048, 1723, 2049, 2050, 1723, 2051, 2052, 1723, 2053,
+     2054, 2055, 2055, 1723, 2056, 2057, 2058, 2059, 2060, 1723,
+     2061, 2062, 1723, 2063, 1723, 2064, 1723, 2065, 2066, 1723,
+     2067, 2068, 1723, 2069, 1723, 2070, 2071, 1723, 2072, 2073,
+     1723, 2074, 1723, 2075, 2076, 1723, 2077, 2078, 1723, 2079,
+     1723, 2080, 2081, 1723, 2082, 2083, 2084, 1723, 2085, 2086,
+     2086, 2087, 2088, 2089, 2089, 1723, 2090, 2091, 2092, 2093,
+     2093, 2093, 2093, 2093, 2093, 2093, 2093, 2093, 2093, 2093,
 
-     2098, 2098, 2098, 2098, 2098, 2098, 2098, 2098, 2098, 2098,
-     2098, 1728, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106,
-     1728, 2107, 2108, 1728, 2109, 2110, 2111, 2111, 2112, 2113,
-     2114, 2115, 1728, 2116, 2117, 2117, 2118, 2119, 2120, 2121,
-     2122, 1728, 2123, 2124, 2124, 2125, 2126, 2127, 2128, 2129,
-     1728, 2130, 2131, 2131, 2132, 2133, 2134, 2135, 2136, 1728,
-     2137, 2138, 2138, 2139, 2140, 2141, 2142, 1728, 2143, 1728,
-     2144, 2145, 1728, 2146, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2148, 1728, 2149, 2150, 2151, 2152, 2153, 2154, 2155,
+     2093, 2093, 2093, 2093, 2093, 2093, 1723, 2094, 2095, 2096,
+     2097, 2098, 2099, 2100, 2101, 1723, 2102, 2103, 1723, 2104,
+     2105, 2106, 2106, 2107, 2108, 2109, 2110, 1723, 2111, 2112,
+     2112, 2113, 2114, 2115, 2116, 2117, 1723, 2118, 2119, 2119,
+     2120, 2121, 2122, 2123, 2124, 1723, 2125, 2126, 2126, 2127,
+     2128, 2129, 2130, 2131, 1723, 2132, 2133, 2133, 2134, 2135,
+     2136, 2137, 1723, 2138, 1723, 2139, 2140, 1723, 2141, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2143, 1723, 2144, 2145,
+     2146, 2147, 2148, 2149, 2150, 2150, 2151, 2152, 2153, 1723,
 
-     2155, 2156, 2157, 2158, 1728, 1728, 2159, 1728, 2160, 1728,
-     2161, 1728, 2162, 1728, 2163, 1728, 2164, 1728, 2165, 1728,
-     2166, 1728, 2167, 1728, 2142, 2168, 1728, 2143, 2169, 2169,
-     2144, 2145, 2170, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2171,
-     1728, 2172, 2173, 1728, 2159, 2160, 2174, 1728, 2161, 2162,
-     2175, 1728, 2163, 2164, 2176, 1728, 2165, 2166, 2177, 1728,
-     2167, 2178, 1728, 2179, 1728, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2180, 1728,
-     2172, 2181, 2182, 2183, 2184, 2185, 2178, 2186, 1728, 2179,
+     1723, 2154, 1723, 2155, 1723, 2156, 1723, 2157, 1723, 2158,
+     1723, 2159, 1723, 2160, 1723, 2161, 1723, 2162, 1723, 2137,
+     2163, 1723, 2138, 2164, 2164, 2139, 2140, 2165, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2166, 1723, 2167, 2168, 1723, 2154,
+     2155, 2169, 1723, 2156, 2157, 2170, 1723, 2158, 2159, 2171,
+     1723, 2160, 2161, 2172, 1723, 2162, 2173, 1723, 2174, 1723,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2175, 1723, 2167, 2176, 2177, 2178, 2179,
+     2180, 2173, 2181, 1723, 2174, 2142, 2142, 2142, 2142, 2142,
 
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2187, 2181, 2182, 2183, 2184, 2185, 2188, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2187, 2188, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2182, 2176, 2177,
+     2178, 2179, 2180, 2183, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2182, 2183, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
 
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147, 2147,
-     2147, 2147, 2147, 2147, 2147, 2147, 2147,    0, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
+     2142, 2142,    0, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
 
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
 
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
 
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
 
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723
     } ;
 
-static yyconst flex_uint16_t yy_nxt[7910] =
+static const flex_int16_t yy_nxt[7679] =
     {   0,
-        4,    5,    6,    7,    8,    9,   10,   11,   12,   12,
-       13,   14,   15,   15,   15,   15,   15,   15,   16,   17,
-       18,   19,   20,   21,   21,   12,   22,   13,   23,   24,
-       25,   26,   27,   28,   29,   30,   31,   21,   32,   33,
-       34,   35,   36,   21,   37,   38,   39,   40,   41,   42,
-       21,   21,   43,   44,   53,  211,   44,   44,   44,   44,
-       44,  212,   44,   44,   44,   57,   58,   44,  248,   44,
-       44,   44,   60,   61,   72,   44,   83,   84,  249,   44,
-       53,   44,   44,   44,   44,  206,   44,   44,   73,   85,
-       44,  117,   79, 1157,   86,   74,   80,  686,  195,   44,
+        4,    5,    6,    5,    7,    8,    9,   10,    9,    9,
+        4,   11,   12,   12,   12,   12,   12,   12,   13,   14,
+       15,   16,   17,   18,   18,   19,    4,   20,   21,   22,
+       23,   24,   25,   26,   27,   28,   18,   29,   30,   31,
+       32,   33,   18,   34,   35,   36,   37,   38,   39,   18,
+       18,   40,   44,   45,   46,   46,   46,   46,   46,   46,
+       46,   47,   53,   54,   49,   48,   49,   50,  769,   51,
+       48,   48,   48,   48,   48,   48,   49,   49,   49,   49,
+       49,   49,   49,   49,   49,   49,   49,   49,   49,   49,
+       49,   49,   50,   49,   49,   56,   57,   60,   74,   61,
 
-      118,  196,   81,  687,  197,   82,  198,   44,   48,   49,
-       50,   50,   50,   50,   50,   50,   50,   51,  207,  201,
-      942,   52,   53,   54,  202,  182,   55,   52,   52,   52,
-       52,   52,   52,   53,   53,   53,   53,   53,   53,   53,
-       53,   53,   53,   53,   53,   53,   53,   53,   53,   54,
-       53,   44,  183,   75,   44,  766,   44,   44,  184,  236,
-       87,   53,  213,   76,   88,  344,   77,  214,   63,   56,
-       78,   63,  237,   63,   63,  208,   89,   44,   62,   52,
-       52,   52,   52,   52,   52,   52,   63,  242,   65,  345,
-       66,   67,   53,  768,   63,   68,   53,  342,  119,  343,
+       62,  112,   75,  499,   63,   78,   79,   80,   76,   64,
+      113,   77,   81,   65,   67,   66,  192,  500,  193,   49,
+       58,   48,   48,   48,   48,   48,   48,   48,   68,   70,
+      190, 1150,   82,  191,   49,   69,   83,  124,  206,   71,
+      201,  125,   72,   85,  207,   86,   73,  196,   84,  126,
+       87,   88,  197,   89,  127, 1152,  128,   90,  237,   49,
+       51,   49,   49,   49,   49,   49,   49,   49,   49, 1723,
+       99,  100,  202,   49,  937,  136,  238,  137,   49,   49,
+       49,   49,   49,   49,   91,  101, 1330,   92,   93,  102,
+       94,  138,   95,  103,   96,  104,   97,  106,  139,   98,
 
-       69,   90,  209,   91,   70,  243,   71,  210,   92,   93,
-      120,   94,  121, 1335,  122,   95,  453,  123,   53,   55,
-       53,   53,   53,   53,   53,   53,   53,   53, 1728,  104,
-      105,  217,   53,  770,  218, 1161,  219,  245,   53,   53,
-       53,   53,   53,   53,   96,  106,  246,   97,   98,  107,
-       99,   53,  100,  108,  101,  109,  102,  111,  124,  103,
-       53,  112,  110,  125,  126,  129,  127,  128,  799,  130,
-      113,  114, 1728,  134,  115,  324,  116,  131,  141,  135,
-      142,  136,  132,  137,  133,  146,   53,  138,  325,  139,
-      140,   53,  355,  147,  143,   53,  527,  148, 1728,  149,
+      119,  107,  105,  114,   49,  120,  121,  208,  122,  123,
+      108,  109,  209,  141,  110,  115,  111,  116,  129,  117,
+      203,  142,  118,  243,  130,  143,  131,  144,  132,   49,
+      231,  319,  133,  244,  134,  135,  148,  148,  148,  148,
+      148,  148,  148,  232,  320,  212,  204,  148,  213,  339,
+      214,  205,  148,  148,  148,  148,  148,  148,  149,  150,
+      150,  150,  150,  150,  150, 1723,  337,  681,  338,  151,
+       49,  350,  340,  682,  151,  151,  151,  151,  151,  151,
+       45,  152,  152,  152,  152,  152,  152,  152,  763,  412,
+     1723,   49,  153,  177,  413, 1723,   49,  153,  153,  153,
 
-       44,  144,  490,   44,   53,   44,   44,  156,  156,  156,
-      156,  156,  156,  156, 1728,  417,   63,   53,   44,   63,
-      418,   63,   63,  491,  500, 1070,   44,  153,  153,  153,
-      153,  153,  153,  153,   63,   53,  708,  501,  153,  492,
-     1728,  775,   63,   53,  153,  153,  153,  153,  153,  153,
-      154,  155,  155,  155,  155,  155,  155, 1728,   53,   53,
-     1728,  156,  380,  381,  382,  383, 1295,  156,  156,  156,
-      156,  156,  156,   49,  157,  157,  157,  157,  157,  157,
-      157,  277,  384, 1728,   53,  158, 1728, 1728, 1728,  279,
-     1413,  158,  158,  158,  158,  158,  158,   62,  158,  158,
+      153,  153,  153,   58,  153,  153,  153,  153,  153,  153,
+      153,  156,  156,  156,  156,  156,  156,  156, 1723,  178,
+     1723,   49,  156,   49,  522,  179,  448,  156,  156,  156,
+      156,  156,  156,  157,  158,  158,  158,  158,  158,  158,
+       49,  703,  762, 1723,  159,  760,   49,   49,   49,  159,
+      159,  159,  159,  159,  159,  151,  151,  151,  151,  151,
+      151,  151,  240,  347,  347,  347,  347,  347,  347,  347,
+      432,  241,  255,   49,  256,  256,  256,  256,  256,  256,
+      256, 1723, 1723, 1156,  260,  256,  375,  376,  377,  378,
+      256,  256,  256,  256,  256,  256,  257,  258,  258,  258,
 
-      158,  158,  158,  158,  158,  161,  161,  161,  161,  161,
-      161,  161,  576, 1728, 1728,  437,  161, 1323,  504,  765,
-       53,  577,  161,  161,  161,  161,  161,  161,   44,  265,
-      767,   44,  505,   44,   44,   53, 1326,  464,  464,  162,
-      163,  163,  163,  163,  163,  163,   44,   53, 1728,   53,
-      164,  465, 1728,  774,   44,  265,  164,  164,  164,  164,
-      164,  164,  260,  579,  261,  261,  261,  261,  261,  261,
-      261,  365,  580,   53, 1728,  261, 1728,  465, 1728,  535,
-      781,  261,  261,  261,  261,  261,  261,  262,  263,  263,
-      263,  263,  263,  263,  263,  277,  468,   53, 1329,  264,
+      258,  258,  258,  258,  272,  379, 1723, 1723,  259,  260,
+      260, 1065,  274,  259,  259,  259,  259,  259,  259,  366,
+      367,  367,  367,  367,  367,  367,  435,  435,  435,  435,
+      435,  435,  435,  459,  776,  260,  261,  259,  259,  259,
+      259,  259,  259,  259, 1723,   49,  761,  460,  259, 1723,
+     1723,   49,   49,  259,  259,  259,  259,  259,  259,  262,
+      263,  263,  263,  263,  263,  263,  263,  264, 1290, 1723,
+       49,  265,  460, 1723, 1723, 1723,  265,  265,  265,  265,
+      265,  265,   49,  265,  265,  265,  265,  265,  265,  265,
+      268,  269,  269,  269,  269,  269,  269,  270, 1723,   49,
 
-     1728,  265, 1728, 1728,  470,  264,  264,  264,  264,  264,
-      264,  352,  352,  352,  352,  352,  352,  352,  371,  372,
-      372,  372,  372,  372,  372,  545, 1728,  265,  266,  264,
-      264,  264,  264,  264,  264,  264,  688, 1728, 1332,  546,
-      264,  380,  381,  382,  383,  689,  264,  264,  264,  264,
-      264,  264,  267,  268,  268,  268,  268,  268,  268,  268,
-      269,  779, 1335, 1728,  270,  546, 1728, 1728,   53, 1413,
-      270,  270,  270,  270,  270,  270,   53,  270,  270,  270,
-      270,  270,  270,  270,  273,  274,  274,  274,  274,  274,
-      274,  275, 1728, 1728,  773,  276,   53,  777,  453,   53,
+      781,  271,  375,  376,  377,  378,  271,  271,  271,  271,
+      271,  271,  272,  273,  273,  273,  273,  273,  273,  273,
+      274,  459, 1723, 1408,  275,  485,  276,   51,  391,  275,
+      275,  275,  275,  275,  275, 1723,  392,  450,  451,  451,
+      451,  451,  451,  451,   51,  486,  495, 1723,  393,  765,
+     1318,  276,  344,  344,  344,  344,  344,  344,  344,  496,
+     1723,  487, 1723,  344,  394,  770, 1321,   49,  344,  344,
+      344,  344,  344,  344,  345,  346,  346,  346,  346,  346,
+      346,  360,  768,   49,   49,  347, 1324, 1723, 1723,  530,
+      347,  347,  347,  347,  347,  347,  257,  348,  348,  348,
 
-      453,  276,  276,  276,  276,  276,  276,  277,  278,  278,
-      278,  278,  278,  278,  278,  279,  782,   53,  786,  280,
-     1223,  281,  453,  396,   53,  280,  280,  280,  280,  280,
-      280,  397,  440,  440,  440,  440,  440,  440,  440,   53,
-      793,  545, 1323,  619,  398,   55,  771,  281,  349,  349,
-      349,  349,  349,  349,  349, 1728,   53,  435,  618,  349,
-      399,  453,   55,   55,  784,  349,  349,  349,  349,  349,
-      349,  350,  351,  351,  351,  351,  351,  351,  690,   53,
-       55, 1728,  352,  435,  618,  854, 1728,  691,  352,  352,
-      352,  352,  352,  352,  262,  353,  353,  353,  353,  353,
+      348,  348,  348,  348,  349,  349,  349,  349,  349,  349,
+      349,  272,  772, 1723,   49,  349,   49,  788, 1327, 1723,
+      349,  349,  349,  349,  349,  349,  351,  352,  352,  352,
+      352,  352,  352,  352,  463,  794, 1330, 1408,  353,  448,
+      448,  613,  465,  353,  353,  353,  353,  353,  353,  356,
+      353,  353,  353,  353,  353,  353,  353,  360,  361,  361,
+      361,  361,  361,  361,  361,  362,  613, 1218,  448,  363,
+       49,  364,   51,  540,  363,  363,  363,  363,  363,  363,
+      519,  519,  519,  519,  519,  519,  519,  541,  774,   51,
+     1318,  448,  771,  540,  614,   49,  364,  272,  368,  368,
 
-      353,  353,  354,  354,  354,  354,  354,  354,  354,  769,
-     1728,  854, 1728,  354, 1326,  453, 1329,   55,   53,  354,
-      354,  354,  354,  354,  354,  356,  357,  357,  357,  357,
-      357,  357,  357,  540,  549,   55, 1728,  358,  453, 1332,
-      872,  716,  719,  358,  358,  358,  358,  358,  358,  361,
-      358,  358,  358,  358,  358,  358,  358,  365,  366,  366,
-      366,  366,  366,  366,  366,  367,  664,  453, 1335,  368,
-      453,  369, 1287, 1289,  666,  368,  368,  368,  368,  368,
-      368,  455,  456,  456,  456,  456,  456,  456,  524,  524,
-      524,  524,  524,  524,  524,  658,  778,  369,  277,  373,
+      368,  368,  368,  368,  368,  274,   49, 1723,  430,  369,
+     1321,   51,  541,  775,  369,  369,  369,  369,  369,  369,
+      370,  371,  371,  371,  371,  371,  371,   49,   51,  871,
+      849,  372, 1723,  430,  571,  766,  372,  372,  372,  372,
+      372,  372,  416,  572,  417,   49,  418,  419,  549,  550,
+      550,  550,  550,  550,  550,  849,  420,  653,  421,  422,
+      653,  423,  425,  574,  426,  426,  426,  426,  426,  426,
+      426,  654,  575,  448, 1723,  426, 1723, 1324,   51,  448,
+      426,  426,  426,  426,  426,  426,  427,  428,  428,  428,
+      428,  428,  428,  428,  777,   51,  654, 1327,  429, 1723,
 
-      373,  373,  373,  373,  373,  373,  279,   53, 1068,  659,
-      374, 1295,   55,   55, 1293,  776,  374,  374,  374,  374,
-      374,  374,  375,  376,  376,  376,  376,  376,  376,   53,
-       55,   55,  780,  377,  658,  659,  879,  866, 1493,  377,
-      377,  377,  377,  377,  377,  421,   53,  422, 1728,  423,
-      424,  554,  555,  555,  555,  555,  555,  555,   55,  425,
-      785,  426,  427,  660,  428,  430,  660,  431,  431,  431,
-      431,  431,  431,  431, 1728,   53,   55,  661,  431,  873,
-     1728,   55, 1413,   55,  431,  431,  431,  431,  431,  431,
-      432,  433,  433,  433,  433,  433,  433,  433, 1413,   55,
+      430, 1723,   49,  429,  429,  429,  429,  429,  429,  553,
+      554,  554,  554,  554,  554,  554,  633,  634,  634,  634,
+      634,  634,  634,  655,  773,  430,  431,  429,  429,  429,
+      429,  429,  429,  429, 1723,   49,  448,  656,  429, 1330,
+       51,   51,  655,  429,  429,  429,  429,  429,  429,  433,
+      434,  434,  434,  434,  434,  434, 1723,   51,   51, 1723,
+      435,  868,  656,   51,  779,  435,  435,  435,  435,  435,
+      435,  262,  436,  436,  436,  436,  436,  436,  436,   49,
+       51, 1723,  448,  437, 1723, 1723, 1723,  861,  437,  437,
+      437,  437,  437,  437,   49,  437,  437,  437,  437,  437,
 
-      876,   55,  434,  661,  435,  453, 1728, 1345,  434,  434,
-      434,  434,  434,  434,  558,  559,  559,  559,  559,  559,
-      559,  638,  639,  639,  639,  639,  639,  639,  729,  783,
-      435,  436,  434,  434,  434,  434,  434,  434,  434,   53,
-     1117, 1350,  730,  434, 1352,   55,   55,   55,  729,  434,
-      434,  434,  434,  434,  434,  438,  439,  439,  439,  439,
-      439,  439, 1728,   55,   55,   55,  440,  874,  730,   55,
-      883,   55,  440,  440,  440,  440,  440,  440,  267,  441,
-      441,  441,  441,  441,  441,  441, 1126,   55, 1728,   55,
-      442, 1728,  884, 1728, 1728, 1358,  442,  442,  442,  442,
+      437,  437,  440,  441,  441,  441,  441,  441,  441, 1723,
+     1723, 1723, 1723,  442, 1282, 1284,   51,  780,  442,  442,
+      442,  442,  442,  442,  446,  447,  447,  447,  447,  447,
+      447,  448,   49,   51, 1063,  449, 1290, 1723,  867,   51,
+      449,  449,  449,  449,  449,  449,  360,  452,  452,  452,
+      452,  452,  452,  452,  362, 1288,   51, 1488,  453,  869,
+       51,   51,   51,  453,  453,  453,  453,  453,  453,  454,
+      455,  455,  455,  455,  455,  455,  448,   51,   51,   51,
+      456,  882,  874,   51,  879,  456,  456,  456,  456,  456,
+      456,  272,  461,  461,  461,  461,  461,  461,  461,  274,
 
-      442,  442,   53,  442,  442,  442,  442,  442,  442,  442,
-      445,  446,  446,  446,  446,  446,  446, 1728,  724, 1728,
-     1728,  447, 1360,   55,   55,  794,  899,  447,  447,  447,
-      447,  447,  447,  451,  452,  452,  452,  452,  452,  452,
-      453,   55,   55,   55,  454,  887, 1728,   55,  796, 1137,
-      454,  454,  454,  454,  454,  454,  365,  457,  457,  457,
-      457,  457,  457,  457,  367,   55, 1728,  935,  458, 1728,
-       55,   55, 1728, 1366,  458,  458,  458,  458,  458,  458,
-      459,  460,  460,  460,  460,  460,  460,  453,   55,   55,
-       53,  461, 1728,  935,  963, 1728,   55,  461,  461,  461,
+       51, 1408, 1723,  462, 1408,  448,   51,  878,  462,  462,
+      462,  462,  462,  462,  463,  464,  464,  464,  464,  464,
+      464,  464,  465,   51, 1340, 1112,  466, 1723,  467,  683,
+      782,  466,  466,  466,  466,  466,  466,  577,  684,  578,
+      685,  724,  579,  580,   49,  724,  581,  582,  764,  686,
+      778,  583,  787,  467,  477,  725, 1345,   49,  478, 1723,
+       49,  479,   49,  733,  480,  733,  481,  482,  483,  484,
+      516,  516,  516,  516,  516,  516,  516,  734, 1347, 1723,
+      725,  516,  930,   51, 1723,  783,  516,  516,  516,  516,
+      516,  516,  517,  518,  518,  518,  518,  518,  518,   49,
 
-      461,  461,  461,  277,  466,  466,  466,  466,  466,  466,
-      466,  279, 1368, 1149,   55,  467,   53, 1374,   55,  964,
-       55,  467,  467,  467,  467,  467,  467,  468,  469,  469,
-      469,  469,  469,  469,  469,  470,   55,  975,   55,  471,
-      787,  472, 1376,  965,  788,  471,  471,  471,  471,  471,
-      471,  582,  738,  583,   53,  789,  584,  585,   53,  738,
-      586,  587,  791,  733,  792,  588,  739,  472,  482,   53,
-     1161,  902,  483, 1728,   53,  484,   53,  740,  485,  740,
-      486,  487,  488,  489,  521,  521,  521,  521,  521,  521,
-      521,  741,  739, 1728, 1295,  521,   55,   55,   55, 1728,
+       51, 1121,  734,  519, 1723, 1723,   49,  930,  519,  519,
+      519,  519,  519,  519,  427,  520,  520,  520,  520,  520,
+      520,  520,  521,  521,  521,  521,  521,  521,  521,  535,
+     1723,   49, 1056,  521, 1723, 1353,  789,  711,  521,  521,
+      521,  521,  521,  521,  432,  523,  523,  523,  523,  523,
+      523,  523,  544,   51, 1355, 1132,  524, 1056,  260, 1723,
+      714,  524,  524,  524,  524,  524,  524,  641,  642,  642,
+      642,  642,  642,  642,  645,  646,  646,  646,  646,  646,
+      646,   51,  735,  260,  524,  524,  524,  524,  524,  524,
+      524, 1723, 1361, 1723, 1723,  524,  736,   51,   51,  784,
 
-     1421,  521,  521,  521,  521,  521,  521,  522,  523,  523,
-      523,  523,  523,  523,   55,   55,   55,  741,  524, 1728,
-      967,  969, 1061,  880,  524,  524,  524,  524,  524,  524,
-      432,  525,  525,  525,  525,  525,  525,  525,  526,  526,
-      526,  526,  526,  526,  526, 1223, 1468, 1470, 1061,  526,
-     1506,   55,   55,   55,   55,  526,  526,  526,  526,  526,
-      526,  437,  528,  528,  528,  528,  528,  528,  528,   55,
-       55,   55,   55,  529, 1510,  265,  970,  976,  881,  529,
-      529,  529,  529,  529,  529,  646,  647,  647,  647,  647,
-      647,  647,  650,  651,  651,  651,  651,  651,  651,   55,
+      524,  524,  524,  524,  524,  524,  525,  525,  525,  525,
+      525,  525,  525,   49,   51,  862, 1723,  526, 1723, 1723,
+     1363,  736,  526,  526,  526,  526,  526,  526,   49,  526,
+      526,  526,  526,  526,  526,  526,  360,  529,  529,  529,
+      529,  529,  529,  529,  530,  786,  735, 1144,  531, 1369,
+      364, 1371, 1156,  531,  531,  531,  531,  531,  531,   49,
+     1723,  744,  745,  745,  745,  745,  745,  745,  747,  748,
+      748,  748,  748,  748,  748,  364,  535,  536,  536,  536,
+      536,  536,  536,  536,  537, 1723, 1290, 1416,  538, 1218,
+      539, 1463, 1465,  538,  538,  538,  538,  538,  538,  751,
 
-      855,  265,  529,  529,  529,  529,  529,  529,  529, 1728,
-      744, 1728, 1728,  529,  856,   55, 1514,   55,  905,  529,
-      529,  529,  529,  529,  529,  530,  530,  530,  530,  530,
-      530,  530, 1518,   55,  867, 1728,  531, 1728, 1728, 1728,
-      856,  979,  531,  531,  531,  531,  531,  531,   53,  531,
-      531,  531,  531,  531,  531,  531,  365,  534,  534,  534,
-      534,  534,  534,  534,  535, 1728, 1522, 1551,  536, 1728,
-      369, 1573, 1155, 1149,  536,  536,  536,  536,  536,  536,
-      749,  750,  750,  750,  750,  750,  750,  752,  753,  753,
-      753,  753,  753,  753,   55, 1728,  369,  540,  541,  541,
+      752,  752,  752,  752,  752,  752,  814,  815,  815,  815,
+      815,  815,  815,  850,   51,  539,  360,  542,  542,  542,
+      542,  542,  542,  542,  530, 1723, 1501,  851,  543, 1505,
+     1723,   51,   51,  543,  543,  543,  543,  543,  543,  544,
+      545,  545,  545,  545,  545,  545,  545,  546,  863,   51,
+     1723,  547,  851,  548,  958, 1723,  547,  547,  547,  547,
+      547,  547,  822,  823,  823,  823,  823,  823,  823,  826,
+      827,  827,  827,  827,  827,  827,  850,   51,  548,  463,
+      555,  555,  555,  555,  555,  555,  555,  465, 1509, 1723,
+     1723,  556, 1513,   51,   51,  852,  556,  556,  556,  556,
 
-      541,  541,  541,  541,  541,  542,  861,  453, 1332,  543,
-      930,  544,   55, 1085,  863,  543,  543,  543,  543,  543,
-      543,  756,  757,  757,  757,  757,  757,  757,  819,  820,
-      820,  820,  820,  820,  820,  855,   55,  544,  365,  547,
-      547,  547,  547,  547,  547,  547,  535, 1145, 1143, 1728,
-      548, 1728, 1137, 1728,   55,   55,  548,  548,  548,  548,
-      548,  548,  549,  550,  550,  550,  550,  550,  550,  550,
-      551,  868,  453,   55,  552, 1728,  553, 1728,  982, 1728,
-      552,  552,  552,  552,  552,  552,  827,  828,  828,  828,
-      828,  828,  828,  831,  832,  832,  832,  832,  832,  832,
+      556,  556,  557,  558,  558,  558,  558,  558,  558,  853,
+       51,  864, 1517,  559, 1723, 1723,   51,  791,  559,  559,
+      559,  559,  559,  559,  608,  852,  609,  609,  609,  609,
+      609,  609,  609,   51,  853, 1546, 1723,  609, 1568, 1723,
+       51,   51,  609,  609,  609,  609,  609,  609,  610,  611,
+      611,  611,  611,  611,  611,  611, 1144,   51,   51, 1086,
+      612, 1723,  613,  959, 1723,  612,  612,  612,  612,  612,
+      612,  834,  835,  835,  835,  835,  835,  835,  837,  838,
+      838,  838,  838,  838,  838,   51,   51,  613,  610,  612,
+      612,  612,  612,  612,  612,  612,  659,  448, 1327, 1137,
 
-      857,   55,  553,  468,  560,  560,  560,  560,  560,  560,
-      560,  470, 1329, 1728,  858,  561,  919,   55, 1133,   55,
-      857,  561,  561,  561,  561,  561,  561,  562,  563,  563,
-      563,  563,  563,  563, 1728,   55,  869, 1131,  564, 1728,
-      858,   55, 1087,   55,  564,  564,  564,  564,  564,  564,
-      613,  915,  614,  614,  614,  614,  614,  614,  614,   55,
-     1728,   55, 1126,  614,  972,  916,   55,   55,  885,  614,
-      614,  614,  614,  614,  614,  615,  616,  616,  616,  616,
-      616,  616,  616,  453,   55,   55, 1326,  617, 1078,  618,
-      910,  916, 1084,  617,  617,  617,  617,  617,  617,  839,
+      612, 1723,   51,   51,  661,  612,  612,  612,  612,  612,
+      612,  432,  615,  615,  615,  615,  615,  615,  615,  866,
+      925, 1140,  872,  616, 1137, 1149, 1723, 1723,  616,  616,
+      616,  616,  616,  616,   49,  616,  616,  616,  616,  616,
+      616,  616,  617,  617,  617,  617,  617,  617,  617,  719,
+     1149, 1138, 1723,  618, 1723, 1281, 1723,  894,  618,  618,
+      618,  618,  618,  618,   49,  618,  618,  618,  618,  618,
+      618,  618,  621,  622,  622,  622,  622,  622,  622, 1723,
+     1281, 1723, 1723,  623, 1132,  448,   51,   51,  623,  623,
+      623,  623,  623,  623,  360,  452,  452,  452,  452,  452,
 
-      840,  840,  840,  840,  840,  840,  842,  843,  843,  843,
-      843,  843,  843,   55,   55,  618,  615,  617,  617,  617,
-      617,  617,  617,  617, 1142,  910, 1122, 1728,  617, 1154,
-     1728,   55,   55, 1101,  617,  617,  617,  617,  617,  617,
-      437,  620,  620,  620,  620,  620,  620,  620,  871,  919,
-     1142,  877,  621, 1728, 1728, 1154, 1728, 1104,  621,  621,
-      621,  621,  621,  621,   53,  621,  621,  621,  621,  621,
-      621,  621,  622,  622,  622,  622,  622,  622,  622,  930,
-     1728, 1117,  453,  623, 1286, 1728, 1728, 1107, 1323,  623,
-      623,  623,  623,  623,  623,   53,  623,  623,  623,  623,
+      452,  452,  530,   51,   51, 1324,  453, 1723,  960,  962,
+      910,  453,  453,  453,  453,  453,  453,  624,  625,  625,
+      625,  625,  625,  625,  911,  914, 1723, 1128,  626, 1126,
+       51,   51, 1121,  626,  626,  626,  626,  626,  626,  630,
+      631,  631,  631,  631,  631,  631,  448,   51,   51,  911,
+      632, 1723,  964,  965,   51,  632,  632,  632,  632,  632,
+      632,  535,  635,  635,  635,  635,  635,  635,  635,  537,
+      448,   51, 1723,  636,  967,   51, 1321,   51,  636,  636,
+      636,  636,  636,  636,  637,  638,  638,  638,  638,  638,
+      638,  448,   51,  970,   51,  639,  905, 1723,   51,  977,
 
-      623,  623,  623,  626,  627,  627,  627,  627,  627,  627,
-     1286, 1728, 1728, 1728,  628,  453, 1225,   55,   55,   55,
-      628,  628,  628,  628,  628,  628,  365,  457,  457,  457,
-      457,  457,  457,  457,  535,   55,   55,   55,  458, 1728,
-     1082, 1086, 1089,  915,  458,  458,  458,  458,  458,  458,
-      629,  630,  630,  630,  630,  630,  630, 1728,  942, 1342,
-     1728,  631, 1206,   55,   55, 1335, 1110,  631,  631,  631,
-      631,  631,  631,  635,  636,  636,  636,  636,  636,  636,
-      453,   55,   55, 1728,  637, 1090, 1728,   55,   55, 1088,
-      637,  637,  637,  637,  637,  637,  540,  640,  640,  640,
+      639,  639,  639,  639,  639,  639,  544,  647,  647,  647,
+      647,  647,  647,  647,  546,   51, 1117, 1112,  648, 1723,
+       51,   51,  971,  648,  648,  648,  648,  648,  648,  649,
+      650,  650,  650,  650,  650,  650,  448,   51,   51, 1723,
+      651, 1073, 1077,   51, 1723,  651,  651,  651,  651,  651,
+      651,  463,  657,  657,  657,  657,  657,  657,  657,  465,
+       51, 1080, 1352,  658, 1723,  448,   51,   51,  658,  658,
+      658,  658,  658,  658,  659,  660,  660,  660,  660,  660,
+      660,  660,  661,   51,   51, 1318,  662, 1352,  663, 1081,
+     1082,  662,  662,  662,  662,  662,  662,  841,  842,  842,
 
-      640,  640,  640,  640,  542,   55,   55, 1091,  641, 1332,
-       55, 1093,   55, 1329,  641,  641,  641,  641,  641,  641,
-      642,  643,  643,  643,  643,  643,  643,  453,   55, 1326,
-       55,  644, 1323, 1206,   55,   55,   55,  644,  644,  644,
-      644,  644,  644,  549,  652,  652,  652,  652,  652,  652,
-      652,  551,   55,   55,   55,  653, 1068,   55,   55,   55,
-     1295,  653,  653,  653,  653,  653,  653,  654,  655,  655,
-      655,  655,  655,  655,  453,   55,   55,   55,  656, 1187,
-     1190,   55, 1191,   55,  656,  656,  656,  656,  656,  656,
-      468,  662,  662,  662,  662,  662,  662,  662,  470,   55,
+      842,  842,  842,  842,  745,  745,  745,  745,  745,  745,
+      745,   51,   51,  663,  699,  699,  699,  699,  699,  699,
+      699, 1360,  448, 1368, 1220,  699, 1723,   51,   51,   51,
+      699,  699,  699,  699,  699,  699,  700,  700,  700,  700,
+      700,  700,  700,  873,   51,  963, 1360,  700, 1368, 1084,
+     1462, 1723,  700,  700,  700,  700,  700,  700,  610,  701,
+      701,  701,  701,  701,  701,  701,  702,  702,  702,  702,
+      702,  702,  702,  728, 1504, 1462, 1508,  702, 1512,   51,
+       51,  897,  702,  702,  702,  702,  702,  702,  432,  704,
+      704,  704,  704,  704,  704,  704,   51,   51, 1337, 1504,
 
-     1070,   55,  663, 1728, 1728,   55, 1194,  861,  663,  663,
-      663,  663,  663,  663,  664,  665,  665,  665,  665,  665,
-      665,  665,  666,   55, 1064, 1195,  667, 1062,  668, 1728,
-     1728, 1163,  667,  667,  667,  667,  667,  667,  846,  847,
-      847,  847,  847,  847,  847,  750,  750,  750,  750,  750,
-      750,  750,   55,   55,  668,  704,  704,  704,  704,  704,
-      704,  704, 1357,  453, 1365, 1373,  704, 1728,   55, 1110,
-       55,   55,  704,  704,  704,  704,  704,  704,  705,  705,
-      705,  705,  705,  705,  705,  878,   55,  968, 1357,  705,
-     1365, 1373, 1199, 1728, 1151,  705,  705,  705,  705,  705,
+      705, 1508, 1088, 1512,  974,  705,  705,  705,  705,  705,
+      705,   49,  705,  705,  705,  705,  705,  705,  705,  706,
+      706,  706,  706,  706,  706,  706,  739, 1201, 1330, 1327,
+      707, 1324, 1321, 1318,  900,  707,  707,  707,  707,  707,
+      707,   49,  707,  707,  707,  707,  707,  707,  707,  535,
+      710,  710,  710,  710,  710,  710,  710,  711,   51,   51,
+       51,  712,   51,  539,   51,   51,  712,  712,  712,  712,
+      712,  712,  856, 1201, 1063,   51,   51,   51, 1290,   51,
+      858,   51,   51,   51, 1085,  875,  876,  865,  539,  544,
+      713,  713,  713,  713,  713,  713,  713,  714,  877,   51,
 
-      705,  615,  706,  706,  706,  706,  706,  706,  706,  707,
-      707,  707,  707,  707,  707,  707, 1068,  453, 1107, 1467,
-      707, 1509,   55,   55, 1070,   55,  707,  707,  707,  707,
-      707,  707,  437,  709,  709,  709,  709,  709,  709,  709,
-       55,   55, 1197,   55,  710, 1467, 1200, 1509, 1513,  978,
-      710,  710,  710,  710,  710,  710,   53,  710,  710,  710,
-      710,  710,  710,  710,  711,  711,  711,  711,  711,  711,
-      711, 1117, 1126, 1139, 1513,  712,  453, 1104, 1128, 1323,
-     1326,  712,  712,  712,  712,  712,  712,   53,  712,  712,
-      712,  712,  712,  712,  712,  540,  715,  715,  715,  715,
+       51,  715,   51,  548,   51,  905,  715,  715,  715,  715,
+      715,  715,  870, 1096, 1065,  914,   51, 1516,  856,   51,
+     1059,   51,   51, 1099, 1057,  880,  910,   51,  548,  719,
+      720,  720,  720,  720,  720,  720,  720,  721,  881,   51,
+     1723,  722, 1516,  723,   51,  925,  722,  722,  722,  722,
+      722,  722,  883, 1102, 1567, 1158,  336,  888,  888,  888,
+      888,  888,  888,  888,  919, 1723,  919,   51,  723,  535,
+      726,  726,  726,  726,  726,  726,  726,  711,  920, 1567,
+     1723,  727,  448, 1587,   51, 1105,  727,  727,  727,  727,
+      727,  727,  728,  729,  729,  729,  729,  729,  729,  729,
 
-      715,  715,  715,  716,   55,   55,  924,  717,   55,  544,
-       55,   55,   55,  717,  717,  717,  717,  717,  717, 1137,
-      925,  453,   55,   55, 1101, 1119,   55, 1329,   55,   55,
-       55,   55,  980,   55,  870,  544,  549,  718,  718,  718,
-      718,  718,  718,  718,  719,  882,  925,  886,  720,   55,
-      553,   55, 1149, 1298,  720,  720,  720,  720,  720,  720,
-     1332,  875,  453, 1225,  888,  893,  893,  893,  893,  893,
-      893,  893,   55,  924,  926, 1517,  553,  724,  725,  725,
-      725,  725,  725,  725,  725,  726,   55, 1728,  927,  727,
-       55,  728,  926,  936,  936,  727,  727,  727,  727,  727,
+      730,  969,  921,  920,  731, 1723,  732,  921, 1587,  731,
+      731,  731,  731,  731,  731, 1146,  922, 1588,  448, 1102,
+     1589, 1723,  835,  835,  835,  835,  835,  835,  835,  931,
+       51,  732,  544,  737,  737,  737,  737,  737,  737,  737,
+      714,  922, 1588,  932,  738, 1589, 1723,   51, 1134,  738,
+      738,  738,  738,  738,  738,  739,  740,  740,  740,  740,
+      740,  740,  740,  741,   51,  931,  933,  742,  932,  743,
+      933,  448,  742,  742,  742,  742,  742,  742, 1099, 1723,
+      934,   51, 1123, 1590, 1723,  943,  944,  944,  944,  944,
+      944,  944,  972,   51,  743,  659,  753,  753,  753,  753,
 
-      727, 1517,  341, 1161,   55, 1521, 1728,  937, 1728,   55,
-      453, 1335, 1206, 1728,  927,  938, 1110,  728,  540,  731,
-      731,  731,  731,  731,  731,  731,  716,   55, 1299,  939,
-      732, 1521, 1728,  937, 1728,   55,  732,  732,  732,  732,
-      732,  732,  733,  734,  734,  734,  734,  734,  734,  734,
-      735, 1300, 1107,   55,  736,  939,  737, 1104, 1304,  938,
-      736,  736,  736,  736,  736,  736,  840,  840,  840,  840,
-      840,  840,  840, 1728,  948,  949,  949,  949,  949,  949,
-      949, 1101,  737,  549,  742,  742,  742,  742,  742,  742,
-      742,  719, 1223, 1206, 1572,  743, 1592, 1593,   55, 1728,
+      753,  753,  753,  661, 1723,  934,  448,  754, 1590, 1723,
+       51,   51,  754,  754,  754,  754,  754,  754,  755,  756,
+      756,  756,  756,  756,  756,  961, 1096, 1114,   51,  757,
+      448,   51,   51,   51,  757,  757,  757,  757,  757,  757,
+       49,   49,   49,   49,   49,   49,   49,  978,   51,   51,
+       51,   49,   51,   51,   51,   51,   49,   49,   49,   49,
+       49,   49,  946,  947,  947,  947,  947,  947,  947,   51,
+       51,   51,   51, 1057,  759,  789, 1057,  790,  790,  790,
+      790,  790,  790,  790,  966,  968, 1068, 1058,  790,  976,
+     1723,   51,   51,  790,  790,  790,  790,  790,  790,  791,
 
-     1413,  743,  743,  743,  743,  743,  743,  744,  745,  745,
-      745,  745,  745,  745,  745,  746,   55, 1070, 1301,  747,
-     1572,  748, 1592, 1593,  863,  747,  747,  747,  747,  747,
-      747,  951,  952,  952,  952,  952,  952,  952,  955,  956,
-      956,  956,  956,  956,  956,   55,   55,  748,  664,  758,
-      758,  758,  758,  758,  758,  758,  666, 1293,  942, 1163,
-      759, 1110, 1594,   55,   55, 1295,  759,  759,  759,  759,
-      759,  759,  760,  761,  761,  761,  761,  761,  761,  966,
-      974,  744,  938,  762,   55,   55,   55,   55, 1594,  762,
-      762,  762,  762,  762,  762,   53,   53,   53,   53,   53,
+      792,  792,  792,  792,  792,  792,  792, 1220,   51,   51,
+     1190,  792, 1058, 1182,  448, 1723,  792,  792,  792,  792,
+      792,  792,  701,  701,  701,  701,  701,  701,  701,  950,
+      951,  951,  951,  951,  951,  951,   51,   51,   51, 1005,
+     1006, 1006, 1006, 1006, 1006, 1006, 1013, 1014, 1014, 1014,
+     1014, 1014, 1014,   51,   51,   51,   49,  702,  702,  702,
+      702,  702,  702,  702,  973, 1201, 1105, 1102,  702, 1069,
+     1072, 1591, 1608,  702,  702,  702,  702,  702,  702,  793,
+      348,  348,  348,  348,  348,  348,  348,  262,  795,  795,
+      795,  795,  795,  795,  795,  937, 1591, 1608, 1099,  796,
 
-       53,   53,   55,   55,   55,   55,   53,   55,   55, 1062,
-       55,   55,   53,   53,   53,   53,   53,   53,  971,  973,
-     1595,  983,  981, 1063, 1293,   55,   55, 1062,   55,   55,
-      764,  794, 1728,  795,  795,  795,  795,  795,  795,  795,
-      977, 1728, 1077, 1073,  795, 1186, 1595,   55,  936, 1063,
-      795,  795,  795,  795,  795,  795, 1010, 1011, 1011, 1011,
-     1011, 1011, 1011, 1064, 1064,   55,   55, 1728,   53,  796,
-      797,  797,  797,  797,  797,  797,  797, 1065, 1728,  930,
-     1074,  797,   55,   55,   55, 1079, 1151,  797,  797,  797,
-      797,  797,  797, 1018, 1019, 1019, 1019, 1019, 1019, 1019,
+     1614, 1096, 1201, 1105,  796,  796,  796,  796,  796,  796,
+       49,  796,  796,  796,  796,  796,  796,  796,  799,  800,
+      800,  800,  800,  800,  800, 1614, 1065,  858,  937,  801,
+     1158, 1105,   51,   51,  801,  801,  801,  801,  801,  801,
+      535,  635,  635,  635,  635,  635,  635,  635,  711,   51,
+       51,  739,  636, 1185,   51, 1186, 1059,  636,  636,  636,
+      636,  636,  636,  802,  803,  803,  803,  803,  803,  803,
+     1060,   51,  933,  931,  804,  925, 1189,   51, 1146,  804,
+      804,  804,  804,  804,  804,  544,  647,  647,  647,  647,
+      647,  647,  647,  714,   51, 1060, 1102,  648,  728,   51,
 
-       55,   55, 1080, 1065, 1728,   53,  706,  706,  706,  706,
-      706,  706,  706, 1022, 1023, 1023, 1023, 1023, 1023, 1023,
-     1030, 1031, 1031, 1031, 1031, 1031, 1031, 1033, 1034, 1034,
-     1034, 1034, 1034, 1034, 1037, 1038, 1038, 1038, 1038, 1038,
-     1038,   53,  707,  707,  707,  707,  707,  707,  707, 1107,
-      733,  926,  924,  707,  919, 1596, 1613, 1619, 1139,  707,
-      707,  707,  707,  707,  707,  798,  353,  353,  353,  353,
-      353,  353,  353,  267,  800,  800,  800,  800,  800,  800,
-      800, 1596, 1613, 1619, 1104,  801,  724,  915,  910, 1128,
-     1101,  801,  801,  801,  801,  801,  801,   53,  801,  801,
+     1194, 1059,  648,  648,  648,  648,  648,  648,  805,  806,
+      806,  806,  806,  806,  806, 1723,   51, 1192,  921,  807,
+      919,   51,   51,  914,  807,  807,  807,  807,  807,  807,
+      811,  812,  812,  812,  812,  812,  812,  448,   51,   51,
+     1723,  813, 1195, 1134,   51, 1099,  813,  813,  813,  813,
+      813,  813,  719,  816,  816,  816,  816,  816,  816,  816,
+      721,   51, 1293,  719,  817,  910,   51,   51,  905,  817,
+      817,  817,  817,  817,  817,  818,  819,  819,  819,  819,
+      819,  819,  448,   51,   51, 1294,  820, 1123, 1096,   51,
+     1114,  820,  820,  820,  820,  820,  820,  728,  828,  828,
 
-      801,  801,  801,  801,  801,  804,  805,  805,  805,  805,
-      805,  805, 1119, 1006,  991, 1110,  806, 1107, 1104,   55,
-       55,   55,  806,  806,  806,  806,  806,  806,  540,  640,
-      640,  640,  640,  640,  640,  640,  716,   55,   55,   55,
-      641, 1315, 1101, 1316,   55, 1122,  641,  641,  641,  641,
-      641,  641,  807,  808,  808,  808,  808,  808,  808, 1123,
-     1302, 1099,   55,  809,  991,  861,   55, 1070,   55,  809,
-      809,  809,  809,  809,  809,  549,  652,  652,  652,  652,
-      652,  652,  652,  719,   55, 1123,   55,  653,  863,   55,
-       55,   55, 1122,  653,  653,  653,  653,  653,  653,  810,
+      828,  828,  828,  828,  828,  730,   51, 1295, 1296,  829,
+     1001,   51,   51,   51,  829,  829,  829,  829,  829,  829,
+      830,  831,  831,  831,  831,  831,  831,  448,   51,   51,
+       51,  832,  986, 1299, 1105,   51,  832,  832,  832,  832,
+      832,  832,  739,  843,  843,  843,  843,  843,  843,  843,
+      741, 1297,   51, 1102,  844, 1099, 1310,   51,   51,  844,
+      844,  844,  844,  844,  844,  845,  846,  846,  846,  846,
+      846,  846,  448, 1096,   51,   51,  847, 1094,  986, 1311,
+       51,  847,  847,  847,  847,  847,  847,  659,  854,  854,
+      854,  854,  854,  854,  854,  661,  856,   51, 1065,  855,
 
-      811,  811,  811,  811,  811,  811, 1728,   55,   55,   55,
-      812,  664,   55, 1395, 1404, 1306,  812,  812,  812,  812,
-      812,  812,  816,  817,  817,  817,  817,  817,  817,  453,
-       55,  857, 1728,  818,  855,  944,  905,   55,   55,  818,
-      818,  818,  818,  818,  818,  724,  821,  821,  821,  821,
-      821,  821,  821,  726, 1401,   55,   55,  822,  932,  902,
-       55,   55,  921,  822,  822,  822,  822,  822,  822,  823,
-      824,  824,  824,  824,  824,  824,  453, 1409,   55,   55,
-      825, 1476, 1477,   55,   55,   55,  825,  825,  825,  825,
-      825,  825,  733,  833,  833,  833,  833,  833,  833,  833,
+      858,  659,  852,   51,  855,  855,  855,  855,  855,  855,
+      856,  857,  857,  857,  857,  857,  857,  857,  858,   51,
+       51, 1117,  859,  850,  860,  939,  900,  859,  859,  859,
+      859,  859,  859, 1087,   51, 1118,   51, 1017, 1018, 1018,
+     1018, 1018, 1018, 1018,   51,  975,  927,   51, 1117,  860,
+       51,   51,  884,  884,  884,  884,  884,  884,  884, 1079,
+     1118,   51, 1723,  884,   51, 1074,   51,   51,  884,  884,
+      884,  884,  884,  884,  885,  885,  885,  885,  885,  885,
+      885, 1184, 1075,   51,  897,  885,   51, 1723,   51,   51,
+      885,  885,  885,  885,  885,  885,  886,  887,  887,  887,
 
-      735,   55,   55,   55,  834,  899, 1479,  912,   55, 1006,
-      834,  834,  834,  834,  834,  834,  835,  836,  836,  836,
-      836,  836,  836,  453,  991, 1478,   55,  837,  905,  902,
-     1481,   55,   55,  837,  837,  837,  837,  837,  837,  744,
-      848,  848,  848,  848,  848,  848,  848,  746,  899,   55,
-       55,  849,  991, 1482,   55,   55, 1483,  849,  849,  849,
-      849,  849,  849,  850,  851,  851,  851,  851,  851,  851,
-      453,  863,   55,   55,  852,  666, 1486,   55, 1489,   55,
-      852,  852,  852,  852,  852,  852,  664,  859,  859,  859,
-      859,  859,  859,  859,  666,   55,  744,   55,  860,  944,
+      887,  887,  887,   51,  916,   51,   51,  888,  894,   51,
+       51, 1083,  888,  888,  888,  888,  888,  888,  262,  889,
+      889,  889,  889,  889,  889,  889,   51,   51,  907, 1001,
+      890,  986, 1390,  900, 1301,  890,  890,  890,  890,  890,
+      890,   49,  890,  890,  890,  890,  890,  890,  890,  719,
+      893,  893,  893,  893,  893,  893,  893,  894,  897,  894,
+      986,  895,  858,  723,  661,  739,  895,  895,  895,  895,
+      895,  895, 1025, 1026, 1026, 1026, 1026, 1026, 1026, 1028,
+     1029, 1029, 1029, 1029, 1029, 1029,  939,   51,  723,  728,
+      896,  896,  896,  896,  896,  896,  896,  897,  900,  544,
 
-      905,   55,  549, 1536,  860,  860,  860,  860,  860,  860,
-      861,  862,  862,  862,  862,  862,  862,  862,  863,   55,
-     1546,  740,  864,  738,  865,  733,  932,  902,  864,  864,
-      864,  864,  864,  864, 1046, 1047, 1047, 1047, 1047, 1047,
-     1047, 1049, 1050, 1050, 1050, 1050, 1050, 1050, 1131,   55,
-      865,   55, 1131,  889,  889,  889,  889,  889,  889,  889,
-      540,  729, 1132,  724,  889,  921, 1728,   55,   55,   55,
-      889,  889,  889,  889,  889,  889,  890,  890,  890,  890,
-      890,  890,  890, 1081,  899,  912,   55,  890, 1132,   55,
-       55,   55, 1728,  890,  890,  890,  890,  890,  890,  891,
+      735,  898,  733,  732,   51,  728,  898,  898,  898,  898,
+      898,  898, 1032, 1033, 1033, 1033, 1033, 1033, 1033, 1041,
+     1042, 1042, 1042, 1042, 1042, 1042,  927,   51,  732,  739,
+      899,  899,  899,  899,  899,  899,  899,  900,  897,  535,
+      724,  901,  719,  743,   51,  916,  901,  901,  901,  901,
+      901,  901, 1044, 1045, 1045, 1045, 1045, 1045, 1045, 1048,
+     1049, 1049, 1049, 1049, 1049, 1049, 1126,   51,  743,  905,
+      906,  906,  906,  906,  906,  906,  906,  907,  894,  907,
+     1127,  908,  904,  909,   51,   51,  908,  908,  908,  908,
+      908,  908,  944,  944,  944,  944,  944,  944,  944, 1070,
 
-      892,  892,  892,  892,  892,  892, 1189,   55,   55,   55,
-      893, 1549,   55,   55,   55,   55,  893,  893,  893,  893,
-      893,  893,  267,  894,  894,  894,  894,  894,  894,  894,
-       55,   55,   55,   55,  895,  909, 1577, 1584,  815, 1396,
-      895,  895,  895,  895,  895,  895,   53,  895,  895,  895,
-      895,  895,  895,  895,  724,  898,  898,  898,  898,  898,
-      898,  898,  899,  803,  905,  902,  900,  899,  728,  897,
-      803,  664,  900,  900,  900,  900,  900,  900, 1053, 1054,
-     1054, 1054, 1054, 1054, 1054,  949,  949,  949,  949,  949,
-      949,  949,   55,   55,  728,  733,  901,  901,  901,  901,
+     1071,  810,   51,  798,  900, 1127, 1126,   51,  909,  719,
+      912,  912,  912,  912,  912,  912,  912,  894, 1076,  897,
+     1723,  913,  894,  892,   51,   51,  913,  913,  913,  913,
+      913,  913,  914,  915,  915,  915,  915,  915,  915,  915,
+      916, 1078,   51, 1128,  917, 1723,  918, 1128, 1063,  917,
+      917,  917,  917,  917,  917,  798, 1065, 1129,  659, 1089,
+      858, 1723, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1138,
+      661,  918,  728,  923,  923,  923,  923,  923,  923,  923,
+      897,  463, 1129, 1139,  924,  655, 1723,   51,  653,  924,
+      924,  924,  924,  924,  924,  925,  926,  926,  926,  926,
 
-      901,  901,  901,  902,   55,   55, 1133,  903,  863,  737,
-       55,   55,   55,  903,  903,  903,  903,  903,  903,  666,
-     1134,  468,   55,   55,  660, 1075, 1076,   55, 1083,   55,
-       55,   55,  658, 1182, 1183,  737,  744,  904,  904,  904,
-      904,  904,  904,  904,  905,   55, 1134,   55,  906,   55,
-      748, 1537, 1133,  746,  906,  906,  906,  906,  906,  906,
-     1092, 1143, 1094, 1185,  719,  735, 1728, 1031, 1031, 1031,
-     1031, 1031, 1031, 1031, 1143, 1144,  748,  910,  911,  911,
-      911,  911,  911,  911,  911,  912,   55,   55, 1728,  913,
-      716,  914, 1728, 1145, 1145,  913,  913,  913,  913,  913,
+      926,  926,  926,  927,   51, 1138, 1140,  928, 1139,  929,
+     1140,  741,  928,  928,  928,  928,  928,  928, 1180, 1723,
+     1141,  714,  730,  711, 1723, 1042, 1042, 1042, 1042, 1042,
+     1042, 1042, 1150,   51,  929,  739,  935,  935,  935,  935,
+      935,  935,  935,  900, 1723, 1141, 1151,  936,  721, 1723,
+       51,  810,  936,  936,  936,  936,  936,  936,  937,  938,
+      938,  938,  938,  938,  938,  938,  939,   51, 1150, 1152,
+      940, 1151,  941, 1152, 1396,  940,  940,  940,  940,  940,
+      940,  798, 1723, 1153,   51,  714,  711, 1723, 1162, 1163,
+     1163, 1163, 1163, 1163, 1163, 1177,  798,  941,  856,  952,
 
-      913, 1144,  726,  815,   55,   55,  803, 1146, 1728,  719,
-       55,  716,  803, 1155, 1728, 1155, 1184,  914,  724,  917,
-      917,  917,  917,  917,  917,  917,  899, 1156,   55, 1728,
-      918,   53,   53, 1146, 1728,   53,  918,  918,  918,  918,
-      918,  918,  919,  920,  920,  920,  920,  920,  920,  920,
-      921, 1581,  790, 1156,  922, 1728,  923,   55,   55, 1157,
-      922,  922,  922,  922,  922,  922, 1047, 1047, 1047, 1047,
-     1047, 1047, 1047, 1158,   53,   55,   55,   53, 1157,   55,
-       55,  772,  923,  733,  928,  928,  928,  928,  928,  928,
-      928,  902, 1728, 1310, 1192,  929,  666,   55,   55, 1158,
+      952,  952,  952,  952,  952,  952,  858, 1723, 1153,   49,
+      953,   49, 1723,   51, 1282,  953,  953,  953,  953,  953,
+      953,  954,  955,  955,  955,  955,  955,  955, 1283,   49,
+       51,  785,  956,   49,   49,   51,  767,  956,  956,  956,
+      956,  956,  956,   51, 1183,  979,  979,  979,  979,  979,
+      979,  979,   51, 1283,  661,  465,  979, 1399,   51,   51,
+       51,  979,  979,  979,  979,  979,  979,  980,  980,  980,
+      980,  980,  980,  980, 1112,   51,   51,  544,  980,  741,
+      714,   51, 1318,  980,  980,  980,  980,  980,  980,  614,
+      981,  981,  981,  981,  981,  981,  981, 1404,   51, 1473,
 
-      470,  929,  929,  929,  929,  929,  929,  930,  931,  931,
-      931,  931,  931,  931,  931,  932, 1311, 1490, 1728,  933,
-      549,  934,  746,  719,  365,  933,  933,  933,  933,  933,
-      933, 1167, 1168, 1168, 1168, 1168, 1168, 1168, 1170, 1171,
-     1171, 1171, 1171, 1171, 1171, 1287,   55,  934,  744,  940,
-      940,  940,  940,  940,  940,  940,  905,  545,  540, 1288,
-      941,  735,  716,  726,   55, 1201,  941,  941,  941,  941,
-      941,  941,  942,  943,  943,  943,  943,  943,  943,  943,
-      944, 1202, 1203,  723,  945, 1288,  946,   55,   55,   55,
-      945,  945,  945,  945,  945,  945, 1174, 1175, 1175, 1175,
+      360,  982, 1474,  430,  540,  535,  982,  982,  982,  982,
+      982,  982, 1165, 1166, 1166, 1166, 1166, 1166, 1166, 1169,
+     1170, 1170, 1170, 1170, 1170, 1170,   51,   51,  430,  982,
+      982,  982,  982,  982,  982,  982,  730,  711,  721,  718,
+      982,  629,  620,   51,   51,  982,  982,  982,  982,  982,
+      982,  262,  983,  983,  983,  983,  983,  983,  983, 1188,
+      714,  711, 1181,  984,  709,  620,  610,  608,  984,  984,
+      984,  984,  984,  984,   49,  984,  984,  984,  984,  984,
+      984,  984,  987,  988,  988,  988,  988,  988,  988, 1121,
+      698,  697,  696,  989,  695,  694,   51, 1321,  989,  989,
 
-     1175, 1175, 1175,  634,  625,   55,   55,   55,   55, 1287,
-     1289,  719,  946,  861,  957,  957,  957,  957,  957,  957,
-      957,  863, 1193, 1728, 1290,  958,   55, 1544,   55,   55,
-     1289,  958,  958,  958,  958,  958,  958,  959,  960,  960,
-      960,  960,  960,  960, 1728, 1314,   55,   55,  961, 1728,
-     1290,   55,  716,   55,  961,  961,  961,  961,  961,  961,
-       55, 1188,  984,  984,  984,  984,  984,  984,  984,   55,
-     1728,   55, 1602,  984, 1603,   55,   55,   55,   55,  984,
-      984,  984,  984,  984,  984,  985,  985,  985,  985,  985,
-      985,  985,  714,   55,   55,   55,  985, 1604,   55,   55,
+      989,  989,  989,  989,  719,  816,  816,  816,  816,  816,
+      816,  816,  894,   51,  693,  692,  817, 1476,   51,   51,
+     1282,  817,  817,  817,  817,  817,  817,  990,  991,  991,
+      991,  991,  991,  991, 1723,   51,   51,  691,  992, 1471,
+     1484,   51,  690,  992,  992,  992,  992,  992,  992,  728,
+      828,  828,  828,  828,  828,  828,  828,  897,   51, 1723,
+      689,  829, 1477,   51,   51, 1284,  829,  829,  829,  829,
+      829,  829,  993,  994,  994,  994,  994,  994,  994, 1285,
+       51,   51,  688,  995, 1472,  687, 1478,  680,  995,  995,
+      995,  995,  995,  995,  739,  843,  843,  843,  843,  843,
 
-       55,   55,  985,  985,  985,  985,  985,  985,  619,  986,
-      986,  986,  986,  986,  986,  986,   55,   55,   55,   55,
-      987, 1610,  435,  625,  615, 1491,  987,  987,  987,  987,
-      987,  987, 1196, 1198, 1229, 1230, 1230, 1230, 1230, 1230,
-     1230, 1235, 1236, 1236, 1236, 1236, 1236, 1236,  435,  987,
-      987,  987,  987,  987,  987,  987,  613,  703,  702,  701,
-      987,  700,   55,   55,   55,   55,  987,  987,  987,  987,
-      987,  987,  267,  988,  988,  988,  988,  988,  988,  988,
-       55,   55,   55,   55,  989, 1624,  699, 1626, 1627, 1535,
-      989,  989,  989,  989,  989,  989,   53,  989,  989,  989,
+      843,  843,  900,  679, 1285,  678,  844,  677,   51,   51,
+     1284,  844,  844,  844,  844,  844,  844,  996,  997,  997,
+      997,  997,  997,  997, 1723,   51,   51,  676,  998, 1481,
+      675,   51,  674,  998,  998,  998,  998,  998,  998, 1002,
+     1003, 1003, 1003, 1003, 1003, 1003,  448, 1532,   51, 1723,
+     1004, 1544,  673,   51,   51, 1004, 1004, 1004, 1004, 1004,
+     1004,  905, 1007, 1007, 1007, 1007, 1007, 1007, 1007,  907,
+       51,   51,  672, 1008,  671,  670,   51,  669, 1008, 1008,
+     1008, 1008, 1008, 1008, 1009, 1010, 1010, 1010, 1010, 1010,
+     1010,  448, 1539,   51, 1541, 1011,  668,  667,   51,   51,
 
-      989,  989,  989,  989,  992,  993,  993,  993,  993,  993,
-      993,  698,  697,  696,  695,  994,  694,  693,   55,   55,
-       55,  994,  994,  994,  994,  994,  994,  724,  821,  821,
-      821,  821,  821,  821,  821,  899,   55,   55,   55,  822,
-      692,  685, 1642,   55, 1345,  822,  822,  822,  822,  822,
-      822,  995,  996,  996,  996,  996,  996,  996, 1346, 1634,
-      684,   55,  997,  683,  682,   55, 1643,   55,  997,  997,
-      997,  997,  997,  997,  733,  833,  833,  833,  833,  833,
-      833,  833,  902,   55, 1346,   55,  834,  681, 1644,   55,
-       55, 1345,  834,  834,  834,  834,  834,  834,  998,  999,
+     1011, 1011, 1011, 1011, 1011, 1011,  914, 1019, 1019, 1019,
+     1019, 1019, 1019, 1019,  916,   51,   51,  666, 1020,  665,
+       51, 1572,   51, 1020, 1020, 1020, 1020, 1020, 1020, 1021,
+     1022, 1022, 1022, 1022, 1022, 1022,  448,   51,  664,   51,
+     1023,  463,  661,  465, 1579, 1023, 1023, 1023, 1023, 1023,
+     1023,  925, 1034, 1034, 1034, 1034, 1034, 1034, 1034,  927,
+     1576,  459,  546, 1035,  530,   51,   51,   51, 1035, 1035,
+     1035, 1035, 1035, 1035, 1036, 1037, 1037, 1037, 1037, 1037,
+     1037,  448,   51,   51,   51, 1038,  537, 1597,   51,   51,
+     1038, 1038, 1038, 1038, 1038, 1038,  937, 1050, 1050, 1050,
 
-      999,  999,  999,  999,  999, 1728, 1635,   55,   55, 1000,
-      680,  679, 1646,  678,   55, 1000, 1000, 1000, 1000, 1000,
-     1000,  744,  848,  848,  848,  848,  848,  848,  848,  905,
-      677, 1728,   55,  849,  676,  675,   55,   55, 1350,  849,
-      849,  849,  849,  849,  849, 1001, 1002, 1002, 1002, 1002,
-     1002, 1002, 1351, 1636,   55,   55, 1003, 1655,   55, 1657,
-      674,  673, 1003, 1003, 1003, 1003, 1003, 1003, 1007, 1008,
-     1008, 1008, 1008, 1008, 1008,  453,   55,  672, 1351, 1009,
-      671, 1659,   55,   55,   55, 1009, 1009, 1009, 1009, 1009,
-     1009,  910, 1012, 1012, 1012, 1012, 1012, 1012, 1012,  912,
+     1050, 1050, 1050, 1050,  939,   51,   51,  629, 1051, 1598,
+       51,   51,   51, 1051, 1051, 1051, 1051, 1051, 1051, 1052,
+     1053, 1053, 1053, 1053, 1053, 1053,  448,   51,   51,   51,
+     1054, 1599, 1605,   51,   51, 1054, 1054, 1054, 1054, 1054,
+     1054,  856, 1061, 1061, 1061, 1061, 1061, 1061, 1061,  858,
+       51,   51,  620, 1062, 1619,  530, 1621,  620, 1062, 1062,
+     1062, 1062, 1062, 1062, 1063, 1064, 1064, 1064, 1064, 1064,
+     1064, 1064, 1065,   51,   51,  614, 1066,   51, 1067, 1340,
+       51, 1066, 1066, 1066, 1066, 1066, 1066, 1132, 1144,  614,
+       51,   51, 1156, 1341,   51, 1324, 1327,   51, 1196,   51,
 
-       55,   55,   55, 1013,  670, 1661,   55,  669,  468, 1013,
-     1013, 1013, 1013, 1013, 1013, 1014, 1015, 1015, 1015, 1015,
-     1015, 1015,  453, 1669,   55, 1662, 1016,  666,  470,   55,
-      464,   55, 1016, 1016, 1016, 1016, 1016, 1016,  919, 1024,
-     1024, 1024, 1024, 1024, 1024, 1024,  921,   55, 1663,   55,
-     1025,  551, 1672,   55,   55,  535, 1025, 1025, 1025, 1025,
-     1025, 1025, 1026, 1027, 1027, 1027, 1027, 1027, 1027,  453,
-      542,   55,   55, 1028,  634,  625, 1680, 1681,   55, 1028,
-     1028, 1028, 1028, 1028, 1028,  930, 1039, 1039, 1039, 1039,
-     1039, 1039, 1039,  932,  535,  625,   55, 1040,  619,   55,
+     1330, 1178, 1179, 1067,   51,  614, 1090, 1090, 1090, 1090,
+     1090, 1090, 1090, 1187, 1197, 1198,   51, 1091, 1341,  607,
+      606,   51, 1091, 1091, 1091, 1091, 1091, 1091,   49, 1091,
+     1091, 1091, 1091, 1091, 1091, 1091,   51,  262, 1092, 1092,
+     1092, 1092, 1092, 1092, 1092,  605,   51,   51,   51,  604,
+       51,  603,   51,   51,  905, 1095, 1095, 1095, 1095, 1095,
+     1095, 1095, 1096,   51,   51,   51, 1097,   51,  909,   51,
+       51, 1097, 1097, 1097, 1097, 1097, 1097, 1303, 1191, 1193,
+     1224, 1225, 1225, 1225, 1225, 1225, 1225,   51, 1309,  602,
+       51,  601,   51,  909,  914, 1098, 1098, 1098, 1098, 1098,
 
-       55, 1686,  619, 1040, 1040, 1040, 1040, 1040, 1040, 1041,
-     1042, 1042, 1042, 1042, 1042, 1042,  453,   55,   55,  612,
-     1043, 1687,  611,   55,   55,   55, 1043, 1043, 1043, 1043,
-     1043, 1043,  942, 1055, 1055, 1055, 1055, 1055, 1055, 1055,
-      944,   55,   55,   55, 1056, 1693, 1690,   55,   55,  610,
-     1056, 1056, 1056, 1056, 1056, 1056, 1057, 1058, 1058, 1058,
-     1058, 1058, 1058,  453,  609,   55,   55, 1059,  608,  607,
-       55, 1700,   55, 1059, 1059, 1059, 1059, 1059, 1059,  861,
-     1066, 1066, 1066, 1066, 1066, 1066, 1066,  863,   55, 1694,
-       55, 1067,  606,  605,   55, 1708,   55, 1067, 1067, 1067,
-
-     1067, 1067, 1067, 1068, 1069, 1069, 1069, 1069, 1069, 1069,
-     1069, 1070,   55,  604,   55, 1071,  603, 1072,  602,  338,
-      239, 1071, 1071, 1071, 1071, 1071, 1071, 1239, 1240, 1240,
-     1240, 1240, 1240, 1240, 1245, 1246, 1246, 1246, 1246, 1246,
-     1246,   55,   55, 1072,   55,  619, 1095, 1095, 1095, 1095,
-     1095, 1095, 1095,  601,  600,  599,  598, 1096,  597,   55,
-       55,  596,   55, 1096, 1096, 1096, 1096, 1096, 1096,   53,
-     1096, 1096, 1096, 1096, 1096, 1096, 1096,   55,  267, 1097,
-     1097, 1097, 1097, 1097, 1097, 1097, 1248, 1249, 1249, 1249,
-     1249, 1249, 1249,   55,   55,   55,  910, 1100, 1100, 1100,
-
-     1100, 1100, 1100, 1100, 1101,  595,  594,  593, 1102,  592,
-      914,   55,   55,  591, 1102, 1102, 1102, 1102, 1102, 1102,
-     1252, 1253, 1253, 1253, 1253, 1253, 1253, 1259, 1260, 1260,
-     1260, 1260, 1260, 1260,   55, 1710,  914,  919, 1103, 1103,
-     1103, 1103, 1103, 1103, 1103, 1104,  590,  589,  581, 1105,
-      578,  923,   55,  575,  574, 1105, 1105, 1105, 1105, 1105,
-     1105, 1262, 1263, 1263, 1263, 1263, 1263, 1263, 1266, 1267,
-     1267, 1267, 1267, 1267, 1267,   55, 1714,  923,  930, 1106,
-     1106, 1106, 1106, 1106, 1106, 1106, 1107,  573,  572,  571,
-     1108,  570,  934,   55,  569,  568, 1108, 1108, 1108, 1108,
-
-     1108, 1108, 1273, 1274, 1274, 1274, 1274, 1274, 1274, 1276,
-     1277, 1277, 1277, 1277, 1277, 1277,   55,   55,  934,  942,
-     1109, 1109, 1109, 1109, 1109, 1109, 1109, 1110,  567,  566,
-      470, 1111,  279,  946,   55,   55,  453, 1111, 1111, 1111,
-     1111, 1111, 1111, 1280, 1281, 1281, 1281, 1281, 1281, 1281,
-     1168, 1168, 1168, 1168, 1168, 1168, 1168,  365,  551,  946,
-     1113, 1114, 1114, 1114, 1114, 1114, 1114, 1115,  535,  542,
-      453, 1116,  539,  450,  444,   55,   55, 1116, 1116, 1116,
-     1116, 1116, 1116, 1117, 1118, 1118, 1118, 1118, 1118, 1118,
-     1118, 1119,   55,   55,   55, 1120,   55, 1121,   55, 1350,
+     1098, 1098, 1099,  600, 1305,  599, 1100,   51,  918,   51,
+      598, 1100, 1100, 1100, 1100, 1100, 1100, 1230, 1231, 1231,
+     1231, 1231, 1231, 1231, 1234, 1235, 1235, 1235, 1235, 1235,
+     1235,  597,   51,  918,  925, 1101, 1101, 1101, 1101, 1101,
+     1101, 1101, 1102,  333,  234,  596, 1103,  595,  929,   51,
+      594, 1103, 1103, 1103, 1103, 1103, 1103, 1240, 1241, 1241,
+     1241, 1241, 1241, 1241, 1243, 1244, 1244, 1244, 1244, 1244,
+     1244,  593,   51,  929,  937, 1104, 1104, 1104, 1104, 1104,
+     1104, 1104, 1105,  592,  591,  590, 1106,  589,  941,   51,
+      588, 1106, 1106, 1106, 1106, 1106, 1106, 1247, 1248, 1248,
 
-       55, 1120, 1120, 1120, 1120, 1120, 1120, 1308, 1305,  535,
-       55,  533,  444, 1728,   55,  436,   55,   55,   55,  430,
-      520, 1303,  519, 1121,  910, 1124, 1124, 1124, 1124, 1124,
-     1124, 1124, 1101, 1312, 1583,   55, 1125, 1402, 1717, 1728,
-       55,   55, 1125, 1125, 1125, 1125, 1125, 1125, 1126, 1127,
-     1127, 1127, 1127, 1127, 1127, 1127, 1128,   55,   55,   55,
-     1129,  518, 1130,  517,  516,   55, 1129, 1129, 1129, 1129,
-     1129, 1129, 1309, 1313,  515,   55, 1337, 1338, 1338, 1338,
-     1338, 1338, 1338,   55, 1352,   55, 1307,  514, 1130,  919,
-     1135, 1135, 1135, 1135, 1135, 1135, 1135, 1104, 1353,  513,
+     1248, 1248, 1248, 1248, 1254, 1255, 1255, 1255, 1255, 1255,
+     1255,   51, 1340,  941, 1108, 1109, 1109, 1109, 1109, 1109,
+     1109, 1110,  587,  586,  585, 1111, 1723,  584,   51,  576,
+     1111, 1111, 1111, 1111, 1111, 1111, 1112, 1113, 1113, 1113,
+     1113, 1113, 1113, 1113, 1114,  573, 1306,  570, 1115,  569,
+     1116, 1723,  568, 1115, 1115, 1115, 1115, 1115, 1115, 1257,
+     1258, 1258, 1258, 1258, 1258, 1258, 1261, 1262, 1262, 1262,
+     1262, 1262, 1262, 1345,   51, 1116,  905, 1119, 1119, 1119,
+     1119, 1119, 1119, 1119, 1096,  567,  566, 1346, 1120,  565,
+      564,   51,   51, 1120, 1120, 1120, 1120, 1120, 1120, 1121,
 
-     1403, 1136,  512,   55,  511,   55,  510, 1136, 1136, 1136,
-     1136, 1136, 1136, 1137, 1138, 1138, 1138, 1138, 1138, 1138,
-     1138, 1139, 1405,   55, 1353, 1140,  509, 1141, 1352,  508,
-      507, 1140, 1140, 1140, 1140, 1140, 1140, 1317,  506,  503,
-      502,  499, 1728, 1246, 1246, 1246, 1246, 1246, 1246, 1246,
-      498, 1358,   55, 1141,  930, 1147, 1147, 1147, 1147, 1147,
-     1147, 1147, 1107,  497,  496, 1359, 1148,  495, 1728,  120,
-       55,  494, 1148, 1148, 1148, 1148, 1148, 1148, 1149, 1150,
-     1150, 1150, 1150, 1150, 1150, 1150, 1151, 1408, 1358, 1360,
-     1152, 1359, 1153, 1360,  493,  481, 1152, 1152, 1152, 1152,
+     1122, 1122, 1122, 1122, 1122, 1122, 1122, 1123, 1307,   51,
+      563, 1124, 1346, 1125, 1622,  562, 1124, 1124, 1124, 1124,
+     1124, 1124, 1268, 1269, 1269, 1269, 1269, 1269, 1269, 1271,
+     1272, 1272, 1272, 1272, 1272, 1272, 1345,   51, 1125,  914,
+     1130, 1130, 1130, 1130, 1130, 1130, 1130, 1099,  561,  465,
+     1723, 1131,  274,  448,   51, 1394, 1131, 1131, 1131, 1131,
+     1131, 1131, 1132, 1133, 1133, 1133, 1133, 1133, 1133, 1133,
+     1134,  360, 1395,  546, 1135, 1723, 1136,  530,  537, 1135,
+     1135, 1135, 1135, 1135, 1135, 1275, 1276, 1276, 1276, 1276,
+     1276, 1276, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1347,
 
-     1152, 1152, 1728, 1361,  480,  479,  478, 1728, 1260, 1260,
-     1260, 1260, 1260, 1260, 1260,  477, 1366,   55, 1153,  942,
-     1159, 1159, 1159, 1159, 1159, 1159, 1159, 1110, 1728, 1361,
-     1367, 1160,  476, 1728,  475,   55,  474, 1160, 1160, 1160,
-     1160, 1160, 1160, 1161, 1162, 1162, 1162, 1162, 1162, 1162,
-     1162, 1163, 1475, 1366, 1368, 1164, 1367, 1165, 1368,  473,
-      277, 1164, 1164, 1164, 1164, 1164, 1164, 1728, 1369,  470,
-      279,  453, 1728, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
-      367, 1374,   55, 1165, 1068, 1176, 1176, 1176, 1176, 1176,
-     1176, 1176, 1070, 1728, 1369, 1375, 1177,  450, 1728,  444,
+       51, 1136,  925, 1142, 1142, 1142, 1142, 1142, 1142, 1142,
+     1102,  448,  534, 1348, 1143,  445,  439,   51,   51, 1143,
+     1143, 1143, 1143, 1143, 1143, 1144, 1145, 1145, 1145, 1145,
+     1145, 1145, 1145, 1146,   51,   51, 1397, 1147, 1348, 1148,
+     1218, 1288, 1147, 1147, 1147, 1147, 1147, 1147, 1408, 1290,
+     1300,   51, 1332, 1333, 1333, 1333, 1333, 1333, 1333,   51,
+     1347,   51, 1298,   51, 1148,  937, 1154, 1154, 1154, 1154,
+     1154, 1154, 1154, 1105, 1723,  530,   51, 1155,   51, 1650,
+       51,   51, 1155, 1155, 1155, 1155, 1155, 1155, 1156, 1157,
+     1157, 1157, 1157, 1157, 1157, 1157, 1158,   51,   51, 1723,
 
-       55, 1374, 1177, 1177, 1177, 1177, 1177, 1177, 1178, 1179,
-     1179, 1179, 1179, 1179, 1179, 1728,  444, 1547,  437, 1180,
-      437, 1375,   55,  429,   55, 1180, 1180, 1180, 1180, 1180,
-     1180,   55,  619, 1204, 1204, 1204, 1204, 1204, 1204, 1204,
-       55, 1728,   55,  420,  989, 1715,  419, 1719,  416,   55,
-      989,  989,  989,  989,  989,  989,   53,  989,  989,  989,
-      989,  989,  989,  989,   55,  267, 1097, 1097, 1097, 1097,
-     1097, 1097, 1097,  415,   55,   55, 1376, 1376,   55,   55,
-      414, 1421,   55, 1207, 1208, 1208, 1208, 1208, 1208, 1208,
-     1377, 1728,   55,   55, 1209, 1422,   55,   55, 1399,  413,
+     1159, 1629, 1160, 1288,  528, 1159, 1159, 1159, 1159, 1159,
+     1159, 1723, 1304,  439,   51, 1241, 1241, 1241, 1241, 1241,
+     1241, 1241,   51,  431, 1353, 1302,   51, 1160, 1063, 1171,
+     1171, 1171, 1171, 1171, 1171, 1171, 1065,  425, 1354,   51,
+     1172,  515,  514,   51, 1353, 1172, 1172, 1172, 1172, 1172,
+     1172, 1173, 1174, 1174, 1174, 1174, 1174, 1174, 1723, 1485,
+     1398,  513, 1175, 1354,  512,   51,  511, 1175, 1175, 1175,
+     1175, 1175, 1175,   51,  614, 1199, 1199, 1199, 1199, 1199,
+     1199, 1199,   51, 1723,  510,  509,  984, 1637,  508,  507,
+       51,  984,  984,  984,  984,  984,  984,   49,  984,  984,
 
-     1209, 1209, 1209, 1209, 1209, 1209,  910, 1012, 1012, 1012,
-     1012, 1012, 1012, 1012, 1101, 1400, 1377, 1728, 1013,  412,
-      411, 1422,  410, 1421, 1013, 1013, 1013, 1013, 1013, 1013,
-     1210, 1211, 1211, 1211, 1211, 1211, 1211, 1728,  409,  408,
-      407, 1212,  406,  405,  404,  403,   55, 1212, 1212, 1212,
-     1212, 1212, 1212,  919, 1024, 1024, 1024, 1024, 1024, 1024,
-     1024, 1104,  402, 1728,   55, 1025,  401,  400,  395,  394,
-     1468, 1025, 1025, 1025, 1025, 1025, 1025, 1213, 1214, 1214,
-     1214, 1214, 1214, 1214, 1469, 1698,  393,  392, 1215,  391,
-      320,  390,  389,   55, 1215, 1215, 1215, 1215, 1215, 1215,
+      984,  984,  984,  984,  984,   51,  262, 1092, 1092, 1092,
+     1092, 1092, 1092, 1092,  506,   51, 1355, 1355,  505, 1361,
+       51, 1361,   51, 1202, 1203, 1203, 1203, 1203, 1203, 1203,
+     1356, 1723,   51, 1362, 1204, 1723, 1652,   51,  504, 1204,
+     1204, 1204, 1204, 1204, 1204,  905, 1007, 1007, 1007, 1007,
+     1007, 1007, 1007, 1096, 1403, 1356, 1723, 1008, 1362,   51,
+     1723, 1363, 1008, 1008, 1008, 1008, 1008, 1008, 1205, 1206,
+     1206, 1206, 1206, 1206, 1206, 1364,   51,  503,  502, 1207,
+      501, 1638,   51,  498, 1207, 1207, 1207, 1207, 1207, 1207,
+      914, 1019, 1019, 1019, 1019, 1019, 1019, 1019, 1099,   51,
 
-      930, 1039, 1039, 1039, 1039, 1039, 1039, 1039, 1107,  388,
-     1469,   55, 1040,  387,  386,  385,  379, 1468, 1040, 1040,
-     1040, 1040, 1040, 1040, 1216, 1217, 1217, 1217, 1217, 1217,
-     1217, 1728, 1723,  279,  367, 1218,  275,  364,  272,  360,
-      266, 1218, 1218, 1218, 1218, 1218, 1218,  942, 1055, 1055,
-     1055, 1055, 1055, 1055, 1055, 1110,  260, 1728,  143, 1056,
-      348,  347,  346,  341, 1470, 1056, 1056, 1056, 1056, 1056,
-     1056, 1219, 1220, 1220, 1220, 1220, 1220, 1220, 1471,  320,
-      340,  339, 1221,  338,  337,  336,  335,  334, 1221, 1221,
-     1221, 1221, 1221, 1221, 1223, 1224, 1224, 1224, 1224, 1224,
+     1364,  497, 1020,  494, 1639,   51, 1363, 1020, 1020, 1020,
+     1020, 1020, 1020, 1208, 1209, 1209, 1209, 1209, 1209, 1209,
+     1723,  493,   51,  492, 1210,  491,  490, 1641,  115, 1210,
+     1210, 1210, 1210, 1210, 1210,  925, 1034, 1034, 1034, 1034,
+     1034, 1034, 1034, 1102,  489, 1723,  488, 1035,  476,   51,
+       51, 1369, 1035, 1035, 1035, 1035, 1035, 1035, 1211, 1212,
+     1212, 1212, 1212, 1212, 1212, 1370,   51,   51,  475, 1213,
+      474, 1654,   51,  473, 1213, 1213, 1213, 1213, 1213, 1213,
+      937, 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1105,   51,
+     1370, 1657, 1051,  472,   51,   51,   51, 1051, 1051, 1051,
 
-     1224, 1224, 1225,  333, 1471,  332, 1226,  331, 1227,  330,
-      329,  328, 1226, 1226, 1226, 1226, 1226, 1226, 1382, 1383,
-     1383, 1383, 1383, 1383, 1383, 1385, 1386, 1386, 1386, 1386,
-     1386, 1386,   55,  327, 1227, 1117, 1231, 1231, 1231, 1231,
-     1231, 1231, 1231, 1119,  326,  323,  322, 1232,  321,  320,
-       55, 1406,  319, 1232, 1232, 1232, 1232, 1232, 1232, 1126,
-     1241, 1241, 1241, 1241, 1241, 1241, 1241, 1128, 1407,  318,
-      317, 1242,  316,  315,  314,  313,  312, 1242, 1242, 1242,
-     1242, 1242, 1242, 1137, 1254, 1254, 1254, 1254, 1254, 1254,
-     1254, 1139,  311,  310,  309, 1255,  308,  307,  306,  305,
+     1051, 1051, 1051, 1214, 1215, 1215, 1215, 1215, 1215, 1215,
+     1630,   51,   51,   51, 1216,  471, 1656,   51,   51, 1216,
+     1216, 1216, 1216, 1216, 1216, 1218, 1219, 1219, 1219, 1219,
+     1219, 1219, 1219, 1220,   51,   51, 1658, 1221,  470, 1222,
+      469,  468, 1221, 1221, 1221, 1221, 1221, 1221, 1308, 1312,
+     1255, 1255, 1255, 1255, 1255, 1255, 1255, 1269, 1269, 1269,
+     1269, 1269, 1269, 1269, 1222, 1112, 1226, 1226, 1226, 1226,
+     1226, 1226, 1226, 1114,  272,  465,  274, 1227,  448,  362,
+       51,   51, 1227, 1227, 1227, 1227, 1227, 1227, 1121, 1236,
+     1236, 1236, 1236, 1236, 1236, 1236, 1123,   51,   51,  445,
 
-      304, 1255, 1255, 1255, 1255, 1255, 1255, 1149, 1268, 1268,
-     1268, 1268, 1268, 1268, 1268, 1151,  303,  302,  301, 1269,
-      300,  299,  298,  297,  143, 1269, 1269, 1269, 1269, 1269,
-     1269, 1161, 1282, 1282, 1282, 1282, 1282, 1282, 1282, 1163,
-      296,  295,  294, 1283,  293,  292,  291,  290,  289, 1283,
-     1283, 1283, 1283, 1283, 1283, 1068, 1291, 1291, 1291, 1291,
-     1291, 1291, 1291, 1070,  288,  287,  286, 1292,  285,  284,
-      283,  282,  279, 1292, 1292, 1292, 1292, 1292, 1292, 1293,
-     1294, 1294, 1294, 1294, 1294, 1294, 1294, 1295,  267,  272,
-      259, 1296,  258, 1297,   55,   55, 1470, 1296, 1296, 1296,
+     1237,  439, 1667, 1675,   51, 1237, 1237, 1237, 1237, 1237,
+     1237, 1132, 1249, 1249, 1249, 1249, 1249, 1249, 1249, 1134,
+      439,   51,  432, 1250,  432,  424, 1676,   51, 1250, 1250,
+     1250, 1250, 1250, 1250, 1144, 1263, 1263, 1263, 1263, 1263,
+     1263, 1263, 1146,  415,   51,  414, 1264,  411,  410, 1681,
+       51, 1264, 1264, 1264, 1264, 1264, 1264, 1156, 1277, 1277,
+     1277, 1277, 1277, 1277, 1277, 1158,  409,   51,  408, 1278,
+      407, 1682,   51,   51, 1278, 1278, 1278, 1278, 1278, 1278,
+     1063, 1286, 1286, 1286, 1286, 1286, 1286, 1286, 1065,   51,
+       51,  406, 1287, 1688, 1685,  405,  404, 1287, 1287, 1287,
 
-     1296, 1296, 1296, 1389, 1390, 1390, 1390, 1390, 1390, 1390,
-     1728,   55,   55,   55,  257,   55,   55,   55,  256, 1297,
-       55,  619,  525,  525,  525,  525,  525,  525,  525,   55,
-      255, 1534, 1576,   55,   55,   55, 1728, 1506,   55, 1318,
-     1319, 1319, 1319, 1319, 1319, 1319, 1320, 1397, 1410, 1660,
-     1321, 1507, 1586,  254,  253,   55, 1321, 1321, 1321, 1321,
-     1321, 1321, 1117, 1322, 1322, 1322, 1322, 1322, 1322, 1322,
-     1323,   55,   55,   55, 1324,  252, 1121, 1507,  251,  250,
-     1324, 1324, 1324, 1324, 1324, 1324,  247, 1480,  244,   55,
-       55, 1427, 1428, 1428, 1428, 1428, 1428, 1428,  241,  240,
+     1287, 1287, 1287, 1288, 1289, 1289, 1289, 1289, 1289, 1289,
+     1289, 1290,   51, 1369, 1371, 1291, 1371, 1292,  403,  402,
+     1291, 1291, 1291, 1291, 1291, 1291,  401, 1723, 1372,   51,
+     1723, 1377, 1378, 1378, 1378, 1378, 1378, 1378, 1391,   51,
+       51,   51, 1292,   51,  614,  520,  520,  520,  520,  520,
+      520,  520, 1723, 1372,  400, 1723,   51,   51,   51, 1416,
+       51, 1313, 1314, 1314, 1314, 1314, 1314, 1314, 1315, 1392,
+      399, 1405, 1316, 1417,  398,   51, 1400, 1316, 1316, 1316,
+     1316, 1316, 1316, 1112, 1317, 1317, 1317, 1317, 1317, 1317,
+     1317, 1318,   51,  397,  396, 1319,  395, 1116, 1417,  390,
 
-     1398, 1411, 1121, 1126, 1325, 1325, 1325, 1325, 1325, 1325,
-     1325, 1326,  239,  238,  235, 1327,  234, 1130,  233,  232,
-      231, 1327, 1327, 1327, 1327, 1327, 1327, 1432, 1433, 1433,
-     1433, 1433, 1433, 1433, 1435, 1436, 1436, 1436, 1436, 1436,
-     1436,  230,  229, 1130, 1137, 1328, 1328, 1328, 1328, 1328,
-     1328, 1328, 1329,  228,  227,  226, 1330,  225, 1141,  224,
-      223,  222, 1330, 1330, 1330, 1330, 1330, 1330, 1441, 1442,
-     1442, 1442, 1442, 1442, 1442, 1444, 1445, 1445, 1445, 1445,
-     1445, 1445,  221,  220, 1141, 1149, 1331, 1331, 1331, 1331,
-     1331, 1331, 1331, 1332,  216,  215,  205, 1333,  204, 1153,
+     1319, 1319, 1319, 1319, 1319, 1319, 1380, 1381, 1381, 1381,
+     1381, 1381, 1381, 1384, 1385, 1385, 1385, 1385, 1385, 1385,
+     1416,   51, 1116, 1121, 1320, 1320, 1320, 1320, 1320, 1320,
+     1320, 1321,  389,   51, 1723, 1322,   51, 1125,   51,   51,
+     1322, 1322, 1322, 1322, 1322, 1322,  388,  387,  386, 1393,
+       51,  315,  385,   51,  384,  383,   51, 1401,  382, 1723,
+      381, 1406, 1125, 1132, 1323, 1323, 1323, 1323, 1323, 1323,
+     1323, 1324, 1529,  380, 1402, 1325,  374, 1136,  274,  362,
+     1325, 1325, 1325, 1325, 1325, 1325, 1422, 1423, 1423, 1423,
+     1423, 1423, 1423, 1427, 1428, 1428, 1428, 1428, 1428, 1428,
 
-      203,  200,  199, 1333, 1333, 1333, 1333, 1333, 1333, 1450,
-     1451, 1451, 1451, 1451, 1451, 1451, 1453, 1454, 1454, 1454,
-     1454, 1454, 1454,  194,  193, 1153, 1161, 1334, 1334, 1334,
-     1334, 1334, 1334, 1334, 1335,  192,  191,  190, 1336,  189,
-     1165,  188,  187,  186, 1336, 1336, 1336, 1336, 1336, 1336,
-     1459, 1460, 1460, 1460, 1460, 1460, 1460, 1462, 1463, 1463,
-     1463, 1463, 1463, 1463, 1506,   55, 1165, 1223, 1339, 1339,
-     1339, 1339, 1339, 1339, 1339, 1225,  185,  181, 1728, 1340,
-      180,  179,  178,   55,  177, 1340, 1340, 1340, 1340, 1340,
-     1340, 1117, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1323,
+      270,   51, 1136, 1144, 1326, 1326, 1326, 1326, 1326, 1326,
+     1326, 1327,  359,  267,  355, 1328,  261, 1148,   51,  255,
+     1328, 1328, 1328, 1328, 1328, 1328, 1430, 1431, 1431, 1431,
+     1431, 1431, 1431, 1436, 1437, 1437, 1437, 1437, 1437, 1437,
+      138,   51, 1148, 1156, 1329, 1329, 1329, 1329, 1329, 1329,
+     1329, 1330,  343,  342,  341, 1331,  336, 1160,   51,  315,
+     1331, 1331, 1331, 1331, 1331, 1331, 1439, 1440, 1440, 1440,
+     1440, 1440, 1440, 1445, 1446, 1446, 1446, 1446, 1446, 1446,
+     1463,   51, 1160, 1218, 1334, 1334, 1334, 1334, 1334, 1334,
+     1334, 1220,  335,  334, 1464, 1335,  333,  332,   51,   51,
 
-      176, 1579,  175, 1348, 1728,  174,  173,  172,  171, 1348,
-     1348, 1348, 1348, 1348, 1348, 1126, 1354, 1354, 1354, 1354,
-     1354, 1354, 1354, 1326,  170,  169,  168, 1355,  167,  166,
-      165,  160,  151, 1355, 1355, 1355, 1355, 1355, 1355, 1137,
-     1362, 1362, 1362, 1362, 1362, 1362, 1362, 1329,  150,  145,
-       59, 1363,   47,   45, 1728, 1728, 1728, 1363, 1363, 1363,
-     1363, 1363, 1363, 1149, 1370, 1370, 1370, 1370, 1370, 1370,
-     1370, 1332, 1728, 1728, 1728, 1371, 1728, 1728, 1728, 1728,
-     1728, 1371, 1371, 1371, 1371, 1371, 1371, 1161, 1378, 1378,
-     1378, 1378, 1378, 1378, 1378, 1335, 1728, 1728, 1728, 1379,
+     1335, 1335, 1335, 1335, 1335, 1335, 1112, 1342, 1342, 1342,
+     1342, 1342, 1342, 1342, 1318, 1470,   51,  331, 1343, 1464,
+      330,   51,   51, 1343, 1343, 1343, 1343, 1343, 1343, 1121,
+     1349, 1349, 1349, 1349, 1349, 1349, 1349, 1321,   51,   51,
+     1689, 1350,  329, 1695, 1703,   51, 1350, 1350, 1350, 1350,
+     1350, 1350, 1132, 1357, 1357, 1357, 1357, 1357, 1357, 1357,
+     1324,  328,   51,  327, 1358,  326,  325,   51,   51, 1358,
+     1358, 1358, 1358, 1358, 1358, 1144, 1365, 1365, 1365, 1365,
+     1365, 1365, 1365, 1327,   51,   51, 1705, 1366,  324,  323,
+     1710,  322, 1366, 1366, 1366, 1366, 1366, 1366, 1156, 1373,
 
-     1728, 1728, 1728, 1728, 1728, 1379, 1379, 1379, 1379, 1379,
-     1379, 1293, 1391, 1391, 1391, 1391, 1391, 1391, 1391, 1295,
-     1728, 1728, 1728, 1392, 1728, 1728, 1728, 1728, 1728, 1392,
-     1392, 1392, 1392, 1392, 1392, 1223, 1412, 1412, 1412, 1412,
-     1412, 1412, 1412, 1413, 1728, 1728, 1728, 1414, 1728, 1227,
-     1728, 1728, 1728, 1414, 1414, 1414, 1414, 1414, 1414, 1383,
-     1383, 1383, 1383, 1383, 1383, 1383, 1500, 1501, 1501, 1501,
-     1501, 1501, 1501, 1510,   55, 1227, 1117, 1231, 1231, 1231,
-     1231, 1231, 1231, 1231, 1323, 1728, 1728, 1511, 1232, 1728,
-     1728, 1728,   55, 1728, 1232, 1232, 1232, 1232, 1232, 1232,
+     1373, 1373, 1373, 1373, 1373, 1373, 1330,  321, 1709,  318,
+     1374,  317,  316,   51,   51, 1374, 1374, 1374, 1374, 1374,
+     1374, 1288, 1386, 1386, 1386, 1386, 1386, 1386, 1386, 1290,
+       51,   51,  315, 1387, 1712,  314,   51,   51, 1387, 1387,
+     1387, 1387, 1387, 1387, 1218, 1407, 1407, 1407, 1407, 1407,
+     1407, 1407, 1408,   51,   51,  313, 1409,  312, 1222, 1714,
+      311, 1409, 1409, 1409, 1409, 1409, 1409, 1448, 1449, 1449,
+     1449, 1449, 1449, 1449, 1454, 1455, 1455, 1455, 1455, 1455,
+     1455, 1463,   51, 1222, 1112, 1226, 1226, 1226, 1226, 1226,
+     1226, 1226, 1318,  310,  309, 1723, 1227,  308,  307,   51,
 
-     1126, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1326, 1728,
-     1580, 1728, 1242, 1511, 1728, 1728, 1728, 1728, 1242, 1242,
-     1242, 1242, 1242, 1242, 1137, 1254, 1254, 1254, 1254, 1254,
-     1254, 1254, 1329, 1728, 1728, 1728, 1255, 1728, 1728, 1728,
-     1728, 1728, 1255, 1255, 1255, 1255, 1255, 1255, 1149, 1268,
-     1268, 1268, 1268, 1268, 1268, 1268, 1332, 1728, 1728, 1728,
-     1269, 1728, 1728, 1728, 1728, 1728, 1269, 1269, 1269, 1269,
-     1269, 1269, 1161, 1282, 1282, 1282, 1282, 1282, 1282, 1282,
-     1335, 1728, 1728, 1728, 1283, 1728, 1728, 1728, 1728, 1728,
-     1283, 1283, 1283, 1283, 1283, 1283, 1223, 1423, 1423, 1423,
+       51, 1227, 1227, 1227, 1227, 1227, 1227, 1121, 1236, 1236,
+     1236, 1236, 1236, 1236, 1236, 1321, 1542,   51,  306, 1237,
+     1723,  305,   51,   51, 1237, 1237, 1237, 1237, 1237, 1237,
+     1132, 1249, 1249, 1249, 1249, 1249, 1249, 1249, 1324,   51,
+       51,  304, 1250,  303,  302,   51,   51, 1250, 1250, 1250,
+     1250, 1250, 1250, 1144, 1263, 1263, 1263, 1263, 1263, 1263,
+     1263, 1327,   51,   51,  301, 1264,  300,  299,   51,  298,
+     1264, 1264, 1264, 1264, 1264, 1264, 1156, 1277, 1277, 1277,
+     1277, 1277, 1277, 1277, 1330,   51,  297,  296, 1278,  295,
+      294,  293,  292, 1278, 1278, 1278, 1278, 1278, 1278, 1218,
 
-     1423, 1423, 1423, 1423, 1413, 1728, 1728, 1728, 1424, 1728,
-     1728, 1728,   55, 1728, 1424, 1424, 1424, 1424, 1424, 1424,
-     1293, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1295,   55,
-       55,   55, 1473, 1728, 1510, 1728, 1728, 1728, 1473, 1473,
-     1473, 1473, 1473, 1473, 1487,   55, 1728,   55, 1728,   55,
-     1433, 1433, 1433, 1433, 1433, 1433, 1433, 1728, 1484, 1728,
-     1728, 1488, 1514,   55, 1485, 1223, 1339, 1339, 1339, 1339,
-     1339, 1339, 1339, 1413, 1728, 1548, 1515, 1340, 1728, 1728,
-     1728, 1728, 1514, 1340, 1340, 1340, 1340, 1340, 1340, 1442,
-     1442, 1442, 1442, 1442, 1442, 1442, 1728, 1518, 1518, 1728,
+     1418, 1418, 1418, 1418, 1418, 1418, 1418, 1408,  138,  291,
+      290, 1419,  289,  288,  287,  286, 1419, 1419, 1419, 1419,
+     1419, 1419, 1457, 1458, 1458, 1458, 1458, 1458, 1458, 1378,
+     1378, 1378, 1378, 1378, 1378, 1378, 1465, 1465,   51,   51,
+       51,   51,   51, 1495, 1496, 1496, 1496, 1496, 1496, 1496,
+     1466, 1723, 1501,  285,  284,   51,   51,   51,   51,   51,
+      283,  282,  281,  280,  279,  278, 1502, 1479, 1486, 1475,
+     1483, 1482, 1501, 1480, 1505, 1466, 1723, 1288, 1467, 1467,
+     1467, 1467, 1467, 1467, 1467, 1290, 1723,  277, 1506, 1468,
+      274, 1502,  262,  267, 1468, 1468, 1468, 1468, 1468, 1468,
 
-     1728, 1728, 1515, 1451, 1451, 1451, 1451, 1451, 1451, 1451,
-     1522, 1519, 1728, 1460, 1460, 1460, 1460, 1460, 1460, 1460,
-     1522, 1728, 1728, 1728, 1523, 1526, 1527, 1527, 1527, 1527,
-     1527, 1527, 1728,   55, 1728,   55,   55, 1519, 1728, 1529,
-     1530, 1530, 1530, 1530, 1530, 1530,   55,   55,   55, 1728,
-     1523,   55,   55,   55,   55, 1551, 1728, 1551,   55,   55,
-     1728,   55, 1538, 1539,   55,   55,   55, 1543, 1728, 1552,
-       55, 1728, 1728, 1540, 1541, 1542,   55,   55, 1728,   55,
-     1728, 1545, 1553, 1554, 1554, 1554, 1554, 1554, 1554, 1728,
-     1728, 1728, 1728, 1622, 1582, 1552, 1587, 1728, 1557, 1558,
+     1218, 1334, 1334, 1334, 1334, 1334, 1334, 1334, 1408,  254,
+      253, 1723, 1335, 1506,  252,  251, 1505, 1335, 1335, 1335,
+     1335, 1335, 1335, 1428, 1428, 1428, 1428, 1428, 1428, 1428,
+     1723, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1509, 1509,
+     1446, 1446, 1446, 1446, 1446, 1446, 1446, 1513, 1513,  250,
+      249,  248, 1510, 1723,  247, 1723, 1517, 1517,  246,  245,
+      242, 1514, 1723, 1455, 1455, 1455, 1455, 1455, 1455, 1455,
+     1518, 1723,  239,  236,  235,  234,  233, 1510, 1723, 1521,
+     1522, 1522, 1522, 1522, 1522, 1522, 1514, 1723, 1524, 1525,
+     1525, 1525, 1525, 1525, 1525, 1518, 1723,   51,   51,   51,
 
-     1558, 1558, 1558, 1558, 1558, 1561, 1562, 1562, 1562, 1562,
-     1562, 1562, 1565, 1566, 1566, 1566, 1566, 1566, 1566, 1569,
-     1570, 1570, 1570, 1570, 1570, 1570, 1527, 1527, 1527, 1527,
-     1527, 1527, 1527, 1573, 1573,   55,   55,   55, 1589, 1590,
-     1590, 1590, 1590, 1590, 1590, 1728, 1728, 1574, 1728, 1728,
-     1728, 1728, 1728,   55,   55,   55, 1728, 1728, 1728, 1728,
-     1728, 1728, 1578, 1585, 1588, 1554, 1554, 1554, 1554, 1554,
-     1554, 1554, 1728, 1574, 1728, 1558, 1558, 1558, 1558, 1558,
-     1558, 1558, 1562, 1562, 1562, 1562, 1562, 1562, 1562, 1566,
-     1566, 1566, 1566, 1566, 1566, 1566, 1570, 1570, 1570, 1570,
+       51,   51,   51,   51,   51,   51,  230,  229,   51,  228,
+      227,  226,  225,  224,   51,   51,   51,   51,   51,   51,
+       51,   51,   51, 1530, 1531,   51, 1533, 1534, 1535, 1536,
+     1537, 1538, 1546, 1540, 1546,  223,  222, 1543, 1548, 1549,
+     1549, 1549, 1549, 1549, 1549,  221, 1547,  220, 1723, 1552,
+     1553, 1553, 1553, 1553, 1553, 1553, 1556, 1557, 1557, 1557,
+     1557, 1557, 1557, 1560, 1561, 1561, 1561, 1561, 1561, 1561,
+      219, 1547,  218, 1723, 1564, 1565, 1565, 1565, 1565, 1565,
+     1565, 1522, 1522, 1522, 1522, 1522, 1522, 1522, 1568, 1568,
+       51,   51,   51,   51,   51,   51,   51,   51,   51,   51,
 
-     1570, 1570, 1570, 1598, 1599, 1599, 1599, 1599, 1599, 1599,
-       55,   55, 1728,   55,   55,   55,   55,   55, 1590, 1590,
-     1590, 1590, 1590, 1590, 1590,   55,   55, 1728,   55,   55,
-     1605,   55,   55,   55,   55,   55, 1728, 1728, 1728, 1728,
-     1728, 1728, 1611,   55,   55, 1601,   55, 1606,   55,   55,
-     1607, 1608, 1609, 1612, 1599, 1599, 1599, 1599, 1599, 1599,
-     1599,   55, 1620, 1628,   55,   55,   55,   55,   55,   55,
-     1728,   55,   55, 1621,   55,   55,   55,   55, 1728,   55,
-     1623, 1625,   55,   55, 1728, 1728,   55,   55, 1629,   55,
-       55,   55,   55,   55,   55,   55, 1647, 1630, 1637, 1728,
+      217,  216, 1569, 1723,   51,   51,   51,   51,   51,   51,
+       51,   51,   51,   51,   51,   51,   51, 1573, 1580, 1583,
+      215,   51,   51,   51,  211,  210, 1571, 1569, 1723, 1574,
+     1575, 1577, 1596,  200, 1578, 1581,  199, 1617,  198, 1604,
+     1582, 1584, 1585, 1585, 1585, 1585, 1585, 1585, 1549, 1549,
+     1549, 1549, 1549, 1549, 1549, 1553, 1553, 1553, 1553, 1553,
+     1553, 1553, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1561,
+     1561, 1561, 1561, 1561, 1561, 1561, 1565, 1565, 1565, 1565,
+     1565, 1565, 1565, 1593, 1594, 1594, 1594, 1594, 1594, 1594,
+       51,  195,   51,   51,   51,   51, 1585, 1585, 1585, 1585,
 
-       55,   55, 1638, 1645,   55, 1633, 1641, 1639, 1728,   55,
-       55, 1640,   55, 1648, 1649,   55, 1650, 1651, 1728,   55,
-       55, 1728,   55,   55,   55,   55, 1652, 1728,   55, 1728,
-       55,   55,   55,   55, 1728,   55, 1653,   55,   55, 1654,
-     1728,   55,   55,   55, 1658, 1656, 1666, 1665, 1728,   55,
-       55,   55, 1664,   55, 1670,   55, 1675,   55, 1667, 1668,
-     1677,   55,   55,   55,   55, 1728, 1671,   55, 1673,   55,
-     1674,   55,   55, 1676, 1728,   55,   55, 1728,   55,   55,
-       55,   55,   55, 1678, 1728,   55,   55, 1728, 1682,   55,
-       55,   55, 1683, 1728,   55, 1679,   55, 1685, 1684, 1688,
+     1585, 1585, 1585,  194,   51,   51,   51,   51, 1600,   51,
+       51,   51,   51, 1594, 1594, 1594, 1594, 1594, 1594, 1594,
+     1606,   51,   51,   51,   51, 1601,   51,   51, 1602, 1603,
+       51, 1607, 1616,   51,   51,   51, 1618,   51,  189,   51,
+     1615,   51,   51,   51,   51,  188,  187,   51,   51,   51,
+       51,   51,   51, 1624,   51, 1620,   51,  186,   51,   51,
+       51, 1625, 1623, 1632,   51,   51,   51, 1633,   51, 1628,
+       51,   51, 1631, 1634, 1640,   51, 1642,   51, 1635, 1636,
+      185,   51,   51,   51,   51,   51,   51,   51,   51,   51,
+       51, 1653,   51, 1643, 1644,   51,  184, 1645, 1646,   51,
 
-       55, 1728, 1689,   55,   55, 1691,   55,   55, 1728,   55,
-     1695, 1692,   55,   55,   55,   55, 1728, 1728,   55, 1696,
-     1697,   55,   55, 1728,   55,   55, 1701,   55,   55, 1699,
-       55,   55,   55,   55, 1704, 1702,   55,   55,   55, 1728,
-       55, 1706, 1709, 1703, 1705,   55,   55,   55,   55,   55,
-       55, 1728, 1707, 1728,   55,   55,   55, 1711, 1728, 1728,
-     1728, 1728, 1728, 1716, 1712,   55,   55,   55,   55, 1728,
-     1728, 1728, 1713, 1728, 1718, 1721, 1722,   55, 1728, 1728,
-     1726, 1727, 1728, 1720, 1728, 1724, 1728, 1725, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728,   55,   46, 1728, 1728, 1728,
+       51,   51, 1647,   51, 1648, 1649,   51,   51,   51,   51,
+     1660, 1661,   51,  183,   51,   51, 1651,   51,   51,  182,
+     1655,   51, 1659, 1662, 1663,   51, 1666, 1664,   51,   51,
+     1668,   51,   51, 1670,   51,   51, 1665,  181,   51,   51,
+       51,  180,   51,   51,   51,   51,   51,   51, 1669, 1673,
+     1671,  176,   51, 1672, 1677,  175,   51,   51, 1674,   51,
+       51,   51,   51, 1679,   51,   51,  174,   51, 1678,   51,
+       51,   51, 1680, 1683, 1684, 1686,   51,  173,  172,   51,
+       51, 1687,   51, 1690,   51,  171,  170,   51,   51,  169,
+       51,   51,   51,   51, 1691, 1692,   51,   51, 1694,   51,
 
-     1728,   46,   46,   46,   64, 1728,   64,   64,   64,   64,
-       64,   64,   64,  152, 1728,  152,  159,  159,  159,  271,
-      271,  271,  280,  280,  280,  359,  359,  359,  362,  362,
-      362,  363,  363,  363,  370,  370,  370,  368,  368,  368,
-      374,  374,  374,  378, 1728,  378,  443,  443,  443,  448,
-      448,  448,  449,  449,  449,  458,  458,  458,  462, 1728,
-      462,  463,  463,  463,  372,  372, 1728, 1728,  372,  467,
-      467,  467,  471,  471,  471,  362,  362,  362,  532,  532,
-      532,  536,  536,  536,  537,  537,  537,  538,  538,  538,
-      370,  370,  370,  543,  543,  543,  456,  456, 1728, 1728,
+       51, 1696, 1697, 1693,   51,  168, 1699,   51,   51,   51,
+       51,   51, 1698,   51,   51,   51,   51,   51,   51, 1701,
+     1700,   51, 1704,   51,   51,   51,  167,   51,   51, 1702,
+      166,   51,   51, 1706,  165,   51, 1707,  164,  163, 1708,
+       51,   51,   51,  162, 1711,  161,  160, 1713,  155, 1715,
+     1717, 1716,  146,  145,   51,  140, 1718, 1721, 1722, 1719,
+       55, 1720,   52,   43,   41, 1723, 1723, 1723, 1723, 1723,
+     1723,   51,   42, 1723,   42,   59, 1723,   59,   59,   59,
+       59,   59,   59,  147, 1723,  147,  154,  154,  154,  266,
+      266,  266,  275,  275,  275,  354,  354,  354,  357,  357,
 
-      456,  548,  548,  548,  552,  552,  552,  556, 1728,  556,
-      557,  557,  557,  561,  561,  561,  565, 1728,  565,  624,
-      624,  624,  458,  458,  458,  632,  632,  632,  633,  633,
-      633,  641,  641,  641,  645, 1728,  645,  648, 1728,  648,
-      649,  649,  649,  653,  653,  653,  657, 1728,  657,  555,
-      555, 1728, 1728,  555,  559,  559, 1728, 1728,  559,  663,
-      663,  663,  667,  667,  667,  565,  565, 1728,  565,  537,
-      537,  537,  713,  713,  713,  717,  717,  717,  720,  720,
-      720,  721,  721,  721,  722,  722,  722,  727,  727,  727,
-      639,  639, 1728, 1728,  639,  732,  732,  732,  736,  736,
+      357,  358,  358,  358,  365,  365,  365,  363,  363,  363,
+      369,  369,  369,  373, 1723,  373,  438,  438,  438,  443,
+      443,  443,  444,  444,  444,  453,  453,  453,  457, 1723,
+      457,  458,  458,  458,  367,  367, 1723, 1723,  367,  462,
+      462,  462,  466,  466,  466,  357,  357,  357,  527,  527,
+      527,  531,  531,  531,  532,  532,  532,  533,  533,  533,
+      365,  365,  365,  538,  538,  538,  451,  451, 1723, 1723,
+      451,  543,  543,  543,  547,  547,  547,  551, 1723,  551,
+      552,  552,  552,  556,  556,  556,  560, 1723,  560,  619,
+      619,  619,  453,  453,  453,  627,  627,  627,  628,  628,
 
-      736,  645,  645, 1728,  645,  647,  647, 1728, 1728,  647,
-      648,  648, 1728,  648,  649,  649,  651,  651, 1728, 1728,
-      651,  743,  743,  743,  747,  747,  747,  657,  657, 1728,
-      657,  751, 1728,  751,  754, 1728,  754,  755,  755,  755,
-      759,  759,  759,  763, 1728,  763,  802,  802,  802,  641,
-      641,  641,  653,  653,  653,  813,  813,  813,  814,  814,
-      814,  822,  822,  822,  826, 1728,  826,  829, 1728,  829,
-      830,  830,  830,  834,  834,  834,  838, 1728,  838,  841,
-     1728,  841,  844, 1728,  844,  845,  845,  845,  849,  849,
-      849,  853, 1728,  853,  750, 1728, 1728,  750,  751,  751,
+      628,  636,  636,  636,  640, 1723,  640,  643, 1723,  643,
+      644,  644,  644,  648,  648,  648,  652, 1723,  652,  550,
+      550, 1723, 1723,  550,  554,  554, 1723, 1723,  554,  658,
+      658,  658,  662,  662,  662,  560,  560, 1723,  560,  532,
+      532,  532,  708,  708,  708,  712,  712,  712,  715,  715,
+      715,  716,  716,  716,  717,  717,  717,  722,  722,  722,
+      634,  634, 1723, 1723,  634,  727,  727,  727,  731,  731,
+      731,  640,  640, 1723,  640,  642,  642, 1723, 1723,  642,
+      643,  643, 1723,  643,  644,  644,  646,  646, 1723, 1723,
+      646,  738,  738,  738,  742,  742,  742,  652,  652, 1723,
 
-     1728,  751,  753,  753, 1728, 1728,  753,  754,  754, 1728,
-      754,  755,  755,  757,  757, 1728, 1728,  757,  860,  860,
-      860,  864,  864,  864,  763,  763, 1728,  763,   53,   53,
-       53, 1728,   53,   53,  721,  721,  721,  896,  896,  896,
-      900,  900,  900,  903,  903,  903,  906,  906,  906,  907,
-      907,  907,  908,  908,  908,  913,  913,  913,  820,  820,
-     1728, 1728,  820,  918,  918,  918,  922,  922,  922,  826,
-      826, 1728,  826,  828,  828, 1728, 1728,  828,  829,  829,
-     1728,  829,  830,  830,  832,  832, 1728, 1728,  832,  929,
-      929,  929,  933,  933,  933,  838,  838, 1728,  838,  840,
+      652,  746, 1723,  746,  749, 1723,  749,  750,  750,  750,
+      754,  754,  754,  758, 1723,  758,  797,  797,  797,  636,
+      636,  636,  648,  648,  648,  808,  808,  808,  809,  809,
+      809,  817,  817,  817,  821, 1723,  821,  824, 1723,  824,
+      825,  825,  825,  829,  829,  829,  833, 1723,  833,  836,
+     1723,  836,  839, 1723,  839,  840,  840,  840,  844,  844,
+      844,  848, 1723,  848,  745, 1723, 1723,  745,  746,  746,
+     1723,  746,  748,  748, 1723, 1723,  748,  749,  749, 1723,
+      749,  750,  750,  752,  752, 1723, 1723,  752,  855,  855,
+      855,  859,  859,  859,  758,  758, 1723,  758,   49,   49,
 
-     1728, 1728,  840,  841,  841, 1728,  841,  843,  843, 1728,
-     1728,  843,  844,  844, 1728,  844,  845,  845,  847,  847,
-     1728, 1728,  847,  941,  941,  941,  945,  945,  945,  853,
-      853, 1728,  853,  947, 1728,  947,  950, 1728,  950,  953,
-     1728,  953,  954,  954,  954,  958,  958,  958,  962, 1728,
-      962,   53,   53,   53, 1728,   53,   53,  990,  990,  990,
-      822,  822,  822,  834,  834,  834,  849,  849,  849, 1004,
-     1004, 1004, 1005, 1005, 1005, 1013, 1013, 1013, 1017, 1728,
-     1017, 1020, 1728, 1020, 1021, 1021, 1021, 1025, 1025, 1025,
-     1029, 1728, 1029, 1032, 1728, 1032, 1035, 1728, 1035, 1036,
+       49, 1723,   49,   49,  716,  716,  716,  891,  891,  891,
+      895,  895,  895,  898,  898,  898,  901,  901,  901,  902,
+      902,  902,  903,  903,  903,  908,  908,  908,  815,  815,
+     1723, 1723,  815,  913,  913,  913,  917,  917,  917,  821,
+      821, 1723,  821,  823,  823, 1723, 1723,  823,  824,  824,
+     1723,  824,  825,  825,  827,  827, 1723, 1723,  827,  924,
+      924,  924,  928,  928,  928,  833,  833, 1723,  833,  835,
+     1723, 1723,  835,  836,  836, 1723,  836,  838,  838, 1723,
+     1723,  838,  839,  839, 1723,  839,  840,  840,  842,  842,
+     1723, 1723,  842,  936,  936,  936,  940,  940,  940,  848,
 
-     1036, 1036, 1040, 1040, 1040, 1044, 1728, 1044, 1045, 1728,
-     1045, 1048, 1728, 1048, 1051, 1728, 1051, 1052, 1052, 1052,
-     1056, 1056, 1056, 1060, 1728, 1060,  947, 1728,  947,  949,
-     1728, 1728,  949,  950,  950, 1728,  950,  952,  952, 1728,
-     1728,  952,  953,  953, 1728,  953,  954,  954,  956,  956,
-     1728, 1728,  956, 1067, 1067, 1067, 1071, 1071, 1071,  962,
-      962, 1728,  962,   53,   53,   53, 1728,   53,   53,  907,
-      907,  907, 1098, 1098, 1098, 1102, 1102, 1102, 1105, 1105,
-     1105, 1108, 1108, 1108, 1111, 1111, 1111, 1112, 1112, 1112,
-     1120, 1120, 1120, 1011, 1011, 1728, 1728, 1011, 1125, 1125,
+      848, 1723,  848,  942, 1723,  942,  945, 1723,  945,  948,
+     1723,  948,  949,  949,  949,  953,  953,  953,  957, 1723,
+      957,   49,   49,   49, 1723,   49,   49,  985,  985,  985,
+      817,  817,  817,  829,  829,  829,  844,  844,  844,  999,
+      999,  999, 1000, 1000, 1000, 1008, 1008, 1008, 1012, 1723,
+     1012, 1015, 1723, 1015, 1016, 1016, 1016, 1020, 1020, 1020,
+     1024, 1723, 1024, 1027, 1723, 1027, 1030, 1723, 1030, 1031,
+     1031, 1031, 1035, 1035, 1035, 1039, 1723, 1039, 1040, 1723,
+     1040, 1043, 1723, 1043, 1046, 1723, 1046, 1047, 1047, 1047,
+     1051, 1051, 1051, 1055, 1723, 1055,  942, 1723,  942,  944,
 
-     1125, 1129, 1129, 1129, 1017, 1017, 1728, 1017, 1019, 1019,
-     1728, 1728, 1019, 1020, 1020, 1728, 1020, 1021, 1021, 1023,
-     1023, 1728, 1728, 1023, 1136, 1136, 1136, 1140, 1140, 1140,
-     1029, 1029, 1728, 1029, 1031, 1728, 1728, 1031, 1032, 1032,
-     1728, 1032, 1034, 1034, 1728, 1728, 1034, 1035, 1035, 1728,
-     1035, 1036, 1036, 1038, 1038, 1728, 1728, 1038, 1148, 1148,
-     1148, 1152, 1152, 1152, 1044, 1044, 1728, 1044, 1045, 1728,
-     1045, 1047, 1728, 1728, 1047, 1048, 1048, 1728, 1048, 1050,
-     1050, 1728, 1728, 1050, 1051, 1051, 1728, 1051, 1052, 1052,
-     1054, 1054, 1728, 1728, 1054, 1160, 1160, 1160, 1164, 1164,
+     1723, 1723,  944,  945,  945, 1723,  945,  947,  947, 1723,
+     1723,  947,  948,  948, 1723,  948,  949,  949,  951,  951,
+     1723, 1723,  951, 1062, 1062, 1062, 1066, 1066, 1066,  957,
+      957, 1723,  957,   49,   49,   49, 1723,   49,   49,  902,
+      902,  902, 1093, 1093, 1093, 1097, 1097, 1097, 1100, 1100,
+     1100, 1103, 1103, 1103, 1106, 1106, 1106, 1107, 1107, 1107,
+     1115, 1115, 1115, 1006, 1006, 1723, 1723, 1006, 1120, 1120,
+     1120, 1124, 1124, 1124, 1012, 1012, 1723, 1012, 1014, 1014,
+     1723, 1723, 1014, 1015, 1015, 1723, 1015, 1016, 1016, 1018,
+     1018, 1723, 1723, 1018, 1131, 1131, 1131, 1135, 1135, 1135,
 
-     1164, 1060, 1060, 1728, 1060, 1166, 1728, 1166, 1169, 1728,
-     1169, 1172, 1728, 1172, 1173, 1173, 1173, 1177, 1177, 1177,
-     1181, 1728, 1181,   53,   53,   53, 1728,   53,   53, 1205,
-     1205, 1205, 1013, 1013, 1013, 1025, 1025, 1025, 1040, 1040,
-     1040, 1056, 1056, 1056, 1222, 1222, 1222, 1228, 1228, 1228,
-     1226, 1226, 1226, 1233, 1233, 1233, 1232, 1232, 1232, 1234,
-     1728, 1234, 1237, 1728, 1237, 1238, 1238, 1238, 1243, 1243,
-     1243, 1242, 1242, 1242, 1244, 1728, 1244, 1247, 1728, 1247,
-     1250, 1728, 1250, 1251, 1251, 1251, 1256, 1256, 1256, 1255,
-     1255, 1255, 1257, 1728, 1257, 1258, 1728, 1258, 1261, 1728,
+     1024, 1024, 1723, 1024, 1026, 1723, 1723, 1026, 1027, 1027,
+     1723, 1027, 1029, 1029, 1723, 1723, 1029, 1030, 1030, 1723,
+     1030, 1031, 1031, 1033, 1033, 1723, 1723, 1033, 1143, 1143,
+     1143, 1147, 1147, 1147, 1039, 1039, 1723, 1039, 1040, 1723,
+     1040, 1042, 1723, 1723, 1042, 1043, 1043, 1723, 1043, 1045,
+     1045, 1723, 1723, 1045, 1046, 1046, 1723, 1046, 1047, 1047,
+     1049, 1049, 1723, 1723, 1049, 1155, 1155, 1155, 1159, 1159,
+     1159, 1055, 1055, 1723, 1055, 1161, 1723, 1161, 1164, 1723,
+     1164, 1167, 1723, 1167, 1168, 1168, 1168, 1172, 1172, 1172,
+     1176, 1723, 1176,   49,   49,   49, 1723,   49,   49, 1200,
 
-     1261, 1264, 1728, 1264, 1265, 1265, 1265, 1270, 1270, 1270,
-     1269, 1269, 1269, 1271, 1728, 1271, 1272, 1728, 1272, 1275,
-     1728, 1275, 1278, 1728, 1278, 1279, 1279, 1279, 1284, 1284,
-     1284, 1283, 1283, 1283, 1285, 1728, 1285, 1166, 1728, 1166,
-     1168, 1728, 1728, 1168, 1169, 1169, 1728, 1169, 1171, 1171,
-     1728, 1728, 1171, 1172, 1172, 1728, 1172, 1173, 1173, 1175,
-     1175, 1728, 1728, 1175, 1292, 1292, 1292, 1296, 1296, 1296,
-     1181, 1181, 1728, 1181,   53,   53,   53, 1728,   53,   53,
-     1112, 1112, 1112, 1324, 1324, 1324, 1327, 1327, 1327, 1330,
-     1330, 1330, 1333, 1333, 1333, 1336, 1336, 1336, 1341, 1341,
+     1200, 1200, 1008, 1008, 1008, 1020, 1020, 1020, 1035, 1035,
+     1035, 1051, 1051, 1051, 1217, 1217, 1217, 1223, 1223, 1223,
+     1221, 1221, 1221, 1228, 1228, 1228, 1227, 1227, 1227, 1229,
+     1723, 1229, 1232, 1723, 1232, 1233, 1233, 1233, 1238, 1238,
+     1238, 1237, 1237, 1237, 1239, 1723, 1239, 1242, 1723, 1242,
+     1245, 1723, 1245, 1246, 1246, 1246, 1251, 1251, 1251, 1250,
+     1250, 1250, 1252, 1723, 1252, 1253, 1723, 1253, 1256, 1723,
+     1256, 1259, 1723, 1259, 1260, 1260, 1260, 1265, 1265, 1265,
+     1264, 1264, 1264, 1266, 1723, 1266, 1267, 1723, 1267, 1270,
+     1723, 1270, 1273, 1723, 1273, 1274, 1274, 1274, 1279, 1279,
 
-     1341, 1340, 1340, 1340, 1343, 1728, 1343, 1344, 1344, 1344,
-     1230, 1230, 1728, 1728, 1230, 1348, 1348, 1348, 1349, 1349,
-     1349, 1234, 1234, 1728, 1234, 1236, 1236, 1728, 1728, 1236,
-     1237, 1237, 1728, 1237, 1238, 1238, 1240, 1240, 1728, 1728,
-     1240, 1355, 1355, 1355, 1356, 1356, 1356, 1244, 1244, 1728,
-     1244, 1246, 1728, 1728, 1246, 1247, 1247, 1728, 1247, 1249,
-     1249, 1728, 1728, 1249, 1250, 1250, 1728, 1250, 1251, 1251,
-     1253, 1253, 1728, 1728, 1253, 1363, 1363, 1363, 1364, 1364,
-     1364, 1257, 1257, 1728, 1257, 1258, 1728, 1258, 1260, 1728,
-     1728, 1260, 1261, 1261, 1728, 1261, 1263, 1263, 1728, 1728,
+     1279, 1278, 1278, 1278, 1280, 1723, 1280, 1161, 1723, 1161,
+     1163, 1723, 1723, 1163, 1164, 1164, 1723, 1164, 1166, 1166,
+     1723, 1723, 1166, 1167, 1167, 1723, 1167, 1168, 1168, 1170,
+     1170, 1723, 1723, 1170, 1287, 1287, 1287, 1291, 1291, 1291,
+     1176, 1176, 1723, 1176,   49,   49,   49, 1723,   49,   49,
+     1107, 1107, 1107, 1319, 1319, 1319, 1322, 1322, 1322, 1325,
+     1325, 1325, 1328, 1328, 1328, 1331, 1331, 1331, 1336, 1336,
+     1336, 1335, 1335, 1335, 1338, 1723, 1338, 1339, 1339, 1339,
+     1225, 1225, 1723, 1723, 1225, 1343, 1343, 1343, 1344, 1344,
+     1344, 1229, 1229, 1723, 1229, 1231, 1231, 1723, 1723, 1231,
 
-     1263, 1264, 1264, 1728, 1264, 1265, 1265, 1267, 1267, 1728,
-     1728, 1267, 1371, 1371, 1371, 1372, 1372, 1372, 1271, 1271,
-     1728, 1271, 1272, 1728, 1272, 1274, 1728, 1728, 1274, 1275,
-     1275, 1728, 1275, 1277, 1277, 1728, 1728, 1277, 1278, 1278,
-     1728, 1278, 1279, 1279, 1281, 1281, 1728, 1728, 1281, 1379,
-     1379, 1379, 1380, 1380, 1380, 1285, 1285, 1728, 1285, 1381,
-     1728, 1381, 1384, 1728, 1384, 1387, 1728, 1387, 1388, 1388,
-     1388, 1393, 1728, 1393, 1392, 1392, 1392, 1394, 1728, 1394,
-       53,   53,   53, 1728,   53,   53, 1415, 1728, 1415, 1414,
-     1414, 1414, 1416, 1728, 1416, 1232, 1232, 1232, 1417, 1728,
+     1232, 1232, 1723, 1232, 1233, 1233, 1235, 1235, 1723, 1723,
+     1235, 1350, 1350, 1350, 1351, 1351, 1351, 1239, 1239, 1723,
+     1239, 1241, 1723, 1723, 1241, 1242, 1242, 1723, 1242, 1244,
+     1244, 1723, 1723, 1244, 1245, 1245, 1723, 1245, 1246, 1246,
+     1248, 1248, 1723, 1723, 1248, 1358, 1358, 1358, 1359, 1359,
+     1359, 1252, 1252, 1723, 1252, 1253, 1723, 1253, 1255, 1723,
+     1723, 1255, 1256, 1256, 1723, 1256, 1258, 1258, 1723, 1723,
+     1258, 1259, 1259, 1723, 1259, 1260, 1260, 1262, 1262, 1723,
+     1723, 1262, 1366, 1366, 1366, 1367, 1367, 1367, 1266, 1266,
+     1723, 1266, 1267, 1723, 1267, 1269, 1723, 1723, 1269, 1270,
 
-     1417, 1242, 1242, 1242, 1418, 1728, 1418, 1255, 1255, 1255,
-     1419, 1728, 1419, 1269, 1269, 1269, 1420, 1728, 1420, 1283,
-     1283, 1283, 1338, 1338, 1728, 1728, 1338, 1424, 1424, 1424,
-     1425, 1425, 1425,  370,  370,  370, 1343, 1343, 1728, 1343,
-     1426, 1426, 1426, 1429, 1728, 1429, 1430, 1430, 1430, 1431,
-     1431, 1431, 1434, 1728, 1434, 1437, 1728, 1437, 1438, 1438,
-     1438, 1439, 1439, 1439, 1440, 1728, 1440, 1443, 1728, 1443,
-     1446, 1728, 1446, 1447, 1447, 1447, 1448, 1448, 1448, 1449,
-     1728, 1449, 1452, 1728, 1452, 1455, 1728, 1455, 1456, 1456,
-     1456, 1457, 1457, 1457, 1458, 1728, 1458, 1461, 1728, 1461,
+     1270, 1723, 1270, 1272, 1272, 1723, 1723, 1272, 1273, 1273,
+     1723, 1273, 1274, 1274, 1276, 1276, 1723, 1723, 1276, 1374,
+     1374, 1374, 1375, 1375, 1375, 1280, 1280, 1723, 1280, 1376,
+     1723, 1376, 1379, 1723, 1379, 1382, 1723, 1382, 1383, 1383,
+     1383, 1388, 1723, 1388, 1387, 1387, 1387, 1389, 1723, 1389,
+       49,   49,   49, 1723,   49,   49, 1410, 1723, 1410, 1409,
+     1409, 1409, 1411, 1723, 1411, 1227, 1227, 1227, 1412, 1723,
+     1412, 1237, 1237, 1237, 1413, 1723, 1413, 1250, 1250, 1250,
+     1414, 1723, 1414, 1264, 1264, 1264, 1415, 1723, 1415, 1278,
+     1278, 1278, 1333, 1333, 1723, 1723, 1333, 1419, 1419, 1419,
 
-     1464, 1728, 1464, 1465, 1465, 1465, 1466, 1466, 1466, 1381,
-     1728, 1381, 1383, 1728, 1728, 1383, 1384, 1384, 1728, 1384,
-     1386, 1386, 1728, 1728, 1386, 1387, 1387, 1728, 1387, 1388,
-     1388, 1390, 1390, 1728, 1728, 1390, 1473, 1473, 1473, 1474,
-     1728, 1474, 1394, 1394, 1728, 1394,   53,   53,   53, 1728,
-       53,   53, 1492, 1492, 1492, 1340, 1340, 1340, 1494, 1728,
-     1494, 1495, 1728, 1495, 1496, 1728, 1496, 1497, 1728, 1497,
-     1498, 1728, 1498, 1499, 1728, 1499, 1502, 1728, 1502, 1503,
-     1503, 1503, 1504, 1504, 1504, 1505, 1728, 1505, 1428, 1428,
-     1728, 1728, 1428, 1429, 1429, 1728, 1429, 1430, 1430, 1508,
+     1420, 1420, 1420,  365,  365,  365, 1338, 1338, 1723, 1338,
+     1421, 1421, 1421, 1424, 1723, 1424, 1425, 1425, 1425, 1426,
+     1426, 1426, 1429, 1723, 1429, 1432, 1723, 1432, 1433, 1433,
+     1433, 1434, 1434, 1434, 1435, 1723, 1435, 1438, 1723, 1438,
+     1441, 1723, 1441, 1442, 1442, 1442, 1443, 1443, 1443, 1444,
+     1723, 1444, 1447, 1723, 1447, 1450, 1723, 1450, 1451, 1451,
+     1451, 1452, 1452, 1452, 1453, 1723, 1453, 1456, 1723, 1456,
+     1459, 1723, 1459, 1460, 1460, 1460, 1461, 1461, 1461, 1376,
+     1723, 1376, 1378, 1723, 1723, 1378, 1379, 1379, 1723, 1379,
+     1381, 1381, 1723, 1723, 1381, 1382, 1382, 1723, 1382, 1383,
 
-     1728, 1508, 1433, 1728, 1728, 1433, 1434, 1434, 1728, 1434,
-     1436, 1436, 1728, 1728, 1436, 1437, 1437, 1728, 1437, 1438,
-     1438, 1512, 1728, 1512, 1440, 1728, 1440, 1442, 1728, 1728,
-     1442, 1443, 1443, 1728, 1443, 1445, 1445, 1728, 1728, 1445,
-     1446, 1446, 1728, 1446, 1447, 1447, 1516, 1728, 1516, 1449,
-     1728, 1449, 1451, 1728, 1728, 1451, 1452, 1452, 1728, 1452,
-     1454, 1454, 1728, 1728, 1454, 1455, 1455, 1728, 1455, 1456,
-     1456, 1520, 1728, 1520, 1458, 1728, 1458, 1460, 1728, 1728,
-     1460, 1461, 1461, 1728, 1461, 1463, 1463, 1728, 1728, 1463,
-     1464, 1464, 1728, 1464, 1465, 1465, 1524, 1728, 1524, 1525,
+     1383, 1385, 1385, 1723, 1723, 1385, 1468, 1468, 1468, 1469,
+     1723, 1469, 1389, 1389, 1723, 1389,   49,   49,   49, 1723,
+       49,   49, 1487, 1487, 1487, 1335, 1335, 1335, 1489, 1723,
+     1489, 1490, 1723, 1490, 1491, 1723, 1491, 1492, 1723, 1492,
+     1493, 1723, 1493, 1494, 1723, 1494, 1497, 1723, 1497, 1498,
+     1498, 1498, 1499, 1499, 1499, 1500, 1723, 1500, 1423, 1423,
+     1723, 1723, 1423, 1424, 1424, 1723, 1424, 1425, 1425, 1503,
+     1723, 1503, 1428, 1723, 1723, 1428, 1429, 1429, 1723, 1429,
+     1431, 1431, 1723, 1723, 1431, 1432, 1432, 1723, 1432, 1433,
+     1433, 1507, 1723, 1507, 1435, 1723, 1435, 1437, 1723, 1723,
 
-     1728, 1525, 1528, 1728, 1528, 1531, 1728, 1531, 1532, 1532,
-     1532, 1533, 1728, 1533,   53,   53,   53, 1728,   53,   53,
-     1550, 1728, 1550, 1426, 1728, 1426, 1431, 1728, 1431, 1439,
-     1728, 1439, 1448, 1728, 1448, 1457, 1728, 1457, 1466, 1728,
-     1466, 1501, 1501, 1728, 1728, 1501, 1502, 1502, 1728, 1502,
-     1503, 1503, 1493, 1728, 1493, 1555, 1728, 1555, 1556, 1728,
-     1556, 1559, 1728, 1559, 1560, 1728, 1560, 1563, 1728, 1563,
-     1564, 1728, 1564, 1567, 1728, 1567, 1568, 1728, 1568, 1571,
-     1728, 1571, 1527, 1728, 1728, 1527, 1530, 1530, 1728, 1728,
-     1530, 1575, 1728, 1575, 1504, 1728, 1504, 1591, 1728, 1591,
+     1437, 1438, 1438, 1723, 1438, 1440, 1440, 1723, 1723, 1440,
+     1441, 1441, 1723, 1441, 1442, 1442, 1511, 1723, 1511, 1444,
+     1723, 1444, 1446, 1723, 1723, 1446, 1447, 1447, 1723, 1447,
+     1449, 1449, 1723, 1723, 1449, 1450, 1450, 1723, 1450, 1451,
+     1451, 1515, 1723, 1515, 1453, 1723, 1453, 1455, 1723, 1723,
+     1455, 1456, 1456, 1723, 1456, 1458, 1458, 1723, 1723, 1458,
+     1459, 1459, 1723, 1459, 1460, 1460, 1519, 1723, 1519, 1520,
+     1723, 1520, 1523, 1723, 1523, 1526, 1723, 1526, 1527, 1527,
+     1527, 1528, 1723, 1528,   49,   49,   49, 1723,   49,   49,
+     1545, 1723, 1545, 1421, 1723, 1421, 1426, 1723, 1426, 1434,
 
-     1554, 1728, 1728, 1554, 1558, 1728, 1728, 1558, 1562, 1728,
-     1728, 1562, 1566, 1728, 1728, 1566, 1570, 1728, 1728, 1570,
-     1597, 1728, 1597, 1600, 1728, 1600, 1590, 1728, 1728, 1590,
-     1614, 1728, 1614, 1615, 1728, 1615, 1616, 1728, 1616, 1617,
-     1728, 1617, 1618, 1728, 1618, 1599, 1728, 1728, 1599, 1631,
-     1728, 1631, 1632, 1728, 1632,    3, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
+     1723, 1434, 1443, 1723, 1443, 1452, 1723, 1452, 1461, 1723,
+     1461, 1496, 1496, 1723, 1723, 1496, 1497, 1497, 1723, 1497,
+     1498, 1498, 1488, 1723, 1488, 1550, 1723, 1550, 1551, 1723,
+     1551, 1554, 1723, 1554, 1555, 1723, 1555, 1558, 1723, 1558,
+     1559, 1723, 1559, 1562, 1723, 1562, 1563, 1723, 1563, 1566,
+     1723, 1566, 1522, 1723, 1723, 1522, 1525, 1525, 1723, 1723,
+     1525, 1570, 1723, 1570, 1499, 1723, 1499, 1586, 1723, 1586,
+     1549, 1723, 1723, 1549, 1553, 1723, 1723, 1553, 1557, 1723,
+     1723, 1557, 1561, 1723, 1723, 1561, 1565, 1723, 1723, 1565,
+     1592, 1723, 1592, 1595, 1723, 1595, 1585, 1723, 1723, 1585,
 
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728
+     1609, 1723, 1609, 1610, 1723, 1610, 1611, 1723, 1611, 1612,
+     1723, 1612, 1613, 1723, 1613, 1594, 1723, 1723, 1594, 1626,
+     1723, 1626, 1627, 1723, 1627,    3, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723
     } ;
 
-static yyconst flex_int16_t yy_chk[7910] =
+static const flex_int16_t yy_chk[7679] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    4,   15,  106,    4,    7,    4,    4,
-        7,  106,    7,    7,    9,   17,   17,    9,  138,    9,
-        9,    4,   19,   19,   24,    7,   27,   27,  138,    4,
-       15,   10,    9,    7,   10,  102,   10,   10,   24,   28,
-        9,   34,   26, 1278,   28,   24,   26,  586,   94,   10,
+        1,    1,   11,   11,   11,   11,   11,   11,   11,   11,
+       11,   11,   14,   14,  674,   11,   11,   11,  674,   11,
+       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
+       11,   11,   11,   11,   11,   11,   11,   11,   11,   11,
+       11,   11,   11,   11,   12,   16,   16,   20,   23,   20,
 
-       34,   94,   26,  586,   95,   26,   95,   10,   14,   14,
-       14,   14,   14,   14,   14,   14,   14,   14,  102,   98,
-     1279,   14,   14,   14,   98,   83,   14,   14,   14,   14,
-       14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
-       14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
-       14,   16,   83,   25,   16,  671,   16,   16,   83,  129,
-       29,  671,  107,   25,   29,  252,   25,  107,   22,   16,
-       25,   22,  129,   22,   22,  103,   29,   16,   20,   20,
-       20,   20,   20,   20,   20,   20,   22,  134,   23,  252,
-       23,   23,   20,  673,   22,   23,  673,  251,   35,  251,
+       20,   31,   23,  408,   20,   24,   24,   25,   23,   20,
+       31,   23,   25,   20,   21,   20,   90,  408,   90,   12,
+       17,   17,   17,   17,   17,   17,   17,   17,   21,   22,
+       89, 1270,   26,   89,   17,   21,   26,   34,  101,   22,
+       97,   34,   22,   27,  101,   27,   22,   93,   26,   34,
+       27,   27,   93,   27,   34, 1273,   34,   27,  129,   17,
+       18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
+       29,   29,   97,   18, 1274,   36,  129,   36,   18,   18,
+       18,   18,   18,   18,   28,   29, 1278,   28,   28,   29,
+       28,   36,   28,   29,   28,   29,   28,   30,   36,   28,
 
-       23,   30,  103,   30,   23,  134,   23,  103,   30,   30,
-       35,   30,   35, 1283,   35,   30, 1284,   35,   20,   21,
-       21,   21,   21,   21,   21,   21,   21,   21,   21,   32,
-       32,  110,   21,  675,  110, 1285,  110,  136,   21,   21,
-       21,   21,   21,   21,   31,   32,  136,   31,   31,   32,
-       31,  675,   31,   32,   31,   32,   31,   33,   36,   31,
-      155,   33,   32,   36,   36,   37,   36,   36,  710,   37,
-       33,   33,  163,   38,   33,  222,   33,   37,   39,   38,
-       39,   38,   37,   38,   37,   41,  155,   38,  222,   38,
-       38,  267,  267,   41,   39,  437,  437,   41,  163,   41,
+       33,   30,   29,   32,  150,   33,   33,  102,   33,   33,
+       30,   30,  102,   38,   30,   32,   30,   32,   35,   32,
+       98,   38,   32,  133,   35,   38,   35,   38,   35,  150,
+      124,  217,   35,  133,   35,   35,   44,   44,   44,   44,
+       44,   44,   44,  124,  217,  105,   98,   44,  105,  247,
+      105,   98,   44,   44,   44,   44,   44,   44,   45,   45,
+       45,   45,   45,   45,   45,  158,  246,  581,  246,   45,
+      262,  262,  247,  581,   45,   45,   45,   45,   45,   45,
+       46,   46,   46,   46,   46,   46,   46,   46,  668,  334,
+      158,  668,   46,   78,  334,  269,  346,   46,   46,   46,
 
-       44,   39,  397,   44,  710,   44,   44,   62,   62,   62,
-       62,   62,   62,   62,  274,  339,   63,  351,   44,   63,
-      339,   63,   63,  397,  410, 1292,   44,   48,   48,   48,
-       48,   48,   48,   48,   63,  619,  619,  410,   48,  397,
-      274,  680,   63,  351,   48,   48,   48,   48,   48,   48,
-       49,   49,   49,   49,   49,   49,   49,  376,  439,  680,
-      446,   49,  284,  284,  284,  284, 1296,   49,   49,   49,
-       49,   49,   49,   50,   50,   50,   50,   50,   50,   50,
-       50,  466,  284,  376,  439,   50,  446,  452,  460,  466,
-     1321,   50,   50,   50,   50,   50,   50,   52,   52,   52,
+       46,   46,   46,   48,   48,   48,   48,   48,   48,   48,
+       48,   50,   50,   50,   50,   50,   50,   50,  371,   78,
+      269,  346,   50,  432,  432,   78, 1279,   50,   50,   50,
+       50,   50,   50,   52,   52,   52,   52,   52,   52,   52,
+      614,  614,  667,  371,   52,  665,  665,  667,  434,   52,
+       52,   52,   52,   52,   52,   58,   58,   58,   58,   58,
+       58,   58,  131,  261,  261,  261,  261,  261,  261,  261,
+      350,  131,  148,  434,  148,  148,  148,  148,  148,  148,
+      148,  441,  447, 1280,  350,  148,  279,  279,  279,  279,
+      148,  148,  148,  148,  148,  148,  149,  149,  149,  149,
 
-       52,   52,   52,   52,   52,   54,   54,   54,   54,   54,
-       54,   54,  486,  452,  460,  355,   54, 1324,  413,  670,
-      670,  486,   54,   54,   54,   54,   54,   54,   56,  355,
-      672,   56,  413,   56,   56,  672, 1327,  371,  372,   56,
-       56,   56,   56,   56,   56,   56,   56,  523,  563,  679,
-       56,  371,  372,  679,   56,  355,   56,   56,   56,   56,
-       56,   56,  153,  488,  153,  153,  153,  153,  153,  153,
-      153,  547,  488,  523,  563,  153,  627,  371,  372,  547,
-      686,  153,  153,  153,  153,  153,  153,  154,  154,  154,
-      154,  154,  154,  154,  154,  557,  662,  686, 1330,  154,
+      149,  149,  149,  149,  461,  279,  441,  447,  149,  350,
+      149, 1287,  461,  149,  149,  149,  149,  149,  149,  272,
+      272,  272,  272,  272,  272,  272,  356,  356,  356,  356,
+      356,  356,  356,  366,  681,  149,  151,  151,  151,  151,
+      151,  151,  151,  151,  455,  518,  666,  366,  151,  558,
+      622,  681,  666,  151,  151,  151,  151,  151,  151,  152,
+      152,  152,  152,  152,  152,  152,  152,  152, 1291,  455,
+      518,  152,  366,  625,  558,  622,  152,  152,  152,  152,
+      152,  152,  153,  153,  153,  153,  153,  153,  153,  153,
+      155,  155,  155,  155,  155,  155,  155,  155,  625,  686,
 
-      630,  154,  627,  557,  662,  154,  154,  154,  154,  154,
-      154,  266,  266,  266,  266,  266,  266,  266,  277,  277,
-      277,  277,  277,  277,  277,  455,  630,  154,  156,  156,
-      156,  156,  156,  156,  156,  156,  587,  636, 1333,  455,
-      156,  566,  566,  566,  566,  587,  156,  156,  156,  156,
-      156,  156,  157,  157,  157,  157,  157,  157,  157,  157,
-      157,  684, 1336,  636,  157,  455,  643,  655,  684, 1340,
-      157,  157,  157,  157,  157,  157,  158,  158,  158,  158,
-      158,  158,  158,  158,  160,  160,  160,  160,  160,  160,
-      160,  160,  643,  655,  678,  160,  678,  682, 1341,  682,
+      686,  155,  561,  561,  561,  561,  155,  155,  155,  155,
+      155,  155,  157,  157,  157,  157,  157,  157,  157,  157,
+      157,  367,  631, 1316,  157,  392,  157,  759,  304,  157,
+      157,  157,  157,  157,  157,  367,  304,  360,  360,  360,
+      360,  360,  360,  360,  759,  392,  405,  631,  304,  670,
+     1319,  157,  255,  255,  255,  255,  255,  255,  255,  405,
+      367,  392,  638,  255,  304,  675, 1322,  670,  255,  255,
+      255,  255,  255,  255,  257,  257,  257,  257,  257,  257,
+      257,  542,  673,  675,  673,  257, 1325,  638,  650,  542,
+      257,  257,  257,  257,  257,  257,  258,  258,  258,  258,
 
-     1342,  160,  160,  160,  160,  160,  160,  162,  162,  162,
-      162,  162,  162,  162,  162,  162,  687,  691,  691,  162,
-     1343,  162, 1344,  309,  687,  162,  162,  162,  162,  162,
-      162,  309,  361,  361,  361,  361,  361,  361,  361,  701,
-      701,  456, 1348,  527,  309,  764,  676,  162,  260,  260,
-      260,  260,  260,  260,  260,  456,  676,  527,  708,  260,
-      309, 1349,  766,  764,  689,  260,  260,  260,  260,  260,
-      260,  262,  262,  262,  262,  262,  262,  262,  588,  689,
-      766,  456,  262,  527,  708,  749,  761,  588,  262,  262,
-      262,  262,  262,  262,  263,  263,  263,  263,  263,  263,
+      258,  258,  258,  258,  260,  260,  260,  260,  260,  260,
+      260,  552,  677,  650,  677,  260,  696,  696, 1328,  552,
+      260,  260,  260,  260,  260,  260,  263,  263,  263,  263,
+      263,  263,  263,  263,  657,  705, 1331, 1335,  263, 1336,
+     1337,  703,  657,  263,  263,  263,  263,  263,  263,  265,
+      265,  265,  265,  265,  265,  265,  265,  268,  268,  268,
+      268,  268,  268,  268,  268,  268,  703, 1338, 1339,  268,
+      705,  268,  761,  450,  268,  268,  268,  268,  268,  268,
+      431,  431,  431,  431,  431,  431,  431,  450,  679,  761,
+     1343, 1344,  676,  451,  522,  679,  268,  273,  273,  273,
 
-      263,  263,  265,  265,  265,  265,  265,  265,  265,  674,
-      805,  749,  761,  265, 1355, 1356, 1363,  772,  674,  265,
-      265,  265,  265,  265,  265,  268,  268,  268,  268,  268,
-      268,  268,  268,  731,  742,  772,  805,  268, 1364, 1371,
-      772,  731,  742,  268,  268,  268,  268,  268,  268,  270,
-      270,  270,  270,  270,  270,  270,  270,  273,  273,  273,
-      273,  273,  273,  273,  273,  273,  859, 1372, 1379,  273,
-     1380,  273, 1384, 1387,  859,  273,  273,  273,  273,  273,
-      273,  365,  365,  365,  365,  365,  365,  365,  436,  436,
-      436,  436,  436,  436,  436,  554,  683,  273,  278,  278,
+      273,  273,  273,  273,  273,  273,  676,  451,  522,  273,
+     1350,  771,  450,  680,  273,  273,  273,  273,  273,  273,
+      274,  274,  274,  274,  274,  274,  274,  680,  771,  771,
+      744,  274,  451,  522,  481,  671,  274,  274,  274,  274,
+      274,  274,  339,  481,  339,  671,  339,  339,  459,  459,
+      459,  459,  459,  459,  459,  744,  339,  549,  339,  339,
+      550,  339,  344,  483,  344,  344,  344,  344,  344,  344,
+      344,  549,  483, 1351,  550,  344,  756, 1358,  782, 1359,
+      344,  344,  344,  344,  344,  344,  345,  345,  345,  345,
+      345,  345,  345,  345,  682,  782,  549, 1366,  345,  550,
 
-      278,  278,  278,  278,  278,  278,  278,  683, 1388,  554,
-      278, 1392,  765,  779, 1394,  681,  278,  278,  278,  278,
-      278,  278,  279,  279,  279,  279,  279,  279,  279,  681,
-      765,  779,  685,  279,  555,  554,  779,  765, 1413,  279,
-      279,  279,  279,  279,  279,  344,  685,  344,  555,  344,
-      344,  464,  464,  464,  464,  464,  464,  464,  773,  344,
-      690,  344,  344,  558,  344,  349,  559,  349,  349,  349,
-      349,  349,  349,  349,  555,  690,  773,  558,  349,  773,
-      559,  776, 1414,  787,  349,  349,  349,  349,  349,  349,
-      350,  350,  350,  350,  350,  350,  350,  350, 1424,  776,
+      345,  756,  682,  345,  345,  345,  345,  345,  345,  463,
+      463,  463,  463,  463,  463,  463,  535,  535,  535,  535,
+      535,  535,  535,  553,  678,  345,  347,  347,  347,  347,
+      347,  347,  347,  347,  800,  678, 1367,  553,  347, 1374,
+      783,  768,  554,  347,  347,  347,  347,  347,  347,  351,
+      351,  351,  351,  351,  351,  351,  554,  783,  768,  800,
+      351,  768,  553,  760,  684,  351,  351,  351,  351,  351,
+      351,  352,  352,  352,  352,  352,  352,  352,  352,  684,
+      760,  554, 1375,  352,  803,  806,  812,  760,  352,  352,
+      352,  352,  352,  352,  353,  353,  353,  353,  353,  353,
 
-      776,  787,  350,  558,  350, 1425,  559, 1429,  350,  350,
-      350,  350,  350,  350,  468,  468,  468,  468,  468,  468,
-      468,  540,  540,  540,  540,  540,  540,  540,  638,  688,
-      350,  352,  352,  352,  352,  352,  352,  352,  352,  688,
-     1430, 1434,  638,  352, 1437,  783,  774,  788,  639,  352,
-      352,  352,  352,  352,  352,  356,  356,  356,  356,  356,
-      356,  356,  639,  783,  774,  788,  356,  774,  638,  784,
-      783,  790,  356,  356,  356,  356,  356,  356,  357,  357,
-      357,  357,  357,  357,  357,  357, 1438,  784,  639,  790,
-      357,  808,  784,  811,  817, 1443,  357,  357,  357,  357,
+      353,  353,  355,  355,  355,  355,  355,  355,  355,  803,
+      806,  812,  819,  355, 1379, 1382,  767,  685,  355,  355,
+      355,  355,  355,  355,  359,  359,  359,  359,  359,  359,
+      359,  359,  685,  767, 1383,  359, 1387,  819,  767,  769,
+      359,  359,  359,  359,  359,  359,  361,  361,  361,  361,
+      361,  361,  361,  361,  361, 1389,  769, 1408,  361,  769,
+      774,  784,  779,  361,  361,  361,  361,  361,  361,  362,
+      362,  362,  362,  362,  362,  362,  362,  774,  784,  779,
+      362,  784,  774,  778,  779,  362,  362,  362,  362,  362,
+      362,  368,  368,  368,  368,  368,  368,  368,  368,  368,
 
-      357,  357,  358,  358,  358,  358,  358,  358,  358,  358,
-      360,  360,  360,  360,  360,  360,  360,  808,  917,  811,
-      817,  360, 1446,  791,  789,  795,  917,  360,  360,  360,
-      360,  360,  360,  364,  364,  364,  364,  364,  364,  364,
-      364,  791,  789,  795,  364,  789,  824,  797,  797, 1447,
-      364,  364,  364,  364,  364,  364,  366,  366,  366,  366,
-      366,  366,  366,  366,  366,  797,  836,  839,  366,  851,
-      866,  867,  824, 1452,  366,  366,  366,  366,  366,  366,
-      367,  367,  367,  367,  367,  367,  367,  367,  866,  867,
-      892,  367,  836,  839,  867,  851,  868,  367,  367,  367,
+      778, 1409,  831,  368, 1419, 1420,  785,  778,  368,  368,
+      368,  368,  368,  368,  370,  370,  370,  370,  370,  370,
+      370,  370,  370,  785, 1424, 1425,  370,  831,  370,  582,
+      687,  370,  370,  370,  370,  370,  370,  485,  582,  485,
+      583,  633,  485,  485,  687,  634,  485,  485,  669,  583,
+      683,  485,  695,  370,  391,  633, 1429,  669,  391,  634,
+      683,  391,  695,  641,  391,  642,  391,  391,  391,  391,
+      425,  425,  425,  425,  425,  425,  425,  641, 1432,  642,
+      633,  425,  834,  786,  634,  688,  425,  425,  425,  425,
+      425,  425,  427,  427,  427,  427,  427,  427,  427,  688,
 
-      367,  367,  367,  373,  373,  373,  373,  373,  373,  373,
-      373,  373, 1455, 1456,  868,  373,  892, 1461,  879,  868,
-      869,  373,  373,  373,  373,  373,  373,  375,  375,  375,
-      375,  375,  375,  375,  375,  375,  879,  879,  869,  375,
-      692,  375, 1464,  869,  693,  375,  375,  375,  375,  375,
-      375,  490,  646,  490,  692,  696,  490,  490,  693,  647,
-      490,  490,  699,  928,  700,  490,  646,  375,  396,  696,
-     1465,  928,  396,  647,  700,  396,  699,  650,  396,  651,
-      396,  396,  396,  396,  430,  430,  430,  430,  430,  430,
-      430,  650,  646,  651, 1473,  430,  780,  871,  873,  647,
+      786, 1433,  641,  427,  642,  846,  887,  834,  427,  427,
+      427,  427,  427,  427,  428,  428,  428,  428,  428,  428,
+      428,  428,  430,  430,  430,  430,  430,  430,  430,  726,
+      846,  887,  943,  430,  955, 1438,  790,  726,  430,  430,
+      430,  430,  430,  430,  433,  433,  433,  433,  433,  433,
+      433,  433,  737,  790, 1441, 1442,  433,  943,  433,  955,
+      737,  433,  433,  433,  433,  433,  433,  540,  540,  540,
+      540,  540,  540,  540,  544,  544,  544,  544,  544,  544,
+      544,  762,  645,  433,  435,  435,  435,  435,  435,  435,
+      435,  988, 1447,  991,  994,  435,  645,  861,  762,  691,
 
-     1502,  430,  430,  430,  430,  430,  430,  432,  432,  432,
-      432,  432,  432,  432,  780,  871,  873,  650,  432,  651,
-      871,  873,  948,  780,  432,  432,  432,  432,  432,  432,
-      433,  433,  433,  433,  433,  433,  433,  433,  435,  435,
-      435,  435,  435,  435,  435, 1503, 1528, 1531,  948,  435,
-     1555,  781,  880,  874,  888,  435,  435,  435,  435,  435,
-      435,  438,  438,  438,  438,  438,  438,  438,  438,  781,
-      880,  874,  888,  438, 1559,  438,  874,  880,  781,  438,
-      438,  438,  438,  438,  438,  545,  545,  545,  545,  545,
-      545,  545,  549,  549,  549,  549,  549,  549,  549,  767,
+      435,  435,  435,  435,  435,  435,  436,  436,  436,  436,
+      436,  436,  436,  691,  861,  762,  988,  436,  991,  994,
+     1450,  645,  436,  436,  436,  436,  436,  436,  437,  437,
+      437,  437,  437,  437,  437,  437,  440,  440,  440,  440,
+      440,  440,  440,  440,  440,  694,  646, 1451,  440, 1456,
+      440, 1459, 1460,  440,  440,  440,  440,  440,  440,  694,
+      646,  653,  653,  653,  653,  653,  653,  653,  655,  655,
+      655,  655,  655,  655,  655,  440,  446,  446,  446,  446,
+      446,  446,  446,  446,  446,  646, 1468, 1497,  446, 1498,
+      446, 1523, 1526,  446,  446,  446,  446,  446,  446,  659,
 
-      752,  438,  440,  440,  440,  440,  440,  440,  440,  960,
-      940,  993,  996,  440,  752,  883, 1563,  767,  940,  440,
-      440,  440,  440,  440,  440,  441,  441,  441,  441,  441,
-      441,  441, 1567,  883,  767,  960,  441,  993,  996,  999,
-      752,  883,  441,  441,  441,  441,  441,  441,  442,  442,
-      442,  442,  442,  442,  442,  442,  445,  445,  445,  445,
-      445,  445,  445,  445,  445,  999, 1571, 1591,  445, 1002,
-      445, 1600, 1275, 1271,  445,  445,  445,  445,  445,  445,
-      658,  658,  658,  658,  658,  658,  658,  660,  660,  660,
-      660,  660,  660,  660,  973, 1002,  445,  451,  451,  451,
+      659,  659,  659,  659,  659,  659,  719,  719,  719,  719,
+      719,  719,  719,  747,  763,  446,  452,  452,  452,  452,
+      452,  452,  452,  452,  452,  997, 1550,  747,  452, 1554,
+     1003,  763,  862,  452,  452,  452,  452,  452,  452,  454,
+      454,  454,  454,  454,  454,  454,  454,  454,  763,  862,
+      997,  454,  747,  454,  862, 1003,  454,  454,  454,  454,
+      454,  454,  724,  724,  724,  724,  724,  724,  724,  728,
+      728,  728,  728,  728,  728,  728,  748,  764,  454,  464,
+      464,  464,  464,  464,  464,  464,  464,  464, 1558, 1010,
+      748,  464, 1562,  883,  764,  751,  464,  464,  464,  464,
 
-      451,  451,  451,  451,  451,  451, 1066, 1270, 1269,  451,
-     1265,  451,  973,  973, 1066,  451,  451,  451,  451,  451,
-      451,  664,  664,  664,  664,  664,  664,  664,  724,  724,
-      724,  724,  724,  724,  724,  753,  768,  451,  457,  457,
-      457,  457,  457,  457,  457,  457,  457, 1264, 1261,  753,
-      457, 1008, 1257, 1015,  768,  886,  457,  457,  457,  457,
-      457,  457,  459,  459,  459,  459,  459,  459,  459,  459,
-      459,  768, 1256,  886,  459,  753,  459, 1008,  886, 1015,
-      459,  459,  459,  459,  459,  459,  729,  729,  729,  729,
-      729,  729,  729,  733,  733,  733,  733,  733,  733,  733,
+      464,  464,  465,  465,  465,  465,  465,  465,  465,  751,
+      883,  764, 1566,  465, 1010,  748,  792,  792,  465,  465,
+      465,  465,  465,  465,  516,  752,  516,  516,  516,  516,
+      516,  516,  516,  792,  751, 1586, 1022,  516, 1595,  752,
+      974,  863,  516,  516,  516,  516,  516,  516,  517,  517,
+      517,  517,  517,  517,  517,  517, 1266,  974,  863,  974,
+      517, 1022,  517,  863,  752,  517,  517,  517,  517,  517,
+      517,  733,  733,  733,  733,  733,  733,  733,  735,  735,
+      735,  735,  735,  735,  735,  766,  772,  517,  519,  519,
+      519,  519,  519,  519,  519,  519,  854, 1265, 1264, 1025,
 
-      756,  769,  459,  469,  469,  469,  469,  469,  469,  469,
-      469,  469, 1255, 1027,  756,  469, 1251,  975, 1250,  769,
-      757,  469,  469,  469,  469,  469,  469,  470,  470,  470,
-      470,  470,  470,  470,  757,  975,  769, 1247,  470, 1027,
-      756,  785,  975,  876,  470,  470,  470,  470,  470,  470,
-      521,  819,  521,  521,  521,  521,  521,  521,  521,  785,
-      757,  876, 1244,  521,  876,  819,  972,  967,  785,  521,
-      521,  521,  521,  521,  521,  522,  522,  522,  522,  522,
-      522,  522,  522, 1243,  972,  967, 1242,  522,  967,  522,
-     1238,  819,  972,  522,  522,  522,  522,  522,  522,  738,
-
-      738,  738,  738,  738,  738,  738,  740,  740,  740,  740,
-      740,  740,  740,  771,  777,  522,  524,  524,  524,  524,
-      524,  524,  524,  524, 1030, 1124, 1237, 1042,  524, 1046,
-     1058,  771,  777, 1124,  524,  524,  524,  524,  524,  524,
-      528,  528,  528,  528,  528,  528,  528,  528,  771, 1135,
-     1030,  777,  528, 1042, 1114, 1046, 1058, 1135,  528,  528,
+      519, 1037,  766,  772,  854,  519,  519,  519,  519,  519,
+      519,  523,  523,  523,  523,  523,  523,  523,  523,  766,
+     1260, 1259,  772,  523, 1025, 1041, 1037, 1053,  523,  523,
+      523,  523,  523,  523,  524,  524,  524,  524,  524,  524,
+      524,  524,  525,  525,  525,  525,  525,  525,  525,  912,
+     1041, 1256, 1053,  525, 1109, 1162, 1174,  912,  525,  525,
+      525,  525,  525,  525,  526,  526,  526,  526,  526,  526,
+      526,  526,  528,  528,  528,  528,  528,  528,  528, 1109,
+     1162, 1174, 1203,  528, 1252, 1251,  864,  866,  528,  528,
       528,  528,  528,  528,  529,  529,  529,  529,  529,  529,
-      529,  529,  530,  530,  530,  530,  530,  530,  530, 1147,
-     1114, 1234, 1233,  530, 1167, 1179, 1208, 1147, 1232,  530,
-      530,  530,  530,  530,  530,  531,  531,  531,  531,  531,
 
-      531,  531,  531,  533,  533,  533,  533,  533,  533,  533,
-     1167, 1179, 1208, 1211,  533, 1228, 1226,  970,  974,  977,
-      533,  533,  533,  533,  533,  533,  534,  534,  534,  534,
-      534,  534,  534,  534,  534,  970,  974,  977,  534, 1211,
-      970,  974,  977,  820,  534,  534,  534,  534,  534,  534,
-      535,  535,  535,  535,  535,  535,  535,  820, 1159, 1225,
-     1214,  535, 1222,  976,  978, 1221, 1159,  535,  535,  535,
-      535,  535,  535,  539,  539,  539,  539,  539,  539,  539,
-      539,  976,  978,  820,  539,  978, 1214,  979,  981,  976,
-      539,  539,  539,  539,  539,  539,  541,  541,  541,  541,
+      529,  529,  529,  864,  866, 1250,  529, 1203,  864,  866,
+      814,  529,  529,  529,  529,  529,  529,  530,  530,  530,
+      530,  530,  530,  530,  814, 1246, 1206, 1245,  530, 1242,
+      868,  869, 1239,  530,  530,  530,  530,  530,  530,  534,
+      534,  534,  534,  534,  534,  534,  534,  868,  869,  814,
+      534, 1206,  868,  869,  871,  534,  534,  534,  534,  534,
+      534,  536,  536,  536,  536,  536,  536,  536,  536,  536,
+     1238,  871, 1209,  536,  871,  874, 1237,  881,  536,  536,
+      536,  536,  536,  536,  537,  537,  537,  537,  537,  537,
+      537,  537,  874,  874,  881,  537, 1233, 1209,  875,  881,
 
-      541,  541,  541,  541,  541,  979,  981,  979,  541, 1218,
-      983,  981,  984, 1215,  541,  541,  541,  541,  541,  541,
-      542,  542,  542,  542,  542,  542,  542,  542,  983, 1212,
-      984,  542, 1209, 1205,  985,  989, 1076,  542,  542,  542,
-      542,  542,  542,  550,  550,  550,  550,  550,  550,  550,
-      550,  550,  985,  989, 1076,  550, 1181, 1079, 1082, 1083,
-     1180,  550,  550,  550,  550,  550,  550,  551,  551,  551,
-      551,  551,  551,  551,  551, 1079, 1082, 1083,  551, 1079,
-     1082, 1084, 1083, 1087,  551,  551,  551,  551,  551,  551,
-      560,  560,  560,  560,  560,  560,  560,  560,  560, 1084,
+      537,  537,  537,  537,  537,  537,  545,  545,  545,  545,
+      545,  545,  545,  545,  545,  875, 1232, 1229,  545, 1212,
+      965,  962,  875,  545,  545,  545,  545,  545,  545,  546,
+      546,  546,  546,  546,  546,  546,  546,  965,  962, 1215,
+      546,  962,  965,  968, 1212,  546,  546,  546,  546,  546,
+      546,  555,  555,  555,  555,  555,  555,  555,  555,  555,
+      968,  968, 1240,  555, 1215, 1228,  970,  969,  555,  555,
+      555,  555,  555,  555,  557,  557,  557,  557,  557,  557,
+      557,  557,  557,  970,  969, 1227,  557, 1240,  557,  969,
+      970,  557,  557,  557,  557,  557,  557,  739,  739,  739,
 
-     1177, 1087,  560, 1217, 1220, 1088, 1087, 1173,  560,  560,
-      560,  560,  560,  560,  562,  562,  562,  562,  562,  562,
-      562,  562,  562, 1088, 1172, 1088,  562, 1169,  562, 1217,
-     1220, 1164,  562,  562,  562,  562,  562,  562,  744,  744,
-      744,  744,  744,  744,  744,  750,  750,  750,  750,  750,
-      750,  750,  872,  778,  562,  613,  613,  613,  613,  613,
-      613,  613, 1245, 1163, 1259, 1273,  613, 1319, 1092, 1160,
-      872,  778,  613,  613,  613,  613,  613,  613,  615,  615,
-      615,  615,  615,  615,  615,  778, 1092,  872, 1245,  615,
-     1259, 1273, 1092, 1319, 1152,  615,  615,  615,  615,  615,
+      739,  739,  739,  739,  745,  745,  745,  745,  745,  745,
+      745,  867,  773,  557,  608,  608,  608,  608,  608,  608,
+      608, 1254, 1223, 1268, 1221,  608, 1314,  972,  867,  773,
+      608,  608,  608,  608,  608,  608,  610,  610,  610,  610,
+      610,  610,  610,  773,  972,  867, 1254,  610, 1268,  972,
+     1377, 1314,  610,  610,  610,  610,  610,  610,  611,  611,
+      611,  611,  611,  611,  611,  611,  613,  613,  613,  613,
+      613,  613,  613,  923, 1427, 1377, 1436,  613, 1445,  878,
+      976,  923,  613,  613,  613,  613,  613,  613,  615,  615,
+      615,  615,  615,  615,  615,  615,  878,  976, 1220, 1427,
 
-      615,  616,  616,  616,  616,  616,  616,  616,  616,  618,
-      618,  618,  618,  618,  618,  618, 1291, 1151, 1148, 1382,
-      618, 1432,  882, 1090, 1291, 1093,  618,  618,  618,  618,
-      618,  618,  620,  620,  620,  620,  620,  620,  620,  620,
-      882, 1090, 1090, 1093,  620, 1382, 1093, 1432, 1441,  882,
-      620,  620,  620,  620,  620,  620,  621,  621,  621,  621,
-      621,  621,  621,  621,  622,  622,  622,  622,  622,  622,
-      622, 1347, 1354, 1140, 1441,  622, 1139, 1136, 1129, 1347,
-     1354,  622,  622,  622,  622,  622,  622,  623,  623,  623,
-      623,  623,  623,  623,  623,  626,  626,  626,  626,  626,
+      615, 1436,  976, 1445,  878,  615,  615,  615,  615,  615,
+      615,  616,  616,  616,  616,  616,  616,  616,  616,  617,
+      617,  617,  617,  617,  617,  617,  935, 1217, 1216, 1213,
+      617, 1210, 1207, 1204,  935,  617,  617,  617,  617,  617,
+      617,  618,  618,  618,  618,  618,  618,  618,  618,  621,
+      621,  621,  621,  621,  621,  621,  621,  621,  765,  775,
+      776,  621,  777,  621,  973,  978,  621,  621,  621,  621,
+      621,  621, 1061, 1200, 1176,  765,  775,  776, 1175,  777,
+     1061,  973,  978,  770,  973,  775,  776,  765,  621,  624,
+      624,  624,  624,  624,  624,  624,  624,  624,  777,  780,
 
-      626,  626,  626,  626,  770,  884,  827,  626,  782,  626,
-      786, 1182, 1186,  626,  626,  626,  626,  626,  626, 1362,
-      827, 1128,  770,  884, 1125, 1120,  782, 1362,  786, 1182,
-     1186,  775,  884,  792,  770,  626,  629,  629,  629,  629,
-      629,  629,  629,  629,  629,  782,  827,  786,  629,  775,
-      629,  792, 1370, 1182,  629,  629,  629,  629,  629,  629,
-     1370,  775, 1119, 1116,  792,  799,  799,  799,  799,  799,
-      799,  799,  793,  828,  831, 1450,  629,  635,  635,  635,
-      635,  635,  635,  635,  635,  635, 1183,  828,  831,  635,
-      793,  635,  832,  842,  843,  635,  635,  635,  635,  635,
+      770,  624,  781,  624,  979, 1119,  624,  624,  624,  624,
+      624,  624,  770, 1119, 1172, 1130,  780, 1454, 1168,  781,
+     1167,  979,  787, 1130, 1164,  780,  815,  788,  624,  630,
+      630,  630,  630,  630,  630,  630,  630,  630,  781,  787,
+      815,  630, 1454,  630,  788, 1142,  630,  630,  630,  630,
+      630,  630,  787, 1142, 1521, 1159,  788,  794,  794,  794,
+      794,  794,  794,  794,  822,  815,  823,  873,  630,  635,
+      635,  635,  635,  635,  635,  635,  635,  635,  822, 1521,
+      823,  635, 1158, 1548,  873, 1155,  635,  635,  635,  635,
+      635,  635,  637,  637,  637,  637,  637,  637,  637,  637,
 
-      635, 1450,  793, 1378, 1183, 1459,  832,  842,  843, 1184,
-     1115, 1378, 1112,  828,  831,  846, 1111,  635,  640,  640,
-      640,  640,  640,  640,  640,  640,  640, 1184, 1183,  846,
-      640, 1459,  832,  842,  843, 1189,  640,  640,  640,  640,
-      640,  640,  642,  642,  642,  642,  642,  642,  642,  642,
-      642, 1184, 1108, 1189,  642,  846,  642, 1105, 1189,  847,
-      642,  642,  642,  642,  642,  642,  840,  840,  840,  840,
-      840,  840,  840,  847,  855,  855,  855,  855,  855,  855,
-      855, 1102,  642,  652,  652,  652,  652,  652,  652,  652,
-      652,  652, 1423, 1098, 1526,  652, 1553, 1557, 1185,  847,
+      637,  873,  826,  822,  637,  823,  637,  827, 1548,  637,
+      637,  637,  637,  637,  637, 1147,  826, 1552, 1146, 1143,
+     1556,  827,  835,  835,  835,  835,  835,  835,  835,  837,
+      980,  637,  647,  647,  647,  647,  647,  647,  647,  647,
+      647,  826, 1552,  837,  647, 1556,  827,  980, 1135,  647,
+      647,  647,  647,  647,  647,  649,  649,  649,  649,  649,
+      649,  649,  649,  649,  876,  838,  841,  649,  837,  649,
+      842, 1134,  649,  649,  649,  649,  649,  649, 1131,  838,
+      841,  876, 1124, 1560,  842,  850,  850,  850,  850,  850,
+      850,  850,  876,  865,  649,  660,  660,  660,  660,  660,
 
-     1423,  652,  652,  652,  652,  652,  652,  654,  654,  654,
-      654,  654,  654,  654,  654,  654, 1185, 1071, 1185,  654,
-     1526,  654, 1553, 1557, 1067,  654,  654,  654,  654,  654,
-      654,  857,  857,  857,  857,  857,  857,  857,  861,  861,
-      861,  861,  861,  861,  861,  878,  870,  654,  665,  665,
-      665,  665,  665,  665,  665,  665,  665, 1472, 1060, 1059,
-      665, 1056, 1561,  878,  870, 1472,  665,  665,  665,  665,
-      665,  665,  666,  666,  666,  666,  666,  666,  666,  870,
-      878, 1052, 1051,  666,  887,  875,  877,  885, 1561,  666,
-      666,  666,  666,  666,  666,  669,  669,  669,  669,  669,
+      660,  660,  660,  660,  838,  841, 1123,  660, 1560,  842,
+      865,  882,  660,  660,  660,  660,  660,  660,  661,  661,
+      661,  661,  661,  661,  661,  865, 1120, 1115,  882,  661,
+     1114,  984, 1071, 1079,  661,  661,  661,  661,  661,  661,
+      664,  664,  664,  664,  664,  664,  664,  882,  984, 1071,
+     1079,  664,  870,  872,  958,  880,  664,  664,  664,  664,
+      664,  664,  852,  852,  852,  852,  852,  852,  852,  870,
+      872,  958,  880,  946,  664,  699,  947,  699,  699,  699,
+      699,  699,  699,  699,  870,  872,  958,  946,  699,  880,
+      947, 1083, 1074,  699,  699,  699,  699,  699,  699,  700,
 
-      669,  669,  887,  875,  877,  885,  669,  966, 1078,  951,
-      963,  881,  669,  669,  669,  669,  669,  669,  875,  877,
-     1565,  887,  885,  951, 1532,  966, 1078,  952,  963,  881,
-      669,  704, 1532,  704,  704,  704,  704,  704,  704,  704,
-      881,  952,  966,  963,  704, 1078, 1565,  964, 1048,  951,
-      704,  704,  704,  704,  704,  704,  910,  910,  910,  910,
-      910,  910,  910,  955,  956,  964,  968,  952,  704,  705,
-      705,  705,  705,  705,  705,  705,  705,  955,  956, 1044,
-      964,  705, 1190, 1298,  968,  968, 1043,  705,  705,  705,
-      705,  705,  705,  915,  915,  915,  915,  915,  915,  915,
+      700,  700,  700,  700,  700,  700,  700, 1111, 1083, 1074,
+     1083,  700,  946, 1074, 1110,  947,  700,  700,  700,  700,
+      700,  700,  701,  701,  701,  701,  701,  701,  701,  856,
+      856,  856,  856,  856,  856,  856,  961,  959,  877,  905,
+      905,  905,  905,  905,  905,  905,  910,  910,  910,  910,
+      910,  910,  910,  961,  959,  877,  701,  702,  702,  702,
+      702,  702,  702,  702,  877, 1107, 1106, 1103,  702,  959,
+      961, 1564, 1584,  702,  702,  702,  702,  702,  702,  704,
+      704,  704,  704,  704,  704,  704,  704,  706,  706,  706,
+      706,  706,  706,  706,  706, 1154, 1564, 1584, 1100,  706,
 
-     1190, 1298,  968,  955,  956,  705,  706,  706,  706,  706,
-      706,  706,  706,  919,  919,  919,  919,  919,  919,  919,
-      924,  924,  924,  924,  924,  924,  924,  926,  926,  926,
-      926,  926,  926,  926,  930,  930,  930,  930,  930,  930,
-      930,  706,  707,  707,  707,  707,  707,  707,  707, 1040,
-     1036, 1035, 1032,  707, 1029, 1569, 1589, 1598, 1028,  707,
-      707,  707,  707,  707,  707,  709,  709,  709,  709,  709,
-      709,  709,  709,  711,  711,  711,  711,  711,  711,  711,
-      711, 1569, 1589, 1598, 1025,  711, 1021, 1020, 1017, 1016,
-     1013,  711,  711,  711,  711,  711,  711,  712,  712,  712,
+     1593, 1097, 1093, 1154,  706,  706,  706,  706,  706,  706,
+      707,  707,  707,  707,  707,  707,  707,  707,  709,  709,
+      709,  709,  709,  709,  709, 1593, 1066, 1062, 1055,  709,
+     1054, 1051, 1077, 1078,  709,  709,  709,  709,  709,  709,
+      710,  710,  710,  710,  710,  710,  710,  710,  710, 1077,
+     1078, 1047,  710, 1077, 1082, 1078,  950,  710,  710,  710,
+      710,  710,  710,  711,  711,  711,  711,  711,  711,  711,
+      950, 1082, 1046, 1043,  711, 1039, 1082, 1087, 1038,  711,
+      711,  711,  711,  711,  711,  713,  713,  713,  713,  713,
+      713,  713,  713,  713, 1087,  950, 1035,  713, 1031, 1085,
 
-      712,  712,  712,  712,  712,  714,  714,  714,  714,  714,
-      714,  714, 1009, 1005, 1004, 1003,  714, 1000,  997, 1201,
-     1202, 1187,  714,  714,  714,  714,  714,  714,  715,  715,
-      715,  715,  715,  715,  715,  715,  715, 1201, 1202, 1187,
-      715, 1201,  994, 1202, 1299, 1010,  715,  715,  715,  715,
-      715,  715,  716,  716,  716,  716,  716,  716,  716, 1010,
-     1187,  991, 1299,  716,  990,  962, 1300,  961, 1301,  716,
-      716,  716,  716,  716,  716,  718,  718,  718,  718,  718,
-      718,  718,  718,  718, 1300, 1010, 1301,  718,  958, 1192,
-     1302, 1310, 1011,  718,  718,  718,  718,  718,  718,  719,
+     1087,  951,  713,  713,  713,  713,  713,  713,  714,  714,
+      714,  714,  714,  714,  714,  951, 1085, 1085, 1030,  714,
+     1027, 1177, 1088, 1024,  714,  714,  714,  714,  714,  714,
+      718,  718,  718,  718,  718,  718,  718,  718, 1177, 1088,
+      951,  718, 1088, 1023, 1178, 1020,  718,  718,  718,  718,
+      718,  718,  720,  720,  720,  720,  720,  720,  720,  720,
+      720, 1178, 1177, 1016,  720, 1015, 1179, 1181, 1012,  720,
+      720,  720,  720,  720,  720,  721,  721,  721,  721,  721,
+      721,  721,  721, 1179, 1181, 1178,  721, 1011, 1008, 1180,
+     1004,  721,  721,  721,  721,  721,  721,  729,  729,  729,
 
-      719,  719,  719,  719,  719,  719, 1011, 1192, 1302, 1310,
-      719,  954, 1307, 1302, 1310, 1192,  719,  719,  719,  719,
-      719,  719,  723,  723,  723,  723,  723,  723,  723,  723,
-     1307,  953, 1011,  723,  950,  945,  941, 1314, 1315,  723,
-      723,  723,  723,  723,  723,  725,  725,  725,  725,  725,
-      725,  725,  725,  725, 1307, 1314, 1315,  725,  933,  929,
-     1396, 1397,  922,  725,  725,  725,  725,  725,  725,  726,
-      726,  726,  726,  726,  726,  726,  726, 1315, 1396, 1397,
-      726, 1396, 1397, 1398, 1399, 1401,  726,  726,  726,  726,
-      726,  726,  734,  734,  734,  734,  734,  734,  734,  734,
+      729,  729,  729,  729,  729,  729, 1180, 1179, 1180,  729,
+     1000, 1184, 1185, 1182,  729,  729,  729,  729,  729,  729,
+      730,  730,  730,  730,  730,  730,  730,  730, 1184, 1185,
+     1182,  730,  999, 1184,  998, 1196,  730,  730,  730,  730,
+      730,  730,  740,  740,  740,  740,  740,  740,  740,  740,
+      740, 1182, 1196,  995,  740,  992, 1196, 1197, 1293,  740,
+      740,  740,  740,  740,  740,  741,  741,  741,  741,  741,
+      741,  741,  741,  989, 1197, 1293,  741,  986,  985, 1197,
+     1294,  741,  741,  741,  741,  741,  741,  753,  753,  753,
+      753,  753,  753,  753,  753,  753,  957, 1294,  956,  753,
 
-      734, 1398, 1399, 1401,  734,  918, 1399,  913, 1402,  908,
-      734,  734,  734,  734,  734,  734,  735,  735,  735,  735,
-      735,  735,  735,  735,  907, 1398, 1402,  735,  906,  903,
-     1402, 1403, 1404,  735,  735,  735,  735,  735,  735,  745,
-      745,  745,  745,  745,  745,  745,  745,  745,  900, 1403,
-     1404,  745,  896, 1403, 1406, 1409, 1404,  745,  745,  745,
-      745,  745,  745,  746,  746,  746,  746,  746,  746,  746,
-      746,  864, 1406, 1409,  746,  860, 1406, 1477, 1409, 1478,
-      746,  746,  746,  746,  746,  746,  758,  758,  758,  758,
-      758,  758,  758,  758,  758, 1477,  853, 1478,  758,  852,
+      953,  949,  948,  975,  753,  753,  753,  753,  753,  753,
+      755,  755,  755,  755,  755,  755,  755,  755,  755,  879,
+      975, 1005,  755,  945,  755,  940,  936,  755,  755,  755,
+      755,  755,  755,  975,  967, 1005,  879,  914,  914,  914,
+      914,  914,  914,  914, 1076,  879,  928,  963, 1006,  755,
+      789,  967,  789,  789,  789,  789,  789,  789,  789,  967,
+     1005, 1076, 1006,  789,  963,  963, 1295,  789,  789,  789,
+      789,  789,  789,  789,  791,  791,  791,  791,  791,  791,
+      791, 1076,  963, 1295,  924,  791,  971, 1006, 1296, 1309,
+      791,  791,  791,  791,  791,  791,  793,  793,  793,  793,
 
-      849, 1488,  845, 1477,  758,  758,  758,  758,  758,  758,
-      760,  760,  760,  760,  760,  760,  760,  760,  760, 1488,
-     1488,  844,  760,  841,  760,  838,  837,  834,  760,  760,
-      760,  760,  760,  760,  936,  936,  936,  936,  936,  936,
-      936,  938,  938,  938,  938,  938,  938,  938, 1018,  969,
-      760,  794, 1019,  794,  794,  794,  794,  794,  794,  794,
-      830,  829, 1018,  826,  794,  825, 1019,  969, 1081,  794,
-      794,  794,  794,  794,  794,  794,  796,  796,  796,  796,
-      796,  796,  796,  969,  822,  818, 1081,  796, 1018, 1534,
-     1491, 1536, 1019,  796,  796,  796,  796,  796,  796,  798,
+      793,  793,  793,  971,  917, 1296, 1309,  793,  913, 1187,
+     1297,  971,  793,  793,  793,  793,  793,  793,  795,  795,
+      795,  795,  795,  795,  795,  795, 1187, 1297,  908,  903,
+      795,  902, 1297,  901, 1187,  795,  795,  795,  795,  795,
+      795,  796,  796,  796,  796,  796,  796,  796,  796,  799,
+      799,  799,  799,  799,  799,  799,  799,  799,  898,  895,
+      891,  799,  859,  799,  855,  848,  799,  799,  799,  799,
+      799,  799,  919,  919,  919,  919,  919,  919,  919,  921,
+      921,  921,  921,  921,  921,  921,  847, 1396,  799,  802,
+      802,  802,  802,  802,  802,  802,  802,  802,  844,  840,
 
-      798,  798,  798,  798,  798,  798, 1081, 1534, 1491, 1536,
-      798, 1491, 1303, 1537, 1544, 1548,  798,  798,  798,  798,
-      798,  798,  800,  800,  800,  800,  800,  800,  800,  800,
-     1303, 1537, 1544, 1548,  800,  815, 1537, 1544,  814, 1303,
-      800,  800,  800,  800,  800,  800,  801,  801,  801,  801,
-      801,  801,  801,  801,  804,  804,  804,  804,  804,  804,
-      804,  804,  804,  813,  812,  809,  804,  806,  804,  803,
-      802,  763,  804,  804,  804,  804,  804,  804,  942,  942,
-      942,  942,  942,  942,  942,  949,  949,  949,  949,  949,
-      949,  949,  965,  971,  804,  807,  807,  807,  807,  807,
+      839,  802,  836,  802, 1396,  833,  802,  802,  802,  802,
+      802,  802,  925,  925,  925,  925,  925,  925,  925,  931,
+      931,  931,  931,  931,  931,  931,  832, 1473,  802,  805,
+      805,  805,  805,  805,  805,  805,  805,  805,  829,  825,
+      824,  805,  821,  805, 1473,  820,  805,  805,  805,  805,
+      805,  805,  933,  933,  933,  933,  933,  933,  933,  937,
+      937,  937,  937,  937,  937,  937, 1013,  960,  805,  811,
+      811,  811,  811,  811,  811,  811,  811,  811,  817,  813,
+     1013,  811,  810,  811,  960,  964,  811,  811,  811,  811,
+      811,  811,  944,  944,  944,  944,  944,  944,  944,  960,
 
-      807,  807,  807,  807, 1073, 1074, 1022,  807,  762,  807,
-      965,  971, 1479,  807,  807,  807,  807,  807,  807,  759,
-     1022,  755, 1073, 1074,  754,  965,  965,  982,  971,  980,
-     1479, 1077,  751, 1073, 1074,  807,  810,  810,  810,  810,
-      810,  810,  810,  810,  810,  982, 1022,  980,  810, 1077,
-      810, 1479, 1023,  747,  810,  810,  810,  810,  810,  810,
-      980, 1033,  982, 1077,  743,  736, 1023, 1031, 1031, 1031,
-     1031, 1031, 1031, 1031, 1034, 1033,  810,  816,  816,  816,
-      816,  816,  816,  816,  816,  816, 1576, 1075, 1034,  816,
-      732,  816, 1023, 1037, 1038,  816,  816,  816,  816,  816,
+      960,  809,  964,  808,  807, 1013, 1014,  966,  811,  816,
+      816,  816,  816,  816,  816,  816,  816,  816,  964,  804,
+     1014,  816,  801,  798,  966,  977,  816,  816,  816,  816,
+      816,  816,  818,  818,  818,  818,  818,  818,  818,  818,
+      818,  966,  977, 1017,  818, 1014,  818, 1018, 1286,  818,
+      818,  818,  818,  818,  818,  797, 1286, 1017,  758,  977,
+      757, 1018, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1028,
+      754,  818,  828,  828,  828,  828,  828,  828,  828,  828,
+      828,  750, 1017, 1028,  828,  749, 1018, 1072,  746,  828,
+      828,  828,  828,  828,  828,  830,  830,  830,  830,  830,
 
-      816, 1033,  727,  722, 1576, 1075,  721, 1037, 1038,  720,
-     1541,  717,  713, 1049, 1034, 1050, 1075,  816,  821,  821,
-      821,  821,  821,  821,  821,  821,  821, 1049, 1541, 1050,
-      821,  703,  702, 1037, 1038,  698,  821,  821,  821,  821,
-      821,  821,  823,  823,  823,  823,  823,  823,  823,  823,
-      823, 1541,  697, 1049,  823, 1050,  823, 1085, 1196, 1053,
-      823,  823,  823,  823,  823,  823, 1047, 1047, 1047, 1047,
-     1047, 1047, 1047, 1053,  695, 1085, 1196,  694, 1054, 1410,
-     1197,  677,  823,  833,  833,  833,  833,  833,  833,  833,
-      833,  833, 1054, 1196, 1085,  833,  667, 1410, 1197, 1053,
+      830,  830,  830,  830, 1072, 1029, 1032,  830, 1028,  830,
+     1033,  742,  830,  830,  830,  830,  830,  830, 1072, 1029,
+     1032,  738,  731,  727, 1033, 1042, 1042, 1042, 1042, 1042,
+     1042, 1042, 1044, 1302,  830,  843,  843,  843,  843,  843,
+      843,  843,  843,  843, 1029, 1032, 1044,  843,  722, 1033,
+     1302,  717,  843,  843,  843,  843,  843,  843,  845,  845,
+      845,  845,  845,  845,  845,  845,  845, 1068, 1045, 1048,
+      845, 1044,  845, 1049, 1302,  845,  845,  845,  845,  845,
+      845,  716, 1045, 1048, 1068,  715,  712, 1049, 1057, 1057,
+     1057, 1057, 1057, 1057, 1057, 1068,  708,  845,  857,  857,
 
-      663,  833,  833,  833,  833,  833,  833,  835,  835,  835,
-      835,  835,  835,  835,  835,  835, 1197, 1410, 1054,  835,
-      657,  835,  656,  653,  649,  835,  835,  835,  835,  835,
-      835, 1062, 1062, 1062, 1062, 1062, 1062, 1062, 1064, 1064,
-     1064, 1064, 1064, 1064, 1064, 1170, 1094,  835,  848,  848,
-      848,  848,  848,  848,  848,  848,  848,  648,  645, 1170,
-      848,  644,  641,  637, 1094, 1094,  848,  848,  848,  848,
-      848,  848,  850,  850,  850,  850,  850,  850,  850,  850,
-      850, 1094, 1094,  634,  850, 1170,  850, 1587, 1486, 1086,
-      850,  850,  850,  850,  850,  850, 1068, 1068, 1068, 1068,
+      857,  857,  857,  857,  857,  857,  857, 1045, 1048,  698,
+      857,  697, 1049, 1075, 1165,  857,  857,  857,  857,  857,
+      857,  858,  858,  858,  858,  858,  858,  858, 1165,  693,
+     1075,  692,  858,  690,  689, 1305,  672,  858,  858,  858,
+      858,  858,  858,  884, 1075,  884,  884,  884,  884,  884,
+      884,  884, 1305, 1165,  662,  658,  884, 1305, 1393, 1310,
+      884,  884,  884,  884,  884,  884,  884,  885,  885,  885,
+      885,  885,  885,  885, 1342, 1393, 1310,  652,  885,  651,
+      648, 1394, 1342,  885,  885,  885,  885,  885,  885,  886,
+      886,  886,  886,  886,  886,  886,  886, 1310, 1394, 1393,
 
-     1068, 1068, 1068,  633,  632, 1587, 1486, 1086, 1200, 1171,
-     1174,  631,  850,  862,  862,  862,  862,  862,  862,  862,
-      862,  862, 1086, 1171, 1174,  862, 1200, 1486, 1612, 1080,
-     1175,  862,  862,  862,  862,  862,  862,  863,  863,  863,
-      863,  863,  863,  863, 1175, 1200, 1612, 1080,  863, 1171,
-     1174, 1578,  628, 1579,  863,  863,  863,  863,  863,  863,
-      889, 1080,  889,  889,  889,  889,  889,  889,  889, 1578,
-     1175, 1579, 1578,  889, 1579, 1620, 1580, 1628,  889,  889,
-      889,  889,  889,  889,  889,  890,  890,  890,  890,  890,
-      890,  890,  625, 1620, 1580, 1628,  890, 1580, 1411, 1089,
+      644,  886, 1394,  886,  643,  640,  886,  886,  886,  886,
+      886,  886, 1059, 1059, 1059, 1059, 1059, 1059, 1059, 1063,
+     1063, 1063, 1063, 1063, 1063, 1063, 1073, 1081,  886,  888,
+      888,  888,  888,  888,  888,  888,  639,  636,  632,  629,
+      888,  628,  627, 1073, 1081,  888,  888,  888,  888,  888,
+      888,  889,  889,  889,  889,  889,  889,  889,  889, 1081,
+      626,  623, 1073,  889,  620,  619,  612,  609,  889,  889,
+      889,  889,  889,  889,  890,  890,  890,  890,  890,  890,
+      890,  890,  892,  892,  892,  892,  892,  892,  892, 1349,
+      607,  603,  597,  892,  596,  595, 1397, 1349,  892,  892,
 
-     1585, 1091,  890,  890,  890,  890,  890,  890,  891,  891,
-      891,  891,  891,  891,  891,  891, 1411, 1089, 1585, 1091,
-      891, 1585,  891,  624,  617, 1411,  891,  891,  891,  891,
-      891,  891, 1089, 1091, 1117, 1117, 1117, 1117, 1117, 1117,
-     1117, 1122, 1122, 1122, 1122, 1122, 1122, 1122,  891,  893,
-      893,  893,  893,  893,  893,  893,  614,  612,  608,  602,
-      893,  601, 1476, 1605, 1607, 1608,  893,  893,  893,  893,
-      893,  893,  894,  894,  894,  894,  894,  894,  894,  894,
-     1476, 1605, 1607, 1608,  894, 1605,  600, 1607, 1608, 1476,
-      894,  894,  894,  894,  894,  894,  895,  895,  895,  895,
+      892,  892,  892,  892,  893,  893,  893,  893,  893,  893,
+      893,  893,  893, 1397,  594,  590,  893, 1397, 1404, 1391,
+     1166,  893,  893,  893,  893,  893,  893,  894,  894,  894,
+      894,  894,  894,  894, 1166, 1404, 1391,  589,  894, 1391,
+     1404, 1398,  587,  894,  894,  894,  894,  894,  894,  896,
+      896,  896,  896,  896,  896,  896,  896,  896, 1398, 1166,
+      586,  896, 1398, 1399, 1392, 1169,  896,  896,  896,  896,
+      896,  896,  897,  897,  897,  897,  897,  897,  897, 1169,
+     1399, 1392,  585,  897, 1392,  584, 1399,  580,  897,  897,
+      897,  897,  897,  897,  899,  899,  899,  899,  899,  899,
 
-      895,  895,  895,  895,  897,  897,  897,  897,  897,  897,
-      897,  599,  595,  594,  592,  897,  591,  590, 1633, 1634,
-     1622,  897,  897,  897,  897,  897,  897,  898,  898,  898,
-      898,  898,  898,  898,  898,  898, 1633, 1634, 1622,  898,
-      589,  585, 1634, 1635, 1229,  898,  898,  898,  898,  898,
-      898,  899,  899,  899,  899,  899,  899,  899, 1229, 1622,
-      584, 1635,  899,  583,  582, 1636, 1635, 1623,  899,  899,
-      899,  899,  899,  899,  901,  901,  901,  901,  901,  901,
-      901,  901,  901, 1636, 1229, 1623,  901,  581, 1636, 1638,
-     1640, 1230,  901,  901,  901,  901,  901,  901,  902,  902,
+      899,  899,  899,  579, 1169,  578,  899,  577, 1401, 1474,
+     1170,  899,  899,  899,  899,  899,  899,  900,  900,  900,
+      900,  900,  900,  900, 1170, 1401, 1474,  576,  900, 1401,
+      575, 1486,  574,  900,  900,  900,  900,  900,  900,  904,
+      904,  904,  904,  904,  904,  904,  904, 1474, 1486, 1170,
+      904, 1486,  573, 1529, 1481,  904,  904,  904,  904,  904,
+      904,  906,  906,  906,  906,  906,  906,  906,  906,  906,
+     1529, 1481,  572,  906,  571,  570, 1483,  569,  906,  906,
+      906,  906,  906,  906,  907,  907,  907,  907,  907,  907,
+      907,  907, 1481, 1483, 1483,  907,  568,  567, 1531, 1532,
 
-      902,  902,  902,  902,  902, 1230, 1623, 1638, 1640,  902,
-      580,  579, 1638,  578, 1624,  902,  902,  902,  902,  902,
-      902,  904,  904,  904,  904,  904,  904,  904,  904,  904,
-      577, 1230, 1624,  904,  576,  575, 1645, 1647, 1235,  904,
-      904,  904,  904,  904,  904,  905,  905,  905,  905,  905,
-      905,  905, 1235, 1624, 1645, 1647,  905, 1645, 1649, 1647,
-      574,  573,  905,  905,  905,  905,  905,  905,  909,  909,
-      909,  909,  909,  909,  909,  909, 1649,  572, 1235,  909,
-      569, 1649, 1651, 1652, 1657,  909,  909,  909,  909,  909,
-      909,  911,  911,  911,  911,  911,  911,  911,  911,  911,
+      907,  907,  907,  907,  907,  907,  915,  915,  915,  915,
+      915,  915,  915,  915,  915, 1531, 1532,  564,  915,  563,
+     1536, 1532, 1539,  915,  915,  915,  915,  915,  915,  916,
+      916,  916,  916,  916,  916,  916,  916, 1536,  562, 1539,
+      916,  560,  559,  556, 1539,  916,  916,  916,  916,  916,
+      916,  926,  926,  926,  926,  926,  926,  926,  926,  926,
+     1536,  551,  547,  926,  543, 1543, 1571, 1573,  926,  926,
+      926,  926,  926,  926,  927,  927,  927,  927,  927,  927,
+      927,  927, 1543, 1571, 1573,  927,  538, 1573, 1582, 1574,
+      927,  927,  927,  927,  927,  927,  938,  938,  938,  938,
 
-     1651, 1652, 1657,  911,  568, 1651, 1653,  567,  565,  911,
-      911,  911,  911,  911,  911,  912,  912,  912,  912,  912,
-      912,  912,  912, 1657, 1653, 1652,  912,  564,  561, 1660,
-      556, 1664,  912,  912,  912,  912,  912,  912,  920,  920,
-      920,  920,  920,  920,  920,  920,  920, 1660, 1653, 1664,
-      920,  552, 1660, 1668, 1669,  548,  920,  920,  920,  920,
-      920,  920,  921,  921,  921,  921,  921,  921,  921,  921,
-      543, 1668, 1669,  921,  538,  537, 1668, 1669, 1674,  921,
-      921,  921,  921,  921,  921,  931,  931,  931,  931,  931,
-      931,  931,  931,  931,  536,  532, 1674,  931,  526, 1675,
+      938,  938,  938,  938,  938, 1582, 1574,  533,  938, 1574,
+     1607, 1575, 1580,  938,  938,  938,  938,  938,  938,  939,
+      939,  939,  939,  939,  939,  939,  939, 1607, 1575, 1580,
+      939, 1575, 1580, 1600, 1602,  939,  939,  939,  939,  939,
+      939,  952,  952,  952,  952,  952,  952,  952,  952,  952,
+     1600, 1602,  532,  952, 1600,  531, 1602,  527,  952,  952,
+      952,  952,  952,  952,  954,  954,  954,  954,  954,  954,
+      954,  954,  954, 1069, 1070,  521,  954, 1080,  954, 1224,
+     1089,  954,  954,  954,  954,  954,  954, 1357, 1365,  520,
+     1069, 1070, 1373, 1224, 1080, 1357, 1365, 1089, 1089, 1615,
 
-     1677, 1674,  525,  931,  931,  931,  931,  931,  931,  932,
-      932,  932,  932,  932,  932,  932,  932, 1675, 1677,  520,
-      932, 1675,  519, 1679, 1682, 1683,  932,  932,  932,  932,
-      932,  932,  943,  943,  943,  943,  943,  943,  943,  943,
-      943, 1679, 1682, 1683,  943, 1682, 1679, 1684, 1689,  518,
-      943,  943,  943,  943,  943,  943,  944,  944,  944,  944,
-      944,  944,  944,  944,  517, 1684, 1689,  944,  516,  515,
-     1694, 1689, 1698,  944,  944,  944,  944,  944,  944,  957,
-      957,  957,  957,  957,  957,  957,  957,  957, 1694, 1684,
-     1698,  957,  514,  513, 1700, 1698, 1703,  957,  957,  957,
+     1373, 1069, 1070,  954,  981,  981,  981,  981,  981,  981,
+      981,  981,  981, 1080, 1089, 1089, 1615,  981, 1224,  515,
+      514,  981,  981,  981,  981,  981,  981,  981,  982,  982,
+      982,  982,  982,  982,  982,  982,  983,  983,  983,  983,
+      983,  983,  983,  983,  983,  513, 1084, 1189, 1086,  512,
+     1623,  511, 1195,  983,  987,  987,  987,  987,  987,  987,
+      987,  987,  987, 1084, 1189, 1086,  987, 1623,  987, 1195,
+     1191,  987,  987,  987,  987,  987,  987, 1189, 1084, 1086,
+     1112, 1112, 1112, 1112, 1112, 1112, 1112, 1191, 1195,  510,
+     1628,  509, 1635,  987,  990,  990,  990,  990,  990,  990,
 
-      957,  957,  957,  959,  959,  959,  959,  959,  959,  959,
-      959,  959, 1700,  512, 1703,  959,  511,  959,  510,  509,
-      508,  959,  959,  959,  959,  959,  959, 1126, 1126, 1126,
-     1126, 1126, 1126, 1126, 1131, 1131, 1131, 1131, 1131, 1131,
-     1131, 1710, 1712,  959,  986,  986,  986,  986,  986,  986,
-      986,  986,  986,  506,  503,  502,  501,  986,  500, 1710,
-     1712,  499,  986,  986,  986,  986,  986,  986,  986,  987,
-      987,  987,  987,  987,  987,  987,  987,  988,  988,  988,
-      988,  988,  988,  988,  988,  988, 1133, 1133, 1133, 1133,
-     1133, 1133, 1133, 1701, 1714,  988,  992,  992,  992,  992,
+      990,  990,  990,  508, 1191,  507,  990, 1628,  990, 1635,
+      506,  990,  990,  990,  990,  990,  990, 1117, 1117, 1117,
+     1117, 1117, 1117, 1117, 1121, 1121, 1121, 1121, 1121, 1121,
+     1121,  505, 1659,  990,  993,  993,  993,  993,  993,  993,
+      993,  993,  993,  504,  503,  501,  993,  498,  993, 1659,
+      497,  993,  993,  993,  993,  993,  993, 1126, 1126, 1126,
+     1126, 1126, 1126, 1126, 1128, 1128, 1128, 1128, 1128, 1128,
+     1128,  496, 1672,  993,  996,  996,  996,  996,  996,  996,
+      996,  996,  996,  495,  494,  493,  996,  492,  996, 1672,
+      490,  996,  996,  996,  996,  996,  996, 1132, 1132, 1132,
 
-      992,  992,  992,  992,  992,  498,  497,  495,  992,  494,
-      992, 1701, 1714,  493,  992,  992,  992,  992,  992,  992,
-     1137, 1137, 1137, 1137, 1137, 1137, 1137, 1143, 1143, 1143,
-     1143, 1143, 1143, 1143, 1706, 1701,  992,  995,  995,  995,
-      995,  995,  995,  995,  995,  995,  492,  491,  489,  995,
-      487,  995, 1706,  485,  484,  995,  995,  995,  995,  995,
-      995, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1149, 1149,
-     1149, 1149, 1149, 1149, 1149, 1719, 1706,  995,  998,  998,
-      998,  998,  998,  998,  998,  998,  998,  483,  482,  481,
-      998,  479,  998, 1719,  478,  476,  998,  998,  998,  998,
+     1132, 1132, 1132, 1132, 1138, 1138, 1138, 1138, 1138, 1138,
+     1138, 1192, 1225,  996, 1001, 1001, 1001, 1001, 1001, 1001,
+     1001, 1001,  489,  488,  487, 1001, 1225,  486, 1192,  484,
+     1001, 1001, 1001, 1001, 1001, 1001, 1002, 1002, 1002, 1002,
+     1002, 1002, 1002, 1002, 1002,  482, 1192,  480, 1002,  479,
+     1002, 1225,  478, 1002, 1002, 1002, 1002, 1002, 1002, 1140,
+     1140, 1140, 1140, 1140, 1140, 1140, 1144, 1144, 1144, 1144,
+     1144, 1144, 1144, 1230, 1193, 1002, 1007, 1007, 1007, 1007,
+     1007, 1007, 1007, 1007, 1007,  477,  476, 1230, 1007,  474,
+      473, 1193, 1603, 1007, 1007, 1007, 1007, 1007, 1007, 1009,
 
-      998,  998, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1157,
-     1157, 1157, 1157, 1157, 1157, 1157, 1721, 1724,  998, 1001,
-     1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001,  475,  474,
-      471, 1001,  467, 1001, 1721, 1724,  463, 1001, 1001, 1001,
-     1001, 1001, 1001, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
-     1168, 1168, 1168, 1168, 1168, 1168, 1168,  462,  461, 1001,
-     1006, 1006, 1006, 1006, 1006, 1006, 1006, 1006,  458,  454,
-      453, 1006,  450,  449,  448, 1191, 1194, 1006, 1006, 1006,
-     1006, 1006, 1006, 1007, 1007, 1007, 1007, 1007, 1007, 1007,
-     1007, 1007, 1188, 1191, 1194, 1007, 1543, 1007, 1198, 1236,
+     1009, 1009, 1009, 1009, 1009, 1009, 1009, 1009, 1193, 1603,
+      471, 1009, 1230, 1009, 1603,  470, 1009, 1009, 1009, 1009,
+     1009, 1009, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1152,
+     1152, 1152, 1152, 1152, 1152, 1152, 1231, 1301, 1009, 1019,
+     1019, 1019, 1019, 1019, 1019, 1019, 1019, 1019,  469,  466,
+     1231, 1019,  462,  458, 1301, 1301, 1019, 1019, 1019, 1019,
+     1019, 1019, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021,
+     1021,  457, 1301,  456, 1021, 1231, 1021,  453,  449, 1021,
+     1021, 1021, 1021, 1021, 1021, 1156, 1156, 1156, 1156, 1156,
+     1156, 1156, 1163, 1163, 1163, 1163, 1163, 1163, 1163, 1234,
 
-     1308, 1007, 1007, 1007, 1007, 1007, 1007, 1194, 1191,  447,
-     1188,  444,  443, 1236, 1543,  434, 1198, 1709, 1308,  431,
-      429, 1188,  428, 1007, 1012, 1012, 1012, 1012, 1012, 1012,
-     1012, 1012, 1012, 1198, 1543, 1709, 1012, 1308, 1709, 1236,
-     1195, 1199, 1012, 1012, 1012, 1012, 1012, 1012, 1014, 1014,
-     1014, 1014, 1014, 1014, 1014, 1014, 1014, 1193, 1195, 1199,
-     1014,  427, 1014,  426,  425, 1309, 1014, 1014, 1014, 1014,
-     1014, 1014, 1195, 1199,  424, 1193, 1223, 1223, 1223, 1223,
-     1223, 1223, 1223, 1309, 1239, 1311, 1193,  423, 1014, 1024,
-     1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1239,  422,
+     1303, 1021, 1034, 1034, 1034, 1034, 1034, 1034, 1034, 1034,
+     1034,  448,  445, 1234, 1034,  444,  443, 1303, 1186, 1034,
+     1034, 1034, 1034, 1034, 1034, 1036, 1036, 1036, 1036, 1036,
+     1036, 1036, 1036, 1036, 1183, 1186, 1303, 1036, 1234, 1036,
+     1418, 1467, 1036, 1036, 1036, 1036, 1036, 1036, 1418, 1467,
+     1186, 1183, 1218, 1218, 1218, 1218, 1218, 1218, 1218, 1640,
+     1235, 1678, 1183, 1617, 1036, 1050, 1050, 1050, 1050, 1050,
+     1050, 1050, 1050, 1050, 1235,  442, 1640, 1050, 1678, 1640,
+     1617, 1190, 1050, 1050, 1050, 1050, 1050, 1050, 1052, 1052,
+     1052, 1052, 1052, 1052, 1052, 1052, 1052, 1188, 1190, 1235,
 
-     1309, 1024,  421, 1311,  420, 1203,  419, 1024, 1024, 1024,
-     1024, 1024, 1024, 1026, 1026, 1026, 1026, 1026, 1026, 1026,
-     1026, 1026, 1311, 1203, 1239, 1026,  418, 1026, 1240,  417,
-      416, 1026, 1026, 1026, 1026, 1026, 1026, 1203,  414,  412,
-      411,  409, 1240, 1246, 1246, 1246, 1246, 1246, 1246, 1246,
-      408, 1248, 1313, 1026, 1039, 1039, 1039, 1039, 1039, 1039,
-     1039, 1039, 1039,  405,  404, 1248, 1039,  402, 1240,  400,
-     1313,  399, 1039, 1039, 1039, 1039, 1039, 1039, 1041, 1041,
-     1041, 1041, 1041, 1041, 1041, 1041, 1041, 1313, 1249, 1252,
-     1041, 1248, 1041, 1253,  398,  393, 1041, 1041, 1041, 1041,
+     1052, 1617, 1052, 1527,  439, 1052, 1052, 1052, 1052, 1052,
+     1052, 1527, 1190,  438, 1188, 1241, 1241, 1241, 1241, 1241,
+     1241, 1241, 1405,  429, 1243, 1188, 1304, 1052, 1064, 1064,
+     1064, 1064, 1064, 1064, 1064, 1064, 1064,  426, 1243, 1405,
+     1064,  424,  423, 1304, 1244, 1064, 1064, 1064, 1064, 1064,
+     1064, 1065, 1065, 1065, 1065, 1065, 1065, 1065, 1244, 1405,
+     1304,  422, 1065, 1243,  421, 1629,  420, 1065, 1065, 1065,
+     1065, 1065, 1065, 1090, 1090, 1090, 1090, 1090, 1090, 1090,
+     1090, 1090, 1629, 1244,  419,  418, 1090, 1629,  417,  416,
+     1090, 1090, 1090, 1090, 1090, 1090, 1090, 1091, 1091, 1091,
 
-     1041, 1041, 1249, 1252,  392,  391,  389, 1253, 1260, 1260,
-     1260, 1260, 1260, 1260, 1260,  388, 1262, 1395, 1041, 1055,
-     1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1249, 1252,
-     1262, 1055,  387, 1253,  386, 1395,  384, 1055, 1055, 1055,
-     1055, 1055, 1055, 1057, 1057, 1057, 1057, 1057, 1057, 1057,
-     1057, 1057, 1395, 1263, 1266, 1057, 1262, 1057, 1267,  379,
-      378, 1057, 1057, 1057, 1057, 1057, 1057, 1263, 1266,  377,
-      374,  370, 1267, 1274, 1274, 1274, 1274, 1274, 1274, 1274,
-      368, 1276, 1489, 1057, 1069, 1069, 1069, 1069, 1069, 1069,
-     1069, 1069, 1069, 1263, 1266, 1276, 1069,  363, 1267,  362,
+     1091, 1091, 1091, 1091, 1091, 1092, 1092, 1092, 1092, 1092,
+     1092, 1092, 1092, 1092,  415, 1642, 1247, 1248,  414, 1257,
+     1308, 1258, 1092, 1094, 1094, 1094, 1094, 1094, 1094, 1094,
+     1247, 1248, 1642, 1257, 1094, 1258, 1642, 1308,  413, 1094,
+     1094, 1094, 1094, 1094, 1094, 1095, 1095, 1095, 1095, 1095,
+     1095, 1095, 1095, 1095, 1308, 1247, 1248, 1095, 1257, 1630,
+     1258, 1261, 1095, 1095, 1095, 1095, 1095, 1095, 1096, 1096,
+     1096, 1096, 1096, 1096, 1096, 1261, 1630,  412,  411, 1096,
+      409, 1630, 1631,  407, 1096, 1096, 1096, 1096, 1096, 1096,
+     1098, 1098, 1098, 1098, 1098, 1098, 1098, 1098, 1098, 1631,
 
-     1489, 1277, 1069, 1069, 1069, 1069, 1069, 1069, 1070, 1070,
-     1070, 1070, 1070, 1070, 1070, 1277,  359, 1489,  354, 1070,
-      353, 1276, 1707,  345, 1713, 1070, 1070, 1070, 1070, 1070,
-     1070, 1095, 1095, 1095, 1095, 1095, 1095, 1095, 1095, 1095,
-     1707, 1277, 1713,  343, 1095, 1707,  342, 1713,  337, 1095,
-     1095, 1095, 1095, 1095, 1095, 1095, 1096, 1096, 1096, 1096,
-     1096, 1096, 1096, 1096, 1097, 1097, 1097, 1097, 1097, 1097,
-     1097, 1097, 1097,  335, 1725, 1726, 1280, 1281, 1727, 1306,
-      333, 1337, 1097, 1099, 1099, 1099, 1099, 1099, 1099, 1099,
-     1280, 1281, 1725, 1726, 1099, 1337, 1727, 1306, 1306,  332,
+     1261,  406, 1098,  404, 1631, 1633, 1262, 1098, 1098, 1098,
+     1098, 1098, 1098, 1099, 1099, 1099, 1099, 1099, 1099, 1099,
+     1262,  403, 1633,  400, 1099,  399,  397, 1633,  395, 1099,
+     1099, 1099, 1099, 1099, 1099, 1101, 1101, 1101, 1101, 1101,
+     1101, 1101, 1101, 1101,  394, 1262,  393, 1101,  388, 1644,
+     1647, 1271, 1101, 1101, 1101, 1101, 1101, 1101, 1102, 1102,
+     1102, 1102, 1102, 1102, 1102, 1271, 1644, 1647,  387, 1102,
+      386, 1644, 1618,  384, 1102, 1102, 1102, 1102, 1102, 1102,
+     1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1618,
+     1271, 1647, 1104,  383, 1646, 1648, 1689, 1104, 1104, 1104,
 
-     1099, 1099, 1099, 1099, 1099, 1099, 1100, 1100, 1100, 1100,
-     1100, 1100, 1100, 1100, 1100, 1306, 1280, 1281, 1100,  331,
-      330, 1337,  329, 1338, 1100, 1100, 1100, 1100, 1100, 1100,
-     1101, 1101, 1101, 1101, 1101, 1101, 1101, 1338,  328,  327,
-      325, 1101,  324,  323,  318,  315, 1687, 1101, 1101, 1101,
-     1101, 1101, 1101, 1103, 1103, 1103, 1103, 1103, 1103, 1103,
-     1103, 1103,  314, 1338, 1687, 1103,  313,  310,  303,  302,
-     1385, 1103, 1103, 1103, 1103, 1103, 1103, 1104, 1104, 1104,
-     1104, 1104, 1104, 1104, 1385, 1687,  300,  299, 1104,  298,
-      296,  294,  293, 1718, 1104, 1104, 1104, 1104, 1104, 1104,
+     1104, 1104, 1104, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+     1618, 1646, 1648, 1689, 1105,  382, 1646, 1194, 1198, 1105,
+     1105, 1105, 1105, 1105, 1105, 1108, 1108, 1108, 1108, 1108,
+     1108, 1108, 1108, 1108, 1194, 1198, 1648, 1108,  381, 1108,
+      379,  374, 1108, 1108, 1108, 1108, 1108, 1108, 1194, 1198,
+     1255, 1255, 1255, 1255, 1255, 1255, 1255, 1269, 1269, 1269,
+     1269, 1269, 1269, 1269, 1108, 1113, 1113, 1113, 1113, 1113,
+     1113, 1113, 1113, 1113,  373,  372,  369, 1113,  365,  363,
+     1655, 1663, 1113, 1113, 1113, 1113, 1113, 1113, 1122, 1122,
+     1122, 1122, 1122, 1122, 1122, 1122, 1122, 1655, 1663,  358,
 
-     1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106,  292,
-     1385, 1718, 1106,  290,  286,  285,  283, 1386, 1106, 1106,
-     1106, 1106, 1106, 1106, 1107, 1107, 1107, 1107, 1107, 1107,
-     1107, 1386, 1718,  280,  276, 1107,  275,  272,  271,  269,
-      264, 1107, 1107, 1107, 1107, 1107, 1107, 1109, 1109, 1109,
-     1109, 1109, 1109, 1109, 1109, 1109,  261, 1386,  259, 1109,
-      258,  256,  253,  249, 1389, 1109, 1109, 1109, 1109, 1109,
-     1109, 1110, 1110, 1110, 1110, 1110, 1110, 1110, 1389,  245,
-      243,  241, 1110,  240,  238,  237,  236,  235, 1110, 1110,
-     1110, 1110, 1110, 1110, 1113, 1113, 1113, 1113, 1113, 1113,
+     1122,  357, 1655, 1663, 1664, 1122, 1122, 1122, 1122, 1122,
+     1122, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133,
+      354, 1664,  349, 1133,  348,  340, 1664, 1669, 1133, 1133,
+     1133, 1133, 1133, 1133, 1145, 1145, 1145, 1145, 1145, 1145,
+     1145, 1145, 1145,  338, 1669,  337, 1145,  332,  330, 1669,
+     1670, 1145, 1145, 1145, 1145, 1145, 1145, 1157, 1157, 1157,
+     1157, 1157, 1157, 1157, 1157, 1157,  328, 1670,  327, 1157,
+      326, 1670, 1674, 1677, 1157, 1157, 1157, 1157, 1157, 1157,
+     1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1674,
+     1677,  325, 1171, 1677, 1674,  324,  323, 1171, 1171, 1171,
 
-     1113, 1113, 1113,  234, 1389,  233, 1113,  232, 1113,  230,
-      228,  226, 1113, 1113, 1113, 1113, 1113, 1113, 1287, 1287,
-     1287, 1287, 1287, 1287, 1287, 1289, 1289, 1289, 1289, 1289,
-     1289, 1289, 1312,  225, 1113, 1118, 1118, 1118, 1118, 1118,
-     1118, 1118, 1118, 1118,  223,  221,  220, 1118,  218,  215,
-     1312, 1312,  214, 1118, 1118, 1118, 1118, 1118, 1118, 1127,
-     1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1312,  213,
-      211, 1127,  209,  208,  205,  204,  202, 1127, 1127, 1127,
-     1127, 1127, 1127, 1138, 1138, 1138, 1138, 1138, 1138, 1138,
-     1138, 1138,  201,  200,  199, 1138,  198,  197,  196,  195,
+     1171, 1171, 1171, 1173, 1173, 1173, 1173, 1173, 1173, 1173,
+     1173, 1173, 1298, 1272, 1275, 1173, 1276, 1173,  322,  320,
+     1173, 1173, 1173, 1173, 1173, 1173,  319, 1272, 1275, 1298,
+     1276, 1282, 1282, 1282, 1282, 1282, 1282, 1282, 1298, 1299,
+     1306, 1311, 1173, 1199, 1199, 1199, 1199, 1199, 1199, 1199,
+     1199, 1199, 1272, 1275,  318, 1276, 1299, 1306, 1311, 1332,
+     1199, 1201, 1201, 1201, 1201, 1201, 1201, 1201, 1201, 1299,
+      313, 1311, 1201, 1332,  310, 1695, 1306, 1201, 1201, 1201,
+     1201, 1201, 1201, 1202, 1202, 1202, 1202, 1202, 1202, 1202,
+     1202, 1202, 1695,  309,  308, 1202,  305, 1202, 1332,  298,
 
-      194, 1138, 1138, 1138, 1138, 1138, 1138, 1150, 1150, 1150,
-     1150, 1150, 1150, 1150, 1150, 1150,  193,  192,  191, 1150,
-      190,  189,  188,  187,  186, 1150, 1150, 1150, 1150, 1150,
-     1150, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162,
-      185,  183,  182, 1162,  179,  178,  177,  176,  175, 1162,
-     1162, 1162, 1162, 1162, 1162, 1176, 1176, 1176, 1176, 1176,
-     1176, 1176, 1176, 1176,  174,  173,  172, 1176,  170,  167,
-      166,  165,  164, 1176, 1176, 1176, 1176, 1176, 1176, 1178,
-     1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178,  161,  159,
-      150, 1178,  149, 1178, 1475, 1535, 1390, 1178, 1178, 1178,
+     1202, 1202, 1202, 1202, 1202, 1202, 1284, 1284, 1284, 1284,
+     1284, 1284, 1284, 1288, 1288, 1288, 1288, 1288, 1288, 1288,
+     1333, 1300, 1202, 1205, 1205, 1205, 1205, 1205, 1205, 1205,
+     1205, 1205,  297, 1312, 1333, 1205, 1470, 1205, 1300, 1307,
+     1205, 1205, 1205, 1205, 1205, 1205,  295,  294,  293, 1300,
+     1312,  291,  289, 1470,  288,  287, 1307, 1307,  285, 1333,
+      281, 1312, 1205, 1208, 1208, 1208, 1208, 1208, 1208, 1208,
+     1208, 1208, 1470,  280, 1307, 1208,  278, 1208,  275,  271,
+     1208, 1208, 1208, 1208, 1208, 1208, 1340, 1340, 1340, 1340,
+     1340, 1340, 1340, 1345, 1345, 1345, 1345, 1345, 1345, 1345,
 
-     1178, 1178, 1178, 1293, 1293, 1293, 1293, 1293, 1293, 1293,
-     1390, 1650, 1475, 1535,  148, 1546, 1304, 1316,  147, 1178,
-     1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1650,
-      146, 1475, 1535, 1546, 1304, 1316, 1390, 1427, 1204, 1206,
-     1206, 1206, 1206, 1206, 1206, 1206, 1206, 1304, 1316, 1650,
-     1206, 1427, 1546,  145,  144, 1400, 1206, 1206, 1206, 1206,
-     1206, 1206, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207,
-     1207, 1305, 1317, 1400, 1207,  142, 1207, 1427,  140,  139,
-     1207, 1207, 1207, 1207, 1207, 1207,  137, 1400,  135, 1305,
-     1317, 1345, 1345, 1345, 1345, 1345, 1345, 1345,  133,  132,
+      270, 1698, 1208, 1211, 1211, 1211, 1211, 1211, 1211, 1211,
+     1211, 1211,  267,  266,  264, 1211,  259, 1211, 1698,  256,
+     1211, 1211, 1211, 1211, 1211, 1211, 1347, 1347, 1347, 1347,
+     1347, 1347, 1347, 1353, 1353, 1353, 1353, 1353, 1353, 1353,
+      254, 1705, 1211, 1214, 1214, 1214, 1214, 1214, 1214, 1214,
+     1214, 1214,  253,  251,  248, 1214,  244, 1214, 1705,  240,
+     1214, 1214, 1214, 1214, 1214, 1214, 1355, 1355, 1355, 1355,
+     1355, 1355, 1355, 1361, 1361, 1361, 1361, 1361, 1361, 1361,
+     1380, 1390, 1214, 1219, 1219, 1219, 1219, 1219, 1219, 1219,
+     1219, 1219,  238,  236, 1380, 1219,  235,  233, 1390, 1679,
 
-     1305, 1317, 1207, 1210, 1210, 1210, 1210, 1210, 1210, 1210,
-     1210, 1210,  131,  130,  128, 1210,  127, 1210,  126,  125,
-      124, 1210, 1210, 1210, 1210, 1210, 1210, 1350, 1350, 1350,
-     1350, 1350, 1350, 1350, 1352, 1352, 1352, 1352, 1352, 1352,
-     1352,  123,  121, 1210, 1213, 1213, 1213, 1213, 1213, 1213,
-     1213, 1213, 1213,  119,  118,  117, 1213,  116, 1213,  115,
-      114,  113, 1213, 1213, 1213, 1213, 1213, 1213, 1358, 1358,
-     1358, 1358, 1358, 1358, 1358, 1360, 1360, 1360, 1360, 1360,
-     1360, 1360,  112,  111, 1213, 1216, 1216, 1216, 1216, 1216,
-     1216, 1216, 1216, 1216,  109,  108,  101, 1216,  100, 1216,
+     1219, 1219, 1219, 1219, 1219, 1219, 1226, 1226, 1226, 1226,
+     1226, 1226, 1226, 1226, 1226, 1390, 1679,  232, 1226, 1380,
+      231, 1684, 1693, 1226, 1226, 1226, 1226, 1226, 1226, 1236,
+     1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1684, 1693,
+     1679, 1236,  230, 1684, 1693, 1696, 1236, 1236, 1236, 1236,
+     1236, 1236, 1249, 1249, 1249, 1249, 1249, 1249, 1249, 1249,
+     1249,  229, 1696,  228, 1249,  227,  225, 1701, 1702, 1249,
+     1249, 1249, 1249, 1249, 1249, 1263, 1263, 1263, 1263, 1263,
+     1263, 1263, 1263, 1263, 1701, 1702, 1696, 1263,  223,  221,
+     1702,  220, 1263, 1263, 1263, 1263, 1263, 1263, 1277, 1277,
 
-       99,   97,   96, 1216, 1216, 1216, 1216, 1216, 1216, 1366,
-     1366, 1366, 1366, 1366, 1366, 1366, 1368, 1368, 1368, 1368,
-     1368, 1368, 1368,   93,   92, 1216, 1219, 1219, 1219, 1219,
-     1219, 1219, 1219, 1219, 1219,   91,   90,   89, 1219,   88,
-     1219,   87,   86,   85, 1219, 1219, 1219, 1219, 1219, 1219,
-     1374, 1374, 1374, 1374, 1374, 1374, 1374, 1376, 1376, 1376,
-     1376, 1376, 1376, 1376, 1428, 1539, 1219, 1224, 1224, 1224,
-     1224, 1224, 1224, 1224, 1224, 1224,   84,   82, 1428, 1224,
-       81,   80,   79, 1539,   78, 1224, 1224, 1224, 1224, 1224,
-     1224, 1231, 1231, 1231, 1231, 1231, 1231, 1231, 1231, 1231,
+     1277, 1277, 1277, 1277, 1277, 1277, 1277,  218, 1701,  216,
+     1277,  215,  213, 1707, 1704, 1277, 1277, 1277, 1277, 1277,
+     1277, 1289, 1289, 1289, 1289, 1289, 1289, 1289, 1289, 1289,
+     1707, 1704,  210, 1289, 1704,  209, 1709, 1708, 1289, 1289,
+     1289, 1289, 1289, 1289, 1313, 1313, 1313, 1313, 1313, 1313,
+     1313, 1313, 1313, 1709, 1708,  208, 1313,  206, 1313, 1708,
+      204, 1313, 1313, 1313, 1313, 1313, 1313, 1363, 1363, 1363,
+     1363, 1363, 1363, 1363, 1369, 1369, 1369, 1369, 1369, 1369,
+     1369, 1381, 1484, 1313, 1317, 1317, 1317, 1317, 1317, 1317,
+     1317, 1317, 1317,  203,  200, 1381, 1317,  199,  197, 1484,
 
-       77, 1539,   76, 1231, 1428,   75,   74,   73,   72, 1231,
-     1231, 1231, 1231, 1231, 1231, 1241, 1241, 1241, 1241, 1241,
-     1241, 1241, 1241, 1241,   71,   70,   69, 1241,   67,   66,
-       65,   51,   43, 1241, 1241, 1241, 1241, 1241, 1241, 1254,
-     1254, 1254, 1254, 1254, 1254, 1254, 1254, 1254,   42,   40,
-       18, 1254,   11,    8,    3,    0,    0, 1254, 1254, 1254,
-     1254, 1254, 1254, 1268, 1268, 1268, 1268, 1268, 1268, 1268,
-     1268, 1268,    0,    0,    0, 1268,    0,    0,    0,    0,
-        0, 1268, 1268, 1268, 1268, 1268, 1268, 1282, 1282, 1282,
-     1282, 1282, 1282, 1282, 1282, 1282,    0,    0,    0, 1282,
+     1714, 1317, 1317, 1317, 1317, 1317, 1317, 1320, 1320, 1320,
+     1320, 1320, 1320, 1320, 1320, 1320, 1484, 1714,  196, 1320,
+     1381,  195, 1716, 1719, 1320, 1320, 1320, 1320, 1320, 1320,
+     1323, 1323, 1323, 1323, 1323, 1323, 1323, 1323, 1323, 1716,
+     1719,  194, 1323,  193,  192, 1720, 1721, 1323, 1323, 1323,
+     1323, 1323, 1323, 1326, 1326, 1326, 1326, 1326, 1326, 1326,
+     1326, 1326, 1720, 1721,  191, 1326,  190,  189, 1722,  188,
+     1326, 1326, 1326, 1326, 1326, 1326, 1329, 1329, 1329, 1329,
+     1329, 1329, 1329, 1329, 1329, 1722,  187,  186, 1329,  185,
+      184,  183,  182, 1329, 1329, 1329, 1329, 1329, 1329, 1334,
 
-        0,    0,    0,    0,    0, 1282, 1282, 1282, 1282, 1282,
-     1282, 1294, 1294, 1294, 1294, 1294, 1294, 1294, 1294, 1294,
-        0,    0,    0, 1294,    0,    0,    0,    0,    0, 1294,
-     1294, 1294, 1294, 1294, 1294, 1318, 1318, 1318, 1318, 1318,
-     1318, 1318, 1318, 1318,    0,    0,    0, 1318,    0, 1318,
-        0,    0,    0, 1318, 1318, 1318, 1318, 1318, 1318, 1383,
-     1383, 1383, 1383, 1383, 1383, 1383, 1421, 1421, 1421, 1421,
-     1421, 1421, 1421, 1435, 1540, 1318, 1322, 1322, 1322, 1322,
-     1322, 1322, 1322, 1322, 1322,    0,    0, 1435, 1322,    0,
-        0,    0, 1540,    0, 1322, 1322, 1322, 1322, 1322, 1322,
+     1334, 1334, 1334, 1334, 1334, 1334, 1334, 1334,  181,  180,
+      178, 1334,  177,  174,  173,  172, 1334, 1334, 1334, 1334,
+     1334, 1334, 1371, 1371, 1371, 1371, 1371, 1371, 1371, 1378,
+     1378, 1378, 1378, 1378, 1378, 1378, 1384, 1385, 1395, 1400,
+     1402, 1403, 1406, 1416, 1416, 1416, 1416, 1416, 1416, 1416,
+     1384, 1385, 1422,  171,  170, 1395, 1400, 1402, 1403, 1406,
+      169,  168,  167,  165,  162,  161, 1422, 1400, 1406, 1395,
+     1403, 1402, 1423, 1400, 1430, 1384, 1385, 1386, 1386, 1386,
+     1386, 1386, 1386, 1386, 1386, 1386, 1423,  160, 1430, 1386,
+      159, 1422,  156,  154, 1386, 1386, 1386, 1386, 1386, 1386,
 
-     1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325, 1325,    0,
-     1540,    0, 1325, 1435,    0,    0,    0,    0, 1325, 1325,
-     1325, 1325, 1325, 1325, 1328, 1328, 1328, 1328, 1328, 1328,
-     1328, 1328, 1328,    0,    0,    0, 1328,    0,    0,    0,
-        0,    0, 1328, 1328, 1328, 1328, 1328, 1328, 1331, 1331,
-     1331, 1331, 1331, 1331, 1331, 1331, 1331,    0,    0,    0,
-     1331,    0,    0,    0,    0,    0, 1331, 1331, 1331, 1331,
-     1331, 1331, 1334, 1334, 1334, 1334, 1334, 1334, 1334, 1334,
-     1334,    0,    0,    0, 1334,    0,    0,    0,    0,    0,
-     1334, 1334, 1334, 1334, 1334, 1334, 1339, 1339, 1339, 1339,
+     1407, 1407, 1407, 1407, 1407, 1407, 1407, 1407, 1407,  145,
+      144, 1423, 1407, 1430,  143,  142, 1431, 1407, 1407, 1407,
+     1407, 1407, 1407, 1428, 1428, 1428, 1428, 1428, 1428, 1428,
+     1431, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1439, 1440,
+     1446, 1446, 1446, 1446, 1446, 1446, 1446, 1448, 1449,  141,
+      140,  139, 1439, 1440,  137, 1431, 1457, 1458,  135,  134,
+      132, 1448, 1449, 1455, 1455, 1455, 1455, 1455, 1455, 1455,
+     1457, 1458,  130,  128,  127,  126,  125, 1439, 1440, 1463,
+     1463, 1463, 1463, 1463, 1463, 1463, 1448, 1449, 1465, 1465,
+     1465, 1465, 1465, 1465, 1465, 1457, 1458, 1471, 1475, 1472,
 
-     1339, 1339, 1339, 1339, 1339,    0,    0,    0, 1339,    0,
-        0,    0, 1407,    0, 1339, 1339, 1339, 1339, 1339, 1339,
-     1391, 1391, 1391, 1391, 1391, 1391, 1391, 1391, 1391, 1405,
-     1407, 1408, 1391,    0, 1436,    0,    0,    0, 1391, 1391,
-     1391, 1391, 1391, 1391, 1407, 1490,    0, 1405, 1436, 1408,
-     1433, 1433, 1433, 1433, 1433, 1433, 1433,    0, 1405,    0,
-        0, 1408, 1444, 1490, 1405, 1412, 1412, 1412, 1412, 1412,
-     1412, 1412, 1412, 1412, 1436, 1490, 1444, 1412,    0,    0,
-        0,    0, 1445, 1412, 1412, 1412, 1412, 1412, 1412, 1442,
-     1442, 1442, 1442, 1442, 1442, 1442, 1445, 1453, 1454,    0,
+     1480, 1476, 1477, 1478, 1479, 1482,  123,  122, 1485,  121,
+      120,  119,  118,  116, 1471, 1475, 1472, 1480, 1476, 1477,
+     1478, 1479, 1482, 1471, 1472, 1485, 1475, 1476, 1477, 1478,
+     1479, 1480, 1495, 1482, 1496,  114,  113, 1485, 1501, 1501,
+     1501, 1501, 1501, 1501, 1501,  112, 1495,  111, 1496, 1505,
+     1505, 1505, 1505, 1505, 1505, 1505, 1509, 1509, 1509, 1509,
+     1509, 1509, 1509, 1513, 1513, 1513, 1513, 1513, 1513, 1513,
+      110, 1495,  109, 1496, 1517, 1517, 1517, 1517, 1517, 1517,
+     1517, 1522, 1522, 1522, 1522, 1522, 1522, 1522, 1524, 1525,
+     1530, 1533, 1540, 1544, 1534, 1535, 1537, 1538, 1572, 1541,
 
-        0,    0, 1444, 1451, 1451, 1451, 1451, 1451, 1451, 1451,
-     1462, 1453, 1454, 1460, 1460, 1460, 1460, 1460, 1460, 1460,
-     1463,    0, 1445,    0, 1462, 1468, 1468, 1468, 1468, 1468,
-     1468, 1468,    0, 1480, 1463, 1485, 1481, 1453, 1454, 1470,
-     1470, 1470, 1470, 1470, 1470, 1470, 1482, 1483, 1484,    0,
-     1462, 1480, 1487, 1485, 1481, 1500,    0, 1501, 1542, 1547,
-     1463, 1603, 1480, 1481, 1482, 1483, 1484, 1485,    0, 1500,
-     1487, 1501,    0, 1482, 1483, 1484, 1542, 1547,    0, 1603,
-        0, 1487, 1506, 1506, 1506, 1506, 1506, 1506, 1506,    0,
-        0,    0,    0, 1603, 1542, 1500, 1547, 1501, 1510, 1510,
+      108,  107, 1524, 1525, 1542, 1579, 1598, 1530, 1533, 1540,
+     1544, 1534, 1535, 1537, 1538, 1572, 1541, 1533, 1540, 1544,
+      106, 1542, 1579, 1598,  104,  103, 1530, 1524, 1525, 1534,
+     1535, 1537, 1572,   96, 1538, 1541,   95, 1598,   94, 1579,
+     1542, 1546, 1546, 1546, 1546, 1546, 1546, 1546, 1549, 1549,
+     1549, 1549, 1549, 1549, 1549, 1553, 1553, 1553, 1553, 1553,
+     1553, 1553, 1557, 1557, 1557, 1557, 1557, 1557, 1557, 1561,
+     1561, 1561, 1561, 1561, 1561, 1561, 1565, 1565, 1565, 1565,
+     1565, 1565, 1565, 1568, 1568, 1568, 1568, 1568, 1568, 1568,
+     1576,   92, 1577, 1578, 1581, 1583, 1585, 1585, 1585, 1585,
 
-     1510, 1510, 1510, 1510, 1510, 1514, 1514, 1514, 1514, 1514,
-     1514, 1514, 1518, 1518, 1518, 1518, 1518, 1518, 1518, 1522,
-     1522, 1522, 1522, 1522, 1522, 1522, 1527, 1527, 1527, 1527,
-     1527, 1527, 1527, 1529, 1530, 1538, 1545, 1549, 1551, 1551,
-     1551, 1551, 1551, 1551, 1551,    0,    0, 1529, 1530,    0,
-        0,    0,    0, 1538, 1545, 1549,    0,    0,    0,    0,
-        0,    0, 1538, 1545, 1549, 1554, 1554, 1554, 1554, 1554,
-     1554, 1554,    0, 1529, 1530, 1558, 1558, 1558, 1558, 1558,
-     1558, 1558, 1562, 1562, 1562, 1562, 1562, 1562, 1562, 1566,
-     1566, 1566, 1566, 1566, 1566, 1566, 1570, 1570, 1570, 1570,
+     1585, 1585, 1585,   91, 1596, 1599, 1597, 1576, 1576, 1577,
+     1578, 1581, 1583, 1594, 1594, 1594, 1594, 1594, 1594, 1594,
+     1581, 1596, 1599, 1597, 1601, 1576, 1604, 1605, 1577, 1578,
+     1606, 1583, 1597, 1616, 1619, 1620, 1599, 1621,   88, 1622,
+     1596, 1601, 1624, 1604, 1605,   87,   86, 1606, 1632, 1625,
+     1616, 1619, 1620, 1605, 1621, 1601, 1622,   85, 1634, 1624,
+     1643, 1606, 1604, 1620, 1636, 1632, 1625, 1621, 1637, 1616,
+     1638, 1639, 1619, 1622, 1632, 1634, 1634, 1643, 1624, 1625,
+       84, 1636, 1641, 1645, 1650, 1637, 1649, 1638, 1639, 1652,
+     1651, 1643, 1654, 1634, 1634, 1656,   83, 1636, 1636, 1641,
 
-     1570, 1570, 1570, 1573, 1573, 1573, 1573, 1573, 1573, 1573,
-     1577, 1581,    0, 1582, 1583, 1586, 1588, 1584, 1590, 1590,
-     1590, 1590, 1590, 1590, 1590, 1601, 1609,    0, 1577, 1581,
-     1581, 1582, 1583, 1586, 1588, 1584,    0,    0,    0,    0,
-        0,    0, 1586, 1601, 1609, 1577, 1602, 1581, 1604, 1606,
-     1582, 1583, 1584, 1588, 1599, 1599, 1599, 1599, 1599, 1599,
-     1599, 1610, 1601, 1609, 1602, 1611, 1604, 1606, 1621, 1625,
-        0, 1626, 1627, 1602, 1629, 1630, 1637, 1639,    0, 1610,
-     1604, 1606, 1641, 1611,    0,    0, 1621, 1625, 1610, 1626,
-     1627, 1642, 1629, 1630, 1637, 1639, 1639, 1611, 1625,    0,
+     1645, 1650, 1637, 1649, 1638, 1639, 1652, 1651, 1653, 1654,
+     1650, 1651, 1656,   82, 1657, 1658, 1641, 1660, 1661,   81,
+     1645, 1662, 1649, 1651, 1651, 1653, 1654, 1652, 1665, 1667,
+     1656, 1657, 1658, 1658, 1660, 1661, 1653,   80, 1662, 1666,
+     1668,   79, 1671, 1675, 1673, 1665, 1667, 1676, 1657, 1661,
+     1658,   77, 1680, 1660, 1665,   76, 1666, 1668, 1662, 1671,
+     1675, 1673, 1681, 1667, 1676, 1682,   75, 1685, 1666, 1680,
+     1683, 1686, 1668, 1671, 1673, 1675, 1687,   74,   73, 1681,
+     1688, 1676, 1682, 1680, 1685,   72,   71, 1683, 1686,   70,
+     1690, 1691, 1692, 1687, 1681, 1681, 1694, 1688, 1683, 1697,
 
-     1641, 1643, 1626, 1637, 1644, 1621, 1630, 1627,    0, 1642,
-     1646, 1629, 1648, 1639, 1639, 1654, 1641, 1641,    0, 1643,
-     1655,    0, 1644, 1665, 1656, 1658, 1642,    0, 1646,    0,
-     1648, 1659, 1661, 1654,    0, 1662, 1643, 1663, 1655, 1644,
-        0, 1665, 1656, 1658, 1648, 1646, 1656, 1655,    0, 1659,
-     1661, 1666, 1654, 1662, 1658, 1663, 1663, 1667, 1656, 1656,
-     1665, 1670, 1671, 1672, 1673,    0, 1659, 1676, 1661, 1666,
-     1662, 1678, 1680, 1663,    0, 1667, 1681,    0, 1685, 1670,
-     1671, 1672, 1673, 1666,    0, 1676, 1686,    0, 1670, 1678,
-     1680, 1690, 1671,    0, 1681, 1667, 1685, 1673, 1672, 1676,
+     1699, 1685, 1686, 1682, 1700,   69, 1688, 1690, 1691, 1692,
+     1703, 1706, 1687, 1694, 1710, 1711, 1697, 1699, 1713, 1691,
+     1690, 1700, 1694, 1715, 1712, 1717,   68, 1703, 1706, 1692,
+       67, 1710, 1711, 1697,   66, 1713, 1699,   65,   64, 1700,
+     1715, 1712, 1717,   62, 1703,   61,   60, 1706,   47, 1710,
+     1712, 1711,   40,   39, 1718,   37, 1713, 1718, 1718, 1715,
+       15, 1717,   13,   10,    7,    3,    0,    0,    0,    0,
+        0, 1718, 1724,    0, 1724, 1725,    0, 1725, 1725, 1725,
+     1725, 1725, 1725, 1726,    0, 1726, 1727, 1727, 1727, 1728,
+     1728, 1728, 1729, 1729, 1729, 1730, 1730, 1730, 1731, 1731,
 
-     1688,    0, 1678, 1691, 1686, 1680, 1692, 1693,    0, 1690,
-     1685, 1681, 1696, 1695, 1697, 1699,    0,    0, 1688, 1686,
-     1686, 1691, 1702,    0, 1692, 1693, 1690, 1704, 1708, 1688,
-     1696, 1695, 1697, 1699, 1693, 1691, 1705, 1711, 1716,    0,
-     1702, 1696, 1699, 1692, 1695, 1704, 1708, 1715, 1720, 1717,
-     1722,    0, 1697,    0, 1705, 1711, 1716, 1702,    0,    0,
-        0,    0,    0, 1708, 1704, 1715, 1720, 1717, 1722,    0,
-        0,    0, 1705,    0, 1711, 1716, 1717, 1723,    0,    0,
-     1723, 1723,    0, 1715,    0, 1720,    0, 1722,    0,    0,
-        0,    0,    0,    0,    0, 1723, 1729,    0,    0,    0,
+     1731, 1732, 1732, 1732, 1733, 1733, 1733, 1734, 1734, 1734,
+     1735, 1735, 1735, 1736,    0, 1736, 1737, 1737, 1737, 1738,
+     1738, 1738, 1739, 1739, 1739, 1740, 1740, 1740, 1741,    0,
+     1741, 1742, 1742, 1742, 1743, 1743,    0,    0, 1743, 1744,
+     1744, 1744, 1745, 1745, 1745, 1746, 1746, 1746, 1747, 1747,
+     1747, 1748, 1748, 1748, 1749, 1749, 1749, 1750, 1750, 1750,
+     1751, 1751, 1751, 1752, 1752, 1752, 1753, 1753,    0,    0,
+     1753, 1754, 1754, 1754, 1755, 1755, 1755, 1756,    0, 1756,
+     1757, 1757, 1757, 1758, 1758, 1758, 1759,    0, 1759, 1760,
+     1760, 1760, 1761, 1761, 1761, 1762, 1762, 1762, 1763, 1763,
 
-        0, 1729, 1729, 1729, 1730,    0, 1730, 1730, 1730, 1730,
-     1730, 1730, 1730, 1731,    0, 1731, 1732, 1732, 1732, 1733,
-     1733, 1733, 1734, 1734, 1734, 1735, 1735, 1735, 1736, 1736,
-     1736, 1737, 1737, 1737, 1738, 1738, 1738, 1739, 1739, 1739,
-     1740, 1740, 1740, 1741,    0, 1741, 1742, 1742, 1742, 1743,
-     1743, 1743, 1744, 1744, 1744, 1745, 1745, 1745, 1746,    0,
-     1746, 1747, 1747, 1747, 1748, 1748,    0,    0, 1748, 1749,
-     1749, 1749, 1750, 1750, 1750, 1751, 1751, 1751, 1752, 1752,
-     1752, 1753, 1753, 1753, 1754, 1754, 1754, 1755, 1755, 1755,
-     1756, 1756, 1756, 1757, 1757, 1757, 1758, 1758,    0,    0,
+     1763, 1764, 1764, 1764, 1765,    0, 1765, 1766,    0, 1766,
+     1767, 1767, 1767, 1768, 1768, 1768, 1769,    0, 1769, 1770,
+     1770,    0,    0, 1770, 1771, 1771,    0,    0, 1771, 1772,
+     1772, 1772, 1773, 1773, 1773, 1774, 1774,    0, 1774, 1775,
+     1775, 1775, 1776, 1776, 1776, 1777, 1777, 1777, 1778, 1778,
+     1778, 1779, 1779, 1779, 1780, 1780, 1780, 1781, 1781, 1781,
+     1782, 1782,    0,    0, 1782, 1783, 1783, 1783, 1784, 1784,
+     1784, 1785, 1785,    0, 1785, 1786, 1786,    0,    0, 1786,
+     1787, 1787,    0, 1787, 1788, 1788, 1789, 1789,    0,    0,
+     1789, 1790, 1790, 1790, 1791, 1791, 1791, 1792, 1792,    0,
 
-     1758, 1759, 1759, 1759, 1760, 1760, 1760, 1761,    0, 1761,
-     1762, 1762, 1762, 1763, 1763, 1763, 1764,    0, 1764, 1765,
-     1765, 1765, 1766, 1766, 1766, 1767, 1767, 1767, 1768, 1768,
-     1768, 1769, 1769, 1769, 1770,    0, 1770, 1771,    0, 1771,
-     1772, 1772, 1772, 1773, 1773, 1773, 1774,    0, 1774, 1775,
-     1775,    0,    0, 1775, 1776, 1776,    0,    0, 1776, 1777,
-     1777, 1777, 1778, 1778, 1778, 1779, 1779,    0, 1779, 1780,
-     1780, 1780, 1781, 1781, 1781, 1782, 1782, 1782, 1783, 1783,
-     1783, 1784, 1784, 1784, 1785, 1785, 1785, 1786, 1786, 1786,
-     1787, 1787,    0,    0, 1787, 1788, 1788, 1788, 1789, 1789,
+     1792, 1793,    0, 1793, 1794,    0, 1794, 1795, 1795, 1795,
+     1796, 1796, 1796, 1797,    0, 1797, 1798, 1798, 1798, 1799,
+     1799, 1799, 1800, 1800, 1800, 1801, 1801, 1801, 1802, 1802,
+     1802, 1803, 1803, 1803, 1804,    0, 1804, 1805,    0, 1805,
+     1806, 1806, 1806, 1807, 1807, 1807, 1808,    0, 1808, 1809,
+        0, 1809, 1810,    0, 1810, 1811, 1811, 1811, 1812, 1812,
+     1812, 1813,    0, 1813, 1814,    0,    0, 1814, 1815, 1815,
+        0, 1815, 1816, 1816,    0,    0, 1816, 1817, 1817,    0,
+     1817, 1818, 1818, 1819, 1819,    0,    0, 1819, 1820, 1820,
+     1820, 1821, 1821, 1821, 1822, 1822,    0, 1822, 1823, 1823,
 
-     1789, 1790, 1790,    0, 1790, 1791, 1791,    0,    0, 1791,
-     1792, 1792,    0, 1792, 1793, 1793, 1794, 1794,    0,    0,
-     1794, 1795, 1795, 1795, 1796, 1796, 1796, 1797, 1797,    0,
-     1797, 1798,    0, 1798, 1799,    0, 1799, 1800, 1800, 1800,
-     1801, 1801, 1801, 1802,    0, 1802, 1803, 1803, 1803, 1804,
-     1804, 1804, 1805, 1805, 1805, 1806, 1806, 1806, 1807, 1807,
-     1807, 1808, 1808, 1808, 1809,    0, 1809, 1810,    0, 1810,
-     1811, 1811, 1811, 1812, 1812, 1812, 1813,    0, 1813, 1814,
-        0, 1814, 1815,    0, 1815, 1816, 1816, 1816, 1817, 1817,
-     1817, 1818,    0, 1818, 1819,    0,    0, 1819, 1820, 1820,
+     1823,    0, 1823, 1823, 1824, 1824, 1824, 1825, 1825, 1825,
+     1826, 1826, 1826, 1827, 1827, 1827, 1828, 1828, 1828, 1829,
+     1829, 1829, 1830, 1830, 1830, 1831, 1831, 1831, 1832, 1832,
+        0,    0, 1832, 1833, 1833, 1833, 1834, 1834, 1834, 1835,
+     1835,    0, 1835, 1836, 1836,    0,    0, 1836, 1837, 1837,
+        0, 1837, 1838, 1838, 1839, 1839,    0,    0, 1839, 1840,
+     1840, 1840, 1841, 1841, 1841, 1842, 1842,    0, 1842, 1843,
+        0,    0, 1843, 1844, 1844,    0, 1844, 1845, 1845,    0,
+        0, 1845, 1846, 1846,    0, 1846, 1847, 1847, 1848, 1848,
+        0,    0, 1848, 1849, 1849, 1849, 1850, 1850, 1850, 1851,
 
-        0, 1820, 1821, 1821,    0,    0, 1821, 1822, 1822,    0,
-     1822, 1823, 1823, 1824, 1824,    0,    0, 1824, 1825, 1825,
-     1825, 1826, 1826, 1826, 1827, 1827,    0, 1827, 1828, 1828,
-     1828,    0, 1828, 1828, 1829, 1829, 1829, 1830, 1830, 1830,
-     1831, 1831, 1831, 1832, 1832, 1832, 1833, 1833, 1833, 1834,
-     1834, 1834, 1835, 1835, 1835, 1836, 1836, 1836, 1837, 1837,
-        0,    0, 1837, 1838, 1838, 1838, 1839, 1839, 1839, 1840,
-     1840,    0, 1840, 1841, 1841,    0,    0, 1841, 1842, 1842,
-        0, 1842, 1843, 1843, 1844, 1844,    0,    0, 1844, 1845,
-     1845, 1845, 1846, 1846, 1846, 1847, 1847,    0, 1847, 1848,
+     1851,    0, 1851, 1852,    0, 1852, 1853,    0, 1853, 1854,
+        0, 1854, 1855, 1855, 1855, 1856, 1856, 1856, 1857,    0,
+     1857, 1858, 1858, 1858,    0, 1858, 1858, 1859, 1859, 1859,
+     1860, 1860, 1860, 1861, 1861, 1861, 1862, 1862, 1862, 1863,
+     1863, 1863, 1864, 1864, 1864, 1865, 1865, 1865, 1866,    0,
+     1866, 1867,    0, 1867, 1868, 1868, 1868, 1869, 1869, 1869,
+     1870,    0, 1870, 1871,    0, 1871, 1872,    0, 1872, 1873,
+     1873, 1873, 1874, 1874, 1874, 1875,    0, 1875, 1876,    0,
+     1876, 1877,    0, 1877, 1878,    0, 1878, 1879, 1879, 1879,
+     1880, 1880, 1880, 1881,    0, 1881, 1882,    0, 1882, 1883,
 
-        0,    0, 1848, 1849, 1849,    0, 1849, 1850, 1850,    0,
-        0, 1850, 1851, 1851,    0, 1851, 1852, 1852, 1853, 1853,
-        0,    0, 1853, 1854, 1854, 1854, 1855, 1855, 1855, 1856,
-     1856,    0, 1856, 1857,    0, 1857, 1858,    0, 1858, 1859,
-        0, 1859, 1860, 1860, 1860, 1861, 1861, 1861, 1862,    0,
-     1862, 1863, 1863, 1863,    0, 1863, 1863, 1864, 1864, 1864,
-     1865, 1865, 1865, 1866, 1866, 1866, 1867, 1867, 1867, 1868,
-     1868, 1868, 1869, 1869, 1869, 1870, 1870, 1870, 1871,    0,
-     1871, 1872,    0, 1872, 1873, 1873, 1873, 1874, 1874, 1874,
-     1875,    0, 1875, 1876,    0, 1876, 1877,    0, 1877, 1878,
+        0,    0, 1883, 1884, 1884,    0, 1884, 1885, 1885,    0,
+        0, 1885, 1886, 1886,    0, 1886, 1887, 1887, 1888, 1888,
+        0,    0, 1888, 1889, 1889, 1889, 1890, 1890, 1890, 1891,
+     1891,    0, 1891, 1892, 1892, 1892,    0, 1892, 1892, 1893,
+     1893, 1893, 1894, 1894, 1894, 1895, 1895, 1895, 1896, 1896,
+     1896, 1897, 1897, 1897, 1898, 1898, 1898, 1899, 1899, 1899,
+     1900, 1900, 1900, 1901, 1901,    0,    0, 1901, 1902, 1902,
+     1902, 1903, 1903, 1903, 1904, 1904,    0, 1904, 1905, 1905,
+        0,    0, 1905, 1906, 1906,    0, 1906, 1907, 1907, 1908,
+     1908,    0,    0, 1908, 1909, 1909, 1909, 1910, 1910, 1910,
 
-     1878, 1878, 1879, 1879, 1879, 1880,    0, 1880, 1881,    0,
-     1881, 1882,    0, 1882, 1883,    0, 1883, 1884, 1884, 1884,
-     1885, 1885, 1885, 1886,    0, 1886, 1887,    0, 1887, 1888,
-        0,    0, 1888, 1889, 1889,    0, 1889, 1890, 1890,    0,
-        0, 1890, 1891, 1891,    0, 1891, 1892, 1892, 1893, 1893,
-        0,    0, 1893, 1894, 1894, 1894, 1895, 1895, 1895, 1896,
-     1896,    0, 1896, 1897, 1897, 1897,    0, 1897, 1897, 1898,
-     1898, 1898, 1899, 1899, 1899, 1900, 1900, 1900, 1901, 1901,
-     1901, 1902, 1902, 1902, 1903, 1903, 1903, 1904, 1904, 1904,
-     1905, 1905, 1905, 1906, 1906,    0,    0, 1906, 1907, 1907,
+     1911, 1911,    0, 1911, 1912,    0,    0, 1912, 1913, 1913,
+        0, 1913, 1914, 1914,    0,    0, 1914, 1915, 1915,    0,
+     1915, 1916, 1916, 1917, 1917,    0,    0, 1917, 1918, 1918,
+     1918, 1919, 1919, 1919, 1920, 1920,    0, 1920, 1921,    0,
+     1921, 1922,    0,    0, 1922, 1923, 1923,    0, 1923, 1924,
+     1924,    0,    0, 1924, 1925, 1925,    0, 1925, 1926, 1926,
+     1927, 1927,    0,    0, 1927, 1928, 1928, 1928, 1929, 1929,
+     1929, 1930, 1930,    0, 1930, 1931,    0, 1931, 1932,    0,
+     1932, 1933,    0, 1933, 1934, 1934, 1934, 1935, 1935, 1935,
+     1936,    0, 1936, 1937, 1937, 1937,    0, 1937, 1937, 1938,
 
-     1907, 1908, 1908, 1908, 1909, 1909,    0, 1909, 1910, 1910,
-        0,    0, 1910, 1911, 1911,    0, 1911, 1912, 1912, 1913,
-     1913,    0,    0, 1913, 1914, 1914, 1914, 1915, 1915, 1915,
-     1916, 1916,    0, 1916, 1917,    0,    0, 1917, 1918, 1918,
-        0, 1918, 1919, 1919,    0,    0, 1919, 1920, 1920,    0,
-     1920, 1921, 1921, 1922, 1922,    0,    0, 1922, 1923, 1923,
-     1923, 1924, 1924, 1924, 1925, 1925,    0, 1925, 1926,    0,
-     1926, 1927,    0,    0, 1927, 1928, 1928,    0, 1928, 1929,
-     1929,    0,    0, 1929, 1930, 1930,    0, 1930, 1931, 1931,
-     1932, 1932,    0,    0, 1932, 1933, 1933, 1933, 1934, 1934,
+     1938, 1938, 1939, 1939, 1939, 1940, 1940, 1940, 1941, 1941,
+     1941, 1942, 1942, 1942, 1943, 1943, 1943, 1944, 1944, 1944,
+     1945, 1945, 1945, 1946, 1946, 1946, 1947, 1947, 1947, 1948,
+        0, 1948, 1949,    0, 1949, 1950, 1950, 1950, 1951, 1951,
+     1951, 1952, 1952, 1952, 1953,    0, 1953, 1954,    0, 1954,
+     1955,    0, 1955, 1956, 1956, 1956, 1957, 1957, 1957, 1958,
+     1958, 1958, 1959,    0, 1959, 1960,    0, 1960, 1961,    0,
+     1961, 1962,    0, 1962, 1963, 1963, 1963, 1964, 1964, 1964,
+     1965, 1965, 1965, 1966,    0, 1966, 1967,    0, 1967, 1968,
+        0, 1968, 1969,    0, 1969, 1970, 1970, 1970, 1971, 1971,
 
-     1934, 1935, 1935,    0, 1935, 1936,    0, 1936, 1937,    0,
-     1937, 1938,    0, 1938, 1939, 1939, 1939, 1940, 1940, 1940,
-     1941,    0, 1941, 1942, 1942, 1942,    0, 1942, 1942, 1943,
-     1943, 1943, 1944, 1944, 1944, 1945, 1945, 1945, 1946, 1946,
-     1946, 1947, 1947, 1947, 1948, 1948, 1948, 1949, 1949, 1949,
-     1950, 1950, 1950, 1951, 1951, 1951, 1952, 1952, 1952, 1953,
-        0, 1953, 1954,    0, 1954, 1955, 1955, 1955, 1956, 1956,
-     1956, 1957, 1957, 1957, 1958,    0, 1958, 1959,    0, 1959,
-     1960,    0, 1960, 1961, 1961, 1961, 1962, 1962, 1962, 1963,
-     1963, 1963, 1964,    0, 1964, 1965,    0, 1965, 1966,    0,
+     1971, 1972, 1972, 1972, 1973,    0, 1973, 1974,    0, 1974,
+     1975,    0,    0, 1975, 1976, 1976,    0, 1976, 1977, 1977,
+        0,    0, 1977, 1978, 1978,    0, 1978, 1979, 1979, 1980,
+     1980,    0,    0, 1980, 1981, 1981, 1981, 1982, 1982, 1982,
+     1983, 1983,    0, 1983, 1984, 1984, 1984,    0, 1984, 1984,
+     1985, 1985, 1985, 1986, 1986, 1986, 1987, 1987, 1987, 1988,
+     1988, 1988, 1989, 1989, 1989, 1990, 1990, 1990, 1991, 1991,
+     1991, 1992, 1992, 1992, 1993,    0, 1993, 1994, 1994, 1994,
+     1995, 1995,    0,    0, 1995, 1996, 1996, 1996, 1997, 1997,
+     1997, 1998, 1998,    0, 1998, 1999, 1999,    0,    0, 1999,
 
-     1966, 1967,    0, 1967, 1968, 1968, 1968, 1969, 1969, 1969,
-     1970, 1970, 1970, 1971,    0, 1971, 1972,    0, 1972, 1973,
-        0, 1973, 1974,    0, 1974, 1975, 1975, 1975, 1976, 1976,
-     1976, 1977, 1977, 1977, 1978,    0, 1978, 1979,    0, 1979,
-     1980,    0,    0, 1980, 1981, 1981,    0, 1981, 1982, 1982,
-        0,    0, 1982, 1983, 1983,    0, 1983, 1984, 1984, 1985,
-     1985,    0,    0, 1985, 1986, 1986, 1986, 1987, 1987, 1987,
-     1988, 1988,    0, 1988, 1989, 1989, 1989,    0, 1989, 1989,
-     1990, 1990, 1990, 1991, 1991, 1991, 1992, 1992, 1992, 1993,
-     1993, 1993, 1994, 1994, 1994, 1995, 1995, 1995, 1996, 1996,
+     2000, 2000,    0, 2000, 2001, 2001, 2002, 2002,    0,    0,
+     2002, 2003, 2003, 2003, 2004, 2004, 2004, 2005, 2005,    0,
+     2005, 2006,    0,    0, 2006, 2007, 2007,    0, 2007, 2008,
+     2008,    0,    0, 2008, 2009, 2009,    0, 2009, 2010, 2010,
+     2011, 2011,    0,    0, 2011, 2012, 2012, 2012, 2013, 2013,
+     2013, 2014, 2014,    0, 2014, 2015,    0, 2015, 2016,    0,
+        0, 2016, 2017, 2017,    0, 2017, 2018, 2018,    0,    0,
+     2018, 2019, 2019,    0, 2019, 2020, 2020, 2021, 2021,    0,
+        0, 2021, 2022, 2022, 2022, 2023, 2023, 2023, 2024, 2024,
+        0, 2024, 2025,    0, 2025, 2026,    0,    0, 2026, 2027,
 
-     1996, 1997, 1997, 1997, 1998,    0, 1998, 1999, 1999, 1999,
-     2000, 2000,    0,    0, 2000, 2001, 2001, 2001, 2002, 2002,
-     2002, 2003, 2003,    0, 2003, 2004, 2004,    0,    0, 2004,
-     2005, 2005,    0, 2005, 2006, 2006, 2007, 2007,    0,    0,
-     2007, 2008, 2008, 2008, 2009, 2009, 2009, 2010, 2010,    0,
-     2010, 2011,    0,    0, 2011, 2012, 2012,    0, 2012, 2013,
-     2013,    0,    0, 2013, 2014, 2014,    0, 2014, 2015, 2015,
-     2016, 2016,    0,    0, 2016, 2017, 2017, 2017, 2018, 2018,
-     2018, 2019, 2019,    0, 2019, 2020,    0, 2020, 2021,    0,
-        0, 2021, 2022, 2022,    0, 2022, 2023, 2023,    0,    0,
+     2027,    0, 2027, 2028, 2028,    0,    0, 2028, 2029, 2029,
+        0, 2029, 2030, 2030, 2031, 2031,    0,    0, 2031, 2032,
+     2032, 2032, 2033, 2033, 2033, 2034, 2034,    0, 2034, 2035,
+        0, 2035, 2036,    0, 2036, 2037,    0, 2037, 2038, 2038,
+     2038, 2039,    0, 2039, 2040, 2040, 2040, 2041,    0, 2041,
+     2042, 2042, 2042,    0, 2042, 2042, 2043,    0, 2043, 2044,
+     2044, 2044, 2045,    0, 2045, 2046, 2046, 2046, 2047,    0,
+     2047, 2048, 2048, 2048, 2049,    0, 2049, 2050, 2050, 2050,
+     2051,    0, 2051, 2052, 2052, 2052, 2053,    0, 2053, 2054,
+     2054, 2054, 2055, 2055,    0,    0, 2055, 2056, 2056, 2056,
 
-     2023, 2024, 2024,    0, 2024, 2025, 2025, 2026, 2026,    0,
-        0, 2026, 2027, 2027, 2027, 2028, 2028, 2028, 2029, 2029,
-        0, 2029, 2030,    0, 2030, 2031,    0,    0, 2031, 2032,
-     2032,    0, 2032, 2033, 2033,    0,    0, 2033, 2034, 2034,
-        0, 2034, 2035, 2035, 2036, 2036,    0,    0, 2036, 2037,
-     2037, 2037, 2038, 2038, 2038, 2039, 2039,    0, 2039, 2040,
-        0, 2040, 2041,    0, 2041, 2042,    0, 2042, 2043, 2043,
-     2043, 2044,    0, 2044, 2045, 2045, 2045, 2046,    0, 2046,
-     2047, 2047, 2047,    0, 2047, 2047, 2048,    0, 2048, 2049,
-     2049, 2049, 2050,    0, 2050, 2051, 2051, 2051, 2052,    0,
+     2057, 2057, 2057, 2058, 2058, 2058, 2059, 2059,    0, 2059,
+     2060, 2060, 2060, 2061,    0, 2061, 2062, 2062, 2062, 2063,
+     2063, 2063, 2064,    0, 2064, 2065,    0, 2065, 2066, 2066,
+     2066, 2067, 2067, 2067, 2068,    0, 2068, 2069,    0, 2069,
+     2070,    0, 2070, 2071, 2071, 2071, 2072, 2072, 2072, 2073,
+        0, 2073, 2074,    0, 2074, 2075,    0, 2075, 2076, 2076,
+     2076, 2077, 2077, 2077, 2078,    0, 2078, 2079,    0, 2079,
+     2080,    0, 2080, 2081, 2081, 2081, 2082, 2082, 2082, 2083,
+        0, 2083, 2084,    0,    0, 2084, 2085, 2085,    0, 2085,
+     2086, 2086,    0,    0, 2086, 2087, 2087,    0, 2087, 2088,
 
-     2052, 2053, 2053, 2053, 2054,    0, 2054, 2055, 2055, 2055,
-     2056,    0, 2056, 2057, 2057, 2057, 2058,    0, 2058, 2059,
-     2059, 2059, 2060, 2060,    0,    0, 2060, 2061, 2061, 2061,
-     2062, 2062, 2062, 2063, 2063, 2063, 2064, 2064,    0, 2064,
-     2065, 2065, 2065, 2066,    0, 2066, 2067, 2067, 2067, 2068,
-     2068, 2068, 2069,    0, 2069, 2070,    0, 2070, 2071, 2071,
-     2071, 2072, 2072, 2072, 2073,    0, 2073, 2074,    0, 2074,
-     2075,    0, 2075, 2076, 2076, 2076, 2077, 2077, 2077, 2078,
-        0, 2078, 2079,    0, 2079, 2080,    0, 2080, 2081, 2081,
-     2081, 2082, 2082, 2082, 2083,    0, 2083, 2084,    0, 2084,
+     2088, 2089, 2089,    0,    0, 2089, 2090, 2090, 2090, 2091,
+        0, 2091, 2092, 2092,    0, 2092, 2093, 2093, 2093,    0,
+     2093, 2093, 2094, 2094, 2094, 2095, 2095, 2095, 2096,    0,
+     2096, 2097,    0, 2097, 2098,    0, 2098, 2099,    0, 2099,
+     2100,    0, 2100, 2101,    0, 2101, 2102,    0, 2102, 2103,
+     2103, 2103, 2104, 2104, 2104, 2105,    0, 2105, 2106, 2106,
+        0,    0, 2106, 2107, 2107,    0, 2107, 2108, 2108, 2109,
+        0, 2109, 2110,    0,    0, 2110, 2111, 2111,    0, 2111,
+     2112, 2112,    0,    0, 2112, 2113, 2113,    0, 2113, 2114,
+     2114, 2115,    0, 2115, 2116,    0, 2116, 2117,    0,    0,
 
-     2085,    0, 2085, 2086, 2086, 2086, 2087, 2087, 2087, 2088,
-        0, 2088, 2089,    0,    0, 2089, 2090, 2090,    0, 2090,
-     2091, 2091,    0,    0, 2091, 2092, 2092,    0, 2092, 2093,
-     2093, 2094, 2094,    0,    0, 2094, 2095, 2095, 2095, 2096,
-        0, 2096, 2097, 2097,    0, 2097, 2098, 2098, 2098,    0,
-     2098, 2098, 2099, 2099, 2099, 2100, 2100, 2100, 2101,    0,
-     2101, 2102,    0, 2102, 2103,    0, 2103, 2104,    0, 2104,
-     2105,    0, 2105, 2106,    0, 2106, 2107,    0, 2107, 2108,
-     2108, 2108, 2109, 2109, 2109, 2110,    0, 2110, 2111, 2111,
-        0,    0, 2111, 2112, 2112,    0, 2112, 2113, 2113, 2114,
+     2117, 2118, 2118,    0, 2118, 2119, 2119,    0,    0, 2119,
+     2120, 2120,    0, 2120, 2121, 2121, 2122,    0, 2122, 2123,
+        0, 2123, 2124,    0,    0, 2124, 2125, 2125,    0, 2125,
+     2126, 2126,    0,    0, 2126, 2127, 2127,    0, 2127, 2128,
+     2128, 2129,    0, 2129, 2130,    0, 2130, 2131,    0,    0,
+     2131, 2132, 2132,    0, 2132, 2133, 2133,    0,    0, 2133,
+     2134, 2134,    0, 2134, 2135, 2135, 2136,    0, 2136, 2137,
+        0, 2137, 2138,    0, 2138, 2139,    0, 2139, 2140, 2140,
+     2140, 2141,    0, 2141, 2142, 2142, 2142,    0, 2142, 2142,
+     2143,    0, 2143, 2144,    0, 2144, 2145,    0, 2145, 2146,
 
-        0, 2114, 2115,    0,    0, 2115, 2116, 2116,    0, 2116,
-     2117, 2117,    0,    0, 2117, 2118, 2118,    0, 2118, 2119,
-     2119, 2120,    0, 2120, 2121,    0, 2121, 2122,    0,    0,
-     2122, 2123, 2123,    0, 2123, 2124, 2124,    0,    0, 2124,
-     2125, 2125,    0, 2125, 2126, 2126, 2127,    0, 2127, 2128,
-        0, 2128, 2129,    0,    0, 2129, 2130, 2130,    0, 2130,
-     2131, 2131,    0,    0, 2131, 2132, 2132,    0, 2132, 2133,
-     2133, 2134,    0, 2134, 2135,    0, 2135, 2136,    0,    0,
-     2136, 2137, 2137,    0, 2137, 2138, 2138,    0,    0, 2138,
-     2139, 2139,    0, 2139, 2140, 2140, 2141,    0, 2141, 2142,
+        0, 2146, 2147,    0, 2147, 2148,    0, 2148, 2149,    0,
+     2149, 2150, 2150,    0,    0, 2150, 2151, 2151,    0, 2151,
+     2152, 2152, 2153,    0, 2153, 2154,    0, 2154, 2155,    0,
+     2155, 2156,    0, 2156, 2157,    0, 2157, 2158,    0, 2158,
+     2159,    0, 2159, 2160,    0, 2160, 2161,    0, 2161, 2162,
+        0, 2162, 2163,    0,    0, 2163, 2164, 2164,    0,    0,
+     2164, 2165,    0, 2165, 2166,    0, 2166, 2167,    0, 2167,
+     2168,    0,    0, 2168, 2169,    0,    0, 2169, 2170,    0,
+        0, 2170, 2171,    0,    0, 2171, 2172,    0,    0, 2172,
+     2173,    0, 2173, 2174,    0, 2174, 2175,    0,    0, 2175,
 
-        0, 2142, 2143,    0, 2143, 2144,    0, 2144, 2145, 2145,
-     2145, 2146,    0, 2146, 2147, 2147, 2147,    0, 2147, 2147,
-     2148,    0, 2148, 2149,    0, 2149, 2150,    0, 2150, 2151,
-        0, 2151, 2152,    0, 2152, 2153,    0, 2153, 2154,    0,
-     2154, 2155, 2155,    0,    0, 2155, 2156, 2156,    0, 2156,
-     2157, 2157, 2158,    0, 2158, 2159,    0, 2159, 2160,    0,
-     2160, 2161,    0, 2161, 2162,    0, 2162, 2163,    0, 2163,
-     2164,    0, 2164, 2165,    0, 2165, 2166,    0, 2166, 2167,
-        0, 2167, 2168,    0,    0, 2168, 2169, 2169,    0,    0,
-     2169, 2170,    0, 2170, 2171,    0, 2171, 2172,    0, 2172,
-
-     2173,    0,    0, 2173, 2174,    0,    0, 2174, 2175,    0,
-        0, 2175, 2176,    0,    0, 2176, 2177,    0,    0, 2177,
-     2178,    0, 2178, 2179,    0, 2179, 2180,    0,    0, 2180,
-     2181,    0, 2181, 2182,    0, 2182, 2183,    0, 2183, 2184,
-        0, 2184, 2185,    0, 2185, 2186,    0,    0, 2186, 2187,
-        0, 2187, 2188,    0, 2188, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728,
-
-     1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728, 1728
+     2176,    0, 2176, 2177,    0, 2177, 2178,    0, 2178, 2179,
+        0, 2179, 2180,    0, 2180, 2181,    0,    0, 2181, 2182,
+        0, 2182, 2183,    0, 2183, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723,
+     1723, 1723, 1723, 1723, 1723, 1723, 1723, 1723
     } ;
 
 /* The intent behind this definition is that it'll catch
@@ -2978,7 +3140,8 @@
  */
 DIAG_OFF_FLEX
 
-#line 2982 "scanner.c"
+#line 3144 "scanner.c"
+#line 3145 "scanner.c"
 
 #define INITIAL 0
 
@@ -3028,52 +3191,52 @@
 
     }; /* end struct yyguts_t */
 
-static int yy_init_globals (yyscan_t yyscanner );
+static int yy_init_globals ( yyscan_t yyscanner );
 
     /* This must go here because YYSTYPE and YYLTYPE are included
      * from bison output in section 1.*/
     #    define yylval yyg->yylval_r
     
-int pcap_lex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
 
-int pcap_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
 
 /* Accessor methods to globals.
    These are made visible to non-reentrant scanners for convenience. */
 
-int pcap_lex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
 
-int pcap_get_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
 
-void pcap_set_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
 
-YY_EXTRA_TYPE pcap_get_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
 
-void pcap_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
 
-FILE *pcap_get_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
 
-void pcap_set_in  (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
 
-FILE *pcap_get_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
 
-void pcap_set_out  (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
 
-			int pcap_get_leng (yyscan_t yyscanner );
+			int yyget_leng ( yyscan_t yyscanner );
 
-char *pcap_get_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
 
-int pcap_get_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
 
-void pcap_set_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
 
-int pcap_get_column  (yyscan_t yyscanner );
+int yyget_column  ( yyscan_t yyscanner );
 
-void pcap_set_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
 
-YYSTYPE * pcap_get_lval (yyscan_t yyscanner );
+YYSTYPE * yyget_lval ( yyscan_t yyscanner );
 
-void pcap_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
+void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -3081,9 +3244,9 @@
 
 #ifndef YY_SKIP_YYWRAP
 #ifdef __cplusplus
-extern "C" int pcap_wrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
 #else
-extern int pcap_wrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
 #endif
 #endif
 
@@ -3092,19 +3255,18 @@
 #endif
 
 #ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
 #endif
 
 #ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
 #endif
 
 #ifndef YY_NO_INPUT
-
 #ifdef __cplusplus
-static int yyinput (yyscan_t yyscanner );
+static int yyinput ( yyscan_t yyscanner );
 #else
-static int input (yyscan_t yyscanner );
+static int input ( yyscan_t yyscanner );
 #endif
 
 #endif
@@ -3135,7 +3297,7 @@
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		size_t n; \
+		int n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -3148,7 +3310,7 @@
 	else \
 		{ \
 		errno=0; \
-		while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+		while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
 			{ \
 			if( errno != EINTR) \
 				{ \
@@ -3189,10 +3351,10 @@
 #ifndef YY_DECL
 #define YY_DECL_IS_OURS 1
 
-extern int pcap_lex \
-               (YYSTYPE * yylval_param ,yyscan_t yyscanner);
+extern int yylex \
+               (YYSTYPE * yylval_param , yyscan_t yyscanner);
 
-#define YY_DECL int pcap_lex \
+#define YY_DECL int yylex \
                (YYSTYPE * yylval_param , yyscan_t yyscanner)
 #endif /* !YY_DECL */
 
@@ -3240,18 +3402,18 @@
 			yyout = stdout;
 
 		if ( ! YY_CURRENT_BUFFER ) {
-			pcap_ensure_buffer_stack (yyscanner);
+			yyensure_buffer_stack (yyscanner);
 			YY_CURRENT_BUFFER_LVALUE =
-				pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+				yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
 		}
 
-		pcap__load_buffer_state(yyscanner );
+		yy_load_buffer_state( yyscanner );
 		}
 
 	{
 #line 254 "scanner.l"
 
-#line 3255 "scanner.c"
+#line 3417 "scanner.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -3278,13 +3440,13 @@
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 1729 )
-					yy_c = yy_meta[(unsigned int) yy_c];
+				if ( yy_current_state >= 1724 )
+					yy_c = yy_meta[yy_c];
 				}
-			yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			++yy_cp;
 			}
-		while ( yy_current_state != 1728 );
+		while ( yy_current_state != 1723 );
 		yy_cp = yyg->yy_last_accepting_cpos;
 		yy_current_state = yyg->yy_last_accepting_state;
 
@@ -3557,705 +3719,690 @@
 case 51:
 YY_RULE_SETUP
 #line 314 "scanner.l"
-{
-#ifdef NO_PROTOCHAIN
-		  bpf_error(yyextra, "%s not supported", yytext);
-#else
-		  return PROTOCHAIN;
-#endif
-		}
+return PROTOCHAIN;
 	YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 322 "scanner.l"
+#line 316 "scanner.l"
 return GATEWAY;
 	YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 324 "scanner.l"
+#line 318 "scanner.l"
 return TYPE;
 	YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 325 "scanner.l"
+#line 319 "scanner.l"
 return SUBTYPE;
 	YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 326 "scanner.l"
+#line 320 "scanner.l"
 return DIR;
 	YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 327 "scanner.l"
+#line 321 "scanner.l"
 return ADDR1;
 	YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 328 "scanner.l"
+#line 322 "scanner.l"
 return ADDR2;
 	YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 329 "scanner.l"
+#line 323 "scanner.l"
 return ADDR3;
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 330 "scanner.l"
+#line 324 "scanner.l"
 return ADDR4;
 	YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 331 "scanner.l"
+#line 325 "scanner.l"
 return RA;
 	YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 332 "scanner.l"
+#line 326 "scanner.l"
 return TA;
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 334 "scanner.l"
+#line 328 "scanner.l"
 return LESS;
 	YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 335 "scanner.l"
+#line 329 "scanner.l"
 return GREATER;
 	YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 336 "scanner.l"
+#line 330 "scanner.l"
 return CBYTE;
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 337 "scanner.l"
+#line 331 "scanner.l"
 return TK_BROADCAST;
 	YY_BREAK
 case 66:
 YY_RULE_SETUP
-#line 338 "scanner.l"
+#line 332 "scanner.l"
 return TK_MULTICAST;
 	YY_BREAK
 case 67:
 YY_RULE_SETUP
-#line 340 "scanner.l"
+#line 334 "scanner.l"
 return AND;
 	YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 341 "scanner.l"
+#line 335 "scanner.l"
 return OR;
 	YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 342 "scanner.l"
+#line 336 "scanner.l"
 return '!';
 	YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 344 "scanner.l"
+#line 338 "scanner.l"
 return LEN;
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 345 "scanner.l"
+#line 339 "scanner.l"
 return INBOUND;
 	YY_BREAK
 case 72:
 YY_RULE_SETUP
-#line 346 "scanner.l"
+#line 340 "scanner.l"
 return OUTBOUND;
 	YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 348 "scanner.l"
+#line 342 "scanner.l"
 return VLAN;
 	YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 349 "scanner.l"
+#line 343 "scanner.l"
 return MPLS;
 	YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 350 "scanner.l"
+#line 344 "scanner.l"
 return PPPOED;
 	YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 351 "scanner.l"
+#line 345 "scanner.l"
 return PPPOES;
 	YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 352 "scanner.l"
+#line 346 "scanner.l"
 return GENEVE;
 	YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 354 "scanner.l"
+#line 348 "scanner.l"
 return LANE;
 	YY_BREAK
 case 79:
 YY_RULE_SETUP
-#line 355 "scanner.l"
+#line 349 "scanner.l"
 return LLC;
 	YY_BREAK
 case 80:
 YY_RULE_SETUP
-#line 356 "scanner.l"
+#line 350 "scanner.l"
 return METAC;
 	YY_BREAK
 case 81:
 YY_RULE_SETUP
-#line 357 "scanner.l"
+#line 351 "scanner.l"
 return BCC;
 	YY_BREAK
 case 82:
 YY_RULE_SETUP
-#line 358 "scanner.l"
+#line 352 "scanner.l"
 return OAM;
 	YY_BREAK
 case 83:
 YY_RULE_SETUP
-#line 359 "scanner.l"
+#line 353 "scanner.l"
 return OAMF4;
 	YY_BREAK
 case 84:
 YY_RULE_SETUP
-#line 360 "scanner.l"
+#line 354 "scanner.l"
 return OAMF4EC;
 	YY_BREAK
 case 85:
 YY_RULE_SETUP
-#line 361 "scanner.l"
+#line 355 "scanner.l"
 return OAMF4SC;
 	YY_BREAK
 case 86:
 YY_RULE_SETUP
-#line 362 "scanner.l"
+#line 356 "scanner.l"
 return SC;
 	YY_BREAK
 case 87:
 YY_RULE_SETUP
-#line 363 "scanner.l"
+#line 357 "scanner.l"
 return ILMIC;
 	YY_BREAK
 case 88:
 YY_RULE_SETUP
-#line 364 "scanner.l"
+#line 358 "scanner.l"
 return VPI;
 	YY_BREAK
 case 89:
 YY_RULE_SETUP
-#line 365 "scanner.l"
+#line 359 "scanner.l"
 return VCI;
 	YY_BREAK
 case 90:
 YY_RULE_SETUP
-#line 366 "scanner.l"
+#line 360 "scanner.l"
 return CONNECTMSG;
 	YY_BREAK
 case 91:
 YY_RULE_SETUP
-#line 367 "scanner.l"
+#line 361 "scanner.l"
 return METACONNECT;
 	YY_BREAK
 case 92:
 YY_RULE_SETUP
-#line 369 "scanner.l"
+#line 363 "scanner.l"
 return PF_IFNAME;
 	YY_BREAK
 case 93:
 YY_RULE_SETUP
-#line 370 "scanner.l"
+#line 364 "scanner.l"
 return PF_RSET;
 	YY_BREAK
 case 94:
 YY_RULE_SETUP
-#line 371 "scanner.l"
+#line 365 "scanner.l"
 return PF_RNR;
 	YY_BREAK
 case 95:
 YY_RULE_SETUP
-#line 372 "scanner.l"
+#line 366 "scanner.l"
 return PF_SRNR;
 	YY_BREAK
 case 96:
 YY_RULE_SETUP
-#line 373 "scanner.l"
+#line 367 "scanner.l"
 return PF_REASON;
 	YY_BREAK
 case 97:
 YY_RULE_SETUP
-#line 374 "scanner.l"
+#line 368 "scanner.l"
 return PF_ACTION;
 	YY_BREAK
 case 98:
 YY_RULE_SETUP
-#line 376 "scanner.l"
+#line 370 "scanner.l"
 return FISU;
 	YY_BREAK
 case 99:
 YY_RULE_SETUP
-#line 377 "scanner.l"
+#line 371 "scanner.l"
 return LSSU;
 	YY_BREAK
 case 100:
 YY_RULE_SETUP
-#line 378 "scanner.l"
+#line 372 "scanner.l"
 return LSSU;
 	YY_BREAK
 case 101:
 YY_RULE_SETUP
-#line 379 "scanner.l"
+#line 373 "scanner.l"
 return MSU;
 	YY_BREAK
 case 102:
 YY_RULE_SETUP
-#line 380 "scanner.l"
+#line 374 "scanner.l"
 return HFISU;
 	YY_BREAK
 case 103:
 YY_RULE_SETUP
-#line 381 "scanner.l"
+#line 375 "scanner.l"
 return HLSSU;
 	YY_BREAK
 case 104:
 YY_RULE_SETUP
-#line 382 "scanner.l"
+#line 376 "scanner.l"
 return HMSU;
 	YY_BREAK
 case 105:
 YY_RULE_SETUP
-#line 383 "scanner.l"
+#line 377 "scanner.l"
 return SIO;
 	YY_BREAK
 case 106:
 YY_RULE_SETUP
-#line 384 "scanner.l"
+#line 378 "scanner.l"
 return OPC;
 	YY_BREAK
 case 107:
 YY_RULE_SETUP
-#line 385 "scanner.l"
+#line 379 "scanner.l"
 return DPC;
 	YY_BREAK
 case 108:
 YY_RULE_SETUP
-#line 386 "scanner.l"
+#line 380 "scanner.l"
 return SLS;
 	YY_BREAK
 case 109:
 YY_RULE_SETUP
-#line 387 "scanner.l"
+#line 381 "scanner.l"
 return HSIO;
 	YY_BREAK
 case 110:
 YY_RULE_SETUP
-#line 388 "scanner.l"
+#line 382 "scanner.l"
 return HOPC;
 	YY_BREAK
 case 111:
 YY_RULE_SETUP
-#line 389 "scanner.l"
+#line 383 "scanner.l"
 return HDPC;
 	YY_BREAK
 case 112:
 YY_RULE_SETUP
-#line 390 "scanner.l"
+#line 384 "scanner.l"
 return HSLS;
 	YY_BREAK
 case 113:
 /* rule 113 can match eol */
 YY_RULE_SETUP
-#line 392 "scanner.l"
+#line 386 "scanner.l"
 ;
 	YY_BREAK
 case 114:
 YY_RULE_SETUP
-#line 393 "scanner.l"
+#line 387 "scanner.l"
 return yytext[0];
 	YY_BREAK
 case 115:
 YY_RULE_SETUP
-#line 394 "scanner.l"
+#line 388 "scanner.l"
 return GEQ;
 	YY_BREAK
 case 116:
 YY_RULE_SETUP
-#line 395 "scanner.l"
+#line 389 "scanner.l"
 return LEQ;
 	YY_BREAK
 case 117:
 YY_RULE_SETUP
-#line 396 "scanner.l"
+#line 390 "scanner.l"
 return NEQ;
 	YY_BREAK
 case 118:
 YY_RULE_SETUP
-#line 397 "scanner.l"
+#line 391 "scanner.l"
 return '=';
 	YY_BREAK
 case 119:
 YY_RULE_SETUP
-#line 398 "scanner.l"
+#line 392 "scanner.l"
 return LSH;
 	YY_BREAK
 case 120:
 YY_RULE_SETUP
-#line 399 "scanner.l"
+#line 393 "scanner.l"
 return RSH;
 	YY_BREAK
 case 121:
 YY_RULE_SETUP
-#line 400 "scanner.l"
-{ yylval->e = pcap_ether_aton(((char *)yytext)+1);
-			  if (yylval->e == NULL)
-				bpf_error(yyextra, "malloc");
-			  return AID; }
+#line 394 "scanner.l"
+{ yylval->s = sdup(yyextra, yytext); return AID; }
 	YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 404 "scanner.l"
-{ yylval->e = pcap_ether_aton((char *)yytext);
-			  if (yylval->e == NULL)
-				bpf_error(yyextra, "malloc");
-			  return EID; }
+#line 395 "scanner.l"
+{ yylval->s = sdup(yyextra, yytext); return EID; }
 	YY_BREAK
 case 123:
 YY_RULE_SETUP
-#line 408 "scanner.l"
+#line 396 "scanner.l"
 { yylval->i = stoi((char *)yytext); return NUM; }
 	YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 409 "scanner.l"
+#line 397 "scanner.l"
 {
 			yylval->s = sdup(yyextra, (char *)yytext); return HID; }
 	YY_BREAK
 case 125:
 YY_RULE_SETUP
-#line 411 "scanner.l"
+#line 399 "scanner.l"
 {
 #ifdef INET6
 			  struct addrinfo hints, *res;
 			  memset(&hints, 0, sizeof(hints));
 			  hints.ai_family = AF_INET6;
 			  hints.ai_flags = AI_NUMERICHOST;
-			  if (getaddrinfo(yytext, NULL, &hints, &res))
-				bpf_error(yyextra, "bogus IPv6 address %s", yytext);
-			  else {
+			  if (getaddrinfo(yytext, NULL, &hints, &res)) {
+				bpf_set_error(yyextra, "bogus IPv6 address %s", yytext);
+				yylval->s = NULL;
+			  } else {
 				freeaddrinfo(res);
-				yylval->s = sdup(yyextra, (char *)yytext); return HID6;
+				yylval->s = sdup(yyextra, (char *)yytext);
 			  }
 #else
-			  bpf_error(yyextra, "IPv6 address %s not supported", yytext);
+			  bpf_set_error(yyextra, "IPv6 address %s not supported", yytext);
+			  yylval->s = NULL;
 #endif /*INET6*/
+			  return HID6;
 			}
 	YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 427 "scanner.l"
-{ bpf_error(yyextra, "bogus ethernet address %s", yytext); }
+#line 418 "scanner.l"
+{ bpf_set_error(yyextra, "bogus ethernet address %s", yytext); yylval->s = NULL; return EID; }
 	YY_BREAK
 case 127:
 YY_RULE_SETUP
-#line 428 "scanner.l"
+#line 419 "scanner.l"
 { yylval->i = 0; return NUM; }
 	YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 429 "scanner.l"
+#line 420 "scanner.l"
 { yylval->i = 1; return NUM; }
 	YY_BREAK
 case 129:
 YY_RULE_SETUP
-#line 430 "scanner.l"
+#line 421 "scanner.l"
 { yylval->i = 0; return NUM; }
 	YY_BREAK
 case 130:
 YY_RULE_SETUP
-#line 431 "scanner.l"
+#line 422 "scanner.l"
 { yylval->i = 3; return NUM; }
 	YY_BREAK
 case 131:
 YY_RULE_SETUP
-#line 432 "scanner.l"
+#line 423 "scanner.l"
 { yylval->i = 4; return NUM; }
 	YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 433 "scanner.l"
+#line 424 "scanner.l"
 { yylval->i = 5; return NUM; }
 	YY_BREAK
 case 133:
 YY_RULE_SETUP
-#line 434 "scanner.l"
+#line 425 "scanner.l"
 { yylval->i = 8; return NUM; }
 	YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 435 "scanner.l"
+#line 426 "scanner.l"
 { yylval->i = 9; return NUM; }
 	YY_BREAK
 case 135:
 YY_RULE_SETUP
-#line 436 "scanner.l"
+#line 427 "scanner.l"
 { yylval->i = 10; return NUM; }
 	YY_BREAK
 case 136:
 YY_RULE_SETUP
-#line 437 "scanner.l"
+#line 428 "scanner.l"
 { yylval->i = 11; return NUM; }
 	YY_BREAK
 case 137:
 YY_RULE_SETUP
-#line 438 "scanner.l"
+#line 429 "scanner.l"
 { yylval->i = 12; return NUM; }
 	YY_BREAK
 case 138:
 YY_RULE_SETUP
-#line 439 "scanner.l"
+#line 430 "scanner.l"
 { yylval->i = 13; return NUM; }
 	YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 440 "scanner.l"
+#line 431 "scanner.l"
 { yylval->i = 14; return NUM; }
 	YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 441 "scanner.l"
+#line 432 "scanner.l"
 { yylval->i = 15; return NUM; }
 	YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 442 "scanner.l"
+#line 433 "scanner.l"
 { yylval->i = 16; return NUM; }
 	YY_BREAK
 case 142:
 YY_RULE_SETUP
-#line 443 "scanner.l"
+#line 434 "scanner.l"
 { yylval->i = 17; return NUM; }
 	YY_BREAK
 case 143:
 YY_RULE_SETUP
-#line 444 "scanner.l"
+#line 435 "scanner.l"
 { yylval->i = 18; return NUM; }
 	YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 446 "scanner.l"
+#line 437 "scanner.l"
 { yylval->i = 0; return NUM; }
 	YY_BREAK
 case 145:
 YY_RULE_SETUP
-#line 447 "scanner.l"
+#line 438 "scanner.l"
 { yylval->i = 1; return NUM; }
 	YY_BREAK
 case 146:
 YY_RULE_SETUP
-#line 449 "scanner.l"
+#line 440 "scanner.l"
 { yylval->i = 128; return NUM; }
 	YY_BREAK
 case 147:
 YY_RULE_SETUP
-#line 450 "scanner.l"
+#line 441 "scanner.l"
 { yylval->i = 129; return NUM; }
 	YY_BREAK
 case 148:
 YY_RULE_SETUP
-#line 451 "scanner.l"
+#line 442 "scanner.l"
 { yylval->i = 130; return NUM; }
 	YY_BREAK
 case 149:
 YY_RULE_SETUP
-#line 452 "scanner.l"
+#line 443 "scanner.l"
 { yylval->i = 131; return NUM; }
 	YY_BREAK
 case 150:
 YY_RULE_SETUP
-#line 453 "scanner.l"
+#line 444 "scanner.l"
 { yylval->i = 132; return NUM; }
 	YY_BREAK
 case 151:
 YY_RULE_SETUP
-#line 454 "scanner.l"
+#line 445 "scanner.l"
 { yylval->i = 133; return NUM; }
 	YY_BREAK
 case 152:
 YY_RULE_SETUP
-#line 455 "scanner.l"
+#line 446 "scanner.l"
 { yylval->i = 134; return NUM; }
 	YY_BREAK
 case 153:
 YY_RULE_SETUP
-#line 456 "scanner.l"
+#line 447 "scanner.l"
 { yylval->i = 135; return NUM; }
 	YY_BREAK
 case 154:
 YY_RULE_SETUP
-#line 457 "scanner.l"
+#line 448 "scanner.l"
 { yylval->i = 136; return NUM; }
 	YY_BREAK
 case 155:
 YY_RULE_SETUP
-#line 458 "scanner.l"
+#line 449 "scanner.l"
 { yylval->i = 137; return NUM; }
 	YY_BREAK
 case 156:
 YY_RULE_SETUP
-#line 459 "scanner.l"
+#line 450 "scanner.l"
 { yylval->i = 138; return NUM; }
 	YY_BREAK
 case 157:
 YY_RULE_SETUP
-#line 460 "scanner.l"
+#line 451 "scanner.l"
 { yylval->i = 139; return NUM; }
 	YY_BREAK
 case 158:
 YY_RULE_SETUP
-#line 461 "scanner.l"
+#line 452 "scanner.l"
 { yylval->i = 140; return NUM; }
 	YY_BREAK
 case 159:
 YY_RULE_SETUP
-#line 462 "scanner.l"
+#line 453 "scanner.l"
 { yylval->i = 141; return NUM; }
 	YY_BREAK
 case 160:
 YY_RULE_SETUP
-#line 463 "scanner.l"
+#line 454 "scanner.l"
 { yylval->i = 142; return NUM; }
 	YY_BREAK
 case 161:
 YY_RULE_SETUP
-#line 464 "scanner.l"
+#line 455 "scanner.l"
 { yylval->i = 143; return NUM; }
 	YY_BREAK
 case 162:
 YY_RULE_SETUP
-#line 465 "scanner.l"
+#line 456 "scanner.l"
 { yylval->i = 144; return NUM; }
 	YY_BREAK
 case 163:
 YY_RULE_SETUP
-#line 466 "scanner.l"
+#line 457 "scanner.l"
 { yylval->i = 145; return NUM; }
 	YY_BREAK
 case 164:
 YY_RULE_SETUP
-#line 467 "scanner.l"
+#line 458 "scanner.l"
 { yylval->i = 146; return NUM; }
 	YY_BREAK
 case 165:
 YY_RULE_SETUP
-#line 468 "scanner.l"
+#line 459 "scanner.l"
 { yylval->i = 147; return NUM; }
 	YY_BREAK
 case 166:
 YY_RULE_SETUP
-#line 469 "scanner.l"
+#line 460 "scanner.l"
 { yylval->i = 148; return NUM; }
 	YY_BREAK
 case 167:
 YY_RULE_SETUP
-#line 470 "scanner.l"
+#line 461 "scanner.l"
 { yylval->i = 149; return NUM; }
 	YY_BREAK
 case 168:
 YY_RULE_SETUP
-#line 471 "scanner.l"
+#line 462 "scanner.l"
 { yylval->i = 151; return NUM; }
 	YY_BREAK
 case 169:
 YY_RULE_SETUP
-#line 472 "scanner.l"
+#line 463 "scanner.l"
 { yylval->i = 152; return NUM; }
 	YY_BREAK
 case 170:
 YY_RULE_SETUP
-#line 473 "scanner.l"
+#line 464 "scanner.l"
 { yylval->i = 153; return NUM; }
 	YY_BREAK
 case 171:
 YY_RULE_SETUP
-#line 475 "scanner.l"
+#line 466 "scanner.l"
 { yylval->i = 13; return NUM; }
 	YY_BREAK
 case 172:
 YY_RULE_SETUP
-#line 476 "scanner.l"
+#line 467 "scanner.l"
 { yylval->i = 0x01; return NUM; }
 	YY_BREAK
 case 173:
 YY_RULE_SETUP
-#line 477 "scanner.l"
+#line 468 "scanner.l"
 { yylval->i = 0x02; return NUM; }
 	YY_BREAK
 case 174:
 YY_RULE_SETUP
-#line 478 "scanner.l"
+#line 469 "scanner.l"
 { yylval->i = 0x04; return NUM; }
 	YY_BREAK
 case 175:
 YY_RULE_SETUP
-#line 479 "scanner.l"
+#line 470 "scanner.l"
 { yylval->i = 0x08; return NUM; }
 	YY_BREAK
 case 176:
 YY_RULE_SETUP
-#line 480 "scanner.l"
+#line 471 "scanner.l"
 { yylval->i = 0x10; return NUM; }
 	YY_BREAK
 case 177:
 YY_RULE_SETUP
-#line 481 "scanner.l"
+#line 472 "scanner.l"
 { yylval->i = 0x20; return NUM; }
 	YY_BREAK
 case 178:
 YY_RULE_SETUP
-#line 482 "scanner.l"
+#line 473 "scanner.l"
 { yylval->i = 0x40; return NUM; }
 	YY_BREAK
 case 179:
 YY_RULE_SETUP
-#line 483 "scanner.l"
+#line 474 "scanner.l"
 { yylval->i = 0x80; return NUM; }
 	YY_BREAK
 case 180:
 YY_RULE_SETUP
-#line 484 "scanner.l"
+#line 475 "scanner.l"
 {
 			 yylval->s = sdup(yyextra, (char *)yytext); return ID; }
 	YY_BREAK
 case 181:
 YY_RULE_SETUP
-#line 486 "scanner.l"
+#line 477 "scanner.l"
 { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; }
 	YY_BREAK
 case 182:
 YY_RULE_SETUP
-#line 487 "scanner.l"
-{
-			bpf_error(yyextra, "illegal token: %s", yytext); }
+#line 478 "scanner.l"
+{ return LEX_ERROR; }
 	YY_BREAK
 case 183:
 YY_RULE_SETUP
-#line 489 "scanner.l"
-{ bpf_error(yyextra, "illegal char '%c'", *yytext); }
-	YY_BREAK
-case 184:
-YY_RULE_SETUP
-#line 490 "scanner.l"
+#line 479 "scanner.l"
 ECHO;
 	YY_BREAK
-#line 4259 "scanner.c"
+#line 4406 "scanner.c"
 case YY_STATE_EOF(INITIAL):
 	yyterminate();
 
@@ -4273,7 +4420,7 @@
 			/* We're scanning a new file or input source.  It's
 			 * possible that this happened because the user
 			 * just pointed yyin at a new source and called
-			 * pcap_lex().  If so, then we have to assure
+			 * yylex().  If so, then we have to assure
 			 * consistency between YY_CURRENT_BUFFER and our
 			 * globals.  Here is the right place to do so, because
 			 * this is the first action (other than possibly a
@@ -4334,7 +4481,7 @@
 				{
 				yyg->yy_did_buffer_switch_on_eof = 0;
 
-				if ( pcap_wrap(yyscanner ) )
+				if ( yywrap( yyscanner ) )
 					{
 					/* Note: because we've taken care in
 					 * yy_get_next_buffer() to have set up
@@ -4388,7 +4535,7 @@
 	} /* end of action switch */
 		} /* end of scanning one token */
 	} /* end of user's declarations */
-} /* end of pcap_lex */
+} /* end of yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
  *
@@ -4467,7 +4614,8 @@
 
 				b->yy_ch_buf = (char *)
 					/* Include room in for 2 EOB chars. */
-					pcap_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+					yyrealloc( (void *) b->yy_ch_buf,
+							 (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
 				}
 			else
 				/* Can't grow it, we don't own it. */
@@ -4499,7 +4647,7 @@
 		if ( number_to_move == YY_MORE_ADJ )
 			{
 			ret_val = EOB_ACT_END_OF_FILE;
-			pcap_restart(yyin  ,yyscanner);
+			yyrestart( yyin  , yyscanner);
 			}
 
 		else
@@ -4516,9 +4664,12 @@
 	if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
 		/* Extend the array by 50%, plus the number we really need. */
 		int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
-		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pcap_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+			(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
 		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
 			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+		/* "- 2" to take care of EOB's */
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
 	}
 
 	yyg->yy_n_chars += number_to_move;
@@ -4551,10 +4702,10 @@
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 1729 )
-				yy_c = yy_meta[(unsigned int) yy_c];
+			if ( yy_current_state >= 1724 )
+				yy_c = yy_meta[yy_c];
 			}
-		yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 		}
 
 	return yy_current_state;
@@ -4580,11 +4731,11 @@
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 1729 )
-			yy_c = yy_meta[(unsigned int) yy_c];
+		if ( yy_current_state >= 1724 )
+			yy_c = yy_meta[yy_c];
 		}
-	yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
-	yy_is_jam = (yy_current_state == 1728);
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+	yy_is_jam = (yy_current_state == 1723);
 
 	(void)yyg;
 	return yy_is_jam ? 0 : yy_current_state;
@@ -4619,7 +4770,7 @@
 
 		else
 			{ /* need more input */
-			int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+			int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
 			++yyg->yy_c_buf_p;
 
 			switch ( yy_get_next_buffer( yyscanner ) )
@@ -4636,13 +4787,13 @@
 					 */
 
 					/* Reset buffer status. */
-					pcap_restart(yyin ,yyscanner);
+					yyrestart( yyin , yyscanner);
 
 					/*FALLTHROUGH*/
 
 				case EOB_ACT_END_OF_FILE:
 					{
-					if ( pcap_wrap(yyscanner ) )
+					if ( yywrap( yyscanner ) )
 						return 0;
 
 					if ( ! yyg->yy_did_buffer_switch_on_eof )
@@ -4674,34 +4825,34 @@
  * @param yyscanner The scanner object.
  * @note This function does not reset the start condition to @c INITIAL .
  */
-    void pcap_restart  (FILE * input_file , yyscan_t yyscanner)
+    void yyrestart  (FILE * input_file , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 	if ( ! YY_CURRENT_BUFFER ){
-        pcap_ensure_buffer_stack (yyscanner);
+        yyensure_buffer_stack (yyscanner);
 		YY_CURRENT_BUFFER_LVALUE =
-            pcap__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
 	}
 
-	pcap__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
-	pcap__load_buffer_state(yyscanner );
+	yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
+	yy_load_buffer_state( yyscanner );
 }
 
 /** Switch to a different input buffer.
  * @param new_buffer The new input buffer.
  * @param yyscanner The scanner object.
  */
-    void pcap__switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
+    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 	/* TODO. We should be able to replace this entire function body
 	 * with
-	 *		pcap_pop_buffer_state();
-	 *		pcap_push_buffer_state(new_buffer);
+	 *		yypop_buffer_state();
+	 *		yypush_buffer_state(new_buffer);
      */
-	pcap_ensure_buffer_stack (yyscanner);
+	yyensure_buffer_stack (yyscanner);
 	if ( YY_CURRENT_BUFFER == new_buffer )
 		return;
 
@@ -4714,17 +4865,17 @@
 		}
 
 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
-	pcap__load_buffer_state(yyscanner );
+	yy_load_buffer_state( yyscanner );
 
 	/* We don't actually know whether we did this switch during
-	 * EOF (pcap_wrap()) processing, but the only time this flag
-	 * is looked at is after pcap_wrap() is called, so it's safe
+	 * EOF (yywrap()) processing, but the only time this flag
+	 * is looked at is after yywrap() is called, so it's safe
 	 * to go ahead and always set it.
 	 */
 	yyg->yy_did_buffer_switch_on_eof = 1;
 }
 
-static void pcap__load_buffer_state  (yyscan_t yyscanner)
+static void yy_load_buffer_state  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
@@ -4739,35 +4890,35 @@
  * @param yyscanner The scanner object.
  * @return the allocated buffer state.
  */
-    YY_BUFFER_STATE pcap__create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
+    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
 {
 	YY_BUFFER_STATE b;
     
-	b = (YY_BUFFER_STATE) pcap_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
 	if ( ! b )
-		YY_FATAL_ERROR( "out of dynamic memory in pcap__create_buffer()" );
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
 
-	b->yy_buf_size = (yy_size_t)size;
+	b->yy_buf_size = size;
 
 	/* yy_ch_buf has to be 2 characters longer than the size given because
 	 * we need to put in 2 end-of-buffer characters.
 	 */
-	b->yy_ch_buf = (char *) pcap_alloc(b->yy_buf_size + 2 ,yyscanner );
+	b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
 	if ( ! b->yy_ch_buf )
-		YY_FATAL_ERROR( "out of dynamic memory in pcap__create_buffer()" );
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
 
 	b->yy_is_our_buffer = 1;
 
-	pcap__init_buffer(b,file ,yyscanner);
+	yy_init_buffer( b, file , yyscanner);
 
 	return b;
 }
 
 /** Destroy the buffer.
- * @param b a buffer created with pcap__create_buffer()
+ * @param b a buffer created with yy_create_buffer()
  * @param yyscanner The scanner object.
  */
-    void pcap__delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
+    void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
@@ -4778,28 +4929,28 @@
 		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
 
 	if ( b->yy_is_our_buffer )
-		pcap_free((void *) b->yy_ch_buf ,yyscanner );
+		yyfree( (void *) b->yy_ch_buf , yyscanner );
 
-	pcap_free((void *) b ,yyscanner );
+	yyfree( (void *) b , yyscanner );
 }
 
 /* Initializes or reinitializes a buffer.
  * This function is sometimes called more than once on the same buffer,
- * such as during a pcap_restart() or at EOF.
+ * such as during a yyrestart() or at EOF.
  */
-    static void pcap__init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
+    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
 
 {
 	int oerrno = errno;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-	pcap__flush_buffer(b ,yyscanner);
+	yy_flush_buffer( b , yyscanner);
 
 	b->yy_input_file = file;
 	b->yy_fill_buffer = 1;
 
-    /* If b is the current buffer, then pcap__init_buffer was _probably_
-     * called from pcap_restart() or through yy_get_next_buffer.
+    /* If b is the current buffer, then yy_init_buffer was _probably_
+     * called from yyrestart() or through yy_get_next_buffer.
      * In that case, we don't want to reset the lineno or column.
      */
     if (b != YY_CURRENT_BUFFER){
@@ -4816,7 +4967,7 @@
  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
  * @param yyscanner The scanner object.
  */
-    void pcap__flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
+    void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	if ( ! b )
@@ -4837,7 +4988,7 @@
 	b->yy_buffer_status = YY_BUFFER_NEW;
 
 	if ( b == YY_CURRENT_BUFFER )
-		pcap__load_buffer_state(yyscanner );
+		yy_load_buffer_state( yyscanner );
 }
 
 /** Pushes the new state onto the stack. The new state becomes
@@ -4846,15 +4997,15 @@
  *  @param new_buffer The new state.
  *  @param yyscanner The scanner object.
  */
-void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	if (new_buffer == NULL)
 		return;
 
-	pcap_ensure_buffer_stack(yyscanner);
+	yyensure_buffer_stack(yyscanner);
 
-	/* This block is copied from pcap__switch_to_buffer. */
+	/* This block is copied from yy_switch_to_buffer. */
 	if ( YY_CURRENT_BUFFER )
 		{
 		/* Flush out information for old buffer. */
@@ -4868,8 +5019,8 @@
 		yyg->yy_buffer_stack_top++;
 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
 
-	/* copied from pcap__switch_to_buffer. */
-	pcap__load_buffer_state(yyscanner );
+	/* copied from yy_switch_to_buffer. */
+	yy_load_buffer_state( yyscanner );
 	yyg->yy_did_buffer_switch_on_eof = 1;
 }
 
@@ -4877,19 +5028,19 @@
  *  The next element becomes the new top.
  *  @param yyscanner The scanner object.
  */
-void pcap_pop_buffer_state (yyscan_t yyscanner)
+void yypop_buffer_state (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	if (!YY_CURRENT_BUFFER)
 		return;
 
-	pcap__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+	yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
 	YY_CURRENT_BUFFER_LVALUE = NULL;
 	if (yyg->yy_buffer_stack_top > 0)
 		--yyg->yy_buffer_stack_top;
 
 	if (YY_CURRENT_BUFFER) {
-		pcap__load_buffer_state(yyscanner );
+		yy_load_buffer_state( yyscanner );
 		yyg->yy_did_buffer_switch_on_eof = 1;
 	}
 }
@@ -4897,9 +5048,9 @@
 /* Allocates the stack if it does not exist.
  *  Guarantees space for at least one push.
  */
-static void pcap_ensure_buffer_stack (yyscan_t yyscanner)
+static void yyensure_buffer_stack (yyscan_t yyscanner)
 {
-	int num_to_alloc;
+	yy_size_t num_to_alloc;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
 	if (!yyg->yy_buffer_stack) {
@@ -4909,11 +5060,11 @@
 		 * immediate realloc on the next call.
          */
       num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
-		yyg->yy_buffer_stack = (struct yy_buffer_state**)pcap_alloc
+		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
 								(num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
 		if ( ! yyg->yy_buffer_stack )
-			YY_FATAL_ERROR( "out of dynamic memory in pcap_ensure_buffer_stack()" );
+			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
 
 		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 
@@ -4928,12 +5079,12 @@
 		yy_size_t grow_size = 8 /* arbitrary grow size */;
 
 		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
-		yyg->yy_buffer_stack = (struct yy_buffer_state**)pcap_realloc
+		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
 								(yyg->yy_buffer_stack,
 								num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
 		if ( ! yyg->yy_buffer_stack )
-			YY_FATAL_ERROR( "out of dynamic memory in pcap_ensure_buffer_stack()" );
+			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
 
 		/* zero only the new slots.*/
 		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -4947,7 +5098,7 @@
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  */
-YY_BUFFER_STATE pcap__scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
 {
 	YY_BUFFER_STATE b;
     
@@ -4957,11 +5108,11 @@
 		/* They forgot to leave room for the EOB's. */
 		return NULL;
 
-	b = (YY_BUFFER_STATE) pcap_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
 	if ( ! b )
-		YY_FATAL_ERROR( "out of dynamic memory in pcap__scan_buffer()" );
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
 
-	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_size = (int) (size - 2);	/* "- 2" to take care of EOB's */
 	b->yy_buf_pos = b->yy_ch_buf = base;
 	b->yy_is_our_buffer = 0;
 	b->yy_input_file = NULL;
@@ -4971,33 +5122,33 @@
 	b->yy_fill_buffer = 0;
 	b->yy_buffer_status = YY_BUFFER_NEW;
 
-	pcap__switch_to_buffer(b ,yyscanner );
+	yy_switch_to_buffer( b , yyscanner );
 
 	return b;
 }
 
-/** Setup the input buffer state to scan a string. The next call to pcap_lex() will
+/** Setup the input buffer state to scan a string. The next call to yylex() will
  * scan from a @e copy of @a str.
  * @param yystr a NUL-terminated string to scan
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  * @note If you want to scan bytes that may contain NUL values, then use
- *       pcap__scan_bytes() instead.
+ *       yy_scan_bytes() instead.
  */
-YY_BUFFER_STATE pcap__scan_string (yyconst char * yystr , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
 {
     
-	return pcap__scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
+	return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
 }
 
-/** Setup the input buffer state to scan the given bytes. The next call to pcap_lex() will
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
  * scan from a @e copy of @a bytes.
  * @param yybytes the byte buffer to scan
  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  */
-YY_BUFFER_STATE pcap__scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
 {
 	YY_BUFFER_STATE b;
 	char *buf;
@@ -5006,18 +5157,18 @@
     
 	/* Get memory for full buffer, including space for trailing EOB's. */
 	n = (yy_size_t) (_yybytes_len + 2);
-	buf = (char *) pcap_alloc(n ,yyscanner );
+	buf = (char *) yyalloc( n , yyscanner );
 	if ( ! buf )
-		YY_FATAL_ERROR( "out of dynamic memory in pcap__scan_bytes()" );
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
 
 	for ( i = 0; i < _yybytes_len; ++i )
 		buf[i] = yybytes[i];
 
 	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
 
-	b = pcap__scan_buffer(buf,n ,yyscanner);
+	b = yy_scan_buffer( buf, n , yyscanner);
 	if ( ! b )
-		YY_FATAL_ERROR( "bad buffer in pcap__scan_bytes()" );
+		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
 
 	/* It's okay to grow etc. this buffer, and we should throw it
 	 * away when we're done.
@@ -5031,11 +5182,11 @@
 #define YY_EXIT_FAILURE 2
 #endif
 
-static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
 {
 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	(void)yyg;
-	(void) fprintf( stderr, "%s\n", msg );
+	fprintf( stderr, "%s\n", msg );
 	exit( YY_EXIT_FAILURE );
 }
 
@@ -5061,7 +5212,7 @@
 /** Get the user-defined data for this scanner.
  * @param yyscanner The scanner object.
  */
-YY_EXTRA_TYPE pcap_get_extra  (yyscan_t yyscanner)
+YY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yyextra;
@@ -5070,7 +5221,7 @@
 /** Get the current line number.
  * @param yyscanner The scanner object.
  */
-int pcap_get_lineno  (yyscan_t yyscanner)
+int yyget_lineno  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
@@ -5083,7 +5234,7 @@
 /** Get the current column number.
  * @param yyscanner The scanner object.
  */
-int pcap_get_column  (yyscan_t yyscanner)
+int yyget_column  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
@@ -5096,7 +5247,7 @@
 /** Get the input stream.
  * @param yyscanner The scanner object.
  */
-FILE *pcap_get_in  (yyscan_t yyscanner)
+FILE *yyget_in  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yyin;
@@ -5105,7 +5256,7 @@
 /** Get the output stream.
  * @param yyscanner The scanner object.
  */
-FILE *pcap_get_out  (yyscan_t yyscanner)
+FILE *yyget_out  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yyout;
@@ -5114,7 +5265,7 @@
 /** Get the length of the current token.
  * @param yyscanner The scanner object.
  */
-int pcap_get_leng  (yyscan_t yyscanner)
+int yyget_leng  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yyleng;
@@ -5124,7 +5275,7 @@
  * @param yyscanner The scanner object.
  */
 
-char *pcap_get_text  (yyscan_t yyscanner)
+char *yyget_text  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yytext;
@@ -5134,7 +5285,7 @@
  * @param user_defined The data to be associated with this scanner.
  * @param yyscanner The scanner object.
  */
-void pcap_set_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
+void yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     yyextra = user_defined ;
@@ -5144,13 +5295,13 @@
  * @param _line_number line number
  * @param yyscanner The scanner object.
  */
-void pcap_set_lineno (int  _line_number , yyscan_t yyscanner)
+void yyset_lineno (int  _line_number , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* lineno is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           YY_FATAL_ERROR( "pcap_set_lineno called with no buffer" );
+           YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
     
     yylineno = _line_number;
 }
@@ -5159,13 +5310,13 @@
  * @param _column_no column number
  * @param yyscanner The scanner object.
  */
-void pcap_set_column (int  _column_no , yyscan_t yyscanner)
+void yyset_column (int  _column_no , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* column is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           YY_FATAL_ERROR( "pcap_set_column called with no buffer" );
+           YY_FATAL_ERROR( "yyset_column called with no buffer" );
     
     yycolumn = _column_no;
 }
@@ -5174,27 +5325,27 @@
  * input buffer.
  * @param _in_str A readable stream.
  * @param yyscanner The scanner object.
- * @see pcap__switch_to_buffer
+ * @see yy_switch_to_buffer
  */
-void pcap_set_in (FILE *  _in_str , yyscan_t yyscanner)
+void yyset_in (FILE *  _in_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     yyin = _in_str ;
 }
 
-void pcap_set_out (FILE *  _out_str , yyscan_t yyscanner)
+void yyset_out (FILE *  _out_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     yyout = _out_str ;
 }
 
-int pcap_get_debug  (yyscan_t yyscanner)
+int yyget_debug  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yy_flex_debug;
 }
 
-void pcap_set_debug (int  _bdebug , yyscan_t yyscanner)
+void yyset_debug (int  _bdebug , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     yy_flex_debug = _bdebug ;
@@ -5202,13 +5353,13 @@
 
 /* Accessor methods for yylval and yylloc */
 
-YYSTYPE * pcap_get_lval  (yyscan_t yyscanner)
+YYSTYPE * yyget_lval  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yylval;
 }
 
-void pcap_set_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
+void yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     yylval = yylval_param;
@@ -5216,20 +5367,18 @@
 
 /* User-visible API */
 
-/* pcap_lex_init is special because it creates the scanner itself, so it is
+/* yylex_init is special because it creates the scanner itself, so it is
  * the ONLY reentrant function that doesn't take the scanner as the last argument.
  * That's why we explicitly handle the declaration, instead of using our macros.
  */
-
-int pcap_lex_init(yyscan_t* ptr_yy_globals)
-
+int yylex_init(yyscan_t* ptr_yy_globals)
 {
     if (ptr_yy_globals == NULL){
         errno = EINVAL;
         return 1;
     }
 
-    *ptr_yy_globals = (yyscan_t) pcap_alloc ( sizeof( struct yyguts_t ), NULL );
+    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
 
     if (*ptr_yy_globals == NULL){
         errno = ENOMEM;
@@ -5242,27 +5391,25 @@
     return yy_init_globals ( *ptr_yy_globals );
 }
 
-/* pcap_lex_init_extra has the same functionality as pcap_lex_init, but follows the
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
  * convention of taking the scanner as the last argument. Note however, that
  * this is a *pointer* to a scanner, as it will be allocated by this call (and
  * is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to pcap_alloc in
+ * The user defined value in the first argument will be available to yyalloc in
  * the yyextra field.
  */
-
-int pcap_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
 {
     struct yyguts_t dummy_yyguts;
 
-    pcap_set_extra (yy_user_defined, &dummy_yyguts);
+    yyset_extra (yy_user_defined, &dummy_yyguts);
 
     if (ptr_yy_globals == NULL){
         errno = EINVAL;
         return 1;
     }
 
-    *ptr_yy_globals = (yyscan_t) pcap_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
 
     if (*ptr_yy_globals == NULL){
         errno = ENOMEM;
@@ -5273,7 +5420,7 @@
     yy_init_globals. Leave at 0x00 for releases. */
     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
 
-    pcap_set_extra (yy_user_defined, *ptr_yy_globals);
+    yyset_extra (yy_user_defined, *ptr_yy_globals);
 
     return yy_init_globals ( *ptr_yy_globals );
 }
@@ -5282,7 +5429,7 @@
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     /* Initialization is the same as for the non-reentrant scanner.
-     * This function is called from pcap_lex_destroy(), so don't allocate here.
+     * This function is called from yylex_destroy(), so don't allocate here.
      */
 
     yyg->yy_buffer_stack = NULL;
@@ -5306,37 +5453,37 @@
 #endif
 
     /* For future reference: Set errno on error, since we are called by
-     * pcap_lex_init()
+     * yylex_init()
      */
     return 0;
 }
 
-/* pcap_lex_destroy is for both reentrant and non-reentrant scanners. */
-int pcap_lex_destroy  (yyscan_t yyscanner)
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
     /* Pop the buffer stack, destroying each element. */
 	while(YY_CURRENT_BUFFER){
-		pcap__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+		yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
 		YY_CURRENT_BUFFER_LVALUE = NULL;
-		pcap_pop_buffer_state(yyscanner);
+		yypop_buffer_state(yyscanner);
 	}
 
 	/* Destroy the stack itself. */
-	pcap_free(yyg->yy_buffer_stack ,yyscanner);
+	yyfree(yyg->yy_buffer_stack , yyscanner);
 	yyg->yy_buffer_stack = NULL;
 
     /* Destroy the start condition stack. */
-        pcap_free(yyg->yy_start_stack ,yyscanner );
+        yyfree( yyg->yy_start_stack , yyscanner );
         yyg->yy_start_stack = NULL;
 
     /* Reset the globals. This is important in a non-reentrant scanner so the next time
-     * pcap_lex() is called, initialization will occur. */
+     * yylex() is called, initialization will occur. */
     yy_init_globals( yyscanner);
 
     /* Destroy the main struct (reentrant only). */
-    pcap_free ( yyscanner , yyscanner );
+    yyfree ( yyscanner , yyscanner );
     yyscanner = NULL;
     return 0;
 }
@@ -5346,7 +5493,7 @@
  */
 
 #ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
 {
 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	(void)yyg;
@@ -5358,7 +5505,7 @@
 #endif
 
 #ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
 {
 	int n;
 	for ( n = 0; s[n]; ++n )
@@ -5368,14 +5515,14 @@
 }
 #endif
 
-void *pcap_alloc (yy_size_t  size , yyscan_t yyscanner)
+void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
 {
 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	(void)yyg;
 	return malloc(size);
 }
 
-void *pcap_realloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
+void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 {
 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	(void)yyg;
@@ -5390,17 +5537,16 @@
 	return realloc(ptr, size);
 }
 
-void pcap_free (void * ptr , yyscan_t yyscanner)
+void yyfree (void * ptr , yyscan_t yyscanner)
 {
 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 	(void)yyg;
-	free( (char *) ptr );	/* see pcap_realloc() for (char *) cast */
+	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
 }
 
 #define YYTABLES_NAME "yytables"
 
-#line 490 "scanner.l"
-
+#line 479 "scanner.l"
 
 
 /*
diff --git a/scanner.h b/scanner.h
index dc464bd..8efc470 100644
--- a/scanner.h
+++ b/scanner.h
@@ -39,11 +39,233 @@
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
 
+#ifdef yy_create_buffer
+#define pcap__create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer pcap__create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define pcap__delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer pcap__delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define pcap__scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer pcap__scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define pcap__scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string pcap__scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define pcap__scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes pcap__scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define pcap__init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer pcap__init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define pcap__flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer pcap__flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define pcap__load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state pcap__load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define pcap__switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer pcap__switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define pcap_push_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state pcap_push_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define pcap_pop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state pcap_pop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define pcap_ensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack pcap_ensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define pcap_lex_ALREADY_DEFINED
+#else
+#define yylex pcap_lex
+#endif
+
+#ifdef yyrestart
+#define pcap_restart_ALREADY_DEFINED
+#else
+#define yyrestart pcap_restart
+#endif
+
+#ifdef yylex_init
+#define pcap_lex_init_ALREADY_DEFINED
+#else
+#define yylex_init pcap_lex_init
+#endif
+
+#ifdef yylex_init_extra
+#define pcap_lex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra pcap_lex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define pcap_lex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy pcap_lex_destroy
+#endif
+
+#ifdef yyget_debug
+#define pcap_get_debug_ALREADY_DEFINED
+#else
+#define yyget_debug pcap_get_debug
+#endif
+
+#ifdef yyset_debug
+#define pcap_set_debug_ALREADY_DEFINED
+#else
+#define yyset_debug pcap_set_debug
+#endif
+
+#ifdef yyget_extra
+#define pcap_get_extra_ALREADY_DEFINED
+#else
+#define yyget_extra pcap_get_extra
+#endif
+
+#ifdef yyset_extra
+#define pcap_set_extra_ALREADY_DEFINED
+#else
+#define yyset_extra pcap_set_extra
+#endif
+
+#ifdef yyget_in
+#define pcap_get_in_ALREADY_DEFINED
+#else
+#define yyget_in pcap_get_in
+#endif
+
+#ifdef yyset_in
+#define pcap_set_in_ALREADY_DEFINED
+#else
+#define yyset_in pcap_set_in
+#endif
+
+#ifdef yyget_out
+#define pcap_get_out_ALREADY_DEFINED
+#else
+#define yyget_out pcap_get_out
+#endif
+
+#ifdef yyset_out
+#define pcap_set_out_ALREADY_DEFINED
+#else
+#define yyset_out pcap_set_out
+#endif
+
+#ifdef yyget_leng
+#define pcap_get_leng_ALREADY_DEFINED
+#else
+#define yyget_leng pcap_get_leng
+#endif
+
+#ifdef yyget_text
+#define pcap_get_text_ALREADY_DEFINED
+#else
+#define yyget_text pcap_get_text
+#endif
+
+#ifdef yyget_lineno
+#define pcap_get_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno pcap_get_lineno
+#endif
+
+#ifdef yyset_lineno
+#define pcap_set_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno pcap_set_lineno
+#endif
+
+#ifdef yyget_column
+#define pcap_get_column_ALREADY_DEFINED
+#else
+#define yyget_column pcap_get_column
+#endif
+
+#ifdef yyset_column
+#define pcap_set_column_ALREADY_DEFINED
+#else
+#define yyset_column pcap_set_column
+#endif
+
+#ifdef yywrap
+#define pcap_wrap_ALREADY_DEFINED
+#else
+#define yywrap pcap_wrap
+#endif
+
+#ifdef yyget_lval
+#define pcap_get_lval_ALREADY_DEFINED
+#else
+#define yyget_lval pcap_get_lval
+#endif
+
+#ifdef yyset_lval
+#define pcap_set_lval_ALREADY_DEFINED
+#else
+#define yyset_lval pcap_set_lval
+#endif
+
+#ifdef yyalloc
+#define pcap_alloc_ALREADY_DEFINED
+#else
+#define yyalloc pcap_alloc
+#endif
+
+#ifdef yyrealloc
+#define pcap_realloc_ALREADY_DEFINED
+#else
+#define yyrealloc pcap_realloc
+#endif
+
+#ifdef yyfree
+#define pcap_free_ALREADY_DEFINED
+#else
+#define yyfree pcap_free
+#endif
+
 /* First, we deal with  platform-specific or compiler-specific issues. */
 
 /* begin standard C headers. */
@@ -114,10 +336,16 @@
 #define UINT32_MAX             (4294967295U)
 #endif
 
+#ifndef SIZE_MAX
+#define SIZE_MAX               (~(size_t)0)
+#endif
+
 #endif /* ! C99 */
 
 #endif /* ! FLEXINT_H */
 
+/* begin standard C++ headers. */
+
 /* TODO: this is always defined, so inline it */
 #define yyconst const
 
@@ -218,21 +446,21 @@
 	};
 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
 
-void pcap_restart (FILE *input_file ,yyscan_t yyscanner );
-void pcap__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE pcap__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void pcap__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void pcap__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void pcap_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void pcap_pop_buffer_state (yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
 
-YY_BUFFER_STATE pcap__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE pcap__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE pcap__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
 
-void *pcap_alloc (yy_size_t ,yyscan_t yyscanner );
-void *pcap_realloc (void *,yy_size_t ,yyscan_t yyscanner );
-void pcap_free (void * ,yyscan_t yyscanner );
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
 
 /* Begin user sect3 */
 
@@ -256,46 +484,46 @@
 
 #define YY_EXTRA_TYPE compiler_state_t *
 
-int pcap_lex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
 
-int pcap_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
 
 /* Accessor methods to globals.
    These are made visible to non-reentrant scanners for convenience. */
 
-int pcap_lex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
 
-int pcap_get_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
 
-void pcap_set_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
 
-YY_EXTRA_TYPE pcap_get_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
 
-void pcap_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
 
-FILE *pcap_get_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
 
-void pcap_set_in  (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
 
-FILE *pcap_get_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
 
-void pcap_set_out  (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
 
-			int pcap_get_leng (yyscan_t yyscanner );
+			int yyget_leng ( yyscan_t yyscanner );
 
-char *pcap_get_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
 
-int pcap_get_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
 
-void pcap_set_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
 
-int pcap_get_column  (yyscan_t yyscanner );
+int yyget_column  ( yyscan_t yyscanner );
 
-void pcap_set_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
 
-YYSTYPE * pcap_get_lval (yyscan_t yyscanner );
+YYSTYPE * yyget_lval ( yyscan_t yyscanner );
 
-void pcap_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
+void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -303,18 +531,18 @@
 
 #ifndef YY_SKIP_YYWRAP
 #ifdef __cplusplus
-extern "C" int pcap_wrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
 #else
-extern int pcap_wrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
 #endif
 #endif
 
 #ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
 #endif
 
 #ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
 #endif
 
 #ifndef YY_NO_INPUT
@@ -342,10 +570,10 @@
 #ifndef YY_DECL
 #define YY_DECL_IS_OURS 1
 
-extern int pcap_lex \
-               (YYSTYPE * yylval_param ,yyscan_t yyscanner);
+extern int yylex \
+               (YYSTYPE * yylval_param , yyscan_t yyscanner);
 
-#define YY_DECL int pcap_lex \
+#define YY_DECL int yylex \
                (YYSTYPE * yylval_param , yyscan_t yyscanner)
 #endif /* !YY_DECL */
 
@@ -363,9 +591,154 @@
 #undef YY_DECL
 #endif
 
-#line 490 "scanner.l"
+#ifndef pcap__create_buffer_ALREADY_DEFINED
+#undef yy_create_buffer
+#endif
+#ifndef pcap__delete_buffer_ALREADY_DEFINED
+#undef yy_delete_buffer
+#endif
+#ifndef pcap__scan_buffer_ALREADY_DEFINED
+#undef yy_scan_buffer
+#endif
+#ifndef pcap__scan_string_ALREADY_DEFINED
+#undef yy_scan_string
+#endif
+#ifndef pcap__scan_bytes_ALREADY_DEFINED
+#undef yy_scan_bytes
+#endif
+#ifndef pcap__init_buffer_ALREADY_DEFINED
+#undef yy_init_buffer
+#endif
+#ifndef pcap__flush_buffer_ALREADY_DEFINED
+#undef yy_flush_buffer
+#endif
+#ifndef pcap__load_buffer_state_ALREADY_DEFINED
+#undef yy_load_buffer_state
+#endif
+#ifndef pcap__switch_to_buffer_ALREADY_DEFINED
+#undef yy_switch_to_buffer
+#endif
+#ifndef pcap_push_buffer_state_ALREADY_DEFINED
+#undef yypush_buffer_state
+#endif
+#ifndef pcap_pop_buffer_state_ALREADY_DEFINED
+#undef yypop_buffer_state
+#endif
+#ifndef pcap_ensure_buffer_stack_ALREADY_DEFINED
+#undef yyensure_buffer_stack
+#endif
+#ifndef pcap_lex_ALREADY_DEFINED
+#undef yylex
+#endif
+#ifndef pcap_restart_ALREADY_DEFINED
+#undef yyrestart
+#endif
+#ifndef pcap_lex_init_ALREADY_DEFINED
+#undef yylex_init
+#endif
+#ifndef pcap_lex_init_extra_ALREADY_DEFINED
+#undef yylex_init_extra
+#endif
+#ifndef pcap_lex_destroy_ALREADY_DEFINED
+#undef yylex_destroy
+#endif
+#ifndef pcap_get_debug_ALREADY_DEFINED
+#undef yyget_debug
+#endif
+#ifndef pcap_set_debug_ALREADY_DEFINED
+#undef yyset_debug
+#endif
+#ifndef pcap_get_extra_ALREADY_DEFINED
+#undef yyget_extra
+#endif
+#ifndef pcap_set_extra_ALREADY_DEFINED
+#undef yyset_extra
+#endif
+#ifndef pcap_get_in_ALREADY_DEFINED
+#undef yyget_in
+#endif
+#ifndef pcap_set_in_ALREADY_DEFINED
+#undef yyset_in
+#endif
+#ifndef pcap_get_out_ALREADY_DEFINED
+#undef yyget_out
+#endif
+#ifndef pcap_set_out_ALREADY_DEFINED
+#undef yyset_out
+#endif
+#ifndef pcap_get_leng_ALREADY_DEFINED
+#undef yyget_leng
+#endif
+#ifndef pcap_get_text_ALREADY_DEFINED
+#undef yyget_text
+#endif
+#ifndef pcap_get_lineno_ALREADY_DEFINED
+#undef yyget_lineno
+#endif
+#ifndef pcap_set_lineno_ALREADY_DEFINED
+#undef yyset_lineno
+#endif
+#ifndef pcap_get_column_ALREADY_DEFINED
+#undef yyget_column
+#endif
+#ifndef pcap_set_column_ALREADY_DEFINED
+#undef yyset_column
+#endif
+#ifndef pcap_wrap_ALREADY_DEFINED
+#undef yywrap
+#endif
+#ifndef pcap_get_lval_ALREADY_DEFINED
+#undef yyget_lval
+#endif
+#ifndef pcap_set_lval_ALREADY_DEFINED
+#undef yyset_lval
+#endif
+#ifndef pcap_get_lloc_ALREADY_DEFINED
+#undef yyget_lloc
+#endif
+#ifndef pcap_set_lloc_ALREADY_DEFINED
+#undef yyset_lloc
+#endif
+#ifndef pcap_alloc_ALREADY_DEFINED
+#undef yyalloc
+#endif
+#ifndef pcap_realloc_ALREADY_DEFINED
+#undef yyrealloc
+#endif
+#ifndef pcap_free_ALREADY_DEFINED
+#undef yyfree
+#endif
+#ifndef pcap_text_ALREADY_DEFINED
+#undef yytext
+#endif
+#ifndef pcap_leng_ALREADY_DEFINED
+#undef yyleng
+#endif
+#ifndef pcap_in_ALREADY_DEFINED
+#undef yyin
+#endif
+#ifndef pcap_out_ALREADY_DEFINED
+#undef yyout
+#endif
+#ifndef pcap__flex_debug_ALREADY_DEFINED
+#undef yy_flex_debug
+#endif
+#ifndef pcap_lineno_ALREADY_DEFINED
+#undef yylineno
+#endif
+#ifndef pcap_tables_fload_ALREADY_DEFINED
+#undef yytables_fload
+#endif
+#ifndef pcap_tables_destroy_ALREADY_DEFINED
+#undef yytables_destroy
+#endif
+#ifndef pcap_TABLES_NAME_ALREADY_DEFINED
+#undef yyTABLES_NAME
+#endif
+
+#line 479 "scanner.l"
 
 
-#line 370 "scanner.h"
+#line 743 "scanner.h"
 #undef pcap_IN_HEADER
 #endif /* pcap_HEADER_H */
diff --git a/scanner.l b/scanner.l
index e0890b4..effcf81 100644
--- a/scanner.l
+++ b/scanner.l
@@ -311,13 +311,7 @@
 port		return PORT;
 portrange	return PORTRANGE;
 proto		return PROTO;
-protochain	{
-#ifdef NO_PROTOCHAIN
-		  bpf_error(yyextra, "%s not supported", yytext);
-#else
-		  return PROTOCHAIN;
-#endif
-		}
+protochain	return PROTOCHAIN;
 
 gateway		return GATEWAY;
 
@@ -397,14 +391,8 @@
 "=="			return '=';
 "<<"			return LSH;
 ">>"			return RSH;
-${B}			{ yylval->e = pcap_ether_aton(((char *)yytext)+1);
-			  if (yylval->e == NULL)
-				bpf_error(yyextra, "malloc");
-			  return AID; }
-{MAC}			{ yylval->e = pcap_ether_aton((char *)yytext);
-			  if (yylval->e == NULL)
-				bpf_error(yyextra, "malloc");
-			  return EID; }
+${B}			{ yylval->s = sdup(yyextra, yytext); return AID; }
+{MAC}			{ yylval->s = sdup(yyextra, yytext); return EID; }
 {N}			{ yylval->i = stoi((char *)yytext); return NUM; }
 ({N}\.{N})|({N}\.{N}\.{N})|({N}\.{N}\.{N}\.{N})	{
 			yylval->s = sdup(yyextra, (char *)yytext); return HID; }
@@ -414,17 +402,20 @@
 			  memset(&hints, 0, sizeof(hints));
 			  hints.ai_family = AF_INET6;
 			  hints.ai_flags = AI_NUMERICHOST;
-			  if (getaddrinfo(yytext, NULL, &hints, &res))
-				bpf_error(yyextra, "bogus IPv6 address %s", yytext);
-			  else {
+			  if (getaddrinfo(yytext, NULL, &hints, &res)) {
+				bpf_set_error(yyextra, "bogus IPv6 address %s", yytext);
+				yylval->s = NULL;
+			  } else {
 				freeaddrinfo(res);
-				yylval->s = sdup(yyextra, (char *)yytext); return HID6;
+				yylval->s = sdup(yyextra, (char *)yytext);
 			  }
 #else
-			  bpf_error(yyextra, "IPv6 address %s not supported", yytext);
+			  bpf_set_error(yyextra, "IPv6 address %s not supported", yytext);
+			  yylval->s = NULL;
 #endif /*INET6*/
+			  return HID6;
 			}
-{B}:+({B}:+)+		{ bpf_error(yyextra, "bogus ethernet address %s", yytext); }
+{B}:+({B}:+)+		{ bpf_set_error(yyextra, "bogus ethernet address %s", yytext); yylval->s = NULL; return EID; }
 icmptype		{ yylval->i = 0; return NUM; }
 icmpcode		{ yylval->i = 1; return NUM; }
 icmp-echoreply		{ yylval->i = 0; return NUM; }
@@ -484,9 +475,7 @@
 [A-Za-z0-9]([-_.A-Za-z0-9]*[.A-Za-z0-9])? {
 			 yylval->s = sdup(yyextra, (char *)yytext); return ID; }
 "\\"[^ !()\n\t]+	{ yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; }
-[^ \[\]\t\n\-_.A-Za-z0-9!<>()&|=]+ {
-			bpf_error(yyextra, "illegal token: %s", yytext); }
-.			{ bpf_error(yyextra, "illegal char '%c'", *yytext); }
+.			{ return LEX_ERROR; }
 %%
 
 /*
diff --git a/sf-pcap.c b/sf-pcap.c
index 96cb308..60c73a8 100644
--- a/sf-pcap.c
+++ b/sf-pcap.c
@@ -43,6 +43,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <limits.h> /* for INT_MAX */
 
 #include "pcap-int.h"
 
@@ -109,6 +110,20 @@
 
 static int pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **datap);
 
+#ifdef _WIN32
+/*
+ * This isn't exported on Windows, because it would only work if both
+ * libpcap and the code using it were using the same C runtime; otherwise they
+ * would be using different definitions of a FILE structure.
+ *
+ * Instead we define this as a macro in pcap/pcap.h that wraps the hopen
+ * version that we do export, passing it a raw OS HANDLE, as defined by the
+ * Win32 / Win64 ABI, obtained from the _fileno() and _get_osfhandle()
+ * functions of the appropriate CRT.
+ */
+static pcap_dumper_t *pcap_dump_fopen(pcap_t *p, FILE *f);
+#endif /* _WIN32 */
+
 /*
  * Private data for reading pcap savefiles.
  */
@@ -135,9 +150,10 @@
  * relevant information from the header.
  */
 pcap_t *
-pcap_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf,
+pcap_check_header(const uint8_t *magic, FILE *fp, u_int precision, char *errbuf,
 		  int *err)
 {
+	bpf_u_int32 magic_int;
 	struct pcap_file_header hdr;
 	size_t amt_read;
 	pcap_t *p;
@@ -154,11 +170,14 @@
 	 * number for a pcap savefile, or for a byte-swapped pcap
 	 * savefile.
 	 */
-	if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC &&
-	    magic != NSEC_TCPDUMP_MAGIC) {
-		magic = SWAPLONG(magic);
-		if (magic != TCPDUMP_MAGIC && magic != KUZNETZOV_TCPDUMP_MAGIC &&
-		    magic != NSEC_TCPDUMP_MAGIC)
+	memcpy(&magic_int, magic, sizeof(magic_int));
+	if (magic_int != TCPDUMP_MAGIC &&
+	    magic_int != KUZNETZOV_TCPDUMP_MAGIC &&
+	    magic_int != NSEC_TCPDUMP_MAGIC) {
+		magic_int = SWAPLONG(magic_int);
+		if (magic_int != TCPDUMP_MAGIC &&
+		    magic_int != KUZNETZOV_TCPDUMP_MAGIC &&
+		    magic_int != NSEC_TCPDUMP_MAGIC)
 			return (NULL);	/* nope */
 		swapped = 1;
 	}
@@ -167,7 +186,7 @@
 	 * They are.  Put the magic number in the header, and read
 	 * the rest of the header.
 	 */
-	hdr.magic = magic;
+	hdr.magic = magic_int;
 	amt_read = fread(((char *)&hdr) + sizeof hdr.magic, 1,
 	    sizeof(hdr) - sizeof(hdr.magic), fp);
 	if (amt_read != sizeof(hdr) - sizeof(hdr.magic)) {
@@ -176,9 +195,8 @@
 			    errno, "error reading dump file");
 		} else {
 			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-			    "truncated dump file; tried to read %lu file header bytes, only got %lu",
-			    (unsigned long)sizeof(hdr),
-			    (unsigned long)amt_read);
+			    "truncated dump file; tried to read %" PRIsize " file header bytes, only got %" PRIsize,
+			    sizeof(hdr), amt_read);
 		}
 		*err = 1;
 		return (NULL);
@@ -232,20 +250,9 @@
 	p->version_major = hdr.version_major;
 	p->version_minor = hdr.version_minor;
 	p->tzoff = hdr.thiszone;
-	p->snapshot = hdr.snaplen;
-	if (p->snapshot <= 0) {
-		/*
-		 * Bogus snapshot length; use the maximum for this
-		 * link-layer type as a fallback.
-		 *
-		 * XXX - the only reason why snapshot is signed is
-		 * that pcap_snapshot() returns an int, not an
-		 * unsigned int.
-		 */
-		p->snapshot = max_snaplen_for_dlt(hdr.linktype);
-	}
 	p->linktype = linktype_to_dlt(LT_LINKTYPE(hdr.linktype));
 	p->linktype_ext = LT_LINKTYPE_EXT(hdr.linktype);
+	p->snapshot = pcap_adjust_snapshot(p->linktype, hdr.snaplen);
 
 	p->next_packet_op = pcap_next_packet;
 
@@ -260,7 +267,7 @@
 	switch (precision) {
 
 	case PCAP_TSTAMP_PRECISION_MICRO:
-		if (magic == NSEC_TCPDUMP_MAGIC) {
+		if (magic_int == NSEC_TCPDUMP_MAGIC) {
 			/*
 			 * The file has nanoseconds, the user
 			 * wants microseconds; scale the
@@ -277,7 +284,7 @@
 		break;
 
 	case PCAP_TSTAMP_PRECISION_NANO:
-		if (magic == NSEC_TCPDUMP_MAGIC) {
+		if (magic_int == NSEC_TCPDUMP_MAGIC) {
 			/*
 			 * The file has nanoseconds, the
 			 * user wants nanoseconds; nothing to do.
@@ -331,7 +338,7 @@
 		break;
 	}
 
-	if (magic == KUZNETZOV_TCPDUMP_MAGIC) {
+	if (magic_int == KUZNETZOV_TCPDUMP_MAGIC) {
 		/*
 		 * XXX - the patch that's in some versions of libpcap
 		 * changes the packet header but not the magic number,
@@ -371,8 +378,14 @@
 			 * length will be misleading if you use it to figure
 			 * out why a capture doesn't have all the packet data,
 			 * but there's not much we can do to avoid that.
+			 *
+			 * But don't grow the snapshot length past the
+			 * maximum value of an int.
 			 */
-			p->snapshot += 14;
+			if (p->snapshot <= INT_MAX - 14)
+				p->snapshot += 14;
+			else
+				p->snapshot = INT_MAX;
 		}
 	} else
 		ps->hdrsize = sizeof(struct pcap_sf_pkthdr);
@@ -450,9 +463,8 @@
 		} else {
 			if (amt_read != 0) {
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-				    "truncated dump file; tried to read %lu header bytes, only got %lu",
-				    (unsigned long)ps->hdrsize,
-				    (unsigned long)amt_read);
+				    "truncated dump file; tried to read %" PRIsize " header bytes, only got %" PRIsize,
+				    ps->hdrsize, amt_read);
 				return (-1);
 			}
 			/* EOF */
@@ -611,8 +623,8 @@
 				 * the read finished.
 				 */
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-				    "truncated dump file; tried to read %u captured bytes, only got %lu",
-				    p->snapshot, (unsigned long)amt_read);
+				    "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+				    p->snapshot, amt_read);
 			}
 			return (-1);
 		}
@@ -635,8 +647,8 @@
 					    "error reading dump file");
 				} else {
 					pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-					    "truncated dump file; tried to read %u captured bytes, only got %lu",
-					    hdr->caplen, (unsigned long)bytes_read);
+					    "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+					    hdr->caplen, bytes_read);
 				}
 				return (-1);
 			}
@@ -649,6 +661,9 @@
 		 */
 		hdr->caplen = p->snapshot;
 	} else {
+		/*
+		 * The packet is within the snapshot length for this file.
+		 */
 		if (hdr->caplen > p->bufsize) {
 			/*
 			 * Grow the buffer to the next power of 2, or
@@ -684,8 +699,8 @@
 				    "error reading dump file");
 			} else {
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-				    "truncated dump file; tried to read %u captured bytes, only got %lu",
-				    hdr->caplen, (unsigned long)amt_read);
+				    "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+				    hdr->caplen, amt_read);
 			}
 			return (-1);
 		}
@@ -817,9 +832,42 @@
 	return (pcap_setup_dump(p, linktype, f, fname));
 }
 
+#ifdef _WIN32
+/*
+ * Initialize so that sf_write() will output to a stream wrapping the given raw
+ * OS file HANDLE.
+ */
+pcap_dumper_t *
+pcap_dump_hopen(pcap_t *p, intptr_t osfd)
+{
+	int fd;
+	FILE *file;
+
+	fd = _open_osfhandle(osfd, _O_APPEND);
+	if (fd < 0) {
+		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+		    errno, "_open_osfhandle");
+		return NULL;
+	}
+
+	file = _fdopen(fd, "wb");
+	if (file == NULL) {
+		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+		    errno, "_fdopen");
+		_close(fd);
+		return NULL;
+	}
+
+	return pcap_dump_fopen(p, file);
+}
+#endif /* _WIN32 */
+
 /*
  * Initialize so that sf_write() will output to the given stream.
  */
+#ifdef _WIN32
+static
+#endif /* _WIN32 */
 pcap_dumper_t *
 pcap_dump_fopen(pcap_t *p, FILE *f)
 {
@@ -862,11 +910,19 @@
 		return (pcap_setup_dump(p, linktype, stdout, "standard output"));
 
 	/*
+	 * "a" will cause the file *not* to be truncated if it exists
+	 * but will cause it to be created if it doesn't.  It will
+	 * also cause all writes to be done at the end of the file,
+	 * but will allow reads to be done anywhere in the file.  This
+	 * is what we need, because we need to read from the beginning
+	 * of the file to see if it already has a header and packets
+	 * or if it doesn't.
+	 *
 	 * "b" is supported as of C90, so *all* UN*Xes should support it,
 	 * even though it does nothing.  It's required on Windows, as the
 	 * file is a binary file and must be read in binary mode.
 	 */
-	f = fopen(fname, "rb+");
+	f = fopen(fname, "ab+");
 	if (f == NULL) {
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 		    errno, "%s", fname);
@@ -875,18 +931,33 @@
 
 	/*
 	 * Try to read a pcap header.
+	 *
+	 * We do not assume that the file will be positioned at the
+	 * beginning immediately after we've opened it - we seek to
+	 * the beginning.  ISO C says it's implementation-defined
+	 * whether the file position indicator is at the beginning
+	 * or the end of the file after an append-mode open, and
+	 * it wasn't obvious from the Single UNIX Specification
+	 * or the Microsoft documentation how that works on SUS-
+	 * compliant systems or on Windows.
 	 */
+	if (fseek(f, 0, SEEK_SET) == -1) {
+		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+		    errno, "Can't seek to the beginning of %s", fname);
+		(void)fclose(f);
+		return (NULL);
+	}
 	amt_read = fread(&ph, 1, sizeof (ph), f);
 	if (amt_read != sizeof (ph)) {
 		if (ferror(f)) {
 			pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
 			    errno, "%s", fname);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 		} else if (feof(f) && amt_read > 0) {
 			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 			    "%s: truncated pcap file header", fname);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 		}
 	}
@@ -922,7 +993,7 @@
 			if (p->opt.tstamp_precision != PCAP_TSTAMP_PRECISION_MICRO) {
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 				    "%s: different time stamp precision, cannot append to file", fname);
-				fclose(f);
+				(void)fclose(f);
 				return (NULL);
 			}
 			break;
@@ -931,7 +1002,7 @@
 			if (p->opt.tstamp_precision != PCAP_TSTAMP_PRECISION_NANO) {
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 				    "%s: different time stamp precision, cannot append to file", fname);
-				fclose(f);
+				(void)fclose(f);
 				return (NULL);
 			}
 			break;
@@ -940,7 +1011,7 @@
 		case SWAPLONG(NSEC_TCPDUMP_MAGIC):
 			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 			    "%s: different byte order, cannot append to file", fname);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 
 		case KUZNETZOV_TCPDUMP_MAGIC:
@@ -949,13 +1020,13 @@
 		case SWAPLONG(NAVTEL_TCPDUMP_MAGIC):
 			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 			    "%s: not a pcap file to which we can append", fname);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 
 		default:
 			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 			    "%s: not a pcap file", fname);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 		}
 
@@ -967,19 +1038,19 @@
 			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 			    "%s: version is %u.%u, cannot append to file", fname,
 			    ph.version_major, ph.version_minor);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 		}
 		if ((bpf_u_int32)linktype != ph.linktype) {
 			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 			    "%s: different linktype, cannot append to file", fname);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 		}
 		if ((bpf_u_int32)p->snapshot != ph.snaplen) {
 			pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 			    "%s: different snaplen, cannot append to file", fname);
-			fclose(f);
+			(void)fclose(f);
 			return (NULL);
 		}
 	} else {
@@ -996,10 +1067,14 @@
 
 	/*
 	 * Start writing at the end of the file.
+	 *
+	 * XXX - this shouldn't be necessary, given that we're opening
+	 * the file in append mode, and ISO C specifies that all writes
+	 * are done at the end of the file in that mode.
 	 */
 	if (fseek(f, 0, SEEK_END) == -1) {
 		pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
-		    errno, "Can't seek to end of %s", fname);
+		    errno, "Can't seek to the end of %s", fname);
 		(void)fclose(f);
 		return (NULL);
 	}
diff --git a/sf-pcap.h b/sf-pcap.h
index e9c7eaf..bc7150f 100644
--- a/sf-pcap.h
+++ b/sf-pcap.h
@@ -31,7 +31,7 @@
 #ifndef sf_pcap_h
 #define	sf_pcap_h
 
-extern pcap_t *pcap_check_header(bpf_u_int32 magic, FILE *fp,
+extern pcap_t *pcap_check_header(const uint8_t *magic, FILE *fp,
     u_int precision, char *errbuf, int *err);
 
 #endif
diff --git a/sf-pcapng.c b/sf-pcapng.c
index 8c8e93e..afaeb05 100644
--- a/sf-pcapng.c
+++ b/sf-pcapng.c
@@ -85,7 +85,7 @@
  * Section Header Block.
  */
 #define BT_SHB			0x0A0D0D0A
-
+#define BT_SHB_INSANE_MAX       1024U*1024U*1U  /* 1MB should be enough */
 struct section_header_block {
 	bpf_u_int32	byte_order_magic;
 	u_short		major_version;
@@ -231,16 +231,21 @@
 };
 
 /*
- * Maximum block size for a given maximum snapshot length; we calculate
- * this based
- *
- * We define it as the size of an EPB with a max_snaplen-sized
- * packet and 128KB of options.
+ * The maximum block size we start with; we use an arbitrary value of
+ * 16 MiB.
  */
-#define MAX_BLOCKSIZE(max_snaplen)	(sizeof (struct block_header) + \
-					 sizeof (struct enhanced_packet_block) + \
-					 (max_snaplen) + 131072 + \
-					 sizeof (struct block_trailer))
+#define INITIAL_MAX_BLOCKSIZE	(16*1024*1024)
+
+/*
+ * Maximum block size for a given maximum snapshot length; we define it
+ * as the size of an EPB with a max_snaplen-sized packet and 128KB of
+ * options.
+ */
+#define MAX_BLOCKSIZE_FOR_SNAPLEN(max_snaplen) \
+	(sizeof (struct block_header) + \
+	 sizeof (struct enhanced_packet_block) + \
+	 (max_snaplen) + 131072 + \
+	 sizeof (struct block_trailer))
 
 static void pcap_ng_cleanup(pcap_t *p);
 static int pcap_ng_next_packet(pcap_t *p, struct pcap_pkthdr *hdr,
@@ -261,9 +266,8 @@
 			if (amt_read == 0 && !fail_on_eof)
 				return (0);	/* EOF */
 			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-			    "truncated dump file; tried to read %lu bytes, only got %lu",
-			    (unsigned long)bytes_to_read,
-			    (unsigned long)amt_read);
+			    "truncated pcapng dump file; tried to read %" PRIsize " bytes, only got %" PRIsize,
+			    bytes_to_read, amt_read);
 		}
 		return (-1);
 	}
@@ -276,6 +280,7 @@
 	struct pcap_ng_sf *ps;
 	int status;
 	struct block_header bhdr;
+	struct block_trailer *btrlr;
 	u_char *bdata;
 	size_t data_remaining;
 
@@ -291,29 +296,28 @@
 	}
 
 	/*
-	 * Is this block "too big"?
-	 *
-	 * We choose 16MB as "too big", for now, so that we handle
-	 * "reasonably" large buffers but don't chew up all the
-	 * memory if we read a malformed file.
-	 */
-	if (bhdr.total_length > 16*1024*1024) {
-		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-		    "pcapng block size %u > maximum %u",
-		    bhdr.total_length, 16*1024*1024);
-		    return (-1);
-	}
-
-	/*
 	 * Is this block "too small" - i.e., is it shorter than a block
 	 * header plus a block trailer?
 	 */
 	if (bhdr.total_length < sizeof(struct block_header) +
 	    sizeof(struct block_trailer)) {
 		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-		    "block in pcapng dump file has a length of %u < %lu",
+		    "block in pcapng dump file has a length of %u < %" PRIsize,
 		    bhdr.total_length,
-		    (unsigned long)(sizeof(struct block_header) + sizeof(struct block_trailer)));
+		    sizeof(struct block_header) + sizeof(struct block_trailer));
+		return (-1);
+	}
+
+	/*
+	 * Is the block total length a multiple of 4?
+	 */
+	if ((bhdr.total_length % 4) != 0) {
+		/*
+		 * No.  Report that as an error.
+		 */
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+		    "block in pcapng dump file has a length of %u that is not a multiple of 4" PRIsize,
+		    bhdr.total_length);
 		return (-1);
 	}
 
@@ -322,12 +326,13 @@
 	 */
 	if (p->bufsize < bhdr.total_length) {
 		/*
-		 * No - make it big enough, unless it's too big.
+		 * No - make it big enough, unless it's too big, in
+		 * which case we fail.
 		 */
 		void *bigger_buffer;
 
 		if (bhdr.total_length > ps->max_blocksize) {
-			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "block is larger than maximum block size %u",
+			pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "pcapng block size %u > maximum %u", bhdr.total_length,
 			    ps->max_blocksize);
 			return (-1);
 		}
@@ -350,6 +355,26 @@
 		return (-1);
 
 	/*
+	 * Get the block size from the trailer.
+	 */
+	btrlr = (struct block_trailer *)(bdata + data_remaining - sizeof (struct block_trailer));
+	if (p->swapped)
+		btrlr->total_length = SWAPLONG(btrlr->total_length);
+
+	/*
+	 * Is the total length from the trailer the same as the total
+	 * length from the header?
+	 */
+	if (bhdr.total_length != btrlr->total_length) {
+		/*
+		 * No.
+		 */
+		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
+		    "block total length in header and trailer don't match");
+		return (-1);
+	}
+
+	/*
 	 * Initialize the cursor.
 	 */
 	cursor->data = bdata;
@@ -736,9 +761,10 @@
  * relevant information from the header.
  */
 pcap_t *
-pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf,
-    int *err)
+pcap_ng_check_header(const uint8_t *magic, FILE *fp, u_int precision,
+    char *errbuf, int *err)
 {
+	bpf_u_int32 magic_int;
 	size_t amt_read;
 	bpf_u_int32 total_length;
 	bpf_u_int32 byte_order_magic;
@@ -760,7 +786,8 @@
 	 * Check whether the first 4 bytes of the file are the block
 	 * type for a pcapng savefile.
 	 */
-	if (magic != BT_SHB) {
+	memcpy(&magic_int, magic, sizeof(magic_int));
+	if (magic_int != BT_SHB) {
 		/*
 		 * XXX - check whether this looks like what the block
 		 * type would be after being munged by mapping between
@@ -829,11 +856,14 @@
 	/*
 	 * Check the sanity of the total length.
 	 */
-	if (total_length < sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)) {
+	if (total_length < sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer) ||
+            (total_length > BT_SHB_INSANE_MAX)) {
 		pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-		    "Section Header Block in pcapng dump file has a length of %u < %lu",
+		    "Section Header Block in pcapng dump file has invalid length %" PRIsize " < _%u_ < %u (BT_SHB_INSANE_MAX)",
+		    sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer),
 		    total_length,
-		    (unsigned long)(sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)));
+		    BT_SHB_INSANE_MAX);
+
 		*err = 1;
 		return (NULL);
 	}
@@ -885,10 +915,10 @@
 	 *	leaving room for some options.
 	 *
 	 * If we find a bigger block, we reallocate the buffer, up to
-	 * the maximum size.  We start out with a maximum size based
-	 * on a maximum snapshot length of MAXIMUM_SNAPLEN; if we see
-	 * any link-layer header types with a larger maximum snapshot
-	 * length, we boost the maximum.
+	 * the maximum size.  We start out with a maximum size of
+	 * INITIAL_MAX_BLOCKSIZE; if we see any link-layer header types
+	 * with a maximum snapshot that results in a larger maximum
+	 * block length, we boost the maximum.
 	 */
 	p->bufsize = 2048;
 	if (p->bufsize < total_length)
@@ -900,7 +930,7 @@
 		*err = 1;
 		return (NULL);
 	}
-	ps->max_blocksize = MAX_BLOCKSIZE(MAXIMUM_SNAPLEN);
+	ps->max_blocksize = INITIAL_MAX_BLOCKSIZE;
 
 	/*
 	 * Copy the stuff we've read to the buffer, and read the rest
@@ -908,12 +938,12 @@
 	 */
 	bhdrp = (struct block_header *)p->buffer;
 	shbp = (struct section_header_block *)((u_char *)p->buffer + sizeof(struct block_header));
-	bhdrp->block_type = magic;
+	bhdrp->block_type = magic_int;
 	bhdrp->total_length = total_length;
 	shbp->byte_order_magic = byte_order_magic;
 	if (read_bytes(fp,
-	    (u_char *)p->buffer + (sizeof(magic) + sizeof(total_length) + sizeof(byte_order_magic)),
-	    total_length - (sizeof(magic) + sizeof(total_length) + sizeof(byte_order_magic)),
+	    (u_char *)p->buffer + (sizeof(magic_int) + sizeof(total_length) + sizeof(byte_order_magic)),
+	    total_length - (sizeof(magic_int) + sizeof(total_length) + sizeof(byte_order_magic)),
 	    1, errbuf) == -1)
 		goto fail;
 
@@ -1010,19 +1040,8 @@
 
 done:
 	p->tzoff = 0;	/* XXX - not used in pcap */
-	p->snapshot = idbp->snaplen;
-	if (p->snapshot <= 0) {
-		/*
-		 * Bogus snapshot length; use the maximum for this
-		 * link-layer type as a fallback.
-		 *
-		 * XXX - the only reason why snapshot is signed is
-		 * that pcap_snapshot() returns an int, not an
-		 * unsigned int.
-		 */
-		p->snapshot = max_snaplen_for_dlt(idbp->linktype);
-	}
 	p->linktype = linktype_to_dlt(idbp->linktype);
+	p->snapshot = pcap_adjust_snapshot(p->linktype, idbp->snaplen);
 	p->linktype_ext = 0;
 
 	/*
@@ -1030,8 +1049,8 @@
 	 * snapshot length for this DLT_ is bigger than the current
 	 * maximum block size, increase the maximum.
 	 */
-	if (MAX_BLOCKSIZE(max_snaplen_for_dlt(p->linktype)) > ps->max_blocksize)
-		ps->max_blocksize = MAX_BLOCKSIZE(max_snaplen_for_dlt(p->linktype));
+	if (MAX_BLOCKSIZE_FOR_SNAPLEN(max_snaplen_for_dlt(p->linktype)) > ps->max_blocksize)
+		ps->max_blocksize = MAX_BLOCKSIZE_FOR_SNAPLEN(max_snaplen_for_dlt(p->linktype));
 
 	p->next_packet_op = pcap_ng_next_packet;
 	p->cleanup_op = pcap_ng_cleanup;
@@ -1217,7 +1236,13 @@
 				    idbp->linktype);
 				return (-1);
 			}
-			if ((bpf_u_int32)p->snapshot != idbp->snaplen) {
+
+			/*
+			 * Check against the *adjusted* value of this IDB's
+			 * snapshot length.
+			 */
+			if ((bpf_u_int32)p->snapshot !=
+			    pcap_adjust_snapshot(p->linktype, idbp->snaplen)) {
 				pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
 				    "an interface has a snapshot length %u different from the type of the first interface",
 				    idbp->snaplen);
diff --git a/sf-pcapng.h b/sf-pcapng.h
index d99b0d4..835082a 100644
--- a/sf-pcapng.h
+++ b/sf-pcapng.h
@@ -26,7 +26,7 @@
 #ifndef sf_pcapng_h
 #define	sf_pcapng_h
 
-extern pcap_t *pcap_ng_check_header(bpf_u_int32 magic, FILE *fp,
+extern pcap_t *pcap_ng_check_header(const uint8_t *magic, FILE *fp,
     u_int precision, char *errbuf, int *err);
 
 #endif
diff --git a/sockutils.c b/sockutils.c
index ef3fe76..d3e9464 100644
--- a/sockutils.c
+++ b/sockutils.c
@@ -130,44 +130,15 @@
  */
 void sock_fmterror(const char *caller, int errcode, char *errbuf, int errbuflen)
 {
+	if (errbuf == NULL)
+		return;
+
 #ifdef _WIN32
-	int retval;
-	char message[SOCK_ERRBUF_SIZE];	/* We're forcing "ANSI" */
-
-	if (errbuf == NULL)
-		return;
-
-	retval = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
-		FORMAT_MESSAGE_MAX_WIDTH_MASK,
-		NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-		message, sizeof(message) / sizeof(TCHAR), NULL);
-
-	if (retval == 0)
-	{
-		if ((caller) && (*caller))
-			pcap_snprintf(errbuf, errbuflen, "%sUnable to get the exact error message", caller);
-		else
-			pcap_snprintf(errbuf, errbuflen, "Unable to get the exact error message");
-	}
-	else
-	{
-		if ((caller) && (*caller))
-			pcap_snprintf(errbuf, errbuflen, "%s%s (code %d)", caller, message, errcode);
-		else
-			pcap_snprintf(errbuf, errbuflen, "%s (code %d)", message, errcode);
-	}
+	pcap_fmt_errmsg_for_win32_err(errbuf, errbuflen, errcode,
+	    "%s", caller);
 #else
-	char *message;
-
-	if (errbuf == NULL)
-		return;
-
-	message = strerror(errcode);
-
-	if ((caller) && (*caller))
-		pcap_snprintf(errbuf, errbuflen, "%s%s (code %d)", caller, message, errcode);
-	else
-		pcap_snprintf(errbuf, errbuflen, "%s (code %d)", message, errcode);
+	pcap_fmt_errmsg_for_errno(errbuf, errbuflen, errcode,
+	    "%s", caller);
 #endif
 }
 
@@ -180,7 +151,7 @@
  *
  * \param caller: a pointer to a user-allocated string which contains a message that has
  * to be printed *before* the true error message. It could be, for example, 'this error
- * comes from the recv() call at line 31'. It may be NULL.
+ * comes from the recv() call at line 31'.
  *
  * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
  * error message. This buffer has to be at least 'errbuflen' in length.
@@ -194,31 +165,30 @@
 void sock_geterror(const char *caller, char *errbuf, int errbuflen)
 {
 #ifdef _WIN32
-	if (errbuf == NULL)
-		return;
 	sock_fmterror(caller, GetLastError(), errbuf, errbuflen);
 #else
-	if (errbuf == NULL)
-		return;
 	sock_fmterror(caller, errno, errbuf, errbuflen);
 #endif
 }
 
 /*
- * \brief It initializes sockets.
+ * \brief This function initializes the socket mechanism if it hasn't
+ * already been initialized or reinitializes it after it has been
+ * cleaned up.
  *
- * This function is pretty useless on UNIX, since socket initialization is not required.
- * However it is required on Win32. In UNIX, this function appears to be completely empty.
+ * On UN*Xes, it doesn't need to do anything; on Windows, it needs to
+ * initialize Winsock.
  *
- * \param errbuf: a pointer to an user-allocated buffer that will contain the complete
- * error message. This buffer has to be at least 'errbuflen' in length.
- * It can be NULL; in this case the error cannot be printed.
+ * \param errbuf: a pointer to an user-allocated buffer that will contain
+ * the complete error message. This buffer has to be at least 'errbuflen'
+ * in length. It can be NULL; in this case no error message is supplied.
  *
- * \param errbuflen: length of the buffer that will contains the error. The error message cannot be
- * larger than 'errbuflen - 1' because the last char is reserved for the string terminator.
+ * \param errbuflen: length of the buffer that will contains the error.
+ * The error message cannot be larger than 'errbuflen - 1' because the
+ * last char is reserved for the string terminator.
  *
- * \return '0' if everything is fine, '-1' if some errors occurred. The error message is returned
- * in the 'errbuf' variable.
+ * \return '0' if everything is fine, '-1' if some errors occurred. The
+ * error message is returned in the buffer pointed to by 'errbuf' variable.
  */
 #ifdef _WIN32
 int sock_init(char *errbuf, int errbuflen)
@@ -240,18 +210,24 @@
 	}
 
 	sockcount++;
+	return 0;
+}
 #else
 int sock_init(char *errbuf _U_, int errbuflen _U_)
 {
-#endif
+	/*
+	 * Nothing to do on UN*Xes.
+	 */
 	return 0;
 }
+#endif
 
 /*
- * \brief It deallocates sockets.
+ * \brief This function cleans up the socket mechanism if we have no
+ * sockets left open.
  *
- * This function is pretty useless on UNIX, since socket deallocation is not required.
- * However it is required on Win32. In UNIX, this function appears to be completely empty.
+ * On UN*Xes, it doesn't need to do anything; on Windows, it needs
+ * to clean up Winsock.
  *
  * \return No error values.
  */
@@ -327,7 +303,7 @@
 	sock = socket(addrinfo->ai_family, addrinfo->ai_socktype, addrinfo->ai_protocol);
 	if (sock == INVALID_SOCKET)
 	{
-		sock_geterror("socket(): ", errbuf, errbuflen);
+		sock_geterror("socket()", errbuf, errbuflen);
 		return INVALID_SOCKET;
 	}
 
@@ -350,6 +326,16 @@
 	/* This is a server socket */
 	if (server)
 	{
+		/*
+		 * Allow a new server to bind the socket after the old one
+		 * exited, even if lingering sockets are still present.
+		 *
+		 * Don't treat an error as a failure.
+		 */
+		int optval = 1;
+		(void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+		    (char *)&optval, sizeof (optval));
+
 #if defined(IPV6_V6ONLY) || defined(IPV6_BINDV6ONLY)
 		/*
 		 * Force the use of IPv6-only addresses.
@@ -399,7 +385,7 @@
 		/* WARNING: if the address is a mcast one, I should place the proper Win32 code here */
 		if (bind(sock, addrinfo->ai_addr, (int) addrinfo->ai_addrlen) != 0)
 		{
-			sock_geterror("bind(): ", errbuf, errbuflen);
+			sock_geterror("bind()", errbuf, errbuflen);
 			closesocket(sock);
 			return INVALID_SOCKET;
 		}
@@ -407,7 +393,7 @@
 		if (addrinfo->ai_socktype == SOCK_STREAM)
 			if (listen(sock, nconn) == -1)
 			{
-				sock_geterror("listen(): ", errbuf, errbuflen);
+				sock_geterror("listen()", errbuf, errbuflen);
 				closesocket(sock);
 				return INVALID_SOCKET;
 			}
@@ -444,13 +430,14 @@
 				 * We have to retrieve the error message before any other socket call completes, otherwise
 				 * the error message is lost
 				 */
-				sock_geterror(NULL, SocketErrorMessage, sizeof(SocketErrorMessage));
+				sock_geterror("Connect to socket failed",
+				    SocketErrorMessage, sizeof(SocketErrorMessage));
 
 				/* Returns the numeric address of the host that triggered the error */
 				sock_getascii_addrport((struct sockaddr_storage *) tempaddrinfo->ai_addr, TmpBuffer, sizeof(TmpBuffer), NULL, 0, NI_NUMERICHOST, TmpBuffer, sizeof(TmpBuffer));
 
 				pcap_snprintf(errbufptr, bufspaceleft,
-				    "Is the server properly installed on %s?  connect() failed: %s", TmpBuffer, SocketErrorMessage);
+				    "Is the server properly installed on %s?  %s", TmpBuffer, SocketErrorMessage);
 
 				/* In case more then one 'connect' fails, we manage to keep all the error messages */
 				msglen = strlen(errbufptr);
@@ -508,7 +495,7 @@
 	 */
 	if (shutdown(sock, SHUT_WR))
 	{
-		sock_geterror("shutdown(): ", errbuf, errbuflen);
+		sock_geterror("shutdown()", errbuf, errbuflen);
 		/* close the socket anyway */
 		closesocket(sock);
 		return -1;
@@ -519,6 +506,157 @@
 }
 
 /*
+ * gai_errstring() 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*
+ *    thread-safe, so an implementation might use a static buffer
+ *    for unknown error codes;
+ * 3) the error message for the most likely error, EAI_NONAME, is
+ *    truly horrible on several platforms ("nodename nor servname
+ *    provided, or not known"?  It's typically going to be "not
+ *    known", not "oopsie, I passed null pointers for the host name
+ *    and service name", not to mention they forgot the "neither");
+ *
+ * so we roll our own.
+ */
+static void
+get_gai_errstring(char *errbuf, int errbuflen, const char *prefix, int err,
+    const char *hostname, const char *portname)
+{
+	char hostport[PCAP_ERRBUF_SIZE];
+
+	if (hostname != NULL && portname != NULL)
+		pcap_snprintf(hostport, PCAP_ERRBUF_SIZE, "%s:%s",
+		    hostname, portname);
+	else if (hostname != NULL)
+		pcap_snprintf(hostport, PCAP_ERRBUF_SIZE, "%s",
+		    hostname);
+	else if (portname != NULL)
+		pcap_snprintf(hostport, PCAP_ERRBUF_SIZE, ":%s",
+		    portname);
+	else
+		pcap_snprintf(hostport, PCAP_ERRBUF_SIZE, "<no host or port!>");
+	switch (err)
+	{
+#ifdef EAI_ADDRFAMILY
+		case EAI_ADDRFAMILY:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sAddress family for %s not supported",
+			    prefix, hostport);
+			break;
+#endif
+
+		case EAI_AGAIN:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%s%s could not be resolved at this time",
+			    prefix, hostport);
+			break;
+
+		case EAI_BADFLAGS:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sThe ai_flags parameter for looking up %s had an invalid value",
+			    prefix, hostport);
+			break;
+
+		case EAI_FAIL:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sA non-recoverable error occurred when attempting to resolve %s",
+			    prefix, hostport);
+			break;
+
+		case EAI_FAMILY:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sThe address family for looking up %s was not recognized",
+			    prefix, hostport);
+			break;
+
+		case EAI_MEMORY:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sOut of memory trying to allocate storage when looking up %s",
+			    prefix, hostport);
+			break;
+
+		/*
+		 * RFC 2553 had both EAI_NODATA and EAI_NONAME.
+		 *
+		 * RFC 3493 has only EAI_NONAME.
+		 *
+		 * Some implementations define EAI_NODATA and EAI_NONAME
+		 * to the same value, others don't.  If EAI_NODATA is
+		 * defined and isn't the same as EAI_NONAME, we handle
+		 * EAI_NODATA.
+		 */
+#if defined(EAI_NODATA) && EAI_NODATA != EAI_NONAME
+		case EAI_NODATA:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sNo address associated with %s",
+			    prefix, hostport);
+			break;
+#endif
+
+		case EAI_NONAME:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sThe host name %s couldn't be resolved",
+			    prefix, hostport);
+			break;
+
+		case EAI_SERVICE:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sThe service value specified when looking up %s as not recognized for the socket type",
+			    prefix, hostport);
+			break;
+
+		case EAI_SOCKTYPE:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sThe socket type specified when looking up %s as not recognized",
+			    prefix, hostport);
+			break;
+
+#ifdef EAI_SYSTEM
+		case EAI_SYSTEM:
+			/*
+			 * Assumed to be UN*X.
+			 */
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sAn error occurred when looking up %s: %s",
+			    prefix, hostport, pcap_strerror(errno));
+			break;
+#endif
+
+#ifdef EAI_BADHINTS
+		case EAI_BADHINTS:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sInvalid value for hints when looking up %s",
+			    prefix, hostport);
+			break;
+#endif
+
+#ifdef EAI_PROTOCOL
+		case EAI_PROTOCOL:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sResolved protocol when looking up %s is unknown",
+			    prefix, hostport);
+			break;
+#endif
+
+#ifdef EAI_OVERFLOW
+		case EAI_OVERFLOW:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sArgument buffer overflow when looking up %s",
+			    prefix, hostport);
+			break;
+#endif
+
+		default:
+			pcap_snprintf(errbuf, errbuflen,
+			    "%sgetaddrinfo() error %d when looking up %s",
+			    prefix, err, hostport);
+			break;
+	}
+}
+
+/*
  * \brief Checks that the address, port and flags given are valids and it returns an 'addrinfo' structure.
  *
  * This function basically calls the getaddrinfo() calls, and it performs a set of sanity checks
@@ -564,17 +702,10 @@
 	retval = getaddrinfo(host, port, hints, addrinfo);
 	if (retval != 0)
 	{
-		/*
-		 * if the getaddrinfo() fails, you have to use gai_strerror(), instead of using the standard
-		 * error routines (errno) in UNIX; Winsock suggests using the GetLastError() instead.
-		 */
 		if (errbuf)
 		{
-#ifdef _WIN32
-			sock_geterror("getaddrinfo(): ", errbuf, errbuflen);
-#else
-			pcap_snprintf(errbuf, errbuflen, "getaddrinfo() %s", gai_strerror(retval));
-#endif
+			get_gai_errstring(errbuf, errbuflen, "", retval,
+			    host, port);
 		}
 		return -1;
 	}
@@ -655,7 +786,7 @@
 		if (errbuf)
 		{
 			pcap_snprintf(errbuf, errbuflen,
-			    "Can't send more than %u bytes with sock_recv",
+			    "Can't send more than %u bytes with sock_send",
 			    INT_MAX);
 		}
 		return -1;
@@ -697,7 +828,7 @@
 				 */
 				return -2;
 			}
-			sock_fmterror("send(): ", errcode, errbuf, errbuflen);
+			sock_fmterror("send()", errcode, errbuf, errbuflen);
 #else
 			errcode = errno;
 			if (errcode == ECONNRESET || errcode == EPIPE)
@@ -709,7 +840,7 @@
 				 */
 				return -2;
 			}
-			sock_fmterror("send(): ", errcode, errbuf, errbuflen);
+			sock_fmterror("send()", errcode, errbuf, errbuflen);
 #endif
 			return -1;
 		}
@@ -848,7 +979,6 @@
 
 	if (size == 0)
 	{
-		SOCK_DEBUG_MESSAGE("I have been requested to read zero bytes");
 		return 0;
 	}
 	if (size > INT_MAX)
@@ -878,7 +1008,7 @@
 			if (errno == EINTR)
 				return -3;
 #endif
-			sock_geterror("recv(): ", errbuf, errbuflen);
+			sock_geterror("recv()", errbuf, errbuflen);
 			return -1;
 		}
 
@@ -939,7 +1069,6 @@
 
 	if (size == 0)
 	{
-		SOCK_DEBUG_MESSAGE("I have been requested to read zero bytes");
 		return 0;
 	}
 	if (size > INT_MAX)
@@ -975,7 +1104,7 @@
 		 * supplied to us, the excess data is discarded,
 		 * and we'll report an error.
 		 */
-		sock_geterror("recv(): ", errbuf, errbuflen);
+		sock_geterror("recv()", errbuf, errbuflen);
 		return -1;
 	}
 #else /* _WIN32 */
@@ -1008,7 +1137,7 @@
 	{
 		if (errno == EINTR)
 			return -3;
-		sock_geterror("recv(): ", errbuf, errbuflen);
+		sock_geterror("recv()", errbuf, errbuflen);
 		return -1;
 	}
 #ifdef HAVE_STRUCT_MSGHDR_MSG_FLAGS
@@ -1095,8 +1224,6 @@
 			return -1;
 	}
 
-	SOCK_DEBUG_MESSAGE("I'm currently discarding data\n");
-
 	return 0;
 }
 
@@ -1137,6 +1264,7 @@
 		struct addrinfo *addrinfo, *ai_next;
 		char *temphostlist;
 		char *lasts;
+		int getaddrinfo_failed = 0;
 
 		/*
 		 * The problem is that strtok modifies the original variable by putting '0' at the end of each token
@@ -1164,13 +1292,19 @@
 			hints.ai_family = PF_UNSPEC;
 			hints.ai_socktype = SOCK_STREAM;
 
-			retval = getaddrinfo(token, "0", &hints, &addrinfo);
+			retval = getaddrinfo(token, NULL, &hints, &addrinfo);
 			if (retval != 0)
 			{
 				if (errbuf)
-					pcap_snprintf(errbuf, errbuflen, "getaddrinfo() %s", gai_strerror(retval));
+					get_gai_errstring(errbuf, errbuflen,
+					    "Allowed host list error: ",
+					    retval, token, NULL);
 
-				SOCK_DEBUG_MESSAGE(errbuf);
+				/*
+				 * Note that at least one call to getaddrinfo()
+				 * failed.
+				 */
+				getaddrinfo_failed = 1;
 
 				/* Get next token */
 				token = pcap_strtok_r(NULL, sep, &lasts);
@@ -1208,11 +1342,25 @@
 			addrinfo = NULL;
 		}
 
-		if (errbuf)
-			pcap_snprintf(errbuf, errbuflen, "The host is not in the allowed host list. Connection refused.");
-
 		free(temphostlist);
-		return -1;
+
+		if (getaddrinfo_failed) {
+			/*
+			 * At least one getaddrinfo() call failed;
+			 * treat that as an error, so rpcapd knows
+			 * that it should log it locally as well
+			 * as telling the client about it.
+			 */
+			return -2;
+		} else {
+			/*
+			 * All getaddrinfo() calls succeeded, but
+			 * the host wasn't in the list.
+			 */
+			if (errbuf)
+				pcap_snprintf(errbuf, errbuflen, "The host is not in the allowed host list. Connection refused.");
+			return -1;
+		}
 	}
 
 	/* No hostlist, so we have to return 'empty list' */
@@ -1311,7 +1459,7 @@
 
 	if (getsockname(sock, (struct sockaddr *) &mysockaddr, &sockaddrlen) == -1)
 	{
-		sock_geterror("getsockname(): ", errbuf, errbuflen);
+		sock_geterror("getsockname()", errbuf, errbuflen);
 		return 0;
 	}
 
@@ -1389,7 +1537,7 @@
 			(memcmp(&((struct sockaddr_in6 *) sockaddr)->sin6_addr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(struct in6_addr)) == 0))
 		{
 			if (address)
-				strlcpy(address, SOCKET_NAME_NULL_DAD, addrlen);
+				pcap_strlcpy(address, SOCKET_NAME_NULL_DAD, addrlen);
 			return retval;
 		}
 	}
@@ -1399,19 +1547,19 @@
 		/* If the user wants to receive an error message */
 		if (errbuf)
 		{
-			sock_geterror("getnameinfo(): ", errbuf, errbuflen);
+			sock_geterror("getnameinfo()", errbuf, errbuflen);
 			errbuf[errbuflen - 1] = 0;
 		}
 
 		if (address)
 		{
-			strlcpy(address, SOCKET_NO_NAME_AVAILABLE, addrlen);
+			pcap_strlcpy(address, SOCKET_NO_NAME_AVAILABLE, addrlen);
 			address[addrlen - 1] = 0;
 		}
 
 		if (port)
 		{
-			strlcpy(port, SOCKET_NO_PORT_AVAILABLE, portlen);
+			pcap_strlcpy(port, SOCKET_NO_PORT_AVAILABLE, portlen);
 			port[portlen - 1] = 0;
 		}
 
diff --git a/sockutils.h b/sockutils.h
index 1df1ef7..8a45b3d 100644
--- a/sockutils.h
+++ b/sockutils.h
@@ -37,54 +37,11 @@
 #pragma once
 #endif
 
-#ifdef _WIN32
-  /* Need windef.h for defines used in winsock2.h under MingW32 */
-  #ifdef __MINGW32__
-    #include <windef.h>
-  #endif
-  #include <winsock2.h>
-  #include <ws2tcpip.h>
+#include "pcap/socket.h"
 
-  /*
-   * Winsock doesn't have this UN*X type; it's used in the UN*X
-   * sockets API.
-   *
-   * XXX - do we need to worry about UN*Xes so old that *they*
-   * don't have it, either?
-   */
-  typedef int socklen_t;
-#else
+#ifndef _WIN32
   /* UN*X */
-  #include <stdio.h>
-  #include <string.h>	/* for memset() */
-  #include <sys/types.h>
-  #include <sys/socket.h>
-  #include <netdb.h>	/* DNS lookup */
   #include <unistd.h>	/* close() */
-  #include <errno.h>	/* errno() */
-  #include <netinet/in.h> /* for sockaddr_in, in BSD at least */
-  #include <arpa/inet.h>
-  #include <net/if.h>
-
-  /*!
-   * \brief In Winsock, a socket handle is of type SOCKET; in UN*X, it's
-   * a file descriptor, and therefore a signed integer.
-   * We define SOCKET to be a signed integer on UN*X, so that it can
-   * be used on both platforms.
-   */
-  #ifndef SOCKET
-    #define SOCKET int
-  #endif
-
-  /*!
-   * \brief In Winsock, the error return if socket() fails is INVALID_SOCKET;
-   * in UN*X, it's -1.
-   * We define INVALID_SOCKET to be -1 on UN*X, so that it can be used on
-   * both platforms.
-   */
-  #ifndef INVALID_SOCKET
-    #define INVALID_SOCKET -1
-  #endif
 
   /*!
    * \brief In Winsock, the close() call cannot be used on a socket;
@@ -122,35 +79,6 @@
  * \{
  */
 
-/*
- * \brief DEBUG facility: it prints an error message on the screen (stderr)
- *
- * This macro prints the error on the standard error stream (stderr);
- * if we are working in debug mode (i.e. there is no NDEBUG defined) and we are in
- * Microsoft Visual C++, the error message will appear on the MSVC console as well.
- *
- * When NDEBUG is defined, this macro is empty.
- *
- * \param msg: the message you want to print.
- *
- * \param expr: 'false' if you want to abort the program, 'true' it you want
- * to print the message and continue.
- *
- * \return No return values.
- */
-#ifdef NDEBUG
-  #define SOCK_DEBUG_MESSAGE(msg) ((void)0)
-#else
-  #if (defined(_WIN32) && defined(_MSC_VER))
-    #include <crtdbg.h>				/* for _CrtDbgReport */
-    /* Use MessageBox(NULL, msg, "warning", MB_OK)' instead of the other calls if you want to debug a Win32 service */
-    /* Remember to activate the 'allow service to interact with desktop' flag of the service */
-    #define SOCK_DEBUG_MESSAGE(msg) { _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%s\n", msg); fprintf(stderr, "%s\n", msg); }
-  #else
-    #define SOCK_DEBUG_MESSAGE(msg) { fprintf(stderr, "%s\n", msg); }
-  #endif
-#endif
-
 /****************************************************
  *                                                  *
  * Exported functions / definitions                 *