]> The Tcpdump Group git mirrors - libpcap/commitdiff
IPv6 packet filtering code.
authoritojun <itojun>
Tue, 19 Oct 1999 15:18:28 +0000 (15:18 +0000)
committeritojun <itojun>
Tue, 19 Oct 1999 15:18:28 +0000 (15:18 +0000)
./configure --enable-ipv6 (requires getaddrinfo(3) and getnameinfo(3)).

TODO: make it work even without getaddrinfo(3) or getnameinfo(3)
(or, tcpdump/configure.in should provide alternative version by
AC_REPLACE_FUNCS)
TODO: make IPv6 filtering code work by default
TODO: make "protochain" friendly with optimization

15 files changed:
Makefile.in
aclocal.m4
bpf/net/bpf.h
configure
configure.in
gencode.c
gencode.h
grammar.y
nametoaddr.c
optimize.c
pcap-bpf.c
pcap-int.h
pcap-namedb.h
ppp.h
scanner.l

index d8121a102f18e9422b7929162b3acdbf45a3361b..bd76e7f4f8422d19a9cfa7d9069d666965c9219e 100644 (file)
@@ -17,7 +17,7 @@
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.73 1999-10-10 01:47:05 mcr Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.74 1999-10-19 15:18:28 itojun Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -65,7 +65,7 @@ YACC = @V_YACC@
 # problem if you don't own the file but can write to the directory.
 .c.o:
        @rm -f $@
-       $(CC) $(CFLAGS) -c $<
+       $(CC) $(CFLAGS) -c $(srcdir)/$*.c
 
 PSRC = pcap-@[email protected]
 CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c \
index be15f25ea1d082b1db5e247dc970add9a84c85c5..a6e6d6cf4a1e33aed31074ec6ee7dbd28bb086d0 100644 (file)
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.64 1999-10-10 01:47:05 mcr Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.65 1999-10-19 15:18:28 itojun Exp $ (LBL)
 dnl
 dnl Copyright (c) 1995, 1996, 1997, 1998
 dnl    The Regents of the University of California.  All rights reserved.
@@ -51,7 +51,7 @@ AC_DEFUN(AC_LBL_C_INIT,
     $1="-O"
     $2=""
     if test "${srcdir}" != "." ; then
-           $2="-I\$(srcdir)"
+           $2="-I\$\(srcdir\)"
     fi
     if test "${CFLAGS+set}" = set; then
            LBL_CFLAGS="$CFLAGS"
index 8d5cd9f28227fad633e652e951424dd34684706d..57b80745361b81b113ffe6e51685c22974e224bd 100644 (file)
@@ -37,7 +37,7 @@
  *
  *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
  *
- * @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.36 1999-10-07 23:46:41 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.37 1999-10-19 15:18:31 itojun Exp $ (LBL)
  */
 
 #ifndef BPF_MAJOR_VERSION
@@ -52,7 +52,11 @@ typedef      u_int bpf_u_int32;
  * Alignment macros.  BPF_WORDALIGN rounds up to the next 
  * even multiple of BPF_ALIGNMENT. 
  */
+#ifndef __NetBSD__
 #define BPF_ALIGNMENT sizeof(bpf_int32)
+#else
+#define BPF_ALIGNMENT sizeof(long)
+#endif
 #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
 
 #define BPF_MAXINSNS 512
@@ -168,10 +172,21 @@ struct bpf_hdr {
 #define DLT_SLIP       8       /* Serial Line IP */
 #define DLT_PPP                9       /* Point-to-point Protocol */
 #define DLT_FDDI       10      /* FDDI */
+#ifdef __FreeBSD__
+#define DLT_ATM_RFC1483        11      /* LLC/SNAP encapsulated atm */
+#endif
+#ifdef __OpenBSD__
 #define DLT_ATM_RFC1483        11      /* LLC/SNAP encapsulated atm */
-#define DLT_RAW                12      /* raw IP */
-#define DLT_SLIP_BSDOS 13      /* BSD/OS Serial Line IP */
-#define DLT_PPP_BSDOS  14      /* BSD/OS Point-to-point Protocol */
+#define DLT_LOOP       12      /* loopback */
+#endif
+/* offset to avoid collision with BSD/OS values */
+#ifndef DLT_ATM_RFC1483
+#define DLT_ATM_RFC1483        100     /* LLC/SNAP encapsulated atm */
+#endif
+#define DLT_RAW                101     /* raw IP */
+#define DLT_SLIP_BSDOS 102     /* BSD/OS Serial Line IP */
+#define DLT_PPP_BSDOS  103     /* BSD/OS Point-to-point Protocol */
+#define DLT_CHDLC      104     /* Cisco HDLC */
 
 /*
  * The instruction encondings.
index 59e6917e2dd5c49ee7164311166e0652a67ffa67..45549c524aa7a0fa26ed2a4fde59b34982c9519b 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12 
+# Generated automatically using autoconf version 2.13 
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This configure script is free software; the Free Software Foundation
@@ -15,6 +15,8 @@ ac_help="$ac_help
   --without-gcc           don't use gcc"
 ac_help="$ac_help
   --with-pcap=TYPE        use packet capture TYPE"
+ac_help="$ac_help
+  --enable-ipv6           build IPv6-capable version"
 ac_help="$ac_help
   --without-flex          don't use flex"
 ac_help="$ac_help
@@ -57,6 +59,7 @@ mandir='${prefix}/man'
 # Initialize some other variables.
 subdirs=
 MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
 # Maximum number of lines to put in a shell here document.
 ac_max_here_lines=12
 
@@ -340,7 +343,7 @@ EOF
     verbose=yes ;;
 
   -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.12"
+    echo "configure generated by autoconf version 2.13"
     exit 0 ;;
 
   -with-* | --with-*)
@@ -510,9 +513,11 @@ ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
+ac_exeext=
+ac_objext=o
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
   # Stardent Vistra SVR4 grep lacks -e, says [email protected].
   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -569,33 +574,33 @@ esac
 
 
 # Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
 else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:578: checking host system type" >&5
+echo "configure:583: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
 NONE)
   case $nonopt in
   NONE)
-    if host_alias=`$ac_config_guess`; then :
+    if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
     else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
     fi ;;
   *) host_alias=$nonopt ;;
   esac ;;
 esac
 
-host=`$ac_config_sub $host_alias`
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
 host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:599: checking target system type" >&5
+echo "configure:604: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -606,14 +611,14 @@ NONE)
   esac ;;
 esac
 
-target=`$ac_config_sub $target_alias`
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
 target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:617: checking build system type" >&5
+echo "configure:622: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -624,7 +629,7 @@ NONE)
   esac ;;
 esac
 
-build=`$ac_config_sub $build_alias`
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
 build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
@@ -655,7 +660,7 @@ fi
     V_CCOPT="-O"
     V_INCLS=""
     if test "${srcdir}" != "." ; then
-           V_INCLS="-I\$(srcdir)"
+           V_INCLS="-I\$\(srcdir\)"
     fi
     if test "${CFLAGS+set}" = set; then
            LBL_CFLAGS="$CFLAGS"
@@ -667,15 +672,16 @@ fi
                    # Extract the first word of "shlicc2", so it can be a program name with args.
 set dummy shlicc2; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:671: checking for $ac_word" >&5
+echo "configure:676: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_SHLICC2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$SHLICC2"; then
   ac_cv_prog_SHLICC2="$SHLICC2" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_SHLICC2="yes"
@@ -707,15 +713,16 @@ fi
     # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:711: checking for $ac_word" >&5
+echo "configure:717: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_CC="gcc"
@@ -736,16 +743,17 @@ if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:740: checking for $ac_word" >&5
+echo "configure:747: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -780,25 +788,61 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
+  if test -z "$CC"; then
+    case "`uname -s`" in
+    *win32* | *WIN32*)
+      # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:798: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="cl"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+ ;;
+    esac
+  fi
   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:788: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:830: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 cross_compiling=$ac_cv_prog_cc_cross
 
-cat > conftest.$ac_ext <<EOF
-#line 798 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 841 "configure"
 #include "confdefs.h"
+
 main(){return(0);}
 EOF
-if { (eval echo configure:802: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:846: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -812,18 +856,24 @@ else
   ac_cv_prog_cc_works=no
 fi
 rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
 
 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
 if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:822: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:872: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:827: checking whether we are using GNU C" >&5
+echo "configure:877: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -832,7 +882,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:836: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:886: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -843,11 +893,15 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6
 
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  ac_test_CFLAGS="${CFLAGS+set}"
-  ac_save_CFLAGS="$CFLAGS"
-  CFLAGS=
-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:851: checking whether ${CC-cc} accepts -g" >&5
+else
+  GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:905: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -862,16 +916,20 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
-    CFLAGS="-O2"
+    CFLAGS="-g"
   fi
 else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
 fi
 
     if test "$GCC" = yes ; then
@@ -880,7 +938,7 @@ fi
                    V_CCOPT="-O2"
            else
                    echo $ac_n "checking gcc version""... $ac_c" 1>&6
-echo "configure:884: checking gcc version" >&5
+echo "configure:942: checking gcc version" >&5
                    if eval "test \"`echo '$''{'ac_cv_lbl_gcc_vers'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -898,19 +956,19 @@ fi
            fi
     else
            echo $ac_n "checking that $CC handles ansi prototypes""... $ac_c" 1>&6
-echo "configure:902: checking that $CC handles ansi prototypes" >&5
+echo "configure:960: checking that $CC handles ansi prototypes" >&5
            if eval "test \"`echo '$''{'ac_cv_lbl_cc_ansi_prototypes'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 907 "configure"
+#line 965 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int main() {
 int frob(int, char *)
 ; return 0; }
 EOF
-if { (eval echo configure:914: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_cc_ansi_prototypes=yes
 else
@@ -928,21 +986,21 @@ fi
 
                    hpux*)
                            echo $ac_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)""... $ac_c" 1>&6
-echo "configure:932: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
+echo "configure:990: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
                            savedcflags="$CFLAGS"
                            CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
                            if eval "test \"`echo '$''{'ac_cv_lbl_cc_hpux_cc_aa'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 939 "configure"
+#line 997 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int main() {
 int frob(int, char *)
 ; return 0; }
 EOF
-if { (eval echo configure:946: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1004: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_cc_hpux_cc_aa=yes
 else
@@ -986,12 +1044,12 @@ EOF
 
            ultrix*)
                    echo $ac_n "checking that Ultrix $CC hacks const in prototypes""... $ac_c" 1>&6
-echo "configure:990: checking that Ultrix $CC hacks const in prototypes" >&5
+echo "configure:1048: checking that Ultrix $CC hacks const in prototypes" >&5
                    if eval "test \"`echo '$''{'ac_cv_lbl_cc_const_proto'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 995 "configure"
+#line 1053 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int main() {
@@ -999,7 +1057,7 @@ struct a { int b; };
                            void c(const struct a *)
 ; return 0; }
 EOF
-if { (eval echo configure:1003: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1061: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_cc_const_proto=yes
 else
@@ -1024,7 +1082,7 @@ EOF
 
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1028: checking how to run the C preprocessor" >&5
+echo "configure:1086: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1039,14 +1097,14 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1043 "configure"
+#line 1101 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1107: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -1056,14 +1114,31 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1060 "configure"
+#line 1118 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1124: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -nologo -E"
+  cat > conftest.$ac_ext <<EOF
+#line 1135 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
 else
@@ -1075,6 +1150,8 @@ else
 fi
 rm -f conftest*
 fi
+rm -f conftest*
+fi
 rm -f conftest*
   ac_cv_prog_CPP="$CPP"
 fi
@@ -1088,18 +1165,18 @@ for ac_hdr in malloc.h sys/ioccom.h sys/sockio.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1092: checking for $ac_hdr" >&5
+echo "configure:1169: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1097 "configure"
+#line 1174 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1102: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1179: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
@@ -1127,12 +1204,12 @@ done
 
 if test "$GCC" = yes ; then
            echo $ac_n "checking for ANSI ioctl definitions""... $ac_c" 1>&6
-echo "configure:1131: checking for ANSI ioctl definitions" >&5
+echo "configure:1208: checking for ANSI ioctl definitions" >&5
            if eval "test \"`echo '$''{'ac_cv_lbl_gcc_fixincludes'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1136 "configure"
+#line 1213 "configure"
 #include "confdefs.h"
 /*
                     * This generates a "duplicate case value" when fixincludes
@@ -1151,7 +1228,7 @@ switch (0) {
                    }
 ; return 0; }
 EOF
-if { (eval echo configure:1155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1232: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_gcc_fixincludes=yes
 else
@@ -1174,12 +1251,12 @@ fi
 for ac_func in ether_hostton strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1178: checking for $ac_func" >&5
+echo "configure:1255: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1183 "configure"
+#line 1260 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1202,7 +1279,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:1206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1234,7 +1311,7 @@ if test "${with_pcap+set}" = set; then
 fi
 
 echo $ac_n "checking packet capture type""... $ac_c" 1>&6
-echo "configure:1238: checking packet capture type" >&5
+echo "configure:1315: checking packet capture type" >&5
 if test ! -z "$with_pcap" ; then
        V_PCAP="$withval"
 elif test -r /dev/bpf0 ; then
@@ -1264,6 +1341,22 @@ else
 fi
 echo "$ac_t""$V_PCAP" 1>&6
 
+echo $ac_n "checking if --enable-ipv6 option is specified""... $ac_c" 1>&6
+echo "configure:1346: checking if --enable-ipv6 option is specified" >&5
+# Check whether --enable-ipv6 or --disable-ipv6 was given.
+if test "${enable_ipv6+set}" = set; then
+  enableval="$enable_ipv6"
+  :
+fi
+
+if test "$enable_ipv6" = "yes"; then
+       cat >> confdefs.h <<\EOF
+#define INET6 1
+EOF
+
+fi
+echo "$ac_t""${enable_ipv6-no}" 1>&6
+
 case "$V_PCAP" in
 
 dlpi)
@@ -1271,18 +1364,18 @@ dlpi)
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1275: checking for $ac_hdr" >&5
+echo "configure:1368: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1280 "configure"
+#line 1373 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1378: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
@@ -1308,7 +1401,7 @@ fi
 done
 
        echo $ac_n "checking for /dev/dlpi device""... $ac_c" 1>&6
-echo "configure:1312: checking for /dev/dlpi device" >&5
+echo "configure:1405: checking for /dev/dlpi device" >&5
        if test -c /dev/dlpi ; then
                echo "$ac_t""yes" 1>&6
                cat >> confdefs.h <<\EOF
@@ -1319,7 +1412,7 @@ EOF
                echo "$ac_t""no" 1>&6
                dir="/dev/dlpi"
                echo $ac_n "checking for $dir directory""... $ac_c" 1>&6
-echo "configure:1323: checking for $dir directory" >&5
+echo "configure:1416: checking for $dir directory" >&5
                if test -d $dir ; then
                        echo "$ac_t""yes" 1>&6
                        cat >> confdefs.h <<EOF
@@ -1337,18 +1430,18 @@ linux)
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1341: checking for $ac_hdr" >&5
+echo "configure:1434: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1346 "configure"
+#line 1439 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1351: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1444: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
@@ -1374,7 +1467,7 @@ fi
 done
 
        echo $ac_n "checking Linux kernel version""... $ac_c" 1>&6
-echo "configure:1378: checking Linux kernel version" >&5
+echo "configure:1471: checking Linux kernel version" >&5
        if eval "test \"`echo '$''{'ac_cv_linux_vers'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1415,15 +1508,16 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1419: checking for $ac_word" >&5
+echo "configure:1512: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_V_LEX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$V_LEX"; then
   ac_cv_prog_V_LEX="$V_LEX" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_V_LEX="$ac_prog"
@@ -1448,7 +1542,7 @@ test -n "$V_LEX" || V_LEX="lex"
     if test "$V_LEX" = flex ; then
            # The -V flag was added in 2.4
            echo $ac_n "checking for flex 2.4 or higher""... $ac_c" 1>&6
-echo "configure:1452: checking for flex 2.4 or higher" >&5
+echo "configure:1546: checking for flex 2.4 or higher" >&5
            if eval "test \"`echo '$''{'ac_cv_lbl_flex_v24'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1474,15 +1568,16 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1478: checking for $ac_word" >&5
+echo "configure:1572: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_V_YACC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$V_YACC"; then
   ac_cv_prog_V_YACC="$V_YACC" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_V_YACC="$ac_prog"
@@ -1548,19 +1643,19 @@ EOF
 
 sinix*)
        echo $ac_n "checking if SINIX compiler defines sinix""... $ac_c" 1>&6
-echo "configure:1552: checking if SINIX compiler defines sinix" >&5
+echo "configure:1647: checking if SINIX compiler defines sinix" >&5
        if eval "test \"`echo '$''{'ac_cv_cc_sinix_defined'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1557 "configure"
+#line 1652 "configure"
 #include "confdefs.h"
 
 int main() {
 int i = sinix;
 ; return 0; }
 EOF
-if { (eval echo configure:1564: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1659: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cc_sinix_defined=yes
 else
@@ -1598,15 +1693,16 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1602: checking for $ac_word" >&5
+echo "configure:1697: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_V_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   if test -n "$V_RANLIB"; then
   ac_cv_prog_V_RANLIB="$V_RANLIB" # Let the user override the test.
 else
-  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
       ac_cv_prog_V_RANLIB="$ac_prog"
@@ -1668,12 +1764,12 @@ EOF
     fi
 
 echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6
-echo "configure:1672: checking if sockaddr struct has sa_len member" >&5
+echo "configure:1768: checking if sockaddr struct has sa_len member" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1677 "configure"
+#line 1773 "configure"
 #include "confdefs.h"
 
 #      include <sys/types.h>
@@ -1682,7 +1778,7 @@ int main() {
 u_int i = sizeof(((struct sockaddr *)0)->sa_len)
 ; return 0; }
 EOF
-if { (eval echo configure:1686: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_lbl_sockaddr_has_sa_len=yes
 else
@@ -1703,7 +1799,7 @@ EOF
     fi
 
 echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
-echo "configure:1707: checking if unaligned accesses fail" >&5
+echo "configure:1803: checking if unaligned accesses fail" >&5
     if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1765,15 +1861,21 @@ EOF
 
     fi
 
-if test -r ${srcdir}/lbl/gnuc.h ; then
+if test "${srcdir}" = "." ; then
+       srcdirprefix=""
+else
+       srcdirprefix="./"
+fi
+
+if test -r ${srcdirprefix}lbl/gnuc.h ; then
        rm -f gnuc.h
-       ln -s ${srcdir}/lbl/gnuc.h gnuc.h
+       ln -s ${srcdirprefix}lbl/gnuc.h gnuc.h
 fi
 
 rm -f bpf_filter.c
-ln -s ${srcdir}/bpf/net/bpf_filter.c bpf_filter.c
+ln -s ${srcdirprefix}bpf/net/bpf_filter.c bpf_filter.c
 rm -f net
-ln -s ${srcdir}/bpf/net net
+ln -s ${srcdirprefix}bpf/net net
 
 
 
@@ -1789,28 +1891,30 @@ ln -s ${srcdir}/bpf/net net
 # SunOS /usr/etc/install
 # IRIX /sbin/install
 # AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1797: checking for a BSD compatible install" >&5
+echo "configure:1900: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
-    IFS="${IFS=        }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+    IFS="${IFS=        }"; ac_save_IFS="$IFS"; IFS=":"
   for ac_dir in $PATH; do
     # Account for people who put trailing slashes in PATH elements.
     case "$ac_dir/" in
     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
     *)
       # OSF1 and SCO ODT 3.0 have their own names for install.
-      for ac_prog in ginstall installbsd scoinst install; do
+      # Don't use installbsd from OSF since it installs stuff as root
+      # by default.
+      for ac_prog in ginstall scoinst install; do
         if test -f $ac_dir/$ac_prog; then
          if test $ac_prog = install &&
             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
            # AIX install.  It has an incompatible calling convention.
-           # OSF/1 installbsd also uses dspmsg, but is usable.
            :
          else
            ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -1840,6 +1944,8 @@ echo "$ac_t""$INSTALL" 1>&6
 # It thinks the first close brace ends the variable substitution.
 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 
@@ -1866,7 +1972,7 @@ EOF
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
 (set) 2>&1 |
-  case `(ac_space=' '; set) 2>&1` in
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
   *ac_space=\ *)
     # `set' does not quote correctly, so add quotes (double-quote substitution
     # turns \\\\ into \\, and sed turns \\ into \).
@@ -1945,7 +2051,7 @@ do
     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.12"
+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
     exit 0 ;;
   -help | --help | --hel | --he | --h)
     echo "\$ac_cs_usage"; exit 0 ;;
@@ -1965,9 +2071,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
 $ac_vpsub
 $extrasub
+s%@SHELL@%$SHELL%g
 s%@CFLAGS@%$CFLAGS%g
 s%@CPPFLAGS@%$CPPFLAGS%g
 s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
 s%@DEFS@%$DEFS%g
 s%@LDFLAGS@%$LDFLAGS%g
 s%@LIBS@%$LIBS%g
@@ -2011,6 +2119,7 @@ s%@V_CCOPT@%$V_CCOPT%g
 s%@V_INCLS@%$V_INCLS%g
 s%@V_PCAP@%$V_PCAP%g
 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
 s%@INSTALL_DATA@%$INSTALL_DATA%g
 
 CEOF
index add647effc34e58b8adac62e18f9dfafe80938c7..506931fa0c9b98949d31341307b57bb4c5da6697 100644 (file)
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.68 1999-10-10 01:47:06 mcr Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.69 1999-10-19 15:18:29 itojun Exp $ (LBL)
 dnl
 dnl Copyright (c) 1994, 1995, 1996, 1997
 dnl    The Regents of the University of California.  All rights reserved.
@@ -61,6 +61,13 @@ else
 fi
 AC_MSG_RESULT($V_PCAP)
 
+AC_MSG_CHECKING(if --enable-ipv6 option is specified)
+AC_ARG_ENABLE(ipv6, [  --enable-ipv6           build IPv6-capable version])
+if test "$enable_ipv6" = "yes"; then
+       AC_DEFINE(INET6)
+fi
+AC_MSG_RESULT(${enable_ipv6-no})
+
 case "$V_PCAP" in
 
 dlpi)
@@ -156,15 +163,21 @@ AC_LBL_SOCKADDR_SA_LEN
 
 AC_LBL_UNALIGNED_ACCESS
 
-if test -r ${srcdir}/lbl/gnuc.h ; then
+if test "${srcdir}" = "." ; then
+       srcdirprefix=""
+else
+       srcdirprefix="./"
+fi
+
+if test -r ${srcdirprefix}lbl/gnuc.h ; then
        rm -f gnuc.h
-       ln -s ${srcdir}/lbl/gnuc.h gnuc.h
+       ln -s ${srcdirprefix}lbl/gnuc.h gnuc.h
 fi
 
 rm -f bpf_filter.c
-ln -s ${srcdir}/bpf/net/bpf_filter.c bpf_filter.c
+ln -s ${srcdirprefix}bpf/net/bpf_filter.c bpf_filter.c
 rm -f net
-ln -s ${srcdir}/bpf/net net
+ln -s ${srcdirprefix}bpf/net net
 
 AC_SUBST(V_CCOPT)
 AC_SUBST(V_INCLS)
index b7c8c88de6488a1f002f3091434f99f7a478a0b4..972736d64e7fff0869c0ab9051eb4843db2cd15f 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -1,3 +1,4 @@
+/*#define CHASE_CHAIN*/
 /*
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
  *     The Regents of the University of California.  All rights reserved.
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.94 1999-10-07 23:46:40 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.95 1999-10-19 15:18:29 itojun 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;
@@ -52,6 +56,10 @@ struct rtentry;
 #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
@@ -135,15 +143,28 @@ 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 *);
@@ -157,8 +178,13 @@ 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) {
@@ -246,6 +272,7 @@ syntax()
 
 static bpf_u_int32 netmask;
 static int snaplen;
+int no_optimize;
 
 int
 pcap_compile(pcap_t *p, struct bpf_program *program,
@@ -254,6 +281,7 @@ 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;
@@ -275,7 +303,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
        if (root == NULL)
                root = gen_retblk(snaplen);
 
-       if (optimize) {
+       if (optimize && !no_optimize) {
                bpf_optimize(&root);
                if (root == NULL ||
                    (root->s.code == (BPF_RET|BPF_K) && root->s.k == 0))
@@ -487,6 +515,7 @@ init_linktype(type)
                return;
 
        case DLT_PPP:
+       case DLT_CHDLC:
                off_linktype = 2;
                off_nl = 4;
                return;
@@ -580,6 +609,10 @@ 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 /* INET6 */
                break;
 
        case DLT_PPP_BSDOS:
@@ -593,6 +626,13 @@ gen_linktype(proto)
                        gen_or(b1, b0);
                        return b0;
 
+#ifdef INET6
+               case ETHERTYPE_IPV6:
+                       proto = PPP_IPV6;
+                       /* more to go? */
+                       break;
+#endif /* INET6 */
+
                case ETHERTYPE_DN:
                        proto = PPP_DECNET;
                        break;
@@ -611,6 +651,10 @@ 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 /* INET6 */
                else
                        return gen_false();
        }
@@ -659,6 +703,60 @@ 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;
@@ -866,6 +964,9 @@ 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");
 
@@ -884,12 +985,106 @@ 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");
+
+       default:
+               abort();
+       }
+       /* NOTREACHED */
+}
+#endif /*INET6*/
+
 static struct block *
 gen_gateway(eaddr, alist, proto, dir)
        const u_char *eaddr;
@@ -938,38 +1133,45 @@ gen_proto_abbrev(proto)
        switch (proto) {
 
        case Q_TCP:
-               b0 = gen_linktype(ETHERTYPE_IP);
-               b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)IPPROTO_TCP);
-               gen_and(b0, b1);
+               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
                break;
 
        case Q_UDP:
-               b0 =  gen_linktype(ETHERTYPE_IP);
-               b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)IPPROTO_UDP);
-               gen_and(b0, b1);
+               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
                break;
 
        case Q_ICMP:
-               b0 =  gen_linktype(ETHERTYPE_IP);
-               b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)IPPROTO_ICMP);
-               gen_and(b0, b1);
+               b1 = gen_proto(IPPROTO_ICMP, Q_IP, Q_DEFAULT);
                break;
 
        case Q_IGMP:
-               b0 =  gen_linktype(ETHERTYPE_IP);
-               b1 = gen_cmp(off_nl + 9, BPF_B, (bpf_int32)2);
-               gen_and(b0, b1);
+               b1 = gen_proto(2, Q_IP, Q_DEFAULT);
                break;
 
 #ifndef        IPPROTO_IGRP
 #define        IPPROTO_IGRP    9
 #endif
        case Q_IGRP:
-               b0 =  gen_linktype(ETHERTYPE_IP);
-               b1 = gen_cmp(off_nl + 9, BPF_B, (long)IPPROTO_IGRP);
+               b1 = gen_proto(IPPROTO_IGRP, Q_IP, Q_DEFAULT);
                gen_and(b0, b1);
                break;
 
+       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;
@@ -1009,6 +1211,41 @@ gen_proto_abbrev(proto)
                b1 =  gen_linktype(ETHERTYPE_MOPRC);
                break;
 
+#ifdef INET6
+       case Q_IPV6:
+               b1 = gen_linktype(ETHERTYPE_IPV6);
+               break;
+
+#ifndef IPPROTO_ICMPV6
+#define IPPROTO_ICMPV6 58
+#endif
+       case Q_ICMPV6:
+               b1 = gen_proto(IPPROTO_ICMPV6, Q_IPV6, 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
+               break;
+
        default:
                abort();
        }
@@ -1053,6 +1290,16 @@ 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;
@@ -1124,6 +1371,77 @@ 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;
@@ -1154,6 +1472,305 @@ 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;
+{
+       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_IP, 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;
+       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;
+       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++;
+
+       /* 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++;
+
+       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 {
+               /* 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;
+}
+
 static struct block *
 gen_proto(v, proto, dir)
        int v;
@@ -1167,9 +1784,21 @@ 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;
 
@@ -1228,6 +1857,31 @@ 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 */
@@ -1245,6 +1899,13 @@ 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;
 
@@ -1294,6 +1955,7 @@ 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);
@@ -1308,6 +1970,41 @@ 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:
@@ -1329,9 +2026,19 @@ 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);
@@ -1340,6 +2047,9 @@ 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);
@@ -1348,6 +2058,14 @@ 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 */
@@ -1450,7 +2168,16 @@ 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");
@@ -1459,6 +2186,9 @@ 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 */
@@ -1470,6 +2200,64 @@ 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;
@@ -1568,6 +2356,9 @@ 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. */
                s = xfer_to_x(index);
                tmp = new_stmt(BPF_LD|BPF_IND|size);
@@ -1586,6 +2377,7 @@ 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));
@@ -1598,8 +2390,16 @@ 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);
@@ -1921,6 +2721,14 @@ 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");
 }
index da340828e5b74fa68847ff7ee13d2323dce26cd8..8bbdee11b342e1559970d4ccc44d5e0e397df2c9 100644 (file)
--- a/gencode.h
+++ b/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.36 1999-10-07 23:46:40 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.37 1999-10-19 15:18:29 itojun Exp $ (LBL)
  */
 
 /*XXX*/
@@ -31,6 +31,7 @@
 #define Q_PORT         3
 #define Q_GATEWAY      4
 #define Q_PROTO                5
+#define Q_PROTOCHAIN   6
 
 /* Protocol qualifiers. */
 
 #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
+
 /* Directional qualifiers. */
 
 #define Q_SRC          1
 #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;
 };
 
@@ -150,6 +163,9 @@ 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);
@@ -177,3 +193,5 @@ void sappend(struct slist *, struct slist *);
 /* XXX */
 #define JT(b)  ((b)->et.succ)
 #define JF(b)  ((b)->ef.succ)
+
+extern int no_optimize;
index edec0f13effa3da56b22ef943bf4753bf5794767..22e6948eadb6b31b42d0836b283cbab91e8b27cf 100644 (file)
--- a/grammar.y
+++ b/grammar.y
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.56 1999-10-07 23:46:40 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.57 1999-10-19 15:18:30 itojun Exp $ (LBL)";
 #endif
 
 #include <sys/types.h>
@@ -102,20 +102,21 @@ pcap_parse()
 %type  <rblk>  other
 
 %token  DST SRC HOST GATEWAY
-%token  NET MASK PORT LESS GREATER PROTO BYTE
-%token  ARP RARP IP TCP UDP ICMP IGMP IGRP
+%token  NET MASK PORT LESS GREATER PROTO PROTOCHAIN BYTE
+%token  ARP RARP IP TCP UDP ICMP IGMP IGRP PIM
 %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
+%token ID EID HID HID6
 %token LSH RSH
 %token  LEN
+%token  IPV6 ICMPV6 AH ESP
 
 %type  <s> ID
 %type  <e> EID
-%type  <s> HID
+%type  <s> HID HID6
 %type  <i> NUM
 
 %left OR AND
@@ -167,6 +168,24 @@ 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; }
        ;
@@ -189,6 +208,7 @@ 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; }
@@ -229,12 +249,17 @@ 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; }
        ;
 other:   pqual TK_BROADCAST    { $$ = gen_broadcast($1); }
        | pqual TK_MULTICAST    { $$ = gen_multicast($1); }
index 3c935a45875fba2709ec6e2a95c24c602e4fc666..056e777cfa3e2c6e8e785b4501dfc7687163e4dc 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.49 1999-10-17 21:29:18 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.50 1999-10-19 15:18:30 itojun Exp $ (LBL)";
 #endif
 
 #include <sys/param.h>
@@ -41,6 +41,10 @@ struct rtentry;
 #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>
@@ -70,6 +74,7 @@ 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)
 {
@@ -93,6 +98,22 @@ 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;
+       error = getaddrinfo(name, NULL, &hints, &res);
+       if (error)
+               return NULL;
+       else
+               return res;
+}
+#endif /*INET6*/
 
 /*
  *  Convert net name to internet address.
@@ -185,6 +206,9 @@ 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 },
@@ -330,6 +354,10 @@ pcap_ether_hostton(const char *name)
 }
 #else
 
+#if !defined(sgi) && !defined(__NetBSD__)
+extern int ether_hostton(char *, struct ether_addr *);
+#endif
+
 /* Use the os supplied routines */
 u_char *
 pcap_ether_hostton(const char *name)
index b035d2d9fc4ce8d840262b88488e13745451be6e..83999394ef77951915f6612d987c1ba46ff3dcfd 100644 (file)
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.60 1999-10-07 23:46:40 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.61 1999-10-19 15:18:30 itojun Exp $ (LBL)";
 #endif
 
 #include <sys/types.h>
@@ -1104,6 +1104,14 @@ opt_blk(b, do_stmts)
        int i;
        bpf_int32 aval;
 
+#if 0
+       for (s = b->stmts; s && s->next; s = s->next)
+               if (BPF_CLASS(s->s.code) == BPF_JMP) {
+                       do_stmts = 0;
+                       break;
+               }
+#endif
+
        /*
         * Initialize the atom values.
         * If we have no predecessors, everything is undefined.
@@ -1886,6 +1894,7 @@ convert_code_r(p)
        int slen;
        u_int off;
        int extrajmps;          /* number of extra jumps inserted */
+       struct slist **offset = NULL;
 
        if (p == 0 || isMarked(p))
                return (1);
@@ -1902,13 +1911,90 @@ convert_code_r(p)
 
        p->offset = dst - fstart;
 
+       /* generate offset[] for convenience  */
+       if (slen) {
+               offset = (struct slist **)calloc(sizeof(struct slist *), slen);
+               if (!offset) {
+                       bpf_error("not enough core");
+                       /*NOTREACHED*/
+               }
+       }
+       src = p->stmts;
+       for (off = 0; off < slen && src; off++) {
+#if 0
+               printf("off=%d src=%x\n", off, src);
+#endif
+               offset[off] = src;
+               src = src->next;
+       }
+
+       off = 0;
        for (src = p->stmts; src; src = src->next) {
                if (src->s.code == NOP)
                        continue;
                dst->code = (u_short)src->s.code;
                dst->k = src->s.k;
+
+               /* fill block-local relative jump */
+               if (BPF_CLASS(src->s.code) != BPF_JMP || src->s.code == BPF_JMP|BPF_JA) {
+#if 0
+                       if (src->s.jt || src->s.jf) {
+                               bpf_error("illegal jmp destination");
+                               /*NOTREACHED*/
+                       }
+#endif
+                       goto filled;
+               }
+               if (off == slen - 2)    /*???*/
+                       goto filled;
+
+           {
+               int i;
+               int jt, jf;
+               char *ljerr = "%s for block-local relative jump: off=%d";
+
+#if 0
+               printf("code=%x off=%d %x %x\n", src->s.code,
+                       off, src->s.jt, src->s.jf);
+#endif
+
+               if (!src->s.jt || !src->s.jf) {
+                       bpf_error(ljerr, "no jmp destination", off);
+                       /*NOTREACHED*/
+               }
+
+               jt = jf = 0;
+               for (i = 0; i < slen; i++) {
+                       if (offset[i] == src->s.jt) {
+                               if (jt) {
+                                       bpf_error(ljerr, "multiple matches", off);
+                                       /*NOTREACHED*/
+                               }
+
+                               dst->jt = i - off - 1;
+                               jt++;
+                       }
+                       if (offset[i] == src->s.jf) {
+                               if (jf) {
+                                       bpf_error(ljerr, "multiple matches", off);
+                                       /*NOTREACHED*/
+                               }
+                               dst->jf = i - off - 1;
+                               jf++;
+                       }
+               }
+               if (!jt || !jf) {
+                       bpf_error(ljerr, "no destination found", off);
+                       /*NOTREACHED*/
+               }
+           }
+filled:
                ++dst;
+               ++off;
        }
+       if (offset)
+               free(offset);
+
 #ifdef BDEBUG
        bids[dst - fstart] = p->id + 1;
 #endif
index ae827092686cc18bbfafe48e39269472e62492f9..a0af02a5f71a0ab0d982f1860f7a78714f90418b 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.31 1999-10-07 23:46:40 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.32 1999-10-19 15:18:30 itojun Exp $ (LBL)";
 #endif
 
 #include <sys/param.h>                 /* optionally get BSD define */
@@ -47,6 +47,8 @@ static const char rcsid[] =
 #include "os-proto.h"
 #endif
 
+#include "gencode.h"
+
 int
 pcap_stats(pcap_t *p, struct pcap_stat *ps)
 {
@@ -202,6 +204,13 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
                sprintf(ebuf, "BIOCGDLT: %s", pcap_strerror(errno));
                goto bad;
        }
+#ifdef __OpenBSD__
+       switch (v) {
+       case DLT_LOOP:
+               v = DLT_NULL;
+               break;
+       }
+#endif
 #if _BSDI_VERSION - 0 >= 199510
        /* The SLIP and PPP link layer header changed in BSD/OS 2.1 */
        switch (v) {
@@ -213,6 +222,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
        case DLT_PPP:
                v = DLT_PPP_BSDOS;
                break;
+
+       case 11:        /*DLT_FR*/
+               v = DLT_RAW;    /*XXX*/
+               break;
+
+       case 12:        /*DLT_C_HDLC*/
+               v = DLT_CHDLC;
+               break;
        }
 #endif
        p->linktype = v;
@@ -253,7 +270,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
 int
 pcap_setfilter(pcap_t *p, struct bpf_program *fp)
 {
-       if (p->sf.rfile != NULL)
+       /*
+        * It looks that BPF code generated by gen_protochain() is not
+        * compatible with some of kernel BPF code (for example BSD/OS 3.1).
+        * Take a safer side for now.
+        */
+       if (no_optimize)
+               p->fcode = *fp;
+       else if (p->sf.rfile != NULL)
                p->fcode = *fp;
        else if (ioctl(p->fd, BIOCSETF, (caddr_t)fp) < 0) {
                sprintf(p->errbuf, "BIOCSETF: %s", pcap_strerror(errno));
index c5a23d98ea1b4aa6bd729b521f11dcd60718d514..6f55160d7fbd67e3d19fccdf0d344649fc65a49c 100644 (file)
@@ -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-int.h,v 1.18 1999-10-07 23:46:40 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.19 1999-10-19 15:18:30 itojun Exp $ (LBL)
  */
 
 #ifndef pcap_int_h
@@ -108,7 +108,7 @@ 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)
+#if defined(ultrix) || defined(__alpha) || defined(__NetBSD__)
 #define       PCAP_FDDIPAD 3
 #endif
 
index f57c6a27a2f79aedf029b1bbd58ba760c04eafee..d08a69bd7ae9c11974fb2745d7335f676905deb2 100644 (file)
@@ -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-namedb.h,v 1.5 1999-10-07 23:46:40 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap-namedb.h,v 1.6 1999-10-19 15:18:31 itojun Exp $ (LBL)
  */
 
 #ifndef lib_pcap_ethers_h
@@ -54,7 +54,11 @@ 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 *);
diff --git a/ppp.h b/ppp.h
index c932b1e6e522607b11c7628b4cbac972740c8fb0..4353b791fbd22c156a2af5eb9da9c3705cfa2437 100644 (file)
--- a/ppp.h
+++ b/ppp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/libpcap/ppp.h,v 1.7 1999-10-07 23:46:40 mcr Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/libpcap/ppp.h,v 1.8 1999-10-19 15:18:31 itojun Exp $ (LBL) */
 /*
  * Point to Point Protocol (PPP) RFC1331
  *
@@ -30,6 +30,7 @@
 #define PPP_BRPDU      0x0031  /* Bridging PDU */
 #define PPP_STII       0x0033  /* Stream Protocol (ST-II) */
 #define PPP_VINES      0x0035  /* Banyan Vines */
+#define PPP_IPV6       0x0057  /* Internet Protocol version 6 */
 
 #define PPP_HELLO      0x0201  /* 802.1d Hello Packets */
 #define PPP_LUXCOM     0x0231  /* Luxcom */
@@ -43,6 +44,7 @@
 #define PPP_IPXCP      0x802b  /* Novell IPX Control Protocol */
 #define PPP_STIICP     0x8033  /* Strean Protocol Control Protocol */
 #define PPP_VINESCP    0x8035  /* Banyan Vines Control Protocol */
+#define PPP_IPV6CP     0x8057  /* IPv6 Control Protocol */
 
 #define PPP_LCP                0xc021  /* Link Control Protocol */
 #define PPP_PAP                0xc023  /* Password Authentication Protocol */
index a556aee374cdba26674f7cc4f47edc2df2487842..da95a76a6be147dad960beefba773e6247de4666 100644 (file)
--- a/scanner.l
+++ b/scanner.l
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.56 1999-10-07 23:46:40 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.57 1999-10-19 15:18:31 itojun Exp $ (LBL)";
 #endif
 
 #include <sys/types.h>
@@ -30,11 +30,16 @@ 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"
@@ -76,6 +81,7 @@ 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 3000
 
@@ -93,6 +99,12 @@ 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;
@@ -106,6 +118,7 @@ net         return NET;
 mask           return MASK;
 port           return PORT;
 proto          return PROTO;
+protochain     return PROTOCHAIN;
 
 gateway                return GATEWAY;
 
@@ -136,6 +149,21 @@ 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; }
+[0-9a-zA-Z:]*:[0-9a-zA-Z:]*(:{N}\.{N}\.{N}\.{N})?      {
+#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; }