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:
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!)
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
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
doc/README.macos \
doc/README.septel \
doc/README.sita \
+ doc/README.solaris.md \
doc/README.tru64 \
CONTRIBUTING.md \
TODO \
: "${CC:=gcc}"
: "${CMAKE:=no}"
: "${REMOTE:=no}"
+: "${LIBPCAP_TAINTED:=no}"
+: "${MAKE_BIN:=make}"
. ./build_common.sh
# Install directory prefix
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
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
# /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
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
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
print_so_deps() {
# shellcheck disable=SC2006
- case `uname -s` in
- Darwin)
+ case `os_id` in
+ Darwin-*)
run_after_echo otool -L "${1:?}"
;;
*)
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.
(
: "${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.
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
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
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 :
* 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);
extern void utf_8_to_acp_truncated(char *);
#endif
-#endif
+#endif /* charconv_h */
$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
#
{ $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
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
#
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
/*
* 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 */
+# 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
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
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
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
--- /dev/null
+# 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.
* 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
#include "pcap/sll.h"
#include "pcap/ipnet.h"
#include "arcnet.h"
+#include "diag-control.h"
-#include "grammar.h"
#include "scanner.h"
#if defined(linux)
va_end(ap);
longjmp(cstate->top_ctx, 1);
/*NOTREACHED*/
+#ifdef _AIX
+ PCAP_UNREACHABLE
+#endif /* _AIX */
}
static int init_linktype(compiler_state_t *, pcap_t *);
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;
* 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:
/* XXX */
#define JT(b) ((b)->et.succ)
#define JF(b) ((b)->ef.succ)
+
+#endif /* gencode_h */
#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
#include "pcap-int.h"
-#include "gencode.h"
-#include "grammar.h"
#include "scanner.h"
#ifdef HAVE_NET_PFVAR_H
{
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);
#include "gencode.h"
#include "optimize.h"
+#include "diag-control.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
}
longjmp(opt_state->top_ctx, 1);
/* NOTREACHED */
+#ifdef _AIX
+ PCAP_UNREACHABLE
+#endif /* _AIX */
}
/*
va_end(ap);
longjmp(conv_state->top_ctx, 1);
/* NOTREACHED */
+#ifdef _AIX
+ PCAP_UNREACHABLE
+#endif /* _AIX */
}
/*
}
#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
*/
#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
+ *
+ */
+#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
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
#
#
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"
#
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"
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
- echo "-L$libdir $RPATH -l$PACKAGE_NAME"
+ echo "$LPATH $RPATH -l$PACKAGE_NAME"
fi
fi
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,
}
}
fclose(fh);
- free(pathstr);
}
+ free(pathstr);
}
#ifdef ETHTOOL_GLINK
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);
#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
*/
#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
*/
#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
+ *
+ */
+#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
#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.
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);
*/
#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.
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()