]> The Tcpdump Group git mirrors - libpcap/commitdiff
Merge pull request #1039 from gokulkumar792/add_bar_and_ba_ctl_frames
authorGuy Harris <[email protected]>
Mon, 13 Sep 2021 21:38:46 +0000 (14:38 -0700)
committerGitHub <[email protected]>
Mon, 13 Sep 2021 21:38:46 +0000 (14:38 -0700)
IEEE 802.11: add support to filter Block Ack Req & Block Ack control frames

36 files changed:
.cirrus.yml
CHANGES
CMakeLists.txt
INSTALL.md
Makefile.in
build.sh
build_common.sh
build_matrix.sh
charconv.h
configure
configure.ac
diag-control.h
doc/README.aix
doc/README.dag
doc/README.septel
doc/README.sita
doc/README.solaris.md [new file with mode: 0644]
ftmacros.h
gencode.c
gencode.h
grammar.y.in
nametoaddr.c
optimize.c
pcap-bpf.c
pcap-common.c
pcap-config.in
pcap-filter.manmisc.in
pcap-linux.c
pcap.c
pcap/bpf.h
pcap/compiler-tests.h
pcap/dlt.h
pcap/funcattrs.h
savefile.c
scanner.l
testprogs/CMakeLists.txt

index 83376f8e05ecbeb7d2fbc884767ccdffad7df404..1bf2a89932eedc44b69cf1ba9f82569be2bb288a 100644 (file)
@@ -19,10 +19,10 @@ freebsd_task:
   env:
     IGNORE_OSVERSION: yes
     MAKEFLAGS: -j 4
-    MATRIX_CC: clang gcc48 gcc10
+    MATRIX_CC: clang gcc10
   script:
-    - pkg install -qy autoconf gcc48 gcc10
-    - pkg install -qy cmake git # for build_matrix.sh and build.sh
+    - pkg install -qy autoconf gcc10
+    - pkg install -qy cmake git-tiny # for build_matrix.sh and build.sh
     - ./build_matrix.sh
 
 linux_task:
diff --git a/CHANGES b/CHANGES
index 9f14d9865c384a022a72a7f9491a12cab3877424..a62b9c56bd1322c68bab77eb499c117429d484e2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,7 +4,10 @@ Monthday, Month DD, YYYY:
     Building and testing:
       Handle some Autoconf/make errors better.
       Fix "make releasetar" on AIX, OpenBSD and Solaris.
-      Fix compiling on Solaris 9.
+      Fix compiling on Solaris 9/SPARC and 11/AMD64.
+      Address assorted compiler warnings.
+    Documentation:
+      Add README.solaris.md.
 
 Monthday, Month DD, YYYY:
   Summary for 1.10.2 libpcap release (so far!)
index ff3014a6783c4bc5f10a09e90ee1dc51c3c7dc8e..fdd91800f428a46bfcc5ec3bcc4ff1e74de48ff3 100644 (file)
@@ -2052,6 +2052,19 @@ if(NOT MSVC)
     endif()
 endif(NOT MSVC)
 
+#
+# Extra compiler options for the build matrix scripts to request -Werror or
+# its equivalent if required.  The CMake variable name cannot be CFLAGS
+# because that is already used for a different purpose in CMake.  Example
+# usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ...
+#
+if(NOT "${EXTRA_CFLAGS}" STREQUAL "")
+    foreach(_extra_cflag ${EXTRA_CFLAGS})
+        check_and_add_compiler_option("${_extra_cflag}")
+    endforeach(_extra_cflag)
+    message(STATUS "Added extra compile options (${EXTRA_CFLAGS})")
+endif()
+
 #
 # Flex/Lex and YACC/Berkeley YACC/Bison.
 # From a mail message to the CMake mailing list by Andy Cedilnik of
index feef03dc8373e8e88bbcc76cdba9ed6bb15e32ab..2bff7da7eb67d828a500ce757264572ef35ec876 100644 (file)
@@ -264,6 +264,7 @@ FILES
        doc/README.macos    - notes on using libpcap on macOS
        doc/README.septel   - notes on using libpcap to capture on Intel/Septel devices
        doc/README.sita     - notes on using libpcap to capture on SITA devices
+       doc/README.solaris.md - notes on using libpcap on Solaris
        doc/README.tru64    - notes on using libpcap on Digital/Tru64 UNIX
        doc/README.Win32.md - notes on using libpcap on Win32 systems (with Npcap)
        VERSION             - version of this release
index f6132522494f2d909c507416ea22d48159c9cb83..c6ba79faf68e886f8cb12f3ce83dc3751542a1d2 100644 (file)
@@ -262,6 +262,7 @@ EXTRA_DIST = \
        doc/README.macos \
        doc/README.septel \
        doc/README.sita \
+       doc/README.solaris.md \
        doc/README.tru64 \
        CONTRIBUTING.md \
        TODO \
index c28a83b7b094e7574f90825a3e750e9db19aa817..9dd3066a622f82debb22fe882ed24b71a47a2a20 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -5,6 +5,8 @@
 : "${CC:=gcc}"
 : "${CMAKE:=no}"
 : "${REMOTE:=no}"
+: "${LIBPCAP_TAINTED:=no}"
+: "${MAKE_BIN:=make}"
 
 . ./build_common.sh
 # Install directory prefix
@@ -16,6 +18,71 @@ if [ -z "$PREFIX" ]; then
 fi
 
 print_cc_version
+
+# The norm is to compile without any warnings, but libpcap builds on some OSes
+# are not warning-free for one or another reason.  If you manage to fix one of
+# these cases, please remember to remove respective exemption below to help any
+# later warnings in the same matrix subset trigger an error.
+# shellcheck disable=SC2006,SC2221,SC2222
+case `cc_id`/`os_id` in
+gcc-*/Linux-*)
+    # This warning is a bit odd.  It is steadily present in Cirrus CI, but not
+    # in Buildbot.  On my Linux system with the same exact distribution and GCC
+    # as Cirrus CI it reproduces only if GCC receives the "-g" flag:
+    # make CFLAGS=-g -- does not reproduce
+    # CFLAGS=-g make -- reproduces
+    # make -- reproduces
+    #
+    # pcap-linux.c:947:8: warning: ignoring return value of 'write', declared
+    # with attribute warn_unused_result [-Wunused-result]
+    #
+    # And even this way it does not make GCC exit with an error when it has
+    # reported the warning and has received the "-Werror" flag. So let's keep
+    # this block no-op for now.
+    ;;
+clang-*/NetBSD-*)
+    # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision:
+    # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+    # [-Wshorten-64-to-32]
+    # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision:
+    # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+    # [-Wshorten-64-to-32]
+    # pcap-bpf.c:1274:39: warning: implicit conversion loses integer precision:
+    # 'long' to 'suseconds_t' (aka 'int') [-Wshorten-64-to-32]
+    LIBPCAP_TAINTED=yes
+    ;;
+clang-*/SunOS-5.11)
+    # (Solaris 11 and OpenIndiana)
+    # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision:
+    #   'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+    #   [-Wshorten-64-to-32]
+    # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision:
+    #   'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
+    #   [-Wshorten-64-to-32]
+    # fad-getad.c:266:52: warning: implicit conversion loses integer precision:
+    #   'uint64_t'(aka 'unsigned long') to 'bpf_u_int32' (aka 'unsigned int')
+    #   [-Wshorten-64-to-32]
+    # (Solaris 11)
+    # pcap-bpf.c:1843:22: warning: implicit conversion loses integer precision:
+    #   'long' to 'int' [-Wshorten-64-to-32]
+    # (OpenIndiana)
+    # rpcapd.c:393:18: warning: this function declaration is not a prototype
+    #   [-Wstrict-prototypes]
+    [ "`uname -p`" = i386 ] && LIBPCAP_TAINTED=yes
+    ;;
+suncc-5.1[45]/SunOS-5.11)
+    # "scanner.l", line 257: warning: statement not reached
+    # (186 warnings for scanner.l)
+    #
+    # "./filtertest.c", line 259: warning: statement not reached
+    # "./filtertest.c", line 276: warning: statement not reached
+    # "./filtertest.c", line 281: warning: statement not reached
+    LIBPCAP_TAINTED=yes
+    ;;
+esac
+# shellcheck disable=SC2006
+[ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
+
 if [ "$CMAKE" = no ]; then
     run_after_echo ./configure --prefix="$PREFIX" --enable-remote="$REMOTE"
 else
@@ -25,15 +92,22 @@ else
     run_after_echo rm -rf CMakeFiles/ CMakeCache.txt
     [ ! -d build ] && run_after_echo mkdir build
     run_after_echo cd build
-    run_after_echo cmake -DCMAKE_INSTALL_PREFIX="$PREFIX" -DENABLE_REMOTE="$REMOTE" ..
+    run_after_echo cmake ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
+        -DCMAKE_INSTALL_PREFIX="$PREFIX" -DENABLE_REMOTE="$REMOTE" ..
+fi
+run_after_echo "$MAKE_BIN" -s clean
+if [ "$CMAKE" = no ]; then
+    run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
+    run_after_echo "$MAKE_BIN" -s testprogs ${CFLAGS:+CFLAGS="$CFLAGS"}
+else
+    # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
+    run_after_echo "$MAKE_BIN"
+    run_after_echo "$MAKE_BIN" testprogs
 fi
-run_after_echo make -s clean
-run_after_echo make -s
-run_after_echo make -s testprogs
-run_after_echo make install
+run_after_echo "$MAKE_BIN" install
 if [ "$CMAKE" = no ]; then
     run_after_echo testprogs/findalldevstest
-    run_after_echo make releasetar
+    run_after_echo "$MAKE_BIN" releasetar
 else
     run_after_echo run/findalldevstest
 fi
index 50fcc388534f09314eac086a0e8e0628af283fbf..21d62b835dd8bdf2d8f0e22c70087481f9512219 100644 (file)
@@ -12,7 +12,7 @@ mktempdir_diy() {
         # /bin/sh implements $RANDOM in AIX 7, but not in Solaris before 11,
         # thus use dd and od instead.
         # shellcheck disable=SC2006
-        mktempdir_diy_suffix=`dd if=/dev/urandom bs=1 count=4 2>/dev/null | od -t x -A n | head -1 | tr -d '\t '`
+        mktempdir_diy_suffix=`dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -t x -A n | head -1 | tr -d '\t '`
         [ -z "$mktempdir_diy_suffix" ] && return 1
         mktempdir_diy_path="${TMPDIR:-/tmp}/${1:?}.${mktempdir_diy_suffix}"
         # "test -e" would be more appropriate, but it is not available in
@@ -23,33 +23,26 @@ mktempdir_diy() {
             echo "$mktempdir_diy_path"
             break
         fi
-        # Try again (AIX /dev/urandom returns zeroes quite often).
+        # Try again (very unlikely, just in case).
     done
 }
 
 mktempdir() {
     mktempdir_prefix=${1:-tmp}
     # shellcheck disable=SC2006
-    case `uname -s` in
-    Darwin|FreeBSD|NetBSD)
+    case `os_id` in
+    Darwin-*|FreeBSD-*|NetBSD-*)
         # In these operating systems mktemp(1) always appends an implicit
         # ".XXXXXXXX" suffix to the requested template when creating a
         # temporary directory.
         mktemp -d -t "$mktempdir_prefix"
         ;;
-    AIX)
-        mktempdir_diy "$mktempdir_prefix"
+    SunOS-5.10|SunOS-5.11)
+        # Although the suffix is optional, specify it for consistent results.
+        mktemp -d -t "${mktempdir_prefix}.XXXXXXXX"
         ;;
-    SunOS)
-        # shellcheck disable=SC2006
-        case `uname -r` in
-        5.10|5.11)
-            mktemp -d -t "${mktempdir_prefix}.XXXXXXXX"
-            ;;
-        *)
-            mktempdir_diy "$mktempdir_prefix"
-            ;;
-        esac
+    SunOS-*|AIX-*)
+        mktempdir_diy "$mktempdir_prefix"
         ;;
     *)
         # At least Linux and OpenBSD implementations require explicit trailing
@@ -61,31 +54,164 @@ mktempdir() {
 
 print_sysinfo() {
     uname -a
+    printf 'OS identification: '
+    os_id
     date
 }
 
-print_cc_version() {
-    # shellcheck disable=SC2006
+# Try to make the current C compiler print its version information (usually
+# multi-line) to stdout.
+# shellcheck disable=SC2006
+cc_version_nocache() {
+    : "${CC:?}"
     case `basename "$CC"` in
-    gcc*|clang*)
+    gcc*|egcc*|clang*)
         # GCC and Clang recognize --version, print to stdout and exit with 0.
         "$CC" --version
         ;;
     xl*)
-        # XL C for AIX recognizes -qversion, prints to stdout and exits with 0,
-        # but on an unknown command-line flag displays its man page and waits.
-        "$CC" -qversion
+        # XL C 12.1 and 13.1 recognize "-qversion", print to stdout and exit
+        # with 0. XL C 12.1 on an unknown command-line flag displays its man
+        # page and waits.
+        # XL C 16.1 recognizes "-qversion" and "--version", prints to stdout
+        # and exits with 0. Community Edition also prints a banner to stderr.
+        "$CC" -qversion 2>/dev/null
         ;;
     sun*)
         # Sun compilers recognize -V, print to stderr and exit with an error.
         "$CC" -V 2>&1 || :
         ;;
+    cc)
+        case `os_id` in
+        SunOS-*)
+            # Most likely Sun C.
+            "$CC" -V 2>&1 || :
+            ;;
+        Darwin-*)
+            # Most likely Clang.
+            "$CC" --version
+            ;;
+        Linux-*|FreeBSD-*|NetBSD-*|OpenBSD-*)
+            # Most likely Clang or GCC.
+            "$CC" --version
+            ;;
+        esac
+        ;;
     *)
         "$CC" --version || "$CC" -V || :
         ;;
     esac
 }
 
+# shellcheck disable=SC2006
+cc_version() {
+    echo "${cc_version_cached:=`cc_version_nocache`}"
+}
+
+print_cc_version() {
+    cc_version
+    printf 'Compiler identification: '
+    cc_id
+}
+
+# For the current C compiler try to print a short and uniform identification
+# string (such as "gcc-9.3.0") that is convenient to use in a case statement.
+# shellcheck disable=SC2006
+cc_id_nocache() {
+    cc_id_firstline=`cc_version | head -1`
+    : "${cc_id_firstline:?}"
+
+    cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^.*clang version \([0-9\.]*\).*$/clang-\1/'`
+    if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+        echo "$cc_id_guessed"
+        return
+    fi
+
+    cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^IBM XL C.*, V\([0-9\.]*\).*$/xlc-\1/'`
+    if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+        echo "$cc_id_guessed"
+        return
+    fi
+
+    cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^.* Sun C \([0-9\.]*\) .*$/suncc-\1/'`
+    if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+        echo "$cc_id_guessed"
+        return
+    fi
+
+    cc_id_guessed=`echo "$cc_id_firstline" | sed 's/^.* (.*) \([0-9\.]*\)$/gcc-\1/'`
+    if [ "$cc_id_firstline" != "$cc_id_guessed" ]; then
+        echo "$cc_id_guessed"
+        return
+    fi
+}
+
+# shellcheck disable=SC2006
+cc_id() {
+    echo "${cc_id_cached:=`cc_id_nocache`}"
+}
+
+# Call this function each time CC has changed.
+discard_cc_cache() {
+    cc_version_cached=
+    cc_id_cached=
+}
+
+# For the current C compiler try to print CFLAGS value that tells to treat
+# warnings as errors.
+# shellcheck disable=SC2006
+cc_werr_cflags() {
+    case `cc_id` in
+    gcc-*|clang-*)
+        echo '-Werror'
+        ;;
+    xlc-*)
+        # XL C 12.1 and 13.1 recognize "-qhalt=w". XL C 16.1 recognizes that
+        # and "-Werror".
+        echo '-qhalt=w'
+        ;;
+    suncc-*)
+        echo '-errwarn=%all'
+        ;;
+    esac
+}
+
+# Tell whether "gcc" is a symlink to Clang (this is the case on macOS).
+# shellcheck disable=SC2006
+gcc_is_clang_in_disguise() {
+    case `cc_id`/`basename "${CC:?}"` in
+    clang-*/gcc)
+        return 0
+        ;;
+    esac
+    return 1
+}
+
+# shellcheck disable=SC2006
+os_id() {
+    # OS does not change between builds or in the middle of a build, so it is
+    # fine to cache uname output.
+    : "${os_id_sysname:=`uname -s`}"
+    printf '%s-' "$os_id_sysname"
+    : "${os_id_release:=`uname -r`}"
+    case "$os_id_sysname" in
+    AIX)
+        : "${os_id_version:=`uname -v`}"
+        echo "${os_id_version}.${os_id_release}"
+        ;;
+    Darwin|NetBSD|OpenBSD|SunOS)
+        echo "$os_id_release"
+        ;;
+    FreeBSD|Linux)
+        # Meaningful version is usually the substring before the first dash.
+        echo "$os_id_release" | sed 's/^\([0-9\.]*\).*$/\1/'
+        ;;
+    *)
+        echo 'UNKNOWN'
+        ;;
+    esac
+}
+
 increment() {
     # No arithmetic expansion in Solaris /bin/sh before 11.
     echo "${1:?} + 1" | bc
@@ -106,8 +232,8 @@ run_after_echo() {
 
 print_so_deps() {
     # shellcheck disable=SC2006
-    case `uname -s` in
-    Darwin)
+    case `os_id` in
+    Darwin-*)
         run_after_echo otool -L "${1:?}"
         ;;
     *)
@@ -131,7 +257,7 @@ handle_matrix_debug() {
 
 purge_directory() {
     # shellcheck disable=SC2006
-    if [ "`uname -s`" = SunOS ] && [ "`uname -r`" = 5.11 ]; then
+    if [ "`os_id`" = SunOS-5.11 ]; then
         # In Solaris 11 /bin/sh the pathname expansion of "*" always includes
         # "." and "..", so the straightforward rm would always fail.
         (
index c2c9e3c6537185411ee5dde2c424797967a7ab4a..489f51757854583d25e057e153541f9d187bcd95 100755 (executable)
@@ -6,6 +6,15 @@
 : "${MATRIX_CC:=gcc clang}"
 : "${MATRIX_CMAKE:=no yes}"
 : "${MATRIX_REMOTE:=no yes}"
+# Set this variable to "yes" before calling this script to disregard all
+# warnings in a particular environment (CI or a local working copy).  Set it
+# to "yes" in this script or in build.sh when a matrix subset is known to be
+# not warning-free because of the OS, the compiler or whatever other factor
+# that the scripts can detect both in and out of CI.
+: "${LIBPCAP_TAINTED:=no}"
+# Some OSes have native make without parallel jobs support and sometimes have
+# GNU Make available as "gmake".
+: "${MAKE_BIN:=make}"
 # It calls the build.sh script which runs one build with setup environment
 # variables: CC, CMAKE and REMOTE.
 
@@ -19,13 +28,13 @@ if [ -z "$PREFIX" ]; then
     export PREFIX
 fi
 COUNT=0
+export LIBPCAP_TAINTED
 
 touch .devel configure
 for CC in $MATRIX_CC; do
     export CC
-    # Exclude gcc on macOS (it is just an alias for clang).
-    # shellcheck disable=SC2006
-    if [ "$CC" = gcc ] && [ "`uname -s`" = Darwin ]; then
+    discard_cc_cache
+    if gcc_is_clang_in_disguise; then
         echo '(skipped)'
         continue
     fi
@@ -35,11 +44,11 @@ for CC in $MATRIX_CC; do
             export REMOTE
             # shellcheck disable=SC2006
             COUNT=`increment $COUNT`
-            echo_magenta "===== SETUP $COUNT: CC=$CC CMAKE=$CMAKE REMOTE=$REMOTE ====="
+            echo_magenta "===== SETUP $COUNT: CC=$CC CMAKE=$CMAKE REMOTE=$REMOTE =====" >&2
             # Run one build with setup environment variables: CC, CMAKE and REMOTE
             run_after_echo ./build.sh
             echo 'Cleaning...'
-            if [ "$CMAKE" = yes ]; then rm -rf build; else make distclean; fi
+            if [ "$CMAKE" = yes ]; then rm -rf build; else "$MAKE_BIN" distclean; fi
             purge_directory "$PREFIX"
             run_after_echo git status -suall
             # Cancel changes in configure
@@ -48,5 +57,5 @@ for CC in $MATRIX_CC; do
     done
 done
 run_after_echo rm -rf "$PREFIX"
-echo_magenta "Tested setup count: $COUNT"
+echo_magenta "Tested setup count: $COUNT" >&2
 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :
index a37d424b7cd592cefc47ee5be8c5aaf10a81a9d5..93103d461ef766c838b52c8161d7ea7ff4b50043 100644 (file)
@@ -32,8 +32,8 @@
  * SUCH DAMAGE.
  */
 
-#ifndef charonv_h
-#define charonv_h
+#ifndef charconv_h
+#define charconv_h
 
 #ifdef _WIN32
 extern wchar_t *cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags);
@@ -41,4 +41,4 @@ extern char *utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string);
 extern void utf_8_to_acp_truncated(char *);
 #endif
 
-#endif
+#endif /* charconv_h */
index 86fdce413230923608e72903530e8aa549ce9204..e66c6474c38535577ffbb215764aa346fbd321d0 100755 (executable)
--- a/configure
+++ b/configure
@@ -8600,7 +8600,13 @@ fi
 $as_echo "$tcpdump_cv_capable_lex" >&6; }
 if test $tcpdump_cv_capable_lex = insufficient ; then
        as_fn_error $? "$LEX is insufficient to compile libpcap.
- libpcap requires Flex 2.5.31 or later, or a compatible version of lex." "$LINENO" 5
+ libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
+ If a suitable version of Lex/Flex is available as a non-standard command
+ and/or not in the PATH, you can specify it using the LEX environment
+ variable. That said, on some systems the error can mean that Flex/Lex is
+ actually acceptable, but m4 is not. Likewise, if a suitable version of
+ m4 (such as GNU M4) is available but has not been detected, you can
+ specify it using the M4 environment variable." "$LINENO" 5
 fi
 
 #
@@ -8747,7 +8753,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_yacc" >&5
 $as_echo "$tcpdump_cv_capable_yacc" >&6; }
                if test $tcpdump_cv_capable_yacc = insufficient ; then
-                   as_fn_error $? "$YACC is insufficient to compile libpcap.
+                   as_fn_error $? "$BISON_BYACC is insufficient to compile libpcap.
  libpcap requires Bison, a newer version of Berkeley YACC with support
  for reentrant parsers, or another YACC compatible with them." "$LINENO" 5
                fi
index bd5b27663cf330048efd31c81af4bc0e8310db1d..321524fd784d6f3b96d76be967f0ec2f6c6e334a 100644 (file)
@@ -1735,7 +1735,13 @@ AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
        fi)
 if test $tcpdump_cv_capable_lex = insufficient ; then
        AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
- libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
+ libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
+ If a suitable version of Lex/Flex is available as a non-standard command
+ and/or not in the PATH, you can specify it using the LEX environment
+ variable. That said, on some systems the error can mean that Flex/Lex is
+ actually acceptable, but m4 is not. Likewise, if a suitable version of
+ m4 (such as GNU M4) is available but has not been detected, you can
+ specify it using the M4 environment variable.])
 fi
 
 #
@@ -1793,7 +1799,7 @@ else
                        tcpdump_cv_capable_yacc=insufficient
                    fi)
                if test $tcpdump_cv_capable_yacc = insufficient ; then
-                   AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
+                   AC_MSG_ERROR([$BISON_BYACC is insufficient to compile libpcap.
  libpcap requires Bison, a newer version of Berkeley YACC with support
  for reentrant parsers, or another YACC compatible with them.])
                fi
index 304295f312d51ea32d7695dbf35197f78fadf8d2..d1622aa6f81dd121e4e3d14520638749a27e8476 100644 (file)
 
   /*
    * Suppress format-truncation= warnings.
+   * GCC 7.1 had introduced this warning option. Earlier versions (at least
+   * one particular copy of GCC 4.6.4) treat the request as a warning.
    */
-  #define DIAG_OFF_FORMAT_TRUNCATION \
-    PCAP_DO_PRAGMA(GCC diagnostic push) \
-    PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wformat-truncation=")
-  #define DIAG_ON_FORMAT_TRUNCATION \
-    PCAP_DO_PRAGMA(GCC diagnostic pop)
+  #if PCAP_IS_AT_LEAST_GNUC_VERSION(7,1)
+    #define DIAG_OFF_FORMAT_TRUNCATION \
+      PCAP_DO_PRAGMA(GCC diagnostic push) \
+      PCAP_DO_PRAGMA(GCC diagnostic ignored "-Wformat-truncation=")
+    #define DIAG_ON_FORMAT_TRUNCATION \
+      PCAP_DO_PRAGMA(GCC diagnostic pop)
+  #else
+   #define DIAG_OFF_FORMAT_TRUNCATION
+   #define DIAG_ON_FORMAT_TRUNCATION
+  #endif
 #else
   /*
    * Neither Visual Studio, nor Clang 2.8 or later, nor GCC 4.6 or later
   #endif
 #endif
 
+/*
+ * GCC needs this on AIX for longjmp().
+ */
+#if PCAP_IS_AT_LEAST_GNUC_VERSION(5,1)
+  /*
+   * Beware that the effect of this builtin is more than just squelching the
+   * warning! GCC trusts it enough for the process to segfault if the control
+   * flow reaches the builtin (an infinite empty loop in the same context would
+   * squelch the warning and ruin the process too, albeit in a different way).
+   * So please remember to use this very carefully.
+   */
+  #define PCAP_UNREACHABLE __builtin_unreachable();
+#else
+  #define PCAP_UNREACHABLE
+#endif
+
 #endif /* _diag_control_h */
index 9e9a23d39db97a465fd693032c9859e899a9e06b..868999476af9e5bbb63b2dafb2c3ab40377c2509 100644 (file)
@@ -1,3 +1,25 @@
+# Compiling libpcap on AIX
+
+* Autoconf is expected to work everywhere.
+* Neither AIX lex nor AIX yacc nor AIX m4 are suitable.
+
+## AIX 7.1
+
+* libpcap build fails with rpcapd enabled.
+* GNU M4 1.4.17 works.
+* flex 2.6.4 and GNU Bison 3.5.1 work.
+* CMake 3.16.0 works.
+* GCC 8.3.0 works, XL C 12.1.0 works.
+
+## AIX 7.2
+
+* libpcap build fails with rpcapd enabled.
+* GNU M4 1.4.17 works.
+* flex 2.5.35 and GNU Bison 3.0.4 work.
+* GCC 7.2.0 works, XL C 13.1.3 works.
+
+## Other AIX-related information
+
 Using BPF:
 
 (1) AIX 4.x's version of BPF is undocumented and somewhat unstandard; the
index 13332c627bddc5425e7ae7a69996f3834b04b1fd..fd2c4b741bd721b7664104da5e8ba6b7fbc5ca9d 100644 (file)
@@ -22,7 +22,7 @@ If 'configure' reports that there is no DAG API, the directory may have been
 incorrectly specified or the DAG software was not built before configuring
 libpcap.
 
-See also the libpcap INSTALL.txt file for further libpcap configuration
+See also the libpcap INSTALL.md file for further libpcap configuration
 options.
 
 Building libpcap at this stage will include support for both the native packet
index 203ec1a6edcb7eb772a9412a7574f270402a39f7..d7fb5c7c61a78e7586bd2b0f5907052adfca5b1a 100644 (file)
@@ -25,7 +25,7 @@ If 'configure' reports that there is no Septel API, the directory may have been
 incorrectly specified or the Septel software was not built before configuring
 libpcap.
 
-See also the libpcap INSTALL.txt file for further libpcap configuration
+See also the libpcap INSTALL.md file for further libpcap configuration
 options.
 
 Building libpcap at this stage will include support for both the native
index 37003f534bc30c53f83d4fb465e51fe16ae8e70d..c85e0d8ceab47397289e853bc43eab8459063139 100644 (file)
@@ -12,7 +12,7 @@ libpcap to support the 'ACN' WAN/LAN router product from SITA
 This might also work on non-Linux Unix-compatible platforms, but that
 has not been tested.
 
-See also the libpcap INSTALL.txt file for further libpcap configuration
+See also the libpcap INSTALL.md file for further libpcap configuration
 options.
 
 These additions/extensions have been made to PCAP to allow it to
diff --git a/doc/README.solaris.md b/doc/README.solaris.md
new file mode 100644 (file)
index 0000000..0745671
--- /dev/null
@@ -0,0 +1,44 @@
+# Compiling libpcap on Solaris and related OSes
+
+* Autoconf works everywhere.
+* Neither Solaris lex nor Solaris yacc are suitable.
+* Neither OpenIndiana lex nor OpenIndiana yacc are suitable.
+* Solaris m4 and OpenIndiana m4 are suitable.
+
+## OpenIndiana 2021.04/AMD64
+
+* flex 2.6.4 and GNU Bison 3.7.6 work.
+* CMake 3.21.1 works.
+* GCC 7.5.0 and GCC 10.3.0 work, Clang 9.0.1 works.
+
+For reference, the tests were done using a system installed from
+`OI-hipster-text-20210430.iso` plus the following packages:
+```shell
+xargs -L1 pkg install <<ENDOFTEXT
+developer/build/autoconf
+developer/parser/bison
+developer/lexer/flex
+developer/build/cmake
+developer/gcc-10
+developer/clang-90
+ENDOFTEXT
+```
+
+## Solaris 11/SPARC
+
+* flex 2.6.4 and GNU Bison 3.7.1 work.
+* CMake 3.14.3 works.
+* Sun C 5.13, Sun C 5.14 and Sun C 5.15 work; GCC 5.5.0 and GCC 7.3.0 work.
+
+## Solaris 10/SPARC
+
+* libpcap build fails with rpcapd enabled.
+* flex 2.6.4 and GNU Bison 3.7.1 work.
+* CMake 3.14.3 works.
+* Sun C 5.13 works, GCC 5.5.0 works.
+
+## Solaris 9/SPARC
+
+* flex 2.5.35 and GNU Bison 3.0.2 work.
+* CMake 2.8.9 does not work.
+* Neither Sun C 5.8 nor Sun C 5.9 work, GCC 4.6.4 works.
index 3cd750568785d738bb241577c35d2385029f8557..7975463b3a6924738ef7e1ffa72370f11006ada6 100644 (file)
  * namespace to the maximum extent possible"?
  */
 #if defined(sun) || defined(__sun)
-  #define __EXTENSIONS__
+  /*
+   * On Solaris Clang defines __EXTENSIONS__ automatically.
+   */
+  #ifndef __EXTENSIONS__
+    #define __EXTENSIONS__
+  #endif
 
   /*
    * We also need to define _XPG4_2 in order to get
index efdcb987485f7355a44df35d3f8ba70355983741..aef078e2533de458564c784f277164d32a10aae6 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -77,8 +77,8 @@
 #include "pcap/sll.h"
 #include "pcap/ipnet.h"
 #include "arcnet.h"
+#include "diag-control.h"
 
-#include "grammar.h"
 #include "scanner.h"
 
 #if defined(linux)
@@ -475,6 +475,9 @@ bpf_error(compiler_state_t *cstate, const char *fmt, ...)
        va_end(ap);
        longjmp(cstate->top_ctx, 1);
        /*NOTREACHED*/
+#ifdef _AIX
+       PCAP_UNREACHABLE
+#endif /* _AIX */
 }
 
 static int init_linktype(compiler_state_t *, pcap_t *);
@@ -1722,7 +1725,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p)
                        cstate->off_nl = OFFSET_NOT_SET;
                        cstate->off_nl_nosnap = OFFSET_NOT_SET;
                } else {
-                       bpf_set_error(cstate, "unknown data link type %d", cstate->linktype);
+                       bpf_set_error(cstate, "unknown data link type %d (min %d, max %d)",
+                           cstate->linktype, DLT_MATCHING_MIN, DLT_MATCHING_MAX);
                        return (-1);
                }
                break;
index 053e85f9c6652387c837b601d2c90ae0c6bc3bf6..9631dd02ee08e66bb254110dad0b094b3a70b919 100644 (file)
--- a/gencode.h
+++ b/gencode.h
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+#ifndef gencode_h
+#define gencode_h
+
 #include "pcap/funcattrs.h"
+#include "pcap/bpf.h" /* bpf_u_int32 and BPF_MEMWORDS */
 
 /*
  * ATM support:
@@ -400,3 +404,5 @@ int pcap_parse(void *, compiler_state_t *);
 /* XXX */
 #define JT(b)  ((b)->et.succ)
 #define JF(b)  ((b)->ef.succ)
+
+#endif /* gencode_h */
index 2f2c86132c3cd21d274e98ae3f4b1c30f0b5bbde..357dcbacb94393ef990ea357b5d8608fb9e55bdd 100644 (file)
 #include <config.h>
 #endif
 
+/*
+ * grammar.h requires gencode.h and sometimes breaks in a polluted namespace
+ * (see ftmacros.h), so include it early.
+ */
+#include "gencode.h"
+#include "grammar.h"
+
 #include <stdlib.h>
 
 #ifndef _WIN32
@@ -92,8 +99,6 @@ struct rtentry;
 
 #include "pcap-int.h"
 
-#include "gencode.h"
-#include "grammar.h"
 #include "scanner.h"
 
 #ifdef HAVE_NET_PFVAR_H
index c944ad3661d819b7b3142c391bf8fa05b4e810ac..7b2ad81b00c504f8fe919fe0f336fd8d1b6f58c7 100644 (file)
@@ -785,9 +785,14 @@ pcap_ether_hostton(const char *name)
 {
        register u_char *ap;
        u_char a[6];
+       char namebuf[1024];
 
+       /*
+        * In AIX 7.1 and 7.2: int ether_ntohost(char *, struct ether_addr *);
+        */
+       pcap_strlcpy(namebuf, name, sizeof(namebuf));
        ap = NULL;
-       if (ether_hostton(name, (struct ether_addr *)a) == 0) {
+       if (ether_hostton(namebuf, (struct ether_addr *)a) == 0) {
                ap = (u_char *)malloc(6);
                if (ap != NULL)
                        memcpy((char *)ap, (char *)a, 6);
index 7cfd1d9599762952ad595c4b06ab82d8e4dcd2db..604e35e8852801a92f6d84692f028856381971bb 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "gencode.h"
 #include "optimize.h"
+#include "diag-control.h"
 
 #ifdef HAVE_OS_PROTO_H
 #include "os-proto.h"
@@ -2421,6 +2422,9 @@ opt_error(opt_state_t *opt_state, const char *fmt, ...)
        }
        longjmp(opt_state->top_ctx, 1);
        /* NOTREACHED */
+#ifdef _AIX
+       PCAP_UNREACHABLE
+#endif /* _AIX */
 }
 
 /*
@@ -2925,6 +2929,9 @@ conv_error(conv_state_t *conv_state, const char *fmt, ...)
        va_end(ap);
        longjmp(conv_state->top_ctx, 1);
        /* NOTREACHED */
+#ifdef _AIX
+       PCAP_UNREACHABLE
+#endif /* _AIX */
 }
 
 /*
index f0ccb96561c4d4c93197dbb825915f1ecc857192..836e7d00c51569c61486ef094eb2e03c732f4ca8 100644 (file)
@@ -2968,7 +2968,7 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
 }
 #else
 static int
-get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
+get_if_flags(const char *name _U_, bpf_u_int32 *flags, char *errbuf _U_)
 {
        /*
         * Nothing we can do other than mark loopback devices as "the
index f3b2e60ff3014acf0889f77cfad57638639fa774..2e0e7b343a5cf72842cbfa64a7dbed33c6f072a3 100644 (file)
  */
 #define LINKTYPE_ETW           290
 
-#define LINKTYPE_MATCHING_MAX  290             /* highest value in the "matching" range */
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH 
+ * netANALYZER NG hardware and software.
+ * 
+ * The specification for this footer can be found at:
+ * https://kb.hilscher.com/x/brDJBw
+ *
+ * Requested by Jan Adam <[email protected]>
+ */
+#define LINKTYPE_NETANALYZER_NG        291
+
+#define LINKTYPE_MATCHING_MAX  291             /* highest value in the "matching" range */
 
 /*
  * The DLT_ and LINKTYPE_ values in the "matching" range should be the
index 54ca42f07bc5fb59b2daef5cce8befc9ef46a0bb..44fb657a190b035eca34d13d3bf9b598f49253ed 100644 (file)
@@ -41,6 +41,13 @@ do
        esac
        shift
 done
+#
+# If libdir isn't /usr/lib, add it to the link-time linker path.
+#
+if [ "$libdir" != "/usr/lib" ]
+then
+       LPATH=-L$libdir
+fi
 if [ "$V_RPATH_OPT" != "" ]
 then
        #
@@ -59,16 +66,16 @@ then
        #
        if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
        then
-               echo "-I$includedir -L$libdir -lpcap $LIBS"
+               echo "-I$includedir $LPATH -lpcap $LIBS"
        elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
        then
-               echo "-I$includedir -L$libdir $LIBS"
+               echo "-I$includedir $LPATH $LIBS"
        elif [ "$show_cflags" = 1 ]
        then
                echo "-I$includedir"
        elif [ "$show_libs" = 1 ]
        then
-               echo "-L$libdir -lpcap $LIBS"
+               echo "$LPATH -lpcap $LIBS"
        elif [ "$show_additional_libs" = 1 ]
        then
                echo "$LIBS"
@@ -80,7 +87,7 @@ else
        #
        if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
        then
-               echo "-I$includedir -L$libdir $RPATH -l$PACKAGE_NAME"
+               echo "-I$includedir $LPATH $RPATH -l$PACKAGE_NAME"
        elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
        then
                echo "-I$includedir"
@@ -89,6 +96,6 @@ else
                echo "-I$includedir"
        elif [ "$show_libs" = 1 ]
        then
-               echo "-L$libdir $RPATH -l$PACKAGE_NAME"
+               echo "$LPATH $RPATH -l$PACKAGE_NAME"
        fi
 fi
index ab5358e9809957dead90178731b2d642849e5b08..23b77e29a4dd74948e5a8bc56cf8a65303812b13 100644 (file)
@@ -818,8 +818,8 @@ True if the packet is an ATM packet, for SunATM on Solaris, and is
 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
 Release, or Release Done message.
 .IP  "\fIexpr relop expr\fR"
-True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =,
-!=, and \fIexpr\fR is an arithmetic expression composed of integer
+True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =
+or ==, !=, and \fIexpr\fR is an arithmetic expression composed of integer
 constants (expressed in standard C syntax), the normal binary operators
 [+, -, *, /, %, &, |, ^, <<, >>], a length operator, and special packet data
 accessors.  Note that all comparisons are unsigned, so that, for example,
index 878f27f01776d635495053ce5889ee21310106e9..3ae93c501baad71230d22c85c8b33e7bcc37867c 100644 (file)
@@ -1612,8 +1612,8 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
                                }
                        }
                        fclose(fh);
-                       free(pathstr);
                }
+               free(pathstr);
        }
 
 #ifdef ETHTOOL_GLINK
diff --git a/pcap.c b/pcap.c
index b8b8af2a73ab7798944afd9d4e5953b22f5d03d1..c27492b312eb409da3c02dc1c802d2b7e2a3b769 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -2849,15 +2849,27 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *er
                goto fail;
        return (p);
 fail:
-       if (status == PCAP_ERROR)
+       if (status == PCAP_ERROR) {
+               /*
+                * Another buffer is a bit cumbersome, but it avoids -Wformat-truncation.
+                */
+               char trimbuf[PCAP_ERRBUF_SIZE - 5]; /* 2 bytes shorter */
+
+               pcap_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf));
                snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %.*s", device,
-                   PCAP_ERRBUF_SIZE - 3, p->errbuf);
-       else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
+                   PCAP_ERRBUF_SIZE - 3, trimbuf);
+       else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
            status == PCAP_ERROR_PERM_DENIED ||
-           status == PCAP_ERROR_PROMISC_PERM_DENIED)
+           status == PCAP_ERROR_PROMISC_PERM_DENIED) {
+               /*
+                * Idem.
+                */
+               char trimbuf[PCAP_ERRBUF_SIZE - 8]; /* 2 bytes shorter */
+
+               pcap_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf));
                snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%.*s)", device,
-                   pcap_statustostr(status), PCAP_ERRBUF_SIZE - 6, p->errbuf);
-       else
+                   pcap_statustostr(status), PCAP_ERRBUF_SIZE - 6, trimbuf);
+       else
                snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device,
                    pcap_statustostr(status));
        pcap_close(p);
index 54373af8a350446afa7fa1a093f4046f7e7f7785..f813258224c33af00d77127b84d5c4f2fcebdf09 100644 (file)
 #if !defined(_NET_BPF_H_) && !defined(_NET_BPF_H_INCLUDED) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h)
 #define lib_pcap_bpf_h
 
-#include <pcap/funcattrs.h>
+/* u_char, u_short and u_int */
+#if defined(_WIN32)
+  #include <winsock2.h>
+#elif defined(HAVE_SYS_TYPES_H)
+  #include <sys/types.h>
+#endif
 
+#include <pcap/funcattrs.h>
 #include <pcap/dlt.h>
 
 #ifdef __cplusplus
index a69c2b0989de678974fe3f6dd7f08e9ce49dae14..2d98a707051115ab8bb0f77948c855cb21eb50a4 100644 (file)
  */
 
 #if ! defined(__GNUC__)
-#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
+  /* Not GCC and not "just like GCC" */
+  #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
 #else
-#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \
+  /* GCC or "just like GCC" */
+  #define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \
        (__GNUC__ > (major) || \
         (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
 #endif
  */
 
 #if !defined(__clang__)
-#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
+  /* Not Clang */
+  #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
 #else
-#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \
+  /* Clang */
+  #define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \
        (__clang_major__ > (major) || \
         (__clang_major__ == (major) && __clang_minor__ >= (minor)))
 #endif
  */
 
 #if ! defined(__SUNPRO_C)
-#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
+  /* Not Sun/Oracle C */
+  #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
 #else
-#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
+  /* Sun/Oracle C */
+  #define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
        (((minor) >= 10) ? \
            (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
            (((major) << 8) | ((minor) << 4)))
-#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \
+  #define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \
        (__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor)))
 #endif
 
  *
  * The version number in __xlC__ has the major version in the
  * upper 8 bits and the minor version in the lower 8 bits.
+ * On AIX __xlC__ is always defined, __ibmxl__ becomes defined in XL C 16.1.
+ * On Linux since XL C 13.1.6 __xlC__ is not defined by default anymore, but
+ * __ibmxl__ is defined since at least XL C 13.1.1.
  */
 
-#if ! defined(__xlC__)
-#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
+#if ! defined(__xlC__) && ! defined(__ibmxl__)
+  /* Not XL C */
+  #define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
 #else
-#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
+  /* XL C */
+  #if defined(__ibmxl__)
+    /*
+     * Later Linux version of XL C; use __ibmxl_version__ to test
+     * the version.
+     */
+    #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
+       (__ibmxl_version__ > (major) || \
+        (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor)))
+  #else /* __ibmxl__ */
+    /*
+     * __ibmxl__ not defined; use __xlC__ to test the version.
+     */
+    #define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
        (__xlC__ >= (((major) << 8) | (minor)))
+  #endif /* __ibmxl__ */
 #endif
 
 /*
  */
 
 #if ! defined(__HP_aCC)
-#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
+  /* Not HP C */
+  #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
 #else
-#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \
+  /* HP C */
+  #define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \
        (__HP_aCC >= ((major)*10000 + (minor)*100))
 #endif
 
index 3fa6127cb286533c61567b2edd947b8f3126aad3..3ef2b493d14caf58be19b938c488fc309364e098 100644 (file)
  */
 #define DLT_ETW                        290
 
+/*
+ * Hilscher Gesellschaft fuer Systemautomation mbH 
+ * netANALYZER NG hardware and software.
+ * 
+ * The specification for this footer can be found at:
+ * https://kb.hilscher.com/x/brDJBw
+ *
+ * Requested by Jan Adam <[email protected]>
+ */
+#define DLT_NETANALYZER_NG     291
+
 /*
  * In case the code that includes this file (directly or indirectly)
  * has also included OS files that happen to define DLT_MATCHING_MAX,
 #ifdef DLT_MATCHING_MAX
 #undef DLT_MATCHING_MAX
 #endif
-#define DLT_MATCHING_MAX       290     /* highest value in the "matching" range */
+#define DLT_MATCHING_MAX       291     /* highest value in the "matching" range */
 
 /*
  * DLT and savefile link type values are split into a class and
index a2ca542b07e329525fe2179cd40e4444ff476e86..808267c2f95a66aa8c57e93f546f1227398068b3 100644 (file)
     #if PCAP_IS_AT_LEAST_GNUC_VERSION(3,4) \
         || PCAP_IS_AT_LEAST_XL_C_VERSION(12,0)
       /*
-       * GCC 3.4 or later, or some compiler asserting compatibility with
-       * GCC 3.4 or later, or XL C 13.0 or later, so we have
+       * GCC 3.4 and later, or some compiler asserting compatibility with
+       * GCC 3.4 and later, or XL C 13.0 and later, so we have
        * __attribute__((visibility()).
        */
       #define PCAP_API_DEF     __attribute__((visibility("default")))
     #elif PCAP_IS_AT_LEAST_SUNC_VERSION(5,5)
       /*
-       * Sun C 5.5 or later, so we have __global.
+       * Sun C 5.5 and later, so we have __global.
        * (Sun C 5.9 and later also have __attribute__((visibility()),
        * but there's no reason to prefer it with Sun C.)
        */
     || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
     || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
   /*
-   * Compiler with support for __attribute((noreturn)), or GCC 2.5 or
-   * later, or some compiler asserting compatibility with GCC 2.5 or
-   * later, or Solaris Studio 12 (Sun C 5.9) or later, or IBM XL C 10.1
-   * or later (do any earlier versions of XL C support this?), or HP aCC
-   * A.06.10 or later.
+   * Compiler with support for __attribute((noreturn)), or GCC 2.5 and
+   * later, or some compiler asserting compatibility with GCC 2.5 and
+   * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
+   * and later (do any earlier versions of XL C support this?), or HP aCC
+   * A.06.10 and later.
    */
   #define PCAP_NORETURN __attribute((noreturn))
   #define PCAP_NORETURN_DEF __attribute((noreturn))
     || PCAP_IS_AT_LEAST_XL_C_VERSION(10,1) \
     || PCAP_IS_AT_LEAST_HP_C_VERSION(6,10)
   /*
-   * Compiler with support for it, or GCC 2.3 or later, or some compiler
-   * asserting compatibility with GCC 2.3 or later, or IBM XL C 10.1
+   * Compiler with support for it, or GCC 2.3 and later, or some compiler
+   * asserting compatibility with GCC 2.3 and later, or IBM XL C 10.1
    * and later (do any earlier versions of XL C support this?),
    * or HP aCC A.06.10 and later.
    */
     || PCAP_IS_AT_LEAST_SUNC_VERSION(5,13)
   /*
    * Compiler that supports __has_attribute and __attribute__((deprecated)),
-   * or GCC 4.5 or later, or Sun/Oracle C 12.4 (Sun C 5.13) or later.
+   * or GCC 4.5 and later, or Sun/Oracle C 12.4 (Sun C 5.13) and later.
    *
    * Those support __attribute__((deprecated(msg))) (we assume, perhaps
    * incorrectly, that anything that supports __has_attribute() is
 #elif defined(_MSC_VER) && !defined(BUILDING_PCAP)
   /*
    * MSVC, and we're not building libpcap itself; it's VS 2015
-   * or later, so we have the deprecated pragma.
+   * and later, so we have the deprecated pragma.
    *
    * If we *are* building libpcap, we don't want this, as it'll warn
    * us even if we *define* the function.
index d04b917a5b810a28bf2025d639cff1096d68ce10..7543b0fc5658a51d36c8aca82418a0435c64e13d 100644 (file)
@@ -350,7 +350,7 @@ pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision,
        if (fname[0] == '-' && fname[1] == '\0')
        {
                fp = stdin;
-               if (stdin == NULL) {
+               if (fp == NULL) {
                        snprintf(errbuf, PCAP_ERRBUF_SIZE,
                            "The standard input is not open");
                        return (NULL);
index 06b9acc14ce16d955c642a84d3119c831321e954..85fe395aa55eab473216a574937323ec94131e41 100644 (file)
--- a/scanner.l
+++ b/scanner.l
  */
 #include <pcap/pcap-inttypes.h>
 
+/*
+ * grammar.h requires gencode.h and sometimes breaks in a polluted namespace
+ * (see ftmacros.h), so include it early.
+ */
+#include "gencode.h"
+#include "grammar.h"
+
 #include "diag-control.h"
 }
 
 
 #include "pcap-int.h"
 
-#include "gencode.h"
-
-#include "grammar.h"
-
 /*
  * Earlier versions of Flex don't declare these, so we declare them
  * ourselves to squelch warnings.
index bf5736131dd95c0d361fe9b50e6a333ea78d698c..567f42aa6ed767725ea14956ff41344784536173 100644 (file)
@@ -41,7 +41,10 @@ endif()
 
 add_test_executable(threadsignaltest ${CMAKE_THREAD_LIBS_INIT})
 
-if(NOT WIN32)
+# Same as in configure.ac.
+if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
+   CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
+   CMAKE_SYSTEM_NAME STREQUAL "Linux")
   add_test_executable(valgrindtest)
 endif()