--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./GNUmakefile	Sat Feb 21 15:59:22 1998
@@ -0,0 +1,24 @@
+# %%% copyright-cmetz-97
+# This software is Copyright 1997-1998 by Craig Metz, All Rights Reserved.
+# The Inner Net License Version 2 applies to this software.
+# You should have received a copy of the license with this software. If
+# you didn't get a copy, you may request one from <license@inner.net>.
+#
+
+ifndef CONFIG_DIR
+CONFIG_DIR=/usr/inet6/lib/
+endif
+
+include $(CONFIG_DIR)GNUmakefile.inc
+
+CFLAGS+=$(DINET6) $(DIPSEC)
+
+all install:
+	if [ ! -f Makefile.autoconf ]; then sh ./configure --prefix=$(DESTDIR) --sbindir=$(DESTDIR)$(USR_SBINDIR); fi
+	$(MAKE) -f Makefile.autoconf XCFLAGS="$(CFLAGS)" XLIBS="$(LOADLIBES)" $@
+
+clean:
+	if [ -f Makefile.autoconf ]; then $(MAKE) -f Makefile.autoconf $@; fi
+
+realclean:
+	if [ -f Makefile.autoconf ]; then $(MAKE) -f Makefile.autoconf distclean; fi
--- Makefile.in	Thu Jan  8 22:16:42 1998
+++ Makefile.in	Sat Feb 21 15:59:22 1998
@@ -1,3 +1,8 @@
+#
+# This file has been slightly modified by NRL for use with IPv6+IPsec.
+# Search for INET6 and/or IPSEC to see the blocks where this happened.
+# See the NRL Copyright notice for conditions on the modifications.
+#
 #  Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
 # 	The Regents of the University of California.  All rights reserved.
 #
@@ -46,13 +51,13 @@
 DEFS = @DEFS@ -DHAVE_FDDI
 
 # Standard CFLAGS
-CFLAGS = $(CCOPT) $(DEFS) $(INCLS)
+CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(XCFLAGS)
 
 # Standard LDFLAGS
 LDFLAGS = @LDFLAGS@
 
 # Standard LIBS
-LIBS = @LIBS@
+LIBS = @LIBS@ $(XLIBS)
 
 INSTALL = @INSTALL@
 
@@ -72,7 +77,8 @@
 	print-pim.c print-ppp.c print-raw.c print-rip.c print-sl.c \
 	print-snmp.c print-sunrpc.c print-tcp.c print-tftp.c print-udp.c \
 	print-wb.c addrtoname.c bpf_dump.c gmt2local.c machdep.c \
-	parsenfsfh.c util.c savestr.c setsignal.c
+	parsenfsfh.c util.c savestr.c setsignal.c \
+	print-ipv6.c print-icmpv6.c print-smb.c smbutil.c
 LOCALSRC =
 GENSRC = version.c
 
@@ -129,7 +135,7 @@
 	rm -f $(CLEANFILES)
 
 distclean:
-	rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
+	rm -f $(CLEANFILES) Makefile.autoconf config.cache config.log config.status \
 	    gnuc.h os-proto.h
 
 tags: $(TAGFILES)
--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./README.ipv6	Sat Feb 21 15:59:22 1998
@@ -0,0 +1,31 @@
+IPv6 Support Patch for tcpdump-3.4a6
+====================================
+
+  This program has been modified to support IPv6. Please see the notices on
+individual files for the copyrights and licenses that apply to the changes.
+This package REQUIRES that the inet6-apps package be installed first. That
+package also contains more documentation and the actual license notices
+referenced in the copyright notice.
+
+History
+=======
+
+1	Initial release. Fixed realclean target. Made AH and ESP printing work
+	again (if NETSEC is enabled). Removed BSD makefile.
+
+Pre-History
+===========
+
+tcpdump-3.4a5
+
+1	Initial release. Updated and merged in ANK's patches. Some API mods.
+
+tcpdump-3.4a4
+
+1	Initial release.
+
+tcpdump-3.3.1a2
+
+2       Updated makefile.
+1       Initial release independent of inet6-apps.
+
--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./README.smb	Sat Feb 21 15:59:22 1998
@@ -0,0 +1,48 @@
+This is set of patches to tcpdump-3.2.1 that gives it the ability to
+interpret NBT and SMB packets in a fair bit of detail.
+
+Please send any feedback to Andrew.Tridgell@anu.edu.au
+
+Usage:
+
+To capture all SMB packets going to or from host "fred" try this:
+
+tcpdump -i eth0 -s 1500 port 139 host fred
+
+If you want name resolution or browse packets then try ports 137 and
+138 respectively.
+
+change log:
+	0.2: added name server and browse stuff
+	0.3: added IPX and Netbeui support	
+
+Example Output:
+
+Here is a sample of a capture of a "SMBsearch" directory search. If
+you don't get output that looks like this then you have patched
+tcpdump incorrectly.
+
+NBT Session Packet
+Flags=0x0
+Length=57
+
+SMB PACKET: SMBsearch (REQUEST)
+SMB Command   =  0x81
+Error class   =  0x0
+Error code    =  0
+Flags1        =  0x8
+Flags2        =  0x3
+Tree ID       =  2048
+Proc ID       =  11787
+UID           =  2048
+MID           =  11887
+Word Count    =  2
+smbvwv[]=
+Count=98
+Attrib=HIDDEN SYSTEM DIR 
+smbbuf[]=
+Path=\????????.???
+BlkType=0x5
+BlkLen=0
+
+
--- addrtoname.c	Sun Jun 15 16:20:07 1997
+++ addrtoname.c	Sat Feb 21 15:59:22 1998
@@ -1,4 +1,18 @@
 /*
+%%% portions-copyright-cmetz-97
+Portions of this software are Copyright 1997-1998 by Craig Metz, All Rights
+Reserved. The Inner Net License Version 2 applies to these portions of
+the software.
+You should have received a copy of the license with this software. If
+you didn't get a copy, you may request one from <license@inner.net>.
+
+*/
+/*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -57,6 +71,10 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#ifdef INET6
+#include "support.h"
+#endif /* INET6 */
+
 #include "interface.h"
 #include "addrtoname.h"
 #include "llc.h"
@@ -78,6 +96,16 @@
 	struct hnamemem *nxt;
 };
 
+#ifdef INET6
+struct hnamemem6 {
+	struct in6_addr addr;
+	char *name;
+	struct hnamemem6 *nxt;
+};
+
+struct hnamemem6 hname6table[HASHNAMESIZE];
+#endif /* INET6 */
+
 struct hnamemem hnametable[HASHNAMESIZE];
 struct hnamemem tporttable[HASHNAMESIZE];
 struct hnamemem uporttable[HASHNAMESIZE];
@@ -248,6 +276,76 @@
 	p->name = savestr(intoa(addr));
 	return (p->name);
 }
+
+#ifdef INET6
+struct hnamemem6 *
+newhnamemem6()
+{
+	register struct hnamemem6 *p;
+	static struct hnamemem6 *ptr = NULL;
+	static u_int num = 0;
+
+	if (num <= 0) {
+		num = 64;
+		ptr = (struct hnamemem6 *)calloc(num, sizeof (*ptr));
+		if (ptr == NULL)
+			error("newhnamemem: calloc");
+	}
+	--num;
+	p = ptr++;
+	return (p);
+}
+
+char *
+ipv6addr_string(const struct in6_addr *ap)
+{
+  static char buffer[64];
+  struct hnamemem6 *p;
+
+  if ((unsigned)ap & 3) {
+    static struct in6_addr i;
+    memcpy(&i, ap, sizeof(struct in6_addr));
+    ap = &i;
+  }
+
+  {
+    u_int32_t *a = (u_int32_t *)ap;
+
+    p = &hname6table[(a[0] ^ a[1] ^ a[2] ^ a[3]) & (HASHNAMESIZE-1)];
+    for (; p->nxt; p = p->nxt) {
+      if (!memcmp(&(p->addr), ap, sizeof(struct in6_addr)))
+	return (p->name);
+    }
+    memcpy(&p->addr, ap, sizeof(struct in6_addr));
+    p->nxt = newhnamemem6();
+  }
+
+  {
+    struct sockaddr_in6 sin6;
+
+    memset(&sin6, 0, sizeof(struct sockaddr_in6));
+#ifdef SIN6_LEN
+    sin6.sin6_len = sizeof(struct sockaddr_in6);
+#endif /* SIN6_LEN */
+    sin6.sin6_family = AF_INET6;
+    memcpy(&sin6.sin6_addr, ap, sizeof(struct in6_addr));
+
+    if (getnameinfo((struct sockaddr *)&sin6, sizeof(struct sockaddr_in6), buffer, sizeof(buffer), NULL, 0, nflag ? NI_NUMERICHOST : 0)) {
+      fprintf(stderr, "tcpdump: getnameinfo failed\n");
+      return p->name = "???";
+    }
+
+    if (Nflag) {
+      char *c;
+
+      if (c = strchr(buffer, '.'))
+        *c = 0;
+    }
+
+    return (p->name = strdup(buffer));
+  }
+}
+#endif /* INET6 */
 
 static char hex[] = "0123456789abcdef";
 
--- config.guess	Fri Nov 29 17:38:35 1996
+++ config.guess	Sat Feb 21 15:59:23 1998
@@ -407,26 +407,26 @@
 	# first see if it will tell us.
 	ld_help_string=`ld --help 2>&1`
 	if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then
-	  echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0
+	  echo "${UNAME_MACHINE}-pc-linux" ; exit 0
 	elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then
-	  echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0
+	  echo "${UNAME_MACHINE}-pc-linux-aout" ; exit 0
 	elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then
-	  echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0
+	  echo "${UNAME_MACHINE}-pc-linux-coff" ; exit 0
 	elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then
-	  echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0
+	  echo "${UNAME_MACHINE}-unknown-linux" ; exit 0
 	elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then
-	  echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0
+	  echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0
 	elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then
-	  echo "powerpc-unknown-linux-gnu" ; exit 0
+	  echo "powerpc-unknown-linux" ; exit 0
 	elif test "${UNAME_MACHINE}" = "alpha" ; then
-	  echo alpha-unknown-linux-gnu ; exit 0
+	  echo alpha-unknown-linux ; exit 0
 	elif test "${UNAME_MACHINE}" = "sparc" ; then
-	  echo sparc-unknown-linux-gnu ; exit 0
+	  echo sparc-unknown-linux ; exit 0
 	else
-	  # Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us
-	  # useful --help.  Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout.
+	  # Either a pre-BFD a.out linker (linux-oldld) or one that does not give us
+	  # useful --help.  Gcc wants to distinguish between linux-oldld and linux-aout.
 	  test ! -d /usr/lib/ldscripts/. \
-	    && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+	    && echo "${UNAME_MACHINE}-pc-linux-oldld" && exit 0
 	  # Determine whether the default compiler is a.out or elf
 	  cat >dummy.c <<EOF
 main(argc, argv)
@@ -434,9 +434,9 @@
 char *argv[];
 {
 #ifdef __ELF__
-  printf ("%s-pc-linux-gnu\n", argv[1]);
+  printf ("%s-pc-linux\n", argv[1]);
 #else
-  printf ("%s-pc-linux-gnuaout\n", argv[1]);
+  printf ("%s-pc-linux-aout\n", argv[1]);
 #endif
   return 0;
 }
--- config.sub	Fri Nov 29 17:38:36 1996
+++ config.sub	Sat Feb 21 15:59:23 1998
@@ -68,7 +68,7 @@
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  linux-gnu*)
+  linux*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -671,9 +671,6 @@
 	-unixware* | svr4*)
 		os=-sysv4
 		;;
-	-gnu/linux*)
-		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
-		;;
 	# First accept the basic system types.
 	# The portable systems comes first.
 	# Each alternative MUST END IN A *, to match a version number.
@@ -689,11 +686,8 @@
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -linux-gnu* | -uxpv*)
+	      | -linux* | -uxpv*)
 	# Remember, each alternative MUST END IN *, to match a version number.
-		;;
-	-linux*)
-		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 		;;
 	-sunos5*)
 		os=`echo $os | sed -e 's|sunos5|solaris2|'`
--- configure	Fri Jan 30 21:44:42 1998
+++ configure	Sat Feb 21 15:59:23 1998
@@ -2830,7 +2830,7 @@
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "Makefile.autoconf:Makefile.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -2926,7 +2926,7 @@
 
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+CONFIG_FILES=\${CONFIG_FILES-"Makefile.autoconf:Makefile.in"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
--- configure.in	Mon Jul 28 01:17:39 1997
+++ configure.in	Sat Feb 21 15:59:24 1998
@@ -1,4 +1,10 @@
 dnl @(#) $Header: /cvs/gnome/gxsnmp/tools/tcpdump-3.4a6+ipv6-1.diff,v 1.1 1998/09/08 21:57:15 jochen Exp $ (LBL)
+dnl
+dnl This file has been slightly modified by NRL for use with IPv6+IPsec.
+dnl Search for INET6 and/or IPSEC to see the blocks where this happened.
+dnl See the NRL Copyright notice for conditions on the modifications.
+dnl
+
 dnl
 dnl Copyright (c) 1994, 1995, 1996, 1997
 dnl	The Regents of the University of California.  All rights reserved.
@@ -188,7 +194,7 @@
 
 AC_PROG_INSTALL
 
-AC_OUTPUT(Makefile)
+AC_OUTPUT(Makefile.autoconf:Makefile.in)
 
 if test -f .devel ; then
 	make depend
--- interface.h	Wed May 28 15:54:25 1997
+++ interface.h	Sat Feb 21 15:59:24 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -34,6 +39,7 @@
 	char *s;		/* string */
 };
 
+extern int Aflag;		/* print packet in ASCII */
 extern int aflag;		/* translate network and broadcast addresses */
 extern int dflag;		/* print filter code */
 extern int eflag;		/* print ethernet header */
@@ -66,7 +72,11 @@
  * In particular, it allows for an ethernet header, tcp/ip header, and
  * 14 bytes of data (assuming no ip options).
  */
+#if INET6
+#define DEFAULT_SNAPLEN 1576
+#else /* INET6 */
 #define DEFAULT_SNAPLEN 68
+#endif /* INET6 */
 
 #ifndef BIG_ENDIAN
 #define BIG_ENDIAN 4321
--- print-ether.c	Mon May 26 20:18:40 1997
+++ print-ether.c	Sat Feb 21 15:59:24 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -138,6 +143,8 @@
 	}
 	if (xflag)
 		default_print(p, caplen);
+	if (Aflag)
+	        ascii_print(p, caplen);
  out:
 	putchar('\n');
 }
@@ -166,6 +173,15 @@
 		ip_print(p, length);
 		return (1);
 
+
+#ifdef INET6
+#ifndef ETHERTYPE_IPV6
+#define ETHERTYPE_IPV6 0x86dd
+#endif /* ETHERTYPE_IPV6 */
+	case ETHERTYPE_IPV6:
+		ipv6_print(p, length);
+		return 1;
+#endif /* INET6 */
 	case ETHERTYPE_ARP:
 	case ETHERTYPE_REVARP:
 		arp_print(p, length, caplen);
--- print-fddi.c	Mon May 26 20:13:24 1997
+++ print-fddi.c	Sat Feb 21 15:59:25 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -332,6 +337,8 @@
 	}
 	if (xflag)
 		default_print(p, caplen);
+	if (Aflag)
+	        ascii_print(p, caplen);
 out:
 	putchar('\n');
 }
--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./print-icmpv6.c	Sat Feb 21 15:59:25 1998
@@ -0,0 +1,375 @@
+/*
+%%% portions-copyright-cmetz-98
+Portions of this software are Copyright 1998 by Craig Metz, All Rights
+Reserved. The Inner Net License Version 2 applies to these portions of
+the software.
+You should have received a copy of the license with this software. If
+you didn't get a copy, you may request one from <license@inner.net>.
+
+*/
+/*
+ * print-icmpv6.c  --  Display ICMPv6 data.
+ * 
+ * Originally from 4.4-Lite BSD.  Modifications to support IPv6 and IPsec
+ * are copyright 1995 by Ken Chin, Bao Phan, Randall Atkinson, & Dan McDonald,
+ * All Rights Reserved.  All Rights under this copyright are assigned to NRL.
+ ----------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------
+#	@(#)COPYRIGHT	1.1 (NRL) 17 January 1995
+
+COPYRIGHT NOTICE
+
+All of the documentation and software included in this software
+distribution from the US Naval Research Laboratory (NRL) are
+copyrighted by their respective developers.
+
+Portions of the software are derived from the Net/2 and 4.4 Berkeley
+Software Distributions (BSD) of the University of California at
+Berkeley and those portions are copyright by The Regents of the
+University of California. All Rights Reserved.  The UC Berkeley
+Copyright and License agreement is binding on those portions of the
+software.  In all cases, the NRL developers have retained the original
+UC Berkeley copyright and license notices in the respective files in
+accordance with the UC Berkeley copyrights and license.
+
+Portions of this software and documentation were developed at NRL by
+various people.  Those developers have each copyrighted the portions
+that they developed at NRL and have assigned All Rights for those
+portions to NRL.  Outside the USA, NRL has copyright on some of the
+software developed at NRL. The affected files all contain specific
+copyright notices and those notices must be retained in any derived
+work.
+
+NRL LICENSE
+
+NRL grants permission for redistribution and use in source and binary
+forms, with or without modification, of the software and documentation
+created at NRL provided that the following conditions are met:
+
+1. All terms of the UC Berkeley copyright and license must be followed.
+2. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+3. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+4. All advertising materials mentioning features or use of this software
+   must display the following acknowledgements:
+
+	This product includes software developed by the University of
+	California, Berkeley and its contributors.
+
+	This product includes software developed at the Information
+	Technology Division, US Naval Research Laboratory.
+
+5. Neither the name of the NRL nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL AND CONTRIBUTORS ``AS
+IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL NRL OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation
+are those of the authors and should not be interpreted as representing
+official policies, either expressed or implied, of the US Naval
+Research Laboratory (NRL).
+
+----------------------------------------------------------------------*/
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <sys/param.h>
+
+#if INET6
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcpip.h>
+
+#include <netinet/ipv6.h>
+#include <netinet/icmpv6.h>
+#include <netinet/nd6_protocol.h>
+
+#include <stdio.h>
+
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+char *ipv6addr_string(struct in6_addr *);
+
+struct nbr_ad {
+  uint8_t type;
+  uint8_t code;
+  uint16_t chksum;
+  uint32_t flags;
+  struct in6_addr targ_addr;
+};
+
+struct nbr_sol
+{
+  uint8_t type;
+  uint8_t code;
+  uint16_t cksum;
+  uint32_t reserved;
+  struct in6_addr target;
+};
+
+struct na_opt {
+  uint8_t type;
+  uint8_t length;
+  uint8_t data[6];
+};
+		
+void na_opt_print(struct na_opt *na, char *s)
+{
+	char *addr;
+	int i;
+	char buf[256];
+
+	switch(na->type)  {
+	case 1:
+		s = strcat(s, " src[");		
+		break;
+	case 2:
+		s = strcat(s, " target[");
+		break;
+	}
+	for (i=0; i< (na->length * 8)-2; i++) {
+		sprintf(buf,"%x", na->data[i]);
+		if ( i == (na->length*8)-3 )  { 
+			s = strcat(s,(char *)buf);
+			s = strcat(s, "]");
+		}  else  {
+			s = strcat(s,(char*)buf);
+			s = strcat(s,":");
+		}
+	}
+}
+
+void
+icmpv6_print(register const u_char *bp, int length)
+{
+	register const struct icmpv6hdr *icmpv6;
+	register char *str;
+	register const struct ipv6 *oip;
+	register const struct uicmpv6hdr *ouh;
+	char buf[256];
+	char src[80];
+	char dst[80];
+	char *cp;
+	struct nbr_ad *na;
+	struct nbr_sol *ns;
+	struct na_opt *opt;
+	char *targ_addr;
+	int na_len, left;
+
+	icmpv6 = (struct icmpv6hdr *)bp;
+	left = (u_int)snapend - (u_int)bp;
+
+	str = buf;
+	*str = '\0';
+
+	if (left < sizeof(struct icmpv6hdr))
+	  goto trunc;
+
+	switch (icmpv6->icmpv6_type) {
+	case ICMPV6_ECHO_REPLY:
+		str = "echo reply";
+		break;
+	case ICMPV6_DST_UNREACH:
+		switch (icmpv6->icmpv6_code) {
+		case ICMPV6_UNREACH_NOROUTE:
+			str = "no route";
+			break;
+		case ICMPV6_UNREACH_ADMIN:
+			str = "admin prohibited";
+			break;
+		case ICMPV6_UNREACH_NOTNEIGHBOR:
+			str ="not a neighbor";
+			break;
+		case ICMPV6_UNREACH_ADDRESS:
+			str = "host unreachable";
+ 			break;
+/*		case ICMPV6_UNREACH_PROTOCOL:
+			str = "protocol unreachable";
+			break;*/
+		case ICMPV6_UNREACH_PORT:
+			str = "port unreachable";
+			break;
+		}
+		break;
+	case ICMPV6_PACKET_TOOBIG:
+		sprintf(str, "packet too big: mtu[%d]", ntohl(icmpv6->icmpv6_mtu));
+		break;
+	case ICMPV6_ECHO_REQUEST:
+		str = "echo request";
+		break;
+	case ICMPV6_MEMBERSHIP_QUERY:
+		str = "query group membership";
+		break;
+	case ICMPV6_MEMBERSHIP_REPORT:
+		str = "join mcast group";
+		break;
+	case ICMPV6_MEMBERSHIP_REDUCTION:
+		str = "leave mcast group";
+		break;
+	case ICMPV6_TIME_EXCEEDED:
+		switch (icmpv6->icmpv6_code) {
+		case ICMPV6_EXCEEDED_HOPS:
+			str = "hop limit exceeded";
+			break;
+		case ICMPV6_EXCEEDED_REASSEMBLY:
+			str = "reassembly time exceeded";
+			break;
+		}
+		break;
+	case ICMPV6_PARAMETER_PROBLEM:
+		switch(icmpv6->icmpv6_code) {
+		case ICMPV6_PARAMPROB_HDR:
+		  strcpy(str, "bad header field");
+		  break;
+		case ICMPV6_PARAMPROB_NEXTHDR:
+		  strcpy(str,"bad next header");
+		  break;
+		case ICMPV6_PARAMPROB_OPTION:
+		  strcpy(str,"unrec. option");
+		  break;
+		}
+		sprintf(str+strlen(str), " ptr[%x]", icmpv6->icmpv6_pptr);
+		break;
+#ifndef ICMPV6_ROUTER_SOLICITATION
+#define ICMPV6_ROUTER_SOLICITATION ND6_ROUTER_SOLICITATION
+#endif /* ICMPV6_ROUTER_SOLICITATION */
+	case ICMPV6_ROUTER_SOLICITATION:
+		str = "router solicit";
+		break;
+#ifndef ICMPV6_ROUTER_ADVERTISEMENT
+#define ICMPV6_ROUTER_ADVERTISEMENT ND6_ROUTER_ADVERTISEMENT
+#endif /* ICMPV6_ROUTER_ADVERTISEMENT */
+	case ICMPV6_ROUTER_ADVERTISEMENT:
+		str = "router ad";
+		break;
+#ifndef ICMPV6_NEIGHBOR_SOLICITATION
+#define ICMPV6_NEIGHBOR_SOLICITATION ND6_NEIGHBOR_SOLICITATION
+#endif /* ICMPV6_NEIGHBOR_SOLICITATION */
+	case ICMPV6_NEIGHBOR_SOLICITATION:
+		if (left < sizeof(struct nbr_sol))
+		  goto trunc;
+                str = strcat(str, "neigh sol ");
+		ns = (struct nbr_sol *)bp;
+                na_len = sizeof (struct nbr_sol);
+		if (vflag)
+		  {
+		    str = strcat(str, "for ");
+                    str = strcat(str, ipv6addr_string(&(ns->target)));
+		  }
+                ns++;   
+                cp = (char *)ns;
+                opt = (struct na_opt *)ns;
+		if (vflag)
+		  while (((na_len + opt->length * 8) <= left) && opt->length) {
+                        na_opt_print((struct na_opt *)opt, str);
+                        cp += opt->length;
+                        na_len += (opt->length * 8);
+                        opt = (struct na_opt *)cp;
+		      }
+		break;
+#ifndef ICMPV6_NEIGHBOR_ADVERTISEMENT
+#define ICMPV6_NEIGHBOR_ADVERTISEMENT ND6_NEIGHBOR_ADVERTISEMENT
+#endif /* ICMPV6_NEIGHBOR_ADVERTISEMENT */
+	case ICMPV6_NEIGHBOR_ADVERTISEMENT:
+		if (left < sizeof(struct nbr_ad))
+		  goto trunc;
+		str = strcat(str, "neigh adv ");
+		na = (struct nbr_ad *)bp;
+		na_len = sizeof (struct nbr_ad);
+		str = strcat(str, "(");
+		/*
+		 * Flags are in network order, but so are bitmasks.
+		 */
+		if (na->flags & ND6_NADVERFLAG_ISROUTER)
+		  str = strcat(str, "R");
+		if (na->flags & ND6_NADVERFLAG_SOLICITED)
+		  str = strcat(str, "S");
+		if (na->flags & ND6_NADVERFLAG_OVERRIDE)
+		  str = strcat(str, "O");
+#if 0
+		if (na->flags & ICMPV6_NEIGHBORADV_RTR)
+		  str = strcat(str, "R");
+		if (na->flags & ICMPV6_NEIGHBORADV_SOL)
+		  str = strcat(str, "S");
+		if (na->flags & ICMPV6_NEIGHBORADV_OVERRIDE)
+		  str = strcat(str, "O");
+		if (na->flags & ICMPV6_NEIGHBORADV_SECOND)
+		  str = strcat(str, "N");
+#endif /* 0 */
+		str = strcat(str, ") ");
+		if (vflag)  {
+		  str = strcat(str, "for ");
+                  str = strcat(str, ipv6addr_string(&(na->targ_addr)));
+		}
+		na++;
+		cp = (char *)na; 
+		opt = (struct na_opt *)na;
+		if (vflag)
+		while (((na_len + opt->length*8) <= left) && opt->length)  {
+			na_opt_print((struct na_opt *)opt, str);
+			cp += opt->length;
+			na_len += (opt->length * 8);
+			opt = (struct na_opt *)cp;
+		}
+		break;
+	default:
+		(void)sprintf(buf, "type#%d", icmpv6->icmpv6_type);
+		break;
+	}
+        (void)printf("icmpv6: %s", str);
+	return;
+trunc:
+	fputs("[|icmpv6]", stdout);
+#undef TCHECK
+}
+
+#endif /* INET6 */
--- print-ip.c	Wed May 28 15:51:25 1997
+++ print-ip.c	Sat Feb 21 15:59:25 1998
@@ -1,4 +1,14 @@
 /*
+%%% portions-copyright-cmetz-98
+
+*/
+
+/*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -49,7 +59,6 @@
 #include "interface.h"
 #include "extract.h"			/* must come after interface.h */
 
-/* Compatibility */
 #ifndef	IPPROTO_ND
 #define	IPPROTO_ND	77
 #endif
@@ -122,6 +131,16 @@
 #define TR_PROTO_PIM	3
 #define TR_PROTO_CBT	4
 
+#if NETSEC
+struct __ipsec_ah
+{
+  uint8_t ah_nexthdr;
+  uint8_t ah_datalen;
+  uint16_t ah_reserved;
+  uint32_t ah_spi; 
+};
+#endif /* NETSEC */
+
 static void print_mtrace(register const u_char *bp, register u_int len)
 {
 	register struct tr_query *tr = (struct tr_query *)(bp + 8);
@@ -221,6 +240,20 @@
 	fputs("[|igmp]", stdout);
 }
 
+#if NETSEC
+void ah_print(const void *p)
+{
+  struct __ipsec_ah *ah = (struct __ipsec_ah *)p;
+
+  printf(" ah 0x%x dlen %d", ntohl(ah->ah_spi), ah->ah_datalen << 2);
+}
+
+void esp_print(const void *esp)
+{
+  printf(" esp 0x%x", ntohl(*(u_int32_t *)esp));
+}
+#endif /* NETSEC */
+
 /*
  * print the recorded route in an IP RR, LSRR or SSRR option.
  */
@@ -282,6 +315,9 @@
 			printf(" TS{%d}", len);
 			break;
 
+#ifndef IPOPT_SECURITY
+#define IPOPT_SECURITY 130
+#endif /* IPOPT_SECURITY */
 		case IPOPT_SECURITY:
 			printf(" SECURITY{%d}", len);
 			break;
@@ -339,6 +375,10 @@
 	register u_int hlen, len, off;
 	register const u_char *cp;
 
+#ifdef NETSEC
+	int chain = 0;
+	int p;
+#endif /* NETSEC */
 	ip = (const struct ip *)bp;
 #ifdef LBL_ALIGN
 	/*
@@ -389,7 +429,13 @@
 	off = ntohs(ip->ip_off);
 	if ((off & 0x1fff) == 0) {
 		cp = (const u_char *)ip + hlen;
-		switch (ip->ip_p) {
+#ifdef NETSEC
+		p = ip->ip_p;
+chain:
+		switch (p) {
+#else /* NETSEC */
+	        switch (ip->ip_p) {
+#endif /* NETSEC */
 
 		case IPPROTO_TCP:
 			tcp_print(cp, len, (const u_char *)ip);
@@ -400,6 +446,7 @@
 			break;
 
 		case IPPROTO_ICMP:
+
 			icmp_print(cp, (const u_char *)ip);
 			break;
 
@@ -463,6 +510,58 @@
   			}
   			break;
 
+#ifdef NETSEC
+#ifndef IPPROTO_ESP
+#define IPPROTO_ESP 50
+#endif /* IPPROTO_ESP */
+		case IPPROTO_ESP:
+			(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
+				ipaddr_string(&ip->ip_dst));
+                        if (len < sizeof(u_int32_t)) {
+                          printf(" esp (truncated)");
+			  break;
+                        }
+			esp_print(cp);
+			break;
+
+#ifndef IPPROTO_AH
+#define IPPROTO_AH 51
+#endif /* IPPROTO_AH */
+		case IPPROTO_AH:
+                        if (chain)
+                          break;
+			(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
+				ipaddr_string(&ip->ip_dst));
+                        if (len < sizeof(struct __ipsec_ah)) {
+                          printf(" ah (truncated)");
+			  break;
+                        }
+			ah_print(cp);
+			{
+                          struct __ipsec_ah *ah = (struct __ipsec_ah *)cp;
+			  int i = sizeof(__struct ipsec_ah) + (ah->ah_datalen << 2);
+			  len -= i;
+			  p = ah->ah_nexthdr;
+			  cp += i;
+			}
+			printf("\n                ");
+			chain = 1;
+			goto chain;
+#endif /* NETSEC */
+
+#ifdef INET6
+#ifndef IPPROTO_IPV6
+#define IPPROTO_IPV6 41
+#endif /* IPPROTO_IPV6 */
+		case IPPROTO_IPV6:
+			printf("%s > %s: v6-in-v4",
+				ipaddr_string(&ip->ip_src),
+				ipaddr_string(&ip->ip_dst));
+			printf("\n                ");
+			ipv6_print(cp, len);
+			break;
+#endif /* INET6 */
+
 		default:
 			(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
 				ipaddr_string(&ip->ip_dst));
@@ -483,9 +582,15 @@
 		if (off & 0x1fff)
 			(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
 				      ipaddr_string(&ip->ip_dst));
+#ifndef IP_MF
+#define IP_MF 0x2000
+#endif /* IP_MF */
 		(void)printf(" (frag %d:%d@%d%s)", ntohs(ip->ip_id), len,
 			(off & 0x1fff) * 8,
 			(off & IP_MF)? "+" : "");
+#ifndef IP_DF
+#define IP_DF 0x4000
+#endif /* IP_DF */
 	} else if (off & IP_DF)
 		(void)printf(" (DF)");
 
--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./print-ipv6.c	Sat Feb 21 15:59:25 1998
@@ -0,0 +1,382 @@
+/*
+%%% portions-copyright-cmetz-98
+Portions of this software are Copyright 1998 by Craig Metz, All Rights
+Reserved. The Inner Net License Version 2 applies to these portions of
+the software.
+You should have received a copy of the license with this software. If
+you didn't get a copy, you may request one from <license@inner.net>.
+
+*/
+
+/*
+ * print-ipv6.c  --  Prints IPv6 information for tcpdump.
+ *
+ * Originally from 4.4-Lite BSD.  Modifications to support IPv6 and IPsec
+ * are copyright 1995 by Ken Chin, Bao Phan, Randall Atkinson, & Dan McDonald,
+ * All Rights Reserved.  All Rights under this copyright are assigned to NRL.
+ ----------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------
+#	@(#)COPYRIGHT	1.1 (NRL) 17 January 1995
+
+COPYRIGHT NOTICE
+
+All of the documentation and software included in this software
+distribution from the US Naval Research Laboratory (NRL) are
+copyrighted by their respective developers.
+
+Portions of the software are derived from the Net/2 and 4.4 Berkeley
+Software Distributions (BSD) of the University of California at
+Berkeley and those portions are copyright by The Regents of the
+University of California. All Rights Reserved.  The UC Berkeley
+Copyright and License agreement is binding on those portions of the
+software.  In all cases, the NRL developers have retained the original
+UC Berkeley copyright and license notices in the respective files in
+accordance with the UC Berkeley copyrights and license.
+
+Portions of this software and documentation were developed at NRL by
+various people.  Those developers have each copyrighted the portions
+that they developed at NRL and have assigned All Rights for those
+portions to NRL.  Outside the USA, NRL has copyright on some of the
+software developed at NRL. The affected files all contain specific
+copyright notices and those notices must be retained in any derived
+work.
+
+NRL LICENSE
+
+NRL grants permission for redistribution and use in source and binary
+forms, with or without modification, of the software and documentation
+created at NRL provided that the following conditions are met:
+
+1. All terms of the UC Berkeley copyright and license must be followed.
+2. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+3. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+4. All advertising materials mentioning features or use of this software
+   must display the following acknowledgements:
+
+	This product includes software developed by the University of
+	California, Berkeley and its contributors.
+
+	This product includes software developed at the Information
+	Technology Division, US Naval Research Laboratory.
+
+5. Neither the name of the NRL nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL AND CONTRIBUTORS ``AS
+IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL NRL OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation
+are those of the authors and should not be interpreted as representing
+official policies, either expressed or implied, of the US Naval
+Research Laboratory (NRL).
+
+----------------------------------------------------------------------*/
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <sys/param.h>
+
+#if INET6
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcpip.h>
+
+#include <netdb.h>
+
+#include <netinet/ipv6.h>
+
+#include <stdio.h>
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
+#include <unistd.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+
+#if NETSEC
+void ah_print(void *);
+void esp_print(void *);
+#endif /* NETSEC */
+
+static void hop_print(const u_char * bp)
+{
+	printf(" hop");
+}
+
+struct __ipv6_fraghdr
+{
+  uint8_t frag_nextheader;
+  uint8_t frag_reserved;
+  uint16_t frag_bitsoffset;
+  uint32_t frag_id;
+};
+
+struct __ipv6_opthdr
+{
+  uint8_t oh_nextheader;
+  uint8_t oh_extlen;
+  uint8_t oh_data[6];
+};
+
+struct __ipv6_srcroute0
+{
+  uint8_t i6sr_nextheader;
+  uint8_t i6sr_numaddrs;
+  uint8_t i6sr_type;
+  uint8_t i6sr_left;
+  uint8_t i6sr_reserved;
+  uint8_t i6sr_mask[3];
+};
+
+#if NETSEC
+struct __ipsec_ah
+{
+  uint8_t ah_nexthdr;
+  uint8_t ah_datalen;
+  uint16_t ah_reserved;
+  uint32_t ah_spi; 
+};
+#endif /* NETSEC */
+
+static void frag_print(struct __ipv6_fraghdr *ip)
+{
+  uint16_t bitoffset;
+
+  printf(" frag[%d", ip->frag_reserved);
+  bitoffset = ntohs(ip->frag_bitsoffset);
+  printf(" %d", bitoffset & 0xfff8);
+  printf(" %d", bitoffset & 0x1);
+  printf(" %u] ", ntohl(ip->frag_id));
+}
+
+static void route_print(struct __ipv6_srcroute0 *ip)
+{
+	printf(" %d", ip->i6sr_type);
+	if (!&ip->i6sr_type)  {
+		printf(" %d", ip->i6sr_numaddrs);
+	}
+}
+
+static void dest_print(struct __ipv6_opthdr *ip)
+{
+	printf(" %d", ip->oh_extlen);
+}
+
+void ipv6_print (register const u_char *bp, register int length)
+{
+	char buf[80];
+	register const struct ipv6hdr *ip;
+	uint8_t nhdr;
+	int first = 1, len=0;
+	char *cp;
+	uint32_t p;	
+	struct hostent *name;
+
+	ip= (const struct ipv6hdr *) bp;
+	if (length < sizeof(struct ipv6hdr)){
+	  (void)printf("truncated-ipv6 %d", length);
+	  return;
+	}
+	
+	len = sizeof(struct ipv6hdr) + ntohs(ip->ipv6_len);
+
+	if (length < len)
+	  (void)printf("truncated-ipv6 - %d bytes missing!",
+		       len - length);
+
+	len = sizeof(struct ipv6hdr);
+
+        printf(" %s > %s ", ipv6addr_string(&(ip->ipv6_src)), 
+	       ipv6addr_string(&(ip->ipv6_dst)));
+
+	if (vflag) {
+	  printf(" (v%d,", ip->ipv6_version);                     /* version */
+	  printf(" priority %d,", (p&0x0f000000)>>24); /* priority */
+	  printf(" flow %d,", p&0x00ffffff);	       /* flow label */
+	  printf(" len %d,", ntohs(ip->ipv6_len));  /* payload length */
+	  printf(" hop %d) ", ip->ipv6_hoplimit);
+	}
+	
+	nhdr = ip->ipv6_nextheader;
+	cp = (char *)(ip + 1);
+
+	while ((nhdr!=IPPROTO_NONE)&&(nhdr!=IPPROTO_TCP)&&(nhdr!=IPPROTO_UDP)
+	       &&(nhdr!=IPPROTO_ICMPV6)&&(nhdr!=IPPROTO_IPV4)&&
+	       (nhdr!=IPPROTO_IPV6))
+		switch (nhdr) {
+
+		case IPPROTO_HOP:	/* hop by hop (0)*/
+			len += sizeof(ip);
+			if (len<snaplen)
+				hop_print(cp);
+			else
+				printf(" hop-hdr");
+			break;
+
+		case IPPROTO_ROUTING:	/* routing header (43)*/
+			len += sizeof(struct __ipv6_srcroute0 );
+			if ((len<snaplen)&&(vflag))
+				route_print((struct __ipv6_srcroute0 *)cp);
+			else
+				printf(" route-hdr");
+			nhdr = ((struct __ipv6_srcroute0 *)cp)->i6sr_nextheader;
+			break;
+
+		case IPPROTO_FRAGMENT:	/* fragment header (44)*/
+			len += sizeof(struct __ipv6_fraghdr);
+			if ((len<snaplen)&&(vflag))
+				frag_print((struct __ipv6_fraghdr *)cp);
+			else
+				printf(" frag ");
+			nhdr = ((struct __ipv6_fraghdr *)cp)->frag_nextheader;
+			printf("nhdr=");
+			switch (nhdr)  {
+			case IPPROTO_HOP:
+				printf("hop");
+				break;
+			case IPPROTO_IGMP:
+				printf("igmp");
+				break;
+			case IPPROTO_TCP:
+				printf("tcp");
+				break;
+			case IPPROTO_UDP:
+				printf("udp");
+				break;
+			case IPPROTO_IPV6:
+				printf("ipv6");
+				break;
+			case IPPROTO_ROUTING:
+				printf("routing");
+				break;
+			case IPPROTO_FRAGMENT:
+				printf("frag");
+				break;
+#if NETSEC
+			case IPPROTO_ESP:
+				printf("esp");
+				break;
+			case IPPROTO_AH:
+				printf("auth");
+				break;
+#endif /* NETSEC */
+			case IPPROTO_ICMPV6:
+				printf("icmpv6");
+				break;
+			case IPPROTO_NONE: 
+				printf("no next");
+				break;
+			case IPPROTO_DST:
+				printf("dest");
+				break;
+			default:
+				printf("%d", nhdr);
+			}
+			return;
+#if NETSEC
+		case IPPROTO_ESP:	/* encapsulation header (50)*/
+			len += sizeof(uint32_t);
+			if ((len<snaplen)&&(vflag)) {
+				esp_print((char *)cp);
+				printf(" ");
+			} else
+				printf(" esp");
+			return;
+
+		case IPPROTO_AH:	/* authentication header (51)*/
+			len += sizeof(struct __ipsec_ah) + sizeof(uint32_t) * ((struct __ipsec_ah *)cp)->ah_datalen;
+			if ((len<snaplen)&&(vflag)) {
+				ah_print((struct __ipsec_ah *)cp);
+				printf(" ");
+			} else
+				printf(" ah");
+			nhdr = ((struct __ipsec_ah *)cp)->ah_nexthdr;
+			cp += ((struct __ipsec_ah *)cp)->ah_datalen * sizeof(uint32_t) + sizeof(struct __ipsec_ah);
+			break;
+#endif /* NETSEC */
+
+		case IPPROTO_DST:	/* destination options header (60)*/
+			len += sizeof(struct __ipv6_opthdr);
+			if ((len<snaplen)&&(vflag))
+				dest_print((struct __ipv6_opthdr *)cp);
+			else
+				printf(" dest-hdr");
+			nhdr = ((struct __ipv6_opthdr *)cp)->oh_nextheader;
+			cp += sizeof(struct __ipv6_opthdr);
+			break;
+
+		default:
+			printf("unknown nexthdr %d", nhdr);
+			return;
+
+	      }
+	len = length - len;
+	switch (nhdr) {
+		case IPPROTO_TCP:
+			tcp_print(cp, len, (const u_char *)ip);
+                        break; 
+		case IPPROTO_UDP:
+			udp_print(cp, len, (const u_char *)ip);
+                        break; 
+		case IPPROTO_ICMPV6:
+			icmpv6_print(cp, len);
+                        break;
+	        case IPPROTO_IPV4:
+			printf(": v4-in-v6");
+			printf("\n                ");
+			ip_print(cp, len);
+			break;
+	        case IPPROTO_IPV6:
+			printf(": v6-in-v6");
+			printf("\n                ");
+			ipv6_print(cp, len);
+			break;
+		default:
+			printf("unknown transport protocol");
+			return;
+	}
+}
+#endif /* INET6 */
--- print-llc.c	Wed Jan  1 23:56:28 1997
+++ print-llc.c	Sat Feb 21 15:59:25 1998
@@ -79,10 +79,12 @@
 		ipx_print(p, length);
 		return (1);
 	}
-#ifdef notyet
-	else if (p[0] == 0xf0 && p[1] == 0xf0)
-		netbios_print(p, length);
-#endif
+	else if (p[0] == 0xf0 && p[1] == 0xf0) {
+	  /* we don't actually have a full netbeui parser yet, but the
+	     smb parser can handle many smb-in-netbeui packets, which
+	     is very useful, so we call that */
+	  netbeui_print(p+2,p+min(caplen,length));
+	}
 	if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
 	    && llc.llcui == LLC_UI) {
 		isoclns_print(p + 3, length - 3, caplen - 3, esrc, edst);
@@ -157,6 +159,13 @@
 			caplen -= 3;
 		    }
 		}
+
+		if (!strcmp(m,"ui") && f=='C') {
+		  /* we don't have a proper ipx decoder yet, but there
+                     is a partial one in the smb code */
+		  ipx_netbios_print(p,p+min(caplen,length));
+		}
+
 	} else {
 		char f;
 		llc.llcis = ntohs(llc.llcis);
@@ -185,8 +194,5 @@
 		caplen -= 4;
 	}
 	(void)printf(" len=%d", length);
-	if (caplen > 0) {
-		default_print_unaligned(p, caplen);
-	}
 	return(1);
 }
--- print-null.c	Wed May 28 15:52:28 1997
+++ print-null.c	Sat Feb 21 15:59:26 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -80,9 +85,17 @@
 		printf("ip: ");
 		break;
 
+#ifdef INET6
+	case AF_INET6:
+		printf("ipv6: ");
+		break;
+#endif /* INET6 */
+
+#ifdef AF_NS
 	case AF_NS:
 		printf("ns: ");
 		break;
+#endif /* AF_NS */
 
 	default:
 		printf("AF %d: ", family);
@@ -114,10 +127,23 @@
 	if (eflag)
 		null_print(p, ip, length);
 
-	ip_print((const u_char *)ip, length);
+	switch(ip->ip_v) {
+		case 4:
+			ip_print((const u_char *)ip, length);
+			break;
+#ifdef INET6
+		case 6:
+			ipv6_print((void *)ip, length);
+			break;
+#endif /* INET6 */
+	}
 
 	if (xflag)
 		default_print((const u_char *)ip, caplen - NULL_HDRLEN);
+
+	if (Aflag)
+		ascii_print((const u_char *)ip, caplen - NULL_HDRLEN);
+
 	putchar('\n');
 }
 
--- print-ppp.c	Thu Jun 12 17:21:15 1997
+++ print-ppp.c	Sat Feb 21 15:59:26 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -82,10 +87,19 @@
 
 	length -= PPP_HDRLEN;
 	ip = (struct ip *)(p + PPP_HDRLEN);
+#ifdef INET6
+	if (ip->ip_v==4) 
+	  ip_print((const u_char *)ip, length);
+        else  
+	  ipv6_print((const u_char *)ip, length);
+#else
 	ip_print((const u_char *)ip, length);
+#endif /* INET6 */
 
 	if (xflag)
 		default_print((const u_char *)ip, caplen - PPP_HDRLEN);
+	if (Aflag)
+	        ascii_print((const u_char *)ip, caplen - PPP_HDRLEN);
 out:
 	putchar('\n');
 }
--- print-sl.c	Thu Jun 12 17:21:16 1997
+++ print-sl.c	Sat Feb 21 15:59:26 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -104,10 +109,19 @@
 	if (eflag)
 		sliplink_print(p, ip, length);
 
+#ifdef INET6
+	if (ip->ip_v == 4)
+	  ip_print((u_char *)ip, length);
+	else 
+	  ipv6_print((u_char *)ip, length);
+#else
 	ip_print((u_char *)ip, length);
+#endif /* INET6 */
 
 	if (xflag)
 		default_print((u_char *)ip, caplen - SLIP_HDRLEN);
+	if (Aflag)
+	        ascii_print((u_char *)ip, caplen - SLIP_HDRLEN);
  out:
 	putchar('\n');
 }
--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./print-smb.c	Sat Feb 21 15:59:26 1998
@@ -0,0 +1,979 @@
+/* 
+   Copyright (C) Andrew Tridgell 1995
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "smb.h"
+
+static int request=0;
+
+uchar *startbuf=NULL;
+
+struct smbdescript
+{
+  char *req_f1;
+  char *req_f2;
+  char *rep_f1;
+  char *rep_f2;
+  void (*fn)();
+};
+
+struct smbfns
+{
+  int id;
+  char *name;
+  int flags;
+  struct smbdescript descript;
+};
+
+#define DEFDESCRIPT  {NULL,NULL,NULL,NULL,NULL}
+
+#define FLG_CHAIN (1<<0)
+
+static struct smbfns *smbfind(int id,struct smbfns *list)
+{
+  int sindex;
+
+  for (sindex=0;list[sindex].name;sindex++) 
+    if (list[sindex].id == id) return(&list[sindex]);
+
+  return(&list[0]);
+}
+
+static void trans2_findfirst(uchar *param,uchar *data,int pcnt,int dcnt)
+{
+  char *fmt;
+
+  if (request) {
+    fmt = "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP5]\nFile=[S]\n";
+  } else {
+    fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
+  }
+
+  fdata(param,fmt,param+pcnt);
+  if (dcnt) {
+    printf("data:\n");
+    print_data(data,dcnt);
+  }
+}
+
+static void trans2_qfsinfo(uchar *param,uchar *data,int pcnt,int dcnt)
+{
+  static int level=0;
+  char *fmt="";
+
+  if (request) {
+    level = SVAL(param,0);
+    fmt = "InfoLevel=[d]\n";
+    fdata(param,fmt,param+pcnt);
+  } else {
+    switch (level) {
+    case 1:
+      fmt = "idFileSystem=[W]\nSectorUnit=[D]\nUnit=[D]\nAvail=[D]\nSectorSize=[d]\n";
+      break;
+    case 2:
+      fmt = "CreationTime=[T2]VolNameLength=[B]\nVolumeLabel=[s12]\n";
+      break;
+    case 0x105:
+      fmt = "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[D]\nVolume=[S]\n";
+      break;
+    default:
+      fmt = "UnknownLevel\n";
+    }
+    fdata(data,fmt,data+dcnt);
+  }
+  if (dcnt) {
+    printf("data:\n");
+    print_data(data,dcnt);
+  }
+}
+
+struct smbfns trans2_fns[] = {
+{0,"TRANSACT2_OPEN",0,
+   {"Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w,w,w,w,w])\nPath=[S]",NULL,
+    "Handle=[d]\nAttrib=[A]\nTime=[T2]\nSize=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nInode=[W]\nOffErr=[d]\n|EALength=[d]\n",NULL,NULL}},
+
+{1,"TRANSACT2_FINDFIRST",0,
+   {NULL,NULL,NULL,NULL,trans2_findfirst}},
+
+{2,"TRANSACT2_FINDNEXT",0,DEFDESCRIPT},
+
+{3,"TRANSACT2_QFSINFO",0,
+   {NULL,NULL,NULL,NULL,trans2_qfsinfo}},
+
+{4,"TRANSACT2_SETFSINFO",0,DEFDESCRIPT},
+{5,"TRANSACT2_QPATHINFO",0,DEFDESCRIPT},
+{6,"TRANSACT2_SETPATHINFO",0,DEFDESCRIPT},
+{7,"TRANSACT2_QFILEINFO",0,DEFDESCRIPT},
+{8,"TRANSACT2_SETFILEINFO",0,DEFDESCRIPT},
+{9,"TRANSACT2_FSCTL",0,DEFDESCRIPT},
+{10,"TRANSACT2_IOCTL",0,DEFDESCRIPT},
+{11,"TRANSACT2_FINDNOTIFYFIRST",0,DEFDESCRIPT},
+{12,"TRANSACT2_FINDNOTIFYNEXT",0,DEFDESCRIPT},
+{13,"TRANSACT2_MKDIR",0,DEFDESCRIPT},
+{-1,NULL,0,DEFDESCRIPT}};
+
+
+static void print_trans2(uchar *words,uchar *dat,uchar *buf,uchar *maxbuf)
+{
+  static struct smbfns *fn = &trans2_fns[0];
+  uchar *data,*param;
+  uchar *f1=NULL,*f2=NULL;
+  int pcnt,dcnt;
+
+  if (request) {
+    fn = smbfind(SVAL(words+1,14*2),trans2_fns);
+    data = buf+SVAL(words+1,12*2);
+    param = buf+SVAL(words+1,10*2);
+    pcnt = SVAL(words+1,9*2);
+    dcnt = SVAL(words+1,11*2);
+  } else {
+    data = buf+SVAL(words+1,7*2);
+    param = buf+SVAL(words+1,4*2);
+    pcnt = SVAL(words+1,3*2);
+    dcnt = SVAL(words+1,6*2);
+  }
+
+  printf("%s param_length=%d data_length=%d\n",
+	 fn->name,pcnt,dcnt);
+
+  if (request) {
+    if (CVAL(words,0) == 8) {
+      fdata(words+1,"Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",maxbuf);
+      return;	    
+    } else {
+      fdata(words+1,"TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[d]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[d]\n",words+1+14*2);
+      fdata(data+1,"TransactionName=[S]\n%",maxbuf);
+    }
+    f1 = fn->descript.req_f1;
+    f2 = fn->descript.req_f2;
+  } else {
+    if (CVAL(words,0) == 0) {
+      printf("Trans2Interim\n");
+      return;
+    } else {
+      fdata(words+1,"TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[d]\n",words+1+10*2);
+    }
+    f1 = fn->descript.rep_f1;
+    f2 = fn->descript.rep_f2;
+  }
+
+  if (fn->descript.fn) {
+    fn->descript.fn(param,data,pcnt,dcnt);
+  } else {
+    fdata(param,f1?f1:(uchar*)"Paramaters=\n",param+pcnt);
+    fdata(data,f2?f2:(uchar*)"Data=\n",data+dcnt);      
+  }
+}
+
+
+static void print_browse(uchar *param,int paramlen,uchar *data,int datalen)
+{
+  uchar *maxbuf = data + datalen;
+  int command = CVAL(data,0);
+
+  fdata(param,"BROWSE PACKET\n|Param ",param+paramlen);
+
+  switch (command) {
+  case 0xF:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",maxbuf);
+    break;
+    
+  case 0x1:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",maxbuf);
+    break;
+    
+  case 0x2:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",maxbuf);
+    break;
+    
+  case 0xc:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",maxbuf);
+    break;
+
+  case 0x8:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W,W)]\nServerName=[S]\n",maxbuf);
+    break;
+    
+  case 0xb:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",maxbuf);
+    break;
+    
+  case 0x9:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken?=[B]\n",maxbuf);
+    break;
+    
+  case 0xa:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken?=[B]*Name=[S]\n",maxbuf);
+    break;
+    
+  case 0xd:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",maxbuf);
+    break;
+    
+  case 0xe:
+    data = fdata(data,"BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n",maxbuf);
+    break;
+    
+  default:
+    data = fdata(data,"Unknown Browser Frame ",maxbuf);
+    break;
+  }
+}
+
+
+static void print_ipc(uchar *param,int paramlen,uchar *data,int datalen)
+{
+  int command = SVAL(param,0);
+  if (paramlen)
+    fdata(param,"Command=[w]\nStr1=[S]\nStr2=[S]\n",param+paramlen);
+  if (datalen)
+    fdata(data,"IPC ",data+datalen);
+}
+
+
+static void print_trans(uchar *words,uchar *data1,uchar *buf,uchar *maxbuf)
+{
+  uchar *f1,*f2,*f3,*f4;
+  uchar *data,*param;
+  int datalen,paramlen;
+  int buflen = SVAL(data1,0);
+
+  if (request) {
+    paramlen = SVAL(words+1,9*2);
+    param = buf + SVAL(words+1,10*2);
+    datalen = SVAL(words+1,11*2);
+    data = buf + SVAL(words+1,12*2);
+    f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n";
+    f2 = "|Name=[S]\n";
+    f3 = "|Param ";
+    f4 = "|Data ";
+  } else {
+    paramlen = SVAL(words+1,3*2);
+    param = buf + SVAL(words+1,4*2);
+    datalen = SVAL(words+1,6*2);
+    data = buf + SVAL(words+1,7*2);
+    f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n";
+    f2 = "|Unknown ";
+    f3 = "|Param ";
+    f4 = "|Data ";
+  }
+
+  fdata(words+1,f1,MIN(words+1+2*CVAL(words,0),maxbuf));
+  fdata(data1+2,f2,maxbuf - (paramlen + datalen));
+
+  if (!strcmp(data1+2,"\\MAILSLOT\\BROWSE")) {
+    print_browse(param,paramlen,data,datalen);
+    return;
+  }
+
+  if (!strcmp(data1+2,"\\PIPE\\LANMAN")) {
+    print_ipc(param,paramlen,data,datalen);
+    return;
+  }
+
+  if (paramlen) fdata(param,f3,MIN(param+paramlen,maxbuf));
+  if (datalen) fdata(data,f4,MIN(data+datalen,maxbuf));
+}
+
+
+
+void print_negprot(uchar *words,uchar *data,uchar *buf,uchar *maxbuf)
+{
+  uchar *f1=NULL,*f2=NULL;
+
+  if (request) {
+    f2 = "*|Dialect=[Z]\n";
+  } else {
+    if (CVAL(words,0) == 1) {
+      f1 = "Core Protocol\nDialectIndex=[d]";
+    } else if (CVAL(words,0) == 17) {
+      f1 = "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey=";
+    } else if (CVAL(words,0) == 13) {
+      f1 = "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[d]\nSecMode=[w]\nMaxXMit=[d]\nMaxMux=[d]\nMaxVcs=[d]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[d]\nRes=[W]\nCryptKey=";
+    }
+  }
+
+  if (f1) 
+    fdata(words+1,f1,MIN(words + 1 + CVAL(words,0)*2,maxbuf));
+  else
+    print_data(words+1,MIN(CVAL(words,0)*2,PTR_DIFF(maxbuf,words+1)));
+  
+  if (f2) 
+    fdata(data+2,f2,MIN(data + 2 + SVAL(data,0),maxbuf));
+  else
+    print_data(data+2,MIN(SVAL(data,0),PTR_DIFF(maxbuf,data+2)));
+    
+}
+
+void print_sesssetup(uchar *words,uchar *data,uchar *buf,uchar *maxbuf)
+{
+  int wcnt = CVAL(words,0);
+  uchar *f1=NULL,*f2=NULL;
+
+  if (request) {
+    if (wcnt==10) {
+      f1 = "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n";
+    } else {
+      f1 = "Com2=[B]\nRes1=[B]\nOff2=[d]\nMaxBuffer=[d]\nMaxMpx=[d]\nVcNumber=[d]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[d]\nCaseSensitivePasswordLength=[d]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n";
+    }
+  } else {
+    if (CVAL(words,0) == 3) {
+      f1 = "Com2=[w]\nOff2=[d]\nAction=[w]\n";
+    } else if (CVAL(words,0) == 13) {
+      f1 = "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n";
+      f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n";
+    }
+  }
+
+  if (f1) 
+    fdata(words+1,f1,MIN(words + 1 + CVAL(words,0)*2,maxbuf));
+  else
+    print_data(words+1,MIN(CVAL(words,0)*2,PTR_DIFF(maxbuf,words+1)));
+  
+  if (f2) 
+    fdata(data+2,f2,MIN(data + 2 + SVAL(data,0),maxbuf));
+  else
+    print_data(data+2,MIN(SVAL(data,0),PTR_DIFF(maxbuf,data+2))); 
+}
+
+
+static struct smbfns smb_fns[] = 
+{
+{-1,"SMBunknown",0,DEFDESCRIPT},
+
+{SMBtcon,"SMBtcon",0,
+   {NULL,"Path=[Z]\nPassword=[Z]\nDevice=[Z]\n",
+    "MaxXmit=[d]\nTreeId=[d]\n",NULL,
+    NULL}},
+
+
+{SMBtdis,"SMBtdis",0,DEFDESCRIPT},
+{SMBexit,"SMBexit",0,DEFDESCRIPT},
+{SMBioctl,"SMBioctl",0,DEFDESCRIPT},
+
+{SMBecho,"SMBecho",0,
+   {"ReverbCount=[d]\n",NULL,
+    "SequenceNum=[d]\n",NULL,
+    NULL}},
+
+{SMBulogoffX, "SMBulogoffX",FLG_CHAIN,DEFDESCRIPT},
+
+{SMBgetatr,"SMBgetatr",0,
+   {NULL,"Path=[Z]\n",
+    "Attribute=[A]\nTime=[T2]Size=[D]\nRes=([w,w,w,w,w])\n",NULL,
+    NULL}},
+
+{SMBsetatr,"SMBsetatr",0,
+   {"Attribute=[A]\nTime=[T2]Res=([w,w,w,w,w])\n","Path=[Z]\n",
+    NULL,NULL,NULL}},
+
+{SMBchkpth,"SMBchkpth",0,
+   {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
+
+{SMBsearch,"SMBsearch",0,
+{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\n",
+"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+
+
+{SMBopen,"SMBopen",0,
+   {"Mode=[w]\nAttribute=[A]\n","Path=[Z]\n",
+    "Handle=[d]\nOAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\n",NULL,
+    NULL}},
+
+{SMBcreate,"SMBcreate",0,
+   {"Attrib=[A]\nTime=[T2]","Path=[Z]\n",
+    "Handle=[d]\n",NULL,
+    NULL}},
+
+{SMBmknew,"SMBmknew",0,
+   {"Attrib=[A]\nTime=[T2]","Path=[Z]\n",
+    "Handle=[d]\n",NULL,
+    NULL}},
+
+{SMBunlink,"SMBunlink",0,
+   {"Attrib=[A]\n","Path=[Z]\n",NULL,NULL,NULL}},
+
+{SMBread,"SMBread",0,
+   {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
+    "Count=[d]\nRes=([w,w,w,w])\n",NULL,NULL}},
+
+{SMBwrite,"SMBwrite",0,
+   {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
+    "Count=[d]\n",NULL,NULL}},
+
+{SMBclose,"SMBclose",0,
+   {"Handle=[d]\nTime=[T2]",NULL,NULL,NULL,NULL}},
+
+{SMBmkdir,"SMBmkdir",0,
+   {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
+
+{SMBrmdir,"SMBrmdir",0,
+   {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
+
+{SMBdskattr,"SMBdskattr",0,
+{NULL,NULL,
+"TotalUnits=[d]\nBlocksPerUnit=[d]\nBlockSize=[d]\nFreeUnits=[d]\nMedia=[w]\n",
+NULL,NULL}},
+
+{SMBmv,"SMBmv",0,
+   {"Attrib=[A]\n","OldPath=[Z]\nNewPath=[Z]\n",NULL,NULL,NULL}},
+
+/* this is a Pathworks specific call, allowing the 
+   changing of the root path */
+{pSETDIR,"SMBsetdir",0,
+   {NULL,"Path=[Z]\n",NULL,NULL,NULL}},
+
+{SMBlseek,"SMBlseek",0,
+   {"Handle=[d]\nMode=[w]\nOffset=[D]\n","Offset=[D]\n",NULL,NULL}},
+
+{SMBflush,"SMBflush",0,
+   {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+
+{SMBsplopen,"SMBsplopen",0,
+   {"SetupLen=[d]\nMode=[w]\n","Ident=[Z]\n","Handle=[d]\n",NULL,NULL}},
+
+{SMBsplclose,"SMBsplclose",0,
+   {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+
+{SMBsplretq,"SMBsplretq",0,
+   {"MaxCount=[d]\nStartIndex=[d]\n",NULL,
+    "Count=[d]\nIndex=[d]\n",
+    "*Time=[T2]Status=[B]\nJobID=[d]\nSize=[D]\nRes=[B]Name=[s16]\n",
+    NULL}},
+
+{SMBsplwr,"SMBsplwr",0,
+   {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+
+{SMBlock,"SMBlock",0,
+   {"Handle=[d]\nCount=[D]\nOffset=[D]\n",NULL,NULL,NULL,NULL}},
+
+{SMBunlock,"SMBunlock",0,
+   {"Handle=[d]\nCount=[D]\nOffset=[D]\n",NULL,NULL,NULL,NULL}},
+
+/* CORE+ PROTOCOL FOLLOWS */
+
+{SMBreadbraw,"SMBreadbraw",0,
+{"Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[d]\n",
+ NULL,NULL,NULL,NULL}},
+
+{SMBwritebraw,"SMBwritebraw",0,
+{"Handle=[d]\nTotalCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\n|DataSize=[d]\nDataOff=[d]\n",
+NULL,"WriteRawAck",NULL,NULL}},
+
+{SMBwritec,"SMBwritec",0,
+   {NULL,NULL,"Count=[d]\n",NULL,NULL}},
+
+{SMBwriteclose,"SMBwriteclose",0,
+   {"Handle=[d]\nCount=[d]\nOffset=[D]\nTime=[T2]Res=([w,w,w,w,w,w])",NULL,
+    "Count=[d]\n",NULL,NULL}},
+
+{SMBlockread,"SMBlockread",0,
+   {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
+    "Count=[d]\nRes=([w,w,w,w])\n",NULL,NULL}},
+
+{SMBwriteunlock,"SMBwriteunlock",0,
+   {"Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n",NULL,
+    "Count=[d]\n",NULL,NULL}},
+
+{SMBreadBmpx,"SMBreadBmpx",0,
+{"Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[w]\n",
+NULL,
+"Offset=[D]\nTotCount=[d]\nRemaining=[d]\nRes=([w,w])\nDataSize=[d]\nDataOff=[d]\n",
+NULL,NULL}},
+
+{SMBwriteBmpx,"SMBwriteBmpx",0,
+{"Handle=[d]\nTotCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\nDataSize=[d]\nDataOff=[d]\n",NULL,
+"Remaining=[d]\n",NULL,NULL}},
+
+{SMBwriteBs,"SMBwriteBs",0,
+   {"Handle=[d]\nTotCount=[d]\nOffset=[D]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\n",NULL,
+    "Count=[d]\n",NULL,NULL}},
+
+{SMBsetattrE,"SMBsetattrE",0,
+   {"Handle=[d]\nCreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]",NULL,
+      NULL,NULL,NULL}},
+
+{SMBgetattrE,"SMBgetattrE",0,
+{"Handle=[d]\n",NULL,
+ "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D]\nAllocSize=[D]\nAttribute=[A]\n",NULL,NULL}},
+
+{SMBtranss,"SMBtranss",0,DEFDESCRIPT},
+{SMBioctls,"SMBioctls",0,DEFDESCRIPT},
+
+{SMBcopy,"SMBcopy",0,
+   {"TreeID2=[d]\nOFun=[w]\nFlags=[w]\n","Path=[S]\nNewPath=[S]\n",
+    "CopyCount=[d]\n","|ErrStr=[S]\n",NULL}},
+
+{SMBmove,"SMBmove",0,
+   {"TreeID2=[d]\nOFun=[w]\nFlags=[w]\n","Path=[S]\nNewPath=[S]\n",
+    "MoveCount=[d]\n","|ErrStr=[S]\n",NULL}},
+
+{SMBopenX,"SMBopenX",FLG_CHAIN,
+{"Com2=[w]\nOff2=[d]\nFlags=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]OFun=[w]\nSize=[D]\nTimeOut=[D]\nRes=[W]\n","Path=[S]\n",
+"Com2=[w]\nOff2=[d]\nHandle=[d]\nAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nFileID=[W]\nRes=[w]\n",NULL,NULL}},
+
+{SMBreadX,"SMBreadX",FLG_CHAIN,
+{"Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nCountLeft=[d]\n",NULL,
+"Com2=[w]\nOff2=[d]\nRemaining=[d]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\nRes=([w,w,w,w])\n",NULL,NULL}},
+
+{SMBwriteX,"SMBwriteX",FLG_CHAIN,
+{"Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nCountLeft=[d]\nRes=[w]\nDataSize=[d]\nDataOff=[d]\n",NULL,
+"Com2=[w]\nOff2=[d]\nCount=[d]\nRemaining=[d]\nRes=[W]\n",NULL,NULL}},
+
+{SMBlockingX,"SMBlockingX",FLG_CHAIN,
+{"Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n",
+"*Process=[d]\nOffset=[D]\nLength=[D]\n",
+"Com2=[w]\nOff2=[d]\n"}},
+
+{SMBffirst,"SMBffirst",0,
+{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
+"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+
+{SMBfunique,"SMBfunique",0,
+{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
+"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+
+{SMBfclose,"SMBfclose",0,
+{"Count=[d]\nAttrib=[A]\n","Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
+"Count=[d]\n","BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",NULL}},
+
+{SMBfindnclose, "SMBfindnclose", 0,
+   {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+
+{SMBfindclose, "SMBfindclose", 0,
+   {"Handle=[d]\n",NULL,NULL,NULL,NULL}},
+
+{SMBsends,"SMBsends",0,
+   {NULL,"Source=[Z]\nDest=[Z]\n",NULL,NULL,NULL}},
+
+{SMBsendstrt,"SMBsendstrt",0,
+   {NULL,"Source=[Z]\nDest=[Z]\n","GroupID=[d]\n",NULL,NULL}},
+   
+{SMBsendend,"SMBsendend",0,
+   {"GroupID=[d]\n",NULL,NULL,NULL,NULL}},
+
+{SMBsendtxt,"SMBsendtxt",0,
+   {"GroupID=[d]\n",NULL,NULL,NULL,NULL}},
+
+{SMBsendb,"SMBsendb",0,
+   {NULL,"Source=[Z]\nDest=[Z]\n",NULL,NULL,NULL}},
+
+{SMBfwdname,"SMBfwdname",0,DEFDESCRIPT},
+{SMBcancelf,"SMBcancelf",0,DEFDESCRIPT},
+{SMBgetmac,"SMBgetmac",0,DEFDESCRIPT},
+
+{SMBnegprot,"SMBnegprot",0,
+   {NULL,NULL,NULL,NULL,print_negprot}},
+
+{SMBsesssetupX,"SMBsesssetupX",FLG_CHAIN,
+   {NULL,NULL,NULL,NULL,print_sesssetup}},
+
+{SMBtconX,"SMBtconX",FLG_CHAIN,
+{"Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n",NULL,
+ "Com2=[w]\nOff2=[d]\n","ServiceType=[S]\n",NULL}},
+
+{SMBtrans2, "SMBtrans2",0,{NULL,NULL,NULL,NULL,print_trans2}},
+
+{SMBtranss2, "SMBtranss2", 0,DEFDESCRIPT},
+{SMBctemp,"SMBctemp",0,DEFDESCRIPT},
+{SMBreadBs,"SMBreadBs",0,DEFDESCRIPT},
+{SMBtrans,"SMBtrans",0,{NULL,NULL,NULL,NULL,print_trans}},
+
+{-1,NULL,0,DEFDESCRIPT}};
+
+/*******************************************************************
+print a SMB message
+********************************************************************/
+void print_smb(uchar *buf,uchar *maxbuf)
+{
+  int command;
+  uchar *words, *data;
+  struct smbfns *fn;
+  char *fmt_smbheader = 
+"[P4]SMB Command   =  [B]\nError class   =  [BP1]\nError code    =  [d]\nFlags1        =  [B]\nFlags2        =  [B][P13]\nTree ID       =  [d]\nProc ID       =  [d]\nUID           =  [d]\nMID           =  [d]\nWord Count    =  [b]\n";
+
+  request = (CVAL(buf,9)&0x80)?0:1;
+
+  command = CVAL(buf,4);
+
+  fn = smbfind(command,smb_fns);
+
+  printf("\nSMB PACKET: %s (%s)\n",fn->name,request?"REQUEST":"REPLY");
+
+  /* print out the header */
+  fdata(buf,fmt_smbheader,buf+33);
+
+  if (CVAL(buf,5)) {
+    int class = CVAL(buf,5);
+    int num = SVAL(buf,7);
+    printf("SMBError = %s\n",smb_errstr(class,num));
+  }
+
+  words = buf+32;
+  data = words + 1 + CVAL(words,0)*2;
+
+
+  while (words && data)
+    {
+      char *f1,*f2;
+      int wct = CVAL(words,0);
+
+      if (request) {
+	f1 = fn->descript.req_f1;
+	f2 = fn->descript.req_f2;
+      } else {
+	f1 = fn->descript.rep_f1;
+	f2 = fn->descript.rep_f2;
+      }
+
+      if (fn->descript.fn) {
+	fn->descript.fn(words,data,buf,maxbuf);
+      } else {
+	if (f1) {
+	  printf("smbvwv[]=\n");
+	  fdata(words+1,f1,words + 1 + wct*2);
+	} else if (wct) {
+	  int i;
+	  int v;
+	  printf("smbvwv[]=\n");
+	  for (i=0;i<wct;i++) {
+	    v = SVAL(words+1,2*i);
+	    printf("smb_vwv[%d]=%d (0x%X)\n",i,v,v);
+	  }
+	}
+	
+	if (f2) {
+	  printf("smbbuf[]=\n");
+	  fdata(data+2,f2,maxbuf);
+	} else {
+	  int bcc = SVAL(data,0);
+	  printf("smb_bcc=%d\n",bcc);
+	  if (bcc>0) {
+	    printf("smb_buf[]=\n");
+	    print_data(data+2,MIN(bcc,PTR_DIFF(maxbuf,data+2)));
+	  }
+	}
+      }
+
+      if ((fn->flags & FLG_CHAIN) && CVAL(words,0) && SVAL(words,1)!=0xFF) {
+	command = SVAL(words,1);
+	words = buf + SVAL(words,3);
+	data = words + 1 + CVAL(words,0)*2;
+
+	fn = smbfind(command,smb_fns);
+
+	printf("\nSMB PACKET: %s (%s) (CHAINED)\n",fn->name,request?"REQUEST":"REPLY");
+      } else {
+	words = data = NULL;
+      }
+    }
+
+  printf("\n");  
+}
+
+
+/*
+   print a NBT packet received across tcp on port 139
+*/
+void nbt_tcp_print(uchar *data,uchar *maxbuf)
+{
+  int flags = CVAL(data,0);
+  int nbt_len = RSVAL(data,2);
+  startbuf = data;
+  if (maxbuf <= data) return;
+
+  printf("\n>>> NBT Packet\n");
+
+  switch (flags) {
+  case 0:    
+    data = fdata(data,"NBT Session Packet\nFlags=[rw]\nLength=[rd]\n",data+4);
+    if (memcmp(data,"\377SMB",4)==0) {
+      if (nbt_len>PTR_DIFF(maxbuf,data))
+	printf("WARNING: Short packet. Try increasing the snap length (%d)\n",
+	       PTR_DIFF(maxbuf,data));
+      print_smb(data,maxbuf>data+nbt_len?data+nbt_len:maxbuf);
+    } else {
+      printf("Session packet:(raw data?)\n");
+    }
+    break;
+
+  case 0x81:
+    data = fdata(data,"NBT Session Request\nFlags=[rW]\nDestination=[n1]\nSource=[n1]\n",maxbuf);
+    break;
+
+  case 0x82:
+    data = fdata(data,"NBT Session Granted\nFlags=[rW]\n",maxbuf);
+    break;
+
+  case 0x83:
+    {
+      int ecode = CVAL(data,4);
+      data = fdata(data,"NBT SessionReject\nFlags=[rW]\nReason=[B]\n",maxbuf);
+      switch (ecode) {
+      case 0x80: 
+	printf("Not listening on called name\n"); 
+	break;
+      case 0x81: 
+	printf("Not listening for calling name\n"); 
+	break;
+      case 0x82: 
+	printf("Called name not present\n"); 
+	break;
+      case 0x83: 
+	printf("Called name present, but insufficient resources\n"); 
+	break;
+      default:
+	printf("Unspecified error 0x%X\n",ecode); 
+	break;	  
+      }
+    }
+    break;
+
+  case 0x85:
+    data = fdata(data,"NBT Session Keepalive\nFlags=[rW]\n",maxbuf);
+    break;
+
+  default:
+    data = fdata(data,"NBT - Unknown packet type\nType=[rW]\n",maxbuf);
+  }
+  printf("\n");
+  fflush(stdout);
+}
+
+
+/*
+   print a NBT packet received across udp on port 137
+*/
+void nbt_udp137_print(uchar *data,uchar *maxbuf)
+{
+  int name_trn_id = RSVAL(data,0);
+  int response = (CVAL(data,2)>>7);
+  int opcode = (CVAL(data,2) >> 3) & 0xF;
+  int nm_flags = ((CVAL(data,2) & 0x7) << 4) + (CVAL(data,3)>>4);
+  int rcode = CVAL(data,3) & 0xF;
+  int qdcount = RSVAL(data,4);
+  int ancount = RSVAL(data,6);
+  int nscount = RSVAL(data,8);
+  int arcount = RSVAL(data,10);
+  char des[1024];
+  char *opcodestr="OPUNKNOWN";  
+  char *p;
+
+  startbuf = data;
+
+  if (maxbuf <= data) return;
+
+  strcpy(des,"\n>>> NBT UDP PACKET(137): ");
+
+  switch (opcode) {
+  case 0: opcodestr = "QUERY"; break;
+  case 5: opcodestr = "REGISTRATION"; break;
+  case 6: opcodestr = "RELEASE"; break;
+  case 7: opcodestr = "WACK"; break;
+  case 8: opcodestr = "REFRESH(8)"; break;
+  case 9: opcodestr = "REFRESH"; break;
+  }
+  strcat(des,opcodestr);
+  if (response) {
+    if (rcode)
+      strcat(des,"; NEGATIVE");
+    else
+      strcat(des,"; POSITIVE");
+  }
+    
+  if (response) 
+    strcat(des,"; RESPONSE");
+  else
+    strcat(des,"; REQUEST");
+
+  if (nm_flags&1)
+    strcat(des,"; BROADCAST");
+  else
+    strcat(des,"; UNICAST");
+  
+  printf("%s\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
+	 des,name_trn_id,opcode,nm_flags,rcode,qdcount,ancount,nscount,arcount);
+
+  p = data + 12;
+
+  {
+    int total = ancount+nscount+arcount;
+    int i;
+
+    if (qdcount>100 || total>100) {
+      printf("Corrupt packet??\n");
+      return;
+    }
+
+    if (qdcount) {
+      printf("QuestionRecords:\n");
+      for (i=0;i<qdcount;i++)
+	p = fdata(p,"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",maxbuf);
+    }
+
+    if (total) {
+      printf("\nResourceRecords:\n");
+      for (i=0;i<total;i++) {	  
+	int rdlen;
+	int restype;
+	p = fdata(p,"Name=[n1]\n#",maxbuf);
+	restype = RSVAL(p,0);
+	p = fdata(p,"ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n",p+8);
+	rdlen = RSVAL(p,0);
+	printf("ResourceLength=%d\nResourceData=\n",rdlen);
+	p += 2;
+	if (rdlen == 6) {
+	  p = fdata(p,"AddrType=[rw]\nAddress=[b.b.b.b]\n",p+rdlen);
+	} else {
+	  if (restype == 0x21) {
+	    int numnames = CVAL(p,0);
+	    p = fdata(p,"NumNames=[B]\n",p+1);
+	    while (numnames--) {
+	      char flags[128]="";
+	      p = fdata(p,"Name=[n2]\t#",maxbuf);
+	      if (p[0] & 0x80) strcat(flags,"<GROUP> ");
+	      if (p[0] & 0x60 == 0) strcat(flags,"B ");
+	      if (p[0] & 0x60 == 1) strcat(flags,"P ");
+	      if (p[0] & 0x60 == 2) strcat(flags,"M ");
+	      if (p[0] & 0x60 == 3) strcat(flags,"_ ");
+	      if (p[0] & 0x10) strcat(flags,"<DEREGISTERING> ");
+	      if (p[0] & 0x08) strcat(flags,"<CONFLICT> ");
+	      if (p[0] & 0x04) strcat(flags,"<ACTIVE> ");
+	      if (p[0] & 0x02) strcat(flags,"<PERMANENT> ");
+	      printf("%s\n",flags);
+	      p += 2;
+	    }
+	  } else {
+	    print_data(p,rdlen);
+	    p += rdlen;
+	  }
+	}
+      }
+    }
+  }
+
+  if ((uchar*)p < maxbuf) {
+    fdata(p,"AdditionalData:\n",maxbuf);    
+  }      
+  
+  printf("\n");
+  fflush(stdout);
+}
+
+
+
+/*
+   print a NBT packet received across udp on port 138
+*/
+void nbt_udp138_print(uchar *data,uchar *maxbuf)
+{
+  startbuf = data;
+  if (maxbuf <= data) return;
+
+  data = fdata(data,"\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#",maxbuf);
+
+  print_smb(data,maxbuf);
+  
+  printf("\n");
+  fflush(stdout);
+}
+
+
+
+/*
+   print netbeui frames 
+*/
+void netbeui_print(uchar *data,uchar *maxbuf)
+{
+  int len = SVAL(data,1);
+  int command = CVAL(data,5);
+  uchar *data2 = data + 1 + len;
+
+  startbuf = data;
+
+  data = fdata(data,"\n>>> NetBeui Packet\nType=[B] Length=[d] Signature=[w] Command=[B]\n#",maxbuf);
+
+  switch (command) {
+  case 0xA: 
+    data = fdata(data,"NameQuery:[P1]\nSessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nDestination=[n2]\nSource=[n2]\n",data2);
+    break;
+
+  case 0x8:
+    data = fdata(data,"NetbiosDataGram:[P7]\nDestination=[n2]\nSource=[n2]\n",data2);
+    break;
+
+  case 0xE:
+    data = fdata(data,"NameRecognise:\n[P1]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n",data2);
+    break;
+
+  case 0x19:
+    data = fdata(data,"SessionInitialise:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
+    break;
+
+  case 0x17:
+    data = fdata(data,"SessionConfirm:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
+    break;
+
+  case 0x16:
+    data = fdata(data,"NetbiosDataOnlyLast:\nFlags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
+    break;
+
+  case 0x14:
+    data = fdata(data,"NetbiosDataAck:\n[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
+    break;
+
+  case 0x18:
+    data = fdata(data,"SessionEnd:\n[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",data2);
+    break;
+
+  default:
+    data = fdata(data,"Unknown Netbios Command ",data2);
+    break;
+  }
+
+  if (memcmp(data2,"\377SMB",4)==0) {
+    print_smb(data2,maxbuf);
+  } else {
+    fdata(data2,"Extra ",maxbuf);
+  }
+
+  printf("\n");
+}
+
+
+/*
+   print IPX-Netbios frames 
+*/
+void ipx_netbios_print(uchar *data,uchar *maxbuf)
+{
+  /* this is a hack till I work out how to parse the rest of the IPX stuff */
+  int i;
+  startbuf = data;
+  for (i=0;i<128;i++)
+    if (memcmp(&data[i],"\377SMB",4)==0) {
+      fdata(data,"\n>>> IPX transport ",&data[i]);
+      print_smb(&data[i],maxbuf);
+      printf("\n");
+      fflush(stdout);
+      break;
+    }
+  if (i==128)
+    fdata(data,"\n>>> Unknown IPX ",maxbuf);
+}
--- print-tcp.c	Sun Jun 15 16:20:08 1997
+++ print-tcp.c	Sat Feb 21 15:59:26 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -38,6 +43,11 @@
 #include <memory.h>
 #endif
 #include <stdio.h>
+
+#ifdef INET6
+#include <netinet/ipv6.h>
+#endif /* INET6 */
+
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -96,6 +106,8 @@
 static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
 
 
+#define NETBIOS_SSN_PORT 139
+
 void
 tcp_print(register const u_char *bp, register u_int length,
 	  register const u_char *bp2)
@@ -124,6 +136,13 @@
 	win = ntohs(tp->th_win);
 	urp = ntohs(tp->th_urp);
 
+#ifdef INET6
+	if (ip->ip_v == 6)
+	  printf("%s.%s > %s.%s:",
+		ipv6addr_string(&(((struct ipv6hdr *)ip)->ipv6_src)), tcpport_string(sport),
+		ipv6addr_string(&(((struct ipv6hdr *)ip)->ipv6_dst)), tcpport_string(dport));
+	else
+#endif /* INET6 */
 	(void)printf("%s.%s > %s.%s: ",
 		ipaddr_string(&ip->ip_src), tcpport_string(sport),
 		ipaddr_string(&ip->ip_dst), tcpport_string(dport));
@@ -349,6 +368,28 @@
 		}
 		putchar('>');
 	}
+
+	/* check for specific tcp-based protocols. This will never be
+	 perfect because of the stream nature of tcp but in practice
+	 it does pretty well */
+	if (!qflag) {
+#define ISPORT(p) (dport == (p) || sport == (p))
+
+	  u_char *data = (u_char *)(tp + 1);
+	  u_char *data_end;
+
+	  if (length < snaplen - sizeof(*tp))
+	    data_end = data + length;
+	  else
+	    data_end = data + snaplen - sizeof(*tp);
+
+	  if (ISPORT(NETBIOS_SSN_PORT)) {
+	    /* netbios-ssn packets, as used for file
+	       sharing by SMB (in for example, windows) */
+	    nbt_tcp_print(data, data_end);
+	  }
+	}
+	
 	return;
 bad:
 	fputs("[bad opt]", stdout);
--- print-udp.c	Mon Jul 28 00:58:36 1997
+++ print-udp.c	Sat Feb 21 15:59:27 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -35,6 +40,10 @@
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
 
+#if INET6
+#include <netinet/ipv6.h>
+#endif /* INET6 */
+
 #ifdef NOERROR
 #undef NOERROR					/* Solaris sucks */
 #endif
@@ -293,6 +302,8 @@
 #define SNMPTRAP_PORT 162	/*XXX*/
 #define RIP_PORT 520		/*XXX*/
 #define KERBEROS_SEC_PORT 750	/*XXX*/
+#define NETBIOS_NS_PORT   137
+#define NETBIOS_DGRAM_PORT   138
 
 void
 udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
@@ -411,6 +422,13 @@
 			return;
 		}
 	}
+#ifdef INET6
+	if (ip->ip_v == 6)
+	  printf("%s.%s > %s.%s:",
+		ipv6addr_string(&(((struct ipv6hdr *)ip)->ipv6_src)), udpport_string(sport),
+		ipv6addr_string(&(((struct ipv6hdr *)ip)->ipv6_dst)), udpport_string(dport));
+	else
+#endif /* INET6 */
 	(void)printf("%s.%s > %s.%s:",
 		ipaddr_string(&ip->ip_src), udpport_string(sport),
 		ipaddr_string(&ip->ip_dst), udpport_string(dport));
@@ -434,6 +452,14 @@
 			krb_print((const void *)(up + 1), length);
 		else if (dport == 3456)
 			vat_print((const void *)(up + 1), length, up);
+		else if (ISPORT(NETBIOS_NS_PORT)) {
+		  unsigned char *data = (unsigned char *)(up + 1);
+		  nbt_udp137_print(data,data+length>snapend?snapend:data+length);
+		}
+		else if (ISPORT(NETBIOS_DGRAM_PORT)) {
+		  unsigned char *data = (unsigned char *)(up + 1);
+		  nbt_udp138_print(data,data+length>snapend?snapend:data+length);
+		}
 		/*
 		 * Kludge in test for whiteboard packets.
 		 */
--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./smb.h	Sat Feb 21 15:59:27 1998
@@ -0,0 +1,158 @@
+/* 
+   Copyright (C) Andrew Tridgell 1995
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
+#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
+#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
+
+#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
+#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
+#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
+#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
+#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
+#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
+#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
+#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
+#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
+#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
+
+/* now the reverse routines - these are used in nmb packets (mostly) */
+#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
+#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
+
+#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
+#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
+#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
+#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
+
+#define uint16 unsigned short
+#define uint32 unsigned int
+#ifndef uchar
+#define uchar unsigned char
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+/* the complete */
+#define SMBmkdir      0x00   /* create directory */
+#define SMBrmdir      0x01   /* delete directory */
+#define SMBopen       0x02   /* open file */
+#define SMBcreate     0x03   /* create file */
+#define SMBclose      0x04   /* close file */
+#define SMBflush      0x05   /* flush file */
+#define SMBunlink     0x06   /* delete file */
+#define SMBmv         0x07   /* rename file */
+#define SMBgetatr     0x08   /* get file attributes */
+#define SMBsetatr     0x09   /* set file attributes */
+#define SMBread       0x0A   /* read from file */
+#define SMBwrite      0x0B   /* write to file */
+#define SMBlock       0x0C   /* lock byte range */
+#define SMBunlock     0x0D   /* unlock byte range */
+#define SMBctemp      0x0E   /* create temporary file */
+#define SMBmknew      0x0F   /* make new file */
+#define SMBchkpth     0x10   /* check directory path */
+#define SMBexit       0x11   /* process exit */
+#define SMBlseek      0x12   /* seek */
+#define SMBtcon       0x70   /* tree connect */
+#define SMBtconX      0x75   /* tree connect and X*/
+#define SMBtdis       0x71   /* tree disconnect */
+#define SMBnegprot    0x72   /* negotiate protocol */
+#define SMBdskattr    0x80   /* get disk attributes */
+#define SMBsearch     0x81   /* search directory */
+#define SMBsplopen    0xC0   /* open print spool file */
+#define SMBsplwr      0xC1   /* write to print spool file */
+#define SMBsplclose   0xC2   /* close print spool file */
+#define SMBsplretq    0xC3   /* return print queue */
+#define SMBsends      0xD0   /* send single block message */
+#define SMBsendb      0xD1   /* send broadcast message */
+#define SMBfwdname    0xD2   /* forward user name */
+#define SMBcancelf    0xD3   /* cancel forward */
+#define SMBgetmac     0xD4   /* get machine name */
+#define SMBsendstrt   0xD5   /* send start of multi-block message */
+#define SMBsendend    0xD6   /* send end of multi-block message */
+#define SMBsendtxt    0xD7   /* send text of multi-block message */
+
+/* Core+ protocol */
+#define SMBlockread	  0x13   /* Lock a range and read */
+#define SMBwriteunlock 0x14 /* Unlock a range then write */
+#define SMBreadbraw   0x1a  /* read a block of data with no smb header */
+#define SMBwritebraw  0x1d  /* write a block of data with no smb header */
+#define SMBwritec     0x20  /* secondary write request */
+#define SMBwriteclose 0x2c  /* write a file then close it */
+
+/* dos extended protocol */
+#define SMBreadBraw      0x1A   /* read block raw */
+#define SMBreadBmpx      0x1B   /* read block multiplexed */
+#define SMBreadBs        0x1C   /* read block (secondary response) */
+#define SMBwriteBraw     0x1D   /* write block raw */
+#define SMBwriteBmpx     0x1E   /* write block multiplexed */
+#define SMBwriteBs       0x1F   /* write block (secondary request) */
+#define SMBwriteC        0x20   /* write complete response */
+#define SMBsetattrE      0x22   /* set file attributes expanded */
+#define SMBgetattrE      0x23   /* get file attributes expanded */
+#define SMBlockingX      0x24   /* lock/unlock byte ranges and X */
+#define SMBtrans         0x25   /* transaction - name, bytes in/out */
+#define SMBtranss        0x26   /* transaction (secondary request/response) */
+#define SMBioctl         0x27   /* IOCTL */
+#define SMBioctls        0x28   /* IOCTL  (secondary request/response) */
+#define SMBcopy          0x29   /* copy */
+#define SMBmove          0x2A   /* move */
+#define SMBecho          0x2B   /* echo */
+#define SMBopenX         0x2D   /* open and X */
+#define SMBreadX         0x2E   /* read and X */
+#define SMBwriteX        0x2F   /* write and X */
+#define SMBsesssetupX    0x73   /* Session Set Up & X (including User Logon) */
+#define SMBtconX         0x75   /* tree connect and X */
+#define SMBffirst        0x82   /* find first */
+#define SMBfunique       0x83   /* find unique */
+#define SMBfclose        0x84   /* find close */
+#define SMBinvalid       0xFE   /* invalid command */
+
+/* Extended 2.0 protocol */
+#define SMBtrans2        0x32   /* TRANS2 protocol set */
+#define SMBtranss2       0x33   /* TRANS2 protocol set, secondary command */
+#define SMBfindclose     0x34   /* Terminate a TRANSACT2_FINDFIRST */
+#define SMBfindnclose    0x35   /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
+#define SMBulogoffX      0x74   /* user logoff */
+
+/* pathworks special */
+#define pSETDIR '\377'
+
+
+/* these are the TRANS2 sub commands */
+#define TRANSACT2_OPEN          0
+#define TRANSACT2_FINDFIRST     1
+#define TRANSACT2_FINDNEXT      2
+#define TRANSACT2_QFSINFO       3
+#define TRANSACT2_SETFSINFO     4
+#define TRANSACT2_QPATHINFO     5
+#define TRANSACT2_SETPATHINFO   6
+#define TRANSACT2_QFILEINFO     7
+#define TRANSACT2_SETFILEINFO   8
+#define TRANSACT2_FSCTL         9
+#define TRANSACT2_IOCTL           10
+#define TRANSACT2_FINDNOTIFYFIRST 11
+#define TRANSACT2_FINDNOTIFYNEXT  12
+#define TRANSACT2_MKDIR           13
+
+#define PTR_DIFF(p1,p2) ((unsigned long)(((char *)(p1)) - (char *)(p2)))
+
+/* some protos */
+uchar *fdata(uchar *buf,char *fmt,uchar *maxbuf);
--- /dev/null	Sun Mar 13 14:59:14 1994
+++ ./smbutil.c	Sat Feb 21 15:59:27 1998
@@ -0,0 +1,643 @@
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "smb.h"
+
+extern uchar *startbuf;
+
+/*******************************************************************
+  interpret a 32 bit dos packed date/time to some parameters
+********************************************************************/
+static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *hour,int *minute,int *second)
+{
+  uint32 p0,p1,p2,p3;
+
+  p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF; 
+  p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
+
+  *second = 2*(p0 & 0x1F);
+  *minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3);
+  *hour = (p1>>3)&0xFF;
+  *day = (p2&0x1F);
+  *month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1;
+  *year = ((p3>>1)&0xFF) + 80;
+}
+
+/*******************************************************************
+  create a unix date from a dos date
+********************************************************************/
+time_t make_unix_date(void *date_ptr)
+{
+  uint32 dos_date=0;
+  struct tm t;
+
+  dos_date = IVAL(date_ptr,0);
+
+  if (dos_date == 0) return(0);
+  
+  interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
+		     &t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
+  t.tm_wday = 1;
+  t.tm_yday = 1;
+  t.tm_isdst = 0;
+
+  return (mktime(&t));
+}
+
+/*******************************************************************
+  create a unix date from a dos date
+********************************************************************/
+time_t make_unix_date2(void *date_ptr)
+{
+  uint32 x,x2;
+
+  x = IVAL(date_ptr,0);
+  x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
+  SIVAL(&x,0,x2);
+
+  return(make_unix_date((void *)&x));
+}
+
+/****************************************************************************
+interpret an 8 byte "filetime" structure to a time_t
+It's originally in "100ns units since jan 1st 1601"
+****************************************************************************/
+time_t interpret_long_date(char *p)
+{
+  double d;
+  time_t ret;
+
+  /* this gives us seconds since jan 1st 1601 (approx) */
+  d = (IVAL(p,4)*256.0 + CVAL(p,3)) * (1.0e-7 * (1<<24));
+ 
+  /* now adjust by 369 years to make the secs since 1970 */
+  d -= 369.0*365.25*24*60*60;
+
+  /* and a fudge factor as we got it wrong by a few days */
+  d += (3*24*60*60 + 6*60*60 + 2);
+
+  if (d<0)
+    return(0);
+
+  ret = (time_t)d;
+
+  return(ret);
+}
+
+
+/****************************************************************************
+interpret the weird netbios "name". Return the name type
+****************************************************************************/
+static int name_interpret(char *in,char *out)
+{
+  int ret;
+  int len = (*in++) / 2;
+
+  *out=0;
+
+  if (len > 30 || len<1) return(0);
+
+  while (len--)
+    {
+      if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
+	*out = 0;
+	return(0);
+      }
+      *out = ((in[0]-'A')<<4) + (in[1]-'A');
+      in += 2;
+      out++;
+    }
+  *out = 0;
+  ret = out[-1];
+
+  /* Handle any scope names */
+  while(*in) 
+    {
+      *out++ = '.';
+      len = *in++;
+      strncpy(out, in, len);
+      out += len;
+      *out=0;
+      in += len;
+    }
+  return(ret);
+}
+
+/****************************************************************************
+find a pointer to a netbios name
+****************************************************************************/
+static char *name_ptr(char *buf,int ofs)
+{
+  unsigned char c = *(unsigned char *)(buf+ofs);
+
+  if ((c & 0xC0) == 0xC0)
+    {
+      uint16 l;
+      char p[2];
+      memcpy(p,buf+ofs,2);
+      p[0] &= ~0xC0;
+      l = RSVAL(p,0);
+      return(buf + l);
+    }
+  else
+    return(buf+ofs);
+}  
+
+/****************************************************************************
+extract a netbios name from a buf
+****************************************************************************/
+static int name_extract(char *buf,int ofs,char *name)
+{
+  char *p = name_ptr(buf,ofs);
+  int d = PTR_DIFF(p,buf+ofs);
+  strcpy(name,"");
+  return(name_interpret(p,name));
+}  
+  
+
+/****************************************************************************
+return the total storage length of a mangled name
+****************************************************************************/
+static int name_len(char *s)
+{
+  char *s0 = s;
+  unsigned char c = *(unsigned char *)s;
+  if ((c & 0xC0) == 0xC0)
+    return(2);  
+  while (*s) s += (*s)+1;
+  return(PTR_DIFF(s,s0)+1);
+}
+
+void print_asc(unsigned char *buf,int len)
+{
+  int i;
+  for (i=0;i<len;i++)
+    printf("%c",isprint(buf[i])?buf[i]:'.');
+}
+
+static char *name_type_str(int name_type)
+{
+  static char *f = NULL;
+  switch (name_type) {
+  case 0:    f = "Workstation"; break;
+  case 0x03: f = "Client?"; break;
+  case 0x20: f = "Server"; break;
+  case 0x1d: f = "Master Browser"; break;
+  case 0x1b: f = "Domain Controller"; break;
+  case 0x1e: f = "Browser Server"; break;
+  default:   f = "Unknown"; break;
+  }
+  return(f);
+}
+
+void print_data(unsigned char *buf,int len)
+{
+  int i=0;
+  if (len<=0) return;
+  printf("[%03X] ",i);
+  for (i=0;i<len;) {
+    printf("%02X ",(int)buf[i]);
+    i++;
+    if (i%8 == 0) printf(" ");
+    if (i%16 == 0) {      
+      print_asc(&buf[i-16],8); printf(" ");
+      print_asc(&buf[i-8],8); printf("\n");
+      if (i<len) printf("[%03X] ",i);
+    }
+  }
+  if (i%16) {
+    int n;
+
+    n = 16 - (i%16);
+    printf(" ");
+    if (n>8) printf(" ");
+    while (n--) printf("   ");
+
+    n = MIN(8,i%16);
+    print_asc(&buf[i-(i%16)],n); printf(" ");
+    n = (i%16) - n;
+    if (n>0) print_asc(&buf[i-n],n); 
+    printf("\n");    
+  }
+}
+
+
+static void write_bits(unsigned int val,char *fmt)
+{
+  char *p = fmt;
+  int i=0;
+
+  while ((p=strchr(fmt,'|'))) {
+    int l = PTR_DIFF(p,fmt);
+    if (l && (val & (1<<i))) 
+      printf("%.*s ",l,fmt);
+    fmt = p+1;
+    i++;
+  }
+}
+
+uchar *fdata1(uchar *buf,char *fmt,uchar *maxbuf)
+{
+  int reverse=0;
+  char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
+
+  while (*fmt && buf<maxbuf) {
+    switch (*fmt) {
+    case 'a':
+      write_bits(CVAL(buf,0),attrib_fmt);
+      buf++; fmt++;
+      break;
+
+    case 'A':
+      write_bits(SVAL(buf,0),attrib_fmt);
+      buf+=2; fmt++;
+      break;
+
+    case '{':
+      {
+	char bitfmt[128];
+	char *p = strchr(++fmt,'}');
+	int l = PTR_DIFF(p,fmt);
+	strncpy(bitfmt,fmt,l);
+	bitfmt[l]=0;
+	fmt = p+1;
+	write_bits(CVAL(buf,0),bitfmt);
+	buf++;
+	break;
+      }
+
+    case 'P':
+      {
+	int l = atoi(fmt+1);
+	buf += l;
+	fmt++;
+	while (isdigit(*fmt)) fmt++;
+	break;
+      }
+    case 'r':
+      reverse = !reverse;
+      fmt++;
+      break;
+    case 'D':
+      {
+	unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
+	printf("%d",x);
+	buf += 4;
+	fmt++;
+	break;
+      }
+    case 'd':
+      {
+	unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
+	printf("%d",x);
+	buf += 2;
+	fmt++;
+	break;
+      }
+    case 'W':
+      {
+	unsigned int x = reverse?RIVAL(buf,0):IVAL(buf,0);
+	printf("0x%X",x);
+	buf += 4;
+	fmt++;
+	break;
+      }
+    case 'w':
+      {
+	unsigned int x = reverse?RSVAL(buf,0):SVAL(buf,0);
+	printf("0x%X",x);
+	buf += 2;
+	fmt++;
+	break;
+      }
+    case 'B':
+      {
+	unsigned int x = CVAL(buf,0);
+	printf("0x%X",x);
+	buf += 1;
+	fmt++;
+	break;
+      }
+    case 'b':
+      {
+	unsigned int x = CVAL(buf,0);
+	printf("%d",x);
+	buf += 1;
+	fmt++;
+	break;
+      }
+    case 'S':
+      {	
+	printf("%.*s",PTR_DIFF(maxbuf,buf),buf);
+	buf += strlen(buf)+1;
+	fmt++;
+	break;
+      }
+    case 'Z':
+      {	
+	if (*buf != 4 && *buf != 2) 
+	  printf("Error! ASCIIZ buffer of type %d (safety=%d)\n",
+		 *buf,PTR_DIFF(maxbuf,buf));
+	printf("%.*s",PTR_DIFF(maxbuf,buf+1),buf+1);
+	buf += strlen(buf+1)+2;
+	fmt++;
+	break;
+      }
+    case 's':
+      {	
+	int l = atoi(fmt+1);
+	printf("%-*.*s",l,l,buf);
+	buf += l;	
+	fmt++; while (isdigit(*fmt)) fmt++;
+	break;
+      }
+    case 'h':
+      {	
+	int l = atoi(fmt+1);
+	while (l--) printf("%02x",*buf++);
+	fmt++; while (isdigit(*fmt)) fmt++;
+	break;
+      }
+    case 'n':
+      {	
+	int t = atoi(fmt+1);
+	char nbuf[255];
+	int name_type;
+	switch (t) {
+	case 1:
+	  name_type = name_extract(startbuf,PTR_DIFF(buf,startbuf),nbuf);
+	  buf += name_len(buf);
+	  printf("%-15.15s NameType=0x%02X (%s)",
+		 nbuf,name_type,name_type_str(name_type));
+	  break;
+	case 2:
+	  name_type = buf[15];
+	  printf("%-15.15s NameType=0x%02X (%s)",
+		 buf,name_type,name_type_str(name_type));
+	  buf += 16;
+	  break;
+	}
+	fmt++; while (isdigit(*fmt)) fmt++;
+	break;
+      }
+    case 'T':
+      {	
+	time_t t;
+	int x = IVAL(buf,0);
+	switch (atoi(fmt+1)) {
+	case 1:
+	  if (x==0 || x==-1 || x==0xFFFFFFFF)
+	    t = 0;
+	  else
+	    t = make_unix_date(buf); 
+	  buf+=4;
+	  break;
+	case 2:
+	  if (x==0 || x==-1 || x==0xFFFFFFFF)
+	    t = 0;
+	  else
+	    t = make_unix_date2(buf); 
+	  buf+=4;
+	  break;
+	case 3:
+	  t = interpret_long_date(buf); 
+	  buf+=8;
+	  break;
+	}
+	printf("%s",t?asctime(localtime(&t)):"NULL\n");
+	fmt++; while (isdigit(*fmt)) fmt++;
+	break;
+      }
+    default:
+      putchar(*fmt);
+      fmt++;
+      break;      
+    }
+  }
+
+  if (buf>=maxbuf && *fmt)
+    printf("END OF BUFFER\n");
+
+  return(buf);
+}
+
+uchar *fdata(uchar *buf,char *fmt,uchar *maxbuf)
+{
+  static int depth=0;
+  char s[128];
+  char *p;
+
+  while (*fmt) {
+    switch (*fmt) {
+    case '*':
+      fmt++;
+      while (buf < maxbuf) {
+	uchar *buf2;
+	depth++;
+	buf2 = fdata(buf,fmt,maxbuf);
+	depth--;
+	if (buf2 == buf) return(buf);
+	buf = buf2;
+      }
+      break;
+
+    case '|':
+      fmt++;
+      if (buf>=maxbuf) return(buf);
+      break;
+
+    case '%':
+      fmt++;
+      buf=maxbuf;
+      break;
+
+    case '#':
+      fmt++;
+      return(buf);
+      break;
+
+    case '[':
+      fmt++;
+      if (buf>=maxbuf) return(buf);
+      bzero(s,sizeof(s));
+      p = strchr(fmt,']');
+      strncpy(s,fmt,p-fmt);
+      fmt = p+1;
+      buf = fdata1(buf,s,maxbuf);
+      break;
+
+    default:
+      putchar(*fmt); fmt++;
+      fflush(stdout);
+      break;
+    }
+  }
+  if (!depth && buf<maxbuf) {
+    int len = PTR_DIFF(maxbuf,buf);
+    printf("Data: (%d bytes)\n",len);
+    print_data(buf,len);
+    return(buf+len);
+  }
+  return(buf);
+}
+
+typedef struct
+{
+  char *name;
+  int code;
+  char *message;
+} err_code_struct;
+
+/* Dos Error Messages */
+static err_code_struct dos_msgs[] = {
+  {"ERRbadfunc",1,"Invalid function."},
+  {"ERRbadfile",2,"File not found."},
+  {"ERRbadpath",3,"Directory invalid."},
+  {"ERRnofids",4,"No file descriptors available"},
+  {"ERRnoaccess",5,"Access denied."},
+  {"ERRbadfid",6,"Invalid file handle."},
+  {"ERRbadmcb",7,"Memory control blocks destroyed."},
+  {"ERRnomem",8,"Insufficient server memory to perform the requested function."},
+  {"ERRbadmem",9,"Invalid memory block address."},
+  {"ERRbadenv",10,"Invalid environment."},
+  {"ERRbadformat",11,"Invalid format."},
+  {"ERRbadaccess",12,"Invalid open mode."},
+  {"ERRbaddata",13,"Invalid data."},
+  {"ERR",14,"reserved."},
+  {"ERRbaddrive",15,"Invalid drive specified."},
+  {"ERRremcd",16,"A Delete Directory request attempted  to  remove  the  server's  current directory."},
+  {"ERRdiffdevice",17,"Not same device."},
+  {"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
+  {"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing  FIDs  on the file."},
+  {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an  invalid mode,  or an Unlock requested attempted to remove a lock held by another process."},
+  {"ERRfilexists",80,"The file named in a Create Directory, Make  New  File  or  Link  request already exists."},
+  {"ERRbadpipe",230,"Pipe invalid."},
+  {"ERRpipebusy",231,"All instances of the requested pipe are busy."},
+  {"ERRpipeclosing",232,"Pipe close in progress."},
+  {"ERRnotconnected",233,"No process on other end of pipe."},
+  {"ERRmoredata",234,"There is more data to be returned."},
+  {NULL,-1,NULL}};
+
+/* Server Error Messages */
+err_code_struct server_msgs[] = {
+  {"ERRerror",1,"Non-specific error code."},
+  {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
+  {"ERRbadtype",3,"reserved."},
+  {"ERRaccess",4,"The requester does not have  the  necessary  access  rights  within  the specified  context for the requested function. The context is defined by the TID or the UID."},
+  {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
+  {"ERRinvnetname",6,"Invalid network name in tree connect."},
+  {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or  non-printer request made to printer connection."},
+  {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
+  {"ERRqtoobig",50,"Print queue full -- no space."},
+  {"ERRqeof",51,"EOF on print queue dump."},
+  {"ERRinvpfid",52,"Invalid print file FID."},
+  {"ERRsmbcmd",64,"The server did not recognize the command received."},
+  {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
+  {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid  combination of values."},
+  {"ERRreserved",68,"reserved."},
+  {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination.  The server cannot set the requested attribute."},
+  {"ERRreserved",70,"reserved."},
+  {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
+  {"ERRpaused",81,"Server is paused."},
+  {"ERRmsgoff",82,"Not receiving messages."},
+  {"ERRnoroom",83,"No room to buffer message."},
+  {"ERRrmuns",87,"Too many remote user names."},
+  {"ERRtimeout",88,"Operation timed out."},
+  {"ERRnoresource",89,"No resources currently available for request."},
+  {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
+  {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
+  {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
+  {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
+  {"ERRcontmpx",252,"Continue in MPX mode."},
+  {"ERRreserved",253,"reserved."},
+  {"ERRreserved",254,"reserved."},
+  {"ERRnosupport",0xFFFF,"Function not supported."},
+  {NULL,-1,NULL}};
+
+/* Hard Error Messages */
+err_code_struct hard_msgs[] = {
+  {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
+  {"ERRbadunit",20,"Unknown unit."},
+  {"ERRnotready",21,"Drive not ready."},
+  {"ERRbadcmd",22,"Unknown command."},
+  {"ERRdata",23,"Data error (CRC)."},
+  {"ERRbadreq",24,"Bad request structure length."},
+  {"ERRseek",25 ,"Seek error."},
+  {"ERRbadmedia",26,"Unknown media type."},
+  {"ERRbadsector",27,"Sector not found."},
+  {"ERRnopaper",28,"Printer out of paper."},
+  {"ERRwrite",29,"Write fault."},
+  {"ERRread",30,"Read fault."},
+  {"ERRgeneral",31,"General failure."},
+  {"ERRbadshare",32,"A open conflicts with an existing open."},
+  {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
+  {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
+  {"ERRFCBUnavail",35,"No FCBs are available to process request."},
+  {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
+  {NULL,-1,NULL}};
+
+
+static struct
+{
+  int code;
+  char *class;
+  err_code_struct *err_msgs;
+} err_classes[] = { 
+  {0,"SUCCESS",NULL},
+  {0x01,"ERRDOS",dos_msgs},
+  {0x02,"ERRSRV",server_msgs},
+  {0x03,"ERRHRD",hard_msgs},
+  {0x04,"ERRXOS",NULL},
+  {0xE1,"ERRRMX1",NULL},
+  {0xE2,"ERRRMX2",NULL},
+  {0xE3,"ERRRMX3",NULL},
+  {0xFF,"ERRCMD",NULL},
+  {-1,NULL,NULL}};
+
+
+/****************************************************************************
+return a SMB error string from a SMB buffer
+****************************************************************************/
+char *smb_errstr(int class,int num)
+{
+  static char ret[128];
+  int i,j;
+
+  ret[0]=0;
+
+  for (i=0;err_classes[i].class;i++)
+    if (err_classes[i].code == class)
+      {
+	if (err_classes[i].err_msgs)
+	  {
+	    err_code_struct *err = err_classes[i].err_msgs;
+	    for (j=0;err[j].name;j++)
+	      if (num == err[j].code)
+		{
+		  sprintf(ret,"%s - %s (%s)",err_classes[i].class,
+			  err[j].name,err[j].message);
+		  return ret;
+		}
+	  }
+
+	sprintf(ret,"%s - %d",err_classes[i].class,num);
+	return ret;
+      }
+  
+  sprintf(ret,"ERROR: Unknown error (%d,%d)",class,num);
+  return(ret);
+}
+
+
+
--- tcpdump.1	Mon Jun 30 19:31:49 1997
+++ tcpdump.1	Sat Feb 21 15:59:27 1998
@@ -1,4 +1,9 @@
 .\" @(#) $Header: /cvs/gnome/gxsnmp/tools/tcpdump-3.4a6+ipv6-1.diff,v 1.1 1998/09/08 21:57:15 jochen Exp $ (LBL)
+.\"
+.\" This file has been slightly modified by NRL for use with IPv6+IPsec.
+.\" Search for INET6 and/or IPSEC to see the blocks where this happened.
+.\" See the NRL Copyright notice for conditions on the modifications.
+.\"
 .\"
 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
 .\"	The Regents of the University of California.  All rights reserved.
@@ -27,7 +32,7 @@
 .na
 .B tcpdump
 [
-.B \-adeflnNOpqStvx
+.B \-AadeflnNOpqStvx
 ] [
 .B \-c
 .I count
@@ -93,6 +98,12 @@
 You must have read access to
 .IR /dev/bpf* .
 .SH OPTIONS
+.TP
+.B \-A
+Print each packet (minus its link level header) in ASCII.
+The smaller of the entire packet or
+.I snaplen
+bytes will be printed.
 .TP
 .B \-a
 Attempt to convert network and broadcast addresses to names.
--- tcpdump.c	Sat Oct 18 16:49:56 1997
+++ tcpdump.c	Sat Feb 21 15:59:28 1998
@@ -1,4 +1,9 @@
 /*
+ * This file has been slightly modified by NRL for use with IPv6+IPsec.
+ * Search for INET6 and/or IPSEC to see the blocks where this happened.
+ * See the NRL Copyright notice for conditions on the modifications.
+ */
+/*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
  *
@@ -53,6 +58,7 @@
 #include "setsignal.h"
 #include "gmt2local.h"
 
+int Aflag;			/* print packet in ASCII */
 int aflag;			/* translate network and broadcast addresses */
 int dflag;			/* print filter code */
 int eflag;			/* print ethernet header */
@@ -89,6 +95,10 @@
 	int type;
 };
 
+#ifndef DLT_RAW
+#define DLT_RAW 12
+#endif /* DLT_RAW */
+
 static struct printer printers[] = {
 	{ ether_if_print,	DLT_EN10MB },
 	{ ether_if_print,	DLT_IEEE802 },
@@ -149,9 +159,13 @@
 
 	opterr = 0;
 	while (
-	    (op = getopt(argc, argv, "ac:defF:i:lnNOpqr:s:StT:vw:xY")) != EOF)
+	    (op = getopt(argc, argv, "Aac:defF:i:lnNOpqr:s:StT:vw:xY")) != EOF)
 		switch (op) {
 
+		case 'A':
+			++Aflag;
+			break;
+
 		case 'a':
 			++aflag;
 			break;
@@ -449,4 +463,61 @@
 	(void)fprintf(stderr,
 "\t\t[ -T type ] [ -w file ] [ expression ]\n");
 	exit(-1);
+}
+
+char *
+nice_char_print(char c)
+{
+	static char buf[3];
+
+	if (isprint(c)) {
+		buf[0] = ' ';
+		buf[1] = c;
+		goto ret;
+	}
+
+	if (iscntrl(c)) {
+		buf[0] = '^';
+		buf[1] = '@' + (char)c;
+		goto ret;
+	}
+
+	if (c == 127) {
+		buf[0] = '^';
+		buf[1] = '?';
+		goto ret;
+	}
+
+	buf[0] = '.';
+	buf[1] = '.';
+
+ret:
+	buf[2] = 0;
+	return buf;
+}
+
+/*
+ * Print buffer out as ASCII characters.  Alignment is not an issue.
+ */
+void
+ascii_print(register const u_char *bp, register int length)
+{
+  int i = 0, even = (length & 1)?length -1:length;
+
+  fputs("\n",stdout);
+  while (i < even) {
+    if ((i % 16) == 0) 
+      (void)printf("\n\t\t\t");
+    fputs(" ",stdout);
+    fputs(nice_char_print(*bp),stdout);
+    fputs(nice_char_print(*(bp+1)),stdout);
+    i += 2;
+    bp += 2;
+  }
+  if (length & 1) {
+    if ((i % 8) == 0)
+      (void)fputs("\n\t\t\t",stdout);
+    fputs(" ",stdout);
+    fputs(nice_char_print(*bp),stdout);
+  }
 }
