git: 26f21a6494b4 - stable/14 - libpcap: Update to 1.10.5

From: Joseph Mingrone <jrm_at_FreeBSD.org>
Date: Tue, 08 Oct 2024 00:31:51 UTC
The branch stable/14 has been updated by jrm:

URL: https://cgit.FreeBSD.org/src/commit/?id=26f21a6494b4cf791bc45d7ed3138bfab9f8f854

commit 26f21a6494b4cf791bc45d7ed3138bfab9f8f854
Author:     Joseph Mingrone <jrm@FreeBSD.org>
AuthorDate: 2024-09-14 17:09:34 +0000
Commit:     Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2024-10-07 17:27:04 +0000

    libpcap: Update to 1.10.5
    
    Changes:        https://git.tcpdump.org/libpcap/blob/bbcbc9174df3298a854daee2b3e666a4b6e5383a:/CHANGES
    Reviewed by:    emaste
    Obtained from:  https://www.tcpdump.org/release/libpcap-1.10.5.tar.gz
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit afdbf109c6a661a729938f68211054a0a50d38ac)
    (cherry picked from commit ecb75be376a3e18d3e4836b6ee07015264784694)
    (cherry picked from commit f0bcebe67ef6cf9f104535d6cd9f151c1b61dd6a)
    (cherry picked from commit 34aa6f2c2db5cc9655f201a1ef01adbb9fb484d5)
---
 contrib/libpcap/CHANGES                            |   181 +-
 contrib/libpcap/CMakeLists.txt                     |  1021 +-
 contrib/libpcap/CREDITS                            |    17 +
 contrib/libpcap/INSTALL.md                         |    84 +-
 contrib/libpcap/Makefile.in                        |   168 +-
 contrib/libpcap/TODO                               |     5 -
 contrib/libpcap/VERSION                            |     2 +-
 contrib/libpcap/aclocal.m4                         |   227 +-
 contrib/libpcap/atmuni31.h                         |     2 +-
 contrib/libpcap/autogen.sh                         |    25 +
 contrib/libpcap/bpf_dump.c                         |     2 -
 contrib/libpcap/bpf_filter.c                       |    16 +-
 contrib/libpcap/bpf_image.c                        |     6 +-
 contrib/libpcap/charconv.c                         |     4 +-
 contrib/libpcap/cmake/Modules/Finddpdk.cmake       |     2 +-
 contrib/libpcap/cmakeconfig.h.in                   |     6 +-
 contrib/libpcap/config.guess                       |    62 +-
 contrib/libpcap/config.h.in                        |    28 +-
 contrib/libpcap/config.sub                         |   230 +-
 contrib/libpcap/configure                          | 10815 ++++++++++---------
 contrib/libpcap/configure.ac                       |   145 +-
 contrib/libpcap/diag-control.h                     |   174 +-
 contrib/libpcap/dlpisubs.c                         |    22 +-
 contrib/libpcap/doc/README.haiku.md                |    57 +
 contrib/libpcap/doc/README.hpux                    |     2 +-
 .../doc/{README.Win32.md => README.windows.md}     |     0
 contrib/libpcap/etherent.c                         |     6 +-
 contrib/libpcap/extract.h                          |     2 +-
 contrib/libpcap/fad-getad.c                        |    30 +-
 contrib/libpcap/fad-gifc.c                         |    24 +-
 contrib/libpcap/fad-glifc.c                        |    28 +-
 contrib/libpcap/fmtutils.c                         |    59 +-
 contrib/libpcap/fmtutils.h                         |    10 +-
 contrib/libpcap/ftmacros.h                         |     4 +-
 contrib/libpcap/gencode.c                          |   596 +-
 contrib/libpcap/gencode.h                          |     4 +-
 contrib/libpcap/grammar.y.in                       |   140 +-
 contrib/libpcap/install-sh                         |   689 +-
 contrib/libpcap/missing/asprintf.c                 |     8 +-
 contrib/libpcap/missing/strlcat.c                  |     6 +-
 contrib/libpcap/missing/strlcpy.c                  |     6 +-
 contrib/libpcap/missing/strtok_r.c                 |     4 +-
 contrib/libpcap/missing/win_asprintf.c             |     6 +-
 contrib/libpcap/mkdep                              |    28 +-
 contrib/libpcap/msdos/makefile                     |     2 +-
 contrib/libpcap/msdos/makefile.dj                  |     4 +-
 contrib/libpcap/msdos/makefile.wc                  |     6 +-
 contrib/libpcap/msdos/pktdrvr.c                    |     2 +-
 contrib/libpcap/msdos/pktdrvr.h                    |     2 +-
 contrib/libpcap/msdos/readme.dos                   |     4 +-
 contrib/libpcap/nametoaddr.c                       |    57 +-
 contrib/libpcap/nlpid.h                            |     2 +-
 contrib/libpcap/optimize.c                         |    34 +-
 contrib/libpcap/pcap-airpcap.c                     |    53 +-
 contrib/libpcap/pcap-bpf.c                         |   417 +-
 contrib/libpcap/pcap-bt-linux.c                    |    56 +-
 contrib/libpcap/pcap-bt-monitor-linux.c            |    38 +-
 contrib/libpcap/pcap-common.c                      |   405 +-
 contrib/libpcap/pcap-config.1                      |   108 +-
 contrib/libpcap/pcap-config.in                     |    11 +-
 contrib/libpcap/pcap-dag.c                         |   103 +-
 contrib/libpcap/pcap-dbus.c                        |    12 +-
 contrib/libpcap/pcap-dlpi.c                        |    72 +-
 contrib/libpcap/pcap-dos.c                         |    22 +-
 contrib/libpcap/pcap-dpdk.c                        |    32 +-
 contrib/libpcap/pcap-enet.c                        |     6 +-
 contrib/libpcap/pcap-filter.manmisc.in             |    15 +-
 contrib/libpcap/pcap-haiku.c                       |   504 +
 contrib/libpcap/pcap-haiku.cpp                     |   305 -
 contrib/libpcap/pcap-int.h                         |   187 +-
 contrib/libpcap/pcap-libdlpi.c                     |    26 +-
 contrib/libpcap/pcap-linux.c                       |   654 +-
 contrib/libpcap/pcap-netfilter-linux.c             |    61 +-
 contrib/libpcap/pcap-netmap.c                      |    24 +-
 contrib/libpcap/pcap-new.c                         |    31 +-
 contrib/libpcap/pcap-nit.c                         |    44 +-
 contrib/libpcap/pcap-npf.c                         |   296 +-
 contrib/libpcap/pcap-null.c                        |    10 +-
 contrib/libpcap/pcap-pf.c                          |    59 +-
 contrib/libpcap/pcap-rdmasniff.c                   |    16 +-
 contrib/libpcap/pcap-rpcap-int.h                   |    75 -
 contrib/libpcap/pcap-rpcap.c                       |   199 +-
 contrib/libpcap/pcap-savefile.manfile.in           |    64 +-
 contrib/libpcap/pcap-septel.c                      |    14 +-
 contrib/libpcap/pcap-sita.c                        |    42 +-
 contrib/libpcap/pcap-sita.html                     |     4 +-
 contrib/libpcap/pcap-snf.c                         |    46 +-
 contrib/libpcap/pcap-snit.c                        |    57 +-
 contrib/libpcap/pcap-snoop.c                       |    54 +-
 contrib/libpcap/pcap-tc.c                          |    66 +-
 contrib/libpcap/pcap-tstamp.manmisc.in             |     7 +-
 contrib/libpcap/pcap-usb-linux-common.c            |   130 -
 contrib/libpcap/pcap-usb-linux-common.h            |   107 +-
 contrib/libpcap/pcap-usb-linux.c                   |    95 +-
 contrib/libpcap/pcap-util.c                        |   287 +-
 contrib/libpcap/pcap-util.h                        |     6 +-
 contrib/libpcap/pcap.3pcap.in                      |    24 +-
 contrib/libpcap/pcap.c                             |   439 +-
 contrib/libpcap/pcap/can_socketcan.h               |    25 +-
 contrib/libpcap/pcap/dlt.h                         |    75 +-
 contrib/libpcap/pcap/funcattrs.h                   |   106 +-
 contrib/libpcap/pcap/namedb.h                      |    27 +-
 contrib/libpcap/pcap/nflog.h                       |     2 +-
 contrib/libpcap/pcap/pcap-inttypes.h               |     2 +-
 contrib/libpcap/pcap/pcap.h                        |    89 +-
 contrib/libpcap/pcap/sll.h                         |     1 +
 contrib/libpcap/pcap/socket.h                      |    56 +-
 contrib/libpcap/pcap/usb.h                         |     6 +
 contrib/libpcap/pcap_activate.3pcap                |    12 +-
 contrib/libpcap/pcap_breakloop.3pcap               |     2 +-
 contrib/libpcap/pcap_compile.3pcap.in              |     3 +-
 contrib/libpcap/pcap_create.3pcap                  |    12 +-
 contrib/libpcap/pcap_dump.3pcap                    |     3 +-
 contrib/libpcap/pcap_findalldevs.3pcap             |    43 +-
 contrib/libpcap/pcap_init.3pcap                    |    15 +-
 contrib/libpcap/pcap_lookupdev.3pcap               |    10 +-
 contrib/libpcap/pcap_lookupnet.3pcap               |    21 +-
 contrib/libpcap/pcap_loop.3pcap                    |    24 +-
 contrib/libpcap/pcap_next_ex.3pcap                 |    11 +-
 contrib/libpcap/pcap_offline_filter.3pcap          |     3 +-
 contrib/libpcap/pcap_open_live.3pcap               |    30 +-
 contrib/libpcap/pcap_open_offline.3pcap.in         |    13 +-
 contrib/libpcap/pcap_set_tstamp_precision.3pcap.in |     3 +-
 contrib/libpcap/pcap_setnonblock.3pcap             |    40 +-
 contrib/libpcap/pcap_strerror.3pcap                |    14 +-
 contrib/libpcap/portability.h                      |    27 +-
 contrib/libpcap/ppp.h                              |     2 +-
 contrib/libpcap/rpcap-protocol.c                   |     4 +-
 contrib/libpcap/rpcap-protocol.h                   |     6 +-
 contrib/libpcap/rpcapd/CMakeLists.txt              |    29 +-
 contrib/libpcap/rpcapd/Makefile.in                 |     4 +-
 contrib/libpcap/rpcapd/config_params.h             |     2 +-
 contrib/libpcap/rpcapd/daemon.c                    |    70 +-
 contrib/libpcap/rpcapd/daemon.h                    |     4 +-
 contrib/libpcap/rpcapd/fileconf.c                  |    18 +-
 contrib/libpcap/rpcapd/log.c                       |     2 -
 contrib/libpcap/rpcapd/rpcapd-config.manfile.in    |    12 +-
 contrib/libpcap/rpcapd/rpcapd.c                    |    62 +-
 contrib/libpcap/rpcapd/rpcapd.manadmin.in          |    54 +-
 contrib/libpcap/rpcapd/win32-svc.c                 |     2 +-
 contrib/libpcap/savefile.c                         |    38 +-
 contrib/libpcap/scanner.l                          |   171 +-
 contrib/libpcap/sf-pcap.c                          |   150 +-
 contrib/libpcap/sf-pcapng.c                        |    24 +-
 contrib/libpcap/sockutils.c                        |   123 +-
 contrib/libpcap/sockutils.h                        |    26 +-
 contrib/libpcap/sslutils.c                         |     4 +-
 contrib/libpcap/sslutils.h                         |    10 +-
 contrib/libpcap/testprogs/Makefile.in              |     2 +-
 contrib/libpcap/testprogs/filtertest.c             |     6 +-
 contrib/libpcap/testprogs/findalldevstest-perf.c   |     2 -
 contrib/libpcap/testprogs/findalldevstest.c        |     8 +-
 contrib/libpcap/testprogs/valgrindtest.c           |     4 +-
 contrib/libpcap/thread-local.h                     |    72 +
 contrib/pf/pflogd/pflogd.c                         |    11 +
 lib/libpcap/Makefile                               |     1 -
 lib/libpcap/config.h                               |     4 +-
 157 files changed, 12381 insertions(+), 9570 deletions(-)

diff --git a/contrib/libpcap/CHANGES b/contrib/libpcap/CHANGES
index c574a278064f..bf8701c829a0 100644
--- a/contrib/libpcap/CHANGES
+++ b/contrib/libpcap/CHANGES
@@ -1,3 +1,168 @@
+Friday, August 30, 2024 / The Tcpdump Group
+  Summary for 1.10.5 libpcap release
+    Source code:
+      Spell WirelessHART details properly.
+      Mark pcap_vasprintf() as printf-like.
+      Finalize moving of bpf_filter.c. (GH #1166)
+      Remove an unneeded argument from gen_mcode6().
+      Don't do some Berkeley YACC workarounds with YACC releases not
+        requiring them.
+      Use correct data types rather than int in some cases.
+      Squelch compiler warning in grammar.c.
+      Fix findalldevtest compilation if IPv6 isn't enabled.
+      Rename helper routines for pcap modules to have names beginning with
+        pcapint_, to avoid namespace collisions for code linking statically
+        with libpcap.
+      Avoid casting hack for the Windows cleanup-on-exit routine.
+      Use %zu format for one case of printing a size_t.
+      Fix some Coverity errors.
+      Fix availabilities of some functions to match reality.
+      pcap: make the seconds and microseconds/nanoseconds fields unsigned.
+      Remove the unused pcap-rpcap-int.h header file.
+    Thread safety:
+      Make some static variables thread-local; fixes issue #1174.
+    Packet filtering:
+      Improve reporting of some invalid filter expressions.
+      Return an error from pcap_compile() if the scanner fails to initialize.
+      Optimizer fix from Archit Shah to recompute dominators after
+        moving code (#976); fixes #945 (although the resulting filter
+        isn't empty).
+      Optimizer fix from Archit Shah to mark value as unknown when store
+        of that value is deleted (#972); fixes #143, #434, #436, #437,
+        and #1076.
+    Linux:
+      Properly return warnings.
+      Don't use DLT_LINUX_SLL2 for anything other than the "any" device.
+      Avoid 32-bit unsigned integer overflow in USB captures.  Fixes
+        issues #1134 and #1205.
+      Fix a file descriptor leak.
+      Properly report warnings about unknown ARPHRD_ types.
+      Fix DLT_CAN_SOCKETCAN handling of CAN FD.
+      Add CAN XL support to DLT_CAN_SOCKETCAN.
+      Clean up the code that sets the "real" ("original") length for
+        isochronous USB transfers.
+      Avoid unnecessary blocking on recvmsg() in the Bluetooth monitor and
+        Bluetoth modules.
+    Solaris:
+      Handle BPF returning ESRCH for unknown devices.
+      List the "any" device if it's supported.
+      Report {non-existent zone}/{interface} errors appropriately.
+      Allow attaching to links owned by a non-global zone.  (Based on
+        pull request #1202.)
+      Fix AF_LINK handling on illumos.
+    macOS:
+      Redid the availability macros to be closer to what Apple's doing
+        in recent SDKs, including tagging pcap-namedb.h routines.
+      Fix the install name of the installed shared library to have a
+        full path when building with CMake.
+      Fix universal builds.
+    Haiku:
+      Convert the module to C.  Fixes issue #1114.
+      Address a few compiler warnings.  Fixes issue #1114.
+      Fix various build problems.  Fixes issue #1114.
+      Report non-existent devices correctly.
+      Fix handling of packet statistics.
+      Fix packet timestamping.
+      Fix packet filtering with low snaplen.
+      Improve connection status reporting.
+      Add support for promiscuous mode.
+      Detect DLTs and loopback capture support at run time.
+      Report IEEE 802.11 as PCAP_IF_WIRELESS.
+    Windows:
+      Fix internal handling of "not supported" error codes from NPF.
+      Work around a bug in Npcap 1.00 in case of driver version mismatch.
+      Don't call WSACleanup() when handling a failed WSAStartup().
+    BSD, macOS, AIX, Solaris 11, Linux:
+      Add a new error PCAP_ERROR_CAPTURE_NOTSUP, for use if a capture
+        mechanism is not present, in the hopes that, for example,
+        attempts to capture on Windows Services for Linux 1, in which
+        the NT kernel attempts to simulate Linux system calls but does
+        not support packet sockets, can get an error that better
+        indicates the underlying problem.
+    AirPcap:
+      Format an error message if we run out of memory.
+    nflog:
+      Fix count of dropped packets.
+      Make sure we don't overflow when rounding up the TLV length.
+    rpcap:
+      Handle routines removed in at least some OpenSSL libraries.
+      CVE-2023-7256: Clean up sock_initaddress() and its callers to avoid
+        double frees in some cases.
+      Don't define SOCKET ourselves; instead, define PCAP_SOCKET as int
+        on UN*Xes and as SOCKET on Windows.
+      CVE-2024-8006: Fix pcap_findalldevs_ex() not to crash if passed a
+        file:// URL with a path to a directory that cannot be opened.
+    Savefiles:
+      Handle DLT_/LINKTYPE_ mapping better, to handle some
+        OpenBSD-specific link types better.
+      Treat if_tsoffset as signed in pcapng files, as the spec says.
+      Don't try to fix the "real" length for isochronous USB
+        transfers if the number of USB descriptors is too large.
+      Reject pcap files where one of the reserved fields in the
+        "link-layer type plus other stuff" is non-zero.
+    Building and testing:
+      Add a configure option to help debugging (--enable-instrument-functions).
+      Improved tests and error reporting for uses of pkg-config, and
+        improve help message.
+      Fix Haiku build.
+      With CMake, install headers in CMAKE_INSTALL_INCLUDEDIR rather
+        than just include.
+      Build libpcap.a before building test programs.
+      Print address family numerically, as well as symbolically,
+        in findalldevstest.
+      Fail with suggestions, rather than failing over to no capture
+        support, if no capture mechanism was found.  Fixes issue #1016.
+      Don't indent comments in Make, as that may cause them not to be
+        recognized as comments.
+      Don't check for libssl if we aren't going to use it.
+      Better handle enabling and disabling of sanitizers.  Fixes issue
+        #1171.
+      CMakeLists.txt: Print "Symlinking: /some/path to ..." conditionally.
+      Evaluate CMAKE_INSTALL_PREFIX at install time.
+      cmake: Update the minimum required version to 2.8.12 (except Windows).
+      cmake: suppress CMP0042 OLD deprecated warning.
+      Makefile.in: Add the releasecheck target.
+      Cirrus CI: Add the "make releasecheck" command in the Linux task.
+      Makefile.in: Add the whitespacecheck target.
+      Cirrus CI: Run the "make whitespacecheck" command in the Linux task.
+      Autoconf: Update config.{guess,sub}, timestamps 2024-01-01.
+      Autoconf: Update the install-sh script to the 2020-11-14.01 version.
+      Compile with '-Wnull-pointer-subtraction',
+        '-Wunused-but-set-parameter', and '-Wunused-but-set-variable' in
+        devel mode if supported.
+      Don't ignore spaces between CMAKE_C_FLAGS and DPDK_C_FLAGS with
+        CMake.
+      Use noreturn and __format__ with XL C 7.0 and later.
+      Check for the same -W flags in autotools and CMake.
+      Autoconf: Add autogen.sh, remove configure and config.h.in and put
+        these generated files in the release tarball.
+      Autoconf: Get the size of a time_t.
+      Fix propagation of cc_werr_cflags() output.
+      Makefile.in(s): Fix the depend target.
+      mkdep: Exit with a non-zero status if a command fails.
+      Fix HCI_CHANNEL_MONITOR detection with musl libc.
+      Extend "make shellcheck" onto mkdep too.
+      Add initial support for building with TinyCC.
+      Address all known compiler warnings specific to illumos, Linux, NetBSD,
+        Solaris and Sun C; in CI expect warnings specific to TinyCC only.
+    Documentation:
+      Update and fix pcap-filter man page.
+      Add a README.haiku.md file.
+      Document pcap-config better.
+      Man page formatting and prose fixes.
+      Rename doc/README.Win32.md to doc/README.windows.md.
+      Update pcap-savefile man page to match the Internet-Draft for
+        pcap.
+      Fix CMake issues for target used by other projects.
+      Explain "any" device better in pcap_open_live(3PCAP).
+      Update INSTALL.md.
+      Note in man pages that errbuf arguments must point to an error
+        buffer.
+      Note that if pcap_findalldevs() fails it sets *alldevsp to NULL;
+        there's no devices list to free.
+      Explain "other addresses" in pcap_findalldevs(3PCAP).
+      Document pcap_lookupnet(3PCAP) a bit better.
+
 Friday, April 7, 2023 / The Tcpdump Group
   Summary for 1.10.4 libpcap release
     Source code:
@@ -58,7 +223,7 @@ Saturday, December 31, 2022 / The Tcpdump Group
         when reading a LINKTYPE_PFLOG file.
       Put CAN ID field in CAN pseudo-headers for LINUX_SLL2, as we do
         for LINUX_SLL.
-      Fix inorrectly-computed "real" length for isochronous USB
+      Fix incorrectly-computed "real" length for isochronous USB
         transfers when reading savefiles.
       Don't crash if pcap_can_set_rfmon() is called.
       Fix pcap_offline_read() loop.
@@ -139,7 +304,7 @@ Saturday, December 31, 2022 / The Tcpdump Group
       Return an error if the driver reports 0 timestamp modes supported.
       Close the ADAPTER handle for some errors in
         pcap_create_interface().
-      Get rid of old umaintained VS project files.
+      Get rid of old unmaintained VS project files.
       Fix deprecation warning for pcap_handle().
       Npcap is now at npcap.com, not npcap.org.
       Make sure "no such device" and "no permission to open device"
@@ -307,7 +472,7 @@ Tuesday, December 29, 2020
     Remove (unused) SITA support
     Capture file reading:
         Correctly handle pcapng captures with more than one IDB with a
-            snspshot length greater than the supported maximum
+            snapshot length greater than the supported maximum
     Capture file writing:
         Create the file in pcap_dump_open_append() if it doesn't exist
     Packet filtering:
@@ -421,7 +586,7 @@ Tuesday, December 29, 2020
             isn't called
         Fix compilation on Cygwin/MSYS
         Add pcap_handle(), and deprecate pcap_fileno()
-        Report PCAP_ERROR_NO_SUCH_DEVICE for a non-existent device
+        Report PCAP_ERROR_NO_SUCH_DEVICE for a nonexistent device
         Return an appropriate error message for device removed or
             device unusable due to a suspend/resume
         Report a warning for unknown NdisMedium types
@@ -503,7 +668,7 @@ Sunday, July 22, 2018
         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
+    Fix the maximum 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
@@ -668,7 +833,7 @@ Wednesday Nov. 12, 2014 guy@alum.mit.edu/mcr@sandelman.ca
 
 Monday Aug. 12, 2014 guy@alum.mit.edu
   Summary for 1.6.2 libpcap release
-	Don't crash on filters testing a non-existent link-layer type
+	Don't crash on filters testing a nonexistent link-layer type
 	    field.
 	Fix sending in non-blocking mode on Linux with memory-mapped
 	    capture.
@@ -956,7 +1121,7 @@ Mon.    October 27, 2008.  ken@netfunctional.ca.  Summary for 1.0.0 libpcap rele
 	Autogenerate VERSION numbers better
 
 Mon.    September 10, 2007.  ken@xelerance.com.  Summary for 0.9.8 libpcap release
-        Change build process to put public libpcap headers into pcap subir
+        Change build process to put public libpcap headers into pcap subdir
         DLT: Add value for IPMI IPMB packets
         DLT: Add value for u10 Networks boards
         Require <net/pfvar.h> for pf definitions - allows reading of pflog formatted
@@ -1285,7 +1450,7 @@ v0.2.1 Sun Jul 14 03:02:26 PDT 1996
   (steve@research.oknet.com)
 
 - Fixed to handle raw ip addresses such as 0.0.0.1 without "left
-  justifing"
+  justifying"
 
 - Add "sca" keyword (for DEC cluster services) as suggested by Terry
   Kennedy (terry@spcvxa.spc.edu)
diff --git a/contrib/libpcap/CMakeLists.txt b/contrib/libpcap/CMakeLists.txt
index 58c5159905d0..9012ef41769f 100644
--- a/contrib/libpcap/CMakeLists.txt
+++ b/contrib/libpcap/CMakeLists.txt
@@ -2,9 +2,26 @@ if(WIN32)
     #
     # We need 3.12 or later, so that we can set policy CMP0074; see
     # below.
+    #
     cmake_minimum_required(VERSION 3.12)
 else(WIN32)
-    cmake_minimum_required(VERSION 2.8.6)
+    #
+    # For now:
+    #
+    #  if this is a version of CMake less than 3.5, require only
+    #  2.8.12, just in case somebody is configuring with CMake
+    #  on a "long-term support" version # of some OS and that
+    #  version supplies an older version of CMake;
+    #
+    #  otherwise, require 3.5, so we don't get messages warning
+    #  that support for versions of CMake lower than 3.5 is
+    #  deprecated.
+    #
+    if(CMAKE_VERSION VERSION_LESS "3.5")
+        cmake_minimum_required(VERSION 2.8.12)
+    else()
+        cmake_minimum_required(VERSION 3.5)
+    endif()
 endif(WIN32)
 
 #
@@ -12,8 +29,15 @@ endif(WIN32)
 # neither do we with autotools; don't do so with CMake, either, and
 # suppress warnings about that.
 #
+# Setting CMAKE_MACOSX_RPATH to FALSE uses the old behavior,
+# but removes the POLICY CMP0042 OLD deprecated warning.
+# See https://cmake.org/cmake/help/latest/policy/CMP0042.html
+#
+if (NOT DEFINED CMAKE_MACOSX_RPATH)
+    set(CMAKE_MACOSX_RPATH FALSE)
+endif()
 if(POLICY CMP0042)
-    cmake_policy(SET CMP0042 OLD)
+    cmake_policy(SET CMP0042 NEW)
 endif()
 
 #
@@ -47,20 +71,52 @@ endif()
 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
 
 #
-# We only need a C++ compiler for Haiku; all code except for its
-# pcap module is in C.
+# We explicitly indicate what languages are used in libpcap to avoid
+# checking for a C++ compiler.
+#
+# One reason to avoid that check is that there's no need to waste
+# configuration time performing it.
+#
+# Another reason is that:
+#
+# CMake will try to determine the sizes of some data types, including
+# void *, early in the process of configuration; apparently, it's done
+# as part of processing the project() command.
 #
-# We do that by specifying just C in the project() call and, after
-# that finishes, checking for Haiku and, if we're building for
-# Haiku, use enable_language() to check for C++.  This means that
-# we don't require a C++ compiler on platforms other than Haiku.
+# At least as of CMake 2.8.6, it does so by checking the size of
+# "void *" in C, setting CMAKE_C_SIZEOF_DATA_PTR based on that,
+# setting CMAKE_SIZEOF_VOID_P to that, and then checking the size
+# of "void *" in C++, setting CMAKE_CXX_SIZEOF_DATA_PTR based on
+# that, and then setting CMAKE_SIZEOF_VOID_P to *that*.
 #
-# CMAKE_SYSTEM_NAME is set by project(), so we can't do this by
-# testing CMAKE_SYSTEM_NAME and then passing different language
-# lists to project() based on the system.
+# The compile tests include whatever C flags may have been provided
+# to CMake in the CFLAGS and CXXFLAGS environment variables.
+#
+# If you set an architecture flag such as -m32 or -m64 in CFLAGS
+# but *not* in CXXFLAGS, the size for C++ will win, and hilarity
+# will ensue.
+#
+# Or if, at least on Solaris, you have a newer version of GCC
+# installed, but *not* a newer version of G++, and you have Oracle
+# Studio installed, it will find GCC, which will default to building
+# 64-bit, and Oracle Studio's C++ compiler, which will default to
+# building 32-bit, the size for C++ will win, and, again, hilarity
+# will ensue.
 #
 project(pcap C)
 
+#
+# Setting CMAKE_MACOSX_RPATH to FALSE causes the installed
+# libpcap.A.dylib to have just libpcap.A.dylib as the install
+# name;  Apple built libpcap with an install_name of /usr/lib/libpcap.A.dylib
+# (back when they still shipped individual system dylibs rather than
+# shipping a pre-built shared library cache, at least), and we do the
+# same with autotools; do the same with CMake.
+#
+if (NOT DEFINED CMAKE_INSTALL_NAME_DIR)
+    set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
+endif()
+
 #
 # For getting raw lists of --libs and --libs --static information from a
 # pkg-config module.
@@ -190,55 +246,6 @@ macro(get_link_info_from_library_path  _library_prefix _library_name)
   endif()
 endmacro()
 
-if(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
-    enable_language(CXX)
-
-    #
-    # OK, this is a royal pain.
-    #
-    # CMake will try to determine the sizes of some data types, including
-    # void *, early in the process of configuration; apparently, it's done
-    # as part of processing the project() command.
-    #
-    # At least as of CMake 2.8.6, it does so by checking the size of
-    # "void *" in C, setting CMAKE_C_SIZEOF_DATA_PTR based on that,
-    # setting CMAKE_SIZEOF_VOID_P to that, and then checking the size
-    # of "void *" in C++, setting CMAKE_CXX_SIZEOF_DATA_PTR based on
-    # that, and then setting CMAKE_SIZEOF_VOID_P to *that*.
-    #
-    # The compile tests include whatever C flags may have been provided
-    # to CMake in the CFLAGS and CXXFLAGS environment variables.
-    #
-    # If you set an architecture flag such as -m32 or -m64 in CFLAGS
-    # but *not* in CXXFLAGS, the size for C++ will win, and hilarity
-    # will ensue.
-    #
-    # Or if, at least on Solaris, you have a newer version of GCC
-    # installed, but *not* a newer version of G++, and you have Oracle
-    # Studio installed, it will find GCC, which will default to building
-    # 64-bit, and Oracle Studio's C++ compiler, which will default to
-    # building 32-bit, the size for C++ will win, and, again, hilarity
-    # will ensue.
-    #
-    # So we make sure both languages have the same pointer sizes with
-    # the flags they're given; if they don't, it means that the
-    # compilers for the languages will, with those flags, not produce
-    # code that can be linked together.
-    #
-    # This is unlikely to happen on Haiku, but it *has* happened on
-    # Solaris; we do this for future-proofing, in case we ever need
-    # C++ on a platform where that can happen.
-    #
-    if(NOT ${CMAKE_C_SIZEOF_DATA_PTR} EQUAL ${CMAKE_CXX_SIZEOF_DATA_PTR})
-         message(FATAL_ERROR
-"C compiler ${CMAKE_C_COMPILER} produces code with \
-${CMAKE_C_SIZEOF_DATA_PTR}-byte pointers while C++ compiler \
-${CMAKE_CXX_COMPILER} produces code with \
-${CMAKE_CXX_SIZEOF_DATA_PTR}-byte pointers. \
-This prevents code in these languages from being combined.")
-    endif()
-endif()
-
 #
 # Show the bit width for which we're compiling.
 # This can help debug problems if you're dealing with a compiler that
@@ -256,7 +263,7 @@ endif()
 # Solaris pkg-config is annoying.  For at least one package (D-Bus, I'm
 # looking at *you*!), there are separate include files for 32-bit and
 # 64-bit builds (I guess using "unsigned long long" as a 64-bit integer
-# type on a 64-bit build is like crossing the beams or soething), and
+# type on a 64-bit build is like crossing the beams or something), and
 # there are two separate .pc files, so if we're doing a 32-bit build we
 # should make sure we look in /usr/lib/pkgconfig for .pc files and if
 # we're doing a 64-bit build we should make sure we look in
@@ -563,8 +570,6 @@ set(PACKAGE_STRING "${LIBRARY_NAME} ${PACKAGE_VERSION}")
 # Project settings
 ######################################
 
-add_definitions(-DHAVE_CONFIG_H)
-
 include_directories(
     ${CMAKE_CURRENT_BINARY_DIR}
     ${pcap_SOURCE_DIR}
@@ -615,9 +620,7 @@ if(USE_STATIC_RT)
         if(MSVC)
             foreach(RT_FLAG
                 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
-                CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
-                CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
-                CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+                CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
                 string(REGEX REPLACE "/MD" "/MT" ${RT_FLAG} "${${RT_FLAG}}")
             endforeach(RT_FLAG)
         elseif(MINGW)
@@ -699,7 +702,6 @@ main(void)
 #
 # Now check for various system functions.
 #
-check_function_exists(strerror HAVE_STRERROR)
 check_function_exists(strerror_r HAVE_STRERROR_R)
 if(HAVE_STRERROR_R)
     #
@@ -755,29 +757,26 @@ if(NOT WIN32)
 endif()
 
 #
-# These tests are for network applications that need socket functions
-# and getaddrinfo()/getnameinfo()-ish functions.  We now require
-# getaddrinfo() and getnameinfo().  On UN*X systems, we also prefer
-# versions of recvmsg() that conform to the Single UNIX Specification,
-# so that we can check whether a datagram received with recvmsg() was
-# truncated when received due to the buffer being too small.
+# Look for various networking-related libraries that we may need.
 #
-# On Windows, getaddrinfo() is in the ws2_32 library.
-
-# On most UN*X systems, they're available in the system library.
+# We need getaddrinfo() to translate host names in filters to IP
+# addresses. We use getaddrinfo() because we want a portable
+# thread-safe way of getting information for a host name or port;
+# there exist _r versions of gethostbyname() and getservbyname() on
+# some platforms, but not on all platforms.
 #
-# Under Solaris, we need to link with libsocket and libnsl to get
-# getaddrinfo() and getnameinfo() and, if we have libxnet, we need to
-# link with libxnet before libsocket to get a version of recvmsg()
-# that conforms to the Single UNIX Specification.
+# We may also need socket() and other socket functions to support:
 #
-# We use getaddrinfo() because we want a portable thread-safe way
-# of getting information for a host name or port; there exist _r
-# versions of gethostbyname() and getservbyname() on some platforms,
-# but not on all platforms.
+#   Local packet capture with capture mechanisms that use sockets.
 #
-# NOTE: if you hand check_library_exists as its last argument a variable
-# that's been set, it skips the test, so we need different variables.
+#   Local capture device enumeration if a socket call is needed to
+#   enumerate devices or get device attributes.
+#
+#   Packet capture from services that put captured packets on the
+#   network, such as rpcap servers.
+#
+# We may also need getnameinfo() for packet capture from services
+# that put packets on the network.
 #
 set(PCAP_LINK_LIBRARIES "")
 set(LIBS "")
@@ -786,9 +785,13 @@ set(REQUIRES_PRIVATE "")
 set(LIBS_PRIVATE "")
 include(CheckLibraryExists)
 if(WIN32)
+    #
+    # Windows.
     #
     # We need winsock2.h and ws2tcpip.h.
     #
+    # On Windows, getaddrinfo() is in the ws2_32 library.
+    #
     cmake_push_check_state()
     set(CMAKE_REQUIRED_LIBRARIES ws2_32)
     check_symbol_exists(getaddrinfo "winsock2.h;ws2tcpip.h" LIBWS2_32_HAS_GETADDRINFO)
@@ -800,16 +803,28 @@ if(WIN32)
     endif(LIBWS2_32_HAS_GETADDRINFO)
 else(WIN32)
     #
-    # UN*X.  First try the system libraries, then try the libraries
-    # for Solaris and possibly other systems that picked up the
-    # System V library split.
+    # UN*X.
+    #
+    # Most UN*Xes have getaddrinfo(), and the other routines we may
+    # need, in the default searched libraries (e.g., libc).
+    # Check there first.
+    #
+    # NOTE: if you hand check_library_exists as its last argument a
+    # variable that's been set, it skips the test, so we need different
+    # variables for different libraries.
     #
     check_function_exists(getaddrinfo STDLIBS_HAVE_GETADDRINFO)
     if(NOT STDLIBS_HAVE_GETADDRINFO)
-        #
-        # Not found in the standard system libraries.
-        # Try libsocket, which requires libnsl.
-        #
+	#
+	# Not found in the standard system libraries.
+	#
+	# In some versions of Solaris, we need to link with libsocket
+	# and libnsl, so check in libsocket and also link with liblnsl
+	# when doing this test.
+	#
+	# Linking with libsocket and libnsl will find all the routines
+	# we need.
+	#
         cmake_push_check_state()
         set(CMAKE_REQUIRED_LIBRARIES nsl)
         check_library_exists(socket getaddrinfo "" LIBSOCKET_HAS_GETADDRINFO)
@@ -823,10 +838,17 @@ else(WIN32)
             set(LIBS_STATIC "-lsocket -lnsl ${LIBS_STATIC}")
             set(LIBS_PRIVATE "-lsocket -lnsl ${LIBS_PRIVATE}")
         else(LIBSOCKET_HAS_GETADDRINFO)
+	    #
+	    # Not found in libsocket; test for it in libnetwork, which
+	    # is where it is in Haiku.
+	    #
+	    # Linking with libnetwork will find all the routines we
+	    # need.
+	    #
             check_library_exists(network getaddrinfo "" LIBNETWORK_HAS_GETADDRINFO)
             if(LIBNETWORK_HAS_GETADDRINFO)
                 #
-                # OK, we found it in libnetwork (Haiku).
+		# OK, we found it in libnetwork.
                 #
                 set(PCAP_LINK_LIBRARIES network ${PCAP_LINK_LIBRARIES})
                 set(LIBS "-lnetwork ${LIBS}")
@@ -840,17 +862,32 @@ else(WIN32)
             endif(LIBNETWORK_HAS_GETADDRINFO)
         endif(LIBSOCKET_HAS_GETADDRINFO)
 
-        #
-        # OK, do we have recvmsg() in libxnet?
-        # We also link with libsocket and libnsl.
-        #
+	#
+	# We require a version of recvmsg() that conforms to the Single
+	# UNIX Specification, so that we can check whether a datagram
+	# received with recvmsg() was truncated when received due to the
+	# buffer being too small.
+	#
+	# On most systems, the version of recvmsg() in the libraries
+	# found above conforms to the SUS.
+	#
+	# On at least some versions of Solaris, it does not conform to
+	# the SUS, and we need the version in libxnet, which does
+	# conform.
+	#
+	# Check whether libxnet exists and has a version of recvmsg();
+	# if it does, link with libxnet before we link with libsocket,
+	# to get that version.
+	#
+	# This test also links with libsocket and libnsl.
+	#
         cmake_push_check_state()
         set(CMAKE_REQUIRED_LIBRARIES socket nsl)
         check_library_exists(xnet recvmsg "" LIBXNET_HAS_RECVMSG)
         cmake_pop_check_state()
         if(LIBXNET_HAS_RECVMSG)
             #
-            # Yes - link with it as well.
+	    # libxnet has recvmsg(); link with it as well.
             #
             set(PCAP_LINK_LIBRARIES xnet ${PCAP_LINK_LIBRARIES})
             set(LIBSC "-lxnet ${LIBS_LIBS}")
@@ -859,7 +896,9 @@ else(WIN32)
         endif(LIBXNET_HAS_RECVMSG)
     endif(NOT STDLIBS_HAVE_GETADDRINFO)
 
-    # DLPI needs putmsg under HPUX so test for -lstr while we're at it
+    #
+    # DLPI needs putmsg under HP-UX, so test for -lstr while we're at it.
+    #
     check_function_exists(putmsg STDLIBS_HAVE_PUTMSG)
     if(NOT STDLIBS_HAVE_PUTMSG)
         check_library_exists(str putmsg "" LIBSTR_HAS_PUTMSG)
@@ -1231,7 +1270,6 @@ endif(NOT WIN32)
 if(ENABLE_PROFILING)
     if(NOT MSVC)
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
     endif()
 endif()
 
@@ -1264,7 +1302,7 @@ endif()
 #
 # Test if the each of the sanitizers in the ENABLE_SANITIZERS list are
 # supported by the compiler, and, if so, adds the appropriate flags to
-# CMAKE_C_FLAGS, CMAKE_CXX_FLAGS, and SANITIZER_FLAGS.  If not, it fails.
+# CMAKE_C_FLAGS, and SANITIZER_FLAGS.  If not, it fails.
 #
 # Do this last, in the hope that it will prevent configuration on Linux
 # from somehow deciding it doesn't need -lpthread when building rpcapd
@@ -1272,17 +1310,25 @@ endif()
 # obvious CMake debugging flag reveals, it doesn't realize that if we
 # turn sanitizer stuff on).
 #
-set(SANITIZER_FLAGS "")
-foreach(sanitizer IN LISTS ENABLE_SANITIZERS)
+# Note: apparently, some projects have decided that ENABLE_SANITIZERS
+# is a Boolean, with OFF meaning "no sanitizers" and ON meaning "all
+# sanitizers".  Whoever decided that didn't put it up as a common
+# CMake idiom, as far as I can tell; we only discovered this because
+# JetBrains' CLion "helpfully" appears to pass -DENABLE_SANITIZERS=OFF
+# to CMake by default, which causes CMake to fail on libpcap.  Thanks!
+#
+# We thus also allow a setting of OFF to mean "no sanitizers" and ON to
+# mean "all supported sanitizers that we know about and that can all
+# be used together".
+#
+macro(test_sanitizer _sanitizer _sanitizer_flag)
+    message(STATUS "Checking sanitizer ${_sanitizer}")
+    set(sanitizer_variable "sanitize_${_sanitizer}")
     # Set -Werror to catch "argument unused during compilation" warnings
-
-    message(STATUS "Checking sanitizer ${sanitizer}")
-    set(sanitizer_variable "sanitize_${sanitizer}")
-    set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize=${sanitizer}")
-    check_c_compiler_flag("-fsanitize=${sanitizer}" ${sanitizer_variable})
+    set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize=${_sanitizer}")
+    check_c_compiler_flag("-fsanitize=${_sanitizer}" ${sanitizer_variable})
     if(${${sanitizer_variable}})
-        set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize=${sanitizer}")
-        message(STATUS "${sanitizer} sanitizer supported using -fsanitizer=${sanitizer}")
+        set(${_sanitizer_flag} "-fsanitize=${_sanitizer}")
     else()
         #
         # Try the versions supported prior to Clang 3.2.
@@ -1291,119 +1337,397 @@ foreach(sanitizer IN LISTS ENABLE_SANITIZERS)
         # Otherwise, give up.
         #
         set(sanitizer_variable "OLD_${sanitizer_variable}")
-        if ("${sanitizer}" STREQUAL "address")
+        if ("${_sanitizer}" STREQUAL "address")
             set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize-address")
             check_c_compiler_flag("-fsanitize-address" ${sanitizer_variable})
             if(${${sanitizer_variable}})
-                set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize-address")
-                message(STATUS "${sanitizer} sanitizer supported using -fsanitize-address")
-            else()
-                message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer")
+                set(${_sanitizer_flag} "-fsanitize-address")
             endif()
-        elseif("${sanitizer}" STREQUAL "undefined")
+        elseif("${_sanitizer}" STREQUAL "undefined")
             set(CMAKE_REQUIRED_FLAGS "-Werror -fcatch-undefined-behavior")
             check_c_compiler_flag("-fcatch-undefined-behavior" ${sanitizer_variable})
             if(${${sanitizer_variable}})
-                set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fcatch-undefined-behavior")
-                message(STATUS "${sanitizer} sanitizer supported using catch-undefined-behavior")
-            else()
-                message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer")
+                set(${_sanitizer_flag} "-fcatch-undefined-behavior")
             endif()
-        else()
-            message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer")
         endif()
     endif()
-
     unset(CMAKE_REQUIRED_FLAGS)
-endforeach()
+endmacro(test_sanitizer)
+
+set(SANITIZER_FLAGS "")
+if("${ENABLE_SANITIZERS}")
+    #
+    # This appears to indicate that ENABLE_SANITIZERS was set to a
+    # string value that is "one of the true constants", meaning
+    # "1, ON, YES, TRUE, Y, or a non-zero number".
+    #
+    # It does not appear to happen for other settings, including
+    # setting it to a list of one or more sanitizers.
+    #
+    # This setting means "enable all sanitizers that the compiler
+    # supports".
+    #
+    foreach(sanitizer "address" "undefined")
+        unset(SANITIZER_FLAG)
+        test_sanitizer(${sanitizer} SANITIZER_FLAG)
+        if(SANITIZER_FLAG)
+            message(STATUS "${sanitizer} sanitizer supported using ${SANITIZER_FLAG}")
+            set(SANITIZER_FLAGS "${SANITIZER_FLAGS} ${SANITIZER_FLAG}")
+        else()
+            message(STATUS "${sanitizer} isn't a supported sanitizer")
+        endif()
+    endforeach()
+    if("${SANITIZER_FLAGS}" STREQUAL "")
+        message(FATAL_ERROR "No supported sanitizers found")
+    endif()
+else()
+    #
+    # This appears to indicate that ENABLE_SANITIZERS was either:
+    #
+    #   not set;
+    #   set to a set to a string value that is not "one of the true
+    #   constants", meaning "1, ON, YES, TRUE, Y, or a non-zero number".
+    #
+    # The latter includes setting it to "one of the false constants",
+    # meaning the string "is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND,
+    # the empty string, or ends in the suffix -NOTFOUND."
+    #
+    # It also includes setting it to a list of one or more sanitizers.
+    #
+    # We want to treat "not set" and "set to one of the false constants"
+    # as meaning "do not enable any sanitizers".
+    #
+    # We want to treat "set to a list of one or more sanitizers" as
+    # meaning "enable all the sanitizers in the list".
+    #
+    # This requires that we distinguish between those two cases.
+    #
+    if(ENABLE_SANITIZERS)
+        #
+        # This appears to indicate that ENABLE_SANITIZERS was set to
+        # a string value that is "not one of the false constants".
+        #
+        # We already know it's "not one of the true constants", so
+        # we treat it as a list of sanitizers.
+        #
+        foreach(sanitizer IN LISTS ENABLE_SANITIZERS)
+            unset(SANITIZER_FLAG)
+            test_sanitizer(${sanitizer} SANITIZER_FLAG)
+            if(SANITIZER_FLAG)
+                message(STATUS "${sanitizer} sanitizer supported using ${SANITIZER_FLAG}")
+                set(SANITIZER_FLAGS "${SANITIZER_FLAGS} ${SANITIZER_FLAG}")
+            else()
+                message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer")
+            endif()
+        endforeach()
+    else()
+        #
+        # This appears to indicate that ENABLE_SANITIZERS was either:
+        #
+        #   not set;
+        #   set to a value that's "one of the false constants";
+        #
+        # so we don't enable any sanitizers.
+        #
+        message(STATUS "Not enabling sanitizers")
+    endif()
+endif()
 
 if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -g ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
 endif()
 
-#
-# OpenSSL/libressl.
-#
-find_package(OpenSSL)
-if(OPENSSL_FOUND)
+if(ENABLE_REMOTE)
   #
-  # We have OpenSSL.
+  # OpenSSL/libressl.
   #
-  include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
-  set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${OPENSSL_LIBRARIES})
+  find_package(OpenSSL)
+  if(OPENSSL_FOUND)
+    #
+    # We have OpenSSL.
+    #
+    include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
+    set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${OPENSSL_LIBRARIES})
 
-  #
-  # The find_package() module CMake provides for OpenSSL uses does not
*** 38674 LINES SKIPPED ***