summaryrefslogtreecommitdiffstats
path: root/contrib/libpcap
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libpcap')
-rw-r--r--contrib/libpcap/FREEBSD-upgrade34
-rw-r--r--contrib/libpcap/aclocal.m4706
-rw-r--r--contrib/libpcap/gencode.c939
-rw-r--r--contrib/libpcap/gencode.h23
-rw-r--r--contrib/libpcap/grammar.y41
-rw-r--r--contrib/libpcap/nametoaddr.c31
-rw-r--r--contrib/libpcap/pcap-int.h34
-rw-r--r--contrib/libpcap/pcap-namedb.h16
-rw-r--r--contrib/libpcap/pcap.315
-rw-r--r--contrib/libpcap/pcap.h15
-rw-r--r--contrib/libpcap/scanner.l126
11 files changed, 153 insertions, 1827 deletions
diff --git a/contrib/libpcap/FREEBSD-upgrade b/contrib/libpcap/FREEBSD-upgrade
new file mode 100644
index 0000000..b8abe2f
--- /dev/null
+++ b/contrib/libpcap/FREEBSD-upgrade
@@ -0,0 +1,34 @@
+This directory contains virgin copies of the original distribution files
+on a "vendor" branch. Do not, under any circumstances, attempt to upgrade
+the files in this directory via patches and a cvs commit.
+
+To upgrade to a newer version of libpcap, when it is available:
+ 1. Unpack the new version into an empty directory.
+ [Do not make ANY changes to the files.]
+
+ 2. Use the command:
+ cvs import -m 'Virgin import of LBL libpcap v<version>' \
+ -I SUNOS4 -I linux-include \
+ src/contrib/libpcap LBL v<version>
+
+ For example, to do the import of version 0.2.1, I typed:
+ cvs import -m 'Virgin import of LBL libpcap v0.2.1' \
+ -I SUNOS4 -I linux-include \
+ src/contrib/libpcap LBL v0_2_1
+
+ 3. Follow the instructions printed out in step 2 to resolve any
+ conflicts between local FreeBSD changes and the newer version.
+
+ 4. Update the shared library version number in
+ src/lib/libpcap/Makefile as described in the
+ handbook section 18.
+
+Do not, under any circumstances, deviate from this procedure.
+
+To make local changes to libpcap, simply patch and commit to the main
+branch (aka HEAD). Never make local changes on the LBL branch.
+
+All local changes should be submitted to "libpcap@ee.lbl.gov" for
+inclusion in the next vendor release of tcpdump and libpcap.
+
+pst@freebsd.org - 19 Aug 1996
diff --git a/contrib/libpcap/aclocal.m4 b/contrib/libpcap/aclocal.m4
deleted file mode 100644
index ef3d05f..0000000
--- a/contrib/libpcap/aclocal.m4
+++ /dev/null
@@ -1,706 +0,0 @@
-dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.66 1999/10/30 04:41:48 itojun Exp $ (LBL)
-dnl
-dnl Copyright (c) 1995, 1996, 1997, 1998
-dnl The Regents of the University of California. All rights reserved.
-dnl
-dnl Redistribution and use in source and binary forms, with or without
-dnl modification, are permitted provided that: (1) source code distributions
-dnl retain the above copyright notice and this paragraph in its entirety, (2)
-dnl distributions including binary code include the above copyright notice and
-dnl this paragraph in its entirety in the documentation or other materials
-dnl provided with the distribution, and (3) all advertising materials mentioning
-dnl features or use of this software display the following acknowledgement:
-dnl ``This product includes software developed by the University of California,
-dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
-dnl the University nor the names of its contributors may be used to endorse
-dnl or promote products derived from this software without specific prior
-dnl written permission.
-dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-dnl
-dnl LBL autoconf macros
-dnl
-
-dnl
-dnl Determine which compiler we're using (cc or gcc)
-dnl If using gcc, determine the version number
-dnl If using cc, require that it support ansi prototypes
-dnl If using gcc, use -O2 (otherwise use -O)
-dnl If using cc, explicitly specify /usr/local/include
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_C_INIT(copt, incls)
-dnl
-dnl results:
-dnl
-dnl $1 (copt set)
-dnl $2 (incls set)
-dnl CC
-dnl LDFLAGS
-dnl ac_cv_lbl_gcc_vers
-dnl LBL_CFLAGS
-dnl
-AC_DEFUN(AC_LBL_C_INIT,
- [AC_PREREQ(2.12)
- AC_BEFORE([$0], [AC_PROG_CC])
- AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
- AC_BEFORE([$0], [AC_LBL_DEVEL])
- AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
- $1="-O"
- $2=""
- if test "${srcdir}" != "." ; then
- $2="-I\$(srcdir)"
- fi
- if test "${CFLAGS+set}" = set; then
- LBL_CFLAGS="$CFLAGS"
- fi
- if test -z "$CC" ; then
- case "$target_os" in
-
- bsdi*)
- AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
- if test $SHLICC2 = yes ; then
- CC=shlicc2
- export CC
- fi
- ;;
- esac
- fi
- if test -z "$CC" -a "$with_gcc" = no ; then
- CC=cc
- export CC
- fi
- AC_PROG_CC
- if test "$GCC" = yes ; then
- if test "$SHLICC2" = yes ; then
- ac_cv_lbl_gcc_vers=2
- $1="-O2"
- else
- AC_MSG_CHECKING(gcc version)
- AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
- ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
- sed -e '/^gcc version /!d' \
- -e 's/^gcc version //' \
- -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \
- -e 's/\..*//'`)
- AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- $1="-O2"
- fi
- fi
- else
- AC_MSG_CHECKING(that $CC handles ansi prototypes)
- AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_lbl_cc_ansi_prototypes=yes,
- ac_cv_lbl_cc_ansi_prototypes=no))
- AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
- if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
- case "$target_os" in
-
- hpux*)
- AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
- savedcflags="$CFLAGS"
- CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
- AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_lbl_cc_hpux_cc_aa=yes,
- ac_cv_lbl_cc_hpux_cc_aa=no))
- AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)
- if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
- AC_MSG_ERROR(see the INSTALL doc for more info)
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-Aa $V_CCOPT"
- AC_DEFINE(_HPUX_SOURCE)
- ;;
-
- *)
- AC_MSG_ERROR(see the INSTALL doc for more info)
- ;;
- esac
- fi
- $2="$$2 -I/usr/local/include"
- LDFLAGS="$LDFLAGS -L/usr/local/lib"
-
- case "$target_os" in
-
- irix*)
- V_CCOPT="$V_CCOPT -xansi -signed -g3"
- ;;
-
- osf*)
- V_CCOPT="$V_CCOPT -std1 -g3"
- ;;
-
- ultrix*)
- AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
- AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [struct a { int b; };
- void c(const struct a *)],
- ac_cv_lbl_cc_const_proto=yes,
- ac_cv_lbl_cc_const_proto=no))
- AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
- if test $ac_cv_lbl_cc_const_proto = no ; then
- AC_DEFINE(const,)
- fi
- ;;
- esac
- fi
-])
-
-dnl
-dnl Use pfopen.c if available and pfopen() not in standard libraries
-dnl Require libpcap
-dnl Look for libpcap in ..
-dnl Use the installed libpcap if there is no local version
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LIBPCAP(pcapdep, incls)
-dnl
-dnl results:
-dnl
-dnl $1 (pcapdep set)
-dnl $2 (incls appended)
-dnl LIBS
-dnl LBL_LIBS
-dnl
-AC_DEFUN(AC_LBL_LIBPCAP,
- [AC_REQUIRE([AC_LBL_LIBRARY_NET])
- dnl
- dnl save a copy before locating libpcap.a
- dnl
- LBL_LIBS="$LIBS"
- pfopen=/usr/examples/packetfilter/pfopen.c
- if test -f $pfopen ; then
- AC_CHECK_FUNCS(pfopen)
- if test $ac_cv_func_pfopen = "no" ; then
- AC_MSG_RESULT(Using $pfopen)
- LIBS="$LIBS $pfopen"
- fi
- fi
- AC_MSG_CHECKING(for local pcap library)
- libpcap=FAIL
- lastdir=FAIL
- places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
- egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
- for dir in $places ../libpcap libpcap ; do
- basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
- if test $lastdir = $basedir ; then
- dnl skip alphas when an actual release is present
- continue;
- fi
- lastdir=$dir
- if test -r $dir/pcap.c ; then
- libpcap=$dir/libpcap.a
- d=$dir
- dnl continue and select the last one that exists
- fi
- done
- if test $libpcap = FAIL ; then
- AC_MSG_RESULT(not found)
- AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
- if test $libpcap = FAIL ; then
- AC_MSG_ERROR(see the INSTALL doc for more info)
- fi
- else
- $1=$libpcap
- $2="-I$d $$2"
- AC_MSG_RESULT($libpcap)
- fi
- LIBS="$libpcap $LIBS"
- case "$target_os" in
-
- aix*)
- pseexe="/lib/pse.exp"
- AC_MSG_CHECKING(for $pseexe)
- if test -f $pseexe ; then
- AC_MSG_RESULT(yes)
- LIBS="$LIBS -I:$pseexe"
- fi
- ;;
- esac])
-
-dnl
-dnl Define RETSIGTYPE and RETSIGVAL
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_TYPE_SIGNAL
-dnl
-dnl results:
-dnl
-dnl RETSIGTYPE (defined)
-dnl RETSIGVAL (defined)
-dnl
-AC_DEFUN(AC_LBL_TYPE_SIGNAL,
- [AC_BEFORE([$0], [AC_LBL_LIBPCAP])
- AC_TYPE_SIGNAL
- if test "$ac_cv_type_signal" = void ; then
- AC_DEFINE(RETSIGVAL,)
- else
- AC_DEFINE(RETSIGVAL,(0))
- fi
- case "$target_os" in
-
- irix*)
- AC_DEFINE(_BSD_SIGNALS)
- ;;
-
- *)
- dnl prefer sigset() to sigaction()
- AC_CHECK_FUNCS(sigset)
- if test $ac_cv_func_sigset = no ; then
- AC_CHECK_FUNCS(sigaction)
- fi
- ;;
- esac])
-
-dnl
-dnl If using gcc, make sure we have ANSI ioctl definitions
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_FIXINCLUDES
-dnl
-AC_DEFUN(AC_LBL_FIXINCLUDES,
- [if test "$GCC" = yes ; then
- AC_MSG_CHECKING(for ANSI ioctl definitions)
- AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
- AC_TRY_COMPILE(
- [/*
- * This generates a "duplicate case value" when fixincludes
- * has not be run.
- */
-# include <sys/types.h>
-# include <sys/time.h>
-# include <sys/ioctl.h>
-# ifdef HAVE_SYS_IOCCOM_H
-# include <sys/ioccom.h>
-# endif],
- [switch (0) {
- case _IO('A', 1):;
- case _IO('B', 1):;
- }],
- ac_cv_lbl_gcc_fixincludes=yes,
- ac_cv_lbl_gcc_fixincludes=no))
- AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
- if test $ac_cv_lbl_gcc_fixincludes = no ; then
- # Don't cache failure
- unset ac_cv_lbl_gcc_fixincludes
- AC_MSG_ERROR(see the INSTALL for more info)
- fi
- fi])
-
-dnl
-dnl Check for flex, default to lex
-dnl Require flex 2.4 or higher
-dnl Check for bison, default to yacc
-dnl Default to lex/yacc if both flex and bison are not available
-dnl Define the yy prefix string if using flex and bison
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
-dnl
-dnl results:
-dnl
-dnl $1 (lex set)
-dnl $2 (yacc appended)
-dnl $3 (optional flex and bison -P prefix)
-dnl
-AC_DEFUN(AC_LBL_LEX_AND_YACC,
- [AC_ARG_WITH(flex, [ --without-flex don't use flex])
- AC_ARG_WITH(bison, [ --without-bison don't use bison])
- if test "$with_flex" = no ; then
- $1=lex
- else
- AC_CHECK_PROGS($1, flex, lex)
- fi
- if test "$$1" = flex ; then
- # The -V flag was added in 2.4
- AC_MSG_CHECKING(for flex 2.4 or higher)
- AC_CACHE_VAL(ac_cv_lbl_flex_v24,
- if flex -V >/dev/null 2>&1; then
- ac_cv_lbl_flex_v24=yes
- else
- ac_cv_lbl_flex_v24=no
- fi)
- AC_MSG_RESULT($ac_cv_lbl_flex_v24)
- if test $ac_cv_lbl_flex_v24 = no ; then
- s="2.4 or higher required"
- AC_MSG_WARN(ignoring obsolete flex executable ($s))
- $1=lex
- fi
- fi
- if test "$with_bison" = no ; then
- $2=yacc
- else
- AC_CHECK_PROGS($2, bison, yacc)
- fi
- if test "$$2" = bison ; then
- $2="$$2 -y"
- fi
- if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
- AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
- $1=lex
- $2=yacc
- fi
- if test "$$1" = flex -a -n "$3" ; then
- $1="$$1 -P$3"
- $2="$$2 -p $3"
- fi])
-
-dnl
-dnl Checks to see if union wait is used with WEXITSTATUS()
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_UNION_WAIT
-dnl
-dnl results:
-dnl
-dnl DECLWAITSTATUS (defined)
-dnl
-AC_DEFUN(AC_LBL_UNION_WAIT,
- [AC_MSG_CHECKING(if union wait is used)
- AC_CACHE_VAL(ac_cv_lbl_union_wait,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/wait.h>],
- [int status;
- u_int i = WEXITSTATUS(status);
- u_int j = waitpid(0, &status, 0);],
- ac_cv_lbl_union_wait=no,
- ac_cv_lbl_union_wait=yes))
- AC_MSG_RESULT($ac_cv_lbl_union_wait)
- if test $ac_cv_lbl_union_wait = yes ; then
- AC_DEFINE(DECLWAITSTATUS,union wait)
- else
- AC_DEFINE(DECLWAITSTATUS,int)
- fi])
-
-dnl
-dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_SOCKADDR_SA_LEN
-dnl
-dnl results:
-dnl
-dnl HAVE_SOCKADDR_SA_LEN (defined)
-dnl
-AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
- [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
- AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
- ac_cv_lbl_sockaddr_has_sa_len=yes,
- ac_cv_lbl_sockaddr_has_sa_len=no))
- AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
- if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
- AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
- fi])
-
-dnl
-dnl Checks to see if -R is used
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_HAVE_RUN_PATH
-dnl
-dnl results:
-dnl
-dnl ac_cv_lbl_have_run_path (yes or no)
-dnl
-AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
- [AC_MSG_CHECKING(for ${CC-cc} -R)
- AC_CACHE_VAL(ac_cv_lbl_have_run_path,
- [echo 'main(){}' > conftest.c
- ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
- if test ! -s conftest.out ; then
- ac_cv_lbl_have_run_path=yes
- else
- ac_cv_lbl_have_run_path=no
- fi
- rm -f conftest*])
- AC_MSG_RESULT($ac_cv_lbl_have_run_path)
- ])
-
-dnl
-dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless.
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_CHECK_TYPE
-dnl
-dnl results:
-dnl
-dnl int32_t (defined)
-dnl u_int32_t (defined)
-dnl
-AC_DEFUN(AC_LBL_CHECK_TYPE,
- [AC_MSG_CHECKING(for $1 using $CC)
- AC_CACHE_VAL(ac_cv_lbl_have_$1,
- AC_TRY_COMPILE([
-# include "confdefs.h"
-# include <sys/types.h>
-# if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-# endif],
- [$1 i],
- ac_cv_lbl_have_$1=yes,
- ac_cv_lbl_have_$1=no))
- AC_MSG_RESULT($ac_cv_lbl_have_$1)
- if test $ac_cv_lbl_have_$1 = no ; then
- AC_DEFINE($1, $2)
- fi])
-
-dnl
-dnl Checks to see if unaligned memory accesses fail
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_UNALIGNED_ACCESS
-dnl
-dnl results:
-dnl
-dnl LBL_ALIGN (DEFINED)
-dnl
-AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
- [AC_MSG_CHECKING(if unaligned accesses fail)
- AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
- [case "$target_cpu" in
-
- alpha|hp*|mips|sparc)
- ac_cv_lbl_unaligned_fail=yes
- ;;
-
- *)
- cat >conftest.c <<EOF
-# include <sys/types.h>
-# include <sys/wait.h>
-# include <stdio.h>
- unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
- main() {
- unsigned int i;
- pid_t pid;
- int status;
- /* avoid "core dumped" message */
- pid = fork();
- if (pid < 0)
- exit(2);
- if (pid > 0) {
- /* parent */
- pid = waitpid(pid, &status, 0);
- if (pid < 0)
- exit(3);
- exit(!WIFEXITED(status));
- }
- /* child */
- i = *(unsigned int *)&a[[1]];
- printf("%d\n", i);
- exit(0);
- }
-EOF
- ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
- conftest.c $LIBS >/dev/null 2>&1
- if test ! -x conftest ; then
- dnl failed to compile for some reason
- ac_cv_lbl_unaligned_fail=yes
- else
- ./conftest >conftest.out
- if test ! -s conftest.out ; then
- ac_cv_lbl_unaligned_fail=yes
- else
- ac_cv_lbl_unaligned_fail=no
- fi
- fi
- rm -f conftest* core core.conftest
- ;;
- esac])
- AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
- if test $ac_cv_lbl_unaligned_fail = yes ; then
- AC_DEFINE(LBL_ALIGN)
- fi])
-
-dnl
-dnl If using gcc and the file .devel exists:
-dnl Compile with -g (if supported) and -Wall
-dnl If using gcc 2, do extra prototype checking
-dnl If an os prototype include exists, symlink os-proto.h to it
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_DEVEL(copt)
-dnl
-dnl results:
-dnl
-dnl $1 (copt appended)
-dnl HAVE_OS_PROTO_H (defined)
-dnl os-proto.h (symlinked)
-dnl
-AC_DEFUN(AC_LBL_DEVEL,
- [rm -f os-proto.h
- if test "${LBL_CFLAGS+set}" = set; then
- $1="$$1 ${LBL_CFLAGS}"
- fi
- if test -f .devel ; then
- if test "$GCC" = yes ; then
- if test "${LBL_CFLAGS+set}" != set; then
- if test "$ac_cv_prog_cc_g" = yes ; then
- $1="-g $$1"
- fi
- $1="$$1 -Wall"
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
- fi
- fi
- else
- case "$target_os" in
-
- irix6*)
- V_CCOPT="$V_CCOPT -n32"
- ;;
-
- *)
- ;;
- esac
- fi
- os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
- name="lbl/os-$os.h"
- if test -f $name ; then
- ln -s $name os-proto.h
- AC_DEFINE(HAVE_OS_PROTO_H)
- else
- AC_MSG_WARN(can't find $name)
- fi
- fi])
-
-dnl
-dnl Improved version of AC_CHECK_LIB
-dnl
-dnl Thanks to John Hawkinson (jhawk@mit.edu)
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
-dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
-dnl
-dnl results:
-dnl
-dnl LIBS
-dnl
-
-define(AC_LBL_CHECK_LIB,
-[AC_MSG_CHECKING([for $2 in -l$1])
-dnl Use a cache variable name containing both the library and function name,
-dnl because the test really is for library $1 defining function $2, not
-dnl just for library $1. Separate tests with the same $1 and different $2's
-dnl may have different results.
-ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
-AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
-[ac_save_LIBS="$LIBS"
-LIBS="-l$1 $5 $LIBS"
-AC_TRY_LINK(dnl
-ifelse([$2], [main], , dnl Avoid conflicting decl of main.
-[/* Override any gcc2 internal prototype to avoid an error. */
-]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])dnl
-[/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $2();
-]),
- [$2()],
- eval "ac_cv_lbl_lib_$ac_lib_var=yes",
- eval "ac_cv_lbl_lib_$ac_lib_var=no")
-LIBS="$ac_save_LIBS"
-])dnl
-if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
- AC_MSG_RESULT(yes)
- ifelse([$3], ,
-[changequote(, )dnl
- ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
-changequote([, ])dnl
- AC_DEFINE_UNQUOTED($ac_tr_lib)
- LIBS="-l$1 $LIBS"
-], [$3])
-else
- AC_MSG_RESULT(no)
-ifelse([$4], , , [$4
-])dnl
-fi
-])
-
-dnl
-dnl AC_LBL_LIBRARY_NET
-dnl
-dnl This test is for network applications that need socket() and
-dnl gethostbyname() -ish functions. Under Solaris, those applications
-dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
-dnl with "-lnsl" but should *not* link with "-lsocket" because
-dnl libsocket.a breaks a number of things (for instance:
-dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
-dnl versions of IRIX).
-dnl
-dnl Unfortunately, many application developers are not aware of this,
-dnl and mistakenly write tests that cause -lsocket to be used under
-dnl IRIX. It is also easy to write tests that cause -lnsl to be used
-dnl under operating systems where neither are necessary (or useful),
-dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
-dnl
-dnl This test exists so that every application developer does not test
-dnl this in a different, and subtly broken fashion.
-
-dnl It has been argued that this test should be broken up into two
-dnl seperate tests, one for the resolver libraries, and one for the
-dnl libraries necessary for using Sockets API. Unfortunately, the two
-dnl are carefully intertwined and allowing the autoconf user to use
-dnl them independantly potentially results in unfortunate ordering
-dnl dependancies -- as such, such component macros would have to
-dnl carefully use indirection and be aware if the other components were
-dnl executed. Since other autoconf macros do not go to this trouble,
-dnl and almost no applications use sockets without the resolver, this
-dnl complexity has not been implemented.
-dnl
-dnl The check for libresolv is in case you are attempting to link
-dnl statically and happen to have a libresolv.a lying around (and no
-dnl libnsl.a).
-dnl
-AC_DEFUN(AC_LBL_LIBRARY_NET, [
- # Most operating systems have gethostbyname() in the default searched
- # libraries (i.e. libc):
- AC_CHECK_FUNC(gethostbyname, ,
- # Some OSes (eg. Solaris) place it in libnsl:
- AC_LBL_CHECK_LIB(nsl, gethostbyname, ,
- # Some strange OSes (SINIX) have it in libsocket:
- AC_LBL_CHECK_LIB(socket, gethostbyname, ,
- # Unfortunately libsocket sometimes depends on libnsl.
- # AC_CHECK_LIB's API is essentially broken so the
- # following ugliness is necessary:
- AC_LBL_CHECK_LIB(socket, gethostbyname,
- LIBS="-lsocket -lnsl $LIBS",
- AC_CHECK_LIB(resolv, gethostbyname),
- -lnsl))))
- AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
- AC_LBL_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
- -lnsl)))
- # DLPI needs putmsg under HPUX so test for -lstr while we're at it
- AC_CHECK_LIB(str, putmsg)
- ])
diff --git a/contrib/libpcap/gencode.c b/contrib/libpcap/gencode.c
index 0298350..b966e3e 100644
--- a/contrib/libpcap/gencode.c
+++ b/contrib/libpcap/gencode.c
@@ -1,4 +1,3 @@
-/*#define CHASE_CHAIN*/
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
* The Regents of the University of California. All rights reserved.
@@ -21,15 +20,12 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.100 1999/12/08 19:54:03 mcr Exp $ (LBL)";
+ "@(#) $Header: gencode.c,v 1.94 98/07/12 13:06:49 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
-#ifdef __NetBSD__
-#include <sys/param.h>
-#endif
#if __STDC__
struct mbuf;
@@ -37,13 +33,14 @@ struct rtentry;
#endif
#include <net/if.h>
+#include <net/ethernet.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
#include <stdlib.h>
#include <memory.h>
#include <setjmp.h>
+#include <net/if_llc.h>
#if __STDC__
#include <stdarg.h>
#else
@@ -53,13 +50,10 @@ struct rtentry;
#include "pcap-int.h"
#include "ethertype.h"
+#include "nlpid.h"
#include "gencode.h"
#include "ppp.h"
#include <pcap-namedb.h>
-#ifdef INET6
-#include <netdb.h>
-#include <sys/socket.h>
-#endif /*INET6*/
#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
@@ -143,28 +137,15 @@ static inline struct block *gen_true(void);
static inline struct block *gen_false(void);
static struct block *gen_linktype(int);
static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int);
-#ifdef INET6
-static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
-#endif
static struct block *gen_ehostop(const u_char *, int);
static struct block *gen_fhostop(const u_char *, int);
static struct block *gen_dnhostop(bpf_u_int32, int, u_int);
static struct block *gen_host(bpf_u_int32, bpf_u_int32, int, int);
-#ifdef INET6
-static struct block *gen_host6(struct in6_addr *, struct in6_addr *, int, int);
-#endif
static struct block *gen_gateway(const u_char *, bpf_u_int32 **, int, int);
static struct block *gen_ipfrag(void);
static struct block *gen_portatom(int, bpf_int32);
-#ifdef INET6
-static struct block *gen_portatom6(int, bpf_int32);
-#endif
struct block *gen_portop(int, int, int);
static struct block *gen_port(int, int, int);
-#ifdef INET6
-struct block *gen_portop6(int, int, int);
-static struct block *gen_port6(int, int, int);
-#endif
static int lookup_proto(const char *, int);
static struct block *gen_proto(int, int, int);
static struct slist *xfer_to_x(struct arth *);
@@ -178,13 +159,8 @@ newchunk(n)
struct chunk *cp;
int k, size;
-#ifndef __NetBSD__
/* XXX Round up to nearest long. */
n = (n + sizeof(long) - 1) & ~(sizeof(long) - 1);
-#else
- /* XXX Round up to structure boundary. */
- n = ALIGN(n);
-#endif
cp = &chunks[cur_chunk];
if (n > cp->n_left) {
@@ -272,7 +248,6 @@ syntax()
static bpf_u_int32 netmask;
static int snaplen;
-int no_optimize;
int
pcap_compile(pcap_t *p, struct bpf_program *program,
@@ -281,7 +256,6 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
extern int n_errors;
int len;
- no_optimize = 0;
n_errors = 0;
root = NULL;
bpf_pcap = p;
@@ -303,54 +277,6 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
if (root == NULL)
root = gen_retblk(snaplen);
- if (optimize && !no_optimize) {
- bpf_optimize(&root);
- if (root == NULL ||
- (root->s.code == (BPF_RET|BPF_K) && root->s.k == 0))
- bpf_error("expression rejects all packets");
- }
- program->bf_insns = icode_to_fcode(root, &len);
- program->bf_len = len;
-
- freechunks();
- return (0);
-}
-
-/*
- * entry point for using the compiler with no pcap open
- * pass in all the stuff that is needed explicitly instead.
- */
-int
-pcap_compile_nopcap(int snaplen_arg, int linktype_arg,
- struct bpf_program *program,
- char *buf, int optimize, bpf_u_int32 mask)
-{
- extern int n_errors;
- int len;
-
- n_errors = 0;
- root = NULL;
- bpf_pcap = NULL;
- if (setjmp(top_ctx)) {
- freechunks();
- return (-1);
- }
-
- netmask = mask;
-
- /* XXX needed? I don't grok the use of globals here. */
- snaplen = snaplen_arg;
-
- lex_init(buf ? buf : "");
- init_linktype(linktype_arg);
- (void)pcap_parse();
-
- if (n_errors)
- syntax();
-
- if (root == NULL)
- root = gen_retblk(snaplen_arg);
-
if (optimize) {
bpf_optimize(&root);
if (root == NULL ||
@@ -563,7 +489,6 @@ init_linktype(type)
return;
case DLT_PPP:
- case DLT_CHDLC:
off_linktype = 2;
off_nl = 4;
return;
@@ -657,10 +582,6 @@ gen_linktype(proto)
case DLT_PPP:
if (proto == ETHERTYPE_IP)
proto = PPP_IP; /* XXX was 0x21 */
-#ifdef INET6
- else if (proto == ETHERTYPE_IPV6)
- proto = PPP_IPV6;
-#endif
break;
case DLT_PPP_BSDOS:
@@ -674,13 +595,6 @@ gen_linktype(proto)
gen_or(b1, b0);
return b0;
-#ifdef INET6
- case ETHERTYPE_IPV6:
- proto = PPP_IPV6;
- /* more to go? */
- break;
-#endif
-
case ETHERTYPE_DN:
proto = PPP_DECNET;
break;
@@ -699,12 +613,26 @@ gen_linktype(proto)
/* XXX */
if (proto == ETHERTYPE_IP)
return (gen_cmp(0, BPF_W, (bpf_int32)htonl(AF_INET)));
-#ifdef INET6
- else if (proto == ETHERTYPE_IPV6)
- return (gen_cmp(0, BPF_W, (bpf_int32)htonl(AF_INET6)));
-#endif
else
return gen_false();
+ case DLT_EN10MB:
+ /*
+ * Having to look at SAP's here is quite disgusting,
+ * but given an internal architecture that _knows_ that
+ * it's looking at IP on Ethernet...
+ */
+ if (proto == LLC_ISO_LSAP) {
+ struct block *b0, *b1;
+
+ b0 = gen_cmp(off_linktype, BPF_H, (long)ETHERMTU);
+ b0->s.code = JMP(BPF_JGT);
+ gen_not(b0);
+ b1 = gen_cmp(off_linktype + 2, BPF_H, (long)
+ ((LLC_ISO_LSAP << 8) | LLC_ISO_LSAP));
+ gen_and(b0, b1);
+ return b1;
+ }
+ break;
}
return gen_cmp(off_linktype, BPF_H, (bpf_int32)proto);
}
@@ -751,60 +679,6 @@ gen_hostop(addr, mask, dir, proto, src_off, dst_off)
return b1;
}
-#ifdef INET6
-static struct block *
-gen_hostop6(addr, mask, dir, proto, src_off, dst_off)
- struct in6_addr *addr;
- struct in6_addr *mask;
- int dir, proto;
- u_int src_off, dst_off;
-{
- struct block *b0, *b1;
- u_int offset;
- u_int32_t *a, *m;
-
- switch (dir) {
-
- case Q_SRC:
- offset = src_off;
- break;
-
- case Q_DST:
- offset = dst_off;
- break;
-
- case Q_AND:
- b0 = gen_hostop6(addr, mask, Q_SRC, proto, src_off, dst_off);
- b1 = gen_hostop6(addr, mask, Q_DST, proto, src_off, dst_off);
- gen_and(b0, b1);
- return b1;
-
- case Q_OR:
- case Q_DEFAULT:
- b0 = gen_hostop6(addr, mask, Q_SRC, proto, src_off, dst_off);
- b1 = gen_hostop6(addr, mask, Q_DST, proto, src_off, dst_off);
- gen_or(b0, b1);
- return b1;
-
- default:
- abort();
- }
- /* this order is important */
- a = (u_int32_t *)addr;
- m = (u_int32_t *)mask;
- b1 = gen_mcmp(offset + 12, BPF_W, ntohl(a[3]), ntohl(m[3]));
- b0 = gen_mcmp(offset + 8, BPF_W, ntohl(a[2]), ntohl(m[2]));
- gen_and(b0, b1);
- b0 = gen_mcmp(offset + 4, BPF_W, ntohl(a[1]), ntohl(m[1]));
- gen_and(b0, b1);
- b0 = gen_mcmp(offset + 0, BPF_W, ntohl(a[0]), ntohl(m[0]));
- gen_and(b0, b1);
- b0 = gen_linktype(proto);
- gen_and(b0, b1);
- return b1;
-}
-#endif /*INET6*/
-
static struct block *
gen_ehostop(eaddr, dir)
register const u_char *eaddr;
@@ -1012,9 +886,6 @@ gen_host(addr, mask, proto, dir)
case Q_IGRP:
bpf_error("'igrp' modifier applied to host");
- case Q_PIM:
- bpf_error("'pim' modifier applied to host");
-
case Q_ATALK:
bpf_error("ATALK host filtering not implemented");
@@ -1033,105 +904,14 @@ gen_host(addr, mask, proto, dir)
case Q_MOPRC:
bpf_error("MOPRC host filtering not implemented");
-#ifdef INET6
- case Q_IPV6:
- bpf_error("'ip6' modifier applied to ip host");
-
- case Q_ICMPV6:
- bpf_error("'icmp6' modifier applied to host");
-#endif /* INET6 */
-
- case Q_AH:
- bpf_error("'ah' modifier applied to host");
-
- case Q_ESP:
- bpf_error("'esp' modifier applied to host");
-
- default:
- abort();
- }
- /* NOTREACHED */
-}
-
-#ifdef INET6
-static struct block *
-gen_host6(addr, mask, proto, dir)
- struct in6_addr *addr;
- struct in6_addr *mask;
- int proto;
- int dir;
-{
- struct block *b0, *b1;
-
- switch (proto) {
-
- case Q_DEFAULT:
- return gen_host6(addr, mask, Q_IPV6, dir);
-
- case Q_IP:
- bpf_error("'ip' modifier applied to ip6 host");
-
- case Q_RARP:
- bpf_error("'rarp' modifier applied to ip6 host");
-
- case Q_ARP:
- bpf_error("'arp' modifier applied to ip6 host");
-
- case Q_TCP:
- bpf_error("'tcp' modifier applied to host");
-
- case Q_UDP:
- bpf_error("'udp' modifier applied to host");
-
- case Q_ICMP:
- bpf_error("'icmp' modifier applied to host");
-
- case Q_IGMP:
- bpf_error("'igmp' modifier applied to host");
-
- case Q_IGRP:
- bpf_error("'igrp' modifier applied to host");
-
- case Q_PIM:
- bpf_error("'pim' modifier applied to host");
-
- case Q_ATALK:
- bpf_error("ATALK host filtering not implemented");
-
- case Q_DECNET:
- bpf_error("'decnet' modifier applied to ip6 host");
-
- case Q_SCA:
- bpf_error("SCA host filtering not implemented");
-
- case Q_LAT:
- bpf_error("LAT host filtering not implemented");
-
- case Q_MOPDL:
- bpf_error("MOPDL host filtering not implemented");
-
- case Q_MOPRC:
- bpf_error("MOPRC host filtering not implemented");
-
- case Q_IPV6:
- return gen_hostop6(addr, mask, dir, ETHERTYPE_IPV6,
- off_nl + 8, off_nl + 24);
-
- case Q_ICMPV6:
- bpf_error("'icmp6' modifier applied to host");
-
- case Q_AH:
- bpf_error("'ah' modifier applied to host");
-
- case Q_ESP:
- bpf_error("'esp' modifier applied to host");
-
+ case Q_ISO:
+ bpf_error("ISO host filtering not implemented");
+
default:
abort();
}
/* NOTREACHED */
}
-#endif /*INET6*/
static struct block *
gen_gateway(eaddr, alist, proto, dir)
@@ -1181,49 +961,38 @@ gen_proto_abbrev(proto)
switch (proto) {
case Q_TCP:
- b1 = gen_proto(IPPROTO_TCP, Q_IP, Q_DEFAULT);
-#ifdef INET6
- b0 = gen_proto(IPPROTO_TCP, Q_IPV6, Q_DEFAULT);
- gen_or(b0, b1);
-#endif
+ b0 = gen_linktype(ETHERTYPE_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)IPPROTO_TCP);
+ gen_and(b0, b1);
break;
case Q_UDP:
- b1 = gen_proto(IPPROTO_UDP, Q_IP, Q_DEFAULT);
-#ifdef INET6
- b0 = gen_proto(IPPROTO_UDP, Q_IPV6, Q_DEFAULT);
- gen_or(b0, b1);
-#endif
+ b0 = gen_linktype(ETHERTYPE_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)IPPROTO_UDP);
+ gen_and(b0, b1);
break;
case Q_ICMP:
- b1 = gen_proto(IPPROTO_ICMP, Q_IP, Q_DEFAULT);
+ b0 = gen_linktype(ETHERTYPE_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)IPPROTO_ICMP);
+ gen_and(b0, b1);
break;
case Q_IGMP:
- b1 = gen_proto(2, Q_IP, Q_DEFAULT);
+ b0 = gen_linktype(ETHERTYPE_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)2);
+ gen_and(b0, b1);
break;
#ifndef IPPROTO_IGRP
#define IPPROTO_IGRP 9
#endif
case Q_IGRP:
- b1 = gen_proto(IPPROTO_IGRP, Q_IP, Q_DEFAULT);
+ b0 = gen_linktype(ETHERTYPE_IP);
+ b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_IGRP);
gen_and(b0, b1);
break;
-#ifndef IPPROTO_PIM
-#define IPPROTO_PIM 103
-#endif
-
- case Q_PIM:
- b1 = gen_proto(IPPROTO_PIM, Q_IP, Q_DEFAULT);
-#ifdef INET6
- b0 = gen_proto(IPPROTO_PIM, Q_IPV6, Q_DEFAULT);
- gen_or(b0, b1);
-#endif
- break;
-
case Q_IP:
b1 = gen_linktype(ETHERTYPE_IP);
break;
@@ -1263,39 +1032,16 @@ gen_proto_abbrev(proto)
b1 = gen_linktype(ETHERTYPE_MOPRC);
break;
-#ifdef INET6
- case Q_IPV6:
- b1 = gen_linktype(ETHERTYPE_IPV6);
+ case Q_ISO:
+ b1 = gen_linktype(LLC_ISO_LSAP);
break;
-#ifndef IPPROTO_ICMPV6
-#define IPPROTO_ICMPV6 58
-#endif
- case Q_ICMPV6:
- b1 = gen_proto(IPPROTO_ICMPV6, Q_IPV6, Q_DEFAULT);
+ case Q_ESIS:
+ b1 = gen_proto(ISO9542_ESIS, Q_ISO, Q_DEFAULT);
break;
-#endif /* INET6 */
-#ifndef IPPROTO_AH
-#define IPPROTO_AH 51
-#endif
- case Q_AH:
- b1 = gen_proto(IPPROTO_AH, Q_IP, Q_DEFAULT);
-#ifdef INET6
- b0 = gen_proto(IPPROTO_AH, Q_IPV6, Q_DEFAULT);
- gen_or(b0, b1);
-#endif
- break;
-
-#ifndef IPPROTO_ESP
-#define IPPROTO_ESP 50
-#endif
- case Q_ESP:
- b1 = gen_proto(IPPROTO_ESP, Q_IP, Q_DEFAULT);
-#ifdef INET6
- b0 = gen_proto(IPPROTO_ESP, Q_IPV6, Q_DEFAULT);
- gen_or(b0, b1);
-#endif
+ case Q_ISIS:
+ b1 = gen_proto(ISO10589_ISIS, Q_ISO, Q_DEFAULT);
break;
default:
@@ -1342,16 +1088,6 @@ gen_portatom(off, v)
return b;
}
-#ifdef INET6
-static struct block *
-gen_portatom6(off, v)
- int off;
- bpf_int32 v;
-{
- return gen_cmp(off_nl + 40 + off, BPF_H, v);
-}
-#endif/*INET6*/
-
struct block *
gen_portop(port, proto, dir)
int port, proto, dir;
@@ -1423,77 +1159,6 @@ gen_port(port, ip_proto, dir)
return b1;
}
-#ifdef INET6
-struct block *
-gen_portop6(port, proto, dir)
- int port, proto, dir;
-{
- struct block *b0, *b1, *tmp;
-
- /* ip proto 'proto' */
- b0 = gen_cmp(off_nl + 6, BPF_B, (bpf_int32)proto);
-
- switch (dir) {
- case Q_SRC:
- b1 = gen_portatom6(0, (bpf_int32)port);
- break;
-
- case Q_DST:
- b1 = gen_portatom6(2, (bpf_int32)port);
- break;
-
- case Q_OR:
- case Q_DEFAULT:
- tmp = gen_portatom6(0, (bpf_int32)port);
- b1 = gen_portatom6(2, (bpf_int32)port);
- gen_or(tmp, b1);
- break;
-
- case Q_AND:
- tmp = gen_portatom6(0, (bpf_int32)port);
- b1 = gen_portatom6(2, (bpf_int32)port);
- gen_and(tmp, b1);
- break;
-
- default:
- abort();
- }
- gen_and(b0, b1);
-
- return b1;
-}
-
-static struct block *
-gen_port6(port, ip_proto, dir)
- int port;
- int ip_proto;
- int dir;
-{
- struct block *b0, *b1, *tmp;
-
- /* ether proto ip */
- b0 = gen_linktype(ETHERTYPE_IPV6);
-
- switch (ip_proto) {
- case IPPROTO_UDP:
- case IPPROTO_TCP:
- b1 = gen_portop6(port, ip_proto, dir);
- break;
-
- case PROTO_UNDEF:
- tmp = gen_portop6(port, IPPROTO_TCP, dir);
- b1 = gen_portop6(port, IPPROTO_UDP, dir);
- gen_or(tmp, b1);
- break;
-
- default:
- abort();
- }
- gen_and(b0, b1);
- return b1;
-}
-#endif /* INET6 */
-
static int
lookup_proto(name, proto)
register const char *name;
@@ -1524,317 +1189,6 @@ lookup_proto(name, proto)
return v;
}
-struct stmt *
-gen_joinsp(s, n)
- struct stmt **s;
- int n;
-{
-}
-
-struct block *
-gen_protochain(v, proto, dir)
- int v;
- int proto;
- int dir;
-{
-#ifdef NO_PROTOCHAIN
- return gen_proto(v, proto, dir);
-#else
- struct block *b0, *b;
- struct slist *s[100], *sp;
- int fix2, fix3, fix4, fix5;
- int ahcheck, again, end;
- int i, max;
- int reg1 = alloc_reg();
- int reg2 = alloc_reg();
-
- memset(s, 0, sizeof(s));
- fix2 = fix3 = fix4 = fix5 = 0;
-
- switch (proto) {
- case Q_IP:
- case Q_IPV6:
- break;
- case Q_DEFAULT:
- b0 = gen_protochain(v, Q_IP, dir);
- b = gen_protochain(v, Q_IPV6, dir);
- gen_or(b0, b);
- return b;
- default:
- bpf_error("bad protocol applied for 'protochain'");
- /*NOTREACHED*/
- }
-
- no_optimize = 1; /*this code is not compatible with optimzer yet */
-
- /*
- * s[0] is a dummy entry to protect other BPF insn from damaged
- * by s[fix] = foo with uninitialized variable "fix". It is somewhat
- * hard to find interdependency made by jump table fixup.
- */
- i = 0;
- s[i] = new_stmt(0); /*dummy*/
- i++;
-
- switch (proto) {
- case Q_IP:
- b0 = gen_linktype(ETHERTYPE_IP);
-
- /* A = ip->ip_p */
- s[i] = new_stmt(BPF_LD|BPF_ABS|BPF_B);
- s[i]->s.k = off_nl + 9;
- i++;
- /* X = ip->ip_hl << 2 */
- s[i] = new_stmt(BPF_LDX|BPF_MSH|BPF_B);
- s[i]->s.k = off_nl;
- i++;
- break;
-#ifdef INET6
- case Q_IPV6:
- b0 = gen_linktype(ETHERTYPE_IPV6);
-
- /* A = ip6->ip_nxt */
- s[i] = new_stmt(BPF_LD|BPF_ABS|BPF_B);
- s[i]->s.k = off_nl + 6;
- i++;
- /* X = sizeof(struct ip6_hdr) */
- s[i] = new_stmt(BPF_LDX|BPF_IMM);
- s[i]->s.k = 40;
- i++;
- break;
-#endif
- default:
- bpf_error("unsupported proto to gen_protochain");
- /*NOTREACHED*/
- }
-
- /* again: if (A == v) goto end; else fall through; */
- again = i;
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
- s[i]->s.k = v;
- s[i]->s.jt = NULL; /*later*/
- s[i]->s.jf = NULL; /*update in next stmt*/
- fix5 = i;
- i++;
-
-#ifndef IPPROTO_NONE
-#define IPPROTO_NONE 59
-#endif
- /* if (A == IPPROTO_NONE) goto end */
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
- s[i]->s.jt = NULL; /*later*/
- s[i]->s.jf = NULL; /*update in next stmt*/
- s[i]->s.k = IPPROTO_NONE;
- s[fix5]->s.jf = s[i];
- fix2 = i;
- i++;
-
-#ifdef INET6
- if (proto == Q_IPV6) {
- int v6start, v6end, v6advance, j;
-
- v6start = i;
- /* if (A == IPPROTO_HOPOPTS) goto v6advance */
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
- s[i]->s.jt = NULL; /*later*/
- s[i]->s.jf = NULL; /*update in next stmt*/
- s[i]->s.k = IPPROTO_HOPOPTS;
- s[fix2]->s.jf = s[i];
- i++;
- /* if (A == IPPROTO_DSTOPTS) goto v6advance */
- s[i - 1]->s.jf = s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
- s[i]->s.jt = NULL; /*later*/
- s[i]->s.jf = NULL; /*update in next stmt*/
- s[i]->s.k = IPPROTO_DSTOPTS;
- i++;
- /* if (A == IPPROTO_ROUTING) goto v6advance */
- s[i - 1]->s.jf = s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
- s[i]->s.jt = NULL; /*later*/
- s[i]->s.jf = NULL; /*update in next stmt*/
- s[i]->s.k = IPPROTO_ROUTING;
- i++;
- /* if (A == IPPROTO_FRAGMENT) goto v6advance; else goto ahcheck; */
- s[i - 1]->s.jf = s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
- s[i]->s.jt = NULL; /*later*/
- s[i]->s.jf = NULL; /*later*/
- s[i]->s.k = IPPROTO_FRAGMENT;
- fix3 = i;
- v6end = i;
- i++;
-
- /* v6advance: */
- v6advance = i;
-
- /*
- * in short,
- * A = P[X + 1];
- * X = X + (P[X] + 1) * 8;
- */
- /* A = X */
- s[i] = new_stmt(BPF_MISC|BPF_TXA);
- i++;
- /* MEM[reg1] = A */
- s[i] = new_stmt(BPF_ST);
- s[i]->s.k = reg1;
- i++;
- /* A += 1 */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
- s[i]->s.k = 1;
- i++;
- /* X = A */
- s[i] = new_stmt(BPF_MISC|BPF_TAX);
- i++;
- /* A = P[X + packet head]; */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_nl;
- i++;
- /* MEM[reg2] = A */
- s[i] = new_stmt(BPF_ST);
- s[i]->s.k = reg2;
- i++;
- /* X = MEM[reg1] */
- s[i] = new_stmt(BPF_LDX|BPF_MEM);
- s[i]->s.k = reg1;
- i++;
- /* A = P[X + packet head] */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_nl;
- i++;
- /* A += 1 */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
- s[i]->s.k = 1;
- i++;
- /* A *= 8 */
- s[i] = new_stmt(BPF_ALU|BPF_MUL|BPF_K);
- s[i]->s.k = 8;
- i++;
- /* X = A; */
- s[i] = new_stmt(BPF_MISC|BPF_TAX);
- i++;
- /* A = MEM[reg2] */
- s[i] = new_stmt(BPF_LD|BPF_MEM);
- s[i]->s.k = reg2;
- i++;
-
- /* goto again; (must use BPF_JA for backward jump) */
- s[i] = new_stmt(BPF_JMP|BPF_JA);
- s[i]->s.k = again - i - 1;
- s[i - 1]->s.jf = s[i];
- i++;
-
- /* fixup */
- for (j = v6start; j <= v6end; j++)
- s[j]->s.jt = s[v6advance];
- } else
-#endif
- {
- /* nop */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
- s[i]->s.k = 0;
- s[fix2]->s.jf = s[i];
- i++;
- }
-
- /* ahcheck: */
- ahcheck = i;
- /* if (A == IPPROTO_AH) then fall through; else goto end; */
- s[i] = new_stmt(BPF_JMP|BPF_JEQ|BPF_K);
- s[i]->s.jt = NULL; /*later*/
- s[i]->s.jf = NULL; /*later*/
- s[i]->s.k = IPPROTO_AH;
- if (fix3)
- s[fix3]->s.jf = s[ahcheck];
- fix4 = i;
- i++;
-
- /*
- * in short,
- * A = P[X + 1];
- * X = X + (P[X] + 2) * 4;
- */
- /* A = X */
- s[i - 1]->s.jt = s[i] = new_stmt(BPF_MISC|BPF_TXA);
- i++;
- /* MEM[reg1] = A */
- s[i] = new_stmt(BPF_ST);
- s[i]->s.k = reg1;
- i++;
- /* A += 1 */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
- s[i]->s.k = 1;
- i++;
- /* X = A */
- s[i] = new_stmt(BPF_MISC|BPF_TAX);
- i++;
- /* A = P[X + packet head]; */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_nl;
- i++;
- /* MEM[reg2] = A */
- s[i] = new_stmt(BPF_ST);
- s[i]->s.k = reg2;
- i++;
- /* X = MEM[reg1] */
- s[i] = new_stmt(BPF_LDX|BPF_MEM);
- s[i]->s.k = reg1;
- i++;
- /* A = P[X + packet head] */
- s[i] = new_stmt(BPF_LD|BPF_IND|BPF_B);
- s[i]->s.k = off_nl;
- i++;
- /* A += 2 */
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
- s[i]->s.k = 2;
- i++;
- /* A *= 4 */
- s[i] = new_stmt(BPF_ALU|BPF_MUL|BPF_K);
- s[i]->s.k = 4;
- i++;
- /* X = A; */
- s[i] = new_stmt(BPF_MISC|BPF_TAX);
- i++;
- /* A = MEM[reg2] */
- s[i] = new_stmt(BPF_LD|BPF_MEM);
- s[i]->s.k = reg2;
- i++;
-
- /* goto again; (must use BPF_JA for backward jump) */
- s[i] = new_stmt(BPF_JMP|BPF_JA);
- s[i]->s.k = again - i - 1;
- i++;
-
- /* end: nop */
- end = i;
- s[i] = new_stmt(BPF_ALU|BPF_ADD|BPF_K);
- s[i]->s.k = 0;
- s[fix2]->s.jt = s[end];
- s[fix4]->s.jf = s[end];
- s[fix5]->s.jt = s[end];
- i++;
-
- /*
- * make slist chain
- */
- max = i;
- for (i = 0; i < max - 1; i++)
- s[i]->next = s[i + 1];
- s[max - 1]->next = NULL;
-
- /*
- * emit final check
- */
- b = new_block(JMP(BPF_JEQ));
- b->stmts = s[1]; /*remember, s[0] is dummy*/
- b->s.k = v;
-
- free_reg(reg1);
- free_reg(reg2);
-
- gen_and(b0, b);
- return b;
-#endif
-}
-
static struct block *
gen_proto(v, proto, dir)
int v;
@@ -1848,21 +1202,15 @@ gen_proto(v, proto, dir)
switch (proto) {
case Q_DEFAULT:
-#ifdef INET6
- b0 = gen_proto(v, Q_IP, dir);
- b1 = gen_proto(v, Q_IPV6, dir);
- gen_or(b0, b1);
- return b1;
-#else
- /*FALLTHROUGH*/
-#endif
case Q_IP:
b0 = gen_linktype(ETHERTYPE_IP);
-#ifndef CHASE_CHAIN
b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)v);
-#else
- b1 = gen_protochain(v, Q_IP);
-#endif
+ gen_and(b0, b1);
+ return b1;
+
+ case Q_ISO:
+ b0 = gen_linktype(LLC_ISO_LSAP);
+ b1 = gen_cmp(off_nl + 3, BPF_B, (long)v);
gen_and(b0, b1);
return b1;
@@ -1921,31 +1269,6 @@ gen_proto(v, proto, dir)
bpf_error("'igrp proto' is bogus");
/* NOTREACHED */
- case Q_PIM:
- bpf_error("'pim proto' is bogus");
- /* NOTREACHED */
-
-#ifdef INET6
- case Q_IPV6:
- b0 = gen_linktype(ETHERTYPE_IPV6);
-#ifndef CHASE_CHAIN
- b1 = gen_cmp(off_nl + 6, BPF_B, (bpf_int32)v);
-#else
- b1 = gen_protochain(v, Q_IPV6);
-#endif
- gen_and(b0, b1);
- return b1;
-
- case Q_ICMPV6:
- bpf_error("'icmp6 proto' is bogus");
-#endif /* INET6 */
-
- case Q_AH:
- bpf_error("'ah proto' is bogus");
-
- case Q_ESP:
- bpf_error("'ah proto' is bogus");
-
default:
abort();
/* NOTREACHED */
@@ -1963,13 +1286,6 @@ gen_scode(name, q)
int tproto;
u_char *eaddr;
bpf_u_int32 mask, addr, **alist;
-#ifdef INET6
- int tproto6;
- struct sockaddr_in *sin;
- struct sockaddr_in6 *sin6;
- struct addrinfo *res, *res0;
- struct in6_addr mask128;
-#endif /*INET6*/
struct block *b, *tmp;
int port, real_proto;
@@ -2019,7 +1335,6 @@ gen_scode(name, q)
*/
return (gen_host(dn_addr, 0, proto, dir));
} else {
-#ifndef INET6
alist = pcap_nametoaddr(name);
if (alist == NULL || *alist == NULL)
bpf_error("unknown host '%s'", name);
@@ -2034,41 +1349,6 @@ gen_scode(name, q)
b = tmp;
}
return b;
-#else
- memset(&mask128, 0xff, sizeof(mask128));
- res0 = res = pcap_nametoaddr(name);
- if (res == NULL)
- bpf_error("unknown host '%s'", name);
- b = tmp = NULL;
- tproto = tproto6 = proto;
- if (off_linktype == -1 && tproto == Q_DEFAULT) {
- tproto = Q_IP;
- tproto6 = Q_IPV6;
- }
- while (res) {
- switch (res->ai_family) {
- case AF_INET:
- sin = (struct sockaddr_in *)
- res->ai_addr;
- tmp = gen_host(ntohl(sin->sin_addr.s_addr),
- 0xffffffff, tproto, dir);
- break;
- case AF_INET6:
- sin6 = (struct sockaddr_in6 *)
- res->ai_addr;
- tmp = gen_host6(&sin6->sin6_addr,
- &mask128, tproto6, dir);
- break;
- }
- if (b)
- gen_or(b, tmp);
- b = tmp;
-
- res = res->ai_next;
- }
- freeaddrinfo(res0);
- return b;
-#endif /*INET6*/
}
case Q_PORT:
@@ -2090,19 +1370,9 @@ gen_scode(name, q)
/* override PROTO_UNDEF */
real_proto = IPPROTO_TCP;
}
-#ifndef INET6
return gen_port(port, real_proto, dir);
-#else
- {
- struct block *b;
- b = gen_port(port, real_proto, dir);
- gen_or(gen_port6(port, real_proto, dir), b);
- return b;
- }
-#endif /* INET6 */
case Q_GATEWAY:
-#ifndef INET6
eaddr = pcap_ether_hostton(name);
if (eaddr == NULL)
bpf_error("unknown ether host: %s", name);
@@ -2111,9 +1381,6 @@ gen_scode(name, q)
if (alist == NULL || *alist == NULL)
bpf_error("unknown host '%s'", name);
return gen_gateway(eaddr, alist, proto, dir);
-#else
- bpf_error("'gateway' not supported in this configuration");
-#endif /*INET6*/
case Q_PROTO:
real_proto = lookup_proto(name, proto);
@@ -2122,14 +1389,6 @@ gen_scode(name, q)
else
bpf_error("unknown protocol: %s", name);
- case Q_PROTOCHAIN:
- real_proto = lookup_proto(name, proto);
- if (real_proto >= 0)
- return gen_protochain(real_proto, proto, dir);
- else
- bpf_error("unknown protocol: %s", name);
-
-
case Q_UNDEF:
syntax();
/* NOTREACHED */
@@ -2232,16 +1491,7 @@ gen_ncode(s, v, q)
else
bpf_error("illegal qualifier of 'port'");
-#ifndef INET6
return gen_port((int)v, proto, dir);
-#else
- {
- struct block *b;
- b = gen_port((int)v, proto, dir);
- gen_or(gen_port6((int)v, proto, dir), b);
- return b;
- }
-#endif /* INET6 */
case Q_GATEWAY:
bpf_error("'gateway' requires a name");
@@ -2250,9 +1500,6 @@ gen_ncode(s, v, q)
case Q_PROTO:
return gen_proto((int)v, proto, dir);
- case Q_PROTOCHAIN:
- return gen_protochain((int)v, proto, dir);
-
case Q_UNDEF:
syntax();
/* NOTREACHED */
@@ -2264,64 +1511,6 @@ gen_ncode(s, v, q)
/* NOTREACHED */
}
-#ifdef INET6
-struct block *
-gen_mcode6(s1, s2, masklen, q)
- register const char *s1, *s2;
- register int masklen;
- struct qual q;
-{
- struct addrinfo *res;
- struct in6_addr *addr;
- struct in6_addr mask;
- struct block *b;
- u_int32_t *a, *m;
-
- if (s2)
- bpf_error("no mask %s supported", s2);
-
- res = pcap_nametoaddr(s1);
- if (!res)
- bpf_error("invalid ip6 address %s", s1);
- if (res->ai_next)
- bpf_error("%s resolved to multiple address", s1);
- addr = &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
-
- if (sizeof(mask) * 8 < masklen)
- bpf_error("mask length must be <= %u", (unsigned int)(sizeof(mask) * 8));
- memset(&mask, 0xff, masklen / 8);
- if (masklen % 8) {
- mask.s6_addr[masklen / 8] =
- (0xff << (8 - masklen % 8)) & 0xff;
- }
-
- a = (u_int32_t *)addr;
- m = (u_int32_t *)&mask;
- if ((a[0] & ~m[0]) || (a[1] & ~m[1])
- || (a[2] & ~m[2]) || (a[3] & ~m[3])) {
- bpf_error("non-network bits set in \"%s/%d\"", s1, masklen);
- }
-
- switch (q.addr) {
-
- case Q_DEFAULT:
- case Q_HOST:
- if (masklen != 128)
- bpf_error("Mask syntax for networks only");
- /* FALLTHROUGH */
-
- case Q_NET:
- b = gen_host6(addr, &mask, q.proto, q.dir);
- freeaddrinfo(res);
- return b;
-
- default:
- bpf_error("invalid qualifier against IPv6 address");
- /* NOTREACHED */
- }
-}
-#endif /*INET6*/
-
struct block *
gen_ecode(eaddr, q)
register const u_char *eaddr;
@@ -2420,10 +1609,7 @@ gen_load(proto, index, size)
case Q_LAT:
case Q_MOPRC:
case Q_MOPDL:
-#ifdef INET6
- case Q_IPV6:
-#endif
- /* XXX Note that we assume a fixed link link header here. */
+ /* XXX Note that we assume a fixed link header here. */
s = xfer_to_x(index);
tmp = new_stmt(BPF_LD|BPF_IND|size);
tmp->s.k = off_nl;
@@ -2441,7 +1627,6 @@ gen_load(proto, index, size)
case Q_ICMP:
case Q_IGMP:
case Q_IGRP:
- case Q_PIM:
s = new_stmt(BPF_LDX|BPF_MSH|BPF_B);
s->s.k = off_nl;
sappend(s, xfer_to_a(index));
@@ -2454,16 +1639,8 @@ gen_load(proto, index, size)
gen_and(gen_proto_abbrev(proto), b = gen_ipfrag());
if (index->b)
gen_and(index->b, b);
-#ifdef INET6
- gen_and(gen_proto_abbrev(Q_IP), b);
-#endif
index->b = b;
break;
-#ifdef INET6
- case Q_ICMPV6:
- bpf_error("IPv6 upper-layer protocol is not supported by proto[x]");
- /*NOTREACHED*/
-#endif
}
index->regno = regno;
s = new_stmt(BPF_ST);
@@ -2660,6 +1837,10 @@ gen_greater(n)
return gen_len(BPF_JGE, n);
}
+/*
+ * Actually, this is less than or equal.
+ */
+
struct block *
gen_less(n)
int n;
@@ -2785,14 +1966,6 @@ gen_multicast(proto)
b1->s.code = JMP(BPF_JGE);
gen_and(b0, b1);
return b1;
-
-#ifdef INET6
- case Q_IPV6:
- b0 = gen_linktype(ETHERTYPE_IPV6);
- b1 = gen_cmp(off_nl + 24, BPF_B, (bpf_int32)255);
- gen_and(b0, b1);
- return b1;
-#endif /* INET6 */
}
bpf_error("only IP multicast filters supported on ethernet/FDDI");
}
diff --git a/contrib/libpcap/gencode.h b/contrib/libpcap/gencode.h
index de80dfc..eb97ec2 100644
--- a/contrib/libpcap/gencode.h
+++ b/contrib/libpcap/gencode.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.37 1999/10/19 15:18:29 itojun Exp $ (LBL)
+ * @(#) $Header: gencode.h,v 1.36 96/07/17 00:11:34 leres Exp $ (LBL)
*/
/*XXX*/
@@ -31,7 +31,6 @@
#define Q_PORT 3
#define Q_GATEWAY 4
#define Q_PROTO 5
-#define Q_PROTOCHAIN 6
/* Protocol qualifiers. */
@@ -52,14 +51,9 @@
#define Q_SCA 13
#define Q_MOPRC 14
#define Q_MOPDL 15
-
-
-#define Q_IPV6 16
-#define Q_ICMPV6 17
-#define Q_AH 18
-#define Q_ESP 19
-
-#define Q_PIM 20
+#define Q_ISO 16
+#define Q_ESIS 17
+#define Q_ISIS 18
/* Directional qualifiers. */
@@ -71,12 +65,8 @@
#define Q_DEFAULT 0
#define Q_UNDEF 255
-struct slist;
-
struct stmt {
int code;
- struct slist *jt; /*only for relative jump in block*/
- struct slist *jf; /*only for relative jump in block*/
bpf_int32 k;
};
@@ -163,9 +153,6 @@ void gen_not(struct block *);
struct block *gen_scode(const char *, struct qual);
struct block *gen_ecode(const u_char *, struct qual);
struct block *gen_mcode(const char *, const char *, int, struct qual);
-#ifdef INET6
-struct block *gen_mcode6(const char *, const char *, int, struct qual);
-#endif
struct block *gen_ncode(const char *, bpf_u_int32, struct qual);
struct block *gen_proto_abbrev(int);
struct block *gen_relation(int, struct arth *, struct arth *, int);
@@ -193,5 +180,3 @@ void sappend(struct slist *, struct slist *);
/* XXX */
#define JT(b) ((b)->et.succ)
#define JF(b) ((b)->ef.succ)
-
-extern int no_optimize;
diff --git a/contrib/libpcap/grammar.y b/contrib/libpcap/grammar.y
index 104056f..0803c6d 100644
--- a/contrib/libpcap/grammar.y
+++ b/contrib/libpcap/grammar.y
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.57 1999/10/19 15:18:30 itojun Exp $ (LBL)";
+ "@(#) $Header: grammar.y,v 1.56 96/11/02 21:54:55 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -37,7 +37,7 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <stdio.h>
@@ -102,21 +102,21 @@ pcap_parse()
%type <rblk> other
%token DST SRC HOST GATEWAY
-%token NET MASK PORT LESS GREATER PROTO PROTOCHAIN BYTE
-%token ARP RARP IP TCP UDP ICMP IGMP IGRP PIM
+%token NET MASK PORT LESS GREATER PROTO BYTE
+%token ARP RARP IP TCP UDP ICMP IGMP IGRP
%token ATALK DECNET LAT SCA MOPRC MOPDL
%token TK_BROADCAST TK_MULTICAST
%token NUM INBOUND OUTBOUND
%token LINK
%token GEQ LEQ NEQ
-%token ID EID HID HID6
+%token ID EID HID
%token LSH RSH
%token LEN
-%token IPV6 ICMPV6 AH ESP
+%token ISO ESIS ISIS
%type <s> ID
%type <e> EID
-%type <s> HID HID6
+%type <s> HID
%type <i> NUM
%left OR AND
@@ -168,24 +168,6 @@ nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
break;
}
}
- | HID6 '/' NUM {
-#ifdef INET6
- $$.b = gen_mcode6($1, NULL, $3,
- $$.q = $<blk>0.q);
-#else
- bpf_error("'ip6addr/prefixlen' not supported "
- "in this configuration");
-#endif /*INET6*/
- }
- | HID6 {
-#ifdef INET6
- $$.b = gen_mcode6($1, 0, 128,
- $$.q = $<blk>0.q);
-#else
- bpf_error("'ip6addr' not supported "
- "in this configuration");
-#endif /*INET6*/
- }
| EID { $$.b = gen_ecode($1, $$.q = $<blk>0.q); }
| not id { gen_not($2.b); $$ = $2; }
;
@@ -208,7 +190,6 @@ head: pqual dqual aqual { QSET($$.q, $1, $2, $3); }
| pqual dqual { QSET($$.q, $1, $2, Q_DEFAULT); }
| pqual aqual { QSET($$.q, $1, Q_DEFAULT, $2); }
| pqual PROTO { QSET($$.q, $1, Q_DEFAULT, Q_PROTO); }
- | pqual PROTOCHAIN { QSET($$.q, $1, Q_DEFAULT, Q_PROTOCHAIN); }
| pqual ndaqual { QSET($$.q, $1, Q_DEFAULT, $2); }
;
rterm: head id { $$ = $2; }
@@ -249,17 +230,15 @@ pname: LINK { $$ = Q_LINK; }
| ICMP { $$ = Q_ICMP; }
| IGMP { $$ = Q_IGMP; }
| IGRP { $$ = Q_IGRP; }
- | PIM { $$ = Q_PIM; }
| ATALK { $$ = Q_ATALK; }
| DECNET { $$ = Q_DECNET; }
| LAT { $$ = Q_LAT; }
| SCA { $$ = Q_SCA; }
| MOPDL { $$ = Q_MOPDL; }
| MOPRC { $$ = Q_MOPRC; }
- | IPV6 { $$ = Q_IPV6; }
- | ICMPV6 { $$ = Q_ICMPV6; }
- | AH { $$ = Q_AH; }
- | ESP { $$ = Q_ESP; }
+ | ISO { $$ = Q_ISO; }
+ | ESIS { $$ = Q_ESIS; }
+ | ISIS { $$ = Q_ISIS; }
;
other: pqual TK_BROADCAST { $$ = gen_broadcast($1); }
| pqual TK_MULTICAST { $$ = gen_multicast($1); }
diff --git a/contrib/libpcap/nametoaddr.c b/contrib/libpcap/nametoaddr.c
index 3a5e3b6..7b744c8 100644
--- a/contrib/libpcap/nametoaddr.c
+++ b/contrib/libpcap/nametoaddr.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.51 1999/11/25 08:25:35 itojun Exp $ (LBL)";
+ "@(#) $Header: nametoaddr.c,v 1.48 98/07/12 13:15:36 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -38,13 +38,9 @@ struct rtentry;
#endif
#include <net/if.h>
+#include <net/ethernet.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
#include <arpa/inet.h>
-#ifdef INET6
-#include <netdb.h>
-#include <sys/socket.h>
-#endif /*INET6*/
#include <ctype.h>
#include <errno.h>
@@ -74,7 +70,6 @@ static inline int xdtoi(int);
* Convert host name to internet address.
* Return 0 upon failure.
*/
-#ifndef INET6
bpf_u_int32 **
pcap_nametoaddr(const char *name)
{
@@ -98,23 +93,6 @@ pcap_nametoaddr(const char *name)
else
return 0;
}
-#else
-struct addrinfo *
-pcap_nametoaddr(const char *name)
-{
- struct addrinfo hints, *res;
- int error;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM; /*not really*/
- error = getaddrinfo(name, NULL, &hints, &res);
- if (error)
- return NULL;
- else
- return res;
-}
-#endif /*INET6*/
/*
* Convert net name to internet address.
@@ -207,9 +185,6 @@ struct eproto eproto_db[] = {
{ "pup", ETHERTYPE_PUP },
{ "xns", ETHERTYPE_NS },
{ "ip", ETHERTYPE_IP },
-#ifdef INET6
- { "ip6", ETHERTYPE_IPV6 },
-#endif
{ "arp", ETHERTYPE_ARP },
{ "rarp", ETHERTYPE_REVARP },
{ "sprite", ETHERTYPE_SPRITE },
@@ -355,7 +330,7 @@ pcap_ether_hostton(const char *name)
}
#else
-#if !defined(sgi) && !defined(__NetBSD__)
+#ifndef sgi
extern int ether_hostton(char *, struct ether_addr *);
#endif
diff --git a/contrib/libpcap/pcap-int.h b/contrib/libpcap/pcap-int.h
index 04e815a..1feda0b 100644
--- a/contrib/libpcap/pcap-int.h
+++ b/contrib/libpcap/pcap-int.h
@@ -30,12 +30,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.20 1999/11/21 01:10:20 assar Exp $ (LBL)
+ * @(#) $Header: pcap-int.h,v 1.18 96/11/27 18:43:09 leres Exp $ (LBL)
*/
#ifndef pcap_int_h
#define pcap_int_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <pcap.h>
/*
@@ -97,27 +101,6 @@ struct pcap {
char errbuf[PCAP_ERRBUF_SIZE];
};
-/*
- * This is a timeval as stored in disk in a dumpfile.
- * It has to use the same types everywhere, independent of the actual
- * `struct timeval'
- */
-
-struct pcap_timeval {
- bpf_int32 tv_sec; /* seconds */
- bpf_int32 tv_usec; /* microseconds */
-};
-
-/*
- * How a `pcap_pkthdr' is actually stored in the dumpfile.
- */
-
-struct pcap_sf_pkthdr {
- struct pcap_timeval ts; /* time stamp */
- bpf_u_int32 caplen; /* length of portion present */
- bpf_u_int32 len; /* length this packet (off wire) */
-};
-
int yylex(void);
#ifndef min
@@ -129,10 +112,15 @@ int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
/* Ultrix pads to make everything line up on a nice boundary */
-#if defined(ultrix) || defined(__alpha) || defined(__NetBSD__)
+#if defined(ultrix) || defined(__alpha)
#define PCAP_FDDIPAD 3
#endif
/* XXX */
extern int pcap_fddipad;
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/contrib/libpcap/pcap-namedb.h b/contrib/libpcap/pcap-namedb.h
index 83ddec1..4310907 100644
--- a/contrib/libpcap/pcap-namedb.h
+++ b/contrib/libpcap/pcap-namedb.h
@@ -30,12 +30,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/libpcap/pcap-namedb.h,v 1.6 1999/10/19 15:18:31 itojun Exp $ (LBL)
+ * @(#) $Header: pcap-namedb.h,v 1.5 96/07/14 03:00:14 leres Exp $ (LBL)
*/
#ifndef lib_pcap_ethers_h
#define lib_pcap_ethers_h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
/*
* As returned by the pcap_next_etherent()
* XXX this stuff doesn't belong in this interface, but this
@@ -54,11 +59,7 @@ struct pcap_etherent *pcap_next_etherent(FILE *);
u_char *pcap_ether_hostton(const char*);
u_char *pcap_ether_aton(const char *);
-#ifndef INET6
bpf_u_int32 **pcap_nametoaddr(const char *);
-#else
-struct addrinfo *pcap_nametoaddr(const char *);
-#endif
bpf_u_int32 pcap_nametonetaddr(const char *);
int pcap_nametoport(const char *, int *, int *);
@@ -77,4 +78,9 @@ int __pcap_atodn(const char *, bpf_u_int32 *);
int __pcap_atoin(const char *, bpf_u_int32 *);
u_short __pcap_nametodnaddr(const char *);
+#ifdef __cplusplus
+}
+#endif
+
+
#endif
diff --git a/contrib/libpcap/pcap.3 b/contrib/libpcap/pcap.3
index c358c63..6c1eaea 100644
--- a/contrib/libpcap/pcap.3
+++ b/contrib/libpcap/pcap.3
@@ -17,6 +17,8 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
+.\" $Id$
+.\"
.TH PCAP 3 "24 June 1998"
.SH NAME
pcap \- Packet Capture library
@@ -156,7 +158,7 @@ If there is an error,
.B NULL
is returned and
.I errbuf
-is filled in with with an appropriate error message.
+is filled in with an appropriate error message.
.PP
.B pcap_lookupnet()
is used to determine the network number and mask
@@ -171,7 +173,7 @@ are
pointers.
A return of -1 indicates an error in which case
.I errbuf
-is filled in with with an appropriate error message.
+is filled in with an appropriate error message.
.PP
.B pcap_dispatch()
is used to collect and process packets.
@@ -225,15 +227,6 @@ controls whether optimization on the resulting code is performed.
.I netmask
specifies the netmask of the local net.
.PP
-.B pcap_compile_nopcap()
-is similar to
-.B pcap_compile()
-except that instead of passing a pcap structure, one passes the
-snaplen and linktype explicitly. It is intended to be used for
-compiling filters for direct bpf usage, without necessarily having
-called
-.BR pcap_open() .
-.PP
.B pcap_setfilter()
is used to specify a filter program.
.I fp
diff --git a/contrib/libpcap/pcap.h b/contrib/libpcap/pcap.h
index 7316386..0c860802 100644
--- a/contrib/libpcap/pcap.h
+++ b/contrib/libpcap/pcap.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.22 1999/12/08 19:54:03 mcr Exp $ (LBL)
+ * @(#) $Header: pcap.h,v 1.21 97/10/15 21:59:13 leres Exp $ (LBL)
*/
#ifndef lib_pcap_h
@@ -43,6 +43,11 @@
#include <stdio.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
#define PCAP_VERSION_MAJOR 2
#define PCAP_VERSION_MINOR 4
@@ -115,8 +120,6 @@ char *pcap_strerror(int);
char *pcap_geterr(pcap_t *);
int pcap_compile(pcap_t *, struct bpf_program *, char *, int,
bpf_u_int32);
-int pcap_compile_nopcap(int, int, struct bpf_program *,
- char *, int, bpf_u_int32);
/* XXX */
int pcap_freecode(pcap_t *, struct bpf_program *);
int pcap_datalink(pcap_t *);
@@ -136,4 +139,10 @@ void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
/* XXX this guy lives in the bpf tree */
u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
char *bpf_image(struct bpf_insn *, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+
#endif
diff --git a/contrib/libpcap/scanner.l b/contrib/libpcap/scanner.l
index 6b973fb..a76491c 100644
--- a/contrib/libpcap/scanner.l
+++ b/contrib/libpcap/scanner.l
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.60 1999/11/17 04:09:58 assar Exp $ (LBL)";
+ "@(#) $Header: scanner.l,v 1.56 97/07/21 13:31:50 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -30,16 +30,11 @@ static const char rcsid[] =
#include <ctype.h>
#include <unistd.h>
-#include <string.h>
#include "pcap-int.h"
#include "gencode.h"
#include <pcap-namedb.h>
-#ifdef INET6
-#include <netdb.h>
-#include <sys/socket.h>
-#endif /*INET6*/
#include "tokdefs.h"
#include "gnuc.h"
@@ -81,91 +76,8 @@ static char *in_buffer;
N ([0-9]+|(0X|0x)[0-9A-Fa-f]+)
B ([0-9A-Fa-f][0-9A-Fa-f]?)
-W ([0-9A-Fa-f][0-9A-Fa-f]?[0-9A-Fa-f]?[0-9A-Fa-f]?)
-%a 15000
-%o 17000
-%e 6000
-%k 4000
-%p 19000
-
-V680 {W}:{W}:{W}:{W}:{W}:{W}:{W}:{W}
-
-V670 ::{W}:{W}:{W}:{W}:{W}:{W}:{W}
-V671 {W}::{W}:{W}:{W}:{W}:{W}:{W}
-V672 {W}:{W}::{W}:{W}:{W}:{W}:{W}
-V673 {W}:{W}:{W}::{W}:{W}:{W}:{W}
-V674 {W}:{W}:{W}:{W}::{W}:{W}:{W}
-V675 {W}:{W}:{W}:{W}:{W}::{W}:{W}
-V676 {W}:{W}:{W}:{W}:{W}:{W}::{W}
-V677 {W}:{W}:{W}:{W}:{W}:{W}:{W}::
-
-V660 ::{W}:{W}:{W}:{W}:{W}:{W}
-V661 {W}::{W}:{W}:{W}:{W}:{W}
-V662 {W}:{W}::{W}:{W}:{W}:{W}
-V663 {W}:{W}:{W}::{W}:{W}:{W}
-V664 {W}:{W}:{W}:{W}::{W}:{W}
-V665 {W}:{W}:{W}:{W}:{W}::{W}
-V666 {W}:{W}:{W}:{W}:{W}:{W}::
-
-V650 ::{W}:{W}:{W}:{W}:{W}
-V651 {W}::{W}:{W}:{W}:{W}
-V652 {W}:{W}::{W}:{W}:{W}
-V653 {W}:{W}:{W}::{W}:{W}
-V654 {W}:{W}:{W}:{W}::{W}
-V655 {W}:{W}:{W}:{W}:{W}::
-
-V640 ::{W}:{W}:{W}:{W}
-V641 {W}::{W}:{W}:{W}
-V642 {W}:{W}::{W}:{W}
-V643 {W}:{W}:{W}::{W}
-V644 {W}:{W}:{W}:{W}::
-
-V630 ::{W}:{W}:{W}
-V631 {W}::{W}:{W}
-V632 {W}:{W}::{W}
-V633 {W}:{W}:{W}::
-
-V620 ::{W}:{W}
-V621 {W}::{W}
-V622 {W}:{W}::
-
-V610 ::{W}
-V611 {W}::
-
-V600 ::
-
-V6604 {W}:{W}:{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
-
-V6504 ::{W}:{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6514 {W}::{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6524 {W}:{W}::{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6534 {W}:{W}:{W}::{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6544 {W}:{W}:{W}:{W}::{W}:{N}\.{N}\.{N}\.{N}
-V6554 {W}:{W}:{W}:{W}:{W}::{N}\.{N}\.{N}\.{N}
-
-V6404 ::{W}:{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6414 {W}::{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6424 {W}:{W}::{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6434 {W}:{W}:{W}::{W}:{N}\.{N}\.{N}\.{N}
-V6444 {W}:{W}:{W}:{W}::{N}\.{N}\.{N}\.{N}
-
-V6304 ::{W}:{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6314 {W}::{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6324 {W}:{W}::{W}:{N}\.{N}\.{N}\.{N}
-V6334 {W}:{W}:{W}::{N}\.{N}\.{N}\.{N}
-
-V6204 ::{W}:{W}:{N}\.{N}\.{N}\.{N}
-V6214 {W}::{W}:{N}\.{N}\.{N}\.{N}
-V6224 {W}:{W}::{N}\.{N}\.{N}\.{N}
-
-V6104 ::{W}:{N}\.{N}\.{N}\.{N}
-V6114 {W}::{N}\.{N}\.{N}\.{N}
-
-V6004 ::{N}\.{N}\.{N}\.{N}
-
-
-V6 ({V680}|{V670}|{V671}|{V672}|{V673}|{V674}|{V675}|{V676}|{V677}|{V660}|{V661}|{V662}|{V663}|{V664}|{V665}|{V666}|{V650}|{V651}|{V652}|{V653}|{V654}|{V655}|{V640}|{V641}|{V642}|{V643}|{V644}|{V630}|{V631}|{V632}|{V633}|{V620}|{V621}|{V622}|{V610}|{V611}|{V600}|{V6604}|{V6504}|{V6514}|{V6524}|{V6534}|{V6544}|{V6554}|{V6404}|{V6414}|{V6424}|{V6434}|{V6444}|{V6304}|{V6314}|{V6324}|{V6334}|{V6204}|{V6214}|{V6224}|{V6104}|{V6114}|{V6004})
+%a 3000
%%
dst return DST;
@@ -181,12 +93,6 @@ udp return UDP;
icmp return ICMP;
igmp return IGMP;
igrp return IGRP;
-pim return PIM;
-
-ip6 return IPV6;
-icmp6 return ICMPV6;
-ah return AH;
-esp return ESP;
atalk return ATALK;
decnet return DECNET;
@@ -195,18 +101,17 @@ sca return SCA;
moprc return MOPRC;
mopdl return MOPDL;
+iso return ISO;
+esis return ESIS;
+es-is return ESIS;
+isis return ISIS;
+is-is return ISIS;
+
host return HOST;
net return NET;
mask return MASK;
port return PORT;
proto return PROTO;
-protochain {
-#ifdef NO_PROTOCHAIN
- bpf_error("%s not supported", yytext);
-#else
- return PROTOCHAIN;
-#endif
- }
gateway return GATEWAY;
@@ -237,21 +142,6 @@ outbound return OUTBOUND;
yylval.s = sdup((char *)yytext); return HID; }
{B}:{B}:{B}:{B}:{B}:{B} { yylval.e = pcap_ether_aton((char *)yytext);
return EID; }
-{V6} {
-#ifdef INET6
- struct addrinfo hints, *res;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET6;
- hints.ai_flags = AI_NUMERICHOST;
- if (getaddrinfo(yytext, NULL, &hints, &res))
- bpf_error("bogus IPv6 address %s", yytext);
- else {
- yylval.e = sdup((char *)yytext); return HID6;
- }
-#else
- bpf_error("IPv6 address %s not supported", yytext);
-#endif /*INET6*/
- }
{B}:+({B}:+)+ { bpf_error("bogus ethernet address %s", yytext); }
[A-Za-z0-9][-_.A-Za-z0-9]*[.A-Za-z0-9] {
yylval.s = sdup((char *)yytext); return ID; }
OpenPOWER on IntegriCloud