Upgrade to tcpdump 4.7.4.

Bug: http://b/24902618
Change-Id: I7c3605015d90453b0a8c339b1774e285796f8775
diff --git a/Android.mk b/Android.mk
index 436ff2f..bce0505 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,56 +1,172 @@
 LOCAL_PATH:= $(call my-dir)
+
+tcpdump_src_files := \
+  addrtoname.c \
+  af.c \
+  bpf_dump.c \
+  checksum.c \
+  cpack.c \
+  gmpls.c \
+  gmt2local.c \
+  in_cksum.c \
+  ipproto.c \
+  l2vpn.c \
+  machdep.c \
+  nlpid.c \
+  oui.c \
+  parsenfsfh.c \
+  print-802_11.c \
+  print-802_15_4.c \
+  print-ah.c \
+  print-ahcp.c \
+  print-aodv.c \
+  print-aoe.c \
+  print-ap1394.c \
+  print-arcnet.c \
+  print-arp.c \
+  print-ascii.c \
+  print-atalk.c \
+  print-atm.c \
+  print-babel.c \
+  print-beep.c \
+  print-bfd.c \
+  print-bgp.c \
+  print-bootp.c \
+  print-bt.c \
+  print-calm-fast.c \
+  print-carp.c \
+  print-cdp.c \
+  print-cfm.c \
+  print-chdlc.c \
+  print-cip.c \
+  print-cnfp.c \
+  print-dccp.c \
+  print-decnet.c \
+  print-dhcp6.c \
+  print-domain.c \
+  print-dtp.c \
+  print-dvmrp.c \
+  print-eap.c \
+  print-egp.c \
+  print-eigrp.c \
+  print-enc.c \
+  print-esp.c \
+  print-ether.c \
+  print-fddi.c \
+  print-forces.c \
+  print-frag6.c \
+  print-fr.c \
+  print-ftp.c \
+  print-geneve.c \
+  print-geonet.c \
+  print-gre.c \
+  print-hsrp.c \
+  print-http.c \
+  print-icmp6.c \
+  print-icmp.c \
+  print-igmp.c \
+  print-igrp.c \
+  print-ip6.c \
+  print-ip6opts.c \
+  print-ip.c \
+  print-ipcomp.c \
+  print-ipfc.c \
+  print-ipnet.c \
+  print-ipx.c \
+  print-isakmp.c \
+  print-isoclns.c \
+  print-juniper.c \
+  print-krb.c \
+  print-l2tp.c \
+  print-lane.c \
+  print-ldp.c \
+  print-llc.c \
+  print-lldp.c \
+  print-lmp.c \
+  print-loopback.c \
+  print-lspping.c \
+  print-lwapp.c \
+  print-lwres.c \
+  print-m3ua.c \
+  print-mobile.c \
+  print-mobility.c \
+  print-mpcp.c \
+  print-mpls.c \
+  print-mptcp.c \
+  print-msdp.c \
+  print-msnlb.c \
+  print-nflog.c \
+  print-nfs.c \
+  print-ntp.c \
+  print-null.c \
+  print-olsr.c \
+  print-openflow-1.0.c \
+  print-openflow.c \
+  print-ospf6.c \
+  print-ospf.c \
+  print-otv.c \
+  print-pgm.c \
+  print-pim.c \
+  print-pktap.c \
+  print-ppi.c \
+  print-ppp.c \
+  print-pppoe.c \
+  print-pptp.c \
+  print-radius.c \
+  print-raw.c \
+  print-rip.c \
+  print-ripng.c \
+  print-rpki-rtr.c \
+  print-rrcp.c \
+  print-rsvp.c \
+  print-rt6.c \
+  print-rtsp.c \
+  print-rx.c \
+  print-sctp.c \
+  print-sflow.c \
+  print-sip.c \
+  print-sl.c \
+  print-sll.c \
+  print-slow.c \
+  print-smb.c \
+  print-smtp.c \
+  print-snmp.c \
+  print-stp.c \
+  print-sunatm.c \
+  print-sunrpc.c \
+  print-symantec.c \
+  print-syslog.c \
+  print-tcp.c \
+  print-telnet.c \
+  print-tftp.c \
+  print-timed.c \
+  print-tipc.c \
+  print-token.c \
+  print-udld.c \
+  print-udp.c \
+  print-usb.c \
+  print-vjc.c \
+  print-vqp.c \
+  print-vrrp.c \
+  print-vtp.c \
+  print-vxlan.c \
+  print-wb.c \
+  print-zephyr.c \
+  print-zeromq.c \
+  setsignal.c \
+  signature.c \
+  smbutil.c \
+  tcpdump.c \
+  util.c \
+  version.c \
+
 include $(CLEAR_VARS)
-
-tcpdump_CSRC =	addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
-        nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
-	print-802_11.c print-802_15_4.c print-ap1394.c print-ah.c \
-	print-arcnet.c print-aodv.c print-arp.c print-ascii.c print-atalk.c \
-	print-atm.c print-beep.c print-bfd.c print-bgp.c \
-	print-bootp.c print-bt.c print-calm-fast.c print-carp.c print-cdp.c print-cfm.c \
-	print-chdlc.c print-cip.c print-cnfp.c print-dccp.c print-decnet.c \
-	print-domain.c print-dtp.c print-dvmrp.c print-enc.c print-egp.c \
-	print-eap.c print-eigrp.c\
-	print-esp.c print-ether.c print-fddi.c print-forces.c print-fr.c \
-	print-geonet.c print-gre.c print-hsrp.c print-icmp.c print-igmp.c \
-	print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c print-ipnet.c \
-	print-ipx.c print-isoclns.c print-juniper.c print-krb.c \
-	print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \
-        print-lmp.c print-lspping.c print-lwapp.c \
-	print-lwres.c print-mobile.c print-mpcp.c print-mpls.c print-mptcp.c print-msdp.c \
-	print-msnlb.c print-nflog.c print-nfs.c print-ntp.c print-null.c \
-	print-olsr.c print-openflow.c print-openflow-1.0.c print-ospf.c \
-	print-pgm.c print-pim.c \
-	print-ppi.c print-ppp.c print-pppoe.c print-pptp.c \
-	print-radius.c print-raw.c print-rip.c print-rpki-rtr.c print-rrcp.c print-rsvp.c \
-	print-rx.c print-sctp.c print-sflow.c print-sip.c print-sl.c print-sll.c \
-	print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \
-	print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
-	print-timed.c print-tipc.c print-token.c print-udld.c print-udp.c \
-	print-usb.c print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \
-	print-wb.c print-zephyr.c print-zeromq.c print-vxlan.c print-otv.c signature.c setsignal.c tcpdump.c util.c
-
-tcpdump_LIBNETDISSECT_SRC=print-isakmp.c
-tcpdump_LOCALSRC = print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c print-smb.c smbutil.c 
-tcpdump_GENSRC = version.c
-
-LOCAL_SRC_FILES:=\
-	$(tcpdump_CSRC) $(tcpdump_LIBNETDISSECT_SRC) $(tcpdump_LOCALSRC) $(tcpdump_GENSRC)
-
-LOCAL_CFLAGS := -O2 -g
-LOCAL_CFLAGS += -DHAVE_CONFIG_H -D_U_="__attribute__((unused))"
-
-LOCAL_C_INCLUDES += \
-	$(LOCAL_PATH)/missing\
-	external/libpcap
-
+LOCAL_SRC_FILES := $(tcpdump_src_files)
+LOCAL_CFLAGS += -DHAVE_CONFIG_H
+LOCAL_CFLAGS += -D_U_="__attribute__((unused))"
 LOCAL_SHARED_LIBRARIES += libssl libcrypto
-
 LOCAL_STATIC_LIBRARIES += libpcap
-
 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-
 LOCAL_MODULE_TAGS := debug
-
 LOCAL_MODULE := tcpdump
-
 include $(BUILD_EXECUTABLE)
diff --git a/CHANGES b/CHANGES
index ee2efa4..38769f2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,58 @@
+Friday April 10, 2015 guy@alum.mit.edu
+  Summary for 4.7.4 tcpdump release
+	RPKI to Router Protocol: Fix Segmentation Faults and other problems
+	RPKI to Router Protocol: print strings with fn_printn()
+	wb: fix some bounds checks
+
+Wednesday March 11, 2015 mcr@sandelman.ca
+  Summary for 4.7.3 tcpdump release
+	Capsicum fixes for FreeBSD 10
+
+Tuesday March 10, 2015 mcr@sandelman.ca
+  Summary for 4.7.2 tcpdump release
+	DCCP: update Packet Types with RFC4340/IANA names
+        fixes for CVE-2015-0261: IPv6 mobility header check issue
+        fixes for CVE-2015-2153, 2154, 2155: kday packets
+
+Friday Nov. 12, 2014 guy@alum.mit.edu
+  Summary for 4.7.0 tcpdump release
+        changes to hex printing of CDP packets
+	Fix PPI printing
+	Radius: update Packet Type Codes and Attribute Types with RFC/IANA names
+	Add a routine to print "text protocols", and add FTP/HTTP/SMTP/RTSP support.
+	improvements to telnet printer, even if not -v
+	omit length for bcp, print-tcp uses it
+	formatting fixes for a bunch of protocols
+	new bounds checks for a number of protocols
+	split netflow 1,6, and 6 dissector up.
+	added geneve dissector
+        CVE-2014-9140 PPP dissector fixed.
+
+Tuesday  Sep.  2, 2014 mcr@sandelman.ca
+  Summary for 4.6.2 tcpdump release
+	fix out-of-source-tree builds: find libpcap that is out of source
+	better configure check for libsmi
+
+Saturday Jul. 19, 2014 mcr@sandelman.ca
+  Summary for 4.6.1 tcpdump release
+	added FreeBSD capsicum
+	add a short option '#', same as long option '--number'
+
+Wednesday Jul. 2, 2014 mcr@sandelman.ca
+  Summary for 4.6.0 tcpdump release
+        all of tcpdump is now using the new "NDO" code base (Thanks Denis!)
+        nflog, mobile, forces, pptp, AODV, AHCP, IPv6, OSPFv4, RPL, DHCPv6 enhancements/fixes
+        M3UA decode added.
+        many new test cases: 82 in 4.5.1 to 133 in 4.6.0
+        many improvements to travis continuous integration system: OSX, and Coverity options
+        cleaned up some unnecessary header files
+        Added bittok2str().
+        a number of unaligned access faults fixed
+        -A flag does not consider CR to be printable anymore
+        fx.lebail took over coverity baby sitting
+        default snapshot size increased to 256K for accomodate USB captures
+        WARNING: this release contains a lot of very worthwhile code churn.
+
 Wednesday Jan. 15, 2014 guy@alum.mit.edu
   Summary for 4.5.2 tcpdump release
 	Man page fix
@@ -9,7 +64,7 @@
 
 Thursday Nov. 7, 2013  mcr@sandelman.ca and guy@alum.mit.edu.
   Summary for 4.5.0 tcpdump release
-        some NFSv4 fixes for printing  
+        some NFSv4 fixes for printing
         fix printing of unknown TCP options, and tcp fast-open
         fixes for syslog parser
         some gcc-version-specific flag tuning
@@ -148,7 +203,7 @@
   Summary for 4.1.1 tcpdump release
 	Fix build on systems with PF, such as FreeBSD and OpenBSD.
 	Don't blow up if a zero-length link-layer address is passed to
-	  linkaddr_string(). 
+	  linkaddr_string().
 
 Thu.	March 11, 2010.  ken@netfunctional.ca/guy@alum.mit.edu.
   Summary for 4.1.0 tcpdump release
@@ -177,7 +232,7 @@
 	Add printer for ForCES
 	Handle frames with an FCS
 	Handle 802.11n Control Wrapper, Block Acq Req and Block Ack frames
-	Fix TCP sequence number printing 
+	Fix TCP sequence number printing
 	Report 802.2 packets as 802.2 instead of 802.3
 	Don't include -L/usr/lib in LDFLAGS
 	On x86_64 Linux, look in lib64 directory too
@@ -213,13 +268,13 @@
         Converted print-isakmp.c to NETDISSECT
         Moved AF specific stuff into af.h
         Test subsystem now table driven, and saves outputs and diffs to one place
-        Require <net/pfvar.h> for pf definitions - allows reading of pflog formatted 
+        Require <net/pfvar.h> for pf definitions - allows reading of pflog formatted
          libpcap files on an OS other than where the file was generated
 
 
 Wed.	July 23, 2007.  mcr@xelerance.com.  Summary for 3.9.7 libpcap release
 
-    	NFS: Print unsigned values as such. 
+    	NFS: Print unsigned values as such.
 	RX: parse safely.
 	BGP: fixes for IPv6-less builds.
 	801.1ag: use standard codepoint.
@@ -229,7 +284,7 @@
 	smb: squelch an uninitialized complaint from coverity.
 	NFS: from NetBSD; don't interpret the reply as a possible NFS reply
 		if it got MSG_DENIED.
-	BGP: don't print TLV values that didn't fit, from www.digit-labs.org. 
+	BGP: don't print TLV values that didn't fit, from www.digit-labs.org.
 	revised INSTALL.txt about libpcap dependancy.
 
 Wed.	April 25, 2007. ken@xelerance.com.  Summary for 3.9.6 tcpdump release
@@ -247,11 +302,11 @@
 	Add support for 802.3ah loopback ctrl msg
 	Add support for Multiple-STP as per 802.1s
 	Add support for rapid-SPT as per 802.1w
-	Add support for CFM Link-trace msg, Link-trace-Reply msg, 
+	Add support for CFM Link-trace msg, Link-trace-Reply msg,
 	 Sender-ID tlv, private tlv, port, interface status
 	Add support for unidirectional link detection as per
 	 http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt
-	Add support for the olsr protocol as per RFC 3626 plus the LQ 
+	Add support for the olsr protocol as per RFC 3626 plus the LQ
 	 extensions from olsr.org
 	Add support for variable-length checksum in DCCP, as per section 9 of
 	 RFC 4340.
@@ -263,7 +318,7 @@
 
 
 Tue.	September 19, 2006. ken@xelerance.com. Summary for 3.9.5 tcpdump release
-	
+
 	Fix compiling on AIX (, at end of ENUM)
 	Updated list of DNS RR typecodes
 	Use local Ethernet defs on WIN32
@@ -278,7 +333,7 @@
 	Add support for BGP signaled VPLS
 	Cleanup the bootp printer
 	Add support for PPP over Frame-Relay
-	Add some bounds checking to the IP options code, and clean up 
+	Add some bounds checking to the IP options code, and clean up
 	 the options output a bit.
 	Add additional modp groups to ISAKMP printer
 	Add support for Address-Withdraw and Label-Withdraw Msgs
diff --git a/CREDITS b/CREDITS
index 2abe0fa..a21311a 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2,11 +2,12 @@
 
 The current maintainers:
     Bill Fenner                   <fenner at research dot att dot com>
-    Denis Ovsienko                <infrastation at yandex dot ru>
+    Denis Ovsienko                <denis at ovsienko dot info>
     Fulvio Risso                  <risso at polito dot it>
     Guy Harris                    <guy at alum dot mit dot edu>
     Hannes Gredler                <hannes at juniper dot net>
     Michael Richardson            <mcr at sandelman dot ottawa dot on dot ca>
+    Francois-Xavier Le Bail       <fx dot lebail at yahoo dot com>
 
 Additional people who have contributed patches:
 
@@ -28,6 +29,7 @@
     Armando L. Caro Jr.           <acaro at mail dot eecis dot udel dot edu>
     Arnaldo Carvalho de Melo      <acme at ghostprotocols dot net>
     Atsushi Onoe                  <onoe at netbsd dot org>
+    Baptiste Jonglez              <baptiste dot jonglez at ens-lyon dot org>
     Ben Byer                      <bushing at sourceforge dot net>
     Ben Smithurst                 <ben at scientia dot demon dot co dot uk>
     Bert Vermeulen                <bert at biot dot com>
@@ -66,7 +68,6 @@
     Francesco Fondelli            <francesco dot fondelli at gmail dot com>
     Francisco Matias Cuenca-Acuna <mcuenca at george dot rutgers dot edu>
     Francis Dupont                <Francis dot Dupont at enst-bretagne dot fr>
-    Francois-Xavier Le Bail       <fx dot lebail at yahoo dot com>
     Frank Volf                    <volf at oasis dot IAEhv dot nl>
     Fulvio Risso                  <risso at polito dot it>
     George Bakos                  <gbakos at ists dot dartmouth dot edu>
@@ -74,7 +75,7 @@
     Gerrit Renker                 <gerrit at erg dot abdn dot ac dot uk>
     Gert Doering                  <gert at greenie dot muc dot de>
     Gilbert Ramirez Jr.           <gram at xiexie dot org>
-    Gisle Vanem                   <gvanem at broadpark dot no>
+    Gisle Vanem                   <gvanem at yahoo dot no>
     Greg Minshall                 <minshall at acm dot org>
     Grégoire Henry                <henry at pps dot jussieu dot fr>
     Gregory Detal                 <gregory dot detal at uclouvain dot be>
@@ -84,6 +85,7 @@
     Harry Raaymakers              <harryr at connect dot com dot au>
     Heinz-Ado Arnolds             <Ado dot Arnolds at dhm-systems dot de>
     Hendrik Scholz                <hendrik at scholz dot net>
+    Herwin Weststrate             <herwin at quarantainenet dot nl>
     Ian McDonald                  <imcdnzl at gmail dot com>
     Ilpo Järvinen                 <ilpo dot jarvinen at helsinki dot fi>
     Jacek Tobiasz                 <Jacek dot Tobiasz at atm dot com dot pl>
@@ -94,6 +96,7 @@
     Jefferson Ogata               <jogata at nodc dot noaa dot gov>
     Jeffrey Hutzelman             <jhutz at cmu dot edu>
     Jesper Peterson               <jesper at endace dot com>
+    Jesse Gross                   <jesse at nicira dot com>
     Jim Hutchins                  <jim at ca dot sandia dot gov>
     João Medeiros                 <ignotus21 at sourceforge dot net>
     Joerg Mayer                   <jmayer at loplof dot de>
@@ -115,6 +118,7 @@
     Krzysztof Halasa              <khc at pm dot waw dot pl>
     Larry Lile                    <lile at stdio dot com>
     Lennert Buytenhek             <buytenh at gnu dot org>
+    Loganaden Velvindron          <logan at elandsys dot com>
     Longinus00                    <Longinus00 at gmail dot com>
     Loris Degioanni               <loris at netgroup-serv dot polito dot it>
     Love Hörnquist-Åstrand        <lha at stacken dot kth dot se>
@@ -194,6 +198,7 @@
     Steinar Haug                  <sthaug at nethelp dot no>
     Stephane Bortzmeyer           <stephane+github at bortzmeyer dot org>
     Swaminathan Chandrasekaran    <chander at juniper dot net>
+    Swaathi Vetrivel              <swaathiv at juniper dot net>
     Takashi Yamamoto              <yamt at mwd dot biglobe dot ne dot jp>
     Tatuya Jinmei                 <jinmei at kame dot net>
     Terry Kennedy                 <terry at tmk dot com>
@@ -204,6 +209,7 @@
     Udayakumar                    <udaya011 at gmail dot com>
     Uns Lider                     <unslider at miranda dot org>
     Victor Oppleman               <oppleman at users dot sourceforge dot net>
+    Vyacheslav Trushkin           <dogonthesun at gmail dot com>
     Weesan Lee                    <weesan at juniper dot net>
     Wesley Griffin                <wgriffin at users dot sourceforge dot net>
     Wesley Shields                <wxs at FreeBSD dot org>
diff --git a/INSTALL.txt b/INSTALL.txt
index a03e2c0..dcb52b8 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -1,5 +1,3 @@
-@(#) $Header: /tcpdump/master/tcpdump/INSTALL.txt,v 1.2 2008-02-06 10:47:53 guy Exp $ (LBL)
-
 If you have not built libpcap, and your system does not have libpcap
 installed, install libpcap first.  Your system might provide a version
 of libpcap that can be installed; if so, to compile tcpdump you might
@@ -9,9 +7,7 @@
 
 You will need an ANSI C compiler to build tcpdump. The configure script
 will abort if your compiler is not ANSI compliant. If this happens, use
-the GNU C compiler, available via anonymous ftp:
-
-	ftp://ftp.gnu.org/pub/gnu/gcc/
+the generally available GNU C compiler (GCC).
 
 After libpcap has been built (either install it with "make install" or
 make sure both the libpcap and tcpdump source trees are in the same
@@ -42,26 +38,20 @@
 -----
 CHANGES		- description of differences between releases
 CREDITS		- people that have helped tcpdump along
-FILES		- list of files exported as part of the distribution
 INSTALL.txt	- this file
 LICENSE		- the license under which tcpdump is distributed
 Makefile.in	- compilation rules (input to the configure script)
 README		- description of distribution
 Readme.Win32	- notes on building tcpdump on Win32 systems (with WinPcap)
 VERSION		- version of this release
-acconfig.h	- autoconf input
 aclocal.m4	- autoconf macros
 addrtoname.c	- address to hostname routines
 addrtoname.h	- address to hostname definitions
 ah.h		- IPSEC Authentication Header definitions
-aodv.h		- AODV definitions
 appletalk.h	- AppleTalk definitions
-arcnet.h	- ARCNET definitions
 atime.awk	- TCP ack awk script
 atm.h		- ATM traffic type definitions
 atmuni31.h	- ATM Q.2931 definitions
-bgp.h		- BGP declarations
-bootp.h		- BOOTP definitions
 bpf_dump.c	- BPF program printing routines, in case libpcap doesn't
 		  have them
 chdlc.h		- Cisco HDLC definitions
@@ -72,37 +62,21 @@
 config.sub	- autoconf support
 configure	- configure script (run this first)
 configure.in	- configure script source
-dccp.h		- DCCP definitions
-decnet.h	- DECnet definitions
-decode_prefix.h	- Declarations of "decode_prefix{4,6}()"
-enc.h		- OpenBSD IPsec encapsulation BPF layer definitions
-esp.h		- IPSEC Encapsulating Security Payload definitions
 ether.h		- Ethernet definitions
 ethertype.h	- Ethernet type value definitions
 extract.h	- alignment definitions
-fddi.h		- Fiber Distributed Data Interface definitions
 gmpls.c		- GMPLS definitions
 gmpls.h		- GMPLS declarations
 gmt2local.c	- time conversion routines
 gmt2local.h	- time conversion prototypes
-icmp6.h		- ICMPv6 definitiions
-ieee802_11.h	- IEEE 802.11 definitions
-ieee802_11_radio.h - radiotap header definitions
-igrp.h		- Interior Gateway Routing Protocol definitions
 install-sh	- BSD style install script
 interface.h	- globals, prototypes and definitions
 ip.h		- IP definitions
 ip6.h		- IPv6 definitions
-ipfc.h		- IP-over-Fibre Channel definitions
 ipproto.c	- IP protocol type value-to-name table
 ipproto.h	- IP protocol type value definitions
-ipsec_doi.h	- ISAKMP packet definitions - RFC2407
-ipx.h		- IPX definitions
-isakmp.h	- ISAKMP packet definitions - RFC2408
 l2vpn.c		- L2VPN encapsulation value-to-name table
 l2vpn.h		- L2VPN encapsulation definitions
-l2tp.h		- Layer Two Tunneling Protocol definitions
-lane.h		- ATM LANE definitions
 lbl/os-*.h	- OS-dependent defines and prototypes
 llc.h		- LLC definitions
 machdep.c	- machine dependent routines
@@ -113,23 +87,18 @@
 mkdep		- construct Makefile dependency list
 mpls.h		- MPLS definitions
 nameser.h	- DNS definitions
-netbios.h	- NETBIOS definitions
 netdissect.h	- definitions and declarations for tcpdump-as-library
 		  (under development)
 nfs.h		- Network File System V2 definitions
 nfsfh.h		- Network File System file handle definitions
 nlpid.c		- OSI NLPID value-to-name table
 nlpid.h		- OSI NLPID definitions
-ntp.h		- Network Time Protocol definitions
-oakley.h	- ISAKMP packet definitions - RFC2409
 ospf.h		- Open Shortest Path First definitions
-ospf6.h		- IPv6 Open Shortest Path First definitions
 packetdat.awk	- TCP chunk summary awk script
 parsenfsfh.c	- Network File System file parser routines
 pcap_dump_ftell.c - pcap_dump_ftell() implementation, in case libpcap
 		doesn't have it
 pcap-missing.h	- declarations of functions possibly missing from libpcap
-pmap_prot.h	- definitions for ONC RPC portmapper protocol
 ppp.h		- Point to Point Protocol definitions
 print-802_11.c	- IEEE 802.11 printer routines
 print-ap1394.c	- Apple IP-over-IEEE 1394 printer routines
@@ -184,7 +153,6 @@
 print-mobility.c - IPv6 mobility printer routines
 print-mpls.c	- Multi-Protocol Label Switching printer routines
 print-msdp.c	- Multicast Source Discovery Protocol printer routines
-print-netbios.c	- NetBIOS frame protocol printer routines
 print-nfs.c	- Network File System printer routines
 print-ntp.c	- Network Time Protocol printer routines
 print-null.c	- BSD loopback device printer routines
@@ -226,18 +194,12 @@
 print-vrrp.c	- Virtual Router Redundancy Protocol
 print-wb.c	- White Board printer routines
 print-zephyr.c	- Zephyr printer routines
-route6d.h	- packet definition for IPv6 Routing Information Protocol
 rpc_auth.h	- definitions for ONC RPC authentication
 rpc_msg.h	- definitions for ONC RPC messages
-rx.h		- AFS RX definitions
-sctpConstants.h	- Stream Control Transmission Protocol constant definitions
-sctpHeader.h	- Stream Control Transmission Protocol packet definitions
 send-ack.awk	- unidirectional tcp send/ack awk script
 setsignal.c	- OS-independent signal routines
 setsignal.h	- OS-independent signal prototypes
 slcompress.h	- SLIP/PPP Van Jacobson compression (RFC1144) definitions
-slip.h		- SLIP definitions
-sll.h		- Linux "cooked" capture definitions
 smb.h		- SMB/CIFS definitions
 smbutil.c	- SMB/CIFS utility routines
 stime.awk	- TCP send awk script
@@ -245,10 +207,6 @@
 tcp.h		- TCP definitions
 tcpdump.1	- manual entry
 tcpdump.c	- main program
-telnet.h	- Telnet definitions
-tftp.h		- TFTP definitions
-timed.h		- BSD time daemon protocol definitions
-token.h		- Token Ring definitions
 udp.h		- UDP definitions
 util.c		- utility routines
 vfprintf.c	- emulation routine
diff --git a/MODULE_LICENSE_BSD b/MODULE_LICENSE_BSD
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_BSD
+++ /dev/null
diff --git a/Makefile.in b/Makefile.in
index eb27a7a..a0dc559 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -16,8 +16,6 @@
 #  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.
-#
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.325 2008-11-21 23:17:26 guy Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -41,6 +39,7 @@
 #
 
 CC = @CC@
+AR = @AR@
 MKDEP = @MKDEP@
 PROG = tcpdump
 CCOPT = @V_CCOPT@
@@ -71,127 +70,209 @@
 	@rm -f $@
 	$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
 
-CSRC =	addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
-        nlpid.c l2vpn.c machdep.c parsenfsfh.c in_cksum.c \
-	print-802_11.c print-802_15_4.c print-ap1394.c print-ah.c \
-	print-arcnet.c print-aodv.c print-arp.c print-ascii.c print-atalk.c \
-	print-atm.c print-beep.c print-bfd.c print-bgp.c \
-	print-bootp.c print-bt.c print-calm-fast.c print-carp.c print-cdp.c print-cfm.c \
-	print-chdlc.c print-cip.c print-cnfp.c print-dccp.c print-decnet.c \
-	print-domain.c print-dtp.c print-dvmrp.c print-enc.c print-egp.c \
-	print-eap.c print-eigrp.c\
-	print-esp.c print-ether.c print-fddi.c print-forces.c print-fr.c \
-	print-geonet.c print-gre.c print-hsrp.c print-icmp.c print-igmp.c \
-	print-igrp.c print-ip.c print-ipcomp.c print-ipfc.c print-ipnet.c \
-	print-ipx.c print-isoclns.c print-juniper.c print-krb.c \
-	print-l2tp.c print-lane.c print-ldp.c print-lldp.c print-llc.c \
-        print-lmp.c print-lspping.c print-lwapp.c \
-	print-lwres.c print-mobile.c print-mpcp.c print-mpls.c print-mptcp.c print-msdp.c \
-	print-msnlb.c print-nflog.c print-nfs.c print-ntp.c print-null.c \
-	print-olsr.c print-openflow.c print-openflow-1.0.c print-ospf.c \
-	print-pgm.c print-pim.c \
-	print-ppi.c print-ppp.c print-pppoe.c print-pptp.c \
-	print-radius.c print-raw.c print-rip.c print-rpki-rtr.c print-rrcp.c print-rsvp.c \
-	print-rx.c print-sctp.c print-sflow.c print-sip.c print-sl.c print-sll.c \
-	print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \
-	print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \
-	print-timed.c print-tipc.c print-token.c print-udld.c print-udp.c \
-	print-usb.c print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \
-	print-wb.c print-zephyr.c print-zeromq.c print-vxlan.c print-otv.c signature.c setsignal.c tcpdump.c util.c
+CSRC =	setsignal.c tcpdump.c
 
-LIBNETDISSECT_SRC=print-isakmp.c
-LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o)
-LIBNETDISSECT=libnetdissect.a
+LIBNETDISSECT_SRC=\
+	addrtoname.c \
+	af.c \
+	checksum.c \
+	cpack.c \
+	gmpls.c \
+	gmt2local.c \
+	in_cksum.c \
+	ipproto.c \
+	l2vpn.c \
+	machdep.c \
+	nlpid.c \
+	oui.c \
+	parsenfsfh.c \
+	print-802_11.c \
+	print-802_15_4.c \
+	print-ah.c \
+	print-ahcp.c \
+	print-aodv.c \
+	print-aoe.c \
+	print-ap1394.c \
+	print-arcnet.c \
+	print-arp.c \
+	print-ascii.c \
+	print-atalk.c \
+	print-atm.c \
+	print-beep.c \
+	print-bfd.c \
+	print-bgp.c \
+	print-bootp.c \
+	print-bt.c \
+	print-calm-fast.c \
+	print-carp.c \
+	print-cdp.c \
+	print-cfm.c \
+	print-chdlc.c \
+	print-cip.c \
+	print-cnfp.c \
+	print-dccp.c \
+	print-decnet.c \
+	print-domain.c \
+	print-dtp.c \
+	print-dvmrp.c \
+	print-eap.c \
+	print-egp.c \
+	print-eigrp.c \
+	print-enc.c \
+	print-esp.c \
+	print-ether.c \
+	print-fddi.c \
+	print-forces.c \
+	print-fr.c \
+	print-ftp.c \
+	print-geneve.c \
+	print-geonet.c \
+	print-gre.c \
+	print-hsrp.c \
+	print-http.c \
+	print-icmp.c \
+	print-igmp.c \
+	print-igrp.c \
+	print-ip.c \
+	print-ip6.c \
+	print-ipcomp.c \
+	print-ipfc.c \
+	print-ipnet.c \
+	print-ipx.c \
+	print-isakmp.c \
+	print-isoclns.c \
+	print-juniper.c \
+	print-krb.c \
+	print-l2tp.c \
+	print-lane.c \
+	print-ldp.c \
+	print-llc.c \
+	print-lldp.c \
+	print-lmp.c \
+	print-loopback.c \
+	print-lspping.c \
+	print-lwapp.c \
+	print-lwres.c \
+	print-m3ua.c \
+	print-mobile.c \
+	print-mpcp.c \
+	print-mpls.c \
+	print-mptcp.c \
+	print-msdp.c \
+	print-msnlb.c \
+	print-nflog.c \
+	print-nfs.c \
+	print-ntp.c \
+	print-null.c \
+	print-olsr.c \
+	print-openflow-1.0.c \
+	print-openflow.c \
+	print-ospf.c \
+	print-otv.c \
+	print-pgm.c \
+	print-pim.c \
+	print-pktap.c \
+	print-ppi.c \
+	print-ppp.c \
+	print-pppoe.c \
+	print-pptp.c \
+	print-radius.c \
+	print-raw.c \
+	print-rip.c \
+	print-rpki-rtr.c \
+	print-rrcp.c \
+	print-rsvp.c \
+	print-rtsp.c \
+	print-rx.c \
+	print-sctp.c \
+	print-sflow.c \
+	print-sip.c \
+	print-sl.c \
+	print-sll.c \
+	print-slow.c \
+	print-smtp.c \
+	print-snmp.c \
+	print-stp.c \
+	print-sunatm.c \
+	print-sunrpc.c \
+	print-symantec.c \
+	print-syslog.c \
+	print-tcp.c \
+	print-telnet.c \
+	print-tftp.c \
+	print-timed.c \
+	print-tipc.c \
+	print-token.c \
+	print-udld.c \
+	print-udp.c \
+	print-usb.c \
+	print-vjc.c \
+	print-vqp.c \
+	print-vrrp.c \
+	print-vtp.c \
+	print-vxlan.c \
+	print-wb.c \
+	print-zephyr.c \
+	print-zeromq.c \
+	signature.c \
+	util.c
 
 LOCALSRC = @LOCALSRC@
 GENSRC = version.c
 LIBOBJS = @LIBOBJS@
 
+LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${LOCALSRC:.c=.o} ${LIBOBJS}
+LIBNETDISSECT=libnetdissect.a
+
+
 SRC =	$(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
 
 # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
 # hack the extra indirection
-OBJ =	$(CSRC:.c=.o) $(GENSRC:.c=.o) $(LOCALSRC:.c=.o) $(LIBOBJS) $(LIBNETDISSECT_OBJ)
+OBJ =	$(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
 HDR = \
 	addrtoname.h \
 	af.h \
 	ah.h \
-	aodv.h \
 	appletalk.h \
-	arcnet.h \
 	atm.h \
 	atmuni31.h \
-	bootp.h \
-	bgp.h \
 	chdlc.h \
 	cpack.h \
-	dccp.h \
-	decnet.h \
-	decode_prefix.h \
-	enc.h \
-	esp.h \
 	ether.h \
 	ethertype.h \
 	extract.h \
-	fddi.h \
+	getopt_long.h \
 	gmpls.h \
 	gmt2local.h \
-	icmp6.h \
-	ieee802_11.h \
-	ieee802_11_radio.h \
-	igrp.h \
-	interface.h \
 	interface.h \
 	ip.h \
 	ip6.h \
-	ipfc.h \
-	ipnet.h \
 	ipproto.h \
-	ipsec_doi.h \
-	ipx.h \
-	isakmp.h \
-	l2tp.h \
 	l2vpn.h \
-	lane.h \
 	llc.h \
 	machdep.h \
 	mib.h \
 	mpls.h \
-	mptcp.h \
 	nameser.h \
-	netbios.h \
 	netdissect.h \
 	nfs.h \
 	nfsfh.h \
 	nlpid.h \
-	ntp.h \
-	oakley.h \
 	openflow.h \
 	ospf.h \
-	ospf6.h \
 	oui.h \
 	pcap-missing.h \
-	pmap_prot.h \
-	ppi.h \
 	ppp.h \
-	route6d.h \
 	rpc_auth.h \
 	rpc_msg.h \
-	rx.h \
-	sctpConstants.h \
-	sctpHeader.h \
+	rpl.h \
 	setsignal.h \
 	signature.h \
 	slcompress.h \
-	slip.h \
-	sll.h \
 	smb.h \
 	tcp.h \
 	tcpdump-stdinc.h \
-	telnet.h \
-	tftp.h \
-	timed.h \
-	token.h \
 	udp.h
 
 TAGHDR = \
@@ -237,11 +318,11 @@
 	missing/dlnames.c \
 	missing/datalinks.c \
 	missing/getnameinfo.c \
+	missing/getopt_long.c \
 	missing/inet_aton.c \
 	missing/inet_ntop.c \
 	missing/inet_pton.c \
 	missing/snprintf.c \
-	missing/sockstorage.h \
 	missing/strdup.c \
 	missing/strlcat.c \
 	missing/strlcpy.c \
@@ -253,10 +334,8 @@
 	print-dhcp6.c \
 	print-frag6.c \
 	print-icmp6.c \
-	print-ip6.c \
 	print-ip6opts.c \
 	print-mobility.c \
-	print-netbios.c \
 	print-ospf6.c \
 	print-pflog.c \
 	print-ripng.c \
@@ -268,18 +347,14 @@
 	strcasecmp.c \
 	tcpdump.1.in \
 	vfprintf.c \
-	win32/Include/bittypes.h \
-	win32/Include/errno.h \
-	win32/Include/getopt.h \
 	win32/Include/w32_fzs.h \
-	win32/Src/getopt.c \
 	win32/prj/GNUmakefile \
 	win32/prj/WinDump.dsp \
 	win32/prj/WinDump.dsw
 
 TEST_DIST= `find tests \( -name 'DIFF' -prune \) -o \( -name NEW -prune \) -o -type f \! -name '.*' \! -name '*~' -print`
 
-all: $(PROG)
+all: $(PROG) $(LIBNETDISSECT)
 
 $(PROG): $(OBJ) @V_PCAPDEP@
 	@rm -f $@
@@ -287,7 +362,7 @@
 
 $(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
 	@rm -f $@
-	$(AR) cr $@ $(LIBNETDISSECT_OBJ) 
+	$(AR) cr $@ $(LIBNETDISSECT_OBJ)
 	$(RANLIB) $@
 
 datalinks.o: $(srcdir)/missing/datalinks.c
@@ -296,8 +371,8 @@
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
 getnameinfo.o: $(srcdir)/missing/getnameinfo.c
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
-getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c
-	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getaddrinfo.c
+getopt_long.o: $(srcdir)/missing/getopt_long.c
+	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
 inet_pton.o: $(srcdir)/missing/inet_pton.c
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
 inet_ntop.o: $(srcdir)/missing/inet_ntop.c
@@ -306,6 +381,8 @@
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
 snprintf.o: $(srcdir)/missing/snprintf.c
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
+strdup.o: $(srcdir)/missing/strdup.c
+	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strdup.c
 strlcat.o: $(srcdir)/missing/strlcat.c
 	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
 strlcpy.o: $(srcdir)/missing/strlcpy.c
@@ -349,8 +426,10 @@
 
 distclean:
 	rm -f $(CLEANFILES) Makefile config.cache config.log config.status \
-	    config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1
-	rm -rf autom4te.cache
+	    config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1 \
+	    libnetdissect.a tests/.failed tests/.passed \
+	    tests/failure-outputs.txt
+	rm -rf autom4te.cache tests/DIFF tests/NEW
 
 check: tcpdump
 	(cd tests && ./TESTrun.sh)
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index dea5f7d..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,19 +0,0 @@
-License: BSD
- 
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-  
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
-  2. 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.
-  3. The names of the authors may not 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.
diff --git a/PLATFORMS b/PLATFORMS
deleted file mode 100644
index 03bfed7..0000000
--- a/PLATFORMS
+++ /dev/null
@@ -1,9 +0,0 @@
-== Tested platforms ==
-NetBSD 		  5.1/i386	(mcr - 2012/4/1)	
-Debian Linux (squeeze/i386)	(mcr - 2012/4/1)
-
----
-RedHat Linux 	6.1/i386	(assar)
-FreeBSD		2.2.8/i386	(itojun)
-
-
diff --git a/README.md b/README.md
index e9fd5a8..c83ffab 100644
--- a/README.md
+++ b/README.md
@@ -61,7 +61,7 @@
 Some tools for viewing and analyzing tcpdump trace files are available
 from the Internet Traffic Archive:
 
-* http://www.acm.org/sigcomm/ITA/
+* http://www.sigcomm.org/ITA/
 
 Another tool that tcpdump users might find useful is tcpslice:
 
diff --git a/TODO b/TODO
deleted file mode 100644
index 12c8b3f..0000000
--- a/TODO
+++ /dev/null
@@ -1,6 +0,0 @@
-1. update credits
-2. review "FILES"
-3. search for version info
-4. get PLATFORMS filled in
-5. update CHANGES file
-6. do same for libpcap
diff --git a/VERSION b/VERSION
index 4404a17..b48b2de 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.5.1
+4.7.4
diff --git a/aclocal.m4 b/aclocal.m4
index 59ddcfc..285000d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,5 +1,3 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.116 2008-09-25 21:45:50 guy Exp $ (LBL)
-dnl
 dnl Copyright (c) 1995, 1996, 1997, 1998
 dnl	The Regents of the University of California.  All rights reserved.
 dnl
@@ -440,25 +438,31 @@
 		    LIBS="$LIBS $pfopen"
 	    fi
     fi
-    AC_MSG_CHECKING(for local pcap library)
-    libpcap=FAIL
-    lastdir=FAIL
-    places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
-	egrep '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT)?$'`
-    for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do
-	    basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//' | \
-	        sed -e 's/-PRE-GIT$//' `
-	    if test $lastdir = $basedir ; then
-		    dnl skip alphas when an actual release is present
-		    continue;
-	    fi
-	    lastdir=$dir
-	    if test -r $dir/libpcap.a ; then
-		    libpcap=$dir/libpcap.a
-		    d=$dir
-		    dnl continue and select the last one that exists
-	    fi
-    done
+	libpcap=FAIL
+	AC_MSG_CHECKING(for local pcap library)
+	AC_ARG_WITH([system-libpcap],
+		[AS_HELP_STRING([--with-system-libpcap], [don't use local pcap library])])
+	if test "x$with_system_libpcap" != xyes ; then
+		lastdir=FAIL
+    	places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+		egrep '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT)?$'`
+    	places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+		egrep '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT)?$'`
+    	for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
+	    	basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//' | \
+	        	sed -e 's/-PRE-GIT$//' `
+	    	if test $lastdir = $basedir ; then
+		    	dnl skip alphas when an actual release is present
+		    	continue;
+	    	fi
+	    	lastdir=$dir
+	    	if test -r $dir/libpcap.a ; then
+		    	libpcap=$dir/libpcap.a
+		    	d=$dir
+		    	dnl continue and select the last one that exists
+	    	fi
+		done
+	fi
     if test $libpcap = FAIL ; then
 	    AC_MSG_RESULT(not found)
 
@@ -528,13 +532,23 @@
 	    $1=$libpcap
 	    places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
     	 		egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
+	    places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+    	 		egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
+            pcapH=FAIL
 	    if test -r $d/pcap.h; then
-		    $2="-I$d $$2"
-	    elif test -r $places/pcap.h; then
-		    $2="-I$places $$2"
+                    pcapH=$d
 	    else
-                    AC_MSG_ERROR(cannot find pcap.h, see INSTALL)
+                for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
+                   if test -r $dir/pcap.h ; then
+                       pcapH=$dir
+                   fi
+                done
+            fi
+
+            if test $pcapH = FAIL ; then
+                    AC_MSG_ERROR(cannot find pcap.h: see INSTALL)
  	    fi
+            $2="-I$pcapH $$2"
 	    AC_MSG_RESULT($libpcap)
 	    AC_PATH_PROG(PCAP_CONFIG, pcap-config,, $d)
 	    if test -n "$PCAP_CONFIG"; then
@@ -610,52 +624,6 @@
 able to fix it, without that information, as we have not been able to
 reproduce this problem ourselves.])
 	])
-
-    dnl
-    dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
-    dnl and "pcap_datalink_name_to_val()", and use substitute versions
-    dnl if they're not present.
-    dnl
-    AC_CHECK_FUNC(pcap_list_datalinks,
-	AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
-	    [define if libpcap has pcap_list_datalinks()]),
-	[
-	    AC_LIBOBJ(datalinks)
-	])
-    AC_CHECK_FUNC(pcap_set_datalink,
-	AC_DEFINE(HAVE_PCAP_SET_DATALINK, 1,
-	    [define if libpcap has pcap_set_datalink()]))
-    AC_CHECK_FUNC(pcap_datalink_name_to_val,
-	[
-	    AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
-		[define if libpcap has pcap_datalink_name_to_val()])
-	    AC_CHECK_FUNC(pcap_datalink_val_to_description,
-		AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
-		    [define if libpcap has pcap_datalink_val_to_description()]),
-		[
-		    AC_LIBOBJ(dlnames)
-		])
-	],
-	[
-	    AC_LIBOBJ(dlnames)
-	])
-
-    dnl
-    dnl Check for "pcap_breakloop()"; you can't substitute for it if
-    dnl it's absent (it has hooks into the live capture routines),
-    dnl so just define the HAVE_ value if it's there.
-    dnl
-    AC_CHECK_FUNCS(pcap_breakloop)
-
-    dnl
-    dnl Check for "pcap_dump_ftell()" and use a substitute version
-    dnl if it's not present.
-    AC_CHECK_FUNC(pcap_dump_ftell,
-	AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
-	    [define if libpcap has pcap_dump_ftell()]),
-	[
-	    AC_LIBOBJ(pcap_dump_ftell)
-	])
 ])
 
 dnl
@@ -821,15 +789,12 @@
 #	    ifdef HAVE_INTTYPES_H
 	    #include <inttypes.h>
 #	    endif
-#	    ifdef HAVE_SYS_BITYPES_H
-            #include <sys/bitypes.h>
-#	    endif
 	    #include <stdio.h>
 	    #include <sys/types.h>
 
 	    main()
 	    {
-	      u_int64_t t = 1;
+	      uint64_t t = 1;
 	      char strbuf[16+1];
 	      sprintf(strbuf, "%016$1x", t << 32);
 	      if (strcmp(strbuf, "0000000100000000") == 0)
@@ -1135,7 +1100,7 @@
 dnl 3. Neither the name of the project nor the names of its contributors
 dnl    may be used to endorse or promote products derived from this software
 dnl    without specific prior written permission.
-dnl 
+dnl
 dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
 dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
diff --git a/addrtoname.c b/addrtoname.c
index 745ffe3..d0437fe 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -21,11 +21,8 @@
  *  Internet, ethernet, port, and protocol string to address
  *  and address to string conversion routines
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -81,7 +78,7 @@
 #define HASHNAMESIZE 4096
 
 struct hnamemem {
-	u_int32_t addr;
+	uint32_t addr;
 	const char *name;
 	struct hnamemem *nxt;
 };
@@ -158,7 +155,7 @@
 static struct enamemem bytestringtable[HASHNAMESIZE];
 
 struct protoidmem {
-	u_int32_t p_oui;
+	uint32_t p_oui;
 	u_short p_proto;
 	const char *p_name;
 	struct protoidmem *p_nxt;
@@ -170,7 +167,7 @@
  * A faster replacement for inet_ntoa().
  */
 const char *
-intoa(u_int32_t addr)
+intoa(uint32_t addr)
 {
 	register char *cp;
 	register u_int byte;
@@ -199,8 +196,8 @@
 	return cp + 1;
 }
 
-static u_int32_t f_netmask;
-static u_int32_t f_localnet;
+static uint32_t f_netmask;
+static uint32_t f_localnet;
 
 /*
  * Return a name for the IP address pointed to by ap.  This address
@@ -222,10 +219,10 @@
  * also needs to check whether they're present in the packet buffer.
  */
 const char *
-getname(const u_char *ap)
+getname(netdissect_options *ndo, const u_char *ap)
 {
 	register struct hostent *hp;
-	u_int32_t addr;
+	uint32_t addr;
 	static struct hnamemem *p;		/* static for longjmp() */
 
 	memcpy(&addr, ap, sizeof(addr));
@@ -244,14 +241,14 @@
 	 *	    given, f_netmask and f_localnet are 0 and the test
 	 *	    evaluates to true)
 	 */
-	if (!nflag &&
+	if (!ndo->ndo_nflag &&
 	    (addr & f_netmask) == f_localnet) {
 		hp = gethostbyaddr((char *)&addr, 4, AF_INET);
 		if (hp) {
 			char *dotp;
 
 			p->name = strdup(hp->h_name);
-			if (Nflag) {
+			if (ndo->ndo_Nflag) {
 				/* Remove domain qualifications */
 				dotp = strchr(p->name, '.');
 				if (dotp)
@@ -270,14 +267,14 @@
  * is assumed to be in network byte order.
  */
 const char *
-getname6(const u_char *ap)
+getname6(netdissect_options *ndo, const u_char *ap)
 {
 	register struct hostent *hp;
 	union {
 		struct in6_addr addr;
 		struct for_hash_addr {
 			char fill[14];
-			u_int16_t d;
+			uint16_t d;
 		} addra;
 	} addr;
 	static struct h6namemem *p;		/* static for longjmp() */
@@ -296,13 +293,13 @@
 	/*
 	 * Do not print names if -n was given.
 	 */
-	if (!nflag) {
+	if (!ndo->ndo_nflag) {
 		hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6);
 		if (hp) {
 			char *dotp;
 
 			p->name = strdup(hp->h_name);
-			if (Nflag) {
+			if (ndo->ndo_Nflag) {
 				/* Remove domain qualifications */
 				dotp = strchr(p->name, '.');
 				if (dotp)
@@ -470,7 +467,7 @@
 }
 
 const char *
-etheraddr_string(register const u_char *ep)
+etheraddr_string(netdissect_options *ndo, register const u_char *ep)
 {
 	register int i;
 	register char *cp;
@@ -482,7 +479,7 @@
 	if (tp->e_name)
 		return (tp->e_name);
 #ifdef USE_ETHER_NTOHOST
-	if (!nflag) {
+	if (!ndo->ndo_nflag) {
 		char buf2[BUFSIZE];
 
 		/*
@@ -507,7 +504,7 @@
 		*cp++ = hex[*ep++ & 0xf];
 	}
 
-	if (!nflag) {
+	if (!ndo->ndo_nflag) {
 		snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)",
 		    tok2str(oui_values, "Unknown", oui));
 	} else
@@ -545,7 +542,7 @@
 }
 
 const char *
-linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int len)
+linkaddr_string(netdissect_options *ndo, const u_char *ep, const unsigned int type, const unsigned int len)
 {
 	register u_int i;
 	register char *cp;
@@ -555,10 +552,10 @@
 		return ("<empty>");
 
 	if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
-		return (etheraddr_string(ep));
+		return (etheraddr_string(ndo, ep));
 
 	if (type == LINKADDR_FRELAY)
-		return (q922_string(ep));
+		return (q922_string(ndo, ep, len));
 
 	tp = lookup_bytestring(ep, len);
 	if (tp->e_name)
@@ -583,7 +580,7 @@
 {
 	register char *cp;
 	register struct hnamemem *tp;
-	register u_int32_t i = port;
+	register uint32_t i = port;
 	char buf[sizeof("0000")];
 
 	for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -666,7 +663,7 @@
 tcpport_string(u_short port)
 {
 	register struct hnamemem *tp;
-	register u_int32_t i = port;
+	register uint32_t i = port;
 	char buf[sizeof("00000")];
 
 	for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -685,7 +682,7 @@
 udpport_string(register u_short port)
 {
 	register struct hnamemem *tp;
-	register u_int32_t i = port;
+	register uint32_t i = port;
 	char buf[sizeof("00000")];
 
 	for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -705,7 +702,7 @@
 {
 	register char *cp;
 	register struct hnamemem *tp;
-	register u_int32_t i = port;
+	register uint32_t i = port;
 	char buf[sizeof("0000")];
 
 	for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -727,7 +724,7 @@
 }
 
 static void
-init_servarray(void)
+init_servarray(netdissect_options *ndo)
 {
 	struct servent *sv;
 	register struct hnamemem *table;
@@ -746,7 +743,7 @@
 
 		while (table->name)
 			table = table->nxt;
-		if (nflag) {
+		if (ndo->ndo_nflag) {
 			(void)snprintf(buf, sizeof(buf), "%d", port);
 			table->name = strdup(buf);
 		} else
@@ -759,7 +756,7 @@
 
 /* in libpcap.a (nametoaddr.c) */
 #if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
-__declspec(dllimport)
+extern __declspec(dllimport)
 #else
 extern
 #endif
@@ -1135,32 +1132,32 @@
 
 /*
  * Initialize the address to name translation machinery.  We map all
- * non-local IP addresses to numeric addresses if fflag is true (i.e.,
- * to prevent blocking on the nameserver).  localnet is the IP address
+ * non-local IP addresses to numeric addresses if ndo->ndo_fflag is true
+ * (i.e., to prevent blocking on the nameserver).  localnet is the IP address
  * of the local network.  mask is its subnet mask.
  */
 void
-init_addrtoname(u_int32_t localnet, u_int32_t mask)
+init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
 {
-	if (fflag) {
+	if (ndo->ndo_fflag) {
 		f_localnet = localnet;
 		f_netmask = mask;
 	}
-	if (nflag)
+	if (ndo->ndo_nflag)
 		/*
 		 * Simplest way to suppress names.
 		 */
 		return;
 
 	init_etherarray();
-	init_servarray();
+	init_servarray(ndo);
 	init_eprotoarray();
 	init_protoidarray();
 	init_ipxsaparray();
 }
 
 const char *
-dnaddr_string(u_short dnaddr)
+dnaddr_string(netdissect_options *ndo, u_short dnaddr)
 {
 	register struct hnamemem *tp;
 
@@ -1171,7 +1168,7 @@
 
 	tp->addr = dnaddr;
 	tp->nxt = newhnamemem();
-	if (nflag)
+	if (ndo->ndo_nflag)
 		tp->name = dnnum_string(dnaddr);
 	else
 		tp->name = dnname_string(dnaddr);
@@ -1218,3 +1215,15 @@
 	return (p);
 }
 #endif /* INET6 */
+
+/* Represent TCI part of the 802.1Q 4-octet tag as text. */
+const char *
+ieee8021q_tci_string(const uint16_t tci)
+{
+	static char buf[128];
+	snprintf(buf, sizeof(buf), "vlan %u, p %u%s",
+	         tci & 0xfff,
+	         tci >> 13,
+	         (tci & 0x1000) ? ", DEI" : "");
+	return buf;
+}
diff --git a/addrtoname.h b/addrtoname.h
index cd5c41f..b07d8b2 100644
--- a/addrtoname.h
+++ b/addrtoname.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.20 2007-08-08 14:06:34 hannes Exp $ (LBL)
  */
 
 /* Name to address translation routines. */
@@ -32,25 +30,30 @@
 
 #define BUFSIZE 128
 
-extern const char *linkaddr_string(const u_char *, const unsigned int, const unsigned int);
-extern const char *etheraddr_string(const u_char *);
+extern const char *linkaddr_string(netdissect_options *, const u_char *, const unsigned int, const unsigned int);
+extern const char *etheraddr_string(netdissect_options *, const u_char *);
 extern const char *le64addr_string(const u_char *);
 extern const char *etherproto_string(u_short);
 extern const char *tcpport_string(u_short);
 extern const char *udpport_string(u_short);
-extern const char *getname(const u_char *);
+extern const char *isonsap_string(const u_char *, register u_int);
+extern const char *dnaddr_string(netdissect_options *, u_short);
+extern const char *protoid_string(const u_char *);
+extern const char *ipxsap_string(u_short);
+extern const char *getname(netdissect_options *, const u_char *);
 #ifdef INET6
-extern const char *getname6(const u_char *);
+extern const char *getname6(netdissect_options *, const u_char *);
 #endif
-extern const char *intoa(u_int32_t);
+extern const char *intoa(uint32_t);
 
-extern void init_addrtoname(u_int32_t, u_int32_t);
+extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
 extern struct hnamemem *newhnamemem(void);
 #ifdef INET6
 extern struct h6namemem *newh6namemem(void);
 #endif
+extern const char * ieee8021q_tci_string(const uint16_t);
 
-#define ipaddr_string(p) getname((const u_char *)(p))
+#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
 #ifdef INET6
-#define ip6addr_string(p) getname6((const u_char *)(p))
+#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
 #endif
diff --git a/af.c b/af.c
index 2c8a928..bea6d97 100644
--- a/af.c
+++ b/af.c
@@ -15,11 +15,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/af.h b/af.h
index 679cc8e..bbe1a16 100644
--- a/af.h
+++ b/af.h
@@ -1,5 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL) */
-
 /*
  * Copyright (c) 1998-2006 The TCPDUMP project
  *
diff --git a/ah.h b/ah.h
index c22806a..d87a087 100644
--- a/ah.h
+++ b/ah.h
@@ -38,19 +38,19 @@
 #define _NETINET6_AH_H_
 
 struct ah {
-	u_int8_t	ah_nxt;		/* Next Header */
-	u_int8_t	ah_len;		/* Length of data, in 32bit */
-	u_int16_t	ah_reserve;	/* Reserved for future use */
-	u_int32_t	ah_spi;		/* Security parameter index */
+	uint8_t		ah_nxt;		/* Next Header */
+	uint8_t		ah_len;		/* Length of data, in 32bit */
+	uint16_t	ah_reserve;	/* Reserved for future use */
+	uint32_t	ah_spi;		/* Security parameter index */
 	/* variable size, 32bit bound*/	/* Authentication data */
 };
 
 struct newah {
-	u_int8_t	ah_nxt;		/* Next Header */
-	u_int8_t	ah_len;		/* Length of data + 1, in 32bit */
-	u_int16_t	ah_reserve;	/* Reserved for future use */
-	u_int32_t	ah_spi;		/* Security parameter index */
-	u_int32_t	ah_seq;		/* Sequence number field */
+	uint8_t		ah_nxt;		/* Next Header */
+	uint8_t		ah_len;		/* Length of data + 1, in 32bit */
+	uint16_t	ah_reserve;	/* Reserved for future use */
+	uint32_t	ah_spi;		/* Security parameter index */
+	uint32_t	ah_seq;		/* Sequence number field */
 	/* variable size, 32bit bound*/	/* Authentication data */
 };
 
diff --git a/aodv.h b/aodv.h
deleted file mode 100644
index c2dec47..0000000
--- a/aodv.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.3 2003-09-13 01:34:42 guy Exp $ (LBL) */
-/*
- * Copyright (c) 2003 Bruce M. Simpson <bms@spc.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *        This product includes software developed by Bruce M. Simpson.
- * 4. Neither the name of Bruce M. Simpson nor the names of co-
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bruce M. Simpson 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 Bruce M. Simpson 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.
- */
-#ifndef _AODV_H_
-#define _AODV_H_
-
-struct aodv_rreq {
-	u_int8_t	rreq_type;	/* AODV message type (1) */
-	u_int8_t	rreq_flags;	/* various flags */
-	u_int8_t	rreq_zero0;	/* reserved, set to zero */
-	u_int8_t	rreq_hops;	/* number of hops from originator */
-	u_int32_t	rreq_id;	/* request ID */
-	u_int32_t	rreq_da;	/* destination IPv4 address */
-	u_int32_t	rreq_ds;	/* destination sequence number */
-	u_int32_t	rreq_oa;	/* originator IPv4 address */
-	u_int32_t	rreq_os;	/* originator sequence number */
-};
-#ifdef INET6
-struct aodv_rreq6 {
-	u_int8_t	rreq_type;	/* AODV message type (1) */
-	u_int8_t	rreq_flags;	/* various flags */
-	u_int8_t	rreq_zero0;	/* reserved, set to zero */
-	u_int8_t	rreq_hops;	/* number of hops from originator */
-	u_int32_t	rreq_id;	/* request ID */
-	struct in6_addr	rreq_da;	/* destination IPv6 address */
-	u_int32_t	rreq_ds;	/* destination sequence number */
-	struct in6_addr	rreq_oa;	/* originator IPv6 address */
-	u_int32_t	rreq_os;	/* originator sequence number */
-};
-struct aodv_rreq6_draft_01 {
-	u_int8_t	rreq_type;	/* AODV message type (16) */
-	u_int8_t	rreq_flags;	/* various flags */
-	u_int8_t	rreq_zero0;	/* reserved, set to zero */
-	u_int8_t	rreq_hops;	/* number of hops from originator */
-	u_int32_t	rreq_id;	/* request ID */
-	u_int32_t	rreq_ds;	/* destination sequence number */
-	u_int32_t	rreq_os;	/* originator sequence number */
-	struct in6_addr	rreq_da;	/* destination IPv6 address */
-	struct in6_addr	rreq_oa;	/* originator IPv6 address */
-};
-#endif
-
-#define	RREQ_JOIN	0x80		/* join (reserved for multicast */
-#define	RREQ_REPAIR	0x40		/* repair (reserved for multicast */
-#define	RREQ_GRAT	0x20		/* gratuitous RREP */
-#define	RREQ_DEST	0x10		/* destination only */
-#define	RREQ_UNKNOWN	0x08		/* unknown destination sequence num */
-#define	RREQ_FLAGS_MASK	0xF8		/* mask for rreq_flags */
-
-struct aodv_rrep {
-	u_int8_t	rrep_type;	/* AODV message type (2) */
-	u_int8_t	rrep_flags;	/* various flags */
-	u_int8_t	rrep_ps;	/* prefix size */
-	u_int8_t	rrep_hops;	/* number of hops from o to d */
-	u_int32_t	rrep_da;	/* destination IPv4 address */
-	u_int32_t	rrep_ds;	/* destination sequence number */
-	u_int32_t	rrep_oa;	/* originator IPv4 address */
-	u_int32_t	rrep_life;	/* lifetime of this route */
-};
-#ifdef INET6
-struct aodv_rrep6 {
-	u_int8_t	rrep_type;	/* AODV message type (2) */
-	u_int8_t	rrep_flags;	/* various flags */
-	u_int8_t	rrep_ps;	/* prefix size */
-	u_int8_t	rrep_hops;	/* number of hops from o to d */
-	struct in6_addr	rrep_da;	/* destination IPv6 address */
-	u_int32_t	rrep_ds;	/* destination sequence number */
-	struct in6_addr	rrep_oa;	/* originator IPv6 address */
-	u_int32_t	rrep_life;	/* lifetime of this route */
-};
-struct aodv_rrep6_draft_01 {
-	u_int8_t	rrep_type;	/* AODV message type (17) */
-	u_int8_t	rrep_flags;	/* various flags */
-	u_int8_t	rrep_ps;	/* prefix size */
-	u_int8_t	rrep_hops;	/* number of hops from o to d */
-	u_int32_t	rrep_ds;	/* destination sequence number */
-	struct in6_addr	rrep_da;	/* destination IPv6 address */
-	struct in6_addr	rrep_oa;	/* originator IPv6 address */
-	u_int32_t	rrep_life;	/* lifetime of this route */
-};
-#endif
-
-#define	RREP_REPAIR		0x80	/* repair (reserved for multicast */
-#define	RREP_ACK		0x40	/* acknowledgement required */
-#define	RREP_FLAGS_MASK		0xC0	/* mask for rrep_flags */
-#define	RREP_PREFIX_MASK	0x1F	/* mask for prefix size */
-
-struct rerr_unreach {
-	u_int32_t	u_da;	/* IPv4 address */
-	u_int32_t	u_ds;	/* sequence number */
-};
-#ifdef INET6
-struct rerr_unreach6 {
-	struct in6_addr	u_da;	/* IPv6 address */
-	u_int32_t	u_ds;	/* sequence number */
-};
-struct rerr_unreach6_draft_01 {
-	struct in6_addr	u_da;	/* IPv6 address */
-	u_int32_t	u_ds;	/* sequence number */
-};
-#endif
-
-struct aodv_rerr {
-	u_int8_t	rerr_type;	/* AODV message type (3 or 18) */
-	u_int8_t	rerr_flags;	/* various flags */
-	u_int8_t	rerr_zero0;	/* reserved, set to zero */
-	u_int8_t	rerr_dc;	/* destination count */
-	union {
-		struct	rerr_unreach dest[1];
-#ifdef INET6
-		struct	rerr_unreach6 dest6[1];
-		struct	rerr_unreach6_draft_01 dest6_draft_01[1];
-#endif
-	} r;
-};
-
-#define RERR_NODELETE		0x80	/* don't delete the link */
-#define RERR_FLAGS_MASK		0x80	/* mask for rerr_flags */
-
-struct aodv_rrep_ack {
-	u_int8_t	ra_type;
-	u_int8_t	ra_zero0;
-};
-
-union aodv {
-	struct aodv_rreq rreq;
-	struct aodv_rrep rrep;
-	struct aodv_rerr rerr;
-	struct aodv_rrep_ack rrep_ack;
-#ifdef INET6
-	struct aodv_rreq6 rreq6;
-	struct aodv_rreq6_draft_01 rreq6_draft_01;
-	struct aodv_rrep6 rrep6;
-	struct aodv_rrep6_draft_01 rrep6_draft_01;
-#endif
-};
-
-#define	AODV_RREQ		1	/* route request */
-#define	AODV_RREP		2	/* route response */
-#define	AODV_RERR		3	/* error report */
-#define	AODV_RREP_ACK		4	/* route response acknowledgement */
-
-#define AODV_V6_DRAFT_01_RREQ		16	/* IPv6 route request */
-#define AODV_V6_DRAFT_01_RREP		17	/* IPv6 route response */
-#define AODV_V6_DRAFT_01_RERR		18	/* IPv6 error report */
-#define AODV_V6_DRAFT_01_RREP_ACK	19	/* IPV6 route response acknowledgment */
-
-struct aodv_ext {
-	u_int8_t	type;		/* extension type */
-	u_int8_t	length;		/* extension length */
-};
-
-struct aodv_hello {
-	struct	aodv_ext	eh;		/* extension header */
-	u_int8_t		interval[4];	/* expect my next hello in
-						 * (n) ms
-						 * NOTE: this is not aligned */
-};
-
-#define	AODV_EXT_HELLO	1
-
-#endif /* _AODV_H_ */
diff --git a/appletalk.h b/appletalk.h
index ff972f6..3fbcbce 100644
--- a/appletalk.h
+++ b/appletalk.h
@@ -19,14 +19,12 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
- *
- * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.16 2004-05-01 09:41:50 hannes Exp $ (LBL)
  */
 
 struct LAP {
-	u_int8_t	dst;
-	u_int8_t	src;
-	u_int8_t	type;
+	uint8_t		dst;
+	uint8_t		src;
+	uint8_t		type;
 };
 #define lapShortDDP	1	/* short DDP type */
 #define lapDDP		2	/* DDP type */
@@ -35,22 +33,22 @@
 /* Datagram Delivery Protocol */
 
 struct atDDP {
-	u_int16_t	length;
-	u_int16_t	checksum;
-	u_int16_t	dstNet;
-	u_int16_t	srcNet;
-	u_int8_t	dstNode;
-	u_int8_t	srcNode;
-	u_int8_t	dstSkt;
-	u_int8_t	srcSkt;
-	u_int8_t	type;
+	uint16_t	length;
+	uint16_t	checksum;
+	uint16_t	dstNet;
+	uint16_t	srcNet;
+	uint8_t		dstNode;
+	uint8_t		srcNode;
+	uint8_t		dstSkt;
+	uint8_t		srcSkt;
+	uint8_t		type;
 };
 
 struct atShortDDP {
-	u_int16_t	length;
-	u_int8_t	dstSkt;
-	u_int8_t	srcSkt;
-	u_int8_t	type;
+	uint16_t	length;
+	uint8_t		dstSkt;
+	uint8_t		srcSkt;
+	uint8_t		type;
 };
 
 #define	ddpMaxWKS	0x7F
@@ -74,10 +72,10 @@
 /* AppleTalk Transaction Protocol */
 
 struct atATP {
-	u_int8_t	control;
-	u_int8_t	bitmap;
-	u_int16_t	transID;
-	int32_t userData;
+	uint8_t		control;
+	uint8_t		bitmap;
+	uint16_t	transID;
+	int32_t		userData;
 };
 
 #define	atpReqCode	0x40
@@ -95,8 +93,8 @@
 /* AppleTalk Echo Protocol */
 
 struct atEcho {
-	u_int8_t	echoFunction;
-	u_int8_t	*echoData;
+	uint8_t		echoFunction;
+	uint8_t		*echoData;
 };
 
 #define echoSkt		4		/* the echoer socket */
@@ -108,15 +106,15 @@
 /* Name Binding Protocol */
 
 struct atNBP {
-	u_int8_t	control;
-	u_int8_t	id;
+	uint8_t		control;
+	uint8_t		id;
 };
 
 struct atNBPtuple {
-	u_int16_t	net;
-	u_int8_t	node;
-	u_int8_t	skt;
-	u_int8_t	enumerator;
+	uint16_t	net;
+	uint8_t		node;
+	uint8_t		skt;
+	uint8_t		enumerator;
 };
 
 #define	nbpBrRq		0x10
@@ -142,8 +140,8 @@
 /* Zone Information Protocol */
 
 struct zipHeader {
-	u_int8_t	command;
-	u_int8_t	netcount;
+	uint8_t		command;
+	uint8_t		netcount;
 };
 
 #define	zipHeaderSize	2
diff --git a/arcnet.h b/arcnet.h
deleted file mode 100644
index 3b60956..0000000
--- a/arcnet.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- *	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 the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. 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 BY THE REGENTS 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 THE REGENTS 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.
- *
- * @(#) $Id: arcnet.h,v 1.3 2003-01-23 09:05:37 guy Exp $ (LBL)
- *
- * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
- */
-
-/*
- * Structure of a 2.5MB/s Arcnet header on the BSDs,
- * as given to interface code.
- */
-struct	arc_header {
-	u_int8_t  arc_shost;
-	u_int8_t  arc_dhost;
-	u_int8_t  arc_type;
-	/*
-	 * only present for newstyle encoding with LL fragmentation.
-	 * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
-	 */
-	u_int8_t  arc_flag;
-	u_int16_t arc_seqid;
-
-	/*
-	 * only present in exception packets (arc_flag == 0xff)
-	 */
-	u_int8_t  arc_type2;	/* same as arc_type */
-	u_int8_t  arc_flag2;	/* real flag value */
-	u_int16_t arc_seqid2;	/* real seqid value */
-};
-
-#define	ARC_HDRLEN		3
-#define	ARC_HDRNEWLEN		6
-#define	ARC_HDRNEWLEN_EXC	10
-
-/* RFC 1051 */
-#define	ARCTYPE_IP_OLD		240	/* IP protocol */
-#define	ARCTYPE_ARP_OLD		241	/* address resolution protocol */
-
-/* RFC 1201 */
-#define	ARCTYPE_IP		212	/* IP protocol */
-#define	ARCTYPE_ARP		213	/* address resolution protocol */
-#define	ARCTYPE_REVARP		214	/* reverse addr resolution protocol */
-
-#define	ARCTYPE_ATALK		221	/* Appletalk */
-#define	ARCTYPE_BANIAN		247	/* Banyan Vines */
-#define	ARCTYPE_IPX		250	/* Novell IPX */
-
-#define ARCTYPE_INET6		0xc4	/* IPng */
-#define ARCTYPE_DIAGNOSE	0x80	/* as per ANSI/ATA 878.1 */
-
-/*
- * Structure of a 2.5MB/s Arcnet header on Linux.  Linux has
- * an extra "offset" field when given to interface code, and
- * never presents packets that look like exception frames.
- */
-struct	arc_linux_header {
-	u_int8_t  arc_shost;
-	u_int8_t  arc_dhost;
-	u_int16_t arc_offset;
-	u_int8_t  arc_type;
-	/*
-	 * only present for newstyle encoding with LL fragmentation.
-	 * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
-	 * instead.
-	 */
-	u_int8_t  arc_flag;
-	u_int16_t arc_seqid;
-};
-
-#define	ARC_LINUX_HDRLEN	5
-#define	ARC_LINUX_HDRNEWLEN	8
diff --git a/atm.h b/atm.h
index 65ac5c1..8d1737e 100644
--- a/atm.h
+++ b/atm.h
@@ -13,8 +13,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.3 2006-02-08 01:43:00 hannes Exp $
  */
 
 /*
diff --git a/atmuni31.h b/atmuni31.h
index ab7a03d..0f85430 100644
--- a/atmuni31.h
+++ b/atmuni31.h
@@ -28,8 +28,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/atmuni31.h,v 1.3 2007-10-22 19:37:51 guy Exp $ (LBL)
  */
 
 /* Based on UNI3.1 standard by ATM Forum */
diff --git a/bootp.h b/bootp.h
deleted file mode 100644
index b1b81dc..0000000
--- a/bootp.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.19 2008-04-22 09:46:03 hannes Exp $ (LBL) */
-/*
- * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
- *
- * This file specifies the "implementation-independent" BOOTP protocol
- * information which is common to both client and server.
- *
- * Copyright 1988 by Carnegie Mellon.
- *
- * Permission to use, copy, modify, and distribute this program for any
- * purpose and without fee is hereby granted, provided that this copyright
- * and permission notice appear on all copies and supporting documentation,
- * the name of Carnegie Mellon not be used in advertising or publicity
- * pertaining to distribution of the program without specific prior
- * permission, and notice be given in supporting documentation that copying
- * and distribution is by permission of Carnegie Mellon and Stanford
- * University.  Carnegie Mellon makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- */
-
-
-struct bootp {
-	u_int8_t	bp_op;		/* packet opcode type */
-	u_int8_t	bp_htype;	/* hardware addr type */
-	u_int8_t	bp_hlen;	/* hardware addr length */
-	u_int8_t	bp_hops;	/* gateway hops */
-	u_int32_t	bp_xid;		/* transaction ID */
-	u_int16_t	bp_secs;	/* seconds since boot began */
-	u_int16_t	bp_flags;	/* flags - see bootp_flag_values[]
-					   in print-bootp.c */
-	struct in_addr	bp_ciaddr;	/* client IP address */
-	struct in_addr	bp_yiaddr;	/* 'your' IP address */
-	struct in_addr	bp_siaddr;	/* server IP address */
-	struct in_addr	bp_giaddr;	/* gateway IP address */
-	u_int8_t	bp_chaddr[16];	/* client hardware address */
-	u_int8_t	bp_sname[64];	/* server host name */
-	u_int8_t	bp_file[128];	/* boot file name */
-	u_int8_t	bp_vend[64];	/* vendor-specific area */
-} UNALIGNED;
-
-/*
- * UDP port numbers, server and client.
- */
-#define	IPPORT_BOOTPS		67
-#define	IPPORT_BOOTPC		68
-
-#define BOOTPREPLY		2
-#define BOOTPREQUEST		1
-
-/*
- * Vendor magic cookie (v_magic) for CMU
- */
-#define VM_CMU		"CMU"
-
-/*
- * Vendor magic cookie (v_magic) for RFC1048
- */
-#define VM_RFC1048	{ 99, 130, 83, 99 }
-
-
-
-/*
- * RFC1048 tag values used to specify what information is being supplied in
- * the vendor field of the packet.
- */
-
-#define TAG_PAD			((u_int8_t)   0)
-#define TAG_SUBNET_MASK		((u_int8_t)   1)
-#define TAG_TIME_OFFSET		((u_int8_t)   2)
-#define TAG_GATEWAY		((u_int8_t)   3)
-#define TAG_TIME_SERVER		((u_int8_t)   4)
-#define TAG_NAME_SERVER		((u_int8_t)   5)
-#define TAG_DOMAIN_SERVER	((u_int8_t)   6)
-#define TAG_LOG_SERVER		((u_int8_t)   7)
-#define TAG_COOKIE_SERVER	((u_int8_t)   8)
-#define TAG_LPR_SERVER		((u_int8_t)   9)
-#define TAG_IMPRESS_SERVER	((u_int8_t)  10)
-#define TAG_RLP_SERVER		((u_int8_t)  11)
-#define TAG_HOSTNAME		((u_int8_t)  12)
-#define TAG_BOOTSIZE		((u_int8_t)  13)
-#define TAG_END			((u_int8_t) 255)
-/* RFC1497 tags */
-#define	TAG_DUMPPATH		((u_int8_t)  14)
-#define	TAG_DOMAINNAME		((u_int8_t)  15)
-#define	TAG_SWAP_SERVER		((u_int8_t)  16)
-#define	TAG_ROOTPATH		((u_int8_t)  17)
-#define	TAG_EXTPATH		((u_int8_t)  18)
-/* RFC2132 */
-#define	TAG_IP_FORWARD		((u_int8_t)  19)
-#define	TAG_NL_SRCRT		((u_int8_t)  20)
-#define	TAG_PFILTERS		((u_int8_t)  21)
-#define	TAG_REASS_SIZE		((u_int8_t)  22)
-#define	TAG_DEF_TTL		((u_int8_t)  23)
-#define	TAG_MTU_TIMEOUT		((u_int8_t)  24)
-#define	TAG_MTU_TABLE		((u_int8_t)  25)
-#define	TAG_INT_MTU		((u_int8_t)  26)
-#define	TAG_LOCAL_SUBNETS	((u_int8_t)  27)
-#define	TAG_BROAD_ADDR		((u_int8_t)  28)
-#define	TAG_DO_MASK_DISC	((u_int8_t)  29)
-#define	TAG_SUPPLY_MASK		((u_int8_t)  30)
-#define	TAG_DO_RDISC		((u_int8_t)  31)
-#define	TAG_RTR_SOL_ADDR	((u_int8_t)  32)
-#define	TAG_STATIC_ROUTE	((u_int8_t)  33)
-#define	TAG_USE_TRAILERS	((u_int8_t)  34)
-#define	TAG_ARP_TIMEOUT		((u_int8_t)  35)
-#define	TAG_ETH_ENCAP		((u_int8_t)  36)
-#define	TAG_TCP_TTL		((u_int8_t)  37)
-#define	TAG_TCP_KEEPALIVE	((u_int8_t)  38)
-#define	TAG_KEEPALIVE_GO	((u_int8_t)  39)
-#define	TAG_NIS_DOMAIN		((u_int8_t)  40)
-#define	TAG_NIS_SERVERS		((u_int8_t)  41)
-#define	TAG_NTP_SERVERS		((u_int8_t)  42)
-#define	TAG_VENDOR_OPTS		((u_int8_t)  43)
-#define	TAG_NETBIOS_NS		((u_int8_t)  44)
-#define	TAG_NETBIOS_DDS		((u_int8_t)  45)
-#define	TAG_NETBIOS_NODE	((u_int8_t)  46)
-#define	TAG_NETBIOS_SCOPE	((u_int8_t)  47)
-#define	TAG_XWIN_FS		((u_int8_t)  48)
-#define	TAG_XWIN_DM		((u_int8_t)  49)
-#define	TAG_NIS_P_DOMAIN	((u_int8_t)  64)
-#define	TAG_NIS_P_SERVERS	((u_int8_t)  65)
-#define	TAG_MOBILE_HOME		((u_int8_t)  68)
-#define	TAG_SMPT_SERVER		((u_int8_t)  69)
-#define	TAG_POP3_SERVER		((u_int8_t)  70)
-#define	TAG_NNTP_SERVER		((u_int8_t)  71)
-#define	TAG_WWW_SERVER		((u_int8_t)  72)
-#define	TAG_FINGER_SERVER	((u_int8_t)  73)
-#define	TAG_IRC_SERVER		((u_int8_t)  74)
-#define	TAG_STREETTALK_SRVR	((u_int8_t)  75)
-#define	TAG_STREETTALK_STDA	((u_int8_t)  76)
-/* DHCP options */
-#define	TAG_REQUESTED_IP	((u_int8_t)  50)
-#define	TAG_IP_LEASE		((u_int8_t)  51)
-#define	TAG_OPT_OVERLOAD	((u_int8_t)  52)
-#define	TAG_TFTP_SERVER		((u_int8_t)  66)
-#define	TAG_BOOTFILENAME	((u_int8_t)  67)
-#define	TAG_DHCP_MESSAGE	((u_int8_t)  53)
-#define	TAG_SERVER_ID		((u_int8_t)  54)
-#define	TAG_PARM_REQUEST	((u_int8_t)  55)
-#define	TAG_MESSAGE		((u_int8_t)  56)
-#define	TAG_MAX_MSG_SIZE	((u_int8_t)  57)
-#define	TAG_RENEWAL_TIME	((u_int8_t)  58)
-#define	TAG_REBIND_TIME		((u_int8_t)  59)
-#define	TAG_VENDOR_CLASS	((u_int8_t)  60)
-#define	TAG_CLIENT_ID		((u_int8_t)  61)
-/* RFC 2241 */
-#define	TAG_NDS_SERVERS		((u_int8_t)  85)
-#define	TAG_NDS_TREE_NAME	((u_int8_t)  86)
-#define	TAG_NDS_CONTEXT		((u_int8_t)  87)
-/* RFC 2242 */
-#define	TAG_NDS_IPDOMAIN	((u_int8_t)  62)
-#define	TAG_NDS_IPINFO		((u_int8_t)  63)
-/* RFC 2485 */
-#define	TAG_OPEN_GROUP_UAP	((u_int8_t)  98)
-/* RFC 2563 */
-#define	TAG_DISABLE_AUTOCONF	((u_int8_t) 116)
-/* RFC 2610 */
-#define	TAG_SLP_DA		((u_int8_t)  78)
-#define	TAG_SLP_SCOPE		((u_int8_t)  79)
-/* RFC 2937 */
-#define	TAG_NS_SEARCH		((u_int8_t) 117)
-/* RFC 3011 */
-#define	TAG_IP4_SUBNET_SELECT	((u_int8_t) 118)
-/* RFC 3442 */
-#define TAG_CLASSLESS_STATIC_RT	((u_int8_t) 121)
-#define TAG_CLASSLESS_STA_RT_MS	((u_int8_t) 249)
-/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
-#define	TAG_USER_CLASS		((u_int8_t)  77)
-#define	TAG_SLP_NAMING_AUTH	((u_int8_t)  80)
-#define	TAG_CLIENT_FQDN		((u_int8_t)  81)
-#define	TAG_AGENT_CIRCUIT	((u_int8_t)  82)
-#define	TAG_AGENT_REMOTE	((u_int8_t)  83)
-#define	TAG_AGENT_MASK		((u_int8_t)  84)
-#define	TAG_TZ_STRING		((u_int8_t)  88)
-#define	TAG_FQDN_OPTION		((u_int8_t)  89)
-#define	TAG_AUTH		((u_int8_t)  90)
-#define	TAG_VINES_SERVERS	((u_int8_t)  91)
-#define	TAG_SERVER_RANK		((u_int8_t)  92)
-#define	TAG_CLIENT_ARCH		((u_int8_t)  93)
-#define	TAG_CLIENT_NDI		((u_int8_t)  94)
-#define	TAG_CLIENT_GUID		((u_int8_t)  97)
-#define	TAG_LDAP_URL		((u_int8_t)  95)
-#define	TAG_6OVER4		((u_int8_t)  96)
-#define	TAG_PRINTER_NAME	((u_int8_t) 100)
-#define	TAG_MDHCP_SERVER	((u_int8_t) 101)
-#define	TAG_IPX_COMPAT		((u_int8_t) 110)
-#define	TAG_NETINFO_PARENT	((u_int8_t) 112)
-#define	TAG_NETINFO_PARENT_TAG	((u_int8_t) 113)
-#define	TAG_URL			((u_int8_t) 114)
-#define	TAG_FAILOVER		((u_int8_t) 115)
-#define	TAG_EXTENDED_REQUEST	((u_int8_t) 126)
-#define	TAG_EXTENDED_OPTION	((u_int8_t) 127)
-
-
-/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
-#define		DHCPDISCOVER	1
-#define		DHCPOFFER	2
-#define		DHCPREQUEST	3
-#define		DHCPDECLINE	4
-#define		DHCPACK		5
-#define		DHCPNAK		6
-#define		DHCPRELEASE	7
-#define		DHCPINFORM	8
-
-
-/*
- * "vendor" data permitted for CMU bootp clients.
- */
-
-struct cmu_vend {
-	u_int8_t	v_magic[4];	/* magic number */
-	u_int32_t	v_flags;	/* flags/opcodes, etc. */
-	struct in_addr	v_smask;	/* Subnet mask */
-	struct in_addr	v_dgate;	/* Default gateway */
-	struct in_addr	v_dns1, v_dns2; /* Domain name servers */
-	struct in_addr	v_ins1, v_ins2; /* IEN-116 name servers */
-	struct in_addr	v_ts1, v_ts2;	/* Time servers */
-	u_int8_t	v_unused[24];	/* currently unused */
-} UNALIGNED;
-
-
-/* v_flags values */
-#define VF_SMASK	1	/* Subnet mask field contains valid data */
-
-/* RFC 4702 DHCP Client FQDN Option */
-
-#define CLIENT_FQDN_FLAGS_S	0x01
-#define CLIENT_FQDN_FLAGS_O	0x02
-#define CLIENT_FQDN_FLAGS_E	0x04
-#define CLIENT_FQDN_FLAGS_N	0x08
diff --git a/bpf_dump.c b/bpf_dump.c
index b50d7e7..2ef8528 100644
--- a/bpf_dump.c
+++ b/bpf_dump.c
@@ -18,18 +18,14 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.17 2008-02-14 20:53:49 guy Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
 #include <stdio.h>
 
 #include "interface.h"
diff --git a/chdlc.h b/chdlc.h
index d117263..d5a2d91 100644
--- a/chdlc.h
+++ b/chdlc.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000-09-18 05:11:43 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
diff --git a/checksum.c b/checksum.c
index 57c02bd..d8263c7 100644
--- a/checksum.c
+++ b/checksum.c
@@ -17,11 +17,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/checksum.c,v 1.4 2006-09-25 09:23:32 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -55,7 +51,7 @@
 	sys.stdout.write("\n")
 
  */
-static const u_int16_t crc10_table[256] =
+static const uint16_t crc10_table[256] =
 {
 	0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff,
 	0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe,
@@ -93,12 +89,12 @@
 
 static void
 init_crc10_table(void)
-{   
+{
 #define CRC10_POLYNOMIAL 0x633
     register int i, j;
-    register u_int16_t accum;
-    u_int16_t verify_crc10_table[256];
-    
+    register uint16_t accum;
+    uint16_t verify_crc10_table[256];
+
     for ( i = 0;  i < 256;  i++ )
     {
         accum = ((unsigned short) i << 2);
@@ -114,8 +110,8 @@
 #undef CRC10_POLYNOMIAL
 }
 
-u_int16_t
-verify_crc10_cksum(u_int16_t accum, const u_char *p, int length)
+uint16_t
+verify_crc10_cksum(uint16_t accum, const u_char *p, int length)
 {
     register int i;
 
@@ -140,16 +136,16 @@
  * Creates the OSI Fletcher checksum. See 8473-1, Appendix C, section C.3.
  * The checksum field of the passed PDU does not need to be reset to zero.
  */
-u_int16_t
-create_osi_cksum (const u_int8_t *pptr, int checksum_offset, int length)
+uint16_t
+create_osi_cksum (const uint8_t *pptr, int checksum_offset, int length)
 {
 
     int x;
     int y;
-    u_int32_t mul;
-    u_int32_t c0;
-    u_int32_t c1;
-    u_int16_t checksum;
+    uint32_t mul;
+    uint32_t c0;
+    uint32_t c1;
+    uint16_t checksum;
     int index;
 
     c0 = 0;
@@ -166,14 +162,14 @@
         } else {
             c0 = c0 + *(pptr++);
             c1 += c0;
-        } 
+        }
     }
 
     c0 = c0 % 255;
     c1 = c1 % 255;
 
     mul = (length - checksum_offset)*(c0);
-  
+
     x = mul - c0 - c1;
     y = c1 - mul - 1;
 
@@ -189,6 +185,6 @@
 
     y &= 0x00FF;
     checksum = ((x << 8) | y);
-  
+
     return checksum;
 }
diff --git a/config.guess b/config.guess
old mode 100755
new mode 100644
index c2246a4..44290b8
--- a/config.guess
+++ b/config.guess
@@ -1,14 +1,12 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-#   Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2009-12-30'
+timestamp='2015-02-23'
 
 # This file 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
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -17,26 +15,22 @@
 # 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., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner.  Please send patches (context
-# diff format) to <config-patches@gnu.org> and include a ChangeLog
-# entry.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 #
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches to <config-patches@gnu.org>.
+
 
 me=`echo "$0" | sed -e 's,.*/,,'`
 
@@ -56,9 +50,7 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
-Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -140,12 +132,33 @@
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+	# If the system lacks a compiler, then just pick glibc.
+	# We could probably try harder.
+	LIBC=gnu
+
+	eval $set_cc_for_build
+	cat <<-EOF > $dummy.c
+	#include <features.h>
+	#if defined(__UCLIBC__)
+	LIBC=uclibc
+	#elif defined(__dietlibc__)
+	LIBC=dietlibc
+	#else
+	LIBC=gnu
+	#endif
+	EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+	;;
+esac
+
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:NetBSD:*:*)
 	# NetBSD (nbsd) targets should (where applicable) match one or
-	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
 	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
 	# switched to ELF, *-*-netbsd* would select the old
 	# object file format.  This provides both forward
@@ -155,20 +168,27 @@
 	# Note: NetBSD doesn't particularly care about the vendor
 	# portion of the name.  We always set it to "unknown".
 	sysctl="sysctl -n hw.machine_arch"
-	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+	    /sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || \
+	    echo unknown)`
 	case "${UNAME_MACHINE_ARCH}" in
 	    armeb) machine=armeb-unknown ;;
 	    arm*) machine=arm-unknown ;;
 	    sh3el) machine=shl-unknown ;;
 	    sh3eb) machine=sh-unknown ;;
 	    sh5el) machine=sh5le-unknown ;;
+	    earmv*)
+		arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+		endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
+		machine=${arch}${endian}-unknown
+		;;
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
 	# to ELF recently, or will in the future.
 	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+	    arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep -q __ELF__
@@ -181,7 +201,14 @@
 		fi
 		;;
 	    *)
-	        os=netbsd
+		os=netbsd
+		;;
+	esac
+	# Determine ABI tags.
+	case "${UNAME_MACHINE_ARCH}" in
+	    earm*)
+		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+		abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
 		;;
 	esac
 	# The OS release
@@ -200,7 +227,11 @@
 	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
 	# contains redundant information, the shorter form:
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-	echo "${machine}-${os}${release}"
+	echo "${machine}-${os}${release}${abi}"
+	exit ;;
+    *:Bitrig:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
 	exit ;;
     *:OpenBSD:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
@@ -224,7 +255,7 @@
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
 		;;
 	*5.*)
-	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
 		;;
 	esac
 	# According to Compaq, /usr/sbin/psrinfo has been available on
@@ -270,7 +301,10 @@
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
 	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	exit ;;
+	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+	exitcode=$?
+	trap '' 0
+	exit $exitcode ;;
     Alpha\ *:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# Should we change UNAME_MACHINE based on the output of uname instead
@@ -296,12 +330,12 @@
 	echo s390-ibm-zvmoe
 	exit ;;
     *:OS400:*:*)
-        echo powerpc-ibm-os400
+	echo powerpc-ibm-os400
 	exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit ;;
-    arm:riscos:*:*|arm:RISCOS:*:*)
+    arm*:riscos:*:*|arm*:RISCOS:*:*)
 	echo arm-unknown-riscos
 	exit ;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@@ -395,23 +429,23 @@
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
+	echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
 	echo m68k-atari-mint${UNAME_RELEASE}
-        exit ;;
+	exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
+	echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-milan-mint${UNAME_RELEASE}
+	exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-hades-mint${UNAME_RELEASE}
+	exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-unknown-mint${UNAME_RELEASE}
+	exit ;;
     m68k:machten:*:*)
 	echo m68k-apple-machten${UNAME_RELEASE}
 	exit ;;
@@ -481,8 +515,8 @@
 	echo m88k-motorola-sysv3
 	exit ;;
     AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	# DG/UX returns AViiON for all architectures
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
 	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
 	then
 	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -495,7 +529,7 @@
 	else
 	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
- 	exit ;;
+	exit ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
 	exit ;;
@@ -552,15 +586,16 @@
 		echo rs6000-ibm-aix3.2
 	fi
 	exit ;;
-    *:AIX:*:[456])
+    *:AIX:*:[4567])
 	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
 	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
 		IBM_ARCH=rs6000
 	else
 		IBM_ARCH=powerpc
 	fi
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
+	if [ -x /usr/bin/lslpp ] ; then
+		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
 	else
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
@@ -595,52 +630,52 @@
 	    9000/[678][0-9][0-9])
 		if [ -x /usr/bin/getconf ]; then
 		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
+		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+		    case "${sc_cpu_version}" in
+		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+		      532)                      # CPU_PA_RISC2_0
+			case "${sc_kernel_bits}" in
+			  32) HP_ARCH="hppa2.0n" ;;
+			  64) HP_ARCH="hppa2.0w" ;;
 			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
+			esac ;;
+		    esac
 		fi
 		if [ "${HP_ARCH}" = "" ]; then
 		    eval $set_cc_for_build
-		    sed 's/^              //' << EOF >$dummy.c
+		    sed 's/^		//' << EOF >$dummy.c
 
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
+		#define _HPUX_SOURCE
+		#include <stdlib.h>
+		#include <unistd.h>
 
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
+		int main ()
+		{
+		#if defined(_SC_KERNEL_BITS)
+		    long bits = sysconf(_SC_KERNEL_BITS);
+		#endif
+		    long cpu  = sysconf (_SC_CPU_VERSION);
 
-                  switch (cpu)
-              	{
-              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-              	case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-              	    switch (bits)
-              		{
-              		case 64: puts ("hppa2.0w"); break;
-              		case 32: puts ("hppa2.0n"); break;
-              		default: puts ("hppa2.0"); break;
-              		} break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-              	    puts ("hppa2.0"); break;
-              #endif
-              	default: puts ("hppa1.0"); break;
-              	}
-                  exit (0);
-              }
+		    switch (cpu)
+			{
+			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+			case CPU_PA_RISC2_0:
+		#if defined(_SC_KERNEL_BITS)
+			    switch (bits)
+				{
+				case 64: puts ("hppa2.0w"); break;
+				case 32: puts ("hppa2.0n"); break;
+				default: puts ("hppa2.0"); break;
+				} break;
+		#else  /* !defined(_SC_KERNEL_BITS) */
+			    puts ("hppa2.0"); break;
+		#endif
+			default: puts ("hppa1.0"); break;
+			}
+		    exit (0);
+		}
 EOF
 		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
 		    test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -731,22 +766,22 @@
 	exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
-        exit ;;
+	exit ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
-        exit ;;
+	exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
 	echo c34-convex-bsd
-        exit ;;
+	exit ;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
 	echo c38-convex-bsd
-        exit ;;
+	exit ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
 	echo c4-convex-bsd
-        exit ;;
+	exit ;;
     CRAY*Y-MP:*:*:*)
 	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit ;;
@@ -770,14 +805,14 @@
 	exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit ;;
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
     5000:UNIX_System_V:4.*:*)
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@@ -789,30 +824,35 @@
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit ;;
     *:FreeBSD:*:*)
-	case ${UNAME_MACHINE} in
-	    pc98)
-		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
+	case ${UNAME_PROCESSOR} in
 	    amd64)
 		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	    *)
-		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	esac
 	exit ;;
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
 	exit ;;
+    *:MINGW64*:*)
+	echo ${UNAME_MACHINE}-pc-mingw64
+	exit ;;
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
+    *:MSYS*:*)
+	echo ${UNAME_MACHINE}-pc-msys
+	exit ;;
     i*:windows32*:*)
-    	# uname -m includes "-pc" on this system.
-    	echo ${UNAME_MACHINE}-mingw32
+	# uname -m includes "-pc" on this system.
+	echo ${UNAME_MACHINE}-mingw32
 	exit ;;
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
     *:Interix*:*)
-    	case ${UNAME_MACHINE} in
+	case ${UNAME_MACHINE} in
 	    x86)
 		echo i586-pc-interix${UNAME_RELEASE}
 		exit ;;
@@ -849,15 +889,22 @@
 	exit ;;
     *:GNU:*:*)
 	# the GNU system
-	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 	exit ;;
     *:GNU/*:*:*)
 	# other systems with GNU libc and userland
-	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
 	exit ;;
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
+    aarch64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    aarch64_be:Linux:*:*)
+	UNAME_MACHINE=aarch64_be
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     alpha:Linux:*:*)
 	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
 	  EV5)   UNAME_MACHINE=alphaev5 ;;
@@ -867,52 +914,56 @@
 	  EV6)   UNAME_MACHINE=alphaev6 ;;
 	  EV67)  UNAME_MACHINE=alphaev67 ;;
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
+	esac
 	objdump --private-headers /bin/sh | grep -q ld.so.1
-	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    arc:Linux:*:* | arceb:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     arm*:Linux:*:*)
 	eval $set_cc_for_build
 	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
 	    | grep -q __ARM_EABI__
 	then
-	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	    echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	else
-	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep -q __ARM_PCS_VFP
+	    then
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+	    else
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+	    fi
 	fi
 	exit ;;
     avr32*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     cris:Linux:*:*)
-	echo cris-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
     crisv32:Linux:*:*)
-	echo crisv32-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
     frv:Linux:*:*)
-    	echo frv-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    hexagon:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     i*86:Linux:*:*)
-	LIBC=gnu
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#ifdef __dietlibc__
-	LIBC=dietlibc
-	#endif
-EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
-	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 	exit ;;
     ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     m32r*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     m68*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
 	eval $set_cc_for_build
@@ -931,51 +982,63 @@
 	#endif
 EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
-	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
-    or32:Linux:*:*)
-	echo or32-unknown-linux-gnu
+    openrisc*:Linux:*:*)
+	echo or1k-unknown-linux-${LIBC}
+	exit ;;
+    or32:Linux:*:* | or1k*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     padre:Linux:*:*)
-	echo sparc-unknown-linux-gnu
+	echo sparc-unknown-linux-${LIBC}
 	exit ;;
     parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-gnu
+	echo hppa64-unknown-linux-${LIBC}
 	exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
-	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
-	  *)    echo hppa-unknown-linux-gnu ;;
+	  PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+	  PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+	  *)    echo hppa-unknown-linux-${LIBC} ;;
 	esac
 	exit ;;
     ppc64:Linux:*:*)
-	echo powerpc64-unknown-linux-gnu
+	echo powerpc64-unknown-linux-${LIBC}
 	exit ;;
     ppc:Linux:*:*)
-	echo powerpc-unknown-linux-gnu
+	echo powerpc-unknown-linux-${LIBC}
+	exit ;;
+    ppc64le:Linux:*:*)
+	echo powerpc64le-unknown-linux-${LIBC}
+	exit ;;
+    ppcle:Linux:*:*)
+	echo powerpcle-unknown-linux-${LIBC}
 	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
-	echo ${UNAME_MACHINE}-ibm-linux
+	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 	exit ;;
     sh64*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     sh*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    tile*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     vax:Linux:*:*)
-	echo ${UNAME_MACHINE}-dec-linux-gnu
+	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	exit ;;
     x86_64:Linux:*:*)
-	echo x86_64-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     xtensa*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -984,11 +1047,11 @@
 	echo i386-sequent-sysv4
 	exit ;;
     i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
+	# Unixware is an offshoot of SVR4, but it has its own version
+	# number series starting with 2...
+	# I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
+	# Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit ;;
     i*86:OS/2:*:*)
@@ -1020,7 +1083,7 @@
 	fi
 	exit ;;
     i*86:*:5:[678]*)
-    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	# UnixWare 7.x, OpenUNIX and OpenServer 6.
 	case `/bin/uname -X | grep "^Machine"` in
 	    *486*)	     UNAME_MACHINE=i486 ;;
 	    *Pentium)	     UNAME_MACHINE=i586 ;;
@@ -1048,13 +1111,13 @@
 	exit ;;
     pc:*:*:*)
 	# Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i586.
+	# uname -m prints for DJGPP always 'pc', but it prints nothing about
+	# the processor, so we play safe by assuming i586.
 	# Note: whatever this is, it MUST be the same as what config.sub
 	# prints for the "djgpp" host, or else GDB configury will decide that
 	# this is a cross-build.
 	echo i586-pc-msdosdjgpp
-        exit ;;
+	exit ;;
     Intel:Mach:3*:*)
 	echo i386-pc-mach3
 	exit ;;
@@ -1089,8 +1152,8 @@
 	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && { echo i486-ncr-sysv4; exit; } ;;
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4; exit; } ;;
     NCR*:*:4.2:* | MPRAS*:*:4.2:*)
 	OS_REL='.3'
 	test -r /etc/.relid \
@@ -1133,10 +1196,10 @@
 		echo ns32k-sni-sysv
 	fi
 	exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel@ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
+    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+			# says <Richard.M.Bartel@ccMail.Census.GOV>
+	echo i586-unisys-sysv4
+	exit ;;
     *:UNIX_System_V:4*:FTX*)
 	# From Gerald Hewes <hewes@openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
@@ -1162,11 +1225,11 @@
 	exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
-	        echo mips-nec-sysv${UNAME_RELEASE}
+		echo mips-nec-sysv${UNAME_RELEASE}
 	else
-	        echo mips-unknown-sysv${UNAME_RELEASE}
+		echo mips-unknown-sysv${UNAME_RELEASE}
 	fi
-        exit ;;
+	exit ;;
     BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
 	echo powerpc-be-beos
 	exit ;;
@@ -1179,6 +1242,9 @@
     BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
 	echo i586-pc-haiku
 	exit ;;
+    x86_64:Haiku:*:*)
+	echo x86_64-unknown-haiku
+	exit ;;
     SX-4:SUPER-UX:*:*)
 	echo sx4-nec-superux${UNAME_RELEASE}
 	exit ;;
@@ -1205,19 +1271,31 @@
 	exit ;;
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-	case $UNAME_PROCESSOR in
-	    i386)
-		eval $set_cc_for_build
-		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-		      grep IS_64BIT_ARCH >/dev/null
-		  then
-		      UNAME_PROCESSOR="x86_64"
-		  fi
-		fi ;;
-	    unknown) UNAME_PROCESSOR=powerpc ;;
-	esac
+	eval $set_cc_for_build
+	if test "$UNAME_PROCESSOR" = unknown ; then
+	    UNAME_PROCESSOR=powerpc
+	fi
+	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+	    if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		    (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		    grep IS_64BIT_ARCH >/dev/null
+		then
+		    case $UNAME_PROCESSOR in
+			i386) UNAME_PROCESSOR=x86_64 ;;
+			powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		    esac
+		fi
+	    fi
+	elif test "$UNAME_PROCESSOR" = i386 ; then
+	    # Avoid executing cc on OS X 10.9, as it ships with a stub
+	    # that puts up a graphical alert prompting to install
+	    # developer tools.  Any system running Mac OS X 10.7 or
+	    # later (Darwin 11 and later) is required to have a 64-bit
+	    # processor. This is not true of the ARM version of Darwin
+	    # that Apple uses in portable devices.
+	    UNAME_PROCESSOR=x86_64
+	fi
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
@@ -1231,7 +1309,10 @@
     *:QNX:*:4*)
 	echo i386-pc-qnx
 	exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
+    NEO-?:NONSTOP_KERNEL:*:*)
+	echo neo-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSE-*:NONSTOP_KERNEL:*:*)
 	echo nse-tandem-nsk${UNAME_RELEASE}
 	exit ;;
     NSR-?:NONSTOP_KERNEL:*:*)
@@ -1276,13 +1357,13 @@
 	echo pdp10-unknown-its
 	exit ;;
     SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
+	echo mips-sei-seiux${UNAME_RELEASE}
 	exit ;;
     *:DragonFly:*:*)
 	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit ;;
     *:*VMS:*:*)
-    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	UNAME_MACHINE=`(uname -p) 2>/dev/null`
 	case "${UNAME_MACHINE}" in
 	    A*) echo alpha-dec-vms ; exit ;;
 	    I*) echo ia64-dec-vms ; exit ;;
@@ -1300,159 +1381,11 @@
     i*86:AROS:*:*)
 	echo ${UNAME_MACHINE}-pc-aros
 	exit ;;
+    x86_64:VMkernel:*:*)
+	echo ${UNAME_MACHINE}-unknown-esx
+	exit ;;
 esac
 
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-          "4"
-#else
-	  ""
-#endif
-         ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-	printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-	printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-	{ echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-	echo c1-convex-bsd
-	exit ;;
-    c2*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-	exit ;;
-    c34*)
-	echo c34-convex-bsd
-	exit ;;
-    c38*)
-	echo c38-convex-bsd
-	exit ;;
-    c4*)
-	echo c4-convex-bsd
-	exit ;;
-    esac
-fi
-
 cat >&2 <<EOF
 $0: unable to guess system type
 
diff --git a/config.h.in b/config.h.in
index ee088c7..914289a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -9,6 +9,21 @@
 /* Define to 1 if you have the `bpf_dump' function. */
 #undef HAVE_BPF_DUMP
 
+/* capsicum support available */
+#undef HAVE_CAPSICUM
+
+/* Define to 1 if you have the `cap_enter' function. */
+#undef HAVE_CAP_ENTER
+
+/* Define to 1 if you have the `cap_ioctls_limit' function. */
+#undef HAVE_CAP_IOCTLS_LIMIT
+
+/* Define to 1 if you have the <cap-ng.h> header file. */
+#undef HAVE_CAP_NG_H
+
+/* Define to 1 if you have the `cap_rights_limit' function. */
+#undef HAVE_CAP_RIGHTS_LIMIT
+
 /* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
    don't. */
 #undef HAVE_DECL_ETHER_NTOHOST
@@ -28,6 +43,9 @@
 /* Define to 1 if you have the `getnameinfo' function. */
 #undef HAVE_GETNAMEINFO
 
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
 /* define if you have getrpcbynumber() */
 #undef HAVE_GETRPCBYNUMBER
 
@@ -37,15 +55,15 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Define to 1 if you have the `cap-ng' library (-lcap-ng). */
+#undef HAVE_LIBCAP_NG
+
 /* Define to 1 if you have the `crypto' library (-lcrypto). */
 #undef HAVE_LIBCRYPTO
 
 /* Define to 1 if you have the `rpc' library (-lrpc). */
 #undef HAVE_LIBRPC
 
-/* Define to 1 if you have the `smi' library (-lsmi). */
-#undef HAVE_LIBSMI
-
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -64,6 +82,9 @@
 /* Define to 1 if you have the <net/pfvar.h> header file. */
 #undef HAVE_NET_PFVAR_H
 
+/* Define to 1 if you have the `openat' function. */
+#undef HAVE_OPENAT
+
 /* Define to 1 if you have the <openssl/evp.h> header file. */
 #undef HAVE_OPENSSL_EVP_H
 
@@ -97,6 +118,9 @@
 /* Define to 1 if you have the `pcap_findalldevs' function. */
 #undef HAVE_PCAP_FINDALLDEVS
 
+/* Define to 1 if you have the `pcap_free_datalinks' function. */
+#undef HAVE_PCAP_FREE_DATALINKS
+
 /* Define to 1 if the system has the type `pcap_if_t'. */
 #undef HAVE_PCAP_IF_T
 
@@ -112,9 +136,15 @@
 /* Define to 1 if you have the `pcap_setdirection' function. */
 #undef HAVE_PCAP_SETDIRECTION
 
-/* define if libpcap has pcap_set_datalink() */
+/* Define to 1 if you have the `pcap_set_datalink' function. */
 #undef HAVE_PCAP_SET_DATALINK
 
+/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
+#undef HAVE_PCAP_SET_IMMEDIATE_MODE
+
+/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
+#undef HAVE_PCAP_SET_TSTAMP_PRECISION
+
 /* Define to 1 if you have the `pcap_set_tstamp_type' function. */
 #undef HAVE_PCAP_SET_TSTAMP_TYPE
 
@@ -142,18 +172,12 @@
 /* Define to 1 if you have the `sigset' function. */
 #undef HAVE_SIGSET
 
-/* Define to 1 if you have the <smi.h> header file. */
-#undef HAVE_SMI_H
-
 /* Define to 1 if you have the `snprintf' function. */
 #undef HAVE_SNPRINTF
 
 /* if struct sockaddr has the sa_len member */
 #undef HAVE_SOCKADDR_SA_LEN
 
-/* define if you have struct sockaddr_storage */
-#undef HAVE_SOCKADDR_STORAGE
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
@@ -187,15 +211,15 @@
 /* Define to 1 if the system has the type `struct ether_addr'. */
 #undef HAVE_STRUCT_ETHER_ADDR
 
-/* Define to 1 if you have the <sys/bitypes.h> header file. */
-#undef HAVE_SYS_BITYPES_H
-
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define to 1 if the system has the type `uintptr_t'. */
+#undef HAVE_UINTPTR_T
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
@@ -220,9 +244,6 @@
 /* if unaligned access fails */
 #undef LBL_ALIGN
 
-/* Define if you enable support for libsmi */
-#undef LIBSMI
-
 /* define if you need to include missing/addrinfo.h */
 #undef NEED_ADDRINFO_H
 
@@ -280,6 +301,9 @@
 /* define if you have ether_ntohost() and it works */
 #undef USE_ETHER_NTOHOST
 
+/* Define if you enable support for libsmi */
+#undef USE_LIBSMI
+
 /* define if should chroot when dropping privileges */
 #undef WITH_CHROOT
 
@@ -340,16 +364,16 @@
    a type exists and the standard includes do not define it. */
 #undef int8_t
 
-/* Define to `unsigned short' if u_int16_t not defined. */
+/* Define to `uint16_t' if u_int16_t not defined. */
 #undef u_int16_t
 
-/* Define to `unsigned int' if u_int32_t not defined. */
+/* Define to `uint32_t' if u_int32_t not defined. */
 #undef u_int32_t
 
-/* Define to `unsigned long long' if u_int64_t not defined. */
+/* Define to `uint64_t' if u_int64_t not defined. */
 #undef u_int64_t
 
-/* Define to `unsigned char' if u_int8_t not defined. */
+/* Define to `uint8_t' if u_int8_t not defined. */
 #undef u_int8_t
 
 /* Define to the type of an unsigned integer type of width exactly 16 bits if
@@ -367,3 +391,7 @@
 /* Define to the type of an unsigned integer type of width exactly 8 bits if
    such a type exists and the standard includes do not define it. */
 #undef uint8_t
+
+/* Define to the type of an unsigned integer type wide enough to hold a
+   pointer, if such a type exists, and if the system does not define it. */
+#undef uintptr_t
diff --git a/config.sub b/config.sub
old mode 100755
new mode 100644
index 8518609..bc855a2
--- a/config.sub
+++ b/config.sub
@@ -1,38 +1,31 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-#   Free Software Foundation, Inc.
+#   Copyright 1992-2015 Free Software Foundation, Inc.
 
-timestamp='2009-12-31'
+timestamp='2015-02-22'
 
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file 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
+# This file 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 3 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.
+# 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., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches to <config-patches@gnu.org>.  Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# Please send patches to <config-patches@gnu.org>.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -75,9 +68,7 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
-Software Foundation, Inc.
+Copyright 1992-2015 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -124,13 +115,18 @@
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
@@ -153,12 +149,12 @@
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray | -microblaze)
+	-apple | -axis | -knuth | -cray | -microblaze*)
 		os=
 		basic_machine=$1
 		;;
-        -bluegene*)
-	        os=-cnk
+	-bluegene*)
+		os=-cnk
 		;;
 	-sim | -cisco | -oki | -wec | -winbond)
 		os=
@@ -174,10 +170,10 @@
 		os=-chorusos
 		basic_machine=$1
 		;;
- 	-chorusrdb)
- 		os=-chorusrdb
+	-chorusrdb)
+		os=-chorusrdb
 		basic_machine=$1
- 		;;
+		;;
 	-hiux*)
 		os=-hiuxwe2
 		;;
@@ -222,6 +218,12 @@
 	-isc*)
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-lynx*178)
+		os=-lynxos178
+		;;
+	-lynx*5)
+		os=-lynxos5
+		;;
 	-lynx*)
 		os=-lynxos
 		;;
@@ -246,20 +248,28 @@
 	# Some are omitted here because they have special meanings below.
 	1750a | 580 \
 	| a29k \
+	| aarch64 | aarch64_be \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| arc | arceb \
+	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+	| avr | avr32 \
+	| be32 | be64 \
 	| bfin \
-	| c4x | clipper \
+	| c4x | c8051 | clipper \
 	| d10v | d30v | dlx | dsp16xx \
-	| fido | fr30 | frv \
+	| epiphany \
+	| fido | fr30 | frv | ft32 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| hexagon \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| k1om \
+	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | mcore | mep | metag \
+	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -273,38 +283,55 @@
 	| mips64vr5900 | mips64vr5900el \
 	| mipsisa32 | mipsisa32el \
 	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa32r6 | mipsisa32r6el \
 	| mipsisa64 | mipsisa64el \
 	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64r6 | mipsisa64r6el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipsr5900 | mipsr5900el \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
 	| moxie \
 	| mt \
 	| msp430 \
-	| nios | nios2 \
+	| nds32 | nds32le | nds32be \
+	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
-	| or32 \
+	| open8 | or1k | or1knd | or32 \
 	| pdp10 | pdp11 | pj | pjl \
-	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
-	| rx \
+	| riscv32 | riscv64 \
+	| rl78 | rx \
 	| score \
 	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-	| spu | strongarm \
-	| tahoe | thumb | tic4x | tic80 | tron \
+	| spu \
+	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
-	| v850 | v850e \
+	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+	| visium \
 	| we32k \
-	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
 		basic_machine=$basic_machine-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
-		# Motorola 68HC11/12.
+	c54x)
+		basic_machine=tic54x-unknown
+		;;
+	c55x)
+		basic_machine=tic55x-unknown
+		;;
+	c6x)
+		basic_machine=tic6x-unknown
+		;;
+	leon|leon[3-9])
+		basic_machine=sparc-$basic_machine
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -314,6 +341,21 @@
 		basic_machine=mt-unknown
 		;;
 
+	strongarm | thumb | xscale)
+		basic_machine=arm-unknown
+		;;
+	xgate)
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	xscaleeb)
+		basic_machine=armeb-unknown
+		;;
+
+	xscaleel)
+		basic_machine=armel-unknown
+		;;
+
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
@@ -328,25 +370,31 @@
 	# Recognize the basic CPU types with company name.
 	580-* \
 	| a29k-* \
+	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
+	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
-	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-	| clipper-* | craynv-* | cydra-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* \
+	| c8051-* | clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
+	| k1om-* \
+	| le32-* | le64-* \
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| microblaze-* | microblazeel-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -360,33 +408,42 @@
 	| mips64vr5900-* | mips64vr5900el-* \
 	| mipsisa32-* | mipsisa32el-* \
 	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa32r6-* | mipsisa32r6el-* \
 	| mipsisa64-* | mipsisa64el-* \
 	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64r6-* | mipsisa64r6el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipsr5900-* | mipsr5900el-* \
 	| mipstx39-* | mipstx39el-* \
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
-	| nios-* | nios2-* \
+	| nds32-* | nds32le-* | nds32be-* \
+	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
+	| open8-* \
+	| or1k*-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
-	| romp-* | rs6000-* | rx-* \
+	| rl78-* | romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
-	| tahoe-* | thumb-* \
-	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| tahoe-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tile*-* \
 	| tron-* \
 	| ubicom32-* \
-	| v850-* | v850e-* | vax-* \
+	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+	| vax-* \
+	| visium-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
 	| ymp-* \
 	| z8k-* | z80-*)
@@ -411,7 +468,7 @@
 		basic_machine=a29k-amd
 		os=-udi
 		;;
-    	abacus)
+	abacus)
 		basic_machine=abacus-unknown
 		;;
 	adobe68k)
@@ -481,11 +538,20 @@
 		basic_machine=powerpc-ibm
 		os=-cnk
 		;;
+	c54x-*)
+		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	c55x-*)
+		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	c6x-*)
+		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	c90)
 		basic_machine=c90-cray
 		os=-unicos
 		;;
-        cegcc)
+	cegcc)
 		basic_machine=arm-unknown
 		os=-cegcc
 		;;
@@ -517,7 +583,7 @@
 		basic_machine=craynv-cray
 		os=-unicosmp
 		;;
-	cr16)
+	cr16 | cr16-*)
 		basic_machine=cr16-unknown
 		os=-elf
 		;;
@@ -675,7 +741,6 @@
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
 		;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
@@ -714,6 +779,9 @@
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
+	leon-*|leon[3-9]-*)
+		basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+		;;
 	m68knommu)
 		basic_machine=m68k-unknown
 		os=-linux
@@ -733,11 +801,15 @@
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-        microblaze)
+	microblaze*)
 		basic_machine=microblaze-xilinx
 		;;
+	mingw64)
+		basic_machine=x86_64-pc
+		os=-mingw64
+		;;
 	mingw32)
-		basic_machine=i386-pc
+		basic_machine=i686-pc
 		os=-mingw32
 		;;
 	mingw32ce)
@@ -765,6 +837,10 @@
 		basic_machine=powerpc-unknown
 		os=-morphos
 		;;
+	moxiebox)
+		basic_machine=moxie-unknown
+		os=-moxiebox
+		;;
 	msdos)
 		basic_machine=i386-pc
 		os=-msdos
@@ -772,10 +848,18 @@
 	ms1-*)
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
+	msys)
+		basic_machine=i686-pc
+		os=-msys
+		;;
 	mvs)
 		basic_machine=i370-ibm
 		os=-mvs
 		;;
+	nacl)
+		basic_machine=le32-unknown
+		os=-nacl
+		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
@@ -840,6 +924,12 @@
 	np1)
 		basic_machine=np1-gould
 		;;
+	neo-tandem)
+		basic_machine=neo-tandem
+		;;
+	nse-tandem)
+		basic_machine=nse-tandem
+		;;
 	nsr-tandem)
 		basic_machine=nsr-tandem
 		;;
@@ -922,9 +1012,10 @@
 		;;
 	power)	basic_machine=power-ibm
 		;;
-	ppc)	basic_machine=powerpc-unknown
+	ppc | ppcbe)	basic_machine=powerpc-unknown
 		;;
-	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+	ppc-* | ppcbe-*)
+		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 		basic_machine=powerpcle-unknown
@@ -949,7 +1040,11 @@
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
-	rdos)
+	rdos | rdos64)
+		basic_machine=x86_64-pc
+		os=-rdos
+		;;
+	rdos32)
 		basic_machine=i386-pc
 		os=-rdos
 		;;
@@ -1018,6 +1113,9 @@
 		basic_machine=i860-stratus
 		os=-sysv4
 		;;
+	strongarm-* | thumb-*)
+		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	sun2)
 		basic_machine=m68000-sun
 		;;
@@ -1074,20 +1172,8 @@
 		basic_machine=t90-cray
 		os=-unicos
 		;;
-	tic54x | c54x*)
-		basic_machine=tic54x-unknown
-		os=-coff
-		;;
-	tic55x | c55x*)
-		basic_machine=tic55x-unknown
-		os=-coff
-		;;
-	tic6x | c6x*)
-		basic_machine=tic6x-unknown
-		os=-coff
-		;;
 	tile*)
-		basic_machine=tile-unknown
+		basic_machine=$basic_machine-unknown
 		os=-linux-gnu
 		;;
 	tx39)
@@ -1157,6 +1243,9 @@
 	xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
+	xscale-* | xscalee[bl]-*)
+		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+		;;
 	ymp)
 		basic_machine=ymp-cray
 		os=-unicos
@@ -1254,11 +1343,11 @@
 if [ x"$os" != x"" ]
 then
 case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
+	# First match some system type aliases
+	# that might get confused with valid system types.
 	# -solaris* is a basic system type, with this one exception.
-        -auroraux)
-	        os=-auroraux
+	-auroraux)
+		os=-auroraux
 		;;
 	-solaris1 | -solaris1.*)
 		os=`echo $os | sed -e 's|solaris1|sunos4|'`
@@ -1282,28 +1371,29 @@
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
-	      | -sym* | -kopensolaris* \
+	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* | -aros* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-	      | -openbsd* | -solidbsd* \
+	      | -bitrig* | -openbsd* | -solidbsd* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
-	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1342,7 +1432,7 @@
 	-opened*)
 		os=-openedition
 		;;
-        -os400*)
+	-os400*)
 		os=-os400
 		;;
 	-wince*)
@@ -1391,7 +1481,7 @@
 	-sinix*)
 		os=-sysv4
 		;;
-        -tpf*)
+	-tpf*)
 		os=-tpf
 		;;
 	-triton*)
@@ -1427,17 +1517,14 @@
 	-aros*)
 		os=-aros
 		;;
-	-kaos*)
-		os=-kaos
-		;;
 	-zvmoe)
 		os=-zvmoe
 		;;
 	-dicos*)
 		os=-dicos
 		;;
-        -nacl*)
-	        ;;
+	-nacl*)
+		;;
 	-none)
 		;;
 	*)
@@ -1460,10 +1547,10 @@
 # system, and we'll never get to this point.
 
 case $basic_machine in
-        score-*)
+	score-*)
 		os=-elf
 		;;
-        spu-*)
+	spu-*)
 		os=-elf
 		;;
 	*-acorn)
@@ -1475,8 +1562,23 @@
 	arm*-semi)
 		os=-aout
 		;;
-        c4x-* | tic4x-*)
-        	os=-coff
+	c4x-* | tic4x-*)
+		os=-coff
+		;;
+	c8051-*)
+		os=-elf
+		;;
+	hexagon-*)
+		os=-elf
+		;;
+	tic54x-*)
+		os=-coff
+		;;
+	tic55x-*)
+		os=-coff
+		;;
+	tic6x-*)
+		os=-coff
 		;;
 	# This must come before the *-dec entry.
 	pdp10-*)
@@ -1496,14 +1598,11 @@
 		;;
 	m68000-sun)
 		os=-sunos3
-		# This also exists in the configure program, but was not the
-		# default.
-		# os=-sunos4
 		;;
 	m68*-cisco)
 		os=-aout
 		;;
-        mep-*)
+	mep-*)
 		os=-elf
 		;;
 	mips*-cisco)
@@ -1530,7 +1629,7 @@
 	*-ibm)
 		os=-aix
 		;;
-    	*-knuth)
+	*-knuth)
 		os=-mmixware
 		;;
 	*-wec)
diff --git a/configure b/configure
index be60aa5..43b3068 100755
--- a/configure
+++ b/configure
@@ -633,6 +633,7 @@
 V_CCOPT
 MKDEP
 DEPENDENCY_CFLAG
+AR
 RANLIB
 PCAP_CONFIG
 LIBOBJS
@@ -702,8 +703,11 @@
 enable_smb
 with_user
 with_chroot
+with_sandbox_capsicum
 enable_ipv6
+with_system_libpcap
 with_crypto
+with_cap_ng
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1339,7 +1343,11 @@
   --without-smi           don't link with libsmi
   --with-user=USERNAME    drop privileges by default to USERNAME
   --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY
+  --with-sandbox-capsicum use Capsicum security functions [default=yes, if
+                          available]
+  --with-system-libpcap   don't use local pcap library
   --with-crypto           use OpenSSL libcrypto [default=yes, if available]
+  --with-cap-ng           use libcap-ng [default=yes, if available]
 
 Some influential environment variables:
   CC          C compiler command
@@ -3778,6 +3786,7 @@
 
 	fi
 fi
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4318,38 +4327,6 @@
 		esac
 	fi
 	;;
-
-linux*)
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Linux kernel version" >&5
-$as_echo_n "checking Linux kernel version... " >&6; }
- 	if test "$cross_compiling" = yes; then
- 		if ${ac_cv_linux_vers+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_linux_vers=unknown
-fi
-
- 	else
- 		if ${ac_cv_linux_vers+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_linux_vers=`uname -r 2>&1 | \
- 			sed -n -e '$s/.* //' -e '$s/\..*//p'`
-fi
-
- 	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_linux_vers" >&5
-$as_echo "$ac_cv_linux_vers" >&6; }
- 	if test $ac_cv_linux_vers = unknown ; then
- 		as_fn_error $? "cannot determine linux version when cross-compiling" "$LINENO" 5
- 	fi
-	if test $ac_cv_linux_vers -lt 2 ; then
-		as_fn_error $? "version 2 or higher required; see the INSTALL doc for more info" "$LINENO" 5
-	fi
-	;;
-
-*)
-	;;
 esac
 
 
@@ -4363,19 +4340,13 @@
 
 
 if test "x$with_smi" != "xno" ; then
-for ac_header in smi.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "smi.h" "ac_cv_header_smi_h" "$ac_includes_default"
+	ac_fn_c_check_header_mongrel "$LINENO" "smi.h" "ac_cv_header_smi_h" "$ac_includes_default"
 if test "x$ac_cv_header_smi_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SMI_H 1
-_ACEOF
 
-fi
-
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for smiInit in -lsmi" >&5
+		#
+		# OK, we found smi.h.  Do we have libsmi with smiInit?
+		#
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for smiInit in -lsmi" >&5
 $as_echo_n "checking for smiInit in -lsmi... " >&6; }
 if ${ac_cv_lib_smi_smiInit+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -4412,27 +4383,26 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_smi_smiInit" >&5
 $as_echo "$ac_cv_lib_smi_smiInit" >&6; }
 if test "x$ac_cv_lib_smi_smiInit" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBSMI 1
-_ACEOF
 
-  LIBS="-lsmi $LIBS"
-
-fi
-
-if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
-then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libsmi" >&5
+			#
+			# OK, we have libsmi with smiInit.  Can we use it?
+			#
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libsmi" >&5
 $as_echo_n "checking whether to enable libsmi... " >&6; }
-        if test "$cross_compiling" = yes; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: not when cross-compiling" >&5
+			savedlibs="$LIBS"
+			LIBS="-lsmi $LIBS"
+			if test "$cross_compiling" = yes; then :
+
+					{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not when cross-compiling" >&5
 $as_echo "not when cross-compiling" >&6; }
-  libsmi=no
+					LIBS="$savedlibs"
+
 
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
- /* libsmi available check */
+
+/* libsmi available check */
 #include <smi.h>
 main()
 {
@@ -4452,32 +4422,41 @@
 
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+
+					{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
-$as_echo "#define LIBSMI 1" >>confdefs.h
+$as_echo "#define USE_LIBSMI 1" >>confdefs.h
 
-  libsmi=yes
+
 else
-   case $? in
-  1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - smiInit failed" >&5
+
+																																			case $? in
+					  1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - smiInit failed" >&5
 $as_echo "no - smiInit failed" >&6; } ;;
-  2) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - header/library version mismatch" >&5
+					  2) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - header/library version mismatch" >&5
 $as_echo "no - header/library version mismatch" >&6; } ;;
-  3) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - can't determine library version" >&5
+					  3) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - can't determine library version" >&5
 $as_echo "no - can't determine library version" >&6; } ;;
-  4) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - too old" >&5
+					  4) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - too old" >&5
 $as_echo "no - too old" >&6; } ;;
-  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+					  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; } ;;
-  esac
-  libsmi=no
+					esac
+					LIBS="$savedlibs"
+
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
+
 fi
+
+
+fi
+
+
 fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the possibly-buggy SMB printer" >&5
@@ -4546,6 +4525,56 @@
 $as_echo "no" >&6; }
 fi
 
+
+# Check whether --with-sandbox-capsicum was given.
+if test "${with_sandbox_capsicum+set}" = set; then :
+  withval=$with_sandbox_capsicum;
+fi
+
+#
+# Check whether various functions are available.  If any are, set
+# ac_lbl_capsicum_function_seen to yes; if any are not, set
+# ac_lbl_capsicum_function_not_seen to yes.
+#
+# We don't check cap_rights_init(), as it's a macro, wrapping another
+# function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
+# doesn't handle that.
+#
+# All of the ones we check for must be available in order to enable
+# capsicum sandboxing.
+#
+# XXX - do we need to check for all of them, or are there some that, if
+# present, imply others are present?
+#
+if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
+	for ac_func in cap_enter cap_rights_limit cap_ioctls_limit openat
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+ ac_lbl_capsicum_function_seen=yes
+else
+  ac_lbl_capsicum_function_not_seen=yes
+fi
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to sandbox using capsicum" >&5
+$as_echo_n "checking whether to sandbox using capsicum... " >&6; }
+if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
+
+$as_echo "#define HAVE_CAPSICUM 1" >>confdefs.h
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
 #
 # We must check this before checking whether to enable IPv6, because,
 # on some platforms (such as SunOS 5.x), the test program requires
@@ -4820,7 +4849,7 @@
   enableval=$enable_ipv6;  case "$enableval" in
 yes)   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-       LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+       LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
 
 $as_echo "#define INET6 1" >>confdefs.h
 
@@ -4855,7 +4884,7 @@
 if ac_fn_c_try_compile "$LINENO"; then :
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-  LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+  LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
 
 $as_echo "#define INET6 1" >>confdefs.h
 
@@ -5091,7 +5120,7 @@
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then :
-  td_cv_buggygetaddrinfo=yes
+  td_cv_buggygetaddrinfo=unknown
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -5205,6 +5234,9 @@
 	if test "$td_cv_buggygetaddrinfo" = no; then
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: good" >&5
 $as_echo "good" >&6; }
+	elif test "$td_cv_buggygetaddrinfo" = unknown; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown (cross-compiling)" >&5
+$as_echo "unknown (cross-compiling)" >&6; }
 	else
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy" >&5
 $as_echo "buggy" >&6; }
@@ -5384,45 +5416,6 @@
 	missing_includes=yes
 fi
 
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_storage" >&5
-$as_echo_n "checking for sockaddr_storage... " >&6; }
-	if ${ac_cv_sa_storage+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#		include <sys/types.h>
-#		include <sys/socket.h>
-int
-main ()
-{
-struct sockaddr_storage s
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sa_storage=yes
-else
-  ac_cv_sa_storage=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sa_storage" >&5
-$as_echo "$ac_cv_sa_storage" >&6; }
-	if test $ac_cv_sa_storage = yes; then
-
-$as_echo "#define HAVE_SOCKADDR_STORAGE 1" >>confdefs.h
-
-	fi
-
-if test "$ac_cv_sa_storage" = no; then
-	missing_includes=yes
-fi
-
 ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf"
 if test "x$ac_cv_func_vfprintf" = xyes; then :
   $as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h
@@ -5501,6 +5494,19 @@
 
 fi
 
+ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long"
+if test "x$ac_cv_func_getopt_long" = xyes; then :
+  $as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h
+
+else
+  case " $LIBOBJS " in
+  *" getopt_long.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
+ ;;
+esac
+
+fi
+
 
 for ac_func in fork vfork strftime
 do :
@@ -5809,24 +5815,34 @@
 		    LIBS="$LIBS $pfopen"
 	    fi
     fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for local pcap library" >&5
+	libpcap=FAIL
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for local pcap library" >&5
 $as_echo_n "checking for local pcap library... " >&6; }
-    libpcap=FAIL
-    lastdir=FAIL
-    places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
-	egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
-    for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do
-	    basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
-	        sed -e 's/-PRE-GIT$//' `
-	    if test $lastdir = $basedir ; then
-		    		    continue;
-	    fi
-	    lastdir=$dir
-	    if test -r $dir/libpcap.a ; then
-		    libpcap=$dir/libpcap.a
-		    d=$dir
-		    	    fi
-    done
+
+# Check whether --with-system-libpcap was given.
+if test "${with_system_libpcap+set}" = set; then :
+  withval=$with_system_libpcap;
+fi
+
+	if test "x$with_system_libpcap" != xyes ; then
+		lastdir=FAIL
+    	places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
+		egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
+    	places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+		egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'`
+    	for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
+	    	basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \
+	        	sed -e 's/-PRE-GIT$//' `
+	    	if test $lastdir = $basedir ; then
+		    			    	continue;
+	    	fi
+	    	lastdir=$dir
+	    	if test -r $dir/libpcap.a ; then
+		    	libpcap=$dir/libpcap.a
+		    	d=$dir
+		    		    	fi
+		done
+	fi
     if test $libpcap = FAIL ; then
 	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
 $as_echo "not found" >&6; }
@@ -6011,13 +6027,23 @@
 	    V_PCAPDEP=$libpcap
 	    places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
     	 		egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+	    places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
+    	 		egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'`
+            pcapH=FAIL
 	    if test -r $d/pcap.h; then
-		    V_INCLS="-I$d $V_INCLS"
-	    elif test -r $places/pcap.h; then
-		    V_INCLS="-I$places $V_INCLS"
+                    pcapH=$d
 	    else
-                    as_fn_error see INSTALL "cannot find pcap.h" "$LINENO" 5
+                for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
+                   if test -r $dir/pcap.h ; then
+                       pcapH=$dir
+                   fi
+                done
+            fi
+
+            if test $pcapH = FAIL ; then
+                    as_fn_error $? "cannot find pcap.h: see INSTALL" "$LINENO" 5
  	    fi
+            V_INCLS="-I$pcapH $V_INCLS"
 	    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libpcap" >&5
 $as_echo "$libpcap" >&6; }
 	    # Extract the first word of "pcap-config", so it can be a program name with args.
@@ -6132,93 +6158,6 @@
 fi
 
 
-                        ac_fn_c_check_func "$LINENO" "pcap_list_datalinks" "ac_cv_func_pcap_list_datalinks"
-if test "x$ac_cv_func_pcap_list_datalinks" = xyes; then :
-
-$as_echo "#define HAVE_PCAP_LIST_DATALINKS 1" >>confdefs.h
-
-else
-
-	    case " $LIBOBJS " in
-  *" datalinks.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS datalinks.$ac_objext"
- ;;
-esac
-
-
-fi
-
-    ac_fn_c_check_func "$LINENO" "pcap_set_datalink" "ac_cv_func_pcap_set_datalink"
-if test "x$ac_cv_func_pcap_set_datalink" = xyes; then :
-
-$as_echo "#define HAVE_PCAP_SET_DATALINK 1" >>confdefs.h
-
-fi
-
-    ac_fn_c_check_func "$LINENO" "pcap_datalink_name_to_val" "ac_cv_func_pcap_datalink_name_to_val"
-if test "x$ac_cv_func_pcap_datalink_name_to_val" = xyes; then :
-
-
-$as_echo "#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1" >>confdefs.h
-
-	    ac_fn_c_check_func "$LINENO" "pcap_datalink_val_to_description" "ac_cv_func_pcap_datalink_val_to_description"
-if test "x$ac_cv_func_pcap_datalink_val_to_description" = xyes; then :
-
-$as_echo "#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1" >>confdefs.h
-
-else
-
-		    case " $LIBOBJS " in
-  *" dlnames.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS dlnames.$ac_objext"
- ;;
-esac
-
-
-fi
-
-
-else
-
-	    case " $LIBOBJS " in
-  *" dlnames.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS dlnames.$ac_objext"
- ;;
-esac
-
-
-fi
-
-
-                        for ac_func in pcap_breakloop
-do :
-  ac_fn_c_check_func "$LINENO" "pcap_breakloop" "ac_cv_func_pcap_breakloop"
-if test "x$ac_cv_func_pcap_breakloop" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_PCAP_BREAKLOOP 1
-_ACEOF
-
-fi
-done
-
-
-                ac_fn_c_check_func "$LINENO" "pcap_dump_ftell" "ac_cv_func_pcap_dump_ftell"
-if test "x$ac_cv_func_pcap_dump_ftell" = xyes; then :
-
-$as_echo "#define HAVE_PCAP_DUMP_FTELL 1" >>confdefs.h
-
-else
-
-	    case " $LIBOBJS " in
-  *" pcap_dump_ftell.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS pcap_dump_ftell.$ac_objext"
- ;;
-esac
-
-
-fi
-
-
 
 #
 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
@@ -6587,6 +6526,110 @@
 	missing_includes=yes
 fi
 
+ac_fn_c_check_func "$LINENO" "pcap_list_datalinks" "ac_cv_func_pcap_list_datalinks"
+if test "x$ac_cv_func_pcap_list_datalinks" = xyes; then :
+
+
+$as_echo "#define HAVE_PCAP_LIST_DATALINKS 1" >>confdefs.h
+
+	    for ac_func in pcap_free_datalinks
+do :
+  ac_fn_c_check_func "$LINENO" "pcap_free_datalinks" "ac_cv_func_pcap_free_datalinks"
+if test "x$ac_cv_func_pcap_free_datalinks" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_FREE_DATALINKS 1
+_ACEOF
+
+fi
+done
+
+
+else
+
+	    case " $LIBOBJS " in
+  *" datalinks.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS datalinks.$ac_objext"
+ ;;
+esac
+
+
+fi
+
+for ac_func in pcap_set_datalink
+do :
+  ac_fn_c_check_func "$LINENO" "pcap_set_datalink" "ac_cv_func_pcap_set_datalink"
+if test "x$ac_cv_func_pcap_set_datalink" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_DATALINK 1
+_ACEOF
+
+fi
+done
+
+ac_fn_c_check_func "$LINENO" "pcap_datalink_name_to_val" "ac_cv_func_pcap_datalink_name_to_val"
+if test "x$ac_cv_func_pcap_datalink_name_to_val" = xyes; then :
+
+
+$as_echo "#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1" >>confdefs.h
+
+	    ac_fn_c_check_func "$LINENO" "pcap_datalink_val_to_description" "ac_cv_func_pcap_datalink_val_to_description"
+if test "x$ac_cv_func_pcap_datalink_val_to_description" = xyes; then :
+
+$as_echo "#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1" >>confdefs.h
+
+else
+
+		    case " $LIBOBJS " in
+  *" dlnames.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS dlnames.$ac_objext"
+ ;;
+esac
+
+
+fi
+
+
+else
+
+	    case " $LIBOBJS " in
+  *" dlnames.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS dlnames.$ac_objext"
+ ;;
+esac
+
+
+fi
+
+
+for ac_func in pcap_breakloop
+do :
+  ac_fn_c_check_func "$LINENO" "pcap_breakloop" "ac_cv_func_pcap_breakloop"
+if test "x$ac_cv_func_pcap_breakloop" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_BREAKLOOP 1
+_ACEOF
+
+fi
+done
+
+
+ac_fn_c_check_func "$LINENO" "pcap_dump_ftell" "ac_cv_func_pcap_dump_ftell"
+if test "x$ac_cv_func_pcap_dump_ftell" = xyes; then :
+
+$as_echo "#define HAVE_PCAP_DUMP_FTELL 1" >>confdefs.h
+
+else
+
+	    case " $LIBOBJS " in
+  *" pcap_dump_ftell.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS pcap_dump_ftell.$ac_objext"
+ ;;
+esac
+
+
+fi
+
+
 #
 # Do we have the new open API?  Check for pcap_create, and assume that,
 # if we do, we also have pcap_activate() and the other new routines
@@ -6619,9 +6662,28 @@
 fi
 done
 
+	#
+	# And do we have pcap_set_tstamp_precision?  If so, we assume
+	# we also have pcap_open_offline_with_tstamp_precision.
+	#
+	for ac_func in pcap_set_tstamp_precision
+do :
+  ac_fn_c_check_func "$LINENO" "pcap_set_tstamp_precision" "ac_cv_func_pcap_set_tstamp_precision"
+if test "x$ac_cv_func_pcap_set_tstamp_precision" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_TSTAMP_PRECISION 1
+_ACEOF
+
+fi
+done
+
 fi
 
-for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection
+#
+# Check for a miscellaneous collection of functions which we use
+# if we have them.
+#
+for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -6676,7 +6738,7 @@
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
     if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
-    	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
 $as_echo "#define HAVE_PCAP_VERSION 1" >>confdefs.h
@@ -6835,6 +6897,7 @@
 #
 # Make sure we have definitions for all the C99 specified-width types
 # (regardless of whether the environment is a C99 environment or not).
+#
 ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t"
 case $ac_cv_c_int8_t in #(
   no|yes) ;; #(
@@ -6935,73 +6998,96 @@
 
 
 #
-# For now, we're using the old BSD-style u_intXX_t types, so check for
-# them.
+# Make sure we have a definition for C99's uintptr_t (regardless of
+# whether the environment is a C99 environment or not).
 #
-# We should probably migrate to the standard C uintXX_t types.
-#
-for ac_header in sys/bitypes.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "sys/bitypes.h" "ac_cv_header_sys_bitypes_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_bitypes_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_BITYPES_H 1
+
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = xyes; then :
+
+$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h
+
+else
+  for ac_type in 'unsigned int' 'unsigned long int' \
+	'unsigned long long int'; do
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
+test_array [0] = 0;
+return test_array [0];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define uintptr_t $ac_type
 _ACEOF
 
+	  ac_type=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       test -z "$ac_type" && break
+     done
 fi
 
-done
 
 
+#
+# Define the old BSD specified-width types in terms of the C99 types;
+# we may need them with libpcap include files.
+#
 ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+#include <sys/types.h>
+
 "
 if test "x$ac_cv_type_u_int8_t" = xyes; then :
 
 else
 
-$as_echo "#define u_int8_t unsigned char" >>confdefs.h
+$as_echo "#define u_int8_t uint8_t" >>confdefs.h
 
 fi
 
 ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+#include <sys/types.h>
+
 "
 if test "x$ac_cv_type_u_int16_t" = xyes; then :
 
 else
 
-$as_echo "#define u_int16_t unsigned short" >>confdefs.h
+$as_echo "#define u_int16_t uint16_t" >>confdefs.h
 
 fi
 
 ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+#include <sys/types.h>
+
 "
 if test "x$ac_cv_type_u_int32_t" = xyes; then :
 
 else
 
-$as_echo "#define u_int32_t unsigned int" >>confdefs.h
+$as_echo "#define u_int32_t uint32_t" >>confdefs.h
 
 fi
 
 ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
+#include <sys/types.h>
+
 "
 if test "x$ac_cv_type_u_int64_t" = xyes; then :
 
 else
 
-$as_echo "#define u_int64_t unsigned long long" >>confdefs.h
+$as_echo "#define u_int64_t uint64_t" >>confdefs.h
 
 fi
 
@@ -7030,16 +7116,13 @@
 	    #include <inttypes.h>
 	    #include <stdio.h>
 	    #include <sys/types.h>
-	    #ifdef HAVE_SYS_BITYPES_H
-	    #include <sys/bitypes.h>
-	    #endif
 
 	    main()
 	    {
-	      printf("%" PRId64 "\n", (u_int64_t)1);
-	      printf("%" PRIo64 "\n", (u_int64_t)1);
-	      printf("%" PRIx64 "\n", (u_int64_t)1);
-	      printf("%" PRIu64 "\n", (u_int64_t)1);
+	      printf("%" PRId64 "\n", (uint64_t)1);
+	      printf("%" PRIo64 "\n", (uint64_t)1);
+	      printf("%" PRIx64 "\n", (uint64_t)1);
+	      printf("%" PRIu64 "\n", (uint64_t)1);
 	    }
 
 
@@ -7088,15 +7171,12 @@
 #	    ifdef HAVE_INTTYPES_H
 	    #include <inttypes.h>
 #	    endif
-#	    ifdef HAVE_SYS_BITYPES_H
-            #include <sys/bitypes.h>
-#	    endif
 	    #include <stdio.h>
 	    #include <sys/types.h>
 
 	    main()
 	    {
-	      u_int64_t t = 1;
+	      uint64_t t = 1;
 	      char strbuf[16+1];
 	      sprintf(strbuf, "%016lx", t << 32);
 	      if (strcmp(strbuf, "0000000100000000") == 0)
@@ -7145,15 +7225,12 @@
 #	    ifdef HAVE_INTTYPES_H
 	    #include <inttypes.h>
 #	    endif
-#	    ifdef HAVE_SYS_BITYPES_H
-            #include <sys/bitypes.h>
-#	    endif
 	    #include <stdio.h>
 	    #include <sys/types.h>
 
 	    main()
 	    {
-	      u_int64_t t = 1;
+	      uint64_t t = 1;
 	      char strbuf[16+1];
 	      sprintf(strbuf, "%016llx", t << 32);
 	      if (strcmp(strbuf, "0000000100000000") == 0)
@@ -7202,15 +7279,12 @@
 #	    ifdef HAVE_INTTYPES_H
 	    #include <inttypes.h>
 #	    endif
-#	    ifdef HAVE_SYS_BITYPES_H
-            #include <sys/bitypes.h>
-#	    endif
 	    #include <stdio.h>
 	    #include <sys/types.h>
 
 	    main()
 	    {
-	      u_int64_t t = 1;
+	      uint64_t t = 1;
 	      char strbuf[16+1];
 	      sprintf(strbuf, "%016Lx", t << 32);
 	      if (strcmp(strbuf, "0000000100000000") == 0)
@@ -7259,15 +7333,12 @@
 #	    ifdef HAVE_INTTYPES_H
 	    #include <inttypes.h>
 #	    endif
-#	    ifdef HAVE_SYS_BITYPES_H
-            #include <sys/bitypes.h>
-#	    endif
 	    #include <stdio.h>
 	    #include <sys/types.h>
 
 	    main()
 	    {
-	      u_int64_t t = 1;
+	      uint64_t t = 1;
 	      char strbuf[16+1];
 	      sprintf(strbuf, "%016qx", t << 32);
 	      if (strcmp(strbuf, "0000000100000000") == 0)
@@ -7477,6 +7548,98 @@
   RANLIB="$ac_cv_prog_RANLIB"
 fi
 
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR="ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
 
 rm -f os-proto.h
     if test "${LBL_CFLAGS+set}" = set; then
@@ -8057,6 +8220,98 @@
 
 fi
 
+# Check for libcap-ng
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libcap-ng" >&5
+$as_echo_n "checking whether to use libcap-ng... " >&6; }
+# Specify location for both includes and libraries.
+want_libcap_ng=ifavailable
+
+# Check whether --with-cap_ng was given.
+if test "${with_cap_ng+set}" = set; then :
+  withval=$with_cap_ng;
+	if test $withval = no
+	then
+		want_libcap_ng=no
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	elif test $withval = yes
+	then
+		want_libcap_ng=yes
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	fi
+
+else
+
+	#
+	# Use libcap-ng if it's present, otherwise don't.
+	#
+	want_libcap_ng=ifavailable
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, if available" >&5
+$as_echo "yes, if available" >&6; }
+
+fi
+
+if test "$want_libcap_ng" != "no"; then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capng_change_id in -lcap-ng" >&5
+$as_echo_n "checking for capng_change_id in -lcap-ng... " >&6; }
+if ${ac_cv_lib_cap_ng_capng_change_id+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcap-ng  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char capng_change_id ();
+int
+main ()
+{
+return capng_change_id ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_cap_ng_capng_change_id=yes
+else
+  ac_cv_lib_cap_ng_capng_change_id=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cap_ng_capng_change_id" >&5
+$as_echo "$ac_cv_lib_cap_ng_capng_change_id" >&6; }
+if test "x$ac_cv_lib_cap_ng_capng_change_id" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBCAP_NG 1
+_ACEOF
+
+  LIBS="-lcap-ng $LIBS"
+
+fi
+
+	for ac_header in cap-ng.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "cap-ng.h" "ac_cv_header_cap_ng_h" "$ac_includes_default"
+if test "x$ac_cv_header_cap_ng_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_CAP_NG_H 1
+_ACEOF
+
+fi
+
+done
+
+fi
+
 if test "$missing_includes" = "yes"; then
 	CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
 	V_INCLS="$V_INCLS -I$srcdir/missing"
diff --git a/configure.in b/configure.in
index 51ba8fe..a629559 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,3 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 guy Exp $ (LBL)
-dnl
 dnl Copyright (c) 1994, 1995, 1996, 1997
 dnl	The Regents of the University of California.  All rights reserved.
 dnl
@@ -33,6 +31,7 @@
 		AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
 	fi
 fi
+
 AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
 #include <sys/socket.h>
@@ -90,28 +89,6 @@
 		esac
 	fi
 	;;
-
-linux*)
-	AC_MSG_CHECKING(Linux kernel version)
- 	if test "$cross_compiling" = yes; then
- 		AC_CACHE_VAL(ac_cv_linux_vers,
- 		    ac_cv_linux_vers=unknown)
- 	else
- 		AC_CACHE_VAL(ac_cv_linux_vers,
- 		    ac_cv_linux_vers=`uname -r 2>&1 | \
- 			sed -n -e '$s/.* //' -e '$s/\..*//p'`)
- 	fi
-	AC_MSG_RESULT($ac_cv_linux_vers)
- 	if test $ac_cv_linux_vers = unknown ; then
- 		AC_MSG_ERROR(cannot determine linux version when cross-compiling)
- 	fi
-	if test $ac_cv_linux_vers -lt 2 ; then
-		AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
-	fi
-	;;
-
-*)
-	;;
 esac
 
 
@@ -121,18 +98,28 @@
    with_smi=yes)
 
 if test "x$with_smi" != "xno" ; then
-AC_CHECK_HEADERS(smi.h)
-AC_CHECK_LIB(smi, smiInit)
-if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
-then
-AC_MSG_CHECKING([whether to enable libsmi])
-        AC_TRY_RUN([ /* libsmi available check */
+	AC_CHECK_HEADER(smi.h,
+	[
+		#
+		# OK, we found smi.h.  Do we have libsmi with smiInit?
+		#
+		AC_CHECK_LIB(smi, smiInit,
+		[
+			#
+			# OK, we have libsmi with smiInit.  Can we use it?
+			#
+			AC_MSG_CHECKING([whether to enable libsmi])
+			savedlibs="$LIBS"
+			LIBS="-lsmi $LIBS"
+			AC_TRY_RUN(
+				[
+/* libsmi available check */
 #include <smi.h>
 main()
 {
   int current, revision, age, n;
   const int required = 2;
-  if (smiInit("")) 
+  if (smiInit(""))
     exit(1);
   if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
     exit(2);
@@ -143,25 +130,35 @@
     exit(4);
   exit(0);
 }
-],
-[ AC_MSG_RESULT(yes)
-  AC_DEFINE(LIBSMI, 1, [Define if you enable support for libsmi])
-  libsmi=yes],
-dnl autoconf documentation says that $? contains the exit value.
-dnl reality is that it does not.  We leave this in just in case
-dnl autoconf ever comes back to match the documentation.
-[ case $? in
-  1) AC_MSG_RESULT(no - smiInit failed) ;;
-  2) AC_MSG_RESULT(no - header/library version mismatch) ;;
-  3) AC_MSG_RESULT(no - can't determine library version) ;;
-  4) AC_MSG_RESULT(no - too old) ;;
-  *) AC_MSG_RESULT(no) ;;
-  esac
-  libsmi=no],
-[ AC_MSG_RESULT(not when cross-compiling)
-  libsmi=no]
-)
-fi
+				],
+				[
+					AC_MSG_RESULT(yes)
+					AC_DEFINE(USE_LIBSMI, 1,
+					    [Define if you enable support for libsmi])
+				],
+				[
+					dnl autoconf documentation says that
+					dnl $? contains the exit value.
+					dnl reality is that it does not.
+					dnl We leave this in just in case
+					dnl autoconf ever comes back to
+					dnl match the documentation.
+					case $? in
+					  1) AC_MSG_RESULT(no - smiInit failed) ;;
+					  2) AC_MSG_RESULT(no - header/library version mismatch) ;;
+					  3) AC_MSG_RESULT(no - can't determine library version) ;;
+					  4) AC_MSG_RESULT(no - too old) ;;
+					  *) AC_MSG_RESULT(no) ;;
+					esac
+					LIBS="$savedlibs"
+				],
+				[
+					AC_MSG_RESULT(not when cross-compiling)
+					LIBS="$savedlibs"
+				]
+			)
+		])
+	])
 fi
 
 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
@@ -200,6 +197,37 @@
        AC_MSG_RESULT(no)
 fi
 
+AC_ARG_WITH(sandbox-capsicum,
+	AS_HELP_STRING([--with-sandbox-capsicum],
+		       [use Capsicum security functions @<:@default=yes, if available@:>@]))
+#
+# Check whether various functions are available.  If any are, set
+# ac_lbl_capsicum_function_seen to yes; if any are not, set
+# ac_lbl_capsicum_function_not_seen to yes.
+#
+# We don't check cap_rights_init(), as it's a macro, wrapping another
+# function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
+# doesn't handle that.
+#
+# All of the ones we check for must be available in order to enable
+# capsicum sandboxing.
+#
+# XXX - do we need to check for all of them, or are there some that, if
+# present, imply others are present?
+#
+if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
+	AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
+	    ac_lbl_capsicum_function_seen=yes,
+	    ac_lbl_capsicum_function_not_seen=yes)
+fi
+AC_MSG_CHECKING([whether to sandbox using capsicum])
+if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
+	AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
+	AC_MSG_RESULT(yes)
+else
+	AC_MSG_RESULT(no)
+fi
+
 #
 # We must check this before checking whether to enable IPv6, because,
 # on some platforms (such as SunOS 5.x), the test program requires
@@ -213,7 +241,7 @@
   --disable-ipv6          disable ipv6 support],
 [ case "$enableval" in
 yes)   AC_MSG_RESULT(yes)
-       LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+       LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
        AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
        ipv6=yes
        ;;
@@ -242,7 +270,7 @@
         ]])
     ],
 [ AC_MSG_RESULT(yes)
-  LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+  LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
   AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
   ipv6=yes],
 [ AC_MSG_RESULT(no)
@@ -477,9 +505,11 @@
 ],
 	td_cv_buggygetaddrinfo=no,
 	td_cv_buggygetaddrinfo=yes,
-	td_cv_buggygetaddrinfo=yes)])
+	td_cv_buggygetaddrinfo=unknown)])
 	if test "$td_cv_buggygetaddrinfo" = no; then
 		AC_MSG_RESULT(good)
+	elif test "$td_cv_buggygetaddrinfo" = unknown; then
+		AC_MSG_RESULT([unknown (cross-compiling)])
 	else
 		AC_MSG_RESULT(buggy)
 	fi
@@ -537,14 +567,7 @@
 	missing_includes=yes
 fi
 
-dnl
-dnl Checks for sockaddr_storage structure
-AC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
-if test "$ac_cv_sa_storage" = no; then
-	missing_includes=yes
-fi
-
-AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
+AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep getopt_long)
 AC_CHECK_FUNCS(fork vfork strftime)
 AC_CHECK_FUNCS(setlinebuf alarm)
 
@@ -738,6 +761,54 @@
 	missing_includes=yes
 fi
 
+dnl
+dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
+dnl and "pcap_datalink_name_to_val()", and use substitute versions
+dnl if they're not present.
+dnl
+AC_CHECK_FUNC(pcap_list_datalinks,
+	[
+	    AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
+		[define if libpcap has pcap_list_datalinks()])
+	    AC_CHECK_FUNCS(pcap_free_datalinks)
+	],
+	[
+	    AC_LIBOBJ(datalinks)
+	])
+AC_CHECK_FUNCS(pcap_set_datalink)
+AC_CHECK_FUNC(pcap_datalink_name_to_val,
+	[
+	    AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
+		[define if libpcap has pcap_datalink_name_to_val()])
+	    AC_CHECK_FUNC(pcap_datalink_val_to_description,
+		AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
+		    [define if libpcap has pcap_datalink_val_to_description()]),
+		[
+		    AC_LIBOBJ(dlnames)
+		])
+	],
+	[
+	    AC_LIBOBJ(dlnames)
+	])
+
+dnl
+dnl Check for "pcap_breakloop()"; you can't substitute for it if
+dnl it's absent (it has hooks into the live capture routines),
+dnl so just define the HAVE_ value if it's there.
+dnl
+AC_CHECK_FUNCS(pcap_breakloop)
+
+dnl
+dnl Check for "pcap_dump_ftell()" and use a substitute version
+dnl if it's not present.
+dnl
+AC_CHECK_FUNC(pcap_dump_ftell,
+	AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
+	    [define if libpcap has pcap_dump_ftell()]),
+	[
+	    AC_LIBOBJ(pcap_dump_ftell)
+	])
+
 #
 # Do we have the new open API?  Check for pcap_create, and assume that,
 # if we do, we also have pcap_activate() and the other new routines
@@ -750,9 +821,18 @@
 	# pcap_list_tstamp_types and pcap_free_tstamp_types as well.
 	#
 	AC_CHECK_FUNCS(pcap_set_tstamp_type)
+	#
+	# And do we have pcap_set_tstamp_precision?  If so, we assume
+	# we also have pcap_open_offline_with_tstamp_precision.
+	#
+	AC_CHECK_FUNCS(pcap_set_tstamp_precision)
 fi
 
-AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection)
+#
+# Check for a miscellaneous collection of functions which we use
+# if we have them.
+#
+AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode)
 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
 dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
 dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
@@ -774,7 +854,7 @@
        ac_lbl_cv_pcap_version_defined=yes,
        ac_lbl_cv_pcap_version_defined=no)
     if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
-    	AC_MSG_RESULT(yes)
+	AC_MSG_RESULT(yes)
 	AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
     else
 	AC_MSG_RESULT(no)
@@ -878,6 +958,7 @@
 #
 # Make sure we have definitions for all the C99 specified-width types
 # (regardless of whether the environment is a C99 environment or not).
+#
 AC_TYPE_INT8_T
 AC_TYPE_INT16_T
 AC_TYPE_INT32_T
@@ -888,41 +969,39 @@
 AC_TYPE_UINT64_T
 
 #
-# For now, we're using the old BSD-style u_intXX_t types, so check for
-# them.
+# Make sure we have a definition for C99's uintptr_t (regardless of
+# whether the environment is a C99 environment or not).
 #
-# We should probably migrate to the standard C uintXX_t types.
-#
-AC_CHECK_HEADERS(sys/bitypes.h)
+AC_TYPE_UINTPTR_T
 
+#
+# Define the old BSD specified-width types in terms of the C99 types;
+# we may need them with libpcap include files.
+#
 AC_CHECK_TYPE([u_int8_t], ,
-	[AC_DEFINE([u_int8_t], [unsigned char],
-	[Define to `unsigned char' if u_int8_t not defined.])],
+	[AC_DEFINE([u_int8_t], [uint8_t],
+	[Define to `uint8_t' if u_int8_t not defined.])],
 	[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
 AC_CHECK_TYPE([u_int16_t], ,
-	[AC_DEFINE([u_int16_t], [unsigned short],
-	[Define to `unsigned short' if u_int16_t not defined.])],
+	[AC_DEFINE([u_int16_t], [uint16_t],
+	[Define to `uint16_t' if u_int16_t not defined.])],
 	[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
 AC_CHECK_TYPE([u_int32_t], ,
-	[AC_DEFINE([u_int32_t], [unsigned int],
-	[Define to `unsigned int' if u_int32_t not defined.])],
+	[AC_DEFINE([u_int32_t], [uint32_t],
+	[Define to `uint32_t' if u_int32_t not defined.])],
 	[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
 AC_CHECK_TYPE([u_int64_t], ,
-	[AC_DEFINE([u_int64_t], [unsigned long long],
-	[Define to `unsigned long long' if u_int64_t not defined.])],
+	[AC_DEFINE([u_int64_t], [uint64_t],
+	[Define to `uint64_t' if u_int64_t not defined.])],
 	[AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif])
+#include <sys/types.h>
+])
 
 #
 # Check for <inttypes.h>
@@ -941,16 +1020,13 @@
 	    #include <inttypes.h>
 	    #include <stdio.h>
 	    #include <sys/types.h>
-	    #ifdef HAVE_SYS_BITYPES_H
-	    #include <sys/bitypes.h>
-	    #endif
 
 	    main()
 	    {
-	      printf("%" PRId64 "\n", (u_int64_t)1);
-	      printf("%" PRIo64 "\n", (u_int64_t)1);
-	      printf("%" PRIx64 "\n", (u_int64_t)1);
-	      printf("%" PRIu64 "\n", (u_int64_t)1);
+	      printf("%" PRId64 "\n", (uint64_t)1);
+	      printf("%" PRIo64 "\n", (uint64_t)1);
+	      printf("%" PRIx64 "\n", (uint64_t)1);
+	      printf("%" PRIu64 "\n", (uint64_t)1);
 	    }
 	  ]])
       ],
@@ -1001,6 +1077,7 @@
 CPPFLAGS="$savedcppflags"
 
 AC_PROG_RANLIB
+AC_CHECK_TOOL([AR], [ar])
 
 AC_LBL_DEVEL(V_CCOPT)
 
@@ -1039,6 +1116,35 @@
 	AC_CHECK_HEADERS(openssl/evp.h)
 fi
 
+# Check for libcap-ng
+AC_MSG_CHECKING(whether to use libcap-ng)
+# Specify location for both includes and libraries.
+want_libcap_ng=ifavailable
+AC_ARG_WITH(cap_ng,
+    AS_HELP_STRING([--with-cap-ng],
+		   [use libcap-ng @<:@default=yes, if available@:>@]),
+[
+	if test $withval = no
+	then
+		want_libcap_ng=no
+		AC_MSG_RESULT(no)
+	elif test $withval = yes
+	then
+		want_libcap_ng=yes
+		AC_MSG_RESULT(yes)
+	fi
+],[
+	#
+	# Use libcap-ng if it's present, otherwise don't.
+	#
+	want_libcap_ng=ifavailable
+	AC_MSG_RESULT([yes, if available])
+])
+if test "$want_libcap_ng" != "no"; then
+	AC_CHECK_LIB(cap-ng, capng_change_id)
+	AC_CHECK_HEADERS(cap-ng.h)
+fi
+
 dnl
 dnl set additional include path if necessary
 if test "$missing_includes" = "yes"; then
diff --git a/cpack.c b/cpack.c
index b863d8e..16bfd15 100644
--- a/cpack.c
+++ b/cpack.c
@@ -27,6 +27,7 @@
  * OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -38,8 +39,8 @@
 #include "cpack.h"
 #include "extract.h"
 
-u_int8_t *
-cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
+uint8_t *
+cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment)
 {
 	size_t misalignment = (size_t)(p - buf) % alignment;
 
@@ -53,10 +54,10 @@
  * wordsize bytes remain in the buffer after the boundary.  Otherwise,
  * return a pointer to the boundary.
  */
-u_int8_t *
+uint8_t *
 cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
 {
-	u_int8_t *next;
+	uint8_t *next;
 
 	/* Ensure alignment. */
 	next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
@@ -80,7 +81,7 @@
 }
 
 int
-cpack_init(struct cpack_state *cs, u_int8_t *buf, size_t buflen)
+cpack_init(struct cpack_state *cs, uint8_t *buf, size_t buflen)
 {
 	memset(cs, 0, sizeof(*cs));
 
@@ -93,55 +94,55 @@
 
 /* Unpack a 64-bit unsigned integer. */
 int
-cpack_uint64(struct cpack_state *cs, u_int64_t *u)
+cpack_uint64(struct cpack_state *cs, uint64_t *u)
 {
-	u_int8_t *next;
+	uint8_t *next;
 
 	if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
 		return -1;
 
 	*u = EXTRACT_LE_64BITS(next);
 
-	/* Move pointer past the u_int64_t. */
+	/* Move pointer past the uint64_t. */
 	cs->c_next = next + sizeof(*u);
 	return 0;
 }
 
 /* Unpack a 32-bit unsigned integer. */
 int
-cpack_uint32(struct cpack_state *cs, u_int32_t *u)
+cpack_uint32(struct cpack_state *cs, uint32_t *u)
 {
-	u_int8_t *next;
+	uint8_t *next;
 
 	if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
 		return -1;
 
 	*u = EXTRACT_LE_32BITS(next);
 
-	/* Move pointer past the u_int32_t. */
+	/* Move pointer past the uint32_t. */
 	cs->c_next = next + sizeof(*u);
 	return 0;
 }
 
 /* Unpack a 16-bit unsigned integer. */
 int
-cpack_uint16(struct cpack_state *cs, u_int16_t *u)
+cpack_uint16(struct cpack_state *cs, uint16_t *u)
 {
-	u_int8_t *next;
+	uint8_t *next;
 
 	if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
 		return -1;
 
 	*u = EXTRACT_LE_16BITS(next);
 
-	/* Move pointer past the u_int16_t. */
+	/* Move pointer past the uint16_t. */
 	cs->c_next = next + sizeof(*u);
 	return 0;
 }
 
 /* Unpack an 8-bit unsigned integer. */
 int
-cpack_uint8(struct cpack_state *cs, u_int8_t *u)
+cpack_uint8(struct cpack_state *cs, uint8_t *u)
 {
 	/* No space left? */
 	if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
@@ -149,7 +150,7 @@
 
 	*u = *cs->c_next;
 
-	/* Move pointer past the u_int8_t. */
+	/* Move pointer past the uint8_t. */
 	cs->c_next++;
 	return 0;
 }
diff --git a/cpack.h b/cpack.h
index 383927f..a7eb6d6 100644
--- a/cpack.h
+++ b/cpack.h
@@ -31,25 +31,25 @@
 #define _CPACK_H
 
 struct cpack_state {
-	u_int8_t					*c_buf;
-	u_int8_t					*c_next;
+	uint8_t					*c_buf;
+	uint8_t					*c_next;
 	size_t						 c_len;
 };
 
-int cpack_init(struct cpack_state *, u_int8_t *, size_t);
+int cpack_init(struct cpack_state *, uint8_t *, size_t);
 
-int cpack_uint8(struct cpack_state *, u_int8_t *);
-int cpack_uint16(struct cpack_state *, u_int16_t *);
-int cpack_uint32(struct cpack_state *, u_int32_t *);
-int cpack_uint64(struct cpack_state *, u_int64_t *);
+int cpack_uint8(struct cpack_state *, uint8_t *);
+int cpack_uint16(struct cpack_state *, uint16_t *);
+int cpack_uint32(struct cpack_state *, uint32_t *);
+int cpack_uint64(struct cpack_state *, uint64_t *);
 
-u_int8_t *cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment);
-u_int8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
+uint8_t *cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment);
+uint8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
 
-#define cpack_int8(__s, __p)	cpack_uint8((__s),  (u_int8_t*)(__p))
-#define cpack_int16(__s, __p)	cpack_uint16((__s), (u_int16_t*)(__p))
-#define cpack_int32(__s, __p)	cpack_uint32((__s), (u_int32_t*)(__p))
-#define cpack_int64(__s, __p)	cpack_uint64((__s), (u_int64_t*)(__p))
+#define cpack_int8(__s, __p)	cpack_uint8((__s),  (uint8_t*)(__p))
+#define cpack_int16(__s, __p)	cpack_uint16((__s), (uint16_t*)(__p))
+#define cpack_int32(__s, __p)	cpack_uint32((__s), (uint32_t*)(__p))
+#define cpack_int64(__s, __p)	cpack_uint64((__s), (uint64_t*)(__p))
 
 extern int cpack_advance(struct cpack_state *, const size_t);
 
diff --git a/dccp.h b/dccp.h
deleted file mode 100644
index 5c66e23..0000000
--- a/dccp.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/dccp.h,v 1.5 2006-11-02 09:05:23 hannes Exp $ (LBL) */
-/*
- * Copyright (C) Arnaldo Carvalho de Melo 2004
- * Copyright (C) Ian McDonald 2005 <iam4@cs.waikato.ac.nz>
- * Copyright (C) Yoshifumi Nishida 2005
- *
- * This software may be distributed either under the terms of the
- * BSD-style license that accompanies tcpdump or the GNU GPL version 2
- */
-
-#ifndef __DCCP_HDR__
-#define __DCCP_HDR__
-
-/**
- * struct dccp_hdr - generic part of DCCP packet header
- *
- * @dccph_sport - Relevant port on the endpoint that sent this packet
- * @dccph_dport - Relevant port on the other endpoint
- * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
- * @dccph_ccval - Used by the HC-Sender CCID
- * @dccph_cscov - Parts of the packet that are covered by the Checksum field
- * @dccph_checksum - Internet checksum, depends on dccph_cscov
- * @dccph_x - 0 = 24 bit sequence number, 1 = 48
- * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
- * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
- */
-struct dccp_hdr {
-	u_int16_t	dccph_sport,
-			dccph_dport;
-	u_int8_t	dccph_doff;
-	u_int8_t	dccph_ccval_cscov;
-	u_int16_t	dccph_checksum;
-	union {
-	u_int8_t	dccph_xtr;
-	u_int32_t	dccph_seq;
-	}		dccph_xtrs;
-};
-
-#define DCCPH_CCVAL(dh)	(((dh)->dccph_ccval_cscov >> 4) & 0xF)
-#define DCCPH_CSCOV(dh)	(((dh)->dccph_ccval_cscov) & 0xF)
-
-#define DCCPH_X(dh)	((dh)->dccph_xtrs.dccph_xtr & 1)
-#define DCCPH_TYPE(dh)	(((dh)->dccph_xtrs.dccph_xtr >> 1) & 0xF)
-#define DCCPH_SEQ(dh)   (((dh)->dccph_xtrs.dccph_seq) >> 8)
-
-/**
- * struct dccp_hdr_ext - the low bits of a 48 bit seq packet
- *
- * @dccph_seq_low - low 24 bits of a 48 bit seq packet
- */
-struct dccp_hdr_ext {
-	u_int32_t	dccph_seq_low;
-};
-
-/**
- * struct dccp_hdr_request - Conection initiation request header
- *
- * @dccph_req_service - Service to which the client app wants to connect
- */
-struct dccp_hdr_request {
-	u_int32_t	dccph_req_service;
-};
-
-/**
- * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
- *
- * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
- * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
- */
-struct dccp_hdr_ack_bits {
-	u_int32_t	dccph_ra;
-	u_int32_t	dccph_ack_nr_low;
-};
-
-#define DCCPH_ACK(dh_ack)   ((dh_ack)->dccph_ra >> 8)
-
-/**
- * struct dccp_hdr_response - Conection initiation response header
- *
- * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
- * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
- * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
- */
-struct dccp_hdr_response {
-	struct dccp_hdr_ack_bits	dccph_resp_ack;
-	u_int32_t			dccph_resp_service;
-};
-
-#if 0
-static inline struct dccp_hdr_data *dccp_hdr_data(struct dccp_hdr *hdrg)
-{
-	const int ext = DCCPH_X(hdrg) ? sizeof(struct dccp_hdr_ext) : 0;
-
-	return (struct dccp_hdr_data *)(((u_char *)hdrg) + sizeof(hdrg) + ext);
-}
-#endif
-
-/**
- * struct dccp_hdr_reset - Unconditionally shut down a connection
- *
- * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
- */
-struct dccp_hdr_reset {
-	struct dccp_hdr_ack_bits	dccph_reset_ack;
-	u_int8_t			dccph_reset_code,
-					dccph_reset_data[3];
-};
-
-enum dccp_pkt_type {
-	DCCP_PKT_REQUEST = 0,
-	DCCP_PKT_RESPONSE,
-	DCCP_PKT_DATA,
-	DCCP_PKT_ACK,
-	DCCP_PKT_DATAACK,
-	DCCP_PKT_CLOSEREQ,
-	DCCP_PKT_CLOSE,
-	DCCP_PKT_RESET,
-	DCCP_PKT_SYNC,
-	DCCP_PKT_SYNCACK,
-	DCCP_PKT_INVALID
-};
-
-enum dccp_reset_codes {
-	DCCP_RESET_CODE_UNSPECIFIED = 0,
-	DCCP_RESET_CODE_CLOSED,
-	DCCP_RESET_CODE_ABORTED,
-	DCCP_RESET_CODE_NO_CONNECTION,
-	DCCP_RESET_CODE_PACKET_ERROR,
-	DCCP_RESET_CODE_OPTION_ERROR,
-	DCCP_RESET_CODE_MANDATORY_ERROR,
-	DCCP_RESET_CODE_CONNECTION_REFUSED,
-	DCCP_RESET_CODE_BAD_SERVICE_CODE,
-	DCCP_RESET_CODE_TOO_BUSY,
-	DCCP_RESET_CODE_BAD_INIT_COOKIE,
-	DCCP_RESET_CODE_AGGRESSION_PENALTY,
-	__DCCP_RESET_CODE_LAST
-};
-
-#endif /* __DCCP_HDR__ */
diff --git a/decnet.h b/decnet.h
deleted file mode 100644
index d25d157..0000000
--- a/decnet.h
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (c) 1992, 1994, 1996
- *	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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.11 2002-12-11 07:13:50 guy Exp $ (LBL)
- */
-
-#ifndef WIN32
-typedef u_int8_t byte[1];		/* single byte field */
-#else
-/*
- * the keyword 'byte' generates conflicts in Windows
- */
-typedef unsigned char Byte[1];		/* single byte field */
-#define byte Byte
-#endif /* WIN32 */
-typedef u_int8_t word[2];		/* 2 byte field */
-typedef u_int8_t longword[4];		/* 4 bytes field */
-
-/*
- * Definitions for DECNET Phase IV protocol headers
- */
-union etheraddress {
-	u_int8_t   dne_addr[6];		/* full ethernet address */
-	struct {
-		u_int8_t dne_hiord[4];	/* DECnet HIORD prefix */
-		u_int8_t dne_nodeaddr[2]; /* DECnet node address */
-	} dne_remote;
-};
-
-typedef union etheraddress etheraddr;	/* Ethernet address */
-
-#define HIORD 0x000400aa		/* high 32-bits of address (swapped) */
-
-#define AREAMASK	0176000		/* mask for area field */
-#define	AREASHIFT	10		/* bit-offset for area field */
-#define NODEMASK	01777		/* mask for node address field */
-
-#define DN_MAXADDL	20		/* max size of DECnet address */
-struct dn_naddr {
-	u_int16_t	a_len;		/* length of address */
-	u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */
-};
-
-/*
- * Define long and short header formats.
- */
-struct shorthdr
-  {
-    byte	sh_flags;		/* route flags */
-    word	sh_dst;			/* destination node address */
-    word	sh_src;			/* source node address */
-    byte	sh_visits;		/* visit count */
-  };
-
-struct longhdr
-  {
-    byte	lg_flags;		/* route flags */
-    byte	lg_darea;		/* destination area (reserved) */
-    byte	lg_dsarea;		/* destination subarea (reserved) */
-    etheraddr	lg_dst;			/* destination id */
-    byte	lg_sarea;		/* source area (reserved) */
-    byte	lg_ssarea;		/* source subarea (reserved) */
-    etheraddr	lg_src;			/* source id */
-    byte	lg_nextl2;		/* next level 2 router (reserved) */
-    byte	lg_visits;		/* visit count */
-    byte	lg_service;		/* service class (reserved) */
-    byte	lg_pt;			/* protocol type (reserved) */
-  };
-
-union routehdr
-  {
-    struct shorthdr rh_short;		/* short route header */
-    struct longhdr rh_long;		/* long route header */
-  };
-
-/*
- * Define the values of various fields in the protocol messages.
- *
- * 1. Data packet formats.
- */
-#define RMF_MASK	7		/* mask for message type */
-#define RMF_SHORT	2		/* short message format */
-#define RMF_LONG	6		/* long message format */
-#ifndef RMF_RQR
-#define RMF_RQR		010		/* request return to sender */
-#define RMF_RTS		020		/* returning to sender */
-#define RMF_IE		040		/* intra-ethernet packet */
-#endif /* RMR_RQR */
-#define RMF_FVER	0100		/* future version flag */
-#define RMF_PAD		0200		/* pad field */
-#define RMF_PADMASK	0177		/* pad field mask */
-
-#define VIS_MASK	077		/* visit field mask */
-
-/*
- * 2. Control packet formats.
- */
-#define RMF_CTLMASK	017		/* mask for message type */
-#define RMF_CTLMSG	01		/* control message indicator */
-#define RMF_INIT	01		/* initialization message */
-#define RMF_VER		03		/* verification message */
-#define RMF_TEST	05		/* hello and test message */
-#define RMF_L1ROUT	07		/* level 1 routing message */
-#define RMF_L2ROUT	011		/* level 2 routing message */
-#define RMF_RHELLO	013		/* router hello message */
-#define RMF_EHELLO	015		/* endnode hello message */
-
-#define TI_L2ROUT	01		/* level 2 router */
-#define TI_L1ROUT	02		/* level 1 router */
-#define TI_ENDNODE	03		/* endnode */
-#define TI_VERIF	04		/* verification required */
-#define TI_BLOCK	010		/* blocking requested */
-
-#define VE_VERS		2		/* version number (2) */
-#define VE_ECO		0		/* ECO number */
-#define VE_UECO		0		/* user ECO number (0) */
-
-#define P3_VERS		1		/* phase III version number (1) */
-#define P3_ECO		3		/* ECO number (3) */
-#define P3_UECO		0		/* user ECO number (0) */
-
-#define II_L2ROUT	01		/* level 2 router */
-#define II_L1ROUT	02		/* level 1 router */
-#define II_ENDNODE	03		/* endnode */
-#define II_VERIF	04		/* verification required */
-#define II_NOMCAST	040		/* no multicast traffic accepted */
-#define II_BLOCK	0100		/* blocking requested */
-#define II_TYPEMASK	03		/* mask for node type */
-
-#define TESTDATA	0252		/* test data bytes */
-#define TESTLEN		1		/* length of transmitted test data */
-
-/*
- * Define control message formats.
- */
-struct initmsgIII			/* phase III initialization message */
-  {
-    byte	inIII_flags;		/* route flags */
-    word	inIII_src;		/* source node address */
-    byte	inIII_info;		/* routing layer information */
-    word	inIII_blksize;		/* maximum data link block size */
-    byte	inIII_vers;		/* version number */
-    byte	inIII_eco;		/* ECO number */
-    byte	inIII_ueco;		/* user ECO number */
-    byte	inIII_rsvd;		/* reserved image field */
-  };
-
-struct initmsg				/* initialization message */
-  {
-    byte	in_flags;		/* route flags */
-    word	in_src;			/* source node address */
-    byte	in_info;		/* routing layer information */
-    word	in_blksize;		/* maximum data link block size */
-    byte	in_vers;		/* version number */
-    byte	in_eco;			/* ECO number */
-    byte	in_ueco;		/* user ECO number */
-    word	in_hello;		/* hello timer */
-    byte	in_rsvd;		/* reserved image field */
-  };
-
-struct verifmsg				/* verification message */
-  {
-    byte	ve_flags;		/* route flags */
-    word	ve_src;			/* source node address */
-    byte	ve_fcnval;		/* function value image field */
-  };
-
-struct testmsg				/* hello and test message */
-  {
-    byte	te_flags;		/* route flags */
-    word	te_src;			/* source node address */
-    byte	te_data;		/* test data image field */
-  };
-
-struct l1rout				/* level 1 routing message */
-  {
-    byte	r1_flags;		/* route flags */
-    word	r1_src;			/* source node address */
-    byte	r1_rsvd;		/* reserved field */
-  };
-
-struct l2rout				/* level 2 routing message */
-  {
-    byte	r2_flags;		/* route flags */
-    word	r2_src;			/* source node address */
-    byte	r2_rsvd;		/* reserved field */
-  };
-
-struct rhellomsg			/* router hello message */
-  {
-    byte	rh_flags;		/* route flags */
-    byte	rh_vers;		/* version number */
-    byte	rh_eco;			/* ECO number */
-    byte	rh_ueco;		/* user ECO number */
-    etheraddr	rh_src;			/* source id */
-    byte	rh_info;		/* routing layer information */
-    word	rh_blksize;		/* maximum data link block size */
-    byte	rh_priority;		/* router's priority */
-    byte	rh_area;		/* reserved */
-    word	rh_hello;		/* hello timer */
-    byte	rh_mpd;			/* reserved */
-  };
-
-struct ehellomsg			/* endnode hello message */
-  {
-    byte	eh_flags;		/* route flags */
-    byte	eh_vers;		/* version number */
-    byte	eh_eco;			/* ECO number */
-    byte	eh_ueco;		/* user ECO number */
-    etheraddr	eh_src;			/* source id */
-    byte	eh_info;		/* routing layer information */
-    word	eh_blksize;		/* maximum data link block size */
-    byte	eh_area;		/* area (reserved) */
-    byte	eh_seed[8];		/* verification seed */
-    etheraddr	eh_router;		/* designated router */
-    word	eh_hello;		/* hello timer */
-    byte	eh_mpd;			/* (reserved) */
-    byte	eh_data;		/* test data image field */
-  };
-
-union controlmsg
-  {
-    struct initmsg	cm_init;	/* initialization message */
-    struct verifmsg	cm_ver;		/* verification message */
-    struct testmsg	cm_test;	/* hello and test message */
-    struct l1rout	cm_l1rou;	/* level 1 routing message */
-    struct l2rout	cm_l2rout;	/* level 2 routing message */
-    struct rhellomsg	cm_rhello;	/* router hello message */
-    struct ehellomsg	cm_ehello;	/* endnode hello message */
-  };
-
-/* Macros for decoding routing-info fields */
-#define	RI_COST(x)	((x)&0777)
-#define	RI_HOPS(x)	(((x)>>10)&037)
-
-/*
- * NSP protocol fields and values.
- */
-
-#define NSP_TYPEMASK 014		/* mask to isolate type code */
-#define NSP_SUBMASK 0160		/* mask to isolate subtype code */
-#define NSP_SUBSHFT 4			/* shift to move subtype code */
-
-#define MFT_DATA 0			/* data message */
-#define MFT_ACK  04			/* acknowledgement message */
-#define MFT_CTL  010			/* control message */
-
-#define MFS_ILS  020			/* data or I/LS indicator */
-#define MFS_BOM  040			/* beginning of message (data) */
-#define MFS_MOM  0			/* middle of message (data) */
-#define MFS_EOM  0100			/* end of message (data) */
-#define MFS_INT  040			/* interrupt message */
-
-#define MFS_DACK 0			/* data acknowledgement */
-#define MFS_IACK 020			/* I/LS acknowledgement */
-#define MFS_CACK 040			/* connect acknowledgement */
-
-#define MFS_NOP  0			/* no operation */
-#define MFS_CI   020			/* connect initiate */
-#define MFS_CC   040			/* connect confirm */
-#define MFS_DI   060			/* disconnect initiate */
-#define MFS_DC   0100			/* disconnect confirm */
-#define MFS_RCI  0140			/* retransmitted connect initiate */
-
-#define SGQ_ACK  0100000		/* ack */
-#define SGQ_NAK  0110000		/* negative ack */
-#define SGQ_OACK 0120000		/* other channel ack */
-#define SGQ_ONAK 0130000		/* other channel negative ack */
-#define SGQ_MASK 07777			/* mask to isolate seq # */
-#define SGQ_OTHER 020000		/* other channel qualifier */
-#define SGQ_DELAY 010000		/* ack delay flag */
-
-#define SGQ_EOM  0100000		/* pseudo flag for end-of-message */
-
-#define LSM_MASK 03			/* mask for modifier field */
-#define LSM_NOCHANGE 0			/* no change */
-#define LSM_DONOTSEND 1			/* do not send data */
-#define LSM_SEND 2			/* send data */
-
-#define LSI_MASK 014			/* mask for interpretation field */
-#define LSI_DATA 0			/* data segment or message count */
-#define LSI_INTR 4			/* interrupt request count */
-#define LSI_INTM 0377			/* funny marker for int. message */
-
-#define COS_MASK 014			/* mask for flow control field */
-#define COS_NONE 0			/* no flow control */
-#define COS_SEGMENT 04			/* segment flow control */
-#define COS_MESSAGE 010			/* message flow control */
-#define COS_CRYPTSER 020		/* cryptographic services requested */
-#define COS_DEFAULT 1			/* default value for field */
-
-#define COI_MASK 3			/* mask for version field */
-#define COI_32 0			/* version 3.2 */
-#define COI_31 1			/* version 3.1 */
-#define COI_40 2			/* version 4.0 */
-#define COI_41 3			/* version 4.1 */
-
-#define MNU_MASK 140			/* mask for session control version */
-#define MNU_10 000				/* session V1.0 */
-#define MNU_20 040				/* session V2.0 */
-#define MNU_ACCESS 1			/* access control present */
-#define MNU_USRDATA 2			/* user data field present */
-#define MNU_INVKPROXY 4			/* invoke proxy field present */
-#define MNU_UICPROXY 8			/* use uic-based proxy */
-
-#define DC_NORESOURCES 1		/* no resource reason code */
-#define DC_NOLINK 41			/* no link terminate reason code */
-#define DC_COMPLETE 42			/* disconnect complete reason code */
-
-#define DI_NOERROR 0			/* user disconnect */
-#define DI_SHUT 3			/* node is shutting down */
-#define DI_NOUSER 4			/* destination end user does not exist */
-#define DI_INVDEST 5			/* invalid end user destination */
-#define DI_REMRESRC 6			/* insufficient remote resources */
-#define DI_TPA 8			/* third party abort */
-#define DI_PROTOCOL 7			/* protocol error discovered */
-#define DI_ABORT 9			/* user abort */
-#define DI_LOCALRESRC 32		/* insufficient local resources */
-#define DI_REMUSERRESRC 33		/* insufficient remote user resources */
-#define DI_BADACCESS 34			/* bad access control information */
-#define DI_BADACCNT 36			/* bad ACCOUNT information */
-#define DI_CONNECTABORT 38		/* connect request cancelled */
-#define DI_TIMEDOUT 38			/* remote node or user crashed */
-#define DI_UNREACHABLE 39		/* local timers expired due to ... */
-#define DI_BADIMAGE 43			/* bad image data in connect */
-#define DI_SERVMISMATCH 54		/* cryptographic service mismatch */
-
-#define UC_OBJREJECT 0			/* object rejected connect */
-#define UC_USERDISCONNECT 0		/* user disconnect */
-#define UC_RESOURCES 1			/* insufficient resources (local or remote) */
-#define UC_NOSUCHNODE 2			/* unrecognized node name */
-#define UC_REMOTESHUT 3			/* remote node shutting down */
-#define UC_NOSUCHOBJ 4			/* unrecognized object */
-#define UC_INVOBJFORMAT 5		/* invalid object name format */
-#define UC_OBJTOOBUSY 6			/* object too busy */
-#define UC_NETWORKABORT 8		/* network abort */
-#define UC_USERABORT 9			/* user abort */
-#define UC_INVNODEFORMAT 10		/* invalid node name format */
-#define UC_LOCALSHUT 11			/* local node shutting down */
-#define UC_ACCESSREJECT 34		/* invalid access control information */
-#define UC_NORESPONSE 38		/* no response from object */
-#define UC_UNREACHABLE 39		/* node unreachable */
-
-/*
- * NSP message formats.
- */
-struct nsphdr				/* general nsp header */
-  {
-    byte	nh_flags;		/* message flags */
-    word	nh_dst;			/* destination link address */
-    word	nh_src;			/* source link address */
-  };
-
-struct seghdr				/* data segment header */
-  {
-    byte	sh_flags;		/* message flags */
-    word	sh_dst;			/* destination link address */
-    word	sh_src;			/* source link address */
-    word	sh_seq[3];		/* sequence numbers */
-  };
-
-struct minseghdr			/* minimum data segment header */
-  {
-    byte	ms_flags;		/* message flags */
-    word	ms_dst;			/* destination link address */
-    word	ms_src;			/* source link address */
-    word	ms_seq;			/* sequence number */
-  };
-
-struct lsmsg				/* link service message (after hdr) */
-  {
-    byte	ls_lsflags;		/* link service flags */
-    byte	ls_fcval;		/* flow control value */
-  };
-
-struct ackmsg				/* acknowledgement message */
-  {
-    byte	ak_flags;		/* message flags */
-    word	ak_dst;			/* destination link address */
-    word	ak_src;			/* source link address */
-    word	ak_acknum[2];		/* acknowledgement numbers */
-  };
-
-struct minackmsg			/* minimum acknowledgement message */
-  {
-    byte	mk_flags;		/* message flags */
-    word	mk_dst;			/* destination link address */
-    word	mk_src;			/* source link address */
-    word	mk_acknum;		/* acknowledgement number */
-  };
-
-struct ciackmsg				/* connect acknowledgement message */
-  {
-    byte	ck_flags;		/* message flags */
-    word	ck_dst;			/* destination link address */
-  };
-
-struct cimsg				/* connect initiate message */
-  {
-    byte	ci_flags;		/* message flags */
-    word	ci_dst;			/* destination link address (0) */
-    word	ci_src;			/* source link address */
-    byte	ci_services;		/* requested services */
-    byte	ci_info;		/* information */
-    word	ci_segsize;		/* maximum segment size */
-  };
-
-struct ccmsg				/* connect confirm message */
-  {
-    byte	cc_flags;		/* message flags */
-    word	cc_dst;			/* destination link address */
-    word	cc_src;			/* source link address */
-    byte	cc_services;		/* requested services */
-    byte	cc_info;		/* information */
-    word	cc_segsize;		/* maximum segment size */
-    byte	cc_optlen;		/* optional data length */
-  };
-
-struct cnmsg				/* generic connect message */
-  {
-    byte	cn_flags;		/* message flags */
-    word	cn_dst;			/* destination link address */
-    word	cn_src;			/* source link address */
-    byte	cn_services;		/* requested services */
-    byte	cn_info;		/* information */
-    word	cn_segsize;		/* maximum segment size */
-  };
-
-struct dimsg				/* disconnect initiate message */
-  {
-    byte	di_flags;		/* message flags */
-    word	di_dst;			/* destination link address */
-    word	di_src;			/* source link address */
-    word	di_reason;		/* reason code */
-    byte	di_optlen;		/* optional data length */
-  };
-
-struct dcmsg				/* disconnect confirm message */
-  {
-    byte	dc_flags;		/* message flags */
-    word	dc_dst;			/* destination link address */
-    word	dc_src;			/* source link address */
-    word	dc_reason;		/* reason code */
-  };
diff --git a/decode_prefix.h b/decode_prefix.h
deleted file mode 100644
index 8bb4a76..0000000
--- a/decode_prefix.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- *
- * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
- * complete BGP support.
- */
-
-#ifndef tcpdump_decode_prefix_h
-#define tcpdump_decode_prefix_h
-
-extern int decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen);
-#ifdef INET6
-extern int decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen);
-#endif
-
-#endif
diff --git a/enc.h b/enc.h
deleted file mode 100644
index 2d57e2b..0000000
--- a/enc.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/enc.h,v 1.1 2003-03-08 08:55:33 guy Exp $ (LBL) */
-/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
-/*
- * The authors of this code are John Ioannidis (ji@tla.org),
- * Angelos D. Keromytis (kermit@csd.uch.gr) and 
- * Niels Provos (provos@physnet.uni-hamburg.de).
- *
- * This code was written by John Ioannidis for BSD/OS in Athens, Greece, 
- * in November 1995.
- *
- * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
- * by Angelos D. Keromytis.
- *
- * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
- * and Niels Provos.
- *
- * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
- * and Niels Provos.
- * Copyright (c) 2001, Angelos D. Keromytis.
- *
- * Permission to use, copy, and modify this software with or without fee
- * is hereby granted, provided that this entire notice is included in
- * all copies of any software which is or includes a copy or
- * modification of this software. 
- * You may use this code under the GNU public license if you so wish. Please
- * contribute changes back to the authors under this freer than GPL license
- * so that we may further the use of strong encryption without limitations to
- * all.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
- * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
- * PURPOSE.
- */
-
-#define ENC_HDRLEN	12
-
-/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $	*/
-#define M_CONF		0x0400  /* packet was encrypted (ESP-transport) */
-#define M_AUTH		0x0800  /* packet was authenticated (AH) */
-
-struct enchdr {
-	u_int32_t af;
-	u_int32_t spi;
-	u_int32_t flags;
-};
diff --git a/esp.h b/esp.h
deleted file mode 100644
index 56cdada..0000000
--- a/esp.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*	$NetBSD: esp.h,v 1.13 2000/09/26 08:37:38 itojun Exp $	*/
-/*	$KAME: esp.h,v 1.15 2000/09/20 18:15:22 itojun Exp $	*/
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-
-/*
- * RFC1827/2406 Encapsulated Security Payload.
- */
-
-#ifndef _NETINET6_ESP_H_
-#define _NETINET6_ESP_H_
-
-struct esp {
-	u_int32_t	esp_spi;	/* ESP */
-	/*variable size, 32bit bound*/	/* Initialization Vector */
-	/*variable size*/		/* Payload data */
-	/*variable size*/		/* padding */
-	/*8bit*/			/* pad size */
-	/*8bit*/			/* next header */
-	/*8bit*/			/* next header */
-	/*variable size, 32bit bound*/	/* Authentication data (new IPsec) */
-};
-
-struct newesp {
-	u_int32_t	esp_spi;	/* ESP */
-	u_int32_t	esp_seq;	/* Sequence number */
-	/*variable size*/		/* (IV and) Payload data */
-	/*variable size*/		/* padding */
-	/*8bit*/			/* pad size */
-	/*8bit*/			/* next header */
-	/*8bit*/			/* next header */
-	/*variable size, 32bit bound*/	/* Authentication data */
-};
-
-struct esptail {
-	u_int8_t	esp_padlen;	/* pad length */
-	u_int8_t	esp_nxt;	/* Next header */
-	/*variable size, 32bit bound*/	/* Authentication data (new IPsec)*/
-};
-
-#endif /*_NETINET6_ESP_H_*/
diff --git a/ether.h b/ether.h
index e8b3a71..58b92de 100644
--- a/ether.h
+++ b/ether.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.8 2002-12-11 07:13:51 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -45,9 +44,9 @@
  * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
  */
 struct	ether_header {
-	u_int8_t	ether_dhost[ETHER_ADDR_LEN];
-	u_int8_t	ether_shost[ETHER_ADDR_LEN];
-	u_int16_t	ether_type;
+	uint8_t		ether_dhost[ETHER_ADDR_LEN];
+	uint8_t		ether_shost[ETHER_ADDR_LEN];
+	uint16_t	ether_type;
 };
 
 /*
diff --git a/ethertype.h b/ethertype.h
index a74c3a8..8039917 100644
--- a/ethertype.h
+++ b/ethertype.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.30 2008-02-06 10:47:53 guy Exp $ (LBL)
  */
 
 /*
@@ -168,11 +166,14 @@
 #ifndef ETHERTYPE_RRCP
 #define ETHERTYPE_RRCP  	0x8899
 #endif
+#ifndef ETHERTYPE_AOE
+#define ETHERTYPE_AOE  		0x88a2
+#endif
 #ifndef	ETHERTYPE_LOOPBACK
 #define	ETHERTYPE_LOOPBACK	0x9000
 #endif
 #ifndef	ETHERTYPE_VMAN
-#define	ETHERTYPE_VMAN	        0x9100 /* Extreme VMAN Protocol */ 
+#define	ETHERTYPE_VMAN	        0x9100 /* Extreme VMAN Protocol */
 #endif
 #ifndef	ETHERTYPE_CFM_OLD
 #define	ETHERTYPE_CFM_OLD       0xabcd /* 802.1ag depreciated */
@@ -180,6 +181,9 @@
 #ifndef	ETHERTYPE_CFM
 #define	ETHERTYPE_CFM           0x8902 /* 802.1ag */
 #endif
+#ifndef	ETHERTYPE_IEEE1905_1
+#define	ETHERTYPE_IEEE1905_1    0x893a /* IEEE 1905.1 */
+#endif
 #ifndef	ETHERTYPE_ISO
 #define	ETHERTYPE_ISO           0xfefe  /* nonstandard - used in Cisco HDLC encapsulation */
 #endif
diff --git a/extract.h b/extract.h
index dd0a686..cb62ebd 100644
--- a/extract.h
+++ b/extract.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.25 2006-01-30 16:20:07 hannes Exp $ (LBL)
  */
 
 /*
@@ -38,7 +36,7 @@
  * MIPS or Alpha, which has instructions that can help when doing
  * unaligned loads.
  *
- * Declare packed structures containing a u_int16_t and a u_int32_t,
+ * Declare packed structures containing a uint16_t and a uint32_t,
  * cast the pointer to point to one of those, and fetch through it;
  * the GCC manual doesn't appear to explicitly say that
  * __attribute__((packed)) causes the compiler to generate unaligned-safe
@@ -65,9 +63,9 @@
  * line is aligned, e.g.
  *
  *	#pragma unalign 1
- *	typedef u_int16_t unaligned_u_int16_t;
+ *	typedef uint16_t unaligned_uint16_t;
  *
- * to define unaligned_u_int16_t as a 16-bit unaligned data type.
+ * to define unaligned_uint16_t as a 16-bit unaligned data type.
  * This could be presumably used, in sufficiently recent versions of
  * the compiler, with macros similar to those below.  This would be
  * useful only if that compiler could generate better code for PA-RISC
@@ -83,30 +81,30 @@
  * accesses for *specific* items?
  */
 typedef struct {
-	u_int16_t	val;
-} __attribute__((packed)) unaligned_u_int16_t;
+	uint16_t	val;
+} __attribute__((packed)) unaligned_uint16_t;
 
 typedef struct {
-	u_int32_t	val;
-} __attribute__((packed)) unaligned_u_int32_t;
+	uint32_t	val;
+} __attribute__((packed)) unaligned_uint32_t;
 
-static inline u_int16_t
+static inline uint16_t
 EXTRACT_16BITS(const void *p)
 {
-	return ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val));
+	return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
 }
 
-static inline u_int32_t
+static inline uint32_t
 EXTRACT_32BITS(const void *p)
 {
-	return ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val));
+	return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
 }
 
-static inline u_int64_t
+static inline uint64_t
 EXTRACT_64BITS(const void *p)
 {
-	return ((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \
-		((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0));
+	return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
+		((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
 }
 
 #else /* have to do it a byte at a time */
@@ -118,54 +116,78 @@
  * assemble them.
  */
 #define EXTRACT_16BITS(p) \
-	((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
-		     (u_int16_t)*((const u_int8_t *)(p) + 1)))
+	((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
+	            ((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
 #define EXTRACT_32BITS(p) \
-	((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 3)))
+	((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
 #define EXTRACT_64BITS(p) \
-	((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 0) << 56 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 1) << 48 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 2) << 40 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 3) << 32 | \
-	             (u_int64_t)*((const u_int8_t *)(p) + 4) << 24 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 5) << 16 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 6) << 8 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 7)))
+	((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
 #endif /* must special-case unaligned accesses */
 #else /* LBL_ALIGN */
 /*
  * The processor natively handles unaligned loads, so we can just
  * cast the pointer and fetch through it.
  */
-static inline u_int16_t
+static inline uint16_t
 EXTRACT_16BITS(const void *p)
 {
-	return ((u_int16_t)ntohs(*(const u_int16_t *)(p)));
+	return ((uint16_t)ntohs(*(const uint16_t *)(p)));
 }
 
-static inline u_int32_t
+static inline uint32_t
 EXTRACT_32BITS(const void *p)
 {
-	return ((u_int32_t)ntohl(*(const u_int32_t *)(p)));
+	return ((uint32_t)ntohl(*(const uint32_t *)(p)));
 }
 
-static inline u_int64_t
+static inline uint64_t
 EXTRACT_64BITS(const void *p)
 {
-	return ((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \
-		((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0));
+	return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
+		((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
 
 }
 
 #endif /* LBL_ALIGN */
 
 #define EXTRACT_24BITS(p) \
-	((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 2)))
+	((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
+
+#define EXTRACT_40BITS(p) \
+	((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
+
+#define EXTRACT_48BITS(p) \
+	((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
+
+#define EXTRACT_56BITS(p) \
+	((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
 
 /*
  * Macros to extract possibly-unaligned little-endian integral values.
@@ -173,23 +195,23 @@
  */
 #define EXTRACT_LE_8BITS(p) (*(p))
 #define EXTRACT_LE_16BITS(p) \
-	((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
-		     (u_int16_t)*((const u_int8_t *)(p) + 0)))
+	((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+	            ((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
 #define EXTRACT_LE_32BITS(p) \
-	((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 0)))
+	((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
 #define EXTRACT_LE_24BITS(p) \
-	((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
-		     (u_int32_t)*((const u_int8_t *)(p) + 0)))
+	((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+	            ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
 #define EXTRACT_LE_64BITS(p) \
-	((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 7) << 56 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 6) << 48 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 5) << 40 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 4) << 32 | \
-	             (u_int64_t)*((const u_int8_t *)(p) + 3) << 24 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 2) << 16 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 1) << 8 | \
-		     (u_int64_t)*((const u_int8_t *)(p) + 0)))
+	((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+	            ((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
diff --git a/fddi.h b/fddi.h
deleted file mode 100644
index df38c8e..0000000
--- a/fddi.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- *	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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.11 2002-12-11 07:13:51 guy Exp $ (LBL)
- */
-
-/*
- * Based on Ultrix if_fddi.h
- */
-
-/*
- * This stuff should come from a system header file, but there's no
- * obviously portable way to do that and it's not really going
- * to change from system to system (except for the padding business).
- */
-
-struct fddi_header {
-	u_char  fddi_fc;		/* frame control */
-	u_char  fddi_dhost[6];
-	u_char  fddi_shost[6];
-};
-
-/*
- * Length of an FDDI header; note that some compilers may pad
- * "struct fddi_header" to a multiple of 4 bytes, for example, so
- * "sizeof (struct fddi_header)" may not give the right
- * answer.
- */
-#define FDDI_HDRLEN 13
-
-/* Useful values for fddi_fc (frame control) field */
-
-/*
- * FDDI Frame Control bits
- */
-#define	FDDIFC_C		0x80		/* Class bit */
-#define	FDDIFC_L		0x40		/* Address length bit */
-#define	FDDIFC_F		0x30		/* Frame format bits */
-#define	FDDIFC_Z		0x0f		/* Control bits */
-
-/*
- * FDDI Frame Control values. (48-bit addressing only).
- */
-#define	FDDIFC_VOID		0x40		/* Void frame */
-#define	FDDIFC_NRT		0x80		/* Nonrestricted token */
-#define	FDDIFC_RT		0xc0		/* Restricted token */
-#define	FDDIFC_SMT_INFO		0x41		/* SMT Info */
-#define	FDDIFC_SMT_NSA		0x4F		/* SMT Next station adrs */
-#define	FDDIFC_MAC_BEACON	0xc2		/* MAC Beacon frame */
-#define	FDDIFC_MAC_CLAIM	0xc3		/* MAC Claim frame */
-#define	FDDIFC_LLC_ASYNC	0x50		/* Async. LLC frame */
-#define	FDDIFC_LLC_SYNC		0xd0		/* Sync. LLC frame */
-#define	FDDIFC_IMP_ASYNC	0x60		/* Implementor Async. */
-#define	FDDIFC_IMP_SYNC		0xe0		/* Implementor Synch. */
-#define FDDIFC_SMT		0x40		/* SMT frame */
-#define FDDIFC_MAC		0xc0		/* MAC frame */
-
-#define	FDDIFC_CLFF		0xF0		/* Class/Length/Format bits */
-#define	FDDIFC_ZZZZ		0x0F		/* Control bits */
diff --git a/getopt_long.h b/getopt_long.h
new file mode 100644
index 0000000..fbb94e6
--- /dev/null
+++ b/getopt_long.h
@@ -0,0 +1,66 @@
+/*	$NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $	*/
+/*	$FreeBSD$ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION 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.
+ */
+
+#ifndef _GETOPT_LONG_H_
+#define _GETOPT_LONG_H_
+
+/*
+ * GNU-like getopt_long()/getopt_long_only() with 4.4BSD optreset extension.
+ * getopt() is declared here too for GNU programs.
+ */
+#define no_argument        0
+#define required_argument  1
+#define optional_argument  2
+
+struct option {
+	/* name of long option */
+	const char *name;
+	/*
+	 * one of no_argument, required_argument, and optional_argument:
+	 * whether option takes an argument
+	 */
+	int has_arg;
+	/* if not NULL, set *flag to val when option found */
+	int *flag;
+	/* if flag not NULL, value to set *flag to; else return value */
+	int val;
+};
+
+int	getopt_long(int, char * const *, const char *,
+	const struct option *, int *);
+int	getopt_long_only(int, char * const *, const char *,
+	const struct option *, int *);
+
+extern char *optarg;			/* getopt(3) external variables */
+extern int optind, opterr, optopt;
+
+#endif /* !_GETOPT_LONG_H_ */
diff --git a/gmpls.c b/gmpls.c
index 7391767..c9fd9bb 100644
--- a/gmpls.c
+++ b/gmpls.c
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -13,11 +13,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.7 2006-04-14 07:11:59 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -141,8 +137,8 @@
     { 0, NULL }
 };
 
-/* 
- * Link Type values used by LMP Service Discovery (specifically, the Client 
+/*
+ * Link Type values used by LMP Service Discovery (specifically, the Client
  * Port Service Attributes Object). See UNI 1.0 section 9.4.2 for details.
  */
 const struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
@@ -151,9 +147,9 @@
     { 0, NULL}
 };
 
-/* 
- * Signal Type values for SDH links used by LMP Service Discovery (specifically, 
- * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for 
+/*
+ * Signal Type values for SDH links used by LMP Service Discovery (specifically,
+ * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
  * details.
  */
 const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
@@ -168,9 +164,9 @@
     { 0, NULL}
 };
 
-/* 
- * Signal Type values for SONET links used by LMP Service Discovery (specifically, 
- * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for 
+/*
+ * Signal Type values for SONET links used by LMP Service Discovery (specifically,
+ * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
  * details.
  */
 const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
@@ -186,7 +182,7 @@
 };
 
 #define DIFFSERV_BC_MODEL_RDM           0   /* draft-ietf-tewg-diff-te-proto-07 */
-#define DIFFSERV_BC_MODEL_MAM           1   /* draft-ietf-tewg-diff-te-proto-07 */ 
+#define DIFFSERV_BC_MODEL_MAM           1   /* draft-ietf-tewg-diff-te-proto-07 */
 #define DIFFSERV_BC_MODEL_EXTD_MAM      254 /* experimental */
 
 const struct tok diffserv_te_bc_values[] = {
diff --git a/gmpls.h b/gmpls.h
index 8db99de..8b44f94 100644
--- a/gmpls.h
+++ b/gmpls.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.5 2006-04-14 07:11:59 hannes Exp $ (LBL) */
-/* 
+/*
  * 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
diff --git a/gmt2local.c b/gmt2local.c
index 1fe0e8a..6958f66 100644
--- a/gmt2local.c
+++ b/gmt2local.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.9 2003-11-16 09:36:09 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/gmt2local.h b/gmt2local.h
index f7b3841..89254df 100644
--- a/gmt2local.h
+++ b/gmt2local.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2 1999-10-07 23:47:10 mcr Exp $ (LBL)
  */
 #ifndef gmt2local_h
 #define gmt2local_h
diff --git a/icmp6.h b/icmp6.h
deleted file mode 100644
index c4d292e..0000000
--- a/icmp6.h
+++ /dev/null
@@ -1,473 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.18 2007-08-29 02:31:44 mcr Exp $ (LBL) */
-/*	NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp 	*/
-/*	$KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $	*/
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-
-/*
- * Copyright (c) 1982, 1986, 1993
- *	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 the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. 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 BY THE REGENTS 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 THE REGENTS 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.
- *
- *	@(#)ip_icmp.h	8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _NETINET_ICMP6_H_
-#define _NETINET_ICMP6_H_
-
-struct icmp6_hdr {
-	u_int8_t	icmp6_type;	/* type field */
-	u_int8_t	icmp6_code;	/* code field */
-	u_int16_t	icmp6_cksum;	/* checksum field */
-	union {
-		u_int32_t	icmp6_un_data32[1]; /* type-specific field */
-		u_int16_t	icmp6_un_data16[2]; /* type-specific field */
-		u_int8_t	icmp6_un_data8[4];  /* type-specific field */
-	} icmp6_dataun;
-};
-
-#define icmp6_data32	icmp6_dataun.icmp6_un_data32
-#define icmp6_data16	icmp6_dataun.icmp6_un_data16
-#define icmp6_data8	icmp6_dataun.icmp6_un_data8
-#define icmp6_pptr	icmp6_data32[0]		/* parameter prob */
-#define icmp6_mtu	icmp6_data32[0]		/* packet too big */
-#define icmp6_id	icmp6_data16[0]		/* echo request/reply */
-#define icmp6_seq	icmp6_data16[1]		/* echo request/reply */
-#define icmp6_maxdelay	icmp6_data16[0]		/* mcast group membership */
-
-#define ICMP6_DST_UNREACH		1	/* dest unreachable, codes: */
-#define ICMP6_PACKET_TOO_BIG		2	/* packet too big */
-#define ICMP6_TIME_EXCEEDED		3	/* time exceeded, code: */
-#define ICMP6_PARAM_PROB		4	/* ip6 header bad */
-
-#define ICMP6_ECHO_REQUEST		128	/* echo service */
-#define ICMP6_ECHO_REPLY		129	/* echo reply */
-#define ICMP6_MEMBERSHIP_QUERY		130	/* group membership query */
-#define MLD6_LISTENER_QUERY		130 	/* multicast listener query */
-#define ICMP6_MEMBERSHIP_REPORT		131	/* group membership report */
-#define MLD6_LISTENER_REPORT		131	/* multicast listener report */
-#define ICMP6_MEMBERSHIP_REDUCTION	132	/* group membership termination */
-#define MLD6_LISTENER_DONE		132	/* multicast listener done */
-
-#define ND_ROUTER_SOLICIT		133	/* router solicitation */
-#define ND_ROUTER_ADVERT		134	/* router advertisement */
-#define ND_NEIGHBOR_SOLICIT		135	/* neighbor solicitation */
-#define ND_NEIGHBOR_ADVERT		136	/* neighbor advertisement */
-#define ND_REDIRECT			137	/* redirect */
-
-#define ICMP6_ROUTER_RENUMBERING	138	/* router renumbering */
-
-#define ICMP6_WRUREQUEST		139	/* who are you request */
-#define ICMP6_WRUREPLY			140	/* who are you reply */
-#define ICMP6_FQDN_QUERY		139	/* FQDN query */
-#define ICMP6_FQDN_REPLY		140	/* FQDN reply */
-#define ICMP6_NI_QUERY			139	/* node information request */
-#define ICMP6_NI_REPLY			140	/* node information reply */
-#define IND_SOLICIT			141	/* inverse neighbor solicitation */
-#define IND_ADVERT			142	/* inverse neighbor advertisement */
-
-#define ICMP6_V2_MEMBERSHIP_REPORT	143	/* v2 membership report */
-#define MLDV2_LISTENER_REPORT		143	/* v2 multicast listener report */
-#define ICMP6_HADISCOV_REQUEST		144
-#define ICMP6_HADISCOV_REPLY		145
-#define ICMP6_MOBILEPREFIX_SOLICIT	146
-#define ICMP6_MOBILEPREFIX_ADVERT	147
-
-#define MLD6_MTRACE_RESP		200	/* mtrace response(to sender) */
-#define MLD6_MTRACE			201	/* mtrace messages */
-
-#define ICMP6_MAXTYPE			201
-
-#define ICMP6_DST_UNREACH_NOROUTE	0	/* no route to destination */
-#define ICMP6_DST_UNREACH_ADMIN	 	1	/* administratively prohibited */
-#define ICMP6_DST_UNREACH_NOTNEIGHBOR	2	/* not a neighbor(obsolete) */
-#define ICMP6_DST_UNREACH_BEYONDSCOPE	2	/* beyond scope of source address */
-#define ICMP6_DST_UNREACH_ADDR		3	/* address unreachable */
-#define ICMP6_DST_UNREACH_NOPORT	4	/* port unreachable */
-
-#define ICMP6_TIME_EXCEED_TRANSIT 	0	/* ttl==0 in transit */
-#define ICMP6_TIME_EXCEED_REASSEMBLY	1	/* ttl==0 in reass */
-
-#define ICMP6_PARAMPROB_HEADER 	 	0	/* erroneous header field */
-#define ICMP6_PARAMPROB_NEXTHEADER	1	/* unrecognized next header */
-#define ICMP6_PARAMPROB_OPTION		2	/* unrecognized option */
-
-#define ICMP6_INFOMSG_MASK		0x80	/* all informational messages */
-
-#define ICMP6_NI_SUBJ_IPV6	0	/* Query Subject is an IPv6 address */
-#define ICMP6_NI_SUBJ_FQDN	1	/* Query Subject is a Domain name */
-#define ICMP6_NI_SUBJ_IPV4	2	/* Query Subject is an IPv4 address */
-
-#define ICMP6_NI_SUCCESS	0	/* node information successful reply */
-#define ICMP6_NI_REFUSED	1	/* node information request is refused */
-#define ICMP6_NI_UNKNOWN	2	/* unknown Qtype */
-
-#define ICMP6_ROUTER_RENUMBERING_COMMAND  0	/* rr command */
-#define ICMP6_ROUTER_RENUMBERING_RESULT   1	/* rr result */
-#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255	/* rr seq num reset */
-
-/* Used in kernel only */
-#define ND_REDIRECT_ONLINK	0	/* redirect to an on-link node */
-#define ND_REDIRECT_ROUTER	1	/* redirect to a better router */
-
-/*
- * Multicast Listener Discovery
- */
-struct mld6_hdr {
-	struct icmp6_hdr	mld6_hdr;
-	struct in6_addr		mld6_addr; /* multicast address */
-};
-
-#define mld6_type	mld6_hdr.icmp6_type
-#define mld6_code	mld6_hdr.icmp6_code
-#define mld6_cksum	mld6_hdr.icmp6_cksum
-#define mld6_maxdelay	mld6_hdr.icmp6_data16[0]
-#define mld6_reserved	mld6_hdr.icmp6_data16[1]
-
-#define MLD_MINLEN	24
-#define MLDV2_MINLEN	28
-
-/*
- * Neighbor Discovery
- */
-
-struct nd_router_solicit {	/* router solicitation */
-	struct icmp6_hdr 	nd_rs_hdr;
-	/* could be followed by options */
-};
-
-#define nd_rs_type	nd_rs_hdr.icmp6_type
-#define nd_rs_code	nd_rs_hdr.icmp6_code
-#define nd_rs_cksum	nd_rs_hdr.icmp6_cksum
-#define nd_rs_reserved	nd_rs_hdr.icmp6_data32[0]
-
-struct nd_router_advert {	/* router advertisement */
-	struct icmp6_hdr	nd_ra_hdr;
-	u_int32_t		nd_ra_reachable;	/* reachable time */
-	u_int32_t		nd_ra_retransmit;	/* retransmit timer */
-	/* could be followed by options */
-};
-
-#define nd_ra_type		nd_ra_hdr.icmp6_type
-#define nd_ra_code		nd_ra_hdr.icmp6_code
-#define nd_ra_cksum		nd_ra_hdr.icmp6_cksum
-#define nd_ra_curhoplimit	nd_ra_hdr.icmp6_data8[0]
-#define nd_ra_flags_reserved	nd_ra_hdr.icmp6_data8[1]
-#define ND_RA_FLAG_MANAGED	0x80
-#define ND_RA_FLAG_OTHER	0x40
-#define ND_RA_FLAG_HOME_AGENT	0x20
-
-/*
- * Router preference values based on draft-draves-ipngwg-router-selection-01.
- * These are non-standard definitions.
- */
-#define ND_RA_FLAG_RTPREF_MASK	0x18 /* 00011000 */
-
-#define ND_RA_FLAG_RTPREF_HIGH	0x08 /* 00001000 */
-#define ND_RA_FLAG_RTPREF_MEDIUM	0x00 /* 00000000 */
-#define ND_RA_FLAG_RTPREF_LOW	0x18 /* 00011000 */
-#define ND_RA_FLAG_RTPREF_RSV	0x10 /* 00010000 */
-
-#define nd_ra_router_lifetime	nd_ra_hdr.icmp6_data16[1]
-
-struct nd_neighbor_solicit {	/* neighbor solicitation */
-	struct icmp6_hdr	nd_ns_hdr;
-	struct in6_addr		nd_ns_target;	/*target address */
-	/* could be followed by options */
-};
-
-#define nd_ns_type		nd_ns_hdr.icmp6_type
-#define nd_ns_code		nd_ns_hdr.icmp6_code
-#define nd_ns_cksum		nd_ns_hdr.icmp6_cksum
-#define nd_ns_reserved		nd_ns_hdr.icmp6_data32[0]
-
-struct nd_neighbor_advert {	/* neighbor advertisement */
-	struct icmp6_hdr	nd_na_hdr;
-	struct in6_addr		nd_na_target;	/* target address */
-	/* could be followed by options */
-};
-
-#define nd_na_type		nd_na_hdr.icmp6_type
-#define nd_na_code		nd_na_hdr.icmp6_code
-#define nd_na_cksum		nd_na_hdr.icmp6_cksum
-#define nd_na_flags_reserved	nd_na_hdr.icmp6_data32[0]
-
-#define ND_NA_FLAG_ROUTER		0x80000000
-#define ND_NA_FLAG_SOLICITED		0x40000000
-#define ND_NA_FLAG_OVERRIDE		0x20000000
-
-struct nd_redirect {		/* redirect */
-	struct icmp6_hdr	nd_rd_hdr;
-	struct in6_addr		nd_rd_target;	/* target address */
-	struct in6_addr		nd_rd_dst;	/* destination address */
-	/* could be followed by options */
-};
-
-#define nd_rd_type		nd_rd_hdr.icmp6_type
-#define nd_rd_code		nd_rd_hdr.icmp6_code
-#define nd_rd_cksum		nd_rd_hdr.icmp6_cksum
-#define nd_rd_reserved		nd_rd_hdr.icmp6_data32[0]
-
-struct nd_opt_hdr {		/* Neighbor discovery option header */
-	u_int8_t	nd_opt_type;
-	u_int8_t	nd_opt_len;
-	/* followed by option specific data*/
-};
-
-#define ND_OPT_SOURCE_LINKADDR		1
-#define ND_OPT_TARGET_LINKADDR		2
-#define ND_OPT_PREFIX_INFORMATION	3
-#define ND_OPT_REDIRECTED_HEADER	4
-#define ND_OPT_MTU			5
-#define ND_OPT_ADVINTERVAL		7
-#define ND_OPT_HOMEAGENT_INFO		8
-#define ND_OPT_ROUTE_INFO		9	/* draft-ietf-ipngwg-router-preference, not officially assigned yet */
-#define ND_OPT_RDNSS			25
-#define ND_OPT_DNSSL			31
-
-struct nd_opt_prefix_info {	/* prefix information */
-	u_int8_t	nd_opt_pi_type;
-	u_int8_t	nd_opt_pi_len;
-	u_int8_t	nd_opt_pi_prefix_len;
-	u_int8_t	nd_opt_pi_flags_reserved;
-	u_int8_t	nd_opt_pi_valid_time[4];
-	u_int8_t	nd_opt_pi_preferred_time[4];
-	u_int8_t	nd_opt_pi_reserved2[4];
-	struct in6_addr	nd_opt_pi_prefix;
-};
-
-#define ND_OPT_PI_FLAG_ONLINK		0x80
-#define ND_OPT_PI_FLAG_AUTO		0x40
-#define ND_OPT_PI_FLAG_ROUTER		0x20	/*2292bis*/
-
-struct nd_opt_rd_hdr {         /* redirected header */
-	u_int8_t	nd_opt_rh_type;
-	u_int8_t	nd_opt_rh_len;
-	u_int16_t	nd_opt_rh_reserved1;
-	u_int32_t	nd_opt_rh_reserved2;
-	/* followed by IP header and data */
-};
-
-struct nd_opt_mtu {		/* MTU option */
-	u_int8_t	nd_opt_mtu_type;
-	u_int8_t	nd_opt_mtu_len;
-	u_int16_t	nd_opt_mtu_reserved;
-	u_int32_t	nd_opt_mtu_mtu;
-};
-
-struct nd_opt_rdnss {		/* RDNSS RFC 6106 5.1 */
-	u_int8_t	nd_opt_rdnss_type;
-	u_int8_t	nd_opt_rdnss_len;
-	u_int16_t	nd_opt_rdnss_reserved;
-	u_int32_t	nd_opt_rdnss_lifetime;
-	struct in6_addr nd_opt_rdnss_addr[1];	/* variable-length */
-};
-
-struct nd_opt_dnssl {		/* DNSSL RFC 6106 5.2 */
-	u_int8_t  nd_opt_dnssl_type;
-	u_int8_t  nd_opt_dnssl_len;
-	u_int16_t nd_opt_dnssl_reserved;
-	u_int32_t nd_opt_dnssl_lifetime;
-	/* followed by list of DNS search domains, variable-length */
-};
-
-struct nd_opt_advinterval {	/* Advertisement interval option */
-	u_int8_t	nd_opt_adv_type;
-	u_int8_t	nd_opt_adv_len;
-	u_int16_t	nd_opt_adv_reserved;
-	u_int32_t	nd_opt_adv_interval;
-};
-
-struct nd_opt_homeagent_info {	/* Home Agent info */
-	u_int8_t	nd_opt_hai_type;
-	u_int8_t	nd_opt_hai_len;
-	u_int16_t	nd_opt_hai_reserved;
-	int16_t		nd_opt_hai_preference;
-	u_int16_t	nd_opt_hai_lifetime;
-};
-
-struct nd_opt_route_info {	/* route info */
-	u_int8_t	nd_opt_rti_type;
-	u_int8_t	nd_opt_rti_len;
-	u_int8_t	nd_opt_rti_prefixlen;
-	u_int8_t	nd_opt_rti_flags;
-	u_int32_t	nd_opt_rti_lifetime;
-	/* prefix follows */
-};
-
-/*
- * icmp6 namelookup
- */
-
-struct icmp6_namelookup {
-	struct icmp6_hdr 	icmp6_nl_hdr;
-	u_int8_t	icmp6_nl_nonce[8];
-	int32_t		icmp6_nl_ttl;
-#if 0
-	u_int8_t	icmp6_nl_len;
-	u_int8_t	icmp6_nl_name[3];
-#endif
-	/* could be followed by options */
-};
-
-/*
- * icmp6 node information
- */
-struct icmp6_nodeinfo {
-	struct icmp6_hdr icmp6_ni_hdr;
-	u_int8_t icmp6_ni_nonce[8];
-	/* could be followed by reply data */
-};
-
-#define ni_type		icmp6_ni_hdr.icmp6_type
-#define ni_code		icmp6_ni_hdr.icmp6_code
-#define ni_cksum	icmp6_ni_hdr.icmp6_cksum
-#define ni_qtype	icmp6_ni_hdr.icmp6_data16[0]
-#define ni_flags	icmp6_ni_hdr.icmp6_data16[1]
-
-#define NI_QTYPE_NOOP		0 /* NOOP  */
-#define NI_QTYPE_SUPTYPES	1 /* Supported Qtypes */
-#define NI_QTYPE_FQDN		2 /* FQDN (draft 04) */
-#define NI_QTYPE_DNSNAME	2 /* DNS Name */
-#define NI_QTYPE_NODEADDR	3 /* Node Addresses */
-#define NI_QTYPE_IPV4ADDR	4 /* IPv4 Addresses */
-
-/* network endian */
-#define NI_SUPTYPE_FLAG_COMPRESS	((u_int16_t)htons(0x1))
-#define NI_FQDN_FLAG_VALIDTTL		((u_int16_t)htons(0x1))
-
-/* network endian */
-#define NI_NODEADDR_FLAG_TRUNCATE	((u_int16_t)htons(0x1))
-#define NI_NODEADDR_FLAG_ALL		((u_int16_t)htons(0x2))
-#define NI_NODEADDR_FLAG_COMPAT		((u_int16_t)htons(0x4))
-#define NI_NODEADDR_FLAG_LINKLOCAL	((u_int16_t)htons(0x8))
-#define NI_NODEADDR_FLAG_SITELOCAL	((u_int16_t)htons(0x10))
-#define NI_NODEADDR_FLAG_GLOBAL		((u_int16_t)htons(0x20))
-#define NI_NODEADDR_FLAG_ANYCAST	((u_int16_t)htons(0x40)) /* just experimental. not in spec */
-
-struct ni_reply_fqdn {
-	u_int32_t ni_fqdn_ttl;	/* TTL */
-	u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
-	u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
-};
-
-/*
- * Router Renumbering. as router-renum-08.txt
- */
-struct icmp6_router_renum {	/* router renumbering header */
-	struct icmp6_hdr	rr_hdr;
-	u_int8_t	rr_segnum;
-	u_int8_t	rr_flags;
-	u_int16_t	rr_maxdelay;
-	u_int32_t	rr_reserved;
-};
-#define ICMP6_RR_FLAGS_TEST		0x80
-#define ICMP6_RR_FLAGS_REQRESULT	0x40
-#define ICMP6_RR_FLAGS_FORCEAPPLY	0x20
-#define ICMP6_RR_FLAGS_SPECSITE		0x10
-#define ICMP6_RR_FLAGS_PREVDONE		0x08
-
-#define rr_type		rr_hdr.icmp6_type
-#define rr_code		rr_hdr.icmp6_code
-#define rr_cksum	rr_hdr.icmp6_cksum
-#define rr_seqnum 	rr_hdr.icmp6_data32[0]
-
-struct rr_pco_match {		/* match prefix part */
-	u_int8_t	rpm_code;
-	u_int8_t	rpm_len;
-	u_int8_t	rpm_ordinal;
-	u_int8_t	rpm_matchlen;
-	u_int8_t	rpm_minlen;
-	u_int8_t	rpm_maxlen;
-	u_int16_t	rpm_reserved;
-	struct	in6_addr	rpm_prefix;
-};
-
-#define RPM_PCO_ADD		1
-#define RPM_PCO_CHANGE		2
-#define RPM_PCO_SETGLOBAL	3
-#define RPM_PCO_MAX		4
-
-struct rr_pco_use {		/* use prefix part */
-	u_int8_t	rpu_uselen;
-	u_int8_t	rpu_keeplen;
-	u_int8_t	rpu_ramask;
-	u_int8_t	rpu_raflags;
-	u_int32_t	rpu_vltime;
-	u_int32_t	rpu_pltime;
-	u_int32_t	rpu_flags;
-	struct	in6_addr rpu_prefix;
-};
-#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK	0x80
-#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO	0x40
-
-/* network endian */
-#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     ((u_int32_t)htonl(0x80000000))
-#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     ((u_int32_t)htonl(0x40000000))
-
-struct rr_result {		/* router renumbering result message */
-	u_int16_t	rrr_flags;
-	u_int8_t	rrr_ordinal;
-	u_int8_t	rrr_matchedlen;
-	u_int32_t	rrr_ifid;
-	struct	in6_addr rrr_prefix;
-};
-/* network endian */
-#define ICMP6_RR_RESULT_FLAGS_OOB		((u_int16_t)htons(0x0002))
-#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		((u_int16_t)htons(0x0001))
-
-#endif /* not _NETINET_ICMP6_H_ */
diff --git a/ieee802_11.h b/ieee802_11.h
deleted file mode 100644
index 2aa1345..0000000
--- a/ieee802_11.h
+++ /dev/null
@@ -1,347 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.12 2007-07-22 19:59:06 guy Exp $ (LBL) */
-/*
- * Copyright (c) 2001
- *	Fortress Technologies
- *      Charlie Lenahan ( clenahan@fortresstech.com )
- *
- * 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.
- */
-
-/* Lengths of 802.11 header components. */
-#define	IEEE802_11_FC_LEN		2
-#define	IEEE802_11_DUR_LEN		2
-#define	IEEE802_11_DA_LEN		6
-#define	IEEE802_11_SA_LEN		6
-#define	IEEE802_11_BSSID_LEN		6
-#define	IEEE802_11_RA_LEN		6
-#define	IEEE802_11_TA_LEN		6
-#define	IEEE802_11_SEQ_LEN		2
-#define	IEEE802_11_CTL_LEN		2
-#define	IEEE802_11_IV_LEN		3
-#define	IEEE802_11_KID_LEN		1
-
-/* Frame check sequence length. */
-#define	IEEE802_11_FCS_LEN		4
-
-/* Lengths of beacon components. */
-#define	IEEE802_11_TSTAMP_LEN		8
-#define	IEEE802_11_BCNINT_LEN		2
-#define	IEEE802_11_CAPINFO_LEN		2
-#define	IEEE802_11_LISTENINT_LEN	2
-
-#define	IEEE802_11_AID_LEN		2
-#define	IEEE802_11_STATUS_LEN		2
-#define	IEEE802_11_REASON_LEN		2
-
-/* Length of previous AP in reassocation frame */
-#define	IEEE802_11_AP_LEN		6
-
-#define	T_MGMT 0x0  /* management */
-#define	T_CTRL 0x1  /* control */
-#define	T_DATA 0x2 /* data */
-#define	T_RESV 0x3  /* reserved */
-
-#define	ST_ASSOC_REQUEST   	0x0
-#define	ST_ASSOC_RESPONSE 	0x1
-#define	ST_REASSOC_REQUEST   	0x2
-#define	ST_REASSOC_RESPONSE  	0x3
-#define	ST_PROBE_REQUEST   	0x4
-#define	ST_PROBE_RESPONSE   	0x5
-/* RESERVED 			0x6  */
-/* RESERVED 			0x7  */
-#define	ST_BEACON   		0x8
-#define	ST_ATIM			0x9
-#define	ST_DISASSOC		0xA
-#define	ST_AUTH			0xB
-#define	ST_DEAUTH		0xC
-#define	ST_ACTION		0xD
-/* RESERVED 			0xE  */
-/* RESERVED 			0xF  */
-
-
-#define CTRL_CONTROL_WRAPPER	0x7
-#define	CTRL_BAR	0x8
-#define	CTRL_BA		0x9
-#define	CTRL_PS_POLL	0xA
-#define	CTRL_RTS	0xB
-#define	CTRL_CTS	0xC
-#define	CTRL_ACK	0xD
-#define	CTRL_CF_END	0xE
-#define	CTRL_END_ACK	0xF
-
-#define	DATA_DATA			0x0
-#define	DATA_DATA_CF_ACK		0x1
-#define	DATA_DATA_CF_POLL		0x2
-#define	DATA_DATA_CF_ACK_POLL		0x3
-#define	DATA_NODATA			0x4
-#define	DATA_NODATA_CF_ACK		0x5
-#define	DATA_NODATA_CF_POLL		0x6
-#define	DATA_NODATA_CF_ACK_POLL		0x7
-
-#define DATA_QOS_DATA			0x8
-#define DATA_QOS_DATA_CF_ACK		0x9
-#define DATA_QOS_DATA_CF_POLL		0xA
-#define DATA_QOS_DATA_CF_ACK_POLL	0xB
-#define DATA_QOS_NODATA			0xC
-#define DATA_QOS_CF_POLL_NODATA		0xE
-#define DATA_QOS_CF_ACK_POLL_NODATA	0xF
-
-/*
- * The subtype field of a data frame is, in effect, composed of 4 flag
- * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
- * any data), and QoS.
- */
-#define DATA_FRAME_IS_CF_ACK(x)		((x) & 0x01)
-#define DATA_FRAME_IS_CF_POLL(x)	((x) & 0x02)
-#define DATA_FRAME_IS_NULL(x)		((x) & 0x04)
-#define DATA_FRAME_IS_QOS(x)		((x) & 0x08)
-
-/*
- * Bits in the frame control field.
- */
-#define	FC_VERSION(fc)		((fc) & 0x3)
-#define	FC_TYPE(fc)		(((fc) >> 2) & 0x3)
-#define	FC_SUBTYPE(fc)		(((fc) >> 4) & 0xF)
-#define	FC_TO_DS(fc)		((fc) & 0x0100)
-#define	FC_FROM_DS(fc)		((fc) & 0x0200)
-#define	FC_MORE_FLAG(fc)	((fc) & 0x0400)
-#define	FC_RETRY(fc)		((fc) & 0x0800)
-#define	FC_POWER_MGMT(fc)	((fc) & 0x1000)
-#define	FC_MORE_DATA(fc)	((fc) & 0x2000)
-#define	FC_WEP(fc)		((fc) & 0x4000)
-#define	FC_ORDER(fc)		((fc) & 0x8000)
-
-struct mgmt_header_t {
-	u_int16_t	fc;
-	u_int16_t 	duration;
-	u_int8_t	da[6];
-	u_int8_t	sa[6];
-	u_int8_t	bssid[6];
-	u_int16_t	seq_ctrl;
-};
-
-#define	MGMT_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
-			 IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
-			 IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
-
-#define	CAPABILITY_ESS(cap)	((cap) & 0x0001)
-#define	CAPABILITY_IBSS(cap)	((cap) & 0x0002)
-#define	CAPABILITY_CFP(cap)	((cap) & 0x0004)
-#define	CAPABILITY_CFP_REQ(cap)	((cap) & 0x0008)
-#define	CAPABILITY_PRIVACY(cap)	((cap) & 0x0010)
-
-struct ssid_t {
-	u_int8_t	element_id;
-	u_int8_t	length;
-	u_char		ssid[33];  /* 32 + 1 for null */
-};
-
-struct rates_t {
-	u_int8_t	element_id;
-	u_int8_t	length;
-	u_int8_t	rate[16];
-};
-
-struct challenge_t {
-	u_int8_t	element_id;
-	u_int8_t	length;
-	u_int8_t	text[254]; /* 1-253 + 1 for null */
-};
-
-struct fh_t {
-	u_int8_t	element_id;
-	u_int8_t	length;
-	u_int16_t	dwell_time;
-	u_int8_t	hop_set;
-	u_int8_t 	hop_pattern;
-	u_int8_t	hop_index;
-};
-
-struct ds_t {
-	u_int8_t	element_id;
-	u_int8_t	length;
-	u_int8_t	channel;
-};
-
-struct cf_t {
-	u_int8_t	element_id;
-	u_int8_t	length;
-	u_int8_t	count;
-	u_int8_t	period;
-	u_int16_t	max_duration;
-	u_int16_t	dur_remaing;
-};
-
-struct tim_t {
-	u_int8_t	element_id;
-	u_int8_t	length;
-	u_int8_t	count;
-	u_int8_t	period;
-	u_int8_t	bitmap_control;
-	u_int8_t	bitmap[251];
-};
-
-#define	E_SSID 		0
-#define	E_RATES 	1
-#define	E_FH	 	2
-#define	E_DS 		3
-#define	E_CF	 	4
-#define	E_TIM	 	5
-#define	E_IBSS 		6
-/* reserved 		7 */
-/* reserved 		8 */
-/* reserved 		9 */
-/* reserved 		10 */
-/* reserved 		11 */
-/* reserved 		12 */
-/* reserved 		13 */
-/* reserved 		14 */
-/* reserved 		15 */
-/* reserved 		16 */
-
-#define	E_CHALLENGE 	16
-/* reserved 		17 */
-/* reserved 		18 */
-/* reserved 		19 */
-/* reserved 		16 */
-/* reserved 		16 */
-
-
-struct mgmt_body_t {
-	u_int8_t   	timestamp[IEEE802_11_TSTAMP_LEN];
-	u_int16_t  	beacon_interval;
-	u_int16_t 	listen_interval;
-	u_int16_t 	status_code;
-	u_int16_t 	aid;
-	u_char		ap[IEEE802_11_AP_LEN];
-	u_int16_t	reason_code;
-	u_int16_t	auth_alg;
-	u_int16_t	auth_trans_seq_num;
-	int		challenge_present;
-	struct challenge_t  challenge;
-	u_int16_t	capability_info;
-	int		ssid_present;
-	struct ssid_t	ssid;
-	int		rates_present;
-	struct rates_t 	rates;
-	int		ds_present;
-	struct ds_t	ds;
-	int		cf_present;
-	struct cf_t	cf;
-	int		fh_present;
-	struct fh_t	fh;
-	int		tim_present;
-	struct tim_t	tim;
-};
-
-struct ctrl_rts_t {
-	u_int16_t	fc;
-	u_int16_t	duration;
-	u_int8_t	ra[6];
-	u_int8_t	ta[6];
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_RTS_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
-			 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
-
-struct ctrl_cts_t {
-	u_int16_t	fc;
-	u_int16_t	duration;
-	u_int8_t	ra[6];
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_CTS_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_ack_t {
-	u_int16_t	fc;
-	u_int16_t	duration;
-	u_int8_t	ra[6];
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_ACK_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_ps_poll_t {
-	u_int16_t	fc;
-	u_int16_t	aid;
-	u_int8_t	bssid[6];
-	u_int8_t	ta[6];
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_PS_POLL_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
-				 IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
-
-struct ctrl_end_t {
-	u_int16_t	fc;
-	u_int16_t	duration;
-	u_int8_t	ra[6];
-	u_int8_t	bssid[6];
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_END_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
-			 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
-
-struct ctrl_end_ack_t {
-	u_int16_t	fc;
-	u_int16_t	duration;
-	u_int8_t	ra[6];
-	u_int8_t	bssid[6];
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_END_ACK_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
-				 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
-
-struct ctrl_ba_t {
-	u_int16_t	fc;
-	u_int16_t	duration;
-	u_int8_t	ra[6];
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_BA_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_bar_t {
-	u_int16_t	fc;
-	u_int16_t	dur;
-	u_int8_t	ra[6];
-	u_int8_t	ta[6];
-	u_int16_t	ctl;
-	u_int16_t	seq;
-	u_int8_t	fcs[4];
-};
-
-#define	CTRL_BAR_HDRLEN		(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
-				 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
-				 IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
-
-struct meshcntl_t {
-	u_int8_t	flags;
-	u_int8_t	ttl;
-	u_int8_t	seq[4];
-	u_int8_t	addr4[6];
-	u_int8_t	addr5[6];
-	u_int8_t	addr6[6];
-};
-
-#define	IV_IV(iv)	((iv) & 0xFFFFFF)
-#define	IV_PAD(iv)	(((iv) >> 24) & 0x3F)
-#define	IV_KEYID(iv)	(((iv) >> 30) & 0x03)
diff --git a/ieee802_11_radio.h b/ieee802_11_radio.h
deleted file mode 100644
index 65c25df..0000000
--- a/ieee802_11_radio.h
+++ /dev/null
@@ -1,297 +0,0 @@
-/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
-/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp  */
-/* $Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.3 2007-08-29 02:31:44 mcr Exp $ */
-
-/*-
- * Copyright (c) 2003, 2004 David Young.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. The name of David Young may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID
- * YOUNG 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.
- */
-#ifndef _NET_IF_IEEE80211RADIOTAP_H_
-#define _NET_IF_IEEE80211RADIOTAP_H_
-
-/* A generic radio capture format is desirable. It must be
- * rigidly defined (e.g., units for fields should be given),
- * and easily extensible.
- *
- * The following is an extensible radio capture format. It is
- * based on a bitmap indicating which fields are present.
- *
- * I am trying to describe precisely what the application programmer
- * should expect in the following, and for that reason I tell the
- * units and origin of each measurement (where it applies), or else I
- * use sufficiently weaselly language ("is a monotonically nondecreasing
- * function of...") that I cannot set false expectations for lawyerly
- * readers.
- */
-
-/*
- * The radio capture header precedes the 802.11 header.
- *
- * Note well: all radiotap fields are little-endian.
- */
-struct ieee80211_radiotap_header {
-	u_int8_t	it_version;	/* Version 0. Only increases
-					 * for drastic changes,
-					 * introduction of compatible
-					 * new fields does not count.
-					 */
-	u_int8_t	it_pad;
-	u_int16_t       it_len;         /* length of the whole
-					 * header in bytes, including
-					 * it_version, it_pad,
-					 * it_len, and data fields.
-					 */
-	u_int32_t       it_present;     /* A bitmap telling which
-					 * fields are present. Set bit 31
-					 * (0x80000000) to extend the
-					 * bitmap by another 32 bits.
-					 * Additional extensions are made
-					 * by setting bit 31.
-					 */
-};
-
-/* Name                                 Data type       Units
- * ----                                 ---------       -----
- *
- * IEEE80211_RADIOTAP_TSFT              u_int64_t       microseconds
- *
- *      Value in microseconds of the MAC's 64-bit 802.11 Time
- *      Synchronization Function timer when the first bit of the
- *      MPDU arrived at the MAC. For received frames, only.
- *
- * IEEE80211_RADIOTAP_CHANNEL           2 x u_int16_t   MHz, bitmap
- *
- *      Tx/Rx frequency in MHz, followed by flags (see below).
- *	Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
- *	represent an HT channel as there is not enough room in
- *	the flags word.
- *
- * IEEE80211_RADIOTAP_FHSS              u_int16_t       see below
- *
- *      For frequency-hopping radios, the hop set (first byte)
- *      and pattern (second byte).
- *
- * IEEE80211_RADIOTAP_RATE              u_int8_t        500kb/s or index
- *
- *      Tx/Rx data rate.  If bit 0x80 is set then it represents an
- *	an MCS index and not an IEEE rate.
- *
- * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     int8_t          decibels from
- *                                                      one milliwatt (dBm)
- *
- *      RF signal power at the antenna, decibel difference from
- *      one milliwatt.
- *
- * IEEE80211_RADIOTAP_DBM_ANTNOISE      int8_t          decibels from
- *                                                      one milliwatt (dBm)
- *
- *      RF noise power at the antenna, decibel difference from one
- *      milliwatt.
- *
- * IEEE80211_RADIOTAP_DB_ANTSIGNAL      u_int8_t        decibel (dB)
- *
- *      RF signal power at the antenna, decibel difference from an
- *      arbitrary, fixed reference.
- *
- * IEEE80211_RADIOTAP_DB_ANTNOISE       u_int8_t        decibel (dB)
- *
- *      RF noise power at the antenna, decibel difference from an
- *      arbitrary, fixed reference point.
- *
- * IEEE80211_RADIOTAP_LOCK_QUALITY      u_int16_t       unitless
- *
- *      Quality of Barker code lock. Unitless. Monotonically
- *      nondecreasing with "better" lock strength. Called "Signal
- *      Quality" in datasheets.  (Is there a standard way to measure
- *      this?)
- *
- * IEEE80211_RADIOTAP_TX_ATTENUATION    u_int16_t       unitless
- *
- *      Transmit power expressed as unitless distance from max
- *      power set at factory calibration.  0 is max power.
- *      Monotonically nondecreasing with lower power levels.
- *
- * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t       decibels (dB)
- *
- *      Transmit power expressed as decibel distance from max power
- *      set at factory calibration.  0 is max power.  Monotonically
- *      nondecreasing with lower power levels.
- *
- * IEEE80211_RADIOTAP_DBM_TX_POWER      int8_t          decibels from
- *                                                      one milliwatt (dBm)
- *
- *      Transmit power expressed as dBm (decibels from a 1 milliwatt
- *      reference). This is the absolute power level measured at
- *      the antenna port.
- *
- * IEEE80211_RADIOTAP_FLAGS             u_int8_t        bitmap
- *
- *      Properties of transmitted and received frames. See flags
- *      defined below.
- *
- * IEEE80211_RADIOTAP_ANTENNA           u_int8_t        antenna index
- *
- *      Unitless indication of the Rx/Tx antenna for this packet.
- *      The first antenna is antenna 0.
- *
- * IEEE80211_RADIOTAP_RX_FLAGS          u_int16_t       bitmap
- *
- *     Properties of received frames. See flags defined below.
- *
- * IEEE80211_RADIOTAP_XCHANNEL          u_int32_t	bitmap
- *					u_int16_t	MHz
- *					u_int8_t	channel number
- *					u_int8_t	.5 dBm
- *
- *	Extended channel specification: flags (see below) followed by
- *	frequency in MHz, the corresponding IEEE channel number, and
- *	finally the maximum regulatory transmit power cap in .5 dBm
- *	units.  This property supersedes IEEE80211_RADIOTAP_CHANNEL
- *	and only one of the two should be present.
- *
- * IEEE80211_RADIOTAP_MCS		u_int8_t	known
- *					u_int8_t	flags
- *					u_int8_t	mcs
- *
- *	Bitset indicating which fields have known values, followed
- *	by bitset of flag values, followed by the MCS rate index as
- *	in IEEE 802.11n.
- *
- * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
- *					u_int8_t  OUI[3]
- *                                   u_int8_t  subspace
- *                                   u_int16_t length
- *
- *     The Vendor Namespace Field contains three sub-fields. The first
- *     sub-field is 3 bytes long. It contains the vendor's IEEE 802
- *     Organizationally Unique Identifier (OUI). The fourth byte is a
- *     vendor-specific "namespace selector."
- *
- */
-enum ieee80211_radiotap_type {
-	IEEE80211_RADIOTAP_TSFT = 0,
-	IEEE80211_RADIOTAP_FLAGS = 1,
-	IEEE80211_RADIOTAP_RATE = 2,
-	IEEE80211_RADIOTAP_CHANNEL = 3,
-	IEEE80211_RADIOTAP_FHSS = 4,
-	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
-	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
-	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
-	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
-	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
-	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
-	IEEE80211_RADIOTAP_ANTENNA = 11,
-	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
-	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
-	IEEE80211_RADIOTAP_RX_FLAGS = 14,
-	/* NB: gap for netbsd definitions */
-	IEEE80211_RADIOTAP_XCHANNEL = 18,
-	IEEE80211_RADIOTAP_MCS = 19,
-	IEEE80211_RADIOTAP_NAMESPACE = 29,
-	IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
-	IEEE80211_RADIOTAP_EXT = 31
-};
-
-/* channel attributes */
-#define	IEEE80211_CHAN_TURBO	0x00010	/* Turbo channel */
-#define	IEEE80211_CHAN_CCK	0x00020	/* CCK channel */
-#define	IEEE80211_CHAN_OFDM	0x00040	/* OFDM channel */
-#define	IEEE80211_CHAN_2GHZ	0x00080	/* 2 GHz spectrum channel. */
-#define	IEEE80211_CHAN_5GHZ	0x00100	/* 5 GHz spectrum channel */
-#define	IEEE80211_CHAN_PASSIVE	0x00200	/* Only passive scan allowed */
-#define	IEEE80211_CHAN_DYN	0x00400	/* Dynamic CCK-OFDM channel */
-#define	IEEE80211_CHAN_GFSK	0x00800	/* GFSK channel (FHSS PHY) */
-#define	IEEE80211_CHAN_GSM	0x01000	/* 900 MHz spectrum channel */
-#define	IEEE80211_CHAN_STURBO	0x02000	/* 11a static turbo channel only */
-#define	IEEE80211_CHAN_HALF	0x04000	/* Half rate channel */
-#define	IEEE80211_CHAN_QUARTER	0x08000	/* Quarter rate channel */
-#define	IEEE80211_CHAN_HT20	0x10000	/* HT 20 channel */
-#define	IEEE80211_CHAN_HT40U	0x20000	/* HT 40 channel w/ ext above */
-#define	IEEE80211_CHAN_HT40D	0x40000	/* HT 40 channel w/ ext below */
-
-/* Useful combinations of channel characteristics, borrowed from Ethereal */
-#define IEEE80211_CHAN_A \
-        (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
-#define IEEE80211_CHAN_B \
-        (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
-#define IEEE80211_CHAN_G \
-        (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
-#define IEEE80211_CHAN_TA \
-        (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
-#define IEEE80211_CHAN_TG \
-        (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN  | IEEE80211_CHAN_TURBO)
-
-
-/* For IEEE80211_RADIOTAP_FLAGS */
-#define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
-						 * during CFP
-						 */
-#define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
-						 * with short
-						 * preamble
-						 */
-#define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
-						 * with WEP encryption
-						 */
-#define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
-						 * with fragmentation
-						 */
-#define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
-#define	IEEE80211_RADIOTAP_F_DATAPAD	0x20	/* frame has padding between
-						 * 802.11 header and payload
-						 * (to 32-bit boundary)
-						 */
-#define	IEEE80211_RADIOTAP_F_BADFCS	0x40	/* does not pass FCS check */
-
-/* For IEEE80211_RADIOTAP_RX_FLAGS */
-#define IEEE80211_RADIOTAP_F_RX_BADFCS	0x0001	/* frame failed crc check */
-#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC	0x0002	/* frame failed PLCP CRC check */
-
-/* For IEEE80211_RADIOTAP_MCS known */
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN		0x01
-#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN		0x02	/* MCS index field */
-#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN	0x04
-#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN		0x08
-#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN		0x10
-#define IEEE80211_RADIOTAP_MCS_STBC_KNOWN		0x20
-
-/* For IEEE80211_RADIOTAP_MCS flags */
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK	0x03
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20	0
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40	1
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L	2
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U	3
-#define IEEE80211_RADIOTAP_MCS_SHORT_GI		0x04 /* short guard interval */
-#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD	0x08
-#define IEEE80211_RADIOTAP_MCS_FEC_LDPC		0x10
-#define IEEE80211_RADIOTAP_MCS_STBC_MASK	0x60
-#define		IEEE80211_RADIOTAP_MCS_STBC_1	1
-#define		IEEE80211_RADIOTAP_MCS_STBC_2	2
-#define		IEEE80211_RADIOTAP_MCS_STBC_3	3
-#define IEEE80211_RADIOTAP_MCS_STBC_SHIFT	5
-
-#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
diff --git a/igrp.h b/igrp.h
deleted file mode 100644
index b5f133b..0000000
--- a/igrp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002-12-11 07:13:52 guy Exp $ (LBL) */
-/* Cisco IGRP definitions */
-
-/* IGRP Header */
-
-struct igrphdr {
-	u_int8_t ig_vop;	/* protocol version number / opcode */
-#define IGRP_V(x)	(((x) & 0xf0) >> 4)
-#define IGRP_OP(x)	((x) & 0x0f)
-	u_int8_t ig_ed;		/* edition number */
-	u_int16_t ig_as;	/* autonomous system number */
-	u_int16_t ig_ni;	/* number of subnet in local net */
-	u_int16_t ig_ns;	/* number of networks in AS */
-	u_int16_t ig_nx;	/* number of networks ouside AS */
-	u_int16_t ig_sum;	/* checksum of IGRP header & data */
-};
-
-#define IGRP_UPDATE	1
-#define IGRP_REQUEST	2
-
-/* IGRP routing entry */
-
-struct igrprte {
-	u_int8_t igr_net[3];	/* 3 significant octets of IP address */
-	u_int8_t igr_dly[3];	/* delay in tens of microseconds */
-	u_int8_t igr_bw[3];	/* bandwidth in units of 1 kb/s */
-	u_int8_t igr_mtu[2];	/* MTU in octets */
-	u_int8_t igr_rel;	/* percent packets successfully tx/rx */
-	u_int8_t igr_ld;	/* percent of channel occupied */
-	u_int8_t igr_hct;	/* hop count */
-};
-
-#define IGRP_RTE_SIZE	14	/* don't believe sizeof ! */
diff --git a/in_cksum.c b/in_cksum.c
index 93cdfc9..171728a 100644
--- a/in_cksum.c
+++ b/in_cksum.c
@@ -35,6 +35,7 @@
  *	@(#)in_cksum.c	8.1 (Berkeley) 6/10/93
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -53,27 +54,27 @@
 #define ADDCARRY(x)  {if ((x) > 65535) (x) -= 65535;}
 #define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
 
-u_int16_t
+uint16_t
 in_cksum(const struct cksum_vec *vec, int veclen)
 {
-	register const u_int16_t *w;
+	register const uint16_t *w;
 	register int sum = 0;
 	register int mlen = 0;
 	int byte_swapped = 0;
 
 	union {
-		u_int8_t	c[2];
-		u_int16_t	s;
+		uint8_t		c[2];
+		uint16_t	s;
 	} s_util;
 	union {
-		u_int16_t	s[2];
-		u_int32_t	l;
+		uint16_t	s[2];
+		uint32_t	l;
 	} l_util;
 
 	for (; veclen != 0; vec++, veclen--) {
 		if (vec->len == 0)
 			continue;
-		w = (const u_int16_t *)(void *)vec->ptr;
+		w = (const uint16_t *)(void *)vec->ptr;
 		if (mlen == -1) {
 			/*
 			 * The first byte of this chunk is the continuation
@@ -83,9 +84,9 @@
 			 * s_util.c[0] is already saved when scanning previous
 			 * chunk.
 			 */
-			s_util.c[1] = *(const u_int8_t *)w;
+			s_util.c[1] = *(const uint8_t *)w;
 			sum += s_util.s;
-			w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1);
+			w = (const uint16_t *)(void *)((const uint8_t *)w + 1);
 			mlen = vec->len - 1;
 		} else
 			mlen = vec->len;
@@ -95,8 +96,8 @@
 		if ((1 & (unsigned long) w) && (mlen > 0)) {
 			REDUCE;
 			sum <<= 8;
-			s_util.c[0] = *(const u_int8_t *)w;
-			w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1);
+			s_util.c[0] = *(const uint8_t *)w;
+			w = (const uint16_t *)(void *)((const uint8_t *)w + 1);
 			mlen--;
 			byte_swapped = 1;
 		}
@@ -128,13 +129,13 @@
 			sum <<= 8;
 			byte_swapped = 0;
 			if (mlen == -1) {
-				s_util.c[1] = *(const u_int8_t *)w;
+				s_util.c[1] = *(const uint8_t *)w;
 				sum += s_util.s;
 				mlen = 0;
 			} else
 				mlen = -1;
 		} else if (mlen == -1)
-			s_util.c[0] = *(const u_int8_t *)w;
+			s_util.c[0] = *(const uint8_t *)w;
 	}
 	if (mlen == -1) {
 		/* The last mbuf has odd # of bytes. Follow the
@@ -153,10 +154,10 @@
  * that the checksum covers (including the checksum itself), compute
  * what the checksum field *should* have been.
  */
-u_int16_t
-in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum)
+uint16_t
+in_cksum_shouldbe(uint16_t sum, uint16_t computed_sum)
 {
-	u_int32_t shouldbe;
+	uint32_t shouldbe;
 
 	/*
 	 * The value that should have gone into the checksum field
diff --git a/install-sh b/install-sh
index ebc6691..b44de09 100755
--- a/install-sh
+++ b/install-sh
@@ -115,7 +115,7 @@
 if [ x"$dir_arg" != x ]; then
 	dst=$src
 	src=""
-	
+
 	if [ -d $dst ]; then
 		instcmd=:
 	else
@@ -124,7 +124,7 @@
 else
 
 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad 
+# might cause directories to be created, which would be especially bad
 # if $src (and thus $dsttmp) contains '*'.
 
 	if [ -f $src -o -d $src ]
@@ -134,7 +134,7 @@
 		echo "install:  $src does not exist"
 		exit 1
 	fi
-	
+
 	if [ x"$dst" = x ]
 	then
 		echo "install:	no destination specified"
@@ -201,17 +201,17 @@
 
 # If we're going to rename the final executable, determine the name now.
 
-	if [ x"$transformarg" = x ] 
+	if [ x"$transformarg" = x ]
 	then
 		dstfile=`basename $dst`
 	else
-		dstfile=`basename $dst $transformbasename | 
+		dstfile=`basename $dst $transformbasename |
 			sed $transformarg`$transformbasename
 	fi
 
 # don't allow the sed command to completely eliminate the filename
 
-	if [ x"$dstfile" = x ] 
+	if [ x"$dstfile" = x ]
 	then
 		dstfile=`basename $dst`
 	else
@@ -242,7 +242,7 @@
 # Now rename the file to the real destination.
 
 	$doit $rmcmd -f $dstdir/$dstfile &&
-	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+	$doit $mvcmd $dsttmp $dstdir/$dstfile
 
 fi &&
 
diff --git a/interface.h b/interface.h
index 9732d39..59c1eef 100644
--- a/interface.h
+++ b/interface.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.285 2008-08-16 11:36:20 hannes Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -84,13 +82,6 @@
 #define PT_PGM_ZMTP1	15	/* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */
 #define PT_LMP		16	/* Link Management Protocol */
 
-#ifndef min
-#define min(a,b) ((a)>(b)?(b):(a))
-#endif
-#ifndef max
-#define max(a,b) ((b)>(a)?(b):(a))
-#endif
-
 #define ESRC(ep) ((ep)->ether_shost)
 #define EDST(ep) ((ep)->ether_dhost)
 
@@ -102,10 +93,6 @@
 #endif
 #endif
 
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-
 extern char *program_name;	/* used to generate self-identifying messages */
 
 extern int32_t thiszone;	/* seconds offset from gmt to local time */
@@ -117,9 +104,21 @@
  * that "snapend - (l)" underflows.
  *
  * The check is for <= rather than < because "l" might be 0.
+ *
+ * We cast the pointers to uintptr_t to make sure that the compiler
+ * doesn't optimize away any of these tests (which it is allowed to
+ * do, as adding an integer to, or subtracting an integer from, a
+ * pointer assumes that the pointer is a pointer to an element of an
+ * array and that the result of the addition or subtraction yields a
+ * pointer to another member of the array, so that, for example, if
+ * you subtract a positive integer from a pointer, the result is
+ * guaranteed to be less than the original pointer value). See
+ *
+ *	http://www.kb.cert.org/vuls/id/162289
  */
-#define TTEST2(var, l) (snapend - (l) <= snapend && \
-			(const u_char *)&(var) <= snapend - (l))
+#define TTEST2(var, l) \
+	((uintptr_t)snapend - (l) <= (uintptr_t)snapend && \
+	   (uintptr_t)&(var) <= (uintptr_t)snapend - (l))
 
 /* True if "var" was captured */
 #define TTEST(var) TTEST2(var, sizeof(var))
@@ -130,18 +129,10 @@
 /* Bail if "var" was not captured */
 #define TCHECK(var) TCHECK2(var, sizeof(var))
 
-extern void ts_print(const struct timeval *);
-extern void relts_print(int);
-
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
-extern int fn_printzp(const u_char *, u_int, const u_char *);
-extern int mask2plen(u_int32_t);
+extern int mask2plen(uint32_t);
 extern const char *tok2strary_internal(const char **, int, const char *, int);
 #define	tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
 
-extern const char *dnaddr_string(u_short);
-
 extern void error(const char *, ...)
      __attribute__((noreturn))
 #ifdef __ATTRIBUTE___FORMAT_OK
@@ -157,216 +148,31 @@
 extern char *read_infile(char *);
 extern char *copy_argv(char **);
 
-extern void safeputchar(int);
-extern void safeputs(const char *, int);
-
-extern const char *isonsap_string(const u_char *, register u_int);
-extern const char *protoid_string(const u_char *);
-extern const char *ipxsap_string(u_short);
 extern const char *dnname_string(u_short);
 extern const char *dnnum_string(u_short);
 
 /* checksum routines */
 extern void init_checksum(void);
-extern u_int16_t verify_crc10_cksum(u_int16_t, const u_char *, int);
-extern u_int16_t create_osi_cksum(const u_int8_t *, int, int);
+extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int);
+extern uint16_t create_osi_cksum(const uint8_t *, int, int);
 
 /* The printer routines. */
 
 #include <pcap.h>
 
-extern int print_unknown_data(const u_char *, const char *,int);
-extern void ascii_print(const u_char *, u_int);
-extern void hex_and_ascii_print_with_offset(const char *, const u_char *,
-	u_int, u_int);
-extern void hex_and_ascii_print(const char *, const u_char *, u_int);
-extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
-extern void hex_print(const char *, const u_char *, u_int);
-extern void telnet_print(const u_char *, u_int);
-extern int llc_print(const u_char *, u_int, u_int, const u_char *,
-	const u_char *, u_short *);
-extern int snap_print(const u_char *, u_int, u_int, u_int);
-extern void aarp_print(const u_char *, u_int);
-extern void aodv_print(const u_char *, u_int, int);
-extern void atalk_print(const u_char *, u_int);
-extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int);
-extern u_int atm_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sunatm_if_print(const struct pcap_pkthdr *, const u_char *);
-extern int oam_print(const u_char *, u_int, u_int);
-extern void bootp_print(const u_char *, u_int);
-extern void bgp_print(const u_char *, int);
-extern void beep_print(const u_char *, u_int);
-extern void cnfp_print(const u_char *, const u_char *);
-extern void decnet_print(const u_char *, u_int, u_int);
-extern void default_print(const u_char *, u_int);
-extern void dvmrp_print(const u_char *, u_int);
-extern void egp_print(const u_char *, u_int);
-extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int token_print(const u_char *, u_int, u_int);
-extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void fddi_print(const u_char *, u_int, u_int);
-extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int mfr_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int fr_print(register const u_char *, u_int);
-extern u_int mfr_print(register const u_char *, u_int);
-extern char *q922_string(const u_char *);
-extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
-	const u_char *);
-extern u_int ap1394_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *,
-	const u_char *);
-extern void gre_print(const u_char *, u_int);
-extern void icmp_print(const u_char *, u_int, const u_char *, int);
-extern void igmp_print(const u_char *, u_int);
-extern void igrp_print(const u_char *, u_int, const u_char *);
-extern void ipN_print(const u_char *, u_int);
-extern u_int ipfc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void ipx_print(const u_char *, u_int);
-extern void isoclns_print(const u_char *, u_int, u_int);
-extern void krb_print(const u_char *);
-extern u_int llap_print(const u_char *, u_int);
-extern u_int ltalk_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void msdp_print(const unsigned char *, u_int);
-extern void nfsreply_print(const u_char *, u_int, const u_char *);
-extern void nfsreply_print_noaddr(const u_char *, u_int, const u_char *);
-extern void nfsreq_print(const u_char *, u_int, const u_char *);
-extern void nfsreq_print_noaddr(const u_char *, u_int, const u_char *);
-extern void ns_print(const u_char *, u_int, int);
-extern const u_char * ns_nprint (register const u_char *, register const u_char *);
-extern void ntp_print(const u_char *, u_int);
-extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void openflow_print(const u_char *, u_int);
-extern void ospf_print(const u_char *, u_int, const u_char *);
-extern void olsr_print (const u_char *, u_int, int);
-extern void pimv1_print(const u_char *, u_int);
-extern void cisco_autorp_print(const u_char *, u_int);
-extern void rsvp_print(const u_char *, u_int);
-extern void ldp_print(const u_char *, u_int);
-extern void lldp_print(const u_char *, u_int);
-extern void rpki_rtr_print(const u_char *, u_int);
-extern void lmp_print(const u_char *, u_int);
-extern void lspping_print(const u_char *, u_int);
-extern void lwapp_control_print(const u_char *, u_int, int);
-extern void lwapp_data_print(const u_char *, u_int);
-extern void eigrp_print(const u_char *, u_int);
-extern void mobile_print(const u_char *, u_int);
-extern void pim_print(const u_char *, u_int, u_int);
-extern u_int pppoe_print(const u_char *, u_int);
-extern u_int ppp_print(register const u_char *, u_int);
-extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void q933_print(const u_char *, u_int);
-extern int vjc_print(register const char *, u_short);
-extern void vqp_print(register const u_char *, register u_int);
-extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void rip_print(const u_char *, u_int);
-extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void lane_print(const u_char *, u_int, u_int);
-extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int cip_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_print(register const u_char *, u_int);
-extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mfr_print(const struct pcap_pkthdr *, register const u_char *);
-extern u_int juniper_mlfr_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mlppp_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_atm_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ggsn_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_es_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_monitor_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_services_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ether_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ppp_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_frelay_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_chdlc_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void snmp_print(const u_char *, u_int);
-extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
-extern u_int symantec_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void tcp_print(const u_char *, u_int, const u_char *, int);
-extern void tftp_print(const u_char *, u_int);
-extern void timed_print(const u_char *);
-extern void udld_print(const u_char *, u_int);
-extern void udp_print(const u_char *, u_int, const u_char *, int);
-extern void vtp_print(const u_char *, u_int);
-extern void wb_print(const void *, u_int);
-extern int ah_print(register const u_char *);
-extern int ipcomp_print(register const u_char *, int *);
-extern void rx_print(register const u_char *, int, int, int, u_char *);
-extern void netbeui_print(u_short, const u_char *, int);
-extern void ipx_netbios_print(const u_char *, u_int);
-extern void nbt_tcp_print(const u_char *, int);
-extern void nbt_udp137_print(const u_char *, int);
-extern void nbt_udp138_print(const u_char *, int);
-extern void smb_tcp_print(const u_char *, int);
 extern char *smb_errstr(int, int);
-extern const char *nt_errstr(u_int32_t);
-extern void print_data(const unsigned char *, int);
-extern void l2tp_print(const u_char *, u_int);
-extern void vrrp_print(const u_char *, u_int, int);
-extern void carp_print(const u_char *, u_int, int);
-extern void slow_print(const u_char *, u_int);
-extern void sflow_print(const u_char *, u_int);
-extern void mpcp_print(const u_char *, u_int);
-extern void cfm_print(const u_char *, u_int);
-extern void pgm_print(const u_char *, u_int, const u_char *);
-extern void cdp_print(const u_char *, u_int, u_int);
-extern void dtp_print(const u_char *, u_int);
-extern void stp_print(const u_char *, u_int);
-extern void radius_print(const u_char *, u_int);
-extern void lwres_print(const u_char *, u_int);
-extern void pptp_print(const u_char *);
-extern void dccp_print(const u_char *, const u_char *, u_int);
-extern void sctp_print(const u_char *, const u_char *, u_int);
-extern void forces_print(const u_char *, u_int);
-extern void mpls_print(const u_char *, u_int);
-extern void mpls_lsp_ping_print(const u_char *, u_int);
-extern void zephyr_print(const u_char *, int);
-extern void zmtp1_print(const u_char *, u_int);
-extern void zmtp1_print_datagram(const u_char *, u_int);
-extern void hsrp_print(const u_char *, u_int);
-extern void bfd_print(const u_char *, u_int, u_int);
-extern void sip_print(const u_char *, u_int);
-extern void syslog_print(const u_char *, u_int);
-extern int mptcp_print(const u_char *, u_int, u_char);
-extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
-extern void vxlan_print(const u_char *, u_int);
-extern void otv_print(const u_char *, u_int);
-
+extern const char *nt_errstr(uint32_t);
 
 #ifdef INET6
-extern void ip6_opt_print(const u_char *, int);
-extern int hbhopt_print(const u_char *);
-extern int dstopt_print(const u_char *);
-extern int frag6_print(const u_char *, const u_char *);
-extern int mobility_print(const u_char *, const u_char *);
-extern void ripng_print(const u_char *, unsigned int);
-extern int rt6_print(const u_char *, const u_char *);
-extern void ospf6_print(const u_char *, u_int);
-extern void dhcp6_print(const u_char *, u_int);
-extern void babel_print(const u_char *, u_int);
 extern int mask62plen(const u_char *);
 #endif /*INET6*/
 
 struct cksum_vec {
-	const u_int8_t	*ptr;
+	const uint8_t	*ptr;
 	int		len;
 };
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
+extern uint16_t in_cksum(const struct cksum_vec *, int);
+extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
 
 #ifndef HAVE_BPF_DUMP
 struct bpf_program;
@@ -382,30 +188,30 @@
 #ifndef NETDISSECT_REWORKED
 extern netdissect_options *gndo;
 
-#define bflag gndo->ndo_bflag 
-#define eflag gndo->ndo_eflag 
-#define fflag gndo->ndo_fflag 
+#define bflag gndo->ndo_bflag
+#define eflag gndo->ndo_eflag
+#define fflag gndo->ndo_fflag
 #define jflag gndo->ndo_jflag
-#define Kflag gndo->ndo_Kflag 
-#define nflag gndo->ndo_nflag 
-#define Nflag gndo->ndo_Nflag 
-#define Oflag gndo->ndo_Oflag 
-#define pflag gndo->ndo_pflag 
-#define qflag gndo->ndo_qflag 
-#define Rflag gndo->ndo_Rflag 
-#define sflag gndo->ndo_sflag 
-#define Sflag gndo->ndo_Sflag 
-#define tflag gndo->ndo_tflag 
-#define Uflag gndo->ndo_Uflag 
-#define uflag gndo->ndo_uflag 
-#define vflag gndo->ndo_vflag 
-#define xflag gndo->ndo_xflag 
-#define Xflag gndo->ndo_Xflag 
-#define Cflag gndo->ndo_Cflag 
-#define Gflag gndo->ndo_Gflag 
-#define Aflag gndo->ndo_Aflag 
-#define Bflag gndo->ndo_Bflag 
-#define Iflag gndo->ndo_Iflag 
+#define Kflag gndo->ndo_Kflag
+#define nflag gndo->ndo_nflag
+#define Nflag gndo->ndo_Nflag
+#define Oflag gndo->ndo_Oflag
+#define pflag gndo->ndo_pflag
+#define qflag gndo->ndo_qflag
+#define Rflag gndo->ndo_Rflag
+#define sflag gndo->ndo_sflag
+#define Sflag gndo->ndo_Sflag
+#define tflag gndo->ndo_tflag
+#define Uflag gndo->ndo_Uflag
+#define uflag gndo->ndo_uflag
+#define vflag gndo->ndo_vflag
+#define xflag gndo->ndo_xflag
+#define Xflag gndo->ndo_Xflag
+#define Cflag gndo->ndo_Cflag
+#define Gflag gndo->ndo_Gflag
+#define Aflag gndo->ndo_Aflag
+#define Bflag gndo->ndo_Bflag
+#define Iflag gndo->ndo_Iflag
 #define suppress_default_print gndo->ndo_suppress_default_print
 #define packettype gndo->ndo_packettype
 #define sigsecret gndo->ndo_sigsecret
@@ -413,9 +219,11 @@
 #define WflagChars gndo->ndo_WflagChars
 #define Cflag_count gndo->ndo_Cflag_count
 #define Gflag_count gndo->ndo_Gflag_count
-#define Gflag_time gndo->ndo_Gflag_time 
+#define Gflag_time gndo->ndo_Gflag_time
 #define Hflag gndo->ndo_Hflag
 #define snaplen     gndo->ndo_snaplen
 #define snapend     gndo->ndo_snapend
 
+extern void default_print(const u_char *, u_int);
+
 #endif
diff --git a/ip.h b/ip.h
index 8a97632..72c8972 100644
--- a/ip.h
+++ b/ip.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.12 2007-09-14 01:29:28 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -34,6 +33,11 @@
  *	@(#)ip.h	8.2 (Berkeley) 6/1/94
  */
 
+#ifndef TCPDUMP_IP_H
+#define TCPDUMP_IP_H
+
+#include "tcpdump-stdinc.h"
+
 /*
  * Definitions for internet protocol version 4.
  * Per RFC 791, September 1981.
@@ -48,19 +52,19 @@
  * against negative integers quite easily, and fail in subtle ways.
  */
 struct ip {
-	u_int8_t	ip_vhl;		/* header length, version */
+	uint8_t		ip_vhl;		/* header length, version */
 #define IP_V(ip)	(((ip)->ip_vhl & 0xf0) >> 4)
 #define IP_HL(ip)	((ip)->ip_vhl & 0x0f)
-	u_int8_t	ip_tos;		/* type of service */
-	u_int16_t	ip_len;		/* total length */
-	u_int16_t	ip_id;		/* identification */
-	u_int16_t	ip_off;		/* fragment offset field */
+	uint8_t		ip_tos;		/* type of service */
+	uint16_t	ip_len;		/* total length */
+	uint16_t	ip_id;		/* identification */
+	uint16_t	ip_off;		/* fragment offset field */
 #define	IP_DF 0x4000			/* dont fragment flag */
 #define	IP_MF 0x2000			/* more fragments flag */
 #define	IP_OFFMASK 0x1fff		/* mask for fragmenting bits */
-	u_int8_t	ip_ttl;		/* time to live */
-	u_int8_t	ip_p;		/* protocol */
-	u_int16_t	ip_sum;		/* checksum */
+	uint8_t		ip_ttl;		/* time to live */
+	uint8_t		ip_p;		/* protocol */
+	uint16_t	ip_sum;		/* checksum */
 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
 } UNALIGNED;
 
@@ -121,17 +125,17 @@
  * Time stamp option structure.
  */
 struct	ip_timestamp {
-	u_int8_t	ipt_code;	/* IPOPT_TS */
-	u_int8_t	ipt_len;	/* size of structure (variable) */
-	u_int8_t	ipt_ptr;	/* index of current entry */
-	u_int8_t	ipt_oflwflg;	/* flags, overflow counter */
+	uint8_t		ipt_code;	/* IPOPT_TS */
+	uint8_t		ipt_len;	/* size of structure (variable) */
+	uint8_t		ipt_ptr;	/* index of current entry */
+	uint8_t		ipt_oflwflg;	/* flags, overflow counter */
 #define IPTS_OFLW(ip)	(((ipt)->ipt_oflwflg & 0xf0) >> 4)
 #define IPTS_FLG(ip)	((ipt)->ipt_oflwflg & 0x0f)
 	union ipt_timestamp {
-		u_int32_t ipt_time[1];
+		uint32_t ipt_time[1];
 		struct	ipt_ta {
 			struct in_addr ipt_addr;
-			u_int32_t ipt_time;
+			uint32_t ipt_time;
 		} ipt_ta[1];
 	} ipt_timestamp;
 } UNALIGNED;
@@ -159,6 +163,4 @@
 #define	IPTTLDEC	1		/* subtracted when forwarding */
 
 #define	IP_MSS		576		/* default maximum segment size */
-
-/* in print-ip.c */
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
+#endif /* TCPDUMP_IP_H */
diff --git a/ip6.h b/ip6.h
index 12c87ad..1ad9149 100644
--- a/ip6.h
+++ b/ip6.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.8 2007-08-29 02:31:44 mcr Exp $ (LBL) */
 /*	NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp 	*/
 /*	$KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $	*/
 
@@ -77,18 +76,19 @@
 struct ip6_hdr {
 	union {
 		struct ip6_hdrctl {
-			u_int32_t ip6_un1_flow;	/* 20 bits of flow-ID */
-			u_int16_t ip6_un1_plen;	/* payload length */
-			u_int8_t  ip6_un1_nxt;	/* next header */
-			u_int8_t  ip6_un1_hlim;	/* hop limit */
+			uint32_t ip6_un1_flow;	/* 20 bits of flow-ID */
+			uint16_t ip6_un1_plen;	/* payload length */
+			uint8_t  ip6_un1_nxt;	/* next header */
+			uint8_t  ip6_un1_hlim;	/* hop limit */
 		} ip6_un1;
-		u_int8_t ip6_un2_vfc;	/* 4 bits version, top 4 bits class */
+		uint8_t ip6_un2_vfc;	/* 4 bits version, top 4 bits class */
 	} ip6_ctlun;
 	struct in6_addr ip6_src;	/* source address */
 	struct in6_addr ip6_dst;	/* destination address */
 } UNALIGNED;
 
 #define ip6_vfc		ip6_ctlun.ip6_un2_vfc
+#define IP6_VERSION(ip6_hdr)	(((ip6_hdr)->ip6_vfc & 0xf0) >> 4)
 #define ip6_flow	ip6_ctlun.ip6_un1.ip6_un1_flow
 #define ip6_plen	ip6_ctlun.ip6_un1.ip6_un1_plen
 #define ip6_nxt		ip6_ctlun.ip6_un1.ip6_un1_nxt
@@ -96,8 +96,8 @@
 #define ip6_hops	ip6_ctlun.ip6_un1.ip6_un1_hlim
 
 /* in network endian */
-#define IPV6_FLOWINFO_MASK	((u_int32_t)htonl(0x0fffffff))	/* flow info (28 bits) */
-#define IPV6_FLOWLABEL_MASK	((u_int32_t)htonl(0x000fffff))	/* flow label (20 bits) */
+#define IPV6_FLOWINFO_MASK	((uint32_t)htonl(0x0fffffff))	/* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK	((uint32_t)htonl(0x000fffff))	/* flow label (20 bits) */
 #if 1
 /* ECN bits proposed by Sally Floyd */
 #define IP6TOS_CE		0x01	/* congestion experienced */
@@ -109,29 +109,33 @@
  */
 
 struct	ip6_ext {
-	u_int8_t ip6e_nxt;
-	u_int8_t ip6e_len;
+	uint8_t ip6e_nxt;
+	uint8_t ip6e_len;
 } UNALIGNED;
 
 /* Hop-by-Hop options header */
 struct ip6_hbh {
-	u_int8_t ip6h_nxt;	/* next header */
-	u_int8_t ip6h_len;	/* length in units of 8 octets */
+	uint8_t ip6h_nxt;	/* next header */
+	uint8_t ip6h_len;	/* length in units of 8 octets */
 	/* followed by options */
 } UNALIGNED;
 
 /* Destination options header */
 struct ip6_dest {
-	u_int8_t ip6d_nxt;	/* next header */
-	u_int8_t ip6d_len;	/* length in units of 8 octets */
+	uint8_t ip6d_nxt;	/* next header */
+	uint8_t ip6d_len;	/* length in units of 8 octets */
 	/* followed by options */
 } UNALIGNED;
 
+/* http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */
+
 /* Option types and related macros */
 #define IP6OPT_PAD1		0x00	/* 00 0 00000 */
 #define IP6OPT_PADN		0x01	/* 00 0 00001 */
 #define IP6OPT_JUMBO		0xC2	/* 11 0 00010 = 194 */
 #define IP6OPT_JUMBO_LEN	6
+#define IP6OPT_RPL		0x63	/* 01 1 00011 */
+#define IP6OPT_TUN_ENC_LIMIT	0x04	/* 00 0 00100 */
 #define IP6OPT_ROUTER_ALERT	0x05	/* 00 0 00101 */
 
 #define IP6OPT_RTALERT_LEN	4
@@ -140,11 +144,16 @@
 #define IP6OPT_RTALERT_ACTNET	2 	/* contains an Active Networks msg */
 #define IP6OPT_MINLEN		2
 
-#define IP6OPT_BINDING_UPDATE	0xc6	/* 11 0 00110 */
-#define IP6OPT_BINDING_ACK	0x07	/* 00 0 00111 */
-#define IP6OPT_BINDING_REQ	0x08	/* 00 0 01000 */
+#define IP6OPT_QUICK_START	0x26	/* 00 1 00110 */
+#define IP6OPT_CALIPSO		0x07	/* 00 0 00111 */
+#define IP6OPT_SMF_DPD		0x08	/* 00 0 01000 */
 #define IP6OPT_HOME_ADDRESS	0xc9	/* 11 0 01001 */
+#define IP6OPT_HOMEADDR_MINLEN	18
 #define IP6OPT_EID		0x8a	/* 10 0 01010 */
+#define IP6OPT_ILNP_NOTICE	0x8b	/* 10 0 01011 */
+#define IP6OPT_LINE_ID		0x8c	/* 10 0 01100 */
+#define IP6OPT_MPL		0x6d	/* 01 1 01101 */
+#define IP6OPT_IP_DFF		0xee	/* 11 1 01110 */
 
 #define IP6OPT_TYPE(o)		((o) & 0xC0)
 #define IP6OPT_TYPE_SKIP	0x00
@@ -156,30 +165,30 @@
 
 /* Routing header */
 struct ip6_rthdr {
-	u_int8_t  ip6r_nxt;	/* next header */
-	u_int8_t  ip6r_len;	/* length in units of 8 octets */
-	u_int8_t  ip6r_type;	/* routing type */
-	u_int8_t  ip6r_segleft;	/* segments left */
+	uint8_t  ip6r_nxt;	/* next header */
+	uint8_t  ip6r_len;	/* length in units of 8 octets */
+	uint8_t  ip6r_type;	/* routing type */
+	uint8_t  ip6r_segleft;	/* segments left */
 	/* followed by routing type specific data */
 } UNALIGNED;
 
 /* Type 0 Routing header */
 struct ip6_rthdr0 {
-	u_int8_t  ip6r0_nxt;		/* next header */
-	u_int8_t  ip6r0_len;		/* length in units of 8 octets */
-	u_int8_t  ip6r0_type;		/* always zero */
-	u_int8_t  ip6r0_segleft;	/* segments left */
-	u_int8_t  ip6r0_reserved;	/* reserved field */
-	u_int8_t  ip6r0_slmap[3];	/* strict/loose bit map */
+	uint8_t  ip6r0_nxt;		/* next header */
+	uint8_t  ip6r0_len;		/* length in units of 8 octets */
+	uint8_t  ip6r0_type;		/* always zero */
+	uint8_t  ip6r0_segleft;	/* segments left */
+	uint8_t  ip6r0_reserved;	/* reserved field */
+	uint8_t  ip6r0_slmap[3];	/* strict/loose bit map */
 	struct in6_addr ip6r0_addr[1];	/* up to 23 addresses */
 } UNALIGNED;
 
 /* Fragment header */
 struct ip6_frag {
-	u_int8_t  ip6f_nxt;		/* next header */
-	u_int8_t  ip6f_reserved;	/* reserved field */
-	u_int16_t ip6f_offlg;		/* offset, reserved, and flag */
-	u_int32_t ip6f_ident;		/* identification */
+	uint8_t  ip6f_nxt;		/* next header */
+	uint8_t  ip6f_reserved;	/* reserved field */
+	uint16_t ip6f_offlg;		/* offset, reserved, and flag */
+	uint32_t ip6f_ident;		/* identification */
 } UNALIGNED;
 
 #define IP6F_OFF_MASK		0xfff8	/* mask out offset from ip6f_offlg */
@@ -187,6 +196,6 @@
 #define IP6F_MORE_FRAG		0x0001	/* more-fragments flag */
 
 /* in print-ip6.c */
-extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
+extern int nextproto6_cksum(const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
 
 #endif /* not _NETINET_IP6_H_ */
diff --git a/ipfc.h b/ipfc.h
deleted file mode 100644
index 438d115..0000000
--- a/ipfc.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- *	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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ipfc.h,v 1.4 2002-12-11 07:13:53 guy Exp $ (LBL)
- */
-
-struct ipfc_header {
-	u_char  ipfc_dhost[8];
-	u_char  ipfc_shost[8];
-};
-
-#define IPFC_HDRLEN 16
diff --git a/ipnet.h b/ipnet.h
deleted file mode 100644
index ae69284..0000000
--- a/ipnet.h
+++ /dev/null
@@ -1,13 +0,0 @@
-typedef struct ipnet_hdr {
-	uint8_t		iph_version;
-	uint8_t		iph_family;
-	uint16_t	iph_htype;
-	uint32_t	iph_pktlen;
-	uint32_t	iph_ifindex;
-	uint32_t	iph_grifindex;
-	uint32_t	iph_zsrc;
-	uint32_t	iph_zdst;
-} ipnet_hdr_t;
-
-#define	IPH_AF_INET	2		/* Matches Solaris's AF_INET */
-#define	IPH_AF_INET6	26		/* Matches Solaris's AF_INET6 */
diff --git a/ipproto.c b/ipproto.c
index cbb9bf3..e44b748 100644
--- a/ipproto.c
+++ b/ipproto.c
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -13,11 +13,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/ipproto.c,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/ipproto.h b/ipproto.h
index c9801a6..75def3d 100644
--- a/ipproto.h
+++ b/ipproto.h
@@ -30,8 +30,6 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/ipproto.h,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)
- *
  * From:
  *	@(#)in.h	8.3 (Berkeley) 1/3/94
  * $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $
diff --git a/ipsec_doi.h b/ipsec_doi.h
deleted file mode 100644
index 554a258..0000000
--- a/ipsec_doi.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002-12-11 07:13:53 guy Exp $ */
-
-/* refer to RFC 2407 */
-
-#if !defined(_IPSEC_DOI_H_)
-#define _IPSEC_DOI_H_
-
-#define IPSEC_DOI 1
-
-/* 4.2 IPSEC Situation Definition */
-#define IPSECDOI_SIT_IDENTITY_ONLY           0x00000001
-#define IPSECDOI_SIT_SECRECY                 0x00000002
-#define IPSECDOI_SIT_INTEGRITY               0x00000004
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-  /* 4.4.2 IPSEC ISAKMP Transform Values */
-#define IPSECDOI_PROTO_ISAKMP                        1
-#define   IPSECDOI_KEY_IKE                             1
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPSEC_AH                      2
-  /* 4.4.3 IPSEC AH Transform Values */
-#define   IPSECDOI_AH_MD5                              2
-#define   IPSECDOI_AH_SHA                              3
-#define   IPSECDOI_AH_DES                              4
-#define   IPSECDOI_AH_SHA2_256                         5
-#define   IPSECDOI_AH_SHA2_384                         6
-#define   IPSECDOI_AH_SHA2_512                         7
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPSEC_ESP                     3
-  /* 4.4.4 IPSEC ESP Transform Identifiers */
-#define   IPSECDOI_ESP_DES_IV64                        1
-#define   IPSECDOI_ESP_DES                             2
-#define   IPSECDOI_ESP_3DES                            3
-#define   IPSECDOI_ESP_RC5                             4
-#define   IPSECDOI_ESP_IDEA                            5
-#define   IPSECDOI_ESP_CAST                            6
-#define   IPSECDOI_ESP_BLOWFISH                        7
-#define   IPSECDOI_ESP_3IDEA                           8
-#define   IPSECDOI_ESP_DES_IV32                        9
-#define   IPSECDOI_ESP_RC4                            10
-#define   IPSECDOI_ESP_NULL                           11
-#define   IPSECDOI_ESP_RIJNDAEL				12
-#define   IPSECDOI_ESP_AES				12
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPCOMP                        4
-  /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
-#define   IPSECDOI_IPCOMP_OUI                          1
-#define   IPSECDOI_IPCOMP_DEFLATE                      2
-#define   IPSECDOI_IPCOMP_LZS                          3
-
-/* 4.5 IPSEC Security Association Attributes */
-#define IPSECDOI_ATTR_SA_LTYPE                1 /* B */
-#define   IPSECDOI_ATTR_SA_LTYPE_DEFAULT        1
-#define   IPSECDOI_ATTR_SA_LTYPE_SEC            1
-#define   IPSECDOI_ATTR_SA_LTYPE_KB             2
-#define IPSECDOI_ATTR_SA_LDUR                 2 /* V */
-#define   IPSECDOI_ATTR_SA_LDUR_DEFAULT         28800 /* 8 hours */
-#define IPSECDOI_ATTR_GRP_DESC                3 /* B */
-#define IPSECDOI_ATTR_ENC_MODE                4 /* B */
-	/* default value: host dependent */
-#define   IPSECDOI_ATTR_ENC_MODE_TUNNEL         1
-#define   IPSECDOI_ATTR_ENC_MODE_TRNS           2
-#define IPSECDOI_ATTR_AUTH                    5 /* B */
-	/* 0 means not to use authentication. */
-#define   IPSECDOI_ATTR_AUTH_HMAC_MD5           1
-#define   IPSECDOI_ATTR_AUTH_HMAC_SHA1          2
-#define   IPSECDOI_ATTR_AUTH_DES_MAC            3
-#define   IPSECDOI_ATTR_AUTH_KPDK               4 /*RFC-1826(Key/Pad/Data/Key)*/
-	/*
-	 * When negotiating ESP without authentication, the Auth
-	 * Algorithm attribute MUST NOT be included in the proposal.
-	 * When negotiating ESP without confidentiality, the Auth
-	 * Algorithm attribute MUST be included in the proposal and
-	 * the ESP transform ID must be ESP_NULL.
-	*/
-#define IPSECDOI_ATTR_KEY_LENGTH              6 /* B */
-#define IPSECDOI_ATTR_KEY_ROUNDS              7 /* B */
-#define IPSECDOI_ATTR_COMP_DICT_SIZE          8 /* B */
-#define IPSECDOI_ATTR_COMP_PRIVALG            9 /* V */
-
-/* 4.6.1 Security Association Payload */
-struct ipsecdoi_sa {
-	struct isakmp_gen h;
-	u_int32_t doi; /* Domain of Interpretation */
-	u_int32_t sit; /* Situation */
-};
-
-struct ipsecdoi_secrecy_h {
-	u_int16_t len;
-	u_int16_t reserved;
-};
-
-/* 4.6.2.1 Identification Type Values */
-struct ipsecdoi_id {
-	struct isakmp_gen h;
-	u_int8_t  type;		/* ID Type */
-	u_int8_t  proto_id;	/* Protocol ID */
-	u_int16_t port;		/* Port */
-	/* Identification Data */
-};
-
-#define IPSECDOI_ID_IPV4_ADDR                        1
-#define IPSECDOI_ID_FQDN                             2
-#define IPSECDOI_ID_USER_FQDN                        3
-#define IPSECDOI_ID_IPV4_ADDR_SUBNET                 4
-#define IPSECDOI_ID_IPV6_ADDR                        5
-#define IPSECDOI_ID_IPV6_ADDR_SUBNET                 6
-#define IPSECDOI_ID_IPV4_ADDR_RANGE                  7
-#define IPSECDOI_ID_IPV6_ADDR_RANGE                  8
-#define IPSECDOI_ID_DER_ASN1_DN                      9
-#define IPSECDOI_ID_DER_ASN1_GN                      10
-#define IPSECDOI_ID_KEY_ID                           11
-
-/* 4.6.3 IPSEC DOI Notify Message Types */
-/* Notify Messages - Status Types */
-#define IPSECDOI_NTYPE_RESPONDER_LIFETIME                  24576
-#define IPSECDOI_NTYPE_REPLAY_STATUS                       24577
-#define IPSECDOI_NTYPE_INITIAL_CONTACT                     24578
-
-#endif /* !defined(_IPSEC_DOI_H_) */
diff --git a/ipx.h b/ipx.h
deleted file mode 100644
index bfc3019..0000000
--- a/ipx.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * IPX protocol formats
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002-12-11 07:13:54 guy Exp $
- */
-
-/* well-known sockets */
-#define	IPX_SKT_NCP		0x0451
-#define	IPX_SKT_SAP		0x0452
-#define	IPX_SKT_RIP		0x0453
-#define	IPX_SKT_NETBIOS		0x0455
-#define	IPX_SKT_DIAGNOSTICS	0x0456
-#define	IPX_SKT_NWLINK_DGM	0x0553	/* NWLink datagram, may contain SMB */
-#define	IPX_SKT_EIGRP		0x85be	/* Cisco EIGRP over IPX */
-
-/* IPX transport header */
-struct ipxHdr {
-    u_int16_t	cksum;		/* Checksum */
-    u_int16_t	length;		/* Length, in bytes, including header */
-    u_int8_t	tCtl;		/* Transport Control (i.e. hop count) */
-    u_int8_t	pType;		/* Packet Type (i.e. level 2 protocol) */
-    u_int16_t	dstNet[2];	/* destination net */
-    u_int8_t	dstNode[6];	/* destination node */
-    u_int16_t	dstSkt;		/* destination socket */
-    u_int16_t	srcNet[2];	/* source net */
-    u_int8_t	srcNode[6];	/* source node */
-    u_int16_t	srcSkt;		/* source socket */
-};
-
-#define ipxSize	30
-
diff --git a/isakmp.h b/isakmp.h
deleted file mode 100644
index d628f7a..0000000
--- a/isakmp.h
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-/* YIPS @(#)$Id: isakmp.h,v 1.12 2007-11-24 18:13:33 mcr Exp $ */
-
-/* refer to RFC 2408 */
-
-/* must include <netinet/in.h> */
-
-#if !defined(_ISAKMP_H_)
-#define _ISAKMP_H_
-
-typedef u_char cookie_t[8];
-typedef u_char msgid_t[4];
-
-typedef struct { /* i_cookie + r_cookie */
-	cookie_t i_ck;
-	cookie_t r_ck;
-} isakmp_index;
-
-#define INITIATOR       1
-#define RESPONDER       2
-
-#define PORT_ISAKMP 500
-
-#define GENERATE  1
-#define VALIDATE  0
-
-/* Phase of oakley definition */
-/*
-  0000 0000 0000 0000
-       |    |||| ||||
-       |    |||| ++++--> negosiation number in phase
-       |    ++++-------> phase number
-       +---------------> expire ?
- */
-#define ISAKMP_PH1      0x0010
-#define ISAKMP_PH2      0x0020
-#define ISAKMP_EXPIRED  0x0100
-
-#define ISAKMP_NGP_0    0x0000
-#define ISAKMP_NGP_1    0x0001
-#define ISAKMP_NGP_2    0x0002
-#define ISAKMP_NGP_3    0x0003
-#define ISAKMP_NGP_4    0x0004
-
-#define ISAKMP_PH1_N    (ISAKMP_PH1 | ISAKMP_NGP_0)  /* i.e. spawn */
-#define ISAKMP_PH1_1    (ISAKMP_PH1 | ISAKMP_NGP_1)
-#define ISAKMP_PH1_2    (ISAKMP_PH1 | ISAKMP_NGP_2)
-#define ISAKMP_PH1_3    (ISAKMP_PH1 | ISAKMP_NGP_3)
-#define ISAKMP_PH2_N    (ISAKMP_PH2 | ISAKMP_NGP_0)
-#define ISAKMP_PH2_1    (ISAKMP_PH2 | ISAKMP_NGP_1)
-#define ISAKMP_PH2_2    (ISAKMP_PH2 | ISAKMP_NGP_2)
-#define ISAKMP_PH2_3    (ISAKMP_PH2 | ISAKMP_NGP_3)
-
-#define ISAKMP_TIMER_DEFAULT     10 /* seconds */
-#define ISAKMP_TRY_DEFAULT        3 /* times */
-
-/* 3.1 ISAKMP Header Format (IKEv1 and IKEv2)
-         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        !                          Initiator                            !
-        !                            Cookie                             !
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        !                          Responder                            !
-        !                            Cookie                             !
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        !  Next Payload ! MjVer ! MnVer ! Exchange Type !     Flags     !
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        !                          Message ID                           !
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        !                            Length                             !
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp {
-	cookie_t i_ck;		/* Initiator Cookie */
-	cookie_t r_ck;		/* Responder Cookie */
-	u_int8_t np;		/* Next Payload Type */
-	u_int8_t vers;
-#define ISAKMP_VERS_MAJOR	0xf0
-#define ISAKMP_VERS_MAJOR_SHIFT	4
-#define ISAKMP_VERS_MINOR	0x0f
-#define ISAKMP_VERS_MINOR_SHIFT	0
-	u_int8_t etype;		/* Exchange Type */
-	u_int8_t flags;		/* Flags */
-	msgid_t msgid;
-	u_int32_t len;		/* Length */
-};
-
-/* Next Payload Type */
-#define ISAKMP_NPTYPE_NONE   0 /* NONE*/
-#define ISAKMP_NPTYPE_SA     1 /* Security Association */
-#define ISAKMP_NPTYPE_P      2 /* Proposal */
-#define ISAKMP_NPTYPE_T      3 /* Transform */
-#define ISAKMP_NPTYPE_KE     4 /* Key Exchange */
-#define ISAKMP_NPTYPE_ID     5 /* Identification */
-#define ISAKMP_NPTYPE_CERT   6 /* Certificate */
-#define ISAKMP_NPTYPE_CR     7 /* Certificate Request */
-#define ISAKMP_NPTYPE_HASH   8 /* Hash */
-#define ISAKMP_NPTYPE_SIG    9 /* Signature */
-#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
-#define ISAKMP_NPTYPE_N     11 /* Notification */
-#define ISAKMP_NPTYPE_D     12 /* Delete */
-#define ISAKMP_NPTYPE_VID   13 /* Vendor ID */
-#define ISAKMP_NPTYPE_v2E   46 /* v2 Encrypted payload */
-
-#define IKEv1_MAJOR_VERSION  1
-#define IKEv1_MINOR_VERSION  0
-
-#define IKEv2_MAJOR_VERSION  2
-#define IKEv2_MINOR_VERSION  0
-
-/* Exchange Type */
-#define ISAKMP_ETYPE_NONE   0 /* NONE */
-#define ISAKMP_ETYPE_BASE   1 /* Base */
-#define ISAKMP_ETYPE_IDENT  2 /* Identity Proteciton */
-#define ISAKMP_ETYPE_AUTH   3 /* Authentication Only */
-#define ISAKMP_ETYPE_AGG    4 /* Aggressive */
-#define ISAKMP_ETYPE_INF    5 /* Informational */
-
-/* Flags */
-#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
-#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
-#define ISAKMP_FLAG_extra 0x04
-
-/* IKEv2 */
-#define ISAKMP_FLAG_I (1 << 3)  /* (I)nitiator */
-#define ISAKMP_FLAG_V (1 << 4)  /* (V)ersion   */
-#define ISAKMP_FLAG_R (1 << 5)  /* (R)esponse  */
-
-
-/* 3.2 Payload Generic Header
-         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        ! Next Payload  !   RESERVED    !         Payload Length        !
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp_gen {
-	u_int8_t  np;       /* Next Payload */
-	u_int8_t  critical; /* bit 7 - critical, rest is RESERVED */
-	u_int16_t len;      /* Payload Length */
-};
-
-/* 3.3 Data Attributes
-         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        !A!       Attribute Type        !    AF=0  Attribute Length     !
-        !F!                             !    AF=1  Attribute Value      !
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        .                   AF=0  Attribute Value                       .
-        .                   AF=1  Not Transmitted                       .
-        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp_data {
-	u_int16_t type;     /* defined by DOI-spec, and Attribute Format */
-	u_int16_t lorv;     /* if f equal 1, Attribute Length */
-	                  /* if f equal 0, Attribute Value */
-	/* if f equal 1, Attribute Value */
-};
-#define ISAKMP_GEN_TLV 0x0000
-#define ISAKMP_GEN_TV  0x8000
-	/* mask for type of attribute format */
-#define ISAKMP_GEN_MASK 0x8000
-
-/* 3.4 Security Association Payload */
-	/* MAY NOT be used, because of being defined in ipsec-doi. */
-	/*
-	If the current payload is the last in the message,
-	then the value of the next payload field will be 0.
-	This field MUST NOT contain the
-	values for the Proposal or Transform payloads as they are considered
-	part of the security association negotiation.  For example, this
-	field would contain the value "10" (Nonce payload) in the first
-	message of a Base Exchange (see Section 4.4) and the value "0" in the
-	first message of an Identity Protect Exchange (see Section 4.5).
-	*/
-struct ikev1_pl_sa {
-	struct isakmp_gen h;
-	u_int32_t doi; /* Domain of Interpretation */
-	u_int32_t sit; /* Situation */
-};
-
-/* 3.5 Proposal Payload */
-	/*
-	The value of the next payload field MUST only contain the value "2"
-	or "0".  If there are additional Proposal payloads in the message,
-	then this field will be 2.  If the current Proposal payload is the
-	last within the security association proposal, then this field will
-	be 0.
-	*/
-struct ikev1_pl_p {
-	struct isakmp_gen h;
-	u_int8_t p_no;      /* Proposal # */
-	u_int8_t prot_id;   /* Protocol */
-	u_int8_t spi_size;  /* SPI Size */
-	u_int8_t num_t;     /* Number of Transforms */
-	/* SPI */
-};
-
-/* 3.6 Transform Payload */
-	/*
-	The value of the next payload field MUST only contain the value "3"
-	or "0".  If there are additional Transform payloads in the proposal,
-	then this field will be 3.  If the current Transform payload is the
-	last within the proposal, then this field will be 0.
-	*/
-struct ikev1_pl_t {
-	struct isakmp_gen h;
-	u_int8_t  t_no;     /* Transform # */
-	u_int8_t  t_id;     /* Transform-Id */
-	u_int16_t reserved; /* RESERVED2 */
-	/* SA Attributes */
-};
-
-/* 3.7 Key Exchange Payload */
-struct ikev1_pl_ke {
-	struct isakmp_gen h;
-	/* Key Exchange Data */
-};
-
-/* 3.8 Identification Payload */
-	/* MUST NOT to be used, because of being defined in ipsec-doi. */
-struct ikev1_pl_id {
-	struct isakmp_gen h;
-	union {
-		u_int8_t  id_type;   /* ID Type */
-		u_int32_t doi_data;  /* DOI Specific ID Data */
-	} d;
-	/* Identification Data */
-};
-
-/* 3.9 Certificate Payload */
-struct ikev1_pl_cert {
-	struct isakmp_gen h;
-	u_int8_t encode; /* Cert Encoding */
-	char   cert;   /* Certificate Data */
-		/*
-		This field indicates the type of
-		certificate or certificate-related information contained in the
-		Certificate Data field.
-		*/
-};
-
-/* Certificate Type */
-#define ISAKMP_CERT_NONE   0
-#define ISAKMP_CERT_PKCS   1
-#define ISAKMP_CERT_PGP    2
-#define ISAKMP_CERT_DNS    3
-#define ISAKMP_CERT_SIGN   4
-#define ISAKMP_CERT_KE     5
-#define ISAKMP_CERT_KT     6
-#define ISAKMP_CERT_CRL    7
-#define ISAKMP_CERT_ARL    8
-#define ISAKMP_CERT_SPKI   9
-
-/* 3.10 Certificate Request Payload */
-struct ikev1_pl_cr {
-	struct isakmp_gen h;
-	u_int8_t num_cert; /* # Cert. Types */
-	/*
-	Certificate Types (variable length)
-	  -- Contains a list of the types of certificates requested,
-	  sorted in order of preference.  Each individual certificate
-	  type is 1 octet.  This field is NOT requiredo
-	*/
-	/* # Certificate Authorities (1 octet) */
-	/* Certificate Authorities (variable length) */
-};
-
-/* 3.11 Hash Payload */
-	/* may not be used, because of having only data. */
-struct ikev1_pl_hash {
-	struct isakmp_gen h;
-	/* Hash Data */
-};
-
-/* 3.12 Signature Payload */
-	/* may not be used, because of having only data. */
-struct ikev1_pl_sig {
-	struct isakmp_gen h;
-	/* Signature Data */
-};
-
-/* 3.13 Nonce Payload */
-	/* may not be used, because of having only data. */
-struct ikev1_pl_nonce {
-	struct isakmp_gen h;
-	/* Nonce Data */
-};
-
-/* 3.14 Notification Payload */
-struct ikev1_pl_n {
-	struct isakmp_gen h;
-	u_int32_t doi;      /* Domain of Interpretation */
-	u_int8_t  prot_id;  /* Protocol-ID */
-	u_int8_t  spi_size; /* SPI Size */
-	u_int16_t type;     /* Notify Message Type */
-	/* SPI */
-	/* Notification Data */
-};
-
-/* 3.14.1 Notify Message Types */
-/* NOTIFY MESSAGES - ERROR TYPES */
-#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE           1
-#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED              2
-#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED        3
-#define ISAKMP_NTYPE_INVALID_COOKIE                 4
-#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION          5
-#define ISAKMP_NTYPE_INVALID_MINOR_VERSION          6
-#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE          7
-#define ISAKMP_NTYPE_INVALID_FLAGS                  8
-#define ISAKMP_NTYPE_INVALID_MESSAGE_ID             9
-#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID            10
-#define ISAKMP_NTYPE_INVALID_SPI                    11
-#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID           12
-#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED       13
-#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN             14
-#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX            15
-#define ISAKMP_NTYPE_PAYLOAD_MALFORMED              16
-#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION        17
-#define ISAKMP_NTYPE_INVALID_ID_INFORMATION         18
-#define ISAKMP_NTYPE_INVALID_CERT_ENCODING          19
-#define ISAKMP_NTYPE_INVALID_CERTIFICATE            20
-#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX        21
-#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY         22
-#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION       23
-#define ISAKMP_NTYPE_AUTHENTICATION_FAILED          24
-#define ISAKMP_NTYPE_INVALID_SIGNATURE              25
-#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION           26
-/* NOTIFY MESSAGES - STATUS TYPES */
-#define ISAKMP_NTYPE_CONNECTED                   16384
-/* using only to log */
-#define ISAKMP_LOG_RETRY_LIMIT_REACHED           65530
-
-/* 3.15 Delete Payload */
-struct ikev1_pl_d {
-	struct isakmp_gen h;
-	u_int32_t doi;      /* Domain of Interpretation */
-	u_int8_t  prot_id;  /* Protocol-Id */
-	u_int8_t  spi_size; /* SPI Size */
-	u_int16_t num_spi;  /* # of SPIs */
-	/* SPI(es) */
-};
-
-
-struct ikev1_ph1tab {
-	struct ikev1_ph1 *head;
-	struct ikev1_ph1 *tail;
-	int len;
-};
-
-struct isakmp_ph2tab {
-	struct ikev1_ph2 *head;
-	struct ikev1_ph2 *tail;
-	int len;
-};
-
-#define EXCHANGE_PROXY   1
-#define EXCHANGE_MYSELF  0
-
-#define PFS_NEED	1
-#define PFS_NONEED	0
-
-/* IKEv2 (RFC4306) */
-
-/* 3.3  Security Association Payload -- generic header */
-/* 3.3.1.  Proposal Substructure */
-struct ikev2_p {
-	struct isakmp_gen h;
-	u_int8_t p_no;      /* Proposal # */
-	u_int8_t prot_id;   /* Protocol */
-	u_int8_t spi_size;  /* SPI Size */
-	u_int8_t num_t;     /* Number of Transforms */
-};
-
-/* 3.3.2.  Transform Substructure */
-struct ikev2_t {
-	struct isakmp_gen h;
-	u_int8_t t_type;    /* Transform Type (ENCR,PRF,INTEG,etc.*/
-	u_int8_t res2;      /* reserved byte */
-	u_int16_t t_id;     /* Transform ID */
-};
-
-enum ikev2_t_type {
-	IV2_T_ENCR = 1,
-	IV2_T_PRF  = 2,
-	IV2_T_INTEG= 3,
-	IV2_T_DH   = 4,
-	IV2_T_ESN  = 5,
-};
-
-/* 3.4.  Key Exchange Payload */
-struct ikev2_ke {
-	struct isakmp_gen h;
-	u_int16_t  ke_group;
-	u_int16_t  ke_res1;
-	/* KE data */
-};
-
-
-/* 3.5.  Identification Payloads */
-enum ikev2_id_type {
-	ID_IPV4_ADDR=1,
-	ID_FQDN=2,
-	ID_RFC822_ADDR=3,
-	ID_IPV6_ADDR=5,
-	ID_DER_ASN1_DN=9,
-	ID_DER_ASN1_GN=10,
-	ID_KEY_ID=11,
-};
-struct ikev2_id {
-	struct isakmp_gen h;
-	u_int8_t  type;        /* ID type */
-	u_int8_t  res1;
-	u_int16_t res2;
-	/* SPI */
-	/* Notification Data */
-};
-
-/* 3.10 Notification Payload */
-struct ikev2_n {
-	struct isakmp_gen h;
-	u_int8_t  prot_id;  /* Protocol-ID */
-	u_int8_t  spi_size; /* SPI Size */
-	u_int16_t type;     /* Notify Message Type */
-};
-
-enum ikev2_n_type {
-	IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD            = 1,
-	IV2_NOTIFY_INVALID_IKE_SPI                         = 4,
-	IV2_NOTIFY_INVALID_MAJOR_VERSION                   = 5,
-	IV2_NOTIFY_INVALID_SYNTAX                          = 7,
-	IV2_NOTIFY_INVALID_MESSAGE_ID                      = 9,
-	IV2_NOTIFY_INVALID_SPI                             =11,
-	IV2_NOTIFY_NO_PROPOSAL_CHOSEN                      =14,
-	IV2_NOTIFY_INVALID_KE_PAYLOAD                      =17,
-	IV2_NOTIFY_AUTHENTICATION_FAILED                   =24,
-	IV2_NOTIFY_SINGLE_PAIR_REQUIRED                    =34,
-	IV2_NOTIFY_NO_ADDITIONAL_SAS                       =35,
-	IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE                =36,
-	IV2_NOTIFY_FAILED_CP_REQUIRED                      =37,
-	IV2_NOTIFY_INVALID_SELECTORS                       =39,
-	IV2_NOTIFY_INITIAL_CONTACT                         =16384,
-	IV2_NOTIFY_SET_WINDOW_SIZE                         =16385,
-	IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE                  =16386,
-	IV2_NOTIFY_IPCOMP_SUPPORTED                        =16387,
-	IV2_NOTIFY_NAT_DETECTION_SOURCE_IP                 =16388,
-	IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP            =16389,
-	IV2_NOTIFY_COOKIE                                  =16390,
-	IV2_NOTIFY_USE_TRANSPORT_MODE                      =16391,
-	IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED              =16392,
-	IV2_NOTIFY_REKEY_SA                                =16393,
-	IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED           =16394,
-	IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO                =16395
-};
-
-struct notify_messages {
-	u_int16_t type;
-	char     *msg;
-};
-
-/* 3.8 Notification Payload */
-struct ikev2_auth {
-	struct isakmp_gen h;
-	u_int8_t  auth_method;  /* Protocol-ID */
-	u_int8_t  reserved[3];
-	/* authentication data */
-};
-
-enum ikev2_auth_type {
-	IV2_RSA_SIG = 1,
-	IV2_SHARED  = 2,
-	IV2_DSS_SIG = 3,
-};
-
-#endif /* !defined(_ISAKMP_H_) */
diff --git a/l2tp.h b/l2tp.h
deleted file mode 100644
index 5be24b9..0000000
--- a/l2tp.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001-11-05 10:03:27 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
- *      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.
- *
- * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
- */
-
-
-#define L2TP_FLAG_TYPE		0x8000	/* Type (0=Data, 1=Control) */
-#define L2TP_FLAG_LENGTH	0x4000	/* Length */
-#define L2TP_FLAG_SEQUENCE	0x0800	/* Sequence */
-#define L2TP_FLAG_OFFSET	0x0200	/* Offset */
-#define L2TP_FLAG_PRIORITY	0x0100	/* Priority */
-
-#define L2TP_VERSION_MASK	0x000f	/* Version Mask */
-#define L2TP_VERSION_L2F	0x0001	/* L2F */
-#define L2TP_VERSION_L2TP	0x0002	/* L2TP */
-
-#define L2TP_AVP_HDR_FLAG_MANDATORY	0x8000	/* Mandatory Flag */
-#define L2TP_AVP_HDR_FLAG_HIDDEN	0x4000	/* Hidden Flag */
-#define L2TP_AVP_HDR_LEN_MASK		0x03ff	/* Length Mask */
-
-#define L2TP_FRAMING_CAP_SYNC_MASK	0x00000001	/* Synchronous */
-#define L2TP_FRAMING_CAP_ASYNC_MASK	0x00000002	/* Asynchronous */
-
-#define L2TP_FRAMING_TYPE_SYNC_MASK	0x00000001	/* Synchronous */
-#define L2TP_FRAMING_TYPE_ASYNC_MASK	0x00000002	/* Asynchronous */
-
-#define L2TP_BEARER_CAP_DIGITAL_MASK	0x00000001	/* Digital */
-#define L2TP_BEARER_CAP_ANALOG_MASK	0x00000002	/* Analog */
-
-#define L2TP_BEARER_TYPE_DIGITAL_MASK	0x00000001	/* Digital */
-#define L2TP_BEARER_TYPE_ANALOG_MASK	0x00000002	/* Analog */
-
-/* Authen Type */
-#define L2TP_AUTHEN_TYPE_RESERVED	0x0000	/* Reserved */
-#define L2TP_AUTHEN_TYPE_TEXTUAL	0x0001	/* Textual username/password exchange */
-#define L2TP_AUTHEN_TYPE_CHAP		0x0002	/* PPP CHAP */
-#define L2TP_AUTHEN_TYPE_PAP		0x0003	/* PPP PAP */
-#define L2TP_AUTHEN_TYPE_NO_AUTH	0x0004	/* No Authentication */
-#define L2TP_AUTHEN_TYPE_MSCHAPv1	0x0005	/* MSCHAPv1 */
-
-#define L2TP_PROXY_AUTH_ID_MASK		0x00ff
-
-
diff --git a/l2vpn.c b/l2vpn.c
index 021e7f0..54037aa 100644
--- a/l2vpn.c
+++ b/l2vpn.c
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -13,11 +13,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/l2vpn.c,v 1.1 2004-06-15 09:42:40 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -31,16 +27,16 @@
     { 0x00, "Reserved"},
     { 0x01, "Frame Relay"},
     { 0x02, "ATM AAL5 VCC transport"},
-    { 0x03, "ATM transparent cell transport"}, 
-    { 0x04, "Ethernet VLAN"}, 
-    { 0x05, "Ethernet"}, 
-    { 0x06, "Cisco-HDLC"}, 
-    { 0x07, "PPP"}, 
-    { 0x08, "SONET/SDH Circuit Emulation Service over MPLS"}, 
-    { 0x09, "ATM n-to-one VCC cell transport"}, 
-    { 0x0a, "ATM n-to-one VPC cell transport"}, 
-    { 0x0b, "IP Layer2 Transport"}, 
-    { 0x0c, "ATM one-to-one VCC Cell Mode"}, 
+    { 0x03, "ATM transparent cell transport"},
+    { 0x04, "Ethernet VLAN"},
+    { 0x05, "Ethernet"},
+    { 0x06, "Cisco-HDLC"},
+    { 0x07, "PPP"},
+    { 0x08, "SONET/SDH Circuit Emulation Service over MPLS"},
+    { 0x09, "ATM n-to-one VCC cell transport"},
+    { 0x0a, "ATM n-to-one VPC cell transport"},
+    { 0x0b, "IP Layer2 Transport"},
+    { 0x0c, "ATM one-to-one VCC Cell Mode"},
     { 0x0d, "ATM one-to-one VPC Cell Mode"},
     { 0x0e, "ATM AAL5 PDU VCC transport"},
     { 0x0f, "Frame-Relay Port mode"},
@@ -53,6 +49,6 @@
     { 0x16, "TDMoIP basic mode"},
     { 0x17, "CESoPSN TDM with CAS"},
     { 0x18, "TDMoIP TDM with CAS"},
-    { 0x40, "IP-interworking"}, 
+    { 0x40, "IP-interworking"},
     { 0, NULL}
 };
diff --git a/l2vpn.h b/l2vpn.h
index 871eca0..151228f 100644
--- a/l2vpn.h
+++ b/l2vpn.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/l2vpn.h,v 1.1 2004-06-15 09:42:41 hannes Exp $ (LBL) */
-/* 
+/*
  * 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
diff --git a/lane.h b/lane.h
deleted file mode 100644
index 76cc020..0000000
--- a/lane.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Marko Kiiskila carnil@cs.tut.fi
- *
- * Tampere University of Technology - Telecommunications Laboratory
- *
- * Permission to use, copy, modify and distribute this
- * software and its documentation is hereby granted,
- * provided that both the copyright notice and this
- * permission notice appear in all copies of the software,
- * derivative works or modified versions, and any portions
- * thereof, that both notices appear in supporting
- * documentation, and that the use of this software is
- * acknowledged in any publications resulting from using
- * the software.
- *
- * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
- * SOFTWARE.
- *
- */
-
-/* $Id: lane.h,v 1.7 2002-12-11 07:13:54 guy Exp $ */
-
-#ifndef ETHER_ADDR_LEN
-#define ETHER_ADDR_LEN 6
-#endif
-
-struct lecdatahdr_8023 {
-  u_int16_t le_header;
-  u_int8_t h_dest[ETHER_ADDR_LEN];
-  u_int8_t h_source[ETHER_ADDR_LEN];
-  u_int16_t h_type;
-};
-
-struct lane_controlhdr {
-  u_int16_t lec_header;
-  u_int8_t lec_proto;
-  u_int8_t lec_vers;
-  u_int16_t lec_opcode;
-};
diff --git a/lbl/os-osf4.h b/lbl/os-osf4.h
index 5682b7e..359bf36 100644
--- a/lbl/os-osf4.h
+++ b/lbl/os-osf4.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-osf4.h,v 1.1 2002-12-11 05:03:13 guy Exp $ (LBL)
  */
 
 /* Prototypes missing in Digital UNIX 4.x */
diff --git a/lbl/os-solaris2.h b/lbl/os-solaris2.h
index 5c01b87..9f94da9 100644
--- a/lbl/os-solaris2.h
+++ b/lbl/os-solaris2.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-solaris2.h,v 1.19 2000-10-11 04:02:15 guy Exp $ (LBL)
  */
 
 /* Prototypes missing in SunOS 5 */
diff --git a/lbl/os-sunos4.h b/lbl/os-sunos4.h
index ab0a12c..b735857 100644
--- a/lbl/os-sunos4.h
+++ b/lbl/os-sunos4.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-sunos4.h,v 1.32 1999-10-07 23:47:13 mcr Exp $ (LBL)
  */
 
 /* Prototypes missing in SunOS 4 */
diff --git a/lbl/os-ultrix4.h b/lbl/os-ultrix4.h
index 347485e..fa1f770 100644
--- a/lbl/os-ultrix4.h
+++ b/lbl/os-ultrix4.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/lbl/os-ultrix4.h,v 1.19 1999-10-07 23:47:13 mcr Exp $ (LBL)
  */
 
 /* Prototypes missing in Ultrix 4 */
diff --git a/llc.h b/llc.h
index 6604669..ec8d069 100644
--- a/llc.h
+++ b/llc.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.23 2007-04-13 09:43:11 hannes Exp $ (LBL)
  */
 
 /*
diff --git a/machdep.c b/machdep.c
index 6b3d473..7b259ae 100644
--- a/machdep.c
+++ b/machdep.c
@@ -19,11 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.13 2003-12-15 03:53:21 guy Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -55,6 +50,15 @@
 
 #include "machdep.h"
 
+/*
+ * On platforms where the CPU doesn't support unaligned loads, force
+ * unaligned accesses to abort with SIGBUS, rather than being fixed
+ * up (slowly) by the OS kernel; on those platforms, misaligned accesses
+ * are bugs, and we want tcpdump to crash so that the bugs are reported.
+ *
+ * The only OS on which this is necessary is DEC OSF/1^W^WDigital
+ * UNIX^W^WTru64 UNIX.
+ */
 int
 abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_)
 {
diff --git a/machdep.h b/machdep.h
index 6328c82..d1c7d4b 100644
--- a/machdep.h
+++ b/machdep.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.2 2000-01-17 06:24:24 itojun Exp $ (LBL)
  */
 #ifndef tcpdump_machdep_h
 #define tcpdump_machdep_h
diff --git a/makemib b/makemib
index b59e2f1..97e7875 100755
--- a/makemib
+++ b/makemib
@@ -26,8 +26,6 @@
 # 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.
-#
-# @(#) $Id: makemib,v 1.3 2001-09-17 22:16:52 fenner Exp $ (jlv)
 
 #
 # This script will read either ASN.1-style MIB files or the ".defs" files
@@ -39,7 +37,7 @@
 # This script needs to be run by "gawk" (GNU awk).  "nawk" will work, but
 # dump will get a recursion error if you process LARGE mibs.  While it would
 # by farily easy to rewrite this not to use recursion (and also easy to
-# eliminate use of gsub and functions to use classic "awk"), you have to 
+# eliminate use of gsub and functions to use classic "awk"), you have to
 # order the structure declarations in defined-first order for the compiler
 # not to barf; too bad tsort doesn't take arguments.
 #
@@ -49,7 +47,7 @@
  * This file was generated by tcpdump/makemib on `date`
  * You probably don't want to edit this by hand!
  *
- * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer 
+ * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer
 };
  */
 
@@ -159,7 +157,7 @@
 }
 
 
-# 
+#
 # End of the road - output the data.
 #
 
diff --git a/missing/addrinfo.h b/missing/addrinfo.h
index d3d63cd..bf4bbf6 100644
--- a/missing/addrinfo.h
+++ b/missing/addrinfo.h
@@ -27,8 +27,6 @@
  * SUCH DAMAGE.
  */
 
-/* $Id: addrinfo.h,v 1.4 2002-06-11 17:13:36 itojun Exp $ */
-
 #ifndef HAVE_ADDRINFO
 
 /*
diff --git a/missing/datalinks.c b/missing/datalinks.c
index 1bd8644..e7d526b 100644
--- a/missing/datalinks.c
+++ b/missing/datalinks.c
@@ -31,11 +31,6 @@
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/missing/datalinks.c,v 1.3 2003-11-16 09:36:47 guy Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/missing/dlnames.c b/missing/dlnames.c
index 32072b7..a10cd39 100644
--- a/missing/dlnames.c
+++ b/missing/dlnames.c
@@ -31,11 +31,6 @@
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/missing/dlnames.c,v 1.5 2003-11-18 23:09:43 guy Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/missing/getnameinfo.c b/missing/getnameinfo.c
index c287221..63aba73 100644
--- a/missing/getnameinfo.c
+++ b/missing/getnameinfo.c
@@ -41,11 +41,6 @@
 #include <config.h>
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/missing/getnameinfo.c,v 1.11 2003-11-16 09:36:49 guy Exp $";
-#endif
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <net/if.h>
@@ -112,7 +107,7 @@
 	u_short port;
 	int family, i;
 	char *addr, *p;
-	u_int32_t v4a;
+	uint32_t v4a;
 	int h_error;
 	char numserv[512];
 	char numaddr[512];
@@ -168,7 +163,7 @@
 
 	switch (sa->sa_family) {
 	case AF_INET:
-		v4a = (u_int32_t)
+                v4a = (uint32_t)
 			ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
 		if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
 			flags |= NI_NUMERICHOST;
diff --git a/missing/getopt_long.c b/missing/getopt_long.c
new file mode 100644
index 0000000..8085736
--- /dev/null
+++ b/missing/getopt_long.c
@@ -0,0 +1,612 @@
+/*	$OpenBSD: getopt_long.c,v 1.22 2006/10/04 21:29:04 jmc Exp $	*/
+/*	$NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $	*/
+
+/*
+ * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION 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.
+ */
+
+
+#include <errno.h>
+#include "getopt_long.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#define GNU_COMPATIBLE		/* Be more compatible, configure's use us! */
+
+#define PRINT_ERROR	((opterr) && (*options != ':'))
+
+#define FLAG_PERMUTE	0x01	/* permute non-options to the end of argv */
+#define FLAG_ALLARGS	0x02	/* treat non-options as args to option "-1" */
+#define FLAG_LONGONLY	0x04	/* operate as getopt_long_only */
+
+/* return values */
+#define	BADCH		(int)'?'
+#define	BADARG		((*options == ':') ? (int)':' : (int)'?')
+#define	INORDER 	(int)1
+
+#define	EMSG		""
+
+#ifdef GNU_COMPATIBLE
+#define NO_PREFIX	(-1)
+#define D_PREFIX	0
+#define DD_PREFIX	1
+#define W_PREFIX	2
+#endif
+
+char *optarg;
+int optind, opterr = 1, optopt;
+
+static int getopt_internal(int, char * const *, const char *,
+			   const struct option *, int *, int);
+static int parse_long_options(char * const *, const char *,
+			      const struct option *, int *, int, int);
+static int gcd(int, int);
+static void permute_args(int, int, int, char * const *);
+
+static const char *place = EMSG; /* option letter processing */
+
+static int nonopt_start = -1; /* first non option argument (for permute) */
+static int nonopt_end = -1;   /* first option after non options (for permute) */
+
+/* Error messages */
+static const char recargchar[] = "option requires an argument -- %c";
+static const char illoptchar[] = "illegal option -- %c"; /* From P1003.2 */
+#ifdef GNU_COMPATIBLE
+static int dash_prefix = NO_PREFIX;
+static const char gnuoptchar[] = "invalid option -- %c";
+
+static const char recargstring[] = "option `%s%s' requires an argument";
+static const char ambig[] = "option `%s%.*s' is ambiguous";
+static const char noarg[] = "option `%s%.*s' doesn't allow an argument";
+static const char illoptstring[] = "unrecognized option `%s%s'";
+#else
+static const char recargstring[] = "option requires an argument -- %s";
+static const char ambig[] = "ambiguous option -- %.*s";
+static const char noarg[] = "option doesn't take an argument -- %.*s";
+static const char illoptstring[] = "unknown option -- %s";
+#endif
+
+/*
+ * Compute the greatest common divisor of a and b.
+ */
+static int
+gcd(int a, int b)
+{
+	int c;
+
+	c = a % b;
+	while (c != 0) {
+		a = b;
+		b = c;
+		c = a % b;
+	}
+
+	return (b);
+}
+
+/*
+ * Exchange the block from nonopt_start to nonopt_end with the block
+ * from nonopt_end to opt_end (keeping the same order of arguments
+ * in each block).
+ */
+static void
+permute_args(int panonopt_start, int panonopt_end, int opt_end,
+	char * const *nargv)
+{
+	int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+	char *swap;
+
+	/*
+	 * compute lengths of blocks and number and size of cycles
+	 */
+	nnonopts = panonopt_end - panonopt_start;
+	nopts = opt_end - panonopt_end;
+	ncycle = gcd(nnonopts, nopts);
+	cyclelen = (opt_end - panonopt_start) / ncycle;
+
+	for (i = 0; i < ncycle; i++) {
+		cstart = panonopt_end+i;
+		pos = cstart;
+		for (j = 0; j < cyclelen; j++) {
+			if (pos >= panonopt_end)
+				pos -= nnonopts;
+			else
+				pos += nopts;
+			swap = nargv[pos];
+			/* LINTED const cast */
+			((char **) nargv)[pos] = nargv[cstart];
+			/* LINTED const cast */
+			((char **)nargv)[cstart] = swap;
+		}
+	}
+}
+
+static void
+warnx(const char *fmt, ...)
+{
+	extern char *program_name;
+	va_list ap;
+
+	va_start(ap, fmt);
+	fprintf(stderr, "%s: ", program_name);
+	vfprintf(stderr, fmt, ap);
+	fprintf(stderr, "\n");
+	va_end(ap);
+}
+
+/*
+ * parse_long_options --
+ *	Parse long options in argc/argv argument vector.
+ * Returns -1 if short_too is set and the option does not match long_options.
+ */
+static int
+parse_long_options(char * const *nargv, const char *options,
+	const struct option *long_options, int *idx, int short_too, int flags)
+{
+	const char *current_argv, *has_equal;
+#ifdef GNU_COMPATIBLE
+	const char *current_dash;
+#endif
+	size_t current_argv_len;
+	int i, match, exact_match, second_partial_match;
+
+	current_argv = place;
+#ifdef GNU_COMPATIBLE
+	switch (dash_prefix) {
+		case D_PREFIX:
+			current_dash = "-";
+			break;
+		case DD_PREFIX:
+			current_dash = "--";
+			break;
+		case W_PREFIX:
+			current_dash = "-W ";
+			break;
+		default:
+			current_dash = "";
+			break;
+	}
+#endif
+	match = -1;
+	exact_match = 0;
+	second_partial_match = 0;
+
+	optind++;
+
+	if ((has_equal = strchr(current_argv, '=')) != NULL) {
+		/* argument found (--option=arg) */
+		current_argv_len = has_equal - current_argv;
+		has_equal++;
+	} else
+		current_argv_len = strlen(current_argv);
+
+	for (i = 0; long_options[i].name; i++) {
+		/* find matching long option */
+		if (strncmp(current_argv, long_options[i].name,
+		    current_argv_len))
+			continue;
+
+		if (strlen(long_options[i].name) == current_argv_len) {
+			/* exact match */
+			match = i;
+			exact_match = 1;
+			break;
+		}
+		/*
+		 * If this is a known short option, don't allow
+		 * a partial match of a single character.
+		 */
+		if (short_too && current_argv_len == 1)
+			continue;
+
+		if (match == -1)        /* first partial match */
+			match = i;
+		else if ((flags & FLAG_LONGONLY) ||
+			 long_options[i].has_arg !=
+			     long_options[match].has_arg ||
+			 long_options[i].flag != long_options[match].flag ||
+			 long_options[i].val != long_options[match].val)
+			second_partial_match = 1;
+	}
+	if (!exact_match && second_partial_match) {
+		/* ambiguous abbreviation */
+		if (PRINT_ERROR)
+			warnx(ambig,
+#ifdef GNU_COMPATIBLE
+			     current_dash,
+#endif
+			     (int)current_argv_len,
+			     current_argv);
+		optopt = 0;
+		return (BADCH);
+	}
+	if (match != -1) {		/* option found */
+		if (long_options[match].has_arg == no_argument
+		    && has_equal) {
+			if (PRINT_ERROR)
+				warnx(noarg,
+#ifdef GNU_COMPATIBLE
+				     current_dash,
+#endif
+				     (int)current_argv_len,
+				     current_argv);
+			/*
+			 * XXX: GNU sets optopt to val regardless of flag
+			 */
+			if (long_options[match].flag == NULL)
+				optopt = long_options[match].val;
+			else
+				optopt = 0;
+#ifdef GNU_COMPATIBLE
+			return (BADCH);
+#else
+			return (BADARG);
+#endif
+		}
+		if (long_options[match].has_arg == required_argument ||
+		    long_options[match].has_arg == optional_argument) {
+			if (has_equal)
+				optarg = (char *)has_equal;
+			else if (long_options[match].has_arg ==
+			    required_argument) {
+				/*
+				 * optional argument doesn't use next nargv
+				 */
+				optarg = nargv[optind++];
+			}
+		}
+		if ((long_options[match].has_arg == required_argument)
+		    && (optarg == NULL)) {
+			/*
+			 * Missing argument; leading ':' indicates no error
+			 * should be generated.
+			 */
+			if (PRINT_ERROR)
+				warnx(recargstring,
+#ifdef GNU_COMPATIBLE
+				    current_dash,
+#endif
+				    current_argv);
+			/*
+			 * XXX: GNU sets optopt to val regardless of flag
+			 */
+			if (long_options[match].flag == NULL)
+				optopt = long_options[match].val;
+			else
+				optopt = 0;
+			--optind;
+			return (BADARG);
+		}
+	} else {			/* unknown option */
+		if (short_too) {
+			--optind;
+			return (-1);
+		}
+		if (PRINT_ERROR)
+			warnx(illoptstring,
+#ifdef GNU_COMPATIBLE
+			      current_dash,
+#endif
+			      current_argv);
+		optopt = 0;
+		return (BADCH);
+	}
+	if (idx)
+		*idx = match;
+	if (long_options[match].flag) {
+		*long_options[match].flag = long_options[match].val;
+		return (0);
+	} else
+		return (long_options[match].val);
+}
+
+/*
+ * getopt_internal --
+ *	Parse argc/argv argument vector.  Called by user level routines.
+ */
+static int
+getopt_internal(int nargc, char * const *nargv, const char *options,
+	const struct option *long_options, int *idx, int flags)
+{
+	char *oli;				/* option letter list index */
+	int optchar, short_too;
+	int posixly_correct;	/* no static, can be changed on the fly */
+
+	if (options == NULL)
+		return (-1);
+
+	/*
+	 * Disable GNU extensions if POSIXLY_CORRECT is set or options
+	 * string begins with a '+'.
+	 */
+	posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
+#ifdef GNU_COMPATIBLE
+	if (*options == '-')
+		flags |= FLAG_ALLARGS;
+	else if (posixly_correct || *options == '+')
+		flags &= ~FLAG_PERMUTE;
+#else
+	if (posixly_correct || *options == '+')
+		flags &= ~FLAG_PERMUTE;
+	else if (*options == '-')
+		flags |= FLAG_ALLARGS;
+#endif
+	if (*options == '+' || *options == '-')
+		options++;
+
+	/*
+	 * XXX Some GNU programs (like cvs) set optind to 0 instead of
+	 * XXX using optreset.  Work around this braindamage.
+	 */
+	if (optind == 0)
+		optind = 1;
+
+	optarg = NULL;
+start:
+	if (!*place) {				/* update scanning pointer */
+		if (optind >= nargc) {          /* end of argument vector */
+			place = EMSG;
+			if (nonopt_end != -1) {
+				/* do permutation, if we have to */
+				permute_args(nonopt_start, nonopt_end,
+				    optind, nargv);
+				optind -= nonopt_end - nonopt_start;
+			}
+			else if (nonopt_start != -1) {
+				/*
+				 * If we skipped non-options, set optind
+				 * to the first of them.
+				 */
+				optind = nonopt_start;
+			}
+			nonopt_start = nonopt_end = -1;
+			return (-1);
+		}
+		if (*(place = nargv[optind]) != '-' ||
+#ifdef GNU_COMPATIBLE
+		    place[1] == '\0') {
+#else
+		    (place[1] == '\0' && strchr(options, '-') == NULL)) {
+#endif
+			place = EMSG;		/* found non-option */
+			if (flags & FLAG_ALLARGS) {
+				/*
+				 * GNU extension:
+				 * return non-option as argument to option 1
+				 */
+				optarg = nargv[optind++];
+				return (INORDER);
+			}
+			if (!(flags & FLAG_PERMUTE)) {
+				/*
+				 * If no permutation wanted, stop parsing
+				 * at first non-option.
+				 */
+				return (-1);
+			}
+			/* do permutation */
+			if (nonopt_start == -1)
+				nonopt_start = optind;
+			else if (nonopt_end != -1) {
+				permute_args(nonopt_start, nonopt_end,
+				    optind, nargv);
+				nonopt_start = optind -
+				    (nonopt_end - nonopt_start);
+				nonopt_end = -1;
+			}
+			optind++;
+			/* process next argument */
+			goto start;
+		}
+		if (nonopt_start != -1 && nonopt_end == -1)
+			nonopt_end = optind;
+
+		/*
+		 * If we have "-" do nothing, if "--" we are done.
+		 */
+		if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
+			optind++;
+			place = EMSG;
+			/*
+			 * We found an option (--), so if we skipped
+			 * non-options, we have to permute.
+			 */
+			if (nonopt_end != -1) {
+				permute_args(nonopt_start, nonopt_end,
+				    optind, nargv);
+				optind -= nonopt_end - nonopt_start;
+			}
+			nonopt_start = nonopt_end = -1;
+			return (-1);
+		}
+	}
+
+	/*
+	 * Check long options if:
+	 *  1) we were passed some
+	 *  2) the arg is not just "-"
+	 *  3) either the arg starts with -- we are getopt_long_only()
+	 */
+	if (long_options != NULL && place != nargv[optind] &&
+	    (*place == '-' || (flags & FLAG_LONGONLY))) {
+		short_too = 0;
+#ifdef GNU_COMPATIBLE
+		dash_prefix = D_PREFIX;
+#endif
+		if (*place == '-') {
+			place++;		/* --foo long option */
+#ifdef GNU_COMPATIBLE
+			dash_prefix = DD_PREFIX;
+#endif
+		} else if (*place != ':' && strchr(options, *place) != NULL)
+			short_too = 1;		/* could be short option too */
+
+		optchar = parse_long_options(nargv, options, long_options,
+		    idx, short_too, flags);
+		if (optchar != -1) {
+			place = EMSG;
+			return (optchar);
+		}
+	}
+
+	if ((optchar = (int)*place++) == (int)':' ||
+	    (optchar == (int)'-' && *place != '\0') ||
+	    (oli = strchr(options, optchar)) == NULL) {
+		/*
+		 * If the user specified "-" and  '-' isn't listed in
+		 * options, return -1 (non-option) as per POSIX.
+		 * Otherwise, it is an unknown option character (or ':').
+		 */
+		if (optchar == (int)'-' && *place == '\0')
+			return (-1);
+		if (!*place)
+			++optind;
+#ifdef GNU_COMPATIBLE
+		if (PRINT_ERROR)
+			warnx(posixly_correct ? illoptchar : gnuoptchar,
+			      optchar);
+#else
+		if (PRINT_ERROR)
+			warnx(illoptchar, optchar);
+#endif
+		optopt = optchar;
+		return (BADCH);
+	}
+	if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
+		/* -W long-option */
+		if (*place)			/* no space */
+			/* NOTHING */;
+		else if (++optind >= nargc) {	/* no arg */
+			place = EMSG;
+			if (PRINT_ERROR)
+				warnx(recargchar, optchar);
+			optopt = optchar;
+			return (BADARG);
+		} else				/* white space */
+			place = nargv[optind];
+#ifdef GNU_COMPATIBLE
+		dash_prefix = W_PREFIX;
+#endif
+		optchar = parse_long_options(nargv, options, long_options,
+		    idx, 0, flags);
+		place = EMSG;
+		return (optchar);
+	}
+	if (*++oli != ':') {			/* doesn't take argument */
+		if (!*place)
+			++optind;
+	} else {				/* takes (optional) argument */
+		optarg = NULL;
+		if (*place)			/* no white space */
+			optarg = (char *)place;
+		else if (oli[1] != ':') {	/* arg not optional */
+			if (++optind >= nargc) {	/* no arg */
+				place = EMSG;
+				if (PRINT_ERROR)
+					warnx(recargchar, optchar);
+				optopt = optchar;
+				return (BADARG);
+			} else
+				optarg = nargv[optind];
+		}
+		place = EMSG;
+		++optind;
+	}
+	/* dump back option letter */
+	return (optchar);
+}
+
+#ifdef REPLACE_GETOPT
+/*
+ * getopt --
+ *	Parse argc/argv argument vector.
+ *
+ * [eventually this will replace the BSD getopt]
+ */
+int
+getopt(int nargc, char * const *nargv, const char *options)
+{
+
+	/*
+	 * We don't pass FLAG_PERMUTE to getopt_internal() since
+	 * the BSD getopt(3) (unlike GNU) has never done this.
+	 *
+	 * Furthermore, since many privileged programs call getopt()
+	 * before dropping privileges it makes sense to keep things
+	 * as simple (and bug-free) as possible.
+	 */
+	return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
+}
+#endif /* REPLACE_GETOPT */
+
+/*
+ * getopt_long --
+ *	Parse argc/argv argument vector.
+ */
+int
+getopt_long(int nargc, char * const *nargv, const char *options,
+	const struct option *long_options, int *idx)
+{
+
+	return (getopt_internal(nargc, nargv, options, long_options, idx,
+	    FLAG_PERMUTE));
+}
+
+/*
+ * getopt_long_only --
+ *	Parse argc/argv argument vector.
+ */
+int
+getopt_long_only(int nargc, char * const *nargv, const char *options,
+	const struct option *long_options, int *idx)
+{
+
+	return (getopt_internal(nargc, nargv, options, long_options, idx,
+	    FLAG_PERMUTE|FLAG_LONGONLY));
+}
diff --git a/missing/inet_aton.c b/missing/inet_aton.c
index bc1461a..e85ad5f 100644
--- a/missing/inet_aton.c
+++ b/missing/inet_aton.c
@@ -36,13 +36,6 @@
  * SUCH DAMAGE.
  */
 
-/* $Id: inet_aton.c,v 1.6 2003-11-16 09:36:49 guy Exp $ */
-
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_aton.c,v 1.6 2003-11-16 09:36:49 guy Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
 /* Minimal implementation of inet_aton.
diff --git a/missing/inet_ntop.c b/missing/inet_ntop.c
index d17d592..8c6f7eb 100644
--- a/missing/inet_ntop.c
+++ b/missing/inet_ntop.c
@@ -36,17 +36,13 @@
  * SUCH DAMAGE.
  */
 
-/* $Id: inet_ntop.c,v 1.8 2005-02-09 02:25:46 guy Exp $ */
-
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_ntop.c,v 1.8 2005-02-09 02:25:46 guy Exp $";
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
-#include <errno.h>
 
 /*
  *
@@ -126,7 +122,9 @@
   for (i = 0; i < IN6ADDRSZ; i++)
       words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
 
+  best.len = 0;
   best.base = -1;
+  cur.len = 0;
   cur.base  = -1;
   for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
   {
@@ -180,7 +178,7 @@
       tp += strlen(tp);
       break;
     }
-    tp += sprintf (tp, "%lX", words[i]);
+    tp += sprintf (tp, "%lx", words[i]);
   }
 
   /* Was it a trailing run of 0x00's?
@@ -197,7 +195,6 @@
     return (NULL);
   }
   return strcpy (dst, tmp);
-  return (NULL);
 }
 #endif   /* INET6 */
 
diff --git a/missing/inet_pton.c b/missing/inet_pton.c
index 83f67e1..3466f42 100644
--- a/missing/inet_pton.c
+++ b/missing/inet_pton.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1999 Kungliga Tekniska H�gskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -17,7 +17,7 @@
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
  *      This product includes software developed by the Kungliga Tekniska
- *      Högskolan and its contributors.
+ *      H�gskolan and its contributors.
  *
  * 4. Neither the name of the Institute nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
@@ -36,17 +36,8 @@
  * SUCH DAMAGE.
  */
 
-/* $Id: inet_pton.c,v 1.6 2003-11-16 09:36:51 guy Exp $ */
-
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/missing/inet_pton.c,v 1.6 2003-11-16 09:36:51 guy Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
-#include <errno.h>
-
 int
 inet_pton(int af, const char *src, void *dst)
 {
diff --git a/missing/snprintf.c b/missing/snprintf.c
index 7932997..21d235d 100644
--- a/missing/snprintf.c
+++ b/missing/snprintf.c
@@ -31,17 +31,10 @@
  * SUCH DAMAGE.
  */
 
-/* $Id: snprintf.c,v 1.8 2003-11-16 09:36:51 guy Exp $ */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/missing/snprintf.c,v 1.8 2003-11-16 09:36:51 guy Exp $";
-#endif
-
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
diff --git a/missing/sockstorage.h b/missing/sockstorage.h
deleted file mode 100644
index e733328..0000000
--- a/missing/sockstorage.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-struct sockaddr_storage {
-#ifdef HAVE_SOCKADDR_SA_LEN
-	u_int8_t ss_len;
-	u_int8_t ss_family;
-	u_int8_t fill[126];
-#else
-	u_int8_t ss_family;
-	u_int8_t fill[127];
-#endif /* HAVE_SOCKADDR_SA_LEN */
-};
diff --git a/missing/strdup.c b/missing/strdup.c
index 079a8ff..9fca752 100644
--- a/missing/strdup.c
+++ b/missing/strdup.c
@@ -31,11 +31,6 @@
  * SUCH DAMAGE.
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/missing/strdup.c,v 1.1 2001-01-20 07:26:08 guy Exp $ (LBL)";
-#endif /* LIBC_SCCS and not lint */
-
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/missing/strlcat.c b/missing/strlcat.c
index a3d3fac..34f1af2 100644
--- a/missing/strlcat.c
+++ b/missing/strlcat.c
@@ -28,11 +28,6 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcat.c,v 1.5 2003-11-16 09:36:51 guy Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H 
 #include <config.h>
 #endif
@@ -41,6 +36,8 @@
 
 #include <string.h>
 
+#include "interface.h"
+
 /*
  * Appends src to string dst of size siz (unlike strncat, siz is the
  * full size of dst, not space left).  At most siz-1 characters
diff --git a/missing/strlcpy.c b/missing/strlcpy.c
index a92e4d1..b0671eb 100644
--- a/missing/strlcpy.c
+++ b/missing/strlcpy.c
@@ -28,11 +28,6 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/missing/strlcpy.c,v 1.5 2003-11-16 09:36:52 guy Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H 
 #include <config.h>
 #endif
@@ -41,6 +36,8 @@
 
 #include <string.h>
 
+#include "interface.h"
+
 /*
  * Copy src to string dst of size siz.  At most siz-1 characters
  * will be copied.  Always NUL terminates (unless siz == 0).
diff --git a/missing/strsep.c b/missing/strsep.c
index 0362d1f..a1e6b30 100644
--- a/missing/strsep.c
+++ b/missing/strsep.c
@@ -31,11 +31,6 @@
  * SUCH DAMAGE.
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/missing/strsep.c,v 1.3 2003-03-25 08:33:48 guy Exp $ (LBL)";
-#endif /* LIBC_SCCS and not lint */
-
 #ifdef HAVE_CONFIG_H 
 #include <config.h>
 #endif
@@ -44,6 +39,8 @@
 
 #include <string.h>
 
+#include "interface.h"
+
 /*
  * Get next token from string *stringp, where tokens are possibly-empty
  * strings separated by characters from delim.
diff --git a/mkdep b/mkdep
index 3062e64..1486b18 100755
--- a/mkdep
+++ b/mkdep
@@ -13,9 +13,6 @@
 #	@(#)mkdep.sh	5.11 (Berkeley) 5/5/88
 #
 
-PATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/bin
-export PATH
-
 MAKE=Makefile			# default makefile name is "Makefile"
 CC=cc				# default C compiler is "cc"
 DEPENDENCY_CFLAG=-M		# default dependency-generation flag is -M
diff --git a/mpls.h b/mpls.h
index ae1c97e..03cb4bf 100644
--- a/mpls.h
+++ b/mpls.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/mpls.h,v 1.1 2004-06-14 14:47:58 hannes Exp $ (LBL)
+/*
  * Copyright (C) 2001 WIDE Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff --git a/mptcp.h b/mptcp.h
deleted file mode 100644
index 4ff552e..0000000
--- a/mptcp.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Copyright (c) 2012
- *
- * Gregory Detal <gregory.detal@uclouvain.be>
- * Christoph Paasch <christoph.paasch@uclouvain.be>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. 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.
- *
- * 3. Neither the name of the University nor of the Laboratory may be used
- *    to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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.
- */
-
-#define MPTCP_SUB_CAPABLE       0x0
-#define MPTCP_SUB_JOIN          0x1
-#define MPTCP_SUB_DSS           0x2
-#define MPTCP_SUB_ADD_ADDR      0x3
-#define MPTCP_SUB_REMOVE_ADDR   0x4
-#define MPTCP_SUB_PRIO          0x5
-#define MPTCP_SUB_FAIL          0x6
-#define MPTCP_SUB_FCLOSE        0x7
-
-
-struct mptcp_option {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub_etc;        /* subtype upper 4 bits, other stuff lower 4 bits */
-};
-
-#define MPTCP_OPT_SUBTYPE(sub_etc)      (((sub_etc) >> 4) & 0xF)
-
-struct mp_capable {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub_ver;
-        u_int8_t        flags;
-        u_int8_t        sender_key[8];
-        u_int8_t        receiver_key[8];
-};
-
-#define MP_CAPABLE_OPT_VERSION(sub_ver) (((sub_ver) >> 0) & 0xF)
-#define MP_CAPABLE_C                    0x80
-#define MP_CAPABLE_S                    0x01
-
-struct mp_join {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub_b;
-        u_int8_t        addr_id;
-        union {
-                struct {
-                        u_int8_t         token[4];
-                        u_int8_t         nonce[4];
-                } syn;
-                struct {
-                        u_int8_t         mac[8];
-                        u_int8_t         nonce[4];
-                } synack;
-                struct {
-                        u_int8_t        mac[20];
-                } ack;
-        } u;
-};
-
-#define MP_JOIN_B                       0x01
-
-struct mp_dss {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub;
-        u_int8_t        flags;
-};
-
-#define MP_DSS_F                        0x10
-#define MP_DSS_m                        0x08
-#define MP_DSS_M                        0x04
-#define MP_DSS_a                        0x02
-#define MP_DSS_A                        0x01
-
-struct mp_add_addr {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub_ipver;
-        u_int8_t        addr_id;
-        union {
-                struct {
-                        u_int8_t         addr[4];
-                        u_int8_t         port[2];
-                } v4;
-                struct {
-                        u_int8_t         addr[16];
-                        u_int8_t         port[2];
-                } v6;
-        } u;
-};
-
-#define MP_ADD_ADDR_IPVER(sub_ipver)    (((sub_ipver) >> 0) & 0xF)
-
-struct mp_remove_addr {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub;
-        /* list of addr_id */
-        u_int8_t        addrs_id;
-};
-
-struct mp_fail {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub;
-        u_int8_t        resv;
-        u_int8_t        data_seq[8];
-};
-
-struct mp_close {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub;
-        u_int8_t        rsv;
-        u_int8_t        key[8];
-};
-
-struct mp_prio {
-        u_int8_t        kind;
-        u_int8_t        len;
-        u_int8_t        sub_b;
-        u_int8_t        addr_id;
-};
-
-#define MP_PRIO_B                       0x01
diff --git a/nameser.h b/nameser.h
index f441f3e..11e71ef 100644
--- a/nameser.h
+++ b/nameser.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.16 2006-11-10 03:18:21 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1983, 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -225,13 +224,13 @@
  * Structure for query header.
  */
 typedef struct {
-	u_int16_t id;		/* query identification number */
-	u_int8_t  flags1;	/* first byte of flags */
-	u_int8_t  flags2;	/* second byte of flags */
-	u_int16_t qdcount;	/* number of question entries */
-	u_int16_t ancount;	/* number of answer entries */
-	u_int16_t nscount;	/* number of authority entries */
-	u_int16_t arcount;	/* number of resource entries */
+	uint16_t id;		/* query identification number */
+	uint8_t  flags1;	/* first byte of flags */
+	uint8_t  flags2;	/* second byte of flags */
+	uint16_t qdcount;	/* number of question entries */
+	uint16_t ancount;	/* number of answer entries */
+	uint16_t nscount;	/* number of authority entries */
+	uint16_t arcount;	/* number of resource entries */
 } HEADER;
 
 /*
@@ -262,36 +261,36 @@
 	int16_t	r_zone;			/* zone number */
 	int16_t	r_class;		/* class number */
 	int16_t	r_type;			/* type number */
-	u_int32_t	r_ttl;			/* time to live */
+	uint32_t	r_ttl;			/* time to live */
 	int	r_size;			/* size of data area */
 	char	*r_data;		/* pointer to data */
 };
 
 /*
  * Inline versions of get/put short/long.  Pointer is advanced.
- * We also assume that a "u_int16_t" holds 2 "chars"
- * and that a "u_int32_t" holds 4 "chars".
+ * We also assume that a "uint16_t" holds 2 "chars"
+ * and that a "uint32_t" holds 4 "chars".
  *
  * These macros demonstrate the property of C whereby it can be
  * portable or it can be elegant but never both.
  */
 #define GETSHORT(s, cp) { \
 	register u_char *t_cp = (u_char *)(cp); \
-	(s) = ((u_int16_t)t_cp[0] << 8) | (u_int16_t)t_cp[1]; \
+	(s) = ((uint16_t)t_cp[0] << 8) | (uint16_t)t_cp[1]; \
 	(cp) += 2; \
 }
 
 #define GETLONG(l, cp) { \
 	register u_char *t_cp = (u_char *)(cp); \
-	(l) = (((u_int32_t)t_cp[0]) << 24) \
-	    | (((u_int32_t)t_cp[1]) << 16) \
-	    | (((u_int32_t)t_cp[2]) << 8) \
-	    | (((u_int32_t)t_cp[3])); \
+	(l) = (((uint32_t)t_cp[0]) << 24) \
+	    | (((uint32_t)t_cp[1]) << 16) \
+	    | (((uint32_t)t_cp[2]) << 8) \
+	    | (((uint32_t)t_cp[3])); \
 	(cp) += 4; \
 }
 
 #define PUTSHORT(s, cp) { \
-	register u_int16_t t_s = (u_int16_t)(s); \
+	register uint16_t t_s = (uint16_t)(s); \
 	register u_char *t_cp = (u_char *)(cp); \
 	*t_cp++ = t_s >> 8; \
 	*t_cp   = t_s; \
@@ -303,7 +302,7 @@
  * were depending on this "feature", you will lose.
  */
 #define PUTLONG(l, cp) { \
-	register u_int32_t t_l = (u_int32_t)(l); \
+	register uint32_t t_l = (uint32_t)(l); \
 	register u_char *t_cp = (u_char *)(cp); \
 	*t_cp++ = t_l >> 24; \
 	*t_cp++ = t_l >> 16; \
diff --git a/netbios.h b/netbios.h
deleted file mode 100644
index d3e2725..0000000
--- a/netbios.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * NETBIOS protocol formats
- *
- * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002-12-11 07:13:55 guy Exp $
- */
-
-struct p8022Hdr {
-    u_char	dsap;
-    u_char	ssap;
-    u_char	flags;
-};
-
-#define	p8022Size	3		/* min 802.2 header size */
-
-#define UI		0x03		/* 802.2 flags */
-
diff --git a/netdissect.h b/netdissect.h
index 5f31cfa..d507f58 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -20,8 +20,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.27 2008-08-16 11:36:20 hannes Exp $ (LBL)
  */
 
 #ifndef netdissect_h
@@ -40,6 +38,8 @@
 
 #include <stdarg.h>
 
+#include "ip.h" /* struct ip for nextproto4_cksum() */
+
 #if !defined(HAVE_SNPRINTF)
 int snprintf (char *str, size_t sz, const char *format, ...)
 #ifdef __ATTRIBUTE___FORMAT_OK
@@ -72,18 +72,18 @@
 #endif
 
 struct tok {
-	int v;			/* value */
+	u_int v;		/* value */
 	const char *s;		/* string */
 };
 
 #define TOKBUFSIZE 128
-extern const char *tok2strbuf(const struct tok *, const char *, int,
+extern const char *tok2strbuf(const struct tok *, const char *, u_int,
 			      char *buf, size_t bufsize);
 
 /* tok2str is deprecated */
-extern const char *tok2str(const struct tok *, const char *, int);
-extern char *bittok2str(const struct tok *, const char *, int);
-extern char *bittok2str_nosep(const struct tok *, const char *, int);
+extern const char *tok2str(const struct tok *, const char *, u_int);
+extern char *bittok2str(const struct tok *, const char *, u_int);
+extern char *bittok2str_nosep(const struct tok *, const char *, u_int);
 
 
 typedef struct netdissect_options netdissect_options;
@@ -115,6 +115,7 @@
   int ndo_dlt;                  /* if != -1, ask libpcap for the DLT it names*/
   int ndo_jflag;                /* packet time stamp source */
   int ndo_pflag;                /* don't go promiscuous */
+  int ndo_immediate;            /* use immediate mode */
 
   int ndo_Cflag;                /* rotate dump files after this many bytes */
   int ndo_Cflag_count;      /* Keep track of which file number we're writing */
@@ -124,7 +125,9 @@
   int ndo_Wflag;          /* recycle output files after this number of files */
   int ndo_WflagChars;
   int ndo_Hflag;		/* dissect 802.11s draft mesh standard */
+  int ndo_packet_number;	/* print a packet number in the beginning of line */
   int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
+  int ndo_tstamp_precision;   /* requested time stamp precision */
   const char *ndo_dltname;
 
   char *ndo_espsecret;
@@ -154,14 +157,18 @@
   /* pointer to void function to output stuff */
   void (*ndo_default_print)(netdissect_options *,
   		      register const u_char *bp, register u_int length);
+
+  /* pointer to function to print ^T output */
   void (*ndo_info)(netdissect_options *, int verbose);
 
+  /* pointer to function to do regular output */
   int  (*ndo_printf)(netdissect_options *,
 		     const char *fmt, ...)
 #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
 		     __attribute__ ((format (printf, 2, 3)))
 #endif
 		     ;
+  /* pointer to function to output errors */
   void (*ndo_error)(netdissect_options *,
 		    const char *fmt, ...)
 #ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
@@ -171,6 +178,7 @@
 		     __attribute__ ((format (printf, 2, 3)))
 #endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
 		     ;
+  /* pointer to function to output warnings */
   void (*ndo_warning)(netdissect_options *,
 		      const char *fmt, ...)
 #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
@@ -207,12 +215,26 @@
  * Maximum snapshot length.  This should be enough to capture the full
  * packet on most network interfaces.
  *
- * XXX - could it be larger?  If so, should it?  Some applications might
- * use the snapshot length in a savefile header to control the size of
- * the buffer they allocate, so a size of, say, 2^31-1 might not work
- * well.
+ *
+ * Somewhat arbitrary, but chosen to be:
+ *
+ *    1) big enough for maximum-size Linux loopback packets (65549)
+ *       and some USB packets captured with USBPcap:
+ *
+ *           http://desowin.org/usbpcap/
+ *
+ *       (> 131072, < 262144)
+ *
+ * and
+ *
+ *    2) small enough not to cause attempts to allocate huge amounts of
+ *       memory; some applications might use the snapshot length in a
+ *       savefile header to control the size of the buffer they allocate,
+ *       so a size of, say, 2^31-1 might not work well.
+ *
+ * XXX - does it need to be bigger still?
  */
-#define MAXIMUM_SNAPLEN	65535
+#define MAXIMUM_SNAPLEN	262144
 
 /*
  * The default snapshot length is the maximum.
@@ -236,9 +258,22 @@
  * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
  *
  * The check is for <= rather than < because "l" might be 0.
+ *
+ * We cast the pointers to uintptr_t to make sure that the compiler
+ * doesn't optimize away any of these tests (which it is allowed to
+ * do, as adding an integer to, or subtracting an integer from, a
+ * pointer assumes that the pointer is a pointer to an element of an
+ * array and that the result of the addition or subtraction yields a
+ * pointer to another member of the array, so that, for example, if
+ * you subtract a positive integer from a pointer, the result is
+ * guaranteed to be less than the original pointer value). See
+ *
+ *	http://www.kb.cert.org/vuls/id/162289
  */
-#define ND_TTEST2(var, l) (ndo->ndo_snapend - (l) <= ndo->ndo_snapend && \
-			(const u_char *)&(var) <= ndo->ndo_snapend - (l))
+#define ND_TTEST2(var, l) \
+  ((l) >= 0 && \
+	((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
+         (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
 
 /* True if "var" was captured */
 #define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
@@ -252,17 +287,20 @@
 #define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
 #define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
 
-#if 0
-extern void ts_print(netdissect_options *ipdo,
-		     const struct timeval *);
-extern void relts_print(int);
-#endif
+extern void ts_print(netdissect_options *, const struct timeval *);
+extern void relts_print(netdissect_options *, int);
 
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
-extern const char *tok2str(const struct tok *, const char *, int);
+extern int fn_print(netdissect_options *, const u_char *, const u_char *);
+extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
 
-extern void wrapup(int);
+/*
+ * Flags for txtproto_print().
+ */
+#define RESP_CODE_SECOND_TOKEN	0x00000001	/* response code is second token in response line */
+
+extern void txtproto_print(netdissect_options *, const u_char *, u_int,
+    const char *, const char **, u_int);
 
 #if 0
 extern char *read_infile(netdissect_options *, char *);
@@ -280,8 +318,8 @@
 #define ND_ISGRAPH(c)	((c) > 0x20 && (c) <= 0x7E)
 #define ND_TOASCII(c)	((c) & 0x7F)
 
-extern void safeputchar(int);
-extern void safeputs(const char *, int);
+extern void safeputchar(netdissect_options *, const u_char);
+extern void safeputs(netdissect_options *, const u_char *, const u_int);
 
 #ifdef LBL_ALIGN
 /*
@@ -312,8 +350,6 @@
 	(((n) != 1) ? "s" : "")
 
 #if 0
-extern const char *isonsap_string(netdissect_options *, const u_char *);
-extern const char *protoid_string(netdissect_options *, const u_char *);
 extern const char *dnname_string(netdissect_options *, u_short);
 extern const char *dnnum_string(netdissect_options *, u_short);
 #endif
@@ -322,6 +358,8 @@
 
 #include <pcap.h>
 
+extern char *q922_string(netdissect_options *ndo, const u_char *, u_int);
+
 typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
 				const struct pcap_pkthdr *, const u_char *);
 typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
@@ -331,7 +369,7 @@
 
 extern void eap_print(netdissect_options *,const u_char *, u_int);
 extern int esp_print(netdissect_options *,
-		     register const u_char *bp, int len, register const u_char *bp2,
+		     const u_char *bp, const int length, const u_char *bp2,
 		     int *nhdr, int *padlen);
 extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
 extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
@@ -347,6 +385,8 @@
 			   const u_char *bp, u_int length, u_int nh,
 			   const u_char *bp2);
 extern void rrcp_print(netdissect_options *,const u_char *, u_int);
+extern void loopback_print(netdissect_options *, const u_char *, const u_int);
+extern void carp_print(netdissect_options *, const u_char *, u_int, int);
 
 extern void ether_print(netdissect_options *,
                         const u_char *, u_int, u_int,
@@ -364,193 +404,219 @@
 extern int ethertype_print(netdissect_options *,u_short, const u_char *,
 			     u_int, u_int);
 
+extern int print_unknown_data(netdissect_options *,const u_char *, const char *,int);
+extern void ascii_print(netdissect_options *, const u_char *, u_int);
+extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp,
+				  u_int, u_int);
+extern void hex_print(netdissect_options *,const char *ident, const u_char *cp,u_int);
+extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
+extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
+
+extern int ah_print(netdissect_options *, register const u_char *);
+extern void beep_print(netdissect_options *, const u_char *, u_int);
+extern void dtp_print(netdissect_options *, const u_char *, u_int);
+extern u_int cip_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern int ipcomp_print(netdissect_options *, register const u_char *, int *);
+extern u_int ipfc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void udld_print(netdissect_options *, const u_char *, u_int);
+extern void hsrp_print(netdissect_options *, const u_char *, u_int);
+extern void igrp_print(netdissect_options *, const u_char *, u_int);
+extern void msdp_print(netdissect_options *, const u_char *, u_int);
+extern u_int null_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void mobile_print(netdissect_options *, const u_char *, u_int);
+extern u_int ap1394_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int bt_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int lane_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void otv_print(netdissect_options *, const u_char *, u_int);
+extern void ahcp_print(netdissect_options *, const u_char *, const u_int);
+extern void vxlan_print(netdissect_options *, const u_char *, u_int);
+extern u_int arcnet_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int arcnet_linux_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void gre_print(netdissect_options *, const u_char *, u_int);
+extern int vjc_print(netdissect_options *, register const char *, u_short);
+extern void ipN_print(netdissect_options *, const u_char *, u_int);
+extern u_int raw_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_48_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_64_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int symantec_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int chdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
+extern void zmtp1_print(netdissect_options *, const u_char *, u_int);
+extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
+extern void ipx_print(netdissect_options *, const u_char *, u_int);
+extern void mpls_print(netdissect_options *, const u_char *, u_int);
+extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
+extern u_int pppoe_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern u_int pflog_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
+extern void zephyr_print(netdissect_options *, const u_char *, int);
+extern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void mpcp_print(netdissect_options *, const u_char *, u_int);
+extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
+extern u_int sll_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *);
+extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, u_int);
+extern void eigrp_print(netdissect_options *, const u_char *, u_int);
+extern void stp_print(netdissect_options *, const u_char *, u_int);
+extern void l2tp_print(netdissect_options *, const u_char *, u_int);
+extern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void openflow_print(netdissect_options *, const u_char *, const u_int);
+extern void telnet_print(netdissect_options *, const u_char *, u_int);
+extern void slow_print(netdissect_options *, const u_char *, u_int);
+extern void radius_print(netdissect_options *, const u_char *, u_int);
+extern void lmp_print(netdissect_options *, const u_char *, u_int);
+extern u_int fr_print(netdissect_options *, register const u_char *, u_int);
+extern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
+extern u_int fr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int mfr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void q933_print(netdissect_options *, const u_char *, u_int);
+extern void igmp_print(netdissect_options *, const u_char *, u_int);
+extern void rip_print(netdissect_options *, const u_char *, u_int);
+extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
+extern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
+extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void pptp_print(netdissect_options *, const u_char *);
+extern void ldp_print(netdissect_options *, const u_char *, u_int);
+extern void wb_print(netdissect_options *, const void *, u_int);
+extern int oam_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
+extern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void vtp_print(netdissect_options *, const u_char *, u_int);
+extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
+extern void ntp_print(netdissect_options *, const u_char *, u_int);
+extern void cnfp_print(netdissect_options *, const u_char *);
+extern void dvmrp_print(netdissect_options *, const u_char *, u_int);
+extern void egp_print(netdissect_options *, const u_char *, u_int);
+extern u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int sl_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int sl_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void tftp_print(netdissect_options *, const u_char *, u_int);
+extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void pimv1_print(netdissect_options *, const u_char *, u_int);
+extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
+extern void pim_print(netdissect_options *, const u_char *, u_int, u_int);
+extern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *);
+extern void ns_print(netdissect_options *, const u_char *, u_int, int);
+extern void bootp_print(netdissect_options *, const u_char *, u_int);
+extern void sflow_print(netdissect_options *, const u_char *, u_int);
+extern void aodv_print(netdissect_options *, const u_char *, u_int, int);
+extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
+extern void bgp_print(netdissect_options *, const u_char *, int);
+extern void olsr_print(netdissect_options *, const u_char *, u_int, int);
+extern void forces_print(netdissect_options *, const u_char *, u_int);
+extern void lspping_print(netdissect_options *, const u_char *, u_int);
+extern void isoclns_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void krb_print(netdissect_options *, const u_char *);
+extern void cdp_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void atalk_print(netdissect_options *, const u_char *, u_int);
+extern u_int ltalk_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int llap_print(netdissect_options *, const u_char *, u_int);
+extern void aarp_print(netdissect_options *, const u_char *, u_int);
+extern u_int juniper_atm1_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_atm2_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_mfr_print(netdissect_options *, const struct pcap_pkthdr *, register const u_char *);
+extern u_int juniper_mlfr_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_mlppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_pppoe_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_pppoe_atm_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_ggsn_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_es_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_monitor_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_services_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_ether_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_ppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_frelay_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int juniper_chdlc_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void snmp_print(netdissect_options *, const u_char *, u_int);
+extern void rx_print(netdissect_options *, register const u_char *, int, int, int, u_char *);
+extern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void sip_print(netdissect_options *, const u_char *, u_int);
+extern void syslog_print(netdissect_options *, const u_char *, u_int);
+extern void lwres_print(netdissect_options *, const u_char *, u_int);
+extern void cfm_print(netdissect_options *, const u_char *, u_int);
+extern void nbt_tcp_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp137_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp138_print(netdissect_options *, const u_char *, int);
+extern void smb_tcp_print(netdissect_options *, const u_char *, int);
+extern void netbeui_print(netdissect_options *, u_short, const u_char *, int);
+extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
+extern void print_data(netdissect_options *, const unsigned char *, int);
+extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
+extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
+extern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
+extern u_int ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void lldp_print(netdissect_options *, const u_char *, u_int);
+extern void rsvp_print(netdissect_options *, const u_char *, u_int);
+extern void timed_print(netdissect_options *, const u_char *);
+extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
+extern void aoe_print(netdissect_options *, const u_char *, const u_int);
+extern void ftp_print(netdissect_options *, const u_char *, u_int);
+extern void http_print(netdissect_options *, const u_char *, u_int);
+extern void rtsp_print(netdissect_options *, const u_char *, u_int);
+extern void smtp_print(netdissect_options *, const u_char *, u_int);
+extern void geneve_print(netdissect_options *, const u_char *, u_int);
+
 /* stuff that has not yet been rototiled */
+
 #if 0
 extern void ascii_print(netdissect_options *,u_int);
-extern void hex_and_ascii_print_with_offset(netdissect_options *,const char *,
-				    u_int, u_int);
-extern void hex_and_ascii_print(netdissect_options *,const char *, u_int);
-extern void hex_print_with_offset(netdissect_options *,const char *,
-				  u_int, u_int);
-extern void hex_print(netdissect_options *,const char *, u_int);
-extern void telnet_print(netdissect_options *,const u_char *, u_int);
-extern int llc_print(netdissect_options *,
-		     const u_char *, u_int, u_int, const u_char *,
-		     const u_char *, u_short *);
-extern void aarp_print(netdissect_options *,const u_char *, u_int);
-extern void atalk_print(netdissect_options *,const u_char *, u_int);
-extern void atm_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void bootp_print(netdissect_options *,const u_char *,
-			u_int, u_short, u_short);
-extern void bgp_print(netdissect_options *,const u_char *, int);
-extern void bxxp_print(netdissect_options *,const u_char *, u_int);
-extern void chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
-			   register const u_char *p);
-extern void chdlc_print(netdissect_options *ndo,
-			register const u_char *p, u_int length, u_int caplen);
-extern void cisco_autorp_print(netdissect_options *,
-			       const u_char *, u_int);
-extern void cnfp_print(netdissect_options *,const u_char *cp,
-		       u_int len, const u_char *bp);
-extern void decnet_print(netdissect_options *,const u_char *,
-			 u_int, u_int);
 extern void default_print(netdissect_options *,const u_char *, u_int);
-extern void dvmrp_print(netdissect_options *,const u_char *, u_int);
-extern void egp_print(netdissect_options *,const u_char *, u_int,
-		      const u_char *);
-
-extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *);
-extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-
-extern void gre_print(netdissect_options *,const u_char *, u_int);
-extern void icmp_print(netdissect_options *,const u_char *, u_int,
-		       const u_char *);
-extern void hsrp_print(netdissect_options *ndo,
-		       register const u_char *bp, register u_int len);
-extern void ieee802_11_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void igmp_print(netdissect_options *,
-		       register const u_char *, u_int);
-extern void igrp_print(netdissect_options *,const u_char *, u_int,
-		       const u_char *);
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
-extern void ipN_print(netdissect_options *,const u_char *, u_int);
-extern void ipx_print(netdissect_options *,const u_char *, u_int);
-extern void isoclns_print(netdissect_options *,const u_char *,
-			  u_int, u_int, const u_char *,	const u_char *);
-extern void krb_print(netdissect_options *,const u_char *, u_int);
-extern void llap_print(netdissect_options *,const u_char *, u_int);
-extern const char *linkaddr_string(netdissect_options *ndo,
-				   const u_char *ep, const unsigned int len);
-extern void ltalk_if_print(netdissect_options *ndo,
-			   u_char *user, const struct pcap_pkthdr *h,
-			   const u_char *p);
-extern void mpls_print(netdissect_options *ndo,
-		       const u_char *bp, u_int length);
-extern void msdp_print(netdissect_options *ndo,
-		       const unsigned char *sp, u_int length);
-extern void nfsreply_print(netdissect_options *,const u_char *,
-			   u_int, const u_char *);
-extern void nfsreq_print(netdissect_options *,const u_char *,
-			 u_int, const u_char *);
-extern void ns_print(netdissect_options *,const u_char *, u_int);
-extern void ntp_print(netdissect_options *,const u_char *, u_int);
-extern void null_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void ospf_print(netdissect_options *,const u_char *,
-		       u_int, const u_char *);
-extern void pimv1_print(netdissect_options *,const u_char *, u_int);
-extern void mobile_print(netdissect_options *,const u_char *, u_int);
-extern void pim_print(netdissect_options *,const u_char *, u_int, u_int);
-extern void pppoe_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void pppoe_print(netdissect_options *,const u_char *, u_int);
-extern void ppp_print(netdissect_options *,
-		      register const u_char *, u_int);
-
-extern void ppp_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void ppp_hdlc_if_print(u_char *,
-			      const struct pcap_pkthdr *, const u_char *);
-extern void ppp_bsdos_if_print(u_char *,
-			       const struct pcap_pkthdr *, const u_char *);
-
-extern int vjc_print(netdissect_options *,register const char *,
-		     register u_int, u_short);
-
-extern void raw_if_print(u_char *,
-			 const struct pcap_pkthdr *, const u_char *);
-
-extern void rip_print(netdissect_options *,const u_char *, u_int);
-extern void rpki_rtr_print(netdissect_options *,const u_char *, u_int);
-
-extern void sctp_print(netdissect_options *ndo,
-		       const u_char *bp, const u_char *bp2,
-		       u_int sctpPacketLength);
-
-extern void sl_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-
-extern void lane_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void cip_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void sl_bsdos_if_print(u_char *,
-			      const struct pcap_pkthdr *, const u_char *);
-extern void sll_if_print(u_char *,
-			 const struct pcap_pkthdr *, const u_char *);
-
-extern void snmp_print(netdissect_options *,const u_char *, u_int);
-extern void sunrpcrequest_print(netdissect_options *,const u_char *,
-				u_int, const u_char *);
-extern void tcp_print(netdissect_options *,const u_char *, u_int,
-		      const u_char *, int);
-extern void tftp_print(netdissect_options *,const u_char *, u_int);
-extern void timed_print(netdissect_options *,const u_char *, u_int);
-extern void udp_print(netdissect_options *,const u_char *, u_int,
-		      const u_char *, int);
-extern void wb_print(netdissect_options *,const void *, u_int);
-extern int ah_print(netdissect_options *,register const u_char *,
-		    register const u_char *);
-extern void esp_print_decodesecret(netdissect_options *ndo);
-extern int ipcomp_print(netdissect_options *,register const u_char *,
-			register const u_char *, int *);
-extern void rx_print(netdissect_options *,register const u_char *,
-		     int, int, int, u_char *);
-extern void netbeui_print(netdissect_options *,u_short,
-			  const u_char *, int);
-extern void ipx_netbios_print(netdissect_options *,const u_char *, u_int);
-extern void nbt_tcp_print(netdissect_options *,const u_char *, int);
-extern void nbt_udp137_print(netdissect_options *,
-			     const u_char *data, int);
-extern void nbt_udp138_print(netdissect_options *,
-			     const u_char *data, int);
 extern char *smb_errstr(netdissect_options *,int, int);
-extern const char *nt_errstr(netdissect_options *, u_int32_t);
-extern void print_data(netdissect_options *,const unsigned char *, int);
-extern void l2tp_print(netdissect_options *,const u_char *, u_int);
-extern void lcp_print(netdissect_options *,const u_char *, u_int);
-extern void vrrp_print(netdissect_options *,const u_char *bp,
-		       u_int len, int ttl);
-extern void carp_print(netdissect_options *,const u_char *bp,
-		       u_int len, int ttl);
-extern void cdp_print(netdissect_options *,const u_char *,
-		      u_int, u_int, const u_char *, const u_char *);
-extern void stp_print(netdissect_options *,const u_char *p, u_int length);
-extern void radius_print(netdissect_options *,const u_char *, u_int);
-extern void lwres_print(netdissect_options *,const u_char *, u_int);
-extern void pptp_print(netdissect_options *,const u_char *, u_int);
+extern const char *nt_errstr(netdissect_options *, uint32_t);
 #endif
 
 extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
 extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
 extern u_int nflog_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
+extern u_int pktap_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_radio_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 
-#ifdef INET6
 extern void ip6_print(netdissect_options *,const u_char *, u_int);
-#if 0
-extern void ip6_opt_print(netdissect_options *,const u_char *, int);
-extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
-extern int hbhopt_print(netdissect_options *,const u_char *);
-extern int dstopt_print(netdissect_options *,const u_char *);
-extern int frag6_print(netdissect_options *,const u_char *,
-		       const u_char *);
-extern void icmp6_print(netdissect_options *,const u_char *,
-			const u_char *);
-extern void ripng_print(netdissect_options *,const u_char *, int);
-extern int rt6_print(netdissect_options *,const u_char *, const u_char *);
-extern void ospf6_print(netdissect_options *,const u_char *, u_int);
-extern void dhcp6_print(netdissect_options *,const u_char *,
-			u_int, u_int16_t, u_int16_t);
-
-extern void zephyr_print(netdissect_options * ndo,
-			 const u_char *cp, int length);
-#endif /* 0 */
-
+#ifdef INET6
+extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
+extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
+extern int hbhopt_print(netdissect_options *, const u_char *);
+extern int dstopt_print(netdissect_options *, const u_char *);
+extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
+extern int mobility_print(netdissect_options *, const u_char *, const u_char *);
+extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
+extern void ospf6_print(netdissect_options *, const u_char *, u_int);
+extern void babel_print(netdissect_options *, const u_char *, u_int);
 #endif /*INET6*/
 
 #if 0
 struct cksum_vec {
-	const u_int8_t	*ptr;
+	const uint8_t	*ptr;
 	int		len;
 };
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
+extern uint16_t in_cksum(const struct cksum_vec *, int);
+extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
+#endif
+extern int nextproto4_cksum(netdissect_options *ndo, const struct ip *, const uint8_t *, u_int, u_int, u_int);
+extern int decode_prefix4(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
+#ifdef INET6
+extern int decode_prefix6(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
 #endif
 
 extern void esp_print_decodesecret(netdissect_options *ndo);
diff --git a/nfs.h b/nfs.h
index a5b5025..da7bc50 100644
--- a/nfs.h
+++ b/nfs.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.9 2007-11-18 03:24:38 guy Exp $ (LBL) */
 /*	NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp 	*/
 
 /*
@@ -239,11 +238,11 @@
 		txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
 				MAKEIMODE((t), (m)))
 #define vtonfsv3_mode(m)	txdr_unsigned((m) & 07777)
-#define	nfstov_mode(a)		(fxdr_unsigned(u_int16_t, (a))&07777)
+#define	nfstov_mode(a)		(fxdr_unsigned(uint16_t, (a))&07777)
 #define	vtonfsv2_type(a)	txdr_unsigned(nfsv2_type[((int32_t)(a))])
 #define	vtonfsv3_type(a)	txdr_unsigned(nfsv3_type[((int32_t)(a))])
-#define	nfsv2tov_type(a)	nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
-#define	nfsv3tov_type(a)	nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
+#define	nfsv2tov_type(a)	nv2tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
+#define	nfsv3tov_type(a)	nv3tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
 
 /* File types */
 typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
@@ -267,14 +266,14 @@
 typedef union nfsfh nfsfh_t;
 
 struct nfsv2_time {
-	u_int32_t nfsv2_sec;
-	u_int32_t nfsv2_usec;
+	uint32_t nfsv2_sec;
+	uint32_t nfsv2_usec;
 };
 typedef struct nfsv2_time	nfstime2;
 
 struct nfsv3_time {
-	u_int32_t nfsv3_sec;
-	u_int32_t nfsv3_nsec;
+	uint32_t nfsv3_sec;
+	uint32_t nfsv3_nsec;
 };
 typedef struct nfsv3_time	nfstime3;
 
@@ -283,7 +282,7 @@
  * protocol and to facilitate xdr conversion.
  */
 struct nfs_uquad {
-	u_int32_t nfsuquad[2];
+	uint32_t nfsuquad[2];
 };
 typedef	struct nfs_uquad	nfsuint64;
 
@@ -291,8 +290,8 @@
  * NFS Version 3 special file number.
  */
 struct nfsv3_spec {
-	u_int32_t specdata1;
-	u_int32_t specdata2;
+	uint32_t specdata1;
+	uint32_t specdata2;
 };
 typedef	struct nfsv3_spec	nfsv3spec;
 
@@ -306,19 +305,19 @@
  *     NFSX_FATTR(v3) macro.
  */
 struct nfs_fattr {
-	u_int32_t fa_type;
-	u_int32_t fa_mode;
-	u_int32_t fa_nlink;
-	u_int32_t fa_uid;
-	u_int32_t fa_gid;
+	uint32_t fa_type;
+	uint32_t fa_mode;
+	uint32_t fa_nlink;
+	uint32_t fa_uid;
+	uint32_t fa_gid;
 	union {
 		struct {
-			u_int32_t nfsv2fa_size;
-			u_int32_t nfsv2fa_blocksize;
-			u_int32_t nfsv2fa_rdev;
-			u_int32_t nfsv2fa_blocks;
-			u_int32_t nfsv2fa_fsid;
-			u_int32_t nfsv2fa_fileid;
+			uint32_t nfsv2fa_size;
+			uint32_t nfsv2fa_blocksize;
+			uint32_t nfsv2fa_rdev;
+			uint32_t nfsv2fa_blocks;
+			uint32_t nfsv2fa_fsid;
+			uint32_t nfsv2fa_fileid;
 			nfstime2  nfsv2fa_atime;
 			nfstime2  nfsv2fa_mtime;
 			nfstime2  nfsv2fa_ctime;
@@ -356,10 +355,10 @@
 #define	fa3_ctime		fa_un.fa_nfsv3.nfsv3fa_ctime
 
 struct nfsv2_sattr {
-	u_int32_t sa_mode;
-	u_int32_t sa_uid;
-	u_int32_t sa_gid;
-	u_int32_t sa_size;
+	uint32_t sa_mode;
+	uint32_t sa_uid;
+	uint32_t sa_gid;
+	uint32_t sa_size;
 	nfstime2  sa_atime;
 	nfstime2  sa_mtime;
 };
@@ -368,28 +367,28 @@
  * NFS Version 3 sattr structure for the new node creation case.
  */
 struct nfsv3_sattr {
-	u_int32_t   sa_modeset;
-	u_int32_t   sa_mode;
-	u_int32_t   sa_uidset;
-	u_int32_t   sa_uid;
-	u_int32_t   sa_gidset;
-	u_int32_t   sa_gid;
-	u_int32_t   sa_sizeset;
-	u_int32_t   sa_size;
-	u_int32_t   sa_atimetype;
+	uint32_t   sa_modeset;
+	uint32_t   sa_mode;
+	uint32_t   sa_uidset;
+	uint32_t   sa_uid;
+	uint32_t   sa_gidset;
+	uint32_t   sa_gid;
+	uint32_t   sa_sizeset;
+	uint32_t   sa_size;
+	uint32_t   sa_atimetype;
 	nfstime3  sa_atime;
-	u_int32_t   sa_mtimetype;
+	uint32_t   sa_mtimetype;
 	nfstime3  sa_mtime;
 };
 
 struct nfs_statfs {
 	union {
 		struct {
-			u_int32_t nfsv2sf_tsize;
-			u_int32_t nfsv2sf_bsize;
-			u_int32_t nfsv2sf_blocks;
-			u_int32_t nfsv2sf_bfree;
-			u_int32_t nfsv2sf_bavail;
+			uint32_t nfsv2sf_tsize;
+			uint32_t nfsv2sf_bsize;
+			uint32_t nfsv2sf_blocks;
+			uint32_t nfsv2sf_bfree;
+			uint32_t nfsv2sf_bavail;
 		} sf_nfsv2;
 		struct {
 			nfsuint64 nfsv3sf_tbytes;
@@ -398,7 +397,7 @@
 			nfsuint64 nfsv3sf_tfiles;
 			nfsuint64 nfsv3sf_ffiles;
 			nfsuint64 nfsv3sf_afiles;
-			u_int32_t nfsv3sf_invarsec;
+			uint32_t nfsv3sf_invarsec;
 		} sf_nfsv3;
 	} sf_un;
 };
@@ -417,23 +416,23 @@
 #define sf_invarsec	sf_un.sf_nfsv3.nfsv3sf_invarsec
 
 struct nfsv3_fsinfo {
-	u_int32_t fs_rtmax;
-	u_int32_t fs_rtpref;
-	u_int32_t fs_rtmult;
-	u_int32_t fs_wtmax;
-	u_int32_t fs_wtpref;
-	u_int32_t fs_wtmult;
-	u_int32_t fs_dtpref;
+	uint32_t fs_rtmax;
+	uint32_t fs_rtpref;
+	uint32_t fs_rtmult;
+	uint32_t fs_wtmax;
+	uint32_t fs_wtpref;
+	uint32_t fs_wtmult;
+	uint32_t fs_dtpref;
 	nfsuint64 fs_maxfilesize;
 	nfstime3  fs_timedelta;
-	u_int32_t fs_properties;
+	uint32_t fs_properties;
 };
 
 struct nfsv3_pathconf {
-	u_int32_t pc_linkmax;
-	u_int32_t pc_namemax;
-	u_int32_t pc_notrunc;
-	u_int32_t pc_chownrestricted;
-	u_int32_t pc_caseinsensitive;
-	u_int32_t pc_casepreserving;
+	uint32_t pc_linkmax;
+	uint32_t pc_namemax;
+	uint32_t pc_notrunc;
+	uint32_t pc_chownrestricted;
+	uint32_t pc_caseinsensitive;
+	uint32_t pc_casepreserving;
 };
diff --git a/nfsfh.h b/nfsfh.h
index 1d96f13..cfd073b 100644
--- a/nfsfh.h
+++ b/nfsfh.h
@@ -1,5 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.13 2002-04-24 06:27:05 guy Exp $ (LBL) */
-
 /*
  * Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
  * Western Research Laboratory. All rights reserved.
@@ -46,8 +44,8 @@
  * that we might be spying upon use different external representations.
  */
 typedef struct {
-	u_int32_t Minor;	/* upper case to avoid clashing with macro names */
-	u_int32_t Major;
+	uint32_t Minor;	/* upper case to avoid clashing with macro names */
+	uint32_t Major;
 } my_devt;
 
 #define	dev_eq(a,b)	((a.Minor == b.Minor) && (a.Major == b.Major))
@@ -59,10 +57,10 @@
 typedef	struct {
 	my_devt	Fsid_dev;		/* XXX avoid name conflict with AIX */
 	char Opaque_Handle[2 * 32 + 1];
-	u_int32_t fsid_code;
+	uint32_t fsid_code;
 } my_fsid;
 
 #define	fsid_eq(a,b)	((a.fsid_code == b.fsid_code) &&\
 			 dev_eq(a.Fsid_dev, b.Fsid_dev))
 
-extern void Parse_fh(const unsigned char *, int, my_fsid *, u_int32_t *, const char **, const char **, int);
+extern void Parse_fh(const unsigned char *, int, my_fsid *, uint32_t *, const char **, const char **, int);
diff --git a/nlpid.c b/nlpid.c
index 9579ba3..919e87d 100644
--- a/nlpid.c
+++ b/nlpid.c
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -13,11 +13,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/nlpid.c,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/nlpid.h b/nlpid.h
index 1546fc6..63a2e70 100644
--- a/nlpid.h
+++ b/nlpid.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nlpid.h,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL) */
-/* 
+/*
  * 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
diff --git a/ntp.h b/ntp.h
deleted file mode 100644
index 0614f73..0000000
--- a/ntp.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004-01-28 14:34:50 hannes Exp $ */
-
-/*
- * Based on ntp.h from the U of MD implementation
- *	This file is based on Version 2 of the NTP spec (RFC1119).
- */
-
-/*
- *  Definitions for the masses
- */
-#define	JAN_1970	2208988800U	/* 1970 - 1900 in seconds */
-
-/*
- * Structure definitions for NTP fixed point values
- *
- *    0			  1		      2			  3
- *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *   |			       Integer Part			     |
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *   |			       Fraction Part			     |
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- *    0			  1		      2			  3
- *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *   |		  Integer Part	     |	   Fraction Part	     |
- *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct l_fixedpt {
-	u_int32_t int_part;
-	u_int32_t fraction;
-};
-
-struct s_fixedpt {
-	u_int16_t int_part;
-	u_int16_t fraction;
-};
-
-/* rfc2030
- *                      1                   2                   3
- *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |LI | VN  |Mode |    Stratum    |     Poll      |   Precision   |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                          Root Delay                           |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                       Root Dispersion                         |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                     Reference Identifier                      |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                                                               |
- * |                   Reference Timestamp (64)                    |
- * |                                                               |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                                                               |
- * |                   Originate Timestamp (64)                    |
- * |                                                               |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                                                               |
- * |                    Receive Timestamp (64)                     |
- * |                                                               |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                                                               |
- * |                    Transmit Timestamp (64)                    |
- * |                                                               |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                 Key Identifier (optional) (32)                |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |                                                               |
- * |                                                               |
- * |                 Message Digest (optional) (128)               |
- * |                                                               |
- * |                                                               |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-struct ntpdata {
-	u_char status;		/* status of local clock and leap info */
-	u_char stratum;		/* Stratum level */
-	u_char ppoll;		/* poll value */
-	int precision:8;
-	struct s_fixedpt root_delay;
-	struct s_fixedpt root_dispersion;
-	u_int32_t refid;
-	struct l_fixedpt ref_timestamp;
-	struct l_fixedpt org_timestamp;
-	struct l_fixedpt rec_timestamp;
-	struct l_fixedpt xmt_timestamp;
-        u_int32_t key_id;
-        u_int8_t  message_digest[16];
-};
-/*
- *	Leap Second Codes (high order two bits)
- */
-#define	NO_WARNING	0x00	/* no warning */
-#define	PLUS_SEC	0x40	/* add a second (61 seconds) */
-#define	MINUS_SEC	0x80	/* minus a second (59 seconds) */
-#define	ALARM		0xc0	/* alarm condition (clock unsynchronized) */
-
-/*
- *	Clock Status Bits that Encode Version
- */
-#define	NTPVERSION_1	0x08
-#define	VERSIONMASK	0x38
-#define LEAPMASK	0xc0
-#define	MODEMASK	0x07
-
-/*
- *	Code values
- */
-#define	MODE_UNSPEC	0	/* unspecified */
-#define	MODE_SYM_ACT	1	/* symmetric active */
-#define	MODE_SYM_PAS	2	/* symmetric passive */
-#define	MODE_CLIENT	3	/* client */
-#define	MODE_SERVER	4	/* server */
-#define	MODE_BROADCAST	5	/* broadcast */
-#define	MODE_RES1	6	/* reserved */
-#define	MODE_RES2	7	/* reserved */
-
-/*
- *	Stratum Definitions
- */
-#define	UNSPECIFIED	0
-#define	PRIM_REF	1	/* radio clock */
-#define	INFO_QUERY	62	/* **** THIS implementation dependent **** */
-#define	INFO_REPLY	63	/* **** THIS implementation dependent **** */
diff --git a/oakley.h b/oakley.h
deleted file mode 100644
index ad32817..0000000
--- a/oakley.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-/* YIPS @(#)$Id: oakley.h,v 1.4 2002-12-11 07:13:56 guy Exp $ */
-
-/* refer to RFC 2409 */
-
-#if !defined(_ISAKMP_OAKLEY_H_)
-#define _ISAKMP_OAKLEY_H_
-
-/* Attribute Classes */
-#define OAKLEY_ATTR_ENC_ALG                   1 /* B */
-#define   OAKLEY_ATTR_ENC_ALG_DES               1
-#define   OAKLEY_ATTR_ENC_ALG_IDEA              2
-#define   OAKLEY_ATTR_ENC_ALG_BL                3
-#define   OAKLEY_ATTR_ENC_ALG_RC5               4
-#define   OAKLEY_ATTR_ENC_ALG_3DES              5
-#define   OAKLEY_ATTR_ENC_ALG_CAST              6
-#define OAKLEY_ATTR_HASH_ALG                  2 /* B */
-#define   OAKLEY_ATTR_HASH_ALG_MD5              1
-#define   OAKLEY_ATTR_HASH_ALG_SHA              2
-#define   OAKLEY_ATTR_HASH_ALG_TIGER            3
-#define OAKLEY_ATTR_AUTH_METHOD               3 /* B */
-#define   OAKLEY_ATTR_AUTH_METHOD_PSKEY         1
-#define   OAKLEY_ATTR_AUTH_METHOD_DSS           2
-#define   OAKLEY_ATTR_AUTH_METHOD_RSA           3
-#define   OAKLEY_ATTR_AUTH_METHOD_RSAENC        4
-#define   OAKLEY_ATTR_AUTH_METHOD_RSAREV        5
-#define OAKLEY_ATTR_GRP_DESC                  4 /* B */
-#define   OAKLEY_ATTR_GRP_DESC_MODP768          1
-#define   OAKLEY_ATTR_GRP_DESC_MODP1024         2
-#define   OAKLEY_ATTR_GRP_DESC_EC2N155          3
-#define   OAKLEY_ATTR_GRP_DESC_EC2N185          4
-#define OAKLEY_ATTR_GRP_TYPE                  5 /* B */
-#define   OAKLEY_ATTR_GRP_TYPE_MODP             1
-#define   OAKLEY_ATTR_GRP_TYPE_ECP              2
-#define   OAKLEY_ATTR_GRP_TYPE_EC2N             3
-#define OAKLEY_ATTR_GRP_PI                    6 /* V */
-#define OAKLEY_ATTR_GRP_GEN_ONE               7 /* V */
-#define OAKLEY_ATTR_GRP_GEN_TWO               8 /* V */
-#define OAKLEY_ATTR_GRP_CURVE_A               9 /* V */
-#define OAKLEY_ATTR_GRP_CURVE_B              10 /* V */
-#define OAKLEY_ATTR_SA_LTYPE                 11 /* B */
-#define   OAKLEY_ATTR_SA_LTYPE_DEFAULT          1
-#define   OAKLEY_ATTR_SA_LTYPE_SEC              1
-#define   OAKLEY_ATTR_SA_LTYPE_KB               2
-#define OAKLEY_ATTR_SA_LDUR                  12 /* V */
-#define   OAKLEY_ATTR_SA_LDUR_DEFAULT           28800 /* 8 hours */
-#define OAKLEY_ATTR_PRF                      13 /* B */
-#define OAKLEY_ATTR_KEY_LEN                  14 /* B */
-#define OAKLEY_ATTR_FIELD_SIZE               15 /* B */
-#define OAKLEY_ATTR_GRP_ORDER                16 /* V */
-
-#define OAKLEY_ID_IPV4_ADDR          0
-#define OAKLEY_ID_IPV4_ADDR_SUBNET   1
-#define OAKLEY_ID_IPV6_ADDR          2
-#define OAKLEY_ID_IPV6_ADDR_SUBNET   3
-
-/* Additional Exchange Type */
-#define ISAKMP_ETYPE_QUICK    32
-#define ISAKMP_ETYPE_NEWGRP   33
-
-/* The use for checking proposal payload. This is not exchange type. */
-#define OAKLEY_MAIN_MODE    0
-#define OAKLEY_QUICK_MODE   1
-
-#define OAKLEY_PRIME_MODP768 "\
-	FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
-	29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
-	EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
-	E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF"
-
-#define OAKLEY_PRIME_MODP1024 "\
-	FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
-	29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
-	EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
-	E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED \
-	EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \
-	FFFFFFFF FFFFFFFF"
-
-#define DEFAULTSECRETSIZE ( 128 / 8 ) /* 128 bits */
-#define DEFAULTNONCESIZE  ( 128 / 8 ) /* 128 bits */
-
-#define MAXPADLWORD 20
-
-#if 0
-/* isakmp sa structure */
-struct oakley_sa {
-	u_int8_t  proto_id;            /* OAKLEY */
-	vchar_t   *spi;                /* spi */
-	u_int8_t  dhgrp;               /* DH; group */
-	u_int8_t  auth_t;              /* method of authentication */
-	u_int8_t  prf_t;               /* type of prf */
-	u_int8_t  hash_t;              /* type of hash */
-	u_int8_t  enc_t;               /* type of cipher */
-	u_int8_t  life_t;              /* type of duration of lifetime */
-	u_int32_t ldur;                /* life duration */
-};
-#endif
-
-#endif /* !defined(_ISAKMP_OAKLEY_H_) */
diff --git a/openflow.h b/openflow.h
index 07ba685..31ef03c 100644
--- a/openflow.h
+++ b/openflow.h
@@ -27,10 +27,25 @@
 
 /* OpenFlow: protocol between controller and datapath. */
 
+/* for netdissect_options */
+#include "netdissect.h"
+
 #define OF_HEADER_LEN 8
 
+#define ONF_EXP_ONF               0x4f4e4600
+#define ONF_EXP_BUTE              0xff000001
+#define ONF_EXP_NOVIFLOW          0xff000002
+#define ONF_EXP_L3                0xff000003
+#define ONF_EXP_L4L7              0xff000004
+#define ONF_EXP_WMOB              0xff000005
+#define ONF_EXP_FABS              0xff000006
+#define ONF_EXP_OTRANS            0xff000007
+extern const struct tok onf_exp_str[];
+
 /*
  * Routines to print packets for various versions of OpenFlow.
  */
-extern const u_char *of10_header_body_print(const u_char *, const u_char *,
+extern const u_char *of10_header_body_print(netdissect_options *ndo,
+	const u_char *, const u_char *,
 	const uint8_t, const uint16_t, const uint32_t);
+extern const char * of_vendor_name(const uint32_t);
diff --git a/ospf.h b/ospf.h
index b86458b..b47aaf6 100644
--- a/ospf.h
+++ b/ospf.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.23 2007-10-08 07:53:21 hannes Exp $ (LBL) */
 /*
  * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
  *	The Regents of the University of California.  All rights reserved.
@@ -35,7 +34,7 @@
  * +------------------------------------+
  *
  */
-                
+
 #define OSPF_OPTION_T	0x01	/* T bit: TOS support	*/
 #define OSPF_OPTION_E	0x02	/* E bit: External routes advertised	*/
 #define	OSPF_OPTION_MC	0x04	/* MC bit: Multicast capable */
@@ -137,6 +136,8 @@
 #define	MCLA_VERTEX_NETWORK	2
 
 /* Link-Local-Signaling */
+#define OSPF_LLS_HDRLEN         4U /* RFC5613 Section 2.2 */
+
 #define OSPF_LLS_EO             1  /* RFC4811, RFC4812 */
 #define OSPF_LLS_MD5            2  /* RFC4813 */
 
@@ -147,14 +148,14 @@
  * TOS metric struct (will be 0 or more in router links update)
  */
 struct tos_metric {
-    u_int8_t tos_type;
-    u_int8_t reserved;
-    u_int8_t tos_metric[2];
+    uint8_t tos_type;
+    uint8_t reserved;
+    uint8_t tos_metric[2];
 };
 struct tos_link {
-    u_int8_t link_type;
-    u_int8_t link_tos_count;
-    u_int8_t tos_metric[2];
+    uint8_t link_type;
+    uint8_t link_tos_count;
+    uint8_t tos_metric[2];
 };
 union un_tos {
     struct tos_link link;
@@ -163,20 +164,20 @@
 
 /* link state advertisement header */
 struct lsa_hdr {
-    u_int16_t ls_age;
-    u_int8_t ls_options;
-    u_int8_t ls_type;
+    uint16_t ls_age;
+    uint8_t ls_options;
+    uint8_t ls_type;
     union {
         struct in_addr lsa_id;
         struct { /* opaque LSAs change the LSA-ID field */
-            u_int8_t opaque_type;
-            u_int8_t opaque_id[3];
+            uint8_t opaque_type;
+            uint8_t opaque_id[3];
 	} opaque_field;
     } un_lsa_id;
     struct in_addr ls_router;
-    u_int32_t ls_seq;
-    u_int16_t ls_chksum;
-    u_int16_t ls_length;
+    uint32_t ls_seq;
+    uint16_t ls_chksum;
+    uint16_t ls_length;
 };
 
 /* link state advertisement */
@@ -187,9 +188,9 @@
     union {
 	/* Router links advertisements */
 	struct {
-	    u_int8_t rla_flags;
-	    u_int8_t rla_zero[1];
-	    u_int16_t rla_count;
+	    uint8_t rla_flags;
+	    uint8_t rla_zero[1];
+	    uint16_t rla_count;
 	    struct rlalink {
 		struct in_addr link_id;
 		struct in_addr link_data;
@@ -206,14 +207,14 @@
 	/* Summary links advertisements */
 	struct {
 	    struct in_addr sla_mask;
-	    u_int32_t sla_tosmetric[1];	/* may repeat	*/
+	    uint32_t sla_tosmetric[1];	/* may repeat	*/
 	} un_sla;
 
 	/* AS external links advertisements */
 	struct {
 	    struct in_addr asla_mask;
 	    struct aslametric {
-		u_int32_t asla_tosmetric;
+		uint32_t asla_tosmetric;
 		struct in_addr asla_forward;
 		struct in_addr asla_tag;
 	    } asla_metric[1];		/* may repeat	*/
@@ -221,34 +222,34 @@
 
 	/* Multicast group membership */
 	struct mcla {
-	    u_int32_t mcla_vtype;
+	    uint32_t mcla_vtype;
 	    struct in_addr mcla_vid;
 	} un_mcla[1];
 
         /* Opaque TE LSA */
         struct {
-	    u_int16_t type;
-	    u_int16_t length;
-	    u_int8_t data[1]; /* may repeat   */
+	    uint16_t type;
+	    uint16_t length;
+	    uint8_t data[1]; /* may repeat   */
 	} un_te_lsa_tlv;
 
         /* Opaque Grace LSA */
         struct {
-	    u_int16_t type;
-	    u_int16_t length;
-	    u_int8_t data[1]; /* may repeat   */
+	    uint16_t type;
+	    uint16_t length;
+	    uint8_t data[1]; /* may repeat   */
 	} un_grace_tlv;
 
         /* Opaque Router information LSA */
         struct {
-	    u_int16_t type;
-	    u_int16_t length;
-	    u_int8_t data[1]; /* may repeat   */
+	    uint16_t type;
+	    uint16_t length;
+	    uint8_t data[1]; /* may repeat   */
 	} un_ri_tlv;
 
         /* Unknown LSA */
         struct unknown {
-	    u_int8_t data[1]; /* may repeat   */
+	    uint8_t data[1]; /* may repeat   */
 	} un_unknown[1];
 
     } lsa_un;
@@ -260,23 +261,23 @@
  * the main header
  */
 struct ospfhdr {
-    u_int8_t ospf_version;
-    u_int8_t ospf_type;
-    u_int16_t ospf_len;
+    uint8_t ospf_version;
+    uint8_t ospf_type;
+    uint16_t ospf_len;
     struct in_addr ospf_routerid;
     struct in_addr ospf_areaid;
-    u_int16_t ospf_chksum;
-    u_int16_t ospf_authtype;
-    u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
+    uint16_t ospf_chksum;
+    uint16_t ospf_authtype;
+    uint8_t ospf_authdata[OSPF_AUTH_SIZE];
     union {
 
 	/* Hello packet */
 	struct {
 	    struct in_addr hello_mask;
-	    u_int16_t hello_helloint;
-	    u_int8_t hello_options;
-	    u_int8_t hello_priority;
-	    u_int32_t hello_deadint;
+	    uint16_t hello_helloint;
+	    uint8_t hello_options;
+	    uint8_t hello_priority;
+	    uint32_t hello_deadint;
 	    struct in_addr hello_dr;
 	    struct in_addr hello_bdr;
 	    struct in_addr hello_neighbor[1]; /* may repeat	*/
@@ -284,21 +285,21 @@
 
 	/* Database Description packet */
 	struct {
-	    u_int16_t db_ifmtu;
-	    u_int8_t db_options;
-	    u_int8_t db_flags;
-	    u_int32_t db_seq;
+	    uint16_t db_ifmtu;
+	    uint8_t db_options;
+	    uint8_t db_flags;
+	    uint32_t db_seq;
 	    struct lsa_hdr db_lshdr[1]; /* may repeat	*/
 	} un_db;
 
 	/* Link State Request */
 	struct lsr {
-	    u_int8_t ls_type[4];
+	    uint8_t ls_type[4];
             union {
                 struct in_addr ls_stateid;
                 struct { /* opaque LSAs change the LSA-ID field */
-                    u_int8_t opaque_type;
-                    u_int8_t opaque_id[3];
+                    uint8_t opaque_type;
+                    uint8_t opaque_id[3];
                 } opaque_field;
             } un_ls_stateid;
 	    struct in_addr ls_router;
@@ -306,7 +307,7 @@
 
 	/* Link State Update */
 	struct {
-	    u_int32_t lsu_count;
+	    uint32_t lsu_count;
 	    struct lsa lsu_lsa[1]; /* may repeat	*/
 	} un_lsu;
 
@@ -322,7 +323,3 @@
 #define	ospf_lsr	ospf_un.un_lsr
 #define	ospf_lsu	ospf_un.un_lsu
 #define	ospf_lsa	ospf_un.un_lsa
-
-/* Functions shared by ospf and ospf6 */
-extern int ospf_print_te_lsa(const u_int8_t *, u_int);
-extern int ospf_print_grace_lsa(const u_int8_t *, u_int);
diff --git a/ospf6.h b/ospf6.h
deleted file mode 100644
index e2eabee..0000000
--- a/ospf6.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.7 2006-09-05 15:50:26 hannes Exp $ (LBL) */
-/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
- *	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.
- *
- * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
- */
-#define	OSPF_TYPE_HELLO         1	/* Hello */
-#define	OSPF_TYPE_DD            2	/* Database Description */
-#define	OSPF_TYPE_LS_REQ        3	/* Link State Request */
-#define	OSPF_TYPE_LS_UPDATE     4	/* Link State Update */
-#define	OSPF_TYPE_LS_ACK        5	/* Link State Ack */
-
-/* Options *_options	*/
-#define OSPF6_OPTION_V6	0x01	/* V6 bit: A bit for peeping tom */
-#define OSPF6_OPTION_E	0x02	/* E bit: External routes advertised	*/
-#define OSPF6_OPTION_MC	0x04	/* MC bit: Multicast capable */
-#define OSPF6_OPTION_N	0x08	/* N bit: For type-7 LSA */
-#define OSPF6_OPTION_R	0x10	/* R bit: Router bit */
-#define OSPF6_OPTION_DC	0x20	/* DC bit: Demand circuits */
-
-
-/* db_flags	*/
-#define	OSPF6_DB_INIT		0x04	    /*	*/
-#define	OSPF6_DB_MORE		0x02
-#define	OSPF6_DB_MASTER		0x01
-
-/* ls_type	*/
-#define	LS_TYPE_ROUTER		1   /* router link */
-#define	LS_TYPE_NETWORK		2   /* network link */
-#define	LS_TYPE_INTER_AP	3   /* Inter-Area-Prefix */
-#define	LS_TYPE_INTER_AR	4   /* Inter-Area-Router */
-#define	LS_TYPE_ASE		5   /* ASE */
-#define	LS_TYPE_GROUP		6   /* Group membership */
-#define	LS_TYPE_NSSA		7   /* NSSA */
-#define	LS_TYPE_LINK		8   /* Link LSA */
-#define	LS_TYPE_INTRA_AP	9   /* Intra-Area-Prefix */
-#define LS_TYPE_INTRA_ATE       10  /* Intra-Area-TE */
-#define LS_TYPE_GRACE           11  /* Grace LSA */
-#define LS_TYPE_MASK		0x1fff
-
-#define LS_SCOPE_LINKLOCAL	0x0000
-#define LS_SCOPE_AREA		0x2000
-#define LS_SCOPE_AS		0x4000
-#define LS_SCOPE_MASK		0x6000
-#define LS_SCOPE_U              0x8000
-
-/* rla_link.link_type	*/
-#define	RLA_TYPE_ROUTER		1   /* point-to-point to another router	*/
-#define	RLA_TYPE_TRANSIT	2   /* connection to transit network	*/
-#define RLA_TYPE_VIRTUAL	4   /* virtual link			*/
-
-/* rla_flags	*/
-#define	RLA_FLAG_B	0x01
-#define	RLA_FLAG_E	0x02
-#define	RLA_FLAG_V	0x04
-#define	RLA_FLAG_W	0x08
-#define RLA_FLAG_N      0x10
-
-/* lsa_prefix options */
-#define LSA_PREFIX_OPT_NU 0x01
-#define LSA_PREFIX_OPT_LA 0x02
-#define LSA_PREFIX_OPT_MC 0x04
-#define LSA_PREFIX_OPT_P  0x08
-#define LSA_PREFIX_OPT_DN 0x10
-
-/* sla_tosmetric breakdown	*/
-#define	SLA_MASK_TOS		0x7f000000
-#define	SLA_MASK_METRIC		0x00ffffff
-#define SLA_SHIFT_TOS		24
-
-/* asla_metric */
-#define ASLA_FLAG_FWDADDR	0x02000000
-#define ASLA_FLAG_ROUTETAG	0x01000000
-#define	ASLA_MASK_METRIC	0x00ffffff
-
-typedef u_int32_t rtrid_t;
-
-/* link state advertisement header */
-struct lsa6_hdr {
-    u_int16_t ls_age;
-    u_int16_t ls_type;
-    rtrid_t ls_stateid;
-    rtrid_t ls_router;
-    u_int32_t ls_seq;
-    u_int16_t ls_chksum;
-    u_int16_t ls_length;
-};
-
-struct lsa6_prefix {
-    u_int8_t lsa_p_len;
-    u_int8_t lsa_p_opt;
-    u_int16_t lsa_p_metric;
-    u_int8_t lsa_p_prefix[4];
-};
-
-/* link state advertisement */
-struct lsa6 {
-    struct lsa6_hdr ls_hdr;
-
-    /* Link state types */
-    union {
-	/* Router links advertisements */
-	struct {
-	    union {
-		u_int8_t flg;
-		u_int32_t opt;
-	    } rla_flgandopt;
-#define rla_flags	rla_flgandopt.flg
-#define rla_options	rla_flgandopt.opt
-	    struct rlalink6 {
-		u_int8_t link_type;
-		u_int8_t link_zero[1];
-		u_int16_t link_metric;
-		u_int32_t link_ifid;
-		u_int32_t link_nifid;
-		rtrid_t link_nrtid;
-	    } rla_link[1];		/* may repeat	*/
-	} un_rla;
-
-	/* Network links advertisements */
-	struct {
-	    u_int32_t nla_options;
-	    rtrid_t nla_router[1];	/* may repeat	*/
-	} un_nla;
-
-	/* Inter Area Prefix LSA */
-	struct {
-	    u_int32_t inter_ap_metric;
-	    struct lsa6_prefix inter_ap_prefix[1];
-	} un_inter_ap;
-
-	/* AS external links advertisements */
-	struct {
-	    u_int32_t asla_metric;
-	    struct lsa6_prefix asla_prefix[1];
-	    /* some optional fields follow */
-	} un_asla;
-
-#if 0
-	/* Summary links advertisements */
-	struct {
-	    struct in_addr sla_mask;
-	    u_int32_t sla_tosmetric[1];	/* may repeat	*/
-	} un_sla;
-
-	/* Multicast group membership */
-	struct mcla {
-	    u_int32_t mcla_vtype;
-	    struct in_addr mcla_vid;
-	} un_mcla[1];
-#endif
-
-	/* Type 7 LSA */
-
-	/* Link LSA */
-	struct llsa {
-	    union {
-		u_int8_t pri;
-		u_int32_t opt;
-	    } llsa_priandopt;
-#define llsa_priority	llsa_priandopt.pri
-#define llsa_options	llsa_priandopt.opt
-	    struct in6_addr llsa_lladdr;
-	    u_int32_t llsa_nprefix;
-	    struct lsa6_prefix llsa_prefix[1];
-	} un_llsa;
-
-	/* Intra-Area-Prefix */
-	struct {
-	    u_int16_t intra_ap_nprefix;
-	    u_int16_t intra_ap_lstype;
-	    rtrid_t intra_ap_lsid;
-	    rtrid_t intra_ap_rtid;
-	    struct lsa6_prefix intra_ap_prefix[1];
-	} un_intra_ap;
-    } lsa_un;
-};
-
-
-#define	OSPF_AUTH_SIZE	8
-
-/*
- * the main header
- */
-struct ospf6hdr {
-    u_int8_t ospf6_version;
-    u_int8_t ospf6_type;
-    u_int16_t ospf6_len;
-    rtrid_t ospf6_routerid;
-    rtrid_t ospf6_areaid;
-    u_int16_t ospf6_chksum;
-    u_int8_t ospf6_instanceid;
-    u_int8_t ospf6_rsvd;
-    union {
-
-	/* Hello packet */
-	struct {
-	    u_int32_t hello_ifid;
-	    union {
-		u_int8_t pri;
-		u_int32_t opt;
-	    } hello_priandopt;
-#define hello_priority	hello_priandopt.pri
-#define hello_options	hello_priandopt.opt
-	    u_int16_t hello_helloint;
-	    u_int16_t hello_deadint;
-	    rtrid_t hello_dr;
-	    rtrid_t hello_bdr;
-	    rtrid_t hello_neighbor[1]; /* may repeat	*/
-	} un_hello;
-
-	/* Database Description packet */
-	struct {
-	    u_int32_t db_options;
-	    u_int16_t db_mtu;
-	    u_int8_t db_mbz;
-	    u_int8_t db_flags;
-	    u_int32_t db_seq;
-	    struct lsa6_hdr db_lshdr[1]; /* may repeat	*/
-	} un_db;
-
-	/* Link State Request */
-	struct lsr6 {
-	    u_int16_t ls_mbz;
-	    u_int16_t ls_type;
-	    rtrid_t ls_stateid;
-	    rtrid_t ls_router;
-	} un_lsr[1];		/* may repeat	*/
-
-	/* Link State Update */
-	struct {
-	    u_int32_t lsu_count;
-	    struct lsa6 lsu_lsa[1]; /* may repeat	*/
-	} un_lsu;
-
-	/* Link State Acknowledgement */
-	struct {
-	    struct lsa6_hdr lsa_lshdr[1]; /* may repeat	*/
-	} un_lsa ;
-    } ospf6_un ;
-};
-
-#define	ospf6_hello	ospf6_un.un_hello
-#define	ospf6_db	ospf6_un.un_db
-#define	ospf6_lsr	ospf6_un.un_lsr
-#define	ospf6_lsu	ospf6_un.un_lsu
-#define	ospf6_lsa	ospf6_un.un_lsa
-
diff --git a/oui.c b/oui.c
index 1067aa1..2aea5ad 100644
--- a/oui.c
+++ b/oui.c
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -13,11 +13,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.9 2008-01-09 09:40:47 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -43,6 +39,15 @@
     { OUI_IEEE_8023_PRIVATE, "IEEE 802.3 Private"},
     { OUI_TIA, "ANSI/TIA"},
     { OUI_DCBX, "DCBX"},
+    { OUI_NICIRA, "Nicira Networks" },
+    { OUI_BSN, "Big Switch Networks" },
+    { OUI_VELLO, "Vello Systems" },
+    { OUI_HP2, "HP" },
+    { OUI_HPLABS, "HP-Labs" },
+    { OUI_INFOBLOX, "Infoblox Inc" },
+    { OUI_ONLAB, "Open Networking Lab" },
+    { OUI_FREESCALE, "Freescale" },
+    { OUI_NETRONOME, "Netronome" },
     { 0, NULL }
 };
 
diff --git a/oui.h b/oui.h
index d39cb6c..4a983ec 100644
--- a/oui.h
+++ b/oui.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.8 2008-01-09 09:40:47 hannes Exp $ (LBL) */
-/* 
+/*
  * 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
@@ -31,6 +30,15 @@
 #define OUI_IEEE_8023_PRIVATE 0x00120f      /* IEEE 802.3 Organisation Specific - Annex G */
 #define OUI_TIA         0x0012bb        /* TIA - Telecommunications Industry Association - ANSI/TIA-1057- 2006 */
 #define OUI_DCBX        0x001B21        /* DCBX */
+#define OUI_NICIRA      0x002320        /* Nicira Networks */
+#define OUI_BSN         0x5c16c7        /* Big Switch Networks */
+#define OUI_VELLO       0xb0d2f5        /* Vello Systems */
+#define OUI_HP2         0x002481        /* HP too */
+#define OUI_HPLABS      0x0004ea        /* HP-Labs */
+#define OUI_INFOBLOX    0x748771        /* Infoblox Inc */
+#define OUI_ONLAB       0xa42305        /* Open Networking Lab */
+#define OUI_FREESCALE   0x00049f        /* Freescale */
+#define OUI_NETRONOME   0x0015ad        /* Netronome */
 
 /*
  * These are SMI Network Management Private Enterprise Codes for
diff --git a/parsenfsfh.c b/parsenfsfh.c
index 86938e3..826ca94 100644
--- a/parsenfsfh.c
+++ b/parsenfsfh.c
@@ -40,11 +40,7 @@
  * Western Research Laboratory
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.29 2006-06-13 22:21:38 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -83,7 +79,7 @@
 
 #ifdef	ultrix
 /* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */
-#define	XFF(x)	((u_int32_t)(x))
+#define	XFF(x)	((uint32_t)(x))
 #else
 #define	XFF(x)	(x)
 #endif
@@ -110,17 +106,14 @@
 static int is_UCX(const unsigned char *);
 
 void
-Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
-register const unsigned char *fh;
-int len _U_;
-my_fsid *fsidp;
-u_int32_t *inop;
-const char **osnamep;		/* if non-NULL, return OS name here */
-const char **fsnamep;		/* if non-NULL, return server fs name here (for VMS) */
-int ourself;		/* true if file handle was generated on this host */
+Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
+	 uint32_t *inop,
+	 const char **osnamep, /* if non-NULL, return OS name here */
+	 const char **fsnamep, /* if non-NULL, return server fs name here (for VMS) */
+	 int ourself)	/* true if file handle was generated on this host */
 {
 	register const unsigned char *fhp = fh;
-	u_int32_t temp;
+	uint32_t temp;
 	int fhtype = FHT_UNKNOWN;
 	int i;
 
@@ -371,7 +364,7 @@
 		memcpy((char *)fsidp, (char *)fh, 14);
 	    }
 	    else {
-		u_int32_t tempa[4];	/* at least 16 bytes, maybe more */
+		uint32_t tempa[4];	/* at least 16 bytes, maybe more */
 
 		memset((char *)tempa, 0, sizeof(tempa));
 		memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */
@@ -450,8 +443,7 @@
  *	(3) followed by string of nulls
  */
 static int
-is_UCX(fhp)
-const unsigned char *fhp;
+is_UCX(const unsigned char *fhp)
 {
 	register int i;
 	int seen_null = 0;
diff --git a/pcap-missing.h b/pcap-missing.h
index 5c0ece2..d776810 100644
--- a/pcap-missing.h
+++ b/pcap-missing.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.3 2005-06-03 22:08:52 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_pcap_missing_h
diff --git a/pcap_dump_ftell.c b/pcap_dump_ftell.c
index 6eb3a4a..1b652b5 100644
--- a/pcap_dump_ftell.c
+++ b/pcap_dump_ftell.c
@@ -19,11 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1 2005-06-03 22:08:52 guy Exp $ (LBL)";
-#endif
-
 #include <stdio.h>
 #include <pcap.h>
 
diff --git a/pmap_prot.h b/pmap_prot.h
deleted file mode 100644
index 67ad626..0000000
--- a/pmap_prot.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/pmap_prot.h,v 1.3 2005-04-27 21:43:48 guy Exp $ (LBL) */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part.  Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- *
- *	from: @(#)pmap_prot.h 1.14 88/02/08 SMI
- *	from: @(#)pmap_prot.h	2.1 88/07/29 4.0 RPCSRC
- * $FreeBSD: src/include/rpc/pmap_prot.h,v 1.9.2.1 1999/08/29 14:39:05 peter Exp $
- */
-
-/*
- * pmap_prot.h
- * Protocol for the local binder service, or pmap.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * The following procedures are supported by the protocol:
- *
- * PMAPPROC_NULL() returns ()
- * 	takes nothing, returns nothing
- *
- * PMAPPROC_SET(struct pmap) returns (bool_t)
- * 	TRUE is success, FALSE is failure.  Registers the tuple
- *	[prog, vers, prot, port].
- *
- * PMAPPROC_UNSET(struct pmap) returns (bool_t)
- *	TRUE is success, FALSE is failure.  Un-registers pair
- *	[prog, vers].  prot and port are ignored.
- *
- * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
- *	0 is failure.  Otherwise returns the port number where the pair
- *	[prog, vers] is registered.  It may lie!
- *
- * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
- *
- * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
- * 	RETURNS (port, string<>);
- * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
- * 	Calls the procedure on the local machine.  If it is not registered,
- *	this procedure is quite; ie it does not return error information!!!
- *	This procedure only is supported on rpc/udp and calls via
- *	rpc/udp.  This routine only passes null authentication parameters.
- *	This file has no interface to xdr routines for PMAPPROC_CALLIT.
- *
- * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
- */
-
-#define SUNRPC_PMAPPORT		((u_int16_t)111)
-#define SUNRPC_PMAPPROG		((u_int32_t)100000)
-#define SUNRPC_PMAPVERS		((u_int32_t)2)
-#define SUNRPC_PMAPVERS_PROTO	((u_int32_t)2)
-#define SUNRPC_PMAPVERS_ORIG	((u_int32_t)1)
-#define SUNRPC_PMAPPROC_NULL	((u_int32_t)0)
-#define SUNRPC_PMAPPROC_SET	((u_int32_t)1)
-#define SUNRPC_PMAPPROC_UNSET	((u_int32_t)2)
-#define SUNRPC_PMAPPROC_GETPORT	((u_int32_t)3)
-#define SUNRPC_PMAPPROC_DUMP	((u_int32_t)4)
-#define SUNRPC_PMAPPROC_CALLIT	((u_int32_t)5)
-
-struct sunrpc_pmap {
-	u_int32_t pm_prog;
-	u_int32_t pm_vers;
-	u_int32_t pm_prot;
-	u_int32_t pm_port;
-};
diff --git a/ppi.h b/ppi.h
deleted file mode 100644
index 733eb95..0000000
--- a/ppi.h
+++ /dev/null
@@ -1,9 +0,0 @@
-typedef struct ppi_header {
-	uint8_t		ppi_ver;
-	uint8_t		ppi_flags;
-	uint16_t	ppi_len;
-	uint32_t	ppi_dlt;
-} ppi_header_t;
-
-#define	PPI_HDRLEN	8
-
diff --git a/ppp.h b/ppp.h
index ba7aea7..9d53423 100644
--- a/ppp.h
+++ b/ppp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004-10-20 16:14:16 hannes Exp $ (LBL) */
 /*
  * Point to Point Protocol (PPP) RFC1331
  *
diff --git a/print-802_11.c b/print-802_11.c
index 8a9a1a6..697e2c9 100644
--- a/print-802_11.c
+++ b/print-802_11.c
@@ -20,50 +20,689 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "ethertype.h"
 
 #include "extract.h"
 
 #include "cpack.h"
 
-#include "ieee802_11.h"
-#include "ieee802_11_radio.h"
+
+/* Lengths of 802.11 header components. */
+#define	IEEE802_11_FC_LEN		2
+#define	IEEE802_11_DUR_LEN		2
+#define	IEEE802_11_DA_LEN		6
+#define	IEEE802_11_SA_LEN		6
+#define	IEEE802_11_BSSID_LEN		6
+#define	IEEE802_11_RA_LEN		6
+#define	IEEE802_11_TA_LEN		6
+#define	IEEE802_11_SEQ_LEN		2
+#define	IEEE802_11_CTL_LEN		2
+#define	IEEE802_11_IV_LEN		3
+#define	IEEE802_11_KID_LEN		1
+
+/* Frame check sequence length. */
+#define	IEEE802_11_FCS_LEN		4
+
+/* Lengths of beacon components. */
+#define	IEEE802_11_TSTAMP_LEN		8
+#define	IEEE802_11_BCNINT_LEN		2
+#define	IEEE802_11_CAPINFO_LEN		2
+#define	IEEE802_11_LISTENINT_LEN	2
+
+#define	IEEE802_11_AID_LEN		2
+#define	IEEE802_11_STATUS_LEN		2
+#define	IEEE802_11_REASON_LEN		2
+
+/* Length of previous AP in reassocation frame */
+#define	IEEE802_11_AP_LEN		6
+
+#define	T_MGMT 0x0  /* management */
+#define	T_CTRL 0x1  /* control */
+#define	T_DATA 0x2 /* data */
+#define	T_RESV 0x3  /* reserved */
+
+#define	ST_ASSOC_REQUEST   	0x0
+#define	ST_ASSOC_RESPONSE 	0x1
+#define	ST_REASSOC_REQUEST   	0x2
+#define	ST_REASSOC_RESPONSE  	0x3
+#define	ST_PROBE_REQUEST   	0x4
+#define	ST_PROBE_RESPONSE   	0x5
+/* RESERVED 			0x6  */
+/* RESERVED 			0x7  */
+#define	ST_BEACON   		0x8
+#define	ST_ATIM			0x9
+#define	ST_DISASSOC		0xA
+#define	ST_AUTH			0xB
+#define	ST_DEAUTH		0xC
+#define	ST_ACTION		0xD
+/* RESERVED 			0xE  */
+/* RESERVED 			0xF  */
+
+static const struct tok st_str[] = {
+	{ ST_ASSOC_REQUEST,    "Assoc Request"    },
+	{ ST_ASSOC_RESPONSE,   "Assoc Response"   },
+	{ ST_REASSOC_REQUEST,  "ReAssoc Request"  },
+	{ ST_REASSOC_RESPONSE, "ReAssoc Response" },
+	{ ST_PROBE_REQUEST,    "Probe Request"    },
+	{ ST_PROBE_RESPONSE,   "Probe Response"   },
+	{ ST_BEACON,           "Beacon"           },
+	{ ST_ATIM,             "ATIM"             },
+	{ ST_DISASSOC,         "Disassociation"   },
+	{ ST_AUTH,             "Authentication"   },
+	{ ST_DEAUTH,           "DeAuthentication" },
+	{ ST_ACTION,           "Action"           },
+	{ 0, NULL }
+};
+
+#define CTRL_CONTROL_WRAPPER	0x7
+#define	CTRL_BAR	0x8
+#define	CTRL_BA		0x9
+#define	CTRL_PS_POLL	0xA
+#define	CTRL_RTS	0xB
+#define	CTRL_CTS	0xC
+#define	CTRL_ACK	0xD
+#define	CTRL_CF_END	0xE
+#define	CTRL_END_ACK	0xF
+
+static const struct tok ctrl_str[] = {
+	{ CTRL_CONTROL_WRAPPER, "Control Wrapper" },
+	{ CTRL_BAR,             "BAR"             },
+	{ CTRL_BA,              "BA"              },
+	{ CTRL_PS_POLL,         "Power Save-Poll" },
+	{ CTRL_RTS,             "Request-To-Send" },
+	{ CTRL_CTS,             "Clear-To-Send"   },
+	{ CTRL_ACK,             "Acknowledgment"  },
+	{ CTRL_CF_END,          "CF-End"          },
+	{ CTRL_END_ACK,         "CF-End+CF-Ack"   },
+	{ 0, NULL }
+};
+
+#define	DATA_DATA			0x0
+#define	DATA_DATA_CF_ACK		0x1
+#define	DATA_DATA_CF_POLL		0x2
+#define	DATA_DATA_CF_ACK_POLL		0x3
+#define	DATA_NODATA			0x4
+#define	DATA_NODATA_CF_ACK		0x5
+#define	DATA_NODATA_CF_POLL		0x6
+#define	DATA_NODATA_CF_ACK_POLL		0x7
+
+#define DATA_QOS_DATA			0x8
+#define DATA_QOS_DATA_CF_ACK		0x9
+#define DATA_QOS_DATA_CF_POLL		0xA
+#define DATA_QOS_DATA_CF_ACK_POLL	0xB
+#define DATA_QOS_NODATA			0xC
+#define DATA_QOS_CF_POLL_NODATA		0xE
+#define DATA_QOS_CF_ACK_POLL_NODATA	0xF
+
+/*
+ * The subtype field of a data frame is, in effect, composed of 4 flag
+ * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
+ * any data), and QoS.
+ */
+#define DATA_FRAME_IS_CF_ACK(x)		((x) & 0x01)
+#define DATA_FRAME_IS_CF_POLL(x)	((x) & 0x02)
+#define DATA_FRAME_IS_NULL(x)		((x) & 0x04)
+#define DATA_FRAME_IS_QOS(x)		((x) & 0x08)
+
+/*
+ * Bits in the frame control field.
+ */
+#define	FC_VERSION(fc)		((fc) & 0x3)
+#define	FC_TYPE(fc)		(((fc) >> 2) & 0x3)
+#define	FC_SUBTYPE(fc)		(((fc) >> 4) & 0xF)
+#define	FC_TO_DS(fc)		((fc) & 0x0100)
+#define	FC_FROM_DS(fc)		((fc) & 0x0200)
+#define	FC_MORE_FLAG(fc)	((fc) & 0x0400)
+#define	FC_RETRY(fc)		((fc) & 0x0800)
+#define	FC_POWER_MGMT(fc)	((fc) & 0x1000)
+#define	FC_MORE_DATA(fc)	((fc) & 0x2000)
+#define	FC_WEP(fc)		((fc) & 0x4000)
+#define	FC_ORDER(fc)		((fc) & 0x8000)
+
+struct mgmt_header_t {
+	uint16_t	fc;
+	uint16_t 	duration;
+	uint8_t		da[6];
+	uint8_t		sa[6];
+	uint8_t		bssid[6];
+	uint16_t	seq_ctrl;
+};
+
+#define	MGMT_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+			 IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
+			 IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
+
+#define	CAPABILITY_ESS(cap)	((cap) & 0x0001)
+#define	CAPABILITY_IBSS(cap)	((cap) & 0x0002)
+#define	CAPABILITY_CFP(cap)	((cap) & 0x0004)
+#define	CAPABILITY_CFP_REQ(cap)	((cap) & 0x0008)
+#define	CAPABILITY_PRIVACY(cap)	((cap) & 0x0010)
+
+struct ssid_t {
+	uint8_t		element_id;
+	uint8_t		length;
+	u_char		ssid[33];  /* 32 + 1 for null */
+};
+
+struct rates_t {
+	uint8_t		element_id;
+	uint8_t		length;
+	uint8_t		rate[16];
+};
+
+struct challenge_t {
+	uint8_t		element_id;
+	uint8_t		length;
+	uint8_t		text[254]; /* 1-253 + 1 for null */
+};
+
+struct fh_t {
+	uint8_t		element_id;
+	uint8_t		length;
+	uint16_t	dwell_time;
+	uint8_t		hop_set;
+	uint8_t 	hop_pattern;
+	uint8_t		hop_index;
+};
+
+struct ds_t {
+	uint8_t		element_id;
+	uint8_t		length;
+	uint8_t		channel;
+};
+
+struct cf_t {
+	uint8_t		element_id;
+	uint8_t		length;
+	uint8_t		count;
+	uint8_t		period;
+	uint16_t	max_duration;
+	uint16_t	dur_remaing;
+};
+
+struct tim_t {
+	uint8_t		element_id;
+	uint8_t		length;
+	uint8_t		count;
+	uint8_t		period;
+	uint8_t		bitmap_control;
+	uint8_t		bitmap[251];
+};
+
+#define	E_SSID 		0
+#define	E_RATES 	1
+#define	E_FH	 	2
+#define	E_DS 		3
+#define	E_CF	 	4
+#define	E_TIM	 	5
+#define	E_IBSS 		6
+/* reserved 		7 */
+/* reserved 		8 */
+/* reserved 		9 */
+/* reserved 		10 */
+/* reserved 		11 */
+/* reserved 		12 */
+/* reserved 		13 */
+/* reserved 		14 */
+/* reserved 		15 */
+/* reserved 		16 */
+
+#define	E_CHALLENGE 	16
+/* reserved 		17 */
+/* reserved 		18 */
+/* reserved 		19 */
+/* reserved 		16 */
+/* reserved 		16 */
+
+
+struct mgmt_body_t {
+	uint8_t   	timestamp[IEEE802_11_TSTAMP_LEN];
+	uint16_t  	beacon_interval;
+	uint16_t 	listen_interval;
+	uint16_t 	status_code;
+	uint16_t 	aid;
+	u_char		ap[IEEE802_11_AP_LEN];
+	uint16_t	reason_code;
+	uint16_t	auth_alg;
+	uint16_t	auth_trans_seq_num;
+	int		challenge_present;
+	struct challenge_t  challenge;
+	uint16_t	capability_info;
+	int		ssid_present;
+	struct ssid_t	ssid;
+	int		rates_present;
+	struct rates_t 	rates;
+	int		ds_present;
+	struct ds_t	ds;
+	int		cf_present;
+	struct cf_t	cf;
+	int		fh_present;
+	struct fh_t	fh;
+	int		tim_present;
+	struct tim_t	tim;
+};
+
+struct ctrl_rts_t {
+	uint16_t	fc;
+	uint16_t	duration;
+	uint8_t		ra[6];
+	uint8_t		ta[6];
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_RTS_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+			 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
+
+struct ctrl_cts_t {
+	uint16_t	fc;
+	uint16_t	duration;
+	uint8_t		ra[6];
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_CTS_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_ack_t {
+	uint16_t	fc;
+	uint16_t	duration;
+	uint8_t		ra[6];
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_ACK_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_ps_poll_t {
+	uint16_t	fc;
+	uint16_t	aid;
+	uint8_t		bssid[6];
+	uint8_t		ta[6];
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_PS_POLL_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
+				 IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
+
+struct ctrl_end_t {
+	uint16_t	fc;
+	uint16_t	duration;
+	uint8_t		ra[6];
+	uint8_t		bssid[6];
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_END_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+			 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
+
+struct ctrl_end_ack_t {
+	uint16_t	fc;
+	uint16_t	duration;
+	uint8_t		ra[6];
+	uint8_t		bssid[6];
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_END_ACK_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+				 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
+
+struct ctrl_ba_t {
+	uint16_t	fc;
+	uint16_t	duration;
+	uint8_t		ra[6];
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_BA_HDRLEN	(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_bar_t {
+	uint16_t	fc;
+	uint16_t	dur;
+	uint8_t		ra[6];
+	uint8_t		ta[6];
+	uint16_t	ctl;
+	uint16_t	seq;
+	uint8_t		fcs[4];
+};
+
+#define	CTRL_BAR_HDRLEN		(IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+				 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
+				 IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
+
+struct meshcntl_t {
+	uint8_t		flags;
+	uint8_t		ttl;
+	uint8_t		seq[4];
+	uint8_t		addr4[6];
+	uint8_t		addr5[6];
+	uint8_t		addr6[6];
+};
+
+#define	IV_IV(iv)	((iv) & 0xFFFFFF)
+#define	IV_PAD(iv)	(((iv) >> 24) & 0x3F)
+#define	IV_KEYID(iv)	(((iv) >> 30) & 0x03)
+
+/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
+/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp  */
+
+/*-
+ * Copyright (c) 2003, 2004 David Young.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The name of David Young may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID
+ * YOUNG 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.
+ */
+
+/* A generic radio capture format is desirable. It must be
+ * rigidly defined (e.g., units for fields should be given),
+ * and easily extensible.
+ *
+ * The following is an extensible radio capture format. It is
+ * based on a bitmap indicating which fields are present.
+ *
+ * I am trying to describe precisely what the application programmer
+ * should expect in the following, and for that reason I tell the
+ * units and origin of each measurement (where it applies), or else I
+ * use sufficiently weaselly language ("is a monotonically nondecreasing
+ * function of...") that I cannot set false expectations for lawyerly
+ * readers.
+ */
+
+/*
+ * The radio capture header precedes the 802.11 header.
+ *
+ * Note well: all radiotap fields are little-endian.
+ */
+struct ieee80211_radiotap_header {
+	uint8_t		it_version;	/* Version 0. Only increases
+					 * for drastic changes,
+					 * introduction of compatible
+					 * new fields does not count.
+					 */
+	uint8_t		it_pad;
+	uint16_t       it_len;         /* length of the whole
+					 * header in bytes, including
+					 * it_version, it_pad,
+					 * it_len, and data fields.
+					 */
+	uint32_t       it_present;     /* A bitmap telling which
+					 * fields are present. Set bit 31
+					 * (0x80000000) to extend the
+					 * bitmap by another 32 bits.
+					 * Additional extensions are made
+					 * by setting bit 31.
+					 */
+};
+
+/* Name                                 Data type       Units
+ * ----                                 ---------       -----
+ *
+ * IEEE80211_RADIOTAP_TSFT              uint64_t       microseconds
+ *
+ *      Value in microseconds of the MAC's 64-bit 802.11 Time
+ *      Synchronization Function timer when the first bit of the
+ *      MPDU arrived at the MAC. For received frames, only.
+ *
+ * IEEE80211_RADIOTAP_CHANNEL           2 x uint16_t   MHz, bitmap
+ *
+ *      Tx/Rx frequency in MHz, followed by flags (see below).
+ *	Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
+ *	represent an HT channel as there is not enough room in
+ *	the flags word.
+ *
+ * IEEE80211_RADIOTAP_FHSS              uint16_t       see below
+ *
+ *      For frequency-hopping radios, the hop set (first byte)
+ *      and pattern (second byte).
+ *
+ * IEEE80211_RADIOTAP_RATE              uint8_t        500kb/s or index
+ *
+ *      Tx/Rx data rate.  If bit 0x80 is set then it represents an
+ *	an MCS index and not an IEEE rate.
+ *
+ * IEEE80211_RADIOTAP_DBM_ANTSIGNAL     int8_t          decibels from
+ *                                                      one milliwatt (dBm)
+ *
+ *      RF signal power at the antenna, decibel difference from
+ *      one milliwatt.
+ *
+ * IEEE80211_RADIOTAP_DBM_ANTNOISE      int8_t          decibels from
+ *                                                      one milliwatt (dBm)
+ *
+ *      RF noise power at the antenna, decibel difference from one
+ *      milliwatt.
+ *
+ * IEEE80211_RADIOTAP_DB_ANTSIGNAL      uint8_t        decibel (dB)
+ *
+ *      RF signal power at the antenna, decibel difference from an
+ *      arbitrary, fixed reference.
+ *
+ * IEEE80211_RADIOTAP_DB_ANTNOISE       uint8_t        decibel (dB)
+ *
+ *      RF noise power at the antenna, decibel difference from an
+ *      arbitrary, fixed reference point.
+ *
+ * IEEE80211_RADIOTAP_LOCK_QUALITY      uint16_t       unitless
+ *
+ *      Quality of Barker code lock. Unitless. Monotonically
+ *      nondecreasing with "better" lock strength. Called "Signal
+ *      Quality" in datasheets.  (Is there a standard way to measure
+ *      this?)
+ *
+ * IEEE80211_RADIOTAP_TX_ATTENUATION    uint16_t       unitless
+ *
+ *      Transmit power expressed as unitless distance from max
+ *      power set at factory calibration.  0 is max power.
+ *      Monotonically nondecreasing with lower power levels.
+ *
+ * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t       decibels (dB)
+ *
+ *      Transmit power expressed as decibel distance from max power
+ *      set at factory calibration.  0 is max power.  Monotonically
+ *      nondecreasing with lower power levels.
+ *
+ * IEEE80211_RADIOTAP_DBM_TX_POWER      int8_t          decibels from
+ *                                                      one milliwatt (dBm)
+ *
+ *      Transmit power expressed as dBm (decibels from a 1 milliwatt
+ *      reference). This is the absolute power level measured at
+ *      the antenna port.
+ *
+ * IEEE80211_RADIOTAP_FLAGS             uint8_t        bitmap
+ *
+ *      Properties of transmitted and received frames. See flags
+ *      defined below.
+ *
+ * IEEE80211_RADIOTAP_ANTENNA           uint8_t        antenna index
+ *
+ *      Unitless indication of the Rx/Tx antenna for this packet.
+ *      The first antenna is antenna 0.
+ *
+ * IEEE80211_RADIOTAP_RX_FLAGS          uint16_t       bitmap
+ *
+ *     Properties of received frames. See flags defined below.
+ *
+ * IEEE80211_RADIOTAP_XCHANNEL          uint32_t	bitmap
+ *					uint16_t	MHz
+ *					uint8_t		channel number
+ *					uint8_t		.5 dBm
+ *
+ *	Extended channel specification: flags (see below) followed by
+ *	frequency in MHz, the corresponding IEEE channel number, and
+ *	finally the maximum regulatory transmit power cap in .5 dBm
+ *	units.  This property supersedes IEEE80211_RADIOTAP_CHANNEL
+ *	and only one of the two should be present.
+ *
+ * IEEE80211_RADIOTAP_MCS		uint8_t		known
+ *					uint8_t		flags
+ *					uint8_t		mcs
+ *
+ *	Bitset indicating which fields have known values, followed
+ *	by bitset of flag values, followed by the MCS rate index as
+ *	in IEEE 802.11n.
+ *
+ * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
+ *					uint8_t  OUI[3]
+ *                                   uint8_t  subspace
+ *                                   uint16_t length
+ *
+ *     The Vendor Namespace Field contains three sub-fields. The first
+ *     sub-field is 3 bytes long. It contains the vendor's IEEE 802
+ *     Organizationally Unique Identifier (OUI). The fourth byte is a
+ *     vendor-specific "namespace selector."
+ *
+ */
+enum ieee80211_radiotap_type {
+	IEEE80211_RADIOTAP_TSFT = 0,
+	IEEE80211_RADIOTAP_FLAGS = 1,
+	IEEE80211_RADIOTAP_RATE = 2,
+	IEEE80211_RADIOTAP_CHANNEL = 3,
+	IEEE80211_RADIOTAP_FHSS = 4,
+	IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
+	IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
+	IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
+	IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
+	IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
+	IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
+	IEEE80211_RADIOTAP_ANTENNA = 11,
+	IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
+	IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
+	IEEE80211_RADIOTAP_RX_FLAGS = 14,
+	/* NB: gap for netbsd definitions */
+	IEEE80211_RADIOTAP_XCHANNEL = 18,
+	IEEE80211_RADIOTAP_MCS = 19,
+	IEEE80211_RADIOTAP_NAMESPACE = 29,
+	IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
+	IEEE80211_RADIOTAP_EXT = 31
+};
+
+/* channel attributes */
+#define	IEEE80211_CHAN_TURBO	0x00010	/* Turbo channel */
+#define	IEEE80211_CHAN_CCK	0x00020	/* CCK channel */
+#define	IEEE80211_CHAN_OFDM	0x00040	/* OFDM channel */
+#define	IEEE80211_CHAN_2GHZ	0x00080	/* 2 GHz spectrum channel. */
+#define	IEEE80211_CHAN_5GHZ	0x00100	/* 5 GHz spectrum channel */
+#define	IEEE80211_CHAN_PASSIVE	0x00200	/* Only passive scan allowed */
+#define	IEEE80211_CHAN_DYN	0x00400	/* Dynamic CCK-OFDM channel */
+#define	IEEE80211_CHAN_GFSK	0x00800	/* GFSK channel (FHSS PHY) */
+#define	IEEE80211_CHAN_GSM	0x01000	/* 900 MHz spectrum channel */
+#define	IEEE80211_CHAN_STURBO	0x02000	/* 11a static turbo channel only */
+#define	IEEE80211_CHAN_HALF	0x04000	/* Half rate channel */
+#define	IEEE80211_CHAN_QUARTER	0x08000	/* Quarter rate channel */
+#define	IEEE80211_CHAN_HT20	0x10000	/* HT 20 channel */
+#define	IEEE80211_CHAN_HT40U	0x20000	/* HT 40 channel w/ ext above */
+#define	IEEE80211_CHAN_HT40D	0x40000	/* HT 40 channel w/ ext below */
+
+/* Useful combinations of channel characteristics, borrowed from Ethereal */
+#define IEEE80211_CHAN_A \
+        (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+        (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_G \
+        (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_TA \
+        (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_TG \
+        (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN  | IEEE80211_CHAN_TURBO)
+
+
+/* For IEEE80211_RADIOTAP_FLAGS */
+#define	IEEE80211_RADIOTAP_F_CFP	0x01	/* sent/received
+						 * during CFP
+						 */
+#define	IEEE80211_RADIOTAP_F_SHORTPRE	0x02	/* sent/received
+						 * with short
+						 * preamble
+						 */
+#define	IEEE80211_RADIOTAP_F_WEP	0x04	/* sent/received
+						 * with WEP encryption
+						 */
+#define	IEEE80211_RADIOTAP_F_FRAG	0x08	/* sent/received
+						 * with fragmentation
+						 */
+#define	IEEE80211_RADIOTAP_F_FCS	0x10	/* frame includes FCS */
+#define	IEEE80211_RADIOTAP_F_DATAPAD	0x20	/* frame has padding between
+						 * 802.11 header and payload
+						 * (to 32-bit boundary)
+						 */
+#define	IEEE80211_RADIOTAP_F_BADFCS	0x40	/* does not pass FCS check */
+
+/* For IEEE80211_RADIOTAP_RX_FLAGS */
+#define IEEE80211_RADIOTAP_F_RX_BADFCS	0x0001	/* frame failed crc check */
+#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC	0x0002	/* frame failed PLCP CRC check */
+
+/* For IEEE80211_RADIOTAP_MCS known */
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN		0x01
+#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN		0x02	/* MCS index field */
+#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN	0x04
+#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN		0x08
+#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN		0x10
+#define IEEE80211_RADIOTAP_MCS_STBC_KNOWN		0x20
+
+/* For IEEE80211_RADIOTAP_MCS flags */
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK	0x03
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20	0
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40	1
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L	2
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U	3
+#define IEEE80211_RADIOTAP_MCS_SHORT_GI		0x04 /* short guard interval */
+#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD	0x08
+#define IEEE80211_RADIOTAP_MCS_FEC_LDPC		0x10
+#define IEEE80211_RADIOTAP_MCS_STBC_MASK	0x60
+#define		IEEE80211_RADIOTAP_MCS_STBC_1	1
+#define		IEEE80211_RADIOTAP_MCS_STBC_2	2
+#define		IEEE80211_RADIOTAP_MCS_STBC_3	3
+#define IEEE80211_RADIOTAP_MCS_STBC_SHIFT	5
+
+static const char tstr[] = "[|802.11]";
 
 /* Radiotap state */
 /*  This is used to save state when parsing/processing parameters */
 struct radiotap_state
 {
-	u_int32_t	present;
+	uint32_t	present;
 
-	u_int8_t	rate;
+	uint8_t		rate;
 };
 
 #define PRINT_SSID(p) \
 	if (p.ssid_present) { \
-		printf(" ("); \
-		fn_print(p.ssid.ssid, NULL); \
-		printf(")"); \
+		ND_PRINT((ndo, " (")); \
+		fn_print(ndo, p.ssid.ssid, NULL); \
+		ND_PRINT((ndo, ")")); \
 	}
 
 #define PRINT_RATE(_sep, _r, _suf) \
-	printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)
+	ND_PRINT((ndo, "%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf))
 #define PRINT_RATES(p) \
 	if (p.rates_present) { \
 		int z; \
@@ -74,14 +713,14 @@
 			sep = " "; \
 		} \
 		if (p.rates.length != 0) \
-			printf(" Mbit]"); \
+			ND_PRINT((ndo, " Mbit]")); \
 	}
 
 #define PRINT_DS_CHANNEL(p) \
 	if (p.ds_present) \
-		printf(" CH: %u", p.ds.channel); \
-	printf("%s", \
-	    CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" );
+		ND_PRINT((ndo, " CH: %u", p.ds.channel)); \
+	ND_PRINT((ndo, "%s", \
+	    CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : ""));
 
 #define MAX_MCS_INDEX	76
 
@@ -548,9 +1187,7 @@
 	"The request has not been successful as one or more parameters "
 	  "have invalid values",				/* 38 */
 	"The TS has not been created because the request cannot be honored. "
-	  "However, a suggested TSPEC is provided so that the initiating QSTA"
-	  "may attempt to set another TS with the suggested changes to the "
-	  "TSPEC",						/* 39 */
+	  "Try again with the suggested changes to the TSPEC",	/* 39 */
 	"Invalid Information Element",				/* 40 */
 	"Group Cipher is not valid",				/* 41 */
 	"Pairwise Cipher is not valid",				/* 42 */
@@ -637,23 +1274,25 @@
 #define NUM_REASONS	(sizeof reason_text / sizeof reason_text[0])
 
 static int
-wep_print(const u_char *p)
+wep_print(netdissect_options *ndo,
+          const u_char *p)
 {
-	u_int32_t iv;
+	uint32_t iv;
 
-	if (!TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN))
+	if (!ND_TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN))
 		return 0;
 	iv = EXTRACT_LE_32BITS(p);
 
-	printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
-	    IV_KEYID(iv));
+	ND_PRINT((ndo, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
+	    IV_KEYID(iv)));
 
 	return 1;
 }
 
 static int
-parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
-    u_int length)
+parse_elements(netdissect_options *ndo,
+               struct mgmt_body_t *pbody, const u_char *p, int offset,
+               u_int length)
 {
 	u_int elementlen;
 	struct ssid_t ssid;
@@ -674,23 +1313,28 @@
 	pbody->tim_present = 0;
 
 	while (length != 0) {
-		if (!TTEST2(*(p + offset), 1))
+		/* Make sure we at least have the element ID and length. */
+		if (!ND_TTEST2(*(p + offset), 2))
 			return 0;
-		if (length < 1)
+		if (length < 2)
 			return 0;
+		elementlen = *(p + offset + 1);
+
+		/* Make sure we have the entire element. */
+		if (!ND_TTEST2(*(p + offset + 2), elementlen))
+			return 0;
+		if (length < elementlen + 2)
+			return 0;
+
 		switch (*(p + offset)) {
 		case E_SSID:
-			if (!TTEST2(*(p + offset), 2))
-				return 0;
-			if (length < 2)
-				return 0;
 			memcpy(&ssid, p + offset, 2);
 			offset += 2;
 			length -= 2;
 			if (ssid.length != 0) {
 				if (ssid.length > sizeof(ssid.ssid) - 1)
 					return 0;
-				if (!TTEST2(*(p + offset), ssid.length))
+				if (!ND_TTEST2(*(p + offset), ssid.length))
 					return 0;
 				if (length < ssid.length)
 					return 0;
@@ -712,10 +1356,6 @@
 			}
 			break;
 		case E_CHALLENGE:
-			if (!TTEST2(*(p + offset), 2))
-				return 0;
-			if (length < 2)
-				return 0;
 			memcpy(&challenge, p + offset, 2);
 			offset += 2;
 			length -= 2;
@@ -723,7 +1363,7 @@
 				if (challenge.length >
 				    sizeof(challenge.text) - 1)
 					return 0;
-				if (!TTEST2(*(p + offset), challenge.length))
+				if (!ND_TTEST2(*(p + offset), challenge.length))
 					return 0;
 				if (length < challenge.length)
 					return 0;
@@ -746,17 +1386,13 @@
 			}
 			break;
 		case E_RATES:
-			if (!TTEST2(*(p + offset), 2))
-				return 0;
-			if (length < 2)
-				return 0;
 			memcpy(&rates, p + offset, 2);
 			offset += 2;
 			length -= 2;
 			if (rates.length != 0) {
 				if (rates.length > sizeof rates.rate)
 					return 0;
-				if (!TTEST2(*(p + offset), rates.length))
+				if (!ND_TTEST2(*(p + offset), rates.length))
 					return 0;
 				if (length < rates.length)
 					return 0;
@@ -786,13 +1422,17 @@
 			}
 			break;
 		case E_DS:
-			if (!TTEST2(*(p + offset), 3))
-				return 0;
-			if (length < 3)
-				return 0;
-			memcpy(&ds, p + offset, 3);
-			offset += 3;
-			length -= 3;
+			memcpy(&ds, p + offset, 2);
+			offset += 2;
+			length -= 2;
+			if (ds.length != 1) {
+				offset += ds.length;
+				length -= ds.length;
+				break;
+			}
+			ds.channel = *(p + offset);
+			offset += 1;
+			length -= 1;
 			/*
 			 * Present and not truncated.
 			 *
@@ -806,13 +1446,17 @@
 			}
 			break;
 		case E_CF:
-			if (!TTEST2(*(p + offset), 8))
-				return 0;
-			if (length < 8)
-				return 0;
-			memcpy(&cf, p + offset, 8);
-			offset += 8;
-			length -= 8;
+			memcpy(&cf, p + offset, 2);
+			offset += 2;
+			length -= 2;
+			if (cf.length != 6) {
+				offset += cf.length;
+				length -= cf.length;
+				break;
+			}
+			memcpy(&cf.count, p + offset, 6);
+			offset += 6;
+			length -= 6;
 			/*
 			 * Present and not truncated.
 			 *
@@ -826,29 +1470,20 @@
 			}
 			break;
 		case E_TIM:
-			if (!TTEST2(*(p + offset), 2))
-				return 0;
-			if (length < 2)
-				return 0;
 			memcpy(&tim, p + offset, 2);
 			offset += 2;
 			length -= 2;
-			if (!TTEST2(*(p + offset), 3))
-				return 0;
-			if (length < 3)
+			if (tim.length <= 3) {
+				offset += tim.length;
+				length -= tim.length;
+				break;
+			}
+			if (tim.length - 3 > (int)sizeof tim.bitmap)
 				return 0;
 			memcpy(&tim.count, p + offset, 3);
 			offset += 3;
 			length -= 3;
 
-			if (tim.length <= 3)
-				break;
-			if (tim.length - 3 > (int)sizeof tim.bitmap)
-				return 0;
-			if (!TTEST2(*(p + offset), tim.length - 3))
-				return 0;
-			if (length < (u_int)(tim.length - 3))
-				return 0;
 			memcpy(tim.bitmap, p + (tim.length - 3),
 			    (tim.length - 3));
 			offset += tim.length - 3;
@@ -867,20 +1502,11 @@
 			break;
 		default:
 #if 0
-			printf("(1) unhandled element_id (%d)  ",
-			    *(p + offset));
+			ND_PRINT((ndo, "(1) unhandled element_id (%d)  ",
+			    *(p + offset)));
 #endif
-			if (!TTEST2(*(p + offset), 2))
-				return 0;
-			if (length < 2)
-				return 0;
-			elementlen = *(p + offset + 1);
-			if (!TTEST2(*(p + offset + 2), elementlen))
-				return 0;
-			if (length < elementlen + 2)
-				return 0;
-			offset += elementlen + 2;
-			length -= elementlen + 2;
+			offset += 2 + elementlen;
+			length -= 2 + elementlen;
 			break;
 		}
 	}
@@ -894,7 +1520,8 @@
  *********************************************************************************/
 
 static int
-handle_beacon(const u_char *p, u_int length)
+handle_beacon(netdissect_options *ndo,
+              const u_char *p, u_int length)
 {
 	struct mgmt_body_t pbody;
 	int offset = 0;
@@ -902,7 +1529,7 @@
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+	if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
 	    IEEE802_11_CAPINFO_LEN))
 		return 0;
 	if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
@@ -918,19 +1545,20 @@
 	offset += IEEE802_11_CAPINFO_LEN;
 	length -= IEEE802_11_CAPINFO_LEN;
 
-	ret = parse_elements(&pbody, p, offset, length);
+	ret = parse_elements(ndo, &pbody, p, offset, length);
 
 	PRINT_SSID(pbody);
 	PRINT_RATES(pbody);
-	printf(" %s",
-	    CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS");
+	ND_PRINT((ndo, " %s",
+	    CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"));
 	PRINT_DS_CHANNEL(pbody);
 
 	return ret;
 }
 
 static int
-handle_assoc_request(const u_char *p, u_int length)
+handle_assoc_request(netdissect_options *ndo,
+                     const u_char *p, u_int length)
 {
 	struct mgmt_body_t pbody;
 	int offset = 0;
@@ -938,7 +1566,7 @@
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
+	if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
 		return 0;
 	if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)
 		return 0;
@@ -949,7 +1577,7 @@
 	offset += IEEE802_11_LISTENINT_LEN;
 	length -= IEEE802_11_LISTENINT_LEN;
 
-	ret = parse_elements(&pbody, p, offset, length);
+	ret = parse_elements(ndo, &pbody, p, offset, length);
 
 	PRINT_SSID(pbody);
 	PRINT_RATES(pbody);
@@ -957,7 +1585,8 @@
 }
 
 static int
-handle_assoc_response(const u_char *p, u_int length)
+handle_assoc_response(netdissect_options *ndo,
+                      const u_char *p, u_int length)
 {
 	struct mgmt_body_t pbody;
 	int offset = 0;
@@ -965,7 +1594,7 @@
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
+	if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
 	    IEEE802_11_AID_LEN))
 		return 0;
 	if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
@@ -981,19 +1610,20 @@
 	offset += IEEE802_11_AID_LEN;
 	length -= IEEE802_11_AID_LEN;
 
-	ret = parse_elements(&pbody, p, offset, length);
+	ret = parse_elements(ndo, &pbody, p, offset, length);
 
-	printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 ,
+	ND_PRINT((ndo, " AID(%x) :%s: %s", ((uint16_t)(pbody.aid << 2 )) >> 2 ,
 	    CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
 	    (pbody.status_code < NUM_STATUSES
 		? status_text[pbody.status_code]
-		: "n/a"));
+		: "n/a")));
 
 	return ret;
 }
 
 static int
-handle_reassoc_request(const u_char *p, u_int length)
+handle_reassoc_request(netdissect_options *ndo,
+                       const u_char *p, u_int length)
 {
 	struct mgmt_body_t pbody;
 	int offset = 0;
@@ -1001,7 +1631,7 @@
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
+	if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
 	    IEEE802_11_AP_LEN))
 		return 0;
 	if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
@@ -1017,23 +1647,25 @@
 	offset += IEEE802_11_AP_LEN;
 	length -= IEEE802_11_AP_LEN;
 
-	ret = parse_elements(&pbody, p, offset, length);
+	ret = parse_elements(ndo, &pbody, p, offset, length);
 
 	PRINT_SSID(pbody);
-	printf(" AP : %s", etheraddr_string( pbody.ap ));
+	ND_PRINT((ndo, " AP : %s", etheraddr_string(ndo,  pbody.ap )));
 
 	return ret;
 }
 
 static int
-handle_reassoc_response(const u_char *p, u_int length)
+handle_reassoc_response(netdissect_options *ndo,
+                        const u_char *p, u_int length)
 {
 	/* Same as a Association Reponse */
-	return handle_assoc_response(p, length);
+	return handle_assoc_response(ndo, p, length);
 }
 
 static int
-handle_probe_request(const u_char *p, u_int length)
+handle_probe_request(netdissect_options *ndo,
+                     const u_char *p, u_int length)
 {
 	struct mgmt_body_t  pbody;
 	int offset = 0;
@@ -1041,7 +1673,7 @@
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	ret = parse_elements(&pbody, p, offset, length);
+	ret = parse_elements(ndo, &pbody, p, offset, length);
 
 	PRINT_SSID(pbody);
 	PRINT_RATES(pbody);
@@ -1050,7 +1682,8 @@
 }
 
 static int
-handle_probe_response(const u_char *p, u_int length)
+handle_probe_response(netdissect_options *ndo,
+                      const u_char *p, u_int length)
 {
 	struct mgmt_body_t  pbody;
 	int offset = 0;
@@ -1058,7 +1691,7 @@
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+	if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
 	    IEEE802_11_CAPINFO_LEN))
 		return 0;
 	if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
@@ -1074,7 +1707,7 @@
 	offset += IEEE802_11_CAPINFO_LEN;
 	length -= IEEE802_11_CAPINFO_LEN;
 
-	ret = parse_elements(&pbody, p, offset, length);
+	ret = parse_elements(ndo, &pbody, p, offset, length);
 
 	PRINT_SSID(pbody);
 	PRINT_RATES(pbody);
@@ -1091,28 +1724,30 @@
 }
 
 static int
-handle_disassoc(const u_char *p, u_int length)
+handle_disassoc(netdissect_options *ndo,
+                const u_char *p, u_int length)
 {
 	struct mgmt_body_t  pbody;
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, IEEE802_11_REASON_LEN))
+	if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN))
 		return 0;
 	if (length < IEEE802_11_REASON_LEN)
 		return 0;
 	pbody.reason_code = EXTRACT_LE_16BITS(p);
 
-	printf(": %s",
+	ND_PRINT((ndo, ": %s",
 	    (pbody.reason_code < NUM_REASONS)
 		? reason_text[pbody.reason_code]
-		: "Reserved" );
+		: "Reserved"));
 
 	return 1;
 }
 
 static int
-handle_auth(const u_char *p, u_int length)
+handle_auth(netdissect_options *ndo,
+            const u_char *p, u_int length)
 {
 	struct mgmt_body_t  pbody;
 	int offset = 0;
@@ -1120,7 +1755,7 @@
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, 6))
+	if (!ND_TTEST2(*p, 6))
 		return 0;
 	if (length < 6)
 		return 0;
@@ -1134,12 +1769,12 @@
 	offset += 2;
 	length -= 2;
 
-	ret = parse_elements(&pbody, p, offset, length);
+	ret = parse_elements(ndo, &pbody, p, offset, length);
 
 	if ((pbody.auth_alg == 1) &&
 	    ((pbody.auth_trans_seq_num == 2) ||
 	     (pbody.auth_trans_seq_num == 3))) {
-		printf(" (%s)-%x [Challenge Text] %s",
+		ND_PRINT((ndo, " (%s)-%x [Challenge Text] %s",
 		    (pbody.auth_alg < NUM_AUTH_ALGS)
 			? auth_alg_text[pbody.auth_alg]
 			: "Reserved",
@@ -1147,10 +1782,10 @@
 		    ((pbody.auth_trans_seq_num % 2)
 		        ? ((pbody.status_code < NUM_STATUSES)
 			       ? status_text[pbody.status_code]
-			       : "n/a") : ""));
+			       : "n/a") : "")));
 		return ret;
 	}
-	printf(" (%s)-%x: %s",
+	ND_PRINT((ndo, " (%s)-%x: %s",
 	    (pbody.auth_alg < NUM_AUTH_ALGS)
 		? auth_alg_text[pbody.auth_alg]
 		: "Reserved",
@@ -1159,126 +1794,125 @@
 	        ? ((pbody.status_code < NUM_STATUSES)
 		    ? status_text[pbody.status_code]
 	            : "n/a")
-	        : "");
+	        : ""));
 
 	return ret;
 }
 
 static int
-handle_deauth(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+handle_deauth(netdissect_options *ndo,
+              const struct mgmt_header_t *pmh, const u_char *p, u_int length)
 {
 	struct mgmt_body_t  pbody;
-	int offset = 0;
 	const char *reason = NULL;
 
 	memset(&pbody, 0, sizeof(pbody));
 
-	if (!TTEST2(*p, IEEE802_11_REASON_LEN))
+	if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN))
 		return 0;
 	if (length < IEEE802_11_REASON_LEN)
 		return 0;
 	pbody.reason_code = EXTRACT_LE_16BITS(p);
-	offset += IEEE802_11_REASON_LEN;
-	length -= IEEE802_11_REASON_LEN;
 
 	reason = (pbody.reason_code < NUM_REASONS)
 			? reason_text[pbody.reason_code]
 			: "Reserved";
 
-	if (eflag) {
-		printf(": %s", reason);
+	if (ndo->ndo_eflag) {
+		ND_PRINT((ndo, ": %s", reason));
 	} else {
-		printf(" (%s): %s", etheraddr_string(pmh->sa), reason);
+		ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, pmh->sa), reason));
 	}
 	return 1;
 }
 
 #define	PRINT_HT_ACTION(v) (\
-	(v) == 0 ? printf("TxChWidth") : \
-	(v) == 1 ? printf("MIMOPwrSave") : \
-		   printf("Act#%d", (v)) \
+	(v) == 0 ? ND_PRINT((ndo, "TxChWidth")) : \
+	(v) == 1 ? ND_PRINT((ndo, "MIMOPwrSave")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 #define	PRINT_BA_ACTION(v) (\
-	(v) == 0 ? printf("ADDBA Request") : \
-	(v) == 1 ? printf("ADDBA Response") : \
-	(v) == 2 ? printf("DELBA") : \
-		   printf("Act#%d", (v)) \
+	(v) == 0 ? ND_PRINT((ndo, "ADDBA Request")) : \
+	(v) == 1 ? ND_PRINT((ndo, "ADDBA Response")) : \
+	(v) == 2 ? ND_PRINT((ndo, "DELBA")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 #define	PRINT_MESHLINK_ACTION(v) (\
-	(v) == 0 ? printf("Request") : \
-	(v) == 1 ? printf("Report") : \
-		   printf("Act#%d", (v)) \
+	(v) == 0 ? ND_PRINT((ndo, "Request")) : \
+	(v) == 1 ? ND_PRINT((ndo, "Report")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 #define	PRINT_MESHPEERING_ACTION(v) (\
-	(v) == 0 ? printf("Open") : \
-	(v) == 1 ? printf("Confirm") : \
-	(v) == 2 ? printf("Close") : \
-		   printf("Act#%d", (v)) \
+	(v) == 0 ? ND_PRINT((ndo, "Open")) : \
+	(v) == 1 ? ND_PRINT((ndo, "Confirm")) : \
+	(v) == 2 ? ND_PRINT((ndo, "Close")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 #define	PRINT_MESHPATH_ACTION(v) (\
-	(v) == 0 ? printf("Request") : \
-	(v) == 1 ? printf("Report") : \
-	(v) == 2 ? printf("Error") : \
-	(v) == 3 ? printf("RootAnnouncement") : \
-		   printf("Act#%d", (v)) \
+	(v) == 0 ? ND_PRINT((ndo, "Request")) : \
+	(v) == 1 ? ND_PRINT((ndo, "Report")) : \
+	(v) == 2 ? ND_PRINT((ndo, "Error")) : \
+	(v) == 3 ? ND_PRINT((ndo, "RootAnnouncement")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 
 #define PRINT_MESH_ACTION(v) (\
-	(v) == 0 ? printf("MeshLink") : \
-	(v) == 1 ? printf("HWMP") : \
-	(v) == 2 ? printf("Gate Announcement") : \
-	(v) == 3 ? printf("Congestion Control") : \
-	(v) == 4 ? printf("MCCA Setup Request") : \
-	(v) == 5 ? printf("MCCA Setup Reply") : \
-	(v) == 6 ? printf("MCCA Advertisement Request") : \
-	(v) == 7 ? printf("MCCA Advertisement") : \
-	(v) == 8 ? printf("MCCA Teardown") : \
-	(v) == 9 ? printf("TBTT Adjustment Request") : \
-	(v) == 10 ? printf("TBTT Adjustment Response") : \
-		   printf("Act#%d", (v)) \
+	(v) == 0 ? ND_PRINT((ndo, "MeshLink")) : \
+	(v) == 1 ? ND_PRINT((ndo, "HWMP")) : \
+	(v) == 2 ? ND_PRINT((ndo, "Gate Announcement")) : \
+	(v) == 3 ? ND_PRINT((ndo, "Congestion Control")) : \
+	(v) == 4 ? ND_PRINT((ndo, "MCCA Setup Request")) : \
+	(v) == 5 ? ND_PRINT((ndo, "MCCA Setup Reply")) : \
+	(v) == 6 ? ND_PRINT((ndo, "MCCA Advertisement Request")) : \
+	(v) == 7 ? ND_PRINT((ndo, "MCCA Advertisement")) : \
+	(v) == 8 ? ND_PRINT((ndo, "MCCA Teardown")) : \
+	(v) == 9 ? ND_PRINT((ndo, "TBTT Adjustment Request")) : \
+	(v) == 10 ? ND_PRINT((ndo, "TBTT Adjustment Response")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 #define PRINT_MULTIHOP_ACTION(v) (\
-	(v) == 0 ? printf("Proxy Update") : \
-	(v) == 1 ? printf("Proxy Update Confirmation") : \
-		   printf("Act#%d", (v)) \
+	(v) == 0 ? ND_PRINT((ndo, "Proxy Update")) : \
+	(v) == 1 ? ND_PRINT((ndo, "Proxy Update Confirmation")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 #define PRINT_SELFPROT_ACTION(v) (\
-	(v) == 1 ? printf("Peering Open") : \
-	(v) == 2 ? printf("Peering Confirm") : \
-	(v) == 3 ? printf("Peering Close") : \
-	(v) == 4 ? printf("Group Key Inform") : \
-	(v) == 5 ? printf("Group Key Acknowledge") : \
-		   printf("Act#%d", (v)) \
+	(v) == 1 ? ND_PRINT((ndo, "Peering Open")) : \
+	(v) == 2 ? ND_PRINT((ndo, "Peering Confirm")) : \
+	(v) == 3 ? ND_PRINT((ndo, "Peering Close")) : \
+	(v) == 4 ? ND_PRINT((ndo, "Group Key Inform")) : \
+	(v) == 5 ? ND_PRINT((ndo, "Group Key Acknowledge")) : \
+		   ND_PRINT((ndo, "Act#%d", (v))) \
 )
 
 static int
-handle_action(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+handle_action(netdissect_options *ndo,
+              const struct mgmt_header_t *pmh, const u_char *p, u_int length)
 {
-	if (!TTEST2(*p, 2))
+	if (!ND_TTEST2(*p, 2))
 		return 0;
 	if (length < 2)
 		return 0;
-	if (eflag) {
-		printf(": ");
+	if (ndo->ndo_eflag) {
+		ND_PRINT((ndo, ": "));
 	} else {
-		printf(" (%s): ", etheraddr_string(pmh->sa));
+		ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, pmh->sa)));
 	}
 	switch (p[0]) {
-	case 0: printf("Spectrum Management Act#%d", p[1]); break;
-	case 1: printf("QoS Act#%d", p[1]); break;
-	case 2: printf("DLS Act#%d", p[1]); break;
-	case 3: printf("BA "); PRINT_BA_ACTION(p[1]); break;
-	case 7: printf("HT "); PRINT_HT_ACTION(p[1]); break;
-	case 13: printf("MeshAction "); PRINT_MESH_ACTION(p[1]); break;
+	case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break;
+	case 1: ND_PRINT((ndo, "QoS Act#%d", p[1])); break;
+	case 2: ND_PRINT((ndo, "DLS Act#%d", p[1])); break;
+	case 3: ND_PRINT((ndo, "BA ")); PRINT_BA_ACTION(p[1]); break;
+	case 7: ND_PRINT((ndo, "HT ")); PRINT_HT_ACTION(p[1]); break;
+	case 13: ND_PRINT((ndo, "MeshAction ")); PRINT_MESH_ACTION(p[1]); break;
 	case 14:
-		printf("MultiohopAction ");
+		ND_PRINT((ndo, "MultiohopAction "));
 		PRINT_MULTIHOP_ACTION(p[1]); break;
 	case 15:
-		printf("SelfprotectAction ");
+		ND_PRINT((ndo, "SelfprotectAction "));
 		PRINT_SELFPROT_ACTION(p[1]); break;
-	case 127: printf("Vendor Act#%d", p[1]); break;
+	case 127: ND_PRINT((ndo, "Vendor Act#%d", p[1])); break;
 	default:
-		printf("Reserved(%d) Act#%d", p[0], p[1]);
+		ND_PRINT((ndo, "Reserved(%d) Act#%d", p[0], p[1]));
 		break;
 	}
 	return 1;
@@ -1291,57 +1925,43 @@
 
 
 static int
-mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
-    const u_char *p, u_int length)
+mgmt_body_print(netdissect_options *ndo,
+                uint16_t fc, const struct mgmt_header_t *pmh,
+                const u_char *p, u_int length)
 {
+	ND_PRINT((ndo, "%s", tok2str(st_str, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc))));
 	switch (FC_SUBTYPE(fc)) {
 	case ST_ASSOC_REQUEST:
-		printf("Assoc Request");
-		return handle_assoc_request(p, length);
+		return handle_assoc_request(ndo, p, length);
 	case ST_ASSOC_RESPONSE:
-		printf("Assoc Response");
-		return handle_assoc_response(p, length);
+		return handle_assoc_response(ndo, p, length);
 	case ST_REASSOC_REQUEST:
-		printf("ReAssoc Request");
-		return handle_reassoc_request(p, length);
+		return handle_reassoc_request(ndo, p, length);
 	case ST_REASSOC_RESPONSE:
-		printf("ReAssoc Response");
-		return handle_reassoc_response(p, length);
+		return handle_reassoc_response(ndo, p, length);
 	case ST_PROBE_REQUEST:
-		printf("Probe Request");
-		return handle_probe_request(p, length);
+		return handle_probe_request(ndo, p, length);
 	case ST_PROBE_RESPONSE:
-		printf("Probe Response");
-		return handle_probe_response(p, length);
+		return handle_probe_response(ndo, p, length);
 	case ST_BEACON:
-		printf("Beacon");
-		return handle_beacon(p, length);
+		return handle_beacon(ndo, p, length);
 	case ST_ATIM:
-		printf("ATIM");
 		return handle_atim();
 	case ST_DISASSOC:
-		printf("Disassociation");
-		return handle_disassoc(p, length);
+		return handle_disassoc(ndo, p, length);
 	case ST_AUTH:
-		printf("Authentication");
-		if (!TTEST2(*p, 3))
+		if (!ND_TTEST2(*p, 3))
 			return 0;
 		if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
-			printf("Authentication (Shared-Key)-3 ");
-			return wep_print(p);
+			ND_PRINT((ndo, "Authentication (Shared-Key)-3 "));
+			return wep_print(ndo, p);
 		}
-		return handle_auth(p, length);
+		return handle_auth(ndo, p, length);
 	case ST_DEAUTH:
-		printf("DeAuthentication");
-		return handle_deauth(pmh, p, length);
-		break;
+		return handle_deauth(ndo, pmh, p, length);
 	case ST_ACTION:
-		printf("Action");
-		return handle_action(pmh, p, length);
-		break;
+		return handle_action(ndo, pmh, p, length);
 	default:
-		printf("Unhandled Management subtype(%x)",
-		    FC_SUBTYPE(fc));
 		return 1;
 	}
 }
@@ -1352,81 +1972,72 @@
  *********************************************************************************/
 
 static int
-ctrl_body_print(u_int16_t fc, const u_char *p)
+ctrl_body_print(netdissect_options *ndo,
+                uint16_t fc, const u_char *p)
 {
+	ND_PRINT((ndo, "%s", tok2str(ctrl_str, "Unknown Ctrl Subtype", FC_SUBTYPE(fc))));
 	switch (FC_SUBTYPE(fc)) {
 	case CTRL_CONTROL_WRAPPER:
-		printf("Control Wrapper");
 		/* XXX - requires special handling */
 		break;
 	case CTRL_BAR:
-		printf("BAR");
-		if (!TTEST2(*p, CTRL_BAR_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_BAR_HDRLEN))
 			return 0;
-		if (!eflag)
-			printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
-			    etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
-			    etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
+			    etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ra),
+			    etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ta),
 			    EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
-			    EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+			    EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))));
 		break;
 	case CTRL_BA:
-		printf("BA");
-		if (!TTEST2(*p, CTRL_BA_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_BA_HDRLEN))
 			return 0;
-		if (!eflag)
-			printf(" RA:%s ",
-			    etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, " RA:%s ",
+			    etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
 		break;
 	case CTRL_PS_POLL:
-		printf("Power Save-Poll");
-		if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_PS_POLL_HDRLEN))
 			return 0;
-		printf(" AID(%x)",
-		    EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid)));
+		ND_PRINT((ndo, " AID(%x)",
+		    EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))));
 		break;
 	case CTRL_RTS:
-		printf("Request-To-Send");
-		if (!TTEST2(*p, CTRL_RTS_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_RTS_HDRLEN))
 			return 0;
-		if (!eflag)
-			printf(" TA:%s ",
-			    etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, " TA:%s ",
+			    etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
 		break;
 	case CTRL_CTS:
-		printf("Clear-To-Send");
-		if (!TTEST2(*p, CTRL_CTS_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_CTS_HDRLEN))
 			return 0;
-		if (!eflag)
-			printf(" RA:%s ",
-			    etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, " RA:%s ",
+			    etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
 		break;
 	case CTRL_ACK:
-		printf("Acknowledgment");
-		if (!TTEST2(*p, CTRL_ACK_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_ACK_HDRLEN))
 			return 0;
-		if (!eflag)
-			printf(" RA:%s ",
-			    etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, " RA:%s ",
+			    etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
 		break;
 	case CTRL_CF_END:
-		printf("CF-End");
-		if (!TTEST2(*p, CTRL_END_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_END_HDRLEN))
 			return 0;
-		if (!eflag)
-			printf(" RA:%s ",
-			    etheraddr_string(((const struct ctrl_end_t *)p)->ra));
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, " RA:%s ",
+			    etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra)));
 		break;
 	case CTRL_END_ACK:
-		printf("CF-End+CF-Ack");
-		if (!TTEST2(*p, CTRL_END_ACK_HDRLEN))
+		if (!ND_TTEST2(*p, CTRL_END_ACK_HDRLEN))
 			return 0;
-		if (!eflag)
-			printf(" RA:%s ",
-			    etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra));
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, " RA:%s ",
+			    etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra)));
 		break;
-	default:
-		printf("Unknown Ctrl Subtype");
 	}
 	return 1;
 }
@@ -1446,26 +2057,27 @@
  */
 
 static void
-data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
-    const u_int8_t **dstp)
+data_header_print(netdissect_options *ndo,
+                  uint16_t fc, const u_char *p, const uint8_t **srcp,
+                  const uint8_t **dstp)
 {
 	u_int subtype = FC_SUBTYPE(fc);
 
 	if (DATA_FRAME_IS_CF_ACK(subtype) || DATA_FRAME_IS_CF_POLL(subtype) ||
 	    DATA_FRAME_IS_QOS(subtype)) {
-		printf("CF ");
+		ND_PRINT((ndo, "CF "));
 		if (DATA_FRAME_IS_CF_ACK(subtype)) {
 			if (DATA_FRAME_IS_CF_POLL(subtype))
-				printf("Ack/Poll");
+				ND_PRINT((ndo, "Ack/Poll"));
 			else
-				printf("Ack");
+				ND_PRINT((ndo, "Ack"));
 		} else {
 			if (DATA_FRAME_IS_CF_POLL(subtype))
-				printf("Poll");
+				ND_PRINT((ndo, "Poll"));
 		}
 		if (DATA_FRAME_IS_QOS(subtype))
-			printf("+QoS");
-		printf(" ");
+			ND_PRINT((ndo, "+QoS"));
+		ND_PRINT((ndo, " "));
 	}
 
 #define ADDR1  (p + 4)
@@ -1478,41 +2090,41 @@
 			*srcp = ADDR2;
 		if (dstp != NULL)
 			*dstp = ADDR1;
-		if (!eflag)
+		if (!ndo->ndo_eflag)
 			return;
-		printf("DA:%s SA:%s BSSID:%s ",
-		    etheraddr_string(ADDR1), etheraddr_string(ADDR2),
-		    etheraddr_string(ADDR3));
+		ND_PRINT((ndo, "DA:%s SA:%s BSSID:%s ",
+		    etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+		    etheraddr_string(ndo, ADDR3)));
 	} else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) {
 		if (srcp != NULL)
 			*srcp = ADDR3;
 		if (dstp != NULL)
 			*dstp = ADDR1;
-		if (!eflag)
+		if (!ndo->ndo_eflag)
 			return;
-		printf("DA:%s BSSID:%s SA:%s ",
-		    etheraddr_string(ADDR1), etheraddr_string(ADDR2),
-		    etheraddr_string(ADDR3));
+		ND_PRINT((ndo, "DA:%s BSSID:%s SA:%s ",
+		    etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+		    etheraddr_string(ndo, ADDR3)));
 	} else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
 		if (srcp != NULL)
 			*srcp = ADDR2;
 		if (dstp != NULL)
 			*dstp = ADDR3;
-		if (!eflag)
+		if (!ndo->ndo_eflag)
 			return;
-		printf("BSSID:%s SA:%s DA:%s ",
-		    etheraddr_string(ADDR1), etheraddr_string(ADDR2),
-		    etheraddr_string(ADDR3));
+		ND_PRINT((ndo, "BSSID:%s SA:%s DA:%s ",
+		    etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+		    etheraddr_string(ndo, ADDR3)));
 	} else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) {
 		if (srcp != NULL)
 			*srcp = ADDR4;
 		if (dstp != NULL)
 			*dstp = ADDR3;
-		if (!eflag)
+		if (!ndo->ndo_eflag)
 			return;
-		printf("RA:%s TA:%s DA:%s SA:%s ",
-		    etheraddr_string(ADDR1), etheraddr_string(ADDR2),
-		    etheraddr_string(ADDR3), etheraddr_string(ADDR4));
+		ND_PRINT((ndo, "RA:%s TA:%s DA:%s SA:%s ",
+		    etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+		    etheraddr_string(ndo, ADDR3), etheraddr_string(ndo, ADDR4)));
 	}
 
 #undef ADDR1
@@ -1522,8 +2134,8 @@
 }
 
 static void
-mgmt_header_print(const u_char *p, const u_int8_t **srcp,
-    const u_int8_t **dstp)
+mgmt_header_print(netdissect_options *ndo,
+                  const u_char *p, const uint8_t **srcp, const uint8_t **dstp)
 {
 	const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
 
@@ -1531,73 +2143,75 @@
 		*srcp = hp->sa;
 	if (dstp != NULL)
 		*dstp = hp->da;
-	if (!eflag)
+	if (!ndo->ndo_eflag)
 		return;
 
-	printf("BSSID:%s DA:%s SA:%s ",
-	    etheraddr_string((hp)->bssid), etheraddr_string((hp)->da),
-	    etheraddr_string((hp)->sa));
+	ND_PRINT((ndo, "BSSID:%s DA:%s SA:%s ",
+	    etheraddr_string(ndo, (hp)->bssid), etheraddr_string(ndo, (hp)->da),
+	    etheraddr_string(ndo, (hp)->sa)));
 }
 
 static void
-ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
-    const u_int8_t **dstp)
+ctrl_header_print(netdissect_options *ndo,
+                  uint16_t fc, const u_char *p, const uint8_t **srcp,
+                  const uint8_t **dstp)
 {
 	if (srcp != NULL)
 		*srcp = NULL;
 	if (dstp != NULL)
 		*dstp = NULL;
-	if (!eflag)
+	if (!ndo->ndo_eflag)
 		return;
 
 	switch (FC_SUBTYPE(fc)) {
 	case CTRL_BAR:
-		printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
-		    etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
-		    etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
+		ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
+		    etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ra),
+		    etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ta),
 		    EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
-		    EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+		    EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))));
 		break;
 	case CTRL_BA:
-		printf("RA:%s ",
-		    etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+		ND_PRINT((ndo, "RA:%s ",
+		    etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
 		break;
 	case CTRL_PS_POLL:
-		printf("BSSID:%s TA:%s ",
-		    etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
-		    etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta));
+		ND_PRINT((ndo, "BSSID:%s TA:%s ",
+		    etheraddr_string(ndo, ((const struct ctrl_ps_poll_t *)p)->bssid),
+		    etheraddr_string(ndo, ((const struct ctrl_ps_poll_t *)p)->ta)));
 		break;
 	case CTRL_RTS:
-		printf("RA:%s TA:%s ",
-		    etheraddr_string(((const struct ctrl_rts_t *)p)->ra),
-		    etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+		ND_PRINT((ndo, "RA:%s TA:%s ",
+		    etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ra),
+		    etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
 		break;
 	case CTRL_CTS:
-		printf("RA:%s ",
-		    etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+		ND_PRINT((ndo, "RA:%s ",
+		    etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
 		break;
 	case CTRL_ACK:
-		printf("RA:%s ",
-		    etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+		ND_PRINT((ndo, "RA:%s ",
+		    etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
 		break;
 	case CTRL_CF_END:
-		printf("RA:%s BSSID:%s ",
-		    etheraddr_string(((const struct ctrl_end_t *)p)->ra),
-		    etheraddr_string(((const struct ctrl_end_t *)p)->bssid));
+		ND_PRINT((ndo, "RA:%s BSSID:%s ",
+		    etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra),
+		    etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->bssid)));
 		break;
 	case CTRL_END_ACK:
-		printf("RA:%s BSSID:%s ",
-		    etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra),
-		    etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid));
+		ND_PRINT((ndo, "RA:%s BSSID:%s ",
+		    etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra),
+		    etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->bssid)));
 		break;
 	default:
-		printf("(H) Unknown Ctrl Subtype");
+		ND_PRINT((ndo, "(H) Unknown Ctrl Subtype"));
 		break;
 	}
 }
 
 static int
-extract_header_length(u_int16_t fc)
+extract_header_length(netdissect_options *ndo,
+                      uint16_t fc)
 {
 	int len;
 
@@ -1629,7 +2243,7 @@
 			len += 2;
 		return len;
 	default:
-		printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
+		ND_PRINT((ndo, "unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)));
 		return 0;
 	}
 }
@@ -1646,56 +2260,58 @@
  * "srcp" and "dstp" aren't null.
  */
 static void
-ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, u_int hdrlen,
-    u_int meshdrlen, const u_int8_t **srcp, const u_int8_t **dstp)
+ieee_802_11_hdr_print(netdissect_options *ndo,
+                      uint16_t fc, const u_char *p, u_int hdrlen,
+                      u_int meshdrlen, const uint8_t **srcp,
+                      const uint8_t **dstp)
 {
-	if (vflag) {
+	if (ndo->ndo_vflag) {
 		if (FC_MORE_DATA(fc))
-			printf("More Data ");
+			ND_PRINT((ndo, "More Data "));
 		if (FC_MORE_FLAG(fc))
-			printf("More Fragments ");
+			ND_PRINT((ndo, "More Fragments "));
 		if (FC_POWER_MGMT(fc))
-			printf("Pwr Mgmt ");
+			ND_PRINT((ndo, "Pwr Mgmt "));
 		if (FC_RETRY(fc))
-			printf("Retry ");
+			ND_PRINT((ndo, "Retry "));
 		if (FC_ORDER(fc))
-			printf("Strictly Ordered ");
+			ND_PRINT((ndo, "Strictly Ordered "));
 		if (FC_WEP(fc))
-			printf("WEP Encrypted ");
+			ND_PRINT((ndo, "WEP Encrypted "));
 		if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL)
-			printf("%dus ",
+			ND_PRINT((ndo, "%dus ",
 			    EXTRACT_LE_16BITS(
-			        &((const struct mgmt_header_t *)p)->duration));
+			        &((const struct mgmt_header_t *)p)->duration)));
 	}
 	if (meshdrlen != 0) {
 		const struct meshcntl_t *mc =
 		    (const struct meshcntl_t *)&p[hdrlen - meshdrlen];
 		int ae = mc->flags & 3;
 
-		printf("MeshData (AE %d TTL %u seq %u", ae, mc->ttl,
-		    EXTRACT_LE_32BITS(mc->seq));
+		ND_PRINT((ndo, "MeshData (AE %d TTL %u seq %u", ae, mc->ttl,
+		    EXTRACT_LE_32BITS(mc->seq)));
 		if (ae > 0)
-			printf(" A4:%s", etheraddr_string(mc->addr4));
+			ND_PRINT((ndo, " A4:%s", etheraddr_string(ndo, mc->addr4)));
 		if (ae > 1)
-			printf(" A5:%s", etheraddr_string(mc->addr5));
+			ND_PRINT((ndo, " A5:%s", etheraddr_string(ndo, mc->addr5)));
 		if (ae > 2)
-			printf(" A6:%s", etheraddr_string(mc->addr6));
-		printf(") ");
+			ND_PRINT((ndo, " A6:%s", etheraddr_string(ndo, mc->addr6)));
+		ND_PRINT((ndo, ") "));
 	}
 
 	switch (FC_TYPE(fc)) {
 	case T_MGMT:
-		mgmt_header_print(p, srcp, dstp);
+		mgmt_header_print(ndo, p, srcp, dstp);
 		break;
 	case T_CTRL:
-		ctrl_header_print(fc, p, srcp, dstp);
+		ctrl_header_print(ndo, fc, p, srcp, dstp);
 		break;
 	case T_DATA:
-		data_header_print(fc, p, srcp, dstp);
+		data_header_print(ndo, fc, p, srcp, dstp);
 		break;
 	default:
-		printf("(header) unknown IEEE802.11 frame type (%d)",
-		    FC_TYPE(fc));
+		ND_PRINT((ndo, "(header) unknown IEEE802.11 frame type (%d)",
+		    FC_TYPE(fc)));
 		*srcp = NULL;
 		*dstp = NULL;
 		break;
@@ -1707,18 +2323,19 @@
 #endif
 
 static u_int
-ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
-    u_int fcslen)
+ieee802_11_print(netdissect_options *ndo,
+                 const u_char *p, u_int length, u_int orig_caplen, int pad,
+                 u_int fcslen)
 {
-	u_int16_t fc;
+	uint16_t fc;
 	u_int caplen, hdrlen, meshdrlen;
-	const u_int8_t *src, *dst;
+	const uint8_t *src, *dst;
 	u_short extracted_ethertype;
 
 	caplen = orig_caplen;
 	/* Remove FCS, if present */
 	if (length < fcslen) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 	length -= fcslen;
@@ -1726,19 +2343,19 @@
 		/* Amount of FCS in actual packet data, if any */
 		fcslen = caplen - length;
 		caplen -= fcslen;
-		snapend -= fcslen;
+		ndo->ndo_snapend -= fcslen;
 	}
 
 	if (caplen < IEEE802_11_FC_LEN) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return orig_caplen;
 	}
 
 	fc = EXTRACT_LE_16BITS(p);
-	hdrlen = extract_header_length(fc);
+	hdrlen = extract_header_length(ndo, fc);
 	if (pad)
 		hdrlen = roundup2(hdrlen, 4);
-	if (Hflag && FC_TYPE(fc) == T_DATA &&
+	if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
 	    DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
 		meshdrlen = extract_mesh_header_length(p+hdrlen);
 		hdrlen += meshdrlen;
@@ -1747,11 +2364,11 @@
 
 
 	if (caplen < hdrlen) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return hdrlen;
 	}
 
-	ieee_802_11_hdr_print(fc, p, hdrlen, meshdrlen, &src, &dst);
+	ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen, &src, &dst);
 
 	/*
 	 * Go past the 802.11 header.
@@ -1762,15 +2379,15 @@
 
 	switch (FC_TYPE(fc)) {
 	case T_MGMT:
-		if (!mgmt_body_print(fc,
+		if (!mgmt_body_print(ndo, fc,
 		    (const struct mgmt_header_t *)(p - hdrlen), p, length)) {
-			printf("[|802.11]");
+			ND_PRINT((ndo, "%s", tstr));
 			return hdrlen;
 		}
 		break;
 	case T_CTRL:
-		if (!ctrl_body_print(fc, p - hdrlen)) {
-			printf("[|802.11]");
+		if (!ctrl_body_print(ndo, fc, p - hdrlen)) {
+			ND_PRINT((ndo, "%s", tstr));
 			return hdrlen;
 		}
 		break;
@@ -1779,29 +2396,29 @@
 			return hdrlen;	/* no-data frame */
 		/* There may be a problem w/ AP not having this bit set */
 		if (FC_WEP(fc)) {
-			if (!wep_print(p)) {
-				printf("[|802.11]");
+			if (!wep_print(ndo, p)) {
+				ND_PRINT((ndo, "%s", tstr));
 				return hdrlen;
 			}
-		} else if (llc_print(p, length, caplen, dst, src,
+		} else if (llc_print(ndo, p, length, caplen, dst, src,
 		    &extracted_ethertype) == 0) {
 			/*
 			 * Some kinds of LLC packet we cannot
 			 * handle intelligently
 			 */
-			if (!eflag)
-				ieee_802_11_hdr_print(fc, p - hdrlen, hdrlen,
+			if (!ndo->ndo_eflag)
+				ieee_802_11_hdr_print(ndo, fc, p - hdrlen, hdrlen,
 				    meshdrlen, NULL, NULL);
 			if (extracted_ethertype)
-				printf("(LLC %s) ",
+				ND_PRINT((ndo, "(LLC %s) ",
 				    etherproto_string(
-				        htons(extracted_ethertype)));
-			if (!suppress_default_print)
-				default_print(p, caplen);
+				        htons(extracted_ethertype))));
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p, caplen);
 		}
 		break;
 	default:
-		printf("unknown 802.11 frame type (%d)", FC_TYPE(fc));
+		ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
 		break;
 	}
 
@@ -1815,9 +2432,10 @@
  * is the number of bytes actually captured.
  */
 u_int
-ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_if_print(netdissect_options *ndo,
+                    const struct pcap_pkthdr *h, const u_char *p)
 {
-	return ieee802_11_print(p, h->len, h->caplen, 0, 0);
+	return ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0);
 }
 
 #define	IEEE80211_CHAN_FHSS \
@@ -1845,50 +2463,52 @@
 	(IS_CHAN_PUREG(flags) || IS_CHAN_G(flags))
 
 static void
-print_chaninfo(int freq, int flags)
+print_chaninfo(netdissect_options *ndo,
+               int freq, int flags)
 {
-	printf("%u MHz", freq);
+	ND_PRINT((ndo, "%u MHz", freq));
 	if (IS_CHAN_FHSS(flags))
-		printf(" FHSS");
+		ND_PRINT((ndo, " FHSS"));
 	if (IS_CHAN_A(flags)) {
 		if (flags & IEEE80211_CHAN_HALF)
-			printf(" 11a/10Mhz");
+			ND_PRINT((ndo, " 11a/10Mhz"));
 		else if (flags & IEEE80211_CHAN_QUARTER)
-			printf(" 11a/5Mhz");
+			ND_PRINT((ndo, " 11a/5Mhz"));
 		else
-			printf(" 11a");
+			ND_PRINT((ndo, " 11a"));
 	}
 	if (IS_CHAN_ANYG(flags)) {
 		if (flags & IEEE80211_CHAN_HALF)
-			printf(" 11g/10Mhz");
+			ND_PRINT((ndo, " 11g/10Mhz"));
 		else if (flags & IEEE80211_CHAN_QUARTER)
-			printf(" 11g/5Mhz");
+			ND_PRINT((ndo, " 11g/5Mhz"));
 		else
-			printf(" 11g");
+			ND_PRINT((ndo, " 11g"));
 	} else if (IS_CHAN_B(flags))
-		printf(" 11b");
+		ND_PRINT((ndo, " 11b"));
 	if (flags & IEEE80211_CHAN_TURBO)
-		printf(" Turbo");
+		ND_PRINT((ndo, " Turbo"));
 	if (flags & IEEE80211_CHAN_HT20)
-		printf(" ht/20");
+		ND_PRINT((ndo, " ht/20"));
 	else if (flags & IEEE80211_CHAN_HT40D)
-		printf(" ht/40-");
+		ND_PRINT((ndo, " ht/40-"));
 	else if (flags & IEEE80211_CHAN_HT40U)
-		printf(" ht/40+");
-	printf(" ");
+		ND_PRINT((ndo, " ht/40+"));
+	ND_PRINT((ndo, " "));
 }
 
 static int
-print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
-						struct radiotap_state *state, u_int32_t presentflags)
+print_radiotap_field(netdissect_options *ndo,
+                     struct cpack_state *s, uint32_t bit, uint8_t *flags,
+                     struct radiotap_state *state, uint32_t presentflags)
 {
 	union {
 		int8_t		i8;
-		u_int8_t	u8;
+		uint8_t		u8;
 		int16_t		i16;
-		u_int16_t	u16;
-		u_int32_t	u32;
-		u_int64_t	u64;
+		uint16_t	u16;
+		uint32_t	u32;
+		uint64_t	u64;
 	} u, u2, u3, u4;
 	int rc;
 
@@ -1959,9 +2579,9 @@
 		rc = cpack_uint8(s, &u3.u8);
 		break;
 	case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: {
-		u_int8_t vns[3];
-		u_int16_t length;
-		u_int8_t subspace;
+		uint8_t vns[3];
+		uint16_t length;
+		uint8_t subspace;
 
 		if ((cpack_align_and_reserve(s, 2)) == NULL) {
 			rc = -1;
@@ -1993,12 +2613,12 @@
 		 * size we do not know, so we cannot
 		 * proceed.  Just print the bit number.
 		 */
-		printf("[bit %u] ", bit);
+		ND_PRINT((ndo, "[bit %u] ", bit));
 		return -1;
 	}
 
 	if (rc != 0) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return rc;
 	}
 
@@ -2013,10 +2633,10 @@
 		 */
 		if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
 			break;
-		print_chaninfo(u.u16, u2.u16);
+		print_chaninfo(ndo, u.u16, u2.u16);
 		break;
 	case IEEE80211_RADIOTAP_FHSS:
-		printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff);
+		ND_PRINT((ndo, "fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff));
 		break;
 	case IEEE80211_RADIOTAP_RATE:
 		/*
@@ -2057,57 +2677,57 @@
 			 * information from Flags, at least on
 			 * FreeBSD?
 			 */
-			printf("MCS %u ", u.u8 & 0x7f);
+			ND_PRINT((ndo, "MCS %u ", u.u8 & 0x7f));
 		} else
-			printf("%2.1f Mb/s ", .5*u.u8);
+			ND_PRINT((ndo, "%2.1f Mb/s ", .5 * u.u8));
 		break;
 	case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
-		printf("%ddB signal ", u.i8);
+		ND_PRINT((ndo, "%ddB signal ", u.i8));
 		break;
 	case IEEE80211_RADIOTAP_DBM_ANTNOISE:
-		printf("%ddB noise ", u.i8);
+		ND_PRINT((ndo, "%ddB noise ", u.i8));
 		break;
 	case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
-		printf("%ddB signal ", u.u8);
+		ND_PRINT((ndo, "%ddB signal ", u.u8));
 		break;
 	case IEEE80211_RADIOTAP_DB_ANTNOISE:
-		printf("%ddB noise ", u.u8);
+		ND_PRINT((ndo, "%ddB noise ", u.u8));
 		break;
 	case IEEE80211_RADIOTAP_LOCK_QUALITY:
-		printf("%u sq ", u.u16);
+		ND_PRINT((ndo, "%u sq ", u.u16));
 		break;
 	case IEEE80211_RADIOTAP_TX_ATTENUATION:
-		printf("%d tx power ", -(int)u.u16);
+		ND_PRINT((ndo, "%d tx power ", -(int)u.u16));
 		break;
 	case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
-		printf("%ddB tx power ", -(int)u.u8);
+		ND_PRINT((ndo, "%ddB tx power ", -(int)u.u8));
 		break;
 	case IEEE80211_RADIOTAP_DBM_TX_POWER:
-		printf("%ddBm tx power ", u.i8);
+		ND_PRINT((ndo, "%ddBm tx power ", u.i8));
 		break;
 	case IEEE80211_RADIOTAP_FLAGS:
 		if (u.u8 & IEEE80211_RADIOTAP_F_CFP)
-			printf("cfp ");
+			ND_PRINT((ndo, "cfp "));
 		if (u.u8 & IEEE80211_RADIOTAP_F_SHORTPRE)
-			printf("short preamble ");
+			ND_PRINT((ndo, "short preamble "));
 		if (u.u8 & IEEE80211_RADIOTAP_F_WEP)
-			printf("wep ");
+			ND_PRINT((ndo, "wep "));
 		if (u.u8 & IEEE80211_RADIOTAP_F_FRAG)
-			printf("fragmented ");
+			ND_PRINT((ndo, "fragmented "));
 		if (u.u8 & IEEE80211_RADIOTAP_F_BADFCS)
-			printf("bad-fcs ");
+			ND_PRINT((ndo, "bad-fcs "));
 		break;
 	case IEEE80211_RADIOTAP_ANTENNA:
-		printf("antenna %d ", u.u8);
+		ND_PRINT((ndo, "antenna %d ", u.u8));
 		break;
 	case IEEE80211_RADIOTAP_TSFT:
-		printf("%" PRIu64 "us tsft ", u.u64);
+		ND_PRINT((ndo, "%" PRIu64 "us tsft ", u.u64));
 		break;
 	case IEEE80211_RADIOTAP_RX_FLAGS:
 		/* Do nothing for now */
 		break;
 	case IEEE80211_RADIOTAP_XCHANNEL:
-		print_chaninfo(u2.u16, u.u32);
+		print_chaninfo(ndo, u2.u16, u.u32);
 		break;
 	case IEEE80211_RADIOTAP_MCS: {
 		static const char *bandwidth[4] = {
@@ -2132,7 +2752,7 @@
 					 * the guard interval, so we can look
 					 * up the rate.
 					 */
-					htrate = 
+					htrate =
 						ieee80211_float_htrates \
 							[u3.u8] \
 							[((u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
@@ -2156,37 +2776,37 @@
 				 * We have the rate.
 				 * Print it.
 				 */
-				printf("%.1f Mb/s MCS %u ", htrate, u3.u8);
+				ND_PRINT((ndo, "%.1f Mb/s MCS %u ", htrate, u3.u8));
 			} else {
 				/*
 				 * We at least have the MCS index.
 				 * Print it.
 				 */
-				printf("MCS %u ", u3.u8);
+				ND_PRINT((ndo, "MCS %u ", u3.u8));
 			}
 		}
 		if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
-			printf("%s ",
-				bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]);
+			ND_PRINT((ndo, "%s ",
+				bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]));
 		}
 		if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
-			printf("%s GI ",
+			ND_PRINT((ndo, "%s GI ",
 				(u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
-				"short" : "lon");
+				"short" : "lon"));
 		}
 		if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
-			printf("%s ",
+			ND_PRINT((ndo, "%s ",
 				(u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
-				"greenfield" : "mixed");
+				"greenfield" : "mixed"));
 		}
 		if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
-			printf("%s FEC ",
+			ND_PRINT((ndo, "%s FEC ",
 				(u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
-				"LDPC" : "BCC");
+				"LDPC" : "BCC"));
 		}
 		if (u.u8 & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) {
-			printf("RX-STBC%u ",
-				(u2.u8 & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT);
+			ND_PRINT((ndo, "RX-STBC%u ",
+				(u2.u8 & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT));
 		}
 
 		break;
@@ -2196,7 +2816,8 @@
 }
 
 static u_int
-ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
+ieee802_11_radio_print(netdissect_options *ndo,
+                       const u_char *p, u_int length, u_int caplen)
 {
 #define	BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
 #define	BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
@@ -2209,19 +2830,19 @@
 
 	struct cpack_state cpacker;
 	struct ieee80211_radiotap_header *hdr;
-	u_int32_t present, next_present;
-	u_int32_t presentflags = 0;
-	u_int32_t *presentp, *last_presentp;
+	uint32_t present, next_present;
+	uint32_t presentflags = 0;
+	uint32_t *presentp, *last_presentp;
 	enum ieee80211_radiotap_type bit;
 	int bit0;
 	u_int len;
-	u_int8_t flags;
+	uint8_t flags;
 	int pad;
 	u_int fcslen;
 	struct radiotap_state state;
 
 	if (caplen < sizeof(*hdr)) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 
@@ -2230,10 +2851,10 @@
 	len = EXTRACT_LE_16BITS(&hdr->it_len);
 
 	if (caplen < len) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
-	cpack_init(&cpacker, (u_int8_t *)hdr, len); /* align against header start */
+	cpack_init(&cpacker, (uint8_t *)hdr, len); /* align against header start */
 	cpack_advance(&cpacker, sizeof(*hdr)); /* includes the 1st bitmap */
 	for (last_presentp = &hdr->it_present;
 	     IS_EXTENDED(last_presentp) &&
@@ -2243,7 +2864,7 @@
 
 	/* are there more bitmap extensions than bytes in header? */
 	if (IS_EXTENDED(last_presentp)) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 
@@ -2269,7 +2890,7 @@
 			bit = (enum ieee80211_radiotap_type)
 			    (bit0 + BITNO_32(present ^ next_present));
 
-			if (print_radiotap_field(&cpacker, bit, &flags, &state, presentflags) != 0)
+			if (print_radiotap_field(ndo, &cpacker, bit, &flags, &state, presentflags) != 0)
 				goto out;
 		}
 	}
@@ -2279,7 +2900,7 @@
 		pad = 1;	/* Atheros padding */
 	if (flags & IEEE80211_RADIOTAP_F_FCS)
 		fcslen = 4;	/* FCS at end of packet */
-	return len + ieee802_11_print(p + len, length - len, caplen - len, pad,
+	return len + ieee802_11_print(ndo, p + len, length - len, caplen - len, pad,
 	    fcslen);
 #undef BITNO_32
 #undef BITNO_16
@@ -2290,12 +2911,13 @@
 }
 
 static u_int
-ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
+ieee802_11_avs_radio_print(netdissect_options *ndo,
+                           const u_char *p, u_int length, u_int caplen)
 {
-	u_int32_t caphdr_len;
+	uint32_t caphdr_len;
 
 	if (caplen < 8) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 
@@ -2306,16 +2928,16 @@
 		 * to be large enough to include even the version
 		 * cookie or capture header length!
 		 */
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 
 	if (caplen < caphdr_len) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 
-	return caphdr_len + ieee802_11_print(p + caphdr_len,
+	return caphdr_len + ieee802_11_print(ndo, p + caphdr_len,
 	    length - caphdr_len, caplen - caphdr_len, 0, 0);
 }
 
@@ -2339,28 +2961,29 @@
  * indicate whether it's a Prism header or an AVS header).
  */
 u_int
-prism_if_print(const struct pcap_pkthdr *h, const u_char *p)
+prism_if_print(netdissect_options *ndo,
+               const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	u_int length = h->len;
-	u_int32_t msgcode;
+	uint32_t msgcode;
 
 	if (caplen < 4) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 
 	msgcode = EXTRACT_32BITS(p);
 	if (msgcode == WLANCAP_MAGIC_COOKIE_V1 ||
 	    msgcode == WLANCAP_MAGIC_COOKIE_V2)
-		return ieee802_11_avs_radio_print(p, length, caplen);
+		return ieee802_11_avs_radio_print(ndo, p, length, caplen);
 
 	if (caplen < PRISM_HDR_LEN) {
-		printf("[|802.11]");
+		ND_PRINT((ndo, "%s", tstr));
 		return caplen;
 	}
 
-	return PRISM_HDR_LEN + ieee802_11_print(p + PRISM_HDR_LEN,
+	return PRISM_HDR_LEN + ieee802_11_print(ndo, p + PRISM_HDR_LEN,
 	    length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0, 0);
 }
 
@@ -2369,9 +2992,10 @@
  * header, containing information such as radio information.
  */
 u_int
-ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_radio_if_print(netdissect_options *ndo,
+                          const struct pcap_pkthdr *h, const u_char *p)
 {
-	return ieee802_11_radio_print(p, h->len, h->caplen);
+	return ieee802_11_radio_print(ndo, p, h->len, h->caplen);
 }
 
 /*
@@ -2380,7 +3004,8 @@
  * which we currently ignore.
  */
 u_int
-ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_radio_avs_if_print(netdissect_options *ndo,
+                              const struct pcap_pkthdr *h, const u_char *p)
 {
-	return ieee802_11_avs_radio_print(p, h->len, h->caplen);
+	return ieee802_11_avs_radio_print(ndo, p, h->len, h->caplen);
 }
diff --git a/print-802_15_4.c b/print-802_15_4.c
index 2016552..26c28ee 100644
--- a/print-802_15_4.c
+++ b/print-802_15_4.c
@@ -20,16 +20,13 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 
@@ -47,7 +44,7 @@
 };
 
 static int
-extract_header_length(u_int16_t fc)
+extract_header_length(uint16_t fc)
 {
 	int len = 0;
 
@@ -90,13 +87,13 @@
 
 
 u_int
-ieee802_15_4_if_print(struct netdissect_options *ndo,
+ieee802_15_4_if_print(netdissect_options *ndo,
                       const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	int hdrlen;
-	u_int16_t fc;
-	u_int8_t seq;
+	uint16_t fc;
+	uint8_t seq;
 
 	if (caplen < 3) {
 		ND_PRINT((ndo, "[|802.15.4] %x", caplen));
@@ -112,7 +109,7 @@
 	caplen -= 3;
 
 	ND_PRINT((ndo,"IEEE 802.15.4 %s packet ", ftypes[fc & 0x7]));
-	if (vflag)
+	if (ndo->ndo_vflag)
 		ND_PRINT((ndo,"seq %02x ", seq));
 	if (hdrlen == -1) {
 		ND_PRINT((ndo,"malformed! "));
@@ -120,11 +117,11 @@
 	}
 
 
-	if (!vflag) {
+	if (!ndo->ndo_vflag) {
 		p+= hdrlen;
 		caplen -= hdrlen;
 	} else {
-		u_int16_t panid = 0;
+		uint16_t panid = 0;
 
 		switch ((fc >> 10) & 0x3) {
 		case 0x00:
@@ -146,7 +143,7 @@
 			p += 8;
 			break;
 		}
-		ND_PRINT((ndo,"< ");
+		ND_PRINT((ndo,"< "));
 
 		switch ((fc >> 14) & 0x3) {
 		case 0x00:
@@ -168,7 +165,7 @@
 				panid = EXTRACT_LE_16BITS(p);
 				p += 2;
 			}
-                        ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p))));
+                        ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p)));
 			p += 8;
 			break;
 		}
@@ -176,8 +173,8 @@
 		caplen -= hdrlen;
 	}
 
-	if (!suppress_default_print)
-		(ndo->ndo_default_print)(ndo, p, caplen);
+	if (!ndo->ndo_suppress_default_print)
+		ND_DEFAULTPRINT(p, caplen);
 
 	return 0;
 }
diff --git a/print-ah.c b/print-ah.c
index ecd106b..0badf48 100644
--- a/print-ah.c
+++ b/print-ah.c
@@ -21,51 +21,44 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "ah.h"
 
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
 
 int
-ah_print(register const u_char *bp)
+ah_print(netdissect_options *ndo, register const u_char *bp)
 {
 	register const struct ah *ah;
 	register const u_char *ep;
 	int sumlen;
-	u_int32_t spi;
+	uint32_t spi;
 
 	ah = (const struct ah *)bp;
-	ep = snapend;		/* 'ep' points to the end of available data. */
+	ep = ndo->ndo_snapend;		/* 'ep' points to the end of available data. */
 
-	TCHECK(*ah);
+	ND_TCHECK(*ah);
 
 	sumlen = ah->ah_len << 2;
 	spi = EXTRACT_32BITS(&ah->ah_spi);
 
-	printf("AH(spi=0x%08x", spi);
-	if (vflag)
-		printf(",sumlen=%d", sumlen);
-	printf(",seq=0x%x", EXTRACT_32BITS(ah + 1));
+	ND_PRINT((ndo, "AH(spi=0x%08x", spi));
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, ",sumlen=%d", sumlen));
+	ND_PRINT((ndo, ",seq=0x%x", EXTRACT_32BITS(ah + 1)));
 	if (bp + sizeof(struct ah) + sumlen > ep)
-		fputs("[truncated]", stdout);
-	fputs("): ", stdout);
+		ND_PRINT((ndo, "[truncated]"));
+	ND_PRINT((ndo, "): "));
 
 	return sizeof(struct ah) + sumlen;
  trunc:
-	fputs("[|AH]", stdout);
+	ND_PRINT((ndo, "[|AH]"));
 	return -1;
 }
diff --git a/print-ahcp.c b/print-ahcp.c
new file mode 100644
index 0000000..a9ae38a
--- /dev/null
+++ b/print-ahcp.c
@@ -0,0 +1,421 @@
+/*
+ * This module implements decoding of AHCP (Ad Hoc Configuration Protocol) based
+ * on draft-chroboczek-ahcp-00 and source code of ahcpd-0.53.
+ *
+ *
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+static const char tstr[] = " [|ahcp]";
+static const char cstr[] = "(corrupt)";
+
+#define AHCP_MAGIC_NUMBER 43
+#define AHCP_VERSION_1 1
+#define AHCP1_HEADER_FIX_LEN 24
+#define AHCP1_BODY_MIN_LEN 4
+
+#define AHCP1_MSG_DISCOVER 0
+#define AHCP1_MSG_OFFER    1
+#define AHCP1_MSG_REQUEST  2
+#define AHCP1_MSG_ACK      3
+#define AHCP1_MSG_NACK     4
+#define AHCP1_MSG_RELEASE  5
+
+static const struct tok ahcp1_msg_str[] = {
+	{ AHCP1_MSG_DISCOVER, "Discover" },
+	{ AHCP1_MSG_OFFER,    "Offer"    },
+	{ AHCP1_MSG_REQUEST,  "Request"  },
+	{ AHCP1_MSG_ACK,      "Ack"      },
+	{ AHCP1_MSG_NACK,     "Nack"     },
+	{ AHCP1_MSG_RELEASE,  "Release"  },
+	{ 0, NULL }
+};
+
+#define AHCP1_OPT_PAD                     0
+#define AHCP1_OPT_MANDATORY               1
+#define AHCP1_OPT_ORIGIN_TIME             2
+#define AHCP1_OPT_EXPIRES                 3
+#define AHCP1_OPT_MY_IPV6_ADDRESS         4
+#define AHCP1_OPT_MY_IPV4_ADDRESS         5
+#define AHCP1_OPT_IPV6_PREFIX             6
+#define AHCP1_OPT_IPV4_PREFIX             7
+#define AHCP1_OPT_IPV6_ADDRESS            8
+#define AHCP1_OPT_IPV4_ADDRESS            9
+#define AHCP1_OPT_IPV6_PREFIX_DELEGATION 10
+#define AHCP1_OPT_IPV4_PREFIX_DELEGATION 11
+#define AHCP1_OPT_NAME_SERVER            12
+#define AHCP1_OPT_NTP_SERVER             13
+#define AHCP1_OPT_MAX                    13
+
+static const struct tok ahcp1_opt_str[] = {
+	{ AHCP1_OPT_PAD,                    "Pad"                    },
+	{ AHCP1_OPT_MANDATORY,              "Mandatory"              },
+	{ AHCP1_OPT_ORIGIN_TIME,            "Origin Time"            },
+	{ AHCP1_OPT_EXPIRES,                "Expires"                },
+	{ AHCP1_OPT_MY_IPV6_ADDRESS,        "My-IPv6-Address"        },
+	{ AHCP1_OPT_MY_IPV4_ADDRESS,        "My-IPv4-Address"        },
+	{ AHCP1_OPT_IPV6_PREFIX,            "IPv6 Prefix"            },
+	{ AHCP1_OPT_IPV4_PREFIX,            "IPv4 Prefix"            },
+	{ AHCP1_OPT_IPV6_ADDRESS,           "IPv6 Address"           },
+	{ AHCP1_OPT_IPV4_ADDRESS,           "IPv4 Address"           },
+	{ AHCP1_OPT_IPV6_PREFIX_DELEGATION, "IPv6 Prefix Delegation" },
+	{ AHCP1_OPT_IPV4_PREFIX_DELEGATION, "IPv4 Prefix Delegation" },
+	{ AHCP1_OPT_NAME_SERVER,            "Name Server"            },
+	{ AHCP1_OPT_NTP_SERVER,             "NTP Server"             },
+	{ 0, NULL }
+};
+
+static int
+ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	time_t t;
+	struct tm *tm;
+	char buf[BUFSIZE];
+
+	if (cp + 4 != ep)
+		goto corrupt;
+	ND_TCHECK2(*cp, 4);
+	t = EXTRACT_32BITS(cp);
+	if (NULL == (tm = gmtime(&t)))
+		ND_PRINT((ndo, ": gmtime() error"));
+	else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm))
+		ND_PRINT((ndo, ": strftime() error"));
+	else
+		ND_PRINT((ndo, ": %s UTC", buf));
+	return 0;
+
+corrupt:
+	ND_PRINT((ndo, ": %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return 0;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return -1;
+}
+
+static int
+ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	if (cp + 4 != ep)
+		goto corrupt;
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ": %us", EXTRACT_32BITS(cp)));
+	return 0;
+
+corrupt:
+	ND_PRINT((ndo, ": %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return 0;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return -1;
+}
+
+static int
+ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	const char *sep = ": ";
+
+	while (cp < ep) {
+		if (cp + 16 > ep)
+			goto corrupt;
+		ND_TCHECK2(*cp, 16);
+#ifdef INET6
+		ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
+#else
+		ND_PRINT((ndo, "%s(compiled w/o IPv6)", sep));
+#endif /* INET6 */
+		cp += 16;
+		sep = ", ";
+	}
+	return 0;
+
+corrupt:
+	ND_PRINT((ndo, ": %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return 0;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return -1;
+}
+
+static int
+ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	const char *sep = ": ";
+
+	while (cp < ep) {
+		if (cp + 4 > ep)
+			goto corrupt;
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
+		cp += 4;
+		sep = ", ";
+	}
+	return 0;
+
+corrupt:
+	ND_PRINT((ndo, ": %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return 0;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return -1;
+}
+
+static int
+ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	const char *sep = ": ";
+
+	while (cp < ep) {
+		if (cp + 17 > ep)
+			goto corrupt;
+		ND_TCHECK2(*cp, 17);
+#ifdef INET6
+		ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
+#else
+		ND_PRINT((ndo, "%s(compiled w/o IPv6)/%u", sep, *(cp + 16)));
+#endif /* INET6 */
+		cp += 17;
+		sep = ", ";
+	}
+	return 0;
+
+corrupt:
+	ND_PRINT((ndo, ": %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return 0;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return -1;
+}
+
+static int
+ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	const char *sep = ": ";
+
+	while (cp < ep) {
+		if (cp + 5 > ep)
+			goto corrupt;
+		ND_TCHECK2(*cp, 5);
+		ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
+		cp += 5;
+		sep = ", ";
+	}
+	return 0;
+
+corrupt:
+	ND_PRINT((ndo, ": %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return 0;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return -1;
+}
+
+/* Data decoders signal truncated data with -1. */
+static int
+(* const data_decoders[AHCP1_OPT_MAX + 1])(netdissect_options *, const u_char *, const u_char *) = {
+	/* [AHCP1_OPT_PAD]                    = */  NULL,
+	/* [AHCP1_OPT_MANDATORY]              = */  NULL,
+	/* [AHCP1_OPT_ORIGIN_TIME]            = */  ahcp_time_print,
+	/* [AHCP1_OPT_EXPIRES]                = */  ahcp_seconds_print,
+	/* [AHCP1_OPT_MY_IPV6_ADDRESS]        = */  ahcp_ipv6_addresses_print,
+	/* [AHCP1_OPT_MY_IPV4_ADDRESS]        = */  ahcp_ipv4_addresses_print,
+	/* [AHCP1_OPT_IPV6_PREFIX]            = */  ahcp_ipv6_prefixes_print,
+	/* [AHCP1_OPT_IPV4_PREFIX]            = */  NULL,
+	/* [AHCP1_OPT_IPV6_ADDRESS]           = */  ahcp_ipv6_addresses_print,
+	/* [AHCP1_OPT_IPV4_ADDRESS]           = */  ahcp_ipv4_addresses_print,
+	/* [AHCP1_OPT_IPV6_PREFIX_DELEGATION] = */  ahcp_ipv6_prefixes_print,
+	/* [AHCP1_OPT_IPV4_PREFIX_DELEGATION] = */  ahcp_ipv4_prefixes_print,
+	/* [AHCP1_OPT_NAME_SERVER]            = */  ahcp_ipv6_addresses_print,
+	/* [AHCP1_OPT_NTP_SERVER]             = */  ahcp_ipv6_addresses_print,
+};
+
+static void
+ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	uint8_t option_no, option_len;
+
+	while (cp < ep) {
+		/* Option no */
+		ND_TCHECK2(*cp, 1);
+		option_no = *cp;
+		cp += 1;
+		ND_PRINT((ndo, "\n\t %s", tok2str(ahcp1_opt_str, "Unknown-%u", option_no)));
+		if (option_no == AHCP1_OPT_PAD || option_no == AHCP1_OPT_MANDATORY)
+			continue;
+		/* Length */
+		if (cp + 1 > ep)
+			goto corrupt;
+		ND_TCHECK2(*cp, 1);
+		option_len = *cp;
+		cp += 1;
+		if (cp + option_len > ep)
+			goto corrupt;
+		/* Value */
+		if (option_no <= AHCP1_OPT_MAX && data_decoders[option_no] != NULL) {
+			if (data_decoders[option_no](ndo, cp, cp + option_len) < 0)
+				break; /* truncated and already marked up */
+		} else {
+			ND_PRINT((ndo, " (Length %u)", option_len));
+			ND_TCHECK2(*cp, option_len);
+		}
+		cp += option_len;
+	}
+	return;
+
+corrupt:
+	ND_PRINT((ndo, " %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	uint8_t type, mbz;
+	uint16_t body_len;
+
+	if (cp + AHCP1_BODY_MIN_LEN > ep)
+		goto corrupt;
+	/* Type */
+	ND_TCHECK2(*cp, 1);
+	type = *cp;
+	cp += 1;
+	/* MBZ */
+	ND_TCHECK2(*cp, 1);
+	mbz = *cp;
+	cp += 1;
+	/* Length */
+	ND_TCHECK2(*cp, 2);
+	body_len = EXTRACT_16BITS(cp);
+	cp += 2;
+
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "\n\t%s", tok2str(ahcp1_msg_str, "Unknown-%u", type)));
+		if (mbz != 0)
+			ND_PRINT((ndo, ", MBZ %u", mbz));
+		ND_PRINT((ndo, ", Length %u", body_len));
+	}
+	if (cp + body_len > ep)
+		goto corrupt;
+
+	/* Options */
+	if (ndo->ndo_vflag >= 2)
+		ahcp1_options_print(ndo, cp, cp + body_len); /* not ep (ignore extra data) */
+	else
+		ND_TCHECK2(*cp, body_len);
+	return;
+
+corrupt:
+	ND_PRINT((ndo, " %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint8_t version;
+
+	ND_PRINT((ndo, "AHCP"));
+	if (len < 2)
+		goto corrupt;
+	/* Magic */
+	ND_TCHECK2(*cp, 1);
+	if (*cp != AHCP_MAGIC_NUMBER)
+		goto corrupt;
+	cp += 1;
+	/* Version */
+	ND_TCHECK2(*cp, 1);
+	version = *cp;
+	cp += 1;
+	switch (version) {
+		case AHCP_VERSION_1: {
+			ND_PRINT((ndo, " Version 1"));
+			if (len < AHCP1_HEADER_FIX_LEN)
+				goto corrupt;
+			if (!ndo->ndo_vflag) {
+				ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2);
+				cp += AHCP1_HEADER_FIX_LEN - 2;
+			} else {
+				/* Hopcount */
+				ND_TCHECK2(*cp, 1);
+				ND_PRINT((ndo, "\n\tHopcount %u", *cp));
+				cp += 1;
+				/* Original Hopcount */
+				ND_TCHECK2(*cp, 1);
+				ND_PRINT((ndo, ", Original Hopcount %u", *cp));
+				cp += 1;
+				/* Nonce */
+				ND_TCHECK2(*cp, 4);
+				ND_PRINT((ndo, ", Nonce 0x%08x", EXTRACT_32BITS(cp)));
+				cp += 4;
+				/* Source Id */
+				ND_TCHECK2(*cp, 8);
+				ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8)));
+				cp += 8;
+				/* Destination Id */
+				ND_TCHECK2(*cp, 8);
+				ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)));
+				cp += 8;
+			}
+			/* Body */
+			ahcp1_body_print(ndo, cp, ep);
+			break;
+		}
+		default:
+			ND_PRINT((ndo, " Version %u (unknown)", version));
+			break;
+	}
+	return;
+
+corrupt:
+	ND_PRINT((ndo, " %s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
diff --git a/print-aodv.c b/print-aodv.c
index c5f6622..ef27eee 100644
--- a/print-aodv.c
+++ b/print-aodv.c
@@ -30,426 +30,556 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.11 2004-03-24 00:30:19 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stddef.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"			/* must come after interface.h */
 
-#include "aodv.h"
+
+struct aodv_rreq {
+	uint8_t		rreq_type;	/* AODV message type (1) */
+	uint8_t		rreq_flags;	/* various flags */
+	uint8_t		rreq_zero0;	/* reserved, set to zero */
+	uint8_t		rreq_hops;	/* number of hops from originator */
+	uint32_t	rreq_id;	/* request ID */
+	uint32_t	rreq_da;	/* destination IPv4 address */
+	uint32_t	rreq_ds;	/* destination sequence number */
+	uint32_t	rreq_oa;	/* originator IPv4 address */
+	uint32_t	rreq_os;	/* originator sequence number */
+};
+#ifdef INET6
+struct aodv_rreq6 {
+	uint8_t		rreq_type;	/* AODV message type (1) */
+	uint8_t		rreq_flags;	/* various flags */
+	uint8_t		rreq_zero0;	/* reserved, set to zero */
+	uint8_t		rreq_hops;	/* number of hops from originator */
+	uint32_t	rreq_id;	/* request ID */
+	struct in6_addr	rreq_da;	/* destination IPv6 address */
+	uint32_t	rreq_ds;	/* destination sequence number */
+	struct in6_addr	rreq_oa;	/* originator IPv6 address */
+	uint32_t	rreq_os;	/* originator sequence number */
+};
+struct aodv_rreq6_draft_01 {
+	uint8_t		rreq_type;	/* AODV message type (16) */
+	uint8_t		rreq_flags;	/* various flags */
+	uint8_t		rreq_zero0;	/* reserved, set to zero */
+	uint8_t		rreq_hops;	/* number of hops from originator */
+	uint32_t	rreq_id;	/* request ID */
+	uint32_t	rreq_ds;	/* destination sequence number */
+	uint32_t	rreq_os;	/* originator sequence number */
+	struct in6_addr	rreq_da;	/* destination IPv6 address */
+	struct in6_addr	rreq_oa;	/* originator IPv6 address */
+};
+#endif
+
+#define	RREQ_JOIN	0x80		/* join (reserved for multicast */
+#define	RREQ_REPAIR	0x40		/* repair (reserved for multicast */
+#define	RREQ_GRAT	0x20		/* gratuitous RREP */
+#define	RREQ_DEST	0x10		/* destination only */
+#define	RREQ_UNKNOWN	0x08		/* unknown destination sequence num */
+#define	RREQ_FLAGS_MASK	0xF8		/* mask for rreq_flags */
+
+struct aodv_rrep {
+	uint8_t		rrep_type;	/* AODV message type (2) */
+	uint8_t		rrep_flags;	/* various flags */
+	uint8_t		rrep_ps;	/* prefix size */
+	uint8_t		rrep_hops;	/* number of hops from o to d */
+	uint32_t	rrep_da;	/* destination IPv4 address */
+	uint32_t	rrep_ds;	/* destination sequence number */
+	uint32_t	rrep_oa;	/* originator IPv4 address */
+	uint32_t	rrep_life;	/* lifetime of this route */
+};
+#ifdef INET6
+struct aodv_rrep6 {
+	uint8_t		rrep_type;	/* AODV message type (2) */
+	uint8_t		rrep_flags;	/* various flags */
+	uint8_t		rrep_ps;	/* prefix size */
+	uint8_t		rrep_hops;	/* number of hops from o to d */
+	struct in6_addr	rrep_da;	/* destination IPv6 address */
+	uint32_t	rrep_ds;	/* destination sequence number */
+	struct in6_addr	rrep_oa;	/* originator IPv6 address */
+	uint32_t	rrep_life;	/* lifetime of this route */
+};
+struct aodv_rrep6_draft_01 {
+	uint8_t		rrep_type;	/* AODV message type (17) */
+	uint8_t		rrep_flags;	/* various flags */
+	uint8_t		rrep_ps;	/* prefix size */
+	uint8_t		rrep_hops;	/* number of hops from o to d */
+	uint32_t	rrep_ds;	/* destination sequence number */
+	struct in6_addr	rrep_da;	/* destination IPv6 address */
+	struct in6_addr	rrep_oa;	/* originator IPv6 address */
+	uint32_t	rrep_life;	/* lifetime of this route */
+};
+#endif
+
+#define	RREP_REPAIR		0x80	/* repair (reserved for multicast */
+#define	RREP_ACK		0x40	/* acknowledgement required */
+#define	RREP_FLAGS_MASK		0xC0	/* mask for rrep_flags */
+#define	RREP_PREFIX_MASK	0x1F	/* mask for prefix size */
+
+struct rerr_unreach {
+	uint32_t	u_da;	/* IPv4 address */
+	uint32_t	u_ds;	/* sequence number */
+};
+#ifdef INET6
+struct rerr_unreach6 {
+	struct in6_addr	u_da;	/* IPv6 address */
+	uint32_t	u_ds;	/* sequence number */
+};
+struct rerr_unreach6_draft_01 {
+	struct in6_addr	u_da;	/* IPv6 address */
+	uint32_t	u_ds;	/* sequence number */
+};
+#endif
+
+struct aodv_rerr {
+	uint8_t		rerr_type;	/* AODV message type (3 or 18) */
+	uint8_t		rerr_flags;	/* various flags */
+	uint8_t		rerr_zero0;	/* reserved, set to zero */
+	uint8_t		rerr_dc;	/* destination count */
+};
+
+#define RERR_NODELETE		0x80	/* don't delete the link */
+#define RERR_FLAGS_MASK		0x80	/* mask for rerr_flags */
+
+struct aodv_rrep_ack {
+	uint8_t		ra_type;
+	uint8_t		ra_zero0;
+};
+
+#define	AODV_RREQ		1	/* route request */
+#define	AODV_RREP		2	/* route response */
+#define	AODV_RERR		3	/* error report */
+#define	AODV_RREP_ACK		4	/* route response acknowledgement */
+
+#define AODV_V6_DRAFT_01_RREQ		16	/* IPv6 route request */
+#define AODV_V6_DRAFT_01_RREP		17	/* IPv6 route response */
+#define AODV_V6_DRAFT_01_RERR		18	/* IPv6 error report */
+#define AODV_V6_DRAFT_01_RREP_ACK	19	/* IPV6 route response acknowledgment */
+
+struct aodv_ext {
+	uint8_t		type;		/* extension type */
+	uint8_t		length;		/* extension length */
+};
+
+struct aodv_hello {
+	struct	aodv_ext	eh;		/* extension header */
+	uint8_t			interval[4];	/* expect my next hello in
+						 * (n) ms
+						 * NOTE: this is not aligned */
+};
+
+#define	AODV_EXT_HELLO	1
 
 static void
-aodv_extension(const struct aodv_ext *ep, u_int length)
+aodv_extension(netdissect_options *ndo,
+               const struct aodv_ext *ep, u_int length)
 {
-	u_int i;
 	const struct aodv_hello *ah;
 
 	switch (ep->type) {
 	case AODV_EXT_HELLO:
-		if (snapend < (u_char *) ep) {
-			printf(" [|hello]");
-			return;
-		}
-		i = min(length, (u_int)(snapend - (u_char *)ep));
-		if (i < sizeof(struct aodv_hello)) {
-			printf(" [|hello]");
-			return;
-		}
-		i -= sizeof(struct aodv_hello);
-		ah = (void *)ep;
-		printf("\n\text HELLO %ld ms",
-		    (unsigned long)EXTRACT_32BITS(&ah->interval));
+		ah = (const struct aodv_hello *)(const void *)ep;
+		ND_TCHECK(*ah);
+		if (length < sizeof(struct aodv_hello))
+			goto trunc;
+		ND_PRINT((ndo, "\n\text HELLO %ld ms",
+		    (unsigned long)EXTRACT_32BITS(&ah->interval)));
 		break;
 
 	default:
-		printf("\n\text %u %u", ep->type, ep->length);
+		ND_PRINT((ndo, "\n\text %u %u", ep->type, ep->length));
 		break;
 	}
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|hello]"));
 }
 
 static void
-aodv_rreq(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
 {
 	u_int i;
+	const struct aodv_rreq *ap = (const struct aodv_rreq *)dat;
 
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
-	}
-	i = min(length, (u_int)(snapend - dat));
-	if (i < sizeof(ap->rreq)) {
-		printf(" [|rreq]");
-		return;
-	}
-	i -= sizeof(ap->rreq);
-	printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
 	    "\tdst %s seq %lu src %s seq %lu", length,
-	    ap->rreq.rreq_type & RREQ_JOIN ? "[J]" : "",
-	    ap->rreq.rreq_type & RREQ_REPAIR ? "[R]" : "",
-	    ap->rreq.rreq_type & RREQ_GRAT ? "[G]" : "",
-	    ap->rreq.rreq_type & RREQ_DEST ? "[D]" : "",
-	    ap->rreq.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
-	    ap->rreq.rreq_hops,
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_id),
-	    ipaddr_string(&ap->rreq.rreq_da),
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_ds),
-	    ipaddr_string(&ap->rreq.rreq_oa),
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_os));
+	    ap->rreq_type & RREQ_JOIN ? "[J]" : "",
+	    ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
+	    ap->rreq_type & RREQ_GRAT ? "[G]" : "",
+	    ap->rreq_type & RREQ_DEST ? "[D]" : "",
+	    ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
+	    ap->rreq_hops,
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_id),
+	    ipaddr_string(ndo, &ap->rreq_da),
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
+	    ipaddr_string(ndo, &ap->rreq_oa),
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
+	i = length - sizeof(*ap);
 	if (i >= sizeof(struct aodv_ext))
-		aodv_extension((void *)(&ap->rreq + 1), i);
+		aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|rreq"));
 }
 
 static void
-aodv_rrep(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
 {
 	u_int i;
+	const struct aodv_rrep *ap = (const struct aodv_rrep *)dat;
 
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
-	}
-	i = min(length, (u_int)(snapend - dat));
-	if (i < sizeof(ap->rrep)) {
-		printf(" [|rrep]");
-		return;
-	}
-	i -= sizeof(ap->rrep);
-	printf(" rrep %u %s%sprefix %u hops %u\n"
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
 	    "\tdst %s dseq %lu src %s %lu ms", length,
-	    ap->rrep.rrep_type & RREP_REPAIR ? "[R]" : "",
-	    ap->rrep.rrep_type & RREP_ACK ? "[A] " : " ",
-	    ap->rrep.rrep_ps & RREP_PREFIX_MASK,
-	    ap->rrep.rrep_hops,
-	    ipaddr_string(&ap->rrep.rrep_da),
-	    (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_ds),
-	    ipaddr_string(&ap->rrep.rrep_oa),
-	    (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_life));
+	    ap->rrep_type & RREP_REPAIR ? "[R]" : "",
+	    ap->rrep_type & RREP_ACK ? "[A] " : " ",
+	    ap->rrep_ps & RREP_PREFIX_MASK,
+	    ap->rrep_hops,
+	    ipaddr_string(ndo, &ap->rrep_da),
+	    (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+	    ipaddr_string(ndo, &ap->rrep_oa),
+	    (unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
+	i = length - sizeof(*ap);
 	if (i >= sizeof(struct aodv_ext))
-		aodv_extension((void *)(&ap->rrep + 1), i);
+		aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|rreq"));
 }
 
 static void
-aodv_rerr(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-	u_int i;
-	const struct rerr_unreach *dp = NULL;
-	int n, trunc;
+	u_int i, dc;
+	const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+	const struct rerr_unreach *dp;
 
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
+	    ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+	    ap->rerr_dc, length));
+	dp = (struct rerr_unreach *)(dat + sizeof(*ap));
+	i = length - sizeof(*ap);
+	for (dc = ap->rerr_dc; dc != 0; dc--) {
+		ND_TCHECK(*dp);
+		if (i < sizeof(*dp))
+			goto trunc;
+		ND_PRINT((ndo, " {%s}(%ld)", ipaddr_string(ndo, &dp->u_da),
+		    (unsigned long)EXTRACT_32BITS(&dp->u_ds)));
+		dp++;
+		i -= sizeof(*dp);
 	}
-	i = min(length, (u_int)(snapend - dat));
-	if (i < offsetof(struct aodv_rerr, r)) {
-		printf(" [|rerr]");
-		return;
-	}
-	i -= offsetof(struct aodv_rerr, r);
-	dp = &ap->rerr.r.dest[0];
-	n = ap->rerr.rerr_dc * sizeof(ap->rerr.r.dest[0]);
-	printf(" rerr %s [items %u] [%u]:",
-	    ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
-	    ap->rerr.rerr_dc, length);
-	trunc = n - (i/sizeof(ap->rerr.r.dest[0]));
-	for (; i >= sizeof(ap->rerr.r.dest[0]);
-	    ++dp, i -= sizeof(ap->rerr.r.dest[0])) {
-		printf(" {%s}(%ld)", ipaddr_string(&dp->u_da),
-		    (unsigned long)EXTRACT_32BITS(&dp->u_ds));
-	}
-	if (trunc)
-		printf("[|rerr]");
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|rerr]"));
 }
 
 static void
 #ifdef INET6
-aodv_v6_rreq(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
 #else
-aodv_v6_rreq(const union aodv *ap _U_, const u_char *dat _U_, u_int length)
+aodv_v6_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 #endif
 {
 #ifdef INET6
 	u_int i;
+	const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
 
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
-	}
-	i = min(length, (u_int)(snapend - dat));
-	if (i < sizeof(ap->rreq6)) {
-		printf(" [|rreq6]");
-		return;
-	}
-	i -= sizeof(ap->rreq6);
-	printf(" v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
 	    "\tdst %s seq %lu src %s seq %lu", length,
-	    ap->rreq6.rreq_type & RREQ_JOIN ? "[J]" : "",
-	    ap->rreq6.rreq_type & RREQ_REPAIR ? "[R]" : "",
-	    ap->rreq6.rreq_type & RREQ_GRAT ? "[G]" : "",
-	    ap->rreq6.rreq_type & RREQ_DEST ? "[D]" : "",
-	    ap->rreq6.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
-	    ap->rreq6.rreq_hops,
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_id),
-	    ip6addr_string(&ap->rreq6.rreq_da),
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_ds),
-	    ip6addr_string(&ap->rreq6.rreq_oa),
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_os));
+	    ap->rreq_type & RREQ_JOIN ? "[J]" : "",
+	    ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
+	    ap->rreq_type & RREQ_GRAT ? "[G]" : "",
+	    ap->rreq_type & RREQ_DEST ? "[D]" : "",
+	    ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
+	    ap->rreq_hops,
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_id),
+	    ip6addr_string(ndo, &ap->rreq_da),
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
+	    ip6addr_string(ndo, &ap->rreq_oa),
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
+	i = length - sizeof(*ap);
 	if (i >= sizeof(struct aodv_ext))
-		aodv_extension((void *)(&ap->rreq6 + 1), i);
+		aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|rreq"));
 #else
-	printf(" v6 rreq %u", length);
+	ND_PRINT((ndo, " v6 rreq %u", length));
 #endif
 }
 
 static void
 #ifdef INET6
-aodv_v6_rrep(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
 #else
-aodv_v6_rrep(const union aodv *ap _U_, const u_char *dat _U_, u_int length)
+aodv_v6_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 #endif
 {
 #ifdef INET6
 	u_int i;
+	const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
 
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
-	}
-	i = min(length, (u_int)(snapend - dat));
-	if (i < sizeof(ap->rrep6)) {
-		printf(" [|rrep6]");
-		return;
-	}
-	i -= sizeof(ap->rrep6);
-	printf(" rrep %u %s%sprefix %u hops %u\n"
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
 	   "\tdst %s dseq %lu src %s %lu ms", length,
-	    ap->rrep6.rrep_type & RREP_REPAIR ? "[R]" : "",
-	    ap->rrep6.rrep_type & RREP_ACK ? "[A] " : " ",
-	    ap->rrep6.rrep_ps & RREP_PREFIX_MASK,
-	    ap->rrep6.rrep_hops,
-	    ip6addr_string(&ap->rrep6.rrep_da),
-	    (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_ds),
-	    ip6addr_string(&ap->rrep6.rrep_oa),
-	    (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_life));
+	    ap->rrep_type & RREP_REPAIR ? "[R]" : "",
+	    ap->rrep_type & RREP_ACK ? "[A] " : " ",
+	    ap->rrep_ps & RREP_PREFIX_MASK,
+	    ap->rrep_hops,
+	    ip6addr_string(ndo, &ap->rrep_da),
+	    (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+	    ip6addr_string(ndo, &ap->rrep_oa),
+	    (unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
+	i = length - sizeof(*ap);
 	if (i >= sizeof(struct aodv_ext))
-		aodv_extension((void *)(&ap->rrep6 + 1), i);
+		aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|rreq"));
 #else
-	printf(" rrep %u", length);
+	ND_PRINT((ndo, " rrep %u", length));
 #endif
 }
 
 static void
 #ifdef INET6
-aodv_v6_rerr(const union aodv *ap, u_int length)
+aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
 #else
-aodv_v6_rerr(const union aodv *ap _U_, u_int length)
+aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 #endif
 {
 #ifdef INET6
-	const struct rerr_unreach6 *dp6 = NULL;
-	int i, j, n, trunc;
+	u_int i, dc;
+	const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+	const struct rerr_unreach6 *dp6;
 
-	i = length - offsetof(struct aodv_rerr, r);
-	j = sizeof(ap->rerr.r.dest6[0]);
-	dp6 = &ap->rerr.r.dest6[0];
-	n = ap->rerr.rerr_dc * j;
-	printf(" rerr %s [items %u] [%u]:",
-	    ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
-	    ap->rerr.rerr_dc, length);
-	trunc = n - (i/j);
-	for (; i -= j >= 0; ++dp6) {
-		printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da),
-		    (unsigned long)EXTRACT_32BITS(&dp6->u_ds));
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
+	    ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+	    ap->rerr_dc, length));
+	dp6 = (struct rerr_unreach6 *)(void *)(ap + 1);
+	i = length - sizeof(*ap);
+	for (dc = ap->rerr_dc; dc != 0; dc--) {
+		ND_TCHECK(*dp6);
+		if (i < sizeof(*dp6))
+			goto trunc;
+		ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
+		    (unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
+		dp6++;
+		i -= sizeof(*dp6);
 	}
-	if (trunc)
-		printf("[|rerr]");
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|rerr]"));
 #else
-	printf(" rerr %u", length);
+	ND_PRINT((ndo, " rerr %u", length));
 #endif
 }
 
 static void
 #ifdef INET6
-aodv_v6_draft_01_rreq(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
 #else
-aodv_v6_draft_01_rreq(const union aodv *ap _U_, const u_char *dat _U_,
-    u_int length)
+aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 #endif
 {
 #ifdef INET6
 	u_int i;
+	const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
 
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
-	}
-	i = min(length, (u_int)(snapend - dat));
-	if (i < sizeof(ap->rreq6_draft_01)) {
-		printf(" [|rreq6]");
-		return;
-	}
-	i -= sizeof(ap->rreq6_draft_01);
-	printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
 	    "\tdst %s seq %lu src %s seq %lu", length,
-	    ap->rreq6_draft_01.rreq_type & RREQ_JOIN ? "[J]" : "",
-	    ap->rreq6_draft_01.rreq_type & RREQ_REPAIR ? "[R]" : "",
-	    ap->rreq6_draft_01.rreq_type & RREQ_GRAT ? "[G]" : "",
-	    ap->rreq6_draft_01.rreq_type & RREQ_DEST ? "[D]" : "",
-	    ap->rreq6_draft_01.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
-	    ap->rreq6_draft_01.rreq_hops,
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_id),
-	    ip6addr_string(&ap->rreq6_draft_01.rreq_da),
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_ds),
-	    ip6addr_string(&ap->rreq6_draft_01.rreq_oa),
-	    (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_os));
+	    ap->rreq_type & RREQ_JOIN ? "[J]" : "",
+	    ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
+	    ap->rreq_type & RREQ_GRAT ? "[G]" : "",
+	    ap->rreq_type & RREQ_DEST ? "[D]" : "",
+	    ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
+	    ap->rreq_hops,
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_id),
+	    ip6addr_string(ndo, &ap->rreq_da),
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
+	    ip6addr_string(ndo, &ap->rreq_oa),
+	    (unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
+	i = length - sizeof(*ap);
 	if (i >= sizeof(struct aodv_ext))
-		aodv_extension((void *)(&ap->rreq6_draft_01 + 1), i);
+		aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|rreq"));
 #else
-	printf(" rreq %u", length);
+	ND_PRINT((ndo, " rreq %u", length));
 #endif
 }
 
 static void
 #ifdef INET6
-aodv_v6_draft_01_rrep(const union aodv *ap, const u_char *dat, u_int length)
+aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
 #else
-aodv_v6_draft_01_rrep(const union aodv *ap _U_, const u_char *dat _U_,
-    u_int length)
+aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 #endif
 {
 #ifdef INET6
 	u_int i;
+	const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
 
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
-	}
-	i = min(length, (u_int)(snapend - dat));
-	if (i < sizeof(ap->rrep6_draft_01)) {
-		printf(" [|rrep6]");
-		return;
-	}
-	i -= sizeof(ap->rrep6_draft_01);
-	printf(" rrep %u %s%sprefix %u hops %u\n"
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
 	   "\tdst %s dseq %lu src %s %lu ms", length,
-	    ap->rrep6_draft_01.rrep_type & RREP_REPAIR ? "[R]" : "",
-	    ap->rrep6_draft_01.rrep_type & RREP_ACK ? "[A] " : " ",
-	    ap->rrep6_draft_01.rrep_ps & RREP_PREFIX_MASK,
-	    ap->rrep6_draft_01.rrep_hops,
-	    ip6addr_string(&ap->rrep6_draft_01.rrep_da),
-	    (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_ds),
-	    ip6addr_string(&ap->rrep6_draft_01.rrep_oa),
-	    (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_life));
+	    ap->rrep_type & RREP_REPAIR ? "[R]" : "",
+	    ap->rrep_type & RREP_ACK ? "[A] " : " ",
+	    ap->rrep_ps & RREP_PREFIX_MASK,
+	    ap->rrep_hops,
+	    ip6addr_string(ndo, &ap->rrep_da),
+	    (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+	    ip6addr_string(ndo, &ap->rrep_oa),
+	    (unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
+	i = length - sizeof(*ap);
 	if (i >= sizeof(struct aodv_ext))
-		aodv_extension((void *)(&ap->rrep6_draft_01 + 1), i);
+		aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|rreq"));
 #else
-	printf(" rrep %u", length);
+	ND_PRINT((ndo, " rrep %u", length));
 #endif
 }
 
 static void
 #ifdef INET6
-aodv_v6_draft_01_rerr(const union aodv *ap, u_int length)
+aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
 #else
-aodv_v6_draft_01_rerr(const union aodv *ap _U_, u_int length)
+aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
 #endif
 {
 #ifdef INET6
-	const struct rerr_unreach6_draft_01 *dp6 = NULL;
-	int i, j, n, trunc;
+	u_int i, dc;
+	const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+	const struct rerr_unreach6_draft_01 *dp6;
 
-	i = length - offsetof(struct aodv_rerr, r);
-	j = sizeof(ap->rerr.r.dest6_draft_01[0]);
-	dp6 = &ap->rerr.r.dest6_draft_01[0];
-	n = ap->rerr.rerr_dc * j;
-	printf(" rerr %s [items %u] [%u]:",
-	    ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
-	    ap->rerr.rerr_dc, length);
-	trunc = n - (i/j);
-	for (; i -= j >= 0; ++dp6) {
-		printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da),
-		    (unsigned long)EXTRACT_32BITS(&dp6->u_ds));
+	ND_TCHECK(*ap);
+	if (length < sizeof(*ap))
+		goto trunc;
+	ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
+	    ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+	    ap->rerr_dc, length));
+	dp6 = (struct rerr_unreach6_draft_01 *)(void *)(ap + 1);
+	i = length - sizeof(*ap);
+	for (dc = ap->rerr_dc; dc != 0; dc--) {
+		ND_TCHECK(*dp6);
+		if (i < sizeof(*dp6))
+			goto trunc;
+		ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
+		    (unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
+		dp6++;
+		i -= sizeof(*dp6);
 	}
-	if (trunc)
-		printf("[|rerr]");
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|rerr]"));
 #else
-	printf(" rerr %u", length);
+	ND_PRINT((ndo, " rerr %u", length));
 #endif
 }
 
 void
-aodv_print(const u_char *dat, u_int length, int is_ip6)
+aodv_print(netdissect_options *ndo,
+           const u_char *dat, u_int length, int is_ip6)
 {
-	const union aodv *ap;
+	uint8_t msg_type;
 
-	ap = (union aodv *)dat;
-	if (snapend < dat) {
-		printf(" [|aodv]");
-		return;
-	}
-	if (min(length, (u_int)(snapend - dat)) < sizeof(ap->rrep_ack)) {
-		printf(" [|aodv]");
-		return;
-	}
-	printf(" aodv");
+	/*
+	 * The message type is the first byte; make sure we have it
+	 * and then fetch it.
+	 */
+	ND_TCHECK(*dat);
+	msg_type = *dat;
+	ND_PRINT((ndo, " aodv"));
 
-	switch (ap->rerr.rerr_type) {
+	switch (msg_type) {
 
 	case AODV_RREQ:
 		if (is_ip6)
-			aodv_v6_rreq(ap, dat, length);
+			aodv_v6_rreq(ndo, dat, length);
 		else
-			aodv_rreq(ap, dat, length);
+			aodv_rreq(ndo, dat, length);
 		break;
 
 	case AODV_RREP:
 		if (is_ip6)
-			aodv_v6_rrep(ap, dat, length);
+			aodv_v6_rrep(ndo, dat, length);
 		else
-			aodv_rrep(ap, dat, length);
+			aodv_rrep(ndo, dat, length);
 		break;
 
 	case AODV_RERR:
 		if (is_ip6)
-			aodv_v6_rerr(ap, length);
+			aodv_v6_rerr(ndo, dat, length);
 		else
-			aodv_rerr(ap, dat, length);
+			aodv_rerr(ndo, dat, length);
 		break;
 
 	case AODV_RREP_ACK:
-		printf(" rrep-ack %u", length);
+		ND_PRINT((ndo, " rrep-ack %u", length));
 		break;
 
 	case AODV_V6_DRAFT_01_RREQ:
-		aodv_v6_draft_01_rreq(ap, dat, length);
+		aodv_v6_draft_01_rreq(ndo, dat, length);
 		break;
 
 	case AODV_V6_DRAFT_01_RREP:
-		aodv_v6_draft_01_rrep(ap, dat, length);
+		aodv_v6_draft_01_rrep(ndo, dat, length);
 		break;
 
 	case AODV_V6_DRAFT_01_RERR:
-		aodv_v6_draft_01_rerr(ap, length);
+		aodv_v6_draft_01_rerr(ndo, dat, length);
 		break;
 
 	case AODV_V6_DRAFT_01_RREP_ACK:
-		printf(" rrep-ack %u", length);
+		ND_PRINT((ndo, " rrep-ack %u", length));
 		break;
 
 	default:
-		printf(" %u %u", ap->rreq.rreq_type, length);
+		ND_PRINT((ndo, " type %u %u", msg_type, length));
 	}
+	return;
+
+trunc:
+	ND_PRINT((ndo, " [|aodv]"));
 }
diff --git a/print-aoe.c b/print-aoe.c
new file mode 100644
index 0000000..f8bc1fc
--- /dev/null
+++ b/print-aoe.c
@@ -0,0 +1,432 @@
+/*
+ * This module implements decoding of the ATA over Ethernet (AoE) protocol
+ * according to the following specification:
+ * http://support.coraid.com/documents/AoEr11.txt
+ *
+ * Copyright (c) 2014 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+#include "ether.h"
+
+static const char tstr[] = " [|aoe]";
+static const char cstr[] = " (corrupt)";
+
+#define AOE_V1 1
+#define ATA_SECTOR_SIZE 512
+
+#define AOEV1_CMD_ISSUE_ATA_COMMAND        0
+#define AOEV1_CMD_QUERY_CONFIG_INFORMATION 1
+#define AOEV1_CMD_MAC_MASK_LIST            2
+#define AOEV1_CMD_RESERVE_RELEASE          3
+
+static const struct tok cmdcode_str[] = {
+	{ AOEV1_CMD_ISSUE_ATA_COMMAND,        "Issue ATA Command"        },
+	{ AOEV1_CMD_QUERY_CONFIG_INFORMATION, "Query Config Information" },
+	{ AOEV1_CMD_MAC_MASK_LIST,            "MAC Mask List"            },
+	{ AOEV1_CMD_RESERVE_RELEASE,          "Reserve/Release"          },
+	{ 0, NULL }
+};
+
+#define AOEV1_COMMON_HDR_LEN    10U /* up to but w/o Arg                */
+#define AOEV1_ISSUE_ARG_LEN     12U /* up to but w/o Data               */
+#define AOEV1_QUERY_ARG_LEN      8U /* up to but w/o Config String      */
+#define AOEV1_MAC_ARG_LEN        4U /* up to but w/o Directive 0        */
+#define AOEV1_RESERVE_ARG_LEN    2U /* up to but w/o Ethernet address 0 */
+#define AOEV1_MAX_CONFSTR_LEN 1024U
+
+#define AOEV1_FLAG_R 0x08
+#define AOEV1_FLAG_E 0x04
+
+static const struct tok aoev1_flag_str[] = {
+	{ AOEV1_FLAG_R, "Response" },
+	{ AOEV1_FLAG_E, "Error"    },
+	{ 0x02,         "MBZ-0x02" },
+	{ 0x01,         "MBZ-0x01" },
+	{ 0, NULL }
+};
+
+static const struct tok aoev1_errcode_str[] = {
+	{ 1, "Unrecognized command code" },
+	{ 2, "Bad argument parameter"    },
+	{ 3, "Device unavailable"        },
+	{ 4, "Config string present"     },
+	{ 5, "Unsupported version"       },
+	{ 6, "Target is reserved"        },
+	{ 0, NULL }
+};
+
+#define AOEV1_AFLAG_E 0x40
+#define AOEV1_AFLAG_D 0x10
+#define AOEV1_AFLAG_A 0x02
+#define AOEV1_AFLAG_W 0x01
+
+static const struct tok aoev1_aflag_str[] = {
+	{ 0x08,          "MBZ-0x08" },
+	{ AOEV1_AFLAG_E, "Ext48"    },
+	{ 0x06,          "MBZ-0x06" },
+	{ AOEV1_AFLAG_D, "Device"   },
+	{ 0x04,          "MBZ-0x04" },
+	{ 0x03,          "MBZ-0x03" },
+	{ AOEV1_AFLAG_A, "Async"    },
+	{ AOEV1_AFLAG_W, "Write"    },
+	{ 0, NULL }
+};
+
+static const struct tok aoev1_ccmd_str[] = {
+	{ 0, "read config string"        },
+	{ 1, "test config string"        },
+	{ 2, "test config string prefix" },
+	{ 3, "set config string"         },
+	{ 4, "force set config string"   },
+	{ 0, NULL }
+};
+
+static const struct tok aoev1_mcmd_str[] = {
+	{ 0, "Read Mac Mask List" },
+	{ 1, "Edit Mac Mask List" },
+	{ 0, NULL }
+};
+
+static const struct tok aoev1_merror_str[] = {
+	{ 1, "Unspecified Error"  },
+	{ 2, "Bad DCmd directive" },
+	{ 3, "Mask list full"     },
+	{ 0, NULL }
+};
+
+static const struct tok aoev1_dcmd_str[] = {
+	{ 0, "No Directive"                      },
+	{ 1, "Add mac address to mask list"      },
+	{ 2, "Delete mac address from mask list" },
+	{ 0, NULL }
+};
+
+static const struct tok aoev1_rcmd_str[] = {
+	{ 0, "Read reserve list"      },
+	{ 1, "Set reserve list"       },
+	{ 2, "Force set reserve list" },
+	{ 0, NULL }
+};
+
+static void
+aoev1_issue_print(netdissect_options *ndo,
+                  const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+
+	if (len < AOEV1_ISSUE_ARG_LEN)
+		goto corrupt;
+	/* AFlags */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp)));
+	cp += 1;
+	/* Err/Feature */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", Err/Feature: %u", *cp));
+	cp += 1;
+	/* Sector Count (not correlated with the length) */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", Sector Count: %u", *cp));
+	cp += 1;
+	/* Cmd/Status */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", Cmd/Status: %u", *cp));
+	cp += 1;
+	/* lba0 */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, "\n\tlba0: %u", *cp));
+	cp += 1;
+	/* lba1 */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", lba1: %u", *cp));
+	cp += 1;
+	/* lba2 */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", lba2: %u", *cp));
+	cp += 1;
+	/* lba3 */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", lba3: %u", *cp));
+	cp += 1;
+	/* lba4 */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", lba4: %u", *cp));
+	cp += 1;
+	/* lba5 */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", lba5: %u", *cp));
+	cp += 1;
+	/* Reserved */
+	ND_TCHECK2(*cp, 2);
+	cp += 2;
+	/* Data */
+	if (len > AOEV1_ISSUE_ARG_LEN)
+		ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN));
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_query_print(netdissect_options *ndo,
+                  const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint16_t cslen;
+
+	if (len < AOEV1_QUERY_ARG_LEN)
+		goto corrupt;
+	/* Buffer Count */
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp)));
+	cp += 2;
+	/* Firmware Version */
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", Firmware Version: %u", EXTRACT_16BITS(cp)));
+	cp += 2;
+	/* Sector Count */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", Sector Count: %u", *cp));
+	cp += 1;
+	/* AoE/CCmd */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (*cp & 0xF0) >> 4,
+	          tok2str(aoev1_ccmd_str, "Unknown (0x02x)", *cp & 0x0F)));
+	cp += 1;
+	/* Config String Length */
+	ND_TCHECK2(*cp, 2);
+	cslen = EXTRACT_16BITS(cp);
+	cp += 2;
+	if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
+		goto corrupt;
+	/* Config String */
+	ND_TCHECK2(*cp, cslen);
+	if (cslen) {
+		ND_PRINT((ndo, "\n\tConfig String (length %u): ", cslen));
+		if (fn_printn(ndo, cp, cslen, ndo->ndo_snapend))
+			goto trunc;
+	}
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_mac_print(netdissect_options *ndo,
+                const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint8_t dircount, i;
+
+	if (len < AOEV1_MAC_ARG_LEN)
+		goto corrupt;
+	/* Reserved */
+	ND_TCHECK2(*cp, 1);
+	cp += 1;
+	/* MCmd */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, "\n\tMCmd: %s", tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", *cp)));
+	cp += 1;
+	/* MError */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", MError: %s", tok2str(aoev1_merror_str, "Unknown (0x%02x)", *cp)));
+	cp += 1;
+	/* Dir Count */
+	ND_TCHECK2(*cp, 1);
+	dircount = *cp;
+	cp += 1;
+	ND_PRINT((ndo, ", Dir Count: %u", dircount));
+	if (AOEV1_MAC_ARG_LEN + dircount * 8 > len)
+		goto corrupt;
+	/* directives */
+	for (i = 0; i < dircount; i++) {
+		/* Reserved */
+		ND_TCHECK2(*cp, 1);
+		cp += 1;
+		/* DCmd */
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", *cp)));
+		cp += 1;
+		/* Ethernet Address */
+		ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+		ND_PRINT((ndo, ", Ethernet Address: %s", etheraddr_string(ndo, cp)));
+		cp += ETHER_ADDR_LEN;
+	}
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_reserve_print(netdissect_options *ndo,
+                    const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint8_t nmacs, i;
+
+	if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
+		goto corrupt;
+	/* RCmd */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp)));
+	cp += 1;
+	/* NMacs (correlated with the length) */
+	ND_TCHECK2(*cp, 1);
+	nmacs = *cp;
+	cp += 1;
+	ND_PRINT((ndo, ", NMacs: %u", nmacs));
+	if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
+		goto corrupt;
+	/* addresses */
+	for (i = 0; i < nmacs; i++) {
+		ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
+		cp += ETHER_ADDR_LEN;
+	}
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+/* cp points to the Ver/Flags octet */
+static void
+aoev1_print(netdissect_options *ndo,
+            const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint8_t flags, command;
+	void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int);
+
+	if (len < AOEV1_COMMON_HDR_LEN)
+		goto corrupt;
+	/* Flags */
+	flags = *cp & 0x0F;
+	ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
+	cp += 1;
+	if (! ndo->ndo_vflag)
+		return;
+	/* Error */
+	ND_TCHECK2(*cp, 1);
+	if (flags & AOEV1_FLAG_E)
+		ND_PRINT((ndo, "\n\tError: %s", tok2str(aoev1_errcode_str, "Invalid (%u)", *cp)));
+	cp += 1;
+	/* Major */
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, "\n\tMajor: 0x%04x", EXTRACT_16BITS(cp)));
+	cp += 2;
+	/* Minor */
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", Minor: 0x%02x", *cp));
+	cp += 1;
+	/* Command */
+	ND_TCHECK2(*cp, 1);
+	command = *cp;
+	cp += 1;
+	ND_PRINT((ndo, ", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command)));
+	/* Tag */
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ", Tag: 0x%08x", EXTRACT_32BITS(cp)));
+	cp += 4;
+	/* Arg */
+	cmd_decoder =
+		command == AOEV1_CMD_ISSUE_ATA_COMMAND        ? aoev1_issue_print :
+		command == AOEV1_CMD_QUERY_CONFIG_INFORMATION ? aoev1_query_print :
+		command == AOEV1_CMD_MAC_MASK_LIST            ? aoev1_mac_print :
+		command == AOEV1_CMD_RESERVE_RELEASE          ? aoev1_reserve_print :
+		NULL;
+	if (cmd_decoder != NULL)
+		cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN);
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+aoe_print(netdissect_options *ndo,
+          const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint8_t ver;
+
+	ND_PRINT((ndo, "AoE length %u", len));
+
+	if (len < 1)
+		goto corrupt;
+	/* Ver/Flags */
+	ND_TCHECK2(*cp, 1);
+	ver = (*cp & 0xF0) >> 4;
+	/* Don't advance cp yet: low order 4 bits are version-specific. */
+	ND_PRINT((ndo, ", Ver %u", ver));
+
+	switch (ver) {
+		case AOE_V1:
+			aoev1_print(ndo, cp, len);
+			break;
+	}
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
diff --git a/print-ap1394.c b/print-ap1394.c
index ab0713b..3befe23 100644
--- a/print-ap1394.c
+++ b/print-ap1394.c
@@ -18,20 +18,14 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.5 2006-02-11 22:12:06 hannes Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -55,27 +49,27 @@
 #define FIREWIRE_HDRLEN		18
 
 static inline void
-ap1394_hdr_print(register const u_char *bp, u_int length)
+ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
 {
 	register const struct firewire_header *fp;
-	u_int16_t firewire_type;
+	uint16_t firewire_type;
 
 	fp = (const struct firewire_header *)bp;
 
-	(void)printf("%s > %s",
-		     linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
-		     linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
+	ND_PRINT((ndo, "%s > %s",
+		     linkaddr_string(ndo, fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
+		     linkaddr_string(ndo, fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)));
 
 	firewire_type = EXTRACT_16BITS(&fp->firewire_type);
-	if (!qflag) {
-		(void)printf(", ethertype %s (0x%04x)",
+	if (!ndo->ndo_qflag) {
+		ND_PRINT((ndo, ", ethertype %s (0x%04x)",
 			       tok2str(ethertype_values,"Unknown", firewire_type),
-                               firewire_type);
+                               firewire_type));
         } else {
-                (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type));
+                ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type)));
         }
 
-	(void)printf(", length %u: ", length);
+	ND_PRINT((ndo, ", length %u: ", length));
 }
 
 /*
@@ -85,7 +79,7 @@
  * is the number of bytes actually captured.
  */
 u_int
-ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int length = h->len;
 	u_int caplen = h->caplen;
@@ -93,12 +87,12 @@
 	u_short ether_type;
 
 	if (caplen < FIREWIRE_HDRLEN) {
-		printf("[|ap1394]");
+		ND_PRINT((ndo, "[|ap1394]"));
 		return FIREWIRE_HDRLEN;
 	}
 
-	if (eflag)
-		ap1394_hdr_print(p, length);
+	if (ndo->ndo_eflag)
+		ap1394_hdr_print(ndo, p, length);
 
 	length -= FIREWIRE_HDRLEN;
 	caplen -= FIREWIRE_HDRLEN;
@@ -106,14 +100,14 @@
 	p += FIREWIRE_HDRLEN;
 
 	ether_type = EXTRACT_16BITS(&fp->firewire_type);
-	if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+	if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
 		/* ether_type not known, print raw packet */
-		if (!eflag)
-			ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
+		if (!ndo->ndo_eflag)
+			ap1394_hdr_print(ndo, (u_char *)fp, length + FIREWIRE_HDRLEN);
 
-		if (!suppress_default_print)
-			default_print(p, caplen);
-	} 
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
+	}
 
 	return FIREWIRE_HDRLEN;
 }
diff --git a/print-arcnet.c b/print-arcnet.c
index 2d60537..0ffb922 100644
--- a/print-arcnet.c
+++ b/print-arcnet.c
@@ -20,25 +20,87 @@
  *
  * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "arcnet.h"
 
-static int arcnet_encap_print(u_char arctype, const u_char *p,
+/*
+ * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
+ */
+
+/*
+ * Structure of a 2.5MB/s Arcnet header on the BSDs,
+ * as given to interface code.
+ */
+struct	arc_header {
+	uint8_t  arc_shost;
+	uint8_t  arc_dhost;
+	uint8_t  arc_type;
+	/*
+	 * only present for newstyle encoding with LL fragmentation.
+	 * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
+	 */
+	uint8_t  arc_flag;
+	uint16_t arc_seqid;
+
+	/*
+	 * only present in exception packets (arc_flag == 0xff)
+	 */
+	uint8_t  arc_type2;	/* same as arc_type */
+	uint8_t  arc_flag2;	/* real flag value */
+	uint16_t arc_seqid2;	/* real seqid value */
+};
+
+#define	ARC_HDRLEN		3
+#define	ARC_HDRNEWLEN		6
+#define	ARC_HDRNEWLEN_EXC	10
+
+/* RFC 1051 */
+#define	ARCTYPE_IP_OLD		240	/* IP protocol */
+#define	ARCTYPE_ARP_OLD		241	/* address resolution protocol */
+
+/* RFC 1201 */
+#define	ARCTYPE_IP		212	/* IP protocol */
+#define	ARCTYPE_ARP		213	/* address resolution protocol */
+#define	ARCTYPE_REVARP		214	/* reverse addr resolution protocol */
+
+#define	ARCTYPE_ATALK		221	/* Appletalk */
+#define	ARCTYPE_BANIAN		247	/* Banyan Vines */
+#define	ARCTYPE_IPX		250	/* Novell IPX */
+
+#define ARCTYPE_INET6		0xc4	/* IPng */
+#define ARCTYPE_DIAGNOSE	0x80	/* as per ANSI/ATA 878.1 */
+
+/*
+ * Structure of a 2.5MB/s Arcnet header on Linux.  Linux has
+ * an extra "offset" field when given to interface code, and
+ * never presents packets that look like exception frames.
+ */
+struct	arc_linux_header {
+	uint8_t  arc_shost;
+	uint8_t  arc_dhost;
+	uint16_t arc_offset;
+	uint8_t  arc_type;
+	/*
+	 * only present for newstyle encoding with LL fragmentation.
+	 * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
+	 * instead.
+	 */
+	uint8_t  arc_flag;
+	uint16_t arc_seqid;
+};
+
+#define	ARC_LINUX_HDRLEN	5
+#define	ARC_LINUX_HDRNEWLEN	8
+
+static int arcnet_encap_print(netdissect_options *, u_char arctype, const u_char *p,
     u_int length, u_int caplen);
 
 static const struct tok arctypemap[] = {
@@ -56,7 +118,8 @@
 };
 
 static inline void
-arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
+arcnet_print(netdissect_options *ndo, const u_char *bp, u_int length, int phds,
+             int flag, u_int seqid)
 {
 	const struct arc_header *ap;
 	const char *arctypename;
@@ -65,40 +128,40 @@
 	ap = (const struct arc_header *)bp;
 
 
-	if (qflag) {
-		(void)printf("%02x %02x %d: ",
+	if (ndo->ndo_qflag) {
+		ND_PRINT((ndo, "%02x %02x %d: ",
 			     ap->arc_shost,
 			     ap->arc_dhost,
-			     length);
+			     length));
 		return;
 	}
 
 	arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
 
 	if (!phds) {
-		(void)printf("%02x %02x %s %d: ",
+		ND_PRINT((ndo, "%02x %02x %s %d: ",
 			     ap->arc_shost, ap->arc_dhost, arctypename,
-			     length);
+			     length));
 			     return;
 	}
 
 	if (flag == 0) {
-		(void)printf("%02x %02x %s seqid %04x %d: ",
+		ND_PRINT((ndo, "%02x %02x %s seqid %04x %d: ",
 			ap->arc_shost, ap->arc_dhost, arctypename, seqid,
-			length);
+			length));
 			return;
 	}
 
 	if (flag & 1)
-		(void)printf("%02x %02x %s seqid %04x "
+		ND_PRINT((ndo, "%02x %02x %s seqid %04x "
 			"(first of %d fragments) %d: ",
 			ap->arc_shost, ap->arc_dhost, arctypename, seqid,
-			(flag + 3) / 2, length);
+			(flag + 3) / 2, length));
 	else
-		(void)printf("%02x %02x %s seqid %04x "
+		ND_PRINT((ndo, "%02x %02x %s seqid %04x "
 			"(fragment %d) %d: ",
 			ap->arc_shost, ap->arc_dhost, arctypename, seqid,
-			flag/2 + 1, length);
+			flag/2 + 1, length));
 }
 
 /*
@@ -108,7 +171,7 @@
  * is the number of bytes actually captured.
  */
 u_int
-arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
+arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	u_int length = h->len;
@@ -118,8 +181,8 @@
 	u_int seqid = 0;
 	u_char arc_type;
 
-	if (caplen < ARC_HDRLEN) {
-		printf("[|arcnet]");
+	if (caplen < ARC_HDRLEN || length < ARC_HDRLEN) {
+		ND_PRINT((ndo, "[|arcnet]"));
 		return (caplen);
 	}
 
@@ -139,16 +202,16 @@
 	}
 
 	if (phds) {
-		if (caplen < ARC_HDRNEWLEN) {
-			arcnet_print(p, length, 0, 0, 0);
-			printf("[|phds]");
+		if (caplen < ARC_HDRNEWLEN || length < ARC_HDRNEWLEN) {
+			arcnet_print(ndo, p, length, 0, 0, 0);
+			ND_PRINT((ndo, "[|phds]"));
 			return (caplen);
 		}
 
 		if (ap->arc_flag == 0xff) {
-			if (caplen < ARC_HDRNEWLEN_EXC) {
-				arcnet_print(p, length, 0, 0, 0);
-				printf("[|phds extended]");
+			if (caplen < ARC_HDRNEWLEN_EXC || length < ARC_HDRNEWLEN_EXC) {
+				arcnet_print(ndo, p, length, 0, 0, 0);
+				ND_PRINT((ndo, "[|phds extended]"));
 				return (caplen);
 			}
 			flag = ap->arc_flag2;
@@ -162,8 +225,8 @@
 	}
 
 
-	if (eflag)
-		arcnet_print(p, length, phds, flag, seqid);
+	if (ndo->ndo_eflag)
+		arcnet_print(ndo, p, length, phds, flag, seqid);
 
 	/*
 	 * Go past the ARCNET header.
@@ -179,8 +242,8 @@
 		return (archdrlen);
 	}
 
-	if (!arcnet_encap_print(arc_type, p, length, caplen))
-		default_print(p, caplen);
+	if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
+		ND_DEFAULTPRINT(p, caplen);
 
 	return (archdrlen);
 }
@@ -196,7 +259,7 @@
  * extra "offset" field between the src/dest and packet type.
  */
 u_int
-arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
+arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	u_int length = h->len;
@@ -205,8 +268,8 @@
 	int archdrlen = 0;
 	u_char arc_type;
 
-	if (caplen < ARC_LINUX_HDRLEN) {
-		printf("[|arcnet]");
+	if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) {
+		ND_PRINT((ndo, "[|arcnet]"));
 		return (caplen);
 	}
 
@@ -216,8 +279,8 @@
 	switch (arc_type) {
 	default:
 		archdrlen = ARC_LINUX_HDRNEWLEN;
-		if (caplen < ARC_LINUX_HDRNEWLEN) {
-			printf("[|arcnet]");
+		if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) {
+			ND_PRINT((ndo, "[|arcnet]"));
 			return (caplen);
 		}
 		break;
@@ -228,8 +291,8 @@
 		break;
 	}
 
-	if (eflag)
-		arcnet_print(p, length, 0, 0, 0);
+	if (ndo->ndo_eflag)
+		arcnet_print(ndo, p, length, 0, 0, 0);
 
 	/*
 	 * Go past the ARCNET header.
@@ -238,8 +301,8 @@
 	caplen -= archdrlen;
 	p += archdrlen;
 
-	if (!arcnet_encap_print(arc_type, p, length, caplen))
-		default_print(p, caplen);
+	if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
+		ND_DEFAULTPRINT(p, caplen);
 
 	return (archdrlen);
 }
@@ -253,36 +316,34 @@
 
 
 static int
-arcnet_encap_print(u_char arctype, const u_char *p,
+arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
     u_int length, u_int caplen)
 {
 	switch (arctype) {
 
 	case ARCTYPE_IP_OLD:
 	case ARCTYPE_IP:
-	        ip_print(gndo, p, length);
+	        ip_print(ndo, p, length);
 		return (1);
 
-#ifdef INET6
 	case ARCTYPE_INET6:
-		ip6_print(gndo, p, length);
+		ip6_print(ndo, p, length);
 		return (1);
-#endif /*INET6*/
 
 	case ARCTYPE_ARP_OLD:
 	case ARCTYPE_ARP:
 	case ARCTYPE_REVARP:
-		arp_print(gndo, p, length, caplen);
+		arp_print(ndo, p, length, caplen);
 		return (1);
 
 	case ARCTYPE_ATALK:	/* XXX was this ever used? */
-		if (vflag)
-			fputs("et1 ", stdout);
-		atalk_print(p, length);
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, "et1 "));
+		atalk_print(ndo, p, length);
 		return (1);
 
 	case ARCTYPE_IPX:
-		ipx_print(p, length);
+		ipx_print(ndo, p, length);
 		return (1);
 
 	default:
diff --git a/print-arp.c b/print-arp.c
index b5047a0..76f39fe 100644
--- a/print-arp.c
+++ b/print-arp.c
@@ -19,26 +19,23 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
-#include "netdissect.h"
+#include "interface.h"
 #include "addrtoname.h"
 #include "ether.h"
 #include "ethertype.h"
 #include "extract.h"			/* must come after interface.h */
 
+static const char tstr[] = "[|ARP]";
+
 /*
  * Address Resolution Protocol.
  *
@@ -189,10 +186,10 @@
 	if (ha_len == 0)
 		ND_PRINT((ndo, "<No address>"));
 	else {
-		ND_PRINT((ndo, "%s", linkaddr_string(ha, LINKADDR_ATM, ha_len)));
-		if (srca_len != 0) 
+		ND_PRINT((ndo, "%s", linkaddr_string(ndo, ha, LINKADDR_ATM, ha_len)));
+		if (srca_len != 0)
 			ND_PRINT((ndo, ",%s",
-				  linkaddr_string(srca, LINKADDR_ATM, srca_len)));
+				  linkaddr_string(ndo, srca, LINKADDR_ATM, srca_len)));
 	}
 }
 
@@ -211,7 +208,7 @@
 	op = ATMOP(ap);
 
 	if (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) {
-		ND_PRINT((ndo, "[|ARP]"));
+		ND_PRINT((ndo, "%s", tstr));
 		ND_DEFAULTPRINT((const u_char *)ap, length);
 		return;
 	}
@@ -237,25 +234,25 @@
 	}
 
         /* print operation */
-        printf("%s%s ",
-               ndo->ndo_vflag ? ", " : "", 
-               tok2str(arpop_values, "Unknown (%u)", op));
+        ND_PRINT((ndo, "%s%s ",
+               ndo->ndo_vflag ? ", " : "",
+               tok2str(arpop_values, "Unknown (%u)", op)));
 
 	switch (op) {
 
 	case ARPOP_REQUEST:
-		ND_PRINT((ndo, "who-has %s", ipaddr_string(ATMTPA(ap))));
+		ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, ATMTPA(ap))));
 		if (ATMTHRD_LEN(ap) != 0) {
 			ND_PRINT((ndo, " ("));
 			atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),
 			    ATMTSA(ap), ATMTSLN(ap));
 			ND_PRINT((ndo, ")"));
 		}
-		ND_PRINT((ndo, "tell %s", ipaddr_string(ATMSPA(ap))));
+		ND_PRINT((ndo, "tell %s", ipaddr_string(ndo, ATMSPA(ap))));
 		break;
 
 	case ARPOP_REPLY:
-		ND_PRINT((ndo, "%s is-at ", ipaddr_string(ATMSPA(ap))));
+		ND_PRINT((ndo, "%s is-at ", ipaddr_string(ndo, ATMSPA(ap))));
 		atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
                                   ATMSSLN(ap));
 		break;
@@ -272,11 +269,11 @@
 	case ARPOP_INVREPLY:
 		atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
 		    ATMSSLN(ap));
-		ND_PRINT((ndo, "at %s", ipaddr_string(ATMSPA(ap))));
+		ND_PRINT((ndo, "at %s", ipaddr_string(ndo, ATMSPA(ap))));
 		break;
 
 	case ARPOP_NAK:
-		ND_PRINT((ndo, "for %s", ipaddr_string(ATMSPA(ap))));
+		ND_PRINT((ndo, "for %s", ipaddr_string(ndo, ATMSPA(ap))));
 		break;
 
 	default:
@@ -289,7 +286,7 @@
         return;
 
 trunc:
-	ND_PRINT((ndo, "[|ARP]"));
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 void
@@ -306,11 +303,11 @@
 	pro = PRO(ap);
 	op = OP(ap);
 
-        
+
         /* if its ATM then call the ATM ARP printer
            for Frame-relay ARP most of the fields
            are similar to Ethernet so overload the Ethernet Printer
-           and set the linkaddr type for linkaddr_string() accordingly */
+           and set the linkaddr type for linkaddr_string(ndo, ) accordingly */
 
         switch(hrd) {
         case ARPHRD_ATM2225:
@@ -325,7 +322,7 @@
 	}
 
 	if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) {
-		ND_PRINT((ndo, "[|ARP]"));
+		ND_PRINT((ndo, "%s", tstr));
 		ND_DEFAULTPRINT((const u_char *)ap, length);
 		return;
 	}
@@ -352,48 +349,48 @@
 	}
 
         /* print operation */
-        printf("%s%s ",
-               ndo->ndo_vflag ? ", " : "", 
-               tok2str(arpop_values, "Unknown (%u)", op));
+        ND_PRINT((ndo, "%s%s ",
+               ndo->ndo_vflag ? ", " : "",
+               tok2str(arpop_values, "Unknown (%u)", op)));
 
 	switch (op) {
 
 	case ARPOP_REQUEST:
-		ND_PRINT((ndo, "who-has %s", ipaddr_string(TPA(ap))));
+		ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap))));
 		if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0)
 			ND_PRINT((ndo, " (%s)",
-				  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap))));
-		ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap))));
+				  linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
+		ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap))));
 		break;
 
 	case ARPOP_REPLY:
 		ND_PRINT((ndo, "%s is-at %s",
-                          ipaddr_string(SPA(ap)),
-                          linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+                          ipaddr_string(ndo, SPA(ap)),
+                          linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
 		break;
 
 	case ARPOP_REVREQUEST:
 		ND_PRINT((ndo, "who-is %s tell %s",
-			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
-			  linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+			  linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+			  linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
 		break;
 
 	case ARPOP_REVREPLY:
 		ND_PRINT((ndo, "%s at %s",
-			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
-			  ipaddr_string(TPA(ap))));
+			  linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+			  ipaddr_string(ndo, TPA(ap))));
 		break;
 
 	case ARPOP_INVREQUEST:
 		ND_PRINT((ndo, "who-is %s tell %s",
-			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
-			  linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+			  linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+			  linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
 		break;
 
 	case ARPOP_INVREPLY:
 		ND_PRINT((ndo,"%s at %s",
-			  linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
-			  ipaddr_string(TPA(ap))));
+			  linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap)),
+			  ipaddr_string(ndo, SPA(ap))));
 		break;
 
 	default:
@@ -406,7 +403,7 @@
 
 	return;
 trunc:
-	ND_PRINT((ndo, "[|ARP]"));
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
diff --git a/print-ascii.c b/print-ascii.c
index f09aa98..3cefef3 100644
--- a/print-ascii.c
+++ b/print-ascii.c
@@ -36,14 +36,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.17 2005-07-06 20:53:32 guy Exp $";
-#endif
 #include <tcpdump-stdinc.h>
 #include <stdio.h>
 
@@ -57,11 +54,16 @@
 		(HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
 
 void
-ascii_print(register const u_char *cp, register u_int length)
+ascii_print(netdissect_options *ndo,
+            const u_char *cp, u_int length)
 {
-	register int s;
+	u_int caplength;
+	register u_char s;
 
-	putchar('\n');
+	caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
+	if (length > caplength)
+		length = caplength;
+	ND_PRINT((ndo, "\n"));
 	while (length > 0) {
 		s = *cp++;
 		length--;
@@ -76,27 +78,31 @@
 			 * In the middle of a line, just print a '.'.
 			 */
 			if (length > 1 && *cp != '\n')
-				putchar('.');
+				ND_PRINT((ndo, "."));
 		} else {
 			if (!ND_ISGRAPH(s) &&
 			    (s != '\t' && s != ' ' && s != '\n'))
-				putchar('.');
+				ND_PRINT((ndo, "."));
 			else
-				putchar(s);
+				ND_PRINT((ndo, "%c", s));
 		}
 	}
 }
 
 void
-hex_and_ascii_print_with_offset(register const char *ident,
+hex_and_ascii_print_with_offset(netdissect_options *ndo, register const char *ident,
     register const u_char *cp, register u_int length, register u_int oset)
 {
+	u_int caplength;
 	register u_int i;
 	register int s1, s2;
 	register int nshorts;
 	char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
 	char asciistuff[ASCII_LINELENGTH+1], *asp;
 
+	caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
+	if (length > caplength)
+		length = caplength;
 	nshorts = length / sizeof(u_short);
 	i = 0;
 	hsp = hexstuff; asp = asciistuff;
@@ -111,9 +117,9 @@
 		i++;
 		if (i >= HEXDUMP_SHORTS_PER_LINE) {
 			*hsp = *asp = '\0';
-			(void)printf("%s0x%04x: %-*s  %s",
+			ND_PRINT((ndo, "%s0x%04x: %-*s  %s",
 			    ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
-			    hexstuff, asciistuff);
+			    hexstuff, asciistuff));
 			i = 0; hsp = hexstuff; asp = asciistuff;
 			oset += HEXDUMP_BYTES_PER_LINE;
 		}
@@ -128,43 +134,48 @@
 	}
 	if (i > 0) {
 		*hsp = *asp = '\0';
-		(void)printf("%s0x%04x: %-*s  %s",
+		ND_PRINT((ndo, "%s0x%04x: %-*s  %s",
 		     ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
-		     hexstuff, asciistuff);
+		     hexstuff, asciistuff));
 	}
 }
 
 void
-hex_and_ascii_print(register const char *ident, register const u_char *cp,
-    register u_int length)
+hex_and_ascii_print(netdissect_options *ndo, register const char *ident,
+    register const u_char *cp, register u_int length)
 {
-	hex_and_ascii_print_with_offset(ident, cp, length, 0);
+	hex_and_ascii_print_with_offset(ndo, ident, cp, length, 0);
 }
 
 /*
  * telnet_print() wants this.  It is essentially default_print_unaligned()
  */
 void
-hex_print_with_offset(register const char *ident, register const u_char *cp, register u_int length,
-		      register u_int oset)
+hex_print_with_offset(netdissect_options *ndo,
+                      const char *ident, const u_char *cp, u_int length,
+		      u_int oset)
 {
+	u_int caplength;
 	register u_int i, s;
 	register int nshorts;
 
+	caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
+	if (length > caplength)
+		length = caplength;
 	nshorts = (u_int) length / sizeof(u_short);
 	i = 0;
 	while (--nshorts >= 0) {
 		if ((i++ % 8) == 0) {
-			(void)printf("%s0x%04x: ", ident, oset);
+			ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
 			oset += HEXDUMP_BYTES_PER_LINE;
 		}
 		s = *cp++;
-		(void)printf(" %02x%02x", s, *cp++);
+		ND_PRINT((ndo," %02x%02x", s, *cp++));
 	}
 	if (length & 1) {
 		if ((i % 8) == 0)
-			(void)printf("%s0x%04x: ", ident, oset);
-		(void)printf(" %02x", *cp);
+			ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
+		ND_PRINT((ndo," %02x", *cp));
 	}
 }
 
@@ -172,9 +183,9 @@
  * just for completeness
  */
 void
-hex_print(register const char *ident, register const u_char *cp, register u_int length)
+hex_print(netdissect_options *ndo,const char *ident, const u_char *cp, u_int length)
 {
-	hex_print_with_offset(ident, cp, length, 0);
+  hex_print_with_offset(ndo, ident, cp, length, 0);
 }
 
 #ifdef MAIN
diff --git a/print-atalk.c b/print-atalk.c
index be1c154..6140549 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -21,11 +21,7 @@
  * Format and print AppleTalk packets.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -33,9 +29,7 @@
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#include <pcap.h>
 
 #include "interface.h"
 #include "addrtoname.h"
@@ -43,6 +37,8 @@
 #include "extract.h"			/* must come after interface.h */
 #include "appletalk.h"
 
+static const char tstr[] = "[|atalk]";
+
 static const struct tok type2str[] = {
 	{ ddpRTMP,		"rtmp" },
 	{ ddpRTMPrequest,	"rtmpReq" },
@@ -54,44 +50,43 @@
 };
 
 struct aarp {
-	u_int16_t	htype, ptype;
-	u_int8_t	halen, palen;
-	u_int16_t	op;
-	u_int8_t	hsaddr[6];
-	u_int8_t	psaddr[4];
-	u_int8_t	hdaddr[6];
-	u_int8_t	pdaddr[4];
+	uint16_t	htype, ptype;
+	uint8_t		halen, palen;
+	uint16_t	op;
+	uint8_t		hsaddr[6];
+	uint8_t		psaddr[4];
+	uint8_t		hdaddr[6];
+	uint8_t		pdaddr[4];
 };
 
-static char tstr[] = "[|atalk]";
-
-static void atp_print(const struct atATP *, u_int);
-static void atp_bitmap_print(u_char);
-static void nbp_print(const struct atNBP *, u_int, u_short, u_char, u_char);
-static const char *print_cstring(const char *, const u_char *);
-static const struct atNBPtuple *nbp_tuple_print(const struct atNBPtuple *,
+static void atp_print(netdissect_options *, const struct atATP *, u_int);
+static void atp_bitmap_print(netdissect_options *, u_char);
+static void nbp_print(netdissect_options *, const struct atNBP *, u_int, u_short, u_char, u_char);
+static const struct atNBPtuple *nbp_tuple_print(netdissect_options *ndo, const struct atNBPtuple *,
 						const u_char *,
 						u_short, u_char, u_char);
-static const struct atNBPtuple *nbp_name_print(const struct atNBPtuple *,
+static const struct atNBPtuple *nbp_name_print(netdissect_options *, const struct atNBPtuple *,
 					       const u_char *);
-static const char *ataddr_string(u_short, u_char);
-static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
-static const char *ddpskt_string(int);
+static const char *ataddr_string(netdissect_options *, u_short, u_char);
+static void ddp_print(netdissect_options *, const u_char *, u_int, int, u_short, u_char, u_char);
+static const char *ddpskt_string(netdissect_options *, int);
 
 /*
  * Print LLAP packets received on a physical LocalTalk interface.
  */
 u_int
-ltalk_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ltalk_if_print(netdissect_options *ndo,
+               const struct pcap_pkthdr *h, const u_char *p)
 {
-	return (llap_print(p, h->caplen));
+	return (llap_print(ndo, p, h->caplen));
 }
 
 /*
  * Print AppleTalk LLAP packets.
  */
 u_int
-llap_print(register const u_char *bp, u_int length)
+llap_print(netdissect_options *ndo,
+           register const u_char *bp, u_int length)
 {
 	register const struct LAP *lp;
 	register const struct atDDP *dp;
@@ -100,7 +95,7 @@
 	u_int hdrlen;
 
 	if (length < sizeof(*lp)) {
-		(void)printf(" [|llap %u]", length);
+		ND_PRINT((ndo, " [|llap %u]", length));
 		return (length);
 	}
 	lp = (const struct LAP *)bp;
@@ -111,36 +106,36 @@
 
 	case lapShortDDP:
 		if (length < ddpSSize) {
-			(void)printf(" [|sddp %u]", length);
+			ND_PRINT((ndo, " [|sddp %u]", length));
 			return (length);
 		}
 		sdp = (const struct atShortDDP *)bp;
-		printf("%s.%s",
-		    ataddr_string(0, lp->src), ddpskt_string(sdp->srcSkt));
-		printf(" > %s.%s:",
-		    ataddr_string(0, lp->dst), ddpskt_string(sdp->dstSkt));
+		ND_PRINT((ndo, "%s.%s",
+		    ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt)));
+		ND_PRINT((ndo, " > %s.%s:",
+		    ataddr_string(ndo, 0, lp->dst), ddpskt_string(ndo, sdp->dstSkt)));
 		bp += ddpSSize;
 		length -= ddpSSize;
 		hdrlen += ddpSSize;
-		ddp_print(bp, length, sdp->type, 0, lp->src, sdp->srcSkt);
+		ddp_print(ndo, bp, length, sdp->type, 0, lp->src, sdp->srcSkt);
 		break;
 
 	case lapDDP:
 		if (length < ddpSize) {
-			(void)printf(" [|ddp %u]", length);
+			ND_PRINT((ndo, " [|ddp %u]", length));
 			return (length);
 		}
 		dp = (const struct atDDP *)bp;
 		snet = EXTRACT_16BITS(&dp->srcNet);
-		printf("%s.%s", ataddr_string(snet, dp->srcNode),
-		    ddpskt_string(dp->srcSkt));
-		printf(" > %s.%s:",
-		    ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
-		    ddpskt_string(dp->dstSkt));
+		ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
+		    ddpskt_string(ndo, dp->srcSkt)));
+		ND_PRINT((ndo, " > %s.%s:",
+		    ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
+		    ddpskt_string(ndo, dp->dstSkt)));
 		bp += ddpSize;
 		length -= ddpSize;
 		hdrlen += ddpSize;
-		ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
+		ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
 		break;
 
 #ifdef notdef
@@ -150,8 +145,8 @@
 #endif
 
 	default:
-		printf("%d > %d at-lap#%d %u",
-		    lp->src, lp->dst, lp->type, length);
+		ND_PRINT((ndo, "%d > %d at-lap#%d %u",
+		    lp->src, lp->dst, lp->type, length));
 		break;
 	}
 	return (hdrlen);
@@ -163,39 +158,41 @@
  * packets in them).
  */
 void
-atalk_print(register const u_char *bp, u_int length)
+atalk_print(netdissect_options *ndo,
+            register const u_char *bp, u_int length)
 {
 	register const struct atDDP *dp;
 	u_short snet;
 
-        if(!eflag)
-            printf("AT ");
+        if(!ndo->ndo_eflag)
+            ND_PRINT((ndo, "AT "));
 
 	if (length < ddpSize) {
-		(void)printf(" [|ddp %u]", length);
+		ND_PRINT((ndo, " [|ddp %u]", length));
 		return;
 	}
 	dp = (const struct atDDP *)bp;
 	snet = EXTRACT_16BITS(&dp->srcNet);
-	printf("%s.%s", ataddr_string(snet, dp->srcNode),
-	       ddpskt_string(dp->srcSkt));
-	printf(" > %s.%s: ",
-	       ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
-	       ddpskt_string(dp->dstSkt));
+	ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
+	       ddpskt_string(ndo, dp->srcSkt)));
+	ND_PRINT((ndo, " > %s.%s: ",
+	       ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
+	       ddpskt_string(ndo, dp->dstSkt)));
 	bp += ddpSize;
 	length -= ddpSize;
-	ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
+	ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
 }
 
 /* XXX should probably pass in the snap header and do checks like arp_print() */
 void
-aarp_print(register const u_char *bp, u_int length)
+aarp_print(netdissect_options *ndo,
+           register const u_char *bp, u_int length)
 {
 	register const struct aarp *ap;
 
-#define AT(member) ataddr_string((ap->member[1]<<8)|ap->member[2],ap->member[3])
+#define AT(member) ataddr_string(ndo, (ap->member[1]<<8)|ap->member[2],ap->member[3])
 
-	printf("aarp ");
+	ND_PRINT((ndo, "aarp "));
 	ap = (const struct aarp *)bp;
 	if (EXTRACT_16BITS(&ap->htype) == 1 &&
 	    EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK &&
@@ -203,151 +200,151 @@
 		switch (EXTRACT_16BITS(&ap->op)) {
 
 		case 1:				/* request */
-			(void)printf("who-has %s tell %s",
-			    AT(pdaddr), AT(psaddr));
+			ND_PRINT((ndo, "who-has %s tell %s", AT(pdaddr), AT(psaddr)));
 			return;
 
 		case 2:				/* response */
-			(void)printf("reply %s is-at %s",
-			    AT(psaddr), etheraddr_string(ap->hsaddr));
+			ND_PRINT((ndo, "reply %s is-at %s", AT(psaddr), etheraddr_string(ndo, ap->hsaddr)));
 			return;
 
 		case 3:				/* probe (oy!) */
-			(void)printf("probe %s tell %s",
-			    AT(pdaddr), AT(psaddr));
+			ND_PRINT((ndo, "probe %s tell %s", AT(pdaddr), AT(psaddr)));
 			return;
 		}
-	(void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
+	ND_PRINT((ndo, "len %u op %u htype %u ptype %#x halen %u palen %u",
 	    length, EXTRACT_16BITS(&ap->op), EXTRACT_16BITS(&ap->htype),
-	    EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen);
+	    EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen));
 }
 
 /*
  * Print AppleTalk Datagram Delivery Protocol packets.
  */
 static void
-ddp_print(register const u_char *bp, register u_int length, register int t,
-	  register u_short snet, register u_char snode, u_char skt)
+ddp_print(netdissect_options *ndo,
+          register const u_char *bp, register u_int length, register int t,
+          register u_short snet, register u_char snode, u_char skt)
 {
 
 	switch (t) {
 
 	case ddpNBP:
-		nbp_print((const struct atNBP *)bp, length, snet, snode, skt);
+		nbp_print(ndo, (const struct atNBP *)bp, length, snet, snode, skt);
 		break;
 
 	case ddpATP:
-		atp_print((const struct atATP *)bp, length);
+		atp_print(ndo, (const struct atATP *)bp, length);
 		break;
 
 	case ddpEIGRP:
-		eigrp_print(bp, length);
+		eigrp_print(ndo, bp, length);
 		break;
 
 	default:
-		(void)printf(" at-%s %d", tok2str(type2str, NULL, t), length);
+		ND_PRINT((ndo, " at-%s %d", tok2str(type2str, NULL, t), length));
 		break;
 	}
 }
 
 static void
-atp_print(register const struct atATP *ap, u_int length)
+atp_print(netdissect_options *ndo,
+          register const struct atATP *ap, u_int length)
 {
 	char c;
-	u_int32_t data;
+	uint32_t data;
 
-	if ((const u_char *)(ap + 1) > snapend) {
+	if ((const u_char *)(ap + 1) > ndo->ndo_snapend) {
 		/* Just bail if we don't have the whole chunk. */
-		fputs(tstr, stdout);
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 	if (length < sizeof(*ap)) {
-		(void)printf(" [|atp %u]", length);
+		ND_PRINT((ndo, " [|atp %u]", length));
 		return;
 	}
 	length -= sizeof(*ap);
 	switch (ap->control & 0xc0) {
 
 	case atpReqCode:
-		(void)printf(" atp-req%s %d",
+		ND_PRINT((ndo, " atp-req%s %d",
 			     ap->control & atpXO? " " : "*",
-			     EXTRACT_16BITS(&ap->transID));
+			     EXTRACT_16BITS(&ap->transID)));
 
-		atp_bitmap_print(ap->bitmap);
+		atp_bitmap_print(ndo, ap->bitmap);
 
 		if (length != 0)
-			(void)printf(" [len=%u]", length);
+			ND_PRINT((ndo, " [len=%u]", length));
 
 		switch (ap->control & (atpEOM|atpSTS)) {
 		case atpEOM:
-			(void)printf(" [EOM]");
+			ND_PRINT((ndo, " [EOM]"));
 			break;
 		case atpSTS:
-			(void)printf(" [STS]");
+			ND_PRINT((ndo, " [STS]"));
 			break;
 		case atpEOM|atpSTS:
-			(void)printf(" [EOM,STS]");
+			ND_PRINT((ndo, " [EOM,STS]"));
 			break;
 		}
 		break;
 
 	case atpRspCode:
-		(void)printf(" atp-resp%s%d:%d (%u)",
+		ND_PRINT((ndo, " atp-resp%s%d:%d (%u)",
 			     ap->control & atpEOM? "*" : " ",
-			     EXTRACT_16BITS(&ap->transID), ap->bitmap, length);
+			     EXTRACT_16BITS(&ap->transID), ap->bitmap, length));
 		switch (ap->control & (atpXO|atpSTS)) {
 		case atpXO:
-			(void)printf(" [XO]");
+			ND_PRINT((ndo, " [XO]"));
 			break;
 		case atpSTS:
-			(void)printf(" [STS]");
+			ND_PRINT((ndo, " [STS]"));
 			break;
 		case atpXO|atpSTS:
-			(void)printf(" [XO,STS]");
+			ND_PRINT((ndo, " [XO,STS]"));
 			break;
 		}
 		break;
 
 	case atpRelCode:
-		(void)printf(" atp-rel  %d", EXTRACT_16BITS(&ap->transID));
+		ND_PRINT((ndo, " atp-rel  %d", EXTRACT_16BITS(&ap->transID)));
 
-		atp_bitmap_print(ap->bitmap);
+		atp_bitmap_print(ndo, ap->bitmap);
 
 		/* length should be zero */
 		if (length)
-			(void)printf(" [len=%u]", length);
+			ND_PRINT((ndo, " [len=%u]", length));
 
 		/* there shouldn't be any control flags */
 		if (ap->control & (atpXO|atpEOM|atpSTS)) {
 			c = '[';
 			if (ap->control & atpXO) {
-				(void)printf("%cXO", c);
+				ND_PRINT((ndo, "%cXO", c));
 				c = ',';
 			}
 			if (ap->control & atpEOM) {
-				(void)printf("%cEOM", c);
+				ND_PRINT((ndo, "%cEOM", c));
 				c = ',';
 			}
 			if (ap->control & atpSTS) {
-				(void)printf("%cSTS", c);
+				ND_PRINT((ndo, "%cSTS", c));
 				c = ',';
 			}
-			(void)printf("]");
+			ND_PRINT((ndo, "]"));
 		}
 		break;
 
 	default:
-		(void)printf(" atp-0x%x  %d (%u)", ap->control,
-			     EXTRACT_16BITS(&ap->transID), length);
+		ND_PRINT((ndo, " atp-0x%x  %d (%u)", ap->control,
+			     EXTRACT_16BITS(&ap->transID), length));
 		break;
 	}
 	data = EXTRACT_32BITS(&ap->userData);
 	if (data != 0)
-		(void)printf(" 0x%x", data);
+		ND_PRINT((ndo, " 0x%x", data));
 }
 
 static void
-atp_bitmap_print(register u_char bm)
+atp_bitmap_print(netdissect_options *ndo,
+                 register u_char bm)
 {
 	register char c;
 	register int i;
@@ -361,25 +358,26 @@
 		c = '<';
 		for (i = 0; bm; ++i) {
 			if (bm & 1) {
-				(void)printf("%c%d", c, i);
+				ND_PRINT((ndo, "%c%d", c, i));
 				c = ',';
 			}
 			bm >>= 1;
 		}
-		(void)printf(">");
+		ND_PRINT((ndo, ">"));
 	} else {
 		for (i = 0; bm; ++i)
 			bm >>= 1;
 		if (i > 1)
-			(void)printf("<0-%d>", i - 1);
+			ND_PRINT((ndo, "<0-%d>", i - 1));
 		else
-			(void)printf("<0>");
+			ND_PRINT((ndo, "<0>"));
 	}
 }
 
 static void
-nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
-	  register u_char snode, register u_char skt)
+nbp_print(netdissect_options *ndo,
+          register const struct atNBP *np, u_int length, register u_short snet,
+          register u_char snode, register u_char skt)
 {
 	register const struct atNBPtuple *tp =
 		(const struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
@@ -387,138 +385,137 @@
 	const u_char *ep;
 
 	if (length < nbpHeaderSize) {
-		(void)printf(" truncated-nbp %u", length);
+		ND_PRINT((ndo, " truncated-nbp %u", length));
 		return;
 	}
 
 	length -= nbpHeaderSize;
 	if (length < 8) {
 		/* must be room for at least one tuple */
-		(void)printf(" truncated-nbp %u", length + nbpHeaderSize);
+		ND_PRINT((ndo, " truncated-nbp %u", length + nbpHeaderSize));
 		return;
 	}
 	/* ep points to end of available data */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 	if ((const u_char *)tp > ep) {
-		fputs(tstr, stdout);
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 	switch (i = np->control & 0xf0) {
 
 	case nbpBrRq:
 	case nbpLkUp:
-		(void)printf(i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:",
-			     np->id);
+		ND_PRINT((ndo, i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:", np->id));
 		if ((const u_char *)(tp + 1) > ep) {
-			fputs(tstr, stdout);
+			ND_PRINT((ndo, "%s", tstr));
 			return;
 		}
-		(void)nbp_name_print(tp, ep);
+		(void)nbp_name_print(ndo, tp, ep);
 		/*
 		 * look for anomalies: the spec says there can only
 		 * be one tuple, the address must match the source
 		 * address and the enumerator should be zero.
 		 */
 		if ((np->control & 0xf) != 1)
-			(void)printf(" [ntup=%d]", np->control & 0xf);
+			ND_PRINT((ndo, " [ntup=%d]", np->control & 0xf));
 		if (tp->enumerator)
-			(void)printf(" [enum=%d]", tp->enumerator);
+			ND_PRINT((ndo, " [enum=%d]", tp->enumerator));
 		if (EXTRACT_16BITS(&tp->net) != snet ||
 		    tp->node != snode || tp->skt != skt)
-			(void)printf(" [addr=%s.%d]",
-			    ataddr_string(EXTRACT_16BITS(&tp->net),
-			    tp->node), tp->skt);
+			ND_PRINT((ndo, " [addr=%s.%d]",
+			    ataddr_string(ndo, EXTRACT_16BITS(&tp->net),
+			    tp->node), tp->skt));
 		break;
 
 	case nbpLkUpReply:
-		(void)printf(" nbp-reply %d:", np->id);
+		ND_PRINT((ndo, " nbp-reply %d:", np->id));
 
 		/* print each of the tuples in the reply */
 		for (i = np->control & 0xf; --i >= 0 && tp; )
-			tp = nbp_tuple_print(tp, ep, snet, snode, skt);
+			tp = nbp_tuple_print(ndo, tp, ep, snet, snode, skt);
 		break;
 
 	default:
-		(void)printf(" nbp-0x%x  %d (%u)", np->control, np->id,
-				length);
+		ND_PRINT((ndo, " nbp-0x%x  %d (%u)", np->control, np->id, length));
 		break;
 	}
 }
 
 /* print a counted string */
 static const char *
-print_cstring(register const char *cp, register const u_char *ep)
+print_cstring(netdissect_options *ndo,
+              register const char *cp, register const u_char *ep)
 {
 	register u_int length;
 
 	if (cp >= (const char *)ep) {
-		fputs(tstr, stdout);
+		ND_PRINT((ndo, "%s", tstr));
 		return (0);
 	}
 	length = *cp++;
 
 	/* Spec says string can be at most 32 bytes long */
 	if (length > 32) {
-		(void)printf("[len=%u]", length);
+		ND_PRINT((ndo, "[len=%u]", length));
 		return (0);
 	}
 	while ((int)--length >= 0) {
 		if (cp >= (const char *)ep) {
-			fputs(tstr, stdout);
+			ND_PRINT((ndo, "%s", tstr));
 			return (0);
 		}
-		putchar(*cp++);
+		ND_PRINT((ndo, "%c", *cp++));
 	}
 	return (cp);
 }
 
 static const struct atNBPtuple *
-nbp_tuple_print(register const struct atNBPtuple *tp,
-		register const u_char *ep,
-		register u_short snet, register u_char snode,
-		register u_char skt)
+nbp_tuple_print(netdissect_options *ndo,
+                register const struct atNBPtuple *tp, register const u_char *ep,
+                register u_short snet, register u_char snode, register u_char skt)
 {
 	register const struct atNBPtuple *tpn;
 
 	if ((const u_char *)(tp + 1) > ep) {
-		fputs(tstr, stdout);
+		ND_PRINT((ndo, "%s", tstr));
 		return 0;
 	}
-	tpn = nbp_name_print(tp, ep);
+	tpn = nbp_name_print(ndo, tp, ep);
 
 	/* if the enumerator isn't 1, print it */
 	if (tp->enumerator != 1)
-		(void)printf("(%d)", tp->enumerator);
+		ND_PRINT((ndo, "(%d)", tp->enumerator));
 
 	/* if the socket doesn't match the src socket, print it */
 	if (tp->skt != skt)
-		(void)printf(" %d", tp->skt);
+		ND_PRINT((ndo, " %d", tp->skt));
 
 	/* if the address doesn't match the src address, it's an anomaly */
 	if (EXTRACT_16BITS(&tp->net) != snet || tp->node != snode)
-		(void)printf(" [addr=%s]",
-		    ataddr_string(EXTRACT_16BITS(&tp->net), tp->node));
+		ND_PRINT((ndo, " [addr=%s]",
+		    ataddr_string(ndo, EXTRACT_16BITS(&tp->net), tp->node)));
 
 	return (tpn);
 }
 
 static const struct atNBPtuple *
-nbp_name_print(const struct atNBPtuple *tp, register const u_char *ep)
+nbp_name_print(netdissect_options *ndo,
+               const struct atNBPtuple *tp, register const u_char *ep)
 {
 	register const char *cp = (const char *)tp + nbpTupleSize;
 
-	putchar(' ');
+	ND_PRINT((ndo, " "));
 
 	/* Object */
-	putchar('"');
-	if ((cp = print_cstring(cp, ep)) != NULL) {
+	ND_PRINT((ndo, "\""));
+	if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
 		/* Type */
-		putchar(':');
-		if ((cp = print_cstring(cp, ep)) != NULL) {
+		ND_PRINT((ndo, ":"));
+		if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
 			/* Zone */
-			putchar('@');
-			if ((cp = print_cstring(cp, ep)) != NULL)
-				putchar('"');
+			ND_PRINT((ndo, "@"));
+			if ((cp = print_cstring(ndo, cp, ep)) != NULL)
+				ND_PRINT((ndo, "\""));
 		}
 	}
 	return ((const struct atNBPtuple *)cp);
@@ -536,7 +533,8 @@
 static struct hnamemem hnametable[HASHNAMESIZE];
 
 static const char *
-ataddr_string(u_short atnet, u_char athost)
+ataddr_string(netdissect_options *ndo,
+              u_short atnet, u_char athost)
 {
 	register struct hnamemem *tp, *tp2;
 	register int i = (atnet << 8) | athost;
@@ -548,7 +546,7 @@
 	 * if this is the first call, see if there's an AppleTalk
 	 * number to name map file.
 	 */
-	if (first && (first = 0, !nflag)
+	if (first && (first = 0, !ndo->ndo_nflag)
 	    && (fp = fopen("/etc/atalk.names", "r"))) {
 		char line[256];
 		int i1, i2;
@@ -611,11 +609,12 @@
 };
 
 static const char *
-ddpskt_string(register int skt)
+ddpskt_string(netdissect_options *ndo,
+              register int skt)
 {
 	static char buf[8];
 
-	if (nflag) {
+	if (ndo->ndo_nflag) {
 		(void)snprintf(buf, sizeof(buf), "%d", skt);
 		return (buf);
 	}
diff --git a/print-atm.c b/print-atm.c
index b132a6d..8faf715 100644
--- a/print-atm.c
+++ b/print-atm.c
@@ -18,30 +18,22 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.49 2007-10-22 19:37:51 guy Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ethertype.h"
 #include "atm.h"
 #include "atmuni31.h"
 #include "llc.h"
 
-#include "ether.h"
+static const char tstr[] = "[|atm]";
 
 #define OAM_CRC10_MASK 0x3ff
 #define OAM_PAYLOAD_LEN 48
@@ -135,19 +127,20 @@
  * Print an RFC 1483 LLC-encapsulated ATM frame.
  */
 static void
-atm_llc_print(const u_char *p, int length, int caplen)
+atm_llc_print(netdissect_options *ndo,
+              const u_char *p, int length, int caplen)
 {
 	u_short extracted_ethertype;
 
-	if (!llc_print(p, length, caplen, NULL, NULL,
+	if (!llc_print(ndo, p, length, caplen, NULL, NULL,
 	    &extracted_ethertype)) {
 		/* ether_type not known, print raw packet */
 		if (extracted_ethertype) {
-			printf("(LLC %s) ",
-		etherproto_string(htons(extracted_ethertype)));
+			ND_PRINT((ndo, "(LLC %s) ",
+		etherproto_string(htons(extracted_ethertype))));
 		}
-		if (!suppress_default_print)
-			default_print(p, caplen);
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
 	}
 }
 
@@ -164,27 +157,37 @@
  * is the number of bytes actually captured.
  */
 u_int
-atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
+atm_if_print(netdissect_options *ndo,
+             const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	u_int length = h->len;
-	u_int32_t llchdr;
+	uint32_t llchdr;
 	u_int hdrlen = 0;
 
-	if (caplen < 8) {
-		printf("[|atm]");
+	if (caplen < 1 || length < 1) {
+		ND_PRINT((ndo, "%s", tstr));
 		return (caplen);
 	}
 
         /* Cisco Style NLPID ? */
         if (*p == LLC_UI) {
-            if (eflag)
-                printf("CNLPID ");
-            isoclns_print(p+1, length-1, caplen-1);
+            if (ndo->ndo_eflag)
+                ND_PRINT((ndo, "CNLPID "));
+            isoclns_print(ndo, p + 1, length - 1, caplen - 1);
             return hdrlen;
         }
 
 	/*
+	 * Must have at least a DSAP, an SSAP, and the first byte of the
+	 * control field.
+	 */
+	if (caplen < 3 || length < 3) {
+		ND_PRINT((ndo, "%s", tstr));
+		return (caplen);
+	}
+
+	/*
 	 * Extract the presumed LLC header into a variable, for quick
 	 * testing.
 	 * Then check for a header that's neither a header for a SNAP
@@ -211,18 +214,22 @@
 		 * packets?  If so, could it be changed to use a
 		 * new DLT_IEEE802_6 value if we added it?
 		 */
-		if (eflag)
-			printf("%08x%08x %08x%08x ",
+		if (caplen < 20 || length < 20) {
+			ND_PRINT((ndo, "%s", tstr));
+			return (caplen);
+		}
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "%08x%08x %08x%08x ",
 			       EXTRACT_32BITS(p),
 			       EXTRACT_32BITS(p+4),
 			       EXTRACT_32BITS(p+8),
-			       EXTRACT_32BITS(p+12));
+			       EXTRACT_32BITS(p+12)));
 		p += 20;
 		length -= 20;
 		caplen -= 20;
 		hdrlen += 20;
 	}
-	atm_llc_print(p, length, caplen);
+	atm_llc_print(ndo, p, length, caplen);
 	return (hdrlen);
 }
 
@@ -249,26 +256,27 @@
 };
 
 static void
-sig_print(const u_char *p, int caplen)
+sig_print(netdissect_options *ndo,
+          const u_char *p, int caplen)
 {
-	bpf_u_int32 call_ref;
+	uint32_t call_ref;
 
 	if (caplen < PROTO_POS) {
-		printf("[|atm]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 	if (p[PROTO_POS] == Q2931) {
 		/*
-		 * protocol:Q.2931 for User to Network Interface 
+		 * protocol:Q.2931 for User to Network Interface
 		 * (UNI 3.1) signalling
 		 */
-		printf("Q.2931");
+		ND_PRINT((ndo, "Q.2931"));
 		if (caplen < MSG_TYPE_POS) {
-			printf(" [|atm]");
+			ND_PRINT((ndo, " %s", tstr));
 			return;
 		}
-		printf(":%s ",
-		    tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
+		ND_PRINT((ndo, ":%s ",
+		    tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
 
 		/*
 		 * The call reference comes before the message type,
@@ -277,10 +285,10 @@
 		 * the call reference.
 		 */
 		call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
-		printf("CALL_REF:0x%06x", call_ref);
+		ND_PRINT((ndo, "CALL_REF:0x%06x", call_ref));
 	} else {
 		/* SCCOP with some unknown protocol atop it */
-		printf("SSCOP, proto %d ", p[PROTO_POS]);
+		ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
 	}
 }
 
@@ -288,35 +296,36 @@
  * Print an ATM PDU (such as an AAL5 PDU).
  */
 void
-atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
-    u_int caplen)
+atm_print(netdissect_options *ndo,
+          u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
+          u_int caplen)
 {
-	if (eflag)
-		printf("VPI:%u VCI:%u ", vpi, vci);
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "VPI:%u VCI:%u ", vpi, vci));
 
 	if (vpi == 0) {
 		switch (vci) {
 
 		case VCI_PPC:
-			sig_print(p, caplen);
+			sig_print(ndo, p, caplen);
 			return;
 
 		case VCI_BCC:
-			printf("broadcast sig: ");
+			ND_PRINT((ndo, "broadcast sig: "));
 			return;
 
 		case VCI_OAMF4SC: /* fall through */
 		case VCI_OAMF4EC:
-                        oam_print(p, length, ATM_OAM_HEC);
+			oam_print(ndo, p, length, ATM_OAM_HEC);
 			return;
 
 		case VCI_METAC:
-			printf("meta: ");
+			ND_PRINT((ndo, "meta: "));
 			return;
 
 		case VCI_ILMIC:
-			printf("ilmi: ");
-			snmp_print(p, length);
+			ND_PRINT((ndo, "ilmi: "));
+			snmp_print(ndo, p, length);
 			return;
 		}
 	}
@@ -328,35 +337,36 @@
 		/*
 		 * Assumes traffic is LLC if unknown.
 		 */
-		atm_llc_print(p, length, caplen);
+		atm_llc_print(ndo, p, length, caplen);
 		break;
 
 	case ATM_LANE:
-		lane_print(p, length, caplen);
+		lane_print(ndo, p, length, caplen);
 		break;
 	}
 }
 
 struct oam_fm_loopback_t {
-    u_int8_t loopback_indicator;
-    u_int8_t correlation_tag[4];
-    u_int8_t loopback_id[12];
-    u_int8_t source_id[12];
-    u_int8_t unused[16];
+    uint8_t loopback_indicator;
+    uint8_t correlation_tag[4];
+    uint8_t loopback_id[12];
+    uint8_t source_id[12];
+    uint8_t unused[16];
 };
 
 struct oam_fm_ais_rdi_t {
-    u_int8_t failure_type;
-    u_int8_t failure_location[16];
-    u_int8_t unused[28];
+    uint8_t failure_type;
+    uint8_t failure_location[16];
+    uint8_t unused[28];
 };
 
-int 
-oam_print (const u_char *p, u_int length, u_int hec) {
-
-    u_int32_t cell_header;
-    u_int16_t vpi, vci, cksum, cksum_shouldbe, idx;
-    u_int8_t  cell_type, func_type, payload, clp;
+int
+oam_print (netdissect_options *ndo,
+           const u_char *p, u_int length, u_int hec)
+{
+    uint32_t cell_header;
+    uint16_t vpi, vci, cksum, cksum_shouldbe, idx;
+    uint8_t  cell_type, func_type, payload, clp;
 
     union {
         const struct oam_fm_loopback_t *oam_fm_loopback;
@@ -373,47 +383,47 @@
     payload = (cell_header>>1)&0x7;
     clp = cell_header&0x1;
 
-    printf("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
+    ND_PRINT((ndo, "%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
            tok2str(oam_f_values, "OAM F5", vci),
            vpi, vci,
            tok2str(atm_pty_values, "Unknown", payload),
-           clp, length);
+           clp, length));
 
-    if (!vflag) {
+    if (!ndo->ndo_vflag) {
         return 1;
     }
 
-    printf("\n\tcell-type %s (%u)",
+    ND_PRINT((ndo, "\n\tcell-type %s (%u)",
            tok2str(oam_celltype_values, "unknown", cell_type),
-           cell_type);
+           cell_type));
 
     if (oam_functype_values[cell_type] == NULL)
-        printf(", func-type unknown (%u)", func_type);
+        ND_PRINT((ndo, ", func-type unknown (%u)", func_type));
     else
-        printf(", func-type %s (%u)",
+        ND_PRINT((ndo, ", func-type %s (%u)",
                tok2str(oam_functype_values[cell_type],"none",func_type),
-               func_type);
+               func_type));
 
     p += ATM_HDR_LEN_NOHEC + hec;
 
     switch (cell_type << 4 | func_type) {
     case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK):
         oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
-        printf("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
+        ND_PRINT((ndo, "\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
                tok2str(oam_fm_loopback_indicator_values,
                        "Unknown",
                        oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK),
-               EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag));
-        printf("\n\tLocation-ID ");
+               EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag)));
+        ND_PRINT((ndo, "\n\tLocation-ID "));
         for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) {
             if (idx % 2) {
-                printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx]));
+                ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx])));
             }
         }
-        printf("\n\tSource-ID   ");
+        ND_PRINT((ndo, "\n\tSource-ID   "));
         for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) {
             if (idx % 2) {
-                printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx]));
+                ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx])));
             }
         }
         break;
@@ -421,11 +431,11 @@
     case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS):
     case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI):
         oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
-        printf("\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type);
-        printf("\n\tLocation-ID ");
+        ND_PRINT((ndo, "\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type));
+        ND_PRINT((ndo, "\n\tLocation-ID "));
         for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) {
             if (idx % 2) {
-                printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx]));
+                ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])));
             }
         }
         break;
@@ -442,10 +452,10 @@
     cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN)
         & OAM_CRC10_MASK;
     cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);
-    
-    printf("\n\tcksum 0x%03x (%scorrect)",
+
+    ND_PRINT((ndo, "\n\tcksum 0x%03x (%scorrect)",
            cksum,
-           cksum_shouldbe == 0 ? "" : "in");
+           cksum_shouldbe == 0 ? "" : "in"));
 
     return 1;
 }
diff --git a/print-babel.c b/print-babel.c
index 4c77a0c..75cb32c 100644
--- a/print-babel.c
+++ b/print-babel.c
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -35,38 +36,42 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "addrtoname.h"
 #include "interface.h"
+#include "addrtoname.h"
 #include "extract.h"
 
-static void babel_print_v2(const u_char *cp, u_int length);
+static const char tstr[] = "[|babel]";
+
+static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length);
 
 void
-babel_print(const u_char *cp, u_int length) {
-    printf("babel");
+babel_print(netdissect_options *ndo,
+            const u_char *cp, u_int length)
+{
+    ND_PRINT((ndo, "babel"));
 
-    TCHECK2(*cp, 4);
+    ND_TCHECK2(*cp, 4);
 
     if(cp[0] != 42) {
-        printf(" malformed header");
+        ND_PRINT((ndo, " malformed header"));
         return;
     } else {
-        printf(" %d", cp[1]);
+        ND_PRINT((ndo, " %d", cp[1]));
     }
 
     switch(cp[1]) {
     case 2:
-        babel_print_v2(cp,length);
+        babel_print_v2(ndo, cp, length);
         break;
     default:
-        printf(" unknown version");
+        ND_PRINT((ndo, " unknown version"));
         break;
     }
 
     return;
 
  trunc:
-    printf(" [|babel]");
+    ND_PRINT((ndo, " %s", tstr));
     return;
 }
 
@@ -89,6 +94,7 @@
 #define MESSAGE_SUB_PAD1 0
 #define MESSAGE_SUB_PADN 1
 #define MESSAGE_SUB_DIVERSITY 2
+#define MESSAGE_SUB_TIMESTAMP 3
 
 /* Diversity sub-TLV channel codes */
 static const struct tok diversity_str[] = {
@@ -111,14 +117,14 @@
     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
 
 static const char *
-format_prefix(const u_char *prefix, unsigned char plen)
+format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
 {
     static char buf[50];
     if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
-        snprintf(buf, 50, "%s/%u", ipaddr_string(prefix + 12), plen - 96);
+        snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
     else
 #ifdef INET6
-        snprintf(buf, 50, "%s/%u", ip6addr_string(prefix), plen);
+        snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
 #else
         snprintf(buf, 50, "IPv6 addresses not supported");
 #endif
@@ -127,35 +133,43 @@
 }
 
 static const char *
-format_address(const u_char *prefix)
+format_address(netdissect_options *ndo, const u_char *prefix)
 {
     if(memcmp(prefix, v4prefix, 12) == 0)
-        return ipaddr_string(prefix + 12);
+        return ipaddr_string(ndo, prefix + 12);
     else
 #ifdef INET6
-        return ip6addr_string(prefix);
+        return ip6addr_string(ndo, prefix);
 #else
         return "IPv6 addresses not supported";
 #endif
 }
 
 static const char *
-format_interval(const u_int16_t i)
+format_interval(const uint16_t i)
 {
-    static char buf[sizeof("0000.0s")];
+    static char buf[sizeof("000.00s")];
 
     if (i == 0)
         return "0.0s (bogus)";
-    snprintf(buf, sizeof(buf), "%u.%us", i / 10, i % 10);
+    snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
     return buf;
 }
 
 static const char *
-format_interval_update(const u_int16_t i)
+format_interval_update(const uint16_t i)
 {
     return i == 0xFFFF ? "infinity" : format_interval(i);
 }
 
+static const char *
+format_timestamp(const uint32_t i)
+{
+    static char buf[sizeof("0000.000000s")];
+    snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
+    return buf;
+}
+
 /* Return number of octets consumed from the input buffer (not the prefix length
  * in bytes), or -1 for encoding error. */
 static int
@@ -242,21 +256,31 @@
  *   each representing per-hop number of interferring radio channel for the
  *   prefix. Channel 0 is invalid and must not be used in the sub-TLV, channel
  *   255 interferes with any other channel.
+ * o Type 3 stands for Timestamp sub-TLV, used to compute RTT between
+ *   neighbours. In the case of a Hello TLV, the body stores a 32-bits
+ *   timestamp, while in the case of a IHU TLV, two 32-bits timestamps are
+ *   stored.
  *
  * Sub-TLV types 0 and 1 are valid for any TLV type, whether sub-TLV type 2 is
  * only valid for TLV type 8 (Update). Note that within an Update TLV a missing
  * Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body.
  * The former would mean a lack of any claims about the interference, and the
- * latter would state that interference is definitely absent. */
+ * latter would state that interference is definitely absent.
+ * A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact
+ * semantic of the sub-TLV is different in each case.
+ */
 static void
-subtlvs_print(const u_char *cp, const u_char *ep, const uint8_t tlv_type) {
+subtlvs_print(netdissect_options *ndo,
+              const u_char *cp, const u_char *ep, const uint8_t tlv_type)
+{
     uint8_t subtype, sublen;
     const char *sep;
+    uint32_t t1, t2;
 
     while (cp < ep) {
         subtype = *cp++;
         if(subtype == MESSAGE_SUB_PAD1) {
-            printf(" sub-pad1");
+            ND_PRINT((ndo, " sub-pad1"));
             continue;
         }
         if(cp == ep)
@@ -267,50 +291,70 @@
 
         switch(subtype) {
         case MESSAGE_SUB_PADN:
-            printf(" sub-padn");
+            ND_PRINT((ndo, " sub-padn"));
             cp += sublen;
             break;
         case MESSAGE_SUB_DIVERSITY:
-            printf(" sub-diversity");
+            ND_PRINT((ndo, " sub-diversity"));
             if (sublen == 0) {
-                printf(" empty");
+                ND_PRINT((ndo, " empty"));
                 break;
             }
             sep = " ";
             while(sublen--) {
-                printf("%s%s", sep, tok2str(diversity_str, "%u", *cp++));
+                ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
                 sep = "-";
             }
             if(tlv_type != MESSAGE_UPDATE)
-                printf(" (bogus)");
+                ND_PRINT((ndo, " (bogus)"));
+            break;
+        case MESSAGE_SUB_TIMESTAMP:
+            ND_PRINT((ndo, " sub-timestamp"));
+            if(tlv_type == MESSAGE_HELLO) {
+                if(sublen < 4)
+                    goto corrupt;
+                t1 = EXTRACT_32BITS(cp);
+                ND_PRINT((ndo, " %s", format_timestamp(t1)));
+            } else if(tlv_type == MESSAGE_IHU) {
+                if(sublen < 8)
+                    goto corrupt;
+                t1 = EXTRACT_32BITS(cp);
+                ND_PRINT((ndo, " %s", format_timestamp(t1)));
+                t2 = EXTRACT_32BITS(cp + 4);
+                ND_PRINT((ndo, "|%s", format_timestamp(t2)));
+            } else
+                ND_PRINT((ndo, " (bogus)"));
+            cp += sublen;
             break;
         default:
-            printf(" sub-unknown-0x%02x", subtype);
+            ND_PRINT((ndo, " sub-unknown-0x%02x", subtype));
             cp += sublen;
         } /* switch */
     } /* while */
     return;
 
  corrupt:
-    printf(" (corrupt)");
+    ND_PRINT((ndo, " (corrupt)"));
 }
 
 #define ICHECK(i, l) \
 	if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt;
 
 static void
-babel_print_v2(const u_char *cp, u_int length) {
+babel_print_v2(netdissect_options *ndo,
+               const u_char *cp, u_int length)
+{
     u_int i;
     u_short bodylen;
     u_char v4_prefix[16] =
         {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
     u_char v6_prefix[16] = {0};
 
-    TCHECK2(*cp, 4);
+    ND_TCHECK2(*cp, 4);
     if (length < 4)
         goto corrupt;
     bodylen = EXTRACT_16BITS(cp + 2);
-    printf(" (%u)", bodylen);
+    ND_PRINT((ndo, " (%u)", bodylen));
 
     /* Process the TLVs in the body */
     i = 0;
@@ -320,131 +364,138 @@
 
         message = cp + 4 + i;
 
-        TCHECK2(*message, 1);
+        ND_TCHECK2(*message, 1);
         if((type = message[0]) == MESSAGE_PAD1) {
-            printf(vflag ? "\n\tPad 1" : " pad1");
+            ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
             i += 1;
             continue;
         }
 
-        TCHECK2(*message, 2);
+        ND_TCHECK2(*message, 2);
         ICHECK(i, 2);
         len = message[1];
 
-        TCHECK2(*message, 2 + len);
+        ND_TCHECK2(*message, 2 + len);
         ICHECK(i, 2 + len);
 
         switch(type) {
         case MESSAGE_PADN: {
-            if(!vflag)
-                printf(" padN");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " padN"));
             else
-                printf("\n\tPad %d", len + 2);
+                ND_PRINT((ndo, "\n\tPad %d", len + 2));
         }
             break;
 
         case MESSAGE_ACK_REQ: {
             u_short nonce, interval;
-            if(!vflag)
-                printf(" ack-req");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " ack-req"));
             else {
-                printf("\n\tAcknowledgment Request ");
+                ND_PRINT((ndo, "\n\tAcknowledgment Request "));
                 if(len < 6) goto corrupt;
                 nonce = EXTRACT_16BITS(message + 4);
                 interval = EXTRACT_16BITS(message + 6);
-                printf("%04x %s", nonce, format_interval(interval));
+                ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));
             }
         }
             break;
 
         case MESSAGE_ACK: {
             u_short nonce;
-            if(!vflag)
-                printf(" ack");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " ack"));
             else {
-                printf("\n\tAcknowledgment ");
+                ND_PRINT((ndo, "\n\tAcknowledgment "));
                 if(len < 2) goto corrupt;
                 nonce = EXTRACT_16BITS(message + 2);
-                printf("%04x", nonce);
+                ND_PRINT((ndo, "%04x", nonce));
             }
         }
             break;
 
         case MESSAGE_HELLO:  {
             u_short seqno, interval;
-            if(!vflag)
-                printf(" hello");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " hello"));
             else {
-                printf("\n\tHello ");
+                ND_PRINT((ndo, "\n\tHello "));
                 if(len < 6) goto corrupt;
                 seqno = EXTRACT_16BITS(message + 4);
                 interval = EXTRACT_16BITS(message + 6);
-                printf("seqno %u interval %s", seqno, format_interval(interval));
+                ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));
+                /* Extra data. */
+                if(len > 6)
+                    subtlvs_print(ndo, message + 8, message + 2 + len, type);
             }
         }
             break;
 
         case MESSAGE_IHU: {
             unsigned short txcost, interval;
-            if(!vflag)
-                printf(" ihu");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " ihu"));
             else {
                 u_char address[16];
                 int rc;
-                printf("\n\tIHU ");
+                ND_PRINT((ndo, "\n\tIHU "));
                 if(len < 6) goto corrupt;
                 txcost = EXTRACT_16BITS(message + 4);
                 interval = EXTRACT_16BITS(message + 6);
                 rc = network_address(message[2], message + 8, len - 6, address);
-                if(rc < 0) { printf("[|babel]"); break; }
-                printf("%s txcost %u interval %s",
-                       format_address(address), txcost, format_interval(interval));
+                if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; }
+                ND_PRINT((ndo, "%s txcost %u interval %s",
+                       format_address(ndo, address), txcost, format_interval(interval)));
+                /* Extra data. */
+                if((u_int)rc < len - 6)
+                    subtlvs_print(ndo, message + 8 + rc, message + 2 + len,
+                                  type);
             }
         }
             break;
 
         case MESSAGE_ROUTER_ID: {
-            if(!vflag)
-                printf(" router-id");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " router-id"));
             else {
-                printf("\n\tRouter Id");
+                ND_PRINT((ndo, "\n\tRouter Id"));
                 if(len < 10) goto corrupt;
-                printf(" %s", format_id(message + 4));
+                ND_PRINT((ndo, " %s", format_id(message + 4)));
             }
         }
             break;
 
         case MESSAGE_NH: {
-            if(!vflag)
-                printf(" nh");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " nh"));
             else {
                 int rc;
                 u_char nh[16];
-                printf("\n\tNext Hop");
+                ND_PRINT((ndo, "\n\tNext Hop"));
                 if(len < 2) goto corrupt;
                 rc = network_address(message[2], message + 4, len - 2, nh);
                 if(rc < 0) goto corrupt;
-                printf(" %s", format_address(nh));
+                ND_PRINT((ndo, " %s", format_address(ndo, nh)));
             }
         }
             break;
 
         case MESSAGE_UPDATE: {
-            if(!vflag) {
-                printf(" update");
+            if (!ndo->ndo_vflag) {
+                ND_PRINT((ndo, " update"));
                 if(len < 1)
-                    printf("/truncated");
+                    ND_PRINT((ndo, "/truncated"));
                 else
-                    printf("%s%s%s",
+                    ND_PRINT((ndo, "%s%s%s",
                            (message[3] & 0x80) ? "/prefix": "",
                            (message[3] & 0x40) ? "/id" : "",
-                           (message[3] & 0x3f) ? "/unknown" : "");
+                           (message[3] & 0x3f) ? "/unknown" : ""));
             } else {
                 u_short interval, seqno, metric;
                 u_char plen;
                 int rc;
                 u_char prefix[16];
-                printf("\n\tUpdate");
+                ND_PRINT((ndo, "\n\tUpdate"));
                 if(len < 10) goto corrupt;
                 plen = message[4] + (message[2] == 1 ? 96 : 0);
                 rc = network_prefix(message[2], message[4], message[5],
@@ -455,12 +506,12 @@
                 interval = EXTRACT_16BITS(message + 6);
                 seqno = EXTRACT_16BITS(message + 8);
                 metric = EXTRACT_16BITS(message + 10);
-                printf("%s%s%s %s metric %u seqno %u interval %s",
+                ND_PRINT((ndo, "%s%s%s %s metric %u seqno %u interval %s",
                        (message[3] & 0x80) ? "/prefix": "",
                        (message[3] & 0x40) ? "/id" : "",
                        (message[3] & 0x3f) ? "/unknown" : "",
-                       format_prefix(prefix, plen),
-                       metric, seqno, format_interval_update(interval));
+                       format_prefix(ndo, prefix, plen),
+                       metric, seqno, format_interval_update(interval)));
                 if(message[3] & 0x80) {
                     if(message[2] == 1)
                         memcpy(v4_prefix, prefix, 16);
@@ -469,88 +520,87 @@
                 }
                 /* extra data? */
                 if((u_int)rc < len - 10)
-                    subtlvs_print(message + 12 + rc, message + 2 + len, type);
+                    subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type);
             }
         }
             break;
 
         case MESSAGE_REQUEST: {
-            if(!vflag)
-                printf(" request");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " request"));
             else {
                 int rc;
                 u_char prefix[16], plen;
-                printf("\n\tRequest ");
+                ND_PRINT((ndo, "\n\tRequest "));
                 if(len < 2) goto corrupt;
                 plen = message[3] + (message[2] == 1 ? 96 : 0);
                 rc = network_prefix(message[2], message[3], 0,
                                     message + 4, NULL, len - 2, prefix);
                 if(rc < 0) goto corrupt;
-                plen = message[3] + (message[2] == 1 ? 96 : 0);
-                printf("for %s",
-                       message[2] == 0 ? "any" : format_prefix(prefix, plen));
+                ND_PRINT((ndo, "for %s",
+                       message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen)));
             }
         }
             break;
 
         case MESSAGE_MH_REQUEST : {
-            if(!vflag)
-                printf(" mh-request");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " mh-request"));
             else {
                 int rc;
                 u_short seqno;
                 u_char prefix[16], plen;
-                printf("\n\tMH-Request ");
+                ND_PRINT((ndo, "\n\tMH-Request "));
                 if(len < 14) goto corrupt;
                 seqno = EXTRACT_16BITS(message + 4);
                 rc = network_prefix(message[2], message[3], 0,
                                     message + 16, NULL, len - 14, prefix);
                 if(rc < 0) goto corrupt;
                 plen = message[3] + (message[2] == 1 ? 96 : 0);
-                printf("(%u hops) for %s seqno %u id %s",
-                       message[6], format_prefix(prefix, plen),
-                       seqno, format_id(message + 8));
+                ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s",
+                       message[6], format_prefix(ndo, prefix, plen),
+                       seqno, format_id(message + 8)));
             }
         }
             break;
         case MESSAGE_TSPC :
-            if(!vflag)
-                printf(" tspc");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " tspc"));
             else {
-                printf("\n\tTS/PC ");
+                ND_PRINT((ndo, "\n\tTS/PC "));
                 if(len < 6) goto corrupt;
-                printf("timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
-                       EXTRACT_16BITS(message + 2));
+                ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
+                       EXTRACT_16BITS(message + 2)));
             }
             break;
         case MESSAGE_HMAC : {
-            if(!vflag)
-                printf(" hmac");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " hmac"));
             else {
                 unsigned j;
-                printf("\n\tHMAC ");
+                ND_PRINT((ndo, "\n\tHMAC "));
                 if(len < 18) goto corrupt;
-                printf("key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2);
+                ND_PRINT((ndo, "key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2));
                 for (j = 0; j < len - 2; j++)
-                    printf ("%02X", message[4 + j]);
+                    ND_PRINT((ndo, "%02X", message[4 + j]));
             }
         }
             break;
         default:
-            if(!vflag)
-                printf(" unknown");
+            if (!ndo->ndo_vflag)
+                ND_PRINT((ndo, " unknown"));
             else
-                printf("\n\tUnknown message type %d", type);
+                ND_PRINT((ndo, "\n\tUnknown message type %d", type));
         }
         i += len + 2;
     }
     return;
 
  trunc:
-    printf(" [|babel]");
+    ND_PRINT((ndo, " %s", tstr));
     return;
 
  corrupt:
-    printf(" (corrupt)");
+    ND_PRINT((ndo, " (corrupt)"));
     return;
 }
diff --git a/print-beep.c b/print-beep.c
index b476dbf..7982feb 100644
--- a/print-beep.c
+++ b/print-beep.c
@@ -9,26 +9,16 @@
  *
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-  "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "interface.h"
-#include "extract.h"
 
 /* Check for a string but not go beyond length
  * Return TRUE on match, FALSE otherwise
@@ -36,8 +26,6 @@
  * Looks at the first few chars up to tl1 ...
  */
 
-static int l_strnstart(const char *, u_int, const char *, u_int);
-
 static int
 l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
 {
@@ -49,23 +37,23 @@
 }
 
 void
-beep_print(const u_char *bp, u_int length)
+beep_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
 
 	if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
-		printf(" BEEP MSG");
+		ND_PRINT((ndo, " BEEP MSG"));
 	else if (l_strnstart("RPY ", 4, (const char *)bp, length))
-		printf(" BEEP RPY");
+		ND_PRINT((ndo, " BEEP RPY"));
 	else if (l_strnstart("ERR ", 4, (const char *)bp, length))
-		printf(" BEEP ERR");
+		ND_PRINT((ndo, " BEEP ERR"));
 	else if (l_strnstart("ANS ", 4, (const char *)bp, length))
-		printf(" BEEP ANS");
+		ND_PRINT((ndo, " BEEP ANS"));
 	else if (l_strnstart("NUL ", 4, (const char *)bp, length))
-		printf(" BEEP NUL");
+		ND_PRINT((ndo, " BEEP NUL"));
 	else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
-		printf(" BEEP SEQ");
+		ND_PRINT((ndo, " BEEP SEQ"));
 	else if (l_strnstart("END", 4, (const char *)bp, length))
-		printf(" BEEP END");
+		ND_PRINT((ndo, " BEEP END"));
 	else
-		printf(" BEEP (payload or undecoded)");
+		ND_PRINT((ndo, " BEEP (payload or undecoded)"));
 }
diff --git a/print-bfd.c b/print-bfd.c
index f157684..f1c2ee8 100644
--- a/print-bfd.c
+++ b/print-bfd.c
@@ -13,23 +13,15 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.10 2006-02-02 06:35:52 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
 
 #include "udp.h"
 
@@ -53,7 +45,7 @@
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
-/* 
+/*
  *  Control packet, BFDv1, draft-ietf-bfd-base-02.txt
  *
  *     0                   1                   2                   3
@@ -74,15 +66,15 @@
  */
 
 struct bfd_header_t {
-    u_int8_t version_diag;
-    u_int8_t flags;
-    u_int8_t detect_time_multiplier;
-    u_int8_t length;
-    u_int8_t my_discriminator[4];
-    u_int8_t your_discriminator[4];
-    u_int8_t desired_min_tx_interval[4];
-    u_int8_t required_min_rx_interval[4];
-    u_int8_t required_min_echo_interval[4];
+    uint8_t version_diag;
+    uint8_t flags;
+    uint8_t detect_time_multiplier;
+    uint8_t length;
+    uint8_t my_discriminator[4];
+    uint8_t your_discriminator[4];
+    uint8_t desired_min_tx_interval[4];
+    uint8_t required_min_rx_interval[4];
+    uint8_t required_min_echo_interval[4];
 };
 
 /*
@@ -96,9 +88,9 @@
  */
 
 struct bfd_auth_header_t {
-    u_int8_t auth_type;
-    u_int8_t auth_len;
-    u_int8_t auth_data;
+    uint8_t auth_type;
+    uint8_t auth_len;
+    uint8_t auth_data;
 };
 
 static const struct tok bfd_v1_authentication_values[] = {
@@ -167,15 +159,16 @@
 };
 
 void
-bfd_print(register const u_char *pptr, register u_int len, register u_int port)
+bfd_print(netdissect_options *ndo, register const u_char *pptr,
+          register u_int len, register u_int port)
 {
         const struct bfd_header_t *bfd_header;
         const struct bfd_auth_header_t *bfd_auth_header;
-        u_int8_t version = 0;
+        uint8_t version = 0;
 
         bfd_header = (const struct bfd_header_t *)pptr;
         if (port == BFD_CONTROL_PORT) {
-            TCHECK(*bfd_header);
+            ND_TCHECK(*bfd_header);
             version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
         } else if (port == BFD_ECHO_PORT) {
             /* Echo is BFD v1 only */
@@ -185,79 +178,79 @@
 
             /* BFDv0 */
         case (BFD_CONTROL_PORT << 8):
-            if (vflag < 1 )
+            if (ndo->ndo_vflag < 1)
             {
-                printf("BFDv%u, %s, Flags: [%s], length: %u",
+                ND_PRINT((ndo, "BFDv%u, %s, Flags: [%s], length: %u",
                        version,
                        tok2str(bfd_port_values, "unknown (%u)", port),
                        bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
-                       len);
+                       len));
                 return;
             }
-            
-            printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
+
+            ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
                    version,
                    len,
                    tok2str(bfd_port_values, "unknown (%u)", port),
                    bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
                    tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
-                   BFD_EXTRACT_DIAG(bfd_header->version_diag));
-            
-            printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+                   BFD_EXTRACT_DIAG(bfd_header->version_diag)));
+
+            ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
                    bfd_header->detect_time_multiplier,
                    bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
-                   bfd_header->length);
+                   bfd_header->length));
 
 
-            printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
-            printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
-            printf("\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
-            printf("\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
-            printf("\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
+            ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+            ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+            ND_PRINT((ndo, "\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+            ND_PRINT((ndo, "\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+            ND_PRINT((ndo, "\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
             break;
 
             /* BFDv1 */
         case (BFD_CONTROL_PORT << 8 | 1):
-            if (vflag < 1 )
+            if (ndo->ndo_vflag < 1)
             {
-                printf("BFDv%u, %s, State %s, Flags: [%s], length: %u",
+                ND_PRINT((ndo, "BFDv%u, %s, State %s, Flags: [%s], length: %u",
                        version,
                        tok2str(bfd_port_values, "unknown (%u)", port),
                        tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
                        bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
-                       len);
+                       len));
                 return;
             }
-            
-            printf("BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
+
+            ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
                    version,
                    len,
                    tok2str(bfd_port_values, "unknown (%u)", port),
                    tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
                    bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
                    tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
-                   BFD_EXTRACT_DIAG(bfd_header->version_diag));
-            
-            printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+                   BFD_EXTRACT_DIAG(bfd_header->version_diag)));
+
+            ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
                    bfd_header->detect_time_multiplier,
                    bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
-                   bfd_header->length);
+                   bfd_header->length));
 
 
-            printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
-            printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
-            printf("\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
-            printf("\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
-            printf("\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
+            ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+            ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+            ND_PRINT((ndo, "\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+            ND_PRINT((ndo, "\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+            ND_PRINT((ndo, "\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
 
             if (bfd_header->flags & BFD_FLAG_AUTH) {
                 pptr += sizeof (const struct bfd_header_t);
                 bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
-                TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
-                printf("\n\t%s (%u) Authentication, length %u present",
+                ND_TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
+                ND_PRINT((ndo, "\n\t%s (%u) Authentication, length %u present",
                        tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type),
                        bfd_auth_header->auth_type,
-                       bfd_auth_header->auth_len);
+                       bfd_auth_header->auth_len));
             }
             break;
 
@@ -267,17 +260,23 @@
         case (BFD_ECHO_PORT << 8 | 1):
 
         default:
-            printf("BFD, %s, length: %u",
+            ND_PRINT((ndo, "BFD, %s, length: %u",
                    tok2str(bfd_port_values, "unknown (%u)", port),
-                   len);
-            if (vflag >= 1) {
-                if(!print_unknown_data(pptr,"\n\t",len))
-                    return;
+                   len));
+            if (ndo->ndo_vflag >= 1) {
+                    if(!print_unknown_data(ndo, pptr,"\n\t",len))
+                            return;
             }
             break;
         }
         return;
 
 trunc:
-        printf("[|BFD]");
+        ND_PRINT((ndo, "[|BFD]"));
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-bgp.c b/print-bgp.c
index 2ad7cbc..c617c3b 100644
--- a/print-bgp.c
+++ b/print-bgp.c
@@ -30,32 +30,26 @@
  * complete BGP support.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.118 2007-12-07 15:54:52 hannes Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
-#include "decode_prefix.h"
 #include "addrtoname.h"
 #include "extract.h"
-#include "bgp.h"
 #include "af.h"
 #include "l2vpn.h"
 
 struct bgp {
-	u_int8_t bgp_marker[16];
-	u_int16_t bgp_len;
-	u_int8_t bgp_type;
+	uint8_t bgp_marker[16];
+	uint16_t bgp_len;
+	uint8_t bgp_type;
 };
 #define BGP_SIZE		19	/* unaligned */
 
@@ -75,43 +69,43 @@
 };
 
 struct bgp_open {
-	u_int8_t bgpo_marker[16];
-	u_int16_t bgpo_len;
-	u_int8_t bgpo_type;
-	u_int8_t bgpo_version;
-	u_int16_t bgpo_myas;
-	u_int16_t bgpo_holdtime;
-	u_int32_t bgpo_id;
-	u_int8_t bgpo_optlen;
+	uint8_t bgpo_marker[16];
+	uint16_t bgpo_len;
+	uint8_t bgpo_type;
+	uint8_t bgpo_version;
+	uint16_t bgpo_myas;
+	uint16_t bgpo_holdtime;
+	uint32_t bgpo_id;
+	uint8_t bgpo_optlen;
 	/* options should follow */
 };
 #define BGP_OPEN_SIZE		29	/* unaligned */
 
 struct bgp_opt {
-	u_int8_t bgpopt_type;
-	u_int8_t bgpopt_len;
+	uint8_t bgpopt_type;
+	uint8_t bgpopt_len;
 	/* variable length */
 };
 #define BGP_OPT_SIZE		2	/* some compilers may pad to 4 bytes */
 #define BGP_CAP_HEADER_SIZE	2	/* some compilers may pad to 4 bytes */
 
 struct bgp_notification {
-	u_int8_t bgpn_marker[16];
-	u_int16_t bgpn_len;
-	u_int8_t bgpn_type;
-	u_int8_t bgpn_major;
-	u_int8_t bgpn_minor;
+	uint8_t bgpn_marker[16];
+	uint16_t bgpn_len;
+	uint8_t bgpn_type;
+	uint8_t bgpn_major;
+	uint8_t bgpn_minor;
 };
 #define BGP_NOTIFICATION_SIZE		21	/* unaligned */
 
 struct bgp_route_refresh {
-    u_int8_t  bgp_marker[16];
-    u_int16_t len;
-    u_int8_t  type;
-    u_int8_t  afi[2]; /* the compiler messes this structure up               */
-    u_int8_t  res;    /* when doing misaligned sequences of int8 and int16   */
-    u_int8_t  safi;   /* afi should be int16 - so we have to access it using */
-};                    /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh)      */ 
+    uint8_t  bgp_marker[16];
+    uint16_t len;
+    uint8_t  type;
+    uint8_t  afi[2]; /* the compiler messes this structure up               */
+    uint8_t  res;    /* when doing misaligned sequences of int8 and int16   */
+    uint8_t  safi;   /* afi should be int16 - so we have to access it using */
+};                    /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh)      */
 #define BGP_ROUTE_REFRESH_SIZE          23
 
 #define bgp_attr_lenlen(flags, p) \
@@ -387,7 +381,7 @@
 #define BGP_EXT_COM_OSPF_RTYPE2 0x8000  /* duplicate - keep for backwards compatability */
 
 #define BGP_EXT_COM_OSPF_RID    0x0107  /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
-#define BGP_EXT_COM_OSPF_RID2   0x8001  /* duplicate - keep for backwards compatability */ 
+#define BGP_EXT_COM_OSPF_RID2   0x8001  /* duplicate - keep for backwards compatability */
 
 #define BGP_EXT_COM_L2INFO      0x800a  /* draft-kompella-ppvpn-l2vpn */
 
@@ -427,7 +421,7 @@
     { BGP_EXT_COM_OSPF_RTYPE2, "ospf-route-type"},
     { BGP_EXT_COM_OSPF_RID,    "ospf-router-id"},
     { BGP_EXT_COM_OSPF_RID2,   "ospf-router-id"},
-    { BGP_EXT_COM_L2INFO,      "layer2-info"}, 
+    { BGP_EXT_COM_L2INFO,      "layer2-info"},
     { BGP_EXT_COM_EIGRP_GEN , "eigrp-general-route (flag, tag)" },
     { BGP_EXT_COM_EIGRP_METRIC_AS_DELAY , "eigrp-route-metric (AS, delay)" },
     { BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW , "eigrp-route-metric (reliability, nexthop, bandwidth)" },
@@ -451,12 +445,12 @@
 #define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */
 
 static const struct tok bgp_extd_comm_ospf_rtype_values[] = {
-  { BGP_OSPF_RTYPE_RTR, "Router" },  
-  { BGP_OSPF_RTYPE_NET, "Network" },  
-  { BGP_OSPF_RTYPE_SUM, "Summary" },  
-  { BGP_OSPF_RTYPE_EXT, "External" },  
+  { BGP_OSPF_RTYPE_RTR, "Router" },
+  { BGP_OSPF_RTYPE_NET, "Network" },
+  { BGP_OSPF_RTYPE_SUM, "Summary" },
+  { BGP_OSPF_RTYPE_EXT, "External" },
   { BGP_OSPF_RTYPE_NSSA,"NSSA External" },
-  { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" },  
+  { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" },
   { 0, NULL },
 };
 
@@ -468,14 +462,15 @@
  *
  * Convert an AS number into a string and return string pointer.
  *
- * Bepending on bflag is set or not, AS number is converted into ASDOT notation
+ * Depending on bflag is set or not, AS number is converted into ASDOT notation
  * or plain number notation.
  *
  */
 static char *
-as_printf (char *str, int size, u_int asnum)
+as_printf(netdissect_options *ndo,
+          char *str, int size, u_int asnum)
 {
-	if (!bflag || asnum <= 0xFFFF) {
+	if (!ndo->ndo_bflag || asnum <= 0xFFFF) {
 		snprintf(str, size, "%u", asnum);
 	} else {
 		snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
@@ -486,12 +481,13 @@
 #define ITEMCHECK(minlen) if (itemlen < minlen) goto badtlv;
 
 int
-decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_prefix4(netdissect_options *ndo,
+               const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
 {
 	struct in_addr addr;
 	u_int plen, plenbytes;
 
-	TCHECK(pptr[0]);
+	ND_TCHECK(pptr[0]);
 	ITEMCHECK(1);
 	plen = pptr[0];
 	if (32 < plen)
@@ -500,14 +496,14 @@
 
 	memset(&addr, 0, sizeof(addr));
 	plenbytes = (plen + 7) / 8;
-	TCHECK2(pptr[1], plenbytes);
+	ND_TCHECK2(pptr[1], plenbytes);
 	ITEMCHECK(plenbytes);
 	memcpy(&addr, &pptr[1], plenbytes);
 	if (plen % 8) {
 		((u_char *)&addr)[plenbytes - 1] &=
 			((0xff00 >> (plen % 8)) & 0xff);
 	}
-	snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen);
+	snprintf(buf, buflen, "%s/%d", getname(ndo, (u_char *)&addr), plen);
 	return 1 + plenbytes;
 
 trunc:
@@ -518,13 +514,14 @@
 }
 
 static int
-decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_labeled_prefix4(netdissect_options *ndo,
+                       const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
 {
 	struct in_addr addr;
 	u_int plen, plenbytes;
 
 	/* prefix length and label = 4 bytes */
-	TCHECK2(pptr[0], 4);
+	ND_TCHECK2(pptr[0], 4);
 	ITEMCHECK(4);
 	plen = pptr[0];   /* get prefix length */
 
@@ -533,7 +530,7 @@
            is added to the prefix length;
            we also do only read out just one label -
            there is no real application for advertisement of
-           stacked labels in a a single BGP message
+           stacked labels in a single BGP message
         */
 
 	if (24 > plen)
@@ -547,7 +544,7 @@
 
 	memset(&addr, 0, sizeof(addr));
 	plenbytes = (plen + 7) / 8;
-	TCHECK2(pptr[4], plenbytes);
+	ND_TCHECK2(pptr[4], plenbytes);
 	ITEMCHECK(plenbytes);
 	memcpy(&addr, &pptr[4], plenbytes);
 	if (plen % 8) {
@@ -556,7 +553,7 @@
 	}
         /* the label may get offsetted by 4 bits so lets shift it right */
 	snprintf(buf, buflen, "%s/%d, label:%u %s",
-                 getname((u_char *)&addr),
+                 getname(ndo, (u_char *)&addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -576,7 +573,9 @@
  * print an ipv4 or ipv6 address into a buffer dependend on address length.
  */
 static char *
-bgp_vpn_ip_print (const u_char *pptr, u_int addr_length) {
+bgp_vpn_ip_print(netdissect_options *ndo,
+                 const u_char *pptr, u_int addr_length)
+{
 
     /* worst case string is s fully formatted v6 address */
     static char addr[sizeof("1234:5678:89ab:cdef:1234:5678:89ab:cdef")];
@@ -584,13 +583,13 @@
 
     switch(addr_length) {
     case (sizeof(struct in_addr) << 3): /* 32 */
-        TCHECK2(pptr[0], sizeof(struct in_addr));
-        snprintf(pos, sizeof(addr), "%s", ipaddr_string(pptr));
+        ND_TCHECK2(pptr[0], sizeof(struct in_addr));
+        snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
         break;
 #ifdef INET6
     case (sizeof(struct in6_addr) << 3): /* 128 */
-        TCHECK2(pptr[0], sizeof(struct in6_addr));
-        snprintf(pos, sizeof(addr), "%s", ip6addr_string(pptr));
+        ND_TCHECK2(pptr[0], sizeof(struct in6_addr));
+        snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
         break;
 #endif
     default:
@@ -623,38 +622,39 @@
  * return the number of bytes read from the wire.
  */
 static int
-bgp_vpn_sg_print (const u_char *pptr, char *buf, u_int buflen) {
-
-    u_int8_t addr_length;
+bgp_vpn_sg_print(netdissect_options *ndo,
+                 const u_char *pptr, char *buf, u_int buflen)
+{
+    uint8_t addr_length;
     u_int total_length, offset;
 
     total_length = 0;
 
     /* Source address length, encoded in bits */
-    TCHECK2(pptr[0], 1);
+    ND_TCHECK2(pptr[0], 1);
     addr_length =  *pptr++;
 
     /* Source address */
-    TCHECK2(pptr[0], (addr_length >> 3));
+    ND_TCHECK2(pptr[0], (addr_length >> 3));
     total_length += (addr_length >> 3) + 1;
     offset = strlen(buf);
     if (addr_length) {
         snprintf(buf + offset, buflen - offset, ", Source %s",
-                 bgp_vpn_ip_print(pptr, addr_length));
+                 bgp_vpn_ip_print(ndo, pptr, addr_length));
         pptr += (addr_length >> 3);
     }
-    
+
     /* Group address length, encoded in bits */
-    TCHECK2(pptr[0], 1);
+    ND_TCHECK2(pptr[0], 1);
     addr_length =  *pptr++;
 
     /* Group address */
-    TCHECK2(pptr[0], (addr_length >> 3));
+    ND_TCHECK2(pptr[0], (addr_length >> 3));
     total_length += (addr_length >> 3) + 1;
     offset = strlen(buf);
     if (addr_length) {
         snprintf(buf + offset, buflen - offset, ", Group %s",
-                 bgp_vpn_ip_print(pptr, addr_length));
+                 bgp_vpn_ip_print(ndo, pptr, addr_length));
         pptr += (addr_length >> 3);
     }
 
@@ -667,8 +667,9 @@
  * we use bgp_vpn_rd_print for
  * printing route targets inside a NLRI */
 char *
-bgp_vpn_rd_print (const u_char *pptr) {
-
+bgp_vpn_rd_print(netdissect_options *ndo,
+                 const u_char *pptr)
+{
    /* allocate space for the largest possible string */
     static char rd[sizeof("xxxxxxxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")];
     char *pos = rd;
@@ -693,7 +694,7 @@
         /* 4-byte-AS:number fmt*/
     case 2:
 	snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
-	    as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)),
+	    as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)),
 	    EXTRACT_16BITS(pptr+6), *(pptr+2), *(pptr+3), *(pptr+4),
 	    *(pptr+5), EXTRACT_16BITS(pptr+6));
         break;
@@ -707,16 +708,19 @@
 }
 
 static int
-decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen)
+decode_rt_routing_info(netdissect_options *ndo,
+                       const u_char *pptr, char *buf, u_int buflen)
 {
-	u_int8_t route_target[8];
+	uint8_t route_target[8];
 	u_int plen;
 
-	TCHECK(pptr[0]);
+	ND_TCHECK(pptr[0]);
 	plen = pptr[0];   /* get prefix length */
 
-	if (0 == plen)
-		return 1; /* default route target */
+	if (0 == plen) {
+		snprintf(buf, buflen, "default route target");
+		return 1;
+	}
 
 	if (32 > plen)
 		return -1;
@@ -727,15 +731,15 @@
 		return -1;
 
 	memset(&route_target, 0, sizeof(route_target));
-	TCHECK2(pptr[1], (plen + 7) / 8);
+	ND_TCHECK2(pptr[1], (plen + 7) / 8);
 	memcpy(&route_target, &pptr[1], (plen + 7) / 8);
 	if (plen % 8) {
 		((u_char *)&route_target)[(plen + 7) / 8 - 1] &=
 			((0xff00 >> (plen % 8)) & 0xff);
 	}
 	snprintf(buf, buflen, "origin AS: %s, route target %s",
-	    as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)),
-	    bgp_vpn_rd_print((u_char *)&route_target));
+	    as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)),
+	    bgp_vpn_rd_print(ndo, (u_char *)&route_target));
 
 	return 5 + (plen + 7) / 8;
 
@@ -744,12 +748,13 @@
 }
 
 static int
-decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_prefix4(netdissect_options *ndo,
+                           const u_char *pptr, char *buf, u_int buflen)
 {
 	struct in_addr addr;
 	u_int plen;
 
-	TCHECK(pptr[0]);
+	ND_TCHECK(pptr[0]);
 	plen = pptr[0];   /* get prefix length */
 
 	if ((24+64) > plen)
@@ -761,7 +766,7 @@
 		return -1;
 
 	memset(&addr, 0, sizeof(addr));
-	TCHECK2(pptr[12], (plen + 7) / 8);
+	ND_TCHECK2(pptr[12], (plen + 7) / 8);
 	memcpy(&addr, &pptr[12], (plen + 7) / 8);
 	if (plen % 8) {
 		((u_char *)&addr)[(plen + 7) / 8 - 1] &=
@@ -769,8 +774,8 @@
 	}
         /* the label may get offsetted by 4 bits so lets shift it right */
 	snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
-                 bgp_vpn_rd_print(pptr+4),
-                 getname((u_char *)&addr),
+                 bgp_vpn_rd_print(ndo, pptr+4),
+                 getname(ndo, (u_char *)&addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -794,35 +799,36 @@
 #define MDT_VPN_NLRI_LEN 16
 
 static int
-decode_mdt_vpn_nlri(const u_char *pptr, char *buf, u_int buflen)
+decode_mdt_vpn_nlri(netdissect_options *ndo,
+                    const u_char *pptr, char *buf, u_int buflen)
 {
 
     const u_char *rd;
     const u_char *vpn_ip;
-    
-    TCHECK(pptr[0]);
+
+    ND_TCHECK(pptr[0]);
 
     /* if the NLRI is not predefined length, quit.*/
-    if (*pptr != MDT_VPN_NLRI_LEN * NBBY)
+    if (*pptr != MDT_VPN_NLRI_LEN * 8)
 	return -1;
     pptr++;
 
     /* RD */
-    TCHECK2(pptr[0], 8);
+    ND_TCHECK2(pptr[0], 8);
     rd = pptr;
     pptr+=8;
 
     /* IPv4 address */
-    TCHECK2(pptr[0], sizeof(struct in_addr));
+    ND_TCHECK2(pptr[0], sizeof(struct in_addr));
     vpn_ip = pptr;
     pptr+=sizeof(struct in_addr);
 
     /* MDT Group Address */
-    TCHECK2(pptr[0], sizeof(struct in_addr));
+    ND_TCHECK2(pptr[0], sizeof(struct in_addr));
 
     snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
-	     bgp_vpn_rd_print(rd), ipaddr_string(vpn_ip), ipaddr_string(pptr));
-       
+	     bgp_vpn_rd_print(ndo, rd), ipaddr_string(ndo, vpn_ip), ipaddr_string(ndo, pptr));
+
     return MDT_VPN_NLRI_LEN + 1;
 
  trunc:
@@ -849,12 +855,13 @@
 };
 
 static int
-decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen)
+decode_multicast_vpn(netdissect_options *ndo,
+                     const u_char *pptr, char *buf, u_int buflen)
 {
-        u_int8_t route_type, route_length, addr_length, sg_length;
+        uint8_t route_type, route_length, addr_length, sg_length;
         u_int offset;
 
-	TCHECK2(pptr[0], 2);
+	ND_TCHECK2(pptr[0], 2);
         route_type = *pptr++;
         route_length = *pptr++;
 
@@ -865,59 +872,59 @@
 
         switch(route_type) {
         case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI:
-            TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+            ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
             offset = strlen(buf);
             snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s",
-                     bgp_vpn_rd_print(pptr),
-                     bgp_vpn_ip_print(pptr + BGP_VPN_RD_LEN,
+                     bgp_vpn_rd_print(ndo, pptr),
+                     bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN,
                                       (route_length - BGP_VPN_RD_LEN) << 3));
             break;
         case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI:
-            TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4);
+            ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4);
             offset = strlen(buf);
 	    snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
-		bgp_vpn_rd_print(pptr),
-		as_printf(astostr, sizeof(astostr),
+		bgp_vpn_rd_print(ndo, pptr),
+		as_printf(ndo, astostr, sizeof(astostr),
 		EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
             break;
 
         case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
-            TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+            ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
             offset = strlen(buf);
             snprintf(buf + offset, buflen - offset, ", RD: %s",
-                     bgp_vpn_rd_print(pptr));
+                     bgp_vpn_rd_print(ndo, pptr));
             pptr += BGP_VPN_RD_LEN;
 
-            sg_length = bgp_vpn_sg_print(pptr, buf, buflen);
+            sg_length = bgp_vpn_sg_print(ndo, pptr, buf, buflen);
             addr_length =  route_length - sg_length;
 
-            TCHECK2(pptr[0], addr_length);
+            ND_TCHECK2(pptr[0], addr_length);
             offset = strlen(buf);
             snprintf(buf + offset, buflen - offset, ", Originator %s",
-                     bgp_vpn_ip_print(pptr, addr_length << 3));
+                     bgp_vpn_ip_print(ndo, pptr, addr_length << 3));
             break;
 
         case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE:
-            TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+            ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
             offset = strlen(buf);
             snprintf(buf + offset, buflen - offset, ", RD: %s",
-                     bgp_vpn_rd_print(pptr));
+                     bgp_vpn_rd_print(ndo, pptr));
             pptr += BGP_VPN_RD_LEN;
 
-            bgp_vpn_sg_print(pptr, buf, buflen);
+            bgp_vpn_sg_print(ndo, pptr, buf, buflen);
             break;
 
         case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */
         case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN:
-            TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+            ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
             offset = strlen(buf);
 	    snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
-		bgp_vpn_rd_print(pptr),
-		as_printf(astostr, sizeof(astostr),
+		bgp_vpn_rd_print(ndo, pptr),
+		as_printf(ndo, astostr, sizeof(astostr),
 		EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
             pptr += BGP_VPN_RD_LEN;
 
-            bgp_vpn_sg_print(pptr, buf, buflen);
+            bgp_vpn_sg_print(ndo, pptr, buf, buflen);
             break;
 
             /*
@@ -955,11 +962,12 @@
     }
 
 static int
-decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_l2(netdissect_options *ndo,
+                      const u_char *pptr, char *buf, u_int buflen)
 {
         int plen,tlen,strlen,tlv_type,tlv_len,ttlv_len;
 
-	TCHECK2(pptr[0], 2);
+	ND_TCHECK2(pptr[0], 2);
         plen=EXTRACT_16BITS(pptr);
         tlen=plen;
         pptr+=2;
@@ -967,27 +975,27 @@
          *   -> Assume a 12 Byte-length NLRI is auto-discovery-only
          *      and > 17 as old format. Complain for the middle case
          */
-        if (plen==12) { 
+        if (plen==12) {
 	    /* assume AD-only with RD, BGPNH */
-	    TCHECK2(pptr[0],12);
+	    ND_TCHECK2(pptr[0],12);
 	    buf[0]='\0';
 	    strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
-			    bgp_vpn_rd_print(pptr), 
-			    /* need something like getname() here */
-			    getname(pptr+8)
+			    bgp_vpn_rd_print(ndo, pptr),
+			    /* need something like getname(ndo, ) here */
+			    getname(ndo, pptr+8)
 			    );
 	    UPDATE_BUF_BUFLEN(buf, buflen, strlen);
 	    pptr+=12;
 	    tlen-=12;
 	    return plen;
-        } else if (plen>17) { 
+        } else if (plen>17) {
 	    /* assume old format */
 	    /* RD, ID, LBLKOFF, LBLBASE */
 
-	    TCHECK2(pptr[0],15);
+	    ND_TCHECK2(pptr[0],15);
 	    buf[0]='\0';
 	    strlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
-			    bgp_vpn_rd_print(pptr),
+			    bgp_vpn_rd_print(ndo, pptr),
 			    EXTRACT_16BITS(pptr+8),
 			    EXTRACT_16BITS(pptr+10),
 			    EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
@@ -999,7 +1007,7 @@
 	    while (tlen>0) {
 		if (tlen < 3)
 		    return -1;
-		TCHECK2(pptr[0], 3);
+		ND_TCHECK2(pptr[0], 3);
 		tlv_type=*pptr++;
 		tlv_len=EXTRACT_16BITS(pptr);
 		ttlv_len=tlv_len;
@@ -1015,7 +1023,7 @@
 		    }
 		    ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */
 		    while (ttlv_len>0) {
-			TCHECK(pptr[0]);
+			ND_TCHECK(pptr[0]);
 			if (buflen!=0) {
 			    strlen=snprintf(buf,buflen, "%02x",*pptr++);
 			    UPDATE_BUF_BUFLEN(buf, buflen, strlen);
@@ -1035,7 +1043,7 @@
 		tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */
 	    }
 	    return plen+2;
-	    
+
         } else {
 	    /* complain bitterly ? */
 	    /* fall through */
@@ -1048,12 +1056,13 @@
 
 #ifdef INET6
 int
-decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen)
+decode_prefix6(netdissect_options *ndo,
+               const u_char *pd, u_int itemlen, char *buf, u_int buflen)
 {
 	struct in6_addr addr;
 	u_int plen, plenbytes;
 
-	TCHECK(pd[0]);
+	ND_TCHECK(pd[0]);
 	ITEMCHECK(1);
 	plen = pd[0];
 	if (128 < plen)
@@ -1062,14 +1071,14 @@
 
 	memset(&addr, 0, sizeof(addr));
 	plenbytes = (plen + 7) / 8;
-	TCHECK2(pd[1], plenbytes);
+	ND_TCHECK2(pd[1], plenbytes);
 	ITEMCHECK(plenbytes);
 	memcpy(&addr, &pd[1], plenbytes);
 	if (plen % 8) {
 		addr.s6_addr[plenbytes - 1] &=
 			((0xff00 >> (plen % 8)) & 0xff);
 	}
-	snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
+	snprintf(buf, buflen, "%s/%d", getname6(ndo, (u_char *)&addr), plen);
 	return 1 + plenbytes;
 
 trunc:
@@ -1080,13 +1089,14 @@
 }
 
 static int
-decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_labeled_prefix6(netdissect_options *ndo,
+                       const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
 {
 	struct in6_addr addr;
 	u_int plen, plenbytes;
 
 	/* prefix length and label = 4 bytes */
-	TCHECK2(pptr[0], 4);
+	ND_TCHECK2(pptr[0], 4);
 	ITEMCHECK(4);
 	plen = pptr[0]; /* get prefix length */
 
@@ -1101,7 +1111,7 @@
 
 	memset(&addr, 0, sizeof(addr));
 	plenbytes = (plen + 7) / 8;
-	TCHECK2(pptr[4], plenbytes);
+	ND_TCHECK2(pptr[4], plenbytes);
 	memcpy(&addr, &pptr[4], plenbytes);
 	if (plen % 8) {
 		addr.s6_addr[plenbytes - 1] &=
@@ -1109,7 +1119,7 @@
 	}
         /* the label may get offsetted by 4 bits so lets shift it right */
 	snprintf(buf, buflen, "%s/%d, label:%u %s",
-                 getname6((u_char *)&addr),
+                 getname6(ndo, (u_char *)&addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1124,12 +1134,13 @@
 }
 
 static int
-decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_prefix6(netdissect_options *ndo,
+                           const u_char *pptr, char *buf, u_int buflen)
 {
 	struct in6_addr addr;
 	u_int plen;
 
-	TCHECK(pptr[0]);
+	ND_TCHECK(pptr[0]);
 	plen = pptr[0];   /* get prefix length */
 
 	if ((24+64) > plen)
@@ -1141,7 +1152,7 @@
 		return -1;
 
 	memset(&addr, 0, sizeof(addr));
-	TCHECK2(pptr[12], (plen + 7) / 8);
+	ND_TCHECK2(pptr[12], (plen + 7) / 8);
 	memcpy(&addr, &pptr[12], (plen + 7) / 8);
 	if (plen % 8) {
 		addr.s6_addr[(plen + 7) / 8 - 1] &=
@@ -1149,8 +1160,8 @@
 	}
         /* the label may get offsetted by 4 bits so lets shift it right */
 	snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
-                 bgp_vpn_rd_print(pptr+4),
-                 getname6((u_char *)&addr),
+                 bgp_vpn_rd_print(ndo, pptr+4),
+                 getname6(ndo, (u_char *)&addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1163,19 +1174,20 @@
 #endif
 
 static int
-decode_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
+decode_clnp_prefix(netdissect_options *ndo,
+                   const u_char *pptr, char *buf, u_int buflen)
 {
-        u_int8_t addr[19];
+        uint8_t addr[19];
 	u_int plen;
 
-	TCHECK(pptr[0]);
+	ND_TCHECK(pptr[0]);
 	plen = pptr[0]; /* get prefix length */
 
 	if (152 < plen)
 		return -1;
 
 	memset(&addr, 0, sizeof(addr));
-	TCHECK2(pptr[4], (plen + 7) / 8);
+	ND_TCHECK2(pptr[4], (plen + 7) / 8);
 	memcpy(&addr, &pptr[4], (plen + 7) / 8);
 	if (plen % 8) {
 		addr[(plen + 7) / 8 - 1] &=
@@ -1192,12 +1204,13 @@
 }
 
 static int
-decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
+                               const u_char *pptr, char *buf, u_int buflen)
 {
-        u_int8_t addr[19];
+        uint8_t addr[19];
 	u_int plen;
 
-	TCHECK(pptr[0]);
+	ND_TCHECK(pptr[0]);
 	plen = pptr[0];   /* get prefix length */
 
 	if ((24+64) > plen)
@@ -1209,7 +1222,7 @@
 		return -1;
 
 	memset(&addr, 0, sizeof(addr));
-	TCHECK2(pptr[12], (plen + 7) / 8);
+	ND_TCHECK2(pptr[12], (plen + 7) / 8);
 	memcpy(&addr, &pptr[12], (plen + 7) / 8);
 	if (plen % 8) {
 		addr[(plen + 7) / 8 - 1] &=
@@ -1217,7 +1230,7 @@
 	}
         /* the label may get offsetted by 4 bits so lets shift it right */
 	snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
-                 bgp_vpn_rd_print(pptr+4),
+                 bgp_vpn_rd_print(ndo, pptr+4),
                  isonsap_string(addr,(plen + 7) / 8),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
@@ -1237,7 +1250,8 @@
  * support, exchange AS-Path with the same path-attribute type value 0x02.
  */
 static int
-bgp_attr_get_as_size (u_int8_t bgpa_type, const u_char *pptr, int len)
+bgp_attr_get_as_size(netdissect_options *ndo,
+                     uint8_t bgpa_type, const u_char *pptr, int len)
 {
     const u_char *tptr = pptr;
 
@@ -1255,7 +1269,7 @@
      * each.
      */
     while (tptr < pptr + len) {
-        TCHECK(tptr[0]);
+        ND_TCHECK(tptr[0]);
 
         /*
          * If we do not find a valid segment type, our guess might be wrong.
@@ -1263,7 +1277,7 @@
         if (tptr[0] < BGP_AS_SEG_TYPE_MIN || tptr[0] > BGP_AS_SEG_TYPE_MAX) {
             goto trunc;
         }
-        TCHECK(tptr[1]);
+        ND_TCHECK(tptr[1]);
         tptr += 2 + tptr[1] * 2;
     }
 
@@ -1287,14 +1301,15 @@
 }
 
 static int
-bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
+bgp_attr_print(netdissect_options *ndo,
+               u_int atype, const u_char *pptr, u_int len)
 {
 	int i;
-	u_int16_t af;
-	u_int8_t safi, snpa, nhlen;
+	uint16_t af;
+	uint8_t safi, snpa, nhlen;
         union { /* copy buffer for bandwidth values */
-            float f; 
-            u_int32_t i;
+            float f;
+            uint32_t i;
         } bw;
 	int advance;
 	u_int tlen;
@@ -1309,13 +1324,13 @@
 	switch (atype) {
 	case BGPTYPE_ORIGIN:
 		if (len != 1)
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 		else {
-			TCHECK(*tptr);
-			printf("%s", tok2strbuf(bgp_origin_values,
+			ND_TCHECK(*tptr);
+			ND_PRINT((ndo, "%s", tok2strbuf(bgp_origin_values,
 						"Unknown Origin Typecode",
 						tptr[0],
-						tokbuf, sizeof(tokbuf)));
+						tokbuf, sizeof(tokbuf))));
 		}
 		break;
 
@@ -1326,11 +1341,11 @@
 	case BGPTYPE_AS4_PATH:
 	case BGPTYPE_AS_PATH:
 		if (len % 2) {
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 			break;
 		}
                 if (!len) {
-			printf("empty");
+			ND_PRINT((ndo, "empty"));
 			break;
                 }
 
@@ -1342,49 +1357,49 @@
                  * 2 bytes first, and it does not pass, assume that ASs are
                  * encoded in 4 bytes format and move on.
                  */
-                as_size = bgp_attr_get_as_size(atype, pptr, len);
+                as_size = bgp_attr_get_as_size(ndo, atype, pptr, len);
 
 		while (tptr < pptr + len) {
-			TCHECK(tptr[0]);
-                        printf("%s", tok2strbuf(bgp_as_path_segment_open_values,
+			ND_TCHECK(tptr[0]);
+                        ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_open_values,
 						"?", tptr[0],
-						tokbuf, sizeof(tokbuf)));
+						tokbuf, sizeof(tokbuf))));
                         for (i = 0; i < tptr[1] * as_size; i += as_size) {
-                            TCHECK2(tptr[2 + i], as_size);
-			    printf("%s ",
-				as_printf(astostr, sizeof(astostr),
-				as_size == 2 ? 
+                            ND_TCHECK2(tptr[2 + i], as_size);
+			    ND_PRINT((ndo, "%s ",
+				as_printf(ndo, astostr, sizeof(astostr),
+				as_size == 2 ?
 				EXTRACT_16BITS(&tptr[2 + i]) :
-				EXTRACT_32BITS(&tptr[2 + i])));
+				EXTRACT_32BITS(&tptr[2 + i]))));
                         }
-			TCHECK(tptr[0]);
-                        printf("%s", tok2strbuf(bgp_as_path_segment_close_values,
+			ND_TCHECK(tptr[0]);
+                        ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_close_values,
 						"?", tptr[0],
-						tokbuf, sizeof(tokbuf)));
-                        TCHECK(tptr[1]);
+						tokbuf, sizeof(tokbuf))));
+                        ND_TCHECK(tptr[1]);
                         tptr += 2 + tptr[1] * as_size;
 		}
 		break;
 	case BGPTYPE_NEXT_HOP:
 		if (len != 4)
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 		else {
-			TCHECK2(tptr[0], 4);
-			printf("%s", getname(tptr));
+			ND_TCHECK2(tptr[0], 4);
+			ND_PRINT((ndo, "%s", getname(ndo, tptr)));
 		}
 		break;
 	case BGPTYPE_MULTI_EXIT_DISC:
 	case BGPTYPE_LOCAL_PREF:
 		if (len != 4)
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 		else {
-			TCHECK2(tptr[0], 4);
-			printf("%u", EXTRACT_32BITS(tptr));
+			ND_TCHECK2(tptr[0], 4);
+			ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr)));
 		}
 		break;
 	case BGPTYPE_ATOMIC_AGGREGATE:
 		if (len != 0)
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 		break;
         case BGPTYPE_AGGREGATOR:
 
@@ -1393,54 +1408,54 @@
                  * the length of this PA can be either 6 bytes or 8 bytes.
                  */
                 if (len != 6 && len != 8) {
-                    printf("invalid len");
+                    ND_PRINT((ndo, "invalid len"));
                     break;
                 }
-                TCHECK2(tptr[0], len);
+                ND_TCHECK2(tptr[0], len);
                 if (len == 6) {
-		    printf(" AS #%s, origin %s",
-			as_printf(astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
-			getname(tptr + 2));
+		    ND_PRINT((ndo, " AS #%s, origin %s",
+			as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
+			getname(ndo, tptr + 2)));
                 } else {
-		    printf(" AS #%s, origin %s",
-			as_printf(astostr, sizeof(astostr),
-			EXTRACT_32BITS(tptr)), getname(tptr + 4));
+		    ND_PRINT((ndo, " AS #%s, origin %s",
+			as_printf(ndo, astostr, sizeof(astostr),
+			EXTRACT_32BITS(tptr)), getname(ndo, tptr + 4)));
                 }
                 break;
 	case BGPTYPE_AGGREGATOR4:
 		if (len != 8) {
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 			break;
 		}
-		TCHECK2(tptr[0], 8);
-		printf(" AS #%s, origin %s",
-	   	    as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
-		    getname(tptr + 4));
+		ND_TCHECK2(tptr[0], 8);
+		ND_PRINT((ndo, " AS #%s, origin %s",
+	   	    as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
+		    getname(ndo, tptr + 4)));
 		break;
 	case BGPTYPE_COMMUNITIES:
 		if (len % 4) {
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 			break;
 		}
 		while (tlen>0) {
-			u_int32_t comm;
-			TCHECK2(tptr[0], 4);
+			uint32_t comm;
+			ND_TCHECK2(tptr[0], 4);
 			comm = EXTRACT_32BITS(tptr);
 			switch (comm) {
 			case BGP_COMMUNITY_NO_EXPORT:
-				printf(" NO_EXPORT");
+				ND_PRINT((ndo, " NO_EXPORT"));
 				break;
 			case BGP_COMMUNITY_NO_ADVERT:
-				printf(" NO_ADVERTISE");
+				ND_PRINT((ndo, " NO_ADVERTISE"));
 				break;
 			case BGP_COMMUNITY_NO_EXPORT_SUBCONFED:
-				printf(" NO_EXPORT_SUBCONFED");
+				ND_PRINT((ndo, " NO_EXPORT_SUBCONFED"));
 				break;
 			default:
-				printf("%u:%u%s",
+				ND_PRINT((ndo, "%u:%u%s",
                                        (comm >> 16) & 0xffff,
                                        comm & 0xffff,
-                                       (tlen>4) ? ", " : "");
+                                       (tlen>4) ? ", " : ""));
 				break;
 			}
                         tlen -=4;
@@ -1449,39 +1464,39 @@
 		break;
         case BGPTYPE_ORIGINATOR_ID:
 		if (len != 4) {
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 			break;
 		}
-		TCHECK2(tptr[0], 4);
-                printf("%s",getname(tptr));
+		ND_TCHECK2(tptr[0], 4);
+                ND_PRINT((ndo, "%s",getname(ndo, tptr)));
                 break;
         case BGPTYPE_CLUSTER_LIST:
 		if (len % 4) {
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 			break;
 		}
                 while (tlen>0) {
-			TCHECK2(tptr[0], 4);
-                        printf("%s%s",
-                               getname(tptr),
-                                (tlen>4) ? ", " : "");
+			ND_TCHECK2(tptr[0], 4);
+                        ND_PRINT((ndo, "%s%s",
+                               getname(ndo, tptr),
+                                (tlen>4) ? ", " : ""));
                         tlen -=4;
                         tptr +=4;
                 }
                 break;
 	case BGPTYPE_MP_REACH_NLRI:
-		TCHECK2(tptr[0], 3);
+		ND_TCHECK2(tptr[0], 3);
 		af = EXTRACT_16BITS(tptr);
 		safi = tptr[2];
-	
-                printf("\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
+
+                ND_PRINT((ndo, "\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
                        tok2strbuf(af_values, "Unknown AFI", af,
 				  tokbuf, sizeof(tokbuf)),
                        af,
                        (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
                        tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
 				  tokbuf, sizeof(tokbuf)),
-                       safi);
+                       safi));
 
                 switch(af<<8 | safi) {
                 case (AFNUM_INET<<8 | SAFNUM_UNICAST):
@@ -1493,7 +1508,7 @@
                 case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
                 case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
                 case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
-		case (AFNUM_INET<<8 | SAFNUM_MDT): 
+		case (AFNUM_INET<<8 | SAFNUM_MDT):
 #ifdef INET6
                 case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
                 case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
@@ -1515,27 +1530,27 @@
                 case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
                     break;
                 default:
-                    TCHECK2(tptr[0], tlen);
-                    printf("\n\t    no AFI %u / SAFI %u decoder",af,safi);
-                    if (vflag <= 1)
-                        print_unknown_data(tptr,"\n\t    ",tlen);
+                    ND_TCHECK2(tptr[0], tlen);
+                    ND_PRINT((ndo, "\n\t    no AFI %u / SAFI %u decoder", af, safi));
+                    if (ndo->ndo_vflag <= 1)
+                        print_unknown_data(ndo, tptr, "\n\t    ", tlen);
                     goto done;
                     break;
                 }
 
                 tptr +=3;
 
-		TCHECK(tptr[0]);
+		ND_TCHECK(tptr[0]);
 		nhlen = tptr[0];
                 tlen = nhlen;
                 tptr++;
 
 		if (tlen) {
                     int nnh = 0;
-                    printf("\n\t    nexthop: ");
+                    ND_PRINT((ndo, "\n\t    nexthop: "));
                     while (tlen > 0) {
                         if ( nnh++ > 0 ) {
-                            printf( ", " );
+                            ND_PRINT((ndo,  ", " ));
                         }
                         switch(af<<8 | safi) {
                         case (AFNUM_INET<<8 | SAFNUM_UNICAST):
@@ -1544,13 +1559,13 @@
                         case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
                         case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
                         case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
-                        case (AFNUM_INET<<8 | SAFNUM_MDT):  
+                        case (AFNUM_INET<<8 | SAFNUM_MDT):
 			    if (tlen < (int)sizeof(struct in_addr)) {
-                                printf("invalid len");
+                                ND_PRINT((ndo, "invalid len"));
                                 tlen = 0;
                             } else {
-                                TCHECK2(tptr[0], sizeof(struct in_addr));
-                                printf("%s",getname(tptr));
+                                ND_TCHECK2(tptr[0], sizeof(struct in_addr));
+                                ND_PRINT((ndo, "%s",getname(ndo, tptr)));
                                 tlen -= sizeof(struct in_addr);
                                 tptr += sizeof(struct in_addr);
                             }
@@ -1559,13 +1574,13 @@
                         case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
                         case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
                             if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) {
-                                printf("invalid len");
+                                ND_PRINT((ndo, "invalid len"));
                                 tlen = 0;
                             } else {
-                                TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
-                                printf("RD: %s, %s",
-                                       bgp_vpn_rd_print(tptr),
-                                       getname(tptr+BGP_VPN_RD_LEN));
+                                ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
+                                ND_PRINT((ndo, "RD: %s, %s",
+                                       bgp_vpn_rd_print(ndo, tptr),
+                                       getname(ndo, tptr+BGP_VPN_RD_LEN)));
                                 tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
                                 tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
                             }
@@ -1576,11 +1591,11 @@
                         case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
                         case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
                             if (tlen < (int)sizeof(struct in6_addr)) {
-                                printf("invalid len");
+                                ND_PRINT((ndo, "invalid len"));
                                 tlen = 0;
                             } else {
-                                TCHECK2(tptr[0], sizeof(struct in6_addr));
-                                printf("%s", getname6(tptr));
+                                ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
+                                ND_PRINT((ndo, "%s", getname6(ndo, tptr)));
                                 tlen -= sizeof(struct in6_addr);
                                 tptr += sizeof(struct in6_addr);
                             }
@@ -1589,13 +1604,13 @@
                         case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
                         case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
                             if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) {
-                                printf("invalid len");
+                                ND_PRINT((ndo, "invalid len"));
                                 tlen = 0;
                             } else {
-                                TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
-                                printf("RD: %s, %s",
-                                       bgp_vpn_rd_print(tptr),
-                                       getname6(tptr+BGP_VPN_RD_LEN));
+                                ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
+                                ND_PRINT((ndo, "RD: %s, %s",
+                                       bgp_vpn_rd_print(ndo, tptr),
+                                       getname6(ndo, tptr+BGP_VPN_RD_LEN)));
                                 tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                                 tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                             }
@@ -1606,11 +1621,11 @@
                         case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
                         case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
                             if (tlen < (int)sizeof(struct in_addr)) {
-                                printf("invalid len");
+                                ND_PRINT((ndo, "invalid len"));
                                 tlen = 0;
                             } else {
-                                TCHECK2(tptr[0], sizeof(struct in_addr));
-                                printf("%s", getname(tptr));
+                                ND_TCHECK2(tptr[0], sizeof(struct in_addr));
+                                ND_PRINT((ndo, "%s", getname(ndo, tptr)));
                                 tlen -= (sizeof(struct in_addr));
                                 tptr += (sizeof(struct in_addr));
                             }
@@ -1618,8 +1633,8 @@
                         case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
                         case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
                         case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
-                            TCHECK2(tptr[0], tlen);
-                            printf("%s",isonsap_string(tptr,tlen));
+                            ND_TCHECK2(tptr[0], tlen);
+                            ND_PRINT((ndo, "%s", isonsap_string(tptr, tlen)));
                             tptr += tlen;
                             tlen = 0;
                             break;
@@ -1628,30 +1643,30 @@
                         case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
                         case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
                             if (tlen < BGP_VPN_RD_LEN+1) {
-                                printf("invalid len");
+                                ND_PRINT((ndo, "invalid len"));
                                 tlen = 0;
                             } else {
-                                TCHECK2(tptr[0], tlen);
-                                printf("RD: %s, %s",
-                                       bgp_vpn_rd_print(tptr),
-                                       isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN));
+                                ND_TCHECK2(tptr[0], tlen);
+                                ND_PRINT((ndo, "RD: %s, %s",
+                                       bgp_vpn_rd_print(ndo, tptr),
+                                       isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
                                 /* rfc986 mapped IPv4 address ? */
                                 if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) ==  0x47000601)
-                                    printf(" = %s", getname(tptr+BGP_VPN_RD_LEN+4));
+                                    ND_PRINT((ndo, " = %s", getname(ndo, tptr+BGP_VPN_RD_LEN+4)));
 #ifdef INET6
                                 /* rfc1888 mapped IPv6 address ? */
                                 else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) ==  0x350000)
-                                    printf(" = %s", getname6(tptr+BGP_VPN_RD_LEN+3));
+                                    ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
 #endif
                                 tptr += tlen;
                                 tlen = 0;
                             }
                             break;
                         default:
-                            TCHECK2(tptr[0], tlen);
-                            printf("no AFI %u/SAFI %u decoder",af,safi);
-                            if (vflag <= 1)
-                                print_unknown_data(tptr,"\n\t    ",tlen);
+                            ND_TCHECK2(tptr[0], tlen);
+                            ND_PRINT((ndo, "no AFI %u/SAFI %u decoder", af, safi));
+                            if (ndo->ndo_vflag <= 1)
+                                print_unknown_data(ndo, tptr, "\n\t    ", tlen);
                             tptr += tlen;
                             tlen = 0;
                             goto done;
@@ -1659,22 +1674,22 @@
                         }
                     }
 		}
-                printf(", nh-length: %u", nhlen);
+		ND_PRINT((ndo, ", nh-length: %u", nhlen));
 		tptr += tlen;
 
-		TCHECK(tptr[0]);
+		ND_TCHECK(tptr[0]);
 		snpa = tptr[0];
 		tptr++;
 
 		if (snpa) {
-			printf("\n\t    %u SNPA", snpa);
+			ND_PRINT((ndo, "\n\t    %u SNPA", snpa));
 			for (/*nothing*/; snpa > 0; snpa--) {
-				TCHECK(tptr[0]);
-				printf("\n\t      %d bytes", tptr[0]);
+				ND_TCHECK(tptr[0]);
+				ND_PRINT((ndo, "\n\t      %d bytes", tptr[0]));
 				tptr += tptr[0] + 1;
 			}
 		} else {
-			printf(", no SNPA");
+			ND_PRINT((ndo, ", no SNPA"));
                 }
 
 		while (len - (tptr - pptr) > 0) {
@@ -1682,143 +1697,143 @@
                     case (AFNUM_INET<<8 | SAFNUM_UNICAST):
                     case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
                     case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
-                        advance = decode_prefix4(tptr, len, buf, sizeof(buf));
+                        advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
-                        advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf));
+                        advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_prefix4(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
-                        advance = decode_rt_routing_info(tptr, buf, sizeof(buf));
+                        advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */
                     case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN):
-                        advance = decode_multicast_vpn(tptr, buf, sizeof(buf));
+                        advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
 
 		    case (AFNUM_INET<<8 | SAFNUM_MDT):
-		      advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+		      advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf));
 		      if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
 		       break;
 #ifdef INET6
                     case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
-                        advance = decode_prefix6(tptr, len, buf, sizeof(buf));
+                        advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
-                        advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf));
+                        advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_prefix6(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
 #endif
                     case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal length)");
+                            ND_PRINT((ndo, "\n\t    (illegal length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);         
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
-                        advance = decode_clnp_prefix(tptr, buf, sizeof(buf));
+                        advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_clnp_prefix(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
-                        break;                                   
+                            ND_PRINT((ndo, "\n\t      %s", buf));
+                        break;
                     default:
-                        TCHECK2(*tptr,tlen);
-                        printf("\n\t    no AFI %u / SAFI %u decoder",af,safi);
-                        if (vflag <= 1)
-                            print_unknown_data(tptr,"\n\t    ",tlen);
+                        ND_TCHECK2(*tptr,tlen);
+                        ND_PRINT((ndo, "\n\t    no AFI %u / SAFI %u decoder", af, safi));
+                        if (ndo->ndo_vflag <= 1)
+                            print_unknown_data(ndo, tptr, "\n\t    ", tlen);
                         advance = 0;
                         tptr = pptr + len;
                         break;
@@ -1831,156 +1846,156 @@
 		break;
 
 	case BGPTYPE_MP_UNREACH_NLRI:
-		TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
+		ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
 		af = EXTRACT_16BITS(tptr);
 		safi = tptr[2];
 
-                printf("\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
+                ND_PRINT((ndo, "\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
                        tok2strbuf(af_values, "Unknown AFI", af,
 				  tokbuf, sizeof(tokbuf)),
                        af,
                        (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
                        tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
 				  tokbuf, sizeof(tokbuf)),
-                       safi);
+                       safi));
 
                 if (len == BGP_MP_NLRI_MINSIZE)
-                    printf("\n\t      End-of-Rib Marker (empty NLRI)");
+                    ND_PRINT((ndo, "\n\t      End-of-Rib Marker (empty NLRI)"));
 
 		tptr += 3;
-                
+
 		while (len - (tptr - pptr) > 0) {
                     switch (af<<8 | safi) {
                     case (AFNUM_INET<<8 | SAFNUM_UNICAST):
                     case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
                     case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
-                        advance = decode_prefix4(tptr, len, buf, sizeof(buf));
+                        advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
-                        advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf));
+                        advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_prefix4(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
 #ifdef INET6
                     case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
-                        advance = decode_prefix6(tptr, len, buf, sizeof(buf));
+                        advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
-                        advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf));
+                        advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else if (advance == -3)
                             break; /* bytes left, but not enough */
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_prefix6(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
 #endif
                     case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal length)");
+                            ND_PRINT((ndo, "\n\t    (illegal length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);         
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
-                        advance = decode_clnp_prefix(tptr, buf, sizeof(buf));
+                        advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
-                        advance = decode_labeled_vpn_clnp_prefix(tptr, buf, sizeof(buf));
+                        advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
-                        break;                                   
+                            ND_PRINT((ndo, "\n\t      %s", buf));
+                        break;
 		    case (AFNUM_INET<<8 | SAFNUM_MDT):
-		      advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+		      advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf));
 		      if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
 		       break;
                     case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */
                     case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN):
-                        advance = decode_multicast_vpn(tptr, buf, sizeof(buf));
+                        advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf));
                         if (advance == -1)
-                            printf("\n\t    (illegal prefix length)");
+                            ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
                         else if (advance == -2)
                             goto trunc;
                         else
-                            printf("\n\t      %s", buf);
+                            ND_PRINT((ndo, "\n\t      %s", buf));
                         break;
                     default:
-                        TCHECK2(*(tptr-3),tlen);
-                        printf("no AFI %u / SAFI %u decoder",af,safi);
-                        if (vflag <= 1)
-                            print_unknown_data(tptr-3,"\n\t    ",tlen);                                        
+                        ND_TCHECK2(*(tptr-3),tlen);
+                        ND_PRINT((ndo, "no AFI %u / SAFI %u decoder", af, safi));
+                        if (ndo->ndo_vflag <= 1)
+                            print_unknown_data(ndo, tptr-3, "\n\t    ", tlen);
                         advance = 0;
                         tptr = pptr + len;
                         break;
@@ -1992,50 +2007,50 @@
 		break;
         case BGPTYPE_EXTD_COMMUNITIES:
 		if (len % 8) {
-			printf("invalid len");
+			ND_PRINT((ndo, "invalid len"));
 			break;
 		}
                 while (tlen>0) {
-                    u_int16_t extd_comm;
+                    uint16_t extd_comm;
 
-                    TCHECK2(tptr[0], 2);
+                    ND_TCHECK2(tptr[0], 2);
                     extd_comm=EXTRACT_16BITS(tptr);
 
-		    printf("\n\t    %s (0x%04x), Flags [%s]",
+		    ND_PRINT((ndo, "\n\t    %s (0x%04x), Flags [%s]",
 			   tok2strbuf(bgp_extd_comm_subtype_values,
 				      "unknown extd community typecode",
 				      extd_comm, tokbuf, sizeof(tokbuf)),
 			   extd_comm,
-			   bittok2str(bgp_extd_comm_flag_values, "none", extd_comm));
+			   bittok2str(bgp_extd_comm_flag_values, "none", extd_comm)));
 
-                    TCHECK2(*(tptr+2), 6);
+                    ND_TCHECK2(*(tptr+2), 6);
                     switch(extd_comm) {
                     case BGP_EXT_COM_RT_0:
                     case BGP_EXT_COM_RO_0:
                     case BGP_EXT_COM_L2VPN_RT_0:
-                        printf(": %u:%u (= %s)",
+                        ND_PRINT((ndo, ": %u:%u (= %s)",
                                EXTRACT_16BITS(tptr+2),
                                EXTRACT_32BITS(tptr+4),
-                               getname(tptr+4));
+                               getname(ndo, tptr+4)));
                         break;
                     case BGP_EXT_COM_RT_1:
                     case BGP_EXT_COM_RO_1:
                     case BGP_EXT_COM_L2VPN_RT_1:
                     case BGP_EXT_COM_VRF_RT_IMP:
-                        printf(": %s:%u",
-                               getname(tptr+2),
-                               EXTRACT_16BITS(tptr+6));
+                        ND_PRINT((ndo, ": %s:%u",
+                               getname(ndo, tptr+2),
+                               EXTRACT_16BITS(tptr+6)));
                         break;
                     case BGP_EXT_COM_RT_2:
                     case BGP_EXT_COM_RO_2:
-			printf(": %s:%u",
-			    as_printf(astostr, sizeof(astostr),
-			    EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6));
+			ND_PRINT((ndo, ": %s:%u",
+			    as_printf(ndo, astostr, sizeof(astostr),
+			    EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6)));
 			break;
                     case BGP_EXT_COM_LINKBAND:
 		        bw.i = EXTRACT_32BITS(tptr+2);
-                        printf(": bandwidth: %.3f Mbps",
-                               bw.f*8/1000000);
+                        ND_PRINT((ndo, ": bandwidth: %.3f Mbps",
+                               bw.f*8/1000000));
                         break;
                     case BGP_EXT_COM_VPN_ORIGIN:
                     case BGP_EXT_COM_VPN_ORIGIN2:
@@ -2043,34 +2058,34 @@
                     case BGP_EXT_COM_VPN_ORIGIN4:
                     case BGP_EXT_COM_OSPF_RID:
                     case BGP_EXT_COM_OSPF_RID2:
-                        printf("%s", getname(tptr+2));
+                        ND_PRINT((ndo, "%s", getname(ndo, tptr+2)));
                         break;
                     case BGP_EXT_COM_OSPF_RTYPE:
-                    case BGP_EXT_COM_OSPF_RTYPE2: 
-                        printf(": area:%s, router-type:%s, metric-type:%s%s",
-                               getname(tptr+2),
+                    case BGP_EXT_COM_OSPF_RTYPE2:
+                        ND_PRINT((ndo, ": area:%s, router-type:%s, metric-type:%s%s",
+                               getname(ndo, tptr+2),
                                tok2strbuf(bgp_extd_comm_ospf_rtype_values,
 					  "unknown (0x%02x)",
 					  *(tptr+6),
 					  tokbuf, sizeof(tokbuf)),
                                (*(tptr+7) &  BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "",
-                               ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : "");
+                               ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : ""));
                         break;
                     case BGP_EXT_COM_L2INFO:
-                        printf(": %s Control Flags [0x%02x]:MTU %u",
+                        ND_PRINT((ndo, ": %s Control Flags [0x%02x]:MTU %u",
                                tok2strbuf(l2vpn_encaps_values,
 					  "unknown encaps",
 					  *(tptr+2),
 					  tokbuf, sizeof(tokbuf)),
                                        *(tptr+3),
-                               EXTRACT_16BITS(tptr+4));
+                               EXTRACT_16BITS(tptr+4)));
                         break;
                     case BGP_EXT_COM_SOURCE_AS:
-                        printf(": AS %u", EXTRACT_16BITS(tptr+2));
+                        ND_PRINT((ndo, ": AS %u", EXTRACT_16BITS(tptr+2)));
                         break;
                     default:
-                        TCHECK2(*tptr,8);
-                        print_unknown_data(tptr,"\n\t      ",8);
+                        ND_TCHECK2(*tptr,8);
+                        print_unknown_data(ndo, tptr, "\n\t      ", 8);
                         break;
                     }
                     tlen -=8;
@@ -2080,18 +2095,18 @@
 
         case BGPTYPE_PMSI_TUNNEL:
         {
-                u_int8_t tunnel_type, flags;
-            
+                uint8_t tunnel_type, flags;
+
                 tunnel_type = *(tptr+1);
                 flags = *tptr;
                 tlen = len;
 
-                TCHECK2(tptr[0], 5);
-                printf("\n\t    Tunnel-type %s (%u), Flags [%s], MPLS Label %u",
+                ND_TCHECK2(tptr[0], 5);
+                ND_PRINT((ndo, "\n\t    Tunnel-type %s (%u), Flags [%s], MPLS Label %u",
                        tok2str(bgp_pmsi_tunnel_values, "Unknown", tunnel_type),
                        tunnel_type,
                        bittok2str(bgp_pmsi_flag_values, "none", flags),
-                       EXTRACT_24BITS(tptr+2)>>4);
+                       EXTRACT_24BITS(tptr+2)>>4));
 
                 tptr +=5;
                 tlen -= 5;
@@ -2099,56 +2114,56 @@
                 switch (tunnel_type) {
                 case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */
                 case BGP_PMSI_TUNNEL_PIM_BIDIR:
-                    TCHECK2(tptr[0], 8);
-                    printf("\n\t      Sender %s, P-Group %s",
-                           ipaddr_string(tptr),
-                           ipaddr_string(tptr+4));
+                    ND_TCHECK2(tptr[0], 8);
+                    ND_PRINT((ndo, "\n\t      Sender %s, P-Group %s",
+                           ipaddr_string(ndo, tptr),
+                           ipaddr_string(ndo, tptr+4)));
                     break;
 
                 case BGP_PMSI_TUNNEL_PIM_SSM:
-                    TCHECK2(tptr[0], 8);
-                    printf("\n\t      Root-Node %s, P-Group %s",
-                           ipaddr_string(tptr),
-                           ipaddr_string(tptr+4));
+                    ND_TCHECK2(tptr[0], 8);
+                    ND_PRINT((ndo, "\n\t      Root-Node %s, P-Group %s",
+                           ipaddr_string(ndo, tptr),
+                           ipaddr_string(ndo, tptr+4)));
                     break;
                 case BGP_PMSI_TUNNEL_INGRESS:
-                    TCHECK2(tptr[0], 4);
-                    printf("\n\t      Tunnel-Endpoint %s",
-                           ipaddr_string(tptr));
+                    ND_TCHECK2(tptr[0], 4);
+                    ND_PRINT((ndo, "\n\t      Tunnel-Endpoint %s",
+                           ipaddr_string(ndo, tptr)));
                     break;
                 case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */
                 case BGP_PMSI_TUNNEL_LDP_MP2MP:
-                    TCHECK2(tptr[0], 8);
-                    printf("\n\t      Root-Node %s, LSP-ID 0x%08x",
-                           ipaddr_string(tptr),
-                           EXTRACT_32BITS(tptr+4));
+                    ND_TCHECK2(tptr[0], 8);
+                    ND_PRINT((ndo, "\n\t      Root-Node %s, LSP-ID 0x%08x",
+                           ipaddr_string(ndo, tptr),
+                           EXTRACT_32BITS(tptr+4)));
                     break;
                 case BGP_PMSI_TUNNEL_RSVP_P2MP:
-                    TCHECK2(tptr[0], 8);
-                    printf("\n\t      Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
-                           ipaddr_string(tptr),
-                           EXTRACT_32BITS(tptr+4));
+                    ND_TCHECK2(tptr[0], 8);
+                    ND_PRINT((ndo, "\n\t      Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
+                           ipaddr_string(ndo, tptr),
+                           EXTRACT_32BITS(tptr+4)));
                     break;
                 default:
-                    if (vflag <= 1) {
-                        print_unknown_data(tptr,"\n\t      ",tlen);
+                    if (ndo->ndo_vflag <= 1) {
+                        print_unknown_data(ndo, tptr, "\n\t      ", tlen);
                     }
                 }
                 break;
         }
         case BGPTYPE_ATTR_SET:
-                TCHECK2(tptr[0], 4);
+                ND_TCHECK2(tptr[0], 4);
                 if (len < 4)
                 	goto trunc;
-		printf("\n\t    Origin AS: %s",
-		    as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)));
+		ND_PRINT((ndo, "\n\t    Origin AS: %s",
+		    as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr))));
 		tptr+=4;
                 len -=4;
 
                 while (len) {
                     u_int aflags, atype, alenlen, alen;
-                    
-                    TCHECK2(tptr[0], 2);
+
+                    ND_TCHECK2(tptr[0], 2);
                     if (len < 2)
                         goto trunc;
                     aflags = *tptr;
@@ -2156,49 +2171,49 @@
                     tptr += 2;
                     len -= 2;
                     alenlen = bgp_attr_lenlen(aflags, tptr);
-                    TCHECK2(tptr[0], alenlen);
+                    ND_TCHECK2(tptr[0], alenlen);
                     if (len < alenlen)
                         goto trunc;
                     alen = bgp_attr_len(aflags, tptr);
                     tptr += alenlen;
                     len -= alenlen;
-                    
-                    printf("\n\t      %s (%u), length: %u",
+
+                    ND_PRINT((ndo, "\n\t      %s (%u), length: %u",
                            tok2strbuf(bgp_attr_values,
                                       "Unknown Attribute", atype,
                                       tokbuf, sizeof(tokbuf)),
                            atype,
-                           alen);
-                    
+                           alen));
+
                     if (aflags) {
-                        printf(", Flags [%s%s%s%s",
+                        ND_PRINT((ndo, ", Flags [%s%s%s%s",
                                aflags & 0x80 ? "O" : "",
                                aflags & 0x40 ? "T" : "",
                                aflags & 0x20 ? "P" : "",
-                               aflags & 0x10 ? "E" : "");
+                               aflags & 0x10 ? "E" : ""));
                         if (aflags & 0xf)
-                            printf("+%x", aflags & 0xf);
-                        printf("]: ");
+                            ND_PRINT((ndo, "+%x", aflags & 0xf));
+                        ND_PRINT((ndo, "]: "));
                     }
                     /* FIXME check for recursion */
-                    if (!bgp_attr_print(atype, tptr, alen))
+                    if (!bgp_attr_print(ndo, atype, tptr, alen))
                         return 0;
                     tptr += alen;
                     len -= alen;
 		}
                 break;
-           
+
 
 	default:
-	    TCHECK2(*pptr,len);
-            printf("\n\t    no Attribute %u decoder",atype); /* we have no decoder for the attribute */
-            if (vflag <= 1)
-                print_unknown_data(pptr,"\n\t    ",len);
+	    ND_TCHECK2(*pptr,len);
+            ND_PRINT((ndo, "\n\t    no Attribute %u decoder", atype)); /* we have no decoder for the attribute */
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo, pptr, "\n\t    ", len);
             break;
 	}
-        if (vflag > 1 && len) { /* omit zero length attributes*/
-            TCHECK2(*pptr,len);
-            print_unknown_data(pptr,"\n\t    ",len);
+        if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/
+            ND_TCHECK2(*pptr,len);
+            print_unknown_data(ndo, pptr, "\n\t    ", len);
         }
         return 1;
 
@@ -2207,7 +2222,8 @@
 }
 
 static void
-bgp_capabilities_print(const u_char *opt, int caps_len)
+bgp_capabilities_print(netdissect_options *ndo,
+                       const u_char *opt, int caps_len)
 {
 	char tokbuf[TOKBUFSIZE];
 	char tokbuf2[TOKBUFSIZE];
@@ -2215,19 +2231,19 @@
         int i = 0;
 
         while (i < caps_len) {
-                TCHECK2(opt[i], BGP_CAP_HEADER_SIZE);
+                ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE);
                 cap_type=opt[i];
                 cap_len=opt[i+1];
                 tcap_len=cap_len;
-                printf("\n\t      %s (%u), length: %u",
+                ND_PRINT((ndo, "\n\t      %s (%u), length: %u",
                        tok2strbuf(bgp_capcode_values, "Unknown",
                                   cap_type, tokbuf, sizeof(tokbuf)),
                        cap_type,
-                       cap_len);
-                TCHECK2(opt[i+2], cap_len);
+                       cap_len));
+                ND_TCHECK2(opt[i+2], cap_len);
                 switch (cap_type) {
                 case BGP_CAPCODE_MP:
-                    printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
+                    ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)",
                            tok2strbuf(af_values, "Unknown",
                                       EXTRACT_16BITS(opt+i+2),
                                       tokbuf, sizeof(tokbuf)),
@@ -2235,16 +2251,16 @@
                            tok2strbuf(bgp_safi_values, "Unknown",
                                       opt[i+5],
                                       tokbuf, sizeof(tokbuf)),
-                           opt[i+5]);
+                           opt[i+5]));
                     break;
                 case BGP_CAPCODE_RESTART:
-                    printf("\n\t\tRestart Flags: [%s], Restart Time %us",
+                    ND_PRINT((ndo, "\n\t\tRestart Flags: [%s], Restart Time %us",
                            ((opt[i+2])&0x80) ? "R" : "none",
-                           EXTRACT_16BITS(opt+i+2)&0xfff);
+                           EXTRACT_16BITS(opt+i+2)&0xfff));
                     tcap_len-=2;
                     cap_offset=4;
                     while(tcap_len>=4) {
-                        printf("\n\t\t  AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
+                        ND_PRINT((ndo, "\n\t\t  AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
                                tok2strbuf(af_values,"Unknown",
                                           EXTRACT_16BITS(opt+i+cap_offset),
                                           tokbuf, sizeof(tokbuf)),
@@ -2253,7 +2269,7 @@
                                           opt[i+cap_offset+2],
                                           tokbuf2, sizeof(tokbuf2)),
                                opt[i+cap_offset+2],
-                               ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" );
+                               ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" ));
                         tcap_len-=4;
                         cap_offset+=4;
                     }
@@ -2267,31 +2283,32 @@
                      * Extract the 4 byte AS number encoded.
                      */
                     if (cap_len == 4) {
-                        printf("\n\t\t 4 Byte AS %s",
-                            as_printf(astostr, sizeof(astostr),
-                            EXTRACT_32BITS(opt + i + 2)));
+                        ND_PRINT((ndo, "\n\t\t 4 Byte AS %s",
+                            as_printf(ndo, astostr, sizeof(astostr),
+                            EXTRACT_32BITS(opt + i + 2))));
                     }
                     break;
                 default:
-                    printf("\n\t\tno decoder for Capability %u",
-                           cap_type);
-                    if (vflag <= 1)
-                        print_unknown_data(&opt[i+2],"\n\t\t",cap_len);
+                    ND_PRINT((ndo, "\n\t\tno decoder for Capability %u",
+                           cap_type));
+                    if (ndo->ndo_vflag <= 1)
+                        print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len);
                     break;
                 }
-                if (vflag > 1 && cap_len > 0) {
-                    print_unknown_data(&opt[i+2],"\n\t\t",cap_len);
+                if (ndo->ndo_vflag > 1 && cap_len > 0) {
+                    print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len);
                 }
                 i += BGP_CAP_HEADER_SIZE + cap_len;
         }
         return;
 
 trunc:
-	printf("[|BGP]");
+	ND_PRINT((ndo, "[|BGP]"));
 }
 
 static void
-bgp_open_print(const u_char *dat, int length)
+bgp_open_print(netdissect_options *ndo,
+               const u_char *dat, int length)
 {
 	struct bgp_open bgpo;
 	struct bgp_opt bgpopt;
@@ -2299,18 +2316,18 @@
 	int i;
 	char tokbuf[TOKBUFSIZE];
 
-	TCHECK2(dat[0], BGP_OPEN_SIZE);
+	ND_TCHECK2(dat[0], BGP_OPEN_SIZE);
 	memcpy(&bgpo, dat, BGP_OPEN_SIZE);
 
-	printf("\n\t  Version %d, ", bgpo.bgpo_version);
-	printf("my AS %s, ",
-	    as_printf(astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas)));
-	printf("Holdtime %us, ", ntohs(bgpo.bgpo_holdtime));
-	printf("ID %s", getname((u_char *)&bgpo.bgpo_id));
-	printf("\n\t  Optional parameters, length: %u", bgpo.bgpo_optlen);
+	ND_PRINT((ndo, "\n\t  Version %d, ", bgpo.bgpo_version));
+	ND_PRINT((ndo, "my AS %s, ",
+	    as_printf(ndo, astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas))));
+	ND_PRINT((ndo, "Holdtime %us, ", ntohs(bgpo.bgpo_holdtime)));
+	ND_PRINT((ndo, "ID %s", getname(ndo, (u_char *)&bgpo.bgpo_id)));
+	ND_PRINT((ndo, "\n\t  Optional parameters, length: %u", bgpo.bgpo_optlen));
 
         /* some little sanity checking */
-        if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE) 
+        if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE)
             return;
 
 	/* ugly! */
@@ -2319,43 +2336,44 @@
 
 	i = 0;
 	while (i < bgpo.bgpo_optlen) {
-		TCHECK2(opt[i], BGP_OPT_SIZE);
+		ND_TCHECK2(opt[i], BGP_OPT_SIZE);
 		memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE);
 		if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
-			printf("\n\t     Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len);
+			ND_PRINT((ndo, "\n\t     Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len));
 			break;
 		}
 
-		printf("\n\t    Option %s (%u), length: %u",
+		ND_PRINT((ndo, "\n\t    Option %s (%u), length: %u",
 		       tok2strbuf(bgp_opt_values,"Unknown",
 				  bgpopt.bgpopt_type,
 				  tokbuf, sizeof(tokbuf)),
 		       bgpopt.bgpopt_type,
-		       bgpopt.bgpopt_len);
+		       bgpopt.bgpopt_len));
 
 		/* now let's decode the options we know*/
 		switch(bgpopt.bgpopt_type) {
 
 		case BGP_OPT_CAP:
-			bgp_capabilities_print(&opt[i+BGP_OPT_SIZE],
+			bgp_capabilities_print(ndo, &opt[i+BGP_OPT_SIZE],
 			    bgpopt.bgpopt_len);
 			break;
 
 		case BGP_OPT_AUTH:
 		default:
-		       printf("\n\t      no decoder for option %u",
-			   bgpopt.bgpopt_type);
+		       ND_PRINT((ndo, "\n\t      no decoder for option %u",
+			   bgpopt.bgpopt_type));
 		       break;
 		}
 		i += BGP_OPT_SIZE + bgpopt.bgpopt_len;
 	}
 	return;
 trunc:
-	printf("[|BGP]");
+	ND_PRINT((ndo, "[|BGP]"));
 }
 
 static void
-bgp_update_print(const u_char *dat, int length)
+bgp_update_print(netdissect_options *ndo,
+                 const u_char *dat, int length)
 {
 	struct bgp bgp;
 	const u_char *p;
@@ -2368,7 +2386,7 @@
 	int wpfx;
 #endif
 
-	TCHECK2(dat[0], BGP_SIZE);
+	ND_TCHECK2(dat[0], BGP_SIZE);
 	if (length < BGP_SIZE)
 		goto trunc;
 	memcpy(&bgp, dat, BGP_SIZE);
@@ -2376,7 +2394,7 @@
 	length -= BGP_SIZE;
 
 	/* Unfeasible routes */
-	TCHECK2(p[0], 2);
+	ND_TCHECK2(p[0], 2);
 	if (length < 2)
 		goto trunc;
 	withdrawn_routes_len = EXTRACT_16BITS(p);
@@ -2388,11 +2406,11 @@
 		 * it's not possible to tell if this a v4 or v6 route,
 		 * so only try to decode it if we're not v6 enabled.
 	         */
-		TCHECK2(p[0], withdrawn_routes_len);
+		ND_TCHECK2(p[0], withdrawn_routes_len);
 		if (length < withdrawn_routes_len)
 			goto trunc;
 #ifdef INET6
-		printf("\n\t  Withdrawn routes: %d bytes", withdrawn_routes_len);
+		ND_PRINT((ndo, "\n\t  Withdrawn routes: %d bytes", withdrawn_routes_len));
 		p += withdrawn_routes_len;
 		length -= withdrawn_routes_len;
 #else
@@ -2402,19 +2420,19 @@
 		withdrawn_routes_len -= 2;
 
 
-		printf("\n\t  Withdrawn routes:");
+		ND_PRINT((ndo, "\n\t  Withdrawn routes:"));
 
 		while(withdrawn_routes_len > 0) {
-			wpfx = decode_prefix4(p, withdrawn_routes_len, buf, sizeof(buf));
+			wpfx = decode_prefix4(ndo, p, withdrawn_routes_len, buf, sizeof(buf));
 			if (wpfx == -1) {
-				printf("\n\t    (illegal prefix length)");
+				ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
 				break;
 			} else if (wpfx == -2)
 				goto trunc;
 			else if (wpfx == -3)
 				goto trunc; /* bytes left, but not enough */
 			else {
-				printf("\n\t    %s", buf);
+				ND_PRINT((ndo, "\n\t    %s", buf));
 				p += wpfx;
 				length -= wpfx;
 				withdrawn_routes_len -= wpfx;
@@ -2423,7 +2441,7 @@
 #endif
 	}
 
-	TCHECK2(p[0], 2);
+	ND_TCHECK2(p[0], 2);
 	if (length < 2)
 		goto trunc;
 	len = EXTRACT_16BITS(p);
@@ -2432,7 +2450,7 @@
 
         if (withdrawn_routes_len == 0 && len == 0 && length == 0) {
             /* No withdrawn routes, no path attributes, no NLRI */
-            printf("\n\t  End-of-Rib Marker (empty NLRI)");
+            ND_PRINT((ndo, "\n\t  End-of-Rib Marker (empty NLRI)"));
             return;
         }
 
@@ -2441,7 +2459,7 @@
 		while (len) {
 			int aflags, atype, alenlen, alen;
 
-			TCHECK2(p[0], 2);
+			ND_TCHECK2(p[0], 2);
 			if (len < 2)
 			    goto trunc;
 			if (length < 2)
@@ -2452,7 +2470,7 @@
 			len -= 2;
 			length -= 2;
 			alenlen = bgp_attr_lenlen(aflags, p);
-			TCHECK2(p[0], alenlen);
+			ND_TCHECK2(p[0], alenlen);
 			if (len < alenlen)
 			    goto trunc;
 			if (length < alenlen)
@@ -2462,34 +2480,34 @@
 			len -= alenlen;
 			length -= alenlen;
 
-			printf("\n\t  %s (%u), length: %u",
+			ND_PRINT((ndo, "\n\t  %s (%u), length: %u",
                               tok2strbuf(bgp_attr_values, "Unknown Attribute",
 					 atype,
 					 tokbuf, sizeof(tokbuf)),
                               atype,
-                              alen);
+                              alen));
 
 			if (aflags) {
-				printf(", Flags [%s%s%s%s",
+				ND_PRINT((ndo, ", Flags [%s%s%s%s",
 					aflags & 0x80 ? "O" : "",
 					aflags & 0x40 ? "T" : "",
 					aflags & 0x20 ? "P" : "",
-					aflags & 0x10 ? "E" : "");
+					aflags & 0x10 ? "E" : ""));
 				if (aflags & 0xf)
-					printf("+%x", aflags & 0xf);
-				printf("]: ");
+					ND_PRINT((ndo, "+%x", aflags & 0xf));
+				ND_PRINT((ndo, "]: "));
 			}
 			if (len < alen)
 				goto trunc;
 			if (length < alen)
 				goto trunc;
-			if (!bgp_attr_print(atype, p, alen))
+			if (!bgp_attr_print(ndo, atype, p, alen))
 				goto trunc;
 			p += alen;
 			len -= alen;
 			length -= alen;
 		}
-	} 
+	}
 
 	if (length) {
 		/*
@@ -2500,19 +2518,19 @@
 		 *
 		 * http://tools.ietf.org/html/draft-ietf-idr-add-paths-06
 		 */
-		printf("\n\t  Updated routes:");
+		ND_PRINT((ndo, "\n\t  Updated routes:"));
 		while (length) {
 			char buf[MAXHOSTNAMELEN + 100];
-			i = decode_prefix4(p, length, buf, sizeof(buf));
+			i = decode_prefix4(ndo, p, length, buf, sizeof(buf));
 			if (i == -1) {
-				printf("\n\t    (illegal prefix length)");
+				ND_PRINT((ndo, "\n\t    (illegal prefix length)"));
 				break;
 			} else if (i == -2)
 				goto trunc;
 			else if (i == -3)
 				goto trunc; /* bytes left, but not enough */
 			else {
-				printf("\n\t    %s", buf);
+				ND_PRINT((ndo, "\n\t    %s", buf));
 				p += i;
 				length -= i;
 			}
@@ -2520,74 +2538,75 @@
 	}
 	return;
 trunc:
-	printf("[|BGP]");
+	ND_PRINT((ndo, "[|BGP]"));
 }
 
 static void
-bgp_notification_print(const u_char *dat, int length)
+bgp_notification_print(netdissect_options *ndo,
+                       const u_char *dat, int length)
 {
 	struct bgp_notification bgpn;
 	const u_char *tptr;
 	char tokbuf[TOKBUFSIZE];
 	char tokbuf2[TOKBUFSIZE];
 
-	TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
+	ND_TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
 	memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
 
         /* some little sanity checking */
         if (length<BGP_NOTIFICATION_SIZE)
             return;
 
-	printf(", %s (%u)",
+	ND_PRINT((ndo, ", %s (%u)",
 	       tok2strbuf(bgp_notify_major_values, "Unknown Error",
 			  bgpn.bgpn_major, tokbuf, sizeof(tokbuf)),
-	       bgpn.bgpn_major);
+	       bgpn.bgpn_major));
 
         switch (bgpn.bgpn_major) {
 
         case BGP_NOTIFY_MAJOR_MSG:
-            printf(", subcode %s (%u)",
+            ND_PRINT((ndo, ", subcode %s (%u)",
 		   tok2strbuf(bgp_notify_minor_msg_values, "Unknown",
 			      bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
-		   bgpn.bgpn_minor);
+		   bgpn.bgpn_minor));
             break;
         case BGP_NOTIFY_MAJOR_OPEN:
-            printf(", subcode %s (%u)",
+            ND_PRINT((ndo, ", subcode %s (%u)",
 		   tok2strbuf(bgp_notify_minor_open_values, "Unknown",
 			      bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
-		   bgpn.bgpn_minor);
+		   bgpn.bgpn_minor));
             break;
         case BGP_NOTIFY_MAJOR_UPDATE:
-            printf(", subcode %s (%u)",
+            ND_PRINT((ndo, ", subcode %s (%u)",
 		   tok2strbuf(bgp_notify_minor_update_values, "Unknown",
 			      bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
-		   bgpn.bgpn_minor);
+		   bgpn.bgpn_minor));
             break;
         case BGP_NOTIFY_MAJOR_CAP:
-            printf(" subcode %s (%u)",
+            ND_PRINT((ndo, " subcode %s (%u)",
 		   tok2strbuf(bgp_notify_minor_cap_values, "Unknown",
 			      bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
-		   bgpn.bgpn_minor);
+		   bgpn.bgpn_minor));
         case BGP_NOTIFY_MAJOR_CEASE:
-            printf(", subcode %s (%u)",
+            ND_PRINT((ndo, ", subcode %s (%u)",
 		   tok2strbuf(bgp_notify_minor_cease_values, "Unknown",
 			      bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
-		   bgpn.bgpn_minor);
+		   bgpn.bgpn_minor));
 
 	    /* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes
              * for the maxprefix subtype, which may contain AFI, SAFI and MAXPREFIXES
              */
 	    if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7) {
 		tptr = dat + BGP_NOTIFICATION_SIZE;
-		TCHECK2(*tptr, 7);
-		printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
+		ND_TCHECK2(*tptr, 7);
+		ND_PRINT((ndo, ", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
 		       tok2strbuf(af_values, "Unknown",
 				  EXTRACT_16BITS(tptr), tokbuf, sizeof(tokbuf)),
 		       EXTRACT_16BITS(tptr),
 		       tok2strbuf(bgp_safi_values, "Unknown", *(tptr+2),
 				  tokbuf2, sizeof(tokbuf)),
 		       *(tptr+2),
-		       EXTRACT_32BITS(tptr+3));
+		       EXTRACT_32BITS(tptr+3)));
 	    }
             break;
         default:
@@ -2596,17 +2615,18 @@
 
 	return;
 trunc:
-	printf("[|BGP]");
+	ND_PRINT((ndo, "[|BGP]"));
 }
 
 static void
-bgp_route_refresh_print(const u_char *pptr, int len) {
-
+bgp_route_refresh_print(netdissect_options *ndo,
+                        const u_char *pptr, int len)
+{
         const struct bgp_route_refresh *bgp_route_refresh_header;
 	char tokbuf[TOKBUFSIZE];
 	char tokbuf2[TOKBUFSIZE];
 
-	TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
+	ND_TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
 
         /* some little sanity checking */
         if (len<BGP_ROUTE_REFRESH_SIZE)
@@ -2614,72 +2634,74 @@
 
         bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr;
 
-        printf("\n\t  AFI %s (%u), SAFI %s (%u)",
+        ND_PRINT((ndo, "\n\t  AFI %s (%u), SAFI %s (%u)",
                tok2strbuf(af_values,"Unknown",
 			  /* this stinks but the compiler pads the structure
 			   * weird */
 			  EXTRACT_16BITS(&bgp_route_refresh_header->afi),
-			  tokbuf, sizeof(tokbuf)), 
+			  tokbuf, sizeof(tokbuf)),
                EXTRACT_16BITS(&bgp_route_refresh_header->afi),
                tok2strbuf(bgp_safi_values,"Unknown",
 			  bgp_route_refresh_header->safi,
 			  tokbuf2, sizeof(tokbuf2)),
-               bgp_route_refresh_header->safi);
+               bgp_route_refresh_header->safi));
 
-        if (vflag > 1) {
-            TCHECK2(*pptr, len);
-            print_unknown_data(pptr,"\n\t  ", len);
+        if (ndo->ndo_vflag > 1) {
+            ND_TCHECK2(*pptr, len);
+            print_unknown_data(ndo, pptr, "\n\t  ", len);
         }
-        
+
         return;
 trunc:
-	printf("[|BGP]");
+	ND_PRINT((ndo, "[|BGP]"));
 }
 
 static int
-bgp_header_print(const u_char *dat, int length)
+bgp_header_print(netdissect_options *ndo,
+                 const u_char *dat, int length)
 {
 	struct bgp bgp;
 	char tokbuf[TOKBUFSIZE];
 
-	TCHECK2(dat[0], BGP_SIZE);
+	ND_TCHECK2(dat[0], BGP_SIZE);
 	memcpy(&bgp, dat, BGP_SIZE);
-	printf("\n\t%s Message (%u), length: %u",
+	ND_PRINT((ndo, "\n\t%s Message (%u), length: %u",
                tok2strbuf(bgp_msg_values, "Unknown", bgp.bgp_type,
 			  tokbuf, sizeof(tokbuf)),
                bgp.bgp_type,
-               length);
+               length));
 
 	switch (bgp.bgp_type) {
 	case BGP_OPEN:
-		bgp_open_print(dat, length);
+		bgp_open_print(ndo, dat, length);
 		break;
 	case BGP_UPDATE:
-		bgp_update_print(dat, length);
+		bgp_update_print(ndo, dat, length);
 		break;
 	case BGP_NOTIFICATION:
-		bgp_notification_print(dat, length);
+		bgp_notification_print(ndo, dat, length);
 		break;
         case BGP_KEEPALIVE:
                 break;
         case BGP_ROUTE_REFRESH:
-                bgp_route_refresh_print(dat, length);
+                bgp_route_refresh_print(ndo, dat, length);
                 break;
         default:
                 /* we have no decoder for the BGP message */
-                TCHECK2(*dat, length);
-                printf("\n\t  no Message %u decoder",bgp.bgp_type);
-                print_unknown_data(dat,"\n\t  ",length);
+                ND_TCHECK2(*dat, length);
+                ND_PRINT((ndo, "\n\t  no Message %u decoder", bgp.bgp_type));
+                print_unknown_data(ndo, dat, "\n\t  ", length);
                 break;
 	}
 	return 1;
 trunc:
-	printf("[|BGP]");
+	ND_PRINT((ndo, "[|BGP]"));
 	return 0;
 }
 
 void
-bgp_print(const u_char *dat, int length)
+bgp_print(netdissect_options *ndo,
+          const u_char *dat, int length)
 {
 	const u_char *p;
 	const u_char *ep;
@@ -2689,29 +2711,29 @@
 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 	};
 	struct bgp bgp;
-	u_int16_t hlen;
+	uint16_t hlen;
 	char tokbuf[TOKBUFSIZE];
 
 	ep = dat + length;
-	if (snapend < dat + length)
-		ep = snapend;
+	if (ndo->ndo_snapend < dat + length)
+		ep = ndo->ndo_snapend;
 
-	printf(": BGP, length: %u",length);
+	ND_PRINT((ndo, ": BGP"));
 
-        if (vflag < 1) /* lets be less chatty */
+        if (ndo->ndo_vflag < 1) /* lets be less chatty */
                 return;
 
 	p = dat;
 	start = p;
 	while (p < ep) {
-		if (!TTEST2(p[0], 1))
+		if (!ND_TTEST2(p[0], 1))
 			break;
 		if (p[0] != 0xff) {
 			p++;
 			continue;
 		}
 
-		if (!TTEST2(p[0], sizeof(marker)))
+		if (!ND_TTEST2(p[0], sizeof(marker)))
 			break;
 		if (memcmp(p, marker, sizeof(marker)) != 0) {
 			p++;
@@ -2719,30 +2741,30 @@
 		}
 
 		/* found BGP header */
-		TCHECK2(p[0], BGP_SIZE);	/*XXX*/
+		ND_TCHECK2(p[0], BGP_SIZE);	/*XXX*/
 		memcpy(&bgp, p, BGP_SIZE);
 
 		if (start != p)
-			printf(" [|BGP]");
+			ND_PRINT((ndo, " [|BGP]"));
 
 		hlen = ntohs(bgp.bgp_len);
 		if (hlen < BGP_SIZE) {
-			printf("\n[|BGP Bogus header length %u < %u]", hlen,
-			    BGP_SIZE);
+			ND_PRINT((ndo, "\n[|BGP Bogus header length %u < %u]", hlen,
+			    BGP_SIZE));
 			break;
 		}
 
-		if (TTEST2(p[0], hlen)) {
-			if (!bgp_header_print(p, hlen))
+		if (ND_TTEST2(p[0], hlen)) {
+			if (!bgp_header_print(ndo, p, hlen))
 				return;
 			p += hlen;
 			start = p;
 		} else {
-			printf("\n[|BGP %s]",
+			ND_PRINT((ndo, "\n[|BGP %s]",
 			       tok2strbuf(bgp_msg_values,
 					  "Unknown Message Type",
 					  bgp.bgp_type,
-					  tokbuf, sizeof(tokbuf)));
+					  tokbuf, sizeof(tokbuf))));
 			break;
 		}
 	}
@@ -2750,7 +2772,7 @@
 	return;
 
 trunc:
-	printf(" [|BGP]");
+	ND_PRINT((ndo, " [|BGP]"));
 }
 
 /*
diff --git a/print-bootp.c b/print-bootp.c
index 5e73815..fe0a070 100644
--- a/print-bootp.c
+++ b/print-bootp.c
@@ -20,158 +20,377 @@
  *
  * Format and print bootp packets.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.89 2008-04-22 09:45:08 hannes Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
-#include "ether.h"
-#include "bootp.h"
 
-static void rfc1048_print(const u_char *);
-static void cmu_print(const u_char *);
+static const char tstr[] = " [|bootp]";
+
+/*
+ * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
+ *
+ * This file specifies the "implementation-independent" BOOTP protocol
+ * information which is common to both client and server.
+ *
+ * Copyright 1988 by Carnegie Mellon.
+ *
+ * Permission to use, copy, modify, and distribute this program for any
+ * purpose and without fee is hereby granted, provided that this copyright
+ * and permission notice appear on all copies and supporting documentation,
+ * the name of Carnegie Mellon not be used in advertising or publicity
+ * pertaining to distribution of the program without specific prior
+ * permission, and notice be given in supporting documentation that copying
+ * and distribution is by permission of Carnegie Mellon and Stanford
+ * University.  Carnegie Mellon makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ */
+
+struct bootp {
+	uint8_t		bp_op;		/* packet opcode type */
+	uint8_t		bp_htype;	/* hardware addr type */
+	uint8_t		bp_hlen;	/* hardware addr length */
+	uint8_t		bp_hops;	/* gateway hops */
+	uint32_t	bp_xid;		/* transaction ID */
+	uint16_t	bp_secs;	/* seconds since boot began */
+	uint16_t	bp_flags;	/* flags - see bootp_flag_values[]
+					   in print-bootp.c */
+	struct in_addr	bp_ciaddr;	/* client IP address */
+	struct in_addr	bp_yiaddr;	/* 'your' IP address */
+	struct in_addr	bp_siaddr;	/* server IP address */
+	struct in_addr	bp_giaddr;	/* gateway IP address */
+	uint8_t		bp_chaddr[16];	/* client hardware address */
+	uint8_t		bp_sname[64];	/* server host name */
+	uint8_t		bp_file[128];	/* boot file name */
+	uint8_t		bp_vend[64];	/* vendor-specific area */
+} UNALIGNED;
+
+#define BOOTPREPLY	2
+#define BOOTPREQUEST	1
+
+/*
+ * Vendor magic cookie (v_magic) for CMU
+ */
+#define VM_CMU		"CMU"
+
+/*
+ * Vendor magic cookie (v_magic) for RFC1048
+ */
+#define VM_RFC1048	{ 99, 130, 83, 99 }
+
+/*
+ * RFC1048 tag values used to specify what information is being supplied in
+ * the vendor field of the packet.
+ */
+
+#define TAG_PAD			((uint8_t)   0)
+#define TAG_SUBNET_MASK		((uint8_t)   1)
+#define TAG_TIME_OFFSET		((uint8_t)   2)
+#define TAG_GATEWAY		((uint8_t)   3)
+#define TAG_TIME_SERVER		((uint8_t)   4)
+#define TAG_NAME_SERVER		((uint8_t)   5)
+#define TAG_DOMAIN_SERVER	((uint8_t)   6)
+#define TAG_LOG_SERVER		((uint8_t)   7)
+#define TAG_COOKIE_SERVER	((uint8_t)   8)
+#define TAG_LPR_SERVER		((uint8_t)   9)
+#define TAG_IMPRESS_SERVER	((uint8_t)  10)
+#define TAG_RLP_SERVER		((uint8_t)  11)
+#define TAG_HOSTNAME		((uint8_t)  12)
+#define TAG_BOOTSIZE		((uint8_t)  13)
+#define TAG_END			((uint8_t) 255)
+/* RFC1497 tags */
+#define	TAG_DUMPPATH		((uint8_t)  14)
+#define	TAG_DOMAINNAME		((uint8_t)  15)
+#define	TAG_SWAP_SERVER		((uint8_t)  16)
+#define	TAG_ROOTPATH		((uint8_t)  17)
+#define	TAG_EXTPATH		((uint8_t)  18)
+/* RFC2132 */
+#define	TAG_IP_FORWARD		((uint8_t)  19)
+#define	TAG_NL_SRCRT		((uint8_t)  20)
+#define	TAG_PFILTERS		((uint8_t)  21)
+#define	TAG_REASS_SIZE		((uint8_t)  22)
+#define	TAG_DEF_TTL		((uint8_t)  23)
+#define	TAG_MTU_TIMEOUT		((uint8_t)  24)
+#define	TAG_MTU_TABLE		((uint8_t)  25)
+#define	TAG_INT_MTU		((uint8_t)  26)
+#define	TAG_LOCAL_SUBNETS	((uint8_t)  27)
+#define	TAG_BROAD_ADDR		((uint8_t)  28)
+#define	TAG_DO_MASK_DISC	((uint8_t)  29)
+#define	TAG_SUPPLY_MASK		((uint8_t)  30)
+#define	TAG_DO_RDISC		((uint8_t)  31)
+#define	TAG_RTR_SOL_ADDR	((uint8_t)  32)
+#define	TAG_STATIC_ROUTE	((uint8_t)  33)
+#define	TAG_USE_TRAILERS	((uint8_t)  34)
+#define	TAG_ARP_TIMEOUT		((uint8_t)  35)
+#define	TAG_ETH_ENCAP		((uint8_t)  36)
+#define	TAG_TCP_TTL		((uint8_t)  37)
+#define	TAG_TCP_KEEPALIVE	((uint8_t)  38)
+#define	TAG_KEEPALIVE_GO	((uint8_t)  39)
+#define	TAG_NIS_DOMAIN		((uint8_t)  40)
+#define	TAG_NIS_SERVERS		((uint8_t)  41)
+#define	TAG_NTP_SERVERS		((uint8_t)  42)
+#define	TAG_VENDOR_OPTS		((uint8_t)  43)
+#define	TAG_NETBIOS_NS		((uint8_t)  44)
+#define	TAG_NETBIOS_DDS		((uint8_t)  45)
+#define	TAG_NETBIOS_NODE	((uint8_t)  46)
+#define	TAG_NETBIOS_SCOPE	((uint8_t)  47)
+#define	TAG_XWIN_FS		((uint8_t)  48)
+#define	TAG_XWIN_DM		((uint8_t)  49)
+#define	TAG_NIS_P_DOMAIN	((uint8_t)  64)
+#define	TAG_NIS_P_SERVERS	((uint8_t)  65)
+#define	TAG_MOBILE_HOME		((uint8_t)  68)
+#define	TAG_SMPT_SERVER		((uint8_t)  69)
+#define	TAG_POP3_SERVER		((uint8_t)  70)
+#define	TAG_NNTP_SERVER		((uint8_t)  71)
+#define	TAG_WWW_SERVER		((uint8_t)  72)
+#define	TAG_FINGER_SERVER	((uint8_t)  73)
+#define	TAG_IRC_SERVER		((uint8_t)  74)
+#define	TAG_STREETTALK_SRVR	((uint8_t)  75)
+#define	TAG_STREETTALK_STDA	((uint8_t)  76)
+/* DHCP options */
+#define	TAG_REQUESTED_IP	((uint8_t)  50)
+#define	TAG_IP_LEASE		((uint8_t)  51)
+#define	TAG_OPT_OVERLOAD	((uint8_t)  52)
+#define	TAG_TFTP_SERVER		((uint8_t)  66)
+#define	TAG_BOOTFILENAME	((uint8_t)  67)
+#define	TAG_DHCP_MESSAGE	((uint8_t)  53)
+#define	TAG_SERVER_ID		((uint8_t)  54)
+#define	TAG_PARM_REQUEST	((uint8_t)  55)
+#define	TAG_MESSAGE		((uint8_t)  56)
+#define	TAG_MAX_MSG_SIZE	((uint8_t)  57)
+#define	TAG_RENEWAL_TIME	((uint8_t)  58)
+#define	TAG_REBIND_TIME		((uint8_t)  59)
+#define	TAG_VENDOR_CLASS	((uint8_t)  60)
+#define	TAG_CLIENT_ID		((uint8_t)  61)
+/* RFC 2241 */
+#define	TAG_NDS_SERVERS		((uint8_t)  85)
+#define	TAG_NDS_TREE_NAME	((uint8_t)  86)
+#define	TAG_NDS_CONTEXT		((uint8_t)  87)
+/* RFC 2242 */
+#define	TAG_NDS_IPDOMAIN	((uint8_t)  62)
+#define	TAG_NDS_IPINFO		((uint8_t)  63)
+/* RFC 2485 */
+#define	TAG_OPEN_GROUP_UAP	((uint8_t)  98)
+/* RFC 2563 */
+#define	TAG_DISABLE_AUTOCONF	((uint8_t) 116)
+/* RFC 2610 */
+#define	TAG_SLP_DA		((uint8_t)  78)
+#define	TAG_SLP_SCOPE		((uint8_t)  79)
+/* RFC 2937 */
+#define	TAG_NS_SEARCH		((uint8_t) 117)
+/* RFC 3004 - The User Class Option for DHCP */
+#define	TAG_USER_CLASS		((uint8_t)  77)
+/* RFC 3011 */
+#define	TAG_IP4_SUBNET_SELECT	((uint8_t) 118)
+/* RFC 3442 */
+#define TAG_CLASSLESS_STATIC_RT	((uint8_t) 121)
+#define TAG_CLASSLESS_STA_RT_MS	((uint8_t) 249)
+/* RFC 5859 - TFTP Server Address Option for DHCPv4 */
+#define	TAG_TFTP_SERVER_ADDRESS	((uint8_t) 150)
+/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
+#define	TAG_SLP_NAMING_AUTH	((uint8_t)  80)
+#define	TAG_CLIENT_FQDN		((uint8_t)  81)
+#define	TAG_AGENT_CIRCUIT	((uint8_t)  82)
+#define	TAG_AGENT_REMOTE	((uint8_t)  83)
+#define	TAG_AGENT_MASK		((uint8_t)  84)
+#define	TAG_TZ_STRING		((uint8_t)  88)
+#define	TAG_FQDN_OPTION		((uint8_t)  89)
+#define	TAG_AUTH		((uint8_t)  90)
+#define	TAG_VINES_SERVERS	((uint8_t)  91)
+#define	TAG_SERVER_RANK		((uint8_t)  92)
+#define	TAG_CLIENT_ARCH		((uint8_t)  93)
+#define	TAG_CLIENT_NDI		((uint8_t)  94)
+#define	TAG_CLIENT_GUID		((uint8_t)  97)
+#define	TAG_LDAP_URL		((uint8_t)  95)
+#define	TAG_6OVER4		((uint8_t)  96)
+#define	TAG_PRINTER_NAME	((uint8_t) 100)
+#define	TAG_MDHCP_SERVER	((uint8_t) 101)
+#define	TAG_IPX_COMPAT		((uint8_t) 110)
+#define	TAG_NETINFO_PARENT	((uint8_t) 112)
+#define	TAG_NETINFO_PARENT_TAG	((uint8_t) 113)
+#define	TAG_URL			((uint8_t) 114)
+#define	TAG_FAILOVER		((uint8_t) 115)
+#define	TAG_EXTENDED_REQUEST	((uint8_t) 126)
+#define	TAG_EXTENDED_OPTION	((uint8_t) 127)
+
+/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
+#define DHCPDISCOVER	1
+#define DHCPOFFER	2
+#define DHCPREQUEST	3
+#define DHCPDECLINE	4
+#define DHCPACK		5
+#define DHCPNAK		6
+#define DHCPRELEASE	7
+#define DHCPINFORM	8
+
+/*
+ * "vendor" data permitted for CMU bootp clients.
+ */
+
+struct cmu_vend {
+	uint8_t		v_magic[4];	/* magic number */
+	uint32_t	v_flags;	/* flags/opcodes, etc. */
+	struct in_addr	v_smask;	/* Subnet mask */
+	struct in_addr	v_dgate;	/* Default gateway */
+	struct in_addr	v_dns1, v_dns2; /* Domain name servers */
+	struct in_addr	v_ins1, v_ins2; /* IEN-116 name servers */
+	struct in_addr	v_ts1, v_ts2;	/* Time servers */
+	uint8_t		v_unused[24];	/* currently unused */
+} UNALIGNED;
+
+
+/* v_flags values */
+#define VF_SMASK	1	/* Subnet mask field contains valid data */
+
+/* RFC 4702 DHCP Client FQDN Option */
+
+#define CLIENT_FQDN_FLAGS_S	0x01
+#define CLIENT_FQDN_FLAGS_O	0x02
+#define CLIENT_FQDN_FLAGS_E	0x04
+#define CLIENT_FQDN_FLAGS_N	0x08
+/* end of original bootp.h */
+
+static void rfc1048_print(netdissect_options *, const u_char *);
+static void cmu_print(netdissect_options *, const u_char *);
 static char *client_fqdn_flags(u_int flags);
 
-static char tstr[] = " [|bootp]";
-
 static const struct tok bootp_flag_values[] = {
-    { 0x8000,                   "Broadcast" },
-    { 0, NULL}
+	{ 0x8000,	"Broadcast" },
+	{ 0, NULL}
 };
 
 static const struct tok bootp_op_values[] = {
-    { BOOTPREQUEST,             "Request" },
-    { BOOTPREPLY,               "Reply" },
-    { 0, NULL}
+	{ BOOTPREQUEST,	"Request" },
+	{ BOOTPREPLY,	"Reply" },
+	{ 0, NULL}
 };
 
 /*
  * Print bootp requests
  */
 void
-bootp_print(register const u_char *cp, u_int length)
+bootp_print(netdissect_options *ndo,
+	    register const u_char *cp, u_int length)
 {
 	register const struct bootp *bp;
 	static const u_char vm_cmu[4] = VM_CMU;
 	static const u_char vm_rfc1048[4] = VM_RFC1048;
 
 	bp = (const struct bootp *)cp;
-	TCHECK(bp->bp_op);
+	ND_TCHECK(bp->bp_op);
 
-        printf("BOOTP/DHCP, %s",
-	       tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op));
+	ND_PRINT((ndo, "BOOTP/DHCP, %s",
+		  tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)));
 
 	if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
-		TCHECK2(bp->bp_chaddr[0], 6);
-		printf(" from %s", etheraddr_string(bp->bp_chaddr));
+		ND_TCHECK2(bp->bp_chaddr[0], 6);
+		ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
 	}
 
-        printf(", length %u", length);
+	ND_PRINT((ndo, ", length %u", length));
 
-        if (!vflag)
-            return;
+	if (!ndo->ndo_vflag)
+		return;
 
-	TCHECK(bp->bp_secs);
+	ND_TCHECK(bp->bp_secs);
 
 	/* The usual hardware address type is 1 (10Mb Ethernet) */
 	if (bp->bp_htype != 1)
-		printf(", htype %d", bp->bp_htype);
+		ND_PRINT((ndo, ", htype %d", bp->bp_htype));
 
 	/* The usual length for 10Mb Ethernet address is 6 bytes */
 	if (bp->bp_htype != 1 || bp->bp_hlen != 6)
-		printf(", hlen %d", bp->bp_hlen);
+		ND_PRINT((ndo, ", hlen %d", bp->bp_hlen));
 
 	/* Only print interesting fields */
 	if (bp->bp_hops)
-		printf(", hops %d", bp->bp_hops);
+		ND_PRINT((ndo, ", hops %d", bp->bp_hops));
 	if (EXTRACT_32BITS(&bp->bp_xid))
-		printf(", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid));
+		ND_PRINT((ndo, ", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)));
 	if (EXTRACT_16BITS(&bp->bp_secs))
-		printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs));
+		ND_PRINT((ndo, ", secs %d", EXTRACT_16BITS(&bp->bp_secs)));
 
-	printf(", Flags [%s]",
-		bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags)));
-	if (vflag > 1)
-		printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags));
+	ND_PRINT((ndo, ", Flags [%s]",
+		  bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))));
+	if (ndo->ndo_vflag > 1)
+		ND_PRINT((ndo, " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)));
 
 	/* Client's ip address */
-	TCHECK(bp->bp_ciaddr);
+	ND_TCHECK(bp->bp_ciaddr);
 	if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr))
-		printf("\n\t  Client-IP %s", ipaddr_string(&bp->bp_ciaddr));
+		ND_PRINT((ndo, "\n\t  Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr)));
 
 	/* 'your' ip address (bootp client) */
-	TCHECK(bp->bp_yiaddr);
+	ND_TCHECK(bp->bp_yiaddr);
 	if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr))
-		printf("\n\t  Your-IP %s", ipaddr_string(&bp->bp_yiaddr));
+		ND_PRINT((ndo, "\n\t  Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr)));
 
 	/* Server's ip address */
-	TCHECK(bp->bp_siaddr);
+	ND_TCHECK(bp->bp_siaddr);
 	if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr))
-		printf("\n\t  Server-IP %s", ipaddr_string(&bp->bp_siaddr));
+		ND_PRINT((ndo, "\n\t  Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr)));
 
 	/* Gateway's ip address */
-	TCHECK(bp->bp_giaddr);
+	ND_TCHECK(bp->bp_giaddr);
 	if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr))
-		printf("\n\t  Gateway-IP %s", ipaddr_string(&bp->bp_giaddr));
+		ND_PRINT((ndo, "\n\t  Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr)));
 
 	/* Client's Ethernet address */
 	if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
-		TCHECK2(bp->bp_chaddr[0], 6);
-		printf("\n\t  Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr));
+		ND_TCHECK2(bp->bp_chaddr[0], 6);
+		ND_PRINT((ndo, "\n\t  Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
 	}
 
-	TCHECK2(bp->bp_sname[0], 1);		/* check first char only */
+	ND_TCHECK2(bp->bp_sname[0], 1);		/* check first char only */
 	if (*bp->bp_sname) {
-		printf("\n\t  sname \"");
-		if (fn_print(bp->bp_sname, snapend)) {
-			putchar('"');
-			fputs(tstr + 1, stdout);
+		ND_PRINT((ndo, "\n\t  sname \""));
+		if (fn_print(ndo, bp->bp_sname, ndo->ndo_snapend)) {
+			ND_PRINT((ndo, "\""));
+			ND_PRINT((ndo, "%s", tstr + 1));
 			return;
 		}
-		putchar('"');
+		ND_PRINT((ndo, "\""));
 	}
-	TCHECK2(bp->bp_file[0], 1);		/* check first char only */
+	ND_TCHECK2(bp->bp_file[0], 1);		/* check first char only */
 	if (*bp->bp_file) {
-		printf("\n\t  file \"");
-		if (fn_print(bp->bp_file, snapend)) {
-			putchar('"');
-			fputs(tstr + 1, stdout);
+		ND_PRINT((ndo, "\n\t  file \""));
+		if (fn_print(ndo, bp->bp_file, ndo->ndo_snapend)) {
+			ND_PRINT((ndo, "\""));
+			ND_PRINT((ndo, "%s", tstr + 1));
 			return;
 		}
-		putchar('"');
+		ND_PRINT((ndo, "\""));
 	}
 
 	/* Decode the vendor buffer */
-	TCHECK(bp->bp_vend[0]);
+	ND_TCHECK(bp->bp_vend[0]);
 	if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
-		 sizeof(u_int32_t)) == 0)
-		rfc1048_print(bp->bp_vend);
+		    sizeof(uint32_t)) == 0)
+		rfc1048_print(ndo, bp->bp_vend);
 	else if (memcmp((const char *)bp->bp_vend, vm_cmu,
-		      sizeof(u_int32_t)) == 0)
-		cmu_print(bp->bp_vend);
+			sizeof(uint32_t)) == 0)
+		cmu_print(ndo, bp->bp_vend);
 	else {
-		u_int32_t ul;
+		uint32_t ul;
 
 		ul = EXTRACT_32BITS(&bp->bp_vend);
 		if (ul != 0)
-			printf("\n\t  Vendor-#0x%x", ul);
+			ND_PRINT((ndo, "\n\t  Vendor-#0x%x", ul));
 	}
 
 	return;
 trunc:
-	fputs(tstr, stdout);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
@@ -276,13 +495,16 @@
 	{ TAG_SLP_SCOPE,	"bSLP-SCOPE" },	/*"b" is a little wrong */
 /* RFC 2937 */
 	{ TAG_NS_SEARCH,	"sNSSEARCH" },	/* XXX 's' */
+/* RFC 3004 - The User Class Option for DHCP */
+	{ TAG_USER_CLASS,	"$User-Class" },
 /* RFC 3011 */
 	{ TAG_IP4_SUBNET_SELECT, "iSUBNET" },
 /* RFC 3442 */
 	{ TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" },
 	{ TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" },
+/* RFC 5859 - TFTP Server Address Option for DHCPv4 */
+	{ TAG_TFTP_SERVER_ADDRESS, "iTFTP-Server-Address" },
 /* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */
-	{ TAG_USER_CLASS,	"aCLASS" },
 	{ TAG_SLP_NAMING_AUTH,	"aSLP-NA" },
 	{ TAG_CLIENT_FQDN,	"$FQDN" },
 	{ TAG_AGENT_CIRCUIT,	"$Agent-Information" },
@@ -305,91 +527,92 @@
 	{ TAG_NETINFO_PARENT_TAG, "aNITAG" },
 	{ TAG_URL,		"aURL" },
 	{ TAG_FAILOVER,		"bFAIL" },	/* XXX 'b' */
-	{ 0,			NULL }
+	{ 0, NULL }
 };
 /* 2-byte extended tags */
 static const struct tok xtag2str[] = {
-	{ 0,			NULL }
+	{ 0, NULL }
 };
 
 /* DHCP "options overload" types */
 static const struct tok oo2str[] = {
-	{ 1,			"file" },
-	{ 2,			"sname" },
-	{ 3,			"file+sname" },
-	{ 0,			NULL }
+	{ 1,	"file" },
+	{ 2,	"sname" },
+	{ 3,	"file+sname" },
+	{ 0, NULL }
 };
 
 /* NETBIOS over TCP/IP node type options */
 static const struct tok nbo2str[] = {
-	{ 0x1,			"b-node" },
-	{ 0x2,			"p-node" },
-	{ 0x4,			"m-node" },
-	{ 0x8,			"h-node" },
-	{ 0,			NULL }
+	{ 0x1,	"b-node" },
+	{ 0x2,	"p-node" },
+	{ 0x4,	"m-node" },
+	{ 0x8,	"h-node" },
+	{ 0, NULL }
 };
 
 /* ARP Hardware types, for Client-ID option */
 static const struct tok arp2str[] = {
-	{ 0x1,			"ether" },
-	{ 0x6,			"ieee802" },
-	{ 0x7,			"arcnet" },
-	{ 0xf,			"frelay" },
-	{ 0x17,			"strip" },
-	{ 0x18,			"ieee1394" },
-	{ 0,			NULL }
+	{ 0x1,	"ether" },
+	{ 0x6,	"ieee802" },
+	{ 0x7,	"arcnet" },
+	{ 0xf,	"frelay" },
+	{ 0x17,	"strip" },
+	{ 0x18,	"ieee1394" },
+	{ 0, NULL }
 };
 
 static const struct tok dhcp_msg_values[] = {
-        { DHCPDISCOVER, "Discover" },
-        { DHCPOFFER, "Offer" },
-        { DHCPREQUEST, "Request" },
-        { DHCPDECLINE, "Decline" },
-        { DHCPACK, "ACK" },
-        { DHCPNAK, "NACK" },
-        { DHCPRELEASE, "Release" },
-        { DHCPINFORM, "Inform" },
-        { 0,			NULL }
+	{ DHCPDISCOVER,	"Discover" },
+	{ DHCPOFFER,	"Offer" },
+	{ DHCPREQUEST,	"Request" },
+	{ DHCPDECLINE,	"Decline" },
+	{ DHCPACK,	"ACK" },
+	{ DHCPNAK,	"NACK" },
+	{ DHCPRELEASE,	"Release" },
+	{ DHCPINFORM,	"Inform" },
+	{ 0, NULL }
 };
 
-#define AGENT_SUBOPTION_CIRCUIT_ID 	1	/* RFC 3046 */
-#define AGENT_SUBOPTION_REMOTE_ID  	2	/* RFC 3046 */
-#define AGENT_SUBOPTION_SUBSCRIBER_ID 	6	/* RFC 3993 */
+#define AGENT_SUBOPTION_CIRCUIT_ID	1	/* RFC 3046 */
+#define AGENT_SUBOPTION_REMOTE_ID	2	/* RFC 3046 */
+#define AGENT_SUBOPTION_SUBSCRIBER_ID	6	/* RFC 3993 */
 static const struct tok agent_suboption_values[] = {
-        { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" },
-        { AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" },
-        { AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" },
-        { 0,			NULL }
+	{ AGENT_SUBOPTION_CIRCUIT_ID,    "Circuit-ID" },
+	{ AGENT_SUBOPTION_REMOTE_ID,     "Remote-ID" },
+	{ AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" },
+	{ 0, NULL }
 };
 
 
 static void
-rfc1048_print(register const u_char *bp)
+rfc1048_print(netdissect_options *ndo,
+	      register const u_char *bp)
 {
-	register u_int16_t tag;
+	register uint16_t tag;
 	register u_int len;
 	register const char *cp;
 	register char c;
 	int first, idx;
-	u_int32_t ul;
-	u_int16_t us;
-	u_int8_t uc, subopt, suboptlen;
+	uint32_t ul;
+	uint16_t us;
+	uint8_t uc, subopt, suboptlen;
 
-	printf("\n\t  Vendor-rfc1048 Extensions");
+	ND_PRINT((ndo, "\n\t  Vendor-rfc1048 Extensions"));
 
 	/* Step over magic cookie */
-        printf("\n\t    Magic Cookie 0x%08x", EXTRACT_32BITS(bp));
+	ND_PRINT((ndo, "\n\t    Magic Cookie 0x%08x", EXTRACT_32BITS(bp)));
 	bp += sizeof(int32_t);
 
 	/* Loop while we there is a tag left in the buffer */
-	while (TTEST2(*bp, 1)) {
+	while (ND_TTEST2(*bp, 1)) {
 		tag = *bp++;
-		if (tag == TAG_PAD && vflag < 3)
+		if (tag == TAG_PAD && ndo->ndo_vflag < 3)
 			continue;
-		if (tag == TAG_END && vflag < 3)
+		if (tag == TAG_END && ndo->ndo_vflag < 3)
 			return;
 		if (tag == TAG_EXTENDED_OPTION) {
-			TCHECK2(*(bp + 1), 2);
+			ND_TCHECK2(*(bp + 1), 2);
 			tag = EXTRACT_16BITS(bp + 1);
 			/* XXX we don't know yet if the IANA will
 			 * preclude overlap of 1-byte and 2-byte spaces.
@@ -404,32 +627,32 @@
 			len = 0;
 		else {
 			/* Get the length; check for truncation */
-			TCHECK2(*bp, 1);
+			ND_TCHECK2(*bp, 1);
 			len = *bp++;
 		}
 
-		printf("\n\t    %s Option %u, length %u%s", cp, tag, len,
-		    len > 0 ? ": " : "");
+		ND_PRINT((ndo, "\n\t    %s Option %u, length %u%s", cp, tag, len,
+			  len > 0 ? ": " : ""));
 
-		if (tag == TAG_PAD && vflag > 2) {
+		if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
 			u_int ntag = 1;
-			while (TTEST2(*bp, 1) && *bp == TAG_PAD) {
+			while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
 				bp++;
 				ntag++;
 			}
 			if (ntag > 1)
-				printf(", occurs %u", ntag);
+				ND_PRINT((ndo, ", occurs %u", ntag));
 		}
 
-		if (!TTEST2(*bp, len)) {
-			printf("[|rfc1048 %u]", len);
+		if (!ND_TTEST2(*bp, len)) {
+			ND_PRINT((ndo, "[|rfc1048 %u]", len));
 			return;
 		}
 
 		if (tag == TAG_DHCP_MESSAGE && len == 1) {
 			uc = *bp++;
-                        printf("%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc));
-                        continue;
+			ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
+			continue;
 		}
 
 		if (tag == TAG_PARM_REQUEST) {
@@ -438,10 +661,10 @@
 				uc = *bp++;
 				cp = tok2str(tag2str, "?Option %u", uc);
 				if (idx % 4 == 0)
-					printf("\n\t      ");
+					ND_PRINT((ndo, "\n\t      "));
 				else
-					printf(", ");
-				printf("%s", cp + 1);
+					ND_PRINT((ndo, ", "));
+				ND_PRINT((ndo, "%s", cp + 1));
 				idx++;
 			}
 			continue;
@@ -455,8 +678,8 @@
 				bp += 2;
 				cp = tok2str(xtag2str, "?xT%u", us);
 				if (!first)
-					putchar('+');
-				printf("%s", cp + 1);
+					ND_PRINT((ndo, "+"));
+				ND_PRINT((ndo, "%s", cp + 1));
 				first = 0;
 			}
 			continue;
@@ -477,12 +700,12 @@
 
 		case 'a':
 			/* ascii strings */
-			putchar('"');
-			if (fn_printn(bp, len, snapend)) {
-				putchar('"');
+			ND_PRINT((ndo, "\""));
+			if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+				ND_PRINT((ndo, "\""));
 				goto trunc;
 			}
-			putchar('"');
+			ND_PRINT((ndo, "\""));
 			bp += len;
 			len = 0;
 			break;
@@ -493,15 +716,15 @@
 			/* ip addresses/32-bit words */
 			while (len >= sizeof(ul)) {
 				if (!first)
-					putchar(',');
+					ND_PRINT((ndo, ","));
 				ul = EXTRACT_32BITS(bp);
 				if (c == 'i') {
 					ul = htonl(ul);
-					printf("%s", ipaddr_string(&ul));
+					ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ul)));
 				} else if (c == 'L')
-					printf("%d", ul);
+					ND_PRINT((ndo, "%d", ul));
 				else
-					printf("%u", ul);
+					ND_PRINT((ndo, "%u", ul));
 				bp += sizeof(ul);
 				len -= sizeof(ul);
 				first = 0;
@@ -512,12 +735,12 @@
 			/* IP address pairs */
 			while (len >= 2*sizeof(ul)) {
 				if (!first)
-					putchar(',');
+					ND_PRINT((ndo, ","));
 				memcpy((char *)&ul, (const char *)bp, sizeof(ul));
-				printf("(%s:", ipaddr_string(&ul));
+				ND_PRINT((ndo, "(%s:", ipaddr_string(ndo, &ul)));
 				bp += sizeof(ul);
 				memcpy((char *)&ul, (const char *)bp, sizeof(ul));
-				printf("%s)", ipaddr_string(&ul));
+				ND_PRINT((ndo, "%s)", ipaddr_string(ndo, &ul)));
 				bp += sizeof(ul);
 				len -= 2*sizeof(ul);
 				first = 0;
@@ -528,9 +751,9 @@
 			/* shorts */
 			while (len >= sizeof(us)) {
 				if (!first)
-					putchar(',');
+					ND_PRINT((ndo, ","));
 				us = EXTRACT_16BITS(bp);
-				printf("%u", us);
+				ND_PRINT((ndo, "%u", us));
 				bp += sizeof(us);
 				len -= sizeof(us);
 				first = 0;
@@ -541,16 +764,16 @@
 			/* boolean */
 			while (len > 0) {
 				if (!first)
-					putchar(',');
+					ND_PRINT((ndo, ","));
 				switch (*bp) {
 				case 0:
-					putchar('N');
+					ND_PRINT((ndo, "N"));
 					break;
 				case 1:
-					putchar('Y');
+					ND_PRINT((ndo, "Y"));
 					break;
 				default:
-					printf("%u?", *bp);
+					ND_PRINT((ndo, "%u?", *bp));
 					break;
 				}
 				++bp;
@@ -565,11 +788,11 @@
 			/* Bytes */
 			while (len > 0) {
 				if (!first)
-					putchar(c == 'x' ? ':' : '.');
+					ND_PRINT((ndo, c == 'x' ? ":" : "."));
 				if (c == 'x')
-					printf("%02x", *bp);
+					ND_PRINT((ndo, "%02x", *bp));
 				else
-					printf("%u", *bp);
+					ND_PRINT((ndo, "%u", *bp));
 				++bp;
 				--len;
 				first = 0;
@@ -582,80 +805,77 @@
 
 			case TAG_NETBIOS_NODE:
 				/* this option should be at least 1 byte long */
-				if (len < 1)  {
-					printf("ERROR: option %u len %u < 1 bytes",
-					    TAG_NETBIOS_NODE, len);
+				if (len < 1) {
+					ND_PRINT((ndo, "ERROR: length < 1 bytes"));
 					break;
 				}
 				tag = *bp++;
 				--len;
-				fputs(tok2str(nbo2str, NULL, tag), stdout);
+				ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag)));
 				break;
 
 			case TAG_OPT_OVERLOAD:
 				/* this option should be at least 1 byte long */
-				if (len < 1)  {
-					printf("ERROR: option %u len %u < 1 bytes",
-					    TAG_OPT_OVERLOAD, len);
+				if (len < 1) {
+					ND_PRINT((ndo, "ERROR: length < 1 bytes"));
 					break;
 				}
 				tag = *bp++;
 				--len;
-				fputs(tok2str(oo2str, NULL, tag), stdout);
+				ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag)));
 				break;
 
 			case TAG_CLIENT_FQDN:
 				/* this option should be at least 3 bytes long */
-				if (len < 3)  {
-					printf("ERROR: option %u len %u < 3 bytes",
-					    TAG_CLIENT_FQDN, len);
+				if (len < 3) {
+					ND_PRINT((ndo, "ERROR: length < 3 bytes"));
 					bp += len;
 					len = 0;
 					break;
 				}
 				if (*bp)
-					printf("[%s] ", client_fqdn_flags(*bp));
+					ND_PRINT((ndo, "[%s] ", client_fqdn_flags(*bp)));
 				bp++;
 				if (*bp || *(bp+1))
-					printf("%u/%u ", *bp, *(bp+1));
+					ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1)));
 				bp += 2;
-				putchar('"');
-				if (fn_printn(bp, len - 3, snapend)) {
-					putchar('"');
+				ND_PRINT((ndo, "\""));
+				if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
+					ND_PRINT((ndo, "\""));
 					goto trunc;
 				}
-				putchar('"');
+				ND_PRINT((ndo, "\""));
 				bp += len - 3;
 				len = 0;
 				break;
 
 			case TAG_CLIENT_ID:
-			    {	int type;
+			    {
+				int type;
 
 				/* this option should be at least 1 byte long */
-				if (len < 1)  {
-					printf("ERROR: option %u len %u < 1 bytes",
-					    TAG_CLIENT_ID, len);
+				if (len < 1) {
+					ND_PRINT((ndo, "ERROR: length < 1 bytes"));
 					break;
 				}
 				type = *bp++;
 				len--;
 				if (type == 0) {
-					putchar('"');
-					if (fn_printn(bp, len, snapend)) {
-						putchar('"');
+					ND_PRINT((ndo, "\""));
+					if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+						ND_PRINT((ndo, "\""));
 						goto trunc;
 					}
-					putchar('"');
+					ND_PRINT((ndo, "\""));
 					bp += len;
 					len = 0;
 					break;
 				} else {
-					printf("%s ", tok2str(arp2str, "hardware-type %u,", type));
+					ND_PRINT((ndo, "%s ", tok2str(arp2str, "hardware-type %u,", type)));
 					while (len > 0) {
 						if (!first)
-							putchar(':');
-						printf("%02x", *bp);
+							ND_PRINT((ndo, ":"));
+						ND_PRINT((ndo, "%02x", *bp));
 						++bp;
 						--len;
 						first = 0;
@@ -670,56 +890,56 @@
 					suboptlen = *bp++;
 					len -= 2;
 					if (suboptlen > len) {
-						printf("\n\t      %s SubOption %u, length %u: length goes past end of option",
-						   tok2str(agent_suboption_values, "Unknown", subopt),
-						   subopt,
-						   suboptlen);
+						ND_PRINT((ndo, "\n\t      %s SubOption %u, length %u: length goes past end of option",
+							  tok2str(agent_suboption_values, "Unknown", subopt),
+							  subopt,
+							  suboptlen));
 						bp += len;
 						len = 0;
 						break;
 					}
-					printf("\n\t      %s SubOption %u, length %u: ",
-					   tok2str(agent_suboption_values, "Unknown", subopt),
-					   subopt,
-					   suboptlen);
+					ND_PRINT((ndo, "\n\t      %s SubOption %u, length %u: ",
+						  tok2str(agent_suboption_values, "Unknown", subopt),
+						  subopt,
+						  suboptlen));
 					switch (subopt) {
 
-                                        case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
-                                        case AGENT_SUBOPTION_REMOTE_ID:
-                                        case AGENT_SUBOPTION_SUBSCRIBER_ID:
-                                                fn_printn(bp, suboptlen, NULL);
-                                                break;
+					case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
+					case AGENT_SUBOPTION_REMOTE_ID:
+					case AGENT_SUBOPTION_SUBSCRIBER_ID:
+						if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend))
+							goto trunc;
+						break;
 
 					default:
-						print_unknown_data(bp, "\n\t\t", suboptlen);
+						print_unknown_data(ndo, bp, "\n\t\t", suboptlen);
 					}
 
 					len -= suboptlen;
 					bp += suboptlen;
-			    }
-			    break;
+				}
+				break;
 
 			case TAG_CLASSLESS_STATIC_RT:
 			case TAG_CLASSLESS_STA_RT_MS:
-			{	
+			    {
 				u_int mask_width, significant_octets, i;
 
 				/* this option should be at least 5 bytes long */
-				if (len < 5)  {
-					printf("ERROR: option %u len %u < 5 bytes",
-					    TAG_CLASSLESS_STATIC_RT, len);
+				if (len < 5) {
+					ND_PRINT((ndo, "ERROR: length < 5 bytes"));
 					bp += len;
 					len = 0;
 					break;
 				}
 				while (len > 0) {
 					if (!first)
-						putchar(',');
+						ND_PRINT((ndo, ","));
 					mask_width = *bp++;
 					len--;
 					/* mask_width <= 32 */
 					if (mask_width > 32) {
-						printf("[ERROR: Mask width (%d) > 32]",  mask_width);
+						ND_PRINT((ndo, "[ERROR: Mask width (%d) > 32]", mask_width));
 						bp += len;
 						len = 0;
 						break;
@@ -727,36 +947,78 @@
 					significant_octets = (mask_width + 7) / 8;
 					/* significant octets + router(4) */
 					if (len < significant_octets + 4) {
-						printf("[ERROR: Remaining length (%u) < %u bytes]",  len, significant_octets + 4);
+						ND_PRINT((ndo, "[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4));
 						bp += len;
 						len = 0;
 						break;
 					}
-					putchar('(');
+					ND_PRINT((ndo, "("));
 					if (mask_width == 0)
-						printf("default");
+						ND_PRINT((ndo, "default"));
 					else {
 						for (i = 0; i < significant_octets ; i++) {
 							if (i > 0)
-								putchar('.');
-							printf("%d", *bp++);
+								ND_PRINT((ndo, "."));
+							ND_PRINT((ndo, "%d", *bp++));
 						}
 						for (i = significant_octets ; i < 4 ; i++)
-							printf(".0");
-						printf("/%d", mask_width);
+							ND_PRINT((ndo, ".0"));
+						ND_PRINT((ndo, "/%d", mask_width));
 					}
 					memcpy((char *)&ul, (const char *)bp, sizeof(ul));
-					printf(":%s)", ipaddr_string(&ul));
+					ND_PRINT((ndo, ":%s)", ipaddr_string(ndo, &ul)));
 					bp += sizeof(ul);
 					len -= (significant_octets + 4);
 					first = 0;
 				}
-			}
-			break;
+				break;
+			    }
+
+			case TAG_USER_CLASS:
+			    {
+				u_int suboptnumber = 1;
+
+				first = 1;
+				if (len < 2) {
+					ND_PRINT((ndo, "ERROR: length < 2 bytes"));
+					bp += len;
+					len = 0;
+					break;
+				}
+				while (len > 0) {
+					suboptlen = *bp++;
+					len--;
+					ND_PRINT((ndo, "\n\t      "));
+					ND_PRINT((ndo, "instance#%u: ", suboptnumber));
+					if (suboptlen == 0) {
+						ND_PRINT((ndo, "ERROR: suboption length must be non-zero"));
+						bp += len;
+						len = 0;
+						break;
+					}
+					if (len < suboptlen) {
+						ND_PRINT((ndo, "ERROR: malformed option"));
+						bp += len;
+						len = 0;
+						break;
+					}
+					ND_PRINT((ndo, "\""));
+					if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) {
+						ND_PRINT((ndo, "\""));
+						goto trunc;
+					}
+					ND_PRINT((ndo, "\""));
+					ND_PRINT((ndo, ", length %d", suboptlen));
+					suboptnumber++;
+					len -= suboptlen;
+					bp += suboptlen;
+				}
+				break;
+			    }
 
 			default:
-				printf("[unknown special tag %u, size %u]",
-				    tag, len);
+				ND_PRINT((ndo, "[unknown special tag %u, size %u]",
+					  tag, len));
 				bp += len;
 				len = 0;
 				break;
@@ -765,31 +1027,32 @@
 		}
 		/* Data left over? */
 		if (len) {
-			printf("\n\t  trailing data length %u", len);
+			ND_PRINT((ndo, "\n\t  trailing data length %u", len));
 			bp += len;
 		}
 	}
 	return;
 trunc:
-	printf("|[rfc1048]");
+	ND_PRINT((ndo, "|[rfc1048]"));
 }
 
 static void
-cmu_print(register const u_char *bp)
+cmu_print(netdissect_options *ndo,
+	  register const u_char *bp)
 {
 	register const struct cmu_vend *cmu;
 
-#define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \
+#define PRINTCMUADDR(m, s) { ND_TCHECK(cmu->m); \
     if (cmu->m.s_addr != 0) \
-	printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); }
+	ND_PRINT((ndo, " %s:%s", s, ipaddr_string(ndo, &cmu->m.s_addr))); }
 
-	printf(" vend-cmu");
+	ND_PRINT((ndo, " vend-cmu"));
 	cmu = (const struct cmu_vend *)bp;
 
 	/* Only print if there are unknown bits */
-	TCHECK(cmu->v_flags);
+	ND_TCHECK(cmu->v_flags);
 	if ((cmu->v_flags & ~(VF_SMASK)) != 0)
-		printf(" F:0x%x", cmu->v_flags);
+		ND_PRINT((ndo, " F:0x%x", cmu->v_flags));
 	PRINTCMUADDR(v_dgate, "DG");
 	PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*");
 	PRINTCMUADDR(v_dns1, "NS1");
@@ -801,7 +1064,7 @@
 	return;
 
 trunc:
-	fputs(tstr, stdout);
+	ND_PRINT((ndo, "%s", tstr));
 #undef PRINTCMUADDR
 }
 
diff --git a/print-bt.c b/print-bt.c
index 259f3e5..128daad 100644
--- a/print-bt.c
+++ b/print-bt.c
@@ -9,32 +9,23 @@
  * 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 Paolo Abeni.'' 
- * The name of author may not be used to endorse or promote products derived 
+ * ``This product includes software developed by Paolo Abeni.''
+ * The name of author may not 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.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
 
 #if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
 #include <pcap/bluetooth.h>
@@ -47,24 +38,24 @@
  * is the number of bytes actually captured.
  */
 u_int
-bt_if_print(const struct pcap_pkthdr *h, const u_char *p)
+bt_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int length = h->len;
 	u_int caplen = h->caplen;
 	const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p;
 
 	if (caplen < BT_HDRLEN) {
-		printf("[|bt]");
+		ND_PRINT((ndo, "[|bt]"));
 		return (BT_HDRLEN);
 	}
 	caplen -= BT_HDRLEN;
 	length -= BT_HDRLEN;
 	p += BT_HDRLEN;
-	if (eflag)
-		(void)printf("hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out");
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out"));
 
-	if (!suppress_default_print)
-		default_print(p, caplen);
+	if (!ndo->ndo_suppress_default_print)
+		ND_DEFAULTPRINT(p, caplen);
 
 	return (BT_HDRLEN);
 }
diff --git a/print-calm-fast.c b/print-calm-fast.c
index 9824072..5cc39f4 100644
--- a/print-calm-fast.c
+++ b/print-calm-fast.c
@@ -15,18 +15,14 @@
  * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
-#include "extract.h"
 #include "addrtoname.h"
 
 /*
@@ -47,12 +43,12 @@
 	length -= 2;
 	bp += 2;
 
-	printf("CALM FAST src:%s; ", etheraddr_string(eth+6));
-	printf("SrcNwref:%d; ", srcNwref);
-	printf("DstNwref:%d; ", dstNwref);
+	ND_PRINT((ndo, "CALM FAST src:%s; ", etheraddr_string(ndo, eth+6)));
+	ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
+	ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
 
 	if (ndo->ndo_vflag)
-		default_print(bp, length);
+		ND_DEFAULTPRINT(bp, length);
 }
 
 
diff --git a/print-carp.c b/print-carp.c
index 75f5774..7b9f28c 100644
--- a/print-carp.c
+++ b/print-carp.c
@@ -34,52 +34,49 @@
  *
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "interface.h"
+#include "interface.h" /* for checksum structure and functions */
 #include "extract.h"
-#include "addrtoname.h"
 
 void
-carp_print(register const u_char *bp, register u_int len, int ttl)
+carp_print(netdissect_options *ndo, register const u_char *bp, register u_int len, int ttl)
 {
 	int version, type;
 	const char *type_s;
 
-	TCHECK(bp[0]);
+	ND_TCHECK(bp[0]);
 	version = (bp[0] & 0xf0) >> 4;
 	type = bp[0] & 0x0f;
 	if (type == 1)
 		type_s = "advertise";
 	else
 		type_s = "unknown";
-	printf("CARPv%d-%s %d: ", version, type_s, len);
+	ND_PRINT((ndo, "CARPv%d-%s %d: ", version, type_s, len));
 	if (ttl != 255)
-		printf("[ttl=%d!] ", ttl);
+		ND_PRINT((ndo, "[ttl=%d!] ", ttl));
 	if (version != 2 || type != 1)
 		return;
-	TCHECK(bp[2]);
-	TCHECK(bp[5]);
-	printf("vhid=%d advbase=%d advskew=%d authlen=%d ",
-	    bp[1], bp[5], bp[2], bp[3]);
-	if (vflag) {
+	ND_TCHECK(bp[2]);
+	ND_TCHECK(bp[5]);
+	ND_PRINT((ndo, "vhid=%d advbase=%d advskew=%d authlen=%d ",
+	    bp[1], bp[5], bp[2], bp[3]));
+	if (ndo->ndo_vflag) {
 		struct cksum_vec vec[1];
-		vec[0].ptr = (const u_int8_t *)bp;
+		vec[0].ptr = (const uint8_t *)bp;
 		vec[0].len = len;
-		if (TTEST2(bp[0], len) && in_cksum(vec, 1))
-			printf(" (bad carp cksum %x!)",
-				EXTRACT_16BITS(&bp[6]));
+		if (ND_TTEST2(bp[0], len) && in_cksum(vec, 1))
+			ND_PRINT((ndo, " (bad carp cksum %x!)",
+				EXTRACT_16BITS(&bp[6])));
 	}
-	printf("counter=%" PRIu64, EXTRACT_64BITS(&bp[8]));
+	ND_PRINT((ndo, "counter=%" PRIu64, EXTRACT_64BITS(&bp[8])));
 
 	return;
 trunc:
-	printf("[|carp]");
+	ND_PRINT((ndo, "[|carp]"));
 }
diff --git a/print-cdp.c b/print-cdp.c
index 152b2f9..932f7bc 100644
--- a/print-cdp.c
+++ b/print-cdp.c
@@ -24,18 +24,13 @@
  *    http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
@@ -43,7 +38,16 @@
 #include "extract.h"			/* must come after interface.h */
 #include "nlpid.h"
 
-#define CDP_HEADER_LEN  4
+static const char tstr[] = "[|cdp]";
+
+#define CDP_HEADER_LEN             4
+#define CDP_HEADER_VERSION_OFFSET  0
+#define CDP_HEADER_TTL_OFFSET      1
+#define CDP_HEADER_CHECKSUM_OFFSET 2
+
+#define CDP_TLV_HEADER_LEN  4
+#define CDP_TLV_TYPE_OFFSET 0
+#define CDP_TLV_LEN_OFFSET  2
 
 static const struct tok cdp_tlv_values[] = {
     { 0x01,             "Device-ID"},
@@ -81,158 +85,180 @@
     { 0, NULL }
 };
 
-static int cdp_print_addr(const u_char *, int);
-static int cdp_print_prefixes(const u_char *, int);
+static int cdp_print_addr(netdissect_options *, const u_char *, int);
+static int cdp_print_prefixes(netdissect_options *, const u_char *, int);
 static unsigned long cdp_get_number(const u_char *, int);
 
 void
-cdp_print(const u_char *pptr, u_int length, u_int caplen)
+cdp_print(netdissect_options *ndo,
+          const u_char *pptr, u_int length, u_int caplen)
 {
 	int type, len, i, j;
-        const u_char *tptr;
+	const u_char *tptr;
 
 	if (caplen < CDP_HEADER_LEN) {
-		(void)printf("[|cdp]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 
-        tptr = pptr; /* temporary pointer */
+	tptr = pptr; /* temporary pointer */
 
-        if (!TTEST2(*tptr, CDP_HEADER_LEN))
-                goto trunc;
-	printf("CDPv%u, ttl: %us", *tptr, *(tptr+1));
-        if (vflag)
-                printf(", checksum: %u (unverified), length %u", EXTRACT_16BITS(tptr), length);
+	ND_TCHECK2(*tptr, CDP_HEADER_LEN);
+	ND_PRINT((ndo, "CDPv%u, ttl: %us", *(tptr + CDP_HEADER_VERSION_OFFSET),
+					   *(tptr + CDP_HEADER_TTL_OFFSET)));
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, ", checksum: 0x%04x (unverified), length %u", EXTRACT_16BITS(tptr+CDP_HEADER_CHECKSUM_OFFSET), length));
 	tptr += CDP_HEADER_LEN;
 
 	while (tptr < (pptr+length)) {
+		ND_TCHECK2(*tptr, CDP_TLV_HEADER_LEN); /* read out Type and Length */
+		type = EXTRACT_16BITS(tptr+CDP_TLV_TYPE_OFFSET);
+		len  = EXTRACT_16BITS(tptr+CDP_TLV_LEN_OFFSET); /* object length includes the 4 bytes header length */
+		if (len < CDP_TLV_HEADER_LEN) {
+		    if (ndo->ndo_vflag)
+			ND_PRINT((ndo, "\n\t%s (0x%02x), TLV length: %u byte%s (too short)",
+			       tok2str(cdp_tlv_values,"unknown field type", type),
+			       type,
+			       len,
+			       PLURAL_SUFFIX(len))); /* plural */
+		    else
+			ND_PRINT((ndo, ", %s TLV length %u too short",
+			       tok2str(cdp_tlv_values,"unknown field type", type),
+			       len));
+		    break;
+		}
+		tptr += CDP_TLV_HEADER_LEN;
+		len -= CDP_TLV_HEADER_LEN;
 
-                if (!TTEST2(*tptr, 4)) /* read out Type and Length */
-                    goto trunc;
-		type = EXTRACT_16BITS(tptr);
-		len  = EXTRACT_16BITS(tptr+2); /* object length includes the 4 bytes header length */
-                tptr += 4;
-                len -= 4;
+		ND_TCHECK2(*tptr, len);
 
-		if (!TTEST2(*tptr, len))
-			goto trunc;
+		if (ndo->ndo_vflag || type == 1) { /* in non-verbose mode just print Device-ID */
 
-                if (vflag || type == 1) { /* in non-verbose mode just print Device-ID */
+		    if (ndo->ndo_vflag)
+			ND_PRINT((ndo, "\n\t%s (0x%02x), value length: %u byte%s: ",
+			       tok2str(cdp_tlv_values,"unknown field type", type),
+			       type,
+			       len,
+			       PLURAL_SUFFIX(len))); /* plural */
 
-                    if (vflag)
-                        printf("\n\t%s (0x%02x), length: %u byte%s: ",
-                               tok2str(cdp_tlv_values,"unknown field type", type),
-                               type,
-                               len,
-                               PLURAL_SUFFIX(len)); /* plural */
+		    switch (type) {
 
-                    switch (type) {
-
-                    case 0x01: /* Device-ID */
-                        if (!vflag)
-                            printf(", Device-ID ");
-                        printf("'");
-                        fn_printn(tptr, len, NULL);
-                        printf("'");
+		    case 0x01: /* Device-ID */
+			if (!ndo->ndo_vflag)
+			    ND_PRINT((ndo, ", Device-ID "));
+			ND_PRINT((ndo, "'"));
+			(void)fn_printn(ndo, tptr, len, NULL);
+			ND_PRINT((ndo, "'"));
 			break;
-                    case 0x02: /* Address */
-                        if (cdp_print_addr(tptr, len) < 0)
-                            goto trunc;
+		    case 0x02: /* Address */
+			if (cdp_print_addr(ndo, tptr, len) < 0)
+			    goto trunc;
 			break;
-                    case 0x03: /* Port-ID */
-                        printf("'");
-                        fn_printn(tptr, len, NULL);
-                        printf("'");
+		    case 0x03: /* Port-ID */
+			ND_PRINT((ndo, "'"));
+			(void)fn_printn(ndo, tptr, len, NULL);
+			ND_PRINT((ndo, "'"));
 			break;
-                    case 0x04: /* Capabilities */
-			printf("(0x%08x): %s",
-                               EXTRACT_32BITS(tptr),
-                               bittok2str(cdp_capability_values, "none",EXTRACT_32BITS(tptr)));
+		    case 0x04: /* Capabilities */
+			if (len < 4)
+			    goto trunc;
+			ND_PRINT((ndo, "(0x%08x): %s",
+			       EXTRACT_32BITS(tptr),
+			       bittok2str(cdp_capability_values, "none", EXTRACT_32BITS(tptr))));
 			break;
-                    case 0x05: /* Version */
-                        printf("\n\t  ");
-                        for (i=0;i<len;i++) {
-                            j = *(tptr+i);
-                            putchar(j);
-                            if (j == 0x0a) /* lets rework the version string to get a nice identation */
-                                printf("\t  ");
-                        }
+		    case 0x05: /* Version */
+			ND_PRINT((ndo, "\n\t  "));
+			for (i=0;i<len;i++) {
+			    j = *(tptr+i);
+			    ND_PRINT((ndo, "%c", j));
+			    if (j == 0x0a) /* lets rework the version string to get a nice indentation */
+				ND_PRINT((ndo, "\t  "));
+			}
 			break;
-                    case 0x06: /* Platform */
-                        printf("'");
-                        fn_printn(tptr, len, NULL);
-                        printf("'");
+		    case 0x06: /* Platform */
+			ND_PRINT((ndo, "'"));
+			(void)fn_printn(ndo, tptr, len, NULL);
+			ND_PRINT((ndo, "'"));
 			break;
-                    case 0x07: /* Prefixes */
-			if (cdp_print_prefixes(tptr, len) < 0)
-                            goto trunc;
+		    case 0x07: /* Prefixes */
+			if (cdp_print_prefixes(ndo, tptr, len) < 0)
+			    goto trunc;
 			break;
-                    case 0x08: /* Protocol Hello Option - not documented */
+		    case 0x08: /* Protocol Hello Option - not documented */
 			break;
-                    case 0x09: /* VTP Mgmt Domain  - not documented */
-                        printf("'");
-                        fn_printn(tptr, len, NULL);
-                        printf("'");
+		    case 0x09: /* VTP Mgmt Domain  - CDPv2 */
+			ND_PRINT((ndo, "'"));
+			(void)fn_printn(ndo, tptr, len, NULL);
+			ND_PRINT((ndo, "'"));
 			break;
-                    case 0x0a: /* Native VLAN ID - not documented */
-			printf("%d",EXTRACT_16BITS(tptr));
+		    case 0x0a: /* Native VLAN ID - CDPv2 */
+			if (len < 2)
+			    goto trunc;
+			ND_PRINT((ndo, "%d", EXTRACT_16BITS(tptr)));
 			break;
-                    case 0x0b: /* Duplex - not documented */
-			printf("%s", *(tptr) ? "full": "half");
+		    case 0x0b: /* Duplex - CDPv2 */
+			if (len < 1)
+			    goto trunc;
+			ND_PRINT((ndo, "%s", *(tptr) ? "full": "half"));
 			break;
 
-                    /* http://www.cisco.com/univercd/cc/td/doc/product/voice/ata/atarn/186rn21m.htm
-                     * plus more details from other sources
-                     */
-                    case 0x0e: /* ATA-186 VoIP VLAN request - incomplete doc. */
-			printf("app %d, vlan %d",
-                               *(tptr), EXTRACT_16BITS(tptr+1));
+		    /* http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cata/186/2_12_m/english/release/notes/186rn21m.html
+		     * plus more details from other sources
+		     */
+		    case 0x0e: /* ATA-186 VoIP VLAN request - incomplete doc. */
+			if (len < 3)
+			    goto trunc;
+			ND_PRINT((ndo, "app %d, vlan %d", *(tptr), EXTRACT_16BITS(tptr + 1)));
 			break;
-                    case 0x10: /* ATA-186 VoIP VLAN assignment - incomplete doc. */
-			printf("%1.2fW",
-                               cdp_get_number(tptr, len)/1000.0 );
+		    case 0x10: /* ATA-186 VoIP VLAN assignment - incomplete doc. */
+			ND_PRINT((ndo, "%1.2fW", cdp_get_number(tptr, len) / 1000.0));
 			break;
-                    case 0x11: /* MTU - not documented */
-			printf("%u bytes", EXTRACT_32BITS(tptr));
+		    case 0x11: /* MTU - not documented */
+			if (len < 4)
+			    goto trunc;
+			ND_PRINT((ndo, "%u bytes", EXTRACT_32BITS(tptr)));
 			break;
-                    case 0x12: /* AVVID trust bitmap - not documented */
-			printf("0x%02x", *(tptr) );
+		    case 0x12: /* AVVID trust bitmap - not documented */
+			if (len < 1)
+			    goto trunc;
+			ND_PRINT((ndo, "0x%02x", *(tptr)));
 			break;
-                    case 0x13: /* AVVID untrusted port CoS - not documented */
-			printf("0x%02x", *(tptr));
+		    case 0x13: /* AVVID untrusted port CoS - not documented */
+			if (len < 1)
+			    goto trunc;
+			ND_PRINT((ndo, "0x%02x", *(tptr)));
 			break;
-                    case 0x14: /* System Name - not documented */
-                        printf("'");
-                        fn_printn(tptr, len, NULL);
-                        printf("'");
+		    case 0x14: /* System Name - not documented */
+			ND_PRINT((ndo, "'"));
+			(void)fn_printn(ndo, tptr, len, NULL);
+			ND_PRINT((ndo, "'"));
 			break;
-                    case 0x16: /* System Object ID - not documented */
-			if (cdp_print_addr(tptr, len) < 0)
+		    case 0x16: /* System Object ID - not documented */
+			if (cdp_print_addr(ndo, tptr, len) < 0)
 				goto trunc;
 			break;
-                    case 0x17: /* Physical Location - not documented */
-			printf("0x%02x", *(tptr));
+		    case 0x17: /* Physical Location - not documented */
+			if (len < 1)
+			    goto trunc;
+			ND_PRINT((ndo, "0x%02x", *(tptr)));
 			if (len > 1) {
-				printf("/");
-	                        fn_printn(tptr + 1, len - 1, NULL);
-	                }
+				ND_PRINT((ndo, "/"));
+				(void)fn_printn(ndo, tptr + 1, len - 1, NULL);
+			}
 			break;
-                    default:
-                        print_unknown_data(tptr,"\n\t  ",len);
+		    default:
+			print_unknown_data(ndo, tptr, "\n\t  ", len);
 			break;
-                    }
-                }
-		/* avoid infinite loop */
-		if (len == 0)
-			break;
+		    }
+		}
 		tptr = tptr+len;
 	}
-        if (vflag < 1)
-            printf(", length %u",caplen);
+	if (ndo->ndo_vflag < 1)
+	    ND_PRINT((ndo, ", length %u", caplen));
 
 	return;
 trunc:
-	printf("[|cdp]");
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
@@ -247,29 +273,32 @@
 #define PT_IEEE_802_2		2	/* IEEE 802.2 LLC header */
 
 static int
-cdp_print_addr(const u_char * p, int l)
+cdp_print_addr(netdissect_options *ndo,
+	       const u_char * p, int l)
 {
 	int pt, pl, al, num;
 	const u_char *endp = p + l;
 #ifdef INET6
-	static u_char prot_ipv6[] = {
+	static const u_char prot_ipv6[] = {
 		0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
 	};
 #endif
 
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 4);
+	if (p + 4 > endp)
+		goto trunc;
 	num = EXTRACT_32BITS(p);
 	p += 4;
 
 	while (p < endp && num >= 0) {
-		TCHECK2(*p, 2);
+		ND_TCHECK2(*p, 2);
 		if (p + 2 > endp)
 			goto trunc;
 		pt = p[0];		/* type of "protocol" field */
 		pl = p[1];		/* length of "protocol" field */
 		p += 2;
 
-		TCHECK2(p[pl], 2);
+		ND_TCHECK2(p[pl], 2);
 		if (p + pl + 2 > endp)
 			goto trunc;
 		al = EXTRACT_16BITS(&p[pl]);	/* address length */
@@ -282,12 +311,10 @@
 			 */
 			p += 3;
 
-			TCHECK2(*p, 4);
+			ND_TCHECK2(*p, 4);
 			if (p + 4 > endp)
 				goto trunc;
-			printf("IPv4 (%u) %s",
-                               num,
-                               ipaddr_string(p));
+			ND_PRINT((ndo, "IPv4 (%u) %s", num, ipaddr_string(ndo, p)));
 			p += 4;
 		}
 #ifdef INET6
@@ -300,13 +327,11 @@
 			 * Ethertype, address length = 16
 			 */
 			p += 10;
-			TCHECK2(*p, al);
+			ND_TCHECK2(*p, al);
 			if (p + al > endp)
 				goto trunc;
 
-			printf("IPv6 (%u) %s",
-                               num,
-                               ip6addr_string(p));
+			ND_PRINT((ndo, "IPv6 (%u) %s", num, ip6addr_string(ndo, p)));
 			p += al;
 		}
 #endif
@@ -314,27 +339,27 @@
 			/*
 			 * Generic case: just print raw data
 			 */
-			TCHECK2(*p, pl);
+			ND_TCHECK2(*p, pl);
 			if (p + pl > endp)
 				goto trunc;
-			printf("pt=0x%02x, pl=%d, pb=", *(p - 2), pl);
+			ND_PRINT((ndo, "pt=0x%02x, pl=%d, pb=", *(p - 2), pl));
 			while (pl-- > 0)
-				printf(" %02x", *p++);
-			TCHECK2(*p, 2);
+				ND_PRINT((ndo, " %02x", *p++));
+			ND_TCHECK2(*p, 2);
 			if (p + 2 > endp)
 				goto trunc;
 			al = (*p << 8) + *(p + 1);
-			printf(", al=%d, a=", al);
+			ND_PRINT((ndo, ", al=%d, a=", al));
 			p += 2;
-			TCHECK2(*p, al);
+			ND_TCHECK2(*p, al);
 			if (p + al > endp)
 				goto trunc;
 			while (al-- > 0)
-				printf(" %02x", *p++);
+				ND_PRINT((ndo, " %02x", *p++));
 		}
 		num--;
 		if (num)
-			printf(" ");
+			ND_PRINT((ndo, " "));
 	}
 
 	return 0;
@@ -345,15 +370,16 @@
 
 
 static int
-cdp_print_prefixes(const u_char * p, int l)
+cdp_print_prefixes(netdissect_options *ndo,
+		   const u_char * p, int l)
 {
 	if (l % 5)
 		goto trunc;
 
-	printf(" IPv4 Prefixes (%d):", l / 5);
+	ND_PRINT((ndo, " IPv4 Prefixes (%d):", l / 5));
 
 	while (l > 0) {
-		printf(" %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]);
+		ND_PRINT((ndo, " %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]));
 		l -= 5;
 		p += 5;
 	}
diff --git a/print-cfm.c b/print-cfm.c
index 5df498c..a85eec0 100644
--- a/print-cfm.c
+++ b/print-cfm.c
@@ -17,11 +17,7 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cfm.c,v 1.5 2007-07-24 16:01:42 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -29,8 +25,6 @@
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 
 #include "interface.h"
 #include "extract.h"
@@ -39,17 +33,11 @@
 #include "oui.h"
 #include "af.h"
 
-/*
- * Prototypes
- */
-const char * cfm_egress_id_string(register const u_char *);
-int cfm_mgmt_addr_print(register const u_char *);
-
 struct cfm_common_header_t {
-    u_int8_t mdlevel_version;
-    u_int8_t opcode;
-    u_int8_t flags;
-    u_int8_t first_tlv_offset;
+    uint8_t mdlevel_version;
+    uint8_t opcode;
+    uint8_t flags;
+    uint8_t first_tlv_offset;
 };
 
 #define	CFM_VERSION 0
@@ -75,13 +63,13 @@
  * Message Formats.
  */
 struct cfm_ccm_t {
-    u_int8_t sequence[4];
-    u_int8_t ma_epi[2];
-    u_int8_t md_nameformat;
-    u_int8_t md_namelength;
-    u_int8_t md_name[46]; /* md name and short ma name */
-    u_int8_t reserved_itu[16];
-    u_int8_t reserved[6];
+    uint8_t sequence[4];
+    uint8_t ma_epi[2];
+    uint8_t md_nameformat;
+    uint8_t md_namelength;
+    uint8_t md_name[46]; /* md name and short ma name */
+    uint8_t reserved_itu[16];
+    uint8_t reserved[6];
 };
 
 /*
@@ -126,17 +114,17 @@
 };
 
 struct cfm_lbm_t {
-    u_int8_t transaction_id[4];
-    u_int8_t reserved[4];
+    uint8_t transaction_id[4];
+    uint8_t reserved[4];
 };
 
 struct cfm_ltm_t {
-    u_int8_t transaction_id[4];
-    u_int8_t egress_id[8];
-    u_int8_t ttl;
-    u_int8_t original_mac[ETHER_ADDR_LEN];
-    u_int8_t target_mac[ETHER_ADDR_LEN];
-    u_int8_t reserved[3];
+    uint8_t transaction_id[4];
+    uint8_t egress_id[8];
+    uint8_t ttl;
+    uint8_t original_mac[ETHER_ADDR_LEN];
+    uint8_t target_mac[ETHER_ADDR_LEN];
+    uint8_t reserved[3];
 };
 
 static const struct tok cfm_ltm_flag_values[] = {
@@ -145,17 +133,18 @@
 };
 
 struct cfm_ltr_t {
-    u_int8_t transaction_id[4];
-    u_int8_t last_egress_id[8];
-    u_int8_t next_egress_id[8];
-    u_int8_t ttl;
-    u_int8_t replay_action;
-    u_int8_t reserved[6];
+    uint8_t transaction_id[4];
+    uint8_t last_egress_id[8];
+    uint8_t next_egress_id[8];
+    uint8_t ttl;
+    uint8_t replay_action;
+    uint8_t reserved[6];
 };
 
 static const struct tok cfm_ltr_flag_values[] = {
-    { 0x80, "Forwarded"},
-    { 0x40, "Terminal MEP"},
+    { 0x80, "UseFDB Only"},
+    { 0x40, "FwdYes"},
+    { 0x20, "Terminal MEP"},
     { 0, NULL}
 };
 
@@ -193,8 +182,8 @@
  */
 
 struct cfm_tlv_header_t {
-    u_int8_t type;
-    u_int8_t length[2];
+    uint8_t type;
+    uint8_t length[2];
 };
 
 /* FIXME define TLV formats */
@@ -236,9 +225,10 @@
 };
 
 
-int
-cfm_mgmt_addr_print(register const u_char *tptr) {
-
+static int
+cfm_mgmt_addr_print(netdissect_options *ndo,
+                    register const u_char *tptr)
+{
     u_int mgmt_addr_type;
     u_int hexdump =  FALSE;
 
@@ -248,21 +238,21 @@
      * is only once octet
      */
     mgmt_addr_type = *tptr;
-    printf("\n\t  Management Address Type %s (%u)",
+    ND_PRINT((ndo, "\n\t  Management Address Type %s (%u)",
            tok2str(af_values, "Unknown", mgmt_addr_type),
-           mgmt_addr_type);
+           mgmt_addr_type));
 
     /*
      * Resolve the passed in Address.
      */
     switch(mgmt_addr_type) {
     case AFNUM_INET:
-        printf(", %s", ipaddr_string(tptr + 1));
+        ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
         break;
 
 #ifdef INET6
     case AFNUM_INET6:
-        printf(", %s", ip6addr_string(tptr + 1));
+        ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
         break;
 #endif
 
@@ -277,24 +267,26 @@
 /*
  * The egress-ID string is a 16-Bit string plus a MAC address.
  */
-const char *
-cfm_egress_id_string(register const u_char *tptr) {
+static const char *
+cfm_egress_id_string(netdissect_options *ndo, register const u_char *tptr)
+{
     static char egress_id_buffer[80];
-    
+
     snprintf(egress_id_buffer, sizeof(egress_id_buffer),
              "MAC 0x%4x-%s",
              EXTRACT_16BITS(tptr),
-             etheraddr_string(tptr+2));
+             etheraddr_string(ndo, tptr+2));
 
     return egress_id_buffer;
 }
 
 void
-cfm_print(register const u_char *pptr, register u_int length) {
-
+cfm_print(netdissect_options *ndo,
+          register const u_char *pptr, register u_int length)
+{
     const struct cfm_common_header_t *cfm_common_header;
     const struct cfm_tlv_header_t *cfm_tlv_header;
-    const u_int8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
+    const uint8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
     u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval;
 
 
@@ -307,31 +299,31 @@
 
     tptr=pptr;
     cfm_common_header = (const struct cfm_common_header_t *)pptr;
-    TCHECK(*cfm_common_header);
+    ND_TCHECK(*cfm_common_header);
 
     /*
      * Sanity checking of the header.
      */
     if (CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version) != CFM_VERSION) {
-	printf("CFMv%u not supported, length %u",
-               CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length);
+	ND_PRINT((ndo, "CFMv%u not supported, length %u",
+               CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length));
 	return;
     }
 
-    printf("CFMv%u %s, MD Level %u, length %u",
+    ND_PRINT((ndo, "CFMv%u %s, MD Level %u, length %u",
            CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version),
            tok2str(cfm_opcode_values, "unknown (%u)", cfm_common_header->opcode),
            CFM_EXTRACT_MD_LEVEL(cfm_common_header->mdlevel_version),
-           length);
+           length));
 
     /*
      * In non-verbose mode just print the opcode and md-level.
      */
-    if (vflag < 1) {
+    if (ndo->ndo_vflag < 1) {
         return;
     }
 
-    printf("\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset);
+    ND_PRINT((ndo, "\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset));
 
     tptr += sizeof(const struct cfm_common_header_t);
     tlen = length - sizeof(struct cfm_common_header_t);
@@ -341,53 +333,53 @@
         msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr;
 
         ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags);
-        printf(", Flags [CCM Interval %u%s]",
+        ND_PRINT((ndo, ", Flags [CCM Interval %u%s]",
                ccm_interval,
                cfm_common_header->flags & CFM_CCM_RDI_FLAG ?
-               ", RDI" : "");
+               ", RDI" : ""));
 
         /*
          * Resolve the CCM interval field.
          */
         if (ccm_interval) {
-            printf("\n\t  CCM Interval %.3fs"
+            ND_PRINT((ndo, "\n\t  CCM Interval %.3fs"
                    ", min CCM Lifetime %.3fs, max CCM Lifetime %.3fs",
                    ccm_interval_base[ccm_interval],
                    ccm_interval_base[ccm_interval] * CCM_INTERVAL_MIN_MULTIPLIER,
-                   ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER);
+                   ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER));
         }
 
-        printf("\n\t  Sequence Number 0x%08x, MA-End-Point-ID 0x%04x",
+        ND_PRINT((ndo, "\n\t  Sequence Number 0x%08x, MA-End-Point-ID 0x%04x",
                EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence),
-               EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi));
+               EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi)));
 
 
         /*
          * Resolve the MD fields.
          */
-        printf("\n\t  MD Name Format %s (%u), MD Name length %u",
+        ND_PRINT((ndo, "\n\t  MD Name Format %s (%u), MD Name length %u",
                tok2str(cfm_md_nameformat_values, "Unknown",
                        msg_ptr.cfm_ccm->md_nameformat),
                msg_ptr.cfm_ccm->md_nameformat,
-               msg_ptr.cfm_ccm->md_namelength);
+               msg_ptr.cfm_ccm->md_namelength));
 
         if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
-            printf("\n\t  MD Name: ");
+            ND_PRINT((ndo, "\n\t  MD Name: "));
             switch (msg_ptr.cfm_ccm->md_nameformat) {
             case CFM_CCM_MD_FORMAT_DNS:
             case CFM_CCM_MD_FORMAT_CHAR:
-                safeputs((const char *)msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength);
+                safeputs(ndo, msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength);
                 break;
 
             case CFM_CCM_MD_FORMAT_MAC:
-                printf("\n\t  MAC %s", etheraddr_string(
-                           msg_ptr.cfm_ccm->md_name));
+                ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(ndo,
+                           msg_ptr.cfm_ccm->md_name)));
                 break;
 
                 /* FIXME add printers for those MD formats - hexdump for now */
             case CFM_CCM_MA_FORMAT_8021:
             default:
-                print_unknown_data(msg_ptr.cfm_ccm->md_name, "\n\t    ",
+                print_unknown_data(ndo, msg_ptr.cfm_ccm->md_name, "\n\t    ",
                                    msg_ptr.cfm_ccm->md_namelength);
             }
         }
@@ -400,16 +392,16 @@
         ma_namelength = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 1;
         ma_name = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 2;
 
-        printf("\n\t  MA Name-Format %s (%u), MA name length %u",
+        ND_PRINT((ndo, "\n\t  MA Name-Format %s (%u), MA name length %u",
                tok2str(cfm_ma_nameformat_values, "Unknown",
                        *ma_nameformat),
                *ma_nameformat,
-               *ma_namelength);        
+               *ma_namelength));
 
-        printf("\n\t  MA Name: ");
+        ND_PRINT((ndo, "\n\t  MA Name: "));
         switch (*ma_nameformat) {
         case CFM_CCM_MA_FORMAT_CHAR:
-            safeputs((const char *)ma_name, *ma_namelength);
+            safeputs(ndo, ma_name, *ma_namelength);
             break;
 
             /* FIXME add printers for those MA formats - hexdump for now */
@@ -418,45 +410,45 @@
         case CFM_CCM_MA_FORMAT_INT:
         case CFM_CCM_MA_FORMAT_VPN:
         default:
-            print_unknown_data(ma_name, "\n\t    ", *ma_namelength);
+            print_unknown_data(ndo, ma_name, "\n\t    ", *ma_namelength);
         }
         break;
 
     case CFM_OPCODE_LTM:
         msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr;
 
-        printf(", Flags [%s]",
-               bittok2str(cfm_ltm_flag_values, "none",  cfm_common_header->flags));
+        ND_PRINT((ndo, ", Flags [%s]",
+               bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)));
 
-        printf("\n\t  Transaction-ID 0x%08x, Egress-ID %s, ttl %u",
+        ND_PRINT((ndo, "\n\t  Transaction-ID 0x%08x, Egress-ID %s, ttl %u",
                EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id),
-               cfm_egress_id_string(msg_ptr.cfm_ltm->egress_id),
-               msg_ptr.cfm_ltm->ttl);
+               cfm_egress_id_string(ndo, msg_ptr.cfm_ltm->egress_id),
+               msg_ptr.cfm_ltm->ttl));
 
-        printf("\n\t  Original-MAC %s, Target-MAC %s",
-               etheraddr_string(msg_ptr.cfm_ltm->original_mac),
-               etheraddr_string(msg_ptr.cfm_ltm->target_mac));
+        ND_PRINT((ndo, "\n\t  Original-MAC %s, Target-MAC %s",
+               etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac),
+               etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac)));
         break;
 
     case CFM_OPCODE_LTR:
         msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr;
 
-        printf(", Flags [%s]",
-               bittok2str(cfm_ltr_flag_values, "none",  cfm_common_header->flags));
+        ND_PRINT((ndo, ", Flags [%s]",
+               bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)));
 
-        printf("\n\t  Transaction-ID 0x%08x, Last-Egress-ID %s",
+        ND_PRINT((ndo, "\n\t  Transaction-ID 0x%08x, Last-Egress-ID %s",
                EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id),
-               cfm_egress_id_string(msg_ptr.cfm_ltr->last_egress_id));
+               cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->last_egress_id)));
 
-        printf("\n\t  Next-Egress-ID %s, ttl %u",
-               cfm_egress_id_string(msg_ptr.cfm_ltr->next_egress_id),
-               msg_ptr.cfm_ltr->ttl);
+        ND_PRINT((ndo, "\n\t  Next-Egress-ID %s, ttl %u",
+               cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->next_egress_id),
+               msg_ptr.cfm_ltr->ttl));
 
-        printf("\n\t  Replay-Action %s (%u)",
+        ND_PRINT((ndo, "\n\t  Replay-Action %s (%u)",
                tok2str(cfm_ltr_replay_action_values,
                        "Unknown",
                        msg_ptr.cfm_ltr->replay_action),
-               msg_ptr.cfm_ltr->replay_action);
+               msg_ptr.cfm_ltr->replay_action));
         break;
 
         /*
@@ -467,7 +459,7 @@
     case CFM_OPCODE_LBM:
     default:
         if (tlen > cfm_common_header->first_tlv_offset) {
-            print_unknown_data(tptr, "\n\t  ",
+            print_unknown_data(ndo, tptr, "\n\t  ",
                                tlen -  cfm_common_header->first_tlv_offset);
         }
         break;
@@ -482,32 +474,32 @@
 
     tptr += cfm_common_header->first_tlv_offset;
     tlen -= cfm_common_header->first_tlv_offset;
-    
+
     while (tlen > 0) {
         cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr;
 
         /* Enough to read the tlv type ? */
-        TCHECK2(*tptr, 1);
+        ND_TCHECK2(*tptr, 1);
         cfm_tlv_type=cfm_tlv_header->type;
 
         if (cfm_tlv_type != CFM_TLV_END) {
             /* did we capture enough for fully decoding the object header ? */
-            TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));            
+            ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
             cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
         } else {
             cfm_tlv_len = 0;
         }
 
-        printf("\n\t%s TLV (0x%02x), length %u",
+        ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
                tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type),
                cfm_tlv_type,
-               cfm_tlv_len);
+               cfm_tlv_len));
 
         /* sanity check for not walking off and infinite loop check. */
         if ((cfm_tlv_type != CFM_TLV_END) &&
             ((cfm_tlv_len + sizeof(struct cfm_tlv_header_t) > tlen) ||
              (!cfm_tlv_len))) {
-            print_unknown_data(tptr,"\n\t  ",tlen);
+            print_unknown_data(ndo, tptr, "\n\t  ", tlen);
             return;
         }
 
@@ -517,7 +509,7 @@
 
         /* did we capture enough for fully decoding the object ? */
         if (cfm_tlv_type != CFM_TLV_END) {
-            TCHECK2(*tptr, cfm_tlv_len);
+            ND_TCHECK2(*tptr, cfm_tlv_len);
         }
         hexdump = FALSE;
 
@@ -527,22 +519,22 @@
             return;
 
         case CFM_TLV_PORT_STATUS:
-            printf(", Status: %s (%u)",
+            ND_PRINT((ndo, ", Status: %s (%u)",
                    tok2str(cfm_tlv_port_status_values, "Unknown", *tptr),
-                   *tptr);
+                   *tptr));
             break;
 
         case CFM_TLV_INTERFACE_STATUS:
-            printf(", Status: %s (%u)",
+            ND_PRINT((ndo, ", Status: %s (%u)",
                    tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr),
-                   *tptr);
+                   *tptr));
             break;
 
         case CFM_TLV_PRIVATE:
-            printf(", Vendor: %s (%u), Sub-Type %u",
+            ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u",
                    tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)),
                    EXTRACT_24BITS(tptr),
-                   *(tptr+3));
+                   *(tptr + 3)));
             hexdump = TRUE;
             break;
 
@@ -565,20 +557,20 @@
 
             if (chassis_id_length) {
                 chassis_id_type = *tptr;
-                printf("\n\t  Chassis-ID Type %s (%u), Chassis-ID length %u",
+                ND_PRINT((ndo, "\n\t  Chassis-ID Type %s (%u), Chassis-ID length %u",
                        tok2str(cfm_tlv_senderid_chassisid_values,
                                "Unknown",
                                chassis_id_type),
                        chassis_id_type,
-                       chassis_id_length);
+                       chassis_id_length));
 
                 switch (chassis_id_type) {
                 case CFM_CHASSIS_ID_MAC_ADDRESS:
-                    printf("\n\t  MAC %s", etheraddr_string(tptr+1));
+                    ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(ndo, tptr + 1)));
                     break;
 
                 case CFM_CHASSIS_ID_NETWORK_ADDRESS:
-                    hexdump |= cfm_mgmt_addr_print(tptr);
+                    hexdump |= cfm_mgmt_addr_print(ndo, tptr);
                     break;
 
                 case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */
@@ -586,7 +578,7 @@
                 case CFM_CHASSIS_ID_LOCAL:
                 case CFM_CHASSIS_ID_CHASSIS_COMPONENT:
                 case CFM_CHASSIS_ID_PORT_COMPONENT:
-                    safeputs((const char *)tptr+1, chassis_id_length);
+                    safeputs(ndo, tptr + 1, chassis_id_length);
                     break;
 
                 default:
@@ -611,7 +603,7 @@
             tlen--;
 
             if (mgmt_addr_length) {
-                hexdump |= cfm_mgmt_addr_print(tptr);
+                hexdump |= cfm_mgmt_addr_print(ndo, tptr);
             }
 
             tptr += mgmt_addr_length;
@@ -633,13 +625,13 @@
             break;
         }
         /* do we want to see an additional hexdump ? */
-        if (hexdump || vflag > 1)
-            print_unknown_data(tlv_ptr, "\n\t  ", cfm_tlv_len);
+        if (hexdump || ndo->ndo_vflag > 1)
+            print_unknown_data(ndo, tlv_ptr, "\n\t  ", cfm_tlv_len);
 
         tptr+=cfm_tlv_len;
         tlen-=cfm_tlv_len;
     }
     return;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
diff --git a/print-chdlc.c b/print-chdlc.c
index 36db69d..3951ef7 100644
--- a/print-chdlc.c
+++ b/print-chdlc.c
@@ -19,30 +19,22 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.43 2005-11-29 08:56:19 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "ethertype.h"
 #include "extract.h"
-#include "ppp.h"
 #include "chdlc.h"
 
-static void chdlc_slarp_print(const u_char *, u_int);
+static void chdlc_slarp_print(netdissect_options *, const u_char *, u_int);
 
-static const struct tok chdlc_cast_values[] = { 
+static const struct tok chdlc_cast_values[] = {
     { CHDLC_UNICAST, "unicast" },
     { CHDLC_BCAST, "bcast" },
     { 0, NULL}
@@ -51,29 +43,30 @@
 
 /* Standard CHDLC printer */
 u_int
-chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
 	register u_int length = h->len;
 	register u_int caplen = h->caplen;
 
 	if (caplen < CHDLC_HDRLEN) {
-		printf("[|chdlc]");
+		ND_PRINT((ndo, "[|chdlc]"));
 		return (caplen);
 	}
-        return (chdlc_print(p,length));
+        return (chdlc_print(ndo, p,length));
 }
 
 u_int
-chdlc_print(register const u_char *p, u_int length) {
+chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)
+{
 	u_int proto;
 
 	proto = EXTRACT_16BITS(&p[2]);
-	if (eflag) {
-                printf("%s, ethertype %s (0x%04x), length %u: ",
+	if (ndo->ndo_eflag) {
+                ND_PRINT((ndo, "%s, ethertype %s (0x%04x), length %u: ",
                        tok2str(chdlc_cast_values, "0x%02x", p[0]),
                        tok2str(ethertype_values, "Unknown", proto),
                        proto,
-                       length);
+                       length));
 	}
 
 	length -= CHDLC_HDRLEN;
@@ -81,15 +74,13 @@
 
 	switch (proto) {
 	case ETHERTYPE_IP:
-		ip_print(gndo, p, length);
+		ip_print(ndo, p, length);
 		break;
-#ifdef INET6
 	case ETHERTYPE_IPV6:
-		ip6_print(gndo, p, length);
+		ip6_print(ndo, p, length);
 		break;
-#endif
 	case CHDLC_TYPE_SLARP:
-		chdlc_slarp_print(p, length);
+		chdlc_slarp_print(ndo, p, length);
 		break;
 #if 0
 	case CHDLC_TYPE_CDP:
@@ -98,20 +89,20 @@
 #endif
         case ETHERTYPE_MPLS:
         case ETHERTYPE_MPLS_MULTI:
-                mpls_print(p, length);
+                mpls_print(ndo, p, length);
 		break;
         case ETHERTYPE_ISO:
                 /* is the fudge byte set ? lets verify by spotting ISO headers */
                 if (*(p+1) == 0x81 ||
                     *(p+1) == 0x82 ||
                     *(p+1) == 0x83)
-                    isoclns_print(p+1, length-1, length-1);
+                    isoclns_print(ndo, p + 1, length - 1, length - 1);
                 else
-                    isoclns_print(p, length, length);
+                    isoclns_print(ndo, p, length, length);
                 break;
 	default:
-                if (!eflag)
-                        printf("unknown CHDLC protocol (0x%04x)", proto);
+                if (!ndo->ndo_eflag)
+                        ND_PRINT((ndo, "unknown CHDLC protocol (0x%04x)", proto));
                 break;
 	}
 
@@ -122,19 +113,19 @@
  * The fixed-length portion of a SLARP packet.
  */
 struct cisco_slarp {
-	u_int8_t code[4];
+	uint8_t code[4];
 #define SLARP_REQUEST	0
 #define SLARP_REPLY	1
 #define SLARP_KEEPALIVE	2
 	union {
 		struct {
-			u_int8_t addr[4];
-			u_int8_t mask[4];
+			uint8_t addr[4];
+			uint8_t mask[4];
 		} addr;
 		struct {
-			u_int8_t myseq[4];
-			u_int8_t yourseq[4];
-			u_int8_t rel[2];
+			uint8_t myseq[4];
+			uint8_t yourseq[4];
+			uint8_t rel[2];
 		} keep;
 	} un;
 };
@@ -143,20 +134,20 @@
 #define SLARP_MAX_LEN	18
 
 static void
-chdlc_slarp_print(const u_char *cp, u_int length)
+chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
 {
 	const struct cisco_slarp *slarp;
         u_int sec,min,hrs,days;
 
-        printf("SLARP (length: %u), ",length);
+	ND_PRINT((ndo, "SLARP (length: %u), ",length));
 	if (length < SLARP_MIN_LEN)
 		goto trunc;
 
 	slarp = (const struct cisco_slarp *)cp;
-	TCHECK2(*slarp, SLARP_MIN_LEN);
+	ND_TCHECK2(*slarp, SLARP_MIN_LEN);
 	switch (EXTRACT_32BITS(&slarp->code)) {
 	case SLARP_REQUEST:
-		printf("request");
+		ND_PRINT((ndo, "request"));
 		/*
 		 * At least according to William "Chops" Westfield's
 		 * message in
@@ -168,42 +159,41 @@
 		 */
 		break;
 	case SLARP_REPLY:
-		printf("reply %s/%s",
-			ipaddr_string(&slarp->un.addr.addr),
-			ipaddr_string(&slarp->un.addr.mask));
+		ND_PRINT((ndo, "reply %s/%s",
+			ipaddr_string(ndo, &slarp->un.addr.addr),
+			ipaddr_string(ndo, &slarp->un.addr.mask)));
 		break;
 	case SLARP_KEEPALIVE:
-		printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
+		ND_PRINT((ndo, "keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
                        EXTRACT_32BITS(&slarp->un.keep.myseq),
                        EXTRACT_32BITS(&slarp->un.keep.yourseq),
-                       EXTRACT_16BITS(&slarp->un.keep.rel));
+                       EXTRACT_16BITS(&slarp->un.keep.rel)));
 
                 if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */
                         cp += SLARP_MIN_LEN;
-                        if (!TTEST2(*cp, 4))
-                                goto trunc;
+                        ND_TCHECK2(*cp, 4);
                         sec = EXTRACT_32BITS(cp) / 1000;
                         min = sec / 60; sec -= min * 60;
                         hrs = min / 60; min -= hrs * 60;
                         days = hrs / 24; hrs -= days * 24;
-                        printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec);
+                        ND_PRINT((ndo, ", link uptime=%ud%uh%um%us",days,hrs,min,sec));
                 }
 		break;
 	default:
-		printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code));
-                if (vflag <= 1)
-                    print_unknown_data(cp+4,"\n\t",length-4);
+		ND_PRINT((ndo, "0x%02x unknown", EXTRACT_32BITS(&slarp->code)));
+                if (ndo->ndo_vflag <= 1)
+                    print_unknown_data(ndo,cp+4,"\n\t",length-4);
 		break;
 	}
 
-	if (SLARP_MAX_LEN < length && vflag)
-		printf(", (trailing junk: %d bytes)", length - SLARP_MAX_LEN);
-        if (vflag > 1)
-            print_unknown_data(cp+4,"\n\t",length-4);
+	if (SLARP_MAX_LEN < length && ndo->ndo_vflag)
+		ND_PRINT((ndo, ", (trailing junk: %d bytes)", length - SLARP_MAX_LEN));
+        if (ndo->ndo_vflag > 1)
+            print_unknown_data(ndo,cp+4,"\n\t",length-4);
 	return;
 
 trunc:
-	printf("[|slarp]");
+	ND_PRINT((ndo, "[|slarp]"));
 }
 
 
diff --git a/print-cip.c b/print-cip.c
index e9d672f..91abe08 100644
--- a/print-cip.c
+++ b/print-cip.c
@@ -20,11 +20,7 @@
  *
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.26 2005-07-07 01:22:17 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -33,17 +29,12 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
 #include "interface.h"
 #include "addrtoname.h"
-#include "ethertype.h"
-#include "ether.h"
 
 #define RFC1483LLC_LEN	8
 
-static unsigned char rfcllc[] = {
+static const unsigned char rfcllc[] = {
 	0xaa,	/* DSAP: non-ISO */
 	0xaa,	/* SSAP: non-ISO */
 	0x03,	/* Ctrl: Unnumbered Information Command PDU */
@@ -52,12 +43,12 @@
 	0x00 };
 
 static inline void
-cip_print(int length)
+cip_print(netdissect_options *ndo, int length)
 {
 	/*
 	 * There is no MAC-layer header, so just print the length.
 	 */
-	printf("%d: ", length);
+	ND_PRINT((ndo, "%d: ", length));
 }
 
 /*
@@ -67,41 +58,41 @@
  * is the number of bytes actually captured.
  */
 u_int
-cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
+cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	u_int length = h->len;
 	u_short extracted_ethertype;
 
 	if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
-		printf("[|cip]");
+		ND_PRINT((ndo, "[|cip]"));
 		return (0);
 	}
 
-	if (eflag)
-		cip_print(length);
+	if (ndo->ndo_eflag)
+		cip_print(ndo, length);
 
 	if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
 		/*
 		 * LLC header is present.  Try to print it & higher layers.
 		 */
-		if (llc_print(p, length, caplen, NULL, NULL,
+		if (llc_print(ndo, p, length, caplen, NULL, NULL,
 		    &extracted_ethertype) == 0) {
 			/* ether_type not known, print raw packet */
-			if (!eflag)
-				cip_print(length);
+			if (!ndo->ndo_eflag)
+				cip_print(ndo, length);
 			if (extracted_ethertype) {
-				printf("(LLC %s) ",
-			       etherproto_string(htons(extracted_ethertype)));
+				ND_PRINT((ndo, "(LLC %s) ",
+			       etherproto_string(htons(extracted_ethertype))));
 			}
-			if (!suppress_default_print)
-				default_print(p, caplen);
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p, caplen);
 		}
 	} else {
 		/*
 		 * LLC header is absent; treat it as just IP.
 		 */
-		ip_print(gndo, p, length);
+		ip_print(ndo, p, length);
 	}
 
 	return (0);
diff --git a/print-cnfp.c b/print-cnfp.c
index 86d7128..d80d7fd 100644
--- a/print-cnfp.c
+++ b/print-cnfp.c
@@ -30,13 +30,15 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* Cisco NetFlow protocol */
+/*
+ * Cisco NetFlow protocol
+ *
+ * See
+ *
+ *    http://www.cisco.com/c/en/us/td/docs/net_mgmt/netflow_collection_engine/3-6/user/guide/format.html#wp1005892
+ */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.17 2005-04-20 20:53:18 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -53,49 +55,120 @@
 #include "tcp.h"
 #include "ipproto.h"
 
-struct nfhdr {
-	u_int32_t	ver_cnt;	/* version [15], and # of records */
-	u_int32_t	msys_uptime;
-	u_int32_t	utc_sec;
-	u_int32_t	utc_nsec;
-	u_int32_t	sequence;	/* v5 flow sequence number */
-	u_int32_t	reserved;	/* v5 only */
+struct nfhdr_v1 {
+	uint16_t	version;	/* version number */
+	uint16_t	count;		/* # of records */
+	uint32_t	msys_uptime;
+	uint32_t	utc_sec;
+	uint32_t	utc_nsec;
 };
 
-struct nfrec {
+struct nfrec_v1 {
 	struct in_addr	src_ina;
 	struct in_addr	dst_ina;
 	struct in_addr	nhop_ina;
-	u_int32_t	ifaces;		/* src,dst ifaces */
-	u_int32_t	packets;
-	u_int32_t	octets;
-	u_int32_t	start_time;	/* sys_uptime value */
-	u_int32_t	last_time;	/* sys_uptime value */
-	u_int32_t	ports;		/* src,dst ports */
-	u_int32_t	proto_tos;	/* proto, tos, pad, flags(v5) */
-	u_int32_t	asses;		/* v1: flags; v5: src,dst AS */
-	u_int32_t	masks;		/* src,dst addr prefix; v6: encaps */
+	uint16_t	input;		/* SNMP index of input interface */
+	uint16_t	output;		/* SNMP index of output interface */
+	uint32_t	packets;	/* packets in the flow */
+	uint32_t	octets;		/* layer 3 octets in the packets of the flow */
+	uint32_t	start_time;	/* sys_uptime value at start of flow */
+	uint32_t	last_time;	/* sys_uptime value when last packet of flow was received */
+	uint16_t	srcport;	/* TCP/UDP source port or equivalent */
+	uint16_t	dstport;	/* TCP/UDP source port or equivalent */
+	uint16_t	pad1;		/* pad */
+	uint8_t		proto;		/* IP protocol type */
+	uint8_t		tos;		/* IP type of service */
+	uint8_t		tcp_flags;	/* cumulative OR of TCP flags */
+	uint8_t		pad[3];		/* padding */
+	uint32_t	reserved;	/* unused */
+};
+
+struct nfhdr_v5 {
+	uint16_t	version;	/* version number */
+	uint16_t	count;		/* # of records */
+	uint32_t	msys_uptime;
+	uint32_t	utc_sec;
+	uint32_t	utc_nsec;
+	uint32_t	sequence;	/* flow sequence number */
+	uint8_t		engine_type;	/* type of flow-switching engine */
+	uint8_t		engine_id;	/* slot number of the flow-switching engine */
+	uint16_t	sampling_interval; /* sampling mode and interval */
+};
+
+struct nfrec_v5 {
+	struct in_addr	src_ina;
+	struct in_addr	dst_ina;
+	struct in_addr	nhop_ina;
+	uint16_t	input;		/* SNMP index of input interface */
+	uint16_t	output;		/* SNMP index of output interface */
+	uint32_t	packets;	/* packets in the flow */
+	uint32_t	octets;		/* layer 3 octets in the packets of the flow */
+	uint32_t	start_time;	/* sys_uptime value at start of flow */
+	uint32_t	last_time;	/* sys_uptime value when last packet of flow was received */
+	uint16_t	srcport;	/* TCP/UDP source port or equivalent */
+	uint16_t	dstport;	/* TCP/UDP source port or equivalent */
+	uint8_t		pad1;		/* pad */
+	uint8_t		tcp_flags;	/* cumulative OR of TCP flags */
+	uint8_t		proto;		/* IP protocol type */
+	uint8_t		tos;		/* IP type of service */
+	uint16_t	src_as;		/* AS number of the source */
+	uint16_t	dst_as;		/* AS number of the destination */
+	uint8_t		src_mask;	/* source address mask bits */
+	uint8_t		dst_mask;	/* destination address prefix mask bits */
+	uint16_t	pad2;
 	struct in_addr	peer_nexthop;	/* v6: IP address of the nexthop within the peer (FIB)*/
 };
 
-void
-cnfp_print(const u_char *cp, const u_char *bp _U_)
+struct nfhdr_v6 {
+	uint16_t	version;	/* version number */
+	uint16_t	count;		/* # of records */
+	uint32_t	msys_uptime;
+	uint32_t	utc_sec;
+	uint32_t	utc_nsec;
+	uint32_t	sequence;	/* v5 flow sequence number */
+	uint32_t	reserved;	/* v5 only */
+};
+
+struct nfrec_v6 {
+	struct in_addr	src_ina;
+	struct in_addr	dst_ina;
+	struct in_addr	nhop_ina;
+	uint16_t	input;		/* SNMP index of input interface */
+	uint16_t	output;		/* SNMP index of output interface */
+	uint32_t	packets;	/* packets in the flow */
+	uint32_t	octets;		/* layer 3 octets in the packets of the flow */
+	uint32_t	start_time;	/* sys_uptime value at start of flow */
+	uint32_t	last_time;	/* sys_uptime value when last packet of flow was received */
+	uint16_t	srcport;	/* TCP/UDP source port or equivalent */
+	uint16_t	dstport;	/* TCP/UDP source port or equivalent */
+	uint8_t		pad1;		/* pad */
+	uint8_t		tcp_flags;	/* cumulative OR of TCP flags */
+	uint8_t		proto;		/* IP protocol type */
+	uint8_t		tos;		/* IP type of service */
+	uint16_t	src_as;		/* AS number of the source */
+	uint16_t	dst_as;		/* AS number of the destination */
+	uint8_t		src_mask;	/* source address mask bits */
+	uint8_t		dst_mask;	/* destination address prefix mask bits */
+	uint16_t	flags;
+	struct in_addr	peer_nexthop;	/* v6: IP address of the nexthop within the peer (FIB)*/
+};
+
+static void
+cnfp_v1_print(netdissect_options *ndo, const u_char *cp)
 {
-	register const struct nfhdr *nh;
-	register const struct nfrec *nr;
+	register const struct nfhdr_v1 *nh;
+	register const struct nfrec_v1 *nr;
 	struct protoent *pent;
 	int nrecs, ver;
 #if 0
 	time_t t;
 #endif
 
-	nh = (const struct nfhdr *)cp;
+	nh = (const struct nfhdr_v1 *)cp;
+	ND_TCHECK(*nh);
 
-	if ((const u_char *)(nh + 1) > snapend)
-		return;
-
-	nrecs = EXTRACT_32BITS(&nh->ver_cnt) & 0xffff;
-	ver = (EXTRACT_32BITS(&nh->ver_cnt) & 0xffff0000) >> 16;
+	ver = EXTRACT_16BITS(&nh->version);
+	nrecs = EXTRACT_32BITS(&nh->count);
 #if 0
 	/*
 	 * This is seconds since the UN*X epoch, and is followed by
@@ -105,86 +178,299 @@
 	t = EXTRACT_32BITS(&nh->utc_sec);
 #endif
 
-	printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+	ND_PRINT((ndo, "NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
 	       EXTRACT_32BITS(&nh->msys_uptime)/1000,
 	       EXTRACT_32BITS(&nh->msys_uptime)%1000,
-	       EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec));
+	       EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)));
 
-	if (ver == 5 || ver == 6) {
-		printf("#%u, ", EXTRACT_32BITS(&nh->sequence));
-		nr = (const struct nfrec *)&nh[1];
-		snaplen -= 24;
-	} else {
-		nr = (const struct nfrec *)&nh->sequence;
-		snaplen -= 16;
-	}
+	nr = (const struct nfrec_v1 *)&nh[1];
 
-	printf("%2u recs", nrecs);
+	ND_PRINT((ndo, "%2u recs", nrecs));
 
-	for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) {
+	for (; nrecs != 0; nr++, nrecs--) {
 		char buf[20];
 		char asbuf[20];
 
-		printf("\n  started %u.%03u, last %u.%03u",
+		/*
+		 * Make sure we have the entire record.
+		 */
+		ND_TCHECK(*nr);
+		ND_PRINT((ndo, "\n  started %u.%03u, last %u.%03u",
 		       EXTRACT_32BITS(&nr->start_time)/1000,
 		       EXTRACT_32BITS(&nr->start_time)%1000,
 		       EXTRACT_32BITS(&nr->last_time)/1000,
-		       EXTRACT_32BITS(&nr->last_time)%1000);
+		       EXTRACT_32BITS(&nr->last_time)%1000));
 
 		asbuf[0] = buf[0] = '\0';
-		if (ver == 5 || ver == 6) {
-			snprintf(buf, sizeof(buf), "/%u",
-				 (EXTRACT_32BITS(&nr->masks) >> 24) & 0xff);
-			snprintf(asbuf, sizeof(asbuf), ":%u",
-				 (EXTRACT_32BITS(&nr->asses) >> 16) & 0xffff);
-		}
-		printf("\n    %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
-			EXTRACT_32BITS(&nr->ports) >> 16);
+		ND_PRINT((ndo, "\n    %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
+			EXTRACT_16BITS(&nr->srcport)));
 
-		if (ver == 5 || ver ==6) {
-			snprintf(buf, sizeof(buf), "/%d",
-				 (EXTRACT_32BITS(&nr->masks) >> 16) & 0xff);
-			snprintf(asbuf, sizeof(asbuf), ":%u",
-				 EXTRACT_32BITS(&nr->asses) & 0xffff);
-		}
-		printf("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
-			EXTRACT_32BITS(&nr->ports) & 0xffff);
+		ND_PRINT((ndo, "> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
+			EXTRACT_16BITS(&nr->dstport)));
 
-		printf(">> %s\n    ", intoa(nr->nhop_ina.s_addr));
+		ND_PRINT((ndo, ">> %s\n    ", intoa(nr->nhop_ina.s_addr)));
 
-		pent = getprotobynumber((EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
-		if (!pent || nflag)
-			printf("%u ",
-			       (EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
+		pent = getprotobynumber(nr->proto);
+		if (!pent || ndo->ndo_nflag)
+			ND_PRINT((ndo, "%u ", nr->proto));
 		else
-			printf("%s ", pent->p_name);
+			ND_PRINT((ndo, "%s ", pent->p_name));
 
 		/* tcp flags for tcp only */
 		if (pent && pent->p_proto == IPPROTO_TCP) {
 			int flags;
-			if (ver == 1)
-				flags = (EXTRACT_32BITS(&nr->asses) >> 24) & 0xff;
-			else
-				flags = (EXTRACT_32BITS(&nr->proto_tos) >> 16) & 0xff;
-			if (flags & TH_FIN)	putchar('F');
-			if (flags & TH_SYN)	putchar('S');
-			if (flags & TH_RST)	putchar('R');
-			if (flags & TH_PUSH)	putchar('P');
-			if (flags & TH_ACK)	putchar('A');
-			if (flags & TH_URG)	putchar('U');
-			if (flags)
-				putchar(' ');
+			flags = nr->tcp_flags;
+			ND_PRINT((ndo, "%s%s%s%s%s%s%s",
+				flags & TH_FIN  ? "F" : "",
+				flags & TH_SYN  ? "S" : "",
+				flags & TH_RST  ? "R" : "",
+				flags & TH_PUSH ? "P" : "",
+				flags & TH_ACK  ? "A" : "",
+				flags & TH_URG  ? "U" : "",
+				flags           ? " " : ""));
 		}
 
 		buf[0]='\0';
-		if (ver == 6) {
-			snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
-				 (EXTRACT_32BITS(&nr->masks) >> 8) & 0xff,
-				 (EXTRACT_32BITS(&nr->masks)) & 0xff);
-		}
-		printf("tos %u, %u (%u octets) %s",
-		       EXTRACT_32BITS(&nr->proto_tos) & 0xff,
+		ND_PRINT((ndo, "tos %u, %u (%u octets) %s",
+		       nr->tos,
 		       EXTRACT_32BITS(&nr->packets),
-		       EXTRACT_32BITS(&nr->octets), buf);
+		       EXTRACT_32BITS(&nr->octets), buf));
 	}
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|cnfp]"));
+	return;
+}
+
+static void
+cnfp_v5_print(netdissect_options *ndo, const u_char *cp)
+{
+	register const struct nfhdr_v5 *nh;
+	register const struct nfrec_v5 *nr;
+	struct protoent *pent;
+	int nrecs, ver;
+#if 0
+	time_t t;
+#endif
+
+	nh = (const struct nfhdr_v5 *)cp;
+	ND_TCHECK(*nh);
+
+	ver = EXTRACT_16BITS(&nh->version);
+	nrecs = EXTRACT_32BITS(&nh->count);
+#if 0
+	/*
+	 * This is seconds since the UN*X epoch, and is followed by
+	 * nanoseconds.  XXX - format it, rather than just dumping the
+	 * raw seconds-since-the-Epoch.
+	 */
+	t = EXTRACT_32BITS(&nh->utc_sec);
+#endif
+
+	ND_PRINT((ndo, "NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+	       EXTRACT_32BITS(&nh->msys_uptime)/1000,
+	       EXTRACT_32BITS(&nh->msys_uptime)%1000,
+	       EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)));
+
+	ND_PRINT((ndo, "#%u, ", EXTRACT_32BITS(&nh->sequence)));
+	nr = (const struct nfrec_v5 *)&nh[1];
+
+	ND_PRINT((ndo, "%2u recs", nrecs));
+
+	for (; nrecs != 0; nr++, nrecs--) {
+		char buf[20];
+		char asbuf[20];
+
+		/*
+		 * Make sure we have the entire record.
+		 */
+		ND_TCHECK(*nr);
+		ND_PRINT((ndo, "\n  started %u.%03u, last %u.%03u",
+		       EXTRACT_32BITS(&nr->start_time)/1000,
+		       EXTRACT_32BITS(&nr->start_time)%1000,
+		       EXTRACT_32BITS(&nr->last_time)/1000,
+		       EXTRACT_32BITS(&nr->last_time)%1000));
+
+		asbuf[0] = buf[0] = '\0';
+		snprintf(buf, sizeof(buf), "/%u", nr->src_mask);
+		snprintf(asbuf, sizeof(asbuf), ":%u",
+			EXTRACT_16BITS(&nr->src_as));
+		ND_PRINT((ndo, "\n    %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
+			EXTRACT_16BITS(&nr->srcport)));
+
+		snprintf(buf, sizeof(buf), "/%d", nr->dst_mask);
+		snprintf(asbuf, sizeof(asbuf), ":%u",
+			 EXTRACT_16BITS(&nr->dst_as));
+		ND_PRINT((ndo, "> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
+			EXTRACT_16BITS(&nr->dstport)));
+
+		ND_PRINT((ndo, ">> %s\n    ", intoa(nr->nhop_ina.s_addr)));
+
+		pent = getprotobynumber(nr->proto);
+		if (!pent || ndo->ndo_nflag)
+			ND_PRINT((ndo, "%u ", nr->proto));
+		else
+			ND_PRINT((ndo, "%s ", pent->p_name));
+
+		/* tcp flags for tcp only */
+		if (pent && pent->p_proto == IPPROTO_TCP) {
+			int flags;
+			flags = nr->tcp_flags;
+			ND_PRINT((ndo, "%s%s%s%s%s%s%s",
+				flags & TH_FIN  ? "F" : "",
+				flags & TH_SYN  ? "S" : "",
+				flags & TH_RST  ? "R" : "",
+				flags & TH_PUSH ? "P" : "",
+				flags & TH_ACK  ? "A" : "",
+				flags & TH_URG  ? "U" : "",
+				flags           ? " " : ""));
+		}
+
+		buf[0]='\0';
+		ND_PRINT((ndo, "tos %u, %u (%u octets) %s",
+		       nr->tos,
+		       EXTRACT_32BITS(&nr->packets),
+		       EXTRACT_32BITS(&nr->octets), buf));
+	}
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|cnfp]"));
+	return;
+}
+
+static void
+cnfp_v6_print(netdissect_options *ndo, const u_char *cp)
+{
+	register const struct nfhdr_v6 *nh;
+	register const struct nfrec_v6 *nr;
+	struct protoent *pent;
+	int nrecs, ver;
+#if 0
+	time_t t;
+#endif
+
+	nh = (const struct nfhdr_v6 *)cp;
+	ND_TCHECK(*nh);
+
+	ver = EXTRACT_16BITS(&nh->version);
+	nrecs = EXTRACT_32BITS(&nh->count);
+#if 0
+	/*
+	 * This is seconds since the UN*X epoch, and is followed by
+	 * nanoseconds.  XXX - format it, rather than just dumping the
+	 * raw seconds-since-the-Epoch.
+	 */
+	t = EXTRACT_32BITS(&nh->utc_sec);
+#endif
+
+	ND_PRINT((ndo, "NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+	       EXTRACT_32BITS(&nh->msys_uptime)/1000,
+	       EXTRACT_32BITS(&nh->msys_uptime)%1000,
+	       EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)));
+
+	ND_PRINT((ndo, "#%u, ", EXTRACT_32BITS(&nh->sequence)));
+	nr = (const struct nfrec_v6 *)&nh[1];
+
+	ND_PRINT((ndo, "%2u recs", nrecs));
+
+	for (; nrecs != 0; nr++, nrecs--) {
+		char buf[20];
+		char asbuf[20];
+
+		/*
+		 * Make sure we have the entire record.
+		 */
+		ND_TCHECK(*nr);
+		ND_PRINT((ndo, "\n  started %u.%03u, last %u.%03u",
+		       EXTRACT_32BITS(&nr->start_time)/1000,
+		       EXTRACT_32BITS(&nr->start_time)%1000,
+		       EXTRACT_32BITS(&nr->last_time)/1000,
+		       EXTRACT_32BITS(&nr->last_time)%1000));
+
+		asbuf[0] = buf[0] = '\0';
+		snprintf(buf, sizeof(buf), "/%u", nr->src_mask);
+		snprintf(asbuf, sizeof(asbuf), ":%u",
+			EXTRACT_16BITS(&nr->src_as));
+		ND_PRINT((ndo, "\n    %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
+			EXTRACT_16BITS(&nr->srcport)));
+
+		snprintf(buf, sizeof(buf), "/%d", nr->dst_mask);
+		snprintf(asbuf, sizeof(asbuf), ":%u",
+			 EXTRACT_16BITS(&nr->dst_as));
+		ND_PRINT((ndo, "> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
+			EXTRACT_16BITS(&nr->dstport)));
+
+		ND_PRINT((ndo, ">> %s\n    ", intoa(nr->nhop_ina.s_addr)));
+
+		pent = getprotobynumber(nr->proto);
+		if (!pent || ndo->ndo_nflag)
+			ND_PRINT((ndo, "%u ", nr->proto));
+		else
+			ND_PRINT((ndo, "%s ", pent->p_name));
+
+		/* tcp flags for tcp only */
+		if (pent && pent->p_proto == IPPROTO_TCP) {
+			int flags;
+			flags = nr->tcp_flags;
+			ND_PRINT((ndo, "%s%s%s%s%s%s%s",
+				flags & TH_FIN  ? "F" : "",
+				flags & TH_SYN  ? "S" : "",
+				flags & TH_RST  ? "R" : "",
+				flags & TH_PUSH ? "P" : "",
+				flags & TH_ACK  ? "A" : "",
+				flags & TH_URG  ? "U" : "",
+				flags           ? " " : ""));
+		}
+
+		buf[0]='\0';
+		snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
+			 (EXTRACT_16BITS(&nr->flags) >> 8) & 0xff,
+			 (EXTRACT_16BITS(&nr->flags)) & 0xff);
+		ND_PRINT((ndo, "tos %u, %u (%u octets) %s",
+		       nr->tos,
+		       EXTRACT_32BITS(&nr->packets),
+		       EXTRACT_32BITS(&nr->octets), buf));
+	}
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|cnfp]"));
+	return;
+}
+
+void
+cnfp_print(netdissect_options *ndo, const u_char *cp)
+{
+	int ver;
+
+	/*
+	 * First 2 bytes are the version number.
+	 */
+	ND_TCHECK2(*cp, 2);
+	ver = EXTRACT_16BITS(cp);
+	switch (ver) {
+
+	case 1:
+		cnfp_v1_print(ndo, cp);
+		break;
+
+	case 5:
+		cnfp_v5_print(ndo, cp);
+		break;
+
+	case 6:
+		cnfp_v6_print(ndo, cp);
+		break;
+
+	default:
+		ND_PRINT((ndo, "NetFlow v%x", ver));
+		break;
+	}
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|cnfp]"));
+	return;
 }
diff --git a/print-dccp.c b/print-dccp.c
index 79ea5f7..45468b5 100644
--- a/print-dccp.c
+++ b/print-dccp.c
@@ -7,19 +7,13 @@
  * BSD-style license that accompanies tcpdump or the GNU GPL version 2
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include "dccp.h"
-
 #include <stdio.h>
 #include <string.h>
 
@@ -32,6 +26,140 @@
 #endif
 #include "ipproto.h"
 
+/* RFC4340: Datagram Congestion Control Protocol (DCCP) */
+
+/**
+ * struct dccp_hdr - generic part of DCCP packet header, with a 24-bit
+ * sequence number
+ *
+ * @dccph_sport - Relevant port on the endpoint that sent this packet
+ * @dccph_dport - Relevant port on the other endpoint
+ * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
+ * @dccph_ccval - Used by the HC-Sender CCID
+ * @dccph_cscov - Parts of the packet that are covered by the Checksum field
+ * @dccph_checksum - Internet checksum, depends on dccph_cscov
+ * @dccph_x - 0 = 24 bit sequence number, 1 = 48
+ * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
+ * @dccph_seq - 24-bit sequence number
+ */
+struct dccp_hdr {
+	uint16_t	dccph_sport,
+			dccph_dport;
+	uint8_t		dccph_doff;
+	uint8_t		dccph_ccval_cscov;
+	uint16_t	dccph_checksum;
+	uint8_t		dccph_xtr;
+	uint8_t		dccph_seq[3];
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_ext - generic part of DCCP packet header, with a 48-bit
+ * sequence number
+ *
+ * @dccph_sport - Relevant port on the endpoint that sent this packet
+ * @dccph_dport - Relevant port on the other endpoint
+ * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
+ * @dccph_ccval - Used by the HC-Sender CCID
+ * @dccph_cscov - Parts of the packet that are covered by the Checksum field
+ * @dccph_checksum - Internet checksum, depends on dccph_cscov
+ * @dccph_x - 0 = 24 bit sequence number, 1 = 48
+ * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
+ * @dccph_seq - 48-bit sequence number
+ */
+struct dccp_hdr_ext {
+	uint16_t	dccph_sport,
+			dccph_dport;
+	uint8_t		dccph_doff;
+	uint8_t		dccph_ccval_cscov;
+	uint16_t	dccph_checksum;
+	uint8_t		dccph_xtr;
+	uint8_t		reserved;
+	uint8_t		dccph_seq[6];
+} UNALIGNED;
+
+#define DCCPH_CCVAL(dh)	(((dh)->dccph_ccval_cscov >> 4) & 0xF)
+#define DCCPH_CSCOV(dh)	(((dh)->dccph_ccval_cscov) & 0xF)
+
+#define DCCPH_X(dh)	((dh)->dccph_xtr & 1)
+#define DCCPH_TYPE(dh)	(((dh)->dccph_xtr >> 1) & 0xF)
+
+/**
+ * struct dccp_hdr_request - Conection initiation request header
+ *
+ * @dccph_req_service - Service to which the client app wants to connect
+ */
+struct dccp_hdr_request {
+	uint32_t	dccph_req_service;
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_response - Conection initiation response header
+ *
+ * @dccph_resp_ack - 48 bit ack number, contains GSR
+ * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
+ */
+struct dccp_hdr_response {
+	uint8_t				dccph_resp_ack[8];	/* always 8 bytes */
+	uint32_t			dccph_resp_service;
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_reset - Unconditionally shut down a connection
+ *
+ * @dccph_resp_ack - 48 bit ack number
+ * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
+ */
+struct dccp_hdr_reset {
+	uint8_t				dccph_reset_ack[8];	/* always 8 bytes */
+	uint8_t				dccph_reset_code,
+					dccph_reset_data[3];
+} UNALIGNED;
+
+enum dccp_pkt_type {
+	DCCP_PKT_REQUEST = 0,
+	DCCP_PKT_RESPONSE,
+	DCCP_PKT_DATA,
+	DCCP_PKT_ACK,
+	DCCP_PKT_DATAACK,
+	DCCP_PKT_CLOSEREQ,
+	DCCP_PKT_CLOSE,
+	DCCP_PKT_RESET,
+	DCCP_PKT_SYNC,
+	DCCP_PKT_SYNCACK
+};
+
+static const struct tok dccp_pkt_type_str[] = {
+	{ DCCP_PKT_REQUEST, "DCCP-Request" },
+	{ DCCP_PKT_RESPONSE, "DCCP-Response" },
+	{ DCCP_PKT_DATA, "DCCP-Data" },
+	{ DCCP_PKT_ACK, "DCCP-Ack" },
+	{ DCCP_PKT_DATAACK, "DCCP-DataAck" },
+	{ DCCP_PKT_CLOSEREQ, "DCCP-CloseReq" },
+	{ DCCP_PKT_CLOSE, "DCCP-Close" },
+	{ DCCP_PKT_RESET, "DCCP-Reset" },
+	{ DCCP_PKT_SYNC, "DCCP-Sync" },
+	{ DCCP_PKT_SYNCACK, "DCCP-SyncAck" },
+	{ 0, NULL}
+};
+
+enum dccp_reset_codes {
+	DCCP_RESET_CODE_UNSPECIFIED = 0,
+	DCCP_RESET_CODE_CLOSED,
+	DCCP_RESET_CODE_ABORTED,
+	DCCP_RESET_CODE_NO_CONNECTION,
+	DCCP_RESET_CODE_PACKET_ERROR,
+	DCCP_RESET_CODE_OPTION_ERROR,
+	DCCP_RESET_CODE_MANDATORY_ERROR,
+	DCCP_RESET_CODE_CONNECTION_REFUSED,
+	DCCP_RESET_CODE_BAD_SERVICE_CODE,
+	DCCP_RESET_CODE_TOO_BUSY,
+	DCCP_RESET_CODE_BAD_INIT_COOKIE,
+	DCCP_RESET_CODE_AGGRESSION_PENALTY,
+	__DCCP_RESET_CODE_LAST
+};
+
+static const char tstr[] = "[|dccp]";
+
 static const char *dccp_reset_codes[] = {
 	"unspecified",
 	"closed",
@@ -48,60 +176,60 @@
 };
 
 static const char *dccp_feature_nums[] = {
-	"reserved", 
+	"reserved",
 	"ccid",
 	"allow_short_seqno",
 	"sequence_window",
-	"ecn_incapable", 
-	"ack_ratio",     
+	"ecn_incapable",
+	"ack_ratio",
 	"send_ack_vector",
-	"send_ndp_count", 
-	"minimum checksum coverage", 
+	"send_ndp_count",
+	"minimum checksum coverage",
 	"check data checksum",
 };
 
 static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
 {
 	u_int cov;
-	
+
 	if (DCCPH_CSCOV(dh) == 0)
 		return len;
-	cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(u_int32_t);
+	cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(uint32_t);
 	return (cov > len)? len : cov;
 }
 
-static int dccp_cksum(const struct ip *ip,
+static int dccp_cksum(netdissect_options *ndo, const struct ip *ip,
 	const struct dccp_hdr *dh, u_int len)
 {
-	return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh,
-	    dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+	return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)dh, len,
+				dccp_csum_coverage(dh, len), IPPROTO_DCCP);
 }
 
 #ifdef INET6
 static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len)
 {
-	return nextproto6_cksum(ip6, (const u_int8_t *)(void *)dh,
-	    dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+	return nextproto6_cksum(ip6, (const uint8_t *)(void *)dh, len,
+				dccp_csum_coverage(dh, len), IPPROTO_DCCP);
 }
 #endif
 
-static const char *dccp_reset_code(u_int8_t code)
+static const char *dccp_reset_code(uint8_t code)
 {
 	if (code >= __DCCP_RESET_CODE_LAST)
 		return "invalid";
 	return dccp_reset_codes[code];
 }
 
-static u_int64_t dccp_seqno(const struct dccp_hdr *dh)
+static uint64_t dccp_seqno(const u_char *bp)
 {
-	u_int32_t seq_high = DCCPH_SEQ(dh);
-	u_int64_t seqno = EXTRACT_24BITS(&seq_high) & 0xFFFFFF;
+	const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
+	uint64_t seqno;
 
 	if (DCCPH_X(dh) != 0) {
-		const struct dccp_hdr_ext *dhx = (void *)(dh + 1);
-		u_int32_t seq_low = dhx->dccph_seq_low;
-		seqno &= 0x00FFFF;  /* clear reserved field */
-		seqno = (seqno << 32) + EXTRACT_32BITS(&seq_low);
+		const struct dccp_hdr_ext *dhx = (const struct dccp_hdr_ext *)bp;
+		seqno = EXTRACT_48BITS(dhx->dccph_seq);
+	} else {
+		seqno = EXTRACT_24BITS(dh->dccph_seq);
 	}
 
 	return seqno;
@@ -109,63 +237,38 @@
 
 static inline unsigned int dccp_basic_hdr_len(const struct dccp_hdr *dh)
 {
-	return sizeof(*dh) + (DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : 0);
+	return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr);
 }
 
-static void dccp_print_ack_no(const u_char *bp)
+static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp)
 {
 	const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
-	const struct dccp_hdr_ack_bits *dh_ack =
-		(struct dccp_hdr_ack_bits *)(bp + dccp_basic_hdr_len(dh));
-	u_int32_t ack_high;
-	u_int64_t ackno;
-
-	TCHECK2(*dh_ack,4);
-	ack_high = DCCPH_ACK(dh_ack);
-	ackno = EXTRACT_24BITS(&ack_high) & 0xFFFFFF;
+	const u_char *ackp = bp + dccp_basic_hdr_len(dh);
+	uint64_t ackno;
 
 	if (DCCPH_X(dh) != 0) {
-		u_int32_t ack_low;
-
-		TCHECK2(*dh_ack,8);
-		ack_low = dh_ack->dccph_ack_nr_low;
-
-		ackno &= 0x00FFFF;  /* clear reserved field */
-		ackno = (ackno << 32) + EXTRACT_32BITS(&ack_low);
+		ND_TCHECK2(*ackp, 8);
+		ackno = EXTRACT_48BITS(ackp + 2);
+	} else {
+		ND_TCHECK2(*ackp, 4);
+		ackno = EXTRACT_24BITS(ackp + 1);
 	}
 
-	(void)printf("(ack=%" PRIu64 ") ", ackno);
+	ND_PRINT((ndo, "(ack=%" PRIu64 ") ", ackno));
 trunc:
 	return;
 }
 
-static inline unsigned int dccp_packet_hdr_len(const u_int8_t type)
-{
-	if (type == DCCP_PKT_DATA)
-		return 0;
-	if (type == DCCP_PKT_DATAACK	||
-	    type == DCCP_PKT_ACK	||
-	    type == DCCP_PKT_SYNC	||
-	    type == DCCP_PKT_SYNCACK	||
-	    type == DCCP_PKT_CLOSE	||
-	    type == DCCP_PKT_CLOSEREQ)
-		return sizeof(struct dccp_hdr_ack_bits);
-	if (type == DCCP_PKT_REQUEST)
-		return sizeof(struct dccp_hdr_request);
-	if (type == DCCP_PKT_RESPONSE)
-		return sizeof(struct dccp_hdr_response);
-	return sizeof(struct dccp_hdr_reset);
-}
-
-static int dccp_print_option(const u_char *option);
+static int dccp_print_option(netdissect_options *, const u_char *, u_int);
 
 /**
  * dccp_print - show dccp packet
  * @bp - beginning of dccp packet
- * @data2 - beginning of enclosing 
+ * @data2 - beginning of enclosing
  * @len - lenght of ip packet
  */
-void dccp_print(const u_char *bp, const u_char *data2, u_int len)
+void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
+		u_int len)
 {
 	const struct dccp_hdr *dh;
 	const struct ip *ip;
@@ -175,7 +278,8 @@
 	const u_char *cp;
 	u_short sport, dport;
 	u_int hlen;
-	u_int extlen = 0;
+	u_int fixed_hdrlen;
+	uint8_t	dccph_type;
 
 	dh = (const struct dccp_hdr *)bp;
 
@@ -186,17 +290,27 @@
 	else
 		ip6 = NULL;
 #endif /*INET6*/
+
+	/* make sure we have enough data to look at the X bit */
 	cp = (const u_char *)(dh + 1);
-	if (cp > snapend) {
-		printf("[Invalid packet|dccp]");
+	if (cp > ndo->ndo_snapend) {
+		ND_PRINT((ndo, "[Invalid packet|dccp]"));
+		return;
+	}
+	if (len < sizeof(struct dccp_hdr)) {
+		ND_PRINT((ndo, "truncated-dccp - %u bytes missing!",
+			  len - (u_int)sizeof(struct dccp_hdr)));
 		return;
 	}
 
-	if (len < sizeof(struct dccp_hdr)) {
-		printf("truncated-dccp - %ld bytes missing!",
-			     (long)len - sizeof(struct dccp_hdr));
+	/* get the length of the generic header */
+	fixed_hdrlen = dccp_basic_hdr_len(dh);
+	if (len < fixed_hdrlen) {
+		ND_PRINT((ndo, "truncated-dccp - %u bytes missing!",
+			  len - fixed_hdrlen));
 		return;
 	}
+	ND_TCHECK2(*dh, fixed_hdrlen);
 
 	sport = EXTRACT_16BITS(&dh->dccph_sport);
 	dport = EXTRACT_16BITS(&dh->dccph_dport);
@@ -204,261 +318,354 @@
 
 #ifdef INET6
 	if (ip6) {
-		(void)printf("%s.%d > %s.%d: ",
-			     ip6addr_string(&ip6->ip6_src), sport,
-			     ip6addr_string(&ip6->ip6_dst), dport);
+		ND_PRINT((ndo, "%s.%d > %s.%d: ",
+			  ip6addr_string(ndo, &ip6->ip6_src), sport,
+			  ip6addr_string(ndo, &ip6->ip6_dst), dport));
 	} else
 #endif /*INET6*/
 	{
-		(void)printf("%s.%d > %s.%d: ",
-			     ipaddr_string(&ip->ip_src), sport,
-			     ipaddr_string(&ip->ip_dst), dport);
+		ND_PRINT((ndo, "%s.%d > %s.%d: ",
+			  ipaddr_string(ndo, &ip->ip_src), sport,
+			  ipaddr_string(ndo, &ip->ip_dst), dport));
 	}
-	fflush(stdout);
 
-	if (qflag) {
-		(void)printf(" %d", len - hlen);
+	ND_PRINT((ndo, "DCCP"));
+
+	if (ndo->ndo_qflag) {
+		ND_PRINT((ndo, " %d", len - hlen));
 		if (hlen > len) {
-			(void)printf("dccp [bad hdr length %u - too long, > %u]",
-			    hlen, len);
+			ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+				  hlen, len));
 		}
 		return;
 	}
 
 	/* other variables in generic header */
-	if (vflag) {
-		(void)printf("CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh));
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, " (CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh)));
 	}
 
 	/* checksum calculation */
-	if (vflag && TTEST2(bp[0], len)) {
-		u_int16_t sum = 0, dccp_sum;
+	if (ndo->ndo_vflag && ND_TTEST2(bp[0], len)) {
+		uint16_t sum = 0, dccp_sum;
 
 		dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);
-		(void)printf("cksum 0x%04x ", dccp_sum);
+		ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum));
 		if (IP_V(ip) == 4)
-			sum = dccp_cksum(ip, dh, len);
+			sum = dccp_cksum(ndo, ip, dh, len);
 #ifdef INET6
 		else if (IP_V(ip) == 6)
 			sum = dccp6_cksum(ip6, dh, len);
 #endif
 		if (sum != 0)
-			(void)printf("(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
+			ND_PRINT((ndo, "(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum)));
 		else
-			(void)printf("(correct), ");
+			ND_PRINT((ndo, "(correct)"));
 	}
 
-	switch (DCCPH_TYPE(dh)) {
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, ")"));
+	ND_PRINT((ndo, " "));
+
+	dccph_type = DCCPH_TYPE(dh);
+	switch (dccph_type) {
 	case DCCP_PKT_REQUEST: {
 		struct dccp_hdr_request *dhr =
-			(struct dccp_hdr_request *)(bp + dccp_basic_hdr_len(dh));
-		TCHECK(*dhr);
-		(void)printf("request (service=%d) ",
-			     EXTRACT_32BITS(&dhr->dccph_req_service));
-		extlen += 4;
+			(struct dccp_hdr_request *)(bp + fixed_hdrlen);
+		fixed_hdrlen += 4;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_TCHECK(*dhr);
+		ND_PRINT((ndo, "%s (service=%d) ",
+			  tok2str(dccp_pkt_type_str, "", dccph_type),
+			  EXTRACT_32BITS(&dhr->dccph_req_service)));
 		break;
 	}
 	case DCCP_PKT_RESPONSE: {
 		struct dccp_hdr_response *dhr =
-			(struct dccp_hdr_response *)(bp + dccp_basic_hdr_len(dh));
-		TCHECK(*dhr);
-		(void)printf("response (service=%d) ",
-			     EXTRACT_32BITS(&dhr->dccph_resp_service));
-		extlen += 12;
+			(struct dccp_hdr_response *)(bp + fixed_hdrlen);
+		fixed_hdrlen += 12;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_TCHECK(*dhr);
+		ND_PRINT((ndo, "%s (service=%d) ",
+			  tok2str(dccp_pkt_type_str, "", dccph_type),
+			  EXTRACT_32BITS(&dhr->dccph_resp_service)));
 		break;
 	}
 	case DCCP_PKT_DATA:
-		(void)printf("data ");
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
 		break;
 	case DCCP_PKT_ACK: {
-		(void)printf("ack ");
-		extlen += 8;
+		fixed_hdrlen += 8;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
 		break;
 	}
 	case DCCP_PKT_DATAACK: {
-		(void)printf("dataack ");
-		extlen += 8;
+		fixed_hdrlen += 8;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
 		break;
 	}
 	case DCCP_PKT_CLOSEREQ:
-		(void)printf("closereq ");
-		extlen += 8;
+		fixed_hdrlen += 8;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
 		break;
 	case DCCP_PKT_CLOSE:
-		(void)printf("close ");
-		extlen += 8;
+		fixed_hdrlen += 8;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
 		break;
 	case DCCP_PKT_RESET: {
 		struct dccp_hdr_reset *dhr =
-			(struct dccp_hdr_reset *)(bp + dccp_basic_hdr_len(dh));
-		TCHECK(*dhr);
-		(void)printf("reset (code=%s) ",
-			     dccp_reset_code(dhr->dccph_reset_code));
-		extlen += 12;
+			(struct dccp_hdr_reset *)(bp + fixed_hdrlen);
+		fixed_hdrlen += 12;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_TCHECK(*dhr);
+		ND_PRINT((ndo, "%s (code=%s) ",
+			  tok2str(dccp_pkt_type_str, "", dccph_type),
+			  dccp_reset_code(dhr->dccph_reset_code)));
 		break;
 	}
 	case DCCP_PKT_SYNC:
-		(void)printf("sync ");
-		extlen += 8;
+		fixed_hdrlen += 8;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
 		break;
 	case DCCP_PKT_SYNCACK:
-		(void)printf("syncack ");
-		extlen += 8;
+		fixed_hdrlen += 8;
+		if (len < fixed_hdrlen) {
+			ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+				  tok2str(dccp_pkt_type_str, "", dccph_type),
+				  len - fixed_hdrlen));
+			return;
+		}
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
 		break;
 	default:
-		(void)printf("invalid ");
+		ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "unknown-type-%u", dccph_type)));
 		break;
 	}
 
-	if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) && 
+	if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
 			(DCCPH_TYPE(dh) != DCCP_PKT_REQUEST))
-		dccp_print_ack_no(bp);
+		dccp_print_ack_no(ndo, bp);
 
-	if (vflag < 2)
+	if (ndo->ndo_vflag < 2)
 		return;
 
-	(void)printf("seq %" PRIu64, dccp_seqno(dh));
+	ND_PRINT((ndo, "seq %" PRIu64, dccp_seqno(bp)));
 
 	/* process options */
-	if (hlen > dccp_basic_hdr_len(dh) + extlen){
+	if (hlen > fixed_hdrlen){
 		const u_char *cp;
 		u_int optlen;
-		cp = bp + dccp_basic_hdr_len(dh) + extlen;
-		printf(" <");	
+		cp = bp + fixed_hdrlen;
+		ND_PRINT((ndo, " <"));
 
-		hlen -= dccp_basic_hdr_len(dh) + extlen;
+		hlen -= fixed_hdrlen;
 		while(1){
-			TCHECK(*cp);
-			optlen = dccp_print_option(cp);
-			if (!optlen) goto trunc2;
-			if (hlen <= optlen) break; 
+			optlen = dccp_print_option(ndo, cp, hlen);
+			if (!optlen)
+				break;
+			if (hlen <= optlen)
+				break;
 			hlen -= optlen;
 			cp += optlen;
-			printf(", ");
+			ND_PRINT((ndo, ", "));
 		}
-		printf(">");	
+		ND_PRINT((ndo, ">"));
 	}
 	return;
 trunc:
-	printf("[|dccp]");
-trunc2:
+	ND_PRINT((ndo, "%s", tstr));
 	return;
 }
 
-static int dccp_print_option(const u_char *option)
-{	
-	u_int8_t optlen, i;
+static const struct tok dccp_option_values[] = {
+	{ 0, "nop" },
+	{ 1, "mandatory" },
+	{ 2, "slowreceiver" },
+	{ 32, "change_l" },
+	{ 33, "confirm_l" },
+	{ 34, "change_r" },
+	{ 35, "confirm_r" },
+	{ 36, "initcookie" },
+	{ 37, "ndp_count" },
+	{ 38, "ack_vector0" },
+	{ 39, "ack_vector1" },
+	{ 40, "data_dropped" },
+	{ 41, "timestamp" },
+	{ 42, "timestamp_echo" },
+	{ 43, "elapsed_time" },
+	{ 44, "data_checksum" },
+	{ 0, NULL }
+};
 
-	TCHECK(*option);
+static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)
+{
+	uint8_t optlen, i;
+
+	ND_TCHECK(*option);
 
 	if (*option >= 32) {
-		TCHECK(*(option+1));
+		ND_TCHECK(*(option+1));
 		optlen = *(option +1);
 		if (optlen < 2) {
-			printf("Option %d optlen too short",*option);
-			return 1;
+			if (*option >= 128)
+				ND_PRINT((ndo, "CCID option %u optlen too short", *option));
+			else
+				ND_PRINT((ndo, "%s optlen too short",
+					  tok2str(dccp_option_values, "Option %u", *option)));
+			return 0;
 		}
-	} else optlen = 1;
+	} else
+		optlen = 1;
 
-	TCHECK2(*option,optlen);
-
-	switch (*option){
-	case 0:
-		printf("nop");
-		break;	
-	case 1:
-		printf("mandatory");
-		break;	
-	case 2:
-		printf("slowreceiver");
-		break;	
-	case 32:
-		printf("change_l");
-		if (*(option +2) < 10){
-			printf(" %s", dccp_feature_nums[*(option +2)]);
-			for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));	
-		}
-		break;	
-	case 33:
-		printf("confirm_l");
-		if (*(option +2) < 10){
-			printf(" %s", dccp_feature_nums[*(option +2)]);
-			for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));	
-		}
-		break;
-	case 34:
-	        printf("change_r");
-		if (*(option +2) < 10){
-			printf(" %s", dccp_feature_nums[*(option +2)]);
-			for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));	
-		}
-		break;
-	case 35:
-		printf("confirm_r");
-		if (*(option +2) < 10){
-			printf(" %s", dccp_feature_nums[*(option +2)]);
-			for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));	
-		}
-		break;
-	case 36:
-		printf("initcookie 0x");
-		for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));	
-		break;
-	case 37:
-		printf("ndp_count");
-		for (i = 0; i < optlen -2; i ++) printf(" %d", *(option +2 + i));	
-		break;
-	case 38:
-		printf("ack_vector0 0x");
-		for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));	
-		break;
-	case 39:
-		printf("ack_vector1 0x");
-		for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));	
-		break;
-	case 40:
-		printf("data_dropped 0x");
-		for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));	
-		break;
-	case 41:
-		printf("timestamp %u", EXTRACT_32BITS(option + 2));
-		break;
-	case 42:
-		printf("timestamp_echo %u", EXTRACT_32BITS(option + 2));
-		break;
-	case 43:
-		printf("elapsed_time ");
-		if (optlen == 6)
-			printf("%u", EXTRACT_32BITS(option + 2));
+	if (hlen < optlen) {
+		if (*option >= 128)
+			ND_PRINT((ndo, "CCID option %u optlen goes past header length",
+				  *option));
 		else
-			printf("%u", EXTRACT_16BITS(option + 2));
-		break;
-	case 44:
-		printf("data_checksum ");
-		for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));	
-		break;
-	default :
-		if (*option >= 128) {
-			printf("CCID option %d",*option);
-			switch (optlen) {
-				case 4:
-					printf(" %u", EXTRACT_16BITS(option + 2));
-					break;
-				case 6:
-					printf(" %u", EXTRACT_32BITS(option + 2));
-					break;
-				default:
-					break;
+			ND_PRINT((ndo, "%s optlen goes past header length",
+				  tok2str(dccp_option_values, "Option %u", *option)));
+		return 0;
+	}
+	ND_TCHECK2(*option, optlen);
+
+	if (*option >= 128) {
+		ND_PRINT((ndo, "CCID option %d", *option));
+		switch (optlen) {
+			case 4:
+				ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));
+				break;
+			case 6:
+				ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+				break;
+			default:
+				break;
+		}
+	} else {
+		ND_PRINT((ndo, "%s", tok2str(dccp_option_values, "Option %u", *option)));
+		switch (*option) {
+		case 32:
+		case 33:
+		case 34:
+		case 35:
+			if (optlen < 3) {
+				ND_PRINT((ndo, " optlen too short"));
+				return optlen;
+			}
+			if (*(option + 2) < 10){
+				ND_PRINT((ndo, " %s", dccp_feature_nums[*(option + 2)]));
+				for (i = 0; i < optlen - 3; i++)
+					ND_PRINT((ndo, " %d", *(option + 3 + i)));
+			}
+			break;
+		case 36:
+			if (optlen > 2) {
+				ND_PRINT((ndo, " 0x"));
+				for (i = 0; i < optlen - 2; i++)
+					ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+			}
+			break;
+		case 37:
+			for (i = 0; i < optlen - 2; i++)
+				ND_PRINT((ndo, " %d", *(option + 2 + i)));
+			break;
+		case 38:
+			if (optlen > 2) {
+				ND_PRINT((ndo, " 0x"));
+				for (i = 0; i < optlen - 2; i++)
+					ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+			}
+			break;
+		case 39:
+			if (optlen > 2) {
+				ND_PRINT((ndo, " 0x"));
+				for (i = 0; i < optlen - 2; i++)
+					ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+			}
+			break;
+		case 40:
+			if (optlen > 2) {
+				ND_PRINT((ndo, " 0x"));
+				for (i = 0; i < optlen - 2; i++)
+					ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+			}
+			break;
+		case 41:
+			if (optlen == 4)
+				ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+			else
+				ND_PRINT((ndo, " optlen != 4"));
+			break;
+		case 42:
+			if (optlen == 4)
+				ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+			else
+				ND_PRINT((ndo, " optlen != 4"));
+			break;
+		case 43:
+			if (optlen == 6)
+				ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+			else if (optlen == 4)
+				ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));
+			else
+				ND_PRINT((ndo, " optlen != 4 or 6"));
+			break;
+		case 44:
+			if (optlen > 2) {
+				ND_PRINT((ndo, " "));
+				for (i = 0; i < optlen - 2; i++)
+					ND_PRINT((ndo, "%02x", *(option + 2 + i)));
 			}
 			break;
 		}
-			
-		printf("unknown_opt %d", *option);
-		break;
 	}
 
 	return optlen;
 trunc:
-	printf("[|dccp]");
+	ND_PRINT((ndo, "%s", tstr));
 	return 0;
 }
diff --git a/print-decnet.c b/print-decnet.c
index 5b9dcfb..5414ec2 100644
--- a/print-decnet.c
+++ b/print-decnet.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -41,22 +37,462 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "decnet.h"
 #include "extract.h"
 #include "interface.h"
 #include "addrtoname.h"
 
+static const char tstr[] = "[|decnet]";
+
+#ifndef WIN32
+typedef uint8_t byte[1];		/* single byte field */
+#else
+/*
+ * the keyword 'byte' generates conflicts in Windows
+ */
+typedef unsigned char Byte[1];		/* single byte field */
+#define byte Byte
+#endif /* WIN32 */
+typedef uint8_t word[2];		/* 2 byte field */
+typedef uint8_t longword[4];		/* 4 bytes field */
+
+/*
+ * Definitions for DECNET Phase IV protocol headers
+ */
+union etheraddress {
+	uint8_t   dne_addr[6];		/* full ethernet address */
+	struct {
+		uint8_t dne_hiord[4];	/* DECnet HIORD prefix */
+		uint8_t dne_nodeaddr[2]; /* DECnet node address */
+	} dne_remote;
+};
+
+typedef union etheraddress etheraddr;	/* Ethernet address */
+
+#define HIORD 0x000400aa		/* high 32-bits of address (swapped) */
+
+#define AREAMASK	0176000		/* mask for area field */
+#define	AREASHIFT	10		/* bit-offset for area field */
+#define NODEMASK	01777		/* mask for node address field */
+
+#define DN_MAXADDL	20		/* max size of DECnet address */
+struct dn_naddr {
+	uint16_t	a_len;		/* length of address */
+	uint8_t a_addr[DN_MAXADDL]; /* address as bytes */
+};
+
+/*
+ * Define long and short header formats.
+ */
+struct shorthdr
+  {
+    byte	sh_flags;		/* route flags */
+    word	sh_dst;			/* destination node address */
+    word	sh_src;			/* source node address */
+    byte	sh_visits;		/* visit count */
+  };
+
+struct longhdr
+  {
+    byte	lg_flags;		/* route flags */
+    byte	lg_darea;		/* destination area (reserved) */
+    byte	lg_dsarea;		/* destination subarea (reserved) */
+    etheraddr	lg_dst;			/* destination id */
+    byte	lg_sarea;		/* source area (reserved) */
+    byte	lg_ssarea;		/* source subarea (reserved) */
+    etheraddr	lg_src;			/* source id */
+    byte	lg_nextl2;		/* next level 2 router (reserved) */
+    byte	lg_visits;		/* visit count */
+    byte	lg_service;		/* service class (reserved) */
+    byte	lg_pt;			/* protocol type (reserved) */
+  };
+
+union routehdr
+  {
+    struct shorthdr rh_short;		/* short route header */
+    struct longhdr rh_long;		/* long route header */
+  };
+
+/*
+ * Define the values of various fields in the protocol messages.
+ *
+ * 1. Data packet formats.
+ */
+#define RMF_MASK	7		/* mask for message type */
+#define RMF_SHORT	2		/* short message format */
+#define RMF_LONG	6		/* long message format */
+#ifndef RMF_RQR
+#define RMF_RQR		010		/* request return to sender */
+#define RMF_RTS		020		/* returning to sender */
+#define RMF_IE		040		/* intra-ethernet packet */
+#endif /* RMR_RQR */
+#define RMF_FVER	0100		/* future version flag */
+#define RMF_PAD		0200		/* pad field */
+#define RMF_PADMASK	0177		/* pad field mask */
+
+#define VIS_MASK	077		/* visit field mask */
+
+/*
+ * 2. Control packet formats.
+ */
+#define RMF_CTLMASK	017		/* mask for message type */
+#define RMF_CTLMSG	01		/* control message indicator */
+#define RMF_INIT	01		/* initialization message */
+#define RMF_VER		03		/* verification message */
+#define RMF_TEST	05		/* hello and test message */
+#define RMF_L1ROUT	07		/* level 1 routing message */
+#define RMF_L2ROUT	011		/* level 2 routing message */
+#define RMF_RHELLO	013		/* router hello message */
+#define RMF_EHELLO	015		/* endnode hello message */
+
+#define TI_L2ROUT	01		/* level 2 router */
+#define TI_L1ROUT	02		/* level 1 router */
+#define TI_ENDNODE	03		/* endnode */
+#define TI_VERIF	04		/* verification required */
+#define TI_BLOCK	010		/* blocking requested */
+
+#define VE_VERS		2		/* version number (2) */
+#define VE_ECO		0		/* ECO number */
+#define VE_UECO		0		/* user ECO number (0) */
+
+#define P3_VERS		1		/* phase III version number (1) */
+#define P3_ECO		3		/* ECO number (3) */
+#define P3_UECO		0		/* user ECO number (0) */
+
+#define II_L2ROUT	01		/* level 2 router */
+#define II_L1ROUT	02		/* level 1 router */
+#define II_ENDNODE	03		/* endnode */
+#define II_VERIF	04		/* verification required */
+#define II_NOMCAST	040		/* no multicast traffic accepted */
+#define II_BLOCK	0100		/* blocking requested */
+#define II_TYPEMASK	03		/* mask for node type */
+
+#define TESTDATA	0252		/* test data bytes */
+#define TESTLEN		1		/* length of transmitted test data */
+
+/*
+ * Define control message formats.
+ */
+struct initmsgIII			/* phase III initialization message */
+  {
+    byte	inIII_flags;		/* route flags */
+    word	inIII_src;		/* source node address */
+    byte	inIII_info;		/* routing layer information */
+    word	inIII_blksize;		/* maximum data link block size */
+    byte	inIII_vers;		/* version number */
+    byte	inIII_eco;		/* ECO number */
+    byte	inIII_ueco;		/* user ECO number */
+    byte	inIII_rsvd;		/* reserved image field */
+  };
+
+struct initmsg				/* initialization message */
+  {
+    byte	in_flags;		/* route flags */
+    word	in_src;			/* source node address */
+    byte	in_info;		/* routing layer information */
+    word	in_blksize;		/* maximum data link block size */
+    byte	in_vers;		/* version number */
+    byte	in_eco;			/* ECO number */
+    byte	in_ueco;		/* user ECO number */
+    word	in_hello;		/* hello timer */
+    byte	in_rsvd;		/* reserved image field */
+  };
+
+struct verifmsg				/* verification message */
+  {
+    byte	ve_flags;		/* route flags */
+    word	ve_src;			/* source node address */
+    byte	ve_fcnval;		/* function value image field */
+  };
+
+struct testmsg				/* hello and test message */
+  {
+    byte	te_flags;		/* route flags */
+    word	te_src;			/* source node address */
+    byte	te_data;		/* test data image field */
+  };
+
+struct l1rout				/* level 1 routing message */
+  {
+    byte	r1_flags;		/* route flags */
+    word	r1_src;			/* source node address */
+    byte	r1_rsvd;		/* reserved field */
+  };
+
+struct l2rout				/* level 2 routing message */
+  {
+    byte	r2_flags;		/* route flags */
+    word	r2_src;			/* source node address */
+    byte	r2_rsvd;		/* reserved field */
+  };
+
+struct rhellomsg			/* router hello message */
+  {
+    byte	rh_flags;		/* route flags */
+    byte	rh_vers;		/* version number */
+    byte	rh_eco;			/* ECO number */
+    byte	rh_ueco;		/* user ECO number */
+    etheraddr	rh_src;			/* source id */
+    byte	rh_info;		/* routing layer information */
+    word	rh_blksize;		/* maximum data link block size */
+    byte	rh_priority;		/* router's priority */
+    byte	rh_area;		/* reserved */
+    word	rh_hello;		/* hello timer */
+    byte	rh_mpd;			/* reserved */
+  };
+
+struct ehellomsg			/* endnode hello message */
+  {
+    byte	eh_flags;		/* route flags */
+    byte	eh_vers;		/* version number */
+    byte	eh_eco;			/* ECO number */
+    byte	eh_ueco;		/* user ECO number */
+    etheraddr	eh_src;			/* source id */
+    byte	eh_info;		/* routing layer information */
+    word	eh_blksize;		/* maximum data link block size */
+    byte	eh_area;		/* area (reserved) */
+    byte	eh_seed[8];		/* verification seed */
+    etheraddr	eh_router;		/* designated router */
+    word	eh_hello;		/* hello timer */
+    byte	eh_mpd;			/* (reserved) */
+    byte	eh_data;		/* test data image field */
+  };
+
+union controlmsg
+  {
+    struct initmsg	cm_init;	/* initialization message */
+    struct verifmsg	cm_ver;		/* verification message */
+    struct testmsg	cm_test;	/* hello and test message */
+    struct l1rout	cm_l1rou;	/* level 1 routing message */
+    struct l2rout	cm_l2rout;	/* level 2 routing message */
+    struct rhellomsg	cm_rhello;	/* router hello message */
+    struct ehellomsg	cm_ehello;	/* endnode hello message */
+  };
+
+/* Macros for decoding routing-info fields */
+#define	RI_COST(x)	((x)&0777)
+#define	RI_HOPS(x)	(((x)>>10)&037)
+
+/*
+ * NSP protocol fields and values.
+ */
+
+#define NSP_TYPEMASK 014		/* mask to isolate type code */
+#define NSP_SUBMASK 0160		/* mask to isolate subtype code */
+#define NSP_SUBSHFT 4			/* shift to move subtype code */
+
+#define MFT_DATA 0			/* data message */
+#define MFT_ACK  04			/* acknowledgement message */
+#define MFT_CTL  010			/* control message */
+
+#define MFS_ILS  020			/* data or I/LS indicator */
+#define MFS_BOM  040			/* beginning of message (data) */
+#define MFS_MOM  0			/* middle of message (data) */
+#define MFS_EOM  0100			/* end of message (data) */
+#define MFS_INT  040			/* interrupt message */
+
+#define MFS_DACK 0			/* data acknowledgement */
+#define MFS_IACK 020			/* I/LS acknowledgement */
+#define MFS_CACK 040			/* connect acknowledgement */
+
+#define MFS_NOP  0			/* no operation */
+#define MFS_CI   020			/* connect initiate */
+#define MFS_CC   040			/* connect confirm */
+#define MFS_DI   060			/* disconnect initiate */
+#define MFS_DC   0100			/* disconnect confirm */
+#define MFS_RCI  0140			/* retransmitted connect initiate */
+
+#define SGQ_ACK  0100000		/* ack */
+#define SGQ_NAK  0110000		/* negative ack */
+#define SGQ_OACK 0120000		/* other channel ack */
+#define SGQ_ONAK 0130000		/* other channel negative ack */
+#define SGQ_MASK 07777			/* mask to isolate seq # */
+#define SGQ_OTHER 020000		/* other channel qualifier */
+#define SGQ_DELAY 010000		/* ack delay flag */
+
+#define SGQ_EOM  0100000		/* pseudo flag for end-of-message */
+
+#define LSM_MASK 03			/* mask for modifier field */
+#define LSM_NOCHANGE 0			/* no change */
+#define LSM_DONOTSEND 1			/* do not send data */
+#define LSM_SEND 2			/* send data */
+
+#define LSI_MASK 014			/* mask for interpretation field */
+#define LSI_DATA 0			/* data segment or message count */
+#define LSI_INTR 4			/* interrupt request count */
+#define LSI_INTM 0377			/* funny marker for int. message */
+
+#define COS_MASK 014			/* mask for flow control field */
+#define COS_NONE 0			/* no flow control */
+#define COS_SEGMENT 04			/* segment flow control */
+#define COS_MESSAGE 010			/* message flow control */
+#define COS_CRYPTSER 020		/* cryptographic services requested */
+#define COS_DEFAULT 1			/* default value for field */
+
+#define COI_MASK 3			/* mask for version field */
+#define COI_32 0			/* version 3.2 */
+#define COI_31 1			/* version 3.1 */
+#define COI_40 2			/* version 4.0 */
+#define COI_41 3			/* version 4.1 */
+
+#define MNU_MASK 140			/* mask for session control version */
+#define MNU_10 000				/* session V1.0 */
+#define MNU_20 040				/* session V2.0 */
+#define MNU_ACCESS 1			/* access control present */
+#define MNU_USRDATA 2			/* user data field present */
+#define MNU_INVKPROXY 4			/* invoke proxy field present */
+#define MNU_UICPROXY 8			/* use uic-based proxy */
+
+#define DC_NORESOURCES 1		/* no resource reason code */
+#define DC_NOLINK 41			/* no link terminate reason code */
+#define DC_COMPLETE 42			/* disconnect complete reason code */
+
+#define DI_NOERROR 0			/* user disconnect */
+#define DI_SHUT 3			/* node is shutting down */
+#define DI_NOUSER 4			/* destination end user does not exist */
+#define DI_INVDEST 5			/* invalid end user destination */
+#define DI_REMRESRC 6			/* insufficient remote resources */
+#define DI_TPA 8			/* third party abort */
+#define DI_PROTOCOL 7			/* protocol error discovered */
+#define DI_ABORT 9			/* user abort */
+#define DI_LOCALRESRC 32		/* insufficient local resources */
+#define DI_REMUSERRESRC 33		/* insufficient remote user resources */
+#define DI_BADACCESS 34			/* bad access control information */
+#define DI_BADACCNT 36			/* bad ACCOUNT information */
+#define DI_CONNECTABORT 38		/* connect request cancelled */
+#define DI_TIMEDOUT 38			/* remote node or user crashed */
+#define DI_UNREACHABLE 39		/* local timers expired due to ... */
+#define DI_BADIMAGE 43			/* bad image data in connect */
+#define DI_SERVMISMATCH 54		/* cryptographic service mismatch */
+
+#define UC_OBJREJECT 0			/* object rejected connect */
+#define UC_USERDISCONNECT 0		/* user disconnect */
+#define UC_RESOURCES 1			/* insufficient resources (local or remote) */
+#define UC_NOSUCHNODE 2			/* unrecognized node name */
+#define UC_REMOTESHUT 3			/* remote node shutting down */
+#define UC_NOSUCHOBJ 4			/* unrecognized object */
+#define UC_INVOBJFORMAT 5		/* invalid object name format */
+#define UC_OBJTOOBUSY 6			/* object too busy */
+#define UC_NETWORKABORT 8		/* network abort */
+#define UC_USERABORT 9			/* user abort */
+#define UC_INVNODEFORMAT 10		/* invalid node name format */
+#define UC_LOCALSHUT 11			/* local node shutting down */
+#define UC_ACCESSREJECT 34		/* invalid access control information */
+#define UC_NORESPONSE 38		/* no response from object */
+#define UC_UNREACHABLE 39		/* node unreachable */
+
+/*
+ * NSP message formats.
+ */
+struct nsphdr				/* general nsp header */
+  {
+    byte	nh_flags;		/* message flags */
+    word	nh_dst;			/* destination link address */
+    word	nh_src;			/* source link address */
+  };
+
+struct seghdr				/* data segment header */
+  {
+    byte	sh_flags;		/* message flags */
+    word	sh_dst;			/* destination link address */
+    word	sh_src;			/* source link address */
+    word	sh_seq[3];		/* sequence numbers */
+  };
+
+struct minseghdr			/* minimum data segment header */
+  {
+    byte	ms_flags;		/* message flags */
+    word	ms_dst;			/* destination link address */
+    word	ms_src;			/* source link address */
+    word	ms_seq;			/* sequence number */
+  };
+
+struct lsmsg				/* link service message (after hdr) */
+  {
+    byte	ls_lsflags;		/* link service flags */
+    byte	ls_fcval;		/* flow control value */
+  };
+
+struct ackmsg				/* acknowledgement message */
+  {
+    byte	ak_flags;		/* message flags */
+    word	ak_dst;			/* destination link address */
+    word	ak_src;			/* source link address */
+    word	ak_acknum[2];		/* acknowledgement numbers */
+  };
+
+struct minackmsg			/* minimum acknowledgement message */
+  {
+    byte	mk_flags;		/* message flags */
+    word	mk_dst;			/* destination link address */
+    word	mk_src;			/* source link address */
+    word	mk_acknum;		/* acknowledgement number */
+  };
+
+struct ciackmsg				/* connect acknowledgement message */
+  {
+    byte	ck_flags;		/* message flags */
+    word	ck_dst;			/* destination link address */
+  };
+
+struct cimsg				/* connect initiate message */
+  {
+    byte	ci_flags;		/* message flags */
+    word	ci_dst;			/* destination link address (0) */
+    word	ci_src;			/* source link address */
+    byte	ci_services;		/* requested services */
+    byte	ci_info;		/* information */
+    word	ci_segsize;		/* maximum segment size */
+  };
+
+struct ccmsg				/* connect confirm message */
+  {
+    byte	cc_flags;		/* message flags */
+    word	cc_dst;			/* destination link address */
+    word	cc_src;			/* source link address */
+    byte	cc_services;		/* requested services */
+    byte	cc_info;		/* information */
+    word	cc_segsize;		/* maximum segment size */
+    byte	cc_optlen;		/* optional data length */
+  };
+
+struct cnmsg				/* generic connect message */
+  {
+    byte	cn_flags;		/* message flags */
+    word	cn_dst;			/* destination link address */
+    word	cn_src;			/* source link address */
+    byte	cn_services;		/* requested services */
+    byte	cn_info;		/* information */
+    word	cn_segsize;		/* maximum segment size */
+  };
+
+struct dimsg				/* disconnect initiate message */
+  {
+    byte	di_flags;		/* message flags */
+    word	di_dst;			/* destination link address */
+    word	di_src;			/* source link address */
+    word	di_reason;		/* reason code */
+    byte	di_optlen;		/* optional data length */
+  };
+
+struct dcmsg				/* disconnect confirm message */
+  {
+    byte	dc_flags;		/* message flags */
+    word	dc_dst;			/* destination link address */
+    word	dc_src;			/* source link address */
+    word	dc_reason;		/* reason code */
+  };
+
 /* Forwards */
-static int print_decnet_ctlmsg(const union routehdr *, u_int, u_int);
-static void print_t_info(int);
-static int print_l1_routes(const char *, u_int);
-static int print_l2_routes(const char *, u_int);
-static void print_i_info(int);
+static int print_decnet_ctlmsg(netdissect_options *, const union routehdr *, u_int, u_int);
+static void print_t_info(netdissect_options *, int);
+static int print_l1_routes(netdissect_options *, const char *, u_int);
+static int print_l2_routes(netdissect_options *, const char *, u_int);
+static void print_i_info(netdissect_options *, int);
 static int print_elist(const char *, u_int);
-static int print_nsp(const u_char *, u_int);
-static void print_reason(int);
+static int print_nsp(netdissect_options *, const u_char *, u_int);
+static void print_reason(netdissect_options *, int);
 #ifdef	PRINT_NSPDATA
-static void pdata(u_char *, int);
+static void pdata(netdissect_options *, u_char *, u_int);
 #endif
 
 #ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
@@ -64,8 +500,9 @@
 #endif
 
 void
-decnet_print(register const u_char *ap, register u_int length,
-	     register u_int caplen)
+decnet_print(netdissect_options *ndo,
+             register const u_char *ap, register u_int length,
+             register u_int caplen)
 {
 	register const union routehdr *rhp;
 	register int mflags;
@@ -74,36 +511,36 @@
 	const u_char *nspp;
 
 	if (length < sizeof(struct shorthdr)) {
-		(void)printf("[|decnet]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 
-	TCHECK2(*ap, sizeof(short));
+	ND_TCHECK2(*ap, sizeof(short));
 	pktlen = EXTRACT_LE_16BITS(ap);
 	if (pktlen < sizeof(struct shorthdr)) {
-		(void)printf("[|decnet]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 	if (pktlen > length) {
-		(void)printf("[|decnet]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 	length = pktlen;
 
 	rhp = (const union routehdr *)&(ap[sizeof(short)]);
-	TCHECK(rhp->rh_short.sh_flags);
+	ND_TCHECK(rhp->rh_short.sh_flags);
 	mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
 
 	if (mflags & RMF_PAD) {
 	    /* pad bytes of some sort in front of message */
 	    u_int padlen = mflags & RMF_PADMASK;
-	    if (vflag)
-		(void) printf("[pad:%d] ", padlen);
+	    if (ndo->ndo_vflag)
+		ND_PRINT((ndo, "[pad:%d] ", padlen));
 	    if (length < padlen + 2) {
-		(void)printf("[|decnet]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	    }
-	    TCHECK2(ap[sizeof(short)], padlen);
+	    ND_TCHECK2(ap[sizeof(short)], padlen);
 	    ap += padlen;
 	    length -= padlen;
 	    caplen -= padlen;
@@ -112,14 +549,14 @@
 	}
 
 	if (mflags & RMF_FVER) {
-		(void) printf("future-version-decnet");
-		default_print(ap, min(length, caplen));
+		ND_PRINT((ndo, "future-version-decnet"));
+		ND_DEFAULTPRINT(ap, min(length, caplen));
 		return;
 	}
 
 	/* is it a control message? */
 	if (mflags & RMF_CTLMSG) {
-		if (!print_decnet_ctlmsg(rhp, length, caplen))
+		if (!print_decnet_ctlmsg(ndo, rhp, length, caplen))
 			goto trunc;
 		return;
 	}
@@ -127,10 +564,10 @@
 	switch (mflags & RMF_MASK) {
 	case RMF_LONG:
 	    if (length < sizeof(struct longhdr)) {
-		(void)printf("[|decnet]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	    }
-	    TCHECK(rhp->rh_long);
+	    ND_TCHECK(rhp->rh_long);
 	    dst =
 		EXTRACT_LE_16BITS(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr);
 	    src =
@@ -140,7 +577,7 @@
 	    nsplen = length - sizeof(struct longhdr);
 	    break;
 	case RMF_SHORT:
-	    TCHECK(rhp->rh_short);
+	    ND_TCHECK(rhp->rh_short);
 	    dst = EXTRACT_LE_16BITS(rhp->rh_short.sh_dst);
 	    src = EXTRACT_LE_16BITS(rhp->rh_short.sh_src);
 	    hops = (EXTRACT_LE_8BITS(rhp->rh_short.sh_visits) & VIS_MASK)+1;
@@ -148,35 +585,36 @@
 	    nsplen = length - sizeof(struct shorthdr);
 	    break;
 	default:
-	    (void) printf("unknown message flags under mask");
-	    default_print((u_char *)ap, min(length, caplen));
+	    ND_PRINT((ndo, "unknown message flags under mask"));
+	    ND_DEFAULTPRINT((u_char *)ap, min(length, caplen));
 	    return;
 	}
 
-	(void)printf("%s > %s %d ",
-			dnaddr_string(src), dnaddr_string(dst), pktlen);
-	if (vflag) {
+	ND_PRINT((ndo, "%s > %s %d ",
+			dnaddr_string(ndo, src), dnaddr_string(ndo, dst), pktlen));
+	if (ndo->ndo_vflag) {
 	    if (mflags & RMF_RQR)
-		(void)printf("RQR ");
+		ND_PRINT((ndo, "RQR "));
 	    if (mflags & RMF_RTS)
-		(void)printf("RTS ");
+		ND_PRINT((ndo, "RTS "));
 	    if (mflags & RMF_IE)
-		(void)printf("IE ");
-	    (void)printf("%d hops ", hops);
+		ND_PRINT((ndo, "IE "));
+	    ND_PRINT((ndo, "%d hops ", hops));
 	}
 
-	if (!print_nsp(nspp, nsplen))
+	if (!print_nsp(ndo, nspp, nsplen))
 		goto trunc;
 	return;
 
 trunc:
-	(void)printf("[|decnet]");
+	ND_PRINT((ndo, "%s", tstr));
 	return;
 }
 
 static int
-print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
-    u_int caplen)
+print_decnet_ctlmsg(netdissect_options *ndo,
+                    register const union routehdr *rhp, u_int length,
+                    u_int caplen)
 {
 	int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
 	register union controlmsg *cmp = (union controlmsg *)rhp;
@@ -188,10 +626,10 @@
 
 	switch (mflags & RMF_CTLMASK) {
 	case RMF_INIT:
-	    (void)printf("init ");
+	    ND_PRINT((ndo, "init "));
 	    if (length < sizeof(struct initmsg))
 		goto trunc;
-	    TCHECK(cmp->cm_init);
+	    ND_TCHECK(cmp->cm_init);
 	    src = EXTRACT_LE_16BITS(cmp->cm_init.in_src);
 	    info = EXTRACT_LE_8BITS(cmp->cm_init.in_info);
 	    blksize = EXTRACT_LE_16BITS(cmp->cm_init.in_blksize);
@@ -199,58 +637,58 @@
 	    eco = EXTRACT_LE_8BITS(cmp->cm_init.in_eco);
 	    ueco = EXTRACT_LE_8BITS(cmp->cm_init.in_ueco);
 	    hello = EXTRACT_LE_16BITS(cmp->cm_init.in_hello);
-	    print_t_info(info);
-	    (void)printf(
+	    print_t_info(ndo, info);
+	    ND_PRINT((ndo,
 		"src %sblksize %d vers %d eco %d ueco %d hello %d",
-			dnaddr_string(src), blksize, vers, eco, ueco,
-			hello);
+			dnaddr_string(ndo, src), blksize, vers, eco, ueco,
+			hello));
 	    ret = 1;
 	    break;
 	case RMF_VER:
-	    (void)printf("verification ");
+	    ND_PRINT((ndo, "verification "));
 	    if (length < sizeof(struct verifmsg))
 		goto trunc;
-	    TCHECK(cmp->cm_ver);
+	    ND_TCHECK(cmp->cm_ver);
 	    src = EXTRACT_LE_16BITS(cmp->cm_ver.ve_src);
 	    other = EXTRACT_LE_8BITS(cmp->cm_ver.ve_fcnval);
-	    (void)printf("src %s fcnval %o", dnaddr_string(src), other);
+	    ND_PRINT((ndo, "src %s fcnval %o", dnaddr_string(ndo, src), other));
 	    ret = 1;
 	    break;
 	case RMF_TEST:
-	    (void)printf("test ");
+	    ND_PRINT((ndo, "test "));
 	    if (length < sizeof(struct testmsg))
 		goto trunc;
-	    TCHECK(cmp->cm_test);
+	    ND_TCHECK(cmp->cm_test);
 	    src = EXTRACT_LE_16BITS(cmp->cm_test.te_src);
 	    other = EXTRACT_LE_8BITS(cmp->cm_test.te_data);
-	    (void)printf("src %s data %o", dnaddr_string(src), other);
+	    ND_PRINT((ndo, "src %s data %o", dnaddr_string(ndo, src), other));
 	    ret = 1;
 	    break;
 	case RMF_L1ROUT:
-	    (void)printf("lev-1-routing ");
+	    ND_PRINT((ndo, "lev-1-routing "));
 	    if (length < sizeof(struct l1rout))
 		goto trunc;
-	    TCHECK(cmp->cm_l1rou);
+	    ND_TCHECK(cmp->cm_l1rou);
 	    src = EXTRACT_LE_16BITS(cmp->cm_l1rou.r1_src);
-	    (void)printf("src %s ", dnaddr_string(src));
-	    ret = print_l1_routes(&(rhpx[sizeof(struct l1rout)]),
+	    ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src)));
+	    ret = print_l1_routes(ndo, &(rhpx[sizeof(struct l1rout)]),
 				length - sizeof(struct l1rout));
 	    break;
 	case RMF_L2ROUT:
-	    (void)printf("lev-2-routing ");
+	    ND_PRINT((ndo, "lev-2-routing "));
 	    if (length < sizeof(struct l2rout))
 		goto trunc;
-	    TCHECK(cmp->cm_l2rout);
+	    ND_TCHECK(cmp->cm_l2rout);
 	    src = EXTRACT_LE_16BITS(cmp->cm_l2rout.r2_src);
-	    (void)printf("src %s ", dnaddr_string(src));
-	    ret = print_l2_routes(&(rhpx[sizeof(struct l2rout)]),
+	    ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src)));
+	    ret = print_l2_routes(ndo, &(rhpx[sizeof(struct l2rout)]),
 				length - sizeof(struct l2rout));
 	    break;
 	case RMF_RHELLO:
-	    (void)printf("router-hello ");
+	    ND_PRINT((ndo, "router-hello "));
 	    if (length < sizeof(struct rhellomsg))
 		goto trunc;
-	    TCHECK(cmp->cm_rhello);
+	    ND_TCHECK(cmp->cm_rhello);
 	    vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers);
 	    eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco);
 	    ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco);
@@ -261,19 +699,19 @@
 	    blksize = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_blksize);
 	    priority = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_priority);
 	    hello = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_hello);
-	    print_i_info(info);
-	    (void)printf(
+	    print_i_info(ndo, info);
+	    ND_PRINT((ndo,
 	    "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d",
-			vers, eco, ueco, dnaddr_string(src),
-			blksize, priority, hello);
+			vers, eco, ueco, dnaddr_string(ndo, src),
+			blksize, priority, hello));
 	    ret = print_elist(&(rhpx[sizeof(struct rhellomsg)]),
 				length - sizeof(struct rhellomsg));
 	    break;
 	case RMF_EHELLO:
-	    (void)printf("endnode-hello ");
+	    ND_PRINT((ndo, "endnode-hello "));
 	    if (length < sizeof(struct ehellomsg))
 		goto trunc;
-	    TCHECK(cmp->cm_ehello);
+	    ND_TCHECK(cmp->cm_ehello);
 	    vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers);
 	    eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco);
 	    ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco);
@@ -288,17 +726,17 @@
 	    dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr);
 	    hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello);
 	    other = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_data);
-	    print_i_info(info);
-	    (void)printf(
+	    print_i_info(ndo, info);
+	    ND_PRINT((ndo,
 	"vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o",
-			vers, eco, ueco, dnaddr_string(src),
-			blksize, dnaddr_string(dst), hello, other);
+			vers, eco, ueco, dnaddr_string(ndo, src),
+			blksize, dnaddr_string(ndo, dst), hello, other));
 	    ret = 1;
 	    break;
 
 	default:
-	    (void)printf("unknown control message");
-	    default_print((u_char *)rhp, min(length, caplen));
+	    ND_PRINT((ndo, "unknown control message"));
+	    ND_DEFAULTPRINT((u_char *)rhp, min(length, caplen));
 	    ret = 1;
 	    break;
 	}
@@ -309,23 +747,25 @@
 }
 
 static void
-print_t_info(int info)
+print_t_info(netdissect_options *ndo,
+             int info)
 {
 	int ntype = info & 3;
 	switch (ntype) {
-	case 0: (void)printf("reserved-ntype? "); break;
-	case TI_L2ROUT: (void)printf("l2rout "); break;
-	case TI_L1ROUT: (void)printf("l1rout "); break;
-	case TI_ENDNODE: (void)printf("endnode "); break;
+	case 0: ND_PRINT((ndo, "reserved-ntype? ")); break;
+	case TI_L2ROUT: ND_PRINT((ndo, "l2rout ")); break;
+	case TI_L1ROUT: ND_PRINT((ndo, "l1rout ")); break;
+	case TI_ENDNODE: ND_PRINT((ndo, "endnode ")); break;
 	}
 	if (info & TI_VERIF)
-	    (void)printf("verif ");
+	    ND_PRINT((ndo, "verif "));
 	if (info & TI_BLOCK)
-	    (void)printf("blo ");
+	    ND_PRINT((ndo, "blo "));
 }
 
 static int
-print_l1_routes(const char *rp, u_int len)
+print_l1_routes(netdissect_options *ndo,
+                const char *rp, u_int len)
 {
 	int count;
 	int id;
@@ -333,7 +773,7 @@
 
 	/* The last short is a checksum */
 	while (len > (3 * sizeof(short))) {
-	    TCHECK2(*rp, 3 * sizeof(short));
+	    ND_TCHECK2(*rp, 3 * sizeof(short));
 	    count = EXTRACT_LE_16BITS(rp);
 	    if (count > 1024)
 		return (1);	/* seems to be bogus from here on */
@@ -345,8 +785,8 @@
 	    info = EXTRACT_LE_16BITS(rp);
 	    rp += sizeof(short);
 	    len -= sizeof(short);
-	    (void)printf("{ids %d-%d cost %d hops %d} ", id, id + count,
-			    RI_COST(info), RI_HOPS(info));
+	    ND_PRINT((ndo, "{ids %d-%d cost %d hops %d} ", id, id + count,
+			    RI_COST(info), RI_HOPS(info)));
 	}
 	return (1);
 
@@ -355,7 +795,8 @@
 }
 
 static int
-print_l2_routes(const char *rp, u_int len)
+print_l2_routes(netdissect_options *ndo,
+                const char *rp, u_int len)
 {
 	int count;
 	int area;
@@ -363,7 +804,7 @@
 
 	/* The last short is a checksum */
 	while (len > (3 * sizeof(short))) {
-	    TCHECK2(*rp, 3 * sizeof(short));
+	    ND_TCHECK2(*rp, 3 * sizeof(short));
 	    count = EXTRACT_LE_16BITS(rp);
 	    if (count > 1024)
 		return (1);	/* seems to be bogus from here on */
@@ -375,8 +816,8 @@
 	    info = EXTRACT_LE_16BITS(rp);
 	    rp += sizeof(short);
 	    len -= sizeof(short);
-	    (void)printf("{areas %d-%d cost %d hops %d} ", area, area + count,
-			    RI_COST(info), RI_HOPS(info));
+	    ND_PRINT((ndo, "{areas %d-%d cost %d hops %d} ", area, area + count,
+			    RI_COST(info), RI_HOPS(info)));
 	}
 	return (1);
 
@@ -385,21 +826,22 @@
 }
 
 static void
-print_i_info(int info)
+print_i_info(netdissect_options *ndo,
+             int info)
 {
 	int ntype = info & II_TYPEMASK;
 	switch (ntype) {
-	case 0: (void)printf("reserved-ntype? "); break;
-	case II_L2ROUT: (void)printf("l2rout "); break;
-	case II_L1ROUT: (void)printf("l1rout "); break;
-	case II_ENDNODE: (void)printf("endnode "); break;
+	case 0: ND_PRINT((ndo, "reserved-ntype? ")); break;
+	case II_L2ROUT: ND_PRINT((ndo, "l2rout ")); break;
+	case II_L1ROUT: ND_PRINT((ndo, "l1rout ")); break;
+	case II_ENDNODE: ND_PRINT((ndo, "endnode ")); break;
 	}
 	if (info & II_VERIF)
-	    (void)printf("verif ");
+	    ND_PRINT((ndo, "verif "));
 	if (info & II_NOMCAST)
-	    (void)printf("nomcast ");
+	    ND_PRINT((ndo, "nomcast "));
 	if (info & II_BLOCK)
-	    (void)printf("blo ");
+	    ND_PRINT((ndo, "blo "));
 }
 
 static int
@@ -410,14 +852,15 @@
 }
 
 static int
-print_nsp(const u_char *nspp, u_int nsplen)
+print_nsp(netdissect_options *ndo,
+          const u_char *nspp, u_int nsplen)
 {
 	const struct nsphdr *nsphp = (struct nsphdr *)nspp;
 	int dst, src, flags;
 
 	if (nsplen < sizeof(struct nsphdr))
 		goto trunc;
-	TCHECK(*nsphp);
+	ND_TCHECK(*nsphp);
 	flags = EXTRACT_LE_8BITS(nsphp->nh_flags);
 	dst = EXTRACT_LE_16BITS(nsphp->nh_dst);
 	src = EXTRACT_LE_16BITS(nsphp->nh_src);
@@ -429,7 +872,7 @@
 	    case MFS_MOM:
 	    case MFS_EOM:
 	    case MFS_BOM+MFS_EOM:
-		printf("data %d>%d ", src, dst);
+		ND_PRINT((ndo, "data %d>%d ", src, dst));
 		{
 		    struct seghdr *shp = (struct seghdr *)nspp;
 		    int ack;
@@ -440,42 +883,42 @@
 
 		    if (nsplen < data_off)
 			goto trunc;
-		    TCHECK(shp->sh_seq[0]);
+		    ND_TCHECK(shp->sh_seq[0]);
 		    ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
 		    if (ack & SGQ_ACK) {	/* acknum field */
 			if ((ack & SGQ_NAK) == SGQ_NAK)
-			    (void)printf("nak %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
 			else
-			    (void)printf("ack %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
 			data_off += sizeof(short);
 			if (nsplen < data_off)
 			    goto trunc;
-			TCHECK(shp->sh_seq[1]);
+			ND_TCHECK(shp->sh_seq[1]);
 		        ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
 			if (ack & SGQ_OACK) {	/* ackoth field */
 			    if ((ack & SGQ_ONAK) == SGQ_ONAK)
-				(void)printf("onak %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK));
 			    else
-				(void)printf("oack %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK));
 			    data_off += sizeof(short);
 			    if (nsplen < data_off)
 				goto trunc;
-			    TCHECK(shp->sh_seq[2]);
+			    ND_TCHECK(shp->sh_seq[2]);
 			    ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
 			}
 		    }
-		    (void)printf("seg %d ", ack & SGQ_MASK);
+		    ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
 #ifdef	PRINT_NSPDATA
 		    if (nsplen > data_off) {
 			dp = &(nspp[data_off]);
-			TCHECK2(*dp, nsplen - data_off);
-			pdata(dp, nsplen - data_off);
+			ND_TCHECK2(*dp, nsplen - data_off);
+			pdata(ndo, dp, nsplen - data_off);
 		    }
 #endif
 		}
 		break;
 	    case MFS_ILS+MFS_INT:
-		printf("intr ");
+		ND_PRINT((ndo, "intr "));
 		{
 		    struct seghdr *shp = (struct seghdr *)nspp;
 		    int ack;
@@ -486,42 +929,42 @@
 
 		    if (nsplen < data_off)
 			goto trunc;
-		    TCHECK(shp->sh_seq[0]);
+		    ND_TCHECK(shp->sh_seq[0]);
 		    ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
 		    if (ack & SGQ_ACK) {	/* acknum field */
 			if ((ack & SGQ_NAK) == SGQ_NAK)
-			    (void)printf("nak %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
 			else
-			    (void)printf("ack %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
 			data_off += sizeof(short);
 			if (nsplen < data_off)
 			    goto trunc;
-			TCHECK(shp->sh_seq[1]);
+			ND_TCHECK(shp->sh_seq[1]);
 		        ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
 			if (ack & SGQ_OACK) {	/* ackdat field */
 			    if ((ack & SGQ_ONAK) == SGQ_ONAK)
-				(void)printf("nakdat %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
 			    else
-				(void)printf("ackdat %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
 			    data_off += sizeof(short);
 			    if (nsplen < data_off)
 				goto trunc;
-			    TCHECK(shp->sh_seq[2]);
+			    ND_TCHECK(shp->sh_seq[2]);
 			    ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
 			}
 		    }
-		    (void)printf("seg %d ", ack & SGQ_MASK);
+		    ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
 #ifdef	PRINT_NSPDATA
 		    if (nsplen > data_off) {
 			dp = &(nspp[data_off]);
-			TCHECK2(*dp, nsplen - data_off);
-			pdata(dp, nsplen - data_off);
+			ND_TCHECK2(*dp, nsplen - data_off);
+			pdata(ndo, dp, nsplen - data_off);
 		    }
 #endif
 		}
 		break;
 	    case MFS_ILS:
-		(void)printf("link-service %d>%d ", src, dst);
+		ND_PRINT((ndo, "link-service %d>%d ", src, dst));
 		{
 		    struct seghdr *shp = (struct seghdr *)nspp;
 		    struct lsmsg *lsmp =
@@ -531,117 +974,117 @@
 
 		    if (nsplen < sizeof(struct seghdr) + sizeof(struct lsmsg))
 			goto trunc;
-		    TCHECK(shp->sh_seq[0]);
+		    ND_TCHECK(shp->sh_seq[0]);
 		    ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
 		    if (ack & SGQ_ACK) {	/* acknum field */
 			if ((ack & SGQ_NAK) == SGQ_NAK)
-			    (void)printf("nak %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
 			else
-			    (void)printf("ack %d ", ack & SGQ_MASK);
-			TCHECK(shp->sh_seq[1]);
+			    ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
+			ND_TCHECK(shp->sh_seq[1]);
 		        ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
 			if (ack & SGQ_OACK) {	/* ackdat field */
 			    if ((ack & SGQ_ONAK) == SGQ_ONAK)
-				(void)printf("nakdat %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
 			    else
-				(void)printf("ackdat %d ", ack & SGQ_MASK);
-			    TCHECK(shp->sh_seq[2]);
+				ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
+			    ND_TCHECK(shp->sh_seq[2]);
 			    ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
 			}
 		    }
-		    (void)printf("seg %d ", ack & SGQ_MASK);
-		    TCHECK(*lsmp);
+		    ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
+		    ND_TCHECK(*lsmp);
 		    lsflags = EXTRACT_LE_8BITS(lsmp->ls_lsflags);
 		    fcval = EXTRACT_LE_8BITS(lsmp->ls_fcval);
 		    switch (lsflags & LSI_MASK) {
 		    case LSI_DATA:
-			(void)printf("dat seg count %d ", fcval);
+			ND_PRINT((ndo, "dat seg count %d ", fcval));
 			switch (lsflags & LSM_MASK) {
 			case LSM_NOCHANGE:
 			    break;
 			case LSM_DONOTSEND:
-			    (void)printf("donotsend-data ");
+			    ND_PRINT((ndo, "donotsend-data "));
 			    break;
 			case LSM_SEND:
-			    (void)printf("send-data ");
+			    ND_PRINT((ndo, "send-data "));
 			    break;
 			default:
-			    (void)printf("reserved-fcmod? %x", lsflags);
+			    ND_PRINT((ndo, "reserved-fcmod? %x", lsflags));
 			    break;
 			}
 			break;
 		    case LSI_INTR:
-			(void)printf("intr req count %d ", fcval);
+			ND_PRINT((ndo, "intr req count %d ", fcval));
 			break;
 		    default:
-			(void)printf("reserved-fcval-int? %x", lsflags);
+			ND_PRINT((ndo, "reserved-fcval-int? %x", lsflags));
 			break;
 		    }
 		}
 		break;
 	    default:
-		(void)printf("reserved-subtype? %x %d > %d", flags, src, dst);
+		ND_PRINT((ndo, "reserved-subtype? %x %d > %d", flags, src, dst));
 		break;
 	    }
 	    break;
 	case MFT_ACK:
 	    switch (flags & NSP_SUBMASK) {
 	    case MFS_DACK:
-		(void)printf("data-ack %d>%d ", src, dst);
+		ND_PRINT((ndo, "data-ack %d>%d ", src, dst));
 		{
 		    struct ackmsg *amp = (struct ackmsg *)nspp;
 		    int ack;
 
 		    if (nsplen < sizeof(struct ackmsg))
 			goto trunc;
-		    TCHECK(*amp);
+		    ND_TCHECK(*amp);
 		    ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]);
 		    if (ack & SGQ_ACK) {	/* acknum field */
 			if ((ack & SGQ_NAK) == SGQ_NAK)
-			    (void)printf("nak %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
 			else
-			    (void)printf("ack %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
 		        ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]);
 			if (ack & SGQ_OACK) {	/* ackoth field */
 			    if ((ack & SGQ_ONAK) == SGQ_ONAK)
-				(void)printf("onak %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK));
 			    else
-				(void)printf("oack %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK));
 			}
 		    }
 		}
 		break;
 	    case MFS_IACK:
-		(void)printf("ils-ack %d>%d ", src, dst);
+		ND_PRINT((ndo, "ils-ack %d>%d ", src, dst));
 		{
 		    struct ackmsg *amp = (struct ackmsg *)nspp;
 		    int ack;
 
 		    if (nsplen < sizeof(struct ackmsg))
 			goto trunc;
-		    TCHECK(*amp);
+		    ND_TCHECK(*amp);
 		    ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]);
 		    if (ack & SGQ_ACK) {	/* acknum field */
 			if ((ack & SGQ_NAK) == SGQ_NAK)
-			    (void)printf("nak %d ", ack & SGQ_MASK);
+			    ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
 			else
-			    (void)printf("ack %d ", ack & SGQ_MASK);
-			TCHECK(amp->ak_acknum[1]);
+			    ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
+			ND_TCHECK(amp->ak_acknum[1]);
 		        ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]);
 			if (ack & SGQ_OACK) {	/* ackdat field */
 			    if ((ack & SGQ_ONAK) == SGQ_ONAK)
-				(void)printf("nakdat %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
 			    else
-				(void)printf("ackdat %d ", ack & SGQ_MASK);
+				ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
 			}
 		    }
 		}
 		break;
 	    case MFS_CACK:
-		(void)printf("conn-ack %d", dst);
+		ND_PRINT((ndo, "conn-ack %d", dst));
 		break;
 	    default:
-		(void)printf("reserved-acktype? %x %d > %d", flags, src, dst);
+		ND_PRINT((ndo, "reserved-acktype? %x %d > %d", flags, src, dst));
 		break;
 	    }
 	    break;
@@ -650,10 +1093,10 @@
 	    case MFS_CI:
 	    case MFS_RCI:
 		if ((flags & NSP_SUBMASK) == MFS_CI)
-		    (void)printf("conn-initiate ");
+		    ND_PRINT((ndo, "conn-initiate "));
 		else
-		    (void)printf("retrans-conn-initiate ");
-		(void)printf("%d>%d ", src, dst);
+		    ND_PRINT((ndo, "retrans-conn-initiate "));
+		ND_PRINT((ndo, "%d>%d ", src, dst));
 		{
 		    struct cimsg *cimp = (struct cimsg *)nspp;
 		    int services, info, segsize;
@@ -663,7 +1106,7 @@
 
 		    if (nsplen < sizeof(struct cimsg))
 			goto trunc;
-		    TCHECK(*cimp);
+		    ND_TCHECK(*cimp);
 		    services = EXTRACT_LE_8BITS(cimp->ci_services);
 		    info = EXTRACT_LE_8BITS(cimp->ci_info);
 		    segsize = EXTRACT_LE_16BITS(cimp->ci_segsize);
@@ -672,41 +1115,41 @@
 		    case COS_NONE:
 			break;
 		    case COS_SEGMENT:
-			(void)printf("seg ");
+			ND_PRINT((ndo, "seg "));
 			break;
 		    case COS_MESSAGE:
-			(void)printf("msg ");
+			ND_PRINT((ndo, "msg "));
 			break;
 		    case COS_CRYPTSER:
-			(void)printf("crypt ");
+			ND_PRINT((ndo, "crypt "));
 			break;
 		    }
 		    switch (info & COI_MASK) {
 		    case COI_32:
-			(void)printf("ver 3.2 ");
+			ND_PRINT((ndo, "ver 3.2 "));
 			break;
 		    case COI_31:
-			(void)printf("ver 3.1 ");
+			ND_PRINT((ndo, "ver 3.1 "));
 			break;
 		    case COI_40:
-			(void)printf("ver 4.0 ");
+			ND_PRINT((ndo, "ver 4.0 "));
 			break;
 		    case COI_41:
-			(void)printf("ver 4.1 ");
+			ND_PRINT((ndo, "ver 4.1 "));
 			break;
 		    }
-		    (void)printf("segsize %d ", segsize);
+		    ND_PRINT((ndo, "segsize %d ", segsize));
 #ifdef	PRINT_NSPDATA
 		    if (nsplen > sizeof(struct cimsg)) {
 			dp = &(nspp[sizeof(struct cimsg)]);
-			TCHECK2(*dp, nsplen - sizeof(struct cimsg));
-			pdata(dp, nsplen - sizeof(struct cimsg));
+			ND_TCHECK2(*dp, nsplen - sizeof(struct cimsg));
+			pdata(ndo, dp, nsplen - sizeof(struct cimsg));
 		    }
 #endif
 		}
 		break;
 	    case MFS_CC:
-		(void)printf("conn-confirm %d>%d ", src, dst);
+		ND_PRINT((ndo, "conn-confirm %d>%d ", src, dst));
 		{
 		    struct ccmsg *ccmp = (struct ccmsg *)nspp;
 		    int services, info;
@@ -717,7 +1160,7 @@
 
 		    if (nsplen < sizeof(struct ccmsg))
 			goto trunc;
-		    TCHECK(*ccmp);
+		    ND_TCHECK(*ccmp);
 		    services = EXTRACT_LE_8BITS(ccmp->cc_services);
 		    info = EXTRACT_LE_8BITS(ccmp->cc_info);
 		    segsize = EXTRACT_LE_16BITS(ccmp->cc_segsize);
@@ -727,44 +1170,44 @@
 		    case COS_NONE:
 			break;
 		    case COS_SEGMENT:
-			(void)printf("seg ");
+			ND_PRINT((ndo, "seg "));
 			break;
 		    case COS_MESSAGE:
-			(void)printf("msg ");
+			ND_PRINT((ndo, "msg "));
 			break;
 		    case COS_CRYPTSER:
-			(void)printf("crypt ");
+			ND_PRINT((ndo, "crypt "));
 			break;
 		    }
 		    switch (info & COI_MASK) {
 		    case COI_32:
-			(void)printf("ver 3.2 ");
+			ND_PRINT((ndo, "ver 3.2 "));
 			break;
 		    case COI_31:
-			(void)printf("ver 3.1 ");
+			ND_PRINT((ndo, "ver 3.1 "));
 			break;
 		    case COI_40:
-			(void)printf("ver 4.0 ");
+			ND_PRINT((ndo, "ver 4.0 "));
 			break;
 		    case COI_41:
-			(void)printf("ver 4.1 ");
+			ND_PRINT((ndo, "ver 4.1 "));
 			break;
 		    }
-		    (void)printf("segsize %d ", segsize);
+		    ND_PRINT((ndo, "segsize %d ", segsize));
 		    if (optlen) {
-			(void)printf("optlen %d ", optlen);
+			ND_PRINT((ndo, "optlen %d ", optlen));
 #ifdef	PRINT_NSPDATA
 			if (optlen > nsplen - sizeof(struct ccmsg))
 			    goto trunc;
 			dp = &(nspp[sizeof(struct ccmsg)]);
-			TCHECK2(*dp, optlen);
-			pdata(dp, optlen);
+			ND_TCHECK2(*dp, optlen);
+			pdata(ndo, dp, optlen);
 #endif
 		    }
 		}
 		break;
 	    case MFS_DI:
-		(void)printf("disconn-initiate %d>%d ", src, dst);
+		ND_PRINT((ndo, "disconn-initiate %d>%d ", src, dst));
 		{
 		    struct dimsg *dimp = (struct dimsg *)nspp;
 		    int reason;
@@ -775,42 +1218,42 @@
 
 		    if (nsplen < sizeof(struct dimsg))
 			goto trunc;
-		    TCHECK(*dimp);
+		    ND_TCHECK(*dimp);
 		    reason = EXTRACT_LE_16BITS(dimp->di_reason);
 		    optlen = EXTRACT_LE_8BITS(dimp->di_optlen);
 
-		    print_reason(reason);
+		    print_reason(ndo, reason);
 		    if (optlen) {
-			(void)printf("optlen %d ", optlen);
+			ND_PRINT((ndo, "optlen %d ", optlen));
 #ifdef	PRINT_NSPDATA
 			if (optlen > nsplen - sizeof(struct dimsg))
 			    goto trunc;
 			dp = &(nspp[sizeof(struct dimsg)]);
-			TCHECK2(*dp, optlen);
-			pdata(dp, optlen);
+			ND_TCHECK2(*dp, optlen);
+			pdata(ndo, dp, optlen);
 #endif
 		    }
 		}
 		break;
 	    case MFS_DC:
-		(void)printf("disconn-confirm %d>%d ", src, dst);
+		ND_PRINT((ndo, "disconn-confirm %d>%d ", src, dst));
 		{
 		    struct dcmsg *dcmp = (struct dcmsg *)nspp;
 		    int reason;
 
-		    TCHECK(*dcmp);
+		    ND_TCHECK(*dcmp);
 		    reason = EXTRACT_LE_16BITS(dcmp->dc_reason);
 
-		    print_reason(reason);
+		    print_reason(ndo, reason);
 		}
 		break;
 	    default:
-		(void)printf("reserved-ctltype? %x %d > %d", flags, src, dst);
+		ND_PRINT((ndo, "reserved-ctltype? %x %d > %d", flags, src, dst));
 		break;
 	    }
 	    break;
 	default:
-	    (void)printf("reserved-type? %x %d > %d", flags, src, dst);
+	    ND_PRINT((ndo, "reserved-type? %x %d > %d", flags, src, dst));
 	    break;
 	}
 	return (1);
@@ -846,9 +1289,10 @@
 };
 
 static void
-print_reason(register int reason)
+print_reason(netdissect_options *ndo,
+             register int reason)
 {
-	printf("%s ", tok2str(reason2str, "reason-%d", reason));
+	ND_PRINT((ndo, "%s ", tok2str(reason2str, "reason-%d", reason)));
 }
 
 const char *
@@ -871,10 +1315,15 @@
 {
 #ifdef HAVE_DNET_HTOA
 	struct dn_naddr dna;
+	char *dnname;
 
 	dna.a_len = sizeof(short);
 	memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
-	return (strdup(dnet_htoa(&dna)));
+	dnname = dnet_htoa(&dna);
+	if(dnname != NULL)
+		return (strdup(dnname));
+	else
+		return(dnnum_string(dnaddr));
 #else
 	return(dnnum_string(dnaddr));	/* punt */
 #endif
@@ -882,14 +1331,15 @@
 
 #ifdef	PRINT_NSPDATA
 static void
-pdata(u_char *dp, u_int maxlen)
+pdata(netdissect_options *ndo,
+      u_char *dp, u_int maxlen)
 {
 	char c;
 	u_int x = maxlen;
 
 	while (x-- > 0) {
 	    c = *dp++;
-	    safeputchar(c);
+	    safeputchar(ndo, c);
 	}
 }
 #endif
diff --git a/print-dhcp6.c b/print-dhcp6.c
index 255f24a..53b96ef 100644
--- a/print-dhcp6.c
+++ b/print-dhcp6.c
@@ -28,7 +28,7 @@
  */
 /*
  * RFC3315: DHCPv6
- * supported DHCPv6 options: 
+ * supported DHCPv6 options:
  *  RFC3319: Session Initiation Protocol (SIP) Servers options,
  *  RFC3633: IPv6 Prefix options,
  *  RFC3646: DNS Configuration options,
@@ -40,11 +40,7 @@
  *  RFC6334: Dual-Stack Lite option,
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -59,7 +55,7 @@
 #include "extract.h"
 
 /* lease duration */
-#define DHCP6_DURATITION_INFINITE 0xffffffff
+#define DHCP6_DURATION_INFINITE 0xffffffff
 
 /* Error Values */
 #define DH6ERR_FAILURE		16
@@ -85,11 +81,30 @@
 #define DH6_LEASEQUERY	14
 #define DH6_LQ_REPLY	15
 
+static const struct tok dh6_msgtype_str[] = {
+	{ DH6_SOLICIT,     "solicit"          },
+	{ DH6_ADVERTISE,   "advertise"        },
+	{ DH6_REQUEST,     "request"          },
+	{ DH6_CONFIRM,     "confirm"          },
+	{ DH6_RENEW,       "renew"            },
+	{ DH6_REBIND,      "rebind"           },
+	{ DH6_REPLY,       "reply"            },
+	{ DH6_RELEASE,     "release"          },
+	{ DH6_DECLINE,     "decline"          },
+	{ DH6_RECONFIGURE, "reconfigure"      },
+	{ DH6_INFORM_REQ,  "inf-req"          },
+	{ DH6_RELAY_FORW,  "relay-fwd"        },
+	{ DH6_RELAY_REPLY, "relay-reply"      },
+	{ DH6_LEASEQUERY,  "leasequery"       },
+	{ DH6_LQ_REPLY,    "leasequery-reply" },
+	{ 0, NULL }
+};
+
 /* DHCP6 base packet format */
 struct dhcp6 {
 	union {
-		u_int8_t m;
-		u_int32_t x;
+		uint8_t m;
+		uint32_t x;
 	} dh6_msgtypexid;
 	/* options follow */
 };
@@ -99,10 +114,10 @@
 
 /* DHCPv6 relay messages */
 struct dhcp6_relay {
-	u_int8_t dh6relay_msgtype;
-	u_int8_t dh6relay_hcnt;
-	u_int8_t dh6relay_linkaddr[16];	/* XXX: badly aligned */
-	u_int8_t dh6relay_peeraddr[16];
+	uint8_t dh6relay_msgtype;
+	uint8_t dh6relay_hcnt;
+	uint8_t dh6relay_linkaddr[16];	/* XXX: badly aligned */
+	uint8_t dh6relay_peeraddr[16];
 	/* options follow */
 };
 
@@ -178,174 +193,100 @@
 #  define DH6OPT_NTP_SUBOPTION_SRV_FQDN 3
 #define DH6OPT_AFTR_NAME 64
 
+static const struct tok dh6opt_str[] = {
+	{ DH6OPT_CLIENTID,           "client-ID"            },
+	{ DH6OPT_SERVERID,           "server-ID"            },
+	{ DH6OPT_IA_NA,              "IA_NA"                },
+	{ DH6OPT_IA_TA,              "IA_TA"                },
+	{ DH6OPT_IA_ADDR,            "IA_ADDR"              },
+	{ DH6OPT_ORO,                "option-request"       },
+	{ DH6OPT_PREFERENCE,         "preference"           },
+	{ DH6OPT_ELAPSED_TIME,       "elapsed-time"         },
+	{ DH6OPT_RELAY_MSG,          "relay-message"        },
+	{ DH6OPT_AUTH,               "authentication"       },
+	{ DH6OPT_UNICAST,            "server-unicast"       },
+	{ DH6OPT_STATUS_CODE,        "status-code"          },
+	{ DH6OPT_RAPID_COMMIT,       "rapid-commit"         },
+	{ DH6OPT_USER_CLASS,         "user-class"           },
+	{ DH6OPT_VENDOR_CLASS,       "vendor-class"         },
+	{ DH6OPT_VENDOR_OPTS,        "vendor-specific-info" },
+	{ DH6OPT_INTERFACE_ID,       "interface-ID"         },
+	{ DH6OPT_RECONF_MSG,         "reconfigure-message"  },
+	{ DH6OPT_RECONF_ACCEPT,      "reconfigure-accept"   },
+	{ DH6OPT_SIP_SERVER_D,       "SIP-servers-domain"   },
+	{ DH6OPT_SIP_SERVER_A,       "SIP-servers-address"  },
+	{ DH6OPT_DNS_SERVERS,        "DNS-server"           },
+	{ DH6OPT_DOMAIN_LIST,        "DNS-search-list"      },
+	{ DH6OPT_IA_PD,              "IA_PD"                },
+	{ DH6OPT_IA_PD_PREFIX,       "IA_PD-prefix"         },
+	{ DH6OPT_SNTP_SERVERS,       "SNTP-servers"         },
+	{ DH6OPT_LIFETIME,           "lifetime"             },
+	{ DH6OPT_NIS_SERVERS,        "NIS-server"           },
+	{ DH6OPT_NISP_SERVERS,       "NIS+-server"          },
+	{ DH6OPT_NIS_NAME,           "NIS-domain-name"      },
+	{ DH6OPT_NISP_NAME,          "NIS+-domain-name"     },
+	{ DH6OPT_BCMCS_SERVER_D,     "BCMCS-domain-name"    },
+	{ DH6OPT_BCMCS_SERVER_A,     "BCMCS-server"         },
+	{ DH6OPT_GEOCONF_CIVIC,      "Geoconf-Civic"        },
+	{ DH6OPT_REMOTE_ID,          "Remote-ID"            },
+	{ DH6OPT_SUBSCRIBER_ID,      "Subscriber-ID"        },
+	{ DH6OPT_CLIENT_FQDN,        "Client-FQDN"          },
+	{ DH6OPT_PANA_AGENT,         "PANA-agent"           },
+	{ DH6OPT_NEW_POSIX_TIMEZONE, "POSIX-timezone"       },
+	{ DH6OPT_NEW_TZDB_TIMEZONE,  "POSIX-tz-database"    },
+	{ DH6OPT_ERO,                "Echo-request-option"  },
+	{ DH6OPT_LQ_QUERY,           "Lease-query"          },
+	{ DH6OPT_CLIENT_DATA,        "LQ-client-data"       },
+	{ DH6OPT_CLT_TIME,           "Clt-time"             },
+	{ DH6OPT_LQ_RELAY_DATA,      "LQ-relay-data"        },
+	{ DH6OPT_LQ_CLIENT_LINK,     "LQ-client-link"       },
+	{ DH6OPT_NTP_SERVER,         "NTP-server"           },
+	{ DH6OPT_AFTR_NAME,          "AFTR-Name"            },
+	{ 0, NULL }
+};
+
+static const struct tok dh6opt_stcode_str[] = {
+	{ DH6OPT_STCODE_SUCCESS,          "success"            },
+	{ DH6OPT_STCODE_UNSPECFAIL,       "unspec failure"     },
+	{ DH6OPT_STCODE_NOADDRAVAIL,      "no addresses"       },
+	{ DH6OPT_STCODE_NOBINDING,        "no binding"         },
+	{ DH6OPT_STCODE_NOTONLINK,        "not on-link"        },
+	{ DH6OPT_STCODE_USEMULTICAST,     "use multicast"      },
+	{ DH6OPT_STCODE_NOPREFIXAVAIL,    "no prefixes"        },
+	{ DH6OPT_STCODE_UNKNOWNQUERYTYPE, "unknown query type" },
+	{ DH6OPT_STCODE_MALFORMEDQUERY,   "malformed query"    },
+	{ DH6OPT_STCODE_NOTCONFIGURED,    "not configured"     },
+	{ DH6OPT_STCODE_NOTALLOWED,       "not allowed"        },
+	{ 0, NULL }
+};
+
 struct dhcp6opt {
-	u_int16_t dh6opt_type;
-	u_int16_t dh6opt_len;
+	uint16_t dh6opt_type;
+	uint16_t dh6opt_len;
 	/* type-dependent data follows */
 };
 
 static const char *
-dhcp6opt_name(int type)
+dhcp6stcode(const uint16_t code)
 {
-	static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
-
-	if (type > 65535)
-		return "INVALID-option";
-
-	switch(type) {
-	case DH6OPT_CLIENTID:
-		return "client-ID";
-	case DH6OPT_SERVERID:
-		return "server-ID";
-	case DH6OPT_IA_NA:
-		return "IA_NA";
-	case DH6OPT_IA_TA:
-		return "IA_TA";
-	case DH6OPT_IA_ADDR:
-		return "IA_ADDR";
-	case DH6OPT_ORO:
-		return "option-request";
-	case DH6OPT_PREFERENCE:
-		return "preference";
-	case DH6OPT_ELAPSED_TIME:
-		return "elapsed-time";
-	case DH6OPT_RELAY_MSG:
-		return "relay-message";
-	case DH6OPT_AUTH:
-		return "authentication";
-	case DH6OPT_UNICAST:
-		return "server-unicast";
-	case DH6OPT_STATUS_CODE:
-		return "status-code";
-	case DH6OPT_RAPID_COMMIT:
-		return "rapid-commit";
-	case DH6OPT_USER_CLASS:
-		return "user-class";
-	case DH6OPT_VENDOR_CLASS:
-		return "vendor-class";
-	case DH6OPT_VENDOR_OPTS:
-		return "vendor-specific-info";
-	case DH6OPT_INTERFACE_ID:
-		return "interface-ID";
-	case DH6OPT_RECONF_MSG:
-		return "reconfigure-message";
-	case DH6OPT_RECONF_ACCEPT:
-		return "reconfigure-accept";
-	case DH6OPT_SIP_SERVER_D:
-		return "SIP-servers-domain";
-	case DH6OPT_SIP_SERVER_A:
-		return "SIP-servers-address";
-	case DH6OPT_DNS_SERVERS:
-		return "DNS-server";
-	case DH6OPT_DOMAIN_LIST:
-		return "DNS-search-list";
-	case DH6OPT_IA_PD:
-		return "IA_PD";
-	case DH6OPT_IA_PD_PREFIX:
-		return "IA_PD-prefix";
-	case DH6OPT_SNTP_SERVERS:
-		return "SNTP-servers";
-	case DH6OPT_LIFETIME:
-		return "lifetime";
-	case DH6OPT_NIS_SERVERS:
-		return "NIS-server";
-	case DH6OPT_NISP_SERVERS:
-		return "NIS+-server";
-	case DH6OPT_NIS_NAME:
-		return "NIS-domain-name";
-	case DH6OPT_NISP_NAME:
-		return "NIS+-domain-name";
-	case DH6OPT_BCMCS_SERVER_D:
-		return "BCMCS-domain-name";
-	case DH6OPT_BCMCS_SERVER_A:
-		return "BCMCS-server";
-	case DH6OPT_GEOCONF_CIVIC:
-		return "Geoconf-Civic";
-	case DH6OPT_REMOTE_ID:
-		return "Remote-ID";
-	case DH6OPT_SUBSCRIBER_ID:
-		return "Subscriber-ID";
-	case DH6OPT_CLIENT_FQDN:
-		return "Client-FQDN";
-	case DH6OPT_PANA_AGENT:
-		return "PANA-agent";
-	case DH6OPT_NEW_POSIX_TIMEZONE:
-		return "POSIX-timezone";
-	case DH6OPT_NEW_TZDB_TIMEZONE:
-		return "POSIX-tz-database";
-	case DH6OPT_ERO:
-		return "Echo-request-option";
-	case DH6OPT_LQ_QUERY:
-		return "Lease-query";
-	case DH6OPT_CLIENT_DATA:
-		return "LQ-client-data";
-	case DH6OPT_CLT_TIME:
-		return "Clt-time";
-	case DH6OPT_LQ_RELAY_DATA:
-		return "LQ-relay-data";
-	case DH6OPT_LQ_CLIENT_LINK:
-		return "LQ-client-link";
-	case DH6OPT_NTP_SERVER:
-		return "NTP-server";
-	case DH6OPT_AFTR_NAME:
-		return "AFTR-Name";
-	default:
-		snprintf(genstr, sizeof(genstr), "opt_%d", type);
-		return(genstr);
-	}
-}
-
-static const char *
-dhcp6stcode(int code)
-{
-	static char genstr[sizeof("code255") + 1]; /* XXX thread unsafe */
-
-	if (code > 255)
-		return "INVALID code";
-
-	switch(code) {
-	case DH6OPT_STCODE_SUCCESS:
-		return "success";
-	case DH6OPT_STCODE_UNSPECFAIL:
-		return "unspec failure";
-	case DH6OPT_STCODE_NOADDRAVAIL:
-		return "no addresses";
-	case DH6OPT_STCODE_NOBINDING:
-		return "no binding";
-	case DH6OPT_STCODE_NOTONLINK:
-		return "not on-link";
-	case DH6OPT_STCODE_USEMULTICAST:
-		return "use multicast";
-	case DH6OPT_STCODE_NOPREFIXAVAIL:
-		return "no prefixes";
-	case DH6OPT_STCODE_UNKNOWNQUERYTYPE:
-		return "unknown query type";
-	case DH6OPT_STCODE_MALFORMEDQUERY:
-		return "malformed query";
-	case DH6OPT_STCODE_NOTCONFIGURED:
-		return "not configured";
-	case DH6OPT_STCODE_NOTALLOWED:
-		return "not allowed";
-	default:
-		snprintf(genstr, sizeof(genstr), "code%d", code);
-		return(genstr);
-	}
+	return code > 255 ? "INVALID code" : tok2str(dh6opt_stcode_str, "code%u", code);
 }
 
 static void
-dhcp6opt_print(const u_char *cp, const u_char *ep)
+dhcp6opt_print(netdissect_options *ndo,
+               const u_char *cp, const u_char *ep)
 {
 	const struct dhcp6opt *dh6o;
 	const u_char *tp;
 	size_t i;
-	u_int16_t opttype;
+	uint16_t opttype;
 	size_t optlen;
-	u_int8_t auth_proto;
+	uint8_t auth_proto;
 	u_int authinfolen, authrealmlen;
 	int remain_len;  /* Length of remaining options */
 	int label_len;   /* Label length */
-	u_int16_t subopt_code;
-	u_int16_t subopt_len;
+	uint16_t subopt_code;
+	uint16_t subopt_len;
 
 	if (cp == ep)
 		return;
@@ -353,159 +294,159 @@
 		if (ep < cp + sizeof(*dh6o))
 			goto trunc;
 		dh6o = (struct dhcp6opt *)cp;
-		TCHECK(*dh6o);
+		ND_TCHECK(*dh6o);
 		optlen = EXTRACT_16BITS(&dh6o->dh6opt_len);
 		if (ep < cp + sizeof(*dh6o) + optlen)
 			goto trunc;
 		opttype = EXTRACT_16BITS(&dh6o->dh6opt_type);
-		printf(" (%s", dhcp6opt_name(opttype));
+		ND_PRINT((ndo, " (%s", tok2str(dh6opt_str, "opt_%u", opttype)));
 		switch (opttype) {
 		case DH6OPT_CLIENTID:
 		case DH6OPT_SERVERID:
 			if (optlen < 2) {
 				/*(*/
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
 			switch (EXTRACT_16BITS(tp)) {
 			case 1:
 				if (optlen >= 2 + 6) {
-					printf(" hwaddr/time type %u time %u ",
+					ND_PRINT((ndo, " hwaddr/time type %u time %u ",
 					    EXTRACT_16BITS(&tp[2]),
-					    EXTRACT_32BITS(&tp[4]));
+					    EXTRACT_32BITS(&tp[4])));
 					for (i = 8; i < optlen; i++)
-						printf("%02x", tp[i]);
+						ND_PRINT((ndo, "%02x", tp[i]));
 					/*(*/
-					printf(")");
+					ND_PRINT((ndo, ")"));
 				} else {
 					/*(*/
-					printf(" ?)");
+					ND_PRINT((ndo, " ?)"));
 				}
 				break;
 			case 2:
 				if (optlen >= 2 + 8) {
-					printf(" vid ");
+					ND_PRINT((ndo, " vid "));
 					for (i = 2; i < 2 + 8; i++)
-						printf("%02x", tp[i]);
+						ND_PRINT((ndo, "%02x", tp[i]));
 					/*(*/
-					printf(")");
+					ND_PRINT((ndo, ")"));
 				} else {
 					/*(*/
-					printf(" ?)");
+					ND_PRINT((ndo, " ?)"));
 				}
 				break;
 			case 3:
 				if (optlen >= 2 + 2) {
-					printf(" hwaddr type %u ",
-					    EXTRACT_16BITS(&tp[2]));
+					ND_PRINT((ndo, " hwaddr type %u ",
+					    EXTRACT_16BITS(&tp[2])));
 					for (i = 4; i < optlen; i++)
-						printf("%02x", tp[i]);
+						ND_PRINT((ndo, "%02x", tp[i]));
 					/*(*/
-					printf(")");
+					ND_PRINT((ndo, ")"));
 				} else {
 					/*(*/
-					printf(" ?)");
+					ND_PRINT((ndo, " ?)"));
 				}
 				break;
 			default:
-				printf(" type %d)", EXTRACT_16BITS(tp));
+				ND_PRINT((ndo, " type %d)", EXTRACT_16BITS(tp)));
 				break;
 			}
 			break;
 		case DH6OPT_IA_ADDR:
 			if (optlen < 24) {
 				/*(*/
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %s", ip6addr_string(&tp[0]));
-			printf(" pltime:%u vltime:%u",
+			ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0])));
+			ND_PRINT((ndo, " pltime:%u vltime:%u",
 			    EXTRACT_32BITS(&tp[16]),
-			    EXTRACT_32BITS(&tp[20]));
+			    EXTRACT_32BITS(&tp[20])));
 			if (optlen > 24) {
 				/* there are sub-options */
-				dhcp6opt_print(tp + 24, tp + optlen);
+				dhcp6opt_print(ndo, tp + 24, tp + optlen);
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_ORO:
 		case DH6OPT_ERO:
 			if (optlen % 2) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
 			for (i = 0; i < optlen; i += 2) {
-				printf(" %s",
-				    dhcp6opt_name(EXTRACT_16BITS(&tp[i])));
+				ND_PRINT((ndo, " %s",
+				    tok2str(dh6opt_str, "opt_%u", EXTRACT_16BITS(&tp[i]))));
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_PREFERENCE:
 			if (optlen != 1) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %d)", *tp);
+			ND_PRINT((ndo, " %d)", *tp));
 			break;
 		case DH6OPT_ELAPSED_TIME:
 			if (optlen != 2) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %d)", EXTRACT_16BITS(tp));
+			ND_PRINT((ndo, " %d)", EXTRACT_16BITS(tp)));
 			break;
 		case DH6OPT_RELAY_MSG:
-			printf(" (");
+			ND_PRINT((ndo, " ("));
 			tp = (u_char *)(dh6o + 1);
-			dhcp6_print(tp, optlen);
-			printf(")");
+			dhcp6_print(ndo, tp, optlen);
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_AUTH:
 			if (optlen < 11) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
 			auth_proto = *tp;
 			switch (auth_proto) {
 			case DH6OPT_AUTHPROTO_DELAYED:
-				printf(" proto: delayed");
+				ND_PRINT((ndo, " proto: delayed"));
 				break;
 			case DH6OPT_AUTHPROTO_RECONFIG:
-				printf(" proto: reconfigure");
+				ND_PRINT((ndo, " proto: reconfigure"));
 				break;
 			default:
-				printf(" proto: %d", auth_proto);
+				ND_PRINT((ndo, " proto: %d", auth_proto));
 				break;
 			}
 			tp++;
 			switch (*tp) {
 			case DH6OPT_AUTHALG_HMACMD5:
 				/* XXX: may depend on the protocol */
-				printf(", alg: HMAC-MD5");
+				ND_PRINT((ndo, ", alg: HMAC-MD5"));
 				break;
 			default:
-				printf(", alg: %d", *tp);
+				ND_PRINT((ndo, ", alg: %d", *tp));
 				break;
 			}
 			tp++;
 			switch (*tp) {
 			case DH6OPT_AUTHRDM_MONOCOUNTER:
-				printf(", RDM: mono");
+				ND_PRINT((ndo, ", RDM: mono"));
 				break;
 			default:
-				printf(", RDM: %d", *tp);
+				ND_PRINT((ndo, ", RDM: %d", *tp));
 				break;
 			}
 			tp++;
-			printf(", RD:");
+			ND_PRINT((ndo, ", RD:"));
 			for (i = 0; i < 4; i++, tp += 2)
-				printf(" %04x", EXTRACT_16BITS(tp));
+				ND_PRINT((ndo, " %04x", EXTRACT_16BITS(tp)));
 
 			/* protocol dependent part */
 			authinfolen = optlen - 11;
@@ -514,50 +455,50 @@
 				if (authinfolen == 0)
 					break;
 				if (authinfolen < 20) {
-					printf(" ??");
+					ND_PRINT((ndo, " ??"));
 					break;
 				}
 				authrealmlen = authinfolen - 20;
 				if (authrealmlen > 0) {
-					printf(", realm: ");
+					ND_PRINT((ndo, ", realm: "));
 				}
 				for (i = 0; i < authrealmlen; i++, tp++)
-					printf("%02x", *tp);
-				printf(", key ID: %08x", EXTRACT_32BITS(tp));
+					ND_PRINT((ndo, "%02x", *tp));
+				ND_PRINT((ndo, ", key ID: %08x", EXTRACT_32BITS(tp)));
 				tp += 4;
-				printf(", HMAC-MD5:");
+				ND_PRINT((ndo, ", HMAC-MD5:"));
 				for (i = 0; i < 4; i++, tp+= 4)
-					printf(" %08x", EXTRACT_32BITS(tp));
+					ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp)));
 				break;
 			case DH6OPT_AUTHPROTO_RECONFIG:
 				if (authinfolen != 17) {
-					printf(" ??");
+					ND_PRINT((ndo, " ??"));
 					break;
 				}
 				switch (*tp++) {
 				case DH6OPT_AUTHRECONFIG_KEY:
-					printf(" reconfig-key");
+					ND_PRINT((ndo, " reconfig-key"));
 					break;
 				case DH6OPT_AUTHRECONFIG_HMACMD5:
-					printf(" type: HMAC-MD5");
+					ND_PRINT((ndo, " type: HMAC-MD5"));
 					break;
 				default:
-					printf(" type: ??");
+					ND_PRINT((ndo, " type: ??"));
 					break;
 				}
-				printf(" value:");
+				ND_PRINT((ndo, " value:"));
 				for (i = 0; i < 4; i++, tp+= 4)
-					printf(" %08x", EXTRACT_32BITS(tp));
+					ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp)));
 				break;
 			default:
-				printf(" ??");
+				ND_PRINT((ndo, " ??"));
 				break;
 			}
 
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_RAPID_COMMIT: /* nothing todo */
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_INTERFACE_ID:
 		case DH6OPT_SUBSCRIBER_ID:
@@ -566,27 +507,27 @@
 			 * at most 10 characters.
 			 */
 			tp = (u_char *)(dh6o + 1);
-			printf(" ");
+			ND_PRINT((ndo, " "));
 			for (i = 0; i < optlen && i < 10; i++)
-				printf("%02x", tp[i]);
-			printf("...)");
+				ND_PRINT((ndo, "%02x", tp[i]));
+			ND_PRINT((ndo, "...)"));
 			break;
 		case DH6OPT_RECONF_MSG:
 			tp = (u_char *)(dh6o + 1);
 			switch (*tp) {
 			case DH6_RENEW:
-				printf(" for renew)");
+				ND_PRINT((ndo, " for renew)"));
 				break;
 			case DH6_INFORM_REQ:
-				printf(" for inf-req)");
+				ND_PRINT((ndo, " for inf-req)"));
 				break;
 			default:
-				printf(" for ?\?\?(%02x))", *tp);
+				ND_PRINT((ndo, " for ?\?\?(%02x))", *tp));
 				break;
 			}
 			break;
 		case DH6OPT_RECONF_ACCEPT: /* nothing todo */
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_SIP_SERVER_A:
 		case DH6OPT_DNS_SERVERS:
@@ -597,150 +538,150 @@
 		case DH6OPT_PANA_AGENT:
 		case DH6OPT_LQ_CLIENT_LINK:
 			if (optlen % 16) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
 			for (i = 0; i < optlen; i += 16)
-				printf(" %s", ip6addr_string(&tp[i]));
-			printf(")");
+				ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[i])));
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_SIP_SERVER_D:
 		case DH6OPT_DOMAIN_LIST:
 			tp = (u_char *)(dh6o + 1);
 			while (tp < cp + sizeof(*dh6o) + optlen) {
-				putchar(' ');
-				if ((tp = ns_nprint(tp, cp + sizeof(*dh6o) + optlen)) == NULL)
+				ND_PRINT((ndo, " "));
+				if ((tp = ns_nprint(ndo, tp, cp + sizeof(*dh6o) + optlen)) == NULL)
 					goto trunc;
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_STATUS_CODE:
 			if (optlen < 2) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0])));
+			ND_PRINT((ndo, " %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0]))));
 			break;
 		case DH6OPT_IA_NA:
 		case DH6OPT_IA_PD:
 			if (optlen < 12) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" IAID:%u T1:%u T2:%u",
+			ND_PRINT((ndo, " IAID:%u T1:%u T2:%u",
 			    EXTRACT_32BITS(&tp[0]),
 			    EXTRACT_32BITS(&tp[4]),
-			    EXTRACT_32BITS(&tp[8]));
+			    EXTRACT_32BITS(&tp[8])));
 			if (optlen > 12) {
 				/* there are sub-options */
-				dhcp6opt_print(tp + 12, tp + optlen);
+				dhcp6opt_print(ndo, tp + 12, tp + optlen);
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_IA_TA:
 			if (optlen < 4) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" IAID:%u", EXTRACT_32BITS(tp));
+			ND_PRINT((ndo, " IAID:%u", EXTRACT_32BITS(tp)));
 			if (optlen > 4) {
 				/* there are sub-options */
-				dhcp6opt_print(tp + 4, tp + optlen);
+				dhcp6opt_print(ndo, tp + 4, tp + optlen);
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_IA_PD_PREFIX:
 			if (optlen < 25) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %s/%d", ip6addr_string(&tp[9]), tp[8]);
-			printf(" pltime:%u vltime:%u",
+			ND_PRINT((ndo, " %s/%d", ip6addr_string(ndo, &tp[9]), tp[8]));
+			ND_PRINT((ndo, " pltime:%u vltime:%u",
 			    EXTRACT_32BITS(&tp[0]),
-			    EXTRACT_32BITS(&tp[4]));
+			    EXTRACT_32BITS(&tp[4])));
 			if (optlen > 25) {
 				/* there are sub-options */
-				dhcp6opt_print(tp + 25, tp + optlen);
+				dhcp6opt_print(ndo, tp + 25, tp + optlen);
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_LIFETIME:
 		case DH6OPT_CLT_TIME:
 			if (optlen != 4) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %d)", EXTRACT_32BITS(tp));
+			ND_PRINT((ndo, " %d)", EXTRACT_32BITS(tp)));
 			break;
 		case DH6OPT_REMOTE_ID:
 			if (optlen < 4) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %d ", EXTRACT_32BITS(tp));
+			ND_PRINT((ndo, " %d ", EXTRACT_32BITS(tp)));
 			/*
 			 * Print hex dump first 10 characters.
 			 */
 			for (i = 4; i < optlen && i < 14; i++)
-				printf("%02x", tp[i]);
-			printf("...)");
+				ND_PRINT((ndo, "%02x", tp[i]));
+			ND_PRINT((ndo, "...)"));
 			break;
 		case DH6OPT_LQ_QUERY:
 			if (optlen < 17) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
 			switch (*tp) {
 			case 1:
-				printf(" by-address");
+				ND_PRINT((ndo, " by-address"));
 				break;
 			case 2:
-				printf(" by-clientID");
+				ND_PRINT((ndo, " by-clientID"));
 				break;
 			default:
-				printf(" type_%d", (int)*tp);
+				ND_PRINT((ndo, " type_%d", (int)*tp));
 				break;
 			}
-			printf(" %s", ip6addr_string(&tp[1]));
+			ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[1])));
 			if (optlen > 17) {
 				/* there are query-options */
-				dhcp6opt_print(tp + 17, tp + optlen);
+				dhcp6opt_print(ndo, tp + 17, tp + optlen);
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_CLIENT_DATA:
 			tp = (u_char *)(dh6o + 1);
 			if (optlen > 0) {
 				/* there are encapsulated options */
-				dhcp6opt_print(tp, tp + optlen);
+				dhcp6opt_print(ndo, tp, tp + optlen);
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_LQ_RELAY_DATA:
 			if (optlen < 16) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
-			printf(" %s ", ip6addr_string(&tp[0]));
+			ND_PRINT((ndo, " %s ", ip6addr_string(ndo, &tp[0])));
 			/*
 			 * Print hex dump first 10 characters.
 			 */
 			for (i = 16; i < optlen && i < 26; i++)
-				printf("%02x", tp[i]);
-			printf("...)");
+				ND_PRINT((ndo, "%02x", tp[i]));
+			ND_PRINT((ndo, "...)"));
 			break;
 		case DH6OPT_NTP_SERVER:
 			if (optlen < 4) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
@@ -751,54 +692,54 @@
 				tp += 2;
 				if (tp + subopt_len > cp + sizeof(*dh6o) + optlen)
 					goto trunc;
-				printf(" subopt:%d", subopt_code);
+				ND_PRINT((ndo, " subopt:%d", subopt_code));
 				switch (subopt_code) {
 				case DH6OPT_NTP_SUBOPTION_SRV_ADDR:
 				case DH6OPT_NTP_SUBOPTION_MC_ADDR:
 					if (subopt_len != 16) {
-						printf(" ?");
+						ND_PRINT((ndo, " ?"));
 						break;
 					}
-					printf(" %s", ip6addr_string(&tp[0]));
+					ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0])));
 					break;
 				case DH6OPT_NTP_SUBOPTION_SRV_FQDN:
-					putchar(' ');
-					if (ns_nprint(tp, tp + subopt_len) == NULL)
+					ND_PRINT((ndo, " "));
+					if (ns_nprint(ndo, tp, tp + subopt_len) == NULL)
 						goto trunc;
 					break;
 				default:
-					printf(" ?");
+					ND_PRINT((ndo, " ?"));
 					break;
 				}
 				tp += subopt_len;
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		case DH6OPT_AFTR_NAME:
 			if (optlen < 3) {
-				printf(" ?)");
+				ND_PRINT((ndo, " ?)"));
 				break;
 			}
 			tp = (u_char *)(dh6o + 1);
 			remain_len = optlen;
-			printf(" ");
+			ND_PRINT((ndo, " "));
 			/* Encoding is described in section 3.1 of RFC 1035 */
 			while (remain_len && *tp) {
 				label_len =  *tp++;
 				if (label_len < remain_len - 1) {
-					printf("%.*s", label_len, tp);
+					ND_PRINT((ndo, "%.*s", label_len, tp));
 					tp += label_len;
 					remain_len -= (label_len + 1);
-					if(*tp) printf(".");
+					if(*tp) ND_PRINT((ndo, "."));
 				} else {
-					printf(" ?");
+					ND_PRINT((ndo, " ?"));
 					break;
 				}
 			}
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		default:
-			printf(")");
+			ND_PRINT((ndo, ")"));
 			break;
 		}
 
@@ -807,14 +748,15 @@
 	return;
 
 trunc:
-	printf("[|dhcp6ext]");
+	ND_PRINT((ndo, "[|dhcp6ext]"));
 }
 
 /*
  * Print dhcp6 packets
  */
 void
-dhcp6_print(const u_char *cp, u_int length)
+dhcp6_print(netdissect_options *ndo,
+            const u_char *cp, u_int length)
 {
 	struct dhcp6 *dh6;
 	struct dhcp6_relay *dh6relay;
@@ -822,104 +764,47 @@
 	u_char *extp;
 	const char *name;
 
-	printf("dhcp6");
+	ND_PRINT((ndo, "dhcp6"));
 
-	ep = (u_char *)snapend;
+	ep = (u_char *)ndo->ndo_snapend;
 	if (cp + length < ep)
 		ep = cp + length;
 
 	dh6 = (struct dhcp6 *)cp;
 	dh6relay = (struct dhcp6_relay *)cp;
-	TCHECK(dh6->dh6_xid);
-	switch (dh6->dh6_msgtype) {
-	case DH6_SOLICIT:
-		name = "solicit";
-		break;
-	case DH6_ADVERTISE:
-		name = "advertise";
-		break;
-	case DH6_REQUEST:
-		name = "request";
-		break;
-	case DH6_CONFIRM:
-		name = "confirm";
-		break;
-	case DH6_RENEW:
-		name = "renew";
-		break;
-	case DH6_REBIND:
-		name = "rebind";
-		break;
-	case DH6_REPLY:
-		name = "reply";
-		break;
-	case DH6_RELEASE:
-		name = "release";
-		break;
-	case DH6_DECLINE:
-		name = "decline";
-		break;
-	case DH6_RECONFIGURE:
-		name = "reconfigure";
-		break;
-	case DH6_INFORM_REQ:
-		name= "inf-req";
-		break;
-	case DH6_RELAY_FORW:
-		name= "relay-fwd";
-		break;
-	case DH6_RELAY_REPLY:
-		name= "relay-reply";
-		break;
-	case DH6_LEASEQUERY:
-		name= "leasequery";
-		break;
-	case DH6_LQ_REPLY:
-		name= "leasequery-reply";
-		break;
-	default:
-		name = NULL;
-		break;
-	}
+	ND_TCHECK(dh6->dh6_xid);
+	name = tok2str(dh6_msgtype_str, "msgtype-%u", dh6->dh6_msgtype);
 
-	if (!vflag) {
-		if (name)
-			printf(" %s", name);
-		else if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
-		    dh6->dh6_msgtype != DH6_RELAY_REPLY) {
-			printf(" msgtype-%u", dh6->dh6_msgtype);
-		}
+	if (!ndo->ndo_vflag) {
+		ND_PRINT((ndo, " %s", name));
 		return;
 	}
 
 	/* XXX relay agent messages have to be handled differently */
 
-	if (name)
-		printf(" %s (", name);	/*)*/
-	else
-		printf(" msgtype-%u (", dh6->dh6_msgtype);	/*)*/
+	ND_PRINT((ndo, " %s (", name));	/*)*/
 	if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
 	    dh6->dh6_msgtype != DH6_RELAY_REPLY) {
-		printf("xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK);
+		ND_PRINT((ndo, "xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK));
 		extp = (u_char *)(dh6 + 1);
-		dhcp6opt_print(extp, ep);
+		dhcp6opt_print(ndo, extp, ep);
 	} else {		/* relay messages */
 		struct in6_addr addr6;
 
-		TCHECK(dh6relay->dh6relay_peeraddr);
+		ND_TCHECK(dh6relay->dh6relay_peeraddr);
 
 		memcpy(&addr6, dh6relay->dh6relay_linkaddr, sizeof (addr6));
-		printf("linkaddr=%s", ip6addr_string(&addr6));
+		ND_PRINT((ndo, "linkaddr=%s", ip6addr_string(ndo, &addr6)));
 
 		memcpy(&addr6, dh6relay->dh6relay_peeraddr, sizeof (addr6));
-		printf(" peeraddr=%s", ip6addr_string(&addr6));
+		ND_PRINT((ndo, " peeraddr=%s", ip6addr_string(ndo, &addr6)));
 
-		dhcp6opt_print((u_char *)(dh6relay + 1), ep);
+		dhcp6opt_print(ndo, (u_char *)(dh6relay + 1), ep);
 	}
 	/*(*/
-	printf(")");
+	ND_PRINT((ndo, ")"));
 	return;
 
 trunc:
-	printf("[|dhcp6]");
+	ND_PRINT((ndo, "[|dhcp6]"));
 }
diff --git a/print-domain.c b/print-domain.c
index 80e8ce9..8805007 100644
--- a/print-domain.c
+++ b/print-domain.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.98 2007-12-09 01:40:32 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -32,7 +28,6 @@
 
 #include "nameser.h"
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
@@ -41,7 +36,7 @@
 
 static const char *ns_ops[] = {
 	"", " inv_q", " stat", " op3", " notify", " update", " op6", " op7",
-	" op8", " updataA", " updateD", " updateDA",
+	" op8", " updateA", " updateD", " updateDA",
 	" updateM", " updateMA", " zoneInit", " zoneRef",
 };
 
@@ -54,11 +49,12 @@
 
 /* skip over a domain name */
 static const u_char *
-ns_nskip(register const u_char *cp)
+ns_nskip(netdissect_options *ndo,
+         register const u_char *cp)
 {
 	register u_char i;
 
-	if (!TTEST2(*cp, 1))
+	if (!ND_TTEST2(*cp, 1))
 		return (NULL);
 	i = *cp++;
 	while (i) {
@@ -69,7 +65,7 @@
 
 			if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
 				return(NULL); /* unknown ELT */
-			if (!TTEST2(*cp, 1))
+			if (!ND_TTEST2(*cp, 1))
 				return (NULL);
 			if ((bitlen = *cp++) == 0)
 				bitlen = 256;
@@ -77,7 +73,7 @@
 			cp += bytelen;
 		} else
 			cp += i;
-		if (!TTEST2(*cp, 1))
+		if (!ND_TTEST2(*cp, 1))
 			return (NULL);
 		i = *cp++;
 	}
@@ -86,13 +82,14 @@
 
 /* print a <domain-name> */
 static const u_char *
-blabel_print(const u_char *cp)
+blabel_print(netdissect_options *ndo,
+             const u_char *cp)
 {
 	int bitlen, slen, b;
 	const u_char *bitp, *lim;
 	char tc;
 
-	if (!TTEST2(*cp, 1))
+	if (!ND_TTEST2(*cp, 1))
 		return(NULL);
 	if ((bitlen = *cp) == 0)
 		bitlen = 256;
@@ -100,42 +97,43 @@
 	lim = cp + 1 + slen;
 
 	/* print the bit string as a hex string */
-	printf("\\[x");
+	ND_PRINT((ndo, "\\[x"));
 	for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) {
-		TCHECK(*bitp);
-		printf("%02x", *bitp);
+		ND_TCHECK(*bitp);
+		ND_PRINT((ndo, "%02x", *bitp));
 	}
 	if (b > 4) {
-		TCHECK(*bitp);
+		ND_TCHECK(*bitp);
 		tc = *bitp++;
-		printf("%02x", tc & (0xff << (8 - b)));
+		ND_PRINT((ndo, "%02x", tc & (0xff << (8 - b))));
 	} else if (b > 0) {
-		TCHECK(*bitp);
+		ND_TCHECK(*bitp);
 		tc = *bitp++;
-		printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
+		ND_PRINT((ndo, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))));
 	}
-	printf("/%d]", bitlen);
+	ND_PRINT((ndo, "/%d]", bitlen));
 	return lim;
 trunc:
-	printf(".../%d]", bitlen);
+	ND_PRINT((ndo, ".../%d]", bitlen));
 	return NULL;
 }
 
 static int
-labellen(const u_char *cp)
+labellen(netdissect_options *ndo,
+         const u_char *cp)
 {
 	register u_int i;
 
-	if (!TTEST2(*cp, 1))
+	if (!ND_TTEST2(*cp, 1))
 		return(-1);
 	i = *cp;
 	if ((i & INDIR_MASK) == EDNS0_MASK) {
 		int bitlen, elt;
 		if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
-			printf("<ELT %d>", elt);
+			ND_PRINT((ndo, "<ELT %d>", elt));
 			return(-1);
 		}
-		if (!TTEST2(*(cp + 1), 1))
+		if (!ND_TTEST2(*(cp + 1), 1))
 			return(-1);
 		if ((bitlen = *(cp + 1)) == 0)
 			bitlen = 256;
@@ -145,18 +143,19 @@
 }
 
 const u_char *
-ns_nprint(register const u_char *cp, register const u_char *bp)
+ns_nprint(netdissect_options *ndo,
+          register const u_char *cp, register const u_char *bp)
 {
 	register u_int i, l;
 	register const u_char *rp = NULL;
 	register int compress = 0;
 	int chars_processed;
 	int elt;
-	int data_size = snapend - bp;
+	int data_size = ndo->ndo_snapend - bp;
 
-	if ((l = labellen(cp)) == (u_int)-1)
+	if ((l = labellen(ndo, cp)) == (u_int)-1)
 		return(NULL);
-	if (!TTEST2(*cp, 1))
+	if (!ND_TTEST2(*cp, 1))
 		return(NULL);
 	chars_processed = 1;
 	if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
@@ -165,18 +164,18 @@
 	}
 
 	if (i != 0)
-		while (i && cp < snapend) {
+		while (i && cp < ndo->ndo_snapend) {
 			if ((i & INDIR_MASK) == INDIR_MASK) {
 				if (!compress) {
 					rp = cp + 1;
 					compress = 1;
 				}
-				if (!TTEST2(*cp, 1))
+				if (!ND_TTEST2(*cp, 1))
 					return(NULL);
 				cp = bp + (((i << 8) | *cp) & 0x3fff);
-				if ((l = labellen(cp)) == (u_int)-1)
+				if ((l = labellen(ndo, cp)) == (u_int)-1)
 					return(NULL);
-				if (!TTEST2(*cp, 1))
+				if (!ND_TTEST2(*cp, 1))
 					return(NULL);
 				i = *cp++;
 				chars_processed++;
@@ -188,7 +187,7 @@
 				 * which means we're looping.
 				 */
 				if (chars_processed >= data_size) {
-					printf("<LOOP>");
+					ND_PRINT((ndo, "<LOOP>"));
 					return (NULL);
 				}
 				continue;
@@ -197,25 +196,25 @@
 				elt = (i & ~INDIR_MASK);
 				switch(elt) {
 				case EDNS0_ELT_BITLABEL:
-					if (blabel_print(cp) == NULL)
+					if (blabel_print(ndo, cp) == NULL)
 						return (NULL);
 					break;
 				default:
 					/* unknown ELT */
-					printf("<ELT %d>", elt);
+					ND_PRINT((ndo, "<ELT %d>", elt));
 					return(NULL);
 				}
 			} else {
-				if (fn_printn(cp, l, snapend))
+				if (fn_printn(ndo, cp, l, ndo->ndo_snapend))
 					return(NULL);
 			}
 
 			cp += l;
 			chars_processed += l;
-			putchar('.');
-			if ((l = labellen(cp)) == (u_int)-1)
+			ND_PRINT((ndo, "."));
+			if ((l = labellen(ndo, cp)) == (u_int)-1)
 				return(NULL);
-			if (!TTEST2(*cp, 1))
+			if (!ND_TTEST2(*cp, 1))
 				return(NULL);
 			i = *cp++;
 			chars_processed++;
@@ -223,20 +222,21 @@
 				rp += l + 1;
 		}
 	else
-		putchar('.');
+		ND_PRINT((ndo, "."));
 	return (rp);
 }
 
 /* print a <character-string> */
 static const u_char *
-ns_cprint(register const u_char *cp)
+ns_cprint(netdissect_options *ndo,
+          register const u_char *cp)
 {
 	register u_int i;
 
-	if (!TTEST2(*cp, 1))
+	if (!ND_TTEST2(*cp, 1))
 		return (NULL);
 	i = *cp++;
-	if (fn_printn(cp, i, snapend))
+	if (fn_printn(ndo, cp, i, ndo->ndo_snapend))
 		return (NULL);
 	return (cp + i);
 }
@@ -317,20 +317,21 @@
 
 /* print a query */
 static const u_char *
-ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
+ns_qprint(netdissect_options *ndo,
+          register const u_char *cp, register const u_char *bp, int is_mdns)
 {
 	register const u_char *np = cp;
 	register u_int i, class;
 
-	cp = ns_nskip(cp);
+	cp = ns_nskip(ndo, cp);
 
-	if (cp == NULL || !TTEST2(*cp, 4))
+	if (cp == NULL || !ND_TTEST2(*cp, 4))
 		return(NULL);
 
 	/* print the qtype */
 	i = EXTRACT_16BITS(cp);
 	cp += 2;
-	printf(" %s", tok2str(ns_type2str, "Type%d", i));
+	ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", i)));
 	/* print the qclass (if it's not IN) */
 	i = EXTRACT_16BITS(cp);
 	cp += 2;
@@ -339,36 +340,34 @@
 	else
 		class = i;
 	if (class != C_IN)
-		printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+		ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class)));
 	if (is_mdns) {
-		if (i & C_QU)
-			printf(" (QU)");
-		else
-			printf(" (QM)");
+		ND_PRINT((ndo, i & C_QU ? " (QU)" : " (QM)"));
 	}
 
-	fputs("? ", stdout);
-	cp = ns_nprint(np, bp);
+	ND_PRINT((ndo, "? "));
+	cp = ns_nprint(ndo, np, bp);
 	return(cp ? cp + 4 : NULL);
 }
 
 /* print a reply */
 static const u_char *
-ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
+ns_rprint(netdissect_options *ndo,
+          register const u_char *cp, register const u_char *bp, int is_mdns)
 {
 	register u_int i, class, opt_flags = 0;
 	register u_short typ, len;
 	register const u_char *rp;
 
-	if (vflag) {
-		putchar(' ');
-		if ((cp = ns_nprint(cp, bp)) == NULL)
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, " "));
+		if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
 			return NULL;
 	} else
-		cp = ns_nskip(cp);
+		cp = ns_nskip(ndo, cp);
 
-	if (cp == NULL || !TTEST2(*cp, 10))
-		return (snapend);
+	if (cp == NULL || !ND_TTEST2(*cp, 10))
+		return (ndo->ndo_snapend);
 
 	/* print the type/qtype */
 	typ = EXTRACT_16BITS(cp);
@@ -381,10 +380,10 @@
 	else
 		class = i;
 	if (class != C_IN && typ != T_OPT)
-		printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+		ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class)));
 	if (is_mdns) {
 		if (i & C_CACHE_FLUSH)
-			printf(" (Cache flush)");
+			ND_PRINT((ndo, " (Cache flush)"));
 	}
 
 	if (typ == T_OPT) {
@@ -393,11 +392,11 @@
 		opt_flags = EXTRACT_16BITS(cp);
 		/* ignore rest of ttl field */
 		cp += 2;
-	} else if (vflag > 2) {
+	} else if (ndo->ndo_vflag > 2) {
 		/* print ttl */
-		printf(" [");
-		relts_print(EXTRACT_32BITS(cp));
-		printf("]");
+		ND_PRINT((ndo, " ["));
+		relts_print(ndo, EXTRACT_32BITS(cp));
+		ND_PRINT((ndo, "]"));
 		cp += 4;
 	} else {
 		/* ignore ttl */
@@ -409,15 +408,15 @@
 
 	rp = cp + len;
 
-	printf(" %s", tok2str(ns_type2str, "Type%d", typ));
-	if (rp > snapend)
+	ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", typ)));
+	if (rp > ndo->ndo_snapend)
 		return(NULL);
 
 	switch (typ) {
 	case T_A:
-		if (!TTEST2(*cp, sizeof(struct in_addr)))
+		if (!ND_TTEST2(*cp, sizeof(struct in_addr)))
 			return(NULL);
-		printf(" %s", intoa(htonl(EXTRACT_32BITS(cp))));
+		ND_PRINT((ndo, " %s", intoa(htonl(EXTRACT_32BITS(cp)))));
 		break;
 
 	case T_NS:
@@ -426,60 +425,60 @@
 #ifdef T_DNAME
 	case T_DNAME:
 #endif
-		putchar(' ');
-		if (ns_nprint(cp, bp) == NULL)
+		ND_PRINT((ndo, " "));
+		if (ns_nprint(ndo, cp, bp) == NULL)
 			return(NULL);
 		break;
 
 	case T_SOA:
-		if (!vflag)
+		if (!ndo->ndo_vflag)
 			break;
-		putchar(' ');
-		if ((cp = ns_nprint(cp, bp)) == NULL)
+		ND_PRINT((ndo, " "));
+		if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
 			return(NULL);
-		putchar(' ');
-		if ((cp = ns_nprint(cp, bp)) == NULL)
+		ND_PRINT((ndo, " "));
+		if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
 			return(NULL);
-		if (!TTEST2(*cp, 5 * 4))
+		if (!ND_TTEST2(*cp, 5 * 4))
 			return(NULL);
-		printf(" %u", EXTRACT_32BITS(cp));
+		ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
 		cp += 4;
-		printf(" %u", EXTRACT_32BITS(cp));
+		ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
 		cp += 4;
-		printf(" %u", EXTRACT_32BITS(cp));
+		ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
 		cp += 4;
-		printf(" %u", EXTRACT_32BITS(cp));
+		ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
 		cp += 4;
-		printf(" %u", EXTRACT_32BITS(cp));
+		ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
 		cp += 4;
 		break;
 	case T_MX:
-		putchar(' ');
-		if (!TTEST2(*cp, 2))
+		ND_PRINT((ndo, " "));
+		if (!ND_TTEST2(*cp, 2))
 			return(NULL);
-		if (ns_nprint(cp + 2, bp) == NULL)
+		if (ns_nprint(ndo, cp + 2, bp) == NULL)
 			return(NULL);
-		printf(" %d", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, " %d", EXTRACT_16BITS(cp)));
 		break;
 
 	case T_TXT:
 		while (cp < rp) {
-			printf(" \"");
-			cp = ns_cprint(cp);
+			ND_PRINT((ndo, " \""));
+			cp = ns_cprint(ndo, cp);
 			if (cp == NULL)
 				return(NULL);
-			putchar('"');
+			ND_PRINT((ndo, "\""));
 		}
 		break;
 
 	case T_SRV:
-		putchar(' ');
-		if (!TTEST2(*cp, 6))
+		ND_PRINT((ndo, " "));
+		if (!ND_TTEST2(*cp, 6))
 			return(NULL);
-		if (ns_nprint(cp + 6, bp) == NULL)
+		if (ns_nprint(ndo, cp + 6, bp) == NULL)
 			return(NULL);
-		printf(":%d %d %d", EXTRACT_16BITS(cp + 4),
-			EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2));
+		ND_PRINT((ndo, ":%d %d %d", EXTRACT_16BITS(cp + 4),
+			EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)));
 		break;
 
 #ifdef INET6
@@ -488,11 +487,11 @@
 		struct in6_addr addr;
 		char ntop_buf[INET6_ADDRSTRLEN];
 
-		if (!TTEST2(*cp, sizeof(struct in6_addr)))
+		if (!ND_TTEST2(*cp, sizeof(struct in6_addr)))
 			return(NULL);
 		memcpy(&addr, cp, sizeof(struct in6_addr));
-		printf(" %s",
-		    inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf)));
+		ND_PRINT((ndo, " %s",
+		    inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf))));
 
 		break;
 	    }
@@ -503,24 +502,24 @@
 		int pbit, pbyte;
 		char ntop_buf[INET6_ADDRSTRLEN];
 
-		if (!TTEST2(*cp, 1))
+		if (!ND_TTEST2(*cp, 1))
 			return(NULL);
 		pbit = *cp;
 		pbyte = (pbit & ~7) / 8;
 		if (pbit > 128) {
-			printf(" %u(bad plen)", pbit);
+			ND_PRINT((ndo, " %u(bad plen)", pbit));
 			break;
 		} else if (pbit < 128) {
-			if (!TTEST2(*(cp + 1), sizeof(a) - pbyte))
+			if (!ND_TTEST2(*(cp + 1), sizeof(a) - pbyte))
 				return(NULL);
 			memset(&a, 0, sizeof(a));
 			memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
-			printf(" %u %s", pbit,
-			    inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf)));
+			ND_PRINT((ndo, " %u %s", pbit,
+			    inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))));
 		}
 		if (pbit > 0) {
-			putchar(' ');
-			if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL)
+			ND_PRINT((ndo, " "));
+			if (ns_nprint(ndo, cp + 1 + sizeof(a) - pbyte, bp) == NULL)
 				return(NULL);
 		}
 		break;
@@ -528,47 +527,47 @@
 #endif /*INET6*/
 
 	case T_OPT:
-		printf(" UDPsize=%u", class);
+		ND_PRINT((ndo, " UDPsize=%u", class));
 		if (opt_flags & 0x8000)
-			printf(" OK");
+			ND_PRINT((ndo, " OK"));
 		break;
 
 	case T_UNSPECA:		/* One long string */
-		if (!TTEST2(*cp, len))
+		if (!ND_TTEST2(*cp, len))
 			return(NULL);
-		if (fn_printn(cp, len, snapend))
+		if (fn_printn(ndo, cp, len, ndo->ndo_snapend))
 			return(NULL);
 		break;
 
 	case T_TSIG:
 	    {
-		if (cp + len > snapend)
+		if (cp + len > ndo->ndo_snapend)
 			return(NULL);
-		if (!vflag)
+		if (!ndo->ndo_vflag)
 			break;
-		putchar(' ');
-		if ((cp = ns_nprint(cp, bp)) == NULL)
+		ND_PRINT((ndo, " "));
+		if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
 			return(NULL);
 		cp += 6;
-		if (!TTEST2(*cp, 2))
+		if (!ND_TTEST2(*cp, 2))
 			return(NULL);
-		printf(" fudge=%u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, " fudge=%u", EXTRACT_16BITS(cp)));
 		cp += 2;
-		if (!TTEST2(*cp, 2))
+		if (!ND_TTEST2(*cp, 2))
 			return(NULL);
-		printf(" maclen=%u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, " maclen=%u", EXTRACT_16BITS(cp)));
 		cp += 2 + EXTRACT_16BITS(cp);
-		if (!TTEST2(*cp, 2))
+		if (!ND_TTEST2(*cp, 2))
 			return(NULL);
-		printf(" origid=%u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, " origid=%u", EXTRACT_16BITS(cp)));
 		cp += 2;
-		if (!TTEST2(*cp, 2))
+		if (!ND_TTEST2(*cp, 2))
 			return(NULL);
-		printf(" error=%u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, " error=%u", EXTRACT_16BITS(cp)));
 		cp += 2;
-		if (!TTEST2(*cp, 2))
+		if (!ND_TTEST2(*cp, 2))
 			return(NULL);
-		printf(" otherlen=%u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, " otherlen=%u", EXTRACT_16BITS(cp)));
 		cp += 2;
 	    }
 	}
@@ -576,15 +575,16 @@
 }
 
 void
-ns_print(register const u_char *bp, u_int length, int is_mdns)
+ns_print(netdissect_options *ndo,
+         register const u_char *bp, u_int length, int is_mdns)
 {
 	register const HEADER *np;
 	register int qdcount, ancount, nscount, arcount;
 	register const u_char *cp;
-	u_int16_t b2;
+	uint16_t b2;
 
 	np = (const HEADER *)bp;
-	TCHECK(*np);
+	ND_TCHECK(*np);
 	/* get the byte-order right */
 	qdcount = EXTRACT_16BITS(&np->qdcount);
 	ancount = EXTRACT_16BITS(&np->ancount);
@@ -593,65 +593,65 @@
 
 	if (DNS_QR(np)) {
 		/* this is a response */
-		printf("%d%s%s%s%s%s%s",
+		ND_PRINT((ndo, "%d%s%s%s%s%s%s",
 			EXTRACT_16BITS(&np->id),
 			ns_ops[DNS_OPCODE(np)],
 			ns_resp[DNS_RCODE(np)],
 			DNS_AA(np)? "*" : "",
 			DNS_RA(np)? "" : "-",
 			DNS_TC(np)? "|" : "",
-			DNS_AD(np)? "$" : "");
+			DNS_AD(np)? "$" : ""));
 
 		if (qdcount != 1)
-			printf(" [%dq]", qdcount);
+			ND_PRINT((ndo, " [%dq]", qdcount));
 		/* Print QUESTION section on -vv */
 		cp = (const u_char *)(np + 1);
 		while (qdcount--) {
 			if (qdcount < EXTRACT_16BITS(&np->qdcount) - 1)
-				putchar(',');
-			if (vflag > 1) {
-				fputs(" q:", stdout);
-				if ((cp = ns_qprint(cp, bp, is_mdns)) == NULL)
+				ND_PRINT((ndo, ","));
+			if (ndo->ndo_vflag > 1) {
+				ND_PRINT((ndo, " q:"));
+				if ((cp = ns_qprint(ndo, cp, bp, is_mdns)) == NULL)
 					goto trunc;
 			} else {
-				if ((cp = ns_nskip(cp)) == NULL)
+				if ((cp = ns_nskip(ndo, cp)) == NULL)
 					goto trunc;
 				cp += 4;	/* skip QTYPE and QCLASS */
 			}
 		}
-		printf(" %d/%d/%d", ancount, nscount, arcount);
+		ND_PRINT((ndo, " %d/%d/%d", ancount, nscount, arcount));
 		if (ancount--) {
-			if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+			if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 				goto trunc;
-			while (cp < snapend && ancount--) {
-				putchar(',');
-				if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+			while (cp < ndo->ndo_snapend && ancount--) {
+				ND_PRINT((ndo, ","));
+				if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 					goto trunc;
 			}
 		}
 		if (ancount > 0)
 			goto trunc;
 		/* Print NS and AR sections on -vv */
-		if (vflag > 1) {
-			if (cp < snapend && nscount--) {
-				fputs(" ns:", stdout);
-				if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+		if (ndo->ndo_vflag > 1) {
+			if (cp < ndo->ndo_snapend && nscount--) {
+				ND_PRINT((ndo, " ns:"));
+				if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 					goto trunc;
-				while (cp < snapend && nscount--) {
-					putchar(',');
-					if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+				while (cp < ndo->ndo_snapend && nscount--) {
+					ND_PRINT((ndo, ","));
+					if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 						goto trunc;
 				}
 			}
 			if (nscount > 0)
 				goto trunc;
-			if (cp < snapend && arcount--) {
-				fputs(" ar:", stdout);
-				if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+			if (cp < ndo->ndo_snapend && arcount--) {
+				ND_PRINT((ndo, " ar:"));
+				if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 					goto trunc;
-				while (cp < snapend && arcount--) {
-					putchar(',');
-					if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+				while (cp < ndo->ndo_snapend && arcount--) {
+					ND_PRINT((ndo, ","));
+					if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 						goto trunc;
 				}
 			}
@@ -661,39 +661,39 @@
 	}
 	else {
 		/* this is a request */
-		printf("%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
+		ND_PRINT((ndo, "%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
 		    DNS_RD(np) ? "+" : "",
-		    DNS_CD(np) ? "%" : "");
+		    DNS_CD(np) ? "%" : ""));
 
 		/* any weirdness? */
 		b2 = EXTRACT_16BITS(((u_short *)np)+1);
 		if (b2 & 0x6cf)
-			printf(" [b2&3=0x%x]", b2);
+			ND_PRINT((ndo, " [b2&3=0x%x]", b2));
 
 		if (DNS_OPCODE(np) == IQUERY) {
 			if (qdcount)
-				printf(" [%dq]", qdcount);
+				ND_PRINT((ndo, " [%dq]", qdcount));
 			if (ancount != 1)
-				printf(" [%da]", ancount);
+				ND_PRINT((ndo, " [%da]", ancount));
 		}
 		else {
 			if (ancount)
-				printf(" [%da]", ancount);
+				ND_PRINT((ndo, " [%da]", ancount));
 			if (qdcount != 1)
-				printf(" [%dq]", qdcount);
+				ND_PRINT((ndo, " [%dq]", qdcount));
 		}
 		if (nscount)
-			printf(" [%dn]", nscount);
+			ND_PRINT((ndo, " [%dn]", nscount));
 		if (arcount)
-			printf(" [%dau]", arcount);
+			ND_PRINT((ndo, " [%dau]", arcount));
 
 		cp = (const u_char *)(np + 1);
 		if (qdcount--) {
-			cp = ns_qprint(cp, (const u_char *)np, is_mdns);
+			cp = ns_qprint(ndo, cp, (const u_char *)np, is_mdns);
 			if (!cp)
 				goto trunc;
-			while (cp < snapend && qdcount--) {
-				cp = ns_qprint((const u_char *)cp,
+			while (cp < ndo->ndo_snapend && qdcount--) {
+				cp = ns_qprint(ndo, (const u_char *)cp,
 					       (const u_char *)np,
 					       is_mdns);
 				if (!cp)
@@ -704,37 +704,37 @@
 			goto trunc;
 
 		/* Print remaining sections on -vv */
-		if (vflag > 1) {
+		if (ndo->ndo_vflag > 1) {
 			if (ancount--) {
-				if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+				if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 					goto trunc;
-				while (cp < snapend && ancount--) {
-					putchar(',');
-					if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+				while (cp < ndo->ndo_snapend && ancount--) {
+					ND_PRINT((ndo, ","));
+					if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 						goto trunc;
 				}
 			}
 			if (ancount > 0)
 				goto trunc;
-			if (cp < snapend && nscount--) {
-				fputs(" ns:", stdout);
-				if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+			if (cp < ndo->ndo_snapend && nscount--) {
+				ND_PRINT((ndo, " ns:"));
+				if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 					goto trunc;
-				while (nscount-- && cp < snapend) {
-					putchar(',');
-					if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+				while (nscount-- && cp < ndo->ndo_snapend) {
+					ND_PRINT((ndo, ","));
+					if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 						goto trunc;
 				}
 			}
 			if (nscount > 0)
 				goto trunc;
-			if (cp < snapend && arcount--) {
-				fputs(" ar:", stdout);
-				if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+			if (cp < ndo->ndo_snapend && arcount--) {
+				ND_PRINT((ndo, " ar:"));
+				if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 					goto trunc;
-				while (cp < snapend && arcount--) {
-					putchar(',');
-					if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+				while (cp < ndo->ndo_snapend && arcount--) {
+					ND_PRINT((ndo, ","));
+					if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
 						goto trunc;
 				}
 			}
@@ -742,10 +742,9 @@
 				goto trunc;
 		}
 	}
-	printf(" (%d)", length);
+	ND_PRINT((ndo, " (%d)", length));
 	return;
 
   trunc:
-	printf("[|domain]");
-	return;
+	ND_PRINT((ndo, "[|domain]"));
 }
diff --git a/print-dtp.c b/print-dtp.c
index 14ac691..5d84a77 100644
--- a/print-dtp.c
+++ b/print-dtp.c
@@ -17,19 +17,16 @@
  * Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
-#include "extract.h"		
-#include "nlpid.h"
+#include "extract.h"
 
 #define DTP_HEADER_LEN			1
 #define DTP_DOMAIN_TLV			0x0001
@@ -46,7 +43,7 @@
 };
 
 void
-dtp_print (const u_char *pptr, u_int length)
+dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
 {
     int type, len;
     const u_char *tptr;
@@ -54,19 +51,18 @@
     if (length < DTP_HEADER_LEN)
         goto trunc;
 
-    tptr = pptr; 
+    tptr = pptr;
 
-    if (!TTEST2(*tptr, DTP_HEADER_LEN))	
-	goto trunc;
+    ND_TCHECK2(*tptr, DTP_HEADER_LEN);
 
-    printf("DTPv%u, length %u", 
+    ND_PRINT((ndo, "DTPv%u, length %u",
            (*tptr),
-           length);
+           length));
 
     /*
      * In non-verbose mode, just print version.
      */
-    if (vflag < 1) {
+    if (ndo->ndo_vflag < 1) {
 	return;
     }
 
@@ -74,45 +70,44 @@
 
     while (tptr < (pptr+length)) {
 
-        if (!TTEST2(*tptr, 4)) 
-            goto trunc;
+        ND_TCHECK2(*tptr, 4);
 
 	type = EXTRACT_16BITS(tptr);
-        len  = EXTRACT_16BITS(tptr+2); 
+        len  = EXTRACT_16BITS(tptr+2);
 
         /* infinite loop check */
         if (type == 0 || len == 0) {
             return;
         }
 
-        printf("\n\t%s (0x%04x) TLV, length %u",
+        ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
                tok2str(dtp_tlv_values, "Unknown", type),
-               type, len);
+               type, len));
 
         switch (type) {
 	case DTP_DOMAIN_TLV:
-		printf(", %s", tptr+4);
+		ND_PRINT((ndo, ", %s", tptr+4));
 		break;
 
-	case DTP_STATUS_TLV:            
+	case DTP_STATUS_TLV:
 	case DTP_DTP_TYPE_TLV:
-                printf(", 0x%x", *(tptr+4));
+                ND_PRINT((ndo, ", 0x%x", *(tptr+4)));
                 break;
 
 	case DTP_NEIGHBOR_TLV:
-                printf(", %s", etheraddr_string(tptr+4));
+                ND_PRINT((ndo, ", %s", etheraddr_string(ndo, tptr+4)));
                 break;
 
         default:
             break;
-        }	
+        }
         tptr += len;
     }
 
     return;
 
  trunc:
-    printf("[|dtp]");
+    ND_PRINT((ndo, "[|dtp]"));
 }
 
 /*
diff --git a/print-dvmrp.c b/print-dvmrp.c
index 437e716..96a0ee7 100644
--- a/print-dvmrp.c
+++ b/print-dvmrp.c
@@ -19,21 +19,13 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.27 2003-11-19 09:42:04 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -62,27 +54,28 @@
 #define DVMRP_NF_DISABLED	0x20	/* administratively disabled */
 #define DVMRP_NF_QUERIER	0x40	/* I am the subnet's querier */
 
-static int print_probe(const u_char *, const u_char *, u_int);
-static int print_report(const u_char *, const u_char *, u_int);
-static int print_neighbors(const u_char *, const u_char *, u_int);
-static int print_neighbors2(const u_char *, const u_char *, u_int);
-static int print_prune(const u_char *);
-static int print_graft(const u_char *);
-static int print_graft_ack(const u_char *);
+static int print_probe(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_report(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_prune(netdissect_options *, const u_char *);
+static int print_graft(netdissect_options *, const u_char *);
+static int print_graft_ack(netdissect_options *, const u_char *);
 
-static u_int32_t target_level;
+static uint32_t target_level;
 
 void
-dvmrp_print(register const u_char *bp, register u_int len)
+dvmrp_print(netdissect_options *ndo,
+            register const u_char *bp, register u_int len)
 {
 	register const u_char *ep;
 	register u_char type;
 
-	ep = (const u_char *)snapend;
+	ep = (const u_char *)ndo->ndo_snapend;
 	if (bp >= ep)
 		return;
 
-	TCHECK(bp[1]);
+	ND_TCHECK(bp[1]);
 	type = bp[1];
 
 	/* Skip IGMP header */
@@ -92,94 +85,95 @@
 	switch (type) {
 
 	case DVMRP_PROBE:
-		printf(" Probe");
-		if (vflag) {
-			if (print_probe(bp, ep, len) < 0)
+		ND_PRINT((ndo, " Probe"));
+		if (ndo->ndo_vflag) {
+			if (print_probe(ndo, bp, ep, len) < 0)
 				goto trunc;
 		}
 		break;
 
 	case DVMRP_REPORT:
-		printf(" Report");
-		if (vflag > 1) {
-			if (print_report(bp, ep, len) < 0)
+		ND_PRINT((ndo, " Report"));
+		if (ndo->ndo_vflag > 1) {
+			if (print_report(ndo, bp, ep, len) < 0)
 				goto trunc;
 		}
 		break;
 
 	case DVMRP_ASK_NEIGHBORS:
-		printf(" Ask-neighbors(old)");
+		ND_PRINT((ndo, " Ask-neighbors(old)"));
 		break;
 
 	case DVMRP_NEIGHBORS:
-		printf(" Neighbors(old)");
-		if (print_neighbors(bp, ep, len) < 0)
+		ND_PRINT((ndo, " Neighbors(old)"));
+		if (print_neighbors(ndo, bp, ep, len) < 0)
 			goto trunc;
 		break;
 
 	case DVMRP_ASK_NEIGHBORS2:
-		printf(" Ask-neighbors2");
+		ND_PRINT((ndo, " Ask-neighbors2"));
 		break;
 
 	case DVMRP_NEIGHBORS2:
-		printf(" Neighbors2");
+		ND_PRINT((ndo, " Neighbors2"));
 		/*
 		 * extract version and capabilities from IGMP group
 		 * address field
 		 */
 		bp -= 4;
-		TCHECK2(bp[0], 4);
+		ND_TCHECK2(bp[0], 4);
 		target_level = (bp[0] << 24) | (bp[1] << 16) |
 		    (bp[2] << 8) | bp[3];
 		bp += 4;
-		if (print_neighbors2(bp, ep, len) < 0)
+		if (print_neighbors2(ndo, bp, ep, len) < 0)
 			goto trunc;
 		break;
 
 	case DVMRP_PRUNE:
-		printf(" Prune");
-		if (print_prune(bp) < 0)
+		ND_PRINT((ndo, " Prune"));
+		if (print_prune(ndo, bp) < 0)
 			goto trunc;
 		break;
 
 	case DVMRP_GRAFT:
-		printf(" Graft");
-		if (print_graft(bp) < 0)
+		ND_PRINT((ndo, " Graft"));
+		if (print_graft(ndo, bp) < 0)
 			goto trunc;
 		break;
 
 	case DVMRP_GRAFT_ACK:
-		printf(" Graft-ACK");
-		if (print_graft_ack(bp) < 0)
+		ND_PRINT((ndo, " Graft-ACK"));
+		if (print_graft_ack(ndo, bp) < 0)
 			goto trunc;
 		break;
 
 	default:
-		printf(" [type %d]", type);
+		ND_PRINT((ndo, " [type %d]", type));
 		break;
 	}
 	return;
 
 trunc:
-	printf("[|dvmrp]");
+	ND_PRINT((ndo, "[|dvmrp]"));
 	return;
 }
 
-static int 
-print_report(register const u_char *bp, register const u_char *ep,
-    register u_int len)
+static int
+print_report(netdissect_options *ndo,
+             register const u_char *bp, register const u_char *ep,
+             register u_int len)
 {
-	register u_int32_t mask, origin;
+	register uint32_t mask, origin;
 	register int metric, done;
 	register u_int i, width;
 
 	while (len > 0) {
 		if (len < 3) {
-			printf(" [|]");
+			ND_PRINT((ndo, " [|]"));
 			return (0);
 		}
-		TCHECK2(bp[0], 3);
-		mask = (u_int32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
+		ND_TCHECK2(bp[0], 3);
+		mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
 		width = 1;
 		if (bp[0])
 			width = 2;
@@ -188,32 +182,32 @@
 		if (bp[2])
 			width = 4;
 
-		printf("\n\tMask %s", intoa(htonl(mask)));
+		ND_PRINT((ndo, "\n\tMask %s", intoa(htonl(mask))));
 		bp += 3;
 		len -= 3;
 		do {
 			if (bp + width + 1 > ep) {
-				printf(" [|]");
+				ND_PRINT((ndo, " [|]"));
 				return (0);
 			}
 			if (len < width + 1) {
-				printf("\n\t  [Truncated Report]");
+				ND_PRINT((ndo, "\n\t  [Truncated Report]"));
 				return (0);
 			}
 			origin = 0;
 			for (i = 0; i < width; ++i) {
-				TCHECK(*bp);
+				ND_TCHECK(*bp);
 				origin = origin << 8 | *bp++;
 			}
 			for ( ; i < 4; ++i)
 				origin <<= 8;
 
-			TCHECK(*bp);
+			ND_TCHECK(*bp);
 			metric = *bp++;
 			done = metric & 0x80;
 			metric &= 0x7f;
-			printf("\n\t  %s metric %d", intoa(htonl(origin)),
-				metric);
+			ND_PRINT((ndo, "\n\t  %s metric %d", intoa(htonl(origin)),
+				metric));
 			len -= width + 1;
 		} while (!done);
 	}
@@ -223,31 +217,29 @@
 }
 
 static int
-print_probe(register const u_char *bp, register const u_char *ep,
-    register u_int len)
+print_probe(netdissect_options *ndo,
+            register const u_char *bp, register const u_char *ep,
+            register u_int len)
 {
-	register u_int32_t genid;
+	register uint32_t genid;
 
-	TCHECK2(bp[0], 4);
+	ND_TCHECK2(bp[0], 4);
 	if ((len < 4) || ((bp + 4) > ep)) {
 		/* { (ctags) */
-		printf(" [|}");
+		ND_PRINT((ndo, " [|}"));
 		return (0);
 	}
 	genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
 	bp += 4;
 	len -= 4;
-	if (vflag > 1)
-		printf("\n\t");
-	else
-		printf(" ");
-	printf("genid %u", genid);
-	if (vflag < 2)
+	ND_PRINT((ndo, ndo->ndo_vflag > 1 ? "\n\t" : " "));
+	ND_PRINT((ndo, "genid %u", genid));
+	if (ndo->ndo_vflag < 2)
 		return (0);
 
 	while ((len > 0) && (bp < ep)) {
-		TCHECK2(bp[0], 4);
-		printf("\n\tneighbor %s", ipaddr_string(bp));
+		ND_TCHECK2(bp[0], 4);
+		ND_PRINT((ndo, "\n\tneighbor %s", ipaddr_string(ndo, bp)));
 		bp += 4; len -= 4;
 	}
 	return (0);
@@ -256,8 +248,9 @@
 }
 
 static int
-print_neighbors(register const u_char *bp, register const u_char *ep,
-    register u_int len)
+print_neighbors(netdissect_options *ndo,
+                register const u_char *bp, register const u_char *ep,
+                register u_int len)
 {
 	const u_char *laddr;
 	register u_char metric;
@@ -265,7 +258,7 @@
 	register int ncount;
 
 	while (len > 0 && bp < ep) {
-		TCHECK2(bp[0], 7);
+		ND_TCHECK2(bp[0], 7);
 		laddr = bp;
 		bp += 4;
 		metric = *bp++;
@@ -273,10 +266,10 @@
 		ncount = *bp++;
 		len -= 7;
 		while (--ncount >= 0) {
-			TCHECK2(bp[0], 4);
-			printf(" [%s ->", ipaddr_string(laddr));
-			printf(" %s, (%d/%d)]",
-				   ipaddr_string(bp), metric, thresh);
+			ND_TCHECK2(bp[0], 4);
+			ND_PRINT((ndo, " [%s ->", ipaddr_string(ndo, laddr)));
+			ND_PRINT((ndo, " %s, (%d/%d)]",
+				   ipaddr_string(ndo, bp), metric, thresh));
 			bp += 4;
 			len -= 4;
 		}
@@ -287,19 +280,20 @@
 }
 
 static int
-print_neighbors2(register const u_char *bp, register const u_char *ep,
-    register u_int len)
+print_neighbors2(netdissect_options *ndo,
+                 register const u_char *bp, register const u_char *ep,
+                 register u_int len)
 {
 	const u_char *laddr;
 	register u_char metric, thresh, flags;
 	register int ncount;
 
-	printf(" (v %d.%d):",
+	ND_PRINT((ndo, " (v %d.%d):",
 	       (int)target_level & 0xff,
-	       (int)(target_level >> 8) & 0xff);
+	       (int)(target_level >> 8) & 0xff));
 
 	while (len > 0 && bp < ep) {
-		TCHECK2(bp[0], 8);
+		ND_TCHECK2(bp[0], 8);
 		laddr = bp;
 		bp += 4;
 		metric = *bp++;
@@ -308,25 +302,25 @@
 		ncount = *bp++;
 		len -= 8;
 		while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) {
-			printf(" [%s -> ", ipaddr_string(laddr));
-			printf("%s (%d/%d", ipaddr_string(bp),
-				     metric, thresh);
+			ND_PRINT((ndo, " [%s -> ", ipaddr_string(ndo, laddr)));
+			ND_PRINT((ndo, "%s (%d/%d", ipaddr_string(ndo, bp),
+				     metric, thresh));
 			if (flags & DVMRP_NF_TUNNEL)
-				printf("/tunnel");
+				ND_PRINT((ndo, "/tunnel"));
 			if (flags & DVMRP_NF_SRCRT)
-				printf("/srcrt");
+				ND_PRINT((ndo, "/srcrt"));
 			if (flags & DVMRP_NF_QUERIER)
-				printf("/querier");
+				ND_PRINT((ndo, "/querier"));
 			if (flags & DVMRP_NF_DISABLED)
-				printf("/disabled");
+				ND_PRINT((ndo, "/disabled"));
 			if (flags & DVMRP_NF_DOWN)
-				printf("/down");
-			printf(")]");
+				ND_PRINT((ndo, "/down"));
+			ND_PRINT((ndo, ")]"));
 			bp += 4;
 			len -= 4;
 		}
 		if (ncount != -1) {
-			printf(" [|]");
+			ND_PRINT((ndo, " [|]"));
 			return (0);
 		}
 	}
@@ -336,33 +330,36 @@
 }
 
 static int
-print_prune(register const u_char *bp)
+print_prune(netdissect_options *ndo,
+            register const u_char *bp)
 {
-	TCHECK2(bp[0], 12);
-	printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+	ND_TCHECK2(bp[0], 12);
+	ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
 	bp += 8;
-	(void)printf(" timer ");
-	relts_print(EXTRACT_32BITS(bp));
+	ND_PRINT((ndo, " timer "));
+	relts_print(ndo, EXTRACT_32BITS(bp));
 	return (0);
 trunc:
 	return (-1);
 }
 
 static int
-print_graft(register const u_char *bp)
+print_graft(netdissect_options *ndo,
+            register const u_char *bp)
 {
-	TCHECK2(bp[0], 8);
-	printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+	ND_TCHECK2(bp[0], 8);
+	ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
 	return (0);
 trunc:
 	return (-1);
 }
 
 static int
-print_graft_ack(register const u_char *bp)
+print_graft_ack(netdissect_options *ndo,
+                register const u_char *bp)
 {
-	TCHECK2(bp[0], 8);
-	printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+	ND_TCHECK2(bp[0], 8);
+	ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
 	return (0);
 trunc:
 	return (-1);
diff --git a/print-eap.c b/print-eap.c
index 9fb333a..0e2c2d3 100644
--- a/print-eap.c
+++ b/print-eap.c
@@ -21,25 +21,15 @@
  *
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-eap.c,v 1.5 2007-10-04 16:41:33 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
-#include "ether.h"
 
 #define	EAP_FRAME_TYPE_PACKET		0
 #define	EAP_FRAME_TYPE_START		1
@@ -113,7 +103,7 @@
     { EAP_TYPE_EXPANDED_TYPES,  "Expanded types" },
     { EAP_TYPE_EXPERIMENTAL,    "Experimental" },
     { 0, NULL}
-};  
+};
 
 #define EAP_TLS_EXTRACT_BIT_L(x) 	(((x)&0x80)>>7)
 
@@ -159,7 +149,7 @@
  * Print EAP requests / responses
  */
 void
-eap_print(netdissect_options *ndo _U_,
+eap_print(netdissect_options *ndo,
           register const u_char *cp,
           u_int length _U_)
 {
@@ -167,27 +157,27 @@
     const u_char *tptr;
     u_int tlen, type, subtype;
     int count=0, len;
-    
+
     tptr = cp;
     tlen = length;
     eap = (const struct eap_frame_t *)cp;
-    TCHECK(*eap);
+    ND_TCHECK(*eap);
 
     /* in non-verbose mode just lets print the basic info */
-    if (vflag < 1) {
-	printf("%s (%u) v%u, len %u",
+    if (ndo->ndo_vflag < 1) {
+	ND_PRINT((ndo, "%s (%u) v%u, len %u",
                tok2str(eap_frame_type_values, "unknown", eap->type),
                eap->type,
                eap->version,
-               EXTRACT_16BITS(eap->length));
+               EXTRACT_16BITS(eap->length)));
 	return;
     }
-  
-    printf("%s (%u) v%u, len %u", 
+
+    ND_PRINT((ndo, "%s (%u) v%u, len %u",
            tok2str(eap_frame_type_values, "unknown", eap->type),
            eap->type,
            eap->version,
-           EXTRACT_16BITS(eap->length));
+           EXTRACT_16BITS(eap->length)));
 
     tptr += sizeof(const struct eap_frame_t);
     tlen -= sizeof(const struct eap_frame_t);
@@ -196,33 +186,32 @@
     case EAP_FRAME_TYPE_PACKET:
         type = *(tptr);
         len = EXTRACT_16BITS(tptr+2);
-        printf(", %s (%u), id %u, len %u",
+        ND_PRINT((ndo, ", %s (%u), id %u, len %u",
                tok2str(eap_code_values, "unknown", type),
                type,
                *(tptr+1),
-               len);
+               len));
 
-        if (!TTEST2(*tptr, len)) 
-            goto trunc;
+        ND_TCHECK2(*tptr, len);
 
         if (type <= 2) { /* For EAP_REQUEST and EAP_RESPONSE only */
             subtype = *(tptr+4);
-            printf("\n\t\t Type %s (%u)",
+            ND_PRINT((ndo, "\n\t\t Type %s (%u)",
                    tok2str(eap_type_values, "unknown", *(tptr+4)),
-                   *(tptr+4));
+                   *(tptr + 4)));
 
-            switch (subtype) {	
+            switch (subtype) {
             case EAP_TYPE_IDENTITY:
                 if (len - 5 > 0) {
-                    printf(", Identity: ");
-                    safeputs((const char *)tptr+5, len-5);
+                    ND_PRINT((ndo, ", Identity: "));
+                    safeputs(ndo, tptr + 5, len - 5);
                 }
                 break;
 
             case EAP_TYPE_NOTIFICATION:
                 if (len - 5 > 0) {
-                    printf(", Notification: ");
-                    safeputs((const char *)tptr+5, len-5);
+                    ND_PRINT((ndo, ", Notification: "));
+                    safeputs(ndo, tptr + 5, len - 5);
                 }
                 break;
 
@@ -234,36 +223,36 @@
                  * the desired authentication
                  * type one octet per type
                  */
-                while (count < len) {	
-                    printf(" %s (%u),", 
+                while (count < len) {
+                    ND_PRINT((ndo, " %s (%u),",
                            tok2str(eap_type_values, "unknown", *(tptr+count)),
-                           *(tptr+count));
+                           *(tptr + count)));
                     count++;
                 }
                 break;
 
             case EAP_TYPE_TTLS:
-                printf(" TTLSv%u", 
-                       EAP_TTLS_VERSION(*(tptr+5))); /* fall through */
+                ND_PRINT((ndo, " TTLSv%u",
+                       EAP_TTLS_VERSION(*(tptr + 5)))); /* fall through */
             case EAP_TYPE_TLS:
-                printf(" flags [%s] 0x%02x,", 
+                ND_PRINT((ndo, " flags [%s] 0x%02x,",
                        bittok2str(eap_tls_flags_values, "none", *(tptr+5)),
-                       *(tptr+5));
+                       *(tptr + 5)));
 
                 if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) {
-		    printf(" len %u", EXTRACT_32BITS(tptr+6));
+		    ND_PRINT((ndo, " len %u", EXTRACT_32BITS(tptr + 6)));
                 }
                 break;
 
             case EAP_TYPE_FAST:
-                printf(" FASTv%u",
-                       EAP_TTLS_VERSION(*(tptr+5)));
-                printf(" flags [%s] 0x%02x,",
+                ND_PRINT((ndo, " FASTv%u",
+                       EAP_TTLS_VERSION(*(tptr + 5))));
+                ND_PRINT((ndo, " flags [%s] 0x%02x,",
                        bittok2str(eap_tls_flags_values, "none", *(tptr+5)),
-                       *(tptr+5));
+                       *(tptr + 5)));
 
                 if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) {
-                    printf(" len %u", EXTRACT_32BITS(tptr+6));
+                    ND_PRINT((ndo, " len %u", EXTRACT_32BITS(tptr + 6)));
                 }
 
                 /* FIXME - TLV attributes follow */
@@ -271,14 +260,14 @@
 
             case EAP_TYPE_AKA:
             case EAP_TYPE_SIM:
-                printf(" subtype [%s] 0x%02x,",
+                ND_PRINT((ndo, " subtype [%s] 0x%02x,",
                        tok2str(eap_aka_subtype_values, "unknown", *(tptr+5)),
-                       *(tptr+5));
+                       *(tptr + 5)));
 
                 /* FIXME - TLV attributes follow */
                 break;
 
-            case EAP_TYPE_MD5_CHALLENGE:	
+            case EAP_TYPE_MD5_CHALLENGE:
             case EAP_TYPE_OTP:
             case EAP_TYPE_GTC:
             case EAP_TYPE_EXPANDED_TYPES:
@@ -287,7 +276,7 @@
                 break;
             }
         }
-        break;	
+        break;
 
     case EAP_FRAME_TYPE_LOGOFF:
     case EAP_FRAME_TYPE_ENCAP_ASF_ALERT:
@@ -297,7 +286,7 @@
     return;
 
  trunc:
-    printf("\n\t[|EAP]");
+    ND_PRINT((ndo, "\n\t[|EAP]"));
 }
 
 /*
diff --git a/print-egp.c b/print-egp.c
index 4a1d046..9c5c811 100644
--- a/print-egp.c
+++ b/print-egp.c
@@ -18,35 +18,27 @@
  * Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU).
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.38 2006-02-11 22:13:24 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 
-#include "ip.h"
-
 struct egp_packet {
-	u_int8_t  egp_version;
+	uint8_t  egp_version;
 #define	EGP_VERSION	2
-	u_int8_t  egp_type;
+	uint8_t  egp_type;
 #define  EGPT_ACQUIRE	3
 #define  EGPT_REACH	5
 #define  EGPT_POLL	2
 #define  EGPT_UPDATE	1
 #define  EGPT_ERROR	8
-	u_int8_t  egp_code;
+	uint8_t  egp_code;
 #define  EGPC_REQUEST	0
 #define  EGPC_CONFIRM	1
 #define  EGPC_REFUSE	2
@@ -54,7 +46,7 @@
 #define  EGPC_CEASEACK	4
 #define  EGPC_HELLO	0
 #define  EGPC_HEARDU	1
-	u_int8_t  egp_status;
+	uint8_t  egp_status;
 #define  EGPS_UNSPEC	0
 #define  EGPS_ACTIVE	1
 #define  EGPS_PASSIVE	2
@@ -67,13 +59,13 @@
 #define  EGPS_UP	1
 #define  EGPS_DOWN	2
 #define  EGPS_UNSOL	0x80
-	u_int16_t  egp_checksum;
-	u_int16_t  egp_as;
-	u_int16_t  egp_sequence;
+	uint16_t  egp_checksum;
+	uint16_t  egp_as;
+	uint16_t  egp_sequence;
 	union {
-		u_int16_t  egpu_hello;
-		u_int8_t egpu_gws[2];
-		u_int16_t  egpu_reason;
+		uint16_t  egpu_hello;
+		uint8_t egpu_gws[2];
+		uint16_t  egpu_reason;
 #define  EGPR_UNSPEC	0
 #define  EGPR_BADHEAD	1
 #define  EGPR_BADDATA	2
@@ -87,14 +79,14 @@
 #define  egp_extgw  egp_handg.egpu_gws[1]
 #define  egp_reason  egp_handg.egpu_reason
 	union {
-		u_int16_t  egpu_poll;
-		u_int32_t egpu_sourcenet;
+		uint16_t  egpu_poll;
+		uint32_t egpu_sourcenet;
 	} egp_pands;
 #define  egp_poll  egp_pands.egpu_poll
 #define  egp_sourcenet  egp_pands.egpu_sourcenet
 };
 
-const char *egp_acquire_codes[] = {
+static const char *egp_acquire_codes[] = {
 	"request",
 	"confirm",
 	"refuse",
@@ -102,7 +94,7 @@
 	"cease_ack"
 };
 
-const char *egp_acquire_status[] = {
+static const char *egp_acquire_status[] = {
 	"unspecified",
 	"active_mode",
 	"passive_mode",
@@ -113,18 +105,18 @@
 	"protocol_violation"
 };
 
-const char *egp_reach_codes[] = {
+static const char *egp_reach_codes[] = {
 	"hello",
 	"i-h-u"
 };
 
-const char *egp_status_updown[] = {
+static const char *egp_status_updown[] = {
 	"indeterminate",
 	"up",
 	"down"
 };
 
-const char *egp_reasons[] = {
+static const char *egp_reasons[] = {
 	"unspecified",
 	"bad_EGP_header_format",
 	"bad_EGP_data_field_format",
@@ -135,11 +127,12 @@
 };
 
 static void
-egpnrprint(register const struct egp_packet *egp)
+egpnrprint(netdissect_options *ndo,
+           register const struct egp_packet *egp)
 {
-	register const u_int8_t *cp;
-	u_int32_t addr;
-	register u_int32_t net;
+	register const uint8_t *cp;
+	uint32_t addr;
+	register uint32_t net;
 	register u_int netlen;
 	int gateways, distances, networks;
 	int t_gateways;
@@ -159,13 +152,13 @@
 		net = 0;
 		netlen = 0;
 	}
-	cp = (u_int8_t *)(egp + 1);
+	cp = (uint8_t *)(egp + 1);
 
 	t_gateways = egp->egp_intgw + egp->egp_extgw;
 	for (gateways = 0; gateways < t_gateways; ++gateways) {
 		/* Pickup host part of gateway address */
 		addr = 0;
-		TCHECK2(cp[0], 4 - netlen);
+		ND_TCHECK2(cp[0], 4 - netlen);
 		switch (netlen) {
 
 		case 1:
@@ -178,43 +171,44 @@
 			addr = (addr << 8) | *cp++;
 		}
 		addr |= net;
-		TCHECK2(cp[0], 1);
+		ND_TCHECK2(cp[0], 1);
 		distances = *cp++;
-		printf(" %s %s ",
+		ND_PRINT((ndo, " %s %s ",
 		       gateways < (int)egp->egp_intgw ? "int" : "ext",
-		       ipaddr_string(&addr));
+		       ipaddr_string(ndo, &addr)));
 
 		comma = "";
-		putchar('(');
+		ND_PRINT((ndo, "("));
 		while (--distances >= 0) {
-			TCHECK2(cp[0], 2);
-			printf("%sd%d:", comma, (int)*cp++);
+			ND_TCHECK2(cp[0], 2);
+			ND_PRINT((ndo, "%sd%d:", comma, (int)*cp++));
 			comma = ", ";
 			networks = *cp++;
 			while (--networks >= 0) {
 				/* Pickup network number */
-				TCHECK2(cp[0], 1);
-				addr = (u_int32_t)*cp++ << 24;
+				ND_TCHECK2(cp[0], 1);
+				addr = (uint32_t)*cp++ << 24;
 				if (IN_CLASSB(addr)) {
-					TCHECK2(cp[0], 1);
-					addr |= (u_int32_t)*cp++ << 16;
+					ND_TCHECK2(cp[0], 1);
+					addr |= (uint32_t)*cp++ << 16;
 				} else if (!IN_CLASSA(addr)) {
-					TCHECK2(cp[0], 2);
-					addr |= (u_int32_t)*cp++ << 16;
-					addr |= (u_int32_t)*cp++ << 8;
+					ND_TCHECK2(cp[0], 2);
+					addr |= (uint32_t)*cp++ << 16;
+					addr |= (uint32_t)*cp++ << 8;
 				}
-				printf(" %s", ipaddr_string(&addr));
+				ND_PRINT((ndo, " %s", ipaddr_string(ndo, &addr)));
 			}
 		}
-		putchar(')');
+		ND_PRINT((ndo, ")"));
 	}
 	return;
 trunc:
-	fputs("[|]", stdout);
+	ND_PRINT((ndo, "[|]"));
 }
 
 void
-egp_print(register const u_int8_t *bp, register u_int length)
+egp_print(netdissect_options *ndo,
+          register const uint8_t *bp, register u_int length)
 {
 	register const struct egp_packet *egp;
 	register int status;
@@ -222,25 +216,25 @@
 	register int type;
 
 	egp = (struct egp_packet *)bp;
-        if (!TTEST2(*egp, length)) {
-		printf("[|egp]");
+        if (!ND_TTEST2(*egp, length)) {
+		ND_PRINT((ndo, "[|egp]"));
 		return;
 	}
 
-        if (!vflag) {
-            printf("EGPv%u, AS %u, seq %u, length %u",
+        if (!ndo->ndo_vflag) {
+            ND_PRINT((ndo, "EGPv%u, AS %u, seq %u, length %u",
                    egp->egp_version,
                    EXTRACT_16BITS(&egp->egp_as),
                    EXTRACT_16BITS(&egp->egp_sequence),
-                   length);
+                   length));
             return;
         } else
-            printf("EGPv%u, length %u",
+            ND_PRINT((ndo, "EGPv%u, length %u",
                    egp->egp_version,
-                   length);            
+                   length));
 
 	if (egp->egp_version != EGP_VERSION) {
-		printf("[version %d]", egp->egp_version);
+		ND_PRINT((ndo, "[version %d]", egp->egp_version));
 		return;
 	}
 
@@ -250,31 +244,31 @@
 
 	switch (type) {
 	case EGPT_ACQUIRE:
-		printf(" acquire");
+		ND_PRINT((ndo, " acquire"));
 		switch (code) {
 		case EGPC_REQUEST:
 		case EGPC_CONFIRM:
-			printf(" %s", egp_acquire_codes[code]);
+			ND_PRINT((ndo, " %s", egp_acquire_codes[code]));
 			switch (status) {
 			case EGPS_UNSPEC:
 			case EGPS_ACTIVE:
 			case EGPS_PASSIVE:
-				printf(" %s", egp_acquire_status[status]);
+				ND_PRINT((ndo, " %s", egp_acquire_status[status]));
 				break;
 
 			default:
-				printf(" [status %d]", status);
+				ND_PRINT((ndo, " [status %d]", status));
 				break;
 			}
-			printf(" hello:%d poll:%d",
+			ND_PRINT((ndo, " hello:%d poll:%d",
 			       EXTRACT_16BITS(&egp->egp_hello),
-			       EXTRACT_16BITS(&egp->egp_poll));
+			       EXTRACT_16BITS(&egp->egp_poll)));
 			break;
 
 		case EGPC_REFUSE:
 		case EGPC_CEASE:
 		case EGPC_CEASEACK:
-			printf(" %s", egp_acquire_codes[code]);
+			ND_PRINT((ndo, " %s", egp_acquire_codes[code]));
 			switch (status ) {
 			case EGPS_UNSPEC:
 			case EGPS_NORES:
@@ -282,17 +276,17 @@
 			case EGPS_GODOWN:
 			case EGPS_PARAM:
 			case EGPS_PROTO:
-				printf(" %s", egp_acquire_status[status]);
+				ND_PRINT((ndo, " %s", egp_acquire_status[status]));
 				break;
 
 			default:
-				printf("[status %d]", status);
+				ND_PRINT((ndo, "[status %d]", status));
 				break;
 			}
 			break;
 
 		default:
-			printf("[code %d]", code);
+			ND_PRINT((ndo, "[code %d]", code));
 			break;
 		}
 		break;
@@ -302,61 +296,61 @@
 
 		case EGPC_HELLO:
 		case EGPC_HEARDU:
-			printf(" %s", egp_reach_codes[code]);
+			ND_PRINT((ndo, " %s", egp_reach_codes[code]));
 			if (status <= EGPS_DOWN)
-				printf(" state:%s", egp_status_updown[status]);
+				ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
 			else
-				printf(" [status %d]", status);
+				ND_PRINT((ndo, " [status %d]", status));
 			break;
 
 		default:
-			printf("[reach code %d]", code);
+			ND_PRINT((ndo, "[reach code %d]", code));
 			break;
 		}
 		break;
 
 	case EGPT_POLL:
-		printf(" poll");
+		ND_PRINT((ndo, " poll"));
 		if (egp->egp_status <= EGPS_DOWN)
-			printf(" state:%s", egp_status_updown[status]);
+			ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
 		else
-			printf(" [status %d]", status);
-		printf(" net:%s", ipaddr_string(&egp->egp_sourcenet));
+			ND_PRINT((ndo, " [status %d]", status));
+		ND_PRINT((ndo, " net:%s", ipaddr_string(ndo, &egp->egp_sourcenet)));
 		break;
 
 	case EGPT_UPDATE:
-		printf(" update");
+		ND_PRINT((ndo, " update"));
 		if (status & EGPS_UNSOL) {
 			status &= ~EGPS_UNSOL;
-			printf(" unsolicited");
+			ND_PRINT((ndo, " unsolicited"));
 		}
 		if (status <= EGPS_DOWN)
-			printf(" state:%s", egp_status_updown[status]);
+			ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
 		else
-			printf(" [status %d]", status);
-		printf(" %s int %d ext %d",
-		       ipaddr_string(&egp->egp_sourcenet),
+			ND_PRINT((ndo, " [status %d]", status));
+		ND_PRINT((ndo, " %s int %d ext %d",
+		       ipaddr_string(ndo, &egp->egp_sourcenet),
 		       egp->egp_intgw,
-		       egp->egp_extgw);
-		if (vflag)
-			egpnrprint(egp);
+		       egp->egp_extgw));
+		if (ndo->ndo_vflag)
+			egpnrprint(ndo, egp);
 		break;
 
 	case EGPT_ERROR:
-		printf(" error");
+		ND_PRINT((ndo, " error"));
 		if (status <= EGPS_DOWN)
-			printf(" state:%s", egp_status_updown[status]);
+			ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
 		else
-			printf(" [status %d]", status);
+			ND_PRINT((ndo, " [status %d]", status));
 
 		if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION)
-			printf(" %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]);
+			ND_PRINT((ndo, " %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]));
 		else
-			printf(" [reason %d]", EXTRACT_16BITS(&egp->egp_reason));
+			ND_PRINT((ndo, " [reason %d]", EXTRACT_16BITS(&egp->egp_reason)));
 		break;
 
 	default:
-		printf("[type %d]", type);
+		ND_PRINT((ndo, "[type %d]", type));
 		break;
 	}
 }
diff --git a/print-eigrp.c b/print-eigrp.c
index 4f941d9..cab77ba 100644
--- a/print-eigrp.c
+++ b/print-eigrp.c
@@ -14,19 +14,13 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "interface.h"
@@ -39,13 +33,13 @@
  */
 
 struct eigrp_common_header {
-    u_int8_t version;
-    u_int8_t opcode;
-    u_int8_t checksum[2];
-    u_int8_t flags[4];
-    u_int8_t seq[4];
-    u_int8_t ack[4];
-    u_int8_t asn[4];
+    uint8_t version;
+    uint8_t opcode;
+    uint8_t checksum[2];
+    uint8_t flags[4];
+    uint8_t seq[4];
+    uint8_t ack[4];
+    uint8_t asn[4];
 };
 
 #define	EIGRP_VERSION                        2
@@ -74,8 +68,8 @@
 };
 
 struct eigrp_tlv_header {
-    u_int8_t type[2];
-    u_int8_t length[2];
+    uint8_t type[2];
+    uint8_t length[2];
 };
 
 #define EIGRP_TLV_GENERAL_PARM   0x0001
@@ -108,91 +102,91 @@
 };
 
 struct eigrp_tlv_general_parm_t {
-    u_int8_t k1;
-    u_int8_t k2;
-    u_int8_t k3;
-    u_int8_t k4;
-    u_int8_t k5;
-    u_int8_t res;
-    u_int8_t holdtime[2];
-};          
+    uint8_t k1;
+    uint8_t k2;
+    uint8_t k3;
+    uint8_t k4;
+    uint8_t k5;
+    uint8_t res;
+    uint8_t holdtime[2];
+};
 
 struct eigrp_tlv_sw_version_t {
-    u_int8_t ios_major;
-    u_int8_t ios_minor;
-    u_int8_t eigrp_major;
-    u_int8_t eigrp_minor;
-}; 
+    uint8_t ios_major;
+    uint8_t ios_minor;
+    uint8_t eigrp_major;
+    uint8_t eigrp_minor;
+};
 
 struct eigrp_tlv_ip_int_t {
-    u_int8_t nexthop[4];
-    u_int8_t delay[4];
-    u_int8_t bandwidth[4];
-    u_int8_t mtu[3];
-    u_int8_t hopcount;
-    u_int8_t reliability;
-    u_int8_t load;
-    u_int8_t reserved[2];
-    u_int8_t plen;
-    u_int8_t destination; /* variable length [1-4] bytes encoding */
-}; 
+    uint8_t nexthop[4];
+    uint8_t delay[4];
+    uint8_t bandwidth[4];
+    uint8_t mtu[3];
+    uint8_t hopcount;
+    uint8_t reliability;
+    uint8_t load;
+    uint8_t reserved[2];
+    uint8_t plen;
+    uint8_t destination; /* variable length [1-4] bytes encoding */
+};
 
 struct eigrp_tlv_ip_ext_t {
-    u_int8_t nexthop[4];
-    u_int8_t origin_router[4];
-    u_int8_t origin_as[4];
-    u_int8_t tag[4];
-    u_int8_t metric[4];
-    u_int8_t reserved[2];
-    u_int8_t proto_id;
-    u_int8_t flags;
-    u_int8_t delay[4];
-    u_int8_t bandwidth[4];
-    u_int8_t mtu[3];
-    u_int8_t hopcount;
-    u_int8_t reliability;
-    u_int8_t load;
-    u_int8_t reserved2[2];
-    u_int8_t plen;
-    u_int8_t destination; /* variable length [1-4] bytes encoding */
-}; 
+    uint8_t nexthop[4];
+    uint8_t origin_router[4];
+    uint8_t origin_as[4];
+    uint8_t tag[4];
+    uint8_t metric[4];
+    uint8_t reserved[2];
+    uint8_t proto_id;
+    uint8_t flags;
+    uint8_t delay[4];
+    uint8_t bandwidth[4];
+    uint8_t mtu[3];
+    uint8_t hopcount;
+    uint8_t reliability;
+    uint8_t load;
+    uint8_t reserved2[2];
+    uint8_t plen;
+    uint8_t destination; /* variable length [1-4] bytes encoding */
+};
 
 struct eigrp_tlv_at_cable_setup_t {
-    u_int8_t cable_start[2];
-    u_int8_t cable_end[2];
-    u_int8_t router_id[4];
+    uint8_t cable_start[2];
+    uint8_t cable_end[2];
+    uint8_t router_id[4];
 };
 
 struct eigrp_tlv_at_int_t {
-    u_int8_t nexthop[4];
-    u_int8_t delay[4];
-    u_int8_t bandwidth[4];
-    u_int8_t mtu[3];
-    u_int8_t hopcount;
-    u_int8_t reliability;
-    u_int8_t load;
-    u_int8_t reserved[2];
-    u_int8_t cable_start[2];
-    u_int8_t cable_end[2];
-}; 
+    uint8_t nexthop[4];
+    uint8_t delay[4];
+    uint8_t bandwidth[4];
+    uint8_t mtu[3];
+    uint8_t hopcount;
+    uint8_t reliability;
+    uint8_t load;
+    uint8_t reserved[2];
+    uint8_t cable_start[2];
+    uint8_t cable_end[2];
+};
 
 struct eigrp_tlv_at_ext_t {
-    u_int8_t nexthop[4];
-    u_int8_t origin_router[4];
-    u_int8_t origin_as[4];
-    u_int8_t tag[4];
-    u_int8_t proto_id;
-    u_int8_t flags;
-    u_int8_t metric[2];
-    u_int8_t delay[4];
-    u_int8_t bandwidth[4];
-    u_int8_t mtu[3];
-    u_int8_t hopcount;
-    u_int8_t reliability;
-    u_int8_t load;
-    u_int8_t reserved2[2];
-    u_int8_t cable_start[2];
-    u_int8_t cable_end[2];
+    uint8_t nexthop[4];
+    uint8_t origin_router[4];
+    uint8_t origin_as[4];
+    uint8_t tag[4];
+    uint8_t proto_id;
+    uint8_t flags;
+    uint8_t metric[2];
+    uint8_t delay[4];
+    uint8_t bandwidth[4];
+    uint8_t mtu[3];
+    uint8_t hopcount;
+    uint8_t reliability;
+    uint8_t load;
+    uint8_t reserved2[2];
+    uint8_t cable_start[2];
+    uint8_t cable_end[2];
 };
 
 static const struct tok eigrp_ext_proto_id_values[] = {
@@ -211,13 +205,13 @@
 };
 
 void
-eigrp_print(register const u_char *pptr, register u_int len) {
-
+eigrp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
+{
     const struct eigrp_common_header *eigrp_com_header;
     const struct eigrp_tlv_header *eigrp_tlv_header;
     const u_char *tptr,*tlv_tptr;
     u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length;
-    u_int8_t prefix[4];
+    uint8_t prefix[4];
 
     union {
         const struct eigrp_tlv_general_parm_t *eigrp_tlv_general_parm;
@@ -231,21 +225,21 @@
 
     tptr=pptr;
     eigrp_com_header = (const struct eigrp_common_header *)pptr;
-    TCHECK(*eigrp_com_header);
+    ND_TCHECK(*eigrp_com_header);
 
     /*
      * Sanity checking of the header.
      */
     if (eigrp_com_header->version != EIGRP_VERSION) {
-	printf("EIGRP version %u packet not supported",eigrp_com_header->version);
+	ND_PRINT((ndo, "EIGRP version %u packet not supported",eigrp_com_header->version));
 	return;
     }
 
     /* in non-verbose mode just lets print the basic Message Type*/
-    if (vflag < 1) {
-        printf("EIGRP %s, length: %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "EIGRP %s, length: %u",
                tok2str(eigrp_opcode_values, "unknown (%u)",eigrp_com_header->opcode),
-               len);
+               len));
         return;
     }
 
@@ -254,7 +248,7 @@
     tlen=len-sizeof(struct eigrp_common_header);
 
     /* FIXME print other header info */
-    printf("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
+    ND_PRINT((ndo, "\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
            eigrp_com_header->version,
            tok2str(eigrp_opcode_values, "unknown, type: %u",eigrp_com_header->opcode),
            eigrp_com_header->opcode,
@@ -265,13 +259,13 @@
            EXTRACT_32BITS(&eigrp_com_header->seq),
            EXTRACT_32BITS(&eigrp_com_header->ack),
            EXTRACT_32BITS(&eigrp_com_header->asn),
-           tlen);
+           tlen));
 
     tptr+=sizeof(const struct eigrp_common_header);
 
     while(tlen>0) {
         /* did we capture enough for fully decoding the object header ? */
-        TCHECK2(*tptr, sizeof(struct eigrp_tlv_header));
+        ND_TCHECK2(*tptr, sizeof(struct eigrp_tlv_header));
 
         eigrp_tlv_header = (const struct eigrp_tlv_header *)tptr;
         eigrp_tlv_len=EXTRACT_16BITS(&eigrp_tlv_header->length);
@@ -280,45 +274,45 @@
 
         if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) ||
             eigrp_tlv_len > tlen) {
-            print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t    ",tlen);
+            print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t    ",tlen);
             return;
         }
 
-        printf("\n\t  %s TLV (0x%04x), length: %u",
+        ND_PRINT((ndo, "\n\t  %s TLV (0x%04x), length: %u",
                tok2str(eigrp_tlv_values,
                        "Unknown",
                        eigrp_tlv_type),
                eigrp_tlv_type,
-               eigrp_tlv_len);
+               eigrp_tlv_len));
 
         tlv_tptr=tptr+sizeof(struct eigrp_tlv_header);
         tlv_tlen=eigrp_tlv_len-sizeof(struct eigrp_tlv_header);
 
         /* did we capture enough for fully decoding the object ? */
-        TCHECK2(*tptr, eigrp_tlv_len);
+        ND_TCHECK2(*tptr, eigrp_tlv_len);
 
         switch(eigrp_tlv_type) {
 
         case EIGRP_TLV_GENERAL_PARM:
             tlv_ptr.eigrp_tlv_general_parm = (const struct eigrp_tlv_general_parm_t *)tlv_tptr;
 
-            printf("\n\t    holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
+            ND_PRINT((ndo, "\n\t    holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
                    EXTRACT_16BITS(tlv_ptr.eigrp_tlv_general_parm->holdtime),
                    tlv_ptr.eigrp_tlv_general_parm->k1,
                    tlv_ptr.eigrp_tlv_general_parm->k2,
                    tlv_ptr.eigrp_tlv_general_parm->k3,
                    tlv_ptr.eigrp_tlv_general_parm->k4,
-                   tlv_ptr.eigrp_tlv_general_parm->k5);
+                   tlv_ptr.eigrp_tlv_general_parm->k5));
             break;
 
         case EIGRP_TLV_SW_VERSION:
             tlv_ptr.eigrp_tlv_sw_version = (const struct eigrp_tlv_sw_version_t *)tlv_tptr;
 
-            printf("\n\t    IOS version: %u.%u, EIGRP version %u.%u",
+            ND_PRINT((ndo, "\n\t    IOS version: %u.%u, EIGRP version %u.%u",
                    tlv_ptr.eigrp_tlv_sw_version->ios_major,
                    tlv_ptr.eigrp_tlv_sw_version->ios_minor,
                    tlv_ptr.eigrp_tlv_sw_version->eigrp_major,
-                   tlv_ptr.eigrp_tlv_sw_version->eigrp_minor);
+                   tlv_ptr.eigrp_tlv_sw_version->eigrp_minor));
             break;
 
         case EIGRP_TLV_IP_INT:
@@ -326,28 +320,28 @@
 
             bit_length = tlv_ptr.eigrp_tlv_ip_int->plen;
             if (bit_length > 32) {
-                printf("\n\t    illegal prefix length %u",bit_length);
+                ND_PRINT((ndo, "\n\t    illegal prefix length %u",bit_length));
                 break;
             }
             byte_length = (bit_length + 7) / 8; /* variable length encoding */
             memset(prefix, 0, 4);
             memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_int->destination,byte_length);
 
-            printf("\n\t    IPv4 prefix: %15s/%u, nexthop: ",
-                   ipaddr_string(prefix),
-                   bit_length);
+            ND_PRINT((ndo, "\n\t    IPv4 prefix: %15s/%u, nexthop: ",
+                   ipaddr_string(ndo, prefix),
+                   bit_length));
             if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->nexthop) == 0)
-                printf("self");
+                ND_PRINT((ndo, "self"));
             else
-                printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_int->nexthop));
+                ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_int->nexthop)));
 
-            printf("\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+            ND_PRINT((ndo, "\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
                    (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->delay)/100),
                    EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->bandwidth),
                    EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_int->mtu),
                    tlv_ptr.eigrp_tlv_ip_int->hopcount,
                    tlv_ptr.eigrp_tlv_ip_int->reliability,
-                   tlv_ptr.eigrp_tlv_ip_int->load);
+                   tlv_ptr.eigrp_tlv_ip_int->load));
             break;
 
         case EIGRP_TLV_IP_EXT:
@@ -355,99 +349,99 @@
 
             bit_length = tlv_ptr.eigrp_tlv_ip_ext->plen;
             if (bit_length > 32) {
-                printf("\n\t    illegal prefix length %u",bit_length);
+                ND_PRINT((ndo, "\n\t    illegal prefix length %u",bit_length));
                 break;
             }
             byte_length = (bit_length + 7) / 8; /* variable length encoding */
             memset(prefix, 0, 4);
             memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_ext->destination,byte_length);
 
-            printf("\n\t    IPv4 prefix: %15s/%u, nexthop: ",
-                   ipaddr_string(prefix),
-                   bit_length);
+            ND_PRINT((ndo, "\n\t    IPv4 prefix: %15s/%u, nexthop: ",
+                   ipaddr_string(ndo, prefix),
+                   bit_length));
             if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->nexthop) == 0)
-                printf("self");
+                ND_PRINT((ndo, "self"));
             else
-                printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_ext->nexthop));
+                ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_ext->nexthop)));
 
-            printf("\n\t      origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
-                   ipaddr_string(tlv_ptr.eigrp_tlv_ip_ext->origin_router),
+            ND_PRINT((ndo, "\n\t      origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
+                   ipaddr_string(ndo, tlv_ptr.eigrp_tlv_ip_ext->origin_router),
                    EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->origin_as),
                    tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_ip_ext->proto_id),
                    tlv_ptr.eigrp_tlv_ip_ext->flags,
                    EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->tag),
-                   EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric));
+                   EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric)));
 
-            printf("\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+            ND_PRINT((ndo, "\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
                    (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->delay)/100),
                    EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->bandwidth),
                    EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_ext->mtu),
                    tlv_ptr.eigrp_tlv_ip_ext->hopcount,
                    tlv_ptr.eigrp_tlv_ip_ext->reliability,
-                   tlv_ptr.eigrp_tlv_ip_ext->load);
+                   tlv_ptr.eigrp_tlv_ip_ext->load));
             break;
 
         case EIGRP_TLV_AT_CABLE_SETUP:
             tlv_ptr.eigrp_tlv_at_cable_setup = (const struct eigrp_tlv_at_cable_setup_t *)tlv_tptr;
 
-            printf("\n\t    Cable-range: %u-%u, Router-ID %u",
+            ND_PRINT((ndo, "\n\t    Cable-range: %u-%u, Router-ID %u",
                    EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_start),
                    EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_end),
-                   EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id));
+                   EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id)));
             break;
 
         case EIGRP_TLV_AT_INT:
             tlv_ptr.eigrp_tlv_at_int = (const struct eigrp_tlv_at_int_t *)tlv_tptr;
 
-            printf("\n\t     Cable-Range: %u-%u, nexthop: ",
+            ND_PRINT((ndo, "\n\t     Cable-Range: %u-%u, nexthop: ",
                    EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_start),
-                   EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end));
+                   EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end)));
 
             if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop) == 0)
-                printf("self");
+                ND_PRINT((ndo, "self"));
             else
-                printf("%u.%u",
+                ND_PRINT((ndo, "%u.%u",
                        EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop),
-                       EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2]));
+                       EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2])));
 
-            printf("\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+            ND_PRINT((ndo, "\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
                    (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->delay)/100),
                    EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->bandwidth),
                    EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_int->mtu),
                    tlv_ptr.eigrp_tlv_at_int->hopcount,
                    tlv_ptr.eigrp_tlv_at_int->reliability,
-                   tlv_ptr.eigrp_tlv_at_int->load);
+                   tlv_ptr.eigrp_tlv_at_int->load));
             break;
 
         case EIGRP_TLV_AT_EXT:
             tlv_ptr.eigrp_tlv_at_ext = (const struct eigrp_tlv_at_ext_t *)tlv_tptr;
 
-            printf("\n\t     Cable-Range: %u-%u, nexthop: ",
+            ND_PRINT((ndo, "\n\t     Cable-Range: %u-%u, nexthop: ",
                    EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_start),
-                   EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end));
+                   EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end)));
 
             if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop) == 0)
-                printf("self");
+                ND_PRINT((ndo, "self"));
             else
-                printf("%u.%u",
+                ND_PRINT((ndo, "%u.%u",
                        EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop),
-                       EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2]));
+                       EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2])));
 
-            printf("\n\t      origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
+            ND_PRINT((ndo, "\n\t      origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
                    EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_router),
                    EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_as),
                    tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_at_ext->proto_id),
                    tlv_ptr.eigrp_tlv_at_ext->flags,
                    EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->tag),
-                   EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric));
+                   EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric)));
 
-            printf("\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+            ND_PRINT((ndo, "\n\t      delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
                    (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->delay)/100),
                    EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->bandwidth),
                    EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_ext->mtu),
                    tlv_ptr.eigrp_tlv_at_ext->hopcount,
                    tlv_ptr.eigrp_tlv_at_ext->reliability,
-                   tlv_ptr.eigrp_tlv_at_ext->load);
+                   tlv_ptr.eigrp_tlv_at_ext->load));
             break;
 
             /*
@@ -462,13 +456,13 @@
         case EIGRP_TLV_IPX_EXT:
 
         default:
-            if (vflag <= 1)
-                print_unknown_data(tlv_tptr,"\n\t    ",tlv_tlen);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo,tlv_tptr,"\n\t    ",tlv_tlen);
             break;
         }
         /* do we want to see an additionally hexdump ? */
-        if (vflag > 1)
-            print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t    ",
+        if (ndo->ndo_vflag > 1)
+            print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t    ",
                                eigrp_tlv_len-sizeof(struct eigrp_tlv_header));
 
         tptr+=eigrp_tlv_len;
@@ -476,5 +470,5 @@
     }
     return;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
diff --git a/print-enc.c b/print-enc.c
index 5c01f3e..7bd8631 100644
--- a/print-enc.c
+++ b/print-enc.c
@@ -21,33 +21,72 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
 
-#include "enc.h"
+/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
+/*
+ * The authors of this code are John Ioannidis (ji@tla.org),
+ * Angelos D. Keromytis (kermit@csd.uch.gr) and
+ * Niels Provos (provos@physnet.uni-hamburg.de).
+ *
+ * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
+ * in November 1995.
+ *
+ * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
+ * by Angelos D. Keromytis.
+ *
+ * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
+ * and Niels Provos.
+ *
+ * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
+ * and Niels Provos.
+ * Copyright (c) 2001, Angelos D. Keromytis.
+ *
+ * Permission to use, copy, and modify this software with or without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all copies of any software which is or includes a copy or
+ * modification of this software.
+ * You may use this code under the GNU public license if you so wish. Please
+ * contribute changes back to the authors under this freer than GPL license
+ * so that we may further the use of strong encryption without limitations to
+ * all.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ */
+
+#define ENC_HDRLEN	12
+
+/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $	*/
+#define M_CONF		0x0400  /* packet was encrypted (ESP-transport) */
+#define M_AUTH		0x0800  /* packet was authenticated (AH) */
+
+struct enchdr {
+	uint32_t af;
+	uint32_t spi;
+	uint32_t flags;
+};
 
 #define ENC_PRINT_TYPE(wh, xf, nam) \
 	if ((wh) & (xf)) { \
-		printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \
+		ND_PRINT((ndo, "%s%s", nam, (wh) == (xf) ? "): " : ",")); \
 		(wh) &= ~(xf); \
 	}
 
 u_int
-enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+enc_if_print(netdissect_options *ndo,
+             const struct pcap_pkthdr *h, register const u_char *p)
 {
 	register u_int length = h->len;
 	register u_int caplen = h->caplen;
@@ -55,34 +94,34 @@
 	const struct enchdr *hdr;
 
 	if (caplen < ENC_HDRLEN) {
-		printf("[|enc]");
+		ND_PRINT((ndo, "[|enc]"));
 		goto out;
 	}
 
 	hdr = (struct enchdr *)p;
 	flags = hdr->flags;
 	if (flags == 0)
-		printf("(unprotected): ");
+		ND_PRINT((ndo, "(unprotected): "));
 	else
-		printf("(");
+		ND_PRINT((ndo, "("));
 	ENC_PRINT_TYPE(flags, M_AUTH, "authentic");
 	ENC_PRINT_TYPE(flags, M_CONF, "confidential");
 	/* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */
-	printf("SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi));
+	ND_PRINT((ndo, "SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi)));
 
 	length -= ENC_HDRLEN;
 	caplen -= ENC_HDRLEN;
 	p += ENC_HDRLEN;
-	
+
 	switch (hdr->af) {
 	case AF_INET:
-		ip_print(gndo, p, length);
+		ip_print(ndo, p, length);
 		break;
-#ifdef INET6
+#ifdef AF_INET6
 	case AF_INET6:
-		ip6_print(gndo, p, length);
+		ip6_print(ndo, p, length);
 		break;
-#endif /*INET6*/
+#endif
 	}
 
 out:
diff --git a/print-esp.c b/print-esp.c
index e01f967..8e267d4 100644
--- a/print-esp.c
+++ b/print-esp.c
@@ -21,19 +21,14 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <string.h>
-
 #include <tcpdump-stdinc.h>
 
+#include <string.h>
 #include <stdlib.h>
 
 /* Any code in this file that depends on HAVE_LIBCRYPTO depends on
@@ -48,36 +43,70 @@
 #endif
 #endif
 
-#include <stdio.h>
-
 #include "ip.h"
-#include "esp.h"
 #ifdef INET6
 #include "ip6.h"
 #endif
 
-#include "netdissect.h"
-#include "addrtoname.h"
+#include "interface.h"
 #include "extract.h"
 
-#ifndef HAVE_SOCKADDR_STORAGE
-#ifdef INET6
-struct sockaddr_storage {
-	union {
-		struct sockaddr_in sin;
-		struct sockaddr_in6 sin6;
-	} un;
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
+ */
+
+/*
+ * RFC1827/2406 Encapsulated Security Payload.
+ */
+
+struct newesp {
+	uint32_t	esp_spi;	/* ESP */
+	uint32_t	esp_seq;	/* Sequence number */
+	/*variable size*/		/* (IV and) Payload data */
+	/*variable size*/		/* padding */
+	/*8bit*/			/* pad size */
+	/*8bit*/			/* next header */
+	/*8bit*/			/* next header */
+	/*variable size, 32bit bound*/	/* Authentication data */
 };
-#else
-#define sockaddr_storage sockaddr
-#endif
-#endif /* HAVE_SOCKADDR_STORAGE */
 
 #ifdef HAVE_LIBCRYPTO
+union inaddr_u {
+	struct in_addr in4;
+#ifdef INET6
+	struct in6_addr in6;
+#endif
+};
 struct sa_list {
 	struct sa_list	*next;
-	struct sockaddr_storage daddr;
-	u_int32_t	spi;          /* if == 0, then IKEv2 */
+	u_int		daddr_version;
+	union inaddr_u	daddr;
+	uint32_t	spi;          /* if == 0, then IKEv2 */
 	int             initiator;
 	u_char          spii[8];      /* for IKEv2 */
 	u_char          spir[8];
@@ -106,7 +135,7 @@
 
 	/* initiator arg is any non-zero value */
 	if(initiator) initiator=1;
-				       
+
 	/* see if we can find the SA, and if so, decode it */
 	for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
 		if (sa->spi == 0
@@ -141,7 +170,7 @@
 	ndo->ndo_snapend = end;
 
 	return 1;
-	
+
 }
 USES_APPLE_RST
 
@@ -200,12 +229,12 @@
 	int i;
 
 	len = strlen(hex) / 2;
-		
+
 	if (len > binbuf_len) {
 		(*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len);
 		return 0;
 	}
-		
+
 	i = 0;
 	while (hex[0] != '\0' && hex[1]!='\0') {
 		binbuf[i] = hex2byte(ndo, hex);
@@ -229,14 +258,14 @@
 	const EVP_CIPHER *evp;
 	int authlen = 0;
 	char *colon, *p;
-	
+
 	colon = strchr(decode, ':');
 	if (colon == NULL) {
 		(*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
 		return 0;
 	}
 	*colon = '\0';
-	
+
 	if (strlen(decode) > strlen("-hmac96") &&
 	    !strcmp(decode + strlen(decode) - strlen("-hmac96"),
 		    "-hmac96")) {
@@ -258,11 +287,11 @@
 		sa->ivlen = 0;
 		return 0;
 	}
-	
+
 	sa->evp = evp;
 	sa->authlen = authlen;
 	sa->ivlen = EVP_CIPHER_iv_length(evp);
-	
+
 	colon++;
 	if (colon[0] == '0' && colon[1] == 'x') {
 		/* decode some hex! */
@@ -272,7 +301,7 @@
 		if(sa->secretlen == 0) return 0;
 	} else {
 		i = strlen(colon);
-		
+
 		if (i < sizeof(sa->secret)) {
 			memcpy(sa->secret, colon, i);
 			sa->secretlen = i;
@@ -302,7 +331,7 @@
 		return 0;
 	}
 	*colon = '\0';
-	
+
 	if(strcasecmp(colon,"sha1") == 0 ||
 	   strcasecmp(colon,"md5") == 0) {
 		sa->authlen = 12;
@@ -321,21 +350,21 @@
 	int   ilen, rlen;
 	char *authkey;
 	char *enckey;
-	
+
 	init = strsep(&line, " \t");
 	icookie = strsep(&line, " \t");
 	rcookie = strsep(&line, " \t");
 	authkey = strsep(&line, " \t");
 	enckey  = strsep(&line, " \t");
-	
+
 	/* if any fields are missing */
 	if(!init || !icookie || !rcookie || !authkey || !enckey) {
 		(*ndo->ndo_warning)(ndo, "print_esp: failed to find all fields for ikev2 at %s:%u",
 				    file, lineno);
-		
+
 		return;
 	}
-	
+
 	ilen = strlen(icookie);
 	rlen = strlen(rcookie);
 
@@ -349,7 +378,7 @@
 
 		(*ndo->ndo_warning)(ndo, "init=%s icookie=%s(%u) rcookie=%s(%u)",
 				    init, icookie, ilen, rcookie, rlen);
-		
+
 		return;
 	}
 
@@ -364,7 +393,7 @@
 	if(!espprint_decode_encalgo(ndo, enckey, &sa1)) return;
 
 	if(!espprint_decode_authalgo(ndo, authkey, &sa1)) return;
-	
+
 	esp_print_addsa(ndo, &sa1, FALSE);
 }
 
@@ -391,6 +420,7 @@
 	if (line == NULL) {
 		decode = spikey;
 		spikey = NULL;
+		/* sa1.daddr.version = 0; */
 		/* memset(&sa1.daddr, 0, sizeof(sa1.daddr)); */
 		/* sa1.spi = 0; */
 		sa_def    = 1;
@@ -430,42 +460,30 @@
 	if (spikey && strcasecmp(spikey, "ikev2") == 0) {
 		esp_print_decode_ikeline(ndo, line, file, lineno);
 		return;
-	} 
+	}
 
 	if (spikey) {
-		
+
 		char *spistr, *foo;
-		u_int32_t spino;
-		struct sockaddr_in *sin;
-#ifdef INET6
-		struct sockaddr_in6 *sin6;
-#endif
-		
+		uint32_t spino;
+
 		spistr = strsep(&spikey, "@");
-		
+
 		spino = strtoul(spistr, &foo, 0);
 		if (spistr == foo || !spikey) {
 			(*ndo->ndo_warning)(ndo, "print_esp: failed to decode spi# %s\n", foo);
 			return;
 		}
-		
+
 		sa1.spi = spino;
-		
-		sin = (struct sockaddr_in *)&sa1.daddr;
+
 #ifdef INET6
-		sin6 = (struct sockaddr_in6 *)&sa1.daddr;
-		if (inet_pton(AF_INET6, spikey, &sin6->sin6_addr) == 1) {
-#ifdef HAVE_SOCKADDR_SA_LEN
-			sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
-			sin6->sin6_family = AF_INET6;
+		if (inet_pton(AF_INET6, spikey, &sa1.daddr.in6) == 1) {
+			sa1.daddr_version = 6;
 		} else
 #endif
-			if (inet_pton(AF_INET, spikey, &sin->sin_addr) == 1) {
-#ifdef HAVE_SOCKADDR_SA_LEN
-				sin->sin_len = sizeof(struct sockaddr_in);
-#endif
-				sin->sin_family = AF_INET;
+			if (inet_pton(AF_INET, spikey, &sa1.daddr.in4) == 1) {
+				sa1.daddr_version = 4;
 			} else {
 				(*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
 				return;
@@ -476,7 +494,7 @@
 		/* skip any blank spaces */
 		while (isspace((unsigned char)*decode))
 			decode++;
-		
+
 		if(!espprint_decode_encalgo(ndo, decode, &sa1)) {
 			return;
 		}
@@ -576,12 +594,12 @@
 	ep = ndo->ndo_snapend;
 
 	if ((u_char *)(esp + 1) >= ep) {
-		fputs("[|ESP]", stdout);
+		ND_PRINT((ndo, "[|ESP]"));
 		goto fail;
 	}
-	(*ndo->ndo_printf)(ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi));
-	(*ndo->ndo_printf)(ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq));
-        (*ndo->ndo_printf)(ndo, ", length %u", length);
+	ND_PRINT((ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi)));
+	ND_PRINT((ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq)));
+	ND_PRINT((ndo, ", length %u", length));
 
 #ifndef HAVE_LIBCRYPTO
 	goto fail;
@@ -610,10 +628,9 @@
 
 		/* see if we can find the SA, and if so, decode it */
 		for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
-			struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa->daddr;
 			if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
-			    sin6->sin6_family == AF_INET6 &&
-			    UNALIGNED_MEMCMP(&sin6->sin6_addr, &ip6->ip6_dst,
+			    sa->daddr_version == 6 &&
+			    UNALIGNED_MEMCMP(&sa->daddr.in6, &ip6->ip6_dst,
 				   sizeof(struct in6_addr)) == 0) {
 				break;
 			}
@@ -628,10 +645,9 @@
 
 		/* see if we can find the SA, and if so, decode it */
 		for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
-			struct sockaddr_in *sin = (struct sockaddr_in *)&sa->daddr;
 			if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
-			    sin->sin_family == AF_INET &&
-			    UNALIGNED_MEMCMP(&sin->sin_addr, &ip->ip_dst,
+			    sa->daddr_version == 4 &&
+			    UNALIGNED_MEMCMP(&sa->daddr.in4, &ip->ip_dst,
 				   sizeof(struct in_addr)) == 0) {
 				break;
 			}
@@ -646,7 +662,7 @@
 	 */
 	if (sa == NULL)
 		sa = ndo->ndo_sa_default;
-	
+
 	/* if not found fail */
 	if (sa == NULL)
 		goto fail;
@@ -687,7 +703,7 @@
 	if (nhdr)
 		*nhdr = *(ep - 1);
 
-	(ndo->ndo_printf)(ndo, ": ");
+	ND_PRINT((ndo, ": "));
 	return advance;
 #endif
 
diff --git a/print-ether.c b/print-ether.c
index 4bc8ad3..e57d993 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -18,10 +18,6 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)";
-#endif
 
 #define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
@@ -30,16 +26,13 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 #include "ethertype.h"
 #include "ether.h"
 
-const struct tok ethertype_values[] = { 
+const struct tok ethertype_values[] = {
     { ETHERTYPE_IP,		"IPv4" },
     { ETHERTYPE_MPLS,		"MPLS unicast" },
     { ETHERTYPE_MPLS_MULTI,	"MPLS multicast" },
@@ -83,11 +76,13 @@
     { ETHERTYPE_GRE_ISO,        "GRE-OSI" },
     { ETHERTYPE_CFM_OLD,        "CFM (old)" },
     { ETHERTYPE_CFM,            "CFM" },
+    { ETHERTYPE_IEEE1905_1,     "IEEE1905.1" },
     { ETHERTYPE_LLDP,           "LLDP" },
-    { ETHERTYPE_TIPC,           "TIPC"},    	
+    { ETHERTYPE_TIPC,           "TIPC"},
     { ETHERTYPE_GEONET_OLD,     "GeoNet (old)"},
     { ETHERTYPE_GEONET,         "GeoNet"},
     { ETHERTYPE_CALM_FAST,      "CALM FAST"},
+    { ETHERTYPE_AOE,            "AoE" },
     { 0, NULL}
 };
 
@@ -96,30 +91,30 @@
                 const u_char *bp, u_int length)
 {
 	register const struct ether_header *ep;
-	u_int16_t ether_type;
+	uint16_t ether_type;
 
 	ep = (const struct ether_header *)bp;
 
-	(void)ND_PRINT((ndo, "%s > %s",
-		     etheraddr_string(ESRC(ep)),
-		     etheraddr_string(EDST(ep))));
+	ND_PRINT((ndo, "%s > %s",
+		     etheraddr_string(ndo, ESRC(ep)),
+		     etheraddr_string(ndo, EDST(ep))));
 
 	ether_type = EXTRACT_16BITS(&ep->ether_type);
 	if (!ndo->ndo_qflag) {
 	        if (ether_type <= ETHERMTU)
-		          (void)ND_PRINT((ndo, ", 802.3"));
-                else 
-		          (void)ND_PRINT((ndo, ", ethertype %s (0x%04x)",
+		          ND_PRINT((ndo, ", 802.3"));
+                else
+		          ND_PRINT((ndo, ", ethertype %s (0x%04x)",
 				       tok2str(ethertype_values,"Unknown", ether_type),
                                        ether_type));
         } else {
                 if (ether_type <= ETHERMTU)
-                          (void)ND_PRINT((ndo, ", 802.3"));
-                else 
-                          (void)ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
+                          ND_PRINT((ndo, ", 802.3"));
+                else
+                          ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
         }
 
-	(void)ND_PRINT((ndo, ", length %u: ", length));
+	ND_PRINT((ndo, ", length %u: ", length));
 }
 
 /*
@@ -163,7 +158,7 @@
 	 */
 	if (ether_type <= ETHERMTU) {
 		/* Try to print the LLC-layer header & higher layers */
-		if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
+		if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep),
 		    &extracted_ether_type) == 0) {
 			/* ether_type not known, print raw packet */
 			if (!ndo->ndo_eflag) {
@@ -173,7 +168,7 @@
 			}
 
 			if (!ndo->ndo_suppress_default_print)
-				ndo->ndo_default_print(ndo, p, caplen);
+				ND_DEFAULTPRINT(p, caplen);
 		}
 	} else if (ether_type == ETHERTYPE_8021Q  ||
                 ether_type == ETHERTYPE_8021Q9100 ||
@@ -188,12 +183,9 @@
 			return;
 		}
 	        if (ndo->ndo_eflag) {
-	        	u_int16_t tag = EXTRACT_16BITS(p);
+	        	uint16_t tag = EXTRACT_16BITS(p);
 
-			ND_PRINT((ndo, "vlan %u, p %u%s, ",
-			    tag & 0xfff,
-			    tag >> 13,
-			    (tag & 0x1000) ? ", CFI" : ""));
+			ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag)));
 		}
 
 		ether_type = EXTRACT_16BITS(p + 2);
@@ -214,7 +206,7 @@
 		 * there's an LLC header and payload.
 		 */
 		/* Try to print the LLC-layer header & higher layers */
-		if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
+		if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep),
 		    &extracted_ether_type) == 0) {
 			/* ether_type not known, print raw packet */
 			if (!ndo->ndo_eflag) {
@@ -224,7 +216,7 @@
 			}
 
 			if (!ndo->ndo_suppress_default_print)
-				ndo->ndo_default_print(ndo, p, caplen);
+				ND_DEFAULTPRINT(p, caplen);
 		}
 	} else {
 		if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
@@ -236,7 +228,7 @@
 			}
 
 			if (!ndo->ndo_suppress_default_print)
-				ndo->ndo_default_print(ndo, p, caplen);
+				ND_DEFAULTPRINT(p, caplen);
 		}
 	}
 }
@@ -273,7 +265,7 @@
 	 * Fail if we don't have enough data for the Hilscher pseudo-header.
 	 */
 	if (h->len < 4 || h->caplen < 4) {
-		printf("[|netanalyzer]");
+		ND_PRINT((ndo, "[|netanalyzer]"));
 		return (h->caplen);
 	}
 
@@ -303,7 +295,7 @@
 	 * preamble, and SOF.
 	 */
 	if (h->len < 12 || h->caplen < 12) {
-		printf("[|netanalyzer-transparent]");
+		ND_PRINT((ndo, "[|netanalyzer-transparent]"));
 		return (h->caplen);
 	}
 
@@ -331,11 +323,9 @@
 	        ip_print(ndo, p, length);
 		return (1);
 
-#ifdef INET6
 	case ETHERTYPE_IPV6:
 		ip6_print(ndo, p, length);
 		return (1);
-#endif /*INET6*/
 
 	case ETHERTYPE_ARP:
 	case ETHERTYPE_REVARP:
@@ -343,33 +333,33 @@
 		return (1);
 
 	case ETHERTYPE_DN:
-		decnet_print(/*ndo,*/p, length, caplen);
+		decnet_print(ndo, p, length, caplen);
 		return (1);
 
 	case ETHERTYPE_ATALK:
 		if (ndo->ndo_vflag)
-			fputs("et1 ", stdout);
-		atalk_print(/*ndo,*/p, length);
+			ND_PRINT((ndo, "et1 "));
+		atalk_print(ndo, p, length);
 		return (1);
 
 	case ETHERTYPE_AARP:
-		aarp_print(/*ndo,*/p, length);
+		aarp_print(ndo, p, length);
 		return (1);
 
 	case ETHERTYPE_IPX:
 		ND_PRINT((ndo, "(NOV-ETHII) "));
-		ipx_print(/*ndo,*/p, length);
+		ipx_print(ndo, p, length);
 		return (1);
 
-        case ETHERTYPE_ISO:
-                isoclns_print(/*ndo,*/p+1, length-1, length-1);
-                return(1);
+	case ETHERTYPE_ISO:
+		isoclns_print(ndo, p + 1, length - 1, length - 1);
+		return(1);
 
 	case ETHERTYPE_PPPOED:
 	case ETHERTYPE_PPPOES:
 	case ETHERTYPE_PPPOED2:
 	case ETHERTYPE_PPPOES2:
-		pppoe_print(/*ndo,*/p, length);
+		pppoe_print(ndo, p, length);
 		return (1);
 
 	case ETHERTYPE_EAPOL:
@@ -382,34 +372,35 @@
 
 	case ETHERTYPE_PPP:
 		if (length) {
-			printf(": ");
-			ppp_print(/*ndo,*/p, length);
+			ND_PRINT((ndo, ": "));
+			ppp_print(ndo, p, length);
 		}
 		return (1);
 
 	case ETHERTYPE_MPCP:
-	        mpcp_print(/*ndo,*/p, length);
+	        mpcp_print(ndo, p, length);
 		return (1);
 
 	case ETHERTYPE_SLOW:
-	        slow_print(/*ndo,*/p, length);
+	        slow_print(ndo, p, length);
 		return (1);
 
 	case ETHERTYPE_CFM:
 	case ETHERTYPE_CFM_OLD:
-	        cfm_print(/*ndo,*/p, length);
+		cfm_print(ndo, p, length);
 		return (1);
 
 	case ETHERTYPE_LLDP:
-	        lldp_print(/*ndo,*/p, length);
+		lldp_print(ndo, p, length);
 		return (1);
 
         case ETHERTYPE_LOOPBACK:
+		loopback_print(ndo, p, length);
                 return (1);
 
 	case ETHERTYPE_MPLS:
 	case ETHERTYPE_MPLS_MULTI:
-		mpls_print(/*ndo,*/p, length);
+		mpls_print(ndo, p, length);
 		return (1);
 
 	case ETHERTYPE_TIPC:
@@ -429,10 +420,15 @@
                 calm_fast_print(ndo, p-14, p, length);
                 return (1);
 
+	case ETHERTYPE_AOE:
+		aoe_print(ndo, p, length);
+		return (1);
+
 	case ETHERTYPE_LAT:
 	case ETHERTYPE_SCA:
 	case ETHERTYPE_MOPRC:
 	case ETHERTYPE_MOPDL:
+	case ETHERTYPE_IEEE1905_1:
 		/* default_print for now */
 	default:
 		return (0);
diff --git a/print-fddi.c b/print-fddi.c
index 1e7d554..ad760c8 100644
--- a/print-fddi.c
+++ b/print-fddi.c
@@ -19,27 +19,66 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "ethertype.h"
-
 #include "ether.h"
-#include "fddi.h"
+
+/*
+ * Based on Ultrix if_fddi.h
+ */
+
+struct fddi_header {
+	u_char  fddi_fc;		/* frame control */
+	u_char  fddi_dhost[6];
+	u_char  fddi_shost[6];
+};
+
+/*
+ * Length of an FDDI header; note that some compilers may pad
+ * "struct fddi_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct fddi_header)" may not give the right
+ * answer.
+ */
+#define FDDI_HDRLEN 13
+
+/* Useful values for fddi_fc (frame control) field */
+
+/*
+ * FDDI Frame Control bits
+ */
+#define	FDDIFC_C		0x80		/* Class bit */
+#define	FDDIFC_L		0x40		/* Address length bit */
+#define	FDDIFC_F		0x30		/* Frame format bits */
+#define	FDDIFC_Z		0x0f		/* Control bits */
+
+/*
+ * FDDI Frame Control values. (48-bit addressing only).
+ */
+#define	FDDIFC_VOID		0x40		/* Void frame */
+#define	FDDIFC_NRT		0x80		/* Nonrestricted token */
+#define	FDDIFC_RT		0xc0		/* Restricted token */
+#define	FDDIFC_SMT_INFO		0x41		/* SMT Info */
+#define	FDDIFC_SMT_NSA		0x4F		/* SMT Next station adrs */
+#define	FDDIFC_MAC_BEACON	0xc2		/* MAC Beacon frame */
+#define	FDDIFC_MAC_CLAIM	0xc3		/* MAC Claim frame */
+#define	FDDIFC_LLC_ASYNC	0x50		/* Async. LLC frame */
+#define	FDDIFC_LLC_SYNC		0xd0		/* Sync. LLC frame */
+#define	FDDIFC_IMP_ASYNC	0x60		/* Implementor Async. */
+#define	FDDIFC_IMP_SYNC		0xe0		/* Implementor Synch. */
+#define FDDIFC_SMT		0x40		/* SMT frame */
+#define FDDIFC_MAC		0xc0		/* MAC frame */
+
+#define	FDDIFC_CLFF		0xF0		/* Class/Length/Format bits */
+#define	FDDIFC_ZZZZ		0x0F		/* Control bits */
 
 /*
  * Some FDDI interfaces use bit-swapped addresses.
@@ -80,7 +119,7 @@
  *  - vj
  */
 
-static u_char fddi_bit_swap[] = {
+static const u_char fddi_bit_swap[] = {
 	0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
 	0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
 	0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
@@ -119,67 +158,67 @@
  * Print FDDI frame-control bits
  */
 static inline void
-print_fddi_fc(u_char fc)
+print_fddi_fc(netdissect_options *ndo, u_char fc)
 {
 	switch (fc) {
 
 	case FDDIFC_VOID:                         /* Void frame */
-		printf("void ");
+		ND_PRINT((ndo, "void "));
 		break;
 
 	case FDDIFC_NRT:                          /* Nonrestricted token */
-		printf("nrt ");
+		ND_PRINT((ndo, "nrt "));
 		break;
 
 	case FDDIFC_RT:                           /* Restricted token */
-		printf("rt ");
+		ND_PRINT((ndo, "rt "));
 		break;
 
 	case FDDIFC_SMT_INFO:                     /* SMT Info */
-		printf("info ");
+		ND_PRINT((ndo, "info "));
 		break;
 
 	case FDDIFC_SMT_NSA:                      /* SMT Next station adrs */
-		printf("nsa ");
+		ND_PRINT((ndo, "nsa "));
 		break;
 
 	case FDDIFC_MAC_BEACON:                   /* MAC Beacon frame */
-		printf("beacon ");
+		ND_PRINT((ndo, "beacon "));
 		break;
 
 	case FDDIFC_MAC_CLAIM:                    /* MAC Claim frame */
-		printf("claim ");
+		ND_PRINT((ndo, "claim "));
 		break;
 
 	default:
 		switch (fc & FDDIFC_CLFF) {
 
 		case FDDIFC_MAC:
-			printf("mac%1x ", fc & FDDIFC_ZZZZ);
+			ND_PRINT((ndo, "mac%1x ", fc & FDDIFC_ZZZZ));
 			break;
 
 		case FDDIFC_SMT:
-			printf("smt%1x ", fc & FDDIFC_ZZZZ);
+			ND_PRINT((ndo, "smt%1x ", fc & FDDIFC_ZZZZ));
 			break;
 
 		case FDDIFC_LLC_ASYNC:
-			printf("async%1x ", fc & FDDIFC_ZZZZ);
+			ND_PRINT((ndo, "async%1x ", fc & FDDIFC_ZZZZ));
 			break;
 
 		case FDDIFC_LLC_SYNC:
-			printf("sync%1x ", fc & FDDIFC_ZZZZ);
+			ND_PRINT((ndo, "sync%1x ", fc & FDDIFC_ZZZZ));
 			break;
 
 		case FDDIFC_IMP_ASYNC:
-			printf("imp_async%1x ", fc & FDDIFC_ZZZZ);
+			ND_PRINT((ndo, "imp_async%1x ", fc & FDDIFC_ZZZZ));
 			break;
 
 		case FDDIFC_IMP_SYNC:
-			printf("imp_sync%1x ", fc & FDDIFC_ZZZZ);
+			ND_PRINT((ndo, "imp_sync%1x ", fc & FDDIFC_ZZZZ));
 			break;
 
 		default:
-			printf("%02x ", fc);
+			ND_PRINT((ndo, "%02x ", fc));
 			break;
 		}
 	}
@@ -211,42 +250,43 @@
  * Print the FDDI MAC header
  */
 static inline void
-fddi_hdr_print(register const struct fddi_header *fddip, register u_int length,
-	   register const u_char *fsrc, register const u_char *fdst)
+fddi_hdr_print(netdissect_options *ndo,
+               register const struct fddi_header *fddip, register u_int length,
+               register const u_char *fsrc, register const u_char *fdst)
 {
 	const char *srcname, *dstname;
 
-	srcname = etheraddr_string(fsrc);
-	dstname = etheraddr_string(fdst);
+	srcname = etheraddr_string(ndo, fsrc);
+	dstname = etheraddr_string(ndo, fdst);
 
-	if (vflag)
-		(void) printf("%02x %s %s %d: ",
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, "%02x %s %s %d: ",
 		       fddip->fddi_fc,
 		       srcname, dstname,
-		       length);
-	else if (qflag)
-		printf("%s %s %d: ", srcname, dstname, length);
+		       length));
+	else if (ndo->ndo_qflag)
+		ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
 	else {
-		(void) print_fddi_fc(fddip->fddi_fc);
-		(void) printf("%s %s %d: ", srcname, dstname, length);
+		print_fddi_fc(ndo, fddip->fddi_fc);
+		ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
 	}
 }
 
 static inline void
-fddi_smt_print(const u_char *p _U_, u_int length _U_)
+fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_)
 {
-	printf("<SMT printer not yet implemented>");
+	ND_PRINT((ndo, "<SMT printer not yet implemented>"));
 }
 
 void
-fddi_print(const u_char *p, u_int length, u_int caplen)
+fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
 	const struct fddi_header *fddip = (const struct fddi_header *)p;
 	struct ether_header ehdr;
 	u_short extracted_ethertype;
 
 	if (caplen < FDDI_HDRLEN) {
-		printf("[|fddi]");
+		ND_PRINT((ndo, "[|fddi]"));
 		return;
 	}
 
@@ -255,8 +295,8 @@
 	 */
 	extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
 
-	if (eflag)
-		fddi_hdr_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
+	if (ndo->ndo_eflag)
+		fddi_hdr_print(ndo, fddip, length, ESRC(&ehdr), EDST(&ehdr));
 
 	/* Skip over FDDI MAC header */
 	length -= FDDI_HDRLEN;
@@ -266,31 +306,31 @@
 	/* Frame Control field determines interpretation of packet */
 	if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
 		/* Try to print the LLC-layer header & higher layers */
-		if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+		if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
 		    &extracted_ethertype) == 0) {
 			/*
 			 * Some kinds of LLC packet we cannot
 			 * handle intelligently
 			 */
-			if (!eflag)
-				fddi_hdr_print(fddip, length + FDDI_HDRLEN,
+			if (!ndo->ndo_eflag)
+				fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN,
 				    ESRC(&ehdr), EDST(&ehdr));
 			if (extracted_ethertype) {
-				printf("(LLC %s) ",
-			etherproto_string(htons(extracted_ethertype)));
+				ND_PRINT((ndo, "(LLC %s) ",
+			etherproto_string(htons(extracted_ethertype))));
 			}
-			if (!suppress_default_print)
-				default_print(p, caplen);
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p, caplen);
 		}
 	} else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
-		fddi_smt_print(p, caplen);
+		fddi_smt_print(ndo, p, caplen);
 	else {
 		/* Some kinds of FDDI packet we cannot handle intelligently */
-		if (!eflag)
-			fddi_hdr_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
+		if (!ndo->ndo_eflag)
+			fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
 			    EDST(&ehdr));
-		if (!suppress_default_print)
-			default_print(p, caplen);
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
 	}
 }
 
@@ -301,9 +341,9 @@
  * is the number of bytes actually captured.
  */
 u_int
-fddi_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
-	fddi_print(p, h->len, h->caplen);
+	fddi_print(ndo, p, h->len, h->caplen);
 
 	return (FDDI_HDRLEN);
 }
diff --git a/print-forces.c b/print-forces.c
index 7391209..6c02b25 100644
--- a/print-forces.c
+++ b/print-forces.c
@@ -14,22 +14,21 @@
  *
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
 
+static const char tstr[] = "[|forces]";
 
 /*
- * Per draft-ietf-forces-protocol-22
-*/
+ * RFC5810: Forwarding and Control Element Separation (ForCES) Protocol
+ */
 #define	ForCES_VERS	1
 #define	ForCES_HDRL	24
 #define	ForCES_ALNL	4U
@@ -63,12 +62,12 @@
 #define TTLV_T2		(ONE_MORE_TTLV|MAX_TLV)
 
 struct tom_h {
-	u_int32_t v;
-	u_int16_t flags;
-	u_int16_t op_msk;
+	uint32_t v;
+	uint16_t flags;
+	uint16_t op_msk;
 	const char *s;
-	int (*print) (register const u_char * pptr, register u_int len,
-		      u_int16_t op_msk, int indent);
+	int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+		      uint16_t op_msk, int indent);
 };
 
 enum {
@@ -87,7 +86,7 @@
 };
 #define TOM_MAX_IND (_TOM_RSV_MAX - 1)
 
-static inline int tom_valid(u_int8_t tom)
+static inline int tom_valid(uint8_t tom)
 {
 	if (tom > 0) {
 		if (tom >= 0x7 && tom <= 0xe)
@@ -101,7 +100,7 @@
 		return 0;
 }
 
-static inline const char *ForCES_node(u_int32_t node)
+static inline const char *ForCES_node(uint32_t node)
 {
 	if (node <= 0x3FFFFFFF)
 		return "FE";
@@ -120,69 +119,51 @@
 
 }
 
-static inline const char *ForCES_ACKp(u_int32_t flg)
-{
-	if (flg == 0x0)
-		return "NoACK";
-	if (flg == 0x1)
-		return "SuccessACK";
-	if (flg == 0x2)
-		return "FailureACK";
-	if (flg == 0x3)
-		return "AlwaysACK";
-	return "ACKUnknown";
-}
+static const struct tok ForCES_ACKs[] = {
+	{0x0, "NoACK"},
+	{0x1, "SuccessACK"},
+	{0x2, "FailureACK"},
+	{0x3, "AlwaysACK"},
+	{0, NULL}
+};
 
-static inline const char *ForCES_EMp(u_int32_t flg)
-{
-	if (flg == 0x0)
-		return "EMReserved";
-	if (flg == 0x1)
-		return "execute-all-or-none";
-	if (flg == 0x2)
-		return "execute-until-failure";
-	if (flg == 0x3)
-		return "continue-execute-on-failure";
-	return "EMUnknown";
-}
+static const struct tok ForCES_EMs[] = {
+	{0x0, "EMReserved"},
+	{0x1, "execute-all-or-none"},
+	{0x2, "execute-until-failure"},
+	{0x3, "continue-execute-on-failure"},
+	{0, NULL}
+};
 
-static inline const char *ForCES_ATp(u_int32_t flg)
-{
-	if (flg == 0x0)
-		return "Standalone";
-	if (flg == 0x1)
-		return "2PCtransaction";
-	return "ATUnknown";
-}
+static const struct tok ForCES_ATs[] = {
+	{0x0, "Standalone"},
+	{0x1, "2PCtransaction"},
+	{0, NULL}
+};
 
-static inline const char *ForCES_TPp(u_int32_t flg)
-{
-	if (flg == 0x0)
-		return "StartofTransaction";
-	if (flg == 0x1)
-		return "MiddleofTransaction";
-	if (flg == 0x2)
-		return "EndofTransaction";
-	if (flg == 0x3)
-		return "abort";
-	return "TPUnknown";
-}
+static const struct tok ForCES_TPs[] = {
+	{0x0, "StartofTransaction"},
+	{0x1, "MiddleofTransaction"},
+	{0x2, "EndofTransaction"},
+	{0x3, "abort"},
+	{0, NULL}
+};
 
 /*
  * Structure of forces header, naked of TLVs.
  */
 struct forcesh {
-	u_int8_t fm_vrsvd;	/* version and reserved */
+	uint8_t fm_vrsvd;	/* version and reserved */
 #define ForCES_V(forcesh)	((forcesh)->fm_vrsvd >> 4)
-	u_int8_t fm_tom;	/* type of message */
-	u_int16_t fm_len;	/* total length * 4 bytes */
-#define ForCES_BLN(forcesh)	((u_int32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
-	u_int32_t fm_sid;	/* Source ID */
+	uint8_t fm_tom;	/* type of message */
+	uint16_t fm_len;	/* total length * 4 bytes */
+#define ForCES_BLN(forcesh)	((uint32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
+	uint32_t fm_sid;	/* Source ID */
 #define ForCES_SID(forcesh)	EXTRACT_32BITS(&(forcesh)->fm_sid)
-	u_int32_t fm_did;	/* Destination ID */
+	uint32_t fm_did;	/* Destination ID */
 #define ForCES_DID(forcesh)	EXTRACT_32BITS(&(forcesh)->fm_did)
-	u_int8_t fm_cor[8];	/* correlator */
-	u_int32_t fm_flags;	/* flags */
+	uint8_t fm_cor[8];	/* correlator */
+	uint32_t fm_flags;	/* flags */
 #define ForCES_ACK(forcesh)	((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
 #define ForCES_PRI(forcesh)	((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
 #define ForCES_RS1(forcesh)	((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
@@ -206,26 +187,28 @@
 	{0, NULL}
 };
 
+/* this is defined in RFC5810 section A.2 */
+/*   http://www.iana.org/assignments/forces/forces.xhtml#oper-tlv-types */
 enum {
-	F_OP_RSV,
-	F_OP_SET,
-	F_OP_SETPROP,
-	F_OP_SETRESP,
-	F_OP_SETPRESP,
-	F_OP_DEL,
-	F_OP_DELRESP,
-	F_OP_GET,
-	F_OP_GETPROP,
-	F_OP_GETRESP,
-	F_OP_GETPRESP,
-	F_OP_REPORT,
-	F_OP_COMMIT,
-	F_OP_RCOMMIT,
-	F_OP_RTRCOMP,
+	F_OP_RSV        = 0,
+	F_OP_SET        = 1,
+	F_OP_SETPROP    = 2,
+	F_OP_SETRESP    = 3,
+	F_OP_SETPRESP   = 4,
+	F_OP_DEL        = 5,
+	F_OP_DELRESP    = 6,
+	F_OP_GET        = 7,
+	F_OP_GETPROP    = 8,
+	F_OP_GETRESP    = 9,
+	F_OP_GETPRESP   = 10,
+	F_OP_REPORT     = 11,
+	F_OP_COMMIT     = 12,
+	F_OP_RCOMMIT    = 13,
+	F_OP_RTRCOMP    = 14,
 	_F_OP_MAX
 };
-
 #define F_OP_MAX	(_F_OP_MAX - 1)
+
 enum {
 	B_OP_SET = 1 << (F_OP_SET - 1),
 	B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
@@ -244,24 +227,24 @@
 };
 
 struct optlv_h {
-	u_int16_t flags;
-	u_int16_t op_msk;
+	uint16_t flags;
+	uint16_t op_msk;
 	const char *s;
-	int (*print) (register const u_char * pptr, register u_int len,
-		      u_int16_t op_msk, int indent);
+	int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+		      uint16_t op_msk, int indent);
 };
 
-static int genoptlv_print(register const u_char * pptr, register u_int len,
-			 u_int16_t op_msk, int indent);
-static int recpdoptlv_print(register const u_char * pptr, register u_int len,
-			    u_int16_t op_msk, int indent);
-static int invoptlv_print(register const u_char * pptr, register u_int len,
-			  u_int16_t op_msk, int indent);
+static int genoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			 uint16_t op_msk, int indent);
+static int recpdoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			    uint16_t op_msk, int indent);
+static int invoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			  uint16_t op_msk, int indent);
 
 #define OP_MIN_SIZ 8
 struct pathdata_h {
-	u_int16_t pflags;
-	u_int16_t pIDcnt;
+	uint16_t pflags;
+	uint16_t pIDcnt;
 };
 
 #define	B_FULLD		0x1
@@ -293,7 +276,7 @@
 	/* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
 };
 
-static inline const struct optlv_h *get_forces_optlv_h(u_int16_t opt)
+static inline const struct optlv_h *get_forces_optlv_h(uint16_t opt)
 {
 	if (opt > F_OP_MAX || opt <= F_OP_RSV)
 		return &OPTLV_msg[F_OP_RSV];
@@ -328,7 +311,7 @@
 	return r;
 }
 
-static inline int op_valid(u_int16_t op, u_int16_t mask)
+static inline int op_valid(uint16_t op, uint16_t mask)
 {
 	int opb = 1 << (op - 1);
 
@@ -376,7 +359,7 @@
 };
 
 #define TLV_HLN	4
-static inline int ttlv_valid(u_int16_t ttlv)
+static inline int ttlv_valid(uint16_t ttlv)
 {
 	if (ttlv > 0) {
 		if (ttlv == 1 || ttlv == 0x1000)
@@ -393,13 +376,13 @@
 }
 
 struct forces_ilv {
-	u_int32_t type;
-	u_int32_t length;
+	uint32_t type;
+	uint32_t length;
 };
 
 struct forces_tlv {
-	u_int16_t type;
-	u_int16_t length;
+	uint16_t type;
+	uint16_t length;
 };
 
 #define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
@@ -418,10 +401,10 @@
 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
 		              (struct forces_ilv *)(((char*)(ilv)) \
 				      + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
-#define INVALID_RLEN -1
-#define INVALID_STLN -2
-#define INVALID_LTLN -3
-#define INVALID_ALEN -4
+#define INVALID_RLEN 1
+#define INVALID_STLN 2
+#define INVALID_LTLN 3
+#define INVALID_ALEN 4
 
 static const struct tok ForCES_TLV_err[] = {
 	{INVALID_RLEN, "Invalid total length"},
@@ -431,7 +414,7 @@
 	{0, NULL}
 };
 
-static inline int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
+static inline u_int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
 {
 	if (rlen < TLV_HDRL)
 		return INVALID_RLEN;
@@ -459,18 +442,18 @@
 	return 0;
 }
 
-static int lfbselect_print(register const u_char * pptr, register u_int len,
-			   u_int16_t op_msk, int indent);
-static int redirect_print(register const u_char * pptr, register u_int len,
-			  u_int16_t op_msk, int indent);
-static int asrtlv_print(register const u_char * pptr, register u_int len,
-			u_int16_t op_msk, int indent);
-static int asttlv_print(register const u_char * pptr, register u_int len,
-			u_int16_t op_msk, int indent);
+static int lfbselect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			   uint16_t op_msk, int indent);
+static int redirect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			  uint16_t op_msk, int indent);
+static int asrtlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			uint16_t op_msk, int indent);
+static int asttlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			uint16_t op_msk, int indent);
 
 struct forces_lfbsh {
-	u_int32_t class;
-	u_int32_t instance;
+	uint32_t class;
+	uint32_t instance;
 };
 
 #define ASSNS_OPS (B_OP_REPORT)
@@ -501,7 +484,7 @@
 	    {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
 };
 
-static inline const struct tom_h *get_forces_tom(u_int8_t tom)
+static inline const struct tom_h *get_forces_tom(uint8_t tom)
 {
 	int i;
 	for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
@@ -513,12 +496,12 @@
 }
 
 struct pdata_ops {
-	u_int32_t v;
-	u_int16_t flags;
-	u_int16_t op_msk;
+	uint32_t v;
+	uint16_t flags;
+	uint16_t op_msk;
 	const char *s;
-	int (*print) (register const u_char * pptr, register u_int len,
-		      u_int16_t op_msk, int indent);
+	int (*print) (netdissect_options *, register const u_char * pptr, register u_int len,
+		      uint16_t op_msk, int indent);
 };
 
 enum {
@@ -532,26 +515,26 @@
 };
 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
 
-static inline int pd_valid(u_int16_t pd)
+static inline int pd_valid(uint16_t pd)
 {
 	if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
 		return 1;
 	return 0;
 }
 
-static inline void chk_op_type(u_int16_t type, u_int16_t msk, u_int16_t omsk)
+static inline void
+chk_op_type(netdissect_options *ndo,
+            uint16_t type, uint16_t msk, uint16_t omsk)
 {
 	if (type != F_TLV_PDAT) {
 		if (msk & B_KEYIN) {
 			if (type != F_TLV_KEYI) {
-				printf
-				    ("Based on flags expected KEYINFO TLV!\n");
+				ND_PRINT((ndo, "Based on flags expected KEYINFO TLV!\n"));
 			}
 		} else {
 			if (!(msk & omsk)) {
-				printf
-				    ("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
-				     type, omsk, msk);
+				ND_PRINT((ndo, "Illegal DATA encoding for type 0x%x programmed %x got %x \n",
+				          type, omsk, msk));
 			}
 		}
 	}
@@ -563,19 +546,19 @@
 #define F_TABAPPEND 4
 
 struct res_val {
-	u_int8_t result;
-	u_int8_t resv1;
-	u_int16_t resv2;
+	uint8_t result;
+	uint8_t resv1;
+	uint16_t resv2;
 };
 
-static int prestlv_print(register const u_char * pptr, register u_int len,
-			 u_int16_t op_msk, int indent);
-static int pkeyitlv_print(register const u_char * pptr, register u_int len,
-			  u_int16_t op_msk, int indent);
-static int fdatatlv_print(register const u_char * pptr, register u_int len,
-			  u_int16_t op_msk, int indent);
-static int sdatatlv_print(register const u_char * pptr, register u_int len,
-			  u_int16_t op_msk, int indent);
+static int prestlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			 uint16_t op_msk, int indent);
+static int pkeyitlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			  uint16_t op_msk, int indent);
+static int fdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			  uint16_t op_msk, int indent);
+static int sdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+			  uint16_t op_msk, int indent);
 
 static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
 	/* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
@@ -587,7 +570,7 @@
 	    {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
 };
 
-static inline const struct pdata_ops *get_forces_pd(u_int16_t pd)
+static inline const struct pdata_ops *get_forces_pd(uint16_t pd)
 {
 	int i;
 	for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
@@ -659,8 +642,9 @@
 #define RESLEN	4
 
 static int
-prestlv_print(register const u_char * pptr, register u_int len,
-	      u_int16_t op_msk _U_, int indent)
+prestlv_print(netdissect_options *ndo,
+              register const u_char * pptr, register u_int len,
+              uint16_t op_msk _U_, int indent)
 {
 	const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
 	register const u_char *tdp = (u_char *) TLV_DATA(tlv);
@@ -673,95 +657,97 @@
 	 */
 	dlen = len - TLV_HDRL;
 	if (dlen != RESLEN) {
-		printf("illegal RESULT-TLV: %d bytes!\n", dlen);
+		ND_PRINT((ndo, "illegal RESULT-TLV: %d bytes!\n", dlen));
 		return -1;
 	}
 
-	TCHECK(*r);
+	ND_TCHECK(*r);
 	if (r->result >= 0x18 && r->result <= 0xFE) {
-		printf("illegal reserved result code: 0x%x!\n", r->result);
+		ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", r->result));
 		return -1;
 	}
 
-	if (vflag >= 3) {
+	if (ndo->ndo_vflag >= 3) {
 		char *ib = indent_pr(indent, 0);
-		printf("%s  Result: %s (code 0x%x)\n", ib,
-		       tok2str(ForCES_errs, NULL, r->result), r->result);
+		ND_PRINT((ndo, "%s  Result: %s (code 0x%x)\n", ib,
+		       tok2str(ForCES_errs, NULL, r->result), r->result));
 	}
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-fdatatlv_print(register const u_char * pptr, register u_int len,
-	       u_int16_t op_msk _U_, int indent)
+fdatatlv_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t op_msk _U_, int indent)
 {
 	const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
 	u_int rlen;
 	register const u_char *tdp = (u_char *) TLV_DATA(tlv);
-	u_int16_t type;
+	uint16_t type;
 
 	/*
 	 * pdatacnt_print() or pkeyitlv_print() has ensured that len
 	 * (the TLV length) >= TLV_HDRL.
 	 */
 	rlen = len - TLV_HDRL;
-	TCHECK(*tlv);
+	ND_TCHECK(*tlv);
 	type = EXTRACT_16BITS(&tlv->type);
 	if (type != F_TLV_FULD) {
-		printf("Error: expecting FULLDATA!\n");
+		ND_PRINT((ndo, "Error: expecting FULLDATA!\n"));
 		return -1;
 	}
 
-	if (vflag >= 3) {
+	if (ndo->ndo_vflag >= 3) {
 		char *ib = indent_pr(indent + 2, 1);
-		printf("%s[", &ib[1]);
-		hex_print_with_offset(ib, tdp, rlen, 0);
-		printf("\n%s]\n", &ib[1]);
+		ND_PRINT((ndo, "%s[", &ib[1]));
+		hex_print_with_offset(ndo, ib, tdp, rlen, 0);
+		ND_PRINT((ndo, "\n%s]\n", &ib[1]));
 	}
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-sdatailv_print(register const u_char * pptr, register u_int len,
-	       u_int16_t op_msk _U_, int indent)
+sdatailv_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t op_msk _U_, int indent)
 {
 	u_int rlen;
 	const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
 	int invilv;
 
 	if (len < ILV_HDRL) {
-		printf("Error: BAD SPARSEDATA-TLV!\n");
+		ND_PRINT((ndo, "Error: BAD SPARSEDATA-TLV!\n"));
 		return -1;
 	}
 	rlen = len;
 	indent += 1;
 	while (rlen != 0) {
 #if 0
-		printf("Jamal - outstanding length <%d>\n", rlen);
+		ND_PRINT((ndo, "Jamal - outstanding length <%d>\n", rlen));
 #endif
 		char *ib = indent_pr(indent, 1);
 		register const u_char *tdp = (u_char *) ILV_DATA(ilv);
-		TCHECK(*ilv);
+		ND_TCHECK(*ilv);
 		invilv = ilv_valid(ilv, rlen);
 		if (invilv) {
-			printf("%s[", &ib[1]);
-			hex_print_with_offset(ib, tdp, rlen, 0);
-			printf("\n%s]\n", &ib[1]);
+			ND_PRINT((ndo, "%s[", &ib[1]));
+			hex_print_with_offset(ndo, ib, tdp, rlen, 0);
+			ND_PRINT((ndo, "\n%s]\n", &ib[1]));
 			return -1;
 		}
-		if (vflag >= 3) {
+		if (ndo->ndo_vflag >= 3) {
 			int ilvl = EXTRACT_32BITS(&ilv->length);
-			printf("\n%s ILV: type %x length %d\n", &ib[1],
-			       EXTRACT_32BITS(&ilv->type), ilvl);
-			hex_print_with_offset("\t\t[", tdp, ilvl-ILV_HDRL, 0);
+			ND_PRINT((ndo, "\n%s ILV: type %x length %d\n", &ib[1],
+			       EXTRACT_32BITS(&ilv->type), ilvl));
+			hex_print_with_offset(ndo, "\t\t[", tdp, ilvl-ILV_HDRL, 0);
 		}
 
 		ilv = GO_NXT_ILV(ilv, rlen);
@@ -770,62 +756,64 @@
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-sdatatlv_print(register const u_char * pptr, register u_int len,
-	       u_int16_t op_msk, int indent)
+sdatatlv_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t op_msk, int indent)
 {
 	const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
 	u_int rlen;
 	register const u_char *tdp = (u_char *) TLV_DATA(tlv);
-	u_int16_t type;
+	uint16_t type;
 
 	/*
 	 * pdatacnt_print() has ensured that len (the TLV length)
 	 * >= TLV_HDRL.
 	 */
 	rlen = len - TLV_HDRL;
-	TCHECK(*tlv);
+	ND_TCHECK(*tlv);
 	type = EXTRACT_16BITS(&tlv->type);
 	if (type != F_TLV_SPAD) {
-		printf("Error: expecting SPARSEDATA!\n");
+		ND_PRINT((ndo, "Error: expecting SPARSEDATA!\n"));
 		return -1;
 	}
 
-	return sdatailv_print(tdp, rlen, op_msk, indent);
+	return sdatailv_print(ndo, tdp, rlen, op_msk, indent);
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-pkeyitlv_print(register const u_char * pptr, register u_int len,
-	       u_int16_t op_msk, int indent)
+pkeyitlv_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t op_msk, int indent)
 {
 	const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
 	register const u_char *tdp = (u_char *) TLV_DATA(tlv);
 	register const u_char *dp = tdp + 4;
 	const struct forces_tlv *kdtlv = (struct forces_tlv *)dp;
-	u_int32_t id;
+	uint32_t id;
 	char *ib = indent_pr(indent, 0);
-	u_int16_t type, tll;
-	int invtlv;
+	uint16_t type, tll;
+	u_int invtlv;
 
-	TCHECK(*tdp);
+	ND_TCHECK(*tdp);
 	id = EXTRACT_32BITS(tdp);
-	printf("%sKeyinfo: Key 0x%x\n", ib, id);
-	TCHECK(*kdtlv);
+	ND_PRINT((ndo, "%sKeyinfo: Key 0x%x\n", ib, id));
+	ND_TCHECK(*kdtlv);
 	type = EXTRACT_16BITS(&kdtlv->type);
 	invtlv = tlv_valid(kdtlv, len);
 
 	if (invtlv) {
-		printf("%s TLV type 0x%x len %d\n",
+		ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
 		       tok2str(ForCES_TLV_err, NULL, invtlv), type,
-		       EXTRACT_16BITS(&kdtlv->length));
+		       EXTRACT_16BITS(&kdtlv->length)));
 		return -1;
 	}
 	/*
@@ -835,44 +823,45 @@
 	 */
 	tll = EXTRACT_16BITS(&kdtlv->length);
 	dp = (u_char *) TLV_DATA(kdtlv);
-	return fdatatlv_print(dp, tll, op_msk, indent);
+	return fdatatlv_print(ndo, dp, tll, op_msk, indent);
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 #define PTH_DESC_SIZE 12
 
 static int
-pdatacnt_print(register const u_char * pptr, register u_int len,
-	       u_int16_t IDcnt, u_int16_t op_msk, int indent)
+pdatacnt_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t IDcnt, uint16_t op_msk, int indent)
 {
 	u_int i;
-	u_int32_t id;
+	uint32_t id;
 	char *ib = indent_pr(indent, 0);
 
-	if ((op_msk & B_APPND) && vflag >= 3) {
-		printf("%sTABLE APPEND\n", ib);
+	if ((op_msk & B_APPND) && ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "%sTABLE APPEND\n", ib));
 	}
 	for (i = 0; i < IDcnt; i++) {
-		TCHECK2(*pptr, 4);
+		ND_TCHECK2(*pptr, 4);
 		if (len < 4)
 			goto trunc;
 		id = EXTRACT_32BITS(pptr);
-		if (vflag >= 3)
-			printf("%sID#%02u: %d\n", ib, i + 1, id);
+		if (ndo->ndo_vflag >= 3)
+			ND_PRINT((ndo, "%sID#%02u: %d\n", ib, i + 1, id));
 		len -= 4;
 		pptr += 4;
 	}
 
 	if ((op_msk & B_TRNG) || (op_msk & B_KEYIN)) {
 		if (op_msk & B_TRNG) {
-			u_int32_t starti, endi;
+			uint32_t starti, endi;
 
 			if (len < PTH_DESC_SIZE) {
-				printf("pathlength %d with key/range too short %d\n",
-				       len, PTH_DESC_SIZE);
+				ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
+				       len, PTH_DESC_SIZE));
 				return -1;
 			}
 
@@ -887,17 +876,17 @@
 			pptr += 4;
 			len -= 4;
 
-			if (vflag >= 3)
-				printf("%sTable range: [%d,%d]\n", ib, starti, endi);
+			if (ndo->ndo_vflag >= 3)
+				ND_PRINT((ndo, "%sTable range: [%d,%d]\n", ib, starti, endi));
 		}
 
 		if (op_msk & B_KEYIN) {
 			struct forces_tlv *keytlv;
-			u_int16_t tll;
+			uint16_t tll;
 
 			if (len < PTH_DESC_SIZE) {
-				printf("pathlength %d with key/range too short %d\n",
-				       len, PTH_DESC_SIZE);
+				ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
+				       len, PTH_DESC_SIZE));
 				return -1;
 			}
 
@@ -911,13 +900,13 @@
 			/* skip key content */
 			tll = EXTRACT_16BITS(&keytlv->length);
 			if (tll < TLV_HDRL) {
-				printf("key content length %u < %u\n",
-					tll, TLV_HDRL);
+				ND_PRINT((ndo, "key content length %u < %u\n",
+					tll, TLV_HDRL));
 				return -1;
 			}
 			tll -= TLV_HDRL;
 			if (len < tll) {
-				printf("key content too short\n");
+				ND_PRINT((ndo, "key content too short\n"));
 				return -1;
 			}
 			pptr += tll;
@@ -928,20 +917,19 @@
 
 	if (len) {
 		const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
-		u_int16_t type;
-		u_int16_t tll;
+		uint16_t type;
+		uint16_t tll;
 		int pad = 0;
 		u_int aln;
-		int invtlv;
+		u_int invtlv;
 
-		TCHECK(*pdtlv);
+		ND_TCHECK(*pdtlv);
 		type = EXTRACT_16BITS(&pdtlv->type);
 		invtlv = tlv_valid(pdtlv, len);
 		if (invtlv) {
-			printf
-			    ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
-			     tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
-			     EXTRACT_16BITS(&pdtlv->length));
+			ND_PRINT((ndo, "%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
+			          tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
+			          EXTRACT_16BITS(&pdtlv->length)));
 			goto pd_err;
 		}
 		/*
@@ -953,9 +941,9 @@
 		aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length));
 		if (aln > EXTRACT_16BITS(&pdtlv->length)) {
 			if (aln > len) {
-				printf
-				    ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
-				     type, EXTRACT_16BITS(&pdtlv->length), aln - len);
+				ND_PRINT((ndo,
+				          "Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
+				          type, EXTRACT_16BITS(&pdtlv->length), aln - len));
 			} else {
 				pad = aln - EXTRACT_16BITS(&pdtlv->length);
 			}
@@ -963,34 +951,30 @@
 		if (pd_valid(type)) {
 			const struct pdata_ops *ops = get_forces_pd(type);
 
-			if (vflag >= 3 && ops->v != F_TLV_PDAT) {
+			if (ndo->ndo_vflag >= 3 && ops->v != F_TLV_PDAT) {
 				if (pad)
-					printf
-					    ("%s  %s (Length %d DataLen %d pad %d Bytes)\n",
-					     ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
-					     tll, pad);
+					ND_PRINT((ndo, "%s  %s (Length %d DataLen %d pad %d Bytes)\n",
+					          ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll, pad));
 				else
-					printf
-					    ("%s  %s (Length %d DataLen %d Bytes)\n",
-					     ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
-					     tll);
+					ND_PRINT((ndo, "%s  %s (Length %d DataLen %d Bytes)\n",
+					          ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll));
 			}
 
-			chk_op_type(type, op_msk, ops->op_msk);
+			chk_op_type(ndo, type, op_msk, ops->op_msk);
 
-			if (ops->print((const u_char *)pdtlv,
+			if (ops->print(ndo, (const u_char *)pdtlv,
 					tll + pad + TLV_HDRL, op_msk,
 					indent + 2) == -1)
 				return -1;
 			len -= (TLV_HDRL + pad + tll);
 		} else {
-			printf("Invalid path data content type 0x%x len %d\n",
-			       type, EXTRACT_16BITS(&pdtlv->length));
+			ND_PRINT((ndo, "Invalid path data content type 0x%x len %d\n",
+			       type, EXTRACT_16BITS(&pdtlv->length)));
 pd_err:
 			if (EXTRACT_16BITS(&pdtlv->length)) {
-				hex_print_with_offset("Bad Data val\n\t  [",
+                                hex_print_with_offset(ndo, "Bad Data val\n\t  [",
 						      pptr, len, 0);
-				printf("]\n");
+				ND_PRINT((ndo, "]\n"));
 
 				return -1;
 			}
@@ -999,26 +983,27 @@
 	return len;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-pdata_print(register const u_char * pptr, register u_int len,
-	    u_int16_t op_msk, int indent)
+pdata_print(netdissect_options *ndo,
+            register const u_char * pptr, register u_int len,
+            uint16_t op_msk, int indent)
 {
 	const struct pathdata_h *pdh = (struct pathdata_h *)pptr;
 	char *ib = indent_pr(indent, 0);
 	u_int minsize = 0;
 	int more_pd = 0;
-	u_int16_t idcnt = 0;
+	uint16_t idcnt = 0;
 
-	TCHECK(*pdh);
+	ND_TCHECK(*pdh);
 	if (len < sizeof(struct pathdata_h))
 		goto trunc;
-	if (vflag >= 3) {
-		printf("\n%sPathdata: Flags 0x%x ID count %d\n",
-		       ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt));
+	if (ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "\n%sPathdata: Flags 0x%x ID count %d\n",
+		       ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt)));
 	}
 
 	if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) {
@@ -1039,49 +1024,50 @@
 	idcnt = EXTRACT_16BITS(&pdh->pIDcnt);
 	minsize = idcnt * 4;
 	if (len < minsize) {
-		printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
-		       len);
-		hex_print_with_offset("\t\t\tID Data[", pptr, len, 0);
-		printf("]\n");
+		ND_PRINT((ndo, "\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
+		       len));
+		hex_print_with_offset(ndo, "\t\t\tID Data[", pptr, len, 0);
+		ND_PRINT((ndo, "]\n"));
 		return -1;
 	}
 
 	if ((op_msk & B_TRNG) && (op_msk & B_KEYIN)) {
-		printf("\t\t\tIllegal to have both Table ranges and keys\n");
+		ND_PRINT((ndo, "\t\t\tIllegal to have both Table ranges and keys\n"));
 		return -1;
 	}
 
-	more_pd = pdatacnt_print(pptr, len, idcnt, op_msk, indent);
+	more_pd = pdatacnt_print(ndo, pptr, len, idcnt, op_msk, indent);
 	if (more_pd > 0) {
 		int consumed = len - more_pd;
 		pptr += consumed;
-		len = more_pd; 
+		len = more_pd;
 		/* XXX: Argh, recurse some more */
-		return recpdoptlv_print(pptr, len, op_msk, indent+1);
+		return recpdoptlv_print(ndo, pptr, len, op_msk, indent+1);
 	} else
 		return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-genoptlv_print(register const u_char * pptr, register u_int len,
-	       u_int16_t op_msk, int indent)
+genoptlv_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t op_msk, int indent)
 {
 	const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
-	u_int16_t type;
+	uint16_t type;
 	int tll;
-	int invtlv;
+	u_int invtlv;
 	char *ib = indent_pr(indent, 0);
 
-	TCHECK(*pdtlv);
+	ND_TCHECK(*pdtlv);
 	type = EXTRACT_16BITS(&pdtlv->type);
 	tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
 	invtlv = tlv_valid(pdtlv, len);
-	printf("genoptlvprint - %s TLV type 0x%x len %d\n",
-	       tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length));
+	ND_PRINT((ndo, "genoptlvprint - %s TLV type 0x%x len %d\n",
+	       tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length)));
 	if (!invtlv) {
 		/*
 		 * At this point, tlv_valid() has ensured that the TLV
@@ -1090,40 +1076,41 @@
 		 */
 		register const u_char *dp = (u_char *) TLV_DATA(pdtlv);
 		if (!ttlv_valid(type)) {
-			printf("%s TLV type 0x%x len %d\n",
+			ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
 			       tok2str(ForCES_TLV_err, NULL, invtlv), type,
-			       EXTRACT_16BITS(&pdtlv->length));
+			       EXTRACT_16BITS(&pdtlv->length)));
 			return -1;
 		}
-		if (vflag >= 3)
-			printf("%s%s, length %d (data length %d Bytes)",
+		if (ndo->ndo_vflag >= 3)
+			ND_PRINT((ndo, "%s%s, length %d (data length %d Bytes)",
 			       ib, tok2str(ForCES_TLV, NULL, type),
-			       EXTRACT_16BITS(&pdtlv->length), tll);
+			       EXTRACT_16BITS(&pdtlv->length), tll));
 
-		return pdata_print(dp, tll, op_msk, indent + 1);
+		return pdata_print(ndo, dp, tll, op_msk, indent + 1);
 	} else {
-		printf("\t\t\tInvalid ForCES TLV type=%x", type);
+		ND_PRINT((ndo, "\t\t\tInvalid ForCES TLV type=%x", type));
 		return -1;
 	}
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-recpdoptlv_print(register const u_char * pptr, register u_int len,
-		 u_int16_t op_msk, int indent)
+recpdoptlv_print(netdissect_options *ndo,
+                 register const u_char * pptr, register u_int len,
+                 uint16_t op_msk, int indent)
 {
 	const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
 	int tll;
-	int invtlv;
-	u_int16_t type;
+	u_int invtlv;
+	uint16_t type;
 	register const u_char *dp;
 	char *ib;
 
 	while (len != 0) {
-		TCHECK(*pdtlv);
+		ND_TCHECK(*pdtlv);
 		invtlv = tlv_valid(pdtlv, len);
 		if (invtlv) {
 			break;
@@ -1139,52 +1126,53 @@
 		dp = (u_char *) TLV_DATA(pdtlv);
 		tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
 
-		if (vflag >= 3)
-			printf
-			    ("%s%s, length %d (data encapsulated %d Bytes)",
-			     ib, tok2str(ForCES_TLV, NULL, type),
-			     EXTRACT_16BITS(&pdtlv->length),
-			     EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL);
+		if (ndo->ndo_vflag >= 3)
+			ND_PRINT((ndo, "%s%s, length %d (data encapsulated %d Bytes)",
+			          ib, tok2str(ForCES_TLV, NULL, type),
+			          EXTRACT_16BITS(&pdtlv->length),
+			          EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL));
 
-		if (pdata_print(dp, tll, op_msk, indent + 1) == -1)
+		if (pdata_print(ndo, dp, tll, op_msk, indent + 1) == -1)
 			return -1;
 		pdtlv = GO_NXT_TLV(pdtlv, len);
 	}
 
 	if (len) {
-		printf
-		    ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
-		     EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length));
+		ND_PRINT((ndo,
+		          "\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+		          EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length)));
 		return -1;
 	}
 
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-invoptlv_print(register const u_char * pptr, register u_int len,
-	       u_int16_t op_msk _U_, int indent)
+invoptlv_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t op_msk _U_, int indent)
 {
 	char *ib = indent_pr(indent, 1);
 
-	if (vflag >= 3) {
-		printf("%sData[", &ib[1]);
-		hex_print_with_offset(ib, pptr, len, 0);
-		printf("%s]\n", ib);
+	if (ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "%sData[", &ib[1]));
+		hex_print_with_offset(ndo, ib, pptr, len, 0);
+		ND_PRINT((ndo, "%s]\n", ib));
 	}
 	return -1;
 }
 
 static int
-otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
+otlv_print(netdissect_options *ndo,
+           const struct forces_tlv *otlv, uint16_t op_msk _U_, int indent)
 {
 	int rc = 0;
 	register const u_char *dp = (u_char *) TLV_DATA(otlv);
-	u_int16_t type;
+	uint16_t type;
 	int tll;
 	char *ib = indent_pr(indent, 0);
 	const struct optlv_h *ops;
@@ -1193,45 +1181,43 @@
 	 * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
 	 * >= TLV_HDRL.
 	 */
-	TCHECK(*otlv);
+	ND_TCHECK(*otlv);
 	type = EXTRACT_16BITS(&otlv->type);
 	tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
 	ops = get_forces_optlv_h(type);
-	if (vflag >= 3) {
-		printf("%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
-		       EXTRACT_16BITS(&otlv->length));
-	}
-	/* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
-	if (!ops->flags & ZERO_TTLV) {
-		if (tll != 0)	/* instead of "if (tll)" - for readability .. */
-			printf("%s: Illegal - MUST be empty\n", ops->s);
-		return rc;
+	if (ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
+		       EXTRACT_16BITS(&otlv->length)));
 	}
 	/* rest of ops must at least have 12B {pathinfo} */
 	if (tll < OP_MIN_SIZ) {
-		printf("\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
-		       EXTRACT_16BITS(&otlv->length));
-		printf("\t\tTruncated data size %d minimum required %d\n", tll,
-		       OP_MIN_SIZ);
-		return invoptlv_print(dp, tll, ops->op_msk, indent);
+		ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
+		       EXTRACT_16BITS(&otlv->length)));
+		ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll,
+		       OP_MIN_SIZ));
+		return invoptlv_print(ndo, dp, tll, ops->op_msk, indent);
 
 	}
 
-	rc = ops->print(dp, tll, ops->op_msk, indent + 1);
+	/* XXX - do anything with ops->flags? */
+        if(ops->print) {
+                rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
+        }
 	return rc;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 #define ASTDLN	4
 #define ASTMCD	255
 static int
-asttlv_print(register const u_char * pptr, register u_int len,
-	     u_int16_t op_msk _U_, int indent)
+asttlv_print(netdissect_options *ndo,
+             register const u_char * pptr, register u_int len,
+             uint16_t op_msk _U_, int indent)
 {
-	u_int32_t rescode;
+	uint32_t rescode;
 	u_int dlen;
 	char *ib = indent_pr(indent, 0);
 
@@ -1241,54 +1227,55 @@
 	 */
 	dlen = len - TLV_HDRL;
 	if (dlen != ASTDLN) {
-		printf("illegal ASTresult-TLV: %d bytes!\n", dlen);
+		ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen));
 		return -1;
 	}
-	TCHECK2(*pptr, 4);
+	ND_TCHECK2(*pptr, 4);
 	rescode = EXTRACT_32BITS(pptr);
 	if (rescode > ASTMCD) {
-		printf("illegal ASTresult result code: %d!\n", rescode);
+		ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode));
 		return -1;
 	}
 
-	if (vflag >= 3) {
-		printf("Teardown reason:\n%s", ib);
+	if (ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "Teardown reason:\n%s", ib));
 		switch (rescode) {
 		case 0:
-			printf("Normal Teardown");
+			ND_PRINT((ndo, "Normal Teardown"));
 			break;
 		case 1:
-			printf("Loss of Heartbeats");
+			ND_PRINT((ndo, "Loss of Heartbeats"));
 			break;
 		case 2:
-			printf("Out of bandwidth");
+			ND_PRINT((ndo, "Out of bandwidth"));
 			break;
 		case 3:
-			printf("Out of Memory");
+			ND_PRINT((ndo, "Out of Memory"));
 			break;
 		case 4:
-			printf("Application Crash");
+			ND_PRINT((ndo, "Application Crash"));
 			break;
 		default:
-			printf("Unknown Teardown reason");
+			ND_PRINT((ndo, "Unknown Teardown reason"));
 			break;
 		}
-		printf("(%x)\n%s", rescode, ib);
+		ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
 	}
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 #define ASRDLN	4
 #define ASRMCD	3
 static int
-asrtlv_print(register const u_char * pptr, register u_int len,
-	     u_int16_t op_msk _U_, int indent)
+asrtlv_print(netdissect_options *ndo,
+             register const u_char * pptr, register u_int len,
+             uint16_t op_msk _U_, int indent)
 {
-	u_int32_t rescode;
+	uint32_t rescode;
 	u_int dlen;
 	char *ib = indent_pr(indent, 0);
 
@@ -1298,39 +1285,39 @@
 	 */
 	dlen = len - TLV_HDRL;
 	if (dlen != ASRDLN) {	/* id, instance, oper tlv */
-		printf("illegal ASRresult-TLV: %d bytes!\n", dlen);
+		ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen));
 		return -1;
 	}
-	TCHECK2(*pptr, 4);
+	ND_TCHECK2(*pptr, 4);
 	rescode = EXTRACT_32BITS(pptr);
 
 	if (rescode > ASRMCD) {
-		printf("illegal ASRresult result code: %d!\n", rescode);
+		ND_PRINT((ndo, "illegal ASRresult result code: %d!\n", rescode));
 		return -1;
 	}
 
-	if (vflag >= 3) {
-		printf("\n%s", ib);
+	if (ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "\n%s", ib));
 		switch (rescode) {
 		case 0:
-			printf("Success ");
+			ND_PRINT((ndo, "Success "));
 			break;
 		case 1:
-			printf("FE ID invalid ");
+			ND_PRINT((ndo, "FE ID invalid "));
 			break;
 		case 2:
-			printf("permission denied ");
+			ND_PRINT((ndo, "permission denied "));
 			break;
 		default:
-			printf("Unknown ");
+			ND_PRINT((ndo, "Unknown "));
 			break;
 		}
-		printf("(%x)\n%s", rescode, ib);
+		ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
 	}
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
@@ -1339,13 +1326,14 @@
  * XXX - not used.
  */
 static int
-gentltlv_print(register const u_char * pptr _U_, register u_int len,
-	       u_int16_t op_msk _U_, int indent _U_)
+gentltlv_print(netdissect_options *ndo,
+               register const u_char * pptr _U_, register u_int len,
+               uint16_t op_msk _U_, int indent _U_)
 {
 	u_int dlen = len - TLV_HDRL;
 
 	if (dlen < 4) {		/* at least 32 bits must exist */
-		printf("truncated TLV: %d bytes missing! ", 4 - dlen);
+		ND_PRINT((ndo, "truncated TLV: %d bytes missing! ", 4 - dlen));
 		return -1;
 	}
 	return 0;
@@ -1355,11 +1343,10 @@
 #define RD_MIN 8
 
 static int
-print_metailv(register const u_char * pptr, register u_int len,
-	      u_int16_t op_msk _U_, int indent)
+print_metailv(netdissect_options *ndo,
+              register const u_char * pptr, uint16_t op_msk _U_, int indent)
 {
 	u_int rlen;
-	u_int plen;
 	char *ib = indent_pr(indent, 0);
 	/* XXX: check header length */
 	const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
@@ -1369,23 +1356,24 @@
 	 * ILV) >= ILV_HDRL.
 	 */
 	rlen = EXTRACT_32BITS(&ilv->length) - ILV_HDRL;
-	TCHECK(*ilv);
-	printf("%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
-	       EXTRACT_32BITS(&ilv->length));
-	if (vflag >= 3) {
-		hex_print_with_offset("\t\t[", ILV_DATA(ilv), rlen, 0);
-		printf(" ]\n");
+	ND_TCHECK(*ilv);
+	ND_PRINT((ndo, "%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
+	       EXTRACT_32BITS(&ilv->length)));
+	if (ndo->ndo_vflag >= 3) {
+		hex_print_with_offset(ndo, "\t\t[", ILV_DATA(ilv), rlen, 0);
+		ND_PRINT((ndo, " ]\n"));
 	}
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-print_metatlv(register const u_char * pptr, register u_int len,
-	      u_int16_t op_msk _U_, int indent)
+print_metatlv(netdissect_options *ndo,
+              register const u_char * pptr, register u_int len,
+              uint16_t op_msk _U_, int indent)
 {
 	u_int dlen;
 	char *ib = indent_pr(indent, 0);
@@ -1399,9 +1387,9 @@
 	 */
 	dlen = len - TLV_HDRL;
 	rlen = dlen;
-	printf("\n%s METADATA length %d \n", ib, rlen);
+	ND_PRINT((ndo, "\n%s METADATA length %d \n", ib, rlen));
 	while (rlen != 0) {
-		TCHECK(*ilv);
+		ND_TCHECK(*ilv);
 		invilv = ilv_valid(ilv, rlen);
 		if (invilv) {
 			break;
@@ -1412,21 +1400,22 @@
 		 * length is large enough but not too large (it doesn't
 		 * go past the end of the containing TLV).
 		 */
-		print_metailv((u_char *) ilv, rlen, 0, indent + 1);
+		print_metailv(ndo, (u_char *) ilv, 0, indent + 1);
 		ilv = GO_NXT_ILV(ilv, rlen);
 	}
 
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 
 static int
-print_reddata(register const u_char * pptr, register u_int len,
-	      u_int16_t op_msk _U_, int indent _U_)
+print_reddata(netdissect_options *ndo,
+              register const u_char * pptr, register u_int len,
+              uint16_t op_msk _U_, int indent _U_)
 {
 	u_int dlen;
 	char *ib = indent_pr(indent, 0);
@@ -1434,25 +1423,26 @@
 
 	dlen = len - TLV_HDRL;
 	rlen = dlen;
-	printf("\n%s Redirect Data length %d \n", ib, rlen);
+	ND_PRINT((ndo, "\n%s Redirect Data length %d \n", ib, rlen));
 
-	if (vflag >= 3) {
-		printf("\t\t[");
-		hex_print_with_offset("\n\t\t", pptr, rlen, 0);
-		printf("\n\t\t]");
+	if (ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "\t\t["));
+		hex_print_with_offset(ndo, "\n\t\t", pptr, rlen, 0);
+		ND_PRINT((ndo, "\n\t\t]"));
 	}
 
 	return 0;
 }
 
 static int
-redirect_print(register const u_char * pptr, register u_int len,
-	       u_int16_t op_msk _U_, int indent)
+redirect_print(netdissect_options *ndo,
+               register const u_char * pptr, register u_int len,
+               uint16_t op_msk _U_, int indent)
 {
 	const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
 	u_int dlen;
 	u_int rlen;
-	int invtlv;
+	u_int invtlv;
 
 	/*
 	 * forces_type_print() has ensured that len (the TLV length)
@@ -1460,18 +1450,18 @@
 	 */
 	dlen = len - TLV_HDRL;
 	if (dlen <= RD_MIN) {
-		printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
-		       RD_MIN - dlen);
+		ND_PRINT((ndo, "\n\t\ttruncated Redirect TLV: %d bytes missing! ",
+		       RD_MIN - dlen));
 		return -1;
 	}
 
 	rlen = dlen;
 	indent += 1;
 	while (rlen != 0) {
-		TCHECK(*tlv);
+		ND_TCHECK(*tlv);
 		invtlv = tlv_valid(tlv, rlen);
 		if (invtlv) {
-			printf("Bad Redirect data\n");
+			ND_PRINT((ndo, "Bad Redirect data\n"));
 			break;
 		}
 
@@ -1481,32 +1471,32 @@
 		 * go past the end of the containing TLV).
 		 */
 		if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) {
-			print_metatlv((u_char *) TLV_DATA(tlv),
+			print_metatlv(ndo, (u_char *) TLV_DATA(tlv),
 				      EXTRACT_16BITS(&tlv->length), 0, indent);
 		} else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) {
-			print_reddata((u_char *) TLV_DATA(tlv),
+			print_reddata(ndo, (u_char *) TLV_DATA(tlv),
 				      EXTRACT_16BITS(&tlv->length), 0, indent);
 		} else {
-			printf("Unknown REDIRECT TLV 0x%x len %d\n",
+			ND_PRINT((ndo, "Unknown REDIRECT TLV 0x%x len %d\n",
 			       EXTRACT_16BITS(&tlv->type),
-			       EXTRACT_16BITS(&tlv->length));
+			       EXTRACT_16BITS(&tlv->length)));
 		}
 
 		tlv = GO_NXT_TLV(tlv, rlen);
 	}
 
 	if (rlen) {
-		printf
-		    ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
-		     EXTRACT_16BITS(&tlv->type),
-		     rlen - EXTRACT_16BITS(&tlv->length));
+		ND_PRINT((ndo,
+		          "\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+		          EXTRACT_16BITS(&tlv->type),
+		          rlen - EXTRACT_16BITS(&tlv->length)));
 		return -1;
 	}
 
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
@@ -1514,15 +1504,16 @@
 #define OP_MIN 12
 
 static int
-lfbselect_print(register const u_char * pptr, register u_int len,
-		u_int16_t op_msk, int indent)
+lfbselect_print(netdissect_options *ndo,
+                register const u_char * pptr, register u_int len,
+                uint16_t op_msk, int indent)
 {
 	const struct forces_lfbsh *lfbs;
 	const struct forces_tlv *otlv;
 	char *ib = indent_pr(indent, 0);
 	u_int dlen;
 	u_int rlen;
-	int invtlv;
+	u_int invtlv;
 
 	/*
 	 * forces_type_print() has ensured that len (the TLV length)
@@ -1530,8 +1521,8 @@
 	 */
 	dlen = len - TLV_HDRL;
 	if (dlen <= OP_MIN) {	/* id, instance, oper tlv header .. */
-		printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
-		       OP_MIN - dlen);
+		ND_PRINT((ndo, "\n\t\ttruncated lfb selector: %d bytes missing! ",
+		       OP_MIN - dlen));
 		return -1;
 	}
 
@@ -1542,19 +1533,19 @@
 	rlen = dlen - OP_OFF;
 
 	lfbs = (const struct forces_lfbsh *)pptr;
-	TCHECK(*lfbs);
-	if (vflag >= 3) {
-		printf("\n%s%s(Classid %x) instance %x\n",
+	ND_TCHECK(*lfbs);
+	if (ndo->ndo_vflag >= 3) {
+		ND_PRINT((ndo, "\n%s%s(Classid %x) instance %x\n",
 		       ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)),
 		       EXTRACT_32BITS(&lfbs->class),
-		       EXTRACT_32BITS(&lfbs->instance));
+		       EXTRACT_32BITS(&lfbs->instance)));
 	}
 
 	otlv = (struct forces_tlv *)(lfbs + 1);
 
 	indent += 1;
 	while (rlen != 0) {
-		TCHECK(*otlv);
+		ND_TCHECK(*otlv);
 		invtlv = tlv_valid(otlv, rlen);
 		if (invtlv)
 			break;
@@ -1565,39 +1556,40 @@
 		 * go past the end of the containing TLV).
 		 */
 		if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) {
-			otlv_print(otlv, 0, indent);
+			otlv_print(ndo, otlv, 0, indent);
 		} else {
-			if (vflag < 3)
-				printf("\n");
-			printf
-			    ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
-			     EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length));
-			invoptlv_print((u_char *)otlv, rlen, 0, indent);
+			if (ndo->ndo_vflag < 3)
+				ND_PRINT((ndo, "\n"));
+			ND_PRINT((ndo,
+			          "\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
+			          EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length)));
+			invoptlv_print(ndo, (u_char *)otlv, rlen, 0, indent);
 		}
 		otlv = GO_NXT_TLV(otlv, rlen);
 	}
 
 	if (rlen) {
-		printf
-		    ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
-		     EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length));
+		ND_PRINT((ndo,
+		          "\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+		          EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length)));
 		return -1;
 	}
 
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 static int
-forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
-		  register u_int mlen, const struct tom_h *tops)
+forces_type_print(netdissect_options *ndo,
+                  register const u_char * pptr, const struct forcesh *fhdr _U_,
+                  register u_int mlen, const struct tom_h *tops)
 {
 	const struct forces_tlv *tltlv;
 	u_int rlen;
-	int invtlv;
+	u_int invtlv;
 	int rc = 0;
 	int ttlv = 0;
 
@@ -1609,14 +1601,14 @@
 
 	if (rlen > TLV_HLN) {
 		if (tops->flags & ZERO_TTLV) {
-			printf("<0x%x>Illegal Top level TLV!\n", tops->flags);
+			ND_PRINT((ndo, "<0x%x>Illegal Top level TLV!\n", tops->flags));
 			return -1;
 		}
 	} else {
 		if (tops->flags & ZERO_MORE_TTLV)
 			return 0;
 		if (tops->flags & ONE_MORE_TTLV) {
-			printf("\tTop level TLV Data missing!\n");
+			ND_PRINT((ndo, "\tTop level TLV Data missing!\n"));
 			return -1;
 		}
 	}
@@ -1631,7 +1623,7 @@
 	/*XXX: 15 top level tlvs will probably be fine
 	   You are nuts if you send more ;-> */
 	while (rlen != 0) {
-		TCHECK(*tltlv);
+		ND_TCHECK(*tltlv);
 		invtlv = tlv_valid(tltlv, rlen);
 		if (invtlv)
 			break;
@@ -1642,18 +1634,18 @@
 		 * go past the end of the packet).
 		 */
 		if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) {
-			printf("\n\tInvalid ForCES Top TLV type=0x%x",
-			       EXTRACT_16BITS(&tltlv->type));
+			ND_PRINT((ndo, "\n\tInvalid ForCES Top TLV type=0x%x",
+			       EXTRACT_16BITS(&tltlv->type)));
 			return -1;
 		}
 
-		if (vflag >= 3)
-			printf("\t%s, length %d (data length %d Bytes)",
+		if (ndo->ndo_vflag >= 3)
+			ND_PRINT((ndo, "\t%s, length %d (data length %d Bytes)",
 			       tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)),
 			       EXTRACT_16BITS(&tltlv->length),
-			       EXTRACT_16BITS(&tltlv->length) - TLV_HDRL);
+			       EXTRACT_16BITS(&tltlv->length) - TLV_HDRL));
 
-		rc = tops->print((u_char *) TLV_DATA(tltlv),
+		rc = tops->print(ndo, (u_char *) TLV_DATA(tltlv),
 				 EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9);
 		if (rc < 0) {
 			return -1;
@@ -1668,31 +1660,32 @@
 	 * short, and didn't have *enough* TLVs in it?
 	 */
 	if (rlen) {
-		printf("\tMess TopTLV header: min %u, total %d advertised %d ",
-		       TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length));
+		ND_PRINT((ndo, "\tMess TopTLV header: min %u, total %d advertised %d ",
+		       TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length)));
 		return -1;
 	}
 
 	return 0;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
 void
-forces_print(register const u_char * pptr, register u_int len)
+forces_print(netdissect_options *ndo,
+             register const u_char * pptr, register u_int len)
 {
 	const struct forcesh *fhdr;
 	u_int mlen;
-	u_int32_t flg_raw;
+	uint32_t flg_raw;
 	const struct tom_h *tops;
 	int rc = 0;
 
 	fhdr = (const struct forcesh *)pptr;
-	TCHECK(*fhdr);
+	ND_TCHECK(*fhdr);
 	if (!tom_valid(fhdr->fm_tom)) {
-		printf("Invalid ForCES message type %d\n", fhdr->fm_tom);
+		ND_PRINT((ndo, "Invalid ForCES message type %d\n", fhdr->fm_tom));
 		goto error;
 	}
 
@@ -1700,57 +1693,68 @@
 
 	tops = get_forces_tom(fhdr->fm_tom);
 	if (tops->v == TOM_RSVD) {
-		printf("\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom);
+		ND_PRINT((ndo, "\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom));
 		goto error;
 	}
 
-	printf("\n\tForCES %s ", tops->s);
+	ND_PRINT((ndo, "\n\tForCES %s ", tops->s));
 	if (!ForCES_HLN_VALID(mlen, len)) {
-		printf
-		    ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
-		     ForCES_HDRL, len, ForCES_BLN(fhdr));
+		ND_PRINT((ndo,
+		          "Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
+		          ForCES_HDRL, len, ForCES_BLN(fhdr)));
 		goto error;
 	}
 
-	TCHECK2(*(pptr + 20), 4);
+	ND_TCHECK2(*(pptr + 20), 4);
 	flg_raw = EXTRACT_32BITS(pptr + 20);
-	if (vflag >= 1) {
-		printf("\n\tForCES Version %d len %uB flags 0x%08x ",
-		       ForCES_V(fhdr), mlen, flg_raw);
-		printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
+	if (ndo->ndo_vflag >= 1) {
+		ND_PRINT((ndo, "\n\tForCES Version %d len %uB flags 0x%08x ",
+		       ForCES_V(fhdr), mlen, flg_raw));
+		ND_PRINT((ndo,
+		       "\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
 		       ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)),
 		       ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)),
-		       EXTRACT_64BITS(fhdr->fm_cor));
+		       EXTRACT_64BITS(fhdr->fm_cor)));
 
 	}
-	if (vflag >= 2) {
-		printf
-		    ("\n\tForCES flags:\n\t  %s(0x%x), prio=%d, %s(0x%x),\n\t  %s(0x%x), %s(0x%x)\n",
-		     ForCES_ACKp(ForCES_ACK(fhdr)), ForCES_ACK(fhdr),
+	if (ndo->ndo_vflag >= 2) {
+		ND_PRINT((ndo,
+		     "\n\tForCES flags:\n\t  %s(0x%x), prio=%d, %s(0x%x),\n\t  %s(0x%x), %s(0x%x)\n",
+		     tok2str(ForCES_ACKs, "ACKUnknown", ForCES_ACK(fhdr)),
+		     ForCES_ACK(fhdr),
 		     ForCES_PRI(fhdr),
-		     ForCES_EMp(ForCES_EM(fhdr)), ForCES_EM(fhdr),
-		     ForCES_ATp(ForCES_AT(fhdr)), ForCES_AT(fhdr),
-		     ForCES_TPp(ForCES_TP(fhdr)), ForCES_TP(fhdr));
-		printf
-		    ("\t  Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
-		     ForCES_RS1(fhdr), ForCES_RS2(fhdr));
+		     tok2str(ForCES_EMs, "EMUnknown", ForCES_EM(fhdr)),
+		     ForCES_EM(fhdr),
+		     tok2str(ForCES_ATs, "ATUnknown", ForCES_AT(fhdr)),
+		     ForCES_AT(fhdr),
+		     tok2str(ForCES_TPs, "TPUnknown", ForCES_TP(fhdr)),
+		     ForCES_TP(fhdr)));
+		ND_PRINT((ndo,
+		     "\t  Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
+		     ForCES_RS1(fhdr), ForCES_RS2(fhdr)));
 	}
-	rc = forces_type_print(pptr, fhdr, mlen, tops);
+	rc = forces_type_print(ndo, pptr, fhdr, mlen, tops);
 	if (rc < 0) {
 error:
-		hex_print_with_offset("\n\t[", pptr, len, 0);
-		printf("\n\t]");
+		hex_print_with_offset(ndo, "\n\t[", pptr, len, 0);
+		ND_PRINT((ndo, "\n\t]"));
 		return;
 	}
 
-	if (vflag >= 4) {
-		printf("\n\t  Raw ForCES message\n\t [");
-		hex_print_with_offset("\n\t ", pptr, len, 0);
-		printf("\n\t ]");
+	if (ndo->ndo_vflag >= 4) {
+		ND_PRINT((ndo, "\n\t  Raw ForCES message\n\t ["));
+		hex_print_with_offset(ndo, "\n\t ", pptr, len, 0);
+		ND_PRINT((ndo, "\n\t ]"));
 	}
-	printf("\n");
+	ND_PRINT((ndo, "\n"));
 	return;
 
 trunc:
-	fputs("[|forces]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-fr.c b/print-fr.c
index 9fb763c..0832522 100644
--- a/print-fr.c
+++ b/print-fr.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-	"@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -32,16 +28,16 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <pcap.h>
 
-#include "addrtoname.h"
 #include "interface.h"
+#include "addrtoname.h"
 #include "ethertype.h"
+#include "llc.h"
 #include "nlpid.h"
 #include "extract.h"
 #include "oui.h"
 
-static void frf15_print(const u_char *, u_int);
+static void frf15_print(netdissect_options *ndo, const u_char *, u_int);
 
 /*
  * the frame relay header has a variable length
@@ -97,15 +93,21 @@
     { 0, NULL }
 };
 
-/* Finds out Q.922 address length, DLCI and flags. Returns 0 on success
+/* Finds out Q.922 address length, DLCI and flags. Returns 1 on success,
+ * 0 on invalid address, -1 on truncated packet
  * save the flags dep. on address length
  */
-static int parse_q922_addr(const u_char *p, u_int *dlci,
-                           u_int *addr_len, u_int8_t *flags)
+static int parse_q922_addr(netdissect_options *ndo,
+                           const u_char *p, u_int *dlci,
+                           u_int *addr_len, uint8_t *flags, u_int length)
 {
-	if ((p[0] & FR_EA_BIT))
+	if (!ND_TTEST(p[0]) || length < 1)
 		return -1;
+	if ((p[0] & FR_EA_BIT))
+		return 0;
 
+	if (!ND_TTEST(p[1]) || length < 2)
+		return -1;
 	*addr_len = 2;
 	*dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4);
 
@@ -115,34 +117,42 @@
         flags[3] = 0;
 
 	if (p[1] & FR_EA_BIT)
-		return 0;	/* 2-byte Q.922 address */
+		return 1;	/* 2-byte Q.922 address */
 
 	p += 2;
+	length -= 2;
+	if (!ND_TTEST(p[0]) || length < 1)
+		return -1;
 	(*addr_len)++;		/* 3- or 4-byte Q.922 address */
 	if ((p[0] & FR_EA_BIT) == 0) {
 		*dlci = (*dlci << 7) | (p[0] >> 1);
 		(*addr_len)++;	/* 4-byte Q.922 address */
 		p++;
+		length--;
 	}
 
+	if (!ND_TTEST(p[0]) || length < 1)
+		return -1;
 	if ((p[0] & FR_EA_BIT) == 0)
-		return -1; /* more than 4 bytes of Q.922 address? */
+		return 0; /* more than 4 bytes of Q.922 address? */
 
         flags[3] = p[0] & 0x02;
 
         *dlci = (*dlci << 6) | (p[0] >> 2);
 
-	return 0;
+	return 1;
 }
 
-char *q922_string(const u_char *p) {
+char *
+q922_string(netdissect_options *ndo, const u_char *p, u_int length)
+{
 
     static u_int dlci, addr_len;
-    static u_int8_t flags[4];
+    static uint8_t flags[4];
     static char buffer[sizeof("DLCI xxxxxxxxxx")];
     memset(buffer, 0, sizeof(buffer));
 
-    if (parse_q922_addr(p, &dlci, &addr_len, flags) == 0){
+    if (parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length) == 1){
         snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
     }
 
@@ -176,178 +186,204 @@
              may optionally be increased to three or four octets.
 */
 
-static u_int
-fr_hdrlen(const u_char *p, u_int addr_len)
-{
-	if (!p[addr_len + 1] /* pad exist */)
-		return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
-	else 
-		return addr_len + 1 /* UI */ + 1 /* NLPID */;
-}
-
 static void
-fr_hdr_print(int length, u_int addr_len, u_int dlci, u_int8_t *flags, u_int16_t nlpid)
+fr_hdr_print(netdissect_options *ndo,
+             int length, u_int addr_len, u_int dlci, uint8_t *flags, uint16_t nlpid)
 {
-    if (qflag) {
-        (void)printf("Q.922, DLCI %u, length %u: ",
+    if (ndo->ndo_qflag) {
+        ND_PRINT((ndo, "Q.922, DLCI %u, length %u: ",
                      dlci,
-                     length);
+                     length));
     } else {
         if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */
-            (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
+            ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
                          addr_len,
                          dlci,
                          bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
                          tok2str(nlpid_values,"unknown", nlpid),
                          nlpid,
-                         length);
+                         length));
         else /* must be an ethertype */
-            (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
+            ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
                          addr_len,
                          dlci,
                          bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
                          tok2str(ethertype_values, "unknown", nlpid),
                          nlpid,
-                         length);        
+                         length));
     }
 }
 
 u_int
-fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+fr_if_print(netdissect_options *ndo,
+            const struct pcap_pkthdr *h, register const u_char *p)
 {
 	register u_int length = h->len;
 	register u_int caplen = h->caplen;
 
-        TCHECK2(*p, 4); /* minimum frame header length */
+        ND_TCHECK2(*p, 4); /* minimum frame header length */
 
-        if ((length = fr_print(p, length)) == 0)
+        if ((length = fr_print(ndo, p, length)) == 0)
             return (0);
         else
             return length;
  trunc:
-        printf("[|fr]");
+        ND_PRINT((ndo, "[|fr]"));
         return caplen;
 }
 
 u_int
-fr_print(register const u_char *p, u_int length)
+fr_print(netdissect_options *ndo,
+         register const u_char *p, u_int length)
 {
-	u_int16_t extracted_ethertype;
+	int ret;
+	uint16_t extracted_ethertype;
 	u_int dlci;
 	u_int addr_len;
-	u_int16_t nlpid;
+	uint16_t nlpid;
 	u_int hdr_len;
-	u_int8_t flags[4];
+	uint8_t flags[4];
 
-	if (parse_q922_addr(p, &dlci, &addr_len, flags)) {
-		printf("Q.922, invalid address");
+	ret = parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length);
+	if (ret == -1)
+		goto trunc;
+	if (ret == 0) {
+		ND_PRINT((ndo, "Q.922, invalid address"));
 		return 0;
 	}
 
-        TCHECK2(*p,addr_len+1+1);
-	hdr_len = fr_hdrlen(p, addr_len);
-        TCHECK2(*p,hdr_len);
+	ND_TCHECK(p[addr_len]);
+	if (length < addr_len + 1)
+		goto trunc;
 
-	if (p[addr_len] != 0x03 && dlci != 0) {
+	if (p[addr_len] != LLC_UI && dlci != 0) {
+                /*
+                 * Let's figure out if we have Cisco-style encapsulation,
+                 * with an Ethernet type (Cisco HDLC type?) following the
+                 * address.
+                 */
+		if (!ND_TTEST2(p[addr_len], 2) || length < addr_len + 2) {
+                        /* no Ethertype */
+                        ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+                } else {
+                        extracted_ethertype = EXTRACT_16BITS(p+addr_len);
 
-                /* lets figure out if we have cisco style encapsulation: */
-                extracted_ethertype = EXTRACT_16BITS(p+addr_len);
+                        if (ndo->ndo_eflag)
+                                fr_hdr_print(ndo, length, addr_len, dlci,
+                                    flags, extracted_ethertype);
 
-                if (eflag)
-                    fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
-
-                if (ethertype_print(gndo, extracted_ethertype,
-                                      p+addr_len+ETHERTYPE_LEN,
-                                      length-addr_len-ETHERTYPE_LEN,
-                                      length-addr_len-ETHERTYPE_LEN) == 0)
-                    /* ether_type not known, probably it wasn't one */
-                    printf("UI %02x! ", p[addr_len]);
-                else
-                    return hdr_len;
+                        if (ethertype_print(ndo, extracted_ethertype,
+                                            p+addr_len+ETHERTYPE_LEN,
+                                            length-addr_len-ETHERTYPE_LEN,
+                                            length-addr_len-ETHERTYPE_LEN) == 0)
+                                /* ether_type not known, probably it wasn't one */
+                                ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+                        else
+                                return addr_len + 2;
+                }
         }
 
-	if (!p[addr_len + 1]) {	/* pad byte should be used with 3-byte Q.922 */
-		if (addr_len != 3)
-			printf("Pad! ");
-	} else if (addr_len == 3)
-		printf("No pad! ");
+	ND_TCHECK(p[addr_len+1]);
+	if (length < addr_len + 2)
+		goto trunc;
 
+	if (p[addr_len + 1] == 0) {
+		/*
+		 * Assume a pad byte after the control (UI) byte.
+		 * A pad byte should only be used with 3-byte Q.922.
+		 */
+		if (addr_len != 3)
+			ND_PRINT((ndo, "Pad! "));
+		hdr_len = addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
+	} else {
+		/*
+		 * Not a pad byte.
+		 * A pad byte should be used with 3-byte Q.922.
+		 */
+		if (addr_len == 3)
+			ND_PRINT((ndo, "No pad! "));
+		hdr_len = addr_len + 1 /* UI */ + 1 /* NLPID */;
+	}
+
+        ND_TCHECK(p[hdr_len - 1]);
+	if (length < hdr_len)
+		goto trunc;
 	nlpid = p[hdr_len - 1];
 
-	if (eflag)
-		fr_hdr_print(length, addr_len, dlci, flags, nlpid);
+	if (ndo->ndo_eflag)
+		fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid);
 	p += hdr_len;
 	length -= hdr_len;
 
 	switch (nlpid) {
 	case NLPID_IP:
-	        ip_print(gndo, p, length);
+	        ip_print(ndo, p, length);
 		break;
 
-#ifdef INET6
 	case NLPID_IP6:
-		ip6_print(gndo, p, length);
+		ip6_print(ndo, p, length);
 		break;
-#endif
+
 	case NLPID_CLNP:
 	case NLPID_ESIS:
 	case NLPID_ISIS:
-                isoclns_print(p-1, length+1, length+1); /* OSI printers need the NLPID field */
+		isoclns_print(ndo, p - 1, length + 1, length + 1); /* OSI printers need the NLPID field */
 		break;
 
 	case NLPID_SNAP:
-		if (snap_print(p, length, length, 0) == 0) {
+		if (snap_print(ndo, p, length, length, 0) == 0) {
 			/* ether_type not known, print raw packet */
-                        if (!eflag)
-                            fr_hdr_print(length + hdr_len, hdr_len,
+                        if (!ndo->ndo_eflag)
+                            fr_hdr_print(ndo, length + hdr_len, hdr_len,
                                          dlci, flags, nlpid);
-			if (!suppress_default_print)
-                            default_print(p - hdr_len, length + hdr_len);
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p - hdr_len, length + hdr_len);
 		}
 		break;
 
         case NLPID_Q933:
-		q933_print(p, length);
+		q933_print(ndo, p, length);
 		break;
 
         case NLPID_MFR:
-                frf15_print(p, length);
+                frf15_print(ndo, p, length);
                 break;
 
         case NLPID_PPP:
-                ppp_print(p, length);
+                ppp_print(ndo, p, length);
                 break;
 
 	default:
-		if (!eflag)
-                    fr_hdr_print(length + hdr_len, addr_len,
+		if (!ndo->ndo_eflag)
+                    fr_hdr_print(ndo, length + hdr_len, addr_len,
 				     dlci, flags, nlpid);
-		if (!xflag)
-			default_print(p, length);
+		if (!ndo->ndo_xflag)
+			ND_DEFAULTPRINT(p, length);
 	}
 
 	return hdr_len;
 
  trunc:
-        printf("[|fr]");
+        ND_PRINT((ndo, "[|fr]"));
         return 0;
 
 }
 
 u_int
-mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+mfr_if_print(netdissect_options *ndo,
+             const struct pcap_pkthdr *h, register const u_char *p)
 {
 	register u_int length = h->len;
 	register u_int caplen = h->caplen;
 
-        TCHECK2(*p, 2); /* minimum frame header length */
+        ND_TCHECK2(*p, 2); /* minimum frame header length */
 
-        if ((length = mfr_print(p, length)) == 0)
+        if ((length = mfr_print(ndo, p, length)) == 0)
             return (0);
         else
             return length;
  trunc:
-        printf("[|mfr]");
+        ND_PRINT((ndo, "[|mfr]"));
         return caplen;
 }
 
@@ -391,22 +427,23 @@
 #define MFR_ID_STRING_MAXLEN 50
 
 struct ie_tlv_header_t {
-    u_int8_t ie_type;
-    u_int8_t ie_len;
+    uint8_t ie_type;
+    uint8_t ie_len;
 };
 
 u_int
-mfr_print(register const u_char *p, u_int length)
+mfr_print(netdissect_options *ndo,
+          register const u_char *p, u_int length)
 {
     u_int tlen,idx,hdr_len = 0;
-    u_int16_t sequence_num;
-    u_int8_t ie_type,ie_len;
-    const u_int8_t *tptr;
+    uint16_t sequence_num;
+    uint8_t ie_type,ie_len;
+    const uint8_t *tptr;
 
 
 /*
  * FRF.16 Link Integrity Control Frame
- * 
+ *
  *      7    6    5    4    3    2    1    0
  *    +----+----+----+----+----+----+----+----+
  *    | B  | E  | C=1| 0    0    0    0  | EA |
@@ -417,35 +454,35 @@
  *    +----+----+----+----+----+----+----+----+
  */
 
-    TCHECK2(*p, 4); /* minimum frame header length */
+    ND_TCHECK2(*p, 4); /* minimum frame header length */
 
     if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) {
-        printf("FRF.16 Control, Flags [%s], %s, length %u",
+        ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u",
                bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)),
                tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]),
-               length);
+               length));
         tptr = p + 3;
         tlen = length -3;
         hdr_len = 3;
 
-        if (!vflag)
+        if (!ndo->ndo_vflag)
             return hdr_len;
 
         while (tlen>sizeof(struct ie_tlv_header_t)) {
-            TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
+            ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
             ie_type=tptr[0];
             ie_len=tptr[1];
 
-            printf("\n\tIE %s (%u), length %u: ",
+            ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ",
                    tok2str(mfr_ctrl_ie_values,"Unknown",ie_type),
                    ie_type,
-                   ie_len);
+                   ie_len));
 
             /* infinite loop check */
             if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t))
                 return hdr_len;
 
-            TCHECK2(*tptr,ie_len);
+            ND_TCHECK2(*tptr, ie_len);
             tptr+=sizeof(struct ie_tlv_header_t);
             /* tlv len includes header */
             ie_len-=sizeof(struct ie_tlv_header_t);
@@ -454,14 +491,14 @@
             switch (ie_type) {
 
             case MFR_CTRL_IE_MAGIC_NUM:
-                printf("0x%08x",EXTRACT_32BITS(tptr));
+                ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(tptr)));
                 break;
 
             case MFR_CTRL_IE_BUNDLE_ID: /* same message format */
             case MFR_CTRL_IE_LINK_ID:
                 for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) {
                     if (*(tptr+idx) != 0) /* don't print null termination */
-                        safeputchar(*(tptr+idx));
+                        safeputchar(ndo, *(tptr + idx));
                     else
                         break;
                 }
@@ -469,7 +506,7 @@
 
             case MFR_CTRL_IE_TIMESTAMP:
                 if (ie_len == sizeof(struct timeval)) {
-                    ts_print((const struct timeval *)tptr);
+                    ts_print(ndo, (const struct timeval *)tptr);
                     break;
                 }
                 /* fall through and hexdump if no unix timestamp */
@@ -483,15 +520,15 @@
             case MFR_CTRL_IE_CAUSE:
 
             default:
-                if (vflag <= 1)
-                    print_unknown_data(tptr,"\n\t  ",ie_len);
+                if (ndo->ndo_vflag <= 1)
+                    print_unknown_data(ndo, tptr, "\n\t  ", ie_len);
                 break;
             }
 
             /* do we want to see a hexdump of the IE ? */
-            if (vflag > 1 )
-                print_unknown_data(tptr,"\n\t  ",ie_len);
-            
+            if (ndo->ndo_vflag > 1 )
+                print_unknown_data(ndo, tptr, "\n\t  ", ie_len);
+
             tlen-=ie_len;
             tptr+=ie_len;
         }
@@ -499,7 +536,7 @@
     }
 /*
  * FRF.16 Fragmentation Frame
- * 
+ *
  *      7    6    5    4    3    2    1    0
  *    +----+----+----+----+----+----+----+----+
  *    | B  | E  | C=0|seq. (high 4 bits) | EA  |
@@ -516,30 +553,30 @@
     /* whole packet or first fragment ? */
     if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
         (p[0] & MFR_BEC_MASK) == MFR_B_BIT) {
-        printf("FRF.16 Frag, seq %u, Flags [%s], ",
+        ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s], ",
                sequence_num,
-               bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
+               bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
         hdr_len = 2;
-        fr_print(p+hdr_len,length-hdr_len);
+        fr_print(ndo, p+hdr_len,length-hdr_len);
         return hdr_len;
     }
 
     /* must be a middle or the last fragment */
-    printf("FRF.16 Frag, seq %u, Flags [%s]",
+    ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]",
            sequence_num,
-           bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
-    print_unknown_data(p,"\n\t",length);
+           bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
+    print_unknown_data(ndo, p, "\n\t", length);
 
     return hdr_len;
 
  trunc:
-    printf("[|mfr]");
+    ND_PRINT((ndo, "[|mfr]"));
     return length;
 }
 
 /* an NLPID of 0xb1 indicates a 2-byte
  * FRF.15 header
- * 
+ *
  *      7    6    5    4    3    2    1    0
  *    +----+----+----+----+----+----+----+----+
  *    ~              Q.922 header             ~
@@ -555,18 +592,19 @@
 #define FR_FRF15_FRAGTYPE 0x01
 
 static void
-frf15_print (const u_char *p, u_int length) {
-    
-    u_int16_t sequence_num, flags;
+frf15_print(netdissect_options *ndo,
+            const u_char *p, u_int length)
+{
+    uint16_t sequence_num, flags;
 
     flags = p[0]&MFR_BEC_MASK;
     sequence_num = (p[0]&0x1e)<<7 | p[1];
 
-    printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
+    ND_PRINT((ndo, "FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
            sequence_num,
            bittok2str(frf_flag_values,"none",flags),
            p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
-           length);
+           length));
 
 /* TODO:
  * depending on all permutations of the B, E and C bit
@@ -584,13 +622,13 @@
  */
 
 /* Q.933 packet format
-                      Format of Other Protocols   
+                      Format of Other Protocols
                           using Q.933 NLPID
-                  +-------------------------------+            
-                  |        Q.922 Address          | 
+                  +-------------------------------+
+                  |        Q.922 Address          |
                   +---------------+---------------+
-                  |Control  0x03  | NLPID   0x08  |        
-                  +---------------+---------------+        
+                  |Control  0x03  | NLPID   0x08  |
+                  +---------------+---------------+
                   |          L2 Protocol ID       |
                   | octet 1       |  octet 2      |
                   +-------------------------------+
@@ -697,14 +735,14 @@
     NULL
 };
 
-static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t  *ie_p,
-    const u_char *p);
+static int fr_q933_print_ie_codeset5(netdissect_options *ndo,
+    const struct ie_tlv_header_t  *ie_p, const u_char *p);
 
-typedef int (*codeset_pr_func_t)(const struct ie_tlv_header_t  *ie_p,
-    const u_char *p);
+typedef int (*codeset_pr_func_t)(netdissect_options *,
+    const struct ie_tlv_header_t  *ie_p, const u_char *p);
 
 /* array of 16 codepages - currently we only support codepage 1,5 */
-static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
+static const codeset_pr_func_t fr_q933_print_ie_codeset[] = {
     NULL,
     fr_q933_print_ie_codeset5,
     NULL,
@@ -724,7 +762,8 @@
 };
 
 void
-q933_print(const u_char *p, u_int length)
+q933_print(netdissect_options *ndo,
+           const u_char *p, u_int length)
 {
 	const u_char *ptemp = p;
 	struct ie_tlv_header_t  *ie_p;
@@ -734,7 +773,7 @@
         u_int ie_is_known = 0;
 
 	if (length < 9) {	/* shortest: Q.933a LINK VERIFY */
-		printf("[|q.933]");
+		ND_PRINT((ndo, "[|q.933]"));
 		return;
 	}
 
@@ -743,45 +782,45 @@
 	if (p[2] == MSG_ANSI_LOCKING_SHIFT) {
 	        is_ansi = 1;
 	}
-    
-        printf("%s", eflag ? "" : "Q.933, ");
+
+        ND_PRINT((ndo, "%s", ndo->ndo_eflag ? "" : "Q.933, "));
 
 	/* printing out header part */
-	printf("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset);
+	ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset));
 
 	if (p[0]) {
-	        printf(", Call Ref: 0x%02x", p[0]);
+	        ND_PRINT((ndo, ", Call Ref: 0x%02x", p[0]));
 	}
-        if (vflag) {
-                printf(", %s (0x%02x), length %u",
+        if (ndo->ndo_vflag) {
+                ND_PRINT((ndo, ", %s (0x%02x), length %u",
 		       tok2str(fr_q933_msg_values,
 			       "unknown message", p[1]),
 		       p[1],
-		       length);
+		       length));
         } else {
-                printf(", %s",
+                ND_PRINT((ndo, ", %s",
 		       tok2str(fr_q933_msg_values,
-			       "unknown message 0x%02x", p[1]));
+			       "unknown message 0x%02x", p[1])));
 	}
 
         olen = length; /* preserve the original length for non verbose mode */
 
 	if (length < (u_int)(2 - is_ansi)) {
-		printf("[|q.933]");
+		ND_PRINT((ndo, "[|q.933]"));
 		return;
 	}
 	length -= 2 + is_ansi;
 	ptemp += 2 + is_ansi;
-	
+
 	/* Loop through the rest of IE */
 	while (length > sizeof(struct ie_tlv_header_t)) {
 		ie_p = (struct ie_tlv_header_t  *)ptemp;
 		if (length < sizeof(struct ie_tlv_header_t) ||
 		    length < sizeof(struct ie_tlv_header_t) + ie_p->ie_len) {
-                    if (vflag) { /* not bark if there is just a trailer */
-                        printf("\n[|q.933]");
+                    if (ndo->ndo_vflag) { /* not bark if there is just a trailer */
+                        ND_PRINT((ndo, "\n[|q.933]"));
                     } else {
-                        printf(", length %u",olen);
+                        ND_PRINT((ndo, ", length %u", olen));
 		    }
                     return;
 		}
@@ -789,12 +828,12 @@
                 /* lets do the full IE parsing only in verbose mode
                  * however some IEs (DLCI Status, Link Verify)
                  * are also interestting in non-verbose mode */
-                if (vflag) {
-                    printf("\n\t%s IE (0x%02x), length %u: ",
+                if (ndo->ndo_vflag) {
+                    ND_PRINT((ndo, "\n\t%s IE (0x%02x), length %u: ",
                            tok2str(fr_q933_ie_codesets[codeset],
 				   "unknown", ie_p->ie_type),
                            ie_p->ie_type,
-                           ie_p->ie_len);
+                           ie_p->ie_len));
 		}
 
                 /* sanity check */
@@ -803,28 +842,29 @@
 		}
 
                 if (fr_q933_print_ie_codeset[codeset] != NULL) {
-                    ie_is_known = fr_q933_print_ie_codeset[codeset](ie_p, ptemp);
-		}               
+                    ie_is_known = fr_q933_print_ie_codeset[codeset](ndo, ie_p, ptemp);
+		}
 
-                if (vflag >= 1 && !ie_is_known) {
-                    print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len);
+                if (ndo->ndo_vflag >= 1 && !ie_is_known) {
+                    print_unknown_data(ndo, ptemp+2, "\n\t", ie_p->ie_len);
 		}
 
                 /* do we want to see a hexdump of the IE ? */
-                if (vflag> 1 && ie_is_known) {
-                    print_unknown_data(ptemp+2,"\n\t  ",ie_p->ie_len);
+                if (ndo->ndo_vflag> 1 && ie_is_known) {
+                    print_unknown_data(ndo, ptemp+2, "\n\t  ", ie_p->ie_len);
 		}
 
 		length = length - ie_p->ie_len - 2;
 		ptemp = ptemp + ie_p->ie_len + 2;
 	}
-        if (!vflag) {
-            printf(", length %u",olen);
+        if (!ndo->ndo_vflag) {
+            ND_PRINT((ndo, ", length %u", olen));
 	}
 }
 
 static int
-fr_q933_print_ie_codeset5(const struct ie_tlv_header_t  *ie_p, const u_char *p)
+fr_q933_print_ie_codeset5(netdissect_options *ndo,
+                          const struct ie_tlv_header_t  *ie_p, const u_char *p)
 {
         u_int dlci;
 
@@ -832,28 +872,28 @@
 
         case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */
         case FR_LMI_CCITT_REPORT_TYPE_IE:
-            if (vflag) {
-                printf("%s (%u)",
+            if (ndo->ndo_vflag) {
+                ND_PRINT((ndo, "%s (%u)",
                        tok2str(fr_lmi_report_type_ie_values,"unknown",p[2]),
-                       p[2]);
+                       p[2]));
 	    }
             return 1;
 
         case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */
         case FR_LMI_CCITT_LINK_VERIFY_IE:
         case FR_LMI_ANSI_LINK_VERIFY_IE_91:
-            if (!vflag) {
-                printf(", ");
+            if (!ndo->ndo_vflag) {
+                ND_PRINT((ndo, ", "));
 	    }
-            printf("TX Seq: %3d, RX Seq: %3d", p[2], p[3]);
+            ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", p[2], p[3]));
             return 1;
 
         case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
         case FR_LMI_CCITT_PVC_STATUS_IE:
-            if (!vflag) {
-                printf(", ");
+            if (!ndo->ndo_vflag) {
+                ND_PRINT((ndo, ", "));
 	    }
-            /* now parse the DLCI information element. */                    
+            /* now parse the DLCI information element. */
             if ((ie_p->ie_len < 3) ||
                 (p[2] & 0x80) ||
                 ((ie_p->ie_len == 3) && !(p[3] & 0x80)) ||
@@ -862,9 +902,9 @@
                                    !(p[5] & 0x80))) ||
                 (ie_p->ie_len > 5) ||
                 !(p[ie_p->ie_len + 1] & 0x80)) {
-                printf("Invalid DLCI IE");
+                ND_PRINT((ndo, "Invalid DLCI IE"));
 	    }
-                    
+
             dlci = ((p[2] & 0x3F) << 4) | ((p[3] & 0x78) >> 3);
             if (ie_p->ie_len == 4) {
                 dlci = (dlci << 6) | ((p[4] & 0x7E) >> 1);
@@ -873,11 +913,17 @@
                 dlci = (dlci << 13) | (p[4] & 0x7F) | ((p[5] & 0x7E) >> 1);
 	    }
 
-            printf("DLCI %u: status %s%s", dlci,
+            ND_PRINT((ndo, "DLCI %u: status %s%s", dlci,
                     p[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
-                    p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive");
+                    p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive"));
             return 1;
 	}
 
         return 0;
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-frag6.c b/print-frag6.c
index e125bd3..1290952 100644
--- a/print-frag6.c
+++ b/print-frag6.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -32,16 +28,12 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "ip6.h"
-
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
 
 int
-frag6_print(register const u_char *bp, register const u_char *bp2)
+frag6_print(netdissect_options *ndo, register const u_char *bp, register const u_char *bp2)
 {
 	register const struct ip6_frag *dp;
 	register const struct ip6_hdr *ip6;
@@ -49,34 +41,31 @@
 	dp = (const struct ip6_frag *)bp;
 	ip6 = (const struct ip6_hdr *)bp2;
 
-	TCHECK(dp->ip6f_offlg);
+	ND_TCHECK(dp->ip6f_offlg);
 
-	if (vflag) {
-		printf("frag (0x%08x:%d|%ld)",
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "frag (0x%08x:%d|%ld)",
 		       EXTRACT_32BITS(&dp->ip6f_ident),
 		       EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
 		       sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
-			       (long)(bp - bp2) - sizeof(struct ip6_frag));
+			       (long)(bp - bp2) - sizeof(struct ip6_frag)));
 	} else {
-		printf("frag (%d|%ld)",
+		ND_PRINT((ndo, "frag (%d|%ld)",
 		       EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
 		       sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
-			       (long)(bp - bp2) - sizeof(struct ip6_frag));
+			       (long)(bp - bp2) - sizeof(struct ip6_frag)));
 	}
 
-#if 1
 	/* it is meaningless to decode non-first fragment */
 	if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
 		return -1;
 	else
-#endif
 	{
-		fputs(" ", stdout);
+		ND_PRINT((ndo, " "));
 		return sizeof(struct ip6_frag);
 	}
 trunc:
-	fputs("[|frag]", stdout);
+	ND_PRINT((ndo, "[|frag]"));
 	return -1;
-#undef TCHECK
 }
 #endif /* INET6 */
diff --git a/bgp.h b/print-ftp.c
similarity index 62%
copy from bgp.h
copy to print-ftp.c
index 5081596..5479042 100644
--- a/bgp.h
+++ b/print-ftp.c
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bgp.h,v 1.3 2004-06-16 08:45:15 hannes Exp $ (LBL) */
-/* 
+/*
  * 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
@@ -10,8 +9,27 @@
  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
- *
- * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-extern char *bgp_vpn_rd_print (const u_char *);
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header$";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+void
+ftp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+	txtproto_print(ndo, pptr, len, "ftp", NULL, 0);
+}
diff --git a/print-geneve.c b/print-geneve.c
new file mode 100644
index 0000000..2187ab8
--- /dev/null
+++ b/print-geneve.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2014 VMware, Inc. All Rights Reserved.
+ *
+ * Jesse Gross <jesse@nicira.com>
+ *
+ * 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, and (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.
+ * 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.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "ethertype.h"
+
+/*
+ * Geneve header, draft-gross-geneve-02
+ *
+ *    0                   1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |Ver|  Opt Len  |O|C|    Rsvd.  |          Protocol Type        |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |        Virtual Network Identifier (VNI)       |    Reserved   |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |                    Variable Length Options                    |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * Options:
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |          Option Class         |      Type     |R|R|R| Length  |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |                      Variable Option Data                     |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define VER_SHIFT 6
+#define HDR_OPTS_LEN_MASK 0x3F
+
+#define FLAG_OAM      (1 << 7)
+#define FLAG_CRITICAL (1 << 6)
+#define FLAG_R1       (1 << 5)
+#define FLAG_R2       (1 << 4)
+#define FLAG_R3       (1 << 3)
+#define FLAG_R4       (1 << 2)
+#define FLAG_R5       (1 << 1)
+#define FLAG_R6       (1 << 0)
+
+#define OPT_TYPE_CRITICAL (1 << 7)
+#define OPT_LEN_MASK 0x1F
+
+static const struct tok geneve_flag_values[] = {
+        { FLAG_OAM, "O" },
+        { FLAG_CRITICAL, "C" },
+        { FLAG_R1, "R1" },
+        { FLAG_R2, "R2" },
+        { FLAG_R3, "R3" },
+        { FLAG_R4, "R4" },
+        { FLAG_R5, "R5" },
+        { FLAG_R6, "R6" },
+        { 0, NULL }
+};
+
+static const char *
+format_opt_class(uint16_t opt_class)
+{
+    if (opt_class <= 0xff)
+        return "Standard";
+    else if (opt_class == 0xffff)
+        return "Experimental";
+    else
+        return "Unknown";
+}
+
+static void
+geneve_opts_print(netdissect_options *ndo, const u_char *bp, u_int len)
+{
+    const char *sep = "";
+
+    while (len > 0) {
+        uint16_t opt_class;
+        uint8_t opt_type;
+        uint8_t opt_len;
+
+        ND_PRINT((ndo, "%s", sep));
+        sep = ", ";
+
+        opt_class = EXTRACT_16BITS(bp);
+        opt_type = *(bp + 2);
+        opt_len = 4 + ((*(bp + 3) & OPT_LEN_MASK) * 4);
+
+        ND_PRINT((ndo, "class %s (0x%x) type 0x%x%s len %u",
+                  format_opt_class(opt_class), opt_class, opt_type,
+                  opt_type & OPT_TYPE_CRITICAL ? "(C)" : "", opt_len));
+
+        if (opt_len > len) {
+            ND_PRINT((ndo, " [bad length]"));
+            return;
+        }
+
+        if (ndo->ndo_vflag > 1 && opt_len > 4) {
+            uint32_t *print_data = (uint32_t *)(bp + 4);
+            int i;
+
+            ND_PRINT((ndo, " data"));
+
+            for (i = 4; i < opt_len; i += 4) {
+                ND_PRINT((ndo, " %08x", EXTRACT_32BITS(print_data)));
+                print_data++;
+            }
+        }
+
+        bp += opt_len;
+        len -= opt_len;
+    }
+}
+
+void
+geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
+{
+    uint8_t ver_opt;
+    uint version;
+    uint8_t flags;
+    uint16_t prot;
+    uint32_t vni;
+    uint8_t reserved;
+    u_int opts_len;
+
+    ND_PRINT((ndo, "Geneve"));
+
+    ND_TCHECK2(*bp, 8);
+
+    ver_opt = *bp;
+    bp += 1;
+    len -= 1;
+
+    version = ver_opt >> VER_SHIFT;
+    if (version != 0) {
+        ND_PRINT((ndo, " ERROR: unknown-version %u", version));
+        return;
+    }
+
+    flags = *bp;
+    bp += 1;
+    len -= 1;
+
+    prot = EXTRACT_16BITS(bp);
+    bp += 2;
+    len -= 2;
+
+    vni = EXTRACT_24BITS(bp);
+    bp += 3;
+    len -= 3;
+
+    reserved = *bp;
+    bp += 1;
+    len -= 1;
+
+    ND_PRINT((ndo, ", Flags [%s]",
+              bittok2str_nosep(geneve_flag_values, "none", flags)));
+    ND_PRINT((ndo, ", vni 0x%x", vni));
+
+    if (reserved)
+        ND_PRINT((ndo, ", rsvd 0x%x", reserved));
+
+    if (ndo->ndo_eflag)
+        ND_PRINT((ndo, ", proto %s (0x%04x)",
+                  tok2str(ethertype_values, "unknown", prot), prot));
+
+    opts_len = (ver_opt & HDR_OPTS_LEN_MASK) * 4;
+
+    if (len < opts_len) {
+        ND_PRINT((ndo, " truncated-geneve - %u bytes missing",
+                  len - opts_len));
+        return;
+    }
+
+    ND_TCHECK2(*bp, opts_len);
+
+    if (opts_len > 0) {
+        ND_PRINT((ndo, ", options ["));
+
+        if (ndo->ndo_vflag)
+            geneve_opts_print(ndo, bp, opts_len);
+        else
+            ND_PRINT((ndo, "%u bytes", opts_len));
+
+        ND_PRINT((ndo, "]"));
+    }
+
+    bp += opts_len;
+    len -= opts_len;
+
+    if (ndo->ndo_vflag < 1)
+        ND_PRINT((ndo, ": "));
+    else
+        ND_PRINT((ndo, "\n\t"));
+
+    if (ethertype_print(ndo, prot, bp, len, len) == 0) {
+        if (prot == ETHERTYPE_TEB)
+            ether_print(ndo, bp, len, len, NULL, NULL);
+        else
+            ND_PRINT((ndo, "geneve-proto-0x%x", prot));
+    }
+
+    return;
+
+trunc:
+    ND_PRINT((ndo, " [|geneve]"));
+}
diff --git a/print-geonet.c b/print-geonet.c
index c268e85..edfb7f2 100644
--- a/print-geonet.c
+++ b/print-geonet.c
@@ -15,16 +15,13 @@
  * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -41,6 +38,8 @@
    Sub-part 1: Media-Independent Functionality
 */
 
+#define GEONET_ADDR_LEN 8
+
 static const struct tok msg_type_values[] = {
 	{   0, "CAM" },
 	{   1, "DENM" },
@@ -56,49 +55,45 @@
 };
 
 static void
-print_btp_body(const u_char *bp, u_int length)
+print_btp_body(netdissect_options *ndo,
+               const u_char *bp)
 {
 	int version;
 	int msg_type;
 	const char *msg_type_str;
 
-	if (length <= 2) {
-		return;
-	}
-
 	/* Assuming ItsDpuHeader */
 	version = bp[0];
 	msg_type = bp[1];
 	msg_type_str = tok2str(msg_type_values, "unknown (%u)", msg_type);
 
-	printf("; ItsPduHeader v:%d t:%d-%s", version, msg_type, msg_type_str);
+	ND_PRINT((ndo, "; ItsPduHeader v:%d t:%d-%s", version, msg_type, msg_type_str));
 }
 
 static void
-print_btp(const u_char *bp)
+print_btp(netdissect_options *ndo,
+          const u_char *bp)
 {
-	u_int16_t dest = EXTRACT_16BITS(bp+0);
-	u_int16_t src = EXTRACT_16BITS(bp+2);
-	printf("; BTP Dst:%u Src:%u", dest, src);
+	uint16_t dest = EXTRACT_16BITS(bp+0);
+	uint16_t src = EXTRACT_16BITS(bp+2);
+	ND_PRINT((ndo, "; BTP Dst:%u Src:%u", dest, src));
 }
 
-static void
-print_long_pos_vector(const u_char *bp)
+static int
+print_long_pos_vector(netdissect_options *ndo,
+                      const u_char *bp)
 {
-	int i;
-	u_int32_t lat, lon;
+	uint32_t lat, lon;
 
-	printf("GN_ADDR:");
-	for (i=0; i<8; i++) {
-		if (i) printf(":");
-		printf("%02x", bp[i]);
-	}
-	printf(" ");
+	ND_PRINT((ndo, "GN_ADDR:%s ", linkaddr_string (ndo, bp, 0, GEONET_ADDR_LEN)));
 
+	if (!ND_TTEST2(*(bp+12), 8))
+		return (-1);
 	lat = EXTRACT_32BITS(bp+12);
-	printf("lat:%d ", lat);
+	ND_PRINT((ndo, "lat:%d ", lat));
 	lon = EXTRACT_32BITS(bp+16);
-	printf("lon:%d", lon);
+	ND_PRINT((ndo, "lon:%d", lon));
+	return (0);
 }
 
 
@@ -109,137 +104,170 @@
 void
 geonet_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int length)
 {
-	printf("GeoNet src:%s; ", etheraddr_string(eth+6));
+	int version;
+	int next_hdr;
+	int hdr_type;
+	int hdr_subtype;
+	uint16_t payload_length;
+	int hop_limit;
+	const char *next_hdr_txt = "Unknown";
+	const char *hdr_type_txt = "Unknown";
+	int hdr_size = -1;
 
-	if (length >= 36) {
-		/* Process Common Header */
-		int version = bp[0] >> 4;
-		int next_hdr = bp[0] & 0x0f;
-		int hdr_type = bp[1] >> 4;
-		int hdr_subtype = bp[1] & 0x0f;
-		u_int16_t payload_length = EXTRACT_16BITS(bp+4);
-		int hop_limit = bp[7];
-		const char *next_hdr_txt = "Unknown";
-		const char *hdr_type_txt = "Unknown";
-		int hdr_size = -1;
+	ND_PRINT((ndo, "GeoNet src:%s; ", etheraddr_string(ndo, eth+6)));
 
-		switch (next_hdr) {
-			case 0: next_hdr_txt = "Any"; break;
-			case 1: next_hdr_txt = "BTP-A"; break;
-			case 2: next_hdr_txt = "BTP-B"; break;
-			case 3: next_hdr_txt = "IPv6"; break;
-		}
+	/* Process Common Header */
+	if (length < 36)
+		goto malformed;
+		
+	ND_TCHECK2(*bp, 7);
+	version = bp[0] >> 4;
+	next_hdr = bp[0] & 0x0f;
+	hdr_type = bp[1] >> 4;
+	hdr_subtype = bp[1] & 0x0f;
+	payload_length = EXTRACT_16BITS(bp+4);
+	hop_limit = bp[7];
 
-		switch (hdr_type) {
-			case 0: hdr_type_txt = "Any"; break;
-			case 1: hdr_type_txt = "Beacon"; break;
-			case 2: hdr_type_txt = "GeoUnicast"; break;
-			case 3: switch (hdr_subtype) {
-					case 0: hdr_type_txt = "GeoAnycastCircle"; break;
-					case 1: hdr_type_txt = "GeoAnycastRect"; break;
-					case 2: hdr_type_txt = "GeoAnycastElipse"; break;
-				}
-				break;
-			case 4: switch (hdr_subtype) {
-					case 0: hdr_type_txt = "GeoBroadcastCircle"; break;
-					case 1: hdr_type_txt = "GeoBroadcastRect"; break;
-					case 2: hdr_type_txt = "GeoBroadcastElipse"; break;
-				}
-				break;
-			case 5: switch (hdr_subtype) {
-					case 0: hdr_type_txt = "TopoScopeBcast-SH"; break;
-					case 1: hdr_type_txt = "TopoScopeBcast-MH"; break;
-				}
-				break;
-			case 6: switch (hdr_subtype) {
-					case 0: hdr_type_txt = "LocService-Request"; break;
-					case 1: hdr_type_txt = "LocService-Reply"; break;
-				}
-				break;
-		}
+	switch (next_hdr) {
+		case 0: next_hdr_txt = "Any"; break;
+		case 1: next_hdr_txt = "BTP-A"; break;
+		case 2: next_hdr_txt = "BTP-B"; break;
+		case 3: next_hdr_txt = "IPv6"; break;
+	}
 
-		printf("v:%d ", version);
-		printf("NH:%d-%s ", next_hdr, next_hdr_txt);
-		printf("HT:%d-%d-%s ", hdr_type, hdr_subtype, hdr_type_txt);
-		printf("HopLim:%d ", hop_limit);
-		printf("Payload:%d ", payload_length);
-        	print_long_pos_vector(bp + 8);
+	switch (hdr_type) {
+		case 0: hdr_type_txt = "Any"; break;
+		case 1: hdr_type_txt = "Beacon"; break;
+		case 2: hdr_type_txt = "GeoUnicast"; break;
+		case 3: switch (hdr_subtype) {
+				case 0: hdr_type_txt = "GeoAnycastCircle"; break;
+				case 1: hdr_type_txt = "GeoAnycastRect"; break;
+				case 2: hdr_type_txt = "GeoAnycastElipse"; break;
+			}
+			break;
+		case 4: switch (hdr_subtype) {
+				case 0: hdr_type_txt = "GeoBroadcastCircle"; break;
+				case 1: hdr_type_txt = "GeoBroadcastRect"; break;
+				case 2: hdr_type_txt = "GeoBroadcastElipse"; break;
+			}
+			break;
+		case 5: switch (hdr_subtype) {
+				case 0: hdr_type_txt = "TopoScopeBcast-SH"; break;
+				case 1: hdr_type_txt = "TopoScopeBcast-MH"; break;
+			}
+			break;
+		case 6: switch (hdr_subtype) {
+				case 0: hdr_type_txt = "LocService-Request"; break;
+				case 1: hdr_type_txt = "LocService-Reply"; break;
+			}
+			break;
+	}
 
-		/* Skip Common Header */
-		length -= 36;
-		bp += 36;
+	ND_PRINT((ndo, "v:%d ", version));
+	ND_PRINT((ndo, "NH:%d-%s ", next_hdr, next_hdr_txt));
+	ND_PRINT((ndo, "HT:%d-%d-%s ", hdr_type, hdr_subtype, hdr_type_txt));
+	ND_PRINT((ndo, "HopLim:%d ", hop_limit));
+	ND_PRINT((ndo, "Payload:%d ", payload_length));
+	if (print_long_pos_vector(ndo, bp + 8) == -1)
+		goto trunc;
 
-		/* Process Extended Headers */
-		switch (hdr_type) {
-			case 0: /* Any */
-				hdr_size = 0;
-				break;
-			case 1: /* Beacon */
-				hdr_size = 0;
-				break;
-			case 2: /* GeoUnicast */
-				break;
-			case 3: switch (hdr_subtype) {
-					case 0: /* GeoAnycastCircle */
-						break;
-					case 1: /* GeoAnycastRect */
-						break;
-					case 2: /* GeoAnycastElipse */
-						break;
-				}
-				break;
-			case 4: switch (hdr_subtype) {
-					case 0: /* GeoBroadcastCircle */
-						break;
-					case 1: /* GeoBroadcastRect */
-						break;
-					case 2: /* GeoBroadcastElipse */
-						break;
-				}
-				break;
-			case 5: switch (hdr_subtype) {
-					case 0: /* TopoScopeBcast-SH */
-						hdr_size = 0;
-						break;
-					case 1: /* TopoScopeBcast-MH */
-						hdr_size = 68 - 36;
-						break;
-				}
-				break;
-			case 6: switch (hdr_subtype) {
-					case 0: /* LocService-Request */
-						break;
-					case 1: /* LocService-Reply */
-						break;
-				}
-				break;
-		}
+	/* Skip Common Header */
+	length -= 36;
+	bp += 36;
 
-		/* Skip Extended headers */
-		if (hdr_size >= 0) {
-			length -= hdr_size;
-			bp += hdr_size;
-			switch (next_hdr) {
-				case 0: /* Any */
+	/* Process Extended Headers */
+	switch (hdr_type) {
+		case 0: /* Any */
+			hdr_size = 0;
+			break;
+		case 1: /* Beacon */
+			hdr_size = 0;
+			break;
+		case 2: /* GeoUnicast */
+			break;
+		case 3: switch (hdr_subtype) {
+				case 0: /* GeoAnycastCircle */
 					break;
-				case 1:
-				case 2: /* BTP A/B */
-					print_btp(bp);
-					length -= 4;
-					bp += 4;
-					print_btp_body(bp, length);
+				case 1: /* GeoAnycastRect */
 					break;
-				case 3: /* IPv6 */
+				case 2: /* GeoAnycastElipse */
 					break;
 			}
+			break;
+		case 4: switch (hdr_subtype) {
+				case 0: /* GeoBroadcastCircle */
+					break;
+				case 1: /* GeoBroadcastRect */
+					break;
+				case 2: /* GeoBroadcastElipse */
+					break;
+			}
+			break;
+		case 5: switch (hdr_subtype) {
+				case 0: /* TopoScopeBcast-SH */
+					hdr_size = 0;
+					break;
+				case 1: /* TopoScopeBcast-MH */
+					hdr_size = 68 - 36;
+					break;
+			}
+			break;
+		case 6: switch (hdr_subtype) {
+				case 0: /* LocService-Request */
+					break;
+				case 1: /* LocService-Reply */
+					break;
+			}
+			break;
+	}
+
+	/* Skip Extended headers */
+	if (hdr_size >= 0) {
+		if (length < (u_int)hdr_size)
+			goto malformed;
+		ND_TCHECK2(*bp, hdr_size);
+		length -= hdr_size;
+		bp += hdr_size;
+		switch (next_hdr) {
+			case 0: /* Any */
+				break;
+			case 1:
+			case 2: /* BTP A/B */
+				if (length < 4)
+					goto malformed;
+				ND_TCHECK2(*bp, 4);
+				print_btp(ndo, bp);
+				length -= 4;
+				bp += 4;
+				if (length >= 2) {
+					/*
+					 * XXX - did print_btp_body()
+					 * return if length < 2
+					 * because this is optional,
+					 * or was that just not
+					 * reporting genuine errors?
+					 */
+					ND_TCHECK2(*bp, 2);
+					print_btp_body(ndo, bp);
+				}
+				break;
+			case 3: /* IPv6 */
+				break;
 		}
-	} else {
-		printf("Malformed (small) ");
 	}
 
 	/* Print user data part */
 	if (ndo->ndo_vflag)
-		default_print(bp, length);
+		ND_DEFAULTPRINT(bp, length);
+	return;
+
+malformed:
+	ND_PRINT((ndo, " Malformed (small) "));
+	/* XXX - print the remaining data as hex? */
+	return;
+
+trunc:
+	ND_PRINT((ndo, "[|geonet]"));
 }
 
 
diff --git a/print-gre.c b/print-gre.c
index b4ad09a..4d7705f 100644
--- a/print-gre.c
+++ b/print-gre.c
@@ -36,27 +36,21 @@
  * RFC1701 (GRE), RFC1702 (GRE IPv4), and RFC2637 (Enhanced GRE)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
-
-#include "ip.h"
 #include "ethertype.h"
 
+static const char tstr[] = "[|gre]";
+
 #define	GRE_CP		0x8000		/* checksum present */
 #define	GRE_RP		0x4000		/* routing present */
 #define	GRE_KP		0x2000		/* key present */
@@ -67,9 +61,9 @@
 
 static const struct tok gre_flag_values[] = {
     { GRE_CP, "checksum present"},
-    { GRE_RP, "routing present"}, 
-    { GRE_KP, "key present"}, 
-    { GRE_SP, "sequence# present"}, 
+    { GRE_RP, "routing present"},
+    { GRE_KP, "key present"},
+    { GRE_SP, "sequence# present"},
     { GRE_sP, "source routing present"},
     { GRE_RECRS, "recursion count"},
     { GRE_AP, "ack present"},
@@ -82,49 +76,47 @@
 #define	GRESRE_IP	0x0800		/* IP */
 #define	GRESRE_ASN	0xfffe		/* ASN */
 
-void gre_print_0(const u_char *, u_int);
-void gre_print_1(const u_char *, u_int);
-void gre_sre_print(u_int16_t, u_int8_t, u_int8_t, const u_char *, u_int);
-void gre_sre_ip_print(u_int8_t, u_int8_t, const u_char *, u_int);
-void gre_sre_asn_print(u_int8_t, u_int8_t, const u_char *, u_int);
+static void gre_print_0(netdissect_options *, const u_char *, u_int);
+static void gre_print_1(netdissect_options *, const u_char *, u_int);
+static void gre_sre_print(netdissect_options *, uint16_t, uint8_t, uint8_t, const u_char *, u_int);
+static void gre_sre_ip_print(netdissect_options *, uint8_t, uint8_t, const u_char *, u_int);
+static void gre_sre_asn_print(netdissect_options *, uint8_t, uint8_t, const u_char *, u_int);
 
 void
-gre_print(const u_char *bp, u_int length)
+gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
 	u_int len = length, vers;
 
 	if (len < 2) {
-		printf("[|gre]");
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 	vers = EXTRACT_16BITS(bp) & GRE_VERS_MASK;
-        printf("GREv%u",vers);
+        ND_PRINT((ndo, "GREv%u",vers));
 
         switch(vers) {
         case 0:
-            gre_print_0(bp, len);
+            gre_print_0(ndo, bp, len);
             break;
         case 1:
-            gre_print_1(bp, len);
+            gre_print_1(ndo, bp, len);
             break;
 	default:
-            printf(" ERROR: unknown-version");
+            ND_PRINT((ndo, " ERROR: unknown-version"));
             break;
         }
-	return;
-
 }
 
-void
-gre_print_0(const u_char *bp, u_int length)
+static void
+gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
 {
 	u_int len = length;
-	u_int16_t flags, prot;
+	uint16_t flags, prot;
 
 	flags = EXTRACT_16BITS(bp);
-        if (vflag)
-            printf(", Flags [%s]",
-                   bittok2str(gre_flag_values,"none",flags));
+        if (ndo->ndo_vflag)
+            ND_PRINT((ndo, ", Flags [%s]",
+                   bittok2str(gre_flag_values,"none",flags)));
 
 	len -= 2;
 	bp += 2;
@@ -138,14 +130,14 @@
 	if ((flags & GRE_CP) | (flags & GRE_RP)) {
 		if (len < 2)
 			goto trunc;
-		if (vflag)
-			printf(", sum 0x%x", EXTRACT_16BITS(bp));
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, ", sum 0x%x", EXTRACT_16BITS(bp)));
 		bp += 2;
 		len -= 2;
 
 		if (len < 2)
 			goto trunc;
-		printf(", off 0x%x", EXTRACT_16BITS(bp));
+		ND_PRINT((ndo, ", off 0x%x", EXTRACT_16BITS(bp)));
 		bp += 2;
 		len -= 2;
 	}
@@ -153,7 +145,7 @@
 	if (flags & GRE_KP) {
 		if (len < 4)
 			goto trunc;
-		printf(", key=0x%x", EXTRACT_32BITS(bp));
+		ND_PRINT((ndo, ", key=0x%x", EXTRACT_32BITS(bp)));
 		bp += 4;
 		len -= 4;
 	}
@@ -161,16 +153,16 @@
 	if (flags & GRE_SP) {
 		if (len < 4)
 			goto trunc;
-		printf(", seq %u", EXTRACT_32BITS(bp));
+		ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
 		bp += 4;
 		len -= 4;
 	}
 
 	if (flags & GRE_RP) {
 		for (;;) {
-			u_int16_t af;
-			u_int8_t sreoff;
-			u_int8_t srelen;
+			uint16_t af;
+			uint8_t sreoff;
+			uint8_t srelen;
 
 			if (len < 4)
 				goto trunc;
@@ -183,7 +175,7 @@
 			if (af == 0 && srelen == 0)
 				break;
 
-			gre_sre_print(af, sreoff, srelen, bp, len);
+			gre_sre_print(ndo, af, sreoff, srelen, bp, len);
 
 			if (len < srelen)
 				goto trunc;
@@ -192,64 +184,62 @@
 		}
 	}
 
-        if (eflag)
-            printf(", proto %s (0x%04x)",
+        if (ndo->ndo_eflag)
+            ND_PRINT((ndo, ", proto %s (0x%04x)",
                    tok2str(ethertype_values,"unknown",prot),
-                   prot);
+                   prot));
 
-        printf(", length %u",length);
+        ND_PRINT((ndo, ", length %u",length));
 
-        if (vflag < 1)
-            printf(": "); /* put in a colon as protocol demarc */
+        if (ndo->ndo_vflag < 1)
+            ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
         else
-            printf("\n\t"); /* if verbose go multiline */
+            ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
 
 	switch (prot) {
 	case ETHERTYPE_IP:
-	        ip_print(gndo, bp, len);
+	        ip_print(ndo, bp, len);
 		break;
-#ifdef INET6
 	case ETHERTYPE_IPV6:
-		ip6_print(gndo, bp, len);
+		ip6_print(ndo, bp, len);
 		break;
-#endif
 	case ETHERTYPE_MPLS:
-		mpls_print(bp, len);
+		mpls_print(ndo, bp, len);
 		break;
 	case ETHERTYPE_IPX:
-		ipx_print(bp, len);
+		ipx_print(ndo, bp, len);
 		break;
 	case ETHERTYPE_ATALK:
-		atalk_print(bp, len);
+		atalk_print(ndo, bp, len);
 		break;
 	case ETHERTYPE_GRE_ISO:
-		isoclns_print(bp, len, len);
+		isoclns_print(ndo, bp, len, len);
 		break;
 	case ETHERTYPE_TEB:
-		ether_print(gndo, bp, len, len, NULL, NULL);
+		ether_print(ndo, bp, len, len, NULL, NULL);
 		break;
 	default:
-		printf("gre-proto-0x%x", prot);
+		ND_PRINT((ndo, "gre-proto-0x%x", prot));
 	}
 	return;
 
 trunc:
-	printf("[|gre]");
+	ND_PRINT((ndo, "%s", tstr));
 }
 
-void
-gre_print_1(const u_char *bp, u_int length)
+static void
+gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
 {
 	u_int len = length;
-	u_int16_t flags, prot;
+	uint16_t flags, prot;
 
 	flags = EXTRACT_16BITS(bp);
 	len -= 2;
 	bp += 2;
 
-	if (vflag)
-            printf(", Flags [%s]",
-                   bittok2str(gre_flag_values,"none",flags));
+	if (ndo->ndo_vflag)
+            ND_PRINT((ndo, ", Flags [%s]",
+                   bittok2str(gre_flag_values,"none",flags)));
 
 	if (len < 2)
 		goto trunc;
@@ -259,12 +249,12 @@
 
 
 	if (flags & GRE_KP) {
-		u_int32_t k;
+		uint32_t k;
 
 		if (len < 4)
 			goto trunc;
 		k = EXTRACT_32BITS(bp);
-		printf(", call %d", k & 0xffff);
+		ND_PRINT((ndo, ", call %d", k & 0xffff));
 		len -= 4;
 		bp += 4;
 	}
@@ -272,7 +262,7 @@
 	if (flags & GRE_SP) {
 		if (len < 4)
 			goto trunc;
-		printf(", seq %u", EXTRACT_32BITS(bp));
+		ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
 		bp += 4;
 		len -= 4;
 	}
@@ -280,78 +270,80 @@
 	if (flags & GRE_AP) {
 		if (len < 4)
 			goto trunc;
-		printf(", ack %u", EXTRACT_32BITS(bp));
+		ND_PRINT((ndo, ", ack %u", EXTRACT_32BITS(bp)));
 		bp += 4;
 		len -= 4;
 	}
 
 	if ((flags & GRE_SP) == 0)
-		printf(", no-payload");
+		ND_PRINT((ndo, ", no-payload"));
 
-        if (eflag)
-            printf(", proto %s (0x%04x)",
+        if (ndo->ndo_eflag)
+            ND_PRINT((ndo, ", proto %s (0x%04x)",
                    tok2str(ethertype_values,"unknown",prot),
-                   prot);
+                   prot));
 
-        printf(", length %u",length);
+        ND_PRINT((ndo, ", length %u",length));
 
         if ((flags & GRE_SP) == 0)
             return;
 
-        if (vflag < 1)
-            printf(": "); /* put in a colon as protocol demarc */
+        if (ndo->ndo_vflag < 1)
+            ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
         else
-            printf("\n\t"); /* if verbose go multiline */
+            ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
 
 	switch (prot) {
 	case ETHERTYPE_PPP:
-                ppp_print(bp, len);
+		ppp_print(ndo, bp, len);
 		break;
 	default:
-		printf("gre-proto-0x%x", prot);
+		ND_PRINT((ndo, "gre-proto-0x%x", prot));
 		break;
 	}
 	return;
 
 trunc:
-	printf("[|gre]");
+	ND_PRINT((ndo, "%s", tstr));
 }
 
-void
-gre_sre_print(u_int16_t af, u_int8_t sreoff, u_int8_t srelen,
-    const u_char *bp, u_int len)
+static void
+gre_sre_print(netdissect_options *ndo, uint16_t af, uint8_t sreoff,
+    uint8_t srelen, const u_char *bp, u_int len)
 {
 	switch (af) {
 	case GRESRE_IP:
-		printf(", (rtaf=ip");
-		gre_sre_ip_print(sreoff, srelen, bp, len);
-		printf(") ");
+		ND_PRINT((ndo, ", (rtaf=ip"));
+		gre_sre_ip_print(ndo, sreoff, srelen, bp, len);
+		ND_PRINT((ndo, ") "));
 		break;
 	case GRESRE_ASN:
-		printf(", (rtaf=asn");
-		gre_sre_asn_print(sreoff, srelen, bp, len);
-		printf(") ");
+		ND_PRINT((ndo, ", (rtaf=asn"));
+		gre_sre_asn_print(ndo, sreoff, srelen, bp, len);
+		ND_PRINT((ndo, ") "));
 		break;
 	default:
-		printf(", (rtaf=0x%x) ", af);
+		ND_PRINT((ndo, ", (rtaf=0x%x) ", af));
 	}
 }
-void
-gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
+
+static void
+gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
+                 const u_char *bp, u_int len)
 {
 	struct in_addr a;
 	const u_char *up = bp;
 
 	if (sreoff & 3) {
-		printf(", badoffset=%u", sreoff);
+		ND_PRINT((ndo, ", badoffset=%u", sreoff));
 		return;
 	}
 	if (srelen & 3) {
-		printf(", badlength=%u", srelen);
+		ND_PRINT((ndo, ", badlength=%u", srelen));
 		return;
 	}
 	if (sreoff >= srelen) {
-		printf(", badoff/len=%u/%u", sreoff, srelen);
+		ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
 		return;
 	}
 
@@ -360,9 +352,9 @@
 			return;
 
 		memcpy(&a, bp, sizeof(a));
-		printf(" %s%s",
+		ND_PRINT((ndo, " %s%s",
 		    ((bp - up) == sreoff) ? "*" : "",
-		    inet_ntoa(a));
+		    inet_ntoa(a)));
 
 		bp += 4;
 		len -= 4;
@@ -370,21 +362,22 @@
 	}
 }
 
-void
-gre_sre_asn_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
+static void
+gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
+                  const u_char *bp, u_int len)
 {
 	const u_char *up = bp;
 
 	if (sreoff & 1) {
-		printf(", badoffset=%u", sreoff);
+		ND_PRINT((ndo, ", badoffset=%u", sreoff));
 		return;
 	}
 	if (srelen & 1) {
-		printf(", badlength=%u", srelen);
+		ND_PRINT((ndo, ", badlength=%u", srelen));
 		return;
 	}
 	if (sreoff >= srelen) {
-		printf(", badoff/len=%u/%u", sreoff, srelen);
+		ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
 		return;
 	}
 
@@ -392,9 +385,9 @@
 		if (len < 2 || srelen == 0)
 			return;
 
-		printf(" %s%x",
+		ND_PRINT((ndo, " %s%x",
 		    ((bp - up) == sreoff) ? "*" : "",
-		    EXTRACT_16BITS(bp));
+		    EXTRACT_16BITS(bp)));
 
 		bp += 2;
 		len -= 2;
diff --git a/print-hsrp.c b/print-hsrp.c
index 9f0f40c..0e2420f 100644
--- a/print-hsrp.c
+++ b/print-hsrp.c
@@ -29,19 +29,13 @@
 
 /* Cisco Hot Standby Router Protocol (HSRP). */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 
@@ -85,56 +79,56 @@
 
 /* HSRP protocol header. */
 struct hsrp {
-	u_int8_t	hsrp_version;
-	u_int8_t	hsrp_op_code;
-	u_int8_t	hsrp_state;
-	u_int8_t	hsrp_hellotime;
-	u_int8_t	hsrp_holdtime;
-	u_int8_t	hsrp_priority;
-	u_int8_t	hsrp_group;
-	u_int8_t	hsrp_reserved;
-	u_int8_t	hsrp_authdata[HSRP_AUTH_SIZE];
+	uint8_t		hsrp_version;
+	uint8_t		hsrp_op_code;
+	uint8_t		hsrp_state;
+	uint8_t		hsrp_hellotime;
+	uint8_t		hsrp_holdtime;
+	uint8_t		hsrp_priority;
+	uint8_t		hsrp_group;
+	uint8_t		hsrp_reserved;
+	uint8_t		hsrp_authdata[HSRP_AUTH_SIZE];
 	struct in_addr	hsrp_virtaddr;
 };
 
 void
-hsrp_print(register const u_int8_t *bp, register u_int len)
+hsrp_print(netdissect_options *ndo, register const uint8_t *bp, register u_int len)
 {
 	struct hsrp *hp = (struct hsrp *) bp;
 
-	TCHECK(hp->hsrp_version);
-	printf("HSRPv%d", hp->hsrp_version);
+	ND_TCHECK(hp->hsrp_version);
+	ND_PRINT((ndo, "HSRPv%d", hp->hsrp_version));
 	if (hp->hsrp_version != 0)
 		return;
-	TCHECK(hp->hsrp_op_code);
-	printf("-");
-	printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code));
-	printf("%d: ", len);
-	TCHECK(hp->hsrp_state);
-	printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state));
-	TCHECK(hp->hsrp_group);
-	printf("group=%d ", hp->hsrp_group);
-	TCHECK(hp->hsrp_reserved);
+	ND_TCHECK(hp->hsrp_op_code);
+	ND_PRINT((ndo, "-"));
+	ND_PRINT((ndo, "%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code)));
+	ND_PRINT((ndo, "%d: ", len));
+	ND_TCHECK(hp->hsrp_state);
+	ND_PRINT((ndo, "state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state)));
+	ND_TCHECK(hp->hsrp_group);
+	ND_PRINT((ndo, "group=%d ", hp->hsrp_group));
+	ND_TCHECK(hp->hsrp_reserved);
 	if (hp->hsrp_reserved != 0) {
-		printf("[reserved=%d!] ", hp->hsrp_reserved);
+		ND_PRINT((ndo, "[reserved=%d!] ", hp->hsrp_reserved));
 	}
-	TCHECK(hp->hsrp_virtaddr);
-	printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr));
-	if (vflag) {
-		printf(" hellotime=");
-		relts_print(hp->hsrp_hellotime);
-		printf(" holdtime=");
-		relts_print(hp->hsrp_holdtime);
-		printf(" priority=%d", hp->hsrp_priority);
-		printf(" auth=\"");
-		if (fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
-		    snapend)) {
-			printf("\"");
+	ND_TCHECK(hp->hsrp_virtaddr);
+	ND_PRINT((ndo, "addr=%s", ipaddr_string(ndo, &hp->hsrp_virtaddr)));
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, " hellotime="));
+		relts_print(ndo, hp->hsrp_hellotime);
+		ND_PRINT((ndo, " holdtime="));
+		relts_print(ndo, hp->hsrp_holdtime);
+		ND_PRINT((ndo, " priority=%d", hp->hsrp_priority));
+		ND_PRINT((ndo, " auth=\""));
+		if (fn_printn(ndo, hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
+		    ndo->ndo_snapend)) {
+			ND_PRINT((ndo, "\""));
 			goto trunc;
 		}
-		printf("\"");
+		ND_PRINT((ndo, "\""));
 	}
 	return;
 trunc:
-	printf("[|hsrp]");
+	ND_PRINT((ndo, "[|hsrp]"));
 }
diff --git a/print-http.c b/print-http.c
new file mode 100644
index 0000000..49df174
--- /dev/null
+++ b/print-http.c
@@ -0,0 +1,80 @@
+/*
+ * 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, and (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.
+ * 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.
+ */
+
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header$";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "interface.h"
+#include "extract.h"
+
+/*
+ * Includes WebDAV requests.
+ */
+static const char *httpcmds[] = {
+	"GET",
+	"PUT",
+	"COPY",
+	"HEAD",
+	"LOCK",
+	"MOVE",
+	"POLL",
+	"POST",
+	"BCOPY",
+	"BMOVE",
+	"MKCOL",
+	"TRACE",
+	"LABEL",
+	"MERGE",
+	"DELETE",
+	"SEARCH",
+	"UNLOCK",
+	"REPORT",
+	"UPDATE",
+	"NOTIFY",
+	"BDELETE",
+	"CONNECT",
+	"OPTIONS",
+	"CHECKIN",
+	"PROPFIND",
+	"CHECKOUT",
+	"CCM_POST",
+	"SUBSCRIBE",
+	"PROPPATCH",
+	"BPROPFIND",
+	"BPROPPATCH",
+	"UNCHECKOUT",
+	"MKACTIVITY",
+	"MKWORKSPACE",
+	"UNSUBSCRIBE",
+	"RPC_CONNECT",
+	"VERSION-CONTROL",
+	"BASELINE-CONTROL",
+	NULL
+};
+
+void
+http_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+	txtproto_print(ndo, pptr, len, "http", httpcmds, RESP_CODE_SECOND_TOKEN);
+}
diff --git a/print-icmp.c b/print-icmp.c
index 9892594..59eb007 100644
--- a/print-icmp.c
+++ b/print-icmp.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.87 2007-09-13 17:42:31 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -51,17 +47,17 @@
  * Structure of an icmp header.
  */
 struct icmp {
-	u_int8_t  icmp_type;		/* type of message, see below */
-	u_int8_t  icmp_code;		/* type sub code */
-	u_int16_t icmp_cksum;		/* ones complement cksum of struct */
+	uint8_t  icmp_type;		/* type of message, see below */
+	uint8_t  icmp_code;		/* type sub code */
+	uint16_t icmp_cksum;		/* ones complement cksum of struct */
 	union {
-		u_int8_t ih_pptr;			/* ICMP_PARAMPROB */
+		uint8_t ih_pptr;			/* ICMP_PARAMPROB */
 		struct in_addr ih_gwaddr;	/* ICMP_REDIRECT */
 		struct ih_idseq {
-			u_int16_t icd_id;
-			u_int16_t icd_seq;
+			uint16_t icd_id;
+			uint16_t icd_seq;
 		} ih_idseq;
-		u_int32_t ih_void;
+		uint32_t ih_void;
 	} icmp_hun;
 #define	icmp_pptr	icmp_hun.ih_pptr
 #define	icmp_gwaddr	icmp_hun.ih_gwaddr
@@ -70,16 +66,16 @@
 #define	icmp_void	icmp_hun.ih_void
 	union {
 		struct id_ts {
-			u_int32_t its_otime;
-			u_int32_t its_rtime;
-			u_int32_t its_ttime;
+			uint32_t its_otime;
+			uint32_t its_rtime;
+			uint32_t its_ttime;
 		} id_ts;
 		struct id_ip  {
 			struct ip idi_ip;
 			/* options and then 64 bits of data */
 		} id_ip;
-		u_int32_t id_mask;
-		u_int8_t id_data[1];
+		uint32_t id_mask;
+		uint8_t id_data[1];
 	} icmp_dun;
 #define	icmp_otime	icmp_dun.id_ts.its_otime
 #define	icmp_rtime	icmp_dun.id_ts.its_rtime
@@ -89,7 +85,7 @@
 #define	icmp_data	icmp_dun.id_data
 };
 
-#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4) 
+#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
 #define ICMP_MPLS_EXT_VERSION 2
 
 /*
@@ -102,7 +98,7 @@
  */
 #define	ICMP_MINLEN	8				/* abs minimum */
 #define ICMP_EXTD_MINLEN (156 - sizeof (struct ip))     /* draft-bonica-internet-icmp-08 */
-#define	ICMP_TSLEN	(8 + 3 * sizeof (u_int32_t))	/* timestamp */
+#define	ICMP_TSLEN	(8 + 3 * sizeof (uint32_t))	/* timestamp */
 #define	ICMP_MASKLEN	12				/* address mask */
 #define	ICMP_ADVLENMIN	(8 + sizeof (struct ip) + 8)	/* min */
 #define	ICMP_ADVLEN(p)	(8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
@@ -149,12 +145,10 @@
 
 #define	ICMP_MAXTYPE		18
 
-#define	ICMP_INFOTYPE(type) \
-	((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
-	(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
-	(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
-	(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
-	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
+#define ICMP_ERRTYPE(type) \
+	((type) == ICMP_UNREACH || (type) == ICMP_SOURCEQUENCH || \
+	(type) == ICMP_REDIRECT || (type) == ICMP_TIMXCEED || \
+	(type) == ICMP_PARAMPROB)
 #define	ICMP_MPLS_EXT_TYPE(type) \
 	((type) == ICMP_UNREACH || \
          (type) == ICMP_TIMXCEED || \
@@ -245,20 +239,20 @@
 
 /* rfc1191 */
 struct mtu_discovery {
-	u_int16_t unused;
-	u_int16_t nexthopmtu;
+	uint16_t unused;
+	uint16_t nexthopmtu;
 };
 
 /* rfc1256 */
 struct ih_rdiscovery {
-	u_int8_t ird_addrnum;
-	u_int8_t ird_addrsiz;
-	u_int16_t ird_lifetime;
+	uint8_t ird_addrnum;
+	uint8_t ird_addrsiz;
+	uint16_t ird_lifetime;
 };
 
 struct id_rdiscovery {
-	u_int32_t ird_addr;
-	u_int32_t ird_pref;
+	uint32_t ird_addr;
+	uint32_t ird_pref;
 };
 
 /*
@@ -288,22 +282,22 @@
  */
 
 struct icmp_ext_t {
-    u_int8_t icmp_type;
-    u_int8_t icmp_code;
-    u_int8_t icmp_checksum[2];
-    u_int8_t icmp_reserved;
-    u_int8_t icmp_length;
-    u_int8_t icmp_reserved2[2];
-    u_int8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
-    u_int8_t icmp_ext_version_res[2];
-    u_int8_t icmp_ext_checksum[2];
-    u_int8_t icmp_ext_data[1];
+    uint8_t icmp_type;
+    uint8_t icmp_code;
+    uint8_t icmp_checksum[2];
+    uint8_t icmp_reserved;
+    uint8_t icmp_length;
+    uint8_t icmp_reserved2[2];
+    uint8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
+    uint8_t icmp_ext_version_res[2];
+    uint8_t icmp_ext_checksum[2];
+    uint8_t icmp_ext_data[1];
 };
 
 struct icmp_mpls_ext_object_header_t {
-    u_int8_t length[2];
-    u_int8_t class_num;
-    u_int8_t ctype;
+    uint8_t length[2];
+    uint8_t class_num;
+    uint8_t ctype;
 };
 
 static const struct tok icmp_mpls_ext_obj_values[] = {
@@ -317,7 +311,8 @@
 
 /* print the milliseconds since midnight UTC */
 const char *
-icmp_tstamp_print(u_int tstamp) {
+icmp_tstamp_print(u_int tstamp)
+{
     u_int msec,sec,min,hrs;
 
     static char buf[64];
@@ -329,9 +324,10 @@
     snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
     return buf;
 }
- 
+
 void
-icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
+icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *bp2,
+           int fragmented)
 {
 	char *cp;
 	const struct icmp *dp;
@@ -340,8 +336,8 @@
 	const char *str, *fmt;
 	const struct ip *oip;
 	const struct udphdr *ouh;
-        const u_int8_t *obj_tptr;
-        u_int32_t raw_label;
+        const uint8_t *obj_tptr;
+        uint32_t raw_label;
         const u_char *snapend_save;
 	const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
 	u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
@@ -353,12 +349,12 @@
 	ip = (struct ip *)bp2;
 	str = buf;
 
-	TCHECK(dp->icmp_code);
+	ND_TCHECK(dp->icmp_code);
 	switch (dp->icmp_type) {
 
 	case ICMP_ECHO:
 	case ICMP_ECHOREPLY:
-		TCHECK(dp->icmp_seq);
+		ND_TCHECK(dp->icmp_seq);
 		(void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
                                dp->icmp_type == ICMP_ECHO ?
                                "request" : "reply",
@@ -367,44 +363,44 @@
 		break;
 
 	case ICMP_UNREACH:
-		TCHECK(dp->icmp_ip.ip_dst);
+		ND_TCHECK(dp->icmp_ip.ip_dst);
 		switch (dp->icmp_code) {
 
 		case ICMP_UNREACH_PROTOCOL:
-			TCHECK(dp->icmp_ip.ip_p);
+			ND_TCHECK(dp->icmp_ip.ip_p);
 			(void)snprintf(buf, sizeof(buf),
 			    "%s protocol %d unreachable",
-			    ipaddr_string(&dp->icmp_ip.ip_dst),
+			    ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
 			    dp->icmp_ip.ip_p);
 			break;
 
 		case ICMP_UNREACH_PORT:
-			TCHECK(dp->icmp_ip.ip_p);
+			ND_TCHECK(dp->icmp_ip.ip_p);
 			oip = &dp->icmp_ip;
 			hlen = IP_HL(oip) * 4;
 			ouh = (struct udphdr *)(((u_char *)oip) + hlen);
-			TCHECK(ouh->uh_dport);
+			ND_TCHECK(ouh->uh_dport);
 			dport = EXTRACT_16BITS(&ouh->uh_dport);
 			switch (oip->ip_p) {
 
 			case IPPROTO_TCP:
 				(void)snprintf(buf, sizeof(buf),
 					"%s tcp port %s unreachable",
-					ipaddr_string(&oip->ip_dst),
+					ipaddr_string(ndo, &oip->ip_dst),
 					tcpport_string(dport));
 				break;
 
 			case IPPROTO_UDP:
 				(void)snprintf(buf, sizeof(buf),
 					"%s udp port %s unreachable",
-					ipaddr_string(&oip->ip_dst),
+					ipaddr_string(ndo, &oip->ip_dst),
 					udpport_string(dport));
 				break;
 
 			default:
 				(void)snprintf(buf, sizeof(buf),
 					"%s protocol %d port %d unreachable",
-					ipaddr_string(&oip->ip_dst),
+					ipaddr_string(ndo, &oip->ip_dst),
 					oip->ip_p, dport);
 				break;
 			}
@@ -418,11 +414,11 @@
 			if (mtu) {
 				(void)snprintf(buf, sizeof(buf),
 				    "%s unreachable - need to frag (mtu %d)",
-				    ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
+				    ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu);
 			} else {
 				(void)snprintf(buf, sizeof(buf),
 				    "%s unreachable - need to frag",
-				    ipaddr_string(&dp->icmp_ip.ip_dst));
+				    ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
 			}
 		    }
 			break;
@@ -431,18 +427,18 @@
 			fmt = tok2str(unreach2str, "#%d %%s unreachable",
 			    dp->icmp_code);
 			(void)snprintf(buf, sizeof(buf), fmt,
-			    ipaddr_string(&dp->icmp_ip.ip_dst));
+			    ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
 			break;
 		}
 		break;
 
 	case ICMP_REDIRECT:
-		TCHECK(dp->icmp_ip.ip_dst);
+		ND_TCHECK(dp->icmp_ip.ip_dst);
 		fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
 		    dp->icmp_code);
 		(void)snprintf(buf, sizeof(buf), fmt,
-		    ipaddr_string(&dp->icmp_ip.ip_dst),
-		    ipaddr_string(&dp->icmp_gwaddr));
+		    ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
+		    ipaddr_string(ndo, &dp->icmp_gwaddr));
 		break;
 
 	case ICMP_ROUTERADVERT:
@@ -455,7 +451,7 @@
 		cp = buf + strlen(buf);
 
 		ihp = (struct ih_rdiscovery *)&dp->icmp_void;
-		TCHECK(*ihp);
+		ND_TCHECK(*ihp);
 		(void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
 		cp = buf + strlen(buf);
 		lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
@@ -486,9 +482,9 @@
 		}
 		idp = (struct id_rdiscovery *)&dp->icmp_data;
 		while (num-- > 0) {
-			TCHECK(*idp);
+			ND_TCHECK(*idp);
 			(void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
-			    ipaddr_string(&idp->ird_addr),
+			    ipaddr_string(ndo, &idp->ird_addr),
 			    EXTRACT_32BITS(&idp->ird_pref));
 			cp = buf + strlen(buf);
 			++idp;
@@ -497,7 +493,7 @@
 		break;
 
 	case ICMP_TIMXCEED:
-		TCHECK(dp->icmp_ip.ip_dst);
+		ND_TCHECK(dp->icmp_ip.ip_dst);
 		switch (dp->icmp_code) {
 
 		case ICMP_TIMXCEED_INTRANS:
@@ -520,20 +516,20 @@
 			(void)snprintf(buf, sizeof(buf),
 			    "parameter problem - code %d", dp->icmp_code);
 		else {
-			TCHECK(dp->icmp_pptr);
+			ND_TCHECK(dp->icmp_pptr);
 			(void)snprintf(buf, sizeof(buf),
 			    "parameter problem - octet %d", dp->icmp_pptr);
 		}
 		break;
 
 	case ICMP_MASKREPLY:
-		TCHECK(dp->icmp_mask);
+		ND_TCHECK(dp->icmp_mask);
 		(void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
 		    EXTRACT_32BITS(&dp->icmp_mask));
 		break;
 
 	case ICMP_TSTAMP:
-		TCHECK(dp->icmp_seq);
+		ND_TCHECK(dp->icmp_seq);
 		(void)snprintf(buf, sizeof(buf),
 		    "time stamp query id %u seq %u",
 		    EXTRACT_16BITS(&dp->icmp_id),
@@ -541,7 +537,7 @@
 		break;
 
 	case ICMP_TSTAMPREPLY:
-		TCHECK(dp->icmp_ttime);
+		ND_TCHECK(dp->icmp_ttime);
 		(void)snprintf(buf, sizeof(buf),
 		    "time stamp reply id %u seq %u: org %s",
                                EXTRACT_16BITS(&dp->icmp_id),
@@ -558,19 +554,19 @@
 		str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
 		break;
 	}
-	(void)printf("ICMP %s, length %u", str, plen);
-	if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
-		u_int16_t sum, icmp_sum;
+	ND_PRINT((ndo, "ICMP %s, length %u", str, plen));
+	if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
+		uint16_t sum, icmp_sum;
 		struct cksum_vec vec[1];
-		if (TTEST2(*bp, plen)) {
-			vec[0].ptr = (const u_int8_t *)(void *)dp;
+		if (ND_TTEST2(*bp, plen)) {
+			vec[0].ptr = (const uint8_t *)(void *)dp;
 			vec[0].len = plen;
 			sum = in_cksum(vec, 1);
 			if (sum != 0) {
 				icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
-				(void)printf(" (wrong icmp cksum %x (->%x)!)",
+				ND_PRINT((ndo, " (wrong icmp cksum %x (->%x)!)",
 					     icmp_sum,
-					     in_cksum_shouldbe(icmp_sum, sum));
+					     in_cksum_shouldbe(icmp_sum, sum)));
 			}
 		}
 	}
@@ -579,22 +575,22 @@
          * print the remnants of the IP packet.
          * save the snaplength as this may get overidden in the IP printer.
          */
-	if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
+	if (ndo->ndo_vflag >= 1 && ICMP_ERRTYPE(dp->icmp_type)) {
 		bp += 8;
-		(void)printf("\n\t");
+		ND_PRINT((ndo, "\n\t"));
 		ip = (struct ip *)bp;
-		snaplen = snapend - bp;
-                snapend_save = snapend;
-		ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len));
-                snapend = snapend_save;
+		ndo->ndo_snaplen = ndo->ndo_snapend - bp;
+                snapend_save = ndo->ndo_snapend;
+		ip_print(ndo, bp, EXTRACT_16BITS(&ip->ip_len));
+                ndo->ndo_snapend = snapend_save;
 	}
 
         /*
          * Attempt to decode the MPLS extensions only for some ICMP types.
          */
-        if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
+        if (ndo->ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
 
-            TCHECK(*ext_dp);
+            ND_TCHECK(*ext_dp);
 
             /*
              * Check first if the mpls extension header shows a non-zero length.
@@ -603,54 +599,54 @@
              * however not all implementations set the length field proper.
              */
             if (!ext_dp->icmp_length) {
-                vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+                vec[0].ptr = (const uint8_t *)(void *)&ext_dp->icmp_ext_version_res;
                 vec[0].len = plen - ICMP_EXTD_MINLEN;
                 if (in_cksum(vec, 1)) {
                     return;
                 }
             }
 
-            printf("\n\tMPLS extension v%u",
-                   ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)));
-            
+            ND_PRINT((ndo, "\n\tMPLS extension v%u",
+                   ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res))));
+
             /*
              * Sanity checking of the header.
              */
             if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) !=
                 ICMP_MPLS_EXT_VERSION) {
-                printf(" packet not supported");
+                ND_PRINT((ndo, " packet not supported"));
                 return;
             }
 
             hlen = plen - ICMP_EXTD_MINLEN;
-            vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+            vec[0].ptr = (const uint8_t *)(void *)&ext_dp->icmp_ext_version_res;
             vec[0].len = hlen;
-            printf(", checksum 0x%04x (%scorrect), length %u",
+            ND_PRINT((ndo, ", checksum 0x%04x (%scorrect), length %u",
                    EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
                    in_cksum(vec, 1) ? "in" : "",
-                   hlen);
+                   hlen));
 
             hlen -= 4; /* subtract common header size */
-            obj_tptr = (u_int8_t *)ext_dp->icmp_ext_data;
+            obj_tptr = (uint8_t *)ext_dp->icmp_ext_data;
 
             while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) {
 
                 icmp_mpls_ext_object_header = (struct icmp_mpls_ext_object_header_t *)obj_tptr;
-                TCHECK(*icmp_mpls_ext_object_header);
+                ND_TCHECK(*icmp_mpls_ext_object_header);
                 obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length);
                 obj_class_num = icmp_mpls_ext_object_header->class_num;
                 obj_ctype = icmp_mpls_ext_object_header->ctype;
                 obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t);
 
-                printf("\n\t  %s Object (%u), Class-Type: %u, length %u",
+                ND_PRINT((ndo, "\n\t  %s Object (%u), Class-Type: %u, length %u",
                        tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num),
                        obj_class_num,
                        obj_ctype,
-                       obj_tlen);
+                       obj_tlen));
 
                 hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */
 
-                /* infinite loop protection */                
+                /* infinite loop protection */
                 if ((obj_class_num == 0) ||
                     (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) {
                     return;
@@ -661,15 +657,15 @@
                 case 1:
                     switch(obj_ctype) {
                     case 1:
-                        TCHECK2(*obj_tptr, 4);
+                        ND_TCHECK2(*obj_tptr, 4);
                         raw_label = EXTRACT_32BITS(obj_tptr);
-                        printf("\n\t    label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label));
+                        ND_PRINT((ndo, "\n\t    label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label)));
                         if (MPLS_STACK(raw_label))
-                            printf(", [S]");
-                        printf(", ttl %u", MPLS_TTL(raw_label));
+                            ND_PRINT((ndo, ", [S]"));
+                        ND_PRINT((ndo, ", ttl %u", MPLS_TTL(raw_label)));
                         break;
                     default:
-                        print_unknown_data(obj_tptr, "\n\t    ", obj_tlen);
+                        print_unknown_data(ndo, obj_tptr, "\n\t    ", obj_tlen);
                     }
                     break;
 
@@ -679,7 +675,7 @@
                 */
                 case 2:
                 default:
-                    print_unknown_data(obj_tptr, "\n\t    ", obj_tlen);
+                    print_unknown_data(ndo, obj_tptr, "\n\t    ", obj_tlen);
                     break;
                 }
                 if (hlen < obj_tlen)
@@ -691,5 +687,11 @@
 
 	return;
 trunc:
-	fputs("[|icmp]", stdout);
+	ND_PRINT((ndo, "[|icmp]"));
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-icmp6.c b/print-icmp6.c
index 811e5a0..81563e6 100644
--- a/print-icmp6.c
+++ b/print-icmp6.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -40,30 +36,461 @@
 #include "extract.h"
 
 #include "ip6.h"
-#include "icmp6.h"
 #include "ipproto.h"
 
 #include "udp.h"
 #include "ah.h"
 
+/*	NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp 	*/
+/*	$KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
+ */
+
+struct icmp6_hdr {
+	uint8_t		icmp6_type;	/* type field */
+	uint8_t		icmp6_code;	/* code field */
+	uint16_t	icmp6_cksum;	/* checksum field */
+	union {
+		uint32_t	icmp6_un_data32[1]; /* type-specific field */
+		uint16_t	icmp6_un_data16[2]; /* type-specific field */
+		uint8_t		icmp6_un_data8[4];  /* type-specific field */
+	} icmp6_dataun;
+};
+
+#define icmp6_data32	icmp6_dataun.icmp6_un_data32
+#define icmp6_data16	icmp6_dataun.icmp6_un_data16
+#define icmp6_data8	icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr	icmp6_data32[0]		/* parameter prob */
+#define icmp6_mtu	icmp6_data32[0]		/* packet too big */
+#define icmp6_id	icmp6_data16[0]		/* echo request/reply */
+#define icmp6_seq	icmp6_data16[1]		/* echo request/reply */
+#define icmp6_maxdelay	icmp6_data16[0]		/* mcast group membership */
+
+#define ICMP6_DST_UNREACH		1	/* dest unreachable, codes: */
+#define ICMP6_PACKET_TOO_BIG		2	/* packet too big */
+#define ICMP6_TIME_EXCEEDED		3	/* time exceeded, code: */
+#define ICMP6_PARAM_PROB		4	/* ip6 header bad */
+
+#define ICMP6_ECHO_REQUEST		128	/* echo service */
+#define ICMP6_ECHO_REPLY		129	/* echo reply */
+#define ICMP6_MEMBERSHIP_QUERY		130	/* group membership query */
+#define MLD6_LISTENER_QUERY		130 	/* multicast listener query */
+#define ICMP6_MEMBERSHIP_REPORT		131	/* group membership report */
+#define MLD6_LISTENER_REPORT		131	/* multicast listener report */
+#define ICMP6_MEMBERSHIP_REDUCTION	132	/* group membership termination */
+#define MLD6_LISTENER_DONE		132	/* multicast listener done */
+
+#define ND_ROUTER_SOLICIT		133	/* router solicitation */
+#define ND_ROUTER_ADVERT		134	/* router advertisement */
+#define ND_NEIGHBOR_SOLICIT		135	/* neighbor solicitation */
+#define ND_NEIGHBOR_ADVERT		136	/* neighbor advertisement */
+#define ND_REDIRECT			137	/* redirect */
+
+#define ICMP6_ROUTER_RENUMBERING	138	/* router renumbering */
+
+#define ICMP6_WRUREQUEST		139	/* who are you request */
+#define ICMP6_WRUREPLY			140	/* who are you reply */
+#define ICMP6_FQDN_QUERY		139	/* FQDN query */
+#define ICMP6_FQDN_REPLY		140	/* FQDN reply */
+#define ICMP6_NI_QUERY			139	/* node information request */
+#define ICMP6_NI_REPLY			140	/* node information reply */
+#define IND_SOLICIT			141	/* inverse neighbor solicitation */
+#define IND_ADVERT			142	/* inverse neighbor advertisement */
+
+#define ICMP6_V2_MEMBERSHIP_REPORT	143	/* v2 membership report */
+#define MLDV2_LISTENER_REPORT		143	/* v2 multicast listener report */
+#define ICMP6_HADISCOV_REQUEST		144
+#define ICMP6_HADISCOV_REPLY		145
+#define ICMP6_MOBILEPREFIX_SOLICIT	146
+#define ICMP6_MOBILEPREFIX_ADVERT	147
+
+#define MLD6_MTRACE_RESP		200	/* mtrace response(to sender) */
+#define MLD6_MTRACE			201	/* mtrace messages */
+
+#define ICMP6_MAXTYPE			201
+
+#define ICMP6_DST_UNREACH_NOROUTE	0	/* no route to destination */
+#define ICMP6_DST_UNREACH_ADMIN	 	1	/* administratively prohibited */
+#define ICMP6_DST_UNREACH_NOTNEIGHBOR	2	/* not a neighbor(obsolete) */
+#define ICMP6_DST_UNREACH_BEYONDSCOPE	2	/* beyond scope of source address */
+#define ICMP6_DST_UNREACH_ADDR		3	/* address unreachable */
+#define ICMP6_DST_UNREACH_NOPORT	4	/* port unreachable */
+
+#define ICMP6_TIME_EXCEED_TRANSIT 	0	/* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_REASSEMBLY	1	/* ttl==0 in reass */
+
+#define ICMP6_PARAMPROB_HEADER 	 	0	/* erroneous header field */
+#define ICMP6_PARAMPROB_NEXTHEADER	1	/* unrecognized next header */
+#define ICMP6_PARAMPROB_OPTION		2	/* unrecognized option */
+
+#define ICMP6_INFOMSG_MASK		0x80	/* all informational messages */
+
+#define ICMP6_NI_SUBJ_IPV6	0	/* Query Subject is an IPv6 address */
+#define ICMP6_NI_SUBJ_FQDN	1	/* Query Subject is a Domain name */
+#define ICMP6_NI_SUBJ_IPV4	2	/* Query Subject is an IPv4 address */
+
+#define ICMP6_NI_SUCCESS	0	/* node information successful reply */
+#define ICMP6_NI_REFUSED	1	/* node information request is refused */
+#define ICMP6_NI_UNKNOWN	2	/* unknown Qtype */
+
+#define ICMP6_ROUTER_RENUMBERING_COMMAND  0	/* rr command */
+#define ICMP6_ROUTER_RENUMBERING_RESULT   1	/* rr result */
+#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255	/* rr seq num reset */
+
+/* Used in kernel only */
+#define ND_REDIRECT_ONLINK	0	/* redirect to an on-link node */
+#define ND_REDIRECT_ROUTER	1	/* redirect to a better router */
+
+/*
+ * Multicast Listener Discovery
+ */
+struct mld6_hdr {
+	struct icmp6_hdr	mld6_hdr;
+	struct in6_addr		mld6_addr; /* multicast address */
+};
+
+#define mld6_type	mld6_hdr.icmp6_type
+#define mld6_code	mld6_hdr.icmp6_code
+#define mld6_cksum	mld6_hdr.icmp6_cksum
+#define mld6_maxdelay	mld6_hdr.icmp6_data16[0]
+#define mld6_reserved	mld6_hdr.icmp6_data16[1]
+
+#define MLD_MINLEN	24
+#define MLDV2_MINLEN	28
+
+/*
+ * Neighbor Discovery
+ */
+
+struct nd_router_solicit {	/* router solicitation */
+	struct icmp6_hdr 	nd_rs_hdr;
+	/* could be followed by options */
+};
+
+#define nd_rs_type	nd_rs_hdr.icmp6_type
+#define nd_rs_code	nd_rs_hdr.icmp6_code
+#define nd_rs_cksum	nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved	nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert {	/* router advertisement */
+	struct icmp6_hdr	nd_ra_hdr;
+	uint32_t		nd_ra_reachable;	/* reachable time */
+	uint32_t		nd_ra_retransmit;	/* retransmit timer */
+	/* could be followed by options */
+};
+
+#define nd_ra_type		nd_ra_hdr.icmp6_type
+#define nd_ra_code		nd_ra_hdr.icmp6_code
+#define nd_ra_cksum		nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit	nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved	nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED	0x80
+#define ND_RA_FLAG_OTHER	0x40
+#define ND_RA_FLAG_HOME_AGENT	0x20
+
+/*
+ * Router preference values based on draft-draves-ipngwg-router-selection-01.
+ * These are non-standard definitions.
+ */
+#define ND_RA_FLAG_RTPREF_MASK	0x18 /* 00011000 */
+
+#define ND_RA_FLAG_RTPREF_HIGH	0x08 /* 00001000 */
+#define ND_RA_FLAG_RTPREF_MEDIUM	0x00 /* 00000000 */
+#define ND_RA_FLAG_RTPREF_LOW	0x18 /* 00011000 */
+#define ND_RA_FLAG_RTPREF_RSV	0x10 /* 00010000 */
+
+#define nd_ra_router_lifetime	nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit {	/* neighbor solicitation */
+	struct icmp6_hdr	nd_ns_hdr;
+	struct in6_addr		nd_ns_target;	/*target address */
+	/* could be followed by options */
+};
+
+#define nd_ns_type		nd_ns_hdr.icmp6_type
+#define nd_ns_code		nd_ns_hdr.icmp6_code
+#define nd_ns_cksum		nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved		nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert {	/* neighbor advertisement */
+	struct icmp6_hdr	nd_na_hdr;
+	struct in6_addr		nd_na_target;	/* target address */
+	/* could be followed by options */
+};
+
+#define nd_na_type		nd_na_hdr.icmp6_type
+#define nd_na_code		nd_na_hdr.icmp6_code
+#define nd_na_cksum		nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved	nd_na_hdr.icmp6_data32[0]
+
+#define ND_NA_FLAG_ROUTER		0x80000000
+#define ND_NA_FLAG_SOLICITED		0x40000000
+#define ND_NA_FLAG_OVERRIDE		0x20000000
+
+struct nd_redirect {		/* redirect */
+	struct icmp6_hdr	nd_rd_hdr;
+	struct in6_addr		nd_rd_target;	/* target address */
+	struct in6_addr		nd_rd_dst;	/* destination address */
+	/* could be followed by options */
+};
+
+#define nd_rd_type		nd_rd_hdr.icmp6_type
+#define nd_rd_code		nd_rd_hdr.icmp6_code
+#define nd_rd_cksum		nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved		nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr {		/* Neighbor discovery option header */
+	uint8_t		nd_opt_type;
+	uint8_t		nd_opt_len;
+	/* followed by option specific data*/
+};
+
+#define ND_OPT_SOURCE_LINKADDR		1
+#define ND_OPT_TARGET_LINKADDR		2
+#define ND_OPT_PREFIX_INFORMATION	3
+#define ND_OPT_REDIRECTED_HEADER	4
+#define ND_OPT_MTU			5
+#define ND_OPT_ADVINTERVAL		7
+#define ND_OPT_HOMEAGENT_INFO		8
+#define ND_OPT_ROUTE_INFO		24	/* RFC4191 */
+#define ND_OPT_RDNSS			25
+#define ND_OPT_DNSSL			31
+
+struct nd_opt_prefix_info {	/* prefix information */
+	uint8_t		nd_opt_pi_type;
+	uint8_t		nd_opt_pi_len;
+	uint8_t		nd_opt_pi_prefix_len;
+	uint8_t		nd_opt_pi_flags_reserved;
+	uint8_t		nd_opt_pi_valid_time[4];
+	uint8_t		nd_opt_pi_preferred_time[4];
+	uint8_t		nd_opt_pi_reserved2[4];
+	struct in6_addr	nd_opt_pi_prefix;
+};
+
+#define ND_OPT_PI_FLAG_ONLINK		0x80
+#define ND_OPT_PI_FLAG_AUTO		0x40
+#define ND_OPT_PI_FLAG_ROUTER		0x20	/*2292bis*/
+
+struct nd_opt_rd_hdr {         /* redirected header */
+	uint8_t		nd_opt_rh_type;
+	uint8_t		nd_opt_rh_len;
+	uint16_t	nd_opt_rh_reserved1;
+	uint32_t	nd_opt_rh_reserved2;
+	/* followed by IP header and data */
+};
+
+struct nd_opt_mtu {		/* MTU option */
+	uint8_t		nd_opt_mtu_type;
+	uint8_t		nd_opt_mtu_len;
+	uint16_t	nd_opt_mtu_reserved;
+	uint32_t	nd_opt_mtu_mtu;
+};
+
+struct nd_opt_rdnss {		/* RDNSS RFC 6106 5.1 */
+	uint8_t		nd_opt_rdnss_type;
+	uint8_t		nd_opt_rdnss_len;
+	uint16_t	nd_opt_rdnss_reserved;
+	uint32_t	nd_opt_rdnss_lifetime;
+	struct in6_addr nd_opt_rdnss_addr[1];	/* variable-length */
+};
+
+struct nd_opt_dnssl {		/* DNSSL RFC 6106 5.2 */
+	uint8_t  nd_opt_dnssl_type;
+	uint8_t  nd_opt_dnssl_len;
+	uint16_t nd_opt_dnssl_reserved;
+	uint32_t nd_opt_dnssl_lifetime;
+	/* followed by list of DNS search domains, variable-length */
+};
+
+struct nd_opt_advinterval {	/* Advertisement interval option */
+	uint8_t		nd_opt_adv_type;
+	uint8_t		nd_opt_adv_len;
+	uint16_t	nd_opt_adv_reserved;
+	uint32_t	nd_opt_adv_interval;
+};
+
+struct nd_opt_homeagent_info {	/* Home Agent info */
+	uint8_t		nd_opt_hai_type;
+	uint8_t		nd_opt_hai_len;
+	uint16_t	nd_opt_hai_reserved;
+	int16_t		nd_opt_hai_preference;
+	uint16_t	nd_opt_hai_lifetime;
+};
+
+struct nd_opt_route_info {	/* route info */
+	uint8_t		nd_opt_rti_type;
+	uint8_t		nd_opt_rti_len;
+	uint8_t		nd_opt_rti_prefixlen;
+	uint8_t		nd_opt_rti_flags;
+	uint32_t	nd_opt_rti_lifetime;
+	/* prefix follows */
+};
+
+/*
+ * icmp6 namelookup
+ */
+
+struct icmp6_namelookup {
+	struct icmp6_hdr 	icmp6_nl_hdr;
+	uint8_t		icmp6_nl_nonce[8];
+	int32_t		icmp6_nl_ttl;
+#if 0
+	uint8_t		icmp6_nl_len;
+	uint8_t		icmp6_nl_name[3];
+#endif
+	/* could be followed by options */
+};
+
+/*
+ * icmp6 node information
+ */
+struct icmp6_nodeinfo {
+	struct icmp6_hdr icmp6_ni_hdr;
+	uint8_t icmp6_ni_nonce[8];
+	/* could be followed by reply data */
+};
+
+#define ni_type		icmp6_ni_hdr.icmp6_type
+#define ni_code		icmp6_ni_hdr.icmp6_code
+#define ni_cksum	icmp6_ni_hdr.icmp6_cksum
+#define ni_qtype	icmp6_ni_hdr.icmp6_data16[0]
+#define ni_flags	icmp6_ni_hdr.icmp6_data16[1]
+
+#define NI_QTYPE_NOOP		0 /* NOOP  */
+#define NI_QTYPE_SUPTYPES	1 /* Supported Qtypes */
+#define NI_QTYPE_FQDN		2 /* FQDN (draft 04) */
+#define NI_QTYPE_DNSNAME	2 /* DNS Name */
+#define NI_QTYPE_NODEADDR	3 /* Node Addresses */
+#define NI_QTYPE_IPV4ADDR	4 /* IPv4 Addresses */
+
+/* network endian */
+#define NI_SUPTYPE_FLAG_COMPRESS	((uint16_t)htons(0x1))
+#define NI_FQDN_FLAG_VALIDTTL		((uint16_t)htons(0x1))
+
+/* network endian */
+#define NI_NODEADDR_FLAG_TRUNCATE	((uint16_t)htons(0x1))
+#define NI_NODEADDR_FLAG_ALL		((uint16_t)htons(0x2))
+#define NI_NODEADDR_FLAG_COMPAT		((uint16_t)htons(0x4))
+#define NI_NODEADDR_FLAG_LINKLOCAL	((uint16_t)htons(0x8))
+#define NI_NODEADDR_FLAG_SITELOCAL	((uint16_t)htons(0x10))
+#define NI_NODEADDR_FLAG_GLOBAL		((uint16_t)htons(0x20))
+#define NI_NODEADDR_FLAG_ANYCAST	((uint16_t)htons(0x40)) /* just experimental. not in spec */
+
+struct ni_reply_fqdn {
+	uint32_t ni_fqdn_ttl;	/* TTL */
+	uint8_t ni_fqdn_namelen; /* length in octets of the FQDN */
+	uint8_t ni_fqdn_name[3]; /* XXX: alignment */
+};
+
+/*
+ * Router Renumbering. as router-renum-08.txt
+ */
+struct icmp6_router_renum {	/* router renumbering header */
+	struct icmp6_hdr	rr_hdr;
+	uint8_t		rr_segnum;
+	uint8_t		rr_flags;
+	uint16_t	rr_maxdelay;
+	uint32_t	rr_reserved;
+};
+#define ICMP6_RR_FLAGS_TEST		0x80
+#define ICMP6_RR_FLAGS_REQRESULT	0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY	0x20
+#define ICMP6_RR_FLAGS_SPECSITE		0x10
+#define ICMP6_RR_FLAGS_PREVDONE		0x08
+
+#define rr_type		rr_hdr.icmp6_type
+#define rr_code		rr_hdr.icmp6_code
+#define rr_cksum	rr_hdr.icmp6_cksum
+#define rr_seqnum 	rr_hdr.icmp6_data32[0]
+
+struct rr_pco_match {		/* match prefix part */
+	uint8_t		rpm_code;
+	uint8_t		rpm_len;
+	uint8_t		rpm_ordinal;
+	uint8_t		rpm_matchlen;
+	uint8_t		rpm_minlen;
+	uint8_t		rpm_maxlen;
+	uint16_t	rpm_reserved;
+	struct	in6_addr	rpm_prefix;
+};
+
+#define RPM_PCO_ADD		1
+#define RPM_PCO_CHANGE		2
+#define RPM_PCO_SETGLOBAL	3
+#define RPM_PCO_MAX		4
+
+struct rr_pco_use {		/* use prefix part */
+	uint8_t		rpu_uselen;
+	uint8_t		rpu_keeplen;
+	uint8_t		rpu_ramask;
+	uint8_t		rpu_raflags;
+	uint32_t	rpu_vltime;
+	uint32_t	rpu_pltime;
+	uint32_t	rpu_flags;
+	struct	in6_addr rpu_prefix;
+};
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK	0x80
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO	0x40
+
+/* network endian */
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     ((uint32_t)htonl(0x80000000))
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     ((uint32_t)htonl(0x40000000))
+
+struct rr_result {		/* router renumbering result message */
+	uint16_t	rrr_flags;
+	uint8_t		rrr_ordinal;
+	uint8_t		rrr_matchedlen;
+	uint32_t	rrr_ifid;
+	struct	in6_addr rrr_prefix;
+};
+/* network endian */
+#define ICMP6_RR_RESULT_FLAGS_OOB		((uint16_t)htons(0x0002))
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN		((uint16_t)htons(0x0001))
+
 static const char *get_rtpref(u_int);
-static const char *get_lifetime(u_int32_t);
-static void print_lladdr(const u_char *, size_t);
-static void icmp6_opt_print(const u_char *, int);
-static void mld6_print(const u_char *);
-static void mldv2_report_print(const u_char *, u_int);
-static void mldv2_query_print(const u_char *, u_int);
-static struct udphdr *get_upperlayer(u_char *, u_int *);
-static void dnsname_print(const u_char *, const u_char *);
-static void icmp6_nodeinfo_print(u_int, const u_char *, const u_char *);
-static void icmp6_rrenum_print(const u_char *, const u_char *);
+static const char *get_lifetime(uint32_t);
+static void print_lladdr(netdissect_options *ndo, const u_char *, size_t);
+static void icmp6_opt_print(netdissect_options *ndo, const u_char *, int);
+static void mld6_print(netdissect_options *ndo, const u_char *);
+static void mldv2_report_print(netdissect_options *ndo, const u_char *, u_int);
+static void mldv2_query_print(netdissect_options *ndo, const u_char *, u_int);
+static const struct udphdr *get_upperlayer(netdissect_options *ndo, const u_char *, u_int *);
+static void dnsname_print(netdissect_options *ndo, const u_char *, const u_char *);
+static void icmp6_nodeinfo_print(netdissect_options *ndo, u_int, const u_char *, const u_char *);
+static void icmp6_rrenum_print(netdissect_options *ndo, const u_char *, const u_char *);
 
 #ifndef abs
 #define abs(a)	((0 < (a)) ? (a) : -(a))
 #endif
 
-/* inline the various RPL definitions */
-#define ND_RPL_MESSAGE 0x9B
+#include "rpl.h"
 
 static const struct tok icmp6_type_values[] = {
     { ICMP6_DST_UNREACH, "destination unreachable"},
@@ -168,11 +595,11 @@
 }
 
 static const char *
-get_lifetime(u_int32_t v)
+get_lifetime(uint32_t v)
 {
 	static char buf[20];
 
-	if (v == (u_int32_t)~0UL)
+	if (v == (uint32_t)~0UL)
 		return "infinity";
 	else {
 		snprintf(buf, sizeof(buf), "%us", v);
@@ -181,16 +608,16 @@
 }
 
 static void
-print_lladdr(const u_int8_t *p, size_t l)
+print_lladdr(netdissect_options *ndo, const uint8_t *p, size_t l)
 {
-	const u_int8_t *ep, *q;
+	const uint8_t *ep, *q;
 
 	q = p;
 	ep = p + l;
 	while (l > 0 && q < ep) {
 		if (q > p)
-			printf(":");
-		printf("%02x", *q++);
+                        ND_PRINT((ndo,":"));
+		ND_PRINT((ndo,"%02x", *q++));
 		l--;
 	}
 }
@@ -198,93 +625,249 @@
 static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
 	u_int len)
 {
-	return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)icp, len,
-	    IPPROTO_ICMPV6));
+	return nextproto6_cksum(ip6, (const uint8_t *)(void *)icp, len, len,
+				IPPROTO_ICMPV6);
 }
 
-enum ND_RPL_CODE {
-        ND_RPL_DIS   =0x00,
-        ND_RPL_DIO   =0x01,
-        ND_RPL_DAO   =0x02,
-        ND_RPL_DAO_ACK=0x03,
-        ND_RPL_SDIS  =0x80,
-        ND_RPL_SDIO  =0x81,
-        ND_RPL_SDAO  =0x82,
-        ND_RPL_SDAO_ACK=0x83,
-        ND_RPL_SCC   =0x8A,
+const struct tok rpl_mop_values[] = {
+        { RPL_DIO_NONSTORING,         "nonstoring"},
+        { RPL_DIO_STORING,            "storing"},
+        { RPL_DIO_NONSTORING_MULTICAST, "nonstoring-multicast"},
+        { RPL_DIO_STORING_MULTICAST,  "storing-multicast"},
+        { 0, NULL},
 };
 
-enum ND_RPL_DIO_FLAGS {
-        ND_RPL_DIO_GROUNDED = 0x80,
-        ND_RPL_DIO_DATRIG   = 0x40,
-        ND_RPL_DIO_DASUPPORT= 0x20,
-        ND_RPL_DIO_RES4     = 0x10,
-        ND_RPL_DIO_RES3     = 0x08,
-        ND_RPL_DIO_PRF_MASK = 0x07,  /* 3-bit preference */
+const struct tok rpl_subopt_values[] = {
+        { RPL_OPT_PAD0, "pad0"},
+        { RPL_OPT_PADN, "padN"},
+        { RPL_DIO_METRICS, "metrics"},
+        { RPL_DIO_ROUTINGINFO, "routinginfo"},
+        { RPL_DIO_CONFIG,    "config"},
+        { RPL_DAO_RPLTARGET, "rpltarget"},
+        { RPL_DAO_TRANSITINFO, "transitinfo"},
+        { RPL_DIO_DESTPREFIX, "destprefix"},
+        { RPL_DAO_RPLTARGET_DESC, "rpltargetdesc"},
+        { 0, NULL},
 };
 
-struct nd_rpl_dio {
-        u_int8_t rpl_flags;
-        u_int8_t rpl_seq;
-        u_int8_t rpl_instanceid;
-        u_int8_t rpl_dagrank;
-        u_int8_t rpl_dagid[16];
-};
+static void
+rpl_format_dagid(char dagid_str[65], const u_char *dagid)
+{
+        char *d = dagid_str;
+        int  i;
+
+        for(i=0;i<16;i++) {
+                if(isprint(dagid[i])) {
+                        *d++ = dagid[i];
+                } else {
+                        snprintf(d,5,"0x%02x", dagid[i]); /* 4 + null char */
+                        d += 4;
+                }
+        }
+        *d++ = '\0';
+}
+
+static void
+rpl_dio_printopt(netdissect_options *ndo,
+                 const struct rpl_dio_genoption *opt,
+                 u_int length)
+{
+        if(length < RPL_DIO_GENOPTION_LEN) return;
+        length -= RPL_DIO_GENOPTION_LEN;
+
+        ND_TCHECK(opt->rpl_dio_len);
+
+        while((opt->rpl_dio_type == RPL_OPT_PAD0 &&
+               (u_char *)opt < ndo->ndo_snapend) ||
+              ND_TTEST2(*opt,(opt->rpl_dio_len+2))) {
+
+                unsigned int optlen = opt->rpl_dio_len+2;
+                if(opt->rpl_dio_type == RPL_OPT_PAD0) {
+                        optlen = 1;
+                        ND_PRINT((ndo, " opt:pad0"));
+                } else {
+                        ND_PRINT((ndo, " opt:%s len:%u ",
+                                  tok2str(rpl_subopt_values, "%subopt:%u", opt->rpl_dio_type),
+                                  optlen));
+                        if(ndo->ndo_vflag > 2) {
+                                unsigned int paylen = opt->rpl_dio_len;
+                                if(paylen > length) paylen = length;
+                                hex_print(ndo,
+                                          " ",
+                                          ((uint8_t *)opt) + RPL_DIO_GENOPTION_LEN,  /* content of DIO option */
+                                          paylen);
+                        }
+                }
+                opt = (struct rpl_dio_genoption *)(((char *)opt) + optlen);
+                length -= optlen;
+        }
+        return;
+trunc:
+	ND_PRINT((ndo," [|truncated]"));
+	return;
+}
+
+static void
+rpl_dio_print(netdissect_options *ndo,
+              const u_char *bp, u_int length)
+{
+        const struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
+        char dagid_str[65];
+
+        ND_TCHECK(*dio);
+        rpl_format_dagid(dagid_str, dio->rpl_dagid);
+
+        ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
+                  dagid_str,
+                  dio->rpl_dtsn,
+                  dio->rpl_instanceid,
+                  EXTRACT_16BITS(&dio->rpl_dagrank),
+                  RPL_DIO_GROUNDED(dio->rpl_mopprf) ? "grounded,":"",
+                  tok2str(rpl_mop_values, "mop%u", RPL_DIO_MOP(dio->rpl_mopprf)),
+                  RPL_DIO_PRF(dio->rpl_mopprf)));
+
+        if(ndo->ndo_vflag > 1) {
+                struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)&dio[1];
+                rpl_dio_printopt(ndo, opt, length);
+        }
+	return;
+trunc:
+	ND_PRINT((ndo," [|truncated]"));
+	return;
+}
+
+static void
+rpl_dao_print(netdissect_options *ndo,
+              const u_char *bp, u_int length)
+{
+        const struct nd_rpl_dao *dao = (struct nd_rpl_dao *)bp;
+        char dagid_str[65];
+
+        ND_TCHECK(*dao);
+        if (length < ND_RPL_DAO_MIN_LEN)
+        	goto tooshort;
+
+        strcpy(dagid_str,"<elided>");
+        bp += ND_RPL_DAO_MIN_LEN;
+        length -= ND_RPL_DAO_MIN_LEN;
+        if(RPL_DAO_D(dao->rpl_flags)) {
+                ND_TCHECK2(dao->rpl_dagid, DAGID_LEN);
+                if (length < DAGID_LEN)
+                	goto tooshort;
+                rpl_format_dagid(dagid_str, dao->rpl_dagid);
+                bp += DAGID_LEN;
+                length -= DAGID_LEN;
+        }
+
+        ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u%s%s,%02x]",
+                  dagid_str,
+                  dao->rpl_daoseq,
+                  dao->rpl_instanceid,
+                  RPL_DAO_K(dao->rpl_flags) ? ",acK":"",
+                  RPL_DAO_D(dao->rpl_flags) ? ",Dagid":"",
+                  dao->rpl_flags));
+
+        if(ndo->ndo_vflag > 1) {
+                const struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)bp;
+                rpl_dio_printopt(ndo, opt, length);
+        }
+	return;
+
+trunc:
+	ND_PRINT((ndo," [|truncated]"));
+	return;
+
+tooshort:
+	ND_PRINT((ndo," [|length too short]"));
+	return;
+}
+
+static void
+rpl_daoack_print(netdissect_options *ndo,
+                 const u_char *bp, u_int length)
+{
+        const struct nd_rpl_daoack *daoack = (struct nd_rpl_daoack *)bp;
+        char dagid_str[65];
+
+        ND_TCHECK2(*daoack, ND_RPL_DAOACK_MIN_LEN);
+        if (length < ND_RPL_DAOACK_MIN_LEN)
+        	goto tooshort;
+
+        strcpy(dagid_str,"<elided>");
+        bp += ND_RPL_DAOACK_MIN_LEN;
+        length -= ND_RPL_DAOACK_MIN_LEN;
+        if(RPL_DAOACK_D(daoack->rpl_flags)) {
+                ND_TCHECK2(daoack->rpl_dagid, 16);
+                if (length < DAGID_LEN)
+                	goto tooshort;
+                rpl_format_dagid(dagid_str, daoack->rpl_dagid);
+                bp += DAGID_LEN;
+                length -= DAGID_LEN;
+        }
+
+        ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,status:%u]",
+                  dagid_str,
+                  daoack->rpl_daoseq,
+                  daoack->rpl_instanceid,
+                  daoack->rpl_status));
+
+        /* no officially defined options for DAOACK, but print any we find */
+        if(ndo->ndo_vflag > 1) {
+                const struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)bp;
+                rpl_dio_printopt(ndo, opt, length);
+        }
+	return;
+
+trunc:
+	ND_PRINT((ndo," [|dao-truncated]"));
+	return;
+
+tooshort:
+	ND_PRINT((ndo," [|dao-length too short]"));
+	return;
+}
 
 static void
 rpl_print(netdissect_options *ndo,
           const struct icmp6_hdr *hdr,
-          const u_char *bp, u_int length _U_)
+          const u_char *bp, u_int length)
 {
-        struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
         int secured = hdr->icmp6_code & 0x80;
         int basecode= hdr->icmp6_code & 0x7f;
 
-        ND_TCHECK(dio->rpl_dagid);
-
         if(secured) {
-                ND_PRINT((ndo, ", (SEC)"));
+                ND_PRINT((ndo, ", (SEC) [worktodo]"));
+                /* XXX
+                 * the next header pointer needs to move forward to
+                 * skip the secure part.
+                 */
+                return;
         } else {
                 ND_PRINT((ndo, ", (CLR)"));
         }
-                
+
         switch(basecode) {
-        case ND_RPL_DIS:
+        case ND_RPL_DAG_IS:
                 ND_PRINT((ndo, "DODAG Information Solicitation"));
                 if(ndo->ndo_vflag) {
                 }
                 break;
-        case ND_RPL_DIO:
+        case ND_RPL_DAG_IO:
                 ND_PRINT((ndo, "DODAG Information Object"));
                 if(ndo->ndo_vflag) {
-                        char dagid[65];
-                        char *d = dagid;
-                        int  i;
-                        for(i=0;i<16;i++) {
-                                if(isprint(dio->rpl_dagid[i])) {
-                                        *d++ = dio->rpl_dagid[i];
-                                } else {
-                                        int cnt=snprintf(d,4,"0x%02x",
-                                                         dio->rpl_dagid[i]);
-                                        d += cnt;
-                                }
-                        }
-                        *d++ = '\0';
-                        ND_PRINT((ndo, " [seq:%u,instance:%u,rank:%u,dagid:%s]",
-                                  dio->rpl_seq,
-                                  dio->rpl_instanceid,
-                                  dio->rpl_dagrank,
-                                  dagid));
+                        rpl_dio_print(ndo, bp, length);
                 }
                 break;
         case ND_RPL_DAO:
                 ND_PRINT((ndo, "Destination Advertisement Object"));
                 if(ndo->ndo_vflag) {
+                        rpl_dao_print(ndo, bp, length);
                 }
                 break;
         case ND_RPL_DAO_ACK:
                 ND_PRINT((ndo, "Destination Advertisement Object Ack"));
                 if(ndo->ndo_vflag) {
+                        rpl_daoack_print(ndo, bp, length);
                 }
                 break;
         default:
@@ -292,10 +875,13 @@
                 break;
         }
 	return;
+
+#if 0
 trunc:
 	ND_PRINT((ndo," [|truncated]"));
 	return;
-        
+#endif
+
 }
 
 
@@ -315,167 +901,167 @@
 	ip = (struct ip6_hdr *)bp2;
 	oip = (struct ip6_hdr *)(dp + 1);
 	/* 'ep' points to the end of available data. */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 
-	TCHECK(dp->icmp6_cksum);
+	ND_TCHECK(dp->icmp6_cksum);
 
-	if (vflag && !fragmented) {
-		u_int16_t sum, udp_sum;
+	if (ndo->ndo_vflag && !fragmented) {
+		uint16_t sum, udp_sum;
 
-		if (TTEST2(bp[0], length)) {
+		if (ND_TTEST2(bp[0], length)) {
 			udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum);
 			sum = icmp6_cksum(ip, dp, length);
 			if (sum != 0)
-				(void)printf("[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
-				    udp_sum,
-				    in_cksum_shouldbe(udp_sum, sum));
+				ND_PRINT((ndo,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
+                                                udp_sum,
+                                                in_cksum_shouldbe(udp_sum, sum)));
 			else
-				(void)printf("[icmp6 sum ok] ");
+				ND_PRINT((ndo,"[icmp6 sum ok] "));
 		}
 	}
 
-        printf("ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type));
+        ND_PRINT((ndo,"ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type)));
 
         /* display cosmetics: print the packet length for printer that use the vflag now */
-        if (vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT ||
+        if (ndo->ndo_vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT ||
                       dp->icmp6_type == ND_ROUTER_ADVERT ||
                       dp->icmp6_type == ND_NEIGHBOR_ADVERT ||
                       dp->icmp6_type == ND_NEIGHBOR_SOLICIT ||
                       dp->icmp6_type == ND_REDIRECT ||
                       dp->icmp6_type == ICMP6_HADISCOV_REPLY ||
                       dp->icmp6_type == ICMP6_MOBILEPREFIX_ADVERT ))
-            printf(", length %u", length);
-                      
+                ND_PRINT((ndo,", length %u", length));
+
 	switch (dp->icmp6_type) {
 	case ICMP6_DST_UNREACH:
-		TCHECK(oip->ip6_dst);
-                printf(", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code));
+		ND_TCHECK(oip->ip6_dst);
+                ND_PRINT((ndo,", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code)));
 		switch (dp->icmp6_code) {
 
 		case ICMP6_DST_UNREACH_NOROUTE: /* fall through */
 		case ICMP6_DST_UNREACH_ADMIN:
 		case ICMP6_DST_UNREACH_ADDR:
-                        printf(" %s",ip6addr_string(&oip->ip6_dst));
+                        ND_PRINT((ndo," %s",ip6addr_string(ndo, &oip->ip6_dst)));
                         break;
 		case ICMP6_DST_UNREACH_BEYONDSCOPE:
-			printf(" %s, source address %s",
-			       ip6addr_string(&oip->ip6_dst),
-			       ip6addr_string(&oip->ip6_src));
+			ND_PRINT((ndo," %s, source address %s",
+			       ip6addr_string(ndo, &oip->ip6_dst),
+                                  ip6addr_string(ndo, &oip->ip6_src)));
 			break;
 		case ICMP6_DST_UNREACH_NOPORT:
-			if ((ouh = get_upperlayer((u_char *)oip, &prot))
+			if ((ouh = get_upperlayer(ndo, (u_char *)oip, &prot))
 			    == NULL)
 				goto trunc;
 
 			dport = EXTRACT_16BITS(&ouh->uh_dport);
 			switch (prot) {
 			case IPPROTO_TCP:
-				printf(", %s tcp port %s",
-					ip6addr_string(&oip->ip6_dst),
-					tcpport_string(dport));
+				ND_PRINT((ndo,", %s tcp port %s",
+					ip6addr_string(ndo, &oip->ip6_dst),
+                                          tcpport_string(dport)));
 				break;
 			case IPPROTO_UDP:
-				printf(", %s udp port %s",
-					ip6addr_string(&oip->ip6_dst),
-					udpport_string(dport));
+				ND_PRINT((ndo,", %s udp port %s",
+					ip6addr_string(ndo, &oip->ip6_dst),
+                                          udpport_string(dport)));
 				break;
 			default:
-				printf(", %s protocol %d port %d unreachable",
-					ip6addr_string(&oip->ip6_dst),
-					oip->ip6_nxt, dport);
+				ND_PRINT((ndo,", %s protocol %d port %d unreachable",
+					ip6addr_string(ndo, &oip->ip6_dst),
+                                          oip->ip6_nxt, dport));
 				break;
 			}
 			break;
 		default:
-                    if (vflag <= 1) {
-                            print_unknown_data(bp,"\n\t",length);
-                            return;
-                    }
+                  if (ndo->ndo_vflag <= 1) {
+                    print_unknown_data(ndo, bp,"\n\t",length);
+                    return;
+                  }
                     break;
 		}
 		break;
 	case ICMP6_PACKET_TOO_BIG:
-		TCHECK(dp->icmp6_mtu);
-		printf(", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu));
+		ND_TCHECK(dp->icmp6_mtu);
+		ND_PRINT((ndo,", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu)));
 		break;
 	case ICMP6_TIME_EXCEEDED:
-		TCHECK(oip->ip6_dst);
+		ND_TCHECK(oip->ip6_dst);
 		switch (dp->icmp6_code) {
 		case ICMP6_TIME_EXCEED_TRANSIT:
-			printf(" for %s",
-				ip6addr_string(&oip->ip6_dst));
+			ND_PRINT((ndo," for %s",
+                                  ip6addr_string(ndo, &oip->ip6_dst)));
 			break;
 		case ICMP6_TIME_EXCEED_REASSEMBLY:
-			printf(" (reassembly)");
+			ND_PRINT((ndo," (reassembly)"));
 			break;
 		default:
-			printf(", unknown code (%u)", dp->icmp6_code);
+                        ND_PRINT((ndo,", unknown code (%u)", dp->icmp6_code));
 			break;
 		}
 		break;
 	case ICMP6_PARAM_PROB:
-		TCHECK(oip->ip6_dst);
+		ND_TCHECK(oip->ip6_dst);
 		switch (dp->icmp6_code) {
 		case ICMP6_PARAMPROB_HEADER:
-			printf(", erroneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
-			break;
+                        ND_PRINT((ndo,", erroneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+                        break;
 		case ICMP6_PARAMPROB_NEXTHEADER:
-			printf(", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
-			break;
+                        ND_PRINT((ndo,", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+                        break;
 		case ICMP6_PARAMPROB_OPTION:
-			printf(", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
-			break;
+                        ND_PRINT((ndo,", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+                        break;
 		default:
-			printf(", code-#%d",
-			       dp->icmp6_code);
-			break;
+                        ND_PRINT((ndo,", code-#%d",
+                                  dp->icmp6_code));
+                        break;
 		}
 		break;
 	case ICMP6_ECHO_REQUEST:
 	case ICMP6_ECHO_REPLY:
-		TCHECK(dp->icmp6_seq);
-		printf(", seq %u", EXTRACT_16BITS(&dp->icmp6_seq));
+                ND_TCHECK(dp->icmp6_seq);
+                ND_PRINT((ndo,", seq %u", EXTRACT_16BITS(&dp->icmp6_seq)));
 		break;
 	case ICMP6_MEMBERSHIP_QUERY:
 		if (length == MLD_MINLEN) {
-			mld6_print((const u_char *)dp);
+			mld6_print(ndo, (const u_char *)dp);
 		} else if (length >= MLDV2_MINLEN) {
-			printf(" v2");
-			mldv2_query_print((const u_char *)dp, length);
+			ND_PRINT((ndo," v2"));
+			mldv2_query_print(ndo, (const u_char *)dp, length);
 		} else {
-			printf(" unknown-version (len %u) ", length);
+                        ND_PRINT((ndo," unknown-version (len %u) ", length));
 		}
 		break;
 	case ICMP6_MEMBERSHIP_REPORT:
-		mld6_print((const u_char *)dp);
+		mld6_print(ndo, (const u_char *)dp);
 		break;
 	case ICMP6_MEMBERSHIP_REDUCTION:
-		mld6_print((const u_char *)dp);
+		mld6_print(ndo, (const u_char *)dp);
 		break;
 	case ND_ROUTER_SOLICIT:
 #define RTSOLLEN 8
-		if (vflag) {
-			icmp6_opt_print((const u_char *)dp + RTSOLLEN,
+		if (ndo->ndo_vflag) {
+			icmp6_opt_print(ndo, (const u_char *)dp + RTSOLLEN,
 					length - RTSOLLEN);
 		}
 		break;
 	case ND_ROUTER_ADVERT:
 #define RTADVLEN 16
-		if (vflag) {
+		if (ndo->ndo_vflag) {
 			struct nd_router_advert *p;
 
 			p = (struct nd_router_advert *)dp;
-			TCHECK(p->nd_ra_retransmit);
-			printf("\n\thop limit %u, Flags [%s]" \
-                               ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
-                               (u_int)p->nd_ra_curhoplimit,
-                               bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
-                               get_rtpref(p->nd_ra_flags_reserved),
-                               EXTRACT_16BITS(&p->nd_ra_router_lifetime),
-                               EXTRACT_32BITS(&p->nd_ra_reachable),
-                               EXTRACT_32BITS(&p->nd_ra_retransmit));
+			ND_TCHECK(p->nd_ra_retransmit);
+			ND_PRINT((ndo,"\n\thop limit %u, Flags [%s]" \
+                                  ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
+                                  (u_int)p->nd_ra_curhoplimit,
+                                  bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
+                                  get_rtpref(p->nd_ra_flags_reserved),
+                                  EXTRACT_16BITS(&p->nd_ra_router_lifetime),
+                                  EXTRACT_32BITS(&p->nd_ra_reachable),
+                                  EXTRACT_32BITS(&p->nd_ra_retransmit)));
 
-			icmp6_opt_print((const u_char *)dp + RTADVLEN,
+			icmp6_opt_print(ndo, (const u_char *)dp + RTADVLEN,
 					length - RTADVLEN);
 		}
 		break;
@@ -483,11 +1069,11 @@
 	    {
 		struct nd_neighbor_solicit *p;
 		p = (struct nd_neighbor_solicit *)dp;
-		TCHECK(p->nd_ns_target);
-		printf(", who has %s", ip6addr_string(&p->nd_ns_target));
-		if (vflag) {
+		ND_TCHECK(p->nd_ns_target);
+		ND_PRINT((ndo,", who has %s", ip6addr_string(ndo, &p->nd_ns_target)));
+		if (ndo->ndo_vflag) {
 #define NDSOLLEN 24
-			icmp6_opt_print((const u_char *)dp + NDSOLLEN,
+			icmp6_opt_print(ndo, (const u_char *)dp + NDSOLLEN,
 					length - NDSOLLEN);
 		}
 	    }
@@ -497,16 +1083,16 @@
 		struct nd_neighbor_advert *p;
 
 		p = (struct nd_neighbor_advert *)dp;
-		TCHECK(p->nd_na_target);
-		printf(", tgt is %s",
-			ip6addr_string(&p->nd_na_target));
-		if (vflag) {
-                        printf(", Flags [%s]",
-                               bittok2str(icmp6_nd_na_flag_values,
-                                          "none",
-                                          EXTRACT_32BITS(&p->nd_na_flags_reserved)));
+		ND_TCHECK(p->nd_na_target);
+		ND_PRINT((ndo,", tgt is %s",
+                          ip6addr_string(ndo, &p->nd_na_target)));
+		if (ndo->ndo_vflag) {
+                        ND_PRINT((ndo,", Flags [%s]",
+                                  bittok2str(icmp6_nd_na_flag_values,
+                                             "none",
+                                             EXTRACT_32BITS(&p->nd_na_flags_reserved))));
 #define NDADVLEN 24
-			icmp6_opt_print((const u_char *)dp + NDADVLEN,
+			icmp6_opt_print(ndo, (const u_char *)dp + NDADVLEN,
 					length - NDADVLEN);
 #undef NDADVLEN
 		}
@@ -514,99 +1100,100 @@
 		break;
 	case ND_REDIRECT:
 #define RDR(i) ((struct nd_redirect *)(i))
-		TCHECK(RDR(dp)->nd_rd_dst);
-		printf(", %s", getname6((const u_char *)&RDR(dp)->nd_rd_dst));
-		TCHECK(RDR(dp)->nd_rd_target);
-		printf(" to %s",
-		    getname6((const u_char*)&RDR(dp)->nd_rd_target));
+                         ND_TCHECK(RDR(dp)->nd_rd_dst);
+                         ND_PRINT((ndo,", %s", getname6(ndo, (const u_char *)&RDR(dp)->nd_rd_dst)));
+		ND_TCHECK(RDR(dp)->nd_rd_target);
+		ND_PRINT((ndo," to %s",
+                          getname6(ndo, (const u_char*)&RDR(dp)->nd_rd_target)));
 #define REDIRECTLEN 40
-		if (vflag) {
-			icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
+		if (ndo->ndo_vflag) {
+			icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN,
 					length - REDIRECTLEN);
 		}
 		break;
 #undef REDIRECTLEN
 #undef RDR
 	case ICMP6_ROUTER_RENUMBERING:
-		icmp6_rrenum_print(bp, ep);
+		icmp6_rrenum_print(ndo, bp, ep);
 		break;
 	case ICMP6_NI_QUERY:
 	case ICMP6_NI_REPLY:
-		icmp6_nodeinfo_print(length, bp, ep);
+		icmp6_nodeinfo_print(ndo, length, bp, ep);
 		break;
 	case IND_SOLICIT:
 	case IND_ADVERT:
 		break;
 	case ICMP6_V2_MEMBERSHIP_REPORT:
-		mldv2_report_print((const u_char *) dp, length);
+		mldv2_report_print(ndo, (const u_char *) dp, length);
 		break;
 	case ICMP6_MOBILEPREFIX_SOLICIT: /* fall through */
 	case ICMP6_HADISCOV_REQUEST:
-                TCHECK(dp->icmp6_data16[0]);
-                printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+                ND_TCHECK(dp->icmp6_data16[0]);
+                ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
                 break;
 	case ICMP6_HADISCOV_REPLY:
-		if (vflag) {
+		if (ndo->ndo_vflag) {
 			struct in6_addr *in6;
 			u_char *cp;
 
-			TCHECK(dp->icmp6_data16[0]);
-			printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+			ND_TCHECK(dp->icmp6_data16[0]);
+			ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
 			cp = (u_char *)dp + length;
 			in6 = (struct in6_addr *)(dp + 1);
 			for (; (u_char *)in6 < cp; in6++) {
-				TCHECK(*in6);
-				printf(", %s", ip6addr_string(in6));
+				ND_TCHECK(*in6);
+				ND_PRINT((ndo,", %s", ip6addr_string(ndo, in6)));
 			}
 		}
 		break;
 	case ICMP6_MOBILEPREFIX_ADVERT:
-		if (vflag) {
-			TCHECK(dp->icmp6_data16[0]);
-			printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+		if (ndo->ndo_vflag) {
+			ND_TCHECK(dp->icmp6_data16[0]);
+			ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
 			if (dp->icmp6_data16[1] & 0xc0)
-				printf(" ");
+				ND_PRINT((ndo," "));
 			if (dp->icmp6_data16[1] & 0x80)
-				printf("M");
+				ND_PRINT((ndo,"M"));
 			if (dp->icmp6_data16[1] & 0x40)
-				printf("O");
+				ND_PRINT((ndo,"O"));
 #define MPADVLEN 8
-			icmp6_opt_print((const u_char *)dp + MPADVLEN,
+			icmp6_opt_print(ndo, (const u_char *)dp + MPADVLEN,
 					length - MPADVLEN);
 		}
 		break;
         case ND_RPL_MESSAGE:
-                rpl_print(ndo, dp, &dp->icmp6_data8[0], length);
+                /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
+                rpl_print(ndo, dp, &dp->icmp6_data8[0], length-sizeof(struct icmp6_hdr)+4);
                 break;
 	default:
-                printf(", length %u", length);
-                if (vflag <= 1)
-                    print_unknown_data(bp,"\n\t", length);
+                ND_PRINT((ndo,", length %u", length));
+                if (ndo->ndo_vflag <= 1)
+                        print_unknown_data(ndo, bp,"\n\t", length);
                 return;
         }
-        if (!vflag)
-            printf(", length %u", length); 
+        if (!ndo->ndo_vflag)
+                ND_PRINT((ndo,", length %u", length));
 	return;
 trunc:
-	fputs("[|icmp6]", stdout);
+	ND_PRINT((ndo, "[|icmp6]"));
 }
 
-static struct udphdr *
-get_upperlayer(u_char *bp, u_int *prot)
+static const struct udphdr *
+get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
 {
 	const u_char *ep;
-	struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
-	struct udphdr *uh;
-	struct ip6_hbh *hbh;
-	struct ip6_frag *fragh;
-	struct ah *ah;
+	const struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
+	const struct udphdr *uh;
+	const struct ip6_hbh *hbh;
+	const struct ip6_frag *fragh;
+	const struct ah *ah;
 	u_int nh;
 	int hlen;
 
 	/* 'ep' points to the end of available data. */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 
-	if (!TTEST(ip6->ip6_nxt))
+	if (!ND_TTEST(ip6->ip6_nxt))
 		return NULL;
 
 	nh = ip6->ip6_nxt;
@@ -619,7 +1206,7 @@
 		case IPPROTO_UDP:
 		case IPPROTO_TCP:
 			uh = (struct udphdr *)bp;
-			if (TTEST(uh->uh_dport)) {
+			if (ND_TTEST(uh->uh_dport)) {
 				*prot = nh;
 				return(uh);
 			}
@@ -631,7 +1218,7 @@
 		case IPPROTO_DSTOPTS:
 		case IPPROTO_ROUTING:
 			hbh = (struct ip6_hbh *)bp;
-			if (!TTEST(hbh->ip6h_len))
+			if (!ND_TTEST(hbh->ip6h_len))
 				return(NULL);
 			nh = hbh->ip6h_nxt;
 			hlen = (hbh->ip6h_len + 1) << 3;
@@ -639,7 +1226,7 @@
 
 		case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */
 			fragh = (struct ip6_frag *)bp;
-			if (!TTEST(fragh->ip6f_offlg))
+			if (!ND_TTEST(fragh->ip6f_offlg))
 				return(NULL);
 			/* fragments with non-zero offset are meaningless */
 			if ((EXTRACT_16BITS(&fragh->ip6f_offlg) & IP6F_OFF_MASK) != 0)
@@ -650,7 +1237,7 @@
 
 		case IPPROTO_AH:
 			ah = (struct ah *)bp;
-			if (!TTEST(ah->ah_len))
+			if (!ND_TTEST(ah->ah_len))
 				return(NULL);
 			nh = ah->ah_nxt;
 			hlen = (ah->ah_len + 2) << 2;
@@ -666,7 +1253,7 @@
 }
 
 static void
-icmp6_opt_print(const u_char *bp, int resid)
+icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
 {
 	const struct nd_opt_hdr *op;
 	const struct nd_opt_prefix_info *opp;
@@ -685,7 +1272,7 @@
 
 	cp = bp;
 	/* 'ep' points to the end of available data. */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 
 	while (cp < ep) {
 		op = (struct nd_opt_hdr *)cp;
@@ -698,113 +1285,113 @@
 		if (cp + (op->nd_opt_len << 3) > ep)
 			goto trunc;
 
-                printf("\n\t  %s option (%u), length %u (%u): ",
-                       tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
-                       op->nd_opt_type,
-                       op->nd_opt_len << 3,
-                       op->nd_opt_len);
+                ND_PRINT((ndo,"\n\t  %s option (%u), length %u (%u): ",
+                          tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
+                          op->nd_opt_type,
+                          op->nd_opt_len << 3,
+                          op->nd_opt_len));
 
 		switch (op->nd_opt_type) {
 		case ND_OPT_SOURCE_LINKADDR:
 			l = (op->nd_opt_len << 3) - 2;
-			print_lladdr(cp + 2, l);
+			print_lladdr(ndo, cp + 2, l);
 			break;
 		case ND_OPT_TARGET_LINKADDR:
 			l = (op->nd_opt_len << 3) - 2;
-			print_lladdr(cp + 2, l);
+			print_lladdr(ndo, cp + 2, l);
 			break;
 		case ND_OPT_PREFIX_INFORMATION:
 			opp = (struct nd_opt_prefix_info *)op;
-			TCHECK(opp->nd_opt_pi_prefix);
-                        printf("%s/%u%s, Flags [%s], valid time %s",
-                               ip6addr_string(&opp->nd_opt_pi_prefix),
-                               opp->nd_opt_pi_prefix_len,
-                               (op->nd_opt_len != 4) ? "badlen" : "",
-                               bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
-                               get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time)));
-                        printf(", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time)));
+			ND_TCHECK(opp->nd_opt_pi_prefix);
+                        ND_PRINT((ndo,"%s/%u%s, Flags [%s], valid time %s",
+                                  ip6addr_string(ndo, &opp->nd_opt_pi_prefix),
+                                  opp->nd_opt_pi_prefix_len,
+                                  (op->nd_opt_len != 4) ? "badlen" : "",
+                                  bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
+                                  get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time))));
+                        ND_PRINT((ndo,", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time))));
 			break;
 		case ND_OPT_REDIRECTED_HEADER:
-                        print_unknown_data(bp,"\n\t    ",op->nd_opt_len<<3);
+                        print_unknown_data(ndo, bp,"\n\t    ",op->nd_opt_len<<3);
 			/* xxx */
 			break;
 		case ND_OPT_MTU:
 			opm = (struct nd_opt_mtu *)op;
-			TCHECK(opm->nd_opt_mtu_mtu);
-			printf(" %u%s",
+			ND_TCHECK(opm->nd_opt_mtu_mtu);
+			ND_PRINT((ndo," %u%s",
                                EXTRACT_32BITS(&opm->nd_opt_mtu_mtu),
-                               (op->nd_opt_len != 1) ? "bad option length" : "" );
+                                  (op->nd_opt_len != 1) ? "bad option length" : "" ));
                         break;
 		case ND_OPT_RDNSS:
 			oprd = (struct nd_opt_rdnss *)op;
 			l = (op->nd_opt_len - 1) / 2;
-			printf(" lifetime %us,", 
-				EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime)); 
+			ND_PRINT((ndo," lifetime %us,",
+                                  EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime)));
 			for (i = 0; i < l; i++) {
-				TCHECK(oprd->nd_opt_rdnss_addr[i]);
-				printf(" addr: %s", 
-				    ip6addr_string(&oprd->nd_opt_rdnss_addr[i]));
+				ND_TCHECK(oprd->nd_opt_rdnss_addr[i]);
+				ND_PRINT((ndo," addr: %s",
+                                          ip6addr_string(ndo, &oprd->nd_opt_rdnss_addr[i])));
 			}
 			break;
 		case ND_OPT_DNSSL:
 			opds = (struct nd_opt_dnssl *)op;
-			printf(" lifetime %us, domain(s):",
-				EXTRACT_32BITS(&opds->nd_opt_dnssl_lifetime));
+			ND_PRINT((ndo," lifetime %us, domain(s):",
+                                  EXTRACT_32BITS(&opds->nd_opt_dnssl_lifetime)));
 			domp = cp + 8; /* domain names, variable-sized, RFC1035-encoded */
 			while (domp < cp + (op->nd_opt_len << 3) && *domp != '\0')
 			{
-				printf (" ");
-				if ((domp = ns_nprint (domp, bp)) == NULL)
+				ND_PRINT((ndo, " "));
+				if ((domp = ns_nprint (ndo, domp, bp)) == NULL)
 					goto trunc;
 			}
 			break;
 		case ND_OPT_ADVINTERVAL:
 			opa = (struct nd_opt_advinterval *)op;
-			TCHECK(opa->nd_opt_adv_interval);
-			printf(" %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval));
+			ND_TCHECK(opa->nd_opt_adv_interval);
+			ND_PRINT((ndo," %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval)));
 			break;
-		case ND_OPT_HOMEAGENT_INFO:
+                case ND_OPT_HOMEAGENT_INFO:
 			oph = (struct nd_opt_homeagent_info *)op;
-			TCHECK(oph->nd_opt_hai_lifetime);
-			printf(" preference %u, lifetime %u",
-                               EXTRACT_16BITS(&oph->nd_opt_hai_preference),
-                               EXTRACT_16BITS(&oph->nd_opt_hai_lifetime));
+			ND_TCHECK(oph->nd_opt_hai_lifetime);
+			ND_PRINT((ndo," preference %u, lifetime %u",
+                                  EXTRACT_16BITS(&oph->nd_opt_hai_preference),
+                                  EXTRACT_16BITS(&oph->nd_opt_hai_lifetime)));
 			break;
 		case ND_OPT_ROUTE_INFO:
 			opri = (struct nd_opt_route_info *)op;
-			TCHECK(opri->nd_opt_rti_lifetime);
+			ND_TCHECK(opri->nd_opt_rti_lifetime);
 			memset(&in6, 0, sizeof(in6));
 			in6p = (struct in6_addr *)(opri + 1);
 			switch (op->nd_opt_len) {
 			case 1:
 				break;
 			case 2:
-				TCHECK2(*in6p, 8);
+				ND_TCHECK2(*in6p, 8);
 				memcpy(&in6, opri + 1, 8);
 				break;
 			case 3:
-				TCHECK(*in6p);
+				ND_TCHECK(*in6p);
 				memcpy(&in6, opri + 1, sizeof(in6));
 				break;
 			default:
 				goto trunc;
 			}
-			printf(" %s/%u", ip6addr_string(&in6),
-			    opri->nd_opt_rti_prefixlen);
-			printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags));
-			printf(", lifetime=%s",
-			    get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime)));
+			ND_PRINT((ndo," %s/%u", ip6addr_string(ndo, &in6),
+                                  opri->nd_opt_rti_prefixlen));
+			ND_PRINT((ndo,", pref=%s", get_rtpref(opri->nd_opt_rti_flags)));
+			ND_PRINT((ndo,", lifetime=%s",
+                                  get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime))));
 			break;
 		default:
-                        if (vflag <= 1) {
-                            print_unknown_data(cp+2,"\n\t  ", (op->nd_opt_len << 3) - 2); /* skip option header */
+                        if (ndo->ndo_vflag <= 1) {
+                                print_unknown_data(ndo,cp+2,"\n\t  ", (op->nd_opt_len << 3) - 2); /* skip option header */
                             return;
                         }
                         break;
 		}
                 /* do we want to see an additional hexdump ? */
-                if (vflag> 1)
-                    print_unknown_data(cp+2,"\n\t    ", (op->nd_opt_len << 3) - 2); /* skip option header */
+                if (ndo->ndo_vflag> 1)
+                        print_unknown_data(ndo, cp+2,"\n\t    ", (op->nd_opt_len << 3) - 2); /* skip option header */
 
 		cp += op->nd_opt_len << 3;
 		resid -= op->nd_opt_len << 3;
@@ -812,29 +1399,29 @@
 	return;
 
  trunc:
-	fputs("[ndp opt]", stdout);
+	ND_PRINT((ndo, "[ndp opt]"));
 	return;
 #undef ECHECK
 }
 
 static void
-mld6_print(const u_char *bp)
+mld6_print(netdissect_options *ndo, const u_char *bp)
 {
-	struct mld6_hdr *mp = (struct mld6_hdr *)bp;
+	const struct mld6_hdr *mp = (struct mld6_hdr *)bp;
 	const u_char *ep;
 
 	/* 'ep' points to the end of available data. */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 
 	if ((u_char *)mp + sizeof(*mp) > ep)
 		return;
 
-	printf("max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay));
-	printf("addr: %s", ip6addr_string(&mp->mld6_addr));
+	ND_PRINT((ndo,"max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay)));
+	ND_PRINT((ndo,"addr: %s", ip6addr_string(ndo, &mp->mld6_addr)));
 }
 
 static void
-mldv2_report_print(const u_char *bp, u_int len)
+mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
 {
     struct icmp6_hdr *icp = (struct icmp6_hdr *) bp;
     u_int group, nsrcs, ngroups;
@@ -842,57 +1429,57 @@
 
     /* Minimum len is 8 */
     if (len < 8) {
-	printf(" [invalid len %d]", len);
-	return;
+            ND_PRINT((ndo," [invalid len %d]", len));
+            return;
     }
 
-    TCHECK(icp->icmp6_data16[1]);
+    ND_TCHECK(icp->icmp6_data16[1]);
     ngroups = EXTRACT_16BITS(&icp->icmp6_data16[1]);
-    printf(", %d group record(s)", ngroups);
-    if (vflag > 0) {
+    ND_PRINT((ndo,", %d group record(s)", ngroups));
+    if (ndo->ndo_vflag > 0) {
 	/* Print the group records */
 	group = 8;
         for (i = 0; i < ngroups; i++) {
 	    /* type(1) + auxlen(1) + numsrc(2) + grp(16) */
 	    if (len < group + 20) {
-		printf(" [invalid number of groups]");
-		return;
+                    ND_PRINT((ndo," [invalid number of groups]"));
+                    return;
 	    }
-            TCHECK2(bp[group + 4], sizeof(struct in6_addr));
-            printf(" [gaddr %s", ip6addr_string(&bp[group + 4]));
-	    printf(" %s", tok2str(mldv2report2str, " [v2-report-#%d]",
-								bp[group]));
+            ND_TCHECK2(bp[group + 4], sizeof(struct in6_addr));
+            ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[group + 4])));
+	    ND_PRINT((ndo," %s", tok2str(mldv2report2str, " [v2-report-#%d]",
+                                         bp[group])));
             nsrcs = (bp[group + 2] << 8) + bp[group + 3];
 	    /* Check the number of sources and print them */
 	    if (len < group + 20 + (nsrcs * sizeof(struct in6_addr))) {
-		printf(" [invalid number of sources %d]", nsrcs);
-		return;
+                    ND_PRINT((ndo," [invalid number of sources %d]", nsrcs));
+                    return;
 	    }
-            if (vflag == 1)
-                printf(", %d source(s)", nsrcs);
+            if (ndo->ndo_vflag == 1)
+                    ND_PRINT((ndo,", %d source(s)", nsrcs));
             else {
 		/* Print the sources */
-                (void)printf(" {");
+                    ND_PRINT((ndo," {"));
                 for (j = 0; j < nsrcs; j++) {
-                    TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)],
+                    ND_TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)],
                             sizeof(struct in6_addr));
-		    printf(" %s", ip6addr_string(&bp[group + 20 + j * sizeof(struct in6_addr)]));
+		    ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[group + 20 + j * sizeof(struct in6_addr)])));
 		}
-                (void)printf(" }");
+                ND_PRINT((ndo," }"));
             }
 	    /* Next group record */
             group += 20 + nsrcs * sizeof(struct in6_addr);
-	    printf("]");
+	    ND_PRINT((ndo,"]"));
         }
     }
     return;
 trunc:
-    (void)printf("[|icmp6]");
+    ND_PRINT((ndo,"[|icmp6]"));
     return;
 }
 
 static void
-mldv2_query_print(const u_char *bp, u_int len)
+mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
 {
     struct icmp6_hdr *icp = (struct icmp6_hdr *) bp;
     u_int mrc;
@@ -902,102 +1489,102 @@
 
     /* Minimum len is 28 */
     if (len < 28) {
-	printf(" [invalid len %d]", len);
+            ND_PRINT((ndo," [invalid len %d]", len));
 	return;
     }
-    TCHECK(icp->icmp6_data16[0]);
+    ND_TCHECK(icp->icmp6_data16[0]);
     mrc = EXTRACT_16BITS(&icp->icmp6_data16[0]);
     if (mrc < 32768) {
 	mrt = mrc;
     } else {
         mrt = ((mrc & 0x0fff) | 0x1000) << (((mrc & 0x7000) >> 12) + 3);
     }
-    if (vflag) {
-	(void)printf(" [max resp delay=%d]", mrt);
+    if (ndo->ndo_vflag) {
+            ND_PRINT((ndo," [max resp delay=%d]", mrt));
     }
-    TCHECK2(bp[8], sizeof(struct in6_addr));
-    printf(" [gaddr %s", ip6addr_string(&bp[8]));
+    ND_TCHECK2(bp[8], sizeof(struct in6_addr));
+    ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[8])));
 
-    if (vflag) {
-        TCHECK(bp[25]);
+    if (ndo->ndo_vflag) {
+        ND_TCHECK(bp[25]);
 	if (bp[24] & 0x08) {
-		printf(" sflag");
+		ND_PRINT((ndo," sflag"));
 	}
 	if (bp[24] & 0x07) {
-		printf(" robustness=%d", bp[24] & 0x07);
+		ND_PRINT((ndo," robustness=%d", bp[24] & 0x07));
 	}
 	if (bp[25] < 128) {
 		qqi = bp[25];
 	} else {
 		qqi = ((bp[25] & 0x0f) | 0x10) << (((bp[25] & 0x70) >> 4) + 3);
 	}
-	printf(" qqi=%d", qqi);
+	ND_PRINT((ndo," qqi=%d", qqi));
     }
 
-    TCHECK2(bp[26], 2);
+    ND_TCHECK2(bp[26], 2);
     nsrcs = EXTRACT_16BITS(&bp[26]);
     if (nsrcs > 0) {
 	if (len < 28 + nsrcs * sizeof(struct in6_addr))
-	    printf(" [invalid number of sources]");
-	else if (vflag > 1) {
-	    printf(" {");
+	    ND_PRINT((ndo," [invalid number of sources]"));
+	else if (ndo->ndo_vflag > 1) {
+	    ND_PRINT((ndo," {"));
 	    for (i = 0; i < nsrcs; i++) {
-		TCHECK2(bp[28 + i * sizeof(struct in6_addr)],
+		ND_TCHECK2(bp[28 + i * sizeof(struct in6_addr)],
                         sizeof(struct in6_addr));
-		printf(" %s", ip6addr_string(&bp[28 + i * sizeof(struct in6_addr)]));
+		ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[28 + i * sizeof(struct in6_addr)])));
 	    }
-	    printf(" }");
+	    ND_PRINT((ndo," }"));
 	} else
-	    printf(", %d source(s)", nsrcs);
+                ND_PRINT((ndo,", %d source(s)", nsrcs));
     }
-    printf("]");
+    ND_PRINT((ndo,"]"));
     return;
 trunc:
-    (void)printf("[|icmp6]");
+    ND_PRINT((ndo,"[|icmp6]"));
     return;
 }
 
 static void
-dnsname_print(const u_char *cp, const u_char *ep)
+dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
 {
 	int i;
 
 	/* DNS name decoding - no decompression */
-	printf(", \"");
+	ND_PRINT((ndo,", \""));
 	while (cp < ep) {
 		i = *cp++;
 		if (i) {
 			if (i > ep - cp) {
-				printf("???");
+				ND_PRINT((ndo,"???"));
 				break;
 			}
 			while (i-- && cp < ep) {
-				safeputchar(*cp);
+				safeputchar(ndo, *cp);
 				cp++;
 			}
 			if (cp + 1 < ep && *cp)
-				printf(".");
+				ND_PRINT((ndo,"."));
 		} else {
 			if (cp == ep) {
 				/* FQDN */
-				printf(".");
+				ND_PRINT((ndo,"."));
 			} else if (cp + 1 == ep && *cp == '\0') {
 				/* truncated */
 			} else {
 				/* invalid */
-				printf("???");
+				ND_PRINT((ndo,"???"));
 			}
 			break;
 		}
 	}
-	printf("\"");
+	ND_PRINT((ndo,"\""));
 }
 
 static void
-icmp6_nodeinfo_print(u_int icmp6len, const u_char *bp, const u_char *ep)
+icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp, const u_char *ep)
 {
-	struct icmp6_nodeinfo *ni6;
-	struct icmp6_hdr *dp;
+	const struct icmp6_nodeinfo *ni6;
+	const struct icmp6_hdr *dp;
 	const u_char *cp;
 	size_t siz, i;
 	int needcomma;
@@ -1012,240 +1599,239 @@
 	case ICMP6_NI_QUERY:
 		if (siz == sizeof(*dp) + 4) {
 			/* KAME who-are-you */
-			printf(" who-are-you request");
+			ND_PRINT((ndo," who-are-you request"));
 			break;
 		}
-		printf(" node information query");
+		ND_PRINT((ndo," node information query"));
 
-		TCHECK2(*dp, sizeof(*ni6));
+		ND_TCHECK2(*dp, sizeof(*ni6));
 		ni6 = (struct icmp6_nodeinfo *)dp;
-		printf(" (");	/*)*/
+		ND_PRINT((ndo," ("));	/*)*/
 		switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
 		case NI_QTYPE_NOOP:
-			printf("noop");
+			ND_PRINT((ndo,"noop"));
 			break;
 		case NI_QTYPE_SUPTYPES:
-			printf("supported qtypes");
+			ND_PRINT((ndo,"supported qtypes"));
 			i = EXTRACT_16BITS(&ni6->ni_flags);
 			if (i)
-				printf(" [%s]", (i & 0x01) ? "C" : "");
-			break;
+				ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : ""));
 			break;
 		case NI_QTYPE_FQDN:
-			printf("DNS name");
+			ND_PRINT((ndo,"DNS name"));
 			break;
 		case NI_QTYPE_NODEADDR:
-			printf("node addresses");
+			ND_PRINT((ndo,"node addresses"));
 			i = ni6->ni_flags;
 			if (!i)
 				break;
 			/* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
-			printf(" [%s%s%s%s%s%s]",
+			ND_PRINT((ndo," [%s%s%s%s%s%s]",
 			    (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
 			    (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
 			    (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
 			    (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
 			    (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
-			    (i & NI_NODEADDR_FLAG_ALL) ? "A" : "");
+			    (i & NI_NODEADDR_FLAG_ALL) ? "A" : ""));
 			break;
 		default:
-			printf("unknown");
+			ND_PRINT((ndo,"unknown"));
 			break;
 		}
 
 		if (ni6->ni_qtype == NI_QTYPE_NOOP ||
 		    ni6->ni_qtype == NI_QTYPE_SUPTYPES) {
 			if (siz != sizeof(*ni6))
-				if (vflag)
-					printf(", invalid len");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", invalid len"));
 			/*(*/
-			printf(")");
+			ND_PRINT((ndo,")"));
 			break;
 		}
 
 
 		/* XXX backward compat, icmp-name-lookup-03 */
 		if (siz == sizeof(*ni6)) {
-			printf(", 03 draft");
+			ND_PRINT((ndo,", 03 draft"));
 			/*(*/
-			printf(")");
+			ND_PRINT((ndo,")"));
 			break;
 		}
 
 		switch (ni6->ni_code) {
 		case ICMP6_NI_SUBJ_IPV6:
-			if (!TTEST2(*dp,
+			if (!ND_TTEST2(*dp,
 			    sizeof(*ni6) + sizeof(struct in6_addr)))
 				break;
 			if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) {
-				if (vflag)
-					printf(", invalid subject len");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", invalid subject len"));
 				break;
 			}
-			printf(", subject=%s",
-			    getname6((const u_char *)(ni6 + 1)));
+			ND_PRINT((ndo,", subject=%s",
+                                  getname6(ndo, (const u_char *)(ni6 + 1))));
 			break;
 		case ICMP6_NI_SUBJ_FQDN:
-			printf(", subject=DNS name");
+			ND_PRINT((ndo,", subject=DNS name"));
 			cp = (const u_char *)(ni6 + 1);
 			if (cp[0] == ep - cp - 1) {
 				/* icmp-name-lookup-03, pascal string */
-				if (vflag)
-					printf(", 03 draft");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", 03 draft"));
 				cp++;
-				printf(", \"");
+				ND_PRINT((ndo,", \""));
 				while (cp < ep) {
-					safeputchar(*cp);
+					safeputchar(ndo, *cp);
 					cp++;
 				}
-				printf("\"");
+				ND_PRINT((ndo,"\""));
 			} else
-				dnsname_print(cp, ep);
+				dnsname_print(ndo, cp, ep);
 			break;
 		case ICMP6_NI_SUBJ_IPV4:
-			if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
+			if (!ND_TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
 				break;
 			if (siz != sizeof(*ni6) + sizeof(struct in_addr)) {
-				if (vflag)
-					printf(", invalid subject len");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", invalid subject len"));
 				break;
 			}
-			printf(", subject=%s",
-			    getname((const u_char *)(ni6 + 1)));
+			ND_PRINT((ndo,", subject=%s",
+                                  getname(ndo, (const u_char *)(ni6 + 1))));
 			break;
 		default:
-			printf(", unknown subject");
+			ND_PRINT((ndo,", unknown subject"));
 			break;
 		}
 
 		/*(*/
-		printf(")");
+		ND_PRINT((ndo,")"));
 		break;
 
 	case ICMP6_NI_REPLY:
 		if (icmp6len > siz) {
-			printf("[|icmp6: node information reply]");
+			ND_PRINT((ndo,"[|icmp6: node information reply]"));
 			break;
 		}
 
 		needcomma = 0;
 
 		ni6 = (struct icmp6_nodeinfo *)dp;
-		printf(" node information reply");
-		printf(" (");	/*)*/
+		ND_PRINT((ndo," node information reply"));
+		ND_PRINT((ndo," ("));	/*)*/
 		switch (ni6->ni_code) {
 		case ICMP6_NI_SUCCESS:
-			if (vflag) {
-				printf("success");
+			if (ndo->ndo_vflag) {
+				ND_PRINT((ndo,"success"));
 				needcomma++;
 			}
 			break;
 		case ICMP6_NI_REFUSED:
-			printf("refused");
+			ND_PRINT((ndo,"refused"));
 			needcomma++;
 			if (siz != sizeof(*ni6))
-				if (vflag)
-					printf(", invalid length");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", invalid length"));
 			break;
 		case ICMP6_NI_UNKNOWN:
-			printf("unknown");
+			ND_PRINT((ndo,"unknown"));
 			needcomma++;
 			if (siz != sizeof(*ni6))
-				if (vflag)
-					printf(", invalid length");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", invalid length"));
 			break;
 		}
 
 		if (ni6->ni_code != ICMP6_NI_SUCCESS) {
 			/*(*/
-			printf(")");
+			ND_PRINT((ndo,")"));
 			break;
 		}
 
 		switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
 		case NI_QTYPE_NOOP:
 			if (needcomma)
-				printf(", ");
-			printf("noop");
+				ND_PRINT((ndo,", "));
+			ND_PRINT((ndo,"noop"));
 			if (siz != sizeof(*ni6))
-				if (vflag)
-					printf(", invalid length");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", invalid length"));
 			break;
 		case NI_QTYPE_SUPTYPES:
 			if (needcomma)
-				printf(", ");
-			printf("supported qtypes");
+				ND_PRINT((ndo,", "));
+			ND_PRINT((ndo,"supported qtypes"));
 			i = EXTRACT_16BITS(&ni6->ni_flags);
 			if (i)
-				printf(" [%s]", (i & 0x01) ? "C" : "");
+				ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : ""));
 			break;
 		case NI_QTYPE_FQDN:
 			if (needcomma)
-				printf(", ");
-			printf("DNS name");
+				ND_PRINT((ndo,", "));
+			ND_PRINT((ndo,"DNS name"));
 			cp = (const u_char *)(ni6 + 1) + 4;
 			if (cp[0] == ep - cp - 1) {
 				/* icmp-name-lookup-03, pascal string */
-				if (vflag)
-					printf(", 03 draft");
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo,", 03 draft"));
 				cp++;
-				printf(", \"");
+				ND_PRINT((ndo,", \""));
 				while (cp < ep) {
-					safeputchar(*cp);
+					safeputchar(ndo, *cp);
 					cp++;
 				}
-				printf("\"");
+				ND_PRINT((ndo,"\""));
 			} else
-				dnsname_print(cp, ep);
+				dnsname_print(ndo, cp, ep);
 			if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0)
-				printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1));
+				ND_PRINT((ndo," [TTL=%u]", *(uint32_t *)(ni6 + 1)));
 			break;
 		case NI_QTYPE_NODEADDR:
 			if (needcomma)
-				printf(", ");
-			printf("node addresses");
+				ND_PRINT((ndo,", "));
+			ND_PRINT((ndo,"node addresses"));
 			i = sizeof(*ni6);
 			while (i < siz) {
 				if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
 					break;
-				printf(" %s", getname6(bp + i));
+				ND_PRINT((ndo," %s", getname6(ndo, bp + i)));
 				i += sizeof(struct in6_addr);
-				printf("(%d)", (int32_t)EXTRACT_32BITS(bp + i));
+				ND_PRINT((ndo,"(%d)", (int32_t)EXTRACT_32BITS(bp + i)));
 				i += sizeof(int32_t);
 			}
 			i = ni6->ni_flags;
 			if (!i)
 				break;
-			printf(" [%s%s%s%s%s%s%s]",
-			    (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
-			    (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
-			    (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
-			    (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
-			    (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
-			    (i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
-			    (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : "");
+			ND_PRINT((ndo," [%s%s%s%s%s%s%s]",
+                                  (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
+                                  (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
+                                  (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
+                                  (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
+                                  (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
+                                  (i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
+                                  (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : ""));
 			break;
 		default:
 			if (needcomma)
-				printf(", ");
-			printf("unknown");
+				ND_PRINT((ndo,", "));
+			ND_PRINT((ndo,"unknown"));
 			break;
 		}
 
 		/*(*/
-		printf(")");
+		ND_PRINT((ndo,")"));
 		break;
 	}
 	return;
 
 trunc:
-	fputs("[|icmp6]", stdout);
+	ND_PRINT((ndo, "[|icmp6]"));
 }
 
 static void
-icmp6_rrenum_print(const u_char *bp, const u_char *ep)
+icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
 {
-	struct icmp6_router_renum *rr6;
+	const struct icmp6_router_renum *rr6;
 	const char *cp;
 	struct rr_pco_match *match;
 	struct rr_pco_use *use;
@@ -1257,40 +1843,40 @@
 	rr6 = (struct icmp6_router_renum *)bp;
 	cp = (const char *)(rr6 + 1);
 
-	TCHECK(rr6->rr_reserved);
+	ND_TCHECK(rr6->rr_reserved);
 	switch (rr6->rr_code) {
 	case ICMP6_ROUTER_RENUMBERING_COMMAND:
-		printf("router renum: command");
+		ND_PRINT((ndo,"router renum: command"));
 		break;
 	case ICMP6_ROUTER_RENUMBERING_RESULT:
-		printf("router renum: result");
+		ND_PRINT((ndo,"router renum: result"));
 		break;
 	case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
-		printf("router renum: sequence number reset");
+		ND_PRINT((ndo,"router renum: sequence number reset"));
 		break;
 	default:
-		printf("router renum: code-#%d", rr6->rr_code);
+		ND_PRINT((ndo,"router renum: code-#%d", rr6->rr_code));
 		break;
 	}
 
-	printf(", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum));
+        ND_PRINT((ndo,", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum)));
 
-	if (vflag) {
+	if (ndo->ndo_vflag) {
 #define F(x, y)	((rr6->rr_flags) & (x) ? (y) : "")
-		printf("[");	/*]*/
+		ND_PRINT((ndo,"["));	/*]*/
 		if (rr6->rr_flags) {
-			printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
-			    F(ICMP6_RR_FLAGS_REQRESULT, "R"),
-			    F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"),
-			    F(ICMP6_RR_FLAGS_SPECSITE, "S"),
-			    F(ICMP6_RR_FLAGS_PREVDONE, "P"));
+			ND_PRINT((ndo,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
+                                  F(ICMP6_RR_FLAGS_REQRESULT, "R"),
+                                  F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"),
+                                  F(ICMP6_RR_FLAGS_SPECSITE, "S"),
+                                  F(ICMP6_RR_FLAGS_PREVDONE, "P")));
 		}
-		printf("seg=%u,", rr6->rr_segnum);
-		printf("maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay));
+                ND_PRINT((ndo,"seg=%u,", rr6->rr_segnum));
+                ND_PRINT((ndo,"maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay)));
 		if (rr6->rr_reserved)
-			printf("rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved));
+			ND_PRINT((ndo,"rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved)));
 		/*[*/
-		printf("]");
+		ND_PRINT((ndo,"]"));
 #undef F
 	}
 
@@ -1298,31 +1884,31 @@
 		match = (struct rr_pco_match *)cp;
 		cp = (const char *)(match + 1);
 
-		TCHECK(match->rpm_prefix);
+		ND_TCHECK(match->rpm_prefix);
 
-		if (vflag > 1)
-			printf("\n\t");
+		if (ndo->ndo_vflag > 1)
+			ND_PRINT((ndo,"\n\t"));
 		else
-			printf(" ");
-		printf("match(");	/*)*/
+			ND_PRINT((ndo," "));
+		ND_PRINT((ndo,"match("));	/*)*/
 		switch (match->rpm_code) {
-		case RPM_PCO_ADD:	printf("add"); break;
-		case RPM_PCO_CHANGE:	printf("change"); break;
-		case RPM_PCO_SETGLOBAL:	printf("setglobal"); break;
-		default:		printf("#%u", match->rpm_code); break;
+		case RPM_PCO_ADD:	ND_PRINT((ndo,"add")); break;
+		case RPM_PCO_CHANGE:	ND_PRINT((ndo,"change")); break;
+		case RPM_PCO_SETGLOBAL:	ND_PRINT((ndo,"setglobal")); break;
+		default:		ND_PRINT((ndo,"#%u", match->rpm_code)); break;
 		}
 
-		if (vflag) {
-			printf(",ord=%u", match->rpm_ordinal);
-			printf(",min=%u", match->rpm_minlen);
-			printf(",max=%u", match->rpm_maxlen);
+		if (ndo->ndo_vflag) {
+			ND_PRINT((ndo,",ord=%u", match->rpm_ordinal));
+			ND_PRINT((ndo,",min=%u", match->rpm_minlen));
+			ND_PRINT((ndo,",max=%u", match->rpm_maxlen));
 		}
 		if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf)))
-			printf(",%s/%u", hbuf, match->rpm_matchlen);
+			ND_PRINT((ndo,",%s/%u", hbuf, match->rpm_matchlen));
 		else
-			printf(",?/%u", match->rpm_matchlen);
+			ND_PRINT((ndo,",?/%u", match->rpm_matchlen));
 		/*(*/
-		printf(")");
+		ND_PRINT((ndo,")"));
 
 		n = match->rpm_len - 3;
 		if (n % 4)
@@ -1332,50 +1918,57 @@
 			use = (struct rr_pco_use *)cp;
 			cp = (const char *)(use + 1);
 
-			TCHECK(use->rpu_prefix);
+			ND_TCHECK(use->rpu_prefix);
 
-			if (vflag > 1)
-				printf("\n\t");
+			if (ndo->ndo_vflag > 1)
+				ND_PRINT((ndo,"\n\t"));
 			else
-				printf(" ");
-			printf("use(");	/*)*/
+				ND_PRINT((ndo," "));
+			ND_PRINT((ndo,"use("));	/*)*/
 			if (use->rpu_flags) {
 #define F(x, y)	((use->rpu_flags) & (x) ? (y) : "")
-				printf("%s%s,",
-				    F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
-				    F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P"));
+				ND_PRINT((ndo,"%s%s,",
+                                          F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
+                                          F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P")));
 #undef F
 			}
-			if (vflag) {
-				printf("mask=0x%x,", use->rpu_ramask);
-				printf("raflags=0x%x,", use->rpu_raflags);
+			if (ndo->ndo_vflag) {
+				ND_PRINT((ndo,"mask=0x%x,", use->rpu_ramask));
+				ND_PRINT((ndo,"raflags=0x%x,", use->rpu_raflags));
 				if (~use->rpu_vltime == 0)
-					printf("vltime=infty,");
+					ND_PRINT((ndo,"vltime=infty,"));
 				else
-					printf("vltime=%u,",
-					    EXTRACT_32BITS(&use->rpu_vltime));
+					ND_PRINT((ndo,"vltime=%u,",
+                                                  EXTRACT_32BITS(&use->rpu_vltime)));
 				if (~use->rpu_pltime == 0)
-					printf("pltime=infty,");
+					ND_PRINT((ndo,"pltime=infty,"));
 				else
-					printf("pltime=%u,",
-					    EXTRACT_32BITS(&use->rpu_pltime));
+					ND_PRINT((ndo,"pltime=%u,",
+                                                  EXTRACT_32BITS(&use->rpu_pltime)));
 			}
 			if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
 			    sizeof(hbuf)))
-				printf("%s/%u/%u", hbuf, use->rpu_uselen,
-				    use->rpu_keeplen);
+				ND_PRINT((ndo,"%s/%u/%u", hbuf, use->rpu_uselen,
+                                          use->rpu_keeplen));
 			else
-				printf("?/%u/%u", use->rpu_uselen,
-				    use->rpu_keeplen);
+				ND_PRINT((ndo,"?/%u/%u", use->rpu_uselen,
+                                          use->rpu_keeplen));
 			/*(*/
-			printf(")");
+                        ND_PRINT((ndo,")"));
 		}
 	}
 
 	return;
 
 trunc:
-	fputs("[|icmp6]", stdout);
+	ND_PRINT((ndo,"[|icmp6]"));
 }
 
 #endif /* INET6 */
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-igmp.c b/print-igmp.c
index bc43102..e4808a7 100644
--- a/print-igmp.c
+++ b/print-igmp.c
@@ -19,20 +19,13 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.15 2004-03-24 00:59:16 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"            /* must come after interface.h */
@@ -41,16 +34,18 @@
 #define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
 #endif
 
+static const char tstr[] = "[|igmp]";
+
 /* (following from ipmulti/mrouted/prune.h) */
 
 /*
  * The packet format for a traceroute request.
  */
 struct tr_query {
-    u_int32_t  tr_src;          /* traceroute source */
-    u_int32_t  tr_dst;          /* traceroute destination */
-    u_int32_t  tr_raddr;        /* traceroute response address */
-    u_int32_t  tr_rttlqid;      /* response ttl and qid */
+    uint32_t  tr_src;          /* traceroute source */
+    uint32_t  tr_dst;          /* traceroute destination */
+    uint32_t  tr_raddr;        /* traceroute response address */
+    uint32_t  tr_rttlqid;      /* response ttl and qid */
 };
 
 #define TR_GETTTL(x)        (int)(((x) >> 24) & 0xff)
@@ -61,17 +56,17 @@
  * beginning, followed by one tr_resp for each hop taken.
  */
 struct tr_resp {
-    u_int32_t tr_qarr;          /* query arrival time */
-    u_int32_t tr_inaddr;        /* incoming interface address */
-    u_int32_t tr_outaddr;       /* outgoing interface address */
-    u_int32_t tr_rmtaddr;       /* parent address in source tree */
-    u_int32_t tr_vifin;         /* input packet count on interface */
-    u_int32_t tr_vifout;        /* output packet count on interface */
-    u_int32_t tr_pktcnt;        /* total incoming packets for src-grp */
-    u_int8_t  tr_rproto;      /* routing proto deployed on router */
-    u_int8_t  tr_fttl;        /* ttl required to forward on outvif */
-    u_int8_t  tr_smask;       /* subnet mask for src addr */
-    u_int8_t  tr_rflags;      /* forwarding error codes */
+    uint32_t tr_qarr;          /* query arrival time */
+    uint32_t tr_inaddr;        /* incoming interface address */
+    uint32_t tr_outaddr;       /* outgoing interface address */
+    uint32_t tr_rmtaddr;       /* parent address in source tree */
+    uint32_t tr_vifin;         /* input packet count on interface */
+    uint32_t tr_vifout;        /* output packet count on interface */
+    uint32_t tr_pktcnt;        /* total incoming packets for src-grp */
+    uint8_t  tr_rproto;      /* routing proto deployed on router */
+    uint8_t  tr_fttl;        /* ttl required to forward on outvif */
+    uint8_t  tr_smask;       /* subnet mask for src addr */
+    uint8_t  tr_rflags;      /* forwarding error codes */
 };
 
 /* defs within mtrace */
@@ -107,118 +102,119 @@
 };
 
 static void
-print_mtrace(register const u_char *bp, register u_int len)
+print_mtrace(netdissect_options *ndo,
+             register const u_char *bp, register u_int len)
 {
     register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
 
-    TCHECK(*tr);
+    ND_TCHECK(*tr);
     if (len < 8 + sizeof (struct tr_query)) {
-	(void)printf(" [invalid len %d]", len);
+	ND_PRINT((ndo, " [invalid len %d]", len));
 	return;
     }
-    printf("mtrace %u: %s to %s reply-to %s",
+    ND_PRINT((ndo, "mtrace %u: %s to %s reply-to %s",
         TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
-        ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
-        ipaddr_string(&tr->tr_raddr));
+        ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst),
+        ipaddr_string(ndo, &tr->tr_raddr)));
     if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
-        printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+        ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))));
     return;
 trunc:
-    (void)printf("[|igmp]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-print_mresp(register const u_char *bp, register u_int len)
+print_mresp(netdissect_options *ndo,
+            register const u_char *bp, register u_int len)
 {
     register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
 
-    TCHECK(*tr);
+    ND_TCHECK(*tr);
     if (len < 8 + sizeof (struct tr_query)) {
-	(void)printf(" [invalid len %d]", len);
+	ND_PRINT((ndo, " [invalid len %d]", len));
 	return;
     }
-    printf("mresp %lu: %s to %s reply-to %s",
+    ND_PRINT((ndo, "mresp %lu: %s to %s reply-to %s",
         (u_long)TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
-        ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
-        ipaddr_string(&tr->tr_raddr));
+        ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst),
+        ipaddr_string(ndo, &tr->tr_raddr)));
     if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
-        printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+        ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))));
     return;
 trunc:
-    (void)printf("[|igmp]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-print_igmpv3_report(register const u_char *bp, register u_int len)
+print_igmpv3_report(netdissect_options *ndo,
+                    register const u_char *bp, register u_int len)
 {
     u_int group, nsrcs, ngroups;
     register u_int i, j;
 
     /* Minimum len is 16, and should be a multiple of 4 */
     if (len < 16 || len & 0x03) {
-	(void)printf(" [invalid len %d]", len);
+	ND_PRINT((ndo, " [invalid len %d]", len));
 	return;
     }
-    TCHECK2(bp[6], 2);
+    ND_TCHECK2(bp[6], 2);
     ngroups = EXTRACT_16BITS(&bp[6]);
-    (void)printf(", %d group record(s)", ngroups);
-    if (vflag > 0) {
+    ND_PRINT((ndo, ", %d group record(s)", ngroups));
+    if (ndo->ndo_vflag > 0) {
 	/* Print the group records */
 	group = 8;
         for (i=0; i<ngroups; i++) {
 	    if (len < group+8) {
-		(void)printf(" [invalid number of groups]");
+		ND_PRINT((ndo, " [invalid number of groups]"));
 		return;
 	    }
-	    TCHECK2(bp[group+4], 4);
-            (void)printf(" [gaddr %s", ipaddr_string(&bp[group+4]));
-	    (void)printf(" %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
-								bp[group]));
+	    ND_TCHECK2(bp[group+4], 4);
+            ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[group+4])));
+	    ND_PRINT((ndo, " %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
+								bp[group])));
             nsrcs = EXTRACT_16BITS(&bp[group+2]);
 	    /* Check the number of sources and print them */
 	    if (len < group+8+(nsrcs<<2)) {
-		(void)printf(" [invalid number of sources %d]", nsrcs);
+		ND_PRINT((ndo, " [invalid number of sources %d]", nsrcs));
 		return;
 	    }
-            if (vflag == 1)
-                (void)printf(", %d source(s)", nsrcs);
+            if (ndo->ndo_vflag == 1)
+                ND_PRINT((ndo, ", %d source(s)", nsrcs));
             else {
 		/* Print the sources */
-                (void)printf(" {");
+                ND_PRINT((ndo, " {"));
                 for (j=0; j<nsrcs; j++) {
-		    TCHECK2(bp[group+8+(j<<2)], 4);
-		    (void)printf(" %s", ipaddr_string(&bp[group+8+(j<<2)]));
+		    ND_TCHECK2(bp[group+8+(j<<2)], 4);
+		    ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[group+8+(j<<2)])));
 		}
-                (void)printf(" }");
+                ND_PRINT((ndo, " }"));
             }
 	    /* Next group record */
             group += 8 + (nsrcs << 2);
-	    (void)printf("]");
+	    ND_PRINT((ndo, "]"));
         }
     }
     return;
 trunc:
-    (void)printf("[|igmp]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-print_igmpv3_query(register const u_char *bp, register u_int len)
+print_igmpv3_query(netdissect_options *ndo,
+                   register const u_char *bp, register u_int len)
 {
     u_int mrc;
     int mrt;
     u_int nsrcs;
     register u_int i;
 
-    (void)printf(" v3");
+    ND_PRINT((ndo, " v3"));
     /* Minimum len is 12, and should be a multiple of 4 */
     if (len < 12 || len & 0x03) {
-	(void)printf(" [invalid len %d]", len);
+	ND_PRINT((ndo, " [invalid len %d]", len));
 	return;
     }
-    TCHECK(bp[1]);
+    ND_TCHECK(bp[1]);
     mrc = bp[1];
     if (mrc < 128) {
 	mrt = mrc;
@@ -226,119 +222,119 @@
         mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3);
     }
     if (mrc != 100) {
-	(void)printf(" [max resp time ");
+	ND_PRINT((ndo, " [max resp time "));
         if (mrt < 600) {
-            (void)printf("%.1fs", mrt * 0.1);
+            ND_PRINT((ndo, "%.1fs", mrt * 0.1));
         } else {
-            relts_print(mrt / 10);
+            relts_print(ndo, mrt / 10);
         }
-	(void)printf("]");
+	ND_PRINT((ndo, "]"));
     }
-    TCHECK2(bp[4], 4);
+    ND_TCHECK2(bp[4], 4);
     if (EXTRACT_32BITS(&bp[4]) == 0)
 	return;
-    (void)printf(" [gaddr %s", ipaddr_string(&bp[4]));
-    TCHECK2(bp[10], 2);
+    ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[4])));
+    ND_TCHECK2(bp[10], 2);
     nsrcs = EXTRACT_16BITS(&bp[10]);
     if (nsrcs > 0) {
 	if (len < 12 + (nsrcs << 2))
-	    (void)printf(" [invalid number of sources]");
-	else if (vflag > 1) {
-	    (void)printf(" {");
+	    ND_PRINT((ndo, " [invalid number of sources]"));
+	else if (ndo->ndo_vflag > 1) {
+	    ND_PRINT((ndo, " {"));
 	    for (i=0; i<nsrcs; i++) {
-		TCHECK2(bp[12+(i<<2)], 4);
-		(void)printf(" %s", ipaddr_string(&bp[12+(i<<2)]));
+		ND_TCHECK2(bp[12+(i<<2)], 4);
+		ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[12+(i<<2)])));
 	    }
-	    (void)printf(" }");
+	    ND_PRINT((ndo, " }"));
 	} else
-	    (void)printf(", %d source(s)", nsrcs);
+	    ND_PRINT((ndo, ", %d source(s)", nsrcs));
     }
-    (void)printf("]");
+    ND_PRINT((ndo, "]"));
     return;
 trunc:
-    (void)printf("[|igmp]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 void
-igmp_print(register const u_char *bp, register u_int len)
+igmp_print(netdissect_options *ndo,
+           register const u_char *bp, register u_int len)
 {
     struct cksum_vec vec[1];
 
-    if (qflag) {
-        (void)printf("igmp");
+    if (ndo->ndo_qflag) {
+        ND_PRINT((ndo, "igmp"));
         return;
     }
 
-    TCHECK(bp[0]);
+    ND_TCHECK(bp[0]);
     switch (bp[0]) {
     case 0x11:
-        (void)printf("igmp query");
+        ND_PRINT((ndo, "igmp query"));
 	if (len >= 12)
-	    print_igmpv3_query(bp, len);
+	    print_igmpv3_query(ndo, bp, len);
 	else {
-            TCHECK(bp[1]);
+            ND_TCHECK(bp[1]);
 	    if (bp[1]) {
-		(void)printf(" v2");
+		ND_PRINT((ndo, " v2"));
 		if (bp[1] != 100)
-		    (void)printf(" [max resp time %d]", bp[1]);
+		    ND_PRINT((ndo, " [max resp time %d]", bp[1]));
 	    } else
-		(void)printf(" v1");
-            TCHECK2(bp[4], 4);
+		ND_PRINT((ndo, " v1"));
+            ND_TCHECK2(bp[4], 4);
 	    if (EXTRACT_32BITS(&bp[4]))
-                (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
+                ND_PRINT((ndo, " [gaddr %s]", ipaddr_string(ndo, &bp[4])));
             if (len != 8)
-                (void)printf(" [len %d]", len);
+                ND_PRINT((ndo, " [len %d]", len));
 	}
         break;
     case 0x12:
-        TCHECK2(bp[4], 4);
-        (void)printf("igmp v1 report %s", ipaddr_string(&bp[4]));
+        ND_TCHECK2(bp[4], 4);
+        ND_PRINT((ndo, "igmp v1 report %s", ipaddr_string(ndo, &bp[4])));
         if (len != 8)
-            (void)printf(" [len %d]", len);
+            ND_PRINT((ndo, " [len %d]", len));
         break;
     case 0x16:
-        TCHECK2(bp[4], 4);
-        (void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
+        ND_TCHECK2(bp[4], 4);
+        ND_PRINT((ndo, "igmp v2 report %s", ipaddr_string(ndo, &bp[4])));
         break;
     case 0x22:
-        (void)printf("igmp v3 report");
-	print_igmpv3_report(bp, len);
+        ND_PRINT((ndo, "igmp v3 report"));
+	print_igmpv3_report(ndo, bp, len);
         break;
     case 0x17:
-        TCHECK2(bp[4], 4);
-        (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
+        ND_TCHECK2(bp[4], 4);
+        ND_PRINT((ndo, "igmp leave %s", ipaddr_string(ndo, &bp[4])));
         break;
     case 0x13:
-        (void)printf("igmp dvmrp");
+        ND_PRINT((ndo, "igmp dvmrp"));
         if (len < 8)
-            (void)printf(" [len %d]", len);
+            ND_PRINT((ndo, " [len %d]", len));
         else
-            dvmrp_print(bp, len);
+            dvmrp_print(ndo, bp, len);
         break;
     case 0x14:
-        (void)printf("igmp pimv1");
-        pimv1_print(bp, len);
+        ND_PRINT((ndo, "igmp pimv1"));
+        pimv1_print(ndo, bp, len);
         break;
     case 0x1e:
-        print_mresp(bp, len);
+        print_mresp(ndo, bp, len);
         break;
     case 0x1f:
-        print_mtrace(bp, len);
+        print_mtrace(ndo, bp, len);
         break;
     default:
-        (void)printf("igmp-%d", bp[0]);
+        ND_PRINT((ndo, "igmp-%d", bp[0]));
         break;
     }
 
-    if (vflag && TTEST2(bp[0], len)) {
+    if (ndo->ndo_vflag && ND_TTEST2(bp[0], len)) {
         /* Check the IGMP checksum */
         vec[0].ptr = bp;
         vec[0].len = len;
         if (in_cksum(vec, 1))
-            printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
+            ND_PRINT((ndo, " bad igmp cksum %x!", EXTRACT_16BITS(&bp[2])));
     }
     return;
 trunc:
-    fputs("[|igmp]", stdout);
+    ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-igrp.c b/print-igrp.c
index 90694b3..fbb3134 100644
--- a/print-igrp.c
+++ b/print-igrp.c
@@ -21,41 +21,65 @@
  * Initial contribution from Francis Dupont (francis.dupont@inria.fr)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.21 2005-04-20 21:01:56 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
-#include "addrtoname.h"
-#include "igrp.h"
-#include "ip.h"
 #include "extract.h"			/* must come after interface.h */
 
+/* Cisco IGRP definitions */
+
+/* IGRP Header */
+
+struct igrphdr {
+	uint8_t ig_vop;	/* protocol version number / opcode */
+#define IGRP_V(x)	(((x) & 0xf0) >> 4)
+#define IGRP_OP(x)	((x) & 0x0f)
+	uint8_t ig_ed;		/* edition number */
+	uint16_t ig_as;	/* autonomous system number */
+	uint16_t ig_ni;	/* number of subnet in local net */
+	uint16_t ig_ns;	/* number of networks in AS */
+	uint16_t ig_nx;	/* number of networks ouside AS */
+	uint16_t ig_sum;	/* checksum of IGRP header & data */
+};
+
+#define IGRP_UPDATE	1
+#define IGRP_REQUEST	2
+
+/* IGRP routing entry */
+
+struct igrprte {
+	uint8_t igr_net[3];	/* 3 significant octets of IP address */
+	uint8_t igr_dly[3];	/* delay in tens of microseconds */
+	uint8_t igr_bw[3];	/* bandwidth in units of 1 kb/s */
+	uint8_t igr_mtu[2];	/* MTU in octets */
+	uint8_t igr_rel;	/* percent packets successfully tx/rx */
+	uint8_t igr_ld;	/* percent of channel occupied */
+	uint8_t igr_hct;	/* hop count */
+};
+
+#define IGRP_RTE_SIZE	14	/* don't believe sizeof ! */
+
 static void
-igrp_entry_print(register struct igrprte *igr, register int is_interior,
-    register int is_exterior)
+igrp_entry_print(netdissect_options *ndo, register struct igrprte *igr,
+    register int is_interior, register int is_exterior)
 {
 	register u_int delay, bandwidth;
 	u_int metric, mtu;
 
 	if (is_interior)
-		printf(" *.%d.%d.%d", igr->igr_net[0],
-		    igr->igr_net[1], igr->igr_net[2]);
+		ND_PRINT((ndo, " *.%d.%d.%d", igr->igr_net[0],
+		    igr->igr_net[1], igr->igr_net[2]));
 	else if (is_exterior)
-		printf(" X%d.%d.%d.0", igr->igr_net[0],
-		    igr->igr_net[1], igr->igr_net[2]);
+		ND_PRINT((ndo, " X%d.%d.%d.0", igr->igr_net[0],
+		    igr->igr_net[1], igr->igr_net[2]));
 	else
-		printf(" %d.%d.%d.0", igr->igr_net[0],
-		    igr->igr_net[1], igr->igr_net[2]);
+		ND_PRINT((ndo, " %d.%d.%d.0", igr->igr_net[0],
+		    igr->igr_net[1], igr->igr_net[2]));
 
 	delay = EXTRACT_24BITS(igr->igr_dly);
 	bandwidth = EXTRACT_24BITS(igr->igr_bw);
@@ -64,10 +88,10 @@
 		metric = 0xffffff;
 	mtu = EXTRACT_16BITS(igr->igr_mtu);
 
-	printf(" d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
+	ND_PRINT((ndo, " d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
 	    10 * delay, bandwidth == 0 ? 0 : 10000000 / bandwidth,
 	    igr->igr_rel, igr->igr_ld, metric,
-	    mtu, igr->igr_hct);
+	    mtu, igr->igr_hct));
 }
 
 static const struct tok op2str[] = {
@@ -77,7 +101,7 @@
 };
 
 void
-igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_)
+igrp_print(netdissect_options *ndo, register const u_char *bp, u_int length)
 {
 	register struct igrphdr *hdr;
 	register u_char *cp;
@@ -85,39 +109,39 @@
 
 	hdr = (struct igrphdr *)bp;
 	cp = (u_char *)(hdr + 1);
-        (void)printf("igrp:");
+	ND_PRINT((ndo, "igrp:"));
 
 	/* Header */
-	TCHECK(*hdr);
+	ND_TCHECK(*hdr);
 	nint = EXTRACT_16BITS(&hdr->ig_ni);
 	nsys = EXTRACT_16BITS(&hdr->ig_ns);
 	next = EXTRACT_16BITS(&hdr->ig_nx);
 
-	(void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)",
+	ND_PRINT((ndo, " %s V%d edit=%d AS=%d (%d/%d/%d)",
 	    tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)),
 	    IGRP_V(hdr->ig_vop),
 	    hdr->ig_ed,
 	    EXTRACT_16BITS(&hdr->ig_as),
 	    nint,
 	    nsys,
-	    next);
+	    next));
 
 	length -= sizeof(*hdr);
 	while (length >= IGRP_RTE_SIZE) {
 		if (nint > 0) {
-			TCHECK2(*cp, IGRP_RTE_SIZE);
-			igrp_entry_print((struct igrprte *)cp, 1, 0);
+			ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+			igrp_entry_print(ndo, (struct igrprte *)cp, 1, 0);
 			--nint;
 		} else if (nsys > 0) {
-			TCHECK2(*cp, IGRP_RTE_SIZE);
-			igrp_entry_print((struct igrprte *)cp, 0, 0);
+			ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+			igrp_entry_print(ndo, (struct igrprte *)cp, 0, 0);
 			--nsys;
 		} else if (next > 0) {
-			TCHECK2(*cp, IGRP_RTE_SIZE);
-			igrp_entry_print((struct igrprte *)cp, 0, 1);
+			ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+			igrp_entry_print(ndo, (struct igrprte *)cp, 0, 1);
 			--next;
 		} else {
-			(void)printf(" [extra bytes %d]", length);
+			ND_PRINT((ndo, " [extra bytes %d]", length));
 			break;
 		}
 		cp += IGRP_RTE_SIZE;
@@ -126,5 +150,5 @@
 	if (nint == 0 && nsys == 0 && next == 0)
 		return;
 trunc:
-	fputs(" [|igrp]", stdout);
+	ND_PRINT((ndo, " [|igrp]"));
 }
diff --git a/print-ip.c b/print-ip.c
index c0fc56b..ceea536 100644
--- a/print-ip.c
+++ b/print-ip.c
@@ -19,28 +19,24 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
-#include "addrtoname.h"
 #include "interface.h"
+#include "addrtoname.h"
 #include "extract.h"			/* must come after interface.h */
 
 #include "ip.h"
 #include "ipproto.h"
 
+static const char tstr[] = "[|ip]";
+
 static const struct tok ip_option_values[] = {
     { IPOPT_EOL, "EOL" },
     { IPOPT_NOP, "NOP" },
@@ -58,25 +54,26 @@
  * print the recorded route in an IP RR, LSRR or SSRR option.
  */
 static void
-ip_printroute(register const u_char *cp, u_int length)
+ip_printroute(netdissect_options *ndo,
+              register const u_char *cp, u_int length)
 {
 	register u_int ptr;
 	register u_int len;
 
 	if (length < 3) {
-		printf(" [bad length %u]", length);
+		ND_PRINT((ndo, " [bad length %u]", length));
 		return;
 	}
 	if ((length + 1) & 3)
-		printf(" [bad length %u]", length);
+		ND_PRINT((ndo, " [bad length %u]", length));
 	ptr = cp[2] - 1;
 	if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
-		printf(" [bad ptr %u]", cp[2]);
+		ND_PRINT((ndo, " [bad ptr %u]", cp[2]));
 
 	for (len = 3; len < length; len += 4) {
-		printf(" %s", ipaddr_string(&cp[len]));
-                if (ptr > len)
-                        printf(",");
+		ND_PRINT((ndo, " %s", ipaddr_string(ndo, &cp[len])));
+		if (ptr > len)
+			ND_PRINT((ndo, ","));
 	}
 }
 
@@ -87,13 +84,14 @@
  * This is used for UDP and TCP pseudo-header in the checksum
  * calculation.
  */
-static u_int32_t
-ip_finddst(const struct ip *ip)
+static uint32_t
+ip_finddst(netdissect_options *ndo,
+           const struct ip *ip)
 {
 	int length;
 	int len;
 	const u_char *cp;
-	u_int32_t retval;
+	uint32_t retval;
 
 	cp = (const u_char *)(ip + 1);
 	length = (IP_HL(ip) << 2) - sizeof(struct ip);
@@ -101,19 +99,19 @@
 	for (; length > 0; cp += len, length -= len) {
 		int tt;
 
-		TCHECK(*cp);
+		ND_TCHECK(*cp);
 		tt = *cp;
 		if (tt == IPOPT_EOL)
 			break;
 		else if (tt == IPOPT_NOP)
 			len = 1;
 		else {
-			TCHECK(cp[1]);
+			ND_TCHECK(cp[1]);
 			len = cp[1];
 			if (len < 2)
 				break;
 		}
-		TCHECK2(*cp, len);
+		ND_TCHECK2(*cp, len);
 		switch (tt) {
 
 		case IPOPT_SSRR:
@@ -125,7 +123,7 @@
 		}
 	}
 trunc:
-	UNALIGNED_MEMCPY(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+	UNALIGNED_MEMCPY(&retval, &ip->ip_dst.s_addr, sizeof(uint32_t));
 	return retval;
 }
 
@@ -133,37 +131,39 @@
  * Compute a V4-style checksum by building a pseudoheader.
  */
 int
-nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
-		 u_int len, u_int next_proto)
+nextproto4_cksum(netdissect_options *ndo,
+                 const struct ip *ip, const uint8_t *data,
+                 u_int len, u_int covlen, u_int next_proto)
 {
 	struct phdr {
-		u_int32_t src;
-		u_int32_t dst;
+		uint32_t src;
+		uint32_t dst;
 		u_char mbz;
 		u_char proto;
-		u_int16_t len;
+		uint16_t len;
 	} ph;
 	struct cksum_vec vec[2];
 
 	/* pseudo-header.. */
-	ph.len = htons((u_int16_t)len);
+	ph.len = htons((uint16_t)len);
 	ph.mbz = 0;
 	ph.proto = next_proto;
-	UNALIGNED_MEMCPY(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
+	UNALIGNED_MEMCPY(&ph.src, &ip->ip_src.s_addr, sizeof(uint32_t));
 	if (IP_HL(ip) == 5)
-		UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+		UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst.s_addr, sizeof(uint32_t));
 	else
-		ph.dst = ip_finddst(ip);
+		ph.dst = ip_finddst(ndo, ip);
 
-	vec[0].ptr = (const u_int8_t *)(void *)&ph;
+	vec[0].ptr = (const uint8_t *)(void *)&ph;
 	vec[0].len = sizeof(ph);
 	vec[1].ptr = data;
-	vec[1].len = len;
+	vec[1].len = covlen;
 	return (in_cksum(vec, 2));
 }
 
 static void
-ip_printts(register const u_char *cp, u_int length)
+ip_printts(netdissect_options *ndo,
+           register const u_char *cp, u_int length)
 {
 	register u_int ptr;
 	register u_int len;
@@ -171,23 +171,23 @@
 	const char *type;
 
 	if (length < 4) {
-		printf("[bad length %u]", length);
+		ND_PRINT((ndo, "[bad length %u]", length));
 		return;
 	}
-	printf(" TS{");
+	ND_PRINT((ndo, " TS{"));
 	hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
 	if ((length - 4) & (hoplen-1))
-		printf("[bad length %u]", length);
+		ND_PRINT((ndo, "[bad length %u]", length));
 	ptr = cp[2] - 1;
 	len = 0;
 	if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
-		printf("[bad ptr %u]", cp[2]);
+		ND_PRINT((ndo, "[bad ptr %u]", cp[2]));
 	switch (cp[3]&0xF) {
 	case IPOPT_TS_TSONLY:
-		printf("TSONLY");
+		ND_PRINT((ndo, "TSONLY"));
 		break;
 	case IPOPT_TS_TSANDADDR:
-		printf("TS+ADDR");
+		ND_PRINT((ndo, "TS+ADDR"));
 		break;
 	/*
 	 * prespecified should really be 3, but some ones might send 2
@@ -196,13 +196,13 @@
 	 */
 
 	case 2:
-		printf("PRESPEC2.0");
+		ND_PRINT((ndo, "PRESPEC2.0"));
 		break;
 	case 3:			/* IPOPT_TS_PRESPEC */
-		printf("PRESPEC");
+		ND_PRINT((ndo, "PRESPEC"));
 		break;
 	default:
-		printf("[bad ts type %d]", cp[3]&0xF);
+		ND_PRINT((ndo, "[bad ts type %d]", cp[3]&0xF));
 		goto done;
 	}
 
@@ -210,25 +210,26 @@
 	for (len = 4; len < length; len += hoplen) {
 		if (ptr == len)
 			type = " ^ ";
-		printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
-		       hoplen!=8 ? "" : ipaddr_string(&cp[len]));
+		ND_PRINT((ndo, "%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
+		       hoplen!=8 ? "" : ipaddr_string(ndo, &cp[len])));
 		type = " ";
 	}
 
 done:
-	printf("%s", ptr == len ? " ^ " : "");
+	ND_PRINT((ndo, "%s", ptr == len ? " ^ " : ""));
 
 	if (cp[3]>>4)
-		printf(" [%d hops not recorded]} ", cp[3]>>4);
+		ND_PRINT((ndo, " [%d hops not recorded]} ", cp[3]>>4));
 	else
-		printf("}");
+		ND_PRINT((ndo, "}"));
 }
 
 /*
  * print IP options.
  */
 static void
-ip_optprint(register const u_char *cp, u_int length)
+ip_optprint(netdissect_options *ndo,
+            register const u_char *cp, u_int length)
 {
 	register u_int option_len;
 	const char *sep = "";
@@ -236,57 +237,57 @@
 	for (; length > 0; cp += option_len, length -= option_len) {
 		u_int option_code;
 
-		printf("%s", sep);
+		ND_PRINT((ndo, "%s", sep));
 		sep = ",";
 
-		TCHECK(*cp);
+		ND_TCHECK(*cp);
 		option_code = *cp;
 
-                printf("%s",
-                        tok2str(ip_option_values,"unknown %u",option_code));
+		ND_PRINT((ndo, "%s",
+		          tok2str(ip_option_values,"unknown %u",option_code)));
 
 		if (option_code == IPOPT_NOP ||
                     option_code == IPOPT_EOL)
 			option_len = 1;
 
 		else {
-			TCHECK(cp[1]);
+			ND_TCHECK(cp[1]);
 			option_len = cp[1];
 			if (option_len < 2) {
-		                printf(" [bad length %u]", option_len);
+				ND_PRINT((ndo, " [bad length %u]", option_len));
 				return;
 			}
 		}
 
 		if (option_len > length) {
-	                printf(" [bad length %u]", option_len);
+			ND_PRINT((ndo, " [bad length %u]", option_len));
 			return;
 		}
 
-                TCHECK2(*cp, option_len);
+		ND_TCHECK2(*cp, option_len);
 
 		switch (option_code) {
 		case IPOPT_EOL:
 			return;
 
 		case IPOPT_TS:
-			ip_printts(cp, option_len);
+			ip_printts(ndo, cp, option_len);
 			break;
 
 		case IPOPT_RR:       /* fall through */
 		case IPOPT_SSRR:
 		case IPOPT_LSRR:
-			ip_printroute(cp, option_len);
+			ip_printroute(ndo, cp, option_len);
 			break;
 
 		case IPOPT_RA:
 			if (option_len < 4) {
-				printf(" [bad length %u]", option_len);
+				ND_PRINT((ndo, " [bad length %u]", option_len));
 				break;
 			}
-                        TCHECK(cp[3]);
-                        if (EXTRACT_16BITS(&cp[2]) != 0)
-                            printf(" value %u", EXTRACT_16BITS(&cp[2]));
+			ND_TCHECK(cp[3]);
+			if (EXTRACT_16BITS(&cp[2]) != 0)
+				ND_PRINT((ndo, " value %u", EXTRACT_16BITS(&cp[2])));
 			break;
 
 		case IPOPT_NOP:       /* nothing to print - fall through */
@@ -298,7 +299,7 @@
 	return;
 
 trunc:
-	printf("[|ip]");
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 #define IP_RES 0x8000
@@ -330,7 +331,7 @@
 
 	case IPPROTO_AH:
 		ipds->nh = *ipds->cp;
-		ipds->advance = ah_print(ipds->cp);
+		ipds->advance = ah_print(ndo, ipds->cp);
 		if (ipds->advance <= 0)
 			break;
 		ipds->cp += ipds->advance;
@@ -354,7 +355,7 @@
 	case IPPROTO_IPCOMP:
 	{
 		int enh;
-		ipds->advance = ipcomp_print(ipds->cp, &enh);
+		ipds->advance = ipcomp_print(ndo, ipds->cp, &enh);
 		if (ipds->advance <= 0)
 			break;
 		ipds->cp += ipds->advance;
@@ -364,28 +365,28 @@
 	}
 
 	case IPPROTO_SCTP:
-		sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+		sctp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
 		break;
 
 	case IPPROTO_DCCP:
-		dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+		dccp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
 		break;
 
 	case IPPROTO_TCP:
 		/* pass on the MF bit plus the offset to detect fragments */
-		tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+		tcp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
 			  ipds->off & (IP_MF|IP_OFFMASK));
 		break;
 
 	case IPPROTO_UDP:
 		/* pass on the MF bit plus the offset to detect fragments */
-		udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+		udp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
 			  ipds->off & (IP_MF|IP_OFFMASK));
 		break;
 
 	case IPPROTO_ICMP:
 		/* pass on the MF bit plus the offset to detect fragments */
-		icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+		icmp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
 			   ipds->off & (IP_MF|IP_OFFMASK));
 		break;
 
@@ -403,11 +404,11 @@
 		 * match was the current protocol number
 		 * assignments say.
 		 */
-		igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+		igrp_print(ndo, ipds->cp, ipds->len);
 		break;
 
 	case IPPROTO_EIGRP:
-		eigrp_print(ipds->cp, ipds->len);
+		eigrp_print(ndo, ipds->cp, ipds->len);
 		break;
 
 	case IPPROTO_ND:
@@ -415,70 +416,69 @@
 		break;
 
 	case IPPROTO_EGP:
-		egp_print(ipds->cp, ipds->len);
+		egp_print(ndo, ipds->cp, ipds->len);
 		break;
 
 	case IPPROTO_OSPF:
-		ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+		ospf_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
 		break;
 
 	case IPPROTO_IGMP:
-		igmp_print(ipds->cp, ipds->len);
+		igmp_print(ndo, ipds->cp, ipds->len);
 		break;
 
 	case IPPROTO_IPV4:
 		/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
 		ip_print(ndo, ipds->cp, ipds->len);
-		if (! vflag) {
+		if (! ndo->ndo_vflag) {
 			ND_PRINT((ndo, " (ipip-proto-4)"));
 			return;
 		}
 		break;
 
-#ifdef INET6
 	case IPPROTO_IPV6:
 		/* ip6-in-ip encapsulation */
 		ip6_print(ndo, ipds->cp, ipds->len);
 		break;
-#endif /*INET6*/
 
 	case IPPROTO_RSVP:
-		rsvp_print(ipds->cp, ipds->len);
+		rsvp_print(ndo, ipds->cp, ipds->len);
 		break;
 
 	case IPPROTO_GRE:
 		/* do it */
-		gre_print(ipds->cp, ipds->len);
+		gre_print(ndo, ipds->cp, ipds->len);
 		break;
 
 	case IPPROTO_MOBILE:
-		mobile_print(ipds->cp, ipds->len);
+		mobile_print(ndo, ipds->cp, ipds->len);
 		break;
 
 	case IPPROTO_PIM:
 		vec[0].ptr = ipds->cp;
 		vec[0].len = ipds->len;
-		pim_print(ipds->cp, ipds->len, in_cksum(vec, 1));
+		pim_print(ndo, ipds->cp, ipds->len, in_cksum(vec, 1));
 		break;
 
 	case IPPROTO_VRRP:
-		if (packettype == PT_CARP) {
-			if (vflag)
-				(void)printf("carp %s > %s: ",
-					     ipaddr_string(&ipds->ip->ip_src),
-					     ipaddr_string(&ipds->ip->ip_dst));
-			carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+		if (ndo->ndo_packettype == PT_CARP) {
+			if (ndo->ndo_vflag)
+				ND_PRINT((ndo, "carp %s > %s: ",
+					     ipaddr_string(ndo, &ipds->ip->ip_src),
+					     ipaddr_string(ndo, &ipds->ip->ip_dst)));
+			carp_print(ndo, ipds->cp, ipds->len, ipds->ip->ip_ttl);
 		} else {
-			if (vflag)
-				(void)printf("vrrp %s > %s: ",
-					     ipaddr_string(&ipds->ip->ip_src),
-					     ipaddr_string(&ipds->ip->ip_dst));
-			vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+			if (ndo->ndo_vflag)
+				ND_PRINT((ndo, "vrrp %s > %s: ",
+					     ipaddr_string(ndo, &ipds->ip->ip_src),
+					     ipaddr_string(ndo, &ipds->ip->ip_dst)));
+			vrrp_print(ndo, ipds->cp, ipds->len,
+				(const u_char *)ipds->ip, ipds->ip->ip_ttl);
 		}
 		break;
 
 	case IPPROTO_PGM:
-		pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+		pgm_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
 		break;
 
 	default:
@@ -523,40 +523,39 @@
 	const u_char *ipend;
 	u_int hlen;
 	struct cksum_vec vec[1];
-	u_int16_t sum, ip_sum;
+	uint16_t sum, ip_sum;
 	struct protoent *proto;
 
 	ipds->ip = (const struct ip *)bp;
+	ND_TCHECK(ipds->ip->ip_vhl);
 	if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
-	    printf("IP%u ", IP_V(ipds->ip));
 	    if (IP_V(ipds->ip) == 6)
-		printf(", wrong link-layer encapsulation");
+	      ND_PRINT((ndo, "IP6, wrong link-layer encapsulation "));
+	    else
+	      ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip)));
 	}
-        else if (!eflag)
-	    printf("IP ");
+	else if (!ndo->ndo_eflag)
+		ND_PRINT((ndo, "IP "));
 
-	if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) {
-		printf("[|ip]");
-		return;
-	}
+	ND_TCHECK(*ipds->ip);
 	if (length < sizeof (struct ip)) {
-		(void)printf("truncated-ip %u", length);
+		ND_PRINT((ndo, "truncated-ip %u", length));
 		return;
 	}
 	hlen = IP_HL(ipds->ip) * 4;
 	if (hlen < sizeof (struct ip)) {
-		(void)printf("bad-hlen %u", hlen);
+		ND_PRINT((ndo, "bad-hlen %u", hlen));
 		return;
 	}
 
 	ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len);
 	if (length < ipds->len)
-		(void)printf("truncated-ip - %u bytes missing! ",
-			ipds->len - length);
+		ND_PRINT((ndo, "truncated-ip - %u bytes missing! ",
+			ipds->len - length));
 	if (ipds->len < hlen) {
 #ifdef GUESS_TSO
             if (ipds->len) {
-                (void)printf("bad-len %u", ipds->len);
+                ND_PRINT((ndo, "bad-len %u", ipds->len));
                 return;
             }
             else {
@@ -564,7 +563,7 @@
                 ipds->len = length;
             }
 #else
-            (void)printf("bad-len %u", ipds->len);
+            ND_PRINT((ndo, "bad-len %u", ipds->len));
             return;
 #endif /* GUESS_TSO */
 	}
@@ -580,24 +579,24 @@
 
 	ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
 
-        if (vflag) {
-            (void)printf("(tos 0x%x", (int)ipds->ip->ip_tos);
+        if (ndo->ndo_vflag) {
+            ND_PRINT((ndo, "(tos 0x%x", (int)ipds->ip->ip_tos));
             /* ECN bits */
             if (ipds->ip->ip_tos & 0x03) {
                 switch (ipds->ip->ip_tos & 0x03) {
                 case 1:
-                    (void)printf(",ECT(1)");
+                    ND_PRINT((ndo, ",ECT(1)"));
                     break;
                 case 2:
-                    (void)printf(",ECT(0)");
+                    ND_PRINT((ndo, ",ECT(0)"));
                     break;
                 case 3:
-                    (void)printf(",CE");
+                    ND_PRINT((ndo, ",CE"));
                 }
             }
 
             if (ipds->ip->ip_ttl >= 1)
-                (void)printf(", ttl %u", ipds->ip->ip_ttl);
+                ND_PRINT((ndo, ", ttl %u", ipds->ip->ip_ttl));
 
 	    /*
 	     * for the firewall guys, print id, offset.
@@ -605,33 +604,33 @@
 	     * For unfragmented datagrams, note the don't fragment flag.
 	     */
 
-	    (void)printf(", id %u, offset %u, flags [%s], proto %s (%u)",
+	    ND_PRINT((ndo, ", id %u, offset %u, flags [%s], proto %s (%u)",
                          EXTRACT_16BITS(&ipds->ip->ip_id),
                          (ipds->off & 0x1fff) * 8,
                          bittok2str(ip_frag_values, "none", ipds->off&0xe000),
                          tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
-                         ipds->ip->ip_p);
+                         ipds->ip->ip_p));
 
-            (void)printf(", length %u", EXTRACT_16BITS(&ipds->ip->ip_len));
+            ND_PRINT((ndo, ", length %u", EXTRACT_16BITS(&ipds->ip->ip_len)));
 
             if ((hlen - sizeof(struct ip)) > 0) {
-                printf(", options (");
-                ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
-                printf(")");
+                ND_PRINT((ndo, ", options ("));
+                ip_optprint(ndo, (u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
+                ND_PRINT((ndo, ")"));
             }
 
-	    if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
-	        vec[0].ptr = (const u_int8_t *)(void *)ipds->ip;
+	    if (!ndo->ndo_Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
+	        vec[0].ptr = (const uint8_t *)(void *)ipds->ip;
 	        vec[0].len = hlen;
 	        sum = in_cksum(vec, 1);
 		if (sum != 0) {
 		    ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
-		    (void)printf(", bad cksum %x (->%x)!", ip_sum,
-			     in_cksum_shouldbe(ip_sum, sum));
+		    ND_PRINT((ndo, ", bad cksum %x (->%x)!", ip_sum,
+			     in_cksum_shouldbe(ip_sum, sum)));
 		}
 	    }
 
-            printf(")\n    ");
+		ND_PRINT((ndo, ")\n    "));
 	}
 
 	/*
@@ -644,52 +643,55 @@
 
 		if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
 		    ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) {
-			(void)printf("%s > %s: ",
-				     ipaddr_string(&ipds->ip->ip_src),
-				     ipaddr_string(&ipds->ip->ip_dst));
+			ND_PRINT((ndo, "%s > %s: ",
+				     ipaddr_string(ndo, &ipds->ip->ip_src),
+				     ipaddr_string(ndo, &ipds->ip->ip_dst)));
 		}
 		ip_print_demux(ndo, ipds);
 	} else {
 	    /* Ultra quiet now means that all this stuff should be suppressed */
-	    if (qflag > 1) return;
+	    if (ndo->ndo_qflag > 1) return;
 
 	    /*
 	     * if this isn't the first frag, we're missing the
 	     * next level protocol header.  print the ip addr
 	     * and the protocol.
 	     */
-	    if (ipds->off & 0x1fff) {
-	        (void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src),
-			     ipaddr_string(&ipds->ip->ip_dst));
-		if (!ndo->ndo_nflag && (proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
-		    (void)printf(" %s", proto->p_name);
-		else
-		    (void)printf(" ip-proto-%d", ipds->ip->ip_p);
-	    }
+		if (ipds->off & 0x1fff) {
+			ND_PRINT((ndo, "%s > %s:", ipaddr_string(ndo, &ipds->ip->ip_src),
+			          ipaddr_string(ndo, &ipds->ip->ip_dst)));
+			if (!ndo->ndo_nflag && (proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
+				ND_PRINT((ndo, " %s", proto->p_name));
+			else
+				ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
+		}
 	}
+	return;
+
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return;
 }
 
 void
-ipN_print(register const u_char *bp, register u_int length)
+ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
 {
 	struct ip hdr;
 
 	if (length < 4) {
-		(void)printf("truncated-ip %d", length);
+		ND_PRINT((ndo, "truncated-ip %d", length));
 		return;
 	}
 	memcpy (&hdr, bp, 4);
 	switch (IP_V(&hdr)) {
 	case 4:
-		ip_print (gndo, bp, length);
+		ip_print (ndo, bp, length);
 		return;
-#ifdef INET6
 	case 6:
-		ip6_print (gndo, bp, length);
+		ip6_print (ndo, bp, length);
 		return;
-#endif
 	default:
-		(void)printf("unknown ip %d", IP_V(&hdr));
+		ND_PRINT((ndo, "unknown ip %d", IP_V(&hdr)));
 		return;
 	}
 }
diff --git a/print-ip6.c b/print-ip6.c
index 3e8db27..dd6b7f5 100644
--- a/print-ip6.c
+++ b/print-ip6.c
@@ -19,28 +19,21 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.52 2007-09-21 07:05:33 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifdef INET6
-
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
-#include "netdissect.h"
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 
+#ifdef INET6
+
 #include "ip6.h"
 #include "ipproto.h"
 
@@ -48,15 +41,15 @@
  * Compute a V6-style checksum by building a pseudoheader.
  */
 int
-nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
-		 u_int len, u_int next_proto)
+nextproto6_cksum(const struct ip6_hdr *ip6, const uint8_t *data,
+		 u_int len, u_int covlen, u_int next_proto)
 {
         struct {
                 struct in6_addr ph_src;
                 struct in6_addr ph_dst;
-                u_int32_t       ph_len;
-                u_int8_t        ph_zero[3];
-                u_int8_t        ph_nxt;
+                uint32_t       ph_len;
+                uint8_t        ph_zero[3];
+                uint8_t        ph_nxt;
         } ph;
         struct cksum_vec vec[2];
 
@@ -67,10 +60,10 @@
         ph.ph_len = htonl(len);
         ph.ph_nxt = next_proto;
 
-        vec[0].ptr = (const u_int8_t *)(void *)&ph;
+        vec[0].ptr = (const uint8_t *)(void *)&ph;
         vec[0].len = sizeof(ph);
         vec[1].ptr = data;
-        vec[1].len = len;
+        vec[1].len = covlen;
 
         return in_cksum(vec, 2);
 }
@@ -93,19 +86,24 @@
 
 	ip6 = (const struct ip6_hdr *)bp;
 
-	TCHECK(*ip6);
+	ND_TCHECK(*ip6);
 	if (length < sizeof (struct ip6_hdr)) {
-		(void)ND_PRINT((ndo, "truncated-ip6 %u", length));
+		ND_PRINT((ndo, "truncated-ip6 %u", length));
 		return;
 	}
 
         if (!ndo->ndo_eflag)
             ND_PRINT((ndo, "IP6 "));
 
+	if (IP6_VERSION(ip6) != 6) {
+          ND_PRINT((ndo,"version error: %u != 6", IP6_VERSION(ip6)));
+          return;
+	}
+
 	payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
 	len = payload_len + sizeof(struct ip6_hdr);
 	if (length < len)
-		(void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
+		ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
 			len - length));
 
         if (ndo->ndo_vflag) {
@@ -114,18 +112,18 @@
 #if 0
             /* rfc1883 */
             if (flow & 0x0f000000)
-		(void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
+		ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
             if (flow & 0x00ffffff)
-		(void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
+		ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
 #else
             /* RFC 2460 */
             if (flow & 0x0ff00000)
-		(void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
+		ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
             if (flow & 0x000fffff)
-		(void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
+		ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
 #endif
 
-            (void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
+            ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
                          ip6->ip6_hlim,
                          tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
                          ip6->ip6_nxt,
@@ -149,21 +147,21 @@
 		if (cp == (const u_char *)(ip6 + 1) &&
 		    nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
 		    nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
-			(void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src),
-				     ip6addr_string(&ip6->ip6_dst)));
+			ND_PRINT((ndo, "%s > %s: ", ip6addr_string(ndo, &ip6->ip6_src),
+				     ip6addr_string(ndo, &ip6->ip6_dst)));
 		}
 
 		switch (nh) {
 		case IPPROTO_HOPOPTS:
-			advance = hbhopt_print(cp);
+			advance = hbhopt_print(ndo, cp);
 			nh = *cp;
 			break;
 		case IPPROTO_DSTOPTS:
-			advance = dstopt_print(cp);
+			advance = dstopt_print(ndo, cp);
 			nh = *cp;
 			break;
 		case IPPROTO_FRAGMENT:
-			advance = frag6_print(cp, (const u_char *)ip6);
+			advance = frag6_print(ndo, cp, (const u_char *)ip6);
 			if (ndo->ndo_snapend <= cp + advance)
 				return;
 			nh = *cp;
@@ -182,30 +180,30 @@
 			 * which payload can be piggybacked atop a
 			 * mobility header.
 			 */
-			advance = mobility_print(cp, (const u_char *)ip6);
+			advance = mobility_print(ndo, cp, (const u_char *)ip6);
 			nh = *cp;
 			return;
 		case IPPROTO_ROUTING:
-			advance = rt6_print(cp, (const u_char *)ip6);
+			advance = rt6_print(ndo, cp, (const u_char *)ip6);
 			nh = *cp;
 			break;
 		case IPPROTO_SCTP:
-			sctp_print(cp, (const u_char *)ip6, len);
+			sctp_print(ndo, cp, (const u_char *)ip6, len);
 			return;
 		case IPPROTO_DCCP:
-			dccp_print(cp, (const u_char *)ip6, len);
+			dccp_print(ndo, cp, (const u_char *)ip6, len);
 			return;
 		case IPPROTO_TCP:
-			tcp_print(cp, len, (const u_char *)ip6, fragmented);
+			tcp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
 			return;
 		case IPPROTO_UDP:
-			udp_print(cp, len, (const u_char *)ip6, fragmented);
+			udp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
 			return;
 		case IPPROTO_ICMPV6:
 			icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
 			return;
 		case IPPROTO_AH:
-			advance = ah_print(cp);
+			advance = ah_print(ndo, cp);
 			nh = *cp;
 			break;
 		case IPPROTO_ESP:
@@ -219,18 +217,18 @@
 		case IPPROTO_IPCOMP:
 		    {
 			int enh;
-			advance = ipcomp_print(cp, &enh);
+			advance = ipcomp_print(ndo, cp, &enh);
 			nh = enh & 0xff;
 			break;
 		    }
 
 		case IPPROTO_PIM:
-			pim_print(cp, len, nextproto6_cksum(ip6, cp, len,
+			pim_print(ndo, cp, len, nextproto6_cksum(ip6, cp, len, len,
 							    IPPROTO_PIM));
 			return;
 
 		case IPPROTO_OSPF:
-			ospf6_print(cp, len);
+			ospf6_print(ndo, cp, len);
 			return;
 
 		case IPPROTO_IPV6:
@@ -242,30 +240,38 @@
 			return;
 
                 case IPPROTO_PGM:
-                        pgm_print(cp, len, (const u_char *)ip6);
+                        pgm_print(ndo, cp, len, (const u_char *)ip6);
                         return;
 
 		case IPPROTO_GRE:
-			gre_print(cp, len);
+			gre_print(ndo, cp, len);
 			return;
 
 		case IPPROTO_RSVP:
-			rsvp_print(cp, len);
+			rsvp_print(ndo, cp, len);
 			return;
 
 		case IPPROTO_NONE:
-			(void)ND_PRINT((ndo, "no next header"));
+			ND_PRINT((ndo, "no next header"));
 			return;
 
 		default:
-			(void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
+			ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
 			return;
 		}
 	}
 
 	return;
 trunc:
-	(void)ND_PRINT((ndo, "[|ip6]"));
+	ND_PRINT((ndo, "[|ip6]"));
+}
+
+#else /* INET6 */
+
+void
+ip6_print(netdissect_options *ndo, const u_char *bp _U_, u_int length)
+{
+	ND_PRINT((ndo, "IP6, length: %u (printing not supported)", length));
 }
 
 #endif /* INET6 */
diff --git a/print-ip6opts.c b/print-ip6opts.c
index 2121b46..14ad42c 100644
--- a/print-ip6opts.c
+++ b/print-ip6opts.c
@@ -27,51 +27,22 @@
  * SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.18 2005-04-20 22:18:50 guy Exp $";
-#endif
-
 #ifdef INET6
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "ip6.h"
 
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 
-/* items outside of rfc2292bis */
-#ifndef IP6OPT_MINLEN
-#define IP6OPT_MINLEN	2
-#endif
-#ifndef IP6OPT_RTALERT_LEN
-#define IP6OPT_RTALERT_LEN	4
-#endif
-#ifndef IP6OPT_JUMBO_LEN
-#define IP6OPT_JUMBO_LEN	6
-#endif
-#define IP6OPT_HOMEADDR_MINLEN 18
-#define IP6OPT_BU_MINLEN       10
-#define IP6OPT_BA_MINLEN       13
-#define IP6OPT_BR_MINLEN        2
-#define IP6SOPT_UI            0x2
-#define IP6SOPT_UI_MINLEN       4
-#define IP6SOPT_ALTCOA        0x3
-#define IP6SOPT_ALTCOA_MINLEN  18
-#define IP6SOPT_AUTH          0x4
-#define IP6SOPT_AUTH_MINLEN     6
-
-static void ip6_sopt_print(const u_char *, int);
-
 static void
-ip6_sopt_print(const u_char *bp, int len)
+ip6_sopt_print(netdissect_options *ndo, const u_char *bp, int len)
 {
     int i;
     int optlen;
@@ -90,53 +61,32 @@
 
 	switch (bp[i]) {
 	case IP6OPT_PAD1:
-            printf(", pad1");
+            ND_PRINT((ndo, ", pad1"));
 	    break;
 	case IP6OPT_PADN:
 	    if (len - i < IP6OPT_MINLEN) {
-		printf(", padn: trunc");
+		ND_PRINT((ndo, ", padn: trunc"));
 		goto trunc;
 	    }
-            printf(", padn");
-	    break;
-        case IP6SOPT_UI:
-             if (len - i < IP6SOPT_UI_MINLEN) {
-		printf(", ui: trunc");
-		goto trunc;
-	    }
-            printf(", ui: 0x%04x ", EXTRACT_16BITS(&bp[i + 2]));
-	    break;
-        case IP6SOPT_ALTCOA:
-             if (len - i < IP6SOPT_ALTCOA_MINLEN) {
-		printf(", altcoa: trunc");
-		goto trunc;
-	    }
-            printf(", alt-CoA: %s", ip6addr_string(&bp[i+2]));
-	    break;
-        case IP6SOPT_AUTH:
-             if (len - i < IP6SOPT_AUTH_MINLEN) {
-		printf(", auth: trunc");
-		goto trunc;
-	    }
-            printf(", auth spi: 0x%08x", EXTRACT_32BITS(&bp[i + 2]));
+            ND_PRINT((ndo, ", padn"));
 	    break;
 	default:
 	    if (len - i < IP6OPT_MINLEN) {
-		printf(", sopt_type %d: trunc)", bp[i]);
+		ND_PRINT((ndo, ", sopt_type %d: trunc)", bp[i]));
 		goto trunc;
 	    }
-	    printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
+	    ND_PRINT((ndo, ", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]));
 	    break;
 	}
     }
     return;
 
 trunc:
-    printf("[trunc] ");
+    ND_PRINT((ndo, "[trunc] "));
 }
 
-void
-ip6_opt_print(const u_char *bp, int len)
+static void
+ip6_opt_print(netdissect_options *ndo, const u_char *bp, int len)
 {
     int i;
     int optlen = 0;
@@ -157,176 +107,108 @@
 
 	switch (bp[i]) {
 	case IP6OPT_PAD1:
-            printf("(pad1)");
+            ND_PRINT((ndo, "(pad1)"));
 	    break;
 	case IP6OPT_PADN:
 	    if (len - i < IP6OPT_MINLEN) {
-		printf("(padn: trunc)");
+		ND_PRINT((ndo, "(padn: trunc)"));
 		goto trunc;
 	    }
-            printf("(padn)");
+            ND_PRINT((ndo, "(padn)"));
 	    break;
 	case IP6OPT_ROUTER_ALERT:
 	    if (len - i < IP6OPT_RTALERT_LEN) {
-		printf("(rtalert: trunc)");
+		ND_PRINT((ndo, "(rtalert: trunc)"));
 		goto trunc;
 	    }
 	    if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
-		printf("(rtalert: invalid len %d)", bp[i + 1]);
+		ND_PRINT((ndo, "(rtalert: invalid len %d)", bp[i + 1]));
 		goto trunc;
 	    }
-	    printf("(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2]));
+	    ND_PRINT((ndo, "(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2])));
 	    break;
 	case IP6OPT_JUMBO:
 	    if (len - i < IP6OPT_JUMBO_LEN) {
-		printf("(jumbo: trunc)");
+		ND_PRINT((ndo, "(jumbo: trunc)"));
 		goto trunc;
 	    }
 	    if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
-		printf("(jumbo: invalid len %d)", bp[i + 1]);
+		ND_PRINT((ndo, "(jumbo: invalid len %d)", bp[i + 1]));
 		goto trunc;
 	    }
-	    printf("(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2]));
+	    ND_PRINT((ndo, "(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2])));
 	    break;
         case IP6OPT_HOME_ADDRESS:
 	    if (len - i < IP6OPT_HOMEADDR_MINLEN) {
-		printf("(homeaddr: trunc)");
+		ND_PRINT((ndo, "(homeaddr: trunc)"));
 		goto trunc;
 	    }
 	    if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
-		printf("(homeaddr: invalid len %d)", bp[i + 1]);
+		ND_PRINT((ndo, "(homeaddr: invalid len %d)", bp[i + 1]));
 		goto trunc;
 	    }
-	    printf("(homeaddr: %s", ip6addr_string(&bp[i + 2]));
+	    ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(ndo, &bp[i + 2])));
             if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
-		ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN],
+		ip6_sopt_print(ndo, &bp[i + IP6OPT_HOMEADDR_MINLEN],
 		    (optlen - IP6OPT_HOMEADDR_MINLEN));
 	    }
-            printf(")");
-	    break;
-        case IP6OPT_BINDING_UPDATE:
-	    if (len - i < IP6OPT_BU_MINLEN) {
-		printf("(bu: trunc)");
-		goto trunc;
-	    }
-	    if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) {
-		printf("(bu: invalid len %d)", bp[i + 1]);
-		goto trunc;
-	    }
-	    printf("(bu: ");
-	    if (bp[i + 2] & 0x80)
-		    printf("A");
-	    if (bp[i + 2] & 0x40)
-		    printf("H");
-	    if (bp[i + 2] & 0x20)
-		    printf("S");
-	    if (bp[i + 2] & 0x10)
-		    printf("D");
-	    if ((bp[i + 2] & 0x0f) || bp[i + 3] || bp[i + 4])
-		    printf("res");
-	    printf(", sequence: %u", bp[i + 5]);
-	    printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 6]));
-
-	    if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) {
-		ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN],
-		    (optlen - IP6OPT_BU_MINLEN));
-	    }
-	    printf(")");
-	    break;
-	case IP6OPT_BINDING_ACK:
-	    if (len - i < IP6OPT_BA_MINLEN) {
-		printf("(ba: trunc)");
-		goto trunc;
-	    }
-	    if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) {
-		printf("(ba: invalid len %d)", bp[i + 1]);
-		goto trunc;
-	    }
-	    printf("(ba: ");
-	    printf("status: %u", bp[i + 2]);
-	    if (bp[i + 3])
-		    printf("res");
-	    printf(", sequence: %u", bp[i + 4]);
-	    printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 5]));
-	    printf(", refresh: %u", EXTRACT_32BITS(&bp[i + 9]));
-
-	    if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
-		ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
-		    (optlen - IP6OPT_BA_MINLEN));
-	    }
-            printf(")");
-	    break;
-        case IP6OPT_BINDING_REQ:
-	    if (len - i < IP6OPT_BR_MINLEN) {
-		printf("(br: trunc)");
-		goto trunc;
-	    }
-            printf("(br");
-            if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
-		ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
-		    (optlen - IP6OPT_BR_MINLEN));
-	    }
-            printf(")");
+            ND_PRINT((ndo, ")"));
 	    break;
 	default:
 	    if (len - i < IP6OPT_MINLEN) {
-		printf("(type %d: trunc)", bp[i]);
+		ND_PRINT((ndo, "(type %d: trunc)", bp[i]));
 		goto trunc;
 	    }
-	    printf("(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]);
+	    ND_PRINT((ndo, "(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]));
 	    break;
 	}
     }
-    printf(" ");
-
-#if 0
-end:
-#endif
+    ND_PRINT((ndo, " "));
     return;
 
 trunc:
-    printf("[trunc] ");
+    ND_PRINT((ndo, "[trunc] "));
 }
 
 int
-hbhopt_print(register const u_char *bp)
+hbhopt_print(netdissect_options *ndo, register const u_char *bp)
 {
     const struct ip6_hbh *dp = (struct ip6_hbh *)bp;
     int hbhlen = 0;
 
-    TCHECK(dp->ip6h_len);
+    ND_TCHECK(dp->ip6h_len);
     hbhlen = (int)((dp->ip6h_len + 1) << 3);
-    TCHECK2(*dp, hbhlen);
-    printf("HBH ");
-    if (vflag)
-	ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
+    ND_TCHECK2(*dp, hbhlen);
+    ND_PRINT((ndo, "HBH "));
+    if (ndo->ndo_vflag)
+	ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
 
     return(hbhlen);
 
   trunc:
-    fputs("[|HBH]", stdout);
+    ND_PRINT((ndo, "[|HBH]"));
     return(-1);
 }
 
 int
-dstopt_print(register const u_char *bp)
+dstopt_print(netdissect_options *ndo, register const u_char *bp)
 {
     const struct ip6_dest *dp = (struct ip6_dest *)bp;
     int dstoptlen = 0;
 
-    TCHECK(dp->ip6d_len);
+    ND_TCHECK(dp->ip6d_len);
     dstoptlen = (int)((dp->ip6d_len + 1) << 3);
-    TCHECK2(*dp, dstoptlen);
-    printf("DSTOPT ");
-    if (vflag) {
-	ip6_opt_print((const u_char *)dp + sizeof(*dp),
+    ND_TCHECK2(*dp, dstoptlen);
+    ND_PRINT((ndo, "DSTOPT "));
+    if (ndo->ndo_vflag) {
+	ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp),
 	    dstoptlen - sizeof(*dp));
     }
 
     return(dstoptlen);
 
   trunc:
-    fputs("[|DSTOPT]", stdout);
+    ND_PRINT((ndo, "[|DSTOPT]"));
     return(-1);
 }
 #endif /* INET6 */
diff --git a/print-ipcomp.c b/print-ipcomp.c
index 89130a3..1ba687e 100644
--- a/print-ipcomp.c
+++ b/print-ipcomp.c
@@ -19,24 +19,17 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <string.h>
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 struct ipcomp {
-	u_int8_t comp_nxt;	/* Next Header */
-	u_int8_t comp_flags;	/* Length of data, in 32bit */
-	u_int16_t comp_cpi;	/* Compression parameter index */
+	uint8_t comp_nxt;	/* Next Header */
+	uint8_t comp_flags;	/* Length of data, in 32bit */
+	uint16_t comp_cpi;	/* Compression parameter index */
 };
 
 #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
@@ -44,15 +37,14 @@
 #endif
 
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
 
 int
-ipcomp_print(register const u_char *bp, int *nhdr _U_)
+ipcomp_print(netdissect_options *ndo, register const u_char *bp, int *nhdr _U_)
 {
 	register const struct ipcomp *ipcomp;
 	register const u_char *ep;
-	u_int16_t cpi;
+	uint16_t cpi;
 #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
 	int advance;
 #endif
@@ -61,13 +53,13 @@
 	cpi = EXTRACT_16BITS(&ipcomp->comp_cpi);
 
 	/* 'ep' points to the end of available data. */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 
 	if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
-		fputs("[|IPCOMP]", stdout);
+		ND_PRINT((ndo, "[|IPCOMP]"));
 		goto fail;
 	}
-	printf("IPComp(cpi=0x%04x)", cpi);
+	ND_PRINT((ndo, "IPComp(cpi=0x%04x)", cpi));
 
 #if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
 	if (1)
@@ -82,7 +74,7 @@
 		*nhdr = ipcomp->comp_nxt;
 	advance = sizeof(struct ipcomp);
 
-	printf(": ");
+	ND_PRINT((ndo, ": "));
 	return advance;
 
 #endif
diff --git a/print-ipfc.c b/print-ipfc.c
index c980765..295ac0f 100644
--- a/print-ipfc.c
+++ b/print-ipfc.c
@@ -19,32 +19,31 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "ethertype.h"
 
 #include "ether.h"
-#include "ipfc.h"
 
 /*
  * RFC 2625 IP-over-Fibre Channel.
  */
 
+struct ipfc_header {
+	u_char  ipfc_dhost[8];
+	u_char  ipfc_shost[8];
+};
+
+#define IPFC_HDRLEN 16
+
 /* Extract src, dst addresses */
 static inline void
 extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
@@ -62,30 +61,31 @@
  * Print the Network_Header
  */
 static inline void
-ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_,
+ipfc_hdr_print(netdissect_options *ndo,
+	   register const struct ipfc_header *ipfcp _U_,
 	   register u_int length, register const u_char *ipfcsrc,
 	   register const u_char *ipfcdst)
 {
 	const char *srcname, *dstname;
 
-	srcname = etheraddr_string(ipfcsrc);
-	dstname = etheraddr_string(ipfcdst);
+	srcname = etheraddr_string(ndo, ipfcsrc);
+	dstname = etheraddr_string(ndo, ipfcdst);
 
 	/*
 	 * XXX - show the upper 16 bits?  Do so only if "vflag" is set?
 	 */
-	(void) printf("%s %s %d: ", srcname, dstname, length);
+	ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
 }
 
 static void
-ipfc_print(const u_char *p, u_int length, u_int caplen)
+ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
 	const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
 	struct ether_header ehdr;
 	u_short extracted_ethertype;
 
 	if (caplen < IPFC_HDRLEN) {
-		printf("[|ipfc]");
+		ND_PRINT((ndo, "[|ipfc]"));
 		return;
 	}
 	/*
@@ -93,8 +93,8 @@
 	 */
 	extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
 
-	if (eflag)
-		ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
+	if (ndo->ndo_eflag)
+		ipfc_hdr_print(ndo, ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
 
 	/* Skip over Network_Header */
 	length -= IPFC_HDRLEN;
@@ -102,21 +102,21 @@
 	caplen -= IPFC_HDRLEN;
 
 	/* Try to print the LLC-layer header & higher layers */
-	if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+	if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
 	    &extracted_ethertype) == 0) {
 		/*
 		 * Some kinds of LLC packet we cannot
 		 * handle intelligently
 		 */
-		if (!eflag)
-			ipfc_hdr_print(ipfcp, length + IPFC_HDRLEN,
+		if (!ndo->ndo_eflag)
+			ipfc_hdr_print(ndo, ipfcp, length + IPFC_HDRLEN,
 			    ESRC(&ehdr), EDST(&ehdr));
 		if (extracted_ethertype) {
-			printf("(LLC %s) ",
-		etherproto_string(htons(extracted_ethertype)));
+			ND_PRINT((ndo, "(LLC %s) ",
+		etherproto_string(htons(extracted_ethertype))));
 		}
-		if (!suppress_default_print)
-			default_print(p, caplen);
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
 	}
 }
 
@@ -127,9 +127,9 @@
  * is the number of bytes actually captured.
  */
 u_int
-ipfc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
-	ipfc_print(p, h->len, h->caplen);
+	ipfc_print(ndo, p, h->len, h->caplen);
 
 	return (IPFC_HDRLEN);
 }
diff --git a/print-ipnet.c b/print-ipnet.c
index e8ed94d..c4ff16a 100644
--- a/print-ipnet.c
+++ b/print-ipnet.c
@@ -1,16 +1,25 @@
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
-#include "netdissect.h"
 #include "interface.h"
-#include "addrtoname.h"
-#include "ipnet.h"
+
+typedef struct ipnet_hdr {
+	uint8_t		iph_version;
+	uint8_t		iph_family;
+	uint16_t	iph_htype;
+	uint32_t	iph_pktlen;
+	uint32_t	iph_ifindex;
+	uint32_t	iph_grifindex;
+	uint32_t	iph_zsrc;
+	uint32_t	iph_zdst;
+} ipnet_hdr_t;
+
+#define	IPH_AF_INET	2		/* Matches Solaris's AF_INET */
+#define	IPH_AF_INET6	26		/* Matches Solaris's AF_INET6 */
 
 #ifdef DLT_IPNET
 
@@ -21,7 +30,7 @@
 };
 
 static inline void
-ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
+ipnet_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
 	const ipnet_hdr_t *hdr;
 	hdr = (const ipnet_hdr_t *)bp;
@@ -44,7 +53,7 @@
 }
 
 static void
-ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
+ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
 	ipnet_hdr_t *hdr;
 
@@ -67,11 +76,9 @@
 	        ip_print(ndo, p, length);
 		break;
 
-#ifdef INET6
 	case IPH_AF_INET6:
 		ip6_print(ndo, p, length);
 		break;
-#endif /*INET6*/
 
 	default:
 		if (!ndo->ndo_eflag)
@@ -79,7 +86,7 @@
 					length + sizeof(ipnet_hdr_t));
 
 		if (!ndo->ndo_suppress_default_print)
-			ndo->ndo_default_print(ndo, p, caplen);
+			ND_DEFAULTPRINT(p, caplen);
 		break;
 	}
 }
@@ -91,7 +98,7 @@
  * is the number of bytes actually captured.
  */
 u_int
-ipnet_if_print(struct netdissect_options *ndo,
+ipnet_if_print(netdissect_options *ndo,
                const struct pcap_pkthdr *h, const u_char *p)
 {
 	ipnet_print(ndo, p, h->len, h->caplen);
diff --git a/print-ipx.c b/print-ipx.c
index c9bde23..93f5d59 100644
--- a/print-ipx.c
+++ b/print-ipx.c
@@ -22,64 +22,81 @@
  * Contributed by Brad Parker (brad@fcr.com).
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.42 2005-05-06 08:26:44 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "ipx.h"
 #include "extract.h"
 
+/* well-known sockets */
+#define	IPX_SKT_NCP		0x0451
+#define	IPX_SKT_SAP		0x0452
+#define	IPX_SKT_RIP		0x0453
+#define	IPX_SKT_NETBIOS		0x0455
+#define	IPX_SKT_DIAGNOSTICS	0x0456
+#define	IPX_SKT_NWLINK_DGM	0x0553	/* NWLink datagram, may contain SMB */
+#define	IPX_SKT_EIGRP		0x85be	/* Cisco EIGRP over IPX */
 
-static const char *ipxaddr_string(u_int32_t, const u_char *);
-void ipx_decode(const struct ipxHdr *, const u_char *, u_int);
-void ipx_sap_print(const u_short *, u_int);
-void ipx_rip_print(const u_short *, u_int);
+/* IPX transport header */
+struct ipxHdr {
+    uint16_t	cksum;		/* Checksum */
+    uint16_t	length;		/* Length, in bytes, including header */
+    uint8_t	tCtl;		/* Transport Control (i.e. hop count) */
+    uint8_t	pType;		/* Packet Type (i.e. level 2 protocol) */
+    uint16_t	dstNet[2];	/* destination net */
+    uint8_t	dstNode[6];	/* destination node */
+    uint16_t	dstSkt;		/* destination socket */
+    uint16_t	srcNet[2];	/* source net */
+    uint8_t	srcNode[6];	/* source node */
+    uint16_t	srcSkt;		/* source socket */
+};
+
+#define ipxSize	30
+
+static const char *ipxaddr_string(uint32_t, const u_char *);
+static void ipx_decode(netdissect_options *, const struct ipxHdr *, const u_char *, u_int);
+static void ipx_sap_print(netdissect_options *, const u_short *, u_int);
+static void ipx_rip_print(netdissect_options *, const u_short *, u_int);
 
 /*
  * Print IPX datagram packets.
  */
 void
-ipx_print(const u_char *p, u_int length)
+ipx_print(netdissect_options *ndo, const u_char *p, u_int length)
 {
 	const struct ipxHdr *ipx = (const struct ipxHdr *)p;
 
-	if (!eflag)
-		printf("IPX ");
+	if (!ndo->ndo_eflag)
+		ND_PRINT((ndo, "IPX "));
 
-	TCHECK(ipx->srcSkt);
-	(void)printf("%s.%04x > ",
+	ND_TCHECK(ipx->srcSkt);
+	ND_PRINT((ndo, "%s.%04x > ",
 		     ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
-		     EXTRACT_16BITS(&ipx->srcSkt));
+		     EXTRACT_16BITS(&ipx->srcSkt)));
 
-	(void)printf("%s.%04x: ",
+	ND_PRINT((ndo, "%s.%04x: ",
 		     ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
-		     EXTRACT_16BITS(&ipx->dstSkt));
+		     EXTRACT_16BITS(&ipx->dstSkt)));
 
 	/* take length from ipx header */
-	TCHECK(ipx->length);
+	ND_TCHECK(ipx->length);
 	length = EXTRACT_16BITS(&ipx->length);
 
-	ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
+	ipx_decode(ndo, ipx, (u_char *)ipx + ipxSize, length - ipxSize);
 	return;
 trunc:
-	printf("[|ipx %d]", length);
+	ND_PRINT((ndo, "[|ipx %d]", length));
 }
 
 static const char *
-ipxaddr_string(u_int32_t net, const u_char *node)
+ipxaddr_string(uint32_t net, const u_char *node)
 {
     static char line[256];
 
@@ -89,52 +106,52 @@
     return line;
 }
 
-void
-ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
+static void
+ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *datap, u_int length)
 {
     register u_short dstSkt;
 
     dstSkt = EXTRACT_16BITS(&ipx->dstSkt);
     switch (dstSkt) {
       case IPX_SKT_NCP:
-	(void)printf("ipx-ncp %d", length);
+	ND_PRINT((ndo, "ipx-ncp %d", length));
 	break;
       case IPX_SKT_SAP:
-	ipx_sap_print((u_short *)datap, length);
+	ipx_sap_print(ndo, (u_short *)datap, length);
 	break;
       case IPX_SKT_RIP:
-	ipx_rip_print((u_short *)datap, length);
+	ipx_rip_print(ndo, (u_short *)datap, length);
 	break;
       case IPX_SKT_NETBIOS:
-	(void)printf("ipx-netbios %d", length);
+	ND_PRINT((ndo, "ipx-netbios %d", length));
 #ifdef TCPDUMP_DO_SMB
-	ipx_netbios_print(datap, length);
+	ipx_netbios_print(ndo, datap, length);
 #endif
 	break;
       case IPX_SKT_DIAGNOSTICS:
-	(void)printf("ipx-diags %d", length);
+	ND_PRINT((ndo, "ipx-diags %d", length));
 	break;
       case IPX_SKT_NWLINK_DGM:
-	(void)printf("ipx-nwlink-dgm %d", length);
+	ND_PRINT((ndo, "ipx-nwlink-dgm %d", length));
 #ifdef TCPDUMP_DO_SMB
-	ipx_netbios_print(datap, length);
+	ipx_netbios_print(ndo, datap, length);
 #endif
 	break;
       case IPX_SKT_EIGRP:
-	eigrp_print(datap, length);
+	eigrp_print(ndo, datap, length);
 	break;
       default:
-	(void)printf("ipx-#%x %d", dstSkt, length);
+	ND_PRINT((ndo, "ipx-#%x %d", dstSkt, length));
 	break;
     }
 }
 
-void
-ipx_sap_print(const u_short *ipx, u_int length)
+static void
+ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
 {
     int command, i;
 
-    TCHECK(ipx[0]);
+    ND_TCHECK(ipx[0]);
     command = EXTRACT_16BITS(ipx);
     ipx++;
     length -= 2;
@@ -143,79 +160,79 @@
       case 1:
       case 3:
 	if (command == 1)
-	    (void)printf("ipx-sap-req");
+	    ND_PRINT((ndo, "ipx-sap-req"));
 	else
-	    (void)printf("ipx-sap-nearest-req");
+	    ND_PRINT((ndo, "ipx-sap-nearest-req"));
 
-	TCHECK(ipx[0]);
-	(void)printf(" %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
+	ND_TCHECK(ipx[0]);
+	ND_PRINT((ndo, " %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
 	break;
 
       case 2:
       case 4:
 	if (command == 2)
-	    (void)printf("ipx-sap-resp");
+	    ND_PRINT((ndo, "ipx-sap-resp"));
 	else
-	    (void)printf("ipx-sap-nearest-resp");
+	    ND_PRINT((ndo, "ipx-sap-nearest-resp"));
 
 	for (i = 0; i < 8 && length > 0; i++) {
-	    TCHECK(ipx[0]);
-	    (void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
-	    if (fn_printzp((u_char *)&ipx[1], 48, snapend)) {
-		printf("'");
+	    ND_TCHECK(ipx[0]);
+	    ND_PRINT((ndo, " %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
+	    if (fn_printzp(ndo, (u_char *)&ipx[1], 48, ndo->ndo_snapend)) {
+		ND_PRINT((ndo, "'"));
 		goto trunc;
 	    }
-	    TCHECK2(ipx[25], 10);
-	    printf("' addr %s",
-		ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27]));
+	    ND_TCHECK2(ipx[25], 10);
+	    ND_PRINT((ndo, "' addr %s",
+		ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])));
 	    ipx += 32;
 	    length -= 64;
 	}
 	break;
       default:
-	(void)printf("ipx-sap-?%x", command);
+	ND_PRINT((ndo, "ipx-sap-?%x", command));
 	break;
     }
     return;
 trunc:
-    printf("[|ipx %d]", length);
+    ND_PRINT((ndo, "[|ipx %d]", length));
 }
 
-void
-ipx_rip_print(const u_short *ipx, u_int length)
+static void
+ipx_rip_print(netdissect_options *ndo, const u_short *ipx, u_int length)
 {
     int command, i;
 
-    TCHECK(ipx[0]);
+    ND_TCHECK(ipx[0]);
     command = EXTRACT_16BITS(ipx);
     ipx++;
     length -= 2;
 
     switch (command) {
       case 1:
-	(void)printf("ipx-rip-req");
+	ND_PRINT((ndo, "ipx-rip-req"));
 	if (length > 0) {
-	    TCHECK(ipx[3]);
-	    (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
-			 EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+	    ND_TCHECK(ipx[3]);
+	    ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+			 EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
 	}
 	break;
       case 2:
-	(void)printf("ipx-rip-resp");
+	ND_PRINT((ndo, "ipx-rip-resp"));
 	for (i = 0; i < 50 && length > 0; i++) {
-	    TCHECK(ipx[3]);
-	    (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
-			 EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+	    ND_TCHECK(ipx[3]);
+	    ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+			 EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
 
 	    ipx += 4;
 	    length -= 8;
 	}
 	break;
       default:
-	(void)printf("ipx-rip-?%x", command);
+	ND_PRINT((ndo, "ipx-rip-?%x", command));
 	break;
     }
     return;
 trunc:
-    printf("[|ipx %d]", length);
+    ND_PRINT((ndo, "[|ipx %d]", length));
 }
diff --git a/print-isakmp.c b/print-isakmp.c
index 2b352e5..bef0b45 100644
--- a/print-isakmp.c
+++ b/print-isakmp.c
@@ -28,11 +28,6 @@
  *
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp $ (LBL)";
-#endif
-
 #define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -49,11 +44,6 @@
 
 #include <string.h>
 
-#include <stdio.h>
-
-#include "isakmp.h"
-#include "ipsec_doi.h"
-#include "oakley.h"
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"                    /* must come after interface.h */
@@ -63,18 +53,537 @@
 #include "ip6.h"
 #endif
 
-#ifndef HAVE_SOCKADDR_STORAGE
-#define sockaddr_storage sockaddr
+/* refer to RFC 2408 */
+
+typedef u_char cookie_t[8];
+typedef u_char msgid_t[4];
+
+#define PORT_ISAKMP 500
+
+/* 3.1 ISAKMP Header Format (IKEv1 and IKEv2)
+         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        !                          Initiator                            !
+        !                            Cookie                             !
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        !                          Responder                            !
+        !                            Cookie                             !
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        !  Next Payload ! MjVer ! MnVer ! Exchange Type !     Flags     !
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        !                          Message ID                           !
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        !                            Length                             !
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp {
+	cookie_t i_ck;		/* Initiator Cookie */
+	cookie_t r_ck;		/* Responder Cookie */
+	uint8_t np;		/* Next Payload Type */
+	uint8_t vers;
+#define ISAKMP_VERS_MAJOR	0xf0
+#define ISAKMP_VERS_MAJOR_SHIFT	4
+#define ISAKMP_VERS_MINOR	0x0f
+#define ISAKMP_VERS_MINOR_SHIFT	0
+	uint8_t etype;		/* Exchange Type */
+	uint8_t flags;		/* Flags */
+	msgid_t msgid;
+	uint32_t len;		/* Length */
+};
+
+/* Next Payload Type */
+#define ISAKMP_NPTYPE_NONE   0 /* NONE*/
+#define ISAKMP_NPTYPE_SA     1 /* Security Association */
+#define ISAKMP_NPTYPE_P      2 /* Proposal */
+#define ISAKMP_NPTYPE_T      3 /* Transform */
+#define ISAKMP_NPTYPE_KE     4 /* Key Exchange */
+#define ISAKMP_NPTYPE_ID     5 /* Identification */
+#define ISAKMP_NPTYPE_CERT   6 /* Certificate */
+#define ISAKMP_NPTYPE_CR     7 /* Certificate Request */
+#define ISAKMP_NPTYPE_HASH   8 /* Hash */
+#define ISAKMP_NPTYPE_SIG    9 /* Signature */
+#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
+#define ISAKMP_NPTYPE_N     11 /* Notification */
+#define ISAKMP_NPTYPE_D     12 /* Delete */
+#define ISAKMP_NPTYPE_VID   13 /* Vendor ID */
+#define ISAKMP_NPTYPE_v2E   46 /* v2 Encrypted payload */
+
+#define IKEv1_MAJOR_VERSION  1
+#define IKEv1_MINOR_VERSION  0
+
+#define IKEv2_MAJOR_VERSION  2
+#define IKEv2_MINOR_VERSION  0
+
+/* Flags */
+#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
+#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
+#define ISAKMP_FLAG_extra 0x04
+
+/* IKEv2 */
+#define ISAKMP_FLAG_I (1 << 3)  /* (I)nitiator */
+#define ISAKMP_FLAG_V (1 << 4)  /* (V)ersion   */
+#define ISAKMP_FLAG_R (1 << 5)  /* (R)esponse  */
+
+
+/* 3.2 Payload Generic Header
+         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        ! Next Payload  !   RESERVED    !         Payload Length        !
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_gen {
+	uint8_t  np;       /* Next Payload */
+	uint8_t  critical; /* bit 7 - critical, rest is RESERVED */
+	uint16_t len;      /* Payload Length */
+};
+
+/* 3.3 Data Attributes
+         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        !A!       Attribute Type        !    AF=0  Attribute Length     !
+        !F!                             !    AF=1  Attribute Value      !
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+        .                   AF=0  Attribute Value                       .
+        .                   AF=1  Not Transmitted                       .
+        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_data {
+	uint16_t type;     /* defined by DOI-spec, and Attribute Format */
+	uint16_t lorv;     /* if f equal 1, Attribute Length */
+	                  /* if f equal 0, Attribute Value */
+	/* if f equal 1, Attribute Value */
+};
+
+/* 3.4 Security Association Payload */
+	/* MAY NOT be used, because of being defined in ipsec-doi. */
+	/*
+	If the current payload is the last in the message,
+	then the value of the next payload field will be 0.
+	This field MUST NOT contain the
+	values for the Proposal or Transform payloads as they are considered
+	part of the security association negotiation.  For example, this
+	field would contain the value "10" (Nonce payload) in the first
+	message of a Base Exchange (see Section 4.4) and the value "0" in the
+	first message of an Identity Protect Exchange (see Section 4.5).
+	*/
+struct ikev1_pl_sa {
+	struct isakmp_gen h;
+	uint32_t doi; /* Domain of Interpretation */
+	uint32_t sit; /* Situation */
+};
+
+/* 3.5 Proposal Payload */
+	/*
+	The value of the next payload field MUST only contain the value "2"
+	or "0".  If there are additional Proposal payloads in the message,
+	then this field will be 2.  If the current Proposal payload is the
+	last within the security association proposal, then this field will
+	be 0.
+	*/
+struct ikev1_pl_p {
+	struct isakmp_gen h;
+	uint8_t p_no;      /* Proposal # */
+	uint8_t prot_id;   /* Protocol */
+	uint8_t spi_size;  /* SPI Size */
+	uint8_t num_t;     /* Number of Transforms */
+	/* SPI */
+};
+
+/* 3.6 Transform Payload */
+	/*
+	The value of the next payload field MUST only contain the value "3"
+	or "0".  If there are additional Transform payloads in the proposal,
+	then this field will be 3.  If the current Transform payload is the
+	last within the proposal, then this field will be 0.
+	*/
+struct ikev1_pl_t {
+	struct isakmp_gen h;
+	uint8_t  t_no;     /* Transform # */
+	uint8_t  t_id;     /* Transform-Id */
+	uint16_t reserved; /* RESERVED2 */
+	/* SA Attributes */
+};
+
+/* 3.7 Key Exchange Payload */
+struct ikev1_pl_ke {
+	struct isakmp_gen h;
+	/* Key Exchange Data */
+};
+
+/* 3.8 Identification Payload */
+	/* MUST NOT to be used, because of being defined in ipsec-doi. */
+struct ikev1_pl_id {
+	struct isakmp_gen h;
+	union {
+		uint8_t  id_type;   /* ID Type */
+		uint32_t doi_data;  /* DOI Specific ID Data */
+	} d;
+	/* Identification Data */
+};
+
+/* 3.9 Certificate Payload */
+struct ikev1_pl_cert {
+	struct isakmp_gen h;
+	uint8_t encode; /* Cert Encoding */
+	char   cert;   /* Certificate Data */
+		/*
+		This field indicates the type of
+		certificate or certificate-related information contained in the
+		Certificate Data field.
+		*/
+};
+
+/* 3.10 Certificate Request Payload */
+struct ikev1_pl_cr {
+	struct isakmp_gen h;
+	uint8_t num_cert; /* # Cert. Types */
+	/*
+	Certificate Types (variable length)
+	  -- Contains a list of the types of certificates requested,
+	  sorted in order of preference.  Each individual certificate
+	  type is 1 octet.  This field is NOT requiredo
+	*/
+	/* # Certificate Authorities (1 octet) */
+	/* Certificate Authorities (variable length) */
+};
+
+/* 3.11 Hash Payload */
+	/* may not be used, because of having only data. */
+struct ikev1_pl_hash {
+	struct isakmp_gen h;
+	/* Hash Data */
+};
+
+/* 3.12 Signature Payload */
+	/* may not be used, because of having only data. */
+struct ikev1_pl_sig {
+	struct isakmp_gen h;
+	/* Signature Data */
+};
+
+/* 3.13 Nonce Payload */
+	/* may not be used, because of having only data. */
+struct ikev1_pl_nonce {
+	struct isakmp_gen h;
+	/* Nonce Data */
+};
+
+/* 3.14 Notification Payload */
+struct ikev1_pl_n {
+	struct isakmp_gen h;
+	uint32_t doi;      /* Domain of Interpretation */
+	uint8_t  prot_id;  /* Protocol-ID */
+	uint8_t  spi_size; /* SPI Size */
+	uint16_t type;     /* Notify Message Type */
+	/* SPI */
+	/* Notification Data */
+};
+
+/* 3.14.1 Notify Message Types */
+/* NOTIFY MESSAGES - ERROR TYPES */
+#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE           1
+#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED              2
+#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED        3
+#define ISAKMP_NTYPE_INVALID_COOKIE                 4
+#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION          5
+#define ISAKMP_NTYPE_INVALID_MINOR_VERSION          6
+#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE          7
+#define ISAKMP_NTYPE_INVALID_FLAGS                  8
+#define ISAKMP_NTYPE_INVALID_MESSAGE_ID             9
+#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID            10
+#define ISAKMP_NTYPE_INVALID_SPI                    11
+#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID           12
+#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED       13
+#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN             14
+#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX            15
+#define ISAKMP_NTYPE_PAYLOAD_MALFORMED              16
+#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION        17
+#define ISAKMP_NTYPE_INVALID_ID_INFORMATION         18
+#define ISAKMP_NTYPE_INVALID_CERT_ENCODING          19
+#define ISAKMP_NTYPE_INVALID_CERTIFICATE            20
+#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX        21
+#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY         22
+#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION       23
+#define ISAKMP_NTYPE_AUTHENTICATION_FAILED          24
+#define ISAKMP_NTYPE_INVALID_SIGNATURE              25
+#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION           26
+
+/* 3.15 Delete Payload */
+struct ikev1_pl_d {
+	struct isakmp_gen h;
+	uint32_t doi;      /* Domain of Interpretation */
+	uint8_t  prot_id;  /* Protocol-Id */
+	uint8_t  spi_size; /* SPI Size */
+	uint16_t num_spi;  /* # of SPIs */
+	/* SPI(es) */
+};
+
+struct ikev1_ph1tab {
+	struct ikev1_ph1 *head;
+	struct ikev1_ph1 *tail;
+	int len;
+};
+
+struct isakmp_ph2tab {
+	struct ikev1_ph2 *head;
+	struct ikev1_ph2 *tail;
+	int len;
+};
+
+/* IKEv2 (RFC4306) */
+
+/* 3.3  Security Association Payload -- generic header */
+/* 3.3.1.  Proposal Substructure */
+struct ikev2_p {
+	struct isakmp_gen h;
+	uint8_t p_no;      /* Proposal # */
+	uint8_t prot_id;   /* Protocol */
+	uint8_t spi_size;  /* SPI Size */
+	uint8_t num_t;     /* Number of Transforms */
+};
+
+/* 3.3.2.  Transform Substructure */
+struct ikev2_t {
+	struct isakmp_gen h;
+	uint8_t t_type;    /* Transform Type (ENCR,PRF,INTEG,etc.*/
+	uint8_t res2;      /* reserved byte */
+	uint16_t t_id;     /* Transform ID */
+};
+
+enum ikev2_t_type {
+	IV2_T_ENCR = 1,
+	IV2_T_PRF  = 2,
+	IV2_T_INTEG= 3,
+	IV2_T_DH   = 4,
+	IV2_T_ESN  = 5,
+};
+
+/* 3.4.  Key Exchange Payload */
+struct ikev2_ke {
+	struct isakmp_gen h;
+	uint16_t  ke_group;
+	uint16_t  ke_res1;
+	/* KE data */
+};
+
+
+/* 3.5.  Identification Payloads */
+enum ikev2_id_type {
+	ID_IPV4_ADDR=1,
+	ID_FQDN=2,
+	ID_RFC822_ADDR=3,
+	ID_IPV6_ADDR=5,
+	ID_DER_ASN1_DN=9,
+	ID_DER_ASN1_GN=10,
+	ID_KEY_ID=11,
+};
+struct ikev2_id {
+	struct isakmp_gen h;
+	uint8_t  type;        /* ID type */
+	uint8_t  res1;
+	uint16_t res2;
+	/* SPI */
+	/* Notification Data */
+};
+
+/* 3.10 Notification Payload */
+struct ikev2_n {
+	struct isakmp_gen h;
+	uint8_t  prot_id;  /* Protocol-ID */
+	uint8_t  spi_size; /* SPI Size */
+	uint16_t type;     /* Notify Message Type */
+};
+
+enum ikev2_n_type {
+	IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD            = 1,
+	IV2_NOTIFY_INVALID_IKE_SPI                         = 4,
+	IV2_NOTIFY_INVALID_MAJOR_VERSION                   = 5,
+	IV2_NOTIFY_INVALID_SYNTAX                          = 7,
+	IV2_NOTIFY_INVALID_MESSAGE_ID                      = 9,
+	IV2_NOTIFY_INVALID_SPI                             =11,
+	IV2_NOTIFY_NO_PROPOSAL_CHOSEN                      =14,
+	IV2_NOTIFY_INVALID_KE_PAYLOAD                      =17,
+	IV2_NOTIFY_AUTHENTICATION_FAILED                   =24,
+	IV2_NOTIFY_SINGLE_PAIR_REQUIRED                    =34,
+	IV2_NOTIFY_NO_ADDITIONAL_SAS                       =35,
+	IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE                =36,
+	IV2_NOTIFY_FAILED_CP_REQUIRED                      =37,
+	IV2_NOTIFY_INVALID_SELECTORS                       =39,
+	IV2_NOTIFY_INITIAL_CONTACT                         =16384,
+	IV2_NOTIFY_SET_WINDOW_SIZE                         =16385,
+	IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE                  =16386,
+	IV2_NOTIFY_IPCOMP_SUPPORTED                        =16387,
+	IV2_NOTIFY_NAT_DETECTION_SOURCE_IP                 =16388,
+	IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP            =16389,
+	IV2_NOTIFY_COOKIE                                  =16390,
+	IV2_NOTIFY_USE_TRANSPORT_MODE                      =16391,
+	IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED              =16392,
+	IV2_NOTIFY_REKEY_SA                                =16393,
+	IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED           =16394,
+	IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO                =16395
+};
+
+struct notify_messages {
+	uint16_t type;
+	char     *msg;
+};
+
+/* 3.8 Notification Payload */
+struct ikev2_auth {
+	struct isakmp_gen h;
+	uint8_t  auth_method;  /* Protocol-ID */
+	uint8_t  reserved[3];
+	/* authentication data */
+};
+
+enum ikev2_auth_type {
+	IV2_RSA_SIG = 1,
+	IV2_SHARED  = 2,
+	IV2_DSS_SIG = 3,
+};
+
+/* refer to RFC 2409 */
+
+#if 0
+/* isakmp sa structure */
+struct oakley_sa {
+	uint8_t  proto_id;            /* OAKLEY */
+	vchar_t   *spi;                /* spi */
+	uint8_t  dhgrp;               /* DH; group */
+	uint8_t  auth_t;              /* method of authentication */
+	uint8_t  prf_t;               /* type of prf */
+	uint8_t  hash_t;              /* type of hash */
+	uint8_t  enc_t;               /* type of cipher */
+	uint8_t  life_t;              /* type of duration of lifetime */
+	uint32_t ldur;                /* life duration */
+};
 #endif
 
+/* refer to RFC 2407 */
+
+#define IPSEC_DOI 1
+
+/* 4.2 IPSEC Situation Definition */
+#define IPSECDOI_SIT_IDENTITY_ONLY           0x00000001
+#define IPSECDOI_SIT_SECRECY                 0x00000002
+#define IPSECDOI_SIT_INTEGRITY               0x00000004
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+  /* 4.4.2 IPSEC ISAKMP Transform Values */
+#define IPSECDOI_PROTO_ISAKMP                        1
+#define   IPSECDOI_KEY_IKE                             1
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_AH                      2
+  /* 4.4.3 IPSEC AH Transform Values */
+#define   IPSECDOI_AH_MD5                              2
+#define   IPSECDOI_AH_SHA                              3
+#define   IPSECDOI_AH_DES                              4
+#define   IPSECDOI_AH_SHA2_256                         5
+#define   IPSECDOI_AH_SHA2_384                         6
+#define   IPSECDOI_AH_SHA2_512                         7
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_ESP                     3
+  /* 4.4.4 IPSEC ESP Transform Identifiers */
+#define   IPSECDOI_ESP_DES_IV64                        1
+#define   IPSECDOI_ESP_DES                             2
+#define   IPSECDOI_ESP_3DES                            3
+#define   IPSECDOI_ESP_RC5                             4
+#define   IPSECDOI_ESP_IDEA                            5
+#define   IPSECDOI_ESP_CAST                            6
+#define   IPSECDOI_ESP_BLOWFISH                        7
+#define   IPSECDOI_ESP_3IDEA                           8
+#define   IPSECDOI_ESP_DES_IV32                        9
+#define   IPSECDOI_ESP_RC4                            10
+#define   IPSECDOI_ESP_NULL                           11
+#define   IPSECDOI_ESP_RIJNDAEL				12
+#define   IPSECDOI_ESP_AES				12
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPCOMP                        4
+  /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
+#define   IPSECDOI_IPCOMP_OUI                          1
+#define   IPSECDOI_IPCOMP_DEFLATE                      2
+#define   IPSECDOI_IPCOMP_LZS                          3
+
+/* 4.5 IPSEC Security Association Attributes */
+#define IPSECDOI_ATTR_SA_LTYPE                1 /* B */
+#define   IPSECDOI_ATTR_SA_LTYPE_DEFAULT        1
+#define   IPSECDOI_ATTR_SA_LTYPE_SEC            1
+#define   IPSECDOI_ATTR_SA_LTYPE_KB             2
+#define IPSECDOI_ATTR_SA_LDUR                 2 /* V */
+#define   IPSECDOI_ATTR_SA_LDUR_DEFAULT         28800 /* 8 hours */
+#define IPSECDOI_ATTR_GRP_DESC                3 /* B */
+#define IPSECDOI_ATTR_ENC_MODE                4 /* B */
+	/* default value: host dependent */
+#define   IPSECDOI_ATTR_ENC_MODE_TUNNEL         1
+#define   IPSECDOI_ATTR_ENC_MODE_TRNS           2
+#define IPSECDOI_ATTR_AUTH                    5 /* B */
+	/* 0 means not to use authentication. */
+#define   IPSECDOI_ATTR_AUTH_HMAC_MD5           1
+#define   IPSECDOI_ATTR_AUTH_HMAC_SHA1          2
+#define   IPSECDOI_ATTR_AUTH_DES_MAC            3
+#define   IPSECDOI_ATTR_AUTH_KPDK               4 /*RFC-1826(Key/Pad/Data/Key)*/
+	/*
+	 * When negotiating ESP without authentication, the Auth
+	 * Algorithm attribute MUST NOT be included in the proposal.
+	 * When negotiating ESP without confidentiality, the Auth
+	 * Algorithm attribute MUST be included in the proposal and
+	 * the ESP transform ID must be ESP_NULL.
+	*/
+#define IPSECDOI_ATTR_KEY_LENGTH              6 /* B */
+#define IPSECDOI_ATTR_KEY_ROUNDS              7 /* B */
+#define IPSECDOI_ATTR_COMP_DICT_SIZE          8 /* B */
+#define IPSECDOI_ATTR_COMP_PRIVALG            9 /* V */
+
+/* 4.6.1 Security Association Payload */
+struct ipsecdoi_sa {
+	struct isakmp_gen h;
+	uint32_t doi; /* Domain of Interpretation */
+	uint32_t sit; /* Situation */
+};
+
+struct ipsecdoi_secrecy_h {
+	uint16_t len;
+	uint16_t reserved;
+};
+
+/* 4.6.2.1 Identification Type Values */
+struct ipsecdoi_id {
+	struct isakmp_gen h;
+	uint8_t  type;		/* ID Type */
+	uint8_t  proto_id;	/* Protocol ID */
+	uint16_t port;		/* Port */
+	/* Identification Data */
+};
+
+#define IPSECDOI_ID_IPV4_ADDR                        1
+#define IPSECDOI_ID_FQDN                             2
+#define IPSECDOI_ID_USER_FQDN                        3
+#define IPSECDOI_ID_IPV4_ADDR_SUBNET                 4
+#define IPSECDOI_ID_IPV6_ADDR                        5
+#define IPSECDOI_ID_IPV6_ADDR_SUBNET                 6
+#define IPSECDOI_ID_IPV4_ADDR_RANGE                  7
+#define IPSECDOI_ID_IPV6_ADDR_RANGE                  8
+#define IPSECDOI_ID_DER_ASN1_DN                      9
+#define IPSECDOI_ID_DER_ASN1_GN                      10
+#define IPSECDOI_ID_KEY_ID                           11
+
+/* 4.6.3 IPSEC DOI Notify Message Types */
+/* Notify Messages - Status Types */
+#define IPSECDOI_NTYPE_RESPONDER_LIFETIME                  24576
+#define IPSECDOI_NTYPE_REPLAY_STATUS                       24577
+#define IPSECDOI_NTYPE_INITIAL_CONTACT                     24578
+
 #define DECLARE_PRINTER(func) static const u_char *ike##func##_print( \
 		netdissect_options *ndo, u_char tpay,	              \
 		const struct isakmp_gen *ext,			      \
 		u_int item_len, \
 		const u_char *end_pointer, \
-		u_int32_t phase,\
-		u_int32_t doi0, \
-		u_int32_t proto0, int depth)
+		uint32_t phase,\
+		uint32_t doi0, \
+		uint32_t proto0, int depth)
 
 DECLARE_PRINTER(v1_sa);
 DECLARE_PRINTER(v1_p);
@@ -108,23 +617,23 @@
 				   struct isakmp *base,
 				   u_char tpay,
 				   const struct isakmp_gen *ext,
-				   u_int item_len,	
-				   const u_char *end_pointer, 
-				   u_int32_t phase,
-				   u_int32_t doi0, 
-				   u_int32_t proto0, int depth);
+				   u_int item_len,
+				   const u_char *end_pointer,
+				   uint32_t phase,
+				   uint32_t doi0,
+				   uint32_t proto0, int depth);
 
 
 static const u_char *ike_sub0_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
-	const u_char *,	u_int32_t, u_int32_t, u_int32_t, int);
+	const u_char *,	uint32_t, uint32_t, uint32_t, int);
 static const u_char *ikev1_sub_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
-	const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
+	const u_char *, uint32_t, uint32_t, uint32_t, int);
 
 static const u_char *ikev2_sub_print(netdissect_options *ndo,
 				     struct isakmp *base,
 				     u_char np, const struct isakmp_gen *ext,
-				     const u_char *ep, u_int32_t phase,
-				     u_int32_t doi, u_int32_t proto,
+				     const u_char *ep, uint32_t phase,
+				     uint32_t doi, uint32_t proto,
 				     int depth);
 
 
@@ -137,10 +646,17 @@
 
 #define MAXINITIATORS	20
 int ninitiator = 0;
+union inaddr_u {
+	struct in_addr in4;
+#ifdef INET6
+	struct in6_addr in6;
+#endif
+};
 struct {
 	cookie_t initiator;
-	struct sockaddr_storage iaddr;
-	struct sockaddr_storage raddr;
+	u_int version;
+	union inaddr_u iaddr;
+	union inaddr_u raddr;
 } cookiecache[MAXINITIATORS];
 
 /* protocol id */
@@ -160,17 +676,17 @@
 	"v2cr",  "v2auth","v2nonce", "v2n",   "v2d",   /* 38- 42 */
 	"v2vid", "v2TSi", "v2TSr", "v2e",   "v2cp",  /* 43- 47 */
 	"v2eap",                                     /* 48 */
-	
+
 };
 
 /* isakmp->np */
-static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay, 
+static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay,
 				 const struct isakmp_gen *ext,
 				 u_int item_len,
 				 const u_char *end_pointer,
-				 u_int32_t phase,
-				 u_int32_t doi0,
-				 u_int32_t proto0, int depth) = {
+				 uint32_t phase,
+				 uint32_t doi0,
+				 uint32_t proto0, int depth) = {
 	NULL,
 	ikev1_sa_print,
 	ikev1_p_print,
@@ -230,7 +746,7 @@
 			ND_PRINT((ndo," [|%s]", NPSTR(np)));		\
 			goto done;					\
 		}
-		
+
 
 #define NPFUNC(x) \
 	(((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \
@@ -266,10 +782,8 @@
 {
 	int i;
 	struct ip *ip;
-	struct sockaddr_in *sin;
 #ifdef INET6
 	struct ip6_hdr *ip6;
-	struct sockaddr_in6 *sin6;
 #endif
 
 	i = cookie_find(in);
@@ -281,44 +795,16 @@
 	ip = (struct ip *)bp2;
 	switch (IP_V(ip)) {
 	case 4:
-		memset(&cookiecache[ninitiator].iaddr, 0,
-			sizeof(cookiecache[ninitiator].iaddr));
-		memset(&cookiecache[ninitiator].raddr, 0,
-			sizeof(cookiecache[ninitiator].raddr));
-
-		sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		sin->sin_len = sizeof(struct sockaddr_in);
-#endif
-		sin->sin_family = AF_INET;
-		UNALIGNED_MEMCPY(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
-		sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		sin->sin_len = sizeof(struct sockaddr_in);
-#endif
-		sin->sin_family = AF_INET;
-		UNALIGNED_MEMCPY(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst));
+		cookiecache[ninitiator].version = 4;
+		UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in4, &ip->ip_src, sizeof(struct in_addr));
+		UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in4, &ip->ip_dst, sizeof(struct in_addr));
 		break;
 #ifdef INET6
 	case 6:
-		memset(&cookiecache[ninitiator].iaddr, 0,
-			sizeof(cookiecache[ninitiator].iaddr));
-		memset(&cookiecache[ninitiator].raddr, 0,
-			sizeof(cookiecache[ninitiator].raddr));
-
 		ip6 = (struct ip6_hdr *)bp2;
-		sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
-		sin6->sin6_family = AF_INET6;
-		UNALIGNED_MEMCPY(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
-		sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
-		sin6->sin6_family = AF_INET6;
-		UNALIGNED_MEMCPY(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
+		cookiecache[ninitiator].version = 6;
+		UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in6, &ip6->ip6_src, sizeof(struct in6_addr));
+		UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr));
 		break;
 #endif
 	default:
@@ -333,78 +819,42 @@
 static int
 cookie_sidecheck(int i, const u_char *bp2, int initiator)
 {
-	struct sockaddr_storage ss;
-	struct sockaddr *sa;
 	struct ip *ip;
-	struct sockaddr_in *sin;
 #ifdef INET6
 	struct ip6_hdr *ip6;
-	struct sockaddr_in6 *sin6;
 #endif
-	int salen;
 
-	memset(&ss, 0, sizeof(ss));
 	ip = (struct ip *)bp2;
 	switch (IP_V(ip)) {
 	case 4:
-		sin = (struct sockaddr_in *)&ss;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		sin->sin_len = sizeof(struct sockaddr_in);
-#endif
-		sin->sin_family = AF_INET;
-		UNALIGNED_MEMCPY(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
+		if (cookiecache[i].version != 4)
+			return 0;
+		if (initiator) {
+			if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].iaddr.in4, sizeof(struct in_addr)) == 0)
+				return 1;
+		} else {
+			if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].raddr.in4, sizeof(struct in_addr)) == 0)
+				return 1;
+		}
 		break;
 #ifdef INET6
 	case 6:
+		if (cookiecache[i].version != 6)
+			return 0;
 		ip6 = (struct ip6_hdr *)bp2;
-		sin6 = (struct sockaddr_in6 *)&ss;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
-		sin6->sin6_family = AF_INET6;
-		UNALIGNED_MEMCPY(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
+		if (initiator) {
+			if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].iaddr.in6, sizeof(struct in6_addr)) == 0)
+				return 1;
+		} else {
+			if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].raddr.in6, sizeof(struct in6_addr)) == 0)
+				return 1;
+		}
 		break;
-#endif
+#endif /* INET6 */
 	default:
-		return 0;
+		break;
 	}
 
-	sa = (struct sockaddr *)&ss;
-	if (initiator) {
-		if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].iaddr)->sa_family)
-			return 0;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		salen = sa->sa_len;
-#else
-#ifdef INET6
-		if (sa->sa_family == AF_INET6)
-			salen = sizeof(struct sockaddr_in6);
-		else
-			salen = sizeof(struct sockaddr);
-#else
-		salen = sizeof(struct sockaddr);
-#endif
-#endif
-		if (memcmp(&ss, &cookiecache[i].iaddr, salen) == 0)
-			return 1;
-	} else {
-		if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].raddr)->sa_family)
-			return 0;
-#ifdef HAVE_SOCKADDR_SA_LEN
-		salen = sa->sa_len;
-#else
-#ifdef INET6
-		if (sa->sa_family == AF_INET6)
-			salen = sizeof(struct sockaddr_in6);
-		else
-			salen = sizeof(struct sockaddr);
-#else
-		salen = sizeof(struct sockaddr);
-#endif
-#endif
-		if (memcmp(&ss, &cookiecache[i].raddr, salen) == 0)
-			return 1;
-	}
 	return 0;
 }
 
@@ -434,7 +884,7 @@
 /*
  * returns false if we run out of data buffer
  */
-static int ike_show_somedata(struct netdissect_options *ndo,
+static int ike_show_somedata(netdissect_options *ndo,
 			     const u_char *cp, const u_char *ep)
 {
 	/* there is too much data, just show some of it */
@@ -444,13 +894,13 @@
 	if(len > 10) {
 		len = 10;
 	}
-	
+
 	/* really shouldn't happen because of above */
 	if(end < cp + len) {
 		end = cp+len;
 		elen = ep - end;
 	}
-	
+
 	ND_PRINT((ndo," data=("));
 	if(!rawprint(ndo, (caddr_t)(cp), len)) goto trunc;
 	ND_PRINT((ndo, "..."));
@@ -476,7 +926,7 @@
 		    const struct attrmap *map, size_t nmap)
 {
 	int totlen;
-	u_int32_t t, v;
+	uint32_t t, v;
 
 	if (p[0] & 0x80)
 		totlen = 4;
@@ -512,7 +962,7 @@
 ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep)
 {
 	int totlen;
-	u_int32_t t;
+	uint32_t t;
 
 	if (p[0] & 0x80)
 		totlen = 4;
@@ -542,12 +992,12 @@
 ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
 	       const struct isakmp_gen *ext,
 		u_int item_len _U_,
-		const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
-		u_int32_t proto0, int depth)
+		const u_char *ep, uint32_t phase, uint32_t doi0 _U_,
+		uint32_t proto0, int depth)
 {
 	const struct ikev1_pl_sa *p;
 	struct ikev1_pl_sa sa;
-	u_int32_t doi, sit, ident;
+	uint32_t doi, sit, ident;
 	const u_char *cp, *np;
 	int t;
 
@@ -560,7 +1010,7 @@
 	sit = ntohl(sa.sit);
 	if (doi != 1) {
 		ND_PRINT((ndo," doi=%d", doi));
-		ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit)));
+		ND_PRINT((ndo," situation=%u", (uint32_t)ntohl(sa.sit)));
 		return (u_char *)(p + 1);
 	}
 
@@ -582,7 +1032,7 @@
 	if (sit != 0x01) {
 		ND_TCHECK2(*(ext + 1), sizeof(ident));
 		UNALIGNED_MEMCPY(&ident, ext + 1, sizeof(ident));
-		ND_PRINT((ndo," ident=%u", (u_int32_t)ntohl(ident)));
+		ND_PRINT((ndo," ident=%u", (uint32_t)ntohl(ident)));
 		np += sizeof(ident);
 	}
 
@@ -601,8 +1051,8 @@
 static const u_char *
 ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
 	      const struct isakmp_gen *ext, u_int item_len _U_,
-	       const u_char *ep, u_int32_t phase, u_int32_t doi0,
-	       u_int32_t proto0 _U_, int depth)
+	       const u_char *ep, uint32_t phase, uint32_t doi0,
+	       uint32_t proto0 _U_, int depth)
 {
 	const struct ikev1_pl_p *p;
 	struct ikev1_pl_p prop;
@@ -623,10 +1073,10 @@
 
 	ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
 	ND_TCHECK(*ext);
-	
+
 	cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
 			     prop.prot_id, depth);
-	
+
 	return cp;
 trunc:
 	ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
@@ -686,7 +1136,7 @@
 	NULL, "oui", "deflate", "lzs",
 };
 
-const struct attrmap ipsec_t_map[] = {
+static const struct attrmap ipsec_t_map[] = {
 	{ NULL,	0, { NULL } },
 	{ "lifetype", 3, { NULL, "sec", "kb", }, },
 	{ "life", 0, { NULL } },
@@ -713,7 +1163,7 @@
 	{ "privalg", 0, { NULL } },
 };
 
-const struct attrmap encr_t_map[] = {
+static const struct attrmap encr_t_map[] = {
 	{ NULL,	0, { NULL } }, 	{ NULL,	0, { NULL } },  /* 0, 1 */
 	{ NULL,	0, { NULL } },	{ NULL,	0, { NULL } },  /* 2, 3 */
 	{ NULL,	0, { NULL } },	{ NULL,	0, { NULL } },  /* 4, 5 */
@@ -724,7 +1174,7 @@
 	{ "keylen", 14, { NULL }},
 };
 
-const struct attrmap oakley_t_map[] = {
+static const struct attrmap oakley_t_map[] = {
 	{ NULL,	0, { NULL } },
 	{ "enc", 8,	{ NULL, "1des", "idea", "blowfish", "rc5",
 		 	  "3des", "cast", "aes", }, },
@@ -764,8 +1214,8 @@
 static const u_char *
 ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
 	      const struct isakmp_gen *ext, u_int item_len,
-	      const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_,
-	      u_int32_t proto, int depth _U_)
+	      const u_char *ep, uint32_t phase _U_, uint32_t doi _U_,
+	      uint32_t proto, int depth _U_)
 {
 	const struct ikev1_pl_t *p;
 	struct ikev1_pl_t t;
@@ -833,8 +1283,8 @@
 static const u_char *
 ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_,
 	       const struct isakmp_gen *ext, u_int item_len _U_,
-	       const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
-	       u_int32_t proto _U_, int depth _U_)
+	       const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+	       uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 
@@ -856,9 +1306,9 @@
 
 static const u_char *
 ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
-	       const struct isakmp_gen *ext, u_int item_len _U_,
-	       const u_char *ep _U_, u_int32_t phase, u_int32_t doi _U_,
-	       u_int32_t proto _U_, int depth _U_)
+	       const struct isakmp_gen *ext, u_int item_len,
+	       const u_char *ep _U_, uint32_t phase, uint32_t doi _U_,
+	       uint32_t proto _U_, int depth _U_)
 {
 #define USE_IPSECDOI_IN_PHASE1	1
 	const struct ikev1_pl_id *p;
@@ -897,7 +1347,7 @@
 	default:
 		ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.d.id_type, idtypestr)));
 		ND_PRINT((ndo," doi_data=%u",
-			  (u_int32_t)(ntohl(id.d.doi_data) & 0xffffff)));
+			  (uint32_t)(ntohl(id.d.doi_data) & 0xffffff)));
 		break;
 
 #ifdef USE_IPSECDOI_IN_PHASE1
@@ -913,20 +1363,12 @@
 		ND_TCHECK(*p);
 		UNALIGNED_MEMCPY(&id, ext, sizeof(id));
 		ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)));
-		if (id.proto_id) {
-#ifndef WIN32
-			setprotoent(1);
-#endif /* WIN32 */
-			pe = getprotobynumber(id.proto_id);
-			if (pe)
-				ND_PRINT((ndo," protoid=%s", pe->p_name));
-#ifndef WIN32
-			endprotoent();
-#endif /* WIN32 */
-		} else {
-			/* it DOES NOT mean IPPROTO_IP! */
-			ND_PRINT((ndo," protoid=%s", "0"));
-		}
+		/* A protocol ID of 0 DOES NOT mean IPPROTO_IP! */
+		pe = id.proto_id ? getprotobynumber(id.proto_id) : NULL;
+		if (pe)
+			ND_PRINT((ndo," protoid=%s", pe->p_name));
+		else
+			ND_PRINT((ndo," protoid=%u", id.proto_id));
 		ND_PRINT((ndo," port=%d", ntohs(id.port)));
 		if (!len)
 			break;
@@ -938,7 +1380,7 @@
 			if (len < 4)
 				ND_PRINT((ndo," len=%d [bad: < 4]", len));
 			else
-				ND_PRINT((ndo," len=%d %s", len, ipaddr_string(data)));
+				ND_PRINT((ndo," len=%d %s", len, ipaddr_string(ndo, data)));
 			len = 0;
 			break;
 		case IPSECDOI_ID_FQDN:
@@ -947,7 +1389,7 @@
 			int i;
 			ND_PRINT((ndo," len=%d ", len));
 			for (i = 0; i < len; i++)
-				safeputchar(data[i]);
+				safeputchar(ndo, data[i]);
 			len = 0;
 			break;
 		    }
@@ -959,7 +1401,7 @@
 			else {
 				mask = data + sizeof(struct in_addr);
 				ND_PRINT((ndo," len=%d %s/%u.%u.%u.%u", len,
-					  ipaddr_string(data),
+					  ipaddr_string(ndo, data),
 					  mask[0], mask[1], mask[2], mask[3]));
 			}
 			len = 0;
@@ -970,7 +1412,7 @@
 			if (len < 16)
 				ND_PRINT((ndo," len=%d [bad: < 16]", len));
 			else
-				ND_PRINT((ndo," len=%d %s", len, ip6addr_string(data)));
+				ND_PRINT((ndo," len=%d %s", len, ip6addr_string(ndo, data)));
 			len = 0;
 			break;
 		case IPSECDOI_ID_IPV6_ADDR_SUBNET:
@@ -982,7 +1424,7 @@
 				mask = (u_char *)(data + sizeof(struct in6_addr));
 				/*XXX*/
 				ND_PRINT((ndo," len=%d %s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", len,
-					  ip6addr_string(data),
+					  ip6addr_string(ndo, data),
 					  mask[0], mask[1], mask[2], mask[3],
 					  mask[4], mask[5], mask[6], mask[7],
 					  mask[8], mask[9], mask[10], mask[11],
@@ -997,8 +1439,8 @@
 				ND_PRINT((ndo," len=%d [bad: < 8]", len));
 			else {
 				ND_PRINT((ndo," len=%d %s-%s", len,
-					  ipaddr_string(data),
-					  ipaddr_string(data + sizeof(struct in_addr))));
+					  ipaddr_string(ndo, data),
+					  ipaddr_string(ndo, data + sizeof(struct in_addr))));
 			}
 			len = 0;
 			break;
@@ -1008,8 +1450,8 @@
 				ND_PRINT((ndo," len=%d [bad: < 32]", len));
 			else {
 				ND_PRINT((ndo," len=%d %s-%s", len,
-					  ip6addr_string(data),
-					  ip6addr_string(data + sizeof(struct in6_addr))));
+					  ip6addr_string(ndo, data),
+					  ip6addr_string(ndo, data + sizeof(struct in6_addr))));
 			}
 			len = 0;
 			break;
@@ -1039,9 +1481,9 @@
 static const u_char *
 ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
 		 const struct isakmp_gen *ext, u_int item_len _U_,
-		 const u_char *ep _U_, u_int32_t phase _U_,
-		 u_int32_t doi0 _U_,
-		 u_int32_t proto0 _U_, int depth _U_)
+		 const u_char *ep _U_, uint32_t phase _U_,
+		 uint32_t doi0 _U_,
+		 uint32_t proto0 _U_, int depth _U_)
 {
 	const struct ikev1_pl_cert *p;
 	struct ikev1_pl_cert cert;
@@ -1072,8 +1514,8 @@
 static const u_char *
 ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_,
 	       const struct isakmp_gen *ext, u_int item_len _U_,
-	       const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
-	       u_int32_t proto0 _U_, int depth _U_)
+	       const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_,
+	       uint32_t proto0 _U_, int depth _U_)
 {
 	const struct ikev1_pl_cert *p;
 	struct ikev1_pl_cert cert;
@@ -1104,8 +1546,8 @@
 static const u_char *
 ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_,
 		 const struct isakmp_gen *ext, u_int item_len _U_,
-		 const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
-		 u_int32_t proto _U_, int depth _U_)
+		 const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+		 uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 
@@ -1128,8 +1570,8 @@
 static const u_char *
 ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_,
 		const struct isakmp_gen *ext, u_int item_len _U_,
-		const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 
@@ -1154,8 +1596,8 @@
 		  const struct isakmp_gen *ext,
 		  u_int item_len _U_,
 		  const u_char *ep _U_,
-		  u_int32_t phase _U_, u_int32_t doi _U_,
-		  u_int32_t proto _U_, int depth _U_)
+		  uint32_t phase _U_, uint32_t doi _U_,
+		  uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 
@@ -1182,14 +1624,14 @@
 static const u_char *
 ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
 	      const struct isakmp_gen *ext, u_int item_len,
-	      const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
-	      u_int32_t proto0 _U_, int depth)
+	      const u_char *ep, uint32_t phase, uint32_t doi0 _U_,
+	      uint32_t proto0 _U_, int depth)
 {
 	struct ikev1_pl_n *p, n;
 	const u_char *cp;
 	u_char *ep2;
-	u_int32_t doi;
-	u_int32_t proto;
+	uint32_t doi;
+	uint32_t proto;
 	static const char *notify_error_str[] = {
 		NULL,				"INVALID-PAYLOAD-TYPE",
 		"DOI-NOT-SUPPORTED",		"SITUATION-NOT-SUPPORTED",
@@ -1323,14 +1765,14 @@
 static const u_char *
 ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
 	      const struct isakmp_gen *ext, u_int item_len _U_,
-	      const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
-	      u_int32_t proto0 _U_, int depth _U_)
+	      const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_,
+	      uint32_t proto0 _U_, int depth _U_)
 {
 	const struct ikev1_pl_d *p;
 	struct ikev1_pl_d d;
-	const u_int8_t *q;
-	u_int32_t doi;
-	u_int32_t proto;
+	const uint8_t *q;
+	uint32_t doi;
+	uint32_t proto;
 	int i;
 
 	ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D)));
@@ -1350,7 +1792,7 @@
 	ND_PRINT((ndo," spilen=%u", d.spi_size));
 	ND_PRINT((ndo," nspi=%u", ntohs(d.num_spi)));
 	ND_PRINT((ndo," spi="));
-	q = (u_int8_t *)(p + 1);
+	q = (uint8_t *)(p + 1);
 	for (i = 0; i < ntohs(d.num_spi); i++) {
 		if (i != 0)
 			ND_PRINT((ndo,","));
@@ -1368,8 +1810,8 @@
 ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 
@@ -1426,12 +1868,12 @@
 static const u_char *
 ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount,
 	      const struct isakmp_gen *ext, u_int item_len,
-	      const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_,
-	      u_int32_t proto _U_, int depth _U_)
+	      const u_char *ep, uint32_t phase _U_, uint32_t doi _U_,
+	      uint32_t proto _U_, int depth _U_)
 {
 	const struct ikev2_t *p;
 	struct ikev2_t t;
-	u_int16_t  t_id;
+	uint16_t  t_id;
 	const u_char *cp;
 	const char *idstr;
 	const struct attrmap *map;
@@ -1444,7 +1886,7 @@
 	ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_T), t.h.critical);
 
 	t_id = ntohs(t.t_id);
-	
+
 	map = NULL;
 	nmap = 0;
 
@@ -1504,8 +1946,8 @@
 static const u_char *
 ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
 	      const struct isakmp_gen *ext, u_int item_len _U_,
-	       const u_char *ep, u_int32_t phase, u_int32_t doi0,
-	       u_int32_t proto0 _U_, int depth)
+	       const u_char *ep, uint32_t phase, uint32_t doi0,
+	       uint32_t proto0 _U_, int depth)
 {
 	const struct ikev2_p *p;
 	struct ikev2_p prop;
@@ -1530,7 +1972,7 @@
 
 	cp = ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
 			     prop.prot_id, depth);
-	
+
 	return cp;
 trunc:
 	ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
@@ -1538,11 +1980,11 @@
 }
 
 static const u_char *
-ikev2_sa_print(netdissect_options *ndo, u_char tpay, 
+ikev2_sa_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext1,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 	int    osa_length, sa_length;
@@ -1566,11 +2008,11 @@
 }
 
 static const u_char *
-ikev2_ke_print(netdissect_options *ndo, u_char tpay, 
+ikev2_ke_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct ikev2_ke ke;
 	struct ikev2_ke *k;
@@ -1582,7 +2024,7 @@
 
 	ND_PRINT((ndo," len=%u group=%s", ntohs(ke.h.len) - 8,
 		  STR_OR_ID(ntohs(ke.ke_group), dh_p_map)));
-		 
+
 	if (2 < ndo->ndo_vflag && 8 < ntohs(ke.h.len)) {
 		ND_PRINT((ndo," "));
 		if (!rawprint(ndo, (caddr_t)(k + 1), ntohs(ke.h.len) - 8))
@@ -1595,11 +2037,11 @@
 }
 
 static const u_char *
-ikev2_ID_print(netdissect_options *ndo, u_char tpay, 
+ikev2_ID_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct ikev2_id id;
 	int id_len, idtype_len, i;
@@ -1677,31 +2119,31 @@
 }
 
 static const u_char *
-ikev2_cert_print(netdissect_options *ndo, u_char tpay, 
+ikev2_cert_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	return ikev2_gen_print(ndo, tpay, ext);
 }
 
 static const u_char *
-ikev2_cr_print(netdissect_options *ndo, u_char tpay, 
+ikev2_cr_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	return ikev2_gen_print(ndo, tpay, ext);
 }
 
 static const u_char *
-ikev2_auth_print(netdissect_options *ndo, u_char tpay, 
+ikev2_auth_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct ikev2_auth a;
 	const char *v2_auth[]={ "invalid", "rsasig",
@@ -1714,7 +2156,7 @@
 	ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical);
 	len = ntohs(a.h.len);
 
-	ND_PRINT((ndo," len=%d method=%s", len-4, 
+	ND_PRINT((ndo," len=%d method=%s", len-4,
 		  STR_OR_ID(a.auth_method, v2_auth)));
 
 	if (1 < ndo->ndo_vflag && 4 < len) {
@@ -1733,11 +2175,11 @@
 }
 
 static const u_char *
-ikev2_nonce_print(netdissect_options *ndo, u_char tpay, 
+ikev2_nonce_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 
@@ -1763,17 +2205,17 @@
 
 /* notify payloads */
 static const u_char *
-ikev2_n_print(netdissect_options *ndo, u_char tpay _U_, 
+ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct ikev2_n *p, n;
 	const u_char *cp;
 	u_char showspi, showdata, showsomedata;
 	const char *notify_name;
-	u_int32_t type;
+	uint32_t type;
 
 	p = (struct ikev2_n *)ext;
 	ND_TCHECK(*p);
@@ -1851,7 +2293,7 @@
 		showspi = 0;
 		break;
 
-	case IV2_NOTIFY_FAILED_CP_REQUIRED: 
+	case IV2_NOTIFY_FAILED_CP_REQUIRED:
 		notify_name = "failed:cp_required";
 		showspi = 0;
 		break;
@@ -1866,7 +2308,7 @@
 		showspi = 0;
 		break;
 
-	case IV2_NOTIFY_SET_WINDOW_SIZE:   
+	case IV2_NOTIFY_SET_WINDOW_SIZE:
 		notify_name = "set_window_size";
 		showspi = 0;
 		break;
@@ -1876,7 +2318,7 @@
 		showspi = 0;
 		break;
 
-	case IV2_NOTIFY_IPCOMP_SUPPORTED: 
+	case IV2_NOTIFY_IPCOMP_SUPPORTED:
 		notify_name = "ipcomp_supported";
 		showspi = 0;
 		break;
@@ -1938,7 +2380,7 @@
 	if(notify_name) {
 		ND_PRINT((ndo," type=%u(%s)", type, notify_name));
 	}
-		
+
 
 	if (showspi && n.spi_size) {
 		ND_PRINT((ndo," spi="));
@@ -1962,7 +2404,7 @@
 	} else if(showsomedata && cp < ep) {
 		if(!ike_show_somedata(ndo, cp, ep)) goto trunc;
 	}
-		
+
 	return (u_char *)ext + item_len;
 trunc:
 	ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N)));
@@ -1970,21 +2412,21 @@
 }
 
 static const u_char *
-ikev2_d_print(netdissect_options *ndo, u_char tpay, 
+ikev2_d_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	return ikev2_gen_print(ndo, tpay, ext);
 }
 
 static const u_char *
-ikev2_vid_print(netdissect_options *ndo, u_char tpay, 
+ikev2_vid_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	struct isakmp_gen e;
 	const u_char *vid;
@@ -2014,11 +2456,11 @@
 }
 
 static const u_char *
-ikev2_TS_print(netdissect_options *ndo, u_char tpay, 
+ikev2_TS_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	return ikev2_gen_print(ndo, tpay, ext);
 }
@@ -2029,21 +2471,21 @@
 	      _U_
 #endif
 	      struct isakmp *base,
-	      u_char tpay, 
+	      u_char tpay,
 	      const struct isakmp_gen *ext,
 	      u_int item_len _U_, const u_char *ep _U_,
 #ifndef HAVE_LIBCRYPTO
 	      _U_
 #endif
-	      u_int32_t phase,
+	      uint32_t phase,
 #ifndef HAVE_LIBCRYPTO
 	      _U_
 #endif
-	      u_int32_t doi,
+	      uint32_t doi,
 #ifndef HAVE_LIBCRYPTO
 	      _U_
 #endif
-	      u_int32_t proto,
+	      uint32_t proto,
 #ifndef HAVE_LIBCRYPTO
 	      _U_
 #endif
@@ -2068,14 +2510,14 @@
 
 	dat = (u_char *)(ext+1);
 	ND_TCHECK2(*dat, dlen);
-	
+
 #ifdef HAVE_LIBCRYPTO
 	/* try to decypt it! */
 	if(esp_print_decrypt_buffer_by_ikev2(ndo,
 					     base->flags & ISAKMP_FLAG_I,
 					     base->i_ck, base->r_ck,
 					     dat, dat+dlen)) {
-		
+
 		ext = (const struct isakmp_gen *)ndo->ndo_packetp;
 
 		/* got it decrypted, print stuff inside. */
@@ -2083,7 +2525,7 @@
 				phase, doi, proto, depth+1);
 	}
 #endif
-	
+
 
 	/* always return NULL, because E must be at end, and NP refers
 	 * to what was inside.
@@ -2095,21 +2537,21 @@
 }
 
 static const u_char *
-ikev2_cp_print(netdissect_options *ndo, u_char tpay, 
+ikev2_cp_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	return ikev2_gen_print(ndo, tpay, ext);
 }
 
 static const u_char *
-ikev2_eap_print(netdissect_options *ndo, u_char tpay, 
+ikev2_eap_print(netdissect_options *ndo, u_char tpay,
 		const struct isakmp_gen *ext,
 		u_int item_len _U_, const u_char *ep _U_,
-		u_int32_t phase _U_, u_int32_t doi _U_,
-		u_int32_t proto _U_, int depth _U_)
+		uint32_t phase _U_, uint32_t doi _U_,
+		uint32_t proto _U_, int depth _U_)
 {
 	return ikev2_gen_print(ndo, tpay, ext);
 }
@@ -2118,7 +2560,7 @@
 ike_sub0_print(netdissect_options *ndo,
 		 u_char np, const struct isakmp_gen *ext, const u_char *ep,
 
-	       u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+	       uint32_t phase, uint32_t doi, uint32_t proto, int depth)
 {
 	const u_char *cp;
 	struct isakmp_gen e;
@@ -2158,7 +2600,7 @@
 static const u_char *
 ikev1_sub_print(netdissect_options *ndo,
 		u_char np, const struct isakmp_gen *ext, const u_char *ep,
-		u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+		uint32_t phase, uint32_t doi, uint32_t proto, int depth)
 {
 	const u_char *cp;
 	int i;
@@ -2214,16 +2656,16 @@
 	u_char np;
 	int i;
 	int phase;
-	
+
 	p = (const struct isakmp *)bp;
 	ep = ndo->ndo_snapend;
-	
+
 	phase = (EXTRACT_32BITS(base->msgid) == 0) ? 1 : 2;
 	if (phase == 1)
 		ND_PRINT((ndo," phase %d", phase));
 	else
 		ND_PRINT((ndo," phase %d/others", phase));
-	
+
 	i = cookie_find(&base->i_ck);
 	if (i < 0) {
 		if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) {
@@ -2241,18 +2683,18 @@
 		else
 			ND_PRINT((ndo," ?"));
 	}
-	
+
 	ND_PRINT((ndo," %s", ETYPESTR(base->etype)));
 	if (base->flags) {
 		ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
 			  base->flags & ISAKMP_FLAG_C ? "C" : ""));
 	}
-	
+
 	if (ndo->ndo_vflag) {
 		const struct isakmp_gen *ext;
-		
+
 		ND_PRINT((ndo,":"));
-		
+
 		/* regardless of phase... */
 		if (base->flags & ISAKMP_FLAG_E) {
 			/*
@@ -2262,18 +2704,18 @@
 			ND_PRINT((ndo," [encrypted %s]", NPSTR(base->np)));
 			goto done;
 		}
-		
+
 		CHECKLEN(p + 1, base->np);
 		np = base->np;
 		ext = (struct isakmp_gen *)(p + 1);
 		ikev1_sub_print(ndo, np, ext, ep, phase, 0, 0, 0);
 	}
-	
+
 done:
 	if (ndo->ndo_vflag) {
 		if (ntohl(base->len) != length) {
 			ND_PRINT((ndo," (len mismatch: isakmp %u/ip %u)",
-				  (u_int32_t)ntohl(base->len), length));
+				  (uint32_t)ntohl(base->len), length));
 		}
 	}
 }
@@ -2282,7 +2724,7 @@
 ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
 		 u_char np, int pcount,
 		 const struct isakmp_gen *ext, const u_char *ep,
-		 u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+		 uint32_t phase, uint32_t doi, uint32_t proto, int depth)
 {
 	const u_char *cp;
 	struct isakmp_gen e;
@@ -2333,7 +2775,7 @@
 ikev2_sub_print(netdissect_options *ndo,
 		struct isakmp *base,
 		u_char np, const struct isakmp_gen *ext, const u_char *ep,
-		u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+		uint32_t phase, uint32_t doi, uint32_t proto, int depth)
 {
 	const u_char *cp;
 	int i;
@@ -2341,7 +2783,7 @@
 	struct isakmp_gen e;
 
 	cp = (const u_char *)ext;
-	pcount = 0;						
+	pcount = 0;
 	while (np) {
 		pcount++;
 		ND_TCHECK(*ext);
@@ -2427,7 +2869,7 @@
 	if (ndo->ndo_vflag) {
 		if (ntohl(base->len) != length) {
 			ND_PRINT((ndo, " (len mismatch: isakmp %u/ip %u)",
-				  (u_int32_t)ntohl(base->len), length));
+				  (uint32_t)ntohl(base->len), length));
 		}
 	}
 }
@@ -2508,7 +2950,7 @@
 	if(length < 4) {
 		goto trunc;
 	}
-	
+
 	/*
 	 * see if this is an IKE packet
 	 */
@@ -2532,7 +2974,7 @@
 		bp += advance;
 		length -= advance + padlen;
 		nh = enh & 0xff;
-	     
+
 		ip_print_inner(ndo, bp, length, nh, bp2);
 		return;
 	}
@@ -2550,5 +2992,5 @@
  */
 
 
-  
+
 
diff --git a/print-isoclns.c b/print-isoclns.c
index 97dcc7f..f8de7bc 100644
--- a/print-isoclns.c
+++ b/print-isoclns.c
@@ -24,23 +24,17 @@
  * complete IS-IS & CLNP support.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.165 2008-08-16 13:38:15 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "ethertype.h"
 #include "ether.h"
 #include "nlpid.h"
 #include "extract.h"
@@ -452,10 +446,10 @@
 };
 
 struct isis_spb_mcid {
-  u_int8_t  format_id;    
-  u_int8_t  name[32];  
-  u_int8_t  revision_lvl[2];
-  u_int8_t  digest[16]; 
+  uint8_t  format_id;
+  uint8_t  name[32];
+  uint8_t  revision_lvl[2];
+  uint8_t  digest[16];
 };
 
 struct isis_subtlv_spb_mcid {
@@ -464,11 +458,11 @@
 };
 
 struct isis_subtlv_spb_instance {
-  u_int8_t cist_root_id[8];
-  u_int8_t cist_external_root_path_cost[4];
-  u_int8_t bridge_priority[2];
-  u_int8_t spsourceid[4];
-  u_int8_t no_of_trees;  
+  uint8_t cist_root_id[8];
+  uint8_t cist_external_root_path_cost[4];
+  uint8_t bridge_priority[2];
+  uint8_t spsourceid[4];
+  uint8_t no_of_trees;
 };
 
 #define CLNP_SEGMENT_PART  0x80
@@ -559,39 +553,39 @@
 };
 
 struct isis_tlv_ptp_adj {
-    u_int8_t adjacency_state;
-    u_int8_t extd_local_circuit_id[4];
-    u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
-    u_int8_t neighbor_extd_local_circuit_id[4];
+    uint8_t adjacency_state;
+    uint8_t extd_local_circuit_id[4];
+    uint8_t neighbor_sysid[SYSTEM_ID_LEN];
+    uint8_t neighbor_extd_local_circuit_id[4];
 };
 
-static void osi_print_cksum(const u_int8_t *pptr, u_int16_t checksum,
+static void osi_print_cksum(netdissect_options *, const uint8_t *pptr, uint16_t checksum,
                             u_int checksum_offset, u_int length);
-static int clnp_print(const u_int8_t *, u_int);
-static void esis_print(const u_int8_t *, u_int);
-static int isis_print(const u_int8_t *, u_int);
+static int clnp_print(netdissect_options *, const uint8_t *, u_int);
+static void esis_print(netdissect_options *, const uint8_t *, u_int);
+static int isis_print(netdissect_options *, const uint8_t *, u_int);
 
 struct isis_metric_block {
-    u_int8_t metric_default;
-    u_int8_t metric_delay;
-    u_int8_t metric_expense;
-    u_int8_t metric_error;
+    uint8_t metric_default;
+    uint8_t metric_delay;
+    uint8_t metric_expense;
+    uint8_t metric_error;
 };
 
 struct isis_tlv_is_reach {
     struct isis_metric_block isis_metric_block;
-    u_int8_t neighbor_nodeid[NODE_ID_LEN];
+    uint8_t neighbor_nodeid[NODE_ID_LEN];
 };
 
 struct isis_tlv_es_reach {
     struct isis_metric_block isis_metric_block;
-    u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
+    uint8_t neighbor_sysid[SYSTEM_ID_LEN];
 };
 
 struct isis_tlv_ip_reach {
     struct isis_metric_block isis_metric_block;
-    u_int8_t prefix[4];
-    u_int8_t mask[4];
+    uint8_t prefix[4];
+    uint8_t mask[4];
 };
 
 static const struct tok isis_is_reach_virtual_values[] = {
@@ -608,59 +602,59 @@
 };
 
 struct isis_common_header {
-    u_int8_t nlpid;
-    u_int8_t fixed_len;
-    u_int8_t version;			/* Protocol version */
-    u_int8_t id_length;
-    u_int8_t pdu_type;		        /* 3 MSbits are reserved */
-    u_int8_t pdu_version;		/* Packet format version */
-    u_int8_t reserved;
-    u_int8_t max_area;
+    uint8_t nlpid;
+    uint8_t fixed_len;
+    uint8_t version;			/* Protocol version */
+    uint8_t id_length;
+    uint8_t pdu_type;		        /* 3 MSbits are reserved */
+    uint8_t pdu_version;		/* Packet format version */
+    uint8_t reserved;
+    uint8_t max_area;
 };
 
 struct isis_iih_lan_header {
-    u_int8_t circuit_type;
-    u_int8_t source_id[SYSTEM_ID_LEN];
-    u_int8_t holding_time[2];
-    u_int8_t pdu_len[2];
-    u_int8_t priority;
-    u_int8_t lan_id[NODE_ID_LEN];
+    uint8_t circuit_type;
+    uint8_t source_id[SYSTEM_ID_LEN];
+    uint8_t holding_time[2];
+    uint8_t pdu_len[2];
+    uint8_t priority;
+    uint8_t lan_id[NODE_ID_LEN];
 };
 
 struct isis_iih_ptp_header {
-    u_int8_t circuit_type;
-    u_int8_t source_id[SYSTEM_ID_LEN];
-    u_int8_t holding_time[2];
-    u_int8_t pdu_len[2];
-    u_int8_t circuit_id;
+    uint8_t circuit_type;
+    uint8_t source_id[SYSTEM_ID_LEN];
+    uint8_t holding_time[2];
+    uint8_t pdu_len[2];
+    uint8_t circuit_id;
 };
 
 struct isis_lsp_header {
-    u_int8_t pdu_len[2];
-    u_int8_t remaining_lifetime[2];
-    u_int8_t lsp_id[LSP_ID_LEN];
-    u_int8_t sequence_number[4];
-    u_int8_t checksum[2];
-    u_int8_t typeblock;
+    uint8_t pdu_len[2];
+    uint8_t remaining_lifetime[2];
+    uint8_t lsp_id[LSP_ID_LEN];
+    uint8_t sequence_number[4];
+    uint8_t checksum[2];
+    uint8_t typeblock;
 };
 
 struct isis_csnp_header {
-    u_int8_t pdu_len[2];
-    u_int8_t source_id[NODE_ID_LEN];
-    u_int8_t start_lsp_id[LSP_ID_LEN];
-    u_int8_t end_lsp_id[LSP_ID_LEN];
+    uint8_t pdu_len[2];
+    uint8_t source_id[NODE_ID_LEN];
+    uint8_t start_lsp_id[LSP_ID_LEN];
+    uint8_t end_lsp_id[LSP_ID_LEN];
 };
 
 struct isis_psnp_header {
-    u_int8_t pdu_len[2];
-    u_int8_t source_id[NODE_ID_LEN];
+    uint8_t pdu_len[2];
+    uint8_t source_id[NODE_ID_LEN];
 };
 
 struct isis_tlv_lsp {
-    u_int8_t remaining_lifetime[2];
-    u_int8_t lsp_id[LSP_ID_LEN];
-    u_int8_t sequence_number[4];
-    u_int8_t checksum[2];
+    uint8_t remaining_lifetime[2];
+    uint8_t lsp_id[LSP_ID_LEN];
+    uint8_t sequence_number[4];
+    uint8_t checksum[2];
 };
 
 #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
@@ -670,66 +664,59 @@
 #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
 #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
 
-void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
+void isoclns_print(netdissect_options *ndo,
+                   const uint8_t *p, u_int length, u_int caplen)
 {
-        if (caplen <= 1) { /* enough bytes on the wire ? */
-            printf("|OSI");
-            return;
-        }
+	if (caplen <= 1) { /* enough bytes on the wire ? */
+		ND_PRINT((ndo, "|OSI"));
+		return;
+	}
 
-        if (eflag)
-            printf("OSI NLPID %s (0x%02x): ",
-                   tok2str(nlpid_values,"Unknown",*p),
-                   *p);
-        
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values, "Unknown", *p), *p));
+
 	switch (*p) {
 
 	case NLPID_CLNP:
-		if (!clnp_print(p, length))
-                        print_unknown_data(p,"\n\t",caplen);
+		if (!clnp_print(ndo, p, length))
+			print_unknown_data(ndo, p, "\n\t", caplen);
 		break;
 
 	case NLPID_ESIS:
-		esis_print(p, length);
+		esis_print(ndo, p, length);
 		return;
 
 	case NLPID_ISIS:
-		if (!isis_print(p, length))
-                        print_unknown_data(p,"\n\t",caplen);
+		if (!isis_print(ndo, p, length))
+			print_unknown_data(ndo, p, "\n\t", caplen);
 		break;
 
 	case NLPID_NULLNS:
-		(void)printf("%slength: %u",
-		             eflag ? "" : ", ",
-                             length);
+		ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
 		break;
 
-        case NLPID_Q933:
-                q933_print(p+1, length-1);
-                break;
+	case NLPID_Q933:
+		q933_print(ndo, p + 1, length - 1);
+		break;
 
-        case NLPID_IP:
-		ip_print(gndo, p+1, length-1);
-                break;
+	case NLPID_IP:
+		ip_print(ndo, p + 1, length - 1);
+		break;
 
-#ifdef INET6
-        case NLPID_IP6:
-                ip6_print(gndo, p+1, length-1);
-                break;
-#endif
+	case NLPID_IP6:
+		ip6_print(ndo, p + 1, length - 1);
+		break;
 
-        case NLPID_PPP:
-                ppp_print(p+1, length-1);
-                break;
+	case NLPID_PPP:
+		ppp_print(ndo, p + 1, length - 1);
+		break;
 
 	default:
-                if (!eflag)
-                    printf("OSI NLPID 0x%02x unknown",*p);
-		(void)printf("%slength: %u",
-		             eflag ? "" : ", ",
-                             length);
+		if (!ndo->ndo_eflag)
+			ND_PRINT((ndo, "OSI NLPID 0x%02x unknown", *p));
+		ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
 		if (caplen > 1)
-                        print_unknown_data(p,"\n\t",caplen);
+			print_unknown_data(ndo, p, "\n\t", caplen);
 		break;
 	}
 }
@@ -750,19 +737,19 @@
 };
 
 struct clnp_header_t {
-    u_int8_t nlpid;
-    u_int8_t length_indicator;
-    u_int8_t version;
-    u_int8_t lifetime; /* units of 500ms */
-    u_int8_t type;
-    u_int8_t segment_length[2];
-    u_int8_t cksum[2];
+    uint8_t nlpid;
+    uint8_t length_indicator;
+    uint8_t version;
+    uint8_t lifetime; /* units of 500ms */
+    uint8_t type;
+    uint8_t segment_length[2];
+    uint8_t cksum[2];
 };
 
 struct clnp_segment_header_t {
-    u_int8_t data_unit_id[2];
-    u_int8_t segment_offset[2];
-    u_int8_t total_length[2];
+    uint8_t data_unit_id[2];
+    uint8_t segment_offset[2];
+    uint8_t total_length[2];
 };
 
 /*
@@ -770,29 +757,31 @@
  * Decode CLNP packets.  Return 0 on error.
  */
 
-static int clnp_print (const u_int8_t *pptr, u_int length)
+static int
+clnp_print(netdissect_options *ndo,
+           const uint8_t *pptr, u_int length)
 {
-	const u_int8_t *optr,*source_address,*dest_address;
+	const uint8_t *optr,*source_address,*dest_address;
         u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
 	const struct clnp_header_t *clnp_header;
 	const struct clnp_segment_header_t *clnp_segment_header;
-        u_int8_t rfd_error_major,rfd_error_minor;
+        uint8_t rfd_error_major,rfd_error_minor;
 
 	clnp_header = (const struct clnp_header_t *) pptr;
-        TCHECK(*clnp_header);
+        ND_TCHECK(*clnp_header);
 
         li = clnp_header->length_indicator;
         optr = pptr;
 
-        if (!eflag)
-            printf("CLNP");
+        if (!ndo->ndo_eflag)
+            ND_PRINT((ndo, "CLNP"));
 
         /*
          * Sanity checking of the header.
          */
 
         if (clnp_header->version != CLNP_VERSION) {
-            printf("version %d packet not supported", clnp_header->version);
+            ND_PRINT((ndo, "version %d packet not supported", clnp_header->version));
             return (0);
         }
 
@@ -814,45 +803,45 @@
         pptr += (1 + source_address_length);
         li -= (1 + source_address_length);
 
-        if (vflag < 1) {
-            printf("%s%s > %s, %s, length %u",
-                   eflag ? "" : ", ",
+        if (ndo->ndo_vflag < 1) {
+            ND_PRINT((ndo, "%s%s > %s, %s, length %u",
+                   ndo->ndo_eflag ? "" : ", ",
                    isonsap_string(source_address, source_address_length),
                    isonsap_string(dest_address, dest_address_length),
                    tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
-                   length);
+                   length));
             return (1);
         }
-        printf("%slength %u",eflag ? "" : ", ",length);
+        ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
 
-        printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
+        ND_PRINT((ndo, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
                tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
                clnp_header->length_indicator,
                clnp_header->version,
                clnp_header->lifetime/2,
                (clnp_header->lifetime%2)*5,
                EXTRACT_16BITS(clnp_header->segment_length),
-               EXTRACT_16BITS(clnp_header->cksum));
+               EXTRACT_16BITS(clnp_header->cksum)));
 
-        osi_print_cksum(optr, EXTRACT_16BITS(clnp_header->cksum), 7,
+        osi_print_cksum(ndo, optr, EXTRACT_16BITS(clnp_header->cksum), 7,
                         clnp_header->length_indicator);
 
-        printf("\n\tFlags [%s]",
-               bittok2str(clnp_flag_values,"none",clnp_flags));
+        ND_PRINT((ndo, "\n\tFlags [%s]",
+               bittok2str(clnp_flag_values, "none", clnp_flags)));
 
-        printf("\n\tsource address (length %u): %s\n\tdest   address (length %u): %s",
+        ND_PRINT((ndo, "\n\tsource address (length %u): %s\n\tdest   address (length %u): %s",
                source_address_length,
                isonsap_string(source_address, source_address_length),
                dest_address_length,
-               isonsap_string(dest_address,dest_address_length));
+               isonsap_string(dest_address, dest_address_length)));
 
         if (clnp_flags & CLNP_SEGMENT_PART) {
             	clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
-                TCHECK(*clnp_segment_header);
-                printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
+                ND_TCHECK(*clnp_segment_header);
+                ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
                        EXTRACT_16BITS(clnp_segment_header->data_unit_id),
                        EXTRACT_16BITS(clnp_segment_header->segment_offset),
-                       EXTRACT_16BITS(clnp_segment_header->total_length));
+                       EXTRACT_16BITS(clnp_segment_header->total_length)));
                 pptr+=sizeof(const struct clnp_segment_header_t);
                 li-=sizeof(const struct clnp_segment_header_t);
         }
@@ -860,46 +849,46 @@
         /* now walk the options */
         while (li >= 2) {
             u_int op, opli;
-            const u_int8_t *tptr;
-            
-            TCHECK2(*pptr, 2);
+            const uint8_t *tptr;
+
+            ND_TCHECK2(*pptr, 2);
             if (li < 2) {
-                printf(", bad opts/li");
+                ND_PRINT((ndo, ", bad opts/li"));
                 return (0);
             }
             op = *pptr++;
             opli = *pptr++;
             li -= 2;
-            TCHECK2(*pptr, opli);
+            ND_TCHECK2(*pptr, opli);
             if (opli > li) {
-                printf(", opt (%d) too long", op);
+                ND_PRINT((ndo, ", opt (%d) too long", op));
                 return (0);
             }
             li -= opli;
             tptr = pptr;
             tlen = opli;
-            
-            printf("\n\t  %s Option #%u, length %u, value: ",
+
+            ND_PRINT((ndo, "\n\t  %s Option #%u, length %u, value: ",
                    tok2str(clnp_option_values,"Unknown",op),
                    op,
-                   opli);
+                   opli));
 
             switch (op) {
 
 
             case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
-            case CLNP_OPTION_SOURCE_ROUTING:  
-                    printf("%s %s",
+            case CLNP_OPTION_SOURCE_ROUTING:
+                    ND_PRINT((ndo, "%s %s",
                            tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
-                           tok2str(clnp_option_sr_rr_string_values,"Unknown Option %u",op));
+                           tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
                     nsap_offset=*(tptr+1);
                     if (nsap_offset == 0) {
-                            printf(" Bad NSAP offset (0)");
+                            ND_PRINT((ndo, " Bad NSAP offset (0)"));
                             break;
                     }
                     nsap_offset-=1; /* offset to nsap list */
                     if (nsap_offset > tlen) {
-                            printf(" Bad NSAP offset (past end of option)");
+                            ND_PRINT((ndo, " Bad NSAP offset (past end of option)"));
                             break;
                     }
                     tptr+=nsap_offset;
@@ -907,53 +896,53 @@
                     while (tlen > 0) {
                             source_address_length=*tptr;
                             if (tlen < source_address_length+1) {
-                                    printf("\n\t    NSAP address goes past end of option");
+                                    ND_PRINT((ndo, "\n\t    NSAP address goes past end of option"));
                                     break;
                             }
                             if (source_address_length > 0) {
                                     source_address=(tptr+1);
-                                    TCHECK2(*source_address, source_address_length);
-                                    printf("\n\t    NSAP address (length %u): %s",
+                                    ND_TCHECK2(*source_address, source_address_length);
+                                    ND_PRINT((ndo, "\n\t    NSAP address (length %u): %s",
                                            source_address_length,
-                                           isonsap_string(source_address, source_address_length));
+                                           isonsap_string(source_address, source_address_length)));
                             }
                             tlen-=source_address_length+1;
                     }
                     break;
 
             case CLNP_OPTION_PRIORITY:
-                    printf("0x%1x", *tptr&0x0f);
+                    ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
                     break;
 
             case CLNP_OPTION_QOS_MAINTENANCE:
-                    printf("\n\t    Format Code: %s",
-                           tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK));
+                    ND_PRINT((ndo, "\n\t    Format Code: %s",
+                           tok2str(clnp_option_scope_values, "Reserved", *tptr&CLNP_OPTION_SCOPE_MASK)));
 
                     if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
-                            printf("\n\t    QoS Flags [%s]",
+                            ND_PRINT((ndo, "\n\t    QoS Flags [%s]",
                                    bittok2str(clnp_option_qos_global_values,
                                               "none",
-                                              *tptr&CLNP_OPTION_OPTION_QOS_MASK));
+                                              *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
                     break;
 
             case CLNP_OPTION_SECURITY:
-                    printf("\n\t    Format Code: %s, Security-Level %u",
+                    ND_PRINT((ndo, "\n\t    Format Code: %s, Security-Level %u",
                            tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
-                           *(tptr+1));
+                           *(tptr+1)));
                     break;
 
             case CLNP_OPTION_DISCARD_REASON:
                 rfd_error_major = (*tptr&0xf0) >> 4;
                 rfd_error_minor = *tptr&0x0f;
-                printf("\n\t    Class: %s Error (0x%01x), %s (0x%01x)",
+                ND_PRINT((ndo, "\n\t    Class: %s Error (0x%01x), %s (0x%01x)",
                        tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
                        rfd_error_major,
                        tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
-                       rfd_error_minor);
+                       rfd_error_minor));
                 break;
 
             case CLNP_OPTION_PADDING:
-                    printf("padding data");
+                    ND_PRINT((ndo, "padding data"));
                 break;
 
                 /*
@@ -962,11 +951,11 @@
                  */
 
             default:
-                print_unknown_data(tptr,"\n\t  ",opli);
+                print_unknown_data(ndo, tptr, "\n\t  ", opli);
                 break;
             }
-            if (vflag > 1)
-                print_unknown_data(pptr,"\n\t  ",opli);
+            if (ndo->ndo_vflag > 1)
+                print_unknown_data(ndo, pptr, "\n\t  ", opli);
             pptr += opli;
         }
 
@@ -974,30 +963,30 @@
 
         case    CLNP_PDU_ER: /* fall through */
         case 	CLNP_PDU_ERP:
-            TCHECK(*pptr);
+            ND_TCHECK(*pptr);
             if (*(pptr) == NLPID_CLNP) {
-                printf("\n\t-----original packet-----\n\t");
+                ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
                 /* FIXME recursion protection */
-                clnp_print(pptr, length-clnp_header->length_indicator);
+                clnp_print(ndo, pptr, length - clnp_header->length_indicator);
                 break;
-            } 
+            }
 
         case 	CLNP_PDU_DT:
         case 	CLNP_PDU_MD:
         case 	CLNP_PDU_ERQ:
-            
+
         default:
             /* dump the PDU specific data */
             if (length-(pptr-optr) > 0) {
-                printf("\n\t  undecoded non-header data, length %u",length-clnp_header->length_indicator);
-                print_unknown_data(pptr,"\n\t  ",length-(pptr-optr));
+                ND_PRINT((ndo, "\n\t  undecoded non-header data, length %u", length-clnp_header->length_indicator));
+                print_unknown_data(ndo, pptr, "\n\t  ", length - (pptr - optr));
             }
         }
 
         return (1);
 
  trunc:
-    fputs("[|clnp]", stdout);
+    ND_PRINT((ndo, "[|clnp]"));
     return (1);
 
 }
@@ -1015,35 +1004,33 @@
 };
 
 struct esis_header_t {
-	u_int8_t nlpid;
-	u_int8_t length_indicator;
-	u_int8_t version;
-	u_int8_t reserved;
-	u_int8_t type;
-	u_int8_t holdtime[2];
-	u_int8_t cksum[2];
+	uint8_t nlpid;
+	uint8_t length_indicator;
+	uint8_t version;
+	uint8_t reserved;
+	uint8_t type;
+	uint8_t holdtime[2];
+	uint8_t cksum[2];
 };
 
 static void
-esis_print(const u_int8_t *pptr, u_int length)
+esis_print(netdissect_options *ndo,
+           const uint8_t *pptr, u_int length)
 {
-	const u_int8_t *optr;
+	const uint8_t *optr;
 	u_int li,esis_pdu_type,source_address_length, source_address_number;
 	const struct esis_header_t *esis_header;
 
-        if (!eflag)
-            printf("ES-IS");
+	if (!ndo->ndo_eflag)
+		ND_PRINT((ndo, "ES-IS"));
 
 	if (length <= 2) {
-		if (qflag)
-			printf("bad pkt!");
-		else
-			printf("no header at all!");
+		ND_PRINT((ndo, ndo->ndo_qflag ? "bad pkt!" : "no header at all!"));
 		return;
 	}
 
 	esis_header = (const struct esis_header_t *) pptr;
-        TCHECK(*esis_header);
+        ND_TCHECK(*esis_header);
         li = esis_header->length_indicator;
         optr = pptr;
 
@@ -1052,104 +1039,105 @@
          */
 
         if (esis_header->nlpid != NLPID_ESIS) {
-            printf(" nlpid 0x%02x packet not supported", esis_header->nlpid);
+            ND_PRINT((ndo, " nlpid 0x%02x packet not supported", esis_header->nlpid));
             return;
         }
 
         if (esis_header->version != ESIS_VERSION) {
-            printf(" version %d packet not supported", esis_header->version);
+            ND_PRINT((ndo, " version %d packet not supported", esis_header->version));
             return;
         }
-                
+
 	if (li > length) {
-            printf(" length indicator(%d) > PDU size (%d)!", li, length);
+            ND_PRINT((ndo, " length indicator(%d) > PDU size (%d)!", li, length));
             return;
 	}
 
 	if (li < sizeof(struct esis_header_t) + 2) {
-            printf(" length indicator < min PDU size %d:", li);
-            while (--length != 0)
-                printf("%02X", *pptr++);
+            ND_PRINT((ndo, " length indicator < min PDU size %d:", li));
+            while (pptr < ndo->ndo_snapend)
+                ND_PRINT((ndo, "%02X", *pptr++));
             return;
 	}
 
         esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
 
-        if (vflag < 1) {
-            printf("%s%s, length %u",
-                   eflag ? "" : ", ",
+        if (ndo->ndo_vflag < 1) {
+            ND_PRINT((ndo, "%s%s, length %u",
+                   ndo->ndo_eflag ? "" : ", ",
                    tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
-                   length);
+                   length));
             return;
         } else
-            printf("%slength %u\n\t%s (%u)",
-                   eflag ? "" : ", ",
+            ND_PRINT((ndo, "%slength %u\n\t%s (%u)",
+                   ndo->ndo_eflag ? "" : ", ",
                    length,
                    tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
-                   esis_pdu_type);
+                   esis_pdu_type));
 
-        printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" );
-        printf(", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum));
+        ND_PRINT((ndo, ", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ));
+        ND_PRINT((ndo, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)));
 
-        osi_print_cksum(pptr, EXTRACT_16BITS(esis_header->cksum), 7, li);
+        osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li);
 
-        printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
+        ND_PRINT((ndo, ", holding time: %us, length indicator: %u",
+                  EXTRACT_16BITS(esis_header->holdtime), li));
 
-        if (vflag > 1)
-            print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t));
+        if (ndo->ndo_vflag > 1)
+            print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t));
 
 	pptr += sizeof(struct esis_header_t);
 	li -= sizeof(struct esis_header_t);
 
 	switch (esis_pdu_type) {
 	case ESIS_PDU_REDIRECT: {
-		const u_int8_t *dst, *snpa, *neta;
+		const uint8_t *dst, *snpa, *neta;
 		u_int dstl, snpal, netal;
 
-		TCHECK(*pptr);
+		ND_TCHECK(*pptr);
 		if (li < 1) {
-			printf(", bad redirect/li");
+			ND_PRINT((ndo, ", bad redirect/li"));
 			return;
 		}
 		dstl = *pptr;
 		pptr++;
 		li--;
-		TCHECK2(*pptr, dstl);
+		ND_TCHECK2(*pptr, dstl);
 		if (li < dstl) {
-			printf(", bad redirect/li");
+			ND_PRINT((ndo, ", bad redirect/li"));
 			return;
 		}
 		dst = pptr;
 		pptr += dstl;
                 li -= dstl;
-		printf("\n\t  %s", isonsap_string(dst,dstl));
+		ND_PRINT((ndo, "\n\t  %s", isonsap_string(dst, dstl)));
 
-		TCHECK(*pptr);
+		ND_TCHECK(*pptr);
 		if (li < 1) {
-			printf(", bad redirect/li");
+			ND_PRINT((ndo, ", bad redirect/li"));
 			return;
 		}
 		snpal = *pptr;
 		pptr++;
 		li--;
-		TCHECK2(*pptr, snpal);
+		ND_TCHECK2(*pptr, snpal);
 		if (li < snpal) {
-			printf(", bad redirect/li");
+			ND_PRINT((ndo, ", bad redirect/li"));
 			return;
 		}
 		snpa = pptr;
 		pptr += snpal;
                 li -= snpal;
-		TCHECK(*pptr);
+		ND_TCHECK(*pptr);
 		if (li < 1) {
-			printf(", bad redirect/li");
+			ND_PRINT((ndo, ", bad redirect/li"));
 			return;
 		}
 		netal = *pptr;
 		pptr++;
-		TCHECK2(*pptr, netal);
+		ND_TCHECK2(*pptr, netal);
 		if (li < netal) {
-			printf(", bad redirect/li");
+			ND_PRINT((ndo, ", bad redirect/li"));
 			return;
 		}
 		neta = pptr;
@@ -1157,42 +1145,42 @@
                 li -= netal;
 
 		if (netal == 0)
-			printf("\n\t  %s", etheraddr_string(snpa));
+			ND_PRINT((ndo, "\n\t  %s", etheraddr_string(ndo, snpa)));
 		else
-			printf("\n\t  %s", isonsap_string(neta,netal));
+			ND_PRINT((ndo, "\n\t  %s", isonsap_string(neta, netal)));
 		break;
 	}
 
 	case ESIS_PDU_ESH:
-            TCHECK(*pptr);
+            ND_TCHECK(*pptr);
             if (li < 1) {
-                printf(", bad esh/li");
+                ND_PRINT((ndo, ", bad esh/li"));
                 return;
             }
             source_address_number = *pptr;
             pptr++;
             li--;
 
-            printf("\n\t  Number of Source Addresses: %u", source_address_number);
-           
+            ND_PRINT((ndo, "\n\t  Number of Source Addresses: %u", source_address_number));
+
             while (source_address_number > 0) {
-                TCHECK(*pptr);
+                ND_TCHECK(*pptr);
             	if (li < 1) {
-                    printf(", bad esh/li");
+                    ND_PRINT((ndo, ", bad esh/li"));
             	    return;
             	}
                 source_address_length = *pptr;
                 pptr++;
             	li--;
 
-                TCHECK2(*pptr, source_address_length);
+                ND_TCHECK2(*pptr, source_address_length);
             	if (li < source_address_length) {
-                    printf(", bad esh/li");
+                    ND_PRINT((ndo, ", bad esh/li"));
             	    return;
             	}
-                printf("\n\t  NET (length: %u): %s",
+                ND_PRINT((ndo, "\n\t  NET (length: %u): %s",
                        source_address_length,
-                       isonsap_string(pptr,source_address_length));
+                       isonsap_string(pptr, source_address_length)));
                 pptr += source_address_length;
                 li -= source_address_length;
                 source_address_number--;
@@ -1201,78 +1189,78 @@
             break;
 
 	case ESIS_PDU_ISH: {
-            TCHECK(*pptr);
+            ND_TCHECK(*pptr);
             if (li < 1) {
-                printf(", bad ish/li");
+                ND_PRINT((ndo, ", bad ish/li"));
                 return;
             }
             source_address_length = *pptr;
             pptr++;
             li--;
-            TCHECK2(*pptr, source_address_length);
+            ND_TCHECK2(*pptr, source_address_length);
             if (li < source_address_length) {
-                printf(", bad ish/li");
+                ND_PRINT((ndo, ", bad ish/li"));
                 return;
             }
-            printf("\n\t  NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length));
+            ND_PRINT((ndo, "\n\t  NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length)));
             pptr += source_address_length;
             li -= source_address_length;
             break;
 	}
 
 	default:
-            if (vflag <= 1) {
-		    if (pptr < snapend) 
-                            print_unknown_data(pptr,"\n\t  ",snapend-pptr);
-            }
-            return;
+		if (ndo->ndo_vflag <= 1) {
+			if (pptr < ndo->ndo_snapend)
+				print_unknown_data(ndo, pptr, "\n\t  ", ndo->ndo_snapend - pptr);
+		}
+		return;
 	}
 
         /* now walk the options */
         while (li != 0) {
             u_int op, opli;
-            const u_int8_t *tptr;
-            
+            const uint8_t *tptr;
+
             if (li < 2) {
-                printf(", bad opts/li");
+                ND_PRINT((ndo, ", bad opts/li"));
                 return;
             }
-            TCHECK2(*pptr, 2);
+            ND_TCHECK2(*pptr, 2);
             op = *pptr++;
             opli = *pptr++;
             li -= 2;
             if (opli > li) {
-                printf(", opt (%d) too long", op);
+                ND_PRINT((ndo, ", opt (%d) too long", op));
                 return;
             }
             li -= opli;
             tptr = pptr;
-            
-            printf("\n\t  %s Option #%u, length %u, value: ",
+
+            ND_PRINT((ndo, "\n\t  %s Option #%u, length %u, value: ",
                    tok2str(esis_option_values,"Unknown",op),
                    op,
-                   opli);
+                   opli));
 
             switch (op) {
 
             case ESIS_OPTION_ES_CONF_TIME:
                 if (opli == 2) {
-                    TCHECK2(*pptr, 2);
-                    printf("%us", EXTRACT_16BITS(tptr));
+                    ND_TCHECK2(*pptr, 2);
+                    ND_PRINT((ndo, "%us", EXTRACT_16BITS(tptr)));
                 } else
-                    printf("(bad length)");
+                    ND_PRINT((ndo, "(bad length)"));
                 break;
 
             case ESIS_OPTION_PROTOCOLS:
                 while (opli>0) {
-                    TCHECK(*pptr);
-                    printf("%s (0x%02x)",
+                    ND_TCHECK(*pptr);
+                    ND_PRINT((ndo, "%s (0x%02x)",
                            tok2str(nlpid_values,
                                    "unknown",
                                    *tptr),
-                           *tptr);
+                           *tptr));
                     if (opli>1) /* further NPLIDs ? - put comma */
-                        printf(", ");
+                        ND_PRINT((ndo, ", "));
                     tptr++;
                     opli--;
                 }
@@ -1290,43 +1278,43 @@
             case ESIS_OPTION_SNPA_MASK:
 
             default:
-                print_unknown_data(tptr,"\n\t  ",opli);
+                print_unknown_data(ndo, tptr, "\n\t  ", opli);
                 break;
             }
-            if (vflag > 1)
-                print_unknown_data(pptr,"\n\t  ",opli);
+            if (ndo->ndo_vflag > 1)
+                print_unknown_data(ndo, pptr, "\n\t  ", opli);
             pptr += opli;
         }
 trunc:
 	return;
-}   
-
+}
 
 static void
-isis_print_mcid (const struct isis_spb_mcid *mcid)
+isis_print_mcid(netdissect_options *ndo,
+                const struct isis_spb_mcid *mcid)
 {
   int i;
 
-  printf( "ID: %d, Name: ", mcid->format_id);
+  ND_PRINT((ndo,  "ID: %d, Name: ", mcid->format_id));
 
-  for(i=0; i<32; i++) 
-  { 
-    printf("%c", mcid->name[i]);
+  for(i=0; i<32; i++)
+  {
+    ND_PRINT((ndo, "%c", mcid->name[i]));
     if(mcid->name[i] == '\0')
         break;
   }
 
-  printf("\n\t              Lvl: %d", 
-          EXTRACT_16BITS(mcid->revision_lvl));
+  ND_PRINT((ndo, "\n\t              Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl)));
 
-  printf( ", Digest: ");
+  ND_PRINT((ndo,  ", Digest: "));
 
-  for(i=0;i<16;i++) 
-    printf("%.2x ",mcid->digest[i]);
+  for(i=0;i<16;i++)
+    ND_PRINT((ndo, "%.2x ", mcid->digest[i]));
 }
 
 static int
-isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
+isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
+                              const uint8_t *tptr, int len)
 {
   int stlv_type, stlv_len;
   const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
@@ -1338,10 +1326,10 @@
     stlv_len  = *(tptr++);
 
     /* first lets see if we know the subTLVs name*/
-    printf("\n\t       %s subTLV #%u, length: %u",
+    ND_PRINT((ndo, "\n\t       %s subTLV #%u, length: %u",
                tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
                stlv_type,
-               stlv_len);
+               stlv_len));
 
     /*len -= TLV_TYPE_LEN_OFFSET;*/
     len = len -2;
@@ -1350,19 +1338,19 @@
     {
       case ISIS_SUBTLV_SPB_MCID:
       {
-        if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN))
+        if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN))
           goto trunctlv;
 
         subtlv_spb_mcid = (struct isis_subtlv_spb_mcid *)tptr;
 
-        printf( "\n\t         MCID: ");
-        isis_print_mcid (&(subtlv_spb_mcid->mcid));
+        ND_PRINT((ndo,  "\n\t         MCID: "));
+        isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
 
           /*tptr += SPB_MCID_MIN_LEN;
             len -= SPB_MCID_MIN_LEN; */
 
-        printf( "\n\t         AUX-MCID: ");
-        isis_print_mcid (&(subtlv_spb_mcid->aux_mcid));
+        ND_PRINT((ndo,  "\n\t         AUX-MCID: "));
+        isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
 
           /*tptr += SPB_MCID_MIN_LEN;
             len -= SPB_MCID_MIN_LEN; */
@@ -1374,22 +1362,22 @@
 
       case ISIS_SUBTLV_SPB_DIGEST:
       {
-        if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN))
+        if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN))
           goto trunctlv;
 
-        printf ("\n\t        RES: %d V: %d A: %d D: %d",
+        ND_PRINT((ndo, "\n\t        RES: %d V: %d A: %d D: %d",
                         (*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
-                        ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03));
+                        ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
 
         tptr++;
 
-        printf( "\n\t         Digest: ");
-          
+        ND_PRINT((ndo,  "\n\t         Digest: "));
+
         for(i=1;i<=8; i++)
         {
-            printf("%08x ", EXTRACT_32BITS(tptr));
+            ND_PRINT((ndo, "%08x ", EXTRACT_32BITS(tptr)));
             if (i%4 == 0 && i != 8)
-              printf("\n\t                 ");
+              ND_PRINT((ndo, "\n\t                 "));
             tptr = tptr + 4;
         }
 
@@ -1400,23 +1388,23 @@
 
       case ISIS_SUBTLV_SPB_BVID:
       {
-        if (!TTEST2(*(tptr), stlv_len))
+        if (!ND_TTEST2(*(tptr), stlv_len))
           goto trunctlv;
 
         while (len)
         {
-          if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN))
+          if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN))
             goto trunctlv;
 
-          printf("\n\t           ECT: %08x", 
-                      EXTRACT_32BITS(tptr));
+          ND_PRINT((ndo, "\n\t           ECT: %08x",
+                      EXTRACT_32BITS(tptr)));
 
           tptr = tptr+4;
 
-          printf(" BVID: %d, U:%01x M:%01x ",
+          ND_PRINT((ndo, " BVID: %d, U:%01x M:%01x ",
                      (EXTRACT_16BITS (tptr) >> 4) ,
                      (EXTRACT_16BITS (tptr) >> 3) & 0x01,
-                     (EXTRACT_16BITS (tptr) >> 2) & 0x01);
+                     (EXTRACT_16BITS (tptr) >> 2) & 0x01));
 
           tptr = tptr + 2;
           len = len - ISIS_SUBTLV_SPB_BVID_MIN_LEN;
@@ -1424,7 +1412,7 @@
 
         break;
       }
-      
+
       default:
           break;
     }
@@ -1433,51 +1421,52 @@
   return 0;
 
   trunctlv:
-    printf("\n\t\t packet exceeded snapshot");
-    return(1); 
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+    return(1);
 }
 
 static int
-isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
+isis_print_mt_capability_subtlv(netdissect_options *ndo,
+                                const uint8_t *tptr, int len)
 {
   int stlv_type, stlv_len, tmp;
 
-  while (len > 0) 
-  {   
+  while (len > 0)
+  {
     stlv_type = *(tptr++);
     stlv_len  = *(tptr++);
 
     /* first lets see if we know the subTLVs name*/
-    printf("\n\t      %s subTLV #%u, length: %u",
+    ND_PRINT((ndo, "\n\t      %s subTLV #%u, length: %u",
                tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
                stlv_type,
-               stlv_len);
- 
+               stlv_len));
+
     len = len - 2;
 
     switch (stlv_type)
-    {    
+    {
       case ISIS_SUBTLV_SPB_INSTANCE:
 
-          if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN)) 
+          if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN))
             goto trunctlv;
 
-          printf("\n\t        CIST Root-ID: %08x", EXTRACT_32BITS(tptr));
+          ND_PRINT((ndo, "\n\t        CIST Root-ID: %08x", EXTRACT_32BITS(tptr)));
           tptr = tptr+4;
-          printf(" %08x", EXTRACT_32BITS(tptr));
+          ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tptr)));
           tptr = tptr+4;
-          printf(", Path Cost: %08x", EXTRACT_32BITS(tptr));
+          ND_PRINT((ndo, ", Path Cost: %08x", EXTRACT_32BITS(tptr)));
           tptr = tptr+4;
-          printf(", Prio: %d", EXTRACT_16BITS(tptr));
-          tptr = tptr + 2; 
-          printf("\n\t        RES: %d", 
-                    EXTRACT_16BITS(tptr) >> 5);
-          printf(", V: %d", 
-                    (EXTRACT_16BITS(tptr) >> 4) & 0x0001);
-          printf(", SPSource-ID: %d", 
-                    (EXTRACT_32BITS(tptr) & 0x000fffff));
+          ND_PRINT((ndo, ", Prio: %d", EXTRACT_16BITS(tptr)));
+          tptr = tptr + 2;
+          ND_PRINT((ndo, "\n\t        RES: %d",
+                    EXTRACT_16BITS(tptr) >> 5));
+          ND_PRINT((ndo, ", V: %d",
+                    (EXTRACT_16BITS(tptr) >> 4) & 0x0001));
+          ND_PRINT((ndo, ", SPSource-ID: %d",
+                    (EXTRACT_32BITS(tptr) & 0x000fffff)));
           tptr = tptr+4;
-          printf(", No of Trees: %x", *(tptr));
+          ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
 
           tmp = *(tptr++);
 
@@ -1485,42 +1474,42 @@
 
           while (tmp)
           {
-            if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN))
+            if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN))
               goto trunctlv;
 
-            printf ("\n\t         U:%d, M:%d, A:%d, RES:%d",
+            ND_PRINT((ndo, "\n\t         U:%d, M:%d, A:%d, RES:%d",
                       *(tptr) >> 7, (*(tptr) >> 6) & 0x01,
-                      (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f));
-            
+                      (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
+
             tptr++;
-    
-            printf (", ECT: %08x", EXTRACT_32BITS(tptr));
+
+            ND_PRINT((ndo, ", ECT: %08x", EXTRACT_32BITS(tptr)));
 
             tptr = tptr + 4;
 
-            printf (", BVID: %d, SPVID: %d",
+            ND_PRINT((ndo, ", BVID: %d, SPVID: %d",
                       (EXTRACT_24BITS(tptr) >> 12) & 0x000fff,
-                      EXTRACT_24BITS(tptr) & 0x000fff);
+                      EXTRACT_24BITS(tptr) & 0x000fff));
 
             tptr = tptr + 3;
             len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
-            tmp--;             
+            tmp--;
           }
 
           break;
 
       case ISIS_SUBTLV_SPBM_SI:
 
-          if (!TTEST2(*(tptr), 6)) 
+          if (!ND_TTEST2(*(tptr), 6))
             goto trunctlv;
 
-          printf("\n\t        BMAC: %08x", EXTRACT_32BITS(tptr));
+          ND_PRINT((ndo, "\n\t        BMAC: %08x", EXTRACT_32BITS(tptr)));
           tptr = tptr+4;
-          printf("%04x", EXTRACT_16BITS(tptr));
+          ND_PRINT((ndo, "%04x", EXTRACT_16BITS(tptr)));
           tptr = tptr+2;
 
-          printf (", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
-                    (EXTRACT_16BITS(tptr)) & 0x0fff);
+          ND_PRINT((ndo, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
+                    (EXTRACT_16BITS(tptr)) & 0x0fff));
 
           tptr = tptr+2;
           len = len - 8;
@@ -1528,11 +1517,11 @@
 
           while (stlv_len)
           {
-            printf("\n\t        T: %d, R: %d, RES: %d, ISID: %d",
+            ND_PRINT((ndo, "\n\t        T: %d, R: %d, RES: %d, ISID: %d",
                     (EXTRACT_32BITS(tptr) >> 31),
                     (EXTRACT_32BITS(tptr) >> 30) & 0x01,
                     (EXTRACT_32BITS(tptr) >> 24) & 0x03f,
-                    (EXTRACT_32BITS(tptr)) & 0x0ffffff);
+                    (EXTRACT_32BITS(tptr)) & 0x0ffffff));
 
             tptr = tptr + 4;
             len = len - 4;
@@ -1548,14 +1537,13 @@
   return 0;
 
   trunctlv:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
     return(1);
 }
 
-
 /* shared routine for printing system, node and lsp-ids */
 static char *
-isis_print_id(const u_int8_t *cp, int id_len)
+isis_print_id(const uint8_t *cp, int id_len)
 {
     int i;
     static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
@@ -1578,29 +1566,31 @@
 
 /* print the 4-byte metric block which is common found in the old-style TLVs */
 static int
-isis_print_metric_block (const struct isis_metric_block *isis_metric_block)
+isis_print_metric_block(netdissect_options *ndo,
+                        const struct isis_metric_block *isis_metric_block)
 {
-    printf(", Default Metric: %d, %s",
+    ND_PRINT((ndo, ", Default Metric: %d, %s",
            ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
-           ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal");
+           ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal"));
     if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
-        printf("\n\t\t  Delay Metric: %d, %s",
+        ND_PRINT((ndo, "\n\t\t  Delay Metric: %d, %s",
                ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
-               ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal");
+               ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal"));
     if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
-        printf("\n\t\t  Expense Metric: %d, %s",
+        ND_PRINT((ndo, "\n\t\t  Expense Metric: %d, %s",
                ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
-               ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal");
+               ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal"));
     if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
-        printf("\n\t\t  Error Metric: %d, %s",
+        ND_PRINT((ndo, "\n\t\t  Error Metric: %d, %s",
                ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
-               ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal");
+               ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal"));
 
     return(1); /* everything is ok */
 }
 
 static int
-isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
+isis_print_tlv_ip_reach(netdissect_options *ndo,
+                        const uint8_t *cp, const char *ident, int length)
 {
 	int prefix_len;
 	const struct isis_tlv_ip_reach *tlv_ip_reach;
@@ -1609,50 +1599,50 @@
 
 	while (length > 0) {
 		if ((size_t)length < sizeof(*tlv_ip_reach)) {
-			printf("short IPv4 Reachability (%d vs %lu)",
+			ND_PRINT((ndo, "short IPv4 Reachability (%d vs %lu)",
                                length,
-                               (unsigned long)sizeof(*tlv_ip_reach));
+                               (unsigned long)sizeof(*tlv_ip_reach)));
 			return (0);
 		}
 
-		if (!TTEST(*tlv_ip_reach))
+		if (!ND_TTEST(*tlv_ip_reach))
 		    return (0);
 
 		prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
 
 		if (prefix_len == -1)
-			printf("%sIPv4 prefix: %s mask %s",
+			ND_PRINT((ndo, "%sIPv4 prefix: %s mask %s",
                                ident,
-			       ipaddr_string((tlv_ip_reach->prefix)),
-			       ipaddr_string((tlv_ip_reach->mask)));
+			       ipaddr_string(ndo, (tlv_ip_reach->prefix)),
+			       ipaddr_string(ndo, (tlv_ip_reach->mask))));
 		else
-			printf("%sIPv4 prefix: %15s/%u",
+			ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
                                ident,
-			       ipaddr_string((tlv_ip_reach->prefix)),
-			       prefix_len);
+			       ipaddr_string(ndo, (tlv_ip_reach->prefix)),
+			       prefix_len));
 
-		printf(", Distribution: %s, Metric: %u, %s",
+		ND_PRINT((ndo, ", Distribution: %s, Metric: %u, %s",
                        ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
                        ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
-                       ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal");
+                       ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal"));
 
 		if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
-                    printf("%s  Delay Metric: %u, %s",
+                    ND_PRINT((ndo, "%s  Delay Metric: %u, %s",
                            ident,
                            ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
-                           ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal");
-                
+                           ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"));
+
 		if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
-                    printf("%s  Expense Metric: %u, %s",
+                    ND_PRINT((ndo, "%s  Expense Metric: %u, %s",
                            ident,
                            ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
-                           ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal");
-                
+                           ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"));
+
 		if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
-                    printf("%s  Error Metric: %u, %s",
+                    ND_PRINT((ndo, "%s  Error Metric: %u, %s",
                            ident,
                            ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
-                           ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal");
+                           ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"));
 
 		length -= sizeof(struct isis_tlv_ip_reach);
 		tlv_ip_reach++;
@@ -1666,50 +1656,47 @@
  */
 
 static int
-isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
-
+isis_print_ip_reach_subtlv(netdissect_options *ndo,
+                           const uint8_t *tptr, int subt, int subl,
+                           const char *ident)
+{
         /* first lets see if we know the subTLVs name*/
-	printf("%s%s subTLV #%u, length: %u",
-	       ident,
-               tok2str(isis_ext_ip_reach_subtlv_values,
-                       "unknown",
-                       subt),
-               subt,
-               subl);
+	ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
+	          ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt),
+	          subt, subl));
 
-	if (!TTEST2(*tptr,subl))
+	if (!ND_TTEST2(*tptr,subl))
 	    goto trunctlv;
 
     switch(subt) {
     case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
     case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
         while (subl >= 4) {
-	    printf(", 0x%08x (=%u)",
+	    ND_PRINT((ndo, ", 0x%08x (=%u)",
 		   EXTRACT_32BITS(tptr),
-		   EXTRACT_32BITS(tptr));
+		   EXTRACT_32BITS(tptr)));
 	    tptr+=4;
 	    subl-=4;
 	}
 	break;
     case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
         while (subl >= 8) {
-	    printf(", 0x%08x%08x",
+	    ND_PRINT((ndo, ", 0x%08x%08x",
 		   EXTRACT_32BITS(tptr),
-		   EXTRACT_32BITS(tptr+4));
+		   EXTRACT_32BITS(tptr+4)));
 	    tptr+=8;
 	    subl-=8;
 	}
 	break;
     default:
-	if(!print_unknown_data(tptr,"\n\t\t    ",
-			       subl))
+	if (!print_unknown_data(ndo, tptr, "\n\t\t    ", subl))
 	  return(0);
 	break;
     }
     return(1);
-	
+
 trunctlv:
-    printf("%spacket exceeded snapshot",ident);
+    ND_PRINT((ndo, "%spacket exceeded snapshot", ident));
     return(0);
 }
 
@@ -1719,122 +1706,120 @@
  */
 
 static int
-isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) {
-
+isis_print_is_reach_subtlv(netdissect_options *ndo,
+                           const uint8_t *tptr, u_int subt, u_int subl,
+                           const char *ident)
+{
         u_int te_class,priority_level,gmpls_switch_cap;
         union { /* int to float conversion buffer for several subTLVs */
-            float f; 
-            u_int32_t i;
+            float f;
+            uint32_t i;
         } bw;
 
         /* first lets see if we know the subTLVs name*/
-	printf("%s%s subTLV #%u, length: %u",
-	       ident,
-               tok2str(isis_ext_is_reach_subtlv_values,
-                       "unknown",
-                       subt),
-               subt,
-               subl);
+	ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
+	          ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt),
+	          subt, subl));
 
-	if (!TTEST2(*tptr,subl))
+	if (!ND_TTEST2(*tptr,subl))
 	    goto trunctlv;
 
         switch(subt) {
-        case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:      
+        case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
         case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
         case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
 	    if (subl >= 4) {
-	      printf(", 0x%08x", EXTRACT_32BITS(tptr));
+	      ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
 	      if (subl == 8) /* rfc4205 */
-	        printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
+	        ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr+4)));
 	    }
 	    break;
         case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
         case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
             if (subl >= sizeof(struct in_addr))
-              printf(", %s", ipaddr_string(tptr));
+              ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
-	case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:  
+	case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
             if (subl >= 4) {
               bw.i = EXTRACT_32BITS(tptr);
-              printf(", %.3f Mbps", bw.f*8/1000000 );
+              ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
             }
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
             if (subl >= 32) {
               for (te_class = 0; te_class < 8; te_class++) {
                 bw.i = EXTRACT_32BITS(tptr);
-                printf("%s  TE-Class %u: %.3f Mbps",
+                ND_PRINT((ndo, "%s  TE-Class %u: %.3f Mbps",
                        ident,
                        te_class,
-                       bw.f*8/1000000 );
+                       bw.f * 8 / 1000000));
 		tptr+=4;
 	      }
             }
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
         case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
-            printf("%sBandwidth Constraints Model ID: %s (%u)",
+            ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
                    ident,
                    tok2str(diffserv_te_bc_values, "unknown", *tptr),
-                   *tptr);
+                   *tptr));
             tptr++;
             /* decode BCs until the subTLV ends */
             for (te_class = 0; te_class < (subl-1)/4; te_class++) {
                 bw.i = EXTRACT_32BITS(tptr);
-                printf("%s  Bandwidth constraint CT%u: %.3f Mbps",
+                ND_PRINT((ndo, "%s  Bandwidth constraint CT%u: %.3f Mbps",
                        ident,
                        te_class,
-                       bw.f*8/1000000 );
+                       bw.f * 8 / 1000000));
 		tptr+=4;
             }
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
             if (subl >= 3)
-              printf(", %u", EXTRACT_24BITS(tptr));
+              ND_PRINT((ndo, ", %u", EXTRACT_24BITS(tptr)));
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE:
             if (subl == 2) {
-               printf(", [ %s ] (0x%04x)",
+               ND_PRINT((ndo, ", [ %s ] (0x%04x)",
                       bittok2str(isis_subtlv_link_attribute_values,
                                  "Unknown",
                                  EXTRACT_16BITS(tptr)),
-                      EXTRACT_16BITS(tptr));
+                      EXTRACT_16BITS(tptr)));
             }
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
             if (subl >= 2) {
-              printf(", %s, Priority %u",
+              ND_PRINT((ndo, ", %s, Priority %u",
 		   bittok2str(gmpls_link_prot_values, "none", *tptr),
-                   *(tptr+1));
+                   *(tptr+1)));
             }
             break;
         case ISIS_SUBTLV_SPB_METRIC:
             if (subl >= 6) {
-              printf (", LM: %u", EXTRACT_24BITS(tptr));
+              ND_PRINT((ndo, ", LM: %u", EXTRACT_24BITS(tptr)));
               tptr=tptr+3;
-              printf (", P: %u", *(tptr));
+              ND_PRINT((ndo, ", P: %u", *(tptr)));
               tptr++;
-              printf (", P-ID: %u", EXTRACT_16BITS(tptr));
+              ND_PRINT((ndo, ", P-ID: %u", EXTRACT_16BITS(tptr)));
             }
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
             if (subl >= 36) {
               gmpls_switch_cap = *tptr;
-              printf("%s  Interface Switching Capability:%s",
+              ND_PRINT((ndo, "%s  Interface Switching Capability:%s",
                    ident,
-                   tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap));
-              printf(", LSP Encoding: %s",
-                   tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
+                   tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
+              ND_PRINT((ndo, ", LSP Encoding: %s",
+                   tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
 	      tptr+=4;
-              printf("%s  Max LSP Bandwidth:",ident);
+              ND_PRINT((ndo, "%s  Max LSP Bandwidth:", ident));
               for (priority_level = 0; priority_level < 8; priority_level++) {
                 bw.i = EXTRACT_32BITS(tptr);
-                printf("%s    priority level %d: %.3f Mbps",
+                ND_PRINT((ndo, "%s    priority level %d: %.3f Mbps",
                        ident,
                        priority_level,
-                       bw.f*8/1000000 );
+                       bw.f * 8 / 1000000));
 		tptr+=4;
               }
               subl-=36;
@@ -1844,36 +1829,34 @@
               case GMPLS_PSC3:
               case GMPLS_PSC4:
                 bw.i = EXTRACT_32BITS(tptr);
-                printf("%s  Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000);
-                printf("%s  Interface MTU: %u", ident, EXTRACT_16BITS(tptr+4));
+                ND_PRINT((ndo, "%s  Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
+                ND_PRINT((ndo, "%s  Interface MTU: %u", ident, EXTRACT_16BITS(tptr + 4)));
                 break;
               case GMPLS_TSC:
                 bw.i = EXTRACT_32BITS(tptr);
-                printf("%s  Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000);
-                printf("%s  Indication %s", ident,
-                       tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr+4)));
+                ND_PRINT((ndo, "%s  Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
+                ND_PRINT((ndo, "%s  Indication %s", ident,
+                       tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr + 4))));
                 break;
               default:
                 /* there is some optional stuff left to decode but this is as of yet
                    not specified so just lets hexdump what is left */
                 if(subl>0){
-                  if(!print_unknown_data(tptr,"\n\t\t    ",
-                                         subl))
+                  if (!print_unknown_data(ndo, tptr, "\n\t\t    ", subl))
                     return(0);
                 }
               }
             }
             break;
         default:
-            if(!print_unknown_data(tptr,"\n\t\t    ",
-				   subl))
+            if (!print_unknown_data(ndo, tptr, "\n\t\t    ", subl))
                 return(0);
             break;
         }
         return(1);
 
 trunctlv:
-    printf("%spacket exceeded snapshot",ident);
+    ND_PRINT((ndo, "%spacket exceeded snapshot", ident));
     return(0);
 }
 
@@ -1884,40 +1867,41 @@
  */
 
 static int
-isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
-
+isis_print_ext_is_reach(netdissect_options *ndo,
+                        const uint8_t *tptr, const char *ident, int tlv_type)
+{
     char ident_buffer[20];
     int subtlv_type,subtlv_len,subtlv_sum_len;
     int proc_bytes = 0; /* how many bytes did we process ? */
-    
-    if (!TTEST2(*tptr, NODE_ID_LEN))
+
+    if (!ND_TTEST2(*tptr, NODE_ID_LEN))
         return(0);
 
-    printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
+    ND_PRINT((ndo, "%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)));
     tptr+=(NODE_ID_LEN);
 
     if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
-        if (!TTEST2(*tptr, 3))    /* and is therefore skipped */
+        if (!ND_TTEST2(*tptr, 3))    /* and is therefore skipped */
 	    return(0);
-	printf(", Metric: %d",EXTRACT_24BITS(tptr));
+	ND_PRINT((ndo, ", Metric: %d", EXTRACT_24BITS(tptr)));
 	tptr+=3;
     }
-        
-    if (!TTEST2(*tptr, 1))
+
+    if (!ND_TTEST2(*tptr, 1))
         return(0);
     subtlv_sum_len=*(tptr++); /* read out subTLV length */
     proc_bytes=NODE_ID_LEN+3+1;
-    printf(", %ssub-TLVs present",subtlv_sum_len ? "" : "no ");
+    ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
     if (subtlv_sum_len) {
-        printf(" (%u)",subtlv_sum_len);
+        ND_PRINT((ndo, " (%u)", subtlv_sum_len));
         while (subtlv_sum_len>0) {
-            if (!TTEST2(*tptr,2))
+            if (!ND_TTEST2(*tptr,2))
                 return(0);
             subtlv_type=*(tptr++);
             subtlv_len=*(tptr++);
             /* prepend the ident string */
             snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
-            if(!isis_print_is_reach_subtlv(tptr,subtlv_type,subtlv_len,ident_buffer))
+            if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
                 return(0);
             tptr+=subtlv_len;
             subtlv_sum_len-=(subtlv_len+2);
@@ -1933,20 +1917,21 @@
  */
 
 static int
-isis_print_mtid (const u_int8_t *tptr,const char *ident) {
-    
-    if (!TTEST2(*tptr, 2))
+isis_print_mtid(netdissect_options *ndo,
+                const uint8_t *tptr, const char *ident)
+{
+    if (!ND_TTEST2(*tptr, 2))
         return(0);
 
-    printf("%s%s",
+    ND_PRINT((ndo, "%s%s",
            ident,
            tok2str(isis_mt_values,
                    "Reserved for IETF Consensus",
-                   ISIS_MASK_MTID(EXTRACT_16BITS(tptr))));
+                   ISIS_MASK_MTID(EXTRACT_16BITS(tptr)))));
 
-    printf(" Topology (0x%03x), Flags: [%s]",
+    ND_PRINT((ndo, " Topology (0x%03x), Flags: [%s]",
            ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
-           bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr))));
+           bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr)))));
 
     return(2);
 }
@@ -1959,44 +1944,45 @@
  */
 
 static int
-isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) {
-
+isis_print_extd_ip_reach(netdissect_options *ndo,
+                         const uint8_t *tptr, const char *ident, uint16_t afi)
+{
     char ident_buffer[20];
 #ifdef INET6
-    u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
+    uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
 #else
-    u_int8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */
+    uint8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */
 #endif
     u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
 
-    if (!TTEST2(*tptr, 4))
+    if (!ND_TTEST2(*tptr, 4))
         return (0);
     metric = EXTRACT_32BITS(tptr);
     processed=4;
     tptr+=4;
-    
+
     if (afi == AF_INET) {
-        if (!TTEST2(*tptr, 1)) /* fetch status byte */
+        if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
             return (0);
         status_byte=*(tptr++);
         bit_length = status_byte&0x3f;
         if (bit_length > 32) {
-            printf("%sIPv4 prefix: bad bit length %u",
+            ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
                    ident,
-                   bit_length);
+                   bit_length));
             return (0);
         }
         processed++;
 #ifdef INET6
     } else if (afi == AF_INET6) {
-        if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
+        if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
             return (0);
         status_byte=*(tptr++);
         bit_length=*(tptr++);
         if (bit_length > 128) {
-            printf("%sIPv6 prefix: bad bit length %u",
+            ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
                    ident,
-                   bit_length);
+                   bit_length));
             return (0);
         }
         processed+=2;
@@ -2005,8 +1991,8 @@
         return (0); /* somebody is fooling us */
 
     byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
-   
-    if (!TTEST2(*tptr, byte_length))
+
+    if (!ND_TTEST2(*tptr, byte_length))
         return (0);
     memset(prefix, 0, sizeof prefix);   /* clear the copy buffer */
     memcpy(prefix,tptr,byte_length);    /* copy as much as is stored in the TLV */
@@ -2014,31 +2000,31 @@
     processed+=byte_length;
 
     if (afi == AF_INET)
-        printf("%sIPv4 prefix: %15s/%u",
+        ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
                ident,
-               ipaddr_string(prefix),
-               bit_length);
+               ipaddr_string(ndo, prefix),
+               bit_length));
 #ifdef INET6
     if (afi == AF_INET6)
-        printf("%sIPv6 prefix: %s/%u",
+        ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
                ident,
-               ip6addr_string(prefix),
-               bit_length);
-#endif 
-   
-    printf(", Distribution: %s, Metric: %u",
+               ip6addr_string(ndo, prefix),
+               bit_length));
+#endif
+
+    ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
            ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
-           metric);
+           metric));
 
     if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
-        printf(", sub-TLVs present");
+        ND_PRINT((ndo, ", sub-TLVs present"));
 #ifdef INET6
     if (afi == AF_INET6)
-        printf(", %s%s",
+        ND_PRINT((ndo, ", %s%s",
                ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
-               ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "");
+               ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""));
 #endif
-    
+
     if ((afi == AF_INET  && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
 #ifdef INET6
      || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
@@ -2048,20 +2034,20 @@
            than one subTLV - therefore the first byte must reflect
            the aggregate bytecount of the subTLVs for this prefix
         */
-        if (!TTEST2(*tptr, 1))
+        if (!ND_TTEST2(*tptr, 1))
             return (0);
         sublen=*(tptr++);
         processed+=sublen+1;
-        printf(" (%u)",sublen);   /* print out subTLV length */
-        
+        ND_PRINT((ndo, " (%u)", sublen));   /* print out subTLV length */
+
         while (sublen>0) {
-            if (!TTEST2(*tptr,2))
+            if (!ND_TTEST2(*tptr,2))
                 return (0);
             subtlvtype=*(tptr++);
             subtlvlen=*(tptr++);
             /* prepend the ident string */
             snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
-            if(!isis_print_ip_reach_subtlv(tptr,subtlvtype,subtlvlen,ident_buffer))
+            if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
                 return(0);
             tptr+=subtlvlen;
             sublen-=(subtlvlen+2);
@@ -2075,7 +2061,9 @@
  * Decode IS-IS packets.  Return 0 on error.
  */
 
-static int isis_print (const u_int8_t *p, u_int length)
+static int
+isis_print(netdissect_options *ndo,
+           const uint8_t *p, u_int length)
 {
     const struct isis_common_header *isis_header;
 
@@ -2090,9 +2078,9 @@
     const struct isis_tlv_is_reach *tlv_is_reach;
     const struct isis_tlv_es_reach *tlv_es_reach;
 
-    u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
-    u_int8_t ext_is_len, ext_ip_len, mt_len;
-    const u_int8_t *optr, *pptr, *tptr;
+    uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
+    uint8_t ext_is_len, ext_ip_len, mt_len;
+    const uint8_t *optr, *pptr, *tptr;
     u_short packet_len,pdu_len, key_id;
     u_int i,vendor_id;
     int sigcheck;
@@ -2102,7 +2090,7 @@
                  need it for parsing the checksum TLV and authentication
                  TLV verification */
     isis_header = (const struct isis_common_header *)p;
-    TCHECK(*isis_header);
+    ND_TCHECK(*isis_header);
     pptr = p+(ISIS_COMMON_HEADER_SIZE);
     header_iih_lan = (const struct isis_iih_lan_header *)pptr;
     header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
@@ -2110,26 +2098,26 @@
     header_csnp = (const struct isis_csnp_header *)pptr;
     header_psnp = (const struct isis_psnp_header *)pptr;
 
-    if (!eflag)
-        printf("IS-IS");
+    if (!ndo->ndo_eflag)
+        ND_PRINT((ndo, "IS-IS"));
 
     /*
      * Sanity checking of the header.
      */
 
     if (isis_header->version != ISIS_VERSION) {
-	printf("version %d packet not supported", isis_header->version);
+	ND_PRINT((ndo, "version %d packet not supported", isis_header->version));
 	return (0);
     }
 
     if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
-	printf("system ID length of %d is not supported",
-	       isis_header->id_length);
+	ND_PRINT((ndo, "system ID length of %d is not supported",
+	       isis_header->id_length));
 	return (0);
     }
 
     if (isis_header->pdu_version != ISIS_VERSION) {
-	printf("version %d packet not supported", isis_header->pdu_version);
+	ND_PRINT((ndo, "version %d packet not supported", isis_header->pdu_version));
 	return (0);
     }
 
@@ -2139,7 +2127,7 @@
 	max_area = 3;	 /* silly shit */
 	break;
     case 255:
-	printf("bad packet -- 255 areas");
+	ND_PRINT((ndo, "bad packet -- 255 areas"));
 	return (0);
     default:
 	break;
@@ -2167,58 +2155,58 @@
     }
 
     /* toss any non 6-byte sys-ID len PDUs */
-    if (id_length != 6 ) { 
-	printf("bad packet -- illegal sys-ID length (%u)", id_length);
+    if (id_length != 6 ) {
+	ND_PRINT((ndo, "bad packet -- illegal sys-ID length (%u)", id_length));
 	return (0);
     }
 
     pdu_type=isis_header->pdu_type;
 
     /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
-    if (vflag < 1) {
-        printf("%s%s",
-               eflag ? "" : ", ",
-               tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "%s%s",
+               ndo->ndo_eflag ? "" : ", ",
+               tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type)));
 
 	switch (pdu_type) {
 
 	case ISIS_PDU_L1_LAN_IIH:
 	case ISIS_PDU_L2_LAN_IIH:
-	    printf(", src-id %s",
-                   isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
-	    printf(", lan-id %s, prio %u",
+	    ND_PRINT((ndo, ", src-id %s",
+                   isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN)));
+	    ND_PRINT((ndo, ", lan-id %s, prio %u",
                    isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
-                   header_iih_lan->priority);
+                   header_iih_lan->priority));
 	    break;
 	case ISIS_PDU_PTP_IIH:
-	    printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
+	    ND_PRINT((ndo, ", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN)));
 	    break;
 	case ISIS_PDU_L1_LSP:
 	case ISIS_PDU_L2_LSP:
-	    printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
+	    ND_PRINT((ndo, ", lsp-id %s, seq 0x%08x, lifetime %5us",
 		   isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
 		   EXTRACT_32BITS(header_lsp->sequence_number),
-		   EXTRACT_16BITS(header_lsp->remaining_lifetime));
+		   EXTRACT_16BITS(header_lsp->remaining_lifetime)));
 	    break;
 	case ISIS_PDU_L1_CSNP:
 	case ISIS_PDU_L2_CSNP:
-	    printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN));
+	    ND_PRINT((ndo, ", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN)));
 	    break;
 	case ISIS_PDU_L1_PSNP:
 	case ISIS_PDU_L2_PSNP:
-	    printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN));
+	    ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN)));
 	    break;
 
 	}
-	printf(", length %u", length);
+	ND_PRINT((ndo, ", length %u", length));
 
         return(1);
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
-    printf("%slength %u", eflag ? "" : ", ",length);
+    ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
 
-    printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
+    ND_PRINT((ndo, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
            tok2str(isis_pdu_values,
                    "unknown, type %u",
                    pdu_type),
@@ -2228,10 +2216,10 @@
 	   id_length,
 	   isis_header->id_length,
            max_area,
-           isis_header->max_area);
+           isis_header->max_area));
 
-    if (vflag > 1) {
-        if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
+    if (ndo->ndo_vflag > 1) {
+        if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */
             return(0);                         /* for optionally debugging the common header */
     }
 
@@ -2240,8 +2228,8 @@
     case ISIS_PDU_L1_LAN_IIH:
     case ISIS_PDU_L2_LAN_IIH:
 	if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
-	    printf(", bogus fixed header length %u should be %lu",
-		   isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
+	    ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+		   isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE));
 	    return (0);
 	}
 
@@ -2251,23 +2239,23 @@
             length=pdu_len;
 	}
 
-	TCHECK(*header_iih_lan);
-	printf("\n\t  source-id: %s,  holding time: %us, Flags: [%s]",
+	ND_TCHECK(*header_iih_lan);
+	ND_PRINT((ndo, "\n\t  source-id: %s,  holding time: %us, Flags: [%s]",
                isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
                EXTRACT_16BITS(header_iih_lan->holding_time),
                tok2str(isis_iih_circuit_type_values,
                        "unknown circuit type 0x%02x",
-                       header_iih_lan->circuit_type));
+                       header_iih_lan->circuit_type)));
 
-	printf("\n\t  lan-id:    %s, Priority: %u, PDU length: %u",
+	ND_PRINT((ndo, "\n\t  lan-id:    %s, Priority: %u, PDU length: %u",
                isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
                (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
-               pdu_len);
+               pdu_len));
 
-        if (vflag > 1) {
-            if(!print_unknown_data(pptr,"\n\t  ",ISIS_IIH_LAN_HEADER_SIZE))
-                return(0);
-        }
+	if (ndo->ndo_vflag > 1) {
+		if (!print_unknown_data(ndo, pptr, "\n\t  ", ISIS_IIH_LAN_HEADER_SIZE))
+			return(0);
+	}
 
 	packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
 	pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
@@ -2275,8 +2263,8 @@
 
     case ISIS_PDU_PTP_IIH:
 	if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
-	    printf(", bogus fixed header length %u should be %lu",
-		   isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
+	    ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+		   isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE));
 	    return (0);
 	}
 
@@ -2286,22 +2274,22 @@
             length=pdu_len;
 	}
 
-	TCHECK(*header_iih_ptp);
-	printf("\n\t  source-id: %s, holding time: %us, Flags: [%s]",
+	ND_TCHECK(*header_iih_ptp);
+	ND_PRINT((ndo, "\n\t  source-id: %s, holding time: %us, Flags: [%s]",
                isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
                EXTRACT_16BITS(header_iih_ptp->holding_time),
                tok2str(isis_iih_circuit_type_values,
                        "unknown circuit type 0x%02x",
-                       header_iih_ptp->circuit_type));
+                       header_iih_ptp->circuit_type)));
 
-	printf("\n\t  circuit-id: 0x%02x, PDU length: %u",
+	ND_PRINT((ndo, "\n\t  circuit-id: 0x%02x, PDU length: %u",
                header_iih_ptp->circuit_id,
-               pdu_len);
+               pdu_len));
 
-        if (vflag > 1) {
-            if(!print_unknown_data(pptr,"\n\t  ",ISIS_IIH_PTP_HEADER_SIZE))
-                return(0);
-        }
+	if (ndo->ndo_vflag > 1) {
+		if (!print_unknown_data(ndo, pptr, "\n\t  ", ISIS_IIH_PTP_HEADER_SIZE))
+			return(0);
+	}
 
 	packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
 	pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
@@ -2310,8 +2298,8 @@
     case ISIS_PDU_L1_LSP:
     case ISIS_PDU_L2_LSP:
 	if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
-	    printf(", bogus fixed header length %u should be %lu",
-		   isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
+	    ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+		   isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE));
 	    return (0);
 	}
 
@@ -2321,15 +2309,15 @@
             length=pdu_len;
 	}
 
-	TCHECK(*header_lsp);
-	printf("\n\t  lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t  chksum: 0x%04x",
+	ND_TCHECK(*header_lsp);
+	ND_PRINT((ndo, "\n\t  lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t  chksum: 0x%04x",
                isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
                EXTRACT_32BITS(header_lsp->sequence_number),
                EXTRACT_16BITS(header_lsp->remaining_lifetime),
-               EXTRACT_16BITS(header_lsp->checksum));
+               EXTRACT_16BITS(header_lsp->checksum)));
 
 
-        osi_print_cksum((u_int8_t *)header_lsp->lsp_id,
+        osi_print_cksum(ndo, (uint8_t *)header_lsp->lsp_id,
                         EXTRACT_16BITS(header_lsp->checksum), 12, length-12);
 
         /*
@@ -2339,26 +2327,27 @@
         header_lsp->checksum[1] = 0;
         header_lsp->remaining_lifetime[0] = 0;
         header_lsp->remaining_lifetime[1] = 0;
-        
 
-	printf(", PDU length: %u, Flags: [ %s",
+
+	ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s",
                pdu_len,
-               ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "");
+               ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""));
 
 	if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
-	    printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : "");
-	    printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : "");
-	    printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : "");
-	    printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : "");
-	    printf("ATT bit set, ");
+	    ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""));
+	    ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""));
+	    ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""));
+	    ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""));
+	    ND_PRINT((ndo, "ATT bit set, "));
 	}
-	printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "");
-	printf("%s ]", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)));
+	ND_PRINT((ndo, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""));
+	ND_PRINT((ndo, "%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)",
+	          ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))));
 
-        if (vflag > 1) {
-            if(!print_unknown_data(pptr,"\n\t  ",ISIS_LSP_HEADER_SIZE))
-                return(0);
-        }
+	if (ndo->ndo_vflag > 1) {
+		if (!print_unknown_data(ndo, pptr, "\n\t  ", ISIS_LSP_HEADER_SIZE))
+			return(0);
+	}
 
 	packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
 	pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
@@ -2367,8 +2356,8 @@
     case ISIS_PDU_L1_CSNP:
     case ISIS_PDU_L2_CSNP:
 	if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
-	    printf(", bogus fixed header length %u should be %lu",
-		   isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
+	    ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+		   isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE));
 	    return (0);
 	}
 
@@ -2378,19 +2367,19 @@
             length=pdu_len;
 	}
 
-	TCHECK(*header_csnp);
-	printf("\n\t  source-id:    %s, PDU length: %u",
+	ND_TCHECK(*header_csnp);
+	ND_PRINT((ndo, "\n\t  source-id:    %s, PDU length: %u",
                isis_print_id(header_csnp->source_id, NODE_ID_LEN),
-               pdu_len);
-	printf("\n\t  start lsp-id: %s",
-               isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN));
-	printf("\n\t  end lsp-id:   %s",
-               isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN));
+               pdu_len));
+	ND_PRINT((ndo, "\n\t  start lsp-id: %s",
+               isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN)));
+	ND_PRINT((ndo, "\n\t  end lsp-id:   %s",
+               isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN)));
 
-        if (vflag > 1) {
-            if(!print_unknown_data(pptr,"\n\t  ",ISIS_CSNP_HEADER_SIZE))
-                return(0);
-        }
+	if (ndo->ndo_vflag > 1) {
+		if (!print_unknown_data(ndo, pptr, "\n\t  ", ISIS_CSNP_HEADER_SIZE))
+			return(0);
+	}
 
 	packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
 	pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
@@ -2399,8 +2388,8 @@
     case ISIS_PDU_L1_PSNP:
     case ISIS_PDU_L2_PSNP:
 	if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
-	    printf("- bogus fixed header length %u should be %lu",
-		   isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
+	    ND_PRINT((ndo, "- bogus fixed header length %u should be %lu",
+		   isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE));
 	    return (0);
 	}
 
@@ -2410,23 +2399,22 @@
             length=pdu_len;
 	}
 
-	TCHECK(*header_psnp);
-	printf("\n\t  source-id:    %s, PDU length: %u",
+	ND_TCHECK(*header_psnp);
+	ND_PRINT((ndo, "\n\t  source-id:    %s, PDU length: %u",
                isis_print_id(header_psnp->source_id, NODE_ID_LEN),
-               pdu_len);
+               pdu_len));
 
-        if (vflag > 1) {
-            if(!print_unknown_data(pptr,"\n\t  ",ISIS_PSNP_HEADER_SIZE))
-                return(0);
-        }
+	if (ndo->ndo_vflag > 1) {
+		if (!print_unknown_data(ndo, pptr, "\n\t  ", ISIS_PSNP_HEADER_SIZE))
+			return(0);
+	}
 
 	packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
 	pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
 	break;
 
     default:
-	if(!print_unknown_data(pptr,"\n\t  ",length))
-	    return(0);
+	(void)print_unknown_data(ndo, pptr, "\n\t  ", length);
 	return (0);
     }
 
@@ -2435,13 +2423,13 @@
      */
 
     while (packet_len >= 2) {
-        if (pptr == snapend) {
-	    return (1);
+        if (pptr == ndo->ndo_snapend) {
+            return (1);
         }
 
-	if (!TTEST2(*pptr, 2)) {
-	    printf("\n\t\t packet exceeded snapshot (%ld) bytes",
-                   (long)(pptr-snapend));
+	if (!ND_TTEST2(*pptr, 2)) {
+	    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot (%ld) bytes",
+                   (long)(pptr - ndo->ndo_snapend)));
 	    return (1);
 	}
 	tlv_type = *pptr++;
@@ -2454,12 +2442,12 @@
 	}
 
         /* first lets see if we know the TLVs name*/
-	printf("\n\t    %s TLV #%u, length: %u",
+	ND_PRINT((ndo, "\n\t    %s TLV #%u, length: %u",
                tok2str(isis_tlv_values,
                        "unknown",
                        tlv_type),
                tlv_type,
-               tlv_len);
+               tlv_len));
 
         if (tlv_len == 0) /* something is malformed */
 	    continue;
@@ -2467,46 +2455,46 @@
         /* now check if we have a decoder otherwise do a hexdump at the end*/
 	switch (tlv_type) {
 	case ISIS_TLV_AREA_ADDR:
-	    if (!TTEST2(*tptr, 1))
+	    if (!ND_TTEST2(*tptr, 1))
 		goto trunctlv;
 	    alen = *tptr++;
 	    while (tmp && alen < tmp) {
-		printf("\n\t      Area address (length: %u): %s",
+		ND_PRINT((ndo, "\n\t      Area address (length: %u): %s",
                        alen,
-                       isonsap_string(tptr,alen));
+                       isonsap_string(tptr, alen)));
 		tptr += alen;
 		tmp -= alen + 1;
 		if (tmp==0) /* if this is the last area address do not attemt a boundary check */
                     break;
-		if (!TTEST2(*tptr, 1))
+		if (!ND_TTEST2(*tptr, 1))
 		    goto trunctlv;
 		alen = *tptr++;
 	    }
 	    break;
 	case ISIS_TLV_ISNEIGH:
 	    while (tmp >= ETHER_ADDR_LEN) {
-                if (!TTEST2(*tptr, ETHER_ADDR_LEN))
+                if (!ND_TTEST2(*tptr, ETHER_ADDR_LEN))
                     goto trunctlv;
-                printf("\n\t      SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
+                ND_PRINT((ndo, "\n\t      SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN)));
                 tmp -= ETHER_ADDR_LEN;
                 tptr += ETHER_ADDR_LEN;
 	    }
 	    break;
 
         case ISIS_TLV_ISNEIGH_VARLEN:
-            if (!TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
+            if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
 		goto trunctlv;
 	    lan_alen = *tptr++; /* LAN address length */
 	    if (lan_alen == 0) {
-                printf("\n\t      LAN address length 0 bytes (invalid)");
+                ND_PRINT((ndo, "\n\t      LAN address length 0 bytes (invalid)"));
                 break;
             }
             tmp --;
-            printf("\n\t      LAN address length %u bytes ",lan_alen);
+            ND_PRINT((ndo, "\n\t      LAN address length %u bytes ", lan_alen));
 	    while (tmp >= lan_alen) {
-                if (!TTEST2(*tptr, lan_alen))
+                if (!ND_TTEST2(*tptr, lan_alen))
                     goto trunctlv;
-                printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
+                ND_PRINT((ndo, "\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen)));
                 tmp -= lan_alen;
                 tptr +=lan_alen;
             }
@@ -2516,16 +2504,16 @@
 	    break;
 
         case ISIS_TLV_MT_IS_REACH:
-            mt_len = isis_print_mtid(tptr, "\n\t      ");
+            mt_len = isis_print_mtid(ndo, tptr, "\n\t      ");
             if (mt_len == 0) /* did something go wrong ? */
                 goto trunctlv;
             tptr+=mt_len;
             tmp-=mt_len;
             while (tmp >= 2+NODE_ID_LEN+3+1) {
-                ext_is_len = isis_print_ext_is_reach(tptr,"\n\t      ",tlv_type);
+                ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t      ", tlv_type);
                 if (ext_is_len == 0) /* did something go wrong ? */
                     goto trunctlv;
-                   
+
                 tmp-=ext_is_len;
                 tptr+=ext_is_len;
             }
@@ -2533,7 +2521,7 @@
 
         case ISIS_TLV_IS_ALIAS_ID:
 	    while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
-	        ext_is_len = isis_print_ext_is_reach(tptr,"\n\t      ",tlv_type);
+	        ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t      ", tlv_type);
 		if (ext_is_len == 0) /* did something go wrong ? */
 	            goto trunctlv;
 		tmp-=ext_is_len;
@@ -2543,27 +2531,27 @@
 
         case ISIS_TLV_EXT_IS_REACH:
             while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
-                ext_is_len = isis_print_ext_is_reach(tptr,"\n\t      ",tlv_type);
+                ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t      ", tlv_type);
                 if (ext_is_len == 0) /* did something go wrong ? */
-                    goto trunctlv;                   
+                    goto trunctlv;
                 tmp-=ext_is_len;
                 tptr+=ext_is_len;
             }
             break;
         case ISIS_TLV_IS_REACH:
-	    if (!TTEST2(*tptr,1))  /* check if there is one byte left to read out the virtual flag */
+	    if (!ND_TTEST2(*tptr,1))  /* check if there is one byte left to read out the virtual flag */
                 goto trunctlv;
-            printf("\n\t      %s",
+            ND_PRINT((ndo, "\n\t      %s",
                    tok2str(isis_is_reach_virtual_values,
                            "bogus virtual flag 0x%02x",
-                           *tptr++));
+                           *tptr++)));
 	    tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
             while (tmp >= sizeof(struct isis_tlv_is_reach)) {
-		if (!TTEST(*tlv_is_reach))
+		if (!ND_TTEST(*tlv_is_reach))
 		    goto trunctlv;
-		printf("\n\t      IS Neighbor: %s",
-		       isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
-                isis_print_metric_block(&tlv_is_reach->isis_metric_block);
+		ND_PRINT((ndo, "\n\t      IS Neighbor: %s",
+		       isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN)));
+		isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
 		tmp -= sizeof(struct isis_tlv_is_reach);
 		tlv_is_reach++;
 	    }
@@ -2572,11 +2560,11 @@
         case ISIS_TLV_ESNEIGH:
 	    tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
             while (tmp >= sizeof(struct isis_tlv_es_reach)) {
-		if (!TTEST(*tlv_es_reach))
+		if (!ND_TTEST(*tlv_es_reach))
 		    goto trunctlv;
-		printf("\n\t      ES Neighbor: %s",
-                       isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
-                isis_print_metric_block(&tlv_es_reach->isis_metric_block);
+		ND_PRINT((ndo, "\n\t      ES Neighbor: %s",
+                       isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN)));
+		isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
 		tmp -= sizeof(struct isis_tlv_es_reach);
 		tlv_es_reach++;
 	    }
@@ -2585,13 +2573,13 @@
             /* those two TLVs share the same format */
 	case ISIS_TLV_INT_IP_REACH:
 	case ISIS_TLV_EXT_IP_REACH:
-	    if (!isis_print_tlv_ip_reach(pptr, "\n\t      ", tlv_len))
-		return (1);
-	    break;
+		if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t      ", tlv_len))
+			return (1);
+		break;
 
 	case ISIS_TLV_EXTD_IP_REACH:
 	    while (tmp>0) {
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET);
+                ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t      ", AF_INET);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
@@ -2600,7 +2588,7 @@
 	    break;
 
         case ISIS_TLV_MT_IP_REACH:
-            mt_len = isis_print_mtid(tptr, "\n\t      ");
+            mt_len = isis_print_mtid(ndo, tptr, "\n\t      ");
             if (mt_len == 0) { /* did something go wrong ? */
                 goto trunctlv;
             }
@@ -2608,7 +2596,7 @@
             tmp-=mt_len;
 
             while (tmp>0) {
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET);
+                ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t      ", AF_INET);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
@@ -2619,7 +2607,7 @@
 #ifdef INET6
 	case ISIS_TLV_IP6_REACH:
 	    while (tmp>0) {
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET6);
+                ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t      ", AF_INET6);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
@@ -2628,7 +2616,7 @@
 	    break;
 
 	case ISIS_TLV_MT_IP6_REACH:
-            mt_len = isis_print_mtid(tptr, "\n\t      ");
+            mt_len = isis_print_mtid(ndo, tptr, "\n\t      ");
             if (mt_len == 0) { /* did something go wrong ? */
                 goto trunctlv;
             }
@@ -2636,7 +2624,7 @@
             tmp-=mt_len;
 
 	    while (tmp>0) {
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET6);
+                ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t      ", AF_INET6);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
@@ -2646,11 +2634,11 @@
 
 	case ISIS_TLV_IP6ADDR:
 	    while (tmp>=sizeof(struct in6_addr)) {
-		if (!TTEST2(*tptr, sizeof(struct in6_addr)))
+		if (!ND_TTEST2(*tptr, sizeof(struct in6_addr)))
 		    goto trunctlv;
 
-                printf("\n\t      IPv6 interface address: %s",
-		       ip6addr_string(tptr));
+                ND_PRINT((ndo, "\n\t      IPv6 interface address: %s",
+		       ip6addr_string(ndo, tptr)));
 
 		tptr += sizeof(struct in6_addr);
 		tmp -= sizeof(struct in6_addr);
@@ -2658,52 +2646,52 @@
 	    break;
 #endif
 	case ISIS_TLV_AUTH:
-	    if (!TTEST2(*tptr, 1))
+	    if (!ND_TTEST2(*tptr, 1))
 		goto trunctlv;
 
-            printf("\n\t      %s: ",
+            ND_PRINT((ndo, "\n\t      %s: ",
                    tok2str(isis_subtlv_auth_values,
                            "unknown Authentication type 0x%02x",
-                           *tptr));
+                           *tptr)));
 
 	    switch (*tptr) {
 	    case ISIS_SUBTLV_AUTH_SIMPLE:
 		for(i=1;i<tlv_len;i++) {
-		    if (!TTEST2(*(tptr+i), 1))
+		    if (!ND_TTEST2(*(tptr + i), 1))
 			goto trunctlv;
-		    printf("%c",*(tptr+i));
+		    ND_PRINT((ndo, "%c", *(tptr + i)));
 		}
 		break;
 	    case ISIS_SUBTLV_AUTH_MD5:
 		for(i=1;i<tlv_len;i++) {
-		    if (!TTEST2(*(tptr+i), 1))
+		    if (!ND_TTEST2(*(tptr + i), 1))
 			goto trunctlv;
-		    printf("%02x",*(tptr+i));
+		    ND_PRINT((ndo, "%02x", *(tptr + i)));
 		}
 		if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
-                    printf(", (malformed subTLV) ");
+                    ND_PRINT((ndo, ", (malformed subTLV) "));
 
 #ifdef HAVE_LIBCRYPTO
-                sigcheck = signature_verify(optr, length,
+                sigcheck = signature_verify(ndo, optr, length,
                                             (unsigned char *)tptr + 1);
 #else
                 sigcheck = CANT_CHECK_SIGNATURE;
 #endif
-                printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+                ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
 
 		break;
             case ISIS_SUBTLV_AUTH_GENERIC:
                 key_id = EXTRACT_16BITS((tptr+1));
-                printf("%u, password: ", key_id); 
-                for(i=1 + sizeof(u_int16_t);i<tlv_len;i++) {
-                    if (!TTEST2(*(tptr+i), 1))
+                ND_PRINT((ndo, "%u, password: ", key_id));
+                for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
+                    if (!ND_TTEST2(*(tptr + i), 1))
                         goto trunctlv;
-                    printf("%02x",*(tptr+i));
+                    ND_PRINT((ndo, "%02x", *(tptr + i)));
                 }
                 break;
 	    case ISIS_SUBTLV_AUTH_PRIVATE:
 	    default:
-		if(!print_unknown_data(tptr+1,"\n\t\t  ",tlv_len-1))
+		if (!print_unknown_data(ndo, tptr + 1, "\n\t\t  ", tlv_len - 1))
 		    return(0);
 		break;
 	    }
@@ -2712,49 +2700,49 @@
 	case ISIS_TLV_PTP_ADJ:
 	    tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
 	    if(tmp>=1) {
-		if (!TTEST2(*tptr, 1))
+		if (!ND_TTEST2(*tptr, 1))
 		    goto trunctlv;
-		printf("\n\t      Adjacency State: %s (%u)",
+		ND_PRINT((ndo, "\n\t      Adjacency State: %s (%u)",
 		       tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
-                        *tptr);
+                        *tptr));
 		tmp--;
 	    }
 	    if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
-		if (!TTEST2(tlv_ptp_adj->extd_local_circuit_id,
+		if (!ND_TTEST2(tlv_ptp_adj->extd_local_circuit_id,
                             sizeof(tlv_ptp_adj->extd_local_circuit_id)))
 		    goto trunctlv;
-		printf("\n\t      Extended Local circuit-ID: 0x%08x",
-		       EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id));
+		ND_PRINT((ndo, "\n\t      Extended Local circuit-ID: 0x%08x",
+		       EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)));
 		tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
 	    }
 	    if(tmp>=SYSTEM_ID_LEN) {
-		if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
+		if (!ND_TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
 		    goto trunctlv;
-		printf("\n\t      Neighbor System-ID: %s",
-		       isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN));
+		ND_PRINT((ndo, "\n\t      Neighbor System-ID: %s",
+		       isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)));
 		tmp-=SYSTEM_ID_LEN;
 	    }
 	    if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
-		if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
+		if (!ND_TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
                             sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
 		    goto trunctlv;
-		printf("\n\t      Neighbor Extended Local circuit-ID: 0x%08x",
-		       EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id));
+		ND_PRINT((ndo, "\n\t      Neighbor Extended Local circuit-ID: 0x%08x",
+		       EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)));
 	    }
 	    break;
 
 	case ISIS_TLV_PROTOCOLS:
-	    printf("\n\t      NLPID(s): ");
+	    ND_PRINT((ndo, "\n\t      NLPID(s): "));
 	    while (tmp>0) {
-		if (!TTEST2(*(tptr), 1))
+		if (!ND_TTEST2(*(tptr), 1))
 		    goto trunctlv;
-		printf("%s (0x%02x)",
+		ND_PRINT((ndo, "%s (0x%02x)",
                        tok2str(nlpid_values,
                                "unknown",
                                *tptr),
-                       *tptr);
+                       *tptr));
 		if (tmp>1) /* further NPLIDs ? - put comma */
-		    printf(", ");
+		    ND_PRINT((ndo, ", "));
                 tptr++;
                 tmp--;
 	    }
@@ -2762,62 +2750,62 @@
 
     case ISIS_TLV_MT_PORT_CAP:
     {
-      if (!TTEST2(*(tptr), 2))
+      if (!ND_TTEST2(*(tptr), 2))
         goto trunctlv;
 
-      printf("\n\t       RES: %d, MTID(s): %d",
-              (EXTRACT_16BITS (tptr) >> 12),    
-              (EXTRACT_16BITS (tptr) & 0x0fff));
+      ND_PRINT((ndo, "\n\t       RES: %d, MTID(s): %d",
+              (EXTRACT_16BITS (tptr) >> 12),
+              (EXTRACT_16BITS (tptr) & 0x0fff)));
 
       tmp = tmp-2;
       tptr = tptr+2;
 
       if (tmp)
-        isis_print_mt_port_cap_subtlv (tptr, tmp);
+        isis_print_mt_port_cap_subtlv(ndo, tptr, tmp);
 
       break;
     }
 
     case ISIS_TLV_MT_CAPABILITY:
 
-      if (!TTEST2(*(tptr), 2))
+      if (!ND_TTEST2(*(tptr), 2))
         goto trunctlv;
 
-      printf("\n\t      O: %d, RES: %d, MTID(s): %d",
+      ND_PRINT((ndo, "\n\t      O: %d, RES: %d, MTID(s): %d",
                 (EXTRACT_16BITS(tptr) >> 15) & 0x01,
                 (EXTRACT_16BITS(tptr) >> 12) & 0x07,
-                EXTRACT_16BITS(tptr) & 0x0fff);
+                EXTRACT_16BITS(tptr) & 0x0fff));
 
       tmp = tmp-2;
       tptr = tptr+2;
 
       if (tmp)
-        isis_print_mt_capability_subtlv (tptr, tmp);
+        isis_print_mt_capability_subtlv(ndo, tptr, tmp);
 
       break;
 
 	case ISIS_TLV_TE_ROUTER_ID:
-	    if (!TTEST2(*pptr, sizeof(struct in_addr)))
+	    if (!ND_TTEST2(*pptr, sizeof(struct in_addr)))
 		goto trunctlv;
-	    printf("\n\t      Traffic Engineering Router ID: %s", ipaddr_string(pptr));
+	    ND_PRINT((ndo, "\n\t      Traffic Engineering Router ID: %s", ipaddr_string(ndo, pptr)));
 	    break;
 
 	case ISIS_TLV_IPADDR:
 	    while (tmp>=sizeof(struct in_addr)) {
-		if (!TTEST2(*tptr, sizeof(struct in_addr)))
+		if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
 		    goto trunctlv;
-		printf("\n\t      IPv4 interface address: %s", ipaddr_string(tptr));
+		ND_PRINT((ndo, "\n\t      IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
 		tptr += sizeof(struct in_addr);
 		tmp -= sizeof(struct in_addr);
 	    }
 	    break;
 
 	case ISIS_TLV_HOSTNAME:
-	    printf("\n\t      Hostname: ");
+	    ND_PRINT((ndo, "\n\t      Hostname: "));
 	    while (tmp>0) {
-		if (!TTEST2(*tptr, 1))
+		if (!ND_TTEST2(*tptr, 1))
 		    goto trunctlv;
-		printf("%c",*tptr++);
+		ND_PRINT((ndo, "%c", *tptr++));
                 tmp--;
 	    }
 	    break;
@@ -2825,39 +2813,39 @@
 	case ISIS_TLV_SHARED_RISK_GROUP:
 	    if (tmp < NODE_ID_LEN)
 	        break;
-	    if (!TTEST2(*tptr, NODE_ID_LEN))
+	    if (!ND_TTEST2(*tptr, NODE_ID_LEN))
                 goto trunctlv;
-	    printf("\n\t      IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
+	    ND_PRINT((ndo, "\n\t      IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN)));
 	    tptr+=(NODE_ID_LEN);
 	    tmp-=(NODE_ID_LEN);
 
 	    if (tmp < 1)
 	        break;
-	    if (!TTEST2(*tptr, 1))
+	    if (!ND_TTEST2(*tptr, 1))
                 goto trunctlv;
-	    printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered");
+	    ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"));
 	    tmp--;
 
 	    if (tmp < sizeof(struct in_addr))
 	        break;
-	    if (!TTEST2(*tptr,sizeof(struct in_addr)))
+	    if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
                 goto trunctlv;
-	    printf("\n\t      IPv4 interface address: %s", ipaddr_string(tptr));
+	    ND_PRINT((ndo, "\n\t      IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
 	    tptr+=sizeof(struct in_addr);
 	    tmp-=sizeof(struct in_addr);
 
 	    if (tmp < sizeof(struct in_addr))
 	        break;
-	    if (!TTEST2(*tptr,sizeof(struct in_addr)))
+	    if (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
                 goto trunctlv;
-	    printf("\n\t      IPv4 neighbor address: %s", ipaddr_string(tptr));
+	    ND_PRINT((ndo, "\n\t      IPv4 neighbor address: %s", ipaddr_string(ndo, tptr)));
 	    tptr+=sizeof(struct in_addr);
 	    tmp-=sizeof(struct in_addr);
 
 	    while (tmp>=4) {
-                if (!TTEST2(*tptr, 4))
+                if (!ND_TTEST2(*tptr, 4))
                     goto trunctlv;
-                printf("\n\t      Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
+                ND_PRINT((ndo, "\n\t      Link-ID: 0x%08x", EXTRACT_32BITS(tptr)));
                 tptr+=4;
                 tmp-=4;
 	    }
@@ -2866,19 +2854,19 @@
 	case ISIS_TLV_LSP:
 	    tlv_lsp = (const struct isis_tlv_lsp *)tptr;
 	    while(tmp>=sizeof(struct isis_tlv_lsp)) {
-		if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
+		if (!ND_TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
 		    goto trunctlv;
-		printf("\n\t      lsp-id: %s",
-                       isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
-		if (!TTEST2(tlv_lsp->sequence_number, 4))
+		ND_PRINT((ndo, "\n\t      lsp-id: %s",
+                       isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN)));
+		if (!ND_TTEST2(tlv_lsp->sequence_number, 4))
 		    goto trunctlv;
-		printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
-		if (!TTEST2(tlv_lsp->remaining_lifetime, 2))
+		ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number)));
+		if (!ND_TTEST2(tlv_lsp->remaining_lifetime, 2))
 		    goto trunctlv;
-		printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime));
-		if (!TTEST2(tlv_lsp->checksum, 2))
+		ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime)));
+		if (!ND_TTEST2(tlv_lsp->checksum, 2))
 		    goto trunctlv;
-		printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
+		ND_PRINT((ndo, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp->checksum)));
 		tmp-=sizeof(struct isis_tlv_lsp);
 		tlv_lsp++;
 	    }
@@ -2887,15 +2875,15 @@
 	case ISIS_TLV_CHECKSUM:
 	    if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
 	        break;
-	    if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
+	    if (!ND_TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
 		goto trunctlv;
-	    printf("\n\t      checksum: 0x%04x ", EXTRACT_16BITS(tptr));
+	    ND_PRINT((ndo, "\n\t      checksum: 0x%04x ", EXTRACT_16BITS(tptr)));
             /* do not attempt to verify the checksum if it is zero
              * most likely a HMAC-MD5 TLV is also present and
              * to avoid conflicts the checksum TLV is zeroed.
              * see rfc3358 for details
              */
-            osi_print_cksum(optr, EXTRACT_16BITS(tptr), tptr-optr, length);
+            osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr, length);
 	    break;
 
 	case ISIS_TLV_MT_SUPPORTED:
@@ -2905,13 +2893,13 @@
 		/* length can only be a multiple of 2, otherwise there is
 		   something broken -> so decode down until length is 1 */
 		if (tmp!=1) {
-                    mt_len = isis_print_mtid(tptr, "\n\t      ");
+                    mt_len = isis_print_mtid(ndo, tptr, "\n\t      ");
                     if (mt_len == 0) /* did something go wrong ? */
                         goto trunctlv;
                     tptr+=mt_len;
                     tmp-=mt_len;
 		} else {
-		    printf("\n\t      malformed MT-ID");
+		    ND_PRINT((ndo, "\n\t      malformed MT-ID"));
 		    break;
 		}
 	    }
@@ -2921,10 +2909,10 @@
             /* first attempt to decode the flags */
             if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
                 break;
-            if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
+            if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
                 goto trunctlv;
-            printf("\n\t      Flags [%s]",
-                   bittok2str(isis_restart_flag_values, "none", *tptr));
+            ND_PRINT((ndo, "\n\t      Flags [%s]",
+                   bittok2str(isis_restart_flag_values, "none", *tptr)));
             tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
             tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
 
@@ -2934,40 +2922,40 @@
 
             if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
                 break;
-            if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
+            if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
                 goto trunctlv;
 
-            printf(", Remaining holding time %us", EXTRACT_16BITS(tptr));
+            ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr)));
             tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
             tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
 
             /* is there an additional sysid field present ?*/
             if (tmp == SYSTEM_ID_LEN) {
-                    if (!TTEST2(*tptr, SYSTEM_ID_LEN))
+                    if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
                             goto trunctlv;
-                    printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN));
-            } 
+                    ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN)));
+            }
 	    break;
 
         case ISIS_TLV_IDRP_INFO:
 	    if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
 	        break;
-            if (!TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
+            if (!ND_TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
                 goto trunctlv;
-            printf("\n\t      Inter-Domain Information Type: %s",
+            ND_PRINT((ndo, "\n\t      Inter-Domain Information Type: %s",
                    tok2str(isis_subtlv_idrp_values,
                            "Unknown (0x%02x)",
-                           *tptr));
+                           *tptr)));
             switch (*tptr++) {
             case ISIS_SUBTLV_IDRP_ASN:
-                if (!TTEST2(*tptr, 2)) /* fetch AS number */
+                if (!ND_TTEST2(*tptr, 2)) /* fetch AS number */
                     goto trunctlv;
-                printf("AS Number: %u",EXTRACT_16BITS(tptr));
+                ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr)));
                 break;
             case ISIS_SUBTLV_IDRP_LOCAL:
             case ISIS_SUBTLV_IDRP_RES:
             default:
-                if(!print_unknown_data(tptr,"\n\t      ",tlv_len-1))
+                if (!print_unknown_data(ndo, tptr, "\n\t      ", tlv_len - 1))
                     return(0);
                 break;
             }
@@ -2976,16 +2964,16 @@
         case ISIS_TLV_LSP_BUFFERSIZE:
 	    if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
 	        break;
-            if (!TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
+            if (!ND_TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
                 goto trunctlv;
-            printf("\n\t      LSP Buffersize: %u",EXTRACT_16BITS(tptr));
+            ND_PRINT((ndo, "\n\t      LSP Buffersize: %u", EXTRACT_16BITS(tptr)));
             break;
 
         case ISIS_TLV_PART_DIS:
             while (tmp >= SYSTEM_ID_LEN) {
-                if (!TTEST2(*tptr, SYSTEM_ID_LEN))
+                if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
                     goto trunctlv;
-                printf("\n\t      %s",isis_print_id(tptr,SYSTEM_ID_LEN));
+                ND_PRINT((ndo, "\n\t      %s", isis_print_id(tptr, SYSTEM_ID_LEN)));
                 tptr+=SYSTEM_ID_LEN;
                 tmp-=SYSTEM_ID_LEN;
             }
@@ -2994,29 +2982,28 @@
         case ISIS_TLV_PREFIX_NEIGH:
 	    if (tmp < sizeof(struct isis_metric_block))
 	        break;
-            if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
+            if (!ND_TTEST2(*tptr, sizeof(struct isis_metric_block)))
                 goto trunctlv;
-            printf("\n\t      Metric Block");
-            isis_print_metric_block((const struct isis_metric_block *)tptr);
+            ND_PRINT((ndo, "\n\t      Metric Block"));
+            isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr);
             tptr+=sizeof(struct isis_metric_block);
             tmp-=sizeof(struct isis_metric_block);
 
             while(tmp>0) {
-                if (!TTEST2(*tptr, 1))
+                if (!ND_TTEST2(*tptr, 1))
                     goto trunctlv;
                 prefix_len=*tptr++; /* read out prefix length in semioctets*/
                 if (prefix_len < 2) {
-                    printf("\n\t\tAddress: prefix length %u < 2", prefix_len);
+                    ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
                     break;
                 }
                 tmp--;
                 if (tmp < prefix_len/2)
                     break;
-                if (!TTEST2(*tptr, prefix_len/2))
+                if (!ND_TTEST2(*tptr, prefix_len / 2))
                     goto trunctlv;
-                printf("\n\t\tAddress: %s/%u",
-                       isonsap_string(tptr,prefix_len/2),
-                       prefix_len*4);
+                ND_PRINT((ndo, "\n\t\tAddress: %s/%u",
+                       isonsap_string(tptr, prefix_len / 2), prefix_len * 4));
                 tptr+=prefix_len/2;
                 tmp-=prefix_len/2;
             }
@@ -3025,24 +3012,24 @@
         case ISIS_TLV_IIH_SEQNR:
 	    if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
 	        break;
-            if (!TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
+            if (!ND_TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
                 goto trunctlv;
-            printf("\n\t      Sequence number: %u", EXTRACT_32BITS(tptr) );
+            ND_PRINT((ndo, "\n\t      Sequence number: %u", EXTRACT_32BITS(tptr)));
             break;
 
         case ISIS_TLV_VENDOR_PRIVATE:
 	    if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN)
 	        break;
-            if (!TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */
+            if (!ND_TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */
                 goto trunctlv;
             vendor_id = EXTRACT_24BITS(tptr);
-            printf("\n\t      Vendor: %s (%u)",
-                   tok2str(oui_values,"Unknown",vendor_id),
-                   vendor_id);
+            ND_PRINT((ndo, "\n\t      Vendor: %s (%u)",
+                   tok2str(oui_values, "Unknown", vendor_id),
+                   vendor_id));
             tptr+=3;
             tmp-=3;
             if (tmp > 0) /* hexdump the rest */
-                if(!print_unknown_data(tptr,"\n\t\t",tmp))
+                if (!print_unknown_data(ndo, tptr, "\n\t\t", tmp))
                     return(0);
             break;
             /*
@@ -3057,51 +3044,68 @@
         case ISIS_TLV_NORTEL_PRIVATE2:
 
 	default:
-            if (vflag <= 1) {
-                if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
-                    return(0);
-            }
-	    break;
+		if (ndo->ndo_vflag <= 1) {
+			if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len))
+				return(0);
+		}
+		break;
 	}
         /* do we want to see an additionally hexdump ? */
-        if (vflag> 1) {
-	    if(!print_unknown_data(pptr,"\n\t      ",tlv_len))
-	        return(0);
-        }
+	if (ndo->ndo_vflag> 1) {
+		if (!print_unknown_data(ndo, pptr, "\n\t      ", tlv_len))
+			return(0);
+	}
 
 	pptr += tlv_len;
 	packet_len -= tlv_len;
     }
 
     if (packet_len != 0) {
-	printf("\n\t      %u straggler bytes", packet_len);
+	ND_PRINT((ndo, "\n\t      %u straggler bytes", packet_len));
     }
     return (1);
 
  trunc:
-    fputs("[|isis]", stdout);
+    ND_PRINT((ndo, "[|isis]"));
     return (1);
 
  trunctlv:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
     return(1);
 }
 
 static void
-osi_print_cksum (const u_int8_t *pptr, u_int16_t checksum,
+osi_print_cksum(netdissect_options *ndo,
+                const uint8_t *pptr, uint16_t checksum,
                     u_int checksum_offset, u_int length)
 {
-        u_int16_t calculated_checksum;
+        uint16_t calculated_checksum;
 
-        /* do not attempt to verify the checksum if it is zero */
-        if (!checksum) {
-                printf("(unverified)");
+        /* do not attempt to verify the checksum if it is zero,
+         * if the total length is nonsense,
+         * if the offset is nonsense,
+         * or the base pointer is not sane
+         */
+        if (!checksum
+            || length > ndo->ndo_snaplen
+            || checksum_offset > ndo->ndo_snaplen
+            || checksum_offset > length) {
+                ND_PRINT((ndo, "(unverified)"));
         } else {
+                unsigned char *truncated = "trunc";
+#if 0
+                printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen);
+                ND_TCHECK2(pptr, checksum_offset+length);
+#endif
                 calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
                 if (checksum == calculated_checksum) {
-                        printf(" (correct)");
+                        ND_PRINT((ndo, " (correct)"));
                 } else {
-                        printf(" (incorrect should be 0x%04x)", calculated_checksum);
+                        truncated = "incorrect";
+#if 0
+                        trunc:
+#endif
+                        ND_PRINT((ndo, " (%s should be 0x%04x)", truncated, calculated_checksum));
                 }
         }
 }
diff --git a/print-juniper.c b/print-juniper.c
index 1789fb5..e4bb77c 100644
--- a/print-juniper.c
+++ b/print-juniper.c
@@ -1,6 +1,6 @@
 /*     NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp        */
 
-/* 
+/*
  * 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
@@ -16,21 +16,17 @@
  */
 
 #ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.34 2007-08-29 02:31:44 mcr Exp $ (LBL)";
 #else
 __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
 #endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -87,8 +83,8 @@
     JUNIPER_EXT_TLV_IFD_MEDIATYPE = 3,
     JUNIPER_EXT_TLV_IFL_IDX = 4,
     JUNIPER_EXT_TLV_IFL_UNIT = 5,
-    JUNIPER_EXT_TLV_IFL_ENCAPS = 6, 
-    JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7,  
+    JUNIPER_EXT_TLV_IFL_ENCAPS = 6,
+    JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7,
     JUNIPER_EXT_TLV_TTP_IFL_ENCAPS = 8
 };
 
@@ -366,12 +362,12 @@
 };
 
 struct juniper_cookie_table_t {
-    u_int32_t pictype;		/* pic type */
-    u_int8_t  cookie_len;       /* cookie len */
+    uint32_t pictype;		/* pic type */
+    uint8_t  cookie_len;       /* cookie len */
     const char *s;		/* pic name */
 };
 
-static struct juniper_cookie_table_t juniper_cookie_table[] = {
+static const struct juniper_cookie_table_t juniper_cookie_table[] = {
 #ifdef DLT_JUNIPER_ATM1
     { DLT_JUNIPER_ATM1,  4, "ATM1"},
 #endif
@@ -409,17 +405,17 @@
 };
 
 struct juniper_l2info_t {
-    u_int32_t length;
-    u_int32_t caplen;
-    u_int32_t pictype;
-    u_int8_t direction;
-    u_int8_t header_len;
-    u_int8_t cookie_len;
-    u_int8_t cookie_type;
-    u_int8_t cookie[8];
-    u_int8_t bundle;
-    u_int16_t proto;
-    u_int8_t flags;
+    uint32_t length;
+    uint32_t caplen;
+    uint32_t pictype;
+    uint8_t direction;
+    uint8_t header_len;
+    uint8_t cookie_len;
+    uint8_t cookie_type;
+    uint8_t cookie[8];
+    uint8_t bundle;
+    uint16_t proto;
+    uint8_t flags;
 };
 
 #define LS_COOKIE_ID            0x54
@@ -446,52 +442,50 @@
     { 0, NULL}
 };
 
-int ip_heuristic_guess(register const u_char *, u_int);
-int juniper_ppp_heuristic_guess(register const u_char *, u_int);
-int juniper_read_tlv_value(const u_char *, u_int, u_int);
-static int juniper_parse_header (const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *);
+static int ip_heuristic_guess(netdissect_options *, register const u_char *, u_int);
+static int juniper_ppp_heuristic_guess(netdissect_options *, register const u_char *, u_int);
+static int juniper_parse_header(netdissect_options *, const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *);
 
 #ifdef DLT_JUNIPER_GGSN
 u_int
-juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ggsn_print(netdissect_options *ndo,
+                   const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
         struct juniper_ggsn_header {
-            u_int8_t svc_id;
-            u_int8_t flags_len;
-            u_int8_t proto;
-            u_int8_t flags;
-            u_int8_t vlan_id[2];
-            u_int8_t res[2];
+            uint8_t svc_id;
+            uint8_t flags_len;
+            uint8_t proto;
+            uint8_t flags;
+            uint8_t vlan_id[2];
+            uint8_t res[2];
         };
         const struct juniper_ggsn_header *gh;
 
         l2info.pictype = DLT_JUNIPER_GGSN;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         gh = (struct juniper_ggsn_header *)&l2info.cookie;
 
-        if (eflag) {
-            printf("proto %s (%u), vlan %u: ",
+        if (ndo->ndo_eflag) {
+            ND_PRINT((ndo, "proto %s (%u), vlan %u: ",
                    tok2str(juniper_protocol_values,"Unknown",gh->proto),
                    gh->proto,
-                   EXTRACT_16BITS(&gh->vlan_id[0]));
+                   EXTRACT_16BITS(&gh->vlan_id[0])));
         }
 
         switch (gh->proto) {
         case JUNIPER_PROTO_IPV4:
-            ip_print(gndo, p, l2info.length);
+            ip_print(ndo, p, l2info.length);
             break;
-#ifdef INET6
         case JUNIPER_PROTO_IPV6:
-            ip6_print(gndo, p, l2info.length);
+            ip6_print(ndo, p, l2info.length);
             break;
-#endif /* INET6 */
         default:
-            if (!eflag)
-                printf("unknown GGSN proto (%u)", gh->proto);
+            if (!ndo->ndo_eflag)
+                ND_PRINT((ndo, "unknown GGSN proto (%u)", gh->proto));
         }
 
         return l2info.header_len;
@@ -500,22 +494,23 @@
 
 #ifdef DLT_JUNIPER_ES
 u_int
-juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_es_print(netdissect_options *ndo,
+                 const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
         struct juniper_ipsec_header {
-            u_int8_t sa_index[2];
-            u_int8_t ttl;
-            u_int8_t type;
-            u_int8_t spi[4];
-            u_int8_t src_ip[4];
-            u_int8_t dst_ip[4];
+            uint8_t sa_index[2];
+            uint8_t ttl;
+            uint8_t type;
+            uint8_t spi[4];
+            uint8_t src_ip[4];
+            uint8_t dst_ip[4];
         };
         u_int rewrite_len,es_type_bundle;
         const struct juniper_ipsec_header *ih;
 
         l2info.pictype = DLT_JUNIPER_ES;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
@@ -532,70 +527,72 @@
         case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE:
             rewrite_len = 16;
             es_type_bundle = 0;
+            break;
         default:
-            printf("ES Invalid type %u, length %u",
+            ND_PRINT((ndo, "ES Invalid type %u, length %u",
                    ih->type,
-                   l2info.length);
+                   l2info.length));
             return l2info.header_len;
         }
 
         l2info.length-=rewrite_len;
         p+=rewrite_len;
 
-        if (eflag) {
+        if (ndo->ndo_eflag) {
             if (!es_type_bundle) {
-                printf("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n", 
+                ND_PRINT((ndo, "ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
                        EXTRACT_16BITS(&ih->sa_index),
-                       ih->ttl, 
+                       ih->ttl,
                        tok2str(juniper_ipsec_type_values,"Unknown",ih->type),
                        ih->type,
                        EXTRACT_32BITS(&ih->spi),
-                       ipaddr_string(&ih->src_ip),
-                       ipaddr_string(&ih->dst_ip),
-                       l2info.length);
+                       ipaddr_string(ndo, &ih->src_ip),
+                       ipaddr_string(ndo, &ih->dst_ip),
+                       l2info.length));
             } else {
-                printf("ES SA, index %u, ttl %u type %s (%u), length %u\n", 
+                ND_PRINT((ndo, "ES SA, index %u, ttl %u type %s (%u), length %u\n",
                        EXTRACT_16BITS(&ih->sa_index),
-                       ih->ttl, 
+                       ih->ttl,
                        tok2str(juniper_ipsec_type_values,"Unknown",ih->type),
                        ih->type,
-                       l2info.length);
+                       l2info.length));
             }
         }
 
-        ip_print(gndo, p, l2info.length);
+        ip_print(ndo, p, l2info.length);
         return l2info.header_len;
 }
 #endif
 
 #ifdef DLT_JUNIPER_MONITOR
 u_int
-juniper_monitor_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_monitor_print(netdissect_options *ndo,
+                      const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
         struct juniper_monitor_header {
-            u_int8_t pkt_type;
-            u_int8_t padding;
-            u_int8_t iif[2];
-            u_int8_t service_id[4];
+            uint8_t pkt_type;
+            uint8_t padding;
+            uint8_t iif[2];
+            uint8_t service_id[4];
         };
         const struct juniper_monitor_header *mh;
 
         l2info.pictype = DLT_JUNIPER_MONITOR;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         mh = (struct juniper_monitor_header *)p;
 
-        if (eflag)
-            printf("service-id %u, iif %u, pkt-type %u: ",
+        if (ndo->ndo_eflag)
+            ND_PRINT((ndo, "service-id %u, iif %u, pkt-type %u: ",
                    EXTRACT_32BITS(&mh->service_id),
                    EXTRACT_16BITS(&mh->iif),
-                   mh->pkt_type);
+                   mh->pkt_type));
 
         /* no proto field - lets guess by first byte of IP header*/
-        ip_heuristic_guess(p, l2info.length);
+        ip_heuristic_guess (ndo, p, l2info.length);
 
         return l2info.header_len;
 }
@@ -603,33 +600,34 @@
 
 #ifdef DLT_JUNIPER_SERVICES
 u_int
-juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_services_print(netdissect_options *ndo,
+                       const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
         struct juniper_services_header {
-            u_int8_t svc_id;
-            u_int8_t flags_len;
-            u_int8_t svc_set_id[2];
-            u_int8_t dir_iif[4];
+            uint8_t svc_id;
+            uint8_t flags_len;
+            uint8_t svc_set_id[2];
+            uint8_t dir_iif[4];
         };
         const struct juniper_services_header *sh;
 
         l2info.pictype = DLT_JUNIPER_SERVICES;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         sh = (struct juniper_services_header *)p;
 
-        if (eflag)
-            printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
+        if (ndo->ndo_eflag)
+            ND_PRINT((ndo, "service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
                    sh->svc_id,
                    sh->flags_len,
                    EXTRACT_16BITS(&sh->svc_set_id),
-                   EXTRACT_24BITS(&sh->dir_iif[1]));
+                   EXTRACT_24BITS(&sh->dir_iif[1])));
 
         /* no proto field - lets guess by first byte of IP header*/
-        ip_heuristic_guess(p, l2info.length);
+        ip_heuristic_guess (ndo, p, l2info.length);
 
         return l2info.header_len;
 }
@@ -637,98 +635,104 @@
 
 #ifdef DLT_JUNIPER_PPPOE
 u_int
-juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_pppoe_print(netdissect_options *ndo,
+                    const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_PPPOE;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         /* this DLT contains nothing but raw ethernet frames */
-        ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+        ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
         return l2info.header_len;
 }
 #endif
 
 #ifdef DLT_JUNIPER_ETHER
 u_int
-juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ether_print(netdissect_options *ndo,
+                    const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_ETHER;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         /* this DLT contains nothing but raw Ethernet frames */
-        ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+        ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
         return l2info.header_len;
 }
 #endif
 
 #ifdef DLT_JUNIPER_PPP
 u_int
-juniper_ppp_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ppp_print(netdissect_options *ndo,
+                  const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_PPP;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         /* this DLT contains nothing but raw ppp frames */
-        ppp_print(p, l2info.length);
+        ppp_print(ndo, p, l2info.length);
         return l2info.header_len;
 }
 #endif
 
 #ifdef DLT_JUNIPER_FRELAY
 u_int
-juniper_frelay_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_frelay_print(netdissect_options *ndo,
+                     const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_FRELAY;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         /* this DLT contains nothing but raw frame-relay frames */
-        fr_print(p, l2info.length);
+        fr_print(ndo, p, l2info.length);
         return l2info.header_len;
 }
 #endif
 
 #ifdef DLT_JUNIPER_CHDLC
 u_int
-juniper_chdlc_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_chdlc_print(netdissect_options *ndo,
+                    const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_CHDLC;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
         /* this DLT contains nothing but raw c-hdlc frames */
-        chdlc_print(p, l2info.length);
+        chdlc_print(ndo, p, l2info.length);
         return l2info.header_len;
 }
 #endif
 
 #ifdef DLT_JUNIPER_PPPOE_ATM
 u_int
-juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_pppoe_atm_print(netdissect_options *ndo,
+                        const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
-	u_int16_t extracted_ethertype;
+	uint16_t extracted_ethertype;
 
         l2info.pictype = DLT_JUNIPER_PPPOE_ATM;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
@@ -736,33 +740,34 @@
         extracted_ethertype = EXTRACT_16BITS(p);
         /* this DLT contains nothing but raw PPPoE frames,
          * prepended with a type field*/
-        if (ethertype_print(gndo, extracted_ethertype,
+        if (ethertype_print(ndo, extracted_ethertype,
                               p+ETHERTYPE_LEN,
                               l2info.length-ETHERTYPE_LEN,
                               l2info.caplen-ETHERTYPE_LEN) == 0)
             /* ether_type not known, probably it wasn't one */
-            printf("unknown ethertype 0x%04x", extracted_ethertype);
-        
+            ND_PRINT((ndo, "unknown ethertype 0x%04x", extracted_ethertype));
+
         return l2info.header_len;
 }
 #endif
 
 #ifdef DLT_JUNIPER_MLPPP
 u_int
-juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mlppp_print(netdissect_options *ndo,
+                    const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_MLPPP;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         /* suppress Bundle-ID if frame was captured on a child-link
          * best indicator if the cookie looks like a proto */
-        if (eflag &&
+        if (ndo->ndo_eflag &&
             EXTRACT_16BITS(&l2info.cookie) != PPP_OSI &&
             EXTRACT_16BITS(&l2info.cookie) !=  (PPP_ADDRESS << 8 | PPP_CONTROL))
-            printf("Bundle-ID %u: ",l2info.bundle);
+            ND_PRINT((ndo, "Bundle-ID %u: ", l2info.bundle));
 
         p+=l2info.header_len;
 
@@ -773,20 +778,18 @@
              * -> this must be incoming IS-IS over PPP
              */
             if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR))
-                ppp_print(p, l2info.length);
+                ppp_print(ndo, p, l2info.length);
             else
-                ip_print(gndo, p, l2info.length);
+                ip_print(ndo, p, l2info.length);
             return l2info.header_len;
-#ifdef INET6
         case JUNIPER_LSQ_L3_PROTO_IPV6:
-            ip6_print(gndo, p,l2info.length);
+            ip6_print(ndo, p,l2info.length);
             return l2info.header_len;
-#endif
         case JUNIPER_LSQ_L3_PROTO_MPLS:
-            mpls_print(p,l2info.length);
+            mpls_print(ndo, p, l2info.length);
             return l2info.header_len;
         case JUNIPER_LSQ_L3_PROTO_ISO:
-            isoclns_print(p,l2info.length,l2info.caplen);
+            isoclns_print(ndo, p, l2info.length, l2info.caplen);
             return l2info.header_len;
         default:
             break;
@@ -795,11 +798,11 @@
         /* zero length cookie ? */
         switch (EXTRACT_16BITS(&l2info.cookie)) {
         case PPP_OSI:
-            ppp_print(p-2,l2info.length+2);
+            ppp_print(ndo, p - 2, l2info.length + 2);
             break;
         case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */
         default:
-            ppp_print(p,l2info.length);
+            ppp_print(ndo, p, l2info.length);
             break;
         }
 
@@ -810,19 +813,20 @@
 
 #ifdef DLT_JUNIPER_MFR
 u_int
-juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mfr_print(netdissect_options *ndo,
+                  const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_MFR;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
-        
+
         p+=l2info.header_len;
 
         /* child-link ? */
         if (l2info.cookie_len == 0) {
-            mfr_print(p,l2info.length);
+            mfr_print(ndo, p, l2info.length);
             return l2info.header_len;
         }
 
@@ -830,18 +834,16 @@
         if (l2info.cookie_len == AS_PIC_COOKIE_LEN) {
             switch(l2info.proto) {
             case JUNIPER_LSQ_L3_PROTO_IPV4:
-                ip_print(gndo, p, l2info.length);
+                ip_print(ndo, p, l2info.length);
                 return l2info.header_len;
-#ifdef INET6
             case JUNIPER_LSQ_L3_PROTO_IPV6:
-                ip6_print(gndo, p,l2info.length);
+                ip6_print(ndo, p,l2info.length);
                 return l2info.header_len;
-#endif
             case JUNIPER_LSQ_L3_PROTO_MPLS:
-                mpls_print(p,l2info.length);
+                mpls_print(ndo, p, l2info.length);
                 return l2info.header_len;
             case JUNIPER_LSQ_L3_PROTO_ISO:
-                isoclns_print(p,l2info.length,l2info.caplen);
+                isoclns_print(ndo, p, l2info.length, l2info.caplen);
                 return l2info.header_len;
             default:
                 break;
@@ -850,19 +852,20 @@
         }
 
         /* suppress Bundle-ID if frame was captured on a child-link */
-        if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle);
+        if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)
+            ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle));
         switch (l2info.proto) {
         case (LLCSAP_ISONS<<8 | LLCSAP_ISONS):
-            isoclns_print(p+1, l2info.length-1, l2info.caplen-1);
+            isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
             break;
         case (LLC_UI<<8 | NLPID_Q933):
         case (LLC_UI<<8 | NLPID_IP):
         case (LLC_UI<<8 | NLPID_IP6):
             /* pass IP{4,6} to the OSI layer for proper link-layer printing */
-            isoclns_print(p-1, l2info.length+1, l2info.caplen+1); 
+            isoclns_print(ndo, p - 1, l2info.length + 1, l2info.caplen + 1);
             break;
         default:
-            printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length);
+            ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length));
         }
 
         return l2info.header_len;
@@ -871,31 +874,33 @@
 
 #ifdef DLT_JUNIPER_MLFR
 u_int
-juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mlfr_print(netdissect_options *ndo,
+                   const struct pcap_pkthdr *h, register const u_char *p)
 {
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_MLFR;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
 
         /* suppress Bundle-ID if frame was captured on a child-link */
-        if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle);
+        if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)
+            ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle));
         switch (l2info.proto) {
         case (LLC_UI):
         case (LLC_UI<<8):
-            isoclns_print(p, l2info.length, l2info.caplen);
+            isoclns_print(ndo, p, l2info.length, l2info.caplen);
             break;
         case (LLC_UI<<8 | NLPID_Q933):
         case (LLC_UI<<8 | NLPID_IP):
         case (LLC_UI<<8 | NLPID_IP6):
             /* pass IP{4,6} to the OSI layer for proper link-layer printing */
-            isoclns_print(p-1, l2info.length+1, l2info.caplen+1);
+            isoclns_print(ndo, p - 1, l2info.length + 1, l2info.caplen + 1);
             break;
         default:
-            printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length);
+            ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length));
         }
 
         return l2info.header_len;
@@ -912,38 +917,39 @@
 
 #ifdef DLT_JUNIPER_ATM1
 u_int
-juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_atm1_print(netdissect_options *ndo,
+                   const struct pcap_pkthdr *h, register const u_char *p)
 {
-        u_int16_t extracted_ethertype;
+        uint16_t extracted_ethertype;
 
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_ATM1;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
 
         if (l2info.cookie[0] == 0x80) { /* OAM cell ? */
-            oam_print(p,l2info.length,ATM_OAM_NOHEC);
+            oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
             return l2info.header_len;
         }
 
         if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
             EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
 
-            if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL,
+            if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL,
                           &extracted_ethertype) != 0)
                 return l2info.header_len;
         }
 
         if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
-            isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1);
+            isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
             /* FIXME check if frame was recognized */
             return l2info.header_len;
         }
 
-        if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */
+        if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */
             return l2info.header_len;
 
 	return l2info.header_len;
@@ -960,47 +966,48 @@
 
 #ifdef DLT_JUNIPER_ATM2
 u_int
-juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_atm2_print(netdissect_options *ndo,
+                   const struct pcap_pkthdr *h, register const u_char *p)
 {
-        u_int16_t extracted_ethertype;
+        uint16_t extracted_ethertype;
 
         struct juniper_l2info_t l2info;
 
         l2info.pictype = DLT_JUNIPER_ATM2;
-        if(juniper_parse_header(p, h, &l2info) == 0)
+        if (juniper_parse_header(ndo, p, h, &l2info) == 0)
             return l2info.header_len;
 
         p+=l2info.header_len;
 
         if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */
-            oam_print(p,l2info.length,ATM_OAM_NOHEC);
+            oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
             return l2info.header_len;
         }
 
         if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
             EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
 
-            if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL,
+            if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL,
                           &extracted_ethertype) != 0)
                 return l2info.header_len;
         }
 
         if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
             (EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
-            ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+            ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
             return l2info.header_len;
         }
 
         if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
-            isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1);
+            isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
             /* FIXME check if frame was recognized */
             return l2info.header_len;
         }
 
-        if(juniper_ppp_heuristic_guess(p, l2info.length) != 0) /* PPPoA vcmux encaps ? */
+        if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) /* PPPoA vcmux encaps ? */
             return l2info.header_len;
 
-        if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */
+        if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */
             return l2info.header_len;
 
 	return l2info.header_len;
@@ -1010,9 +1017,10 @@
 
 /* try to guess, based on all PPP protos that are supported in
  * a juniper router if the payload data is encapsulated using PPP */
-int
-juniper_ppp_heuristic_guess(register const u_char *p, u_int length) {
-
+static int
+juniper_ppp_heuristic_guess(netdissect_options *ndo,
+                            register const u_char *p, u_int length)
+{
     switch(EXTRACT_16BITS(p)) {
     case PPP_IP :
     case PPP_OSI :
@@ -1029,7 +1037,7 @@
     case PPP_IPV6 :
     case PPP_IPV6CP :
 #endif
-        ppp_print(p, length);
+        ppp_print(ndo, p, length);
         break;
 
     default:
@@ -1039,9 +1047,10 @@
     return 1; /* we printed a ppp packet */
 }
 
-int
-ip_heuristic_guess(register const u_char *p, u_int length) {
-
+static int
+ip_heuristic_guess(netdissect_options *ndo,
+                   register const u_char *p, u_int length)
+{
     switch(p[0]) {
     case 0x45:
     case 0x46:
@@ -1054,9 +1063,8 @@
     case 0x4d:
     case 0x4e:
     case 0x4f:
-	    ip_print(gndo, p, length);
+	    ip_print(ndo, p, length);
 	    break;
-#ifdef INET6
     case 0x60:
     case 0x61:
     case 0x62:
@@ -1073,9 +1081,8 @@
     case 0x6d:
     case 0x6e:
     case 0x6f:
-        ip6_print(gndo, p, length);
+        ip6_print(ndo, p, length);
         break;
-#endif
     default:
         return 0; /* did not find a ip header */
         break;
@@ -1083,9 +1090,9 @@
     return 1; /* we printed an v4/v6 packet */
 }
 
-int
-juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) {
-
+static int
+juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len)
+{
    int tlv_value;
 
    /* TLVs < 128 are little endian encoded */
@@ -1131,12 +1138,13 @@
 }
 
 static int
-juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) {
-
-    struct juniper_cookie_table_t *lp = juniper_cookie_table;
+juniper_parse_header(netdissect_options *ndo,
+                     const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info)
+{
+    const struct juniper_cookie_table_t *lp = juniper_cookie_table;
     u_int idx, jnx_ext_len, jnx_header_len = 0;
-    u_int8_t tlv_type,tlv_len;
-    u_int32_t control_word;
+    uint8_t tlv_type,tlv_len;
+    uint32_t control_word;
     int tlv_value;
     const u_char *tptr;
 
@@ -1148,24 +1156,24 @@
 
     l2info->length = h->len;
     l2info->caplen = h->caplen;
-    TCHECK2(p[0],4);
+    ND_TCHECK2(p[0], 4);
     l2info->flags = p[3];
     l2info->direction = p[3]&JUNIPER_BPF_PKT_IN;
-    
-    if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */
-        printf("no magic-number found!");
-        return 0;
-    } 
 
-    if (eflag) /* print direction */
-        printf("%3s ",tok2str(juniper_direction_values,"---",l2info->direction));
+    if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */
+        ND_PRINT((ndo, "no magic-number found!"));
+        return 0;
+    }
+
+    if (ndo->ndo_eflag) /* print direction */
+        ND_PRINT((ndo, "%3s ", tok2str(juniper_direction_values, "---", l2info->direction)));
 
     /* magic number + flags */
     jnx_header_len = 4;
 
-    if (vflag>1)
-        printf("\n\tJuniper PCAP Flags [%s]",
-               bittok2str(jnx_flag_values, "none", l2info->flags));
+    if (ndo->ndo_vflag > 1)
+        ND_PRINT((ndo, "\n\tJuniper PCAP Flags [%s]",
+               bittok2str(jnx_flag_values, "none", l2info->flags)));
 
     /* extensions present ?  - calculate how much bytes to skip */
     if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) {
@@ -1173,36 +1181,35 @@
         tptr = p+jnx_header_len;
 
         /* ok to read extension length ? */
-        TCHECK2(tptr[0], 2);
+        ND_TCHECK2(tptr[0], 2);
         jnx_ext_len = EXTRACT_16BITS(tptr);
         jnx_header_len += 2;
         tptr +=2;
-        
+
         /* nail up the total length -
          * just in case something goes wrong
          * with TLV parsing */
         jnx_header_len += jnx_ext_len;
-        
-        if (vflag>1)
-            printf(", PCAP Extension(s) total length %u",
-                   jnx_ext_len);
-        
-        TCHECK2(tptr[0], jnx_ext_len);
+
+        if (ndo->ndo_vflag > 1)
+            ND_PRINT((ndo, ", PCAP Extension(s) total length %u", jnx_ext_len));
+
+        ND_TCHECK2(tptr[0], jnx_ext_len);
         while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) {
             tlv_type = *(tptr++);
             tlv_len = *(tptr++);
             tlv_value = 0;
-            
+
             /* sanity check */
             if (tlv_type == 0 || tlv_len == 0)
                 break;
-            
-            if (vflag>1)
-                printf("\n\t  %s Extension TLV #%u, length %u, value ",
+
+            if (ndo->ndo_vflag > 1)
+                ND_PRINT((ndo, "\n\t  %s Extension TLV #%u, length %u, value ",
                        tok2str(jnx_ext_tlv_values,"Unknown",tlv_type),
                        tlv_type,
-                       tlv_len);
-            
+                       tlv_len));
+
             tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len);
             switch (tlv_type) {
             case JUNIPER_EXT_TLV_IFD_NAME:
@@ -1211,19 +1218,19 @@
             case JUNIPER_EXT_TLV_IFD_MEDIATYPE:
             case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE:
                 if (tlv_value != -1) {
-                    if (vflag>1)
-                        printf("%s (%u)",
+                    if (ndo->ndo_vflag > 1)
+                        ND_PRINT((ndo, "%s (%u)",
                                tok2str(juniper_ifmt_values, "Unknown", tlv_value),
-                               tlv_value);
+                               tlv_value));
                 }
                 break;
             case JUNIPER_EXT_TLV_IFL_ENCAPS:
             case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS:
                 if (tlv_value != -1) {
-                    if (vflag>1)
-                        printf("%s (%u)",
+                    if (ndo->ndo_vflag > 1)
+                        ND_PRINT((ndo, "%s (%u)",
                                tok2str(juniper_ifle_values, "Unknown", tlv_value),
-                               tlv_value);
+                               tlv_value));
                 }
                 break;
             case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */
@@ -1231,35 +1238,36 @@
             case JUNIPER_EXT_TLV_IFD_IDX:
             default:
                 if (tlv_value != -1) {
-                    if (vflag>1)
-                        printf("%u",tlv_value);
+                    if (ndo->ndo_vflag > 1)
+                        ND_PRINT((ndo, "%u", tlv_value));
                 }
                 break;
             }
-            
+
             tptr+=tlv_len;
             jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD;
         }
-        
-        if (vflag>1)
-            printf("\n\t-----original packet-----\n\t");
-    } 
-    
-    if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) {            
-        if (eflag)
-            printf("no-L2-hdr, ");
+
+        if (ndo->ndo_vflag > 1)
+            ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
+    }
+
+    if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) {
+        if (ndo->ndo_eflag)
+            ND_PRINT((ndo, "no-L2-hdr, "));
 
         /* there is no link-layer present -
          * perform the v4/v6 heuristics
          * to figure out what it is
          */
-        TCHECK2(p[jnx_header_len+4],1);
-        if(ip_heuristic_guess(p+jnx_header_len+4,l2info->length-(jnx_header_len+4)) == 0)
-            printf("no IP-hdr found!");
+        ND_TCHECK2(p[jnx_header_len + 4], 1);
+        if (ip_heuristic_guess(ndo, p + jnx_header_len + 4,
+                               l2info->length - (jnx_header_len + 4)) == 0)
+            ND_PRINT((ndo, "no IP-hdr found!"));
 
         l2info->header_len=jnx_header_len+4;
         return 0; /* stop parsing the output further */
-        
+
     }
     l2info->header_len = jnx_header_len;
     p+=l2info->header_len;
@@ -1281,7 +1289,7 @@
                 l2info->cookie_type = AS_COOKIE_ID;
                 l2info->cookie_len = 8;
                 break;
-            
+
             default:
                 l2info->bundle = l2info->cookie[0];
                 break;
@@ -1300,25 +1308,25 @@
             l2info->length -= l2info->cookie_len;
             l2info->caplen -= l2info->cookie_len;
 
-            if (eflag)
-                printf("%s-PIC, cookie-len %u",
+            if (ndo->ndo_eflag)
+                ND_PRINT((ndo, "%s-PIC, cookie-len %u",
                        lp->s,
-                       l2info->cookie_len);
+                       l2info->cookie_len));
 
             if (l2info->cookie_len > 0) {
-                TCHECK2(p[0],l2info->cookie_len);
-                if (eflag)
-                    printf(", cookie 0x");
+                ND_TCHECK2(p[0], l2info->cookie_len);
+                if (ndo->ndo_eflag)
+                    ND_PRINT((ndo, ", cookie 0x"));
                 for (idx = 0; idx < l2info->cookie_len; idx++) {
                     l2info->cookie[idx] = p[idx]; /* copy cookie data */
-                    if (eflag) printf("%02x",p[idx]);
+                    if (ndo->ndo_eflag) ND_PRINT((ndo, "%02x", p[idx]));
                 }
             }
 
-            if (eflag) printf(": "); /* print demarc b/w L2/L3*/
-            
+            if (ndo->ndo_eflag) ND_PRINT((ndo, ": ")); /* print demarc b/w L2/L3*/
 
-            l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len); 
+
+            l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len);
             break;
         }
         ++lp;
@@ -1335,7 +1343,7 @@
             break;
         case AS_COOKIE_ID:
             l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff;
-            l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;            
+            l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
             break;
         default:
             l2info->bundle = l2info->cookie[0];
@@ -1348,7 +1356,7 @@
         switch (l2info->cookie_type) {
         case LS_COOKIE_ID:
             l2info->bundle = l2info->cookie[1];
-            l2info->proto = EXTRACT_16BITS(p);        
+            l2info->proto = EXTRACT_16BITS(p);
             l2info->header_len += 2;
             l2info->length -= 2;
             l2info->caplen -= 2;
@@ -1371,7 +1379,7 @@
         switch (l2info->cookie_type) {
         case LS_COOKIE_ID:
             l2info->bundle = l2info->cookie[1];
-            l2info->proto = EXTRACT_16BITS(p);        
+            l2info->proto = EXTRACT_16BITS(p);
             l2info->header_len += 2;
             l2info->length -= 2;
             l2info->caplen -= 2;
@@ -1388,7 +1396,7 @@
 #endif
 #ifdef DLT_JUNIPER_ATM2
     case DLT_JUNIPER_ATM2:
-        TCHECK2(p[0],4);
+        ND_TCHECK2(p[0], 4);
         /* ATM cell relay control word present ? */
         if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) {
             control_word = EXTRACT_32BITS(p);
@@ -1402,9 +1410,9 @@
             default:
                 break;
             }
-            
-            if (eflag)
-                printf("control-word 0x%08x ", control_word);
+
+            if (ndo->ndo_eflag)
+                ND_PRINT((ndo, "control-word 0x%08x ", control_word));
         }
         break;
 #endif
@@ -1434,16 +1442,16 @@
 #endif
 
     default:
-        printf("Unknown Juniper DLT_ type %u: ", l2info->pictype);
+        ND_PRINT((ndo, "Unknown Juniper DLT_ type %u: ", l2info->pictype));
         break;
     }
-    
-    if (eflag > 1)
-        printf("hlen %u, proto 0x%04x, ",l2info->header_len,l2info->proto);
+
+    if (ndo->ndo_eflag > 1)
+        ND_PRINT((ndo, "hlen %u, proto 0x%04x, ", l2info->header_len, l2info->proto));
 
     return 1; /* everything went ok so far. continue parsing */
  trunc:
-    printf("[|juniper_hdr], length %u",h->len);
+    ND_PRINT((ndo, "[|juniper_hdr], length %u", h->len));
     return 0;
 }
 
diff --git a/print-krb.c b/print-krb.c
index af70875..2eebfa6 100644
--- a/print-krb.c
+++ b/print-krb.c
@@ -21,26 +21,21 @@
  * Initial contribution from John Hawkinson (jhawk@mit.edu).
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.23 2003-11-16 09:36:26 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
 
-static const u_char *c_print(register const u_char *, register const u_char *);
-static const u_char *krb4_print_hdr(const u_char *);
-static void krb4_print(const u_char *);
+static const char tstr[] = " [|kerberos]";
+
+static const u_char *c_print(netdissect_options *, register const u_char *, register const u_char *);
+static const u_char *krb4_print_hdr(netdissect_options *, const u_char *);
+static void krb4_print(netdissect_options *, const u_char *);
 
 #define AUTH_MSG_KDC_REQUEST			1<<1
 #define AUTH_MSG_KDC_REPLY			2<<1
@@ -65,12 +60,10 @@
 #define KERB_ERR_NULL_KEY			10
 
 struct krb {
-	u_int8_t pvno;		/* Protocol Version */
-	u_int8_t type;		/* Type+B */
+	uint8_t pvno;		/* Protocol Version */
+	uint8_t type;		/* Type+B */
 };
 
-static char tstr[] = " [|kerberos]";
-
 static const struct tok type2str[] = {
 	{ AUTH_MSG_KDC_REQUEST,		"KDC_REQUEST" },
 	{ AUTH_MSG_KDC_REPLY,		"KDC_REPLY" },
@@ -100,7 +93,8 @@
 };
 
 static const u_char *
-c_print(register const u_char *s, register const u_char *ep)
+c_print(netdissect_options *ndo,
+        register const u_char *s, register const u_char *ep)
 {
 	register u_char c;
 	register int flag;
@@ -114,14 +108,13 @@
 		}
 		if (!ND_ISASCII(c)) {
 			c = ND_TOASCII(c);
-			putchar('M');
-			putchar('-');
+			ND_PRINT((ndo, "M-"));
 		}
 		if (!ND_ISPRINT(c)) {
 			c ^= 0x40;	/* DEL to ?, others to alpha */
-			putchar('^');
+			ND_PRINT((ndo, "^"));
 		}
-		putchar(c);
+		ND_PRINT((ndo, "%c", c));
 	}
 	if (flag)
 		return NULL;
@@ -129,112 +122,115 @@
 }
 
 static const u_char *
-krb4_print_hdr(const u_char *cp)
+krb4_print_hdr(netdissect_options *ndo,
+               const u_char *cp)
 {
 	cp += 2;
 
-#define PRINT		if ((cp = c_print(cp, snapend)) == NULL) goto trunc
+#define PRINT		if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
 
 	PRINT;
-	putchar('.');
+	ND_PRINT((ndo, "."));
 	PRINT;
-	putchar('@');
+	ND_PRINT((ndo, "@"));
 	PRINT;
 	return (cp);
 
 trunc:
-	fputs(tstr, stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return (NULL);
 
 #undef PRINT
 }
 
 static void
-krb4_print(const u_char *cp)
+krb4_print(netdissect_options *ndo,
+           const u_char *cp)
 {
 	register const struct krb *kp;
 	u_char type;
 	u_short len;
 
-#define PRINT		if ((cp = c_print(cp, snapend)) == NULL) goto trunc
+#define PRINT		if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
 /*  True if struct krb is little endian */
 #define IS_LENDIAN(kp)	(((kp)->type & 0x01) != 0)
 #define KTOHSP(kp, cp)	(IS_LENDIAN(kp) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp))
 
 	kp = (struct krb *)cp;
 
-	if ((&kp->type) >= snapend) {
-		fputs(tstr, stdout);
+	if ((&kp->type) >= ndo->ndo_snapend) {
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 
 	type = kp->type & (0xFF << 1);
 
-	printf(" %s %s: ",
-	    IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type));
+	ND_PRINT((ndo, " %s %s: ",
+	    IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)));
 
 	switch (type) {
 
 	case AUTH_MSG_KDC_REQUEST:
-		if ((cp = krb4_print_hdr(cp)) == NULL)
+		if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
 			return;
 		cp += 4;	/* ctime */
-		TCHECK(*cp);
-		printf(" %dmin ", *cp++ * 5);
+		ND_TCHECK(*cp);
+		ND_PRINT((ndo, " %dmin ", *cp++ * 5));
 		PRINT;
-		putchar('.');
+		ND_PRINT((ndo, "."));
 		PRINT;
 		break;
 
 	case AUTH_MSG_APPL_REQUEST:
 		cp += 2;
-		TCHECK(*cp);
-		printf("v%d ", *cp++);
+		ND_TCHECK(*cp);
+		ND_PRINT((ndo, "v%d ", *cp++));
 		PRINT;
-		TCHECK(*cp);
-		printf(" (%d)", *cp++);
-		TCHECK(*cp);
-		printf(" (%d)", *cp);
+		ND_TCHECK(*cp);
+		ND_PRINT((ndo, " (%d)", *cp++));
+		ND_TCHECK(*cp);
+		ND_PRINT((ndo, " (%d)", *cp));
 		break;
 
 	case AUTH_MSG_KDC_REPLY:
-		if ((cp = krb4_print_hdr(cp)) == NULL)
+		if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
 			return;
 		cp += 10;	/* timestamp + n + exp + kvno */
-		TCHECK2(*cp, sizeof(short));
+		ND_TCHECK2(*cp, sizeof(short));
 		len = KTOHSP(kp, cp);
-		printf(" (%d)", len);
+		ND_PRINT((ndo, " (%d)", len));
 		break;
 
 	case AUTH_MSG_ERR_REPLY:
-		if ((cp = krb4_print_hdr(cp)) == NULL)
+		if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
 			return;
 		cp += 4; 	  /* timestamp */
-		TCHECK2(*cp, sizeof(short));
-		printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp)));
+		ND_TCHECK2(*cp, sizeof(short));
+		ND_PRINT((ndo, " %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))));
 		cp += 4;
 		PRINT;
 		break;
 
 	default:
-		fputs("(unknown)", stdout);
+		ND_PRINT((ndo, "(unknown)"));
 		break;
 	}
 
 	return;
 trunc:
-	fputs(tstr, stdout);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 void
-krb_print(const u_char *dat)
+krb_print(netdissect_options *ndo,
+          const u_char *dat)
 {
 	register const struct krb *kp;
 
 	kp = (struct krb *)dat;
 
-	if (dat >= snapend) {
-		fputs(tstr, stdout);
+	if (dat >= ndo->ndo_snapend) {
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 
@@ -243,17 +239,17 @@
 	case 1:
 	case 2:
 	case 3:
-		printf(" v%d", kp->pvno);
+		ND_PRINT((ndo, " v%d", kp->pvno));
 		break;
 
 	case 4:
-		printf(" v%d", kp->pvno);
-		krb4_print((const u_char *)kp);
+		ND_PRINT((ndo, " v%d", kp->pvno));
+		krb4_print(ndo, (const u_char *)kp);
 		break;
 
 	case 106:
 	case 107:
-		fputs(" v5", stdout);
+		ND_PRINT((ndo, " v5"));
 		/* Decode ASN.1 here "someday" */
 		break;
 	}
diff --git a/print-l2tp.c b/print-l2tp.c
index 840239c..346dae9 100644
--- a/print-l2tp.c
+++ b/print-l2tp.c
@@ -21,24 +21,53 @@
  * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
-#include "l2tp.h"
 #include "interface.h"
 #include "extract.h"
 
-static char tstr[] = " [|l2tp]";
+#define L2TP_FLAG_TYPE		0x8000	/* Type (0=Data, 1=Control) */
+#define L2TP_FLAG_LENGTH	0x4000	/* Length */
+#define L2TP_FLAG_SEQUENCE	0x0800	/* Sequence */
+#define L2TP_FLAG_OFFSET	0x0200	/* Offset */
+#define L2TP_FLAG_PRIORITY	0x0100	/* Priority */
+
+#define L2TP_VERSION_MASK	0x000f	/* Version Mask */
+#define L2TP_VERSION_L2F	0x0001	/* L2F */
+#define L2TP_VERSION_L2TP	0x0002	/* L2TP */
+
+#define L2TP_AVP_HDR_FLAG_MANDATORY	0x8000	/* Mandatory Flag */
+#define L2TP_AVP_HDR_FLAG_HIDDEN	0x4000	/* Hidden Flag */
+#define L2TP_AVP_HDR_LEN_MASK		0x03ff	/* Length Mask */
+
+#define L2TP_FRAMING_CAP_SYNC_MASK	0x00000001	/* Synchronous */
+#define L2TP_FRAMING_CAP_ASYNC_MASK	0x00000002	/* Asynchronous */
+
+#define L2TP_FRAMING_TYPE_SYNC_MASK	0x00000001	/* Synchronous */
+#define L2TP_FRAMING_TYPE_ASYNC_MASK	0x00000002	/* Asynchronous */
+
+#define L2TP_BEARER_CAP_DIGITAL_MASK	0x00000001	/* Digital */
+#define L2TP_BEARER_CAP_ANALOG_MASK	0x00000002	/* Analog */
+
+#define L2TP_BEARER_TYPE_DIGITAL_MASK	0x00000001	/* Digital */
+#define L2TP_BEARER_TYPE_ANALOG_MASK	0x00000002	/* Analog */
+
+/* Authen Type */
+#define L2TP_AUTHEN_TYPE_RESERVED	0x0000	/* Reserved */
+#define L2TP_AUTHEN_TYPE_TEXTUAL	0x0001	/* Textual username/password exchange */
+#define L2TP_AUTHEN_TYPE_CHAP		0x0002	/* PPP CHAP */
+#define L2TP_AUTHEN_TYPE_PAP		0x0003	/* PPP PAP */
+#define L2TP_AUTHEN_TYPE_NO_AUTH	0x0004	/* No Authentication */
+#define L2TP_AUTHEN_TYPE_MSCHAPv1	0x0005	/* MSCHAPv1 */
+
+#define L2TP_PROXY_AUTH_ID_MASK		0x00ff
+
+static const char tstr[] = " [|l2tp]";
 
 #define	L2TP_MSGTYPE_SCCRQ	1  /* Start-Control-Connection-Request */
 #define	L2TP_MSGTYPE_SCCRP	2  /* Start-Control-Connection-Reply */
@@ -234,236 +263,236 @@
 /* generic print out routines */
 /******************************/
 static void
-print_string(const u_char *dat, u_int length)
+print_string(netdissect_options *ndo, const u_char *dat, u_int length)
 {
 	u_int i;
 	for (i=0; i<length; i++) {
-		printf("%c", *dat++);
+		ND_PRINT((ndo, "%c", *dat++));
 	}
 }
 
 static void
-print_octets(const u_char *dat, u_int length)
+print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
 {
 	u_int i;
 	for (i=0; i<length; i++) {
-		printf("%02x", *dat++);
+		ND_PRINT((ndo, "%02x", *dat++));
 	}
 }
 
 static void
-print_16bits_val(const u_int16_t *dat)
+print_16bits_val(netdissect_options *ndo, const uint16_t *dat)
 {
-	printf("%u", EXTRACT_16BITS(dat));
+	ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
 }
 
 static void
-print_32bits_val(const u_int32_t *dat)
+print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
 {
-	printf("%lu", (u_long)EXTRACT_32BITS(dat));
+	ND_PRINT((ndo, "%lu", (u_long)EXTRACT_32BITS(dat)));
 }
 
 /***********************************/
 /* AVP-specific print out routines */
 /***********************************/
 static void
-l2tp_msgtype_print(const u_char *dat)
+l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int16_t *ptr = (u_int16_t*)dat;
+	uint16_t *ptr = (uint16_t*)dat;
 
-	printf("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
-	    EXTRACT_16BITS(ptr)));
+	ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
+	    EXTRACT_16BITS(ptr))));
 }
 
 static void
-l2tp_result_code_print(const u_char *dat, u_int length)
+l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-	u_int16_t *ptr = (u_int16_t *)dat;
+	uint16_t *ptr = (uint16_t *)dat;
 
-	printf("%u", EXTRACT_16BITS(ptr)); ptr++;	/* Result Code */
+	ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr))); ptr++;	/* Result Code */
 	if (length > 2) {				/* Error Code (opt) */
-	        printf("/%u", EXTRACT_16BITS(ptr)); ptr++;
+	        ND_PRINT((ndo, "/%u", EXTRACT_16BITS(ptr))); ptr++;
 	}
 	if (length > 4) {				/* Error Message (opt) */
-		printf(" ");
-		print_string((u_char *)ptr, length - 4);
+		ND_PRINT((ndo, " "));
+		print_string(ndo, (u_char *)ptr, length - 4);
 	}
 }
 
 static void
-l2tp_proto_ver_print(const u_int16_t *dat)
+l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat)
 {
-	printf("%u.%u", (EXTRACT_16BITS(dat) >> 8),
-	    (EXTRACT_16BITS(dat) & 0xff));
+	ND_PRINT((ndo, "%u.%u", (EXTRACT_16BITS(dat) >> 8),
+	    (EXTRACT_16BITS(dat) & 0xff)));
 }
 
 static void
-l2tp_framing_cap_print(const u_char *dat)
+l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int32_t *ptr = (u_int32_t *)dat;
+	uint32_t *ptr = (uint32_t *)dat;
 
 	if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_CAP_ASYNC_MASK) {
-		printf("A");
+		ND_PRINT((ndo, "A"));
 	}
 	if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_CAP_SYNC_MASK) {
-		printf("S");
+		ND_PRINT((ndo, "S"));
 	}
 }
 
 static void
-l2tp_bearer_cap_print(const u_char *dat)
+l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int32_t *ptr = (u_int32_t *)dat;
+	uint32_t *ptr = (uint32_t *)dat;
 
 	if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_CAP_ANALOG_MASK) {
-		printf("A");
+		ND_PRINT((ndo, "A"));
 	}
 	if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_CAP_DIGITAL_MASK) {
-		printf("D");
+		ND_PRINT((ndo, "D"));
 	}
 }
 
 static void
-l2tp_q931_cc_print(const u_char *dat, u_int length)
+l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-	print_16bits_val((u_int16_t *)dat);
-	printf(", %02x", dat[2]);
+	print_16bits_val(ndo, (uint16_t *)dat);
+	ND_PRINT((ndo, ", %02x", dat[2]));
 	if (length > 3) {
-		printf(" ");
-		print_string(dat+3, length-3);
+		ND_PRINT((ndo, " "));
+		print_string(ndo, dat+3, length-3);
 	}
 }
 
 static void
-l2tp_bearer_type_print(const u_char *dat)
+l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int32_t *ptr = (u_int32_t *)dat;
+	uint32_t *ptr = (uint32_t *)dat;
 
 	if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_TYPE_ANALOG_MASK) {
-		printf("A");
+		ND_PRINT((ndo, "A"));
 	}
 	if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_TYPE_DIGITAL_MASK) {
-		printf("D");
+		ND_PRINT((ndo, "D"));
 	}
 }
 
 static void
-l2tp_framing_type_print(const u_char *dat)
+l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int32_t *ptr = (u_int32_t *)dat;
+	uint32_t *ptr = (uint32_t *)dat;
 
 	if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_TYPE_ASYNC_MASK) {
-		printf("A");
+		ND_PRINT((ndo, "A"));
 	}
 	if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_TYPE_SYNC_MASK) {
-		printf("S");
+		ND_PRINT((ndo, "S"));
 	}
 }
 
 static void
-l2tp_packet_proc_delay_print(void)
+l2tp_packet_proc_delay_print(netdissect_options *ndo)
 {
-	printf("obsolete");
+	ND_PRINT((ndo, "obsolete"));
 }
 
 static void
-l2tp_proxy_auth_type_print(const u_char *dat)
+l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int16_t *ptr = (u_int16_t *)dat;
+	uint16_t *ptr = (uint16_t *)dat;
 
-	printf("%s", tok2str(l2tp_authentype2str,
-			     "AuthType-#%u", EXTRACT_16BITS(ptr)));
+	ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
+			     "AuthType-#%u", EXTRACT_16BITS(ptr))));
 }
 
 static void
-l2tp_proxy_auth_id_print(const u_char *dat)
+l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int16_t *ptr = (u_int16_t *)dat;
+	uint16_t *ptr = (uint16_t *)dat;
 
-	printf("%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK);
+	ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK));
 }
 
 static void
-l2tp_call_errors_print(const u_char *dat)
+l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int16_t *ptr = (u_int16_t *)dat;
-	u_int16_t val_h, val_l;
+	uint16_t *ptr = (uint16_t *)dat;
+	uint16_t val_h, val_l;
 
 	ptr++;		/* skip "Reserved" */
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("CRCErr=%u ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "CRCErr=%u ", (val_h<<16) + val_l));
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("FrameErr=%u ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "FrameErr=%u ", (val_h<<16) + val_l));
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("HardOver=%u ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "HardOver=%u ", (val_h<<16) + val_l));
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("BufOver=%u ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "BufOver=%u ", (val_h<<16) + val_l));
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("Timeout=%u ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "Timeout=%u ", (val_h<<16) + val_l));
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("AlignErr=%u ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "AlignErr=%u ", (val_h<<16) + val_l));
 }
 
 static void
-l2tp_accm_print(const u_char *dat)
+l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
 {
-	u_int16_t *ptr = (u_int16_t *)dat;
-	u_int16_t val_h, val_l;
+	uint16_t *ptr = (uint16_t *)dat;
+	uint16_t val_h, val_l;
 
 	ptr++;		/* skip "Reserved" */
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("send=%08x ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "send=%08x ", (val_h<<16) + val_l));
 
 	val_h = EXTRACT_16BITS(ptr); ptr++;
 	val_l = EXTRACT_16BITS(ptr); ptr++;
-	printf("recv=%08x ", (val_h<<16) + val_l);
+	ND_PRINT((ndo, "recv=%08x ", (val_h<<16) + val_l));
 }
 
 static void
-l2tp_ppp_discon_cc_print(const u_char *dat, u_int length)
+l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-	u_int16_t *ptr = (u_int16_t *)dat;
+	uint16_t *ptr = (uint16_t *)dat;
 
-	printf("%04x, ", EXTRACT_16BITS(ptr)); ptr++;	/* Disconnect Code */
-	printf("%04x ",  EXTRACT_16BITS(ptr)); ptr++;	/* Control Protocol Number */
-	printf("%s", tok2str(l2tp_cc_direction2str,
-			     "Direction-#%u", *((u_char *)ptr++)));
+	ND_PRINT((ndo, "%04x, ", EXTRACT_16BITS(ptr))); ptr++;	/* Disconnect Code */
+	ND_PRINT((ndo, "%04x ",  EXTRACT_16BITS(ptr))); ptr++;	/* Control Protocol Number */
+	ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str,
+			     "Direction-#%u", *((u_char *)ptr++))));
 
 	if (length > 5) {
-		printf(" ");
-		print_string((const u_char *)ptr, length-5);
+		ND_PRINT((ndo, " "));
+		print_string(ndo, (const u_char *)ptr, length-5);
 	}
 }
 
 static void
-l2tp_avp_print(const u_char *dat, int length)
+l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
 {
 	u_int len;
-	const u_int16_t *ptr = (u_int16_t *)dat;
-	u_int16_t attr_type;
+	const uint16_t *ptr = (uint16_t *)dat;
+	uint16_t attr_type;
 	int hidden = FALSE;
 
 	if (length <= 0) {
 		return;
 	}
 
-	printf(" ");
+	ND_PRINT((ndo, " "));
 
-	TCHECK(*ptr);	/* Flags & Length */
+	ND_TCHECK(*ptr);	/* Flags & Length */
 	len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK;
 
 	/* If it is not long enough to contain the header, we'll give up. */
@@ -477,58 +506,58 @@
 
 	/* If it goes past the end of the remaining length of the captured
 	   data, we'll give up. */
-	TCHECK2(*ptr, len);
+	ND_TCHECK2(*ptr, len);
 	/* After this point, no need to worry about truncation */
 
 	if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
-		printf("*");
+		ND_PRINT((ndo, "*"));
 	}
 	if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
 		hidden = TRUE;
-		printf("?");
+		ND_PRINT((ndo, "?"));
 	}
 	ptr++;
 
 	if (EXTRACT_16BITS(ptr)) {
 		/* Vendor Specific Attribute */
-	        printf("VENDOR%04x:", EXTRACT_16BITS(ptr)); ptr++;
-		printf("ATTR%04x", EXTRACT_16BITS(ptr)); ptr++;
-		printf("(");
-		print_octets((u_char *)ptr, len-6);
-		printf(")");
+	        ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(ptr))); ptr++;
+		ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(ptr))); ptr++;
+		ND_PRINT((ndo, "("));
+		print_octets(ndo, (u_char *)ptr, len-6);
+		ND_PRINT((ndo, ")"));
 	} else {
 		/* IETF-defined Attributes */
 		ptr++;
 		attr_type = EXTRACT_16BITS(ptr); ptr++;
-		printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type));
-		printf("(");
+		ND_PRINT((ndo, "%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)));
+		ND_PRINT((ndo, "("));
 		if (hidden) {
-			printf("???");
+			ND_PRINT((ndo, "???"));
 		} else {
 			switch (attr_type) {
 			case L2TP_AVP_MSGTYPE:
-				l2tp_msgtype_print((u_char *)ptr);
+				l2tp_msgtype_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_RESULT_CODE:
-				l2tp_result_code_print((u_char *)ptr, len-6);
+				l2tp_result_code_print(ndo, (u_char *)ptr, len-6);
 				break;
 			case L2TP_AVP_PROTO_VER:
-				l2tp_proto_ver_print(ptr);
+				l2tp_proto_ver_print(ndo, ptr);
 				break;
 			case L2TP_AVP_FRAMING_CAP:
-				l2tp_framing_cap_print((u_char *)ptr);
+				l2tp_framing_cap_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_BEARER_CAP:
-				l2tp_bearer_cap_print((u_char *)ptr);
+				l2tp_bearer_cap_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_TIE_BREAKER:
-				print_octets((u_char *)ptr, 8);
+				print_octets(ndo, (u_char *)ptr, 8);
 				break;
 			case L2TP_AVP_FIRM_VER:
 			case L2TP_AVP_ASSND_TUN_ID:
 			case L2TP_AVP_RECV_WIN_SIZE:
 			case L2TP_AVP_ASSND_SESS_ID:
-				print_16bits_val(ptr);
+				print_16bits_val(ndo, ptr);
 				break;
 			case L2TP_AVP_HOST_NAME:
 			case L2TP_AVP_VENDOR_NAME:
@@ -537,7 +566,7 @@
 			case L2TP_AVP_SUB_ADDRESS:
 			case L2TP_AVP_PROXY_AUTH_NAME:
 			case L2TP_AVP_PRIVATE_GRP_ID:
-				print_string((u_char *)ptr, len-6);
+				print_string(ndo, (u_char *)ptr, len-6);
 				break;
 			case L2TP_AVP_CHALLENGE:
 			case L2TP_AVP_INI_RECV_LCP:
@@ -546,13 +575,13 @@
 			case L2TP_AVP_PROXY_AUTH_CHAL:
 			case L2TP_AVP_PROXY_AUTH_RESP:
 			case L2TP_AVP_RANDOM_VECTOR:
-				print_octets((u_char *)ptr, len-6);
+				print_octets(ndo, (u_char *)ptr, len-6);
 				break;
 			case L2TP_AVP_Q931_CC:
-				l2tp_q931_cc_print((u_char *)ptr, len-6);
+				l2tp_q931_cc_print(ndo, (u_char *)ptr, len-6);
 				break;
 			case L2TP_AVP_CHALLENGE_RESP:
-				print_octets((u_char *)ptr, 16);
+				print_octets(ndo, (u_char *)ptr, 16);
 				break;
 			case L2TP_AVP_CALL_SER_NUM:
 			case L2TP_AVP_MINIMUM_BPS:
@@ -560,97 +589,97 @@
 			case L2TP_AVP_TX_CONN_SPEED:
 			case L2TP_AVP_PHY_CHANNEL_ID:
 			case L2TP_AVP_RX_CONN_SPEED:
-				print_32bits_val((u_int32_t *)ptr);
+				print_32bits_val(ndo, (uint32_t *)ptr);
 				break;
 			case L2TP_AVP_BEARER_TYPE:
-				l2tp_bearer_type_print((u_char *)ptr);
+				l2tp_bearer_type_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_FRAMING_TYPE:
-				l2tp_framing_type_print((u_char *)ptr);
+				l2tp_framing_type_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_PACKET_PROC_DELAY:
-				l2tp_packet_proc_delay_print();
+				l2tp_packet_proc_delay_print(ndo);
 				break;
 			case L2TP_AVP_PROXY_AUTH_TYPE:
-				l2tp_proxy_auth_type_print((u_char *)ptr);
+				l2tp_proxy_auth_type_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_PROXY_AUTH_ID:
-				l2tp_proxy_auth_id_print((u_char *)ptr);
+				l2tp_proxy_auth_id_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_CALL_ERRORS:
-				l2tp_call_errors_print((u_char *)ptr);
+				l2tp_call_errors_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_ACCM:
-				l2tp_accm_print((u_char *)ptr);
+				l2tp_accm_print(ndo, (u_char *)ptr);
 				break;
 			case L2TP_AVP_SEQ_REQUIRED:
 				break;	/* No Attribute Value */
 			case L2TP_AVP_PPP_DISCON_CC:
-				l2tp_ppp_discon_cc_print((u_char *)ptr, len-6);
+				l2tp_ppp_discon_cc_print(ndo, (u_char *)ptr, len-6);
 				break;
 			default:
 				break;
 			}
 		}
-		printf(")");
+		ND_PRINT((ndo, ")"));
 	}
 
-	l2tp_avp_print(dat+len, length-len);
+	l2tp_avp_print(ndo, dat+len, length-len);
 	return;
 
  trunc:
-	printf("|...");
+	ND_PRINT((ndo, "|..."));
 }
 
 
 void
-l2tp_print(const u_char *dat, u_int length)
+l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
 	const u_char *ptr = dat;
 	u_int cnt = 0;			/* total octets consumed */
-	u_int16_t pad;
+	uint16_t pad;
 	int flag_t, flag_l, flag_s, flag_o;
-	u_int16_t l2tp_len;
+	uint16_t l2tp_len;
 
 	flag_t = flag_l = flag_s = flag_o = FALSE;
 
-	TCHECK2(*ptr, 2);	/* Flags & Version */
+	ND_TCHECK2(*ptr, 2);	/* Flags & Version */
 	if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
-		printf(" l2tp:");
+		ND_PRINT((ndo, " l2tp:"));
 	} else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
-		printf(" l2f:");
+		ND_PRINT((ndo, " l2f:"));
 		return;		/* nothing to do */
 	} else {
-		printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
+		ND_PRINT((ndo, " Unknown Version, neither L2F(1) nor L2TP(2)"));
 		return;		/* nothing we can do */
 	}
 
-	printf("[");
+	ND_PRINT((ndo, "["));
 	if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) {
 		flag_t = TRUE;
-		printf("T");
+		ND_PRINT((ndo, "T"));
 	}
 	if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) {
 		flag_l = TRUE;
-		printf("L");
+		ND_PRINT((ndo, "L"));
 	}
 	if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) {
 		flag_s = TRUE;
-		printf("S");
+		ND_PRINT((ndo, "S"));
 	}
 	if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) {
 		flag_o = TRUE;
-		printf("O");
+		ND_PRINT((ndo, "O"));
 	}
 	if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY)
-		printf("P");
-	printf("]");
+		ND_PRINT((ndo, "P"));
+	ND_PRINT((ndo, "]"));
 
 	ptr += 2;
 	cnt += 2;
 
 	if (flag_l) {
-		TCHECK2(*ptr, 2);	/* Length */
+		ND_TCHECK2(*ptr, 2);	/* Length */
 		l2tp_len = EXTRACT_16BITS(ptr);
 		ptr += 2;
 		cnt += 2;
@@ -658,28 +687,28 @@
 		l2tp_len = 0;
 	}
 
-	TCHECK2(*ptr, 2);		/* Tunnel ID */
-	printf("(%u/", EXTRACT_16BITS(ptr));
+	ND_TCHECK2(*ptr, 2);		/* Tunnel ID */
+	ND_PRINT((ndo, "(%u/", EXTRACT_16BITS(ptr)));
 	ptr += 2;
 	cnt += 2;
-	TCHECK2(*ptr, 2);		/* Session ID */
-	printf("%u)",  EXTRACT_16BITS(ptr));
+	ND_TCHECK2(*ptr, 2);		/* Session ID */
+	ND_PRINT((ndo, "%u)",  EXTRACT_16BITS(ptr)));
 	ptr += 2;
 	cnt += 2;
 
 	if (flag_s) {
-		TCHECK2(*ptr, 2);	/* Ns */
-		printf("Ns=%u,", EXTRACT_16BITS(ptr));
+		ND_TCHECK2(*ptr, 2);	/* Ns */
+		ND_PRINT((ndo, "Ns=%u,", EXTRACT_16BITS(ptr)));
 		ptr += 2;
 		cnt += 2;
-		TCHECK2(*ptr, 2);	/* Nr */
-		printf("Nr=%u",  EXTRACT_16BITS(ptr));
+		ND_TCHECK2(*ptr, 2);	/* Nr */
+		ND_PRINT((ndo, "Nr=%u",  EXTRACT_16BITS(ptr)));
 		ptr += 2;
 		cnt += 2;
 	}
 
 	if (flag_o) {
-		TCHECK2(*ptr, 2);	/* Offset Size */
+		ND_TCHECK2(*ptr, 2);	/* Offset Size */
 		pad =  EXTRACT_16BITS(ptr);
 		ptr += (2 + pad);
 		cnt += (2 + pad);
@@ -687,33 +716,33 @@
 
 	if (flag_l) {
 		if (length < l2tp_len) {
-			printf(" Length %u larger than packet", l2tp_len);
+			ND_PRINT((ndo, " Length %u larger than packet", l2tp_len));
 			return;
 		}
 		length = l2tp_len;
 	}
 	if (length < cnt) {
-		printf(" Length %u smaller than header length", length);
+		ND_PRINT((ndo, " Length %u smaller than header length", length));
 		return;
 	}
 	if (flag_t) {
 		if (!flag_l) {
-			printf(" No length");
+			ND_PRINT((ndo, " No length"));
 			return;
 		}
 		if (length - cnt == 0) {
-			printf(" ZLB");
+			ND_PRINT((ndo, " ZLB"));
 		} else {
-			l2tp_avp_print(ptr, length - cnt);
+			l2tp_avp_print(ndo, ptr, length - cnt);
 		}
 	} else {
-		printf(" {");
-		ppp_print(ptr, length - cnt);
-		printf("}");
+		ND_PRINT((ndo, " {"));
+		ppp_print(ndo, ptr, length - cnt);
+		ND_PRINT((ndo, "}"));
 	}
 
 	return;
 
  trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-lane.c b/print-lane.c
index aa79311..c1e0b2e 100644
--- a/print-lane.c
+++ b/print-lane.c
@@ -20,25 +20,30 @@
  *
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
 #include "ether.h"
-#include "lane.h"
+
+struct lecdatahdr_8023 {
+  uint16_t le_header;
+  uint8_t h_dest[ETHER_ADDR_LEN];
+  uint8_t h_source[ETHER_ADDR_LEN];
+  uint16_t h_type;
+};
+
+struct lane_controlhdr {
+  uint16_t lec_header;
+  uint8_t lec_proto;
+  uint8_t lec_vers;
+  uint16_t lec_opcode;
+};
 
 static const struct tok lecop2str[] = {
 	{ 0x0001,	"configure request" },
@@ -63,7 +68,7 @@
 static void
 lane_hdr_print(netdissect_options *ndo, const u_char *bp)
 {
-	(void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
+	ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
 }
 
 /*
@@ -75,12 +80,12 @@
  * This assumes 802.3, not 802.5, LAN emulation.
  */
 void
-lane_print(const u_char *p, u_int length, u_int caplen)
+lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
 	struct lane_controlhdr *lec;
 
 	if (caplen < sizeof(struct lane_controlhdr)) {
-		printf("[|lane]");
+		ND_PRINT((ndo, "[|lane]"));
 		return;
 	}
 
@@ -89,9 +94,9 @@
 		/*
 		 * LE Control.
 		 */
-		printf("lec: proto %x vers %x %s",
+		ND_PRINT((ndo, "lec: proto %x vers %x %s",
 		    lec->lec_proto, lec->lec_vers,
-		    tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode)));
+		    tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))));
 		return;
 	}
 
@@ -106,13 +111,13 @@
 	 * Now print the encapsulated frame, under the assumption
 	 * that it's an Ethernet frame.
 	 */
-	ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
+	ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
 }
 
 u_int
-lane_if_print(const struct pcap_pkthdr *h, const u_char *p)
+lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
-	lane_print(p, h->len, h->caplen);
+	lane_print(ndo, p, h->len, h->caplen);
 
 	return (sizeof(struct lecdatahdr_8023));
 }
diff --git a/print-ldp.c b/print-ldp.c
index 262c9bd..3f741d1 100644
--- a/print-ldp.c
+++ b/print-ldp.c
@@ -14,23 +14,14 @@
  *  and Steinar Haug (sthaug@nethelp.no)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
-#include "decode_prefix.h"
 #include "extract.h"
 #include "addrtoname.h"
 
@@ -53,10 +44,10 @@
  */
 
 struct ldp_common_header {
-    u_int8_t version[2];
-    u_int8_t pdu_length[2];
-    u_int8_t lsr_id[4];
-    u_int8_t label_space[2];
+    uint8_t version[2];
+    uint8_t pdu_length[2];
+    uint8_t lsr_id[4];
+    uint8_t label_space[2];
 };
 
 #define LDP_VERSION 1
@@ -86,13 +77,13 @@
  */
 
 struct ldp_msg_header {
-    u_int8_t type[2];
-    u_int8_t length[2];
-    u_int8_t id[4];
+    uint8_t type[2];
+    uint8_t length[2];
+    uint8_t id[4];
 };
 
-#define	LDP_MASK_MSG_TYPE(x)  ((x)&0x7fff) 
-#define	LDP_MASK_U_BIT(x)     ((x)&0x8000) 
+#define	LDP_MASK_MSG_TYPE(x)  ((x)&0x7fff)
+#define	LDP_MASK_U_BIT(x)     ((x)&0x8000)
 
 #define	LDP_MSG_NOTIF                0x0001
 #define	LDP_MSG_HELLO                0x0100
@@ -126,8 +117,8 @@
     { 0, NULL}
 };
 
-#define	LDP_MASK_TLV_TYPE(x)  ((x)&0x3fff) 
-#define	LDP_MASK_F_BIT(x) ((x)&0x4000) 
+#define	LDP_MASK_TLV_TYPE(x)  ((x)&0x3fff)
+#define	LDP_MASK_F_BIT(x) ((x)&0x4000)
 
 #define	LDP_TLV_FEC                  0x0100
 #define	LDP_TLV_ADDRESS_LIST         0x0101
@@ -218,10 +209,9 @@
     { 0, NULL}
 };
 
-int ldp_msg_print(register const u_char *);
-int ldp_tlv_print(register const u_char *);
-   
-/* 
+static int ldp_pdu_print(netdissect_options *, register const u_char *);
+
+/*
  * ldp tlv header
  *
  *  0                   1                   2                   3
@@ -239,14 +229,16 @@
  */
 
 #define TLV_TCHECK(minlen) \
-    TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv;
+    ND_TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv;
 
-int
-ldp_tlv_print(register const u_char *tptr) {
-
+static int
+ldp_tlv_print(netdissect_options *ndo,
+              register const u_char *tptr,
+              u_short msg_tlen)
+{
     struct ldp_tlv_header {
-        u_int8_t type[2];
-        u_int8_t length[2];
+        uint8_t type[2];
+        uint8_t length[2];
     };
 
     const struct ldp_tlv_header *ldp_tlv_header;
@@ -256,20 +248,25 @@
     char buf[100];
     int i;
 
-    ldp_tlv_header = (const struct ldp_tlv_header *)tptr;    
+    ldp_tlv_header = (const struct ldp_tlv_header *)tptr;
+    ND_TCHECK(*ldp_tlv_header);
     tlv_len=EXTRACT_16BITS(ldp_tlv_header->length);
+    if (tlv_len + 4 > msg_tlen) {
+        ND_PRINT((ndo, "\n\t\t TLV contents go past end of message"));
+        return 0;
+    }
     tlv_tlen=tlv_len;
     tlv_type=LDP_MASK_TLV_TYPE(EXTRACT_16BITS(ldp_tlv_header->type));
 
     /* FIXME vendor private / experimental check */
-    printf("\n\t    %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
+    ND_PRINT((ndo, "\n\t    %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
            tok2str(ldp_tlv_values,
                    "Unknown",
                    tlv_type),
            tlv_type,
            tlv_len,
            LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "continue processing" : "ignore",
-           LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't");
+           LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't"));
 
     tptr+=sizeof(struct ldp_tlv_header);
 
@@ -277,25 +274,25 @@
 
     case LDP_TLV_COMMON_HELLO:
         TLV_TCHECK(4);
-        printf("\n\t      Hold Time: %us, Flags: [%s Hello%s]",
+        ND_PRINT((ndo, "\n\t      Hold Time: %us, Flags: [%s Hello%s]",
                EXTRACT_16BITS(tptr),
                (EXTRACT_16BITS(tptr+2)&0x8000) ? "Targeted" : "Link",
-               (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : "");
+               (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : ""));
         break;
 
     case LDP_TLV_IPV4_TRANSPORT_ADDR:
         TLV_TCHECK(4);
-        printf("\n\t      IPv4 Transport Address: %s", ipaddr_string(tptr));
+        ND_PRINT((ndo, "\n\t      IPv4 Transport Address: %s", ipaddr_string(ndo, tptr)));
         break;
 #ifdef INET6
     case LDP_TLV_IPV6_TRANSPORT_ADDR:
         TLV_TCHECK(16);
-        printf("\n\t      IPv6 Transport Address: %s", ip6addr_string(tptr));
+        ND_PRINT((ndo, "\n\t      IPv6 Transport Address: %s", ip6addr_string(ndo, tptr)));
         break;
 #endif
     case LDP_TLV_CONFIG_SEQ_NUMBER:
         TLV_TCHECK(4);
-        printf("\n\t      Sequence Number: %u", EXTRACT_32BITS(tptr));
+        ND_PRINT((ndo, "\n\t      Sequence Number: %u", EXTRACT_32BITS(tptr)));
         break;
 
     case LDP_TLV_ADDRESS_LIST:
@@ -303,24 +300,24 @@
 	af = EXTRACT_16BITS(tptr);
 	tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
         tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
-	printf("\n\t      Address Family: %s, addresses",
-               tok2str(af_values, "Unknown (%u)", af));
+	ND_PRINT((ndo, "\n\t      Address Family: %s, addresses",
+               tok2str(af_values, "Unknown (%u)", af)));
         switch (af) {
         case AFNUM_INET:
 	    while(tlv_tlen >= sizeof(struct in_addr)) {
-		TCHECK2(*tptr, sizeof(struct in_addr));
-		printf(" %s",ipaddr_string(tptr));
+		ND_TCHECK2(*tptr, sizeof(struct in_addr));
+		ND_PRINT((ndo, " %s", ipaddr_string(ndo, tptr)));
 		tlv_tlen-=sizeof(struct in_addr);
-		tptr+=sizeof(struct in_addr);                
+		tptr+=sizeof(struct in_addr);
 	    }
             break;
 #ifdef INET6
         case AFNUM_INET6:
 	    while(tlv_tlen >= sizeof(struct in6_addr)) {
-		TCHECK2(*tptr, sizeof(struct in6_addr));
-		printf(" %s",ip6addr_string(tptr));
+		ND_TCHECK2(*tptr, sizeof(struct in6_addr));
+		ND_PRINT((ndo, " %s", ip6addr_string(ndo, tptr)));
 		tlv_tlen-=sizeof(struct in6_addr);
-		tptr+=sizeof(struct in6_addr);                
+		tptr+=sizeof(struct in6_addr);
 	    }
             break;
 #endif
@@ -332,19 +329,19 @@
 
     case LDP_TLV_COMMON_SESSION:
 	TLV_TCHECK(8);
-	printf("\n\t      Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
+	ND_PRINT((ndo, "\n\t      Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
 	       EXTRACT_16BITS(tptr), EXTRACT_16BITS(tptr+2),
 	       (EXTRACT_16BITS(tptr+6)&0x8000) ? "On Demand" : "Unsolicited",
 	       (EXTRACT_16BITS(tptr+6)&0x4000) ? "Enabled" : "Disabled"
-	       );
+	       ));
 	break;
 
     case LDP_TLV_FEC:
         TLV_TCHECK(1);
         fec_type = *tptr;
-	printf("\n\t      %s FEC (0x%02x)",
+	ND_PRINT((ndo, "\n\t      %s FEC (0x%02x)",
 	       tok2str(ldp_fec_values, "Unknown", fec_type),
-	       fec_type);
+	       fec_type));
 
 	tptr+=1;
 	tlv_tlen-=1;
@@ -358,31 +355,31 @@
 	    tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
 	    tlv_tlen-=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
 	    if (af == AFNUM_INET) {
-		i=decode_prefix4(tptr,tlv_tlen,buf,sizeof(buf));
+		i=decode_prefix4(ndo, tptr, tlv_tlen, buf, sizeof(buf));
 		if (i == -2)
 		    goto trunc;
 		if (i == -3)
-		    printf(": IPv4 prefix (goes past end of TLV)");
+		    ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)"));
 		else if (i == -1)
-		    printf(": IPv4 prefix (invalid length)");
+		    ND_PRINT((ndo, ": IPv4 prefix (invalid length)"));
 		else
-		    printf(": IPv4 prefix %s",buf);
+		    ND_PRINT((ndo, ": IPv4 prefix %s", buf));
 	    }
 #ifdef INET6
 	    else if (af == AFNUM_INET6) {
-		i=decode_prefix6(tptr,tlv_tlen,buf,sizeof(buf));
+		i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf));
 		if (i == -2)
 		    goto trunc;
 		if (i == -3)
-		    printf(": IPv4 prefix (goes past end of TLV)");
+		    ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)"));
 		else if (i == -1)
-		    printf(": IPv6 prefix (invalid length)");
+		    ND_PRINT((ndo, ": IPv6 prefix (invalid length)"));
 		else
-		    printf(": IPv6 prefix %s",buf);
+		    ND_PRINT((ndo, ": IPv6 prefix %s", buf));
 	    }
 #endif
 	    else
-		printf(": Address family %u prefix", af);
+		ND_PRINT((ndo, ": Address family %u prefix", af));
 	    break;
 	case LDP_FEC_HOSTADDRESS:
 	    break;
@@ -396,24 +393,27 @@
             vc_info_len = *(tptr+2);
 
             if (vc_info_len == 0) {
-                printf(": %s, %scontrol word, group-ID %u, VC-info-length: %u",
+                ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-info-length: %u",
                        tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
                        EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
                        EXTRACT_32BITS(tptr+3),
-                       vc_info_len);
+                       vc_info_len));
                 break;
             }
 
             /* Make sure we have the VC ID as well */
             TLV_TCHECK(11);
-	    printf(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
+	    ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
 		   tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
 		   EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
                    EXTRACT_32BITS(tptr+3),
 		   EXTRACT_32BITS(tptr+7),
-                   vc_info_len);
-            if (vc_info_len < 4)
-                goto trunc; /* minimum 4, for the VC ID */
+                   vc_info_len));
+            if (vc_info_len < 4) {
+                /* minimum 4, for the VC ID */
+                ND_PRINT((ndo, " (invalid, < 4"));
+                return(tlv_len+4); /* Type & Length fields not included */
+	    }
             vc_info_len -= 4; /* subtract out the VC ID, giving the length of the interface parameters */
 
             /* Skip past the fixed information and the VC ID */
@@ -429,33 +429,33 @@
                 if (vc_info_len < vc_info_tlv_len)
                     break;
 
-                printf("\n\t\tInterface Parameter: %s (0x%02x), len %u",
+                ND_PRINT((ndo, "\n\t\tInterface Parameter: %s (0x%02x), len %u",
                        tok2str(ldp_fec_martini_ifparm_values,"Unknown",vc_info_tlv_type),
                        vc_info_tlv_type,
-                       vc_info_tlv_len);
+                       vc_info_tlv_len));
 
                 switch(vc_info_tlv_type) {
                 case LDP_FEC_MARTINI_IFPARM_MTU:
-                    printf(": %u",EXTRACT_16BITS(tptr+2));
+                    ND_PRINT((ndo, ": %u", EXTRACT_16BITS(tptr+2)));
                     break;
 
                 case LDP_FEC_MARTINI_IFPARM_DESC:
-                    printf(": ");
+                    ND_PRINT((ndo, ": "));
                     for (idx = 2; idx < vc_info_tlv_len; idx++)
-                        safeputchar(*(tptr+idx));
+                        safeputchar(ndo, *(tptr + idx));
                     break;
 
                 case LDP_FEC_MARTINI_IFPARM_VCCV:
-                    printf("\n\t\t  Control Channels (0x%02x) = [%s]",
+                    ND_PRINT((ndo, "\n\t\t  Control Channels (0x%02x) = [%s]",
                            *(tptr+2),
-                           bittok2str(ldp_fec_martini_ifparm_vccv_cc_values,"none",*(tptr+2)));
-                    printf("\n\t\t  CV Types (0x%02x) = [%s]",
+                           bittok2str(ldp_fec_martini_ifparm_vccv_cc_values, "none", *(tptr+2))));
+                    ND_PRINT((ndo, "\n\t\t  CV Types (0x%02x) = [%s]",
                            *(tptr+3),
-                           bittok2str(ldp_fec_martini_ifparm_vccv_cv_values,"none",*(tptr+3)));
+                           bittok2str(ldp_fec_martini_ifparm_vccv_cv_values, "none", *(tptr+3))));
                     break;
 
                 default:
-                    print_unknown_data(tptr+2,"\n\t\t  ",vc_info_tlv_len-2);
+                    print_unknown_data(ndo, tptr+2, "\n\t\t  ", vc_info_tlv_len-2);
                     break;
                 }
 
@@ -469,45 +469,45 @@
 
     case LDP_TLV_GENERIC_LABEL:
 	TLV_TCHECK(4);
-	printf("\n\t      Label: %u", EXTRACT_32BITS(tptr) & 0xfffff);
+	ND_PRINT((ndo, "\n\t      Label: %u", EXTRACT_32BITS(tptr) & 0xfffff));
 	break;
 
     case LDP_TLV_STATUS:
 	TLV_TCHECK(8);
 	ui = EXTRACT_32BITS(tptr);
 	tptr+=4;
-	printf("\n\t      Status: 0x%02x, Flags: [%s and %s forward]",
+	ND_PRINT((ndo, "\n\t      Status: 0x%02x, Flags: [%s and %s forward]",
 	       ui&0x3fffffff,
 	       ui&0x80000000 ? "Fatal error" : "Advisory Notification",
-	       ui&0x40000000 ? "do" : "don't");
+	       ui&0x40000000 ? "do" : "don't"));
 	ui = EXTRACT_32BITS(tptr);
 	tptr+=4;
 	if (ui)
-	    printf(", causing Message ID: 0x%08x", ui);
+	    ND_PRINT((ndo, ", causing Message ID: 0x%08x", ui));
 	break;
 
     case LDP_TLV_FT_SESSION:
 	TLV_TCHECK(8);
 	ft_flags = EXTRACT_16BITS(tptr);
-	printf("\n\t      Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
+	ND_PRINT((ndo, "\n\t      Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
 	       ft_flags&0x8000 ? "" : "No ",
 	       ft_flags&0x8 ? "" : "Don't ",
 	       ft_flags&0x4 ? "" : "No ",
 	       ft_flags&0x2 ? "Sequence Numbered Label" : "All Labels",
-	       ft_flags&0x1 ? "" : "Don't ");
+	       ft_flags&0x1 ? "" : "Don't "));
 	tptr+=4;
 	ui = EXTRACT_32BITS(tptr);
 	if (ui)
-	    printf(", Reconnect Timeout: %ums", ui);
+	    ND_PRINT((ndo, ", Reconnect Timeout: %ums", ui));
 	tptr+=4;
 	ui = EXTRACT_32BITS(tptr);
 	if (ui)
-	    printf(", Recovery Time: %ums", ui);
+	    ND_PRINT((ndo, ", Recovery Time: %ums", ui));
 	break;
 
     case LDP_TLV_MTU:
 	TLV_TCHECK(2);
-	printf("\n\t      MTU: %u", EXTRACT_16BITS(tptr));
+	ND_PRINT((ndo, "\n\t      MTU: %u", EXTRACT_16BITS(tptr)));
 	break;
 
 
@@ -528,27 +528,28 @@
     case LDP_TLV_LABEL_REQUEST_MSG_ID:
 
     default:
-        if (vflag <= 1)
-            print_unknown_data(tptr,"\n\t      ",tlv_tlen);
+        if (ndo->ndo_vflag <= 1)
+            print_unknown_data(ndo, tptr, "\n\t      ", tlv_tlen);
         break;
     }
     return(tlv_len+4); /* Type & Length fields not included */
- 
+
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
     return 0;
 
 badtlv:
-    printf("\n\t\t TLV contents go past end of TLV");
+    ND_PRINT((ndo, "\n\t\t TLV contents go past end of TLV"));
     return(tlv_len+4); /* Type & Length fields not included */
 }
 
 void
-ldp_print(register const u_char *pptr, register u_int len) {
-
+ldp_print(netdissect_options *ndo,
+          register const u_char *pptr, register u_int len)
+{
     int processed;
     while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) {
-        processed = ldp_msg_print(pptr);
+        processed = ldp_pdu_print(ndo, pptr);
         if (processed == 0)
             return;
         len -= processed;
@@ -556,10 +557,10 @@
     }
 }
 
-
-int
-ldp_msg_print(register const u_char *pptr) {
-
+static int
+ldp_pdu_print(netdissect_options *ndo,
+              register const u_char *pptr)
+{
     const struct ldp_common_header *ldp_com_header;
     const struct ldp_msg_header *ldp_msg_header;
     const u_char *tptr,*msg_tptr;
@@ -567,68 +568,84 @@
     u_short pdu_len,msg_len,msg_type,msg_tlen;
     int hexdump,processed;
 
-    tptr=pptr;
     ldp_com_header = (const struct ldp_common_header *)pptr;
-    TCHECK(*ldp_com_header);
+    ND_TCHECK(*ldp_com_header);
 
     /*
      * Sanity checking of the header.
      */
     if (EXTRACT_16BITS(&ldp_com_header->version) != LDP_VERSION) {
-	printf("%sLDP version %u packet not supported",
-               (vflag < 1) ? "" : "\n\t",
-               EXTRACT_16BITS(&ldp_com_header->version));
+	ND_PRINT((ndo, "%sLDP version %u packet not supported",
+               (ndo->ndo_vflag < 1) ? "" : "\n\t",
+               EXTRACT_16BITS(&ldp_com_header->version)));
 	return 0;
     }
 
-    /* print the LSR-ID, label-space & length */
     pdu_len = EXTRACT_16BITS(&ldp_com_header->pdu_length);
-    printf("%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
-           (vflag < 1) ? "" : "\n\t",
-           ipaddr_string(&ldp_com_header->lsr_id),
-           EXTRACT_16BITS(&ldp_com_header->label_space),
-           pdu_len);
+    if (pdu_len < sizeof(const struct ldp_common_header)-4) {
+        /* length too short */
+        ND_PRINT((ndo, "%sLDP, pdu-length: %u (too short, < %u)",
+               (ndo->ndo_vflag < 1) ? "" : "\n\t",
+               pdu_len,
+               (u_int)(sizeof(const struct ldp_common_header)-4)));
+        return 0;
+    }
 
-    /* bail out if non-verbose */ 
-    if (vflag < 1)
+    /* print the LSR-ID, label-space & length */
+    ND_PRINT((ndo, "%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
+           (ndo->ndo_vflag < 1) ? "" : "\n\t",
+           ipaddr_string(ndo, &ldp_com_header->lsr_id),
+           EXTRACT_16BITS(&ldp_com_header->label_space),
+           pdu_len));
+
+    /* bail out if non-verbose */
+    if (ndo->ndo_vflag < 1)
         return 0;
 
     /* ok they seem to want to know everything - lets fully decode it */
-    tlen=pdu_len;
-
-    tptr += sizeof(const struct ldp_common_header);
-    tlen -= sizeof(const struct ldp_common_header)-4;	/* Type & Length fields not included */
+    tptr = pptr + sizeof(const struct ldp_common_header);
+    tlen = pdu_len - (sizeof(const struct ldp_common_header)-4);	/* Type & Length fields not included */
 
     while(tlen>0) {
         /* did we capture enough for fully decoding the msg header ? */
-        TCHECK2(*tptr, sizeof(struct ldp_msg_header));
+        ND_TCHECK2(*tptr, sizeof(struct ldp_msg_header));
 
         ldp_msg_header = (const struct ldp_msg_header *)tptr;
         msg_len=EXTRACT_16BITS(ldp_msg_header->length);
         msg_type=LDP_MASK_MSG_TYPE(EXTRACT_16BITS(ldp_msg_header->type));
 
+        if (msg_len < sizeof(struct ldp_msg_header)-4) {
+            /* length too short */
+            /* FIXME vendor private / experimental check */
+            ND_PRINT((ndo, "\n\t  %s Message (0x%04x), length: %u (too short, < %u)",
+                   tok2str(ldp_msg_values,
+                           "Unknown",
+                           msg_type),
+                   msg_type,
+                   msg_len,
+                   (u_int)(sizeof(struct ldp_msg_header)-4)));
+            return 0;
+        }
+
         /* FIXME vendor private / experimental check */
-        printf("\n\t  %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
+        ND_PRINT((ndo, "\n\t  %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
                tok2str(ldp_msg_values,
                        "Unknown",
                        msg_type),
                msg_type,
                msg_len,
                EXTRACT_32BITS(&ldp_msg_header->id),
-               LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore");
-
-        if (msg_len == 0) /* infinite loop protection */
-            return 0;
+               LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore"));
 
         msg_tptr=tptr+sizeof(struct ldp_msg_header);
-        msg_tlen=msg_len-sizeof(struct ldp_msg_header)+4; /* Type & Length fields not included */
+        msg_tlen=msg_len-(sizeof(struct ldp_msg_header)-4); /* Type & Length fields not included */
 
         /* did we capture enough for fully decoding the message ? */
-        TCHECK2(*tptr, msg_len);
+        ND_TCHECK2(*tptr, msg_len);
         hexdump=FALSE;
 
         switch(msg_type) {
- 
+
         case LDP_MSG_NOTIF:
         case LDP_MSG_HELLO:
         case LDP_MSG_INIT:
@@ -638,7 +655,7 @@
         case LDP_MSG_ADDRESS_WITHDRAW:
         case LDP_MSG_LABEL_WITHDRAW:
             while(msg_tlen >= 4) {
-                processed = ldp_tlv_print(msg_tptr);
+                processed = ldp_tlv_print(ndo, msg_tptr, msg_tlen);
                 if (processed == 0)
                     break;
                 msg_tlen-=processed;
@@ -656,13 +673,13 @@
         case LDP_MSG_LABEL_ABORT_REQUEST:
 
         default:
-            if (vflag <= 1)
-                print_unknown_data(msg_tptr,"\n\t  ",msg_tlen);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo, msg_tptr, "\n\t  ", msg_tlen);
             break;
         }
         /* do we want to see an additionally hexdump ? */
-        if (vflag > 1 || hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(struct ldp_msg_header),"\n\t  ",
+        if (ndo->ndo_vflag > 1 || hexdump==TRUE)
+            print_unknown_data(ndo, tptr+sizeof(struct ldp_msg_header), "\n\t  ",
                                msg_len);
 
         tptr += msg_len+4;
@@ -670,7 +687,13 @@
     }
     return pdu_len+4;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
     return 0;
 }
 
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-llc.c b/print-llc.c
index 356e313..e8a3314 100644
--- a/print-llc.c
+++ b/print-llc.c
@@ -22,20 +22,13 @@
  *	with an awful lot of hacking by Jeffrey Mogul, DECWRL
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.75 2007-04-13 09:43:11 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"			/* must come after interface.h */
@@ -75,7 +68,7 @@
 	{ 0,		NULL }
 };
 
-static const struct tok llc_flag_values[] = { 
+static const struct tok llc_flag_values[] = {
         { 0, "Command" },
         { LLC_GSAP, "Response" },
         { LLC_U_POLL, "Poll" },
@@ -86,14 +79,14 @@
 };
 
 
-static const struct tok llc_ig_flag_values[] = { 
+static const struct tok llc_ig_flag_values[] = {
         { 0, "Individual" },
         { LLC_IG, "Group" },
 	{ 0, NULL }
 };
 
 
-static const struct tok llc_supervisory_values[] = { 
+static const struct tok llc_supervisory_values[] = {
         { 0, "Receiver Ready" },
         { 1, "Receiver not Ready" },
         { 2, "Reject" },
@@ -101,7 +94,7 @@
 };
 
 
-static const struct tok cisco_values[] = { 
+static const struct tok cisco_values[] = {
 	{ PID_CISCO_CDP, "CDP" },
 	{ PID_CISCO_VTP, "VTP" },
 	{ PID_CISCO_DTP, "DTP" },
@@ -111,7 +104,7 @@
 	{ 0,             NULL }
 };
 
-static const struct tok bridged_values[] = { 
+static const struct tok bridged_values[] = {
 	{ PID_RFC2684_ETH_FCS,     "Ethernet + FCS" },
 	{ PID_RFC2684_ETH_NOFCS,   "Ethernet w/o FCS" },
 	{ PID_RFC2684_802_4_FCS,   "802.4 + FCS" },
@@ -126,12 +119,12 @@
 	{ 0,                       NULL },
 };
 
-static const struct tok null_values[] = { 
+static const struct tok null_values[] = {
 	{ 0,             NULL }
 };
 
 struct oui_tok {
-	u_int32_t	oui;
+	uint32_t	oui;
 	const struct tok *tok;
 };
 
@@ -148,20 +141,20 @@
  * Returns non-zero IFF it succeeds in printing the header
  */
 int
-llc_print(const u_char *p, u_int length, u_int caplen,
+llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
 	  const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
 {
-	u_int8_t dsap_field, dsap, ssap_field, ssap;
-	u_int16_t control;
+	uint8_t dsap_field, dsap, ssap_field, ssap;
+	uint16_t control;
 	int is_u;
 	register int ret;
 
 	*extracted_ethertype = 0;
 
-	if (caplen < 3) {
-		(void)printf("[|llc]");
-		default_print((u_char *)p, caplen);
-		return(0);
+	if (caplen < 3 || length < 3) {
+		ND_PRINT((ndo, "[|llc]"));
+		ND_DEFAULTPRINT((u_char *)p, caplen);
+		return (1);
 	}
 
 	dsap_field = *p;
@@ -184,10 +177,10 @@
 		 * The control field in I and S frames is
 		 * 2 bytes...
 		 */
-		if (caplen < 4) {
-			(void)printf("[|llc]");
-			default_print((u_char *)p, caplen);
-			return(0);
+		if (caplen < 4 || length < 4) {
+			ND_PRINT((ndo, "[|llc]"));
+			ND_DEFAULTPRINT((u_char *)p, caplen);
+			return (1);
 		}
 
 		/*
@@ -213,41 +206,46 @@
 		 * least one capture file.)
 		 */
 
-            if (eflag)
-		printf("IPX 802.3: ");
+            if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "IPX 802.3: "));
 
-            ipx_print(p, length);
+            ipx_print(ndo, p, length);
             return (1);
 	}
 
 	dsap = dsap_field & ~LLC_IG;
 	ssap = ssap_field & ~LLC_GSAP;
 
-	if (eflag) {
-                printf("LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s",
+	if (ndo->ndo_eflag) {
+                ND_PRINT((ndo, "LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s",
                        tok2str(llc_values, "Unknown", dsap),
                        dsap,
                        tok2str(llc_ig_flag_values, "Unknown", dsap_field & LLC_IG),
                        tok2str(llc_values, "Unknown", ssap),
                        ssap,
-                       tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP));
+                       tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP)));
 
 		if (is_u) {
-			printf(", ctrl 0x%02x: ", control);
+			ND_PRINT((ndo, ", ctrl 0x%02x: ", control));
 		} else {
-			printf(", ctrl 0x%04x: ", control);
+			ND_PRINT((ndo, ", ctrl 0x%04x: ", control));
 		}
 	}
 
 	if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D &&
 	    control == LLC_UI) {
-		stp_print(p+3, length-3);
+		stp_print(ndo, p+3, length-3);
 		return (1);
 	}
 
 	if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
 	    control == LLC_UI) {
-		ip_print(gndo, p+4, length-4);
+		if (caplen < 4 || length < 4) {
+			ND_PRINT((ndo, "[|llc]"));
+			ND_DEFAULTPRINT((u_char *)p, caplen);
+			return (1);
+		}
+		ip_print(ndo, p+4, length-4);
 		return (1);
 	}
 
@@ -260,10 +258,10 @@
 		 *
 		 * Skip DSAP, LSAP, and control field.
 		 */
-                if (eflag)
-                        printf("IPX 802.2: ");
+                if (ndo->ndo_eflag)
+                        ND_PRINT((ndo, "IPX 802.2: "));
 
-		ipx_print(p+3, length-3);
+		ipx_print(ndo, p+3, length-3);
 		return (1);
 	}
 
@@ -287,19 +285,17 @@
 		if (is_u) {
 			p += 3;
 			length -= 3;
-			caplen -= 3;
 		} else {
 			p += 4;
 			length -= 4;
-			caplen -= 4;
 		}
-		netbeui_print(control, p, length);
+		netbeui_print(ndo, control, p, length);
 		return (1);
 	}
 #endif
 	if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
 	    && control == LLC_UI) {
-		isoclns_print(p + 3, length - 3, caplen - 3);
+		isoclns_print(ndo, p + 3, length - 3, caplen - 3);
 		return (1);
 	}
 
@@ -310,85 +306,79 @@
 		 * Does anybody ever bridge one form of LAN traffic
 		 * over a networking type that uses 802.2 LLC?
 		 */
-		ret = snap_print(p+3, length-3, caplen-3, 2);
+		ret = snap_print(ndo, p+3, length-3, caplen-3, 2);
 		if (ret)
 			return (ret);
 	}
 
-	if (!eflag) {
+	if (!ndo->ndo_eflag) {
 		if (ssap == dsap) {
 			if (esrc == NULL || edst == NULL)
-				(void)printf("%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+				ND_PRINT((ndo, "%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
 			else
-				(void)printf("%s > %s %s ",
-						etheraddr_string(esrc),
-						etheraddr_string(edst),
-						tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+				ND_PRINT((ndo, "%s > %s %s ",
+						etheraddr_string(ndo, esrc),
+						etheraddr_string(ndo, edst),
+						tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
 		} else {
 			if (esrc == NULL || edst == NULL)
-				(void)printf("%s > %s ",
+				ND_PRINT((ndo, "%s > %s ",
                                         tok2str(llc_values, "Unknown SSAP 0x%02x", ssap),
-					tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+					tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
 			else
-				(void)printf("%s %s > %s %s ",
-					etheraddr_string(esrc),
+				ND_PRINT((ndo, "%s %s > %s %s ",
+					etheraddr_string(ndo, esrc),
                                         tok2str(llc_values, "Unknown SSAP 0x%02x", ssap),
-					etheraddr_string(edst),
-					tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+					etheraddr_string(ndo, edst),
+					tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
 		}
 	}
 
 	if (is_u) {
-		printf("Unnumbered, %s, Flags [%s], length %u",
+		ND_PRINT((ndo, "Unnumbered, %s, Flags [%s], length %u",
                        tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)),
                        tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)),
-                       length);
+                       length));
 
 		p += 3;
-		length -= 3;
-		caplen -= 3;
 
 		if ((control & ~LLC_U_POLL) == LLC_XID) {
 			if (*p == LLC_XID_FI) {
-				printf(": %02x %02x", p[1], p[2]);
-				p += 3;
-				length -= 3;
-				caplen -= 3;
+				ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
 			}
 		}
 	} else {
 		if ((control & LLC_S_FMT) == LLC_S_FMT) {
-			(void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u",
+			ND_PRINT((ndo, "Supervisory, %s, rcv seq %u, Flags [%s], length %u",
 				tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)),
 				LLC_IS_NR(control),
 				tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
-                                length);
+                                length));
 		} else {
-			(void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u",
+			ND_PRINT((ndo, "Information, send seq %u, rcv seq %u, Flags [%s], length %u",
 				LLC_I_NS(control),
 				LLC_IS_NR(control),
 				tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
-                                length);
+                                length));
 		}
-		p += 4;
-		length -= 4;
-		caplen -= 4;
 	}
 	return(1);
 }
 
 int
-snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
+snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
 {
-	u_int32_t orgcode;
+	uint32_t orgcode;
 	register u_short et;
 	register int ret;
 
-	TCHECK2(*p, 5);
+	ND_TCHECK2(*p, 5);
+	if (caplen < 5 || length < 5)
+		goto trunc;
 	orgcode = EXTRACT_24BITS(p);
 	et = EXTRACT_16BITS(p + 3);
 
-	if (eflag) {
+	if (ndo->ndo_eflag) {
 		const struct tok *tok = null_values;
 		const struct oui_tok *otp;
 
@@ -398,12 +388,12 @@
 				break;
 			}
 		}
-		(void)printf("oui %s (0x%06x), %s %s (0x%04x): ",
+		ND_PRINT((ndo, "oui %s (0x%06x), %s %s (0x%04x): ",
 		     tok2str(oui_values, "Unknown", orgcode),
 		     orgcode,
 		     (orgcode == 0x000000 ? "ethertype" : "pid"),
 		     tok2str(tok, "Unknown", et),
-		     et);
+		     et));
 	}
 	p += 5;
 	length -= 5;
@@ -418,7 +408,7 @@
 		 * Cisco hardware; the protocol ID is
 		 * an Ethernet protocol type.
 		 */
-		ret = ethertype_print(gndo, et, p, length, caplen);
+		ret = ethertype_print(ndo, et, p, length, caplen);
 		if (ret)
 			return (ret);
 		break;
@@ -433,7 +423,7 @@
 			 * but used 0x000000 and an Ethernet
 			 * packet type for AARP packets.
 			 */
-			ret = ethertype_print(gndo, et, p, length, caplen);
+			ret = ethertype_print(ndo, et, p, length, caplen);
 			if (ret)
 				return (ret);
 		}
@@ -442,24 +432,25 @@
 	case OUI_CISCO:
                 switch (et) {
                 case PID_CISCO_CDP:
-                        cdp_print(p, length, caplen);
+                        cdp_print(ndo, p, length, caplen);
                         return (1);
                 case PID_CISCO_DTP:
-                        dtp_print(p, length); 
+                        dtp_print(ndo, p, length);
                         return (1);
                 case PID_CISCO_UDLD:
-                        udld_print(p, length);
+                        udld_print(ndo, p, length);
                         return (1);
                 case PID_CISCO_VTP:
-                        vtp_print(p, length);
+                        vtp_print(ndo, p, length);
                         return (1);
                 case PID_CISCO_PVST:
                 case PID_CISCO_VLANBRIDGE:
-                        stp_print(p, length);
+                        stp_print(ndo, p, length);
                         return (1);
                 default:
                         break;
                 }
+		break;
 
 	case OUI_RFC2684:
 		switch (et) {
@@ -473,7 +464,7 @@
 			/*
 			 * Skip the padding.
 			 */
-			TCHECK2(*p, bridge_pad);
+			ND_TCHECK2(*p, bridge_pad);
 			caplen -= bridge_pad;
 			length -= bridge_pad;
 			p += bridge_pad;
@@ -481,7 +472,7 @@
 			/*
 			 * What remains is an Ethernet packet.
 			 */
-			ether_print(gndo, p, length, caplen, NULL, NULL);
+			ether_print(ndo, p, length, caplen, NULL, NULL);
 			return (1);
 
 		case PID_RFC2684_802_5_FCS:
@@ -494,7 +485,7 @@
 			 * Skip the padding, but not the Access
 			 * Control field.
 			 */
-			TCHECK2(*p, bridge_pad);
+			ND_TCHECK2(*p, bridge_pad);
 			caplen -= bridge_pad;
 			length -= bridge_pad;
 			p += bridge_pad;
@@ -503,7 +494,7 @@
 			 * What remains is an 802.5 Token Ring
 			 * packet.
 			 */
-			token_print(p, length, caplen);
+			token_print(ndo, p, length, caplen);
 			return (1);
 
 		case PID_RFC2684_FDDI_FCS:
@@ -515,7 +506,7 @@
 			/*
 			 * Skip the padding.
 			 */
-			TCHECK2(*p, bridge_pad + 1);
+			ND_TCHECK2(*p, bridge_pad + 1);
 			caplen -= bridge_pad + 1;
 			length -= bridge_pad + 1;
 			p += bridge_pad + 1;
@@ -523,18 +514,18 @@
 			/*
 			 * What remains is an FDDI packet.
 			 */
-			fddi_print(p, length, caplen);
+			fddi_print(ndo, p, length, caplen);
 			return (1);
 
 		case PID_RFC2684_BPDU:
-			stp_print(p, length);
+			stp_print(ndo, p, length);
 			return (1);
 		}
 	}
 	return (0);
 
 trunc:
-	(void)printf("[|snap]");
+	ND_PRINT((ndo, "[|snap]"));
 	return (1);
 }
 
diff --git a/print-lldp.c b/print-lldp.c
index 04591ab..ce3c093 100644
--- a/print-lldp.c
+++ b/print-lldp.c
@@ -19,11 +19,7 @@
  * DCBX extensions by Kaladhar Musunuru <kaladharm@sourceforge.net>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -31,8 +27,6 @@
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 
 #include "interface.h"
 #include "extract.h"
@@ -40,8 +34,8 @@
 #include "af.h"
 #include "oui.h"
 
-#define	LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9) 
-#define	LLDP_EXTRACT_LEN(x) ((x)&0x01ff) 
+#define	LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9)
+#define	LLDP_EXTRACT_LEN(x) ((x)&0x01ff)
 
 /*
  * TLV type codes
@@ -244,7 +238,7 @@
 
 static const struct tok lldp_tia_location_lci_what_values[] = {
     { 0, "location of DHCP server"},
-    { 1, "location of the network element believed to be closest to the client"}, 
+    { 1, "location of the network element believed to be closest to the client"},
     { 2, "location of the client"},
     { 0, NULL}
 };
@@ -473,7 +467,7 @@
 
 /*
  * From RFC 3636 - ifMauAutoNegCapAdvertisedBits
- */ 
+ */
 #define	 LLDP_MAU_PMD_OTHER			(1 <<  15)
 #define	 LLDP_MAU_PMD_10BASE_T			(1 <<  14)
 #define	 LLDP_MAU_PMD_10BASE_T_FD		(1 <<  13)
@@ -608,74 +602,80 @@
 #define LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH                      9
 #define LLDP_PRIVATE_8021_SUBTYPE_CDCP_MIN_LENGTH                 8
 
-static void print_ets_priority_assignment_table(const u_char *ptr)
+static void
+print_ets_priority_assignment_table(netdissect_options *ndo,
+                                    const u_char *ptr)
 {
-    printf("\n\t    Priority Assignment Table");
-    printf("\n\t     Priority : 0   1   2   3   4   5   6   7");
-    printf("\n\t     Value    : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+    ND_PRINT((ndo, "\n\t    Priority Assignment Table"));
+    ND_PRINT((ndo, "\n\t     Priority : 0   1   2   3   4   5   6   7"));
+    ND_PRINT((ndo, "\n\t     Value    : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
             ptr[0]>>4,ptr[0]&0x0f,ptr[1]>>4,ptr[1]&0x0f,ptr[2]>>4,
-            ptr[2]&0x0f,ptr[3]>>4,ptr[3]&0x0f);
+            ptr[2] & 0x0f, ptr[3] >> 4, ptr[3] & 0x0f));
 }
 
-static void print_tc_bandwidth_table(const u_char *ptr)
+static void
+print_tc_bandwidth_table(netdissect_options *ndo,
+                         const u_char *ptr)
 {
-    printf("\n\t    TC Bandwidth Table");
-    printf("\n\t     TC%%   : 0   1   2   3   4   5   6   7");
-    printf("\n\t     Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
-             ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5],ptr[6],ptr[7]);
+    ND_PRINT((ndo, "\n\t    TC Bandwidth Table"));
+    ND_PRINT((ndo, "\n\t     TC%%   : 0   1   2   3   4   5   6   7"));
+    ND_PRINT((ndo, "\n\t     Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+             ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
 }
 
-static void print_tsa_assignment_table(const u_char *ptr)
+static void
+print_tsa_assignment_table(netdissect_options *ndo,
+                           const u_char *ptr)
 {
-    printf("\n\t    TSA Assignment Table");
-    printf("\n\t     Traffic Class: 0   1   2   3   4   5   6   7");
-    printf("\n\t     Value        : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d", 
-             ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5],ptr[6],ptr[7]);
+    ND_PRINT((ndo, "\n\t    TSA Assignment Table"));
+    ND_PRINT((ndo, "\n\t     Traffic Class: 0   1   2   3   4   5   6   7"));
+    ND_PRINT((ndo, "\n\t     Value        : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+             ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
 }
 
 /*
  * Print IEEE 802.1 private extensions. (802.1AB annex E)
  */
 static int
-lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
+lldp_private_8021_print(netdissect_options *ndo,
+                        const u_char *tptr, u_int tlv_len)
 {
     int subtype, hexdump = FALSE;
     u_int sublen;
     u_int tval;
-    u_int8_t i;
+    uint8_t i;
 
     if (tlv_len < 4) {
         return hexdump;
     }
     subtype = *(tptr+3);
 
-    printf("\n\t  %s Subtype (%u)",
+    ND_PRINT((ndo, "\n\t  %s Subtype (%u)",
            tok2str(lldp_8021_subtype_values, "unknown", subtype),
-           subtype);
+           subtype));
 
     switch (subtype) {
     case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID:
         if (tlv_len < 6) {
             return hexdump;
         }
-        printf("\n\t    port vlan id (PVID): %u",
-               EXTRACT_16BITS(tptr+4));
+        ND_PRINT((ndo, "\n\t    port vlan id (PVID): %u",
+               EXTRACT_16BITS(tptr + 4)));
         break;
     case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID:
         if (tlv_len < 7) {
             return hexdump;
         }
-        printf("\n\t    port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
+        ND_PRINT((ndo, "\n\t    port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
                EXTRACT_16BITS(tptr+5),
 	       bittok2str(lldp_8021_port_protocol_id_values, "none", *(tptr+4)),
-	       *(tptr+4));
+	       *(tptr + 4)));
         break;
     case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME:
         if (tlv_len < 6) {
             return hexdump;
         }
-        printf("\n\t    vlan id (VID): %u",
-               EXTRACT_16BITS(tptr+4));
+        ND_PRINT((ndo, "\n\t    vlan id (VID): %u", EXTRACT_16BITS(tptr + 4)));
         if (tlv_len < 7) {
             return hexdump;
         }
@@ -683,8 +683,8 @@
         if (tlv_len < 7+sublen) {
             return hexdump;
         }
-        printf("\n\t    vlan name: ");
-        safeputs((const char *)tptr+7, sublen);
+        ND_PRINT((ndo, "\n\t    vlan name: "));
+        safeputs(ndo, tptr + 7, sublen);
         break;
     case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY:
         if (tlv_len < 5) {
@@ -694,57 +694,57 @@
         if (tlv_len < 5+sublen) {
             return hexdump;
         }
-        printf("\n\t    protocol identity: ");
-        safeputs((const char *)tptr+5, sublen);
+        ND_PRINT((ndo, "\n\t    protocol identity: "));
+        safeputs(ndo, tptr + 5, sublen);
         break;
     case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION:
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH){
         	return hexdump;
         }
         tval=*(tptr+4);
-        printf("\n\t    Pre-Priority CNPV Indicator");
-        printf("\n\t     Priority : 0  1  2  3  4  5  6  7");        
-        printf("\n\t     Value    : ");
+        ND_PRINT((ndo, "\n\t    Pre-Priority CNPV Indicator"));
+        ND_PRINT((ndo, "\n\t     Priority : 0  1  2  3  4  5  6  7"));
+        ND_PRINT((ndo, "\n\t     Value    : "));
         for(i=0;i<NO_OF_BITS;i++)
-            printf("%-2d ",(tval>>i)&0x01);
+            ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
         tval=*(tptr+5);
-        printf("\n\t    Pre-Priority Ready Indicator");
-        printf("\n\t     Priority : 0  1  2  3  4  5  6  7");
-        printf("\n\t     Value    : ");
+        ND_PRINT((ndo, "\n\t    Pre-Priority Ready Indicator"));
+        ND_PRINT((ndo, "\n\t     Priority : 0  1  2  3  4  5  6  7"));
+        ND_PRINT((ndo, "\n\t     Value    : "));
         for(i=0;i<NO_OF_BITS;i++)
-            printf("%-2d ",(tval>>i)&0x01);
+            ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
         break;
 
-    case LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION: 
+    case LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION:
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION_LENGTH) {
             return hexdump;
         }
         tval=*(tptr+4);
-        printf("\n\t    Willing:%d, CBS:%d, RES:%d, Max TCs:%d",
-        	tval>>7, (tval>>6) & 0x02, (tval>>3) & 0x07, tval & 0x07);
-		
+        ND_PRINT((ndo, "\n\t    Willing:%d, CBS:%d, RES:%d, Max TCs:%d",
+        	tval >> 7, (tval >> 6) & 0x02, (tval >> 3) & 0x07, tval & 0x07));
+
         /*Print Priority Assignment Table*/
-        print_ets_priority_assignment_table(tptr+5);
-	
+        print_ets_priority_assignment_table(ndo, tptr + 5);
+
         /*Print TC Bandwidth Table*/
-        print_tc_bandwidth_table(tptr+9);
-		
+        print_tc_bandwidth_table(ndo, tptr + 9);
+
         /* Print TSA Assignment Table */
-        print_tsa_assignment_table(tptr+17);
-		
+        print_tsa_assignment_table(ndo, tptr + 17);
+
         break;
 
     case LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION:
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH) {
         	return hexdump;
-        }       
-        printf("\n\t    RES: %d",*(tptr+4));
-        /*Print Priority Assignment Table */ 
-        print_ets_priority_assignment_table(tptr+5);
+        }
+        ND_PRINT((ndo, "\n\t    RES: %d", *(tptr + 4)));
+        /*Print Priority Assignment Table */
+        print_ets_priority_assignment_table(ndo, tptr + 5);
         /*Print TC Bandwidth Table */
-        print_tc_bandwidth_table(tptr+9);
+        print_tc_bandwidth_table(ndo, tptr + 9);
         /* Print TSA Assignment Table */
-        print_tsa_assignment_table(tptr+17);
+        print_tsa_assignment_table(ndo, tptr + 17);
         break;
 
     case LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION:
@@ -752,36 +752,36 @@
             return hexdump;
         }
         tval=*(tptr+4);
-        printf("\n\t    Willing: %d, MBC: %d, RES: %d, PFC cap:%d ",
-        	tval>>7, (tval>>6)&0x01, (tval>>4)&0x03, (tval & 0x0f));
-        printf("\n\t    PFC Enable");
+        ND_PRINT((ndo, "\n\t    Willing: %d, MBC: %d, RES: %d, PFC cap:%d ",
+        	tval >> 7, (tval >> 6) & 0x01, (tval >> 4) & 0x03, (tval & 0x0f)));
+        ND_PRINT((ndo, "\n\t    PFC Enable"));
         tval=*(tptr+5);
-        printf("\n\t     Priority : 0  1  2  3  4  5  6  7");
-        printf("\n\t     Value    : ");
+        ND_PRINT((ndo, "\n\t     Priority : 0  1  2  3  4  5  6  7"));
+        ND_PRINT((ndo, "\n\t     Value    : "));
         for(i=0;i<NO_OF_BITS;i++)
-            printf("%-2d ",(tval>>i)&0x01);
+            ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
         break;
 
     case LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY:
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH) {
             return hexdump;
         }
-        printf("\n\t    RES: %d",*(tptr+4));
+        ND_PRINT((ndo, "\n\t    RES: %d", *(tptr + 4)));
         if(tlv_len<=LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH){
         	return hexdump;
         }
         /*  Length of Application Priority Table */
-        sublen=tlv_len-5; 
+        sublen=tlv_len-5;
         if(sublen%3!=0){
         	return hexdump;
         }
         i=0;
-        printf("\n\t    Application Priority Table");
+        ND_PRINT((ndo, "\n\t    Application Priority Table"));
         while(i<sublen) {
         	tval=*(tptr+i+5);
-        	printf("\n\t      Priority: %d, RES: %d, Sel: %d",
-        		 tval>>5, (tval>>3)&0x03, (tval & 0x07));
-        	printf("Protocol ID: %d",EXTRACT_16BITS(tptr+i+5));
+        	ND_PRINT((ndo, "\n\t      Priority: %d, RES: %d, Sel: %d",
+        		 tval >> 5, (tval >> 3) & 0x03, (tval & 0x07)));
+        	ND_PRINT((ndo, "Protocol ID: %d", EXTRACT_16BITS(tptr + i + 5)));
         	i=i+3;
         }
         break;
@@ -789,22 +789,22 @@
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH){
         	return hexdump;
         }
-        printf("\n\t    EVB Bridge Status");
+        ND_PRINT((ndo, "\n\t    EVB Bridge Status"));
         tval=*(tptr+4);
-        printf("\n\t      RES: %d, BGID: %d, RRCAP: %d, RRCTR: %d",
-        	tval>>3, (tval>>2)&0x01, (tval>>1)&0x01,tval&0x01);
-        printf("\n\t    EVB Station Status");
+        ND_PRINT((ndo, "\n\t      RES: %d, BGID: %d, RRCAP: %d, RRCTR: %d",
+        	tval >> 3, (tval >> 2) & 0x01, (tval >> 1) & 0x01, tval & 0x01));
+        ND_PRINT((ndo, "\n\t    EVB Station Status"));
         tval=*(tptr+5);
-        printf("\n\t      RES: %d, SGID: %d, RRREQ: %d,RRSTAT: %d",
-        	tval>>4, (tval>>3)&0x01, (tval>>2)&0x01, tval&0x03);
+        ND_PRINT((ndo, "\n\t      RES: %d, SGID: %d, RRREQ: %d,RRSTAT: %d",
+        	tval >> 4, (tval >> 3) & 0x01, (tval >> 2) & 0x01, tval & 0x03));
         tval=*(tptr+6);
-        printf("\n\t    R: %d, RTE: %d, ",tval>>5, tval&0x1f);
+        ND_PRINT((ndo, "\n\t    R: %d, RTE: %d, ",tval >> 5, tval & 0x1f));
         tval=*(tptr+7);
-        printf("EVB Mode: %s [%d]",
-        	tok2str(lldp_evb_mode_values,"unknown",tval>>6),tval>>6);
-        printf("\n\t    ROL: %d, RWD: %d, ", (tval>>5)&0x01,tval&0x1f);
+        ND_PRINT((ndo, "EVB Mode: %s [%d]",
+        	tok2str(lldp_evb_mode_values, "unknown", tval >> 6), tval >> 6));
+        ND_PRINT((ndo, "\n\t    ROL: %d, RWD: %d, ", (tval >> 5) & 0x01, tval & 0x1f));
         tval=*(tptr+8);
-        printf("RES: %d, ROL: %d, RKA: %d", tval>>6,(tval>>5)&0x01, tval&0x1f);
+        ND_PRINT((ndo, "RES: %d, ROL: %d, RKA: %d", tval >> 6, (tval >> 5) & 0x01, tval & 0x1f));
         break;
 
     case LLDP_PRIVATE_8021_SUBTYPE_CDCP:
@@ -812,18 +812,18 @@
         	return hexdump;
         }
         tval=*(tptr+4);
-        printf("\n\t    Role: %d, RES: %d, Scomp: %d ",
-        	tval>>7, (tval>>4)&0x07,(tval>>3)&0x01);
-        printf("ChnCap: %d",EXTRACT_16BITS(tptr+6)&0x0fff);
+        ND_PRINT((ndo, "\n\t    Role: %d, RES: %d, Scomp: %d ",
+        	tval >> 7, (tval >> 4) & 0x07, (tval >> 3) & 0x01));
+        ND_PRINT((ndo, "ChnCap: %d", EXTRACT_16BITS(tptr + 6) & 0x0fff));
         sublen=tlv_len-8;
         if(sublen%3!=0) {
         	return hexdump;
-        }	
+        }
         i=0;
         while(i<sublen) {
         	tval=EXTRACT_24BITS(tptr+i+8);
-        	printf("\n\t    SCID: %d, SVID: %d",
-        		tval>>12, tval&0x000fff);
+        	ND_PRINT((ndo, "\n\t    SCID: %d, SVID: %d",
+        		tval >> 12, tval & 0x000fff));
         	i=i+3;
         }
         break;
@@ -840,7 +840,8 @@
  * Print IEEE 802.3 private extensions. (802.3bc)
  */
 static int
-lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
+lldp_private_8023_print(netdissect_options *ndo,
+                        const u_char *tptr, u_int tlv_len)
 {
     int subtype, hexdump = FALSE;
 
@@ -849,47 +850,47 @@
     }
     subtype = *(tptr+3);
 
-    printf("\n\t  %s Subtype (%u)",
+    ND_PRINT((ndo, "\n\t  %s Subtype (%u)",
            tok2str(lldp_8023_subtype_values, "unknown", subtype),
-           subtype);
+           subtype));
 
     switch (subtype) {
     case LLDP_PRIVATE_8023_SUBTYPE_MACPHY:
         if (tlv_len < 9) {
             return hexdump;
         }
-        printf("\n\t    autonegotiation [%s] (0x%02x)",
+        ND_PRINT((ndo, "\n\t    autonegotiation [%s] (0x%02x)",
                bittok2str(lldp_8023_autonegotiation_values, "none", *(tptr+4)),
-               *(tptr+4));
-        printf("\n\t    PMD autoneg capability [%s] (0x%04x)",
+               *(tptr + 4)));
+        ND_PRINT((ndo, "\n\t    PMD autoneg capability [%s] (0x%04x)",
                bittok2str(lldp_pmd_capability_values,"unknown", EXTRACT_16BITS(tptr+5)),
-               EXTRACT_16BITS(tptr+5));
-        printf("\n\t    MAU type %s (0x%04x)",
+               EXTRACT_16BITS(tptr + 5)));
+        ND_PRINT((ndo, "\n\t    MAU type %s (0x%04x)",
                tok2str(lldp_mau_types_values, "unknown", EXTRACT_16BITS(tptr+7)),
-               EXTRACT_16BITS(tptr+7));
+               EXTRACT_16BITS(tptr + 7)));
         break;
 
     case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER:
         if (tlv_len < 7) {
             return hexdump;
         }
-        printf("\n\t    MDI power support [%s], power pair %s, power class %s",
+        ND_PRINT((ndo, "\n\t    MDI power support [%s], power pair %s, power class %s",
                bittok2str(lldp_mdi_values, "none", *(tptr+4)),
                tok2str(lldp_mdi_power_pairs_values, "unknown", *(tptr+5)),
-               tok2str(lldp_mdi_power_class_values, "unknown", *(tptr+6)));
+               tok2str(lldp_mdi_power_class_values, "unknown", *(tptr + 6))));
         break;
 
     case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR:
         if (tlv_len < 9) {
             return hexdump;
         }
-        printf("\n\t    aggregation status [%s], aggregation port ID %u",
+        ND_PRINT((ndo, "\n\t    aggregation status [%s], aggregation port ID %u",
                bittok2str(lldp_aggregation_values, "none", *(tptr+4)),
-               EXTRACT_32BITS(tptr+5));
+               EXTRACT_32BITS(tptr + 5)));
         break;
 
     case LLDP_PRIVATE_8023_SUBTYPE_MTU:
-        printf("\n\t    MTU size %u", EXTRACT_16BITS(tptr+4));
+        ND_PRINT((ndo, "\n\t    MTU size %u", EXTRACT_16BITS(tptr + 4)));
         break;
 
     default:
@@ -903,10 +904,10 @@
 /*
  * Extract 34bits of latitude/longitude coordinates.
  */
-static u_int64_t
+static uint64_t
 lldp_extract_latlon(const u_char *tptr)
 {
-    u_int64_t latlon;
+    uint64_t latlon;
 
     latlon = *tptr & 0x3;
     latlon = (latlon << 32) | EXTRACT_32BITS(tptr+1);
@@ -918,51 +919,52 @@
  * Print private TIA extensions.
  */
 static int
-lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
+lldp_private_tia_print(netdissect_options *ndo,
+                       const u_char *tptr, u_int tlv_len)
 {
     int subtype, hexdump = FALSE;
-    u_int8_t location_format;
-    u_int16_t power_val;
+    uint8_t location_format;
+    uint16_t power_val;
     u_int lci_len;
-    u_int8_t ca_type, ca_len;
+    uint8_t ca_type, ca_len;
 
     if (tlv_len < 4) {
         return hexdump;
     }
     subtype = *(tptr+3);
 
-    printf("\n\t  %s Subtype (%u)",
+    ND_PRINT((ndo, "\n\t  %s Subtype (%u)",
            tok2str(lldp_tia_subtype_values, "unknown", subtype),
-           subtype);
+           subtype));
 
     switch (subtype) {
     case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES:
         if (tlv_len < 7) {
             return hexdump;
         }
-        printf("\n\t    Media capabilities [%s] (0x%04x)",
+        ND_PRINT((ndo, "\n\t    Media capabilities [%s] (0x%04x)",
                bittok2str(lldp_tia_capabilities_values, "none",
-                          EXTRACT_16BITS(tptr+4)), EXTRACT_16BITS(tptr+4));
-        printf("\n\t    Device type [%s] (0x%02x)",
+                          EXTRACT_16BITS(tptr + 4)), EXTRACT_16BITS(tptr + 4)));
+        ND_PRINT((ndo, "\n\t    Device type [%s] (0x%02x)",
                tok2str(lldp_tia_device_type_values, "unknown", *(tptr+6)),
-               *(tptr+6));
+               *(tptr + 6)));
         break;
 
     case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY:
         if (tlv_len < 8) {
             return hexdump;
         }
-        printf("\n\t    Application type [%s] (0x%02x)",
+        ND_PRINT((ndo, "\n\t    Application type [%s] (0x%02x)",
                tok2str(lldp_tia_application_type_values, "none", *(tptr+4)),
-               *(tptr+4));
-        printf(", Flags [%s]", bittok2str(
-                   lldp_tia_network_policy_bits_values, "none", *(tptr+5)));
-        printf("\n\t    Vlan id %u",
-               LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr+5)));
-        printf(", L2 priority %u",
-               LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr+6)));
-        printf(", DSCP value %u",
-               LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr+6)));
+               *(tptr + 4)));
+        ND_PRINT((ndo, ", Flags [%s]", bittok2str(
+                   lldp_tia_network_policy_bits_values, "none", *(tptr + 5))));
+        ND_PRINT((ndo, "\n\t    Vlan id %u",
+               LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr + 5))));
+        ND_PRINT((ndo, ", L2 priority %u",
+               LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr + 6))));
+        ND_PRINT((ndo, ", DSCP value %u",
+               LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr + 6))));
         break;
 
     case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID:
@@ -970,28 +972,28 @@
             return hexdump;
         }
         location_format = *(tptr+4);
-        printf("\n\t    Location data format %s (0x%02x)",
+        ND_PRINT((ndo, "\n\t    Location data format %s (0x%02x)",
                tok2str(lldp_tia_location_data_format_values, "unknown", location_format),
-               location_format);
+               location_format));
 
         switch (location_format) {
         case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED:
             if (tlv_len < 21) {
                 return hexdump;
             }
-            printf("\n\t    Latitude resolution %u, latitude value %" PRIu64,
-                   (*(tptr+5)>>2), lldp_extract_latlon(tptr+5));
-            printf("\n\t    Longitude resolution %u, longitude value %" PRIu64,
-                   (*(tptr+10)>>2), lldp_extract_latlon(tptr+10));
-            printf("\n\t    Altitude type %s (%u)",
+            ND_PRINT((ndo, "\n\t    Latitude resolution %u, latitude value %" PRIu64,
+                   (*(tptr + 5) >> 2), lldp_extract_latlon(tptr + 5)));
+            ND_PRINT((ndo, "\n\t    Longitude resolution %u, longitude value %" PRIu64,
+                   (*(tptr + 10) >> 2), lldp_extract_latlon(tptr + 10)));
+            ND_PRINT((ndo, "\n\t    Altitude type %s (%u)",
                    tok2str(lldp_tia_location_altitude_type_values, "unknown",(*(tptr+15)>>4)),
-                   (*(tptr+15)>>4));
-            printf("\n\t    Altitude resolution %u, altitude value 0x%x",
+                   (*(tptr + 15) >> 4)));
+            ND_PRINT((ndo, "\n\t    Altitude resolution %u, altitude value 0x%x",
                    (EXTRACT_16BITS(tptr+15)>>6)&0x3f,
-                   ((EXTRACT_32BITS(tptr+16)&0x3fffffff)));
-            printf("\n\t    Datum %s (0x%02x)",
+                   ((EXTRACT_32BITS(tptr + 16) & 0x3fffffff))));
+            ND_PRINT((ndo, "\n\t    Datum %s (0x%02x)",
                    tok2str(lldp_tia_location_datum_type_values, "unknown", *(tptr+20)),
-                   *(tptr+20));
+                   *(tptr + 20)));
             break;
 
         case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS:
@@ -1005,18 +1007,18 @@
             if (tlv_len < 7+lci_len) {
                 return hexdump;
             }
-            printf("\n\t    LCI length %u, LCI what %s (0x%02x), Country-code ",
+            ND_PRINT((ndo, "\n\t    LCI length %u, LCI what %s (0x%02x), Country-code ",
                    lci_len,
                    tok2str(lldp_tia_location_lci_what_values, "unknown", *(tptr+6)),
-                   *(tptr+6));
+                   *(tptr + 6)));
 
             /* Country code */
-            safeputs((const char *)(tptr+7), 2);
+            safeputs(ndo, tptr + 7, 2);
 
             lci_len = lci_len-3;
             tptr = tptr + 9;
 
-            /* Decode each civic address element */	
+            /* Decode each civic address element */
             while (lci_len > 0) {
                 if (lci_len < 2) {
                     return hexdump;
@@ -1025,11 +1027,11 @@
                 ca_len = *(tptr+1);
 
 		tptr += 2;
-                lci_len -= 2; 
+                lci_len -= 2;
 
-                printf("\n\t      CA type \'%s\' (%u), length %u: ",
+                ND_PRINT((ndo, "\n\t      CA type \'%s\' (%u), length %u: ",
                        tok2str(lldp_tia_location_lci_catype_values, "unknown", ca_type),
-                       ca_type, ca_len);
+                       ca_type, ca_len));
 
 		/* basic sanity check */
 		if ( ca_type == 0 || ca_len == 0) {
@@ -1039,20 +1041,20 @@
 		    return hexdump;
 		}
 
-                safeputs((const char *)tptr, ca_len);
+                safeputs(ndo, tptr, ca_len);
                 tptr += ca_len;
                 lci_len -= ca_len;
             }
             break;
 
         case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN:
-            printf("\n\t    ECS ELIN id ");
-            safeputs((const char *)tptr+5, tlv_len-5);       
+            ND_PRINT((ndo, "\n\t    ECS ELIN id "));
+            safeputs(ndo, tptr + 5, tlv_len - 5);
             break;
 
         default:
-            printf("\n\t    Location ID ");
-            print_unknown_data(tptr+5, "\n\t      ", tlv_len-5);
+            ND_PRINT((ndo, "\n\t    Location ID "));
+            print_unknown_data(ndo, tptr + 5, "\n\t      ", tlv_len - 5);
         }
         break;
 
@@ -1060,18 +1062,18 @@
         if (tlv_len < 7) {
             return hexdump;
         }
-        printf("\n\t    Power type [%s]",
-               (*(tptr+4)&0xC0>>6) ? "PD device" : "PSE device");
-        printf(", Power source [%s]",
-               tok2str(lldp_tia_power_source_values, "none", (*(tptr+4)&0x30)>>4));
-        printf("\n\t    Power priority [%s] (0x%02x)",
+        ND_PRINT((ndo, "\n\t    Power type [%s]",
+               (*(tptr + 4) & 0xC0 >> 6) ? "PD device" : "PSE device"));
+        ND_PRINT((ndo, ", Power source [%s]",
+               tok2str(lldp_tia_power_source_values, "none", (*(tptr + 4) & 0x30) >> 4)));
+        ND_PRINT((ndo, "\n\t    Power priority [%s] (0x%02x)",
                tok2str(lldp_tia_power_priority_values, "none", *(tptr+4)&0x0f),
-               *(tptr+4)&0x0f);
+               *(tptr + 4) & 0x0f));
         power_val = EXTRACT_16BITS(tptr+5);
         if (power_val < LLDP_TIA_POWER_VAL_MAX) {
-            printf(", Power %.1f Watts", ((float)power_val)/10);
+            ND_PRINT((ndo, ", Power %.1f Watts", ((float)power_val) / 10));
         } else {
-            printf(", Power %u (Reserved)", power_val);
+            ND_PRINT((ndo, ", Power %u (Reserved)", power_val));
         }
         break;
 
@@ -1082,9 +1084,9 @@
     case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME:
     case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME:
     case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID:
-        printf("\n\t  %s ",
-               tok2str(lldp_tia_inventory_values, "unknown", subtype));
-        safeputs((const char *)tptr+4, tlv_len-4);
+        ND_PRINT((ndo, "\n\t  %s ",
+               tok2str(lldp_tia_inventory_values, "unknown", subtype)));
+        safeputs(ndo, tptr + 4, tlv_len - 4);
         break;
 
     default:
@@ -1099,12 +1101,13 @@
  * Print DCBX Protocol fields (V 1.01).
  */
 static int
-lldp_private_dcbx_print(const u_char *pptr, u_int len)
+lldp_private_dcbx_print(netdissect_options *ndo,
+                        const u_char *pptr, u_int len)
 {
     int subtype, hexdump = FALSE;
-    u_int8_t tval;
-    u_int16_t tlv;
-    u_int32_t i, pgval, uval;
+    uint8_t tval;
+    uint16_t tlv;
+    uint32_t i, pgval, uval;
     u_int tlen, tlv_type, tlv_len;
     const u_char *tptr, *mptr;
 
@@ -1113,9 +1116,9 @@
     }
     subtype = *(pptr+3);
 
-    printf("\n\t  %s Subtype (%u)",
+    ND_PRINT((ndo, "\n\t  %s Subtype (%u)",
            tok2str(lldp_dcbx_subtype_values, "unknown", subtype),
-           subtype);
+           subtype));
 
     /* by passing old version */
     if (subtype == LLDP_DCBX_SUBTYPE_1)
@@ -1126,7 +1129,7 @@
 
     while (tlen >= sizeof(tlv)) {
 
-        TCHECK2(*tptr, sizeof(tlv));
+        ND_TCHECK2(*tptr, sizeof(tlv));
 
         tlv = EXTRACT_16BITS(tptr);
 
@@ -1142,7 +1145,7 @@
             break;
         }
 
-        TCHECK2(*tptr, tlv_len);
+        ND_TCHECK2(*tptr, tlv_len);
         if (tlen < tlv_len) {
             goto trunc;
         }
@@ -1153,89 +1156,92 @@
             if (tlv_len < 10) {
                 goto trunc;
             }
-	    printf("\n\t    Control - Protocol Control (type 0x%x, length %d)",
-		LLDP_DCBX_CONTROL_TLV, tlv_len);
-	    printf("\n\t      Oper_Version: %d", *tptr);
-	    printf("\n\t      Max_Version: %d", *(tptr+1));
-	    printf("\n\t      Sequence Number: %d", EXTRACT_32BITS(tptr+2));
-	    printf("\n\t      Acknowledgement Number: %d",
-					EXTRACT_32BITS(tptr+6));
+	    ND_PRINT((ndo, "\n\t    Control - Protocol Control (type 0x%x, length %d)",
+		LLDP_DCBX_CONTROL_TLV, tlv_len));
+	    ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
+	    ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
+	    ND_PRINT((ndo, "\n\t      Sequence Number: %d", EXTRACT_32BITS(tptr + 2)));
+	    ND_PRINT((ndo, "\n\t      Acknowledgement Number: %d",
+					EXTRACT_32BITS(tptr + 6)));
 	    break;
         case LLDP_DCBX_PRIORITY_GROUPS_TLV:
             if (tlv_len < 17) {
                 goto trunc;
             }
-	    printf("\n\t    Feature - Priority Group (type 0x%x, length %d)",
-		LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len);
-	    printf("\n\t      Oper_Version: %d", *tptr);
-	    printf("\n\t      Max_Version: %d", *(tptr+1));
-	    printf("\n\t      Info block(0x%02X): ", *(tptr+2));
+	    ND_PRINT((ndo, "\n\t    Feature - Priority Group (type 0x%x, length %d)",
+		LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len));
+	    ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
+	    ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
+	    ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", *(tptr + 2)));
 	    tval = *(tptr+2);
-	    printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+	    ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
 		(tval &  0x80) ? 1 : 0, (tval &  0x40) ? 1 : 0,
-		(tval &  0x20) ? 1 : 0);
-	    printf("\n\t      SubType: %d", *(tptr+3));
-	    printf("\n\t      Priority Allocation");
+		(tval &  0x20) ? 1 : 0));
+	    ND_PRINT((ndo, "\n\t      SubType: %d", *(tptr + 3)));
+	    ND_PRINT((ndo, "\n\t      Priority Allocation"));
 
+	    /*
+	     * Array of 8 4-bit priority group ID values; we fetch all
+	     * 32 bits and extract each nibble.
+	     */
 	    pgval = EXTRACT_32BITS(tptr+4);
 	    for (i = 0; i <= 7; i++) {
-		tval = *(tptr+4+(i/2));
-		printf("\n\t          PgId_%d: %d",
-			i, (pgval >> (28-4*i)) & 0xF);
+		ND_PRINT((ndo, "\n\t          PgId_%d: %d",
+			i, (pgval >> (28 - 4 * i)) & 0xF));
 	    }
-	    printf("\n\t      Priority Group Allocation");
+	    ND_PRINT((ndo, "\n\t      Priority Group Allocation"));
 	    for (i = 0; i <= 7; i++)
-		printf("\n\t          Pg percentage[%d]: %d", i, *(tptr+8+i));
-	    printf("\n\t      NumTCsSupported: %d", *(tptr+8+8));
+		ND_PRINT((ndo, "\n\t          Pg percentage[%d]: %d", i, *(tptr + 8 + i)));
+	    ND_PRINT((ndo, "\n\t      NumTCsSupported: %d", *(tptr + 8 + 8)));
 	    break;
         case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV:
             if (tlv_len < 6) {
                 goto trunc;
             }
-	    printf("\n\t    Feature - Priority Flow Control");
-	    printf(" (type 0x%x, length %d)",
-		LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len);
-	    printf("\n\t      Oper_Version: %d", *tptr);
-	    printf("\n\t      Max_Version: %d", *(tptr+1));
-	    printf("\n\t      Info block(0x%02X): ", *(tptr+2));
+	    ND_PRINT((ndo, "\n\t    Feature - Priority Flow Control"));
+	    ND_PRINT((ndo, " (type 0x%x, length %d)",
+		LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len));
+	    ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
+	    ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
+	    ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", *(tptr + 2)));
 	    tval = *(tptr+2);
-	    printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+	    ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
 		(tval &  0x80) ? 1 : 0, (tval &  0x40) ? 1 : 0,
-		(tval &  0x20) ? 1 : 0);
-	    printf("\n\t      SubType: %d", *(tptr+3));
+		(tval &  0x20) ? 1 : 0));
+	    ND_PRINT((ndo, "\n\t      SubType: %d", *(tptr + 3)));
 	    tval = *(tptr+4);
-	    printf("\n\t      PFC Config (0x%02X)", *(tptr+4));
+	    ND_PRINT((ndo, "\n\t      PFC Config (0x%02X)", *(tptr + 4)));
 	    for (i = 0; i <= 7; i++)
-		printf("\n\t          Priority Bit %d: %s",
-		    i, (tval & (1 << i)) ? "Enabled" : "Disabled");
-	    printf("\n\t      NumTCPFCSupported: %d", *(tptr+5));
+		ND_PRINT((ndo, "\n\t          Priority Bit %d: %s",
+		    i, (tval & (1 << i)) ? "Enabled" : "Disabled"));
+	    ND_PRINT((ndo, "\n\t      NumTCPFCSupported: %d", *(tptr + 5)));
 	    break;
         case LLDP_DCBX_APPLICATION_TLV:
             if (tlv_len < 4) {
                 goto trunc;
             }
-	    printf("\n\t    Feature - Application (type 0x%x, length %d)",
-		LLDP_DCBX_APPLICATION_TLV, tlv_len);
-	    printf("\n\t      Oper_Version: %d", *tptr);
-	    printf("\n\t      Max_Version: %d", *(tptr+1));
-	    printf("\n\t      Info block(0x%02X): ", *(tptr+2));
+	    ND_PRINT((ndo, "\n\t    Feature - Application (type 0x%x, length %d)",
+		LLDP_DCBX_APPLICATION_TLV, tlv_len));
+	    ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
+	    ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
+	    ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", *(tptr + 2)));
 	    tval = *(tptr+2);
-	    printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+	    ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
 		(tval &  0x80) ? 1 : 0, (tval &  0x40) ? 1 : 0,
-		(tval &  0x20) ? 1 : 0);
-	    printf("\n\t      SubType: %d", *(tptr+3));
+		(tval &  0x20) ? 1 : 0));
+	    ND_PRINT((ndo, "\n\t      SubType: %d", *(tptr + 3)));
 	    tval = tlv_len - 4;
 	    mptr = tptr + 4;
 	    while (tval >= 6) {
-		printf("\n\t      Application Value");
-		printf("\n\t          Application Protocol ID: 0x%04x",
-			EXTRACT_16BITS(mptr));
+		ND_PRINT((ndo, "\n\t      Application Value"));
+		ND_PRINT((ndo, "\n\t          Application Protocol ID: 0x%04x",
+			EXTRACT_16BITS(mptr)));
 		uval = EXTRACT_24BITS(mptr+2);
-		printf("\n\t          SF (0x%x) Application Protocol ID is %s",
+		ND_PRINT((ndo, "\n\t          SF (0x%x) Application Protocol ID is %s",
 			(uval >> 22),
-			(uval >> 22) ? "Socket Number" : "L2 EtherType");
-		printf("\n\t          OUI: 0x%06x", uval & 0x3fffff);
-		printf("\n\t          User Priority Map: 0x%02x", *(mptr+5));
+			(uval >> 22) ? "Socket Number" : "L2 EtherType"));
+		ND_PRINT((ndo, "\n\t          OUI: 0x%06x", uval & 0x3fffff));
+		ND_PRINT((ndo, "\n\t          User Priority Map: 0x%02x", *(mptr + 5)));
 		tval = tval - 6;
 		mptr = mptr + 6;
 	    }
@@ -1246,8 +1252,8 @@
 	}
 
         /* do we also want to see a hex dump ? */
-        if (vflag > 1 || (vflag && hexdump)) {
-	    print_unknown_data(tptr,"\n\t    ", tlv_len);
+        if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+	    print_unknown_data(ndo, tptr, "\n\t    ", tlv_len);
         }
 
         tlen -= tlv_len;
@@ -1259,11 +1265,11 @@
 }
 
 static char *
-lldp_network_addr_print(const u_char *tptr, u_int len) {
-
-    u_int8_t af;
+lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
+{
+    uint8_t af;
     static char buf[BUFSIZE];
-    const char * (*pfunc)(const u_char *);
+    const char * (*pfunc)(netdissect_options *, const u_char *);
 
     if (len < 1)
       return NULL;
@@ -1273,7 +1279,7 @@
     case AFNUM_INET:
         if (len < 4)
           return NULL;
-        pfunc = getname; 
+        pfunc = getname;
         break;
 #ifdef INET6
     case AFNUM_INET6:
@@ -1297,20 +1303,21 @@
                  tok2str(af_values, "Unknown", af), af);
     } else {
         snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
-                 tok2str(af_values, "Unknown", af), af, (*pfunc)(tptr+1));
+                 tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1));
     }
 
     return buf;
 }
 
 static int
-lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
-
-    u_int8_t mgmt_addr_len, intf_num_subtype, oid_len;
+lldp_mgmt_addr_tlv_print(netdissect_options *ndo,
+                         const u_char *pptr, u_int len)
+{
+    uint8_t mgmt_addr_len, intf_num_subtype, oid_len;
     const u_char *tptr;
     u_int tlen;
     char *mgmt_addr;
-    
+
     tlen = len;
     tptr = pptr;
 
@@ -1324,12 +1331,12 @@
         return 0;
     }
 
-    mgmt_addr = lldp_network_addr_print(tptr, mgmt_addr_len);
+    mgmt_addr = lldp_network_addr_print(ndo, tptr, mgmt_addr_len);
     if (mgmt_addr == NULL) {
         return 0;
     }
-    printf("\n\t  Management Address length %u, %s",
-           mgmt_addr_len, mgmt_addr);
+    ND_PRINT((ndo, "\n\t  Management Address length %u, %s",
+           mgmt_addr_len, mgmt_addr));
     tptr += mgmt_addr_len;
     tlen -= mgmt_addr_len;
 
@@ -1338,10 +1345,10 @@
     }
 
     intf_num_subtype = *tptr;
-    printf("\n\t  %s Interface Numbering (%u): %u",
+    ND_PRINT((ndo, "\n\t  %s Interface Numbering (%u): %u",
            tok2str(lldp_intf_numb_subtype_values, "Unknown", intf_num_subtype),
            intf_num_subtype,
-           EXTRACT_32BITS(tptr+1));
+           EXTRACT_32BITS(tptr + 1)));
 
     tptr += LLDP_INTF_NUM_LEN;
     tlen -= LLDP_INTF_NUM_LEN;
@@ -1356,31 +1363,32 @@
             return 0;
         }
         if (oid_len) {
-            printf("\n\t  OID length %u", oid_len);
-            safeputs((const char *)tptr+1, oid_len);
+            ND_PRINT((ndo, "\n\t  OID length %u", oid_len));
+            safeputs(ndo, tptr + 1, oid_len);
         }
     }
 
     return 1;
-} 
+}
 
 void
-lldp_print(register const u_char *pptr, register u_int len) {
-
-    u_int8_t subtype;
-    u_int16_t tlv, cap, ena_cap;
+lldp_print(netdissect_options *ndo,
+           register const u_char *pptr, register u_int len)
+{
+    uint8_t subtype;
+    uint16_t tlv, cap, ena_cap;
     u_int oui, tlen, hexdump, tlv_type, tlv_len;
     const u_char *tptr;
     char *network_addr;
-    
+
     tptr = pptr;
     tlen = len;
 
-    printf("LLDP, length %u", len);
+    ND_PRINT((ndo, "LLDP, length %u", len));
 
     while (tlen >= sizeof(tlv)) {
 
-        TCHECK2(*tptr, sizeof(tlv));
+        ND_TCHECK2(*tptr, sizeof(tlv));
 
         tlv = EXTRACT_16BITS(tptr);
 
@@ -1391,10 +1399,10 @@
         tlen -= sizeof(tlv);
         tptr += sizeof(tlv);
 
-        if (vflag) {
-            printf("\n\t%s TLV (%u), length %u",
+        if (ndo->ndo_vflag) {
+            ND_PRINT((ndo, "\n\t%s TLV (%u), length %u",
                    tok2str(lldp_tlv_values, "Unknown", tlv_type),
-                   tlv_type, tlv_len);
+                   tlv_type, tlv_len));
         }
 
         /* infinite loop check */
@@ -1402,7 +1410,7 @@
             break;
         }
 
-        TCHECK2(*tptr, tlv_len);
+        ND_TCHECK2(*tptr, tlv_len);
         if (tlen < tlv_len) {
             goto trunc;
         }
@@ -1410,21 +1418,21 @@
         switch (tlv_type) {
 
         case LLDP_CHASSIS_ID_TLV:
-            if (vflag) {
+            if (ndo->ndo_vflag) {
                 if (tlv_len < 2) {
                     goto trunc;
                 }
                 subtype = *tptr;
-                printf("\n\t  Subtype %s (%u): ",
+                ND_PRINT((ndo, "\n\t  Subtype %s (%u): ",
                        tok2str(lldp_chassis_subtype_values, "Unknown", subtype),
-                       subtype);
+                       subtype));
 
                 switch (subtype) {
                 case LLDP_CHASSIS_MAC_ADDR_SUBTYPE:
                     if (tlv_len < 1+6) {
                         goto trunc;
                     }
-                    printf("%s", etheraddr_string(tptr+1));
+                    ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr + 1)));
                     break;
 
                 case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
@@ -1432,15 +1440,15 @@
                 case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
                 case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
                 case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
-                    safeputs((const char *)tptr+1, tlv_len-1);
+                    safeputs(ndo, tptr + 1, tlv_len - 1);
                     break;
 
                 case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
-                    network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
+                    network_addr = lldp_network_addr_print(ndo, tptr+1, tlv_len-1);
                     if (network_addr == NULL) {
                         goto trunc;
                     }
-                    printf("%s", network_addr);
+                    ND_PRINT((ndo, "%s", network_addr));
                     break;
 
                 default:
@@ -1451,21 +1459,21 @@
             break;
 
         case LLDP_PORT_ID_TLV:
-            if (vflag) {
+            if (ndo->ndo_vflag) {
                 if (tlv_len < 2) {
                     goto trunc;
                 }
                 subtype = *tptr;
-                printf("\n\t  Subtype %s (%u): ",
+                ND_PRINT((ndo, "\n\t  Subtype %s (%u): ",
                        tok2str(lldp_port_subtype_values, "Unknown", subtype),
-                       subtype);
+                       subtype));
 
                 switch (subtype) {
                 case LLDP_PORT_MAC_ADDR_SUBTYPE:
                     if (tlv_len < 1+6) {
                         goto trunc;
                     }
-                    printf("%s", etheraddr_string(tptr+1));
+                    ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr + 1)));
                     break;
 
                 case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */
@@ -1473,15 +1481,15 @@
                 case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
                 case LLDP_PORT_INTF_ALIAS_SUBTYPE:
                 case LLDP_PORT_PORT_COMP_SUBTYPE:
-                    safeputs((const char *)tptr+1, tlv_len-1);
+                    safeputs(ndo, tptr + 1, tlv_len - 1);
                     break;
 
                 case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
-                    network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
+                    network_addr = lldp_network_addr_print(ndo, tptr+1, tlv_len-1);
                     if (network_addr == NULL) {
                         goto trunc;
                     }
-                    printf("%s", network_addr);
+                    ND_PRINT((ndo, "%s", network_addr));
                     break;
 
                 default:
@@ -1492,18 +1500,18 @@
             break;
 
         case LLDP_TTL_TLV:
-            if (vflag) {
+            if (ndo->ndo_vflag) {
                 if (tlv_len < 2) {
                     goto trunc;
                 }
-                printf(": TTL %us", EXTRACT_16BITS(tptr));
+                ND_PRINT((ndo, ": TTL %us", EXTRACT_16BITS(tptr)));
             }
             break;
 
         case LLDP_PORT_DESCR_TLV:
-            if (vflag) {
-                printf(": ");
-                safeputs((const char *)tptr, tlv_len);
+            if (ndo->ndo_vflag) {
+                ND_PRINT((ndo, ": "));
+                safeputs(ndo, tptr, tlv_len);
             }
             break;
 
@@ -1512,19 +1520,19 @@
              * The system name is also print in non-verbose mode
              * similar to the CDP printer.
              */
-            printf(": ");
-            safeputs((const char *)tptr, tlv_len);
+            ND_PRINT((ndo, ": "));
+            safeputs(ndo, tptr, tlv_len);
             break;
 
         case LLDP_SYSTEM_DESCR_TLV:
-            if (vflag) {
-                printf("\n\t  ");
-                safeputs((const char *)tptr, tlv_len);
+            if (ndo->ndo_vflag) {
+                ND_PRINT((ndo, "\n\t  "));
+                safeputs(ndo, tptr, tlv_len);
             }
             break;
 
         case LLDP_SYSTEM_CAP_TLV:
-            if (vflag) {
+            if (ndo->ndo_vflag) {
                 /*
                  * XXX - IEEE Std 802.1AB-2009 says the first octet
                  * if a chassis ID subtype, with the system
@@ -1536,41 +1544,41 @@
                 }
                 cap = EXTRACT_16BITS(tptr);
                 ena_cap = EXTRACT_16BITS(tptr+2);
-                printf("\n\t  System  Capabilities [%s] (0x%04x)",
-                       bittok2str(lldp_cap_values, "none", cap), cap);
-                printf("\n\t  Enabled Capabilities [%s] (0x%04x)",
-                       bittok2str(lldp_cap_values, "none", ena_cap), ena_cap);
+                ND_PRINT((ndo, "\n\t  System  Capabilities [%s] (0x%04x)",
+                       bittok2str(lldp_cap_values, "none", cap), cap));
+                ND_PRINT((ndo, "\n\t  Enabled Capabilities [%s] (0x%04x)",
+                       bittok2str(lldp_cap_values, "none", ena_cap), ena_cap));
             }
             break;
 
         case LLDP_MGMT_ADDR_TLV:
-            if (vflag) {
-                if (!lldp_mgmt_addr_tlv_print(tptr, tlv_len)) {
+            if (ndo->ndo_vflag) {
+                if (!lldp_mgmt_addr_tlv_print(ndo, tptr, tlv_len)) {
                     goto trunc;
                 }
             }
             break;
 
         case LLDP_PRIVATE_TLV:
-            if (vflag) {
+            if (ndo->ndo_vflag) {
                 if (tlv_len < 3) {
                     goto trunc;
                 }
                 oui = EXTRACT_24BITS(tptr);
-                printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui);
-                
+                ND_PRINT((ndo, ": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui));
+
                 switch (oui) {
                 case OUI_IEEE_8021_PRIVATE:
-                    hexdump = lldp_private_8021_print(tptr, tlv_len);
+                    hexdump = lldp_private_8021_print(ndo, tptr, tlv_len);
                     break;
                 case OUI_IEEE_8023_PRIVATE:
-                    hexdump = lldp_private_8023_print(tptr, tlv_len);
+                    hexdump = lldp_private_8023_print(ndo, tptr, tlv_len);
                     break;
                 case OUI_TIA:
-                    hexdump = lldp_private_tia_print(tptr, tlv_len);
+                    hexdump = lldp_private_tia_print(ndo, tptr, tlv_len);
                     break;
                 case OUI_DCBX:
-                    hexdump = lldp_private_dcbx_print(tptr, tlv_len);
+                    hexdump = lldp_private_dcbx_print(ndo, tptr, tlv_len);
                     break;
                 default:
                     hexdump = TRUE;
@@ -1585,8 +1593,8 @@
         }
 
         /* do we also want to see a hex dump ? */
-        if (vflag > 1 || (vflag && hexdump)) {
-            print_unknown_data(tptr,"\n\t  ", tlv_len);
+        if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+            print_unknown_data(ndo, tptr, "\n\t  ", tlv_len);
         }
 
         tlen -= tlv_len;
@@ -1594,7 +1602,7 @@
     }
     return;
  trunc:
-    printf("\n\t[|LLDP]");
+    ND_PRINT((ndo, "\n\t[|LLDP]"));
 }
 
 /*
diff --git a/print-lmp.c b/print-lmp.c
index c03e12e..904dd71 100644
--- a/print-lmp.c
+++ b/print-lmp.c
@@ -17,21 +17,13 @@
  * by Manu Pathak (mapathak@cisco.com), May 2005
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.11 2007-08-02 17:32:49 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -50,15 +42,15 @@
  */
 
 struct lmp_common_header {
-    u_int8_t version_res[2];
-    u_int8_t flags;   
-    u_int8_t msg_type;
-    u_int8_t length[2];
-    u_int8_t reserved[2];
+    uint8_t version_res[2];
+    uint8_t flags;
+    uint8_t msg_type;
+    uint8_t length[2];
+    uint8_t reserved[2];
 };
 
 #define LMP_VERSION            1
-#define	LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) 
+#define	LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
 
 static const struct tok lmp_header_flag_values[] = {
     { 0x01, "Control Channel Down"},
@@ -205,7 +197,7 @@
     { 0, NULL}
 };
 
-/* 
+/*
  * LMP object header
  *
  *  0                   1                   2                   3
@@ -216,20 +208,20 @@
  * |                                                               |
  * //                       (object contents)                     //
  * |                                                               |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
 struct lmp_object_header {
-    u_int8_t ctype;
-    u_int8_t class_num;
-    u_int8_t length[2];
+    uint8_t ctype;
+    uint8_t class_num;
+    uint8_t length[2];
 };
 
 #define	LMP_OBJ_CC_ID                 1
 #define	LMP_OBJ_NODE_ID               2
 #define	LMP_OBJ_LINK_ID               3
 #define	LMP_OBJ_INTERFACE_ID          4
-#define	LMP_OBJ_MESSAGE_ID            5 
+#define	LMP_OBJ_MESSAGE_ID            5
 #define	LMP_OBJ_CONFIG                6
 #define	LMP_OBJ_HELLO                 7
 #define	LMP_OBJ_VERIFY_BEGIN          8
@@ -279,13 +271,13 @@
 #define	LMP_CTYPE_LOC        1
 #define	LMP_CTYPE_RMT        2
 #define	LMP_CTYPE_UNMD       3
- 
+
 #define	LMP_CTYPE_IPV4_LOC   1
 #define	LMP_CTYPE_IPV4_RMT   2
 #define	LMP_CTYPE_IPV6_LOC   3
 #define	LMP_CTYPE_IPV6_RMT   4
-#define	LMP_CTYPE_UNMD_LOC   5  
-#define	LMP_CTYPE_UNMD_RMT   6 
+#define	LMP_CTYPE_UNMD_LOC   5
+#define	LMP_CTYPE_UNMD_RMT   6
 
 #define	LMP_CTYPE_1          1
 #define	LMP_CTYPE_2          2
@@ -302,7 +294,7 @@
 #define LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM     3
 #define LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY    4
 
-/* 
+/*
  * Different link types allowed in the Client Port Service Attributes
  * subobject defined for LMP Service Discovery in the UNI 1.0 spec
  */
@@ -361,8 +353,9 @@
 };
 
 void
-lmp_print(register const u_char *pptr, register u_int len) {
-
+lmp_print(netdissect_options *ndo,
+          register const u_char *pptr, register u_int len)
+{
     const struct lmp_common_header *lmp_com_header;
     const struct lmp_object_header *lmp_obj_header;
     const u_char *tptr,*obj_tptr;
@@ -372,29 +365,29 @@
     int link_type;
 
     union { /* int to float conversion buffer */
-        float f; 
-        u_int32_t i;
+        float f;
+        uint32_t i;
     } bw;
 
     tptr=pptr;
     lmp_com_header = (const struct lmp_common_header *)pptr;
-    TCHECK(*lmp_com_header);
+    ND_TCHECK(*lmp_com_header);
 
     /*
      * Sanity checking of the header.
      */
     if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) {
-	printf("LMP version %u packet not supported",
-               LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]));
+	ND_PRINT((ndo, "LMP version %u packet not supported",
+               LMP_EXTRACT_VERSION(lmp_com_header->version_res[0])));
 	return;
     }
 
     /* in non-verbose mode just lets print the basic Message Type*/
-    if (vflag < 1) {
-        printf("LMPv%u %s Message, length: %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "LMPv%u %s Message, length: %u",
                LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
                tok2str(lmp_msg_type_values, "unknown (%u)",lmp_com_header->msg_type),
-               len);
+               len));
         return;
     }
 
@@ -402,19 +395,18 @@
 
     tlen=EXTRACT_16BITS(lmp_com_header->length);
 
-    printf("\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
+    ND_PRINT((ndo, "\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
            LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
            tok2str(lmp_msg_type_values, "unknown, type: %u",lmp_com_header->msg_type),
            bittok2str(lmp_header_flag_values,"none",lmp_com_header->flags),
-           tlen);
+           tlen));
 
     tptr+=sizeof(const struct lmp_common_header);
     tlen-=sizeof(const struct lmp_common_header);
 
     while(tlen>0) {
         /* did we capture enough for fully decoding the object header ? */
-        if (!TTEST2(*tptr, sizeof(struct lmp_object_header)))
-            goto trunc;
+        ND_TCHECK2(*tptr, sizeof(struct lmp_object_header));
 
         lmp_obj_header = (const struct lmp_object_header *)tptr;
         lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length);
@@ -423,7 +415,7 @@
         if(lmp_obj_len % 4 || lmp_obj_len < 4)
             return;
 
-        printf("\n\t  %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
+        ND_PRINT((ndo, "\n\t  %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
                tok2str(lmp_obj_values,
                        "Unknown",
                        lmp_obj_header->class_num),
@@ -433,14 +425,13 @@
                        ((lmp_obj_header->class_num)<<8)+lmp_obj_ctype),
                lmp_obj_ctype,
                (lmp_obj_header->ctype)&0x80 ? "" : "non-",
-               lmp_obj_len);
+               lmp_obj_len));
 
         obj_tptr=tptr+sizeof(struct lmp_object_header);
         obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header);
 
         /* did we capture enough for fully decoding the object ? */
-        if (!TTEST2(*tptr, lmp_obj_len))
-            goto trunc;
+        ND_TCHECK2(*tptr, lmp_obj_len);
         hexdump=FALSE;
 
         switch(lmp_obj_header->class_num) {
@@ -449,9 +440,9 @@
             switch(lmp_obj_ctype) {
             case LMP_CTYPE_LOC:
             case LMP_CTYPE_RMT:
-                printf("\n\t    Control Channel ID: %u (0x%08x)",
+                ND_PRINT((ndo, "\n\t    Control Channel ID: %u (0x%08x)",
                        EXTRACT_32BITS(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr));
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
 
             default:
@@ -464,23 +455,23 @@
             switch(lmp_obj_ctype) {
             case LMP_CTYPE_IPV4_LOC:
             case LMP_CTYPE_IPV4_RMT:
-                printf("\n\t    IPv4 Link ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr));
+                ND_PRINT((ndo, "\n\t    IPv4 Link ID: %s (0x%08x)",
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
 #ifdef INET6
             case LMP_CTYPE_IPV6_LOC:
             case LMP_CTYPE_IPV6_RMT:
-                printf("\n\t    IPv6 Link ID: %s (0x%08x)",
-                       ip6addr_string(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr));
+                ND_PRINT((ndo, "\n\t    IPv6 Link ID: %s (0x%08x)",
+                       ip6addr_string(ndo, obj_tptr),
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
 #endif
             case LMP_CTYPE_UNMD_LOC:
             case LMP_CTYPE_UNMD_RMT:
-                printf("\n\t    Link ID: %u (0x%08x)",
+                ND_PRINT((ndo, "\n\t    Link ID: %u (0x%08x)",
                        EXTRACT_32BITS(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr));
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
             default:
                 hexdump=TRUE;
@@ -490,14 +481,14 @@
         case LMP_OBJ_MESSAGE_ID:
             switch(lmp_obj_ctype) {
             case LMP_CTYPE_1:
-                printf("\n\t    Message ID: %u (0x%08x)",
+                ND_PRINT((ndo, "\n\t    Message ID: %u (0x%08x)",
                        EXTRACT_32BITS(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr));
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
             case LMP_CTYPE_2:
-                printf("\n\t    Message ID Ack: %u (0x%08x)",
+                ND_PRINT((ndo, "\n\t    Message ID Ack: %u (0x%08x)",
                        EXTRACT_32BITS(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr));
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
             default:
                 hexdump=TRUE;
@@ -508,9 +499,9 @@
             switch(lmp_obj_ctype) {
             case LMP_CTYPE_LOC:
             case LMP_CTYPE_RMT:
-                printf("\n\t    Node ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr));
+                ND_PRINT((ndo, "\n\t    Node ID: %s (0x%08x)",
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
 
             default:
@@ -521,45 +512,45 @@
         case LMP_OBJ_CONFIG:
             switch(lmp_obj_ctype) {
             case LMP_CTYPE_HELLO_CONFIG:
-                printf("\n\t    Hello Interval: %u\n\t    Hello Dead Interval: %u",
+                ND_PRINT((ndo, "\n\t    Hello Interval: %u\n\t    Hello Dead Interval: %u",
                        EXTRACT_16BITS(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+2));
+                       EXTRACT_16BITS(obj_tptr+2)));
                 break;
 
             default:
                 hexdump=TRUE;
             }
             break;
-	
+
         case LMP_OBJ_HELLO:
             switch(lmp_obj_ctype) {
 	    case LMP_CTYPE_HELLO:
-                printf("\n\t    Tx Seq: %u, Rx Seq: %u",
+                ND_PRINT((ndo, "\n\t    Tx Seq: %u, Rx Seq: %u",
                        EXTRACT_32BITS(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr+4));
+                       EXTRACT_32BITS(obj_tptr+4)));
                 break;
 
             default:
                 hexdump=TRUE;
             }
-            break;      
-	    
+            break;
+
         case LMP_OBJ_TE_LINK:
-		printf("\n\t    Flags: [%s]",
+		ND_PRINT((ndo, "\n\t    Flags: [%s]",
 		bittok2str(lmp_obj_te_link_flag_values,
 			"none",
-			EXTRACT_16BITS(obj_tptr)>>8));
-            
+			EXTRACT_16BITS(obj_tptr)>>8)));
+
 	    switch(lmp_obj_ctype) {
 	    case LMP_CTYPE_IPV4:
-		printf("\n\t    Local Link-ID: %s (0x%08x)"
+		ND_PRINT((ndo, "\n\t    Local Link-ID: %s (0x%08x)"
 		       "\n\t    Remote Link-ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr+4),
+                       ipaddr_string(ndo, obj_tptr+4),
                        EXTRACT_32BITS(obj_tptr+4),
-                       ipaddr_string(obj_tptr+8),
-                       EXTRACT_32BITS(obj_tptr+8));
+                       ipaddr_string(ndo, obj_tptr+8),
+                       EXTRACT_32BITS(obj_tptr+8)));
 		break;
-		
+
 #ifdef INET6
 	    case LMP_CTYPE_IPV6:
 #endif
@@ -568,56 +559,56 @@
                 hexdump=TRUE;
             }
             break;
-	
+
         case LMP_OBJ_DATA_LINK:
-		printf("\n\t    Flags: [%s]",
+		ND_PRINT((ndo, "\n\t    Flags: [%s]",
 		bittok2str(lmp_obj_data_link_flag_values,
 			"none",
-			EXTRACT_16BITS(obj_tptr)>>8));
-            
+			EXTRACT_16BITS(obj_tptr)>>8)));
+
 	    switch(lmp_obj_ctype) {
 	    case LMP_CTYPE_IPV4:
 	    case LMP_CTYPE_UNMD:
-                printf("\n\t    Local Interface ID: %s (0x%08x)"
+                ND_PRINT((ndo, "\n\t    Local Interface ID: %s (0x%08x)"
                        "\n\t    Remote Interface ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr+4),
+                       ipaddr_string(ndo, obj_tptr+4),
                        EXTRACT_32BITS(obj_tptr+4),
-                       ipaddr_string(obj_tptr+8),
-                       EXTRACT_32BITS(obj_tptr+8));
-		
-		total_subobj_len = lmp_obj_len - 16;	 
+                       ipaddr_string(ndo, obj_tptr+8),
+                       EXTRACT_32BITS(obj_tptr+8)));
+
+		total_subobj_len = lmp_obj_len - 16;
 		offset = 12;
 		while (total_subobj_len > 0 && hexdump == FALSE ) {
 			subobj_type = EXTRACT_16BITS(obj_tptr+offset)>>8;
 			subobj_len  = EXTRACT_16BITS(obj_tptr+offset)&0x00FF;
-			printf("\n\t    Subobject, Type: %s (%u), Length: %u",
+			ND_PRINT((ndo, "\n\t    Subobject, Type: %s (%u), Length: %u",
 				tok2str(lmp_data_link_subobj,
 					"Unknown",
 					subobj_type),
 					subobj_type,
-					subobj_len);
+					subobj_len));
 			switch(subobj_type) {
 			case INT_SWITCHING_TYPE_SUBOBJ:
-				printf("\n\t      Switching Type: %s (%u)",
-					tok2str(gmpls_switch_cap_values, 
-						"Unknown", 
+				ND_PRINT((ndo, "\n\t      Switching Type: %s (%u)",
+					tok2str(gmpls_switch_cap_values,
+						"Unknown",
 						EXTRACT_16BITS(obj_tptr+offset+2)>>8),
-					EXTRACT_16BITS(obj_tptr+offset+2)>>8);
-				printf("\n\t      Encoding Type: %s (%u)",
-					tok2str(gmpls_encoding_values, 
-						"Unknown", 
+					EXTRACT_16BITS(obj_tptr+offset+2)>>8));
+				ND_PRINT((ndo, "\n\t      Encoding Type: %s (%u)",
+					tok2str(gmpls_encoding_values,
+						"Unknown",
 						EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF),
-					EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF);
+					EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF));
 				bw.i = EXTRACT_32BITS(obj_tptr+offset+4);
-				printf("\n\t      Min Reservable Bandwidth: %.3f Mbps",
-                                       bw.f*8/1000000);
+				ND_PRINT((ndo, "\n\t      Min Reservable Bandwidth: %.3f Mbps",
+                                       bw.f*8/1000000));
 				bw.i = EXTRACT_32BITS(obj_tptr+offset+8);
-				printf("\n\t      Max Reservable Bandwidth: %.3f Mbps",
-                                       bw.f*8/1000000);
-				break;	
+				ND_PRINT((ndo, "\n\t      Max Reservable Bandwidth: %.3f Mbps",
+                                       bw.f*8/1000000));
+				break;
 			case WAVELENGTH_SUBOBJ:
-				printf("\n\t      Wavelength: %u",
-					EXTRACT_32BITS(obj_tptr+offset+4));
+				ND_PRINT((ndo, "\n\t      Wavelength: %u",
+					EXTRACT_32BITS(obj_tptr+offset+4)));
 				break;
 			default:
 				/* Any Unknown Subobject ==> Exit loop */
@@ -627,70 +618,70 @@
 			total_subobj_len-=subobj_len;
 			offset+=subobj_len;
 		}
-		
+
 		break;
-#ifdef INET6   
+#ifdef INET6
 	    case LMP_CTYPE_IPV6:
 #endif
             default:
                 hexdump=TRUE;
             }
-            break;      
-	    
+            break;
+
         case LMP_OBJ_VERIFY_BEGIN:
 	    switch(lmp_obj_ctype) {
             case LMP_CTYPE_1:
-		printf("\n\t    Flags: %s",
+		ND_PRINT((ndo, "\n\t    Flags: %s",
 		bittok2str(lmp_obj_begin_verify_flag_values,
 			"none",
-			EXTRACT_16BITS(obj_tptr)));
-		printf("\n\t    Verify Interval: %u",
-			EXTRACT_16BITS(obj_tptr+2));
-		printf("\n\t    Data links: %u",
-			EXTRACT_32BITS(obj_tptr+4));
-                printf("\n\t    Encoding type: %s",
-			tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8)));
-                printf("\n\t    Verify Transport Mechanism: %u (0x%x)%s",
+			EXTRACT_16BITS(obj_tptr))));
+		ND_PRINT((ndo, "\n\t    Verify Interval: %u",
+			EXTRACT_16BITS(obj_tptr+2)));
+		ND_PRINT((ndo, "\n\t    Data links: %u",
+			EXTRACT_32BITS(obj_tptr+4)));
+                ND_PRINT((ndo, "\n\t    Encoding type: %s",
+			tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8))));
+                ND_PRINT((ndo, "\n\t    Verify Transport Mechanism: %u (0x%x)%s",
 			EXTRACT_16BITS(obj_tptr+10),
 			EXTRACT_16BITS(obj_tptr+10),
-			EXTRACT_16BITS(obj_tptr+10)&8000 ? " (Payload test messages capable)" : "");
+			EXTRACT_16BITS(obj_tptr+10)&8000 ? " (Payload test messages capable)" : ""));
                 bw.i = EXTRACT_32BITS(obj_tptr+12);
-		printf("\n\t    Transmission Rate: %.3f Mbps",bw.f*8/1000000);
-		printf("\n\t    Wavelength: %u",
-			EXTRACT_32BITS(obj_tptr+16));
+		ND_PRINT((ndo, "\n\t    Transmission Rate: %.3f Mbps",bw.f*8/1000000));
+		ND_PRINT((ndo, "\n\t    Wavelength: %u",
+			EXTRACT_32BITS(obj_tptr+16)));
 		break;
-		
+
             default:
                 hexdump=TRUE;
             }
-            break;      
-	
+            break;
+
         case LMP_OBJ_VERIFY_BEGIN_ACK:
 	    switch(lmp_obj_ctype) {
             case LMP_CTYPE_1:
-                printf("\n\t    Verify Dead Interval: %u"
+                ND_PRINT((ndo, "\n\t    Verify Dead Interval: %u"
                        "\n\t    Verify Transport Response: %u",
                        EXTRACT_16BITS(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+2));
+                       EXTRACT_16BITS(obj_tptr+2)));
                 break;
-		
+
             default:
                 hexdump=TRUE;
             }
-            break;      
-        
+            break;
+
 	case LMP_OBJ_VERIFY_ID:
 	    switch(lmp_obj_ctype) {
             case LMP_CTYPE_1:
-                printf("\n\t    Verify ID: %u",
-                       EXTRACT_32BITS(obj_tptr));
+                ND_PRINT((ndo, "\n\t    Verify ID: %u",
+                       EXTRACT_32BITS(obj_tptr)));
                 break;
-		
+
             default:
                 hexdump=TRUE;
             }
-            break;      
-        
+            break;
+
 	case LMP_OBJ_CHANNEL_STATUS:
             switch(lmp_obj_ctype) {
 	    case LMP_CTYPE_IPV4:
@@ -698,164 +689,164 @@
 		offset = 0;
 		/* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> */
 		while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
-			printf("\n\t    Interface ID: %s (0x%08x)",
-			ipaddr_string(obj_tptr+offset),
-			EXTRACT_32BITS(obj_tptr+offset));
-			
-			printf("\n\t\t    Active: %s (%u)", 		(EXTRACT_32BITS(obj_tptr+offset+4)>>31) ? 
+			ND_PRINT((ndo, "\n\t    Interface ID: %s (0x%08x)",
+			ipaddr_string(ndo, obj_tptr+offset),
+			EXTRACT_32BITS(obj_tptr+offset)));
+
+			ND_PRINT((ndo, "\n\t\t    Active: %s (%u)", 		(EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?
 						"Allocated" : "Non-allocated",
-				(EXTRACT_32BITS(obj_tptr+offset+4)>>31));
-			
-			printf("\n\t\t    Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ? 
+				(EXTRACT_32BITS(obj_tptr+offset+4)>>31)));
+
+			ND_PRINT((ndo, "\n\t\t    Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?
 						"Transmit" : "Receive",
-				(EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1);	
-						
-			printf("\n\t\t    Channel Status: %s (%u)",
+				(EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1));
+
+			ND_PRINT((ndo, "\n\t\t    Channel Status: %s (%u)",
 					tok2str(lmp_obj_channel_status_values,
 			 		"Unknown",
 					EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF),
-			EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF);
+			EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF));
 			offset+=8;
 		}
                 break;
-#ifdef INET6       
+#ifdef INET6
 	    case LMP_CTYPE_IPV6:
 #endif
             default:
                 hexdump=TRUE;
             }
-            break;      
-        
+            break;
+
 	case LMP_OBJ_CHANNEL_STATUS_REQ:
             switch(lmp_obj_ctype) {
 	    case LMP_CTYPE_IPV4:
 	    case LMP_CTYPE_UNMD:
 		offset = 0;
 		while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
-			printf("\n\t    Interface ID: %s (0x%08x)",
-			ipaddr_string(obj_tptr+offset),
-			EXTRACT_32BITS(obj_tptr+offset));
+			ND_PRINT((ndo, "\n\t    Interface ID: %s (0x%08x)",
+			ipaddr_string(ndo, obj_tptr+offset),
+			EXTRACT_32BITS(obj_tptr+offset)));
 			offset+=4;
 		}
                 break;
-#ifdef INET6       
+#ifdef INET6
 	    case LMP_CTYPE_IPV6:
 #endif
 	    default:
                 hexdump=TRUE;
             }
-            break;      
-	
+            break;
+
         case LMP_OBJ_ERROR_CODE:
 	    switch(lmp_obj_ctype) {
             case LMP_CTYPE_BEGIN_VERIFY_ERROR:
-		printf("\n\t    Error Code: %s",
+		ND_PRINT((ndo, "\n\t    Error Code: %s",
 		bittok2str(lmp_obj_begin_verify_error_values,
 			"none",
-			EXTRACT_32BITS(obj_tptr)));
+			EXTRACT_32BITS(obj_tptr))));
                 break;
-		
+
             case LMP_CTYPE_LINK_SUMMARY_ERROR:
-		printf("\n\t    Error Code: %s",
+		ND_PRINT((ndo, "\n\t    Error Code: %s",
 		bittok2str(lmp_obj_link_summary_error_values,
 			"none",
-			EXTRACT_32BITS(obj_tptr)));
+			EXTRACT_32BITS(obj_tptr))));
                 break;
             default:
                 hexdump=TRUE;
             }
-            break;      
+            break;
 
 	case LMP_OBJ_SERVICE_CONFIG:
 	    switch (lmp_obj_ctype) {
 	    case LMP_CTYPE_SERVICE_CONFIG_SP:
-		
-		printf("\n\t Flags: %s",
-		       bittok2str(lmp_obj_service_config_sp_flag_values,
-				  "none", 
-				  EXTRACT_16BITS(obj_tptr)>>8));
 
-		printf("\n\t  UNI Version: %u",
-		       EXTRACT_16BITS(obj_tptr) & 0x00FF);
+		ND_PRINT((ndo, "\n\t Flags: %s",
+		       bittok2str(lmp_obj_service_config_sp_flag_values,
+				  "none",
+				  EXTRACT_16BITS(obj_tptr)>>8)));
+
+		ND_PRINT((ndo, "\n\t  UNI Version: %u",
+		       EXTRACT_16BITS(obj_tptr) & 0x00FF));
 
 		break;
-		
+
             case LMP_CTYPE_SERVICE_CONFIG_CPSA:
-		
+
 		link_type = EXTRACT_16BITS(obj_tptr)>>8;
-		
-		printf("\n\t Link Type: %s (%u)",
+
+		ND_PRINT((ndo, "\n\t Link Type: %s (%u)",
 		       tok2str(lmp_sd_service_config_cpsa_link_type_values,
 			       "Unknown", link_type),
-		       link_type);
-		
+		       link_type));
+
 		if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH) {
-		    printf("\n\t Signal Type: %s (%u)",
+		    ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
 			   tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values,
 				   "Unknown",
 				   EXTRACT_16BITS(obj_tptr) & 0x00FF),
-			   EXTRACT_16BITS(obj_tptr) & 0x00FF);
+			   EXTRACT_16BITS(obj_tptr) & 0x00FF));
 		}
-		
+
 		if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET) {
-		    printf("\n\t Signal Type: %s (%u)",
+		    ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
 			   tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values,
 				   "Unknown",
 				   EXTRACT_16BITS(obj_tptr) & 0x00FF),
-			   EXTRACT_16BITS(obj_tptr) & 0x00FF);
+			   EXTRACT_16BITS(obj_tptr) & 0x00FF));
 		}
-		
-		printf("\n\t Transparency: %s",
+
+		ND_PRINT((ndo, "\n\t Transparency: %s",
 		       bittok2str(lmp_obj_service_config_cpsa_tp_flag_values,
 				  "none",
-				  EXTRACT_16BITS(obj_tptr+2)>>8));
-		
-		printf("\n\t Contiguous Concatenation Types: %s",
+				  EXTRACT_16BITS(obj_tptr+2)>>8)));
+
+		ND_PRINT((ndo, "\n\t Contiguous Concatenation Types: %s",
 		       bittok2str(lmp_obj_service_config_cpsa_cct_flag_values,
 				  "none",
-				  EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF));
-		
-		printf("\n\t Minimum NCC: %u",
-		       EXTRACT_16BITS(obj_tptr+4));
-		
-		printf("\n\t Maximum NCC: %u",
-		       EXTRACT_16BITS(obj_tptr+6));
-		
-		printf("\n\t Minimum NVC:%u",
-		       EXTRACT_16BITS(obj_tptr+8));
-		
-		printf("\n\t Maximum NVC:%u",
-		       EXTRACT_16BITS(obj_tptr+10));
-		
-		printf("\n\t    Local Interface ID: %s (0x%08x)",
-		       ipaddr_string(obj_tptr+12),
-		       EXTRACT_32BITS(obj_tptr+12));
-		
+				  EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF)));
+
+		ND_PRINT((ndo, "\n\t Minimum NCC: %u",
+		       EXTRACT_16BITS(obj_tptr+4)));
+
+		ND_PRINT((ndo, "\n\t Maximum NCC: %u",
+		       EXTRACT_16BITS(obj_tptr+6)));
+
+		ND_PRINT((ndo, "\n\t Minimum NVC:%u",
+		       EXTRACT_16BITS(obj_tptr+8)));
+
+		ND_PRINT((ndo, "\n\t Maximum NVC:%u",
+		       EXTRACT_16BITS(obj_tptr+10)));
+
+		ND_PRINT((ndo, "\n\t    Local Interface ID: %s (0x%08x)",
+		       ipaddr_string(ndo, obj_tptr+12),
+		       EXTRACT_32BITS(obj_tptr+12)));
+
 		break;
-		
+
 	    case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM:
-		
-		printf("\n\t Transparency Flags: %s",
+
+		ND_PRINT((ndo, "\n\t Transparency Flags: %s",
 		       bittok2str(
 			   lmp_obj_service_config_nsa_transparency_flag_values,
 			   "none",
-			   EXTRACT_32BITS(obj_tptr)));
+			   EXTRACT_32BITS(obj_tptr))));
 
-		printf("\n\t TCM Monitoring Flags: %s",
+		ND_PRINT((ndo, "\n\t TCM Monitoring Flags: %s",
 		       bittok2str(
 			   lmp_obj_service_config_nsa_tcm_flag_values,
 			   "none",
-			   EXTRACT_16BITS(obj_tptr+6) & 0x00FF));
-		
+			   EXTRACT_16BITS(obj_tptr+6) & 0x00FF)));
+
 		break;
-		
+
 	    case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY:
-		
-		printf("\n\t Diversity: Flags: %s",
+
+		ND_PRINT((ndo, "\n\t Diversity: Flags: %s",
 		       bittok2str(
 			   lmp_obj_service_config_nsa_network_diversity_flag_values,
 			   "none",
-			   EXTRACT_16BITS(obj_tptr+2) & 0x00FF));
+			   EXTRACT_16BITS(obj_tptr+2) & 0x00FF)));
 		break;
 
 	    default:
@@ -865,13 +856,13 @@
 	break;
 
         default:
-            if (vflag <= 1)
-                print_unknown_data(obj_tptr,"\n\t    ",obj_tlen);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo,obj_tptr,"\n\t    ",obj_tlen);
             break;
         }
         /* do we want to see an additionally hexdump ? */
-        if (vflag > 1 || hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(struct lmp_object_header),"\n\t    ",
+        if (ndo->ndo_vflag > 1 || hexdump==TRUE)
+            print_unknown_data(ndo,tptr+sizeof(struct lmp_object_header),"\n\t    ",
                                lmp_obj_len-sizeof(struct lmp_object_header));
 
         tptr+=lmp_obj_len;
@@ -879,5 +870,11 @@
     }
     return;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-loopback.c b/print-loopback.c
new file mode 100644
index 0000000..9a74ae6
--- /dev/null
+++ b/print-loopback.c
@@ -0,0 +1,136 @@
+/*
+ * This module implements decoding of the Loopback Protocol, originally
+ * defined as the Configuration Testing Protocol. It is based on the following
+ * specification:
+ * http://www.mit.edu/people/jhawk/ctp.pdf
+ *
+ * Copyright (c) 2014 The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "ether.h"
+#include "addrtoname.h"
+
+static const char tstr[] = " [|loopback]";
+static const char cstr[] = " (corrupt)";
+
+#define LOOPBACK_REPLY   1
+#define LOOPBACK_FWDDATA 2
+
+static const struct tok fcode_str[] = {
+	{ LOOPBACK_REPLY,   "Reply"        },
+	{ LOOPBACK_FWDDATA, "Forward Data" },
+	{ 0, NULL }
+};
+
+static void
+loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint16_t function;
+
+	if (len < 2)
+		goto corrupt;
+	/* function */
+	ND_TCHECK2(*cp, 2);
+	function = EXTRACT_LE_16BITS(cp);
+	cp += 2;
+	ND_PRINT((ndo, ", %s", tok2str(fcode_str, " invalid (%u)", function)));
+
+	switch (function) {
+		case LOOPBACK_REPLY:
+			if (len < 4)
+				goto corrupt;
+			/* receipt number */
+			ND_TCHECK2(*cp, 2);
+			ND_PRINT((ndo, ", receipt number %u", EXTRACT_LE_16BITS(cp)));
+			cp += 2;
+			/* data */
+			ND_PRINT((ndo, ", data (%u octets)", len - 4));
+			ND_TCHECK2(*cp, len - 4);
+			break;
+		case LOOPBACK_FWDDATA:
+			if (len < 8)
+				goto corrupt;
+			/* forwarding address */
+			ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+			ND_PRINT((ndo, ", forwarding address %s", etheraddr_string(ndo, cp)));
+			cp += ETHER_ADDR_LEN;
+			/* data */
+			ND_PRINT((ndo, ", data (%u octets)", len - 8));
+			ND_TCHECK2(*cp, len - 8);
+			break;
+		default:
+			ND_TCHECK2(*cp, len - 2);
+			break;
+	}
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+	const u_char *ep = cp + len;
+	uint16_t skipCount;
+
+	ND_PRINT((ndo, "Loopback"));
+	if (len < 2)
+		goto corrupt;
+	/* skipCount */
+	ND_TCHECK2(*cp, 2);
+	skipCount = EXTRACT_LE_16BITS(cp);
+	cp += 2;
+	ND_PRINT((ndo, ", skipCount %u", skipCount));
+	if (skipCount % 8)
+		ND_PRINT((ndo, " (bogus)"));
+	if (skipCount > len - 2)
+		goto corrupt;
+	loopback_message_print(ndo, cp + skipCount, len - 2 - skipCount);
+	return;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
+	return;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+}
+
diff --git a/print-lspping.c b/print-lspping.c
index 2ca57fb..888adfa 100644
--- a/print-lspping.c
+++ b/print-lspping.c
@@ -13,26 +13,17 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.20 2008-01-28 14:20:43 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 
-#include "bgp.h"
 #include "l2vpn.h"
 #include "oui.h"
 
@@ -65,18 +56,18 @@
  */
 
 struct lspping_common_header {
-    u_int8_t version[2];
-    u_int8_t reserved[2];
-    u_int8_t msg_type;
-    u_int8_t reply_mode;   
-    u_int8_t return_code;   
-    u_int8_t return_subcode;   
-    u_int8_t sender_handle[4];
-    u_int8_t seq_number[4];
-    u_int8_t ts_sent_sec[4];
-    u_int8_t ts_sent_usec[4];
-    u_int8_t ts_rcvd_sec[4];
-    u_int8_t ts_rcvd_usec[4];
+    uint8_t version[2];
+    uint8_t reserved[2];
+    uint8_t msg_type;
+    uint8_t reply_mode;
+    uint8_t return_code;
+    uint8_t return_subcode;
+    uint8_t sender_handle[4];
+    uint8_t seq_number[4];
+    uint8_t ts_sent_sec[4];
+    uint8_t ts_sent_usec[4];
+    uint8_t ts_rcvd_sec[4];
+    uint8_t ts_rcvd_usec[4];
 };
 
 #define LSPPING_VERSION            1
@@ -112,7 +103,7 @@
 };
 
 
-/* 
+/*
  * LSPPING TLV header
  *  0                   1                   2                   3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -128,8 +119,8 @@
  */
 
 struct lspping_tlv_header {
-    u_int8_t type[2];
-    u_int8_t length[2];
+    uint8_t type[2];
+    uint8_t length[2];
 };
 
 #define	LSPPING_TLV_TARGET_FEC_STACK      1
@@ -195,8 +186,8 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
-    u_int8_t prefix [4];
-    u_int8_t prefix_len;
+    uint8_t prefix [4];
+    uint8_t prefix_len;
 };
 
 /*
@@ -212,8 +203,8 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
-    u_int8_t prefix [16];
-    u_int8_t prefix_len;
+    uint8_t prefix [16];
+    uint8_t prefix_len;
 };
 
 /*
@@ -227,9 +218,9 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
-    u_int8_t sender_id [4];
-    u_int8_t prefix [4];
-    u_int8_t prefix_len;
+    uint8_t sender_id [4];
+    uint8_t prefix [4];
+    uint8_t prefix_len;
 };
 
 /*
@@ -249,9 +240,9 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
-    u_int8_t sender_id [16];
-    u_int8_t prefix [16];
-    u_int8_t prefix_len;
+    uint8_t sender_id [16];
+    uint8_t prefix [16];
+    uint8_t prefix_len;
 };
 
 /*
@@ -270,13 +261,13 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
-    u_int8_t tunnel_endpoint [4];
-    u_int8_t res[2];
-    u_int8_t tunnel_id[2];
-    u_int8_t extended_tunnel_id[4];
-    u_int8_t tunnel_sender [4];
-    u_int8_t res2[2];
-    u_int8_t lsp_id [2];
+    uint8_t tunnel_endpoint [4];
+    uint8_t res[2];
+    uint8_t tunnel_id[2];
+    uint8_t extended_tunnel_id[4];
+    uint8_t tunnel_sender [4];
+    uint8_t res2[2];
+    uint8_t lsp_id [2];
 };
 
 /*
@@ -304,13 +295,13 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
-    u_int8_t tunnel_endpoint [16];
-    u_int8_t res[2];
-    u_int8_t tunnel_id[2];
-    u_int8_t extended_tunnel_id[16];
-    u_int8_t tunnel_sender [16];
-    u_int8_t res2[2];
-    u_int8_t lsp_id [2];
+    uint8_t tunnel_endpoint [16];
+    uint8_t res[2];
+    uint8_t tunnel_id[2];
+    uint8_t extended_tunnel_id[16];
+    uint8_t tunnel_sender [16];
+    uint8_t res2[2];
+    uint8_t lsp_id [2];
 };
 
 /*
@@ -326,9 +317,9 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
-    u_int8_t rd [8];
-    u_int8_t prefix [4];
-    u_int8_t prefix_len;
+    uint8_t rd [8];
+    uint8_t prefix [4];
+    uint8_t prefix_len;
 };
 
 /*
@@ -347,9 +338,9 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
-    u_int8_t rd [8];
-    u_int8_t prefix [16];
-    u_int8_t prefix_len;
+    uint8_t rd [8];
+    uint8_t prefix [16];
+    uint8_t prefix_len;
 };
 
 /*
@@ -366,10 +357,10 @@
  *  0                   1                   2                   3
  */
 struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
-    u_int8_t rd [8];
-    u_int8_t sender_ce_id [2];
-    u_int8_t receiver_ce_id [2];
-    u_int8_t encapsulation[2];
+    uint8_t rd [8];
+    uint8_t sender_ce_id [2];
+    uint8_t receiver_ce_id [2];
+    uint8_t encapsulation[2];
 };
 
 /*
@@ -383,9 +374,9 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
-    u_int8_t remote_pe_address [4];
-    u_int8_t vc_id [4];
-    u_int8_t encapsulation[2];
+    uint8_t remote_pe_address [4];
+    uint8_t vc_id [4];
+    uint8_t encapsulation[2];
 };
 
 /*
@@ -401,10 +392,10 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
-    u_int8_t sender_pe_address [4];
-    u_int8_t remote_pe_address [4];
-    u_int8_t vc_id [4];
-    u_int8_t encapsulation[2];
+    uint8_t sender_pe_address [4];
+    uint8_t remote_pe_address [4];
+    uint8_t vc_id [4];
+    uint8_t encapsulation[2];
 };
 
 /*
@@ -433,25 +424,25 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lspping_tlv_downstream_map_ipv4_t {
-    u_int8_t mtu [2];
-    u_int8_t address_type;
-    u_int8_t res;
-    u_int8_t downstream_ip[4];
-    u_int8_t downstream_interface[4];
+    uint8_t mtu [2];
+    uint8_t address_type;
+    uint8_t res;
+    uint8_t downstream_ip[4];
+    uint8_t downstream_interface[4];
 };
 
 struct lspping_tlv_downstream_map_ipv6_t {
-    u_int8_t mtu [2];
-    u_int8_t address_type;
-    u_int8_t res;
-    u_int8_t downstream_ip[16];
-    u_int8_t downstream_interface[16];
+    uint8_t mtu [2];
+    uint8_t address_type;
+    uint8_t res;
+    uint8_t downstream_ip[16];
+    uint8_t downstream_interface[16];
 };
 
 struct lspping_tlv_downstream_map_info_t {
-    u_int8_t hash_key_type;
-    u_int8_t depth_limit;
-    u_int8_t multipath_length [2];
+    uint8_t hash_key_type;
+    uint8_t depth_limit;
+    uint8_t multipath_length [2];
 };
 
 #define LSPPING_AFI_IPV4 1
@@ -466,8 +457,9 @@
 };
 
 void
-lspping_print(register const u_char *pptr, register u_int len) {
-
+lspping_print(netdissect_options *ndo,
+              register const u_char *pptr, register u_int len)
+{
     const struct lspping_common_header *lspping_com_header;
     const struct lspping_tlv_header *lspping_tlv_header;
     const struct lspping_tlv_header *lspping_subtlv_header;
@@ -475,7 +467,7 @@
     int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
     int tlv_hexdump,subtlv_hexdump;
     int lspping_subtlv_len,lspping_subtlv_type;
-    struct timeval timestamp; 
+    struct timeval timestamp;
 
     union {
         const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4;
@@ -499,24 +491,24 @@
 
     tptr=pptr;
     lspping_com_header = (const struct lspping_common_header *)pptr;
-    TCHECK(*lspping_com_header);
+    ND_TCHECK(*lspping_com_header);
 
     /*
      * Sanity checking of the header.
      */
     if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
-	printf("LSP-PING version %u packet not supported",
-               EXTRACT_16BITS(&lspping_com_header->version[0]));
+	ND_PRINT((ndo, "LSP-PING version %u packet not supported",
+               EXTRACT_16BITS(&lspping_com_header->version[0])));
 	return;
     }
 
     /* in non-verbose mode just lets print the basic Message Type*/
-    if (vflag < 1) {
-        printf("LSP-PINGv%u, %s, seq %u, length: %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u",
                EXTRACT_16BITS(&lspping_com_header->version[0]),
                tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type),
                EXTRACT_32BITS(lspping_com_header->seq_number),
-               len);
+               len));
         return;
     }
 
@@ -524,13 +516,13 @@
 
     tlen=len;
 
-    printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t  reply-mode: %s (%u)",
+    ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t  reply-mode: %s (%u)",
            EXTRACT_16BITS(&lspping_com_header->version[0]),
            tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type),
            lspping_com_header->msg_type,
            len,
            tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode),
-           lspping_com_header->reply_mode);
+           lspping_com_header->reply_mode));
 
     /*
      *  the following return codes require that the subcode is attached
@@ -542,33 +534,33 @@
         lspping_com_header->return_code == 10 ||
         lspping_com_header->return_code == 11 ||
         lspping_com_header->return_code == 12 )
-        printf("\n\t  Return Code: %s %u (%u)\n\t  Return Subcode: (%u)",
+        ND_PRINT((ndo, "\n\t  Return Code: %s %u (%u)\n\t  Return Subcode: (%u)",
                tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
-               lspping_com_header->return_subcode,    
+               lspping_com_header->return_subcode,
                lspping_com_header->return_code,
-               lspping_com_header->return_subcode);
+               lspping_com_header->return_subcode));
     else
-        printf("\n\t  Return Code: %s (%u)\n\t  Return Subcode: (%u)",
-               tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),   
+        ND_PRINT((ndo, "\n\t  Return Code: %s (%u)\n\t  Return Subcode: (%u)",
+               tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
                lspping_com_header->return_code,
-               lspping_com_header->return_subcode);
- 
-    printf("\n\t  Sender Handle: 0x%08x, Sequence: %u",
+               lspping_com_header->return_subcode));
+
+    ND_PRINT((ndo, "\n\t  Sender Handle: 0x%08x, Sequence: %u",
            EXTRACT_32BITS(lspping_com_header->sender_handle),
-           EXTRACT_32BITS(lspping_com_header->seq_number));
+           EXTRACT_32BITS(lspping_com_header->seq_number)));
 
     timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
-    timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);     
-    printf("\n\t  Sender Timestamp: ");
-    ts_print(&timestamp);
+    timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
+    ND_PRINT((ndo, "\n\t  Sender Timestamp: "));
+    ts_print(ndo, &timestamp);
 
     timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
-    timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec); 
-    printf("Receiver Timestamp: ");
+    timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
+    ND_PRINT((ndo, "Receiver Timestamp: "));
     if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
-        ts_print(&timestamp);
+        ts_print(ndo, &timestamp);
     else
-        printf("no timestamp");
+        ND_PRINT((ndo, "no timestamp"));
 
     tptr+=sizeof(const struct lspping_common_header);
     tlen-=sizeof(const struct lspping_common_header);
@@ -576,8 +568,7 @@
     while(tlen>(int)sizeof(struct lspping_tlv_header)) {
 
         /* did we capture enough for fully decoding the tlv header ? */
-        if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
-            goto trunc;
+        ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
 
         lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
         lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type);
@@ -588,23 +579,22 @@
             return;
 
         if(lspping_tlv_len < 4) {
-            printf("\n\t  ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len);
+            ND_PRINT((ndo, "\n\t  ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len));
             return;
         }
 
-        printf("\n\t  %s TLV (%u), length: %u",
+        ND_PRINT((ndo, "\n\t  %s TLV (%u), length: %u",
                tok2str(lspping_tlv_values,
                        "Unknown",
                        lspping_tlv_type),
                lspping_tlv_type,
-               lspping_tlv_len);
+               lspping_tlv_len));
 
         tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
         tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
 
         /* did we capture enough for fully decoding the tlv ? */
-        if (!TTEST2(*tptr, lspping_tlv_len))
-            goto trunc;
+        ND_TCHECK2(*tptr, lspping_tlv_len);
         tlv_hexdump=FALSE;
 
         switch(lspping_tlv_type) {
@@ -612,154 +602,153 @@
             while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) {
 
                 /* did we capture enough for fully decoding the subtlv header ? */
-                if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
-                    goto trunc;
+                ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
                 subtlv_hexdump=FALSE;
 
                 lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
                 lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
                 lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
                 subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
-                
+
                 if (lspping_subtlv_len == 0)
                     break;
 
-                printf("\n\t    %s subTLV (%u), length: %u",
+                ND_PRINT((ndo, "\n\t    %s subTLV (%u), length: %u",
                        tok2str(lspping_tlvtargetfec_subtlv_values,
                                "Unknown",
                                lspping_subtlv_type),
                        lspping_subtlv_type,
-                       lspping_subtlv_len);
+                       lspping_subtlv_len));
 
                 switch(lspping_subtlv_type) {
 
                 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
                         (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
-                    printf("\n\t      %s/%u",
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
-                           subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len);
+                    ND_PRINT((ndo, "\n\t      %s/%u",
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
+                           subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
                     break;
 
 #ifdef INET6
                 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
                         (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
-                    printf("\n\t      %s/%u",
-                           ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
-                           subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len);
+                    ND_PRINT((ndo, "\n\t      %s/%u",
+                           ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
+                           subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
                     break;
 #endif
 
                 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
                         (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
-                    printf("\n\t      %s/%u, sender-id %s",
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
+                    ND_PRINT((ndo, "\n\t      %s/%u, sender-id %s",
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
                            subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id));
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)));
                     break;
 
 #ifdef INET6
                 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
                         (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
-                    printf("\n\t      %s/%u, sender-id %s",
-                           ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
+                    ND_PRINT((ndo, "\n\t      %s/%u, sender-id %s",
+                           ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
                            subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
-                           ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id));
+                           ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)));
                     break;
 #endif
 
                 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
                         (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
-                    printf("\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
+                    ND_PRINT((ndo, "\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
                            "\n\t      tunnel-id 0x%04x, extended tunnel-id %s",
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id));
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
                     break;
 
 #ifdef INET6
                 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
                         (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
-                    printf("\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
+                    ND_PRINT((ndo, "\n\t      tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
                            "\n\t      tunnel-id 0x%04x, extended tunnel-id %s",
-                           ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
-                           ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
+                           ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
+                           ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
-                           ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id));
+                           ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
                     break;
 #endif
 
                 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
                         (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
-                    printf("\n\t      RD: %s, %s/%u",
-                           bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
-                           subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len);
+                    ND_PRINT((ndo, "\n\t      RD: %s, %s/%u",
+                           bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
+                           subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
                     break;
 
 #ifdef INET6
                 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
                         (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
-                    printf("\n\t      RD: %s, %s/%u",
-                           bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
-                           ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
-                           subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len);
+                    ND_PRINT((ndo, "\n\t      RD: %s, %s/%u",
+                           bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
+                           ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
+                           subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
                     break;
 #endif
 
                 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
                         (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
-                    printf("\n\t      RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
+                    ND_PRINT((ndo, "\n\t      RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
                            "\n\t      Encapsulation Type: %s (%u)",
-                           bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
+                           bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id),
                            EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id),
                            tok2str(l2vpn_encaps_values,
                                    "unknown",
                                    EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
-                           EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation));
-                    
+                           EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)));
+
                     break;
 
                     /* the old L2VPN VCID subTLV does not have support for the sender field */
                 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
                         (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr;
-                    printf("\n\t      Remote PE: %s" \
+                    ND_PRINT((ndo, "\n\t      Remote PE: %s" \
                            "\n\t      VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
                            EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id),
                            tok2str(l2vpn_encaps_values,
                                    "unknown",
                                    EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)),
-                           EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation));
-                    
+                           EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)));
+
                     break;
 
                 case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID:
                     subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
                         (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr;
-                    printf("\n\t      Sender PE: %s, Remote PE: %s" \
+                    ND_PRINT((ndo, "\n\t      Sender PE: %s, Remote PE: %s" \
                            "\n\t      VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
-                           ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
+                           ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
                            EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id),
                            tok2str(l2vpn_encaps_values,
                                    "unknown",
                                    EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)),
-                           EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation));
-                    
+                           EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)));
+
                     break;
 
                 default:
@@ -767,8 +756,8 @@
                     break;
                 }
                 /* do we want to see an additionally subtlv hexdump ? */
-                if (vflag > 1 || subtlv_hexdump==TRUE)
-                    print_unknown_data(tlv_tptr+sizeof(struct lspping_tlv_header), \
+                if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
+                    print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \
                                        "\n\t      ",
                                        lspping_subtlv_len);
 
@@ -779,45 +768,45 @@
 
         case LSPPING_TLV_DOWNSTREAM_MAPPING:
             /* that strange thing with the downstream map TLV is that until now
-             * we do not know if its IPv4 or IPv6 , after we found the adress-type
+             * we do not know if its IPv4 or IPv6 , after we found the address-type
              * lets recast the tlv_tptr and move on */
 
             tlv_ptr.lspping_tlv_downstream_map_ipv4= \
                 (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
             tlv_ptr.lspping_tlv_downstream_map_ipv6= \
                 (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
-            printf("\n\t    MTU: %u, Address-Type: %s (%u)",
+            ND_PRINT((ndo, "\n\t    MTU: %u, Address-Type: %s (%u)",
                    EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu),
                    tok2str(lspping_tlv_downstream_addr_values,
                            "unknown",
                            tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type),
-                   tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type);
+                   tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type));
 
             switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) {
 
             case LSPPING_AFI_IPV4:
-                printf("\n\t    Downstream IP: %s" \
+                ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
                        "\n\t    Downstream Interface IP: %s",
-                       ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
-                       ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface));
+                       ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
+                       ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
                 break;
 #ifdef INET6
              case LSPPING_AFI_IPV6:
-                printf("\n\t    Downstream IP: %s" \
+                ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
                        "\n\t    Downstream Interface IP: %s",
-                       ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
-                       ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface));
+                       ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
+                       ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)));
                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
                 break;
 #endif
             case LSPPING_AFI_UNMB:
-                printf("\n\t    Downstream IP: %s" \
+                ND_PRINT((ndo, "\n\t    Downstream IP: %s" \
                        "\n\t    Downstream Interface Index: 0x%08x",
-                       ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
-                       EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface));
+                       ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
+                       EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
                 tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
                 tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
                 break;
@@ -829,7 +818,7 @@
 
             tlv_ptr.lspping_tlv_downstream_map_info= \
                 (const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
-            
+
             /* FIXME add hash-key type, depth limit, multipath processing */
 
 
@@ -845,21 +834,19 @@
 
         case LSPPING_TLV_BFD_DISCRIMINATOR:
             tptr += sizeof(struct lspping_tlv_header);
-            if (!TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN))
-                goto trunc;
-            printf("\n\t    BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr));
+            ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
+            ND_PRINT((ndo, "\n\t    BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)));
             break;
 
         case  LSPPING_TLV_VENDOR_ENTERPRISE:
         {
-            u_int32_t vendor_id;
+            uint32_t vendor_id;
 
-            if (!TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN))
-                goto trunc;
+            ND_TCHECK2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
             vendor_id = EXTRACT_32BITS(tlv_tptr);
-            printf("\n\t    Vendor: %s (0x%04x)",
+            ND_PRINT((ndo, "\n\t    Vendor: %s (0x%04x)",
                    tok2str(smi_values, "Unknown", vendor_id),
-                   vendor_id);
+                   vendor_id));
         }
             break;
 
@@ -870,15 +857,15 @@
         case LSPPING_TLV_PAD:
         case LSPPING_TLV_ERROR_CODE:
         case LSPPING_TLV_VENDOR_PRIVATE:
-    
+
         default:
-            if (vflag <= 1)
-                print_unknown_data(tlv_tptr,"\n\t    ",tlv_tlen);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo, tlv_tptr, "\n\t    ", tlv_tlen);
             break;
         }
         /* do we want to see an additionally tlv hexdump ? */
-        if (vflag > 1 || tlv_hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(struct lspping_tlv_header),"\n\t    ",
+        if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
+            print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t    ",
                                lspping_tlv_len);
 
 
@@ -892,5 +879,11 @@
     }
     return;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-lwapp.c b/print-lwapp.c
index 154876f..5b8683f 100644
--- a/print-lwapp.c
+++ b/print-lwapp.c
@@ -12,31 +12,23 @@
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
  *
- * Support for the Light Weight Access Point Protocol as per draft-ohara-capwap-lwapp-04
+ * Support for the Light Weight Access Point Protocol as per RFC 5412
  *
  * Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lwapp.c,v 1.1 2007-07-24 16:07:30 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 
-/* 
+/*
  * LWAPP transport (common) header
  *      0                   1                   2                   3
  *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -49,10 +41,10 @@
  */
 
 struct lwapp_transport_header {
-    u_int8_t  version;
-    u_int8_t  frag_id;
-    u_int8_t  length[2];
-    u_int16_t status;
+    uint8_t  version;
+    uint8_t  frag_id;
+    uint8_t  length[2];
+    uint16_t status;
 };
 
 /*
@@ -69,16 +61,16 @@
  */
 
 struct lwapp_control_header {
-    u_int8_t  msg_type;
-    u_int8_t  seq_num;
-    u_int8_t  len[2];
-    u_int8_t  session_id[4];
+    uint8_t  msg_type;
+    uint8_t  seq_num;
+    uint8_t  len[2];
+    uint8_t  session_id[4];
 };
 
 #define LWAPP_VERSION 0
-#define	LWAPP_EXTRACT_VERSION(x) (((x)&0xC0)>>6) 
-#define	LWAPP_EXTRACT_RID(x) (((x)&0x38)>>3) 
-#define LWAPP_EXTRACT_CONTROL_BIT(x) (((x)&0x04)>>2) 
+#define	LWAPP_EXTRACT_VERSION(x) (((x)&0xC0)>>6)
+#define	LWAPP_EXTRACT_RID(x) (((x)&0x38)>>3)
+#define LWAPP_EXTRACT_CONTROL_BIT(x) (((x)&0x04)>>2)
 
 static const struct tok lwapp_header_bits_values[] = {
     { 0x01, "Last Fragment Bit"},
@@ -154,9 +146,9 @@
     { 0, NULL}
 };
 
-/* 
+/*
  * LWAPP message elements
- * 
+ *
  * 0                   1                   2                   3
  * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -164,13 +156,14 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct lwapp_message_header {
-    u_int8_t type;
-    u_int8_t length[2];
+    uint8_t type;
+    uint8_t length[2];
 };
 
 void
-lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
-
+lwapp_control_print(netdissect_options *ndo,
+                    const u_char *pptr, u_int len, int has_ap_ident)
+{
     const struct lwapp_transport_header *lwapp_trans_header;
     const struct lwapp_control_header *lwapp_control_header;
     const u_char *tptr;
@@ -181,47 +174,45 @@
 
     if (has_ap_ident) {
         /* check if enough bytes for AP identity */
-        if (!TTEST2(*tptr, 6))
-            goto trunc;
+        ND_TCHECK2(*tptr, 6);
         lwapp_trans_header = (const struct lwapp_transport_header *)(pptr+6);
     } else {
         lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
     }
-    TCHECK(*lwapp_trans_header);
+    ND_TCHECK(*lwapp_trans_header);
 
     /*
      * Sanity checking of the header.
      */
     if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) {
-	printf("LWAPP version %u packet not supported",
-               LWAPP_EXTRACT_VERSION(lwapp_trans_header->version));
+	ND_PRINT((ndo, "LWAPP version %u packet not supported",
+               LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)));
 	return;
     }
 
     /* non-verbose */
-    if (vflag < 1) {
-        printf("LWAPPv%u, %s frame, Flags [%s], length %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
                LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
                LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
                bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
-               len);
+               len));
         return;
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
     tlen=EXTRACT_16BITS(lwapp_trans_header->length);
 
-    printf("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
+    ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
            LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
            LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
            LWAPP_EXTRACT_RID(lwapp_trans_header->version),
            bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
 	   lwapp_trans_header->frag_id,
-	   tlen);
+	   tlen));
 
     if (has_ap_ident) {
-        printf("\n\tAP identity: %s",
-               etheraddr_string(tptr));
+        ND_PRINT((ndo, "\n\tAP identity: %s", etheraddr_string(ndo, tptr)));
         tptr+=sizeof(const struct lwapp_transport_header)+6;
     } else {
         tptr+=sizeof(const struct lwapp_transport_header);
@@ -230,23 +221,21 @@
     while(tlen>0) {
 
         /* did we capture enough for fully decoding the object header ? */
-        if (!TTEST2(*tptr, sizeof(struct lwapp_control_header)))
-            goto trunc;
+        ND_TCHECK2(*tptr, sizeof(struct lwapp_control_header));
 
         lwapp_control_header = (const struct lwapp_control_header *)tptr;
 	msg_tlen = EXTRACT_16BITS(lwapp_control_header->len);
 
-	/* print message header */ 
-        printf("\n\t  Msg type: %s (%u), Seqnum: %u, Msg len: %d, Session: 0x%08x",
+	/* print message header */
+        ND_PRINT((ndo, "\n\t  Msg type: %s (%u), Seqnum: %u, Msg len: %d, Session: 0x%08x",
                tok2str(lwapp_msg_type_values,"Unknown",lwapp_control_header->msg_type),
                lwapp_control_header->msg_type,
                lwapp_control_header->seq_num,
                msg_tlen,
-               EXTRACT_32BITS(lwapp_control_header->session_id));
+               EXTRACT_32BITS(lwapp_control_header->session_id)));
 
         /* did we capture enough for fully decoding the message */
-        if (!TTEST2(*tptr, msg_tlen))
-            goto trunc;
+        ND_TCHECK2(*tptr, msg_tlen);
 
 	/* XXX - Decode sub messages for each message */
         switch(lwapp_control_header->msg_type) {
@@ -291,12 +280,13 @@
     return;
 
  trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
 
 void
-lwapp_data_print(const u_char *pptr, u_int len) {
-
+lwapp_data_print(netdissect_options *ndo,
+                 const u_char *pptr, u_int len)
+{
     const struct lwapp_transport_header *lwapp_trans_header;
     const u_char *tptr;
     int tlen;
@@ -304,51 +294,50 @@
     tptr=pptr;
 
     /* check if enough bytes for AP identity */
-    if (!TTEST2(*tptr, 6))
-        goto trunc;
+    ND_TCHECK2(*tptr, 6);
     lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
-    TCHECK(*lwapp_trans_header);
+    ND_TCHECK(*lwapp_trans_header);
 
     /*
      * Sanity checking of the header.
      */
     if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) {
-        printf("LWAPP version %u packet not supported",
-               LWAPP_EXTRACT_VERSION(lwapp_trans_header->version));
+        ND_PRINT((ndo, "LWAPP version %u packet not supported",
+               LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)));
         return;
     }
 
     /* non-verbose */
-    if (vflag < 1) {
-        printf("LWAPPv%u, %s frame, Flags [%s], length %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
                LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
                LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
                bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
-               len);
+               len));
         return;
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
     tlen=EXTRACT_16BITS(lwapp_trans_header->length);
 
-    printf("LWAPPv%u, %s frame, Radio-id  %u, Flags [%s], Frag-id  %u, length %u",
+    ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id  %u, Flags [%s], Frag-id  %u, length %u",
            LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
            LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
            LWAPP_EXTRACT_RID(lwapp_trans_header->version),
            bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
            lwapp_trans_header->frag_id,
-           tlen);
+           tlen));
 
     tptr+=sizeof(const struct lwapp_transport_header);
     tlen-=sizeof(const struct lwapp_transport_header);
 
     /* FIX - An IEEE 802.11 frame follows - hexdump for now */
-    print_unknown_data(tptr, "\n\t", tlen);
+    print_unknown_data(ndo, tptr, "\n\t", tlen);
 
     return;
 
  trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
 
 /*
diff --git a/print-lwres.c b/print-lwres.c
index 60acc5b..d78c9a9 100644
--- a/print-lwres.c
+++ b/print-lwres.c
@@ -27,11 +27,7 @@
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -48,9 +44,9 @@
 #include "extract.h"                    /* must come after interface.h */
 
 /* BIND9 lib/lwres/include/lwres */
-typedef u_int32_t lwres_uint32_t;
-typedef u_int16_t lwres_uint16_t;
-typedef u_int8_t lwres_uint8_t;
+typedef uint32_t lwres_uint32_t;
+typedef uint16_t lwres_uint16_t;
+typedef uint8_t lwres_uint8_t;
 
 struct lwres_lwpacket {
 	lwres_uint32_t		length;
@@ -187,25 +183,21 @@
 extern const struct tok ns_type2str[];
 extern const struct tok ns_class2str[];
 
-static int lwres_printname(size_t, const char *);
-static int lwres_printnamelen(const char *);
-static int lwres_printbinlen(const char *);
-static int lwres_printaddr(lwres_addr_t *);
-
 static int
-lwres_printname(size_t l, const char *p0)
+lwres_printname(netdissect_options *ndo,
+                size_t l, const char *p0)
 {
 	const char *p;
 	size_t i;
 
 	p = p0;
 	/* + 1 for terminating \0 */
-	if (p + l + 1 > (const char *)snapend)
+	if (p + l + 1 > (const char *)ndo->ndo_snapend)
 		goto trunc;
 
-	printf(" ");
+	ND_PRINT((ndo, " "));
 	for (i = 0; i < l; i++)
-		safeputchar(*p++);
+		safeputchar(ndo, *p++);
 	p++;	/* skip terminating \0 */
 
 	return p - p0;
@@ -215,15 +207,16 @@
 }
 
 static int
-lwres_printnamelen(const char *p)
+lwres_printnamelen(netdissect_options *ndo,
+                   const char *p)
 {
-	u_int16_t l;
+	uint16_t l;
 	int advance;
 
-	if (p + 2 > (const char *)snapend)
+	if (p + 2 > (const char *)ndo->ndo_snapend)
 		goto trunc;
 	l = EXTRACT_16BITS(p);
-	advance = lwres_printname(l, p + 2);
+	advance = lwres_printname(ndo, l, p + 2);
 	if (advance < 0)
 		goto trunc;
 	return 2 + advance;
@@ -233,21 +226,22 @@
 }
 
 static int
-lwres_printbinlen(const char *p0)
+lwres_printbinlen(netdissect_options *ndo,
+                  const char *p0)
 {
 	const char *p;
-	u_int16_t l;
+	uint16_t l;
 	int i;
 
 	p = p0;
-	if (p + 2 > (const char *)snapend)
+	if (p + 2 > (const char *)ndo->ndo_snapend)
 		goto trunc;
 	l = EXTRACT_16BITS(p);
-	if (p + 2 + l > (const char *)snapend)
+	if (p + 2 + l > (const char *)ndo->ndo_snapend)
 		goto trunc;
 	p += 2;
 	for (i = 0; i < l; i++)
-		printf("%02x", *p++);
+		ND_PRINT((ndo, "%02x", *p++));
 	return p - p0;
 
   trunc:
@@ -255,37 +249,38 @@
 }
 
 static int
-lwres_printaddr(lwres_addr_t *ap)
+lwres_printaddr(netdissect_options *ndo,
+                lwres_addr_t *ap)
 {
-	u_int16_t l;
+	uint16_t l;
 	const char *p;
 	int i;
 
-	TCHECK(ap->length);
+	ND_TCHECK(ap->length);
 	l = EXTRACT_16BITS(&ap->length);
 	/* XXX ap points to packed struct */
 	p = (const char *)&ap->length + sizeof(ap->length);
-	TCHECK2(*p, l);
+	ND_TCHECK2(*p, l);
 
 	switch (EXTRACT_32BITS(&ap->family)) {
 	case 1:	/* IPv4 */
 		if (l < 4)
 			return -1;
-		printf(" %s", ipaddr_string(p));
+		ND_PRINT((ndo, " %s", ipaddr_string(ndo, p)));
 		p += sizeof(struct in_addr);
 		break;
 #ifdef INET6
 	case 2:	/* IPv6 */
 		if (l < 16)
 			return -1;
-		printf(" %s", ip6addr_string(p));
+		ND_PRINT((ndo, " %s", ip6addr_string(ndo, p)));
 		p += sizeof(struct in6_addr);
 		break;
 #endif
 	default:
-		printf(" %u/", EXTRACT_32BITS(&ap->family));
+		ND_PRINT((ndo, " %u/", EXTRACT_32BITS(&ap->family)));
 		for (i = 0; i < l; i++)
-			printf("%02x", *p++);
+			ND_PRINT((ndo, "%02x", *p++));
 	}
 
 	return p - (const char *)ap;
@@ -295,22 +290,23 @@
 }
 
 void
-lwres_print(register const u_char *bp, u_int length)
+lwres_print(netdissect_options *ndo,
+            register const u_char *bp, u_int length)
 {
 	const struct lwres_lwpacket *np;
-	u_int32_t v;
+	uint32_t v;
 	const char *s;
 	int response;
 	int advance;
 	int unsupported = 0;
 
 	np = (const struct lwres_lwpacket *)bp;
-	TCHECK(np->authlength);
+	ND_TCHECK(np->authlength);
 
-	printf(" lwres");
+	ND_PRINT((ndo, " lwres"));
 	v = EXTRACT_16BITS(&np->version);
-	if (vflag || v != LWRES_LWPACKETVERSION_0)
-		printf(" v%u", v);
+	if (ndo->ndo_vflag || v != LWRES_LWPACKETVERSION_0)
+		ND_PRINT((ndo, " v%u", v));
 	if (v != LWRES_LWPACKETVERSION_0) {
 		s = (const char *)np + EXTRACT_32BITS(&np->length);
 		goto tail;
@@ -321,25 +317,25 @@
 	/* opcode and pktflags */
 	v = EXTRACT_32BITS(&np->opcode);
 	s = tok2str(opcode, "#0x%x", v);
-	printf(" %s%s", s, response ? "" : "?");
+	ND_PRINT((ndo, " %s%s", s, response ? "" : "?"));
 
 	/* pktflags */
 	v = EXTRACT_16BITS(&np->pktflags);
 	if (v & ~LWRES_LWPACKETFLAG_RESPONSE)
-		printf("[0x%x]", v);
+		ND_PRINT((ndo, "[0x%x]", v));
 
-	if (vflag > 1) {
-		printf(" (");	/*)*/
-		printf("serial:0x%x", EXTRACT_32BITS(&np->serial));
-		printf(" result:0x%x", EXTRACT_32BITS(&np->result));
-		printf(" recvlen:%u", EXTRACT_32BITS(&np->recvlength));
+	if (ndo->ndo_vflag > 1) {
+		ND_PRINT((ndo, " ("));	/*)*/
+		ND_PRINT((ndo, "serial:0x%x", EXTRACT_32BITS(&np->serial)));
+		ND_PRINT((ndo, " result:0x%x", EXTRACT_32BITS(&np->result)));
+		ND_PRINT((ndo, " recvlen:%u", EXTRACT_32BITS(&np->recvlength)));
 		/* BIND910: not used */
-		if (vflag > 2) {
-			printf(" authtype:0x%x", EXTRACT_16BITS(&np->authtype));
-			printf(" authlen:%u", EXTRACT_16BITS(&np->authlength));
+		if (ndo->ndo_vflag > 2) {
+			ND_PRINT((ndo, " authtype:0x%x", EXTRACT_16BITS(&np->authtype)));
+			ND_PRINT((ndo, " authlen:%u", EXTRACT_16BITS(&np->authlength)));
 		}
 		/*(*/
-		printf(")");
+		ND_PRINT((ndo, ")"));
 	}
 
 	/* per-opcode content */
@@ -350,7 +346,7 @@
 		lwres_gabnrequest_t *gabn;
 		lwres_gnbarequest_t *gnba;
 		lwres_grbnrequest_t *grbn;
-		u_int32_t l;
+		uint32_t l;
 
 		gabn = NULL;
 		gnba = NULL;
@@ -361,51 +357,51 @@
 			break;
 		case LWRES_OPCODE_GETADDRSBYNAME:
 			gabn = (lwres_gabnrequest_t *)(np + 1);
-			TCHECK(gabn->namelen);
+			ND_TCHECK(gabn->namelen);
 			/* XXX gabn points to packed struct */
 			s = (const char *)&gabn->namelen +
 			    sizeof(gabn->namelen);
 			l = EXTRACT_16BITS(&gabn->namelen);
 
 			/* BIND910: not used */
-			if (vflag > 2) {
-				printf(" flags:0x%x",
-				    EXTRACT_32BITS(&gabn->flags));
+			if (ndo->ndo_vflag > 2) {
+				ND_PRINT((ndo, " flags:0x%x",
+				    EXTRACT_32BITS(&gabn->flags)));
 			}
 
 			v = EXTRACT_32BITS(&gabn->addrtypes);
 			switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) {
 			case LWRES_ADDRTYPE_V4:
-				printf(" IPv4");
+				ND_PRINT((ndo, " IPv4"));
 				break;
 			case LWRES_ADDRTYPE_V6:
-				printf(" IPv6");
+				ND_PRINT((ndo, " IPv6"));
 				break;
 			case LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6:
-				printf(" IPv4/6");
+				ND_PRINT((ndo, " IPv4/6"));
 				break;
 			}
 			if (v & ~(LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6))
-				printf("[0x%x]", v);
+				ND_PRINT((ndo, "[0x%x]", v));
 
-			advance = lwres_printname(l, s);
+			advance = lwres_printname(ndo, l, s);
 			if (advance < 0)
 				goto trunc;
 			s += advance;
 			break;
 		case LWRES_OPCODE_GETNAMEBYADDR:
 			gnba = (lwres_gnbarequest_t *)(np + 1);
-			TCHECK(gnba->addr);
+			ND_TCHECK(gnba->addr);
 
 			/* BIND910: not used */
-			if (vflag > 2) {
-				printf(" flags:0x%x",
-				    EXTRACT_32BITS(&gnba->flags));
+			if (ndo->ndo_vflag > 2) {
+				ND_PRINT((ndo, " flags:0x%x",
+				    EXTRACT_32BITS(&gnba->flags)));
 			}
 
 			s = (const char *)&gnba->addr;
 
-			advance = lwres_printaddr(&gnba->addr);
+			advance = lwres_printaddr(ndo, &gnba->addr);
 			if (advance < 0)
 				goto trunc;
 			s += advance;
@@ -413,19 +409,19 @@
 		case LWRES_OPCODE_GETRDATABYNAME:
 			/* XXX no trace, not tested */
 			grbn = (lwres_grbnrequest_t *)(np + 1);
-			TCHECK(grbn->namelen);
+			ND_TCHECK(grbn->namelen);
 
 			/* BIND910: not used */
-			if (vflag > 2) {
-				printf(" flags:0x%x",
-				    EXTRACT_32BITS(&grbn->flags));
+			if (ndo->ndo_vflag > 2) {
+				ND_PRINT((ndo, " flags:0x%x",
+				    EXTRACT_32BITS(&grbn->flags)));
 			}
 
-			printf(" %s", tok2str(ns_type2str, "Type%d",
-			    EXTRACT_16BITS(&grbn->rdtype)));
+			ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d",
+			    EXTRACT_16BITS(&grbn->rdtype))));
 			if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
-				printf(" %s", tok2str(ns_class2str, "Class%d",
-				    EXTRACT_16BITS(&grbn->rdclass)));
+				ND_PRINT((ndo, " %s", tok2str(ns_class2str, "Class%d",
+				    EXTRACT_16BITS(&grbn->rdclass))));
 			}
 
 			/* XXX grbn points to packed struct */
@@ -433,7 +429,7 @@
 			    sizeof(grbn->namelen);
 			l = EXTRACT_16BITS(&grbn->namelen);
 
-			advance = lwres_printname(l, s);
+			advance = lwres_printname(ndo, l, s);
 			if (advance < 0)
 				goto trunc;
 			s += advance;
@@ -449,8 +445,8 @@
 		lwres_gabnresponse_t *gabn;
 		lwres_gnbaresponse_t *gnba;
 		lwres_grbnresponse_t *grbn;
-		u_int32_t l, na;
-		u_int32_t i;
+		uint32_t l, na;
+		uint32_t i;
 
 		gabn = NULL;
 		gnba = NULL;
@@ -461,22 +457,22 @@
 			break;
 		case LWRES_OPCODE_GETADDRSBYNAME:
 			gabn = (lwres_gabnresponse_t *)(np + 1);
-			TCHECK(gabn->realnamelen);
+			ND_TCHECK(gabn->realnamelen);
 			/* XXX gabn points to packed struct */
 			s = (const char *)&gabn->realnamelen +
 			    sizeof(gabn->realnamelen);
 			l = EXTRACT_16BITS(&gabn->realnamelen);
 
 			/* BIND910: not used */
-			if (vflag > 2) {
-				printf(" flags:0x%x",
-				    EXTRACT_32BITS(&gabn->flags));
+			if (ndo->ndo_vflag > 2) {
+				ND_PRINT((ndo, " flags:0x%x",
+				    EXTRACT_32BITS(&gabn->flags)));
 			}
 
-			printf(" %u/%u", EXTRACT_16BITS(&gabn->naliases),
-			    EXTRACT_16BITS(&gabn->naddrs));
+			ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&gabn->naliases),
+			    EXTRACT_16BITS(&gabn->naddrs)));
 
-			advance = lwres_printname(l, s);
+			advance = lwres_printname(ndo, l, s);
 			if (advance < 0)
 				goto trunc;
 			s += advance;
@@ -484,7 +480,7 @@
 			/* aliases */
 			na = EXTRACT_16BITS(&gabn->naliases);
 			for (i = 0; i < na; i++) {
-				advance = lwres_printnamelen(s);
+				advance = lwres_printnamelen(ndo, s);
 				if (advance < 0)
 					goto trunc;
 				s += advance;
@@ -493,7 +489,7 @@
 			/* addrs */
 			na = EXTRACT_16BITS(&gabn->naddrs);
 			for (i = 0; i < na; i++) {
-				advance = lwres_printaddr((lwres_addr_t *)s);
+				advance = lwres_printaddr(ndo, (lwres_addr_t *)s);
 				if (advance < 0)
 					goto trunc;
 				s += advance;
@@ -501,21 +497,21 @@
 			break;
 		case LWRES_OPCODE_GETNAMEBYADDR:
 			gnba = (lwres_gnbaresponse_t *)(np + 1);
-			TCHECK(gnba->realnamelen);
+			ND_TCHECK(gnba->realnamelen);
 			/* XXX gnba points to packed struct */
 			s = (const char *)&gnba->realnamelen +
 			    sizeof(gnba->realnamelen);
 			l = EXTRACT_16BITS(&gnba->realnamelen);
 
 			/* BIND910: not used */
-			if (vflag > 2) {
-				printf(" flags:0x%x",
-				    EXTRACT_32BITS(&gnba->flags));
+			if (ndo->ndo_vflag > 2) {
+				ND_PRINT((ndo, " flags:0x%x",
+				    EXTRACT_32BITS(&gnba->flags)));
 			}
 
-			printf(" %u", EXTRACT_16BITS(&gnba->naliases));
+			ND_PRINT((ndo, " %u", EXTRACT_16BITS(&gnba->naliases)));
 
-			advance = lwres_printname(l, s);
+			advance = lwres_printname(ndo, l, s);
 			if (advance < 0)
 				goto trunc;
 			s += advance;
@@ -523,7 +519,7 @@
 			/* aliases */
 			na = EXTRACT_16BITS(&gnba->naliases);
 			for (i = 0; i < na; i++) {
-				advance = lwres_printnamelen(s);
+				advance = lwres_printnamelen(ndo, s);
 				if (advance < 0)
 					goto trunc;
 				s += advance;
@@ -532,29 +528,29 @@
 		case LWRES_OPCODE_GETRDATABYNAME:
 			/* XXX no trace, not tested */
 			grbn = (lwres_grbnresponse_t *)(np + 1);
-			TCHECK(grbn->nsigs);
+			ND_TCHECK(grbn->nsigs);
 
 			/* BIND910: not used */
-			if (vflag > 2) {
-				printf(" flags:0x%x",
-				    EXTRACT_32BITS(&grbn->flags));
+			if (ndo->ndo_vflag > 2) {
+				ND_PRINT((ndo, " flags:0x%x",
+				    EXTRACT_32BITS(&grbn->flags)));
 			}
 
-			printf(" %s", tok2str(ns_type2str, "Type%d",
-			    EXTRACT_16BITS(&grbn->rdtype)));
+			ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d",
+			    EXTRACT_16BITS(&grbn->rdtype))));
 			if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
-				printf(" %s", tok2str(ns_class2str, "Class%d",
-				    EXTRACT_16BITS(&grbn->rdclass)));
+				ND_PRINT((ndo, " %s", tok2str(ns_class2str, "Class%d",
+				    EXTRACT_16BITS(&grbn->rdclass))));
 			}
-			printf(" TTL ");
-			relts_print(EXTRACT_32BITS(&grbn->ttl));
-			printf(" %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
-			    EXTRACT_16BITS(&grbn->nsigs));
+			ND_PRINT((ndo, " TTL "));
+			relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
+			ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
+			    EXTRACT_16BITS(&grbn->nsigs)));
 
 			/* XXX grbn points to packed struct */
 			s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs);
 
-			advance = lwres_printnamelen(s);
+			advance = lwres_printnamelen(ndo, s);
 			if (advance < 0)
 				goto trunc;
 			s += advance;
@@ -563,7 +559,7 @@
 			na = EXTRACT_16BITS(&grbn->nrdatas);
 			for (i = 0; i < na; i++) {
 				/* XXX should decode resource data */
-				advance = lwres_printbinlen(s);
+				advance = lwres_printbinlen(ndo, s);
 				if (advance < 0)
 					goto trunc;
 				s += advance;
@@ -573,7 +569,7 @@
 			na = EXTRACT_16BITS(&grbn->nsigs);
 			for (i = 0; i < na; i++) {
 				/* XXX how should we print it? */
-				advance = lwres_printbinlen(s);
+				advance = lwres_printbinlen(ndo, s);
 				if (advance < 0)
 					goto trunc;
 				s += advance;
@@ -588,14 +584,13 @@
   tail:
 	/* length mismatch */
 	if (EXTRACT_32BITS(&np->length) != length) {
-		printf(" [len: %u != %u]", EXTRACT_32BITS(&np->length),
-		    length);
+		ND_PRINT((ndo, " [len: %u != %u]", EXTRACT_32BITS(&np->length),
+		    length));
 	}
 	if (!unsupported && s < (const char *)np + EXTRACT_32BITS(&np->length))
-		printf("[extra]");
+		ND_PRINT((ndo, "[extra]"));
 	return;
 
   trunc:
-	printf("[|lwres]");
-	return;
+	ND_PRINT((ndo, "[|lwres]"));
 }
diff --git a/print-m3ua.c b/print-m3ua.c
new file mode 100644
index 0000000..33f8777
--- /dev/null
+++ b/print-m3ua.c
@@ -0,0 +1,339 @@
+/* Copyright (c) 2013, The TCPDUMP project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ *    list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT OWNER 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.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+
+static const char tstr[] = " [|m3ua]";
+static const char cstr[] = " (corrupt)";
+
+/* RFC 4666 */
+
+#define M3UA_REL_1_0 1
+
+struct m3ua_common_header {
+  uint8_t  v;
+  uint8_t  reserved;
+  uint8_t  msg_class;
+  uint8_t  msg_type;
+  uint32_t len;
+};
+
+struct m3ua_param_header {
+  uint16_t tag;
+  uint16_t len;
+};
+
+/* message classes */
+#define M3UA_MSGC_MGMT 0
+#define M3UA_MSGC_TRANSFER 1
+#define M3UA_MSGC_SSNM 2
+#define M3UA_MSGC_ASPSM 3
+#define M3UA_MSGC_ASPTM 4
+/* reserved values */
+#define M3UA_MSGC_RKM 9
+
+static const struct tok MessageClasses[] = {
+	{ M3UA_MSGC_MGMT,     "Management"            },
+	{ M3UA_MSGC_TRANSFER, "Transfer"              },
+	{ M3UA_MSGC_SSNM,     "SS7"                   },
+	{ M3UA_MSGC_ASPSM,    "ASP"                   },
+	{ M3UA_MSGC_ASPTM,    "ASP"                   },
+	{ M3UA_MSGC_RKM,      "Routing Key Managment" },
+	{ 0, NULL }
+};
+
+/* management messages */
+#define M3UA_MGMT_ERROR 0
+#define M3UA_MGMT_NOTIFY 1
+
+static const struct tok MgmtMessages[] = {
+  { M3UA_MGMT_ERROR, "Error" },
+  { M3UA_MGMT_NOTIFY, "Notify" },
+  { 0, NULL }
+};
+
+/* transfer messages */
+#define M3UA_TRANSFER_DATA 1
+
+static const struct tok TransferMessages[] = {
+  { M3UA_TRANSFER_DATA, "Data" },
+  { 0, NULL }
+};
+
+/* SS7 Signaling Network Management messages */
+#define M3UA_SSNM_DUNA 1
+#define M3UA_SSNM_DAVA 2
+#define M3UA_SSNM_DAUD 3
+#define M3UA_SSNM_SCON 4
+#define M3UA_SSNM_DUPU 5
+#define M3UA_SSNM_DRST 6
+
+static const struct tok SS7Messages[] = {
+  { M3UA_SSNM_DUNA, "Destination Unavailable" },
+  { M3UA_SSNM_DAVA, "Destination Available" },
+  { M3UA_SSNM_DAUD, "Destination State Audit" },
+  { M3UA_SSNM_SCON, "Signalling Congestion" },
+  { M3UA_SSNM_DUPU, "Destination User Part Unavailable" },
+  { M3UA_SSNM_DRST, "Destination Restricted" },
+  { 0, NULL }
+};
+
+/* ASP State Maintenance messages */
+#define M3UA_ASP_UP 1
+#define M3UA_ASP_DN 2
+#define M3UA_ASP_BEAT 3
+#define M3UA_ASP_UP_ACK 4
+#define M3UA_ASP_DN_ACK 5
+#define M3UA_ASP_BEAT_ACK 6
+
+static const struct tok ASPStateMessages[] = {
+  { M3UA_ASP_UP, "Up" },
+  { M3UA_ASP_DN, "Down" },
+  { M3UA_ASP_BEAT, "Heartbeat" },
+  { M3UA_ASP_UP_ACK, "Up Acknowledgement" },
+  { M3UA_ASP_DN_ACK, "Down Acknowledgement" },
+  { M3UA_ASP_BEAT_ACK, "Heartbeat Acknowledgement" },
+  { 0, NULL }
+};
+
+/* ASP Traffic Maintenance messages */
+#define M3UA_ASP_AC 1
+#define M3UA_ASP_IA 2
+#define M3UA_ASP_AC_ACK 3
+#define M3UA_ASP_IA_ACK 4
+
+static const struct tok ASPTrafficMessages[] = {
+  { M3UA_ASP_AC, "Active" },
+  { M3UA_ASP_IA, "Inactive" },
+  { M3UA_ASP_AC_ACK, "Active Acknowledgement" },
+  { M3UA_ASP_IA_ACK, "Inactive Acknowledgement" },
+  { 0, NULL }
+};
+
+/* Routing Key Management messages */
+#define M3UA_RKM_REQ 1
+#define M3UA_RKM_RSP 2
+#define M3UA_RKM_DEREQ 3
+#define M3UA_RKM_DERSP 4
+
+static const struct tok RoutingKeyMgmtMessages[] = {
+  { M3UA_RKM_REQ, "Registration Request" },
+  { M3UA_RKM_RSP, "Registration Response" },
+  { M3UA_RKM_DEREQ, "Deregistration Request" },
+  { M3UA_RKM_DERSP, "Deregistration Response" },
+  { 0, NULL }
+};
+
+/* M3UA Parameters */
+#define M3UA_PARAM_INFO 0x0004
+#define M3UA_PARAM_ROUTING_CTX 0x0006
+#define M3UA_PARAM_DIAGNOSTIC 0x0007
+#define M3UA_PARAM_HB_DATA 0x0009
+#define M3UA_PARAM_TRAFFIC_MODE_TYPE 0x000b
+#define M3UA_PARAM_ERROR_CODE 0x000c
+#define M3UA_PARAM_STATUS 0x000d
+#define M3UA_PARAM_ASP_ID 0x0011
+#define M3UA_PARAM_AFFECTED_POINT_CODE 0x0012
+#define M3UA_PARAM_CORR_ID 0x0013
+
+#define M3UA_PARAM_NETWORK_APPEARANCE 0x0200
+#define M3UA_PARAM_USER 0x0204
+#define M3UA_PARAM_CONGESTION_INDICATION 0x0205
+#define M3UA_PARAM_CONCERNED_DST 0x0206
+#define M3UA_PARAM_ROUTING_KEY 0x0207
+#define M3UA_PARAM_REG_RESULT 0x0208
+#define M3UA_PARAM_DEREG_RESULT 0x0209
+#define M3UA_PARAM_LOCAL_ROUTING_KEY_ID 0x020a
+#define M3UA_PARAM_DST_POINT_CODE 0x020b
+#define M3UA_PARAM_SI 0x020c
+#define M3UA_PARAM_ORIGIN_POINT_CODE_LIST 0x020e
+#define M3UA_PARAM_PROTO_DATA 0x0210
+#define M3UA_PARAM_REG_STATUS 0x0212
+#define M3UA_PARAM_DEREG_STATUS 0x0213
+
+static const struct tok ParamName[] = {
+  { M3UA_PARAM_INFO, "INFO String" },
+  { M3UA_PARAM_ROUTING_CTX, "Routing Context" },
+  { M3UA_PARAM_DIAGNOSTIC, "Diagnostic Info" },
+  { M3UA_PARAM_HB_DATA, "Heartbeat Data" },
+  { M3UA_PARAM_TRAFFIC_MODE_TYPE, "Traffic Mode Type" },
+  { M3UA_PARAM_ERROR_CODE, "Error Code" },
+  { M3UA_PARAM_STATUS, "Status" },
+  { M3UA_PARAM_ASP_ID, "ASP Identifier" },
+  { M3UA_PARAM_AFFECTED_POINT_CODE, "Affected Point Code" },
+  { M3UA_PARAM_CORR_ID, "Correlation ID" },
+  { M3UA_PARAM_NETWORK_APPEARANCE, "Network Appearance" },
+  { M3UA_PARAM_USER, "User/Cause" },
+  { M3UA_PARAM_CONGESTION_INDICATION, "Congestion Indications" },
+  { M3UA_PARAM_CONCERNED_DST, "Concerned Destination" },
+  { M3UA_PARAM_ROUTING_KEY, "Routing Key" },
+  { M3UA_PARAM_REG_RESULT, "Registration Result" },
+  { M3UA_PARAM_DEREG_RESULT, "Deregistration Result" },
+  { M3UA_PARAM_LOCAL_ROUTING_KEY_ID, "Local Routing Key Identifier" },
+  { M3UA_PARAM_DST_POINT_CODE, "Destination Point Code" },
+  { M3UA_PARAM_SI, "Service Indicators" },
+  { M3UA_PARAM_ORIGIN_POINT_CODE_LIST, "Originating Point Code List" },
+  { M3UA_PARAM_PROTO_DATA, "Protocol Data" },
+  { M3UA_PARAM_REG_STATUS, "Registration Status" },
+  { M3UA_PARAM_DEREG_STATUS, "Deregistration Status" },
+  { 0, NULL }
+};
+
+static void
+tag_value_print(netdissect_options *ndo,
+                const u_char *buf, const uint16_t tag, const uint16_t size)
+{
+  switch (tag) {
+  case M3UA_PARAM_NETWORK_APPEARANCE:
+  case M3UA_PARAM_ROUTING_CTX:
+  case M3UA_PARAM_CORR_ID:
+    /* buf and size don't include the header */
+    if (size < 4)
+      goto corrupt;
+    ND_TCHECK2(*buf, size);
+    ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(buf)));
+    break;
+  /* ... */
+  default:
+    ND_PRINT((ndo, "(length %u)", size + (u_int)sizeof(struct m3ua_param_header)));
+    ND_TCHECK2(*buf, size);
+  }
+  return;
+
+corrupt:
+  ND_PRINT((ndo, "%s", cstr));
+  ND_TCHECK2(*buf, size);
+  return;
+trunc:
+  ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ *     0                   1                   2                   3
+ *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |          Parameter Tag        |       Parameter Length        |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    \                                                               \
+ *    /                       Parameter Value                         /
+ *    \                                                               \
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+static void
+m3ua_tags_print(netdissect_options *ndo,
+                const u_char *buf, const u_int size)
+{
+  const u_char *p = buf;
+  int align;
+  uint16_t hdr_tag;
+  uint16_t hdr_len;
+
+  while (p < buf + size) {
+    if (p + sizeof(struct m3ua_param_header) > buf + size)
+      goto corrupt;
+    ND_TCHECK2(*p, sizeof(struct m3ua_param_header));
+    /* Parameter Tag */
+    hdr_tag = EXTRACT_16BITS(p);
+    ND_PRINT((ndo, "\n\t\t\t%s: ", tok2str(ParamName, "Unknown Parameter (0x%04x)", hdr_tag)));
+    /* Parameter Length */
+    hdr_len = EXTRACT_16BITS(p + 2);
+    if (hdr_len < sizeof(struct m3ua_param_header))
+      goto corrupt;
+    /* Parameter Value */
+    align = (p + hdr_len - buf) % 4;
+    align = align ? 4 - align : 0;
+    ND_TCHECK2(*p, hdr_len + align);
+    tag_value_print(ndo, p, hdr_tag, hdr_len - sizeof(struct m3ua_param_header));
+    p += hdr_len + align;
+  }
+  return;
+
+corrupt:
+  ND_PRINT((ndo, "%s", cstr));
+  ND_TCHECK2(*buf, size);
+  return;
+trunc:
+  ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ *     0                   1                   2                   3
+ *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |    Version    |   Reserved    | Message Class | Message Type  |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |                        Message Length                         |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    \                                                               \
+ *    /                                                               /
+ */
+void
+m3ua_print(netdissect_options *ndo,
+           const u_char *buf, const u_int size)
+{
+  const struct m3ua_common_header *hdr = (const struct m3ua_common_header *) buf;
+  const struct tok *dict;
+
+  /* size includes the header */
+  if (size < sizeof(struct m3ua_common_header))
+    goto corrupt;
+  ND_TCHECK(*hdr);
+  if (hdr->v != M3UA_REL_1_0)
+    return;
+
+  dict =
+    hdr->msg_class == M3UA_MSGC_MGMT     ? MgmtMessages :
+    hdr->msg_class == M3UA_MSGC_TRANSFER ? TransferMessages :
+    hdr->msg_class == M3UA_MSGC_SSNM     ? SS7Messages :
+    hdr->msg_class == M3UA_MSGC_ASPSM    ? ASPStateMessages :
+    hdr->msg_class == M3UA_MSGC_ASPTM    ? ASPTrafficMessages :
+    hdr->msg_class == M3UA_MSGC_RKM      ? RoutingKeyMgmtMessages :
+    NULL;
+
+  ND_PRINT((ndo, "\n\t\t%s", tok2str(MessageClasses, "Unknown message class %i", hdr->msg_class)));
+  if (dict != NULL)
+    ND_PRINT((ndo, " %s Message", tok2str(dict, "Unknown (0x%02x)", hdr->msg_type)));
+
+  if (size != EXTRACT_32BITS(&hdr->len))
+    ND_PRINT((ndo, "\n\t\t\t@@@@@@ Corrupted length %u of message @@@@@@", EXTRACT_32BITS(&hdr->len)));
+  else
+    m3ua_tags_print(ndo, buf + sizeof(struct m3ua_common_header), EXTRACT_32BITS(&hdr->len) - sizeof(struct m3ua_common_header));
+  return;
+
+corrupt:
+  ND_PRINT((ndo, "%s", cstr));
+  ND_TCHECK2(*buf, size);
+  return;
+trunc:
+  ND_PRINT((ndo, "%s", tstr));
+}
+
diff --git a/print-mobile.c b/print-mobile.c
index de4eab1..df412ee 100644
--- a/print-mobile.c
+++ b/print-mobile.c
@@ -36,19 +36,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"		/* must come after interface.h */
@@ -56,10 +50,10 @@
 #define MOBILE_SIZE (8)
 
 struct mobile_ip {
-	u_int16_t proto;
-	u_int16_t hcheck;
-	u_int32_t odst;
-	u_int32_t osrc;
+	uint16_t proto;
+	uint16_t hcheck;
+	uint32_t odst;
+	uint32_t osrc;
 };
 
 #define OSRC_PRES	0x0080	/* old source is present */
@@ -68,9 +62,8 @@
  * Deencapsulate and print a mobile-tunneled IP datagram
  */
 void
-mobile_print(const u_char *bp, u_int length)
+mobile_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
-	const u_char *cp = bp +8 ;
 	const struct mobile_ip *mob;
 	struct cksum_vec vec[1];
 	u_short proto,crc;
@@ -78,35 +71,32 @@
 
 	mob = (const struct mobile_ip *)bp;
 
-	if (length < MOBILE_SIZE || !TTEST(*mob)) {
-		fputs("[|mobile]", stdout);
+	if (length < MOBILE_SIZE || !ND_TTEST(*mob)) {
+		ND_PRINT((ndo, "[|mobile]"));
 		return;
 	}
-	fputs("mobile: ", stdout);
+	ND_PRINT((ndo, "mobile: "));
 
 	proto = EXTRACT_16BITS(&mob->proto);
 	crc =  EXTRACT_16BITS(&mob->hcheck);
 	if (proto & OSRC_PRES) {
 		osp=1;
-		cp +=4 ;
 	}
 
 	if (osp)  {
-		fputs("[S] ",stdout);
-		if (vflag)
-			(void)printf("%s ",ipaddr_string(&mob->osrc));
+		ND_PRINT((ndo, "[S] "));
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, "%s ", ipaddr_string(ndo, &mob->osrc)));
 	} else {
-		fputs("[] ",stdout);
+		ND_PRINT((ndo, "[] "));
 	}
-	if (vflag) {
-		(void)printf("> %s ",ipaddr_string(&mob->odst));
-		(void)printf("(oproto=%d)",proto>>8);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "> %s ", ipaddr_string(ndo, &mob->odst)));
+		ND_PRINT((ndo, "(oproto=%d)", proto>>8));
 	}
-	vec[0].ptr = (const u_int8_t *)(void *)mob;
+	vec[0].ptr = (const uint8_t *)(void *)mob;
 	vec[0].len = osp ? 12 : 8;
 	if (in_cksum(vec, 1)!=0) {
-		(void)printf(" (bad checksum %d)",crc);
+		ND_PRINT((ndo, " (bad checksum %d)", crc));
 	}
-
-	return;
 }
diff --git a/print-mobility.c b/print-mobility.c
index 1490b72..b6fa61e 100644
--- a/print-mobility.c
+++ b/print-mobility.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2002 WIDE Project.
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -13,7 +13,7 @@
  * 3. Neither the name of the project 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 BY THE PROJECT 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
@@ -27,36 +27,29 @@
  * SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.12 2005-04-20 22:21:00 guy Exp $";
-#endif
-
 #ifdef INET6
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "ip6.h"
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"		/* must come after interface.h */
 
 /* Mobility header */
 struct ip6_mobility {
-	u_int8_t ip6m_pproto;	/* following payload protocol (for PG) */
-	u_int8_t ip6m_len;	/* length in units of 8 octets */
-	u_int8_t ip6m_type;	/* message type */
-	u_int8_t reserved;	/* reserved */
-	u_int16_t ip6m_cksum;	/* sum of IPv6 pseudo-header and MH */
+	uint8_t ip6m_pproto;	/* following payload protocol (for PG) */
+	uint8_t ip6m_len;	/* length in units of 8 octets */
+	uint8_t ip6m_type;	/* message type */
+	uint8_t reserved;	/* reserved */
+	uint16_t ip6m_cksum;	/* sum of IPv6 pseudo-header and MH */
 	union {
-		u_int16_t	ip6m_un_data16[1]; /* type-specific field */
-		u_int8_t	ip6m_un_data8[2];  /* type-specific fiedl */
+		uint16_t	ip6m_un_data16[1]; /* type-specific field */
+		uint8_t		ip6m_un_data8[2];  /* type-specific field */
 	} ip6m_dataun;
 };
 
@@ -65,6 +58,8 @@
 
 #define IP6M_MINLEN	8
 
+/* http://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml */
+
 /* message type */
 #define IP6M_BINDING_REQUEST	0	/* Binding Refresh Request */
 #define IP6M_HOME_TEST_INIT	1	/* Home Test Init */
@@ -74,6 +69,23 @@
 #define IP6M_BINDING_UPDATE	5	/* Binding Update */
 #define IP6M_BINDING_ACK	6	/* Binding Acknowledgement */
 #define IP6M_BINDING_ERROR	7	/* Binding Error */
+#define IP6M_MAX		7
+
+static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = {
+	IP6M_MINLEN,      /* IP6M_BINDING_REQUEST  */
+	IP6M_MINLEN + 8,  /* IP6M_HOME_TEST_INIT   */
+	IP6M_MINLEN + 8,  /* IP6M_CAREOF_TEST_INIT */
+	IP6M_MINLEN + 16, /* IP6M_HOME_TEST        */
+	IP6M_MINLEN + 16, /* IP6M_CAREOF_TEST      */
+	IP6M_MINLEN + 4,  /* IP6M_BINDING_UPDATE   */
+	IP6M_MINLEN + 4,  /* IP6M_BINDING_ACK      */
+	IP6M_MINLEN + 16, /* IP6M_BINDING_ERROR    */
+};
+
+/* XXX: unused */
+#define IP6MOPT_BU_MINLEN	10
+#define IP6MOPT_BA_MINLEN	13
+#define IP6MOPT_BR_MINLEN	2
 
 /* Mobility Header Options */
 #define IP6MOPT_MINLEN		2
@@ -89,97 +101,103 @@
 #define IP6MOPT_AUTH_MINLEN    12
 
 static void
-mobility_opt_print(const u_char *bp, int len)
+mobility_opt_print(netdissect_options *ndo,
+                   const u_char *bp, const unsigned len)
 {
-	int i;
-	int optlen;
+	unsigned i, optlen;
 
 	for (i = 0; i < len; i += optlen) {
+		ND_TCHECK(bp[i]);
 		if (bp[i] == IP6MOPT_PAD1)
 			optlen = 1;
 		else {
-			if (i + 1 < len)
+			if (i + 1 < len) {
+				ND_TCHECK(bp[i + 1]);
 				optlen = bp[i + 1] + 2;
+			}
 			else
 				goto trunc;
 		}
 		if (i + optlen > len)
 			goto trunc;
+		ND_TCHECK(bp[i + optlen]);
 
 		switch (bp[i]) {
 		case IP6MOPT_PAD1:
-			printf("(pad1)");
+			ND_PRINT((ndo, "(pad1)"));
 			break;
 		case IP6MOPT_PADN:
 			if (len - i < IP6MOPT_MINLEN) {
-				printf("(padn: trunc)");
+				ND_PRINT((ndo, "(padn: trunc)"));
 				goto trunc;
 			}
-			printf("(padn)");
+			ND_PRINT((ndo, "(padn)"));
 			break;
 		case IP6MOPT_REFRESH:
 			if (len - i < IP6MOPT_REFRESH_MINLEN) {
-				printf("(refresh: trunc)");
+				ND_PRINT((ndo, "(refresh: trunc)"));
 				goto trunc;
 			}
 			/* units of 4 secs */
-			printf("(refresh: %d)",
-				EXTRACT_16BITS(&bp[i+2]) << 2);
+			ND_PRINT((ndo, "(refresh: %u)",
+				EXTRACT_16BITS(&bp[i+2]) << 2));
 			break;
 		case IP6MOPT_ALTCOA:
 			if (len - i < IP6MOPT_ALTCOA_MINLEN) {
-				printf("(altcoa: trunc)");
+				ND_PRINT((ndo, "(altcoa: trunc)"));
 				goto trunc;
 			}
-			printf("(alt-CoA: %s)", ip6addr_string(&bp[i+2]));
+			ND_PRINT((ndo, "(alt-CoA: %s)", ip6addr_string(ndo, &bp[i+2])));
 			break;
 		case IP6MOPT_NONCEID:
 			if (len - i < IP6MOPT_NONCEID_MINLEN) {
-				printf("(ni: trunc)");
+				ND_PRINT((ndo, "(ni: trunc)"));
 				goto trunc;
 			}
-			printf("(ni: ho=0x%04x co=0x%04x)",
+			ND_PRINT((ndo, "(ni: ho=0x%04x co=0x%04x)",
 				EXTRACT_16BITS(&bp[i+2]),
-				EXTRACT_16BITS(&bp[i+4]));
+				EXTRACT_16BITS(&bp[i+4])));
 			break;
 		case IP6MOPT_AUTH:
 			if (len - i < IP6MOPT_AUTH_MINLEN) {
-				printf("(auth: trunc)");
+				ND_PRINT((ndo, "(auth: trunc)"));
 				goto trunc;
 			}
-			printf("(auth)");
+			ND_PRINT((ndo, "(auth)"));
 			break;
 		default:
 			if (len - i < IP6MOPT_MINLEN) {
-				printf("(sopt_type %d: trunc)", bp[i]);
+				ND_PRINT((ndo, "(sopt_type %u: trunc)", bp[i]));
 				goto trunc;
 			}
-			printf("(type-0x%02x: len=%d)", bp[i], bp[i + 1]);
+			ND_PRINT((ndo, "(type-0x%02x: len=%u)", bp[i], bp[i + 1]));
 			break;
 		}
 	}
 	return;
 
 trunc:
-	printf("[trunc] ");
+	ND_PRINT((ndo, "[trunc] "));
 }
 
 /*
  * Mobility Header
  */
 int
-mobility_print(const u_char *bp, const u_char *bp2 _U_)
+mobility_print(netdissect_options *ndo,
+               const u_char *bp, const u_char *bp2 _U_)
 {
 	const struct ip6_mobility *mh;
 	const u_char *ep;
-	int mhlen, hlen, type;
+	unsigned mhlen, hlen;
+	uint8_t type;
 
 	mh = (struct ip6_mobility *)bp;
 
 	/* 'ep' points to the end of available data. */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 
-	if (!TTEST(mh->ip6m_len)) {
+	if (!ND_TTEST(mh->ip6m_len)) {
 		/*
 		 * There's not enough captured data to include the
 		 * mobility header length.
@@ -195,118 +213,122 @@
 		mhlen = ep - bp;
 		goto trunc;
 	}
-	mhlen = (int)((mh->ip6m_len + 1) << 3);
+	mhlen = (mh->ip6m_len + 1) << 3;
 
 	/* XXX ip6m_cksum */
 
-	TCHECK(mh->ip6m_type);
+	ND_TCHECK(mh->ip6m_type);
 	type = mh->ip6m_type;
+	if (type <= IP6M_MAX && mhlen < ip6m_hdrlen[type]) {
+		ND_PRINT((ndo, "(header length %u is too small for type %u)", mhlen, type));
+		goto trunc;
+	}
 	switch (type) {
 	case IP6M_BINDING_REQUEST:
-		printf("mobility: BRR");
+		ND_PRINT((ndo, "mobility: BRR"));
 		hlen = IP6M_MINLEN;
 		break;
 	case IP6M_HOME_TEST_INIT:
 	case IP6M_CAREOF_TEST_INIT:
-		printf("mobility: %soTI",
-			type == IP6M_HOME_TEST_INIT ? "H" : "C");
+		ND_PRINT((ndo, "mobility: %soTI",
+			type == IP6M_HOME_TEST_INIT ? "H" : "C"));
 		hlen = IP6M_MINLEN;
-    		if (vflag) {
-			TCHECK2(*mh, hlen + 8);
-			printf(" %s Init Cookie=%08x:%08x",
+    		if (ndo->ndo_vflag) {
+			ND_TCHECK2(*mh, hlen + 8);
+			ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
 			       type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of",
 			       EXTRACT_32BITS(&bp[hlen]),
-			       EXTRACT_32BITS(&bp[hlen + 4]));
+			       EXTRACT_32BITS(&bp[hlen + 4])));
 		}
 		hlen += 8;
 		break;
 	case IP6M_HOME_TEST:
 	case IP6M_CAREOF_TEST:
-		printf("mobility: %soT",
-			type == IP6M_HOME_TEST ? "H" : "C");
-		TCHECK(mh->ip6m_data16[0]);
-		printf(" nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0]));
+		ND_PRINT((ndo, "mobility: %soT",
+			type == IP6M_HOME_TEST ? "H" : "C"));
+		ND_TCHECK(mh->ip6m_data16[0]);
+		ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])));
 		hlen = IP6M_MINLEN;
-    		if (vflag) {
-			TCHECK2(*mh, hlen + 8);
-			printf(" %s Init Cookie=%08x:%08x",
+    		if (ndo->ndo_vflag) {
+			ND_TCHECK2(*mh, hlen + 8);
+			ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
 			       type == IP6M_HOME_TEST ? "Home" : "Care-of",
 			       EXTRACT_32BITS(&bp[hlen]),
-			       EXTRACT_32BITS(&bp[hlen + 4]));
+			       EXTRACT_32BITS(&bp[hlen + 4])));
 		}
 		hlen += 8;
-    		if (vflag) {
-			TCHECK2(*mh, hlen + 8);
-			printf(" %s Keygen Token=%08x:%08x",
+    		if (ndo->ndo_vflag) {
+			ND_TCHECK2(*mh, hlen + 8);
+			ND_PRINT((ndo, " %s Keygen Token=%08x:%08x",
 			       type == IP6M_HOME_TEST ? "Home" : "Care-of",
 			       EXTRACT_32BITS(&bp[hlen]),
-			       EXTRACT_32BITS(&bp[hlen + 4]));
+			       EXTRACT_32BITS(&bp[hlen + 4])));
 		}
 		hlen += 8;
 		break;
 	case IP6M_BINDING_UPDATE:
-		printf("mobility: BU");
-		TCHECK(mh->ip6m_data16[0]);
-		printf(" seq#=%d", EXTRACT_16BITS(&mh->ip6m_data16[0]));
+		ND_PRINT((ndo, "mobility: BU"));
+		ND_TCHECK(mh->ip6m_data16[0]);
+		ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0])));
 		hlen = IP6M_MINLEN;
-		TCHECK2(*mh, hlen + 1);
+		ND_TCHECK2(*mh, hlen + 1);
 		if (bp[hlen] & 0xf0)
-			printf(" ");
+			ND_PRINT((ndo, " "));
 		if (bp[hlen] & 0x80)
-			printf("A");
+			ND_PRINT((ndo, "A"));
 		if (bp[hlen] & 0x40)
-			printf("H");
+			ND_PRINT((ndo, "H"));
 		if (bp[hlen] & 0x20)
-			printf("L");
+			ND_PRINT((ndo, "L"));
 		if (bp[hlen] & 0x10)
-			printf("K");
+			ND_PRINT((ndo, "K"));
 		/* Reserved (4bits) */
 		hlen += 1;
 		/* Reserved (8bits) */
 		hlen += 1;
-		TCHECK2(*mh, hlen + 2);
+		ND_TCHECK2(*mh, hlen + 2);
 		/* units of 4 secs */
-		printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2);
+		ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
 		hlen += 2;
 		break;
 	case IP6M_BINDING_ACK:
-		printf("mobility: BA");
-		TCHECK(mh->ip6m_data8[0]);
-		printf(" status=%d", mh->ip6m_data8[0]);
+		ND_PRINT((ndo, "mobility: BA"));
+		ND_TCHECK(mh->ip6m_data8[0]);
+		ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
 		if (mh->ip6m_data8[1] & 0x80)
-			printf(" K");
+			ND_PRINT((ndo, " K"));
 		/* Reserved (7bits) */
 		hlen = IP6M_MINLEN;
-		TCHECK2(*mh, hlen + 2);
-		printf(" seq#=%d", EXTRACT_16BITS(&bp[hlen]));
+		ND_TCHECK2(*mh, hlen + 2);
+		ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&bp[hlen])));
 		hlen += 2;
-		TCHECK2(*mh, hlen + 2);
+		ND_TCHECK2(*mh, hlen + 2);
 		/* units of 4 secs */
-		printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2);
+		ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
 		hlen += 2;
 		break;
 	case IP6M_BINDING_ERROR:
-		printf("mobility: BE");
-		TCHECK(mh->ip6m_data8[0]);
-		printf(" status=%d", mh->ip6m_data8[0]);
+		ND_PRINT((ndo, "mobility: BE"));
+		ND_TCHECK(mh->ip6m_data8[0]);
+		ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
 		/* Reserved */
 		hlen = IP6M_MINLEN;
-		TCHECK2(*mh, hlen + 16);
-		printf(" homeaddr %s", ip6addr_string(&bp[hlen]));
+		ND_TCHECK2(*mh, hlen + 16);
+		ND_PRINT((ndo, " homeaddr %s", ip6addr_string(ndo, &bp[hlen])));
 		hlen += 16;
 		break;
 	default:
-		printf("mobility: type-#%d len=%d", type, mh->ip6m_len);
+		ND_PRINT((ndo, "mobility: type-#%u len=%u", type, mh->ip6m_len));
 		return(mhlen);
 		break;
 	}
-    	if (vflag)
-		mobility_opt_print(&bp[hlen], mhlen - hlen);
+    	if (ndo->ndo_vflag)
+		mobility_opt_print(ndo, &bp[hlen], mhlen - hlen);
 
 	return(mhlen);
 
  trunc:
-	fputs("[|MOBILITY]", stdout);
+	ND_PRINT((ndo, "[|MOBILITY]"));
 	return(mhlen);
 }
 #endif /* INET6 */
diff --git a/print-mpcp.c b/print-mpcp.c
index 244f280..9da3582 100644
--- a/print-mpcp.c
+++ b/print-mpcp.c
@@ -17,32 +17,22 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-mpcp.c,v 1.2 2006-02-10 17:24:55 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
-#include "ether.h"
 
 #define MPCP_TIMESTAMP_LEN        4
 #define MPCP_TIMESTAMP_DURATION_LEN 2
 
 struct mpcp_common_header_t {
-    u_int8_t opcode[2];
-    u_int8_t timestamp[MPCP_TIMESTAMP_LEN];
+    uint8_t opcode[2];
+    uint8_t timestamp[MPCP_TIMESTAMP_LEN];
 };
 
 #define	MPCP_OPCODE_PAUSE   0x0001
@@ -63,7 +53,7 @@
 };
 
 #define MPCP_GRANT_NUMBER_LEN 1
-#define	MPCP_GRANT_NUMBER_MASK 0x7 
+#define	MPCP_GRANT_NUMBER_MASK 0x7
 static const struct tok mpcp_grant_flag_values[] = {
     { 0x08, "Discovery" },
     { 0x10, "Force Grant #1" },
@@ -74,13 +64,13 @@
 };
 
 struct mpcp_grant_t {
-    u_int8_t starttime[MPCP_TIMESTAMP_LEN];
-    u_int8_t duration[MPCP_TIMESTAMP_DURATION_LEN];
+    uint8_t starttime[MPCP_TIMESTAMP_LEN];
+    uint8_t duration[MPCP_TIMESTAMP_DURATION_LEN];
 };
 
 struct mpcp_reg_req_t {
-    u_int8_t flags;
-    u_int8_t pending_grants;
+    uint8_t flags;
+    uint8_t pending_grants;
 };
 
 
@@ -91,10 +81,10 @@
 };
 
 struct mpcp_reg_t {
-    u_int8_t assigned_port[2];
-    u_int8_t flags;
-    u_int8_t sync_time[MPCP_TIMESTAMP_DURATION_LEN];
-    u_int8_t echoed_pending_grants;
+    uint8_t assigned_port[2];
+    uint8_t flags;
+    uint8_t sync_time[MPCP_TIMESTAMP_DURATION_LEN];
+    uint8_t echoed_pending_grants;
 };
 
 static const struct tok mpcp_reg_flag_values[] = {
@@ -120,9 +110,9 @@
 };
 
 struct mpcp_reg_ack_t {
-    u_int8_t flags;
-    u_int8_t echoed_assigned_port[2];
-    u_int8_t echoed_sync_time[MPCP_TIMESTAMP_DURATION_LEN];
+    uint8_t flags;
+    uint8_t echoed_assigned_port[2];
+    uint8_t echoed_sync_time[MPCP_TIMESTAMP_DURATION_LEN];
 };
 
 static const struct tok mpcp_reg_ack_flag_values[] = {
@@ -132,8 +122,8 @@
 };
 
 void
-mpcp_print(register const u_char *pptr, register u_int length) {
-
+mpcp_print(netdissect_options *ndo, register const u_char *pptr, register u_int length)
+{
     union {
         const struct mpcp_common_header_t *common_header;
         const struct mpcp_grant_t *grant;
@@ -144,23 +134,22 @@
 
 
     const u_char *tptr;
-    u_int16_t opcode;
-    u_int8_t grant_numbers, grant;
-    u_int8_t queue_sets, queue_set, report_bitmap, report;
+    uint16_t opcode;
+    uint8_t grant_numbers, grant;
+    uint8_t queue_sets, queue_set, report_bitmap, report;
 
     tptr=pptr;
     mpcp.common_header = (const struct mpcp_common_header_t *)pptr;
 
-    if (!TTEST2(*tptr, sizeof(const struct mpcp_common_header_t)))
-        goto trunc;
+    ND_TCHECK2(*tptr, sizeof(const struct mpcp_common_header_t));
     opcode = EXTRACT_16BITS(mpcp.common_header->opcode);
-    printf("MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode));
+    ND_PRINT((ndo, "MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode)));
     if (opcode != MPCP_OPCODE_PAUSE) {
-        printf(", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp));
+        ND_PRINT((ndo, ", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp)));
     }
-    printf(", length %u", length);
+    ND_PRINT((ndo, ", length %u", length));
 
-    if (!vflag)
+    if (!ndo->ndo_vflag)
         return;
 
     tptr += sizeof(const struct mpcp_common_header_t);
@@ -170,57 +159,51 @@
         break;
 
     case MPCP_OPCODE_GATE:
-	if (!TTEST2(*tptr, MPCP_GRANT_NUMBER_LEN))
-	    goto trunc;
+        ND_TCHECK2(*tptr, MPCP_GRANT_NUMBER_LEN);
         grant_numbers = *tptr & MPCP_GRANT_NUMBER_MASK;
-        printf("\n\tGrant Numbers %u, Flags [ %s ]",
+        ND_PRINT((ndo, "\n\tGrant Numbers %u, Flags [ %s ]",
                grant_numbers,
                bittok2str(mpcp_grant_flag_values,
                           "?",
-                          *tptr &~ MPCP_GRANT_NUMBER_MASK));
+                          *tptr &~ MPCP_GRANT_NUMBER_MASK)));
         tptr++;
 
         for (grant = 1; grant <= grant_numbers; grant++) {
-            if (!TTEST2(*tptr, sizeof(const struct mpcp_grant_t)))
-                goto trunc;
-            mpcp.grant = (const struct mpcp_grant_t *)tptr;        
-            printf("\n\tGrant #%u, Start-Time %u ticks, duration %u ticks",
+            ND_TCHECK2(*tptr, sizeof(const struct mpcp_grant_t));
+            mpcp.grant = (const struct mpcp_grant_t *)tptr;
+            ND_PRINT((ndo, "\n\tGrant #%u, Start-Time %u ticks, duration %u ticks",
                    grant,
                    EXTRACT_32BITS(mpcp.grant->starttime),
-                   EXTRACT_16BITS(mpcp.grant->duration));
+                   EXTRACT_16BITS(mpcp.grant->duration)));
             tptr += sizeof(const struct mpcp_grant_t);
         }
 
-	if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
-	    goto trunc;
-        printf("\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr));
+        ND_TCHECK2(*tptr, MPCP_TIMESTAMP_DURATION_LEN);
+        ND_PRINT((ndo, "\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr)));
         break;
 
 
     case MPCP_OPCODE_REPORT:
-	if (!TTEST2(*tptr, MPCP_REPORT_QUEUESETS_LEN))
-	    goto trunc;
+        ND_TCHECK2(*tptr, MPCP_REPORT_QUEUESETS_LEN);
         queue_sets = *tptr;
         tptr+=MPCP_REPORT_QUEUESETS_LEN;
-        printf("\n\tTotal Queue-Sets %u", queue_sets);
+        ND_PRINT((ndo, "\n\tTotal Queue-Sets %u", queue_sets));
 
         for (queue_set = 1; queue_set < queue_sets; queue_set++) {
-            if (!TTEST2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN))
-                goto trunc;
+            ND_TCHECK2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN);
             report_bitmap = *(tptr);
-            printf("\n\t  Queue-Set #%u, Report-Bitmap [ %s ]",
+            ND_PRINT((ndo, "\n\t  Queue-Set #%u, Report-Bitmap [ %s ]",
                    queue_sets,
-                   bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap));
+                   bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap)));
             tptr++;
 
             report=1;
-            while (report_bitmap != 0) { 
+            while (report_bitmap != 0) {
                 if (report_bitmap & 1) {
-                    if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
-                        goto trunc;
-                    printf("\n\t    Q%u Report, Duration %u ticks",
+                    ND_TCHECK2(*tptr, MPCP_TIMESTAMP_DURATION_LEN);
+                    ND_PRINT((ndo, "\n\t    Q%u Report, Duration %u ticks",
                            report,
-                           EXTRACT_16BITS(tptr));
+                           EXTRACT_16BITS(tptr)));
                     tptr+=MPCP_TIMESTAMP_DURATION_LEN;
                 }
                 report++;
@@ -230,45 +213,48 @@
         break;
 
     case MPCP_OPCODE_REG_REQ:
-        if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_req_t)))
-            goto trunc;
-        mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr;        
-        printf("\n\tFlags [ %s ], Pending-Grants %u",
+        ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_req_t));
+        mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr;
+        ND_PRINT((ndo, "\n\tFlags [ %s ], Pending-Grants %u",
                bittok2str(mpcp_reg_req_flag_values, "Reserved", mpcp.reg_req->flags),
-               mpcp.reg_req->pending_grants);
+               mpcp.reg_req->pending_grants));
         break;
 
     case MPCP_OPCODE_REG:
-        if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_t)))
-            goto trunc;
-        mpcp.reg = (const struct mpcp_reg_t *)tptr;        
-        printf("\n\tAssigned-Port %u, Flags [ %s ]" \
+        ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_t));
+        mpcp.reg = (const struct mpcp_reg_t *)tptr;
+        ND_PRINT((ndo, "\n\tAssigned-Port %u, Flags [ %s ]" \
                "\n\tSync-Time %u ticks, Echoed-Pending-Grants %u",
                EXTRACT_16BITS(mpcp.reg->assigned_port),
                bittok2str(mpcp_reg_flag_values, "Reserved", mpcp.reg->flags),
                EXTRACT_16BITS(mpcp.reg->sync_time),
-               mpcp.reg->echoed_pending_grants);
+               mpcp.reg->echoed_pending_grants));
         break;
 
     case MPCP_OPCODE_REG_ACK:
-        if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_ack_t)))
-            goto trunc;
-        mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr;        
-        printf("\n\tEchoed-Assigned-Port %u, Flags [ %s ]" \
+        ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_ack_t));
+        mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr;
+        ND_PRINT((ndo, "\n\tEchoed-Assigned-Port %u, Flags [ %s ]" \
                "\n\tEchoed-Sync-Time %u ticks",
                EXTRACT_16BITS(mpcp.reg_ack->echoed_assigned_port),
                bittok2str(mpcp_reg_ack_flag_values, "Reserved", mpcp.reg_ack->flags),
-               EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time));
+               EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time)));
         break;
 
     default:
         /* unknown opcode - hexdump for now */
-        print_unknown_data(pptr, "\n\t", length);
+        print_unknown_data(ndo,pptr, "\n\t", length);
         break;
     }
 
     return;
 
 trunc:
-    printf("\n\t[|MPCP]");
+    ND_PRINT((ndo, "\n\t[|MPCP]"));
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print-mpls.c b/print-mpls.c
index d97cce5..bc34d50 100644
--- a/print-mpls.c
+++ b/print-mpls.c
@@ -26,22 +26,13 @@
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.14 2005-07-05 09:38:19 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "addrtoname.h"
 #include "interface.h"
 #include "extract.h"			/* must come after interface.h */
 #include "mpls.h"
@@ -65,29 +56,29 @@
  * RFC3032: MPLS label stack encoding
  */
 void
-mpls_print(const u_char *bp, u_int length)
+mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
 	const u_char *p;
-	u_int32_t label_entry;
-	u_int16_t label_stack_depth = 0;
+	uint32_t label_entry;
+	uint16_t label_stack_depth = 0;
 	enum mpls_packet_type pt = PT_UNKNOWN;
 
 	p = bp;
-	printf("MPLS");
+	ND_PRINT((ndo, "MPLS"));
 	do {
-		TCHECK2(*p, sizeof(label_entry));
+		ND_TCHECK2(*p, sizeof(label_entry));
 		label_entry = EXTRACT_32BITS(p);
-		printf("%s(label %u",
-		       (label_stack_depth && vflag) ? "\n\t" : " ",
-       		       MPLS_LABEL(label_entry));
+		ND_PRINT((ndo, "%s(label %u",
+		       (label_stack_depth && ndo->ndo_vflag) ? "\n\t" : " ",
+       		       MPLS_LABEL(label_entry)));
 		label_stack_depth++;
-		if (vflag &&
+		if (ndo->ndo_vflag &&
 		    MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
-			printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]);
-		printf(", exp %u", MPLS_EXP(label_entry));
+			ND_PRINT((ndo, " (%s)", mpls_labelname[MPLS_LABEL(label_entry)]));
+		ND_PRINT((ndo, ", exp %u", MPLS_EXP(label_entry)));
 		if (MPLS_STACK(label_entry))
-			printf(", [S]");
-		printf(", ttl %u)", MPLS_TTL(label_entry));
+			ND_PRINT((ndo, ", [S]"));
+		ND_PRINT((ndo, ", ttl %u)", MPLS_TTL(label_entry)));
 
 		p += sizeof(label_entry);
 	} while (!MPLS_STACK(label_entry));
@@ -147,7 +138,7 @@
 		case 0x4f:
 			pt = PT_IPV4;
 			break;
-				
+
 		case 0x60:
 		case 0x61:
 		case 0x62:
@@ -183,30 +174,23 @@
 	 * Print the payload.
 	 */
 	if (pt == PT_UNKNOWN) {
-		if (!suppress_default_print)
-			default_print(p, length - (p - bp));
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, length - (p - bp));
 		return;
 	}
-	if (vflag)
-		printf("\n\t");
-	else
-		printf(" ");
+	ND_PRINT((ndo, ndo->ndo_vflag ? "\n\t" : " "));
 	switch (pt) {
 
 	case PT_IPV4:
-		ip_print(gndo, p, length - (p - bp));
+		ip_print(ndo, p, length - (p - bp));
 		break;
 
 	case PT_IPV6:
-#ifdef INET6
-		ip6_print(gndo, p, length - (p - bp));
-#else
-		printf("IPv6, length: %u", length);
-#endif
+		ip6_print(ndo, p, length - (p - bp));
 		break;
 
 	case PT_OSI:
-		isoclns_print(p, length - (p - bp), length - (p - bp));
+		isoclns_print(ndo, p, length - (p - bp), length - (p - bp));
 		break;
 
 	default:
@@ -215,7 +199,7 @@
 	return;
 
 trunc:
-	printf("[|MPLS]");
+	ND_PRINT((ndo, "[|MPLS]"));
 }
 
 
diff --git a/print-mptcp.c b/print-mptcp.c
index 17be82f..f85f1d2 100644
--- a/print-mptcp.c
+++ b/print-mptcp.c
@@ -32,29 +32,146 @@
  * SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 
-#include "ipproto.h"
-#include "mptcp.h"
 #include "tcp.h"
 
-static int dummy_print(const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
+#define MPTCP_SUB_CAPABLE       0x0
+#define MPTCP_SUB_JOIN          0x1
+#define MPTCP_SUB_DSS           0x2
+#define MPTCP_SUB_ADD_ADDR      0x3
+#define MPTCP_SUB_REMOVE_ADDR   0x4
+#define MPTCP_SUB_PRIO          0x5
+#define MPTCP_SUB_FAIL          0x6
+#define MPTCP_SUB_FCLOSE        0x7
+
+struct mptcp_option {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub_etc;        /* subtype upper 4 bits, other stuff lower 4 bits */
+};
+
+#define MPTCP_OPT_SUBTYPE(sub_etc)      (((sub_etc) >> 4) & 0xF)
+
+struct mp_capable {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub_ver;
+        uint8_t        flags;
+        uint8_t        sender_key[8];
+        uint8_t        receiver_key[8];
+};
+
+#define MP_CAPABLE_OPT_VERSION(sub_ver) (((sub_ver) >> 0) & 0xF)
+#define MP_CAPABLE_C                    0x80
+#define MP_CAPABLE_S                    0x01
+
+struct mp_join {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub_b;
+        uint8_t        addr_id;
+        union {
+                struct {
+                        uint8_t         token[4];
+                        uint8_t         nonce[4];
+                } syn;
+                struct {
+                        uint8_t         mac[8];
+                        uint8_t         nonce[4];
+                } synack;
+                struct {
+                        uint8_t        mac[20];
+                } ack;
+        } u;
+};
+
+#define MP_JOIN_B                       0x01
+
+struct mp_dss {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub;
+        uint8_t        flags;
+};
+
+#define MP_DSS_F                        0x10
+#define MP_DSS_m                        0x08
+#define MP_DSS_M                        0x04
+#define MP_DSS_a                        0x02
+#define MP_DSS_A                        0x01
+
+struct mp_add_addr {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub_ipver;
+        uint8_t        addr_id;
+        union {
+                struct {
+                        uint8_t         addr[4];
+                        uint8_t         port[2];
+                } v4;
+                struct {
+                        uint8_t         addr[16];
+                        uint8_t         port[2];
+                } v6;
+        } u;
+};
+
+#define MP_ADD_ADDR_IPVER(sub_ipver)    (((sub_ipver) >> 0) & 0xF)
+
+struct mp_remove_addr {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub;
+        /* list of addr_id */
+        uint8_t        addrs_id;
+};
+
+struct mp_fail {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub;
+        uint8_t        resv;
+        uint8_t        data_seq[8];
+};
+
+struct mp_close {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub;
+        uint8_t        rsv;
+        uint8_t        key[8];
+};
+
+struct mp_prio {
+        uint8_t        kind;
+        uint8_t        len;
+        uint8_t        sub_b;
+        uint8_t        addr_id;
+};
+
+#define MP_PRIO_B                       0x01
+
+static int
+dummy_print(netdissect_options *ndo _U_,
+            const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
 {
         return 1;
 }
 
-static int mp_capable_print(const u_char *opt, u_int opt_len, u_char flags)
+static int
+mp_capable_print(netdissect_options *ndo,
+                 const u_char *opt, u_int opt_len, u_char flags)
 {
         struct mp_capable *mpc = (struct mp_capable *) opt;
 
@@ -63,20 +180,22 @@
                 return 0;
 
         if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {
-                printf(" Unknown Version (%d)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver));
+                ND_PRINT((ndo, " Unknown Version (%d)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver)));
                 return 1;
         }
 
         if (mpc->flags & MP_CAPABLE_C)
-                printf(" csum");
-        printf(" {0x%" PRIx64, EXTRACT_64BITS(mpc->sender_key));
+                ND_PRINT((ndo, " csum"));
+        ND_PRINT((ndo, " {0x%" PRIx64, EXTRACT_64BITS(mpc->sender_key)));
         if (opt_len == 20) /* ACK */
-                printf(",0x%" PRIx64, EXTRACT_64BITS(mpc->receiver_key));
-        printf("}");
+                ND_PRINT((ndo, ",0x%" PRIx64, EXTRACT_64BITS(mpc->receiver_key)));
+        ND_PRINT((ndo, "}"));
         return 1;
 }
 
-static int mp_join_print(const u_char *opt, u_int opt_len, u_char flags)
+static int
+mp_join_print(netdissect_options *ndo,
+              const u_char *opt, u_int opt_len, u_char flags)
 {
         struct mp_join *mpj = (struct mp_join *) opt;
 
@@ -87,26 +206,26 @@
 
         if (opt_len != 24) {
                 if (mpj->sub_b & MP_JOIN_B)
-                        printf(" backup");
-                printf(" id %u", mpj->addr_id);
+                        ND_PRINT((ndo, " backup"));
+                ND_PRINT((ndo, " id %u", mpj->addr_id));
         }
 
         switch (opt_len) {
         case 12: /* SYN */
-                printf(" token 0x%x" " nonce 0x%x",
+                ND_PRINT((ndo, " token 0x%x" " nonce 0x%x",
                         EXTRACT_32BITS(mpj->u.syn.token),
-                        EXTRACT_32BITS(mpj->u.syn.nonce));
+                        EXTRACT_32BITS(mpj->u.syn.nonce)));
                 break;
         case 16: /* SYN/ACK */
-                printf(" hmac 0x%" PRIx64 " nonce 0x%x",
+                ND_PRINT((ndo, " hmac 0x%" PRIx64 " nonce 0x%x",
                         EXTRACT_64BITS(mpj->u.synack.mac),
-                        EXTRACT_32BITS(mpj->u.synack.nonce));
+                        EXTRACT_32BITS(mpj->u.synack.nonce)));
                 break;
         case 24: {/* ACK */
                 size_t i;
-                printf(" hmac 0x");
+                ND_PRINT((ndo, " hmac 0x"));
                 for (i = 0; i < sizeof(mpj->u.ack.mac); ++i)
-                        printf("%02x", mpj->u.ack.mac[i]);
+                        ND_PRINT((ndo, "%02x", mpj->u.ack.mac[i]));
         }
         default:
                 break;
@@ -142,7 +261,9 @@
 	return len;
 }
 
-static int mp_dss_print(const u_char *opt, u_int opt_len, u_char flags)
+static int
+mp_dss_print(netdissect_options *ndo,
+             const u_char *opt, u_int opt_len, u_char flags)
 {
         struct mp_dss *mdss = (struct mp_dss *) opt;
 
@@ -151,41 +272,43 @@
                 return 0;
 
         if (mdss->flags & MP_DSS_F)
-                printf(" fin");
+                ND_PRINT((ndo, " fin"));
 
         opt += 4;
         if (mdss->flags & MP_DSS_A) {
-                printf(" ack ");
+                ND_PRINT((ndo, " ack "));
                 if (mdss->flags & MP_DSS_a) {
-                        printf("%" PRIu64, EXTRACT_64BITS(opt));
+                        ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
                         opt += 8;
                 } else {
-                        printf("%u", EXTRACT_32BITS(opt));
+                        ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
                         opt += 4;
                 }
         }
 
         if (mdss->flags & MP_DSS_M) {
-                printf(" seq ");
+                ND_PRINT((ndo, " seq "));
                 if (mdss->flags & MP_DSS_m) {
-                        printf("%" PRIu64, EXTRACT_64BITS(opt));
+                        ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
                         opt += 8;
                 } else {
-                        printf("%u", EXTRACT_32BITS(opt));
+                        ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
                         opt += 4;
                 }
-                printf(" subseq %u", EXTRACT_32BITS(opt));
+                ND_PRINT((ndo, " subseq %u", EXTRACT_32BITS(opt)));
                 opt += 4;
-                printf(" len %u", EXTRACT_16BITS(opt));
+                ND_PRINT((ndo, " len %u", EXTRACT_16BITS(opt)));
                 opt += 2;
 
                 if (opt_len == mp_dss_len(mdss, 1))
-                        printf(" csum 0x%x", EXTRACT_16BITS(opt));
+                        ND_PRINT((ndo, " csum 0x%x", EXTRACT_16BITS(opt)));
         }
         return 1;
 }
 
-static int add_addr_print(const u_char *opt, u_int opt_len, u_char flags _U_)
+static int
+add_addr_print(netdissect_options *ndo,
+               const u_char *opt, u_int opt_len, u_char flags _U_)
 {
         struct mp_add_addr *add_addr = (struct mp_add_addr *) opt;
         u_int ipver = MP_ADD_ADDR_IPVER(add_addr->sub_ipver);
@@ -194,19 +317,19 @@
             !((opt_len == 20 || opt_len == 22) && ipver == 6))
                 return 0;
 
-        printf(" id %u", add_addr->addr_id);
+        ND_PRINT((ndo, " id %u", add_addr->addr_id));
         switch (ipver) {
         case 4:
-                printf(" %s", ipaddr_string(add_addr->u.v4.addr));
+                ND_PRINT((ndo, " %s", ipaddr_string(ndo, add_addr->u.v4.addr)));
                 if (opt_len == 10)
-                        printf(":%u", EXTRACT_16BITS(add_addr->u.v4.port));
+                        ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v4.port)));
                 break;
         case 6:
 #ifdef INET6
-                printf(" %s", ip6addr_string(add_addr->u.v6.addr));
+                ND_PRINT((ndo, " %s", ip6addr_string(ndo, add_addr->u.v6.addr)));
 #endif
                 if (opt_len == 22)
-                        printf(":%u", EXTRACT_16BITS(add_addr->u.v6.port));
+                        ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v6.port)));
                 break;
         default:
                 return 0;
@@ -215,22 +338,26 @@
         return 1;
 }
 
-static int remove_addr_print(const u_char *opt, u_int opt_len, u_char flags _U_)
+static int
+remove_addr_print(netdissect_options *ndo,
+                  const u_char *opt, u_int opt_len, u_char flags _U_)
 {
         struct mp_remove_addr *remove_addr = (struct mp_remove_addr *) opt;
-        u_int8_t *addr_id = &remove_addr->addrs_id;
+        uint8_t *addr_id = &remove_addr->addrs_id;
 
         if (opt_len < 4)
                 return 0;
 
         opt_len -= 3;
-        printf(" id");
+        ND_PRINT((ndo, " id"));
         while (opt_len--)
-                printf(" %u", *addr_id++);
+                ND_PRINT((ndo, " %u", *addr_id++));
         return 1;
 }
 
-static int mp_prio_print(const u_char *opt, u_int opt_len, u_char flags _U_)
+static int
+mp_prio_print(netdissect_options *ndo,
+              const u_char *opt, u_int opt_len, u_char flags _U_)
 {
         struct mp_prio *mpp = (struct mp_prio *) opt;
 
@@ -238,36 +365,40 @@
                 return 0;
 
         if (mpp->sub_b & MP_PRIO_B)
-                printf(" backup");
+                ND_PRINT((ndo, " backup"));
         else
-                printf(" non-backup");
+                ND_PRINT((ndo, " non-backup"));
         if (opt_len == 4)
-                printf(" id %u", mpp->addr_id);
+                ND_PRINT((ndo, " id %u", mpp->addr_id));
 
         return 1;
 }
 
-static int mp_fail_print(const u_char *opt, u_int opt_len, u_char flags _U_)
+static int
+mp_fail_print(netdissect_options *ndo,
+              const u_char *opt, u_int opt_len, u_char flags _U_)
 {
         if (opt_len != 12)
                 return 0;
 
-        printf(" seq %" PRIu64, EXTRACT_64BITS(opt + 4));
+        ND_PRINT((ndo, " seq %" PRIu64, EXTRACT_64BITS(opt + 4)));
         return 1;
 }
 
-static int mp_fast_close_print(const u_char *opt, u_int opt_len, u_char flags _U_)
+static int
+mp_fast_close_print(netdissect_options *ndo,
+                    const u_char *opt, u_int opt_len, u_char flags _U_)
 {
         if (opt_len != 12)
                 return 0;
 
-        printf(" key 0x%" PRIx64, EXTRACT_64BITS(opt + 4));
+        ND_PRINT((ndo, " key 0x%" PRIx64, EXTRACT_64BITS(opt + 4)));
         return 1;
 }
 
-static struct {
+static const struct {
         const char *name;
-        int (*print)(const u_char *, u_int, u_char);
+        int (*print)(netdissect_options *, const u_char *, u_int, u_char);
 } mptcp_options[] = {
         { "capable", mp_capable_print},
         { "join",       mp_join_print },
@@ -280,7 +411,9 @@
         { "unknown",    dummy_print },
 };
 
-int mptcp_print(const u_char *cp, u_int len, u_char flags)
+int
+mptcp_print(netdissect_options *ndo,
+            const u_char *cp, u_int len, u_char flags)
 {
         struct mptcp_option *opt;
         u_int subtype;
@@ -291,6 +424,6 @@
         opt = (struct mptcp_option *) cp;
         subtype = min(MPTCP_OPT_SUBTYPE(opt->sub_etc), MPTCP_SUB_FCLOSE + 1);
 
-        printf(" %s", mptcp_options[subtype].name);
-        return mptcp_options[subtype].print(cp, len, flags);
+        ND_PRINT((ndo, " %s", mptcp_options[subtype].name));
+        return mptcp_options[subtype].print(ndo, cp, len, flags);
 }
diff --git a/print-msdp.c b/print-msdp.c
index a228ab7..fb802b5 100644
--- a/print-msdp.c
+++ b/print-msdp.c
@@ -15,20 +15,14 @@
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp $";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -36,23 +30,23 @@
 #define MSDP_TYPE_MAX	7
 
 void
-msdp_print(const unsigned char *sp, u_int length)
+msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
 {
 	unsigned int type, len;
 
-	TCHECK2(*sp, 3);
+	ND_TCHECK2(*sp, 3);
 	/* See if we think we're at the beginning of a compound packet */
 	type = *sp;
 	len = EXTRACT_16BITS(sp + 1);
 	if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX)
 		goto trunc;	/* not really truncated, but still not decodable */
-	(void)printf(" msdp:");
+	ND_PRINT((ndo, " msdp:"));
 	while (length > 0) {
-		TCHECK2(*sp, 3);
+		ND_TCHECK2(*sp, 3);
 		type = *sp;
 		len = EXTRACT_16BITS(sp + 1);
-		if (len > 1400 || vflag)
-			printf(" [len %u]", len);
+		if (len > 1400 || ndo->ndo_vflag)
+			ND_PRINT((ndo, " [len %u]", len));
 		if (len < 3)
 			goto trunc;
 		sp += 3;
@@ -61,35 +55,35 @@
 		case 1:	/* IPv4 Source-Active */
 		case 3: /* IPv4 Source-Active Response */
 			if (type == 1)
-				(void)printf(" SA");
+				ND_PRINT((ndo, " SA"));
 			else
-				(void)printf(" SA-Response");
-			TCHECK(*sp);
-			(void)printf(" %u entries", *sp);
+				ND_PRINT((ndo, " SA-Response"));
+			ND_TCHECK(*sp);
+			ND_PRINT((ndo, " %u entries", *sp));
 			if ((u_int)((*sp * 12) + 8) < len) {
-				(void)printf(" [w/data]");
-				if (vflag > 1) {
-					(void)printf(" ");
-					ip_print(gndo, sp + *sp * 12 + 8 - 3,
+				ND_PRINT((ndo, " [w/data]"));
+				if (ndo->ndo_vflag > 1) {
+					ND_PRINT((ndo, " "));
+					ip_print(ndo, sp + *sp * 12 + 8 - 3,
 					         len - (*sp * 12 + 8));
 				}
 			}
 			break;
 		case 2:
-			(void)printf(" SA-Request");
-			TCHECK2(*sp, 5);
-			(void)printf(" for %s", ipaddr_string(sp + 1));
+			ND_PRINT((ndo, " SA-Request"));
+			ND_TCHECK2(*sp, 5);
+			ND_PRINT((ndo, " for %s", ipaddr_string(ndo, sp + 1)));
 			break;
 		case 4:
-			(void)printf(" Keepalive");
+			ND_PRINT((ndo, " Keepalive"));
 			if (len != 3)
-				(void)printf("[len=%d] ", len);
+				ND_PRINT((ndo, "[len=%d] ", len));
 			break;
 		case 5:
-			(void)printf(" Notification");
+			ND_PRINT((ndo, " Notification"));
 			break;
 		default:
-			(void)printf(" [type=%d len=%d]", type, len);
+			ND_PRINT((ndo, " [type=%d len=%d]", type, len));
 			break;
 		}
 		sp += (len - 3);
@@ -97,7 +91,7 @@
 	}
 	return;
 trunc:
-	(void)printf(" [|msdp]");
+	ND_PRINT((ndo, " [|msdp]"));
 }
 
 /*
diff --git a/print-msnlb.c b/print-msnlb.c
index b300498..fcd0006 100644
--- a/print-msnlb.c
+++ b/print-msnlb.c
@@ -26,25 +26,23 @@
  * SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
+#include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 
 struct msnlb_heartbeat_pkt {
-	u_int32_t unknown1;
-	u_int32_t unknown2;
-	u_int32_t host_prio;	/* little-endian */
-	u_int32_t virtual_ip;
-	u_int32_t host_ip;
+	uint32_t unknown1;
+	uint32_t unknown2;
+	uint32_t host_prio;	/* little-endian */
+	uint32_t virtual_ip;
+	uint32_t host_ip;
 	/* the protocol is undocumented so we ignore the rest */
 };
 
@@ -58,8 +56,8 @@
 
 	ND_PRINT((ndo, "MS NLB heartbeat, host priority: %u,",
 		EXTRACT_LE_32BITS(&(hb->host_prio))));
-	ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(&(hb->virtual_ip))));
-	ND_PRINT((ndo, " host IP: %s", ipaddr_string(&(hb->host_ip))));
+	ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(ndo, &(hb->virtual_ip))));
+	ND_PRINT((ndo, " host IP: %s", ipaddr_string(ndo, &(hb->host_ip))));
 	return;
 trunc:
 	ND_PRINT((ndo, "[|MS NLB]"));
diff --git a/print-netbios.c b/print-netbios.c
deleted file mode 100644
index c92eb9e..0000000
--- a/print-netbios.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 1994, 1995, 1996
- *	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.
- *
- * Format and print NETBIOS packets.
- * Contributed by Brad Parker (brad@fcr.com).
- */
-
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp $";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tcpdump-stdinc.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
-#include "addrtoname.h"
-#include "netbios.h"
-#include "extract.h"
-
-/*
- * Print NETBIOS packets.
- */
-void
-netbios_print(struct p8022Hdr *nb, u_int length)
-{
-	if (length < p8022Size) {
-		(void)printf(" truncated-netbios %d", length);
-		return;
-	}
-
-	if (nb->flags == UI) {
-	    (void)printf("802.1 UI ");
-	} else {
-	    (void)printf("802.1 CONN ");
-	}
-
-	if ((u_char *)(nb + 1) > snapend) {
-		printf(" [|netbios]");
-		return;
-	}
-
-/*
-	netbios_decode(nb, (u_char *)nb + p8022Size, length - p8022Size);
-*/
-}
-
-#ifdef never
-	(void)printf("%s.%d > ",
-		     ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
-		     EXTRACT_16BITS(ipx->srcSkt));
-
-	(void)printf("%s.%d:",
-		     ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
-		     EXTRACT_16BITS(ipx->dstSkt));
-
-	if ((u_char *)(ipx + 1) > snapend) {
-		printf(" [|ipx]");
-		return;
-	}
-
-	/* take length from ipx header */
-	length = EXTRACT_16BITS(&ipx->length);
-
-	ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
-#endif
-
diff --git a/print-nflog.c b/print-nflog.c
index 94dee18..95da4cb 100644
--- a/print-nflog.c
+++ b/print-nflog.c
@@ -25,16 +25,13 @@
  * DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
-#include "netdissect.h"
 #include "interface.h"
 
 #if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
@@ -42,12 +39,14 @@
 
 static const struct tok nflog_values[] = {
 	{ AF_INET,		"IPv4" },
+#ifdef INET6
 	{ AF_INET6,		"IPv6" },
-	{ 0,				NULL }
+#endif /*INET6*/
+	{ 0,			NULL }
 };
 
 static inline void
-nflog_hdr_print(struct netdissect_options *ndo, const nflog_hdr_t *hdr, u_int length)
+nflog_hdr_print(netdissect_options *ndo, const nflog_hdr_t *hdr, u_int length)
 {
 	ND_PRINT((ndo, "version %d, resource ID %d", hdr->nflog_version, ntohs(hdr->nflog_rid)));
 
@@ -67,13 +66,13 @@
 }
 
 u_int
-nflog_if_print(struct netdissect_options *ndo,
+nflog_if_print(netdissect_options *ndo,
 			   const struct pcap_pkthdr *h, const u_char *p)
 {
 	const nflog_hdr_t *hdr = (const nflog_hdr_t *)p;
 	const nflog_tlv_t *tlv;
-	u_int16_t size;
-	u_int16_t h_size = sizeof(nflog_hdr_t);
+	uint16_t size;
+	uint16_t h_size = sizeof(nflog_hdr_t);
 	u_int caplen = h->caplen;
 	u_int length = h->len;
 
@@ -146,11 +145,11 @@
 		ip_print(ndo, p, length);
 		break;
 
-#ifdef INET6
+#ifdef AF_INET6
 	case AF_INET6:
 		ip6_print(ndo, p, length);
 		break;
-#endif /*INET6*/
+#endif /* AF_INET6 */
 
 	default:
 		if (!ndo->ndo_eflag)
@@ -158,7 +157,7 @@
 				length + sizeof(nflog_hdr_t));
 
 		if (!ndo->ndo_suppress_default_print)
-			ndo->ndo_default_print(ndo, p, caplen);
+			ND_DEFAULTPRINT(p, caplen);
 		break;
 	}
 
diff --git a/print-nfs.c b/print-nfs.c
index 526e543..dd2f7f1 100644
--- a/print-nfs.c
+++ b/print-nfs.c
@@ -19,18 +19,13 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.111 2007-12-22 03:08:04 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -48,19 +43,19 @@
 #include "rpc_auth.h"
 #include "rpc_msg.h"
 
-static void nfs_printfh(const u_int32_t *, const u_int);
-static int xid_map_enter(const struct sunrpc_msg *, const u_char *);
+static const char tstr[] = " [|nfs]";
+
+static void nfs_printfh(netdissect_options *, const uint32_t *, const u_int);
+static int xid_map_enter(netdissect_options *, const struct sunrpc_msg *, const u_char *);
 static int xid_map_find(const struct sunrpc_msg *, const u_char *,
-			    u_int32_t *, u_int32_t *);
-static void interp_reply(const struct sunrpc_msg *, u_int32_t, u_int32_t, int);
-static const u_int32_t *parse_post_op_attr(const u_int32_t *, int);
-static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose);
-static void print_nfsaddr(const u_char *, const char *, const char *);
+			    uint32_t *, uint32_t *);
+static void interp_reply(netdissect_options *, const struct sunrpc_msg *, uint32_t, uint32_t, int);
+static const uint32_t *parse_post_op_attr(netdissect_options *, const uint32_t *, int);
 
 /*
  * Mapping of old NFS Version 2 RPC numbers to generic numbers.
  */
-u_int32_t nfsv3_procid[NFS_NPROCS] = {
+uint32_t nfsv3_procid[NFS_NPROCS] = {
 	NFSPROC_NULL,
 	NFSPROC_GETATTR,
 	NFSPROC_SETATTR,
@@ -89,6 +84,33 @@
 	NFSPROC_NOOP
 };
 
+static const struct tok nfsproc_str[] = {
+	{ NFSPROC_NOOP,        "nop"         },
+	{ NFSPROC_NULL,        "null"        },
+	{ NFSPROC_GETATTR,     "getattr"     },
+	{ NFSPROC_SETATTR,     "setattr"     },
+	{ NFSPROC_LOOKUP,      "lookup"      },
+	{ NFSPROC_ACCESS,      "access"      },
+	{ NFSPROC_READLINK,    "readlink"    },
+	{ NFSPROC_READ,        "read"        },
+	{ NFSPROC_WRITE,       "write"       },
+	{ NFSPROC_CREATE,      "create"      },
+	{ NFSPROC_MKDIR,       "mkdir"       },
+	{ NFSPROC_SYMLINK,     "symlink"     },
+	{ NFSPROC_MKNOD,       "mknod"       },
+	{ NFSPROC_REMOVE,      "remove"      },
+	{ NFSPROC_RMDIR,       "rmdir"       },
+	{ NFSPROC_RENAME,      "rename"      },
+	{ NFSPROC_LINK,        "link"        },
+	{ NFSPROC_READDIR,     "readdir"     },
+	{ NFSPROC_READDIRPLUS, "readdirplus" },
+	{ NFSPROC_FSSTAT,      "fsstat"      },
+	{ NFSPROC_FSINFO,      "fsinfo"      },
+	{ NFSPROC_PATHCONF,    "pathconf"    },
+	{ NFSPROC_COMMIT,      "commit"      },
+	{ 0, NULL }
+};
+
 /*
  * NFS V2 and V3 status values.
  *
@@ -156,8 +178,30 @@
 	{ 0,		NULL }
 };
 
+static const struct tok sunrpc_auth_str[] = {
+	{ SUNRPC_AUTH_OK,           "OK"                                                     },
+	{ SUNRPC_AUTH_BADCRED,      "Bogus Credentials (seal broken)"                        },
+	{ SUNRPC_AUTH_REJECTEDCRED, "Rejected Credentials (client should begin new session)" },
+	{ SUNRPC_AUTH_BADVERF,      "Bogus Verifier (seal broken)"                           },
+	{ SUNRPC_AUTH_REJECTEDVERF, "Verifier expired or was replayed"                       },
+	{ SUNRPC_AUTH_TOOWEAK,      "Credentials are too weak"                               },
+	{ SUNRPC_AUTH_INVALIDRESP,  "Bogus response verifier"                                },
+	{ SUNRPC_AUTH_FAILED,       "Unknown failure"                                        },
+	{ 0, NULL }
+};
+
+static const struct tok sunrpc_str[] = {
+	{ SUNRPC_PROG_UNAVAIL,  "PROG_UNAVAIL"  },
+	{ SUNRPC_PROG_MISMATCH, "PROG_MISMATCH" },
+	{ SUNRPC_PROC_UNAVAIL,  "PROC_UNAVAIL"  },
+	{ SUNRPC_GARBAGE_ARGS,  "GARBAGE_ARGS"  },
+	{ SUNRPC_SYSTEM_ERR,    "SYSTEM_ERR"    },
+	{ 0, NULL }
+};
+
 static void
-print_nfsaddr(const u_char *bp, const char *s, const char *d)
+print_nfsaddr(netdissect_options *ndo,
+              const u_char *bp, const char *s, const char *d)
 {
 	struct ip *ip;
 #ifdef INET6
@@ -174,15 +218,15 @@
 	switch (IP_V((struct ip *)bp)) {
 	case 4:
 		ip = (struct ip *)bp;
-		strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr));
-		strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr));
+		strlcpy(srcaddr, ipaddr_string(ndo, &ip->ip_src), sizeof(srcaddr));
+		strlcpy(dstaddr, ipaddr_string(ndo, &ip->ip_dst), sizeof(dstaddr));
 		break;
 #ifdef INET6
 	case 6:
 		ip6 = (struct ip6_hdr *)bp;
-		strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src),
+		strlcpy(srcaddr, ip6addr_string(ndo, &ip6->ip6_src),
 		    sizeof(srcaddr));
-		strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst),
+		strlcpy(dstaddr, ip6addr_string(ndo, &ip6->ip6_dst),
 		    sizeof(dstaddr));
 		break;
 #endif
@@ -192,64 +236,65 @@
 		break;
 	}
 
-	(void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d);
+	ND_PRINT((ndo, "%s.%s > %s.%s: ", srcaddr, s, dstaddr, d));
 }
 
-static const u_int32_t *
-parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3)
+static const uint32_t *
+parse_sattr3(netdissect_options *ndo,
+             const uint32_t *dp, struct nfsv3_sattr *sa3)
 {
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	sa3->sa_modeset = EXTRACT_32BITS(dp);
 	dp++;
 	if (sa3->sa_modeset) {
-		TCHECK(dp[0]);
+		ND_TCHECK(dp[0]);
 		sa3->sa_mode = EXTRACT_32BITS(dp);
 		dp++;
 	}
 
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	sa3->sa_uidset = EXTRACT_32BITS(dp);
 	dp++;
 	if (sa3->sa_uidset) {
-		TCHECK(dp[0]);
+		ND_TCHECK(dp[0]);
 		sa3->sa_uid = EXTRACT_32BITS(dp);
 		dp++;
 	}
 
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	sa3->sa_gidset = EXTRACT_32BITS(dp);
 	dp++;
 	if (sa3->sa_gidset) {
-		TCHECK(dp[0]);
+		ND_TCHECK(dp[0]);
 		sa3->sa_gid = EXTRACT_32BITS(dp);
 		dp++;
 	}
 
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	sa3->sa_sizeset = EXTRACT_32BITS(dp);
 	dp++;
 	if (sa3->sa_sizeset) {
-		TCHECK(dp[0]);
+		ND_TCHECK(dp[0]);
 		sa3->sa_size = EXTRACT_32BITS(dp);
 		dp++;
 	}
 
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	sa3->sa_atimetype = EXTRACT_32BITS(dp);
 	dp++;
 	if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) {
-		TCHECK(dp[1]);
+		ND_TCHECK(dp[1]);
 		sa3->sa_atime.nfsv3_sec = EXTRACT_32BITS(dp);
 		dp++;
 		sa3->sa_atime.nfsv3_nsec = EXTRACT_32BITS(dp);
 		dp++;
 	}
 
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	sa3->sa_mtimetype = EXTRACT_32BITS(dp);
 	dp++;
 	if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) {
-		TCHECK(dp[1]);
+		ND_TCHECK(dp[1]);
 		sa3->sa_mtime.nfsv3_sec = EXTRACT_32BITS(dp);
 		dp++;
 		sa3->sa_mtime.nfsv3_nsec = EXTRACT_32BITS(dp);
@@ -264,27 +309,29 @@
 static int nfserr;		/* true if we error rather than trunc */
 
 static void
-print_sattr3(const struct nfsv3_sattr *sa3, int verbose)
+print_sattr3(netdissect_options *ndo,
+             const struct nfsv3_sattr *sa3, int verbose)
 {
 	if (sa3->sa_modeset)
-		printf(" mode %o", sa3->sa_mode);
+		ND_PRINT((ndo, " mode %o", sa3->sa_mode));
 	if (sa3->sa_uidset)
-		printf(" uid %u", sa3->sa_uid);
+		ND_PRINT((ndo, " uid %u", sa3->sa_uid));
 	if (sa3->sa_gidset)
-		printf(" gid %u", sa3->sa_gid);
+		ND_PRINT((ndo, " gid %u", sa3->sa_gid));
 	if (verbose > 1) {
 		if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT)
-			printf(" atime %u.%06u", sa3->sa_atime.nfsv3_sec,
-			       sa3->sa_atime.nfsv3_nsec);
+			ND_PRINT((ndo, " atime %u.%06u", sa3->sa_atime.nfsv3_sec,
+			       sa3->sa_atime.nfsv3_nsec));
 		if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT)
-			printf(" mtime %u.%06u", sa3->sa_mtime.nfsv3_sec,
-			       sa3->sa_mtime.nfsv3_nsec);
+			ND_PRINT((ndo, " mtime %u.%06u", sa3->sa_mtime.nfsv3_sec,
+			       sa3->sa_mtime.nfsv3_nsec));
 	}
 }
 
 void
-nfsreply_print(register const u_char *bp, u_int length,
-	       register const u_char *bp2)
+nfsreply_print(netdissect_options *ndo,
+               register const u_char *bp, u_int length,
+               register const u_char *bp2)
 {
 	register const struct sunrpc_msg *rp;
 	char srcid[20], dstid[20];	/*fits 32bit*/
@@ -292,8 +339,8 @@
 	nfserr = 0;		/* assume no error */
 	rp = (const struct sunrpc_msg *)bp;
 
-	TCHECK(rp->rm_xid);
-	if (!nflag) {
+	ND_TCHECK(rp->rm_xid);
+	if (!ndo->ndo_nflag) {
 		strlcpy(srcid, "nfs", sizeof(srcid));
 		snprintf(dstid, sizeof(dstid), "%u",
 		    EXTRACT_32BITS(&rp->rm_xid));
@@ -302,141 +349,101 @@
 		snprintf(dstid, sizeof(dstid), "%u",
 		    EXTRACT_32BITS(&rp->rm_xid));
 	}
-	print_nfsaddr(bp2, srcid, dstid);
+	print_nfsaddr(ndo, bp2, srcid, dstid);
 
-	nfsreply_print_noaddr(bp, length, bp2);
+	nfsreply_print_noaddr(ndo, bp, length, bp2);
 	return;
 
 trunc:
 	if (!nfserr)
-		fputs(" [|nfs]", stdout);
+		ND_PRINT((ndo, "%s", tstr));
 }
 
 void
-nfsreply_print_noaddr(register const u_char *bp, u_int length,
-	       register const u_char *bp2)
+nfsreply_print_noaddr(netdissect_options *ndo,
+                      register const u_char *bp, u_int length,
+                      register const u_char *bp2)
 {
 	register const struct sunrpc_msg *rp;
-	u_int32_t proc, vers, reply_stat;
+	uint32_t proc, vers, reply_stat;
 	enum sunrpc_reject_stat rstat;
-	u_int32_t rlow;
-	u_int32_t rhigh;
+	uint32_t rlow;
+	uint32_t rhigh;
 	enum sunrpc_auth_stat rwhy;
 
 	nfserr = 0;		/* assume no error */
 	rp = (const struct sunrpc_msg *)bp;
 
-	TCHECK(rp->rm_reply.rp_stat);
+	ND_TCHECK(rp->rm_reply.rp_stat);
 	reply_stat = EXTRACT_32BITS(&rp->rm_reply.rp_stat);
 	switch (reply_stat) {
 
 	case SUNRPC_MSG_ACCEPTED:
-		(void)printf("reply ok %u", length);
+		ND_PRINT((ndo, "reply ok %u", length));
 		if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
-			interp_reply(rp, proc, vers, length);
+			interp_reply(ndo, rp, proc, vers, length);
 		break;
 
 	case SUNRPC_MSG_DENIED:
-		(void)printf("reply ERR %u: ", length);
-		TCHECK(rp->rm_reply.rp_reject.rj_stat);
+		ND_PRINT((ndo, "reply ERR %u: ", length));
+		ND_TCHECK(rp->rm_reply.rp_reject.rj_stat);
 		rstat = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_stat);
 		switch (rstat) {
 
 		case SUNRPC_RPC_MISMATCH:
-			TCHECK(rp->rm_reply.rp_reject.rj_vers.high);
+			ND_TCHECK(rp->rm_reply.rp_reject.rj_vers.high);
 			rlow = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.low);
 			rhigh = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.high);
-			(void)printf("RPC Version mismatch (%u-%u)",
-			    rlow, rhigh);
+			ND_PRINT((ndo, "RPC Version mismatch (%u-%u)", rlow, rhigh));
 			break;
 
 		case SUNRPC_AUTH_ERROR:
-			TCHECK(rp->rm_reply.rp_reject.rj_why);
+			ND_TCHECK(rp->rm_reply.rp_reject.rj_why);
 			rwhy = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_why);
-			(void)printf("Auth ");
-			switch (rwhy) {
-
-			case SUNRPC_AUTH_OK:
-				(void)printf("OK");
-				break;
-
-			case SUNRPC_AUTH_BADCRED:
-				(void)printf("Bogus Credentials (seal broken)");
-				break;
-
-			case SUNRPC_AUTH_REJECTEDCRED:
-				(void)printf("Rejected Credentials (client should begin new session)");
-				break;
-
-			case SUNRPC_AUTH_BADVERF:
-				(void)printf("Bogus Verifier (seal broken)");
-				break;
-
-			case SUNRPC_AUTH_REJECTEDVERF:
-				(void)printf("Verifier expired or was replayed");
-				break;
-
-			case SUNRPC_AUTH_TOOWEAK:
-				(void)printf("Credentials are too weak");
-				break;
-
-			case SUNRPC_AUTH_INVALIDRESP:
-				(void)printf("Bogus response verifier");
-				break;
-
-			case SUNRPC_AUTH_FAILED:
-				(void)printf("Unknown failure");
-				break;
-
-			default:
-				(void)printf("Invalid failure code %u",
-				    (unsigned int)rwhy);
-				break;
-			}
+			ND_PRINT((ndo, "Auth %s", tok2str(sunrpc_auth_str, "Invalid failure code %u", rwhy)));
 			break;
 
 		default:
-			(void)printf("Unknown reason for rejecting rpc message %u",
-			    (unsigned int)rstat);
+			ND_PRINT((ndo, "Unknown reason for rejecting rpc message %u", (unsigned int)rstat));
 			break;
 		}
 		break;
 
 	default:
-		(void)printf("reply Unknown rpc response code=%u %u",
-		    reply_stat, length);
+		ND_PRINT((ndo, "reply Unknown rpc response code=%u %u", reply_stat, length));
 		break;
 	}
 	return;
 
 trunc:
 	if (!nfserr)
-		fputs(" [|nfs]", stdout);
+		ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
  * Return a pointer to the first file handle in the packet.
  * If the packet was truncated, return 0.
  */
-static const u_int32_t *
-parsereq(register const struct sunrpc_msg *rp, register u_int length)
+static const uint32_t *
+parsereq(netdissect_options *ndo,
+         register const struct sunrpc_msg *rp, register u_int length)
 {
-	register const u_int32_t *dp;
+	register const uint32_t *dp;
 	register u_int len;
 
 	/*
 	 * find the start of the req data (if we captured it)
 	 */
-	dp = (u_int32_t *)&rp->rm_call.cb_cred;
-	TCHECK(dp[1]);
+	dp = (uint32_t *)&rp->rm_call.cb_cred;
+	ND_TCHECK(dp[1]);
 	len = EXTRACT_32BITS(&dp[1]);
 	if (len < length) {
 		dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
-		TCHECK(dp[1]);
+		ND_TCHECK(dp[1]);
 		len = EXTRACT_32BITS(&dp[1]);
 		if (len < length) {
 			dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
-			TCHECK2(dp[0], 0);
+			ND_TCHECK2(dp[0], 0);
 			return (dp);
 		}
 	}
@@ -448,20 +455,21 @@
  * Print out an NFS file handle and return a pointer to following word.
  * If packet was truncated, return 0.
  */
-static const u_int32_t *
-parsefh(register const u_int32_t *dp, int v3)
+static const uint32_t *
+parsefh(netdissect_options *ndo,
+        register const uint32_t *dp, int v3)
 {
 	u_int len;
 
 	if (v3) {
-		TCHECK(dp[0]);
+		ND_TCHECK(dp[0]);
 		len = EXTRACT_32BITS(dp) / 4;
 		dp++;
 	} else
 		len = NFSX_V2FH / 4;
 
-	if (TTEST2(*dp, len * sizeof(*dp))) {
-		nfs_printfh(dp, len);
+	if (ND_TTEST2(*dp, len * sizeof(*dp))) {
+		nfs_printfh(ndo, dp, len);
 		return (dp + len);
 	}
 trunc:
@@ -472,30 +480,31 @@
  * Print out a file name and return pointer to 32-bit word past it.
  * If packet was truncated, return 0.
  */
-static const u_int32_t *
-parsefn(register const u_int32_t *dp)
+static const uint32_t *
+parsefn(netdissect_options *ndo,
+        register const uint32_t *dp)
 {
-	register u_int32_t len;
+	register uint32_t len;
 	register const u_char *cp;
 
 	/* Bail if we don't have the string length */
-	TCHECK(*dp);
+	ND_TCHECK(*dp);
 
 	/* Fetch string length; convert to host order */
 	len = *dp++;
 	NTOHL(len);
 
-	TCHECK2(*dp, ((len + 3) & ~3));
+	ND_TCHECK2(*dp, ((len + 3) & ~3));
 
 	cp = (u_char *)dp;
 	/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
 	dp += ((len + 3) & ~3) / sizeof(*dp);
-	putchar('"');
-	if (fn_printn(cp, len, snapend)) {
-		putchar('"');
+	ND_PRINT((ndo, "\""));
+	if (fn_printn(ndo, cp, len, ndo->ndo_snapend)) {
+		ND_PRINT((ndo, "\""));
 		goto trunc;
 	}
-	putchar('"');
+	ND_PRINT((ndo, "\""));
 
 	return (dp);
 trunc:
@@ -507,63 +516,35 @@
  * Return pointer to 32-bit word past file name.
  * If packet was truncated (or there was some other error), return 0.
  */
-static const u_int32_t *
-parsefhn(register const u_int32_t *dp, int v3)
+static const uint32_t *
+parsefhn(netdissect_options *ndo,
+         register const uint32_t *dp, int v3)
 {
-	dp = parsefh(dp, v3);
+	dp = parsefh(ndo, dp, v3);
 	if (dp == NULL)
 		return (NULL);
-	putchar(' ');
-	return (parsefn(dp));
+	ND_PRINT((ndo, " "));
+	return (parsefn(ndo, dp));
 }
 
 void
-nfsreq_print(register const u_char *bp, u_int length,
-    register const u_char *bp2)
+nfsreq_print_noaddr(netdissect_options *ndo,
+                    register const u_char *bp, u_int length,
+                    register const u_char *bp2)
 {
 	register const struct sunrpc_msg *rp;
-	char srcid[20], dstid[20];	/*fits 32bit*/
-
-	nfserr = 0;		/* assume no error */
-	rp = (const struct sunrpc_msg *)bp;
-
-	TCHECK(rp->rm_xid);
-	if (!nflag) {
-		snprintf(srcid, sizeof(srcid), "%u",
-		    EXTRACT_32BITS(&rp->rm_xid));
-		strlcpy(dstid, "nfs", sizeof(dstid));
-	} else {
-		snprintf(srcid, sizeof(srcid), "%u",
-		    EXTRACT_32BITS(&rp->rm_xid));
-		snprintf(dstid, sizeof(dstid), "%u", NFS_PORT);
-	}
-	print_nfsaddr(bp2, srcid, dstid);
-	(void)printf("%d", length);
-
-	nfsreq_print_noaddr(bp, length, bp2);
-	return;
-
-trunc:
-	if (!nfserr)
-		fputs(" [|nfs]", stdout);
-}
-
-void
-nfsreq_print_noaddr(register const u_char *bp, u_int length,
-    register const u_char *bp2)
-{
-	register const struct sunrpc_msg *rp;
-	register const u_int32_t *dp;
+	register const uint32_t *dp;
 	nfs_type type;
 	int v3;
-	u_int32_t proc;
-	u_int32_t access_flags;
+	uint32_t proc;
+	uint32_t access_flags;
 	struct nfsv3_sattr sa3;
 
+	ND_PRINT((ndo, "%d", length));
 	nfserr = 0;		/* assume no error */
 	rp = (const struct sunrpc_msg *)bp;
 
-	if (!xid_map_enter(rp, bp2))	/* record proc number for later on */
+	if (!xid_map_enter(ndo, rp, bp2))	/* record proc number for later on */
 		goto trunc;
 
 	v3 = (EXTRACT_32BITS(&rp->rm_call.cb_vers) == NFS_VER3);
@@ -572,307 +553,235 @@
 	if (!v3 && proc < NFS_NPROCS)
 		proc =  nfsv3_procid[proc];
 
+	ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc)));
 	switch (proc) {
-	case NFSPROC_NOOP:
-		printf(" nop");
-		return;
-	case NFSPROC_NULL:
-		printf(" null");
-		return;
 
 	case NFSPROC_GETATTR:
-		printf(" getattr");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefh(dp, v3) != NULL)
-			return;
-		break;
-
 	case NFSPROC_SETATTR:
-		printf(" setattr");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefh(dp, v3) != NULL)
+	case NFSPROC_READLINK:
+	case NFSPROC_FSSTAT:
+	case NFSPROC_FSINFO:
+	case NFSPROC_PATHCONF:
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    parsefh(ndo, dp, v3) != NULL)
 			return;
 		break;
 
 	case NFSPROC_LOOKUP:
-		printf(" lookup");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefhn(dp, v3) != NULL)
+	case NFSPROC_CREATE:
+	case NFSPROC_MKDIR:
+	case NFSPROC_REMOVE:
+	case NFSPROC_RMDIR:
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    parsefhn(ndo, dp, v3) != NULL)
 			return;
 		break;
 
 	case NFSPROC_ACCESS:
-		printf(" access");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefh(dp, v3)) != NULL) {
-			TCHECK(dp[0]);
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefh(ndo, dp, v3)) != NULL) {
+			ND_TCHECK(dp[0]);
 			access_flags = EXTRACT_32BITS(&dp[0]);
 			if (access_flags & ~NFSV3ACCESS_FULL) {
 				/* NFSV3ACCESS definitions aren't up to date */
-				printf(" %04x", access_flags);
+				ND_PRINT((ndo, " %04x", access_flags));
 			} else if ((access_flags & NFSV3ACCESS_FULL) == NFSV3ACCESS_FULL) {
-				printf(" NFS_ACCESS_FULL");
+				ND_PRINT((ndo, " NFS_ACCESS_FULL"));
 			} else {
 				char separator = ' ';
 				if (access_flags & NFSV3ACCESS_READ) {
-					printf(" NFS_ACCESS_READ");
+					ND_PRINT((ndo, " NFS_ACCESS_READ"));
 					separator = '|';
 				}
 				if (access_flags & NFSV3ACCESS_LOOKUP) {
-					printf("%cNFS_ACCESS_LOOKUP", separator);
+					ND_PRINT((ndo, "%cNFS_ACCESS_LOOKUP", separator));
 					separator = '|';
 				}
 				if (access_flags & NFSV3ACCESS_MODIFY) {
-					printf("%cNFS_ACCESS_MODIFY", separator);
+					ND_PRINT((ndo, "%cNFS_ACCESS_MODIFY", separator));
 					separator = '|';
 				}
 				if (access_flags & NFSV3ACCESS_EXTEND) {
-					printf("%cNFS_ACCESS_EXTEND", separator);
+					ND_PRINT((ndo, "%cNFS_ACCESS_EXTEND", separator));
 					separator = '|';
 				}
 				if (access_flags & NFSV3ACCESS_DELETE) {
-					printf("%cNFS_ACCESS_DELETE", separator);
+					ND_PRINT((ndo, "%cNFS_ACCESS_DELETE", separator));
 					separator = '|';
 				}
 				if (access_flags & NFSV3ACCESS_EXECUTE)
-					printf("%cNFS_ACCESS_EXECUTE", separator);
+					ND_PRINT((ndo, "%cNFS_ACCESS_EXECUTE", separator));
 			}
 			return;
 		}
 		break;
 
-	case NFSPROC_READLINK:
-		printf(" readlink");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefh(dp, v3) != NULL)
-			return;
-		break;
-
 	case NFSPROC_READ:
-		printf(" read");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefh(dp, v3)) != NULL) {
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefh(ndo, dp, v3)) != NULL) {
 			if (v3) {
-				TCHECK(dp[2]);
-				printf(" %u bytes @ %" PRIu64,
+				ND_TCHECK(dp[2]);
+				ND_PRINT((ndo, " %u bytes @ %" PRIu64,
 				       EXTRACT_32BITS(&dp[2]),
-				       EXTRACT_64BITS(&dp[0]));
+				       EXTRACT_64BITS(&dp[0])));
 			} else {
-				TCHECK(dp[1]);
-				printf(" %u bytes @ %u",
+				ND_TCHECK(dp[1]);
+				ND_PRINT((ndo, " %u bytes @ %u",
 				    EXTRACT_32BITS(&dp[1]),
-				    EXTRACT_32BITS(&dp[0]));
+				    EXTRACT_32BITS(&dp[0])));
 			}
 			return;
 		}
 		break;
 
 	case NFSPROC_WRITE:
-		printf(" write");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefh(dp, v3)) != NULL) {
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefh(ndo, dp, v3)) != NULL) {
 			if (v3) {
-				TCHECK(dp[2]);
-				printf(" %u (%u) bytes @ %" PRIu64,
+				ND_TCHECK(dp[2]);
+				ND_PRINT((ndo, " %u (%u) bytes @ %" PRIu64,
 						EXTRACT_32BITS(&dp[4]),
 						EXTRACT_32BITS(&dp[2]),
-						EXTRACT_64BITS(&dp[0]));
-				if (vflag) {
+						EXTRACT_64BITS(&dp[0])));
+				if (ndo->ndo_vflag) {
 					dp += 3;
-					TCHECK(dp[0]);
-					printf(" <%s>",
+					ND_TCHECK(dp[0]);
+					ND_PRINT((ndo, " <%s>",
 						tok2str(nfsv3_writemodes,
-							NULL, EXTRACT_32BITS(dp)));
+							NULL, EXTRACT_32BITS(dp))));
 				}
 			} else {
-				TCHECK(dp[3]);
-				printf(" %u (%u) bytes @ %u (%u)",
+				ND_TCHECK(dp[3]);
+				ND_PRINT((ndo, " %u (%u) bytes @ %u (%u)",
 						EXTRACT_32BITS(&dp[3]),
 						EXTRACT_32BITS(&dp[2]),
 						EXTRACT_32BITS(&dp[1]),
-						EXTRACT_32BITS(&dp[0]));
+						EXTRACT_32BITS(&dp[0])));
 			}
 			return;
 		}
 		break;
 
-	case NFSPROC_CREATE:
-		printf(" create");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefhn(dp, v3) != NULL)
-			return;
-		break;
-
-	case NFSPROC_MKDIR:
-		printf(" mkdir");
-		if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
-			return;
-		break;
-
 	case NFSPROC_SYMLINK:
-		printf(" symlink");
-		if ((dp = parsereq(rp, length)) != 0 &&
-		    (dp = parsefhn(dp, v3)) != 0) {
-			fputs(" ->", stdout);
-			if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0)
+		if ((dp = parsereq(ndo, rp, length)) != 0 &&
+		    (dp = parsefhn(ndo, dp, v3)) != 0) {
+			ND_PRINT((ndo, " ->"));
+			if (v3 && (dp = parse_sattr3(ndo, dp, &sa3)) == 0)
 				break;
-			if (parsefn(dp) == 0)
+			if (parsefn(ndo, dp) == 0)
 				break;
-			if (v3 && vflag)
-				print_sattr3(&sa3, vflag);
+			if (v3 && ndo->ndo_vflag)
+				print_sattr3(ndo, &sa3, ndo->ndo_vflag);
 			return;
 		}
 		break;
 
 	case NFSPROC_MKNOD:
-		printf(" mknod");
-		if ((dp = parsereq(rp, length)) != 0 &&
-		    (dp = parsefhn(dp, v3)) != 0) {
-			TCHECK(*dp);
+		if ((dp = parsereq(ndo, rp, length)) != 0 &&
+		    (dp = parsefhn(ndo, dp, v3)) != 0) {
+			ND_TCHECK(*dp);
 			type = (nfs_type)EXTRACT_32BITS(dp);
 			dp++;
-			if ((dp = parse_sattr3(dp, &sa3)) == 0)
+			if ((dp = parse_sattr3(ndo, dp, &sa3)) == 0)
 				break;
-			printf(" %s", tok2str(type2str, "unk-ft %d", type));
-			if (vflag && (type == NFCHR || type == NFBLK)) {
-				TCHECK(dp[1]);
-				printf(" %u/%u",
+			ND_PRINT((ndo, " %s", tok2str(type2str, "unk-ft %d", type)));
+			if (ndo->ndo_vflag && (type == NFCHR || type == NFBLK)) {
+				ND_TCHECK(dp[1]);
+				ND_PRINT((ndo, " %u/%u",
 				       EXTRACT_32BITS(&dp[0]),
-				       EXTRACT_32BITS(&dp[1]));
+				       EXTRACT_32BITS(&dp[1])));
 				dp += 2;
 			}
-			if (vflag)
-				print_sattr3(&sa3, vflag);
+			if (ndo->ndo_vflag)
+				print_sattr3(ndo, &sa3, ndo->ndo_vflag);
 			return;
 		}
 		break;
 
-	case NFSPROC_REMOVE:
-		printf(" remove");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefhn(dp, v3) != NULL)
-			return;
-		break;
-
-	case NFSPROC_RMDIR:
-		printf(" rmdir");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefhn(dp, v3) != NULL)
-			return;
-		break;
-
 	case NFSPROC_RENAME:
-		printf(" rename");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefhn(dp, v3)) != NULL) {
-			fputs(" ->", stdout);
-			if (parsefhn(dp, v3) != NULL)
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefhn(ndo, dp, v3)) != NULL) {
+			ND_PRINT((ndo, " ->"));
+			if (parsefhn(ndo, dp, v3) != NULL)
 				return;
 		}
 		break;
 
 	case NFSPROC_LINK:
-		printf(" link");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefh(dp, v3)) != NULL) {
-			fputs(" ->", stdout);
-			if (parsefhn(dp, v3) != NULL)
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefh(ndo, dp, v3)) != NULL) {
+			ND_PRINT((ndo, " ->"));
+			if (parsefhn(ndo, dp, v3) != NULL)
 				return;
 		}
 		break;
 
 	case NFSPROC_READDIR:
-		printf(" readdir");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefh(dp, v3)) != NULL) {
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefh(ndo, dp, v3)) != NULL) {
 			if (v3) {
-				TCHECK(dp[4]);
+				ND_TCHECK(dp[4]);
 				/*
 				 * We shouldn't really try to interpret the
 				 * offset cookie here.
 				 */
-				printf(" %u bytes @ %" PRId64,
+				ND_PRINT((ndo, " %u bytes @ %" PRId64,
 				    EXTRACT_32BITS(&dp[4]),
-				    EXTRACT_64BITS(&dp[0]));
-				if (vflag)
-					printf(" verf %08x%08x", dp[2],
-					       dp[3]);
+				    EXTRACT_64BITS(&dp[0])));
+				if (ndo->ndo_vflag)
+					ND_PRINT((ndo, " verf %08x%08x", dp[2], dp[3]));
 			} else {
-				TCHECK(dp[1]);
+				ND_TCHECK(dp[1]);
 				/*
 				 * Print the offset as signed, since -1 is
 				 * common, but offsets > 2^31 aren't.
 				 */
-				printf(" %u bytes @ %d",
+				ND_PRINT((ndo, " %u bytes @ %d",
 				    EXTRACT_32BITS(&dp[1]),
-				    EXTRACT_32BITS(&dp[0]));
+				    EXTRACT_32BITS(&dp[0])));
 			}
 			return;
 		}
 		break;
 
 	case NFSPROC_READDIRPLUS:
-		printf(" readdirplus");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefh(dp, v3)) != NULL) {
-			TCHECK(dp[4]);
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefh(ndo, dp, v3)) != NULL) {
+			ND_TCHECK(dp[4]);
 			/*
 			 * We don't try to interpret the offset
 			 * cookie here.
 			 */
-			printf(" %u bytes @ %" PRId64,
+			ND_PRINT((ndo, " %u bytes @ %" PRId64,
 				EXTRACT_32BITS(&dp[4]),
-				EXTRACT_64BITS(&dp[0]));
-			if (vflag) {
-				TCHECK(dp[5]);
-				printf(" max %u verf %08x%08x",
-				       EXTRACT_32BITS(&dp[5]), dp[2], dp[3]);
+				EXTRACT_64BITS(&dp[0])));
+			if (ndo->ndo_vflag) {
+				ND_TCHECK(dp[5]);
+				ND_PRINT((ndo, " max %u verf %08x%08x",
+				       EXTRACT_32BITS(&dp[5]), dp[2], dp[3]));
 			}
 			return;
 		}
 		break;
 
-	case NFSPROC_FSSTAT:
-		printf(" fsstat");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefh(dp, v3) != NULL)
-			return;
-		break;
-
-	case NFSPROC_FSINFO:
-		printf(" fsinfo");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefh(dp, v3) != NULL)
-			return;
-		break;
-
-	case NFSPROC_PATHCONF:
-		printf(" pathconf");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    parsefh(dp, v3) != NULL)
-			return;
-		break;
-
 	case NFSPROC_COMMIT:
-		printf(" commit");
-		if ((dp = parsereq(rp, length)) != NULL &&
-		    (dp = parsefh(dp, v3)) != NULL) {
-			TCHECK(dp[2]);
-			printf(" %u bytes @ %" PRIu64,
+		if ((dp = parsereq(ndo, rp, length)) != NULL &&
+		    (dp = parsefh(ndo, dp, v3)) != NULL) {
+			ND_TCHECK(dp[2]);
+			ND_PRINT((ndo, " %u bytes @ %" PRIu64,
 				EXTRACT_32BITS(&dp[2]),
-				EXTRACT_64BITS(&dp[0]));
+				EXTRACT_64BITS(&dp[0])));
 			return;
 		}
 		break;
 
 	default:
-		printf(" proc-%u", EXTRACT_32BITS(&rp->rm_call.cb_proc));
 		return;
 	}
 
 trunc:
 	if (!nfserr)
-		fputs(" [|nfs]", stdout);
+		ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
@@ -885,23 +794,24 @@
  * additional hacking on the parser code.
  */
 static void
-nfs_printfh(register const u_int32_t *dp, const u_int len)
+nfs_printfh(netdissect_options *ndo,
+            register const uint32_t *dp, const u_int len)
 {
 	my_fsid fsid;
-	u_int32_t ino;
+	uint32_t ino;
 	const char *sfsname = NULL;
 	char *spacep;
 
-	if (uflag) {
+	if (ndo->ndo_uflag) {
 		u_int i;
 		char const *sep = "";
 
-		printf(" fh[");
+		ND_PRINT((ndo, " fh["));
 		for (i=0; i<len; i++) {
-			(void)printf("%s%x", sep, dp[i]);
+			ND_PRINT((ndo, "%s%x", sep, dp[i]));
 			sep = ":";
 		}
-		printf("]");
+		ND_PRINT((ndo, "]"));
 		return;
 	}
 
@@ -919,17 +829,17 @@
 		if (spacep)
 			*spacep = '\0';
 
-		(void)printf(" fh %s/", temp);
+		ND_PRINT((ndo, " fh %s/", temp));
 	} else {
-		(void)printf(" fh %d,%d/",
-			     fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor);
+		ND_PRINT((ndo, " fh %d,%d/",
+			     fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor));
 	}
 
 	if(fsid.Fsid_dev.Minor == 257)
 		/* Print the undecoded handle */
-		(void)printf("%s", fsid.Opaque_Handle);
+		ND_PRINT((ndo, "%s", fsid.Opaque_Handle));
 	else
-		(void)printf("%ld", (long) ino);
+		ND_PRINT((ndo, "%ld", (long) ino));
 }
 
 /*
@@ -939,7 +849,7 @@
  */
 
 struct xid_map_entry {
-	u_int32_t	xid;		/* transaction ID (net order) */
+	uint32_t	xid;		/* transaction ID (net order) */
 	int ipver;			/* IP version (4 or 6) */
 #ifdef INET6
 	struct in6_addr	client;		/* client IP address (net order) */
@@ -948,8 +858,8 @@
 	struct in_addr	client;		/* client IP address (net order) */
 	struct in_addr	server;		/* server IP address (net order) */
 #endif
-	u_int32_t	proc;		/* call proc number (host order) */
-	u_int32_t	vers;		/* program version (host order) */
+	uint32_t	proc;		/* call proc number (host order) */
+	uint32_t	vers;		/* program version (host order) */
 };
 
 /*
@@ -966,7 +876,8 @@
 int	xid_map_hint = 0;
 
 static int
-xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
+xid_map_enter(netdissect_options *ndo,
+              const struct sunrpc_msg *rp, const u_char *bp)
 {
 	struct ip *ip = NULL;
 #ifdef INET6
@@ -974,7 +885,7 @@
 #endif
 	struct xid_map_entry *xmep;
 
-	if (!TTEST(rp->rm_call.cb_vers))
+	if (!ND_TTEST(rp->rm_call.cb_vers))
 		return (0);
 	switch (IP_V((struct ip *)bp)) {
 	case 4:
@@ -994,7 +905,7 @@
 	if (++xid_map_next >= XIDMAPSIZE)
 		xid_map_next = 0;
 
-	xmep->xid = rp->rm_xid;
+	UNALIGNED_MEMCPY(&xmep->xid, &rp->rm_xid, sizeof(xmep->xid));
 	if (ip) {
 		xmep->ipver = 4;
 		UNALIGNED_MEMCPY(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
@@ -1017,12 +928,12 @@
  * version in vers return, or returns -1 on failure
  */
 static int
-xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
-	     u_int32_t *vers)
+xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
+	     uint32_t *vers)
 {
 	int i;
 	struct xid_map_entry *xmep;
-	u_int32_t xid = rp->rm_xid;
+	uint32_t xid = rp->rm_xid;
 	struct ip *ip = (struct ip *)bp;
 #ifdef INET6
 	struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
@@ -1083,10 +994,11 @@
  * Return a pointer to the beginning of the actual results.
  * If the packet was truncated, return 0.
  */
-static const u_int32_t *
-parserep(register const struct sunrpc_msg *rp, register u_int length)
+static const uint32_t *
+parserep(netdissect_options *ndo,
+         register const struct sunrpc_msg *rp, register u_int length)
 {
-	register const u_int32_t *dp;
+	register const uint32_t *dp;
 	u_int len;
 	enum sunrpc_accept_stat astat;
 
@@ -1094,7 +1006,7 @@
 	 * Portability note:
 	 * Here we find the address of the ar_verf credentials.
 	 * Originally, this calculation was
-	 *	dp = (u_int32_t *)&rp->rm_reply.rp_acpt.ar_verf
+	 *	dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
 	 * On the wire, the rp_acpt field starts immediately after
 	 * the (32 bit) rp_stat field.  However, rp_acpt (which is a
 	 * "struct accepted_reply") contains a "struct opaque_auth",
@@ -1105,77 +1017,48 @@
 	 * representation.  Instead, we skip past the rp_stat field,
 	 * which is an "enum" and so occupies one 32-bit word.
 	 */
-	dp = ((const u_int32_t *)&rp->rm_reply) + 1;
-	TCHECK(dp[1]);
+	dp = ((const uint32_t *)&rp->rm_reply) + 1;
+	ND_TCHECK(dp[1]);
 	len = EXTRACT_32BITS(&dp[1]);
 	if (len >= length)
 		return (NULL);
 	/*
 	 * skip past the ar_verf credentials.
 	 */
-	dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t);
-	TCHECK2(dp[0], 0);
+	dp += (len + (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
+	ND_TCHECK2(dp[0], 0);
 
 	/*
 	 * now we can check the ar_stat field
 	 */
 	astat = (enum sunrpc_accept_stat) EXTRACT_32BITS(dp);
-	switch (astat) {
-
-	case SUNRPC_SUCCESS:
-		break;
-
-	case SUNRPC_PROG_UNAVAIL:
-		printf(" PROG_UNAVAIL");
-		nfserr = 1;		/* suppress trunc string */
-		return (NULL);
-
-	case SUNRPC_PROG_MISMATCH:
-		printf(" PROG_MISMATCH");
-		nfserr = 1;		/* suppress trunc string */
-		return (NULL);
-
-	case SUNRPC_PROC_UNAVAIL:
-		printf(" PROC_UNAVAIL");
-		nfserr = 1;		/* suppress trunc string */
-		return (NULL);
-
-	case SUNRPC_GARBAGE_ARGS:
-		printf(" GARBAGE_ARGS");
-		nfserr = 1;		/* suppress trunc string */
-		return (NULL);
-
-	case SUNRPC_SYSTEM_ERR:
-		printf(" SYSTEM_ERR");
-		nfserr = 1;		/* suppress trunc string */
-		return (NULL);
-
-	default:
-		printf(" ar_stat %d", astat);
+	if (astat != SUNRPC_SUCCESS) {
+		ND_PRINT((ndo, " %s", tok2str(sunrpc_str, "ar_stat %d", astat)));
 		nfserr = 1;		/* suppress trunc string */
 		return (NULL);
 	}
 	/* successful return */
-	TCHECK2(*dp, sizeof(astat));
-	return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
+	ND_TCHECK2(*dp, sizeof(astat));
+	return ((uint32_t *) (sizeof(astat) + ((char *)dp)));
 trunc:
 	return (0);
 }
 
-static const u_int32_t *
-parsestatus(const u_int32_t *dp, int *er)
+static const uint32_t *
+parsestatus(netdissect_options *ndo,
+            const uint32_t *dp, int *er)
 {
 	int errnum;
 
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 
 	errnum = EXTRACT_32BITS(&dp[0]);
 	if (er)
 		*er = errnum;
 	if (errnum != 0) {
-		if (!qflag)
-			printf(" ERROR: %s",
-			    tok2str(status2str, "unk %d", errnum));
+		if (!ndo->ndo_qflag)
+			ND_PRINT((ndo, " ERROR: %s",
+			    tok2str(status2str, "unk %d", errnum)));
 		nfserr = 1;
 	}
 	return (dp + 1);
@@ -1183,166 +1066,171 @@
 	return NULL;
 }
 
-static const u_int32_t *
-parsefattr(const u_int32_t *dp, int verbose, int v3)
+static const uint32_t *
+parsefattr(netdissect_options *ndo,
+           const uint32_t *dp, int verbose, int v3)
 {
 	const struct nfs_fattr *fap;
 
 	fap = (const struct nfs_fattr *)dp;
-	TCHECK(fap->fa_gid);
+	ND_TCHECK(fap->fa_gid);
 	if (verbose) {
-		printf(" %s %o ids %d/%d",
+		ND_PRINT((ndo, " %s %o ids %d/%d",
 		    tok2str(type2str, "unk-ft %d ",
 		    EXTRACT_32BITS(&fap->fa_type)),
 		    EXTRACT_32BITS(&fap->fa_mode),
 		    EXTRACT_32BITS(&fap->fa_uid),
-		    EXTRACT_32BITS(&fap->fa_gid));
+		    EXTRACT_32BITS(&fap->fa_gid)));
 		if (v3) {
-			TCHECK(fap->fa3_size);
-			printf(" sz %" PRIu64,
-				EXTRACT_64BITS((u_int32_t *)&fap->fa3_size));
+			ND_TCHECK(fap->fa3_size);
+			ND_PRINT((ndo, " sz %" PRIu64,
+				EXTRACT_64BITS((uint32_t *)&fap->fa3_size)));
 		} else {
-			TCHECK(fap->fa2_size);
-			printf(" sz %d", EXTRACT_32BITS(&fap->fa2_size));
+			ND_TCHECK(fap->fa2_size);
+			ND_PRINT((ndo, " sz %d", EXTRACT_32BITS(&fap->fa2_size)));
 		}
 	}
 	/* print lots more stuff */
 	if (verbose > 1) {
 		if (v3) {
-			TCHECK(fap->fa3_ctime);
-			printf(" nlink %d rdev %d/%d",
+			ND_TCHECK(fap->fa3_ctime);
+			ND_PRINT((ndo, " nlink %d rdev %d/%d",
 			       EXTRACT_32BITS(&fap->fa_nlink),
 			       EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
-			       EXTRACT_32BITS(&fap->fa3_rdev.specdata2));
-			printf(" fsid %" PRIx64,
-				EXTRACT_64BITS((u_int32_t *)&fap->fa3_fsid));
-			printf(" fileid %" PRIx64,
-				EXTRACT_64BITS((u_int32_t *)&fap->fa3_fileid));
-			printf(" a/m/ctime %u.%06u",
+			       EXTRACT_32BITS(&fap->fa3_rdev.specdata2)));
+			ND_PRINT((ndo, " fsid %" PRIx64,
+				EXTRACT_64BITS((uint32_t *)&fap->fa3_fsid)));
+			ND_PRINT((ndo, " fileid %" PRIx64,
+				EXTRACT_64BITS((uint32_t *)&fap->fa3_fileid)));
+			ND_PRINT((ndo, " a/m/ctime %u.%06u",
 			       EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec),
-			       EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec));
-			printf(" %u.%06u",
+			       EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec)));
+			ND_PRINT((ndo, " %u.%06u",
 			       EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_sec),
-			       EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec));
-			printf(" %u.%06u",
+			       EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec)));
+			ND_PRINT((ndo, " %u.%06u",
 			       EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_sec),
-			       EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec));
+			       EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec)));
 		} else {
-			TCHECK(fap->fa2_ctime);
-			printf(" nlink %d rdev %x fsid %x nodeid %x a/m/ctime",
+			ND_TCHECK(fap->fa2_ctime);
+			ND_PRINT((ndo, " nlink %d rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
 			       EXTRACT_32BITS(&fap->fa_nlink),
 			       EXTRACT_32BITS(&fap->fa2_rdev),
 			       EXTRACT_32BITS(&fap->fa2_fsid),
-			       EXTRACT_32BITS(&fap->fa2_fileid));
-			printf(" %u.%06u",
+			       EXTRACT_32BITS(&fap->fa2_fileid)));
+			ND_PRINT((ndo, " %u.%06u",
 			       EXTRACT_32BITS(&fap->fa2_atime.nfsv2_sec),
-			       EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec));
-			printf(" %u.%06u",
+			       EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec)));
+			ND_PRINT((ndo, " %u.%06u",
 			       EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_sec),
-			       EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec));
-			printf(" %u.%06u",
+			       EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec)));
+			ND_PRINT((ndo, " %u.%06u",
 			       EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_sec),
-			       EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec));
+			       EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec)));
 		}
 	}
-	return ((const u_int32_t *)((unsigned char *)dp +
+	return ((const uint32_t *)((unsigned char *)dp +
 		(v3 ? NFSX_V3FATTR : NFSX_V2FATTR)));
 trunc:
 	return (NULL);
 }
 
 static int
-parseattrstat(const u_int32_t *dp, int verbose, int v3)
+parseattrstat(netdissect_options *ndo,
+              const uint32_t *dp, int verbose, int v3)
 {
 	int er;
 
-	dp = parsestatus(dp, &er);
+	dp = parsestatus(ndo, dp, &er);
 	if (dp == NULL)
 		return (0);
 	if (er)
 		return (1);
 
-	return (parsefattr(dp, verbose, v3) != NULL);
+	return (parsefattr(ndo, dp, verbose, v3) != NULL);
 }
 
 static int
-parsediropres(const u_int32_t *dp)
+parsediropres(netdissect_options *ndo,
+              const uint32_t *dp)
 {
 	int er;
 
-	if (!(dp = parsestatus(dp, &er)))
+	if (!(dp = parsestatus(ndo, dp, &er)))
 		return (0);
 	if (er)
 		return (1);
 
-	dp = parsefh(dp, 0);
+	dp = parsefh(ndo, dp, 0);
 	if (dp == NULL)
 		return (0);
 
-	return (parsefattr(dp, vflag, 0) != NULL);
+	return (parsefattr(ndo, dp, ndo->ndo_vflag, 0) != NULL);
 }
 
 static int
-parselinkres(const u_int32_t *dp, int v3)
+parselinkres(netdissect_options *ndo,
+             const uint32_t *dp, int v3)
 {
 	int er;
 
-	dp = parsestatus(dp, &er);
+	dp = parsestatus(ndo, dp, &er);
 	if (dp == NULL)
 		return(0);
 	if (er)
 		return(1);
-	if (v3 && !(dp = parse_post_op_attr(dp, vflag)))
+	if (v3 && !(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
 		return (0);
-	putchar(' ');
-	return (parsefn(dp) != NULL);
+	ND_PRINT((ndo, " "));
+	return (parsefn(ndo, dp) != NULL);
 }
 
 static int
-parsestatfs(const u_int32_t *dp, int v3)
+parsestatfs(netdissect_options *ndo,
+            const uint32_t *dp, int v3)
 {
 	const struct nfs_statfs *sfsp;
 	int er;
 
-	dp = parsestatus(dp, &er);
+	dp = parsestatus(ndo, dp, &er);
 	if (dp == NULL)
 		return (0);
 	if (!v3 && er)
 		return (1);
 
-	if (qflag)
+	if (ndo->ndo_qflag)
 		return(1);
 
 	if (v3) {
-		if (vflag)
-			printf(" POST:");
-		if (!(dp = parse_post_op_attr(dp, vflag)))
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, " POST:"));
+		if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
 			return (0);
 	}
 
-	TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
+	ND_TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
 
 	sfsp = (const struct nfs_statfs *)dp;
 
 	if (v3) {
-		printf(" tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
-			EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tbytes),
-			EXTRACT_64BITS((u_int32_t *)&sfsp->sf_fbytes),
-			EXTRACT_64BITS((u_int32_t *)&sfsp->sf_abytes));
-		if (vflag) {
-			printf(" tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
-			       EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tfiles),
-			       EXTRACT_64BITS((u_int32_t *)&sfsp->sf_ffiles),
-			       EXTRACT_64BITS((u_int32_t *)&sfsp->sf_afiles),
-			       EXTRACT_32BITS(&sfsp->sf_invarsec));
+		ND_PRINT((ndo, " tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
+			EXTRACT_64BITS((uint32_t *)&sfsp->sf_tbytes),
+			EXTRACT_64BITS((uint32_t *)&sfsp->sf_fbytes),
+			EXTRACT_64BITS((uint32_t *)&sfsp->sf_abytes)));
+		if (ndo->ndo_vflag) {
+			ND_PRINT((ndo, " tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
+			       EXTRACT_64BITS((uint32_t *)&sfsp->sf_tfiles),
+			       EXTRACT_64BITS((uint32_t *)&sfsp->sf_ffiles),
+			       EXTRACT_64BITS((uint32_t *)&sfsp->sf_afiles),
+			       EXTRACT_32BITS(&sfsp->sf_invarsec)));
 		}
 	} else {
-		printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
+		ND_PRINT((ndo, " tsize %d bsize %d blocks %d bfree %d bavail %d",
 			EXTRACT_32BITS(&sfsp->sf_tsize),
 			EXTRACT_32BITS(&sfsp->sf_bsize),
 			EXTRACT_32BITS(&sfsp->sf_blocks),
 			EXTRACT_32BITS(&sfsp->sf_bfree),
-			EXTRACT_32BITS(&sfsp->sf_bavail));
+			EXTRACT_32BITS(&sfsp->sf_bavail)));
 	}
 
 	return (1);
@@ -1351,52 +1239,55 @@
 }
 
 static int
-parserddires(const u_int32_t *dp)
+parserddires(netdissect_options *ndo,
+             const uint32_t *dp)
 {
 	int er;
 
-	dp = parsestatus(dp, &er);
+	dp = parsestatus(ndo, dp, &er);
 	if (dp == NULL)
 		return (0);
 	if (er)
 		return (1);
-	if (qflag)
+	if (ndo->ndo_qflag)
 		return (1);
 
-	TCHECK(dp[2]);
-	printf(" offset %x size %d ",
-	       EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1]));
+	ND_TCHECK(dp[2]);
+	ND_PRINT((ndo, " offset 0x%x size %d ",
+	       EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1])));
 	if (dp[2] != 0)
-		printf(" eof");
+		ND_PRINT((ndo, " eof"));
 
 	return (1);
 trunc:
 	return (0);
 }
 
-static const u_int32_t *
-parse_wcc_attr(const u_int32_t *dp)
+static const uint32_t *
+parse_wcc_attr(netdissect_options *ndo,
+               const uint32_t *dp)
 {
-	printf(" sz %" PRIu64, EXTRACT_64BITS(&dp[0]));
-	printf(" mtime %u.%06u ctime %u.%06u",
+	ND_PRINT((ndo, " sz %" PRIu64, EXTRACT_64BITS(&dp[0])));
+	ND_PRINT((ndo, " mtime %u.%06u ctime %u.%06u",
 	       EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]),
-	       EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5]));
+	       EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5])));
 	return (dp + 6);
 }
 
 /*
  * Pre operation attributes. Print only if vflag > 1.
  */
-static const u_int32_t *
-parse_pre_op_attr(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_pre_op_attr(netdissect_options *ndo,
+                  const uint32_t *dp, int verbose)
 {
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	if (!EXTRACT_32BITS(&dp[0]))
 		return (dp + 1);
 	dp++;
-	TCHECK2(*dp, 24);
+	ND_TCHECK2(*dp, 24);
 	if (verbose > 1) {
-		return parse_wcc_attr(dp);
+		return parse_wcc_attr(ndo, dp);
 	} else {
 		/* If not verbose enough, just skip over wcc_attr */
 		return (dp + 6);
@@ -1408,56 +1299,59 @@
 /*
  * Post operation attributes are printed if vflag >= 1
  */
-static const u_int32_t *
-parse_post_op_attr(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_post_op_attr(netdissect_options *ndo,
+                   const uint32_t *dp, int verbose)
 {
-	TCHECK(dp[0]);
+	ND_TCHECK(dp[0]);
 	if (!EXTRACT_32BITS(&dp[0]))
 		return (dp + 1);
 	dp++;
 	if (verbose) {
-		return parsefattr(dp, verbose, 1);
+		return parsefattr(ndo, dp, verbose, 1);
 	} else
-		return (dp + (NFSX_V3FATTR / sizeof (u_int32_t)));
+		return (dp + (NFSX_V3FATTR / sizeof (uint32_t)));
 trunc:
 	return (NULL);
 }
 
-static const u_int32_t *
-parse_wcc_data(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_wcc_data(netdissect_options *ndo,
+               const uint32_t *dp, int verbose)
 {
 	if (verbose > 1)
-		printf(" PRE:");
-	if (!(dp = parse_pre_op_attr(dp, verbose)))
+		ND_PRINT((ndo, " PRE:"));
+	if (!(dp = parse_pre_op_attr(ndo, dp, verbose)))
 		return (0);
 
 	if (verbose)
-		printf(" POST:");
-	return parse_post_op_attr(dp, verbose);
+		ND_PRINT((ndo, " POST:"));
+	return parse_post_op_attr(ndo, dp, verbose);
 }
 
-static const u_int32_t *
-parsecreateopres(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parsecreateopres(netdissect_options *ndo,
+                 const uint32_t *dp, int verbose)
 {
 	int er;
 
-	if (!(dp = parsestatus(dp, &er)))
+	if (!(dp = parsestatus(ndo, dp, &er)))
 		return (0);
 	if (er)
-		dp = parse_wcc_data(dp, verbose);
+		dp = parse_wcc_data(ndo, dp, verbose);
 	else {
-		TCHECK(dp[0]);
+		ND_TCHECK(dp[0]);
 		if (!EXTRACT_32BITS(&dp[0]))
 			return (dp + 1);
 		dp++;
-		if (!(dp = parsefh(dp, 1)))
+		if (!(dp = parsefh(ndo, dp, 1)))
 			return (0);
 		if (verbose) {
-			if (!(dp = parse_post_op_attr(dp, verbose)))
+			if (!(dp = parse_post_op_attr(ndo, dp, verbose)))
 				return (0);
-			if (vflag > 1) {
-				printf(" dir attr:");
-				dp = parse_wcc_data(dp, verbose);
+			if (ndo->ndo_vflag > 1) {
+				ND_PRINT((ndo, " dir attr:"));
+				dp = parse_wcc_data(ndo, dp, verbose);
 			}
 		}
 	}
@@ -1467,31 +1361,33 @@
 }
 
 static int
-parsewccres(const u_int32_t *dp, int verbose)
+parsewccres(netdissect_options *ndo,
+            const uint32_t *dp, int verbose)
 {
 	int er;
 
-	if (!(dp = parsestatus(dp, &er)))
+	if (!(dp = parsestatus(ndo, dp, &er)))
 		return (0);
-	return parse_wcc_data(dp, verbose) != 0;
+	return parse_wcc_data(ndo, dp, verbose) != 0;
 }
 
-static const u_int32_t *
-parsev3rddirres(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parsev3rddirres(netdissect_options *ndo,
+                const uint32_t *dp, int verbose)
 {
 	int er;
 
-	if (!(dp = parsestatus(dp, &er)))
+	if (!(dp = parsestatus(ndo, dp, &er)))
 		return (0);
-	if (vflag)
-		printf(" POST:");
-	if (!(dp = parse_post_op_attr(dp, verbose)))
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, " POST:"));
+	if (!(dp = parse_post_op_attr(ndo, dp, verbose)))
 		return (0);
 	if (er)
 		return dp;
-	if (vflag) {
-		TCHECK(dp[1]);
-		printf(" verf %08x%08x", dp[0], dp[1]);
+	if (ndo->ndo_vflag) {
+		ND_TCHECK(dp[1]);
+		ND_PRINT((ndo, " verf %08x%08x", dp[0], dp[1]));
 		dp += 2;
 	}
 	return dp;
@@ -1500,36 +1396,37 @@
 }
 
 static int
-parsefsinfo(const u_int32_t *dp)
+parsefsinfo(netdissect_options *ndo,
+            const uint32_t *dp)
 {
 	struct nfsv3_fsinfo *sfp;
 	int er;
 
-	if (!(dp = parsestatus(dp, &er)))
+	if (!(dp = parsestatus(ndo, dp, &er)))
 		return (0);
-	if (vflag)
-		printf(" POST:");
-	if (!(dp = parse_post_op_attr(dp, vflag)))
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, " POST:"));
+	if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
 		return (0);
 	if (er)
 		return (1);
 
 	sfp = (struct nfsv3_fsinfo *)dp;
-	TCHECK(*sfp);
-	printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
+	ND_TCHECK(*sfp);
+	ND_PRINT((ndo, " rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
 	       EXTRACT_32BITS(&sfp->fs_rtmax),
 	       EXTRACT_32BITS(&sfp->fs_rtpref),
 	       EXTRACT_32BITS(&sfp->fs_wtmax),
 	       EXTRACT_32BITS(&sfp->fs_wtpref),
-	       EXTRACT_32BITS(&sfp->fs_dtpref));
-	if (vflag) {
-		printf(" rtmult %u wtmult %u maxfsz %" PRIu64,
+	       EXTRACT_32BITS(&sfp->fs_dtpref)));
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, " rtmult %u wtmult %u maxfsz %" PRIu64,
 		       EXTRACT_32BITS(&sfp->fs_rtmult),
 		       EXTRACT_32BITS(&sfp->fs_wtmult),
-		       EXTRACT_64BITS((u_int32_t *)&sfp->fs_maxfilesize));
-		printf(" delta %u.%06u ",
+		       EXTRACT_64BITS((uint32_t *)&sfp->fs_maxfilesize)));
+		ND_PRINT((ndo, " delta %u.%06u ",
 		       EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec),
-		       EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec));
+		       EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec)));
 	}
 	return (1);
 trunc:
@@ -1537,39 +1434,41 @@
 }
 
 static int
-parsepathconf(const u_int32_t *dp)
+parsepathconf(netdissect_options *ndo,
+              const uint32_t *dp)
 {
 	int er;
 	struct nfsv3_pathconf *spp;
 
-	if (!(dp = parsestatus(dp, &er)))
+	if (!(dp = parsestatus(ndo, dp, &er)))
 		return (0);
-	if (vflag)
-		printf(" POST:");
-	if (!(dp = parse_post_op_attr(dp, vflag)))
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, " POST:"));
+	if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
 		return (0);
 	if (er)
 		return (1);
 
 	spp = (struct nfsv3_pathconf *)dp;
-	TCHECK(*spp);
+	ND_TCHECK(*spp);
 
-	printf(" linkmax %u namemax %u %s %s %s %s",
+	ND_PRINT((ndo, " linkmax %u namemax %u %s %s %s %s",
 	       EXTRACT_32BITS(&spp->pc_linkmax),
 	       EXTRACT_32BITS(&spp->pc_namemax),
 	       EXTRACT_32BITS(&spp->pc_notrunc) ? "notrunc" : "",
 	       EXTRACT_32BITS(&spp->pc_chownrestricted) ? "chownres" : "",
 	       EXTRACT_32BITS(&spp->pc_caseinsensitive) ? "igncase" : "",
-	       EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : "");
+	       EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : ""));
 	return (1);
 trunc:
 	return (0);
 }
 
 static void
-interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
+interp_reply(netdissect_options *ndo,
+             const struct sunrpc_msg *rp, uint32_t proc, uint32_t vers, int length)
 {
-	register const u_int32_t *dp;
+	register const uint32_t *dp;
 	register int v3;
 	int er;
 
@@ -1578,309 +1477,258 @@
 	if (!v3 && proc < NFS_NPROCS)
 		proc = nfsv3_procid[proc];
 
+	ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc)));
 	switch (proc) {
 
-	case NFSPROC_NOOP:
-		printf(" nop");
-		return;
-
-	case NFSPROC_NULL:
-		printf(" null");
-		return;
-
 	case NFSPROC_GETATTR:
-		printf(" getattr");
-		dp = parserep(rp, length);
-		if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0)
+		dp = parserep(ndo, rp, length);
+		if (dp != NULL && parseattrstat(ndo, dp, !ndo->ndo_qflag, v3) != 0)
 			return;
 		break;
 
 	case NFSPROC_SETATTR:
-		printf(" setattr");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			return;
 		if (v3) {
-			if (parsewccres(dp, vflag))
+			if (parsewccres(ndo, dp, ndo->ndo_vflag))
 				return;
 		} else {
-			if (parseattrstat(dp, !qflag, 0) != 0)
+			if (parseattrstat(ndo, dp, !ndo->ndo_qflag, 0) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_LOOKUP:
-		printf(" lookup");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (!(dp = parsestatus(dp, &er)))
+			if (!(dp = parsestatus(ndo, dp, &er)))
 				break;
 			if (er) {
-				if (vflag > 1) {
-					printf(" post dattr:");
-					dp = parse_post_op_attr(dp, vflag);
+				if (ndo->ndo_vflag > 1) {
+					ND_PRINT((ndo, " post dattr:"));
+					dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag);
 				}
 			} else {
-				if (!(dp = parsefh(dp, v3)))
+				if (!(dp = parsefh(ndo, dp, v3)))
 					break;
-				if ((dp = parse_post_op_attr(dp, vflag)) &&
-				    vflag > 1) {
-					printf(" post dattr:");
-					dp = parse_post_op_attr(dp, vflag);
+				if ((dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)) &&
+				    ndo->ndo_vflag > 1) {
+					ND_PRINT((ndo, " post dattr:"));
+					dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag);
 				}
 			}
 			if (dp)
 				return;
 		} else {
-			if (parsediropres(dp) != 0)
+			if (parsediropres(ndo, dp) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_ACCESS:
-		printf(" access");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
-		if (!(dp = parsestatus(dp, &er)))
+		if (!(dp = parsestatus(ndo, dp, &er)))
 			break;
-		if (vflag)
-			printf(" attr:");
-		if (!(dp = parse_post_op_attr(dp, vflag)))
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, " attr:"));
+		if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
 			break;
 		if (!er)
-			printf(" c %04x", EXTRACT_32BITS(&dp[0]));
+			ND_PRINT((ndo, " c %04x", EXTRACT_32BITS(&dp[0])));
 		return;
 
 	case NFSPROC_READLINK:
-		printf(" readlink");
-		dp = parserep(rp, length);
-		if (dp != NULL && parselinkres(dp, v3) != 0)
+		dp = parserep(ndo, rp, length);
+		if (dp != NULL && parselinkres(ndo, dp, v3) != 0)
 			return;
 		break;
 
 	case NFSPROC_READ:
-		printf(" read");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (!(dp = parsestatus(dp, &er)))
+			if (!(dp = parsestatus(ndo, dp, &er)))
 				break;
-			if (!(dp = parse_post_op_attr(dp, vflag)))
+			if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
 				break;
 			if (er)
 				return;
-			if (vflag) {
-				TCHECK(dp[1]);
-				printf(" %u bytes", EXTRACT_32BITS(&dp[0]));
+			if (ndo->ndo_vflag) {
+				ND_TCHECK(dp[1]);
+				ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0])));
 				if (EXTRACT_32BITS(&dp[1]))
-					printf(" EOF");
+					ND_PRINT((ndo, " EOF"));
 			}
 			return;
 		} else {
-			if (parseattrstat(dp, vflag, 0) != 0)
+			if (parseattrstat(ndo, dp, ndo->ndo_vflag, 0) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_WRITE:
-		printf(" write");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (!(dp = parsestatus(dp, &er)))
+			if (!(dp = parsestatus(ndo, dp, &er)))
 				break;
-			if (!(dp = parse_wcc_data(dp, vflag)))
+			if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
 				break;
 			if (er)
 				return;
-			if (vflag) {
-				TCHECK(dp[0]);
-				printf(" %u bytes", EXTRACT_32BITS(&dp[0]));
-				if (vflag > 1) {
-					TCHECK(dp[1]);
-					printf(" <%s>",
+			if (ndo->ndo_vflag) {
+				ND_TCHECK(dp[0]);
+				ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0])));
+				if (ndo->ndo_vflag > 1) {
+					ND_TCHECK(dp[1]);
+					ND_PRINT((ndo, " <%s>",
 						tok2str(nfsv3_writemodes,
-							NULL, EXTRACT_32BITS(&dp[1])));
+							NULL, EXTRACT_32BITS(&dp[1]))));
 				}
 				return;
 			}
 		} else {
-			if (parseattrstat(dp, vflag, v3) != 0)
+			if (parseattrstat(ndo, dp, ndo->ndo_vflag, v3) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_CREATE:
-		printf(" create");
-		if (!(dp = parserep(rp, length)))
-			break;
-		if (v3) {
-			if (parsecreateopres(dp, vflag) != 0)
-				return;
-		} else {
-			if (parsediropres(dp) != 0)
-				return;
-		}
-		break;
-
 	case NFSPROC_MKDIR:
-		printf(" mkdir");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (parsecreateopres(dp, vflag) != 0)
+			if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
 				return;
 		} else {
-			if (parsediropres(dp) != 0)
+			if (parsediropres(ndo, dp) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_SYMLINK:
-		printf(" symlink");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (parsecreateopres(dp, vflag) != 0)
+			if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
 				return;
 		} else {
-			if (parsestatus(dp, &er) != 0)
+			if (parsestatus(ndo, dp, &er) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_MKNOD:
-		printf(" mknod");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
-		if (parsecreateopres(dp, vflag) != 0)
+		if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
 			return;
 		break;
 
 	case NFSPROC_REMOVE:
-		printf(" remove");
-		if (!(dp = parserep(rp, length)))
-			break;
-		if (v3) {
-			if (parsewccres(dp, vflag))
-				return;
-		} else {
-			if (parsestatus(dp, &er) != 0)
-				return;
-		}
-		break;
-
 	case NFSPROC_RMDIR:
-		printf(" rmdir");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (parsewccres(dp, vflag))
+			if (parsewccres(ndo, dp, ndo->ndo_vflag))
 				return;
 		} else {
-			if (parsestatus(dp, &er) != 0)
+			if (parsestatus(ndo, dp, &er) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_RENAME:
-		printf(" rename");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (!(dp = parsestatus(dp, &er)))
+			if (!(dp = parsestatus(ndo, dp, &er)))
 				break;
-			if (vflag) {
-				printf(" from:");
-				if (!(dp = parse_wcc_data(dp, vflag)))
+			if (ndo->ndo_vflag) {
+				ND_PRINT((ndo, " from:"));
+				if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
 					break;
-				printf(" to:");
-				if (!(dp = parse_wcc_data(dp, vflag)))
+				ND_PRINT((ndo, " to:"));
+				if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
 					break;
 			}
 			return;
 		} else {
-			if (parsestatus(dp, &er) != 0)
+			if (parsestatus(ndo, dp, &er) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_LINK:
-		printf(" link");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (!(dp = parsestatus(dp, &er)))
+			if (!(dp = parsestatus(ndo, dp, &er)))
 				break;
-			if (vflag) {
-				printf(" file POST:");
-				if (!(dp = parse_post_op_attr(dp, vflag)))
+			if (ndo->ndo_vflag) {
+				ND_PRINT((ndo, " file POST:"));
+				if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
 					break;
-				printf(" dir:");
-				if (!(dp = parse_wcc_data(dp, vflag)))
+				ND_PRINT((ndo, " dir:"));
+				if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
 					break;
 				return;
 			}
 		} else {
-			if (parsestatus(dp, &er) != 0)
+			if (parsestatus(ndo, dp, &er) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_READDIR:
-		printf(" readdir");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
 		if (v3) {
-			if (parsev3rddirres(dp, vflag))
+			if (parsev3rddirres(ndo, dp, ndo->ndo_vflag))
 				return;
 		} else {
-			if (parserddires(dp) != 0)
+			if (parserddires(ndo, dp) != 0)
 				return;
 		}
 		break;
 
 	case NFSPROC_READDIRPLUS:
-		printf(" readdirplus");
-		if (!(dp = parserep(rp, length)))
+		if (!(dp = parserep(ndo, rp, length)))
 			break;
-		if (parsev3rddirres(dp, vflag))
+		if (parsev3rddirres(ndo, dp, ndo->ndo_vflag))
 			return;
 		break;
 
 	case NFSPROC_FSSTAT:
-		printf(" fsstat");
-		dp = parserep(rp, length);
-		if (dp != NULL && parsestatfs(dp, v3) != 0)
+		dp = parserep(ndo, rp, length);
+		if (dp != NULL && parsestatfs(ndo, dp, v3) != 0)
 			return;
 		break;
 
 	case NFSPROC_FSINFO:
-		printf(" fsinfo");
-		dp = parserep(rp, length);
-		if (dp != NULL && parsefsinfo(dp) != 0)
+		dp = parserep(ndo, rp, length);
+		if (dp != NULL && parsefsinfo(ndo, dp) != 0)
 			return;
 		break;
 
 	case NFSPROC_PATHCONF:
-		printf(" pathconf");
-		dp = parserep(rp, length);
-		if (dp != NULL && parsepathconf(dp) != 0)
+		dp = parserep(ndo, rp, length);
+		if (dp != NULL && parsepathconf(ndo, dp) != 0)
 			return;
 		break;
 
 	case NFSPROC_COMMIT:
-		printf(" commit");
-		dp = parserep(rp, length);
-		if (dp != NULL && parsewccres(dp, vflag) != 0)
+		dp = parserep(ndo, rp, length);
+		if (dp != NULL && parsewccres(ndo, dp, ndo->ndo_vflag) != 0)
 			return;
 		break;
 
 	default:
-		printf(" proc-%u", proc);
 		return;
 	}
 trunc:
 	if (!nfserr)
-		fputs(" [|nfs]", stdout);
+		ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-ntp.c b/print-ntp.c
index 28c8619..e83d47a 100644
--- a/print-ntp.c
+++ b/print-ntp.c
@@ -23,19 +23,13 @@
  *	loosely based on print-bootp.c
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
 #ifdef HAVE_STRFTIME
 #include <time.h>
 #endif
@@ -43,14 +37,139 @@
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
+
+/*
+ * Based on ntp.h from the U of MD implementation
+ *	This file is based on Version 2 of the NTP spec (RFC1119).
+ */
+
+/*
+ *  Definitions for the masses
+ */
+#define	JAN_1970	2208988800U	/* 1970 - 1900 in seconds */
+
+/*
+ * Structure definitions for NTP fixed point values
+ *
+ *    0			  1		      2			  3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |			       Integer Part			     |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |			       Fraction Part			     |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *    0			  1		      2			  3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |		  Integer Part	     |	   Fraction Part	     |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct l_fixedpt {
+	uint32_t int_part;
+	uint32_t fraction;
+};
+
+struct s_fixedpt {
+	uint16_t int_part;
+	uint16_t fraction;
+};
+
+/* rfc2030
+ *                      1                   2                   3
+ *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |LI | VN  |Mode |    Stratum    |     Poll      |   Precision   |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                          Root Delay                           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                       Root Dispersion                         |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                     Reference Identifier                      |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                                                               |
+ * |                   Reference Timestamp (64)                    |
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                                                               |
+ * |                   Originate Timestamp (64)                    |
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                                                               |
+ * |                    Receive Timestamp (64)                     |
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                                                               |
+ * |                    Transmit Timestamp (64)                    |
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                 Key Identifier (optional) (32)                |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                                                               |
+ * |                                                               |
+ * |                 Message Digest (optional) (128)               |
+ * |                                                               |
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+struct ntpdata {
+	u_char status;		/* status of local clock and leap info */
+	u_char stratum;		/* Stratum level */
+	u_char ppoll;		/* poll value */
+	int precision:8;
+	struct s_fixedpt root_delay;
+	struct s_fixedpt root_dispersion;
+	uint32_t refid;
+	struct l_fixedpt ref_timestamp;
+	struct l_fixedpt org_timestamp;
+	struct l_fixedpt rec_timestamp;
+	struct l_fixedpt xmt_timestamp;
+        uint32_t key_id;
+        uint8_t  message_digest[16];
+};
+/*
+ *	Leap Second Codes (high order two bits)
+ */
+#define	NO_WARNING	0x00	/* no warning */
+#define	PLUS_SEC	0x40	/* add a second (61 seconds) */
+#define	MINUS_SEC	0x80	/* minus a second (59 seconds) */
+#define	ALARM		0xc0	/* alarm condition (clock unsynchronized) */
+
+/*
+ *	Clock Status Bits that Encode Version
+ */
+#define	NTPVERSION_1	0x08
+#define	VERSIONMASK	0x38
+#define LEAPMASK	0xc0
 #ifdef MODEMASK
 #undef MODEMASK					/* Solaris sucks */
 #endif
-#include "ntp.h"
+#define	MODEMASK	0x07
 
-static void p_sfix(const struct s_fixedpt *);
-static void p_ntp_time(const struct l_fixedpt *);
-static void p_ntp_delta(const struct l_fixedpt *, const struct l_fixedpt *);
+/*
+ *	Code values
+ */
+#define	MODE_UNSPEC	0	/* unspecified */
+#define	MODE_SYM_ACT	1	/* symmetric active */
+#define	MODE_SYM_PAS	2	/* symmetric passive */
+#define	MODE_CLIENT	3	/* client */
+#define	MODE_SERVER	4	/* server */
+#define	MODE_BROADCAST	5	/* broadcast */
+#define	MODE_RES1	6	/* reserved */
+#define	MODE_RES2	7	/* reserved */
+
+/*
+ *	Stratum Definitions
+ */
+#define	UNSPECIFIED	0
+#define	PRIM_REF	1	/* radio clock */
+#define	INFO_QUERY	62	/* **** THIS implementation dependent **** */
+#define	INFO_REPLY	63	/* **** THIS implementation dependent **** */
+
+static void p_sfix(netdissect_options *ndo, const struct s_fixedpt *);
+static void p_ntp_time(netdissect_options *, const struct l_fixedpt *);
+static void p_ntp_delta(netdissect_options *, const struct l_fixedpt *, const struct l_fixedpt *);
 
 static const struct tok ntp_mode_values[] = {
     { MODE_UNSPEC,    "unspecified" },
@@ -82,127 +201,129 @@
  * Print ntp requests
  */
 void
-ntp_print(register const u_char *cp, u_int length)
+ntp_print(netdissect_options *ndo,
+          register const u_char *cp, u_int length)
 {
 	register const struct ntpdata *bp;
 	int mode, version, leapind;
 
 	bp = (struct ntpdata *)cp;
 
-	TCHECK(bp->status);
+	ND_TCHECK(bp->status);
 
 	version = (int)(bp->status & VERSIONMASK) >> 3;
-	printf("NTPv%d", version);
+	ND_PRINT((ndo, "NTPv%d", version));
 
 	mode = bp->status & MODEMASK;
-        if (!vflag) {
-            printf (", %s, length %u",
-                    tok2str(ntp_mode_values, "Unknown mode", mode),
-                    length);
-            return;
-        }
-        
-        printf (", length %u\n\t%s",
-                length,
-                tok2str(ntp_mode_values, "Unknown mode", mode));        
+	if (!ndo->ndo_vflag) {
+		ND_PRINT((ndo, ", %s, length %u",
+		          tok2str(ntp_mode_values, "Unknown mode", mode),
+		          length));
+		return;
+	}
+
+	ND_PRINT((ndo, ", length %u\n\t%s",
+	          length,
+	          tok2str(ntp_mode_values, "Unknown mode", mode)));
 
 	leapind = bp->status & LEAPMASK;
-        printf (", Leap indicator: %s (%u)",
-                tok2str(ntp_leapind_values, "Unknown", leapind),
-                leapind);
+	ND_PRINT((ndo, ", Leap indicator: %s (%u)",
+	          tok2str(ntp_leapind_values, "Unknown", leapind),
+	          leapind));
 
-	TCHECK(bp->stratum);
-	printf(", Stratum %u (%s)", 	
+	ND_TCHECK(bp->stratum);
+	ND_PRINT((ndo, ", Stratum %u (%s)",
 		bp->stratum,
-		tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum));
+		tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum)));
 
-	TCHECK(bp->ppoll);
-	printf(", poll %u (%us)", bp->ppoll, 1 << bp->ppoll);
+	ND_TCHECK(bp->ppoll);
+	ND_PRINT((ndo, ", poll %u (%us)", bp->ppoll, 1 << bp->ppoll));
 
-	/* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */
-	TCHECK2(bp->root_delay, 0);
-	printf(", precision %d", bp->precision);
+	/* Can't ND_TCHECK bp->precision bitfield so bp->distance + 0 instead */
+	ND_TCHECK2(bp->root_delay, 0);
+	ND_PRINT((ndo, ", precision %d", bp->precision));
 
-	TCHECK(bp->root_delay);
-	fputs("\n\tRoot Delay: ", stdout);
-	p_sfix(&bp->root_delay);
+	ND_TCHECK(bp->root_delay);
+	ND_PRINT((ndo, "\n\tRoot Delay: "));
+	p_sfix(ndo, &bp->root_delay);
 
-	TCHECK(bp->root_dispersion);
-	fputs(", Root dispersion: ", stdout);
-	p_sfix(&bp->root_dispersion);
+	ND_TCHECK(bp->root_dispersion);
+	ND_PRINT((ndo, ", Root dispersion: "));
+	p_sfix(ndo, &bp->root_dispersion);
 
-	TCHECK(bp->refid);
-	fputs(", Reference-ID: ", stdout);
+	ND_TCHECK(bp->refid);
+	ND_PRINT((ndo, ", Reference-ID: "));
 	/* Interpretation depends on stratum */
 	switch (bp->stratum) {
 
 	case UNSPECIFIED:
-		printf("(unspec)");
+		ND_PRINT((ndo, "(unspec)"));
 		break;
 
 	case PRIM_REF:
-		if (fn_printn((u_char *)&(bp->refid), 4, snapend))
+		if (fn_printn(ndo, (u_char *)&(bp->refid), 4, ndo->ndo_snapend))
 			goto trunc;
 		break;
 
 	case INFO_QUERY:
-		printf("%s INFO_QUERY", ipaddr_string(&(bp->refid)));
+		ND_PRINT((ndo, "%s INFO_QUERY", ipaddr_string(ndo, &(bp->refid))));
 		/* this doesn't have more content */
 		return;
 
 	case INFO_REPLY:
-		printf("%s INFO_REPLY", ipaddr_string(&(bp->refid)));
+		ND_PRINT((ndo, "%s INFO_REPLY", ipaddr_string(ndo, &(bp->refid))));
 		/* this is too complex to be worth printing */
 		return;
 
 	default:
-		printf("%s", ipaddr_string(&(bp->refid)));
+		ND_PRINT((ndo, "%s", ipaddr_string(ndo, &(bp->refid))));
 		break;
 	}
 
-	TCHECK(bp->ref_timestamp);
-	fputs("\n\t  Reference Timestamp:  ", stdout);
-	p_ntp_time(&(bp->ref_timestamp));
+	ND_TCHECK(bp->ref_timestamp);
+	ND_PRINT((ndo, "\n\t  Reference Timestamp:  "));
+	p_ntp_time(ndo, &(bp->ref_timestamp));
 
-	TCHECK(bp->org_timestamp);
-	fputs("\n\t  Originator Timestamp: ", stdout);
-	p_ntp_time(&(bp->org_timestamp));
+	ND_TCHECK(bp->org_timestamp);
+	ND_PRINT((ndo, "\n\t  Originator Timestamp: "));
+	p_ntp_time(ndo, &(bp->org_timestamp));
 
-	TCHECK(bp->rec_timestamp);
-	fputs("\n\t  Receive Timestamp:    ", stdout);
-	p_ntp_time(&(bp->rec_timestamp));
+	ND_TCHECK(bp->rec_timestamp);
+	ND_PRINT((ndo, "\n\t  Receive Timestamp:    "));
+	p_ntp_time(ndo, &(bp->rec_timestamp));
 
-	TCHECK(bp->xmt_timestamp);
-	fputs("\n\t  Transmit Timestamp:   ", stdout);
-	p_ntp_time(&(bp->xmt_timestamp));
+	ND_TCHECK(bp->xmt_timestamp);
+	ND_PRINT((ndo, "\n\t  Transmit Timestamp:   "));
+	p_ntp_time(ndo, &(bp->xmt_timestamp));
 
-	fputs("\n\t    Originator - Receive Timestamp:  ", stdout);
-	p_ntp_delta(&(bp->org_timestamp), &(bp->rec_timestamp));
+	ND_PRINT((ndo, "\n\t    Originator - Receive Timestamp:  "));
+	p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->rec_timestamp));
 
-	fputs("\n\t    Originator - Transmit Timestamp: ", stdout);
-	p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp));
+	ND_PRINT((ndo, "\n\t    Originator - Transmit Timestamp: "));
+	p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->xmt_timestamp));
 
 	if ( (sizeof(struct ntpdata) - length) == 16) { 	/* Optional: key-id */
-		TCHECK(bp->key_id);
-		printf("\n\tKey id: %u", bp->key_id);
+		ND_TCHECK(bp->key_id);
+		ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
 	} else if ( (sizeof(struct ntpdata) - length) == 0) { 	/* Optional: key-id + authentication */
-		TCHECK(bp->key_id);
-		printf("\n\tKey id: %u", bp->key_id);
-		TCHECK2(bp->message_digest, sizeof (bp->message_digest));
-                printf("\n\tAuthentication: %08x%08x%08x%08x",
+		ND_TCHECK(bp->key_id);
+		ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
+		ND_TCHECK2(bp->message_digest, sizeof (bp->message_digest));
+                ND_PRINT((ndo, "\n\tAuthentication: %08x%08x%08x%08x",
         		       EXTRACT_32BITS(bp->message_digest),
 		               EXTRACT_32BITS(bp->message_digest + 4),
 		               EXTRACT_32BITS(bp->message_digest + 8),
-		               EXTRACT_32BITS(bp->message_digest + 12));
+		               EXTRACT_32BITS(bp->message_digest + 12)));
         }
 	return;
 
 trunc:
-	fputs(" [|ntp]", stdout);
+	ND_PRINT((ndo, " [|ntp]"));
 }
 
 static void
-p_sfix(register const struct s_fixedpt *sfp)
+p_sfix(netdissect_options *ndo,
+       register const struct s_fixedpt *sfp)
 {
 	register int i;
 	register int f;
@@ -212,17 +333,18 @@
 	f = EXTRACT_16BITS(&sfp->fraction);
 	ff = f / 65536.0;	/* shift radix point by 16 bits */
 	f = ff * 1000000.0;	/* Treat fraction as parts per million */
-	printf("%d.%06d", i, f);
+	ND_PRINT((ndo, "%d.%06d", i, f));
 }
 
 #define	FMAXINT	(4294967296.0)	/* floating point rep. of MAXINT */
 
 static void
-p_ntp_time(register const struct l_fixedpt *lfp)
+p_ntp_time(netdissect_options *ndo,
+           register const struct l_fixedpt *lfp)
 {
 	register int32_t i;
-	register u_int32_t uf;
-	register u_int32_t f;
+	register uint32_t uf;
+	register uint32_t f;
 	register float ff;
 
 	i = EXTRACT_32BITS(&lfp->int_part);
@@ -232,7 +354,7 @@
 		ff += FMAXINT;
 	ff = ff / FMAXINT;	/* shift radix point by 32 bits */
 	f = ff * 1000000000.0;	/* treat fraction as parts per billion */
-	printf("%u.%09d", i, f);
+	ND_PRINT((ndo, "%u.%09d", i, f));
 
 #ifdef HAVE_STRFTIME
 	/*
@@ -245,20 +367,21 @@
 
 	    tm = localtime(&seconds);
 	    strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm);
-	    printf (" (%s)", time_buf);
+	    ND_PRINT((ndo, " (%s)", time_buf));
 	}
 #endif
 }
 
 /* Prints time difference between *lfp and *olfp */
 static void
-p_ntp_delta(register const struct l_fixedpt *olfp,
-	    register const struct l_fixedpt *lfp)
+p_ntp_delta(netdissect_options *ndo,
+            register const struct l_fixedpt *olfp,
+            register const struct l_fixedpt *lfp)
 {
 	register int32_t i;
-	register u_int32_t u, uf;
-	register u_int32_t ou, ouf;
-	register u_int32_t f;
+	register uint32_t u, uf;
+	register uint32_t ou, ouf;
+	register uint32_t f;
 	register float ff;
 	int signbit;
 
@@ -267,7 +390,7 @@
 	uf = EXTRACT_32BITS(&lfp->fraction);
 	ouf = EXTRACT_32BITS(&olfp->fraction);
 	if (ou == 0 && ouf == 0) {
-		p_ntp_time(lfp);
+		p_ntp_time(ndo, lfp);
 		return;
 	}
 
@@ -299,10 +422,6 @@
 		ff += FMAXINT;
 	ff = ff / FMAXINT;	/* shift radix point by 32 bits */
 	f = ff * 1000000000.0;	/* treat fraction as parts per billion */
-	if (signbit)
-		putchar('-');
-	else
-		putchar('+');
-	printf("%d.%09d", i, f);
+	ND_PRINT((ndo, "%s%d.%09d", signbit ? "-" : "+", i, f));
 }
 
diff --git a/print-null.c b/print-null.c
index 8eabe5d..166f777 100644
--- a/print-null.c
+++ b/print-null.c
@@ -19,28 +19,16 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
-#include "addrtoname.h"
-
-#include "ip.h"
-#ifdef INET6
-#include "ip6.h"
-#endif
 #include "af.h"
 
 /*
@@ -64,17 +52,17 @@
 ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
 
 static inline void
-null_hdr_print(u_int family, u_int length)
+null_hdr_print(netdissect_options *ndo, u_int family, u_int length)
 {
-	if (!qflag) {
-		(void)printf("AF %s (%u)",
-			tok2str(bsd_af_values,"Unknown",family),family);
+	if (!ndo->ndo_qflag) {
+		ND_PRINT((ndo, "AF %s (%u)",
+			tok2str(bsd_af_values,"Unknown",family),family));
 	} else {
-		(void)printf("%s",
-			tok2str(bsd_af_values,"Unknown AF %u",family));
+		ND_PRINT((ndo, "%s",
+			tok2str(bsd_af_values,"Unknown AF %u",family)));
 	}
 
-	(void)printf(", length %u: ", length);
+	ND_PRINT((ndo, ", length %u: ", length));
 }
 
 /*
@@ -84,14 +72,14 @@
  * is the number of bytes actually captured.
  */
 u_int
-null_if_print(const struct pcap_pkthdr *h, const u_char *p)
+null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int length = h->len;
 	u_int caplen = h->caplen;
 	u_int family;
 
 	if (caplen < NULL_HDRLEN) {
-		printf("[|null]");
+		ND_PRINT((ndo, "[|null]"));
 		return (NULL_HDRLEN);
 	}
 
@@ -108,8 +96,8 @@
 	if ((family & 0xFFFF0000) != 0)
 		family = SWAPLONG(family);
 
-	if (eflag)
-		null_hdr_print(family, length);
+	if (ndo->ndo_eflag)
+		null_hdr_print(ndo, family, length);
 
 	length -= NULL_HDRLEN;
 	caplen -= NULL_HDRLEN;
@@ -118,35 +106,33 @@
 	switch (family) {
 
 	case BSD_AFNUM_INET:
-		ip_print(gndo, p, length);
+		ip_print(ndo, p, length);
 		break;
 
-#ifdef INET6
 	case BSD_AFNUM_INET6_BSD:
 	case BSD_AFNUM_INET6_FREEBSD:
 	case BSD_AFNUM_INET6_DARWIN:
-		ip6_print(gndo, p, length);
+		ip6_print(ndo, p, length);
 		break;
-#endif
 
 	case BSD_AFNUM_ISO:
-		isoclns_print(p, length, caplen);
+		isoclns_print(ndo, p, length, caplen);
 		break;
 
 	case BSD_AFNUM_APPLETALK:
-		atalk_print(p, length);
+		atalk_print(ndo, p, length);
 		break;
 
 	case BSD_AFNUM_IPX:
-		ipx_print(p, length);
+		ipx_print(ndo, p, length);
 		break;
 
 	default:
 		/* unknown AF_ value */
-		if (!eflag)
-			null_hdr_print(family, length + NULL_HDRLEN);
-		if (!suppress_default_print)
-			default_print(p, caplen);
+		if (!ndo->ndo_eflag)
+			null_hdr_print(ndo, family, length + NULL_HDRLEN);
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
 	}
 
 	return (NULL_HDRLEN);
diff --git a/print-olsr.c b/print-olsr.c
index 2713c09..b90eea1 100644
--- a/print-olsr.c
+++ b/print-olsr.c
@@ -19,19 +19,16 @@
  * IPv6 additions by Florian Forster <octo at verplant.org>
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
-#include "ip.h"
 
 /*
  * RFC 3626 common header
@@ -65,8 +62,8 @@
  */
 
 struct olsr_common {
-    u_int8_t packet_len[2];
-    u_int8_t packet_seq[2];
+    uint8_t packet_len[2];
+    uint8_t packet_seq[2];
 };
 
 #define OLSR_HELLO_MSG         1 /* rfc3626 */
@@ -91,50 +88,50 @@
 };
 
 struct olsr_msg4 {
-    u_int8_t msg_type;
-    u_int8_t vtime;
-    u_int8_t msg_len[2];
-    u_int8_t originator[4];
-    u_int8_t ttl;
-    u_int8_t hopcount;
-    u_int8_t msg_seq[2];
+    uint8_t msg_type;
+    uint8_t vtime;
+    uint8_t msg_len[2];
+    uint8_t originator[4];
+    uint8_t ttl;
+    uint8_t hopcount;
+    uint8_t msg_seq[2];
 };
 
 struct olsr_msg6 {
-    u_int8_t msg_type;
-    u_int8_t vtime;
-    u_int8_t msg_len[2];
-    u_int8_t originator[16];
-    u_int8_t ttl;
-    u_int8_t hopcount;
-    u_int8_t msg_seq[2];
+    uint8_t msg_type;
+    uint8_t vtime;
+    uint8_t msg_len[2];
+    uint8_t originator[16];
+    uint8_t ttl;
+    uint8_t hopcount;
+    uint8_t msg_seq[2];
 };
 
 struct olsr_hello {
-    u_int8_t res[2];
-    u_int8_t htime;
-    u_int8_t will;
+    uint8_t res[2];
+    uint8_t htime;
+    uint8_t will;
 };
 
 struct olsr_hello_link {
-    u_int8_t link_code;
-    u_int8_t res;
-    u_int8_t len[2];
+    uint8_t link_code;
+    uint8_t res;
+    uint8_t len[2];
 };
 
 struct olsr_tc {
-    u_int8_t ans_seq[2];
-    u_int8_t res[2];
+    uint8_t ans_seq[2];
+    uint8_t res[2];
 };
 
 struct olsr_hna4 {
-    u_int8_t network[4];
-    u_int8_t mask[4];
+    uint8_t network[4];
+    uint8_t mask[4];
 };
 
 struct olsr_hna6 {
-    u_int8_t network[16];
-    u_int8_t mask[16];
+    uint8_t network[16];
+    uint8_t mask[16];
 };
 
 
@@ -157,17 +154,17 @@
 };
 
 struct olsr_lq_neighbor4 {
-    u_int8_t neighbor[4];
-    u_int8_t link_quality;
-    u_int8_t neighbor_link_quality;
-    u_int8_t res[2];
+    uint8_t neighbor[4];
+    uint8_t link_quality;
+    uint8_t neighbor_link_quality;
+    uint8_t res[2];
 };
 
 struct olsr_lq_neighbor6 {
-    u_int8_t neighbor[16];
-    u_int8_t link_quality;
-    u_int8_t neighbor_link_quality;
-    u_int8_t res[2];
+    uint8_t neighbor[16];
+    uint8_t link_quality;
+    uint8_t neighbor_link_quality;
+    uint8_t res[2];
 };
 
 /*
@@ -181,74 +178,87 @@
 /*
  * print a neighbor list with LQ extensions.
  */
-static void
-olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len)
+static int
+olsr_print_lq_neighbor4(netdissect_options *ndo,
+                        const u_char *msg_data, u_int hello_len)
 {
     struct olsr_lq_neighbor4 *lq_neighbor;
 
     while (hello_len >= sizeof(struct olsr_lq_neighbor4)) {
 
         lq_neighbor = (struct olsr_lq_neighbor4 *)msg_data;
+        if (!ND_TTEST(*lq_neighbor))
+            return (-1);
 
-        printf("\n\t      neighbor %s, link-quality %.2lf%%"
+        ND_PRINT((ndo, "\n\t      neighbor %s, link-quality %.2lf%%"
                ", neighbor-link-quality %.2lf%%",
-               ipaddr_string(lq_neighbor->neighbor),
+               ipaddr_string(ndo, lq_neighbor->neighbor),
                ((double)lq_neighbor->link_quality/2.55),
-               ((double)lq_neighbor->neighbor_link_quality/2.55));
+               ((double)lq_neighbor->neighbor_link_quality/2.55)));
 
         msg_data += sizeof(struct olsr_lq_neighbor4);
         hello_len -= sizeof(struct olsr_lq_neighbor4);
     }
+    return (0);
 }
 
 #if INET6
-static void
-olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len)
+static int
+olsr_print_lq_neighbor6(netdissect_options *ndo,
+                        const u_char *msg_data, u_int hello_len)
 {
     struct olsr_lq_neighbor6 *lq_neighbor;
 
     while (hello_len >= sizeof(struct olsr_lq_neighbor6)) {
 
         lq_neighbor = (struct olsr_lq_neighbor6 *)msg_data;
+        if (!ND_TTEST(*lq_neighbor))
+            return (-1);
 
-        printf("\n\t      neighbor %s, link-quality %.2lf%%"
+        ND_PRINT((ndo, "\n\t      neighbor %s, link-quality %.2lf%%"
                ", neighbor-link-quality %.2lf%%",
-               ip6addr_string(lq_neighbor->neighbor),
+               ip6addr_string(ndo, lq_neighbor->neighbor),
                ((double)lq_neighbor->link_quality/2.55),
-               ((double)lq_neighbor->neighbor_link_quality/2.55));
+               ((double)lq_neighbor->neighbor_link_quality/2.55)));
 
         msg_data += sizeof(struct olsr_lq_neighbor6);
         hello_len -= sizeof(struct olsr_lq_neighbor6);
     }
+    return (0);
 }
 #endif /* INET6 */
 
 /*
  * print a neighbor list.
  */
-static void
-olsr_print_neighbor (const u_char *msg_data, u_int hello_len)
+static int
+olsr_print_neighbor(netdissect_options *ndo,
+                    const u_char *msg_data, u_int hello_len)
 {
     int neighbor;
 
-    printf("\n\t      neighbor\n\t\t");
+    ND_PRINT((ndo, "\n\t      neighbor\n\t\t"));
     neighbor = 1;
 
     while (hello_len >= sizeof(struct in_addr)) {
 
+        if (!ND_TTEST2(*msg_data, sizeof(struct in_addr)))
+            return (-1);
         /* print 4 neighbors per line */
 
-        printf("%s%s", ipaddr_string(msg_data),
-               neighbor % 4 == 0 ? "\n\t\t" : " ");
+        ND_PRINT((ndo, "%s%s", ipaddr_string(ndo, msg_data),
+               neighbor % 4 == 0 ? "\n\t\t" : " "));
 
         msg_data += sizeof(struct in_addr);
         hello_len -= sizeof(struct in_addr);
     }
+    return (0);
 }
 
 
 void
-olsr_print (const u_char *pptr, u_int length, int is_ipv6)
+olsr_print(netdissect_options *ndo,
+           const u_char *pptr, u_int length, int is_ipv6)
 {
     union {
         const struct olsr_common *common;
@@ -261,9 +271,9 @@
     } ptr;
 
     u_int msg_type, msg_len, msg_tlen, hello_len;
-    u_int16_t name_entry_type, name_entry_len;
+    uint16_t name_entry_type, name_entry_len;
     u_int name_entry_padding;
-    u_int8_t link_type, neighbor_type;
+    uint8_t link_type, neighbor_type;
     const u_char *tptr, *msg_data;
 
     tptr = pptr;
@@ -272,24 +282,22 @@
         goto trunc;
     }
 
-    if (!TTEST2(*tptr, sizeof(struct olsr_common))) {
-        goto trunc;
-    }
+    ND_TCHECK2(*tptr, sizeof(struct olsr_common));
 
     ptr.common = (struct olsr_common *)tptr;
-    length = MIN(length, EXTRACT_16BITS(ptr.common->packet_len));
+    length = min(length, EXTRACT_16BITS(ptr.common->packet_len));
 
-    printf("OLSRv%i, seq 0x%04x, length %u",
+    ND_PRINT((ndo, "OLSRv%i, seq 0x%04x, length %u",
             (is_ipv6 == 0) ? 4 : 6,
             EXTRACT_16BITS(ptr.common->packet_seq),
-            length);
+            length));
 
     tptr += sizeof(struct olsr_common);
 
     /*
      * In non-verbose mode, just print version.
      */
-    if (vflag < 1) {
+    if (ndo->ndo_vflag < 1) {
         return;
     }
 
@@ -301,8 +309,7 @@
         } msgptr;
         int msg_len_valid = 0;
 
-        if (!TTEST2(*tptr, sizeof(struct olsr_msg4)))
-            goto trunc;
+        ND_TCHECK2(*tptr, sizeof(struct olsr_msg4));
 
 #if INET6
         if (is_ipv6)
@@ -319,15 +326,18 @@
                 return;
             }
 
-            printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+            ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
                     "\n\t  vtime %.3lfs, msg-seq 0x%04x, length %u%s",
                     tok2str(olsr_msg_values, "Unknown", msg_type),
-                    msg_type, ip6addr_string(msgptr.v6->originator),
+                    msg_type, ip6addr_string(ndo, msgptr.v6->originator),
                     msgptr.v6->ttl,
                     msgptr.v6->hopcount,
                     ME_TO_DOUBLE(msgptr.v6->vtime),
                     EXTRACT_16BITS(msgptr.v6->msg_seq),
-                    msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+                    msg_len, (msg_len_valid == 0) ? " (invalid)" : ""));
+            if (!msg_len_valid) {
+                return;
+            }
 
             msg_tlen = msg_len - sizeof(struct olsr_msg6);
             msg_data = tptr + sizeof(struct olsr_msg6);
@@ -347,15 +357,18 @@
                 return;
             }
 
-            printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+            ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
                     "\n\t  vtime %.3lfs, msg-seq 0x%04x, length %u%s",
                     tok2str(olsr_msg_values, "Unknown", msg_type),
-                    msg_type, ipaddr_string(msgptr.v4->originator),
+                    msg_type, ipaddr_string(ndo, msgptr.v4->originator),
                     msgptr.v4->ttl,
                     msgptr.v4->hopcount,
                     ME_TO_DOUBLE(msgptr.v4->vtime),
                     EXTRACT_16BITS(msgptr.v4->msg_seq),
-                    msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+                    msg_len, (msg_len_valid == 0) ? " (invalid)" : ""));
+            if (!msg_len_valid) {
+                return;
+            }
 
             msg_tlen = msg_len - sizeof(struct olsr_msg4);
             msg_data = tptr + sizeof(struct olsr_msg4);
@@ -364,12 +377,13 @@
         switch (msg_type) {
         case OLSR_HELLO_MSG:
         case OLSR_HELLO_LQ_MSG:
-            if (!TTEST2(*msg_data, sizeof(struct olsr_hello)))
+            if (msg_tlen < sizeof(struct olsr_hello))
                 goto trunc;
+            ND_TCHECK2(*msg_data, sizeof(struct olsr_hello));
 
             ptr.hello = (struct olsr_hello *)msg_data;
-            printf("\n\t  hello-time %.3lfs, MPR willingness %u",
-                   ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will);
+            ND_PRINT((ndo, "\n\t  hello-time %.3lfs, MPR willingness %u",
+                   ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will));
             msg_data += sizeof(struct olsr_hello);
             msg_tlen -= sizeof(struct olsr_hello);
 
@@ -379,8 +393,7 @@
                 /*
                  * link-type.
                  */
-                if (!TTEST2(*msg_data, sizeof(struct olsr_hello_link)))
-                    goto trunc;
+                ND_TCHECK2(*msg_data, sizeof(struct olsr_hello_link));
 
                 ptr.hello_link = (struct olsr_hello_link *)msg_data;
 
@@ -392,11 +405,11 @@
                         && (hello_len >= sizeof(struct olsr_hello_link)))
                     hello_len_valid = 1;
 
-                printf("\n\t    link-type %s, neighbor-type %s, len %u%s",
+                ND_PRINT((ndo, "\n\t    link-type %s, neighbor-type %s, len %u%s",
                        tok2str(olsr_link_type_values, "Unknown", link_type),
                        tok2str(olsr_neighbor_type_values, "Unknown", neighbor_type),
                        hello_len,
-                       (hello_len_valid == 0) ? " (invalid)" : "");
+                       (hello_len_valid == 0) ? " (invalid)" : ""));
 
                 if (hello_len_valid == 0)
                     break;
@@ -405,15 +418,21 @@
                 msg_tlen -= sizeof(struct olsr_hello_link);
                 hello_len -= sizeof(struct olsr_hello_link);
 
+                ND_TCHECK2(*msg_data, hello_len);
                 if (msg_type == OLSR_HELLO_MSG) {
-                    olsr_print_neighbor(msg_data, hello_len);
+                    if (olsr_print_neighbor(ndo, msg_data, hello_len) == -1)
+                        goto trunc;
                 } else {
 #if INET6
-                    if (is_ipv6)
-                        olsr_print_lq_neighbor6(msg_data, hello_len);
-                    else
+                    if (is_ipv6) {
+                        if (olsr_print_lq_neighbor6(ndo, msg_data, hello_len) == -1)
+                            goto trunc;
+                    } else
 #endif
-                        olsr_print_lq_neighbor4(msg_data, hello_len);
+                    {
+                        if (olsr_print_lq_neighbor4(ndo, msg_data, hello_len) == -1)
+                            goto trunc;
+                    }
                 }
 
                 msg_data += hello_len;
@@ -423,24 +442,30 @@
 
         case OLSR_TC_MSG:
         case OLSR_TC_LQ_MSG:
-            if (!TTEST2(*msg_data, sizeof(struct olsr_tc)))
+            if (msg_tlen < sizeof(struct olsr_tc))
                 goto trunc;
+            ND_TCHECK2(*msg_data, sizeof(struct olsr_tc));
 
             ptr.tc = (struct olsr_tc *)msg_data;
-            printf("\n\t    advertised neighbor seq 0x%04x",
-                   EXTRACT_16BITS(ptr.tc->ans_seq));
+            ND_PRINT((ndo, "\n\t    advertised neighbor seq 0x%04x",
+                   EXTRACT_16BITS(ptr.tc->ans_seq)));
             msg_data += sizeof(struct olsr_tc);
             msg_tlen -= sizeof(struct olsr_tc);
 
             if (msg_type == OLSR_TC_MSG) {
-                olsr_print_neighbor(msg_data, msg_tlen);
+                if (olsr_print_neighbor(ndo, msg_data, msg_tlen) == -1)
+                    goto trunc;
             } else {
 #if INET6
-                if (is_ipv6)
-                    olsr_print_lq_neighbor6(msg_data, msg_tlen);
-                else
+                if (is_ipv6) {
+                    if (olsr_print_lq_neighbor6(ndo, msg_data, msg_tlen) == -1)
+                        goto trunc;
+                } else
 #endif
-                    olsr_print_lq_neighbor4(msg_data, msg_tlen);
+                {
+                    if (olsr_print_lq_neighbor4(ndo, msg_data, msg_tlen) == -1)
+                        goto trunc;
+                }
             }
             break;
 
@@ -454,14 +479,16 @@
 #endif
 
             while (msg_tlen >= addr_size) {
-                if (!TTEST2(*msg_data, addr_size))
-                    goto trunc;
-
-                printf("\n\t  interface address %s",
+                ND_TCHECK2(*msg_data, addr_size);
 #if INET6
-                        is_ipv6 ? ip6addr_string(msg_data) :
+                ND_PRINT((ndo, "\n\t  interface address %s",
+                        is_ipv6 ? ip6addr_string(ndo, msg_data) :
+                        ipaddr_string(ndo, msg_data)));
+#else
+                ND_PRINT((ndo, "\n\t  interface address %s",
+                        ipaddr_string(ndo, msg_data)));
 #endif
-                        ipaddr_string(msg_data));
+
                 msg_data += addr_size;
                 msg_tlen -= addr_size;
             }
@@ -469,8 +496,8 @@
         }
 
         case OLSR_HNA_MSG:
-            printf("\n\t  Advertised networks (total %u)",
-                    (unsigned int) (msg_tlen / sizeof(struct olsr_hna6)));
+            ND_PRINT((ndo, "\n\t  Advertised networks (total %u)",
+                    (unsigned int) (msg_tlen / sizeof(struct olsr_hna6))));
 #if INET6
             if (is_ipv6)
             {
@@ -478,14 +505,13 @@
                 while (msg_tlen >= sizeof(struct olsr_hna6)) {
                     struct olsr_hna6 *hna6;
 
-                    if (!TTEST2(*msg_data, sizeof(struct olsr_hna6)))
-                        goto trunc;
+                    ND_TCHECK2(*msg_data, sizeof(struct olsr_hna6));
 
                     hna6 = (struct olsr_hna6 *)msg_data;
 
-                    printf("\n\t    #%i: %s/%u",
-                            i, ip6addr_string(hna6->network),
-                            mask62plen (hna6->mask));
+                    ND_PRINT((ndo, "\n\t    #%i: %s/%u",
+                            i, ip6addr_string(ndo, hna6->network),
+                            mask62plen (hna6->mask)));
 
                     msg_data += sizeof(struct olsr_hna6);
                     msg_tlen -= sizeof(struct olsr_hna6);
@@ -496,20 +522,15 @@
             {
                 int col = 0;
                 while (msg_tlen >= sizeof(struct olsr_hna4)) {
-                    if (!TTEST2(*msg_data, sizeof(struct olsr_hna4)))
-                        goto trunc;
+                    ND_TCHECK2(*msg_data, sizeof(struct olsr_hna4));
 
                     ptr.hna = (struct olsr_hna4 *)msg_data;
 
                     /* print 4 prefixes per line */
-                    if (col == 0)
-                        printf ("\n\t    ");
-                    else
-                        printf (", ");
-
-                    printf("%s/%u",
-                            ipaddr_string(ptr.hna->network),
-                            mask2plen(EXTRACT_32BITS(ptr.hna->mask)));
+                    ND_PRINT((ndo, "%s%s/%u",
+                            col == 0 ? "\n\t    " : ", ",
+                            ipaddr_string(ndo, ptr.hna->network),
+                            mask2plen(EXTRACT_32BITS(ptr.hna->mask))));
 
                     msg_data += sizeof(struct olsr_hna4);
                     msg_tlen -= sizeof(struct olsr_hna4);
@@ -535,12 +556,11 @@
 
             if (msg_tlen < 4)
                 goto trunc;
-            if (!TTEST2(*msg_data, 4))
-                goto trunc;
+            ND_TCHECK2(*msg_data, 4);
 
-            printf("\n\t  Version %u, Entries %u%s",
+            ND_PRINT((ndo, "\n\t  Version %u, Entries %u%s",
                    EXTRACT_16BITS(msg_data),
-                   name_entries, (name_entries_valid == 0) ? " (invalid)" : "");
+                   name_entries, (name_entries_valid == 0) ? " (invalid)" : ""));
 
             if (name_entries_valid == 0)
                 break;
@@ -553,8 +573,7 @@
 
                 if (msg_tlen < 4)
                     break;
-                if (!TTEST2(*msg_data, 4))
-                    goto trunc;
+                ND_TCHECK2(*msg_data, 4);
 
                 name_entry_type = EXTRACT_16BITS(msg_data);
                 name_entry_len = EXTRACT_16BITS(msg_data+2);
@@ -565,9 +584,9 @@
                 if ((name_entry_len > 0) && ((addr_size + name_entry_len) <= msg_tlen))
                     name_entry_len_valid = 1;
 
-                printf("\n\t    #%u: type %#06x, length %u%s",
+                ND_PRINT((ndo, "\n\t    #%u: type %#06x, length %u%s",
                         (unsigned int) i, name_entry_type,
-                        name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : "");
+                        name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : ""));
 
                 if (name_entry_len_valid == 0)
                     break;
@@ -580,19 +599,18 @@
                 if (msg_tlen < addr_size + name_entry_len + name_entry_padding)
                     goto trunc;
 
-                if (!TTEST2(*msg_data, addr_size + name_entry_len + name_entry_padding))
-                    goto trunc;
+                ND_TCHECK2(*msg_data, addr_size + name_entry_len + name_entry_padding);
 
 #if INET6
                 if (is_ipv6)
-                    printf(", address %s, name \"",
-                            ip6addr_string(msg_data));
+                    ND_PRINT((ndo, ", address %s, name \"",
+                            ip6addr_string(ndo, msg_data)));
                 else
 #endif
-                    printf(", address %s, name \"",
-                            ipaddr_string(msg_data));
-                fn_printn(msg_data + addr_size, name_entry_len, NULL);
-                printf("\"");
+                    ND_PRINT((ndo, ", address %s, name \"",
+                            ipaddr_string(ndo, msg_data)));
+                (void)fn_printn(ndo, msg_data + addr_size, name_entry_len, NULL);
+                ND_PRINT((ndo, "\""));
 
                 msg_data += addr_size + name_entry_len + name_entry_padding;
                 msg_tlen -= addr_size + name_entry_len + name_entry_padding;
@@ -606,7 +624,7 @@
              */
         case OLSR_POWERINFO_MSG:
         default:
-            print_unknown_data(msg_data, "\n\t    ", msg_tlen);
+            print_unknown_data(ndo, msg_data, "\n\t    ", msg_tlen);
             break;
         } /* switch (msg_type) */
         tptr += msg_len;
@@ -615,7 +633,7 @@
     return;
 
  trunc:
-    printf("[|olsr]");
+    ND_PRINT((ndo, "[|olsr]"));
 }
 
 /*
diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c
index 95a93a9..a36c32f 100644
--- a/print-openflow-1.0.c
+++ b/print-openflow-1.0.c
@@ -8,6 +8,16 @@
  *
  * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf
  *
+ * Most functions in this file take 3 arguments into account:
+ * * cp -- the pointer to the first octet to decode
+ * * len -- the length of the current structure as declared on the wire
+ * * ep -- the pointer to the end of the captured frame
+ * They return either the pointer to the next not-yet-decoded part of the frame
+ * or the value of ep, which means the current frame processing is over as it
+ * has been fully decoded or is malformed or truncated. This way it is possible
+ * to chain and nest such functions uniformly to decode an OF1.0 message, which
+ * consists of several layers of nested structures.
+ *
  * Decoding of Ethernet frames nested in OFPT_PACKET_IN and OFPT_PACKET_OUT
  * messages is done only when the verbosity level set by command-line argument
  * is "-vvv" or higher. In that case the verbosity level is temporarily
@@ -15,6 +25,10 @@
  * tcpdump with "-vvvv" will do full decoding of OpenFlow and "-v" decoding of
  * the nested frames.
  *
+ * Partial decoding of Big Switch Networks vendor extensions is done after the
+ * oftest (OpenFlow Testing Framework) and Loxigen (library generator) source
+ * code.
+ *
  *
  * Copyright (c) 2013 The TCPDUMP project
  * All rights reserved.
@@ -42,6 +56,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -51,10 +66,15 @@
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
+#include "ether.h"
 #include "ethertype.h"
 #include "ipproto.h"
+#include "oui.h"
 #include "openflow.h"
 
+static const char tstr[] = " [|openflow]";
+static const char cstr[] = " (corrupt)";
+
 #define OFPT_HELLO                    0x00
 #define OFPT_ERROR                    0x01
 #define OFPT_ECHO_REQUEST             0x02
@@ -573,11 +593,111 @@
 #define OFP_MAX_PORT_NAME_LEN      16
 #define DESC_STR_LEN              256
 #define SERIAL_NUM_LEN             32
-#define OFP_ETH_ALEN                6
 #define OFP_VLAN_NONE          0xffff
 
+/* vendor extensions */
+#define BSN_SET_IP_MASK                    0
+#define BSN_GET_IP_MASK_REQUEST            1
+#define BSN_GET_IP_MASK_REPLY              2
+#define BSN_SET_MIRRORING                  3
+#define BSN_GET_MIRRORING_REQUEST          4
+#define BSN_GET_MIRRORING_REPLY            5
+#define BSN_SHELL_COMMAND                  6
+#define BSN_SHELL_OUTPUT                   7
+#define BSN_SHELL_STATUS                   8
+#define BSN_GET_INTERFACES_REQUEST         9
+#define BSN_GET_INTERFACES_REPLY          10
+#define BSN_SET_PKTIN_SUPPRESSION_REQUEST 11
+#define BSN_SET_L2_TABLE_REQUEST          12
+#define BSN_GET_L2_TABLE_REQUEST          13
+#define BSN_GET_L2_TABLE_REPLY            14
+#define BSN_VIRTUAL_PORT_CREATE_REQUEST   15
+#define BSN_VIRTUAL_PORT_CREATE_REPLY     16
+#define BSN_VIRTUAL_PORT_REMOVE_REQUEST   17
+#define BSN_BW_ENABLE_SET_REQUEST         18
+#define BSN_BW_ENABLE_GET_REQUEST         19
+#define BSN_BW_ENABLE_GET_REPLY           20
+#define BSN_BW_CLEAR_DATA_REQUEST         21
+#define BSN_BW_CLEAR_DATA_REPLY           22
+#define BSN_BW_ENABLE_SET_REPLY           23
+#define BSN_SET_L2_TABLE_REPLY            24
+#define BSN_SET_PKTIN_SUPPRESSION_REPLY   25
+#define BSN_VIRTUAL_PORT_REMOVE_REPLY     26
+#define BSN_HYBRID_GET_REQUEST            27
+#define BSN_HYBRID_GET_REPLY              28
+                                       /* 29 */
+                                       /* 30 */
+#define BSN_PDU_TX_REQUEST                31
+#define BSN_PDU_TX_REPLY                  32
+#define BSN_PDU_RX_REQUEST                33
+#define BSN_PDU_RX_REPLY                  34
+#define BSN_PDU_RX_TIMEOUT                35
+
+static const struct tok bsn_subtype_str[] = {
+	{ BSN_SET_IP_MASK,                   "SET_IP_MASK"                   },
+	{ BSN_GET_IP_MASK_REQUEST,           "GET_IP_MASK_REQUEST"           },
+	{ BSN_GET_IP_MASK_REPLY,             "GET_IP_MASK_REPLY"             },
+	{ BSN_SET_MIRRORING,                 "SET_MIRRORING"                 },
+	{ BSN_GET_MIRRORING_REQUEST,         "GET_MIRRORING_REQUEST"         },
+	{ BSN_GET_MIRRORING_REPLY,           "GET_MIRRORING_REPLY"           },
+	{ BSN_SHELL_COMMAND,                 "SHELL_COMMAND"                 },
+	{ BSN_SHELL_OUTPUT,                  "SHELL_OUTPUT"                  },
+	{ BSN_SHELL_STATUS,                  "SHELL_STATUS"                  },
+	{ BSN_GET_INTERFACES_REQUEST,        "GET_INTERFACES_REQUEST"        },
+	{ BSN_GET_INTERFACES_REPLY,          "GET_INTERFACES_REPLY"          },
+	{ BSN_SET_PKTIN_SUPPRESSION_REQUEST, "SET_PKTIN_SUPPRESSION_REQUEST" },
+	{ BSN_SET_L2_TABLE_REQUEST,          "SET_L2_TABLE_REQUEST"          },
+	{ BSN_GET_L2_TABLE_REQUEST,          "GET_L2_TABLE_REQUEST"          },
+	{ BSN_GET_L2_TABLE_REPLY,            "GET_L2_TABLE_REPLY"            },
+	{ BSN_VIRTUAL_PORT_CREATE_REQUEST,   "VIRTUAL_PORT_CREATE_REQUEST"   },
+	{ BSN_VIRTUAL_PORT_CREATE_REPLY,     "VIRTUAL_PORT_CREATE_REPLY"     },
+	{ BSN_VIRTUAL_PORT_REMOVE_REQUEST,   "VIRTUAL_PORT_REMOVE_REQUEST"   },
+	{ BSN_BW_ENABLE_SET_REQUEST,         "BW_ENABLE_SET_REQUEST"         },
+	{ BSN_BW_ENABLE_GET_REQUEST,         "BW_ENABLE_GET_REQUEST"         },
+	{ BSN_BW_ENABLE_GET_REPLY,           "BW_ENABLE_GET_REPLY"           },
+	{ BSN_BW_CLEAR_DATA_REQUEST,         "BW_CLEAR_DATA_REQUEST"         },
+	{ BSN_BW_CLEAR_DATA_REPLY,           "BW_CLEAR_DATA_REPLY"           },
+	{ BSN_BW_ENABLE_SET_REPLY,           "BW_ENABLE_SET_REPLY"           },
+	{ BSN_SET_L2_TABLE_REPLY,            "SET_L2_TABLE_REPLY"            },
+	{ BSN_SET_PKTIN_SUPPRESSION_REPLY,   "SET_PKTIN_SUPPRESSION_REPLY"   },
+	{ BSN_VIRTUAL_PORT_REMOVE_REPLY,     "VIRTUAL_PORT_REMOVE_REPLY"     },
+	{ BSN_HYBRID_GET_REQUEST,            "HYBRID_GET_REQUEST"            },
+	{ BSN_HYBRID_GET_REPLY,              "HYBRID_GET_REPLY"              },
+	{ BSN_PDU_TX_REQUEST,                "PDU_TX_REQUEST"                },
+	{ BSN_PDU_TX_REPLY,                  "PDU_TX_REPLY"                  },
+	{ BSN_PDU_RX_REQUEST,                "PDU_RX_REQUEST"                },
+	{ BSN_PDU_RX_REPLY,                  "PDU_RX_REPLY"                  },
+	{ BSN_PDU_RX_TIMEOUT,                "PDU_RX_TIMEOUT"                },
+	{ 0, NULL }
+};
+
+#define BSN_ACTION_MIRROR                  1
+#define BSN_ACTION_SET_TUNNEL_DST          2
+                                        /* 3 */
+#define BSN_ACTION_CHECKSUM                4
+
+static const struct tok bsn_action_subtype_str[] = {
+	{ BSN_ACTION_MIRROR,                 "MIRROR"                        },
+	{ BSN_ACTION_SET_TUNNEL_DST,         "SET_TUNNEL_DST"                },
+	{ BSN_ACTION_CHECKSUM,               "CHECKSUM"                      },
+	{ 0, NULL }
+};
+
+static const struct tok bsn_mirror_copy_stage_str[] = {
+	{ 0, "INGRESS" },
+	{ 1, "EGRESS"  },
+	{ 0, NULL },
+};
+
+static const struct tok bsn_onoff_str[] = {
+	{ 0, "OFF" },
+	{ 1, "ON"  },
+	{ 0, NULL },
+};
+
 static const char *
-vlan_str(const uint16_t vid) {
+vlan_str(const uint16_t vid)
+{
 	static char buf[sizeof("65535 (bogus)")];
 	const char *fmt;
 
@@ -589,14 +709,17 @@
 }
 
 static const char *
-pcp_str(const uint8_t pcp) {
+pcp_str(const uint8_t pcp)
+{
 	static char buf[sizeof("255 (bogus)")];
 	snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
 	return buf;
 }
 
 static void
-of10_bitmap_print(const struct tok *t, const uint32_t v, const uint32_t u) {
+of10_bitmap_print(netdissect_options *ndo,
+                  const struct tok *t, const uint32_t v, const uint32_t u)
+{
 	const char *sep = " (";
 
 	if (v == 0)
@@ -604,73 +727,421 @@
 	/* assigned bits */
 	for (; t->s != NULL; t++)
 		if (v & t->v) {
-			printf("%s%s", sep, t->s);
+			ND_PRINT((ndo, "%s%s", sep, t->s));
 			sep = ", ";
 		}
 	/* unassigned bits? */
-	printf(v & u ? ") (bogus)" : ")");
+	ND_PRINT((ndo, v & u ? ") (bogus)" : ")"));
 }
 
 static const u_char *
-of10_data_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_data_print(netdissect_options *ndo,
+                const u_char *cp, const u_char *ep, const u_int len)
+{
 	if (len == 0)
 		return cp;
 	/* data */
-	printf("\n\t data (%u octets)", len);
-	TCHECK2(*cp, len);
-	if (vflag >= 2)
-		hex_and_ascii_print("\n\t  ", cp, len);
+	ND_PRINT((ndo, "\n\t data (%u octets)", len));
+	ND_TCHECK2(*cp, len);
+	if (ndo->ndo_vflag >= 2)
+		hex_and_ascii_print(ndo, "\n\t  ", cp, len);
 	return cp + len;
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
+	return ep;
+}
+
+static const u_char *
+of10_bsn_message_print(netdissect_options *ndo,
+                       const u_char *cp, const u_char *ep, const u_int len)
+{
+	const u_char *cp0 = cp;
+	uint32_t subtype;
+
+	if (len < 4)
+		goto corrupt;
+	/* subtype */
+	ND_TCHECK2(*cp, 4);
+	subtype = EXTRACT_32BITS(cp);
+	cp += 4;
+	ND_PRINT((ndo, "\n\t subtype %s", tok2str(bsn_subtype_str, "unknown (0x%08x)", subtype)));
+	switch (subtype) {
+	case BSN_GET_IP_MASK_REQUEST:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |     index     |                      pad                      |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                              pad                              |
+		 * +---------------+---------------+---------------+---------------+
+		 *
+		 */
+		if (len != 12)
+			goto corrupt;
+		/* index */
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, ", index %u", *cp));
+		cp += 1;
+		/* pad */
+		ND_TCHECK2(*cp, 7);
+		cp += 7;
+		break;
+	case BSN_SET_IP_MASK:
+	case BSN_GET_IP_MASK_REPLY:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |     index     |                      pad                      |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                              mask                             |
+		 * +---------------+---------------+---------------+---------------+
+		 *
+		 */
+		if (len != 12)
+			goto corrupt;
+		/* index */
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, ", index %u", *cp));
+		cp += 1;
+		/* pad */
+		ND_TCHECK2(*cp, 3);
+		cp += 3;
+		/* mask */
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", mask %s", ipaddr_string(ndo, cp)));
+		cp += 4;
+		break;
+	case BSN_SET_MIRRORING:
+	case BSN_GET_MIRRORING_REQUEST:
+	case BSN_GET_MIRRORING_REPLY:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * | report m. p.  |                      pad                      |
+		 * +---------------+---------------+---------------+---------------+
+		 *
+		 */
+		if (len != 8)
+			goto corrupt;
+		/* report_mirror_ports */
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, ", report_mirror_ports %s", tok2str(bsn_onoff_str, "bogus (%u)", *cp)));
+		cp += 1;
+		/* pad */
+		ND_TCHECK2(*cp, 3);
+		cp += 3;
+		break;
+	case BSN_GET_INTERFACES_REQUEST:
+	case BSN_GET_L2_TABLE_REQUEST:
+	case BSN_BW_ENABLE_GET_REQUEST:
+	case BSN_BW_CLEAR_DATA_REQUEST:
+	case BSN_HYBRID_GET_REQUEST:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 *
+		 */
+		if (len != 4)
+			goto corrupt;
+		break;
+	case BSN_VIRTUAL_PORT_REMOVE_REQUEST:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                           vport_no                            |
+		 * +---------------+---------------+---------------+---------------+
+		 *
+		 */
+		if (len != 8)
+			goto corrupt;
+		/* vport_no */
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", vport_no %u", EXTRACT_32BITS(cp)));
+		cp += 4;
+		break;
+	case BSN_SHELL_COMMAND:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            service                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                             data ...
+		 * +---------------+---------------+--------
+		 *
+		 */
+		if (len < 8)
+			goto corrupt;
+		/* service */
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", service %u", EXTRACT_32BITS(cp)));
+		cp += 4;
+		/* data */
+		ND_PRINT((ndo, ", data '"));
+		if (fn_printn(ndo, cp, len - 8, ep)) {
+			ND_PRINT((ndo, "'"));
+			goto trunc;
+		}
+		ND_PRINT((ndo, "'"));
+		cp += len - 8;
+		break;
+	case BSN_SHELL_OUTPUT:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                             data ...
+		 * +---------------+---------------+--------
+		 *
+		 */
+		/* already checked that len >= 4 */
+		/* data */
+		ND_PRINT((ndo, ", data '"));
+		if (fn_printn(ndo, cp, len - 4, ep)) {
+			ND_PRINT((ndo, "'"));
+			goto trunc;
+		}
+		ND_PRINT((ndo, "'"));
+		cp += len - 4;
+		break;
+	case BSN_SHELL_STATUS:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            status                             |
+		 * +---------------+---------------+---------------+---------------+
+		 *
+		 */
+		if (len != 8)
+			goto corrupt;
+		/* status */
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", status 0x%08x", EXTRACT_32BITS(cp)));
+		cp += 4;
+		break;
+	default:
+		ND_TCHECK2(*cp, len - 4);
+		cp += len - 4;
+	}
+	return cp;
+
+corrupt: /* skip the undersized data */
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len);
+	return cp0 + len;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return ep;
+}
+
+static const u_char *
+of10_bsn_actions_print(netdissect_options *ndo,
+                       const u_char *cp, const u_char *ep, const u_int len)
+{
+	const u_char *cp0 = cp;
+	uint32_t subtype, vlan_tag;
+
+	if (len < 4)
+		goto corrupt;
+	/* subtype */
+	ND_TCHECK2(*cp, 4);
+	subtype = EXTRACT_32BITS(cp);
+	cp += 4;
+	ND_PRINT((ndo, "\n\t  subtype %s", tok2str(bsn_action_subtype_str, "unknown (0x%08x)", subtype)));
+	switch (subtype) {
+	case BSN_ACTION_MIRROR:
+		/*
+		 *  0                   1                   2                   3
+		 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+		 * +---------------+---------------+---------------+---------------+
+		 * |                            subtype                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                           dest_port                           |
+		 * +---------------+---------------+---------------+---------------+
+		 * |                           vlan_tag                            |
+		 * +---------------+---------------+---------------+---------------+
+		 * |  copy_stage   |                      pad                      |
+		 * +---------------+---------------+---------------+---------------+
+		 *
+		 */
+		if (len != 16)
+			goto corrupt;
+		/* dest_port */
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", dest_port %u", EXTRACT_32BITS(cp)));
+		cp += 4;
+		/* vlan_tag */
+		ND_TCHECK2(*cp, 4);
+		vlan_tag = EXTRACT_32BITS(cp);
+		cp += 4;
+		switch (vlan_tag >> 16) {
+		case 0:
+			ND_PRINT((ndo, ", vlan_tag none"));
+			break;
+		case ETHERTYPE_8021Q:
+			ND_PRINT((ndo, ", vlan_tag 802.1Q (%s)", ieee8021q_tci_string(vlan_tag & 0xffff)));
+			break;
+		default:
+			ND_PRINT((ndo, ", vlan_tag unknown (0x%04x)", vlan_tag >> 16));
+		}
+		/* copy_stage */
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, ", copy_stage %s", tok2str(bsn_mirror_copy_stage_str, "unknown (%u)", *cp)));
+		cp += 1;
+		/* pad */
+		ND_TCHECK2(*cp, 3);
+		cp += 3;
+		break;
+	default:
+		ND_TCHECK2(*cp, len - 4);
+		cp += len - 4;
+	}
+
+	return cp;
+
+corrupt:
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len);
+	return cp0 + len;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return ep;
+}
+
+static const u_char *
+of10_vendor_action_print(netdissect_options *ndo,
+                         const u_char *cp, const u_char *ep, const u_int len)
+{
+	uint32_t vendor;
+	const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, const u_int);
+
+	if (len < 4)
+		goto corrupt;
+	/* vendor */
+	ND_TCHECK2(*cp, 4);
+	vendor = EXTRACT_32BITS(cp);
+	cp += 4;
+	ND_PRINT((ndo, ", vendor 0x%08x (%s)", vendor, of_vendor_name(vendor)));
+	/* data */
+	decoder =
+		vendor == OUI_BSN         ? of10_bsn_actions_print         :
+		of10_data_print;
+	return decoder(ndo, cp, ep, len - 4);
+
+corrupt: /* skip the undersized data */
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, len);
+	return cp + len;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
+	return ep;
+}
+
+static const u_char *
+of10_vendor_message_print(netdissect_options *ndo,
+                          const u_char *cp, const u_char *ep, const u_int len)
+{
+	uint32_t vendor;
+	const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, u_int);
+
+	if (len < 4)
+		goto corrupt;
+	/* vendor */
+	ND_TCHECK2(*cp, 4);
+	vendor = EXTRACT_32BITS(cp);
+	cp += 4;
+	ND_PRINT((ndo, ", vendor 0x%08x (%s)", vendor, of_vendor_name(vendor)));
+	/* data */
+	decoder =
+		vendor == OUI_BSN         ? of10_bsn_message_print         :
+		of10_data_print;
+	return decoder(ndo, cp, ep, len - 4);
+
+corrupt: /* skip the undersized data */
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, len);
+	return cp + len;
+trunc:
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* Vendor ID is mandatory, data is optional. */
 static const u_char *
-of10_vendor_data_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_vendor_data_print(netdissect_options *ndo,
+                       const u_char *cp, const u_char *ep, const u_int len)
+{
+	uint32_t vendor;
+
 	if (len < 4)
 		goto corrupt;
 	/* vendor */
-	TCHECK2(*cp, 4);
-	printf(", vendor 0x%08x", EXTRACT_32BITS(cp));
+	ND_TCHECK2(*cp, 4);
+	vendor = EXTRACT_32BITS(cp);
 	cp += 4;
+	ND_PRINT((ndo, ", vendor 0x%08x (%s)", vendor, of_vendor_name(vendor)));
 	/* data */
-	return of10_data_print(cp, ep, len - 4);
+	return of10_data_print(ndo, cp, ep, len - 4);
 
 corrupt: /* skip the undersized data */
-	printf(" (corrupt)");
-	TCHECK2(*cp, len);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, len);
 	return cp + len;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 static const u_char *
-of10_packet_data_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_packet_data_print(netdissect_options *ndo,
+                       const u_char *cp, const u_char *ep, const u_int len)
+{
 	if (len == 0)
 		return cp;
 	/* data */
-	printf("\n\t data (%u octets)", len);
-	if (vflag < 3)
+	ND_PRINT((ndo, "\n\t data (%u octets)", len));
+	if (ndo->ndo_vflag < 3)
 		return cp + len;
-	TCHECK2(*cp, len);
-	vflag -= 3;
-	printf(", frame decoding below\n");
-	ether_print(gndo, cp, len, snapend - cp, NULL, NULL);
-	vflag += 3;
+	ND_TCHECK2(*cp, len);
+	ndo->ndo_vflag -= 3;
+	ND_PRINT((ndo, ", frame decoding below\n"));
+	ether_print(ndo, cp, len, ndo->ndo_snapend - cp, NULL, NULL);
+	ndo->ndo_vflag += 3;
 	return cp + len;
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.2.1 */
 static const u_char *
-of10_phy_ports_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_phy_ports_print(netdissect_options *ndo,
+                     const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 
@@ -678,54 +1149,54 @@
 		if (len < OF_PHY_PORT_LEN)
 			goto corrupt;
 		/* port_no */
-		TCHECK2(*cp, 2);
-		printf("\n\t  port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t  port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		cp += 2;
 		/* hw_addr */
-		TCHECK2(*cp, OFP_ETH_ALEN);
-		printf(", hw_addr %s", etheraddr_string(cp));
-		cp += OFP_ETH_ALEN;
+		ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+		ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
+		cp += ETHER_ADDR_LEN;
 		/* name */
-		TCHECK2(*cp, OFP_MAX_PORT_NAME_LEN);
-		printf(", name '");
-		fn_print(cp, cp + OFP_MAX_PORT_NAME_LEN);
-		printf("'");
+		ND_TCHECK2(*cp, OFP_MAX_PORT_NAME_LEN);
+		ND_PRINT((ndo, ", name '"));
+		fn_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
+		ND_PRINT((ndo, "'"));
 		cp += OFP_MAX_PORT_NAME_LEN;
 
-		if (vflag < 2) {
-			TCHECK2(*cp, 24);
+		if (ndo->ndo_vflag < 2) {
+			ND_TCHECK2(*cp, 24);
 			cp += 24;
 			goto next_port;
 		}
 		/* config */
-		TCHECK2(*cp, 4);
-		printf("\n\t   config 0x%08x", EXTRACT_32BITS(cp));
-		of10_bitmap_print(ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t   config 0x%08x", EXTRACT_32BITS(cp)));
+		of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
 		cp += 4;
 		/* state */
-		TCHECK2(*cp, 4);
-		printf("\n\t   state 0x%08x", EXTRACT_32BITS(cp));
-		of10_bitmap_print(ofpps_bm, EXTRACT_32BITS(cp), OFPPS_U);
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t   state 0x%08x", EXTRACT_32BITS(cp)));
+		of10_bitmap_print(ndo, ofpps_bm, EXTRACT_32BITS(cp), OFPPS_U);
 		cp += 4;
 		/* curr */
-		TCHECK2(*cp, 4);
-		printf("\n\t   curr 0x%08x", EXTRACT_32BITS(cp));
-		of10_bitmap_print(ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t   curr 0x%08x", EXTRACT_32BITS(cp)));
+		of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
 		cp += 4;
 		/* advertised */
-		TCHECK2(*cp, 4);
-		printf("\n\t   advertised 0x%08x", EXTRACT_32BITS(cp));
-		of10_bitmap_print(ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t   advertised 0x%08x", EXTRACT_32BITS(cp)));
+		of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
 		cp += 4;
 		/* supported */
-		TCHECK2(*cp, 4);
-		printf("\n\t   supported 0x%08x", EXTRACT_32BITS(cp));
-		of10_bitmap_print(ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t   supported 0x%08x", EXTRACT_32BITS(cp)));
+		of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
 		cp += 4;
 		/* peer */
-		TCHECK2(*cp, 4);
-		printf("\n\t   peer 0x%08x", EXTRACT_32BITS(cp));
-		of10_bitmap_print(ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t   peer 0x%08x", EXTRACT_32BITS(cp)));
+		of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
 		cp += 4;
 next_port:
 		len -= OF_PHY_PORT_LEN;
@@ -733,17 +1204,19 @@
 	return cp;
 
 corrupt: /* skip the undersized trailing data */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.2.2 */
 static const u_char *
-of10_queue_props_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_queue_props_print(netdissect_options *ndo,
+                       const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 	uint16_t property, plen, rate;
@@ -754,19 +1227,19 @@
 		if (len < OF_QUEUE_PROP_HEADER_LEN)
 			goto corrupt;
 		/* property */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		property = EXTRACT_16BITS(cp);
 		cp += 2;
-		printf("\n\t   property %s", tok2str(ofpqt_str, "invalid (0x%04x)", property));
+		ND_PRINT((ndo, "\n\t   property %s", tok2str(ofpqt_str, "invalid (0x%04x)", property)));
 		/* len */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		plen = EXTRACT_16BITS(cp);
 		cp += 2;
-		printf(", len %u", plen);
+		ND_PRINT((ndo, ", len %u", plen));
 		if (plen < OF_QUEUE_PROP_HEADER_LEN || plen > len)
 			goto corrupt;
 		/* pad */
-		TCHECK2(*cp, 4);
+		ND_TCHECK2(*cp, 4);
 		cp += 4;
 		/* property-specific constraints and decoding */
 		switch (property) {
@@ -780,25 +1253,25 @@
 			skip = 1;
 		}
 		if (plen_bogus) {
-			printf(" (bogus)");
+			ND_PRINT((ndo, " (bogus)"));
 			skip = 1;
 		}
 		if (skip) {
-			TCHECK2(*cp, plen - 4);
+			ND_TCHECK2(*cp, plen - 4);
 			cp += plen - 4;
 			goto next_property;
 		}
 		if (property == OFPQT_MIN_RATE) { /* the only case of property decoding */
 			/* rate */
-			TCHECK2(*cp, 2);
+			ND_TCHECK2(*cp, 2);
 			rate = EXTRACT_16BITS(cp);
 			cp += 2;
 			if (rate > 1000)
-				printf(", rate disabled");
+				ND_PRINT((ndo, ", rate disabled"));
 			else
-				printf(", rate %u.%u%%", rate / 10, rate % 10);
+				ND_PRINT((ndo, ", rate %u.%u%%", rate / 10, rate % 10));
 			/* pad */
-			TCHECK2(*cp, 6);
+			ND_TCHECK2(*cp, 6);
 			cp += 6;
 		}
 next_property:
@@ -807,17 +1280,19 @@
 	return cp;
 
 corrupt: /* skip the rest of queue properties */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_queues_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_queues_print(netdissect_options *ndo,
+                  const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 	uint16_t desclen;
@@ -826,26 +1301,26 @@
 		if (len < OF_PACKET_QUEUE_LEN)
 			goto corrupt;
 		/* queue_id */
-		TCHECK2(*cp, 4);
-		printf("\n\t  queue_id %u", EXTRACT_32BITS(cp));
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t  queue_id %u", EXTRACT_32BITS(cp)));
 		cp += 4;
 		/* len */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		desclen = EXTRACT_16BITS(cp);
 		cp += 2;
-		printf(", len %u", desclen);
+		ND_PRINT((ndo, ", len %u", desclen));
 		if (desclen < OF_PACKET_QUEUE_LEN || desclen > len)
 			goto corrupt;
 		/* pad */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		cp += 2;
 		/* properties */
-		if (vflag < 2) {
-			TCHECK2(*cp, desclen - OF_PACKET_QUEUE_LEN);
+		if (ndo->ndo_vflag < 2) {
+			ND_TCHECK2(*cp, desclen - OF_PACKET_QUEUE_LEN);
 			cp += desclen - OF_PACKET_QUEUE_LEN;
 			goto next_queue;
 		}
-		if (ep == (cp = of10_queue_props_print(cp, ep, desclen - OF_PACKET_QUEUE_LEN)))
+		if (ep == (cp = of10_queue_props_print(ndo, cp, ep, desclen - OF_PACKET_QUEUE_LEN)))
 			return ep; /* end of snapshot */
 next_queue:
 		len -= desclen;
@@ -853,17 +1328,19 @@
 	return cp;
 
 corrupt: /* skip the rest of queues */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.2.3 */
 static const u_char *
-of10_match_print(const char *pfx, const u_char *cp, const u_char *ep) {
+of10_match_print(netdissect_options *ndo,
+                 const char *pfx, const u_char *cp, const u_char *ep)
+{
 	uint32_t wildcards;
 	uint16_t dl_type;
 	uint8_t nw_proto;
@@ -871,102 +1348,104 @@
 	const char *field_name;
 
 	/* wildcards */
-	TCHECK2(*cp, 4);
+	ND_TCHECK2(*cp, 4);
 	wildcards = EXTRACT_32BITS(cp);
 	if (wildcards & OFPFW_U)
-		printf("%swildcards 0x%08x (bogus)", pfx, wildcards);
+		ND_PRINT((ndo, "%swildcards 0x%08x (bogus)", pfx, wildcards));
 	cp += 4;
 	/* in_port */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (! (wildcards & OFPFW_IN_PORT))
-		printf("%smatch in_port %s", pfx, tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_PRINT((ndo, "%smatch in_port %s", pfx, tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 	cp += 2;
 	/* dl_src */
-	TCHECK2(*cp, OFP_ETH_ALEN);
+	ND_TCHECK2(*cp, ETHER_ADDR_LEN);
 	if (! (wildcards & OFPFW_DL_SRC))
-		printf("%smatch dl_src %s", pfx, etheraddr_string(cp));
-	cp += OFP_ETH_ALEN;
+		ND_PRINT((ndo, "%smatch dl_src %s", pfx, etheraddr_string(ndo, cp)));
+	cp += ETHER_ADDR_LEN;
 	/* dl_dst */
-	TCHECK2(*cp, OFP_ETH_ALEN);
+	ND_TCHECK2(*cp, ETHER_ADDR_LEN);
 	if (! (wildcards & OFPFW_DL_DST))
-		printf("%smatch dl_dst %s", pfx, etheraddr_string(cp));
-	cp += OFP_ETH_ALEN;
+		ND_PRINT((ndo, "%smatch dl_dst %s", pfx, etheraddr_string(ndo, cp)));
+	cp += ETHER_ADDR_LEN;
 	/* dl_vlan */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (! (wildcards & OFPFW_DL_VLAN))
-		printf("%smatch dl_vlan %s", pfx, vlan_str(EXTRACT_16BITS(cp)));
+		ND_PRINT((ndo, "%smatch dl_vlan %s", pfx, vlan_str(EXTRACT_16BITS(cp))));
 	cp += 2;
 	/* dl_vlan_pcp */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	if (! (wildcards & OFPFW_DL_VLAN_PCP))
-		printf("%smatch dl_vlan_pcp %s", pfx, pcp_str(*cp));
+		ND_PRINT((ndo, "%smatch dl_vlan_pcp %s", pfx, pcp_str(*cp)));
 	cp += 1;
 	/* pad1 */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	cp += 1;
 	/* dl_type */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	dl_type = EXTRACT_16BITS(cp);
 	cp += 2;
 	if (! (wildcards & OFPFW_DL_TYPE))
-		printf("%smatch dl_type 0x%04x", pfx, dl_type);
+		ND_PRINT((ndo, "%smatch dl_type 0x%04x", pfx, dl_type));
 	/* nw_tos */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	if (! (wildcards & OFPFW_NW_TOS))
-		printf("%smatch nw_tos 0x%02x", pfx, *cp);
+		ND_PRINT((ndo, "%smatch nw_tos 0x%02x", pfx, *cp));
 	cp += 1;
 	/* nw_proto */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	nw_proto = *cp;
 	cp += 1;
 	if (! (wildcards & OFPFW_NW_PROTO)) {
 		field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_ARP
 		  ? "arp_opcode" : "nw_proto";
-		printf("%smatch %s %u", pfx, field_name, nw_proto);
+		ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, nw_proto));
 	}
 	/* pad2 */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	cp += 2;
 	/* nw_src */
-	TCHECK2(*cp, 4);
+	ND_TCHECK2(*cp, 4);
 	nw_bits = (wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT;
 	if (nw_bits < 32)
-		printf("%smatch nw_src %s/%u", pfx, ipaddr_string(cp), 32 - nw_bits);
+		ND_PRINT((ndo, "%smatch nw_src %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
 	cp += 4;
 	/* nw_dst */
-	TCHECK2(*cp, 4);
+	ND_TCHECK2(*cp, 4);
 	nw_bits = (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT;
 	if (nw_bits < 32)
-		printf("%smatch nw_dst %s/%u", pfx, ipaddr_string(cp), 32 - nw_bits);
+		ND_PRINT((ndo, "%smatch nw_dst %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
 	cp += 4;
 	/* tp_src */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (! (wildcards & OFPFW_TP_SRC)) {
 		field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
 		  && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
 		  ? "icmp_type" : "tp_src";
-		printf("%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
 	}
 	cp += 2;
 	/* tp_dst */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (! (wildcards & OFPFW_TP_DST)) {
 		field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
 		  && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
 		  ? "icmp_code" : "tp_dst";
-		printf("%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
 	}
 	return cp + 2;
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.2.4 */
 static const u_char *
-of10_actions_print(const char *pfx, const u_char *cp, const u_char *ep,
-                   u_int len) {
+of10_actions_print(netdissect_options *ndo,
+                   const char *pfx, const u_char *cp, const u_char *ep,
+                   u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 	uint16_t type, alen, output_port;
@@ -977,15 +1456,15 @@
 		if (len < OF_ACTION_HEADER_LEN)
 			goto corrupt;
 		/* type */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		type = EXTRACT_16BITS(cp);
 		cp += 2;
-		printf("%saction type %s", pfx, tok2str(ofpat_str, "invalid (0x%04x)", type));
+		ND_PRINT((ndo, "%saction type %s", pfx, tok2str(ofpat_str, "invalid (0x%04x)", type)));
 		/* length */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		alen = EXTRACT_16BITS(cp);
 		cp += 2;
-		printf(", len %u", alen);
+		ND_PRINT((ndo, ", len %u", alen));
 		/* On action size underrun/overrun skip the rest of the action list. */
 		if (alen < OF_ACTION_HEADER_LEN || alen > len)
 			goto corrupt;
@@ -1015,11 +1494,11 @@
 			skip = 1;
 		}
 		if (alen_bogus) {
-			printf(" (bogus)");
+			ND_PRINT((ndo, " (bogus)"));
 			skip = 1;
 		}
 		if (skip) {
-			TCHECK2(*cp, alen - 4);
+			ND_TCHECK2(*cp, alen - 4);
 			cp += alen - 4;
 			goto next_action;
 		}
@@ -1027,90 +1506,90 @@
 		switch (type) {
 		case OFPAT_OUTPUT:
 			/* port */
-			TCHECK2(*cp, 2);
+			ND_TCHECK2(*cp, 2);
 			output_port = EXTRACT_16BITS(cp);
 			cp += 2;
-			printf(", port %s", tok2str(ofpp_str, "%u", output_port));
+			ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", output_port)));
 			/* max_len */
-			TCHECK2(*cp, 2);
+			ND_TCHECK2(*cp, 2);
 			if (output_port == OFPP_CONTROLLER)
-				printf(", max_len %u", EXTRACT_16BITS(cp));
+				ND_PRINT((ndo, ", max_len %u", EXTRACT_16BITS(cp)));
 			cp += 2;
 			break;
 		case OFPAT_SET_VLAN_VID:
 			/* vlan_vid */
-			TCHECK2(*cp, 2);
-			printf(", vlan_vid %s", vlan_str(EXTRACT_16BITS(cp)));
+			ND_TCHECK2(*cp, 2);
+			ND_PRINT((ndo, ", vlan_vid %s", vlan_str(EXTRACT_16BITS(cp))));
 			cp += 2;
 			/* pad */
-			TCHECK2(*cp, 2);
+			ND_TCHECK2(*cp, 2);
 			cp += 2;
 			break;
 		case OFPAT_SET_VLAN_PCP:
 			/* vlan_pcp */
-			TCHECK2(*cp, 1);
-			printf(", vlan_pcp %s", pcp_str(*cp));
+			ND_TCHECK2(*cp, 1);
+			ND_PRINT((ndo, ", vlan_pcp %s", pcp_str(*cp)));
 			cp += 1;
 			/* pad */
-			TCHECK2(*cp, 3);
+			ND_TCHECK2(*cp, 3);
 			cp += 3;
 			break;
 		case OFPAT_SET_DL_SRC:
 		case OFPAT_SET_DL_DST:
 			/* dl_addr */
-			TCHECK2(*cp, OFP_ETH_ALEN);
-			printf(", dl_addr %s", etheraddr_string(cp));
-			cp += OFP_ETH_ALEN;
+			ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+			ND_PRINT((ndo, ", dl_addr %s", etheraddr_string(ndo, cp)));
+			cp += ETHER_ADDR_LEN;
 			/* pad */
-			TCHECK2(*cp, 6);
+			ND_TCHECK2(*cp, 6);
 			cp += 6;
 			break;
 		case OFPAT_SET_NW_SRC:
 		case OFPAT_SET_NW_DST:
 			/* nw_addr */
-			TCHECK2(*cp, 4);
-			printf(", nw_addr %s", ipaddr_string(cp));
+			ND_TCHECK2(*cp, 4);
+			ND_PRINT((ndo, ", nw_addr %s", ipaddr_string(ndo, cp)));
 			cp += 4;
 			break;
 		case OFPAT_SET_NW_TOS:
 			/* nw_tos */
-			TCHECK2(*cp, 1);
-			printf(", nw_tos 0x%02x", *cp);
+			ND_TCHECK2(*cp, 1);
+			ND_PRINT((ndo, ", nw_tos 0x%02x", *cp));
 			cp += 1;
 			/* pad */
-			TCHECK2(*cp, 3);
+			ND_TCHECK2(*cp, 3);
 			cp += 3;
 			break;
 		case OFPAT_SET_TP_SRC:
 		case OFPAT_SET_TP_DST:
 			/* nw_tos */
-			TCHECK2(*cp, 2);
-			printf(", tp_port %u", EXTRACT_16BITS(cp));
+			ND_TCHECK2(*cp, 2);
+			ND_PRINT((ndo, ", tp_port %u", EXTRACT_16BITS(cp)));
 			cp += 2;
 			/* pad */
-			TCHECK2(*cp, 2);
+			ND_TCHECK2(*cp, 2);
 			cp += 2;
 			break;
 		case OFPAT_ENQUEUE:
 			/* port */
-			TCHECK2(*cp, 2);
-			printf(", port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+			ND_TCHECK2(*cp, 2);
+			ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 			cp += 2;
 			/* pad */
-			TCHECK2(*cp, 6);
+			ND_TCHECK2(*cp, 6);
 			cp += 6;
 			/* queue_id */
-			TCHECK2(*cp, 4);
-			printf(", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp)));
+			ND_TCHECK2(*cp, 4);
+			ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
 			cp += 4;
 			break;
 		case OFPAT_VENDOR:
-			if (ep == (cp = of10_vendor_data_print(cp, ep, alen - 4)))
+			if (ep == (cp = of10_vendor_action_print(ndo, cp, ep, alen - 4)))
 				return ep; /* end of snapshot */
 			break;
 		case OFPAT_STRIP_VLAN:
 			/* pad */
-			TCHECK2(*cp, 4);
+			ND_TCHECK2(*cp, 4);
 			cp += 4;
 			break;
 		} /* switch */
@@ -1120,158 +1599,166 @@
 	return cp;
 
 corrupt: /* skip the rest of actions */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.3.1 */
 static const u_char *
-of10_features_reply_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_features_reply_print(netdissect_options *ndo,
+                          const u_char *cp, const u_char *ep, const u_int len)
+{
 	/* datapath_id */
-	TCHECK2(*cp, 8);
-	printf("\n\t dpid 0x%016" PRIx64, EXTRACT_64BITS(cp));
+	ND_TCHECK2(*cp, 8);
+	ND_PRINT((ndo, "\n\t dpid 0x%016" PRIx64, EXTRACT_64BITS(cp)));
 	cp += 8;
 	/* n_buffers */
-	TCHECK2(*cp, 4);
-	printf(", n_buffers %u", EXTRACT_32BITS(cp));
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ", n_buffers %u", EXTRACT_32BITS(cp)));
 	cp += 4;
 	/* n_tables */
-	TCHECK2(*cp, 1);
-	printf(", n_tables %u", *cp);
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", n_tables %u", *cp));
 	cp += 1;
 	/* pad */
-	TCHECK2(*cp, 3);
+	ND_TCHECK2(*cp, 3);
 	cp += 3;
 	/* capabilities */
-	TCHECK2(*cp, 4);
-	printf("\n\t capabilities 0x%08x", EXTRACT_32BITS(cp));
-	of10_bitmap_print(ofp_capabilities_bm, EXTRACT_32BITS(cp), OFPCAP_U);
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, "\n\t capabilities 0x%08x", EXTRACT_32BITS(cp)));
+	of10_bitmap_print(ndo, ofp_capabilities_bm, EXTRACT_32BITS(cp), OFPCAP_U);
 	cp += 4;
 	/* actions */
-	TCHECK2(*cp, 4);
-	printf("\n\t actions 0x%08x", EXTRACT_32BITS(cp));
-	of10_bitmap_print(ofpat_bm, EXTRACT_32BITS(cp), OFPAT_U);
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, "\n\t actions 0x%08x", EXTRACT_32BITS(cp)));
+	of10_bitmap_print(ndo, ofpat_bm, EXTRACT_32BITS(cp), OFPAT_U);
 	cp += 4;
 	/* ports */
-	return of10_phy_ports_print(cp, ep, len - OF_SWITCH_FEATURES_LEN);
+	return of10_phy_ports_print(ndo, cp, ep, len - OF_SWITCH_FEATURES_LEN);
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.3.3 */
 static const u_char *
-of10_flow_mod_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_flow_mod_print(netdissect_options *ndo,
+                    const u_char *cp, const u_char *ep, const u_int len)
+{
 	uint16_t command;
 
 	/* match */
-	if (ep == (cp = of10_match_print("\n\t ", cp, ep)))
+	if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
 		return ep; /* end of snapshot */
 	/* cookie */
-	TCHECK2(*cp, 8);
-	printf("\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp));
+	ND_TCHECK2(*cp, 8);
+	ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
 	cp += 8;
 	/* command */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	command = EXTRACT_16BITS(cp);
-	printf(", command %s", tok2str(ofpfc_str, "invalid (0x%04x)", command));
+	ND_PRINT((ndo, ", command %s", tok2str(ofpfc_str, "invalid (0x%04x)", command)));
 	cp += 2;
 	/* idle_timeout */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (EXTRACT_16BITS(cp))
-		printf(", idle_timeout %u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
 	cp += 2;
 	/* hard_timeout */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (EXTRACT_16BITS(cp))
-		printf(", hard_timeout %u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
 	cp += 2;
 	/* priority */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (EXTRACT_16BITS(cp))
-		printf(", priority %u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
 	cp += 2;
 	/* buffer_id */
-	TCHECK2(*cp, 4);
+	ND_TCHECK2(*cp, 4);
 	if (command == OFPFC_ADD || command == OFPFC_MODIFY ||
 	    command == OFPFC_MODIFY_STRICT)
-		printf(", buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp)));
+		ND_PRINT((ndo, ", buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
 	cp += 4;
 	/* out_port */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (command == OFPFC_DELETE || command == OFPFC_DELETE_STRICT)
-		printf(", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 	cp += 2;
 	/* flags */
-	TCHECK2(*cp, 2);
-	printf(", flags 0x%04x", EXTRACT_16BITS(cp));
-	of10_bitmap_print(ofpff_bm, EXTRACT_16BITS(cp), OFPFF_U);
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+	of10_bitmap_print(ndo, ofpff_bm, EXTRACT_16BITS(cp), OFPFF_U);
 	cp += 2;
 	/* actions */
-	return of10_actions_print("\n\t ", cp, ep, len - OF_FLOW_MOD_LEN);
+	return of10_actions_print(ndo, "\n\t ", cp, ep, len - OF_FLOW_MOD_LEN);
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_port_mod_print(const u_char *cp, const u_char *ep) {
+of10_port_mod_print(netdissect_options *ndo,
+                    const u_char *cp, const u_char *ep)
+{
 	/* port_no */
-	TCHECK2(*cp, 2);
-	printf("\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 	cp += 2;
 	/* hw_addr */
-	TCHECK2(*cp, OFP_ETH_ALEN);
-	printf(", hw_addr %s", etheraddr_string(cp));
-	cp += OFP_ETH_ALEN;
+	ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+	ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
+	cp += ETHER_ADDR_LEN;
 	/* config */
-	TCHECK2(*cp, 4);
-	printf("\n\t config 0x%08x", EXTRACT_32BITS(cp));
-	of10_bitmap_print(ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_32BITS(cp)));
+	of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
 	cp += 4;
 	/* mask */
-	TCHECK2(*cp, 4);
-	printf("\n\t mask 0x%08x", EXTRACT_32BITS(cp));
-	of10_bitmap_print(ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, "\n\t mask 0x%08x", EXTRACT_32BITS(cp)));
+	of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
 	cp += 4;
 	/* advertise */
-	TCHECK2(*cp, 4);
-	printf("\n\t advertise 0x%08x", EXTRACT_32BITS(cp));
-	of10_bitmap_print(ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, "\n\t advertise 0x%08x", EXTRACT_32BITS(cp)));
+	of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
 	cp += 4;
 	/* pad */
-	TCHECK2(*cp, 4);
+	ND_TCHECK2(*cp, 4);
 	return cp + 4;
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.3.5 */
 static const u_char *
-of10_stats_request_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_stats_request_print(netdissect_options *ndo,
+                         const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 	uint16_t type;
 
 	/* type */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	type = EXTRACT_16BITS(cp);
 	cp += 2;
-	printf("\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type));
+	ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
 	/* flags */
-	TCHECK2(*cp, 2);
-	printf(", flags 0x%04x", EXTRACT_16BITS(cp));
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
 	if (EXTRACT_16BITS(cp))
-		printf(" (bogus)");
+		ND_PRINT((ndo, " (bogus)"));
 	cp += 2;
 	/* type-specific body of one of fixed lengths */
 	len -= OF_STATS_REQUEST_LEN;
@@ -1286,105 +1773,109 @@
 		if (len != OF_FLOW_STATS_REQUEST_LEN)
 			goto corrupt;
 		/* match */
-		if (ep == (cp = of10_match_print("\n\t ", cp, ep)))
+		if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
 			return ep; /* end of snapshot */
 		/* table_id */
-		TCHECK2(*cp, 1);
-		printf("\n\t table_id %s", tok2str(tableid_str, "%u", *cp));
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
 		cp += 1;
 		/* pad */
-		TCHECK2(*cp, 1);
+		ND_TCHECK2(*cp, 1);
 		cp += 1;
 		/* out_port */
-		TCHECK2(*cp, 2);
-		printf(", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		return cp + 2;
 	case OFPST_PORT:
 		if (len != OF_PORT_STATS_REQUEST_LEN)
 			goto corrupt;
 		/* port_no */
-		TCHECK2(*cp, 2);
-		printf("\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		cp += 2;
 		/* pad */
-		TCHECK2(*cp, 6);
+		ND_TCHECK2(*cp, 6);
 		return cp + 6;
 	case OFPST_QUEUE:
 		if (len != OF_QUEUE_STATS_REQUEST_LEN)
 			goto corrupt;
 		/* port_no */
-		TCHECK2(*cp, 2);
-		printf("\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		cp += 2;
 		/* pad */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		cp += 2;
 		/* queue_id */
-		TCHECK2(*cp, 4);
-		printf(", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp)));
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
 		return cp + 4;
 	case OFPST_VENDOR:
-		return of10_vendor_data_print(cp, ep, len);
+		return of10_vendor_data_print(ndo, cp, ep, len);
 	}
 	return cp;
 
 corrupt: /* skip the message body */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_desc_stats_reply_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_desc_stats_reply_print(netdissect_options *ndo,
+                            const u_char *cp, const u_char *ep, const u_int len)
+{
 	if (len != OF_DESC_STATS_LEN)
 		goto corrupt;
 	/* mfr_desc */
-	TCHECK2(*cp, DESC_STR_LEN);
-	printf("\n\t  mfr_desc '");
-	fn_print(cp, cp + DESC_STR_LEN);
-	printf("'");
+	ND_TCHECK2(*cp, DESC_STR_LEN);
+	ND_PRINT((ndo, "\n\t  mfr_desc '"));
+	fn_print(ndo, cp, cp + DESC_STR_LEN);
+	ND_PRINT((ndo, "'"));
 	cp += DESC_STR_LEN;
 	/* hw_desc */
-	TCHECK2(*cp, DESC_STR_LEN);
-	printf("\n\t  hw_desc '");
-	fn_print(cp, cp + DESC_STR_LEN);
-	printf("'");
+	ND_TCHECK2(*cp, DESC_STR_LEN);
+	ND_PRINT((ndo, "\n\t  hw_desc '"));
+	fn_print(ndo, cp, cp + DESC_STR_LEN);
+	ND_PRINT((ndo, "'"));
 	cp += DESC_STR_LEN;
 	/* sw_desc */
-	TCHECK2(*cp, DESC_STR_LEN);
-	printf("\n\t  sw_desc '");
-	fn_print(cp, cp + DESC_STR_LEN);
-	printf("'");
+	ND_TCHECK2(*cp, DESC_STR_LEN);
+	ND_PRINT((ndo, "\n\t  sw_desc '"));
+	fn_print(ndo, cp, cp + DESC_STR_LEN);
+	ND_PRINT((ndo, "'"));
 	cp += DESC_STR_LEN;
 	/* serial_num */
-	TCHECK2(*cp, SERIAL_NUM_LEN);
-	printf("\n\t  serial_num '");
-	fn_print(cp, cp + SERIAL_NUM_LEN);
-	printf("'");
+	ND_TCHECK2(*cp, SERIAL_NUM_LEN);
+	ND_PRINT((ndo, "\n\t  serial_num '"));
+	fn_print(ndo, cp, cp + SERIAL_NUM_LEN);
+	ND_PRINT((ndo, "'"));
 	cp += SERIAL_NUM_LEN;
 	/* dp_desc */
-	TCHECK2(*cp, DESC_STR_LEN);
-	printf("\n\t  dp_desc '");
-	fn_print(cp, cp + DESC_STR_LEN);
-	printf("'");
+	ND_TCHECK2(*cp, DESC_STR_LEN);
+	ND_PRINT((ndo, "\n\t  dp_desc '"));
+	fn_print(ndo, cp, cp + DESC_STR_LEN);
+	ND_PRINT((ndo, "'"));
 	return cp + DESC_STR_LEN;
 
 corrupt: /* skip the message body */
-	printf(" (corrupt)");
-	TCHECK2(*cp, len);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, len);
 	return cp + len;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_flow_stats_reply_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_flow_stats_reply_print(netdissect_options *ndo,
+                            const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 	uint16_t entry_len;
@@ -1393,59 +1884,59 @@
 		if (len < OF_FLOW_STATS_LEN)
 			goto corrupt;
 		/* length */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		entry_len = EXTRACT_16BITS(cp);
-		printf("\n\t length %u", entry_len);
+		ND_PRINT((ndo, "\n\t length %u", entry_len));
 		if (entry_len < OF_FLOW_STATS_LEN || entry_len > len)
 			goto corrupt;
 		cp += 2;
 		/* table_id */
-		TCHECK2(*cp, 1);
-		printf(", table_id %s", tok2str(tableid_str, "%u", *cp));
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, ", table_id %s", tok2str(tableid_str, "%u", *cp)));
 		cp += 1;
 		/* pad */
-		TCHECK2(*cp, 1);
+		ND_TCHECK2(*cp, 1);
 		cp += 1;
 		/* match */
-		if (ep == (cp = of10_match_print("\n\t  ", cp, ep)))
+		if (ep == (cp = of10_match_print(ndo, "\n\t  ", cp, ep)))
 			return ep; /* end of snapshot */
 		/* duration_sec */
-		TCHECK2(*cp, 4);
-		printf("\n\t  duration_sec %u", EXTRACT_32BITS(cp));
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t  duration_sec %u", EXTRACT_32BITS(cp)));
 		cp += 4;
 		/* duration_nsec */
-		TCHECK2(*cp, 4);
-		printf(", duration_nsec %u", EXTRACT_32BITS(cp));
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
 		cp += 4;
 		/* priority */
-		TCHECK2(*cp, 2);
-		printf(", priority %u", EXTRACT_16BITS(cp));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
 		cp += 2;
 		/* idle_timeout */
-		TCHECK2(*cp, 2);
-		printf(", idle_timeout %u", EXTRACT_16BITS(cp));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
 		cp += 2;
 		/* hard_timeout */
-		TCHECK2(*cp, 2);
-		printf(", hard_timeout %u", EXTRACT_16BITS(cp));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
 		cp += 2;
 		/* pad2 */
-		TCHECK2(*cp, 6);
+		ND_TCHECK2(*cp, 6);
 		cp += 6;
 		/* cookie */
-		TCHECK2(*cp, 8);
-		printf(", cookie 0x%016" PRIx64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* packet_count */
-		TCHECK2(*cp, 8);
-		printf(", packet_count %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* byte_count */
-		TCHECK2(*cp, 8);
-		printf(", byte_count %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* actions */
-		if (ep == (cp = of10_actions_print("\n\t  ", cp, ep, entry_len - OF_FLOW_STATS_LEN)))
+		if (ep == (cp = of10_actions_print(ndo, "\n\t  ", cp, ep, entry_len - OF_FLOW_STATS_LEN)))
 			return ep; /* end of snapshot */
 
 		len -= entry_len;
@@ -1453,48 +1944,52 @@
 	return cp;
 
 corrupt: /* skip the rest of flow statistics entries */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_aggregate_stats_reply_print(const u_char *cp, const u_char *ep,
-                                 const u_int len) {
+of10_aggregate_stats_reply_print(netdissect_options *ndo,
+                                 const u_char *cp, const u_char *ep,
+                                 const u_int len)
+{
 	if (len != OF_AGGREGATE_STATS_REPLY_LEN)
 		goto corrupt;
 	/* packet_count */
-	TCHECK2(*cp, 8);
-	printf("\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp));
+	ND_TCHECK2(*cp, 8);
+	ND_PRINT((ndo, "\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp)));
 	cp += 8;
 	/* byte_count */
-	TCHECK2(*cp, 8);
-	printf(", byte_count %" PRIu64, EXTRACT_64BITS(cp));
+	ND_TCHECK2(*cp, 8);
+	ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
 	cp += 8;
 	/* flow_count */
-	TCHECK2(*cp, 4);
-	printf(", flow_count %u", EXTRACT_32BITS(cp));
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ", flow_count %u", EXTRACT_32BITS(cp)));
 	cp += 4;
 	/* pad */
-	TCHECK2(*cp, 4);
+	ND_TCHECK2(*cp, 4);
 	return cp + 4;
 
 corrupt: /* skip the message body */
-	printf(" (corrupt)");
-	TCHECK2(*cp, len);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, len);
 	return cp + len;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_table_stats_reply_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_table_stats_reply_print(netdissect_options *ndo,
+                             const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 
@@ -1502,38 +1997,38 @@
 		if (len < OF_TABLE_STATS_LEN)
 			goto corrupt;
 		/* table_id */
-		TCHECK2(*cp, 1);
-		printf("\n\t table_id %s", tok2str(tableid_str, "%u", *cp));
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
 		cp += 1;
 		/* pad */
-		TCHECK2(*cp, 3);
+		ND_TCHECK2(*cp, 3);
 		cp += 3;
 		/* name */
-		TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
-		printf(", name '");
-		fn_print(cp, cp + OFP_MAX_TABLE_NAME_LEN);
-		printf("'");
+		ND_TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
+		ND_PRINT((ndo, ", name '"));
+		fn_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
+		ND_PRINT((ndo, "'"));
 		cp += OFP_MAX_TABLE_NAME_LEN;
 		/* wildcards */
-		TCHECK2(*cp, 4);
-		printf("\n\t  wildcards 0x%08x", EXTRACT_32BITS(cp));
-		of10_bitmap_print(ofpfw_bm, EXTRACT_32BITS(cp), OFPFW_U);
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t  wildcards 0x%08x", EXTRACT_32BITS(cp)));
+		of10_bitmap_print(ndo, ofpfw_bm, EXTRACT_32BITS(cp), OFPFW_U);
 		cp += 4;
 		/* max_entries */
-		TCHECK2(*cp, 4);
-		printf("\n\t  max_entries %u", EXTRACT_32BITS(cp));
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, "\n\t  max_entries %u", EXTRACT_32BITS(cp)));
 		cp += 4;
 		/* active_count */
-		TCHECK2(*cp, 4);
-		printf(", active_count %u", EXTRACT_32BITS(cp));
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", active_count %u", EXTRACT_32BITS(cp)));
 		cp += 4;
 		/* lookup_count */
-		TCHECK2(*cp, 8);
-		printf(", lookup_count %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", lookup_count %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* matched_count */
-		TCHECK2(*cp, 8);
-		printf(", matched_count %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", matched_count %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 
 		len -= OF_TABLE_STATS_LEN;
@@ -1541,17 +2036,19 @@
 	return cp;
 
 corrupt: /* skip the undersized trailing data */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_port_stats_reply_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_port_stats_reply_print(netdissect_options *ndo,
+                            const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 
@@ -1559,64 +2056,64 @@
 		if (len < OF_PORT_STATS_LEN)
 			goto corrupt;
 		/* port_no */
-		TCHECK2(*cp, 2);
-		printf("\n\t  port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t  port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		cp += 2;
-		if (vflag < 2) {
-			TCHECK2(*cp, OF_PORT_STATS_LEN - 2);
+		if (ndo->ndo_vflag < 2) {
+			ND_TCHECK2(*cp, OF_PORT_STATS_LEN - 2);
 			cp += OF_PORT_STATS_LEN - 2;
 			goto next_port;
 		}
 		/* pad */
-		TCHECK2(*cp, 6);
+		ND_TCHECK2(*cp, 6);
 		cp += 6;
 		/* rx_packets */
-		TCHECK2(*cp, 8);
-		printf(", rx_packets %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", rx_packets %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* tx_packets */
-		TCHECK2(*cp, 8);
-		printf(", tx_packets %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* rx_bytes */
-		TCHECK2(*cp, 8);
-		printf(", rx_bytes %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", rx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* tx_bytes */
-		TCHECK2(*cp, 8);
-		printf(", tx_bytes %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* rx_dropped */
-		TCHECK2(*cp, 8);
-		printf(", rx_dropped %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", rx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* tx_dropped */
-		TCHECK2(*cp, 8);
-		printf(", tx_dropped %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", tx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* rx_errors */
-		TCHECK2(*cp, 8);
-		printf(", rx_errors %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", rx_errors %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* tx_errors */
-		TCHECK2(*cp, 8);
-		printf(", tx_errors %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* rx_frame_err */
-		TCHECK2(*cp, 8);
-		printf(", rx_frame_err %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", rx_frame_err %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* rx_over_err */
-		TCHECK2(*cp, 8);
-		printf(", rx_over_err %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", rx_over_err %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* rx_crc_err */
-		TCHECK2(*cp, 8);
-		printf(", rx_crc_err %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", rx_crc_err %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* collisions */
-		TCHECK2(*cp, 8);
-		printf(", collisions %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", collisions %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 next_port:
 		len -= OF_PORT_STATS_LEN;
@@ -1624,17 +2121,19 @@
 	return cp;
 
 corrupt: /* skip the undersized trailing data */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_queue_stats_reply_print(const u_char *cp, const u_char *ep, u_int len) {
+of10_queue_stats_reply_print(netdissect_options *ndo,
+                             const u_char *cp, const u_char *ep, u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 
@@ -1642,27 +2141,27 @@
 		if (len < OF_QUEUE_STATS_LEN)
 			goto corrupt;
 		/* port_no */
-		TCHECK2(*cp, 2);
-		printf("\n\t  port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t  port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		cp += 2;
 		/* pad */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		cp += 2;
 		/* queue_id */
-		TCHECK2(*cp, 4);
-		printf(", queue_id %u", EXTRACT_32BITS(cp));
+		ND_TCHECK2(*cp, 4);
+		ND_PRINT((ndo, ", queue_id %u", EXTRACT_32BITS(cp)));
 		cp += 4;
 		/* tx_bytes */
-		TCHECK2(*cp, 8);
-		printf(", tx_bytes %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* tx_packets */
-		TCHECK2(*cp, 8);
-		printf(", tx_packets %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 		/* tx_errors */
-		TCHECK2(*cp, 8);
-		printf(", tx_errors %" PRIu64, EXTRACT_64BITS(cp));
+		ND_TCHECK2(*cp, 8);
+		ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
 		cp += 8;
 
 		len -= OF_QUEUE_STATS_LEN;
@@ -1670,33 +2169,35 @@
 	return cp;
 
 corrupt: /* skip the undersized trailing data */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* ibid */
 static const u_char *
-of10_stats_reply_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_stats_reply_print(netdissect_options *ndo,
+                       const u_char *cp, const u_char *ep, const u_int len)
+{
 	const u_char *cp0 = cp;
 	uint16_t type;
 
 	/* type */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	type = EXTRACT_16BITS(cp);
-	printf("\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type));
+	ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
 	cp += 2;
 	/* flags */
-	TCHECK2(*cp, 2);
-	printf(", flags 0x%04x", EXTRACT_16BITS(cp));
-	of10_bitmap_print(ofpsf_reply_bm, EXTRACT_16BITS(cp), OFPSF_REPLY_U);
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+	of10_bitmap_print(ndo, ofpsf_reply_bm, EXTRACT_16BITS(cp), OFPSF_REPLY_U);
 	cp += 2;
 
-	if (vflag > 0) {
-		const u_char *(*decoder)(const u_char *, const u_char *, u_int) =
+	if (ndo->ndo_vflag > 0) {
+		const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, u_int) =
 			type == OFPST_DESC      ? of10_desc_stats_reply_print      :
 			type == OFPST_FLOW      ? of10_flow_stats_reply_print      :
 			type == OFPST_AGGREGATE ? of10_aggregate_stats_reply_print :
@@ -1706,148 +2207,156 @@
 			type == OFPST_VENDOR    ? of10_vendor_data_print           :
 			NULL;
 		if (decoder != NULL)
-			return decoder(cp, ep, len - OF_STATS_REPLY_LEN);
+			return decoder(ndo, cp, ep, len - OF_STATS_REPLY_LEN);
 	}
-	TCHECK2(*cp0, len);
+	ND_TCHECK2(*cp0, len);
 	return cp0 + len;
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.3.6 */
 static const u_char *
-of10_packet_out_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_packet_out_print(netdissect_options *ndo,
+                      const u_char *cp, const u_char *ep, const u_int len)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 	uint16_t actions_len;
 
 	/* buffer_id */
-	TCHECK2(*cp, 4);
-	printf("\n\t buffer_id 0x%08x", EXTRACT_32BITS(cp));
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, "\n\t buffer_id 0x%08x", EXTRACT_32BITS(cp)));
 	cp += 4;
 	/* in_port */
-	TCHECK2(*cp, 2);
-	printf(", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 	cp += 2;
 	/* actions_len */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	actions_len = EXTRACT_16BITS(cp);
 	cp += 2;
 	if (actions_len > len - OF_PACKET_OUT_LEN)
 		goto corrupt;
 	/* actions */
-	if (ep == (cp = of10_actions_print("\n\t ", cp, ep, actions_len)))
+	if (ep == (cp = of10_actions_print(ndo, "\n\t ", cp, ep, actions_len)))
 		return ep; /* end of snapshot */
 	/* data */
-	return of10_packet_data_print(cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
+	return of10_packet_data_print(ndo, cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
 
 corrupt: /* skip the rest of the message body */
-	printf(" (corrupt)");
-	TCHECK2(*cp0, len0);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp0, len0);
 	return cp0 + len0;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.4.1 */
 static const u_char *
-of10_packet_in_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_packet_in_print(netdissect_options *ndo,
+                     const u_char *cp, const u_char *ep, const u_int len)
+{
 	/* buffer_id */
-	TCHECK2(*cp, 4);
-	printf("\n\t buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp)));
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, "\n\t buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
 	cp += 4;
 	/* total_len */
-	TCHECK2(*cp, 2);
-	printf(", total_len %u", EXTRACT_16BITS(cp));
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", total_len %u", EXTRACT_16BITS(cp)));
 	cp += 2;
 	/* in_port */
-	TCHECK2(*cp, 2);
-	printf(", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 	cp += 2;
 	/* reason */
-	TCHECK2(*cp, 1);
-	printf(", reason %s", tok2str(ofpr_str, "invalid (0x%02x)", *cp));
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", reason %s", tok2str(ofpr_str, "invalid (0x%02x)", *cp)));
 	cp += 1;
 	/* pad */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	cp += 1;
 	/* data */
 	/* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
-	return of10_packet_data_print(cp, ep, len - (OF_PACKET_IN_LEN - 2));
+	return of10_packet_data_print(ndo, cp, ep, len - (OF_PACKET_IN_LEN - 2));
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.4.2 */
 static const u_char *
-of10_flow_removed_print(const u_char *cp, const u_char *ep) {
+of10_flow_removed_print(netdissect_options *ndo,
+                        const u_char *cp, const u_char *ep)
+{
 	/* match */
-	if (ep == (cp = of10_match_print("\n\t ", cp, ep)))
+	if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
 		return ep; /* end of snapshot */
 	/* cookie */
-	TCHECK2(*cp, 8);
-	printf("\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp));
+	ND_TCHECK2(*cp, 8);
+	ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
 	cp += 8;
 	/* priority */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (EXTRACT_16BITS(cp))
-		printf(", priority %u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
 	cp += 2;
 	/* reason */
-	TCHECK2(*cp, 1);
-	printf(", reason %s", tok2str(ofprr_str, "unknown (0x%02x)", *cp));
+	ND_TCHECK2(*cp, 1);
+	ND_PRINT((ndo, ", reason %s", tok2str(ofprr_str, "unknown (0x%02x)", *cp)));
 	cp += 1;
 	/* pad */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	cp += 1;
 	/* duration_sec */
-	TCHECK2(*cp, 4);
-	printf(", duration_sec %u", EXTRACT_32BITS(cp));
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ", duration_sec %u", EXTRACT_32BITS(cp)));
 	cp += 4;
 	/* duration_nsec */
-	TCHECK2(*cp, 4);
-	printf(", duration_nsec %u", EXTRACT_32BITS(cp));
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
 	cp += 4;
 	/* idle_timeout */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	if (EXTRACT_16BITS(cp))
-		printf(", idle_timeout %u", EXTRACT_16BITS(cp));
+		ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
 	cp += 2;
 	/* pad2 */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	cp += 2;
 	/* packet_count */
-	TCHECK2(*cp, 8);
-	printf(", packet_count %" PRIu64, EXTRACT_64BITS(cp));
+	ND_TCHECK2(*cp, 8);
+	ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
 	cp += 8;
 	/* byte_count */
-	TCHECK2(*cp, 8);
-	printf(", byte_count %" PRIu64, EXTRACT_64BITS(cp));
+	ND_TCHECK2(*cp, 8);
+	ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
 	return cp + 8;
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* [OF10] Section 5.4.4 */
 static const u_char *
-of10_error_print(const u_char *cp, const u_char *ep, const u_int len) {
+of10_error_print(netdissect_options *ndo,
+                 const u_char *cp, const u_char *ep, const u_int len)
+{
 	uint16_t type;
 	const struct tok *code_str;
 
 	/* type */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	type = EXTRACT_16BITS(cp);
 	cp += 2;
-	printf("\n\t type %s", tok2str(ofpet_str, "invalid (0x%04x)", type));
+	ND_PRINT((ndo, "\n\t type %s", tok2str(ofpet_str, "invalid (0x%04x)", type)));
 	/* code */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	code_str =
 		type == OFPET_HELLO_FAILED    ? ofphfc_str  :
 		type == OFPET_BAD_REQUEST     ? ofpbrc_str  :
@@ -1856,19 +2365,21 @@
 		type == OFPET_PORT_MOD_FAILED ? ofppmfc_str :
 		type == OFPET_QUEUE_OP_FAILED ? ofpqofc_str :
 		empty_str;
-	printf(", code %s", tok2str(code_str, "invalid (0x%04x)", EXTRACT_16BITS(cp)));
+	ND_PRINT((ndo, ", code %s", tok2str(code_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
 	cp += 2;
 	/* data */
-	return of10_data_print(cp, ep, len - OF_ERROR_MSG_LEN);
+	return of10_data_print(ndo, cp, ep, len - OF_ERROR_MSG_LEN);
 
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 const u_char *
-of10_header_body_print(const u_char *cp, const u_char *ep, const uint8_t type,
-                       const uint16_t len, const uint32_t xid) {
+of10_header_body_print(netdissect_options *ndo,
+                       const u_char *cp, const u_char *ep, const uint8_t type,
+                       const uint16_t len, const uint32_t xid)
+{
 	const u_char *cp0 = cp;
 	const u_int len0 = len;
 	/* Thus far message length is not less than the basic header size, but most
@@ -1879,8 +2390,8 @@
 	 * corrupt, proceed to the next message. */
 
 	/* [OF10] Section 5.1 */
-	printf("\n\tversion 1.0, type %s, length %u, xid 0x%08x",
-	       tok2str(ofpt_str, "invalid (0x%02x)", type), len, xid);
+	ND_PRINT((ndo, "\n\tversion 1.0, type %s, length %u, xid 0x%08x",
+	       tok2str(ofpt_str, "invalid (0x%02x)", type), len, xid));
 	switch (type) {
 	/* OpenFlow header only. */
 	case OFPT_FEATURES_REQUEST: /* [OF10] Section 5.3.1 */
@@ -1896,92 +2407,92 @@
 	case OFPT_GET_CONFIG_REPLY: /* ibid */
 		if (len != OF_SWITCH_CONFIG_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
 		/* flags */
-		TCHECK2(*cp, 2);
-		printf("\n\t flags %s", tok2str(ofp_config_str, "invalid (0x%04x)", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t flags %s", tok2str(ofp_config_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
 		cp += 2;
 		/* miss_send_len */
-		TCHECK2(*cp, 2);
-		printf(", miss_send_len %u", EXTRACT_16BITS(cp));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, ", miss_send_len %u", EXTRACT_16BITS(cp)));
 		return cp + 2;
 	case OFPT_PORT_MOD:
 		if (len != OF_PORT_MOD_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_port_mod_print(cp, ep);
+		return of10_port_mod_print(ndo, cp, ep);
 	case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.4 */
 		if (len != OF_QUEUE_GET_CONFIG_REQUEST_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
 		/* port */
-		TCHECK2(*cp, 2);
-		printf("\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		cp += 2;
 		/* pad */
-		TCHECK2(*cp, 2);
+		ND_TCHECK2(*cp, 2);
 		return cp + 2;
 	case OFPT_FLOW_REMOVED:
 		if (len != OF_FLOW_REMOVED_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_flow_removed_print(cp, ep);
+		return of10_flow_removed_print(ndo, cp, ep);
 	case OFPT_PORT_STATUS: /* [OF10] Section 5.4.3 */
 		if (len != OF_PORT_STATUS_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
 		/* reason */
-		TCHECK2(*cp, 1);
-		printf("\n\t reason %s", tok2str(ofppr_str, "invalid (0x%02x)", *cp));
+		ND_TCHECK2(*cp, 1);
+		ND_PRINT((ndo, "\n\t reason %s", tok2str(ofppr_str, "invalid (0x%02x)", *cp)));
 		cp += 1;
 		/* pad */
-		TCHECK2(*cp, 7);
+		ND_TCHECK2(*cp, 7);
 		cp += 7;
 		/* desc */
-		return of10_phy_ports_print(cp, ep, OF_PHY_PORT_LEN);
+		return of10_phy_ports_print(ndo, cp, ep, OF_PHY_PORT_LEN);
 
 	/* OpenFlow header, fixed-size message body and n * fixed-size data units. */
 	case OFPT_FEATURES_REPLY:
 		if (len < OF_SWITCH_FEATURES_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_features_reply_print(cp, ep, len);
+		return of10_features_reply_print(ndo, cp, ep, len);
 
 	/* OpenFlow header and variable-size data. */
 	case OFPT_HELLO: /* [OF10] Section 5.5.1 */
 	case OFPT_ECHO_REQUEST: /* [OF10] Section 5.5.2 */
 	case OFPT_ECHO_REPLY: /* [OF10] Section 5.5.3 */
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_data_print(cp, ep, len - OF_HEADER_LEN);
+		return of10_data_print(ndo, cp, ep, len - OF_HEADER_LEN);
 
 	/* OpenFlow header, fixed-size message body and variable-size data. */
 	case OFPT_ERROR:
 		if (len < OF_ERROR_MSG_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_error_print(cp, ep, len);
+		return of10_error_print(ndo, cp, ep, len);
 	case OFPT_VENDOR:
 	  /* [OF10] Section 5.5.4 */
 		if (len < OF_VENDOR_HEADER_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_vendor_data_print(cp, ep, len - OF_HEADER_LEN);
+		return of10_vendor_message_print(ndo, cp, ep, len - OF_HEADER_LEN);
 	case OFPT_PACKET_IN:
 		/* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
 		if (len < OF_PACKET_IN_LEN - 2)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_packet_in_print(cp, ep, len);
+		return of10_packet_in_print(ndo, cp, ep, len);
 
 	/* a. OpenFlow header. */
 	/* b. OpenFlow header and one of the fixed-size message bodies. */
@@ -1989,9 +2500,9 @@
 	case OFPT_STATS_REQUEST:
 		if (len < OF_STATS_REQUEST_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_stats_request_print(cp, ep, len);
+		return of10_stats_request_print(ndo, cp, ep, len);
 
 	/* a. OpenFlow header and fixed-size message body. */
 	/* b. OpenFlow header and n * fixed-size data units. */
@@ -2000,50 +2511,50 @@
 	case OFPT_STATS_REPLY:
 		if (len < OF_STATS_REPLY_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_stats_reply_print(cp, ep, len);
+		return of10_stats_reply_print(ndo, cp, ep, len);
 
 	/* OpenFlow header and n * variable-size data units and variable-size data. */
 	case OFPT_PACKET_OUT:
 		if (len < OF_PACKET_OUT_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_packet_out_print(cp, ep, len);
+		return of10_packet_out_print(ndo, cp, ep, len);
 
 	/* OpenFlow header, fixed-size message body and n * variable-size data units. */
 	case OFPT_FLOW_MOD:
 		if (len < OF_FLOW_MOD_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
-		return of10_flow_mod_print(cp, ep, len);
+		return of10_flow_mod_print(ndo, cp, ep, len);
 
 	/* OpenFlow header, fixed-size message body and n * variable-size data units. */
 	case OFPT_QUEUE_GET_CONFIG_REPLY: /* [OF10] Section 5.3.4 */
 		if (len < OF_QUEUE_GET_CONFIG_REPLY_LEN)
 			goto corrupt;
-		if (vflag < 1)
+		if (ndo->ndo_vflag < 1)
 			goto next_message;
 		/* port */
-		TCHECK2(*cp, 2);
-		printf("\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp)));
+		ND_TCHECK2(*cp, 2);
+		ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
 		cp += 2;
 		/* pad */
-		TCHECK2(*cp, 6);
+		ND_TCHECK2(*cp, 6);
 		cp += 6;
 		/* queues */
-		return of10_queues_print(cp, ep, len - OF_QUEUE_GET_CONFIG_REPLY_LEN);
+		return of10_queues_print(ndo, cp, ep, len - OF_QUEUE_GET_CONFIG_REPLY_LEN);
 	} /* switch (type) */
 	goto next_message;
 
 corrupt: /* skip the message body */
-	printf(" (corrupt)");
+	ND_PRINT((ndo, "%s", cstr));
 next_message:
-	TCHECK2(*cp0, len0 - OF_HEADER_LEN);
+	ND_TCHECK2(*cp0, len0 - OF_HEADER_LEN);
 	return cp0 + len0 - OF_HEADER_LEN;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
diff --git a/print-openflow.c b/print-openflow.c
index 5dbefac..8825ae3 100644
--- a/print-openflow.c
+++ b/print-openflow.c
@@ -30,6 +30,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -39,19 +40,44 @@
 #include "interface.h"
 #include "extract.h"
 #include "openflow.h"
+#include "oui.h"
+
+static const char tstr[] = " [|openflow]";
+static const char cstr[] = " (corrupt)";
 
 #define OF_VER_1_0    0x01
 
+const struct tok onf_exp_str[] = {
+	{ ONF_EXP_ONF,               "ONF Extensions"                                  },
+	{ ONF_EXP_BUTE,              "Budapest University of Technology and Economics" },
+	{ ONF_EXP_NOVIFLOW,          "NoviFlow"                                        },
+	{ ONF_EXP_L3,                "L3+ Extensions, Vendor Neutral"                  },
+	{ ONF_EXP_L4L7,              "L4-L7 Extensions"                                },
+	{ ONF_EXP_WMOB,              "Wireless and Mobility Extensions"                },
+	{ ONF_EXP_FABS,              "Forwarding Abstractions Extensions"              },
+	{ ONF_EXP_OTRANS,            "Optical Transport Extensions"                    },
+	{ 0, NULL }
+};
+
+const char *
+of_vendor_name(const uint32_t vendor)
+{
+	const struct tok *table = (vendor & 0xff000000) == 0 ? oui_values : onf_exp_str;
+	return tok2str(table, "unknown", vendor);
+}
+
 static void
-of_header_print(const uint8_t version, const uint8_t type,
-                      const uint16_t length, const uint32_t xid) {
-	printf("\n\tversion unknown (0x%02x), type 0x%02x, length %u, xid 0x%08x",
-	       version, type, length, xid);
+of_header_print(netdissect_options *ndo, const uint8_t version, const uint8_t type,
+                      const uint16_t length, const uint32_t xid)
+{
+	ND_PRINT((ndo, "\n\tversion unknown (0x%02x), type 0x%02x, length %u, xid 0x%08x",
+	       version, type, length, xid));
 }
 
 /* Print a single OpenFlow message. */
 static const u_char *
-of_header_body_print(const u_char *cp, const u_char *ep) {
+of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
 	uint8_t version, type;
 	uint16_t length;
 	uint32_t xid;
@@ -59,19 +85,19 @@
 	if (ep < cp + OF_HEADER_LEN)
 		goto corrupt;
 	/* version */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	version = *cp;
 	cp += 1;
 	/* type */
-	TCHECK2(*cp, 1);
+	ND_TCHECK2(*cp, 1);
 	type = *cp;
 	cp += 1;
 	/* length */
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	length = EXTRACT_16BITS(cp);
 	cp += 2;
 	/* xid */
-	TCHECK2(*cp, 4);
+	ND_TCHECK2(*cp, 4);
 	xid = EXTRACT_32BITS(cp);
 	cp += 4;
 	/* Message length includes the header length and a message always includes
@@ -80,36 +106,37 @@
 	 * message as possible even when it does not end within the current TCP
 	 * segment. */
 	if (length < OF_HEADER_LEN) {
-		of_header_print(version, type, length, xid);
+		of_header_print(ndo, version, type, length, xid);
 		goto corrupt;
 	}
 	/* Decode known protocol versions further without printing the header (the
 	 * type decoding is version-specific. */
 	switch (version) {
 	case OF_VER_1_0:
-		return of10_header_body_print(cp, ep, type, length, xid);
+		return of10_header_body_print(ndo, cp, ep, type, length, xid);
 	default:
-		of_header_print(version, type, length, xid);
-		TCHECK2(*cp, length - OF_HEADER_LEN);
+		of_header_print(ndo, version, type, length, xid);
+		ND_TCHECK2(*cp, length - OF_HEADER_LEN);
 		return cp + length - OF_HEADER_LEN; /* done with current message */
 	}
 
 corrupt: /* fail current packet */
-	printf(" (corrupt)");
-	TCHECK2(*cp, ep - cp);
+	ND_PRINT((ndo, "%s", cstr));
+	ND_TCHECK2(*cp, ep - cp);
 	return ep;
 trunc:
-	printf(" [|openflow]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 /* Print a TCP segment worth of OpenFlow messages presuming the segment begins
  * on a message boundary. */
 void
-openflow_print(const u_char *cp, const u_int len) {
+openflow_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
 	const u_char *ep = cp + len;
 
-	printf(": OpenFlow");
+	ND_PRINT((ndo, ": OpenFlow"));
 	while (cp < ep)
-		cp = of_header_body_print(cp, ep);
+		cp = of_header_body_print(ndo, cp, ep);
 }
diff --git a/print-ospf.c b/print-ospf.c
index 9533cb6..3583417 100644
--- a/print-ospf.c
+++ b/print-ospf.c
@@ -21,19 +21,13 @@
  * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.66 2007-10-08 07:53:21 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -41,7 +35,7 @@
 
 #include "ospf.h"
 
-#include "ip.h"
+static const char tstr[] = " [|ospf2]";
 
 static const struct tok ospf_option_values[] = {
         { OSPF_OPTION_T,	"MultiTopology" }, /* draft-ietf-ospf-mt-09 */
@@ -185,38 +179,32 @@
 	{ 0,	NULL }
 };
 
-static char tstr[] = " [|ospf2]";
-
-static int ospf_print_lshdr(const struct lsa_hdr *);
-static const u_char *ospf_print_lsa(const struct lsa *);
-static int ospf_decode_v2(const struct ospfhdr *, const u_char *);
-static int ospf_decode_lls(const struct ospfhdr *, register u_int);
-
 int
-ospf_print_grace_lsa (const u_int8_t *tptr, u_int ls_length) {
-
+ospf_print_grace_lsa(netdissect_options *ndo,
+                     const uint8_t *tptr, u_int ls_length)
+{
     u_int tlv_type, tlv_length;
 
 
     while (ls_length > 0) {
-        TCHECK2(*tptr, 4);
+        ND_TCHECK2(*tptr, 4);
         if (ls_length < 4) {
-            printf("\n\t    Remaining LS length %u < 4", ls_length);
+            ND_PRINT((ndo, "\n\t    Remaining LS length %u < 4", ls_length));
             return -1;
         }
         tlv_type = EXTRACT_16BITS(tptr);
         tlv_length = EXTRACT_16BITS(tptr+2);
         tptr+=4;
         ls_length-=4;
-                    
-        printf("\n\t    %s TLV (%u), length %u, value: ",
+
+        ND_PRINT((ndo, "\n\t    %s TLV (%u), length %u, value: ",
                tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type),
                tlv_type,
-               tlv_length);
+               tlv_length));
 
         if (tlv_length > ls_length) {
-            printf("\n\t    Bogus length %u > %u", tlv_length,
-                   ls_length);
+            ND_PRINT((ndo, "\n\t    Bogus length %u > %u", tlv_length,
+                   ls_length));
             return -1;
         }
 
@@ -225,38 +213,38 @@
             return -1;
         }
 
-        TCHECK2(*tptr, tlv_length);
+        ND_TCHECK2(*tptr, tlv_length);
         switch(tlv_type) {
 
         case LS_OPAQUE_GRACE_TLV_PERIOD:
             if (tlv_length != 4) {
-                printf("\n\t    Bogus length %u != 4", tlv_length);
+                ND_PRINT((ndo, "\n\t    Bogus length %u != 4", tlv_length));
                 return -1;
             }
-            printf("%us",EXTRACT_32BITS(tptr));
+            ND_PRINT((ndo, "%us", EXTRACT_32BITS(tptr)));
             break;
 
         case LS_OPAQUE_GRACE_TLV_REASON:
             if (tlv_length != 1) {
-                printf("\n\t    Bogus length %u != 1", tlv_length);
+                ND_PRINT((ndo, "\n\t    Bogus length %u != 1", tlv_length));
                 return -1;
             }
-            printf("%s (%u)",
+            ND_PRINT((ndo, "%s (%u)",
                    tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", *tptr),
-                   *tptr);
+                   *tptr));
             break;
 
         case LS_OPAQUE_GRACE_TLV_INT_ADDRESS:
             if (tlv_length != 4) {
-                printf("\n\t    Bogus length %u != 4", tlv_length);
+                ND_PRINT((ndo, "\n\t    Bogus length %u != 4", tlv_length));
                 return -1;
             }
-            printf("%s", ipaddr_string(tptr));
+            ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
             break;
 
         default:
-            if (vflag <= 1) {
-                if(!print_unknown_data(tptr,"\n\t      ",tlv_length))
+            if (ndo->ndo_vflag <= 1) {
+                if (!print_unknown_data(ndo, tptr, "\n\t      ", tlv_length))
                     return -1;
             }
             break;
@@ -275,34 +263,35 @@
 }
 
 int
-ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
-
+ospf_print_te_lsa(netdissect_options *ndo,
+                  const uint8_t *tptr, u_int ls_length)
+{
     u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
     u_int priority_level, te_class, count_srlg;
     union { /* int to float conversion buffer for several subTLVs */
-        float f; 
-        u_int32_t i;
+        float f;
+        uint32_t i;
     } bw;
 
     while (ls_length != 0) {
-        TCHECK2(*tptr, 4);
+        ND_TCHECK2(*tptr, 4);
         if (ls_length < 4) {
-            printf("\n\t    Remaining LS length %u < 4", ls_length);
+            ND_PRINT((ndo, "\n\t    Remaining LS length %u < 4", ls_length));
             return -1;
         }
         tlv_type = EXTRACT_16BITS(tptr);
         tlv_length = EXTRACT_16BITS(tptr+2);
         tptr+=4;
         ls_length-=4;
-                    
-        printf("\n\t    %s TLV (%u), length: %u",
+
+        ND_PRINT((ndo, "\n\t    %s TLV (%u), length: %u",
                tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type),
                tlv_type,
-               tlv_length);
+               tlv_length));
 
         if (tlv_length > ls_length) {
-            printf("\n\t    Bogus length %u > %u", tlv_length,
-                   ls_length);
+            ND_PRINT((ndo, "\n\t    Bogus length %u > %u", tlv_length,
+                   ls_length));
             return -1;
         }
 
@@ -315,108 +304,108 @@
         case LS_OPAQUE_TE_TLV_LINK:
             while (tlv_length >= sizeof(subtlv_type) + sizeof(subtlv_length)) {
                 if (tlv_length < 4) {
-                    printf("\n\t    Remaining TLV length %u < 4",
-                           tlv_length);
+                    ND_PRINT((ndo, "\n\t    Remaining TLV length %u < 4",
+                           tlv_length));
                     return -1;
                 }
-                TCHECK2(*tptr, 4);
+                ND_TCHECK2(*tptr, 4);
                 subtlv_type = EXTRACT_16BITS(tptr);
                 subtlv_length = EXTRACT_16BITS(tptr+2);
                 tptr+=4;
                 tlv_length-=4;
-                            
-                printf("\n\t      %s subTLV (%u), length: %u",
+
+                ND_PRINT((ndo, "\n\t      %s subTLV (%u), length: %u",
                        tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type),
                        subtlv_type,
-                       subtlv_length);
-                            
-                TCHECK2(*tptr, subtlv_length);
+                       subtlv_length));
+
+                ND_TCHECK2(*tptr, subtlv_length);
                 switch(subtlv_type) {
                 case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
-                    printf(", 0x%08x", EXTRACT_32BITS(tptr));
+                    ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID:
                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID:
-                    printf(", %s (0x%08x)",
-                           ipaddr_string(tptr),
-                           EXTRACT_32BITS(tptr));
+                    ND_PRINT((ndo, ", %s (0x%08x)",
+                           ipaddr_string(ndo, tptr),
+                           EXTRACT_32BITS(tptr)));
                     if (subtlv_length == 8) /* rfc4203 */
-                        printf(", %s (0x%08x)",
-                               ipaddr_string(tptr+4),
-                               EXTRACT_32BITS(tptr+4));
+                        ND_PRINT((ndo, ", %s (0x%08x)",
+                               ipaddr_string(ndo, tptr+4),
+                               EXTRACT_32BITS(tptr + 4)));
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP:
                 case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP:
-                    printf(", %s", ipaddr_string(tptr));
+                    ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW:
                 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW:
                     bw.i = EXTRACT_32BITS(tptr);
-                    printf(", %.3f Mbps", bw.f*8/1000000 );
+                    ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW:
                     for (te_class = 0; te_class < 8; te_class++) {
                         bw.i = EXTRACT_32BITS(tptr+te_class*4);
-                        printf("\n\t\tTE-Class %u: %.3f Mbps",
+                        ND_PRINT((ndo, "\n\t\tTE-Class %u: %.3f Mbps",
                                te_class,
-                               bw.f*8/1000000 );
+                               bw.f * 8 / 1000000));
                     }
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
-                    printf("\n\t\tBandwidth Constraints Model ID: %s (%u)",
+                    ND_PRINT((ndo, "\n\t\tBandwidth Constraints Model ID: %s (%u)",
                            tok2str(diffserv_te_bc_values, "unknown", *tptr),
-                           *tptr);
+                           *tptr));
                     /* decode BCs until the subTLV ends */
                     for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) {
                         bw.i = EXTRACT_32BITS(tptr+4+te_class*4);
-                        printf("\n\t\t  Bandwidth constraint CT%u: %.3f Mbps",
+                        ND_PRINT((ndo, "\n\t\t  Bandwidth constraint CT%u: %.3f Mbps",
                                te_class,
-                               bw.f*8/1000000 );
+                               bw.f * 8 / 1000000));
                     }
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
-                    printf(", Metric %u", EXTRACT_32BITS(tptr));
+                    ND_PRINT((ndo, ", Metric %u", EXTRACT_32BITS(tptr)));
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE:
-                    printf(", %s, Priority %u",
+                    ND_PRINT((ndo, ", %s, Priority %u",
                            bittok2str(gmpls_link_prot_values, "none", *tptr),
-                           *(tptr+1));
+                           *(tptr + 1)));
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR:
-                    printf("\n\t\tInterface Switching Capability: %s",
-                           tok2str(gmpls_switch_cap_values, "Unknown", *(tptr)));
-                    printf("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
-                           tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
+                    ND_PRINT((ndo, "\n\t\tInterface Switching Capability: %s",
+                           tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))));
+                    ND_PRINT((ndo, "\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
+                           tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
                     for (priority_level = 0; priority_level < 8; priority_level++) {
                         bw.i = EXTRACT_32BITS(tptr+4+(priority_level*4));
-                        printf("\n\t\t  priority level %d: %.3f Mbps",
+                        ND_PRINT((ndo, "\n\t\t  priority level %d: %.3f Mbps",
                                priority_level,
-                               bw.f*8/1000000 );
+                               bw.f * 8 / 1000000));
                     }
                     break;
                 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
-                    printf(", %s (%u)",
+                    ND_PRINT((ndo, ", %s (%u)",
                            tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr),
-                           *tptr);
+                           *tptr));
                     break;
 
                 case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP:
                     count_srlg = subtlv_length / 4;
                     if (count_srlg != 0)
-                        printf("\n\t\t  Shared risk group: ");
+                        ND_PRINT((ndo, "\n\t\t  Shared risk group: "));
                     while (count_srlg > 0) {
                         bw.i = EXTRACT_32BITS(tptr);
-                        printf("%d",bw.i);
+                        ND_PRINT((ndo, "%d", bw.i));
                         tptr+=4;
                         count_srlg--;
                         if (count_srlg > 0)
-                            printf(", ");
+                            ND_PRINT((ndo, ", "));
                     }
                     break;
 
                 default:
-                    if (vflag <= 1) {
-                        if(!print_unknown_data(tptr,"\n\t\t",subtlv_length))
+                    if (ndo->ndo_vflag <= 1) {
+                        if (!print_unknown_data(ndo, tptr, "\n\t\t", subtlv_length))
                             return -1;
                     }
                     break;
@@ -424,25 +413,25 @@
                 /* in OSPF everything has to be 32-bit aligned, including subTLVs */
                 if (subtlv_length%4 != 0)
                     subtlv_length+=4-(subtlv_length%4);
-                            
+
                 tlv_length-=subtlv_length;
                 tptr+=subtlv_length;
-                            
+
             }
             break;
-                        
+
         case LS_OPAQUE_TE_TLV_ROUTER:
             if (tlv_length < 4) {
-                printf("\n\t    TLV length %u < 4", tlv_length);
+                ND_PRINT((ndo, "\n\t    TLV length %u < 4", tlv_length));
                 return -1;
             }
-            TCHECK2(*tptr, 4);
-            printf(", %s", ipaddr_string(tptr));
+            ND_TCHECK2(*tptr, 4);
+            ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
             break;
-                        
+
         default:
-            if (vflag <= 1) {
-                if(!print_unknown_data(tptr,"\n\t      ",tlv_length))
+            if (ndo->ndo_vflag <= 1) {
+                if (!print_unknown_data(ndo, tptr, "\n\t      ", tlv_length))
                     return -1;
             }
             break;
@@ -458,34 +447,34 @@
     return -1;
 }
 
-
 static int
-ospf_print_lshdr(register const struct lsa_hdr *lshp)
+ospf_print_lshdr(netdissect_options *ndo,
+                 register const struct lsa_hdr *lshp)
 {
         u_int ls_length;
 
-        TCHECK(lshp->ls_length);
+        ND_TCHECK(lshp->ls_length);
         ls_length = EXTRACT_16BITS(&lshp->ls_length);
         if (ls_length < sizeof(struct lsa_hdr)) {
-                printf("\n\t    Bogus length %u < header (%lu)", ls_length,
-                    (unsigned long)sizeof(struct lsa_hdr));
+                ND_PRINT((ndo, "\n\t    Bogus length %u < header (%lu)", ls_length,
+                    (unsigned long)sizeof(struct lsa_hdr)));
                 return(-1);
         }
 
-        TCHECK(lshp->ls_seq);	/* XXX - ls_length check checked this */
-	printf("\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
-	       ipaddr_string(&lshp->ls_router),
-	       EXTRACT_32BITS(&lshp->ls_seq),
-	       EXTRACT_16BITS(&lshp->ls_age),
-               ls_length-(u_int)sizeof(struct lsa_hdr));
+        ND_TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
+        ND_PRINT((ndo, "\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
+                  ipaddr_string(ndo, &lshp->ls_router),
+                  EXTRACT_32BITS(&lshp->ls_seq),
+                  EXTRACT_16BITS(&lshp->ls_age),
+                  ls_length - (u_int)sizeof(struct lsa_hdr)));
 
-	TCHECK(lshp->ls_type);	/* XXX - ls_length check checked this */
+        ND_TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
         switch (lshp->ls_type) {
-	/* the LSA header for opaque LSAs was slightly changed */
+        /* the LSA header for opaque LSAs was slightly changed */
         case LS_TYPE_OPAQUE_LL:
         case LS_TYPE_OPAQUE_AL:
         case LS_TYPE_OPAQUE_DW:
-            printf("\n\t    %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
+            ND_PRINT((ndo, "\n\t    %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
                    tok2str(lsa_values,"unknown",lshp->ls_type),
                    lshp->ls_type,
 
@@ -494,21 +483,21 @@
 			   *(&lshp->un_lsa_id.opaque_field.opaque_type)),
 		   *(&lshp->un_lsa_id.opaque_field.opaque_type),
 		   EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id)
-                   
-                   );
+
+                   ));
             break;
 
-	/* all other LSA types use regular style LSA headers */
-	default:
-            printf("\n\t    %s LSA (%d), LSA-ID: %s",
+        /* all other LSA types use regular style LSA headers */
+        default:
+            ND_PRINT((ndo, "\n\t    %s LSA (%d), LSA-ID: %s",
                    tok2str(lsa_values,"unknown",lshp->ls_type),
                    lshp->ls_type,
-                   ipaddr_string(&lshp->un_lsa_id.lsa_id));
+                   ipaddr_string(ndo, &lshp->un_lsa_id.lsa_id)));
             break;
         }
 
-	TCHECK(lshp->ls_options);	/* XXX - ls_length check checked this */
-        printf("\n\t    Options: [%s]", bittok2str(ospf_option_values,"none",lshp->ls_options));
+        ND_TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
+        ND_PRINT((ndo, "\n\t    Options: [%s]", bittok2str(ospf_option_values, "none", lshp->ls_options)));
 
         return (ls_length);
 trunc:
@@ -527,7 +516,8 @@
  * Print all the per-topology metrics.
  */
 static void
-ospf_print_tos_metrics(const union un_tos *tos)
+ospf_print_tos_metrics(netdissect_options *ndo,
+                       const union un_tos *tos)
 {
     int metric_count;
     int toscount;
@@ -538,12 +528,12 @@
     /*
      * All but the first metric contain a valid topology id.
      */
-    while (toscount) { 
-        printf("\n\t\ttopology %s(%u), metric %u",
+    while (toscount) {
+        ND_PRINT((ndo, "\n\t\ttopology %s(%u), metric %u",
                tok2str(ospf_topology_values, "",
                        metric_count ? tos->metrics.tos_type : 0),
                metric_count ? tos->metrics.tos_type : 0,
-               EXTRACT_16BITS(&tos->metrics.tos_metric));
+               EXTRACT_16BITS(&tos->metrics.tos_metric)));
         metric_count++;
         tos++;
         toscount--;
@@ -555,71 +545,73 @@
  * field is less than the length of the LSA header, return NULl, else
  * return pointer to data past end of LSA.
  */
-static const u_int8_t *
-ospf_print_lsa(register const struct lsa *lsap)
+static const uint8_t *
+ospf_print_lsa(netdissect_options *ndo,
+               register const struct lsa *lsap)
 {
-	register const u_int8_t *ls_end;
+	register const uint8_t *ls_end;
 	register const struct rlalink *rlp;
 	register const struct in_addr *ap;
 	register const struct aslametric *almp;
 	register const struct mcla *mcp;
-	register const u_int32_t *lp;
+	register const uint32_t *lp;
 	register int j, tlv_type, tlv_length, topology;
 	register int ls_length;
-	const u_int8_t *tptr;
+	const uint8_t *tptr;
 
-	tptr = (u_int8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
-        ls_length = ospf_print_lshdr(&lsap->ls_hdr);
+	tptr = (uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
+        ls_length = ospf_print_lshdr(ndo, &lsap->ls_hdr);
         if (ls_length == -1)
                 return(NULL);
-	ls_end = (u_int8_t *)lsap + ls_length;
+	ls_end = (uint8_t *)lsap + ls_length;
 	ls_length -= sizeof(struct lsa_hdr);
 
 	switch (lsap->ls_hdr.ls_type) {
 
 	case LS_TYPE_ROUTER:
-		TCHECK(lsap->lsa_un.un_rla.rla_flags);
-                printf("\n\t    Router LSA Options: [%s]", bittok2str(ospf_rla_flag_values,"none",lsap->lsa_un.un_rla.rla_flags));
+		ND_TCHECK(lsap->lsa_un.un_rla.rla_flags);
+		ND_PRINT((ndo, "\n\t    Router LSA Options: [%s]",
+		          bittok2str(ospf_rla_flag_values, "none", lsap->lsa_un.un_rla.rla_flags)));
 
-		TCHECK(lsap->lsa_un.un_rla.rla_count);
+		ND_TCHECK(lsap->lsa_un.un_rla.rla_count);
 		j = EXTRACT_16BITS(&lsap->lsa_un.un_rla.rla_count);
-		TCHECK(lsap->lsa_un.un_rla.rla_link);
+		ND_TCHECK(lsap->lsa_un.un_rla.rla_link);
 		rlp = lsap->lsa_un.un_rla.rla_link;
 		while (j--) {
-			TCHECK(*rlp);
+			ND_TCHECK(*rlp);
 			switch (rlp->un_tos.link.link_type) {
 
 			case RLA_TYPE_VIRTUAL:
-				printf("\n\t      Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
-				    ipaddr_string(&rlp->link_id),
-				    ipaddr_string(&rlp->link_data)); 
-                                break;
+				ND_PRINT((ndo, "\n\t      Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
+				    ipaddr_string(ndo, &rlp->link_id),
+				    ipaddr_string(ndo, &rlp->link_data)));
+				break;
 
 			case RLA_TYPE_ROUTER:
-				printf("\n\t      Neighbor Router-ID: %s, Interface Address: %s",
-				    ipaddr_string(&rlp->link_id),
-				    ipaddr_string(&rlp->link_data));
+				ND_PRINT((ndo, "\n\t      Neighbor Router-ID: %s, Interface Address: %s",
+				    ipaddr_string(ndo, &rlp->link_id),
+				    ipaddr_string(ndo, &rlp->link_data)));
 				break;
 
 			case RLA_TYPE_TRANSIT:
-				printf("\n\t      Neighbor Network-ID: %s, Interface Address: %s",
-				    ipaddr_string(&rlp->link_id),
-				    ipaddr_string(&rlp->link_data));
+				ND_PRINT((ndo, "\n\t      Neighbor Network-ID: %s, Interface Address: %s",
+				    ipaddr_string(ndo, &rlp->link_id),
+				    ipaddr_string(ndo, &rlp->link_data)));
 				break;
 
 			case RLA_TYPE_STUB:
-				printf("\n\t      Stub Network: %s, Mask: %s",
-				    ipaddr_string(&rlp->link_id),
-				    ipaddr_string(&rlp->link_data));
+				ND_PRINT((ndo, "\n\t      Stub Network: %s, Mask: %s",
+				    ipaddr_string(ndo, &rlp->link_id),
+				    ipaddr_string(ndo, &rlp->link_data)));
 				break;
 
 			default:
-				printf("\n\t      Unknown Router Link Type (%u)",
-				    rlp->un_tos.link.link_type);
+				ND_PRINT((ndo, "\n\t      Unknown Router Link Type (%u)",
+				    rlp->un_tos.link.link_type));
 				return (ls_end);
 			}
 
-                        ospf_print_tos_metrics(&rlp->un_tos);
+			ospf_print_tos_metrics(ndo, &rlp->un_tos);
 
 			rlp = (struct rlalink *)((u_char *)(rlp + 1) +
 			    ((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
@@ -627,86 +619,84 @@
 		break;
 
 	case LS_TYPE_NETWORK:
-		TCHECK(lsap->lsa_un.un_nla.nla_mask);
-		printf("\n\t    Mask %s\n\t    Connected Routers:",
-		    ipaddr_string(&lsap->lsa_un.un_nla.nla_mask));
+		ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+		ND_PRINT((ndo, "\n\t    Mask %s\n\t    Connected Routers:",
+		    ipaddr_string(ndo, &lsap->lsa_un.un_nla.nla_mask)));
 		ap = lsap->lsa_un.un_nla.nla_router;
 		while ((u_char *)ap < ls_end) {
-			TCHECK(*ap);
-			printf("\n\t      %s", ipaddr_string(ap));
+			ND_TCHECK(*ap);
+			ND_PRINT((ndo, "\n\t      %s", ipaddr_string(ndo, ap)));
 			++ap;
 		}
 		break;
 
 	case LS_TYPE_SUM_IP:
-		TCHECK(lsap->lsa_un.un_nla.nla_mask);
-		printf("\n\t    Mask %s",
-		    ipaddr_string(&lsap->lsa_un.un_sla.sla_mask));
-		TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+		ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+		ND_PRINT((ndo, "\n\t    Mask %s",
+		    ipaddr_string(ndo, &lsap->lsa_un.un_sla.sla_mask)));
+		ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
 		lp = lsap->lsa_un.un_sla.sla_tosmetric;
 		while ((u_char *)lp < ls_end) {
-			register u_int32_t ul;
+			register uint32_t ul;
 
-			TCHECK(*lp);
+			ND_TCHECK(*lp);
 			ul = EXTRACT_32BITS(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
-			printf("\n\t\ttopology %s(%u) metric %d",
+			ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d",
                                tok2str(ospf_topology_values, "", topology),
                                topology,
-                               ul & SLA_MASK_METRIC);
+                               ul & SLA_MASK_METRIC));
 			++lp;
 		}
 		break;
 
 	case LS_TYPE_SUM_ABR:
-		TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+		ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
 		lp = lsap->lsa_un.un_sla.sla_tosmetric;
 		while ((u_char *)lp < ls_end) {
-			register u_int32_t ul;
+			register uint32_t ul;
 
-			TCHECK(*lp);
+			ND_TCHECK(*lp);
 			ul = EXTRACT_32BITS(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
-			printf("\n\t\ttopology %s(%u) metric %d",
+			ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d",
                                tok2str(ospf_topology_values, "", topology),
                                topology,
-                               ul & SLA_MASK_METRIC);
+                               ul & SLA_MASK_METRIC));
 			++lp;
 		}
 		break;
 
 	case LS_TYPE_ASE:
         case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */
-		TCHECK(lsap->lsa_un.un_nla.nla_mask);
-		printf("\n\t    Mask %s",
-		    ipaddr_string(&lsap->lsa_un.un_asla.asla_mask));
+		ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+		ND_PRINT((ndo, "\n\t    Mask %s",
+		    ipaddr_string(ndo, &lsap->lsa_un.un_asla.asla_mask)));
 
-		TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+		ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
 		almp = lsap->lsa_un.un_asla.asla_metric;
 		while ((u_char *)almp < ls_end) {
-			register u_int32_t ul;
+			register uint32_t ul;
 
-			TCHECK(almp->asla_tosmetric);
+			ND_TCHECK(almp->asla_tosmetric);
 			ul = EXTRACT_32BITS(&almp->asla_tosmetric);
                         topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
-			printf("\n\t\ttopology %s(%u), type %d, metric",
+			ND_PRINT((ndo, "\n\t\ttopology %s(%u), type %d, metric",
                                tok2str(ospf_topology_values, "", topology),
                                topology,
-                               (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1);
-                        if ((ul & ASLA_MASK_METRIC)==0xffffff)
-                            printf(" infinite");
-                        else
-                            printf(" %d", (ul & ASLA_MASK_METRIC));
+                               (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1));
+			if ((ul & ASLA_MASK_METRIC) == 0xffffff)
+				ND_PRINT((ndo, " infinite"));
+			else
+				ND_PRINT((ndo, " %d", (ul & ASLA_MASK_METRIC)));
 
-			TCHECK(almp->asla_forward);
+			ND_TCHECK(almp->asla_forward);
 			if (almp->asla_forward.s_addr) {
-				printf(", forward %s",
-				    ipaddr_string(&almp->asla_forward));
+				ND_PRINT((ndo, ", forward %s", ipaddr_string(ndo, &almp->asla_forward)));
 			}
-			TCHECK(almp->asla_tag);
+			ND_TCHECK(almp->asla_tag);
 			if (almp->asla_tag.s_addr) {
-				printf(", tag %s",
-				    ipaddr_string(&almp->asla_tag));
+				ND_PRINT((ndo, ", tag %s", ipaddr_string(ndo, &almp->asla_tag)));
 			}
 			++almp;
 		}
@@ -716,22 +706,22 @@
 		/* Multicast extensions as of 23 July 1991 */
 		mcp = lsap->lsa_un.un_mcla;
 		while ((u_char *)mcp < ls_end) {
-			TCHECK(mcp->mcla_vid);
+			ND_TCHECK(mcp->mcla_vid);
 			switch (EXTRACT_32BITS(&mcp->mcla_vtype)) {
 
 			case MCLA_VERTEX_ROUTER:
-				printf("\n\t    Router Router-ID %s",
-				    ipaddr_string(&mcp->mcla_vid));
+				ND_PRINT((ndo, "\n\t    Router Router-ID %s",
+				    ipaddr_string(ndo, &mcp->mcla_vid)));
 				break;
 
 			case MCLA_VERTEX_NETWORK:
-				printf("\n\t    Network Designated Router %s",
-				    ipaddr_string(&mcp->mcla_vid));
+				ND_PRINT((ndo, "\n\t    Network Designated Router %s",
+				    ipaddr_string(ndo, &mcp->mcla_vid)));
 				break;
 
 			default:
-				printf("\n\t    unknown VertexType (%u)",
-				    EXTRACT_32BITS(&mcp->mcla_vtype));
+				ND_PRINT((ndo, "\n\t    unknown VertexType (%u)",
+				    EXTRACT_32BITS(&mcp->mcla_vtype)));
 				break;
 			}
 		++mcp;
@@ -739,48 +729,48 @@
 		break;
 
 	case LS_TYPE_OPAQUE_LL: /* fall through */
-	case LS_TYPE_OPAQUE_AL: 
+	case LS_TYPE_OPAQUE_AL:
 	case LS_TYPE_OPAQUE_DW:
 
 	    switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
             case LS_OPAQUE_TYPE_RI:
-		tptr = (u_int8_t *)(&lsap->lsa_un.un_ri_tlv.type);
+		tptr = (uint8_t *)(&lsap->lsa_un.un_ri_tlv.type);
 
 		while (ls_length != 0) {
-                    TCHECK2(*tptr, 4);
+                    ND_TCHECK2(*tptr, 4);
 		    if (ls_length < 4) {
-                        printf("\n\t    Remaining LS length %u < 4", ls_length);
+                        ND_PRINT((ndo, "\n\t    Remaining LS length %u < 4", ls_length));
                         return(ls_end);
                     }
                     tlv_type = EXTRACT_16BITS(tptr);
                     tlv_length = EXTRACT_16BITS(tptr+2);
                     tptr+=4;
                     ls_length-=4;
-                    
-                    printf("\n\t    %s TLV (%u), length: %u, value: ",
+
+                    ND_PRINT((ndo, "\n\t    %s TLV (%u), length: %u, value: ",
                            tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
                            tlv_type,
-                           tlv_length);
+                           tlv_length));
 
                     if (tlv_length > ls_length) {
-                        printf("\n\t    Bogus length %u > %u", tlv_length,
-                            ls_length);
+                        ND_PRINT((ndo, "\n\t    Bogus length %u > %u", tlv_length,
+                            ls_length));
                         return(ls_end);
                     }
-                    TCHECK2(*tptr, tlv_length);
+                    ND_TCHECK2(*tptr, tlv_length);
                     switch(tlv_type) {
 
                     case LS_OPAQUE_RI_TLV_CAP:
                         if (tlv_length != 4) {
-                            printf("\n\t    Bogus length %u != 4", tlv_length);
+                            ND_PRINT((ndo, "\n\t    Bogus length %u != 4", tlv_length));
                             return(ls_end);
                         }
-                        printf("Capabilities: %s",
-                               bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr)));
+                        ND_PRINT((ndo, "Capabilities: %s",
+                               bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr))));
                         break;
                     default:
-                        if (vflag <= 1) {
-                            if(!print_unknown_data(tptr,"\n\t      ",tlv_length))
+                        if (ndo->ndo_vflag <= 1) {
+                            if (!print_unknown_data(ndo, tptr, "\n\t      ", tlv_length))
                                 return(ls_end);
                         }
                         break;
@@ -792,50 +782,50 @@
                 break;
 
             case LS_OPAQUE_TYPE_GRACE:
-                if (ospf_print_grace_lsa((u_int8_t *)(&lsap->lsa_un.un_grace_tlv.type),
+                if (ospf_print_grace_lsa(ndo, (uint8_t *)(&lsap->lsa_un.un_grace_tlv.type),
                                          ls_length) == -1) {
                     return(ls_end);
                 }
                 break;
 
 	    case LS_OPAQUE_TYPE_TE:
-                if (ospf_print_te_lsa((u_int8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type),
+                if (ospf_print_te_lsa(ndo, (uint8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type),
                                       ls_length) == -1) {
                     return(ls_end);
                 }
                 break;
 
             default:
-                if (vflag <= 1) {
-                    if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown,
+                if (ndo->ndo_vflag <= 1) {
+                    if (!print_unknown_data(ndo, (uint8_t *)lsap->lsa_un.un_unknown,
                                            "\n\t    ", ls_length))
                         return(ls_end);
-                } 
+                }
                 break;
             }
         }
 
         /* do we want to see an additionally hexdump ? */
-        if (vflag> 1)
-            if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown,
+        if (ndo->ndo_vflag> 1)
+            if (!print_unknown_data(ndo, (uint8_t *)lsap->lsa_un.un_unknown,
                                    "\n\t    ", ls_length)) {
                 return(ls_end);
             }
-        
+
 	return (ls_end);
 trunc:
 	return (NULL);
 }
 
 static int
-ospf_decode_lls(register const struct ospfhdr *op,
-		register u_int length)
+ospf_decode_lls(netdissect_options *ndo,
+                register const struct ospfhdr *op, register u_int length)
 {
     register const u_char *dptr;
     register const u_char *dataend;
     register u_int length2;
-    register u_int16_t lls_type, lls_len;
-    register u_int32_t lls_flags;
+    register uint16_t lls_type, lls_len;
+    register uint32_t lls_flags;
 
     switch (op->ospf_type) {
 
@@ -863,51 +853,51 @@
         length2 += op->ospf_authdata[3];
     }
     if (length2 >= length) {
-        printf("\n\t[LLS truncated]");
+        ND_PRINT((ndo, "\n\t[LLS truncated]"));
         return (1);
     }
-    TCHECK2(*dptr, 2);
-    printf("\n\t  LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr));
+    ND_TCHECK2(*dptr, 2);
+    ND_PRINT((ndo, "\n\t  LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr)));
 
     dptr += 2;
-    TCHECK2(*dptr, 2);
+    ND_TCHECK2(*dptr, 2);
     length2 = EXTRACT_16BITS(dptr);
-    printf(", length: %u", length2);
+    ND_PRINT((ndo, ", length: %u", length2));
 
     dptr += 2;
-    TCHECK(*dptr);
+    ND_TCHECK(*dptr);
     while (dptr < dataend) {
-        TCHECK2(*dptr, 2);
+        ND_TCHECK2(*dptr, 2);
         lls_type = EXTRACT_16BITS(dptr);
-        printf("\n\t    %s (%u)",
+        ND_PRINT((ndo, "\n\t    %s (%u)",
                tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type),
-               lls_type);
+               lls_type));
         dptr += 2;
-        TCHECK2(*dptr, 2);
+        ND_TCHECK2(*dptr, 2);
         lls_len = EXTRACT_16BITS(dptr);
-        printf(", length: %u", lls_len);
+        ND_PRINT((ndo, ", length: %u", lls_len));
         dptr += 2;
         switch (lls_type) {
 
         case OSPF_LLS_EO:
             if (lls_len != 4) {
-                printf(" [should be 4]");
+                ND_PRINT((ndo, " [should be 4]"));
                 lls_len = 4;
             }
-            TCHECK2(*dptr, 4);
+            ND_TCHECK2(*dptr, 4);
             lls_flags = EXTRACT_32BITS(dptr);
-            printf("\n\t      Options: 0x%08x [%s]", lls_flags,
-                   bittok2str(ospf_lls_eo_options,"?",lls_flags));
+            ND_PRINT((ndo, "\n\t      Options: 0x%08x [%s]", lls_flags,
+                   bittok2str(ospf_lls_eo_options, "?", lls_flags)));
 
             break;
 
         case OSPF_LLS_MD5:
             if (lls_len != 20) {
-                printf(" [should be 20]");
+                ND_PRINT((ndo, " [should be 20]"));
                 lls_len = 20;
             }
-			TCHECK2(*dptr, 4);
-            printf("\n\t      Sequence number: 0x%08x", EXTRACT_32BITS(dptr));
+            ND_TCHECK2(*dptr, 4);
+            ND_PRINT((ndo, "\n\t      Sequence number: 0x%08x", EXTRACT_32BITS(dptr)));
             break;
         }
 
@@ -920,14 +910,14 @@
 }
 
 static int
-ospf_decode_v2(register const struct ospfhdr *op,
-    register const u_char *dataend)
+ospf_decode_v2(netdissect_options *ndo,
+               register const struct ospfhdr *op, register const u_char *dataend)
 {
 	register const struct in_addr *ap;
 	register const struct lsr *lsrp;
 	register const struct lsa_hdr *lshp;
 	register const struct lsa *lsap;
-	register u_int32_t lsa_count,lsa_count_max;
+	register uint32_t lsa_count,lsa_count_max;
 
 	switch (op->ospf_type) {
 
@@ -939,95 +929,95 @@
 		break;
 
 	case OSPF_TYPE_HELLO:
-                printf("\n\tOptions [%s]",
-                       bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options));
+		ND_PRINT((ndo, "\n\tOptions [%s]",
+		          bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)));
 
-                TCHECK(op->ospf_hello.hello_deadint);
-                printf("\n\t  Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
-                       EXTRACT_16BITS(&op->ospf_hello.hello_helloint),
-                       EXTRACT_32BITS(&op->ospf_hello.hello_deadint),
-                       ipaddr_string(&op->ospf_hello.hello_mask),
-                       op->ospf_hello.hello_priority);
+		ND_TCHECK(op->ospf_hello.hello_deadint);
+		ND_PRINT((ndo, "\n\t  Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
+		          EXTRACT_16BITS(&op->ospf_hello.hello_helloint),
+		          EXTRACT_32BITS(&op->ospf_hello.hello_deadint),
+		          ipaddr_string(ndo, &op->ospf_hello.hello_mask),
+		          op->ospf_hello.hello_priority));
 
-		TCHECK(op->ospf_hello.hello_dr);
+		ND_TCHECK(op->ospf_hello.hello_dr);
 		if (op->ospf_hello.hello_dr.s_addr != 0)
-			printf("\n\t  Designated Router %s",
-			    ipaddr_string(&op->ospf_hello.hello_dr));
+			ND_PRINT((ndo, "\n\t  Designated Router %s",
+			    ipaddr_string(ndo, &op->ospf_hello.hello_dr)));
 
-		TCHECK(op->ospf_hello.hello_bdr);
+		ND_TCHECK(op->ospf_hello.hello_bdr);
 		if (op->ospf_hello.hello_bdr.s_addr != 0)
-			printf(", Backup Designated Router %s",
-			    ipaddr_string(&op->ospf_hello.hello_bdr));
+			ND_PRINT((ndo, ", Backup Designated Router %s",
+			          ipaddr_string(ndo, &op->ospf_hello.hello_bdr)));
 
-                ap = op->ospf_hello.hello_neighbor;
-                if ((u_char *)ap < dataend)
-                        printf("\n\t  Neighbor List:");
-                while ((u_char *)ap < dataend) {
-                        TCHECK(*ap);
-                        printf("\n\t    %s", ipaddr_string(ap));
-                        ++ap;
-                }
+		ap = op->ospf_hello.hello_neighbor;
+		if ((u_char *)ap < dataend)
+			ND_PRINT((ndo, "\n\t  Neighbor List:"));
+		while ((u_char *)ap < dataend) {
+			ND_TCHECK(*ap);
+			ND_PRINT((ndo, "\n\t    %s", ipaddr_string(ndo, ap)));
+			++ap;
+		}
 		break;	/* HELLO */
 
 	case OSPF_TYPE_DD:
-		TCHECK(op->ospf_db.db_options);
-                printf("\n\tOptions [%s]",
-                       bittok2str(ospf_option_values,"none",op->ospf_db.db_options));
-		TCHECK(op->ospf_db.db_flags);
-                printf(", DD Flags [%s]",
-                       bittok2str(ospf_dd_flag_values,"none",op->ospf_db.db_flags));
-                TCHECK(op->ospf_db.db_ifmtu);
-                if (op->ospf_db.db_ifmtu) {
-                        printf(", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu));
-                }
-                TCHECK(op->ospf_db.db_seq);
-                printf(", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq));
+		ND_TCHECK(op->ospf_db.db_options);
+		ND_PRINT((ndo, "\n\tOptions [%s]",
+		          bittok2str(ospf_option_values, "none", op->ospf_db.db_options)));
+		ND_TCHECK(op->ospf_db.db_flags);
+		ND_PRINT((ndo, ", DD Flags [%s]",
+		          bittok2str(ospf_dd_flag_values, "none", op->ospf_db.db_flags)));
+		ND_TCHECK(op->ospf_db.db_ifmtu);
+		if (op->ospf_db.db_ifmtu) {
+			ND_PRINT((ndo, ", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu)));
+		}
+		ND_TCHECK(op->ospf_db.db_seq);
+		ND_PRINT((ndo, ", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq)));
 
-                /* Print all the LS adv's */
-                lshp = op->ospf_db.db_lshdr;
-                while (((u_char *)lshp < dataend) && ospf_print_lshdr(lshp) != -1) {
-                    ++lshp;
-                }
+		/* Print all the LS adv's */
+		lshp = op->ospf_db.db_lshdr;
+		while (((u_char *)lshp < dataend) && ospf_print_lshdr(ndo, lshp) != -1) {
+			++lshp;
+		}
 		break;
 
 	case OSPF_TYPE_LS_REQ:
                 lsrp = op->ospf_lsr;
                 while ((u_char *)lsrp < dataend) {
-                    TCHECK(*lsrp);
+                    ND_TCHECK(*lsrp);
 
-                    printf("\n\t  Advertising Router: %s, %s LSA (%u)",
-                           ipaddr_string(&lsrp->ls_router),
+                    ND_PRINT((ndo, "\n\t  Advertising Router: %s, %s LSA (%u)",
+                           ipaddr_string(ndo, &lsrp->ls_router),
                            tok2str(lsa_values,"unknown",EXTRACT_32BITS(lsrp->ls_type)),
-                           EXTRACT_32BITS(&lsrp->ls_type));
+                           EXTRACT_32BITS(&lsrp->ls_type)));
 
                     switch (EXTRACT_32BITS(lsrp->ls_type)) {
                         /* the LSA header for opaque LSAs was slightly changed */
                     case LS_TYPE_OPAQUE_LL:
                     case LS_TYPE_OPAQUE_AL:
                     case LS_TYPE_OPAQUE_DW:
-                        printf(", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
+                        ND_PRINT((ndo, ", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
                                tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type),
                                lsrp->un_ls_stateid.opaque_field.opaque_type,
-                               EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id));
+                               EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id)));
                         break;
                     default:
-                        printf(", LSA-ID: %s",
-                               ipaddr_string(&lsrp->un_ls_stateid.ls_stateid));
+                        ND_PRINT((ndo, ", LSA-ID: %s",
+                               ipaddr_string(ndo, &lsrp->un_ls_stateid.ls_stateid)));
                         break;
                     }
-                    
+
                     ++lsrp;
                 }
 		break;
 
 	case OSPF_TYPE_LS_UPDATE:
                 lsap = op->ospf_lsu.lsu_lsa;
-                TCHECK(op->ospf_lsu.lsu_count);
+                ND_TCHECK(op->ospf_lsu.lsu_count);
                 lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count);
-                printf(", %d LSA%s",lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
+                ND_PRINT((ndo, ", %d LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max)));
                 for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
-                    printf("\n\t  LSA #%u",lsa_count);
-                        lsap = (const struct lsa *)ospf_print_lsa(lsap);
+                    ND_PRINT((ndo, "\n\t  LSA #%u", lsa_count));
+                        lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
                         if (lsap == NULL)
                                 goto trunc;
                 }
@@ -1035,7 +1025,7 @@
 
 	case OSPF_TYPE_LS_ACK:
                 lshp = op->ospf_lsa.lsa_lshdr;
-                while (ospf_print_lshdr(lshp) != -1) {
+                while (ospf_print_lshdr(ndo, lshp) != -1) {
                     ++lshp;
                 }
                 break;
@@ -1049,8 +1039,9 @@
 }
 
 void
-ospf_print(register const u_char *bp, register u_int length,
-    const u_char *bp2 _U_)
+ospf_print(netdissect_options *ndo,
+           register const u_char *bp, register u_int length,
+           const u_char *bp2 _U_)
 {
 	register const struct ospfhdr *op;
 	register const u_char *dataend;
@@ -1058,31 +1049,28 @@
 
 	op = (struct ospfhdr *)bp;
 
-        /* XXX Before we do anything else, strip off the MD5 trailer */
-        TCHECK(op->ospf_authtype);
-        if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
-                length -= OSPF_AUTH_MD5_LEN;
-                snapend -= OSPF_AUTH_MD5_LEN;
-        }
+	/* XXX Before we do anything else, strip off the MD5 trailer */
+	ND_TCHECK(op->ospf_authtype);
+	if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
+		length -= OSPF_AUTH_MD5_LEN;
+		ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
+	}
 
 	/* If the type is valid translate it, or just print the type */
 	/* value.  If it's not valid, say so and return */
-	TCHECK(op->ospf_type);
+	ND_TCHECK(op->ospf_type);
 	cp = tok2str(type2str, "unknown LS-type", op->ospf_type);
-	printf("OSPFv%u, %s, length %u",
-	       op->ospf_version,
-	       cp,
-	       length);
+	ND_PRINT((ndo, "OSPFv%u, %s, length %u", op->ospf_version, cp, length));
 	if (*cp == 'u')
 		return;
 
-        if(!vflag) { /* non verbose - so lets bail out here */
-                return;
-        }
+	if (!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
+		return;
+	}
 
-	TCHECK(op->ospf_len);
+	ND_TCHECK(op->ospf_len);
 	if (length != EXTRACT_16BITS(&op->ospf_len)) {
-		printf(" [len %d]", EXTRACT_16BITS(&op->ospf_len));
+		ND_PRINT((ndo, " [len %d]", EXTRACT_16BITS(&op->ospf_len)));
 	}
 
 	if (length > EXTRACT_16BITS(&op->ospf_len)) {
@@ -1091,22 +1079,22 @@
 		dataend = bp + length;
 	}
 
-	TCHECK(op->ospf_routerid);
-        printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf_routerid));
+	ND_TCHECK(op->ospf_routerid);
+	ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf_routerid)));
 
-	TCHECK(op->ospf_areaid);
+	ND_TCHECK(op->ospf_areaid);
 	if (op->ospf_areaid.s_addr != 0)
-		printf(", Area %s", ipaddr_string(&op->ospf_areaid));
+		ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf_areaid)));
 	else
-		printf(", Backbone Area");
+		ND_PRINT((ndo, ", Backbone Area"));
 
-	if (vflag) {
+	if (ndo->ndo_vflag) {
 		/* Print authentication data (should we really do this?) */
-		TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
+		ND_TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
 
-                printf(", Authentication Type: %s (%u)",
-                       tok2str(ospf_authtype_values,"unknown",EXTRACT_16BITS(&op->ospf_authtype)),
-                       EXTRACT_16BITS(&op->ospf_authtype));
+		ND_PRINT((ndo, ", Authentication Type: %s (%u)",
+		          tok2str(ospf_authtype_values, "unknown", EXTRACT_16BITS(&op->ospf_authtype)),
+		          EXTRACT_16BITS(&op->ospf_authtype)));
 
 		switch (EXTRACT_16BITS(&op->ospf_authtype)) {
 
@@ -1114,15 +1102,15 @@
 			break;
 
 		case OSPF_AUTH_SIMPLE:
-                        printf("\n\tSimple text password: ");
-                        safeputs((const char *)op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
+			ND_PRINT((ndo, "\n\tSimple text password: "));
+			safeputs(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
 			break;
 
 		case OSPF_AUTH_MD5:
-                        printf("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
-                               *((op->ospf_authdata)+2),
-                               *((op->ospf_authdata)+3),
-                               EXTRACT_32BITS((op->ospf_authdata)+4));
+			ND_PRINT((ndo, "\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
+			          *((op->ospf_authdata) + 2),
+			          *((op->ospf_authdata) + 3),
+			          EXTRACT_32BITS((op->ospf_authdata) + 4)));
 			break;
 
 		default:
@@ -1134,20 +1122,20 @@
 
 	case 2:
 		/* ospf version 2 */
-		if (ospf_decode_v2(op, dataend))
+		if (ospf_decode_v2(ndo, op, dataend))
 			goto trunc;
 		if (length > EXTRACT_16BITS(&op->ospf_len)) {
-			if (ospf_decode_lls(op, length))
+			if (ospf_decode_lls(ndo, op, length))
 				goto trunc;
 		}
 		break;
 
 	default:
-		printf(" ospf [version %d]", op->ospf_version);
+		ND_PRINT((ndo, " ospf [version %d]", op->ospf_version));
 		break;
 	}			/* end switch on version */
 
 	return;
 trunc:
-	fputs(tstr, stdout);
+	ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-ospf6.c b/print-ospf6.c
index b0a6f27..49210bc 100644
--- a/print-ospf6.c
+++ b/print-ospf6.c
@@ -21,18 +21,13 @@
  * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.15 2006-09-13 06:31:11 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
@@ -40,15 +35,266 @@
 #include "extract.h"
 
 #include "ospf.h"
-#include "ospf6.h"
+
+#define	OSPF_TYPE_HELLO         1	/* Hello */
+#define	OSPF_TYPE_DD            2	/* Database Description */
+#define	OSPF_TYPE_LS_REQ        3	/* Link State Request */
+#define	OSPF_TYPE_LS_UPDATE     4	/* Link State Update */
+#define	OSPF_TYPE_LS_ACK        5	/* Link State Ack */
+
+/* Options *_options	*/
+#define OSPF6_OPTION_V6	0x01	/* V6 bit: A bit for peeping tom */
+#define OSPF6_OPTION_E	0x02	/* E bit: External routes advertised	*/
+#define OSPF6_OPTION_MC	0x04	/* MC bit: Multicast capable */
+#define OSPF6_OPTION_N	0x08	/* N bit: For type-7 LSA */
+#define OSPF6_OPTION_R	0x10	/* R bit: Router bit */
+#define OSPF6_OPTION_DC	0x20	/* DC bit: Demand circuits */
+/* The field is actually 24-bit (RFC5340 Section A.2). */
+#define OSPF6_OPTION_AF	0x0100	/* AF bit: Multiple address families */
+#define OSPF6_OPTION_L	0x0200	/* L bit: Link-local signaling (LLS) */
+#define OSPF6_OPTION_AT	0x0400	/* AT bit: Authentication trailer */
+
+
+/* db_flags	*/
+#define	OSPF6_DB_INIT		0x04	    /*	*/
+#define	OSPF6_DB_MORE		0x02
+#define	OSPF6_DB_MASTER		0x01
+#define	OSPF6_DB_M6		0x10  /* IPv6 MTU */
+
+/* ls_type	*/
+#define	LS_TYPE_ROUTER		1   /* router link */
+#define	LS_TYPE_NETWORK		2   /* network link */
+#define	LS_TYPE_INTER_AP	3   /* Inter-Area-Prefix */
+#define	LS_TYPE_INTER_AR	4   /* Inter-Area-Router */
+#define	LS_TYPE_ASE		5   /* ASE */
+#define	LS_TYPE_GROUP		6   /* Group membership */
+#define	LS_TYPE_NSSA		7   /* NSSA */
+#define	LS_TYPE_LINK		8   /* Link LSA */
+#define	LS_TYPE_INTRA_AP	9   /* Intra-Area-Prefix */
+#define LS_TYPE_INTRA_ATE       10  /* Intra-Area-TE */
+#define LS_TYPE_GRACE           11  /* Grace LSA */
+#define LS_TYPE_RI		12  /* Router information */
+#define LS_TYPE_INTER_ASTE	13  /* Inter-AS-TE */
+#define LS_TYPE_L1VPN		14  /* L1VPN */
+#define LS_TYPE_MASK		0x1fff
+
+#define LS_SCOPE_LINKLOCAL	0x0000
+#define LS_SCOPE_AREA		0x2000
+#define LS_SCOPE_AS		0x4000
+#define LS_SCOPE_MASK		0x6000
+#define LS_SCOPE_U              0x8000
+
+/* rla_link.link_type	*/
+#define	RLA_TYPE_ROUTER		1   /* point-to-point to another router	*/
+#define	RLA_TYPE_TRANSIT	2   /* connection to transit network	*/
+#define RLA_TYPE_VIRTUAL	4   /* virtual link			*/
+
+/* rla_flags	*/
+#define	RLA_FLAG_B	0x01
+#define	RLA_FLAG_E	0x02
+#define	RLA_FLAG_V	0x04
+#define	RLA_FLAG_W	0x08
+#define RLA_FLAG_N      0x10
+
+/* lsa_prefix options */
+#define LSA_PREFIX_OPT_NU 0x01
+#define LSA_PREFIX_OPT_LA 0x02
+#define LSA_PREFIX_OPT_MC 0x04
+#define LSA_PREFIX_OPT_P  0x08
+#define LSA_PREFIX_OPT_DN 0x10
+
+/* sla_tosmetric breakdown	*/
+#define	SLA_MASK_TOS		0x7f000000
+#define	SLA_MASK_METRIC		0x00ffffff
+#define SLA_SHIFT_TOS		24
+
+/* asla_metric */
+#define ASLA_FLAG_FWDADDR	0x02000000
+#define ASLA_FLAG_ROUTETAG	0x01000000
+#define	ASLA_MASK_METRIC	0x00ffffff
+
+/* RFC6506 Section 4.1 */
+#define OSPF6_AT_HDRLEN             16U
+#define OSPF6_AUTH_TYPE_HMAC        0x0001
+
+typedef uint32_t rtrid_t;
+
+/* link state advertisement header */
+struct lsa6_hdr {
+    uint16_t ls_age;
+    uint16_t ls_type;
+    rtrid_t ls_stateid;
+    rtrid_t ls_router;
+    uint32_t ls_seq;
+    uint16_t ls_chksum;
+    uint16_t ls_length;
+};
+
+/* Length of an IPv6 address, in bytes. */
+#define IPV6_ADDR_LEN_BYTES (128/8)
+
+struct lsa6_prefix {
+    uint8_t lsa_p_len;
+    uint8_t lsa_p_opt;
+    uint16_t lsa_p_metric;
+    uint8_t lsa_p_prefix[IPV6_ADDR_LEN_BYTES]; /* maximum length */
+};
+
+/* link state advertisement */
+struct lsa6 {
+    struct lsa6_hdr ls_hdr;
+
+    /* Link state types */
+    union {
+	/* Router links advertisements */
+	struct {
+	    union {
+		uint8_t flg;
+		uint32_t opt;
+	    } rla_flgandopt;
+#define rla_flags	rla_flgandopt.flg
+#define rla_options	rla_flgandopt.opt
+	    struct rlalink6 {
+		uint8_t link_type;
+		uint8_t link_zero[1];
+		uint16_t link_metric;
+		uint32_t link_ifid;
+		uint32_t link_nifid;
+		rtrid_t link_nrtid;
+	    } rla_link[1];		/* may repeat	*/
+	} un_rla;
+
+	/* Network links advertisements */
+	struct {
+	    uint32_t nla_options;
+	    rtrid_t nla_router[1];	/* may repeat	*/
+	} un_nla;
+
+	/* Inter Area Prefix LSA */
+	struct {
+	    uint32_t inter_ap_metric;
+	    struct lsa6_prefix inter_ap_prefix[1];
+	} un_inter_ap;
+
+	/* AS external links advertisements */
+	struct {
+	    uint32_t asla_metric;
+	    struct lsa6_prefix asla_prefix[1];
+	    /* some optional fields follow */
+	} un_asla;
+
+#if 0
+	/* Summary links advertisements */
+	struct {
+	    struct in_addr sla_mask;
+	    uint32_t sla_tosmetric[1];	/* may repeat	*/
+	} un_sla;
+
+	/* Multicast group membership */
+	struct mcla {
+	    uint32_t mcla_vtype;
+	    struct in_addr mcla_vid;
+	} un_mcla[1];
+#endif
+
+	/* Type 7 LSA */
+
+	/* Link LSA */
+	struct llsa {
+	    union {
+		uint8_t pri;
+		uint32_t opt;
+	    } llsa_priandopt;
+#define llsa_priority	llsa_priandopt.pri
+#define llsa_options	llsa_priandopt.opt
+	    struct in6_addr llsa_lladdr;
+	    uint32_t llsa_nprefix;
+	    struct lsa6_prefix llsa_prefix[1];
+	} un_llsa;
+
+	/* Intra-Area-Prefix */
+	struct {
+	    uint16_t intra_ap_nprefix;
+	    uint16_t intra_ap_lstype;
+	    rtrid_t intra_ap_lsid;
+	    rtrid_t intra_ap_rtid;
+	    struct lsa6_prefix intra_ap_prefix[1];
+	} un_intra_ap;
+    } lsa_un;
+};
+
+/*
+ * the main header
+ */
+struct ospf6hdr {
+    uint8_t ospf6_version;
+    uint8_t ospf6_type;
+    uint16_t ospf6_len;
+    rtrid_t ospf6_routerid;
+    rtrid_t ospf6_areaid;
+    uint16_t ospf6_chksum;
+    uint8_t ospf6_instanceid;
+    uint8_t ospf6_rsvd;
+};
+
+/*
+ * The OSPF6 header length is 16 bytes, regardless of how your compiler
+ * might choose to pad the above structure.
+ */
+#define OSPF6HDR_LEN    16
+
+/* Hello packet */
+struct hello6 {
+    uint32_t hello_ifid;
+    union {
+	uint8_t pri;
+	uint32_t opt;
+    } hello_priandopt;
+#define hello_priority	hello_priandopt.pri
+#define hello_options	hello_priandopt.opt
+    uint16_t hello_helloint;
+    uint16_t hello_deadint;
+    rtrid_t hello_dr;
+    rtrid_t hello_bdr;
+    rtrid_t hello_neighbor[1]; /* may repeat	*/
+};
+
+/* Database Description packet */
+struct dd6 {
+    uint32_t db_options;
+    uint16_t db_mtu;
+    uint8_t db_mbz;
+    uint8_t db_flags;
+    uint32_t db_seq;
+    struct lsa6_hdr db_lshdr[1]; /* may repeat	*/
+};
+
+/* Link State Request */
+struct lsr6 {
+    uint16_t ls_mbz;
+    uint16_t ls_type;
+    rtrid_t ls_stateid;
+    rtrid_t ls_router;
+};
+
+/* Link State Update */
+struct lsu6 {
+    uint32_t lsu_count;
+    struct lsa6 lsu_lsa[1]; /* may repeat	*/
+};
+
+static const char tstr[] = " [|ospf3]";
 
 static const struct tok ospf6_option_values[] = {
 	{ OSPF6_OPTION_V6,	"V6" },
 	{ OSPF6_OPTION_E,	"External" },
-	{ OSPF6_OPTION_MC,	"Multicast" },
+	{ OSPF6_OPTION_MC,	"Deprecated" },
 	{ OSPF6_OPTION_N,	"NSSA" },
 	{ OSPF6_OPTION_R,	"Router" },
 	{ OSPF6_OPTION_DC,	"Demand Circuit" },
+	{ OSPF6_OPTION_AF,	"AFs Support" },
+	{ OSPF6_OPTION_L,	"LLS" },
+	{ OSPF6_OPTION_AT,	"Authentication Trailer" },
 	{ 0,			NULL }
 };
 
@@ -63,7 +309,7 @@
 
 static const struct tok ospf6_asla_flag_values[] = {
 	{ ASLA_FLAG_EXTERNAL,	"External Type 2" },
-	{ ASLA_FLAG_FWDADDR,	"Fforwarding" },
+	{ ASLA_FLAG_FWDADDR,	"Forwarding" },
 	{ ASLA_FLAG_ROUTETAG,	"Tag" },
 	{ 0,			NULL }
 };
@@ -83,12 +329,15 @@
 	{ LS_TYPE_INTER_AP,     "Inter-Area Prefix" },
 	{ LS_TYPE_INTER_AR,     "Inter-Area Router" },
 	{ LS_TYPE_ASE,          "External" },
-	{ LS_TYPE_GROUP,        "Multicast Group" },
+	{ LS_TYPE_GROUP,        "Deprecated" },
 	{ LS_TYPE_NSSA,         "NSSA" },
 	{ LS_TYPE_LINK,         "Link" },
 	{ LS_TYPE_INTRA_AP,     "Intra-Area Prefix" },
         { LS_TYPE_INTRA_ATE,    "Intra-Area TE" },
         { LS_TYPE_GRACE,        "Grace" },
+	{ LS_TYPE_RI,           "Router Information" },
+	{ LS_TYPE_INTER_ASTE,   "Inter-AS-TE" },
+	{ LS_TYPE_L1VPN,        "Layer 1 VPN" },
 	{ 0,			NULL }
 };
 
@@ -103,52 +352,52 @@
 	{ OSPF6_DB_INIT,	"Init" },
 	{ OSPF6_DB_MORE,	"More" },
 	{ OSPF6_DB_MASTER,	"Master" },
+	{ OSPF6_DB_M6,		"IPv6 MTU" },
 	{ 0,			NULL }
 };
 
 static const struct tok ospf6_lsa_prefix_option_values[] = {
         { LSA_PREFIX_OPT_NU, "No Unicast" },
         { LSA_PREFIX_OPT_LA, "Local address" },
-        { LSA_PREFIX_OPT_MC, "Multicast" },
+        { LSA_PREFIX_OPT_MC, "Deprecated" },
         { LSA_PREFIX_OPT_P, "Propagate" },
         { LSA_PREFIX_OPT_DN, "Down" },
 	{ 0, NULL }
 };
 
-static char tstr[] = " [|ospf3]";
-
-/* Forwards */
-static void ospf6_print_ls_type(u_int, const rtrid_t *);
-static int ospf6_print_lshdr(const struct lsa6_hdr *);
-static int ospf6_print_lsa(const struct lsa6 *);
-static int ospf6_decode_v3(const struct ospf6hdr *, const u_char *);
-
+static const struct tok ospf6_auth_type_str[] = {
+	{ OSPF6_AUTH_TYPE_HMAC,        "HMAC" },
+	{ 0, NULL }
+};
 
 static void
-ospf6_print_ls_type(register u_int ls_type, register const rtrid_t *ls_stateid)
+ospf6_print_ls_type(netdissect_options *ndo,
+                    register u_int ls_type, register const rtrid_t *ls_stateid)
 {
-        printf("\n\t    %s LSA (%d), %s Scope%s, LSA-ID %s",
+        ND_PRINT((ndo, "\n\t    %s LSA (%d), %s Scope%s, LSA-ID %s",
                tok2str(ospf6_lsa_values, "Unknown", ls_type & LS_TYPE_MASK),
                ls_type & LS_TYPE_MASK,
                tok2str(ospf6_ls_scope_values, "Unknown", ls_type & LS_SCOPE_MASK),
                ls_type &0x8000 ? ", transitive" : "", /* U-bit */
-               ipaddr_string(ls_stateid));
+               ipaddr_string(ndo, ls_stateid)));
 }
 
 static int
-ospf6_print_lshdr(register const struct lsa6_hdr *lshp)
+ospf6_print_lshdr(netdissect_options *ndo,
+                  register const struct lsa6_hdr *lshp, const u_char *dataend)
 {
+	if ((u_char *)(lshp + 1) > dataend)
+		goto trunc;
+	ND_TCHECK(lshp->ls_type);
+	ND_TCHECK(lshp->ls_seq);
 
-	TCHECK(lshp->ls_type);
-	TCHECK(lshp->ls_seq);
-
-	printf("\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
-               ipaddr_string(&lshp->ls_router),
+	ND_PRINT((ndo, "\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
+               ipaddr_string(ndo, &lshp->ls_router),
                EXTRACT_32BITS(&lshp->ls_seq),
                EXTRACT_16BITS(&lshp->ls_age),
-               EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr));
+               EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr)));
 
-	ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid);
+	ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid);
 
 	return (0);
 trunc:
@@ -156,36 +405,37 @@
 }
 
 static int
-ospf6_print_lsaprefix(const u_int8_t *tptr, u_int lsa_length)
+ospf6_print_lsaprefix(netdissect_options *ndo,
+                      const uint8_t *tptr, u_int lsa_length)
 {
 	const struct lsa6_prefix *lsapp = (struct lsa6_prefix *)tptr;
 	u_int wordlen;
 	struct in6_addr prefix;
 
-	if (lsa_length < sizeof (*lsapp) - 4)
+	if (lsa_length < sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES)
 		goto trunc;
-	lsa_length -= sizeof (*lsapp) - 4;
-	TCHECK2(*lsapp, sizeof (*lsapp) - 4);
+	lsa_length -= sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES;
+	ND_TCHECK2(*lsapp, sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES);
 	wordlen = (lsapp->lsa_p_len + 31) / 32;
 	if (wordlen * 4 > sizeof(struct in6_addr)) {
-		printf(" bogus prefixlen /%d", lsapp->lsa_p_len);
+		ND_PRINT((ndo, " bogus prefixlen /%d", lsapp->lsa_p_len));
 		goto trunc;
 	}
 	if (lsa_length < wordlen * 4)
 		goto trunc;
 	lsa_length -= wordlen * 4;
-	TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
+	ND_TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
 	memset(&prefix, 0, sizeof(prefix));
 	memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
-	printf("\n\t\t%s/%d", ip6addr_string(&prefix),
-		lsapp->lsa_p_len);
+	ND_PRINT((ndo, "\n\t\t%s/%d", ip6addr_string(ndo, &prefix),
+		lsapp->lsa_p_len));
         if (lsapp->lsa_p_opt) {
-            printf(", Options [%s]",
+            ND_PRINT((ndo, ", Options [%s]",
                    bittok2str(ospf6_lsa_prefix_option_values,
-                              "none", lsapp->lsa_p_opt));
+                              "none", lsapp->lsa_p_opt)));
         }
-        printf(", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric));
-	return sizeof(*lsapp) - 4 + wordlen * 4;
+        ND_PRINT((ndo, ", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric)));
+	return sizeof(*lsapp) - IPV6_ADDR_LEN_BYTES + wordlen * 4;
 
 trunc:
 	return -1;
@@ -196,7 +446,8 @@
  * Print a single link state advertisement.  If truncated return 1, else 0.
  */
 static int
-ospf6_print_lsa(register const struct lsa6 *lsap)
+ospf6_print_lsa(netdissect_options *ndo,
+                register const struct lsa6 *lsap, const u_char *dataend)
 {
 	register const struct rlalink6 *rlp;
 #if 0
@@ -210,17 +461,17 @@
 	register const struct llsa *llsap;
 	register const struct lsa6_prefix *lsapp;
 #if 0
-	register const u_int32_t *lp;
+	register const uint32_t *lp;
 #endif
 	register u_int prefixes;
 	register int bytelen;
 	register u_int length, lsa_length;
-	u_int32_t flags32;
-	const u_int8_t *tptr;
+	uint32_t flags32;
+	const uint8_t *tptr;
 
-	if (ospf6_print_lshdr(&lsap->ls_hdr))
+	if (ospf6_print_lshdr(ndo, &lsap->ls_hdr, dataend))
 		return (1);
-	TCHECK(lsap->ls_hdr.ls_length);
+	ND_TCHECK(lsap->ls_hdr.ls_length);
         length = EXTRACT_16BITS(&lsap->ls_hdr.ls_length);
 
 	/*
@@ -229,62 +480,62 @@
 	 * If it does, find the length of what follows the
 	 * header.
 	 */
-        if (length < sizeof(struct lsa6_hdr))
+        if (length < sizeof(struct lsa6_hdr) || (u_char *)lsap + length > dataend)
         	return (1);
         lsa_length = length - sizeof(struct lsa6_hdr);
-        tptr = (u_int8_t *)lsap+sizeof(struct lsa6_hdr);
+        tptr = (uint8_t *)lsap+sizeof(struct lsa6_hdr);
 
 	switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) {
 	case LS_TYPE_ROUTER | LS_SCOPE_AREA:
 		if (lsa_length < sizeof (lsap->lsa_un.un_rla.rla_options))
 			return (1);
 		lsa_length -= sizeof (lsap->lsa_un.un_rla.rla_options);
-		TCHECK(lsap->lsa_un.un_rla.rla_options);
-                printf("\n\t      Options [%s]",
-                       bittok2str(ospf6_option_values, "none",
-                                  EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options)));
-                printf(", RLA-Flags [%s]",
-                       bittok2str(ospf6_rla_flag_values, "none",
-                                  lsap->lsa_un.un_rla.rla_flags));
+		ND_TCHECK(lsap->lsa_un.un_rla.rla_options);
+		ND_PRINT((ndo, "\n\t      Options [%s]",
+		          bittok2str(ospf6_option_values, "none",
+		          EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options))));
+		ND_PRINT((ndo, ", RLA-Flags [%s]",
+		          bittok2str(ospf6_rla_flag_values, "none",
+		          lsap->lsa_un.un_rla.rla_flags)));
 
 		rlp = lsap->lsa_un.un_rla.rla_link;
 		while (lsa_length != 0) {
 			if (lsa_length < sizeof (*rlp))
 				return (1);
 			lsa_length -= sizeof (*rlp);
-			TCHECK(*rlp);
+			ND_TCHECK(*rlp);
 			switch (rlp->link_type) {
 
 			case RLA_TYPE_VIRTUAL:
-				printf("\n\t      Virtual Link: Neighbor Router-ID %s"
+				ND_PRINT((ndo, "\n\t      Virtual Link: Neighbor Router-ID %s"
                                        "\n\t      Neighbor Interface-ID %s, Interface %s",
-                                       ipaddr_string(&rlp->link_nrtid),
-                                       ipaddr_string(&rlp->link_nifid),
-                                       ipaddr_string(&rlp->link_ifid)); 
+                                       ipaddr_string(ndo, &rlp->link_nrtid),
+                                       ipaddr_string(ndo, &rlp->link_nifid),
+                                       ipaddr_string(ndo, &rlp->link_ifid)));
                                 break;
 
 			case RLA_TYPE_ROUTER:
-				printf("\n\t      Neighbor Router-ID %s"
+				ND_PRINT((ndo, "\n\t      Neighbor Router-ID %s"
                                        "\n\t      Neighbor Interface-ID %s, Interface %s",
-                                       ipaddr_string(&rlp->link_nrtid),
-                                       ipaddr_string(&rlp->link_nifid),
-                                       ipaddr_string(&rlp->link_ifid)); 
+                                       ipaddr_string(ndo, &rlp->link_nrtid),
+                                       ipaddr_string(ndo, &rlp->link_nifid),
+                                       ipaddr_string(ndo, &rlp->link_ifid)));
 				break;
 
 			case RLA_TYPE_TRANSIT:
-				printf("\n\t      Neighbor Network-ID %s"
+				ND_PRINT((ndo, "\n\t      Neighbor Network-ID %s"
                                        "\n\t      Neighbor Interface-ID %s, Interface %s",
-				    ipaddr_string(&rlp->link_nrtid),
-				    ipaddr_string(&rlp->link_nifid),
-				    ipaddr_string(&rlp->link_ifid));
+				    ipaddr_string(ndo, &rlp->link_nrtid),
+				    ipaddr_string(ndo, &rlp->link_nifid),
+				    ipaddr_string(ndo, &rlp->link_ifid)));
 				break;
 
 			default:
-				printf("\n\t      Unknown Router Links Type 0x%02x",
-				    rlp->link_type);
+				ND_PRINT((ndo, "\n\t      Unknown Router Links Type 0x%02x",
+				    rlp->link_type));
 				return (0);
 			}
-			printf(", metric %d", EXTRACT_16BITS(&rlp->link_metric));
+			ND_PRINT((ndo, ", metric %d", EXTRACT_16BITS(&rlp->link_metric)));
 			rlp++;
 		}
 		break;
@@ -293,19 +544,19 @@
 		if (lsa_length < sizeof (lsap->lsa_un.un_nla.nla_options))
 			return (1);
 		lsa_length -= sizeof (lsap->lsa_un.un_nla.nla_options);
-		TCHECK(lsap->lsa_un.un_nla.nla_options);
-                printf("\n\t      Options [%s]",
-                       bittok2str(ospf6_option_values, "none",
-                                  EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options)));
+		ND_TCHECK(lsap->lsa_un.un_nla.nla_options);
+		ND_PRINT((ndo, "\n\t      Options [%s]",
+		          bittok2str(ospf6_option_values, "none",
+		          EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options))));
 
-		printf("\n\t      Connected Routers:");
+		ND_PRINT((ndo, "\n\t      Connected Routers:"));
 		ap = lsap->lsa_un.un_nla.nla_router;
 		while (lsa_length != 0) {
 			if (lsa_length < sizeof (*ap))
 				return (1);
 			lsa_length -= sizeof (*ap);
-			TCHECK(*ap);
-			printf("\n\t\t%s", ipaddr_string(ap));
+			ND_TCHECK(*ap);
+			ND_PRINT((ndo, "\n\t\t%s", ipaddr_string(ndo, ap)));
 			++ap;
 		}
 		break;
@@ -314,13 +565,13 @@
 		if (lsa_length < sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric))
 			return (1);
 		lsa_length -= sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric);
-		TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
-		printf(", metric %u",
-			EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
+		ND_TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
+		ND_PRINT((ndo, ", metric %u",
+			EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC));
 
-		tptr = (u_int8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
+		tptr = (uint8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
 		while (lsa_length != 0) {
-			bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+			bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
 			if (bytelen < 0)
 				goto trunc;
 			lsa_length -= bytelen;
@@ -332,17 +583,17 @@
 		if (lsa_length < sizeof (lsap->lsa_un.un_asla.asla_metric))
 			return (1);
 		lsa_length -= sizeof (lsap->lsa_un.un_asla.asla_metric);
-		TCHECK(lsap->lsa_un.un_asla.asla_metric);
+		ND_TCHECK(lsap->lsa_un.un_asla.asla_metric);
 		flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric);
-                printf("\n\t     Flags [%s]",
-                       bittok2str(ospf6_asla_flag_values, "none", flags32));
-		printf(" metric %u",
+		ND_PRINT((ndo, "\n\t     Flags [%s]",
+		          bittok2str(ospf6_asla_flag_values, "none", flags32)));
+		ND_PRINT((ndo, " metric %u",
 		       EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) &
-		       ASLA_MASK_METRIC);
+		       ASLA_MASK_METRIC));
 
-		tptr = (u_int8_t *)lsap->lsa_un.un_asla.asla_prefix;
+		tptr = (uint8_t *)lsap->lsa_un.un_asla.asla_prefix;
 		lsapp = (struct lsa6_prefix *)tptr;
-		bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+		bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
 		if (bytelen < 0)
 			goto trunc;
 		lsa_length -= bytelen;
@@ -355,30 +606,30 @@
 			if (lsa_length < sizeof (*fwdaddr6))
 				return (1);
 			lsa_length -= sizeof (*fwdaddr6);
-			TCHECK(*fwdaddr6);
-			printf(" forward %s",
-			       ip6addr_string(fwdaddr6));
+			ND_TCHECK(*fwdaddr6);
+			ND_PRINT((ndo, " forward %s",
+			       ip6addr_string(ndo, fwdaddr6)));
 			tptr += sizeof(*fwdaddr6);
 		}
 
 		if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
-			if (lsa_length < sizeof (u_int32_t))
+			if (lsa_length < sizeof (uint32_t))
 				return (1);
-			lsa_length -= sizeof (u_int32_t);
-			TCHECK(*(u_int32_t *)tptr);
-			printf(" tag %s",
-			       ipaddr_string((u_int32_t *)tptr));
-			tptr += sizeof(u_int32_t);
+			lsa_length -= sizeof (uint32_t);
+			ND_TCHECK(*(uint32_t *)tptr);
+			ND_PRINT((ndo, " tag %s",
+			       ipaddr_string(ndo, (uint32_t *)tptr)));
+			tptr += sizeof(uint32_t);
 		}
 
 		if (lsapp->lsa_p_metric) {
-			if (lsa_length < sizeof (u_int32_t))
+			if (lsa_length < sizeof (uint32_t))
 				return (1);
-			lsa_length -= sizeof (u_int32_t);
-			TCHECK(*(u_int32_t *)tptr);
-			printf(" RefLSID: %s",
-			       ipaddr_string((u_int32_t *)tptr));
-			tptr += sizeof(u_int32_t);
+			lsa_length -= sizeof (uint32_t);
+			ND_TCHECK(*(uint32_t *)tptr);
+			ND_PRINT((ndo, " RefLSID: %s",
+			       ipaddr_string(ndo, (uint32_t *)tptr)));
+			tptr += sizeof(uint32_t);
 		}
 		break;
 
@@ -388,23 +639,23 @@
 		if (lsa_length < sizeof (llsap->llsa_priandopt))
 			return (1);
 		lsa_length -= sizeof (llsap->llsa_priandopt);
-		TCHECK(llsap->llsa_priandopt);
-                printf("\n\t      Options [%s]",
-                       bittok2str(ospf6_option_values, "none",
-                                  EXTRACT_32BITS(&llsap->llsa_options)));
+		ND_TCHECK(llsap->llsa_priandopt);
+		ND_PRINT((ndo, "\n\t      Options [%s]",
+		          bittok2str(ospf6_option_values, "none",
+		          EXTRACT_32BITS(&llsap->llsa_options))));
 
 		if (lsa_length < sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix))
 			return (1);
 		lsa_length -= sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix);
                 prefixes = EXTRACT_32BITS(&llsap->llsa_nprefix);
-		printf("\n\t      Priority %d, Link-local address %s, Prefixes %d:",
+		ND_PRINT((ndo, "\n\t      Priority %d, Link-local address %s, Prefixes %d:",
                        llsap->llsa_priority,
-                       ip6addr_string(&llsap->llsa_lladdr),
-                       prefixes);
+                       ip6addr_string(ndo, &llsap->llsa_lladdr),
+                       prefixes));
 
-		tptr = (u_int8_t *)llsap->llsa_prefix;
+		tptr = (uint8_t *)llsap->llsa_prefix;
 		while (prefixes > 0) {
-			bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+			bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
 			if (bytelen < 0)
 				goto trunc;
 			prefixes--;
@@ -418,21 +669,21 @@
 		if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid))
 			return (1);
 		lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid);
-		TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
-		ospf6_print_ls_type(
+		ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
+		ospf6_print_ls_type(ndo,
 			EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype),
 			&lsap->lsa_un.un_intra_ap.intra_ap_lsid);
 
 		if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix))
 			return (1);
 		lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
-		TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+		ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
                 prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
-		printf("\n\t      Prefixes %d:", prefixes);
+		ND_PRINT((ndo, "\n\t      Prefixes %d:", prefixes));
 
-		tptr = (u_int8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
+		tptr = (uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
 		while (prefixes > 0) {
-			bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+			bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
 			if (bytelen < 0)
 				goto trunc;
 			prefixes--;
@@ -442,19 +693,19 @@
 		break;
 
         case LS_TYPE_GRACE | LS_SCOPE_LINKLOCAL:
-                if (ospf_print_grace_lsa(tptr, lsa_length) == -1) {
+                if (ospf_print_grace_lsa(ndo, tptr, lsa_length) == -1) {
                     return 1;
                 }
                 break;
 
         case LS_TYPE_INTRA_ATE | LS_SCOPE_LINKLOCAL:
-                if (ospf_print_te_lsa(tptr, lsa_length) == -1) {
+                if (ospf_print_te_lsa(ndo, tptr, lsa_length) == -1) {
                     return 1;
                 }
                 break;
 
 	default:
-                if(!print_unknown_data(tptr,
+                if(!print_unknown_data(ndo,tptr,
                                        "\n\t      ",
                                        lsa_length)) {
                     return (1);
@@ -468,8 +719,9 @@
 }
 
 static int
-ospf6_decode_v3(register const struct ospf6hdr *op,
-    register const u_char *dataend)
+ospf6_decode_v3(netdissect_options *ndo,
+                register const struct ospf6hdr *op,
+                register const u_char *dataend)
 {
 	register const rtrid_t *ap;
 	register const struct lsr6 *lsrp;
@@ -479,66 +731,74 @@
 
 	switch (op->ospf6_type) {
 
-	case OSPF_TYPE_HELLO:
-                printf("\n\tOptions [%s]",
-                       bittok2str(ospf6_option_values, "none",
-                                  EXTRACT_32BITS(&op->ospf6_hello.hello_options)));
+	case OSPF_TYPE_HELLO: {
+		register const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
 
-                TCHECK(op->ospf6_hello.hello_deadint);
-                printf("\n\t  Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
-                       EXTRACT_16BITS(&op->ospf6_hello.hello_helloint),
-                       EXTRACT_16BITS(&op->ospf6_hello.hello_deadint),
-                       ipaddr_string(&op->ospf6_hello.hello_ifid),
-                       op->ospf6_hello.hello_priority);
+		ND_PRINT((ndo, "\n\tOptions [%s]",
+		          bittok2str(ospf6_option_values, "none",
+		          EXTRACT_32BITS(&hellop->hello_options))));
 
-		TCHECK(op->ospf6_hello.hello_dr);
-		if (op->ospf6_hello.hello_dr != 0)
-			printf("\n\t  Designated Router %s",
-			    ipaddr_string(&op->ospf6_hello.hello_dr));
-		TCHECK(op->ospf6_hello.hello_bdr);
-		if (op->ospf6_hello.hello_bdr != 0)
-			printf(", Backup Designated Router %s",
-			    ipaddr_string(&op->ospf6_hello.hello_bdr));
-		if (vflag) {
-			printf("\n\t  Neighbor List:");
-			ap = op->ospf6_hello.hello_neighbor;
+		ND_TCHECK(hellop->hello_deadint);
+		ND_PRINT((ndo, "\n\t  Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
+		          EXTRACT_16BITS(&hellop->hello_helloint),
+		          EXTRACT_16BITS(&hellop->hello_deadint),
+		          ipaddr_string(ndo, &hellop->hello_ifid),
+		          hellop->hello_priority));
+
+		ND_TCHECK(hellop->hello_dr);
+		if (EXTRACT_32BITS(&hellop->hello_dr) != 0)
+			ND_PRINT((ndo, "\n\t  Designated Router %s",
+			    ipaddr_string(ndo, &hellop->hello_dr)));
+		ND_TCHECK(hellop->hello_bdr);
+		if (EXTRACT_32BITS(&hellop->hello_bdr) != 0)
+			ND_PRINT((ndo, ", Backup Designated Router %s",
+			    ipaddr_string(ndo, &hellop->hello_bdr)));
+		if (ndo->ndo_vflag > 1) {
+			ND_PRINT((ndo, "\n\t  Neighbor List:"));
+			ap = hellop->hello_neighbor;
 			while ((u_char *)ap < dataend) {
-				TCHECK(*ap);
-				printf("\n\t    %s", ipaddr_string(ap));
+				ND_TCHECK(*ap);
+				ND_PRINT((ndo, "\n\t    %s", ipaddr_string(ndo, ap)));
 				++ap;
 			}
 		}
 		break;	/* HELLO */
+	}
 
-	case OSPF_TYPE_DD:
-		TCHECK(op->ospf6_db.db_options);
-                printf("\n\tOptions [%s]",
-                       bittok2str(ospf6_option_values, "none",
-                                  EXTRACT_32BITS(&op->ospf6_db.db_options)));
-		TCHECK(op->ospf6_db.db_flags);
-                printf(", DD Flags [%s]",
-                       bittok2str(ospf6_dd_flag_values,"none",op->ospf6_db.db_flags));
+	case OSPF_TYPE_DD: {
+		register const struct dd6 *ddp = (const struct dd6 *)((uint8_t *)op + OSPF6HDR_LEN);
 
-		TCHECK(op->ospf6_db.db_seq);
-		printf(", MTU %u, DD-Sequence 0x%08x",
-                       EXTRACT_16BITS(&op->ospf6_db.db_mtu),
-                       EXTRACT_32BITS(&op->ospf6_db.db_seq));
+		ND_TCHECK(ddp->db_options);
+		ND_PRINT((ndo, "\n\tOptions [%s]",
+		          bittok2str(ospf6_option_values, "none",
+		          EXTRACT_32BITS(&ddp->db_options))));
+		ND_TCHECK(ddp->db_flags);
+		ND_PRINT((ndo, ", DD Flags [%s]",
+		          bittok2str(ospf6_dd_flag_values,"none",ddp->db_flags)));
 
-                /* Print all the LS adv's */
-                lshp = op->ospf6_db.db_lshdr;
-                while (!ospf6_print_lshdr(lshp)) {
-                    ++lshp;
-                }
+		ND_TCHECK(ddp->db_seq);
+		ND_PRINT((ndo, ", MTU %u, DD-Sequence 0x%08x",
+                       EXTRACT_16BITS(&ddp->db_mtu),
+                       EXTRACT_32BITS(&ddp->db_seq)));
+		if (ndo->ndo_vflag > 1) {
+			/* Print all the LS adv's */
+			lshp = ddp->db_lshdr;
+			while ((u_char *)lshp < dataend) {
+				if (ospf6_print_lshdr(ndo, lshp++, dataend))
+					goto trunc;
+			}
+		}
 		break;
+	}
 
 	case OSPF_TYPE_LS_REQ:
-		if (vflag) {
-			lsrp = op->ospf6_lsr;
+		if (ndo->ndo_vflag > 1) {
+			lsrp = (const struct lsr6 *)((uint8_t *)op + OSPF6HDR_LEN);
 			while ((u_char *)lsrp < dataend) {
-				TCHECK(*lsrp);
-                                printf("\n\t  Advertising Router %s",
-                                       ipaddr_string(&lsrp->ls_router));
-				ospf6_print_ls_type(EXTRACT_16BITS(&lsrp->ls_type),
+				ND_TCHECK(*lsrp);
+				ND_PRINT((ndo, "\n\t  Advertising Router %s",
+				          ipaddr_string(ndo, &lsrp->ls_router)));
+				ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lsrp->ls_type),
                                                     &lsrp->ls_stateid);
 				++lsrp;
 			}
@@ -546,12 +806,14 @@
 		break;
 
 	case OSPF_TYPE_LS_UPDATE:
-		if (vflag) {
-			lsap = op->ospf6_lsu.lsu_lsa;
-			TCHECK(op->ospf6_lsu.lsu_count);
-			i = EXTRACT_32BITS(&op->ospf6_lsu.lsu_count);
-			while (i--) {
-				if (ospf6_print_lsa(lsap))
+		if (ndo->ndo_vflag > 1) {
+			register const struct lsu6 *lsup = (const struct lsu6 *)((uint8_t *)op + OSPF6HDR_LEN);
+
+			ND_TCHECK(lsup->lsu_count);
+			i = EXTRACT_32BITS(&lsup->lsu_count);
+			lsap = lsup->lsu_lsa;
+			while ((u_char *)lsap < dataend && i--) {
+				if (ospf6_print_lsa(ndo, lsap, dataend))
 					goto trunc;
 				lsap = (struct lsa6 *)((u_char *)lsap +
 				    EXTRACT_16BITS(&lsap->ls_hdr.ls_length));
@@ -559,13 +821,12 @@
 		}
 		break;
 
-
 	case OSPF_TYPE_LS_ACK:
-		if (vflag) {
-			lshp = op->ospf6_lsa.lsa_lshdr;
-
-			while (!ospf6_print_lshdr(lshp)) {
-				++lshp;
+		if (ndo->ndo_vflag > 1) {
+			lshp = (const struct lsa6_hdr *)((uint8_t *)op + OSPF6HDR_LEN);
+			while ((u_char *)lshp < dataend) {
+				if (ospf6_print_lshdr(ndo, lshp++, dataend))
+					goto trunc;
 			}
 		}
 		break;
@@ -578,63 +839,171 @@
 	return (1);
 }
 
+/* RFC5613 Section 2.2 (w/o the TLVs) */
+static int
+ospf6_print_lls(netdissect_options *ndo,
+                const u_char *cp, const u_int len)
+{
+	uint16_t llsdatalen;
+
+	if (len == 0)
+		return 0;
+	if (len < OSPF_LLS_HDRLEN)
+		goto trunc;
+	/* Checksum */
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, "\n\tLLS Checksum 0x%04x", EXTRACT_16BITS(cp)));
+	cp += 2;
+	/* LLS Data Length */
+	ND_TCHECK2(*cp, 2);
+	llsdatalen = EXTRACT_16BITS(cp);
+	ND_PRINT((ndo, ", Data Length %u", llsdatalen));
+	if (llsdatalen < OSPF_LLS_HDRLEN || llsdatalen > len)
+		goto trunc;
+	cp += 2;
+	/* LLS TLVs */
+	ND_TCHECK2(*cp, llsdatalen - OSPF_LLS_HDRLEN);
+	/* FIXME: code in print-ospf.c can be reused to decode the TLVs */
+
+	return llsdatalen;
+trunc:
+	return -1;
+}
+
+/* RFC6506 Section 4.1 */
+static int
+ospf6_decode_at(netdissect_options *ndo,
+                const u_char *cp, const u_int len)
+{
+	uint16_t authdatalen;
+
+	if (len == 0)
+		return 0;
+	if (len < OSPF6_AT_HDRLEN)
+		goto trunc;
+	/* Authentication Type */
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, "\n\tAuthentication Type %s", tok2str(ospf6_auth_type_str, "unknown (0x%04x)", EXTRACT_16BITS(cp))));
+	cp += 2;
+	/* Auth Data Len */
+	ND_TCHECK2(*cp, 2);
+	authdatalen = EXTRACT_16BITS(cp);
+	ND_PRINT((ndo, ", Length %u", authdatalen));
+	if (authdatalen < OSPF6_AT_HDRLEN || authdatalen > len)
+		goto trunc;
+	cp += 2;
+	/* Reserved */
+	ND_TCHECK2(*cp, 2);
+	cp += 2;
+	/* Security Association ID */
+	ND_TCHECK2(*cp, 2);
+	ND_PRINT((ndo, ", SAID %u", EXTRACT_16BITS(cp)));
+	cp += 2;
+	/* Cryptographic Sequence Number (High-Order 32 Bits) */
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ", CSN 0x%08x", EXTRACT_32BITS(cp)));
+	cp += 4;
+	/* Cryptographic Sequence Number (Low-Order 32 Bits) */
+	ND_TCHECK2(*cp, 4);
+	ND_PRINT((ndo, ":%08x", EXTRACT_32BITS(cp)));
+	cp += 4;
+	/* Authentication Data */
+	ND_TCHECK2(*cp, authdatalen - OSPF6_AT_HDRLEN);
+	if (ndo->ndo_vflag > 1)
+		print_unknown_data(ndo,cp, "\n\tAuthentication Data ", authdatalen - OSPF6_AT_HDRLEN);
+	return 0;
+
+trunc:
+	return 1;
+}
+
+/* The trailing data may include LLS and/or AT data (in this specific order).
+ * LLS data may be present only in Hello and DBDesc packets with the L-bit set.
+ * AT data may be present in Hello and DBDesc packets with the AT-bit set or in
+ * any other packet type, thus decode the AT data regardless of the AT-bit.
+ */
+static int
+ospf6_decode_v3_trailer(netdissect_options *ndo,
+                        const struct ospf6hdr *op, const u_char *cp, const unsigned len)
+{
+	int llslen = 0;
+	int lls_hello = 0;
+	int lls_dd = 0;
+
+	if (op->ospf6_type == OSPF_TYPE_HELLO) {
+		const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
+		if (EXTRACT_32BITS(&hellop->hello_options) & OSPF6_OPTION_L)
+			lls_hello = 1;
+	} else if (op->ospf6_type == OSPF_TYPE_DD) {
+		const struct dd6 *ddp = (const struct dd6 *)((uint8_t *)op + OSPF6HDR_LEN);
+		if (EXTRACT_32BITS(&ddp->db_options) & OSPF6_OPTION_L)
+			lls_dd = 1;
+	}
+	if ((lls_hello || lls_dd) && (llslen = ospf6_print_lls(ndo, cp, len)) < 0)
+		goto trunc;
+	return ospf6_decode_at(ndo, cp + llslen, len - llslen);
+
+trunc:
+	return 1;
+}
+
 void
-ospf6_print(register const u_char *bp, register u_int length)
+ospf6_print(netdissect_options *ndo,
+            register const u_char *bp, register u_int length)
 {
 	register const struct ospf6hdr *op;
 	register const u_char *dataend;
 	register const char *cp;
+	uint16_t datalen;
 
 	op = (struct ospf6hdr *)bp;
 
 	/* If the type is valid translate it, or just print the type */
 	/* value.  If it's not valid, say so and return */
-	TCHECK(op->ospf6_type);
-	cp = tok2str(ospf6_type_values, "unknown LS-type", op->ospf6_type);
-	printf("OSPFv%u, %s, length %d", op->ospf6_version, cp, length);
+	ND_TCHECK(op->ospf6_type);
+	cp = tok2str(ospf6_type_values, "unknown packet type (%u)", op->ospf6_type);
+	ND_PRINT((ndo, "OSPFv%u, %s, length %d", op->ospf6_version, cp, length));
 	if (*cp == 'u') {
 		return;
-        }
+	}
 
-        if(!vflag) { /* non verbose - so lets bail out here */
-                return;
-        }
-
-	TCHECK(op->ospf6_len);
-	if (length != EXTRACT_16BITS(&op->ospf6_len)) {
-		printf(" [len %d]", EXTRACT_16BITS(&op->ospf6_len));
+	if(!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
 		return;
 	}
-	dataend = bp + length;
 
-	/* Print the routerid if it is not the same as the source */
-	TCHECK(op->ospf6_routerid);
-	printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf6_routerid));
+	/* OSPFv3 data always comes first and optional trailing data may follow. */
+	ND_TCHECK(op->ospf6_len);
+	datalen = EXTRACT_16BITS(&op->ospf6_len);
+	if (datalen > length) {
+		ND_PRINT((ndo, " [len %d]", datalen));
+		return;
+	}
+	dataend = bp + datalen;
 
-	TCHECK(op->ospf6_areaid);
-	if (op->ospf6_areaid != 0)
-		printf(", Area %s", ipaddr_string(&op->ospf6_areaid));
+	ND_TCHECK(op->ospf6_routerid);
+	ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf6_routerid)));
+
+	ND_TCHECK(op->ospf6_areaid);
+	if (EXTRACT_32BITS(&op->ospf6_areaid) != 0)
+		ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf6_areaid)));
 	else
-		printf(", Backbone Area");
-	TCHECK(op->ospf6_instanceid);
+		ND_PRINT((ndo, ", Backbone Area"));
+	ND_TCHECK(op->ospf6_instanceid);
 	if (op->ospf6_instanceid)
-		printf(", Instance %u", op->ospf6_instanceid);
+		ND_PRINT((ndo, ", Instance %u", op->ospf6_instanceid));
 
 	/* Do rest according to version.	 */
 	switch (op->ospf6_version) {
 
 	case 3:
 		/* ospf version 3 */
-		if (ospf6_decode_v3(op, dataend))
+		if (ospf6_decode_v3(ndo, op, dataend) ||
+		    ospf6_decode_v3_trailer(ndo, op, dataend, length - datalen))
 			goto trunc;
 		break;
-
-	default:
-		printf(" ospf [version %d]", op->ospf6_version);
-		break;
 	}			/* end switch on version */
 
 	return;
 trunc:
-	fputs(tstr, stdout);
+	ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-otv.c b/print-otv.c
index cd53957..53a79de 100644
--- a/print-otv.c
+++ b/print-otv.c
@@ -13,20 +13,15 @@
  * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
-
-#include "udp.h"
 
 /*
  * OTV header, draft-hasmit-otv-04
@@ -41,14 +36,14 @@
  */
 
 void
-otv_print(const u_char *bp, u_int len)
+otv_print(netdissect_options *ndo, const u_char *bp, u_int len)
 {
-    u_int8_t flags;
-    u_int32_t overlay_id;
-    u_int32_t instance_id;
-    
+    uint8_t flags;
+    uint32_t overlay_id;
+    uint32_t instance_id;
+
     if (len < 8) {
-        printf("[|OTV]");
+        ND_PRINT((ndo, "[|OTV]"));
         return;
     }
 
@@ -61,19 +56,10 @@
     instance_id = EXTRACT_24BITS(bp);
     bp += 4;
 
-    printf("OTV, ");
+    ND_PRINT((ndo, "OTV, "));
+    ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
+    ND_PRINT((ndo, "overlay %u, ", overlay_id));
+    ND_PRINT((ndo, "instance %u\n", instance_id));
 
-    fputs("flags [", stdout);
-    if (flags & 0x08)
-        fputs("I", stdout);
-    else
-        fputs(".", stdout);
-    fputs("] ", stdout);
-
-    printf("(0x%02x), ", flags);
-    printf("overlay %u, ", overlay_id);
-    printf("instance %u\n", instance_id);
-
-    ether_print(gndo, bp, len - 8, len - 8, NULL, NULL);
-    return;
+    ether_print(ndo, bp, len - 8, len - 8, NULL, NULL);
 }
diff --git a/print-pflog.c b/print-pflog.c
index 8a3b66a..72ae276 100644
--- a/print-pflog.c
+++ b/print-pflog.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.16 2007-09-12 19:36:18 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -39,12 +35,10 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
-#include "extract.h"
 #include "interface.h"
-#include "addrtoname.h"
+#include "extract.h"
+
+static const char tstr[] = "[|pflog]";
 
 static const struct tok pf_reasons[] = {
 	{ 0,	"0(match)" },
@@ -91,58 +85,59 @@
 #define	OPENBSD_AF_INET6	24
 
 static void
-pflog_print(const struct pfloghdr *hdr)
+pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
 {
-	u_int32_t rulenr, subrulenr;
+	uint32_t rulenr, subrulenr;
 
 	rulenr = EXTRACT_32BITS(&hdr->rulenr);
 	subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
-	if (subrulenr == (u_int32_t)-1)
-		printf("rule %u/", rulenr);
+	if (subrulenr == (uint32_t)-1)
+		ND_PRINT((ndo, "rule %u/", rulenr));
 	else
-		printf("rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr);
+		ND_PRINT((ndo, "rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr));
 
-	printf("%s: %s %s on %s: ",
+	ND_PRINT((ndo, "%s: %s %s on %s: ",
 	    tok2str(pf_reasons, "unkn(%u)", hdr->reason),
 	    tok2str(pf_actions, "unkn(%u)", hdr->action),
 	    tok2str(pf_directions, "unkn(%u)", hdr->dir),
-	    hdr->ifname);
+	    hdr->ifname));
 }
 
 u_int
-pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+               register const u_char *p)
 {
 	u_int length = h->len;
 	u_int hdrlen;
 	u_int caplen = h->caplen;
 	const struct pfloghdr *hdr;
-	u_int8_t af;
+	uint8_t af;
 
 	/* check length */
-	if (caplen < sizeof(u_int8_t)) {
-		printf("[|pflog]");
+	if (caplen < sizeof(uint8_t)) {
+		ND_PRINT((ndo, "%s", tstr));
 		return (caplen);
 	}
 
 #define MIN_PFLOG_HDRLEN	45
 	hdr = (struct pfloghdr *)p;
 	if (hdr->length < MIN_PFLOG_HDRLEN) {
-		printf("[pflog: invalid header length!]");
+		ND_PRINT((ndo, "[pflog: invalid header length!]"));
 		return (hdr->length);	/* XXX: not really */
 	}
 	hdrlen = BPF_WORDALIGN(hdr->length);
 
 	if (caplen < hdrlen) {
-		printf("[|pflog]");
+		ND_PRINT((ndo, "%s", tstr));
 		return (hdrlen);	/* XXX: true? */
 	}
 
 	/* print what we know */
 	hdr = (struct pfloghdr *)p;
-	TCHECK(*hdr);
-	if (eflag)
-		pflog_print(hdr);
-	
+	ND_TCHECK(*hdr);
+	if (ndo->ndo_eflag)
+		pflog_print(ndo, hdr);
+
 	/* skip to the real packet */
 	af = hdr->af;
 	length -= hdrlen;
@@ -154,29 +149,31 @@
 #if OPENBSD_AF_INET != AF_INET
 		case OPENBSD_AF_INET:		/* XXX: read pcap files */
 #endif
-		        ip_print(gndo, p, length);
+		        ip_print(ndo, p, length);
 			break;
 
-#ifdef INET6
+#if defined(AF_INET6) || defined(OPENBSD_AF_INET6)
+#ifdef AF_INET6
 		case AF_INET6:
-#if OPENBSD_AF_INET6 != AF_INET6
+#endif /* AF_INET6 */
+#if !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6
 		case OPENBSD_AF_INET6:		/* XXX: read pcap files */
-#endif
-			ip6_print(gndo, p, length);
+#endif /* !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6 */
+			ip6_print(ndo, p, length);
 			break;
-#endif
+#endif /* defined(AF_INET6) || defined(OPENBSD_AF_INET6) */
 
 	default:
 		/* address family not handled, print raw packet */
-		if (!eflag)
-			pflog_print(hdr);
-		if (!suppress_default_print)
-			default_print(p, caplen);
+		if (!ndo->ndo_eflag)
+			pflog_print(ndo, hdr);
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
 	}
-	
+
 	return (hdrlen);
 trunc:
-	printf("[|pflog]");
+	ND_PRINT((ndo, "%s", tstr));
 	return (hdrlen);
 }
 
diff --git a/print-pgm.c b/print-pgm.c
index b6138c6..6a83425 100644
--- a/print-pgm.c
+++ b/print-pgm.c
@@ -13,21 +13,13 @@
  * Original code by Andy Heffernan (ahh@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.5 2005-06-07 22:05:58 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -37,67 +29,68 @@
 #include "ip6.h"
 #endif
 #include "ipproto.h"
+#include "af.h"
 
 /*
  * PGM header (RFC 3208)
  */
 struct pgm_header {
-    u_int16_t	pgm_sport;
-    u_int16_t	pgm_dport;
-    u_int8_t	pgm_type;
-    u_int8_t	pgm_options;
-    u_int16_t	pgm_sum;
-    u_int8_t	pgm_gsid[6];
-    u_int16_t	pgm_length;
+    uint16_t	pgm_sport;
+    uint16_t	pgm_dport;
+    uint8_t	pgm_type;
+    uint8_t	pgm_options;
+    uint16_t	pgm_sum;
+    uint8_t	pgm_gsid[6];
+    uint16_t	pgm_length;
 };
 
 struct pgm_spm {
-    u_int32_t	pgms_seq;
-    u_int32_t	pgms_trailseq;
-    u_int32_t	pgms_leadseq;
-    u_int16_t	pgms_nla_afi;
-    u_int16_t	pgms_reserved;
-    /* ... u_int8_t	pgms_nla[0]; */
+    uint32_t	pgms_seq;
+    uint32_t	pgms_trailseq;
+    uint32_t	pgms_leadseq;
+    uint16_t	pgms_nla_afi;
+    uint16_t	pgms_reserved;
+    /* ... uint8_t	pgms_nla[0]; */
     /* ... options */
 };
 
 struct pgm_nak {
-    u_int32_t	pgmn_seq;
-    u_int16_t	pgmn_source_afi;
-    u_int16_t	pgmn_reserved;
-    /* ... u_int8_t	pgmn_source[0]; */
-    /* ... u_int16_t	pgmn_group_afi */
-    /* ... u_int16_t	pgmn_reserved2; */
-    /* ... u_int8_t	pgmn_group[0]; */
+    uint32_t	pgmn_seq;
+    uint16_t	pgmn_source_afi;
+    uint16_t	pgmn_reserved;
+    /* ... uint8_t	pgmn_source[0]; */
+    /* ... uint16_t	pgmn_group_afi */
+    /* ... uint16_t	pgmn_reserved2; */
+    /* ... uint8_t	pgmn_group[0]; */
     /* ... options */
 };
 
 struct pgm_ack {
-    u_int32_t	pgma_rx_max_seq;
-    u_int32_t	pgma_bitmap;
+    uint32_t	pgma_rx_max_seq;
+    uint32_t	pgma_bitmap;
     /* ... options */
 };
 
 struct pgm_poll {
-    u_int32_t	pgmp_seq;
-    u_int16_t	pgmp_round;
-    u_int16_t	pgmp_reserved;
+    uint32_t	pgmp_seq;
+    uint16_t	pgmp_round;
+    uint16_t	pgmp_reserved;
     /* ... options */
 };
 
 struct pgm_polr {
-    u_int32_t	pgmp_seq;
-    u_int16_t	pgmp_round;
-    u_int16_t	pgmp_subtype;
-    u_int16_t	pgmp_nla_afi;
-    u_int16_t	pgmp_reserved;
-    /* ... u_int8_t	pgmp_nla[0]; */
+    uint32_t	pgmp_seq;
+    uint16_t	pgmp_round;
+    uint16_t	pgmp_subtype;
+    uint16_t	pgmp_nla_afi;
+    uint16_t	pgmp_reserved;
+    /* ... uint8_t	pgmp_nla[0]; */
     /* ... options */
 };
 
 struct pgm_data {
-    u_int32_t	pgmd_seq;
-    u_int32_t	pgmd_trailseq;
+    uint32_t	pgmd_seq;
+    uint32_t	pgmd_trailseq;
     /* ... options */
 };
 
@@ -142,26 +135,22 @@
 
 #define PGM_OPT_PGMCC_DATA	0x12
 #define PGM_OPT_PGMCC_FEEDBACK	0x13
-     
+
 #define PGM_OPT_MASK		0x7f
 
 #define PGM_OPT_END		0x80    /* end of options marker */
 
 #define PGM_MIN_OPT_LEN		4
 
-#ifndef AFI_IP
-#define AFI_IP		1
-#define AFI_IP6	        2
-#endif
-
 void
-pgm_print(register const u_char *bp, register u_int length,
-	  register const u_char *bp2)
+pgm_print(netdissect_options *ndo,
+          register const u_char *bp, register u_int length,
+          register const u_char *bp2)
 {
 	register const struct pgm_header *pgm;
 	register const struct ip *ip;
 	register char ch;
-	u_int16_t sport, dport;
+	uint16_t sport, dport;
 	int addr_size;
 	const void *nla;
 	int nla_af;
@@ -171,8 +160,8 @@
 #else
 	char nla_buf[INET_ADDRSTRLEN];
 #endif
-	u_int8_t opt_type, opt_len;
-	u_int32_t seq, opts_len, len, offset;
+	uint8_t opt_type, opt_len;
+	uint32_t seq, opts_len, len, offset;
 
 	pgm = (struct pgm_header *)bp;
 	ip = (struct ip *)bp2;
@@ -183,24 +172,24 @@
 		ip6 = NULL;
 #else /* INET6 */
 	if (IP_V(ip) == 6) {
-		(void)printf("Can't handle IPv6");
+		ND_PRINT((ndo, "Can't handle IPv6"));
 		return;
 	}
 #endif /* INET6 */
 	ch = '\0';
-	if (!TTEST(pgm->pgm_dport)) {
+	if (!ND_TTEST(pgm->pgm_dport)) {
 #ifdef INET6
 		if (ip6) {
-			(void)printf("%s > %s: [|pgm]",
-				ip6addr_string(&ip6->ip6_src),
-				ip6addr_string(&ip6->ip6_dst));
+			ND_PRINT((ndo, "%s > %s: [|pgm]",
+				ip6addr_string(ndo, &ip6->ip6_src),
+				ip6addr_string(ndo, &ip6->ip6_dst)));
 			return;
 		} else
 #endif /* INET6 */
 		{
-			(void)printf("%s > %s: [|pgm]",
-				ipaddr_string(&ip->ip_src),
-				ipaddr_string(&ip->ip_dst));
+			ND_PRINT((ndo, "%s > %s: [|pgm]",
+				ipaddr_string(ndo, &ip->ip_src),
+				ipaddr_string(ndo, &ip->ip_dst)));
 			return;
 		}
 	}
@@ -211,58 +200,58 @@
 #ifdef INET6
 	if (ip6) {
 		if (ip6->ip6_nxt == IPPROTO_PGM) {
-			(void)printf("%s.%s > %s.%s: ",
-				ip6addr_string(&ip6->ip6_src),
+			ND_PRINT((ndo, "%s.%s > %s.%s: ",
+				ip6addr_string(ndo, &ip6->ip6_src),
 				tcpport_string(sport),
-				ip6addr_string(&ip6->ip6_dst),
-				tcpport_string(dport));
+				ip6addr_string(ndo, &ip6->ip6_dst),
+				tcpport_string(dport)));
 		} else {
-			(void)printf("%s > %s: ",
-				tcpport_string(sport), tcpport_string(dport));
+			ND_PRINT((ndo, "%s > %s: ",
+				tcpport_string(sport), tcpport_string(dport)));
 		}
 	} else
 #endif /*INET6*/
 	{
 		if (ip->ip_p == IPPROTO_PGM) {
-			(void)printf("%s.%s > %s.%s: ",
-				ipaddr_string(&ip->ip_src),
+			ND_PRINT((ndo, "%s.%s > %s.%s: ",
+				ipaddr_string(ndo, &ip->ip_src),
 				tcpport_string(sport),
-				ipaddr_string(&ip->ip_dst),
-				tcpport_string(dport));
+				ipaddr_string(ndo, &ip->ip_dst),
+				tcpport_string(dport)));
 		} else {
-			(void)printf("%s > %s: ",
-				tcpport_string(sport), tcpport_string(dport));
+			ND_PRINT((ndo, "%s > %s: ",
+				tcpport_string(sport), tcpport_string(dport)));
 		}
 	}
 
-	TCHECK(*pgm);
+	ND_TCHECK(*pgm);
 
-        (void)printf("PGM, length %u", EXTRACT_16BITS(&pgm->pgm_length));
+        ND_PRINT((ndo, "PGM, length %u", EXTRACT_16BITS(&pgm->pgm_length)));
 
-        if (!vflag)
+        if (!ndo->ndo_vflag)
             return;
 
-	(void)printf(" 0x%02x%02x%02x%02x%02x%02x ",
+	ND_PRINT((ndo, " 0x%02x%02x%02x%02x%02x%02x ",
 		     pgm->pgm_gsid[0],
                      pgm->pgm_gsid[1],
                      pgm->pgm_gsid[2],
 		     pgm->pgm_gsid[3],
                      pgm->pgm_gsid[4],
-                     pgm->pgm_gsid[5]);
+                     pgm->pgm_gsid[5]));
 	switch (pgm->pgm_type) {
 	case PGM_SPM: {
 	    struct pgm_spm *spm;
 
 	    spm = (struct pgm_spm *)(pgm + 1);
-	    TCHECK(*spm);
+	    ND_TCHECK(*spm);
 
 	    switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) {
-	    case AFI_IP:
+	    case AFNUM_INET:
 		addr_size = sizeof(struct in_addr);
 		nla_af = AF_INET;
 		break;
 #ifdef INET6
-	    case AFI_IP6:
+	    case AFNUM_INET6:
 		addr_size = sizeof(struct in6_addr);
 		nla_af = AF_INET6;
 		break;
@@ -272,16 +261,16 @@
 		break;
 	    }
 	    bp = (u_char *) (spm + 1);
-	    TCHECK2(*bp, addr_size);
+	    ND_TCHECK2(*bp, addr_size);
 	    nla = bp;
 	    bp += addr_size;
 
 	    inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-	    (void)printf("SPM seq %u trail %u lead %u nla %s",
+	    ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
 			 EXTRACT_32BITS(&spm->pgms_seq),
                          EXTRACT_32BITS(&spm->pgms_trailseq),
 			 EXTRACT_32BITS(&spm->pgms_leadseq),
-                         nla_buf);
+                         nla_buf));
 	    break;
 	}
 
@@ -289,27 +278,27 @@
 	    struct pgm_poll *poll;
 
 	    poll = (struct pgm_poll *)(pgm + 1);
-	    TCHECK(*poll);
-	    (void)printf("POLL seq %u round %u",
+	    ND_TCHECK(*poll);
+	    ND_PRINT((ndo, "POLL seq %u round %u",
 			 EXTRACT_32BITS(&poll->pgmp_seq),
-                         EXTRACT_16BITS(&poll->pgmp_round));
+                         EXTRACT_16BITS(&poll->pgmp_round)));
 	    bp = (u_char *) (poll + 1);
 	    break;
 	}
 	case PGM_POLR: {
 	    struct pgm_polr *polr;
-	    u_int32_t ivl, rnd, mask;
+	    uint32_t ivl, rnd, mask;
 
 	    polr = (struct pgm_polr *)(pgm + 1);
-	    TCHECK(*polr);
+	    ND_TCHECK(*polr);
 
 	    switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) {
-	    case AFI_IP:
+	    case AFNUM_INET:
 		addr_size = sizeof(struct in_addr);
 		nla_af = AF_INET;
 		break;
 #ifdef INET6
-	    case AFI_IP6:
+	    case AFNUM_INET6:
 		addr_size = sizeof(struct in6_addr);
 		nla_af = AF_INET6;
 		break;
@@ -319,37 +308,37 @@
 		break;
 	    }
 	    bp = (u_char *) (polr + 1);
-	    TCHECK2(*bp, addr_size);
+	    ND_TCHECK2(*bp, addr_size);
 	    nla = bp;
 	    bp += addr_size;
 
 	    inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
 
-	    TCHECK2(*bp, sizeof(u_int32_t));
+	    ND_TCHECK2(*bp, sizeof(uint32_t));
 	    ivl = EXTRACT_32BITS(bp);
-	    bp += sizeof(u_int32_t);
+	    bp += sizeof(uint32_t);
 
-	    TCHECK2(*bp, sizeof(u_int32_t));
+	    ND_TCHECK2(*bp, sizeof(uint32_t));
 	    rnd = EXTRACT_32BITS(bp);
-	    bp += sizeof(u_int32_t);
+	    bp += sizeof(uint32_t);
 
-	    TCHECK2(*bp, sizeof(u_int32_t));
+	    ND_TCHECK2(*bp, sizeof(uint32_t));
 	    mask = EXTRACT_32BITS(bp);
-	    bp += sizeof(u_int32_t);
+	    bp += sizeof(uint32_t);
 
-	    (void)printf("POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
+	    ND_PRINT((ndo, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
 			 "mask 0x%08x", EXTRACT_32BITS(&polr->pgmp_seq),
-			 EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask);
+			 EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask));
 	    break;
 	}
 	case PGM_ODATA: {
 	    struct pgm_data *odata;
 
 	    odata = (struct pgm_data *)(pgm + 1);
-	    TCHECK(*odata);
-	    (void)printf("ODATA trail %u seq %u",
+	    ND_TCHECK(*odata);
+	    ND_PRINT((ndo, "ODATA trail %u seq %u",
 			 EXTRACT_32BITS(&odata->pgmd_trailseq),
-			 EXTRACT_32BITS(&odata->pgmd_seq));
+			 EXTRACT_32BITS(&odata->pgmd_seq)));
 	    bp = (u_char *) (odata + 1);
 	    break;
 	}
@@ -358,10 +347,10 @@
 	    struct pgm_data *rdata;
 
 	    rdata = (struct pgm_data *)(pgm + 1);
-	    TCHECK(*rdata);
-	    (void)printf("RDATA trail %u seq %u",
+	    ND_TCHECK(*rdata);
+	    ND_PRINT((ndo, "RDATA trail %u seq %u",
 			 EXTRACT_32BITS(&rdata->pgmd_trailseq),
-			 EXTRACT_32BITS(&rdata->pgmd_seq));
+			 EXTRACT_32BITS(&rdata->pgmd_seq)));
 	    bp = (u_char *) (rdata + 1);
 	    break;
 	}
@@ -379,19 +368,19 @@
 #endif
 
 	    nak = (struct pgm_nak *)(pgm + 1);
-	    TCHECK(*nak);
+	    ND_TCHECK(*nak);
 
 	    /*
 	     * Skip past the source, saving info along the way
 	     * and stopping if we don't have enough.
 	     */
 	    switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) {
-	    case AFI_IP:
+	    case AFNUM_INET:
 		addr_size = sizeof(struct in_addr);
 		source_af = AF_INET;
 		break;
 #ifdef INET6
-	    case AFI_IP6:
+	    case AFNUM_INET6:
 		addr_size = sizeof(struct in6_addr);
 		source_af = AF_INET6;
 		break;
@@ -401,7 +390,7 @@
 		break;
 	    }
 	    bp = (u_char *) (nak + 1);
-	    TCHECK2(*bp, addr_size);
+	    ND_TCHECK2(*bp, addr_size);
 	    source = bp;
 	    bp += addr_size;
 
@@ -410,12 +399,12 @@
 	     * and stopping if we don't have enough.
 	     */
 	    switch (EXTRACT_16BITS(bp)) {
-	    case AFI_IP:
+	    case AFNUM_INET:
 		addr_size = sizeof(struct in_addr);
 		group_af = AF_INET;
 		break;
 #ifdef INET6
-	    case AFI_IP6:
+	    case AFNUM_INET6:
 		addr_size = sizeof(struct in6_addr);
 		group_af = AF_INET6;
 		break;
@@ -424,8 +413,8 @@
 		goto trunc;
 		break;
 	    }
-	    bp += (2 * sizeof(u_int16_t));
-	    TCHECK2(*bp, addr_size);
+	    bp += (2 * sizeof(uint16_t));
+	    ND_TCHECK2(*bp, addr_size);
 	    group = bp;
 	    bp += addr_size;
 
@@ -436,19 +425,19 @@
 	    inet_ntop(group_af, group, group_buf, sizeof(group_buf));
 	    switch (pgm->pgm_type) {
 		case PGM_NAK:
-		    (void)printf("NAK ");
+		    ND_PRINT((ndo, "NAK "));
 		    break;
 		case PGM_NULLNAK:
-		    (void)printf("NNAK ");
+		    ND_PRINT((ndo, "NNAK "));
 		    break;
 		case PGM_NCF:
-		    (void)printf("NCF ");
+		    ND_PRINT((ndo, "NCF "));
 		    break;
 		default:
                     break;
 	    }
-	    (void)printf("(%s -> %s), seq %u",
-			 source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq));
+	    ND_PRINT((ndo, "(%s -> %s), seq %u",
+			 source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq)));
 	    break;
 	}
 
@@ -456,31 +445,31 @@
 	    struct pgm_ack *ack;
 
 	    ack = (struct pgm_ack *)(pgm + 1);
-	    TCHECK(*ack);
-	    (void)printf("ACK seq %u",
-			 EXTRACT_32BITS(&ack->pgma_rx_max_seq));
+	    ND_TCHECK(*ack);
+	    ND_PRINT((ndo, "ACK seq %u",
+			 EXTRACT_32BITS(&ack->pgma_rx_max_seq)));
 	    bp = (u_char *) (ack + 1);
 	    break;
 	}
 
 	case PGM_SPMR:
-	    (void)printf("SPMR");
+	    ND_PRINT((ndo, "SPMR"));
 	    break;
 
 	default:
-	    (void)printf("UNKNOWN type 0x%02x", pgm->pgm_type);
+	    ND_PRINT((ndo, "UNKNOWN type 0x%02x", pgm->pgm_type));
 	    break;
 
 	}
-	if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {      
+	if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {
 
 	    /*
 	     * make sure there's enough for the first option header
 	     */
-	    if (!TTEST2(*bp, PGM_MIN_OPT_LEN)) {
-		(void)printf("[|OPT]");
+	    if (!ND_TTEST2(*bp, PGM_MIN_OPT_LEN)) {
+		ND_PRINT((ndo, "[|OPT]"));
 		return;
-	    } 
+	    }
 
 	    /*
 	     * That option header MUST be an OPT_LENGTH option
@@ -488,137 +477,137 @@
 	     */
 	    opt_type = *bp++;
 	    if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) {
-		(void)printf("[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK);
+		ND_PRINT((ndo, "[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK));
 		return;
 	    }
 	    opt_len = *bp++;
 	    if (opt_len != 4) {
-		(void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+		ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
 		return;
 	    }
 	    opts_len = EXTRACT_16BITS(bp);
 	    if (opts_len < 4) {
-		(void)printf("[Bad total option length %u < 4]", opts_len);
+		ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len));
 		return;
 	    }
-	    bp += sizeof(u_int16_t);
-	    (void)printf(" OPTS LEN %d", opts_len);
+	    bp += sizeof(uint16_t);
+	    ND_PRINT((ndo, " OPTS LEN %d", opts_len));
 	    opts_len -= 4;
 
 	    while (opts_len) {
 		if (opts_len < PGM_MIN_OPT_LEN) {
-		    (void)printf("[Total option length leaves no room for final option]");
+		    ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
 		    return;
 		}
 		opt_type = *bp++;
 		opt_len = *bp++;
 		if (opt_len < PGM_MIN_OPT_LEN) {
-		    (void)printf("[Bad option, length %u < %u]", opt_len,
-		        PGM_MIN_OPT_LEN);
+		    ND_PRINT((ndo, "[Bad option, length %u < %u]", opt_len,
+		        PGM_MIN_OPT_LEN));
 		    break;
 		}
 		if (opts_len < opt_len) {
-		    (void)printf("[Total option length leaves no room for final option]");
+		    ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
 		    return;
 		}
-		if (!TTEST2(*bp, opt_len - 2)) {
-		    (void)printf(" [|OPT]");
+		if (!ND_TTEST2(*bp, opt_len - 2)) {
+		    ND_PRINT((ndo, " [|OPT]"));
 		    return;
-		} 
+		}
 
 		switch (opt_type & PGM_OPT_MASK) {
 		case PGM_OPT_LENGTH:
 		    if (opt_len != 4) {
-			(void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
 			return;
 		    }
-		    (void)printf(" OPTS LEN (extra?) %d", EXTRACT_16BITS(bp));
-		    bp += sizeof(u_int16_t);
+		    ND_PRINT((ndo, " OPTS LEN (extra?) %d", EXTRACT_16BITS(bp)));
+		    bp += sizeof(uint16_t);
 		    opts_len -= 4;
 		    break;
 
 		case PGM_OPT_FRAGMENT:
 		    if (opt_len != 16) {
-			(void)printf("[Bad OPT_FRAGMENT option, length %u != 16]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_FRAGMENT option, length %u != 16]", opt_len));
 			return;
 		    }
 		    bp += 2;
 		    seq = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
+		    bp += sizeof(uint32_t);
 		    offset = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
+		    bp += sizeof(uint32_t);
 		    len = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
-		    (void)printf(" FRAG seq %u off %u len %u", seq, offset, len);
+		    bp += sizeof(uint32_t);
+		    ND_PRINT((ndo, " FRAG seq %u off %u len %u", seq, offset, len));
 		    opts_len -= 16;
 		    break;
 
 		case PGM_OPT_NAK_LIST:
 		    bp += 2;
-		    opt_len -= sizeof(u_int32_t);	/* option header */
-		    (void)printf(" NAK LIST");
+		    opt_len -= sizeof(uint32_t);	/* option header */
+		    ND_PRINT((ndo, " NAK LIST"));
 		    while (opt_len) {
-			if (opt_len < sizeof(u_int32_t)) {
-			    (void)printf("[Option length not a multiple of 4]");
+			if (opt_len < sizeof(uint32_t)) {
+			    ND_PRINT((ndo, "[Option length not a multiple of 4]"));
 			    return;
 			}
-			TCHECK2(*bp, sizeof(u_int32_t));
-			(void)printf(" %u", EXTRACT_32BITS(bp));
-			bp += sizeof(u_int32_t);
-			opt_len -= sizeof(u_int32_t);
-			opts_len -= sizeof(u_int32_t);
+			ND_TCHECK2(*bp, sizeof(uint32_t));
+			ND_PRINT((ndo, " %u", EXTRACT_32BITS(bp)));
+			bp += sizeof(uint32_t);
+			opt_len -= sizeof(uint32_t);
+			opts_len -= sizeof(uint32_t);
 		    }
 		    break;
 
 		case PGM_OPT_JOIN:
 		    if (opt_len != 8) {
-			(void)printf("[Bad OPT_JOIN option, length %u != 8]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_JOIN option, length %u != 8]", opt_len));
 			return;
 		    }
 		    bp += 2;
 		    seq = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
-		    (void)printf(" JOIN %u", seq);
+		    bp += sizeof(uint32_t);
+		    ND_PRINT((ndo, " JOIN %u", seq));
 		    opts_len -= 8;
 		    break;
 
 		case PGM_OPT_NAK_BO_IVL:
 		    if (opt_len != 12) {
-			(void)printf("[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len));
 			return;
 		    }
 		    bp += 2;
 		    offset = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
+		    bp += sizeof(uint32_t);
 		    seq = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
-		    (void)printf(" BACKOFF ivl %u ivlseq %u", offset, seq);
+		    bp += sizeof(uint32_t);
+		    ND_PRINT((ndo, " BACKOFF ivl %u ivlseq %u", offset, seq));
 		    opts_len -= 12;
 		    break;
 
 		case PGM_OPT_NAK_BO_RNG:
 		    if (opt_len != 12) {
-			(void)printf("[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len));
 			return;
 		    }
 		    bp += 2;
 		    offset = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
+		    bp += sizeof(uint32_t);
 		    seq = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
-		    (void)printf(" BACKOFF max %u min %u", offset, seq);
+		    bp += sizeof(uint32_t);
+		    ND_PRINT((ndo, " BACKOFF max %u min %u", offset, seq));
 		    opts_len -= 12;
 		    break;
 
 		case PGM_OPT_REDIRECT:
 		    bp += 2;
 		    switch (EXTRACT_16BITS(bp)) {
-		    case AFI_IP:
+		    case AFNUM_INET:
 			addr_size = sizeof(struct in_addr);
 			nla_af = AF_INET;
 			break;
 #ifdef INET6
-		    case AFI_IP6:
+		    case AFNUM_INET6:
 			addr_size = sizeof(struct in6_addr);
 			nla_af = AF_INET6;
 			break;
@@ -627,129 +616,129 @@
 			goto trunc;
 			break;
 		    }
-		    bp += (2 * sizeof(u_int16_t));
+		    bp += (2 * sizeof(uint16_t));
 		    if (opt_len != 4 + addr_size) {
-			(void)printf("[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
 			return;
 		    }
-		    TCHECK2(*bp, addr_size);
+		    ND_TCHECK2(*bp, addr_size);
 		    nla = bp;
 		    bp += addr_size;
 
 		    inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-		    (void)printf(" REDIRECT %s",  (char *)nla);
+		    ND_PRINT((ndo, " REDIRECT %s",  (char *)nla));
 		    opts_len -= 4 + addr_size;
 		    break;
 
 		case PGM_OPT_PARITY_PRM:
 		    if (opt_len != 8) {
-			(void)printf("[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len));
 			return;
 		    }
 		    bp += 2;
 		    len = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
-		    (void)printf(" PARITY MAXTGS %u", len);
+		    bp += sizeof(uint32_t);
+		    ND_PRINT((ndo, " PARITY MAXTGS %u", len));
 		    opts_len -= 8;
 		    break;
 
 		case PGM_OPT_PARITY_GRP:
 		    if (opt_len != 8) {
-			(void)printf("[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len));
 			return;
 		    }
 		    bp += 2;
 		    seq = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
-		    (void)printf(" PARITY GROUP %u", seq);
+		    bp += sizeof(uint32_t);
+		    ND_PRINT((ndo, " PARITY GROUP %u", seq));
 		    opts_len -= 8;
 		    break;
 
 		case PGM_OPT_CURR_TGSIZE:
 		    if (opt_len != 8) {
-			(void)printf("[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len));
 			return;
 		    }
 		    bp += 2;
 		    len = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
-		    (void)printf(" PARITY ATGS %u", len);
+		    bp += sizeof(uint32_t);
+		    ND_PRINT((ndo, " PARITY ATGS %u", len));
 		    opts_len -= 8;
 		    break;
 
 		case PGM_OPT_NBR_UNREACH:
 		    if (opt_len != 4) {
-			(void)printf("[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len));
 			return;
 		    }
 		    bp += 2;
-		    (void)printf(" NBR_UNREACH");
+		    ND_PRINT((ndo, " NBR_UNREACH"));
 		    opts_len -= 4;
 		    break;
 
 		case PGM_OPT_PATH_NLA:
-		    (void)printf(" PATH_NLA [%d]", opt_len);
+		    ND_PRINT((ndo, " PATH_NLA [%d]", opt_len));
 		    bp += opt_len;
 		    opts_len -= opt_len;
 		    break;
 
 		case PGM_OPT_SYN:
 		    if (opt_len != 4) {
-			(void)printf("[Bad OPT_SYN option, length %u != 4]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_SYN option, length %u != 4]", opt_len));
 			return;
 		    }
 		    bp += 2;
-		    (void)printf(" SYN");
+		    ND_PRINT((ndo, " SYN"));
 		    opts_len -= 4;
 		    break;
 
 		case PGM_OPT_FIN:
 		    if (opt_len != 4) {
-			(void)printf("[Bad OPT_FIN option, length %u != 4]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_FIN option, length %u != 4]", opt_len));
 			return;
 		    }
 		    bp += 2;
-		    (void)printf(" FIN");
+		    ND_PRINT((ndo, " FIN"));
 		    opts_len -= 4;
 		    break;
 
 		case PGM_OPT_RST:
 		    if (opt_len != 4) {
-			(void)printf("[Bad OPT_RST option, length %u != 4]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_RST option, length %u != 4]", opt_len));
 			return;
 		    }
 		    bp += 2;
-		    (void)printf(" RST");
+		    ND_PRINT((ndo, " RST"));
 		    opts_len -= 4;
 		    break;
 
 		case PGM_OPT_CR:
-		    (void)printf(" CR");
+		    ND_PRINT((ndo, " CR"));
 		    bp += opt_len;
 		    opts_len -= opt_len;
 		    break;
 
 		case PGM_OPT_CRQST:
 		    if (opt_len != 4) {
-			(void)printf("[Bad OPT_CRQST option, length %u != 4]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_CRQST option, length %u != 4]", opt_len));
 			return;
 		    }
 		    bp += 2;
-		    (void)printf(" CRQST");
+		    ND_PRINT((ndo, " CRQST"));
 		    opts_len -= 4;
 		    break;
 
 		case PGM_OPT_PGMCC_DATA:
 		    bp += 2;
 		    offset = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
+		    bp += sizeof(uint32_t);
 		    switch (EXTRACT_16BITS(bp)) {
-		    case AFI_IP:
+		    case AFNUM_INET:
 			addr_size = sizeof(struct in_addr);
 			nla_af = AF_INET;
 			break;
 #ifdef INET6
-		    case AFI_IP6:
+		    case AFNUM_INET6:
 			addr_size = sizeof(struct in6_addr);
 			nla_af = AF_INET6;
 			break;
@@ -758,31 +747,31 @@
 			goto trunc;
 			break;
 		    }
-		    bp += (2 * sizeof(u_int16_t));
+		    bp += (2 * sizeof(uint16_t));
 		    if (opt_len != 12 + addr_size) {
-			(void)printf("[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
 			return;
 		    }
-		    TCHECK2(*bp, addr_size);
+		    ND_TCHECK2(*bp, addr_size);
 		    nla = bp;
 		    bp += addr_size;
 
 		    inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-		    (void)printf(" PGMCC DATA %u %s", offset, (char*)nla);
+		    ND_PRINT((ndo, " PGMCC DATA %u %s", offset, (char*)nla));
 		    opts_len -= 16;
 		    break;
 
 		case PGM_OPT_PGMCC_FEEDBACK:
 		    bp += 2;
 		    offset = EXTRACT_32BITS(bp);
-		    bp += sizeof(u_int32_t);
+		    bp += sizeof(uint32_t);
 		    switch (EXTRACT_16BITS(bp)) {
-		    case AFI_IP:
+		    case AFNUM_INET:
 			addr_size = sizeof(struct in_addr);
 			nla_af = AF_INET;
 			break;
 #ifdef INET6
-		    case AFI_IP6:
+		    case AFNUM_INET6:
 			addr_size = sizeof(struct in6_addr);
 			nla_af = AF_INET6;
 			break;
@@ -791,22 +780,22 @@
 			goto trunc;
 			break;
 		    }
-		    bp += (2 * sizeof(u_int16_t));
+		    bp += (2 * sizeof(uint16_t));
 		    if (opt_len != 12 + addr_size) {
-			(void)printf("[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len);
+			ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len));
 			return;
 		    }
-		    TCHECK2(*bp, addr_size);
+		    ND_TCHECK2(*bp, addr_size);
 		    nla = bp;
 		    bp += addr_size;
 
 		    inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-		    (void)printf(" PGMCC FEEDBACK %u %s", offset, (char*)nla);
+		    ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, (char*)nla));
 		    opts_len -= 16;
 		    break;
 
 		default:
-		    (void)printf(" OPT_%02X [%d] ", opt_type, opt_len);
+		    ND_PRINT((ndo, " OPT_%02X [%d] ", opt_type, opt_len));
 		    bp += opt_len;
 		    opts_len -= opt_len;
 		    break;
@@ -817,15 +806,15 @@
 	     }
 	}
 
-	(void)printf(" [%u]", length);
-	if (packettype == PT_PGM_ZMTP1 &&
+	ND_PRINT((ndo, " [%u]", length));
+	if (ndo->ndo_packettype == PT_PGM_ZMTP1 &&
 	    (pgm->pgm_type == PGM_ODATA || pgm->pgm_type == PGM_RDATA))
-		zmtp1_print_datagram(bp, EXTRACT_16BITS(&pgm->pgm_length));
+		zmtp1_print_datagram(ndo, bp, EXTRACT_16BITS(&pgm->pgm_length));
 
 	return;
 
 trunc:
-	fputs("[|pgm]", stdout);
+	ND_PRINT((ndo, "[|pgm]"));
 	if (ch != '\0')
-		putchar('>');
+		ND_PRINT((ndo, ">"));
 }
diff --git a/print-pim.c b/print-pim.c
index 7136083..15f4c51 100644
--- a/print-pim.c
+++ b/print-pim.c
@@ -19,26 +19,40 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 
 #include "ip.h"
 
+#define PIMV1_TYPE_QUERY           0
+#define PIMV1_TYPE_REGISTER        1
+#define PIMV1_TYPE_REGISTER_STOP   2
+#define PIMV1_TYPE_JOIN_PRUNE      3
+#define PIMV1_TYPE_RP_REACHABILITY 4
+#define PIMV1_TYPE_ASSERT          5
+#define PIMV1_TYPE_GRAFT           6
+#define PIMV1_TYPE_GRAFT_ACK       7
+
+static const struct tok pimv1_type_str[] = {
+	{ PIMV1_TYPE_QUERY,           "Query"         },
+	{ PIMV1_TYPE_REGISTER,        "Register"      },
+	{ PIMV1_TYPE_REGISTER_STOP,   "Register-Stop" },
+	{ PIMV1_TYPE_JOIN_PRUNE,      "Join/Prune"    },
+	{ PIMV1_TYPE_RP_REACHABILITY, "RP-reachable"  },
+	{ PIMV1_TYPE_ASSERT,          "Assert"        },
+	{ PIMV1_TYPE_GRAFT,           "Graft"         },
+	{ PIMV1_TYPE_GRAFT_ACK,       "Graft-ACK"     },
+	{ 0, NULL }
+};
+
 #define PIMV2_TYPE_HELLO         0
 #define PIMV2_TYPE_REGISTER      1
 #define PIMV2_TYPE_REGISTER_STOP 2
@@ -49,6 +63,8 @@
 #define PIMV2_TYPE_GRAFT_ACK     7
 #define PIMV2_TYPE_CANDIDATE_RP  8
 #define PIMV2_TYPE_PRUNE_REFRESH 9
+#define PIMV2_TYPE_DF_ELECTION   10
+#define PIMV2_TYPE_ECMP_REDIRECT 11
 
 static const struct tok pimv2_type_values[] = {
     { PIMV2_TYPE_HELLO,         "Hello" },
@@ -61,6 +77,8 @@
     { PIMV2_TYPE_GRAFT_ACK,     "Graft Acknowledgement" },
     { PIMV2_TYPE_CANDIDATE_RP,  "Candidate RP Advertisement" },
     { PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
+    { PIMV2_TYPE_DF_ELECTION,   "DF Election" },
+    { PIMV2_TYPE_ECMP_REDIRECT, "ECMP Redirect" },
     { 0, NULL}
 };
 
@@ -95,7 +113,7 @@
     { PIMV2_REGISTER_FLAG_BORDER, "Border" },
     { PIMV2_REGISTER_FLAG_NULL, "Null" },
     { 0, NULL}
-};    
+};
 
 /*
  * XXX: We consider a case where IPv6 is not ready yet for portability,
@@ -103,7 +121,7 @@
  */
 
 struct pim {
-	u_int8_t pim_typever;
+	uint8_t pim_typever;
 			/* upper 4bit: PIM version number; 2 for PIMv2 */
 			/* lower 4bit: the PIM message type, currently they are:
 			 * Hello, Register, Register-Stop, Join/Prune,
@@ -116,52 +134,53 @@
 	u_short	pim_cksum;	/* IP style check sum */
 };
 
-static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
+static void pimv2_print(netdissect_options *, register const u_char *bp, register u_int len, u_int cksum);
 
 static void
-pimv1_join_prune_print(register const u_char *bp, register u_int len)
+pimv1_join_prune_print(netdissect_options *ndo,
+                       register const u_char *bp, register u_int len)
 {
 	int ngroups, njoin, nprune;
 	int njp;
 
 	/* If it's a single group and a single source, use 1-line output. */
-	if (TTEST2(bp[0], 30) && bp[11] == 1 &&
+	if (ND_TTEST2(bp[0], 30) && bp[11] == 1 &&
 	    ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
 		int hold;
 
-		(void)printf(" RPF %s ", ipaddr_string(bp));
+		ND_PRINT((ndo, " RPF %s ", ipaddr_string(ndo, bp)));
 		hold = EXTRACT_16BITS(&bp[6]);
 		if (hold != 180) {
-			(void)printf("Hold ");
-			relts_print(hold);
+			ND_PRINT((ndo, "Hold "));
+			relts_print(ndo, hold);
 		}
-		(void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
-		ipaddr_string(&bp[26]), bp[25] & 0x3f,
-		ipaddr_string(&bp[12]));
+		ND_PRINT((ndo, "%s (%s/%d, %s", njoin ? "Join" : "Prune",
+		ipaddr_string(ndo, &bp[26]), bp[25] & 0x3f,
+		ipaddr_string(ndo, &bp[12])));
 		if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
-			(void)printf("/%s", ipaddr_string(&bp[16]));
-		(void)printf(") %s%s %s",
+			ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[16])));
+		ND_PRINT((ndo, ") %s%s %s",
 		    (bp[24] & 0x01) ? "Sparse" : "Dense",
 		    (bp[25] & 0x80) ? " WC" : "",
-		    (bp[25] & 0x40) ? "RP" : "SPT");
+		    (bp[25] & 0x40) ? "RP" : "SPT"));
 		return;
 	}
 
-	TCHECK2(bp[0], sizeof(struct in_addr));
-	if (vflag > 1)
-		(void)printf("\n");
-	(void)printf(" Upstream Nbr: %s", ipaddr_string(bp));
-	TCHECK2(bp[6], 2);
-	if (vflag > 1)
-		(void)printf("\n");
-	(void)printf(" Hold time: ");
-	relts_print(EXTRACT_16BITS(&bp[6]));
-	if (vflag < 2)
+	ND_TCHECK2(bp[0], sizeof(struct in_addr));
+	if (ndo->ndo_vflag > 1)
+		ND_PRINT((ndo, "\n"));
+	ND_PRINT((ndo, " Upstream Nbr: %s", ipaddr_string(ndo, bp)));
+	ND_TCHECK2(bp[6], 2);
+	if (ndo->ndo_vflag > 1)
+		ND_PRINT((ndo, "\n"));
+	ND_PRINT((ndo, " Hold time: "));
+	relts_print(ndo, EXTRACT_16BITS(&bp[6]));
+	if (ndo->ndo_vflag < 2)
 		return;
 	bp += 8;
 	len -= 8;
 
-	TCHECK2(bp[0], 4);
+	ND_TCHECK2(bp[0], 4);
 	ngroups = bp[3];
 	bp += 4;
 	len -= 4;
@@ -170,15 +189,15 @@
 		 * XXX - does the address have length "addrlen" and the
 		 * mask length "maddrlen"?
 		 */
-		TCHECK2(bp[0], sizeof(struct in_addr));
-		(void)printf("\n\tGroup: %s", ipaddr_string(bp));
-		TCHECK2(bp[4], sizeof(struct in_addr));
+		ND_TCHECK2(bp[0], sizeof(struct in_addr));
+		ND_PRINT((ndo, "\n\tGroup: %s", ipaddr_string(ndo, bp)));
+		ND_TCHECK2(bp[4], sizeof(struct in_addr));
 		if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
-			(void)printf("/%s", ipaddr_string(&bp[4]));
-		TCHECK2(bp[8], 4);
+			ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[4])));
+		ND_TCHECK2(bp[8], 4);
 		njoin = EXTRACT_16BITS(&bp[8]);
 		nprune = EXTRACT_16BITS(&bp[10]);
-		(void)printf(" joined: %d pruned: %d", njoin, nprune);
+		ND_PRINT((ndo, " joined: %d pruned: %d", njoin, nprune));
 		bp += 12;
 		len -= 12;
 		for (njp = 0; njp < (njoin + nprune); njp++) {
@@ -188,127 +207,108 @@
 				type = "Join ";
 			else
 				type = "Prune";
-			TCHECK2(bp[0], 6);
-			(void)printf("\n\t%s %s%s%s%s/%d", type,
+			ND_TCHECK2(bp[0], 6);
+			ND_PRINT((ndo, "\n\t%s %s%s%s%s/%d", type,
 			    (bp[0] & 0x01) ? "Sparse " : "Dense ",
 			    (bp[1] & 0x80) ? "WC " : "",
 			    (bp[1] & 0x40) ? "RP " : "SPT ",
-			ipaddr_string(&bp[2]), bp[1] & 0x3f);
+			ipaddr_string(ndo, &bp[2]), bp[1] & 0x3f));
 			bp += 6;
 			len -= 6;
 		}
 	}
 	return;
 trunc:
-	(void)printf("[|pim]");
+	ND_PRINT((ndo, "[|pim]"));
 	return;
 }
 
 void
-pimv1_print(register const u_char *bp, register u_int len)
+pimv1_print(netdissect_options *ndo,
+            register const u_char *bp, register u_int len)
 {
 	register const u_char *ep;
 	register u_char type;
 
-	ep = (const u_char *)snapend;
+	ep = (const u_char *)ndo->ndo_snapend;
 	if (bp >= ep)
 		return;
 
-	TCHECK(bp[1]);
+	ND_TCHECK(bp[1]);
 	type = bp[1];
 
+	ND_PRINT((ndo, " %s", tok2str(pimv1_type_str, "[type %u]", type)));
 	switch (type) {
-	case 0:
-		(void)printf(" Query");
-		if (TTEST(bp[8])) {
+	case PIMV1_TYPE_QUERY:
+		if (ND_TTEST(bp[8])) {
 			switch (bp[8] >> 4) {
 			case 0:
-				(void)printf(" Dense-mode");
+				ND_PRINT((ndo, " Dense-mode"));
 				break;
 			case 1:
-				(void)printf(" Sparse-mode");
+				ND_PRINT((ndo, " Sparse-mode"));
 				break;
 			case 2:
-				(void)printf(" Sparse-Dense-mode");
+				ND_PRINT((ndo, " Sparse-Dense-mode"));
 				break;
 			default:
-				(void)printf(" mode-%d", bp[8] >> 4);
+				ND_PRINT((ndo, " mode-%d", bp[8] >> 4));
 				break;
 			}
 		}
-		if (vflag) {
-			TCHECK2(bp[10],2);
-			(void)printf(" (Hold-time ");
-			relts_print(EXTRACT_16BITS(&bp[10]));
-			(void)printf(")");
+		if (ndo->ndo_vflag) {
+			ND_TCHECK2(bp[10],2);
+			ND_PRINT((ndo, " (Hold-time "));
+			relts_print(ndo, EXTRACT_16BITS(&bp[10]));
+			ND_PRINT((ndo, ")"));
 		}
 		break;
 
-	case 1:
-		(void)printf(" Register");
-		TCHECK2(bp[8], 20);			/* ip header */
-		(void)printf(" for %s > %s", ipaddr_string(&bp[20]),
-		    ipaddr_string(&bp[24]));
+	case PIMV1_TYPE_REGISTER:
+		ND_TCHECK2(bp[8], 20);			/* ip header */
+		ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[20]),
+		    ipaddr_string(ndo, &bp[24])));
 		break;
-	case 2:
-		(void)printf(" Register-Stop");
-		TCHECK2(bp[12], sizeof(struct in_addr));
-		(void)printf(" for %s > %s", ipaddr_string(&bp[8]),
-		    ipaddr_string(&bp[12]));
+	case PIMV1_TYPE_REGISTER_STOP:
+		ND_TCHECK2(bp[12], sizeof(struct in_addr));
+		ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[8]),
+		    ipaddr_string(ndo, &bp[12])));
 		break;
-	case 3:
-		(void)printf(" Join/Prune");
-		if (vflag)
-			pimv1_join_prune_print(&bp[8], len - 8);
-		break;
-	case 4:
-		(void)printf(" RP-reachable");
-		if (vflag) {
-			TCHECK2(bp[22], 2);
-			(void)printf(" group %s",
-			ipaddr_string(&bp[8]));
+	case PIMV1_TYPE_RP_REACHABILITY:
+		if (ndo->ndo_vflag) {
+			ND_TCHECK2(bp[22], 2);
+			ND_PRINT((ndo, " group %s", ipaddr_string(ndo, &bp[8])));
 			if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
-				(void)printf("/%s", ipaddr_string(&bp[12]));
-			(void)printf(" RP %s hold ", ipaddr_string(&bp[16]));
-			relts_print(EXTRACT_16BITS(&bp[22]));
+				ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
+			ND_PRINT((ndo, " RP %s hold ", ipaddr_string(ndo, &bp[16])));
+			relts_print(ndo, EXTRACT_16BITS(&bp[22]));
 		}
 		break;
-	case 5:
-		(void)printf(" Assert");
-		TCHECK2(bp[16], sizeof(struct in_addr));
-		(void)printf(" for %s > %s", ipaddr_string(&bp[16]),
-		    ipaddr_string(&bp[8]));
+	case PIMV1_TYPE_ASSERT:
+		ND_TCHECK2(bp[16], sizeof(struct in_addr));
+		ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[16]),
+		    ipaddr_string(ndo, &bp[8])));
 		if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
-			(void)printf("/%s", ipaddr_string(&bp[12]));
-		TCHECK2(bp[24], 4);
-		(void)printf(" %s pref %d metric %d",
+			ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
+		ND_TCHECK2(bp[24], 4);
+		ND_PRINT((ndo, " %s pref %d metric %d",
 		    (bp[20] & 0x80) ? "RP-tree" : "SPT",
 		EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
-		EXTRACT_32BITS(&bp[24]));
+		EXTRACT_32BITS(&bp[24])));
 		break;
-	case 6:
-		(void)printf(" Graft");
-		if (vflag)
-			pimv1_join_prune_print(&bp[8], len - 8);
-		break;
-	case 7:
-		(void)printf(" Graft-ACK");
-		if (vflag)
-			pimv1_join_prune_print(&bp[8], len - 8);
-		break;
-	case 8:
-		(void)printf(" Mode");
-		break;
-	default:
-		(void)printf(" [type %d]", type);
+	case PIMV1_TYPE_JOIN_PRUNE:
+	case PIMV1_TYPE_GRAFT:
+	case PIMV1_TYPE_GRAFT_ACK:
+		if (ndo->ndo_vflag)
+			pimv1_join_prune_print(ndo, &bp[8], len - 8);
 		break;
 	}
 	if ((bp[4] >> 4) != 1)
-		(void)printf(" [v%d]", bp[4] >> 4);
+		ND_PRINT((ndo, " [v%d]", bp[4] >> 4));
 	return;
 
 trunc:
-	(void)printf("[|pim]");
+	ND_PRINT((ndo, "[|pim]"));
 	return;
 }
 
@@ -319,37 +319,38 @@
  * This implements version 1+, dated Sept 9, 1998.
  */
 void
-cisco_autorp_print(register const u_char *bp, register u_int len)
+cisco_autorp_print(netdissect_options *ndo,
+                   register const u_char *bp, register u_int len)
 {
 	int type;
 	int numrps;
 	int hold;
 
-	TCHECK(bp[0]);
-	(void)printf(" auto-rp ");
+	ND_TCHECK(bp[0]);
+	ND_PRINT((ndo, " auto-rp "));
 	type = bp[0];
 	switch (type) {
 	case 0x11:
-		(void)printf("candidate-advert");
+		ND_PRINT((ndo, "candidate-advert"));
 		break;
 	case 0x12:
-		(void)printf("mapping");
+		ND_PRINT((ndo, "mapping"));
 		break;
 	default:
-		(void)printf("type-0x%02x", type);
+		ND_PRINT((ndo, "type-0x%02x", type));
 		break;
 	}
 
-	TCHECK(bp[1]);
+	ND_TCHECK(bp[1]);
 	numrps = bp[1];
 
-	TCHECK2(bp[2], 2);
-	(void)printf(" Hold ");
+	ND_TCHECK2(bp[2], 2);
+	ND_PRINT((ndo, " Hold "));
 	hold = EXTRACT_16BITS(&bp[2]);
 	if (hold)
-		relts_print(EXTRACT_16BITS(&bp[2]));
+		relts_print(ndo, EXTRACT_16BITS(&bp[2]));
 	else
-		printf("FOREVER");
+		ND_PRINT((ndo, "FOREVER"));
 
 	/* Next 4 bytes are reserved. */
 
@@ -372,34 +373,34 @@
 		int nentries;
 		char s;
 
-		TCHECK2(bp[0], 4);
-		(void)printf(" RP %s", ipaddr_string(bp));
-		TCHECK(bp[4]);
+		ND_TCHECK2(bp[0], 4);
+		ND_PRINT((ndo, " RP %s", ipaddr_string(ndo, bp)));
+		ND_TCHECK(bp[4]);
 		switch (bp[4] & 0x3) {
-		case 0: printf(" PIMv?");
+		case 0: ND_PRINT((ndo, " PIMv?"));
 			break;
-		case 1:	printf(" PIMv1");
+		case 1:	ND_PRINT((ndo, " PIMv1"));
 			break;
-		case 2:	printf(" PIMv2");
+		case 2:	ND_PRINT((ndo, " PIMv2"));
 			break;
-		case 3:	printf(" PIMv1+2");
+		case 3:	ND_PRINT((ndo, " PIMv1+2"));
 			break;
 		}
 		if (bp[4] & 0xfc)
-			(void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc);
-		TCHECK(bp[5]);
+			ND_PRINT((ndo, " [rsvd=0x%02x]", bp[4] & 0xfc));
+		ND_TCHECK(bp[5]);
 		nentries = bp[5];
 		bp += 6; len -= 6;
 		s = ' ';
 		for (; nentries; nentries--) {
-			TCHECK2(bp[0], 6);
-			(void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
-			    ipaddr_string(&bp[2]), bp[1]);
+			ND_TCHECK2(bp[0], 6);
+			ND_PRINT((ndo, "%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
+			          ipaddr_string(ndo, &bp[2]), bp[1]));
 			if (bp[0] & 0x02) {
-			    (void)printf(" bidir");
+				ND_PRINT((ndo, " bidir"));
 			}
 			if (bp[0] & 0xfc) {
-			    (void)printf("[rsvd=0x%02x]", bp[0] & 0xfc);
+				ND_PRINT((ndo, "[rsvd=0x%02x]", bp[0] & 0xfc));
 			}
 			s = ',';
 			bp += 6; len -= 6;
@@ -408,43 +409,44 @@
 	return;
 
 trunc:
-	(void)printf("[|autorp]");
+	ND_PRINT((ndo, "[|autorp]"));
 	return;
 }
 
 void
-pim_print(register const u_char *bp, register u_int len, u_int cksum)
+pim_print(netdissect_options *ndo,
+          register const u_char *bp, register u_int len, u_int cksum)
 {
 	register const u_char *ep;
 	register struct pim *pim = (struct pim *)bp;
 
-	ep = (const u_char *)snapend;
+	ep = (const u_char *)ndo->ndo_snapend;
 	if (bp >= ep)
 		return;
 #ifdef notyet			/* currently we see only version and type */
-	TCHECK(pim->pim_rsv);
+	ND_TCHECK(pim->pim_rsv);
 #endif
 
 	switch (PIM_VER(pim->pim_typever)) {
 	case 2:
-            if (!vflag) {
-                printf("PIMv%u, %s, length %u",
-                       PIM_VER(pim->pim_typever),
-                       tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
-                       len);
-                return;
-            } else {
-                printf("PIMv%u, length %u\n\t%s",
-                       PIM_VER(pim->pim_typever),
-                       len,
-                       tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
-                pimv2_print(bp, len, cksum);
-            }
-            break;
+		if (!ndo->ndo_vflag) {
+			ND_PRINT((ndo, "PIMv%u, %s, length %u",
+			          PIM_VER(pim->pim_typever),
+			          tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
+			          len));
+			return;
+		} else {
+			ND_PRINT((ndo, "PIMv%u, length %u\n\t%s",
+			          PIM_VER(pim->pim_typever),
+			          len,
+			          tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever))));
+			pimv2_print(ndo, bp, len, cksum);
+		}
+		break;
 	default:
-		printf("PIMv%u, length %u",
-                       PIM_VER(pim->pim_typever),
-                       len);
+		ND_PRINT((ndo, "PIMv%u, length %u",
+		          PIM_VER(pim->pim_typever),
+		          len));
 		break;
 	}
 	return;
@@ -517,15 +519,16 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 static int
-pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
+pimv2_addr_print(netdissect_options *ndo,
+                 const u_char *bp, enum pimv2_addrtype at, int silent)
 {
 	int af;
 	int len, hdrlen;
 
-	TCHECK(bp[0]);
+	ND_TCHECK(bp[0]);
 
 	if (pimv2_addr_len == 0) {
-		TCHECK(bp[1]);
+		ND_TCHECK(bp[1]);
 		switch (bp[0]) {
 		case 1:
 			af = AF_INET;
@@ -564,49 +567,49 @@
 	bp += hdrlen;
 	switch (at) {
 	case pimv2_unicast:
-		TCHECK2(bp[0], len);
+		ND_TCHECK2(bp[0], len);
 		if (af == AF_INET) {
 			if (!silent)
-				(void)printf("%s", ipaddr_string(bp));
+				ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp)));
 		}
 #ifdef INET6
 		else if (af == AF_INET6) {
 			if (!silent)
-				(void)printf("%s", ip6addr_string(bp));
+				ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp)));
 		}
 #endif
 		return hdrlen + len;
 	case pimv2_group:
 	case pimv2_source:
-		TCHECK2(bp[0], len + 2);
+		ND_TCHECK2(bp[0], len + 2);
 		if (af == AF_INET) {
 			if (!silent) {
-				(void)printf("%s", ipaddr_string(bp + 2));
+				ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp + 2)));
 				if (bp[1] != 32)
-					(void)printf("/%u", bp[1]);
+					ND_PRINT((ndo, "/%u", bp[1]));
 			}
 		}
 #ifdef INET6
 		else if (af == AF_INET6) {
 			if (!silent) {
-				(void)printf("%s", ip6addr_string(bp + 2));
+				ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
 				if (bp[1] != 128)
-					(void)printf("/%u", bp[1]);
+					ND_PRINT((ndo, "/%u", bp[1]));
 			}
 		}
 #endif
 		if (bp[0] && !silent) {
 			if (at == pimv2_group) {
-				(void)printf("(0x%02x)", bp[0]);
+				ND_PRINT((ndo, "(0x%02x)", bp[0]));
 			} else {
-				(void)printf("(%s%s%s",
+				ND_PRINT((ndo, "(%s%s%s",
 					bp[0] & 0x04 ? "S" : "",
 					bp[0] & 0x02 ? "W" : "",
-					bp[0] & 0x01 ? "R" : "");
+					bp[0] & 0x01 ? "R" : ""));
 				if (bp[0] & 0xf8) {
-					(void) printf("+0x%02x", bp[0] & 0xf8);
+					ND_PRINT((ndo, "+0x%02x", bp[0] & 0xf8));
 				}
-				(void)printf(")");
+				ND_PRINT((ndo, ")"));
 			}
 		}
 		return hdrlen + 2 + len;
@@ -618,110 +621,110 @@
 }
 
 static void
-pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
+pimv2_print(netdissect_options *ndo,
+            register const u_char *bp, register u_int len, u_int cksum)
 {
 	register const u_char *ep;
 	register struct pim *pim = (struct pim *)bp;
 	int advance;
 
-	ep = (const u_char *)snapend;
+	ep = (const u_char *)ndo->ndo_snapend;
 	if (bp >= ep)
 		return;
 	if (ep > bp + len)
 		ep = bp + len;
-	TCHECK(pim->pim_rsv);
+	ND_TCHECK(pim->pim_rsv);
 	pimv2_addr_len = pim->pim_rsv;
 	if (pimv2_addr_len != 0)
-		(void)printf(", RFC2117-encoding");
+		ND_PRINT((ndo, ", RFC2117-encoding"));
 
-        printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum));
-        if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
-                printf("(unverified)");
-        } else {
-                printf("(%scorrect)", TTEST2(bp[0], len) && cksum ? "in" : "" );
-        }
+	ND_PRINT((ndo, ", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum)));
+	if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
+		ND_PRINT((ndo, "(unverified)"));
+	} else {
+		ND_PRINT((ndo, "(%scorrect)", ND_TTEST2(bp[0], len) && cksum ? "in" : "" ));
+	}
 
 	switch (PIM_TYPE(pim->pim_typever)) {
 	case PIMV2_TYPE_HELLO:
 	    {
-		u_int16_t otype, olen;
+		uint16_t otype, olen;
 		bp += 4;
 		while (bp < ep) {
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			otype = EXTRACT_16BITS(&bp[0]);
 			olen = EXTRACT_16BITS(&bp[2]);
-			TCHECK2(bp[0], 4 + olen);
-
-                        printf("\n\t  %s Option (%u), length %u, Value: ",
-                               tok2str( pimv2_hello_option_values,"Unknown",otype),
-                               otype,
-                               olen);
+			ND_TCHECK2(bp[0], 4 + olen);
+			ND_PRINT((ndo, "\n\t  %s Option (%u), length %u, Value: ",
+			          tok2str(pimv2_hello_option_values, "Unknown", otype),
+			          otype,
+			          olen));
 			bp += 4;
 
 			switch (otype) {
 			case PIMV2_HELLO_OPTION_HOLDTIME:
-                                relts_print(EXTRACT_16BITS(bp));
-                                break;
+				relts_print(ndo, EXTRACT_16BITS(bp));
+				break;
 
 			case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
 				if (olen != 4) {
-					(void)printf("ERROR: Option Length != 4 Bytes (%u)", olen);
+					ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
 				} else {
 					char t_bit;
-					u_int16_t lan_delay, override_interval;
+					uint16_t lan_delay, override_interval;
 					lan_delay = EXTRACT_16BITS(bp);
 					override_interval = EXTRACT_16BITS(bp+2);
 					t_bit = (lan_delay & 0x8000)? 1 : 0;
 					lan_delay &= ~0x8000;
-					(void)printf("\n\t    T-bit=%d, LAN delay %dms, Override interval %dms",
-					t_bit, lan_delay, override_interval);
+					ND_PRINT((ndo, "\n\t    T-bit=%d, LAN delay %dms, Override interval %dms",
+					t_bit, lan_delay, override_interval));
 				}
 				break;
 
 			case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
 			case PIMV2_HELLO_OPTION_DR_PRIORITY:
-                                switch (olen) {
-                                case 0:
-                                    printf("Bi-Directional Capability (Old)");
-                                    break;
-                                case 4:
-                                    printf("%u", EXTRACT_32BITS(bp));
-                                    break;
-                                default:
-                                    printf("ERROR: Option Length != 4 Bytes (%u)", olen);
-                                    break;
-                                }
-                                break;
+				switch (olen) {
+				case 0:
+					ND_PRINT((ndo, "Bi-Directional Capability (Old)"));
+					break;
+				case 4:
+					ND_PRINT((ndo, "%u", EXTRACT_32BITS(bp)));
+					break;
+				default:
+					ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
+					break;
+				}
+				break;
 
 			case PIMV2_HELLO_OPTION_GENID:
-                                (void)printf("0x%08x", EXTRACT_32BITS(bp));
+				ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(bp)));
 				break;
 
 			case PIMV2_HELLO_OPTION_REFRESH_CAP:
-                                (void)printf("v%d", *bp);
+				ND_PRINT((ndo, "v%d", *bp));
 				if (*(bp+1) != 0) {
-                                    (void)printf(", interval ");
-                                    relts_print(*(bp+1));
+					ND_PRINT((ndo, ", interval "));
+					relts_print(ndo, *(bp+1));
 				}
 				if (EXTRACT_16BITS(bp+2) != 0) {
-                                    (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp+2));
+					ND_PRINT((ndo, " ?0x%04x?", EXTRACT_16BITS(bp+2)));
 				}
 				break;
 
 			case  PIMV2_HELLO_OPTION_BIDIR_CAP:
 				break;
 
-                        case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
-                        case PIMV2_HELLO_OPTION_ADDRESS_LIST:
-				if (vflag > 1) {
+			case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
+			case PIMV2_HELLO_OPTION_ADDRESS_LIST:
+				if (ndo->ndo_vflag > 1) {
 					const u_char *ptr = bp;
 					while (ptr < (bp+olen)) {
 						int advance;
 
-						printf("\n\t    ");
-						advance = pimv2_addr_print(ptr, pimv2_unicast, 0);
+						ND_PRINT((ndo, "\n\t    "));
+						advance = pimv2_addr_print(ndo, ptr, pimv2_unicast, 0);
 						if (advance < 0) {
-							printf("...");
+							ND_PRINT((ndo, "..."));
 							break;
 						}
 						ptr += advance;
@@ -729,13 +732,13 @@
 				}
 				break;
 			default:
-                                if (vflag <= 1)
-                                    print_unknown_data(bp,"\n\t    ",olen);
-                                break;
+				if (ndo->ndo_vflag <= 1)
+					print_unknown_data(ndo, bp, "\n\t    ", olen);
+				break;
 			}
-                        /* do we want to see an additionally hexdump ? */
-                        if (vflag> 1)
-                            print_unknown_data(bp,"\n\t    ",olen);
+			/* do we want to see an additionally hexdump ? */
+			if (ndo->ndo_vflag> 1)
+				print_unknown_data(ndo, bp, "\n\t    ", olen);
 			bp += olen;
 		}
 		break;
@@ -745,35 +748,34 @@
 	{
 		struct ip *ip;
 
-                if (!TTEST2(*(bp+4), PIMV2_REGISTER_FLAG_LEN))
-                        goto trunc;
+		ND_TCHECK2(*(bp + 4), PIMV2_REGISTER_FLAG_LEN);
 
-                printf(", Flags [ %s ]\n\t",
-                       tok2str(pimv2_register_flag_values,
-                               "none",
-                               EXTRACT_32BITS(bp+4)));
+		ND_PRINT((ndo, ", Flags [ %s ]\n\t",
+		          tok2str(pimv2_register_flag_values,
+		          "none",
+		          EXTRACT_32BITS(bp+4))));
 
 		bp += 8; len -= 8;
 		/* encapsulated multicast packet */
 		ip = (struct ip *)bp;
 		switch (IP_V(ip)) {
                 case 0: /* Null header */
-			(void)printf("IP-Null-header %s > %s",
-                                     ipaddr_string(&ip->ip_src),
-                                     ipaddr_string(&ip->ip_dst));
+			ND_PRINT((ndo, "IP-Null-header %s > %s",
+			          ipaddr_string(ndo, &ip->ip_src),
+			          ipaddr_string(ndo, &ip->ip_dst)));
 			break;
 
 		case 4:	/* IPv4 */
-			ip_print(gndo, bp, len);
+			ip_print(ndo, bp, len);
 			break;
-#ifdef INET6
+
 		case 6:	/* IPv6 */
-			ip6_print(gndo, bp, len);
+			ip6_print(ndo, bp, len);
 			break;
-#endif
-                default:
-                        (void)printf("IP ver %d", IP_V(ip));
-                        break;
+
+		default:
+			ND_PRINT((ndo, "IP ver %d", IP_V(ip)));
+			break;
 		}
 		break;
 	}
@@ -782,17 +784,17 @@
 		bp += 4; len -= 4;
 		if (bp >= ep)
 			break;
-		(void)printf(" group=");
-		if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " group="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance; len -= advance;
 		if (bp >= ep)
 			break;
-		(void)printf(" source=");
-		if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " source="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance; len -= advance;
@@ -839,19 +841,19 @@
          */
 
 	    {
-		u_int8_t ngroup;
-		u_int16_t holdtime;
-		u_int16_t njoin;
-		u_int16_t nprune;
+		uint8_t ngroup;
+		uint16_t holdtime;
+		uint16_t njoin;
+		uint16_t nprune;
 		int i, j;
 
 		bp += 4; len -= 4;
 		if (PIM_TYPE(pim->pim_typever) != 7) {	/*not for Graft-ACK*/
 			if (bp >= ep)
 				break;
-			(void)printf(", upstream-neighbor: ");
-			if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
-				(void)printf("...");
+			ND_PRINT((ndo, ", upstream-neighbor: "));
+			if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+				ND_PRINT((ndo, "..."));
 				break;
 			}
 			bp += advance; len -= advance;
@@ -860,44 +862,44 @@
 			break;
 		ngroup = bp[1];
 		holdtime = EXTRACT_16BITS(&bp[2]);
-		(void)printf("\n\t  %u group(s)", ngroup);
+		ND_PRINT((ndo, "\n\t  %u group(s)", ngroup));
 		if (PIM_TYPE(pim->pim_typever) != 7) {	/*not for Graft-ACK*/
-			(void)printf(", holdtime: ");
+			ND_PRINT((ndo, ", holdtime: "));
 			if (holdtime == 0xffff)
-				(void)printf("infinite");
+				ND_PRINT((ndo, "infinite"));
 			else
-				relts_print(holdtime);
+				relts_print(ndo, holdtime);
 		}
 		bp += 4; len -= 4;
 		for (i = 0; i < ngroup; i++) {
 			if (bp >= ep)
 				goto jp_done;
-			(void)printf("\n\t    group #%u: ", i+1);
-			if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
-				(void)printf("...)");
+			ND_PRINT((ndo, "\n\t    group #%u: ", i+1));
+			if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+				ND_PRINT((ndo, "...)"));
 				goto jp_done;
 			}
 			bp += advance; len -= advance;
 			if (bp + 4 > ep) {
-				(void)printf("...)");
+				ND_PRINT((ndo, "...)"));
 				goto jp_done;
 			}
 			njoin = EXTRACT_16BITS(&bp[0]);
 			nprune = EXTRACT_16BITS(&bp[2]);
-			(void)printf(", joined sources: %u, pruned sources: %u", njoin,nprune);
+			ND_PRINT((ndo, ", joined sources: %u, pruned sources: %u", njoin, nprune));
 			bp += 4; len -= 4;
 			for (j = 0; j < njoin; j++) {
-				(void)printf("\n\t      joined source #%u: ",j+1);
-				if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
-					(void)printf("...)");
+				ND_PRINT((ndo, "\n\t      joined source #%u: ", j+1));
+				if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
+					ND_PRINT((ndo, "...)"));
 					goto jp_done;
 				}
 				bp += advance; len -= advance;
 			}
 			for (j = 0; j < nprune; j++) {
-				(void)printf("\n\t      pruned source #%u: ",j+1);
-				if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
-					(void)printf("...)");
+				ND_PRINT((ndo, "\n\t      pruned source #%u: ", j+1));
+				if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
+					ND_PRINT((ndo, "...)"));
 					goto jp_done;
 				}
 				bp += advance; len -= advance;
@@ -913,72 +915,72 @@
 		bp += 4;
 
 		/* Fragment Tag, Hash Mask len, and BSR-priority */
-		if (bp + sizeof(u_int16_t) >= ep) break;
-		(void)printf(" tag=%x", EXTRACT_16BITS(bp));
-		bp += sizeof(u_int16_t);
+		if (bp + sizeof(uint16_t) >= ep) break;
+		ND_PRINT((ndo, " tag=%x", EXTRACT_16BITS(bp)));
+		bp += sizeof(uint16_t);
 		if (bp >= ep) break;
-		(void)printf(" hashmlen=%d", bp[0]);
+		ND_PRINT((ndo, " hashmlen=%d", bp[0]));
 		if (bp + 1 >= ep) break;
-		(void)printf(" BSRprio=%d", bp[1]);
+		ND_PRINT((ndo, " BSRprio=%d", bp[1]));
 		bp += 2;
 
 		/* Encoded-Unicast-BSR-Address */
 		if (bp >= ep) break;
-		(void)printf(" BSR=");
-		if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " BSR="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance;
 
 		for (i = 0; bp < ep; i++) {
 			/* Encoded-Group Address */
-			(void)printf(" (group%d: ", i);
-			if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+			ND_PRINT((ndo, " (group%d: ", i));
+			if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
 			    < 0) {
-				(void)printf("...)");
+				ND_PRINT((ndo, "...)"));
 				goto bs_done;
 			}
 			bp += advance;
 
 			/* RP-Count, Frag RP-Cnt, and rsvd */
 			if (bp >= ep) {
-				(void)printf("...)");
+				ND_PRINT((ndo, "...)"));
 				goto bs_done;
 			}
-			(void)printf(" RPcnt=%d", bp[0]);
+			ND_PRINT((ndo, " RPcnt=%d", bp[0]));
 			if (bp + 1 >= ep) {
-				(void)printf("...)");
+				ND_PRINT((ndo, "...)"));
 				goto bs_done;
 			}
-			(void)printf(" FRPcnt=%d", frpcnt = bp[1]);
+			ND_PRINT((ndo, " FRPcnt=%d", frpcnt = bp[1]));
 			bp += 4;
 
 			for (j = 0; j < frpcnt && bp < ep; j++) {
 				/* each RP info */
-				(void)printf(" RP%d=", j);
-				if ((advance = pimv2_addr_print(bp,
+				ND_PRINT((ndo, " RP%d=", j));
+				if ((advance = pimv2_addr_print(ndo, bp,
 								pimv2_unicast,
 								0)) < 0) {
-					(void)printf("...)");
+					ND_PRINT((ndo, "...)"));
 					goto bs_done;
 				}
 				bp += advance;
 
 				if (bp + 1 >= ep) {
-					(void)printf("...)");
+					ND_PRINT((ndo, "...)"));
 					goto bs_done;
 				}
-				(void)printf(",holdtime=");
-				relts_print(EXTRACT_16BITS(bp));
+				ND_PRINT((ndo, ",holdtime="));
+				relts_print(ndo, EXTRACT_16BITS(bp));
 				if (bp + 2 >= ep) {
-					(void)printf("...)");
+					ND_PRINT((ndo, "...)"));
 					goto bs_done;
 				}
-				(void)printf(",prio=%d", bp[2]);
+				ND_PRINT((ndo, ",prio=%d", bp[2]));
 				bp += 4;
 			}
-			(void)printf(")");
+			ND_PRINT((ndo, ")"));
 		}
 	   bs_done:
 		break;
@@ -987,26 +989,26 @@
 		bp += 4; len -= 4;
 		if (bp >= ep)
 			break;
-		(void)printf(" group=");
-		if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " group="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance; len -= advance;
 		if (bp >= ep)
 			break;
-		(void)printf(" src=");
-		if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " src="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance; len -= advance;
 		if (bp + 8 > ep)
 			break;
 		if (bp[0] & 0x80)
-			(void)printf(" RPT");
-		(void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff);
-		(void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
+			ND_PRINT((ndo, " RPT"));
+		ND_PRINT((ndo, " pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff));
+		ND_PRINT((ndo, " metric=%u", EXTRACT_32BITS(&bp[4])));
 		break;
 
 	case PIMV2_TYPE_CANDIDATE_RP:
@@ -1016,30 +1018,30 @@
 
 		/* Prefix-Cnt, Priority, and Holdtime */
 		if (bp >= ep) break;
-		(void)printf(" prefix-cnt=%d", bp[0]);
+		ND_PRINT((ndo, " prefix-cnt=%d", bp[0]));
 		pfxcnt = bp[0];
 		if (bp + 1 >= ep) break;
-		(void)printf(" prio=%d", bp[1]);
+		ND_PRINT((ndo, " prio=%d", bp[1]));
 		if (bp + 3 >= ep) break;
-		(void)printf(" holdtime=");
-		relts_print(EXTRACT_16BITS(&bp[2]));
+		ND_PRINT((ndo, " holdtime="));
+		relts_print(ndo, EXTRACT_16BITS(&bp[2]));
 		bp += 4;
 
 		/* Encoded-Unicast-RP-Address */
 		if (bp >= ep) break;
-		(void)printf(" RP=");
-		if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " RP="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance;
 
 		/* Encoded-Group Addresses */
 		for (i = 0; i < pfxcnt && bp < ep; i++) {
-			(void)printf(" Group%d=", i);
-			if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+			ND_PRINT((ndo, " Group%d=", i));
+			if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
 			    < 0) {
-				(void)printf("...");
+				ND_PRINT((ndo, "..."));
 				break;
 			}
 			bp += advance;
@@ -1048,39 +1050,39 @@
 	}
 
 	case PIMV2_TYPE_PRUNE_REFRESH:
-		(void)printf(" src=");
-		if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " src="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance;
-		(void)printf(" grp=");
-		if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " grp="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance;
-		(void)printf(" forwarder=");
-		if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
-			(void)printf("...");
+		ND_PRINT((ndo, " forwarder="));
+		if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+			ND_PRINT((ndo, "..."));
 			break;
 		}
 		bp += advance;
-		TCHECK2(bp[0], 2);
-		(void)printf(" TUNR ");
-		relts_print(EXTRACT_16BITS(bp));
+		ND_TCHECK2(bp[0], 2);
+		ND_PRINT((ndo, " TUNR "));
+		relts_print(ndo, EXTRACT_16BITS(bp));
 		break;
 
 
 	 default:
-		(void)printf(" [type %d]", PIM_TYPE(pim->pim_typever));
+		ND_PRINT((ndo, " [type %d]", PIM_TYPE(pim->pim_typever)));
 		break;
 	}
 
 	return;
 
 trunc:
-	(void)printf("[|pim]");
+	ND_PRINT((ndo, "[|pim]"));
 }
 
 /*
diff --git a/print-pktap.c b/print-pktap.c
new file mode 100644
index 0000000..46a187d
--- /dev/null
+++ b/print-pktap.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ *	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.
+ */
+
+#define NETDISSECT_REWORKED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include "interface.h"
+#include "extract.h"
+
+#ifdef DLT_PKTAP
+
+/*
+ * XXX - these are little-endian in the captures I've seen, but Apple
+ * no longer make any big-endian machines (Macs use x86, iOS machines
+ * use ARM and run it little-endian), so that might be by definition
+ * or they might be host-endian.
+ *
+ * If a big-endian PKTAP file ever shows up, and it comes from a
+ * big-endian machine, presumably these are host-endian, and we need
+ * to just fetch the fields directly in tcpdump but byte-swap them
+ * to host byte order in libpcap.
+ */
+typedef struct pktap_header {
+	uint32_t	pkt_len;	/* length of pktap header */
+	uint32_t	pkt_rectype;	/* type of record */
+	uint32_t	pkt_dlt;	/* DLT type of this packet */
+	char		pkt_ifname[24];	/* interface name */
+	uint32_t	pkt_flags;
+	uint32_t	pkt_pfamily;	/* "protocol family" */
+	uint32_t	pkt_llhdrlen;	/* link-layer header length? */
+	uint32_t	pkt_lltrlrlen;	/* link-layer trailer length? */
+	uint32_t	pkt_pid;	/* process ID */
+	char		pkt_cmdname[20]; /* command name */
+	uint32_t	pkt_svc_class;	/* "service class" */
+	uint16_t	pkt_iftype;	/* "interface type" */
+	uint16_t	pkt_ifunit;	/* unit number of interface? */
+	uint32_t	pkt_epid;	/* "effective process ID" */
+	char		pkt_ecmdname[20]; /* "effective command name" */
+} pktap_header_t;
+
+/*
+ * Record types.
+ */
+#define PKT_REC_NONE	0	/* nothing follows the header */
+#define PKT_REC_PACKET	1	/* a packet follows the header */
+
+static inline void
+pktap_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+	const pktap_header_t *hdr;
+	uint32_t dlt, hdrlen;
+
+	hdr = (const pktap_header_t *)bp;
+
+	dlt = EXTRACT_LE_32BITS(&hdr->pkt_dlt);
+	hdrlen = EXTRACT_LE_32BITS(&hdr->pkt_len);
+	if (!ndo->ndo_qflag) {
+		ND_PRINT((ndo,", DLT %s (%d) len %d",
+			  pcap_datalink_val_to_name(dlt), dlt, hdrlen));
+        } else {
+		ND_PRINT((ndo,", %s", pcap_datalink_val_to_name(dlt)));
+        }
+
+	ND_PRINT((ndo, ", length %u: ", length));
+}
+
+/*
+ * This is the top level routine of the printer.  'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+pktap_if_print(netdissect_options *ndo,
+               const struct pcap_pkthdr *h, const u_char *p)
+{
+	uint32_t dlt, hdrlen, rectype;
+	u_int caplen = h->caplen;
+	u_int length = h->len;
+	if_ndo_printer ndo_printer;
+        if_printer printer;
+	pktap_header_t *hdr;
+
+	if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) {
+		ND_PRINT((ndo, "[|pktap]"));
+		return (0);
+	}
+	hdr = (pktap_header_t *)p;
+	dlt = EXTRACT_LE_32BITS(&hdr->pkt_dlt);
+	hdrlen = EXTRACT_LE_32BITS(&hdr->pkt_len);
+	if (hdrlen < sizeof(pktap_header_t)) {
+		/*
+		 * Claimed header length < structure length.
+		 * XXX - does this just mean some fields aren't
+		 * being supplied, or is it truly an error (i.e.,
+		 * is the length supplied so that the header can
+		 * be expanded in the future)?
+		 */
+		ND_PRINT((ndo, "[|pktap]"));
+		return (0);
+	}
+	if (caplen < hdrlen || length < hdrlen) {
+		ND_PRINT((ndo, "[|pktap]"));
+		return (hdrlen);
+	}
+
+	if (ndo->ndo_eflag)
+		pktap_header_print(ndo, p, length);
+
+	length -= hdrlen;
+	caplen -= hdrlen;
+	p += hdrlen;
+
+	rectype = EXTRACT_LE_32BITS(&hdr->pkt_rectype);
+	switch (rectype) {
+
+	case PKT_REC_NONE:
+		ND_PRINT((ndo, "no data"));
+		break;
+
+	case PKT_REC_PACKET:
+		if ((printer = lookup_printer(dlt)) != NULL) {
+			printer(h, p);
+		} else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
+			ndo_printer(ndo, h, p);
+		} else {
+			if (!ndo->ndo_eflag)
+				pktap_header_print(ndo, (u_char *)hdr,
+						length + hdrlen);
+
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p, caplen);
+		}
+		break;
+	}
+
+	return (hdrlen);
+}
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+
+#endif /* DLT_PKTAP */
diff --git a/print-ppi.c b/print-ppi.c
index 38873c8..b403536 100644
--- a/print-ppi.c
+++ b/print-ppi.c
@@ -1,47 +1,52 @@
 /*
  * Oracle
  */
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
-#include "netdissect.h"
 #include "interface.h"
 #include "extract.h"
-#include "ppi.h"
+
+typedef struct ppi_header {
+	uint8_t		ppi_ver;
+	uint8_t		ppi_flags;
+	uint16_t	ppi_len;
+	uint32_t	ppi_dlt;
+} ppi_header_t;
+
+#define	PPI_HDRLEN	8
 
 #ifdef DLT_PPI
 
 static inline void
-ppi_header_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
+ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
 	const ppi_header_t *hdr;
-	u_int32_t dlt;
-	u_int16_t len;
+	uint16_t len;
+	uint32_t dlt;
 
 	hdr = (const ppi_header_t *)bp;
 
-	len = EXTRACT_16BITS(&hdr->ppi_len);
-	dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
+	len = EXTRACT_LE_16BITS(&hdr->ppi_len);
+	dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
 
 	if (!ndo->ndo_qflag) {
-		ND_PRINT((ndo,", V.%d DLT %s (%d) len %d", hdr->ppi_ver,
+		ND_PRINT((ndo, "V.%d DLT %s (%d) len %d", hdr->ppi_ver,
 			  pcap_datalink_val_to_name(dlt), dlt,
                           len));
         } else {
-		ND_PRINT((ndo,", %s", pcap_datalink_val_to_name(dlt)));
+		ND_PRINT((ndo, "%s", pcap_datalink_val_to_name(dlt)));
         }
 
 	ND_PRINT((ndo, ", length %u: ", length));
 }
 
 static void
-ppi_print(struct netdissect_options *ndo,
+ppi_print(netdissect_options *ndo,
                const struct pcap_pkthdr *h, const u_char *p)
 {
 	if_ndo_printer ndo_printer;
@@ -49,21 +54,32 @@
 	ppi_header_t *hdr;
 	u_int caplen = h->caplen;
 	u_int length = h->len;
-	u_int32_t dlt;
+	uint16_t len;
+	uint32_t dlt;
 
 	if (caplen < sizeof(ppi_header_t)) {
 		ND_PRINT((ndo, "[|ppi]"));
 		return;
 	}
+
 	hdr = (ppi_header_t *)p;
-	dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
+	len = EXTRACT_LE_16BITS(&hdr->ppi_len);
+	if (len < sizeof(ppi_header_t)) {
+		ND_PRINT((ndo, "[|ppi]"));
+		return;
+	}
+	if (caplen < len) {
+		ND_PRINT((ndo, "[|ppi]"));
+		return;
+	}
+	dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
 
 	if (ndo->ndo_eflag)
 		ppi_header_print(ndo, p, length);
 
-	length -= sizeof(ppi_header_t);
-	caplen -= sizeof(ppi_header_t);
-	p += sizeof(ppi_header_t);
+	length -= len;
+	caplen -= len;
+	p += len;
 
 	if ((printer = lookup_printer(dlt)) != NULL) {
 		printer(h, p);
@@ -71,11 +87,10 @@
 		ndo_printer(ndo, h, p);
 	} else {
 		if (!ndo->ndo_eflag)
-			ppi_header_print(ndo, (u_char *)hdr,
-					length + sizeof(ppi_header_t));
+			ppi_header_print(ndo, (u_char *)hdr, length + len);
 
 		if (!ndo->ndo_suppress_default_print)
-			ndo->ndo_default_print(ndo, p, caplen);
+			ND_DEFAULTPRINT(p, caplen);
 	}
 }
 
@@ -86,7 +101,7 @@
  * is the number of bytes actually captured.
  */
 u_int
-ppi_if_print(struct netdissect_options *ndo,
+ppi_if_print(netdissect_options *ndo,
                const struct pcap_pkthdr *h, const u_char *p)
 {
 	ppi_print(ndo, h, p);
diff --git a/print-ppp.c b/print-ppp.c
index 0ae8811..edc03c0 100644
--- a/print-ppp.c
+++ b/print-ppp.c
@@ -29,11 +29,7 @@
  * o BAP support
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.114 2005-12-05 11:35:58 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -45,8 +41,6 @@
 #include <net/if_ppp.h>
 #endif
 
-#include <pcap.h>
-#include <stdio.h>
 #include <stdlib.h>
 
 #include "interface.h"
@@ -107,6 +101,7 @@
 	{ PPP_BACP,	  "BACP" },
 	{ PPP_BAP,	  "BAP" },
 	{ PPP_MPCP,	  "MLPPP-CP" },
+	{ PPP_CCP,	  "CCP" },
 	{ 0,		  NULL }
 };
 
@@ -406,73 +401,68 @@
 #define BAP_CSIND	7
 #define BAP_CSRES	8
 
-static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
-static void handle_chap (const u_char *p, int length);
-static void handle_pap (const u_char *p, int length);
-static void handle_bap (const u_char *p, int length);
-static void handle_mlppp(const u_char *p, int length);
-static int print_lcp_config_options (const u_char *p, int);
-static int print_ipcp_config_options (const u_char *p, int);
-static int print_ip6cp_config_options (const u_char *p, int);
-static int print_ccp_config_options (const u_char *p, int);
-static int print_bacp_config_options (const u_char *p, int);
-static void handle_ppp (u_int proto, const u_char *p, int length);
-static void ppp_hdlc(const u_char *p, int length);
+static int print_lcp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ipcp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ip6cp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ccp_config_options(netdissect_options *, const u_char *p, int);
+static int print_bacp_config_options(netdissect_options *, const u_char *p, int);
+static void handle_ppp(netdissect_options *, u_int proto, const u_char *p, int length);
 
 /* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
 static void
-handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
+handle_ctrl_proto(netdissect_options *ndo,
+                  u_int proto, const u_char *pptr, int length)
 {
 	const char *typestr;
 	u_int code, len;
-	int (*pfunc)(const u_char *, int);
+	int (*pfunc)(netdissect_options *, const u_char *, int);
 	int x, j;
         const u_char *tptr;
 
         tptr=pptr;
 
         typestr = tok2str(ppptype2str, "unknown ctrl-proto (0x%04x)", proto);
-        printf("%s, ",typestr);
+	ND_PRINT((ndo, "%s, ", typestr));
 
 	if (length < 4) /* FIXME weak boundary checking */
 		goto trunc;
-	TCHECK2(*tptr, 2);
+	ND_TCHECK2(*tptr, 2);
 
 	code = *tptr++;
-	
-        printf("%s (0x%02x), id %u, length %u",
-               tok2str(cpcodes, "Unknown Opcode",code),
-               code,
-               *tptr++, /* ID */
-               length+2);
 
-        if (!vflag)
-                return;
+	ND_PRINT((ndo, "%s (0x%02x), id %u, length %u",
+	          tok2str(cpcodes, "Unknown Opcode",code),
+	          code,
+	          *tptr++, /* ID */
+	          length + 2));
+
+	if (!ndo->ndo_vflag)
+		return;
 
 	if (length <= 4)
 		return;    /* there may be a NULL confreq etc. */
 
-	TCHECK2(*tptr, 2);
+	ND_TCHECK2(*tptr, 2);
 	len = EXTRACT_16BITS(tptr);
 	tptr += 2;
 
-        printf("\n\tencoded length %u (=Option(s) length %u)",len,len-4);
+	ND_PRINT((ndo, "\n\tencoded length %u (=Option(s) length %u)", len, len - 4));
 
-        if (vflag>1)
-            print_unknown_data(pptr-2,"\n\t",6);
+	if (ndo->ndo_vflag > 1)
+		print_unknown_data(ndo, pptr - 2, "\n\t", 6);
 
 
 	switch (code) {
 	case CPCODES_VEXT:
 		if (length < 11)
 			break;
-		TCHECK2(*tptr, 4);
-		printf("\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+		ND_TCHECK2(*tptr, 4);
+		ND_PRINT((ndo, "\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
 		tptr += 4;
-		TCHECK2(*tptr, 3);
-		printf(" Vendor: %s (%u)",
+		ND_TCHECK2(*tptr, 3);
+		ND_PRINT((ndo, " Vendor: %s (%u)",
                        tok2str(oui_values,"Unknown",EXTRACT_24BITS(tptr)),
-                       EXTRACT_24BITS(tptr));
+                       EXTRACT_24BITS(tptr)));
 		/* XXX: need to decode Kind and Value(s)? */
 		break;
 	case CPCODES_CONF_REQ:
@@ -508,8 +498,8 @@
 
 			if (pfunc == NULL) /* catch the above null pointer if unknown CP */
 				break;
- 
-			if ((j = (*pfunc)(tptr, len)) == 0)
+
+			if ((j = (*pfunc)(ndo, tptr, len)) == 0)
 				break;
 			x -= j;
 			tptr += j;
@@ -526,209 +516,239 @@
 	case CPCODES_PROT_REJ:
 		if (length < 6)
 			break;
-		TCHECK2(*tptr, 2);
-		printf("\n\t  Rejected %s Protocol (0x%04x)",
+		ND_TCHECK2(*tptr, 2);
+		ND_PRINT((ndo, "\n\t  Rejected %s Protocol (0x%04x)",
 		       tok2str(ppptype2str,"unknown", EXTRACT_16BITS(tptr)),
-		       EXTRACT_16BITS(tptr));
+		       EXTRACT_16BITS(tptr)));
 		/* XXX: need to decode Rejected-Information? - hexdump for now */
-                if (len > 6) {
-                        printf("\n\t  Rejected Packet");
-                        print_unknown_data(tptr+2,"\n\t    ",len-2);
-                }
+		if (len > 6) {
+			ND_PRINT((ndo, "\n\t  Rejected Packet"));
+			print_unknown_data(ndo, tptr + 2, "\n\t    ", len - 2);
+		}
 		break;
 	case CPCODES_ECHO_REQ:
 	case CPCODES_ECHO_RPL:
 	case CPCODES_DISC_REQ:
 		if (length < 8)
 			break;
-		TCHECK2(*tptr, 4);
-		printf("\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+		ND_TCHECK2(*tptr, 4);
+		ND_PRINT((ndo, "\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
 		/* XXX: need to decode Data? - hexdump for now */
-                if (len > 8) {
-                        printf("\n\t  -----trailing data-----");
-                        TCHECK2(tptr[4], len-8);
-                        print_unknown_data(tptr+4,"\n\t  ",len-8);
-                }
+		if (len > 8) {
+			ND_PRINT((ndo, "\n\t  -----trailing data-----"));
+			ND_TCHECK2(tptr[4], len - 8);
+			print_unknown_data(ndo, tptr + 4, "\n\t  ", len - 8);
+		}
 		break;
 	case CPCODES_ID:
 		if (length < 8)
 			break;
-		TCHECK2(*tptr, 4);
-		printf("\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+		ND_TCHECK2(*tptr, 4);
+		ND_PRINT((ndo, "\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
 		/* RFC 1661 says this is intended to be human readable */
-                if (len > 8) {
-                        printf("\n\t  Message\n\t    ");
-                        fn_printn(tptr+4,len-4,snapend);
-                }
+		if (len > 8) {
+			ND_PRINT((ndo, "\n\t  Message\n\t    "));
+			if (fn_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
+				goto trunc;
+		}
 		break;
 	case CPCODES_TIME_REM:
 		if (length < 12)
 			break;
-		TCHECK2(*tptr, 4);
-		printf("\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
-		TCHECK2(*(tptr + 4), 4);
-		printf(", Seconds-Remaining %us", EXTRACT_32BITS(tptr + 4));
+		ND_TCHECK2(*tptr, 4);
+		ND_PRINT((ndo, "\n\t  Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
+		ND_TCHECK2(*(tptr + 4), 4);
+		ND_PRINT((ndo, ", Seconds-Remaining %us", EXTRACT_32BITS(tptr + 4)));
 		/* XXX: need to decode Message? */
 		break;
 	default:
-            /* XXX this is dirty but we do not get the
-             * original pointer passed to the begin
-             * the PPP packet */
-                if (vflag <= 1)
-                    print_unknown_data(pptr-2,"\n\t  ",length+2);
+		/* XXX this is dirty but we do not get the
+		 * original pointer passed to the begin
+		 * the PPP packet */
+		if (ndo->ndo_vflag <= 1)
+			print_unknown_data(ndo, pptr - 2, "\n\t  ", length + 2);
 		break;
 	}
 	return;
 
 trunc:
-	printf("[|%s]", typestr);
+	ND_PRINT((ndo, "[|%s]", typestr));
 }
 
 /* LCP config options */
 static int
-print_lcp_config_options(const u_char *p, int length)
+print_lcp_config_options(netdissect_options *ndo,
+                         const u_char *p, int length)
 {
 	int len, opt;
 
 	if (length < 2)
 		return 0;
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	len = p[1];
 	opt = p[0];
 	if (length < len)
 		return 0;
 	if (len < 2) {
 		if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
-			printf("\n\t  %s Option (0x%02x), length %u (bogus, should be >= 2)", lcpconfopts[opt],opt,len);
+			ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+			          lcpconfopts[opt], opt, len));
 		else
-			printf("\n\tunknown LCP option 0x%02x", opt);
+			ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt));
 		return 0;
 	}
 	if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
-		printf("\n\t  %s Option (0x%02x), length %u: ", lcpconfopts[opt],opt,len);
+		ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u", lcpconfopts[opt], opt, len));
 	else {
-		printf("\n\tunknown LCP option 0x%02x", opt);
+		ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt));
 		return len;
 	}
 
 	switch (opt) {
 	case LCPOPT_VEXT:
-		if (len >= 6) {
-			TCHECK2(*(p + 2), 3);
-			printf("Vendor: %s (%u)",
-                               tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
-                               EXTRACT_24BITS(p+2));
-#if 0
-			TCHECK(p[5]);
-			printf(", kind: 0x%02x", p[5]);
-			printf(", Value: 0x")
-			for (i = 0; i < len - 6; i++) {
-				TCHECK(p[6 + i]);
-				printf("%02x", p[6 + i]);
-			}
-#endif
+		if (len < 6) {
+			ND_PRINT((ndo, " (length bogus, should be >= 6)"));
+			return len;
 		}
+		ND_TCHECK2(*(p + 2), 3);
+		ND_PRINT((ndo, ": Vendor: %s (%u)",
+			tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
+			EXTRACT_24BITS(p + 2)));
+#if 0
+		ND_TCHECK(p[5]);
+		ND_PRINT((ndo, ", kind: 0x%02x", p[5]));
+		ND_PRINT((ndo, ", Value: 0x"));
+		for (i = 0; i < len - 6; i++) {
+			ND_TCHECK(p[6 + i]);
+			ND_PRINT((ndo, "%02x", p[6 + i]));
+		}
+#endif
 		break;
 	case LCPOPT_MRU:
-		if (len == 4) {
-			TCHECK2(*(p + 2), 2);
-			printf("%u", EXTRACT_16BITS(p + 2));
+		if (len != 4) {
+			ND_PRINT((ndo, " (length bogus, should be = 4)"));
+			return len;
 		}
+		ND_TCHECK2(*(p + 2), 2);
+		ND_PRINT((ndo, ": %u", EXTRACT_16BITS(p + 2)));
 		break;
 	case LCPOPT_ACCM:
-		if (len == 6) {
-			TCHECK2(*(p + 2), 4);
-			printf("0x%08x", EXTRACT_32BITS(p + 2));
+		if (len != 6) {
+			ND_PRINT((ndo, " (length bogus, should be = 6)"));
+			return len;
 		}
+		ND_TCHECK2(*(p + 2), 4);
+		ND_PRINT((ndo, ": 0x%08x", EXTRACT_32BITS(p + 2)));
 		break;
 	case LCPOPT_AP:
-		if (len >= 4) {
-		    TCHECK2(*(p + 2), 2);
-                    printf("%s", tok2str(ppptype2str,"Unknown Auth Proto (0x04x)",EXTRACT_16BITS(p+2)));
+		if (len < 4) {
+			ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+			return len;
+		}
+		ND_TCHECK2(*(p + 2), 2);
+		ND_PRINT((ndo, ": %s", tok2str(ppptype2str, "Unknown Auth Proto (0x04x)", EXTRACT_16BITS(p + 2))));
 
-		    switch (EXTRACT_16BITS(p+2)) {
-		    case PPP_CHAP:
-		        TCHECK(p[4]);
-                        printf(", %s",tok2str(authalg_values,"Unknown Auth Alg %u",p[4]));
+		switch (EXTRACT_16BITS(p+2)) {
+		case PPP_CHAP:
+			ND_TCHECK(p[4]);
+			ND_PRINT((ndo, ", %s", tok2str(authalg_values, "Unknown Auth Alg %u", p[4])));
 			break;
-		    case PPP_PAP: /* fall through */
-		    case PPP_EAP:
-		    case PPP_SPAP:
-		    case PPP_SPAP_OLD:
+		case PPP_PAP: /* fall through */
+		case PPP_EAP:
+		case PPP_SPAP:
+		case PPP_SPAP_OLD:
                         break;
-		    default:
-                        print_unknown_data(p,"\n\t",len);
-		    }
+		default:
+			print_unknown_data(ndo, p, "\n\t", len);
 		}
 		break;
 	case LCPOPT_QP:
-		if (len >= 4) {
-			TCHECK2(*(p + 2), 2);
-		        if (EXTRACT_16BITS(p+2) == PPP_LQM)
-				printf(" LQR");
-			else
-				printf(" unknown");
+		if (len < 4) {
+			ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+			return 0;
 		}
+		ND_TCHECK2(*(p + 2), 2);
+		if (EXTRACT_16BITS(p+2) == PPP_LQM)
+			ND_PRINT((ndo, ": LQR"));
+		else
+			ND_PRINT((ndo, ": unknown"));
 		break;
 	case LCPOPT_MN:
-		if (len == 6) {
-			TCHECK2(*(p + 2), 4);
-			printf("0x%08x", EXTRACT_32BITS(p + 2));
+		if (len != 6) {
+			ND_PRINT((ndo, " (length bogus, should be = 6)"));
+			return 0;
 		}
+		ND_TCHECK2(*(p + 2), 4);
+		ND_PRINT((ndo, ": 0x%08x", EXTRACT_32BITS(p + 2)));
 		break;
 	case LCPOPT_PFC:
 		break;
 	case LCPOPT_ACFC:
 		break;
 	case LCPOPT_LD:
-		if (len == 4) {
-			TCHECK2(*(p + 2), 2);
-			printf("0x%04x", EXTRACT_16BITS(p + 2));
+		if (len != 4) {
+			ND_PRINT((ndo, " (length bogus, should be = 4)"));
+			return 0;
 		}
+		ND_TCHECK2(*(p + 2), 2);
+		ND_PRINT((ndo, ": 0x%04x", EXTRACT_16BITS(p + 2)));
 		break;
 	case LCPOPT_CBACK:
-		if (len < 3)
-			break;
-		TCHECK(p[2]);
-                printf("Callback Operation %s (%u)",
-                       tok2str(ppp_callback_values,"Unknown",p[2]),
-                       p[2]);
+		if (len < 3) {
+			ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+			return 0;
+		}
+		ND_PRINT((ndo, ": "));
+		ND_TCHECK(p[2]);
+		ND_PRINT((ndo, ": Callback Operation %s (%u)",
+                       tok2str(ppp_callback_values, "Unknown", p[2]),
+                       p[2]));
 		break;
 	case LCPOPT_MLMRRU:
-		if (len == 4) {
-			TCHECK2(*(p + 2), 2);
-			printf("%u", EXTRACT_16BITS(p + 2));
+		if (len != 4) {
+			ND_PRINT((ndo, " (length bogus, should be = 4)"));
+			return 0;
 		}
+		ND_TCHECK2(*(p + 2), 2);
+		ND_PRINT((ndo, ": %u", EXTRACT_16BITS(p + 2)));
 		break;
 	case LCPOPT_MLED:
-		if (len < 3)
-			break;
-		TCHECK(p[2]);
+		if (len < 3) {
+			ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+			return 0;
+		}
+		ND_TCHECK(p[2]);
 		switch (p[2]) {		/* class */
 		case MEDCLASS_NULL:
-			printf("Null");
+			ND_PRINT((ndo, ": Null"));
 			break;
 		case MEDCLASS_LOCAL:
-			printf("Local"); /* XXX */
+			ND_PRINT((ndo, ": Local")); /* XXX */
 			break;
 		case MEDCLASS_IPV4:
-			if (len != 7)
-				break;
-			TCHECK2(*(p + 3), 4);
-			printf("IPv4 %s", ipaddr_string(p + 3));
+			if (len != 7) {
+				ND_PRINT((ndo, " (length bogus, should be = 7)"));
+				return 0;
+			}
+			ND_TCHECK2(*(p + 3), 4);
+			ND_PRINT((ndo, ": IPv4 %s", ipaddr_string(ndo, p + 3)));
 			break;
 		case MEDCLASS_MAC:
-			if (len != 9)
-				break;
-			TCHECK(p[8]);
-			printf("MAC %02x:%02x:%02x:%02x:%02x:%02x",
-			       p[3], p[4], p[5], p[6], p[7], p[8]);
+			if (len != 9) {
+				ND_PRINT((ndo, " (length bogus, should be = 9)"));
+				return 0;
+			}
+			ND_TCHECK2(*(p + 3), 6);
+			ND_PRINT((ndo, ": MAC %s", etheraddr_string(ndo, p + 3)));
 			break;
 		case MEDCLASS_MNB:
-			printf("Magic-Num-Block"); /* XXX */
+			ND_PRINT((ndo, ": Magic-Num-Block")); /* XXX */
 			break;
 		case MEDCLASS_PSNDN:
-			printf("PSNDN"); /* XXX */
+			ND_PRINT((ndo, ": PSNDN")); /* XXX */
+			break;
+		default:
+			ND_PRINT((ndo, ": Unknown class %u", p[2]));
 			break;
 		}
 		break;
@@ -756,19 +776,23 @@
 	case LCPOPT_PPPMUX:
 		break;
 #endif
-        default:
-                if(vflag<2)
-                        print_unknown_data(&p[2],"\n\t    ",len-2);
-                break;
+	default:
+		/*
+		 * Unknown option; dump it as raw bytes now if we're
+		 * not going to do so below.
+		 */
+		if (ndo->ndo_vflag < 2)
+			print_unknown_data(ndo, &p[2], "\n\t    ", len - 2);
+		break;
 	}
-         
-        if (vflag>1)
-                print_unknown_data(&p[2],"\n\t    ",len-2); /* exclude TLV header */
+
+	if (ndo->ndo_vflag > 1)
+		print_unknown_data(ndo, &p[2], "\n\t    ", len - 2); /* exclude TLV header */
 
 	return len;
 
 trunc:
-	printf("[|lcp]");
+	ND_PRINT((ndo, "[|lcp]"));
 	return 0;
 }
 
@@ -780,22 +804,22 @@
 };
 
 static void
-handle_mlppp(const u_char *p, int length) {
+handle_mlppp(netdissect_options *ndo,
+             const u_char *p, int length)
+{
+    if (!ndo->ndo_eflag)
+        ND_PRINT((ndo, "MLPPP, "));
 
-    if (!eflag)
-        printf("MLPPP, ");
-
-    printf("seq 0x%03x, Flags [%s], length %u",
+    ND_PRINT((ndo, "seq 0x%03x, Flags [%s], length %u",
            (EXTRACT_16BITS(p))&0x0fff, /* only support 12-Bit sequence space for now */
            bittok2str(ppp_ml_flag_values, "none", *p & 0xc0),
-           length);
-
-    return;
+           length));
 }
 
 /* CHAP */
 static void
-handle_chap(const u_char *p, int length)
+handle_chap(netdissect_options *ndo,
+            const u_char *p, int length)
 {
 	u_int code, len;
 	int val_size, name_size, msg_size;
@@ -804,26 +828,26 @@
 
 	p0 = p;
 	if (length < 1) {
-		printf("[|chap]");
+		ND_PRINT((ndo, "[|chap]"));
 		return;
 	} else if (length < 4) {
-		TCHECK(*p);
-		printf("[|chap 0x%02x]", *p);
+		ND_TCHECK(*p);
+		ND_PRINT((ndo, "[|chap 0x%02x]", *p));
 		return;
 	}
 
-	TCHECK(*p);
+	ND_TCHECK(*p);
 	code = *p;
-        printf("CHAP, %s (0x%02x)",
+	ND_PRINT((ndo, "CHAP, %s (0x%02x)",
                tok2str(chapcode_values,"unknown",code),
-               code);
+               code));
 	p++;
 
-	TCHECK(*p);
-	printf(", id %u", *p);		/* ID */
+	ND_TCHECK(*p);
+	ND_PRINT((ndo, ", id %u", *p));		/* ID */
 	p++;
 
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	len = EXTRACT_16BITS(p);
 	p += 2;
 
@@ -839,42 +863,43 @@
 	case CHAP_RESP:
 		if (length - (p - p0) < 1)
 			return;
-		TCHECK(*p);
+		ND_TCHECK(*p);
 		val_size = *p;		/* value size */
 		p++;
 		if (length - (p - p0) < val_size)
 			return;
-		printf(", Value ");
+		ND_PRINT((ndo, ", Value "));
 		for (i = 0; i < val_size; i++) {
-			TCHECK(*p);
-			printf("%02x", *p++);
+			ND_TCHECK(*p);
+			ND_PRINT((ndo, "%02x", *p++));
 		}
 		name_size = len - (p - p0);
-		printf(", Name ");
+		ND_PRINT((ndo, ", Name "));
 		for (i = 0; i < name_size; i++) {
-			TCHECK(*p);
-			safeputchar(*p++);
+			ND_TCHECK(*p);
+			safeputchar(ndo, *p++);
 		}
 		break;
 	case CHAP_SUCC:
 	case CHAP_FAIL:
 		msg_size = len - (p - p0);
-		printf(", Msg ");
+		ND_PRINT((ndo, ", Msg "));
 		for (i = 0; i< msg_size; i++) {
-			TCHECK(*p);
-			safeputchar(*p++);
+			ND_TCHECK(*p);
+			safeputchar(ndo, *p++);
 		}
 		break;
 	}
 	return;
 
 trunc:
-	printf("[|chap]");
+	ND_PRINT((ndo, "[|chap]"));
 }
 
 /* PAP (see RFC 1334) */
 static void
-handle_pap(const u_char *p, int length)
+handle_pap(netdissect_options *ndo,
+           const u_char *p, int length)
 {
 	u_int code, len;
 	int peerid_len, passwd_len, msg_len;
@@ -883,36 +908,36 @@
 
 	p0 = p;
 	if (length < 1) {
-		printf("[|pap]");
+		ND_PRINT((ndo, "[|pap]"));
 		return;
 	} else if (length < 4) {
-		TCHECK(*p);
-		printf("[|pap 0x%02x]", *p);
+		ND_TCHECK(*p);
+		ND_PRINT((ndo, "[|pap 0x%02x]", *p));
 		return;
 	}
 
-	TCHECK(*p);
+	ND_TCHECK(*p);
 	code = *p;
-        printf("PAP, %s (0x%02x)",
-               tok2str(papcode_values,"unknown",code),
-               code);
+	ND_PRINT((ndo, "PAP, %s (0x%02x)",
+	          tok2str(papcode_values, "unknown", code),
+	          code));
 	p++;
 
-	TCHECK(*p);
-	printf(", id %u", *p);		/* ID */
+	ND_TCHECK(*p);
+	ND_PRINT((ndo, ", id %u", *p));		/* ID */
 	p++;
 
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	len = EXTRACT_16BITS(p);
 	p += 2;
 
 	if ((int)len > length) {
-		printf(", length %u > packet size", len);
+		ND_PRINT((ndo, ", length %u > packet size", len));
 		return;
 	}
 	length = len;
 	if (length < (p - p0)) {
-		printf(", length %u < PAP header length", length);
+		ND_PRINT((ndo, ", length %u < PAP header length", length));
 		return;
 	}
 
@@ -920,55 +945,56 @@
 	case PAP_AREQ:
 		if (length - (p - p0) < 1)
 			return;
-		TCHECK(*p);
+		ND_TCHECK(*p);
 		peerid_len = *p;	/* Peer-ID Length */
 		p++;
 		if (length - (p - p0) < peerid_len)
 			return;
-		printf(", Peer ");
+		ND_PRINT((ndo, ", Peer "));
 		for (i = 0; i < peerid_len; i++) {
-			TCHECK(*p);
-			safeputchar(*p++);
+			ND_TCHECK(*p);
+			safeputchar(ndo, *p++);
 		}
 
 		if (length - (p - p0) < 1)
 			return;
-		TCHECK(*p);
+		ND_TCHECK(*p);
 		passwd_len = *p;	/* Password Length */
 		p++;
 		if (length - (p - p0) < passwd_len)
 			return;
-		printf(", Name ");
+		ND_PRINT((ndo, ", Name "));
 		for (i = 0; i < passwd_len; i++) {
-			TCHECK(*p);
-			safeputchar(*p++);
+			ND_TCHECK(*p);
+			safeputchar(ndo, *p++);
 		}
 		break;
 	case PAP_AACK:
 	case PAP_ANAK:
 		if (length - (p - p0) < 1)
 			return;
-		TCHECK(*p);
+		ND_TCHECK(*p);
 		msg_len = *p;		/* Msg-Length */
 		p++;
 		if (length - (p - p0) < msg_len)
 			return;
-		printf(", Msg ");
+		ND_PRINT((ndo, ", Msg "));
 		for (i = 0; i< msg_len; i++) {
-			TCHECK(*p);
-			safeputchar(*p++);
+			ND_TCHECK(*p);
+			safeputchar(ndo, *p++);
 		}
 		break;
 	}
 	return;
 
 trunc:
-	printf("[|pap]");
+	ND_PRINT((ndo, "[|pap]"));
 }
 
 /* BAP */
 static void
-handle_bap(const u_char *p _U_, int length _U_)
+handle_bap(netdissect_options *ndo _U_,
+           const u_char *p _U_, int length _U_)
 {
 	/* XXX: to be supported!! */
 }
@@ -976,91 +1002,99 @@
 
 /* IPCP config options */
 static int
-print_ipcp_config_options(const u_char *p, int length)
+print_ipcp_config_options(netdissect_options *ndo,
+                          const u_char *p, int length)
 {
 	int len, opt;
         u_int compproto, ipcomp_subopttotallen, ipcomp_subopt, ipcomp_suboptlen;
 
 	if (length < 2)
 		return 0;
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	len = p[1];
 	opt = p[0];
 	if (length < len)
 		return 0;
 	if (len < 2) {
-		printf("\n\t  %s Option (0x%02x), length %u (bogus, should be >= 2)",
+		ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u (length bogus, should be >= 2)",
 		       tok2str(ipcpopt_values,"unknown",opt),
 		       opt,
-        	       len);
+		       len));
 		return 0;
 	}
 
-	printf("\n\t  %s Option (0x%02x), length %u: ",
+	ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u",
 	       tok2str(ipcpopt_values,"unknown",opt),
 	       opt,
-               len);
+	       len));
 
 	switch (opt) {
 	case IPCPOPT_2ADDR:		/* deprecated */
-		if (len != 10)
-			goto invlen;
-		TCHECK2(*(p + 6), 4);
-		printf("src %s, dst %s",
-		       ipaddr_string(p + 2),
-		       ipaddr_string(p + 6));
+		if (len != 10) {
+			ND_PRINT((ndo, " (length bogus, should be = 10)"));
+			return len;
+		}
+		ND_TCHECK2(*(p + 6), 4);
+		ND_PRINT((ndo, ": src %s, dst %s",
+		       ipaddr_string(ndo, p + 2),
+		       ipaddr_string(ndo, p + 6)));
 		break;
 	case IPCPOPT_IPCOMP:
-		if (len < 4)
-			goto invlen;
-		TCHECK2(*(p + 2), 2);
-                compproto = EXTRACT_16BITS(p+2);
+		if (len < 4) {
+			ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+			return 0;
+		}
+		ND_TCHECK2(*(p + 2), 2);
+		compproto = EXTRACT_16BITS(p+2);
 
-                printf("%s (0x%02x):",
-                       tok2str(ipcpopt_compproto_values,"Unknown",compproto),
-                       compproto);
+		ND_PRINT((ndo, ": %s (0x%02x):",
+		          tok2str(ipcpopt_compproto_values, "Unknown", compproto),
+		          compproto));
 
 		switch (compproto) {
                 case PPP_VJC:
 			/* XXX: VJ-Comp parameters should be decoded */
                         break;
                 case IPCPOPT_IPCOMP_HDRCOMP:
-                        if (len < IPCPOPT_IPCOMP_MINLEN)
-                                goto invlen;
+                        if (len < IPCPOPT_IPCOMP_MINLEN) {
+                        	ND_PRINT((ndo, " (length bogus, should be >= %u)",
+                        		IPCPOPT_IPCOMP_MINLEN));
+                        	return 0;
+                        }
 
-                        TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);
-                        printf("\n\t    TCP Space %u, non-TCP Space %u" \
+                        ND_TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);
+                        ND_PRINT((ndo, "\n\t    TCP Space %u, non-TCP Space %u" \
                                ", maxPeriod %u, maxTime %u, maxHdr %u",
                                EXTRACT_16BITS(p+4),
                                EXTRACT_16BITS(p+6),
                                EXTRACT_16BITS(p+8),
                                EXTRACT_16BITS(p+10),
-                               EXTRACT_16BITS(p+12));
+                               EXTRACT_16BITS(p+12)));
 
                         /* suboptions present ? */
                         if (len > IPCPOPT_IPCOMP_MINLEN) {
                                 ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN;
                                 p += IPCPOPT_IPCOMP_MINLEN;
-                                
-                                printf("\n\t      Suboptions, length %u", ipcomp_subopttotallen);
+
+                                ND_PRINT((ndo, "\n\t      Suboptions, length %u", ipcomp_subopttotallen));
 
                                 while (ipcomp_subopttotallen >= 2) {
-                                        TCHECK2(*p, 2);
+                                        ND_TCHECK2(*p, 2);
                                         ipcomp_subopt = *p;
                                         ipcomp_suboptlen = *(p+1);
-                                        
+
                                         /* sanity check */
                                         if (ipcomp_subopt == 0 ||
                                             ipcomp_suboptlen == 0 )
                                                 break;
 
                                         /* XXX: just display the suboptions for now */
-                                        printf("\n\t\t%s Suboption #%u, length %u",
+                                        ND_PRINT((ndo, "\n\t\t%s Suboption #%u, length %u",
                                                tok2str(ipcpopt_compproto_subopt_values,
                                                        "Unknown",
                                                        ipcomp_subopt),
                                                ipcomp_subopt,
-                                               ipcomp_suboptlen);
+                                               ipcomp_suboptlen));
 
                                         ipcomp_subopttotallen -= ipcomp_suboptlen;
                                         p += ipcomp_suboptlen;
@@ -1078,114 +1112,153 @@
 	case IPCPOPT_PRINBNS:
 	case IPCPOPT_SECDNS:
 	case IPCPOPT_SECNBNS:
-		if (len != 6)
-			goto invlen;
-		TCHECK2(*(p + 2), 4);
-		printf("%s", ipaddr_string(p + 2));
+		if (len != 6) {
+			ND_PRINT((ndo, " (length bogus, should be = 6)"));
+			return 0;
+		}
+		ND_TCHECK2(*(p + 2), 4);
+		ND_PRINT((ndo, ": %s", ipaddr_string(ndo, p + 2)));
 		break;
 	default:
-                if(vflag<2)
-                        print_unknown_data(&p[2],"\n\t    ",len-2);
+		/*
+		 * Unknown option; dump it as raw bytes now if we're
+		 * not going to do so below.
+		 */
+		if (ndo->ndo_vflag < 2)
+			print_unknown_data(ndo, &p[2], "\n\t    ", len - 2);
 		break;
 	}
-        if (vflag>1)
-                print_unknown_data(&p[2],"\n\t    ",len-2); /* exclude TLV header */
+	if (ndo->ndo_vflag > 1)
+		print_unknown_data(ndo, &p[2], "\n\t    ", len - 2); /* exclude TLV header */
 	return len;
 
-invlen:
-	printf(", invalid-length-%d", opt);
-	return 0;
-
 trunc:
-	printf("[|ipcp]");
+	ND_PRINT((ndo, "[|ipcp]"));
 	return 0;
 }
 
 /* IP6CP config options */
 static int
-print_ip6cp_config_options(const u_char *p, int length)
+print_ip6cp_config_options(netdissect_options *ndo,
+                           const u_char *p, int length)
 {
 	int len, opt;
 
 	if (length < 2)
 		return 0;
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	len = p[1];
 	opt = p[0];
 	if (length < len)
 		return 0;
 	if (len < 2) {
-		printf("\n\t  %s Option (0x%02x), length %u (bogus, should be >= 2)",
+		ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u (length bogus, should be >= 2)",
 		       tok2str(ip6cpopt_values,"unknown",opt),
 		       opt,
-	               len);
-	        return 0;
+		       len));
+		return 0;
 	}
 
-	printf("\n\t  %s Option (0x%02x), length %u: ",
+	ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u",
 	       tok2str(ip6cpopt_values,"unknown",opt),
 	       opt,
-               len);
+	       len));
 
 	switch (opt) {
 	case IP6CP_IFID:
-		if (len != 10)
-			goto invlen;
-		TCHECK2(*(p + 2), 8);
-		printf("%04x:%04x:%04x:%04x",
+		if (len != 10) {
+			ND_PRINT((ndo, " (length bogus, should be = 10)"));
+			return len;
+		}
+		ND_TCHECK2(*(p + 2), 8);
+		ND_PRINT((ndo, ": %04x:%04x:%04x:%04x",
 		       EXTRACT_16BITS(p + 2),
 		       EXTRACT_16BITS(p + 4),
 		       EXTRACT_16BITS(p + 6),
-		       EXTRACT_16BITS(p + 8));
+		       EXTRACT_16BITS(p + 8)));
 		break;
 	default:
-                if(vflag<2)
-                        print_unknown_data(&p[2],"\n\t    ",len-2);
+		/*
+		 * Unknown option; dump it as raw bytes now if we're
+		 * not going to do so below.
+		 */
+		if (ndo->ndo_vflag < 2)
+			print_unknown_data(ndo, &p[2], "\n\t    ", len - 2);
 		break;
 	}
-        if (vflag>1)
-                print_unknown_data(&p[2],"\n\t    ",len-2); /* exclude TLV header */
+	if (ndo->ndo_vflag > 1)
+		print_unknown_data(ndo, &p[2], "\n\t    ", len - 2); /* exclude TLV header */
 
 	return len;
 
-invlen:
-	printf(", invalid-length-%d", opt);
-	return 0;
-
 trunc:
-	printf("[|ip6cp]");
+	ND_PRINT((ndo, "[|ip6cp]"));
 	return 0;
 }
 
 
 /* CCP config options */
 static int
-print_ccp_config_options(const u_char *p, int length)
+print_ccp_config_options(netdissect_options *ndo,
+                         const u_char *p, int length)
 {
 	int len, opt;
 
 	if (length < 2)
 		return 0;
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	len = p[1];
 	opt = p[0];
 	if (length < len)
 		return 0;
 	if (len < 2) {
-	        printf("\n\t  %s Option (0x%02x), length %u (bogus, should be >= 2)",
-        	       tok2str(ccpconfopts_values, "Unknown", opt),
-	               opt,
-        	       len);
-        	return 0;
-        }
+		ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+		          tok2str(ccpconfopts_values, "Unknown", opt),
+		          opt,
+		          len));
+		return 0;
+	}
 
-        printf("\n\t  %s Option (0x%02x), length %u:",
-               tok2str(ccpconfopts_values, "Unknown", opt),
-               opt,
-               len);
+	ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u",
+	          tok2str(ccpconfopts_values, "Unknown", opt),
+	          opt,
+	          len));
 
 	switch (opt) {
-                /* fall through --> default: nothing supported yet */
+	case CCPOPT_BSDCOMP:
+		if (len < 3) {
+			ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+			return len;
+		}
+		ND_TCHECK2(*(p + 2), 1);
+		ND_PRINT((ndo, ": Version: %u, Dictionary Bits: %u",
+			p[2] >> 5, p[2] & 0x1f));
+		break;
+	case CCPOPT_MVRCA:
+		if (len < 4) {
+			ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+			return len;
+		}
+		ND_TCHECK2(*(p + 2), 1);
+		ND_PRINT((ndo, ": Features: %u, PxP: %s, History: %u, #CTX-ID: %u",
+				(p[2] & 0xc0) >> 6,
+				(p[2] & 0x20) ? "Enabled" : "Disabled",
+				p[2] & 0x1f, p[3]));
+		break;
+	case CCPOPT_DEFLATE:
+		if (len < 4) {
+			ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+			return len;
+		}
+		ND_TCHECK2(*(p + 2), 1);
+		ND_PRINT((ndo, ": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u",
+			(p[2] & 0xf0) >> 4,
+			((p[2] & 0x0f) == 8) ? "zlib" : "unkown",
+			p[2] & 0x0f, (p[3] & 0xfc) >> 2, p[3] & 0x03));
+		break;
+
+/* XXX: to be supported */
+#if 0
 	case CCPOPT_OUI:
 	case CCPOPT_PRED1:
 	case CCPOPT_PRED2:
@@ -1195,82 +1268,98 @@
 	case CCPOPT_MPPC:
 	case CCPOPT_GFZA:
 	case CCPOPT_V42BIS:
-	case CCPOPT_BSDCOMP:
 	case CCPOPT_LZSDCP:
-	case CCPOPT_MVRCA:
 	case CCPOPT_DEC:
-	case CCPOPT_DEFLATE:
 	case CCPOPT_RESV:
+		break;
+#endif
 	default:
-                if(vflag<2)
-                        print_unknown_data(&p[2],"\n\t    ",len-2);
+		/*
+		 * Unknown option; dump it as raw bytes now if we're
+		 * not going to do so below.
+		 */
+		if (ndo->ndo_vflag < 2)
+			print_unknown_data(ndo, &p[2], "\n\t    ", len - 2);
 		break;
 	}
-        if (vflag>1)
-                print_unknown_data(&p[2],"\n\t    ",len-2); /* exclude TLV header */
+	if (ndo->ndo_vflag > 1)
+		print_unknown_data(ndo, &p[2], "\n\t    ", len - 2); /* exclude TLV header */
 
 	return len;
 
 trunc:
-	printf("[|ccp]");
+	ND_PRINT((ndo, "[|ccp]"));
 	return 0;
 }
 
 /* BACP config options */
 static int
-print_bacp_config_options(const u_char *p, int length)
+print_bacp_config_options(netdissect_options *ndo,
+                          const u_char *p, int length)
 {
 	int len, opt;
 
 	if (length < 2)
 		return 0;
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	len = p[1];
 	opt = p[0];
 	if (length < len)
 		return 0;
 	if (len < 2) {
-	        printf("\n\t  %s Option (0x%02x), length %u (bogus, should be >= 2)",
-        	       tok2str(bacconfopts_values, "Unknown", opt),
-	               opt,
-        	       len);
-        	return 0;
-        }
+		ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+		          tok2str(bacconfopts_values, "Unknown", opt),
+		          opt,
+		          len));
+		return 0;
+	}
 
-        printf("\n\t  %s Option (0x%02x), length %u:",
-               tok2str(bacconfopts_values, "Unknown", opt),
-               opt,
-               len);
+	ND_PRINT((ndo, "\n\t  %s Option (0x%02x), length %u",
+	          tok2str(bacconfopts_values, "Unknown", opt),
+	          opt,
+	          len));
 
 	switch (opt) {
 	case BACPOPT_FPEER:
-		TCHECK2(*(p + 2), 4);
-		printf(", Magic-Num 0x%08x", EXTRACT_32BITS(p + 2));
-                break;
+		if (len != 6) {
+			ND_PRINT((ndo, " (length bogus, should be = 6)"));
+			return len;
+		}
+		ND_TCHECK2(*(p + 2), 4);
+		ND_PRINT((ndo, ": Magic-Num 0x%08x", EXTRACT_32BITS(p + 2)));
+		break;
 	default:
-                if(vflag<2)
-                        print_unknown_data(&p[2],"\n\t    ",len-2);
+		/*
+		 * Unknown option; dump it as raw bytes now if we're
+		 * not going to do so below.
+		 */
+		if (ndo->ndo_vflag < 2)
+			print_unknown_data(ndo, &p[2], "\n\t    ", len - 2);
 		break;
 	}
-        if (vflag>1)
-                print_unknown_data(&p[2],"\n\t    ",len-2); /* exclude TLV header */
+	if (ndo->ndo_vflag > 1)
+		print_unknown_data(ndo, &p[2], "\n\t    ", len - 2); /* exclude TLV header */
 
 	return len;
 
 trunc:
-	printf("[|bacp]");
+	ND_PRINT((ndo, "[|bacp]"));
 	return 0;
 }
 
-
 static void
-ppp_hdlc(const u_char *p, int length)
+ppp_hdlc(netdissect_options *ndo,
+         const u_char *p, int length)
 {
-	u_char *b, *s, *t, c;
+	u_char *b, *t, c;
+	const u_char *s;
 	int i, proto;
 	const void *se;
 
-	b = (u_int8_t *)malloc(length);
+        if (length <= 0)
+                return;
+
+	b = (u_char *)malloc(length);
 	if (b == NULL)
 		return;
 
@@ -1279,64 +1368,74 @@
 	 * Do this so that we dont overwrite the original packet
 	 * contents.
 	 */
-	for (s = (u_char *)p, t = b, i = length; i > 0; i--) {
+	for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) {
 		c = *s++;
 		if (c == 0x7d) {
-			if (i > 1) {
-				i--;
-				c = *s++ ^ 0x20;
-			} else
-				continue;
+			if (i <= 1 || !ND_TTEST(*s))
+				break;
+			i--;
+			c = *s++ ^ 0x20;
 		}
 		*t++ = c;
 	}
 
-	se = snapend;
-	snapend = t;
+	se = ndo->ndo_snapend;
+	ndo->ndo_snapend = t;
+	length = t - b;
 
         /* now lets guess about the payload codepoint format */
+        if (length < 1)
+                goto trunc;
         proto = *b; /* start with a one-octet codepoint guess */
-        
+
         switch (proto) {
         case PPP_IP:
-		ip_print(gndo, b+1, t - b - 1);
+		ip_print(ndo, b + 1, length - 1);
 		goto cleanup;
-#ifdef INET6
         case PPP_IPV6:
-		ip6_print(gndo, b+1, t - b - 1);
+		ip6_print(ndo, b + 1, length - 1);
 		goto cleanup;
-#endif
         default: /* no luck - try next guess */
 		break;
         }
 
+        if (length < 2)
+                goto trunc;
         proto = EXTRACT_16BITS(b); /* next guess - load two octets */
 
         switch (proto) {
         case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */
+            if (length < 4)
+                goto trunc;
             proto = EXTRACT_16BITS(b+2); /* load the PPP proto-id */
-            handle_ppp(proto, b+4, t - b - 4);
+            handle_ppp(ndo, proto, b + 4, length - 4);
             break;
         default: /* last guess - proto must be a PPP proto-id */
-            handle_ppp(proto, b+2, t - b - 2);
+            handle_ppp(ndo, proto, b + 2, length - 2);
             break;
         }
 
 cleanup:
-        snapend = se;
+	ndo->ndo_snapend = se;
 	free(b);
         return;
+
+trunc:
+	ndo->ndo_snapend = se;
+	free(b);
+	ND_PRINT((ndo, "[|ppp]"));
 }
 
 
 /* PPP */
 static void
-handle_ppp(u_int proto, const u_char *p, int length)
+handle_ppp(netdissect_options *ndo,
+           u_int proto, const u_char *p, int length)
 {
-        if ((proto & 0xff00) == 0x7e00) {/* is this an escape code ? */
-            ppp_hdlc(p-1, length);
-            return;
-        }
+	if ((proto & 0xff00) == 0x7e00) { /* is this an escape code ? */
+		ppp_hdlc(ndo, p - 1, length);
+		return;
+	}
 
 	switch (proto) {
 	case PPP_LCP: /* fall through */
@@ -1346,55 +1445,54 @@
 	case PPP_IPV6CP:
 	case PPP_CCP:
 	case PPP_BACP:
-		handle_ctrl_proto(proto, p, length);
+		handle_ctrl_proto(ndo, proto, p, length);
 		break;
-        case PPP_ML:
-                handle_mlppp(p, length);
-                break;
+	case PPP_ML:
+		handle_mlppp(ndo, p, length);
+		break;
 	case PPP_CHAP:
-		handle_chap(p, length);
+		handle_chap(ndo, p, length);
 		break;
 	case PPP_PAP:
-		handle_pap(p, length);
+		handle_pap(ndo, p, length);
 		break;
 	case PPP_BAP:		/* XXX: not yet completed */
-		handle_bap(p, length);
+		handle_bap(ndo, p, length);
 		break;
 	case ETHERTYPE_IP:	/*XXX*/
         case PPP_VJNC:
 	case PPP_IP:
-		ip_print(gndo, p, length);
+		ip_print(ndo, p, length);
 		break;
-#ifdef INET6
 	case ETHERTYPE_IPV6:	/*XXX*/
 	case PPP_IPV6:
-		ip6_print(gndo, p, length);
+		ip6_print(ndo, p, length);
 		break;
-#endif
 	case ETHERTYPE_IPX:	/*XXX*/
 	case PPP_IPX:
-		ipx_print(p, length);
+		ipx_print(ndo, p, length);
 		break;
 	case PPP_OSI:
-	        isoclns_print(p, length, length);
-	        break;
+		isoclns_print(ndo, p, length, length);
+		break;
 	case PPP_MPLS_UCAST:
 	case PPP_MPLS_MCAST:
-		mpls_print(p, length);
+		mpls_print(ndo, p, length);
 		break;
 	case PPP_COMP:
-		printf("compressed PPP data");
+		ND_PRINT((ndo, "compressed PPP data"));
 		break;
 	default:
-		printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
-		print_unknown_data(p,"\n\t",length);
+		ND_PRINT((ndo, "%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto)));
+		print_unknown_data(ndo, p, "\n\t", length);
 		break;
 	}
 }
 
 /* Standard PPP printer */
 u_int
-ppp_print(register const u_char *p, u_int length)
+ppp_print(netdissect_options *ndo,
+          register const u_char *p, u_int length)
 {
 	u_int proto,ppp_header;
         u_int olen = length; /* _o_riginal length */
@@ -1406,18 +1504,18 @@
 	 */
 	if (length < 2)
 		goto trunc;
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
         ppp_header = EXTRACT_16BITS(p);
 
         switch(ppp_header) {
         case (PPP_WITHDIRECTION_IN  << 8 | PPP_CONTROL):
-            if (eflag) printf("In  ");
+            if (ndo->ndo_eflag) ND_PRINT((ndo, "In  "));
             p += 2;
             length -= 2;
             hdr_len += 2;
             break;
         case (PPP_WITHDIRECTION_OUT << 8 | PPP_CONTROL):
-            if (eflag) printf("Out ");
+            if (ndo->ndo_eflag) ND_PRINT((ndo, "Out "));
             p += 2;
             length -= 2;
             hdr_len += 2;
@@ -1434,43 +1532,44 @@
 
 	if (length < 2)
 		goto trunc;
-	TCHECK(*p);
+	ND_TCHECK(*p);
 	if (*p % 2) {
 		proto = *p;		/* PFC is used */
 		p++;
 		length--;
 		hdr_len++;
 	} else {
-		TCHECK2(*p, 2);
+		ND_TCHECK2(*p, 2);
 		proto = EXTRACT_16BITS(p);
 		p += 2;
 		length -= 2;
 		hdr_len += 2;
 	}
 
-        if (eflag)
-            printf("%s (0x%04x), length %u: ",
-                   tok2str(ppptype2str, "unknown", proto),
-                   proto,
-                   olen);
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "%s (0x%04x), length %u: ",
+		          tok2str(ppptype2str, "unknown", proto),
+		          proto,
+		          olen));
 
-	handle_ppp(proto, p, length);
+	handle_ppp(ndo, proto, p, length);
 	return (hdr_len);
 trunc:
-	printf("[|ppp]");
+	ND_PRINT((ndo, "[|ppp]"));
 	return (0);
 }
 
 
 /* PPP I/F printer */
 u_int
-ppp_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ppp_if_print(netdissect_options *ndo,
+             const struct pcap_pkthdr *h, register const u_char *p)
 {
 	register u_int length = h->len;
 	register u_int caplen = h->caplen;
 
 	if (caplen < PPP_HDRLEN) {
-		printf("[|ppp]");
+		ND_PRINT((ndo, "[|ppp]"));
 		return (caplen);
 	}
 
@@ -1511,11 +1610,11 @@
 	 * (Is the Cisco framing in question what DLT_C_HDLC, in
 	 * BSD/OS, is?)
 	 */
-	if (eflag)
-		printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]);
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]));
 #endif
 
-	ppp_print(p, length);
+	ppp_print(ndo, p, length);
 
 	return (0);
 }
@@ -1530,7 +1629,8 @@
  * This handles, for example, DLT_PPP_SERIAL in NetBSD.
  */
 u_int
-ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ppp_hdlc_if_print(netdissect_options *ndo,
+                  const struct pcap_pkthdr *h, register const u_char *p)
 {
 	register u_int length = h->len;
 	register u_int caplen = h->caplen;
@@ -1538,7 +1638,7 @@
 	u_int hdrlen = 0;
 
 	if (caplen < 2) {
-		printf("[|ppp]");
+		ND_PRINT((ndo, "[|ppp]"));
 		return (caplen);
 	}
 
@@ -1546,12 +1646,12 @@
 
 	case PPP_ADDRESS:
 		if (caplen < 4) {
-			printf("[|ppp]");
+			ND_PRINT((ndo, "[|ppp]"));
 			return (caplen);
 		}
 
-		if (eflag)
-			printf("%02x %02x %d ", p[0], p[1], length);
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "%02x %02x %d ", p[0], p[1], length));
 		p += 2;
 		length -= 2;
 		hdrlen += 2;
@@ -1560,20 +1660,19 @@
 		p += 2;
 		length -= 2;
 		hdrlen += 2;
-		printf("%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
+		ND_PRINT((ndo, "%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto)));
 
-		handle_ppp(proto, p, length);
+		handle_ppp(ndo, proto, p, length);
 		break;
 
 	case CHDLC_UNICAST:
 	case CHDLC_BCAST:
-		return (chdlc_if_print(h, p));
+		return (chdlc_if_print(ndo, h, p));
 
 	default:
-		if (eflag)
-			printf("%02x %02x %d ", p[0], p[1], length);
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "%02x %02x %d ", p[0], p[1], length));
 		p += 2;
-		length -= 2;
 		hdrlen += 2;
 
 		/*
@@ -1581,7 +1680,7 @@
 		 * the next two octets as an Ethernet type; does that
 		 * ever happen?
 		 */
-		printf("unknown addr %02x; ctrl %02x", p[0], p[1]);
+		ND_PRINT((ndo, "unknown addr %02x; ctrl %02x", p[0], p[1]));
 		break;
 	}
 
@@ -1592,18 +1691,19 @@
 
 /* BSD/OS specific PPP printer */
 u_int
-ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_)
+ppp_bsdos_if_print(netdissect_options *ndo _U_,
+                   const struct pcap_pkthdr *h _U_, register const u_char *p _U_)
 {
 	register int hdrlength;
 #ifdef __bsdi__
 	register u_int length = h->len;
 	register u_int caplen = h->caplen;
-	u_int16_t ptype;
+	uint16_t ptype;
 	const u_char *q;
 	int i;
 
 	if (caplen < PPP_BSDI_HDRLEN) {
-		printf("[|ppp]");
+		ND_PRINT((ndo, "[|ppp]"));
 		return (caplen)
 	}
 
@@ -1611,34 +1711,34 @@
 
 #if 0
 	if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
-		if (eflag)
-			printf("%02x %02x ", p[0], p[1]);
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "%02x %02x ", p[0], p[1]));
 		p += 2;
 		hdrlength = 2;
 	}
 
-	if (eflag)
-		printf("%d ", length);
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "%d ", length));
 	/* Retrieve the protocol type */
 	if (*p & 01) {
 		/* Compressed protocol field */
 		ptype = *p;
-		if (eflag)
-			printf("%02x ", ptype);
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "%02x ", ptype));
 		p++;
 		hdrlength += 1;
 	} else {
 		/* Un-compressed protocol field */
 		ptype = EXTRACT_16BITS(p);
-		if (eflag)
-			printf("%04x ", ptype);
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "%04x ", ptype));
 		p += 2;
 		hdrlength += 2;
 	}
 #else
 	ptype = 0;	/*XXX*/
-	if (eflag)
-		printf("%c ", p[SLC_DIR] ? 'O' : 'I');
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "%c ", p[SLC_DIR] ? 'O' : 'I'));
 	if (p[SLC_LLHL]) {
 		/* link level header */
 		struct ppp_header *ph;
@@ -1647,72 +1747,68 @@
 		ph = (struct ppp_header *)q;
 		if (ph->phdr_addr == PPP_ADDRESS
 		 && ph->phdr_ctl == PPP_CONTROL) {
-			if (eflag)
-				printf("%02x %02x ", q[0], q[1]);
+			if (ndo->ndo_eflag)
+				ND_PRINT((ndo, "%02x %02x ", q[0], q[1]));
 			ptype = EXTRACT_16BITS(&ph->phdr_type);
-			if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
-				printf("%s ", tok2str(ppptype2str,
-						"proto-#%d", ptype));
+			if (ndo->ndo_eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
+				ND_PRINT((ndo, "%s ", tok2str(ppptype2str,
+						"proto-#%d", ptype)));
 			}
 		} else {
-			if (eflag) {
-				printf("LLH=[");
+			if (ndo->ndo_eflag) {
+				ND_PRINT((ndo, "LLH=["));
 				for (i = 0; i < p[SLC_LLHL]; i++)
-					printf("%02x", q[i]);
-				printf("] ");
+					ND_PRINT((ndo, "%02x", q[i]));
+				ND_PRINT((ndo, "] "));
 			}
 		}
 	}
-	if (eflag)
-		printf("%d ", length);
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "%d ", length));
 	if (p[SLC_CHL]) {
 		q = p + SLC_BPFHDRLEN + p[SLC_LLHL];
 
 		switch (ptype) {
 		case PPP_VJC:
-			ptype = vjc_print(q, ptype);
+			ptype = vjc_print(ndo, q, ptype);
 			hdrlength = PPP_BSDI_HDRLEN;
 			p += hdrlength;
 			switch (ptype) {
 			case PPP_IP:
-				ip_print(gndo, p, length);
+				ip_print(ndo, p, length);
 				break;
-#ifdef INET6
 			case PPP_IPV6:
-				ip6_print(gndo, p, length);
+				ip6_print(ndo, p, length);
 				break;
-#endif
 			case PPP_MPLS_UCAST:
 			case PPP_MPLS_MCAST:
-				mpls_print(p, length);
+				mpls_print(ndo, p, length);
 				break;
 			}
 			goto printx;
 		case PPP_VJNC:
-			ptype = vjc_print(q, ptype);
+			ptype = vjc_print(ndo, q, ptype);
 			hdrlength = PPP_BSDI_HDRLEN;
 			p += hdrlength;
 			switch (ptype) {
 			case PPP_IP:
-				ip_print(gndo, p, length);
+				ip_print(ndo, p, length);
 				break;
-#ifdef INET6
 			case PPP_IPV6:
-				ip6_print(gndo, p, length);
+				ip6_print(ndo, p, length);
 				break;
-#endif
 			case PPP_MPLS_UCAST:
 			case PPP_MPLS_MCAST:
-				mpls_print(p, length);
+				mpls_print(ndo, p, length);
 				break;
 			}
 			goto printx;
 		default:
-			if (eflag) {
-				printf("CH=[");
+			if (ndo->ndo_eflag) {
+				ND_PRINT((ndo, "CH=["));
 				for (i = 0; i < p[SLC_LLHL]; i++)
-					printf("%02x", q[i]);
-				printf("] ");
+					ND_PRINT((ndo, "%02x", q[i]));
+				ND_PRINT((ndo, "] "));
 			}
 			break;
 		}
@@ -1728,17 +1824,15 @@
 	case PPP_IP:
 		ip_print(p, length);
 		break;
-#ifdef INET6
 	case PPP_IPV6:
-		ip6_print(gndo, p, length);
+		ip6_print(ndo, p, length);
 		break;
-#endif
-        case PPP_MPLS_UCAST:
-        case PPP_MPLS_MCAST:
-                mpls_print(gndo, p, length);
-                break;
+	case PPP_MPLS_UCAST:
+	case PPP_MPLS_MCAST:
+		mpls_print(ndo, p, length);
+		break;
 	default:
-		printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype));
+		ND_PRINT((ndo, "%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype)));
 	}
 
 printx:
diff --git a/print-pppoe.c b/print-pppoe.c
index f8c9008..1624c5e 100644
--- a/print-pppoe.c
+++ b/print-pppoe.c
@@ -17,29 +17,18 @@
  * 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.
- * 
- * Original code by Greg Stark <gsstark@mit.edu> 
+ *
+ * Original code by Greg Stark <gsstark@mit.edu>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.31 2005-04-26 19:48:38 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
-#include "addrtoname.h"
-#include "ppp.h"
-#include "ethertype.h"
-#include "ether.h"
 #include "extract.h"			/* must come after interface.h */
 
 /* Codes */
@@ -95,25 +84,25 @@
 #define MAXTAGPRINT 80
 
 u_int
-pppoe_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pppoe_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
-	return (pppoe_print(p, h->len));
+	return (pppoe_print(ndo, p, h->len));
 }
 
 u_int
-pppoe_print(register const u_char *bp, u_int length)
+pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
 {
-	u_int16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
+	uint16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
 	u_int pppoe_length;
 	const u_char *pppoe_packet, *pppoe_payload;
 
 	if (length < PPPOE_HDRLEN) {
-		(void)printf("truncated-pppoe %u", length);
+		ND_PRINT((ndo, "truncated-pppoe %u", length));
 		return (length);
 	}
 	length -= PPPOE_HDRLEN;
 	pppoe_packet = bp;
-	TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
+	ND_TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
 	pppoe_ver  = (pppoe_packet[0] & 0xF0) >> 4;
 	pppoe_type  = (pppoe_packet[0] & 0x0F);
 	pppoe_code = pppoe_packet[1];
@@ -122,22 +111,22 @@
 	pppoe_payload = pppoe_packet + PPPOE_HDRLEN;
 
 	if (pppoe_ver != 1) {
-		printf(" [ver %d]",pppoe_ver);
+		ND_PRINT((ndo, " [ver %d]",pppoe_ver));
 	}
 	if (pppoe_type != 1) {
-		printf(" [type %d]",pppoe_type);
+		ND_PRINT((ndo, " [type %d]",pppoe_type));
 	}
 
-	printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
+	ND_PRINT((ndo, "PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code)));
 	if (pppoe_code == PPPOE_PADI && pppoe_length > 1484 - PPPOE_HDRLEN) {
-		printf(" [len %u!]",pppoe_length);
+		ND_PRINT((ndo, " [len %u!]",pppoe_length));
 	}
 	if (pppoe_length > length) {
-		printf(" [len %u > %u!]", pppoe_length, length);
+		ND_PRINT((ndo, " [len %u > %u!]", pppoe_length, length));
 		pppoe_length = length;
 	}
 	if (pppoe_sessionid) {
-		printf(" [ses 0x%x]", pppoe_sessionid);
+		ND_PRINT((ndo, " [ses 0x%x]", pppoe_sessionid));
 	}
 
 	if (pppoe_code) {
@@ -151,7 +140,7 @@
 		 * tag_type is previous tag or 0xffff for first iteration
 		 */
 		while (tag_type && p < pppoe_payload + pppoe_length) {
-			TCHECK2(*p, 4);
+			ND_TCHECK2(*p, 4);
 			tag_type = EXTRACT_16BITS(p);
 			tag_len = EXTRACT_16BITS(p + 2);
 			p += 4;
@@ -164,7 +153,7 @@
 				unsigned tag_str_len = 0;
 
 				/* TODO print UTF-8 decoded text */
-				TCHECK2(*p, tag_len);
+				ND_TCHECK2(*p, tag_len);
 				for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++)
 					if (*v >= 32 && *v < 127) {
 						tag_str[tag_str_len++] = *v;
@@ -176,24 +165,24 @@
 				tag_str[tag_str_len] = 0;
 
 				if (isascii > isgarbage) {
-					printf(" [%s \"%*.*s\"]",
+					ND_PRINT((ndo, " [%s \"%*.*s\"]",
 					       tok2str(pppoetag2str, "TAG-0x%x", tag_type),
 					       (int)tag_str_len,
 					       (int)tag_str_len,
-					       tag_str);
+					       tag_str));
 				} else {
 					/* Print hex, not fast to abuse printf but this doesn't get used much */
-					printf(" [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+					ND_PRINT((ndo, " [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type)));
 					for (v=p; v<p+tag_len; v++) {
-						printf("%02X", *v);
+						ND_PRINT((ndo, "%02X", *v));
 					}
-					printf("]");
+					ND_PRINT((ndo, "]"));
 				}
-				
+
 
 			} else
-				printf(" [%s]", tok2str(pppoetag2str,
-				    "TAG-0x%x", tag_type));
+				ND_PRINT((ndo, " [%s]", tok2str(pppoetag2str,
+				    "TAG-0x%x", tag_type)));
 
 			p += tag_len;
 			/* p points to next tag */
@@ -201,11 +190,11 @@
 		return (0);
 	} else {
 		/* PPPoE data */
-		printf(" ");
-		return (PPPOE_HDRLEN + ppp_print(pppoe_payload, pppoe_length));
+		ND_PRINT((ndo, " "));
+		return (PPPOE_HDRLEN + ppp_print(ndo, pppoe_payload, pppoe_length));
 	}
 
 trunc:
-	printf("[|pppoe]");
+	ND_PRINT((ndo, "[|pppoe]"));
 	return (PPPOE_HDRLEN);
 }
diff --git a/print-pptp.c b/print-pptp.c
index 2fbba62..c77868d 100644
--- a/print-pptp.c
+++ b/print-pptp.c
@@ -21,24 +21,17 @@
  * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
  */
 
-
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.12 2006-06-23 02:03:09 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "extract.h"
 
-static char tstr[] = " [|pptp]";
+static const char tstr[] = " [|pptp]";
 
 #define PPTP_MSG_TYPE_CTRL	1	/* Control Message */
 #define PPTP_MSG_TYPE_MGMT	2	/* Management Message (currently not used */
@@ -91,147 +84,147 @@
 
 /* common for all PPTP control messages */
 struct pptp_hdr {
-	u_int16_t length;
-	u_int16_t msg_type;
-	u_int32_t magic_cookie;
-	u_int16_t ctrl_msg_type;
-	u_int16_t reserved0;
+	uint16_t length;
+	uint16_t msg_type;
+	uint32_t magic_cookie;
+	uint16_t ctrl_msg_type;
+	uint16_t reserved0;
 };
 
 struct pptp_msg_sccrq {
-	u_int16_t proto_ver;
-	u_int16_t reserved1;
-	u_int32_t framing_cap;
-	u_int32_t bearer_cap;
-	u_int16_t max_channel;
-	u_int16_t firm_rev;
+	uint16_t proto_ver;
+	uint16_t reserved1;
+	uint32_t framing_cap;
+	uint32_t bearer_cap;
+	uint16_t max_channel;
+	uint16_t firm_rev;
 	u_char hostname[64];
 	u_char vendor[64];
 };
 
 struct pptp_msg_sccrp {
-	u_int16_t proto_ver;
-	u_int8_t result_code;
-	u_int8_t err_code;
-	u_int32_t framing_cap;
-	u_int32_t bearer_cap;
-	u_int16_t max_channel;
-	u_int16_t firm_rev;
+	uint16_t proto_ver;
+	uint8_t result_code;
+	uint8_t err_code;
+	uint32_t framing_cap;
+	uint32_t bearer_cap;
+	uint16_t max_channel;
+	uint16_t firm_rev;
 	u_char hostname[64];
 	u_char vendor[64];
 };
 
 struct pptp_msg_stopccrq {
-	u_int8_t reason;
-	u_int8_t reserved1;
-	u_int16_t reserved2;
+	uint8_t reason;
+	uint8_t reserved1;
+	uint16_t reserved2;
 };
 
 struct pptp_msg_stopccrp {
-	u_int8_t result_code;
-	u_int8_t err_code;
-	u_int16_t reserved1;
+	uint8_t result_code;
+	uint8_t err_code;
+	uint16_t reserved1;
 };
 
 struct pptp_msg_echorq {
-	u_int32_t id;
+	uint32_t id;
 };
 
 struct pptp_msg_echorp {
-	u_int32_t id;
-	u_int8_t result_code;
-	u_int8_t err_code;
-	u_int16_t reserved1;
+	uint32_t id;
+	uint8_t result_code;
+	uint8_t err_code;
+	uint16_t reserved1;
 };
 
 struct pptp_msg_ocrq {
-	u_int16_t call_id;
-	u_int16_t call_ser;
-	u_int32_t min_bps;
-	u_int32_t max_bps;
-	u_int32_t bearer_type;
-	u_int32_t framing_type;
-	u_int16_t recv_winsiz;
-	u_int16_t pkt_proc_delay;
-	u_int16_t phone_no_len;
-	u_int16_t reserved1;
+	uint16_t call_id;
+	uint16_t call_ser;
+	uint32_t min_bps;
+	uint32_t max_bps;
+	uint32_t bearer_type;
+	uint32_t framing_type;
+	uint16_t recv_winsiz;
+	uint16_t pkt_proc_delay;
+	uint16_t phone_no_len;
+	uint16_t reserved1;
 	u_char phone_no[64];
 	u_char subaddr[64];
 };
 
 struct pptp_msg_ocrp {
-	u_int16_t call_id;
-	u_int16_t peer_call_id;
-	u_int8_t result_code;
-	u_int8_t err_code;
-	u_int16_t cause_code;
-	u_int32_t conn_speed;
-	u_int16_t recv_winsiz;
-	u_int16_t pkt_proc_delay;
-	u_int32_t phy_chan_id;
+	uint16_t call_id;
+	uint16_t peer_call_id;
+	uint8_t result_code;
+	uint8_t err_code;
+	uint16_t cause_code;
+	uint32_t conn_speed;
+	uint16_t recv_winsiz;
+	uint16_t pkt_proc_delay;
+	uint32_t phy_chan_id;
 };
 
 struct pptp_msg_icrq {
-	u_int16_t call_id;
-	u_int16_t call_ser;
-	u_int32_t bearer_type;
-	u_int32_t phy_chan_id;
-	u_int16_t dialed_no_len;
-	u_int16_t dialing_no_len;
+	uint16_t call_id;
+	uint16_t call_ser;
+	uint32_t bearer_type;
+	uint32_t phy_chan_id;
+	uint16_t dialed_no_len;
+	uint16_t dialing_no_len;
 	u_char dialed_no[64];		/* DNIS */
 	u_char dialing_no[64];		/* CLID */
 	u_char subaddr[64];
 };
 
 struct pptp_msg_icrp {
-	u_int16_t call_id;
-	u_int16_t peer_call_id;
-	u_int8_t result_code;
-	u_int8_t err_code;
-	u_int16_t recv_winsiz;
-	u_int16_t pkt_proc_delay;
-	u_int16_t reserved1;
+	uint16_t call_id;
+	uint16_t peer_call_id;
+	uint8_t result_code;
+	uint8_t err_code;
+	uint16_t recv_winsiz;
+	uint16_t pkt_proc_delay;
+	uint16_t reserved1;
 };
 
 struct pptp_msg_iccn {
-	u_int16_t peer_call_id;
-	u_int16_t reserved1;
-	u_int32_t conn_speed;
-	u_int16_t recv_winsiz;
-	u_int16_t pkt_proc_delay;
-	u_int32_t framing_type;
+	uint16_t peer_call_id;
+	uint16_t reserved1;
+	uint32_t conn_speed;
+	uint16_t recv_winsiz;
+	uint16_t pkt_proc_delay;
+	uint32_t framing_type;
 };
 
 struct pptp_msg_ccrq {
-	u_int16_t call_id;
-	u_int16_t reserved1;
+	uint16_t call_id;
+	uint16_t reserved1;
 };
 
 struct pptp_msg_cdn {
-	u_int16_t call_id;
-	u_int8_t result_code;
-	u_int8_t err_code;
-	u_int16_t cause_code;
-	u_int16_t reserved1;
+	uint16_t call_id;
+	uint8_t result_code;
+	uint8_t err_code;
+	uint16_t cause_code;
+	uint16_t reserved1;
 	u_char call_stats[128];
 };
 
 struct pptp_msg_wen {
-	u_int16_t peer_call_id;
-	u_int16_t reserved1;
-	u_int32_t crc_err;
-	u_int32_t framing_err;
-	u_int32_t hardware_overrun;
-	u_int32_t buffer_overrun;
-	u_int32_t timeout_err;
-	u_int32_t align_err;
+	uint16_t peer_call_id;
+	uint16_t reserved1;
+	uint32_t crc_err;
+	uint32_t framing_err;
+	uint32_t hardware_overrun;
+	uint32_t buffer_overrun;
+	uint32_t timeout_err;
+	uint32_t align_err;
 };
 
 struct pptp_msg_sli {
-	u_int16_t peer_call_id;
-	u_int16_t reserved1;
-	u_int32_t send_accm;
-	u_int32_t recv_accm;
+	uint16_t peer_call_id;
+	uint16_t reserved1;
+	uint32_t send_accm;
+	uint32_t recv_accm;
 };
 
 /* attributes that appear more than once in above messages:
@@ -239,27 +232,27 @@
    Number of
    occurence    attributes
   --------------------------------------
-      2         u_int32_t bearer_cap;
-      2         u_int32_t bearer_type;
-      6         u_int16_t call_id;
-      2         u_int16_t call_ser;
-      2         u_int16_t cause_code;
-      2         u_int32_t conn_speed;
-      6         u_int8_t err_code;
-      2         u_int16_t firm_rev;
-      2         u_int32_t framing_cap;
-      2         u_int32_t framing_type;
+      2         uint32_t bearer_cap;
+      2         uint32_t bearer_type;
+      6         uint16_t call_id;
+      2         uint16_t call_ser;
+      2         uint16_t cause_code;
+      2         uint32_t conn_speed;
+      6         uint8_t err_code;
+      2         uint16_t firm_rev;
+      2         uint32_t framing_cap;
+      2         uint32_t framing_type;
       2         u_char hostname[64];
-      2         u_int32_t id;
-      2         u_int16_t max_channel;
-      5         u_int16_t peer_call_id;
-      2         u_int32_t phy_chan_id;
-      4         u_int16_t pkt_proc_delay;
-      2         u_int16_t proto_ver;
-      4         u_int16_t recv_winsiz;
-      2         u_int8_t reserved1;
-      9         u_int16_t reserved1;
-      6         u_int8_t result_code;
+      2         uint32_t id;
+      2         uint16_t max_channel;
+      5         uint16_t peer_call_id;
+      2         uint32_t phy_chan_id;
+      4         uint16_t pkt_proc_delay;
+      2         uint16_t proto_ver;
+      4         uint16_t recv_winsiz;
+      2         uint8_t reserved1;
+      9         uint16_t reserved1;
+      6         uint8_t result_code;
       2         u_char subaddr[64];
       2         u_char vendor[64];
 
@@ -272,781 +265,733 @@
 /******************************************/
 
 /* In these attribute-specific print-out functions, it't not necessary
-   to do TCHECK because they are already checked in the caller of
+   to do ND_TCHECK because they are already checked in the caller of
    these functions. */
 
 static void
-pptp_bearer_cap_print(const u_int32_t *bearer_cap)
+pptp_bearer_cap_print(netdissect_options *ndo,
+                      const uint32_t *bearer_cap)
 {
-	printf(" BEARER_CAP(");
-	if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) {
-                printf("D");
-        }
-        if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) {
-                printf("A");
-        }
-	printf(")");
+	ND_PRINT((ndo, " BEARER_CAP(%s%s)",
+	          EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
+	          EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : ""));
+}
+
+static const struct tok pptp_btype_str[] = {
+	{ 1, "A"   }, /* Analog */
+	{ 2, "D"   }, /* Digital */
+	{ 3, "Any" },
+	{ 0, NULL }
+};
+
+static void
+pptp_bearer_type_print(netdissect_options *ndo,
+                       const uint32_t *bearer_type)
+{
+	ND_PRINT((ndo, " BEARER_TYPE(%s)",
+	          tok2str(pptp_btype_str, "?", EXTRACT_32BITS(bearer_type))));
 }
 
 static void
-pptp_bearer_type_print(const u_int32_t *bearer_type)
+pptp_call_id_print(netdissect_options *ndo,
+                   const uint16_t *call_id)
 {
-	printf(" BEARER_TYPE(");
-	switch (EXTRACT_32BITS(bearer_type)) {
-	case 1:
-		printf("A");	/* Analog */
-		break;
-	case 2:
-		printf("D");	/* Digital */
-		break;
-	case 3:
-		printf("Any");
-		break;
-	default:
-		printf("?");
-		break;
-        }
-	printf(")");
+	ND_PRINT((ndo, " CALL_ID(%u)", EXTRACT_16BITS(call_id)));
 }
 
 static void
-pptp_call_id_print(const u_int16_t *call_id)
+pptp_call_ser_print(netdissect_options *ndo,
+                    const uint16_t *call_ser)
 {
-	printf(" CALL_ID(%u)", EXTRACT_16BITS(call_id));
+	ND_PRINT((ndo, " CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)));
 }
 
 static void
-pptp_call_ser_print(const u_int16_t *call_ser)
+pptp_cause_code_print(netdissect_options *ndo,
+                      const uint16_t *cause_code)
 {
-	printf(" CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser));
+	ND_PRINT((ndo, " CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)));
 }
 
 static void
-pptp_cause_code_print(const u_int16_t *cause_code)
+pptp_conn_speed_print(netdissect_options *ndo,
+                      const uint32_t *conn_speed)
 {
-	printf(" CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code));
+	ND_PRINT((ndo, " CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)));
 }
 
-static void
-pptp_conn_speed_print(const u_int32_t *conn_speed)
-{
-	printf(" CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed));
-}
+static const struct tok pptp_errcode_str[] = {
+	{ 0, "None"          },
+	{ 1, "Not-Connected" },
+	{ 2, "Bad-Format"    },
+	{ 3, "Bad-Value"     },
+	{ 4, "No-Resource"   },
+	{ 5, "Bad-Call-ID"   },
+	{ 6, "PAC-Error"     },
+	{ 0, NULL }
+};
 
 static void
-pptp_err_code_print(const u_int8_t *err_code)
+pptp_err_code_print(netdissect_options *ndo,
+                    const uint8_t *err_code)
 {
-	printf(" ERR_CODE(%u", *err_code);
-	if (vflag) {
-		switch (*err_code) {
-		case 0:
-			printf(":None");
-			break;
-		case 1:
-			printf(":Not-Connected");
-			break;
-		case 2:
-			printf(":Bad-Format");
-			break;
-		case 3:
-			printf(":Bad-Valude");
-			break;
-		case 4:
-			printf(":No-Resource");
-			break;
-		case 5:
-			printf(":Bad-Call-ID");
-			break;
-		case 6:
-			printf(":PAC-Error");
-			break;
-		default:
-			printf(":?");
-			break;
-		}
+	ND_PRINT((ndo, " ERR_CODE(%u", *err_code));
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, ":%s", tok2str(pptp_errcode_str, "?", *err_code)));
 	}
-	printf(")");
+	ND_PRINT((ndo, ")"));
 }
 
 static void
-pptp_firm_rev_print(const u_int16_t *firm_rev)
+pptp_firm_rev_print(netdissect_options *ndo,
+                    const uint16_t *firm_rev)
 {
-	printf(" FIRM_REV(%u)", EXTRACT_16BITS(firm_rev));
+	ND_PRINT((ndo, " FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)));
 }
 
 static void
-pptp_framing_cap_print(const u_int32_t *framing_cap)
+pptp_framing_cap_print(netdissect_options *ndo,
+                       const uint32_t *framing_cap)
 {
-	printf(" FRAME_CAP(");
+	ND_PRINT((ndo, " FRAME_CAP("));
 	if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
-                printf("A");		/* Async */
+                ND_PRINT((ndo, "A"));		/* Async */
         }
         if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
-                printf("S");		/* Sync */
+                ND_PRINT((ndo, "S"));		/* Sync */
         }
-	printf(")");
+	ND_PRINT((ndo, ")"));
+}
+
+static const struct tok pptp_ftype_str[] = {
+	{ 1, "A" }, /* Async */
+	{ 2, "S" }, /* Sync */
+	{ 3, "E" }, /* Either */
+	{ 0, NULL }
+};
+
+static void
+pptp_framing_type_print(netdissect_options *ndo,
+                        const uint32_t *framing_type)
+{
+	ND_PRINT((ndo, " FRAME_TYPE(%s)",
+	          tok2str(pptp_ftype_str, "?", EXTRACT_32BITS(framing_type))));
 }
 
 static void
-pptp_framing_type_print(const u_int32_t *framing_type)
+pptp_hostname_print(netdissect_options *ndo,
+                    const u_char *hostname)
 {
-	printf(" FRAME_TYPE(");
-	switch (EXTRACT_32BITS(framing_type)) {
-	case 1:
-		printf("A");		/* Async */
-		break;
-	case 2:
-		printf("S");		/* Sync */
-		break;
-	case 3:
-		printf("E");		/* Either */
-		break;
-	default:
-		printf("?");
-		break;
-	}
-	printf(")");
+	ND_PRINT((ndo, " HOSTNAME(%.64s)", hostname));
 }
 
 static void
-pptp_hostname_print(const u_char *hostname)
+pptp_id_print(netdissect_options *ndo,
+              const uint32_t *id)
 {
-	printf(" HOSTNAME(%.64s)", hostname);
+	ND_PRINT((ndo, " ID(%u)", EXTRACT_32BITS(id)));
 }
 
 static void
-pptp_id_print(const u_int32_t *id)
+pptp_max_channel_print(netdissect_options *ndo,
+                       const uint16_t *max_channel)
 {
-	printf(" ID(%u)", EXTRACT_32BITS(id));
+	ND_PRINT((ndo, " MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)));
 }
 
 static void
-pptp_max_channel_print(const u_int16_t *max_channel)
+pptp_peer_call_id_print(netdissect_options *ndo,
+                        const uint16_t *peer_call_id)
 {
-	printf(" MAX_CHAN(%u)", EXTRACT_16BITS(max_channel));
+	ND_PRINT((ndo, " PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)));
 }
 
 static void
-pptp_peer_call_id_print(const u_int16_t *peer_call_id)
+pptp_phy_chan_id_print(netdissect_options *ndo,
+                       const uint32_t *phy_chan_id)
 {
-	printf(" PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id));
+	ND_PRINT((ndo, " PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)));
 }
 
 static void
-pptp_phy_chan_id_print(const u_int32_t *phy_chan_id)
+pptp_pkt_proc_delay_print(netdissect_options *ndo,
+                          const uint16_t *pkt_proc_delay)
 {
-	printf(" PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id));
+	ND_PRINT((ndo, " PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)));
 }
 
 static void
-pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay)
+pptp_proto_ver_print(netdissect_options *ndo,
+                     const uint16_t *proto_ver)
 {
-	printf(" PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay));
-}
-
-static void
-pptp_proto_ver_print(const u_int16_t *proto_ver)
-{
-	printf(" PROTO_VER(%u.%u)",	/* Version.Revision */
+	ND_PRINT((ndo, " PROTO_VER(%u.%u)",	/* Version.Revision */
 	       EXTRACT_16BITS(proto_ver) >> 8,
-	       EXTRACT_16BITS(proto_ver) & 0xff);
+	       EXTRACT_16BITS(proto_ver) & 0xff));
 }
 
 static void
-pptp_recv_winsiz_print(const u_int16_t *recv_winsiz)
+pptp_recv_winsiz_print(netdissect_options *ndo,
+                       const uint16_t *recv_winsiz)
 {
-	printf(" RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz));
+	ND_PRINT((ndo, " RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)));
 }
 
+static const struct tok pptp_scrrp_str[] = {
+	{ 1, "Successful channel establishment"                           },
+	{ 2, "General error"                                              },
+	{ 3, "Command channel already exists"                             },
+	{ 4, "Requester is not authorized to establish a command channel" },
+	{ 5, "The protocol version of the requester is not supported"     },
+	{ 0, NULL }
+};
+
+static const struct tok pptp_echorp_str[] = {
+	{ 1, "OK" },
+	{ 2, "General Error" },
+	{ 0, NULL }
+};
+
+static const struct tok pptp_ocrp_str[] = {
+	{ 1, "Connected"     },
+	{ 2, "General Error" },
+	{ 3, "No Carrier"    },
+	{ 4, "Busy"          },
+	{ 5, "No Dial Tone"  },
+	{ 6, "Time-out"      },
+	{ 7, "Do Not Accept" },
+	{ 0, NULL }
+};
+
+static const struct tok pptp_icrp_str[] = {
+	{ 1, "Connect"       },
+	{ 2, "General Error" },
+	{ 3, "Do Not Accept" },
+	{ 0, NULL }
+};
+
+static const struct tok pptp_cdn_str[] = {
+	{ 1, "Lost Carrier"   },
+	{ 2, "General Error"  },
+	{ 3, "Admin Shutdown" },
+	{ 4, "Request"        },
+	{ 0, NULL }
+};
+
 static void
-pptp_result_code_print(const u_int8_t *result_code, int ctrl_msg_type)
+pptp_result_code_print(netdissect_options *ndo,
+                       const uint8_t *result_code, int ctrl_msg_type)
 {
-	printf(" RESULT_CODE(%u", *result_code);
-	if (vflag) {
-		switch (ctrl_msg_type) {
-		case PPTP_CTRL_MSG_TYPE_SCCRP:
-			switch (*result_code) {
-			case 1:
-				printf(":Successful channel establishment");
-				break;
-			case 2:
-				printf(":General error");
-				break;
-			case 3:
-				printf(":Command channel already exists");
-				break;
-			case 4:
-				printf(":Requester is not authorized to establish a command channel");
-				break;
-			case 5:
-				printf(":The protocol version of the requester is not supported");
-				break;
-			default:
-				printf(":?");
-				break;
-			}
-			break;
-		case PPTP_CTRL_MSG_TYPE_StopCCRP:
-		case PPTP_CTRL_MSG_TYPE_ECHORP:
-			switch (*result_code) {
-			case 1:
-				printf(":OK");
-				break;
-			case 2:
-				printf(":General Error");
-				break;
-			default:
-				printf(":?");
-				break;
-			}
-			break;
-		case PPTP_CTRL_MSG_TYPE_OCRP:
-			switch (*result_code) {
-			case 1:
-				printf(":Connected");
-				break;
-			case 2:
-				printf(":General Error");
-				break;
-			case 3:
-				printf(":No Carrier");
-				break;
-			case 4:
-				printf(":Busy");
-				break;
-			case 5:
-				printf(":No Dial Tone");
-				break;
-			case 6:
-				printf(":Time-out");
-				break;
-			case 7:
-				printf(":Do Not Accept");
-				break;
-			default:
-				printf(":?");
-				break;
-			}
-			break;
-		case PPTP_CTRL_MSG_TYPE_ICRP:
-			switch (*result_code) {
-			case 1:
-				printf(":Connect");
-				break;
-			case 2:
-				printf(":General Error");
-				break;
-			case 3:
-				printf(":Do Not Accept");
-				break;
-			default:
-				printf(":?");
-				break;
-			}
-			break;
-		case PPTP_CTRL_MSG_TYPE_CDN:
-			switch (*result_code) {
-			case 1:
-				printf(":Lost Carrier");
-				break;
-			case 2:
-				printf(":General Error");
-				break;
-			case 3:
-				printf(":Admin Shutdown");
-				break;
-			case 4:
-				printf(":Request");
-			default:
-				printf(":?");
-				break;
-			break;
-			}
-		default:
-			/* assertion error */
-			break;
-		}
+	ND_PRINT((ndo, " RESULT_CODE(%u", *result_code));
+	if (ndo->ndo_vflag) {
+		const struct tok *dict =
+			ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP    ? pptp_scrrp_str :
+			ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
+			ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP   ? pptp_echorp_str :
+			ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP     ? pptp_ocrp_str :
+			ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP     ? pptp_icrp_str :
+			ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN      ? pptp_cdn_str :
+			NULL; /* assertion error */
+		if (dict != NULL)
+			ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));
 	}
-	printf(")");
+	ND_PRINT((ndo, ")"));
 }
 
 static void
-pptp_subaddr_print(const u_char *subaddr)
+pptp_subaddr_print(netdissect_options *ndo,
+                   const u_char *subaddr)
 {
-	printf(" SUB_ADDR(%.64s)", subaddr);
+	ND_PRINT((ndo, " SUB_ADDR(%.64s)", subaddr));
 }
 
 static void
-pptp_vendor_print(const u_char *vendor)
+pptp_vendor_print(netdissect_options *ndo,
+                  const u_char *vendor)
 {
-	printf(" VENDOR(%.64s)", vendor);
+	ND_PRINT((ndo, " VENDOR(%.64s)", vendor));
 }
 
 /************************************/
 /* PPTP message print out functions */
 /************************************/
 static void
-pptp_sccrq_print(const u_char *dat)
+pptp_sccrq_print(netdissect_options *ndo,
+                 const u_char *dat)
 {
 	struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
 
-	TCHECK(ptr->proto_ver);
-	pptp_proto_ver_print(&ptr->proto_ver);
-	TCHECK(ptr->reserved1);
-	TCHECK(ptr->framing_cap);
-	pptp_framing_cap_print(&ptr->framing_cap);
-	TCHECK(ptr->bearer_cap);
-	pptp_bearer_cap_print(&ptr->bearer_cap);
-	TCHECK(ptr->max_channel);
-	pptp_max_channel_print(&ptr->max_channel);
-	TCHECK(ptr->firm_rev);
-	pptp_firm_rev_print(&ptr->firm_rev);
-	TCHECK(ptr->hostname);
-	pptp_hostname_print(&ptr->hostname[0]);
-	TCHECK(ptr->vendor);
-	pptp_vendor_print(&ptr->vendor[0]);
+	ND_TCHECK(ptr->proto_ver);
+	pptp_proto_ver_print(ndo, &ptr->proto_ver);
+	ND_TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->framing_cap);
+	pptp_framing_cap_print(ndo, &ptr->framing_cap);
+	ND_TCHECK(ptr->bearer_cap);
+	pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
+	ND_TCHECK(ptr->max_channel);
+	pptp_max_channel_print(ndo, &ptr->max_channel);
+	ND_TCHECK(ptr->firm_rev);
+	pptp_firm_rev_print(ndo, &ptr->firm_rev);
+	ND_TCHECK(ptr->hostname);
+	pptp_hostname_print(ndo, &ptr->hostname[0]);
+	ND_TCHECK(ptr->vendor);
+	pptp_vendor_print(ndo, &ptr->vendor[0]);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_sccrp_print(const u_char *dat)
+pptp_sccrp_print(netdissect_options *ndo,
+                 const u_char *dat)
 {
 	struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
 
-	TCHECK(ptr->proto_ver);
-	pptp_proto_ver_print(&ptr->proto_ver);
-	TCHECK(ptr->result_code);
-	pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
-	TCHECK(ptr->err_code);
-	pptp_err_code_print(&ptr->err_code);
-	TCHECK(ptr->framing_cap);
-	pptp_framing_cap_print(&ptr->framing_cap);
-	TCHECK(ptr->bearer_cap);
-	pptp_bearer_cap_print(&ptr->bearer_cap);
-	TCHECK(ptr->max_channel);
-	pptp_max_channel_print(&ptr->max_channel);
-	TCHECK(ptr->firm_rev);
-	pptp_firm_rev_print(&ptr->firm_rev);
-	TCHECK(ptr->hostname);
-	pptp_hostname_print(&ptr->hostname[0]);
-	TCHECK(ptr->vendor);
-	pptp_vendor_print(&ptr->vendor[0]);
+	ND_TCHECK(ptr->proto_ver);
+	pptp_proto_ver_print(ndo, &ptr->proto_ver);
+	ND_TCHECK(ptr->result_code);
+	pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
+	ND_TCHECK(ptr->err_code);
+	pptp_err_code_print(ndo, &ptr->err_code);
+	ND_TCHECK(ptr->framing_cap);
+	pptp_framing_cap_print(ndo, &ptr->framing_cap);
+	ND_TCHECK(ptr->bearer_cap);
+	pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
+	ND_TCHECK(ptr->max_channel);
+	pptp_max_channel_print(ndo, &ptr->max_channel);
+	ND_TCHECK(ptr->firm_rev);
+	pptp_firm_rev_print(ndo, &ptr->firm_rev);
+	ND_TCHECK(ptr->hostname);
+	pptp_hostname_print(ndo, &ptr->hostname[0]);
+	ND_TCHECK(ptr->vendor);
+	pptp_vendor_print(ndo, &ptr->vendor[0]);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_stopccrq_print(const u_char *dat)
+pptp_stopccrq_print(netdissect_options *ndo,
+                    const u_char *dat)
 {
 	struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
 
-	TCHECK(ptr->reason);
-	printf(" REASON(%u", ptr->reason);
-	if (vflag) {
+	ND_TCHECK(ptr->reason);
+	ND_PRINT((ndo, " REASON(%u", ptr->reason));
+	if (ndo->ndo_vflag) {
 		switch (ptr->reason) {
 		case 1:
-			printf(":None");
+			ND_PRINT((ndo, ":None"));
 			break;
 		case 2:
-			printf(":Stop-Protocol");
+			ND_PRINT((ndo, ":Stop-Protocol"));
 			break;
 		case 3:
-			printf(":Stop-Local-Shutdown");
+			ND_PRINT((ndo, ":Stop-Local-Shutdown"));
 			break;
 		default:
-			printf(":?");
+			ND_PRINT((ndo, ":?"));
 			break;
 		}
 	}
-	printf(")");
-	TCHECK(ptr->reserved1);
-	TCHECK(ptr->reserved2);
+	ND_PRINT((ndo, ")"));
+	ND_TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->reserved2);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_stopccrp_print(const u_char *dat)
+pptp_stopccrp_print(netdissect_options *ndo,
+                    const u_char *dat)
 {
 	struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
 
-	TCHECK(ptr->result_code);
-	pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
-	TCHECK(ptr->err_code);
-	pptp_err_code_print(&ptr->err_code);
-	TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->result_code);
+	pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
+	ND_TCHECK(ptr->err_code);
+	pptp_err_code_print(ndo, &ptr->err_code);
+	ND_TCHECK(ptr->reserved1);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_echorq_print(const u_char *dat)
+pptp_echorq_print(netdissect_options *ndo,
+                  const u_char *dat)
 {
 	struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
 
-	TCHECK(ptr->id);
-	pptp_id_print(&ptr->id);
+	ND_TCHECK(ptr->id);
+	pptp_id_print(ndo, &ptr->id);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_echorp_print(const u_char *dat)
+pptp_echorp_print(netdissect_options *ndo,
+                  const u_char *dat)
 {
 	struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
 
-	TCHECK(ptr->id);
-	pptp_id_print(&ptr->id);
-	TCHECK(ptr->result_code);
-	pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
-	TCHECK(ptr->err_code);
-	pptp_err_code_print(&ptr->err_code);
-	TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->id);
+	pptp_id_print(ndo, &ptr->id);
+	ND_TCHECK(ptr->result_code);
+	pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
+	ND_TCHECK(ptr->err_code);
+	pptp_err_code_print(ndo, &ptr->err_code);
+	ND_TCHECK(ptr->reserved1);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_ocrq_print(const u_char *dat)
+pptp_ocrq_print(netdissect_options *ndo,
+                const u_char *dat)
 {
 	struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
 
-	TCHECK(ptr->call_id);
-	pptp_call_id_print(&ptr->call_id);
-	TCHECK(ptr->call_ser);
-	pptp_call_ser_print(&ptr->call_ser);
-	TCHECK(ptr->min_bps);
-	printf(" MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps));
-	TCHECK(ptr->max_bps);
-	printf(" MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps));
-	TCHECK(ptr->bearer_type);
-	pptp_bearer_type_print(&ptr->bearer_type);
-	TCHECK(ptr->framing_type);
-	pptp_framing_type_print(&ptr->framing_type);
-	TCHECK(ptr->recv_winsiz);
-	pptp_recv_winsiz_print(&ptr->recv_winsiz);
-	TCHECK(ptr->pkt_proc_delay);
-	pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
-	TCHECK(ptr->phone_no_len);
-	printf(" PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len));
-	TCHECK(ptr->reserved1);
-	TCHECK(ptr->phone_no);
-	printf(" PHONE_NO(%.64s)", ptr->phone_no);
-	TCHECK(ptr->subaddr);
-	pptp_subaddr_print(&ptr->subaddr[0]);
+	ND_TCHECK(ptr->call_id);
+	pptp_call_id_print(ndo, &ptr->call_id);
+	ND_TCHECK(ptr->call_ser);
+	pptp_call_ser_print(ndo, &ptr->call_ser);
+	ND_TCHECK(ptr->min_bps);
+	ND_PRINT((ndo, " MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)));
+	ND_TCHECK(ptr->max_bps);
+	ND_PRINT((ndo, " MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)));
+	ND_TCHECK(ptr->bearer_type);
+	pptp_bearer_type_print(ndo, &ptr->bearer_type);
+	ND_TCHECK(ptr->framing_type);
+	pptp_framing_type_print(ndo, &ptr->framing_type);
+	ND_TCHECK(ptr->recv_winsiz);
+	pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+	ND_TCHECK(ptr->pkt_proc_delay);
+	pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+	ND_TCHECK(ptr->phone_no_len);
+	ND_PRINT((ndo, " PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)));
+	ND_TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->phone_no);
+	ND_PRINT((ndo, " PHONE_NO(%.64s)", ptr->phone_no));
+	ND_TCHECK(ptr->subaddr);
+	pptp_subaddr_print(ndo, &ptr->subaddr[0]);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_ocrp_print(const u_char *dat)
+pptp_ocrp_print(netdissect_options *ndo,
+                const u_char *dat)
 {
 	struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
 
-	TCHECK(ptr->call_id);
-	pptp_call_id_print(&ptr->call_id);
-	TCHECK(ptr->peer_call_id);
-	pptp_peer_call_id_print(&ptr->peer_call_id);
-	TCHECK(ptr->result_code);
-	pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
-	TCHECK(ptr->err_code);
-	pptp_err_code_print(&ptr->err_code);
-	TCHECK(ptr->cause_code);
-	pptp_cause_code_print(&ptr->cause_code);
-	TCHECK(ptr->conn_speed);
-	pptp_conn_speed_print(&ptr->conn_speed);
-	TCHECK(ptr->recv_winsiz);
-	pptp_recv_winsiz_print(&ptr->recv_winsiz);
-	TCHECK(ptr->pkt_proc_delay);
-	pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
-	TCHECK(ptr->phy_chan_id);
-	pptp_phy_chan_id_print(&ptr->phy_chan_id);
+	ND_TCHECK(ptr->call_id);
+	pptp_call_id_print(ndo, &ptr->call_id);
+	ND_TCHECK(ptr->peer_call_id);
+	pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+	ND_TCHECK(ptr->result_code);
+	pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
+	ND_TCHECK(ptr->err_code);
+	pptp_err_code_print(ndo, &ptr->err_code);
+	ND_TCHECK(ptr->cause_code);
+	pptp_cause_code_print(ndo, &ptr->cause_code);
+	ND_TCHECK(ptr->conn_speed);
+	pptp_conn_speed_print(ndo, &ptr->conn_speed);
+	ND_TCHECK(ptr->recv_winsiz);
+	pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+	ND_TCHECK(ptr->pkt_proc_delay);
+	pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+	ND_TCHECK(ptr->phy_chan_id);
+	pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_icrq_print(const u_char *dat)
+pptp_icrq_print(netdissect_options *ndo,
+                const u_char *dat)
 {
 	struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
 
-	TCHECK(ptr->call_id);
-	pptp_call_id_print(&ptr->call_id);
-	TCHECK(ptr->call_ser);
-	pptp_call_ser_print(&ptr->call_ser);
-	TCHECK(ptr->bearer_type);
-	pptp_bearer_type_print(&ptr->bearer_type);
-	TCHECK(ptr->phy_chan_id);
-	pptp_phy_chan_id_print(&ptr->phy_chan_id);
-	TCHECK(ptr->dialed_no_len);
-	printf(" DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len));
-	TCHECK(ptr->dialing_no_len);
-	printf(" DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len));
-	TCHECK(ptr->dialed_no);
-	printf(" DIALED_NO(%.64s)", ptr->dialed_no);
-	TCHECK(ptr->dialing_no);
-	printf(" DIALING_NO(%.64s)", ptr->dialing_no);
-	TCHECK(ptr->subaddr);
-	pptp_subaddr_print(&ptr->subaddr[0]);
+	ND_TCHECK(ptr->call_id);
+	pptp_call_id_print(ndo, &ptr->call_id);
+	ND_TCHECK(ptr->call_ser);
+	pptp_call_ser_print(ndo, &ptr->call_ser);
+	ND_TCHECK(ptr->bearer_type);
+	pptp_bearer_type_print(ndo, &ptr->bearer_type);
+	ND_TCHECK(ptr->phy_chan_id);
+	pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
+	ND_TCHECK(ptr->dialed_no_len);
+	ND_PRINT((ndo, " DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)));
+	ND_TCHECK(ptr->dialing_no_len);
+	ND_PRINT((ndo, " DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)));
+	ND_TCHECK(ptr->dialed_no);
+	ND_PRINT((ndo, " DIALED_NO(%.64s)", ptr->dialed_no));
+	ND_TCHECK(ptr->dialing_no);
+	ND_PRINT((ndo, " DIALING_NO(%.64s)", ptr->dialing_no));
+	ND_TCHECK(ptr->subaddr);
+	pptp_subaddr_print(ndo, &ptr->subaddr[0]);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_icrp_print(const u_char *dat)
+pptp_icrp_print(netdissect_options *ndo,
+                const u_char *dat)
 {
 	struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
 
-	TCHECK(ptr->call_id);
-	pptp_call_id_print(&ptr->call_id);
-	TCHECK(ptr->peer_call_id);
-	pptp_peer_call_id_print(&ptr->peer_call_id);
-	TCHECK(ptr->result_code);
-	pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
-	TCHECK(ptr->err_code);
-	pptp_err_code_print(&ptr->err_code);
-	TCHECK(ptr->recv_winsiz);
-	pptp_recv_winsiz_print(&ptr->recv_winsiz);
-	TCHECK(ptr->pkt_proc_delay);
-	pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
-	TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->call_id);
+	pptp_call_id_print(ndo, &ptr->call_id);
+	ND_TCHECK(ptr->peer_call_id);
+	pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+	ND_TCHECK(ptr->result_code);
+	pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
+	ND_TCHECK(ptr->err_code);
+	pptp_err_code_print(ndo, &ptr->err_code);
+	ND_TCHECK(ptr->recv_winsiz);
+	pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+	ND_TCHECK(ptr->pkt_proc_delay);
+	pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+	ND_TCHECK(ptr->reserved1);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_iccn_print(const u_char *dat)
+pptp_iccn_print(netdissect_options *ndo,
+                const u_char *dat)
 {
 	struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
 
-	TCHECK(ptr->peer_call_id);
-	pptp_peer_call_id_print(&ptr->peer_call_id);
-	TCHECK(ptr->reserved1);
-	TCHECK(ptr->conn_speed);
-	pptp_conn_speed_print(&ptr->conn_speed);
-	TCHECK(ptr->recv_winsiz);
-	pptp_recv_winsiz_print(&ptr->recv_winsiz);
-	TCHECK(ptr->pkt_proc_delay);
-	pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
-	TCHECK(ptr->framing_type);
-	pptp_framing_type_print(&ptr->framing_type);
+	ND_TCHECK(ptr->peer_call_id);
+	pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+	ND_TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->conn_speed);
+	pptp_conn_speed_print(ndo, &ptr->conn_speed);
+	ND_TCHECK(ptr->recv_winsiz);
+	pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+	ND_TCHECK(ptr->pkt_proc_delay);
+	pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+	ND_TCHECK(ptr->framing_type);
+	pptp_framing_type_print(ndo, &ptr->framing_type);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_ccrq_print(const u_char *dat)
+pptp_ccrq_print(netdissect_options *ndo,
+                const u_char *dat)
 {
 	struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
 
-	TCHECK(ptr->call_id);
-	pptp_call_id_print(&ptr->call_id);
-	TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->call_id);
+	pptp_call_id_print(ndo, &ptr->call_id);
+	ND_TCHECK(ptr->reserved1);
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_cdn_print(const u_char *dat)
+pptp_cdn_print(netdissect_options *ndo,
+               const u_char *dat)
 {
 	struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
 
-	TCHECK(ptr->call_id);
-	pptp_call_id_print(&ptr->call_id);
-	TCHECK(ptr->result_code);
-	pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
-	TCHECK(ptr->err_code);
-	pptp_err_code_print(&ptr->err_code);
-	TCHECK(ptr->cause_code);
-	pptp_cause_code_print(&ptr->cause_code);
-	TCHECK(ptr->reserved1);
-	TCHECK(ptr->call_stats);
-	printf(" CALL_STATS(%.128s)", ptr->call_stats);
+	ND_TCHECK(ptr->call_id);
+	pptp_call_id_print(ndo, &ptr->call_id);
+	ND_TCHECK(ptr->result_code);
+	pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
+	ND_TCHECK(ptr->err_code);
+	pptp_err_code_print(ndo, &ptr->err_code);
+	ND_TCHECK(ptr->cause_code);
+	pptp_cause_code_print(ndo, &ptr->cause_code);
+	ND_TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->call_stats);
+	ND_PRINT((ndo, " CALL_STATS(%.128s)", ptr->call_stats));
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_wen_print(const u_char *dat)
+pptp_wen_print(netdissect_options *ndo,
+               const u_char *dat)
 {
 	struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
 
-	TCHECK(ptr->peer_call_id);
-	pptp_peer_call_id_print(&ptr->peer_call_id);
-	TCHECK(ptr->reserved1);
-	TCHECK(ptr->crc_err);
-	printf(" CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err));
-	TCHECK(ptr->framing_err);
-	printf(" FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err));
-	TCHECK(ptr->hardware_overrun);
-	printf(" HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun));
-	TCHECK(ptr->buffer_overrun);
-	printf(" BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun));
-	TCHECK(ptr->timeout_err);
-	printf(" TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err));
-	TCHECK(ptr->align_err);
-	printf(" ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err));
+	ND_TCHECK(ptr->peer_call_id);
+	pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+	ND_TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->crc_err);
+	ND_PRINT((ndo, " CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)));
+	ND_TCHECK(ptr->framing_err);
+	ND_PRINT((ndo, " FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)));
+	ND_TCHECK(ptr->hardware_overrun);
+	ND_PRINT((ndo, " HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)));
+	ND_TCHECK(ptr->buffer_overrun);
+	ND_PRINT((ndo, " BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)));
+	ND_TCHECK(ptr->timeout_err);
+	ND_PRINT((ndo, " TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)));
+	ND_TCHECK(ptr->align_err);
+	ND_PRINT((ndo, " ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)));
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-pptp_sli_print(const u_char *dat)
+pptp_sli_print(netdissect_options *ndo,
+               const u_char *dat)
 {
 	struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
 
-	TCHECK(ptr->peer_call_id);
-	pptp_peer_call_id_print(&ptr->peer_call_id);
-	TCHECK(ptr->reserved1);
-	TCHECK(ptr->send_accm);
-	printf(" SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm));
-	TCHECK(ptr->recv_accm);
-	printf(" RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm));
+	ND_TCHECK(ptr->peer_call_id);
+	pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+	ND_TCHECK(ptr->reserved1);
+	ND_TCHECK(ptr->send_accm);
+	ND_PRINT((ndo, " SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)));
+	ND_TCHECK(ptr->recv_accm);
+	ND_PRINT((ndo, " RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)));
 
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 void
-pptp_print(const u_char *dat)
+pptp_print(netdissect_options *ndo,
+           const u_char *dat)
 {
 	const struct pptp_hdr *hdr;
-	u_int32_t mc;
-	u_int16_t ctrl_msg_type;
+	uint32_t mc;
+	uint16_t ctrl_msg_type;
 
-	printf(": pptp");
+	ND_PRINT((ndo, ": pptp"));
 
 	hdr = (struct pptp_hdr *)dat;
 
-	TCHECK(hdr->length);
-	if (vflag) {
-		printf(" Length=%u", EXTRACT_16BITS(&hdr->length));
+	ND_TCHECK(hdr->length);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, " Length=%u", EXTRACT_16BITS(&hdr->length)));
 	}
-	TCHECK(hdr->msg_type);
-	if (vflag) {
+	ND_TCHECK(hdr->msg_type);
+	if (ndo->ndo_vflag) {
 		switch(EXTRACT_16BITS(&hdr->msg_type)) {
 		case PPTP_MSG_TYPE_CTRL:
-			printf(" CTRL-MSG");
+			ND_PRINT((ndo, " CTRL-MSG"));
 			break;
 		case PPTP_MSG_TYPE_MGMT:
-			printf(" MGMT-MSG");
+			ND_PRINT((ndo, " MGMT-MSG"));
 			break;
 		default:
-			printf(" UNKNOWN-MSG-TYPE");
+			ND_PRINT((ndo, " UNKNOWN-MSG-TYPE"));
 			break;
 		}
 	}
 
-	TCHECK(hdr->magic_cookie);
+	ND_TCHECK(hdr->magic_cookie);
 	mc = EXTRACT_32BITS(&hdr->magic_cookie);
 	if (mc != PPTP_MAGIC_COOKIE) {
-		printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
+		ND_PRINT((ndo, " UNEXPECTED Magic-Cookie!!(%08x)", mc));
 	}
-	if (vflag || mc != PPTP_MAGIC_COOKIE) {
-		printf(" Magic-Cookie=%08x", mc);
+	if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
+		ND_PRINT((ndo, " Magic-Cookie=%08x", mc));
 	}
-	TCHECK(hdr->ctrl_msg_type);
+	ND_TCHECK(hdr->ctrl_msg_type);
 	ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
 	if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
-		printf(" CTRL_MSGTYPE=%s",
-		       pptp_message_type_string[ctrl_msg_type]);
+		ND_PRINT((ndo, " CTRL_MSGTYPE=%s",
+		       pptp_message_type_string[ctrl_msg_type]));
 	} else {
-		printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
+		ND_PRINT((ndo, " UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type));
 	}
-	TCHECK(hdr->reserved0);
+	ND_TCHECK(hdr->reserved0);
 
 	dat += 12;
 
 	switch(ctrl_msg_type) {
 	case PPTP_CTRL_MSG_TYPE_SCCRQ:
-		pptp_sccrq_print(dat);
+		pptp_sccrq_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_SCCRP:
-		pptp_sccrp_print(dat);
+		pptp_sccrp_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_StopCCRQ:
-		pptp_stopccrq_print(dat);
+		pptp_stopccrq_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_StopCCRP:
-		pptp_stopccrp_print(dat);
+		pptp_stopccrp_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_ECHORQ:
-		pptp_echorq_print(dat);
+		pptp_echorq_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_ECHORP:
-		pptp_echorp_print(dat);
+		pptp_echorp_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_OCRQ:
-		pptp_ocrq_print(dat);
+		pptp_ocrq_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_OCRP:
-		pptp_ocrp_print(dat);
+		pptp_ocrp_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_ICRQ:
-		pptp_icrq_print(dat);
+		pptp_icrq_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_ICRP:
-		pptp_icrp_print(dat);
+		pptp_icrp_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_ICCN:
-		pptp_iccn_print(dat);
+		pptp_iccn_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_CCRQ:
-		pptp_ccrq_print(dat);
+		pptp_ccrq_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_CDN:
-		pptp_cdn_print(dat);
+		pptp_cdn_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_WEN:
-		pptp_wen_print(dat);
+		pptp_wen_print(ndo, dat);
 		break;
 	case PPTP_CTRL_MSG_TYPE_SLI:
-		pptp_sli_print(dat);
+		pptp_sli_print(ndo, dat);
 		break;
 	default:
 		/* do nothing */
@@ -1056,5 +1001,5 @@
 	return;
 
 trunc:
-	printf("%s", tstr);
+	ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-radius.c b/print-radius.c
index 74fd72d..5cf8ad2 100644
--- a/print-radius.c
+++ b/print-radius.c
@@ -37,16 +37,18 @@
  * RFC 2869:
  *      "RADIUS Extensions"
  *
+ * RFC 4675:
+ *      "RADIUS Attributes for Virtual LAN and Priority Support"
+ *
+ * RFC 5176:
+ *      "Dynamic Authorization Extensions to RADIUS"
+ *
  * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
  *
  * TODO: Among other things to print ok MacIntosh and Vendor values
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "$Id: print-radius.c,v 1.28 2005-09-26 01:01:55 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -55,19 +57,19 @@
 
 #include <string.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 #include "oui.h"
 
+static const char tstr[] = " [|radius]";
+
 #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
 
 #define PRINT_HEX(bytes_len, ptr_data)                               \
            while(bytes_len)                                          \
            {                                                         \
-              printf("%02X", *ptr_data );                            \
+              ND_PRINT((ndo, "%02X", *ptr_data ));                   \
               ptr_data++;                                            \
               bytes_len--;                                           \
            }
@@ -82,17 +84,29 @@
 #define RADCMD_ACCESS_CHA  11 /* Access-Challenge    */
 #define RADCMD_STATUS_SER  12 /* Status-Server       */
 #define RADCMD_STATUS_CLI  13 /* Status-Client       */
+#define RADCMD_DISCON_REQ  40 /* Disconnect-Request  */
+#define RADCMD_DISCON_ACK  41 /* Disconnect-ACK      */
+#define RADCMD_DISCON_NAK  42 /* Disconnect-NAK      */
+#define RADCMD_COA_REQ     43 /* CoA-Request         */
+#define RADCMD_COA_ACK     44 /* CoA-ACK             */
+#define RADCMD_COA_NAK     45 /* CoA-NAK             */
 #define RADCMD_RESERVED   255 /* Reserved            */
 
 static const struct tok radius_command_values[] = {
-    { RADCMD_ACCESS_REQ, "Access Request" },
-    { RADCMD_ACCESS_ACC, "Access Accept" },
-    { RADCMD_ACCESS_REJ, "Access Reject" },
-    { RADCMD_ACCOUN_REQ, "Accounting Request" },
-    { RADCMD_ACCOUN_RES, "Accounting Response" },
-    { RADCMD_ACCESS_CHA, "Access Challenge" },
-    { RADCMD_STATUS_SER, "Status Server" },
-    { RADCMD_STATUS_CLI, "Status Client" },
+    { RADCMD_ACCESS_REQ, "Access-Request" },
+    { RADCMD_ACCESS_ACC, "Access-Accept" },
+    { RADCMD_ACCESS_REJ, "Access-Reject" },
+    { RADCMD_ACCOUN_REQ, "Accounting-Request" },
+    { RADCMD_ACCOUN_RES, "Accounting-Response" },
+    { RADCMD_ACCESS_CHA, "Access-Challenge" },
+    { RADCMD_STATUS_SER, "Status-Server" },
+    { RADCMD_STATUS_CLI, "Status-Client" },
+    { RADCMD_DISCON_REQ, "Disconnect-Request" },
+    { RADCMD_DISCON_ACK, "Disconnect-ACK" },
+    { RADCMD_DISCON_NAK, "Disconnect-NAK" },
+    { RADCMD_COA_REQ,    "CoA-Request" },
+    { RADCMD_COA_ACK,    "CoA-ACK" },
+    { RADCMD_COA_NAK,    "CoA-NAK" },
     { RADCMD_RESERVED,   "Reserved" },
     { 0, NULL}
 };
@@ -113,6 +127,9 @@
 #define ACCT_DELAY        41
 #define ACCT_SESSION_TIME 46
 
+#define EGRESS_VLAN_ID   56
+#define EGRESS_VLAN_NAME 58
+
 #define TUNNEL_TYPE        64
 #define TUNNEL_MEDIUM      65
 #define TUNNEL_CLIENT_END  66
@@ -135,25 +152,34 @@
 /* End Radius Attribute types */
 /********************************/
 
+#define RFC4675_TAGGED   0x31
+#define RFC4675_UNTAGGED 0x32
 
-static void print_attr_string(register u_char *, u_int, u_short );
-static void print_attr_num(register u_char *, u_int, u_short );
-static void print_vendor_attr(register u_char *, u_int, u_short );
-static void print_attr_address(register u_char *, u_int, u_short);
-static void print_attr_time(register u_char *, u_int, u_short);
-static void print_attr_strange(register u_char *, u_int, u_short);
+static const struct tok rfc4675_tagged[] = {
+    { RFC4675_TAGGED,   "Tagged" },
+    { RFC4675_UNTAGGED, "Untagged" },
+    { 0, NULL}
+};
 
 
-struct radius_hdr { u_int8_t  code; /* Radius packet code  */
-                    u_int8_t  id;   /* Radius packet id    */
-                    u_int16_t len;  /* Radius total length */
-                    u_int8_t  auth[16]; /* Authenticator   */
+static void print_attr_string(netdissect_options *, register u_char *, u_int, u_short );
+static void print_attr_num(netdissect_options *, register u_char *, u_int, u_short );
+static void print_vendor_attr(netdissect_options *, register u_char *, u_int, u_short );
+static void print_attr_address(netdissect_options *, register u_char *, u_int, u_short);
+static void print_attr_time(netdissect_options *, register u_char *, u_int, u_short);
+static void print_attr_strange(netdissect_options *, register u_char *, u_int, u_short);
+
+
+struct radius_hdr { uint8_t  code; /* Radius packet code  */
+                    uint8_t  id;   /* Radius packet id    */
+                    uint16_t len;  /* Radius total length */
+                    uint8_t  auth[16]; /* Authenticator   */
                   };
 
 #define MIN_RADIUS_LEN	20
 
-struct radius_attr { u_int8_t type; /* Attribute type   */
-                     u_int8_t len;  /* Attribute length */
+struct radius_attr { uint8_t type; /* Attribute type   */
+                     uint8_t len;  /* Attribute length */
                    };
 
 
@@ -214,6 +240,12 @@
                                    "RADIUS-Request",
                                  };
 
+/* Ingress-Filters Attribute standard values */
+static const char *ingress_filters[]={ NULL,
+                                       "Enabled",
+                                       "Disabled",
+                                     };
+
 /* NAS-Port-Type Attribute standard values */
 static const char *nas_port_type[]={ "Async",
                                      "Sync",
@@ -337,101 +369,101 @@
                   const char **subtypes; /* Standard Values (if any)       */
                   u_char siz_subtypes;   /* Size of total standard values  */
                   u_char first_subtype;  /* First standard value is 0 or 1 */
-                  void (*print_func)(register u_char *, u_int, u_short );
+                  void (*print_func)(netdissect_options *, register u_char *, u_int, u_short);
                 } attr_type[]=
   {
      { NULL,                              NULL, 0, 0, NULL               },
-     { "Username",                        NULL, 0, 0, print_attr_string  },
-     { "Password",                        NULL, 0, 0, NULL               },
-     { "CHAP Password",                   NULL, 0, 0, NULL               },
-     { "NAS IP Address",                  NULL, 0, 0, print_attr_address },
-     { "NAS Port",                        NULL, 0, 0, print_attr_num     },
-     { "Service Type",                    serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
-     { "Framed Protocol",                 frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
-     { "Framed IP Address",               NULL, 0, 0, print_attr_address },
-     { "Framed IP Network",               NULL, 0, 0, print_attr_address },
-     { "Framed Routing",                  frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
-     { "Filter ID",                       NULL, 0, 0, print_attr_string  },
-     { "Framed MTU",                      NULL, 0, 0, print_attr_num     },
-     { "Framed Compression",              frm_comp, TAM_SIZE(frm_comp),   0, print_attr_num },
-     { "Login IP Host",                   NULL, 0, 0, print_attr_address },
-     { "Login Service",                   login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
-     { "Login TCP Port",                  NULL, 0, 0, print_attr_num     },
+     { "User-Name",                       NULL, 0, 0, print_attr_string  },
+     { "User-Password",                   NULL, 0, 0, NULL               },
+     { "CHAP-Password",                   NULL, 0, 0, NULL               },
+     { "NAS-IP-Address",                  NULL, 0, 0, print_attr_address },
+     { "NAS-Port",                        NULL, 0, 0, print_attr_num     },
+     { "Service-Type",                    serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
+     { "Framed-Protocol",                 frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
+     { "Framed-IP-Address",               NULL, 0, 0, print_attr_address },
+     { "Framed-IP-Netmask",               NULL, 0, 0, print_attr_address },
+     { "Framed-Routing",                  frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
+     { "Filter-Id",                       NULL, 0, 0, print_attr_string  },
+     { "Framed-MTU",                      NULL, 0, 0, print_attr_num     },
+     { "Framed-Compression",              frm_comp, TAM_SIZE(frm_comp),   0, print_attr_num },
+     { "Login-IP-Host",                   NULL, 0, 0, print_attr_address },
+     { "Login-Service",                   login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
+     { "Login-TCP-Port",                  NULL, 0, 0, print_attr_num     },
      { "Unassigned",                      NULL, 0, 0, NULL }, /*17*/
-     { "Reply",                           NULL, 0, 0, print_attr_string },
-     { "Callback-number",                 NULL, 0, 0, print_attr_string },
-     { "Callback-ID",                     NULL, 0, 0, print_attr_string },
+     { "Reply-Message",                   NULL, 0, 0, print_attr_string },
+     { "Callback-Number",                 NULL, 0, 0, print_attr_string },
+     { "Callback-Id",                     NULL, 0, 0, print_attr_string },
      { "Unassigned",                      NULL, 0, 0, NULL }, /*21*/
-     { "Framed Route",                    NULL, 0, 0, print_attr_string },
-     { "Framed IPX Network",              NULL, 0, 0, print_attr_num    },
+     { "Framed-Route",                    NULL, 0, 0, print_attr_string },
+     { "Framed-IPX-Network",              NULL, 0, 0, print_attr_num    },
      { "State",                           NULL, 0, 0, print_attr_string },
      { "Class",                           NULL, 0, 0, print_attr_string },
-     { "Vendor Specific",                 NULL, 0, 0, print_vendor_attr },
-     { "Session Timeout",                 NULL, 0, 0, print_attr_num    },
-     { "Idle Timeout",                    NULL, 0, 0, print_attr_num    },
-     { "Termination Action",              term_action, TAM_SIZE(term_action), 0, print_attr_num },
-     { "Called Station",                  NULL, 0, 0, print_attr_string },
-     { "Calling Station",                 NULL, 0, 0, print_attr_string },
-     { "NAS ID",                          NULL, 0, 0, print_attr_string },
-     { "Proxy State",                     NULL, 0, 0, print_attr_string },
-     { "Login LAT Service",               NULL, 0, 0, print_attr_string },
-     { "Login LAT Node",                  NULL, 0, 0, print_attr_string },
-     { "Login LAT Group",                 NULL, 0, 0, print_attr_string },
-     { "Framed Appletalk Link",           NULL, 0, 0, print_attr_num    },
-     { "Framed Appltalk Net",             NULL, 0, 0, print_attr_num    },
-     { "Framed Appletalk Zone",           NULL, 0, 0, print_attr_string },
-     { "Accounting Status",               acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
-     { "Accounting Delay",                NULL, 0, 0, print_attr_num    },
-     { "Accounting Input Octets",         NULL, 0, 0, print_attr_num    },
-     { "Accounting Output Octets",        NULL, 0, 0, print_attr_num    },
-     { "Accounting Session ID",           NULL, 0, 0, print_attr_string },
-     { "Accounting Authentication",       acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
-     { "Accounting Session Time",         NULL, 0, 0, print_attr_num },
-     { "Accounting Input Packets",        NULL, 0, 0, print_attr_num },
-     { "Accounting Output Packets",       NULL, 0, 0, print_attr_num },
-     { "Accounting Termination Cause",    acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
-     { "Accounting Multilink Session ID", NULL, 0, 0, print_attr_string },
-     { "Accounting Link Count",           NULL, 0, 0, print_attr_num },
-     { "Accounting Input Giga",           NULL, 0, 0, print_attr_num },
-     { "Accounting Output Giga",          NULL, 0, 0, print_attr_num },
+     { "Vendor-Specific",                 NULL, 0, 0, print_vendor_attr },
+     { "Session-Timeout",                 NULL, 0, 0, print_attr_num    },
+     { "Idle-Timeout",                    NULL, 0, 0, print_attr_num    },
+     { "Termination-Action",              term_action, TAM_SIZE(term_action), 0, print_attr_num },
+     { "Called-Station-Id",               NULL, 0, 0, print_attr_string },
+     { "Calling-Station-Id",              NULL, 0, 0, print_attr_string },
+     { "NAS-Identifier",                  NULL, 0, 0, print_attr_string },
+     { "Proxy-State",                     NULL, 0, 0, print_attr_string },
+     { "Login-LAT-Service",               NULL, 0, 0, print_attr_string },
+     { "Login-LAT-Node",                  NULL, 0, 0, print_attr_string },
+     { "Login-LAT-Group",                 NULL, 0, 0, print_attr_string },
+     { "Framed-AppleTalk-Link",           NULL, 0, 0, print_attr_num    },
+     { "Framed-AppleTalk-Network",        NULL, 0, 0, print_attr_num    },
+     { "Framed-AppleTalk-Zone",           NULL, 0, 0, print_attr_string },
+     { "Acct-Status-Type",                acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
+     { "Acct-Delay-Time",                 NULL, 0, 0, print_attr_num    },
+     { "Acct-Input-Octets",               NULL, 0, 0, print_attr_num    },
+     { "Acct-Output-Octets",              NULL, 0, 0, print_attr_num    },
+     { "Acct-Session-Id",                 NULL, 0, 0, print_attr_string },
+     { "Acct-Authentic",                  acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
+     { "Acct-Session-Time",               NULL, 0, 0, print_attr_num },
+     { "Acct-Input-Packets",              NULL, 0, 0, print_attr_num },
+     { "Acct-Output-Packets",             NULL, 0, 0, print_attr_num },
+     { "Acct-Terminate-Cause",            acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
+     { "Acct-Multi-Session-Id",           NULL, 0, 0, print_attr_string },
+     { "Acct-Link-Count",                 NULL, 0, 0, print_attr_num },
+     { "Acct-Input-Gigawords",            NULL, 0, 0, print_attr_num },
+     { "Acct-Output-Gigawords",           NULL, 0, 0, print_attr_num },
      { "Unassigned",                      NULL, 0, 0, NULL }, /*54*/
-     { "Event Timestamp",                 NULL, 0, 0, print_attr_time },
-     { "Unassigned",                      NULL, 0, 0, NULL }, /*56*/
-     { "Unassigned",                      NULL, 0, 0, NULL }, /*57*/
-     { "Unassigned",                      NULL, 0, 0, NULL }, /*58*/
-     { "Unassigned",                      NULL, 0, 0, NULL }, /*59*/
-     { "CHAP challenge",                  NULL, 0, 0, print_attr_string },
-     { "NAS Port Type",                   nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
-     { "Port Limit",                      NULL, 0, 0, print_attr_num },
-     { "Login LAT Port",                  NULL, 0, 0, print_attr_string }, /*63*/
-     { "Tunnel Type",                     tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
-     { "Tunnel Medium",                   tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
-     { "Tunnel Client End",               NULL, 0, 0, print_attr_string },
-     { "Tunnel Server End",               NULL, 0, 0, print_attr_string },
-     { "Accounting Tunnel connect",       NULL, 0, 0, print_attr_string },
-     { "Tunnel Password",                 NULL, 0, 0, print_attr_string  },
-     { "ARAP Password",                   NULL, 0, 0, print_attr_strange },
-     { "ARAP Feature",                    NULL, 0, 0, print_attr_strange },
-     { "ARAP Zone Acces",                 arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
-     { "ARAP Security",                   NULL, 0, 0, print_attr_string },
-     { "ARAP Security Data",              NULL, 0, 0, print_attr_string },
-     { "Password Retry",                  NULL, 0, 0, print_attr_num    },
+     { "Event-Timestamp",                 NULL, 0, 0, print_attr_time },
+     { "Egress-VLANID",                   NULL, 0, 0, print_attr_num },
+     { "Ingress-Filters",                 ingress_filters, TAM_SIZE(ingress_filters)-1, 1, print_attr_num },
+     { "Egress-VLAN-Name",                NULL, 0, 0, print_attr_string },
+     { "User-Priority-Table",             NULL, 0, 0, NULL },
+     { "CHAP-Challenge",                  NULL, 0, 0, print_attr_string },
+     { "NAS-Port-Type",                   nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
+     { "Port-Limit",                      NULL, 0, 0, print_attr_num },
+     { "Login-LAT-Port",                  NULL, 0, 0, print_attr_string }, /*63*/
+     { "Tunnel-Type",                     tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
+     { "Tunnel-Medium-Type",              tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
+     { "Tunnel-Client-Endpoint",          NULL, 0, 0, print_attr_string },
+     { "Tunnel-Server-Endpoint",          NULL, 0, 0, print_attr_string },
+     { "Acct-Tunnel-Connection",          NULL, 0, 0, print_attr_string },
+     { "Tunnel-Password",                 NULL, 0, 0, print_attr_string  },
+     { "ARAP-Password",                   NULL, 0, 0, print_attr_strange },
+     { "ARAP-Features",                   NULL, 0, 0, print_attr_strange },
+     { "ARAP-Zone-Access",                arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
+     { "ARAP-Security",                   NULL, 0, 0, print_attr_string },
+     { "ARAP-Security-Data",              NULL, 0, 0, print_attr_string },
+     { "Password-Retry",                  NULL, 0, 0, print_attr_num    },
      { "Prompt",                          prompt, TAM_SIZE(prompt), 0, print_attr_num },
-     { "Connect Info",                    NULL, 0, 0, print_attr_string   },
-     { "Config Token",                    NULL, 0, 0, print_attr_string   },
-     { "EAP Message",                     NULL, 0, 0, print_attr_string   },
-     { "Message Authentication",          NULL, 0, 0, print_attr_string }, /*80*/
-     { "Tunnel Private Group",            NULL, 0, 0, print_attr_string },
-     { "Tunnel Assigned ID",              NULL, 0, 0, print_attr_string },
-     { "Tunnel Preference",               NULL, 0, 0, print_attr_num    },
-     { "ARAP Challenge Response",         NULL, 0, 0, print_attr_strange },
-     { "Accounting Interim Interval",     NULL, 0, 0, print_attr_num     },
-     { "Accounting Tunnel packets lost",  NULL, 0, 0, print_attr_num }, /*86*/
-     { "NAS Port ID",                     NULL, 0, 0, print_attr_string },
-     { "Framed Pool",                     NULL, 0, 0, print_attr_string },
-     { "Unassigned",                      NULL, 0, 0, NULL },
-     { "Tunnel Client Authentication ID", NULL, 0, 0, print_attr_string },
-     { "Tunnel Server Authentication ID", NULL, 0, 0, print_attr_string },
+     { "Connect-Info",                    NULL, 0, 0, print_attr_string   },
+     { "Configuration-Token",             NULL, 0, 0, print_attr_string   },
+     { "EAP-Message",                     NULL, 0, 0, print_attr_string   },
+     { "Message-Authenticator",           NULL, 0, 0, print_attr_string }, /*80*/
+     { "Tunnel-Private-Group-ID",         NULL, 0, 0, print_attr_string },
+     { "Tunnel-Assignment-ID",            NULL, 0, 0, print_attr_string },
+     { "Tunnel-Preference",               NULL, 0, 0, print_attr_num    },
+     { "ARAP-Challenge-Response",         NULL, 0, 0, print_attr_strange },
+     { "Acct-Interim-Interval",           NULL, 0, 0, print_attr_num     },
+     { "Acct-Tunnel-Packets-Lost",        NULL, 0, 0, print_attr_num }, /*86*/
+     { "NAS-Port-Id",                     NULL, 0, 0, print_attr_string },
+     { "Framed-Pool",                     NULL, 0, 0, print_attr_string },
+     { "CUI",                             NULL, 0, 0, print_attr_string },
+     { "Tunnel-Client-Auth-ID",           NULL, 0, 0, print_attr_string },
+     { "Tunnel-Server-Auth-ID",           NULL, 0, 0, print_attr_string },
      { "Unassigned",                      NULL, 0, 0, NULL }, /*92*/
      { "Unassigned",                      NULL, 0, 0, NULL }  /*93*/
   };
@@ -445,25 +477,28 @@
 /* Returns nothing.          */
 /*****************************/
 static void
-print_attr_string(register u_char *data, u_int length, u_short attr_code )
+print_attr_string(netdissect_options *ndo,
+                  register u_char *data, u_int length, u_short attr_code)
 {
    register u_int i;
 
-   TCHECK2(data[0],length);
+   ND_TCHECK2(data[0],length);
 
    switch(attr_code)
    {
       case TUNNEL_PASS:
            if (length < 3)
            {
-              printf(" [|radius]");
+              ND_PRINT((ndo, "%s", tstr));
               return;
            }
            if (*data && (*data <=0x1F) )
-              printf("Tag %u, ",*data);
+              ND_PRINT((ndo, "Tag[%u] ", *data));
+           else
+              ND_PRINT((ndo, "Tag[Unused] "));
            data++;
            length--;
-           printf("Salt %u ",EXTRACT_16BITS(data) );
+           ND_PRINT((ndo, "Salt %u ", EXTRACT_16BITS(data)));
            data+=2;
            length-=2;
         break;
@@ -477,31 +512,41 @@
            {
               if (length < 1)
               {
-                 printf(" [|radius]");
+                 ND_PRINT((ndo, "%s", tstr));
                  return;
               }
-              printf("Tag %u",*data);
+              if (*data)
+                ND_PRINT((ndo, "Tag[%u] ", *data));
+              else
+                ND_PRINT((ndo, "Tag[Unused] "));
               data++;
               length--;
            }
         break;
+      case EGRESS_VLAN_NAME:
+           ND_PRINT((ndo, "%s (0x%02x) ",
+                  tok2str(rfc4675_tagged,"Unknown tag",*data),
+                  *data));
+           data++;
+           length--;
+        break;
    }
 
    for (i=0; *data && i < length ; i++, data++)
-       printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
+       ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
 
    return;
 
    trunc:
-      printf(" [|radius]");
+      ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
  * print vendor specific attributes
  */
-
 static void
-print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
+print_vendor_attr(netdissect_options *ndo,
+                  register u_char *data, u_int length, u_short attr_code _U_)
 {
     u_int idx;
     u_int vendor_id;
@@ -510,55 +555,53 @@
 
     if (length < 4)
         goto trunc;
-    TCHECK2(*data, 4);
+    ND_TCHECK2(*data, 4);
     vendor_id = EXTRACT_32BITS(data);
     data+=4;
     length-=4;
 
-    printf("Vendor: %s (%u)",
+    ND_PRINT((ndo, "Vendor: %s (%u)",
            tok2str(smi_values,"Unknown",vendor_id),
-           vendor_id);
+           vendor_id));
 
     while (length >= 2) {
-	TCHECK2(*data, 2);
+	ND_TCHECK2(*data, 2);
 
         vendor_type = *(data);
         vendor_length = *(data+1);
 
         if (vendor_length < 2)
         {
-            printf("\n\t    Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
+            ND_PRINT((ndo, "\n\t    Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
                    vendor_type,
-                   vendor_length);
+                   vendor_length));
             return;
         }
         if (vendor_length > length)
         {
-            printf("\n\t    Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
+            ND_PRINT((ndo, "\n\t    Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
                    vendor_type,
-                   vendor_length);
+                   vendor_length));
             return;
         }
         data+=2;
         vendor_length-=2;
         length-=2;
-	TCHECK2(*data, vendor_length);
+	ND_TCHECK2(*data, vendor_length);
 
-        printf("\n\t    Vendor Attribute: %u, Length: %u, Value: ",
+        ND_PRINT((ndo, "\n\t    Vendor Attribute: %u, Length: %u, Value: ",
                vendor_type,
-               vendor_length);
+               vendor_length));
         for (idx = 0; idx < vendor_length ; idx++, data++)
-            printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
+            ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
         length-=vendor_length;
     }
     return;
 
    trunc:
-     printf(" [|radius]");
+     ND_PRINT((ndo, "%s", tstr));
 }
 
-
-
 /******************************/
 /* Print an attribute numeric */
 /* value pointed by 'data'    */
@@ -567,31 +610,31 @@
 /* Returns nothing.           */
 /******************************/
 static void
-print_attr_num(register u_char *data, u_int length, u_short attr_code )
+print_attr_num(netdissect_options *ndo,
+               register u_char *data, u_int length, u_short attr_code)
 {
-   u_int8_t tag;
-   u_int32_t timeout;
+   uint32_t timeout;
 
    if (length != 4)
    {
-       printf("ERROR: length %u != 4", length);
+       ND_PRINT((ndo, "ERROR: length %u != 4", length));
        return;
    }
 
-   TCHECK2(data[0],4);
+   ND_TCHECK2(data[0],4);
                           /* This attribute has standard values */
    if (attr_type[attr_code].siz_subtypes)
    {
       static const char **table;
-      u_int32_t data_value;
+      uint32_t data_value;
       table = attr_type[attr_code].subtypes;
 
       if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
       {
          if (!*data)
-            printf("Tag[Unused]");
+            ND_PRINT((ndo, "Tag[Unused] "));
          else
-            printf("Tag[%d]", *data);
+            ND_PRINT((ndo, "Tag[%d] ", *data));
          data++;
          data_value = EXTRACT_24BITS(data);
       }
@@ -599,12 +642,12 @@
       {
          data_value = EXTRACT_32BITS(data);
       }
-      if ( data_value <= (u_int32_t)(attr_type[attr_code].siz_subtypes - 1 +
+      if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 +
             attr_type[attr_code].first_subtype) &&
 	   data_value >= attr_type[attr_code].first_subtype )
-         printf("%s",table[data_value]);
+         ND_PRINT((ndo, "%s", table[data_value]));
       else
-         printf("#%u",data_value);
+         ND_PRINT((ndo, "#%u", data_value));
    }
    else
    {
@@ -612,9 +655,9 @@
       {
         case FRM_IPX:
              if (EXTRACT_32BITS( data) == 0xFFFFFFFE )
-                printf("NAS Select");
+                ND_PRINT((ndo, "NAS Select"));
              else
-                printf("%d",EXTRACT_32BITS( data) );
+                ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
           break;
 
         case SESSION_TIMEOUT:
@@ -624,44 +667,52 @@
         case ACCT_INT_INTERVAL:
              timeout = EXTRACT_32BITS( data);
              if ( timeout < 60 )
-                printf( "%02d secs", timeout);
+                ND_PRINT((ndo,  "%02d secs", timeout));
              else
              {
                 if ( timeout < 3600 )
-                   printf( "%02d:%02d min",
-                          timeout / 60, timeout % 60);
+                   ND_PRINT((ndo,  "%02d:%02d min",
+                          timeout / 60, timeout % 60));
                 else
-                   printf( "%02d:%02d:%02d hours",
+                   ND_PRINT((ndo, "%02d:%02d:%02d hours",
                           timeout / 3600, (timeout % 3600) / 60,
-                          timeout % 60);
+                          timeout % 60));
              }
           break;
 
         case FRM_ATALK_LINK:
              if (EXTRACT_32BITS(data) )
-                printf("%d",EXTRACT_32BITS(data) );
+                ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
              else
-                printf("Unnumbered" );
+                ND_PRINT((ndo, "Unnumbered"));
           break;
 
         case FRM_ATALK_NETWORK:
              if (EXTRACT_32BITS(data) )
-                printf("%d",EXTRACT_32BITS(data) );
+                ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
              else
-                printf("NAS assigned" );
+                ND_PRINT((ndo, "NAS assigned"));
           break;
 
         case TUNNEL_PREFERENCE:
-            tag = *data;
-            data++;
-            if (tag == 0)
-               printf("Tag (Unused) %d",EXTRACT_24BITS(data) );
+            if (*data)
+               ND_PRINT((ndo, "Tag[%d] ", *data));
             else
-               printf("Tag (%d) %d", tag, EXTRACT_24BITS(data) );
+               ND_PRINT((ndo, "Tag[Unused] "));
+            data++;
+            ND_PRINT((ndo, "%d", EXTRACT_24BITS(data)));
+          break;
+
+        case EGRESS_VLAN_ID:
+            ND_PRINT((ndo, "%s (0x%02x) ",
+                   tok2str(rfc4675_tagged,"Unknown tag",*data),
+                   *data));
+            data++;
+            ND_PRINT((ndo, "%d", EXTRACT_24BITS(data)));
           break;
 
         default:
-             printf("%d",EXTRACT_32BITS( data) );
+             ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
           break;
 
       } /* switch */
@@ -671,10 +722,9 @@
    return;
 
    trunc:
-     printf(" [|radius]");
+     ND_PRINT((ndo, "%s", tstr));
 }
 
-
 /*****************************/
 /* Print an attribute IPv4   */
 /* address value pointed by  */
@@ -683,41 +733,41 @@
 /* Returns nothing.          */
 /*****************************/
 static void
-print_attr_address(register u_char *data, u_int length, u_short attr_code )
+print_attr_address(netdissect_options *ndo,
+                   register u_char *data, u_int length, u_short attr_code)
 {
    if (length != 4)
    {
-       printf("ERROR: length %u != 4", length);
+       ND_PRINT((ndo, "ERROR: length %u != 4", length));
        return;
    }
 
-   TCHECK2(data[0],4);
+   ND_TCHECK2(data[0],4);
 
    switch(attr_code)
    {
       case FRM_IPADDR:
       case LOG_IPHOST:
            if (EXTRACT_32BITS(data) == 0xFFFFFFFF )
-              printf("User Selected");
+              ND_PRINT((ndo, "User Selected"));
            else
               if (EXTRACT_32BITS(data) == 0xFFFFFFFE )
-                 printf("NAS Select");
+                 ND_PRINT((ndo, "NAS Select"));
               else
-                 printf("%s",ipaddr_string(data));
+                 ND_PRINT((ndo, "%s",ipaddr_string(ndo, data)));
       break;
 
       default:
-          printf("%s",ipaddr_string(data) );
+          ND_PRINT((ndo, "%s", ipaddr_string(ndo, data)));
       break;
    }
 
    return;
 
    trunc:
-     printf(" [|radius]");
+     ND_PRINT((ndo, "%s", tstr));
 }
 
-
 /*************************************/
 /* Print an attribute of 'secs since */
 /* January 1, 1970 00:00 UTC' value  */
@@ -726,31 +776,32 @@
 /*************************************/
 /* Returns nothing.                  */
 /*************************************/
-static void print_attr_time(register u_char *data, u_int length, u_short attr_code _U_)
+static void
+print_attr_time(netdissect_options *ndo,
+                register u_char *data, u_int length, u_short attr_code _U_)
 {
    time_t attr_time;
    char string[26];
 
    if (length != 4)
    {
-       printf("ERROR: length %u != 4", length);
+       ND_PRINT((ndo, "ERROR: length %u != 4", length));
        return;
    }
 
-   TCHECK2(data[0],4);
+   ND_TCHECK2(data[0],4);
 
    attr_time = EXTRACT_32BITS(data);
    strlcpy(string, ctime(&attr_time), sizeof(string));
    /* Get rid of the newline */
    string[24] = '\0';
-   printf("%.24s", string);
+   ND_PRINT((ndo, "%.24s", string));
    return;
 
    trunc:
-     printf(" [|radius]");
+     ND_PRINT((ndo, "%s", tstr));
 }
 
-
 /***********************************/
 /* Print an attribute of 'strange' */
 /* data format pointed by 'data'   */
@@ -758,7 +809,9 @@
 /***********************************/
 /* Returns nothing.                */
 /***********************************/
-static void print_attr_strange(register u_char *data, u_int length, u_short attr_code)
+static void
+print_attr_strange(netdissect_options *ndo,
+                   register u_char *data, u_int length, u_short attr_code)
 {
    u_short len_data;
 
@@ -767,45 +820,45 @@
       case ARAP_PASS:
            if (length != 16)
            {
-               printf("ERROR: length %u != 16", length);
+               ND_PRINT((ndo, "ERROR: length %u != 16", length));
                return;
            }
-           printf("User_challenge (");
-           TCHECK2(data[0],8);
+           ND_PRINT((ndo, "User_challenge ("));
+           ND_TCHECK2(data[0],8);
            len_data = 8;
            PRINT_HEX(len_data, data);
-           printf(") User_resp(");
-           TCHECK2(data[0],8);
+           ND_PRINT((ndo, ") User_resp("));
+           ND_TCHECK2(data[0],8);
            len_data = 8;
            PRINT_HEX(len_data, data);
-           printf(")");
+           ND_PRINT((ndo, ")"));
         break;
 
       case ARAP_FEATURES:
            if (length != 14)
            {
-               printf("ERROR: length %u != 14", length);
+               ND_PRINT((ndo, "ERROR: length %u != 14", length));
                return;
            }
-           TCHECK2(data[0],1);
+           ND_TCHECK2(data[0],1);
            if (*data)
-              printf("User can change password");
+              ND_PRINT((ndo, "User can change password"));
            else
-              printf("User cannot change password");
+              ND_PRINT((ndo, "User cannot change password"));
            data++;
-           TCHECK2(data[0],1);
-           printf(", Min password length: %d",*data);
+           ND_TCHECK2(data[0],1);
+           ND_PRINT((ndo, ", Min password length: %d", *data));
            data++;
-           printf(", created at: ");
-           TCHECK2(data[0],4);
+           ND_PRINT((ndo, ", created at: "));
+           ND_TCHECK2(data[0],4);
            len_data = 4;
            PRINT_HEX(len_data, data);
-           printf(", expires in: ");
-           TCHECK2(data[0],4);
+           ND_PRINT((ndo, ", expires in: "));
+           ND_TCHECK2(data[0],4);
            len_data = 4;
            PRINT_HEX(len_data, data);
-           printf(", Current Time: ");
-           TCHECK2(data[0],4);
+           ND_PRINT((ndo, ", Current Time: "));
+           ND_TCHECK2(data[0],4);
            len_data = 4;
            PRINT_HEX(len_data, data);
         break;
@@ -813,10 +866,10 @@
       case ARAP_CHALLENGE_RESP:
            if (length < 8)
            {
-               printf("ERROR: length %u != 8", length);
+               ND_PRINT((ndo, "ERROR: length %u != 8", length));
                return;
            }
-           TCHECK2(data[0],8);
+           ND_TCHECK2(data[0],8);
            len_data = 8;
            PRINT_HEX(len_data, data);
         break;
@@ -824,13 +877,12 @@
    return;
 
    trunc:
-     printf(" [|radius]");
+     ND_PRINT((ndo, "%s", tstr));
 }
 
-
-
 static void
-radius_attrs_print(register const u_char *attr, u_int length)
+radius_attrs_print(netdissect_options *ndo,
+                   register const u_char *attr, u_int length)
 {
    register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
    const char *attr_string;
@@ -839,32 +891,32 @@
    {
      if (length < 2)
         goto trunc;
-     TCHECK(*rad_attr);
-     
+     ND_TCHECK(*rad_attr);
+
      if (rad_attr->type > 0 && rad_attr->type < TAM_SIZE(attr_type))
 	attr_string = attr_type[rad_attr->type].name;
      else
 	attr_string = "Unknown";
      if (rad_attr->len < 2)
      {
-	printf("\n\t  %s Attribute (%u), length: %u (bogus, must be >= 2)",
+	ND_PRINT((ndo, "\n\t  %s Attribute (%u), length: %u (bogus, must be >= 2)",
                attr_string,
                rad_attr->type,
-               rad_attr->len);
+               rad_attr->len));
 	return;
      }
      if (rad_attr->len > length)
      {
-	printf("\n\t  %s Attribute (%u), length: %u (bogus, goes past end of packet)",
+	ND_PRINT((ndo, "\n\t  %s Attribute (%u), length: %u (bogus, goes past end of packet)",
                attr_string,
                rad_attr->type,
-               rad_attr->len);
+               rad_attr->len));
         return;
      }
-     printf("\n\t  %s Attribute (%u), length: %u, Value: ",
+     ND_PRINT((ndo, "\n\t  %s Attribute (%u), length: %u, Value: ",
             attr_string,
             rad_attr->type,
-            rad_attr->len);
+            rad_attr->len));
 
      if (rad_attr->type < TAM_SIZE(attr_type))
      {
@@ -872,13 +924,13 @@
          {
              if ( attr_type[rad_attr->type].print_func )
                  (*attr_type[rad_attr->type].print_func)(
-                     ((u_char *)(rad_attr+1)),
+                     ndo, ((u_char *)(rad_attr+1)),
                      rad_attr->len - 2, rad_attr->type);
          }
      }
      /* do we also want to see a hex dump ? */
-     if (vflag> 1)
-         print_unknown_data((u_char *)rad_attr+2,"\n\t    ",(rad_attr->len)-2);
+     if (ndo->ndo_vflag> 1)
+         print_unknown_data(ndo, (u_char *)rad_attr+2, "\n\t    ", (rad_attr->len)-2);
 
      length-=(rad_attr->len);
      rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len);
@@ -886,52 +938,52 @@
    return;
 
 trunc:
-   printf(" [|radius]");
+   ND_PRINT((ndo, "%s", tstr));
 }
 
-
 void
-radius_print(const u_char *dat, u_int length)
+radius_print(netdissect_options *ndo,
+             const u_char *dat, u_int length)
 {
    register const struct radius_hdr *rad;
    u_int len, auth_idx;
 
-   TCHECK2(*dat, MIN_RADIUS_LEN);
+   ND_TCHECK2(*dat, MIN_RADIUS_LEN);
    rad = (struct radius_hdr *)dat;
    len = EXTRACT_16BITS(&rad->len);
 
    if (len < MIN_RADIUS_LEN)
    {
-	  printf(" [|radius]");
+	  ND_PRINT((ndo, "%s", tstr));
 	  return;
    }
 
    if (len > length)
 	  len = length;
 
-   if (vflag < 1) {
-       printf("RADIUS, %s (%u), id: 0x%02x length: %u",
+   if (ndo->ndo_vflag < 1) {
+       ND_PRINT((ndo, "RADIUS, %s (%u), id: 0x%02x length: %u",
               tok2str(radius_command_values,"Unknown Command",rad->code),
               rad->code,
               rad->id,
-              len);
+              len));
        return;
    }
    else {
-       printf("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
+       ND_PRINT((ndo, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
               len,
               tok2str(radius_command_values,"Unknown Command",rad->code),
               rad->code,
-              rad->id);
+              rad->id));
 
        for(auth_idx=0; auth_idx < 16; auth_idx++)
-            printf("%02x", rad->auth[auth_idx] );
+            ND_PRINT((ndo, "%02x", rad->auth[auth_idx]));
    }
 
    if (len > MIN_RADIUS_LEN)
-      radius_attrs_print( dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
+      radius_attrs_print(ndo, dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
    return;
 
 trunc:
-   printf(" [|radius]");
+   ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-raw.c b/print-raw.c
index 8e376ce..d20387c 100644
--- a/print-raw.c
+++ b/print-raw.c
@@ -19,22 +19,13 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.41 2003-11-16 09:36:34 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "addrtoname.h"
 #include "interface.h"
 
 /*
@@ -42,12 +33,12 @@
  */
 
 u_int
-raw_if_print(const struct pcap_pkthdr *h, const u_char *p)
+raw_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
-	if (eflag)
-		printf("ip: ");
+	if (ndo->ndo_eflag)
+		ND_PRINT((ndo, "ip: "));
 
-	ipN_print(p, h->len);
+	ipN_print(ndo, p, h->len);
 
 	return (0);
 }
diff --git a/print-rip.c b/print-rip.c
index c753a92..c1b036e 100644
--- a/print-rip.c
+++ b/print-rip.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.59 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -31,7 +27,6 @@
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
-#include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
@@ -39,10 +34,12 @@
 
 #include "af.h"
 
+static const char tstr[] = "[|rip]";
+
 struct rip {
-	u_int8_t rip_cmd;		/* request/response */
-	u_int8_t rip_vers;		/* protocol version # */
-	u_int8_t unused[2];		/* unused */
+	uint8_t rip_cmd;		/* request/response */
+	uint8_t rip_vers;		/* protocol version # */
+	uint8_t unused[2];		/* unused */
 };
 
 #define	RIPCMD_REQUEST		1	/* want info */
@@ -67,7 +64,7 @@
 
 /*
  * rfc 1723
- * 
+ *
  *  0                   1                   2                   3 3
  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -87,118 +84,121 @@
  */
 
 struct rip_netinfo {
-	u_int16_t rip_family;
-	u_int16_t rip_tag;
-	u_int32_t rip_dest;
-	u_int32_t rip_dest_mask;
-	u_int32_t rip_router;
-	u_int32_t rip_metric;		/* cost of route */
+	uint16_t rip_family;
+	uint16_t rip_tag;
+	uint32_t rip_dest;
+	uint32_t rip_dest_mask;
+	uint32_t rip_router;
+	uint32_t rip_metric;		/* cost of route */
 };
 
 static void
-rip_entry_print_v1(register const struct rip_netinfo *ni)
+rip_entry_print_v1(netdissect_options *ndo,
+                   register const struct rip_netinfo *ni)
 {
 	register u_short family;
 
 	/* RFC 1058 */
 	family = EXTRACT_16BITS(&ni->rip_family);
 	if (family != BSD_AFNUM_INET && family != 0) {
-		printf("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family));
-                print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t  ",RIP_ROUTELEN);
+		ND_PRINT((ndo, "\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family)));
+		print_unknown_data(ndo, (uint8_t *)&ni->rip_family, "\n\t  ", RIP_ROUTELEN);
 		return;
 	}
 	if (EXTRACT_16BITS(&ni->rip_tag) ||
 	    EXTRACT_32BITS(&ni->rip_dest_mask) ||
 	    EXTRACT_32BITS(&ni->rip_router)) {
 		/* MBZ fields not zero */
-                print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t  ",RIP_ROUTELEN);
+                print_unknown_data(ndo, (uint8_t *)&ni->rip_family, "\n\t  ", RIP_ROUTELEN);
 		return;
 	}
 	if (family == 0) {
-		printf("\n\t  AFI 0, %s, metric: %u",
-			ipaddr_string(&ni->rip_dest),
-			EXTRACT_32BITS(&ni->rip_metric));
+		ND_PRINT((ndo, "\n\t  AFI 0, %s, metric: %u",
+			ipaddr_string(ndo, &ni->rip_dest),
+			EXTRACT_32BITS(&ni->rip_metric)));
 		return;
 	} /* BSD_AFNUM_INET */
-	printf("\n\t  %s, metric: %u",
-               ipaddr_string(&ni->rip_dest),
-	       EXTRACT_32BITS(&ni->rip_metric));
+	ND_PRINT((ndo, "\n\t  %s, metric: %u",
+               ipaddr_string(ndo, &ni->rip_dest),
+	       EXTRACT_32BITS(&ni->rip_metric)));
 }
 
 static unsigned
-rip_entry_print_v2(register const struct rip_netinfo *ni, const unsigned remaining)
+rip_entry_print_v2(netdissect_options *ndo,
+                   register const struct rip_netinfo *ni, const unsigned remaining)
 {
 	register u_short family;
 
 	family = EXTRACT_16BITS(&ni->rip_family);
 	if (family == 0xFFFF) { /* variable-sized authentication structures */
-		u_int16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
+		uint16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
 		if (auth_type == 2) {
 			register u_char *p = (u_char *)&ni->rip_dest;
 			u_int i = 0;
-			printf("\n\t  Simple Text Authentication data: ");
+			ND_PRINT((ndo, "\n\t  Simple Text Authentication data: "));
 			for (; i < RIP_AUTHLEN; p++, i++)
-				putchar (ND_ISPRINT(*p) ? *p : '.');
+				ND_PRINT((ndo, "%c", ND_ISPRINT(*p) ? *p : '.'));
 		} else if (auth_type == 3) {
-			printf("\n\t  Auth header:");
-			printf(" Packet Len %u,", EXTRACT_16BITS((u_int8_t *)ni + 4));
-			printf(" Key-ID %u,", *((u_int8_t *)ni + 6));
-			printf(" Auth Data Len %u,", *((u_int8_t *)ni + 7));
-			printf(" SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask));
-			printf(" MBZ %u,", EXTRACT_32BITS(&ni->rip_router));
-			printf(" MBZ %u", EXTRACT_32BITS(&ni->rip_metric));
+			ND_PRINT((ndo, "\n\t  Auth header:"));
+			ND_PRINT((ndo, " Packet Len %u,", EXTRACT_16BITS((uint8_t *)ni + 4)));
+			ND_PRINT((ndo, " Key-ID %u,", *((uint8_t *)ni + 6)));
+			ND_PRINT((ndo, " Auth Data Len %u,", *((uint8_t *)ni + 7)));
+			ND_PRINT((ndo, " SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask)));
+			ND_PRINT((ndo, " MBZ %u,", EXTRACT_32BITS(&ni->rip_router)));
+			ND_PRINT((ndo, " MBZ %u", EXTRACT_32BITS(&ni->rip_metric)));
 		} else if (auth_type == 1) {
-			printf("\n\t  Auth trailer:");
-			print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t  ",remaining);
+			ND_PRINT((ndo, "\n\t  Auth trailer:"));
+			print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t  ", remaining);
 			return remaining; /* AT spans till the packet end */
-                } else {
-			printf("\n\t  Unknown (%u) Authentication data:",
-			       EXTRACT_16BITS(&ni->rip_tag));
-			print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t  ",remaining);
+		} else {
+			ND_PRINT((ndo, "\n\t  Unknown (%u) Authentication data:",
+			       EXTRACT_16BITS(&ni->rip_tag)));
+			print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t  ", remaining);
 		}
 	} else if (family != BSD_AFNUM_INET && family != 0) {
-		printf("\n\t  AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family));
-                print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t  ",RIP_ROUTELEN-2);
+		ND_PRINT((ndo, "\n\t  AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family)));
+                print_unknown_data(ndo, (uint8_t *)&ni->rip_tag, "\n\t  ", RIP_ROUTELEN-2);
 	} else { /* BSD_AFNUM_INET or AFI 0 */
-		printf("\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
+		ND_PRINT((ndo, "\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
                        tok2str(bsd_af_values, "%u", family),
-                       ipaddr_string(&ni->rip_dest),
+                       ipaddr_string(ndo, &ni->rip_dest),
 		       mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)),
                        EXTRACT_16BITS(&ni->rip_tag),
-                       EXTRACT_32BITS(&ni->rip_metric));
+                       EXTRACT_32BITS(&ni->rip_metric)));
 		if (EXTRACT_32BITS(&ni->rip_router))
-			printf("%s", ipaddr_string(&ni->rip_router));
-                else
-                    printf("self");
+			ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ni->rip_router)));
+		else
+			ND_PRINT((ndo, "self"));
 	}
 	return sizeof (*ni);
 }
 
 void
-rip_print(const u_char *dat, u_int length)
+rip_print(netdissect_options *ndo,
+          const u_char *dat, u_int length)
 {
 	register const struct rip *rp;
 	register const struct rip_netinfo *ni;
 	register u_int i, j;
 
-	if (snapend < dat) {
-		printf(" [|rip]");
+	if (ndo->ndo_snapend < dat) {
+		ND_PRINT((ndo, " %s", tstr));
 		return;
 	}
-	i = snapend - dat;
+	i = ndo->ndo_snapend - dat;
 	if (i > length)
 		i = length;
 	if (i < sizeof(*rp)) {
-		printf(" [|rip]");
+		ND_PRINT((ndo, " %s", tstr));
 		return;
 	}
 	i -= sizeof(*rp);
 
 	rp = (struct rip *)dat;
 
-        printf("%sRIPv%u",
-               (vflag >= 1) ? "\n\t" : "",
-               rp->rip_vers);
+	ND_PRINT((ndo, "%sRIPv%u",
+               (ndo->ndo_vflag >= 1) ? "\n\t" : "",
+               rp->rip_vers));
 
 	switch (rp->rip_vers) {
 	case 0:
@@ -213,38 +213,38 @@
 		 *
 		 * so perhaps we should just dump the packet, in hex.
 		 */
-                print_unknown_data((u_int8_t *)&rp->rip_cmd,"\n\t",length);
+                print_unknown_data(ndo, (uint8_t *)&rp->rip_cmd, "\n\t", length);
 		break;
 	default:
                 /* dump version and lets see if we know the commands name*/
-                printf(", %s, length: %u",
+                ND_PRINT((ndo, ", %s, length: %u",
                        tok2str(rip_cmd_values,
                                "unknown command (%u)",
                                rp->rip_cmd),
-                       length);
+                       length));
 
-                if (vflag < 1)
+                if (ndo->ndo_vflag < 1)
                     return;
 
 		switch (rp->rip_cmd) {
 		case RIPCMD_REQUEST:
 		case RIPCMD_RESPONSE:
 			j = length / sizeof(*ni);
-                        printf(", routes: %u%s", j, rp->rip_vers == 2 ? " or less" : "");
+			ND_PRINT((ndo, ", routes: %u%s", j, rp->rip_vers == 2 ? " or less" : ""));
 			ni = (struct rip_netinfo *)(rp + 1);
 			for (; i >= sizeof(*ni); ++ni) {
 				if (rp->rip_vers == 1)
 				{
-					rip_entry_print_v1(ni);
+					rip_entry_print_v1(ndo, ni);
 					i -= sizeof(*ni);
 				}
 				else if (rp->rip_vers == 2)
-					i -= rip_entry_print_v2(ni, i);
+					i -= rip_entry_print_v2(ndo, ni, i);
                                 else
                                     break;
 			}
 			if (i)
-				printf("[|rip]");
+				ND_PRINT((ndo, "%s", tstr));
 			break;
 
 		case RIPCMD_TRACEOFF:
@@ -255,15 +255,15 @@
 		case RIPCMD_TRACEON:
                     /* fall through */
 	        default:
-                    if (vflag <= 1) {
-                        if(!print_unknown_data((u_int8_t *)rp,"\n\t",length))
+                    if (ndo->ndo_vflag <= 1) {
+                        if(!print_unknown_data(ndo, (uint8_t *)rp, "\n\t", length))
                             return;
                     }
                     break;
                 }
                 /* do we want to see an additionally hexdump ? */
-                if (vflag> 1) {
-                    if(!print_unknown_data((u_int8_t *)rp,"\n\t",length))
+                if (ndo->ndo_vflag> 1) {
+                    if(!print_unknown_data(ndo, (uint8_t *)rp, "\n\t", length))
                         return;
                 }
         }
diff --git a/print-ripng.c b/print-ripng.c
index cef39da..4bc900d 100644
--- a/print-ripng.c
+++ b/print-ripng.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.18 2005-01-04 00:15:54 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -31,13 +27,65 @@
 #ifdef INET6
 
 #include <tcpdump-stdinc.h>
-#include <stdio.h>
 
-#include "route6d.h"
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 
+/*
+ * Copyright (C) 1995, 1996, 1997 and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
+ */
+#define	RIP6_VERSION	1
+
+#define	RIP6_REQUEST	1
+#define	RIP6_RESPONSE	2
+
+struct netinfo6 {
+	struct in6_addr	rip6_dest;
+	uint16_t	rip6_tag;
+	uint8_t		rip6_plen;
+	uint8_t		rip6_metric;
+};
+
+struct	rip6 {
+	uint8_t		rip6_cmd;
+	uint8_t		rip6_vers;
+	uint8_t		rip6_res1[2];
+	union {
+		struct	netinfo6	ru6_nets[1];
+		char	ru6_tracefile[1];
+	} rip6un;
+#define	rip6_nets	rip6un.ru6_nets
+#define	rip6_tracefile	rip6un.ru6_tracefile
+};
+
+#define	HOPCNT_INFINITY6	16
+
 #if !defined(IN6_IS_ADDR_UNSPECIFIED) && !defined(_MSC_VER) /* MSVC inline */
 static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
 {
@@ -47,19 +95,19 @@
 #endif
 
 static int
-rip6_entry_print(register const struct netinfo6 *ni, int metric)
+rip6_entry_print(netdissect_options *ndo, register const struct netinfo6 *ni, int metric)
 {
 	int l;
-	l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
+	l = ND_PRINT((ndo, "%s/%d", ip6addr_string(ndo, &ni->rip6_dest), ni->rip6_plen));
 	if (ni->rip6_tag)
-		l += printf(" [%d]", EXTRACT_16BITS(&ni->rip6_tag));
+		l += ND_PRINT((ndo, " [%d]", EXTRACT_16BITS(&ni->rip6_tag)));
 	if (metric)
-		l += printf(" (%d)", ni->rip6_metric);
+		l += ND_PRINT((ndo, " (%d)", ni->rip6_metric));
 	return l;
 }
 
 void
-ripng_print(const u_char *dat, unsigned int length)
+ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
 {
 	register const struct rip6 *rp = (struct rip6 *)dat;
 	register const struct netinfo6 *ni;
@@ -68,9 +116,9 @@
 	int j;
 	int trunc;
 
-	if (snapend < dat)
+	if (ndo->ndo_snapend < dat)
 		return;
-	amt = snapend - dat;
+	amt = ndo->ndo_snapend - dat;
 	i = min(length, amt);
 	if (i < (sizeof(struct rip6) - sizeof(struct netinfo6)))
 		return;
@@ -83,46 +131,46 @@
 		if (j == 1
 		    &&  rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6
 		    &&  IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) {
-			printf(" ripng-req dump");
+			ND_PRINT((ndo, " ripng-req dump"));
 			break;
 		}
 		if (j * sizeof(*ni) != length - 4)
-			printf(" ripng-req %d[%u]:", j, length);
+			ND_PRINT((ndo, " ripng-req %d[%u]:", j, length));
 		else
-			printf(" ripng-req %d:", j);
+			ND_PRINT((ndo, " ripng-req %d:", j));
 		trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
 		for (ni = rp->rip6_nets; i >= sizeof(*ni);
 		    i -= sizeof(*ni), ++ni) {
-			if (vflag > 1)
-				printf("\n\t");
+			if (ndo->ndo_vflag > 1)
+				ND_PRINT((ndo, "\n\t"));
 			else
-				printf(" ");
-			rip6_entry_print(ni, 0);
+				ND_PRINT((ndo, " "));
+			rip6_entry_print(ndo, ni, 0);
 		}
 		break;
 	case RIP6_RESPONSE:
 		j = length / sizeof(*ni);
 		if (j * sizeof(*ni) != length - 4)
-			printf(" ripng-resp %d[%u]:", j, length);
+			ND_PRINT((ndo, " ripng-resp %d[%u]:", j, length));
 		else
-			printf(" ripng-resp %d:", j);
+			ND_PRINT((ndo, " ripng-resp %d:", j));
 		trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
 		for (ni = rp->rip6_nets; i >= sizeof(*ni);
 		    i -= sizeof(*ni), ++ni) {
-			if (vflag > 1)
-				printf("\n\t");
+			if (ndo->ndo_vflag > 1)
+				ND_PRINT((ndo, "\n\t"));
 			else
-				printf(" ");
-			rip6_entry_print(ni, ni->rip6_metric);
+				ND_PRINT((ndo, " "));
+			rip6_entry_print(ndo, ni, ni->rip6_metric);
 		}
 		if (trunc)
-			printf("[|ripng]");
+			ND_PRINT((ndo, "[|ripng]"));
 		break;
 	default:
-		printf(" ripng-%d ?? %u", rp->rip6_cmd, length);
+		ND_PRINT((ndo, " ripng-%d ?? %u", rp->rip6_cmd, length));
 		break;
 	}
 	if (rp->rip6_vers != RIP6_VERSION)
-		printf(" [vers %d]", rp->rip6_vers);
+		ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
 }
 #endif /* INET6 */
diff --git a/print-rpki-rtr.c b/print-rpki-rtr.c
index c705c05..34e2057 100644
--- a/print-rpki-rtr.c
+++ b/print-rpki-rtr.c
@@ -17,19 +17,13 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-rpki_rtr.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "interface.h"
@@ -126,7 +120,7 @@
 };
 
 /*
- * Build a identation string for a given identation level.
+ * Build a indentation string for a given indentation level.
  * XXX this should be really in util.c
  */
 static char *
@@ -175,7 +169,7 @@
  * Print a single PDU.
  */
 static void
-rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
+rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
 {
     const rpki_rtr_pdu *pdu_header;
     u_int pdu_type, pdu_len, hexdump;
@@ -184,13 +178,14 @@
     pdu_header = (rpki_rtr_pdu *)tptr;
     pdu_type = pdu_header->pdu_type;
     pdu_len = EXTRACT_32BITS(pdu_header->length);
+    ND_TCHECK2(*tptr, pdu_len);
     hexdump = FALSE;
 
-    printf("%sRPKI-RTRv%u, %s PDU (%u), length: %u",
+    ND_PRINT((ndo, "%sRPKI-RTRv%u, %s PDU (%u), length: %u",
 	   indent_string(8),
 	   pdu_header->version,
 	   tok2str(rpki_rtr_pdu_values, "Unknown", pdu_type),
-	   pdu_type, pdu_len);
+	   pdu_type, pdu_len));
 
     switch (pdu_type) {
 
@@ -201,10 +196,10 @@
     case RPKI_RTR_SERIAL_QUERY_PDU:
     case RPKI_RTR_END_OF_DATA_PDU:
         msg = (const u_char *)(pdu_header + 1);
-	printf("%sSession ID: 0x%04x, Serial: %u",
+	ND_PRINT((ndo, "%sSession ID: 0x%04x, Serial: %u",
 	       indent_string(indent+2),
 	       EXTRACT_16BITS(pdu_header->u.session_id),
-	       EXTRACT_32BITS(msg));
+	       EXTRACT_32BITS(msg)));
 	break;
 
 	/*
@@ -219,9 +214,9 @@
 	break;
 
     case RPKI_RTR_CACHE_RESPONSE_PDU:
-	printf("%sSession ID: 0x%04x",
+	ND_PRINT((ndo, "%sSession ID: 0x%04x",
 	       indent_string(indent+2),
-	       EXTRACT_16BITS(pdu_header->u.session_id));
+	       EXTRACT_16BITS(pdu_header->u.session_id)));
 	break;
 
     case RPKI_RTR_IPV4_PREFIX_PDU:
@@ -229,11 +224,11 @@
 	    rpki_rtr_pdu_ipv4_prefix *pdu;
 
 	    pdu = (rpki_rtr_pdu_ipv4_prefix *)tptr;
-	    printf("%sIPv4 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
+	    ND_PRINT((ndo, "%sIPv4 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
 		   indent_string(indent+2),
-		   ipaddr_string(pdu->prefix),
+		   ipaddr_string(ndo, pdu->prefix),
 		   pdu->prefix_length, pdu->max_length,
-		   EXTRACT_32BITS(pdu->as), pdu->flags);
+		   EXTRACT_32BITS(pdu->as), pdu->flags));
 	}
 	break;
 
@@ -243,11 +238,11 @@
 	    rpki_rtr_pdu_ipv6_prefix *pdu;
 
 	    pdu = (rpki_rtr_pdu_ipv6_prefix *)tptr;
-	    printf("%sIPv6 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
+	    ND_PRINT((ndo, "%sIPv6 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
 		   indent_string(indent+2),
-		   ip6addr_string(pdu->prefix),
+		   ip6addr_string(ndo, pdu->prefix),
 		   pdu->prefix_length, pdu->max_length,
-		   EXTRACT_32BITS(pdu->as), pdu->flags);
+		   EXTRACT_32BITS(pdu->as), pdu->flags));
 	}
 	break;
 #endif
@@ -256,17 +251,17 @@
 	{
 	    rpki_rtr_pdu_error_report *pdu;
 	    u_int encapsulated_pdu_length, text_length, tlen, error_code;
-	    u_char buf[80];
 
 	    pdu = (rpki_rtr_pdu_error_report *)tptr;
 	    encapsulated_pdu_length = EXTRACT_32BITS(pdu->encapsulated_pdu_length);
+	    ND_TCHECK2(*tptr, encapsulated_pdu_length);
 	    tlen = pdu_len;
 
 	    error_code = EXTRACT_16BITS(pdu->pdu_header.u.error_code);
-	    printf("%sError code: %s (%u), Encapsulated PDU length: %u",
+	    ND_PRINT((ndo, "%sError code: %s (%u), Encapsulated PDU length: %u",
 		   indent_string(indent+2),
 		   tok2str(rpki_rtr_error_codes, "Unknown", error_code),
-		   error_code, encapsulated_pdu_length);
+		   error_code, encapsulated_pdu_length));
 
 	    tptr += sizeof(*pdu);
 	    tlen -= sizeof(*pdu);
@@ -276,8 +271,8 @@
 	     */
 	    if (encapsulated_pdu_length &&
 		(encapsulated_pdu_length <= tlen)) {
-		printf("%s-----encapsulated PDU-----", indent_string(indent+4));
-		rpki_rtr_pdu_print(tptr, indent+2);
+		ND_PRINT((ndo, "%s-----encapsulated PDU-----", indent_string(indent+4)));
+		rpki_rtr_pdu_print(ndo, tptr, indent+2);
 	    }
 
 	    tptr += encapsulated_pdu_length;
@@ -285,17 +280,17 @@
 
 	    /*
 	     * Extract, trail-zero and print the Error message.
-	     */ 
+	     */
 	    text_length = 0;
 	    if (tlen > 4) {
 		text_length = EXTRACT_32BITS(tptr);
 		tptr += 4;
 		tlen -= 4;
 	    }
+	    ND_TCHECK2(*tptr, text_length);
 	    if (text_length && (text_length <= tlen )) {
-		memcpy(buf, tptr, MIN(sizeof(buf)-1, text_length));
-		buf[text_length] = '\0';
-		printf("%sError text: %s", indent_string(indent+2), buf);
+		ND_PRINT((ndo, "%sError text: ", indent_string(indent+2)));
+		fn_printn(ndo, tptr, text_length, ndo->ndo_snapend);
 	    }
 	}
 	break;
@@ -304,19 +299,24 @@
 
 	/*
 	 * Unknown data, please hexdump.
-	 */ 
+	 */
 	hexdump = TRUE;
     }
 
     /* do we also want to see a hex dump ? */
-    if (vflag > 1 || (vflag && hexdump)) {
-	print_unknown_data(tptr,"\n\t  ", pdu_len);
+    if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+	print_unknown_data(ndo,tptr,"\n\t  ", pdu_len);
     }
+    return;
+
+ trunc:
+    ND_PRINT((ndo, "|trunc"));
+    return;
 }
 
 void
-rpki_rtr_print(register const u_char *pptr, register u_int len) {
-
+rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
+{
     u_int tlen, pdu_type, pdu_len;
     const u_char *tptr;
     const rpki_rtr_pdu *pdu_header;
@@ -324,25 +324,25 @@
     tptr = pptr;
     tlen = len;
 
-    if (!vflag) {
-	printf(", RPKI-RTR");
+    if (!ndo->ndo_vflag) {
+	ND_PRINT((ndo, ", RPKI-RTR"));
 	return;
     }
 
     while (tlen >= sizeof(rpki_rtr_pdu)) {
 
-        TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
+        ND_TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
 
 	pdu_header = (rpki_rtr_pdu *)tptr;
         pdu_type = pdu_header->pdu_type;
         pdu_len = EXTRACT_32BITS(pdu_header->length);
+        ND_TCHECK2(*tptr, pdu_len);
 
         /* infinite loop check */
         if (!pdu_type || !pdu_len) {
             break;
         }
 
-        TCHECK2(*tptr, pdu_len);
         if (tlen < pdu_len) {
             goto trunc;
         }
@@ -350,14 +350,14 @@
 	/*
 	 * Print the PDU.
 	 */
-	rpki_rtr_pdu_print(tptr, 8);
+	rpki_rtr_pdu_print(ndo, tptr, 8);
 
         tlen -= pdu_len;
         tptr += pdu_len;
     }
     return;
  trunc:
-    printf("\n\t[|RPKI-RTR]");
+    ND_PRINT((ndo, "\n\t[|RPKI-RTR]"));
 }
 
 /*
diff --git a/print-rrcp.c b/print-rrcp.c
index c5b1fdd..2370d9c 100644
--- a/print-rrcp.c
+++ b/print-rrcp.c
@@ -21,29 +21,18 @@
  * and Realtek Echo Protocol (RRCP-REP) packets.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rrcp.c,v 1.2 2008-04-11 17:21:34 gianluca Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
+#include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 #include "ether.h"
 
-#ifndef ETH_ALEN 
-#define ETH_ALEN 6
-#endif
-
 #define RRCP_OPCODE_MASK	0x7F	/* 0x00 = hello, 0x01 = get, 0x02 = set */
 #define RRCP_ISREPLY		0x80	/* 0 = request to switch, 0x80 = reply from switch */
 
@@ -86,8 +75,8 @@
 	  u_int length _U_)
 {
 	const u_char *rrcp;
-	u_int8_t rrcp_proto;
-	u_int8_t rrcp_opcode;
+	uint8_t rrcp_proto;
+	uint8_t rrcp_opcode;
 	register const struct ether_header *ep;
 	char proto_str[16];
 	char opcode_str[32];
@@ -100,8 +89,8 @@
 	ND_TCHECK(*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET));
 	rrcp_opcode = (*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK;
         ND_PRINT((ndo, "%s > %s, %s %s",
-		etheraddr_string(ESRC(ep)),
-		etheraddr_string(EDST(ep)),
+		etheraddr_string(ndo, ESRC(ep)),
+		etheraddr_string(ndo, EDST(ep)),
 		tok2strbuf(proto_values,"RRCP-0x%02x",rrcp_proto,proto_str,sizeof(proto_str)),
 		((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
 	if (rrcp_proto==1){
@@ -125,7 +114,7 @@
 	    ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
 		     *(rrcp + RRCP_DOWNLINK_PORT_OFFSET),
 		     *(rrcp + RRCP_UPLINK_PORT_OFFSET),
-		     etheraddr_string(rrcp + RRCP_UPLINK_MAC_OFFSET),
+		     etheraddr_string(ndo, rrcp + RRCP_UPLINK_MAC_OFFSET),
 		     EXTRACT_32BITS(rrcp + RRCP_VENDOR_ID_OFFSET),
 		     EXTRACT_16BITS(rrcp + RRCP_CHIP_ID_OFFSET)));
 	}else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){
@@ -134,8 +123,6 @@
 		    EXTRACT_32BITS(rrcp + RRCP_COOKIE2_OFFSET),
 		    EXTRACT_32BITS(rrcp + RRCP_COOKIE1_OFFSET)));
 	}
-        if (!ndo->ndo_vflag)
-            return;
 	return;
 
 trunc:
diff --git a/print-rsvp.c b/print-rsvp.c
index 2d54a3e..263ef3d 100644
--- a/print-rsvp.c
+++ b/print-rsvp.c
@@ -15,21 +15,13 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.50 2008-08-16 11:36:20 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -51,18 +43,18 @@
  */
 
 struct rsvp_common_header {
-    u_int8_t version_flags;
-    u_int8_t msg_type;
-    u_int8_t checksum[2];
-    u_int8_t ttl;
-    u_int8_t reserved;
-    u_int8_t length[2];
+    uint8_t version_flags;
+    uint8_t msg_type;
+    uint8_t checksum[2];
+    uint8_t ttl;
+    uint8_t reserved;
+    uint8_t length[2];
 };
 
-/* 
+/*
  * RFC2205 object header
  *
- * 
+ *
  *               0             1              2             3
  *        +-------------+-------------+-------------+-------------+
  *        |       Length (bytes)      |  Class-Num  |   C-Type    |
@@ -74,13 +66,13 @@
  */
 
 struct rsvp_object_header {
-    u_int8_t length[2];
-    u_int8_t class_num;
-    u_int8_t ctype;
+    uint8_t length[2];
+    uint8_t class_num;
+    uint8_t ctype;
 };
 
 #define RSVP_VERSION            1
-#define	RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) 
+#define	RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
 #define	RSVP_EXTRACT_FLAGS(x)   ((x)&0x0f)
 
 #define	RSVP_MSGTYPE_PATH       1
@@ -121,7 +113,7 @@
 #define	RSVP_OBJ_RSVP_HOP           3   /* rfc2205, rfc3473 */
 #define	RSVP_OBJ_INTEGRITY          4   /* rfc2747 */
 #define	RSVP_OBJ_TIME_VALUES        5   /* rfc2205 */
-#define	RSVP_OBJ_ERROR_SPEC         6 
+#define	RSVP_OBJ_ERROR_SPEC         6
 #define	RSVP_OBJ_SCOPE              7
 #define	RSVP_OBJ_STYLE              8   /* rfc2205 */
 #define	RSVP_OBJ_FLOWSPEC           9   /* rfc2215 */
@@ -300,11 +292,11 @@
 };
 
 struct rsvp_obj_integrity_t {
-    u_int8_t flags;
-    u_int8_t res;
-    u_int8_t key_id[6];
-    u_int8_t sequence[8];
-    u_int8_t digest[16];
+    uint8_t flags;
+    uint8_t res;
+    uint8_t key_id[6];
+    uint8_t sequence[8];
+    uint8_t digest[16];
 };
 
 static const struct tok rsvp_obj_integrity_flag_values[] = {
@@ -313,14 +305,14 @@
 };
 
 struct rsvp_obj_frr_t {
-    u_int8_t setup_prio;
-    u_int8_t hold_prio;
-    u_int8_t hop_limit;
-    u_int8_t flags;
-    u_int8_t bandwidth[4];
-    u_int8_t include_any[4];
-    u_int8_t exclude_any[4];
-    u_int8_t include_all[4];
+    uint8_t setup_prio;
+    uint8_t hold_prio;
+    uint8_t hop_limit;
+    uint8_t flags;
+    uint8_t bandwidth[4];
+    uint8_t include_any[4];
+    uint8_t exclude_any[4];
+    uint8_t include_all[4];
 };
 
 
@@ -442,7 +434,7 @@
     { 4,                      "CT/setup priority do not form a configured TE-Class" },
     { 5,                      "CT/holding priority do not form a configured TE-Class" },
     { 6,                      "CT/setup priority and CT/holding priority do not form a configured TE-Class" },
-    { 7,                      "Inconsistency between signaled PSC and signaled CT" }, 
+    { 7,                      "Inconsistency between signaled PSC and signaled CT" },
     { 8,                      "Inconsistency between signaled PHBs and signaled CT" },
    { 0, NULL}
 };
@@ -486,21 +478,20 @@
     { 0, NULL}
 };
 
-static int rsvp_intserv_print(const u_char *, u_short);
-
-/* 
+/*
  * this is a dissector for all the intserv defined
  * specs as defined per rfc2215
  * it is called from various rsvp objects;
  * returns the amount of bytes being processed
  */
 static int
-rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
-
+rsvp_intserv_print(netdissect_options *ndo,
+                   const u_char *tptr, u_short obj_tlen)
+{
     int parameter_id,parameter_length;
     union {
 	float f;
-	u_int32_t i;
+	uint32_t i;
     } bw;
 
     if (obj_tlen < 4)
@@ -508,11 +499,11 @@
     parameter_id = *(tptr);
     parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */
 
-    printf("\n\t      Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
+    ND_PRINT((ndo, "\n\t      Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
            tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),
            parameter_id,
            parameter_length,
-           *(tptr+1));
+           *(tptr + 1)));
 
     if (obj_tlen < parameter_length+4)
         return 0;
@@ -527,7 +518,7 @@
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4)
-            printf("\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr+4));
+            ND_PRINT((ndo, "\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr + 4)));
         break;
 
     case 6:
@@ -540,7 +531,7 @@
         */
         if (parameter_length == 4) {
             bw.i = EXTRACT_32BITS(tptr+4);
-            printf("\n\t\tPath b/w estimate: %.10g Mbps", bw.f/125000);
+            ND_PRINT((ndo, "\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000));
         }
         break;
 
@@ -553,11 +544,11 @@
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4) {
-            printf("\n\t\tMinimum path latency: ");
+            ND_PRINT((ndo, "\n\t\tMinimum path latency: "));
             if (EXTRACT_32BITS(tptr+4) == 0xffffffff)
-                printf("don't care");
+                ND_PRINT((ndo, "don't care"));
             else
-                printf("%u", EXTRACT_32BITS(tptr+4));
+                ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr + 4)));
         }
         break;
 
@@ -571,10 +562,10 @@
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         */
         if (parameter_length == 4)
-            printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4));
+            ND_PRINT((ndo, "\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr + 4)));
         break;
     case 127:
-       /* 
+       /*
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         * |   127 (e)     |    0 (f)      |             5 (g)             |
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -592,18 +583,18 @@
 
         if (parameter_length == 20) {
             bw.i = EXTRACT_32BITS(tptr+4);
-            printf("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f/125000);
+            ND_PRINT((ndo, "\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000));
             bw.i = EXTRACT_32BITS(tptr+8);
-            printf("\n\t\tToken Bucket Size: %.10g bytes", bw.f);
+            ND_PRINT((ndo, "\n\t\tToken Bucket Size: %.10g bytes", bw.f));
             bw.i = EXTRACT_32BITS(tptr+12);
-            printf("\n\t\tPeak Data Rate: %.10g Mbps", bw.f/125000);
-            printf("\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr+16));
-            printf("\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr+20));
+            ND_PRINT((ndo, "\n\t\tPeak Data Rate: %.10g Mbps", bw.f / 125000));
+            ND_PRINT((ndo, "\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr + 16)));
+            ND_PRINT((ndo, "\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr + 20)));
         }
         break;
 
     case 130:
-       /* 
+       /*
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         * |     130 (h)   |    0 (i)      |            2 (j)              |
         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -615,8 +606,8 @@
 
         if (parameter_length == 8) {
             bw.i = EXTRACT_32BITS(tptr+4);
-            printf("\n\t\tRate: %.10g Mbps", bw.f/125000);
-            printf("\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr+8));
+            ND_PRINT((ndo, "\n\t\tRate: %.10g Mbps", bw.f / 125000));
+            ND_PRINT((ndo, "\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr + 8)));
         }
         break;
 
@@ -625,18 +616,19 @@
     case 135:
     case 136:
         if (parameter_length == 4)
-            printf("\n\t\tValue: %u", EXTRACT_32BITS(tptr+4));
+            ND_PRINT((ndo, "\n\t\tValue: %u", EXTRACT_32BITS(tptr + 4)));
         break;
 
     default:
-        if (vflag <= 1)
-            print_unknown_data(tptr+4,"\n\t\t",parameter_length);
+        if (ndo->ndo_vflag <= 1)
+            print_unknown_data(ndo, tptr + 4, "\n\t\t", parameter_length);
     }
     return (parameter_length+4); /* header length 4 bytes */
 }
 
 static int
-rsvp_obj_print (const u_char *pptr
+rsvp_obj_print(netdissect_options *ndo,
+                const u_char *pptr
 #ifndef HAVE_LIBCRYPTO
 _U_
 #endif
@@ -645,8 +637,8 @@
 _U_
 #endif
 , const u_char *tptr,
-                const char *ident, u_int tlen) {
-
+                const char *ident, u_int tlen)
+{
     const struct rsvp_object_header *rsvp_obj_header;
     const u_char *obj_tptr;
     union {
@@ -658,52 +650,51 @@
     int hexdump,processed,padbytes,error_code,error_value,i,sigcheck;
     union {
 	float f;
-	u_int32_t i;
+	uint32_t i;
     } bw;
-    u_int8_t namelen;
+    uint8_t namelen;
 
     u_int action, subchannel;
 
     while(tlen>=sizeof(struct rsvp_object_header)) {
         /* did we capture enough for fully decoding the object header ? */
-        if (!TTEST2(*tptr, sizeof(struct rsvp_object_header)))
-            goto trunc;
+        ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header));
 
         rsvp_obj_header = (const struct rsvp_object_header *)tptr;
         rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length);
         rsvp_obj_ctype=rsvp_obj_header->ctype;
 
         if(rsvp_obj_len % 4) {
-            printf("%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len);
+            ND_PRINT((ndo, "%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len));
             return -1;
         }
         if(rsvp_obj_len < sizeof(struct rsvp_object_header)) {
-            printf("%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
-                   (unsigned long)sizeof(const struct rsvp_object_header));
+            ND_PRINT((ndo, "%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
+                   (unsigned long)sizeof(const struct rsvp_object_header)));
             return -1;
         }
 
-        printf("%s%s Object (%u) Flags: [%s",
+        ND_PRINT((ndo, "%s%s Object (%u) Flags: [%s",
                ident,
                tok2str(rsvp_obj_values,
                        "Unknown",
                        rsvp_obj_header->class_num),
                rsvp_obj_header->class_num,
-               ((rsvp_obj_header->class_num)&0x80) ? "ignore" : "reject");
+               ((rsvp_obj_header->class_num) & 0x80) ? "ignore" : "reject"));
 
         if (rsvp_obj_header->class_num > 128)
-            printf(" %s",
-                   ((rsvp_obj_header->class_num)&0x40) ? "and forward" : "silently");
+            ND_PRINT((ndo, " %s",
+                   ((rsvp_obj_header->class_num) & 0x40) ? "and forward" : "silently"));
 
-        printf(" if unknown], Class-Type: %s (%u), length: %u",
+        ND_PRINT((ndo, " if unknown], Class-Type: %s (%u), length: %u",
                tok2str(rsvp_ctype_values,
                        "Unknown",
                        ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype),
                rsvp_obj_ctype,
-               rsvp_obj_len);
-    
+               rsvp_obj_len));
+
         if(tlen < rsvp_obj_len) {
-            printf("%sERROR: object goes past end of objects TLV", ident);
+            ND_PRINT((ndo, "%sERROR: object goes past end of objects TLV", ident));
             return -1;
         }
 
@@ -711,7 +702,7 @@
         obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header);
 
         /* did we capture enough for fully decoding the object ? */
-        if (!TTEST2(*tptr, rsvp_obj_len))
+        if (!ND_TTEST2(*tptr, rsvp_obj_len))
             return -1;
         hexdump=FALSE;
 
@@ -721,79 +712,79 @@
             case RSVP_CTYPE_IPV4:
                 if (obj_tlen < 8)
                     return -1;
-                printf("%s  IPv4 DestAddress: %s, Protocol ID: 0x%02x",
+                ND_PRINT((ndo, "%s  IPv4 DestAddress: %s, Protocol ID: 0x%02x",
                        ident,
-                       ipaddr_string(obj_tptr),
-                       *(obj_tptr+sizeof(struct in_addr)));
-                printf("%s  Flags: [0x%02x], DestPort %u",
+                       ipaddr_string(ndo, obj_tptr),
+                       *(obj_tptr + sizeof(struct in_addr))));
+                ND_PRINT((ndo, "%s  Flags: [0x%02x], DestPort %u",
                        ident,
                        *(obj_tptr+5),
-                       EXTRACT_16BITS(obj_tptr+6));
+                       EXTRACT_16BITS(obj_tptr + 6)));
                 obj_tlen-=8;
-                obj_tptr+=8;                
+                obj_tptr+=8;
                 break;
 #ifdef INET6
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 20)
                     return -1;
-                printf("%s  IPv6 DestAddress: %s, Protocol ID: 0x%02x",
+                ND_PRINT((ndo, "%s  IPv6 DestAddress: %s, Protocol ID: 0x%02x",
                        ident,
-                       ip6addr_string(obj_tptr),
-                       *(obj_tptr+sizeof(struct in6_addr)));
-                printf("%s  Flags: [0x%02x], DestPort %u",
+                       ip6addr_string(ndo, obj_tptr),
+                       *(obj_tptr + sizeof(struct in6_addr))));
+                ND_PRINT((ndo, "%s  Flags: [0x%02x], DestPort %u",
                        ident,
                        *(obj_tptr+sizeof(struct in6_addr)+1),
-                       EXTRACT_16BITS(obj_tptr+sizeof(struct in6_addr)+2));
+                       EXTRACT_16BITS(obj_tptr + sizeof(struct in6_addr) + 2)));
                 obj_tlen-=20;
-                obj_tptr+=20;                
+                obj_tptr+=20;
                 break;
 
             case RSVP_CTYPE_TUNNEL_IPV6:
                 if (obj_tlen < 36)
                     return -1;
-                printf("%s  IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+                ND_PRINT((ndo, "%s  IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
                        ident,
-                       ip6addr_string(obj_tptr),
+                       ip6addr_string(ndo, obj_tptr),
                        EXTRACT_16BITS(obj_tptr+18),
-                       ip6addr_string(obj_tptr+20));
+                       ip6addr_string(ndo, obj_tptr + 20)));
                 obj_tlen-=36;
-                obj_tptr+=36;                
+                obj_tptr+=36;
                 break;
 
             case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */
                 if (obj_tlen < 26)
                     return -1;
-                printf("%s  IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+                ND_PRINT((ndo, "%s  IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
                        ident,
                        EXTRACT_32BITS(obj_tptr),
                        EXTRACT_16BITS(obj_tptr+6),
-                       ip6addr_string(obj_tptr+8));
+                       ip6addr_string(ndo, obj_tptr + 8)));
                 obj_tlen-=26;
-                obj_tptr+=26;                
+                obj_tptr+=26;
                 break;
 #endif
             case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
                 if (obj_tlen < 12)
                     return -1;
-                printf("%s  IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+                ND_PRINT((ndo, "%s  IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
                        ident,
-                       ipaddr_string(obj_tptr),
+                       ipaddr_string(ndo, obj_tptr),
                        EXTRACT_16BITS(obj_tptr+6),
-                       ipaddr_string(obj_tptr+8));
+                       ipaddr_string(ndo, obj_tptr + 8)));
                 obj_tlen-=12;
-                obj_tptr+=12;                
+                obj_tptr+=12;
                 break;
             case RSVP_CTYPE_TUNNEL_IPV4:
             case RSVP_CTYPE_UNI_IPV4:
                 if (obj_tlen < 12)
                     return -1;
-                printf("%s  IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+                ND_PRINT((ndo, "%s  IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
                        ident,
-                       ipaddr_string(obj_tptr),
+                       ipaddr_string(ndo, obj_tptr),
                        EXTRACT_16BITS(obj_tptr+6),
-                       ipaddr_string(obj_tptr+8));
+                       ipaddr_string(ndo, obj_tptr + 8)));
                 obj_tlen-=12;
-                obj_tptr+=12;                
+                obj_tptr+=12;
                 break;
             default:
                 hexdump=TRUE;
@@ -805,21 +796,21 @@
             case RSVP_CTYPE_IPV4:
                 if (obj_tlen < sizeof(struct in_addr))
                     return -1;
-                printf("%s  IPv4 Receiver Address: %s",
+                ND_PRINT((ndo, "%s  IPv4 Receiver Address: %s",
                        ident,
-                       ipaddr_string(obj_tptr));
+                       ipaddr_string(ndo, obj_tptr)));
                 obj_tlen-=sizeof(struct in_addr);
-                obj_tptr+=sizeof(struct in_addr);                
+                obj_tptr+=sizeof(struct in_addr);
                 break;
 #ifdef INET6
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < sizeof(struct in6_addr))
                     return -1;
-                printf("%s  IPv6 Receiver Address: %s",
+                ND_PRINT((ndo, "%s  IPv6 Receiver Address: %s",
                        ident,
-                       ip6addr_string(obj_tptr));
+                       ip6addr_string(ndo, obj_tptr)));
                 obj_tlen-=sizeof(struct in6_addr);
-                obj_tptr+=sizeof(struct in6_addr);                
+                obj_tptr+=sizeof(struct in6_addr);
                 break;
 #endif
             default:
@@ -832,21 +823,21 @@
             case RSVP_CTYPE_IPV4:
                 if (obj_tlen < sizeof(struct in_addr))
                     return -1;
-                printf("%s  IPv4 Notify Node Address: %s",
+                ND_PRINT((ndo, "%s  IPv4 Notify Node Address: %s",
                        ident,
-                       ipaddr_string(obj_tptr));
+                       ipaddr_string(ndo, obj_tptr)));
                 obj_tlen-=sizeof(struct in_addr);
-                obj_tptr+=sizeof(struct in_addr);                
+                obj_tptr+=sizeof(struct in_addr);
                 break;
 #ifdef INET6
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < sizeof(struct in6_addr))
                     return-1;
-                printf("%s  IPv6 Notify Node Address: %s",
+                ND_PRINT((ndo, "%s  IPv6 Notify Node Address: %s",
                        ident,
-                       ip6addr_string(obj_tptr));
+                       ip6addr_string(ndo, obj_tptr)));
                 obj_tlen-=sizeof(struct in6_addr);
-                obj_tptr+=sizeof(struct in6_addr);                
+                obj_tptr+=sizeof(struct in6_addr);
                 break;
 #endif
             default:
@@ -861,7 +852,7 @@
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_1:
                 while(obj_tlen >= 4 ) {
-                    printf("%s  Label: %u", ident, EXTRACT_32BITS(obj_tptr));
+                    ND_PRINT((ndo, "%s  Label: %u", ident, EXTRACT_32BITS(obj_tptr)));
                     obj_tlen-=4;
                     obj_tptr+=4;
                 }
@@ -869,21 +860,21 @@
             case RSVP_CTYPE_2:
                 if (obj_tlen < 4)
                     return-1;
-                printf("%s  Generalized Label: %u",
+                ND_PRINT((ndo, "%s  Generalized Label: %u",
                        ident,
-                       EXTRACT_32BITS(obj_tptr));
+                       EXTRACT_32BITS(obj_tptr)));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
             case RSVP_CTYPE_3:
                 if (obj_tlen < 12)
                     return-1;
-                printf("%s  Waveband ID: %u%s  Start Label: %u, Stop Label: %u",
+                ND_PRINT((ndo, "%s  Waveband ID: %u%s  Start Label: %u, Stop Label: %u",
                        ident,
                        EXTRACT_32BITS(obj_tptr),
                        ident,
                        EXTRACT_32BITS(obj_tptr+4),
-                       EXTRACT_32BITS(obj_tptr+8));
+                       EXTRACT_32BITS(obj_tptr + 8)));
                 obj_tlen-=12;
                 obj_tptr+=12;
                 break;
@@ -897,12 +888,12 @@
             case RSVP_CTYPE_1:
                 if (obj_tlen < 4)
                     return-1;
-                printf("%s  Reservation Style: %s, Flags: [0x%02x]",
+                ND_PRINT((ndo, "%s  Reservation Style: %s, Flags: [0x%02x]",
                        ident,
                        tok2str(rsvp_resstyle_values,
                                "Unknown",
                                EXTRACT_24BITS(obj_tptr+1)),
-                       *(obj_tptr));
+                       *(obj_tptr)));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
@@ -916,10 +907,10 @@
             case RSVP_CTYPE_IPV4:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  Source Address: %s, Source Port: %u",
+                ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
                        ident,
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+6));
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_16BITS(obj_tptr + 6)));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
@@ -927,24 +918,24 @@
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 20)
                     return-1;
-                printf("%s  Source Address: %s, Source Port: %u",
+                ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
                        ident,
-                       ip6addr_string(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+18));
+                       ip6addr_string(ndo, obj_tptr),
+                       EXTRACT_16BITS(obj_tptr + 18)));
                 obj_tlen-=20;
                 obj_tptr+=20;
                 break;
             case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
                 if (obj_tlen < 40)
                     return-1;
-                printf("%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+                ND_PRINT((ndo, "%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
                        ident,
-                       ip6addr_string(obj_tptr),
+                       ip6addr_string(ndo, obj_tptr),
                        EXTRACT_16BITS(obj_tptr+18),
                        ident,
-                       ip6addr_string(obj_tptr+20),
-                       EXTRACT_16BITS(obj_tptr+38));
+                       ip6addr_string(ndo, obj_tptr+20),
+                       EXTRACT_16BITS(obj_tptr + 38)));
                 obj_tlen-=40;
                 obj_tptr+=40;
                 break;
@@ -952,24 +943,24 @@
             case RSVP_CTYPE_TUNNEL_IPV4:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
+                ND_PRINT((ndo, "%s  IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
                        ident,
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+6));
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_16BITS(obj_tptr + 6)));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
             case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
                 if (obj_tlen < 16)
                     return-1;
-                printf("%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+                ND_PRINT((ndo, "%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
                        ident,
-                       ipaddr_string(obj_tptr),
+                       ipaddr_string(ndo, obj_tptr),
                        EXTRACT_16BITS(obj_tptr+6),
                        ident,
-                       ipaddr_string(obj_tptr+8),
-                       EXTRACT_16BITS(obj_tptr+12));
+                       ipaddr_string(ndo, obj_tptr+8),
+                       EXTRACT_16BITS(obj_tptr + 12)));
                 obj_tlen-=16;
                 obj_tptr+=16;
                 break;
@@ -982,11 +973,11 @@
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_1:
                 while(obj_tlen >= 4 ) {
-                    printf("%s  L3 Protocol ID: %s",
+                    ND_PRINT((ndo, "%s  L3 Protocol ID: %s",
                            ident,
                            tok2str(ethertype_values,
                                    "Unknown Protocol (0x%04x)",
-                                   EXTRACT_16BITS(obj_tptr+2)));
+                                   EXTRACT_16BITS(obj_tptr + 2))));
                     obj_tlen-=4;
                     obj_tptr+=4;
                 }
@@ -994,50 +985,50 @@
             case RSVP_CTYPE_2:
                 if (obj_tlen < 12)
                     return-1;
-                printf("%s  L3 Protocol ID: %s",
+                ND_PRINT((ndo, "%s  L3 Protocol ID: %s",
                        ident,
                        tok2str(ethertype_values,
                                "Unknown Protocol (0x%04x)",
-                               EXTRACT_16BITS(obj_tptr+2)));
-                printf(",%s merge capability",((*(obj_tptr+4))&0x80) ? "no" : "" );
-                printf("%s  Minimum VPI/VCI: %u/%u",
+                               EXTRACT_16BITS(obj_tptr + 2))));
+                ND_PRINT((ndo, ",%s merge capability",((*(obj_tptr + 4)) & 0x80) ? "no" : "" ));
+                ND_PRINT((ndo, "%s  Minimum VPI/VCI: %u/%u",
                        ident,
                        (EXTRACT_16BITS(obj_tptr+4))&0xfff,
-                       (EXTRACT_16BITS(obj_tptr+6))&0xfff);
-                printf("%s  Maximum VPI/VCI: %u/%u",
+                       (EXTRACT_16BITS(obj_tptr + 6)) & 0xfff));
+                ND_PRINT((ndo, "%s  Maximum VPI/VCI: %u/%u",
                        ident,
                        (EXTRACT_16BITS(obj_tptr+8))&0xfff,
-                       (EXTRACT_16BITS(obj_tptr+10))&0xfff);
+                       (EXTRACT_16BITS(obj_tptr + 10)) & 0xfff));
                 obj_tlen-=12;
                 obj_tptr+=12;
                 break;
             case RSVP_CTYPE_3:
                 if (obj_tlen < 12)
                     return-1;
-                printf("%s  L3 Protocol ID: %s",
+                ND_PRINT((ndo, "%s  L3 Protocol ID: %s",
                        ident,
                        tok2str(ethertype_values,
                                "Unknown Protocol (0x%04x)",
-                               EXTRACT_16BITS(obj_tptr+2)));
-                printf("%s  Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
+                               EXTRACT_16BITS(obj_tptr + 2))));
+                ND_PRINT((ndo, "%s  Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
                        ident,
                        (EXTRACT_32BITS(obj_tptr+4))&0x7fffff,
                        (EXTRACT_32BITS(obj_tptr+8))&0x7fffff,
                        (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "",
-                       (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 2 ) ? "23" : "");
+                       (((EXTRACT_16BITS(obj_tptr + 4) >> 7) & 3) == 2 ) ? "23" : ""));
                 obj_tlen-=12;
                 obj_tptr+=12;
                 break;
             case RSVP_CTYPE_4:
                 if (obj_tlen < 4)
                     return-1;
-                printf("%s  LSP Encoding Type: %s (%u)",
+                ND_PRINT((ndo, "%s  LSP Encoding Type: %s (%u)",
                        ident,
                        tok2str(gmpls_encoding_values,
                                "Unknown",
                                *obj_tptr),
-		       *obj_tptr);
-                printf("%s  Switching Type: %s (%u), Payload ID: %s (0x%04x)",
+		       *obj_tptr));
+                ND_PRINT((ndo, "%s  Switching Type: %s (%u), Payload ID: %s (0x%04x)",
                        ident,
                        tok2str(gmpls_switch_cap_values,
                                "Unknown",
@@ -1046,7 +1037,7 @@
                        tok2str(gmpls_payload_values,
                                "Unknown",
                                EXTRACT_16BITS(obj_tptr+2)),
-		       EXTRACT_16BITS(obj_tptr+2));
+		       EXTRACT_16BITS(obj_tptr + 2)));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
@@ -1060,30 +1051,30 @@
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_IPV4:
                 while(obj_tlen >= 4 ) {
-                    printf("%s  Subobject Type: %s, length %u",
+                    ND_PRINT((ndo, "%s  Subobject Type: %s, length %u",
                            ident,
                            tok2str(rsvp_obj_xro_values,
                                    "Unknown %u",
                                    RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
-                           *(obj_tptr+1));                
+                           *(obj_tptr + 1)));
 
                     if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
-                        printf("%s  ERROR: zero length ERO subtype",ident);
+                        ND_PRINT((ndo, "%s  ERROR: zero length ERO subtype", ident));
                         break;
                     }
 
                     switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
                     case RSVP_OBJ_XRO_IPV4:
-                        printf(", %s, %s/%u, Flags: [%s]",
+                        ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]",
                                RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict",
-                               ipaddr_string(obj_tptr+2),
+                               ipaddr_string(ndo, obj_tptr+2),
                                *(obj_tptr+6),
                                bittok2str(rsvp_obj_rro_flag_values,
                                    "none",
-                                   *(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */
+                                   *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */
                     break;
                     case RSVP_OBJ_XRO_LABEL:
-                        printf(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
+                        ND_PRINT((ndo, ", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
                                bittok2str(rsvp_obj_rro_label_flag_values,
                                    "none",
                                    *(obj_tptr+2)),
@@ -1092,7 +1083,7 @@
                                        "Unknown",
                                        *(obj_tptr+3) + 256*RSVP_OBJ_RRO),
                                *(obj_tptr+3),
-                               EXTRACT_32BITS(obj_tptr+4));
+                               EXTRACT_32BITS(obj_tptr + 4)));
                     }
                     obj_tlen-=*(obj_tptr+1);
                     obj_tptr+=*(obj_tptr+1);
@@ -1109,10 +1100,10 @@
             case RSVP_CTYPE_2:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  Source Instance: 0x%08x, Destination Instance: 0x%08x",
+                ND_PRINT((ndo, "%s  Source Instance: 0x%08x, Destination Instance: 0x%08x",
                        ident,
                        EXTRACT_32BITS(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr+4));
+                       EXTRACT_32BITS(obj_tptr + 4)));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
@@ -1126,10 +1117,10 @@
             case RSVP_CTYPE_1:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  Restart  Time: %ums, Recovery Time: %ums",
+                ND_PRINT((ndo, "%s  Restart  Time: %ums, Recovery Time: %ums",
                        ident,
                        EXTRACT_32BITS(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr+4));
+                       EXTRACT_32BITS(obj_tptr + 4)));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
@@ -1146,17 +1137,17 @@
                 namelen = *(obj_tptr+3);
                 if (obj_tlen < 4+namelen)
                     return-1;
-                printf("%s  Session Name: ", ident);
+                ND_PRINT((ndo, "%s  Session Name: ", ident));
                 for (i = 0; i < namelen; i++)
-                    safeputchar(*(obj_tptr+4+i));
-                printf("%s  Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
+                    safeputchar(ndo, *(obj_tptr + 4 + i));
+                ND_PRINT((ndo, "%s  Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
                        ident,
                        (int)*obj_tptr,
                        (int)*(obj_tptr+1),
                        bittok2str(rsvp_session_attribute_flag_values,
                                   "none",
                                   *(obj_tptr+2)),
-                       *(obj_tptr+2));
+                       *(obj_tptr + 2)));
                 obj_tlen-=4+*(obj_tptr+3);
                 obj_tptr+=4+*(obj_tptr+3);
                 break;
@@ -1169,7 +1160,7 @@
             switch(rsvp_obj_ctype) {
 		int subobj_type,af,subobj_len,total_subobj_len;
 
-            case RSVP_CTYPE_1: 
+            case RSVP_CTYPE_1:
 
                 if (obj_tlen < 4)
                     return-1;
@@ -1181,12 +1172,12 @@
                     subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8;
                     af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF;
 
-                    printf("%s  Subobject Type: %s (%u), AF: %s (%u), length: %u",
+                    ND_PRINT((ndo, "%s  Subobject Type: %s (%u), AF: %s (%u), length: %u",
                            ident,
                            tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type),
                            subobj_type,
                            tok2str(af_values, "Unknown", af), af,
-                           subobj_len);
+                           subobj_len));
 
                     switch(subobj_type) {
                     case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
@@ -1196,15 +1187,15 @@
                         case AFNUM_INET:
                             if (subobj_len < 8)
                                 return -1;
-                            printf("%s    UNI IPv4 TNA address: %s",
-                                   ident, ipaddr_string(obj_tptr+4));
+                            ND_PRINT((ndo, "%s    UNI IPv4 TNA address: %s",
+                                   ident, ipaddr_string(ndo, obj_tptr + 4)));
                             break;
 #ifdef INET6
                         case AFNUM_INET6:
                             if (subobj_len < 20)
                                 return -1;
-                            printf("%s    UNI IPv6 TNA address: %s",
-                                   ident, ip6addr_string(obj_tptr+4));
+                            ND_PRINT((ndo, "%s    UNI IPv6 TNA address: %s",
+                                   ident, ip6addr_string(ndo, obj_tptr + 4)));
                             break;
 #endif
                         case AFNUM_NSAP:
@@ -1228,12 +1219,12 @@
                             return -1;
                         }
 
-                        printf("%s    U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
+                        ND_PRINT((ndo, "%s    U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
                                ident,
                                ((EXTRACT_32BITS(obj_tptr+4))>>31),
                                ((EXTRACT_32BITS(obj_tptr+4))&0xFF),
                                EXTRACT_32BITS(obj_tptr+8),
-                               EXTRACT_32BITS(obj_tptr+12));
+                               EXTRACT_32BITS(obj_tptr + 12)));
                         break;
 
                     case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL:
@@ -1241,8 +1232,8 @@
                             return -1;
                         }
 
-                        printf("%s    Service level: %u",
-                               ident, (EXTRACT_32BITS(obj_tptr+4))>>24);
+                        ND_PRINT((ndo, "%s    Service level: %u",
+                               ident, (EXTRACT_32BITS(obj_tptr + 4)) >> 24));
                         break;
 
                     default:
@@ -1271,10 +1262,10 @@
             case RSVP_CTYPE_IPV4:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
+                ND_PRINT((ndo, "%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
                        ident,
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr+4));
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_32BITS(obj_tptr + 4)));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 if (obj_tlen)
@@ -1285,10 +1276,10 @@
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 20)
                     return-1;
-                printf("%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
+                ND_PRINT((ndo, "%s  Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
                        ident,
-                       ip6addr_string(obj_tptr),
-                       EXTRACT_32BITS(obj_tptr+16));
+                       ip6addr_string(ndo, obj_tptr),
+                       EXTRACT_32BITS(obj_tptr + 16)));
                 obj_tlen-=20;
                 obj_tptr+=20;
                 hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
@@ -1304,9 +1295,9 @@
             case RSVP_CTYPE_1:
                 if (obj_tlen < 4)
                     return-1;
-                printf("%s  Refresh Period: %ums",
+                ND_PRINT((ndo, "%s  Refresh Period: %ums",
                        ident,
-                       EXTRACT_32BITS(obj_tptr));
+                       EXTRACT_32BITS(obj_tptr)));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
@@ -1323,27 +1314,27 @@
             case RSVP_CTYPE_2:
                 if (obj_tlen < 4)
                     return-1;
-                printf("%s  Msg-Version: %u, length: %u",
+                ND_PRINT((ndo, "%s  Msg-Version: %u, length: %u",
                        ident,
                        (*obj_tptr & 0xf0) >> 4,
-                       EXTRACT_16BITS(obj_tptr+2)<<2);
+                       EXTRACT_16BITS(obj_tptr + 2) << 2));
                 obj_tptr+=4; /* get to the start of the service header */
                 obj_tlen-=4;
 
                 while (obj_tlen >= 4) {
                     intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2;
-                    printf("%s  Service Type: %s (%u), break bit %s set, Service length: %u",
+                    ND_PRINT((ndo, "%s  Service Type: %s (%u), break bit %s set, Service length: %u",
                            ident,
                            tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)),
                            *(obj_tptr),
                            (*(obj_tptr+1)&0x80) ? "" : "not",
-                           intserv_serv_tlen);
-                    
+                           intserv_serv_tlen));
+
                     obj_tptr+=4; /* get to the start of the parameter list */
                     obj_tlen-=4;
 
                     while (intserv_serv_tlen>=4) {
-                        processed = rsvp_intserv_print(obj_tptr, obj_tlen);
+                        processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen);
                         if (processed == 0)
                             break;
                         obj_tlen-=processed;
@@ -1362,10 +1353,10 @@
             case RSVP_CTYPE_IPV4:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  Source Address: %s, Source Port: %u",
+                ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
                        ident,
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+6));
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_16BITS(obj_tptr + 6)));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
@@ -1373,44 +1364,44 @@
             case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 20)
                     return-1;
-                printf("%s  Source Address: %s, Source Port: %u",
+                ND_PRINT((ndo, "%s  Source Address: %s, Source Port: %u",
                        ident,
-                       ip6addr_string(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+18));
+                       ip6addr_string(ndo, obj_tptr),
+                       EXTRACT_16BITS(obj_tptr + 18)));
                 obj_tlen-=20;
                 obj_tptr+=20;
                 break;
             case RSVP_CTYPE_3:
                 if (obj_tlen < 20)
                     return-1;
-                printf("%s  Source Address: %s, Flow Label: %u",
+                ND_PRINT((ndo, "%s  Source Address: %s, Flow Label: %u",
                        ident,
-                       ip6addr_string(obj_tptr),
-                       EXTRACT_24BITS(obj_tptr+17));
+                       ip6addr_string(ndo, obj_tptr),
+                       EXTRACT_24BITS(obj_tptr + 17)));
                 obj_tlen-=20;
                 obj_tptr+=20;
                 break;
             case RSVP_CTYPE_TUNNEL_IPV6:
                 if (obj_tlen < 20)
                     return-1;
-                printf("%s  Source Address: %s, LSP-ID: 0x%04x",
+                ND_PRINT((ndo, "%s  Source Address: %s, LSP-ID: 0x%04x",
                        ident,
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+18));
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_16BITS(obj_tptr + 18)));
                 obj_tlen-=20;
                 obj_tptr+=20;
                 break;
             case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
                 if (obj_tlen < 40)
                     return-1;
-                printf("%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+                ND_PRINT((ndo, "%s  IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
                        ident,
-                       ip6addr_string(obj_tptr),
+                       ip6addr_string(ndo, obj_tptr),
                        EXTRACT_16BITS(obj_tptr+18),
                        ident,
-                       ip6addr_string(obj_tptr+20),
-                       EXTRACT_16BITS(obj_tptr+38));
+                       ip6addr_string(ndo, obj_tptr+20),
+                       EXTRACT_16BITS(obj_tptr + 38)));
                 obj_tlen-=40;
                 obj_tptr+=40;
                 break;
@@ -1418,24 +1409,24 @@
             case RSVP_CTYPE_TUNNEL_IPV4:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  Source Address: %s, LSP-ID: 0x%04x",
+                ND_PRINT((ndo, "%s  Source Address: %s, LSP-ID: 0x%04x",
                        ident,
-                       ipaddr_string(obj_tptr),
-                       EXTRACT_16BITS(obj_tptr+6));
+                       ipaddr_string(ndo, obj_tptr),
+                       EXTRACT_16BITS(obj_tptr + 6)));
                 obj_tlen-=8;
                 obj_tptr+=8;
                 break;
             case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
                 if (obj_tlen < 16)
                     return-1;
-                printf("%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+                ND_PRINT((ndo, "%s  IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
                        "%s  Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
                        ident,
-                       ipaddr_string(obj_tptr),
+                       ipaddr_string(ndo, obj_tptr),
                        EXTRACT_16BITS(obj_tptr+6),
                        ident,
-                       ipaddr_string(obj_tptr+8),
-                       EXTRACT_16BITS(obj_tptr+12));
+                       ipaddr_string(ndo, obj_tptr+8),
+                       EXTRACT_16BITS(obj_tptr + 12)));
                 obj_tlen-=16;
                 obj_tptr+=16;
                 break;
@@ -1453,17 +1444,17 @@
             case RSVP_CTYPE_1: /* new style */
                 if (obj_tlen < sizeof(struct rsvp_obj_frr_t))
                     return-1;
-                printf("%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
+                ND_PRINT((ndo, "%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
                        ident,
                        (int)obj_ptr.rsvp_obj_frr->setup_prio,
                        (int)obj_ptr.rsvp_obj_frr->hold_prio,
                        (int)obj_ptr.rsvp_obj_frr->hop_limit,
-                        bw.f*8/1000000);              
-                printf("%s  Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
+                        bw.f * 8 / 1000000));
+                ND_PRINT((ndo, "%s  Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
                        ident,
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any),
-                       EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all));
+                       EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all)));
                 obj_tlen-=sizeof(struct rsvp_obj_frr_t);
                 obj_tptr+=sizeof(struct rsvp_obj_frr_t);
                 break;
@@ -1471,16 +1462,16 @@
             case RSVP_CTYPE_TUNNEL_IPV4: /* old style */
                 if (obj_tlen < 16)
                     return-1;
-                printf("%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
+                ND_PRINT((ndo, "%s  Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
                        ident,
                        (int)obj_ptr.rsvp_obj_frr->setup_prio,
                        (int)obj_ptr.rsvp_obj_frr->hold_prio,
                        (int)obj_ptr.rsvp_obj_frr->hop_limit,
-                        bw.f*8/1000000);              
-                printf("%s  Include Colors: 0x%08x, Exclude Colors: 0x%08x",
+                        bw.f * 8 / 1000000));
+                ND_PRINT((ndo, "%s  Include Colors: 0x%08x, Exclude Colors: 0x%08x",
                        ident,
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
-                       EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any));
+                       EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any)));
                 obj_tlen-=16;
                 obj_tptr+=16;
                 break;
@@ -1494,10 +1485,10 @@
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_TUNNEL_IPV4:
                 while(obj_tlen >= 8) {
-                    printf("%s  PLR-ID: %s, Avoid-Node-ID: %s",
+                    ND_PRINT((ndo, "%s  PLR-ID: %s, Avoid-Node-ID: %s",
                            ident,
-                           ipaddr_string(obj_tptr),
-                           ipaddr_string(obj_tptr+4));              
+                           ipaddr_string(ndo, obj_tptr),
+                           ipaddr_string(ndo, obj_tptr + 4)));
                     obj_tlen-=8;
                     obj_tptr+=8;
                 }
@@ -1511,9 +1502,9 @@
         case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_1:
-                printf("%s  CT: %u",
+                ND_PRINT((ndo, "%s  CT: %u",
                        ident,
-                       EXTRACT_32BITS(obj_tptr)&0x7);              
+                       EXTRACT_32BITS(obj_tptr) & 0x7));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
@@ -1530,27 +1521,27 @@
                     return-1;
                 error_code=*(obj_tptr+5);
                 error_value=EXTRACT_16BITS(obj_tptr+6);
-                printf("%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
+                ND_PRINT((ndo, "%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
                        ident,
-                       ipaddr_string(obj_tptr),
+                       ipaddr_string(ndo, obj_tptr),
                        *(obj_tptr+4),
                        ident,
                        tok2str(rsvp_obj_error_code_values,"unknown",error_code),
-                       error_code);
+                       error_code));
                 switch (error_code) {
                 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
-                    printf(", Error Value: %s (%u)",
+                    ND_PRINT((ndo, ", Error Value: %s (%u)",
                            tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
-                           error_value);
+                           error_value));
                     break;
                 case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */
                 case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD:
-                    printf(", Error Value: %s (%u)",
+                    ND_PRINT((ndo, ", Error Value: %s (%u)",
                            tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value),
-                           error_value);
+                           error_value));
                     break;
                 default:
-                    printf(", Unknown Error Value (%u)", error_value);
+                    ND_PRINT((ndo, ", Unknown Error Value (%u)", error_value));
                     break;
                 }
                 obj_tlen-=8;
@@ -1563,19 +1554,19 @@
                     return-1;
                 error_code=*(obj_tptr+17);
                 error_value=EXTRACT_16BITS(obj_tptr+18);
-                printf("%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
+                ND_PRINT((ndo, "%s  Error Node Address: %s, Flags: [0x%02x]%s  Error Code: %s (%u)",
                        ident,
-                       ip6addr_string(obj_tptr),
+                       ip6addr_string(ndo, obj_tptr),
                        *(obj_tptr+16),
                        ident,
                        tok2str(rsvp_obj_error_code_values,"unknown",error_code),
-                       error_code);
+                       error_code));
 
                 switch (error_code) {
                 case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
-                    printf(", Error Value: %s (%u)",
+                    ND_PRINT((ndo, ", Error Value: %s (%u)",
                            tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
-			   error_value);
+			   error_value));
                     break;
                 default:
                     break;
@@ -1595,24 +1586,24 @@
                 if (obj_tlen < 4)
                     return-1;
                 padbytes = EXTRACT_16BITS(obj_tptr+2);
-                printf("%s  TLV count: %u, padding bytes: %u",
+                ND_PRINT((ndo, "%s  TLV count: %u, padding bytes: %u",
                        ident,
                        EXTRACT_16BITS(obj_tptr),
-                       padbytes);
+                       padbytes));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 /* loop through as long there is anything longer than the TLV header (2) */
                 while(obj_tlen >= 2 + padbytes) {
-                    printf("%s    %s TLV (0x%02x), length: %u", /* length includes header */
+                    ND_PRINT((ndo, "%s    %s TLV (0x%02x), length: %u", /* length includes header */
                            ident,
                            tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr),
                            *obj_tptr,
-                           *(obj_tptr+1));
+                           *(obj_tptr + 1)));
                     if (obj_tlen < *(obj_tptr+1))
                         return-1;
                     if (*(obj_tptr+1) < 2)
                         return -1;
-                    print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2);
+                    print_unknown_data(ndo, obj_tptr + 2, "\n\t\t", *(obj_tptr + 1) - 2);
                     obj_tlen-=*(obj_tptr+1);
                     obj_tptr+=*(obj_tptr+1);
                 }
@@ -1630,18 +1621,18 @@
             case RSVP_CTYPE_2:
                 if (obj_tlen < 8)
                     return-1;
-                printf("%s  Flags [0x%02x], epoch: %u",
+                ND_PRINT((ndo, "%s  Flags [0x%02x], epoch: %u",
                        ident,
                        *obj_tptr,
-                       EXTRACT_24BITS(obj_tptr+1));
+                       EXTRACT_24BITS(obj_tptr + 1)));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 /* loop through as long there are no messages left */
                 while(obj_tlen >= 4) {
-                    printf("%s    Message-ID 0x%08x (%u)",
+                    ND_PRINT((ndo, "%s    Message-ID 0x%08x (%u)",
                            ident,
                            EXTRACT_32BITS(obj_tptr),
-                           EXTRACT_32BITS(obj_tptr));
+                           EXTRACT_32BITS(obj_tptr)));
                     obj_tlen-=4;
                     obj_tptr+=4;
                 }
@@ -1657,7 +1648,7 @@
                 if (obj_tlen < sizeof(struct rsvp_obj_integrity_t))
                     return-1;
                 obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr;
-                printf("%s  Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
+                ND_PRINT((ndo, "%s  Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
                        ident,
                        EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id),
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2),
@@ -1665,21 +1656,21 @@
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4),
                        bittok2str(rsvp_obj_integrity_flag_values,
                                   "none",
-                                  obj_ptr.rsvp_obj_integrity->flags));
-                printf("%s  MD5-sum 0x%08x%08x%08x%08x ",
+                                  obj_ptr.rsvp_obj_integrity->flags)));
+                ND_PRINT((ndo, "%s  MD5-sum 0x%08x%08x%08x%08x ",
                        ident,
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest),
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4),
                        EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8),
-                       EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+12));
+                       EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12)));
 
 #ifdef HAVE_LIBCRYPTO
-                sigcheck = signature_verify(pptr, plen, (unsigned char *)obj_ptr.\
+                sigcheck = signature_verify(ndo, pptr, plen, (unsigned char *)obj_ptr.\
                                              rsvp_obj_integrity->digest);
 #else
                 sigcheck = CANT_CHECK_SIGNATURE;
 #endif
-                printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+                ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
 
                 obj_tlen+=sizeof(struct rsvp_obj_integrity_t);
                 obj_tptr+=sizeof(struct rsvp_obj_integrity_t);
@@ -1687,16 +1678,16 @@
             default:
                 hexdump=TRUE;
             }
-            break;           
+            break;
 
         case RSVP_OBJ_ADMIN_STATUS:
             switch(rsvp_obj_ctype) {
-            case RSVP_CTYPE_1: 
+            case RSVP_CTYPE_1:
                 if (obj_tlen < 4)
                     return-1;
-                printf("%s  Flags [%s]", ident,
+                ND_PRINT((ndo, "%s  Flags [%s]", ident,
                        bittok2str(rsvp_obj_admin_status_flag_values, "none",
-                                  EXTRACT_32BITS(obj_tptr)));
+                                  EXTRACT_32BITS(obj_tptr))));
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
@@ -1707,14 +1698,14 @@
 
         case RSVP_OBJ_LABEL_SET:
             switch(rsvp_obj_ctype) {
-            case RSVP_CTYPE_1: 
+            case RSVP_CTYPE_1:
                 if (obj_tlen < 4)
                     return-1;
                 action = (EXTRACT_16BITS(obj_tptr)>>8);
 
-                printf("%s  Action: %s (%u), Label type: %u", ident,
+                ND_PRINT((ndo, "%s  Action: %s (%u), Label type: %u", ident,
                        tok2str(rsvp_obj_label_set_action_values, "Unknown", action),
-                       action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)));
+                       action, ((EXTRACT_32BITS(obj_tptr) & 0x7F))));
 
                 switch (action) {
                 case LABEL_SET_INCLUSIVE_RANGE:
@@ -1723,9 +1714,9 @@
 		    /* only a couple of subchannels are expected */
 		    if (obj_tlen < 12)
 			return -1;
-		    printf("%s  Start range: %u, End range: %u", ident,
+		    ND_PRINT((ndo, "%s  Start range: %u, End range: %u", ident,
                            EXTRACT_32BITS(obj_tptr+4),
-                           EXTRACT_32BITS(obj_tptr+8));
+                           EXTRACT_32BITS(obj_tptr + 8)));
 		    obj_tlen-=12;
 		    obj_tptr+=12;
                     break;
@@ -1735,8 +1726,8 @@
                     obj_tptr+=4;
                     subchannel = 1;
                     while(obj_tlen >= 4 ) {
-                        printf("%s  Subchannel #%u: %u", ident, subchannel,
-                               EXTRACT_32BITS(obj_tptr));
+                        ND_PRINT((ndo, "%s  Subchannel #%u: %u", ident, subchannel,
+                               EXTRACT_32BITS(obj_tptr)));
                         obj_tptr+=4;
                         obj_tlen-=4;
                         subchannel++;
@@ -1750,21 +1741,21 @@
 
         case RSVP_OBJ_S2L:
             switch (rsvp_obj_ctype) {
-            case RSVP_CTYPE_IPV4: 
+            case RSVP_CTYPE_IPV4:
                 if (obj_tlen < 4)
                     return-1;
-                printf("%s  Sub-LSP destination address: %s",
-                       ident, ipaddr_string(obj_tptr));
+                ND_PRINT((ndo, "%s  Sub-LSP destination address: %s",
+                       ident, ipaddr_string(ndo, obj_tptr)));
 
                 obj_tlen-=4;
                 obj_tptr+=4;
                 break;
 #ifdef INET6
-            case RSVP_CTYPE_IPV6: 
+            case RSVP_CTYPE_IPV6:
                 if (obj_tlen < 16)
                     return-1;
-                printf("%s  Sub-LSP destination address: %s",
-                       ident, ip6addr_string(obj_tptr));
+                ND_PRINT((ndo, "%s  Sub-LSP destination address: %s",
+                       ident, ip6addr_string(ndo, obj_tptr)));
 
                 obj_tlen-=16;
                 obj_tptr+=16;
@@ -1784,28 +1775,28 @@
         case RSVP_OBJ_ACCEPT_LABEL_SET:
         case RSVP_OBJ_PROTECTION:
         default:
-            if (vflag <= 1)
-                print_unknown_data(obj_tptr,"\n\t    ",obj_tlen); /* FIXME indentation */
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo, obj_tptr, "\n\t    ", obj_tlen); /* FIXME indentation */
             break;
         }
         /* do we also want to see a hex dump ? */
-        if (vflag > 1 || hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(struct rsvp_object_header),"\n\t    ", /* FIXME indentation */
-                               rsvp_obj_len-sizeof(struct rsvp_object_header));
+        if (ndo->ndo_vflag > 1 || hexdump == TRUE)
+            print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), "\n\t    ", /* FIXME indentation */
+                               rsvp_obj_len - sizeof(struct rsvp_object_header));
 
         tptr+=rsvp_obj_len;
         tlen-=rsvp_obj_len;
     }
     return 0;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
     return -1;
 }
 
-
 void
-rsvp_print(register const u_char *pptr, register u_int len) {
-
+rsvp_print(netdissect_options *ndo,
+           register const u_char *pptr, register u_int len)
+{
     struct rsvp_common_header *rsvp_com_header;
     const u_char *tptr,*subtptr;
     u_short plen, tlen, subtlen;
@@ -1813,23 +1804,23 @@
     tptr=pptr;
 
     rsvp_com_header = (struct rsvp_common_header *)pptr;
-    TCHECK(*rsvp_com_header);
+    ND_TCHECK(*rsvp_com_header);
 
     /*
      * Sanity checking of the header.
      */
     if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
-	printf("ERROR: RSVP version %u packet not supported",
-               RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
+	ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
+               RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
 	return;
     }
 
     /* in non-verbose mode just lets print the basic Message Type*/
-    if (vflag < 1) {
-        printf("RSVPv%u %s Message, length: %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "RSVPv%u %s Message, length: %u",
                RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
                tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type),
-               len);
+               len));
         return;
     }
 
@@ -1837,14 +1828,14 @@
 
     plen = tlen = EXTRACT_16BITS(rsvp_com_header->length);
 
-    printf("\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
+    ND_PRINT((ndo, "\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
            RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
            tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
            rsvp_com_header->msg_type,
            bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
            tlen,
            rsvp_com_header->ttl,
-           EXTRACT_16BITS(rsvp_com_header->checksum));
+           EXTRACT_16BITS(rsvp_com_header->checksum)));
 
     /*
      * Clear checksum prior to signature verification.
@@ -1853,8 +1844,8 @@
     rsvp_com_header->checksum[1] = 0;
 
     if (tlen < sizeof(const struct rsvp_common_header)) {
-        printf("ERROR: common header too short %u < %lu", tlen,
-               (unsigned long)sizeof(const struct rsvp_common_header));
+        ND_PRINT((ndo, "ERROR: common header too short %u < %lu", tlen,
+               (unsigned long)sizeof(const struct rsvp_common_header)));
         return;
     }
 
@@ -1867,49 +1858,49 @@
         while(tlen > 0) {
             subtptr=tptr;
             rsvp_com_header = (struct rsvp_common_header *)subtptr;
-            TCHECK(*rsvp_com_header);
+            ND_TCHECK(*rsvp_com_header);
 
             /*
              * Sanity checking of the header.
              */
             if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
-                printf("ERROR: RSVP version %u packet not supported",
-                       RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
+                ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
+                       RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
                 return;
             }
             subtlen=EXTRACT_16BITS(rsvp_com_header->length);
-            
-            printf("\n\t  RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
+
+            ND_PRINT((ndo, "\n\t  RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
                    RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
                    tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
                    rsvp_com_header->msg_type,
                    bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
                    subtlen,
                    rsvp_com_header->ttl,
-                   EXTRACT_16BITS(rsvp_com_header->checksum));
+                   EXTRACT_16BITS(rsvp_com_header->checksum)));
 
             /*
              * Clear checksum prior to signature verification.
              */
             rsvp_com_header->checksum[0] = 0;
             rsvp_com_header->checksum[1] = 0;
-            
+
             if (subtlen < sizeof(const struct rsvp_common_header)) {
-                printf("ERROR: common header too short %u < %lu", subtlen,
-                       (unsigned long)sizeof(const struct rsvp_common_header));
+                ND_PRINT((ndo, "ERROR: common header too short %u < %lu", subtlen,
+                       (unsigned long)sizeof(const struct rsvp_common_header)));
                 return;
             }
 
             if (tlen < subtlen) {
-                printf("ERROR: common header too large %u > %u", subtlen,
-                       tlen);
+                ND_PRINT((ndo, "ERROR: common header too large %u > %u", subtlen,
+                       tlen));
                 return;
             }
 
             subtptr+=sizeof(const struct rsvp_common_header);
             subtlen-=sizeof(const struct rsvp_common_header);
 
-            if (rsvp_obj_print(pptr, plen, subtptr,"\n\t    ", subtlen) == -1)
+            if (rsvp_obj_print(ndo, pptr, plen, subtptr, "\n\t    ", subtlen) == -1)
                 return;
 
             tptr+=subtlen+sizeof(const struct rsvp_common_header);
@@ -1929,16 +1920,16 @@
     case RSVP_MSGTYPE_HELLO:
     case RSVP_MSGTYPE_ACK:
     case RSVP_MSGTYPE_SREFRESH:
-        if (rsvp_obj_print(pptr, plen, tptr,"\n\t  ", tlen) == -1)
+        if (rsvp_obj_print(ndo, pptr, plen, tptr, "\n\t  ", tlen) == -1)
             return;
         break;
 
-    default: 
-        print_unknown_data(tptr,"\n\t    ",tlen);  
+    default:
+        print_unknown_data(ndo, tptr, "\n\t    ", tlen);
         break;
     }
 
     return;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
diff --git a/print-rt6.c b/print-rt6.c
index dc196b4..3d5f9e3 100644
--- a/print-rt6.c
+++ b/print-rt6.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.27 2005-04-20 22:34:57 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -32,7 +28,7 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
+#include <string.h>
 
 #include "ip6.h"
 
@@ -41,25 +37,26 @@
 #include "extract.h"
 
 int
-rt6_print(register const u_char *bp, const u_char *bp2 _U_)
+rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2 _U_)
 {
 	register const struct ip6_rthdr *dp;
 	register const struct ip6_rthdr0 *dp0;
 	register const u_char *ep;
 	int i, len;
 	register const struct in6_addr *addr;
+	const struct in6_addr *last_addr = NULL;
 
 	dp = (struct ip6_rthdr *)bp;
 	len = dp->ip6r_len;
 
 	/* 'ep' points to the end of available data. */
-	ep = snapend;
+	ep = ndo->ndo_snapend;
 
-	TCHECK(dp->ip6r_segleft);
+	ND_TCHECK(dp->ip6r_segleft);
 
-	printf("srcrt (len=%d", dp->ip6r_len);	/*)*/
-	printf(", type=%d", dp->ip6r_type);
-	printf(", segleft=%d", dp->ip6r_segleft);
+	ND_PRINT((ndo, "srcrt (len=%d", dp->ip6r_len));	/*)*/
+	ND_PRINT((ndo, ", type=%d", dp->ip6r_type));
+	ND_PRINT((ndo, ", segleft=%d", dp->ip6r_segleft));
 
 	switch (dp->ip6r_type) {
 #ifndef IPV6_RTHDR_TYPE_0
@@ -72,10 +69,10 @@
 	case IPV6_RTHDR_TYPE_2:			/* Mobile IPv6 ID-20 */
 		dp0 = (struct ip6_rthdr0 *)dp;
 
-		TCHECK(dp0->ip6r0_reserved);
-		if (dp0->ip6r0_reserved || vflag) {
-			printf(", rsv=0x%0x",
-			    EXTRACT_32BITS(&dp0->ip6r0_reserved));
+		ND_TCHECK(dp0->ip6r0_reserved);
+		if (dp0->ip6r0_reserved || ndo->ndo_vflag) {
+			ND_PRINT((ndo, ", rsv=0x%0x",
+			    EXTRACT_32BITS(&dp0->ip6r0_reserved)));
 		}
 
 		if (len % 2 == 1)
@@ -86,11 +83,20 @@
 			if ((u_char *)(addr + 1) > ep)
 				goto trunc;
 
-			printf(", [%d]%s", i, ip6addr_string(addr));
+			ND_PRINT((ndo, ", [%d]%s", i, ip6addr_string(ndo, addr)));
+			last_addr = addr;
 			addr++;
 		}
+		/*
+		 * the destination address used in the pseudo-header is that of the final
+		 * destination : the last address of the routing header
+		 */
+		if (last_addr != NULL) {
+			struct ip6_hdr *ip6 = (struct ip6_hdr *)bp2;
+			UNALIGNED_MEMCPY(&ip6->ip6_dst, last_addr, sizeof (struct in6_addr));
+		}
 		/*(*/
-		printf(") ");
+		ND_PRINT((ndo, ") "));
 		return((dp0->ip6r0_len + 1) << 3);
 		break;
 	default:
@@ -99,7 +105,7 @@
 	}
 
  trunc:
-	fputs("[|srcrt]", stdout);
+	ND_PRINT((ndo, "[|srcrt]"));
 	return -1;
 }
 #endif /* INET6 */
diff --git a/print-rtsp.c b/print-rtsp.c
new file mode 100644
index 0000000..d721b8d
--- /dev/null
+++ b/print-rtsp.c
@@ -0,0 +1,50 @@
+/*
+ * 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, and (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.
+ * 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.
+ */
+
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header$";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "interface.h"
+#include "extract.h"
+
+static const char *rtspcmds[] = {
+	"DESCRIBE",
+	"ANNOUNCE",
+	"GET_PARAMETER",
+	"OPTIONS",
+	"PAUSE",
+	"PLAY",
+	"RECORD",
+	"REDIRECT",
+	"SETUP",
+	"SET_PARAMETER",
+	"TEARDOWN",
+	NULL
+};
+
+void
+rtsp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+	txtproto_print(ndo, pptr, len, "rtsp", rtspcmds, RESP_CODE_SECOND_TOKEN);
+}
diff --git a/print-rx.c b/print-rx.c
index 1b4f949..8a9babb 100644
--- a/print-rx.c
+++ b/print-rx.c
@@ -32,11 +32,7 @@
  * Ken Hornstein <kenh@cmf.nrl.navy.mil>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.42 2008-07-01 07:44:50 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -50,10 +46,88 @@
 #include "addrtoname.h"
 #include "extract.h"
 
-#include "rx.h"
-
 #include "ip.h"
 
+#define FS_RX_PORT	7000
+#define CB_RX_PORT	7001
+#define PROT_RX_PORT	7002
+#define VLDB_RX_PORT	7003
+#define KAUTH_RX_PORT	7004
+#define VOL_RX_PORT	7005
+#define ERROR_RX_PORT	7006		/* Doesn't seem to be used */
+#define BOS_RX_PORT	7007
+
+#define AFSNAMEMAX 256
+#define AFSOPAQUEMAX 1024
+#define PRNAMEMAX 64
+#define VLNAMEMAX 65
+#define KANAMEMAX 64
+#define BOSNAMEMAX 256
+
+#define	PRSFS_READ		1 /* Read files */
+#define	PRSFS_WRITE		2 /* Write files */
+#define	PRSFS_INSERT		4 /* Insert files into a directory */
+#define	PRSFS_LOOKUP		8 /* Lookup files into a directory */
+#define	PRSFS_DELETE		16 /* Delete files */
+#define	PRSFS_LOCK		32 /* Lock files */
+#define	PRSFS_ADMINISTER	64 /* Change ACL's */
+
+struct rx_header {
+	uint32_t epoch;
+	uint32_t cid;
+	uint32_t callNumber;
+	uint32_t seq;
+	uint32_t serial;
+	uint8_t type;
+#define RX_PACKET_TYPE_DATA		1
+#define RX_PACKET_TYPE_ACK		2
+#define RX_PACKET_TYPE_BUSY		3
+#define RX_PACKET_TYPE_ABORT		4
+#define RX_PACKET_TYPE_ACKALL		5
+#define RX_PACKET_TYPE_CHALLENGE	6
+#define RX_PACKET_TYPE_RESPONSE		7
+#define RX_PACKET_TYPE_DEBUG		8
+#define RX_PACKET_TYPE_PARAMS		9
+#define RX_PACKET_TYPE_VERSION		13
+	uint8_t flags;
+#define RX_CLIENT_INITIATED	1
+#define RX_REQUEST_ACK		2
+#define RX_LAST_PACKET		4
+#define RX_MORE_PACKETS		8
+#define RX_FREE_PACKET		16
+#define RX_SLOW_START_OK	32
+#define RX_JUMBO_PACKET		32
+	uint8_t userStatus;
+	uint8_t securityIndex;
+	uint16_t spare;		/* How clever: even though the AFS */
+	uint16_t serviceId;		/* header files indicate that the */
+};					/* serviceId is first, it's really */
+					/* encoded _after_ the spare field */
+					/* I wasted a day figuring that out! */
+
+#define NUM_RX_FLAGS 7
+
+#define RX_MAXACKS 255
+
+struct rx_ackPacket {
+	uint16_t bufferSpace;		/* Number of packet buffers available */
+	uint16_t maxSkew;		/* Max diff between ack'd packet and */
+					/* highest packet received */
+	uint32_t firstPacket;		/* The first packet in ack list */
+	uint32_t previousPacket;	/* Previous packet recv'd (obsolete) */
+	uint32_t serial;		/* # of packet that prompted the ack */
+	uint8_t reason;		/* Reason for acknowledgement */
+	uint8_t nAcks;			/* Number of acknowledgements */
+	uint8_t acks[RX_MAXACKS];	/* Up to RX_MAXACKS acknowledgements */
+};
+
+/*
+ * Values for the acks array
+ */
+
+#define RX_ACK_TYPE_NACK	0	/* Don't have this packet */
+#define RX_ACK_TYPE_ACK		1	/* I have this packet */
+
 static const struct tok rx_types[] = {
 	{ RX_PACKET_TYPE_DATA,		"data" },
 	{ RX_PACKET_TYPE_ACK,		"ack" },
@@ -68,7 +142,7 @@
 	{ 0,				NULL },
 };
 
-static struct double_tok {
+static const struct double_tok {
 	int flag;		/* Rx flag */
 	int packetType;		/* Packet type */
 	const char *s;		/* Flag string */
@@ -373,7 +447,7 @@
 	{ 110, 		"volume busy" },
 	{ 111, 		"volume moved" },
 	{ 112, 		"AFS IO error" },
-	{ -100,		"restarting fileserver" },
+	{ 0xffffff9c,	"restarting fileserver" }, /* -100, sic! */
 	{ 0,		NULL }
 };
 
@@ -400,12 +474,12 @@
  */
 
 struct rx_cache_entry {
-	u_int32_t	callnum;	/* Call number (net order) */
+	uint32_t	callnum;	/* Call number (net order) */
 	struct in_addr	client;		/* client IP address (net order) */
 	struct in_addr	server;		/* server IP address (net order) */
 	int		dport;		/* server port (host order) */
 	u_short		serviceId;	/* Service identifier (net order) */
-	u_int32_t	opcode;		/* RX opcode (host order) */
+	uint32_t	opcode;		/* RX opcode (host order) */
 };
 
 #define RX_CACHE_SIZE	64
@@ -414,31 +488,31 @@
 
 static int	rx_cache_next = 0;
 static int	rx_cache_hint = 0;
-static void	rx_cache_insert(const u_char *, const struct ip *, int);
+static void	rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, int);
 static int	rx_cache_find(const struct rx_header *, const struct ip *,
 			      int, int32_t *);
 
-static void fs_print(const u_char *, int);
-static void fs_reply_print(const u_char *, int, int32_t);
-static void acl_print(u_char *, int, u_char *);
-static void cb_print(const u_char *, int);
-static void cb_reply_print(const u_char *, int, int32_t);
-static void prot_print(const u_char *, int);
-static void prot_reply_print(const u_char *, int, int32_t);
-static void vldb_print(const u_char *, int);
-static void vldb_reply_print(const u_char *, int, int32_t);
-static void kauth_print(const u_char *, int);
-static void kauth_reply_print(const u_char *, int, int32_t);
-static void vol_print(const u_char *, int);
-static void vol_reply_print(const u_char *, int, int32_t);
-static void bos_print(const u_char *, int);
-static void bos_reply_print(const u_char *, int, int32_t);
-static void ubik_print(const u_char *);
-static void ubik_reply_print(const u_char *, int, int32_t);
+static void fs_print(netdissect_options *, const u_char *, int);
+static void fs_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void acl_print(netdissect_options *, u_char *, int, u_char *);
+static void cb_print(netdissect_options *, const u_char *, int);
+static void cb_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void prot_print(netdissect_options *, const u_char *, int);
+static void prot_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void vldb_print(netdissect_options *, const u_char *, int);
+static void vldb_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void kauth_print(netdissect_options *, const u_char *, int);
+static void kauth_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void vol_print(netdissect_options *, const u_char *, int);
+static void vol_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void bos_print(netdissect_options *, const u_char *, int);
+static void bos_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void ubik_print(netdissect_options *, const u_char *);
+static void ubik_reply_print(netdissect_options *, const u_char *, int, int32_t);
 
-static void rx_ack_print(const u_char *, int);
+static void rx_ack_print(netdissect_options *, const u_char *, int);
 
-static int is_ubik(u_int32_t);
+static int is_ubik(uint32_t);
 
 /*
  * Handle the rx-level packet.  See if we know what port it's going to so
@@ -446,51 +520,52 @@
  */
 
 void
-rx_print(register const u_char *bp, int length, int sport, int dport,
-	 u_char *bp2)
+rx_print(netdissect_options *ndo,
+         register const u_char *bp, int length, int sport, int dport,
+         u_char *bp2)
 {
 	register struct rx_header *rxh;
 	int i;
 	int32_t opcode;
 
-	if (snapend - bp < (int)sizeof (struct rx_header)) {
-		printf(" [|rx] (%d)", length);
+	if (ndo->ndo_snapend - bp < (int)sizeof (struct rx_header)) {
+		ND_PRINT((ndo, " [|rx] (%d)", length));
 		return;
 	}
 
 	rxh = (struct rx_header *) bp;
 
-	printf(" rx %s", tok2str(rx_types, "type %d", rxh->type));
+	ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type)));
 
-	if (vflag) {
+	if (ndo->ndo_vflag) {
 		int firstflag = 0;
 
-		if (vflag > 1)
-			printf(" cid %08x call# %d",
+		if (ndo->ndo_vflag > 1)
+			ND_PRINT((ndo, " cid %08x call# %d",
 			       (int) EXTRACT_32BITS(&rxh->cid),
-			       (int) EXTRACT_32BITS(&rxh->callNumber));
+			       (int) EXTRACT_32BITS(&rxh->callNumber)));
 
-		printf(" seq %d ser %d",
+		ND_PRINT((ndo, " seq %d ser %d",
 		       (int) EXTRACT_32BITS(&rxh->seq),
-		       (int) EXTRACT_32BITS(&rxh->serial));
+		       (int) EXTRACT_32BITS(&rxh->serial)));
 
-		if (vflag > 2)
-			printf(" secindex %d serviceid %hu",
+		if (ndo->ndo_vflag > 2)
+			ND_PRINT((ndo, " secindex %d serviceid %hu",
 				(int) rxh->securityIndex,
-				EXTRACT_16BITS(&rxh->serviceId));
+				EXTRACT_16BITS(&rxh->serviceId)));
 
-		if (vflag > 1)
+		if (ndo->ndo_vflag > 1)
 			for (i = 0; i < NUM_RX_FLAGS; i++) {
 				if (rxh->flags & rx_flags[i].flag &&
 				    (!rx_flags[i].packetType ||
 				     rxh->type == rx_flags[i].packetType)) {
 					if (!firstflag) {
 						firstflag = 1;
-						printf(" ");
+						ND_PRINT((ndo, " "));
 					} else {
-						printf(",");
+						ND_PRINT((ndo, ","));
 					}
-					printf("<%s>", rx_flags[i].s);
+					ND_PRINT((ndo, "<%s>", rx_flags[i].s));
 				}
 			}
 	}
@@ -513,29 +588,29 @@
 		 * have a chance to print out replies
 		 */
 
-		rx_cache_insert(bp, (const struct ip *) bp2, dport);
+		rx_cache_insert(ndo, bp, (const struct ip *) bp2, dport);
 
 		switch (dport) {
 			case FS_RX_PORT:	/* AFS file service */
-				fs_print(bp, length);
+				fs_print(ndo, bp, length);
 				break;
 			case CB_RX_PORT:	/* AFS callback service */
-				cb_print(bp, length);
+				cb_print(ndo, bp, length);
 				break;
 			case PROT_RX_PORT:	/* AFS protection service */
-				prot_print(bp, length);
+				prot_print(ndo, bp, length);
 				break;
 			case VLDB_RX_PORT:	/* AFS VLDB service */
-				vldb_print(bp, length);
+				vldb_print(ndo, bp, length);
 				break;
 			case KAUTH_RX_PORT:	/* AFS Kerberos auth service */
-				kauth_print(bp, length);
+				kauth_print(ndo, bp, length);
 				break;
 			case VOL_RX_PORT:	/* AFS Volume service */
-				vol_print(bp, length);
+				vol_print(ndo, bp, length);
 				break;
 			case BOS_RX_PORT:	/* AFS BOS service */
-				bos_print(bp, length);
+				bos_print(ndo, bp, length);
 				break;
 			default:
 				;
@@ -557,25 +632,25 @@
 
 		switch (sport) {
 			case FS_RX_PORT:	/* AFS file service */
-				fs_reply_print(bp, length, opcode);
+				fs_reply_print(ndo, bp, length, opcode);
 				break;
 			case CB_RX_PORT:	/* AFS callback service */
-				cb_reply_print(bp, length, opcode);
+				cb_reply_print(ndo, bp, length, opcode);
 				break;
 			case PROT_RX_PORT:	/* AFS PT service */
-				prot_reply_print(bp, length, opcode);
+				prot_reply_print(ndo, bp, length, opcode);
 				break;
 			case VLDB_RX_PORT:	/* AFS VLDB service */
-				vldb_reply_print(bp, length, opcode);
+				vldb_reply_print(ndo, bp, length, opcode);
 				break;
 			case KAUTH_RX_PORT:	/* AFS Kerberos auth service */
-				kauth_reply_print(bp, length, opcode);
+				kauth_reply_print(ndo, bp, length, opcode);
 				break;
 			case VOL_RX_PORT:	/* AFS Volume service */
-				vol_reply_print(bp, length, opcode);
+				vol_reply_print(ndo, bp, length, opcode);
 				break;
 			case BOS_RX_PORT:	/* AFS BOS service */
-				bos_reply_print(bp, length, opcode);
+				bos_reply_print(ndo, bp, length, opcode);
 				break;
 			default:
 				;
@@ -588,10 +663,10 @@
 	 */
 
 	} else if (rxh->type == RX_PACKET_TYPE_ACK)
-		rx_ack_print(bp, length);
+		rx_ack_print(ndo, bp, length);
 
 
-	printf(" (%d)", length);
+	ND_PRINT((ndo, " (%d)", length));
 }
 
 /*
@@ -599,12 +674,13 @@
  */
 
 static void
-rx_cache_insert(const u_char *bp, const struct ip *ip, int dport)
+rx_cache_insert(netdissect_options *ndo,
+                const u_char *bp, const struct ip *ip, int dport)
 {
 	struct rx_cache_entry *rxent;
 	const struct rx_header *rxh = (const struct rx_header *) bp;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t)))
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t)))
 		return;
 
 	rxent = &rx_cache[rx_cache_next];
@@ -633,8 +709,8 @@
 {
 	int i;
 	struct rx_cache_entry *rxent;
-	u_int32_t clip = ip->ip_dst.s_addr;
-	u_int32_t sip = ip->ip_src.s_addr;
+	uint32_t clip = ip->ip_dst.s_addr;
+	uint32_t sip = ip->ip_src.s_addr;
 
 	/* Start the search where we last left off */
 
@@ -666,101 +742,101 @@
  */
 
 #define FIDOUT() { unsigned long n1, n2, n3; \
-			TCHECK2(bp[0], sizeof(int32_t) * 3); \
+			ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
 			n1 = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
 			n2 = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
 			n3 = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
-			printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
+			ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
 		}
 
 #define STROUT(MAX) { unsigned int i; \
-			TCHECK2(bp[0], sizeof(int32_t)); \
+			ND_TCHECK2(bp[0], sizeof(int32_t)); \
 			i = EXTRACT_32BITS(bp); \
 			if (i > (MAX)) \
 				goto trunc; \
 			bp += sizeof(int32_t); \
-			printf(" \""); \
-			if (fn_printn(bp, i, snapend)) \
+			ND_PRINT((ndo, " \"")); \
+			if (fn_printn(ndo, bp, i, ndo->ndo_snapend)) \
 				goto trunc; \
-			printf("\""); \
+			ND_PRINT((ndo, "\"")); \
 			bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
 		}
 
 #define INTOUT() { int i; \
-			TCHECK2(bp[0], sizeof(int32_t)); \
+			ND_TCHECK2(bp[0], sizeof(int32_t)); \
 			i = (int) EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
-			printf(" %d", i); \
+			ND_PRINT((ndo, " %d", i)); \
 		}
 
 #define UINTOUT() { unsigned long i; \
-			TCHECK2(bp[0], sizeof(int32_t)); \
+			ND_TCHECK2(bp[0], sizeof(int32_t)); \
 			i = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
-			printf(" %lu", i); \
+			ND_PRINT((ndo, " %lu", i)); \
 		}
 
-#define UINT64OUT() { u_int64_t i; \
-			TCHECK2(bp[0], sizeof(u_int64_t)); \
+#define UINT64OUT() { uint64_t i; \
+			ND_TCHECK2(bp[0], sizeof(uint64_t)); \
 			i = EXTRACT_64BITS(bp); \
-			bp += sizeof(u_int64_t); \
-			printf(" %" PRIu64, i); \
+			bp += sizeof(uint64_t); \
+			ND_PRINT((ndo, " %" PRIu64, i)); \
 		}
 
 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
-			TCHECK2(bp[0], sizeof(int32_t)); \
+			ND_TCHECK2(bp[0], sizeof(int32_t)); \
 			t = (time_t) EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
 			tm = localtime(&t); \
 			strftime(str, 256, "%Y/%m/%d %T", tm); \
-			printf(" %s", str); \
+			ND_PRINT((ndo, " %s", str)); \
 		}
 
 #define STOREATTROUT() { unsigned long mask, i; \
-			TCHECK2(bp[0], (sizeof(int32_t)*6)); \
+			ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
 			mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
-			if (mask) printf (" StoreStatus"); \
-		        if (mask & 1) { printf(" date"); DATEOUT(); } \
+			if (mask) ND_PRINT((ndo, " StoreStatus")); \
+		        if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
 			else bp += sizeof(int32_t); \
 			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
-		        if (mask & 2) printf(" owner %lu", i);  \
+		        if (mask & 2) ND_PRINT((ndo, " owner %lu", i));  \
 			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
-		        if (mask & 4) printf(" group %lu", i); \
+		        if (mask & 4) ND_PRINT((ndo, " group %lu", i)); \
 			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
-		        if (mask & 8) printf(" mode %lo", i & 07777); \
+		        if (mask & 8) ND_PRINT((ndo, " mode %lo", i & 07777)); \
 			i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
-		        if (mask & 16) printf(" segsize %lu", i); \
+		        if (mask & 16) ND_PRINT((ndo, " segsize %lu", i)); \
 			/* undocumented in 3.3 docu */ \
-		        if (mask & 1024) printf(" fsync");  \
+		        if (mask & 1024) ND_PRINT((ndo, " fsync"));  \
 		}
 
 #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
-			TCHECK2(bp[0], sizeof(int32_t) * 2); \
+			ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
 			epoch = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
 			counter = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
-			printf(" %d.%d", epoch, counter); \
+			ND_PRINT((ndo, " %d.%d", epoch, counter)); \
 		}
 
-#define AFSUUIDOUT() {u_int32_t temp; int i; \
-			TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
+#define AFSUUIDOUT() {uint32_t temp; int i; \
+			ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
 			temp = EXTRACT_32BITS(bp); \
-			bp += sizeof(u_int32_t); \
-			printf(" %08x", temp); \
+			bp += sizeof(uint32_t); \
+			ND_PRINT((ndo, " %08x", temp)); \
 			temp = EXTRACT_32BITS(bp); \
-			bp += sizeof(u_int32_t); \
-			printf("%04x", temp); \
+			bp += sizeof(uint32_t); \
+			ND_PRINT((ndo, "%04x", temp)); \
 			temp = EXTRACT_32BITS(bp); \
-			bp += sizeof(u_int32_t); \
-			printf("%04x", temp); \
+			bp += sizeof(uint32_t); \
+			ND_PRINT((ndo, "%04x", temp)); \
 			for (i = 0; i < 8; i++) { \
 				temp = EXTRACT_32BITS(bp); \
-				bp += sizeof(u_int32_t); \
-				printf("%02x", (unsigned char) temp); \
+				bp += sizeof(uint32_t); \
+				ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
 			} \
 		}
 
@@ -773,27 +849,27 @@
 			int k; \
 			if ((MAX) + 1 > sizeof(s)) \
 				goto trunc; \
-			TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
+			ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
 			sp = s; \
 			for (k = 0; k < (MAX); k++) { \
 				*sp++ = (u_char) EXTRACT_32BITS(bp); \
 				bp += sizeof(int32_t); \
 			} \
 			s[(MAX)] = '\0'; \
-			printf(" \""); \
-			fn_print(s, NULL); \
-			printf("\""); \
+			ND_PRINT((ndo, " \"")); \
+			fn_print(ndo, s, NULL); \
+			ND_PRINT((ndo, "\"")); \
 		}
 
 #define DESTSERVEROUT() { unsigned long n1, n2, n3; \
-			TCHECK2(bp[0], sizeof(int32_t) * 3); \
+			ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
 			n1 = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
 			n2 = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
 			n3 = EXTRACT_32BITS(bp); \
 			bp += sizeof(int32_t); \
-			printf(" server %d:%d:%d", (int) n1, (int) n2, (int) n3); \
+			ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
 		}
 
 /*
@@ -801,7 +877,8 @@
  */
 
 static void
-fs_print(register const u_char *bp, int length)
+fs_print(netdissect_options *ndo,
+         register const u_char *bp, int length)
 {
 	int fs_op;
 	unsigned long i;
@@ -809,7 +886,7 @@
 	if (length <= (int)sizeof(struct rx_header))
 		return;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
 		goto trunc;
 	}
 
@@ -820,7 +897,7 @@
 
 	fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op));
+	ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op)));
 
 	/*
 	 * Print out arguments to some of the AFS calls.  This stuff is
@@ -836,9 +913,9 @@
 	switch (fs_op) {
 		case 130:	/* Fetch data */
 			FIDOUT();
-			printf(" offset");
+			ND_PRINT((ndo, " offset"));
 			UINTOUT();
-			printf(" length");
+			ND_PRINT((ndo, " length"));
 			UINTOUT();
 			break;
 		case 131:	/* Fetch ACL */
@@ -858,25 +935,25 @@
 		case 133:	/* Store data */
 			FIDOUT();
 			STOREATTROUT();
-			printf(" offset");
+			ND_PRINT((ndo, " offset"));
 			UINTOUT();
-			printf(" length");
+			ND_PRINT((ndo, " length"));
 			UINTOUT();
-			printf(" flen");
+			ND_PRINT((ndo, " flen"));
 			UINTOUT();
 			break;
 		case 134:	/* Store ACL */
 		{
 			char a[AFSOPAQUEMAX+1];
 			FIDOUT();
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			i = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
-			TCHECK2(bp[0], i);
+			ND_TCHECK2(bp[0], i);
 			i = min(AFSOPAQUEMAX, i);
 			strncpy(a, (char *) bp, i);
 			a[i] = '\0';
-			acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
+			acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
 			break;
 		}
 		case 137:	/* Create file */
@@ -891,23 +968,23 @@
 			STROUT(AFSNAMEMAX);
 			break;
 		case 138:	/* Rename file */
-			printf(" old");
+			ND_PRINT((ndo, " old"));
 			FIDOUT();
 			STROUT(AFSNAMEMAX);
-			printf(" new");
+			ND_PRINT((ndo, " new"));
 			FIDOUT();
 			STROUT(AFSNAMEMAX);
 			break;
 		case 139:	/* Symlink */
 			FIDOUT();
 			STROUT(AFSNAMEMAX);
-			printf(" link to");
+			ND_PRINT((ndo, " link to"));
 			STROUT(AFSNAMEMAX);
 			break;
 		case 140:	/* Link */
 			FIDOUT();
 			STROUT(AFSNAMEMAX);
-			printf(" link to");
+			ND_PRINT((ndo, " link to"));
 			FIDOUT();
 			break;
 		case 148:	/* Get volume info */
@@ -915,48 +992,48 @@
 			break;
 		case 149:	/* Get volume stats */
 		case 150:	/* Set volume stats */
-			printf(" volid");
+			ND_PRINT((ndo, " volid"));
 			UINTOUT();
 			break;
 		case 154:	/* New get volume info */
-			printf(" volname");
+			ND_PRINT((ndo, " volname"));
 			STROUT(AFSNAMEMAX);
 			break;
 		case 155:	/* Bulk stat */
 		case 65536:     /* Inline bulk stat */
 		{
 			unsigned long j;
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			j = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 
 			for (i = 0; i < j; i++) {
 				FIDOUT();
 				if (i != j - 1)
-					printf(",");
+					ND_PRINT((ndo, ","));
 			}
 			if (j == 0)
-				printf(" <none!>");
+				ND_PRINT((ndo, " <none!>"));
 		}
 		case 65537:	/* Fetch data 64 */
 			FIDOUT();
-			printf(" offset");
+			ND_PRINT((ndo, " offset"));
 			UINT64OUT();
-			printf(" length");
+			ND_PRINT((ndo, " length"));
 			UINT64OUT();
 			break;
 		case 65538:	/* Store data 64 */
 			FIDOUT();
 			STOREATTROUT();
-			printf(" offset");
+			ND_PRINT((ndo, " offset"));
 			UINT64OUT();
-			printf(" length");
+			ND_PRINT((ndo, " length"));
 			UINT64OUT();
-			printf(" flen");
+			ND_PRINT((ndo, " flen"));
 			UINT64OUT();
 			break;
 		case 65541:    /* CallBack rx conn address */
-			printf(" addr");
+			ND_PRINT((ndo, " addr"));
 			UINTOUT();
 		default:
 			;
@@ -965,7 +1042,7 @@
 	return;
 
 trunc:
-	printf(" [|fs]");
+	ND_PRINT((ndo, " [|fs]"));
 }
 
 /*
@@ -973,7 +1050,8 @@
  */
 
 static void
-fs_reply_print(register const u_char *bp, int length, int32_t opcode)
+fs_reply_print(netdissect_options *ndo,
+               register const u_char *bp, int length, int32_t opcode)
 {
 	unsigned long i;
 	struct rx_header *rxh;
@@ -988,7 +1066,7 @@
 	 * gleaned from fsint/afsint.xg
 	 */
 
-	printf(" fs reply %s", tok2str(fs_req, "op#%d", opcode));
+	ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -1001,23 +1079,23 @@
 		case 131:	/* Fetch ACL */
 		{
 			char a[AFSOPAQUEMAX+1];
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			i = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
-			TCHECK2(bp[0], i);
+			ND_TCHECK2(bp[0], i);
 			i = min(AFSOPAQUEMAX, i);
 			strncpy(a, (char *) bp, i);
 			a[i] = '\0';
-			acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
+			acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
 			break;
 		}
 		case 137:	/* Create file */
 		case 141:	/* MakeDir */
-			printf(" new");
+			ND_PRINT((ndo, " new"));
 			FIDOUT();
 			break;
 		case 151:	/* Get root volume */
-			printf(" root volume");
+			ND_PRINT((ndo, " root volume"));
 			STROUT(AFSNAMEMAX);
 			break;
 		case 153:	/* Get time */
@@ -1032,19 +1110,19 @@
 		/*
 		 * Otherwise, just print out the return code
 		 */
-		TCHECK2(bp[0], sizeof(int32_t));
+		ND_TCHECK2(bp[0], sizeof(int32_t));
 		i = (int) EXTRACT_32BITS(bp);
 		bp += sizeof(int32_t);
 
-		printf(" error %s", tok2str(afs_fs_errors, "#%d", i));
+		ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i)));
 	} else {
-		printf(" strange fs reply of type %d", rxh->type);
+		ND_PRINT((ndo, " strange fs reply of type %d", rxh->type));
 	}
 
 	return;
 
 trunc:
-	printf(" [|fs]");
+	ND_PRINT((ndo, " [|fs]"));
 }
 
 /*
@@ -1062,7 +1140,8 @@
  */
 
 static void
-acl_print(u_char *s, int maxsize, u_char *end)
+acl_print(netdissect_options *ndo,
+          u_char *s, int maxsize, u_char *end)
 {
 	int pos, neg, acl;
 	int n, i;
@@ -1085,31 +1164,25 @@
 	 */
 
 #define ACLOUT(acl) \
-	if (acl & PRSFS_READ) \
-		printf("r"); \
-	if (acl & PRSFS_LOOKUP) \
-		printf("l"); \
-	if (acl & PRSFS_INSERT) \
-		printf("i"); \
-	if (acl & PRSFS_DELETE) \
-		printf("d"); \
-	if (acl & PRSFS_WRITE) \
-		printf("w"); \
-	if (acl & PRSFS_LOCK) \
-		printf("k"); \
-	if (acl & PRSFS_ADMINISTER) \
-		printf("a");
+	ND_PRINT((ndo, "%s%s%s%s%s%s%s", \
+	          acl & PRSFS_READ       ? "r" : "", \
+	          acl & PRSFS_LOOKUP     ? "l" : "", \
+	          acl & PRSFS_INSERT     ? "i" : "", \
+	          acl & PRSFS_DELETE     ? "d" : "", \
+	          acl & PRSFS_WRITE      ? "w" : "", \
+	          acl & PRSFS_LOCK       ? "k" : "", \
+	          acl & PRSFS_ADMINISTER ? "a" : ""));
 
 	for (i = 0; i < pos; i++) {
 		snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
 		if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
 			goto finish;
 		s += n;
-		printf(" +{");
-		fn_print((u_char *)user, NULL);
-		printf(" ");
+		ND_PRINT((ndo, " +{"));
+		fn_print(ndo, (u_char *)user, NULL);
+		ND_PRINT((ndo, " "));
 		ACLOUT(acl);
-		printf("}");
+		ND_PRINT((ndo, "}"));
 		if (s > end)
 			goto finish;
 	}
@@ -1119,11 +1192,11 @@
 		if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
 			goto finish;
 		s += n;
-		printf(" -{");
-		fn_print((u_char *)user, NULL);
-		printf(" ");
+		ND_PRINT((ndo, " -{"));
+		fn_print(ndo, (u_char *)user, NULL);
+		ND_PRINT((ndo, " "));
 		ACLOUT(acl);
-		printf("}");
+		ND_PRINT((ndo, "}"));
 		if (s > end)
 			goto finish;
 	}
@@ -1140,7 +1213,8 @@
  */
 
 static void
-cb_print(register const u_char *bp, int length)
+cb_print(netdissect_options *ndo,
+         register const u_char *bp, int length)
 {
 	int cb_op;
 	unsigned long i;
@@ -1148,7 +1222,7 @@
 	if (length <= (int)sizeof(struct rx_header))
 		return;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
 		goto trunc;
 	}
 
@@ -1159,7 +1233,7 @@
 
 	cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op));
+	ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op)));
 
 	bp += sizeof(struct rx_header) + 4;
 
@@ -1172,38 +1246,38 @@
 		case 204:		/* Callback */
 		{
 			unsigned long j, t;
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			j = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 
 			for (i = 0; i < j; i++) {
 				FIDOUT();
 				if (i != j - 1)
-					printf(",");
+					ND_PRINT((ndo, ","));
 			}
 
 			if (j == 0)
-				printf(" <none!>");
+				ND_PRINT((ndo, " <none!>"));
 
 			j = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 
 			if (j != 0)
-				printf(";");
+				ND_PRINT((ndo, ";"));
 
 			for (i = 0; i < j; i++) {
-				printf(" ver");
+				ND_PRINT((ndo, " ver"));
 				INTOUT();
-				printf(" expires");
+				ND_PRINT((ndo, " expires"));
 				DATEOUT();
-				TCHECK2(bp[0], 4);
+				ND_TCHECK2(bp[0], 4);
 				t = EXTRACT_32BITS(bp);
 				bp += sizeof(int32_t);
 				tok2str(cb_types, "type %d", t);
 			}
 		}
 		case 214: {
-			printf(" afsuuid");
+			ND_PRINT((ndo, " afsuuid"));
 			AFSUUIDOUT();
 			break;
 		}
@@ -1214,7 +1288,7 @@
 	return;
 
 trunc:
-	printf(" [|cb]");
+	ND_PRINT((ndo, " [|cb]"));
 }
 
 /*
@@ -1222,7 +1296,8 @@
  */
 
 static void
-cb_reply_print(register const u_char *bp, int length, int32_t opcode)
+cb_reply_print(netdissect_options *ndo,
+               register const u_char *bp, int length, int32_t opcode)
 {
 	struct rx_header *rxh;
 
@@ -1236,7 +1311,7 @@
 	 * gleaned from fsint/afscbint.xg
 	 */
 
-	printf(" cb reply %s", tok2str(cb_req, "op#%d", opcode));
+	ND_PRINT((ndo, " cb reply %s", tok2str(cb_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -1256,14 +1331,14 @@
 		/*
 		 * Otherwise, just print out the return code
 		 */
-		printf(" errcode");
+		ND_PRINT((ndo, " errcode"));
 		INTOUT();
 	}
 
 	return;
 
 trunc:
-	printf(" [|cb]");
+	ND_PRINT((ndo, " [|cb]"));
 }
 
 /*
@@ -1271,7 +1346,8 @@
  */
 
 static void
-prot_print(register const u_char *bp, int length)
+prot_print(netdissect_options *ndo,
+           register const u_char *bp, int length)
 {
 	unsigned long i;
 	int pt_op;
@@ -1279,7 +1355,7 @@
 	if (length <= (int)sizeof(struct rx_header))
 		return;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
 		goto trunc;
 	}
 
@@ -1290,14 +1366,14 @@
 
 	pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" pt");
+	ND_PRINT((ndo, " pt"));
 
 	if (is_ubik(pt_op)) {
-		ubik_print(bp);
+		ubik_print(ndo, bp);
 		return;
 	}
 
-	printf(" call %s", tok2str(pt_req, "op#%d", pt_op));
+	ND_PRINT((ndo, " call %s", tok2str(pt_req, "op#%d", pt_op)));
 
 	/*
 	 * Decode some of the arguments to the PT calls
@@ -1308,9 +1384,9 @@
 	switch (pt_op) {
 		case 500:	/* I New User */
 			STROUT(PRNAMEMAX);
-			printf(" id");
+			ND_PRINT((ndo, " id"));
 			INTOUT();
-			printf(" oldid");
+			ND_PRINT((ndo, " oldid"));
 			INTOUT();
 			break;
 		case 501:	/* Where is it */
@@ -1322,25 +1398,25 @@
 		case 518:	/* Get CPS2 */
 		case 519:	/* Get host CPS */
 		case 530:	/* List super groups */
-			printf(" id");
+			ND_PRINT((ndo, " id"));
 			INTOUT();
 			break;
 		case 502:	/* Dump entry */
-			printf(" pos");
+			ND_PRINT((ndo, " pos"));
 			INTOUT();
 			break;
 		case 503:	/* Add to group */
 		case 507:	/* Remove from group */
 		case 515:	/* Is a member of? */
-			printf(" uid");
+			ND_PRINT((ndo, " uid"));
 			INTOUT();
-			printf(" gid");
+			ND_PRINT((ndo, " gid"));
 			INTOUT();
 			break;
 		case 504:	/* Name to ID */
 		{
 			unsigned long j;
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			j = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 
@@ -1355,46 +1431,46 @@
 				VECOUT(PRNAMEMAX);
 			}
 			if (j == 0)
-				printf(" <none!>");
+				ND_PRINT((ndo, " <none!>"));
 		}
 			break;
 		case 505:	/* Id to name */
 		{
 			unsigned long j;
-			printf(" ids:");
-			TCHECK2(bp[0], 4);
+			ND_PRINT((ndo, " ids:"));
+			ND_TCHECK2(bp[0], 4);
 			i = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 			for (j = 0; j < i; j++)
 				INTOUT();
 			if (j == 0)
-				printf(" <none!>");
+				ND_PRINT((ndo, " <none!>"));
 		}
 			break;
 		case 509:	/* New entry */
 			STROUT(PRNAMEMAX);
-			printf(" flag");
+			ND_PRINT((ndo, " flag"));
 			INTOUT();
-			printf(" oid");
+			ND_PRINT((ndo, " oid"));
 			INTOUT();
 			break;
 		case 511:	/* Set max */
-			printf(" id");
+			ND_PRINT((ndo, " id"));
 			INTOUT();
-			printf(" gflag");
+			ND_PRINT((ndo, " gflag"));
 			INTOUT();
 			break;
 		case 513:	/* Change entry */
-			printf(" id");
+			ND_PRINT((ndo, " id"));
 			INTOUT();
 			STROUT(PRNAMEMAX);
-			printf(" oldid");
+			ND_PRINT((ndo, " oldid"));
 			INTOUT();
-			printf(" newid");
+			ND_PRINT((ndo, " newid"));
 			INTOUT();
 			break;
 		case 520:	/* Update entry */
-			printf(" id");
+			ND_PRINT((ndo, " id"));
 			INTOUT();
 			STROUT(PRNAMEMAX);
 			break;
@@ -1406,7 +1482,7 @@
 	return;
 
 trunc:
-	printf(" [|pt]");
+	ND_PRINT((ndo, " [|pt]"));
 }
 
 /*
@@ -1414,7 +1490,8 @@
  */
 
 static void
-prot_reply_print(register const u_char *bp, int length, int32_t opcode)
+prot_reply_print(netdissect_options *ndo,
+                 register const u_char *bp, int length, int32_t opcode)
 {
 	struct rx_header *rxh;
 	unsigned long i;
@@ -1430,14 +1507,14 @@
 	 * Ubik call, however.
 	 */
 
-	printf(" pt");
+	ND_PRINT((ndo, " pt"));
 
 	if (is_ubik(opcode)) {
-		ubik_reply_print(bp, length, opcode);
+		ubik_reply_print(ndo, bp, length, opcode);
 		return;
 	}
 
-	printf(" reply %s", tok2str(pt_req, "op#%d", opcode));
+	ND_PRINT((ndo, " reply %s", tok2str(pt_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -1450,20 +1527,20 @@
 		case 504:		/* Name to ID */
 		{
 			unsigned long j;
-			printf(" ids:");
-			TCHECK2(bp[0], 4);
+			ND_PRINT((ndo, " ids:"));
+			ND_TCHECK2(bp[0], 4);
 			i = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 			for (j = 0; j < i; j++)
 				INTOUT();
 			if (j == 0)
-				printf(" <none!>");
+				ND_PRINT((ndo, " <none!>"));
 		}
 			break;
 		case 505:		/* ID to name */
 		{
 			unsigned long j;
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			j = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 
@@ -1478,7 +1555,7 @@
 				VECOUT(PRNAMEMAX);
 			}
 			if (j == 0)
-				printf(" <none!>");
+				ND_PRINT((ndo, " <none!>"));
 		}
 			break;
 		case 508:		/* Get CPS */
@@ -1488,20 +1565,20 @@
 		case 519:		/* Get host CPS */
 		{
 			unsigned long j;
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			j = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 			for (i = 0; i < j; i++) {
 				INTOUT();
 			}
 			if (j == 0)
-				printf(" <none!>");
+				ND_PRINT((ndo, " <none!>"));
 		}
 			break;
 		case 510:		/* List max */
-			printf(" maxuid");
+			ND_PRINT((ndo, " maxuid"));
 			INTOUT();
-			printf(" maxgid");
+			ND_PRINT((ndo, " maxgid"));
 			INTOUT();
 			break;
 		default:
@@ -1511,14 +1588,14 @@
 		/*
 		 * Otherwise, just print out the return code
 		 */
-		printf(" errcode");
+		ND_PRINT((ndo, " errcode"));
 		INTOUT();
 	}
 
 	return;
 
 trunc:
-	printf(" [|pt]");
+	ND_PRINT((ndo, " [|pt]"));
 }
 
 /*
@@ -1526,7 +1603,8 @@
  */
 
 static void
-vldb_print(register const u_char *bp, int length)
+vldb_print(netdissect_options *ndo,
+           register const u_char *bp, int length)
 {
 	int vldb_op;
 	unsigned long i;
@@ -1534,7 +1612,7 @@
 	if (length <= (int)sizeof(struct rx_header))
 		return;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
 		goto trunc;
 	}
 
@@ -1545,13 +1623,13 @@
 
 	vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" vldb");
+	ND_PRINT((ndo, " vldb"));
 
 	if (is_ubik(vldb_op)) {
-		ubik_print(bp);
+		ubik_print(ndo, bp);
 		return;
 	}
-	printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op));
+	ND_PRINT((ndo, " call %s", tok2str(vldb_req, "op#%d", vldb_op)));
 
 	/*
 	 * Decode some of the arguments to the VLDB calls
@@ -1570,13 +1648,13 @@
 		case 508:	/* Set lock */
 		case 509:	/* Release lock */
 		case 518:	/* Get entry by ID N */
-			printf(" volid");
+			ND_PRINT((ndo, " volid"));
 			INTOUT();
-			TCHECK2(bp[0], sizeof(int32_t));
+			ND_TCHECK2(bp[0], sizeof(int32_t));
 			i = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 			if (i <= 2)
-				printf(" type %s", voltype[i]);
+				ND_PRINT((ndo, " type %s", voltype[i]));
 			break;
 		case 504:	/* Get entry by name */
 		case 519:	/* Get entry by name N */
@@ -1585,23 +1663,23 @@
 			STROUT(VLNAMEMAX);
 			break;
 		case 505:	/* Get new vol id */
-			printf(" bump");
+			ND_PRINT((ndo, " bump"));
 			INTOUT();
 			break;
 		case 506:	/* Replace entry */
 		case 520:	/* Replace entry N */
-			printf(" volid");
+			ND_PRINT((ndo, " volid"));
 			INTOUT();
-			TCHECK2(bp[0], sizeof(int32_t));
+			ND_TCHECK2(bp[0], sizeof(int32_t));
 			i = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 			if (i <= 2)
-				printf(" type %s", voltype[i]);
+				ND_PRINT((ndo, " type %s", voltype[i]));
 			VECOUT(VLNAMEMAX);
 			break;
 		case 510:	/* List entry */
 		case 521:	/* List entry N */
-			printf(" index");
+			ND_PRINT((ndo, " index"));
 			INTOUT();
 			break;
 		default:
@@ -1611,7 +1689,7 @@
 	return;
 
 trunc:
-	printf(" [|vldb]");
+	ND_PRINT((ndo, " [|vldb]"));
 }
 
 /*
@@ -1619,7 +1697,8 @@
  */
 
 static void
-vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
+vldb_reply_print(netdissect_options *ndo,
+                 register const u_char *bp, int length, int32_t opcode)
 {
 	struct rx_header *rxh;
 	unsigned long i;
@@ -1635,14 +1714,14 @@
 	 * Ubik call, however.
 	 */
 
-	printf(" vldb");
+	ND_PRINT((ndo, " vldb"));
 
 	if (is_ubik(opcode)) {
-		ubik_reply_print(bp, length, opcode);
+		ubik_reply_print(ndo, bp, length, opcode);
 		return;
 	}
 
-	printf(" reply %s", tok2str(vldb_req, "op#%d", opcode));
+	ND_PRINT((ndo, " reply %s", tok2str(vldb_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -1653,93 +1732,93 @@
 	if (rxh->type == RX_PACKET_TYPE_DATA)
 		switch (opcode) {
 		case 510:	/* List entry */
-			printf(" count");
+			ND_PRINT((ndo, " count"));
 			INTOUT();
-			printf(" nextindex");
+			ND_PRINT((ndo, " nextindex"));
 			INTOUT();
 		case 503:	/* Get entry by id */
 		case 504:	/* Get entry by name */
 		{	unsigned long nservers, j;
 			VECOUT(VLNAMEMAX);
-			TCHECK2(bp[0], sizeof(int32_t));
+			ND_TCHECK2(bp[0], sizeof(int32_t));
 			bp += sizeof(int32_t);
-			printf(" numservers");
-			TCHECK2(bp[0], sizeof(int32_t));
+			ND_PRINT((ndo, " numservers"));
+			ND_TCHECK2(bp[0], sizeof(int32_t));
 			nservers = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
-			printf(" %lu", nservers);
-			printf(" servers");
+			ND_PRINT((ndo, " %lu", nservers));
+			ND_PRINT((ndo, " servers"));
 			for (i = 0; i < 8; i++) {
-				TCHECK2(bp[0], sizeof(int32_t));
+				ND_TCHECK2(bp[0], sizeof(int32_t));
 				if (i < nservers)
-					printf(" %s",
-					   intoa(((struct in_addr *) bp)->s_addr));
+					ND_PRINT((ndo, " %s",
+					   intoa(((struct in_addr *) bp)->s_addr)));
 				bp += sizeof(int32_t);
 			}
-			printf(" partitions");
+			ND_PRINT((ndo, " partitions"));
 			for (i = 0; i < 8; i++) {
-				TCHECK2(bp[0], sizeof(int32_t));
+				ND_TCHECK2(bp[0], sizeof(int32_t));
 				j = EXTRACT_32BITS(bp);
 				if (i < nservers && j <= 26)
-					printf(" %c", 'a' + (int)j);
+					ND_PRINT((ndo, " %c", 'a' + (int)j));
 				else if (i < nservers)
-					printf(" %lu", j);
+					ND_PRINT((ndo, " %lu", j));
 				bp += sizeof(int32_t);
 			}
-			TCHECK2(bp[0], 8 * sizeof(int32_t));
+			ND_TCHECK2(bp[0], 8 * sizeof(int32_t));
 			bp += 8 * sizeof(int32_t);
-			printf(" rwvol");
+			ND_PRINT((ndo, " rwvol"));
 			UINTOUT();
-			printf(" rovol");
+			ND_PRINT((ndo, " rovol"));
 			UINTOUT();
-			printf(" backup");
+			ND_PRINT((ndo, " backup"));
 			UINTOUT();
 		}
 			break;
 		case 505:	/* Get new volume ID */
-			printf(" newvol");
+			ND_PRINT((ndo, " newvol"));
 			UINTOUT();
 			break;
 		case 521:	/* List entry */
 		case 529:	/* List entry U */
-			printf(" count");
+			ND_PRINT((ndo, " count"));
 			INTOUT();
-			printf(" nextindex");
+			ND_PRINT((ndo, " nextindex"));
 			INTOUT();
 		case 518:	/* Get entry by ID N */
 		case 519:	/* Get entry by name N */
 		{	unsigned long nservers, j;
 			VECOUT(VLNAMEMAX);
-			printf(" numservers");
-			TCHECK2(bp[0], sizeof(int32_t));
+			ND_PRINT((ndo, " numservers"));
+			ND_TCHECK2(bp[0], sizeof(int32_t));
 			nservers = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
-			printf(" %lu", nservers);
-			printf(" servers");
+			ND_PRINT((ndo, " %lu", nservers));
+			ND_PRINT((ndo, " servers"));
 			for (i = 0; i < 13; i++) {
-				TCHECK2(bp[0], sizeof(int32_t));
+				ND_TCHECK2(bp[0], sizeof(int32_t));
 				if (i < nservers)
-					printf(" %s",
-					   intoa(((struct in_addr *) bp)->s_addr));
+					ND_PRINT((ndo, " %s",
+					   intoa(((struct in_addr *) bp)->s_addr)));
 				bp += sizeof(int32_t);
 			}
-			printf(" partitions");
+			ND_PRINT((ndo, " partitions"));
 			for (i = 0; i < 13; i++) {
-				TCHECK2(bp[0], sizeof(int32_t));
+				ND_TCHECK2(bp[0], sizeof(int32_t));
 				j = EXTRACT_32BITS(bp);
 				if (i < nservers && j <= 26)
-					printf(" %c", 'a' + (int)j);
+					ND_PRINT((ndo, " %c", 'a' + (int)j));
 				else if (i < nservers)
-					printf(" %lu", j);
+					ND_PRINT((ndo, " %lu", j));
 				bp += sizeof(int32_t);
 			}
-			TCHECK2(bp[0], 13 * sizeof(int32_t));
+			ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
 			bp += 13 * sizeof(int32_t);
-			printf(" rwvol");
+			ND_PRINT((ndo, " rwvol"));
 			UINTOUT();
-			printf(" rovol");
+			ND_PRINT((ndo, " rovol"));
 			UINTOUT();
-			printf(" backup");
+			ND_PRINT((ndo, " backup"));
 			UINTOUT();
 		}
 			break;
@@ -1747,40 +1826,40 @@
 		case 527:	/* Get entry by name U */
 		{	unsigned long nservers, j;
 			VECOUT(VLNAMEMAX);
-			printf(" numservers");
-			TCHECK2(bp[0], sizeof(int32_t));
+			ND_PRINT((ndo, " numservers"));
+			ND_TCHECK2(bp[0], sizeof(int32_t));
 			nservers = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
-			printf(" %lu", nservers);
-			printf(" servers");
+			ND_PRINT((ndo, " %lu", nservers));
+			ND_PRINT((ndo, " servers"));
 			for (i = 0; i < 13; i++) {
 				if (i < nservers) {
-					printf(" afsuuid");
+					ND_PRINT((ndo, " afsuuid"));
 					AFSUUIDOUT();
 				} else {
-					TCHECK2(bp[0], 44);
+					ND_TCHECK2(bp[0], 44);
 					bp += 44;
 				}
 			}
-			TCHECK2(bp[0], 4 * 13);
+			ND_TCHECK2(bp[0], 4 * 13);
 			bp += 4 * 13;
-			printf(" partitions");
+			ND_PRINT((ndo, " partitions"));
 			for (i = 0; i < 13; i++) {
-				TCHECK2(bp[0], sizeof(int32_t));
+				ND_TCHECK2(bp[0], sizeof(int32_t));
 				j = EXTRACT_32BITS(bp);
 				if (i < nservers && j <= 26)
-					printf(" %c", 'a' + (int)j);
+					ND_PRINT((ndo, " %c", 'a' + (int)j));
 				else if (i < nservers)
-					printf(" %lu", j);
+					ND_PRINT((ndo, " %lu", j));
 				bp += sizeof(int32_t);
 			}
-			TCHECK2(bp[0], 13 * sizeof(int32_t));
+			ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
 			bp += 13 * sizeof(int32_t);
-			printf(" rwvol");
+			ND_PRINT((ndo, " rwvol"));
 			UINTOUT();
-			printf(" rovol");
+			ND_PRINT((ndo, " rovol"));
 			UINTOUT();
-			printf(" backup");
+			ND_PRINT((ndo, " backup"));
 			UINTOUT();
 		}
 		default:
@@ -1791,14 +1870,14 @@
 		/*
 		 * Otherwise, just print out the return code
 		 */
-		printf(" errcode");
+		ND_PRINT((ndo, " errcode"));
 		INTOUT();
 	}
 
 	return;
 
 trunc:
-	printf(" [|vldb]");
+	ND_PRINT((ndo, " [|vldb]"));
 }
 
 /*
@@ -1806,14 +1885,15 @@
  */
 
 static void
-kauth_print(register const u_char *bp, int length)
+kauth_print(netdissect_options *ndo,
+            register const u_char *bp, int length)
 {
 	int kauth_op;
 
 	if (length <= (int)sizeof(struct rx_header))
 		return;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
 		goto trunc;
 	}
 
@@ -1824,15 +1904,15 @@
 
 	kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" kauth");
+	ND_PRINT((ndo, " kauth"));
 
 	if (is_ubik(kauth_op)) {
-		ubik_print(bp);
+		ubik_print(ndo, bp);
 		return;
 	}
 
 
-	printf(" call %s", tok2str(kauth_req, "op#%d", kauth_op));
+	ND_PRINT((ndo, " call %s", tok2str(kauth_req, "op#%d", kauth_op)));
 
 	/*
 	 * Decode some of the arguments to the KA calls
@@ -1851,7 +1931,7 @@
 		case 8:		/* Get entry */
 		case 14:	/* Unlock */
 		case 15:	/* Lock status */
-			printf(" principal");
+			ND_PRINT((ndo, " principal"));
 			STROUT(KANAMEMAX);
 			STROUT(KANAMEMAX);
 			break;
@@ -1859,29 +1939,29 @@
 		case 23:	/* GetTicket */
 		{
 			int i;
-			printf(" kvno");
+			ND_PRINT((ndo, " kvno"));
 			INTOUT();
-			printf(" domain");
+			ND_PRINT((ndo, " domain"));
 			STROUT(KANAMEMAX);
-			TCHECK2(bp[0], sizeof(int32_t));
+			ND_TCHECK2(bp[0], sizeof(int32_t));
 			i = (int) EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
-			TCHECK2(bp[0], i);
+			ND_TCHECK2(bp[0], i);
 			bp += i;
-			printf(" principal");
+			ND_PRINT((ndo, " principal"));
 			STROUT(KANAMEMAX);
 			STROUT(KANAMEMAX);
 			break;
 		}
 		case 4:		/* Set Password */
-			printf(" principal");
+			ND_PRINT((ndo, " principal"));
 			STROUT(KANAMEMAX);
 			STROUT(KANAMEMAX);
-			printf(" kvno");
+			ND_PRINT((ndo, " kvno"));
 			INTOUT();
 			break;
 		case 12:	/* Get password */
-			printf(" name");
+			ND_PRINT((ndo, " name"));
 			STROUT(KANAMEMAX);
 			break;
 		default:
@@ -1891,7 +1971,7 @@
 	return;
 
 trunc:
-	printf(" [|kauth]");
+	ND_PRINT((ndo, " [|kauth]"));
 }
 
 /*
@@ -1899,7 +1979,8 @@
  */
 
 static void
-kauth_reply_print(register const u_char *bp, int length, int32_t opcode)
+kauth_reply_print(netdissect_options *ndo,
+                  register const u_char *bp, int length, int32_t opcode)
 {
 	struct rx_header *rxh;
 
@@ -1913,14 +1994,14 @@
 	 * gleaned from kauth/kauth.rg
 	 */
 
-	printf(" kauth");
+	ND_PRINT((ndo, " kauth"));
 
 	if (is_ubik(opcode)) {
-		ubik_reply_print(bp, length, opcode);
+		ubik_reply_print(ndo, bp, length, opcode);
 		return;
 	}
 
-	printf(" reply %s", tok2str(kauth_req, "op#%d", opcode));
+	ND_PRINT((ndo, " reply %s", tok2str(kauth_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -1935,14 +2016,14 @@
 		/*
 		 * Otherwise, just print out the return code
 		 */
-		printf(" errcode");
+		ND_PRINT((ndo, " errcode"));
 		INTOUT();
 	}
 
 	return;
 
 trunc:
-	printf(" [|kauth]");
+	ND_PRINT((ndo, " [|kauth]"));
 }
 
 /*
@@ -1950,14 +2031,15 @@
  */
 
 static void
-vol_print(register const u_char *bp, int length)
+vol_print(netdissect_options *ndo,
+          register const u_char *bp, int length)
 {
 	int vol_op;
 
 	if (length <= (int)sizeof(struct rx_header))
 		return;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
 		goto trunc;
 	}
 
@@ -1968,126 +2050,126 @@
 
 	vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op));
+	ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op)));
 
 	bp += sizeof(struct rx_header) + 4;
 
 	switch (vol_op) {
 		case 100:	/* Create volume */
-			printf(" partition");
+			ND_PRINT((ndo, " partition"));
 			UINTOUT();
-			printf(" name");
+			ND_PRINT((ndo, " name"));
 			STROUT(AFSNAMEMAX);
-			printf(" type");
+			ND_PRINT((ndo, " type"));
 			UINTOUT();
-			printf(" parent");
+			ND_PRINT((ndo, " parent"));
 			UINTOUT();
 			break;
 		case 101:	/* Delete volume */
 		case 107:	/* Get flags */
-			printf(" trans");
+			ND_PRINT((ndo, " trans"));
 			UINTOUT();
 			break;
 		case 102:	/* Restore */
-			printf(" totrans");
+			ND_PRINT((ndo, " totrans"));
 			UINTOUT();
-			printf(" flags");
+			ND_PRINT((ndo, " flags"));
 			UINTOUT();
 			break;
 		case 103:	/* Forward */
-			printf(" fromtrans");
+			ND_PRINT((ndo, " fromtrans"));
 			UINTOUT();
-			printf(" fromdate");
+			ND_PRINT((ndo, " fromdate"));
 			DATEOUT();
 			DESTSERVEROUT();
-			printf(" desttrans");
+			ND_PRINT((ndo, " desttrans"));
 			INTOUT();
 			break;
 		case 104:	/* End trans */
-			printf(" trans");
+			ND_PRINT((ndo, " trans"));
 			UINTOUT();
 			break;
 		case 105:	/* Clone */
-			printf(" trans");
+			ND_PRINT((ndo, " trans"));
 			UINTOUT();
-			printf(" purgevol");
+			ND_PRINT((ndo, " purgevol"));
 			UINTOUT();
-			printf(" newtype");
+			ND_PRINT((ndo, " newtype"));
 			UINTOUT();
-			printf(" newname");
+			ND_PRINT((ndo, " newname"));
 			STROUT(AFSNAMEMAX);
 			break;
 		case 106:	/* Set flags */
-			printf(" trans");
+			ND_PRINT((ndo, " trans"));
 			UINTOUT();
-			printf(" flags");
+			ND_PRINT((ndo, " flags"));
 			UINTOUT();
 			break;
 		case 108:	/* Trans create */
-			printf(" vol");
+			ND_PRINT((ndo, " vol"));
 			UINTOUT();
-			printf(" partition");
+			ND_PRINT((ndo, " partition"));
 			UINTOUT();
-			printf(" flags");
+			ND_PRINT((ndo, " flags"));
 			UINTOUT();
 			break;
 		case 109:	/* Dump */
 		case 655537:	/* Get size */
-			printf(" fromtrans");
+			ND_PRINT((ndo, " fromtrans"));
 			UINTOUT();
-			printf(" fromdate");
+			ND_PRINT((ndo, " fromdate"));
 			DATEOUT();
 			break;
 		case 110:	/* Get n-th volume */
-			printf(" index");
+			ND_PRINT((ndo, " index"));
 			UINTOUT();
 			break;
 		case 111:	/* Set forwarding */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UINTOUT();
-			printf(" newsite");
+			ND_PRINT((ndo, " newsite"));
 			UINTOUT();
 			break;
 		case 112:	/* Get name */
 		case 113:	/* Get status */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			break;
 		case 114:	/* Signal restore */
-			printf(" name");
+			ND_PRINT((ndo, " name"));
 			STROUT(AFSNAMEMAX);
-			printf(" type");
+			ND_PRINT((ndo, " type"));
 			UINTOUT();
-			printf(" pid");
+			ND_PRINT((ndo, " pid"));
 			UINTOUT();
-			printf(" cloneid");
+			ND_PRINT((ndo, " cloneid"));
 			UINTOUT();
 			break;
 		case 116:	/* List volumes */
-			printf(" partition");
+			ND_PRINT((ndo, " partition"));
 			UINTOUT();
-			printf(" flags");
+			ND_PRINT((ndo, " flags"));
 			UINTOUT();
 			break;
 		case 117:	/* Set id types */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UINTOUT();
-			printf(" name");
+			ND_PRINT((ndo, " name"));
 			STROUT(AFSNAMEMAX);
-			printf(" type");
+			ND_PRINT((ndo, " type"));
 			UINTOUT();
-			printf(" pid");
+			ND_PRINT((ndo, " pid"));
 			UINTOUT();
-			printf(" clone");
+			ND_PRINT((ndo, " clone"));
 			UINTOUT();
-			printf(" backup");
+			ND_PRINT((ndo, " backup"));
 			UINTOUT();
 			break;
 		case 119:	/* Partition info */
-			printf(" name");
+			ND_PRINT((ndo, " name"));
 			STROUT(AFSNAMEMAX);
 			break;
 		case 120:	/* Reclone */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UINTOUT();
 			break;
 		case 121:	/* List one volume */
@@ -2095,46 +2177,46 @@
 		case 124:	/* Extended List volumes */
 		case 125:	/* Extended List one volume */
 		case 65536:	/* Convert RO to RW volume */
-			printf(" partid");
+			ND_PRINT((ndo, " partid"));
 			UINTOUT();
-			printf(" volid");
+			ND_PRINT((ndo, " volid"));
 			UINTOUT();
 			break;
 		case 123:	/* Set date */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UINTOUT();
-			printf(" date");
+			ND_PRINT((ndo, " date"));
 			DATEOUT();
 			break;
 		case 126:	/* Set info */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UINTOUT();
 			break;
 		case 128:	/* Forward multiple */
-			printf(" fromtrans");
+			ND_PRINT((ndo, " fromtrans"));
 			UINTOUT();
-			printf(" fromdate");
+			ND_PRINT((ndo, " fromdate"));
 			DATEOUT();
 			{
 				unsigned long i, j;
-				TCHECK2(bp[0], 4);
+				ND_TCHECK2(bp[0], 4);
 				j = EXTRACT_32BITS(bp);
 				bp += sizeof(int32_t);
 				for (i = 0; i < j; i++) {
 					DESTSERVEROUT();
 					if (i != j - 1)
-						printf(",");
+						ND_PRINT((ndo, ","));
 				}
 				if (j == 0)
-					printf(" <none!>");
+					ND_PRINT((ndo, " <none!>"));
 			}
 			break;
 		case 65538:	/* Dump version 2 */
-			printf(" fromtrans");
+			ND_PRINT((ndo, " fromtrans"));
 			UINTOUT();
-			printf(" fromdate");
+			ND_PRINT((ndo, " fromdate"));
 			DATEOUT();
-			printf(" flags");
+			ND_PRINT((ndo, " flags"));
 			UINTOUT();
 			break;
 		default:
@@ -2143,7 +2225,7 @@
 	return;
 
 trunc:
-	printf(" [|vol]");
+	ND_PRINT((ndo, " [|vol]"));
 }
 
 /*
@@ -2151,7 +2233,8 @@
  */
 
 static void
-vol_reply_print(register const u_char *bp, int length, int32_t opcode)
+vol_reply_print(netdissect_options *ndo,
+                register const u_char *bp, int length, int32_t opcode)
 {
 	struct rx_header *rxh;
 
@@ -2165,7 +2248,7 @@
 	 * gleaned from volser/volint.xg
 	 */
 
-	printf(" vol reply %s", tok2str(vol_req, "op#%d", opcode));
+	ND_PRINT((ndo, " vol reply %s", tok2str(vol_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -2176,66 +2259,66 @@
 	if (rxh->type == RX_PACKET_TYPE_DATA) {
 		switch (opcode) {
 			case 100:	/* Create volume */
-				printf(" volid");
+				ND_PRINT((ndo, " volid"));
 				UINTOUT();
-				printf(" trans");
+				ND_PRINT((ndo, " trans"));
 				UINTOUT();
 				break;
 			case 104:	/* End transaction */
 				UINTOUT();
 				break;
 			case 105:	/* Clone */
-				printf(" newvol");
+				ND_PRINT((ndo, " newvol"));
 				UINTOUT();
 				break;
 			case 107:	/* Get flags */
 				UINTOUT();
 				break;
 			case 108:	/* Transaction create */
-				printf(" trans");
+				ND_PRINT((ndo, " trans"));
 				UINTOUT();
 				break;
 			case 110:	/* Get n-th volume */
-				printf(" volume");
+				ND_PRINT((ndo, " volume"));
 				UINTOUT();
-				printf(" partition");
+				ND_PRINT((ndo, " partition"));
 				UINTOUT();
 				break;
 			case 112:	/* Get name */
 				STROUT(AFSNAMEMAX);
 				break;
 			case 113:	/* Get status */
-				printf(" volid");
+				ND_PRINT((ndo, " volid"));
 				UINTOUT();
-				printf(" nextuniq");
+				ND_PRINT((ndo, " nextuniq"));
 				UINTOUT();
-				printf(" type");
+				ND_PRINT((ndo, " type"));
 				UINTOUT();
-				printf(" parentid");
+				ND_PRINT((ndo, " parentid"));
 				UINTOUT();
-				printf(" clone");
+				ND_PRINT((ndo, " clone"));
 				UINTOUT();
-				printf(" backup");
+				ND_PRINT((ndo, " backup"));
 				UINTOUT();
-				printf(" restore");
+				ND_PRINT((ndo, " restore"));
 				UINTOUT();
-				printf(" maxquota");
+				ND_PRINT((ndo, " maxquota"));
 				UINTOUT();
-				printf(" minquota");
+				ND_PRINT((ndo, " minquota"));
 				UINTOUT();
-				printf(" owner");
+				ND_PRINT((ndo, " owner"));
 				UINTOUT();
-				printf(" create");
+				ND_PRINT((ndo, " create"));
 				DATEOUT();
-				printf(" access");
+				ND_PRINT((ndo, " access"));
 				DATEOUT();
-				printf(" update");
+				ND_PRINT((ndo, " update"));
 				DATEOUT();
-				printf(" expire");
+				ND_PRINT((ndo, " expire"));
 				DATEOUT();
-				printf(" backup");
+				ND_PRINT((ndo, " backup"));
 				DATEOUT();
-				printf(" copy");
+				ND_PRINT((ndo, " copy"));
 				DATEOUT();
 				break;
 			case 115:	/* Old list partitions */
@@ -2244,24 +2327,24 @@
 			case 121:	/* List one volume */
 				{
 					unsigned long i, j;
-					TCHECK2(bp[0], 4);
+					ND_TCHECK2(bp[0], 4);
 					j = EXTRACT_32BITS(bp);
 					bp += sizeof(int32_t);
 					for (i = 0; i < j; i++) {
-						printf(" name");
+						ND_PRINT((ndo, " name"));
 						VECOUT(32);
-						printf(" volid");
+						ND_PRINT((ndo, " volid"));
 						UINTOUT();
-						printf(" type");
+						ND_PRINT((ndo, " type"));
 						bp += sizeof(int32_t) * 21;
 						if (i != j - 1)
-							printf(",");
+							ND_PRINT((ndo, ","));
 					}
 					if (j == 0)
-						printf(" <none!>");
+						ND_PRINT((ndo, " <none!>"));
 				}
 				break;
-				
+
 
 			default:
 				;
@@ -2270,14 +2353,14 @@
 		/*
 		 * Otherwise, just print out the return code
 		 */
-		printf(" errcode");
+		ND_PRINT((ndo, " errcode"));
 		INTOUT();
 	}
 
 	return;
 
 trunc:
-	printf(" [|vol]");
+	ND_PRINT((ndo, " [|vol]"));
 }
 
 /*
@@ -2285,14 +2368,15 @@
  */
 
 static void
-bos_print(register const u_char *bp, int length)
+bos_print(netdissect_options *ndo,
+          register const u_char *bp, int length)
 {
 	int bos_op;
 
 	if (length <= (int)sizeof(struct rx_header))
 		return;
 
-	if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+	if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
 		goto trunc;
 	}
 
@@ -2303,7 +2387,7 @@
 
 	bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op));
+	ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op)));
 
 	/*
 	 * Decode some of the arguments to the BOS calls
@@ -2313,9 +2397,9 @@
 
 	switch (bos_op) {
 		case 80:	/* Create B node */
-			printf(" type");
+			ND_PRINT((ndo, " type"));
 			STROUT(BOSNAMEMAX);
-			printf(" instance");
+			ND_PRINT((ndo, " instance"));
 			STROUT(BOSNAMEMAX);
 			break;
 		case 81:	/* Delete B node */
@@ -2336,12 +2420,12 @@
 		case 82:	/* Set status */
 		case 98:	/* Set T status */
 			STROUT(BOSNAMEMAX);
-			printf(" status");
+			ND_PRINT((ndo, " status"));
 			INTOUT();
 			break;
 		case 86:	/* Get instance parm */
 			STROUT(BOSNAMEMAX);
-			printf(" num");
+			ND_PRINT((ndo, " num"));
 			INTOUT();
 			break;
 		case 84:	/* Enumerate instance */
@@ -2354,11 +2438,11 @@
 			break;
 		case 105:	/* Install */
 			STROUT(BOSNAMEMAX);
-			printf(" size");
+			ND_PRINT((ndo, " size"));
 			INTOUT();
-			printf(" flags");
+			ND_PRINT((ndo, " flags"));
 			INTOUT();
-			printf(" date");
+			ND_PRINT((ndo, " date"));
 			INTOUT();
 			break;
 		default:
@@ -2368,7 +2452,7 @@
 	return;
 
 trunc:
-	printf(" [|bos]");
+	ND_PRINT((ndo, " [|bos]"));
 }
 
 /*
@@ -2376,7 +2460,8 @@
  */
 
 static void
-bos_reply_print(register const u_char *bp, int length, int32_t opcode)
+bos_reply_print(netdissect_options *ndo,
+                register const u_char *bp, int length, int32_t opcode)
 {
 	struct rx_header *rxh;
 
@@ -2390,7 +2475,7 @@
 	 * gleaned from volser/volint.xg
 	 */
 
-	printf(" bos reply %s", tok2str(bos_req, "op#%d", opcode));
+	ND_PRINT((ndo, " bos reply %s", tok2str(bos_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -2405,14 +2490,14 @@
 		/*
 		 * Otherwise, just print out the return code
 		 */
-		printf(" errcode");
+		ND_PRINT((ndo, " errcode"));
 		INTOUT();
 	}
 
 	return;
 
 trunc:
-	printf(" [|bos]");
+	ND_PRINT((ndo, " [|bos]"));
 }
 
 /*
@@ -2420,7 +2505,7 @@
  */
 
 static int
-is_ubik(u_int32_t opcode)
+is_ubik(uint32_t opcode)
 {
 	if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
 	    (opcode >= DISK_LOW && opcode <= DISK_HIGH))
@@ -2434,7 +2519,8 @@
  */
 
 static void
-ubik_print(register const u_char *bp)
+ubik_print(netdissect_options *ndo,
+           register const u_char *bp)
 {
 	int ubik_op;
 	int32_t temp;
@@ -2446,7 +2532,7 @@
 
 	ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 
-	printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op));
+	ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)));
 
 	/*
 	 * Decode some of the arguments to the Ubik calls
@@ -2456,19 +2542,19 @@
 
 	switch (ubik_op) {
 		case 10000:		/* Beacon */
-			TCHECK2(bp[0], 4);
+			ND_TCHECK2(bp[0], 4);
 			temp = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
-			printf(" syncsite %s", temp ? "yes" : "no");
-			printf(" votestart");
+			ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no"));
+			ND_PRINT((ndo, " votestart"));
 			DATEOUT();
-			printf(" dbversion");
+			ND_PRINT((ndo, " dbversion"));
 			UBIK_VERSIONOUT();
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UBIK_VERSIONOUT();
 			break;
 		case 10003:		/* Get sync site */
-			printf(" site");
+			ND_PRINT((ndo, " site"));
 			UINTOUT();
 			break;
 		case 20000:		/* Begin */
@@ -2476,56 +2562,56 @@
 		case 20007:		/* Abort */
 		case 20008:		/* Release locks */
 		case 20010:		/* Writev */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UBIK_VERSIONOUT();
 			break;
 		case 20002:		/* Lock */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UBIK_VERSIONOUT();
-			printf(" file");
+			ND_PRINT((ndo, " file"));
 			INTOUT();
-			printf(" pos");
+			ND_PRINT((ndo, " pos"));
 			INTOUT();
-			printf(" length");
+			ND_PRINT((ndo, " length"));
 			INTOUT();
 			temp = EXTRACT_32BITS(bp);
 			bp += sizeof(int32_t);
 			tok2str(ubik_lock_types, "type %d", temp);
 			break;
 		case 20003:		/* Write */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UBIK_VERSIONOUT();
-			printf(" file");
+			ND_PRINT((ndo, " file"));
 			INTOUT();
-			printf(" pos");
+			ND_PRINT((ndo, " pos"));
 			INTOUT();
 			break;
 		case 20005:		/* Get file */
-			printf(" file");
+			ND_PRINT((ndo, " file"));
 			INTOUT();
 			break;
 		case 20006:		/* Send file */
-			printf(" file");
+			ND_PRINT((ndo, " file"));
 			INTOUT();
-			printf(" length");
+			ND_PRINT((ndo, " length"));
 			INTOUT();
-			printf(" dbversion");
+			ND_PRINT((ndo, " dbversion"));
 			UBIK_VERSIONOUT();
 			break;
 		case 20009:		/* Truncate */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UBIK_VERSIONOUT();
-			printf(" file");
+			ND_PRINT((ndo, " file"));
 			INTOUT();
-			printf(" length");
+			ND_PRINT((ndo, " length"));
 			INTOUT();
 			break;
 		case 20012:		/* Set version */
-			printf(" tid");
+			ND_PRINT((ndo, " tid"));
 			UBIK_VERSIONOUT();
-			printf(" oldversion");
+			ND_PRINT((ndo, " oldversion"));
 			UBIK_VERSIONOUT();
-			printf(" newversion");
+			ND_PRINT((ndo, " newversion"));
 			UBIK_VERSIONOUT();
 			break;
 		default:
@@ -2535,7 +2621,7 @@
 	return;
 
 trunc:
-	printf(" [|ubik]");
+	ND_PRINT((ndo, " [|ubik]"));
 }
 
 /*
@@ -2543,7 +2629,8 @@
  */
 
 static void
-ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
+ubik_reply_print(netdissect_options *ndo,
+                 register const u_char *bp, int length, int32_t opcode)
 {
 	struct rx_header *rxh;
 
@@ -2557,7 +2644,7 @@
 	 * from ubik/ubik_int.xg
 	 */
 
-	printf(" ubik reply %s", tok2str(ubik_req, "op#%d", opcode));
+	ND_PRINT((ndo, " ubik reply %s", tok2str(ubik_req, "op#%d", opcode)));
 
 	bp += sizeof(struct rx_header);
 
@@ -2568,10 +2655,10 @@
 	if (rxh->type == RX_PACKET_TYPE_DATA)
 		switch (opcode) {
 		case 10000:		/* Beacon */
-			printf(" vote no");
+			ND_PRINT((ndo, " vote no"));
 			break;
 		case 20004:		/* Get version */
-			printf(" dbversion");
+			ND_PRINT((ndo, " dbversion"));
 			UBIK_VERSIONOUT();
 			break;
 		default:
@@ -2587,18 +2674,18 @@
 	else
 		switch (opcode) {
 		case 10000:		/* Beacon */
-			printf(" vote yes until");
+			ND_PRINT((ndo, " vote yes until"));
 			DATEOUT();
 			break;
 		default:
-			printf(" errcode");
+			ND_PRINT((ndo, " errcode"));
 			INTOUT();
 		}
 
 	return;
 
 trunc:
-	printf(" [|ubik]");
+	ND_PRINT((ndo, " [|ubik]"));
 }
 
 /*
@@ -2606,11 +2693,12 @@
  */
 
 static void
-rx_ack_print(register const u_char *bp, int length)
+rx_ack_print(netdissect_options *ndo,
+             register const u_char *bp, int length)
 {
 	struct rx_ackPacket *rxa;
 	int i, start, last;
-	u_int32_t firstPacket;
+	uint32_t firstPacket;
 
 	if (length < (int)sizeof(struct rx_header))
 		return;
@@ -2625,7 +2713,7 @@
 	 * rx_ackPacket structure.
 	 */
 
-	TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
+	ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
 
 	rxa = (struct rx_ackPacket *) bp;
 	bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS);
@@ -2634,15 +2722,15 @@
 	 * Print out a few useful things from the ack packet structure
 	 */
 
-	if (vflag > 2)
-		printf(" bufspace %d maxskew %d",
+	if (ndo->ndo_vflag > 2)
+		ND_PRINT((ndo, " bufspace %d maxskew %d",
 		       (int) EXTRACT_16BITS(&rxa->bufferSpace),
-		       (int) EXTRACT_16BITS(&rxa->maxSkew));
+		       (int) EXTRACT_16BITS(&rxa->maxSkew)));
 
 	firstPacket = EXTRACT_32BITS(&rxa->firstPacket);
-	printf(" first %d serial %d reason %s",
+	ND_PRINT((ndo, " first %d serial %d reason %s",
 	       firstPacket, EXTRACT_32BITS(&rxa->serial),
-	       tok2str(rx_ack_reasons, "#%d", (int) rxa->reason));
+	       tok2str(rx_ack_reasons, "#%d", (int) rxa->reason)));
 
 	/*
 	 * Okay, now we print out the ack array.  The way _this_ works
@@ -2665,7 +2753,7 @@
 
 	if (rxa->nAcks != 0) {
 
-		TCHECK2(bp[0], rxa->nAcks);
+		ND_TCHECK2(bp[0], rxa->nAcks);
 
 		/*
 		 * Sigh, this is gross, but it seems to work to collapse
@@ -2683,13 +2771,12 @@
 				 */
 
 				if (last == -2) {
-					printf(" acked %d",
-					       firstPacket + i);
+					ND_PRINT((ndo, " acked %d", firstPacket + i));
 					start = i;
 				}
 
 				/*
-				 * Otherwise, if the there is a skip in
+				 * Otherwise, if there is a skip in
 				 * the range (such as an nacked packet in
 				 * the middle of some acked packets),
 				 * then print the current packet number
@@ -2698,7 +2785,7 @@
 				 */
 
 				else if (last != i - 1) {
-					printf(",%d", firstPacket + i);
+					ND_PRINT((ndo, ",%d", firstPacket + i));
 					start = i;
 				}
 
@@ -2724,7 +2811,7 @@
 				 * range.
 				 */
 			} else if (last == i - 1 && start != last)
-				printf("-%d", firstPacket + i - 1);
+				ND_PRINT((ndo, "-%d", firstPacket + i - 1));
 
 		/*
 		 * So, what's going on here?  We ran off the end of the
@@ -2738,7 +2825,7 @@
 		 */
 
 		if (last == i - 1 && start != last)
-			printf("-%d", firstPacket + i - 1);
+			ND_PRINT((ndo, "-%d", firstPacket + i - 1));
 
 		/*
 		 * Same as above, just without comments
@@ -2747,19 +2834,18 @@
 		for (i = 0, start = last = -2; i < rxa->nAcks; i++)
 			if (rxa->acks[i] == RX_ACK_TYPE_NACK) {
 				if (last == -2) {
-					printf(" nacked %d",
-					       firstPacket + i);
+					ND_PRINT((ndo, " nacked %d", firstPacket + i));
 					start = i;
 				} else if (last != i - 1) {
-					printf(",%d", firstPacket + i);
+					ND_PRINT((ndo, ",%d", firstPacket + i));
 					start = i;
 				}
 				last = i;
 			} else if (last == i - 1 && start != last)
-				printf("-%d", firstPacket + i - 1);
+				ND_PRINT((ndo, "-%d", firstPacket + i - 1));
 
 		if (last == i - 1 && start != last)
-			printf("-%d", firstPacket + i - 1);
+			ND_PRINT((ndo, "-%d", firstPacket + i - 1));
 
 		bp += rxa->nAcks;
 	}
@@ -2770,29 +2856,29 @@
 	 * you may or may not see them
 	 */
 
-#define TRUNCRET(n)	if (snapend - bp + 1 <= n) return;
+#define TRUNCRET(n)	if (ndo->ndo_snapend - bp + 1 <= n) return;
 
-	if (vflag > 1) {
+	if (ndo->ndo_vflag > 1) {
 		TRUNCRET(4);
-		printf(" ifmtu");
+		ND_PRINT((ndo, " ifmtu"));
 		INTOUT();
 
 		TRUNCRET(4);
-		printf(" maxmtu");
+		ND_PRINT((ndo, " maxmtu"));
 		INTOUT();
 
 		TRUNCRET(4);
-		printf(" rwind");
+		ND_PRINT((ndo, " rwind"));
 		INTOUT();
 
 		TRUNCRET(4);
-		printf(" maxpackets");
+		ND_PRINT((ndo, " maxpackets"));
 		INTOUT();
 	}
 
 	return;
 
 trunc:
-	printf(" [|ack]");
+	ND_PRINT((ndo, " [|ack]"));
 }
 #undef TRUNCRET
diff --git a/print-sctp.c b/print-sctp.c
index 5a4b1e9..4b595f2 100644
--- a/print-sctp.c
+++ b/print-sctp.c
@@ -33,24 +33,13 @@
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.21 2007-09-13 18:03:49 guy Exp $ (NETLAB/PEL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include "sctpHeader.h"
-#include "sctpConstants.h"
-#include <assert.h>
-
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"			/* must come after interface.h */
@@ -59,10 +48,368 @@
 #include "ip6.h"
 #endif
 
+/* Definitions from:
+ *
+ * SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. 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.
+ *
+ * 3. Neither the name of Cisco nor of Motorola may be used
+ *    to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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.
+ *
+ * This file is part of the SCTP reference Implementation
+ *
+ *
+ * Please send any bug reports or fixes you make to one of the following email
+ * addresses:
+ *
+ * rstewar1@email.mot.com
+ * kmorneau@cisco.com
+ * qxie1@email.mot.com
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorperated into the next SCTP release.
+ */
+
+/* The valid defines for all message
+ * types know to SCTP. 0 is reserved
+ */
+#define SCTP_DATA		0x00
+#define SCTP_INITIATION		0x01
+#define SCTP_INITIATION_ACK	0x02
+#define SCTP_SELECTIVE_ACK	0x03
+#define SCTP_HEARTBEAT_REQUEST	0x04
+#define SCTP_HEARTBEAT_ACK	0x05
+#define SCTP_ABORT_ASSOCIATION	0x06
+#define SCTP_SHUTDOWN		0x07
+#define SCTP_SHUTDOWN_ACK	0x08
+#define SCTP_OPERATION_ERR	0x09
+#define SCTP_COOKIE_ECHO	0x0a
+#define SCTP_COOKIE_ACK         0x0b
+#define SCTP_ECN_ECHO		0x0c
+#define SCTP_ECN_CWR		0x0d
+#define SCTP_SHUTDOWN_COMPLETE	0x0e
+#define SCTP_FORWARD_CUM_TSN    0xc0
+#define SCTP_RELIABLE_CNTL      0xc1
+#define SCTP_RELIABLE_CNTL_ACK  0xc2
+
+static const struct tok sctp_chunkid_str[] = {
+	{ SCTP_DATA,              "DATA"              },
+	{ SCTP_INITIATION,        "INIT"              },
+	{ SCTP_INITIATION_ACK,    "INIT ACK"          },
+	{ SCTP_SELECTIVE_ACK,     "SACK"              },
+	{ SCTP_HEARTBEAT_REQUEST, "HB REQ"            },
+	{ SCTP_HEARTBEAT_ACK,     "HB ACK"            },
+	{ SCTP_ABORT_ASSOCIATION, "ABORT"             },
+	{ SCTP_SHUTDOWN,          "SHUTDOWN"          },
+	{ SCTP_SHUTDOWN_ACK,      "SHUTDOWN ACK"      },
+	{ SCTP_OPERATION_ERR,     "OP ERR"            },
+	{ SCTP_COOKIE_ECHO,       "COOKIE ECHO"       },
+	{ SCTP_COOKIE_ACK,        "COOKIE ACK"        },
+	{ SCTP_ECN_ECHO,          "ECN ECHO"          },
+	{ SCTP_ECN_CWR,           "ECN CWR"           },
+	{ SCTP_SHUTDOWN_COMPLETE, "SHUTDOWN COMPLETE" },
+	{ SCTP_FORWARD_CUM_TSN,   "FOR CUM TSN"       },
+	{ SCTP_RELIABLE_CNTL,     "REL CTRL"          },
+	{ SCTP_RELIABLE_CNTL_ACK, "REL CTRL ACK"      },
+	{ 0, NULL }
+};
+
+/* Data Chuck Specific Flags */
+#define SCTP_DATA_FRAG_MASK	0x03
+#define SCTP_DATA_MIDDLE_FRAG	0x00
+#define SCTP_DATA_LAST_FRAG	0x01
+#define SCTP_DATA_FIRST_FRAG	0x02
+#define SCTP_DATA_NOT_FRAG	0x03
+#define SCTP_DATA_UNORDERED	0x04
+
+#define SCTP_ADDRMAX 60
+
 #define CHAN_HP 6704
 #define CHAN_MP 6705
 #define CHAN_LP 6706
 
+/* the sctp common header */
+
+struct sctpHeader{
+  uint16_t source;
+  uint16_t destination;
+  uint32_t verificationTag;
+  uint32_t adler32;
+};
+
+/* various descriptor parsers */
+
+struct sctpChunkDesc{
+  uint8_t chunkID;
+  uint8_t chunkFlg;
+  uint16_t chunkLength;
+};
+
+struct sctpParamDesc{
+  uint16_t paramType;
+  uint16_t paramLength;
+};
+
+
+struct sctpRelChunkDesc{
+  struct sctpChunkDesc chk;
+  uint32_t serialNumber;
+};
+
+struct sctpVendorSpecificParam {
+  struct sctpParamDesc p;  /* type must be 0xfffe */
+  uint32_t vendorId;	   /* vendor ID from RFC 1700 */
+  uint16_t vendorSpecificType;
+  uint16_t vendorSpecificLen;
+};
+
+
+/* Structures for the control parts */
+
+
+
+/* Sctp association init request/ack */
+
+/* this is used for init ack, too */
+struct sctpInitiation{
+  uint32_t initTag;		/* tag of mine */
+  uint32_t rcvWindowCredit;	/* rwnd */
+  uint16_t NumPreopenStreams;	/* OS */
+  uint16_t MaxInboundStreams;     /* MIS */
+  uint32_t initialTSN;
+  /* optional param's follow in sctpParamDesc form */
+};
+
+struct sctpV4IpAddress{
+  struct sctpParamDesc p;	/* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
+  uint32_t  ipAddress;
+};
+
+
+struct sctpV6IpAddress{
+  struct sctpParamDesc p;	/* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
+  uint8_t  ipAddress[16];
+};
+
+struct sctpDNSName{
+  struct sctpParamDesc param;
+  uint8_t name[1];
+};
+
+
+struct sctpCookiePreserve{
+  struct sctpParamDesc p;	/* type is set to SCTP_COOKIE_PRESERVE, len=8 */
+  uint32_t extraTime;
+};
+
+
+struct sctpTimeStamp{
+  uint32_t ts_sec;
+  uint32_t ts_usec;
+};
+
+/* wire structure of my cookie */
+struct cookieMessage{
+  uint32_t TieTag_curTag;		/* copied from assoc if present */
+  uint32_t TieTag_hisTag; 		/* copied from assoc if present */
+  int32_t cookieLife;			/* life I will award this cookie */
+  struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
+  struct sctpInitiation initAckISent;	/* the INIT-ACK that I sent to my peer */
+  uint32_t addressWhereISent[4];	/* I make this 4 ints so I get 128bits for future */
+  int32_t addrtype;			/* address type */
+  uint16_t locScope;			/* V6 local scope flag */
+  uint16_t siteScope;			/* V6 site scope flag */
+  /* at the end is tacked on the INIT chunk sent in
+   * its entirety and of course our
+   * signature.
+   */
+};
+
+
+/* this guy is for use when
+ * I have a initiate message gloming the
+ * things together.
+
+ */
+struct sctpUnifiedInit{
+  struct sctpChunkDesc uh;
+  struct sctpInitiation initm;
+};
+
+struct sctpSendableInit{
+  struct sctpHeader mh;
+  struct sctpUnifiedInit msg;
+};
+
+
+/* Selective Acknowledgement
+ * has the following structure with
+ * a optional ammount of trailing int's
+ * on the last part (based on the numberOfDesc
+ * field).
+ */
+
+struct sctpSelectiveAck{
+  uint32_t highestConseqTSN;
+  uint32_t updatedRwnd;
+  uint16_t numberOfdesc;
+  uint16_t numDupTsns;
+};
+
+struct sctpSelectiveFrag{
+  uint16_t fragmentStart;
+  uint16_t fragmentEnd;
+};
+
+
+struct sctpUnifiedSack{
+  struct sctpChunkDesc uh;
+  struct sctpSelectiveAck sack;
+};
+
+/* for both RTT request/response the
+ * following is sent
+ */
+
+struct sctpHBrequest {
+  uint32_t time_value_1;
+  uint32_t time_value_2;
+};
+
+/* here is what I read and respond with to. */
+struct sctpHBunified{
+  struct sctpChunkDesc hdr;
+  struct sctpParamDesc hb;
+};
+
+
+/* here is what I send */
+struct sctpHBsender{
+  struct sctpChunkDesc hdr;
+  struct sctpParamDesc hb;
+  struct sctpHBrequest rtt;
+  int8_t addrFmt[SCTP_ADDRMAX];
+  uint16_t userreq;
+};
+
+
+
+/* for the abort and shutdown ACK
+ * we must carry the init tag in the common header. Just the
+ * common header is all that is needed with a chunk descriptor.
+ */
+struct sctpUnifiedAbort{
+  struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortLight{
+  struct sctpHeader mh;
+  struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortHeavy{
+  struct sctpHeader mh;
+  struct sctpChunkDesc uh;
+  uint16_t causeCode;
+  uint16_t causeLen;
+};
+
+/* For the graceful shutdown we must carry
+ * the tag (in common header)  and the highest consequitive acking value
+ */
+struct sctpShutdown {
+  uint32_t TSN_Seen;
+};
+
+struct sctpUnifiedShutdown{
+  struct sctpChunkDesc uh;
+  struct sctpShutdown shut;
+};
+
+/* in the unified message we add the trailing
+ * stream id since it is the only message
+ * that is defined as a operation error.
+ */
+struct sctpOpErrorCause{
+  uint16_t cause;
+  uint16_t causeLen;
+};
+
+struct sctpUnifiedOpError{
+  struct sctpChunkDesc uh;
+  struct sctpOpErrorCause c;
+};
+
+struct sctpUnifiedStreamError{
+  struct sctpHeader mh;
+  struct sctpChunkDesc uh;
+  struct sctpOpErrorCause c;
+  uint16_t strmNum;
+  uint16_t reserved;
+};
+
+struct staleCookieMsg{
+  struct sctpHeader mh;
+  struct sctpChunkDesc uh;
+  struct sctpOpErrorCause c;
+  uint32_t moretime;
+};
+
+/* the following is used in all sends
+ * where nothing is needed except the
+ * chunk/type i.e. shutdownAck Abort */
+
+struct sctpUnifiedSingleMsg{
+  struct sctpHeader mh;
+  struct sctpChunkDesc uh;
+};
+
+struct sctpDataPart{
+  uint32_t TSN;
+  uint16_t streamId;
+  uint16_t sequence;
+  uint32_t payloadtype;
+};
+
+struct sctpUnifiedDatagram{
+  struct sctpChunkDesc uh;
+  struct sctpDataPart dp;
+};
+
+struct sctpECN_echo{
+  struct sctpChunkDesc uh;
+  uint32_t Lowest_TSN;
+};
+
+
+struct sctpCWR{
+  struct sctpChunkDesc uh;
+  uint32_t TSN_reduced_at;
+};
+
 static const struct tok ForCES_channels[] = {
 	{ CHAN_HP, "ForCES HP" },
 	{ CHAN_MP, "ForCES MP" },
@@ -70,6 +417,68 @@
 	{ 0, NULL }
 };
 
+/* data chunk's payload protocol identifiers */
+
+#define SCTP_PPID_IUA 1
+#define SCTP_PPID_M2UA 2
+#define SCTP_PPID_M3UA 3
+#define SCTP_PPID_SUA 4
+#define SCTP_PPID_M2PA 5
+#define SCTP_PPID_V5UA 6
+#define SCTP_PPID_H248 7
+#define SCTP_PPID_BICC 8
+#define SCTP_PPID_TALI 9
+#define SCTP_PPID_DUA 10
+#define SCTP_PPID_ASAP 11
+#define SCTP_PPID_ENRP 12
+#define SCTP_PPID_H323 13
+#define SCTP_PPID_QIPC 14
+#define SCTP_PPID_SIMCO 15
+#define SCTP_PPID_DDPSC 16
+#define SCTP_PPID_DDPSSC 17
+#define SCTP_PPID_S1AP 18
+#define SCTP_PPID_RUA 19
+#define SCTP_PPID_HNBAP 20
+#define SCTP_PPID_FORCES_HP 21
+#define SCTP_PPID_FORCES_MP 22
+#define SCTP_PPID_FORCES_LP 23
+#define SCTP_PPID_SBC_AP 24
+#define SCTP_PPID_NBAP 25
+/* 26 */
+#define SCTP_PPID_X2AP 27
+
+static const struct tok PayloadProto_idents[] = {
+	{ SCTP_PPID_IUA,    "ISDN Q.921" },
+	{ SCTP_PPID_M2UA,   "M2UA"   },
+	{ SCTP_PPID_M3UA,   "M3UA"   },
+	{ SCTP_PPID_SUA,    "SUA"    },
+	{ SCTP_PPID_M2PA,   "M2PA"   },
+	{ SCTP_PPID_V5UA,   "V5.2"   },
+	{ SCTP_PPID_H248,   "H.248"  },
+	{ SCTP_PPID_BICC,   "BICC"   },
+	{ SCTP_PPID_TALI,   "TALI"   },
+	{ SCTP_PPID_DUA,    "DUA"    },
+	{ SCTP_PPID_ASAP,   "ASAP"   },
+	{ SCTP_PPID_ENRP,   "ENRP"   },
+	{ SCTP_PPID_H323,   "H.323"  },
+	{ SCTP_PPID_QIPC,   "Q.IPC"  },
+	{ SCTP_PPID_SIMCO,  "SIMCO"  },
+	{ SCTP_PPID_DDPSC,  "DDPSC"  },
+	{ SCTP_PPID_DDPSSC, "DDPSSC" },
+	{ SCTP_PPID_S1AP,   "S1AP"   },
+	{ SCTP_PPID_RUA,    "RUA"    },
+	{ SCTP_PPID_HNBAP,  "HNBAP"  },
+	{ SCTP_PPID_FORCES_HP, "ForCES HP" },
+	{ SCTP_PPID_FORCES_MP, "ForCES MP" },
+	{ SCTP_PPID_FORCES_LP, "ForCES LP" },
+	{ SCTP_PPID_SBC_AP, "SBc-AP" },
+	{ SCTP_PPID_NBAP,   "NBAP"   },
+	/* 26 */
+	{ SCTP_PPID_X2AP,   "X2AP"   },
+	{ 0, NULL }
+};
+
+
 static inline int isForCES_port(u_short Port)
 {
 	if (Port == CHAN_HP)
@@ -82,9 +491,10 @@
 	return 0;
 }
 
-void sctp_print(const u_char *bp,        /* beginning of sctp packet */
-		const u_char *bp2,       /* beginning of enclosing */
-		u_int sctpPacketLength)  /* ip packet */
+void sctp_print(netdissect_options *ndo,
+                const u_char *bp,        /* beginning of sctp packet */
+                const u_char *bp2,       /* beginning of enclosing */
+                u_int sctpPacketLength)  /* ip packet */
 {
   const struct sctpHeader *sctpPktHdr;
   const struct ip *ip;
@@ -103,8 +513,8 @@
   sctpPktHdr = (const struct sctpHeader*) bp;
   endPacketPtr = (const u_char*)sctpPktHdr+sctpPacketLength;
 
-  if( (u_long) endPacketPtr > (u_long) snapend)
-    endPacketPtr = (const void *) snapend;
+  if( (u_long) endPacketPtr > (u_long) ndo->ndo_snapend)
+    endPacketPtr = (const void *) ndo->ndo_snapend;
   ip = (struct ip *)bp2;
 #ifdef INET6
   if (IP_V(ip) == 6)
@@ -112,12 +522,12 @@
   else
     ip6 = NULL;
 #endif /*INET6*/
-  TCHECK(*sctpPktHdr);
+  ND_TCHECK(*sctpPktHdr);
 
   if (sctpPacketLength < sizeof(struct sctpHeader))
     {
-      (void)printf("truncated-sctp - %ld bytes missing!",
-		   (long)sctpPacketLength-sizeof(struct sctpHeader));
+      ND_PRINT((ndo, "truncated-sctp - %ld bytes missing!",
+		   (long)sctpPacketLength-sizeof(struct sctpHeader)));
       return;
     }
 
@@ -129,32 +539,31 @@
 
 #ifdef INET6
   if (ip6) {
-    (void)printf("%s.%d > %s.%d: sctp",
-      ip6addr_string(&ip6->ip6_src),
+    ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
+      ip6addr_string(ndo, &ip6->ip6_src),
       sourcePort,
-      ip6addr_string(&ip6->ip6_dst),
-      destPort);
+      ip6addr_string(ndo, &ip6->ip6_dst),
+      destPort));
   } else
 #endif /*INET6*/
   {
-    (void)printf("%s.%d > %s.%d: sctp",
-      ipaddr_string(&ip->ip_src),
+    ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
+      ipaddr_string(ndo, &ip->ip_src),
       sourcePort,
-      ipaddr_string(&ip->ip_dst),
-      destPort);
+      ipaddr_string(ndo, &ip->ip_dst),
+      destPort));
   }
-  fflush(stdout);
 
   if (isForCES_port(sourcePort)) {
-         printf("[%s]", tok2str(ForCES_channels, NULL, sourcePort));
+         ND_PRINT((ndo, "[%s]", tok2str(ForCES_channels, NULL, sourcePort)));
          isforces = 1;
   }
   if (isForCES_port(destPort)) {
-         printf("[%s]", tok2str(ForCES_channels, NULL, destPort));
+         ND_PRINT((ndo, "[%s]", tok2str(ForCES_channels, NULL, destPort)));
          isforces = 1;
   }
 
-  if (vflag >= 2)
+  if (ndo->ndo_vflag >= 2)
     sep = "\n\t";
   else
     sep = " (";
@@ -169,18 +578,18 @@
 
        chunkDescPtr = (const struct sctpChunkDesc *) nextChunk, chunkCount++)
     {
-      u_int16_t chunkLength;
+      uint16_t chunkLength;
       const u_char *chunkEnd;
-      u_int16_t align;
+      uint16_t align;
 
-      TCHECK(*chunkDescPtr);
+      ND_TCHECK(*chunkDescPtr);
       chunkLength = EXTRACT_16BITS(&chunkDescPtr->chunkLength);
       if (chunkLength < sizeof(*chunkDescPtr)) {
-      	printf("%s%d) [Bad chunk length %u]", sep, chunkCount+1, chunkLength);
-      	break;
+        ND_PRINT((ndo, "%s%d) [Bad chunk length %u]", sep, chunkCount+1, chunkLength));
+        break;
       }
 
-      TCHECK2(*((u_int8_t *)chunkDescPtr), chunkLength);
+      ND_TCHECK2(*((uint8_t *)chunkDescPtr), chunkLength);
       chunkEnd = ((const u_char*)chunkDescPtr + chunkLength);
 
       align=chunkLength % 4;
@@ -189,26 +598,29 @@
 
       nextChunk = (const void *) (chunkEnd + align);
 
-      printf("%s%d) ", sep, chunkCount+1);
+      ND_PRINT((ndo, "%s%d) ", sep, chunkCount+1));
+      ND_PRINT((ndo, "[%s] ", tok2str(sctp_chunkid_str, "Unknown chunk type: 0x%x",
+                                      chunkDescPtr->chunkID)));
       switch (chunkDescPtr->chunkID)
 	{
 	case SCTP_DATA :
 	  {
 	    const struct sctpDataPart *dataHdrPtr;
-
-	    printf("[DATA] ");
+	    uint32_t ppid;
+	    const u_char *payloadPtr;
+	    u_int payload_size;
 
 	    if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
 		== SCTP_DATA_UNORDERED)
-	      printf("(U)");
+	      ND_PRINT((ndo, "(U)"));
 
 	    if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG)
 		== SCTP_DATA_FIRST_FRAG)
-	      printf("(B)");
+	      ND_PRINT((ndo, "(B)"));
 
 	    if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
 		== SCTP_DATA_LAST_FRAG)
-	      printf("(E)");
+	      ND_PRINT((ndo, "(E)"));
 
 	    if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
 		 == SCTP_DATA_UNORDERED)
@@ -218,72 +630,68 @@
 		||
 		((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
 		 == SCTP_DATA_LAST_FRAG) )
-	      printf(" ");
+	      ND_PRINT((ndo, " "));
 
 	    dataHdrPtr=(const struct sctpDataPart*)(chunkDescPtr+1);
 
-	    printf("[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN));
-	    printf("[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId));
-	    printf("[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence));
-	    printf("[PPID 0x%x] ", EXTRACT_32BITS(&dataHdrPtr->payloadtype));
-	    fflush(stdout);
+	    ppid = EXTRACT_32BITS(&dataHdrPtr->payloadtype);
+	    ND_PRINT((ndo, "[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN)));
+	    ND_PRINT((ndo, "[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId)));
+	    ND_PRINT((ndo, "[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence)));
+	    ND_PRINT((ndo, "[PPID %s] ",
+		    tok2str(PayloadProto_idents, "0x%x", ppid)));
+
+	    if (!isforces) {
+		isforces = (ppid == SCTP_PPID_FORCES_HP) ||
+		    (ppid == SCTP_PPID_FORCES_MP) ||
+		    (ppid == SCTP_PPID_FORCES_LP);
+	    }
+
+	    payloadPtr = (const u_char *) (dataHdrPtr + 1);
+	    if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
+		    sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc) + 1) {
+		ND_PRINT((ndo, "bogus chunk length %u]", EXTRACT_16BITS(&chunkDescPtr->chunkLength)));
+		return;
+	    }
+
+	    payload_size = EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
+		(sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc));
+
 	    if (isforces) {
-		const u_char *payloadPtr;
-		u_int chunksize = sizeof(struct sctpDataPart)+
-			          sizeof(struct sctpChunkDesc);
-		payloadPtr = (const u_char *) (dataHdrPtr + 1);
-		if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
-			sizeof(struct sctpDataPart)+
-			sizeof(struct sctpChunkDesc)+1) {
-		/* Less than 1 byte of chunk payload */
-			printf("bogus ForCES chunk length %u]",
-			    EXTRACT_16BITS(&chunkDescPtr->chunkLength));
-			return;
-		}
-
-		forces_print(payloadPtr, EXTRACT_16BITS(&chunkDescPtr->chunkLength)- chunksize);
-	   } else if (vflag >= 2) {	/* if verbose output is specified */
+		forces_print(ndo, payloadPtr, payload_size);
+	    } else if (ndo->ndo_vflag >= 2) {	/* if verbose output is specified */
 					/* at the command line */
-		const u_char *payloadPtr;
-
-		printf("[Payload");
-
-		if (!suppress_default_print) {
-			payloadPtr = (const u_char *) (++dataHdrPtr);
-			printf(":");
-			if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
-			    sizeof(struct sctpDataPart)+
-			    sizeof(struct sctpChunkDesc)+1) {
-				/* Less than 1 byte of chunk payload */
-				printf("bogus chunk length %u]",
-				    EXTRACT_16BITS(&chunkDescPtr->chunkLength));
-				return;
+		switch (ppid) {
+		case SCTP_PPID_M3UA :
+			m3ua_print(ndo, payloadPtr, payload_size);
+			break;
+		default:
+			ND_PRINT((ndo, "[Payload"));
+			if (!ndo->ndo_suppress_default_print) {
+				ND_PRINT((ndo, ":"));
+				ND_DEFAULTPRINT(payloadPtr, payload_size);
 			}
-			default_print(payloadPtr,
-			      EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
-			      (sizeof(struct sctpDataPart)+
-			      sizeof(struct sctpChunkDesc)));
-		} else
-			printf("]");
-	      }
+			ND_PRINT((ndo, "]"));
+			break;
+		}
+	    }
 	    break;
 	  }
 	case SCTP_INITIATION :
 	  {
 	    const struct sctpInitiation *init;
 
-	    printf("[INIT] ");
 	    init=(const struct sctpInitiation*)(chunkDescPtr+1);
-	    printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
-	    printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
-	    printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
-	    printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
-	    printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
+	    ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
+	    ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
+	    ND_PRINT((ndo, "[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)));
+	    ND_PRINT((ndo, "[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)));
+	    ND_PRINT((ndo, "[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)));
 
 #if(0) /* ALC you can add code for optional params here */
 	    if( (init+1) < chunkEnd )
-	      printf(" @@@@@ UNFINISHED @@@@@@%s\n",
-		     "Optional params present, but not printed.");
+	      ND_PRINT((ndo, " @@@@@ UNFINISHED @@@@@@%s\n",
+		     "Optional params present, but not printed."));
 #endif
 	    break;
 	  }
@@ -291,18 +699,17 @@
 	  {
 	    const struct sctpInitiation *init;
 
-	    printf("[INIT ACK] ");
 	    init=(const struct sctpInitiation*)(chunkDescPtr+1);
-	    printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
-	    printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
-	    printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
-	    printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
-	    printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
+	    ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
+	    ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
+	    ND_PRINT((ndo, "[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)));
+	    ND_PRINT((ndo, "[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)));
+	    ND_PRINT((ndo, "[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)));
 
 #if(0) /* ALC you can add code for optional params here */
 	    if( (init+1) < chunkEnd )
-	      printf(" @@@@@ UNFINISHED @@@@@@%s\n",
-		     "Optional params present, but not printed.");
+	      ND_PRINT((ndo, " @@@@@ UNFINISHED @@@@@@%s\n",
+		     "Optional params present, but not printed."));
 #endif
 	    break;
 	  }
@@ -313,12 +720,11 @@
 	    int fragNo, tsnNo;
 	    const u_char *dupTSN;
 
-	    printf("[SACK] ");
 	    sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1);
-	    printf("[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN));
-	    printf("[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd));
-	    printf("[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc));
-	    printf("[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns));
+	    ND_PRINT((ndo, "[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN)));
+	    ND_PRINT((ndo, "[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd)));
+	    ND_PRINT((ndo, "[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc)));
+	    ND_PRINT((ndo, "[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns)));
 
 
 	    /* print gaps */
@@ -327,74 +733,28 @@
 		   fragNo=0;
 		 (const void *)frag < nextChunk && fragNo < EXTRACT_16BITS(&sack->numberOfdesc);
 		 frag++, fragNo++)
-	      printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ",
+	      ND_PRINT((ndo, "\n\t\t[gap ack block #%d: start = %u, end = %u] ",
 		     fragNo+1,
 		     EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentStart),
-		     EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd));
+		     EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd)));
 
 
 	    /* print duplicate TSNs */
 	    for (dupTSN = (const u_char *)frag, tsnNo=0;
 		 (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns);
 		 dupTSN += 4, tsnNo++)
-	      printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
-	          EXTRACT_32BITS(dupTSN));
+	      ND_PRINT((ndo, "\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
+	          EXTRACT_32BITS(dupTSN)));
 
 	    break;
 	  }
-	case SCTP_HEARTBEAT_REQUEST :
-	  printf("[HB REQ] ");
-	  break;
-	case SCTP_HEARTBEAT_ACK :
-	  printf("[HB ACK] ");
-	  break;
-	case SCTP_ABORT_ASSOCIATION :
-	  printf("[ABORT] ");
-	  break;
-	case SCTP_SHUTDOWN :
-	  printf("[SHUTDOWN] ");
-	  break;
-	case SCTP_SHUTDOWN_ACK :
-	  printf("[SHUTDOWN ACK] ");
-	  break;
-	case SCTP_OPERATION_ERR :
-	  printf("[OP ERR] ");
-	  break;
-	case SCTP_COOKIE_ECHO :
-	  printf("[COOKIE ECHO] ");
-	  break;
-	case SCTP_COOKIE_ACK :
-	  printf("[COOKIE ACK] ");
-	  break;
-	case SCTP_ECN_ECHO :
-	  printf("[ECN ECHO] ");
-	  break;
-	case SCTP_ECN_CWR :
-	  printf("[ECN CWR] ");
-	  break;
-	case SCTP_SHUTDOWN_COMPLETE :
-	  printf("[SHUTDOWN COMPLETE] ");
-	  break;
-	case SCTP_FORWARD_CUM_TSN :
-	  printf("[FOR CUM TSN] ");
-	  break;
-	case SCTP_RELIABLE_CNTL :
-	  printf("[REL CTRL] ");
-	  break;
-	case SCTP_RELIABLE_CNTL_ACK :
-	  printf("[REL CTRL ACK] ");
-	  break;
-	default :
-	  printf("[Unknown chunk type: 0x%x]", chunkDescPtr->chunkID);
-	  return;
 	}
 
-	if (vflag < 2)
+	if (ndo->ndo_vflag < 2)
 	  sep = ", (";
     }
     return;
 
 trunc:
-    printf("[|sctp]");
-    return;
+    ND_PRINT((ndo, "[|sctp]"));
 }
diff --git a/print-sflow.c b/print-sflow.c
index 1a23d49..24112f4 100644
--- a/print-sflow.c
+++ b/print-sflow.c
@@ -19,28 +19,20 @@
  * Expansion and refactoring by Rick Jones <rick.jones2@hp.com>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sflow.c,v 1.1 2007-08-08 17:20:58 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 
-/* 
+/*
  * sFlow datagram
- * 
+ *
  * 0                   1                   2                   3
  * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -58,22 +50,22 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  * |                    num samples in datagram                    |
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * 
+ *
  */
 
 struct sflow_datagram_t {
-    u_int8_t 	version[4];
-    u_int8_t 	ip_version[4];
-    u_int8_t 	agent[4];
-    u_int8_t 	agent_id[4];
-    u_int8_t 	seqnum[4];
-    u_int8_t 	uptime[4];
-    u_int8_t 	samples[4];
+    uint8_t 	version[4];
+    uint8_t 	ip_version[4];
+    uint8_t 	agent[4];
+    uint8_t 	agent_id[4];
+    uint8_t 	seqnum[4];
+    uint8_t 	uptime[4];
+    uint8_t 	samples[4];
 };
 
 struct sflow_sample_header {
-    u_int8_t	format[4];
-    u_int8_t	len[4];
+    uint8_t	format[4];
+    uint8_t	len[4];
 };
 
 #define		SFLOW_FLOW_SAMPLE		1
@@ -90,29 +82,29 @@
 };
 
 struct sflow_flow_sample_t {
-    u_int8_t    seqnum[4];
-    u_int8_t    typesource[4];
-    u_int8_t    rate[4];
-    u_int8_t    pool[4];
-    u_int8_t    drops[4];
-    u_int8_t    in_interface[4];
-    u_int8_t    out_interface[4];
-    u_int8_t    records[4];
+    uint8_t    seqnum[4];
+    uint8_t    typesource[4];
+    uint8_t    rate[4];
+    uint8_t    pool[4];
+    uint8_t    drops[4];
+    uint8_t    in_interface[4];
+    uint8_t    out_interface[4];
+    uint8_t    records[4];
 
 };
 
 struct sflow_expanded_flow_sample_t {
-    u_int8_t    seqnum[4];
-    u_int8_t    type[4];
-    u_int8_t    index[4];
-    u_int8_t    rate[4];
-    u_int8_t    pool[4];
-    u_int8_t    drops[4];
-    u_int8_t    in_interface_format[4];
-    u_int8_t    in_interface_value[4];
-    u_int8_t    out_interface_format[4];
-    u_int8_t    out_interface_value[4];
-    u_int8_t    records[4];
+    uint8_t    seqnum[4];
+    uint8_t    type[4];
+    uint8_t    index[4];
+    uint8_t    rate[4];
+    uint8_t    pool[4];
+    uint8_t    drops[4];
+    uint8_t    in_interface_format[4];
+    uint8_t    in_interface_value[4];
+    uint8_t    out_interface_format[4];
+    uint8_t    out_interface_value[4];
+    uint8_t    records[4];
 };
 
 #define 	SFLOW_FLOW_RAW_PACKET			1
@@ -162,49 +154,49 @@
     { SFLOW_HEADER_PROTOCOL_IPV6, "IPv6"},
     { 0, NULL}
 };
-	
+
 struct sflow_expanded_flow_raw_t {
-    u_int8_t    protocol[4];
-    u_int8_t    length[4];
-    u_int8_t    stripped_bytes[4];
-    u_int8_t    header_size[4];
+    uint8_t    protocol[4];
+    uint8_t    length[4];
+    uint8_t    stripped_bytes[4];
+    uint8_t    header_size[4];
 };
 
 struct sflow_ethernet_frame_t {
-    u_int8_t length[4];
-    u_int8_t src_mac[8];
-    u_int8_t dst_mac[8];
-    u_int8_t type[4];
+    uint8_t length[4];
+    uint8_t src_mac[8];
+    uint8_t dst_mac[8];
+    uint8_t type[4];
 };
 
 struct sflow_extended_switch_data_t {
-    u_int8_t src_vlan[4];
-    u_int8_t src_pri[4];
-    u_int8_t dst_vlan[4];
-    u_int8_t dst_pri[4];
+    uint8_t src_vlan[4];
+    uint8_t src_pri[4];
+    uint8_t dst_vlan[4];
+    uint8_t dst_pri[4];
 };
 
 struct sflow_counter_record_t {
-    u_int8_t    format[4];
-    u_int8_t    length[4];
+    uint8_t    format[4];
+    uint8_t    length[4];
 };
 
 struct sflow_flow_record_t {
-    u_int8_t    format[4];
-    u_int8_t    length[4];
+    uint8_t    format[4];
+    uint8_t    length[4];
 };
 
 struct sflow_counter_sample_t {
-    u_int8_t    seqnum[4];
-    u_int8_t    typesource[4];
-    u_int8_t    records[4];
+    uint8_t    seqnum[4];
+    uint8_t    typesource[4];
+    uint8_t    records[4];
 };
 
 struct sflow_expanded_counter_sample_t {
-    u_int8_t    seqnum[4];
-    u_int8_t    type[4];
-    u_int8_t    index[4];
-    u_int8_t    records[4];
+    uint8_t    seqnum[4];
+    uint8_t    type[4];
+    uint8_t    index[4];
+    uint8_t    records[4];
 };
 
 #define         SFLOW_COUNTER_GENERIC           1
@@ -237,75 +229,76 @@
     { SFLOW_IFACE_DIRECTION_IN, "in"},
     { SFLOW_IFACE_DIRECTION_OUT, "out"},
     { 0, NULL}
-};  
+};
 
 struct sflow_generic_counter_t {
-    u_int8_t    ifindex[4];
-    u_int8_t    iftype[4];
-    u_int8_t    ifspeed[8];
-    u_int8_t    ifdirection[4];	
-    u_int8_t    ifstatus[4];
-    u_int8_t    ifinoctets[8];	
-    u_int8_t    ifinunicastpkts[4];	
-    u_int8_t    ifinmulticastpkts[4];	
-    u_int8_t    ifinbroadcastpkts[4];	
-    u_int8_t    ifindiscards[4];	
-    u_int8_t    ifinerrors[4];	
-    u_int8_t    ifinunkownprotos[4];	
-    u_int8_t    ifoutoctets[8];
-    u_int8_t    ifoutunicastpkts[4];     
-    u_int8_t    ifoutmulticastpkts[4];   
-    u_int8_t    ifoutbroadcastpkts[4];         
-    u_int8_t    ifoutdiscards[4];             
-    u_int8_t    ifouterrors[4];        
-    u_int8_t    ifpromiscmode[4];        
+    uint8_t    ifindex[4];
+    uint8_t    iftype[4];
+    uint8_t    ifspeed[8];
+    uint8_t    ifdirection[4];
+    uint8_t    ifstatus[4];
+    uint8_t    ifinoctets[8];
+    uint8_t    ifinunicastpkts[4];
+    uint8_t    ifinmulticastpkts[4];
+    uint8_t    ifinbroadcastpkts[4];
+    uint8_t    ifindiscards[4];
+    uint8_t    ifinerrors[4];
+    uint8_t    ifinunkownprotos[4];
+    uint8_t    ifoutoctets[8];
+    uint8_t    ifoutunicastpkts[4];
+    uint8_t    ifoutmulticastpkts[4];
+    uint8_t    ifoutbroadcastpkts[4];
+    uint8_t    ifoutdiscards[4];
+    uint8_t    ifouterrors[4];
+    uint8_t    ifpromiscmode[4];
 };
 
 struct sflow_ethernet_counter_t {
-    u_int8_t    alignerrors[4];
-    u_int8_t    fcserrors[4];
-    u_int8_t    single_collision_frames[4];
-    u_int8_t    multiple_collision_frames[4];
-    u_int8_t    test_errors[4];
-    u_int8_t    deferred_transmissions[4];
-    u_int8_t    late_collisions[4];
-    u_int8_t    excessive_collisions[4];
-    u_int8_t    mac_transmit_errors[4];
-    u_int8_t    carrier_sense_errors[4];
-    u_int8_t    frame_too_longs[4];
-    u_int8_t    mac_receive_errors[4];
-    u_int8_t    symbol_errors[4];
+    uint8_t    alignerrors[4];
+    uint8_t    fcserrors[4];
+    uint8_t    single_collision_frames[4];
+    uint8_t    multiple_collision_frames[4];
+    uint8_t    test_errors[4];
+    uint8_t    deferred_transmissions[4];
+    uint8_t    late_collisions[4];
+    uint8_t    excessive_collisions[4];
+    uint8_t    mac_transmit_errors[4];
+    uint8_t    carrier_sense_errors[4];
+    uint8_t    frame_too_longs[4];
+    uint8_t    mac_receive_errors[4];
+    uint8_t    symbol_errors[4];
 };
 
 struct sflow_100basevg_counter_t {
-    u_int8_t    in_highpriority_frames[4];
-    u_int8_t    in_highpriority_octets[8];
-    u_int8_t    in_normpriority_frames[4];
-    u_int8_t    in_normpriority_octets[8];
-    u_int8_t    in_ipmerrors[4]; 
-    u_int8_t    in_oversized[4]; 
-    u_int8_t    in_data_errors[4];
-    u_int8_t    in_null_addressed_frames[4];
-    u_int8_t    out_highpriority_frames[4];
-    u_int8_t    out_highpriority_octets[8];
-    u_int8_t    transitioninto_frames[4];
-    u_int8_t    hc_in_highpriority_octets[8];
-    u_int8_t    hc_in_normpriority_octets[8];
-    u_int8_t    hc_out_highpriority_octets[8];
+    uint8_t    in_highpriority_frames[4];
+    uint8_t    in_highpriority_octets[8];
+    uint8_t    in_normpriority_frames[4];
+    uint8_t    in_normpriority_octets[8];
+    uint8_t    in_ipmerrors[4];
+    uint8_t    in_oversized[4];
+    uint8_t    in_data_errors[4];
+    uint8_t    in_null_addressed_frames[4];
+    uint8_t    out_highpriority_frames[4];
+    uint8_t    out_highpriority_octets[8];
+    uint8_t    transitioninto_frames[4];
+    uint8_t    hc_in_highpriority_octets[8];
+    uint8_t    hc_in_normpriority_octets[8];
+    uint8_t    hc_out_highpriority_octets[8];
 };
 
 struct sflow_vlan_counter_t {
-    u_int8_t    vlan_id[4];
-    u_int8_t    octets[8];
-    u_int8_t    unicast_pkt[4];
-    u_int8_t    multicast_pkt[4];
-    u_int8_t    broadcast_pkt[4];
-    u_int8_t    discards[4];
+    uint8_t    vlan_id[4];
+    uint8_t    octets[8];
+    uint8_t    unicast_pkt[4];
+    uint8_t    multicast_pkt[4];
+    uint8_t    broadcast_pkt[4];
+    uint8_t    discards[4];
 };
 
 static int
-print_sflow_counter_generic(const u_char *pointer, u_int len) {
-
+print_sflow_counter_generic(netdissect_options *ndo,
+                            const u_char *pointer, u_int len)
+{
     const struct sflow_generic_counter_t *sflow_gen_counter;
 
     if (len < sizeof(struct sflow_generic_counter_t))
@@ -313,163 +306,169 @@
 
 
     sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer;
-    printf("\n\t      ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)",
+    ND_PRINT((ndo, "\n\t      ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)",
 	   EXTRACT_32BITS(sflow_gen_counter->ifindex),
 	   EXTRACT_32BITS(sflow_gen_counter->iftype),
 	   EXTRACT_64BITS(sflow_gen_counter->ifspeed),
 	   EXTRACT_32BITS(sflow_gen_counter->ifdirection),
 	   tok2str(sflow_iface_direction_values, "Unknown",
-		   EXTRACT_32BITS(sflow_gen_counter->ifdirection)));
-    printf("\n\t      ifstatus %u, adminstatus: %s, operstatus: %s",
+	   EXTRACT_32BITS(sflow_gen_counter->ifdirection))));
+    ND_PRINT((ndo, "\n\t      ifstatus %u, adminstatus: %s, operstatus: %s",
 	   EXTRACT_32BITS(sflow_gen_counter->ifstatus),
 	   EXTRACT_32BITS(sflow_gen_counter->ifstatus)&1 ? "up" : "down",
-	   (EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down");
-    printf("\n\t      In octets %" PRIu64
+	   (EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down"));
+    ND_PRINT((ndo, "\n\t      In octets %" PRIu64
 	   ", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
 	   EXTRACT_64BITS(sflow_gen_counter->ifinoctets),
 	   EXTRACT_32BITS(sflow_gen_counter->ifinunicastpkts),
 	   EXTRACT_32BITS(sflow_gen_counter->ifinmulticastpkts),
 	   EXTRACT_32BITS(sflow_gen_counter->ifinbroadcastpkts),
-	   EXTRACT_32BITS(sflow_gen_counter->ifindiscards));
-    printf("\n\t      In errors %u, unknown protos %u",
+	   EXTRACT_32BITS(sflow_gen_counter->ifindiscards)));
+    ND_PRINT((ndo, "\n\t      In errors %u, unknown protos %u",
 	   EXTRACT_32BITS(sflow_gen_counter->ifinerrors),
-	   EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos));
-    printf("\n\t      Out octets %" PRIu64
+	   EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos)));
+    ND_PRINT((ndo, "\n\t      Out octets %" PRIu64
 	   ", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
 	   EXTRACT_64BITS(sflow_gen_counter->ifoutoctets),
 	   EXTRACT_32BITS(sflow_gen_counter->ifoutunicastpkts),
 	   EXTRACT_32BITS(sflow_gen_counter->ifoutmulticastpkts),
 	   EXTRACT_32BITS(sflow_gen_counter->ifoutbroadcastpkts),
-	   EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards));
-    printf("\n\t      Out errors %u, promisc mode %u", 
+	   EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards)));
+    ND_PRINT((ndo, "\n\t      Out errors %u, promisc mode %u",
 	   EXTRACT_32BITS(sflow_gen_counter->ifouterrors),
-	   EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode));
+	   EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode)));
 
     return 0;
 }
 
 static int
-print_sflow_counter_ethernet(const u_char *pointer, u_int len){
-
+print_sflow_counter_ethernet(netdissect_options *ndo,
+                             const u_char *pointer, u_int len)
+{
     const struct sflow_ethernet_counter_t *sflow_eth_counter;
 
     if (len < sizeof(struct sflow_ethernet_counter_t))
 	return 1;
 
     sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer;
-    printf("\n\t      align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u",
+    ND_PRINT((ndo, "\n\t      align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u",
 	   EXTRACT_32BITS(sflow_eth_counter->alignerrors),
 	   EXTRACT_32BITS(sflow_eth_counter->fcserrors),
 	   EXTRACT_32BITS(sflow_eth_counter->single_collision_frames),
 	   EXTRACT_32BITS(sflow_eth_counter->multiple_collision_frames),
-	   EXTRACT_32BITS(sflow_eth_counter->test_errors));
-    printf("\n\t      deferred %u, late collision %u, excessive collision %u, mac trans error %u", 
+	   EXTRACT_32BITS(sflow_eth_counter->test_errors)));
+    ND_PRINT((ndo, "\n\t      deferred %u, late collision %u, excessive collision %u, mac trans error %u",
 	   EXTRACT_32BITS(sflow_eth_counter->deferred_transmissions),
 	   EXTRACT_32BITS(sflow_eth_counter->late_collisions),
 	   EXTRACT_32BITS(sflow_eth_counter->excessive_collisions),
-	   EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors));
-    printf("\n\t      carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u",	
+	   EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors)));
+    ND_PRINT((ndo, "\n\t      carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u",
 	   EXTRACT_32BITS(sflow_eth_counter->carrier_sense_errors),
 	   EXTRACT_32BITS(sflow_eth_counter->frame_too_longs),
 	   EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors),
-	   EXTRACT_32BITS(sflow_eth_counter->symbol_errors));
+	   EXTRACT_32BITS(sflow_eth_counter->symbol_errors)));
 
     return 0;
 }
 
 static int
-print_sflow_counter_token_ring(const u_char *pointer _U_, u_int len _U_) {
-
+print_sflow_counter_token_ring(netdissect_options *ndo _U_,
+                               const u_char *pointer _U_, u_int len _U_)
+{
     return 0;
 }
 
 static int
-print_sflow_counter_basevg(const u_char *pointer, u_int len) {
-
+print_sflow_counter_basevg(netdissect_options *ndo,
+                           const u_char *pointer, u_int len)
+{
     const struct sflow_100basevg_counter_t *sflow_100basevg_counter;
 
     if (len < sizeof(struct sflow_100basevg_counter_t))
 	return 1;
 
     sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer;
-    printf("\n\t      in high prio frames %u, in high prio octets %" PRIu64,
+    ND_PRINT((ndo, "\n\t      in high prio frames %u, in high prio octets %" PRIu64,
 	   EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames),
-	   EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets));
-    printf("\n\t      in norm prio frames %u, in norm prio octets %" PRIu64,
+	   EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets)));
+    ND_PRINT((ndo, "\n\t      in norm prio frames %u, in norm prio octets %" PRIu64,
 	   EXTRACT_32BITS(sflow_100basevg_counter->in_normpriority_frames),
-	   EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets));
-    printf("\n\t      in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u",
+	   EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets)));
+    ND_PRINT((ndo, "\n\t      in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u",
 	   EXTRACT_32BITS(sflow_100basevg_counter->in_ipmerrors),
 	   EXTRACT_32BITS(sflow_100basevg_counter->in_oversized),
 	   EXTRACT_32BITS(sflow_100basevg_counter->in_data_errors),
-	   EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames));
-    printf("\n\t      out high prio frames %u, out high prio octets %" PRIu64
+	   EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames)));
+    ND_PRINT((ndo, "\n\t      out high prio frames %u, out high prio octets %" PRIu64
 	   ", trans into frames %u",
 	   EXTRACT_32BITS(sflow_100basevg_counter->out_highpriority_frames),
 	   EXTRACT_64BITS(sflow_100basevg_counter->out_highpriority_octets),
-	   EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames));
-    printf("\n\t      in hc high prio octets %" PRIu64
+	   EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames)));
+    ND_PRINT((ndo, "\n\t      in hc high prio octets %" PRIu64
 	   ", in hc norm prio octets %" PRIu64
 	   ", out hc high prio octets %" PRIu64,
 	   EXTRACT_64BITS(sflow_100basevg_counter->hc_in_highpriority_octets),
 	   EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets),
-	   EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets));
+	   EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets)));
 
     return 0;
 }
 
 static int
-print_sflow_counter_vlan(const u_char *pointer, u_int len) {
-
+print_sflow_counter_vlan(netdissect_options *ndo,
+                         const u_char *pointer, u_int len)
+{
     const struct sflow_vlan_counter_t *sflow_vlan_counter;
-    
+
     if (len < sizeof(struct sflow_vlan_counter_t))
 	return 1;
 
     sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer;
-    printf("\n\t      vlan_id %u, octets %" PRIu64
+    ND_PRINT((ndo, "\n\t      vlan_id %u, octets %" PRIu64
 	   ", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u",
 	   EXTRACT_32BITS(sflow_vlan_counter->vlan_id),
 	   EXTRACT_64BITS(sflow_vlan_counter->octets),
 	   EXTRACT_32BITS(sflow_vlan_counter->unicast_pkt),
 	   EXTRACT_32BITS(sflow_vlan_counter->multicast_pkt),
 	   EXTRACT_32BITS(sflow_vlan_counter->broadcast_pkt),
-	   EXTRACT_32BITS(sflow_vlan_counter->discards));
+	   EXTRACT_32BITS(sflow_vlan_counter->discards)));
 
     return 0;
 }
 
 struct sflow_processor_counter_t {
-    u_int8_t five_sec_util[4];
-    u_int8_t one_min_util[4];
-    u_int8_t five_min_util[4];
-    u_int8_t total_memory[8];
-    u_int8_t free_memory[8];
+    uint8_t five_sec_util[4];
+    uint8_t one_min_util[4];
+    uint8_t five_min_util[4];
+    uint8_t total_memory[8];
+    uint8_t free_memory[8];
 };
 
 static int
-print_sflow_counter_processor(const u_char *pointer, u_int len) {
-
+print_sflow_counter_processor(netdissect_options *ndo,
+                              const u_char *pointer, u_int len)
+{
     const struct sflow_processor_counter_t *sflow_processor_counter;
 
     if (len < sizeof(struct sflow_processor_counter_t))
 	return 1;
 
     sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer;
-    printf("\n\t      5sec %u, 1min %u, 5min %u, total_mem %" PRIu64
+    ND_PRINT((ndo, "\n\t      5sec %u, 1min %u, 5min %u, total_mem %" PRIu64
 	   ", total_mem %" PRIu64,
 	   EXTRACT_32BITS(sflow_processor_counter->five_sec_util),
 	   EXTRACT_32BITS(sflow_processor_counter->one_min_util),
 	   EXTRACT_32BITS(sflow_processor_counter->five_min_util),
 	   EXTRACT_64BITS(sflow_processor_counter->total_memory),
-	   EXTRACT_64BITS(sflow_processor_counter->free_memory));
+	   EXTRACT_64BITS(sflow_processor_counter->free_memory)));
 
     return 0;
 }
 
 static int
-sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
-
+sflow_print_counter_records(netdissect_options *ndo,
+                            const u_char *pointer, u_int len, u_int records)
+{
     u_int nrecords;
     const u_char *tptr;
     u_int tlen;
@@ -492,11 +491,11 @@
 	counter_type = enterprise & 0x0FFF;
 	enterprise = enterprise >> 20;
 	counter_len  = EXTRACT_32BITS(sflow_counter_record->length);
-	printf("\n\t    enterprise %u, %s (%u) length %u",
+	ND_PRINT((ndo, "\n\t    enterprise %u, %s (%u) length %u",
 	       enterprise,
 	       (enterprise == 0) ? tok2str(sflow_counter_type_values,"Unknown",counter_type) : "Unknown",
 	       counter_type,
-	       counter_len);
+	       counter_len));
 
 	tptr += sizeof(struct sflow_counter_record_t);
 	tlen -= sizeof(struct sflow_counter_record_t);
@@ -506,48 +505,48 @@
 	if (enterprise == 0) {
 	    switch (counter_type) {
 	    case SFLOW_COUNTER_GENERIC:
-		if (print_sflow_counter_generic(tptr,tlen))
+		if (print_sflow_counter_generic(ndo, tptr, tlen))
 		    return 1;
 		break;
 	    case SFLOW_COUNTER_ETHERNET:
-		if (print_sflow_counter_ethernet(tptr,tlen))
+		if (print_sflow_counter_ethernet(ndo, tptr, tlen))
 		    return 1;
 		break;
 	    case SFLOW_COUNTER_TOKEN_RING:
-		if (print_sflow_counter_token_ring(tptr,tlen))
+		if (print_sflow_counter_token_ring(ndo, tptr,tlen))
 		    return 1;
 		break;
 	    case SFLOW_COUNTER_BASEVG:
-		if (print_sflow_counter_basevg(tptr,tlen))
+		if (print_sflow_counter_basevg(ndo, tptr, tlen))
 		    return 1;
 		break;
 	    case SFLOW_COUNTER_VLAN:
-		if (print_sflow_counter_vlan(tptr,tlen))
+		if (print_sflow_counter_vlan(ndo, tptr, tlen))
 		    return 1;
 		break;
 	    case SFLOW_COUNTER_PROCESSOR:
-		if (print_sflow_counter_processor(tptr,tlen))
+		if (print_sflow_counter_processor(ndo, tptr, tlen))
 		    return 1;
 		break;
 	    default:
-		if (vflag <= 1)
-		    print_unknown_data(tptr, "\n\t\t", counter_len);
+		if (ndo->ndo_vflag <= 1)
+		    print_unknown_data(ndo, tptr, "\n\t\t", counter_len);
 		break;
 	    }
 	}
 	tptr += counter_len;
 	tlen -= counter_len;
 	nrecords--;
-	
+
     }
 
     return 0;
 }
 
-
 static int
-sflow_print_counter_sample(const u_char *pointer, u_int len) {
-
+sflow_print_counter_sample(netdissect_options *ndo,
+                           const u_char *pointer, u_int len)
+{
     const struct sflow_counter_sample_t *sflow_counter_sample;
     u_int           nrecords;
     u_int           typesource;
@@ -564,22 +563,23 @@
     nrecords   = EXTRACT_32BITS(sflow_counter_sample->records);
     type = typesource >> 24;
     index = typesource & 0x0FFF;
-    
-    printf(" seqnum %u, type %u, idx %u, records %u",
+
+    ND_PRINT((ndo, " seqnum %u, type %u, idx %u, records %u",
 	   EXTRACT_32BITS(sflow_counter_sample->seqnum),
 	   type,
 	   index,
-	   nrecords);
+	   nrecords));
 
-    return sflow_print_counter_records(pointer + sizeof(struct sflow_counter_sample_t),
+    return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_counter_sample_t),
 				       len - sizeof(struct sflow_counter_sample_t),
 				       nrecords);
 
 }
 
 static int
-sflow_print_expanded_counter_sample(const u_char *pointer, u_int len) {
-
+sflow_print_expanded_counter_sample(netdissect_options *ndo,
+                                    const u_char *pointer, u_int len)
+{
     const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample;
     u_int           nrecords;
 
@@ -591,33 +591,34 @@
 
     nrecords = EXTRACT_32BITS(sflow_expanded_counter_sample->records);
 
-    printf(" seqnum %u, type %u, idx %u, records %u",
+    ND_PRINT((ndo, " seqnum %u, type %u, idx %u, records %u",
 	   EXTRACT_32BITS(sflow_expanded_counter_sample->seqnum),
 	   EXTRACT_32BITS(sflow_expanded_counter_sample->type),
 	   EXTRACT_32BITS(sflow_expanded_counter_sample->index),
-	   nrecords);
-    
-    return sflow_print_counter_records(pointer + sizeof(struct sflow_expanded_counter_sample_t),
+	   nrecords));
+
+    return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_expanded_counter_sample_t),
 				       len - sizeof(struct sflow_expanded_counter_sample_t),
 				       nrecords);
 
 }
 
 static int
-print_sflow_raw_packet(const u_char *pointer, u_int len) {
-
+print_sflow_raw_packet(netdissect_options *ndo,
+                       const u_char *pointer, u_int len)
+{
     const struct sflow_expanded_flow_raw_t *sflow_flow_raw;
 
     if (len < sizeof(struct sflow_expanded_flow_raw_t))
 	return 1;
 
     sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer;
-    printf("\n\t      protocol %s (%u), length %u, stripped bytes %u, header_size %u",
+    ND_PRINT((ndo, "\n\t      protocol %s (%u), length %u, stripped bytes %u, header_size %u",
 	   tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)),
 	   EXTRACT_32BITS(sflow_flow_raw->protocol),
 	   EXTRACT_32BITS(sflow_flow_raw->length),
 	   EXTRACT_32BITS(sflow_flow_raw->stripped_bytes),
-	   EXTRACT_32BITS(sflow_flow_raw->header_size));
+	   EXTRACT_32BITS(sflow_flow_raw->header_size)));
 
     /* QUESTION - should we attempt to print the raw header itself?
        assuming of course there is wnough data present to do so... */
@@ -626,8 +627,9 @@
 }
 
 static int
-print_sflow_ethernet_frame(const u_char *pointer, u_int len) {
-
+print_sflow_ethernet_frame(netdissect_options *ndo,
+                           const u_char *pointer, u_int len)
+{
     const struct sflow_ethernet_frame_t *sflow_ethernet_frame;
 
     if (len < sizeof(struct sflow_ethernet_frame_t))
@@ -635,34 +637,36 @@
 
     sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer;
 
-    printf("\n\t      frame len %u, type %u",
+    ND_PRINT((ndo, "\n\t      frame len %u, type %u",
 	   EXTRACT_32BITS(sflow_ethernet_frame->length),
-	   EXTRACT_32BITS(sflow_ethernet_frame->type));
+	   EXTRACT_32BITS(sflow_ethernet_frame->type)));
 
     return 0;
 }
 
 static int
-print_sflow_extended_switch_data(const u_char *pointer, u_int len) {
-
+print_sflow_extended_switch_data(netdissect_options *ndo,
+                                 const u_char *pointer, u_int len)
+{
     const struct sflow_extended_switch_data_t *sflow_extended_sw_data;
 
     if (len < sizeof(struct sflow_extended_switch_data_t))
 	return 1;
 
     sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer;
-    printf("\n\t      src vlan %u, src pri %u, dst vlan %u, dst pri %u",
+    ND_PRINT((ndo, "\n\t      src vlan %u, src pri %u, dst vlan %u, dst pri %u",
 	   EXTRACT_32BITS(sflow_extended_sw_data->src_vlan),
 	   EXTRACT_32BITS(sflow_extended_sw_data->src_pri),
 	   EXTRACT_32BITS(sflow_extended_sw_data->dst_vlan),
-	   EXTRACT_32BITS(sflow_extended_sw_data->dst_pri));
+	   EXTRACT_32BITS(sflow_extended_sw_data->dst_pri)));
 
     return 0;
 }
 
 static int
-sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
-
+sflow_print_flow_records(netdissect_options *ndo,
+                         const u_char *pointer, u_int len, u_int records)
+{
     u_int nrecords;
     const u_char *tptr;
     u_int tlen;
@@ -684,16 +688,16 @@
 
 	/* so, the funky encoding means we cannot blythly mask-off
 	   bits, we must also check the enterprise. */
-	
+
 	enterprise = EXTRACT_32BITS(sflow_flow_record->format);
 	flow_type = enterprise & 0x0FFF;
 	enterprise = enterprise >> 12;
 	flow_len  = EXTRACT_32BITS(sflow_flow_record->length);
-	printf("\n\t    enterprise %u %s (%u) length %u",
+	ND_PRINT((ndo, "\n\t    enterprise %u %s (%u) length %u",
 	       enterprise,
 	       (enterprise == 0) ? tok2str(sflow_flow_type_values,"Unknown",flow_type) : "Unknown",
 	       flow_type,
-	       flow_len);
+	       flow_len));
 
 	tptr += sizeof(struct sflow_flow_record_t);
 	tlen -= sizeof(struct sflow_flow_record_t);
@@ -704,15 +708,15 @@
 	if (enterprise == 0) {
 	    switch (flow_type) {
 	    case SFLOW_FLOW_RAW_PACKET:
-		if (print_sflow_raw_packet(tptr,tlen))
+		if (print_sflow_raw_packet(ndo, tptr, tlen))
 		    return 1;
 		break;
 	    case SFLOW_FLOW_EXTENDED_SWITCH_DATA:
-		if (print_sflow_extended_switch_data(tptr,tlen))
+		if (print_sflow_extended_switch_data(ndo, tptr, tlen))
 		    return 1;
 		break;
 	    case SFLOW_FLOW_ETHERNET_FRAME:
-		if (print_sflow_ethernet_frame(tptr,tlen))
+		if (print_sflow_ethernet_frame(ndo, tptr, tlen))
 		    return 1;
 		break;
 		/* FIXME these need a decoder */
@@ -731,8 +735,8 @@
 	    case SFLOW_FLOW_EXTENDED_VLAN_TUNNEL:
 		break;
 	    default:
-		if (vflag <= 1)
-		    print_unknown_data(tptr, "\n\t\t", flow_len);
+		if (ndo->ndo_vflag <= 1)
+		    print_unknown_data(ndo, tptr, "\n\t\t", flow_len);
 		break;
 	    }
 	}
@@ -746,8 +750,9 @@
 }
 
 static int
-sflow_print_flow_sample(const u_char *pointer, u_int len) {
-
+sflow_print_flow_sample(netdissect_options *ndo,
+                        const u_char *pointer, u_int len)
+{
     const struct sflow_flow_sample_t *sflow_flow_sample;
     u_int          nrecords;
     u_int          typesource;
@@ -764,7 +769,7 @@
     type = typesource >> 24;
     index = typesource & 0x0FFF;
 
-    printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u",
+    ND_PRINT((ndo, " seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u",
 	   EXTRACT_32BITS(sflow_flow_sample->seqnum),
 	   type,
 	   index,
@@ -773,17 +778,18 @@
 	   EXTRACT_32BITS(sflow_flow_sample->drops),
 	   EXTRACT_32BITS(sflow_flow_sample->in_interface),
 	   EXTRACT_32BITS(sflow_flow_sample->out_interface),
-	   nrecords);
+	   nrecords));
 
-    return sflow_print_flow_records(pointer + sizeof(struct sflow_flow_sample_t),
+    return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_flow_sample_t),
 				    len - sizeof(struct sflow_flow_sample_t),
 				    nrecords);
 
 }
 
 static int
-sflow_print_expanded_flow_sample(const u_char *pointer, u_int len) {
-
+sflow_print_expanded_flow_sample(netdissect_options *ndo,
+                                 const u_char *pointer, u_int len)
+{
     const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample;
     u_int nrecords;
 
@@ -794,68 +800,69 @@
 
     nrecords = EXTRACT_32BITS(sflow_expanded_flow_sample->records);
 
-    printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u",
+    ND_PRINT((ndo, " seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u",
 	   EXTRACT_32BITS(sflow_expanded_flow_sample->seqnum),
 	   EXTRACT_32BITS(sflow_expanded_flow_sample->type),
 	   EXTRACT_32BITS(sflow_expanded_flow_sample->index),
 	   EXTRACT_32BITS(sflow_expanded_flow_sample->rate),
 	   EXTRACT_32BITS(sflow_expanded_flow_sample->pool),
 	   EXTRACT_32BITS(sflow_expanded_flow_sample->drops),
-	   EXTRACT_32BITS(sflow_expanded_flow_sample->records));
-    
-    return sflow_print_flow_records(pointer + sizeof(struct sflow_expanded_flow_sample_t),
+	   EXTRACT_32BITS(sflow_expanded_flow_sample->records)));
+
+    return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_expanded_flow_sample_t),
 				    len - sizeof(struct sflow_expanded_flow_sample_t),
 				    nrecords);
 
 }
 
 void
-sflow_print(const u_char *pptr, u_int len) {
-
+sflow_print(netdissect_options *ndo,
+            const u_char *pptr, u_int len)
+{
     const struct sflow_datagram_t *sflow_datagram;
     const struct sflow_sample_header *sflow_sample;
 
     const u_char *tptr;
     u_int tlen;
-    u_int32_t sflow_sample_type, sflow_sample_len;
-    u_int32_t nsamples;
+    uint32_t sflow_sample_type, sflow_sample_len;
+    uint32_t nsamples;
 
 
     tptr = pptr;
     tlen = len;
     sflow_datagram = (const struct sflow_datagram_t *)pptr;
-    TCHECK(*sflow_datagram);
+    ND_TCHECK(*sflow_datagram);
 
     /*
      * Sanity checking of the header.
      */
     if (EXTRACT_32BITS(sflow_datagram->version) != 5) {
-        printf("sFlow version %u packet not supported",
-               EXTRACT_32BITS(sflow_datagram->version));
+        ND_PRINT((ndo, "sFlow version %u packet not supported",
+               EXTRACT_32BITS(sflow_datagram->version)));
         return;
     }
 
-    if (vflag < 1) {
-        printf("sFlowv%u, %s agent %s, agent-id %u, length %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "sFlowv%u, %s agent %s, agent-id %u, length %u",
                EXTRACT_32BITS(sflow_datagram->version),
                EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6",
-	       ipaddr_string(sflow_datagram->agent),
+               ipaddr_string(ndo, sflow_datagram->agent),
                EXTRACT_32BITS(sflow_datagram->agent_id),
-               len);
+               len));
         return;
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
     nsamples=EXTRACT_32BITS(sflow_datagram->samples);
-    printf("sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u",
+    ND_PRINT((ndo, "sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u",
            EXTRACT_32BITS(sflow_datagram->version),
            EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6",
-           ipaddr_string(sflow_datagram->agent),
+           ipaddr_string(ndo, sflow_datagram->agent),
            EXTRACT_32BITS(sflow_datagram->agent_id),
            EXTRACT_32BITS(sflow_datagram->seqnum),
            EXTRACT_32BITS(sflow_datagram->uptime),
            nsamples,
-           len);
+           len));
 
     /* skip Common header */
     tptr += sizeof(const struct sflow_datagram_t);
@@ -863,7 +870,7 @@
 
     while (nsamples > 0 && tlen > 0) {
         sflow_sample = (const struct sflow_sample_header *)tptr;
-        TCHECK(*sflow_sample);
+        ND_TCHECK(*sflow_sample);
 
         sflow_sample_type = (EXTRACT_32BITS(sflow_sample->format)&0x0FFF);
         sflow_sample_len = EXTRACT_32BITS(sflow_sample->len);
@@ -873,11 +880,11 @@
 
         tptr += sizeof(struct sflow_sample_header);
         tlen -= sizeof(struct sflow_sample_header);
-  
-        printf("\n\t%s (%u), length %u,",
+
+        ND_PRINT((ndo, "\n\t%s (%u), length %u,",
                tok2str(sflow_format_values, "Unknown", sflow_sample_type),
                sflow_sample_type,
-               sflow_sample_len);
+               sflow_sample_len));
 
         /* basic sanity check */
         if (sflow_sample_type == 0 || sflow_sample_len ==0) {
@@ -888,32 +895,32 @@
 	    goto trunc;
 
         /* did we capture enough for fully decoding the sample ? */
-        TCHECK2(*tptr, sflow_sample_len);
+        ND_TCHECK2(*tptr, sflow_sample_len);
 
 	switch(sflow_sample_type) {
         case SFLOW_FLOW_SAMPLE:
-	    if (sflow_print_flow_sample(tptr,tlen))
+	    if (sflow_print_flow_sample(ndo, tptr, tlen))
 		goto trunc;
             break;
 
         case SFLOW_COUNTER_SAMPLE:
-	    if (sflow_print_counter_sample(tptr,tlen))
+	    if (sflow_print_counter_sample(ndo, tptr,tlen))
 		goto trunc;
             break;
 
         case SFLOW_EXPANDED_FLOW_SAMPLE:
-	    if (sflow_print_expanded_flow_sample(tptr,tlen))
+	    if (sflow_print_expanded_flow_sample(ndo, tptr, tlen))
 		goto trunc;
 	    break;
 
         case SFLOW_EXPANDED_COUNTER_SAMPLE:
-	    if (sflow_print_expanded_counter_sample(tptr,tlen))
+	    if (sflow_print_expanded_counter_sample(ndo, tptr,tlen))
 		goto trunc;
 	    break;
 
         default:
-            if (vflag <= 1)
-                print_unknown_data(tptr, "\n\t    ", sflow_sample_len);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo, tptr, "\n\t    ", sflow_sample_len);
             break;
         }
         tptr += sflow_sample_len;
@@ -923,7 +930,7 @@
     return;
 
  trunc:
-    printf("[|SFLOW]");
+    ND_PRINT((ndo, "[|SFLOW]"));
 }
 
 /*
diff --git a/print-sip.c b/print-sip.c
index c5bc853..d0fd349 100644
--- a/print-sip.c
+++ b/print-sip.c
@@ -11,54 +11,43 @@
  * FOR A PARTICULAR PURPOSE.
  *
  * Original code by Hannes Gredler (hannes@juniper.net)
+ * Turned into common "text protocol" code, which this uses, by
+ * Guy Harris.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sip.c,v 1.1 2004-07-27 17:04:20 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
 
-#include "udp.h"
+static const char *sipcmds[] = {
+	"ACK",
+	"BYE",
+	"CANCEL",
+	"DO",
+	"INFO",
+	"INVITE",
+	"MESSAGE",
+	"NOTIFY",
+	"OPTIONS",
+	"PRACK",
+	"QAUTH",
+	"REFER",
+	"REGISTER",
+	"SPRACK",
+	"SUBSCRIBE",
+	"UPDATE",
+	"PUBLISH",
+	NULL
+};
 
 void
-sip_print(register const u_char *pptr, register u_int len)
+sip_print(netdissect_options *ndo, const u_char *pptr, u_int len)
 {
-    u_int idx;
-
-    printf("SIP, length: %u%s", len, vflag ? "\n\t" : "");
-
-    /* in non-verbose mode just lets print the protocol and length */
-    if (vflag < 1)
-        return;
-
-    for (idx = 0; idx < len; idx++) {
-        TCHECK2(*(pptr+idx), 2);
-        if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */
-            safeputchar(*(pptr+idx));
-        } else {
-            printf("\n\t");
-            idx+=1;
-        }
-    }
-
-    /* do we want to see an additionally hexdump ? */
-    if (vflag> 1)
-        print_unknown_data(pptr,"\n\t",len);
-
-    return;
-
-trunc:
-    printf("[|sip]");
+	txtproto_print(ndo, pptr, len, "sip", sipcmds, RESP_CODE_SECOND_TOKEN);
 }
diff --git a/print-sl.c b/print-sl.c
index 91dbaad..bd410ce 100644
--- a/print-sl.c
+++ b/print-sl.c
@@ -19,44 +19,51 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.65 2005-04-06 21:32:42 mcr Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"			/* must come after interface.h */
 
 #include "ip.h"
 #include "tcp.h"
-#include "slip.h"
 #include "slcompress.h"
 
+/*
+ * definitions of the pseudo- link-level header attached to slip
+ * packets grabbed by the packet filter (bpf) traffic monitor.
+ */
+#define SLIP_HDRLEN 16
+
+#define SLX_DIR 0
+#define SLX_CHDR 1
+#define CHDR_LEN 15
+
+#define SLIPDIR_IN 0
+#define SLIPDIR_OUT 1
+
+static const char tstr[] = "[|slip]";
+
 static u_int lastlen[2][256];
 static u_int lastconn = 255;
 
-static void sliplink_print(const u_char *, const struct ip *, u_int);
-static void compressed_sl_print(const u_char *, const struct ip *, u_int, int);
+static void sliplink_print(netdissect_options *, const u_char *, const struct ip *, u_int);
+static void compressed_sl_print(netdissect_options *, const u_char *, const struct ip *, u_int, int);
 
 u_int
-sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sl_if_print(netdissect_options *ndo,
+            const struct pcap_pkthdr *h, const u_char *p)
 {
 	register u_int caplen = h->caplen;
 	register u_int length = h->len;
 	register const struct ip *ip;
 
-	if (caplen < SLIP_HDRLEN) {
-		printf("[|slip]");
+	if (caplen < SLIP_HDRLEN || length < SLIP_HDRLEN) {
+		ND_PRINT((ndo, "%s", tstr));
 		return (caplen);
 	}
 
@@ -64,34 +71,33 @@
 
 	ip = (struct ip *)(p + SLIP_HDRLEN);
 
-	if (eflag)
-		sliplink_print(p, ip, length);
+	if (ndo->ndo_eflag)
+		sliplink_print(ndo, p, ip, length);
 
 	switch (IP_V(ip)) {
 	case 4:
-	        ip_print(gndo, (u_char *)ip, length);
+	        ip_print(ndo, (u_char *)ip, length);
 		break;
-#ifdef INET6
 	case 6:
-		ip6_print(gndo, (u_char *)ip, length);
+		ip6_print(ndo, (u_char *)ip, length);
 		break;
-#endif
 	default:
-		printf ("ip v%d", IP_V(ip));
+		ND_PRINT((ndo, "ip v%d", IP_V(ip)));
 	}
 
 	return (SLIP_HDRLEN);
 }
 
 u_int
-sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sl_bsdos_if_print(netdissect_options *ndo,
+                  const struct pcap_pkthdr *h, const u_char *p)
 {
 	register u_int caplen = h->caplen;
 	register u_int length = h->len;
 	register const struct ip *ip;
 
 	if (caplen < SLIP_HDRLEN) {
-		printf("[|slip]");
+		ND_PRINT((ndo, "%s", tstr));
 		return (caplen);
 	}
 
@@ -100,39 +106,39 @@
 	ip = (struct ip *)(p + SLIP_HDRLEN);
 
 #ifdef notdef
-	if (eflag)
-		sliplink_print(p, ip, length);
+	if (ndo->ndo_eflag)
+		sliplink_print(ndo, p, ip, length);
 #endif
 
-	ip_print(gndo, (u_char *)ip, length);
+	ip_print(ndo, (u_char *)ip, length);
 
 	return (SLIP_HDRLEN);
 }
 
 static void
-sliplink_print(register const u_char *p, register const struct ip *ip,
-	       register u_int length)
+sliplink_print(netdissect_options *ndo,
+               register const u_char *p, register const struct ip *ip,
+               register u_int length)
 {
 	int dir;
 	u_int hlen;
 
 	dir = p[SLX_DIR];
-	putchar(dir == SLIPDIR_IN ? 'I' : 'O');
-	putchar(' ');
+	ND_PRINT((ndo, dir == SLIPDIR_IN ? "I " : "O "));
 
-	if (nflag) {
+	if (ndo->ndo_nflag) {
 		/* XXX just dump the header */
 		register int i;
 
 		for (i = SLX_CHDR; i < SLX_CHDR + CHDR_LEN - 1; ++i)
-			printf("%02x.", p[i]);
-		printf("%02x: ", p[SLX_CHDR + CHDR_LEN - 1]);
+			ND_PRINT((ndo, "%02x.", p[i]));
+		ND_PRINT((ndo, "%02x: ", p[SLX_CHDR + CHDR_LEN - 1]));
 		return;
 	}
 	switch (p[SLX_CHDR] & 0xf0) {
 
 	case TYPE_IP:
-		printf("ip %d: ", length + SLIP_HDRLEN);
+		ND_PRINT((ndo, "ip %d: ", length + SLIP_HDRLEN));
 		break;
 
 	case TYPE_UNCOMPRESSED_TCP:
@@ -145,21 +151,22 @@
 		hlen = IP_HL(ip);
 		hlen += TH_OFF((struct tcphdr *)&((int *)ip)[hlen]);
 		lastlen[dir][lastconn] = length - (hlen << 2);
-		printf("utcp %d: ", lastconn);
+		ND_PRINT((ndo, "utcp %d: ", lastconn));
 		break;
 
 	default:
 		if (p[SLX_CHDR] & TYPE_COMPRESSED_TCP) {
-			compressed_sl_print(&p[SLX_CHDR], ip,
+			compressed_sl_print(ndo, &p[SLX_CHDR], ip,
 			    length, dir);
-			printf(": ");
+			ND_PRINT((ndo, ": "));
 		} else
-			printf("slip-%d!: ", p[SLX_CHDR]);
+			ND_PRINT((ndo, "slip-%d!: ", p[SLX_CHDR]));
 	}
 }
 
 static const u_char *
-print_sl_change(const char *str, register const u_char *cp)
+print_sl_change(netdissect_options *ndo,
+                const char *str, register const u_char *cp)
 {
 	register u_int i;
 
@@ -167,12 +174,13 @@
 		i = EXTRACT_16BITS(cp);
 		cp += 2;
 	}
-	printf(" %s%d", str, i);
+	ND_PRINT((ndo, " %s%d", str, i));
 	return (cp);
 }
 
 static const u_char *
-print_sl_winchange(register const u_char *cp)
+print_sl_winchange(netdissect_options *ndo,
+                   register const u_char *cp)
 {
 	register short i;
 
@@ -181,15 +189,16 @@
 		cp += 2;
 	}
 	if (i >= 0)
-		printf(" W+%d", i);
+		ND_PRINT((ndo, " W+%d", i));
 	else
-		printf(" W%d", i);
+		ND_PRINT((ndo, " W%d", i));
 	return (cp);
 }
 
 static void
-compressed_sl_print(const u_char *chdr, const struct ip *ip,
-		    u_int length, int dir)
+compressed_sl_print(netdissect_options *ndo,
+                    const u_char *chdr, const struct ip *ip,
+                    u_int length, int dir)
 {
 	register const u_char *cp = chdr;
 	register u_int flags, hlen;
@@ -197,35 +206,35 @@
 	flags = *cp++;
 	if (flags & NEW_C) {
 		lastconn = *cp++;
-		printf("ctcp %d", lastconn);
+		ND_PRINT((ndo, "ctcp %d", lastconn));
 	} else
-		printf("ctcp *");
+		ND_PRINT((ndo, "ctcp *"));
 
 	/* skip tcp checksum */
 	cp += 2;
 
 	switch (flags & SPECIALS_MASK) {
 	case SPECIAL_I:
-		printf(" *SA+%d", lastlen[dir][lastconn]);
+		ND_PRINT((ndo, " *SA+%d", lastlen[dir][lastconn]));
 		break;
 
 	case SPECIAL_D:
-		printf(" *S+%d", lastlen[dir][lastconn]);
+		ND_PRINT((ndo, " *S+%d", lastlen[dir][lastconn]));
 		break;
 
 	default:
 		if (flags & NEW_U)
-			cp = print_sl_change("U=", cp);
+			cp = print_sl_change(ndo, "U=", cp);
 		if (flags & NEW_W)
-			cp = print_sl_winchange(cp);
+			cp = print_sl_winchange(ndo, cp);
 		if (flags & NEW_A)
-			cp = print_sl_change("A+", cp);
+			cp = print_sl_change(ndo, "A+", cp);
 		if (flags & NEW_S)
-			cp = print_sl_change("S+", cp);
+			cp = print_sl_change(ndo, "S+", cp);
 		break;
 	}
 	if (flags & NEW_I)
-		cp = print_sl_change("I+", cp);
+		cp = print_sl_change(ndo, "I+", cp);
 
 	/*
 	 * 'hlen' is the length of the uncompressed TCP/IP header (in words).
@@ -235,5 +244,5 @@
 	hlen = IP_HL(ip);
 	hlen += TH_OFF((struct tcphdr *)&((int32_t *)ip)[hlen]);
 	lastlen[dir][lastconn] = length - (hlen << 2);
-	printf(" %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr));
+	ND_PRINT((ndo, " %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr)));
 }
diff --git a/print-sll.c b/print-sll.c
index 062398e..1f5f600 100644
--- a/print-sll.c
+++ b/print-sll.c
@@ -18,28 +18,108 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.19 2005-11-13 12:12:43 guy Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-#include <pcap.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "ethertype.h"
 #include "extract.h"
 
 #include "ether.h"
-#include "sll.h"
+
+/*
+ * For captures on Linux cooked sockets, we construct a fake header
+ * that includes:
+ *
+ *	a 2-byte "packet type" which is one of:
+ *
+ *		LINUX_SLL_HOST		packet was sent to us
+ *		LINUX_SLL_BROADCAST	packet was broadcast
+ *		LINUX_SLL_MULTICAST	packet was multicast
+ *		LINUX_SLL_OTHERHOST	packet was sent to somebody else
+ *		LINUX_SLL_OUTGOING	packet was sent *by* us;
+ *
+ *	a 2-byte Ethernet protocol field;
+ *
+ *	a 2-byte link-layer type;
+ *
+ *	a 2-byte link-layer address length;
+ *
+ *	an 8-byte source link-layer address, whose actual length is
+ *	specified by the previous value.
+ *
+ * All fields except for the link-layer address are in network byte order.
+ *
+ * DO NOT change the layout of this structure, or change any of the
+ * LINUX_SLL_ values below.  If you must change the link-layer header
+ * for a "cooked" Linux capture, introduce a new DLT_ type (ask
+ * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it
+ * a value that collides with a value already being used), and use the
+ * new header in captures of that type, so that programs that can
+ * handle DLT_LINUX_SLL captures will continue to handle them correctly
+ * without any change, and so that capture files with different headers
+ * can be told apart and programs that read them can dissect the
+ * packets in them.
+ *
+ * This structure, and the #defines below, must be the same in the
+ * libpcap and tcpdump versions of "sll.h".
+ */
+
+/*
+ * A DLT_LINUX_SLL fake link-layer header.
+ */
+#define SLL_HDR_LEN	16		/* total header length */
+#define SLL_ADDRLEN	8		/* length of address field */
+
+struct sll_header {
+	uint16_t	sll_pkttype;	/* packet type */
+	uint16_t	sll_hatype;	/* link-layer address type */
+	uint16_t	sll_halen;	/* link-layer address length */
+	uint8_t		sll_addr[SLL_ADDRLEN];	/* link-layer address */
+	uint16_t	sll_protocol;	/* protocol */
+};
+
+/*
+ * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
+ * PACKET_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux, and so that they
+ * don't change even if the PACKET_ values change.
+ */
+#define LINUX_SLL_HOST		0
+#define LINUX_SLL_BROADCAST	1
+#define LINUX_SLL_MULTICAST	2
+#define LINUX_SLL_OTHERHOST	3
+#define LINUX_SLL_OUTGOING	4
+
+/*
+ * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
+ * ETH_P_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux.  We assume, for now,
+ * that the ETH_P_ values won't change in Linux; if they do, then:
+ *
+ *	if we don't translate them in "pcap-linux.c", capture files
+ *	won't necessarily be readable if captured on a system that
+ *	defines ETH_P_ values that don't match these values;
+ *
+ *	if we do translate them in "pcap-linux.c", that makes life
+ *	unpleasant for the BPF code generator, as the values you test
+ *	for in the kernel aren't the values that you test for when
+ *	reading a capture file, so the fixup code run on BPF programs
+ *	handed to the kernel ends up having to do more work.
+ *
+ * Add other values here as necessary, for handling packet types that
+ * might show up on non-Ethernet, non-802.x networks.  (Not all the ones
+ * in the Linux "if_ether.h" will, I suspect, actually show up in
+ * captures.)
+ */
+#define LINUX_SLL_P_802_3	0x0001	/* Novell 802.3 frames without 802.2 LLC header */
+#define LINUX_SLL_P_802_2	0x0004	/* 802.2 frames (not D/I/X Ethernet) */
 
 static const struct tok sll_pkttype_values[] = {
     { LINUX_SLL_HOST, "In" },
@@ -51,11 +131,11 @@
 };
 
 static inline void
-sll_print(register const struct sll_header *sllp, u_int length)
+sll_print(netdissect_options *ndo, register const struct sll_header *sllp, u_int length)
 {
 	u_short ether_type;
 
-        printf("%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype)));
+        ND_PRINT((ndo, "%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype))));
 
 	/*
 	 * XXX - check the link-layer address type value?
@@ -63,11 +143,11 @@
 	 * XXX - print others as strings of hex?
 	 */
 	if (EXTRACT_16BITS(&sllp->sll_halen) == 6)
-		(void)printf("%s ", etheraddr_string(sllp->sll_addr));
+		ND_PRINT((ndo, "%s ", etheraddr_string(ndo, sllp->sll_addr)));
 
-	if (!qflag) {
+	if (!ndo->ndo_qflag) {
 		ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
-	
+
 		if (ether_type <= ETHERMTU) {
 			/*
 			 * Not an Ethernet type; what type is it?
@@ -78,30 +158,30 @@
 				/*
 				 * Ethernet_802.3 IPX frame.
 				 */
-				(void)printf("802.3");
+				ND_PRINT((ndo, "802.3"));
 				break;
 
 			case LINUX_SLL_P_802_2:
 				/*
 				 * 802.2.
 				 */
-				(void)printf("802.2");
+				ND_PRINT((ndo, "802.2"));
 				break;
 
 			default:
 				/*
 				 * What is it?
 				 */
-				(void)printf("ethertype Unknown (0x%04x)",
-				    ether_type);
+				ND_PRINT((ndo, "ethertype Unknown (0x%04x)",
+				    ether_type));
 				break;
 			}
 		} else {
-			(void)printf("ethertype %s (0x%04x)",
+			ND_PRINT((ndo, "ethertype %s (0x%04x)",
 			    tok2str(ethertype_values, "Unknown", ether_type),
-			    ether_type);
+			    ether_type));
 		}
-		(void)printf(", length %u: ", length);
+		ND_PRINT((ndo, ", length %u: ", length));
 	}
 }
 
@@ -112,7 +192,7 @@
  * is the number of bytes actually captured.
  */
 u_int
-sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	u_int length = h->len;
@@ -126,14 +206,14 @@
 		 * adds this many bytes of header to every packet in a
 		 * cooked socket capture.
 		 */
-		printf("[|sll]");
+		ND_PRINT((ndo, "[|sll]"));
 		return (caplen);
 	}
 
 	sllp = (const struct sll_header *)p;
 
-	if (eflag)
-		sll_print(sllp, length);
+	if (ndo->ndo_eflag)
+		sll_print(ndo, sllp, length);
 
 	/*
 	 * Go past the cooked-mode header.
@@ -159,7 +239,7 @@
 			/*
 			 * Ethernet_802.3 IPX frame.
 			 */
-			ipx_print(p, length);
+			ipx_print(ndo, p, length);
 			break;
 
 		case LINUX_SLL_P_802_2:
@@ -167,7 +247,7 @@
 			 * 802.2.
 			 * Try to print the LLC-layer header & higher layers.
 			 */
-			if (llc_print(p, length, caplen, NULL, NULL,
+			if (llc_print(ndo, p, length, caplen, NULL, NULL,
 			    &extracted_ethertype) == 0)
 				goto unknown;	/* unknown LLC type */
 			break;
@@ -178,14 +258,14 @@
 
 		unknown:
 			/* ether_type not known, print raw packet */
-			if (!eflag)
-				sll_print(sllp, length + SLL_HDR_LEN);
+			if (!ndo->ndo_eflag)
+				sll_print(ndo, sllp, length + SLL_HDR_LEN);
 			if (extracted_ethertype) {
-				printf("(LLC %s) ",
-			       etherproto_string(htons(extracted_ethertype)));
+				ND_PRINT((ndo, "(LLC %s) ",
+			       etherproto_string(htons(extracted_ethertype))));
 			}
-			if (!suppress_default_print)
-				default_print(p, caplen);
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p, caplen);
 			break;
 		}
 	} else if (ether_type == ETHERTYPE_8021Q) {
@@ -194,36 +274,33 @@
 		 * the enclosed type field.
 		 */
 		if (caplen < 4 || length < 4) {
-			printf("[|vlan]");
+			ND_PRINT((ndo, "[|vlan]"));
 			return (SLL_HDR_LEN);
 		}
-	        if (eflag) {
-	        	u_int16_t tag = EXTRACT_16BITS(p);
+	        if (ndo->ndo_eflag) {
+	        	uint16_t tag = EXTRACT_16BITS(p);
 
-			printf("vlan %u, p %u%s, ",
-			    tag & 0xfff,
-			    tag >> 13,
-			    (tag & 0x1000) ? ", CFI" : "");
+			ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag)));
 		}
 
 		ether_type = EXTRACT_16BITS(p + 2);
 		if (ether_type <= ETHERMTU)
 			ether_type = LINUX_SLL_P_802_2;
-		if (!qflag) {
-			(void)printf("ethertype %s, ",
-			    tok2str(ethertype_values, "Unknown", ether_type));
+		if (!ndo->ndo_qflag) {
+			ND_PRINT((ndo, "ethertype %s, ",
+			    tok2str(ethertype_values, "Unknown", ether_type)));
 		}
 		p += 4;
 		length -= 4;
 		caplen -= 4;
 		goto recurse;
 	} else {
-		if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+		if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
 			/* ether_type not known, print raw packet */
-			if (!eflag)
-				sll_print(sllp, length + SLL_HDR_LEN);
-			if (!suppress_default_print)
-				default_print(p, caplen);
+			if (!ndo->ndo_eflag)
+				sll_print(ndo, sllp, length + SLL_HDR_LEN);
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p, caplen);
 		}
 	}
 
diff --git a/print-slow.c b/print-slow.c
index fdfefcc..2db3581 100644
--- a/print-slow.c
+++ b/print-slow.c
@@ -18,21 +18,13 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-slow.c,v 1.8 2006-10-12 05:44:33 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -40,8 +32,8 @@
 #include "oui.h"
 
 struct slow_common_header_t {
-    u_int8_t proto_subtype;
-    u_int8_t version;
+    uint8_t proto_subtype;
+    uint8_t version;
 };
 
 #define	SLOW_PROTO_LACP                     1
@@ -67,7 +59,7 @@
     { 0x0020, "Remote Evaluating" },
     { 0x0040, "Remote Stable" },
     { 0, NULL}
-}; 
+};
 
 #define SLOW_OAM_CODE_INFO          0x00
 #define SLOW_OAM_CODE_EVENT_NOTIF   0x01
@@ -87,15 +79,15 @@
 };
 
 struct slow_oam_info_t {
-    u_int8_t info_type;
-    u_int8_t info_length;
-    u_int8_t oam_version;
-    u_int8_t revision[2];
-    u_int8_t state;
-    u_int8_t oam_config;
-    u_int8_t oam_pdu_config[2];
-    u_int8_t oui[3];
-    u_int8_t vendor_private[4];
+    uint8_t info_type;
+    uint8_t info_length;
+    uint8_t oam_version;
+    uint8_t revision[2];
+    uint8_t state;
+    uint8_t oam_config;
+    uint8_t oam_pdu_config[2];
+    uint8_t oui[3];
+    uint8_t vendor_private[4];
 };
 
 #define SLOW_OAM_INFO_TYPE_END_OF_TLV 0x00
@@ -157,29 +149,29 @@
 };
 
 struct slow_oam_link_event_t {
-    u_int8_t event_type;
-    u_int8_t event_length;
-    u_int8_t time_stamp[2];
-    u_int8_t window[8];
-    u_int8_t threshold[8];
-    u_int8_t errors[8];
-    u_int8_t errors_running_total[8];
-    u_int8_t event_running_total[4];
+    uint8_t event_type;
+    uint8_t event_length;
+    uint8_t time_stamp[2];
+    uint8_t window[8];
+    uint8_t threshold[8];
+    uint8_t errors[8];
+    uint8_t errors_running_total[8];
+    uint8_t event_running_total[4];
 };
 
 struct slow_oam_variablerequest_t {
-    u_int8_t branch;
-    u_int8_t leaf[2];
+    uint8_t branch;
+    uint8_t leaf[2];
 };
 
 struct slow_oam_variableresponse_t {
-    u_int8_t branch;
-    u_int8_t leaf[2];
-    u_int8_t length;
+    uint8_t branch;
+    uint8_t leaf[2];
+    uint8_t length;
 };
 
 struct slow_oam_loopbackctrl_t {
-    u_int8_t command;
+    uint8_t command;
 };
 
 static const struct tok slow_oam_loopbackctrl_cmd_values[] = {
@@ -189,8 +181,8 @@
 };
 
 struct tlv_header_t {
-    u_int8_t type;
-    u_int8_t length;
+    uint8_t type;
+    uint8_t length;
 };
 
 #define LACP_TLV_TERMINATOR     0x00
@@ -213,14 +205,14 @@
 };
 
 struct lacp_tlv_actor_partner_info_t {
-    u_int8_t sys_pri[2];
-    u_int8_t sys[ETHER_ADDR_LEN];
-    u_int8_t key[2];
-    u_int8_t port_pri[2];
-    u_int8_t port[2];
-    u_int8_t state;
-    u_int8_t pad[3];
-};          
+    uint8_t sys_pri[2];
+    uint8_t sys[ETHER_ADDR_LEN];
+    uint8_t key[2];
+    uint8_t port_pri[2];
+    uint8_t port[2];
+    uint8_t state;
+    uint8_t pad[3];
+};
 
 static const struct tok lacp_tlv_actor_partner_info_state_values[] = {
     { 0x01, "Activity"},
@@ -235,33 +227,34 @@
 };
 
 struct lacp_tlv_collector_info_t {
-    u_int8_t max_delay[2];
-    u_int8_t pad[12];
-}; 
+    uint8_t max_delay[2];
+    uint8_t pad[12];
+};
 
 struct marker_tlv_marker_info_t {
-    u_int8_t req_port[2];
-    u_int8_t req_sys[ETHER_ADDR_LEN];
-    u_int8_t req_trans_id[4];
-    u_int8_t pad[2];
-}; 
+    uint8_t req_port[2];
+    uint8_t req_sys[ETHER_ADDR_LEN];
+    uint8_t req_trans_id[4];
+    uint8_t pad[2];
+};
 
 struct lacp_marker_tlv_terminator_t {
-    u_int8_t pad[50];
-}; 
+    uint8_t pad[50];
+};
 
-void slow_marker_lacp_print(register const u_char *, register u_int);
-void slow_oam_print(register const u_char *, register u_int);
+static void slow_marker_lacp_print(netdissect_options *, register const u_char *, register u_int);
+static void slow_oam_print(netdissect_options *, register const u_char *, register u_int);
 
 const struct slow_common_header_t *slow_com_header;
 
 void
-slow_print(register const u_char *pptr, register u_int len) {
-
+slow_print(netdissect_options *ndo,
+           register const u_char *pptr, register u_int len)
+{
     int print_version;
 
     slow_com_header = (const struct slow_common_header_t *)pptr;
-    TCHECK(*slow_com_header);
+    ND_TCHECK(*slow_com_header);
 
     /*
      * Sanity checking of the header.
@@ -269,7 +262,7 @@
     switch (slow_com_header->proto_subtype) {
     case SLOW_PROTO_LACP:
         if (slow_com_header->version != LACP_VERSION) {
-            printf("LACP version %u packet not supported",slow_com_header->version);
+            ND_PRINT((ndo, "LACP version %u packet not supported",slow_com_header->version));
             return;
         }
         print_version = 1;
@@ -277,7 +270,7 @@
 
     case SLOW_PROTO_MARKER:
         if (slow_com_header->version != MARKER_VERSION) {
-            printf("MARKER version %u packet not supported",slow_com_header->version);
+            ND_PRINT((ndo, "MARKER version %u packet not supported",slow_com_header->version));
             return;
         }
         print_version = 1;
@@ -294,24 +287,24 @@
     }
 
     if (print_version) {
-        printf("%sv%u, length %u",
+        ND_PRINT((ndo, "%sv%u, length %u",
                tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
                slow_com_header->version,
-               len);
+               len));
     } else {
         /* some slow protos don't have a version number in the header */
-        printf("%s, length %u",
+        ND_PRINT((ndo, "%s, length %u",
                tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
-               len);
+               len));
     }
 
     /* unrecognized subtype */
     if (print_version == -1) {
-        print_unknown_data(pptr, "\n\t", len);
+        print_unknown_data(ndo, pptr, "\n\t", len);
         return;
     }
 
-    if (!vflag)
+    if (!ndo->ndo_vflag)
         return;
 
     switch (slow_com_header->proto_subtype) {
@@ -320,7 +313,7 @@
 
     case SLOW_PROTO_OAM:
         /* skip proto_subtype */
-        slow_oam_print(pptr+1, len-1);
+        slow_oam_print(ndo, pptr+1, len-1);
         break;
 
     case SLOW_PROTO_LACP:   /* LACP and MARKER share the same semantics */
@@ -328,17 +321,19 @@
         /* skip slow_common_header */
         len -= sizeof(const struct slow_common_header_t);
         pptr += sizeof(const struct slow_common_header_t);
-        slow_marker_lacp_print(pptr, len);
+        slow_marker_lacp_print(ndo, pptr, len);
         break;
     }
     return;
 
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
 
-void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
-
+static void
+slow_marker_lacp_print(netdissect_options *ndo,
+                       register const u_char *tptr, register u_int tlen)
+{
     const struct tlv_header_t *tlv_header;
     const u_char *tlv_tptr;
     u_int tlv_len, tlv_tlen;
@@ -349,26 +344,26 @@
         const struct lacp_tlv_collector_info_t *lacp_tlv_collector_info;
         const struct marker_tlv_marker_info_t *marker_tlv_marker_info;
     } tlv_ptr;
-    
+
     while(tlen>0) {
         /* did we capture enough for fully decoding the tlv header ? */
-        TCHECK2(*tptr, sizeof(struct tlv_header_t));
+        ND_TCHECK2(*tptr, sizeof(struct tlv_header_t));
         tlv_header = (const struct tlv_header_t *)tptr;
         tlv_len = tlv_header->length;
 
-        printf("\n\t%s TLV (0x%02x), length %u",
+        ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
                tok2str(slow_tlv_values,
                        "Unknown",
                        (slow_com_header->proto_subtype << 8) + tlv_header->type),
                tlv_header->type,
-               tlv_len);
+               tlv_len));
 
         if ((tlv_len < sizeof(struct tlv_header_t) ||
             tlv_len > tlen) &&
             tlv_header->type != LACP_TLV_TERMINATOR &&
             tlv_header->type != MARKER_TLV_TERMINATOR) {
-            printf("\n\t-----trailing data-----");
-            print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t  ",tlen);
+            ND_PRINT((ndo, "\n\t-----trailing data-----"));
+            print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t  ", tlen);
             return;
         }
 
@@ -376,7 +371,7 @@
         tlv_tlen=tlv_len-sizeof(struct tlv_header_t);
 
         /* did we capture enough for fully decoding the tlv ? */
-        TCHECK2(*tptr, tlv_len);
+        ND_TCHECK2(*tptr, tlv_len);
 
         switch((slow_com_header->proto_subtype << 8) + tlv_header->type) {
 
@@ -385,34 +380,34 @@
         case ((SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO):
             tlv_ptr.lacp_tlv_actor_partner_info = (const struct lacp_tlv_actor_partner_info_t *)tlv_tptr;
 
-            printf("\n\t  System %s, System Priority %u, Key %u" \
+            ND_PRINT((ndo, "\n\t  System %s, System Priority %u, Key %u" \
                    ", Port %u, Port Priority %u\n\t  State Flags [%s]",
-                   etheraddr_string(tlv_ptr.lacp_tlv_actor_partner_info->sys),
+                   etheraddr_string(ndo, tlv_ptr.lacp_tlv_actor_partner_info->sys),
                    EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->sys_pri),
                    EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->key),
                    EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port),
                    EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port_pri),
                    bittok2str(lacp_tlv_actor_partner_info_state_values,
                               "none",
-                              tlv_ptr.lacp_tlv_actor_partner_info->state));
+                              tlv_ptr.lacp_tlv_actor_partner_info->state)));
 
             break;
 
         case ((SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO):
             tlv_ptr.lacp_tlv_collector_info = (const struct lacp_tlv_collector_info_t *)tlv_tptr;
 
-            printf("\n\t  Max Delay %u",
-                   EXTRACT_16BITS(tlv_ptr.lacp_tlv_collector_info->max_delay));
+            ND_PRINT((ndo, "\n\t  Max Delay %u",
+                   EXTRACT_16BITS(tlv_ptr.lacp_tlv_collector_info->max_delay)));
 
             break;
 
         case ((SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO):
             tlv_ptr.marker_tlv_marker_info = (const struct marker_tlv_marker_info_t *)tlv_tptr;
 
-            printf("\n\t  Request System %s, Request Port %u, Request Transaction ID 0x%08x",
-                   etheraddr_string(tlv_ptr.marker_tlv_marker_info->req_sys),
+            ND_PRINT((ndo, "\n\t  Request System %s, Request Port %u, Request Transaction ID 0x%08x",
+                   etheraddr_string(ndo, tlv_ptr.marker_tlv_marker_info->req_sys),
                    EXTRACT_16BITS(tlv_ptr.marker_tlv_marker_info->req_port),
-                   EXTRACT_32BITS(tlv_ptr.marker_tlv_marker_info->req_trans_id));
+                   EXTRACT_32BITS(tlv_ptr.marker_tlv_marker_info->req_trans_id)));
 
             break;
 
@@ -424,24 +419,24 @@
                 tlv_len = sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad) +
                     sizeof(struct tlv_header_t);
                 /* tell the user that we modified the length field  */
-                if (vflag>1)
-                    printf(" (=%u)",tlv_len);
+                if (ndo->ndo_vflag>1)
+                    ND_PRINT((ndo, " (=%u)", tlv_len));
                 /* we have messed around with the length field - now we need to check
                  * again if there are enough bytes on the wire for the hexdump */
-                TCHECK2(tlv_ptr.lacp_marker_tlv_terminator->pad[0],
+                ND_TCHECK2(tlv_ptr.lacp_marker_tlv_terminator->pad[0],
                         sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad));
             }
 
             break;
 
         default:
-            if (vflag <= 1)
-                print_unknown_data(tlv_tptr,"\n\t  ",tlv_tlen);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo, tlv_tptr, "\n\t  ", tlv_tlen);
             break;
         }
         /* do we want to see an additional hexdump ? */
-        if (vflag > 1) {
-            print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t  ",
+        if (ndo->ndo_vflag > 1) {
+            print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t  ",
                                tlv_len-sizeof(struct tlv_header_t));
         }
 
@@ -450,21 +445,23 @@
     }
     return;
 trunc:
-    printf("\n\t\t packet exceeded snapshot");
+    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
 }
 
-void slow_oam_print(register const u_char *tptr, register u_int tlen) {
-
+static void
+slow_oam_print(netdissect_options *ndo,
+               register const u_char *tptr, register u_int tlen)
+{
     u_int hexdump;
 
     struct slow_oam_common_header_t {
-        u_int8_t flags[2];
-        u_int8_t code;
+        uint8_t flags[2];
+        uint8_t code;
     };
 
     struct slow_oam_tlv_header_t {
-        u_int8_t type;
-        u_int8_t length;
+        uint8_t type;
+        uint8_t length;
     };
 
     union {
@@ -479,71 +476,71 @@
         const struct slow_oam_variableresponse_t *slow_oam_variableresponse;
         const struct slow_oam_loopbackctrl_t *slow_oam_loopbackctrl;
     } tlv;
-    
+
     ptr.slow_oam_common_header = (struct slow_oam_common_header_t *)tptr;
     tptr += sizeof(struct slow_oam_common_header_t);
     tlen -= sizeof(struct slow_oam_common_header_t);
 
-    printf("\n\tCode %s OAM PDU, Flags [%s]",
+    ND_PRINT((ndo, "\n\tCode %s OAM PDU, Flags [%s]",
            tok2str(slow_oam_code_values, "Unknown (%u)", ptr.slow_oam_common_header->code),
            bittok2str(slow_oam_flag_values,
                       "none",
-                      EXTRACT_16BITS(&ptr.slow_oam_common_header->flags)));
+                      EXTRACT_16BITS(&ptr.slow_oam_common_header->flags))));
 
     switch (ptr.slow_oam_common_header->code) {
     case SLOW_OAM_CODE_INFO:
         while (tlen > 0) {
             ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
-            printf("\n\t  %s Information Type (%u), length %u",
+            ND_PRINT((ndo, "\n\t  %s Information Type (%u), length %u",
                    tok2str(slow_oam_info_type_values, "Reserved",
                            ptr.slow_oam_tlv_header->type),
                    ptr.slow_oam_tlv_header->type,
-                   ptr.slow_oam_tlv_header->length);
+                   ptr.slow_oam_tlv_header->length));
 
             hexdump = FALSE;
             switch (ptr.slow_oam_tlv_header->type) {
             case SLOW_OAM_INFO_TYPE_END_OF_TLV:
                 if (ptr.slow_oam_tlv_header->length != 0) {
-                    printf("\n\t    ERROR: illegal length - should be 0");
+                    ND_PRINT((ndo, "\n\t    ERROR: illegal length - should be 0"));
                 }
                 return;
-                
+
             case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */
             case SLOW_OAM_INFO_TYPE_REMOTE:
                 tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr;
-                
+
                 if (tlv.slow_oam_info->info_length !=
                     sizeof(struct slow_oam_info_t)) {
-                    printf("\n\t    ERROR: illegal length - should be %lu",
-                           (unsigned long) sizeof(struct slow_oam_info_t));
+                    ND_PRINT((ndo, "\n\t    ERROR: illegal length - should be %lu",
+                           (unsigned long) sizeof(struct slow_oam_info_t)));
                     return;
                 }
 
-                printf("\n\t    OAM-Version %u, Revision %u",
+                ND_PRINT((ndo, "\n\t    OAM-Version %u, Revision %u",
                        tlv.slow_oam_info->oam_version,
-                       EXTRACT_16BITS(&tlv.slow_oam_info->revision));
+                       EXTRACT_16BITS(&tlv.slow_oam_info->revision)));
 
-                printf("\n\t    State-Parser-Action %s, State-MUX-Action %s",
+                ND_PRINT((ndo, "\n\t    State-Parser-Action %s, State-MUX-Action %s",
                        tok2str(slow_oam_info_type_state_parser_values, "Reserved",
                                tlv.slow_oam_info->state & OAM_INFO_TYPE_PARSER_MASK),
                        tok2str(slow_oam_info_type_state_mux_values, "Reserved",
-                               tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK));
-                printf("\n\t    OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u",
+                               tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK)));
+                ND_PRINT((ndo, "\n\t    OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u",
                        bittok2str(slow_oam_info_type_oam_config_values, "none",
                                   tlv.slow_oam_info->oam_config),
                        EXTRACT_16BITS(&tlv.slow_oam_info->oam_pdu_config) &
-                       OAM_INFO_TYPE_PDU_SIZE_MASK);
-                printf("\n\t    OUI %s (0x%06x), Vendor-Private 0x%08x",
+                       OAM_INFO_TYPE_PDU_SIZE_MASK));
+                ND_PRINT((ndo, "\n\t    OUI %s (0x%06x), Vendor-Private 0x%08x",
                        tok2str(oui_values, "Unknown",
                                EXTRACT_24BITS(&tlv.slow_oam_info->oui)),
                        EXTRACT_24BITS(&tlv.slow_oam_info->oui),
-                       EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private));
+                       EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private)));
                 break;
-                
+
             case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC:
                 hexdump = TRUE;
                 break;
-                
+
             default:
                 hexdump = TRUE;
                 break;
@@ -555,8 +552,8 @@
             }
 
             /* do we also want to see a hex dump ? */
-            if (vflag > 1 || hexdump==TRUE) {
-                print_unknown_data(tptr,"\n\t  ",
+            if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
+                print_unknown_data(ndo, tptr, "\n\t  ",
                                    ptr.slow_oam_tlv_header->length);
             }
 
@@ -568,34 +565,34 @@
     case SLOW_OAM_CODE_EVENT_NOTIF:
         while (tlen > 0) {
             ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
-            printf("\n\t  %s Link Event Type (%u), length %u",
+            ND_PRINT((ndo, "\n\t  %s Link Event Type (%u), length %u",
                    tok2str(slow_oam_link_event_values, "Reserved",
                            ptr.slow_oam_tlv_header->type),
                    ptr.slow_oam_tlv_header->type,
-                   ptr.slow_oam_tlv_header->length);
+                   ptr.slow_oam_tlv_header->length));
 
             hexdump = FALSE;
             switch (ptr.slow_oam_tlv_header->type) {
             case SLOW_OAM_LINK_EVENT_END_OF_TLV:
                 if (ptr.slow_oam_tlv_header->length != 0) {
-                    printf("\n\t    ERROR: illegal length - should be 0");
+                    ND_PRINT((ndo, "\n\t    ERROR: illegal length - should be 0"));
                 }
                 return;
-                
+
             case SLOW_OAM_LINK_EVENT_ERR_SYM_PER: /* identical format - fall through */
             case SLOW_OAM_LINK_EVENT_ERR_FRM:
             case SLOW_OAM_LINK_EVENT_ERR_FRM_PER:
             case SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM:
                 tlv.slow_oam_link_event = (const struct slow_oam_link_event_t *)tptr;
-                
+
                 if (tlv.slow_oam_link_event->event_length !=
                     sizeof(struct slow_oam_link_event_t)) {
-                    printf("\n\t    ERROR: illegal length - should be %lu",
-                           (unsigned long) sizeof(struct slow_oam_link_event_t));
+                    ND_PRINT((ndo, "\n\t    ERROR: illegal length - should be %lu",
+                           (unsigned long) sizeof(struct slow_oam_link_event_t)));
                     return;
                 }
 
-                printf("\n\t    Timestamp %u ms, Errored Window %" PRIu64
+                ND_PRINT((ndo, "\n\t    Timestamp %u ms, Errored Window %" PRIu64
                        "\n\t    Errored Threshold %" PRIu64
                        "\n\t    Errors %" PRIu64
                        "\n\t    Error Running Total %" PRIu64
@@ -605,13 +602,13 @@
                        EXTRACT_64BITS(&tlv.slow_oam_link_event->threshold),
                        EXTRACT_64BITS(&tlv.slow_oam_link_event->errors),
                        EXTRACT_64BITS(&tlv.slow_oam_link_event->errors_running_total),
-                       EXTRACT_32BITS(&tlv.slow_oam_link_event->event_running_total));
+                       EXTRACT_32BITS(&tlv.slow_oam_link_event->event_running_total)));
                 break;
-                
+
             case SLOW_OAM_LINK_EVENT_ORG_SPECIFIC:
                 hexdump = TRUE;
                 break;
-                
+
             default:
                 hexdump = TRUE;
                 break;
@@ -623,8 +620,8 @@
             }
 
             /* do we also want to see a hex dump ? */
-            if (vflag > 1 || hexdump==TRUE) {
-                print_unknown_data(tptr,"\n\t  ",
+            if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
+                print_unknown_data(ndo, tptr, "\n\t  ",
                                    ptr.slow_oam_tlv_header->length);
             }
 
@@ -632,14 +629,14 @@
             tptr += ptr.slow_oam_tlv_header->length;
         }
         break;
- 
+
     case SLOW_OAM_CODE_LOOPBACK_CTRL:
         tlv.slow_oam_loopbackctrl = (const struct slow_oam_loopbackctrl_t *)tptr;
-        printf("\n\t  Command %s (%u)",
+        ND_PRINT((ndo, "\n\t  Command %s (%u)",
                tok2str(slow_oam_loopbackctrl_cmd_values,
                        "Unknown",
                        tlv.slow_oam_loopbackctrl->command),
-               tlv.slow_oam_loopbackctrl->command);
+               tlv.slow_oam_loopbackctrl->command));
                tptr ++;
                tlen --;
         break;
@@ -652,8 +649,8 @@
     case SLOW_OAM_CODE_VAR_RESPONSE:
     case SLOW_OAM_CODE_PRIVATE:
     default:
-        if (vflag <= 1) {
-            print_unknown_data(tptr,"\n\t  ", tlen);
+        if (ndo->ndo_vflag <= 1) {
+            print_unknown_data(ndo, tptr, "\n\t  ", tlen);
         }
         break;
     }
diff --git a/print-smb.c b/print-smb.c
index 68c7365..f5be9ff 100644
--- a/print-smb.c
+++ b/print-smb.c
@@ -6,24 +6,21 @@
  * or later
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.47 2007-12-09 00:30:47 guy Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "extract.h"
 #include "smb.h"
 
+static const char tstr[] = "[|SMB]";
+
 static int request = 0;
 static int unicodestr = 0;
 
@@ -34,7 +31,7 @@
     const char *req_f2;
     const char *rep_f1;
     const char *rep_f2;
-    void (*fn)(const u_char *, const u_char *, const u_char *, const u_char *);
+    void (*fn)(netdissect_options *, const u_char *, const u_char *, const u_char *, const u_char *);
 };
 
 struct smbdescriptint {
@@ -42,7 +39,7 @@
     const char *req_f2;
     const char *rep_f1;
     const char *rep_f2;
-    void (*fn)(const u_char *, const u_char *, int, int);
+    void (*fn)(netdissect_options *, const u_char *, const u_char *, int, int);
 };
 
 struct smbfns
@@ -65,8 +62,8 @@
 
 #define FLG_CHAIN	(1 << 0)
 
-static struct smbfns *
-smbfind(int id, struct smbfns *list)
+static const struct smbfns *
+smbfind(int id, const struct smbfns *list)
 {
     int sindex;
 
@@ -77,8 +74,8 @@
     return(&list[0]);
 }
 
-static struct smbfnsint *
-smbfindint(int id, struct smbfnsint *list)
+static const struct smbfnsint *
+smbfindint(int id, const struct smbfnsint *list)
 {
     int sindex;
 
@@ -90,7 +87,8 @@
 }
 
 static void
-trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt)
+trans2_findfirst(netdissect_options *ndo,
+                 const u_char *param, const u_char *data, int pcnt, int dcnt)
 {
     const char *fmt;
 
@@ -99,24 +97,25 @@
     else
 	fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
 
-    smb_fdata(param, fmt, param + pcnt, unicodestr);
+    smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
     if (dcnt) {
-	printf("data:\n");
-	print_data(data, dcnt);
+	ND_PRINT((ndo, "data:\n"));
+	print_data(ndo, data, dcnt);
     }
 }
 
 static void
-trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt)
+trans2_qfsinfo(netdissect_options *ndo,
+               const u_char *param, const u_char *data, int pcnt, int dcnt)
 {
     static int level = 0;
     const char *fmt="";
 
     if (request) {
-	TCHECK2(*param, 2);
+	ND_TCHECK2(*param, 2);
 	level = EXTRACT_LE_16BITS(param);
 	fmt = "InfoLevel=[d]\n";
-	smb_fdata(param, fmt, param + pcnt, unicodestr);
+	smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
     } else {
 	switch (level) {
 	case 1:
@@ -132,19 +131,18 @@
 	    fmt = "UnknownLevel\n";
 	    break;
 	}
-	smb_fdata(data, fmt, data + dcnt, unicodestr);
+	smb_fdata(ndo, data, fmt, data + dcnt, unicodestr);
     }
     if (dcnt) {
-	printf("data:\n");
-	print_data(data, dcnt);
+	ND_PRINT((ndo, "data:\n"));
+	print_data(ndo, data, dcnt);
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
-struct smbfnsint trans2_fns[] = {
+static const struct smbfnsint 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,
@@ -170,18 +168,19 @@
 
 
 static void
-print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
+print_trans2(netdissect_options *ndo,
+             const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
 {
     u_int bcc;
-    static struct smbfnsint *fn = &trans2_fns[0];
+    static const struct smbfnsint *fn = &trans2_fns[0];
     const u_char *data, *param;
     const u_char *w = words + 1;
     const char *f1 = NULL, *f2 = NULL;
     int pcnt, dcnt;
 
-    TCHECK(words[0]);
+    ND_TCHECK(words[0]);
     if (request) {
-	TCHECK2(w[14 * 2], 2);
+	ND_TCHECK2(w[14 * 2], 2);
 	pcnt = EXTRACT_LE_16BITS(w + 9 * 2);
 	param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
 	dcnt = EXTRACT_LE_16BITS(w + 11 * 2);
@@ -189,151 +188,151 @@
 	fn = smbfindint(EXTRACT_LE_16BITS(w + 14 * 2), trans2_fns);
     } else {
 	if (words[0] == 0) {
-	    printf("%s\n", fn->name);
-	    printf("Trans2Interim\n");
+	    ND_PRINT((ndo, "%s\n", fn->name));
+	    ND_PRINT((ndo, "Trans2Interim\n"));
 	    return;
 	}
-	TCHECK2(w[7 * 2], 2);
+	ND_TCHECK2(w[7 * 2], 2);
 	pcnt = EXTRACT_LE_16BITS(w + 3 * 2);
 	param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
 	dcnt = EXTRACT_LE_16BITS(w + 6 * 2);
 	data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
     }
 
-    printf("%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt);
+    ND_PRINT((ndo, "%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt));
 
     if (request) {
 	if (words[0] == 8) {
-	    smb_fdata(words + 1,
+	    smb_fdata(ndo, words + 1,
 		"Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",
 		maxbuf, unicodestr);
 	    return;
 	} else {
-	    smb_fdata(words + 1,
+	    smb_fdata(ndo, words + 1,
 		"TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[b][P1]\n",
 		words + 1 + 14 * 2, unicodestr);
 	}
 	f1 = fn->descript.req_f1;
 	f2 = fn->descript.req_f2;
     } else {
-	smb_fdata(words + 1,
+	smb_fdata(ndo, words + 1,
 	    "TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[b][P1]\n",
 	    words + 1 + 10 * 2, unicodestr);
 	f1 = fn->descript.rep_f1;
 	f2 = fn->descript.rep_f2;
     }
 
-    TCHECK2(*dat, 2);
+    ND_TCHECK2(*dat, 2);
     bcc = EXTRACT_LE_16BITS(dat);
-    printf("smb_bcc=%u\n", bcc);
+    ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
     if (fn->descript.fn)
-	(*fn->descript.fn)(param, data, pcnt, dcnt);
+	(*fn->descript.fn)(ndo, param, data, pcnt, dcnt);
     else {
-	smb_fdata(param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
-	smb_fdata(data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
+	smb_fdata(ndo, param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
+	smb_fdata(ndo, data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
-
 static void
-print_browse(const u_char *param, int paramlen, const u_char *data, int datalen)
+print_browse(netdissect_options *ndo,
+             const u_char *param, int paramlen, const u_char *data, int datalen)
 {
     const u_char *maxbuf = data + datalen;
     int command;
 
-    TCHECK(data[0]);
+    ND_TCHECK(data[0]);
     command = data[0];
 
-    smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
+    smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
 
     switch (command) {
     case 0xF:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, 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, unicodestr);
 	break;
 
     case 0x1:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, 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, unicodestr);
 	break;
 
     case 0x2:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, data,
 	    "BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
 	    maxbuf, unicodestr);
 	break;
 
     case 0xc:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, 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, unicodestr);
 	break;
 
     case 0x8:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, data,
 	    "BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
 	    maxbuf, unicodestr);
 	break;
 
     case 0xb:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, data,
 	    "BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
 	    maxbuf, unicodestr);
 	break;
 
     case 0x9:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, data,
 	    "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n",
 	    maxbuf, unicodestr);
 	break;
 
     case 0xa:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, data,
 	    "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n",
 	    maxbuf, unicodestr);
 	break;
 
     case 0xd:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, data,
 	    "BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
 	    maxbuf, unicodestr);
 	break;
 
     case 0xe:
-	data = smb_fdata(data,
+	data = smb_fdata(ndo, data,
 	    "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf, unicodestr);
 	break;
 
     default:
-	data = smb_fdata(data, "Unknown Browser Frame ", maxbuf, unicodestr);
+	data = smb_fdata(ndo, data, "Unknown Browser Frame ", maxbuf, unicodestr);
 	break;
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 
 static void
-print_ipc(const u_char *param, int paramlen, const u_char *data, int datalen)
+print_ipc(netdissect_options *ndo,
+          const u_char *param, int paramlen, const u_char *data, int datalen)
 {
     if (paramlen)
-	smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen,
+	smb_fdata(ndo, param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen,
 	    unicodestr);
     if (datalen)
-	smb_fdata(data, "IPC ", data + datalen, unicodestr);
+	smb_fdata(ndo, data, "IPC ", data + datalen, unicodestr);
 }
 
 
 static void
-print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
+print_trans(netdissect_options *ndo,
+            const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
 {
     u_int bcc;
     const char *f1, *f2, *f3, *f4;
@@ -342,7 +341,7 @@
     int datalen, paramlen;
 
     if (request) {
-	TCHECK2(w[12 * 2], 2);
+	ND_TCHECK2(w[12 * 2], 2);
 	paramlen = EXTRACT_LE_16BITS(w + 9 * 2);
 	param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
 	datalen = EXTRACT_LE_16BITS(w + 11 * 2);
@@ -352,7 +351,7 @@
 	f3 = "|Param ";
 	f4 = "|Data ";
     } else {
-	TCHECK2(w[7 * 2], 2);
+	ND_TCHECK2(w[7 * 2], 2);
 	paramlen = EXTRACT_LE_16BITS(w + 3 * 2);
 	param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
 	datalen = EXTRACT_LE_16BITS(w + 6 * 2);
@@ -363,44 +362,44 @@
 	f4 = "|Data ";
     }
 
-    smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf),
+    smb_fdata(ndo, words + 1, f1, min(words + 1 + 2 * words[0], maxbuf),
         unicodestr);
 
-    TCHECK2(*data1, 2);
+    ND_TCHECK2(*data1, 2);
     bcc = EXTRACT_LE_16BITS(data1);
-    printf("smb_bcc=%u\n", bcc);
+    ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
     if (bcc > 0) {
-	smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
+	smb_fdata(ndo, data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
 
 	if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) {
-	    print_browse(param, paramlen, data, datalen);
+	    print_browse(ndo, param, paramlen, data, datalen);
 	    return;
 	}
 
 	if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) {
-	    print_ipc(param, paramlen, data, datalen);
+	    print_ipc(ndo, param, paramlen, data, datalen);
 	    return;
 	}
 
 	if (paramlen)
-	    smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf), unicodestr);
+	    smb_fdata(ndo, param, f3, min(param + paramlen, maxbuf), unicodestr);
 	if (datalen)
-	    smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf), unicodestr);
+	    smb_fdata(ndo, data, f4, min(data + datalen, maxbuf), unicodestr);
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 
 static void
-print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_negprot(netdissect_options *ndo,
+              const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
 {
     u_int wct, bcc;
     const char *f1 = NULL, *f2 = NULL;
 
-    TCHECK(words[0]);
+    ND_TCHECK(words[0]);
     wct = words[0];
     if (request)
 	f2 = "*|Dialect=[Y]\n";
@@ -414,34 +413,34 @@
     }
 
     if (f1)
-	smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf),
+	smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
 	    unicodestr);
     else
-	print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+	print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
 
-    TCHECK2(*data, 2);
+    ND_TCHECK2(*data, 2);
     bcc = EXTRACT_LE_16BITS(data);
-    printf("smb_bcc=%u\n", bcc);
+    ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
     if (bcc > 0) {
 	if (f2)
-	    smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+	    smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
 		maxbuf), unicodestr);
 	else
-	    print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+	    print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_sesssetup(netdissect_options *ndo,
+                const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
 {
     u_int wct, bcc;
     const char *f1 = NULL, *f2 = NULL;
 
-    TCHECK(words[0]);
+    ND_TCHECK(words[0]);
     wct = words[0];
     if (request) {
 	if (wct == 10)
@@ -458,39 +457,39 @@
     }
 
     if (f1)
-	smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf),
+	smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
 	    unicodestr);
     else
-	print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+	print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
 
-    TCHECK2(*data, 2);
+    ND_TCHECK2(*data, 2);
     bcc = EXTRACT_LE_16BITS(data);
-    printf("smb_bcc=%u\n", bcc);
+    ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
     if (bcc > 0) {
 	if (f2)
-	    smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+	    smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
 		maxbuf), unicodestr);
 	else
-	    print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+	    print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
-print_lockingandx(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_lockingandx(netdissect_options *ndo,
+                  const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
 {
     u_int wct, bcc;
     const u_char *maxwords;
     const char *f1 = NULL, *f2 = NULL;
 
-    TCHECK(words[0]);
+    ND_TCHECK(words[0]);
     wct = words[0];
     if (request) {
 	f1 = "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n";
-	TCHECK(words[7]);
+	ND_TCHECK(words[7]);
 	if (words[7] & 0x10)
 	    f2 = "*Process=[d]\n[P2]Offset=[M]\nLength=[M]\n";
 	else
@@ -499,28 +498,27 @@
 	f1 = "Com2=[w]\nOff2=[d]\n";
     }
 
-    maxwords = SMBMIN(words + 1 + wct * 2, maxbuf);
+    maxwords = min(words + 1 + wct * 2, maxbuf);
     if (wct)
-	smb_fdata(words + 1, f1, maxwords, unicodestr);
+	smb_fdata(ndo, words + 1, f1, maxwords, unicodestr);
 
-    TCHECK2(*data, 2);
+    ND_TCHECK2(*data, 2);
     bcc = EXTRACT_LE_16BITS(data);
-    printf("smb_bcc=%u\n", bcc);
+    ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
     if (bcc > 0) {
 	if (f2)
-	    smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+	    smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
 		maxbuf), unicodestr);
 	else
-	    print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+	    print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 
-static struct smbfns smb_fns[] = {
+static const struct smbfns smb_fns[] = {
     { -1, "SMBunknown", 0, DEFDESCRIPT },
 
     { SMBtcon, "SMBtcon", 0,
@@ -792,19 +790,20 @@
  * print a SMB message
  */
 static void
-print_smb(const u_char *buf, const u_char *maxbuf)
+print_smb(netdissect_options *ndo,
+          const u_char *buf, const u_char *maxbuf)
 {
-    u_int16_t flags2;
+    uint16_t flags2;
     int nterrcodes;
     int command;
-    u_int32_t nterror;
+    uint32_t nterror;
     const u_char *words, *maxwords, *data;
-    struct smbfns *fn;
+    const struct smbfns *fn;
     const 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";
     int smboffset;
 
-    TCHECK(buf[9]);
+    ND_TCHECK(buf[9]);
     request = (buf[9] & 0x80) ? 0 : 1;
     flags2 = EXTRACT_LE_16BITS(&buf[10]);
     unicodestr = flags2 & 0x8000;
@@ -815,24 +814,24 @@
 
     fn = smbfind(command, smb_fns);
 
-    if (vflag > 1)
-	printf("\n");
+    if (ndo->ndo_vflag > 1)
+	ND_PRINT((ndo, "\n"));
 
-    printf("SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY");
+    ND_PRINT((ndo, "SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY"));
 
-    if (vflag < 2)
+    if (ndo->ndo_vflag < 2)
 	return;
 
     /* print out the header */
-    smb_fdata(buf, fmt_smbheader, buf + 33, unicodestr);
+    smb_fdata(ndo, buf, fmt_smbheader, buf + 33, unicodestr);
 
     if (nterrcodes) {
     	nterror = EXTRACT_LE_32BITS(&buf[5]);
 	if (nterror)
-	    printf("NTError = %s\n", nt_errstr(nterror));
+	    ND_PRINT((ndo, "NTError = %s\n", nt_errstr(nterror)));
     } else {
 	if (buf[5])
-	    printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7])));
+	    ND_PRINT((ndo, "SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7]))));
     }
 
     smboffset = 32;
@@ -844,10 +843,10 @@
 	int newsmboffset;
 
 	words = buf + smboffset;
-	TCHECK(words[0]);
+	ND_TCHECK(words[0]);
 	wct = words[0];
 	data = words + 1 + wct * 2;
-	maxwords = SMBMIN(data, maxbuf);
+	maxwords = min(data, maxbuf);
 
 	if (request) {
 	    f1 = fn->descript.req_f1;
@@ -858,33 +857,33 @@
 	}
 
 	if (fn->descript.fn)
-	    (*fn->descript.fn)(words, data, buf, maxbuf);
+	    (*fn->descript.fn)(ndo, words, data, buf, maxbuf);
 	else {
 	    if (wct) {
 		if (f1)
-		    smb_fdata(words + 1, f1, words + 1 + wct * 2, unicodestr);
+		    smb_fdata(ndo, words + 1, f1, words + 1 + wct * 2, unicodestr);
 		else {
 		    int i;
 		    int v;
 
 		    for (i = 0; &words[1 + 2 * i] < maxwords; i++) {
-			TCHECK2(words[1 + 2 * i], 2);
+			ND_TCHECK2(words[1 + 2 * i], 2);
 			v = EXTRACT_LE_16BITS(words + 1 + 2 * i);
-			printf("smb_vwv[%d]=%d (0x%X)\n", i, v, v);
+			ND_PRINT((ndo, "smb_vwv[%d]=%d (0x%X)\n", i, v, v));
 		    }
 		}
 	    }
 
-	    TCHECK2(*data, 2);
+	    ND_TCHECK2(*data, 2);
 	    bcc = EXTRACT_LE_16BITS(data);
-	    printf("smb_bcc=%u\n", bcc);
+	    ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
 	    if (f2) {
 		if (bcc > 0)
-		    smb_fdata(data + 2, f2, data + 2 + bcc, unicodestr);
+		    smb_fdata(ndo, data + 2, f2, data + 2 + bcc, unicodestr);
 	    } else {
 		if (bcc > 0) {
-		    printf("smb_buf[]=\n");
-		    print_data(data + 2, SMBMIN(bcc, PTR_DIFF(maxbuf, data + 2)));
+		    ND_PRINT((ndo, "smb_buf[]=\n"));
+		    print_data(ndo, data + 2, min(bcc, PTR_DIFF(maxbuf, data + 2)));
 		}
 	    }
 	}
@@ -893,29 +892,28 @@
 	    break;
 	if (wct == 0)
 	    break;
-	TCHECK(words[1]);
+	ND_TCHECK(words[1]);
 	command = words[1];
 	if (command == 0xFF)
 	    break;
-	TCHECK2(words[3], 2);
-	newsmboffset = EXTRACT_LE_16BITS(words + 3); 
+	ND_TCHECK2(words[3], 2);
+	newsmboffset = EXTRACT_LE_16BITS(words + 3);
 
 	fn = smbfind(command, smb_fns);
 
-	printf("\nSMB PACKET: %s (%s) (CHAINED)\n",
-	    fn->name, request ? "REQUEST" : "REPLY");
+	ND_PRINT((ndo, "\nSMB PACKET: %s (%s) (CHAINED)\n",
+	    fn->name, request ? "REQUEST" : "REPLY"));
 	if (newsmboffset <= smboffset) {
-	    printf("Bad andX offset: %u <= %u\n", newsmboffset, smboffset);
+	    ND_PRINT((ndo, "Bad andX offset: %u <= %u\n", newsmboffset, smboffset));
 	    break;
 	}
 	smboffset = newsmboffset;
     }
 
-    printf("\n");
+    ND_PRINT((ndo, "\n"));
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 
@@ -923,7 +921,8 @@
  * print a NBT packet received across tcp on port 139
  */
 void
-nbt_tcp_print(const u_char *data, int length)
+nbt_tcp_print(netdissect_options *ndo,
+              const u_char *data, int length)
 {
     int caplen;
     int type;
@@ -932,9 +931,9 @@
 
     if (length < 4)
 	goto trunc;
-    if (snapend < data)
+    if (ndo->ndo_snapend < data)
 	goto trunc;
-    caplen = snapend - data;
+    caplen = ndo->ndo_snapend - data;
     if (caplen < 4)
 	goto trunc;
     maxbuf = data + caplen;
@@ -945,19 +944,19 @@
 
     startbuf = data;
 
-    if (vflag < 2) {
-	printf(" NBT Session Packet: ");
+    if (ndo->ndo_vflag < 2) {
+	ND_PRINT((ndo, " NBT Session Packet: "));
 	switch (type) {
 	case 0x00:
-	    printf("Session Message");
+	    ND_PRINT((ndo, "Session Message"));
 	    break;
 
 	case 0x81:
-	    printf("Session Request");
+	    ND_PRINT((ndo, "Session Request"));
 	    break;
 
 	case 0x82:
-	    printf("Session Granted");
+	    ND_PRINT((ndo, "Session Granted"));
 	    break;
 
 	case 0x83:
@@ -972,64 +971,64 @@
 		goto trunc;
 	    ecode = data[4];
 
-	    printf("Session Reject, ");
+	    ND_PRINT((ndo, "Session Reject, "));
 	    switch (ecode) {
 	    case 0x80:
-		printf("Not listening on called name");
+		ND_PRINT((ndo, "Not listening on called name"));
 		break;
 	    case 0x81:
-		printf("Not listening for calling name");
+		ND_PRINT((ndo, "Not listening for calling name"));
 		break;
 	    case 0x82:
-		printf("Called name not present");
+		ND_PRINT((ndo, "Called name not present"));
 		break;
 	    case 0x83:
-		printf("Called name present, but insufficient resources");
+		ND_PRINT((ndo, "Called name present, but insufficient resources"));
 		break;
 	    default:
-		printf("Unspecified error 0x%X", ecode);
+		ND_PRINT((ndo, "Unspecified error 0x%X", ecode));
 		break;
 	    }
 	  }
 	    break;
 
 	case 0x85:
-	    printf("Session Keepalive");
+	    ND_PRINT((ndo, "Session Keepalive"));
 	    break;
 
 	default:
-	    data = smb_fdata(data, "Unknown packet type [rB]", maxbuf, 0);
+	    data = smb_fdata(ndo, data, "Unknown packet type [rB]", maxbuf, 0);
 	    break;
 	}
     } else {
-	printf ("\n>>> NBT Session Packet\n");
+	ND_PRINT((ndo, "\n>>> NBT Session Packet\n"));
 	switch (type) {
 	case 0x00:
-	    data = smb_fdata(data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n",
+	    data = smb_fdata(ndo, data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n",
 		data + 4, 0);
 	    if (data == NULL)
 		break;
 	    if (nbt_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
 		if ((int)nbt_len > caplen) {
 		    if ((int)nbt_len > length)
-			printf("WARNING: Packet is continued in later TCP segments\n");
+			ND_PRINT((ndo, "WARNING: Packet is continued in later TCP segments\n"));
 		    else
-			printf("WARNING: Short packet. Try increasing the snap length by %d\n",
-			    nbt_len - caplen);
+			ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length by %d\n",
+			    nbt_len - caplen));
 		}
-		print_smb(data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
+		print_smb(ndo, data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
 	    } else
-		printf("Session packet:(raw data or continuation?)\n");
+		ND_PRINT((ndo, "Session packet:(raw data or continuation?)\n"));
 	    break;
 
 	case 0x81:
-	    data = smb_fdata(data,
+	    data = smb_fdata(ndo, data,
 		"[P1]NBT Session Request\nFlags=[B]\nLength=[rd]\nDestination=[n1]\nSource=[n1]\n",
 		maxbuf, 0);
 	    break;
 
 	case 0x82:
-	    data = smb_fdata(data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
+	    data = smb_fdata(ndo, data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
 	    break;
 
 	case 0x83:
@@ -1038,7 +1037,7 @@
 	    int ecode;
 
 	    origdata = data;
-	    data = smb_fdata(data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n",
+	    data = smb_fdata(ndo, data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n",
 		maxbuf, 0);
 	    if (data == NULL)
 		break;
@@ -1046,19 +1045,19 @@
 		ecode = origdata[4];
 		switch (ecode) {
 		case 0x80:
-		    printf("Not listening on called name\n");
+		    ND_PRINT((ndo, "Not listening on called name\n"));
 		    break;
 		case 0x81:
-		    printf("Not listening for calling name\n");
+		    ND_PRINT((ndo, "Not listening for calling name\n"));
 		    break;
 		case 0x82:
-		    printf("Called name not present\n");
+		    ND_PRINT((ndo, "Called name not present\n"));
 		    break;
 		case 0x83:
-		    printf("Called name present, but insufficient resources\n");
+		    ND_PRINT((ndo, "Called name present, but insufficient resources\n"));
 		    break;
 		default:
-		    printf("Unspecified error 0x%X\n", ecode);
+		    ND_PRINT((ndo, "Unspecified error 0x%X\n", ecode));
 		    break;
 		}
 	    }
@@ -1066,37 +1065,45 @@
 	    break;
 
 	case 0x85:
-	    data = smb_fdata(data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
+	    data = smb_fdata(ndo, data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
 	    break;
 
 	default:
-	    data = smb_fdata(data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0);
+	    data = smb_fdata(ndo, data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0);
 	    break;
 	}
-	printf("\n");
-	fflush(stdout);
+	ND_PRINT((ndo, "\n"));
     }
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
+static const struct tok opcode_str[] = {
+	{ 0,  "QUERY"                   },
+	{ 5,  "REGISTRATION"            },
+	{ 6,  "RELEASE"                 },
+	{ 7,  "WACK"                    },
+	{ 8,  "REFRESH(8)"              },
+	{ 9,  "REFRESH"                 },
+	{ 15, "MULTIHOMED REGISTRATION" },
+	{ 0, NULL }
+};
 
 /*
  * print a NBT packet received across udp on port 137
  */
 void
-nbt_udp137_print(const u_char *data, int length)
+nbt_udp137_print(netdissect_options *ndo,
+                 const u_char *data, int length)
 {
     const u_char *maxbuf = data + length;
     int name_trn_id, response, opcode, nm_flags, rcode;
     int qdcount, ancount, nscount, arcount;
-    const char *opcodestr;
     const u_char *p;
     int total, i;
 
-    TCHECK2(data[10], 2);
+    ND_TCHECK2(data[10], 2);
     name_trn_id = EXTRACT_16BITS(data);
     response = (data[2] >> 7);
     opcode = (data[2] >> 3) & 0xF;
@@ -1111,59 +1118,36 @@
     if (maxbuf <= data)
 	return;
 
-    if (vflag > 1)
-	printf("\n>>> ");
+    if (ndo->ndo_vflag > 1)
+	ND_PRINT((ndo, "\n>>> "));
 
-    printf("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;
-    case 15: opcodestr = "MULTIHOMED REGISTRATION"; break;
-    default: opcodestr = "OPUNKNOWN"; break;
-    }
-    printf("%s", opcodestr);
+    ND_PRINT((ndo, "NBT UDP PACKET(137): %s", tok2str(opcode_str, "OPUNKNOWN", opcode)));
     if (response) {
-	if (rcode)
-	    printf("; NEGATIVE");
-	else
-	    printf("; POSITIVE");
+        ND_PRINT((ndo, "; %s", rcode ? "NEGATIVE" : "POSITIVE"));
     }
+    ND_PRINT((ndo, "; %s; %s", response ? "RESPONSE" : "REQUEST",
+              (nm_flags & 1) ? "BROADCAST" : "UNICAST"));
 
-    if (response)
-	printf("; RESPONSE");
-    else
-	printf("; REQUEST");
-
-    if (nm_flags & 1)
-	printf("; BROADCAST");
-    else
-	printf("; UNICAST");
-
-    if (vflag < 2)
+    if (ndo->ndo_vflag < 2)
 	return;
 
-    printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
+    ND_PRINT((ndo, "\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
 	name_trn_id, opcode, nm_flags, rcode, qdcount, ancount, nscount,
-	arcount);
+	arcount));
 
     p = data + 12;
 
     total = ancount + nscount + arcount;
 
     if (qdcount > 100 || total > 100) {
-	printf("Corrupt packet??\n");
+	ND_PRINT((ndo, "Corrupt packet??\n"));
 	return;
     }
 
     if (qdcount) {
-	printf("QuestionRecords:\n");
+	ND_PRINT((ndo, "QuestionRecords:\n"));
 	for (i = 0; i < qdcount; i++) {
-	    p = smb_fdata(p,
+	    p = smb_fdata(ndo, p,
 		"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
 		maxbuf, 0);
 	    if (p == NULL)
@@ -1172,60 +1156,60 @@
     }
 
     if (total) {
-	printf("\nResourceRecords:\n");
+	ND_PRINT((ndo, "\nResourceRecords:\n"));
 	for (i = 0; i < total; i++) {
 	    int rdlen;
 	    int restype;
 
-	    p = smb_fdata(p, "Name=[n1]\n#", maxbuf, 0);
+	    p = smb_fdata(ndo, p, "Name=[n1]\n#", maxbuf, 0);
 	    if (p == NULL)
 		goto out;
 	    restype = EXTRACT_16BITS(p);
-	    p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0);
+	    p = smb_fdata(ndo, p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0);
 	    if (p == NULL)
 		goto out;
 	    rdlen = EXTRACT_16BITS(p);
-	    printf("ResourceLength=%d\nResourceData=\n", rdlen);
+	    ND_PRINT((ndo, "ResourceLength=%d\nResourceData=\n", rdlen));
 	    p += 2;
 	    if (rdlen == 6) {
-		p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0);
+		p = smb_fdata(ndo, p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0);
 		if (p == NULL)
 		    goto out;
 	    } else {
 		if (restype == 0x21) {
 		    int numnames;
 
-		    TCHECK(*p);
+		    ND_TCHECK(*p);
 		    numnames = p[0];
-		    p = smb_fdata(p, "NumNames=[B]\n", p + 1, 0);
+		    p = smb_fdata(ndo, p, "NumNames=[B]\n", p + 1, 0);
 		    if (p == NULL)
 			goto out;
 		    while (numnames--) {
-			p = smb_fdata(p, "Name=[n2]\t#", maxbuf, 0);
+			p = smb_fdata(ndo, p, "Name=[n2]\t#", maxbuf, 0);
 			if (p == NULL)
 			    goto out;
-			TCHECK(*p);
+			ND_TCHECK(*p);
 			if (p[0] & 0x80)
-			    printf("<GROUP> ");
+			    ND_PRINT((ndo, "<GROUP> "));
 			switch (p[0] & 0x60) {
-			case 0x00: printf("B "); break;
-			case 0x20: printf("P "); break;
-			case 0x40: printf("M "); break;
-			case 0x60: printf("_ "); break;
+			case 0x00: ND_PRINT((ndo, "B ")); break;
+			case 0x20: ND_PRINT((ndo, "P ")); break;
+			case 0x40: ND_PRINT((ndo, "M ")); break;
+			case 0x60: ND_PRINT((ndo, "_ ")); break;
 			}
 			if (p[0] & 0x10)
-			    printf("<DEREGISTERING> ");
+			    ND_PRINT((ndo, "<DEREGISTERING> "));
 			if (p[0] & 0x08)
-			    printf("<CONFLICT> ");
+			    ND_PRINT((ndo, "<CONFLICT> "));
 			if (p[0] & 0x04)
-			    printf("<ACTIVE> ");
+			    ND_PRINT((ndo, "<ACTIVE> "));
 			if (p[0] & 0x02)
-			    printf("<PERMANENT> ");
-			printf("\n");
+			    ND_PRINT((ndo, "<PERMANENT> "));
+			ND_PRINT((ndo, "\n"));
 			p += 2;
 		    }
 		} else {
-		    print_data(p, min(rdlen, length - (p - data)));
+		    print_data(ndo, p, min(rdlen, length - (p - data)));
 		    p += rdlen;
 		}
 	    }
@@ -1233,22 +1217,21 @@
     }
 
     if (p < maxbuf)
-	smb_fdata(p, "AdditionalData:\n", maxbuf, 0);
+	smb_fdata(ndo, p, "AdditionalData:\n", maxbuf, 0);
 
 out:
-    printf("\n");
-    fflush(stdout);
+    ND_PRINT((ndo, "\n"));
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
  * Print an SMB-over-TCP packet received across tcp on port 445
  */
 void
-smb_tcp_print (const u_char * data, int length)
+smb_tcp_print(netdissect_options *ndo,
+              const u_char * data, int length)
 {
     int caplen;
     u_int smb_len;
@@ -1256,9 +1239,9 @@
 
     if (length < 4)
 	goto trunc;
-    if (snapend < data)
+    if (ndo->ndo_snapend < data)
 	goto trunc;
-    caplen = snapend - data;
+    caplen = ndo->ndo_snapend - data;
     if (caplen < 4)
 	goto trunc;
     maxbuf = data + caplen;
@@ -1272,40 +1255,41 @@
     if (smb_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
 	if ((int)smb_len > caplen) {
 	    if ((int)smb_len > length)
-		printf("WARNING: Packet is continued in later TCP segments\n");
+		ND_PRINT((ndo, " WARNING: Packet is continued in later TCP segments\n"));
 	    else
-		printf("WARNING: Short packet. Try increasing the snap length by %d\n",
-		    smb_len - caplen);
-	}
-	print_smb(data, maxbuf > data + smb_len ? data + smb_len : maxbuf);
+		ND_PRINT((ndo, " WARNING: Short packet. Try increasing the snap length by %d\n",
+		    smb_len - caplen));
+	} else
+	    ND_PRINT((ndo, " "));
+	print_smb(ndo, data, maxbuf > data + smb_len ? data + smb_len : maxbuf);
     } else
-	printf("SMB-over-TCP packet:(raw data or continuation?)\n");
+	ND_PRINT((ndo, " SMB-over-TCP packet:(raw data or continuation?)\n"));
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
  * print a NBT packet received across udp on port 138
  */
 void
-nbt_udp138_print(const u_char *data, int length)
+nbt_udp138_print(netdissect_options *ndo,
+                 const u_char *data, int length)
 {
     const u_char *maxbuf = data + length;
 
-    if (maxbuf > snapend)
-	maxbuf = snapend;
+    if (maxbuf > ndo->ndo_snapend)
+	maxbuf = ndo->ndo_snapend;
     if (maxbuf <= data)
 	return;
     startbuf = data;
 
-    if (vflag < 2) {
-	printf("NBT UDP PACKET(138)");
+    if (ndo->ndo_vflag < 2) {
+	ND_PRINT((ndo, "NBT UDP PACKET(138)"));
 	return;
     }
 
-    data = smb_fdata(data,
+    data = smb_fdata(ndo, 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, 0);
 
@@ -1315,11 +1299,10 @@
 	    goto out;
 
 	if (memcmp(data, "\377SMB",4) == 0)
-	    print_smb(data, maxbuf);
+	    print_smb(ndo, data, maxbuf);
     }
 out:
-    printf("\n");
-    fflush(stdout);
+    ND_PRINT((ndo, "\n"));
 }
 
 
@@ -1382,7 +1365,8 @@
 };
 
 void
-netbeui_print(u_short control, const u_char *data, int length)
+netbeui_print(netdissect_options *ndo,
+              u_short control, const u_char *data, int length)
 {
     const u_char *maxbuf = data + length;
     int len;
@@ -1390,9 +1374,9 @@
     const u_char *data2;
     int is_truncated = 0;
 
-    if (maxbuf > snapend)
-	maxbuf = snapend;
-    TCHECK(data[4]);
+    if (maxbuf > ndo->ndo_snapend)
+	maxbuf = ndo->ndo_snapend;
+    ND_TCHECK(data[4]);
     len = EXTRACT_LE_16BITS(data);
     command = data[4];
     data2 = data + len;
@@ -1403,36 +1387,36 @@
 
     startbuf = data;
 
-    if (vflag < 2) {
-	printf("NBF Packet: ");
-	data = smb_fdata(data, "[P5]#", maxbuf, 0);
+    if (ndo->ndo_vflag < 2) {
+	ND_PRINT((ndo, "NBF Packet: "));
+	data = smb_fdata(ndo, data, "[P5]#", maxbuf, 0);
     } else {
-	printf("\n>>> NBF Packet\nType=0x%X ", control);
-	data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0);
+	ND_PRINT((ndo, "\n>>> NBF Packet\nType=0x%X ", control));
+	data = smb_fdata(ndo, data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0);
     }
     if (data == NULL)
 	goto out;
 
     if (command > 0x1f || nbf_strings[command].name == NULL) {
-	if (vflag < 2)
-	    data = smb_fdata(data, "Unknown NBF Command#", data2, 0);
+	if (ndo->ndo_vflag < 2)
+	    data = smb_fdata(ndo, data, "Unknown NBF Command#", data2, 0);
 	else
-	    data = smb_fdata(data, "Unknown NBF Command\n", data2, 0);
+	    data = smb_fdata(ndo, data, "Unknown NBF Command\n", data2, 0);
     } else {
-	if (vflag < 2) {
-	    printf("%s", nbf_strings[command].name);
+	if (ndo->ndo_vflag < 2) {
+	    ND_PRINT((ndo, "%s", nbf_strings[command].name));
 	    if (nbf_strings[command].nonverbose != NULL)
-		data = smb_fdata(data, nbf_strings[command].nonverbose, data2, 0);
+		data = smb_fdata(ndo, data, nbf_strings[command].nonverbose, data2, 0);
 	} else {
-	    printf("%s:\n", nbf_strings[command].name);
+	    ND_PRINT((ndo, "%s:\n", nbf_strings[command].name));
 	    if (nbf_strings[command].verbose != NULL)
-		data = smb_fdata(data, nbf_strings[command].verbose, data2, 0);
+		data = smb_fdata(ndo, data, nbf_strings[command].verbose, data2, 0);
 	    else
-		printf("\n");
+		ND_PRINT((ndo, "\n"));
 	}
     }
 
-    if (vflag < 2)
+    if (ndo->ndo_vflag < 2)
 	return;
 
     if (data == NULL)
@@ -1453,26 +1437,25 @@
 	goto out;
 
     if (memcmp(data2, "\377SMB",4) == 0)
-	print_smb(data2, maxbuf);
+	print_smb(ndo, data2, maxbuf);
     else {
 	int i;
 	for (i = 0; i < 128; i++) {
 	    if (&data2[i + 3] >= maxbuf)
 		break;
 	    if (memcmp(&data2[i], "\377SMB", 4) == 0) {
-		printf("found SMB packet at %d\n", i);
-		print_smb(&data2[i], maxbuf);
+		ND_PRINT((ndo, "found SMB packet at %d\n", i));
+		print_smb(ndo, &data2[i], maxbuf);
 		break;
 	    }
 	}
     }
 
 out:
-    printf("\n");
+    ND_PRINT((ndo, "\n"));
     return;
 trunc:
-    printf("[|SMB]");
-    return;
+    ND_PRINT((ndo, "%s", tstr));
 }
 
 
@@ -1480,7 +1463,8 @@
  * print IPX-Netbios frames
  */
 void
-ipx_netbios_print(const u_char *data, u_int length)
+ipx_netbios_print(netdissect_options *ndo,
+                  const u_char *data, u_int length)
 {
     /*
      * this is a hack till I work out how to parse the rest of the
@@ -1491,20 +1475,19 @@
 
     maxbuf = data + length;
     /* Don't go past the end of the captured data in the packet. */
-    if (maxbuf > snapend)
-	maxbuf = snapend;
+    if (maxbuf > ndo->ndo_snapend)
+	maxbuf = ndo->ndo_snapend;
     startbuf = data;
     for (i = 0; i < 128; i++) {
 	if (&data[i + 4] > maxbuf)
 	    break;
 	if (memcmp(&data[i], "\377SMB", 4) == 0) {
-	    smb_fdata(data, "\n>>> IPX transport ", &data[i], 0);
-	    print_smb(&data[i], maxbuf);
-	    printf("\n");
-	    fflush(stdout);
+	    smb_fdata(ndo, data, "\n>>> IPX transport ", &data[i], 0);
+	    print_smb(ndo, &data[i], maxbuf);
+	    ND_PRINT((ndo, "\n"));
 	    break;
 	}
     }
     if (i == 128)
-	smb_fdata(data, "\n>>> Unknown IPX ", maxbuf, 0);
+	smb_fdata(ndo, data, "\n>>> Unknown IPX ", maxbuf, 0);
 }
diff --git a/bgp.h b/print-smtp.c
similarity index 67%
rename from bgp.h
rename to print-smtp.c
index 5081596..fe0bbc2 100644
--- a/bgp.h
+++ b/print-smtp.c
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bgp.h,v 1.3 2004-06-16 08:45:15 hannes Exp $ (LBL) */
-/* 
+/*
  * 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
@@ -10,8 +9,22 @@
  * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
- *
- * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-extern char *bgp_vpn_rd_print (const u_char *);
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+void
+smtp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+	txtproto_print(ndo, pptr, len, "smtp", NULL, 0);
+}
diff --git a/print-snmp.c b/print-snmp.c
index 27ab0c4..f550158 100644
--- a/print-snmp.c
+++ b/print-snmp.c
@@ -56,11 +56,7 @@
  #	@(#)snmp.awk.x	1.1 (LANL) 1/15/90
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.64 2005-05-06 07:56:53 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -70,20 +66,21 @@
 #include <stdio.h>
 #include <string.h>
 
-#ifdef HAVE_SMI_H
+#ifdef USE_LIBSMI
 #include <smi.h>
 #endif
 
 #include "interface.h"
-#include "addrtoname.h"
 
 #undef OPAQUE  /* defined in <wingdi.h> */
 
+static const char tstr[] = "[|snmp]";
+
 /*
  * Universal ASN.1 types
  * (we only care about the tag values for those allowed in the Internet SMI)
  */
-const char *Universal[] = {
+static const char *Universal[] = {
 	"U-0",
 	"Boolean",
 	"Integer",
@@ -106,7 +103,7 @@
 /*
  * Application-wide ASN.1 types from the Internet SMI and their tags
  */
-const char *Application[] = {
+static const char *Application[] = {
 	"IpAddress",
 #define IPADDR 0
 	"Counter",
@@ -125,7 +122,7 @@
 /*
  * Context-specific ASN.1 types for the SNMP PDUs and their tags
  */
-const char *Context[] = {
+static const char *Context[] = {
 	"GetRequest",
 #define GETREQ 0
 	"GetNextRequest",
@@ -155,7 +152,7 @@
 /*
  * Context-specific ASN.1 types for the SNMP Exceptions and their tags
  */
-const char *Exceptions[] = {
+static const char *Exceptions[] = {
 	"noSuchObject",
 #define NOSUCHOBJECT 0
 	"noSuchInstance",
@@ -168,14 +165,14 @@
  * Private ASN.1 types
  * The Internet SMI does not specify any
  */
-const char *Private[] = {
+static const char *Private[] = {
 	"P-0"
 };
 
 /*
  * error-status values for any SNMP PDU
  */
-const char *ErrorStatus[] = {
+static const char *ErrorStatus[] = {
 	"noError",
 	"tooBig",
 	"noSuchName",
@@ -204,7 +201,7 @@
 /*
  * generic-trap values in the SNMP Trap-PDU
  */
-const char *GenericTrap[] = {
+static const char *GenericTrap[] = {
 	"coldStart",
 	"warmStart",
 	"linkDown",
@@ -225,7 +222,7 @@
  * type definitions.
  */
 #define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */
-struct {
+static const struct {
 	const char	*name;
 	const char	**Id;
 	    int	numIDs;
@@ -245,7 +242,7 @@
 /*
  * defined forms for ASN.1 types
  */
-const char *Form[] = {
+static const char *Form[] = {
 	"Primitive",
 #define PRIMITIVE	0
 	"Constructed",
@@ -278,7 +275,7 @@
  * Currently, this includes the prefixes for the Internet MIB, the
  * private enterprises tree, and the experimental tree.
  */
-struct obj_abrev {
+static const struct obj_abrev {
 	const char *prefix;		/* prefix for this abrev */
 	struct obj *node;		/* pointer into object table */
 	const char *oid;		/* ASN.1 encoded OID */
@@ -315,10 +312,10 @@
 		} while ((objp = objp->next) != NULL); \
 	} \
 	if (objp) { \
-		printf(suppressdot?"%s":".%s", objp->desc); \
+		ND_PRINT((ndo, suppressdot?"%s":".%s", objp->desc)); \
 		objp = objp->child; \
 	} else \
-		printf(suppressdot?"%u":".%u", (o)); \
+		ND_PRINT((ndo, suppressdot?"%u":".%u", (o))); \
 }
 
 /*
@@ -326,15 +323,15 @@
  * temporary internal representation while decoding an ASN.1 data stream.
  */
 struct be {
-	u_int32_t asnlen;
+	uint32_t asnlen;
 	union {
 		caddr_t raw;
 		int32_t integer;
-		u_int32_t uns;
+		uint32_t uns;
 		const u_char *str;
 	        struct {
-		        u_int32_t high;
-		        u_int32_t low;
+		        uint32_t high;
+		        uint32_t low;
 		} uns64;
 	} data;
 	u_short id;
@@ -360,7 +357,7 @@
 /*
  * SNMP versions recognized by this module
  */
-const char *SnmpVersion[] = {
+static const char *SnmpVersion[] = {
 	"SNMPv1",
 #define SNMP_VERSION_1	0
 	"SNMPv2c",
@@ -403,7 +400,8 @@
  * O/w, this returns the number of bytes parsed from "p".
  */
 static int
-asn1_parse(register const u_char *p, u_int len, struct be *elem)
+asn1_parse(netdissect_options *ndo,
+           register const u_char *p, u_int len, struct be *elem)
 {
 	u_char form, class, id;
 	int i, hdr;
@@ -411,10 +409,10 @@
 	elem->asnlen = 0;
 	elem->type = BE_ANY;
 	if (len < 1) {
-		fputs("[nothing to parse]", stdout);
+		ND_PRINT((ndo, "[nothing to parse]"));
 		return -1;
 	}
-	TCHECK(*p);
+	ND_TCHECK(*p);
 
 	/*
 	 * it would be nice to use a bit field, but you can't depend on them.
@@ -450,54 +448,54 @@
 		 */
 		for (id = 0; *p & ASN_BIT8; len--, hdr++, p++) {
 			if (len < 1) {
-				fputs("[Xtagfield?]", stdout);
+				ND_PRINT((ndo, "[Xtagfield?]"));
 				return -1;
 			}
-			TCHECK(*p);
+			ND_TCHECK(*p);
 			id = (id << 7) | (*p & ~ASN_BIT8);
 		}
 		if (len < 1) {
-			fputs("[Xtagfield?]", stdout);
+			ND_PRINT((ndo, "[Xtagfield?]"));
 			return -1;
 		}
-		TCHECK(*p);
+		ND_TCHECK(*p);
 		elem->id = id = (id << 7) | *p;
 		--len;
 		++hdr;
 		++p;
 	}
 	if (len < 1) {
-		fputs("[no asnlen]", stdout);
+		ND_PRINT((ndo, "[no asnlen]"));
 		return -1;
 	}
-	TCHECK(*p);
+	ND_TCHECK(*p);
 	elem->asnlen = *p;
 	p++; len--; hdr++;
 	if (elem->asnlen & ASN_BIT8) {
-		u_int32_t noct = elem->asnlen % ASN_BIT8;
+		uint32_t noct = elem->asnlen % ASN_BIT8;
 		elem->asnlen = 0;
 		if (len < noct) {
-			printf("[asnlen? %d<%d]", len, noct);
+			ND_PRINT((ndo, "[asnlen? %d<%d]", len, noct));
 			return -1;
 		}
-		TCHECK2(*p, noct);
+		ND_TCHECK2(*p, noct);
 		for (; noct-- > 0; len--, hdr++)
 			elem->asnlen = (elem->asnlen << ASN_SHIFT8) | *p++;
 	}
 	if (len < elem->asnlen) {
-		printf("[len%d<asnlen%u]", len, elem->asnlen);
+		ND_PRINT((ndo, "[len%d<asnlen%u]", len, elem->asnlen));
 		return -1;
 	}
 	if (form >= sizeof(Form)/sizeof(Form[0])) {
-		printf("[form?%d]", form);
+		ND_PRINT((ndo, "[form?%d]", form));
 		return -1;
 	}
 	if (class >= sizeof(Class)/sizeof(Class[0])) {
-		printf("[class?%c/%d]", *Form[form], class);
+		ND_PRINT((ndo, "[class?%c/%d]", *Form[form], class));
 		return -1;
 	}
 	if ((int)id >= Class[class].numIDs) {
-		printf("[id?%c/%s/%d]", *Form[form], Class[class].name, id);
+		ND_PRINT((ndo, "[id?%c/%s/%d]", *Form[form], Class[class].name, id));
 		return -1;
 	}
 
@@ -516,7 +514,7 @@
 				elem->type = BE_INT;
 				data = 0;
 
-				TCHECK2(*p, elem->asnlen);
+				ND_TCHECK2(*p, elem->asnlen);
 				if (*p & ASN_BIT8)	/* negative */
 					data = -1;
 				for (i = elem->asnlen; i-- > 0; p++)
@@ -538,8 +536,7 @@
 			default:
 				elem->type = BE_OCTET;
 				elem->data.raw = (caddr_t)p;
-				printf("[P/U/%s]",
-					Class[class].Id[id]);
+				ND_PRINT((ndo, "[P/U/%s]", Class[class].Id[id]));
 				break;
 			}
 			break;
@@ -554,8 +551,8 @@
 			case COUNTER:
 			case GAUGE:
 			case TIMETICKS: {
-				register u_int32_t data;
-				TCHECK2(*p, elem->asnlen);
+				register uint32_t data;
+				ND_TCHECK2(*p, elem->asnlen);
 				elem->type = BE_UNS;
 				data = 0;
 				for (i = elem->asnlen; i-- > 0; p++)
@@ -565,8 +562,8 @@
 			}
 
 			case COUNTER64: {
-				register u_int32_t high, low;
-				TCHECK2(*p, elem->asnlen);
+				register uint32_t high, low;
+				ND_TCHECK2(*p, elem->asnlen);
 			        elem->type = BE_UNS64;
 				high = 0, low = 0;
 				for (i = elem->asnlen; i-- > 0; p++) {
@@ -582,8 +579,8 @@
 			default:
 				elem->type = BE_OCTET;
 				elem->data.raw = (caddr_t)p;
-				printf("[P/A/%s]",
-					Class[class].Id[id]);
+				ND_PRINT((ndo, "[P/A/%s]",
+					Class[class].Id[id]));
 				break;
 			}
 			break;
@@ -608,9 +605,8 @@
 			break;
 
 		default:
-			printf("[P/%s/%s]",
-				Class[class].name, Class[class].Id[id]);
-			TCHECK2(*p, elem->asnlen);
+			ND_PRINT((ndo, "[P/%s/%s]", Class[class].name, Class[class].Id[id]));
+			ND_TCHECK2(*p, elem->asnlen);
 			elem->type = BE_OCTET;
 			elem->data.raw = (caddr_t)p;
 			break;
@@ -629,7 +625,7 @@
 			default:
 				elem->type = BE_OCTET;
 				elem->data.raw = (caddr_t)p;
-				printf("C/U/%s", Class[class].Id[id]);
+				ND_PRINT((ndo, "C/U/%s", Class[class].Id[id]));
 				break;
 			}
 			break;
@@ -642,8 +638,7 @@
 		default:
 			elem->type = BE_OCTET;
 			elem->data.raw = (caddr_t)p;
-			printf("C/%s/%s",
-				Class[class].name, Class[class].Id[id]);
+			ND_PRINT((ndo, "C/%s/%s", Class[class].name, Class[class].Id[id]));
 			break;
 		}
 		break;
@@ -653,7 +648,7 @@
 	return elem->asnlen + hdr;
 
 trunc:
-	fputs("[|snmp]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
@@ -663,18 +658,19 @@
  * BE form was added.
  */
 static int
-asn1_print(struct be *elem)
+asn1_print(netdissect_options *ndo,
+           struct be *elem)
 {
 	u_char *p = (u_char *)elem->data.raw;
-	u_int32_t asnlen = elem->asnlen;
-	u_int32_t i;
+	uint32_t asnlen = elem->asnlen;
+	uint32_t i;
 
 	switch (elem->type) {
 
 	case BE_OCTET:
-		TCHECK2(*p, asnlen);
+		ND_TCHECK2(*p, asnlen);
 		for (i = asnlen; i-- > 0; p++)
-			printf("_%.2x", *p);
+			ND_PRINT((ndo, "_%.2x", *p));
 		break;
 
 	case BE_NULL:
@@ -683,24 +679,24 @@
 	case BE_OID: {
 		int o = 0, first = -1, i = asnlen;
 
-		if (!sflag && !nflag && asnlen > 2) {
-			struct obj_abrev *a = &obj_abrev_list[0];
+		if (!ndo->ndo_sflag && !ndo->ndo_nflag && asnlen > 2) {
+			const struct obj_abrev *a = &obj_abrev_list[0];
 			size_t a_len = strlen(a->oid);
 			for (; a->node; a++) {
-				TCHECK2(*p, a_len);
+				ND_TCHECK2(*p, a_len);
 				if (memcmp(a->oid, (char *)p, a_len) == 0) {
 					objp = a->node->child;
 					i -= strlen(a->oid);
 					p += strlen(a->oid);
-					fputs(a->prefix, stdout);
+					ND_PRINT((ndo, "%s", a->prefix));
 					first = 1;
 					break;
 				}
 			}
 		}
 
-		for (; !sflag && i-- > 0; p++) {
-			TCHECK(*p);
+		for (; !ndo->ndo_sflag && i-- > 0; p++) {
+			ND_TCHECK(*p);
 			o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
 			if (*p & ASN_LONGLEN)
 			        continue;
@@ -711,7 +707,7 @@
 			 */
 			if (first < 0) {
 			        int s;
-				if (!nflag)
+				if (!ndo->ndo_nflag)
 					objp = mibroot;
 				first = 0;
 				s = o / OIDMUX;
@@ -728,11 +724,11 @@
 	}
 
 	case BE_INT:
-		printf("%d", elem->data.integer);
+		ND_PRINT((ndo, "%d", elem->data.integer));
 		break;
 
 	case BE_UNS:
-		printf("%u", elem->data.uns);
+		ND_PRINT((ndo, "%u", elem->data.uns));
 		break;
 
 	case BE_UNS64: {	/* idea borrowed from by Marshall Rose */
@@ -740,16 +736,16 @@
 		int j, carry;
 		char *cpf, *cpl, last[6], first[30];
 		if (elem->data.uns64.high == 0) {
-		        printf("%u", elem->data.uns64.low);
-		        break;
+			ND_PRINT((ndo, "%u", elem->data.uns64.low));
+			break;
 		}
 		d = elem->data.uns64.high * 4294967296.0;	/* 2^32 */
 		if (elem->data.uns64.high <= 0x1fffff) {
 		        d += elem->data.uns64.low;
 #if 0 /*is looks illegal, but what is the intention?*/
-			printf("%.f", d);
+			ND_PRINT((ndo, "%.f", d));
 #else
-			printf("%f", d);
+			ND_PRINT((ndo, "%f", d));
 #endif
 			break;
 		}
@@ -773,68 +769,67 @@
 		        }
 			*cpf = j + '0';
 		}
-		fputs(first, stdout);
+		ND_PRINT((ndo, "%s", first));
 		break;
 	}
 
 	case BE_STR: {
 		register int printable = 1, first = 1;
 		const u_char *p = elem->data.str;
-		TCHECK2(*p, asnlen);
+		ND_TCHECK2(*p, asnlen);
 		for (i = asnlen; printable && i-- > 0; p++)
 			printable = ND_ISPRINT(*p);
 		p = elem->data.str;
 		if (printable) {
-			putchar('"');
-			if (fn_printn(p, asnlen, snapend)) {
-				putchar('"');
+			ND_PRINT((ndo, "\""));
+			if (fn_printn(ndo, p, asnlen, ndo->ndo_snapend)) {
+				ND_PRINT((ndo, "\""));
 				goto trunc;
 			}
-			putchar('"');
+			ND_PRINT((ndo, "\""));
 		} else
 			for (i = asnlen; i-- > 0; p++) {
-				printf(first ? "%.2x" : "_%.2x", *p);
+				ND_PRINT((ndo, first ? "%.2x" : "_%.2x", *p));
 				first = 0;
 			}
 		break;
 	}
 
 	case BE_SEQ:
-		printf("Seq(%u)", elem->asnlen);
+		ND_PRINT((ndo, "Seq(%u)", elem->asnlen));
 		break;
 
 	case BE_INETADDR:
 		if (asnlen != ASNLEN_INETADDR)
-			printf("[inetaddr len!=%d]", ASNLEN_INETADDR);
-		TCHECK2(*p, asnlen);
+			ND_PRINT((ndo, "[inetaddr len!=%d]", ASNLEN_INETADDR));
+		ND_TCHECK2(*p, asnlen);
 		for (i = asnlen; i-- != 0; p++) {
-			printf((i == asnlen-1) ? "%u" : ".%u", *p);
+			ND_PRINT((ndo, (i == asnlen-1) ? "%u" : ".%u", *p));
 		}
 		break;
 
 	case BE_NOSUCHOBJECT:
 	case BE_NOSUCHINST:
 	case BE_ENDOFMIBVIEW:
-	        printf("[%s]", Class[EXCEPTIONS].Id[elem->id]);
+		ND_PRINT((ndo, "[%s]", Class[EXCEPTIONS].Id[elem->id]));
 		break;
 
 	case BE_PDU:
-		printf("%s(%u)",
-			Class[CONTEXT].Id[elem->id], elem->asnlen);
+		ND_PRINT((ndo, "%s(%u)", Class[CONTEXT].Id[elem->id], elem->asnlen));
 		break;
 
 	case BE_ANY:
-		fputs("[BE_ANY!?]", stdout);
+		ND_PRINT((ndo, "[BE_ANY!?]"));
 		break;
 
 	default:
-		fputs("[be!?]", stdout);
+		ND_PRINT((ndo, "[be!?]"));
 		break;
 	}
 	return 0;
 
 trunc:
-	fputs("[|snmp]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
@@ -855,15 +850,15 @@
 	int i = 0;
 
 	while (i >= 0 && length > 0) {
-		i = asn1_parse(p, length, &elem);
+		i = asn1_parse(ndo, p, length, &elem);
 		if (i >= 0) {
-			fputs(" ", stdout);
-			if (asn1_print(&elem) < 0)
+			ND_PRINT((ndo, " "));
+			if (asn1_print(ndo, &elem) < 0)
 				return;
 			if (elem.type == BE_SEQ || elem.type == BE_PDU) {
-				fputs(" {", stdout);
+				ND_PRINT((ndo, " {"));
 				asn1_decode(elem.data.raw, elem.asnlen);
-				fputs(" }", stdout);
+				ND_PRINT((ndo, " }"));
 			}
 			length -= i;
 			p += i;
@@ -872,14 +867,14 @@
 }
 #endif
 
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
 
 struct smi2be {
     SmiBasetype basetype;
     int be;
 };
 
-static struct smi2be smi2betab[] = {
+static const struct smi2be smi2betab[] = {
     { SMI_BASETYPE_INTEGER32,		BE_INT },
     { SMI_BASETYPE_OCTETSTRING,		BE_STR },
     { SMI_BASETYPE_OCTETSTRING,		BE_INETADDR },
@@ -896,15 +891,17 @@
 };
 
 static int
-smi_decode_oid(struct be *elem, unsigned int *oid,
-	       unsigned int oidsize, unsigned int *oidlen)
+smi_decode_oid(netdissect_options *ndo,
+               struct be *elem, unsigned int *oid,
+               unsigned int oidsize, unsigned int *oidlen)
 {
 	u_char *p = (u_char *)elem->data.raw;
-	u_int32_t asnlen = elem->asnlen;
+	uint32_t asnlen = elem->asnlen;
 	int o = 0, first = -1, i = asnlen;
+	unsigned int firstval;
 
-	for (*oidlen = 0; sflag && i-- > 0; p++) {
-		TCHECK(*p);
+	for (*oidlen = 0; ndo->ndo_sflag && i-- > 0; p++) {
+		ND_TCHECK(*p);
 	        o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
 		if (*p & ASN_LONGLEN)
 		    continue;
@@ -915,12 +912,12 @@
 		 */
 		if (first < 0) {
 		        first = 0;
+			firstval = o / OIDMUX;
+			if (firstval > 2) firstval = 2;
+			o -= firstval * OIDMUX;
 			if (*oidlen < oidsize) {
-			    oid[*oidlen] = o / OIDMUX;
-			    if (oid[*oidlen] > 2) oid[*oidlen] = 2;
+			    oid[(*oidlen)++] = firstval;
 			}
-			o -= oid[*oidlen] * OIDMUX;
-			if (*oidlen < oidsize) (*oidlen)++;
 		}
 		if (*oidlen < oidsize) {
 			oid[(*oidlen)++] = o;
@@ -930,7 +927,7 @@
 	return 0;
 
 trunc:
-	fputs("[|snmp]", stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return -1;
 }
 
@@ -1024,29 +1021,30 @@
 	return ok;
 }
 
-static SmiNode *smi_print_variable(struct be *elem, int *status)
+static SmiNode *
+smi_print_variable(netdissect_options *ndo,
+                   struct be *elem, int *status)
 {
 	unsigned int oid[128], oidlen;
 	SmiNode *smiNode = NULL;
 	unsigned int i;
 
-	*status = smi_decode_oid(elem, oid, sizeof(oid)/sizeof(unsigned int),
+	*status = smi_decode_oid(ndo, elem, oid, sizeof(oid) / sizeof(unsigned int),
 	    &oidlen);
 	if (*status < 0)
 		return NULL;
 	smiNode = smiGetNodeByOID(oidlen, oid);
 	if (! smiNode) {
-		*status = asn1_print(elem);
+		*status = asn1_print(ndo, elem);
 		return NULL;
 	}
-	if (vflag) {
-		fputs(smiGetNodeModule(smiNode)->name, stdout);
-		fputs("::", stdout);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "%s::", smiGetNodeModule(smiNode)->name));
 	}
-	fputs(smiNode->name, stdout);
+	ND_PRINT((ndo, "%s", smiNode->name));
 	if (smiNode->oidlen < oidlen) {
-	        for (i = smiNode->oidlen; i < oidlen; i++) {
-		        printf(".%u", oid[i]);
+		for (i = smiNode->oidlen; i < oidlen; i++) {
+			ND_PRINT((ndo, ".%u", oid[i]));
 		}
 	}
 	*status = 0;
@@ -1054,7 +1052,8 @@
 }
 
 static int
-smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
+smi_print_value(netdissect_options *ndo,
+                SmiNode *smiNode, u_char pduid, struct be *elem)
 {
 	unsigned int i, oid[128], oidlen;
 	SmiType *smiType;
@@ -1063,43 +1062,43 @@
 
 	if (! smiNode || ! (smiNode->nodekind
 			    & (SMI_NODEKIND_SCALAR | SMI_NODEKIND_COLUMN))) {
-	    return asn1_print(elem);
+	    return asn1_print(ndo, elem);
 	}
 
 	if (elem->type == BE_NOSUCHOBJECT
 	    || elem->type == BE_NOSUCHINST
 	    || elem->type == BE_ENDOFMIBVIEW) {
-	    return asn1_print(elem);
+	    return asn1_print(ndo, elem);
 	}
 
 	if (NOTIFY_CLASS(pduid) && smiNode->access < SMI_ACCESS_NOTIFY) {
-	    fputs("[notNotifyable]", stdout);
+	    ND_PRINT((ndo, "[notNotifyable]"));
 	}
 
 	if (READ_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_ONLY) {
-	    fputs("[notReadable]", stdout);
+	    ND_PRINT((ndo, "[notReadable]"));
 	}
 
 	if (WRITE_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_WRITE) {
-	    fputs("[notWritable]", stdout);
+	    ND_PRINT((ndo, "[notWritable]"));
 	}
 
 	if (RESPONSE_CLASS(pduid)
 	    && smiNode->access == SMI_ACCESS_NOT_ACCESSIBLE) {
-	    fputs("[noAccess]", stdout);
+	    ND_PRINT((ndo, "[noAccess]"));
 	}
 
 	smiType = smiGetNodeType(smiNode);
 	if (! smiType) {
-	    return asn1_print(elem);
+	    return asn1_print(ndo, elem);
 	}
 
 	if (! smi_check_type(smiType->basetype, elem->type)) {
-	    fputs("[wrongType]", stdout);
+	    ND_PRINT((ndo, "[wrongType]"));
 	}
 
 	if (! smi_check_range(smiType, elem)) {
-	    fputs("[outOfRange]", stdout);
+	    ND_PRINT((ndo, "[outOfRange]"));
 	}
 
 	/* resolve bits to named bits */
@@ -1115,20 +1114,19 @@
 	        if (smiType->basetype == SMI_BASETYPE_BITS) {
 		        /* print bit labels */
 		} else {
-		        smi_decode_oid(elem, oid,
+		        smi_decode_oid(ndo, elem, oid,
 				       sizeof(oid)/sizeof(unsigned int),
 				       &oidlen);
 			smiNode = smiGetNodeByOID(oidlen, oid);
 			if (smiNode) {
-			        if (vflag) {
-					fputs(smiGetNodeModule(smiNode)->name, stdout);
-					fputs("::", stdout);
+			        if (ndo->ndo_vflag) {
+					ND_PRINT((ndo, "%s::", smiGetNodeModule(smiNode)->name));
 				}
-				fputs(smiNode->name, stdout);
+				ND_PRINT((ndo, "%s", smiNode->name));
 				if (smiNode->oidlen < oidlen) {
 				        for (i = smiNode->oidlen;
 					     i < oidlen; i++) {
-					        printf(".%u", oid[i]);
+					        ND_PRINT((ndo, ".%u", oid[i]));
 					}
 				}
 				done++;
@@ -1143,8 +1141,8 @@
 			     nn = smiGetNextNamedNumber(nn)) {
 			         if (nn->value.value.integer32
 				     == elem->data.integer) {
-				         fputs(nn->name, stdout);
-					 printf("(%d)", elem->data.integer);
+				         ND_PRINT((ndo, "%s", nn->name));
+					 ND_PRINT((ndo, "(%d)", elem->data.integer));
 					 done++;
 					 break;
 				}
@@ -1154,7 +1152,7 @@
 	}
 
 	if (! done) {
-		return asn1_print(elem);
+		return asn1_print(ndo, elem);
 	}
 	return 0;
 }
@@ -1197,25 +1195,26 @@
  * Decode SNMP varBind
  */
 static void
-varbind_print(u_char pduid, const u_char *np, u_int length)
+varbind_print(netdissect_options *ndo,
+              u_char pduid, const u_char *np, u_int length)
 {
 	struct be elem;
 	int count = 0, ind;
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
 	SmiNode *smiNode = NULL;
 #endif
 	int status;
 
 	/* Sequence of varBind */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_SEQ) {
-		fputs("[!SEQ of varbind]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[!SEQ of varbind]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	if ((u_int)count < length)
-		printf("[%d extra after SEQ of varbind]", length - count);
+		ND_PRINT((ndo, "[%d extra after SEQ of varbind]", length - count));
 	/* descend */
 	length = elem.asnlen;
 	np = (u_char *)elem.data.raw;
@@ -1224,14 +1223,14 @@
 		const u_char *vbend;
 		u_int vblength;
 
-		fputs(" ", stdout);
+		ND_PRINT((ndo, " "));
 
 		/* Sequence */
-		if ((count = asn1_parse(np, length, &elem)) < 0)
+		if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 			return;
 		if (elem.type != BE_SEQ) {
-			fputs("[!varbind]", stdout);
-			asn1_print(&elem);
+			ND_PRINT((ndo, "[!varbind]"));
+			asn1_print(ndo, &elem);
 			return;
 		}
 		vbend = np + count;
@@ -1241,17 +1240,17 @@
 		np = (u_char *)elem.data.raw;
 
 		/* objName (OID) */
-		if ((count = asn1_parse(np, length, &elem)) < 0)
+		if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 			return;
 		if (elem.type != BE_OID) {
-			fputs("[objName!=OID]", stdout);
-			asn1_print(&elem);
+			ND_PRINT((ndo, "[objName!=OID]"));
+			asn1_print(ndo, &elem);
 			return;
 		}
-#ifdef LIBSMI
-		smiNode = smi_print_variable(&elem, &status);
+#ifdef USE_LIBSMI
+		smiNode = smi_print_variable(ndo, &elem, &status);
 #else
-		status = asn1_print(&elem);
+		status = asn1_print(ndo, &elem);
 #endif
 		if (status < 0)
 			return;
@@ -1260,24 +1259,24 @@
 
 		if (pduid != GETREQ && pduid != GETNEXTREQ
 		    && pduid != GETBULKREQ)
-			fputs("=", stdout);
+			ND_PRINT((ndo, "="));
 
 		/* objVal (ANY) */
-		if ((count = asn1_parse(np, length, &elem)) < 0)
+		if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 			return;
 		if (pduid == GETREQ || pduid == GETNEXTREQ
 		    || pduid == GETBULKREQ) {
 			if (elem.type != BE_NULL) {
-				fputs("[objVal!=NULL]", stdout);
-				if (asn1_print(&elem) < 0)
+				ND_PRINT((ndo, "[objVal!=NULL]"));
+				if (asn1_print(ndo, &elem) < 0)
 					return;
 			}
 		} else {
 		        if (elem.type != BE_NULL) {
-#ifdef LIBSMI
-				status = smi_print_value(smiNode, pduid, &elem);
+#ifdef USE_LIBSMI
+				status = smi_print_value(ndo, smiNode, pduid, &elem);
 #else
-				status = asn1_print(&elem);
+				status = asn1_print(ndo, &elem);
 #endif
 			}
 			if (status < 0)
@@ -1293,30 +1292,31 @@
  * GetBulk, Inform, V2Trap, and Report
  */
 static void
-snmppdu_print(u_short pduid, const u_char *np, u_int length)
+snmppdu_print(netdissect_options *ndo,
+              u_short pduid, const u_char *np, u_int length)
 {
 	struct be elem;
 	int count = 0, error;
 
 	/* reqId (Integer) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[reqId!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[reqId!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
-	if (vflag)
-		printf("R=%d ", elem.data.integer);
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, "R=%d ", elem.data.integer));
 	length -= count;
 	np += count;
 
 	/* errorStatus (Integer) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[errorStatus!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[errorStatus!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	error = 0;
@@ -1324,48 +1324,47 @@
 	    || pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT)
 	    && elem.data.integer != 0) {
 		char errbuf[20];
-		printf("[errorStatus(%s)!=0]",
-			DECODE_ErrorStatus(elem.data.integer));
+		ND_PRINT((ndo, "[errorStatus(%s)!=0]",
+			DECODE_ErrorStatus(elem.data.integer)));
 	} else if (pduid == GETBULKREQ) {
-	        printf(" N=%d", elem.data.integer);
+		ND_PRINT((ndo, " N=%d", elem.data.integer));
 	} else if (elem.data.integer != 0) {
 		char errbuf[20];
-		printf(" %s", DECODE_ErrorStatus(elem.data.integer));
+		ND_PRINT((ndo, " %s", DECODE_ErrorStatus(elem.data.integer)));
 		error = elem.data.integer;
 	}
 	length -= count;
 	np += count;
 
 	/* errorIndex (Integer) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[errorIndex!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[errorIndex!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	if ((pduid == GETREQ || pduid == GETNEXTREQ || pduid == SETREQ
 	    || pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT)
 	    && elem.data.integer != 0)
-		printf("[errorIndex(%d)!=0]", elem.data.integer);
+		ND_PRINT((ndo, "[errorIndex(%d)!=0]", elem.data.integer));
 	else if (pduid == GETBULKREQ)
-	        printf(" M=%d", elem.data.integer);
+		ND_PRINT((ndo, " M=%d", elem.data.integer));
 	else if (elem.data.integer != 0) {
 		if (!error)
-			printf("[errorIndex(%d) w/o errorStatus]",
-				elem.data.integer);
+			ND_PRINT((ndo, "[errorIndex(%d) w/o errorStatus]", elem.data.integer));
 		else {
-			printf("@%d", elem.data.integer);
+			ND_PRINT((ndo, "@%d", elem.data.integer));
 			error = elem.data.integer;
 		}
 	} else if (error) {
-		fputs("[errorIndex==0]", stdout);
+		ND_PRINT((ndo, "[errorIndex==0]"));
 		error = 0;
 	}
 	length -= count;
 	np += count;
 
-	varbind_print(pduid, np, length);
+	varbind_print(ndo, pduid, np, length);
 	return;
 }
 
@@ -1373,89 +1372,90 @@
  * Decode SNMP Trap PDU
  */
 static void
-trappdu_print(const u_char *np, u_int length)
+trappdu_print(netdissect_options *ndo,
+              const u_char *np, u_int length)
 {
 	struct be elem;
 	int count = 0, generic;
 
-	putchar(' ');
+	ND_PRINT((ndo, " "));
 
 	/* enterprise (oid) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_OID) {
-		fputs("[enterprise!=OID]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[enterprise!=OID]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
-	if (asn1_print(&elem) < 0)
+	if (asn1_print(ndo, &elem) < 0)
 		return;
 	length -= count;
 	np += count;
 
-	putchar(' ');
+	ND_PRINT((ndo, " "));
 
 	/* agent-addr (inetaddr) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INETADDR) {
-		fputs("[agent-addr!=INETADDR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[agent-addr!=INETADDR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
-	if (asn1_print(&elem) < 0)
+	if (asn1_print(ndo, &elem) < 0)
 		return;
 	length -= count;
 	np += count;
 
 	/* generic-trap (Integer) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[generic-trap!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[generic-trap!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	generic = elem.data.integer;
 	{
 		char buf[20];
-		printf(" %s", DECODE_GenericTrap(generic));
+		ND_PRINT((ndo, " %s", DECODE_GenericTrap(generic)));
 	}
 	length -= count;
 	np += count;
 
 	/* specific-trap (Integer) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[specific-trap!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[specific-trap!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	if (generic != GT_ENTERPRISE) {
 		if (elem.data.integer != 0)
-			printf("[specific-trap(%d)!=0]", elem.data.integer);
+			ND_PRINT((ndo, "[specific-trap(%d)!=0]", elem.data.integer));
 	} else
-		printf(" s=%d", elem.data.integer);
+		ND_PRINT((ndo, " s=%d", elem.data.integer));
 	length -= count;
 	np += count;
 
-	putchar(' ');
+	ND_PRINT((ndo, " "));
 
 	/* time-stamp (TimeTicks) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_UNS) {			/* XXX */
-		fputs("[time-stamp!=TIMETICKS]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[time-stamp!=TIMETICKS]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
-	if (asn1_print(&elem) < 0)
+	if (asn1_print(ndo, &elem) < 0)
 		return;
 	length -= count;
 	np += count;
 
-	varbind_print (TRAP, np, length);
+	varbind_print(ndo, TRAP, np, length);
 	return;
 }
 
@@ -1463,26 +1463,27 @@
  * Decode arbitrary SNMP PDUs.
  */
 static void
-pdu_print(const u_char *np, u_int length, int version)
+pdu_print(netdissect_options *ndo,
+          const u_char *np, u_int length, int version)
 {
 	struct be pdu;
 	int count = 0;
 
 	/* PDU (Context) */
-	if ((count = asn1_parse(np, length, &pdu)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &pdu)) < 0)
 		return;
 	if (pdu.type != BE_PDU) {
-		fputs("[no PDU]", stdout);
+		ND_PRINT((ndo, "[no PDU]"));
 		return;
 	}
 	if ((u_int)count < length)
-		printf("[%d extra after PDU]", length - count);
-	if (vflag) {
-		fputs("{ ", stdout);
+		ND_PRINT((ndo, "[%d extra after PDU]", length - count));
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "{ "));
 	}
-	if (asn1_print(&pdu) < 0)
+	if (asn1_print(ndo, &pdu) < 0)
 		return;
-	fputs(" ", stdout);
+	ND_PRINT((ndo, " "));
 	/* descend into PDU */
 	length = pdu.asnlen;
 	np = (u_char *)pdu.data.raw;
@@ -1490,18 +1491,18 @@
 	if (version == SNMP_VERSION_1 &&
 	    (pdu.id == GETBULKREQ || pdu.id == INFORMREQ ||
 	     pdu.id == V2TRAP || pdu.id == REPORT)) {
-	        printf("[v2 PDU in v1 message]");
+	        ND_PRINT((ndo, "[v2 PDU in v1 message]"));
 		return;
 	}
 
 	if (version == SNMP_VERSION_2 && pdu.id == TRAP) {
-	        printf("[v1 PDU in v2 message]");
+		ND_PRINT((ndo, "[v1 PDU in v2 message]"));
 		return;
 	}
 
 	switch (pdu.id) {
 	case TRAP:
-		trappdu_print(np, length);
+		trappdu_print(ndo, np, length);
 		break;
 	case GETREQ:
 	case GETNEXTREQ:
@@ -1511,12 +1512,12 @@
 	case INFORMREQ:
 	case V2TRAP:
 	case REPORT:
-		snmppdu_print(pdu.id, np, length);
+		snmppdu_print(ndo, pdu.id, np, length);
 		break;
 	}
 
-	if (vflag) {
-		fputs(" } ", stdout);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, " } "));
 	}
 }
 
@@ -1524,70 +1525,72 @@
  * Decode a scoped SNMP PDU.
  */
 static void
-scopedpdu_print(const u_char *np, u_int length, int version)
+scopedpdu_print(netdissect_options *ndo,
+                const u_char *np, u_int length, int version)
 {
 	struct be elem;
 	int i, count = 0;
 
 	/* Sequence */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_SEQ) {
-		fputs("[!scoped PDU]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[!scoped PDU]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length = elem.asnlen;
 	np = (u_char *)elem.data.raw;
 
 	/* contextEngineID (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[contextEngineID!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[contextEngineID!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
 	np += count;
 
-	fputs("E= ", stdout);
+	ND_PRINT((ndo, "E= "));
 	for (i = 0; i < (int)elem.asnlen; i++) {
-            printf("0x%02X", elem.data.str[i]);
-        }
-	fputs(" ", stdout);
+		ND_PRINT((ndo, "0x%02X", elem.data.str[i]));
+	}
+	ND_PRINT((ndo, " "));
 
 	/* contextName (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[contextName!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[contextName!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
 	np += count;
 
-	printf("C=%.*s ", (int)elem.asnlen, elem.data.str);
+	ND_PRINT((ndo, "C=%.*s ", (int)elem.asnlen, elem.data.str));
 
-	pdu_print(np, length, version);
+	pdu_print(ndo, np, length, version);
 }
 
 /*
  * Decode SNMP Community Header (SNMPv1 and SNMPv2c)
  */
 static void
-community_print(const u_char *np, u_int length, int version)
+community_print(netdissect_options *ndo,
+                const u_char *np, u_int length, int version)
 {
 	struct be elem;
 	int count = 0;
 
 	/* Community (String) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[comm!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[comm!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	/* default community */
@@ -1595,114 +1598,116 @@
 	    strncmp((char *)elem.data.str, DEF_COMMUNITY,
 	            sizeof(DEF_COMMUNITY) - 1) == 0))
 		/* ! "public" */
-		printf("C=%.*s ", (int)elem.asnlen, elem.data.str);
+		ND_PRINT((ndo, "C=%.*s ", (int)elem.asnlen, elem.data.str));
 	length -= count;
 	np += count;
 
-	pdu_print(np, length, version);
+	pdu_print(ndo, np, length, version);
 }
 
 /*
  * Decode SNMPv3 User-based Security Message Header (SNMPv3)
  */
 static void
-usm_print(const u_char *np, u_int length)
+usm_print(netdissect_options *ndo,
+          const u_char *np, u_int length)
 {
         struct be elem;
 	int count = 0;
 
 	/* Sequence */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_SEQ) {
-		fputs("[!usm]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[!usm]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length = elem.asnlen;
 	np = (u_char *)elem.data.raw;
 
 	/* msgAuthoritativeEngineID (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[msgAuthoritativeEngineID!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgAuthoritativeEngineID!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
 	np += count;
 
 	/* msgAuthoritativeEngineBoots (INTEGER) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[msgAuthoritativeEngineBoots!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgAuthoritativeEngineBoots!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
-	if (vflag)
-	        printf("B=%d ", elem.data.integer);
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, "B=%d ", elem.data.integer));
 	length -= count;
 	np += count;
 
 	/* msgAuthoritativeEngineTime (INTEGER) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[msgAuthoritativeEngineTime!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgAuthoritativeEngineTime!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
-	if (vflag)
-	        printf("T=%d ", elem.data.integer);
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, "T=%d ", elem.data.integer));
 	length -= count;
 	np += count;
 
 	/* msgUserName (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[msgUserName!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgUserName!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
         np += count;
 
-	printf("U=%.*s ", (int)elem.asnlen, elem.data.str);
+	ND_PRINT((ndo, "U=%.*s ", (int)elem.asnlen, elem.data.str));
 
 	/* msgAuthenticationParameters (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[msgAuthenticationParameters!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgAuthenticationParameters!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
         np += count;
 
 	/* msgPrivacyParameters (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[msgPrivacyParameters!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgPrivacyParameters!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
         np += count;
 
 	if ((u_int)count < length)
-		printf("[%d extra after usm SEQ]", length - count);
+		ND_PRINT((ndo, "[%d extra after usm SEQ]", length - count));
 }
 
 /*
  * Decode SNMPv3 Message Header (SNMPv3)
  */
 static void
-v3msg_print(const u_char *np, u_int length)
+v3msg_print(netdissect_options *ndo,
+            const u_char *np, u_int length)
 {
 	struct be elem;
 	int count = 0;
@@ -1712,75 +1717,74 @@
 	int xlength = length;
 
 	/* Sequence */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_SEQ) {
-		fputs("[!message]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[!message]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length = elem.asnlen;
 	np = (u_char *)elem.data.raw;
 
-	if (vflag) {
-		fputs("{ ", stdout);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "{ "));
 	}
 
 	/* msgID (INTEGER) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[msgID!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgID!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
 	np += count;
 
 	/* msgMaxSize (INTEGER) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[msgMaxSize!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgMaxSize!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
 	np += count;
 
 	/* msgFlags (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[msgFlags!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgFlags!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	if (elem.asnlen != 1) {
-	        printf("[msgFlags size %d]", elem.asnlen);
+		ND_PRINT((ndo, "[msgFlags size %d]", elem.asnlen));
 		return;
 	}
 	flags = elem.data.str[0];
 	if (flags != 0x00 && flags != 0x01 && flags != 0x03
 	    && flags != 0x04 && flags != 0x05 && flags != 0x07) {
-		printf("[msgFlags=0x%02X]", flags);
+		ND_PRINT((ndo, "[msgFlags=0x%02X]", flags));
 		return;
 	}
 	length -= count;
 	np += count;
 
-	fputs("F=", stdout);
-	if (flags & 0x01) fputs("a", stdout);
-	if (flags & 0x02) fputs("p", stdout);
-	if (flags & 0x04) fputs("r", stdout);
-	fputs(" ", stdout);
+	ND_PRINT((ndo, "F=%s%s%s ",
+	          flags & 0x01 ? "a" : "",
+	          flags & 0x02 ? "p" : "",
+	          flags & 0x04 ? "r" : ""));
 
 	/* msgSecurityModel (INTEGER) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[msgSecurityModel!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgSecurityModel!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	model = elem.data.integer;
@@ -1788,18 +1792,18 @@
 	np += count;
 
 	if ((u_int)count < length)
-		printf("[%d extra after message SEQ]", length - count);
+		ND_PRINT((ndo, "[%d extra after message SEQ]", length - count));
 
-	if (vflag) {
-		fputs("} ", stdout);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "} "));
 	}
 
 	if (model == 3) {
-	    if (vflag) {
-		fputs("{ USM ", stdout);
+	    if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "{ USM "));
 	    }
 	} else {
-	    printf("[security model %d]", model);
+	    ND_PRINT((ndo, "[security model %d]", model));
             return;
 	}
 
@@ -1807,31 +1811,31 @@
 	length = xlength - (np - xnp);
 
 	/* msgSecurityParameters (OCTET STRING) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_STR) {
-		fputs("[msgSecurityParameters!=STR]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[msgSecurityParameters!=STR]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	length -= count;
 	np += count;
 
 	if (model == 3) {
-	    usm_print(elem.data.str, elem.asnlen);
-	    if (vflag) {
-		fputs("} ", stdout);
+	    usm_print(ndo, elem.data.str, elem.asnlen);
+	    if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "} "));
 	    }
 	}
 
-	if (vflag) {
-	    fputs("{ ScopedPDU ", stdout);
+	if (ndo->ndo_vflag) {
+	    ND_PRINT((ndo, "{ ScopedPDU "));
 	}
 
-	scopedpdu_print(np, length, 3);
+	scopedpdu_print(ndo, np, length, 3);
 
-	if (vflag) {
-		fputs("} ", stdout);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "} "));
 	}
 }
 
@@ -1839,34 +1843,35 @@
  * Decode SNMP header and pass on to PDU printing routines
  */
 void
-snmp_print(const u_char *np, u_int length)
+snmp_print(netdissect_options *ndo,
+           const u_char *np, u_int length)
 {
 	struct be elem;
 	int count = 0;
 	int version = 0;
 
-	putchar(' ');
+	ND_PRINT((ndo, " "));
 
 	/* initial Sequence */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_SEQ) {
-		fputs("[!init SEQ]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[!init SEQ]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 	if ((u_int)count < length)
-		printf("[%d extra after iSEQ]", length - count);
+		ND_PRINT((ndo, "[%d extra after iSEQ]", length - count));
 	/* descend */
 	length = elem.asnlen;
 	np = (u_char *)elem.data.raw;
 
 	/* Version (INTEGER) */
-	if ((count = asn1_parse(np, length, &elem)) < 0)
+	if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
 		return;
 	if (elem.type != BE_INT) {
-		fputs("[version!=INT]", stdout);
-		asn1_print(&elem);
+		ND_PRINT((ndo, "[version!=INT]"));
+		asn1_print(ndo, &elem);
 		return;
 	}
 
@@ -1874,11 +1879,11 @@
 	case SNMP_VERSION_1:
 	case SNMP_VERSION_2:
 	case SNMP_VERSION_3:
-	        if (vflag)
-		        printf("{ %s ", SnmpVersion[elem.data.integer]);
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, "{ %s ", SnmpVersion[elem.data.integer]));
 		break;
 	default:
-	        printf("[version = %d]", elem.data.integer);
+	        ND_PRINT((ndo, "[version = %d]", elem.data.integer));
 		return;
 	}
 	version = elem.data.integer;
@@ -1888,17 +1893,17 @@
 	switch (version) {
 	case SNMP_VERSION_1:
         case SNMP_VERSION_2:
-		community_print(np, length, version);
+		community_print(ndo, np, length, version);
 		break;
 	case SNMP_VERSION_3:
-		v3msg_print(np, length);
+		v3msg_print(ndo, np, length);
 		break;
 	default:
-	        printf("[version = %d]", elem.data.integer);
+		ND_PRINT((ndo, "[version = %d]", elem.data.integer));
 		break;
 	}
 
-	if (vflag) {
-		fputs("} ", stdout);
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, "} "));
 	}
 }
diff --git a/print-stp.c b/print-stp.c
index 5c9b12d..93bb600 100644
--- a/print-stp.c
+++ b/print-stp.c
@@ -9,44 +9,37 @@
  * Contributed by Lennert Buytenhek <buytenh@gnu.org>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.20 2007-03-18 17:11:46 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
 
-#define	RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2) 
+#define	RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2)
 /* STP timers are expressed in multiples of 1/256th second */
 #define STP_TIME_BASE 256
 #define STP_BPDU_MSTP_MIN_LEN 102
 
 struct stp_bpdu_ {
-    u_int8_t protocol_id[2];
-    u_int8_t protocol_version;
-    u_int8_t bpdu_type;
-    u_int8_t flags;
-    u_int8_t root_id[8];
-    u_int8_t root_path_cost[4];
-    u_int8_t bridge_id[8];
-    u_int8_t port_id[2];
-    u_int8_t message_age[2];
-    u_int8_t max_age[2];
-    u_int8_t hello_time[2];
-    u_int8_t forward_delay[2];
-    u_int8_t v1_length;
+    uint8_t protocol_id[2];
+    uint8_t protocol_version;
+    uint8_t bpdu_type;
+    uint8_t flags;
+    uint8_t root_id[8];
+    uint8_t root_path_cost[4];
+    uint8_t bridge_id[8];
+    uint8_t port_id[2];
+    uint8_t message_age[2];
+    uint8_t max_age[2];
+    uint8_t hello_time[2];
+    uint8_t forward_delay[2];
+    uint8_t v1_length;
 };
 
 #define STP_PROTO_REGULAR 0x00
@@ -104,36 +97,37 @@
 }
 
 static void
-stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
+stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+                      u_int length)
 {
-    printf(", Flags [%s]",
-           bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags));
+    ND_PRINT((ndo, ", Flags [%s]",
+           bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags)));
 
-    printf(", bridge-id %s.%04x, length %u",
+    ND_PRINT((ndo, ", bridge-id %s.%04x, length %u",
            stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id),
-           EXTRACT_16BITS(&stp_bpdu->port_id), length);
+           EXTRACT_16BITS(&stp_bpdu->port_id), length));
 
     /* in non-verbose mode just print the bridge-id */
-    if (!vflag) {
+    if (!ndo->ndo_vflag) {
         return;
     }
 
-    printf("\n\tmessage-age %.2fs, max-age %.2fs"
+    ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
            ", hello-time %.2fs, forwarding-delay %.2fs",
            (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
            (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
            (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
-           (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
+           (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
 
-    printf("\n\troot-id %s, root-pathcost %u",
+    ND_PRINT((ndo, "\n\troot-id %s, root-pathcost %u",
            stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
-           EXTRACT_32BITS(&stp_bpdu->root_path_cost));
+           EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
 
     /* Port role is only valid for 802.1w */
     if (stp_bpdu->protocol_version == STP_PROTO_RAPID) {
-        printf(", port-role %s",
+        ND_PRINT((ndo, ", port-role %s",
                tok2str(rstp_obj_port_role_values, "Unknown",
-                       RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+                       RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
     }
 }
 
@@ -144,7 +138,7 @@
  * MSTP BPDU
  *
  * 2 -  bytes Protocol Id
- * 1 -  byte  Protocol Ver. 
+ * 1 -  byte  Protocol Ver.
  * 1 -  byte  BPDU tye
  * 1 -  byte  Flags
  * 8 -  bytes CIST Root Identifier
@@ -171,11 +165,11 @@
  * Ref. IEEE 802.1aq. Section 14
  *
  * 2 -  bytes Version 4 length
- * 1 -  byte  Aux Config Identifier  
+ * 1 -  byte  Aux Config Identifier
  * 32 - bytes Aux Config Name
  * 2 -  bytes Aux Revision level
  * 16 - bytes Aux Config Digest [MD5]
- * 1 -  byte  (1 - 2) Agreement Number 
+ * 1 -  byte  (1 - 2) Agreement Number
  *            (3 - 4) Discarded Agreement Number
  *            (5) Agreement Valid Flag
  *            (6) Restricted Role Flag
@@ -234,62 +228,63 @@
 
 
 static void
-stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
+stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+                    u_int length)
 {
     const u_char *ptr;
-    u_int16_t	    v3len;
-    u_int16_t	    len;
-    u_int16_t	    msti;
+    uint16_t	    v3len;
+    uint16_t	    len;
+    uint16_t	    msti;
     u_int	    offset;
 
     ptr = (const u_char *)stp_bpdu;
-    printf(", CIST Flags [%s], length %u",
-           bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length);
+    ND_PRINT((ndo, ", CIST Flags [%s], length %u",
+           bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length));
 
     /*
      * in non-verbose mode just print the flags.
      */
-    if (!vflag) {
+    if (!ndo->ndo_vflag) {
         return;
     }
 
-    printf("\n\tport-role %s, ",
+    ND_PRINT((ndo, "\n\tport-role %s, ",
            tok2str(rstp_obj_port_role_values, "Unknown",
-                   RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+                   RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
 
-    printf("CIST root-id %s, CIST ext-pathcost %u ",
+    ND_PRINT((ndo, "CIST root-id %s, CIST ext-pathcost %u ",
            stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
-           EXTRACT_32BITS(&stp_bpdu->root_path_cost));
+           EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
 
-    printf("\n\tCIST regional-root-id %s, ",
-           stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
+    ND_PRINT((ndo, "\n\tCIST regional-root-id %s, ",
+           stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id)));
 
-    printf("CIST port-id %04x, ", EXTRACT_16BITS(&stp_bpdu->port_id));
+    ND_PRINT((ndo, "CIST port-id %04x, ", EXTRACT_16BITS(&stp_bpdu->port_id)));
 
-    printf("\n\tmessage-age %.2fs, max-age %.2fs"
+    ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
            ", hello-time %.2fs, forwarding-delay %.2fs",
            (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
            (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
            (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
-           (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
+           (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
 
-    printf ("\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET));
-    printf("MCID Name %s, rev %u, "
+    ND_PRINT((ndo, "\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET)));
+    ND_PRINT((ndo, "MCID Name %s, rev %u, "
             "\n\t\tdigest %08x%08x%08x%08x, ",
             ptr + MST_BPDU_CONFIG_NAME_OFFSET,
 	          EXTRACT_16BITS(ptr + MST_BPDU_CONFIG_NAME_OFFSET + 32),
       	    EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET),
         	  EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4),
 	          EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 8),
-	          EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12));
+	          EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12)));
 
-    printf ("CIST int-root-pathcost %u, ", 
-            EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET));  
+    ND_PRINT((ndo, "CIST int-root-pathcost %u, ",
+            EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET)));
 
-    printf("\n\tCIST bridge-id %s, ",
-           stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET));
+    ND_PRINT((ndo, "\n\tCIST bridge-id %s, ",
+           stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET)));
 
-    printf("CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
+    ND_PRINT((ndo, "CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]));
 
     /* Dump all MSTI's */
     v3len = EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
@@ -301,19 +296,19 @@
                                   MST_BPDU_MSTI_ROOT_PRIO_OFFSET);
             msti = msti & 0x0FFF;
 
-            printf("\n\tMSTI %d, Flags [%s], port-role %s", 
+            ND_PRINT((ndo, "\n\tMSTI %d, Flags [%s], port-role %s",
                    msti, bittok2str(stp_bpdu_flag_values, "none", ptr[offset]),
                    tok2str(rstp_obj_port_role_values, "Unknown",
-                           RSTP_EXTRACT_PORT_ROLE(ptr[offset])));
-            printf("\n\t\tMSTI regional-root-id %s, pathcost %u",
+                           RSTP_EXTRACT_PORT_ROLE(ptr[offset]))));
+            ND_PRINT((ndo, "\n\t\tMSTI regional-root-id %s, pathcost %u",
                    stp_print_bridge_id(ptr + offset +
                                        MST_BPDU_MSTI_ROOT_PRIO_OFFSET),
                    EXTRACT_32BITS(ptr + offset +
-                                  MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET));
-            printf("\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
+                                  MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET)));
+            ND_PRINT((ndo, "\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
                    ptr[offset + MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET] >> 4,
                    ptr[offset + MST_BPDU_MSTI_PORT_PRIO_OFFSET] >> 4,
-                   ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]);
+                   ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]));
 
             len -= MST_BPDU_MSTI_LENGTH;
             offset += MST_BPDU_MSTI_LENGTH;
@@ -322,32 +317,33 @@
 }
 
 static void
-stp_print_spb_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int offset)
+stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+                   u_int offset)
 {
     const u_char *ptr;
 
     /*
      * in non-verbose mode don't print anything.
      */
-    if (!vflag) {
+    if (!ndo->ndo_vflag) {
         return;
     }
 
     ptr = (const u_char *)stp_bpdu;
-    printf("\n\tv4len %d AUXMCID Name %s, Rev %u, \n\t\tdigest %08x%08x%08x%08x",
+    ND_PRINT((ndo, "\n\tv4len %d AUXMCID Name %s, Rev %u, \n\t\tdigest %08x%08x%08x%08x",
             EXTRACT_16BITS (ptr + offset),
             ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET,
             EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET),
             EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET),
             EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4),
             EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8),
-            EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12));
-     
-    printf("\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-"
+            EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12)));
+
+    ND_PRINT((ndo, "\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-"
             "flag %d, \n\tRestricted role-flag: %d, Format id %d cap %d, "
             "Convention id %d cap %d, \n\tEdge count %d, "
             "Agreement digest %08x%08x%08x%08x%08x\n",
-            ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6, 
+            ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6,
             ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3,
             ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1,
             ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1,
@@ -360,32 +356,32 @@
             EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+4,
             EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+8,
             EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+12,
-            EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+16);
+            EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+16));
 }
 
 /*
  * Print 802.1d / 802.1w / 802.1q (mstp) / 802.1aq (spb) packets.
  */
 void
-stp_print(const u_char *p, u_int length)
+stp_print(netdissect_options *ndo, const u_char *p, u_int length)
 {
     const struct stp_bpdu_ *stp_bpdu;
     u_int                  mstp_len;
     u_int                  spb_len;
-    
+
     stp_bpdu = (struct stp_bpdu_*)p;
 
     /* Minimum STP Frame size. */
     if (length < 4)
         goto trunc;
-        
+
     if (EXTRACT_16BITS(&stp_bpdu->protocol_id)) {
-        printf("unknown STP version, length %u", length);
+        ND_PRINT((ndo, "unknown STP version, length %u", length));
         return;
     }
 
-    printf("STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
-                         stp_bpdu->protocol_version));
+    ND_PRINT((ndo, "STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
+                         stp_bpdu->protocol_version)));
 
     switch (stp_bpdu->protocol_version) {
     case STP_PROTO_REGULAR:
@@ -397,15 +393,15 @@
         return;
     }
 
-    printf(", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
-                           stp_bpdu->bpdu_type));
+    ND_PRINT((ndo, ", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
+                           stp_bpdu->bpdu_type)));
 
     switch (stp_bpdu->bpdu_type) {
     case STP_BPDU_TYPE_CONFIG:
         if (length < sizeof(struct stp_bpdu_) - 1) {
             goto trunc;
         }
-        stp_print_config_bpdu(stp_bpdu, length);
+        stp_print_config_bpdu(ndo, stp_bpdu, length);
         break;
 
     case STP_BPDU_TYPE_RSTP:
@@ -413,7 +409,7 @@
             if (length < sizeof(struct stp_bpdu_)) {
                 goto trunc;
             }
-            stp_print_config_bpdu(stp_bpdu, length);
+            stp_print_config_bpdu(ndo, stp_bpdu, length);
         } else if (stp_bpdu->protocol_version == STP_PROTO_MSTP ||
                    stp_bpdu->protocol_version == STP_PROTO_SPB) {
             if (length < STP_BPDU_MSTP_MIN_LEN) {
@@ -431,7 +427,7 @@
             if (length < (sizeof(struct stp_bpdu_) + mstp_len)) {
                 goto trunc;
             }
-            stp_print_mstp_bpdu(stp_bpdu, length);
+            stp_print_mstp_bpdu(ndo, stp_bpdu, length);
 
             if (stp_bpdu->protocol_version == STP_PROTO_SPB)
             {
@@ -442,7 +438,7 @@
                   spb_len < SPB_BPDU_MIN_LEN) {
                 goto trunc;
               }
-              stp_print_spb_bpdu(stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len));
+              stp_print_spb_bpdu(ndo, stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len));
             }
         }
         break;
@@ -457,7 +453,7 @@
 
     return;
  trunc:
-    printf("[|stp %d]", length);
+    ND_PRINT((ndo, "[|stp %d]", length));
 }
 
 /*
diff --git a/print-sunatm.c b/print-sunatm.c
index e6f19e8..fc03d42 100644
--- a/print-sunatm.c
+++ b/print-sunatm.c
@@ -29,29 +29,21 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004-03-17 23:24:38 guy Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
- 
+
 struct mbuf;
 struct rtentry;
- 
-#include <stdio.h>
-#include <pcap.h>
 
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
 
 #include "atm.h"
-#include "atmuni31.h"
 
 /* SunATM header for ATM packet */
 #define DIR_POS		0	/* Direction (0x80 = transmit, 0x00 = receive) */
@@ -70,7 +62,8 @@
  * is the number of bytes actually captured.
  */
 u_int
-sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sunatm_if_print(netdissect_options *ndo,
+                const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int caplen = h->caplen;
 	u_int length = h->len;
@@ -79,15 +72,12 @@
 	u_int traftype;
 
 	if (caplen < PKT_BEGIN_POS) {
-		printf("[|atm]");
+		ND_PRINT((ndo, "[|atm]"));
 		return (caplen);
 	}
 
-	if (eflag) {
-		if (p[DIR_POS] & 0x80)
-			printf("Tx: ");
-		else
-			printf("Rx: ");
+	if (ndo->ndo_eflag) {
+		ND_PRINT((ndo, p[DIR_POS] & 0x80 ? "Tx: " : "Rx: "));
 	}
 
 	switch (p[DIR_POS] & 0x0f) {
@@ -111,7 +101,7 @@
 	p += PKT_BEGIN_POS;
 	caplen -= PKT_BEGIN_POS;
 	length -= PKT_BEGIN_POS;
-	atm_print(vpi, vci, traftype, p, length, caplen);
+	atm_print(ndo, vpi, vci, traftype, p, length, caplen);
 
 	return (PKT_BEGIN_POS);
 }
diff --git a/print-sunrpc.c b/print-sunrpc.c
index 195825d..bc7138d 100644
--- a/print-sunrpc.c
+++ b/print-sunrpc.c
@@ -19,11 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.47 2005-04-27 21:43:48 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -66,7 +62,95 @@
 
 #include "rpc_auth.h"
 #include "rpc_msg.h"
-#include "pmap_prot.h"
+
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part.  Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California  94043
+ *
+ *	from: @(#)pmap_prot.h 1.14 88/02/08 SMI
+ *	from: @(#)pmap_prot.h	2.1 88/07/29 4.0 RPCSRC
+ * $FreeBSD: src/include/rpc/pmap_prot.h,v 1.9.2.1 1999/08/29 14:39:05 peter Exp $
+ */
+
+/*
+ * pmap_prot.h
+ * Protocol for the local binder service, or pmap.
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ *
+ * The following procedures are supported by the protocol:
+ *
+ * PMAPPROC_NULL() returns ()
+ * 	takes nothing, returns nothing
+ *
+ * PMAPPROC_SET(struct pmap) returns (bool_t)
+ * 	TRUE is success, FALSE is failure.  Registers the tuple
+ *	[prog, vers, prot, port].
+ *
+ * PMAPPROC_UNSET(struct pmap) returns (bool_t)
+ *	TRUE is success, FALSE is failure.  Un-registers pair
+ *	[prog, vers].  prot and port are ignored.
+ *
+ * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
+ *	0 is failure.  Otherwise returns the port number where the pair
+ *	[prog, vers] is registered.  It may lie!
+ *
+ * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
+ *
+ * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
+ * 	RETURNS (port, string<>);
+ * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
+ * 	Calls the procedure on the local machine.  If it is not registered,
+ *	this procedure is quite; ie it does not return error information!!!
+ *	This procedure only is supported on rpc/udp and calls via
+ *	rpc/udp.  This routine only passes null authentication parameters.
+ *	This file has no interface to xdr routines for PMAPPROC_CALLIT.
+ *
+ * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
+ */
+
+#define SUNRPC_PMAPPORT		((uint16_t)111)
+#define SUNRPC_PMAPPROG		((uint32_t)100000)
+#define SUNRPC_PMAPVERS		((uint32_t)2)
+#define SUNRPC_PMAPVERS_PROTO	((uint32_t)2)
+#define SUNRPC_PMAPVERS_ORIG	((uint32_t)1)
+#define SUNRPC_PMAPPROC_NULL	((uint32_t)0)
+#define SUNRPC_PMAPPROC_SET	((uint32_t)1)
+#define SUNRPC_PMAPPROC_UNSET	((uint32_t)2)
+#define SUNRPC_PMAPPROC_GETPORT	((uint32_t)3)
+#define SUNRPC_PMAPPROC_DUMP	((uint32_t)4)
+#define SUNRPC_PMAPPROC_CALLIT	((uint32_t)5)
+
+struct sunrpc_pmap {
+	uint32_t pm_prog;
+	uint32_t pm_vers;
+	uint32_t pm_prot;
+	uint32_t pm_port;
+};
 
 static const struct tok proc2str[] = {
 	{ SUNRPC_PMAPPROC_NULL,		"null" },
@@ -79,23 +163,23 @@
 };
 
 /* Forwards */
-static char *progstr(u_int32_t);
+static char *progstr(uint32_t);
 
 void
-sunrpcrequest_print(register const u_char *bp, register u_int length,
-		    register const u_char *bp2)
+sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
+                    register u_int length, register const u_char *bp2)
 {
 	register const struct sunrpc_msg *rp;
 	register const struct ip *ip;
 #ifdef INET6
 	register const struct ip6_hdr *ip6;
 #endif
-	u_int32_t x;
+	uint32_t x;
 	char srcid[20], dstid[20];	/*fits 32bit*/
 
 	rp = (struct sunrpc_msg *)bp;
 
-	if (!nflag) {
+	if (!ndo->ndo_nflag) {
 		snprintf(srcid, sizeof(srcid), "0x%x",
 		    EXTRACT_32BITS(&rp->rm_xid));
 		strlcpy(dstid, "sunrpc", sizeof(dstid));
@@ -108,28 +192,28 @@
 	switch (IP_V((struct ip *)bp2)) {
 	case 4:
 		ip = (struct ip *)bp2;
-		printf("%s.%s > %s.%s: %d",
-		    ipaddr_string(&ip->ip_src), srcid,
-		    ipaddr_string(&ip->ip_dst), dstid, length);
+		ND_PRINT((ndo, "%s.%s > %s.%s: %d",
+		    ipaddr_string(ndo, &ip->ip_src), srcid,
+		    ipaddr_string(ndo, &ip->ip_dst), dstid, length));
 		break;
 #ifdef INET6
 	case 6:
 		ip6 = (struct ip6_hdr *)bp2;
-		printf("%s.%s > %s.%s: %d",
-		    ip6addr_string(&ip6->ip6_src), srcid,
-		    ip6addr_string(&ip6->ip6_dst), dstid, length);
+		ND_PRINT((ndo, "%s.%s > %s.%s: %d",
+		    ip6addr_string(ndo, &ip6->ip6_src), srcid,
+		    ip6addr_string(ndo, &ip6->ip6_dst), dstid, length));
 		break;
 #endif
 	default:
-		printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length);
+		ND_PRINT((ndo, "%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length));
 		break;
 	}
 
-	printf(" %s", tok2str(proc2str, " proc #%u",
-	    EXTRACT_32BITS(&rp->rm_call.cb_proc)));
+	ND_PRINT((ndo, " %s", tok2str(proc2str, " proc #%u",
+	    EXTRACT_32BITS(&rp->rm_call.cb_proc))));
 	x = EXTRACT_32BITS(&rp->rm_call.cb_rpcvers);
 	if (x != 2)
-		printf(" [rpcver %u]", x);
+		ND_PRINT((ndo, " [rpcver %u]", x));
 
 	switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) {
 
@@ -138,24 +222,23 @@
 	case SUNRPC_PMAPPROC_GETPORT:
 	case SUNRPC_PMAPPROC_CALLIT:
 		x = EXTRACT_32BITS(&rp->rm_call.cb_prog);
-		if (!nflag)
-			printf(" %s", progstr(x));
+		if (!ndo->ndo_nflag)
+			ND_PRINT((ndo, " %s", progstr(x)));
 		else
-			printf(" %u", x);
-		printf(".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers));
+			ND_PRINT((ndo, " %u", x));
+		ND_PRINT((ndo, ".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers)));
 		break;
 	}
 }
 
 static char *
-progstr(prog)
-	u_int32_t prog;
+progstr(uint32_t prog)
 {
 #if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
 	register struct rpcent *rp;
 #endif
 	static char buf[32];
-	static u_int32_t lastprog = 0;
+	static uint32_t lastprog = 0;
 
 	if (lastprog != 0 && prog == lastprog)
 		return (buf);
diff --git a/print-symantec.c b/print-symantec.c
index 8b4ee38..dcff2a6 100644
--- a/print-symantec.c
+++ b/print-symantec.c
@@ -18,57 +18,50 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-symantec.c,v 1.5 2005-07-07 01:22:21 guy Exp $ (LBL)";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <pcap.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
 #include "ethertype.h"
 
 #include "ether.h"
 
 struct symantec_header {
-	u_int8_t  stuff1[6];
-	u_int16_t ether_type;
-	u_int8_t  stuff2[36];
+	uint8_t  stuff1[6];
+	uint16_t ether_type;
+	uint8_t  stuff2[36];
 };
 
 static inline void
-symantec_hdr_print(register const u_char *bp, u_int length)
+symantec_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
 {
 	register const struct symantec_header *sp;
-	u_int16_t etype;
+	uint16_t etype;
 
 	sp = (const struct symantec_header *)bp;
 
 	etype = EXTRACT_16BITS(&sp->ether_type);
-	if (!qflag) {
+	if (!ndo->ndo_qflag) {
 	        if (etype <= ETHERMTU)
-		          (void)printf("invalid ethertype %u", etype);
-                else 
-		          (void)printf("ethertype %s (0x%04x)",
+		          ND_PRINT((ndo, "invalid ethertype %u", etype));
+                else
+		          ND_PRINT((ndo, "ethertype %s (0x%04x)",
 				       tok2str(ethertype_values,"Unknown", etype),
-                                       etype);
+                                       etype));
         } else {
                 if (etype <= ETHERMTU)
-                          (void)printf("invalid ethertype %u", etype);
-                else 
-                          (void)printf("%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype));  
+                          ND_PRINT((ndo, "invalid ethertype %u", etype));
+                else
+                          ND_PRINT((ndo, "%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype)));
         }
 
-	(void)printf(", length %u: ", length);
+	ND_PRINT((ndo, ", length %u: ", length));
 }
 
 /*
@@ -78,7 +71,7 @@
  * is the number of bytes actually captured.
  */
 u_int
-symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
+symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 	u_int length = h->len;
 	u_int caplen = h->caplen;
@@ -86,12 +79,12 @@
 	u_short ether_type;
 
 	if (caplen < sizeof (struct symantec_header)) {
-		printf("[|symantec]");
+		ND_PRINT((ndo, "[|symantec]"));
 		return caplen;
 	}
 
-	if (eflag)
-		symantec_hdr_print(p, length);
+	if (ndo->ndo_eflag)
+		symantec_hdr_print(ndo, p, length);
 
 	length -= sizeof (struct symantec_header);
 	caplen -= sizeof (struct symantec_header);
@@ -102,19 +95,19 @@
 
 	if (ether_type <= ETHERMTU) {
 		/* ether_type not known, print raw packet */
-		if (!eflag)
-			symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+		if (!ndo->ndo_eflag)
+			symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
 
-		if (!suppress_default_print)
-			default_print(p, caplen);
-	} else if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
+	} else if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
 		/* ether_type not known, print raw packet */
-		if (!eflag)
-			symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+		if (!ndo->ndo_eflag)
+			symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
 
-		if (!suppress_default_print)
-			default_print(p, caplen);
-	} 
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
+	}
 
 	return (sizeof (struct symantec_header));
 }
diff --git a/print-syslog.c b/print-syslog.c
index f213cf2..5e3cd4f 100644
--- a/print-syslog.c
+++ b/print-syslog.c
@@ -14,23 +14,18 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-syslog.c,v 1.1 2004-10-29 11:42:53 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
 
+static const char tstr[] = "[|syslog]";
+
 /*
  * tokenlists and #defines taken from Ethereal - Network traffic analyzer
  * by Gerald Combs <gerald@ethereal.com>
@@ -81,11 +76,12 @@
 };
 
 void
-syslog_print(register const u_char *pptr, register u_int len)
+syslog_print(netdissect_options *ndo,
+             register const u_char *pptr, register u_int len)
 {
-    u_int16_t msg_off = 0;
-    u_int16_t pri = 0;
-    u_int16_t facility,severity;
+    uint16_t msg_off = 0;
+    uint16_t pri = 0;
+    uint16_t facility,severity;
 
     /* extract decimal figures that are
      * encapsulated within < > tags
@@ -93,57 +89,57 @@
      * severity and facility values
      */
 
-    TCHECK2(*pptr, 1);
+    ND_TCHECK2(*pptr, 1);
     if (*(pptr+msg_off) == '<') {
         msg_off++;
-        TCHECK2(*(pptr+msg_off), 1);
+        ND_TCHECK2(*(pptr + msg_off), 1);
         while ( *(pptr+msg_off) >= '0' &&
                 *(pptr+msg_off) <= '9' &&
                 msg_off <= SYSLOG_MAX_DIGITS) {
             pri = pri * 10 + (*(pptr+msg_off) - '0');
             msg_off++;
-            TCHECK2(*(pptr+msg_off), 1);
+            ND_TCHECK2(*(pptr + msg_off), 1);
         }
         if (*(pptr+msg_off) != '>') {
-            printf("[|syslog]");
+            ND_PRINT((ndo, "%s", tstr));
             return;
         }
         msg_off++;
     } else {
-        printf("[|syslog]");
+        ND_PRINT((ndo, "%s", tstr));
         return;
     }
 
     facility = (pri & SYSLOG_FACILITY_MASK) >> 3;
     severity = pri & SYSLOG_SEVERITY_MASK;
 
-    if (vflag < 1 )
+    if (ndo->ndo_vflag < 1 )
     {
-        printf("SYSLOG %s.%s, length: %u",
+        ND_PRINT((ndo, "SYSLOG %s.%s, length: %u",
                tok2str(syslog_facility_values, "unknown (%u)", facility),
                tok2str(syslog_severity_values, "unknown (%u)", severity),
-               len);
+               len));
         return;
     }
 
-    printf("SYSLOG, length: %u\n\tFacility %s (%u), Severity %s (%u)\n\tMsg: ",
+    ND_PRINT((ndo, "SYSLOG, length: %u\n\tFacility %s (%u), Severity %s (%u)\n\tMsg: ",
            len,
            tok2str(syslog_facility_values, "unknown (%u)", facility),
            facility,
            tok2str(syslog_severity_values, "unknown (%u)", severity),
-           severity);
+           severity));
 
     /* print the syslog text in verbose mode */
     for (; msg_off < len; msg_off++) {
-        TCHECK2(*(pptr+msg_off), 1);
-        safeputchar(*(pptr+msg_off));
+        ND_TCHECK2(*(pptr + msg_off), 1);
+        safeputchar(ndo, *(pptr + msg_off));
     }
 
-    if (vflag > 1)
-        print_unknown_data(pptr,"\n\t",len);
+    if (ndo->ndo_vflag > 1)
+        print_unknown_data(ndo, pptr, "\n\t", len);
 
     return;
 
 trunc:
-        printf("[|syslog]");
+    ND_PRINT((ndo, "%s", tstr));
 }
diff --git a/print-tcp.c b/print-tcp.c
index 4b807c9..bc200e2 100644
--- a/print-tcp.c
+++ b/print-tcp.c
@@ -24,19 +24,17 @@
  */
 
 #ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.135 2008-11-09 23:35:03 mcr Exp $ (LBL)";
 #else
 __RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
 #endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -60,11 +58,12 @@
 #include <openssl/md5.h>
 #include <signature.h>
 
-static int tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
+static int tcp_verify_signature(netdissect_options *ndo,
+                                const struct ip *ip, const struct tcphdr *tp,
                                 const u_char *data, int length, const u_char *rcvsig);
 #endif
 
-static void print_tcp_rst_data(register const u_char *sp, u_int length);
+static void print_tcp_rst_data(netdissect_options *, register const u_char *sp, u_int length);
 
 #define MAX_RST_DATA_LEN	30
 
@@ -140,27 +139,30 @@
         { 0, NULL }
 };
 
-static int tcp_cksum(register const struct ip *ip,
-		     register const struct tcphdr *tp,
-		     register u_int len)
+static int
+tcp_cksum(netdissect_options *ndo,
+          register const struct ip *ip,
+          register const struct tcphdr *tp,
+          register u_int len)
 {
-	return (nextproto4_cksum(ip, (const u_int8_t *)tp, len,
-	    IPPROTO_TCP));
+	return nextproto4_cksum(ndo, ip, (const uint8_t *)tp, len, len,
+				IPPROTO_TCP);
 }
 
 void
-tcp_print(register const u_char *bp, register u_int length,
-	  register const u_char *bp2, int fragmented)
+tcp_print(netdissect_options *ndo,
+          register const u_char *bp, register u_int length,
+          register const u_char *bp2, int fragmented)
 {
         register const struct tcphdr *tp;
         register const struct ip *ip;
         register u_char flags;
         register u_int hlen;
         register char ch;
-        u_int16_t sport, dport, win, urp;
-        u_int32_t seq, ack, thseq, thack;
+        uint16_t sport, dport, win, urp;
+        uint32_t seq, ack, thseq, thack;
         u_int utoval;
-        u_int16_t magic;
+        uint16_t magic;
         register int rev;
 #ifdef INET6
         register const struct ip6_hdr *ip6;
@@ -175,10 +177,10 @@
                 ip6 = NULL;
 #endif /*INET6*/
         ch = '\0';
-        if (!TTEST(tp->th_dport)) {
-                (void)printf("%s > %s: [|tcp]",
-                             ipaddr_string(&ip->ip_src),
-                             ipaddr_string(&ip->ip_dst));
+        if (!ND_TTEST(tp->th_dport)) {
+                ND_PRINT((ndo, "%s > %s: [|tcp]",
+                             ipaddr_string(ndo, &ip->ip_src),
+                             ipaddr_string(ndo, &ip->ip_dst)));
                 return;
         }
 
@@ -190,56 +192,56 @@
 #ifdef INET6
         if (ip6) {
                 if (ip6->ip6_nxt == IPPROTO_TCP) {
-                        (void)printf("%s.%s > %s.%s: ",
-                                     ip6addr_string(&ip6->ip6_src),
+                        ND_PRINT((ndo, "%s.%s > %s.%s: ",
+                                     ip6addr_string(ndo, &ip6->ip6_src),
                                      tcpport_string(sport),
-                                     ip6addr_string(&ip6->ip6_dst),
-                                     tcpport_string(dport));
+                                     ip6addr_string(ndo, &ip6->ip6_dst),
+                                     tcpport_string(dport)));
                 } else {
-                        (void)printf("%s > %s: ",
-                                     tcpport_string(sport), tcpport_string(dport));
+                        ND_PRINT((ndo, "%s > %s: ",
+                                     tcpport_string(sport), tcpport_string(dport)));
                 }
         } else
 #endif /*INET6*/
         {
                 if (ip->ip_p == IPPROTO_TCP) {
-                        (void)printf("%s.%s > %s.%s: ",
-                                     ipaddr_string(&ip->ip_src),
+                        ND_PRINT((ndo, "%s.%s > %s.%s: ",
+                                     ipaddr_string(ndo, &ip->ip_src),
                                      tcpport_string(sport),
-                                     ipaddr_string(&ip->ip_dst),
-                                     tcpport_string(dport));
+                                     ipaddr_string(ndo, &ip->ip_dst),
+                                     tcpport_string(dport)));
                 } else {
-                        (void)printf("%s > %s: ",
-                                     tcpport_string(sport), tcpport_string(dport));
+                        ND_PRINT((ndo, "%s > %s: ",
+                                     tcpport_string(sport), tcpport_string(dport)));
                 }
         }
 
         if (hlen < sizeof(*tp)) {
-                (void)printf(" tcp %d [bad hdr length %u - too short, < %lu]",
-                             length - hlen, hlen, (unsigned long)sizeof(*tp));
+                ND_PRINT((ndo, " tcp %d [bad hdr length %u - too short, < %lu]",
+                             length - hlen, hlen, (unsigned long)sizeof(*tp)));
                 return;
         }
 
-        TCHECK(*tp);
+        ND_TCHECK(*tp);
 
         seq = EXTRACT_32BITS(&tp->th_seq);
         ack = EXTRACT_32BITS(&tp->th_ack);
         win = EXTRACT_16BITS(&tp->th_win);
         urp = EXTRACT_16BITS(&tp->th_urp);
 
-        if (qflag) {
-                (void)printf("tcp %d", length - hlen);
+        if (ndo->ndo_qflag) {
+                ND_PRINT((ndo, "tcp %d", length - hlen));
                 if (hlen > length) {
-                        (void)printf(" [bad hdr length %u - too long, > %u]",
-                                     hlen, length);
+                        ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+                                     hlen, length));
                 }
                 return;
         }
 
         flags = tp->th_flags;
-        printf("Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags));
+        ND_PRINT((ndo, "Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags)));
 
-        if (!Sflag && (flags & TH_ACK)) {
+        if (!ndo->ndo_Sflag && (flags & TH_ACK)) {
                 /*
                  * Find (or record) the initial sequence numbers for
                  * this conversation.  (we pick an arbitrary
@@ -363,40 +365,41 @@
                 thseq = thack = rev = 0;
         }
         if (hlen > length) {
-                (void)printf(" [bad hdr length %u - too long, > %u]",
-                             hlen, length);
+                ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+                             hlen, length));
                 return;
         }
 
-        if (vflag && !Kflag && !fragmented) {
+        if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
                 /* Check the checksum, if possible. */
-                u_int16_t sum, tcp_sum;
+                uint16_t sum, tcp_sum;
 
                 if (IP_V(ip) == 4) {
-                        if (TTEST2(tp->th_sport, length)) {
-                                sum = tcp_cksum(ip, tp, length);
+                        if (ND_TTEST2(tp->th_sport, length)) {
+                                sum = tcp_cksum(ndo, ip, tp, length);
                                 tcp_sum = EXTRACT_16BITS(&tp->th_sum);
 
-                                (void)printf(", cksum 0x%04x", tcp_sum);
+                                ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
                                 if (sum != 0)
-                                        (void)printf(" (incorrect -> 0x%04x)",
-                                            in_cksum_shouldbe(tcp_sum, sum));
+                                        ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+                                            in_cksum_shouldbe(tcp_sum, sum)));
                                 else
-                                        (void)printf(" (correct)");
+                                        ND_PRINT((ndo, " (correct)"));
                         }
                 }
 #ifdef INET6
                 else if (IP_V(ip) == 6 && ip6->ip6_plen) {
-                        if (TTEST2(tp->th_sport, length)) {
-                                sum = nextproto6_cksum(ip6, (const u_int8_t *)tp, length, IPPROTO_TCP);
+                        if (ND_TTEST2(tp->th_sport, length)) {
+                                sum = nextproto6_cksum(ip6, (const uint8_t *)tp,
+							length, length, IPPROTO_TCP);
                                 tcp_sum = EXTRACT_16BITS(&tp->th_sum);
 
-                                (void)printf(", cksum 0x%04x", tcp_sum);
+                                ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
                                 if (sum != 0)
-                                        (void)printf(" (incorrect -> 0x%04x)",
-                                            in_cksum_shouldbe(tcp_sum, sum));
+                                        ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+                                            in_cksum_shouldbe(tcp_sum, sum)));
                                 else
-                                        (void)printf(" (correct)");
+                                        ND_PRINT((ndo, " (correct)"));
 
                         }
                 }
@@ -404,22 +407,22 @@
         }
 
         length -= hlen;
-        if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
-                (void)printf(", seq %u", seq);
+        if (ndo->ndo_vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
+                ND_PRINT((ndo, ", seq %u", seq));
 
                 if (length > 0) {
-                        (void)printf(":%u", seq + length);
+                        ND_PRINT((ndo, ":%u", seq + length));
                 }
         }
 
         if (flags & TH_ACK) {
-                (void)printf(", ack %u", ack);
+                ND_PRINT((ndo, ", ack %u", ack));
         }
 
-        (void)printf(", win %d", win);
+        ND_PRINT((ndo, ", win %d", win));
 
         if (flags & TH_URG)
-                (void)printf(", urg %d", urp);
+                ND_PRINT((ndo, ", urg %d", urp));
         /*
          * Handle any options.
          */
@@ -430,16 +433,16 @@
 
                 hlen -= sizeof(*tp);
                 cp = (const u_char *)tp + sizeof(*tp);
-                printf(", options [");
+                ND_PRINT((ndo, ", options ["));
                 while (hlen > 0) {
                         if (ch != '\0')
-                                putchar(ch);
-                        TCHECK(*cp);
+                                ND_PRINT((ndo, "%c", ch));
+                        ND_TCHECK(*cp);
                         opt = *cp++;
                         if (ZEROLENOPT(opt))
                                 len = 1;
                         else {
-                                TCHECK(*cp);
+                                ND_TCHECK(*cp);
                                 len = *cp++;	/* total including type, len */
                                 if (len < 2 || len > hlen)
                                         goto bad;
@@ -449,33 +452,33 @@
                         datalen = 0;
 
 /* Bail if "l" bytes of data are not left or were not captured  */
-#define LENCHECK(l) { if ((l) > hlen) goto bad; TCHECK2(*cp, l); }
+#define LENCHECK(l) { if ((l) > hlen) goto bad; ND_TCHECK2(*cp, l); }
 
 
-                        printf("%s", tok2str(tcp_option_values, "unknown-%u", opt));
+                        ND_PRINT((ndo, "%s", tok2str(tcp_option_values, "unknown-%u", opt)));
 
                         switch (opt) {
 
                         case TCPOPT_MAXSEG:
                                 datalen = 2;
                                 LENCHECK(datalen);
-                                (void)printf(" %u", EXTRACT_16BITS(cp));
+                                ND_PRINT((ndo, " %u", EXTRACT_16BITS(cp)));
                                 break;
 
                         case TCPOPT_WSCALE:
                                 datalen = 1;
                                 LENCHECK(datalen);
-                                (void)printf(" %u", *cp);
+                                ND_PRINT((ndo, " %u", *cp));
                                 break;
 
                         case TCPOPT_SACK:
                                 datalen = len - 2;
                                 if (datalen % 8 != 0) {
-                                        (void)printf("malformed sack");
+                                        ND_PRINT((ndo, "malformed sack"));
                                 } else {
-                                        u_int32_t s, e;
+                                        uint32_t s, e;
 
-                                        (void)printf(" %d ", datalen / 8);
+                                        ND_PRINT((ndo, " %d ", datalen / 8));
                                         for (i = 0; i < datalen; i += 8) {
                                                 LENCHECK(i + 4);
                                                 s = EXTRACT_32BITS(cp + i);
@@ -488,7 +491,7 @@
                                                         s -= thack;
                                                         e -= thack;
                                                 }
-                                                (void)printf("{%u:%u}", s, e);
+                                                ND_PRINT((ndo, "{%u:%u}", s, e));
                                         }
                                 }
                                 break;
@@ -505,50 +508,50 @@
                                  */
                                 datalen = 4;
                                 LENCHECK(datalen);
-                                (void)printf(" %u", EXTRACT_32BITS(cp));
+                                ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
                                 break;
 
                         case TCPOPT_TIMESTAMP:
                                 datalen = 8;
                                 LENCHECK(datalen);
-                                (void)printf(" val %u ecr %u",
+                                ND_PRINT((ndo, " val %u ecr %u",
                                              EXTRACT_32BITS(cp),
-                                             EXTRACT_32BITS(cp + 4));
+                                             EXTRACT_32BITS(cp + 4)));
                                 break;
 
                         case TCPOPT_SIGNATURE:
                                 datalen = TCP_SIGLEN;
                                 LENCHECK(datalen);
 #ifdef HAVE_LIBCRYPTO
-                                switch (tcp_verify_signature(ip, tp,
+                                switch (tcp_verify_signature(ndo, ip, tp,
                                                              bp + TH_OFF(tp) * 4, length, cp)) {
 
                                 case SIGNATURE_VALID:
-                                        (void)printf("valid");
+                                        ND_PRINT((ndo, "valid"));
                                         break;
 
                                 case SIGNATURE_INVALID:
-                                        (void)printf("invalid");
+                                        ND_PRINT((ndo, "invalid"));
                                         break;
 
                                 case CANT_CHECK_SIGNATURE:
-                                        (void)printf("can't check - ");
+                                        ND_PRINT((ndo, "can't check - "));
                                         for (i = 0; i < TCP_SIGLEN; ++i)
-                                                (void)printf("%02x", cp[i]);
+                                                ND_PRINT((ndo, "%02x", cp[i]));
                                         break;
                                 }
 #else
                                 for (i = 0; i < TCP_SIGLEN; ++i)
-                                        (void)printf("%02x", cp[i]);
+                                        ND_PRINT((ndo, "%02x", cp[i]));
 #endif
                                 break;
 
                         case TCPOPT_AUTH:
-                                (void)printf("keyid %d", *cp++);
+                                ND_PRINT((ndo, "keyid %d", *cp++));
                                 datalen = len - 3;
                                 for (i = 0; i < datalen; ++i) {
                                         LENCHECK(i);
-                                        (void)printf("%02x", cp[i]);
+                                        ND_PRINT((ndo, "%02x", cp[i]));
                                 }
                                 break;
 
@@ -566,18 +569,18 @@
                                 datalen = 2;
                                 LENCHECK(datalen);
                                 utoval = EXTRACT_16BITS(cp);
-                                (void)printf("0x%x", utoval);
+                                ND_PRINT((ndo, "0x%x", utoval));
                                 if (utoval & 0x0001)
                                         utoval = (utoval >> 1) * 60;
                                 else
                                         utoval >>= 1;
-                                (void)printf(" %u", utoval);
+                                ND_PRINT((ndo, " %u", utoval));
                                 break;
 
                         case TCPOPT_MPTCP:
                                 datalen = len - 2;
                                 LENCHECK(datalen);
-                                if (!mptcp_print(cp-2, len, flags))
+                                if (!mptcp_print(ndo, cp-2, len, flags))
                                         goto bad;
                                 break;
 
@@ -588,30 +591,30 @@
                                         goto bad;
                                 /* RFC6994 */
                                 magic = EXTRACT_16BITS(cp);
-                                (void)printf("-");
+                                ND_PRINT((ndo, "-"));
 
                                 switch(magic) {
 
                                 case 0xf989:
-                                        /* TCP Fast Open: draft-ietf-tcpm-fastopen-04 */
+                                        /* TCP Fast Open: RFC 7413 */
                                         if (datalen == 2) {
                                                 /* Fast Open Cookie Request */
-                                                (void)printf("tfo cookiereq");
+                                                ND_PRINT((ndo, "tfo cookiereq"));
                                         } else {
                                                 /* Fast Open Cookie */
                                                 if (datalen % 2 != 0 || datalen < 6 || datalen > 18) {
-                                                        (void)printf("tfo malformed");
+                                                        ND_PRINT((ndo, "tfo malformed"));
                                                 } else {
-                                                        (void)printf("tfo cookie ");
+                                                        ND_PRINT((ndo, "tfo cookie "));
                                                         for (i = 2; i < datalen; ++i)
-                                                                (void)printf("%02x", cp[i]);
+                                                                ND_PRINT((ndo, "%02x", cp[i]));
                                                 }
                                         }
                                         break;
 
                                 default:
                                         /* Unknown magic number */
-                                        (void)printf("%04x", magic);
+                                        ND_PRINT((ndo, "%04x", magic));
                                         break;
                                 }
                                 break;
@@ -619,10 +622,10 @@
                         default:
                                 datalen = len - 2;
                                 if (datalen)
-                                        printf(" 0x");
+                                        ND_PRINT((ndo, " 0x"));
                                 for (i = 0; i < datalen; ++i) {
                                         LENCHECK(i);
-                                        (void)printf("%02x", cp[i]);
+                                        ND_PRINT((ndo, "%02x", cp[i]));
                                 }
                                 break;
                         }
@@ -636,18 +639,18 @@
                         if (!ZEROLENOPT(opt))
                                 ++datalen;		/* size octet */
                         if (datalen != len)
-                                (void)printf("[len %d]", len);
+                                ND_PRINT((ndo, "[len %d]", len));
                         ch = ',';
                         if (opt == TCPOPT_EOL)
                                 break;
                 }
-                putchar(']');
+                ND_PRINT((ndo, "]"));
         }
 
         /*
          * Print length field before crawling down the stack.
          */
-        printf(", length %u", length);
+        ND_PRINT((ndo, ", length %u", length));
 
         if (length <= 0)
                 return;
@@ -656,62 +659,76 @@
          * Decode payload if necessary.
          */
         bp += TH_OFF(tp) * 4;
-        if ((flags & TH_RST) && vflag) {
-                print_tcp_rst_data(bp, length);
+        if ((flags & TH_RST) && ndo->ndo_vflag) {
+                print_tcp_rst_data(ndo, bp, length);
                 return;
-        } 
+        }
 
-        if (packettype) {
-                switch (packettype) {
+        if (ndo->ndo_packettype) {
+                switch (ndo->ndo_packettype) {
                 case PT_ZMTP1:
-                        zmtp1_print(bp, length);
+                        zmtp1_print(ndo, bp, length);
                         break;
                 }
                 return;
         }
 
         if (sport == TELNET_PORT || dport == TELNET_PORT) {
-                if (!qflag && vflag)
-                        telnet_print(bp, length);
+                telnet_print(ndo, bp, length);
+        } else if (sport == SMTP_PORT || dport == SMTP_PORT) {
+                ND_PRINT((ndo, ": "));
+                smtp_print(ndo, bp, length);
         } else if (sport == BGP_PORT || dport == BGP_PORT)
-                bgp_print(bp, length);
+                bgp_print(ndo, bp, length);
         else if (sport == PPTP_PORT || dport == PPTP_PORT)
-                pptp_print(bp);
+                pptp_print(ndo, bp);
 #ifdef TCPDUMP_DO_SMB
         else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
-                nbt_tcp_print(bp, length);
+                nbt_tcp_print(ndo, bp, length);
 	else if (sport == SMB_PORT || dport == SMB_PORT)
-		smb_tcp_print(bp, length);
+		smb_tcp_print(ndo, bp, length);
 #endif
         else if (sport == BEEP_PORT || dport == BEEP_PORT)
-                beep_print(bp, length);
-        else if (sport == OPENFLOW_PORT || dport == OPENFLOW_PORT)
-                openflow_print(bp, length);
-        else if (length > 2 &&
+                beep_print(ndo, bp, length);
+        else if (sport == OPENFLOW_PORT_OLD || dport == OPENFLOW_PORT_OLD ||
+                 sport == OPENFLOW_PORT_IANA || dport == OPENFLOW_PORT_IANA)
+                openflow_print(ndo, bp, length);
+        else if (sport == FTP_PORT || dport == FTP_PORT) {
+                ND_PRINT((ndo, ": "));
+                ftp_print(ndo, bp, length);
+        } else if (sport == HTTP_PORT || dport == HTTP_PORT ||
+            sport == HTTP_PORT_ALT || dport == HTTP_PORT_ALT) {
+                ND_PRINT((ndo, ": "));
+                http_print(ndo, bp, length);
+        } else if (sport == RTSP_PORT || dport == RTSP_PORT ||
+            sport == RTSP_PORT_ALT || dport == RTSP_PORT_ALT) {
+                ND_PRINT((ndo, ": "));
+                rtsp_print(ndo, bp, length);
+        } else if (length > 2 &&
                  (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT ||
                   sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) {
                 /*
                  * TCP DNS query has 2byte length at the head.
                  * XXX packet could be unaligned, it can go strange
                  */
-                ns_print(bp + 2, length - 2, 0);
+                ns_print(ndo, bp + 2, length - 2, 0);
         } else if (sport == MSDP_PORT || dport == MSDP_PORT) {
-                msdp_print(bp, length);
+                msdp_print(ndo, bp, length);
         } else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
-                rpki_rtr_print(bp, length);
+                rpki_rtr_print(ndo, bp, length);
         }
         else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
-                ldp_print(bp, length);
+                ldp_print(ndo, bp, length);
         }
         else if ((sport == NFS_PORT || dport == NFS_PORT) &&
-                 length >= 4 && TTEST2(*bp, 4)) {
+                 length >= 4 && ND_TTEST2(*bp, 4)) {
                 /*
                  * If data present, header length valid, and NFS port used,
                  * assume NFS.
                  * Pass offset of data plus 4 bytes for RPC TCP msg length
                  * to NFS print routines.
                  */
-                u_int32_t fraglen;
+                uint32_t fraglen;
                 register struct sunrpc_msg *rp;
                 enum sunrpc_msg_type direction;
 
@@ -719,16 +736,16 @@
                 if (fraglen > (length) - 4)
                         fraglen = (length) - 4;
                 rp = (struct sunrpc_msg *)(bp + 4);
-                if (TTEST(rp->rm_direction)) {
+                if (ND_TTEST(rp->rm_direction)) {
                         direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
                         if (dport == NFS_PORT && direction == SUNRPC_CALL) {
-                                (void)printf(": NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid));
-                                nfsreq_print_noaddr((u_char *)rp, fraglen, (u_char *)ip);
+                                ND_PRINT((ndo, ": NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+                                nfsreq_print_noaddr(ndo, (u_char *)rp, fraglen, (u_char *)ip);
                                 return;
                         }
                         if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
-                                (void)printf(": NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid));
-                                nfsreply_print_noaddr((u_char *)rp, fraglen, (u_char *)ip);
+                                ND_PRINT((ndo, ": NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+                                nfsreply_print_noaddr(ndo, (u_char *)rp, fraglen, (u_char *)ip);
                                 return;
                         }
                 }
@@ -736,14 +753,14 @@
 
         return;
  bad:
-        fputs("[bad opt]", stdout);
+        ND_PRINT((ndo, "[bad opt]"));
         if (ch != '\0')
-                putchar('>');
+                ND_PRINT((ndo, ">"));
         return;
  trunc:
-        fputs("[|tcp]", stdout);
+        ND_PRINT((ndo, "[|tcp]"));
         if (ch != '\0')
-                putchar('>');
+                ND_PRINT((ndo, ">"));
 }
 
 /*
@@ -762,52 +779,51 @@
  */
 
 static void
-print_tcp_rst_data(register const u_char *sp, u_int length)
+print_tcp_rst_data(netdissect_options *ndo,
+                   register const u_char *sp, u_int length)
 {
         int c;
 
-        if (TTEST2(*sp, length))
-                printf(" [RST");
-        else
-                printf(" [!RST");
+        ND_PRINT((ndo, ND_TTEST2(*sp, length) ? " [RST" : " [!RST"));
         if (length > MAX_RST_DATA_LEN) {
                 length = MAX_RST_DATA_LEN;	/* can use -X for longer */
-                putchar('+');			/* indicate we truncate */
+                ND_PRINT((ndo, "+"));			/* indicate we truncate */
         }
-        putchar(' ');
-        while (length-- && sp <= snapend) {
+        ND_PRINT((ndo, " "));
+        while (length-- && sp <= ndo->ndo_snapend) {
                 c = *sp++;
-                safeputchar(c);
+                safeputchar(ndo, c);
         }
-        putchar(']');
+        ND_PRINT((ndo, "]"));
 }
 
 #ifdef HAVE_LIBCRYPTO
 USES_APPLE_DEPRECATED_API
 static int
-tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
+tcp_verify_signature(netdissect_options *ndo,
+                     const struct ip *ip, const struct tcphdr *tp,
                      const u_char *data, int length, const u_char *rcvsig)
 {
         struct tcphdr tp1;
         u_char sig[TCP_SIGLEN];
         char zero_proto = 0;
         MD5_CTX ctx;
-        u_int16_t savecsum, tlen;
+        uint16_t savecsum, tlen;
 #ifdef INET6
         struct ip6_hdr *ip6;
-        u_int32_t len32;
-        u_int8_t nxt;
+        uint32_t len32;
+        uint8_t nxt;
 #endif
 
-	if (data + length > snapend) {
-		printf("snaplen too short, ");
+	if (data + length > ndo->ndo_snapend) {
+		ND_PRINT((ndo, "snaplen too short, "));
 		return (CANT_CHECK_SIGNATURE);
 	}
 
         tp1 = *tp;
 
-        if (sigsecret == NULL) {
-		printf("shared secret not supplied with -M, ");
+        if (ndo->ndo_sigsecret == NULL) {
+		ND_PRINT((ndo, "shared secret not supplied with -M, "));
                 return (CANT_CHECK_SIGNATURE);
         }
 
@@ -839,9 +855,9 @@
 #endif
         } else {
 #ifdef INET6
-		printf("IP version not 4 or 6, ");
+		ND_PRINT((ndo, "IP version not 4 or 6, "));
 #else
-		printf("IP version not 4, ");
+		ND_PRINT((ndo, "IP version not 4, "));
 #endif
                 return (CANT_CHECK_SIGNATURE);
         }
@@ -862,7 +878,7 @@
         /*
          * Step 4: Update MD5 hash with shared secret.
          */
-        MD5_Update(&ctx, sigsecret, strlen(sigsecret));
+        MD5_Update(&ctx, ndo->ndo_sigsecret, strlen(ndo->ndo_sigsecret));
         MD5_Final(sig, &ctx);
 
         if (memcmp(rcvsig, sig, TCP_SIGLEN) == 0)
diff --git a/print-telnet.c b/print-telnet.c
index 4911e5c..fa59b1f 100644
--- a/print-telnet.c
+++ b/print-telnet.c
@@ -45,27 +45,304 @@
  *      are preserved in all copies.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.24 2003-12-29 11:05:10 hannes Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
 
 #include "interface.h"
-#include "addrtoname.h"
 
 #define TELCMDS
 #define TELOPTS
-#include "telnet.h"
+
+/*	NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp 	*/
+
+/*
+ * Definitions for the TELNET protocol.
+ */
+#define	IAC	255		/* interpret as command: */
+#define	DONT	254		/* you are not to use option */
+#define	DO	253		/* please, you use option */
+#define	WONT	252		/* I won't use option */
+#define	WILL	251		/* I will use option */
+#define	SB	250		/* interpret as subnegotiation */
+#define	GA	249		/* you may reverse the line */
+#define	EL	248		/* erase the current line */
+#define	EC	247		/* erase the current character */
+#define	AYT	246		/* are you there */
+#define	AO	245		/* abort output--but let prog finish */
+#define	IP	244		/* interrupt process--permanently */
+#define	BREAK	243		/* break */
+#define	DM	242		/* data mark--for connect. cleaning */
+#define	NOP	241		/* nop */
+#define	SE	240		/* end sub negotiation */
+#define EOR     239             /* end of record (transparent mode) */
+#define	ABORT	238		/* Abort process */
+#define	SUSP	237		/* Suspend process */
+#define	xEOF	236		/* End of file: EOF is already used... */
+
+#define SYNCH	242		/* for telfunc calls */
+
+#ifdef TELCMDS
+const char *telcmds[] = {
+	"EOF", "SUSP", "ABORT", "EOR",
+	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
+	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
+};
+#else
+extern char *telcmds[];
+#endif
+
+#define	TELCMD_FIRST	xEOF
+#define	TELCMD_LAST	IAC
+#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
+			 (unsigned int)(x) >= TELCMD_FIRST)
+#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
+
+/* telnet options */
+#define TELOPT_BINARY	0	/* 8-bit data path */
+#define TELOPT_ECHO	1	/* echo */
+#define	TELOPT_RCP	2	/* prepare to reconnect */
+#define	TELOPT_SGA	3	/* suppress go ahead */
+#define	TELOPT_NAMS	4	/* approximate message size */
+#define	TELOPT_STATUS	5	/* give status */
+#define	TELOPT_TM	6	/* timing mark */
+#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
+#define TELOPT_NAOL 	8	/* negotiate about output line width */
+#define TELOPT_NAOP 	9	/* negotiate about output page size */
+#define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
+#define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
+#define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
+#define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
+#define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
+#define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
+#define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
+#define TELOPT_XASCII	17	/* extended ascic character set */
+#define	TELOPT_LOGOUT	18	/* force logout */
+#define	TELOPT_BM	19	/* byte macro */
+#define	TELOPT_DET	20	/* data entry terminal */
+#define	TELOPT_SUPDUP	21	/* supdup protocol */
+#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
+#define	TELOPT_SNDLOC	23	/* send location */
+#define	TELOPT_TTYPE	24	/* terminal type */
+#define	TELOPT_EOR	25	/* end or record */
+#define	TELOPT_TUID	26	/* TACACS user identification */
+#define	TELOPT_OUTMRK	27	/* output marking */
+#define	TELOPT_TTYLOC	28	/* terminal location number */
+#define	TELOPT_3270REGIME 29	/* 3270 regime */
+#define	TELOPT_X3PAD	30	/* X.3 PAD */
+#define	TELOPT_NAWS	31	/* window size */
+#define	TELOPT_TSPEED	32	/* terminal speed */
+#define	TELOPT_LFLOW	33	/* remote flow control */
+#define TELOPT_LINEMODE	34	/* Linemode option */
+#define TELOPT_XDISPLOC	35	/* X Display Location */
+#define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
+#define	TELOPT_AUTHENTICATION 37/* Authenticate */
+#define	TELOPT_ENCRYPT	38	/* Encryption option */
+#define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
+#define	TELOPT_EXOPL	255	/* extended-options-list */
+
+
+#define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
+#ifdef TELOPTS
+const char *telopts[NTELOPTS+1] = {
+	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
+	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
+	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
+	"ENCRYPT", "NEW-ENVIRON",
+	0,
+};
+#define	TELOPT_FIRST	TELOPT_BINARY
+#define	TELOPT_LAST	TELOPT_NEW_ENVIRON
+#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
+#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
+#endif
+
+/* sub-option qualifiers */
+#define	TELQUAL_IS	0	/* option is... */
+#define	TELQUAL_SEND	1	/* send option */
+#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
+#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
+#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
+
+#define	LFLOW_OFF		0	/* Disable remote flow control */
+#define	LFLOW_ON		1	/* Enable remote flow control */
+#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
+#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
+
+/*
+ * LINEMODE suboptions
+ */
+
+#define	LM_MODE		1
+#define	LM_FORWARDMASK	2
+#define	LM_SLC		3
+
+#define	MODE_EDIT	0x01
+#define	MODE_TRAPSIG	0x02
+#define	MODE_ACK	0x04
+#define MODE_SOFT_TAB	0x08
+#define MODE_LIT_ECHO	0x10
+
+#define	MODE_MASK	0x1f
+
+#define	SLC_SYNCH	1
+#define	SLC_BRK		2
+#define	SLC_IP		3
+#define	SLC_AO		4
+#define	SLC_AYT		5
+#define	SLC_EOR		6
+#define	SLC_ABORT	7
+#define	SLC_EOF		8
+#define	SLC_SUSP	9
+#define	SLC_EC		10
+#define	SLC_EL		11
+#define	SLC_EW		12
+#define	SLC_RP		13
+#define	SLC_LNEXT	14
+#define	SLC_XON		15
+#define	SLC_XOFF	16
+#define	SLC_FORW1	17
+#define	SLC_FORW2	18
+#define	SLC_MCL         19
+#define	SLC_MCR         20
+#define	SLC_MCWL        21
+#define	SLC_MCWR        22
+#define	SLC_MCBOL       23
+#define	SLC_MCEOL       24
+#define	SLC_INSRT       25
+#define	SLC_OVER        26
+#define	SLC_ECR         27
+#define	SLC_EWR         28
+#define	SLC_EBOL        29
+#define	SLC_EEOL        30
+
+#define	NSLC		30
+
+/*
+ * For backwards compatibility, we define SLC_NAMES to be the
+ * list of names if SLC_NAMES is not defined.
+ */
+#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
+			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
+			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
+			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
+			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
+			"EBOL", "EEOL",					\
+			0,
+
+#ifdef	SLC_NAMES
+const char *slc_names[] = {
+	SLC_NAMELIST
+};
+#else
+extern char *slc_names[];
+#define	SLC_NAMES SLC_NAMELIST
+#endif
+
+#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
+#define SLC_NAME(x)	slc_names[x]
+
+#define	SLC_NOSUPPORT	0
+#define	SLC_CANTCHANGE	1
+#define	SLC_VARIABLE	2
+#define	SLC_DEFAULT	3
+#define	SLC_LEVELBITS	0x03
+
+#define	SLC_FUNC	0
+#define	SLC_FLAGS	1
+#define	SLC_VALUE	2
+
+#define	SLC_ACK		0x80
+#define	SLC_FLUSHIN	0x40
+#define	SLC_FLUSHOUT	0x20
+
+#define	OLD_ENV_VAR	1
+#define	OLD_ENV_VALUE	0
+#define	NEW_ENV_VAR	0
+#define	NEW_ENV_VALUE	1
+#define	ENV_ESC		2
+#define ENV_USERVAR	3
+
+/*
+ * AUTHENTICATION suboptions
+ */
+
+/*
+ * Who is authenticating who ...
+ */
+#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
+#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
+#define	AUTH_WHO_MASK		1
+
+#define	AUTHTYPE_NULL		0
+#define	AUTHTYPE_KERBEROS_V4	1
+#define	AUTHTYPE_KERBEROS_V5	2
+#define	AUTHTYPE_SPX		3
+#define	AUTHTYPE_MINK		4
+#define	AUTHTYPE_CNT		5
+
+#define	AUTHTYPE_TEST		99
+
+#ifdef	AUTH_NAMES
+const char *authtype_names[] = {
+	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
+#define	AUTHTYPE_NAME(x)	authtype_names[x]
+
+/*
+ * ENCRYPTion suboptions
+ */
+#define	ENCRYPT_IS		0	/* I pick encryption type ... */
+#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
+#define	ENCRYPT_REPLY		2	/* Initial setup response */
+#define	ENCRYPT_START		3	/* Am starting to send encrypted */
+#define	ENCRYPT_END		4	/* Am ending encrypted */
+#define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
+#define	ENCRYPT_REQEND		6	/* Request you send encrypting */
+#define	ENCRYPT_ENC_KEYID	7
+#define	ENCRYPT_DEC_KEYID	8
+#define	ENCRYPT_CNT		9
+
+#define	ENCTYPE_ANY		0
+#define	ENCTYPE_DES_CFB64	1
+#define	ENCTYPE_DES_OFB64	2
+#define	ENCTYPE_CNT		3
+
+#ifdef	ENCRYPT_NAMES
+const char *encrypt_names[] = {
+	"IS", "SUPPORT", "REPLY", "START", "END",
+	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+	0,
+};
+const char *enctype_names[] = {
+	"ANY", "DES_CFB64",  "DES_OFB64",  0,
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
+#define	ENCRYPT_NAME(x)		encrypt_names[x]
+
+#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
+#define	ENCTYPE_NAME(x)		enctype_names[x]
 
 /* normal */
 static const char *cmds[] = {
@@ -107,7 +384,7 @@
 
 /* sp points to IAC byte */
 static int
-telnet_parse(const u_char *sp, u_int length, int print)
+telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
 {
 	int i, x;
 	u_int c;
@@ -116,7 +393,7 @@
 	do { \
 		if (length < 1) \
 			goto pktend; \
-		TCHECK(*sp); \
+		ND_TCHECK(*sp); \
 		c = *sp++; \
 		length--; \
 	} while (0)
@@ -129,7 +406,7 @@
 	FETCH(c, sp, length);
 	if (c == IAC) {		/* <IAC><IAC>! */
 		if (print)
-			printf("IAC IAC");
+			ND_PRINT((ndo, "IAC IAC"));
 		goto done;
 	}
 
@@ -147,10 +424,10 @@
 		FETCH(x, sp, length);
 		if (x >= 0 && x < NTELOPTS) {
 			if (print)
-				(void)printf("%s %s", telcmds[i], telopts[x]);
+				ND_PRINT((ndo, "%s %s", telcmds[i], telopts[x]));
 		} else {
 			if (print)
-				(void)printf("%s %#x", telcmds[i], x);
+				ND_PRINT((ndo, "%s %#x", telcmds[i], x));
 		}
 		if (c != SB)
 			break;
@@ -170,47 +447,46 @@
 				break;
 			FETCH(c, sp, length);
 			if (print)
-				(void)printf(" %s", STR_OR_ID(c, authcmd));
+				ND_PRINT((ndo, " %s", STR_OR_ID(c, authcmd)));
 			if (p <= sp)
 				break;
 			FETCH(c, sp, length);
 			if (print)
-				(void)printf(" %s", STR_OR_ID(c, authtype));
+				ND_PRINT((ndo, " %s", STR_OR_ID(c, authtype)));
 			break;
 		case TELOPT_ENCRYPT:
 			if (p <= sp)
 				break;
 			FETCH(c, sp, length);
 			if (print)
-				(void)printf(" %s", STR_OR_ID(c, enccmd));
+				ND_PRINT((ndo, " %s", STR_OR_ID(c, enccmd)));
 			if (p <= sp)
 				break;
 			FETCH(c, sp, length);
 			if (print)
-				(void)printf(" %s", STR_OR_ID(c, enctype));
+				ND_PRINT((ndo, " %s", STR_OR_ID(c, enctype)));
 			break;
 		default:
 			if (p <= sp)
 				break;
 			FETCH(c, sp, length);
 			if (print)
-				(void)printf(" %s", STR_OR_ID(c, cmds));
+				ND_PRINT((ndo, " %s", STR_OR_ID(c, cmds)));
 			break;
 		}
 		while (p > sp) {
 			FETCH(x, sp, length);
 			if (print)
-				(void)printf(" %#x", x);
+				ND_PRINT((ndo, " %#x", x));
 		}
 		/* terminating IAC SE */
 		if (print)
-			(void)printf(" SE");
+			ND_PRINT((ndo, " SE"));
 		sp += 2;
-		length -= 2;
 		break;
 	default:
 		if (print)
-			(void)printf("%s", telcmds[i]);
+			ND_PRINT((ndo, "%s", telcmds[i]));
 		goto done;
 	}
 
@@ -218,14 +494,14 @@
 	return sp - osp;
 
 trunc:
-	(void)printf("[|telnet]");
+	ND_PRINT((ndo, "[|telnet]"));
 pktend:
 	return -1;
 #undef FETCH
 }
 
 void
-telnet_print(const u_char *sp, u_int length)
+telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
 {
 	int first = 1;
 	const u_char *osp;
@@ -234,34 +510,38 @@
 	osp = sp;
 
 	while (length > 0 && *sp == IAC) {
-		l = telnet_parse(sp, length, 0);
+		/*
+		 * Parse the Telnet command without printing it,
+		 * to determine its length.
+		 */
+		l = telnet_parse(ndo, sp, length, 0);
 		if (l < 0)
 			break;
 
 		/*
 		 * now print it
 		 */
-		if (Xflag && 2 < vflag) {
+		if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag) {
 			if (first)
-				printf("\nTelnet:");
-			hex_print_with_offset("\n", sp, l, sp - osp);
+				ND_PRINT((ndo, "\nTelnet:"));
+			hex_print_with_offset(ndo, "\n", sp, l, sp - osp);
 			if (l > 8)
-				printf("\n\t\t\t\t");
+				ND_PRINT((ndo, "\n\t\t\t\t"));
 			else
-				printf("%*s\t", (8 - l) * 3, "");
+				ND_PRINT((ndo, "%*s\t", (8 - l) * 3, ""));
 		} else
-			printf("%s", (first) ? " [telnet " : ", ");
+			ND_PRINT((ndo, "%s", (first) ? " [telnet " : ", "));
 
-		(void)telnet_parse(sp, length, 1);
+		(void)telnet_parse(ndo, sp, length, 1);
 		first = 0;
 
 		sp += l;
 		length -= l;
 	}
 	if (!first) {
-		if (Xflag && 2 < vflag)
-			printf("\n");
+		if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag)
+			ND_PRINT((ndo, "\n"));
 		else
-			printf("]");
+			ND_PRINT((ndo, "]"));
 	}
 }
diff --git a/print-tftp.c b/print-tftp.c
index 62e2c99..9b88e74 100644
--- a/print-tftp.c
+++ b/print-tftp.c
@@ -21,28 +21,60 @@
  * Format and print trivial file transfer protocol packets.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.39 2008-04-11 16:47:38 gianluca Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#ifdef SEGSIZE
-#undef SEGSIZE					/* SINIX sucks */
-#endif
-
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
-#include "addrtoname.h"
 #include "extract.h"
-#include "tftp.h"
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ */
+
+/*
+ * Packet types.
+ */
+#define	RRQ	01			/* read request */
+#define	WRQ	02			/* write request */
+#define	DATA	03			/* data packet */
+#define	ACK	04			/* acknowledgement */
+#define	TFTP_ERROR	05			/* error code */
+#define OACK	06			/* option acknowledgement */
+
+struct	tftphdr {
+	unsigned short	th_opcode;		/* packet type */
+	union {
+		unsigned short	tu_block;	/* block # */
+		unsigned short	tu_code;	/* error code */
+		char	tu_stuff[1];	/* request packet stuff */
+	} th_u;
+	char	th_data[1];		/* data or error string */
+};
+
+#define	th_block	th_u.tu_block
+#define	th_code		th_u.tu_code
+#define	th_stuff	th_u.tu_stuff
+#define	th_msg		th_data
+
+/*
+ * Error codes.
+ */
+#define	EUNDEF		0		/* not defined */
+#define	ENOTFOUND	1		/* file not found */
+#define	EACCESS		2		/* access violation */
+#define	ENOSPACE	3		/* disk full or allocation exceeded */
+#define	EBADOP		4		/* illegal TFTP operation */
+#define	EBADID		5		/* unknown transfer ID */
+#define	EEXISTS		6		/* file already exists */
+#define	ENOUSER		7		/* no such user */
+
+static const char tstr[] = " [|tftp]";
 
 /* op code to string mapping */
 static const struct tok op2str[] = {
@@ -72,24 +104,24 @@
  * Print trivial file transfer program requests
  */
 void
-tftp_print(register const u_char *bp, u_int length)
+tftp_print(netdissect_options *ndo,
+           register const u_char *bp, u_int length)
 {
 	register const struct tftphdr *tp;
 	register const char *cp;
 	register const u_char *p;
 	register int opcode, i;
-	static char tstr[] = " [|tftp]";
 
 	tp = (const struct tftphdr *)bp;
 
 	/* Print length */
-	printf(" %d", length);
+	ND_PRINT((ndo, " %d", length));
 
 	/* Print tftp request type */
-	TCHECK(tp->th_opcode);
+	ND_TCHECK(tp->th_opcode);
 	opcode = EXTRACT_16BITS(&tp->th_opcode);
 	cp = tok2str(op2str, "tftp-#%d", opcode);
-	printf(" %s", cp);
+	ND_PRINT((ndo, " %s", cp));
 	/* Bail if bogus opcode */
 	if (*cp == 't')
 		return;
@@ -100,13 +132,13 @@
 	case WRQ:
 	case OACK:
 		p = (u_char *)tp->th_stuff;
-		putchar(' ');
+		ND_PRINT((ndo, " "));
 		/* Print filename or first option */
 		if (opcode != OACK)
-			putchar('"');
-		i = fn_print(p, snapend);
+			ND_PRINT((ndo, "\""));
+		i = fn_print(ndo, p, ndo->ndo_snapend);
 		if (opcode != OACK)
-			putchar('"');
+			ND_PRINT((ndo, "\""));
 
 		/* Print the mode (RRQ and WRQ only) and any options */
 		while ((p = (const u_char *)strchr((const char *)p, '\0')) != NULL) {
@@ -114,40 +146,40 @@
 				break;
 			p++;
 			if (*p != '\0') {
-				putchar(' ');
-				fn_print(p, snapend);
+				ND_PRINT((ndo, " "));
+				fn_print(ndo, p, ndo->ndo_snapend);
 			}
 		}
-		
+
 		if (i)
 			goto trunc;
 		break;
 
 	case ACK:
 	case DATA:
-		TCHECK(tp->th_block);
-		printf(" block %d", EXTRACT_16BITS(&tp->th_block));
+		ND_TCHECK(tp->th_block);
+		ND_PRINT((ndo, " block %d", EXTRACT_16BITS(&tp->th_block)));
 		break;
 
 	case TFTP_ERROR:
 		/* Print error code string */
-		TCHECK(tp->th_code);
-		printf(" %s \"", tok2str(err2str, "tftp-err-#%d \"",
-				       EXTRACT_16BITS(&tp->th_code)));
+		ND_TCHECK(tp->th_code);
+		ND_PRINT((ndo, " %s \"", tok2str(err2str, "tftp-err-#%d \"",
+				       EXTRACT_16BITS(&tp->th_code))));
 		/* Print error message string */
-		i = fn_print((const u_char *)tp->th_data, snapend);
-		putchar('"');
+		i = fn_print(ndo, (const u_char *)tp->th_data, ndo->ndo_snapend);
+		ND_PRINT((ndo, "\""));
 		if (i)
 			goto trunc;
 		break;
 
 	default:
 		/* We shouldn't get here */
-		printf("(unknown #%d)", opcode);
+		ND_PRINT((ndo, "(unknown #%d)", opcode));
 		break;
 	}
 	return;
 trunc:
-	fputs(tstr, stdout);
+	ND_PRINT((ndo, "%s", tstr));
 	return;
 }
diff --git a/print-timed.c b/print-timed.c
index 55fbb39..5830bc7 100644
--- a/print-timed.c
+++ b/print-timed.c
@@ -19,24 +19,72 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.9 2003-11-16 09:36:40 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "timed.h"
 #include "interface.h"
 #include "extract.h"
 
+/*
+ * Time Synchronization Protocol
+ */
+
+struct tsp_timeval {
+	uint32_t	tv_sec;
+	uint32_t	tv_usec;
+};
+
+struct tsp {
+	uint8_t		tsp_type;
+	uint8_t		tsp_vers;
+	uint16_t	tsp_seq;
+	union {
+		struct tsp_timeval tspu_time;
+		int8_t tspu_hopcnt;
+	} tsp_u;
+	int8_t tsp_name[256];
+};
+
+#define	tsp_time	tsp_u.tspu_time
+#define	tsp_hopcnt	tsp_u.tspu_hopcnt
+
+/*
+ * Command types.
+ */
+#define	TSP_ANY			0	/* match any types */
+#define	TSP_ADJTIME		1	/* send adjtime */
+#define	TSP_ACK			2	/* generic acknowledgement */
+#define	TSP_MASTERREQ		3	/* ask for master's name */
+#define	TSP_MASTERACK		4	/* acknowledge master request */
+#define	TSP_SETTIME		5	/* send network time */
+#define	TSP_MASTERUP		6	/* inform slaves that master is up */
+#define	TSP_SLAVEUP		7	/* slave is up but not polled */
+#define	TSP_ELECTION		8	/* advance candidature for master */
+#define	TSP_ACCEPT		9	/* support candidature of master */
+#define	TSP_REFUSE		10	/* reject candidature of master */
+#define	TSP_CONFLICT		11	/* two or more masters present */
+#define	TSP_RESOLVE		12	/* masters' conflict resolution */
+#define	TSP_QUIT		13	/* reject candidature if master is up */
+#define	TSP_DATE		14	/* reset the time (date command) */
+#define	TSP_DATEREQ		15	/* remote request to reset the time */
+#define	TSP_DATEACK		16	/* acknowledge time setting  */
+#define	TSP_TRACEON		17	/* turn tracing on */
+#define	TSP_TRACEOFF		18	/* turn tracing off */
+#define	TSP_MSITE		19	/* find out master's site */
+#define	TSP_MSITEREQ		20	/* remote master's site request */
+#define	TSP_TEST		21	/* for testing election algo */
+#define	TSP_SETDATE		22	/* New from date command */
+#define	TSP_SETDATEREQ		23	/* New remote for above */
+#define	TSP_LOOP		24	/* loop detection packet */
+
+#define	TSPTYPENUMBER		25
+
+static const char tstr[] = "[|timed]";
+
 static const char *tsptype[TSPTYPENUMBER] =
   { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
   "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
@@ -44,68 +92,56 @@
   "TEST", "SETDATE", "SETDATEREQ", "LOOP" };
 
 void
-timed_print(register const u_char *bp)
+timed_print(netdissect_options *ndo,
+            register const u_char *bp)
 {
-#define endof(x) ((u_char *)&(x) + sizeof (x))
 	struct tsp *tsp = (struct tsp *)bp;
 	long sec, usec;
-	const u_char *end;
 
-	if (endof(tsp->tsp_type) > snapend) {
-		fputs("[|timed]", stdout);
-		return;
-	}
+	ND_TCHECK(tsp->tsp_type);
 	if (tsp->tsp_type < TSPTYPENUMBER)
-		printf("TSP_%s", tsptype[tsp->tsp_type]);
+		ND_PRINT((ndo, "TSP_%s", tsptype[tsp->tsp_type]));
 	else
-		printf("(tsp_type %#x)", tsp->tsp_type);
+		ND_PRINT((ndo, "(tsp_type %#x)", tsp->tsp_type));
 
-	if (endof(tsp->tsp_vers) > snapend) {
-		fputs(" [|timed]", stdout);
-		return;
-	}
-	printf(" vers %d", tsp->tsp_vers);
+	ND_TCHECK(tsp->tsp_vers);
+	ND_PRINT((ndo, " vers %u", tsp->tsp_vers));
 
-	if (endof(tsp->tsp_seq) > snapend) {
-		fputs(" [|timed]", stdout);
-		return;
-	}
-	printf(" seq %d", tsp->tsp_seq);
+	ND_TCHECK(tsp->tsp_seq);
+	ND_PRINT((ndo, " seq %u", tsp->tsp_seq));
 
-	if (tsp->tsp_type == TSP_LOOP) {
-		if (endof(tsp->tsp_hopcnt) > snapend) {
-			fputs(" [|timed]", stdout);
-			return;
-		}
-		printf(" hopcnt %d", tsp->tsp_hopcnt);
-	} else if (tsp->tsp_type == TSP_SETTIME ||
-	  tsp->tsp_type == TSP_ADJTIME ||
-	  tsp->tsp_type == TSP_SETDATE ||
-	  tsp->tsp_type == TSP_SETDATEREQ) {
-		if (endof(tsp->tsp_time) > snapend) {
-			fputs(" [|timed]", stdout);
-			return;
-		}
+	switch (tsp->tsp_type) {
+	case TSP_LOOP:
+		ND_TCHECK(tsp->tsp_hopcnt);
+		ND_PRINT((ndo, " hopcnt %u", tsp->tsp_hopcnt));
+		break;
+	case TSP_SETTIME:
+	case TSP_ADJTIME:
+	case TSP_SETDATE:
+	case TSP_SETDATEREQ:
+		ND_TCHECK(tsp->tsp_time);
 		sec = EXTRACT_32BITS(&tsp->tsp_time.tv_sec);
 		usec = EXTRACT_32BITS(&tsp->tsp_time.tv_usec);
+		/* XXX The comparison below is always false? */
 		if (usec < 0)
 			/* corrupt, skip the rest of the packet */
 			return;
-		fputs(" time ", stdout);
+		ND_PRINT((ndo, " time "));
 		if (sec < 0 && usec != 0) {
 			sec++;
 			if (sec == 0)
-				fputc('-', stdout);
+				ND_PRINT((ndo, "-"));
 			usec = 1000000 - usec;
 		}
-		printf("%ld.%06ld", sec, usec);
+		ND_PRINT((ndo, "%ld.%06ld", sec, usec));
+		break;
 	}
+	ND_TCHECK(tsp->tsp_name);
+	ND_PRINT((ndo, " name "));
+	if (fn_print(ndo, (u_char *)tsp->tsp_name, (u_char *)tsp->tsp_name + sizeof(tsp->tsp_name)))
+		goto trunc;
+	return;
 
-	end = memchr(tsp->tsp_name, '\0', snapend - (u_char *)tsp->tsp_name);
-	if (end == NULL)
-		fputs(" [|timed]", stdout);
-	else {
-		fputs(" name ", stdout);
-		fwrite(tsp->tsp_name, end - (u_char *)tsp->tsp_name, 1, stdout);
-	}
+trunc:
+	ND_PRINT((ndo, " %s", tstr));
 }
diff --git a/print-tipc.c b/print-tipc.c
index 8f2f769..b883fba 100644
--- a/print-tipc.c
+++ b/print-tipc.c
@@ -19,26 +19,20 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "netdissect.h"
-#include "addrtoname.h"
+#include "interface.h"
 #include "ether.h"
 #include "ethertype.h"
 #include "extract.h"			/* must come after interface.h */
 
+static const char tstr[] = "[|TIPC]";
+
 /*
  * Transparent Inter-Process Communication (TIPC) protocol.
  *
@@ -69,8 +63,8 @@
 #define TIPC_NODE(addr)		(((addr) >> 0) & 0xFFF)
 
 struct tipc_pkthdr {
-	u_int32_t w0;
-	u_int32_t w1;
+	uint32_t w0;
+	uint32_t w1;
 };
 
 #define TIPC_VER(w0)		(((w0) >> 29) & 0x07)
@@ -113,30 +107,30 @@
 };
 
 struct payload_tipc_pkthdr {
-	u_int32_t w0;
-	u_int32_t w1;
-	u_int32_t w2;
-	u_int32_t prev_node;
-	u_int32_t orig_port;
-	u_int32_t dest_port;
-	u_int32_t orig_node;
-	u_int32_t dest_node;
-	u_int32_t name_type;
-	u_int32_t w9;
-	u_int32_t wA;
+	uint32_t w0;
+	uint32_t w1;
+	uint32_t w2;
+	uint32_t prev_node;
+	uint32_t orig_port;
+	uint32_t dest_port;
+	uint32_t orig_node;
+	uint32_t dest_node;
+	uint32_t name_type;
+	uint32_t w9;
+	uint32_t wA;
 };
 
 struct  internal_tipc_pkthdr {
-	u_int32_t w0;
-	u_int32_t w1;
-	u_int32_t w2;
-	u_int32_t prev_node;
-	u_int32_t w4;
-	u_int32_t w5;
-	u_int32_t orig_node;
-	u_int32_t dest_node;
-	u_int32_t trans_seq;
-	u_int32_t w9;
+	uint32_t w0;
+	uint32_t w1;
+	uint32_t w2;
+	uint32_t prev_node;
+	uint32_t w4;
+	uint32_t w5;
+	uint32_t orig_node;
+	uint32_t dest_node;
+	uint32_t trans_seq;
+	uint32_t w9;
 };
 
 #define TIPC_SEQ_GAP(w1)	(((w1) >> 16) & 0x1FFF)
@@ -149,13 +143,13 @@
 #define TIPC_LINK_TOL(w9)	(((w9) >> 0) & 0xFFFF)
 
 struct link_conf_tipc_pkthdr {
-	u_int32_t w0;
-	u_int32_t w1;
-	u_int32_t dest_domain;
-	u_int32_t prev_node;
-	u_int32_t ntwrk_id;
-	u_int32_t w5;
-	u_int8_t media_address[16];
+	uint32_t w0;
+	uint32_t w1;
+	uint32_t dest_domain;
+	uint32_t prev_node;
+	uint32_t ntwrk_id;
+	uint32_t w5;
+	uint8_t media_address[16];
 };
 
 #define TIPC_NODE_SIG(w1)	(((w1) >> 0) & 0xFFFF)
@@ -164,7 +158,7 @@
 static void
 print_payload(netdissect_options *ndo, const struct payload_tipc_pkthdr *ap)
 {
-	u_int32_t w0, w1, w2;
+	uint32_t w0, w1, w2;
 	u_int user;
 	u_int hsize;
 	u_int msize;
@@ -223,13 +217,13 @@
 	return;
 
 trunc:
-	ND_PRINT((ndo, "[|TIPC]"));
+	ND_PRINT((ndo, "%s", tstr));
 }
-	 
+
 static void
 print_internal(netdissect_options *ndo, const struct internal_tipc_pkthdr *ap)
 {
-	u_int32_t w0, w1, w2, w4, w5, w9;
+	uint32_t w0, w1, w2, w4, w5, w9;
 	u_int user;
 	u_int hsize;
 	u_int msize;
@@ -291,13 +285,13 @@
 	return;
 
 trunc:
-	ND_PRINT((ndo, "[|TIPC]"));
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
 print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
 {
-	u_int32_t w0, w1, w5;
+	uint32_t w0, w1, w5;
 	u_int user;
 	u_int hsize;
 	u_int msize;
@@ -315,7 +309,6 @@
 	msize = TIPC_MSIZE(w0);
 	w1 = EXTRACT_32BITS(&ap->w1);
 	mtype = TIPC_MTYPE(w1);
-	prev_node = EXTRACT_32BITS(&ap->prev_node);
 	dest_domain = EXTRACT_32BITS(&ap->dest_domain);
 	prev_node = EXTRACT_32BITS(&ap->prev_node);
 
@@ -338,7 +331,7 @@
 	return;
 
 trunc:
-	ND_PRINT((ndo, "[|TIPC]"));
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 void
@@ -346,7 +339,7 @@
     u_int caplen _U_)
 {
 	const struct tipc_pkthdr *ap;
-	u_int32_t w0;
+	uint32_t w0;
 	u_int user;
 
 	ap = (struct tipc_pkthdr *)bp;
@@ -363,7 +356,7 @@
 		case TIPC_USER_NAME_DISTRIBUTOR:
 		case TIPC_USER_CONN_MANAGER:
 			print_payload(ndo, (struct payload_tipc_pkthdr *)bp);
-			break;			 
+			break;
 
 		case TIPC_USER_LINK_CONFIG:
 			print_link_conf(ndo, (struct link_conf_tipc_pkthdr *)bp);
@@ -381,7 +374,7 @@
 	return;
 
 trunc:
-	ND_PRINT((ndo, "[|TIPC]"));
+	ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
diff --git a/print-token.c b/print-token.c
index 4f8422b..b88bcf7 100644
--- a/print-token.c
+++ b/print-token.c
@@ -23,28 +23,74 @@
  * Further tweaked to more closely resemble print-fddi.c
  *	Guy Harris <guy@alum.mit.edu>
  */
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $";
-#endif
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ethertype.h"
-
 #include "ether.h"
-#include "token.h"
+
+/*
+ * Copyright (c) 1998, Larry Lile
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 THE AUTHOR 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.
+ *
+ */
+
+#define TOKEN_HDRLEN		14
+#define TOKEN_RING_MAC_LEN	6
+#define ROUTING_SEGMENT_MAX	16
+#define IS_SOURCE_ROUTED(trp)	((trp)->token_shost[0] & 0x80)
+#define FRAME_TYPE(trp)		(((trp)->token_fc & 0xC0) >> 6)
+#define TOKEN_FC_LLC		1
+
+#define BROADCAST(trp)		((EXTRACT_16BITS(&(trp)->token_rcf) & 0xE000) >> 13)
+#define RIF_LENGTH(trp)		((EXTRACT_16BITS(&(trp)->token_rcf) & 0x1f00) >> 8)
+#define DIRECTION(trp)		((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0080) >> 7)
+#define LARGEST_FRAME(trp)	((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0070) >> 4)
+#define RING_NUMBER(trp, x)	((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0xfff0) >> 4)
+#define BRIDGE_NUMBER(trp, x)	((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0x000f))
+#define SEGMENT_COUNT(trp)	((int)((RIF_LENGTH(trp) - 2) / 2))
+
+struct token_header {
+	uint8_t  token_ac;
+	uint8_t  token_fc;
+	uint8_t  token_dhost[TOKEN_RING_MAC_LEN];
+	uint8_t  token_shost[TOKEN_RING_MAC_LEN];
+	uint16_t token_rcf;
+	uint16_t token_rseg[ROUTING_SEGMENT_MAX];
+};
+
+static const char tstr[] = "[|token-ring]";
 
 /* Extract src, dst addresses */
 static inline void
@@ -58,22 +104,23 @@
  * Print the TR MAC header
  */
 static inline void
-token_hdr_print(register const struct token_header *trp, register u_int length,
-	   register const u_char *fsrc, register const u_char *fdst)
+token_hdr_print(netdissect_options *ndo,
+                register const struct token_header *trp, register u_int length,
+                register const u_char *fsrc, register const u_char *fdst)
 {
 	const char *srcname, *dstname;
 
-	srcname = etheraddr_string(fsrc);
-	dstname = etheraddr_string(fdst);
+	srcname = etheraddr_string(ndo, fsrc);
+	dstname = etheraddr_string(ndo, fdst);
 
-	if (vflag)
-		(void) printf("%02x %02x %s %s %d: ",
+	if (ndo->ndo_vflag)
+		ND_PRINT((ndo, "%02x %02x %s %s %d: ",
 		       trp->token_ac,
 		       trp->token_fc,
 		       srcname, dstname,
-		       length);
+		       length));
 	else
-		printf("%s %s %d: ", srcname, dstname, length);
+		ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
 }
 
 static const char *broadcast_indicator[] = {
@@ -99,7 +146,7 @@
 };
 
 u_int
-token_print(const u_char *p, u_int length, u_int caplen)
+token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
 	const struct token_header *trp;
 	u_short extracted_ethertype;
@@ -110,7 +157,7 @@
 	trp = (const struct token_header *)p;
 
 	if (caplen < TOKEN_HDRLEN) {
-		printf("[|token-ring]");
+		ND_PRINT((ndo, "%s", tstr));
 		return hdr_len;
 	}
 
@@ -124,36 +171,36 @@
 		/* Clear source-routed bit */
 		*ESRC(&ehdr) &= 0x7f;
 
-		if (eflag)
-			token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+		if (ndo->ndo_eflag)
+			token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
 
 		if (caplen < TOKEN_HDRLEN + 2) {
-			printf("[|token-ring]");
+			ND_PRINT((ndo, "%s", tstr));
 			return hdr_len;
 		}
 		route_len = RIF_LENGTH(trp);
 		hdr_len += route_len;
 		if (caplen < hdr_len) {
-			printf("[|token-ring]");
+			ND_PRINT((ndo, "%s", tstr));
 			return hdr_len;
 		}
-		if (vflag) {
-			printf("%s ", broadcast_indicator[BROADCAST(trp)]);
-			printf("%s", direction[DIRECTION(trp)]);
+		if (ndo->ndo_vflag) {
+			ND_PRINT((ndo, "%s ", broadcast_indicator[BROADCAST(trp)]));
+			ND_PRINT((ndo, "%s", direction[DIRECTION(trp)]));
 
 			for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
-				printf(" [%d:%d]", RING_NUMBER(trp, seg),
-				    BRIDGE_NUMBER(trp, seg));
+				ND_PRINT((ndo, " [%d:%d]", RING_NUMBER(trp, seg),
+				    BRIDGE_NUMBER(trp, seg)));
 		} else {
-			printf("rt = %x", EXTRACT_16BITS(&trp->token_rcf));
+			ND_PRINT((ndo, "rt = %x", EXTRACT_16BITS(&trp->token_rcf)));
 
 			for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
-				printf(":%x", EXTRACT_16BITS(&trp->token_rseg[seg]));
+				ND_PRINT((ndo, ":%x", EXTRACT_16BITS(&trp->token_rseg[seg])));
 		}
-		printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
+		ND_PRINT((ndo, " (%s) ", largest_frame[LARGEST_FRAME(trp)]));
 	} else {
-		if (eflag)
-			token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+		if (ndo->ndo_eflag)
+			token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
 	}
 
 	/* Skip over token ring MAC header and routing information */
@@ -164,28 +211,28 @@
 	/* Frame Control field determines interpretation of packet */
 	if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
 		/* Try to print the LLC-layer header & higher layers */
-		if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+		if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
 		    &extracted_ethertype) == 0) {
 			/* ether_type not known, print raw packet */
-			if (!eflag)
-				token_hdr_print(trp,
+			if (!ndo->ndo_eflag)
+				token_hdr_print(ndo, trp,
 				    length + TOKEN_HDRLEN + route_len,
 				    ESRC(&ehdr), EDST(&ehdr));
 			if (extracted_ethertype) {
-				printf("(LLC %s) ",
-			etherproto_string(htons(extracted_ethertype)));
+				ND_PRINT((ndo, "(LLC %s) ",
+			etherproto_string(htons(extracted_ethertype))));
 			}
-			if (!suppress_default_print)
-				default_print(p, caplen);
+			if (!ndo->ndo_suppress_default_print)
+				ND_DEFAULTPRINT(p, caplen);
 		}
 	} else {
 		/* Some kinds of TR packet we cannot handle intelligently */
 		/* XXX - dissect MAC packets if frame type is 0 */
-		if (!eflag)
-			token_hdr_print(trp, length + TOKEN_HDRLEN + route_len,
+		if (!ndo->ndo_eflag)
+			token_hdr_print(ndo, trp, length + TOKEN_HDRLEN + route_len,
 			    ESRC(&ehdr), EDST(&ehdr));
-		if (!suppress_default_print)
-			default_print(p, caplen);
+		if (!ndo->ndo_suppress_default_print)
+			ND_DEFAULTPRINT(p, caplen);
 	}
 	return (hdr_len);
 }
@@ -197,7 +244,7 @@
  * is the number of bytes actually captured.
  */
 u_int
-token_if_print(const struct pcap_pkthdr *h, const u_char *p)
+token_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
-	return (token_print(p, h->len, h->caplen));
+	return (token_print(ndo, p, h->len, h->caplen));
 }
diff --git a/print-udld.c b/print-udld.c
index e8395d0..15e2bf6 100644
--- a/print-udld.c
+++ b/print-udld.c
@@ -12,25 +12,21 @@
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
  *
- * UNIDIRECTIONAL LINK DETECTION (UDLD) as per 
+ * UNIDIRECTIONAL LINK DETECTION (UDLD) as per
  * http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt
  *
  * Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
-#include "addrtoname.h"
-#include "extract.h"		
-#include "nlpid.h"
+#include "extract.h"
 
 #define UDLD_HEADER_LEN			4
 #define UDLD_DEVICE_ID_TLV		0x0001
@@ -68,22 +64,22 @@
 
 /*
  *
- * 0                   1                   2                   3 
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
- * | Ver | Opcode  |     Flags     |           Checksum            | 
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
- * |               List of TLVs (variable length list)             | 
- * |                              ...                              | 
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
+ * 0                   1                   2                   3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Ver | Opcode  |     Flags     |           Checksum            |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |               List of TLVs (variable length list)             |
+ * |                              ...                              |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
  */
 
-#define	UDLD_EXTRACT_VERSION(x) (((x)&0xe0)>>5) 
-#define	UDLD_EXTRACT_OPCODE(x) ((x)&0x1f) 
+#define	UDLD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
+#define	UDLD_EXTRACT_OPCODE(x) ((x)&0x1f)
 
 void
-udld_print (const u_char *pptr, u_int length)
+udld_print (netdissect_options *ndo, const u_char *pptr, u_int length)
 {
     int code, type, len;
     const u_char *tptr;
@@ -91,39 +87,37 @@
     if (length < UDLD_HEADER_LEN)
         goto trunc;
 
-    tptr = pptr; 
+    tptr = pptr;
 
-    if (!TTEST2(*tptr, UDLD_HEADER_LEN))	
-	goto trunc;
+    ND_TCHECK2(*tptr, UDLD_HEADER_LEN);
 
     code = UDLD_EXTRACT_OPCODE(*tptr);
 
-    printf("UDLDv%u, Code %s (%x), Flags [%s] (0x%02x), length %u", 
+    ND_PRINT((ndo, "UDLDv%u, Code %s (%x), Flags [%s] (0x%02x), length %u",
            UDLD_EXTRACT_VERSION(*tptr),
            tok2str(udld_code_values, "Reserved", code),
            code,
            bittok2str(udld_flags_values, "none", *(tptr+1)),
            *(tptr+1),
-           length);
+           length));
 
     /*
      * In non-verbose mode, just print version and opcode type
      */
-    if (vflag < 1) {
+    if (ndo->ndo_vflag < 1) {
 	return;
     }
 
-    printf("\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2));
+    ND_PRINT((ndo, "\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2)));
 
     tptr += UDLD_HEADER_LEN;
 
     while (tptr < (pptr+length)) {
 
-        if (!TTEST2(*tptr, 4)) 
-            goto trunc;
+        ND_TCHECK2(*tptr, 4);
 
 	type = EXTRACT_16BITS(tptr);
-        len  = EXTRACT_16BITS(tptr+2); 
+        len  = EXTRACT_16BITS(tptr+2);
         len -= 4;
         tptr += 4;
 
@@ -132,37 +126,37 @@
             return;
         }
 
-        printf("\n\t%s (0x%04x) TLV, length %u",
+        ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
                tok2str(udld_tlv_values, "Unknown", type),
-               type, len);
+               type, len));
 
         switch (type) {
         case UDLD_DEVICE_ID_TLV:
         case UDLD_PORT_ID_TLV:
         case UDLD_ECHO_TLV:
-        case UDLD_DEVICE_NAME_TLV: 
-            printf(", %s", tptr);
+        case UDLD_DEVICE_NAME_TLV:
+            ND_PRINT((ndo, ", %s", tptr));
             break;
 
-        case UDLD_MESSAGE_INTERVAL_TLV: 
+        case UDLD_MESSAGE_INTERVAL_TLV:
         case UDLD_TIMEOUT_INTERVAL_TLV:
-            printf(", %us", (*tptr));
+            ND_PRINT((ndo, ", %us", (*tptr)));
             break;
 
         case UDLD_SEQ_NUMBER_TLV:
-            printf(", %u", EXTRACT_32BITS(tptr));
+            ND_PRINT((ndo, ", %u", EXTRACT_32BITS(tptr)));
             break;
 
         default:
             break;
-        }	
+        }
         tptr += len;
     }
 
     return;
 
  trunc:
-    printf("[|udld]");
+    ND_PRINT((ndo, "[|udld]"));
 }
 
 /*
diff --git a/print-udp.c b/print-udp.c
index 8148023..c3edf6e 100644
--- a/print-udp.c
+++ b/print-udp.c
@@ -19,24 +19,13 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.142 2007-08-08 17:20:58 hannes Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#ifdef SEGSIZE
-#undef SEGSIZE
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -54,17 +43,16 @@
 
 #include "nameser.h"
 #include "nfs.h"
-#include "bootp.h"
 
 struct rtcphdr {
-	u_int16_t rh_flags;	/* T:2 P:1 CNT:5 PT:8 */
-	u_int16_t rh_len;	/* length of message (in words) */
-	u_int32_t rh_ssrc;	/* synchronization src id */
+	uint16_t rh_flags;	/* T:2 P:1 CNT:5 PT:8 */
+	uint16_t rh_len;	/* length of message (in words) */
+	uint32_t rh_ssrc;	/* synchronization src id */
 };
 
 typedef struct {
-	u_int32_t upper;	/* more significant 32 bits */
-	u_int32_t lower;	/* less significant 32 bits */
+	uint32_t upper;	/* more significant 32 bits */
+	uint32_t lower;	/* less significant 32 bits */
 } ntp64;
 
 /*
@@ -72,9 +60,9 @@
  */
 struct rtcp_sr {
 	ntp64 sr_ntp;		/* 64-bit ntp timestamp */
-	u_int32_t sr_ts;	/* reference media timestamp */
-	u_int32_t sr_np;	/* no. packets sent */
-	u_int32_t sr_nb;	/* no. bytes sent */
+	uint32_t sr_ts;	/* reference media timestamp */
+	uint32_t sr_np;	/* no. packets sent */
+	uint32_t sr_nb;	/* no. bytes sent */
 };
 
 /*
@@ -82,12 +70,12 @@
  * Time stamps are middle 32-bits of ntp timestamp.
  */
 struct rtcp_rr {
-	u_int32_t rr_srcid;	/* sender being reported */
-	u_int32_t rr_nl;	/* no. packets lost */
-	u_int32_t rr_ls;	/* extended last seq number received */
-	u_int32_t rr_dv;	/* jitter (delay variance) */
-	u_int32_t rr_lsr;	/* orig. ts from last rr from this src  */
-	u_int32_t rr_dlsr;	/* time from recpt of last rr to xmit time */
+	uint32_t rr_srcid;	/* sender being reported */
+	uint32_t rr_nl;	/* no. packets lost */
+	uint32_t rr_ls;	/* extended last seq number received */
+	uint32_t rr_dv;	/* jitter (delay variance) */
+	uint32_t rr_lsr;	/* orig. ts from last rr from this src  */
+	uint32_t rr_dlsr;	/* time from recpt of last rr to xmit time */
 };
 
 /*XXX*/
@@ -106,39 +94,40 @@
 #define RTCP_PT_APP	204
 
 static void
-vat_print(const void *hdr, register const struct udphdr *up)
+vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr *up)
 {
 	/* vat/vt audio */
-	u_int ts = *(u_int16_t *)hdr;
+	u_int ts = *(uint16_t *)hdr;
 	if ((ts & 0xf060) != 0) {
 		/* probably vt */
-		(void)printf("udp/vt %u %d / %d",
-			     (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
-			     ts & 0x3ff, ts >> 10);
+		ND_PRINT((ndo, "udp/vt %u %d / %d",
+			     (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
+			     ts & 0x3ff, ts >> 10));
 	} else {
 		/* probably vat */
-		u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
-		u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
-		printf("udp/vat %u c%d %u%s",
-			(u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
+		uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+		uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+		ND_PRINT((ndo, "udp/vat %u c%d %u%s",
+			(uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
 			i0 & 0xffff,
-			i1, i0 & 0x800000? "*" : "");
+			i1, i0 & 0x800000? "*" : ""));
 		/* audio format */
 		if (i0 & 0x1f0000)
-			printf(" f%d", (i0 >> 16) & 0x1f);
+			ND_PRINT((ndo, " f%d", (i0 >> 16) & 0x1f));
 		if (i0 & 0x3f000000)
-			printf(" s%d", (i0 >> 24) & 0x3f);
+			ND_PRINT((ndo, " s%d", (i0 >> 24) & 0x3f));
 	}
 }
 
 static void
-rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
+rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
+          register const struct udphdr *up)
 {
 	/* rtp v1 or v2 */
 	u_int *ip = (u_int *)hdr;
 	u_int hasopt, hasext, contype, hasmarker;
-	u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
-	u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+	uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+	uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
 	u_int dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8;
 	const char * ptype;
 
@@ -163,23 +152,23 @@
 		ip += 1;
 		len -= 1;
 	}
-	printf("udp/%s %d c%d %s%s %d %u",
+	ND_PRINT((ndo, "udp/%s %d c%d %s%s %d %u",
 		ptype,
 		dlen,
 		contype,
 		(hasopt || hasext)? "+" : "",
 		hasmarker? "*" : "",
 		i0 & 0xffff,
-		i1);
-	if (vflag) {
-		printf(" %u", EXTRACT_32BITS(&((u_int *)hdr)[2]));
+		i1));
+	if (ndo->ndo_vflag) {
+		ND_PRINT((ndo, " %u", EXTRACT_32BITS(&((u_int *)hdr)[2])));
 		if (hasopt) {
 			u_int i2, optlen;
 			do {
 				i2 = ip[0];
 				optlen = (i2 >> 16) & 0xff;
 				if (optlen == 0 || optlen > len) {
-					printf(" !opt");
+					ND_PRINT((ndo, " !opt"));
 					return;
 				}
 				ip += optlen;
@@ -191,29 +180,29 @@
 			i2 = ip[0];
 			extlen = (i2 & 0xffff) + 1;
 			if (extlen > len) {
-				printf(" !ext");
+				ND_PRINT((ndo, " !ext"));
 				return;
 			}
 			ip += extlen;
 		}
 		if (contype == 0x1f) /*XXX H.261 */
-			printf(" 0x%04x", ip[0] >> 16);
+			ND_PRINT((ndo, " 0x%04x", ip[0] >> 16));
 	}
 }
 
 static const u_char *
-rtcp_print(const u_char *hdr, const u_char *ep)
+rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
 {
 	/* rtp v2 control (rtcp) */
 	struct rtcp_rr *rr = 0;
 	struct rtcp_sr *sr;
 	struct rtcphdr *rh = (struct rtcphdr *)hdr;
 	u_int len;
-	u_int16_t flags;
+	uint16_t flags;
 	int cnt;
 	double ts, dts;
 	if ((u_char *)(rh + 1) > ep) {
-		printf(" [|rtcp]");
+		ND_PRINT((ndo, " [|rtcp]"));
 		return (ep);
 	}
 	len = (EXTRACT_16BITS(&rh->rh_len) + 1) * 4;
@@ -222,85 +211,85 @@
 	switch (flags & 0xff) {
 	case RTCP_PT_SR:
 		sr = (struct rtcp_sr *)(rh + 1);
-		printf(" sr");
+		ND_PRINT((ndo, " sr"));
 		if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
-			printf(" [%d]", len);
-		if (vflag)
-			printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+			ND_PRINT((ndo, " [%d]", len));
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
 		if ((u_char *)(sr + 1) > ep) {
-			printf(" [|rtcp]");
+			ND_PRINT((ndo, " [|rtcp]"));
 			return (ep);
 		}
 		ts = (double)(EXTRACT_32BITS(&sr->sr_ntp.upper)) +
 		    ((double)(EXTRACT_32BITS(&sr->sr_ntp.lower)) /
 		    4294967296.0);
-		printf(" @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
-		    EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb));
+		ND_PRINT((ndo, " @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
+		    EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb)));
 		rr = (struct rtcp_rr *)(sr + 1);
 		break;
 	case RTCP_PT_RR:
-		printf(" rr");
+		ND_PRINT((ndo, " rr"));
 		if (len != cnt * sizeof(*rr) + sizeof(*rh))
-			printf(" [%d]", len);
+			ND_PRINT((ndo, " [%d]", len));
 		rr = (struct rtcp_rr *)(rh + 1);
-		if (vflag)
-			printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
 		break;
 	case RTCP_PT_SDES:
-		printf(" sdes %d", len);
-		if (vflag)
-			printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+		ND_PRINT((ndo, " sdes %d", len));
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
 		cnt = 0;
 		break;
 	case RTCP_PT_BYE:
-		printf(" bye %d", len);
-		if (vflag)
-			printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+		ND_PRINT((ndo, " bye %d", len));
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
 		cnt = 0;
 		break;
 	default:
-		printf(" type-0x%x %d", flags & 0xff, len);
+		ND_PRINT((ndo, " type-0x%x %d", flags & 0xff, len));
 		cnt = 0;
 		break;
 	}
 	if (cnt > 1)
-		printf(" c%d", cnt);
+		ND_PRINT((ndo, " c%d", cnt));
 	while (--cnt >= 0) {
 		if ((u_char *)(rr + 1) > ep) {
-			printf(" [|rtcp]");
+			ND_PRINT((ndo, " [|rtcp]"));
 			return (ep);
 		}
-		if (vflag)
-			printf(" %u", EXTRACT_32BITS(&rr->rr_srcid));
+		if (ndo->ndo_vflag)
+			ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rr->rr_srcid)));
 		ts = (double)(EXTRACT_32BITS(&rr->rr_lsr)) / 65536.;
 		dts = (double)(EXTRACT_32BITS(&rr->rr_dlsr)) / 65536.;
-		printf(" %ul %us %uj @%.2f+%.2f",
+		ND_PRINT((ndo, " %ul %us %uj @%.2f+%.2f",
 		    EXTRACT_32BITS(&rr->rr_nl) & 0x00ffffff,
 		    EXTRACT_32BITS(&rr->rr_ls),
-		    EXTRACT_32BITS(&rr->rr_dv), ts, dts);
+		    EXTRACT_32BITS(&rr->rr_dv), ts, dts));
 	}
 	return (hdr + len);
 }
 
-static int udp_cksum(register const struct ip *ip,
+static int udp_cksum(netdissect_options *ndo, register const struct ip *ip,
 		     register const struct udphdr *up,
 		     register u_int len)
 {
-	return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len,
-	    IPPROTO_UDP));
+	return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)up, len, len,
+				IPPROTO_UDP);
 }
 
 #ifdef INET6
 static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
 	u_int len)
 {
-	return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)up, len,
-	    IPPROTO_UDP));
+	return nextproto6_cksum(ip6, (const uint8_t *)(void *)up, len, len,
+	    IPPROTO_UDP);
 }
 #endif
 
 static void
-udpipaddr_print(const struct ip *ip, int sport, int dport)
+udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dport)
 {
 #ifdef INET6
 	const struct ip6_hdr *ip6;
@@ -313,21 +302,21 @@
 	if (ip6) {
 		if (ip6->ip6_nxt == IPPROTO_UDP) {
 			if (sport == -1) {
-				(void)printf("%s > %s: ",
-					ip6addr_string(&ip6->ip6_src),
-					ip6addr_string(&ip6->ip6_dst));
+				ND_PRINT((ndo, "%s > %s: ",
+					ip6addr_string(ndo, &ip6->ip6_src),
+					ip6addr_string(ndo, &ip6->ip6_dst)));
 			} else {
-				(void)printf("%s.%s > %s.%s: ",
-					ip6addr_string(&ip6->ip6_src),
+				ND_PRINT((ndo, "%s.%s > %s.%s: ",
+					ip6addr_string(ndo, &ip6->ip6_src),
 					udpport_string(sport),
-					ip6addr_string(&ip6->ip6_dst),
-					udpport_string(dport));
+					ip6addr_string(ndo, &ip6->ip6_dst),
+					udpport_string(dport)));
 			}
 		} else {
 			if (sport != -1) {
-				(void)printf("%s > %s: ",
+				ND_PRINT((ndo, "%s > %s: ",
 					udpport_string(sport),
-					udpport_string(dport));
+					udpport_string(dport)));
 			}
 		}
 	} else
@@ -335,41 +324,41 @@
 	{
 		if (ip->ip_p == IPPROTO_UDP) {
 			if (sport == -1) {
-				(void)printf("%s > %s: ",
-					ipaddr_string(&ip->ip_src),
-					ipaddr_string(&ip->ip_dst));
+				ND_PRINT((ndo, "%s > %s: ",
+					ipaddr_string(ndo, &ip->ip_src),
+					ipaddr_string(ndo, &ip->ip_dst)));
 			} else {
-				(void)printf("%s.%s > %s.%s: ",
-					ipaddr_string(&ip->ip_src),
+				ND_PRINT((ndo, "%s.%s > %s.%s: ",
+					ipaddr_string(ndo, &ip->ip_src),
 					udpport_string(sport),
-					ipaddr_string(&ip->ip_dst),
-					udpport_string(dport));
+					ipaddr_string(ndo, &ip->ip_dst),
+					udpport_string(dport)));
 			}
 		} else {
 			if (sport != -1) {
-				(void)printf("%s > %s: ",
+				ND_PRINT((ndo, "%s > %s: ",
 					udpport_string(sport),
-					udpport_string(dport));
+					udpport_string(dport)));
 			}
 		}
 	}
 }
 
 void
-udp_print(register const u_char *bp, u_int length,
+udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
 	  register const u_char *bp2, int fragmented)
 {
 	register const struct udphdr *up;
 	register const struct ip *ip;
 	register const u_char *cp;
 	register const u_char *ep = bp + length;
-	u_int16_t sport, dport, ulen;
+	uint16_t sport, dport, ulen;
 #ifdef INET6
 	register const struct ip6_hdr *ip6;
 #endif
 
-	if (ep > snapend)
-		ep = snapend;
+	if (ep > ndo->ndo_snapend)
+		ep = ndo->ndo_snapend;
 	up = (struct udphdr *)bp;
 	ip = (struct ip *)bp2;
 #ifdef INET6
@@ -378,10 +367,9 @@
 	else
 		ip6 = NULL;
 #endif /*INET6*/
-	cp = (u_char *)(up + 1);
-	if (!TTEST(up->uh_dport)) {
-		udpipaddr_print(ip, -1, -1);
-		(void)printf("[|udp]");
+	if (!ND_TTEST(up->uh_dport)) {
+		udpipaddr_print(ndo, ip, -1, -1);
+		ND_PRINT((ndo, "[|udp]"));
 		return;
 	}
 
@@ -389,80 +377,84 @@
 	dport = EXTRACT_16BITS(&up->uh_dport);
 
 	if (length < sizeof(struct udphdr)) {
-		udpipaddr_print(ip, sport, dport);
-		(void)printf("truncated-udp %d", length);
+		udpipaddr_print(ndo, ip, sport, dport);
+		ND_PRINT((ndo, "truncated-udp %d", length));
 		return;
 	}
-	length -= sizeof(struct udphdr);
-
-	if (cp > snapend) {
-		udpipaddr_print(ip, sport, dport);
-		(void)printf("[|udp]");
-		return;
-	}
-
 	ulen = EXTRACT_16BITS(&up->uh_ulen);
-	if (ulen < 8) {
-		udpipaddr_print(ip, sport, dport);
-		(void)printf("truncated-udplength %d", ulen);
+	if (ulen < sizeof(struct udphdr)) {
+		udpipaddr_print(ndo, ip, sport, dport);
+		ND_PRINT((ndo, "truncated-udplength %d", ulen));
 		return;
 	}
-	if (packettype) {
+	ulen -= sizeof(struct udphdr);
+	length -= sizeof(struct udphdr);
+	if (ulen < length)
+		length = ulen;
+
+	cp = (u_char *)(up + 1);
+	if (cp > ndo->ndo_snapend) {
+		udpipaddr_print(ndo, ip, sport, dport);
+		ND_PRINT((ndo, "[|udp]"));
+		return;
+	}
+
+	if (ndo->ndo_packettype) {
 		register struct sunrpc_msg *rp;
 		enum sunrpc_msg_type direction;
 
-		switch (packettype) {
+		switch (ndo->ndo_packettype) {
 
 		case PT_VAT:
-			udpipaddr_print(ip, sport, dport);
-			vat_print((void *)(up + 1), up);
+			udpipaddr_print(ndo, ip, sport, dport);
+			vat_print(ndo, (void *)(up + 1), up);
 			break;
 
 		case PT_WB:
-			udpipaddr_print(ip, sport, dport);
-			wb_print((void *)(up + 1), length);
+			udpipaddr_print(ndo, ip, sport, dport);
+			wb_print(ndo, (void *)(up + 1), length);
 			break;
 
 		case PT_RPC:
 			rp = (struct sunrpc_msg *)(up + 1);
 			direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
 			if (direction == SUNRPC_CALL)
-				sunrpcrequest_print((u_char *)rp, length,
+				sunrpcrequest_print(ndo, (u_char *)rp, length,
 				    (u_char *)ip);
 			else
-				nfsreply_print((u_char *)rp, length,
+				nfsreply_print(ndo, (u_char *)rp, length,
 				    (u_char *)ip);			/*XXX*/
 			break;
 
 		case PT_RTP:
-			udpipaddr_print(ip, sport, dport);
-			rtp_print((void *)(up + 1), length, up);
+			udpipaddr_print(ndo, ip, sport, dport);
+			rtp_print(ndo, (void *)(up + 1), length, up);
 			break;
 
 		case PT_RTCP:
-			udpipaddr_print(ip, sport, dport);
+			udpipaddr_print(ndo, ip, sport, dport);
 			while (cp < ep)
-				cp = rtcp_print(cp, ep);
+				cp = rtcp_print(ndo, cp, ep);
 			break;
 
 		case PT_SNMP:
-			udpipaddr_print(ip, sport, dport);
-			snmp_print((const u_char *)(up + 1), length);
+			udpipaddr_print(ndo, ip, sport, dport);
+			snmp_print(ndo, (const u_char *)(up + 1), length);
 			break;
 
 		case PT_CNFP:
-			udpipaddr_print(ip, sport, dport);
-			cnfp_print(cp, (const u_char *)ip);
+			udpipaddr_print(ndo, ip, sport, dport);
+			cnfp_print(ndo, cp);
 			break;
 
 		case PT_TFTP:
-			udpipaddr_print(ip, sport, dport);
-			tftp_print(cp, length);
+			udpipaddr_print(ndo, ip, sport, dport);
+			tftp_print(ndo, cp, length);
 			break;
 
 		case PT_AODV:
-			udpipaddr_print(ip, sport, dport);
-			aodv_print((const u_char *)(up + 1), length,
+			udpipaddr_print(ndo, ip, sport, dport);
+			aodv_print(ndo, (const u_char *)(up + 1), length,
 #ifdef INET6
 			    ip6 != NULL);
 #else
@@ -471,42 +463,45 @@
 			break;
 
 		case PT_RADIUS:
-			udpipaddr_print(ip, sport, dport);
-			radius_print(cp, length);
+			udpipaddr_print(ndo, ip, sport, dport);
+			radius_print(ndo, cp, length);
 			break;
 
 		case PT_VXLAN:
-			udpipaddr_print(ip, sport, dport);
-			vxlan_print((const u_char *)(up + 1), length);
+			udpipaddr_print(ndo, ip, sport, dport);
+			vxlan_print(ndo, (const u_char *)(up + 1), length);
 			break;
 
 		case PT_PGM:
 		case PT_PGM_ZMTP1:
-			udpipaddr_print(ip, sport, dport);
-			pgm_print(cp, length, bp2);
+			udpipaddr_print(ndo, ip, sport, dport);
+			pgm_print(ndo, cp, length, bp2);
 			break;
 		case PT_LMP:
-			udpipaddr_print(ip, sport, dport);
-			lmp_print(cp, length);
+			udpipaddr_print(ndo, ip, sport, dport);
+			lmp_print(ndo, cp, length);
 			break;
 		}
 		return;
 	}
 
-	if (!qflag) {
+	udpipaddr_print(ndo, ip, sport, dport);
+	if (!ndo->ndo_qflag) {
 		register struct sunrpc_msg *rp;
 		enum sunrpc_msg_type direction;
 
 		rp = (struct sunrpc_msg *)(up + 1);
-		if (TTEST(rp->rm_direction)) {
+		if (ND_TTEST(rp->rm_direction)) {
 			direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
 			if (dport == NFS_PORT && direction == SUNRPC_CALL) {
-				nfsreq_print((u_char *)rp, length,
+				ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+				nfsreq_print_noaddr(ndo, (u_char *)rp, length,
 				    (u_char *)ip);
 				return;
 			}
 			if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
-				nfsreply_print((u_char *)rp, length,
+				ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+				nfsreply_print_noaddr(ndo, (u_char *)rp, length,
 				    (u_char *)ip);
 				return;
 			}
@@ -517,177 +512,190 @@
 			}
 #endif
 		}
-		if (TTEST(((struct LAP *)cp)->type) &&
+		if (ND_TTEST(((struct LAP *)cp)->type) &&
 		    ((struct LAP *)cp)->type == lapDDP &&
 		    (atalk_port(sport) || atalk_port(dport))) {
-			if (vflag)
-				fputs("kip ", stdout);
-			llap_print(cp, length);
+			if (ndo->ndo_vflag)
+				ND_PRINT((ndo, "kip "));
+			llap_print(ndo, cp, length);
 			return;
 		}
 	}
-	udpipaddr_print(ip, sport, dport);
 
-	if (vflag && !Kflag && !fragmented) {
+	if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
                 /* Check the checksum, if possible. */
-                u_int16_t sum, udp_sum;
+                uint16_t sum, udp_sum;
 
 		/*
 		 * XXX - do this even if vflag == 1?
 		 * TCP does, and we do so for UDP-over-IPv6.
 		 */
-	        if (IP_V(ip) == 4 && (vflag > 1)) {
+	        if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
 			udp_sum = EXTRACT_16BITS(&up->uh_sum);
 			if (udp_sum == 0) {
-				(void)printf("[no cksum] ");
-			} else if (TTEST2(cp[0], length)) {
-				sum = udp_cksum(ip, up, length + sizeof(struct udphdr));
+				ND_PRINT((ndo, "[no cksum] "));
+			} else if (ND_TTEST2(cp[0], length)) {
+				sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr));
 
 	                        if (sum != 0) {
-        	                        (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
+					ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
 					    udp_sum,
-					    in_cksum_shouldbe(udp_sum, sum));
+					    in_cksum_shouldbe(udp_sum, sum)));
 				} else
-					(void)printf("[udp sum ok] ");
+					ND_PRINT((ndo, "[udp sum ok] "));
 			}
 		}
 #ifdef INET6
 		else if (IP_V(ip) == 6 && ip6->ip6_plen) {
 			/* for IPv6, UDP checksum is mandatory */
-			if (TTEST2(cp[0], length)) {
+			if (ND_TTEST2(cp[0], length)) {
 				sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
 				udp_sum = EXTRACT_16BITS(&up->uh_sum);
 
 	                        if (sum != 0) {
-        	                        (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
+					ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
 					    udp_sum,
-					    in_cksum_shouldbe(udp_sum, sum));
+					    in_cksum_shouldbe(udp_sum, sum)));
 				} else
-					(void)printf("[udp sum ok] ");
+					ND_PRINT((ndo, "[udp sum ok] "));
 			}
 		}
 #endif
 	}
 
-	if (!qflag) {
+	if (!ndo->ndo_qflag) {
 #define ISPORT(p) (dport == (p) || sport == (p))
 		if (ISPORT(NAMESERVER_PORT))
-			ns_print((const u_char *)(up + 1), length, 0);
+			ns_print(ndo, (const u_char *)(up + 1), length, 0);
 		else if (ISPORT(MULTICASTDNS_PORT))
-			ns_print((const u_char *)(up + 1), length, 1);
+			ns_print(ndo, (const u_char *)(up + 1), length, 1);
 		else if (ISPORT(TIMED_PORT))
-			timed_print((const u_char *)(up + 1));
+			timed_print(ndo, (const u_char *)(up + 1));
 		else if (ISPORT(TFTP_PORT))
-			tftp_print((const u_char *)(up + 1), length);
-		else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
-			bootp_print((const u_char *)(up + 1), length);
+			tftp_print(ndo, (const u_char *)(up + 1), length);
+		else if (ISPORT(BOOTPC_PORT) || ISPORT(BOOTPS_PORT))
+			bootp_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(RIP_PORT))
-			rip_print((const u_char *)(up + 1), length);
+			rip_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(AODV_PORT))
-			aodv_print((const u_char *)(up + 1), length,
+			aodv_print(ndo, (const u_char *)(up + 1), length,
 #ifdef INET6
 			    ip6 != NULL);
 #else
 			    0);
 #endif
 	        else if (ISPORT(ISAKMP_PORT))
-			 isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+			 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
   	        else if (ISPORT(ISAKMP_PORT_NATT))
-			 isakmp_rfc3948_print(gndo, (const u_char *)(up + 1), length, bp2);
+			 isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
 #if 1 /*???*/
    	        else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
-			isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+			isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
 #endif
 		else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
-			snmp_print((const u_char *)(up + 1), length);
+			snmp_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(NTP_PORT))
-			ntp_print((const u_char *)(up + 1), length);
+			ntp_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
-			krb_print((const void *)(up + 1));
+			krb_print(ndo, (const void *)(up + 1));
 		else if (ISPORT(L2TP_PORT))
-			l2tp_print((const u_char *)(up + 1), length);
+			l2tp_print(ndo, (const u_char *)(up + 1), length);
 #ifdef TCPDUMP_DO_SMB
 		else if (ISPORT(NETBIOS_NS_PORT))
-			nbt_udp137_print((const u_char *)(up + 1), length);
+			nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(NETBIOS_DGRAM_PORT))
-			nbt_udp138_print((const u_char *)(up + 1), length);
+			nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
 #endif
 		else if (dport == VAT_PORT)
-			vat_print((const void *)(up + 1), up);
+			vat_print(ndo, (const void *)(up + 1), up);
 		else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
-			zephyr_print((const void *)(up + 1), length);
+			zephyr_print(ndo, (const void *)(up + 1), length);
 		/*
 		 * Since there are 10 possible ports to check, I think
 		 * a <> test would be more efficient
 		 */
 		else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
 			 (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
-			rx_print((const void *)(up + 1), length, sport, dport,
+			rx_print(ndo, (const void *)(up + 1), length, sport, dport,
 				 (u_char *) ip);
 #ifdef INET6
 		else if (ISPORT(RIPNG_PORT))
-			ripng_print((const u_char *)(up + 1), length);
+			ripng_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
-			dhcp6_print((const u_char *)(up + 1), length);
+			dhcp6_print(ndo, (const u_char *)(up + 1), length);
+		else if (ISPORT(AHCP_PORT))
+			ahcp_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
-			babel_print((const u_char *)(up + 1), length);
+			babel_print(ndo, (const u_char *)(up + 1), length);
 #endif /*INET6*/
 		/*
 		 * Kludge in test for whiteboard packets.
 		 */
 		else if (dport == WB_PORT)
-			wb_print((const void *)(up + 1), length);
+			wb_print(ndo, (const void *)(up + 1), length);
 		else if (ISPORT(CISCO_AUTORP_PORT))
-			cisco_autorp_print((const void *)(up + 1), length);
+			cisco_autorp_print(ndo, (const void *)(up + 1), length);
 		else if (ISPORT(RADIUS_PORT) ||
 			 ISPORT(RADIUS_NEW_PORT) ||
 			 ISPORT(RADIUS_ACCOUNTING_PORT) ||
-			 ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
-			radius_print((const u_char *)(up+1), length);
+			 ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ||
+			 ISPORT(RADIUS_COA_PORT) )
+			radius_print(ndo, (const u_char *)(up+1), length);
 		else if (dport == HSRP_PORT)
-			hsrp_print((const u_char *)(up + 1), length);
+			hsrp_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(LWRES_PORT))
-			lwres_print((const u_char *)(up + 1), length);
+			lwres_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(LDP_PORT))
-			ldp_print((const u_char *)(up + 1), length);
+			ldp_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(OLSR_PORT))
-			olsr_print((const u_char *)(up + 1), length,
+			olsr_print(ndo, (const u_char *)(up + 1), length,
 #if INET6
 					(IP_V(ip) == 6) ? 1 : 0);
 #else
 					0);
 #endif
 		else if (ISPORT(MPLS_LSP_PING_PORT))
-			lspping_print((const u_char *)(up + 1), length);
+			lspping_print(ndo, (const u_char *)(up + 1), length);
 		else if (dport == BFD_CONTROL_PORT ||
 			 dport == BFD_ECHO_PORT )
-			bfd_print((const u_char *)(up+1), length, dport);
+			bfd_print(ndo, (const u_char *)(up+1), length, dport);
                 else if (ISPORT(LMP_PORT))
-			lmp_print((const u_char *)(up + 1), length);
+			lmp_print(ndo, (const u_char *)(up + 1), length);
 		else if (ISPORT(VQP_PORT))
-			vqp_print((const u_char *)(up + 1), length);
+			vqp_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(SFLOW_PORT))
-                        sflow_print((const u_char *)(up + 1), length);
+                        sflow_print(ndo, (const u_char *)(up + 1), length);
 	        else if (dport == LWAPP_CONTROL_PORT)
-			lwapp_control_print((const u_char *)(up + 1), length, 1);
+			lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
                 else if (sport == LWAPP_CONTROL_PORT)
-                        lwapp_control_print((const u_char *)(up + 1), length, 0);
+                        lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
                 else if (ISPORT(LWAPP_DATA_PORT))
-                        lwapp_data_print((const u_char *)(up + 1), length);
+                        lwapp_data_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(SIP_PORT))
-			sip_print((const u_char *)(up + 1), length);
+			sip_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(SYSLOG_PORT))
-			syslog_print((const u_char *)(up + 1), length);
+			syslog_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(OTV_PORT))
-			otv_print((const u_char *)(up + 1), length);
+			otv_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(VXLAN_PORT))
-			vxlan_print((const u_char *)(up + 1), length);
-		else
-			(void)printf("UDP, length %u",
-			    (u_int32_t)(ulen - sizeof(*up)));
+			vxlan_print(ndo, (const u_char *)(up + 1), length);
+                else if (ISPORT(GENEVE_PORT))
+			geneve_print(ndo, (const u_char *)(up + 1), length);
+		else {
+			if (ulen > length)
+				ND_PRINT((ndo, "UDP, bad length %u > %u",
+				    ulen, length));
+			else
+				ND_PRINT((ndo, "UDP, length %u", ulen));
+		}
 #undef ISPORT
-	} else
-		(void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));
+	} else {
+		if (ulen > length)
+			ND_PRINT((ndo, "UDP, bad length %u > %u",
+			    ulen, length));
+		else
+			ND_PRINT((ndo, "UDP, length %u", ulen));
+	}
 }
 
 
diff --git a/print-usb.c b/print-usb.c
index 8e15e7b..75f78fc 100644
--- a/print-usb.c
+++ b/print-usb.c
@@ -19,22 +19,21 @@
  *
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 
 
 #if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
 #include <pcap/usb.h>
 
+static const char tstr[] = "[|usb]";
+
 /* returns direction: 1=inbound 2=outbound -1=invalid */
 static int
 get_direction(int transfer_type, int event_type)
@@ -81,49 +80,49 @@
 }
 
 static void
-usb_header_print(const pcap_usb_header *uh)
+usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
 {
 	int direction;
 
 	switch(uh->transfer_type)
 	{
 		case URB_ISOCHRONOUS:
-			printf("ISOCHRONOUS");
+			ND_PRINT((ndo, "ISOCHRONOUS"));
 			break;
 		case URB_INTERRUPT:
-			printf("INTERRUPT");
+			ND_PRINT((ndo, "INTERRUPT"));
 			break;
 		case URB_CONTROL:
-			printf("CONTROL");
+			ND_PRINT((ndo, "CONTROL"));
 			break;
 		case URB_BULK:
-			printf("BULK");
+			ND_PRINT((ndo, "BULK"));
 			break;
 		default:
-			printf(" ?");
+			ND_PRINT((ndo, " ?"));
 	}
 
 	switch(uh->event_type)
 	{
 		case URB_SUBMIT:
-			printf(" SUBMIT");
+			ND_PRINT((ndo, " SUBMIT"));
 			break;
 		case URB_COMPLETE:
-			printf(" COMPLETE");
+			ND_PRINT((ndo, " COMPLETE"));
 			break;
 		case URB_ERROR:
-			printf(" ERROR");
+			ND_PRINT((ndo, " ERROR"));
 			break;
 		default:
-			printf(" ?");
+			ND_PRINT((ndo, " ?"));
 	}
 
 	direction = get_direction(uh->transfer_type, uh->event_type);
 	if(direction == 1)
-		printf(" from");
+		ND_PRINT((ndo, " from"));
 	else if(direction == 2)
-		printf(" to");
-	printf(" %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f);
+		ND_PRINT((ndo, " to"));
+	ND_PRINT((ndo, " %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f));
 }
 
 /*
@@ -135,14 +134,15 @@
  * is the number of bytes actually captured.
  */
 u_int
-usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_48_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+                        register const u_char *p)
 {
 	if (h->caplen < sizeof(pcap_usb_header)) {
-		printf("[|usb]");
+		ND_PRINT((ndo, "%s", tstr));
 		return(sizeof(pcap_usb_header));
 	}
 
-	usb_header_print((const pcap_usb_header *) p);
+	usb_header_print(ndo, (const pcap_usb_header *) p);
 
 	return(sizeof(pcap_usb_header));
 }
@@ -157,14 +157,15 @@
  * is the number of bytes actually captured.
  */
 u_int
-usb_linux_64_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_64_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+                        register const u_char *p)
 {
 	if (h->caplen < sizeof(pcap_usb_header_mmapped)) {
-		printf("[|usb]");
+		ND_PRINT((ndo, "%s", tstr));
 		return(sizeof(pcap_usb_header_mmapped));
 	}
 
-	usb_header_print((const pcap_usb_header *) p);
+	usb_header_print(ndo, (const pcap_usb_header *) p);
 
 	return(sizeof(pcap_usb_header_mmapped));
 }
diff --git a/print-vjc.c b/print-vjc.c
index 2dc89aa..24f8a12 100644
--- a/print-vjc.c
+++ b/print-vjc.c
@@ -19,23 +19,14 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.15 2004-03-25 03:31:17 mcr Exp $ (LBL)";
-#endif
-
 #include <tcpdump-stdinc.h>
 
-#include <pcap.h>
-#include <stdio.h>
-
 #include "interface.h"
-#include "addrtoname.h"
-
 #include "slcompress.h"
 #include "ppp.h"
 
@@ -82,38 +73,38 @@
  * unused argument remind us that we should fix this some day.
  */
 int
-vjc_print(register const char *bp, u_short proto _U_)
+vjc_print(netdissect_options *ndo, register const char *bp, u_short proto _U_)
 {
 	int i;
 
 	switch (bp[0] & 0xf0) {
 	case TYPE_IP:
-		if (eflag)
-			printf("(vjc type=IP) ");
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "(vjc type=IP) "));
 		return PPP_IP;
 	case TYPE_UNCOMPRESSED_TCP:
-		if (eflag)
-			printf("(vjc type=raw TCP) ");
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "(vjc type=raw TCP) "));
 		return PPP_IP;
 	case TYPE_COMPRESSED_TCP:
-		if (eflag)
-			printf("(vjc type=compressed TCP) ");
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "(vjc type=compressed TCP) "));
 		for (i = 0; i < 8; i++) {
 			if (bp[1] & (0x80 >> i))
-				printf("%c", "?CI?SAWU"[i]);
+				ND_PRINT((ndo, "%c", "?CI?SAWU"[i]));
 		}
 		if (bp[1])
-			printf(" ");
-		printf("C=0x%02x ", bp[2]);
-		printf("sum=0x%04x ", *(u_short *)&bp[3]);
+			ND_PRINT((ndo, " "));
+		ND_PRINT((ndo, "C=0x%02x ", bp[2]));
+		ND_PRINT((ndo, "sum=0x%04x ", *(u_short *)&bp[3]));
 		return -1;
 	case TYPE_ERROR:
-		if (eflag)
-			printf("(vjc type=error) ");
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "(vjc type=error) "));
 		return -1;
 	default:
-		if (eflag)
-			printf("(vjc type=0x%02x) ", bp[0] & 0xf0);
+		if (ndo->ndo_eflag)
+			ND_PRINT((ndo, "(vjc type=0x%02x) ", bp[0] & 0xf0));
 		return -1;
 	}
 }
diff --git a/print-vqp.c b/print-vqp.c
index 2d9e8e1..ce3572a 100644
--- a/print-vqp.c
+++ b/print-vqp.c
@@ -12,26 +12,18 @@
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
  *
- * support for the Cisco prop. VQP Protocol 
+ * support for the Cisco prop. VQP Protocol
  *
  * Original code by Carles Kishimoto <Carles.Kishimoto@bsc.es>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-vqp.c,v 1.3 2006-08-19 06:51:13 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -52,16 +44,16 @@
  */
 
 struct vqp_common_header_t {
-    u_int8_t version;
-    u_int8_t msg_type;
-    u_int8_t error_code;
-    u_int8_t nitems;
-    u_int8_t sequence[4];
+    uint8_t version;
+    uint8_t msg_type;
+    uint8_t error_code;
+    uint8_t nitems;
+    uint8_t sequence[4];
 };
 
 struct vqp_obj_tlv_t {
-    u_int8_t obj_type[4];
-    u_int8_t obj_length[2];
+    uint8_t obj_type[4];
+    uint8_t obj_length[2];
 };
 
 #define VQP_OBJ_REQ_JOIN_PORT  0x01
@@ -106,52 +98,52 @@
 };
 
 void
-vqp_print(register const u_char *pptr, register u_int len) 
+vqp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
 {
     const struct vqp_common_header_t *vqp_common_header;
     const struct vqp_obj_tlv_t *vqp_obj_tlv;
 
     const u_char *tptr;
-    u_int16_t vqp_obj_len;
-    u_int32_t vqp_obj_type;
+    uint16_t vqp_obj_len;
+    uint32_t vqp_obj_type;
     int tlen;
-    u_int8_t nitems;
+    uint8_t nitems;
 
     tptr=pptr;
     tlen = len;
     vqp_common_header = (const struct vqp_common_header_t *)pptr;
-    TCHECK(*vqp_common_header);
+    ND_TCHECK(*vqp_common_header);
 
     /*
      * Sanity checking of the header.
      */
     if (VQP_EXTRACT_VERSION(vqp_common_header->version) != VQP_VERSION) {
-	printf("VQP version %u packet not supported",
-               VQP_EXTRACT_VERSION(vqp_common_header->version));
+	ND_PRINT((ndo, "VQP version %u packet not supported",
+               VQP_EXTRACT_VERSION(vqp_common_header->version)));
 	return;
     }
 
     /* in non-verbose mode just lets print the basic Message Type */
-    if (vflag < 1) {
-        printf("VQPv%u %s Message, error-code %s (%u), length %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "VQPv%u %s Message, error-code %s (%u), length %u",
                VQP_EXTRACT_VERSION(vqp_common_header->version),
                tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
                tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
 	       vqp_common_header->error_code,
-               len);
+               len));
         return;
     }
-    
+
     /* ok they seem to want to know everything - lets fully decode it */
     nitems = vqp_common_header->nitems;
-    printf("\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
+    ND_PRINT((ndo, "\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
            VQP_EXTRACT_VERSION(vqp_common_header->version),
 	   tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
 	   tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
 	   vqp_common_header->error_code,
            EXTRACT_32BITS(&vqp_common_header->sequence),
            nitems,
-           len);
+           len));
 
     /* skip VQP Common header */
     tptr+=sizeof(const struct vqp_common_header_t);
@@ -165,9 +157,9 @@
         tptr+=sizeof(struct vqp_obj_tlv_t);
         tlen-=sizeof(struct vqp_obj_tlv_t);
 
-        printf("\n\t  %s Object (0x%08x), length %u, value: ",
+        ND_PRINT((ndo, "\n\t  %s Object (0x%08x), length %u, value: ",
                tok2str(vqp_obj_values, "Unknown", vqp_obj_type),
-               vqp_obj_type, vqp_obj_len);
+               vqp_obj_type, vqp_obj_len));
 
         /* basic sanity check */
         if (vqp_obj_type == 0 || vqp_obj_len ==0) {
@@ -175,28 +167,27 @@
         }
 
         /* did we capture enough for fully decoding the object ? */
-        if (!TTEST2(*tptr, vqp_obj_len)) 
-            goto trunc;
+        ND_TCHECK2(*tptr, vqp_obj_len);
 
         switch(vqp_obj_type) {
 	case VQP_OBJ_IP_ADDRESS:
-            printf("%s (0x%08x)", ipaddr_string(tptr), EXTRACT_32BITS(tptr));
+            ND_PRINT((ndo, "%s (0x%08x)", ipaddr_string(ndo, tptr), EXTRACT_32BITS(tptr)));
             break;
             /* those objects have similar semantics - fall through */
         case VQP_OBJ_PORT_NAME:
 	case VQP_OBJ_VLAN_NAME:
 	case VQP_OBJ_VTP_DOMAIN:
 	case VQP_OBJ_ETHERNET_PKT:
-            safeputs((const char *)tptr, vqp_obj_len);
+            safeputs(ndo, tptr, vqp_obj_len);
             break;
             /* those objects have similar semantics - fall through */
 	case VQP_OBJ_MAC_ADDRESS:
 	case VQP_OBJ_MAC_NULL:
-	      printf("%s", etheraddr_string(tptr));
+	      ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr)));
               break;
         default:
-            if (vflag <= 1)
-                print_unknown_data(tptr, "\n\t    ", vqp_obj_len);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo,tptr, "\n\t    ", vqp_obj_len);
             break;
         }
 	tptr += vqp_obj_len;
@@ -205,5 +196,5 @@
     }
     return;
 trunc:
-    printf("\n\t[|VQP]");
+    ND_PRINT((ndo, "\n\t[|VQP]"));
 }
diff --git a/print-vrrp.c b/print-vrrp.c
index 8b733d2..f739d1e 100644
--- a/print-vrrp.c
+++ b/print-vrrp.c
@@ -23,26 +23,22 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.10 2005-05-06 07:56:54 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 
+#include "ip.h"
+#include "ipproto.h"
 /*
- * RFC 2338:
+ * RFC 2338 (VRRP v2):
+ *
  *     0                   1                   2                   3
  *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -62,6 +58,27 @@
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *    |                     Authentication Data (2)                   |
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *
+ * RFC 5798 (VRRP v3):
+ *
+ *    0                   1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |                    IPv4 Fields or IPv6 Fields                 |
+ *   ...                                                             ...
+ *    |                                                               |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |Version| Type  | Virtual Rtr ID|   Priority    |Count IPvX Addr|
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |(rsvd) |     Max Adver Int     |          Checksum             |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *    |                                                               |
+ *    +                                                               +
+ *    |                       IPvX Address(es)                        |
+ *    +                                                               +
+ *    |                                                               |
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
 /* Type */
@@ -85,63 +102,81 @@
 };
 
 void
-vrrp_print(register const u_char *bp, register u_int len, int ttl)
+vrrp_print(netdissect_options *ndo,
+           register const u_char *bp, register u_int len,
+           register const u_char *bp2, int ttl)
 {
-	int version, type, auth_type;
+	int version, type, auth_type = VRRP_AUTH_NONE; /* keep compiler happy */
 	const char *type_s;
 
-	TCHECK(bp[0]);
+	ND_TCHECK(bp[0]);
 	version = (bp[0] & 0xf0) >> 4;
 	type = bp[0] & 0x0f;
 	type_s = tok2str(type2str, "unknown type (%u)", type);
-	printf("VRRPv%u, %s", version, type_s);
+	ND_PRINT((ndo, "VRRPv%u, %s", version, type_s));
 	if (ttl != 255)
-		printf(", (ttl %u)", ttl);
-	if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT)
+		ND_PRINT((ndo, ", (ttl %u)", ttl));
+	if (version < 2 || version > 3 || type != VRRP_TYPE_ADVERTISEMENT)
 		return;
-	TCHECK(bp[2]);
-	printf(", vrid %u, prio %u", bp[1], bp[2]);
-	TCHECK(bp[5]);
-	auth_type = bp[4];
-	printf(", authtype %s", tok2str(auth2str, NULL, auth_type));
-	printf(", intvl %us, length %u", bp[5],len);
-	if (vflag) {
+	ND_TCHECK(bp[2]);
+	ND_PRINT((ndo, ", vrid %u, prio %u", bp[1], bp[2]));
+	ND_TCHECK(bp[5]);
+
+	if (version == 2) {
+		auth_type = bp[4];
+		ND_PRINT((ndo, ", authtype %s", tok2str(auth2str, NULL, auth_type)));
+		ND_PRINT((ndo, ", intvl %us, length %u", bp[5], len));
+	} else { /* version == 3 */
+		uint16_t intvl = (bp[4] & 0x0f) << 8 | bp[5];
+		ND_PRINT((ndo, ", intvl %ucs, length %u", intvl, len));
+	}
+
+	if (ndo->ndo_vflag) {
 		int naddrs = bp[3];
 		int i;
 		char c;
 
-		if (TTEST2(bp[0], len)) {
+		if (version == 2 && ND_TTEST2(bp[0], len)) {
 			struct cksum_vec vec[1];
 
 			vec[0].ptr = bp;
 			vec[0].len = len;
 			if (in_cksum(vec, 1))
-				printf(", (bad vrrp cksum %x)",
-					EXTRACT_16BITS(&bp[6]));
+				ND_PRINT((ndo, ", (bad vrrp cksum %x)",
+					EXTRACT_16BITS(&bp[6])));
 		}
-		printf(", addrs");
+
+		if (version == 3 && ND_TTEST2(bp[0], len)) {
+			uint16_t cksum = nextproto4_cksum(ndo, (struct ip *)bp2, bp,
+				len, len, IPPROTO_VRRP);
+			if (cksum)
+				ND_PRINT((ndo, ", (bad vrrp cksum %x)",
+					EXTRACT_16BITS(&bp[6])));
+		}
+
+		ND_PRINT((ndo, ", addrs"));
 		if (naddrs > 1)
-			printf("(%d)", naddrs);
-		printf(":");
+			ND_PRINT((ndo, "(%d)", naddrs));
+		ND_PRINT((ndo, ":"));
 		c = ' ';
 		bp += 8;
 		for (i = 0; i < naddrs; i++) {
-			TCHECK(bp[3]);
-			printf("%c%s", c, ipaddr_string(bp));
+			ND_TCHECK(bp[3]);
+			ND_PRINT((ndo, "%c%s", c, ipaddr_string(ndo, bp)));
 			c = ',';
 			bp += 4;
 		}
-		if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
-			TCHECK(bp[7]);
-			printf(" auth \"");
-			if (fn_printn(bp, 8, snapend)) {
-				printf("\"");
+		if (version == 2 && auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
+			ND_TCHECK(bp[7]);
+			ND_PRINT((ndo, " auth \""));
+			if (fn_printn(ndo, bp, 8, ndo->ndo_snapend)) {
+				ND_PRINT((ndo, "\""));
 				goto trunc;
 			}
-			printf("\"");
+			ND_PRINT((ndo, "\""));
 		}
 	}
 	return;
 trunc:
-	printf("[|vrrp]");
+	ND_PRINT((ndo, "[|vrrp]"));
 }
diff --git a/print-vtp.c b/print-vtp.c
index 04ae24c..9fe86e3 100644
--- a/print-vtp.c
+++ b/print-vtp.c
@@ -15,26 +15,23 @@
  * VLAN TRUNKING PROTOCOL (VTP)
  *
  * Reference documentation:
- *  http://www.cisco.com/en/US/tech/tk389/tk689/technologies_tech_note09186a0080094c52.shtml 
- *  http://www.cisco.com/warp/public/473/21.html 
+ *  http://www.cisco.com/en/US/tech/tk389/tk689/technologies_tech_note09186a0080094c52.shtml
+ *  http://www.cisco.com/warp/public/473/21.html
  *  http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
  *
  * Original code ode by Carles Kishimoto <carles.kishimoto@gmail.com>
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
-#include "extract.h"		
-#include "nlpid.h"
+#include "extract.h"
 
 #define VTP_HEADER_LEN			36
 #define	VTP_DOMAIN_NAME_LEN		32
@@ -48,13 +45,13 @@
 #define VTP_JOIN_MESSAGE		0x04
 
 struct vtp_vlan_ {
-    u_int8_t  len;
-    u_int8_t  status;
-    u_int8_t  type;
-    u_int8_t  name_len;
-    u_int16_t vlanid;
-    u_int16_t mtu;
-    u_int32_t index;
+    uint8_t  len;
+    uint8_t  status;
+    uint8_t  type;
+    uint8_t  name_len;
+    uint16_t vlanid;
+    uint16_t mtu;
+    uint32_t index;
 };
 
 static const struct tok vtp_message_type_values[] = {
@@ -121,7 +118,8 @@
 };
 
 void
-vtp_print (const u_char *pptr, u_int length)
+vtp_print (netdissect_options *ndo,
+           const u_char *pptr, u_int length)
 {
     int type, len, tlv_len, tlv_value;
     const u_char *tptr;
@@ -130,28 +128,27 @@
     if (length < VTP_HEADER_LEN)
         goto trunc;
 
-    tptr = pptr; 
+    tptr = pptr;
 
-    if (!TTEST2(*tptr, VTP_HEADER_LEN))	
-	goto trunc;
+    ND_TCHECK2(*tptr, VTP_HEADER_LEN);
 
     type = *(tptr+1);
-    printf("VTPv%u, Message %s (0x%02x), length %u",
-	   *tptr,  
+    ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u",
+	   *tptr,
 	   tok2str(vtp_message_type_values,"Unknown message type", type),
 	   *(tptr+1),
-	   length);
+	   length));
 
     /* In non-verbose mode, just print version and message type */
-    if (vflag < 1) {
+    if (ndo->ndo_vflag < 1) {
         return;
     }
 
     /* verbose mode print all fields */
-    printf("\n\tDomain name: %s, %s: %u", 
+    ND_PRINT((ndo, "\n\tDomain name: %s, %s: %u",
 	   (tptr+4),
 	   tok2str(vtp_header_values,"Unknown",*(tptr+1)),
-	   *(tptr+2));
+	   *(tptr+2)));
 
     tptr += VTP_HEADER_LEN;
 
@@ -176,23 +173,23 @@
 	 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 	 *  |                        MD5 digest (16 bytes)                  |
 	 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	 *  
+	 *
 	 */
 
-	printf("\n\t  Config Rev %x, Updater %s",
+	ND_PRINT((ndo, "\n\t  Config Rev %x, Updater %s",
 	       EXTRACT_32BITS(tptr),
-	       ipaddr_string(tptr+4));
-	tptr += 8;	
-	printf(", Timestamp 0x%08x 0x%08x 0x%08x",
+	       ipaddr_string(ndo, tptr+4)));
+	tptr += 8;
+	ND_PRINT((ndo, ", Timestamp 0x%08x 0x%08x 0x%08x",
 	       EXTRACT_32BITS(tptr),
 	       EXTRACT_32BITS(tptr + 4),
-	       EXTRACT_32BITS(tptr + 8));
+	       EXTRACT_32BITS(tptr + 8)));
 	tptr += VTP_UPDATE_TIMESTAMP_LEN;
-	printf(", MD5 digest: %08x%08x%08x%08x",
+	ND_PRINT((ndo, ", MD5 digest: %08x%08x%08x%08x",
 	       EXTRACT_32BITS(tptr),
 	       EXTRACT_32BITS(tptr + 4),
 	       EXTRACT_32BITS(tptr + 8),
-	       EXTRACT_32BITS(tptr + 12));
+	       EXTRACT_32BITS(tptr + 12)));
 	tptr += VTP_MD5_DIGEST_LEN;
 	break;
 
@@ -215,12 +212,12 @@
 	 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 	 *  |                         VLAN info field N                     |
 	 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	 *      
+	 *
 	 */
 
-	printf(", Config Rev %x", EXTRACT_32BITS(tptr));
+	ND_PRINT((ndo, ", Config Rev %x", EXTRACT_32BITS(tptr)));
 
-	/*  
+	/*
 	 *  VLAN INFORMATION
 	 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 	 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -242,17 +239,16 @@
 	    if (len == 0)
 		break;
 
-	    if (!TTEST2(*tptr, len))
-		goto trunc;
+	    ND_TCHECK2(*tptr, len);
 
 	    vtp_vlan = (struct vtp_vlan_*)tptr;
-	    printf("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
+	    ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
 		   tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status),
 		   tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type),
 		   EXTRACT_16BITS(&vtp_vlan->vlanid),
 		   EXTRACT_16BITS(&vtp_vlan->mtu),
 		   EXTRACT_32BITS(&vtp_vlan->index),
-		   (tptr + VTP_VLAN_INFO_OFFSET));
+		   (tptr + VTP_VLAN_INFO_OFFSET)));
 
             /*
              * Vlan names are aligned to 32-bit boundaries.
@@ -264,16 +260,16 @@
 
             while (len > 0) {
 
-                /* 
+                /*
                  * Cisco specs says 2 bytes for type + 2 bytes for length, take only 1
-                 * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm 
+                 * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
                  */
                 type = *tptr;
                 tlv_len = *(tptr+1);
 
-                printf("\n\t\t%s (0x%04x) TLV",
+                ND_PRINT((ndo, "\n\t\t%s (0x%04x) TLV",
                        tok2str(vtp_vlan_tlv_values, "Unknown", type),
-                       type);
+                       type));
 
                 /*
                  * infinite loop check
@@ -282,38 +278,37 @@
                     return;
                 }
 
-                if (!TTEST2(*tptr, tlv_len*2 +2))
-                    goto trunc;
+                ND_TCHECK2(*tptr, tlv_len * 2 +2);
 
                 tlv_value = EXTRACT_16BITS(tptr+2);
 
                 switch (type) {
                 case VTP_VLAN_STE_HOP_COUNT:
-                    printf(", %u", tlv_value);
+                    ND_PRINT((ndo, ", %u", tlv_value));
                     break;
 
                 case VTP_VLAN_PRUNING:
-                    printf(", %s (%u)",
+                    ND_PRINT((ndo, ", %s (%u)",
                            tlv_value == 1 ? "Enabled" : "Disabled",
-                           tlv_value);
+                           tlv_value));
                     break;
 
                 case VTP_VLAN_STP_TYPE:
-                    printf(", %s (%u)",
+                    ND_PRINT((ndo, ", %s (%u)",
                            tok2str(vtp_stp_type_values, "Unknown", tlv_value),
-                           tlv_value);
+                           tlv_value));
                     break;
 
                 case VTP_VLAN_BRIDGE_TYPE:
-                    printf(", %s (%u)",
+                    ND_PRINT((ndo, ", %s (%u)",
                            tlv_value == 1 ? "SRB" : "SRT",
-                           tlv_value);
+                           tlv_value));
                     break;
 
                 case VTP_VLAN_BACKUP_CRF_MODE:
-                    printf(", %s (%u)",
+                    ND_PRINT((ndo, ", %s (%u)",
                            tlv_value == 1 ? "Backup" : "Not backup",
-                           tlv_value);
+                           tlv_value));
                     break;
 
                     /*
@@ -327,7 +322,7 @@
                 case VTP_VLAN_TRANS_BRIDGED_VLAN:
                 case VTP_VLAN_ARP_HOP_COUNT:
                 default:
-		    print_unknown_data(tptr, "\n\t\t  ", 2 + tlv_len*2);
+		    print_unknown_data(ndo, tptr, "\n\t\t  ", 2 + tlv_len*2);
                     break;
                 }
                 len -= 2 + tlv_len*2;
@@ -352,7 +347,7 @@
 	 *
 	 */
 
-	printf("\n\tStart value: %u", EXTRACT_32BITS(tptr));
+	ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_32BITS(tptr)));
 	break;
 
     case VTP_JOIN_MESSAGE:
@@ -367,7 +362,7 @@
     return;
 
  trunc:
-    printf("[|vtp]");
+    ND_PRINT((ndo, "[|vtp]"));
 }
 
 /*
diff --git a/print-vxlan.c b/print-vxlan.c
index 8034463..c4de68d 100644
--- a/print-vxlan.c
+++ b/print-vxlan.c
@@ -13,23 +13,20 @@
  * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "interface.h"
 #include "extract.h"
-#include "addrtoname.h"
-
-#include "udp.h"
 
 /*
- * VXLAN header, draft-mahalingam-dutt-dcops-vxlan-03
+ * VXLAN header, RFC7348
+ *               Virtual eXtensible Local Area Network (VXLAN): A Framework
+ *               for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks
  *
  *     0                   1                   2                   3
  *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -37,17 +34,17 @@
  *    |R|R|R|R|I|R|R|R|            Reserved                           |
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *    |                VXLAN Network Identifier (VNI) |   Reserved    |
- *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
+ *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
 void
-vxlan_print(const u_char *bp, u_int len)
+vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
 {
-    u_int8_t flags;
-    u_int32_t vni;
-    
+    uint8_t flags;
+    uint32_t vni;
+
     if (len < 8) {
-        printf("[|VXLAN]");
+        ND_PRINT((ndo, "[|VXLAN]"));
         return;
     }
 
@@ -57,18 +54,9 @@
     vni = EXTRACT_24BITS(bp);
     bp += 4;
 
-    printf("VXLAN, ");
+    ND_PRINT((ndo, "VXLAN, "));
+    ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
+    ND_PRINT((ndo, "vni %u\n", vni));
 
-    fputs("flags [", stdout);
-    if (flags & 0x08)
-        fputs("I", stdout);
-    else
-        fputs(".", stdout);
-    fputs("] ", stdout);
-
-    printf("(0x%02x), ", flags);
-    printf("vni %u\n", vni);
-
-    ether_print(gndo, bp, len - 8, len - 8, NULL, NULL);
-    return;
+    ether_print(ndo, bp, len - 8, len - 8, NULL, NULL);
 }
diff --git a/print-wb.c b/print-wb.c
index 3ae604f..e10d532 100644
--- a/print-wb.c
+++ b/print-wb.c
@@ -19,23 +19,19 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.33 2004-03-24 04:06:28 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
 
+static const char tstr[] = "[|wb]";
+
 /* XXX need to add byte-swapping macros! */
 /* XXX - you mean like the ones in "extract.h"? */
 
@@ -60,9 +56,9 @@
  * The transport level header.
  */
 struct pkt_hdr {
-	u_int32_t ph_src;		/* site id of source */
-	u_int32_t ph_ts;		/* time stamp (for skew computation) */
-	u_int16_t ph_version;	/* version number */
+	uint32_t ph_src;		/* site id of source */
+	uint32_t ph_ts;		/* time stamp (for skew computation) */
+	uint16_t ph_version;	/* version number */
 	u_char ph_type;		/* message type */
 	u_char ph_flags;	/* message flags */
 };
@@ -85,13 +81,13 @@
 #define PF_VIS		0x02	/* only visible ops wanted */
 
 struct PageID {
-	u_int32_t p_sid;		/* session id of initiator */
-	u_int32_t p_uid;		/* page number */
+	uint32_t p_sid;		/* session id of initiator */
+	uint32_t p_uid;		/* page number */
 };
 
 struct dophdr {
-	u_int32_t  dh_ts;		/* sender's timestamp */
-	u_int16_t	dh_len;		/* body length */
+	uint32_t  dh_ts;		/* sender's timestamp */
+	uint16_t	dh_len;		/* body length */
 	u_char	dh_flags;
 	u_char	dh_type;	/* body type */
 	/* body follows */
@@ -120,8 +116,8 @@
  */
 struct pkt_dop {
 	struct PageID pd_page;	/* page that operations apply to */
-	u_int32_t	pd_sseq;	/* start sequence number */
-	u_int32_t	pd_eseq;	/* end sequence number */
+	uint32_t	pd_sseq;	/* start sequence number */
+	uint32_t	pd_eseq;	/* end sequence number */
 	/* drawing ops follow */
 };
 
@@ -129,31 +125,31 @@
  * A repair request.
  */
 struct pkt_rreq {
-        u_int32_t pr_id;           /* source id of drawops to be repaired */
+        uint32_t pr_id;           /* source id of drawops to be repaired */
         struct PageID pr_page;           /* page of drawops */
-        u_int32_t pr_sseq;         /* start seqno */
-        u_int32_t pr_eseq;         /* end seqno */
+        uint32_t pr_sseq;         /* start seqno */
+        uint32_t pr_eseq;         /* end seqno */
 };
 
 /*
  * A repair reply.
  */
 struct pkt_rrep {
-	u_int32_t pr_id;	/* original site id of ops  */
+	uint32_t pr_id;	/* original site id of ops  */
 	struct pkt_dop pr_dop;
 	/* drawing ops follow */
 };
 
 struct id_off {
-        u_int32_t id;
-        u_int32_t off;
+        uint32_t id;
+        uint32_t off;
 };
 
 struct pgstate {
-	u_int32_t slot;
+	uint32_t slot;
 	struct PageID page;
-	u_int16_t nid;
-	u_int16_t rsvd;
+	uint16_t nid;
+	uint16_t rsvd;
         /* seqptr's */
 };
 
@@ -161,7 +157,7 @@
  * An announcement packet.
  */
 struct pkt_id {
-	u_int32_t pi_mslot;
+	uint32_t pi_mslot;
         struct PageID    pi_mpage;        /* current page */
 	struct pgstate pi_ps;
         /* seqptr's */
@@ -170,17 +166,18 @@
 
 struct pkt_preq {
         struct PageID  pp_page;
-        u_int32_t  pp_low;
-        u_int32_t  pp_high;
+        uint32_t  pp_low;
+        uint32_t  pp_high;
 };
 
 struct pkt_prep {
-        u_int32_t  pp_n;           /* size of pageid array */
+        uint32_t  pp_n;           /* size of pageid array */
         /* pgstate's follow */
 };
 
 static int
-wb_id(const struct pkt_id *id, u_int len)
+wb_id(netdissect_options *ndo,
+      const struct pkt_id *id, u_int len)
 {
 	int i;
 	const char *cp;
@@ -188,107 +185,110 @@
 	char c;
 	int nid;
 
-	printf(" wb-id:");
-	if (len < sizeof(*id) || (u_char *)(id + 1) > snapend)
+	ND_PRINT((ndo, " wb-id:"));
+	if (len < sizeof(*id) || !ND_TTEST(*id))
 		return (-1);
 	len -= sizeof(*id);
 
-	printf(" %u/%s:%u (max %u/%s:%u) ",
+	ND_PRINT((ndo, " %u/%s:%u (max %u/%s:%u) ",
 	       EXTRACT_32BITS(&id->pi_ps.slot),
-	       ipaddr_string(&id->pi_ps.page.p_sid),
+	       ipaddr_string(ndo, &id->pi_ps.page.p_sid),
 	       EXTRACT_32BITS(&id->pi_ps.page.p_uid),
 	       EXTRACT_32BITS(&id->pi_mslot),
-	       ipaddr_string(&id->pi_mpage.p_sid),
-	       EXTRACT_32BITS(&id->pi_mpage.p_uid));
+	       ipaddr_string(ndo, &id->pi_mpage.p_sid),
+	       EXTRACT_32BITS(&id->pi_mpage.p_uid)));
 
 	nid = EXTRACT_16BITS(&id->pi_ps.nid);
 	len -= sizeof(*io) * nid;
 	io = (struct id_off *)(id + 1);
 	cp = (char *)(io + nid);
-	if ((u_char *)cp + len <= snapend) {
-		putchar('"');
-		(void)fn_print((u_char *)cp, (u_char *)cp + len);
-		putchar('"');
+	if (ND_TTEST2(cp, len)) {
+		ND_PRINT((ndo, "\""));
+		fn_print(ndo, (u_char *)cp, (u_char *)cp + len);
+		ND_PRINT((ndo, "\""));
 	}
 
 	c = '<';
-	for (i = 0; i < nid && (u_char *)(io + 1) <= snapend; ++io, ++i) {
-		printf("%c%s:%u",
-		    c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off));
+	for (i = 0; i < nid && ND_TTEST(*io); ++io, ++i) {
+		ND_PRINT((ndo, "%c%s:%u",
+		    c, ipaddr_string(ndo, &io->id), EXTRACT_32BITS(&io->off)));
 		c = ',';
 	}
 	if (i >= nid) {
-		printf(">");
+		ND_PRINT((ndo, ">"));
 		return (0);
 	}
 	return (-1);
 }
 
 static int
-wb_rreq(const struct pkt_rreq *rreq, u_int len)
+wb_rreq(netdissect_options *ndo,
+        const struct pkt_rreq *rreq, u_int len)
 {
-	printf(" wb-rreq:");
-	if (len < sizeof(*rreq) || (u_char *)(rreq + 1) > snapend)
+	ND_PRINT((ndo, " wb-rreq:"));
+	if (len < sizeof(*rreq) || !ND_TTEST(*rreq))
 		return (-1);
 
-	printf(" please repair %s %s:%u<%u:%u>",
-	       ipaddr_string(&rreq->pr_id),
-	       ipaddr_string(&rreq->pr_page.p_sid),
+	ND_PRINT((ndo, " please repair %s %s:%u<%u:%u>",
+	       ipaddr_string(ndo, &rreq->pr_id),
+	       ipaddr_string(ndo, &rreq->pr_page.p_sid),
 	       EXTRACT_32BITS(&rreq->pr_page.p_uid),
 	       EXTRACT_32BITS(&rreq->pr_sseq),
-	       EXTRACT_32BITS(&rreq->pr_eseq));
+	       EXTRACT_32BITS(&rreq->pr_eseq)));
 	return (0);
 }
 
 static int
-wb_preq(const struct pkt_preq *preq, u_int len)
+wb_preq(netdissect_options *ndo,
+        const struct pkt_preq *preq, u_int len)
 {
-	printf(" wb-preq:");
-	if (len < sizeof(*preq) || (u_char *)(preq + 1) > snapend)
+	ND_PRINT((ndo, " wb-preq:"));
+	if (len < sizeof(*preq) || !ND_TTEST(*preq))
 		return (-1);
 
-	printf(" need %u/%s:%u",
+	ND_PRINT((ndo, " need %u/%s:%u",
 	       EXTRACT_32BITS(&preq->pp_low),
-	       ipaddr_string(&preq->pp_page.p_sid),
-	       EXTRACT_32BITS(&preq->pp_page.p_uid));
+	       ipaddr_string(ndo, &preq->pp_page.p_sid),
+	       EXTRACT_32BITS(&preq->pp_page.p_uid)));
 	return (0);
 }
 
 static int
-wb_prep(const struct pkt_prep *prep, u_int len)
+wb_prep(netdissect_options *ndo,
+        const struct pkt_prep *prep, u_int len)
 {
 	int n;
 	const struct pgstate *ps;
-	const u_char *ep = snapend;
+	const u_char *ep = ndo->ndo_snapend;
 
-	printf(" wb-prep:");
+	ND_PRINT((ndo, " wb-prep:"));
 	if (len < sizeof(*prep)) {
 		return (-1);
 	}
 	n = EXTRACT_32BITS(&prep->pp_n);
 	ps = (const struct pgstate *)(prep + 1);
-	while (--n >= 0 && (u_char *)(ps + 1) <= ep) {
+	while (--n >= 0 && ND_TTEST(*ps)) {
 		const struct id_off *io, *ie;
 		char c = '<';
 
-		printf(" %u/%s:%u",
+		ND_PRINT((ndo, " %u/%s:%u",
 		    EXTRACT_32BITS(&ps->slot),
-		    ipaddr_string(&ps->page.p_sid),
-		    EXTRACT_32BITS(&ps->page.p_uid));
+		    ipaddr_string(ndo, &ps->page.p_sid),
+		    EXTRACT_32BITS(&ps->page.p_uid)));
 		io = (struct id_off *)(ps + 1);
-		for (ie = io + ps->nid; io < ie && (u_char *)(io + 1) <= ep; ++io) {
-			printf("%c%s:%u", c, ipaddr_string(&io->id),
-			    EXTRACT_32BITS(&io->off));
+		for (ie = io + ps->nid; io < ie && ND_TTEST(*io); ++io) {
+			ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(ndo, &io->id),
+			    EXTRACT_32BITS(&io->off)));
 			c = ',';
 		}
-		printf(">");
+		ND_PRINT((ndo, ">"));
 		ps = (struct pgstate *)io;
 	}
 	return ((u_char *)ps <= ep? 0 : -1);
 }
 
 
-const char *dopstr[] = {
+static const char *dopstr[] = {
 	"dop-0!",
 	"dop-1!",
 	"RECT",
@@ -308,21 +308,30 @@
 };
 
 static int
-wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
+wb_dops(netdissect_options *ndo, const struct pkt_dop *dop,
+        uint32_t ss, uint32_t es)
 {
-	printf(" <");
+	const struct dophdr *dh = (const struct dophdr *)((const u_char *)dop + sizeof(*dop));
+
+	ND_PRINT((ndo, " <"));
 	for ( ; ss <= es; ++ss) {
-		register int t = dh->dh_type;
+		int t;
+
+		if (!ND_TTEST(*dh)) {
+			ND_PRINT((ndo, "%s", tstr));
+			break;
+		}
+		t = dh->dh_type;
 
 		if (t > DT_MAXTYPE)
-			printf(" dop-%d!", t);
+			ND_PRINT((ndo, " dop-%d!", t));
 		else {
-			printf(" %s", dopstr[t]);
+			ND_PRINT((ndo, " %s", dopstr[t]));
 			if (t == DT_SKIP || t == DT_HOLE) {
-				u_int32_t ts = EXTRACT_32BITS(&dh->dh_ts);
-				printf("%d", ts - ss + 1);
+				uint32_t ts = EXTRACT_32BITS(&dh->dh_ts);
+				ND_PRINT((ndo, "%d", ts - ss + 1));
 				if (ss > ts || ts > es) {
-					printf("[|]");
+					ND_PRINT((ndo, "[|]"));
 					if (ts < ss)
 						return (0);
 				}
@@ -330,55 +339,53 @@
 			}
 		}
 		dh = DOP_NEXT(dh);
-		if ((u_char *)dh > snapend) {
-			printf("[|wb]");
-			break;
-		}
 	}
-	printf(" >");
+	ND_PRINT((ndo, " >"));
 	return (0);
 }
 
 static int
-wb_rrep(const struct pkt_rrep *rrep, u_int len)
+wb_rrep(netdissect_options *ndo,
+        const struct pkt_rrep *rrep, u_int len)
 {
 	const struct pkt_dop *dop = &rrep->pr_dop;
 
-	printf(" wb-rrep:");
-	if (len < sizeof(*rrep) || (u_char *)(rrep + 1) > snapend)
+	ND_PRINT((ndo, " wb-rrep:"));
+	if (len < sizeof(*rrep) || !ND_TTEST(*rrep))
 		return (-1);
 	len -= sizeof(*rrep);
 
-	printf(" for %s %s:%u<%u:%u>",
-	    ipaddr_string(&rrep->pr_id),
-	    ipaddr_string(&dop->pd_page.p_sid),
+	ND_PRINT((ndo, " for %s %s:%u<%u:%u>",
+	    ipaddr_string(ndo, &rrep->pr_id),
+	    ipaddr_string(ndo, &dop->pd_page.p_sid),
 	    EXTRACT_32BITS(&dop->pd_page.p_uid),
 	    EXTRACT_32BITS(&dop->pd_sseq),
-	    EXTRACT_32BITS(&dop->pd_eseq));
+	    EXTRACT_32BITS(&dop->pd_eseq)));
 
-	if (vflag)
-		return (wb_dops((const struct dophdr *)(dop + 1),
+	if (ndo->ndo_vflag)
+		return (wb_dops(ndo, dop,
 		    EXTRACT_32BITS(&dop->pd_sseq),
 		    EXTRACT_32BITS(&dop->pd_eseq)));
 	return (0);
 }
 
 static int
-wb_drawop(const struct pkt_dop *dop, u_int len)
+wb_drawop(netdissect_options *ndo,
+          const struct pkt_dop *dop, u_int len)
 {
-	printf(" wb-dop:");
-	if (len < sizeof(*dop) || (u_char *)(dop + 1) > snapend)
+	ND_PRINT((ndo, " wb-dop:"));
+	if (len < sizeof(*dop) || !ND_TTEST(*dop))
 		return (-1);
 	len -= sizeof(*dop);
 
-	printf(" %s:%u<%u:%u>",
-	    ipaddr_string(&dop->pd_page.p_sid),
+	ND_PRINT((ndo, " %s:%u<%u:%u>",
+	    ipaddr_string(ndo, &dop->pd_page.p_sid),
 	    EXTRACT_32BITS(&dop->pd_page.p_uid),
 	    EXTRACT_32BITS(&dop->pd_sseq),
-	    EXTRACT_32BITS(&dop->pd_eseq));
+	    EXTRACT_32BITS(&dop->pd_eseq)));
 
-	if (vflag)
-		return (wb_dops((const struct dophdr *)(dop + 1),
+	if (ndo->ndo_vflag)
+		return (wb_dops(ndo, dop,
 				EXTRACT_32BITS(&dop->pd_sseq),
 				EXTRACT_32BITS(&dop->pd_eseq)));
 	return (0);
@@ -388,57 +395,58 @@
  * Print whiteboard multicast packets.
  */
 void
-wb_print(register const void *hdr, register u_int len)
+wb_print(netdissect_options *ndo,
+         register const void *hdr, register u_int len)
 {
 	register const struct pkt_hdr *ph;
 
 	ph = (const struct pkt_hdr *)hdr;
-	if (len < sizeof(*ph) || (u_char *)(ph + 1) > snapend) {
-		printf("[|wb]");
+	if (len < sizeof(*ph) || !ND_TTEST(*ph)) {
+		ND_PRINT((ndo, "%s", tstr));
 		return;
 	}
 	len -= sizeof(*ph);
 
 	if (ph->ph_flags)
-		printf("*");
+		ND_PRINT((ndo, "*"));
 	switch (ph->ph_type) {
 
 	case PT_KILL:
-		printf(" wb-kill");
+		ND_PRINT((ndo, " wb-kill"));
 		return;
 
 	case PT_ID:
-		if (wb_id((struct pkt_id *)(ph + 1), len) >= 0)
+		if (wb_id(ndo, (struct pkt_id *)(ph + 1), len) >= 0)
 			return;
 		break;
 
 	case PT_RREQ:
-		if (wb_rreq((struct pkt_rreq *)(ph + 1), len) >= 0)
+		if (wb_rreq(ndo, (struct pkt_rreq *)(ph + 1), len) >= 0)
 			return;
 		break;
 
 	case PT_RREP:
-		if (wb_rrep((struct pkt_rrep *)(ph + 1), len) >= 0)
+		if (wb_rrep(ndo, (struct pkt_rrep *)(ph + 1), len) >= 0)
 			return;
 		break;
 
 	case PT_DRAWOP:
-		if (wb_drawop((struct pkt_dop *)(ph + 1), len) >= 0)
+		if (wb_drawop(ndo, (struct pkt_dop *)(ph + 1), len) >= 0)
 			return;
 		break;
 
 	case PT_PREQ:
-		if (wb_preq((struct pkt_preq *)(ph + 1), len) >= 0)
+		if (wb_preq(ndo, (struct pkt_preq *)(ph + 1), len) >= 0)
 			return;
 		break;
 
 	case PT_PREP:
-		if (wb_prep((struct pkt_prep *)(ph + 1), len) >= 0)
+		if (wb_prep(ndo, (struct pkt_prep *)(ph + 1), len) >= 0)
 			return;
 		break;
 
 	default:
-		printf(" wb-%d!", ph->ph_type);
+		ND_PRINT((ndo, " wb-%d!", ph->ph_type));
 		return;
 	}
 }
diff --git a/print-zephyr.c b/print-zephyr.c
index d8252cc..8132c49 100644
--- a/print-zephyr.c
+++ b/print-zephyr.c
@@ -20,11 +20,7 @@
  * PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.10 2007-08-09 18:47:27 hannes Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -82,26 +78,26 @@
     { Z_PACKET_STAT,		"stat" }
 };
 
-char z_buf[256];
+static char z_buf[256];
 
 static char *
-parse_field(char **pptr, int *len)
+parse_field(netdissect_options *ndo, char **pptr, int *len)
 {
     char *s;
 
     if (*len <= 0 || !pptr || !*pptr)
 	return NULL;
-    if (*pptr > (char *) snapend)
+    if (*pptr > (char *) ndo->ndo_snapend)
 	return NULL;
 
     s = *pptr;
-    while (*pptr <= (char *) snapend && *len >= 0 && **pptr) {
+    while (*pptr <= (char *) ndo->ndo_snapend && *len >= 0 && **pptr) {
 	(*pptr)++;
 	(*len)--;
     }
     (*pptr)++;
     (*len)--;
-    if (*len < 0 || *pptr > (char *) snapend)
+    if (*len < 0 || *pptr > (char *) ndo->ndo_snapend)
 	return NULL;
     return s;
 }
@@ -132,7 +128,7 @@
 }
 
 void
-zephyr_print(const u_char *cp, int length)
+zephyr_print(netdissect_options *ndo, const u_char *cp, int length)
 {
     struct z_packet z;
     char *parse = (char *) cp;
@@ -150,7 +146,7 @@
     z.recipient = 0;
 
 #define PARSE_STRING				\
-	s = parse_field(&parse, &parselen);	\
+	s = parse_field(ndo, &parse, &parselen);	\
 	if (!s) lose = 1;
 
 #define PARSE_FIELD_INT(field)			\
@@ -184,38 +180,38 @@
     PARSE_FIELD_STR(z.multi_uid);
 
     if (lose) {
-	printf(" [|zephyr] (%d)", length);
+	ND_PRINT((ndo, " [|zephyr] (%d)", length));
 	return;
     }
 
-    printf(" zephyr");
+    ND_PRINT((ndo, " zephyr"));
     if (strncmp(z.version+4, "0.2", 3)) {
-	printf(" v%s", z.version+4);
+	ND_PRINT((ndo, " v%s", z.version+4));
 	return;
     }
 
-    printf(" %s", tok2str(z_types, "type %d", z.kind));
+    ND_PRINT((ndo, " %s", tok2str(z_types, "type %d", z.kind)));
     if (z.kind == Z_PACKET_SERVACK) {
 	/* Initialization to silence warnings */
 	char *ackdata = NULL;
 	PARSE_FIELD_STR(ackdata);
 	if (!lose && strcmp(ackdata, "SENT"))
-	    printf("/%s", str_to_lower(ackdata));
+	    ND_PRINT((ndo, "/%s", str_to_lower(ackdata)));
     }
-    if (*z.sender) printf(" %s", z.sender);
+    if (*z.sender) ND_PRINT((ndo, " %s", z.sender));
 
     if (!strcmp(z.class, "USER_LOCATE")) {
 	if (!strcmp(z.opcode, "USER_HIDE"))
-	    printf(" hide");
+	    ND_PRINT((ndo, " hide"));
 	else if (!strcmp(z.opcode, "USER_UNHIDE"))
-	    printf(" unhide");
+	    ND_PRINT((ndo, " unhide"));
 	else
-	    printf(" locate %s", z.inst);
+	    ND_PRINT((ndo, " locate %s", z.inst));
 	return;
     }
 
     if (!strcmp(z.class, "ZEPHYR_ADMIN")) {
-	printf(" zephyr-admin %s", str_to_lower(z.opcode));
+	ND_PRINT((ndo, " zephyr-admin %s", str_to_lower(z.opcode)));
 	return;
     }
 
@@ -225,79 +221,79 @@
 		!strcmp(z.opcode, "SUBSCRIBE_NODEFS") ||
 		!strcmp(z.opcode, "UNSUBSCRIBE")) {
 
-		printf(" %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
+		ND_PRINT((ndo, " %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
 				   strcmp(z.opcode, "SUBSCRIBE_NODEFS") ? "" :
-								   "-nodefs");
+								   "-nodefs"));
 		if (z.kind != Z_PACKET_SERVACK) {
 		    /* Initialization to silence warnings */
 		    char *c = NULL, *i = NULL, *r = NULL;
 		    PARSE_FIELD_STR(c);
 		    PARSE_FIELD_STR(i);
 		    PARSE_FIELD_STR(r);
-		    if (!lose) printf(" %s", z_triple(c, i, r));
+		    if (!lose) ND_PRINT((ndo, " %s", z_triple(c, i, r)));
 		}
 		return;
 	    }
 
 	    if (!strcmp(z.opcode, "GIMME")) {
-		printf(" ret");
+		ND_PRINT((ndo, " ret"));
 		return;
 	    }
 
 	    if (!strcmp(z.opcode, "GIMMEDEFS")) {
-		printf(" gimme-defs");
+		ND_PRINT((ndo, " gimme-defs"));
 		return;
 	    }
 
 	    if (!strcmp(z.opcode, "CLEARSUB")) {
-		printf(" clear-subs");
+		ND_PRINT((ndo, " clear-subs"));
 		return;
 	    }
 
-	    printf(" %s", str_to_lower(z.opcode));
+	    ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
 	    return;
 	}
 
 	if (!strcmp(z.inst, "HM")) {
-	    printf(" %s", str_to_lower(z.opcode));
+	    ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
 	    return;
 	}
 
 	if (!strcmp(z.inst, "REALM")) {
 	    if (!strcmp(z.opcode, "ADD_SUBSCRIBE"))
-		printf(" realm add-subs");
+		ND_PRINT((ndo, " realm add-subs"));
 	    if (!strcmp(z.opcode, "REQ_SUBSCRIBE"))
-		printf(" realm req-subs");
+		ND_PRINT((ndo, " realm req-subs"));
 	    if (!strcmp(z.opcode, "RLM_SUBSCRIBE"))
-		printf(" realm rlm-sub");
+		ND_PRINT((ndo, " realm rlm-sub"));
 	    if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE"))
-		printf(" realm rlm-unsub");
+		ND_PRINT((ndo, " realm rlm-unsub"));
 	    return;
 	}
     }
 
     if (!strcmp(z.class, "HM_CTL")) {
-	printf(" hm_ctl %s", str_to_lower(z.inst));
-	printf(" %s", str_to_lower(z.opcode));
+	ND_PRINT((ndo, " hm_ctl %s", str_to_lower(z.inst)));
+	ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
 	return;
     }
 
     if (!strcmp(z.class, "HM_STAT")) {
 	if (!strcmp(z.inst, "HMST_CLIENT") && !strcmp(z.opcode, "GIMMESTATS")) {
-	    printf(" get-client-stats");
+	    ND_PRINT((ndo, " get-client-stats"));
 	    return;
 	}
     }
 
     if (!strcmp(z.class, "WG_CTL")) {
-	printf(" wg_ctl %s", str_to_lower(z.inst));
-	printf(" %s", str_to_lower(z.opcode));
+	ND_PRINT((ndo, " wg_ctl %s", str_to_lower(z.inst)));
+	ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
 	return;
     }
 
     if (!strcmp(z.class, "LOGIN")) {
 	if (!strcmp(z.opcode, "USER_FLUSH")) {
-	    printf(" flush_locs");
+	    ND_PRINT((ndo, " flush_locs"));
 	    return;
 	}
 
@@ -307,7 +303,7 @@
 	    !strcmp(z.opcode, "REALM-ANNOUNCED") ||
 	    !strcmp(z.opcode, "NET-VISIBLE") ||
 	    !strcmp(z.opcode, "NET-ANNOUNCED")) {
-	    printf(" set-exposure %s", str_to_lower(z.opcode));
+	    ND_PRINT((ndo, " set-exposure %s", str_to_lower(z.opcode)));
 	    return;
 	}
     }
@@ -315,8 +311,7 @@
     if (!*z.recipient)
 	z.recipient = "*";
 
-    printf(" to %s", z_triple(z.class, z.inst, z.recipient));
+    ND_PRINT((ndo, " to %s", z_triple(z.class, z.inst, z.recipient)));
     if (*z.opcode)
-	printf(" op %s", z.opcode);
-    return;
+	ND_PRINT((ndo, " op %s", z.opcode));
 }
diff --git a/print-zeromq.c b/print-zeromq.c
index b957b9b..ba22c96 100644
--- a/print-zeromq.c
+++ b/print-zeromq.c
@@ -28,17 +28,18 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "extract.h"
 
+static const char tstr[] = " [|zmtp1]";
+
 /* Maximum number of ZMTP/1.0 frame body bytes (without the flags) to dump in
  * hex and ASCII under a single "-v" flag.
  */
@@ -75,42 +76,43 @@
  */
 
 static const u_char *
-zmtp1_print_frame(const u_char *cp, const u_char *ep) {
-	u_int64_t body_len_declared, body_len_captured, header_len;
-	u_int8_t flags;
+zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+	uint64_t body_len_declared, body_len_captured, header_len;
+	uint8_t flags;
 
-	printf("\n\t");
-	TCHECK2(*cp, 1); /* length/0xFF */
+	ND_PRINT((ndo, "\n\t"));
+	ND_TCHECK2(*cp, 1); /* length/0xFF */
 
 	if (cp[0] != 0xFF) {
 		header_len = 1; /* length */
 		body_len_declared = cp[0];
 		if (body_len_declared == 0)
 			return cp + header_len; /* skip to next frame */
-		printf(" frame flags+body  (8-bit) length %u", cp[0]);
-		TCHECK2(*cp, header_len + 1); /* length, flags */
+		ND_PRINT((ndo, " frame flags+body  (8-bit) length %u", cp[0]));
+		ND_TCHECK2(*cp, header_len + 1); /* length, flags */
 		flags = cp[1];
 	} else {
 		header_len = 1 + 8; /* 0xFF, length */
-		printf(" frame flags+body (64-bit) length");
-		TCHECK2(*cp, header_len); /* 0xFF, length */
+		ND_PRINT((ndo, " frame flags+body (64-bit) length"));
+		ND_TCHECK2(*cp, header_len); /* 0xFF, length */
 		body_len_declared = EXTRACT_64BITS(cp + 1);
 		if (body_len_declared == 0)
 			return cp + header_len; /* skip to next frame */
-		printf(" %" PRIu64, body_len_declared);
-		TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
+		ND_PRINT((ndo, " %" PRIu64, body_len_declared));
+		ND_TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
 		flags = cp[9];
 	}
 
 	body_len_captured = ep - cp - header_len;
 	if (body_len_declared > body_len_captured)
-		printf(" (%" PRIu64 " captured)", body_len_captured);
-	printf(", flags 0x%02x", flags);
+		ND_PRINT((ndo, " (%" PRIu64 " captured)", body_len_captured));
+	ND_PRINT((ndo, ", flags 0x%02x", flags));
 
-	if (vflag) {
-		u_int64_t body_len_printed = MIN(body_len_captured, body_len_declared);
+	if (ndo->ndo_vflag) {
+		uint64_t body_len_printed = min(body_len_captured, body_len_declared);
 
-		printf(" (%s|%s|%s|%s|%s|%s|%s|%s)",
+		ND_PRINT((ndo, " (%s|%s|%s|%s|%s|%s|%s|%s)",
 			flags & 0x80 ? "MBZ" : "-",
 			flags & 0x40 ? "MBZ" : "-",
 			flags & 0x20 ? "MBZ" : "-",
@@ -118,32 +120,33 @@
 			flags & 0x08 ? "MBZ" : "-",
 			flags & 0x04 ? "MBZ" : "-",
 			flags & 0x02 ? "MBZ" : "-",
-			flags & 0x01 ? "MORE" : "-");
+			flags & 0x01 ? "MORE" : "-"));
 
-		if (vflag == 1)
-			body_len_printed = MIN(VBYTES + 1, body_len_printed);
+		if (ndo->ndo_vflag == 1)
+			body_len_printed = min(VBYTES + 1, body_len_printed);
 		if (body_len_printed > 1) {
-			printf(", first %" PRIu64 " byte(s) of body:", body_len_printed - 1);
-			hex_and_ascii_print("\n\t ", cp + header_len + 1, body_len_printed - 1);
-			printf("\n");
+			ND_PRINT((ndo, ", first %" PRIu64 " byte(s) of body:", body_len_printed - 1));
+			hex_and_ascii_print(ndo, "\n\t ", cp + header_len + 1, body_len_printed - 1);
+			ND_PRINT((ndo, "\n"));
 		}
 	}
 
-	TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
+	ND_TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
 	return cp + header_len + body_len_declared;
 
 trunc:
-	printf(" [|zmtp1]");
+	ND_PRINT((ndo, "%s", tstr));
 	return ep;
 }
 
 void
-zmtp1_print(const u_char *cp, u_int len) {
-	const u_char *ep = MIN(snapend, cp + len);
+zmtp1_print(netdissect_options *ndo, const u_char *cp, u_int len)
+{
+	const u_char *ep = min(ndo->ndo_snapend, cp + len);
 
-	printf(": ZMTP/1.0");
+	ND_PRINT((ndo, ": ZMTP/1.0"));
 	while (cp < ep)
-		cp = zmtp1_print_frame(cp, ep);
+		cp = zmtp1_print_frame(ndo, cp, ep);
 }
 
 /* The functions below decode a ZeroMQ datagram, supposedly stored in the "Data"
@@ -163,52 +166,54 @@
  */
 
 static const u_char *
-zmtp1_print_intermediate_part(const u_char *cp, const u_int len) {
+zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
 	u_int frame_offset;
-	u_int64_t remaining_len;
+	uint64_t remaining_len;
 
-	TCHECK2(*cp, 2);
+	ND_TCHECK2(*cp, 2);
 	frame_offset = EXTRACT_16BITS(cp);
-	printf("\n\t frame offset 0x%04x", frame_offset);
+	ND_PRINT((ndo, "\n\t frame offset 0x%04x", frame_offset));
 	cp += 2;
-	remaining_len = snapend - cp; /* without the frame length */
+	remaining_len = ndo->ndo_snapend - cp; /* without the frame length */
 
 	if (frame_offset == 0xFFFF)
 		frame_offset = len - 2; /* always within the declared length */
 	else if (2 + frame_offset > len) {
-		printf(" (exceeds datagram declared length)");
+		ND_PRINT((ndo, " (exceeds datagram declared length)"));
 		goto trunc;
 	}
 
 	/* offset within declared length of the datagram */
 	if (frame_offset) {
-		printf("\n\t frame intermediate part, %u bytes", frame_offset);
+		ND_PRINT((ndo, "\n\t frame intermediate part, %u bytes", frame_offset));
 		if (frame_offset > remaining_len)
-			printf(" (%"PRIu64" captured)", remaining_len);
-		if (vflag) {
-			u_int64_t len_printed = MIN(frame_offset, remaining_len);
+			ND_PRINT((ndo, " (%"PRIu64" captured)", remaining_len));
+		if (ndo->ndo_vflag) {
+			uint64_t len_printed = min(frame_offset, remaining_len);
 
-			if (vflag == 1)
-				len_printed = MIN(VBYTES, len_printed);
+			if (ndo->ndo_vflag == 1)
+				len_printed = min(VBYTES, len_printed);
 			if (len_printed > 1) {
-				printf(", first %"PRIu64" byte(s):", len_printed);
-				hex_and_ascii_print("\n\t ", cp, len_printed);
-				printf("\n");
+				ND_PRINT((ndo, ", first %"PRIu64" byte(s):", len_printed));
+				hex_and_ascii_print(ndo, "\n\t ", cp, len_printed);
+				ND_PRINT((ndo, "\n"));
 			}
 		}
 	}
 	return cp + frame_offset;
 
 trunc:
-	printf(" [|zmtp1]");
+	ND_PRINT((ndo, "%s", tstr));
 	return cp + len;
 }
 
 void
-zmtp1_print_datagram(const u_char *cp, const u_int len) {
-	const u_char *ep = MIN(snapend, cp + len);
+zmtp1_print_datagram(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+	const u_char *ep = min(ndo->ndo_snapend, cp + len);
 
-	cp = zmtp1_print_intermediate_part(cp, len);
+	cp = zmtp1_print_intermediate_part(ndo, cp, len);
 	while (cp < ep)
-		cp = zmtp1_print_frame(cp, ep);
+		cp = zmtp1_print_frame(ndo, cp, ep);
 }
diff --git a/route6d.h b/route6d.h
deleted file mode 100644
index 53953fd..0000000
--- a/route6d.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997 and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-/*
- * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.5 2002-12-11 07:14:10 guy Exp $
- */
-
-#define	RIP6_VERSION	1
-
-#define	RIP6_REQUEST	1
-#define	RIP6_RESPONSE	2
-
-struct netinfo6 {
-	struct in6_addr	rip6_dest;
-	u_int16_t	rip6_tag;
-	u_int8_t	rip6_plen;
-	u_int8_t	rip6_metric;
-};
-
-struct	rip6 {
-	u_int8_t	rip6_cmd;
-	u_int8_t	rip6_vers;
-	u_int8_t	rip6_res1[2];
-	union {
-		struct	netinfo6	ru6_nets[1];
-		char	ru6_tracefile[1];
-	} rip6un;
-#define	rip6_nets	rip6un.ru6_nets
-#define	rip6_tracefile	rip6un.ru6_tracefile
-};
-
-#define	HOPCNT_INFINITY6	16
-#define	MAXRTE			24
-#define	NEXTHOP_METRIC		0xff
-
-#ifndef	DEBUG
-#define	SUPPLY_INTERVAL6	30
-#define	RIP_LIFETIME		180
-#define	RIP_HOLDDOWN		120
-#define	RIP_TRIG_INTERVAL6	5
-#define	RIP_TRIG_INTERVAL6_MIN	1
-#else
-/* only for debugging; can not wait for 30sec to appear a bug */
-#define	SUPPLY_INTERVAL6	10
-#define	RIP_LIFETIME		60
-#define	RIP_HOLDDOWN		40
-#define	RIP_TRIG_INTERVAL6	5
-#define	RIP_TRIG_INTERVAL6_MIN	1
-#endif
-
-#define	RIP6_PORT		521
-#define	RIP6_DEST		"ff02::9"
diff --git a/rpc_auth.h b/rpc_auth.h
index fe9a40b..3cc9b30 100644
--- a/rpc_auth.h
+++ b/rpc_auth.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/rpc_auth.h,v 1.2 2005-04-27 21:43:48 guy Exp $ (LBL) */
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -66,8 +65,8 @@
  * Authentication info.  Opaque to client.
  */
 struct sunrpc_opaque_auth {
-	u_int32_t oa_flavor;		/* flavor of auth */
-	u_int32_t oa_len;		/* length of opaque body */
+	uint32_t oa_flavor;		/* flavor of auth */
+	uint32_t oa_len;		/* length of opaque body */
 	/* zero or more bytes of body */
 };
 
diff --git a/rpc_msg.h b/rpc_msg.h
index 3e79ac7..88e7319 100644
--- a/rpc_msg.h
+++ b/rpc_msg.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/rpc_msg.h,v 1.2 2005-04-27 21:43:48 guy Exp $ (LBL) */
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -39,7 +38,7 @@
  * Copyright (C) 1984, Sun Microsystems, Inc.
  */
 
-#define SUNRPC_MSG_VERSION	((u_int32_t) 2)
+#define SUNRPC_MSG_VERSION	((uint32_t) 2)
 
 /*
  * Bottom up definition of an rpc message.
@@ -79,13 +78,13 @@
  * Reply to an rpc request that was rejected by the server.
  */
 struct sunrpc_rejected_reply {
-	u_int32_t		 rj_stat;	/* enum reject_stat */
+	uint32_t		 rj_stat;	/* enum reject_stat */
 	union {
 		struct {
-			u_int32_t low;
-			u_int32_t high;
+			uint32_t low;
+			uint32_t high;
 		} RJ_versions;
-		u_int32_t RJ_why;  /* enum auth_stat - why authentication did not work */
+		uint32_t RJ_why;  /* enum auth_stat - why authentication did not work */
 	} ru;
 #define	rj_vers	ru.RJ_versions
 #define	rj_why	ru.RJ_why
@@ -95,7 +94,7 @@
  * Body of a reply to an rpc request.
  */
 struct sunrpc_reply_body {
-	u_int32_t	rp_stat;		/* enum reply_stat */
+	uint32_t	rp_stat;		/* enum reply_stat */
 	struct sunrpc_rejected_reply rp_reject;	/* if rejected */
 };
 
@@ -103,10 +102,10 @@
  * Body of an rpc request call.
  */
 struct sunrpc_call_body {
-	u_int32_t cb_rpcvers;	/* must be equal to two */
-	u_int32_t cb_prog;
-	u_int32_t cb_vers;
-	u_int32_t cb_proc;
+	uint32_t cb_rpcvers;	/* must be equal to two */
+	uint32_t cb_prog;
+	uint32_t cb_vers;
+	uint32_t cb_proc;
 	struct sunrpc_opaque_auth cb_cred;
 	/* followed by opaque verifier */
 };
@@ -115,8 +114,8 @@
  * The rpc message
  */
 struct sunrpc_msg {
-	u_int32_t		rm_xid;
-	u_int32_t		rm_direction;	/* enum msg_type */
+	uint32_t		rm_xid;
+	uint32_t		rm_direction;	/* enum msg_type */
 	union {
 		struct sunrpc_call_body RM_cmb;
 		struct sunrpc_reply_body RM_rmb;
diff --git a/rpl.h b/rpl.h
new file mode 100644
index 0000000..c48784b
--- /dev/null
+++ b/rpl.h
@@ -0,0 +1,174 @@
+#ifndef _RPL_H_
+
+/*
+ * NOTE: the contents of this file are an interpretation of RFC6550.
+ *       no copyright is asserted on this file, as it transcribes
+ *       a public specification.
+ *
+ */
+
+/*
+ * DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
+ */
+
+#define ND_RPL_MESSAGE 155  /* 0x9B */
+
+enum ND_RPL_CODE {
+    ND_RPL_DAG_IS=0x00,
+    ND_RPL_DAG_IO=0x01,
+    ND_RPL_DAO   =0x02,
+    ND_RPL_DAO_ACK=0x03,
+    ND_RPL_SEC_DAG_IS = 0x80,
+    ND_RPL_SEC_DAG_IO = 0x81,
+    ND_RPL_SEC_DAG    = 0x82,
+    ND_RPL_SEC_DAG_ACK= 0x83,
+    ND_RPL_SEC_CONSIST= 0x84,
+};
+
+enum ND_RPL_DIO_FLAGS {
+        ND_RPL_DIO_GROUNDED = 0x80,
+        ND_RPL_DIO_DATRIG   = 0x40,
+        ND_RPL_DIO_DASUPPORT= 0x20,
+        ND_RPL_DIO_RES4     = 0x10,
+        ND_RPL_DIO_RES3     = 0x08,
+        ND_RPL_DIO_PRF_MASK = 0x07,  /* 3-bit preference */
+};
+
+#define DAGID_LEN 16
+
+/* section 6 of draft-ietf-roll-rpl-19 */
+struct nd_rpl_security {
+    uint8_t  rpl_sec_t_reserved;     /* bit 7 is T-bit */
+    uint8_t  rpl_sec_algo;
+    uint16_t rpl_sec_kim_lvl_flags;  /* bit 15/14, KIM */
+                                      /* bit 10-8, LVL, bit 7-0 flags */
+    uint32_t rpl_sec_counter;
+#if 0
+    uint8_t  rpl_sec_ki[0];          /* depends upon kim */
+#endif
+};
+
+/* section 6.2.1, DODAG Information Solication (DIS_IS) */
+struct nd_rpl_dis_is {
+    uint8_t rpl_dis_flags;
+    uint8_t rpl_dis_reserved;
+#if 0
+    uint8_t rpl_dis_options[0];
+#endif
+};
+
+/* section 6.3.1, DODAG Information Object (DIO) */
+struct nd_rpl_dio {
+    uint8_t  rpl_instanceid;
+    uint8_t  rpl_version;
+    uint16_t rpl_dagrank;
+    uint8_t  rpl_mopprf;   /* bit 7=G, 5-3=MOP, 2-0=PRF */
+    uint8_t  rpl_dtsn;     /* Dest. Advertisement Trigger Sequence Number */
+    uint8_t  rpl_flags;    /* no flags defined yet */
+    uint8_t  rpl_resv1;
+    uint8_t  rpl_dagid[DAGID_LEN];
+};
+#define RPL_DIO_GROUND_FLAG 0x80
+#define RPL_DIO_MOP_SHIFT   3
+#define RPL_DIO_MOP_MASK    (7 << RPL_DIO_MOP_SHIFT)
+#define RPL_DIO_PRF_SHIFT   0
+#define RPL_DIO_PRF_MASK    (7 << RPL_DIO_PRF_SHIFT)
+#define RPL_DIO_GROUNDED(X) ((X)&RPL_DIO_GROUND_FLAG)
+#define RPL_DIO_MOP(X)      (enum RPL_DIO_MOP)(((X)&RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT)
+#define RPL_DIO_PRF(X)      (((X)&RPL_DIO_PRF_MASK) >> RPL_DIO_PRF_SHIFT)
+
+enum RPL_DIO_MOP {
+    RPL_DIO_NONSTORING= 0x0,
+    RPL_DIO_STORING   = 0x1,
+    RPL_DIO_NONSTORING_MULTICAST = 0x2,
+    RPL_DIO_STORING_MULTICAST    = 0x3,
+};
+
+enum RPL_SUBOPT {
+        RPL_OPT_PAD0        = 0,
+        RPL_OPT_PADN        = 1,
+        RPL_DIO_METRICS     = 2,
+        RPL_DIO_ROUTINGINFO = 3,
+        RPL_DIO_CONFIG      = 4,
+        RPL_DAO_RPLTARGET   = 5,
+        RPL_DAO_TRANSITINFO = 6,
+        RPL_DIO_DESTPREFIX  = 8,
+        RPL_DAO_RPLTARGET_DESC=9,
+};
+
+struct rpl_dio_genoption {
+    uint8_t rpl_dio_type;
+    uint8_t rpl_dio_len;        /* suboption length, not including type/len */
+};
+#define RPL_DIO_GENOPTION_LEN	2
+
+#define RPL_DIO_LIFETIME_INFINITE   0xffffffff
+#define RPL_DIO_LIFETIME_DISCONNECT 0
+
+struct rpl_dio_destprefix {
+    uint8_t rpl_dio_type;
+    uint8_t rpl_dio_len;
+    uint8_t rpl_dio_prefixlen;        /* in bits */
+    uint8_t rpl_dio_prf;              /* flags, including Route Preference */
+    uint32_t rpl_dio_prefixlifetime;  /* in seconds */
+#if 0
+    uint8_t rpl_dio_prefix[0];        /* variable number of bytes */
+#endif
+};
+
+/* section 6.4.1, DODAG Information Object (DIO) */
+struct nd_rpl_dao {
+    uint8_t  rpl_instanceid;
+    uint8_t  rpl_flags;      /* bit 7=K, 6=D */
+    uint8_t  rpl_resv;
+    uint8_t  rpl_daoseq;
+    uint8_t  rpl_dagid[DAGID_LEN];   /* present when D set. */
+};
+#define ND_RPL_DAO_MIN_LEN	4	/* length without DAGID */
+
+/* indicates if this DAO is to be acK'ed */
+#define RPL_DAO_K_SHIFT   7
+#define RPL_DAO_K_MASK    (1 << RPL_DAO_K_SHIFT)
+#define RPL_DAO_K(X)      (((X)&RPL_DAO_K_MASK) >> RPL_DAO_K_SHIFT)
+
+/* indicates if the DAGID is present */
+#define RPL_DAO_D_SHIFT   6
+#define RPL_DAO_D_MASK    (1 << RPL_DAO_D_SHIFT)
+#define RPL_DAO_D(X)      (((X)&RPL_DAO_D_MASK) >> RPL_DAO_D_SHIFT)
+
+struct rpl_dao_target {
+    uint8_t rpl_dao_type;
+    uint8_t rpl_dao_len;
+    uint8_t rpl_dao_flags;            /* unused */
+    uint8_t rpl_dao_prefixlen;        /* in bits */
+#if 0
+    uint8_t rpl_dao_prefix[0];        /* variable number of bytes */
+#endif
+};
+
+/* section 6.5.1, Destination Advertisement Object Acknowledgement (DAO-ACK) */
+struct nd_rpl_daoack {
+    uint8_t  rpl_instanceid;
+    uint8_t  rpl_flags;      /* bit 7=D */
+    uint8_t  rpl_daoseq;
+    uint8_t  rpl_status;
+    uint8_t  rpl_dagid[DAGID_LEN];   /* present when D set. */
+};
+#define ND_RPL_DAOACK_MIN_LEN	4	/* length without DAGID */
+/* indicates if the DAGID is present */
+#define RPL_DAOACK_D_SHIFT   7
+#define RPL_DAOACK_D_MASK    (1 << RPL_DAOACK_D_SHIFT)
+#define RPL_DAOACK_D(X)      (((X)&RPL_DAOACK_D_MASK) >> RPL_DAOACK_D_SHIFT)
+
+
+
+#define _RPL_H_
+#endif /* _RPL_H_ */
+
+/*
+ * Local Variables:
+ * c-basic-offset:4
+ * c-style: whitesmith
+ * End:
+ */
+
diff --git a/rx.h b/rx.h
deleted file mode 100644
index b79dd30..0000000
--- a/rx.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright: (c) 2000 United States Government as represented by the
- *	Secretary of the Navy. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *   2. 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.
- *   3. The names of the authors may not 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.
- */
-/*
- * Rx protocol format
- *
- * $Id: rx.h,v 1.8 2002-12-11 07:14:11 guy Exp $
- */
-
-#define FS_RX_PORT	7000
-#define CB_RX_PORT	7001
-#define PROT_RX_PORT	7002
-#define VLDB_RX_PORT	7003
-#define KAUTH_RX_PORT	7004
-#define VOL_RX_PORT	7005
-#define ERROR_RX_PORT	7006		/* Doesn't seem to be used */
-#define BOS_RX_PORT	7007
-
-#ifndef AFSNAMEMAX
-#define AFSNAMEMAX 256
-#endif
-
-#ifndef AFSOPAQUEMAX
-#define AFSOPAQUEMAX 1024
-#endif
-
-#define PRNAMEMAX 64
-#define VLNAMEMAX 65
-#define KANAMEMAX 64
-#define BOSNAMEMAX 256
-
-#define	PRSFS_READ		1 /* Read files */
-#define	PRSFS_WRITE		2 /* Write files */
-#define	PRSFS_INSERT		4 /* Insert files into a directory */
-#define	PRSFS_LOOKUP		8 /* Lookup files into a directory */
-#define	PRSFS_DELETE		16 /* Delete files */
-#define	PRSFS_LOCK		32 /* Lock files */
-#define	PRSFS_ADMINISTER	64 /* Change ACL's */
-
-struct rx_header {
-	u_int32_t epoch;
-	u_int32_t cid;
-	u_int32_t callNumber;
-	u_int32_t seq;
-	u_int32_t serial;
-	u_int8_t type;
-#define RX_PACKET_TYPE_DATA		1
-#define RX_PACKET_TYPE_ACK		2
-#define RX_PACKET_TYPE_BUSY		3
-#define RX_PACKET_TYPE_ABORT		4
-#define RX_PACKET_TYPE_ACKALL		5
-#define RX_PACKET_TYPE_CHALLENGE	6
-#define RX_PACKET_TYPE_RESPONSE		7
-#define RX_PACKET_TYPE_DEBUG		8
-#define RX_PACKET_TYPE_PARAMS		9
-#define RX_PACKET_TYPE_VERSION		13
-	u_int8_t flags;
-#define RX_CLIENT_INITIATED	1
-#define RX_REQUEST_ACK		2
-#define RX_LAST_PACKET		4
-#define RX_MORE_PACKETS		8
-#define RX_FREE_PACKET		16
-#define RX_SLOW_START_OK	32
-#define RX_JUMBO_PACKET		32
-	u_int8_t userStatus;
-	u_int8_t securityIndex;
-	u_int16_t spare;		/* How clever: even though the AFS */
-	u_int16_t serviceId;		/* header files indicate that the */
-};					/* serviceId is first, it's really */
-					/* encoded _after_ the spare field */
-					/* I wasted a day figuring that out! */
-
-#define NUM_RX_FLAGS 7
-
-#define RX_MAXACKS 255
-
-struct rx_ackPacket {
-	u_int16_t bufferSpace;		/* Number of packet buffers available */
-	u_int16_t maxSkew;		/* Max diff between ack'd packet and */
-					/* highest packet received */
-	u_int32_t firstPacket;		/* The first packet in ack list */
-	u_int32_t previousPacket;	/* Previous packet recv'd (obsolete) */
-	u_int32_t serial;		/* # of packet that prompted the ack */
-	u_int8_t reason;		/* Reason for acknowledgement */
-	u_int8_t nAcks;			/* Number of acknowledgements */
-	u_int8_t acks[RX_MAXACKS];	/* Up to RX_MAXACKS acknowledgements */
-};
-
-/*
- * Values for the acks array
- */
-
-#define RX_ACK_TYPE_NACK	0	/* Don't have this packet */
-#define RX_ACK_TYPE_ACK		1	/* I have this packet */
diff --git a/sctpConstants.h b/sctpConstants.h
deleted file mode 100644
index ac28a15..0000000
--- a/sctpConstants.h
+++ /dev/null
@@ -1,571 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/sctpConstants.h,v 1.4 2003-06-03 23:49:23 guy Exp $ (LBL) */
-
-/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. 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.
- *
- * 3. Neither the name of Cisco nor of Motorola may be used
- *    to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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.
- *
- * This file is part of the SCTP reference Implementation
- *
- *
- * Please send any bug reports or fixes you make to one of the following email
- * addresses:
- *
- * rstewar1@email.mot.com
- * kmorneau@cisco.com
- * qxie1@email.mot.com
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorperated into the next SCTP release.
- */
-
-
-#ifndef __sctpConstants_h__
-#define __sctpConstants_h__
-
-
-  /* If you wish to use MD5 instead of SLA uncomment the line
-   * below. Why you would like to do this:
-   * a) There may be IPR on SHA-1, or so the FIP-180-1 page says,
-   * b) MD5 is 3 times faster (has coded here).
-   *
-   * The disadvantage is, it is thought that MD5 has been
-   * cracked... see RFC2104.
-   */
-/*#define USE_MD5 1*/
-
-/* the SCTP protocol signature
- * this includes the version number
- * encoded in the last 4 bits of the
- * signature.
- */
-#define PROTO_SIGNATURE_A 0x30000000
-
-#define SCTP_VERSION_NUMBER 0x3
-
-#define MAX_TSN 0xffffffff
-#define MAX_SEQ 0xffff
-
-/* option:
- * If you comment out the following you will
- * receive the old behavior of obeying cwnd for
- * the fast retransmit algorithm. With this defined
- * a FR happens right away with-out waiting for the
- * flightsize to drop below the cwnd value (which
- * is reduced by the FR to 1/2 the inflight packets).
- */
-#define SCTP_IGNORE_CWND_ON_FR 1
-/* default max I can burst out after a fast retransmit */
-#define SCTP_DEF_MAX_BURST 4
-
-/* Packet transmit states in the sent
- * field in the SCTP_transmitOnQueue struct
- */
-#define SCTP_DATAGRAM_UNSENT 		0
-#define SCTP_DATAGRAM_SENT   		1
-#define SCTP_DATAGRAM_RESEND1		2 /* not used */
-#define SCTP_DATAGRAM_RESEND2		3 /* not used */
-#define SCTP_DATAGRAM_RESEND3		4 /* not used */
-#define SCTP_DATAGRAM_RESEND		5
-#define SCTP_DATAGRAM_ACKED		10010
-#define SCTP_DATAGRAM_INBOUND		10011
-#define SCTP_READY_TO_TRANSMIT		10012
-#define SCTP_DATAGRAM_MARKED		20010
-
-#define MAX_FSID 64	/* debug 5 ints used for cc dynamic tracking */
-
-/* The valid defines for all message
- * types know to SCTP. 0 is reserved
- */
-#define SCTP_MSGTYPE_MASK	0xff
-
-#define SCTP_DATA		0x00
-#define SCTP_INITIATION		0x01
-#define SCTP_INITIATION_ACK	0x02
-#define SCTP_SELECTIVE_ACK	0x03
-#define SCTP_HEARTBEAT_REQUEST	0x04
-#define SCTP_HEARTBEAT_ACK	0x05
-#define SCTP_ABORT_ASSOCIATION	0x06
-#define SCTP_SHUTDOWN		0x07
-#define SCTP_SHUTDOWN_ACK	0x08
-#define SCTP_OPERATION_ERR	0x09
-#define SCTP_COOKIE_ECHO	0x0a
-#define SCTP_COOKIE_ACK         0x0b
-#define SCTP_ECN_ECHO		0x0c
-#define SCTP_ECN_CWR		0x0d
-#define SCTP_SHUTDOWN_COMPLETE	0x0e
-#define SCTP_FORWARD_CUM_TSN    0xc0
-#define SCTP_RELIABLE_CNTL      0xc1
-#define SCTP_RELIABLE_CNTL_ACK  0xc2
-
-/* ABORT and SHUTDOWN COMPLETE FLAG */
-#define SCTP_HAD_NO_TCB		0x01
-
-/* Data Chuck Specific Flags */
-#define SCTP_DATA_FRAG_MASK	0x03
-#define SCTP_DATA_MIDDLE_FRAG	0x00
-#define SCTP_DATA_LAST_FRAG	0x01
-#define SCTP_DATA_FIRST_FRAG	0x02
-#define SCTP_DATA_NOT_FRAG	0x03
-#define SCTP_DATA_UNORDERED	0x04
-
-#define SCTP_CRC_ENABLE_BIT	0x01	/* lower bit of reserved */
-
-#define isSCTPControl(a) (a->chunkID != SCTP_DATA)
-#define isSCTPData(a) (a->chunkID == SCTP_DATA)
-
-/* sctp parameter types for init/init-ack */
-
-#define SCTP_IPV4_PARAM_TYPE    0x0005
-#define SCTP_IPV6_PARAM_TYPE    0x0006
-#define SCTP_RESPONDER_COOKIE   0x0007
-#define SCTP_UNRECOG_PARAM	0x0008
-#define SCTP_COOKIE_PRESERVE    0x0009
-#define SCTP_HOSTNAME_VIA_DNS   0x000b
-#define SCTP_RESTRICT_ADDR_TO	0x000c
-
-#define SCTP_ECN_I_CAN_DO_ECN	0x8000
-#define SCTP_OPERATION_SUCCEED	0x4001
-#define SCTP_ERROR_NOT_EXECUTED	0x4002
-
-#define SCTP_UNRELIABLE_STRM    0xc000
-#define SCTP_ADD_IP_ADDRESS     0xc001
-#define SCTP_DEL_IP_ADDRESS     0xc002
-#define SCTP_STRM_FLOW_LIMIT    0xc003
-#define SCTP_PARTIAL_CSUM       0xc004
-#define SCTP_ERROR_CAUSE_TLV	0xc005
-#define SCTP_MIT_STACK_NAME	0xc006
-#define SCTP_SETADDRESS_PRIMARY 0xc007
-
-/* bits for TOS field */
-#define SCTP_ECT_BIT		0x02
-#define SCTP_CE_BIT		0x01
-
-/* error codes */
-#define SCTP_OP_ERROR_NO_ERROR		0x0000
-#define SCTP_OP_ERROR_INV_STRM		0x0001
-#define SCTP_OP_ERROR_MISS_PARAM	0x0002
-#define SCTP_OP_ERROR_STALE_COOKIE	0x0003
-#define SCTP_OP_ERROR_NO_RESOURCE 	0x0004
-#define SCTP_OP_ERROR_DNS_FAILED   	0x0005
-#define SCTP_OP_ERROR_UNK_CHUNK	   	0x0006
-#define SCTP_OP_ERROR_INV_PARAM		0x0007
-#define SCTP_OP_ERROR_UNK_PARAM	       	0x0008
-#define SCTP_OP_ERROR_NO_USERD    	0x0009
-#define SCTP_OP_ERROR_COOKIE_SHUT	0x000a
-#define SCTP_OP_ERROR_DELETE_LAST	0x000b
-#define SCTP_OP_ERROR_RESOURCE_SHORT 	0x000c
-
-#define SCTP_MAX_ERROR_CAUSE  12
-
-/* empty error causes i.e. nothing but the cause
- * are SCTP_OP_ERROR_NO_RESOURCE, SCTP_OP_ERROR_INV_PARAM,
- * SCTP_OP_ERROR_COOKIE_SHUT.
- */
-
-/* parameter for Heart Beat */
-#define HEART_BEAT_PARAM 0x0001
-
-
-
-/* send options for SCTP
- */
-#define SCTP_ORDERED_DELIVERY		0x01
-#define SCTP_NON_ORDERED_DELIVERY	0x02
-#define SCTP_DO_CRC16			0x08
-#define SCTP_MY_ADDRESS_ONLY		0x10
-
-/* below turns off above */
-#define SCTP_FLEXIBLE_ADDRESS		0x20
-#define SCTP_NO_HEARTBEAT		0x40
-
-/* mask to get sticky */
-#define SCTP_STICKY_OPTIONS_MASK        0x0c
-
-/* MTU discovery flags */
-#define SCTP_DONT_FRAGMENT		0x0100
-#define SCTP_FRAGMENT_OK		0x0200
-
-
-/* SCTP state defines for internal state machine */
-#define SCTP_STATE_EMPTY		0x0000
-#define SCTP_STATE_INUSE		0x0001
-#define SCTP_STATE_COOKIE_WAIT		0x0002
-#define SCTP_STATE_COOKIE_SENT		0x0004
-#define SCTP_STATE_OPEN			0x0008
-#define SCTP_STATE_SHUTDOWN		0x0010
-#define SCTP_STATE_SHUTDOWN_RECV	0x0020
-#define SCTP_STATE_SHUTDOWN_ACK_SENT	0x0040
-#define SCTP_STATE_SHUTDOWN_PEND	0x0080
-#define SCTP_STATE_MASK			0x007f
-/* SCTP reachability state for each address */
-#define SCTP_ADDR_NOT_REACHABLE		1
-#define SCTP_ADDR_REACHABLE		2
-#define SCTP_ADDR_NOHB			4
-#define SCTP_ADDR_BEING_DELETED		8
-
-/* How long a cookie lives */
-#define SCTP_DEFAULT_COOKIE_LIFE 60 /* seconds */
-
-/* resource limit of streams */
-#define MAX_SCTP_STREAMS 2048
-
-
-/* guess at how big to make the TSN mapping array */
-#define SCTP_STARTING_MAPARRAY 10000
-
-/* Here we define the timer types used
- * by the implementation has
- * arguments in the set/get timer type calls.
- */
-#define SCTP_TIMER_INIT 	0
-#define SCTP_TIMER_RECV 	1
-#define SCTP_TIMER_SEND 	2
-#define SCTP_TIMER_SHUTDOWN	3
-#define SCTP_TIMER_HEARTBEAT	4
-#define SCTP_TIMER_PMTU		5
-/* number of timer types in the base SCTP
- * structure used in the set/get and has
- * the base default.
- */
-#define SCTP_NUM_TMRS 6
-
-
-
-#define SCTP_IPV4_ADDRESS	2
-#define SCTP_IPV6_ADDRESS	4
-
-/* timer types */
-#define SctpTimerTypeNone		0
-#define SctpTimerTypeSend		1
-#define SctpTimerTypeInit		2
-#define SctpTimerTypeRecv		3
-#define SctpTimerTypeShutdown		4
-#define SctpTimerTypeHeartbeat		5
-#define SctpTimerTypeCookie		6
-#define SctpTimerTypeNewCookie		7
-#define SctpTimerTypePathMtuRaise	8
-#define SctpTimerTypeShutdownAck	9
-#define SctpTimerTypeRelReq		10
-
-/* Here are the timer directives given to the
- * user provided function
- */
-#define SCTP_TIMER_START	1
-#define SCTP_TIMER_STOP		2
-
-/* running flag states in timer structure */
-#define SCTP_TIMER_IDLE		0x0
-#define SCTP_TIMER_EXPIRED	0x1
-#define SCTP_TIMER_RUNNING	0x2
-
-
-/* number of simultaneous timers running */
-#define SCTP_MAX_NET_TIMERS     6	/* base of where net timers start */
-#define SCTP_NUMBER_TIMERS	12	/* allows up to 6 destinations */
-
-
-/* Of course we really don't collect stale cookies, being
- * folks of decerning taste. However we do count them, if
- * we get to many before the association comes up.. we
- * give up. Below is the constant that dictates when
- * we give it up...this is a implemenation dependant
- * treatment. In ours we do not ask for a extension of
- * time, but just retry this many times...
- */
-#define SCTP_MAX_STALE_COOKIES_I_COLLECT 10
-
-/* max number of TSN's dup'd that I will hold */
-#define SCTP_MAX_DUP_TSNS      20
-
-/* Here we define the types used when
- * setting the retry ammounts.
- */
-/* constants for type of set */
-#define SCTP_MAXATTEMPT_INIT 2
-#define SCTP_MAXATTEMPT_SEND 3
-
-/* Here we define the default timers and the
- * default number of attemts we make for
- * each respective side (send/init).
- */
-
-/* init timer def = 3sec  */
-#define SCTP_INIT_SEC	3
-#define SCTP_INIT_NSEC	0
-
-/* send timer def = 3 seconds */
-#define SCTP_SEND_SEC	1
-#define SCTP_SEND_NSEC	0
-
-/* recv timer def = 200ms (in nsec) */
-#define SCTP_RECV_SEC	0
-#define SCTP_RECV_NSEC	200000000
-
-/* 30 seconds + RTO */
-#define SCTP_HB_SEC	30
-#define SCTP_HB_NSEC	0
-
-
-/* 300 ms */
-#define SCTP_SHUTDOWN_SEC	0
-#define SCTP_SHUTDOWN_NSEC	300000000
-
-#define SCTP_RTO_UPPER_BOUND 60000000 /* 60 sec in micro-second's */
-#define SCTP_RTO_UPPER_BOUND_SEC 60  /* for the init timer */
-#define SCTP_RTO_LOWER_BOUND  1000000 /* 1 sec in micro-sec's */
-
-#define SCTP_DEF_MAX_INIT 8
-#define SCTP_DEF_MAX_SEND 10
-
-#define SCTP_DEF_PMTU_RAISE 600  /* 10 Minutes between raise attempts */
-#define SCTP_DEF_PMTU_MIN   600
-
-#define SCTP_MSEC_IN_A_SEC  1000
-#define SCTP_USEC_IN_A_SEC  1000000
-#define SCTP_NSEC_IN_A_SEC  1000000000
-
-
-/* Events that SCTP will look for, these
- * are or'd together to declare what SCTP
- * wants. Each select mask/poll list should be
- * set for the fd, if the bit is on.
- */
-#define SCTP_EVENT_READ		0x000001
-#define SCTP_EVENT_WRITE	0x000002
-#define SCTP_EVENT_EXCEPT	0x000004
-
-/* The following constant is a value for this
- * particular implemenation. It is quite arbitrary and
- * is used to limit how much data will be queued up to
- * a sender, waiting for cwnd to be larger than flightSize.
- * All implementations will need this protection is some
- * way due to buffer size constraints.
- */
-
-#define SCTP_MAX_OUTSTANDING_DG	10000
-
-
-
-/* This constant (SCTP_MAX_READBUFFER) define
- * how big the read/write buffer is
- * when we enter the fd event notification
- * the buffer is put on the stack, so the bigger
- * it is the more stack you chew up, however it
- * has got to be big enough to handle the bigest
- * message this O/S will send you. In solaris
- * with sockets (not TLI) we end up at a value
- * of 64k. In TLI we could do partial reads to
- * get it all in with less hassel.. but we
- * write to sockets for generality.
- */
-#define SCTP_MAX_READBUFFER 65536
-#define SCTP_ADDRMAX 60
-
-/* amount peer is obligated to have in rwnd or
- * I will abort
- */
-#define SCTP_MIN_RWND	1500
-
-#define SCTP_WINDOW_MIN	1500	/* smallest rwnd can be */
-#define SCTP_WINDOW_MAX 1048576	/* biggest I can grow rwnd to
-				 * My playing around suggests a
-				 * value greater than 64k does not
-				 * do much, I guess via the kernel
-				 * limitations on the stream/socket.
-				 */
-
-#define SCTP_MAX_BUNDLE_UP 256	/* max number of chunks I can bundle */
-
-/*  I can handle a 1meg re-assembly */
-#define SCTP_DEFAULT_MAXMSGREASM 1048576
-
-
-#define SCTP_DEFAULT_MAXWINDOW	32768	/* default rwnd size */
-#define SCTP_DEFAULT_MAXSEGMENT 1500	/* MTU size, this is the default
-                                         * to which we set the smallestMTU
-					 * size to. This governs what is the
-					 * largest size we will use, of course
-					 * PMTU will raise this up to
-					 * the largest interface MTU or the
-					 * ceiling below if there is no
-					 * SIOCGIFMTU.
-					 */
-#ifdef LYNX
-#define DEFAULT_MTU_CEILING  1500 	/* Since Lynx O/S is brain dead
-					 * in the way it handles the
-					 * raw IP socket, insisting
-					 * on makeing its own IP
-					 * header, we limit the growth
-					 * to that of the e-net size
-					 */
-#else
-#define DEFAULT_MTU_CEILING  2048	/* If no SIOCGIFMTU, highest value
-					 * to raise the PMTU to, i.e.
-					 * don't try to raise above this
-					 * value. Tune this per your
-					 * largest MTU interface if your
-					 * system does not support the
-					 * SIOCGIFMTU ioctl.
-					 */
-#endif
-#define SCTP_DEFAULT_MINSEGMENT 512	/* MTU size ... if no mtu disc */
-#define SCTP_HOW_MANY_SECRETS 2		/* how many secrets I keep */
-/* This is how long a secret lives, NOT how long a cookie lives */
-#define SCTP_HOW_LONG_COOKIE_LIVE 3600	/* how many seconds the current secret will live */
-
-#define SCTP_NUMBER_OF_SECRETS	8	/* or 8 * 4 = 32 octets */
-#define SCTP_SECRET_SIZE 32		/* number of octets in a 256 bits */
-
-#ifdef USE_MD5
-#define SCTP_SIGNATURE_SIZE 16	/* size of a MD5 signature */
-#else
-#define SCTP_SIGNATURE_SIZE 20	/* size of a SLA-1 signature */
-#endif
-/* Here are the notification constants
- * that the code and upper layer will get
- */
-
-/* association is up */
-#define SCTP_NOTIFY_ASSOC_UP		1
-
-/* association is down */
-#define SCTP_NOTIFY_ASSOC_DOWN		2
-
-/* interface on a association is down
- * and out of consideration for selection.
- */
-#define SCTP_NOTIFY_INTF_DOWN		3
-
-/* interface on a association is up
- * and now back in consideration for selection.
- */
-#define SCTP_NOTIFY_INTF_UP		4
-
-/* The given datagram cannot be delivered
- * to the peer, this will probably be followed
- * by a SCTP_NOTFIY_ASSOC_DOWN.
- */
-#define SCTP_NOTIFY_DG_FAIL		5
-
-/* Sent dg on non-open stream extreme code error!
- */
-#define SCTP_NOTIFY_STRDATA_ERR 	6
-
-#define SCTP_NOTIFY_ASSOC_ABORTED	7
-
-/* The stream ones are not used yet, but could
- * be when a association opens.
- */
-#define SCTP_NOTIFY_PEER_OPENED_STR	8
-#define SCTP_NOTIFY_STREAM_OPENED_OK	9
-
-/* association sees a restart event */
-#define SCTP_NOTIFY_ASSOC_RESTART	10
-
-/* a user requested HB returned */
-#define SCTP_NOTIFY_HB_RESP             11
-
-/* a result from a REL-REQ */
-#define SCTP_NOTIFY_RELREQ_RESULT_OK		12
-#define SCTP_NOTIFY_RELREQ_RESULT_FAILED	13
-
-/* clock variance is 10ms or 10,000 us's */
-#define SCTP_CLOCK_GRAINULARITY 10000
-
-#define IP_HDR_SIZE 40		/* we use the size of a IP6 header here
-				 * this detracts a small amount for ipv4
-				 * but it simplifies the ipv6 addition
-				 */
-
-#define SCTP_NUM_FDS 3
-
-/* raw IP filedescriptor */
-#define SCTP_FD_IP   0
-/* raw ICMP filedescriptor */
-#define SCTP_FD_ICMP 1
-/* processes contact me for requests here */
-#define SCTP_REQUEST 2
-
-
-#define SCTP_DEAMON_PORT 9899
-
-/* Deamon registration message types/responses */
-#define DEAMON_REGISTER       0x01
-#define DEAMON_REGISTER_ACK   0x02
-#define DEAMON_DEREGISTER     0x03
-#define DEAMON_DEREGISTER_ACK 0x04
-#define DEAMON_CHECKADDR_LIST 0x05
-
-#define DEAMON_MAGIC_VER_LEN 0xff
-
-/* max times I will attempt to send a message to deamon */
-#define SCTP_MAX_ATTEMPTS_AT_DEAMON 5
-#define SCTP_TIMEOUT_IN_POLL_FOR_DEAMON 1500 /* 1.5 seconds */
-
-/* modular comparison */
-/* True if a > b (mod = M) */
-#define compare_with_wrap(a, b, M) ((a > b) && ((a - b) < (M >> 1))) || \
-              ((b > a) && ((b - a) > (M >> 1)))
-
-#ifndef TIMEVAL_TO_TIMESPEC
-#define TIMEVAL_TO_TIMESPEC(tv, ts)			\
-{							\
-    (ts)->tv_sec  = (tv)->tv_sec;			\
-    (ts)->tv_nsec = (tv)->tv_usec * 1000;		\
-}
-#endif
-
-/* pegs */
-#define SCTP_NUMBER_OF_PEGS 21
-/* peg index's */
-#define SCTP_PEG_SACKS_SEEN 0
-#define SCTP_PEG_SACKS_SENT 1
-#define SCTP_PEG_TSNS_SENT  2
-#define SCTP_PEG_TSNS_RCVD  3
-#define SCTP_DATAGRAMS_SENT 4
-#define SCTP_DATAGRAMS_RCVD 5
-#define SCTP_RETRANTSN_SENT 6
-#define SCTP_DUPTSN_RECVD   7
-#define SCTP_HBR_RECV	    8
-#define SCTP_HBA_RECV       9
-#define SCTP_HB_SENT	   10
-#define SCTP_DATA_DG_SENT  11
-#define SCTP_DATA_DG_RECV  12
-#define SCTP_TMIT_TIMER    13
-#define SCTP_RECV_TIMER    14
-#define SCTP_HB_TIMER      15
-#define SCTP_FAST_RETRAN   16
-#define SCTP_PEG_TSNS_READ 17
-#define SCTP_NONE_LFT_TO   18
-#define SCTP_NONE_LFT_RWND 19
-#define SCTP_NONE_LFT_CWND 20
-
-
-
-#endif
-
diff --git a/sctpHeader.h b/sctpHeader.h
deleted file mode 100644
index 63f30b5..0000000
--- a/sctpHeader.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002-12-11 07:14:11 guy Exp $ (LBL) */
-
-/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. 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. Neither the name of Cisco nor of Motorola may be used
- *    to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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.
- *
- * This file is part of the SCTP reference Implementation
- *
- *
- * Please send any bug reports or fixes you make to one of the following email
- * addresses:
- *
- * rstewar1@email.mot.com
- * kmorneau@cisco.com
- * qxie1@email.mot.com
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorperated into the next SCTP release.
- */
-
-
-#ifndef __sctpHeader_h__
-#define __sctpHeader_h__
-
-#include <sctpConstants.h>
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-/* the sctp common header */
-
-#ifdef TRU64
- #define _64BITS 1
-#endif
-
-struct sctpHeader{
-  u_int16_t source;
-  u_int16_t destination;
-  u_int32_t verificationTag;
-  u_int32_t adler32;
-};
-
-/* various descriptor parsers */
-
-struct sctpChunkDesc{
-  u_int8_t chunkID;
-  u_int8_t chunkFlg;
-  u_int16_t chunkLength;
-};
-
-struct sctpParamDesc{
-  u_int16_t paramType;
-  u_int16_t paramLength;
-};
-
-
-struct sctpRelChunkDesc{
-  struct sctpChunkDesc chk;
-  u_int32_t serialNumber;
-};
-
-struct sctpVendorSpecificParam {
-  struct sctpParamDesc p;  /* type must be 0xfffe */
-  u_int32_t vendorId;	   /* vendor ID from RFC 1700 */
-  u_int16_t vendorSpecificType;
-  u_int16_t vendorSpecificLen;
-};
-
-
-/* Structures for the control parts */
-
-
-
-/* Sctp association init request/ack */
-
-/* this is used for init ack, too */
-struct sctpInitiation{
-  u_int32_t initTag;		/* tag of mine */
-  u_int32_t rcvWindowCredit;	/* rwnd */
-  u_int16_t NumPreopenStreams;	/* OS */
-  u_int16_t MaxInboundStreams;     /* MIS */
-  u_int32_t initialTSN;
-  /* optional param's follow in sctpParamDesc form */
-};
-
-struct sctpV4IpAddress{
-  struct sctpParamDesc p;	/* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
-  u_int32_t  ipAddress;
-};
-
-
-struct sctpV6IpAddress{
-  struct sctpParamDesc p;	/* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
-  u_int8_t  ipAddress[16];
-};
-
-struct sctpDNSName{
-  struct sctpParamDesc param;
-  u_int8_t name[1];
-};
-
-
-struct sctpCookiePreserve{
-  struct sctpParamDesc p;	/* type is set to SCTP_COOKIE_PRESERVE, len=8 */
-  u_int32_t extraTime;
-};
-
-
-struct sctpTimeStamp{
-  u_int32_t ts_sec;
-  u_int32_t ts_usec;
-};
-
-/* wire structure of my cookie */
-struct cookieMessage{
-  u_int32_t TieTag_curTag;		/* copied from assoc if present */
-  u_int32_t TieTag_hisTag; 		/* copied from assoc if present */
-  int32_t cookieLife;			/* life I will award this cookie */
-  struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
-  struct sctpInitiation initAckISent;	/* the INIT-ACK that I sent to my peer */
-  u_int32_t addressWhereISent[4];	/* I make this 4 ints so I get 128bits for future */
-  int32_t addrtype;			/* address type */
-  u_int16_t locScope;			/* V6 local scope flag */
-  u_int16_t siteScope;			/* V6 site scope flag */
-  /* at the end is tacked on the INIT chunk sent in
-   * its entirety and of course our
-   * signature.
-   */
-};
-
-
-/* this guy is for use when
- * I have a initiate message gloming the
- * things together.
-
- */
-struct sctpUnifiedInit{
-  struct sctpChunkDesc uh;
-  struct sctpInitiation initm;
-};
-
-struct sctpSendableInit{
-  struct sctpHeader mh;
-  struct sctpUnifiedInit msg;
-};
-
-
-/* Selective Acknowledgement
- * has the following structure with
- * a optional ammount of trailing int's
- * on the last part (based on the numberOfDesc
- * field).
- */
-
-struct sctpSelectiveAck{
-  u_int32_t highestConseqTSN;
-  u_int32_t updatedRwnd;
-  u_int16_t numberOfdesc;
-  u_int16_t numDupTsns;
-};
-
-struct sctpSelectiveFrag{
-  u_int16_t fragmentStart;
-  u_int16_t fragmentEnd;
-};
-
-
-struct sctpUnifiedSack{
-  struct sctpChunkDesc uh;
-  struct sctpSelectiveAck sack;
-};
-
-/* for both RTT request/response the
- * following is sent
- */
-
-struct sctpHBrequest {
-  u_int32_t time_value_1;
-  u_int32_t time_value_2;
-};
-
-/* here is what I read and respond with to. */
-struct sctpHBunified{
-  struct sctpChunkDesc hdr;
-  struct sctpParamDesc hb;
-};
-
-
-/* here is what I send */
-struct sctpHBsender{
-  struct sctpChunkDesc hdr;
-  struct sctpParamDesc hb;
-  struct sctpHBrequest rtt;
-  int8_t addrFmt[SCTP_ADDRMAX];
-  u_int16_t userreq;
-};
-
-
-
-/* for the abort and shutdown ACK
- * we must carry the init tag in the common header. Just the
- * common header is all that is needed with a chunk descriptor.
- */
-struct sctpUnifiedAbort{
-  struct sctpChunkDesc uh;
-};
-
-struct sctpUnifiedAbortLight{
-  struct sctpHeader mh;
-  struct sctpChunkDesc uh;
-};
-
-struct sctpUnifiedAbortHeavy{
-  struct sctpHeader mh;
-  struct sctpChunkDesc uh;
-  u_int16_t causeCode;
-  u_int16_t causeLen;
-};
-
-/* For the graceful shutdown we must carry
- * the tag (in common header)  and the highest consequitive acking value
- */
-struct sctpShutdown {
-  u_int32_t TSN_Seen;
-};
-
-struct sctpUnifiedShutdown{
-  struct sctpChunkDesc uh;
-  struct sctpShutdown shut;
-};
-
-/* in the unified message we add the trailing
- * stream id since it is the only message
- * that is defined as a operation error.
- */
-struct sctpOpErrorCause{
-  u_int16_t cause;
-  u_int16_t causeLen;
-};
-
-struct sctpUnifiedOpError{
-  struct sctpChunkDesc uh;
-  struct sctpOpErrorCause c;
-};
-
-struct sctpUnifiedStreamError{
-  struct sctpHeader mh;
-  struct sctpChunkDesc uh;
-  struct sctpOpErrorCause c;
-  u_int16_t strmNum;
-  u_int16_t reserved;
-};
-
-struct staleCookieMsg{
-  struct sctpHeader mh;
-  struct sctpChunkDesc uh;
-  struct sctpOpErrorCause c;
-  u_int32_t moretime;
-};
-
-/* the following is used in all sends
- * where nothing is needed except the
- * chunk/type i.e. shutdownAck Abort */
-
-struct sctpUnifiedSingleMsg{
-  struct sctpHeader mh;
-  struct sctpChunkDesc uh;
-};
-
-struct sctpDataPart{
-  u_int32_t TSN;
-  u_int16_t streamId;
-  u_int16_t sequence;
-  u_int32_t payloadtype;
-};
-
-struct sctpUnifiedDatagram{
-  struct sctpChunkDesc uh;
-  struct sctpDataPart dp;
-};
-
-struct sctpECN_echo{
-  struct sctpChunkDesc uh;
-  u_int32_t Lowest_TSN;
-};
-
-
-struct sctpCWR{
-  struct sctpChunkDesc uh;
-  u_int32_t TSN_reduced_at;
-};
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif
diff --git a/setsignal.c b/setsignal.c
index 6032835..1bcc032 100644
--- a/setsignal.c
+++ b/setsignal.c
@@ -19,11 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.11 2003-11-16 09:36:42 guy Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/setsignal.h b/setsignal.h
index 984c340..91a2048 100644
--- a/setsignal.h
+++ b/setsignal.h
@@ -17,8 +17,6 @@
  * 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/setsignal.h,v 1.2 1999-10-07 23:47:13 mcr Exp $ (LBL)
  */
 #ifndef setsignal_h
 #define setsignal_h
diff --git a/signature.c b/signature.c
index b2a7084..324035f 100644
--- a/signature.c
+++ b/signature.c
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -11,15 +11,11 @@
  * FOR A PARTICULAR PURPOSE.
  *
  * Functions for signature and digest verification.
- * 
+ *
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/signature.c,v 1.2 2008-09-22 20:22:10 guy Exp $ (LBL)";
-#endif
-
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -50,8 +46,8 @@
  */
 USES_APPLE_DEPRECATED_API
 static void
-signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *key,
-                           unsigned int key_len, u_int8_t *digest)
+signature_compute_hmac_md5(const uint8_t *text, int text_len, unsigned char *key,
+                           unsigned int key_len, uint8_t *digest)
 {
     MD5_CTX context;
     unsigned char k_ipad[65];    /* inner padding - key XORd with ipad */
@@ -120,10 +116,11 @@
  * Currently only MD5 is supported.
  */
 int
-signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
+signature_verify(netdissect_options *ndo,
+                 const u_char *pptr, u_int plen, u_char *sig_ptr)
 {
-    u_int8_t rcvsig[16];
-    u_int8_t sig[16];
+    uint8_t rcvsig[16];
+    uint8_t sig[16];
     unsigned int i;
 
     /*
@@ -132,12 +129,12 @@
     memcpy(rcvsig, sig_ptr, sizeof(rcvsig));
     memset(sig_ptr, 0, sizeof(rcvsig));
 
-    if (!sigsecret) {
+    if (!ndo->ndo_sigsecret) {
         return (CANT_CHECK_SIGNATURE);
     }
 
-    signature_compute_hmac_md5(pptr, plen, (unsigned char *)sigsecret,
-                               strlen(sigsecret), sig);
+    signature_compute_hmac_md5(pptr, plen, (unsigned char *)ndo->ndo_sigsecret,
+                               strlen(ndo->ndo_sigsecret), sig);
 
     if (memcmp(rcvsig, sig, sizeof(sig)) == 0) {
         return (SIGNATURE_VALID);
@@ -145,7 +142,7 @@
     } else {
 
         for (i = 0; i < sizeof(sig); ++i) {
-            (void)printf("%02x", sig[i]);
+            ND_PRINT((ndo, "%02x", sig[i]));
         }
 
         return (SIGNATURE_INVALID);
diff --git a/signature.h b/signature.h
index e48b722..a052df8 100644
--- a/signature.h
+++ b/signature.h
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -15,7 +15,8 @@
  * Original code by Hannes Gredler (hannes@juniper.net)
  */
 
-/* @(#) $Header: /tcpdump/master/tcpdump/signature.h,v 1.1 2008-08-16 11:36:20 hannes Exp $ (LBL) */
+/* for netdissect_options */
+#include "netdissect.h"
 
 /* signature checking result codes */
 #define SIGNATURE_VALID		0
@@ -23,4 +24,4 @@
 #define CANT_CHECK_SIGNATURE	2
 
 extern const struct tok signature_check_values[];
-extern int signature_verify (const u_char *, u_int, u_char *);
+extern int signature_verify(netdissect_options *, const u_char *, u_int, u_char *);
diff --git a/slcompress.h b/slcompress.h
index d10243a..644c755 100644
--- a/slcompress.h
+++ b/slcompress.h
@@ -1,8 +1,6 @@
 /*
  * Definitions for tcp compression routines.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/slcompress.h,v 1.2 2000-10-09 02:03:44 guy Exp $ (LBL)
- *
  * Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of
  * California. All rights reserved.
  *
diff --git a/slip.h b/slip.h
deleted file mode 100644
index aa6402c..0000000
--- a/slip.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Definitions that user level programs might need to know to interact
- * with serial line IP (slip) lines.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/slip.h,v 1.1 2000-10-09 01:53:21 guy Exp $
- *
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * definitions of the pseudo- link-level header attached to slip
- * packets grabbed by the packet filter (bpf) traffic monitor.
- */
-#define SLIP_HDRLEN 16
-
-#define SLX_DIR 0
-#define SLX_CHDR 1
-#define CHDR_LEN 15
-
-#define SLIPDIR_IN 0
-#define SLIPDIR_OUT 1
diff --git a/sll.h b/sll.h
deleted file mode 100644
index 0a34963..0000000
--- a/sll.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from the Stanford/CMU enet packet filter,
- * (net/enet.c) distributed as part of 4.3BSD, and code contributed
- * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
- * Berkeley Laboratory.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *      This product includes software developed by the University of
- *      California, Berkeley and its contributors.
- * 4. 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 BY THE REGENTS 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 THE REGENTS 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.8 2008-05-30 01:37:41 guy Exp $ (LBL)
- */
-
-/*
- * For captures on Linux cooked sockets, we construct a fake header
- * that includes:
- *
- *	a 2-byte "packet type" which is one of:
- *
- *		LINUX_SLL_HOST		packet was sent to us
- *		LINUX_SLL_BROADCAST	packet was broadcast
- *		LINUX_SLL_MULTICAST	packet was multicast
- *		LINUX_SLL_OTHERHOST	packet was sent to somebody else
- *		LINUX_SLL_OUTGOING	packet was sent *by* us;
- *
- *	a 2-byte Ethernet protocol field;
- *
- *	a 2-byte link-layer type;
- *
- *	a 2-byte link-layer address length;
- *
- *	an 8-byte source link-layer address, whose actual length is
- *	specified by the previous value.
- *
- * All fields except for the link-layer address are in network byte order.
- *
- * DO NOT change the layout of this structure, or change any of the
- * LINUX_SLL_ values below.  If you must change the link-layer header
- * for a "cooked" Linux capture, introduce a new DLT_ type (ask
- * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it
- * a value that collides with a value already being used), and use the
- * new header in captures of that type, so that programs that can
- * handle DLT_LINUX_SLL captures will continue to handle them correctly
- * without any change, and so that capture files with different headers
- * can be told apart and programs that read them can dissect the
- * packets in them.
- *
- * This structure, and the #defines below, must be the same in the
- * libpcap and tcpdump versions of "sll.h".
- */
-
-/*
- * A DLT_LINUX_SLL fake link-layer header.
- */
-#define SLL_HDR_LEN	16		/* total header length */
-#define SLL_ADDRLEN	8		/* length of address field */
-
-struct sll_header {
-	u_int16_t	sll_pkttype;	/* packet type */
-	u_int16_t	sll_hatype;	/* link-layer address type */
-	u_int16_t	sll_halen;	/* link-layer address length */
-	u_int8_t	sll_addr[SLL_ADDRLEN];	/* link-layer address */
-	u_int16_t	sll_protocol;	/* protocol */
-};
-
-/*
- * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
- * PACKET_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux, and so that they
- * don't change even if the PACKET_ values change.
- */
-#define LINUX_SLL_HOST		0
-#define LINUX_SLL_BROADCAST	1
-#define LINUX_SLL_MULTICAST	2
-#define LINUX_SLL_OTHERHOST	3
-#define LINUX_SLL_OUTGOING	4
-
-/*
- * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
- * ETH_P_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux.  We assume, for now,
- * that the ETH_P_ values won't change in Linux; if they do, then:
- *
- *	if we don't translate them in "pcap-linux.c", capture files
- *	won't necessarily be readable if captured on a system that
- *	defines ETH_P_ values that don't match these values;
- *
- *	if we do translate them in "pcap-linux.c", that makes life
- *	unpleasant for the BPF code generator, as the values you test
- *	for in the kernel aren't the values that you test for when
- *	reading a capture file, so the fixup code run on BPF programs
- *	handed to the kernel ends up having to do more work.
- *
- * Add other values here as necessary, for handling packet types that
- * might show up on non-Ethernet, non-802.x networks.  (Not all the ones
- * in the Linux "if_ether.h" will, I suspect, actually show up in
- * captures.)
- */
-#define LINUX_SLL_P_802_3	0x0001	/* Novell 802.3 frames without 802.2 LLC header */
-#define LINUX_SLL_P_802_2	0x0004	/* 802.2 frames (not D/I/X Ethernet) */
diff --git a/smb.h b/smb.h
index 8eeb303..88eaa06 100644
--- a/smb.h
+++ b/smb.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.9 2004-12-28 22:29:44 guy Exp $ (LBL) */
 /*
  * Copyright (C) Andrew Tridgell 1995-1999
  *
@@ -7,7 +6,8 @@
  * or later
  */
 
-#define SMBMIN(a,b) ((a)<(b)?(a):(b))
+/* for netdissect_options */
+#include "netdissect.h"
 
 /* the complete */
 #define SMBmkdir      0x00   /* create directory */
@@ -119,4 +119,4 @@
 #define PTR_DIFF(p1, p2) ((size_t)(((char *)(p1)) - (char *)(p2)))
 
 /* some protos */
-const u_char *smb_fdata(const u_char *, const char *, const u_char *, int);
+const u_char *smb_fdata(netdissect_options *, const u_char *, const char *, const u_char *, int);
diff --git a/smbutil.c b/smbutil.c
index b69788f..1c1742c 100644
--- a/smbutil.c
+++ b/smbutil.c
@@ -6,15 +6,11 @@
  * or later
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.39 2007-07-15 19:07:39 guy Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
 #include <stdio.h>
@@ -25,16 +21,16 @@
 #include "extract.h"
 #include "smb.h"
 
-static u_int32_t stringlen;
+static uint32_t stringlen;
 extern const u_char *startbuf;
 
 /*
  * interpret a 32 bit dos packed date/time to some parameters
  */
 static void
-interpret_dos_date(u_int32_t date, struct tm *tp)
+interpret_dos_date(uint32_t date, struct tm *tp)
 {
-    u_int32_t p0, p1, p2, p3;
+    uint32_t p0, p1, p2, p3;
 
     p0 = date & 0xFF;
     p1 = ((date & 0xFF00) >> 8) & 0xFF;
@@ -54,7 +50,7 @@
  * create a unix date from a dos date
  */
 static time_t
-int_unix_date(u_int32_t dos_date)
+int_unix_date(uint32_t dos_date)
 {
     struct tm t;
 
@@ -76,7 +72,7 @@
 static time_t
 make_unix_date(const u_char *date_ptr)
 {
-    u_int32_t dos_date = 0;
+    uint32_t dos_date = 0;
 
     dos_date = EXTRACT_LE_32BITS(date_ptr);
 
@@ -90,7 +86,7 @@
 static time_t
 make_unix_date2(const u_char *date_ptr)
 {
-    u_int32_t x, x2;
+    uint32_t x, x2;
 
     x = EXTRACT_LE_32BITS(date_ptr);
     x2 = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16);
@@ -129,14 +125,15 @@
  * we run past the end of the buffer
  */
 static int
-name_interpret(const u_char *in, const u_char *maxbuf, char *out)
+name_interpret(netdissect_options *ndo,
+               const u_char *in, const u_char *maxbuf, char *out)
 {
     int ret;
     int len;
 
     if (in >= maxbuf)
 	return(-1);	/* name goes past the end of the buffer */
-    TCHECK2(*in, 1);
+    ND_TCHECK2(*in, 1);
     len = (*in++) / 2;
 
     *out=0;
@@ -145,7 +142,7 @@
 	return(0);
 
     while (len--) {
-	TCHECK2(*in, 2);
+	ND_TCHECK2(*in, 2);
 	if (in + 1 >= maxbuf)
 	    return(-1);	/* name goes past the end of the buffer */
 	if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
@@ -169,7 +166,8 @@
  * find a pointer to a netbios name
  */
 static const u_char *
-name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
+name_ptr(netdissect_options *ndo,
+         const u_char *buf, int ofs, const u_char *maxbuf)
 {
     const u_char *p;
     u_char c;
@@ -177,15 +175,15 @@
     p = buf + ofs;
     if (p >= maxbuf)
 	return(NULL);	/* name goes past the end of the buffer */
-    TCHECK2(*p, 1);
+    ND_TCHECK2(*p, 1);
 
     c = *p;
 
     /* XXX - this should use the same code that the DNS dissector does */
     if ((c & 0xC0) == 0xC0) {
-	u_int16_t l;
+	uint16_t l;
 
-	TCHECK2(*p, 2);
+	ND_TCHECK2(*p, 2);
 	if ((p + 1) >= maxbuf)
 	    return(NULL);	/* name goes past the end of the buffer */
 	l = EXTRACT_16BITS(p) & 0x3FFF;
@@ -196,7 +194,7 @@
 	p = buf + l;
 	if (p >= maxbuf)
 	    return(NULL);	/* name goes past the end of the buffer */
-	TCHECK2(*p, 1);
+	ND_TCHECK2(*p, 1);
     }
     return(p);
 
@@ -208,13 +206,14 @@
  * extract a netbios name from a buf
  */
 static int
-name_extract(const u_char *buf, int ofs, const u_char *maxbuf, char *name)
+name_extract(netdissect_options *ndo,
+             const u_char *buf, int ofs, const u_char *maxbuf, char *name)
 {
-    const u_char *p = name_ptr(buf, ofs, maxbuf);
+    const u_char *p = name_ptr(ndo, buf, ofs, maxbuf);
     if (p == NULL)
 	return(-1);	/* error (probably name going past end of buffer) */
     name[0] = '\0';
-    return(name_interpret(p, maxbuf, name));
+    return(name_interpret(ndo, p, maxbuf, name));
 }
 
 
@@ -222,21 +221,22 @@
  * return the total storage length of a mangled name
  */
 static int
-name_len(const unsigned char *s, const unsigned char *maxbuf)
+name_len(netdissect_options *ndo,
+         const unsigned char *s, const unsigned char *maxbuf)
 {
     const unsigned char *s0 = s;
     unsigned char c;
 
     if (s >= maxbuf)
 	return(-1);	/* name goes past the end of the buffer */
-    TCHECK2(*s, 1);
+    ND_TCHECK2(*s, 1);
     c = *s;
     if ((c & 0xC0) == 0xC0)
 	return(2);
     while (*s) {
 	if (s >= maxbuf)
 	    return(-1);	/* name goes past the end of the buffer */
-	TCHECK2(*s, 1);
+	ND_TCHECK2(*s, 1);
 	s += (*s) + 1;
     }
     return(PTR_DIFF(s, s0) + 1);
@@ -246,11 +246,12 @@
 }
 
 static void
-print_asc(const unsigned char *buf, int len)
+print_asc(netdissect_options *ndo,
+          const unsigned char *buf, int len)
 {
     int i;
     for (i = 0; i < len; i++)
-	safeputchar(buf[i]);
+        safeputchar(ndo, buf[i]);
 }
 
 static const char *
@@ -271,56 +272,58 @@
 }
 
 void
-print_data(const unsigned char *buf, int len)
+print_data(netdissect_options *ndo,
+           const unsigned char *buf, int len)
 {
     int i = 0;
 
     if (len <= 0)
 	return;
-    printf("[%03X] ", i);
+    ND_PRINT((ndo, "[%03X] ", i));
     for (i = 0; i < len; /*nothing*/) {
-        TCHECK(buf[i]);
-	printf("%02X ", buf[i] & 0xff);
+        ND_TCHECK(buf[i]);
+	ND_PRINT((ndo, "%02X ", buf[i] & 0xff));
 	i++;
 	if (i%8 == 0)
-	    printf(" ");
+	    ND_PRINT((ndo, " "));
 	if (i % 16 == 0) {
-	    print_asc(&buf[i - 16], 8);
-	    printf(" ");
-	    print_asc(&buf[i - 8], 8);
-	    printf("\n");
+	    print_asc(ndo, &buf[i - 16], 8);
+	    ND_PRINT((ndo, " "));
+	    print_asc(ndo, &buf[i - 8], 8);
+	    ND_PRINT((ndo, "\n"));
 	    if (i < len)
-		printf("[%03X] ", i);
+		ND_PRINT((ndo, "[%03X] ", i));
 	}
     }
     if (i % 16) {
 	int n;
 
 	n = 16 - (i % 16);
-	printf(" ");
+	ND_PRINT((ndo, " "));
 	if (n>8)
-	    printf(" ");
+	    ND_PRINT((ndo, " "));
 	while (n--)
-	    printf("   ");
+	    ND_PRINT((ndo, "   "));
 
-	n = SMBMIN(8, i % 16);
-	print_asc(&buf[i - (i % 16)], n);
-	printf(" ");
+	n = min(8, i % 16);
+	print_asc(ndo, &buf[i - (i % 16)], n);
+	ND_PRINT((ndo, " "));
 	n = (i % 16) - n;
 	if (n > 0)
-	    print_asc(&buf[i - n], n);
-	printf("\n");
+	    print_asc(ndo, &buf[i - n], n);
+	ND_PRINT((ndo, "\n"));
     }
     return;
 
 trunc:
-    printf("\n");
-    printf("WARNING: Short packet. Try increasing the snap length\n");
+    ND_PRINT((ndo, "\n"));
+    ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n"));
 }
 
 
 static void
-write_bits(unsigned int val, const char *fmt)
+write_bits(netdissect_options *ndo,
+           unsigned int val, const char *fmt)
 {
     const char *p = fmt;
     int i = 0;
@@ -328,7 +331,7 @@
     while ((p = strchr(fmt, '|'))) {
 	size_t l = PTR_DIFF(p, fmt);
 	if (l && (val & (1 << i)))
-	    printf("%.*s ", (int)l, fmt);
+	    ND_PRINT((ndo, "%.*s ", (int)l, fmt));
 	fmt = p + 1;
 	i++;
     }
@@ -337,11 +340,12 @@
 /* convert a UCS-2 string into an ASCII string */
 #define MAX_UNISTR_SIZE	1000
 static const char *
-unistr(const u_char *s, u_int32_t *len, int use_unicode)
+unistr(netdissect_options *ndo,
+       const u_char *s, uint32_t *len, int use_unicode)
 {
     static char buf[MAX_UNISTR_SIZE+1];
     size_t l = 0;
-    u_int32_t strsize;
+    uint32_t strsize;
     const u_char *sp;
 
     if (use_unicode) {
@@ -349,7 +353,7 @@
 	 * Skip padding that puts the string on an even boundary.
 	 */
 	if (((s - startbuf) % 2) != 0) {
-	    TCHECK(s[0]);
+	    ND_TCHECK(s[0]);
 	    s++;
 	}
     }
@@ -361,7 +365,7 @@
 	sp = s;
 	if (!use_unicode) {
 	    for (;;) {
-		TCHECK(sp[0]);
+		ND_TCHECK(sp[0]);
 		*len += 1;
 		if (sp[0] == 0)
 		    break;
@@ -370,7 +374,7 @@
 	    strsize = *len - 1;
 	} else {
 	    for (;;) {
-		TCHECK2(sp[0], 2);
+		ND_TCHECK2(sp[0], 2);
 		*len += 2;
 		if (sp[0] == 0 && sp[1] == 0)
 		    break;
@@ -386,7 +390,7 @@
     }
     if (!use_unicode) {
     	while (strsize != 0) {
-    	    TCHECK(s[0]);
+          ND_TCHECK(s[0]);
 	    if (l >= MAX_UNISTR_SIZE)
 		break;
 	    if (ND_ISPRINT(s[0]))
@@ -402,7 +406,7 @@
 	}
     } else {
 	while (strsize != 0) {
-	    TCHECK2(s[0], 2);
+	    ND_TCHECK2(s[0], 2);
 	    if (l >= MAX_UNISTR_SIZE)
 		break;
 	    if (s[1] == 0 && ND_ISPRINT(s[0])) {
@@ -429,8 +433,9 @@
 }
 
 static const u_char *
-smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
-    int unicodestr)
+smb_fdata1(netdissect_options *ndo,
+           const u_char *buf, const char *fmt, const u_char *maxbuf,
+           int unicodestr)
 {
     int reverse = 0;
     const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
@@ -438,15 +443,15 @@
     while (*fmt && buf<maxbuf) {
 	switch (*fmt) {
 	case 'a':
-	    TCHECK(buf[0]);
-	    write_bits(buf[0], attrib_fmt);
+	    ND_TCHECK(buf[0]);
+	    write_bits(ndo, buf[0], attrib_fmt);
 	    buf++;
 	    fmt++;
 	    break;
 
 	case 'A':
-	    TCHECK2(buf[0], 2);
-	    write_bits(EXTRACT_LE_16BITS(buf), attrib_fmt);
+	    ND_TCHECK2(buf[0], 2);
+	    write_bits(ndo, EXTRACT_LE_16BITS(buf), attrib_fmt);
 	    buf += 2;
 	    fmt++;
 	    break;
@@ -466,8 +471,8 @@
 	    strncpy(bitfmt, fmt, l);
 	    bitfmt[l] = '\0';
 	    fmt = p + 1;
-	    TCHECK(buf[0]);
-	    write_bits(buf[0], bitfmt);
+	    ND_TCHECK(buf[0]);
+	    write_bits(ndo, buf[0], bitfmt);
 	    buf++;
 	    break;
 	  }
@@ -475,7 +480,7 @@
 	case 'P':
 	  {
 	    int l = atoi(fmt + 1);
-	    TCHECK2(buf[0], l);
+	    ND_TCHECK2(buf[0], l);
 	    buf += l;
 	    fmt++;
 	    while (isdigit((unsigned char)*fmt))
@@ -489,9 +494,9 @@
 	case 'b':
 	  {
 	    unsigned int x;
-	    TCHECK(buf[0]);
+	    ND_TCHECK(buf[0]);
 	    x = buf[0];
-	    printf("%u (0x%x)", x, x);
+	    ND_PRINT((ndo, "%u (0x%x)", x, x));
 	    buf += 1;
 	    fmt++;
 	    break;
@@ -499,10 +504,10 @@
 	case 'd':
 	  {
 	    unsigned int x;
-	    TCHECK2(buf[0], 2);
+	    ND_TCHECK2(buf[0], 2);
 	    x = reverse ? EXTRACT_16BITS(buf) :
 			  EXTRACT_LE_16BITS(buf);
-	    printf("%d (0x%x)", x, x);
+	    ND_PRINT((ndo, "%d (0x%x)", x, x));
 	    buf += 2;
 	    fmt++;
 	    break;
@@ -510,21 +515,21 @@
 	case 'D':
 	  {
 	    unsigned int x;
-	    TCHECK2(buf[0], 4);
+	    ND_TCHECK2(buf[0], 4);
 	    x = reverse ? EXTRACT_32BITS(buf) :
 			  EXTRACT_LE_32BITS(buf);
-	    printf("%d (0x%x)", x, x);
+	    ND_PRINT((ndo, "%d (0x%x)", x, x));
 	    buf += 4;
 	    fmt++;
 	    break;
 	  }
 	case 'L':
 	  {
-	    u_int64_t x;
-	    TCHECK2(buf[0], 8);
+	    uint64_t x;
+	    ND_TCHECK2(buf[0], 8);
 	    x = reverse ? EXTRACT_64BITS(buf) :
 			  EXTRACT_LE_64BITS(buf);
-	    printf("%" PRIu64 " (0x%" PRIx64 ")", x, x);
+	    ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
 	    buf += 8;
 	    fmt++;
 	    break;
@@ -532,15 +537,15 @@
 	case 'M':
 	  {
 	    /* Weird mixed-endian length values in 64-bit locks */
-	    u_int32_t x1, x2;
-	    u_int64_t x;
-	    TCHECK2(buf[0], 8);
+	    uint32_t x1, x2;
+	    uint64_t x;
+	    ND_TCHECK2(buf[0], 8);
 	    x1 = reverse ? EXTRACT_32BITS(buf) :
 			   EXTRACT_LE_32BITS(buf);
 	    x2 = reverse ? EXTRACT_32BITS(buf + 4) :
 			   EXTRACT_LE_32BITS(buf + 4);
-	    x = (((u_int64_t)x1) << 32) | x2;
-	    printf("%" PRIu64 " (0x%" PRIx64 ")", x, x);
+	    x = (((uint64_t)x1) << 32) | x2;
+	    ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
 	    buf += 8;
 	    fmt++;
 	    break;
@@ -548,9 +553,9 @@
 	case 'B':
 	  {
 	    unsigned int x;
-	    TCHECK(buf[0]);
+	    ND_TCHECK(buf[0]);
 	    x = buf[0];
-	    printf("0x%X", x);
+	    ND_PRINT((ndo, "0x%X", x));
 	    buf += 1;
 	    fmt++;
 	    break;
@@ -558,10 +563,10 @@
 	case 'w':
 	  {
 	    unsigned int x;
-	    TCHECK2(buf[0], 2);
+	    ND_TCHECK2(buf[0], 2);
 	    x = reverse ? EXTRACT_16BITS(buf) :
 			  EXTRACT_LE_16BITS(buf);
-	    printf("0x%X", x);
+	    ND_PRINT((ndo, "0x%X", x));
 	    buf += 2;
 	    fmt++;
 	    break;
@@ -569,10 +574,10 @@
 	case 'W':
 	  {
 	    unsigned int x;
-	    TCHECK2(buf[0], 4);
+	    ND_TCHECK2(buf[0], 4);
 	    x = reverse ? EXTRACT_32BITS(buf) :
 			  EXTRACT_LE_32BITS(buf);
-	    printf("0x%X", x);
+	    ND_PRINT((ndo, "0x%X", x));
 	    buf += 4;
 	    fmt++;
 	    break;
@@ -583,25 +588,25 @@
 	    switch (*fmt) {
 
 	    case 'b':
-		TCHECK(buf[0]);
+		ND_TCHECK(buf[0]);
 		stringlen = buf[0];
-		printf("%u", stringlen);
+		ND_PRINT((ndo, "%u", stringlen));
 		buf += 1;
 		break;
 
 	    case 'd':
-		TCHECK2(buf[0], 2);
+		ND_TCHECK2(buf[0], 2);
 		stringlen = reverse ? EXTRACT_16BITS(buf) :
 				      EXTRACT_LE_16BITS(buf);
-		printf("%u", stringlen);
+		ND_PRINT((ndo, "%u", stringlen));
 		buf += 2;
 		break;
 
 	    case 'D':
-		TCHECK2(buf[0], 4);
+		ND_TCHECK2(buf[0], 4);
 		stringlen = reverse ? EXTRACT_32BITS(buf) :
 				      EXTRACT_LE_32BITS(buf);
-		printf("%u", stringlen);
+		ND_PRINT((ndo, "%u", stringlen));
 		buf += 4;
 		break;
 	    }
@@ -613,13 +618,13 @@
 	  {
 	    /*XXX unistr() */
 	    const char *s;
-	    u_int32_t len;
+	    uint32_t len;
 
 	    len = 0;
-	    s = unistr(buf, &len, (*fmt == 'R') ? 0 : unicodestr);
+	    s = unistr(ndo, buf, &len, (*fmt == 'R') ? 0 : unicodestr);
 	    if (s == NULL)
 		goto trunc;
-	    printf("%s", s);
+	    ND_PRINT((ndo, "%s", s));
 	    buf += len;
 	    fmt++;
 	    break;
@@ -628,18 +633,18 @@
 	case 'Y':	/* like 'Z', but always ASCII */
 	  {
 	    const char *s;
-	    u_int32_t len;
+	    uint32_t len;
 
-	    TCHECK(*buf);
+	    ND_TCHECK(*buf);
 	    if (*buf != 4 && *buf != 2) {
-		printf("Error! ASCIIZ buffer of type %u", *buf);
+		ND_PRINT((ndo, "Error! ASCIIZ buffer of type %u", *buf));
 		return maxbuf;	/* give up */
 	    }
 	    len = 0;
-	    s = unistr(buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr);
+	    s = unistr(ndo, buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr);
 	    if (s == NULL)
 		goto trunc;
-	    printf("%s", s);
+	    ND_PRINT((ndo, "%s", s));
 	    buf += len + 1;
 	    fmt++;
 	    break;
@@ -647,8 +652,8 @@
 	case 's':
 	  {
 	    int l = atoi(fmt + 1);
-	    TCHECK2(*buf, l);
-	    printf("%-*.*s", l, l, buf);
+	    ND_TCHECK2(*buf, l);
+	    ND_PRINT((ndo, "%-*.*s", l, l, buf));
 	    buf += l;
 	    fmt++;
 	    while (isdigit((unsigned char)*fmt))
@@ -657,8 +662,8 @@
 	  }
 	case 'c':
 	  {
-	    TCHECK2(*buf, stringlen);
-	    printf("%-*.*s", (int)stringlen, (int)stringlen, buf);
+	    ND_TCHECK2(*buf, stringlen);
+	    ND_PRINT((ndo, "%-*.*s", (int)stringlen, (int)stringlen, buf));
 	    buf += stringlen;
 	    fmt++;
 	    while (isdigit((unsigned char)*fmt))
@@ -668,10 +673,10 @@
 	case 'C':
 	  {
 	    const char *s;
-	    s = unistr(buf, &stringlen, unicodestr);
+	    s = unistr(ndo, buf, &stringlen, unicodestr);
 	    if (s == NULL)
 		goto trunc;
-	    printf("%s", s);
+	    ND_PRINT((ndo, "%s", s));
 	    buf += stringlen;
 	    fmt++;
 	    break;
@@ -679,9 +684,9 @@
 	case 'h':
 	  {
 	    int l = atoi(fmt + 1);
-	    TCHECK2(*buf, l);
+	    ND_TCHECK2(*buf, l);
 	    while (l--)
-		printf("%02x", *buf++);
+		ND_PRINT((ndo, "%02x", *buf++));
 	    fmt++;
 	    while (isdigit((unsigned char)*fmt))
 		fmt++;
@@ -696,22 +701,22 @@
 
 	    switch (t) {
 	    case 1:
-		name_type = name_extract(startbuf, PTR_DIFF(buf, startbuf),
+		name_type = name_extract(ndo, startbuf, PTR_DIFF(buf, startbuf),
 		    maxbuf, nbuf);
 		if (name_type < 0)
 		    goto trunc;
-		len = name_len(buf, maxbuf);
+		len = name_len(ndo, buf, maxbuf);
 		if (len < 0)
 		    goto trunc;
 		buf += len;
-		printf("%-15.15s NameType=0x%02X (%s)", nbuf, name_type,
-		    name_type_str(name_type));
+		ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", nbuf, name_type,
+		    name_type_str(name_type)));
 		break;
 	    case 2:
-		TCHECK(buf[15]);
+		ND_TCHECK(buf[15]);
 		name_type = buf[15];
-		printf("%-15.15s NameType=0x%02X (%s)", buf, name_type,
-		    name_type_str(name_type));
+		ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", buf, name_type,
+		    name_type_str(name_type)));
 		buf += 16;
 		break;
 	    }
@@ -725,11 +730,11 @@
 	    time_t t;
 	    struct tm *lt;
 	    const char *tstring;
-	    u_int32_t x;
+	    uint32_t x;
 
 	    switch (atoi(fmt + 1)) {
 	    case 1:
-		TCHECK2(buf[0], 4);
+		ND_TCHECK2(buf[0], 4);
 		x = EXTRACT_LE_32BITS(buf);
 		if (x == 0 || x == 0xFFFFFFFF)
 		    t = 0;
@@ -738,7 +743,7 @@
 		buf += 4;
 		break;
 	    case 2:
-		TCHECK2(buf[0], 4);
+		ND_TCHECK2(buf[0], 4);
 		x = EXTRACT_LE_32BITS(buf);
 		if (x == 0 || x == 0xFFFFFFFF)
 		    t = 0;
@@ -747,7 +752,7 @@
 		buf += 4;
 		break;
 	    case 3:
-		TCHECK2(buf[0], 8);
+		ND_TCHECK2(buf[0], 8);
 		t = interpret_long_date(buf);
 		buf += 8;
 		break;
@@ -763,33 +768,34 @@
 		    tstring = "(Can't convert time)\n";
 	    } else
 		tstring = "NULL\n";
-	    printf("%s", tstring);
+	    ND_PRINT((ndo, "%s", tstring));
 	    fmt++;
 	    while (isdigit((unsigned char)*fmt))
 		fmt++;
 	    break;
 	  }
 	default:
-	    putchar(*fmt);
+	    ND_PRINT((ndo, "%c", *fmt));
 	    fmt++;
 	    break;
 	}
     }
 
     if (buf >= maxbuf && *fmt)
-	printf("END OF BUFFER\n");
+	ND_PRINT((ndo, "END OF BUFFER\n"));
 
     return(buf);
 
 trunc:
-    printf("\n");
-    printf("WARNING: Short packet. Try increasing the snap length\n");
+    ND_PRINT((ndo, "\n"));
+    ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n"));
     return(NULL);
 }
 
 const u_char *
-smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
-    int unicodestr)
+smb_fdata(netdissect_options *ndo,
+          const u_char *buf, const char *fmt, const u_char *maxbuf,
+          int unicodestr)
 {
     static int depth = 0;
     char s[128];
@@ -802,7 +808,7 @@
 	    while (buf < maxbuf) {
 		const u_char *buf2;
 		depth++;
-		buf2 = smb_fdata(buf, fmt, maxbuf, unicodestr);
+		buf2 = smb_fdata(ndo, buf, fmt, maxbuf, unicodestr);
 		depth--;
 		if (buf2 == NULL)
 		    return(NULL);
@@ -841,22 +847,21 @@
 	    strncpy(s, fmt, p - fmt);
 	    s[p - fmt] = '\0';
 	    fmt = p + 1;
-	    buf = smb_fdata1(buf, s, maxbuf, unicodestr);
+	    buf = smb_fdata1(ndo, buf, s, maxbuf, unicodestr);
 	    if (buf == NULL)
 		return(NULL);
 	    break;
 
 	default:
-	    putchar(*fmt);
+	    ND_PRINT((ndo, "%c", *fmt));
 	    fmt++;
-	    fflush(stdout);
 	    break;
 	}
     }
     if (!depth && buf < maxbuf) {
 	size_t len = PTR_DIFF(maxbuf, buf);
-	printf("Data: (%lu bytes)\n", (unsigned long)len);
-	print_data(buf, len);
+	ND_PRINT((ndo, "Data: (%lu bytes)\n", (unsigned long)len));
+	print_data(ndo, buf, len);
 	return(buf + len);
     }
     return(buf);
@@ -1008,7 +1013,7 @@
 }
 
 typedef struct {
-    u_int32_t code;
+    uint32_t code;
     const char *name;
 } nt_err_code_struct;
 
@@ -1872,7 +1877,7 @@
  * return an NT error string from a SMB buffer
  */
 const char *
-nt_errstr(u_int32_t err)
+nt_errstr(uint32_t err)
 {
     static char ret[128];
     int i;
diff --git a/strcasecmp.c b/strcasecmp.c
index 5504e0a..7ee4e38 100644
--- a/strcasecmp.c
+++ b/strcasecmp.c
@@ -14,11 +14,6 @@
 #include "config.h"
 #endif
 
-#ifndef lint
-static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/strcasecmp.c,v 1.6 2003-11-16 09:36:43 guy Exp $";
-#endif
-
 #include <tcpdump-stdinc.h>
 
 #include "interface.h"
diff --git a/tcp.h b/tcp.h
index 777118f..c18d138 100644
--- a/tcp.h
+++ b/tcp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.14 2007-12-09 00:30:47 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -34,21 +33,21 @@
  *	@(#)tcp.h	8.1 (Berkeley) 6/10/93
  */
 
-typedef	u_int32_t	tcp_seq;
+typedef	uint32_t	tcp_seq;
 /*
  * TCP header.
  * Per RFC 793, September, 1981.
  */
 struct tcphdr {
-	u_int16_t	th_sport;		/* source port */
-	u_int16_t	th_dport;		/* destination port */
+	uint16_t	th_sport;		/* source port */
+	uint16_t	th_dport;		/* destination port */
 	tcp_seq		th_seq;			/* sequence number */
 	tcp_seq		th_ack;			/* acknowledgement number */
-	u_int8_t	th_offx2;		/* data offset, rsvd */
-	u_int8_t	th_flags;
-	u_int16_t	th_win;			/* window */
-	u_int16_t	th_sum;			/* checksum */
-	u_int16_t	th_urp;			/* urgent pointer */
+	uint8_t		th_offx2;		/* data offset, rsvd */
+	uint8_t		th_flags;
+	uint16_t	th_win;			/* window */
+	uint16_t	th_sum;			/* checksum */
+	uint16_t	th_urp;			/* urgent pointer */
 } UNALIGNED;
 
 #define TH_OFF(th)	(((th)->th_offx2 & 0xf0) >> 4)
@@ -94,12 +93,18 @@
 #ifndef TELNET_PORT
 #define TELNET_PORT             23
 #endif
+#ifndef SMTP_PORT
+#define SMTP_PORT		25
+#endif
 #ifndef BGP_PORT
 #define BGP_PORT                179
 #endif
 #define NETBIOS_SSN_PORT        139
-#ifndef OPENFLOW_PORT
-#define OPENFLOW_PORT           6633
+#ifndef OPENFLOW_PORT_OLD
+#define OPENFLOW_PORT_OLD       6633
+#endif
+#ifndef OPENFLOW_PORT_IANA
+#define OPENFLOW_PORT_IANA      6653
 #endif
 #ifndef PPTP_PORT
 #define PPTP_PORT	        1723
@@ -114,3 +119,18 @@
 #ifndef SMB_PORT
 #define SMB_PORT                445
 #endif
+#ifndef HTTP_PORT
+#define HTTP_PORT		80
+#endif
+#ifndef HTTP_PORT_ALT
+#define HTTP_PORT_ALT		8080
+#endif
+#ifndef RTSP_PORT
+#define RTSP_PORT		554
+#endif
+#ifndef RTSP_PORT_ALT
+#define RTSP_PORT_ALT		8554
+#endif
+#ifndef FTP_PORT
+#define FTP_PORT		21
+#endif
diff --git a/tcpdump-stdinc.h b/tcpdump-stdinc.h
index 4866b59..32f8fc9 100644
--- a/tcpdump-stdinc.h
+++ b/tcpdump-stdinc.h
@@ -27,27 +27,27 @@
  * 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.
- *
- *
- * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.18 2007-11-24 18:13:33 mcr Exp $ (LBL)
  */
 
 /*
  * Include the appropriate OS header files on Windows and various flavors
- * of UNIX, and also define some additional items and include various
- * non-OS header files on Windows, and; this isolates most of the platform
+ * of UNIX, include various non-OS header files on Windows, and define
+ * various items as needed, to isolate most of tcpdump's platform
  * differences to this one file.
  */
 
 #ifndef tcpdump_stdinc_h
 #define tcpdump_stdinc_h
 
+#include <errno.h>
+
 #ifdef WIN32
 
+#include <stdint.h>
 #include <stdio.h>
 #include <winsock2.h>
-#include <Ws2tcpip.h>
-#include "bittypes.h"
+#include <ws2tcpip.h>
+#include "bittypes.h"   /* in wpcap's Win32/include */
 #include <ctype.h>
 #include <time.h>
 #include <io.h>
@@ -55,22 +55,92 @@
 #include <sys/types.h>
 #include <net/netdb.h>  /* in wpcap's Win32/include */
 
-#ifndef NBBY
-#define NBBY	8
+#ifndef uint8_t
+#define uint8_t		unsigned char
 #endif
 
-#if !defined(__MINGW32__) && !defined(__WATCOMC__)
+#ifndef int8_t
+#define int8_t		signed char
+#endif
+
+#ifndef uint16_t
+#define uint16_t	unsigned short
+#endif
+
+#ifndef int16_t
+#define int16_t		signed short
+#endif
+
+#ifndef uint32_t
+#define uint32_t	unsigned int
+#endif
+
+#ifndef int32_t
+#define int32_t		signed int
+#endif
+
+#ifdef _MSC_EXTENSIONS
+
+#ifndef uint64_t
+#define uint64_t	unsigned _int64
+#endif
+
+#ifndef int64_t
+#define int64_t		_int64
+#endif
+
+#ifndef PRId64
+#define PRId64		"I64d"
+#endif
+
+#ifndef PRIo64
+#define PRIo64		"I64o"
+#endif
+
+#ifndef PRIu64
+#define PRIu64		"I64u"
+#endif
+
+#ifndef PRIx64
+#define PRIx64		"I64x"
+#endif
+
+#else /* _MSC_EXTENSIONS */
+
+#ifndef uint64_t
+#define uint64_t	unsigned long long
+#endif
+
+#ifndef int64_t
+#define int64_t		long long
+#endif
+
+#ifndef PRId64
+#define PRId64		"lld"
+#endif
+
+#ifndef PRIo64
+#define PRIo64		"llo"
+#endif
+
+#ifndef PRIu64
+#define PRIu64		"llu"
+#endif
+
+#ifndef PRIx64
+#define PRIx64		"llx"
+#endif
+
+#endif /* _MSC_EXTENSIONS */
+
+#ifdef _MSC_VER
 #define stat _stat
 #define open _open
 #define fstat _fstat
 #define read _read
 #define close _close
 #define O_RDONLY _O_RDONLY
-#endif /* __MINGW32__ */
-
-#ifdef __MINGW32__
-#include <stdint.h>
-#endif
+#endif  /* _MSC_VER */
 
 /* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
  * should be used, but it clashes with <ws2tcpip.h>).
@@ -90,6 +160,12 @@
 #define INET6_ADDRSTRLEN 46
 #endif
 
+/* It is in MSVC's <errno.h>, but not defined in MingW+Watcom.
+ */
+#ifndef EAFNOSUPPORT
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
+#endif
+
 #ifndef caddr_t
 typedef char* caddr_t;
 #endif /* caddr_t */
@@ -107,14 +183,9 @@
 #include <netdb.h>
 #if HAVE_INTTYPES_H
 #include <inttypes.h>
-#else
-#if HAVE_STDINT_H
+#elif HAVE_STDINT_H
 #include <stdint.h>
 #endif
-#endif
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
 #include <sys/param.h>
 #include <sys/types.h>			/* concession to AIX */
 #include <sys/time.h>
@@ -127,14 +198,6 @@
 
 #include <arpa/inet.h>
 
-#ifndef NBBY
-#define NBBY	8
-#endif
-
-/* Doesn't exist on Android. */
-#define setprotoent(...)
-#define endprotoent(...)
-
 #endif /* WIN32 */
 
 #ifndef HAVE___ATTRIBUTE__
@@ -172,9 +235,9 @@
  * Note: this also requires that padding be put into the structure,
  * at least for compilers where it's implemented as __attribute__((packed)).
  */
-#if defined(_MSC_VER) && defined(UNALIGNED)
+#if !(defined(_MSC_VER) && defined(UNALIGNED))
 /* MSVC may have its own macro defined with the same name and purpose. */
-#else
+#undef UNALIGNED
 #define UNALIGNED	__attribute__((packed))
 #endif
 
@@ -190,7 +253,7 @@
   #define FOPEN_WRITE_BIN  FOPEN_WRITE_TXT
 #endif
 
-#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl) 
+#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
   #undef ntohl
   #undef ntohs
   #undef htonl
@@ -279,4 +342,11 @@
  * end of Apple deprecation workaround macros
  */
 
+#ifndef min
+#define min(a,b) ((a)>(b)?(b):(a))
+#endif
+#ifndef max
+#define max(a,b) ((b)>(a)?(b):(a))
+#endif
+
 #endif /* tcpdump_stdinc_h */
diff --git a/tcpdump.1.in b/tcpdump.1.in
index be807c5..f9522cb 100644
--- a/tcpdump.1.in
+++ b/tcpdump.1.in
@@ -1,5 +1,3 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1.in,v 1.2 2008-11-09 23:35:03 mcr Exp $ (LBL)
-.\"
 .\"	$NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
 .\"
 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
@@ -22,18 +20,21 @@
 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.TH TCPDUMP 1  "3 February 2014"
+.TH TCPDUMP 1  "11 July 2014"
 .SH NAME
 tcpdump \- dump traffic on a network
 .SH SYNOPSIS
 .na
 .B tcpdump
 [
-.B \-AbdDefhHIJKlLnNOpqRStuUvxX
+.B \-AbdDefhHIJKlLnNOpqRStuUvxX#
 ] [
 .B \-B
 .I buffer_size
-] [
+]
+.br
+.ti +8
+[
 .B \-c
 .I count
 ]
@@ -70,6 +71,9 @@
 .br
 .ti +8
 [
+.B \-\-number
+]
+[
 .B \-Q
 .I in|out|inout
 ]
@@ -122,6 +126,17 @@
 ]
 .ti +8
 [
+.BI \-\-time\-stamp\-precision= tstamp_precision
+]
+.ti +8
+[
+.B \-\-immediate\-mode
+]
+[
+.B \-\-version
+]
+.ti +8
+[
 .I expression
 ]
 .br
@@ -129,7 +144,9 @@
 .SH DESCRIPTION
 .LP
 \fITcpdump\fP prints out a description of the contents of packets on a
-network interface that match the boolean \fIexpression\fP.  It can also
+network interface that match the boolean \fIexpression\fP; the
+description is preceded by a time stamp, printed, by default, as hours,
+minutes, seconds, and fractions of a second since midnight.  It can also
 be run with the
 .B \-w
 flag, which causes it to save the packet data to a file for later
@@ -193,7 +210,9 @@
 platforms, such as Mac OS X, the ``status'' character is not set by
 default, so you must set it with
 .BR stty (1)
-in order to use it) and will continue capturing packets.
+in order to use it) and will continue capturing packets. On platforms that
+do not support the SIGINFO signal, the same can be achieved by using the
+SIGUSR1 signal.
 .LP
 Reading packets from a network interface may require that you have
 special privileges; see the
@@ -210,14 +229,18 @@
 Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN
 notation.
 .TP
-.B \-B
+.BI \-B " buffer_size"
+.PD 0
+.TP
+.BI \-\-buffer\-size= buffer_size
+.PD
 Set the operating system capture buffer size to \fIbuffer_size\fP, in
 units of KiB (1024 bytes).
 .TP
-.B \-c
+.BI \-c " count"
 Exit after receiving \fIcount\fP packets.
 .TP
-.B \-C
+.BI \-C " file_size"
 Before writing a raw packet to a savefile, check whether the file is
 currently larger than \fIfile_size\fP and, if so, close the current
 savefile and open a new one.  Savefiles after the first savefile will
@@ -240,6 +263,10 @@
 Dump packet-matching code as decimal numbers (preceded with a count).
 .TP
 .B \-D
+.PD 0
+.TP
+.B \-\-list\-interfaces
+.PD
 Print the list of the network interfaces available on the system and on
 which
 .I tcpdump
@@ -319,11 +346,11 @@
 can capture on more than one interface, this option will not work
 correctly.
 .TP
-.B \-F
+.BI \-F " file"
 Use \fIfile\fP as input for the filter expression.
 An additional expression given on the command line is ignored.
 .TP
-.B \-G
+.BI \-G " rotate_seconds"
 If specified, rotates the dump file specified with the
 .B \-w
 option every \fIrotate_seconds\fP seconds.
@@ -338,13 +365,25 @@
 option, filenames will take the form of `\fIfile\fP<count>'.
 .TP
 .B \-h
+.PD 0
+.TP
+.B \-\-help
+.PD
 Print the tcpdump and libpcap version strings, print a usage message,
 and exit.
 .TP
+.B \-\-version
+.PD
+Print the tcpdump and libpcap version strings and exit.
+.TP
 .B \-H
 Attempt to detect 802.11s draft mesh headers.
 .TP
-.B \-i
+.BI \-i " interface"
+.PD 0
+.TP
+.BI \-\-interface= interface
+.PD
 Listen on \fIinterface\fP.
 If unspecified, \fItcpdump\fP searches the system interface list for the
 lowest numbered, configured up interface (excluding loopback), which may turn
@@ -364,6 +403,10 @@
 argument.
 .TP
 .B \-I
+.PD 0
+.TP
+.B \-\-monitor\-mode
+.PD
 Put the interface in "monitor mode"; this is supported only on IEEE
 802.11 Wi-Fi interfaces, and supported only on some operating systems.
 .IP
@@ -384,7 +427,18 @@
 is specified, only those link-layer types available when in monitor mode
 will be shown.
 .TP
-.B \-j
+.BI \-\-immediate\-mode
+Capture in "immediate mode".  In this mode, packets are delivered to
+tcpdump as soon as they arrive, rather than being buffered for
+efficiency.  This is the default when printing packets rather than
+saving packets to a ``savefile'' if the packets are being printed to a
+terminal rather than to a file or pipe.
+.TP
+.BI \-j " tstamp_type"
+.PD 0
+.TP
+.BI \-\-time\-stamp\-type= tstamp_type
+.PD
 Set the time stamp type for the capture to \fItstamp_type\fP.  The names
 to use for the time stamp types are given in
 .BR pcap-tstamp (@MAN_MISC_INFO@);
@@ -392,11 +446,38 @@
 interface.
 .TP
 .B \-J
+.PD 0
+.TP
+.B \-\-list\-time\-stamp\-types
+.PD
 List the supported time stamp types for the interface and exit.  If the
 time stamp type cannot be set for the interface, no time stamp types are
 listed.
 .TP
+.BI \-\-time\-stamp\-precision= tstamp_precision
+When capturing, set the time stamp precision for the capture to
+\fItstamp_precision\fP.  Note that availability of high precision time
+stamps (nanoseconds) and their actual accuracy is platform and hardware
+dependent.  Also note that when writing captures made with nanosecond
+accuracy to a savefile, the time stamps are written with nanosecond
+resolution, and the file is written with a different magic number, to
+indicate that the time stamps are in seconds and nanoseconds; not all
+programs that read pcap savefiles will be able to read those captures.
+.LP
+When reading a savefile, convert time stamps to the precision specified
+by \fItimestamp_precision\fP, and display them with that resolution.  If
+the precision specified is less than the precision of time stamps in the
+file, the conversion will lose precision.
+.LP
+The supported values for \fItimestamp_precision\fP are \fBmicro\fP for
+microsecond resolution and \fBnano\fP for nanosecond resolution.  The
+default is microsecond resolution.
+.TP
 .B \-K
+.PD 0
+.TP
+.B \-\-dont\-verify\-checksums
+.PD
 Don't attempt to verify IP, TCP, or UDP checksums.  This is useful for
 interfaces that perform some or all of those checksum calculation in
 hardware; otherwise, all outgoing TCP checksums will be flagged as bad.
@@ -439,6 +520,10 @@
 including Windows.
 .TP
 .B \-L
+.PD 0
+.TP
+.B \-\-list\-data\-link\-types
+.PD
 List the known data link types for the interface, in the specified mode,
 and exit.  The list of known data link types may be dependent on the
 specified mode; for example, on some platforms, a Wi-Fi interface might
@@ -449,12 +534,12 @@
 might support 802.11 headers, or 802.11 headers with radio information,
 only in monitor mode).
 .TP
-.B \-m
+.BI \-m " module"
 Load SMI MIB module definitions from file \fImodule\fR.
 This option
 can be used several times to load several MIB modules into \fItcpdump\fP.
 .TP
-.B \-M
+.BI \-M " secret"
 Use \fIsecret\fP as a shared secret for validating the digests found in
 TCP segments with the TCP-MD5 option (RFC 2385), if present.
 .TP
@@ -467,19 +552,38 @@
 if you give this flag then \fItcpdump\fP will print ``nic''
 instead of ``nic.ddn.mil''.
 .TP
+.B \-#
+.PD 0
+.TP
+.B \-\-number
+.PD
+Print an optional packet number at the beginning of the line.
+.TP
 .B \-O
+.PD 0
+.TP
+.B \-\-no\-optimize
+.PD
 Do not run the packet-matching code optimizer.
 This is useful only
 if you suspect a bug in the optimizer.
 .TP
 .B \-p
+.PD 0
+.TP
+.B \-\-no\-promiscuous\-mode
+.PD
 \fIDon't\fP put the interface
 into promiscuous mode.
 Note that the interface might be in promiscuous
 mode for some other reason; hence, `-p' cannot be used as an abbreviation for
 `ether host {local-hw-addr} or ether broadcast'.
 .TP
-.B \-Q
+.BI \-Q " direction"
+.PD 0
+.TP
+.BI \-\-direction= direction
+.PD
 Choose send/receive direction \fIdirection\fR for which packets should be
 captured. Possible values are `in', `out' and `inout'. Not available
 on all platforms.
@@ -495,16 +599,24 @@
 Since there is no protocol version field in ESP/AH specification,
 \fItcpdump\fP cannot deduce the version of ESP/AH protocol.
 .TP
-.B \-r
+.BI \-r " file"
 Read packets from \fIfile\fR (which was created with the
 .B \-w
-option).
+option or by other tools that write pcap or pcap-ng files).
 Standard input is used if \fIfile\fR is ``-''.
 .TP
 .B \-S
+.PD 0
+.TP
+.B \-\-absolute\-tcp\-sequence\-numbers
+.PD
 Print absolute, rather than relative, TCP sequence numbers.
 .TP
-.B \-s
+.BI \-s " snaplen"
+.PD 0
+.TP
+.BI \-\-snapshot\-length= snaplen
+.PD
 Snarf \fIsnaplen\fP bytes of data from each packet rather than the
 default of 65535 bytes.
 Packets truncated because of a limited snapshot
@@ -522,7 +634,7 @@
 for backwards compatibility with recent older versions of
 .IR tcpdump .
 .TP
-.B \-T
+.BI \-T " type"
 Force packets selected by "\fIexpression\fP" to be interpreted the
 specified \fItype\fR.
 Currently known types are
@@ -558,14 +670,16 @@
 \fIDon't\fP print a timestamp on each dump line.
 .TP
 .B \-tt
-Print an unformatted timestamp on each dump line.
+Print the timestamp, as seconds since January 1, 1970, 00:00:00, UTC, and
+fractions of a second since that time, on each dump line.
 .TP
 .B \-ttt
 Print a delta (micro-second resolution) between current and previous line
 on each dump line.
 .TP
 .B \-tttt
-Print a timestamp in default format proceeded by date on each dump line.
+Print a timestamp, as hours, minutes, seconds, and fractions of a second
+since midnight, preceded by the date, on each dump line.
 .TP
 .B \-ttttt
 Print a delta (micro-second resolution) between current and first line
@@ -575,6 +689,10 @@
 Print undecoded NFS handles.
 .TP
 .B \-U
+.PD 0
+.TP
+.B \-\-packet\-buffered
+.PD
 If the
 .B \-w
 option is not specified, make the printed packet output
@@ -625,11 +743,11 @@
 .B \-X
 Telnet options are printed in hex as well.
 .TP
-.B \-V
+.BI \-V " file"
 Read a list of filenames from \fIfile\fR. Standard input is used
 if \fIfile\fR is ``-''.
 .TP
-.B \-w
+.BI \-w " file"
 Write the raw packets to \fIfile\fR rather than parsing and printing
 them out.
 They can later be printed with the \-r option.
@@ -702,10 +820,14 @@
 .I including
 its link level header, in hex and ASCII.
 .TP
-.B \-y
+.BI \-y " datalinktype"
+.PD 0
+.TP
+.BI \-\-linktype= datalinktype
+.PD
 Set the data link type to use while capturing packets to \fIdatalinktype\fP.
 .TP
-.B \-z
+.BI \-z " postrotate-command"
 Used in conjunction with the
 .B -C
 or
@@ -713,7 +835,7 @@
 options, this will make
 .I tcpdump
 run "
-.I command file
+.I postrotate-command file
 " where
 .I file
 is the savefile being closed after each rotation. For example, specifying
@@ -730,7 +852,11 @@
 savefile name as the only argument, make the flags & arguments arrangements
 and execute the command that you want.
 .TP
-.B \-Z
+.BI \-Z " user"
+.PD 0
+.TP
+.BI \-\-relinquish\-privileges= user
+.PD
 If
 .I tcpdump
 is running as root, after opening the capture device or input savefile,
@@ -1412,39 +1538,45 @@
 .RS
 .nf
 .sp .5
-\fIsrc.xid > dst.nfs: len op args\fP
-\fIsrc.nfs > dst.xid: reply stat len op results\fP
+\fIsrc.sport > dst.nfs: NFS request xid xid len op args\fP
+\fIsrc.nfs > dst.dport: NFS reply xid xid reply stat len op results\fP
 .sp .5
 \f(CW
-sushi.6709 > wrl.nfs: 112 readlink fh 21,24/10.73165
-wrl.nfs > sushi.6709: reply ok 40 readlink "../var"
-sushi.201b > wrl.nfs:
+sushi.1023 > wrl.nfs: NFS request xid 26377
+	112 readlink fh 21,24/10.73165
+wrl.nfs > sushi.1023: NFS reply xid 26377
+	reply ok 40 readlink "../var"
+sushi.1022 > wrl.nfs: NFS request xid 8219
 	144 lookup fh 9,74/4096.6878 "xcolors"
-wrl.nfs > sushi.201b:
+wrl.nfs > sushi.1022: NFS reply xid 8219
 	reply ok 128 lookup fh 9,74/4134.3150
 \fR
 .sp .5
 .fi
 .RE
-In the first line, host \fIsushi\fP sends a transaction with id \fI6709\fP
-to \fIwrl\fP (note that the number following the src host is a
-transaction id, \fInot\fP the source port).
+In the first line, host \fIsushi\fP sends a transaction with id \fI26377\fP
+to \fIwrl\fP.
 The request was 112 bytes,
 excluding the UDP and IP headers.
 The operation was a \fIreadlink\fP
 (read symbolic link) on file handle (\fIfh\fP) 21,24/10.731657119.
 (If one is lucky, as in this case, the file handle can be interpreted
 as a major,minor device number pair, followed by the inode number and
-generation number.)
-\fIWrl\fP replies `ok' with the contents of the link.
+generation number.) In the second line, \fIwrl\fP replies `ok' with
+the same transaction id and the contents of the link.
 .LP
-In the third line, \fIsushi\fP asks \fIwrl\fP to lookup the name
-`\fIxcolors\fP' in directory file 9,74/4096.6878.
+In the third line, \fIsushi\fP asks (using a new transaction id) \fIwrl\fP
+to lookup the name `\fIxcolors\fP' in directory file 9,74/4096.6878. In
+the fourth line, \fIwrl\fP sends a reply with the respective transaction id.
+.LP
 Note that the data printed
 depends on the operation type.
 The format is intended to be self
 explanatory if read in conjunction with
 an NFS protocol spec.
+Also note that older versions of tcpdump printed NFS packets in a
+slightly different format: the transaction id (xid) would be printed
+instead of the non-NFS port number of the packet.
 .LP
 If the \-v (verbose) flag is given, additional information is printed.
 For example:
@@ -1452,9 +1584,9 @@
 .nf
 .sp .5
 \f(CW
-sushi.1372a > wrl.nfs:
+sushi.1023 > wrl.nfs: NFS request xid 79658
 	148 read fh 21,11/12.195 8192 bytes @ 24576
-wrl.nfs > sushi.1372a:
+wrl.nfs > sushi.1023: NFS reply xid 79658
 	reply ok 1472 read REG 100664 ids 417/0 sz 29388
 \fP
 .sp .5
diff --git a/tcpdump.c b/tcpdump.c
index a92bfe0..2b71d27 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -29,8 +29,6 @@
 static const char copyright[] _U_ =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
 The Regents of the University of California.  All rights reserved.\n";
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.283 2008-09-25 21:45:50 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -45,10 +43,20 @@
 #include "config.h"
 #endif
 
+/*
+ * Mac OS X may ship pcap.h from libpcap 0.6 with a libpcap based on
+ * 0.8.  That means it has pcap_findalldevs() but the header doesn't
+ * define pcap_if_t, meaning that we can't actually *use* pcap_findalldevs().
+ */
+#ifdef HAVE_PCAP_FINDALLDEVS
+#ifndef HAVE_PCAP_IF_T
+#undef HAVE_PCAP_FINDALLDEVS
+#endif
+#endif
+
 #include <tcpdump-stdinc.h>
 
 #ifdef WIN32
-#include "getopt.h"
 #include "w32_fzs.h"
 extern int strcasecmp (const char *__s1, const char *__s2);
 extern int SIZE_BUF;
@@ -56,10 +64,30 @@
 #define uint UINT
 #endif /* WIN32 */
 
-#ifdef HAVE_SMI_H
+#ifdef USE_LIBSMI
 #include <smi.h>
 #endif
 
+#ifdef HAVE_LIBCRYPTO
+#include <openssl/crypto.h>
+#endif
+
+#ifdef HAVE_GETOPT_LONG
+#include <getopt.h>
+#else
+#include "getopt_long.h"
+#endif
+/* Capsicum-specific code requires macros from <net/bpf.h>, which will fail
+ * to compile if <pcap.h> has already been included; including the headers
+ * in the opposite order works fine.
+ */
+#ifdef HAVE_CAPSICUM
+#include <sys/capability.h>
+#include <sys/ioccom.h>
+#include <net/bpf.h>
+#include <fcntl.h>
+#include <libgen.h>
+#endif	/* HAVE_CAPSICUM */
 #include <pcap.h>
 #include <signal.h>
 #include <stdio.h>
@@ -71,13 +99,20 @@
 #include <sys/resource.h>
 #include <pwd.h>
 #include <grp.h>
-#include <errno.h>
 #endif /* WIN32 */
 
-/* capabilities convinience library */
+/* capabilities convenience library */
+/* If a code depends on HAVE_LIBCAP_NG, it depends also on HAVE_CAP_NG_H.
+ * If HAVE_CAP_NG_H is not defined, undefine HAVE_LIBCAP_NG.
+ * Thus, the later tests are done only on HAVE_LIBCAP_NG.
+ */
+#ifdef HAVE_LIBCAP_NG
 #ifdef HAVE_CAP_NG_H
 #include <cap-ng.h>
+#else
+#undef HAVE_LIBCAP_NG
 #endif /* HAVE_CAP_NG_H */
+#endif /* HAVE_LIBCAP_NG */
 
 #include "netdissect.h"
 #include "interface.h"
@@ -100,13 +135,14 @@
 netdissect_options Gndo;
 netdissect_options *gndo = &Gndo;
 
+static int Dflag;			/* list available devices and exit */
 static int dflag;			/* print filter code */
 static int Lflag;			/* list available data link types and exit */
 #ifdef HAVE_PCAP_SET_TSTAMP_TYPE
 static int Jflag;			/* list available time stamp types */
 #endif
 #ifdef HAVE_PCAP_SETDIRECTION
-int Pflag = -1;	/* Restrict captured packet by sent/receive direction */
+int Qflag = -1;				/* restrict captured packet by send/receive direction */
 #endif
 static char *zflag = NULL;		/* compress each savefile using a specified command (like gzip or bzip2) */
 
@@ -120,7 +156,8 @@
 /* Forwards */
 static RETSIGTYPE cleanup(int);
 static RETSIGTYPE child_cleanup(int);
-static void usage(void) __attribute__((noreturn));
+static void print_version(void);
+static void print_usage(void);
 static void show_dlts_and_exit(const char *device, pcap_t *pd) __attribute__((noreturn));
 
 static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
@@ -129,8 +166,16 @@
 static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
 static void droproot(const char *, const char *);
 static void ndo_error(netdissect_options *ndo, const char *fmt, ...)
-     __attribute__ ((noreturn, format (printf, 2, 3)));
-static void ndo_warning(netdissect_options *ndo, const char *fmt, ...);
+     __attribute__((noreturn))
+#ifdef __ATTRIBUTE___FORMAT_OK
+     __attribute__((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+    ;
+static void ndo_warning(netdissect_options *ndo, const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+     __attribute__((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+    ;
 
 #ifdef SIGNAL_REQ_INFO
 RETSIGTYPE requestinfo(int);
@@ -159,14 +204,32 @@
 };
 
 
-static struct printer printers[] = {
-	{ arcnet_if_print,	DLT_ARCNET },
-#ifdef DLT_ARCNET_LINUX
-	{ arcnet_linux_if_print, DLT_ARCNET_LINUX },
+static const struct printer printers[] = {
+	{ NULL,			0 },
+};
+
+static const struct ndo_printer ndo_printers[] = {
+	{ ether_if_print,	DLT_EN10MB },
+#ifdef DLT_IPNET
+	{ ipnet_if_print,	DLT_IPNET },
 #endif
-	{ token_if_print,	DLT_IEEE802 },
-#ifdef DLT_LANE8023
-	{ lane_if_print,        DLT_LANE8023 },
+#ifdef DLT_IEEE802_15_4
+	{ ieee802_15_4_if_print, DLT_IEEE802_15_4 },
+#endif
+#ifdef DLT_IEEE802_15_4_NOFCS
+	{ ieee802_15_4_if_print, DLT_IEEE802_15_4_NOFCS },
+#endif
+#ifdef DLT_PPI
+	{ ppi_if_print,		DLT_PPI },
+#endif
+#ifdef DLT_NETANALYZER
+	{ netanalyzer_if_print, DLT_NETANALYZER },
+#endif
+#ifdef DLT_NETANALYZER_TRANSPARENT
+	{ netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
+#endif
+#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
+	{ nflog_if_print,	DLT_NFLOG},
 #endif
 #ifdef DLT_CIP
 	{ cip_if_print,         DLT_CIP },
@@ -174,77 +237,83 @@
 #ifdef DLT_ATM_CLIP
 	{ cip_if_print,		DLT_ATM_CLIP },
 #endif
-	{ sl_if_print,		DLT_SLIP },
-#ifdef DLT_SLIP_BSDOS
-	{ sl_bsdos_if_print,	DLT_SLIP_BSDOS },
+#ifdef DLT_IP_OVER_FC
+	{ ipfc_if_print,	DLT_IP_OVER_FC },
 #endif
-	{ ppp_if_print,		DLT_PPP },
-#ifdef DLT_PPP_WITHDIRECTION
-	{ ppp_if_print,		DLT_PPP_WITHDIRECTION },
-#endif
-#ifdef DLT_PPP_BSDOS
-	{ ppp_bsdos_if_print,	DLT_PPP_BSDOS },
-#endif
-	{ fddi_if_print,	DLT_FDDI },
 	{ null_if_print,	DLT_NULL },
 #ifdef DLT_LOOP
 	{ null_if_print,	DLT_LOOP },
 #endif
+#ifdef DLT_APPLE_IP_OVER_IEEE1394
+	{ ap1394_if_print,	DLT_APPLE_IP_OVER_IEEE1394 },
+#endif
+#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
+	{ bt_if_print,		DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#endif
+#ifdef DLT_LANE8023
+	{ lane_if_print,        DLT_LANE8023 },
+#endif
+	{ arcnet_if_print,	DLT_ARCNET },
+#ifdef DLT_ARCNET_LINUX
+	{ arcnet_linux_if_print, DLT_ARCNET_LINUX },
+#endif
 	{ raw_if_print,		DLT_RAW },
-	{ atm_if_print,		DLT_ATM_RFC1483 },
+#ifdef DLT_IPV4
+	{ raw_if_print,		DLT_IPV4 },
+#endif
+#ifdef DLT_IPV6
+	{ raw_if_print,		DLT_IPV6 },
+#endif
+#ifdef HAVE_PCAP_USB_H
+#ifdef DLT_USB_LINUX
+	{ usb_linux_48_byte_print, DLT_USB_LINUX},
+#endif /* DLT_USB_LINUX */
+#ifdef DLT_USB_LINUX_MMAPPED
+	{ usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
+#endif /* DLT_USB_LINUX_MMAPPED */
+#endif /* HAVE_PCAP_USB_H */
+#ifdef DLT_SYMANTEC_FIREWALL
+	{ symantec_if_print,	DLT_SYMANTEC_FIREWALL },
+#endif
 #ifdef DLT_C_HDLC
 	{ chdlc_if_print,	DLT_C_HDLC },
 #endif
 #ifdef DLT_HDLC
 	{ chdlc_if_print,	DLT_HDLC },
 #endif
-#ifdef DLT_PPP_SERIAL
-	{ ppp_hdlc_if_print,	DLT_PPP_SERIAL },
-#endif
 #ifdef DLT_PPP_ETHER
 	{ pppoe_if_print,	DLT_PPP_ETHER },
 #endif
-#ifdef DLT_LINUX_SLL
-	{ sll_if_print,		DLT_LINUX_SLL },
-#endif
-#ifdef DLT_IEEE802_11
-	{ ieee802_11_if_print,	DLT_IEEE802_11},
-#endif
-#ifdef DLT_LTALK
-	{ ltalk_if_print,	DLT_LTALK },
-#endif
 #if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
 	{ pflog_if_print,	DLT_PFLOG },
 #endif
+	{ token_if_print,	DLT_IEEE802 },
+	{ fddi_if_print,	DLT_FDDI },
+#ifdef DLT_LINUX_SLL
+	{ sll_if_print,		DLT_LINUX_SLL },
+#endif
 #ifdef DLT_FR
 	{ fr_if_print,		DLT_FR },
 #endif
 #ifdef DLT_FRELAY
 	{ fr_if_print,		DLT_FRELAY },
 #endif
+#ifdef DLT_MFR
+	{ mfr_if_print,		DLT_MFR },
+#endif
+	{ atm_if_print,		DLT_ATM_RFC1483 },
 #ifdef DLT_SUNATM
 	{ sunatm_if_print,	DLT_SUNATM },
 #endif
-#ifdef DLT_IP_OVER_FC
-	{ ipfc_if_print,	DLT_IP_OVER_FC },
-#endif
-#ifdef DLT_PRISM_HEADER
-	{ prism_if_print,	DLT_PRISM_HEADER },
-#endif
-#ifdef DLT_IEEE802_11_RADIO
-	{ ieee802_11_radio_if_print,	DLT_IEEE802_11_RADIO },
-#endif
 #ifdef DLT_ENC
 	{ enc_if_print,		DLT_ENC },
 #endif
-#ifdef DLT_SYMANTEC_FIREWALL
-	{ symantec_if_print,	DLT_SYMANTEC_FIREWALL },
+	{ sl_if_print,		DLT_SLIP },
+#ifdef DLT_SLIP_BSDOS
+	{ sl_bsdos_if_print,	DLT_SLIP_BSDOS },
 #endif
-#ifdef DLT_APPLE_IP_OVER_IEEE1394
-	{ ap1394_if_print,	DLT_APPLE_IP_OVER_IEEE1394 },
-#endif
-#ifdef DLT_IEEE802_11_RADIO_AVS
-	{ ieee802_11_radio_avs_if_print,	DLT_IEEE802_11_RADIO_AVS },
+#ifdef DLT_LTALK
+	{ ltalk_if_print,	DLT_LTALK },
 #endif
 #ifdef DLT_JUNIPER_ATM1
 	{ juniper_atm1_print,	DLT_JUNIPER_ATM1 },
@@ -291,59 +360,49 @@
 #ifdef DLT_JUNIPER_CHDLC
 	{ juniper_chdlc_print,	DLT_JUNIPER_CHDLC },
 #endif
-#ifdef DLT_MFR
-	{ mfr_if_print,		DLT_MFR },
+#ifdef DLT_PKTAP
+	{ pktap_if_print,	DLT_PKTAP },
 #endif
-#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
-	{ bt_if_print,		DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#ifdef DLT_IEEE802_11_RADIO
+	{ ieee802_11_radio_if_print,	DLT_IEEE802_11_RADIO },
 #endif
-#ifdef HAVE_PCAP_USB_H
-#ifdef DLT_USB_LINUX
-	{ usb_linux_48_byte_print, DLT_USB_LINUX},
-#endif /* DLT_USB_LINUX */
-#ifdef DLT_USB_LINUX_MMAPPED
-	{ usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
-#endif /* DLT_USB_LINUX_MMAPPED */
-#endif /* HAVE_PCAP_USB_H */
-#ifdef DLT_IPV4
-	{ raw_if_print,		DLT_IPV4 },
+#ifdef DLT_IEEE802_11
+	{ ieee802_11_if_print,	DLT_IEEE802_11},
 #endif
-#ifdef DLT_IPV6
-	{ raw_if_print,		DLT_IPV6 },
+#ifdef DLT_IEEE802_11_RADIO_AVS
+	{ ieee802_11_radio_avs_if_print,	DLT_IEEE802_11_RADIO_AVS },
+#endif
+#ifdef DLT_PRISM_HEADER
+	{ prism_if_print,	DLT_PRISM_HEADER },
+#endif
+	{ ppp_if_print,		DLT_PPP },
+#ifdef DLT_PPP_WITHDIRECTION
+	{ ppp_if_print,		DLT_PPP_WITHDIRECTION },
+#endif
+#ifdef DLT_PPP_BSDOS
+	{ ppp_bsdos_if_print,	DLT_PPP_BSDOS },
+#endif
+#ifdef DLT_PPP_SERIAL
+	{ ppp_hdlc_if_print,	DLT_PPP_SERIAL },
 #endif
 	{ NULL,			0 },
 };
 
-static struct ndo_printer ndo_printers[] = {
-	{ ether_if_print,	DLT_EN10MB },
-#ifdef DLT_IPNET
-	{ ipnet_if_print,	DLT_IPNET },
+static const struct tok status_flags[] = {
+#ifdef PCAP_IF_UP
+	{ PCAP_IF_UP,       "Up"       },
 #endif
-#ifdef DLT_IEEE802_15_4
-	{ ieee802_15_4_if_print, DLT_IEEE802_15_4 },
+#ifdef PCAP_IF_RUNNING
+	{ PCAP_IF_RUNNING,  "Running"  },
 #endif
-#ifdef DLT_IEEE802_15_4_NOFCS
-	{ ieee802_15_4_if_print, DLT_IEEE802_15_4_NOFCS },
-#endif
-#ifdef DLT_PPI
-	{ ppi_if_print,		DLT_PPI },
-#endif
-#ifdef DLT_NETANALYZER
-	{ netanalyzer_if_print, DLT_NETANALYZER },
-#endif
-#ifdef DLT_NETANALYZER_TRANSPARENT
-	{ netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
-#endif
-#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
-	{ nflog_if_print,	DLT_NFLOG},
-#endif
-	{ NULL,			0 },
+	{ PCAP_IF_LOOPBACK, "Loopback" },
+	{ 0, NULL }
 };
 
 if_printer
 lookup_printer(int type)
 {
-	struct printer *p;
+	const struct printer *p;
 
 	for (p = printers; p->f; ++p)
 		if (type == p->type)
@@ -356,12 +415,36 @@
 if_ndo_printer
 lookup_ndo_printer(int type)
 {
-	struct ndo_printer *p;
+	const struct ndo_printer *p;
 
 	for (p = ndo_printers; p->f; ++p)
 		if (type == p->type)
 			return p->f;
 
+#if defined(DLT_USER2) && defined(DLT_PKTAP)
+	/*
+	 * Apple incorrectly chose to use DLT_USER2 for their PKTAP
+	 * header.
+	 *
+	 * We map DLT_PKTAP, whether it's DLT_USER2 as it is on Darwin-
+	 * based OSes or the same value as LINKTYPE_PKTAP as it is on
+	 * other OSes, to LINKTYPE_PKTAP, so files written with
+	 * this version of libpcap for a DLT_PKTAP capture have a link-
+	 * layer header type of LINKTYPE_PKTAP.
+	 *
+	 * However, files written on OS X Mavericks for a DLT_PKTAP
+	 * capture have a link-layer header type of LINKTYPE_USER2.
+	 * If we don't have a printer for DLT_USER2, and type is
+	 * DLT_USER2, we look up the printer for DLT_PKTAP and use
+	 * that.
+	 */
+	if (type == DLT_USER2) {
+		for (p = ndo_printers; p->f; ++p)
+			if (DLT_PKTAP == p->type)
+				return p->f;
+	}
+#endif
+
 	return NULL;
 	/* NOTREACHED */
 }
@@ -388,6 +471,9 @@
 	char	*CurrentFileName;
 	pcap_t	*pd;
 	pcap_dumper_t *p;
+#ifdef HAVE_CAPSICUM
+	int	dirfd;
+#endif
 };
 
 #ifdef HAVE_PCAP_SET_TSTAMP_TYPE
@@ -477,6 +563,61 @@
 	exit(0);
 }
 
+#ifdef HAVE_PCAP_FINDALLDEVS
+static void
+show_devices_and_exit (void)
+{
+	pcap_if_t *devpointer;
+	char ebuf[PCAP_ERRBUF_SIZE];
+	int i;
+
+	if (pcap_findalldevs(&devpointer, ebuf) < 0)
+		error("%s", ebuf);
+	else {
+		for (i = 0; devpointer != NULL; i++) {
+			printf("%d.%s", i+1, devpointer->name);
+			if (devpointer->description != NULL)
+				printf(" (%s)", devpointer->description);
+			if (devpointer->flags != 0)
+				printf(" [%s]", bittok2str(status_flags, "none", devpointer->flags));
+			printf("\n");
+			devpointer = devpointer->next;
+		}
+	}
+	exit(0);
+}
+#endif /* HAVE_PCAP_FINDALLDEVS */
+
+/*
+ * Short options.
+ *
+ * Note that there we use all letters for short options except for g, k,
+ * o, and P, and those are used by other versions of tcpdump, and we should
+ * only use them for the same purposes that the other versions of tcpdump
+ * use them:
+ *
+ * OS X tcpdump uses -g to force non--v output for IP to be on one
+ * line, making it more "g"repable;
+ *
+ * OS X tcpdump uses -k tospecify that packet comments in pcap-ng files
+ * should be printed;
+ *
+ * OpenBSD tcpdump uses -o to indicate that OS fingerprinting should be done
+ * for hosts sending TCP SYN packets;
+ *
+ * OS X tcpdump uses -P to indicate that -w should write pcap-ng rather
+ * than pcap files.
+ *
+ * OS X tcpdump also uses -Q to specify expressions that match packet
+ * metadata, including but not limited to the packet direction.
+ * The expression syntax is different from a simple "in|out|inout",
+ * and those expressions aren't accepted by OS X tcpdump, but the
+ * equivalents would be "in" = "dir=in", "out" = "dir=out", and
+ * "inout" = "dir=in or dir=out", and the parser could conceivably
+ * special-case "in", "out", and "inout" as expressions for backwards
+ * compatibility, so all is not (yet) lost.
+ */
+
 /*
  * Set up flags that might or might not be supported depending on the
  * version of libpcap we're using.
@@ -506,12 +647,6 @@
 #endif /* PCAP_ERROR_TSTAMP_TYPE_NOTSUP */
 
 #ifdef HAVE_PCAP_FINDALLDEVS
-#ifndef HAVE_PCAP_IF_T
-#undef HAVE_PCAP_FINDALLDEVS
-#endif
-#endif
-
-#ifdef HAVE_PCAP_FINDALLDEVS
 #define D_FLAG	"D"
 #else
 #define D_FLAG
@@ -524,13 +659,79 @@
 #endif
 
 #ifdef HAVE_PCAP_SETDIRECTION
-#define P_FLAG "P:"
 #define Q_FLAG "Q:"
 #else
-#define P_FLAG
 #define Q_FLAG
 #endif
 
+#define SHORTOPTS "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:Rs:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#"
+
+/*
+ * Long options.
+ *
+ * We do not currently have long options corresponding to all short
+ * options; we should probably pick appropriate option names for them.
+ *
+ * However, the short options where the number of times the option is
+ * specified matters, such as -v and -d and -t, should probably not
+ * just map to a long option, as saying
+ *
+ *  tcpdump --verbose --verbose
+ *
+ * doesn't make sense; it should be --verbosity={N} or something such
+ * as that.
+ *
+ * For long options with no corresponding short options, we define values
+ * outside the range of ASCII graphic characters, make that the last
+ * component of the entry for the long option, and have a case for that
+ * option in the switch statement.
+ */
+#define OPTION_VERSION		128
+#define OPTION_TSTAMP_PRECISION	129
+#define OPTION_IMMEDIATE_MODE	130
+
+static const struct option longopts[] = {
+#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+	{ "buffer-size", required_argument, NULL, 'B' },
+#endif
+	{ "list-interfaces", no_argument, NULL, 'D' },
+	{ "help", no_argument, NULL, 'h' },
+	{ "interface", required_argument, NULL, 'i' },
+#ifdef HAVE_PCAP_CREATE
+	{ "monitor-mode", no_argument, NULL, 'I' },
+#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
+	{ "time-stamp-type", required_argument, NULL, 'j' },
+	{ "list-time-stamp-types", no_argument, NULL, 'J' },
+#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+	{ "time-stamp-precision", required_argument, NULL, OPTION_TSTAMP_PRECISION},
+#endif
+	{ "dont-verify-checksums", no_argument, NULL, 'K' },
+	{ "list-data-link-types", no_argument, NULL, 'L' },
+	{ "no-optimize", no_argument, NULL, 'O' },
+	{ "no-promiscuous-mode", no_argument, NULL, 'p' },
+#ifdef HAVE_PCAP_SETDIRECTION
+	{ "direction", required_argument, NULL, 'Q' },
+#endif
+	{ "snapshot-length", required_argument, NULL, 's' },
+	{ "absolute-tcp-sequence-numbers", no_argument, NULL, 'S' },
+#ifdef HAVE_PCAP_DUMP_FLUSH
+	{ "packet-buffered", no_argument, NULL, 'U' },
+#endif
+	{ "linktype", required_argument, NULL, 'y' },
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+	{ "immediate-mode", no_argument, NULL, OPTION_IMMEDIATE_MODE },
+#endif
+#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
+	{ "debug-filter-parser", no_argument, NULL, 'Y' },
+#endif
+	{ "relinquish-privileges", required_argument, NULL, 'Z' },
+	{ "number", no_argument, NULL, '#' },
+	{ "version", no_argument, NULL, OPTION_VERSION },
+	{ NULL, 0, NULL, 0 }
+};
+
 #ifndef WIN32
 /* Drop root privileges and chroot if necessary */
 static void
@@ -542,7 +743,7 @@
 		fprintf(stderr, "tcpdump: Chroot without dropping root is insecure\n");
 		exit(1);
 	}
-	
+
 	pw = getpwnam(username);
 	if (pw) {
 		if (chroot_dir) {
@@ -552,35 +753,45 @@
 				exit(1);
 			}
 		}
-#ifdef HAVE_CAP_NG_H
+#ifdef HAVE_LIBCAP_NG
 		int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
 		if (ret < 0) {
-			printf("error : ret %d\n", ret);
+			fprintf(stderr, "error : ret %d\n", ret);
 		}
-		/* We don't need CAP_SETUID and CAP_SETGID */
-		capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_SETUID);
-		capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_SETUID);
-		capng_update(CAPNG_DROP, CAPNG_PERMITTED, CAP_SETUID);
-		capng_update(CAPNG_DROP, CAPNG_PERMITTED, CAP_SETUID);
-		capng_apply(CAPNG_SELECT_BOTH);
-
+		else {
+			fprintf(stderr, "dropped privs to %s\n", username);
+		}
 #else
 		if (initgroups(pw->pw_name, pw->pw_gid) != 0 ||
 		    setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) {
 			fprintf(stderr, "tcpdump: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n",
-			    username, 
+			    username,
 			    (unsigned long)pw->pw_uid,
 			    (unsigned long)pw->pw_gid,
 			    pcap_strerror(errno));
 			exit(1);
 		}
-#endif /* HAVE_CAP_NG_H */
+		else {
+			fprintf(stderr, "dropped privs to %s\n", username);
+		}
+#endif /* HAVE_LIBCAP_NG */
 	}
 	else {
 		fprintf(stderr, "tcpdump: Couldn't find user '%.32s'\n",
 		    username);
 		exit(1);
 	}
+#ifdef HAVE_LIBCAP_NG
+	/* We don't need CAP_SETUID and CAP_SETGID any more. */
+	capng_updatev(
+		CAPNG_DROP,
+		CAPNG_EFFECTIVE | CAPNG_PERMITTED,
+		CAP_SETUID,
+		CAP_SETGID,
+		-1);
+	capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+
 }
 #endif /* WIN32 */
 
@@ -635,7 +846,7 @@
 static int tcpdump_printf(netdissect_options *ndo _U_,
 			  const char *fmt, ...)
 {
-  
+
   va_list args;
   int ret;
 
@@ -684,11 +895,111 @@
 	return ret;
 }
 
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+static int
+tstamp_precision_from_string(const char *precision)
+{
+	if (strncmp(precision, "nano", strlen("nano")) == 0)
+		return PCAP_TSTAMP_PRECISION_NANO;
+
+	if (strncmp(precision, "micro", strlen("micro")) == 0)
+		return PCAP_TSTAMP_PRECISION_MICRO;
+
+	return -EINVAL;
+}
+
+static const char *
+tstamp_precision_to_string(int precision)
+{
+	switch (precision) {
+
+	case PCAP_TSTAMP_PRECISION_MICRO:
+		return "micro";
+
+	case PCAP_TSTAMP_PRECISION_NANO:
+		return "nano";
+
+	default:
+		return "unknown";
+	}
+}
+#endif
+
+#ifdef HAVE_CAPSICUM
+/*
+ * Ensure that, on a dump file's descriptor, we have all the rights
+ * necessary to make the standard I/O library work with an fdopen()ed
+ * FILE * from that descriptor.
+ *
+ * A long time ago, in a galaxy far far away, AT&T decided that, instead
+ * of providing separate APIs for getting and setting the FD_ flags on a
+ * descriptor, getting and setting the O_ flags on a descriptor, and
+ * locking files, they'd throw them all into a kitchen-sink fcntl() call
+ * along the lines of ioctl(), the fact that ioctl() operations are
+ * largely specific to particular character devices but fcntl() operations
+ * are either generic to all descriptors or generic to all descriptors for
+ * regular files nonwithstanding.
+ *
+ * The Capsicum people decided that fine-grained control of descriptor
+ * operations was required, so that you need to grant permission for
+ * reading, writing, seeking, and fcntl-ing.  The latter, courtesy of
+ * AT&T's decision, means that "fcntl-ing" isn't a thing, but a motley
+ * collection of things, so there are *individual* fcntls for which
+ * permission needs to be granted.
+ *
+ * The FreeBSD standard I/O people implemented some optimizations that
+ * requires that the standard I/O routines be able to determine whether
+ * the descriptor for the FILE * is open append-only or not; as that
+ * descriptor could have come from an open() rather than an fopen(),
+ * that requires that it be able to do an F_GETFL fcntl() to read
+ * the O_ flags.
+ *
+ * Tcpdump uses ftell() to determine how much data has been written
+ * to a file in order to, when used with -C, determine when it's time
+ * to rotate capture files.  ftell() therefore needs to do an lseek()
+ * to find out the file offset and must, thanks to the aforementioned
+ * optimization, also know whether the descriptor is open append-only
+ * or not.
+ *
+ * The net result of all the above is that we need to grant CAP_SEEK,
+ * CAP_WRITE, and CAP_FCNTL with the CAP_FCNTL_GETFL subcapability.
+ *
+ * Perhaps this is the universe's way of saying that either
+ *
+ *	1) there needs to be an fopenat() call and a pcap_dump_openat() call
+ *	   using it, so that Capsicum-capable tcpdump wouldn't need to do
+ *	   an fdopen()
+ *
+ * or
+ *
+ *	2) there needs to be a cap_fdopen() call in the FreeBSD standard
+ *	   I/O library that knows what rights are needed by the standard
+ *	   I/O library, based on the open mode, and assigns them, perhaps
+ *	   with an additional argument indicating, for example, whether
+ *	   seeking should be allowed, so that tcpdump doesn't need to know
+ *	   what the standard I/O library happens to require this week.
+ */
+static void
+set_dumper_capsicum_rights(pcap_dumper_t *p)
+{
+	int fd = fileno(pcap_dump_file(p));
+	cap_rights_t rights;
+
+	cap_rights_init(&rights, CAP_SEEK, CAP_WRITE, CAP_FCNTL);
+	if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) {
+		error("unable to limit dump descriptor");
+	}
+	if (cap_fcntls_limit(fd, CAP_FCNTL_GETFL) < 0 && errno != ENOSYS) {
+		error("unable to limit dump descriptor fcntls");
+	}
+}
+#endif
+
 int
 main(int argc, char **argv)
 {
 	register int cnt, op, i;
-	bpf_u_int32 localnet, netmask;
+	bpf_u_int32 localnet =0 , netmask = 0;
 	register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName;
 	pcap_handler callback;
 	int type;
@@ -714,6 +1025,11 @@
 #endif
 	int status;
 	FILE *VFile;
+#ifdef HAVE_CAPSICUM
+	cap_rights_t rights;
+	int cansandbox;
+#endif	/* HAVE_CAPSICUM */
+
 #ifdef WIN32
 	if(wsockinit() != 0) return 1;
 #endif /* WIN32 */
@@ -727,7 +1043,8 @@
 	gndo->ndo_error=ndo_error;
 	gndo->ndo_warning=ndo_warning;
 	gndo->ndo_snaplen = DEFAULT_SNAPLEN;
-  
+	gndo->ndo_immediate = 0;
+
 	cnt = -1;
 	device = NULL;
 	infile = NULL;
@@ -741,15 +1058,22 @@
 	else
 		program_name = argv[0];
 
+	/*
+	 * On platforms where the CPU doesn't support unaligned loads,
+	 * force unaligned accesses to abort with SIGBUS, rather than
+	 * being fixed up (slowly) by the OS kernel; on those platforms,
+	 * misaligned accesses are bugs, and we want tcpdump to crash so
+	 * that the bugs are reported.
+	 */
 	if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
 		error("%s", ebuf);
 
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
 	smiInit("tcpdump");
 #endif
 
 	while (
-	    (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOp" P_FLAG "q" Q_FLAG "r:Rs:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:")) != -1)
+	    (op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1)
 		switch (op) {
 
 		case 'a':
@@ -788,21 +1112,9 @@
 			++dflag;
 			break;
 
-#ifdef HAVE_PCAP_FINDALLDEVS
 		case 'D':
-			if (pcap_findalldevs(&devpointer, ebuf) < 0)
-				error("%s", ebuf);
-			else {
-				for (i = 0; devpointer != 0; i++) {
-					printf("%d.%s", i+1, devpointer->name);
-					if (devpointer->description != NULL)
-						printf(" (%s)", devpointer->description);
-					printf("\n");
-					devpointer = devpointer->next;
-				}
-			}
-			return 0;
-#endif /* HAVE_PCAP_FINDALLDEVS */
+			Dflag++;
+			break;
 
 		case 'L':
 			Lflag++;
@@ -843,7 +1155,8 @@
 			break;
 
 		case 'h':
-			usage();
+			print_usage();
+			exit(0);
 			break;
 
 		case 'H':
@@ -853,7 +1166,7 @@
 		case 'i':
 			if (optarg[0] == '0' && optarg[1] == 0)
 				error("Invalid adapter index");
-			
+
 #ifdef HAVE_PCAP_FINDALLDEVS
 			/*
 			 * If the argument is a number, treat it as
@@ -936,7 +1249,7 @@
 			break;
 
 		case 'm':
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
 			if (smiLoadModule(optarg) == 0) {
 				error("could not load MIB module %s", optarg);
 			}
@@ -971,27 +1284,25 @@
 		case 'p':
 			++pflag;
 			break;
-#ifdef HAVE_PCAP_SETDIRECTION
-		case 'P':
-			warning("don't use -P, use -Q; -P will be used for pcap-ng output in the future");
-			/* FALLTHROUGH */
 
-		case 'Q':
-			if (strcasecmp(optarg, "in") == 0)
-				Pflag = PCAP_D_IN;
-			else if (strcasecmp(optarg, "out") == 0)
-				Pflag = PCAP_D_OUT;
-			else if (strcasecmp(optarg, "inout") == 0)
-				Pflag = PCAP_D_INOUT;
-			else
-				error("unknown capture direction `%s'", optarg);
-			break;
-#endif /* HAVE_PCAP_SETDIRECTION */
 		case 'q':
 			++qflag;
 			++suppress_default_print;
 			break;
 
+#ifdef HAVE_PCAP_SETDIRECTION
+		case 'Q':
+			if (strcasecmp(optarg, "in") == 0)
+				Qflag = PCAP_D_IN;
+			else if (strcasecmp(optarg, "out") == 0)
+				Qflag = PCAP_D_OUT;
+			else if (strcasecmp(optarg, "inout") == 0)
+				Qflag = PCAP_D_INOUT;
+			else
+				error("unknown capture direction `%s'", optarg);
+			break;
+#endif /* HAVE_PCAP_SETDIRECTION */
+
 		case 'r':
 			RFileName = optarg;
 			break;
@@ -1078,7 +1389,7 @@
 
 		case 'W':
 			Wflag = atoi(optarg);
-			if (Wflag < 0) 
+			if (Wflag < 0)
 				error("invalid number of output files %s", optarg);
 			WflagChars = getWflagChars(Wflag);
 			break;
@@ -1116,29 +1427,47 @@
 			break;
 #endif
 		case 'z':
-			if (optarg) {
-				zflag = strdup(optarg);
-			} else {
-				usage();
-				/* NOTREACHED */
-			}
+			zflag = strdup(optarg);
 			break;
 
 		case 'Z':
-			if (optarg) {
-				username = strdup(optarg);
-			}
-			else {
-				usage();
-				/* NOTREACHED */
-			}
+			username = strdup(optarg);
 			break;
 
+		case '#':
+			gndo->ndo_packet_number = 1;
+			break;
+
+		case OPTION_VERSION:
+			print_version();
+			exit(0);
+			break;
+
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+		case OPTION_TSTAMP_PRECISION:
+			gndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg);
+			if (gndo->ndo_tstamp_precision < 0)
+				error("unsupported time stamp precision");
+			break;
+#endif
+
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+		case OPTION_IMMEDIATE_MODE:
+			gndo->ndo_immediate = 1;
+			break;
+#endif
+
 		default:
-			usage();
+			print_usage();
+			exit(1);
 			/* NOTREACHED */
 		}
 
+#ifdef HAVE_PCAP_FINDALLDEVS
+	if (Dflag)
+		show_devices_and_exit();
+#endif
+
 	switch (tflag) {
 
 	case 0: /* Default */
@@ -1163,6 +1492,17 @@
 	if (VFileName != NULL && RFileName != NULL)
 		error("-V and -r are mutually exclusive.");
 
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+	/*
+	 * If we're printing dissected packets to the standard output
+	 * rather than saving raw packets to a file, and the standard
+	 * output is a terminal, use immediate mode, as the user's
+	 * probably expecting to see packets pop up immediately.
+	 */
+	if (WFileName == NULL && isatty(1))
+		gndo->ndo_immediate = 1;
+#endif
+
 #ifdef WITH_CHROOT
 	/* if run as root, prepare for chrooting */
 	if (getuid() == 0 || geteuid() == 0) {
@@ -1175,7 +1515,7 @@
 #ifdef WITH_USER
 	/* if run as root, prepare for dropping root privileges */
 	if (getuid() == 0 || geteuid() == 0) {
-		/* Run with '-Z root' to restore old behaviour */ 
+		/* Run with '-Z root' to restore old behaviour */
 		if (!username)
 			username = WITH_USER;
 	}
@@ -1219,9 +1559,22 @@
 			RFileName = VFileLine;
 		}
 
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+		pd = pcap_open_offline_with_tstamp_precision(RFileName,
+		    gndo->ndo_tstamp_precision, ebuf);
+#else
 		pd = pcap_open_offline(RFileName, ebuf);
+#endif
+
 		if (pd == NULL)
 			error("%s", ebuf);
+#ifdef HAVE_CAPSICUM
+		cap_rights_init(&rights, CAP_READ);
+		if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
+		    errno != ENOSYS) {
+			error("unable to limit pcap descriptor");
+		}
+#endif
 		dlt = pcap_datalink(pd);
 		dlt_name = pcap_datalink_val_to_name(dlt);
 		if (dlt_name == NULL) {
@@ -1233,8 +1586,6 @@
 			    RFileName, dlt_name,
 			    pcap_datalink_val_to_description(dlt));
 		}
-		localnet = 0;
-		netmask = 0;
 	} else {
 		/*
 		 * We're doing a live capture.
@@ -1258,7 +1609,7 @@
 			fprintf(stderr, "%s: listening on %s\n", program_name, device);
 		}
 
-		fflush(stderr);	
+		fflush(stderr);
 #endif /* WIN32 */
 #ifdef HAVE_PCAP_CREATE
 		pd = pcap_create(device, ebuf);
@@ -1268,6 +1619,24 @@
 		if (Jflag)
 			show_tstamp_types_and_exit(device, pd);
 #endif
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+		status = pcap_set_tstamp_precision(pd, gndo->ndo_tstamp_precision);
+		if (status != 0)
+			error("%s: Can't set %ssecond time stamp precision: %s",
+				device,
+				tstamp_precision_to_string(gndo->ndo_tstamp_precision),
+				pcap_statustostr(status));
+#endif
+
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+		if (gndo->ndo_immediate) {
+			status = pcap_set_immediate_mode(pd, 1);
+			if (status != 0)
+				error("%s: Can't set immediate mode: %s",
+				device,
+				pcap_statustostr(status));
+		}
+#endif
 		/*
 		 * Is this an interface that supports monitor mode?
 		 */
@@ -1304,7 +1673,7 @@
 			status = pcap_set_tstamp_type(pd, jflag);
 			if (status < 0)
 				error("%s: Can't set time stamp type: %s",
-			    	    device, pcap_statustostr(status));
+			              device, pcap_statustostr(status));
 		}
 #endif
 		status = pcap_activate(pd);
@@ -1340,13 +1709,13 @@
 				    pcap_statustostr(status));
 		}
 #ifdef HAVE_PCAP_SETDIRECTION
-		if (Pflag != -1) {
-			status = pcap_setdirection(pd, Pflag);
+		if (Qflag != -1) {
+			status = pcap_setdirection(pd, Qflag);
 			if (status != 0)
 				error("%s: pcap_setdirection() failed: %s",
 				      device,  pcap_geterr(pd));
 		}
-#endif
+#endif /* HAVE_PCAP_SETDIRECTION */
 #else
 		*ebuf = '\0';
 		pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
@@ -1394,11 +1763,12 @@
 			warning("snaplen raised from %d to %d", snaplen, i);
 			snaplen = i;
 		}
-		if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
-			localnet = 0;
-			netmask = 0;
-			warning("%s", ebuf);
-		}
+                if(fflag != 0) {
+                        if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
+                                warning("foreign (-f) flag used but: %s", ebuf);
+                        }
+                }
+
 	}
 	if (infile)
 		cmdbuf = read_infile(infile);
@@ -1413,10 +1783,10 @@
 		free(cmdbuf);
 		exit(0);
 	}
-	init_addrtoname(localnet, netmask);
+	init_addrtoname(gndo, localnet, netmask);
         init_checksum();
 
-#ifndef WIN32	
+#ifndef WIN32
 	(void)setsignal(SIGPIPE, cleanup);
 	(void)setsignal(SIGTERM, cleanup);
 	(void)setsignal(SIGINT, cleanup);
@@ -1425,7 +1795,7 @@
 	(void)setsignal(SIGCHLD, child_cleanup);
 #endif
 	/* Cooperate with nohup(1) */
-#ifndef WIN32	
+#ifndef WIN32
 	if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
 		(void)setsignal(SIGHUP, oldhandler);
 #endif /* WIN32 */
@@ -1449,27 +1819,28 @@
 	 * savefile doesn't handle the general case.
 	 */
 
-#ifdef HAVE_CAP_NG_H
-	/* We are running as root and we will be writing to savefile */
-	if ((getuid() == 0 || geteuid() == 0) && WFileName) {
-		if (username) {
-			/* Drop all capabilities from effective set */
-			capng_clear(CAPNG_EFFECTIVE);
-			/* Add capabilities we will need*/
-			capng_update(CAPNG_ADD, CAPNG_PERMITTED, CAP_SETUID);
-			capng_update(CAPNG_ADD, CAPNG_PERMITTED, CAP_SETGID);
-			capng_update(CAPNG_ADD, CAPNG_PERMITTED, CAP_DAC_OVERRIDE);
-
-			capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_SETUID);
-			capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_SETGID);
-			capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
-
-			capng_apply(CAPNG_SELECT_BOTH);
-		}
-	}
-#endif /* HAVE_CAP_NG_H */
-
 	if (getuid() == 0 || geteuid() == 0) {
+#ifdef HAVE_LIBCAP_NG
+		/* Initialize capng */
+		capng_clear(CAPNG_SELECT_BOTH);
+		if (username) {
+			capng_updatev(
+				CAPNG_ADD,
+				CAPNG_PERMITTED | CAPNG_EFFECTIVE,
+				CAP_SETUID,
+				CAP_SETGID,
+				-1);
+		}
+
+		if (WFileName) {
+			capng_update(
+				CAPNG_ADD,
+				CAPNG_PERMITTED | CAPNG_EFFECTIVE,
+				CAP_DAC_OVERRIDE
+				);
+		}
+		capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
 		if (username || chroot_dir)
 			droproot(username, chroot_dir);
 
@@ -1478,6 +1849,21 @@
 
 	if (pcap_setfilter(pd, &fcode) < 0)
 		error("%s", pcap_geterr(pd));
+#ifdef HAVE_CAPSICUM
+	if (RFileName == NULL && VFileName == NULL) {
+		static const unsigned long cmds[] = { BIOCGSTATS };
+
+		cap_rights_init(&rights, CAP_IOCTL, CAP_READ);
+		if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 &&
+		    errno != ENOSYS) {
+			error("unable to limit pcap descriptor");
+		}
+		if (cap_ioctls_limit(pcap_fileno(pd), cmds,
+		    sizeof(cmds) / sizeof(cmds[0])) < 0 && errno != ENOSYS) {
+			error("unable to limit ioctls on pcap descriptor");
+		}
+	}
+#endif
 	if (WFileName) {
 		pcap_dumper_t *p;
 		/* Do not exceed the default PATH_MAX for files. */
@@ -1493,15 +1879,47 @@
 		  MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0);
 
 		p = pcap_dump_open(pd, dumpinfo.CurrentFileName);
-#ifdef HAVE_CAP_NG_H
-        /* Give up capabilities, clear Effective set */
-        capng_clear(CAPNG_EFFECTIVE);
-#endif
+#ifdef HAVE_LIBCAP_NG
+		/* Give up CAP_DAC_OVERRIDE capability.
+		 * Only allow it to be restored if the -C or -G flag have been
+		 * set since we may need to create more files later on.
+		 */
+		capng_update(
+			CAPNG_DROP,
+			(Cflag || Gflag ? 0 : CAPNG_PERMITTED)
+				| CAPNG_EFFECTIVE,
+			CAP_DAC_OVERRIDE
+			);
+		capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
 		if (p == NULL)
 			error("%s", pcap_geterr(pd));
+#ifdef HAVE_CAPSICUM
+		set_dumper_capsicum_rights(p);
+#endif
 		if (Cflag != 0 || Gflag != 0) {
-			callback = dump_packet_and_trunc;
+#ifdef HAVE_CAPSICUM
+			dumpinfo.WFileName = strdup(basename(WFileName));
+			dumpinfo.dirfd = open(dirname(WFileName),
+			    O_DIRECTORY | O_RDONLY);
+			if (dumpinfo.dirfd < 0) {
+				error("unable to open directory %s",
+				    dirname(WFileName));
+			}
+			cap_rights_init(&rights, CAP_CREATE, CAP_FCNTL,
+			    CAP_FTRUNCATE, CAP_LOOKUP, CAP_SEEK, CAP_WRITE);
+			if (cap_rights_limit(dumpinfo.dirfd, &rights) < 0 &&
+			    errno != ENOSYS) {
+				error("unable to limit directory rights");
+			}
+			if (cap_fcntls_limit(dumpinfo.dirfd, CAP_FCNTL_GETFL) < 0 &&
+			    errno != ENOSYS) {
+				error("unable to limit dump descriptor fcntls");
+			}
+#else	/* !HAVE_CAPSICUM */
 			dumpinfo.WFileName = WFileName;
+#endif
+			callback = dump_packet_and_trunc;
 			dumpinfo.pd = pd;
 			dumpinfo.p = p;
 			pcap_userdata = (u_char *)&dumpinfo;
@@ -1571,6 +1989,15 @@
 		(void)fflush(stderr);
 	}
 #endif /* WIN32 */
+
+#ifdef HAVE_CAPSICUM
+	cansandbox = (nflag && VFileName == NULL && zflag == NULL);
+	if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
+		error("unable to enter the capability mode");
+	if (cap_sandboxed())
+		fprintf(stderr, "capability mode sandbox enabled\n");
+#endif	/* HAVE_CAPSICUM */
+
 	do {
 		status = pcap_loop(pd, cnt, callback, pcap_userdata);
 		if (WFileName == NULL) {
@@ -1618,6 +2045,13 @@
 				pd = pcap_open_offline(RFileName, ebuf);
 				if (pd == NULL)
 					error("%s", ebuf);
+#ifdef HAVE_CAPSICUM
+				cap_rights_init(&rights, CAP_READ);
+				if (cap_rights_limit(fileno(pcap_file(pd)),
+				    &rights) < 0 && errno != ENOSYS) {
+					error("unable to limit pcap descriptor");
+				}
+#endif
 				new_dlt = pcap_datalink(pd);
 				if (WFileName && new_dlt != dlt)
 					error("%s: new dlt does not match original", RFileName);
@@ -1814,6 +2248,11 @@
 
 		/* If the time is greater than the specified window, rotate */
 		if (t - Gflag_time >= Gflag) {
+#ifdef HAVE_CAPSICUM
+			FILE *fp;
+			int fd;
+#endif
+
 			/* Update the Gflag_time */
 			Gflag_time = t;
 			/* Update Gflag_count */
@@ -1846,6 +2285,13 @@
 			if (dump_info->CurrentFileName == NULL)
 				error("dump_packet_and_trunc: malloc");
 			/*
+			 * Gflag was set otherwise we wouldn't be here. Reset the count
+			 * so multiple files would end with 1,2,3 in the filename.
+			 * The counting is handled with the -C flow after this.
+			 */
+			Cflag_count = 0;
+
+			/*
 			 * This is always the first file in the Cflag
 			 * rotation: e.g. 0
 			 * We also don't need numbering if Cflag is not set.
@@ -1856,17 +2302,36 @@
 			else
 				MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, 0);
 
-#ifdef HAVE_CAP_NG_H
+#ifdef HAVE_LIBCAP_NG
 			capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
-			capng_apply(CAPNG_EFFECTIVE);
-#endif /* HAVE_CAP_NG_H */
+			capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+#ifdef HAVE_CAPSICUM
+			fd = openat(dump_info->dirfd,
+			    dump_info->CurrentFileName,
+			    O_CREAT | O_WRONLY | O_TRUNC, 0644);
+			if (fd < 0) {
+				error("unable to open file %s",
+				    dump_info->CurrentFileName);
+			}
+			fp = fdopen(fd, "w");
+			if (fp == NULL) {
+				error("unable to fdopen file %s",
+				    dump_info->CurrentFileName);
+			}
+			dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
+#else	/* !HAVE_CAPSICUM */
 			dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
-#ifdef HAVE_CAP_NG_H
+#endif
+#ifdef HAVE_LIBCAP_NG
 			capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
-			capng_apply(CAPNG_EFFECTIVE);
-#endif /* HAVE_CAP_NG_H */
+			capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
 			if (dump_info->p == NULL)
 				error("%s", pcap_geterr(pd));
+#ifdef HAVE_CAPSICUM
+			set_dumper_capsicum_rights(dump_info->p);
+#endif
 		}
 	}
 
@@ -1875,32 +2340,70 @@
 	 * larger than Cflag - the last packet written to the
 	 * file could put it over Cflag.
 	 */
-	if (Cflag != 0 && pcap_dump_ftell(dump_info->p) > Cflag) {
-		/*
-		 * Close the current file and open a new one.
-		 */
-		pcap_dump_close(dump_info->p);
+	if (Cflag != 0) {
+		long size = pcap_dump_ftell(dump_info->p);
 
-		/*
-		 * Compress the file we just closed, if the user asked for it
-		 */
-		if (zflag != NULL)
-			compress_savefile(dump_info->CurrentFileName);
+		if (size == -1)
+			error("ftell fails on output file");
+		if (size > Cflag) {
+#ifdef HAVE_CAPSICUM
+			FILE *fp;
+			int fd;
+#endif
 
-		Cflag_count++;
-		if (Wflag > 0) {
-			if (Cflag_count >= Wflag)
-				Cflag_count = 0;
+			/*
+			 * Close the current file and open a new one.
+			 */
+			pcap_dump_close(dump_info->p);
+
+			/*
+			 * Compress the file we just closed, if the user
+			 * asked for it.
+			 */
+			if (zflag != NULL)
+				compress_savefile(dump_info->CurrentFileName);
+
+			Cflag_count++;
+			if (Wflag > 0) {
+				if (Cflag_count >= Wflag)
+					Cflag_count = 0;
+			}
+			if (dump_info->CurrentFileName != NULL)
+				free(dump_info->CurrentFileName);
+			dump_info->CurrentFileName = (char *)malloc(PATH_MAX + 1);
+			if (dump_info->CurrentFileName == NULL)
+				error("dump_packet_and_trunc: malloc");
+			MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars);
+#ifdef HAVE_LIBCAP_NG
+			capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
+			capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+#ifdef HAVE_CAPSICUM
+			fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
+			    O_CREAT | O_WRONLY | O_TRUNC, 0644);
+			if (fd < 0) {
+				error("unable to open file %s",
+				    dump_info->CurrentFileName);
+			}
+			fp = fdopen(fd, "w");
+			if (fp == NULL) {
+				error("unable to fdopen file %s",
+				    dump_info->CurrentFileName);
+			}
+			dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
+#else	/* !HAVE_CAPSICUM */
+			dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
+#endif
+#ifdef HAVE_LIBCAP_NG
+			capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
+			capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+			if (dump_info->p == NULL)
+				error("%s", pcap_geterr(pd));
+#ifdef HAVE_CAPSICUM
+			set_dumper_capsicum_rights(dump_info->p);
+#endif
 		}
-		if (dump_info->CurrentFileName != NULL)
-			free(dump_info->CurrentFileName);
-		dump_info->CurrentFileName = (char *)malloc(PATH_MAX + 1);
-		if (dump_info->CurrentFileName == NULL)
-			error("dump_packet_and_trunc: malloc");
-		MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars);
-		dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
-		if (dump_info->p == NULL)
-			error("%s", pcap_geterr(pd));
 	}
 
 	pcap_dump((u_char *)dump_info->p, h, sp);
@@ -1937,36 +2440,48 @@
 {
 	struct print_info *print_info;
 	u_int hdrlen;
+        netdissect_options *ndo;
 
 	++packets_captured;
 
 	++infodelay;
-	ts_print(&h->ts);
 
 	print_info = (struct print_info *)user;
+        ndo = print_info->ndo;
+
+	if(ndo->ndo_packet_number)
+		ND_PRINT((ndo, "%5u  ", packets_captured));
+
+	ts_print(ndo, &h->ts);
 
 	/*
 	 * Some printers want to check that they're not walking off the
 	 * end of the packet.
-	 * Rather than pass it all the way down, we set this global.
+	 * Rather than pass it all the way down, we set this member
+	 * of the netdissect_options structure.
 	 */
-	snapend = sp + h->caplen;
+	ndo->ndo_snapend = sp + h->caplen;
 
         if(print_info->ndo_type) {
                 hdrlen = (*print_info->p.ndo_printer)(print_info->ndo, h, sp);
         } else {
                 hdrlen = (*print_info->p.printer)(h, sp);
         }
-                
-	if (Xflag) {
+
+	/*
+	 * Restore the original snapend, as a printer might have
+	 * changed it.
+	 */
+	ndo->ndo_snapend = sp + h->caplen;
+	if (ndo->ndo_Xflag) {
 		/*
 		 * Print the raw packet data in hex and ASCII.
 		 */
-		if (Xflag > 1) {
+		if (ndo->ndo_Xflag > 1) {
 			/*
 			 * Include the link-layer header.
 			 */
-			hex_and_ascii_print("\n\t", sp, h->caplen);
+			hex_and_ascii_print(ndo, "\n\t", sp, h->caplen);
 		} else {
 			/*
 			 * Don't include the link-layer header - and if
@@ -1974,18 +2489,18 @@
 			 * print nothing.
 			 */
 			if (h->caplen > hdrlen)
-				hex_and_ascii_print("\n\t", sp + hdrlen,
+				hex_and_ascii_print(ndo, "\n\t", sp + hdrlen,
 				    h->caplen - hdrlen);
 		}
-	} else if (xflag) {
+	} else if (ndo->ndo_xflag) {
 		/*
 		 * Print the raw packet data in hex.
 		 */
-		if (xflag > 1) {
+		if (ndo->ndo_xflag > 1) {
 			/*
 			 * Include the link-layer header.
 			 */
-			hex_print("\n\t", sp, h->caplen);
+                        hex_print(ndo, "\n\t", sp, h->caplen);
 		} else {
 			/*
 			 * Don't include the link-layer header - and if
@@ -1993,18 +2508,18 @@
 			 * print nothing.
 			 */
 			if (h->caplen > hdrlen)
-				hex_print("\n\t", sp + hdrlen,
-				    h->caplen - hdrlen);
+				hex_print(ndo, "\n\t", sp + hdrlen,
+                                          h->caplen - hdrlen);
 		}
-	} else if (Aflag) {
+	} else if (ndo->ndo_Aflag) {
 		/*
 		 * Print the raw packet data in ASCII.
 		 */
-		if (Aflag > 1) {
+		if (ndo->ndo_Aflag > 1) {
 			/*
 			 * Include the link-layer header.
 			 */
-			ascii_print(sp, h->caplen);
+			ascii_print(ndo, sp, h->caplen);
 		} else {
 			/*
 			 * Don't include the link-layer header - and if
@@ -2012,7 +2527,7 @@
 			 * print nothing.
 			 */
 			if (h->caplen > hdrlen)
-				ascii_print(sp + hdrlen, h->caplen - hdrlen);
+				ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen);
 		}
 	}
 
@@ -2042,11 +2557,11 @@
 	 * version number of the Packet.dll code, to supply the
 	 * "Wpcap_version" information on Windows.
 	 */
-	char WDversion[]="current-cvs.tcpdump.org";
+	char WDversion[]="current-git.tcpdump.org";
 #if !defined(HAVE_GENERATED_VERSION)
-	char version[]="current-cvs.tcpdump.org";
+	char version[]="current-git.tcpdump.org";
 #endif
-	char pcap_version[]="current-cvs.tcpdump.org";
+	char pcap_version[]="current-git.tcpdump.org";
 	char Wpcap_version[]="3.1";
 #endif
 
@@ -2054,9 +2569,9 @@
  * By default, print the specified data out in hex and ASCII.
  */
 static void
-ndo_default_print(netdissect_options *ndo _U_, const u_char *bp, u_int length)
+ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
-	hex_and_ascii_print("\n\t", bp, length); /* pass on lf and identation string */
+	hex_and_ascii_print(ndo, "\n\t", bp, length); /* pass on lf and indentation string */
 }
 
 void
@@ -2098,8 +2613,9 @@
 }
 #endif
 
+USES_APPLE_DEPRECATED_API
 static void
-usage(void)
+print_version(void)
 {
 	extern char version[];
 #ifndef HAVE_PCAP_LIB_VERSION
@@ -2126,23 +2642,46 @@
 	(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
 #endif /* WIN32 */
 #endif /* HAVE_PCAP_LIB_VERSION */
+
+#if defined(HAVE_LIBCRYPTO) && defined(SSLEAY_VERSION)
+	(void)fprintf (stderr, "%s\n", SSLeay_version(SSLEAY_VERSION));
+#endif
+
+#ifdef USE_LIBSMI
+	(void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
+#endif
+}
+USES_APPLE_RST
+
+static void
+print_usage(void)
+{
+	print_version();
 	(void)fprintf(stderr,
-"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
+"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX#]" B_FLAG_USAGE " [ -c count ]\n", program_name);
 	(void)fprintf(stderr,
 "\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n");
 	(void)fprintf(stderr,
-"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ]\n");
+"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ] [ --number ]\n");
 #ifdef HAVE_PCAP_SETDIRECTION
 	(void)fprintf(stderr,
 "\t\t[ -Q in|out|inout ]\n");
 #endif
 	(void)fprintf(stderr,
-"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -V file ] [ -w file ]\n");
+"\t\t[ -r file ] [ -s snaplen ] ");
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+	(void)fprintf(stderr, "[ --time-stamp-precision precision ]\n");
 	(void)fprintf(stderr,
-"\t\t[ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
+"\t\t");
+#endif
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+	(void)fprintf(stderr, "[ --immediate-mode ] ");
+#endif
+	(void)fprintf(stderr, "[ -T type ] [ --version ] [ -V file ]\n");
+	(void)fprintf(stderr,
+"\t\t[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
 	(void)fprintf(stderr,
 "\t\t[ -Z user ] [ expression ]\n");
-	exit(1);
 }
 
 
@@ -2182,3 +2721,9 @@
 			(void)fputc('\n', stderr);
 	}
 }
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/telnet.h b/telnet.h
deleted file mode 100644
index 33a07be..0000000
--- a/telnet.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.5 2007-08-29 02:31:44 mcr Exp $ (LBL) */
-
-/*	NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp 	*/
-
-/*
- * Copyright (c) 1983, 1993
- *	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 the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. 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 BY THE REGENTS 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 THE REGENTS 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.
- *
- *	@(#)telnet.h	8.2 (Berkeley) 12/15/93
- */
-
-#ifndef _ARPA_TELNET_H_
-#define	_ARPA_TELNET_H_
-
-/*
- * Definitions for the TELNET protocol.
- */
-#define	IAC	255		/* interpret as command: */
-#define	DONT	254		/* you are not to use option */
-#define	DO	253		/* please, you use option */
-#define	WONT	252		/* I won't use option */
-#define	WILL	251		/* I will use option */
-#define	SB	250		/* interpret as subnegotiation */
-#define	GA	249		/* you may reverse the line */
-#define	EL	248		/* erase the current line */
-#define	EC	247		/* erase the current character */
-#define	AYT	246		/* are you there */
-#define	AO	245		/* abort output--but let prog finish */
-#define	IP	244		/* interrupt process--permanently */
-#define	BREAK	243		/* break */
-#define	DM	242		/* data mark--for connect. cleaning */
-#define	NOP	241		/* nop */
-#define	SE	240		/* end sub negotiation */
-#define EOR     239             /* end of record (transparent mode) */
-#define	ABORT	238		/* Abort process */
-#define	SUSP	237		/* Suspend process */
-#define	xEOF	236		/* End of file: EOF is already used... */
-
-#define SYNCH	242		/* for telfunc calls */
-
-#ifdef TELCMDS
-const char *telcmds[] = {
-	"EOF", "SUSP", "ABORT", "EOR",
-	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
-	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
-};
-#else
-extern char *telcmds[];
-#endif
-
-#define	TELCMD_FIRST	xEOF
-#define	TELCMD_LAST	IAC
-#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
-			 (unsigned int)(x) >= TELCMD_FIRST)
-#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]
-
-/* telnet options */
-#define TELOPT_BINARY	0	/* 8-bit data path */
-#define TELOPT_ECHO	1	/* echo */
-#define	TELOPT_RCP	2	/* prepare to reconnect */
-#define	TELOPT_SGA	3	/* suppress go ahead */
-#define	TELOPT_NAMS	4	/* approximate message size */
-#define	TELOPT_STATUS	5	/* give status */
-#define	TELOPT_TM	6	/* timing mark */
-#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
-#define TELOPT_NAOL 	8	/* negotiate about output line width */
-#define TELOPT_NAOP 	9	/* negotiate about output page size */
-#define TELOPT_NAOCRD	10	/* negotiate about CR disposition */
-#define TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
-#define TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
-#define TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
-#define TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
-#define TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
-#define TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
-#define TELOPT_XASCII	17	/* extended ascic character set */
-#define	TELOPT_LOGOUT	18	/* force logout */
-#define	TELOPT_BM	19	/* byte macro */
-#define	TELOPT_DET	20	/* data entry terminal */
-#define	TELOPT_SUPDUP	21	/* supdup protocol */
-#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
-#define	TELOPT_SNDLOC	23	/* send location */
-#define	TELOPT_TTYPE	24	/* terminal type */
-#define	TELOPT_EOR	25	/* end or record */
-#define	TELOPT_TUID	26	/* TACACS user identification */
-#define	TELOPT_OUTMRK	27	/* output marking */
-#define	TELOPT_TTYLOC	28	/* terminal location number */
-#define	TELOPT_3270REGIME 29	/* 3270 regime */
-#define	TELOPT_X3PAD	30	/* X.3 PAD */
-#define	TELOPT_NAWS	31	/* window size */
-#define	TELOPT_TSPEED	32	/* terminal speed */
-#define	TELOPT_LFLOW	33	/* remote flow control */
-#define TELOPT_LINEMODE	34	/* Linemode option */
-#define TELOPT_XDISPLOC	35	/* X Display Location */
-#define TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
-#define	TELOPT_AUTHENTICATION 37/* Authenticate */
-#define	TELOPT_ENCRYPT	38	/* Encryption option */
-#define TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
-#define	TELOPT_EXOPL	255	/* extended-options-list */
-
-
-#define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
-#ifdef TELOPTS
-const char *telopts[NTELOPTS+1] = {
-	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
-	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
-	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
-	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
-	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
-	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
-	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
-	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
-	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
-	"ENCRYPT", "NEW-ENVIRON",
-	0,
-};
-#define	TELOPT_FIRST	TELOPT_BINARY
-#define	TELOPT_LAST	TELOPT_NEW_ENVIRON
-#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
-#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]
-#endif
-
-/* sub-option qualifiers */
-#define	TELQUAL_IS	0	/* option is... */
-#define	TELQUAL_SEND	1	/* send option */
-#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
-#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
-#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */
-
-#define	LFLOW_OFF		0	/* Disable remote flow control */
-#define	LFLOW_ON		1	/* Enable remote flow control */
-#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
-#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */
-
-/*
- * LINEMODE suboptions
- */
-
-#define	LM_MODE		1
-#define	LM_FORWARDMASK	2
-#define	LM_SLC		3
-
-#define	MODE_EDIT	0x01
-#define	MODE_TRAPSIG	0x02
-#define	MODE_ACK	0x04
-#define MODE_SOFT_TAB	0x08
-#define MODE_LIT_ECHO	0x10
-
-#define	MODE_MASK	0x1f
-
-/* Not part of protocol, but needed to simplify things... */
-#define MODE_FLOW		0x0100
-#define MODE_ECHO		0x0200
-#define MODE_INBIN		0x0400
-#define MODE_OUTBIN		0x0800
-#define MODE_FORCE		0x1000
-
-#define	SLC_SYNCH	1
-#define	SLC_BRK		2
-#define	SLC_IP		3
-#define	SLC_AO		4
-#define	SLC_AYT		5
-#define	SLC_EOR		6
-#define	SLC_ABORT	7
-#define	SLC_EOF		8
-#define	SLC_SUSP	9
-#define	SLC_EC		10
-#define	SLC_EL		11
-#define	SLC_EW		12
-#define	SLC_RP		13
-#define	SLC_LNEXT	14
-#define	SLC_XON		15
-#define	SLC_XOFF	16
-#define	SLC_FORW1	17
-#define	SLC_FORW2	18
-#define	SLC_MCL         19
-#define	SLC_MCR         20
-#define	SLC_MCWL        21
-#define	SLC_MCWR        22
-#define	SLC_MCBOL       23
-#define	SLC_MCEOL       24
-#define	SLC_INSRT       25
-#define	SLC_OVER        26
-#define	SLC_ECR         27
-#define	SLC_EWR         28
-#define	SLC_EBOL        29
-#define	SLC_EEOL        30
-
-#define	NSLC		30
-
-/*
- * For backwards compatibility, we define SLC_NAMES to be the
- * list of names if SLC_NAMES is not defined.
- */
-#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR",	\
-			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP",	\
-			"LNEXT", "XON", "XOFF", "FORW1", "FORW2",	\
-			"MCL", "MCR", "MCWL", "MCWR", "MCBOL",		\
-			"MCEOL", "INSRT", "OVER", "ECR", "EWR",		\
-			"EBOL", "EEOL",					\
-			0,
-
-#ifdef	SLC_NAMES
-const char *slc_names[] = {
-	SLC_NAMELIST
-};
-#else
-extern char *slc_names[];
-#define	SLC_NAMES SLC_NAMELIST
-#endif
-
-#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
-#define SLC_NAME(x)	slc_names[x]
-
-#define	SLC_NOSUPPORT	0
-#define	SLC_CANTCHANGE	1
-#define	SLC_VARIABLE	2
-#define	SLC_DEFAULT	3
-#define	SLC_LEVELBITS	0x03
-
-#define	SLC_FUNC	0
-#define	SLC_FLAGS	1
-#define	SLC_VALUE	2
-
-#define	SLC_ACK		0x80
-#define	SLC_FLUSHIN	0x40
-#define	SLC_FLUSHOUT	0x20
-
-#define	OLD_ENV_VAR	1
-#define	OLD_ENV_VALUE	0
-#define	NEW_ENV_VAR	0
-#define	NEW_ENV_VALUE	1
-#define	ENV_ESC		2
-#define ENV_USERVAR	3
-
-/*
- * AUTHENTICATION suboptions
- */
-
-/*
- * Who is authenticating who ...
- */
-#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
-#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
-#define	AUTH_WHO_MASK		1
-
-/*
- * amount of authentication done
- */
-#define	AUTH_HOW_ONE_WAY	0
-#define	AUTH_HOW_MUTUAL		2
-#define	AUTH_HOW_MASK		2
-
-/*
- * should we be encrypting? (not yet formally standardized)
- */
-#define AUTH_ENCRYPT_OFF	0
-#define AUTH_ENCRYPT_ON		4
-#define AUTH_ENCRYPT_MASK	4
-
-#define	AUTHTYPE_NULL		0
-#define	AUTHTYPE_KERBEROS_V4	1
-#define	AUTHTYPE_KERBEROS_V5	2
-#define	AUTHTYPE_SPX		3
-#define	AUTHTYPE_MINK		4
-#define	AUTHTYPE_CNT		5
-
-#define	AUTHTYPE_TEST		99
-
-#ifdef	AUTH_NAMES
-const char *authtype_names[] = {
-	"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
-};
-#else
-extern char *authtype_names[];
-#endif
-
-#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)
-#define	AUTHTYPE_NAME(x)	authtype_names[x]
-
-/*
- * ENCRYPTion suboptions
- */
-#define	ENCRYPT_IS		0	/* I pick encryption type ... */
-#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
-#define	ENCRYPT_REPLY		2	/* Initial setup response */
-#define	ENCRYPT_START		3	/* Am starting to send encrypted */
-#define	ENCRYPT_END		4	/* Am ending encrypted */
-#define	ENCRYPT_REQSTART	5	/* Request you start encrypting */
-#define	ENCRYPT_REQEND		6	/* Request you send encrypting */
-#define	ENCRYPT_ENC_KEYID	7
-#define	ENCRYPT_DEC_KEYID	8
-#define	ENCRYPT_CNT		9
-
-#define	ENCTYPE_ANY		0
-#define	ENCTYPE_DES_CFB64	1
-#define	ENCTYPE_DES_OFB64	2
-#define	ENCTYPE_CNT		3
-
-#ifdef	ENCRYPT_NAMES
-const char *encrypt_names[] = {
-	"IS", "SUPPORT", "REPLY", "START", "END",
-	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
-	0,
-};
-const char *enctype_names[] = {
-	"ANY", "DES_CFB64",  "DES_OFB64",  0,
-};
-#else
-extern char *encrypt_names[];
-extern char *enctype_names[];
-#endif
-
-
-#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
-#define	ENCRYPT_NAME(x)		encrypt_names[x]
-
-#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < ENCTYPE_CNT)
-#define	ENCTYPE_NAME(x)		enctype_names[x]
-
-#endif /* _ARPA_TELNET_H_ */
diff --git a/tests/.gitignore b/tests/.gitignore
deleted file mode 100644
index 98d697f..0000000
--- a/tests/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.failed
-.passed
-DIFF
-NEW
diff --git a/tests/3560_CDP.pcap b/tests/3560_CDP.pcap
new file mode 100644
index 0000000..f29fd50
--- /dev/null
+++ b/tests/3560_CDP.pcap
Binary files differ
diff --git a/tests/802.1D_spanning_tree.pcap b/tests/802.1D_spanning_tree.pcap
new file mode 100644
index 0000000..b21f71c
--- /dev/null
+++ b/tests/802.1D_spanning_tree.pcap
Binary files differ
diff --git a/tests/802.1w_rapid_STP.pcap b/tests/802.1w_rapid_STP.pcap
new file mode 100644
index 0000000..db85a45
--- /dev/null
+++ b/tests/802.1w_rapid_STP.pcap
Binary files differ
diff --git a/tests/AoE_Linux.pcap b/tests/AoE_Linux.pcap
new file mode 100644
index 0000000..de5c744
--- /dev/null
+++ b/tests/AoE_Linux.pcap
Binary files differ
diff --git a/tests/DECnet_Phone.pcap b/tests/DECnet_Phone.pcap
new file mode 100644
index 0000000..20ff167
--- /dev/null
+++ b/tests/DECnet_Phone.pcap
Binary files differ
diff --git a/tests/DTP.pcap b/tests/DTP.pcap
new file mode 100644
index 0000000..9f0c5f4
--- /dev/null
+++ b/tests/DTP.pcap
Binary files differ
diff --git a/tests/EIGRP_adjacency.pcap b/tests/EIGRP_adjacency.pcap
new file mode 100644
index 0000000..a0966b6
--- /dev/null
+++ b/tests/EIGRP_adjacency.pcap
Binary files differ
diff --git a/tests/EIGRP_goodbye.pcap b/tests/EIGRP_goodbye.pcap
new file mode 100644
index 0000000..6a73f5d
--- /dev/null
+++ b/tests/EIGRP_goodbye.pcap
Binary files differ
diff --git a/tests/EIGRP_subnet_down.pcap b/tests/EIGRP_subnet_down.pcap
new file mode 100644
index 0000000..a85579d
--- /dev/null
+++ b/tests/EIGRP_subnet_down.pcap
Binary files differ
diff --git a/tests/EIGRP_subnet_up.pcap b/tests/EIGRP_subnet_up.pcap
new file mode 100644
index 0000000..49f53ef
--- /dev/null
+++ b/tests/EIGRP_subnet_up.pcap
Binary files differ
diff --git a/tests/HDLC.pcap b/tests/HDLC.pcap
new file mode 100644
index 0000000..0d94d3f
--- /dev/null
+++ b/tests/HDLC.pcap
Binary files differ
diff --git a/tests/HSRP_coup.pcap b/tests/HSRP_coup.pcap
new file mode 100644
index 0000000..41f8ef0
--- /dev/null
+++ b/tests/HSRP_coup.pcap
Binary files differ
diff --git a/tests/HSRP_election.pcap b/tests/HSRP_election.pcap
new file mode 100644
index 0000000..72ccdfb
--- /dev/null
+++ b/tests/HSRP_election.pcap
Binary files differ
diff --git a/tests/HSRP_failover.pcap b/tests/HSRP_failover.pcap
new file mode 100644
index 0000000..cad4e61
--- /dev/null
+++ b/tests/HSRP_failover.pcap
Binary files differ
diff --git a/tests/IGMP_V1.pcap b/tests/IGMP_V1.pcap
new file mode 100644
index 0000000..2a6e90d
--- /dev/null
+++ b/tests/IGMP_V1.pcap
Binary files differ
diff --git a/tests/IGMP_V2.pcap b/tests/IGMP_V2.pcap
new file mode 100644
index 0000000..6d1d8db
--- /dev/null
+++ b/tests/IGMP_V2.pcap
Binary files differ
diff --git a/tests/ISAKMP_sa_setup.pcap b/tests/ISAKMP_sa_setup.pcap
new file mode 100644
index 0000000..28c5d61
--- /dev/null
+++ b/tests/ISAKMP_sa_setup.pcap
Binary files differ
diff --git a/tests/ISIS_external_lsp.pcap b/tests/ISIS_external_lsp.pcap
new file mode 100644
index 0000000..5fbf975
--- /dev/null
+++ b/tests/ISIS_external_lsp.pcap
Binary files differ
diff --git a/tests/ISIS_level1_adjacency.pcap b/tests/ISIS_level1_adjacency.pcap
new file mode 100644
index 0000000..9614218
--- /dev/null
+++ b/tests/ISIS_level1_adjacency.pcap
Binary files differ
diff --git a/tests/ISIS_level2_adjacency.pcap b/tests/ISIS_level2_adjacency.pcap
new file mode 100644
index 0000000..9d8a329
--- /dev/null
+++ b/tests/ISIS_level2_adjacency.pcap
Binary files differ
diff --git a/tests/ISIS_p2p_adjacency.pcap b/tests/ISIS_p2p_adjacency.pcap
new file mode 100644
index 0000000..a065ad7
--- /dev/null
+++ b/tests/ISIS_p2p_adjacency.pcap
Binary files differ
diff --git a/tests/LACP.pcap b/tests/LACP.pcap
new file mode 100644
index 0000000..9681961
--- /dev/null
+++ b/tests/LACP.pcap
Binary files differ
diff --git a/tests/LLDP_and_CDP.pcap b/tests/LLDP_and_CDP.pcap
new file mode 100644
index 0000000..ebbf49e
--- /dev/null
+++ b/tests/LLDP_and_CDP.pcap
Binary files differ
diff --git a/tests/MSTP_Intra-Region_BPDUs.pcap b/tests/MSTP_Intra-Region_BPDUs.pcap
new file mode 100644
index 0000000..559b234
--- /dev/null
+++ b/tests/MSTP_Intra-Region_BPDUs.pcap
Binary files differ
diff --git a/tests/OSPFv3_NBMA_adjacencies.pcap b/tests/OSPFv3_NBMA_adjacencies.pcap
new file mode 100644
index 0000000..7aa8fae
--- /dev/null
+++ b/tests/OSPFv3_NBMA_adjacencies.pcap
Binary files differ
diff --git a/tests/OSPFv3_broadcast_adjacency.pcap b/tests/OSPFv3_broadcast_adjacency.pcap
new file mode 100644
index 0000000..15cb2dd
--- /dev/null
+++ b/tests/OSPFv3_broadcast_adjacency.pcap
Binary files differ
diff --git a/tests/OSPFv3_multipoint_adjacencies.pcap b/tests/OSPFv3_multipoint_adjacencies.pcap
new file mode 100644
index 0000000..9ba7698
--- /dev/null
+++ b/tests/OSPFv3_multipoint_adjacencies.pcap
Binary files differ
diff --git a/tests/OSPFv3_with_AH.pcap b/tests/OSPFv3_with_AH.pcap
new file mode 100644
index 0000000..6c647b4
--- /dev/null
+++ b/tests/OSPFv3_with_AH.pcap
Binary files differ
diff --git a/tests/PIM-DM_pruning.pcap b/tests/PIM-DM_pruning.pcap
new file mode 100644
index 0000000..ad0f80d
--- /dev/null
+++ b/tests/PIM-DM_pruning.pcap
Binary files differ
diff --git a/tests/PIM-SM_join_prune.pcap b/tests/PIM-SM_join_prune.pcap
new file mode 100644
index 0000000..12396bf
--- /dev/null
+++ b/tests/PIM-SM_join_prune.pcap
Binary files differ
diff --git a/tests/PIM_register_register-stop.pcap b/tests/PIM_register_register-stop.pcap
new file mode 100644
index 0000000..e2419ad
--- /dev/null
+++ b/tests/PIM_register_register-stop.pcap
Binary files differ
diff --git a/tests/PIMv2_bootstrap.pcap b/tests/PIMv2_bootstrap.pcap
new file mode 100644
index 0000000..1bc0ae9
--- /dev/null
+++ b/tests/PIMv2_bootstrap.pcap
Binary files differ
diff --git a/tests/PIMv2_hellos.pcap b/tests/PIMv2_hellos.pcap
new file mode 100644
index 0000000..6a5f49d
--- /dev/null
+++ b/tests/PIMv2_hellos.pcap
Binary files differ
diff --git a/tests/RADIUS-RFC4675.pcap b/tests/RADIUS-RFC4675.pcap
new file mode 100644
index 0000000..a5d7505
--- /dev/null
+++ b/tests/RADIUS-RFC4675.pcap
Binary files differ
diff --git a/tests/RADIUS-RFC5176.pcap b/tests/RADIUS-RFC5176.pcap
new file mode 100644
index 0000000..2ef19f2
--- /dev/null
+++ b/tests/RADIUS-RFC5176.pcap
Binary files differ
diff --git a/tests/RADIUS.pcap b/tests/RADIUS.pcap
new file mode 100644
index 0000000..2e902e4
--- /dev/null
+++ b/tests/RADIUS.pcap
Binary files differ
diff --git a/tests/TESTLIST b/tests/TESTLIST
index 8892b84..35963c6 100644
--- a/tests/TESTLIST
+++ b/tests/TESTLIST
@@ -17,59 +17,65 @@
 print-AA	print-flags.pcap	print-AA.out	-t -AA
 
 # BGP tests
-bgp_vpn_attrset bgp_vpn_attrset.pcap bgp_vpn_attrset.out -t -v 
+bgp_vpn_attrset bgp_vpn_attrset.pcap bgp_vpn_attrset.out -t -v
 mpbgp-linklocal-nexthop mpbgp-linklocal-nexthop.pcap mpbgp-linklocal-nexthop.out -t -v
+bgp_infloop-v		bgp-infinite-loop.pcap		bgp_infloop-v.out	-t -v
 
 # EAP tests
-eapon1 eapon1.pcap eapon1.out -t 
+eapon1 eapon1.pcap eapon1.out -t
 
 # ESP tests
 esp0 02-sunrise-sunset-esp.pcap esp0.out -t -n
-esp1 02-sunrise-sunset-esp.pcap esp1.out -t -E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758" 
-esp2 08-sunrise-sunset-esp2.pcap esp2.out -t -E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"
-esp3 02-sunrise-sunset-esp.pcap esp1.out -t -E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"
-esp4 08-sunrise-sunset-esp2.pcap esp2.out -t -E "file esp-secrets.txt"
-esp5 08-sunrise-sunset-aes.pcap esp5.out -t -E "file esp-secrets.txt"
-espudp1 espudp1.pcap                    espudp1.out -nnnn -t -E "file esp-secrets.txt"
+# more ESP tests in crypto.sh
 
 # ISAKMP tests
-isakmp1 isakmp-delete-segfault.pcap isakmp1.out -t 
+isakmp1 isakmp-delete-segfault.pcap isakmp1.out -t
 isakmp2 isakmp-pointer-loop.pcap    isakmp2.out -t
 isakmp3 isakmp-identification-segfault.pcap isakmp3.out -t -v
-isakmp4 isakmp4500.pcap             isakmp4.out -t -E "file esp-secrets.txt"
+# isakmp4 is in crypto.sh
+isakmp5-v	ISAKMP_sa_setup.pcap		isakmp5-v.out	-t -v
 
 # Link Management Protocol tests
 lmp		lmp.pcap		lmp.out -t -T lmp
-lmp-v		lmp.pcap		lmp-v.out -t -T lmp -v
+# lmp-v is now conditionally handled by lmp-v.sh
 
 # MPLS tests
 mpls-ldp-hello	mpls-ldp-hello.pcap	mpls-ldp-hello.out -t -v
+ldp_infloop	ldp-infinite-loop.pcap	ldp_infloop.out -t
 
 # OSPF tests
-ospf-gmpls	ospf-gmpls.pcap		ospf-gmpls.out	-t -v
+ospf-gmpls	ospf-gmpls.pcap				ospf-gmpls.out		-t -v
+ospf3_ah-vv	OSPFv3_with_AH.pcap			ospf3_ah-vv.out		-t -v -v
+ospf3_auth-vv	ospf3_auth.pcap				ospf3_auth-vv.out 	-t -v -v
+ospf3_bc-vv	OSPFv3_broadcast_adjacency.pcap		ospf3_bc-vv.out		-t -v -v
+ospf3_mp-vv	OSPFv3_multipoint_adjacencies.pcap	ospf3_mp-vv.out		-t -v -v
+ospf3_nbma-vv	OSPFv3_NBMA_adjacencies.pcap		ospf3_nbma-vv.out	-t -v -v
 
 # IKEv2 tests
 ikev2four	ikev2four.pcap		ikev2four.out	-t -v
-ikev2fourv	ikev2four.pcap		ikev2fourv.out	-t -v -v -v 
+ikev2fourv	ikev2four.pcap		ikev2fourv.out	-t -v -v -v
 ikev2fourv4	ikev2four.pcap		ikev2fourv4.out	-t -v -v -v -v
-ikev2pI2	ikev2pI2.pcap		ikev2pI2.out	-t -E "file ikev2pI2-secrets.txt" -v -v -v -v
+# ikev2pI2 test in crypto.sh
 
 # IETF ROLL RPL packets
-dio01           dio.pcap                dio.out         -t -v
+dio02           rpl-19-pickdag.pcap         rpl-19-pickdag.out  -t -v -v
+dio03           rpl-19-pickdag.pcap         rpl-19-pickdagvvv.out  -t -v -v -v
+dao01           rpl-14-dao.pcap             rpl-14-daovvv.out    -t -v -v -v
+daoack01        rpl-26-senddaoack.pcap      rpl-26-senddaovv.out -t -v -v -v
 
 # IPNET encapsulated site
 e1000g		e1000g.pcap		e1000g.out	-t
 
 # IETF FORCES WG packets and printer
 forces01        forces1.pcap            forces1.out     -t
-forces01vvv     forces1.pcap            forces1vvv.out  -t -v -v -v 
+forces01vvv     forces1.pcap            forces1vvv.out  -t -v -v -v
 forces01vvvv    forces1.pcap            forces1vvvv.out -t -v -v -v -v
 # need new pcap file, not sure what the differences were?
 #forces02        forces2.pcap            forces2.out     -t
 #forces02v       forces2.pcap            forces2v.out    -t -v
 #forces02vv      forces2.pcap            forces2vv.out   -t -v -v
 
-# 802.1ad, QinQ tests 
+# 802.1ad, QinQ tests
 qinq            QinQpacket.pcap         QinQpacket.out  -t -e
 qinqv           QinQpacket.pcap         QinQpacketv.out  -t -e -v
 
@@ -77,11 +83,13 @@
 sflow1          sflow_multiple_counter_30_pdus.pcap     sflow_multiple_counter_30_pdus.out      -t -v
 sflow2          sflow_multiple_counter_30_pdus.pcap     sflow_multiple_counter_30_pdus-nv.out      -t
 
-# Babel tests
-babel1          babel.pcap             babel1.out      -t 
+# AHCP and Babel tests
+ahcp-vv         ahcp.pcap              ahcp-vv.out     -t -vv
+babel1          babel.pcap             babel1.out      -t
 babel1v         babel.pcap             babel1v.out     -t -v
 babel_auth      babel_auth.pcap        babel_auth.out  -t -v
 babel_pad1      babel_pad1.pcap        babel_pad1.out  -t
+babel_rtt       babel_rtt.pcap         babel_rtt.out   -t -v
 
 # PPPoE tests
 pppoe           pppoe.pcap             pppoe.out       -t
@@ -89,10 +97,15 @@
 pppoes_id       pppoes.pcap            pppoes_id.out   -t pppoes 0x3b
 
 # IGMP tests
+igmpv1		IGMP_V1.pcap		igmpv1.out		-t
+igmpv2		IGMP_V2.pcap		igmpv2.out		-t
 igmpv3-queries  igmpv3-queries.pcap     igmpv3-queries.out      -t
+mtrace		mtrace.pcap		mtrace.out		-t
+dvmrp		mrinfo_query.pcap	dvmrp.out		-t
 
 # ICMPv6
 icmpv6          icmpv6.pcap             icmpv6.out      -t -vv
+icmpv6_opt24-v	icmpv6_opt24.pcap	icmpv6_opt24-v.out	-t -v
 
 # SPB tests
 spb	            spb.pcap	            spb.out -t
@@ -108,6 +121,12 @@
 # EVB tests
 evb             evb.pcap              evb.out       -t -vv
 
+# STP tests
+mstp-v		MSTP_Intra-Region_BPDUs.pcap	mstp-v.out	-t -v
+stp-v		802.1D_spanning_tree.pcap	stp-v.out	-t -v
+rstp-v		802.1w_rapid_STP.pcap		rstp-v.out	-t -v
+rpvst-v		rpvstp-trunk-native-vid5.pcap	rpvst-v.out	-t -v
+
 # RIP tests
 ripv1v2         ripv1v2.pcap            ripv1v2.out     -t -v
 ripv2_auth      ripv2_auth.pcap         ripv2_auth.out  -t -v
@@ -151,12 +170,122 @@
 of10_p3295-vv	of10_p3295.pcap		of10_p3295-vv.out	-t -vv
 of10_s4810-vvvv	of10_s4810.pcap		of10_s4810-vvvv.out	-t -vvvv
 of10_pf5240-vv	of10_pf5240.pcap	of10_pf5240-vv.out	-t -vv
+of10_7050q-v	of10_7050q.pcap		of10_7050q-v.out	-t -v
+of10_7050sx_bsn-vv	of10_7050sx_bsn.pcap		of10_7050sx_bsn-vv.out	-t -vv
 
 # GeoNetworking and CALM FAST tests
 geonet-calm-fast	geonet_and_calm_fast.pcap	geonet_and_calm_fast.out	-t -vv -n
 
-# NFLOG test case
-nflog-e		nflog.pcap		nflog-e.out		-t -e
+# M3UA tests
+m3ua isup.pcap isup.out -t
+m3ua-vv isup.pcap isupvv.out -t -vv
+
+# NFLOG test case moved to nflog-e.sh
 
 # syslog test case
 syslog-v	syslog_udp.pcap		syslog-v.out		-t -v
+
+#IPv6 tests
+ipv6-bad-version.pcap	ipv6-bad-version.pcap 	ipv6-bad-version.out	-t
+ipv6-routing-header	ipv6-routing-header.pcap	ipv6-routing-header.out -t -v
+
+# Loopback/CTP test case
+loopback	loopback.pcap		loopback.out		-t
+
+# DCCP partial checksums tests
+dccp_partial_csum_v4_simple	dccp_partial_csum_v4_simple.pcap	dccp_partial_csum_v4_simple.out -t -vv
+dccp_partial_csum_v4_longer	dccp_partial_csum_v4_longer.pcap	dccp_partial_csum_v4_longer.out -t -vv
+dccp_partial_csum_v6_simple	dccp_partial_csum_v6_simple.pcap	dccp_partial_csum_v6_simple.out -t -vv
+dccp_partial_csum_v6_longer	dccp_partial_csum_v6_longer.pcap	dccp_partial_csum_v6_longer.out -t -vv
+
+# VRRP tests
+vrrp		vrrp.pcap		vrrp.out		-t
+vrrp-v		vrrp.pcap		vrrp-v.out		-t -v
+
+# HSRP tests
+hsrp_1		HSRP_coup.pcap		hsrp_1.out	-t
+hsrp_1-v	HSRP_coup.pcap		hsrp_1-v.out	-t -v
+hsrp_2-v	HSRP_election.pcap	hsrp_2-v.out	-t -v
+hsrp_3-v	HSRP_failover.pcap	hsrp_3-v.out	-t -v
+
+# PIMv2 tests
+pimv2_dm-v		PIM-DM_pruning.pcap		pimv2_dm-v.out		-t -v
+pimv2_register-v	PIM_register_register-stop.pcap	pimv2_register-v.out	-t -v
+pimv2_sm-v		PIM-SM_join_prune.pcap		pimv2_sm-v.out		-t -v
+pimv2_bootstrap-v	PIMv2_bootstrap.pcap		pimv2_bootstrap-v.out	-t -v
+pimv2_hellos-v		PIMv2_hellos.pcap		pimv2_hellos-v.out	-t -v
+
+# IS-IS tests
+isis_infloop-v	isis-infinite-loop.pcap		isis_infloop-v.out	-t -v
+
+# RSVP tests
+rsvp_infloop-v	rsvp-infinite-loop.pcap		rsvp_infloop-v.out	-t -v
+
+# HDLC tests
+hdlc1	chdlc-slarp.pcap	hdlc1.out	-t
+hdlc2	chdlc-slarp-short.pcap	hdlc2.out	-t
+hdlc3	HDLC.pcap		hdlc3.out	-t
+hdlc4	hdlc_slarp.pcap		hdlc4.out	-t
+
+# DECnet test case
+decnet		DECnet_Phone.pcap	decnet.out	-t
+
+# RADIUS tests
+radius-v	RADIUS.pcap	radius-v.out	-t -v
+radius-rfc4675	RADIUS-RFC4675.pcap	radius-rfc4675-v.out	-t -v
+radius-rfc5176	RADIUS-RFC5176.pcap	radius-rfc5176-v.out	-t -v
+
+# link-level protocols
+dtp-v		DTP.pcap		dtp-v.out		-t -v
+lacp-ev		LACP.pcap		lacp-ev.out		-t -e -v
+lldp_cdp-ev	LLDP_and_CDP.pcap	lldp_cdp-ev.out		-t -e -v
+cdp-v		3560_CDP.pcap		cdp-v.out		-t -v
+udld-v		UDLD.pcap		udld-v.out		-t -v
+
+# EIGRP tests
+eigrp1-v	EIGRP_adjacency.pcap	eigrp1-v.out	-t -v
+eigrp2-v	EIGRP_goodbye.pcap	eigrp2-v.out	-t -v
+eigrp3-v	EIGRP_subnet_down.pcap	eigrp3-v.out	-t -v
+eigrp4-v	EIGRP_subnet_up.pcap	eigrp4-v.out	-t -v
+
+# IS-IS tests
+isis_1		ISIS_external_lsp.pcap		isis_1.out	-t
+isis_1-v	ISIS_external_lsp.pcap		isis_1-v.out	-t -v
+isis_2-v	ISIS_level1_adjacency.pcap	isis_2-v.out	-t -v
+isis_3-v	ISIS_level2_adjacency.pcap	isis_3-v.out	-t -v
+isis_4-v	ISIS_p2p_adjacency.pcap		isis_4-v.out	-t -v
+
+# ATA-over-Ethernet tests
+aoe_1		AoE_Linux.pcap		aoe_1.out	-t
+aoe_1-v		AoE_Linux.pcap		aoe_1-v.out	-t -v
+
+# Geneve tests
+geneve-v	geneve.pcap		geneve-vv.out	-t -vv
+geneve-vni	geneve.pcap		geneve-vni.out	-t geneve 0xb
+geneve-tcp	geneve.pcap		geneve-tcp.out	-t "geneve && tcp"
+
+# DHCP tests
+dhcp-rfc3004	dhcp-rfc3004.pcap	dhcp-rfc3004-v.out	-t -v
+dhcp-rfc5859	dhcp-rfc5859.pcap	dhcp-rfc5859-v.out	-t -v
+
+# bad packets from Kevin Day
+# cve-2015-2155 -- futz testing on FORCES printer
+kday1           kday1.pcap              kday1.out       -t -v
+# cve-2015-2153 -- futz testing on TCP printer
+kday2           kday2.pcap              kday2.out       -t -v
+# cve-2015-2153 -- futz testing on TCP printer
+kday3           kday3.pcap              kday3.out       -t -v
+# cve-2015-2153 -- futz testing on TCP printer
+kday4           kday4.pcap              kday4.out       -t -v
+# cve-2015-2153 -- futz testing on TCP printer
+kday5           kday5.pcap              kday5.out       -t -v
+# cve-2015-2154 -- ethernet printer
+kday6           kday6.pcap              kday6.out       -t -v
+# cve-2015-2153 -- futz testing on TCP printer
+kday7           kday7.pcap              kday7.out       -t -v
+# cve-2015-2153 -- futz testing on TCP printer
+kday8           kday8.pcap              kday8.out       -t -v
+
+# bad packets from reversex86.
+cve2015-0261_01    cve2015-0261-ipv6.pcap       cve2015-0261-ipv6.out -t -v
+cve2015-0261_02    cve2015-0261-crash.pcap      cve2015-0261-crash.out -t -v
diff --git a/tests/TESTonce b/tests/TESTonce
index c5bcb34..30ffccd 100755
--- a/tests/TESTonce
+++ b/tests/TESTonce
@@ -1,39 +1,68 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
-$debug = 0;
 system("mkdir -p NEW DIFF");
 
-if(@ARGV == 1) {
-  open(TESTLIST, "TESTLIST") || die "can not open TESTLIST: $!\n";
-  $wanted = $ARGV[0];
-  #print "Searching for test case $wanted\n";
-  while(<TESTLIST>) {
-    #print "Processing $_\n";
-    next unless (/^$wanted/);
-
-    chop;
-    ($name,$input,$output,$options)=split(/\s+/,$_, 4);
-    last;
-  }
-  close(TESTLIST);
-
-  die "Can not find test $wanted\n" unless defined($input);
-
-} elsif(@ARGV == 4) {
-  $name=$ARGV[0];
-  $input=$ARGV[1];
-  $output=$ARGV[2];
-  $options=$ARGV[3];
-} else {
-  print "Usage: TESTonce name [input output options]\n";
+if(@ARGV != 4) {
+  print "Usage: TESTonce name input output options\n";
   exit 20;
 }
 
-print "Running $name. \n" if $debug;
-print "   Input: $input, OUTPUT: $output, OPTIONS: $options\n" if $debug;
+$name=$ARGV[0];
+$input=$ARGV[1];
+$output=$ARGV[2];
+$options=$ARGV[3];
 
-print "    ";
-exec("../tcpdump 2>/dev/null -n -r $input $options | tee NEW/$output | diff -w - $output >DIFF/$output.diff");
-@cores = glob("core*");
-exit 10 if (@cores > 0);
-exit 0;
+my $r;
+
+if ($^O eq 'MSWin32') {
+    $r = system "..\\windump -n -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$output | diff $output - >DIFF/$output.diff";
+    # need to do same as below for Cygwin.
+}
+else {
+    # we used to do this as a nice pipeline, but the problem is that $r fails to
+    # to be set properly if the tcpdump core dumps.
+    $r = system "../tcpdump 2>/dev/null -n -r $input $options >NEW/$output";
+    if($r == 0x100) {
+        # this means tcpdump exited with code 1.
+        open(OUTPUT, ">>"."NEW/$output") || die "fail to open $output\n";
+        printf OUTPUT "EXIT CODE %08x\n", $r;
+        close(OUTPUT);
+        $r = 0;
+    }
+    if($r == 0) {
+        $r = system "cat NEW/$output | diff $output - >DIFF/$output.diff";
+    }
+    #print sprintf("END: %08x\n", $r);
+}
+
+if($r == 0) {
+  printf "    %-30s: passed\n", $name;
+  unlink "DIFF/$output.diff";
+  exit 0;
+}
+printf "    %-30s: TEST FAILED", $name;
+open FOUT, '>>failure-outputs.txt';
+printf FOUT "Failed test: $name\n\n";
+close FOUT;
+if(-f "DIFF/$output.diff") {
+    system "cat DIFF/$output.diff >> failure-outputs.txt";
+}
+
+if($r == -1) {
+  print " (failed to execute: $!)\n";
+  exit 30;
+}
+
+# this is not working right, $r == 0x8b00 when there is a core dump.
+# clearly, we need some platform specific perl magic to take this apart, so look for "core"
+# too.
+if($r & 127 || -f "core") {
+    my $with = ($r & 128) ? 'with' : 'without';
+    if(-f "core") {
+        $with = "with";
+    }
+    printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with;
+    exit ($r & 128) ? 10 : 20;
+}
+print "\n";
+exit $r >> 8;
diff --git a/tests/TESTrun.sh b/tests/TESTrun.sh
index d1baaa7..4cd0440 100755
--- a/tests/TESTrun.sh
+++ b/tests/TESTrun.sh
@@ -6,57 +6,62 @@
 failed=0
 cat /dev/null > failure-outputs.txt
 
-# first run any specific tests.
-for i in *.sh
-do
-  case $i in TEST*.sh) continue;; esac
-
-  if sh ./$i >DIFF/$i.result
-  then
-      echo $i: passed.
-      rm -f DIFF/$i.result
+runComplexTests()
+{
+  for i in *.sh
+  do
+    case $i in TEST*.sh) continue;; esac
+    if sh ./$i
+    then
       passed=`expr $passed + 1`
-  else
-      echo $i: failed.
+    else
       failed=`expr $failed + 1`
-  fi          
-done 
+    fi
+  done
+}
 
-echo $passed >.passed
-echo $failed >.failed
-
-# now run typical tests
-cat TESTLIST | while read name input output options
-do
-  case $name in
+runSimpleTests()
+{
+  only=$1
+  echo $passed >.passed
+  echo $failed >.failed
+  cat TESTLIST | while read name input output options
+  do
+    case $name in
       \#*) continue;;
       '') continue;;
-  esac
-
-  if ./TESTonce $name $input $output "$options"
-  then
-      echo $name: passed.
-      rm -f DIFF/$output.diff
+    esac
+    rm -f core
+    [ "$only" != "" -a "$name" != "$only" ] && continue
+    if ./TESTonce $name $input $output "$options"
+    then
       passed=`expr $passed + 1`
       echo $passed >.passed
-  else
-      echo $name: failed.
+    else
       failed=`expr $failed + 1`
       echo $failed >.failed
-      echo "Failed test: $name" >> failure-outputs.txt
-      echo >> failure-outputs.txt
-      cat DIFF/$output.diff >> failure-outputs.txt
-      echo >> failure-outputs.txt
-  fi
-done 
+    fi
+    [ "$only" != "" -a "$name" = "$only" ] && break
+  done
+  # I hate shells with their stupid, useless subshells.
+  passed=`cat .passed`
+  failed=`cat .failed`
+}
 
-# I hate shells with their stupid, useless subshells.
-passed=`cat .passed`
-failed=`cat .failed`
+if [ $# -eq 0 ]
+then
+  runComplexTests
+  runSimpleTests
+elif [ $# -eq 1 ]
+then
+  runSimpleTests $1
+else
+  echo "Usage: $0 [test_name]"
+  exit 30
+fi
 
 # exit with number of failing tests.
-echo 
-echo
+echo '------------------------------------------------'
 printf "%4u tests failed\n" $failed
 printf "%4u tests passed\n" $passed
 echo
@@ -64,8 +69,4 @@
 cat failure-outputs.txt
 echo
 echo
-exit $failed      
-
-
-
-
+exit $failed
diff --git a/tests/UDLD.pcap b/tests/UDLD.pcap
new file mode 100644
index 0000000..d8d3ff6
--- /dev/null
+++ b/tests/UDLD.pcap
Binary files differ
diff --git a/tests/ahcp-vv.out b/tests/ahcp-vv.out
new file mode 100644
index 0000000..167dd43
--- /dev/null
+++ b/tests/ahcp-vv.out
@@ -0,0 +1,76 @@
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 60) fe80::6aa3:c4ff:fef4:841e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0x7ce31135, Source Id 6a:a3:c4:ff:fe:f4:84:1e, Destination Id ff:ff:ff:ff:ff:ff:ff:ff
+	Discover, Length 24
+	 Origin Time: 2013-11-10 07:59:42 UTC
+	 Expires: 418s
+	 IPv4 Address: 0.0.0.0
+	 IPv6 Prefix
+	 Name Server
+	 NTP Server
+IP6 (class 0xc0, hlim 64, next-header UDP (17) payload length: 193) fe80::22cf:30ff:fe02:b052.5359 > fe80::6aa3:c4ff:fef4:841e.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0x9dccbd40, Source Id 08:4b:37:1e:f3:6e:1e:dc, Destination Id 6a:a3:c4:ff:fe:f4:84:1e
+	Offer, Length 157
+	 Origin Time: 2013-11-10 07:59:44 UTC
+	 Mandatory
+	 Expires: 512s
+	 IPv4 Address: 10.100.0.1
+	 Name Server: ::ffff:89.233.43.71, ::ffff:89.104.194.142, 2002:d596:2a92:1:71:53::, 2002:5968:c28e::53
+	 NTP Server: ::ffff:195.234.155.124, ::ffff:78.156.97.78, ::ffff:80.71.132.103, ::ffff:83.151.158.44
+	 My-IPv4-Address: 10.0.0.80
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 56) fe80::6aa3:c4ff:fef4:841e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0x7de31135, Source Id 6a:a3:c4:ff:fe:f4:84:1e, Destination Id 08:4b:37:1e:f3:6e:1e:dc
+	Request, Length 20
+	 Origin Time: 2013-11-10 07:59:42 UTC
+	 Expires: 405s
+	 IPv4 Address
+	 IPv6 Prefix
+	 Name Server
+	 NTP Server
+IP6 (class 0xc0, hlim 64, next-header UDP (17) payload length: 193) fe80::22cf:30ff:fe02:b052.5359 > fe80::6aa3:c4ff:fef4:841e.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0x9eccbd40, Source Id 08:4b:37:1e:f3:6e:1e:dc, Destination Id 6a:a3:c4:ff:fe:f4:84:1e
+	Ack, Length 157
+	 Origin Time: 2013-11-10 07:59:44 UTC
+	 Mandatory
+	 Expires: 524s
+	 IPv4 Address: 10.100.0.1
+	 Name Server: ::ffff:89.233.43.71, ::ffff:89.104.194.142, 2002:d596:2a92:1:71:53::, 2002:5968:c28e::53
+	 NTP Server: ::ffff:195.234.155.124, ::ffff:78.156.97.78, ::ffff:80.71.132.103, ::ffff:83.151.158.44
+	 My-IPv4-Address: 10.0.0.80
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 56) fe80::6aa3:c4ff:fef4:841e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0x7ee31135, Source Id 6a:a3:c4:ff:fe:f4:84:1e, Destination Id ff:ff:ff:ff:ff:ff:ff:ff
+	Discover, Length 20
+	 Origin Time: 2013-11-10 08:00:09 UTC
+	 Expires: 415s
+	 IPv4 Address
+	 IPv6 Prefix
+	 Name Server
+	 NTP Server
+IP6 (class 0xc0, hlim 64, next-header UDP (17) payload length: 193) fe80::22cf:30ff:fe02:b052.5359 > fe80::6aa3:c4ff:fef4:841e.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0x9fccbd40, Source Id 08:4b:37:1e:f3:6e:1e:dc, Destination Id 6a:a3:c4:ff:fe:f4:84:1e
+	Offer, Length 157
+	 Origin Time: 2013-11-10 08:00:11 UTC
+	 Mandatory
+	 Expires: 505s
+	 IPv4 Address: 10.100.0.1
+	 Name Server: ::ffff:89.233.43.71, ::ffff:89.104.194.142, 2002:d596:2a92:1:71:53::, 2002:5968:c28e::53
+	 NTP Server: ::ffff:195.234.155.124, ::ffff:78.156.97.78, ::ffff:80.71.132.103, ::ffff:83.151.158.44
+	 My-IPv4-Address: 10.0.0.80
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 56) fe80::6aa3:c4ff:fef4:841e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0x7fe31135, Source Id 6a:a3:c4:ff:fe:f4:84:1e, Destination Id 08:4b:37:1e:f3:6e:1e:dc
+	Request, Length 20
+	 Origin Time: 2013-11-10 08:00:09 UTC
+	 Expires: 409s
+	 IPv4 Address
+	 IPv6 Prefix
+	 Name Server
+	 NTP Server
+IP6 (class 0xc0, hlim 64, next-header UDP (17) payload length: 193) fe80::22cf:30ff:fe02:b052.5359 > fe80::6aa3:c4ff:fef4:841e.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0xa0ccbd40, Source Id 08:4b:37:1e:f3:6e:1e:dc, Destination Id 6a:a3:c4:ff:fe:f4:84:1e
+	Ack, Length 157
+	 Origin Time: 2013-11-10 08:00:12 UTC
+	 Mandatory
+	 Expires: 518s
+	 IPv4 Address: 10.100.0.1
+	 Name Server: ::ffff:89.233.43.71, ::ffff:89.104.194.142, 2002:d596:2a92:1:71:53::, 2002:5968:c28e::53
+	 NTP Server: ::ffff:195.234.155.124, ::ffff:78.156.97.78, ::ffff:80.71.132.103, ::ffff:83.151.158.44
+	 My-IPv4-Address: 10.0.0.80
diff --git a/tests/ahcp.pcap b/tests/ahcp.pcap
new file mode 100644
index 0000000..e3bfdf1
--- /dev/null
+++ b/tests/ahcp.pcap
Binary files differ
diff --git a/tests/aoe_1-v.out b/tests/aoe_1-v.out
new file mode 100644
index 0000000..a85e993
--- /dev/null
+++ b/tests/aoe_1-v.out
@@ -0,0 +1,888 @@
+AoE length 18, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 0
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0001cd4a
+	AFlags: [none], Err/Feature: 0, Sector Count: 1, Cmd/Status: 236
+	lba0: 0, lba1: 0, lba2: 0, lba3: 160, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 534, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0001cd4a
+	AFlags: [none], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 0, lba1: 0, lba2: 0, lba3: 160, lba4: 0, lba5: 0
+	Data: 512 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0002cd63
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 0, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0003cd63
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0004cd63
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0005cd64
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 6, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0002cd63
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 0, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0003cd63
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0004cd63
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0005cd64
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 6, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0006cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 8, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0007cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 10, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0008cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0009cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0006cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 8, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0007cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 10, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0008cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0009cd68
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000acd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 0, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000acd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 0, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000bcd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000ccd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000dcd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 6, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000bcd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000ccd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000dcd71
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 6, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000ecd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 24, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000fcd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 26, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0010cd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 28, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000ecd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 24, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x000fcd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 26, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0010cd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 28, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0011cd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 30, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0011cd74
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 30, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0012cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 8, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0013cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 10, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0014cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0015cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0012cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 8, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0013cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 10, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0014cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0015cd7b
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0016cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 56, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0017cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 58, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0018cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 60, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0019cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 62, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0016cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 56, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0017cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 58, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0018cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 60, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0019cd8f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 62, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 16, Firmware Version: 16405, Sector Count: 2, AoE: 1, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001acd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 120, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001bcd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 122, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001ccd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 124, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001dcd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 126, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001acd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 120, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001bcd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 122, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001ccd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 124, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001dcd97
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 126, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 16, Firmware Version: 16405, Sector Count: 2, AoE: 1, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001ecdfb
+	AFlags: [none], Err/Feature: 0, Sector Count: 1, Cmd/Status: 236
+	lba0: 0, lba1: 0, lba2: 0, lba3: 160, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 534, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001ecdfb
+	AFlags: [none], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 0, lba1: 0, lba2: 0, lba3: 160, lba4: 0, lba5: 0
+	Data: 512 bytes
+AoE length 18, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001f6eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 8, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x001f6eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 8, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00206eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 10, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00216eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00226eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00206eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 10, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00216eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00226eeb
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00236ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 0, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00236ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 0, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00246ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00256ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00266ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 6, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00246ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00256ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00266ef0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 6, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00276ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 24, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00286ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 26, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00296ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 28, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002a6ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 30, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00276ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 24, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00286ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 26, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00296ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 28, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002a6ef3
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 30, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002b6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 56, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002b6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 56, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002c6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 58, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002d6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 60, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002e6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 62, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002c6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 58, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002d6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 60, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002e6ef7
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 62, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002f6efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 120, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00306efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 122, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00316efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 124, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00326efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 126, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x002f6efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 120, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00306efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 122, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00316efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 124, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00326efa
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 126, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00336f01
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00336f01
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00346f07
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00346f07
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00356f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 18, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00366f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 20, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00376f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 22, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00386f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 24, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00356f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 18, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00396f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 26, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003a6f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 28, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003b6f0a
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 30, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003c6f0a
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 32, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00366f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 20, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00376f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 22, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00386f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 24, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00396f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 26, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003a6f09
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 28, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003b6f0a
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 30, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003c6f0a
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 32, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003d6f0f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 34, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003e6f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 16, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003f6f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 36, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003d6f0f
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 34, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003e6f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 16, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x003f6f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 36, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00406f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 38, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00416f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 40, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00406f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 38, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00426f13
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 42, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00436f13
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 44, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00446f13
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 46, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00416f12
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 40, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00426f13
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 42, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00436f13
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 44, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00446f13
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 46, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00456f15
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 48, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00456f15
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 48, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00466f16
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00466f16
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 16, Firmware Version: 16405, Sector Count: 2, AoE: 1, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 16, Firmware Version: 16405, Sector Count: 2, AoE: 1, CCmd: read config string
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0047e470
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x0047e470
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 18, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 16, Firmware Version: 16405, Sector Count: 2, AoE: 1, CCmd: read config string
+AoE length 18, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0xffff, Minor: 0xff, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 16, Firmware Version: 16405, Sector Count: 2, AoE: 1, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00484ae0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00484ae0
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00494ae2
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 2, Cmd/Status: 36
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00494ae2
+	AFlags: [Ext48], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004a5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 76, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004a5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 76, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004b5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 48, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004b5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 48, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004c5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004c5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 12, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004d5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004d5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 14, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004e5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 16, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004e5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 16, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004f5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 18, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x004f5ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 18, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00505ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00505ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00515ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00515ecd
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 4, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 1046, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00525ed2
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 2, Cmd/Status: 52
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 1024 bytes
+AoE length 46, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00525ed2
+	AFlags: [Ext48, Write], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 2, lba1: 0, lba2: 0, lba3: 0, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 0, Firmware Version: 0, Sector Count: 0, AoE: 0, CCmd: read config string
+AoE length 18, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Query Config Information, Tag: 0x00000000
+	Buffer Count: 16, Firmware Version: 16405, Sector Count: 2, AoE: 1, CCmd: read config string
+AoE length 46, Ver 1, Flags: [none]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00535f2f
+	AFlags: [none], Err/Feature: 0, Sector Count: 1, Cmd/Status: 236
+	lba0: 0, lba1: 0, lba2: 0, lba3: 160, lba4: 0, lba5: 0
+	Data: 24 bytes
+AoE length 534, Ver 1, Flags: [Response]
+	Major: 0x0014, Minor: 0x00, Command: Issue ATA Command, Tag: 0x00535f2f
+	AFlags: [none], Err/Feature: 0, Sector Count: 0, Cmd/Status: 64
+	lba0: 0, lba1: 0, lba2: 0, lba3: 160, lba4: 0, lba5: 0
+	Data: 512 bytes
diff --git a/tests/aoe_1.out b/tests/aoe_1.out
new file mode 100644
index 0000000..1729195
--- /dev/null
+++ b/tests/aoe_1.out
@@ -0,0 +1,186 @@
+AoE length 18, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 0
+AoE length 46, Ver 1, Flags: [none]
+AoE length 534, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 534, Ver 1, Flags: [Response]
+AoE length 18, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 18, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 1, Flags: [Response]
+AoE length 18, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 1046, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 1046, Ver 1, Flags: [none]
+AoE length 46, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 18, Ver 1, Flags: [Response]
+AoE length 46, Ver 1, Flags: [none]
+AoE length 534, Ver 1, Flags: [Response]
diff --git a/tests/babel1.out b/tests/babel1.out
index 2243847..de3d37e 100644
--- a/tests/babel1.out
+++ b/tests/babel1.out
@@ -9,17 +9,17 @@
 IP6 fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: babel 2 (8) hello
 IP6 fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: babel 2 (52) update/prefix/id update/prefix update/prefix
 IP6 fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: babel 2 (32) mh-request
-IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: UDP, length 42
-IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: UDP, length 42
-IP6 fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: UDP, length 180
-IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: UDP, length 42
-IP6 fe80::3428:af91:251:d626.5359 > ff02::cca6:c0f9:e182:5359.5359: UDP, length 42
+IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: AHCP Version 1
+IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: AHCP Version 1
+IP6 fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: AHCP Version 1
+IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: AHCP Version 1
+IP6 fe80::3428:af91:251:d626.5359 > ff02::cca6:c0f9:e182:5359.5359: AHCP Version 1
 IP6 fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: babel 2 (28) update/prefix/id
 IP6 fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: babel 2 (32) mh-request
-IP6 fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: UDP, length 180
-IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: UDP, length 42
+IP6 fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: AHCP Version 1
+IP6 fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: AHCP Version 1
 IP6 fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: babel 2 (24) hello ihu
 IP6 fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: babel 2 (28) update/prefix/id
 IP6 fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: babel 2 (32) mh-request
-IP6 fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: UDP, length 180
+IP6 fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: AHCP Version 1
 IP6 fe80::68d3:1235:d068:1f9e > ff02::16: HBH ICMP6, multicast listener report v2, 2 group record(s), length 48
diff --git a/tests/babel1v.out b/tests/babel1v.out
index c8d85ee..d483a14 100644
--- a/tests/babel1v.out
+++ b/tests/babel1v.out
@@ -1,51 +1,67 @@
 IP6 (hlim 1, next-header UDP (17) payload length: 20) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (8)
-	Hello seqno 8042 interval 200.0s
+	Hello seqno 8042 interval 20.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 20) fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (8)
-	Hello seqno 40102 interval 200.0s
+	Hello seqno 40102 interval 20.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 122) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (110)
-	Update/prefix/id 2001:660:3301:8063:218:84ff:fe1a:615d/128 metric 1 seqno 32272 interval 800.0s sub-diversity 6
+	Update/prefix/id 2001:660:3301:8063:218:84ff:fe1a:615d/128 metric 1 seqno 32272 interval 80.00s sub-diversity 6
 	Next Hop 192.168.4.25
-	Update 192.168.4.195/32 metric 1 seqno 32272 interval 800.0s sub-diversity 6
-	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 0 seqno 40149 interval 800.0s sub-diversity empty
-	Update ::/0 metric 196 seqno 40149 interval 800.0s sub-diversity empty
-	Update 192.168.4.25/32 metric 0 seqno 40149 interval 800.0s sub-diversity empty
+	Update 192.168.4.195/32 metric 1 seqno 32272 interval 80.00s sub-diversity 6
+	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 0 seqno 40149 interval 80.00s sub-diversity empty
+	Update ::/0 metric 196 seqno 40149 interval 80.00s sub-diversity empty
+	Update 192.168.4.25/32 metric 0 seqno 40149 interval 80.00s sub-diversity empty
 IP6 (hlim 1, next-header UDP (17) payload length: 36) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (24)
-	Hello seqno 8043 interval 200.0s
-	IHU fe80::3428:af91:251:d626 txcost 96 interval 600.0s
+	Hello seqno 8043 interval 20.00s
+	IHU fe80::3428:af91:251:d626 txcost 96 interval 60.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 20) fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (8)
-	Hello seqno 40103 interval 200.0s
+	Hello seqno 40103 interval 20.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 20) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (8)
-	Hello seqno 8044 interval 200.0s
+	Hello seqno 8044 interval 20.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 36) fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (24)
-	Hello seqno 40104 interval 200.0s
-	IHU fe80::68d3:1235:d068:1f9e txcost 96 interval 600.0s
+	Hello seqno 40104 interval 20.00s
+	IHU fe80::68d3:1235:d068:1f9e txcost 96 interval 60.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 20) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (8)
-	Hello seqno 8045 interval 200.0s
+	Hello seqno 8045 interval 20.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 20) fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (8)
-	Hello seqno 40105 interval 200.0s
+	Hello seqno 40105 interval 20.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 64) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (52)
-	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 800.0s
-	Update/prefix 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 800.0s
-	Update/prefix 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 800.0s
+	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 80.00s
+	Update/prefix 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 80.00s
+	Update/prefix 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 80.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 44) fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (32)
 	MH-Request (127 hops) for 2001:660:3301:8063:218:f3ff:fea9:914e/128 seqno 40150 id 02:18:f3:ff:fe:a9:91:4e
-IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] UDP, length 42
-IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] UDP, length 42
-IP6 (hlim 64, next-header UDP (17) payload length: 188) fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: [udp sum ok] UDP, length 180
-IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] UDP, length 42
-IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::3428:af91:251:d626.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] UDP, length 42
+IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0xde3e5127, Source Id 02:18:f3:ff:fe:a9:91:4e, Destination Id ff:ff:ff:ff:ff:ff:ff:ff
+	Discover, Length 14
+IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 2, Original Hopcount 2, Nonce 0xdf3e5127, Source Id 02:18:f3:ff:fe:a9:91:4e, Destination Id ff:ff:ff:ff:ff:ff:ff:ff
+	Discover, Length 14
+IP6 (hlim 64, next-header UDP (17) payload length: 188) fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0xc9b83d0d, Source Id 79:40:14:7f:b6:6d:c3:29, Destination Id 02:18:f3:ff:fe:a9:91:4e
+	Offer, Length 152
+IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0xe03e5127, Source Id 02:18:f3:ff:fe:a9:91:4e, Destination Id 79:40:14:7f:b6:6d:c3:29
+	Request, Length 14
+IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::3428:af91:251:d626.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 2, Nonce 0xdf3e5127, Source Id 02:18:f3:ff:fe:a9:91:4e, Destination Id ff:ff:ff:ff:ff:ff:ff:ff
+	Discover, Length 14
 IP6 (hlim 1, next-header UDP (17) payload length: 40) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (28)
-	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 800.0s
+	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 80.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 44) fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (32)
 	MH-Request (127 hops) for 2001:660:3301:8063:218:f3ff:fea9:914e/128 seqno 40150 id 02:18:f3:ff:fe:a9:91:4e
-IP6 (hlim 64, next-header UDP (17) payload length: 188) fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: [udp sum ok] UDP, length 180
-IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] UDP, length 42
+IP6 (hlim 64, next-header UDP (17) payload length: 188) fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: [udp sum ok] AHCP Version 1
+	Hopcount 2, Original Hopcount 2, Nonce 0xcab83d0d, Source Id 79:40:14:7f:b6:6d:c3:29, Destination Id 02:18:f3:ff:fe:a9:91:4e
+	Offer, Length 152
+IP6 (hlim 1, next-header UDP (17) payload length: 50) fe80::68d3:1235:d068:1f9e.5359 > ff02::cca6:c0f9:e182:5359.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0xe13e5127, Source Id 02:18:f3:ff:fe:a9:91:4e, Destination Id 79:40:14:7f:b6:6d:c3:29
+	Request, Length 14
 IP6 (hlim 1, next-header UDP (17) payload length: 36) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (24)
-	Hello seqno 8046 interval 200.0s
-	IHU fe80::3428:af91:251:d626 txcost 96 interval 600.0s
+	Hello seqno 8046 interval 20.00s
+	IHU fe80::3428:af91:251:d626 txcost 96 interval 60.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 40) fe80::68d3:1235:d068:1f9e.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (28)
-	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 800.0s
+	Update/prefix/id 2001:660:3301:8063:218:f3ff:fea9:914e/128 metric 65535 seqno 40149 interval 80.00s
 IP6 (hlim 1, next-header UDP (17) payload length: 44) fe80::3428:af91:251:d626.6697 > ff02::1:6.6697: [udp sum ok] babel 2 (32)
 	MH-Request (127 hops) for 2001:660:3301:8063:218:f3ff:fea9:914e/128 seqno 40150 id 02:18:f3:ff:fe:a9:91:4e
-IP6 (hlim 64, next-header UDP (17) payload length: 188) fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: [udp sum ok] UDP, length 180
+IP6 (hlim 64, next-header UDP (17) payload length: 188) fe80::3428:af91:251:d626.5359 > fe80::68d3:1235:d068:1f9e.5359: [udp sum ok] AHCP Version 1
+	Hopcount 1, Original Hopcount 1, Nonce 0xcbb83d0d, Source Id 79:40:14:7f:b6:6d:c3:29, Destination Id 02:18:f3:ff:fe:a9:91:4e
+	Ack, Length 152
 IP6 (hlim 1, next-header Options (0) payload length: 56) fe80::68d3:1235:d068:1f9e > ff02::16: HBH (rtalert: 0x0000) (padn) [icmp6 sum ok] ICMP6, multicast listener report v2, 2 group record(s) [gaddr ff02::1:6 to_ex, 0 source(s)] [gaddr ff02::cca6:c0f9:e182:5359 to_ex, 0 source(s)]
diff --git a/tests/babel_auth.out b/tests/babel_auth.out
index 56ca7fd..c918495 100644
--- a/tests/babel_auth.out
+++ b/tests/babel_auth.out
@@ -1,5 +1,5 @@
 IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 436) fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (424)
-	Hello seqno 58134 interval 40.0s
+	Hello seqno 58134 interval 4.00s
 	Update/id ::/0 metric 65535 seqno 41391 interval infinity
 	Request for any
 	TS/PC timestamp 1339081200 packetcounter 2
diff --git a/tests/babel_rtt.out b/tests/babel_rtt.out
new file mode 100644
index 0000000..a95829a
--- /dev/null
+++ b/tests/babel_rtt.out
@@ -0,0 +1,25 @@
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 26) fe80::5054:ff:fe85:5da9.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (14)
+	Hello seqno 58805 interval 4.00s sub-timestamp 2222.954827s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 52) fe80::5054:ff:fe23:4567.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (40)
+	Hello seqno 15585 interval 4.00s sub-timestamp 94.665527s
+	IHU fe80::5054:ff:fe85:5da9 txcost 96 interval 12.00s sub-timestamp 2222.954827s|91.378052s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 52) fe80::5054:ff:fe85:5da9.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (40)
+	Hello seqno 58806 interval 4.00s sub-timestamp 2226.449854s
+	IHU fe80::5054:ff:fe23:4567 txcost 96 interval 12.00s sub-timestamp 90.173759s|2222.137366s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 26) fe80::5054:ff:fe85:5da9.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (14)
+	Hello seqno 58807 interval 4.00s sub-timestamp 2229.725353s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 26) fe80::5054:ff:fe23:4567.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (14)
+	Hello seqno 15586 interval 4.00s sub-timestamp 98.956759s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 26) fe80::5054:ff:fe23:4567.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (14)
+	Hello seqno 15587 interval 4.00s sub-timestamp 102.558329s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 26) fe80::5054:ff:fe85:5da9.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (14)
+	Hello seqno 58808 interval 4.00s sub-timestamp 2234.612063s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 52) fe80::5054:ff:fe23:4567.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (40)
+	Hello seqno 15588 interval 4.00s sub-timestamp 106.492002s
+	IHU fe80::5054:ff:fe85:5da9 txcost 96 interval 12.00s sub-timestamp 2234.612063s|103.034525s
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 88) fe80::5054:ff:fe85:5da9.6696 > ff02::1:6.6696: [udp sum ok] babel 2 (76)
+	Hello seqno 58809 interval 4.00s sub-timestamp 2239.274046s
+	IHU fe80::5054:ff:fe23:4567 txcost 96 interval 12.00s sub-timestamp 98.956759s|2230.863572s
+	Next Hop 192.168.42.1
+	Router Id 48:5f:08:26:dc:36:6d:ad
+	Update 192.168.42.1/32 metric 0 seqno 61070 interval 16.00s
diff --git a/tests/babel_rtt.pcap b/tests/babel_rtt.pcap
new file mode 100644
index 0000000..b48d161
--- /dev/null
+++ b/tests/babel_rtt.pcap
Binary files differ
diff --git a/tests/bgp_infloop-v.out b/tests/bgp_infloop-v.out
new file mode 100644
index 0000000..d79a6aa
--- /dev/null
+++ b/tests/bgp_infloop-v.out
@@ -0,0 +1,15 @@
+IP (tos 0x0, ttl 128, id 1467, offset 0, flags [DF], proto TCP (6), length 74)
+    196.59.48.65.14214 > 192.168.1.1.179: Flags [P.], cksum 0xbec1 (correct), seq 2470159403:2470159437, ack 160570221, win 8192, length 34: BGP
+	Update Message (2), length: 19[|BGP]
+IP (tos 0x0, ttl 64, id 39449, offset 0, flags [DF], proto TCP (6), length 74)
+    235.101.90.12.60082 > 192.168.1.1.179: Flags [P.], cksum 0x742d (correct), seq 1978178:1978212, ack 2473062416, win 4096, length 34: BGP
+	Update Message (2), length: 19[|BGP]
+IP (tos 0x0, ttl 128, id 43331, offset 0, flags [DF], proto TCP (6), length 74)
+    179.110.109.87.40936 > 192.168.1.1.179: Flags [P.], cksum 0xd82d (correct), seq 3014673177:3014673211, ack 1498443316, win 4096, length 34: BGP
+	Update Message (2), length: 19[|BGP]
+IP (tos 0x0, ttl 64, id 51082, offset 0, flags [DF], proto TCP (6), length 74)
+    114.227.144.98.32757 > 192.168.1.1.179: Flags [P.], cksum 0xb456 (correct), seq 1117364848:1117364882, ack 3778435416, win 4096, length 34: BGP
+	Update Message (2), length: 19[|BGP]
+IP (tos 0x0, ttl 64, id 51082, offset 0, flags [DF], proto TCP (6), length 74)
+    114.227.144.98.32757 > 192.168.1.1.179: Flags [P.], cksum 0xb456 (correct), seq 0:34, ack 1, win 4096, length 34: BGP
+	Update Message (2), length: 19[|BGP]
diff --git a/tests/bgp_vpn_attrset.out b/tests/bgp_vpn_attrset.out
index a0a9f1c..c62c8d5 100644
--- a/tests/bgp_vpn_attrset.out
+++ b/tests/bgp_vpn_attrset.out
@@ -1,5 +1,5 @@
 IP (tos 0xc0, ttl 62, id 58628, offset 0, flags [none], proto TCP (6), length 173)
-    12.4.4.4.2051 > 12.1.1.1.179: Flags [P.], cksum 0xcf18 (correct), seq 3293077573:3293077694, ack 3348108582, win 16384, options [nop,nop,TS val 383131 ecr 890299], length 121: BGP, length: 121
+    12.4.4.4.2051 > 12.1.1.1.179: Flags [P.], cksum 0xcf18 (correct), seq 3293077573:3293077694, ack 3348108582, win 16384, options [nop,nop,TS val 383131 ecr 890299], length 121: BGP
 	Update Message (2), length: 121
 	  Origin (1), length: 1, Flags [T]: IGP
 	  AS Path (2), length: 0, Flags [T]: empty
diff --git a/tests/cdp-v.out b/tests/cdp-v.out
new file mode 100644
index 0000000..eb578bf
--- /dev/null
+++ b/tests/cdp-v.out
@@ -0,0 +1,57 @@
+CDPv2, ttl: 180s, checksum: 0xb0bd (unverified), length 378
+	Device-ID (0x01), value length: 6 bytes: 'Switch'
+	Version String (0x05), value length: 192 bytes: 
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(25)SEB4, RELEASE SOFTWARE (fc1)
+	  Copyright (c) 1986-2005 by Cisco Systems, Inc.
+	  Compiled Tue 30-Aug-05 17:56 by yenanh
+	Platform (0x06), value length: 20 bytes: 'cisco WS-C3560G-24PS'
+	Address (0x02), value length: 13 bytes: IPv4 (1) 192.168.0.1
+	Port-ID (0x03), value length: 18 bytes: 'GigabitEthernet0/5'
+	Capability (0x04), value length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
+	Protocol-Hello option (0x08), value length: 32 bytes: 
+	VTP Management Domain (0x09), value length: 3 bytes: 'Lab'
+	Native VLAN ID (0x0a), value length: 2 bytes: 1
+	Duplex (0x0b), value length: 1 byte: full
+	AVVID trust bitmap (0x12), value length: 1 byte: 0x00
+	AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
+	Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 192.168.0.1
+	unknown field type (0x1a), value length: 12 bytes: 
+	  0x0000:  0000 0001 0000 0000 ffff ffff
+CDPv2, ttl: 180s, checksum: 0xb0bd (unverified), length 378
+	Device-ID (0x01), value length: 6 bytes: 'Switch'
+	Version String (0x05), value length: 192 bytes: 
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(25)SEB4, RELEASE SOFTWARE (fc1)
+	  Copyright (c) 1986-2005 by Cisco Systems, Inc.
+	  Compiled Tue 30-Aug-05 17:56 by yenanh
+	Platform (0x06), value length: 20 bytes: 'cisco WS-C3560G-24PS'
+	Address (0x02), value length: 13 bytes: IPv4 (1) 192.168.0.1
+	Port-ID (0x03), value length: 18 bytes: 'GigabitEthernet0/5'
+	Capability (0x04), value length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
+	Protocol-Hello option (0x08), value length: 32 bytes: 
+	VTP Management Domain (0x09), value length: 3 bytes: 'Lab'
+	Native VLAN ID (0x0a), value length: 2 bytes: 1
+	Duplex (0x0b), value length: 1 byte: full
+	AVVID trust bitmap (0x12), value length: 1 byte: 0x00
+	AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
+	Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 192.168.0.1
+	unknown field type (0x1a), value length: 12 bytes: 
+	  0x0000:  0000 0001 0000 0000 ffff ffff
+CDPv2, ttl: 180s, checksum: 0xb0bd (unverified), length 378
+	Device-ID (0x01), value length: 6 bytes: 'Switch'
+	Version String (0x05), value length: 192 bytes: 
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(25)SEB4, RELEASE SOFTWARE (fc1)
+	  Copyright (c) 1986-2005 by Cisco Systems, Inc.
+	  Compiled Tue 30-Aug-05 17:56 by yenanh
+	Platform (0x06), value length: 20 bytes: 'cisco WS-C3560G-24PS'
+	Address (0x02), value length: 13 bytes: IPv4 (1) 192.168.0.1
+	Port-ID (0x03), value length: 18 bytes: 'GigabitEthernet0/5'
+	Capability (0x04), value length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
+	Protocol-Hello option (0x08), value length: 32 bytes: 
+	VTP Management Domain (0x09), value length: 3 bytes: 'Lab'
+	Native VLAN ID (0x0a), value length: 2 bytes: 1
+	Duplex (0x0b), value length: 1 byte: full
+	AVVID trust bitmap (0x12), value length: 1 byte: 0x00
+	AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
+	Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 192.168.0.1
+	unknown field type (0x1a), value length: 12 bytes: 
+	  0x0000:  0000 0001 0000 0000 ffff ffff
diff --git a/tests/crypto.sh b/tests/crypto.sh
new file mode 100755
index 0000000..bd41921
--- /dev/null
+++ b/tests/crypto.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# Only attempt OpenSSL-specific tests when compiled with the library.
+
+if grep '^#define HAVE_LIBCRYPTO 1$' ../config.h >/dev/null
+then
+	./TESTonce esp1 02-sunrise-sunset-esp.pcap esp1.out '-t -E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
+	./TESTonce esp2 08-sunrise-sunset-esp2.pcap esp2.out '-t -E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
+	./TESTonce esp3 02-sunrise-sunset-esp.pcap esp1.out '-t -E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
+	# Reading the secret(s) from a file does not work with Capsicum.
+	if grep '^#define HAVE_CAPSICUM 1$' ../config.h >/dev/null
+	then
+		FORMAT='    %-30s: TEST SKIPPED (compiled w/Capsicum)\n'
+		printf "$FORMAT" esp4
+		printf "$FORMAT" esp5
+		printf "$FORMAT" espudp1
+		printf "$FORMAT" ikev2pI2
+		printf "$FORMAT" isakmp4
+	else
+		./TESTonce esp4 08-sunrise-sunset-esp2.pcap esp2.out '-t -E "file esp-secrets.txt"'
+		./TESTonce esp5 08-sunrise-sunset-aes.pcap esp5.out '-t -E "file esp-secrets.txt"'
+		./TESTonce espudp1 espudp1.pcap espudp1.out '-nnnn -t -E "file esp-secrets.txt"'
+		./TESTonce ikev2pI2 ikev2pI2.pcap ikev2pI2.out '-t -E "file ikev2pI2-secrets.txt" -v -v -v -v'
+		./TESTonce isakmp4 isakmp4500.pcap isakmp4.out '-t -E "file esp-secrets.txt"'
+	fi
+else
+	FORMAT='    %-30s: TEST SKIPPED (compiled w/o OpenSSL)\n'
+	printf "$FORMAT" esp1
+	printf "$FORMAT" esp2
+	printf "$FORMAT" esp3
+	printf "$FORMAT" esp4
+	printf "$FORMAT" esp5
+	printf "$FORMAT" espudp1
+	printf "$FORMAT" ikev2pI2
+	printf "$FORMAT" isakmp4
+fi
diff --git a/tests/cve2015-0261-crash.out b/tests/cve2015-0261-crash.out
new file mode 100644
index 0000000..1946280
--- /dev/null
+++ b/tests/cve2015-0261-crash.out
@@ -0,0 +1 @@
+IP6 (class 0x03, flowlabel 0x03030, hlim 48, next-header Options (0) payload length: 12336) 3030:3030:3030:3030:3030:3030:3030:3030 > 130:3030:3030:3030:3030:3030:3030:3030: HBH [trunc] (header length 8 is too small for type 1)[|MOBILITY]
diff --git a/tests/cve2015-0261-crash.pcap b/tests/cve2015-0261-crash.pcap
new file mode 100644
index 0000000..c876c1f
--- /dev/null
+++ b/tests/cve2015-0261-crash.pcap
Binary files differ
diff --git a/tests/cve2015-0261-ipv6.out b/tests/cve2015-0261-ipv6.out
new file mode 100644
index 0000000..4674ada
--- /dev/null
+++ b/tests/cve2015-0261-ipv6.out
@@ -0,0 +1,3 @@
+IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:6767:6767:6767:6767:6767:6705: mobility: BU seq#=26471 HL lifetime=105884(type-0x67: len=103)[trunc] 
+IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:4f67:6767:6767:6767:6767:6767: (header length 8 is too small for type 6)[|MOBILITY]
+EXIT CODE 00000100
diff --git a/tests/cve2015-0261-ipv6.pcap b/tests/cve2015-0261-ipv6.pcap
new file mode 100644
index 0000000..a8a32ba
--- /dev/null
+++ b/tests/cve2015-0261-ipv6.pcap
Binary files differ
diff --git a/tests/dccp_partial_csum_v4_longer.out b/tests/dccp_partial_csum_v4_longer.out
new file mode 100644
index 0000000..1ec7002
--- /dev/null
+++ b/tests/dccp_partial_csum_v4_longer.out
@@ -0,0 +1,30 @@
+IP (tos 0x0, ttl 64, id 65312, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xaaf3 (correct)) DCCP-Request (service=0) seq 38464816766 <change_l ack_ratio 2, change_r ccid 2, change_l ccid 2>
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xb04b (correct)) DCCP-Response (service=0) (ack=38464816766) seq 1960341146 <nop, nop, change_l ack_ratio 2, confirm_r ccid 2 2, confirm_l ccid 2 2, confirm_r ack_ratio 2>
+IP (tos 0x0, ttl 64, id 65313, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xf53a (correct)) DCCP-Ack (ack=1960341146) seq 38464816767 <nop, confirm_r ack_ratio 2, ack_vector0 0x00, elapsed_time 1>
+IP (tos 0x0, ttl 64, id 65314, offset 0, flags [DF], proto DCCP (33), length 152)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 6, cksum 0x7d28 (correct)) DCCP-DataAck (ack=1960341146) seq 38464816768 <nop, nop, ack_vector0 0x00, elapsed_time 1249, ndp_count 1>
+IP (tos 0x0, ttl 64, id 3176, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xfc63 (correct)) DCCP-Ack (ack=38464816768) seq 1960341147 <nop, ack_vector0 0x01, elapsed_time 1>
+IP (tos 0x0, ttl 64, id 65315, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 6, cksum 0x5e05 (correct)) DCCP-DataAck (ack=1960341147) seq 38464816769 <nop, ack_vector0 0x00, elapsed_time 84>
+IP (tos 0x0, ttl 64, id 3177, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0x0165 (correct)) DCCP-Ack (ack=38464816769) seq 1960341148 <nop, nop, ack_vector0 0x00, ndp_count 1>
+IP (tos 0x0, ttl 64, id 65316, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 6, cksum 0x5e1e (correct)) DCCP-DataAck (ack=1960341148) seq 38464816770 <nop, ack_vector0 0x00, elapsed_time 57>
+IP (tos 0x0, ttl 64, id 65317, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 6, cksum 0x5e15 (correct)) DCCP-DataAck (ack=1960341148) seq 38464816771 <nop, ack_vector0 0x00, elapsed_time 65>
+IP (tos 0x0, ttl 64, id 3178, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xfb32 (correct)) DCCP-Ack (ack=38464816770) seq 1960341149 <nop, nop, ack_vector0 0x00, elapsed_time 1, ndp_count 2>
+IP (tos 0x0, ttl 64, id 3179, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xfa2f (correct)) DCCP-Ack (ack=38464816771) seq 1960341150 <nop, nop, ack_vector0 0x01, elapsed_time 1, ndp_count 3>
+IP (tos 0x0, ttl 64, id 65318, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 6, cksum 0x5e35 (correct)) DCCP-DataAck (ack=1960341150) seq 38464816772 <nop, ack_vector0 0x00, elapsed_time 30>
+IP (tos 0x0, ttl 64, id 65319, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xf638 (correct)) DCCP-Close (ack=1960341150) seq 38464816773 <nop, ack_vector0 0x00, elapsed_time 37>
+IP (tos 0x0, ttl 64, id 3180, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xfb2c (correct)) DCCP-Ack (ack=38464816772) seq 1960341151 <nop, nop, ack_vector0 0x00, elapsed_time 1, ndp_count 4>
+IP (tos 0x0, ttl 64, id 3181, offset 0, flags [DF], proto DCCP (33), length 60)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xef25 (correct)) DCCP-Reset (code=closed) (ack=38464816773) seq 1960341152 <nop, nop, ack_vector0 0x01, elapsed_time 2, ndp_count 5>
diff --git a/tests/dccp_partial_csum_v4_longer.pcap b/tests/dccp_partial_csum_v4_longer.pcap
new file mode 100644
index 0000000..f1176c0
--- /dev/null
+++ b/tests/dccp_partial_csum_v4_longer.pcap
Binary files differ
diff --git a/tests/dccp_partial_csum_v4_simple.out b/tests/dccp_partial_csum_v4_simple.out
new file mode 100644
index 0000000..6fee70d
--- /dev/null
+++ b/tests/dccp_partial_csum_v4_simple.out
@@ -0,0 +1,14 @@
+IP (tos 0x0, ttl 64, id 30095, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.52667 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xa766 (correct)) DCCP-Request (service=0) seq 33164071488 <change_l ack_ratio 2, change_r ccid 2, change_l ccid 2>
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68)
+    139.133.209.65.5001 > 139.133.209.176.52667: DCCP (CCVal 0, CsCov 0, cksum 0x9a1a (correct)) DCCP-Response (service=0) (ack=33164071488) seq 1925546833 <nop, nop, change_l ack_ratio 2, confirm_r ccid 2 2, confirm_l ccid 2 2, confirm_r ack_ratio 2>
+IP (tos 0x0, ttl 64, id 30096, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.176.52667 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xdf09 (correct)) DCCP-Ack (ack=1925546833) seq 33164071489 <nop, confirm_r ack_ratio 2, ack_vector0 0x00, elapsed_time 1>
+IP (tos 0x0, ttl 64, id 30097, offset 0, flags [DF], proto DCCP (33), length 68)
+    139.133.209.176.52667 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 1, cksum 0x9dfa (correct)) DCCP-DataAck (ack=1925546833) seq 33164071490 <nop, nop, ack_vector0 0x00, elapsed_time 70, ndp_count 1>
+IP (tos 0x0, ttl 64, id 24713, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.52667: DCCP (CCVal 0, CsCov 0, cksum 0xe632 (correct)) DCCP-Ack (ack=33164071490) seq 1925546834 <nop, ack_vector0 0x01, elapsed_time 1>
+IP (tos 0x0, ttl 64, id 30098, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.52667 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xdf8d (correct)) DCCP-Close (ack=1925546834) seq 33164071491 <nop, ack_vector0 0x00, elapsed_time 166>
+IP (tos 0x0, ttl 64, id 24714, offset 0, flags [DF], proto DCCP (33), length 60)
+    139.133.209.65.5001 > 139.133.209.176.52667: DCCP (CCVal 0, CsCov 0, cksum 0xd900 (correct)) DCCP-Reset (code=closed) (ack=33164071491) seq 1925546835 <nop, nop, ack_vector0 0x00, elapsed_time 3, ndp_count 1>
diff --git a/tests/dccp_partial_csum_v4_simple.pcap b/tests/dccp_partial_csum_v4_simple.pcap
new file mode 100644
index 0000000..a9c3d66
--- /dev/null
+++ b/tests/dccp_partial_csum_v4_simple.pcap
Binary files differ
diff --git a/tests/dccp_partial_csum_v6_longer.out b/tests/dccp_partial_csum_v6_longer.out
new file mode 100644
index 0000000..76355d4
--- /dev/null
+++ b/tests/dccp_partial_csum_v6_longer.out
@@ -0,0 +1,9 @@
+IP6 (hlim 64, next-header DCCP (33) payload length: 32) 3ffe::1.55024 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 0, cksum 0xd538 (correct)) DCCP-Request (service=0) seq 1559687427 <change_l ack_ratio 2, change_r ccid 2, change_l ccid 2>
+IP6 (hlim 64, next-header DCCP (33) payload length: 48) 3ffe::2.5001 > 3ffe::1.55024: DCCP (CCVal 0, CsCov 0, cksum 0x81a3 (correct)) DCCP-Response (service=0) (ack=1559687427) seq 1585962456 <nop, nop, change_l ack_ratio 2, confirm_r ccid 2 2, confirm_l ccid 2 2, confirm_r ack_ratio 2>
+IP6 (hlim 64, next-header DCCP (33) payload length: 36) 3ffe::1.55024 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 0, cksum 0xc692 (correct)) DCCP-Ack (ack=1585962456) seq 1559687428 <nop, confirm_r ack_ratio 2, ack_vector0 0x00, elapsed_time 1>
+IP6 (hlim 64, next-header DCCP (33) payload length: 164) 3ffe::1.55024 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 10, cksum 0xe362 (correct)) DCCP-DataAck (ack=1585962456) seq 1559687429 <nop, nop, ack_vector0 0x00, elapsed_time 7282, ndp_count 1>
+IP6 (hlim 64, next-header DCCP (33) payload length: 32) 3ffe::2.5001 > 3ffe::1.55024: DCCP (CCVal 0, CsCov 0, cksum 0xcdbb (correct)) DCCP-Ack (ack=1559687429) seq 1585962457 <nop, ack_vector0 0x01, elapsed_time 1>
+IP6 (hlim 64, next-header DCCP (33) payload length: 160) 3ffe::1.55024 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 10, cksum 0x5574 (correct)) DCCP-DataAck (ack=1585962457) seq 1559687430 <nop, ack_vector0 0x00, elapsed_time 55>
+IP6 (hlim 64, next-header DCCP (33) payload length: 32) 3ffe::1.55024 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 0, cksum 0xc778 (correct)) DCCP-Close (ack=1585962457) seq 1559687431 <nop, ack_vector0 0x00, elapsed_time 67>
+IP6 (hlim 64, next-header DCCP (33) payload length: 32) 3ffe::2.5001 > 3ffe::1.55024: DCCP (CCVal 0, CsCov 0, cksum 0xd2bc (correct)) DCCP-Ack (ack=1559687430) seq 1585962458 <nop, nop, ack_vector0 0x00, ndp_count 1>
+IP6 (hlim 64, next-header DCCP (33) payload length: 40) 3ffe::2.5001 > 3ffe::1.55024: DCCP (CCVal 0, CsCov 0, cksum 0xc186 (correct)) DCCP-Reset (code=closed) (ack=1559687431) seq 1585962459 <nop, nop, ack_vector0 0x01, elapsed_time 1, ndp_count 2>
diff --git a/tests/dccp_partial_csum_v6_longer.pcap b/tests/dccp_partial_csum_v6_longer.pcap
new file mode 100644
index 0000000..644379d
--- /dev/null
+++ b/tests/dccp_partial_csum_v6_longer.pcap
Binary files differ
diff --git a/tests/dccp_partial_csum_v6_simple.out b/tests/dccp_partial_csum_v6_simple.out
new file mode 100644
index 0000000..317a68a
--- /dev/null
+++ b/tests/dccp_partial_csum_v6_simple.out
@@ -0,0 +1,7 @@
+IP6 (hlim 64, next-header DCCP (33) payload length: 32) 3ffe::1.52921 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 0, cksum 0xef1a (correct)) DCCP-Request (service=0) seq 1337846929 <change_l ack_ratio 2, change_r ccid 2, change_l ccid 2>
+IP6 (hlim 64, next-header DCCP (33) payload length: 48) 3ffe::2.5001 > 3ffe::1.52921: DCCP (CCVal 0, CsCov 0, cksum 0x0b73 (correct)) DCCP-Response (service=0) (ack=1337846929) seq 1385331168 <nop, nop, change_l ack_ratio 2, confirm_r ccid 2 2, confirm_l ccid 2 2, confirm_r ack_ratio 2>
+IP6 (hlim 64, next-header DCCP (33) payload length: 36) 3ffe::1.52921 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 0, cksum 0x5062 (correct)) DCCP-Ack (ack=1385331168) seq 1337846930 <nop, confirm_r ack_ratio 2, ack_vector0 0x00, elapsed_time 1>
+IP6 (hlim 64, next-header DCCP (33) payload length: 48) 3ffe::1.52921 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 1, cksum 0x8792 (correct)) DCCP-DataAck (ack=1385331168) seq 1337846931 <nop, nop, ack_vector0 0x00, elapsed_time 49357, ndp_count 1>
+IP6 (hlim 64, next-header DCCP (33) payload length: 32) 3ffe::2.5001 > 3ffe::1.52921: DCCP (CCVal 0, CsCov 0, cksum 0x578b (correct)) DCCP-Ack (ack=1337846931) seq 1385331169 <nop, ack_vector0 0x01, elapsed_time 1>
+IP6 (hlim 64, next-header DCCP (33) payload length: 32) 3ffe::1.52921 > 3ffe::2.5001: DCCP (CCVal 0, CsCov 0, cksum 0x61e0 (correct)) DCCP-Close (ack=1385331169) seq 1337846932 <nop, ack_vector0 0x00, elapsed_time 61355>
+IP6 (hlim 64, next-header DCCP (33) payload length: 40) 3ffe::2.5001 > 3ffe::1.52921: DCCP (CCVal 0, CsCov 0, cksum 0x4b59 (correct)) DCCP-Reset (code=closed) (ack=1337846932) seq 1385331170 <nop, nop, ack_vector0 0x00, elapsed_time 2, ndp_count 1>
diff --git a/tests/dccp_partial_csum_v6_simple.pcap b/tests/dccp_partial_csum_v6_simple.pcap
new file mode 100644
index 0000000..c343d90
--- /dev/null
+++ b/tests/dccp_partial_csum_v6_simple.pcap
Binary files differ
diff --git a/tests/decnet.out b/tests/decnet.out
new file mode 100644
index 0000000..8767c62
--- /dev/null
+++ b/tests/decnet.out
@@ -0,0 +1,139 @@
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+1.1 > 1.1 34 conn-initiate 8195>0 ver 4.1 segsize 16403 
+1.1 > 1.1 9 [|decnet]
+1.1 > 1.1 16 conn-confirm 8196>8195 ver 4.1 segsize 16403 
+1.1 > 1.1 19 link-service 8195>8196 ack 0 ackdat 0 seg 1 dat seg count 0 
+1.1 > 1.1 15 ils-ack 8196>8195 ack 1 ackdat 0 
+1.1 > 1.1 45 data 8195>8196 ack 0 oack 0 seg 1 
+1.1 > 1.1 15 data-ack 8196>8195 ack 1 oack 1 
+1.1 > 1.1 18 data 8196>8195 ack 1 oack 1 seg 1 
+1.1 > 1.1 15 data-ack 8195>8196 ack 1 oack 0 
+1.1 > 1.1 33 data 8195>8196 ack 1 oack 0 seg 2 
+1.1 > 1.1 15 data-ack 8196>8195 ack 2 oack 1 
+1.1 > 1.1 18 data 8196>8195 ack 2 oack 1 seg 2 
+1.1 > 1.1 15 data-ack 8195>8196 ack 2 oack 0 
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+1.1 > 1.1 34 conn-initiate 8197>0 ver 4.1 segsize 16403 
+1.1 > 1.1 9 [|decnet]
+1.1 > 1.1 16 conn-confirm 8198>8197 ver 4.1 segsize 16403 
+1.1 > 1.1 19 link-service 8197>8198 ack 0 ackdat 0 seg 1 dat seg count 0 
+1.1 > 1.1 15 ils-ack 8198>8197 ack 1 ackdat 0 
+1.1 > 1.1 45 data 8197>8198 ack 0 oack 0 seg 1 
+1.1 > 1.1 15 data-ack 8198>8197 ack 1 oack 1 
+1.1 > 1.1 32 data 8197>8198 ack 0 oack 0 seg 2 
+1.1 > 1.1 15 data-ack 8198>8197 ack 2 oack 1 
+1.1 > 1.1 18 data 8198>8197 ack 2 oack 1 seg 1 
+1.1 > 1.1 15 data-ack 8197>8198 ack 1 oack 0 
+1.1 > 1.1 19 link-service 8195>8196 ack 0 ackdat 2 seg 2 dat seg count 0 
+1.1 > 1.1 15 ils-ack 8196>8195 ack 2 ackdat 2 
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+1.1 > 1.1 19 link-service 8197>8198 ack 0 ackdat 1 seg 2 dat seg count 0 
+1.1 > 1.1 19 link-service 8198>8197 ack 1 ackdat 2 seg 1 dat seg count 0 
+1.1 > 1.1 15 ils-ack 8198>8197 ack 2 ackdat 2 
+1.1 > 1.1 15 ils-ack 8197>8198 ack 1 ackdat 1 
+1.1 > 1.1 19 link-service 8195>8196 ack 0 ackdat 2 seg 3 dat seg count 0 
+1.1 > 1.1 15 ils-ack 8196>8195 ack 3 ackdat 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 3 
+1.1 > 1.1 15 data-ack 8198>8197 ack 3 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 4 
+1.1 > 1.1 15 data-ack 8198>8197 ack 4 oack 2 
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 5 
+1.1 > 1.1 15 data-ack 8198>8197 ack 5 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 6 
+1.1 > 1.1 15 data-ack 8198>8197 ack 6 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 7 
+1.1 > 1.1 15 data-ack 8198>8197 ack 7 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 8 
+1.1 > 1.1 15 data-ack 8198>8197 ack 8 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 9 
+1.1 > 1.1 15 data-ack 8198>8197 ack 9 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 10 
+1.1 > 1.1 15 data-ack 8198>8197 ack 10 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 11 
+1.1 > 1.1 15 data-ack 8198>8197 ack 11 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 12 
+1.1 > 1.1 15 data-ack 8198>8197 ack 12 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 13 
+1.1 > 1.1 15 data-ack 8198>8197 ack 13 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 14 
+1.1 > 1.1 15 data-ack 8198>8197 ack 14 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 15 
+1.1 > 1.1 15 data-ack 8198>8197 ack 15 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 16 
+1.1 > 1.1 15 data-ack 8198>8197 ack 16 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 17 
+1.1 > 1.1 15 data-ack 8198>8197 ack 17 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 18 
+1.1 > 1.1 15 data-ack 8198>8197 ack 18 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 19 
+1.1 > 1.1 15 data-ack 8198>8197 ack 19 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 20 
+1.1 > 1.1 15 data-ack 8198>8197 ack 20 oack 2 
+1.1 > 1.1 33 data 8197>8198 ack 1 oack 1 seg 21 
+1.1 > 1.1 15 data-ack 8198>8197 ack 21 oack 2 
+1.1 > 1.1 19 link-service 8195>8196 ack 0 ackdat 2 seg 4 dat seg count 0 
+1.1 > 1.1 15 ils-ack 8196>8195 ack 4 ackdat 2 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 3 
+1.1 > 1.1 15 data-ack 8196>8195 ack 3 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 4 
+1.1 > 1.1 15 data-ack 8196>8195 ack 4 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 5 
+1.1 > 1.1 15 data-ack 8196>8195 ack 5 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 6 
+1.1 > 1.1 15 data-ack 8196>8195 ack 6 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 7 
+1.1 > 1.1 15 data-ack 8196>8195 ack 7 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 8 
+1.1 > 1.1 15 data-ack 8196>8195 ack 8 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 9 
+1.1 > 1.1 15 data-ack 8196>8195 ack 9 oack 4 
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 10 
+1.1 > 1.1 15 data-ack 8196>8195 ack 10 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 11 
+1.1 > 1.1 15 data-ack 8196>8195 ack 11 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 12 
+1.1 > 1.1 15 data-ack 8196>8195 ack 12 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 13 
+1.1 > 1.1 15 data-ack 8196>8195 ack 13 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 14 
+1.1 > 1.1 15 data-ack 8196>8195 ack 14 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 15 
+1.1 > 1.1 15 data-ack 8196>8195 ack 15 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 16 
+1.1 > 1.1 15 data-ack 8196>8195 ack 16 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 17 
+1.1 > 1.1 15 data-ack 8196>8195 ack 17 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 18 
+1.1 > 1.1 15 data-ack 8196>8195 ack 18 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 19 
+1.1 > 1.1 15 data-ack 8196>8195 ack 19 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 20 
+1.1 > 1.1 15 data-ack 8196>8195 ack 20 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 21 
+1.1 > 1.1 15 data-ack 8196>8195 ack 21 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 22 
+1.1 > 1.1 15 data-ack 8196>8195 ack 22 oack 4 
+1.1 > 1.1 33 data 8195>8196 ack 2 oack 0 seg 23 
+1.1 > 1.1 15 data-ack 8196>8195 ack 23 oack 4 
+1.1 > 1.1 19 link-service 8197>8198 ack 1 ackdat 1 seg 3 dat seg count 0 
+1.1 > 1.1 19 link-service 8198>8197 ack 2 ackdat 21 seg 2 dat seg count 0 
+1.1 > 1.1 15 ils-ack 8198>8197 ack 3 ackdat 21 
+1.1 > 1.1 15 ils-ack 8197>8198 ack 2 ackdat 1 
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
+1.1 > 1.1 32 data 8197>8198 ack 1 oack 2 seg 22 
+1.1 > 1.1 15 data-ack 8198>8197 ack 22 oack 3 
+1.1 > 1.1 32 data 8197>8198 ack 1 oack 2 seg 23 
+1.1 > 1.1 15 data-ack 8198>8197 ack 23 oack 3 
+1.1 > 1.1 14 disconn-initiate 8196>8195 object rejected connect 
+1.1 > 1.1 13 disconn-confirm 8195>8196 disconnect complete 
+1.1 > 1.1 14 disconn-initiate 8197>8198 object rejected connect 
+1.1 > 1.1 13 disconn-confirm 8198>8197 disconnect complete 
+1.1 > 1.1 13 disconn-confirm 8198>8197 disconnect complete 
+1.1 > 1.1 13 disconn-confirm 8195>8196 disconnect complete 
+endnode-hello endnode vers 2 eco 0 ueco 0 src 1.1 blksize 16434 rtr 0.0 hello 10 data 2
diff --git a/tests/dhcp-rfc3004-v.out b/tests/dhcp-rfc3004-v.out
new file mode 100644
index 0000000..2032817
--- /dev/null
+++ b/tests/dhcp-rfc3004-v.out
@@ -0,0 +1,55 @@
+IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
+    0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0c:29:1f:74:06, length 300, xid 0x6e32864, Flags [none]
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: Discover
+	    Requested-IP Option 50, length 4: 192.168.1.4
+	    Parameter-Request Option 55, length 7: 
+	      Subnet-Mask, BR, Time-Zone, Default-Gateway
+	      Domain-Name, Domain-Name-Server, Hostname
+	    User-Class Option 77, length 37: 
+	      instance#1: "subopt1", length 7
+	      instance#2: "subopt2-123456789", length 17
+	      instance#3: "subopt3-12", length 10
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 308)
+    192.168.1.1.67 > 192.168.1.4.68: BOOTP/DHCP, Reply, length 280, xid 0x6e32864, Flags [none]
+	  Your-IP 192.168.1.4
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: Offer
+	    Server-ID Option 54, length 4: 192.168.1.1
+	    Lease-Time Option 51, length 4: 86400
+	    Subnet-Mask Option 1, length 4: 255.255.255.0
+	    Default-Gateway Option 3, length 4: 192.168.1.1
+	    Domain-Name-Server Option 6, length 4: 192.168.1.1
+	    Domain-Name Option 15, length 4: "Home"
+IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 332)
+    0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0c:29:1f:74:06, length 304, xid 0x6e32864, Flags [none]
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: Request
+	    Server-ID Option 54, length 4: 192.168.1.1
+	    Requested-IP Option 50, length 4: 192.168.1.4
+	    Parameter-Request Option 55, length 7: 
+	      Subnet-Mask, BR, Time-Zone, Default-Gateway
+	      Domain-Name, Domain-Name-Server, Hostname
+	    User-Class Option 77, length 37: 
+	      instance#1: "subopt1", length 7
+	      instance#2: "subopt2-123456789", length 17
+	      instance#3: "subopt3-12", length 10
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 308)
+    192.168.1.1.67 > 192.168.1.4.68: BOOTP/DHCP, Reply, length 280, xid 0x6e32864, Flags [none]
+	  Your-IP 192.168.1.4
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: ACK
+	    Server-ID Option 54, length 4: 192.168.1.1
+	    Lease-Time Option 51, length 4: 86400
+	    Subnet-Mask Option 1, length 4: 255.255.255.0
+	    Default-Gateway Option 3, length 4: 192.168.1.1
+	    Domain-Name-Server Option 6, length 4: 192.168.1.1
+	    Domain-Name Option 15, length 4: "Home"
diff --git a/tests/dhcp-rfc3004.pcap b/tests/dhcp-rfc3004.pcap
new file mode 100644
index 0000000..11806c3
--- /dev/null
+++ b/tests/dhcp-rfc3004.pcap
Binary files differ
diff --git a/tests/dhcp-rfc5859-v.out b/tests/dhcp-rfc5859-v.out
new file mode 100644
index 0000000..6f31368
--- /dev/null
+++ b/tests/dhcp-rfc5859-v.out
@@ -0,0 +1,44 @@
+IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
+    0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0c:29:1f:74:06, length 300, xid 0xde549277, Flags [none]
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: Discover
+	    Parameter-Request Option 55, length 8: 
+	      Subnet-Mask, BR, Time-Zone, Default-Gateway
+	      Domain-Name, Domain-Name-Server, Hostname, TFTP-Server-Address
+IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
+    192.168.1.1.67 > 192.168.1.4.68: BOOTP/DHCP, Reply, length 300, xid 0xde549277, Flags [none]
+	  Your-IP 192.168.1.4
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: Offer
+	    Server-ID Option 54, length 4: 192.168.1.1
+	    Lease-Time Option 51, length 4: 43200
+	    Subnet-Mask Option 1, length 4: 255.255.255.0
+	    Default-Gateway Option 3, length 4: 192.168.1.1
+	    TFTP-Server-Address Option 150, length 8: 192.168.1.10,192.168.1.11
+IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
+    0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0c:29:1f:74:06, length 300, xid 0xde549277, Flags [none]
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: Request
+	    Server-ID Option 54, length 4: 192.168.1.1
+	    Requested-IP Option 50, length 4: 192.168.1.4
+	    Parameter-Request Option 55, length 8: 
+	      Subnet-Mask, BR, Time-Zone, Default-Gateway
+	      Domain-Name, Domain-Name-Server, Hostname, TFTP-Server-Address
+IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
+    192.168.1.1.67 > 192.168.1.4.68: BOOTP/DHCP, Reply, length 300, xid 0xde549277, Flags [none]
+	  Your-IP 192.168.1.4
+	  Client-Ethernet-Address 00:0c:29:1f:74:06
+	  Vendor-rfc1048 Extensions
+	    Magic Cookie 0x63825363
+	    DHCP-Message Option 53, length 1: ACK
+	    Server-ID Option 54, length 4: 192.168.1.1
+	    Lease-Time Option 51, length 4: 43200
+	    Subnet-Mask Option 1, length 4: 255.255.255.0
+	    Default-Gateway Option 3, length 4: 192.168.1.1
+	    TFTP-Server-Address Option 150, length 8: 192.168.1.10,192.168.1.11
diff --git a/tests/dhcp-rfc5859.pcap b/tests/dhcp-rfc5859.pcap
new file mode 100644
index 0000000..e16a6b3
--- /dev/null
+++ b/tests/dhcp-rfc5859.pcap
Binary files differ
diff --git a/tests/dio.out b/tests/dio.out
deleted file mode 100644
index 4f0c189..0000000
--- a/tests/dio.out
+++ /dev/null
@@ -1 +0,0 @@
-IP6 (hlim 255, next-header ICMPv6 (58) payload length: 24) fe80::1000:ff:fe64:6423 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object
diff --git a/tests/dio.pcap b/tests/dio.pcap
deleted file mode 100644
index 8170635..0000000
--- a/tests/dio.pcap
+++ /dev/null
Binary files differ
diff --git a/tests/dtp-v.out b/tests/dtp-v.out
new file mode 100644
index 0000000..1d73418
--- /dev/null
+++ b/tests/dtp-v.out
@@ -0,0 +1,30 @@
+DTPv1, length 38
+	Domain TLV (0x0001) TLV, length 8, Lab
+	Status TLV (0x0002) TLV, length 5, 0x4
+	DTP type TLV (0x0003) TLV, length 5, 0x40
+	Neighbor TLV (0x0004) TLV, length 10, 00:19:06:ea:b8:85
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP Unnumbered, ui, Flags [Command], length 76
+DTPv1, length 38
+	Domain TLV (0x0001) TLV, length 8, Lab
+	Status TLV (0x0002) TLV, length 5, 0x4
+	DTP type TLV (0x0003) TLV, length 5, 0x40
+	Neighbor TLV (0x0004) TLV, length 10, 00:19:06:ea:b8:85
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP Unnumbered, ui, Flags [Command], length 76
+DTPv1, length 38
+	Domain TLV (0x0001) TLV, length 8, Lab
+	Status TLV (0x0002) TLV, length 5, 0x4
+	DTP type TLV (0x0003) TLV, length 5, 0x40
+	Neighbor TLV (0x0004) TLV, length 10, 00:19:06:ea:b8:85
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP Unnumbered, ui, Flags [Command], length 76
+DTPv1, length 38
+	Domain TLV (0x0001) TLV, length 8, Lab
+	Status TLV (0x0002) TLV, length 5, 0x4
+	DTP type TLV (0x0003) TLV, length 5, 0x40
+	Neighbor TLV (0x0004) TLV, length 10, 00:19:06:ea:b8:85
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP Unnumbered, ui, Flags [Command], length 76
+DTPv1, length 38
+	Domain TLV (0x0001) TLV, length 8, Lab
+	Status TLV (0x0002) TLV, length 5, 0x4
+	DTP type TLV (0x0003) TLV, length 5, 0x40
+	Neighbor TLV (0x0004) TLV, length 10, 00:19:06:ea:b8:85
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP Unnumbered, ui, Flags [Command], length 76
diff --git a/tests/dvmrp.out b/tests/dvmrp.out
new file mode 100644
index 0000000..d612f7d
--- /dev/null
+++ b/tests/dvmrp.out
@@ -0,0 +1,2 @@
+IP 10.0.0.1 > 2.2.2.2: igmp dvmrp Ask-neighbors2
+IP 2.2.2.2 > 10.0.0.1: igmp dvmrp Neighbors2 (v 12.4): [10.0.0.2 -> 10.0.0.1 (1/0/querier)] [10.0.0.9 -> 10.0.0.10 (1/0)]
diff --git a/tests/eigrp1-v.out b/tests/eigrp1-v.out
new file mode 100644
index 0000000..e2e75b2
--- /dev/null
+++ b/tests/eigrp1-v.out
@@ -0,0 +1,444 @@
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Update (1), chksum: 0xfd82, Flags: [Init]
+	seq: 0x00000017, ack: 0x00000000, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Update (1), chksum: 0xfd82, Flags: [Init]
+	seq: 0x00000017, ack: 0x00000000, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Update (1), chksum: 0xfd6b, Flags: [Init]
+	seq: 0x00000017, ack: 0x00000017, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 239)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Update (1), chksum: 0x24b9, Flags: [none]
+	seq: 0x00000018, ack: 0x00000017, AS: 100, length: 199
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.1.0/24, nexthop: self
+	      delay 25 ms, bandwidth 25600 Kbps, mtu 1500, hop 0, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:        10.0.0.4/30, nexthop: self
+	      delay 256 ms, bandwidth 256000 Kbps, mtu 1500, hop 0, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.3.0/24, nexthop: self
+	      delay 281 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:       10.0.0.12/30, nexthop: self
+	      delay 512 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 537 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:        10.0.0.8/30, nexthop: self
+	      delay 768 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.2.0/24, nexthop: self
+	      delay 793 ms, bandwidth 256000 Kbps, mtu 1500, hop 3, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 154)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Update (1), chksum: 0x7d9b, Flags: [none]
+	seq: 0x00000018, ack: 0x00000018, AS: 100, length: 114
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.2.0/24, nexthop: self
+	      delay 25 ms, bandwidth 25600 Kbps, mtu 1500, hop 0, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:        10.0.0.8/30, nexthop: self
+	      delay 256 ms, bandwidth 256000 Kbps, mtu 1500, hop 0, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 281 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:       10.0.0.12/30, nexthop: self
+	      delay 512 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd7e, Flags: [none]
+	seq: 0x00000000, ack: 0x00000018, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 77)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xc352, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 37
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+	  Sequence TLV (0x0003), length: 9
+	    0x0000:  040a 0000 01
+	  Next Multicast Sequence TLV (0x0005), length: 8
+	    0x0000:  0000 0019
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 125)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Update (1), chksum: 0xa2d8, Flags: [Conditionally Received]
+	seq: 0x00000019, ack: 0x00000000, AS: 100, length: 85
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.1.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:        10.0.0.4/30, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.3.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 125)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Update (1), chksum: 0xa2c2, Flags: [none]
+	seq: 0x00000019, ack: 0x00000018, AS: 100, length: 85
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.1.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:        10.0.0.4/30, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.3.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd7d, Flags: [none]
+	seq: 0x00000000, ack: 0x00000019, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 125)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Update (1), chksum: 0x9dd9, Flags: [none]
+	seq: 0x00000019, ack: 0x00000000, AS: 100, length: 85
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.2.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 29
+	    IPv4 prefix:        10.0.0.8/30, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd7d, Flags: [none]
+	seq: 0x00000000, ack: 0x00000019, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
diff --git a/tests/eigrp2-v.out b/tests/eigrp2-v.out
new file mode 100644
index 0000000..112a1a4
--- /dev/null
+++ b/tests/eigrp2-v.out
@@ -0,0 +1,120 @@
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xf167, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 255, k2 255, k3 255, k4 255, k5 255
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
diff --git a/tests/eigrp3-v.out b/tests/eigrp3-v.out
new file mode 100644
index 0000000..4e344cb
--- /dev/null
+++ b/tests/eigrp3-v.out
@@ -0,0 +1,143 @@
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Update (1), chksum: 0x7876, Flags: [none]
+	seq: 0x00000034, ack: 0x00000000, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd62, Flags: [none]
+	seq: 0x00000000, ack: 0x00000034, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Query (3), chksum: 0x5f7e, Flags: [none]
+	seq: 0x0000002e, ack: 0x00000000, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 0 Kbps, mtu 1500, hop 0, reliability 0, load 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd68, Flags: [none]
+	seq: 0x00000000, ack: 0x0000002e, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Query (3), chksum: 0x5f75, Flags: [none]
+	seq: 0x00000037, ack: 0x00000000, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 0 Kbps, mtu 1500, hop 0, reliability 0, load 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd5f, Flags: [none]
+	seq: 0x00000000, ack: 0x00000037, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Reply (4), chksum: 0x5f44, Flags: [none]
+	seq: 0x00000030, ack: 0x00000037, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 0 Kbps, mtu 1500, hop 0, reliability 0, load 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd66, Flags: [none]
+	seq: 0x00000000, ack: 0x00000030, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Reply (4), chksum: 0x5f46, Flags: [none]
+	seq: 0x00000039, ack: 0x00000030, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 0 Kbps, mtu 1500, hop 0, reliability 0, load 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd5d, Flags: [none]
+	seq: 0x00000000, ack: 0x00000039, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
diff --git a/tests/eigrp4-v.out b/tests/eigrp4-v.out
new file mode 100644
index 0000000..f5cb165
--- /dev/null
+++ b/tests/eigrp4-v.out
@@ -0,0 +1,105 @@
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Update (1), chksum: 0x0a7e, Flags: [none]
+	seq: 0x0000002d, ack: 0x00000000, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 281 ms, bandwidth 256000 Kbps, mtu 1500, hop 1, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Update (1), chksum: 0xa67a, Flags: [none]
+	seq: 0x0000002f, ack: 0x00000000, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 537 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.1 > 10.0.0.2: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd69, Flags: [none]
+	seq: 0x00000000, ack: 0x0000002d, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd67, Flags: [none]
+	seq: 0x00000000, ack: 0x0000002f, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 68)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Update (1), chksum: 0x7878, Flags: [none]
+	seq: 0x00000032, ack: 0x00000000, AS: 100, length: 28
+	  IP Internal routes TLV (0x0102), length: 28
+	    IPv4 prefix:     192.168.4.0/24, nexthop: self
+	      delay 42949672 ms, bandwidth 256000 Kbps, mtu 1500, hop 2, reliability 255, load 1
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 40)
+    10.0.0.2 > 10.0.0.1: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xfd64, Flags: [none]
+	seq: 0x00000000, ack: 0x00000032, AS: 100, length: 0
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.1 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
+IP (tos 0xc0, ttl 2, id 0, offset 0, flags [none], proto EIGRP (88), length 60)
+    10.0.0.2 > 224.0.0.10: 
+	EIGRP v2, opcode: Hello (5), chksum: 0xee68, Flags: [none]
+	seq: 0x00000000, ack: 0x00000000, AS: 100, length: 20
+	  General Parameters TLV (0x0001), length: 12
+	    holdtime: 15s, k1 1, k2 0, k3 1, k4 0, k5 0
+	  Software Version TLV (0x0004), length: 8
+	    IOS version: 12.4, EIGRP version 1.2
diff --git a/tests/forces1vvv.out b/tests/forces1vvv.out
index 32b7693..ebd378c 100644
--- a/tests/forces1vvv.out
+++ b/tests/forces1vvv.out
@@ -13,7 +13,7 @@
           Oper TLV  GetResp(0x9) length 296
            PATH-DATA TLV, length 292 (data encapsulated 288 Bytes)
             Pathdata: Flags 0x0 ID count 1
-              ID#01: 2
+            ID#01: 2
               FULLDATA TLV (Length 280 DataLen 276 Bytes)
                [
                0x0000:  0000 0000 0000 0001 0000 0001 0000 0001
@@ -67,7 +67,7 @@
           Oper TLV  Get(0x7) length 16
            PATH-DATA TLV, length 12 (data encapsulated 8 Bytes)
             Pathdata: Flags 0x0 ID count 1
-              ID#01: 1
+            ID#01: 1
 
 
 IP (tos 0x0, ttl 46, id 4, offset 0, flags [DF], proto SCTP (132), length 112)
@@ -85,8 +85,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 1
+            ID#01: 60
+            ID#02: 1
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
@@ -111,8 +111,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 2
+            ID#01: 60
+            ID#02: 2
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
@@ -134,8 +134,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 3
+            ID#01: 60
+            ID#02: 3
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
@@ -160,8 +160,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 1
+            ID#01: 60
+            ID#02: 1
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
diff --git a/tests/forces1vvvv.out b/tests/forces1vvvv.out
index 6bc4faa..e418839 100644
--- a/tests/forces1vvvv.out
+++ b/tests/forces1vvvv.out
@@ -13,7 +13,7 @@
           Oper TLV  GetResp(0x9) length 296
            PATH-DATA TLV, length 292 (data encapsulated 288 Bytes)
             Pathdata: Flags 0x0 ID count 1
-              ID#01: 2
+            ID#01: 2
               FULLDATA TLV (Length 280 DataLen 276 Bytes)
                [
                0x0000:  0000 0000 0000 0001 0000 0001 0000 0001
@@ -96,7 +96,7 @@
           Oper TLV  Get(0x7) length 16
            PATH-DATA TLV, length 12 (data encapsulated 8 Bytes)
             Pathdata: Flags 0x0 ID count 1
-              ID#01: 1
+            ID#01: 1
 
 	  Raw ForCES message
 	 [
@@ -121,8 +121,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 1
+            ID#01: 60
+            ID#02: 1
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
@@ -154,8 +154,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 2
+            ID#01: 60
+            ID#02: 2
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
@@ -184,8 +184,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 3
+            ID#01: 60
+            ID#02: 3
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
@@ -217,8 +217,8 @@
           Oper TLV  SetProp(0x2) length 28
            PATH-DATA TLV, length 24 (data encapsulated 20 Bytes)
             Pathdata: Flags 0x0 ID count 2
-              ID#01: 60
-              ID#02: 1
+            ID#01: 60
+            ID#02: 1
               FULLDATA TLV (Length 8 DataLen 4 Bytes)
                [
                0x0000:  0000 0001
diff --git a/tests/geneve-tcp.out b/tests/geneve-tcp.out
new file mode 100644
index 0000000..e2cdc37
--- /dev/null
+++ b/tests/geneve-tcp.out
@@ -0,0 +1,33 @@
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [S], seq 397610159, win 14600, options [mss 1460,sackOK,TS val 2876069566 ecr 0,nop,wscale 7], length 0
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [S.], seq 2910871522, ack 397610160, win 28960, options [mss 1460,sackOK,TS val 84248969 ecr 2876069566,nop,wscale 7], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 1, win 115, options [nop,nop,TS val 2876069566 ecr 84248969], length 0
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 1:40, ack 1, win 227, options [nop,nop,TS val 84248971 ecr 2876069566], length 39
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1:22, ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 21
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [.], ack 22, win 227, options [nop,nop,TS val 84248971 ecr 2876069573], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 22:814, ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 792
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [.], ack 814, win 239, options [nop,nop,TS val 84248971 ecr 2876069573], length 0
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 40:1024, ack 814, win 239, options [nop,nop,TS val 84248971 ecr 2876069573], length 984
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 814:838, ack 1024, win 130, options [nop,nop,TS val 2876069574 ecr 84248971], length 24
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 1024:1176, ack 838, win 239, options [nop,nop,TS val 84248972 ecr 2876069574], length 152
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 838:982, ack 1176, win 145, options [nop,nop,TS val 2876069577 ecr 84248972], length 144
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 1176:1896, ack 982, win 251, options [nop,nop,TS val 84248973 ecr 2876069577], length 720
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 982:998, ack 1896, win 161, options [nop,nop,TS val 2876069583 ecr 84248973], length 16
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [.], ack 998, win 251, options [nop,nop,TS val 84248983 ecr 2876069583], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 998:1046, ack 1896, win 161, options [nop,nop,TS val 2876069620 ecr 84248983], length 48
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [.], ack 1046, win 251, options [nop,nop,TS val 84248983 ecr 2876069620], length 0
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 1896:1944, ack 1046, win 251, options [nop,nop,TS val 84248983 ecr 2876069620], length 48
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1046:1110, ack 1944, win 161, options [nop,nop,TS val 2876069621 ecr 84248983], length 64
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 1944:2008, ack 1110, win 251, options [nop,nop,TS val 84248983 ecr 2876069621], length 64
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2008, win 161, options [nop,nop,TS val 2876069662 ecr 84248983], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1110:1254, ack 2008, win 161, options [nop,nop,TS val 2876070845 ecr 84248983], length 144
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 2008:2040, ack 1254, win 264, options [nop,nop,TS val 84249289 ecr 2876070845], length 32
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2040, win 161, options [nop,nop,TS val 2876070846 ecr 84249289], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1254:1382, ack 2040, win 161, options [nop,nop,TS val 2876070846 ecr 84249289], length 128
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 2040:2088, ack 1382, win 276, options [nop,nop,TS val 84249292 ecr 2876070846], length 48
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1382:1830, ack 2088, win 161, options [nop,nop,TS val 2876070859 ecr 84249292], length 448
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 2088:2200, ack 1830, win 289, options [nop,nop,TS val 84249292 ecr 2876070859], length 112
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 2200:2488, ack 1830, win 289, options [nop,nop,TS val 84249293 ecr 2876070859], length 288
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2488, win 176, options [nop,nop,TS val 2876070861 ecr 84249292], length 0
+IP 20.0.0.1.22540 > 20.0.0.2.6081: Geneve, Flags [C], vni 0xa, options [8 bytes]: IP 30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], seq 2488:2568, ack 1830, win 289, options [nop,nop,TS val 84249351 ecr 2876070861], length 80
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2568, win 176, options [nop,nop,TS val 2876071133 ecr 84249351], length 0
diff --git a/tests/geneve-vni.out b/tests/geneve-vni.out
new file mode 100644
index 0000000..8b6858b
--- /dev/null
+++ b/tests/geneve-vni.out
@@ -0,0 +1,20 @@
+IP 20.0.0.2.50525 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2 > 30.0.0.1: ICMP echo reply, id 10578, seq 23, length 64
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [S], seq 397610159, win 14600, options [mss 1460,sackOK,TS val 2876069566 ecr 0,nop,wscale 7], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2910871523, win 115, options [nop,nop,TS val 2876069566 ecr 84248969], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 0:21, ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 21
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 21:813, ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 792
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 813:837, ack 1024, win 130, options [nop,nop,TS val 2876069574 ecr 84248971], length 24
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 837:981, ack 1176, win 145, options [nop,nop,TS val 2876069577 ecr 84248972], length 144
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 981:997, ack 1896, win 161, options [nop,nop,TS val 2876069583 ecr 84248973], length 16
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 997:1045, ack 1896, win 161, options [nop,nop,TS val 2876069620 ecr 84248983], length 48
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1045:1109, ack 1944, win 161, options [nop,nop,TS val 2876069621 ecr 84248983], length 64
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2008, win 161, options [nop,nop,TS val 2876069662 ecr 84248983], length 0
+IP 20.0.0.2.50525 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2 > 30.0.0.1: ICMP echo reply, id 10578, seq 24, length 64
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1109:1253, ack 2008, win 161, options [nop,nop,TS val 2876070845 ecr 84248983], length 144
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2040, win 161, options [nop,nop,TS val 2876070846 ecr 84249289], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1253:1381, ack 2040, win 161, options [nop,nop,TS val 2876070846 ecr 84249289], length 128
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], seq 1381:1829, ack 2088, win 161, options [nop,nop,TS val 2876070859 ecr 84249292], length 448
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2488, win 176, options [nop,nop,TS val 2876070861 ecr 84249292], length 0
+IP 20.0.0.2.43443 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2.51225 > 30.0.0.1.22: Flags [.], ack 2568, win 176, options [nop,nop,TS val 2876071133 ecr 84249351], length 0
+IP 20.0.0.2.50525 > 20.0.0.1.6081: Geneve, Flags [none], vni 0xb: IP 30.0.0.2 > 30.0.0.1: ICMP echo reply, id 10578, seq 25, length 64
diff --git a/tests/geneve-vv.out b/tests/geneve-vv.out
new file mode 100644
index 0000000..eb50e66
--- /dev/null
+++ b/tests/geneve-vv.out
@@ -0,0 +1,156 @@
+IP (tos 0x0, ttl 64, id 57261, offset 0, flags [DF], proto UDP (17), length 142)
+    20.0.0.1.12618 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 48546, offset 0, flags [DF], proto ICMP (1), length 84)
+    30.0.0.1 > 30.0.0.2: ICMP echo request, id 10578, seq 23, length 64
+IP (tos 0x0, ttl 64, id 34821, offset 0, flags [DF], proto UDP (17), length 134)
+    20.0.0.2.50525 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 4595, offset 0, flags [none], proto ICMP (1), length 84)
+    30.0.0.2 > 30.0.0.1: ICMP echo reply, id 10578, seq 23, length 64
+IP (tos 0x0, ttl 64, id 34822, offset 0, flags [DF], proto UDP (17), length 110)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23057, offset 0, flags [DF], proto TCP (6), length 60)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [S], cksum 0xe437 (correct), seq 397610159, win 14600, options [mss 1460,sackOK,TS val 2876069566 ecr 0,nop,wscale 7], length 0
+IP (tos 0x0, ttl 64, id 57274, offset 0, flags [DF], proto UDP (17), length 118)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [S.], cksum 0x101d (correct), seq 2910871522, ack 397610160, win 28960, options [mss 1460,sackOK,TS val 84248969 ecr 2876069566,nop,wscale 7], length 0
+IP (tos 0x0, ttl 64, id 34823, offset 0, flags [DF], proto UDP (17), length 102)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23058, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [.], cksum 0xaf96 (correct), seq 1, ack 1, win 115, options [nop,nop,TS val 2876069566 ecr 84248969], length 0
+IP (tos 0x0, ttl 64, id 57275, offset 0, flags [DF], proto UDP (17), length 149)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54890, offset 0, flags [DF], proto TCP (6), length 91)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0xf103 (correct), seq 1:40, ack 1, win 227, options [nop,nop,TS val 84248971 ecr 2876069566], length 39
+IP (tos 0x0, ttl 64, id 34824, offset 0, flags [DF], proto UDP (17), length 102)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23059, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [.], cksum 0xaf66 (correct), seq 1, ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 0
+IP (tos 0x0, ttl 64, id 34825, offset 0, flags [DF], proto UDP (17), length 123)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23060, offset 0, flags [DF], proto TCP (6), length 73)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0xeea0 (correct), seq 1:22, ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 21
+IP (tos 0x0, ttl 64, id 57276, offset 0, flags [DF], proto UDP (17), length 110)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54891, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [.], cksum 0xaee1 (correct), seq 40, ack 22, win 227, options [nop,nop,TS val 84248971 ecr 2876069573], length 0
+IP (tos 0x0, ttl 64, id 34826, offset 0, flags [DF], proto UDP (17), length 894)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23061, offset 0, flags [DF], proto TCP (6), length 844)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0xe70f (correct), seq 22:814, ack 40, win 115, options [nop,nop,TS val 2876069573 ecr 84248971], length 792
+IP (tos 0x0, ttl 64, id 57277, offset 0, flags [DF], proto UDP (17), length 110)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54892, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [.], cksum 0xabbd (correct), seq 40, ack 814, win 239, options [nop,nop,TS val 84248971 ecr 2876069573], length 0
+IP (tos 0x0, ttl 64, id 57278, offset 0, flags [DF], proto UDP (17), length 1094)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54893, offset 0, flags [DF], proto TCP (6), length 1036)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0xb8b1 (correct), seq 40:1024, ack 814, win 239, options [nop,nop,TS val 84248971 ecr 2876069573], length 984
+IP (tos 0x0, ttl 64, id 34827, offset 0, flags [DF], proto UDP (17), length 126)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23062, offset 0, flags [DF], proto TCP (6), length 76)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0x79fb (correct), seq 814:838, ack 1024, win 130, options [nop,nop,TS val 2876069574 ecr 84248971], length 24
+IP (tos 0x0, ttl 64, id 57279, offset 0, flags [DF], proto UDP (17), length 262)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54894, offset 0, flags [DF], proto TCP (6), length 204)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0xa779 (correct), seq 1024:1176, ack 838, win 239, options [nop,nop,TS val 84248972 ecr 2876069574], length 152
+IP (tos 0x0, ttl 64, id 34828, offset 0, flags [DF], proto UDP (17), length 246)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23063, offset 0, flags [DF], proto TCP (6), length 196)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0xecb6 (correct), seq 838:982, ack 1176, win 145, options [nop,nop,TS val 2876069577 ecr 84248972], length 144
+IP (tos 0x0, ttl 64, id 57280, offset 0, flags [DF], proto UDP (17), length 830)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54895, offset 0, flags [DF], proto TCP (6), length 772)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0x6255 (correct), seq 1176:1896, ack 982, win 251, options [nop,nop,TS val 84248973 ecr 2876069577], length 720
+IP (tos 0x0, ttl 64, id 34829, offset 0, flags [DF], proto UDP (17), length 118)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23064, offset 0, flags [DF], proto TCP (6), length 68)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0x99de (correct), seq 982:998, ack 1896, win 161, options [nop,nop,TS val 2876069583 ecr 84248973], length 16
+IP (tos 0x0, ttl 64, id 57288, offset 0, flags [DF], proto UDP (17), length 110)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54896, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [.], cksum 0xa3a3 (correct), seq 1896, ack 998, win 251, options [nop,nop,TS val 84248983 ecr 2876069583], length 0
+IP (tos 0x0, ttl 64, id 34830, offset 0, flags [DF], proto UDP (17), length 150)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23065, offset 0, flags [DF], proto TCP (6), length 100)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0xb953 (correct), seq 998:1046, ack 1896, win 161, options [nop,nop,TS val 2876069620 ecr 84248983], length 48
+IP (tos 0x0, ttl 64, id 57289, offset 0, flags [DF], proto UDP (17), length 110)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54897, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [.], cksum 0xa34e (correct), seq 1896, ack 1046, win 251, options [nop,nop,TS val 84248983 ecr 2876069620], length 0
+IP (tos 0x0, ttl 64, id 57290, offset 0, flags [DF], proto UDP (17), length 158)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54898, offset 0, flags [DF], proto TCP (6), length 100)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0xd5ed (correct), seq 1896:1944, ack 1046, win 251, options [nop,nop,TS val 84248983 ecr 2876069620], length 48
+IP (tos 0x0, ttl 64, id 34831, offset 0, flags [DF], proto UDP (17), length 166)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23066, offset 0, flags [DF], proto TCP (6), length 116)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0xf2f0 (correct), seq 1046:1110, ack 1944, win 161, options [nop,nop,TS val 2876069621 ecr 84248983], length 64
+IP (tos 0x0, ttl 64, id 57291, offset 0, flags [DF], proto UDP (17), length 174)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54899, offset 0, flags [DF], proto TCP (6), length 116)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0x4ac6 (correct), seq 1944:2008, ack 1110, win 251, options [nop,nop,TS val 84248983 ecr 2876069621], length 64
+IP (tos 0x0, ttl 64, id 34832, offset 0, flags [DF], proto UDP (17), length 102)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23067, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [.], cksum 0xa2ce (correct), seq 1110, ack 2008, win 161, options [nop,nop,TS val 2876069662 ecr 84248983], length 0
+IP (tos 0x0, ttl 64, id 57466, offset 0, flags [DF], proto UDP (17), length 142)
+    20.0.0.1.12618 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 48621, offset 0, flags [DF], proto ICMP (1), length 84)
+    30.0.0.1 > 30.0.0.2: ICMP echo request, id 10578, seq 24, length 64
+IP (tos 0x0, ttl 64, id 34833, offset 0, flags [DF], proto UDP (17), length 134)
+    20.0.0.2.50525 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 4596, offset 0, flags [none], proto ICMP (1), length 84)
+    30.0.0.2 > 30.0.0.1: ICMP echo reply, id 10578, seq 24, length 64
+IP (tos 0x0, ttl 64, id 34834, offset 0, flags [DF], proto UDP (17), length 246)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23068, offset 0, flags [DF], proto TCP (6), length 196)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0x318f (correct), seq 1110:1254, ack 2008, win 161, options [nop,nop,TS val 2876070845 ecr 84248983], length 144
+IP (tos 0x0, ttl 64, id 57567, offset 0, flags [DF], proto UDP (17), length 142)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54900, offset 0, flags [DF], proto TCP (6), length 84)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0x3a95 (correct), seq 2008:2040, ack 1254, win 264, options [nop,nop,TS val 84249289 ecr 2876070845], length 32
+IP (tos 0x0, ttl 64, id 34835, offset 0, flags [DF], proto UDP (17), length 102)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23069, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [.], cksum 0x9c4c (correct), seq 1254, ack 2040, win 161, options [nop,nop,TS val 2876070846 ecr 84249289], length 0
+IP (tos 0x0, ttl 64, id 34836, offset 0, flags [DF], proto UDP (17), length 230)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 23070, offset 0, flags [DF], proto TCP (6), length 180)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0x31d7 (correct), seq 1254:1382, ack 2040, win 161, options [nop,nop,TS val 2876070846 ecr 84249289], length 128
+IP (tos 0x0, ttl 64, id 57570, offset 0, flags [DF], proto UDP (17), length 158)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54901, offset 0, flags [DF], proto TCP (6), length 100)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0x8215 (correct), seq 2040:2088, ack 1382, win 276, options [nop,nop,TS val 84249292 ecr 2876070846], length 48
+IP (tos 0x0, ttl 64, id 34837, offset 0, flags [DF], proto UDP (17), length 550)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x10, ttl 64, id 23071, offset 0, flags [DF], proto TCP (6), length 500)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [P.], cksum 0x5e86 (correct), seq 1382:1830, ack 2088, win 161, options [nop,nop,TS val 2876070859 ecr 84249292], length 448
+IP (tos 0x0, ttl 64, id 57571, offset 0, flags [DF], proto UDP (17), length 222)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54902, offset 0, flags [DF], proto TCP (6), length 164)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0x2c83 (correct), seq 2088:2200, ack 1830, win 289, options [nop,nop,TS val 84249292 ecr 2876070859], length 112
+IP (tos 0x0, ttl 64, id 57572, offset 0, flags [DF], proto UDP (17), length 398)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54903, offset 0, flags [DF], proto TCP (6), length 340)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0xbe0e (correct), seq 2200:2488, ack 1830, win 289, options [nop,nop,TS val 84249293 ecr 2876070859], length 288
+IP (tos 0x0, ttl 64, id 34838, offset 0, flags [DF], proto UDP (17), length 102)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x10, ttl 64, id 23072, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [.], cksum 0x982b (correct), seq 1830, ack 2488, win 176, options [nop,nop,TS val 2876070861 ecr 84249292], length 0
+IP (tos 0x0, ttl 64, id 57627, offset 0, flags [DF], proto UDP (17), length 190)
+    20.0.0.1.22540 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 54904, offset 0, flags [DF], proto TCP (6), length 132)
+    30.0.0.1.22 > 30.0.0.2.51225: Flags [P.], cksum 0x3d51 (correct), seq 2488:2568, ack 1830, win 289, options [nop,nop,TS val 84249351 ecr 2876070861], length 80
+IP (tos 0x0, ttl 64, id 34839, offset 0, flags [DF], proto UDP (17), length 102)
+    20.0.0.2.43443 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x10, ttl 64, id 23073, offset 0, flags [DF], proto TCP (6), length 52)
+    30.0.0.2.51225 > 30.0.0.1.22: Flags [.], cksum 0x9690 (correct), seq 1830, ack 2568, win 176, options [nop,nop,TS val 2876071133 ecr 84249351], length 0
+IP (tos 0x0, ttl 64, id 57691, offset 0, flags [DF], proto UDP (17), length 142)
+    20.0.0.1.12618 > 20.0.0.2.6081: [no cksum] Geneve, Flags [C], vni 0xa, options [class Standard (0x0) type 0x80(C) len 8 data 0000000c]
+	IP (tos 0x0, ttl 64, id 48733, offset 0, flags [DF], proto ICMP (1), length 84)
+    30.0.0.1 > 30.0.0.2: ICMP echo request, id 10578, seq 25, length 64
+IP (tos 0x0, ttl 64, id 34840, offset 0, flags [DF], proto UDP (17), length 134)
+    20.0.0.2.50525 > 20.0.0.1.6081: [no cksum] Geneve, Flags [none], vni 0xb
+	IP (tos 0x0, ttl 64, id 4597, offset 0, flags [none], proto ICMP (1), length 84)
+    30.0.0.2 > 30.0.0.1: ICMP echo reply, id 10578, seq 25, length 64
diff --git a/tests/geneve.pcap b/tests/geneve.pcap
new file mode 100644
index 0000000..2795493
--- /dev/null
+++ b/tests/geneve.pcap
Binary files differ
diff --git a/tests/hdlc1.out b/tests/hdlc1.out
new file mode 100644
index 0000000..3c510e0
--- /dev/null
+++ b/tests/hdlc1.out
@@ -0,0 +1 @@
+SLARP (length: 18), keepalive: mineseen=0x000d0a31, yourseen=0x57405e26, reliability=0x04ff, link uptime=49d12h52m33s
diff --git a/tests/hdlc2.out b/tests/hdlc2.out
new file mode 100644
index 0000000..78a2663
--- /dev/null
+++ b/tests/hdlc2.out
@@ -0,0 +1 @@
+SLARP (length: 14), keepalive: mineseen=0x000d0a31, yourseen=0x57405e26, reliability=0x04ff
diff --git a/tests/hdlc3.out b/tests/hdlc3.out
new file mode 100644
index 0000000..edbc605
--- /dev/null
+++ b/tests/hdlc3.out
@@ -0,0 +1,38 @@
+SLARP (length: 20), keepalive: mineseen=0x00000005, yourseen=0x00000002, reliability=0xffff, link uptime=0d2h12m5s
+SLARP (length: 20), keepalive: mineseen=0x00000003, yourseen=0x00000005, reliability=0xffff, link uptime=0d6h51m44s
+SLARP (length: 20), keepalive: mineseen=0x00000006, yourseen=0x00000003, reliability=0xffff, link uptime=0d2h12m15s
+SLARP (length: 20), keepalive: mineseen=0x00000004, yourseen=0x00000006, reliability=0xffff, link uptime=0d6h51m54s
+SLARP (length: 20), keepalive: mineseen=0x00000007, yourseen=0x00000004, reliability=0xffff, link uptime=0d2h12m25s
+SLARP (length: 20), keepalive: mineseen=0x00000005, yourseen=0x00000007, reliability=0xffff, link uptime=0d6h52m4s
+IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 0, seq 0, length 80
+IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 0, seq 0, length 80
+IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 0, seq 1, length 80
+IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 0, seq 1, length 80
+IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 0, seq 2, length 80
+IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 0, seq 2, length 80
+IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 0, seq 3, length 80
+IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 0, seq 3, length 80
+IP 10.0.0.1 > 10.0.0.2: ICMP echo request, id 0, seq 4, length 80
+IP 10.0.0.2 > 10.0.0.1: ICMP echo reply, id 0, seq 4, length 80
+unknown CHDLC protocol (0x2000)
+SLARP (length: 20), keepalive: mineseen=0x00000008, yourseen=0x00000005, reliability=0xffff, link uptime=0d2h12m35s
+SLARP (length: 20), keepalive: mineseen=0x00000006, yourseen=0x00000008, reliability=0xffff, link uptime=0d6h52m14s
+unknown CHDLC protocol (0x2000)
+SLARP (length: 20), keepalive: mineseen=0x00000009, yourseen=0x00000006, reliability=0xffff, link uptime=0d2h12m45s
+SLARP (length: 20), keepalive: mineseen=0x00000007, yourseen=0x00000009, reliability=0xffff, link uptime=0d6h52m24s
+SLARP (length: 20), keepalive: mineseen=0x0000000a, yourseen=0x00000007, reliability=0xffff, link uptime=0d2h12m55s
+SLARP (length: 20), keepalive: mineseen=0x00000008, yourseen=0x0000000a, reliability=0xffff, link uptime=0d6h52m34s
+SLARP (length: 20), keepalive: mineseen=0x0000000b, yourseen=0x00000008, reliability=0xffff, link uptime=0d2h13m5s
+SLARP (length: 20), keepalive: mineseen=0x00000009, yourseen=0x0000000b, reliability=0xffff, link uptime=0d6h52m44s
+SLARP (length: 20), keepalive: mineseen=0x0000000c, yourseen=0x00000009, reliability=0xffff, link uptime=0d2h13m15s
+SLARP (length: 20), keepalive: mineseen=0x0000000a, yourseen=0x0000000c, reliability=0xffff, link uptime=0d6h52m54s
+SLARP (length: 20), keepalive: mineseen=0x0000000d, yourseen=0x0000000a, reliability=0xffff, link uptime=0d2h13m25s
+SLARP (length: 20), keepalive: mineseen=0x0000000b, yourseen=0x0000000d, reliability=0xffff, link uptime=0d6h53m4s
+unknown CHDLC protocol (0x2000)
+SLARP (length: 20), keepalive: mineseen=0x0000000e, yourseen=0x0000000b, reliability=0xffff, link uptime=0d2h13m35s
+SLARP (length: 20), keepalive: mineseen=0x0000000c, yourseen=0x0000000e, reliability=0xffff, link uptime=0d6h53m14s
+unknown CHDLC protocol (0x2000)
+SLARP (length: 20), keepalive: mineseen=0x0000000f, yourseen=0x0000000c, reliability=0xffff, link uptime=0d2h13m45s
+SLARP (length: 20), keepalive: mineseen=0x0000000d, yourseen=0x0000000f, reliability=0xffff, link uptime=0d6h53m24s
+SLARP (length: 20), keepalive: mineseen=0x00000010, yourseen=0x0000000d, reliability=0xffff, link uptime=0d2h13m55s
+SLARP (length: 20), keepalive: mineseen=0x0000000e, yourseen=0x00000010, reliability=0xffff, link uptime=0d6h53m34s
diff --git a/tests/hdlc4.out b/tests/hdlc4.out
new file mode 100644
index 0000000..deffd79
--- /dev/null
+++ b/tests/hdlc4.out
@@ -0,0 +1,7 @@
+SLARP (length: 20), keepalive: mineseen=0x00000001, yourseen=0x00000000, reliability=0xffff, link uptime=1d0h1m32s
+SLARP (length: 20), request
+SLARP (length: 20), reply 15.0.0.1/255.255.255.252
+SLARP (length: 20), keepalive: mineseen=0x00000001, yourseen=0x00000000, reliability=0xffff, link uptime=1d0h1m42s
+SLARP (length: 20), keepalive: mineseen=0x00000001, yourseen=0x00000001, reliability=0xffff, link uptime=1d4h41m19s
+SLARP (length: 20), keepalive: mineseen=0x00000002, yourseen=0x00000001, reliability=0xffff, link uptime=1d0h1m52s
+SLARP (length: 20), keepalive: mineseen=0x00000002, yourseen=0x00000002, reliability=0xffff, link uptime=1d4h41m29s
diff --git a/tests/hdlc_slarp.pcap b/tests/hdlc_slarp.pcap
new file mode 100644
index 0000000..3a24dca
--- /dev/null
+++ b/tests/hdlc_slarp.pcap
Binary files differ
diff --git a/tests/hsrp_1-v.out b/tests/hsrp_1-v.out
new file mode 100644
index 0000000..61b8e2b
--- /dev/null
+++ b/tests/hsrp_1-v.out
@@ -0,0 +1,102 @@
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=3 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-coup 20: state=listen group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=3 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
diff --git a/tests/hsrp_1.out b/tests/hsrp_1.out
new file mode 100644
index 0000000..326e57b
--- /dev/null
+++ b/tests/hsrp_1.out
@@ -0,0 +1,51 @@
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=3 [|hsrp]
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-coup 20: state=listen group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=3 [|hsrp]
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
+IP 192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP 192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1
+IP 192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1
diff --git a/tests/hsrp_2-v.out b/tests/hsrp_2-v.out
new file mode 100644
index 0000000..d96227f
--- /dev/null
+++ b/tests/hsrp_2-v.out
@@ -0,0 +1,98 @@
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=3 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
diff --git a/tests/hsrp_3-v.out b/tests/hsrp_3-v.out
new file mode 100644
index 0000000..54a78f4
--- /dev/null
+++ b/tests/hsrp_3-v.out
@@ -0,0 +1,78 @@
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.10.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=200 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=3 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=speak group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=standby group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 44)
+    192.168.0.20.1985 > 224.0.0.2.1985: HSRPv0-unknown (3) 16: state=initial group=2 [|hsrp]
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [none], proto UDP (17), length 48)
+    192.168.0.30.1985 > 224.0.0.2.1985: HSRPv0-hello 20: state=active group=1 addr=192.168.0.1 hellotime=3s holdtime=10s priority=100 auth="cisco^@^@^@"
diff --git a/tests/icmpv6_opt24-v.out b/tests/icmpv6_opt24-v.out
new file mode 100644
index 0000000..2b7cf09
--- /dev/null
+++ b/tests/icmpv6_opt24-v.out
@@ -0,0 +1,16 @@
+IP6 (hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::16cf:92ff:fe87:23d6 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120
+	hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0s, retrans time 0s
+	  source link-address option (1), length 8 (1): 14:cf:92:87:23:d6
+	  mtu option (5), length 8 (1):  1500
+	  prefix info option (3), length 32 (4): fd8d:4fb3:5b2e::/64, Flags [onlink, auto], valid time 7200s, pref. time 1800s
+	  route info option (24), length 16 (2):  fd8d:4fb3:5b2e::/48, pref=medium, lifetime=7200s
+	  rdnss option (25), length 24 (3):  lifetime 1800s, addr: fd8d:4fb3:5b2e::1
+	  dnssl option (31), length 16 (2):  lifetime 1800s, domain(s): lan.
+IP6 (hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::16cf:92ff:fe87:23d6 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120
+	hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0s, retrans time 0s
+	  source link-address option (1), length 8 (1): 14:cf:92:87:23:d6
+	  mtu option (5), length 8 (1):  1500
+	  prefix info option (3), length 32 (4): fd8d:4fb3:5b2e::/64, Flags [onlink, auto], valid time 7200s, pref. time 1800s
+	  route info option (24), length 16 (2):  fd8d:4fb3:5b2e::/48, pref=medium, lifetime=7200s
+	  rdnss option (25), length 24 (3):  lifetime 1800s, addr: fd8d:4fb3:5b2e::1
+	  dnssl option (31), length 16 (2):  lifetime 1800s, domain(s): lan.
diff --git a/tests/icmpv6_opt24.pcap b/tests/icmpv6_opt24.pcap
new file mode 100644
index 0000000..974e7a3
--- /dev/null
+++ b/tests/icmpv6_opt24.pcap
Binary files differ
diff --git a/tests/igmpv1.out b/tests/igmpv1.out
new file mode 100644
index 0000000..ad8618f
--- /dev/null
+++ b/tests/igmpv1.out
@@ -0,0 +1,27 @@
+IP 10.0.200.151 > 224.0.0.1: igmp query v1
+IP 10.0.200.163 > 224.0.0.252: igmp v1 report 224.0.0.252
+IP 192.168.1.3 > 239.255.255.250: igmp v1 report 239.255.255.250
+IP 10.0.200.108 > 224.0.1.24: igmp v1 report 224.0.1.24
+IP 10.0.200.100 > 224.0.1.60: igmp v1 report 224.0.1.60
+IP 10.0.200.144 > 224.0.0.9: igmp v1 report 224.0.0.9
+IP 10.0.200.108 > 239.255.255.254: igmp v1 report 239.255.255.254
+IP 10.0.200.10 > 224.0.0.251: igmp v1 report 224.0.0.251
+IP 10.0.200.151 > 224.0.0.1: igmp query v1
+IP 10.0.200.108 > 239.255.255.250: igmp v1 report 239.255.255.250
+IP 10.0.200.108 > 239.255.255.254: igmp v1 report 239.255.255.254
+IP 10.0.200.10 > 224.0.0.251: igmp v1 report 224.0.0.251
+IP 10.0.200.163 > 224.0.0.252: igmp v1 report 224.0.0.252
+IP 10.0.200.108 > 224.0.1.24: igmp v1 report 224.0.1.24
+IP 10.0.200.144 > 224.0.0.9: igmp v1 report 224.0.0.9
+IP 10.0.200.100 > 224.0.1.60: igmp v1 report 224.0.1.60
+IP 10.0.200.25 > 239.255.255.250: igmp v1 report 239.255.255.250
+IP 10.0.200.25 > 239.255.255.250: igmp v1 report 239.255.255.250
+IP 10.0.200.25 > 239.255.255.250: igmp v1 report 239.255.255.250
+IP 10.0.200.151 > 224.0.0.1: igmp query v1
+IP 10.0.200.163 > 239.255.255.250: igmp v1 report 239.255.255.250
+IP 10.0.200.144 > 224.0.0.9: igmp v1 report 224.0.0.9
+IP 10.0.200.163 > 224.0.0.252: igmp v1 report 224.0.0.252
+IP 10.0.200.100 > 224.0.1.60: igmp v1 report 224.0.1.60
+IP 10.0.200.108 > 224.0.1.24: igmp v1 report 224.0.1.24
+IP 10.0.200.108 > 239.255.255.254: igmp v1 report 239.255.255.254
+IP 10.0.200.10 > 224.0.0.251: igmp v1 report 224.0.0.251
diff --git a/tests/igmpv2.out b/tests/igmpv2.out
new file mode 100644
index 0000000..ae340da
--- /dev/null
+++ b/tests/igmpv2.out
@@ -0,0 +1,18 @@
+IP 192.168.1.2 > 224.0.0.1: igmp query v2
+IP 192.168.1.64 > 239.255.255.250: igmp v2 report 239.255.255.250
+IP 192.168.11.201 > 225.10.10.10: igmp v2 report 225.10.10.10
+IP 192.168.11.201 > 225.1.1.3: igmp v2 report 225.1.1.3
+IP 192.168.11.201 > 224.0.0.2: igmp leave 225.1.1.3
+IP 192.168.1.2 > 225.1.1.3: igmp query v2 [max resp time 10] [gaddr 225.1.1.3]
+IP 192.168.11.201 > 225.1.1.4: igmp v2 report 225.1.1.4
+IP 192.168.11.201 > 225.1.1.4: igmp v2 report 225.1.1.4
+IP 192.168.11.201 > 225.1.1.4: igmp v2 report 225.1.1.4
+IP 192.168.11.201 > 224.0.0.2: igmp leave 225.1.1.4
+IP 192.168.1.2 > 225.1.1.4: igmp query v2 [max resp time 10] [gaddr 225.1.1.4]
+IP 192.168.11.201 > 225.1.1.5: igmp v2 report 225.1.1.5
+IP 192.168.11.201 > 225.1.1.5: igmp v2 report 225.1.1.5
+IP 192.168.11.201 > 225.1.1.5: igmp v2 report 225.1.1.5
+IP 192.168.1.2 > 224.0.0.1: igmp query v2
+IP 192.168.11.201 > 225.10.10.10: igmp v2 report 225.10.10.10
+IP 192.168.1.64 > 239.255.255.250: igmp v2 report 239.255.255.250
+IP 192.168.11.201 > 225.1.1.5: igmp v2 report 225.1.1.5
diff --git a/tests/ipv6-bad-version.out b/tests/ipv6-bad-version.out
new file mode 100644
index 0000000..cd9150b
--- /dev/null
+++ b/tests/ipv6-bad-version.out
@@ -0,0 +1,4 @@
+IP6 :: > ff02::1:ff76:6c14: ICMP6, neighbor solicitation, who has fe80::20c:29ff:fe76:6c14, length 24
+IP6 version error: 0 != 6
+IP6 :: > ff02::1:ff76:6c14: ICMP6, neighbor solicitation, who has 1111:2222:3333:4444:20c:29ff:fe76:6c14, length 24
+IP6 version error: 0 != 6
diff --git a/tests/ipv6-bad-version.pcap b/tests/ipv6-bad-version.pcap
new file mode 100644
index 0000000..357a6ee
--- /dev/null
+++ b/tests/ipv6-bad-version.pcap
Binary files differ
diff --git a/tests/ipv6-routing-header.out b/tests/ipv6-routing-header.out
new file mode 100644
index 0000000..c19b879
--- /dev/null
+++ b/tests/ipv6-routing-header.out
@@ -0,0 +1,4 @@
+IP6 (hlim 4, next-header Routing (43) payload length: 32) 2200::244:212:3fff:feae:22f7 > 2200::240:2:0:0:4: srcrt (len=2, type=0, segleft=1, rsv=0x0, [0]2200::210:2:0:0:4) [icmp6 sum ok] ICMP6, echo request, seq 0
+IP6 (hlim 5, next-header Routing (43) payload length: 48) 2200::244:212:3fff:feae:22f7 > 2200::211:2:0:0:2: srcrt (len=4, type=0, segleft=2, rsv=0x0, [0]2200::210:2:0:0:4, [1]2200::240:2:0:0:4) [icmp6 sum ok] ICMP6, echo request, seq 0
+IP6 (hlim 4, next-header Routing (43) payload length: 32) 2200::244:212:3fff:feae:22f7 > 2200::240:2:0:0:4: srcrt (len=2, type=0, segleft=1, rsv=0x0, [0]2200::210:2:0:0:4) 5645 > 5642: [udp sum ok] UDP, length 0
+IP6 (hlim 5, next-header Routing (43) payload length: 48) 2200::244:212:3fff:feae:22f7 > 2200::211:2:0:0:2: srcrt (len=4, type=0, segleft=2, rsv=0x0, [0]2200::210:2:0:0:4, [1]2200::240:2:0:0:4) 5645 > 5642: [udp sum ok] UDP, length 0
diff --git a/tests/ipv6-routing-header.pcap b/tests/ipv6-routing-header.pcap
new file mode 100644
index 0000000..683e01b
--- /dev/null
+++ b/tests/ipv6-routing-header.pcap
Binary files differ
diff --git a/tests/isakmp5-v.out b/tests/isakmp5-v.out
new file mode 100644
index 0000000..58014af
--- /dev/null
+++ b/tests/isakmp5-v.out
@@ -0,0 +1,44 @@
+IP (tos 0xc0, ttl 255, id 101, offset 0, flags [none], proto UDP (17), length 176)
+    10.0.0.1.500 > 10.0.0.2.500: isakmp 1.0 msgid 00000000: phase 1 I ident:
+    (sa: doi=ipsec situation=identity
+        (p: #1 protoid=isakmp transform=1
+            (t: #1 id=ike (type=enc value=aes)(type=keylen value=0080)(type=hash value=sha1)(type=group desc value=modp768)(type=auth value=preshared)(type=lifetype value=sec)(type=lifeduration len=4 value=00015180))))
+    (vid: len=16)
+    (vid: len=16)
+    (vid: len=16)
+IP (tos 0xc0, ttl 255, id 49, offset 0, flags [none], proto UDP (17), length 136)
+    10.0.0.2.500 > 10.0.0.1.500: isakmp 1.0 msgid 00000000: phase 1 R ident:
+    (sa: doi=ipsec situation=identity
+        (p: #1 protoid=isakmp transform=1
+            (t: #1 id=ike (type=enc value=aes)(type=keylen value=0080)(type=hash value=sha1)(type=group desc value=modp768)(type=auth value=preshared)(type=lifetype value=sec)(type=lifeduration len=4 value=00015180))))
+    (vid: len=16)
+IP (tos 0xc0, ttl 255, id 102, offset 0, flags [none], proto UDP (17), length 300)
+    10.0.0.1.500 > 10.0.0.2.500: isakmp 1.0 msgid 00000000: phase 1 I ident:
+    (ke: key len=96)
+    (nonce: n len=20)
+    (vid: len=16)
+    (vid: len=16)
+    (vid: len=16)
+    (vid: len=8)
+    (pay15)
+    (pay15)
+IP (tos 0xc0, ttl 255, id 50, offset 0, flags [none], proto UDP (17), length 300)
+    10.0.0.2.500 > 10.0.0.1.500: isakmp 1.0 msgid 00000000: phase 1 R ident:
+    (ke: key len=96)
+    (nonce: n len=20)
+    (vid: len=16)
+    (vid: len=16)
+    (vid: len=16)
+    (vid: len=8)
+    (pay15)
+    (pay15)
+IP (tos 0xc0, ttl 255, id 103, offset 0, flags [none], proto UDP (17), length 136)
+    10.0.0.1.500 > 10.0.0.2.500: isakmp 1.0 msgid 00000000: phase 1 I ident[E]: [encrypted id]
+IP (tos 0xc0, ttl 255, id 51, offset 0, flags [none], proto UDP (17), length 104)
+    10.0.0.2.500 > 10.0.0.1.500: isakmp 1.0 msgid 00000000: phase 1 R ident[E]: [encrypted id]
+IP (tos 0xc0, ttl 255, id 104, offset 0, flags [none], proto UDP (17), length 248)
+    10.0.0.1.500 > 10.0.0.2.500: isakmp 1.0 msgid 0f2b7862: phase 2/others I oakley-quick[E]: [encrypted hash]
+IP (tos 0xc0, ttl 255, id 52, offset 0, flags [none], proto UDP (17), length 248)
+    10.0.0.2.500 > 10.0.0.1.500: isakmp 1.0 msgid 0f2b7862: phase 2/others R oakley-quick[E]: [encrypted hash]
+IP (tos 0xc0, ttl 255, id 105, offset 0, flags [none], proto UDP (17), length 88)
+    10.0.0.1.500 > 10.0.0.2.500: isakmp 1.0 msgid 0f2b7862: phase 2/others I oakley-quick[E]: [encrypted hash]
diff --git a/tests/isis_1-v.out b/tests/isis_1-v.out
new file mode 100644
index 0000000..bbe6e26
--- /dev/null
+++ b/tests/isis_1-v.out
@@ -0,0 +1,270 @@
+IS-IS, length 83
+	L1 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    3333.3333.3333.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x0000000e, lifetime:  1184s, chksum: 0x5910
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000010, lifetime:  1147s, chksum: 0x1749
+	      lsp-id: 3333.3333.3333.02-00, seq: 0x00000004, lifetime:   634s, chksum: 0x7f9f
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0001
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L1 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    3333.3333.3333.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x0000000e, lifetime:  1174s, chksum: 0x5910
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000010, lifetime:  1137s, chksum: 0x1749
+	      lsp-id: 3333.3333.3333.02-00, seq: 0x00000004, lifetime:   624s, chksum: 0x7f9f
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 136
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 2222.2222.2222.00-00, seq: 0x0000000f, lifetime:  1199s
+	  chksum: 0xb503 (correct), PDU length: 136, Flags: [ L1 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R2
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 192.168.10.1
+	    IPv4 Internal Reachability TLV #128, length: 24
+	      IPv4 prefix:       10.0.10.0/30, Distribution: up, Metric: 10, Internal
+	      IPv4 prefix:    192.168.10.0/24, Distribution: up, Metric: 10, Internal
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 3333.3333.3333.02, Default Metric: 10, Internal
+	    IPv4 External Reachability TLV #130, length: 48
+	      IPv4 prefix:      172.16.0.0/30, Distribution: up, Metric: 0, External
+	      IPv4 prefix:      172.16.1.0/24, Distribution: up, Metric: 0, External
+	      IPv4 prefix:      172.16.2.0/24, Distribution: up, Metric: 0, External
+	      IPv4 prefix:      172.16.3.0/24, Distribution: up, Metric: 0, External
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0001
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L1 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    3333.3333.3333.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x0000000f, lifetime:  1194s, chksum: 0xb503
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000010, lifetime:  1130s, chksum: 0x1749
+	      lsp-id: 3333.3333.3333.02-00, seq: 0x00000004, lifetime:   616s, chksum: 0x7f9f
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0001
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
diff --git a/tests/isis_1.out b/tests/isis_1.out
new file mode 100644
index 0000000..32edae9
--- /dev/null
+++ b/tests/isis_1.out
@@ -0,0 +1,15 @@
+IS-IS, L1 CSNP, src-id 3333.3333.3333.00, length 83
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 Lan IIH, src-id 2222.2222.2222, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 CSNP, src-id 3333.3333.3333.00, length 83
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 LSP, lsp-id 2222.2222.2222.00-00, seq 0x0000000f, lifetime  1199s, length 136
+IS-IS, L1 Lan IIH, src-id 2222.2222.2222, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 CSNP, src-id 3333.3333.3333.00, length 83
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 Lan IIH, src-id 3333.3333.3333, lan-id 3333.3333.3333.02, prio 64, length 1497
+IS-IS, L1 Lan IIH, src-id 2222.2222.2222, lan-id 3333.3333.3333.02, prio 64, length 1497
diff --git a/tests/isis_2-v.out b/tests/isis_2-v.out
new file mode 100644
index 0000000..8c05206
--- /dev/null
+++ b/tests/isis_2-v.out
@@ -0,0 +1,403 @@
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    2222.2222.2222.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    2222.2222.2222.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    2222.2222.2222.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    2222.2222.2222.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    2222.2222.2222.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0001
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0001
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 86
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 2222.2222.2222.00-00, seq: 0x00000009, lifetime:  1199s
+	  chksum: 0x630b (correct), PDU length: 86, Flags: [ L1 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R2
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 192.168.10.1
+	    IPv4 Internal Reachability TLV #128, length: 24
+	      IPv4 prefix:       10.0.10.0/30, Distribution: up, Metric: 10, Internal
+	      IPv4 prefix:    192.168.10.0/24, Distribution: up, Metric: 10, Internal
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 3333.3333.3333.02, Default Metric: 10, Internal
+IS-IS, length 74
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 3333.3333.3333.00-00, seq: 0x0000000e, lifetime:  1199s
+	  chksum: 0x1b47 (correct), PDU length: 74, Flags: [ default ATT bit set, L2 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R3
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    IPv4 Internal Reachability TLV #128, length: 12
+	      IPv4 prefix:       10.0.10.0/30, Distribution: up, Metric: 10, Internal
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 3333.3333.3333.02, Default Metric: 10, Internal
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L1 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    3333.3333.3333.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000009, lifetime:  1192s, chksum: 0x630b
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x0000000e, lifetime:  1194s, chksum: 0x1b47
+	      lsp-id: 3333.3333.3333.02-00, seq: 0x00000004, lifetime:  1039s, chksum: 0x7f9f
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0001
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L1 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    3333.3333.3333.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000009, lifetime:  1184s, chksum: 0x630b
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x0000000e, lifetime:  1186s, chksum: 0x1b47
+	      lsp-id: 3333.3333.3333.02-00, seq: 0x00000004, lifetime:  1032s, chksum: 0x7f9f
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222,  holding time: 30s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0001
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L1 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 10s, Flags: [Level 1 only]
+	  lan-id:    3333.3333.3333.02, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c201.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
diff --git a/tests/isis_3-v.out b/tests/isis_3-v.out
new file mode 100644
index 0000000..4894864
--- /dev/null
+++ b/tests/isis_3-v.out
@@ -0,0 +1,774 @@
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    3333.3333.3333.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 163
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    3333.3333.3333.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 100
+	L2 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 4444.4444.4444.00-00, seq: 0x0000000a, lifetime:  1199s
+	  chksum: 0xf252 (correct), PDU length: 100, Flags: [ L2 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R4
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.20.1
+	    IPv4 Internal Reachability TLV #128, length: 12
+	      IPv4 prefix:        10.0.0.0/30, Distribution: up, Metric: 10, Internal
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 4444.4444.4444.01, Default Metric: 10, Internal
+	    IPv4 Internal Reachability TLV #128, length: 24
+	      IPv4 prefix:       10.0.20.0/30, Distribution: up, Metric: 10, Internal
+	      IPv4 prefix:    192.168.20.0/24, Distribution: up, Metric: 20, Internal
+IS-IS, length 52
+	L2 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 4444.4444.4444.01-00, seq: 0x00000003, lifetime:  1199s
+	  chksum: 0x7ef7 (correct), PDU length: 52, Flags: [ L2 IS ]
+	    IS Reachability TLV #2, length: 23
+	      IsNotVirtual
+	      IS Neighbor: 4444.4444.4444.00, Default Metric: 0, Internal
+	      IS Neighbor: 3333.3333.3333.00, Default Metric: 0, Internal
+IS-IS, length 100
+	L2 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 3333.3333.3333.00-00, seq: 0x00000009, lifetime:  1199s
+	  chksum: 0x24b1 (correct), PDU length: 100, Flags: [ L2 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R3
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.10.1
+	    IPv4 Internal Reachability TLV #128, length: 12
+	      IPv4 prefix:        10.0.0.0/30, Distribution: up, Metric: 10, Internal
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 4444.4444.4444.01, Default Metric: 10, Internal
+	    IPv4 Internal Reachability TLV #128, length: 24
+	      IPv4 prefix:       10.0.10.0/30, Distribution: up, Metric: 10, Internal
+	      IPv4 prefix:    192.168.10.0/24, Distribution: up, Metric: 20, Internal
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    4444.4444.4444.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000009, lifetime:  1192s, chksum: 0x24b1
+	      lsp-id: 4444.4444.4444.00-00, seq: 0x0000000a, lifetime:  1194s, chksum: 0xf252
+	      lsp-id: 4444.4444.4444.01-00, seq: 0x00000003, lifetime:  1194s, chksum: 0x7ef7
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    4444.4444.4444.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000009, lifetime:  1183s, chksum: 0x24b1
+	      lsp-id: 4444.4444.4444.00-00, seq: 0x0000000a, lifetime:  1185s, chksum: 0xf252
+	      lsp-id: 4444.4444.4444.01-00, seq: 0x00000003, lifetime:  1185s, chksum: 0x7ef7
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    4444.4444.4444.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000009, lifetime:  1174s, chksum: 0x24b1
+	      lsp-id: 4444.4444.4444.00-00, seq: 0x0000000a, lifetime:  1176s, chksum: 0xf252
+	      lsp-id: 4444.4444.4444.01-00, seq: 0x00000003, lifetime:  1176s, chksum: 0x7ef7
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    4444.4444.4444.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000009, lifetime:  1166s, chksum: 0x24b1
+	      lsp-id: 4444.4444.4444.00-00, seq: 0x0000000a, lifetime:  1168s, chksum: 0xf252
+	      lsp-id: 4444.4444.4444.01-00, seq: 0x00000003, lifetime:  1168s, chksum: 0x7ef7
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    4444.4444.4444.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000009, lifetime:  1157s, chksum: 0x24b1
+	      lsp-id: 4444.4444.4444.00-00, seq: 0x0000000a, lifetime:  1159s, chksum: 0xf252
+	      lsp-id: 4444.4444.4444.01-00, seq: 0x00000003, lifetime:  1159s, chksum: 0x7ef7
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 83
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    4444.4444.4444.00, PDU length: 83
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 48
+	      lsp-id: 3333.3333.3333.00-00, seq: 0x00000009, lifetime:  1147s, chksum: 0x24b1
+	      lsp-id: 4444.4444.4444.00-00, seq: 0x0000000a, lifetime:  1149s, chksum: 0xf252
+	      lsp-id: 4444.4444.4444.01-00, seq: 0x00000003, lifetime:  1149s, chksum: 0x7ef7
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 3333.3333.3333,  holding time: 30s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.000a
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c203.29a9.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
+IS-IS, length 1497
+	L2 Lan IIH, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 4444.4444.4444,  holding time: 10s, Flags: [Level 2 only]
+	  lan-id:    4444.4444.4444.01, Priority: 64, PDU length: 1497
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0014
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    IS Neighbor(s) TLV #6, length: 6
+	      SNPA: c202.2998.0000
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 155
diff --git a/tests/isis_4-v.out b/tests/isis_4-v.out
new file mode 100644
index 0000000..b4875f3
--- /dev/null
+++ b/tests/isis_4-v.out
@@ -0,0 +1,400 @@
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 1111.1111.1111, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Down (2)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 1111.1111.1111, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Down (2)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Down (2)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Down (2)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 1111.1111.1111, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Initializing (1)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Initializing (1)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 1111.1111.1111, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 74
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1200s
+	  chksum: 0x1da8 (correct), PDU length: 74, Flags: [ L2 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R1
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    IPv4 Internal Reachability TLV #128, length: 12
+	      IPv4 prefix:        10.0.0.0/30, Distribution: up, Metric: 10, Internal
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 2222.2222.2222.00, Default Metric: 10, Internal
+IS-IS, length 74
+	L2 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1200s
+	  chksum: 0x378e (correct), PDU length: 74, Flags: [ L2 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R1
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 2222.2222.2222.00, Default Metric: 10, Internal
+	    IPv4 Internal Reachability TLV #128, length: 12
+	      IPv4 prefix:        10.0.0.0/30, Distribution: up, Metric: 10, Internal
+IS-IS, length 74
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 2222.2222.2222.00-00, seq: 0x00000005, lifetime:  1200s
+	  chksum: 0x4382 (correct), PDU length: 74, Flags: [ L2 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R2
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    IPv4 Internal Reachability TLV #128, length: 12
+	      IPv4 prefix:        10.0.0.0/30, Distribution: up, Metric: 10, Internal
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 1111.1111.1111.00, Default Metric: 10, Internal
+IS-IS, length 74
+	L2 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  lsp-id: 2222.2222.2222.00-00, seq: 0x00000006, lifetime:  1200s
+	  chksum: 0xf4cf (correct), PDU length: 74, Flags: [ L2 IS ]
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Hostname TLV #137, length: 2
+	      Hostname: R2
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    IS Reachability TLV #2, length: 12
+	      IsNotVirtual
+	      IS Neighbor: 1111.1111.1111.00, Default Metric: 10, Internal
+	    IPv4 Internal Reachability TLV #128, length: 12
+	      IPv4 prefix:        10.0.0.0/30, Distribution: up, Metric: 10, Internal
+IS-IS, length 67
+	L1 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    2222.2222.2222.00, PDU length: 67
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 32
+	      lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1198s, chksum: 0x1da8
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000005, lifetime:  1199s, chksum: 0x4382
+IS-IS, length 67
+	L1 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    1111.1111.1111.00, PDU length: 67
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 32
+	      lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1199s, chksum: 0x1da8
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000005, lifetime:  1198s, chksum: 0x4382
+IS-IS, length 67
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    1111.1111.1111.00, PDU length: 67
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 32
+	      lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1199s, chksum: 0x378e
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000006, lifetime:  1198s, chksum: 0xf4cf
+IS-IS, length 67
+	L2 CSNP, hlen: 33, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    2222.2222.2222.00, PDU length: 67
+	  start lsp-id: 0000.0000.0000.00-00
+	  end lsp-id:   ffff.ffff.ffff.ff-ff
+	    LSP entries TLV #9, length: 32
+	      lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1198s, chksum: 0x378e
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000006, lifetime:  1199s, chksum: 0xf4cf
+IS-IS, length 35
+	L1 PSNP, hlen: 17, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    1111.1111.1111.00, PDU length: 35
+	    LSP entries TLV #9, length: 16
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000005, lifetime:  1197s, chksum: 0x4382
+IS-IS, length 35
+	L2 PSNP, hlen: 17, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    1111.1111.1111.00, PDU length: 35
+	    LSP entries TLV #9, length: 16
+	      lsp-id: 2222.2222.2222.00-00, seq: 0x00000006, lifetime:  1198s, chksum: 0xf4cf
+IS-IS, length 35
+	L1 PSNP, hlen: 17, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    2222.2222.2222.00, PDU length: 35
+	    LSP entries TLV #9, length: 16
+	      lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1197s, chksum: 0x1da8
+IS-IS, length 35
+	L2 PSNP, hlen: 17, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id:    2222.2222.2222.00, PDU length: 35
+	    LSP entries TLV #9, length: 16
+	      lsp-id: 1111.1111.1111.00-00, seq: 0x00000007, lifetime:  1198s, chksum: 0x378e
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 1111.1111.1111, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 1111.1111.1111, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 2222.2222.2222, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.2
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
+IS-IS, length 1499
+	p2p IIH, hlen: 20, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 3 (0)
+	  source-id: 1111.1111.1111, holding time: 30s, Flags: [Level 1, Level 2]
+	  circuit-id: 0x00, PDU length: 1499
+	    Restart Signaling TLV #211, length: 3
+	      Flags [none], Remaining holding time 0s
+	    Point-to-point Adjacency State TLV #240, length: 1
+	      Adjacency State: Up (0)
+	    Protocols supported TLV #129, length: 1
+	      NLPID(s): IPv4 (0xcc)
+	    Area address(es) TLV #1, length: 4
+	      Area address (length: 3): 49.0001
+	    IPv4 Interface address(es) TLV #132, length: 4
+	      IPv4 interface address: 10.0.0.1
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 255
+	    Padding TLV #8, length: 169
diff --git a/tests/isis_infloop-v.out b/tests/isis_infloop-v.out
new file mode 100644
index 0000000..1bb8301
--- /dev/null
+++ b/tests/isis_infloop-v.out
@@ -0,0 +1,40 @@
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto GRE (47), length 54)
+    253.120.2.55 > 192.168.1.1: GREv0, Flags [none], length 34
+	IS-IS, length 30
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (6), max-area: 7 (7)
+	  lsp-id: ffff.ffff.ffff.ff-ff, seq: 0xffffffff, lifetime: 65535s
+	  chksum: 0xffff (incorrect should be 0x0fe8), PDU length: 65535, Flags: [ L1 IS ]
+	    IS Neighbor(s) (variable length) TLV #7, length: 0
+	      1 straggler bytes
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto GRE (47), length 54)
+    234.176.145.73 > 192.168.1.1: GREv0, Flags [none], length 34
+	IS-IS, length 30
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (6), max-area: 7 (7)
+	  lsp-id: ffff.ffff.ffff.ff-ff, seq: 0xffffffff, lifetime: 65535s
+	  chksum: 0xffff (incorrect should be 0x0fe8), PDU length: 65535, Flags: [ L1 IS ]
+	    IS Neighbor(s) (variable length) TLV #7, length: 0
+	      1 straggler bytes
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto GRE (47), length 54)
+    225.91.211.91 > 192.168.1.1: GREv0, Flags [none], length 34
+	IS-IS, length 30
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (6), max-area: 7 (7)
+	  lsp-id: ffff.ffff.ffff.ff-ff, seq: 0xffffffff, lifetime: 65535s
+	  chksum: 0xffff (incorrect should be 0x0fe8), PDU length: 65535, Flags: [ L1 IS ]
+	    IS Neighbor(s) (variable length) TLV #7, length: 0
+	      1 straggler bytes
+IP (tos 0x0, ttl 128, id 0, offset 0, flags [DF], proto GRE (47), length 54)
+    160.196.17.46 > 192.168.1.1: GREv0, Flags [none], length 34
+	IS-IS, length 30
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (6), max-area: 7 (7)
+	  lsp-id: ffff.ffff.ffff.ff-ff, seq: 0xffffffff, lifetime: 65535s
+	  chksum: 0xffff (incorrect should be 0x0fe8), PDU length: 65535, Flags: [ L1 IS ]
+	    IS Neighbor(s) (variable length) TLV #7, length: 0
+	      1 straggler bytes
+IP (tos 0x0, ttl 128, id 0, offset 0, flags [DF], proto GRE (47), length 54)
+    246.181.173.63 > 192.168.1.1: GREv0, Flags [none], length 34
+	IS-IS, length 30
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (6), max-area: 7 (7)
+	  lsp-id: ffff.ffff.ffff.ff-ff, seq: 0xffffffff, lifetime: 65535s
+	  chksum: 0xffff (incorrect should be 0x0fe8), PDU length: 65535, Flags: [ L1 IS ]
+	    IS Neighbor(s) (variable length) TLV #7, length: 0
+	      1 straggler bytes
diff --git a/tests/isup.out b/tests/isup.out
new file mode 100644
index 0000000..fb4d9af
--- /dev/null
+++ b/tests/isup.out
@@ -0,0 +1,6 @@
+IP 10.28.6.42.2905 > 10.28.6.44.2905: sctp (1) [DATA] (B)(E) [TSN: 1822994892] [SID: 6] [SSEQ 42] [PPID M3UA] 
+IP 10.28.6.44.2905 > 10.28.6.42.2905: sctp (1) [DATA] (B)(E) [TSN: 4307] [SID: 0] [SSEQ 643] [PPID M3UA] 
+IP 10.28.6.44.2905 > 10.28.6.42.2905: sctp (1) [DATA] (B)(E) [TSN: 4308] [SID: 0] [SSEQ 644] [PPID M3UA] 
+IP 10.28.6.44.2905 > 10.28.6.42.2905: sctp (1) [DATA] (B)(E) [TSN: 4309] [SID: 0] [SSEQ 645] [PPID M3UA] 
+IP 10.28.6.42.2905 > 10.28.6.44.2905: sctp (1) [DATA] (B)(E) [TSN: 1822994893] [SID: 6] [SSEQ 43] [PPID M3UA] 
+IP 10.28.6.44.2905 > 10.28.6.42.2905: sctp (1) [DATA] (B)(E) [TSN: 4310] [SID: 0] [SSEQ 646] [PPID M3UA] 
diff --git a/tests/isup.pcap b/tests/isup.pcap
new file mode 100644
index 0000000..39f16b9
--- /dev/null
+++ b/tests/isup.pcap
Binary files differ
diff --git a/tests/isupvv.out b/tests/isupvv.out
new file mode 100644
index 0000000..8e8a008
--- /dev/null
+++ b/tests/isupvv.out
@@ -0,0 +1,30 @@
+IP (tos 0x0, ttl 64, id 38618, offset 0, flags [none], proto SCTP (132), length 132)
+    10.28.6.42.2905 > 10.28.6.44.2905: sctp
+	1) [DATA] (B)(E) [TSN: 1822994892] [SID: 6] [SSEQ 42] [PPID M3UA] 
+		Transfer Data Message
+			Unknown Parameter (0x0002): (length 73)
+IP (tos 0x0, ttl 255, id 50089, offset 0, flags [DF], proto SCTP (132), length 76)
+    10.28.6.44.2905 > 10.28.6.42.2905: sctp
+	1) [DATA] (B)(E) [TSN: 4307] [SID: 0] [SSEQ 643] [PPID M3UA] 
+		Transfer Data Message
+			Unknown Parameter (0x0002): (length 18)
+IP (tos 0x0, ttl 255, id 50090, offset 0, flags [DF], proto SCTP (132), length 72)
+    10.28.6.44.2905 > 10.28.6.42.2905: sctp
+	1) [DATA] (B)(E) [TSN: 4308] [SID: 0] [SSEQ 644] [PPID M3UA] 
+		Transfer Data Message
+			Unknown Parameter (0x0002): (length 15)
+IP (tos 0x0, ttl 255, id 50091, offset 0, flags [DF], proto SCTP (132), length 72)
+    10.28.6.44.2905 > 10.28.6.42.2905: sctp
+	1) [DATA] (B)(E) [TSN: 4309] [SID: 0] [SSEQ 645] [PPID M3UA] 
+		Transfer Data Message
+			Unknown Parameter (0x0002): (length 13)
+IP (tos 0x0, ttl 64, id 38651, offset 0, flags [none], proto SCTP (132), length 76)
+    10.28.6.42.2905 > 10.28.6.44.2905: sctp
+	1) [DATA] (B)(E) [TSN: 1822994893] [SID: 6] [SSEQ 43] [PPID M3UA] 
+		Transfer Data Message
+			Unknown Parameter (0x0002): (length 17)
+IP (tos 0x0, ttl 255, id 50109, offset 0, flags [DF], proto SCTP (132), length 72)
+    10.28.6.44.2905 > 10.28.6.42.2905: sctp
+	1) [DATA] (B)(E) [TSN: 4310] [SID: 0] [SSEQ 646] [PPID M3UA] 
+		Transfer Data Message
+			Unknown Parameter (0x0002): (length 13)
diff --git a/tests/kday1.out b/tests/kday1.out
new file mode 100644
index 0000000..eaaacaa
--- /dev/null
+++ b/tests/kday1.out
@@ -0,0 +1,15 @@
+IP6, wrong link-layer encapsulation (tos 0x10, ttl 192, id 63177, offset 0, flags [DF], proto SCTP (132), length 168, options (security [bad length 110]), bad cksum a291 (->9204)!)
+    c084:a291:b8aa:42aa:3e38:9ac7:826e:b930.33943 > 8497:1a30:7cd4:d4d4:d4d4:d428:13:68.6704: sctp[ForCES HP] (1) [DATA] (B)(E) [TSN: 1934917887] [SID: 256] [SSEQ 15360] [PPID 0x3c00] 
+	ForCES Config 
+	ForCES Version 14 len 88B flags 0x0a040604 
+	SrcID 0xff000200(AllMulticast) DstID 0xb59cbe(FE) Correlator 0x30480805f4010800
+		Messy oper TLV header, type (0x600)
+		excess of -240 Bytes 
+	[0x0000:  e803 0016 ff00 0200 00b5 9cbe 3048 0805
+	[0x0010:  f401 0800 0a04 0604 0010 003c 0000 3ce8
+	[0x0020:  0300 3c00 000e 0016 0604 0010 003c 0000
+	[0x0030:  0000 ff00 ffff a69c be30 4808 0600 0108
+	[0x0040:  0006 0400 0184 b59c be30 84b5 0010 0000
+	[0x0050:  cc05 367e 0003 0000
+	][|sctp]
+EXIT CODE 00000100
diff --git a/tests/kday1.pcap b/tests/kday1.pcap
new file mode 100644
index 0000000..ca2d960
--- /dev/null
+++ b/tests/kday1.pcap
Binary files differ
diff --git a/tests/kday2.out b/tests/kday2.out
new file mode 100644
index 0000000..770fc3b
--- /dev/null
+++ b/tests/kday2.out
@@ -0,0 +1,34 @@
+CFMv0 unknown (204), MD Level 0, length 168
+	First TLV offset 52
+	  0x0000:  a300 0000 0080 0000 0000 0000 0000 0000
+	  0x0010:  0000 00aa 6873 54d7 060b 003c 0000 003c
+	  0x0020:  d4c3 b2a1 0200 1a00 000b 003c 0000 003c
+	  0x0030:  d4c3 b2a1 0200 1a00 0000 0000 3620 0a00
+	  0x0040:  b600 0000 b600 0000 40b5 9cbe 3048 0cc4
+	  0x0050:  ad37 1005 ffff 05cc 0934 9300 0000 0080
+	  0x0060:  0000 0000 0000 3200 0000 0000 00aa 6873
+	Port status TLV (0x02), length 26, Status: Unknown (0)
+	Unknown TLV (0x37), length 4101
+	  0x0000:  3710 05ff ff05 cc09 3493 0000 0000 8000
+	  0x0010:  0000 0000 0032 0000 0000 0000 aa68 7354
+	  0x0020:  d706 0b00 3c00 0000 3c00 0000 0080 0000
+	  0x0030:  fffd 4d5f d9bd c709 30ac 8176 b36d cc11
+	  0x0040:  3abf 1291 f106 4ede 61f4 6297 afc4 39a4
+	  0x0050:  0db9 7a
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0
+IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x66a1), ack 2339312418, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x8900), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 21
+	  Error code: Unknown (66), Encapsulated PDU length: 37|trunc
+	[|RPKI-RTR]
+EXIT CODE 00000100
diff --git a/tests/kday2.pcap b/tests/kday2.pcap
new file mode 100644
index 0000000..28e921b
--- /dev/null
+++ b/tests/kday2.pcap
Binary files differ
diff --git a/tests/kday3.out b/tests/kday3.out
new file mode 100644
index 0000000..f6fd728
--- /dev/null
+++ b/tests/kday3.out
@@ -0,0 +1,41 @@
+IP (tos 0x10, ttl 64, id 63177, offset 0, flags [DF], proto TCP (6), length 168)
+    204.9.54.80.22 > 204.9.51.132.50079: Flags [P.], cksum 0x0282 (incorrect -> 0x3217), seq 1819218606:1819218722, ack 1238485076, win 1039, options [nop,nop,TS val 1340592078 ecr 941371882], length 116
+IP6, wrong link-layer encapsulation (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52, options (unknown 195 [bad length 159]), bad cksum 3da6 (->45ca)!)
+    27759 > 4782:  tcp 24 [bad hdr length 0 - too short, < 20]
+IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x0cf1), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2381534627 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66|trunc
+	RPKI-RTRv115, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 12
+	    -----encapsulated PDU-----|trunc|trunc
+	[|RPKI-RTR]
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 0, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0
+IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 1, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xa6b3), seq 0:347, ack 1, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 37
+	    -----encapsulated PDU-----|trunc|trunc
+	RPKI-RTRv9, Unknown PDU (51), length: 32
+	  0x0000:  0933 84cc 0000 0020 9f00 1649 d1c8 546c
+	  0x0010:  ff13 1980 100f fc85 8b00 0055 0000 0101
+	[|RPKI-RTR]
+EXIT CODE 00000100
diff --git a/tests/kday3.pcap b/tests/kday3.pcap
new file mode 100644
index 0000000..e22de28
--- /dev/null
+++ b/tests/kday3.pcap
Binary files differ
diff --git a/tests/kday4.out b/tests/kday4.out
new file mode 100644
index 0000000..95b29cc
--- /dev/null
+++ b/tests/kday4.out
@@ -0,0 +1,60 @@
+IP (tos 0x10, ttl 64, id 63177, offset 0, flags [none], proto unknown (240), length 168, bad cksum 418f (->80a5)!)
+    204.9.54.80 > 204.9.51.132:  ip-proto-240 148
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3da6 (->35a6)!)
+    212.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0x4811), ack 1819218606, win 17918, options [nop,nop,TS val 941371903 ecr 1340592074], length 0
+84:b5:9c:be:30:48 Unknown SSAP 0x10 > 0c:c4:7a:08:e9:12 Unknown DSAP 0x44 Information, send seq 0, rcv seq 26, Flags [Command], length 52
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.54.80.55936 > 204.9.55.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x725a), ack 3589495407, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xcd5f), seq 3589495407:3589495754, ack 370436242, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 58f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 37
+	    -----encapsulated PDU-----|trunc|trunc
+	RPKI-RTRv115, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 12
+	    -----encapsulated PDU-----|trunc|trunc
+	[|RPKI-RTR]
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0
+IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xfa70), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv197, Unknown PDU (100), length: 60
+	  0x0000:  c564 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 37
+	    -----encapsulated PDU-----|trunc|trunc
+	RPKI-RTRv115, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 12
+	    -----encapsulated PDU-----|trunc|trunc
+	[|RPKI-RTR]
+IP truncated-ip - 768 bytes missing! (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 820, bad cksum 3da6 (->3aa6)!)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], seq 0:768, ack 1, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 768
+IP (tos 0x6,ECT(0), ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->4524)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 1, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x3f28), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 100
+	  Error text: ^@^@^@M-^?M-^?^_^[pM-xWM-nhMM-}M_M-YM-=M-G^I0M-,M-^AvM-3mM-L^Q:M-?^RM-^QM-q^FNM-^aM-tbM-^WM-/M-D9M-$^MM-9zM-%hs3M-hA^J^@B^@^@^@B^@^@^@%M-Dz^HM-i^RM-^DM-5M-^\M->0H^H^@E^P^@4M-}&@^@>^F
+	RPKI-RTRv115, Error Report PDU (10), length: 66|trunc
+	[|RPKI-RTR]
+EXIT CODE 00000100
diff --git a/tests/kday4.pcap b/tests/kday4.pcap
new file mode 100644
index 0000000..f25e84a
--- /dev/null
+++ b/tests/kday4.pcap
Binary files differ
diff --git a/tests/kday5.out b/tests/kday5.out
new file mode 100644
index 0000000..7aeae72
--- /dev/null
+++ b/tests/kday5.out
@@ -0,0 +1,35 @@
+CFMv0 unknown (204), MD Level 0, length 168
+	First TLV offset 52
+	  0x0000:  a300 0000 0080 0000 0000 0000 0000 0000
+	  0x0010:  0000 00aa 6873 54d7 060b 003c 0000 003c
+	  0x0020:  d4c3 b2a1 0200 1a00 000b 003c 0000 003c
+	  0x0030:  d4c3 b2a1 0200 1a00 0000 0000 3620 0a00
+	  0x0040:  b600 0000 b600 0000 40b5 9cbe 3048 0cc4
+	  0x0050:  ad37 1005 ffff 05cc 0934 9300 0000 0080
+	  0x0060:  0000 0000 0000 3200 0000 0000 00aa 6873
+	Port status TLV (0x02), length 26, Status: Unknown (0)
+	Unknown TLV (0x37), length 4101
+	  0x0000:  3710 05ff ff05 cc09 3493 0000 0000 8000
+	  0x0010:  0000 0000 0032 0000 0000 0000 aa68 7354
+	  0x0020:  d706 0b00 3c00 0000 3c00 0000 0080 0000
+	  0x0030:  fffd 4d5f d9bd c709 30ac 8176 b36d cc11
+	  0x0040:  3abf 1291 f106 4ede 61f4 6297 afc4 39a4
+	  0x0050:  0db9 7a
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0
+IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x98c3), ack 1819279359, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x183a), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2351322531 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 80
+	  Error text: M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-CM-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9M-9^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^V^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J^J
+	[|RPKI-RTR]
+EXIT CODE 00000100
diff --git a/tests/kday5.pcap b/tests/kday5.pcap
new file mode 100644
index 0000000..759bf88
--- /dev/null
+++ b/tests/kday5.pcap
Binary files differ
diff --git a/tests/kday6.out b/tests/kday6.out
new file mode 100644
index 0000000..3eba7e6
--- /dev/null
+++ b/tests/kday6.out
@@ -0,0 +1,460 @@
+FRF.16 Frag, seq 693, Flags [Begin], UI e8! IS-IS, length 301989913
+	L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 131 (131)
+	  lsp-id: 8383.8383.834f.00-60, seq: 0x06418fcc, lifetime: 33667s
+	  chksum: 0x0900(unverified), PDU length: 33667, Flags: [ Overload bit set, expense ATT bit set, L1 IS ]
+	    Multi-Topology Capability TLV #144, length: 137
+	      O: 0, RES: 4, MTID(s): 3945
+	      unknown subTLV #8, length: 233
+	      unknown subTLV #18, length: 0
+	      unknown subTLV #37, length: 144
+	      unknown subTLV #137, length: 79
+	      unknown subTLV #105, length: 8
+	      unknown subTLV #0, length: 69
+	      unknown subTLV #0, length: 0
+	      unknown subTLV #52, length: 144
+	      unknown subTLV #64, length: 64
+	      SPB Instance subTLV #1, length: 64
+	        CIST Root-ID: 06a516cc 09370acc, Path Cost: ffffff7f, Prio: 48090
+	        RES: 1031, V: 1, SPSource-ID: 324444, No of Trees: 5
+	         U:0, M:0, A:0, RES:22, ECT: 144a2d80, BVID: 256, SPVID: 1040
+	         U:0, M:1, A:1, RES:14, ECT: 55000001, BVID: 16, SPVID: 2058
+	         U:1, M:0, A:0, RES:12, ECT: f3ac2b26, BVID: 2499, SPVID: 185
+	         U:1, M:0, A:1, RES:5, ECT: 68735440, BVID: 1216, SPVID: 3072
+	         U:1, M:1, A:1, RES:23, ECT: 020000f7, BVID: 32, SPVID: 0
+	      unknown subTLV #132, length: 181
+	      unknown subTLV #156, length: 190
+	      unknown subTLV #255, length: 255
+	      unknown subTLV #255, length: 255
+	      unknown subTLV #0, length: 64
+	      unknown subTLV #6, length: 62
+	      unknown subTLV #136, length: 204
+	      unknown subTLV #9, length: 16
+	      unknown subTLV #4, length: 16
+	      unknown subTLV #5, length: 148
+	      unknown subTLV #0, length: 0
+	      SPB Instance subTLV #1, length: 1
+	        CIST Root-ID: 080a26a6 318b8cf3, Path Cost: a5d38ec4, Prio: 31240
+	        RES: 1864, V: 1, SPSource-ID: 133120, No of Trees: 45
+	         U:0, M:0, A:0, RES:0, ECT: cc09370a, BVID: 3496, SPVID: 1
+	         U:1, M:0, A:1, RES:27, ECT: 16274ce2, BVID: 3423, SPVID: 860
+	         U:1, M:1, A:0, RES:10, ECT: 80100410, BVID: 89, SPVID: 1093
+	         U:0, M:0, A:0, RES:16, ECT: 04106e55, BVID: 0, SPVID: 1
+	         U:0, M:0, A:0, RES:1, ECT: 080a8cf3, BVID: 2754, SPVID: 2854
+	         U:1, M:0, A:0, RES:28, ECT: 0e2d0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:27, ECT: 01001201, BVID: 2104, SPVID: 899
+	         U:1, M:0, A:0, RES:3, ECT: 83838383, BVID: 2104, SPVID: 899
+	         U:0, M:1, A:0, RES:15, ECT: 00600641, BVID: 2300, SPVID: 3081
+	         U:0, M:0, A:0, RES:0, ECT: 2590894f, BVID: 1680, SPVID: 2281
+	         U:0, M:0, A:0, RES:18, ECT: 0025e489, BVID: 1264, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3711
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0c0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e640e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e80ff, BVID: 3760, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e000003, BVID: 3720, SPVID: 14
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 560e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3675
+	         U:1, M:0, A:0, RES:0, ECT: acaa4016, BVID: 380, SPVID: 494
+	         U:1, M:1, A:0, RES:14, ECT: 1560b70f, BVID: 2993, SPVID: 1575
+	         U:0, M:1, A:0, RES:12, ECT: e2d5f35c, BVID: 3240, SPVID: 16
+	         U:0, M:0, A:0, RES:4, ECT: 10059445, BVID: 256, SPVID: 1040
+	         U:0, M:1, A:1, RES:14, ECT: 55000001, BVID: 16, SPVID: 2058
+	         U:1, M:0, A:0, RES:12, ECT: f3ac2b26, BVID: 2499, SPVID: 2745
+	         U:1, M:0, A:1, RES:5, ECT: 68735440, BVID: 1216, SPVID: 3072
+	         U:1, M:1, A:1, RES:23, ECT: 020000f7, BVID: 32, SPVID: 0
+	         U:1, M:0, A:0, RES:4, ECT: b59cbe8c, BVID: 4095, SPVID: 4095
+	         U:0, M:0, A:0, RES:0, ECT: 40ff3e88, BVID: 3264, SPVID: 2320
+	         U:0, M:0, A:0, RES:4, ECT: 10059400, BVID: 0, SPVID: 257
+	         U:0, M:0, A:0, RES:8, ECT: 0a269c31, BVID: 2232, SPVID: 3315
+	         U:1, M:0, A:1, RES:12, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:0, ECT: 040e0e0e, BVID: 224, SPVID: 3598
+	         U:1, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0b0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 224, SPVID: 3598
+	         U:0, M:0, A:0, RES:14, ECT: 0e0e0e0e, BVID: 3, SPVID: 3616
+	    unknown TLV #213, length: 243
+		0x0000:  5cca 8010 0410 0594 4510 0410 6e55 0000
+		0x0010:  0101 080a 8cf3 ac2b 269c 0e2d 0e0e 0e0e
+		0x0020:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0030:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0040:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0050:  0e0e 0e0e 0e0e 0e0e 0e1b 0100 1201 8383
+		0x0060:  8383 8383 8383 8383 834f 0060 0641 8fcc
+		0x0070:  0900 2590 894f 6908 e912 0025 e489 4f0e
+		0x0080:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0090:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00a0:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00b0:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00c0:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00d0:  7f0e 0e0e 0e0e 0e0e 0e0e 0e0e 0c0e 0e0e
+		0x00e0:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00f0:  0e0e 0e
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    unknown TLV #100, length: 14
+		0x0000:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    unknown TLV #96, length: 183
+		0x0000:  0fbb 1627 4ce2 d5f3 5cca 8010 0410 0594
+		0x0010:  4510 0410 6e55 0000 0101 080a 8cf3 ac2b
+		0x0020:  269c 3ab9 a568 7354 404c 0c00 f702 0000
+		0x0030:  f702 0000 84b5 9cbe 8cff ffff 0040 ff3e
+		0x0040:  88cc 0910 0410 0594 0000 0101 080a 269c
+		0x0050:  318b 8cf3 ac0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0060:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0070:  0e0e 0e0e 0004 0e0e 0e0e 0e0e 8e0e 0e0e
+		0x0080:  0e0e 0e0e 0e0b 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0090:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00a0:  0e00 3e20 0a00 b60d 0000 2000 0000 84b5
+		0x00b0:  aee0 3083 8383 1b
+	    Area address(es) TLV #1, length: 0
+	    unknown TLV #18, length: 1
+		0x0000:  83
+	    Inter-Domain Information Type TLV #131, length: 131
+	      Inter-Domain Information Type: Unknown (0x83)
+	      0x0000:  8383 8383 8383 834f 0060 0641 8fcc 0900
+	      0x0010:  2590 894f 6908 e912 0025 9089 4f69 0800
+	      0x0020:  4500 0034 9040 4001 4006 a516 cc09 370a
+	      0x0030:  ccff ffff 7fbb da80 d5f3 5c05 1614 4a2d
+	      0x0040:  8010 0410 6e55 0000 0101 080a 8cf3 ac2b
+	      0x0050:  269c 30b9 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+	      0x0060:  0e08 0e0e 0e0e 0e01 0e0e 0e0e 0e0e 110e
+	      0x0070:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+	      0x0080:  0e0e
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    unknown TLV #172, length: 198
+		0x0000:  2478 f620 70ac 2561 8ae3 3458 2d7a 4ea0
+		0x0010:  d056 a568 7354 180e 0e0e 0e0e 0e0e 0e0e
+		0x0020:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0030:  0e0d f20e 0e0e 0e0e 0e0e 0e0e 0e04 0e0e
+		0x0040:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0050:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0060:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0070:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e49 0e0e
+		0x0080:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0d
+		0x0090:  f20e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00a0:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00b0:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00c0:  0e0e 0e0e 0e0e
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3612
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 5
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3676
+	    unknown TLV #92, length: 92
+		0x0000:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0010:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0020:  5c44 4444 4444 4444 4444 4444 4444 4444
+		0x0030:  44b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0040:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0050:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+	    unknown TLV #183, length: 183
+		0x0000:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0010:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0020:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0030:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0040:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0050:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0060:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0070:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0080:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0090:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x00a0:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x00b0:  b7b7 b7b7 b7b7 b7
+	    unknown TLV #183, length: 183
+		0x0000:  b7b7 b7b7 b7b7 b7b7 b7c0 b7b7 b7b7 b7b7
+		0x0010:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0020:  b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7
+		0x0030:  b7b7 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0040:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0050:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0060:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0070:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0080:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0090:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x00a0:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x00b0:  5c5c 5c5c 5c5c 5c
+	    unknown TLV #92, length: 92
+		0x0000:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0010:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0020:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0030:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0040:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0050:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+	    unknown TLV #92, length: 92
+		0x0000:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0010:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0020:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0030:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0040:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0050:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+	    unknown TLV #92, length: 92
+		0x0000:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0010:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0020:  5c5c 715c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0030:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0040:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0050:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+	    unknown TLV #92, length: 92
+		0x0000:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0010:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0020:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0030:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0040:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0050:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+	    unknown TLV #92, length: 92
+		0x0000:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0010:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0020:  5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c
+		0x0030:  5c5c 5c5c 5c5c 5c5c 5c10 0594 4510 0410
+		0x0040:  6e55 0000 0101 080a 8cf3 ac2b 269c 3ab9
+		0x0050:  a568 7354 404c 0c00 f702 0000
+	    unknown TLV #247, length: 2
+		0x0000:  0000
+	    IPv4 Interface address(es) TLV #132, length: 181
+	      IPv4 interface address: 156.190.140.255
+	      IPv4 interface address: 255.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.14.14
+	      IPv4 interface address: 14.14.28.14
+	      IPv4 interface address: 28.14.21.14
+	      IPv4 interface address: 14.14.14.130
+	      IPv4 interface address: 89.186.4.171
+	      IPv4 interface address: 23.3.1.0
+	      IPv4 interface address: 32.144.252.48
+	      IPv4 interface address: 165.128.255.255
+	      IPv4 interface address: 255.246.232.117
+	      IPv4 interface address: 154.157.104.136
+	      IPv4 interface address: 118.103.188.123
+	      IPv4 interface address: 181.119.205.109
+	      IPv4 interface address: 60.22.90.116
+	      IPv4 interface address: 80.127.192.14
+	      IPv4 interface address: 156.165.230.105
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 61197
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 13
+	      LSP Buffersize: 244
+	    unknown TLV #255, length: 0
+	    unknown TLV #64, length: 6
+		0x0000:  3e88 cc09 3650
+	    unknown TLV #204, length: 9
+		0x0000:  370a da80 01bb 0404 04
+	    unknown TLV #11, length: 4
+		0x0000:  2104 0404
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    unknown TLV #234, length: 4
+		0x0000:  0404 0404
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    unknown TLV #0, length: 0
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 5
+	    unknown TLV #13, length: 178
+		0x0000:  c4e4 f9cb 0ce2 cd2e 175a 0bf3 b492 01fa
+		0x0010:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0020:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0030:  3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a
+		0x0040:  3a3a 3a0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e28
+		0x0050:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0060:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0070:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0080:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0090:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00a0:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x00b0:  0e0e
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    Partition DIS TLV #4, length: 4
+	    unknown TLV #0, length: 13
+		0x0000:  b2c4 e4f9 cb0c e2cd 2e17 5a0b f3
+	    unknown TLV #180, length: 146
+		0x0000:  01fa 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0010:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0020:  0e0e 0e28 0e0e 0e0e 0e0e fb0d 0e0e 0e0e
+		0x0030:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0040:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0050:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0060:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0070:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0080:  0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e
+		0x0090:  0e0e
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    IPv4 Internal Reachability TLV #128, length: 0
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    LSP Buffersize TLV #14, length: 14
+	      LSP Buffersize: 3598
+	    unknown TLV #58, length: 58
+		0x0000:  3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a
+		0x0010:  3a3a 3a
+		 packet exceeded snapshot (39) bytes
+EXIT CODE 00000100
diff --git a/tests/kday6.pcap b/tests/kday6.pcap
new file mode 100644
index 0000000..7c6ab89
--- /dev/null
+++ b/tests/kday6.pcap
Binary files differ
diff --git a/tests/kday7.out b/tests/kday7.out
new file mode 100644
index 0000000..94e8b65
--- /dev/null
+++ b/tests/kday7.out
@@ -0,0 +1,59 @@
+IP (tos 0x10, ttl 64, id 63177, offset 0, flags [none], proto unknown (240), length 168, bad cksum 418f (->80a5)!)
+    204.9.54.80 > 204.9.51.132:  ip-proto-240 148
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3da6 (->35a6)!)
+    212.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0x4811), ack 1819218606, win 17918, options [nop,nop,TS val 941371903 ecr 1340592074], length 0
+84:b5:9c:be:30:48 Unknown SSAP 0x10 > 0c:c4:7a:08:e9:12 Unknown DSAP 0x44 Information, send seq 0, rcv seq 26, Flags [Command], length 52
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.54.80.55936 > 204.9.55.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x725a), ack 3589495407, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xcd5f), seq 3589495407:3589495754, ack 370436242, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 58f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 37
+	    -----encapsulated PDU-----|trunc|trunc
+	RPKI-RTRv115, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 12
+	    -----encapsulated PDU-----|trunc|trunc
+	[|RPKI-RTR]
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0
+IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xfa86), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv197, Unknown PDU (100), length: 60
+	  0x0000:  c564 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 37
+	    -----encapsulated PDU-----|trunc|trunc
+	RPKI-RTRv115, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 12
+	    -----encapsulated PDU-----|trunc|trunc
+	[|RPKI-RTR]
+IP truncated-ip - 768 bytes missing! (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 820, bad cksum 3da6 (->3aa6)!)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], seq 0:768, ack 1, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 768
+IP (tos 0x6,ECT(0), ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->4524)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 1, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x4ba9), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 100|trunc
+	RPKI-RTRv115, Error Report PDU (10), length: 66|trunc
+	[|RPKI-RTR]
+EXIT CODE 00000100
diff --git a/tests/kday7.pcap b/tests/kday7.pcap
new file mode 100644
index 0000000..ec1da78
--- /dev/null
+++ b/tests/kday7.pcap
Binary files differ
diff --git a/tests/kday8.out b/tests/kday8.out
new file mode 100644
index 0000000..2d84b72
--- /dev/null
+++ b/tests/kday8.out
@@ -0,0 +1,34 @@
+CFMv0 unknown (204), MD Level 0, length 168
+	First TLV offset 52
+	  0x0000:  a300 0000 0080 0000 0000 0000 0000 0000
+	  0x0010:  0000 00aa 6873 54d7 060b 003c 0000 003c
+	  0x0020:  d4c3 b2a1 0200 1a00 000b 003c 0000 003c
+	  0x0030:  d4c3 b2a1 0200 1a00 0000 0000 3620 0a00
+	  0x0040:  b600 0000 b600 0000 40b5 9cbe 3048 0cc4
+	  0x0050:  ad37 1005 ffff 05cc 0934 9300 0000 0080
+	  0x0060:  fffa 0000 0000 3200 0000 0000 00aa 6873
+	Port status TLV (0x02), length 26, Status: Unknown (0)
+	Unknown TLV (0x37), length 4101
+	  0x0000:  3710 05ff ff05 cc09 3493 0000 0000 80ff
+	  0x0010:  fa00 0000 0032 0000 0000 0000 aa68 7354
+	  0x0020:  d706 0b00 3c00 0000 3c00 0000 0080 0000
+	  0x0030:  fffd 4d5f d9bd c709 30ac 8176 b36d cc11
+	  0x0040:  3abf 1291 f106 4ede 61f4 6297 afc4 39a4
+	  0x0050:  0db9 7a
+IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52)
+    204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0
+IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!)
+    204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0
+IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!)
+    204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0
+IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
+    204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xed9b), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
+	RPKI-RTRv177, Unknown PDU (100), length: 60
+	  0x0000:  b164 003c 0000 003c 0000 00ff ff1f 1b70
+	  0x0010:  f857 ee68 4dfd 4d5f d9bd c709 30ac 8176
+	  0x0020:  b36d cc11 3abf 1291 f106 4ede 61f4 6297
+	  0x0030:  afc4 39a4 0db9 7aa5 6873 33e8
+	RPKI-RTRv65, Error Report PDU (10), length: 66
+	  Error code: Unknown (66), Encapsulated PDU length: 80|trunc
+	[|RPKI-RTR]
+EXIT CODE 00000100
diff --git a/tests/kday8.pcap b/tests/kday8.pcap
new file mode 100644
index 0000000..83577f6
--- /dev/null
+++ b/tests/kday8.pcap
Binary files differ
diff --git a/tests/lacp-ev.out b/tests/lacp-ev.out
new file mode 100644
index 0000000..36ed753
--- /dev/null
+++ b/tests/lacp-ev.out
@@ -0,0 +1,200 @@
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Expired]
+	Partner Information TLV (0x02), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Timeout, Aggregation, Collecting, Distributing]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Expired]
+	Partner Information TLV (0x02), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Timeout, Aggregation, Collecting, Distributing]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Expired]
+	Partner Information TLV (0x02), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Timeout, Aggregation, Collecting, Distributing]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Default]
+	Partner Information TLV (0x02), length 20
+	  System 00:00:00:00:00:00, System Priority 0, Key 0, Port 0, Port Priority 0
+	  State Flags [none]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Collecting, Distributing, Default]
+	Partner Information TLV (0x02), length 20
+	  System 00:00:00:00:00:00, System Priority 0, Key 0, Port 0, Port Priority 0
+	  State Flags [none]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Collecting, Distributing, Default]
+	Partner Information TLV (0x02), length 20
+	  System 00:00:00:00:00:00, System Priority 0, Key 0, Port 0, Port Priority 0
+	  State Flags [none]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Collecting, Distributing, Default]
+	Partner Information TLV (0x02), length 20
+	  System 00:00:00:00:00:00, System Priority 0, Key 0, Port 0, Port Priority 0
+	  State Flags [none]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Collecting, Distributing, Default]
+	Partner Information TLV (0x02), length 20
+	  System 00:00:00:00:00:00, System Priority 0, Key 0, Port 0, Port Priority 0
+	  State Flags [none]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:0e:83:16:f5:10 > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation, Synchronization]
+	Partner Information TLV (0x02), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Collecting, Distributing, Default]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Default]
+	Partner Information TLV (0x02), length 20
+	  System 00:00:00:00:00:00, System Priority 0, Key 0, Port 0, Port Priority 0
+	  State Flags [none]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Default]
+	Partner Information TLV (0x02), length 20
+	  System 00:00:00:00:00:00, System Priority 0, Key 0, Port 0, Port Priority 0
+	  State Flags [none]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:0e:83:16:f5:10 > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation]
+	Partner Information TLV (0x02), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Collecting, Distributing, Default]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:0e:83:16:f5:10 > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation]
+	Partner Information TLV (0x02), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Collecting, Distributing, Default]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:0e:83:16:f5:10 > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation]
+	Partner Information TLV (0x02), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Default]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:0e:83:16:f5:10 > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation, Synchronization]
+	Partner Information TLV (0x02), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Default]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization]
+	Partner Information TLV (0x02), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation, Synchronization]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Collecting, Distributing]
+	Partner Information TLV (0x02), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation, Synchronization]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:0e:83:16:f5:10 > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation, Synchronization, Collecting, Distributing]
+	Partner Information TLV (0x02), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:0e:83:16:f5:10 > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation, Synchronization, Collecting, Distributing]
+	Partner Information TLV (0x02), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Collecting, Distributing]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
+00:13:c4:12:0f:0d > 01:80:c2:00:00:02, ethertype Slow Protocols (0x8809), length 124: LACPv1, length 110
+	Actor Information TLV (0x01), length 20
+	  System 00:13:c4:12:0f:00, System Priority 32768, Key 13, Port 22, Port Priority 32768
+	  State Flags [Activity, Aggregation, Synchronization, Collecting, Distributing]
+	Partner Information TLV (0x02), length 20
+	  System 00:0e:83:16:f5:00, System Priority 32768, Key 13, Port 25, Port Priority 32768
+	  State Flags [Aggregation, Synchronization, Collecting, Distributing]
+	Collector Information TLV (0x03), length 16
+	  Max Delay 32768
+	Terminator TLV (0x00), length 0
diff --git a/tests/ldp_infloop.out b/tests/ldp_infloop.out
new file mode 100644
index 0000000..8c0a062
--- /dev/null
+++ b/tests/ldp_infloop.out
@@ -0,0 +1,5 @@
+IP 45.116.197.72.45307 > 192.168.1.1.646: 
+IP 90.6.30.91.34115 > 192.168.1.1.646: 
+IP 146.203.190.45.13504 > 192.168.1.1.646: 
+IP 67.199.76.127.18327 > 192.168.1.1.646: 
+IP 13.213.243.81.57100 > 192.168.1.1.646: 
diff --git a/tests/lldp_cdp-ev.out b/tests/lldp_cdp-ev.out
new file mode 100644
index 0000000..d9fc647
--- /dev/null
+++ b/tests/lldp_cdp-ev.out
@@ -0,0 +1,252 @@
+00:18:ba:98:68:8f > 01:00:0c:cc:cc:cc, 802.3, length 388: LLC, dsap SNAP (0xaa) Individual, ssap SNAP (0xaa) Command, ctrl 0x03: oui Cisco (0x00000c), pid CDP (0x2000): CDPv2, ttl: 180s, checksum: 0x0bea (unverified), length 366
+	Device-ID (0x01), value length: 2 bytes: 'S1'
+	Version String (0x05), value length: 190 bytes: 
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)
+	  Copyright (c) 1986-2008 by Cisco Systems, Inc.
+	  Compiled Sat 05-Jan-08 00:15 by weiliu
+	Platform (0x06), value length: 19 bytes: 'cisco WS-C3560-24TS'
+	Address (0x02), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	Port-ID (0x03), value length: 16 bytes: 'FastEthernet0/13'
+	Capability (0x04), value length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
+	Protocol-Hello option (0x08), value length: 32 bytes: 
+	VTP Management Domain (0x09), value length: 0 bytes: ''
+	Native VLAN ID (0x0a), value length: 2 bytes: 1
+	Duplex (0x0b), value length: 1 byte: full
+	AVVID trust bitmap (0x12), value length: 1 byte: 0x00
+	AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
+	Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	unknown field type (0x1a), value length: 12 bytes: 
+	  0x0000:  0000 0001 0000 0000 ffff ffff
+00:19:2f:a7:b2:8d > 01:00:0c:cc:cc:cc, 802.3, length 392: LLC, dsap SNAP (0xaa) Individual, ssap SNAP (0xaa) Command, ctrl 0x03: oui Cisco (0x00000c), pid CDP (0x2000): CDPv2, ttl: 180s, checksum: 0x971d (unverified), length 370
+	Device-ID (0x01), value length: 2 bytes: 'S2'
+	Version String (0x05), value length: 190 bytes: 
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)
+	  Copyright (c) 1986-2008 by Cisco Systems, Inc.
+	  Compiled Sat 05-Jan-08 00:15 by weiliu
+	Platform (0x06), value length: 20 bytes: 'cisco WS-C3560G-24PS'
+	Address (0x02), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	Port-ID (0x03), value length: 19 bytes: 'GigabitEthernet0/13'
+	Capability (0x04), value length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
+	Protocol-Hello option (0x08), value length: 32 bytes: 
+	VTP Management Domain (0x09), value length: 0 bytes: ''
+	Native VLAN ID (0x0a), value length: 2 bytes: 1
+	Duplex (0x0b), value length: 1 byte: full
+	AVVID trust bitmap (0x12), value length: 1 byte: 0x00
+	AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
+	Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	unknown field type (0x1a), value length: 12 bytes: 
+	  0x0000:  0000 0001 0000 0000 ffff ffff
+00:19:2f:a7:b2:8d > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 296: LLDP, length 282
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:19:2f:a7:b2:8d
+	Port ID TLV (2), length 13
+	  Subtype Interface alias (1): Uplink to S1
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S2.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 19: GigabitEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [10BASE-T hdx, Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0xc036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
+00:18:ba:98:68:8f > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 287: LLDP, length 273
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:18:ba:98:68:8f
+	Port ID TLV (2), length 7
+	  Subtype Local (7): Fa0/13
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S1.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 16: FastEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0x0036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
+00:19:2f:a7:b2:8d > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 296: LLDP, length 282
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:19:2f:a7:b2:8d
+	Port ID TLV (2), length 13
+	  Subtype Interface alias (1): Uplink to S1
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S2.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 19: GigabitEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [10BASE-T hdx, Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0xc036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
+00:18:ba:98:68:8f > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 287: LLDP, length 273
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:18:ba:98:68:8f
+	Port ID TLV (2), length 7
+	  Subtype Local (7): Fa0/13
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S1.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 16: FastEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0x0036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
+00:18:ba:98:68:8f > 01:00:0c:cc:cc:cc, 802.3, length 388: LLC, dsap SNAP (0xaa) Individual, ssap SNAP (0xaa) Command, ctrl 0x03: oui Cisco (0x00000c), pid CDP (0x2000): CDPv2, ttl: 180s, checksum: 0x0be9 (unverified), length 366
+	Device-ID (0x01), value length: 2 bytes: 'S1'
+	Version String (0x05), value length: 190 bytes: 
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)
+	  Copyright (c) 1986-2008 by Cisco Systems, Inc.
+	  Compiled Sat 05-Jan-08 00:15 by weiliu
+	Platform (0x06), value length: 19 bytes: 'cisco WS-C3560-24TS'
+	Address (0x02), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	Port-ID (0x03), value length: 16 bytes: 'FastEthernet0/13'
+	Capability (0x04), value length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
+	Protocol-Hello option (0x08), value length: 32 bytes: 
+	VTP Management Domain (0x09), value length: 0 bytes: ''
+	Native VLAN ID (0x0a), value length: 2 bytes: 1
+	Duplex (0x0b), value length: 1 byte: full
+	AVVID trust bitmap (0x12), value length: 1 byte: 0x00
+	AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
+	Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	unknown field type (0x1a), value length: 12 bytes: 
+	  0x0000:  0000 0001 0000 0000 ffff ffff
+00:19:2f:a7:b2:8d > 01:00:0c:cc:cc:cc, 802.3, length 392: LLC, dsap SNAP (0xaa) Individual, ssap SNAP (0xaa) Command, ctrl 0x03: oui Cisco (0x00000c), pid CDP (0x2000): CDPv2, ttl: 180s, checksum: 0x971c (unverified), length 370
+	Device-ID (0x01), value length: 2 bytes: 'S2'
+	Version String (0x05), value length: 190 bytes: 
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)
+	  Copyright (c) 1986-2008 by Cisco Systems, Inc.
+	  Compiled Sat 05-Jan-08 00:15 by weiliu
+	Platform (0x06), value length: 20 bytes: 'cisco WS-C3560G-24PS'
+	Address (0x02), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	Port-ID (0x03), value length: 19 bytes: 'GigabitEthernet0/13'
+	Capability (0x04), value length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
+	Protocol-Hello option (0x08), value length: 32 bytes: 
+	VTP Management Domain (0x09), value length: 0 bytes: ''
+	Native VLAN ID (0x0a), value length: 2 bytes: 1
+	Duplex (0x0b), value length: 1 byte: full
+	AVVID trust bitmap (0x12), value length: 1 byte: 0x00
+	AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
+	Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 0.0.0.0
+	unknown field type (0x1a), value length: 12 bytes: 
+	  0x0000:  0000 0001 0000 0000 ffff ffff
+00:19:2f:a7:b2:8d > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 296: LLDP, length 282
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:19:2f:a7:b2:8d
+	Port ID TLV (2), length 13
+	  Subtype Interface alias (1): Uplink to S1
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S2.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 19: GigabitEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [10BASE-T hdx, Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0xc036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
+00:18:ba:98:68:8f > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 287: LLDP, length 273
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:18:ba:98:68:8f
+	Port ID TLV (2), length 7
+	  Subtype Local (7): Fa0/13
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S1.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 16: FastEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0x0036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
+00:19:2f:a7:b2:8d > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 296: LLDP, length 282
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:19:2f:a7:b2:8d
+	Port ID TLV (2), length 13
+	  Subtype Interface alias (1): Uplink to S1
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S2.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 19: GigabitEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [10BASE-T hdx, Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0xc036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
+00:18:ba:98:68:8f > 01:80:c2:00:00:0e, ethertype LLDP (0x88cc), length 287: LLDP, length 273
+	Chassis ID TLV (1), length 7
+	  Subtype MAC address (4): 00:18:ba:98:68:8f
+	Port ID TLV (2), length 7
+	  Subtype Local (7): Fa0/13
+	Time to Live TLV (3), length 2: TTL 120s
+	System Name TLV (5), length 12: S1.cisco.com
+	System Description TLV (6), length 190
+	  Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(44)SE, RELEASE SOFTWARE (fc1)\0x0aCopyright (c) 1986-2008 by Cisco Systems, Inc.\0x0aCompiled Sat 05-Jan-08 00:15 by weiliu
+	Port Description TLV (4), length 16: FastEthernet0/13
+	System Capabilities TLV (7), length 4
+	  System  Capabilities [Bridge, Router] (0x0014)
+	  Enabled Capabilities [Bridge] (0x0004)
+	Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
+	  Port VLAN Id Subtype (1)
+	    port vlan id (PVID): 1
+	Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
+	  MAC/PHY configuration/status Subtype (1)
+	    autonegotiation [supported, enabled] (0x03)
+	    PMD autoneg capability [Sym PAUSE for fdx, Asym and Sym PAUSE for fdx, 1000BASE-{X LX SX CX} fdx, 1000BASE-T hdx] (0x0036)
+	    MAU type 100BASETX fdx (0x0010)
+	End TLV (0), length 0
diff --git a/tests/lmp-v.sh b/tests/lmp-v.sh
new file mode 100755
index 0000000..138a0cd
--- /dev/null
+++ b/tests/lmp-v.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# The "verbose" Link Management Protocol test involves a float calculation that
+# may produce a slightly different result depending on the architecture and the
+# compiler (see GitHub issue #333). The reference output was produced using a
+# GCC build and must reproduce correctly on any other GCC build regardless of
+# the architecture.
+
+# A Windows build may have no file named Makefile and also a version of grep
+# that won't return an error when the file does not exist. Work around.
+if [ ! -f ../Makefile ]
+then
+	printf '    %-30s: TEST SKIPPED (no Makefile)\n' 'lmp-v'
+elif grep '^CC = .*gcc' ../Makefile >/dev/null
+then
+  ./TESTonce lmp-v lmp.pcap lmp-v.out '-t -T lmp -v'
+else
+	printf '    %-30s: TEST SKIPPED (compiler is not GCC)\n' 'lmp-v'
+fi
diff --git a/tests/loopback.out b/tests/loopback.out
new file mode 100644
index 0000000..7b8dece
--- /dev/null
+++ b/tests/loopback.out
@@ -0,0 +1,6 @@
+Loopback, skipCount 0, Forward Data, forwarding address aa:00:04:00:1d:04, data (44 octets)
+Loopback, skipCount 8, Reply, receipt number 1, data (40 octets)
+Loopback, skipCount 0, Forward Data, forwarding address aa:00:04:00:6a:04, data (60 octets)
+Loopback, skipCount 8, Forward Data, forwarding address aa:00:04:00:69:04, data (52 octets)
+Loopback, skipCount 16, Forward Data, forwarding address aa:00:04:00:1d:04, data (44 octets)
+Loopback, skipCount 24, Reply, receipt number 2, data (40 octets)
diff --git a/tests/loopback.pcap b/tests/loopback.pcap
new file mode 100644
index 0000000..384c0d3
--- /dev/null
+++ b/tests/loopback.pcap
Binary files differ
diff --git a/tests/mpbgp-linklocal-nexthop.out b/tests/mpbgp-linklocal-nexthop.out
index 337f0d8..9a4c2bd 100644
--- a/tests/mpbgp-linklocal-nexthop.out
+++ b/tests/mpbgp-linklocal-nexthop.out
@@ -1,5 +1,5 @@
 IP (tos 0xc0, ttl 64, id 22725, offset 0, flags [DF], proto TCP (6), length 142)
-    30.0.0.1.49038 > 30.0.0.2.179: Flags [P.], cksum 0xd6dc (correct), seq 1284816775:1284816865, ack 1288709908, win 29, options [nop,nop,TS val 184150022 ecr 184150021], length 90: BGP, length: 90
+    30.0.0.1.49038 > 30.0.0.2.179: Flags [P.], cksum 0xd6dc (correct), seq 1284816775:1284816865, ack 1288709908, win 29, options [nop,nop,TS val 184150022 ecr 184150021], length 90: BGP
 	Update Message (2), length: 90
 	  Origin (1), length: 1, Flags [T]: Incomplete
 	  AS Path (2), length: 4, Flags [T]: 1 
diff --git a/tests/mrinfo_query.pcap b/tests/mrinfo_query.pcap
new file mode 100644
index 0000000..63a86d6
--- /dev/null
+++ b/tests/mrinfo_query.pcap
Binary files differ
diff --git a/tests/mstp-v.out b/tests/mstp-v.out
new file mode 100644
index 0000000..16127b5
--- /dev/null
+++ b/tests/mstp-v.out
@@ -0,0 +1,130 @@
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward], length 134
+	port-role Root, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 8012, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 200000, 
+	CIST bridge-id 8000.00:1e:f7:05:a8:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 0
+		MSTI bridge-prio 6, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward, Agreement], length 134
+	port-role Designated, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 800f, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 0, 
+	CIST bridge-id 8000.00:16:46:b5:8c:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 0
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward], length 134
+	port-role Root, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 8012, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 200000, 
+	CIST bridge-id 8000.00:1e:f7:05:a8:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 0
+		MSTI bridge-prio 6, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward, Agreement], length 134
+	port-role Designated, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 800f, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 0, 
+	CIST bridge-id 8000.00:16:46:b5:8c:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 0
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward], length 134
+	port-role Root, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 8012, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 200000, 
+	CIST bridge-id 8000.00:1e:f7:05:a8:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 0
+		MSTI bridge-prio 6, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward, Agreement], length 134
+	port-role Designated, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 800f, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 0, 
+	CIST bridge-id 8000.00:16:46:b5:8c:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 0
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward], length 134
+	port-role Root, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 8012, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 200000, 
+	CIST bridge-id 8000.00:1e:f7:05:a8:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 0
+		MSTI bridge-prio 6, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward, Agreement], length 134
+	port-role Designated, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 800f, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 0, 
+	CIST bridge-id 8000.00:16:46:b5:8c:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 0
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward], length 134
+	port-role Root, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 8012, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 200000, 
+	CIST bridge-id 8000.00:1e:f7:05:a8:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 0
+		MSTI bridge-prio 6, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+STP 802.1s, Rapid STP, CIST Flags [Learn, Forward, Agreement], length 134
+	port-role Designated, CIST root-id 0000.00:1f:27:b4:7d:80, CIST ext-pathcost 200000 
+	CIST regional-root-id 8000.00:16:46:b5:8c:80, CIST port-id 800f, 
+	message-age 1.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	v3len 96, MCID Name Brewery, rev 0, 
+		digest 9357ebb7a8d74dd5fef4f2bab50531aa, CIST int-root-pathcost 0, 
+	CIST bridge-id 8000.00:16:46:b5:8c:80, CIST remaining-hops 20
+	MSTI 1, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Root
+		MSTI regional-root-id 6001.00:1e:f7:05:a8:80, pathcost 200000
+		MSTI bridge-prio 8, port-prio 8, hops 20
+	MSTI 2, Flags [Learn, Forward, Agreement, Topology change ACK], port-role Designated
+		MSTI regional-root-id 8002.00:16:46:b5:8c:80, pathcost 0
+		MSTI bridge-prio 8, port-prio 8, hops 20
diff --git a/tests/mtrace.out b/tests/mtrace.out
new file mode 100644
index 0000000..2995f60
--- /dev/null
+++ b/tests/mtrace.out
@@ -0,0 +1,2 @@
+IP 10.0.0.5 > 172.16.20.1: mtrace 7: 172.16.40.1 to 172.16.20.1 reply-to 172.16.40.1
+IP 10.0.0.6 > 10.0.0.5: mtrace 7: 172.16.40.1 to 172.16.20.1 reply-to 172.16.40.1
diff --git a/tests/mtrace.pcap b/tests/mtrace.pcap
new file mode 100644
index 0000000..0d16dd3
--- /dev/null
+++ b/tests/mtrace.pcap
Binary files differ
diff --git a/tests/nflog-e.sh b/tests/nflog-e.sh
new file mode 100755
index 0000000..00ac4fd
--- /dev/null
+++ b/tests/nflog-e.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# NFLOG support depends on both DLT_NFLOG and working <pcap/nflog.h>
+
+if grep '^#define HAVE_PCAP_NFLOG_H 1$' ../config.h >/dev/null
+then
+  ./TESTonce nflog-e nflog.pcap nflog-e.out '-t -e'
+else
+	printf '    %-30s: TEST SKIPPED (compiled w/o NFLOG)\n' 'nflog-e'
+fi
diff --git a/tests/of10_7050q-v.out b/tests/of10_7050q-v.out
new file mode 100644
index 0000000..4929920
--- /dev/null
+++ b/tests/of10_7050q-v.out
@@ -0,0 +1,18 @@
+IP (tos 0x0, ttl 64, id 53965, offset 0, flags [DF], proto TCP (6), length 104)
+    10.0.0.80.6633 > 86.139.225.177.57145: Flags [P.], cksum 0xddb3 (correct), seq 3804035784:3804035836, ack 3936946676, win 136, options [nop,nop,TS val 256259488 ecr 12980962], length 52: OpenFlow
+	version 1.0, type VENDOR, length 24, xid 0x00000018, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_IP_MASK_REQUEST, index 0
+	version 1.0, type VENDOR, length 20, xid 0x00000019, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_MIRRORING_REQUEST, report_mirror_ports OFF
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x0000001a
+IP (tos 0x0, ttl 44, id 2943, offset 0, flags [DF], proto TCP (6), length 76)
+    86.139.225.177.57145 > 10.0.0.80.6633: Flags [P.], cksum 0xf75f (correct), seq 1:25, ack 52, win 54, options [nop,nop,TS val 12980987 ecr 256259488], length 24: OpenFlow
+	version 1.0, type VENDOR, length 24, xid 0x00000018, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_IP_MASK_REPLY, index 0, mask 255.255.255.255
+IP (tos 0x0, ttl 64, id 53966, offset 0, flags [DF], proto TCP (6), length 52)
+    10.0.0.80.6633 > 86.139.225.177.57145: Flags [.], cksum 0x42b3 (incorrect -> 0x0ee3), ack 25, win 136, options [nop,nop,TS val 256259628 ecr 12980987], length 0
+IP (tos 0x0, ttl 44, id 2944, offset 0, flags [DF], proto TCP (6), length 80)
+    86.139.225.177.57145 > 10.0.0.80.6633: Flags [P.], cksum 0xf55e (correct), seq 25:53, ack 52, win 54, options [nop,nop,TS val 12981023 ecr 256259628], length 28: OpenFlow
+	version 1.0, type VENDOR, length 20, xid 0x00000019, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_MIRRORING_REPLY, report_mirror_ports OFF
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x0000001a
diff --git a/tests/of10_7050q.pcap b/tests/of10_7050q.pcap
new file mode 100644
index 0000000..43602af
--- /dev/null
+++ b/tests/of10_7050q.pcap
Binary files differ
diff --git a/tests/of10_7050sx_bsn-vv.out b/tests/of10_7050sx_bsn-vv.out
new file mode 100644
index 0000000..a1674fc
--- /dev/null
+++ b/tests/of10_7050sx_bsn-vv.out
@@ -0,0 +1,343 @@
+IP (tos 0x0, ttl 55, id 5483, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.37044 > 109.74.202.168.6653: Flags [S], cksum 0x0576 (correct), seq 1216143989, win 14600, options [mss 1460,sackOK,TS val 50525982 ecr 0,nop,wscale 7], length 0
+IP (tos 0x0, ttl 64, id 26571, offset 0, flags [DF], proto TCP (6), length 40)
+    109.74.202.168.6653 > 88.150.169.52.37044: Flags [R.], cksum 0xa06e (correct), seq 0, ack 1216143990, win 0, length 0
+IP (tos 0x0, ttl 55, id 49495, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [S], cksum 0x4629 (correct), seq 774256709, win 14600, options [mss 1460,sackOK,TS val 50526482 ecr 0,nop,wscale 7], length 0
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [S.], cksum 0x39ec (incorrect -> 0x0c04), seq 3422281440, ack 774256710, win 28960, options [mss 1460,sackOK,TS val 590230513 ecr 50526482,nop,wscale 7], length 0
+IP (tos 0x0, ttl 55, id 49496, offset 0, flags [DF], proto TCP (6), length 52)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [.], cksum 0xab7c (correct), seq 1, ack 1, win 115, options [nop,nop,TS val 50526483 ecr 590230513], length 0
+IP (tos 0x0, ttl 64, id 60691, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa9f0), seq 1:9, ack 1, win 227, options [nop,nop,TS val 590230516 ecr 50526483], length 8: OpenFlow
+	version 1.0, type HELLO, length 8, xid 0x00000001
+IP (tos 0x0, ttl 55, id 49497, offset 0, flags [DF], proto TCP (6), length 52)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [.], cksum 0xab6e (correct), seq 1, ack 9, win 115, options [nop,nop,TS val 50526486 ecr 590230516], length 0
+IP (tos 0x0, ttl 55, id 49498, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x7b45 (correct), seq 1:9, ack 9, win 115, options [nop,nop,TS val 50526732 ecr 590230516], length 8: OpenFlow
+	version 1.0, type HELLO, length 8, xid 0x00002e1b
+IP (tos 0x0, ttl 64, id 60692, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa8d7), seq 9, ack 9, win 227, options [nop,nop,TS val 590230813 ecr 50526732], length 0
+IP (tos 0x0, ttl 64, id 60693, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa7b8), seq 9:17, ack 9, win 227, options [nop,nop,TS val 590230813 ecr 50526732], length 8: OpenFlow
+	version 1.0, type FEATURES_REQUEST, length 8, xid 0x00000002
+IP (tos 0x0, ttl 55, id 49499, offset 0, flags [DF], proto TCP (6), length 52)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [.], cksum 0xa93e (correct), seq 9, ack 17, win 115, options [nop,nop,TS val 50526733 ecr 590230813], length 0
+IP (tos 0x0, ttl 55, id 49500, offset 0, flags [DF], proto TCP (6), length 468)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xff61 (correct), seq 9:425, ack 17, win 115, options [nop,nop,TS val 50526733 ecr 590230813], length 416: OpenFlow
+	version 1.0, type FEATURES_REPLY, length 416, xid 0x00000002
+	 dpid 0x0000001c737d280f, n_buffers 0, n_tables 1
+	 capabilities 0x000000c7 (FLOW_STATS, TABLE_STATS, PORT_STATS, QUEUE_STATS, ARP_MATCH_IP)
+	 actions 0x00000905 (OUTPUT, SET_VLAN_PCP, SET_NW_TOS, ENQUEUE)
+	  port_no 16, hw_addr 00:1c:73:7d:28:1f, name 'Ethernet16'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 20, hw_addr 00:1c:73:7d:28:23, name 'Ethernet20'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 18, hw_addr 00:1c:73:7d:28:21, name 'Ethernet18'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 22, hw_addr 00:1c:73:7d:28:25, name 'Ethernet22'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 17, hw_addr 00:1c:73:7d:28:20, name 'Ethernet17'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000cc0 (10GB_FD, COPPER, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 21, hw_addr 00:1c:73:7d:28:24, name 'Ethernet21'
+	   config 0x80000001 (PORT_DOWN) (bogus)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000cc0 (10GB_FD, COPPER, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 19, hw_addr 00:1c:73:7d:28:22, name 'Ethernet19'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 23, hw_addr 00:1c:73:7d:28:26, name 'Ethernet23'
+	   config 0x80000001 (PORT_DOWN) (bogus)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+IP (tos 0x0, ttl 64, id 60694, offset 0, flags [DF], proto TCP (6), length 136)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x3a38 (incorrect -> 0xa414), seq 17:101, ack 425, win 235, options [nop,nop,TS val 590230815 ecr 50526733], length 84: OpenFlow
+	version 1.0, type SET_CONFIG, length 12, xid 0x00000003
+	 flags FRAG_NORMAL, miss_send_len 65535
+	version 1.0, type FLOW_MOD, length 72, xid 0x00000004
+	 cookie 0x0000000000000000, command DELETE, out_port NONE, flags 0x0000
+IP (tos 0x0, ttl 64, id 60695, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa5a0), seq 101:109, ack 425, win 235, options [nop,nop,TS val 590230816 ecr 50526733], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000005
+IP (tos 0x0, ttl 55, id 49501, offset 0, flags [DF], proto TCP (6), length 140)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x8297 (correct), seq 425:513, ack 109, win 115, options [nop,nop,TS val 50526735 ecr 590230815], length 88: OpenFlow
+	version 1.0, type FLOW_REMOVED, length 88, xid 0x00000ffd
+	 match in_port 16
+	 cookie 0x0000000000000001, priority 33000, reason DELETE, duration_sec 53, duration_nsec 990000000, packet_count 0, byte_count 0
+IP (tos 0x0, ttl 64, id 60696, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa661), seq 109, ack 513, win 235, options [nop,nop,TS val 590230828 ecr 50526735], length 0
+IP (tos 0x0, ttl 55, id 49502, offset 0, flags [DF], proto TCP (6), length 236)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x6fdb (correct), seq 513:697, ack 109, win 115, options [nop,nop,TS val 50526745 ecr 590230828], length 184: OpenFlow
+	version 1.0, type FLOW_REMOVED, length 88, xid 0x00000ffe
+	 match in_port 18
+	 cookie 0x0000000000000002, priority 31000, reason DELETE, duration_sec 53, duration_nsec 990000000, packet_count 0, byte_count 0
+	version 1.0, type FLOW_REMOVED, length 88, xid 0x00000fff
+	 match in_port 22
+	 cookie 0x0000000000000003, priority 30000, reason DELETE, duration_sec 53, duration_nsec 990000000, packet_count 0, byte_count 0
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000005
+IP (tos 0x0, ttl 64, id 60697, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa596), seq 109, ack 697, win 243, options [nop,nop,TS val 590230829 ecr 50526745], length 0
+IP (tos 0x0, ttl 64, id 60698, offset 0, flags [DF], proto TCP (6), length 140)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x3a3c (incorrect -> 0x41fa), seq 109:197, ack 697, win 243, options [nop,nop,TS val 590230829 ecr 50526745], length 88: OpenFlow
+	version 1.0, type VENDOR, length 20, xid 0x00000006, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SET_MIRRORING, report_mirror_ports ON
+	version 1.0, type VENDOR, length 20, xid 0x00000007, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_MIRRORING_REQUEST, report_mirror_ports OFF
+	version 1.0, type VENDOR, length 20, xid 0x00000008, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SET_MIRRORING, report_mirror_ports OFF
+	version 1.0, type VENDOR, length 20, xid 0x00000009, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_MIRRORING_REQUEST, report_mirror_ports OFF
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x0000000a
+IP (tos 0x0, ttl 55, id 49503, offset 0, flags [DF], proto TCP (6), length 72)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x8c59 (correct), seq 697:717, ack 197, win 115, options [nop,nop,TS val 50526747 ecr 590230829], length 20: OpenFlow
+	version 1.0, type VENDOR, length 20, xid 0x00000007, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_MIRRORING_REPLY, report_mirror_ports ON
+IP (tos 0x0, ttl 64, id 60699, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa51a), seq 197, ack 717, win 243, options [nop,nop,TS val 590230843 ecr 50526747], length 0
+IP (tos 0x0, ttl 55, id 49504, offset 0, flags [DF], proto TCP (6), length 80)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x8bfd (correct), seq 717:745, ack 197, win 115, options [nop,nop,TS val 50526758 ecr 590230843], length 28: OpenFlow
+	version 1.0, type VENDOR, length 20, xid 0x00000009, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_MIRRORING_REPLY, report_mirror_ports OFF
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x0000000a
+IP (tos 0x0, ttl 64, id 60700, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa4f3), seq 197, ack 745, win 243, options [nop,nop,TS val 590230843 ecr 50526758], length 0
+IP (tos 0x0, ttl 64, id 60701, offset 0, flags [DF], proto TCP (6), length 80)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x3a00 (incorrect -> 0xa165), seq 197:225, ack 745, win 243, options [nop,nop,TS val 590230843 ecr 50526758], length 28: OpenFlow
+	version 1.0, type FEATURES_REQUEST, length 8, xid 0x0000000b
+	version 1.0, type STATS_REQUEST, length 12, xid 0x0000000c
+	 type TABLE, flags 0x0000
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x0000000d
+IP (tos 0x0, ttl 55, id 49505, offset 0, flags [DF], proto TCP (6), length 468)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xfb70 (correct), seq 745:1161, ack 225, win 115, options [nop,nop,TS val 50526759 ecr 590230843], length 416: OpenFlow
+	version 1.0, type FEATURES_REPLY, length 416, xid 0x0000000b
+	 dpid 0x0000001c737d280f, n_buffers 0, n_tables 1
+	 capabilities 0x000000c7 (FLOW_STATS, TABLE_STATS, PORT_STATS, QUEUE_STATS, ARP_MATCH_IP)
+	 actions 0x00000905 (OUTPUT, SET_VLAN_PCP, SET_NW_TOS, ENQUEUE)
+	  port_no 16, hw_addr 00:1c:73:7d:28:1f, name 'Ethernet16'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 20, hw_addr 00:1c:73:7d:28:23, name 'Ethernet20'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 18, hw_addr 00:1c:73:7d:28:21, name 'Ethernet18'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 22, hw_addr 00:1c:73:7d:28:25, name 'Ethernet22'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 17, hw_addr 00:1c:73:7d:28:20, name 'Ethernet17'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000cc0 (10GB_FD, COPPER, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 21, hw_addr 00:1c:73:7d:28:24, name 'Ethernet21'
+	   config 0x80000001 (PORT_DOWN) (bogus)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000cc0 (10GB_FD, COPPER, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 19, hw_addr 00:1c:73:7d:28:22, name 'Ethernet19'
+	   config 0x00000001 (PORT_DOWN)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+	  port_no 23, hw_addr 00:1c:73:7d:28:26, name 'Ethernet23'
+	   config 0x80000001 (PORT_DOWN) (bogus)
+	   state 0x00000001 (LINK_DOWN)
+	   curr 0x00000040 (10GB_FD)
+	   advertised 0x00000000
+	   supported 0x00000c40 (10GB_FD, PAUSE, PAUSE_ASYM)
+	   peer 0x00000000
+IP (tos 0x0, ttl 64, id 60702, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa320), seq 225, ack 1161, win 252, options [nop,nop,TS val 590230856 ecr 50526759], length 0
+IP (tos 0x0, ttl 55, id 49506, offset 0, flags [DF], proto TCP (6), length 136)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x4ea6 (correct), seq 1161:1245, ack 225, win 115, options [nop,nop,TS val 50526769 ecr 590230856], length 84: OpenFlow
+	version 1.0, type STATS_REPLY, length 76, xid 0x0000000c
+	 type TABLE, flags 0x0000
+	 table_id 0, name 'Table 0'
+	  wildcards 0x003fffff (IN_PORT, DL_VLAN, DL_SRC, DL_DST, DL_TYPE, NW_PROTO, TP_SRC, TP_DST, DL_VLAN_PCP, NW_TOS)
+	  max_entries 1500, active_count 0, lookup_count 0, matched_count 0
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x0000000d
+IP (tos 0x0, ttl 64, id 60703, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa2c1), seq 225, ack 1245, win 252, options [nop,nop,TS val 590230857 ecr 50526769], length 0
+IP (tos 0x0, ttl 64, id 60704, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa189), seq 225:233, ack 1245, win 252, options [nop,nop,TS val 590230857 ecr 50526769], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x0000000e
+IP (tos 0x0, ttl 55, id 49507, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa208 (correct), seq 1245:1253, ack 233, win 115, options [nop,nop,TS val 50526770 ecr 590230857], length 8: OpenFlow
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x0000000e
+IP (tos 0x0, ttl 64, id 60705, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa176), seq 233:241, ack 1253, win 252, options [nop,nop,TS val 590230858 ecr 50526770], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x0000000f
+IP (tos 0x0, ttl 55, id 49508, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa1f5 (correct), seq 1253:1261, ack 241, win 115, options [nop,nop,TS val 50526771 ecr 590230858], length 8: OpenFlow
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x0000000f
+IP (tos 0x0, ttl 64, id 60706, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa163), seq 241:249, ack 1261, win 252, options [nop,nop,TS val 590230859 ecr 50526771], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000010
+IP (tos 0x0, ttl 55, id 49509, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa1e3 (correct), seq 1261:1269, ack 249, win 115, options [nop,nop,TS val 50526771 ecr 590230859], length 8: OpenFlow
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000010
+IP (tos 0x0, ttl 64, id 60707, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa151), seq 249:257, ack 1269, win 252, options [nop,nop,TS val 590230860 ecr 50526771], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000011
+IP (tos 0x0, ttl 55, id 49510, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa1d0 (correct), seq 1269:1277, ack 257, win 115, options [nop,nop,TS val 50526772 ecr 590230860], length 8: OpenFlow
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000011
+IP (tos 0x0, ttl 64, id 60708, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa13e), seq 257:265, ack 1277, win 252, options [nop,nop,TS val 590230861 ecr 50526772], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000012
+IP (tos 0x0, ttl 55, id 49511, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa1bd (correct), seq 1277:1285, ack 265, win 115, options [nop,nop,TS val 50526773 ecr 590230861], length 8: OpenFlow
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000012
+IP (tos 0x0, ttl 64, id 60709, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0xa12b), seq 265:273, ack 1285, win 252, options [nop,nop,TS val 590230862 ecr 50526773], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000013
+IP (tos 0x0, ttl 55, id 49512, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa1aa (correct), seq 1285:1293, ack 273, win 115, options [nop,nop,TS val 50526774 ecr 590230862], length 8: OpenFlow
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000013
+IP (tos 0x0, ttl 64, id 60710, offset 0, flags [DF], proto TCP (6), length 120)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x3a28 (incorrect -> 0x9a6c), seq 273:341, ack 1293, win 252, options [nop,nop,TS val 590230863 ecr 50526774], length 68: OpenFlow
+	version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000014
+	 port_no 16
+	version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000015
+	 port_no 20
+	version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000016
+	 port_no 18
+	version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000017
+	 port_no 22
+	version 1.0, type QUEUE_GET_CONFIG_REQUEST, length 12, xid 0x00000018
+	 port_no 17
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000019
+IP (tos 0x0, ttl 55, id 49513, offset 0, flags [DF], proto TCP (6), length 68)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0xa139 (correct), seq 1293:1309, ack 341, win 115, options [nop,nop,TS val 50526775 ecr 590230863], length 16: OpenFlow
+	version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000014
+	 port_no 16
+IP (tos 0x0, ttl 64, id 60711, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa1f5), seq 341, ack 1309, win 252, options [nop,nop,TS val 590230875 ecr 50526775], length 0
+IP (tos 0x0, ttl 55, id 49514, offset 0, flags [DF], proto TCP (6), length 124)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x9bb5 (correct), seq 1309:1381, ack 341, win 115, options [nop,nop,TS val 50526785 ecr 590230875], length 72: OpenFlow
+	version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000015
+	 port_no 20
+	version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000016
+	 port_no 18
+	version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000017
+	 port_no 22
+	version 1.0, type QUEUE_GET_CONFIG_REPLY, length 16, xid 0x00000018
+	 port_no 17
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000019
+IP (tos 0x0, ttl 64, id 60712, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0xa1a3), seq 341, ack 1381, win 252, options [nop,nop,TS val 590230875 ecr 50526785], length 0
+IP (tos 0x0, ttl 64, id 60713, offset 0, flags [DF], proto TCP (6), length 562)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x3be2 (incorrect -> 0x4d80), seq 341:851, ack 1381, win 252, options [nop,nop,TS val 590230876 ecr 50526785], length 510: OpenFlow
+	version 1.0, type VENDOR, length 24, xid 0x0000001a, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SET_IP_MASK, index 1, mask 255.0.14.0
+	version 1.0, type VENDOR, length 24, xid 0x0000001b, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SET_IP_MASK, index 2, mask 255.0.28.0
+	version 1.0, type VENDOR, length 24, xid 0x0000001c, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SET_IP_MASK, index 3, mask 255.0.56.0
+	version 1.0, type VENDOR, length 24, xid 0x0000001d, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SET_IP_MASK, index 4, mask 255.0.112.0
+	version 1.0, type VENDOR, length 24, xid 0x0000001e, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SET_IP_MASK, index 5, mask 255.0.224.0
+	version 1.0, type VENDOR, length 24, xid 0x0000001f, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_IP_MASK_REQUEST, index 3
+	version 1.0, type VENDOR, length 30, xid 0x00000020, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SHELL_COMMAND, service 0, data 'show clock'
+	version 1.0, type FLOW_MOD, length 104, xid 0x00000021
+	 match in_port 16
+	 cookie 0x0000000000000001, command ADD, priority 33000, buffer_id NONE, flags 0x0001 (SEND_FLOW_REM)
+	 action type VENDOR, len 24, vendor 0x005c16c7 (Big Switch Networks)
+	  subtype MIRROR, dest_port 21, vlan_tag none, copy_stage INGRESS
+	 action type OUTPUT, len 8, port 17
+	version 1.0, type FLOW_MOD, length 128, xid 0x00000022
+	 match in_port 18
+	 cookie 0x0000000000000002, command ADD, priority 31000, buffer_id NONE, flags 0x0001 (SEND_FLOW_REM)
+	 action type VENDOR, len 24, vendor 0x005c16c7 (Big Switch Networks)
+	  subtype MIRROR, dest_port 21, vlan_tag 802.1Q (vlan 2, p 4), copy_stage INGRESS
+	 action type OUTPUT, len 8, port 19
+	 action type VENDOR, len 24, vendor 0x005c16c7 (Big Switch Networks)
+	  subtype MIRROR, dest_port 23, vlan_tag 802.1Q (vlan 2748, p 5, DEI), copy_stage EGRESS
+	version 1.0, type FLOW_MOD, length 96, xid 0x00000023
+	 match in_port 22
+	 cookie 0x0000000000000003, command ADD, priority 30000, buffer_id NONE, flags 0x0001 (SEND_FLOW_REM)
+	 action type VENDOR, len 24, vendor 0x005c16c7 (Big Switch Networks)
+	  subtype MIRROR, dest_port 21, vlan_tag 802.1Q (vlan 0, p 1), copy_stage INGRESS
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000024
+IP (tos 0x0, ttl 55, id 49515, offset 0, flags [DF], proto TCP (6), length 76)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x4da3 (correct), seq 1381:1405, ack 851, win 123, options [nop,nop,TS val 50526786 ecr 590230876], length 24: OpenFlow
+	version 1.0, type VENDOR, length 24, xid 0x0000001f, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype GET_IP_MASK_REPLY, index 3, mask 255.0.56.0
+IP (tos 0x0, ttl 64, id 60714, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0x9f7f), seq 851, ack 1405, win 252, options [nop,nop,TS val 590230888 ecr 50526786], length 0
+IP (tos 0x0, ttl 55, id 49516, offset 0, flags [DF], proto TCP (6), length 80)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x8632 (correct), seq 1405:1433, ack 851, win 123, options [nop,nop,TS val 50526795 ecr 590230888], length 28: OpenFlow
+	version 1.0, type VENDOR, length 20, xid 0x00000020, vendor 0x005c16c7 (Big Switch Networks)
+	 subtype SHELL_STATUS, status 0xfffffffe
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000024
+IP (tos 0x0, ttl 64, id 60715, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0x9f59), seq 851, ack 1433, win 252, options [nop,nop,TS val 590230889 ecr 50526795], length 0
+IP (tos 0x0, ttl 64, id 60716, offset 0, flags [DF], proto TCP (6), length 60)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], cksum 0x39ec (incorrect -> 0x9e0a), seq 851:859, ack 1433, win 252, options [nop,nop,TS val 590230889 ecr 50526795], length 8: OpenFlow
+	version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000025
+IP (tos 0x0, ttl 55, id 49517, offset 0, flags [DF], proto TCP (6), length 60)
+    88.150.169.52.4756 > 109.74.202.168.6653: Flags [P.], cksum 0x9e80 (correct), seq 1433:1441, ack 859, win 123, options [nop,nop,TS val 50526797 ecr 590230889], length 8: OpenFlow
+	version 1.0, type BARRIER_REPLY, length 8, xid 0x00000025
+IP (tos 0x0, ttl 64, id 60717, offset 0, flags [DF], proto TCP (6), length 52)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [.], cksum 0x39e4 (incorrect -> 0x9f3a), seq 859, ack 1441, win 252, options [nop,nop,TS val 590230902 ecr 50526797], length 0
diff --git a/tests/of10_7050sx_bsn.pcap b/tests/of10_7050sx_bsn.pcap
new file mode 100644
index 0000000..c5164f1
--- /dev/null
+++ b/tests/of10_7050sx_bsn.pcap
Binary files differ
diff --git a/tests/of10_p3295-vv.out b/tests/of10_p3295-vv.out
index 824595d..7d1a691 100644
--- a/tests/of10_p3295-vv.out
+++ b/tests/of10_p3295-vv.out
@@ -456,7 +456,7 @@
 	version 1.0, type FLOW_MOD, length 144, xid 0x00000010
 	 match in_port 4
 	 cookie 0x000000000000000b, command ADD, priority 54311, buffer_id NONE, flags 0x0001 (SEND_FLOW_REM)
-	 action type VENDOR, len 72, vendor 0x00001234
+	 action type VENDOR, len 72, vendor 0x00001234 (unknown)
 	 data (64 octets)
 	  0x0000:  4469 6420 796f 7520 6b6e 6f77 2076 656e  Did.you.know.ven
 	  0x0010:  646f 7220 6163 7469 6f6e 2064 6174 6120  dor.action.data.
@@ -730,8 +730,8 @@
 	version 1.0, type STATS_REPLY, length 76, xid 0x0000001f
 	 type TABLE, flags 0x0000
 	 table_id 0, name 'classifier'
-	 wildcards 0x003fffff (IN_PORT, DL_VLAN, DL_SRC, DL_DST, DL_TYPE, NW_PROTO, TP_SRC, TP_DST, DL_VLAN_PCP, NW_TOS)
-	 max_entries 1000000, active_count 26, lookup_count 1158498983736653433, matched_count 1158498983736653433
+	  wildcards 0x003fffff (IN_PORT, DL_VLAN, DL_SRC, DL_DST, DL_TYPE, NW_PROTO, TP_SRC, TP_DST, DL_VLAN_PCP, NW_TOS)
+	  max_entries 1000000, active_count 26, lookup_count 1158498983736653433, matched_count 1158498983736653433
 IP (tos 0x0, ttl 64, id 794, offset 0, flags [DF], proto TCP (6), length 52)
     10.0.0.20.6633 > 10.0.0.50.35256: Flags [.], cksum 0x146c (incorrect -> 0x7eb8), seq 2237, ack 7057, win 203, options [nop,nop,TS val 220958721 ecr 194889063], length 0
 IP (tos 0x0, ttl 64, id 55530, offset 0, flags [DF], proto TCP (6), length 2948)
diff --git a/tests/ospf3_ah-vv.out b/tests/ospf3_ah-vv.out
new file mode 100644
index 0000000..54a521b
--- /dev/null
+++ b/tests/ospf3_ah-vv.out
@@ -0,0 +1,645 @@
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 60) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x13): OSPFv3, Hello, length 36
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 60) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0xd): OSPFv3, Hello, length 36
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x14): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0xe): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x15): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0xf): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x17): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 52) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x16): OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x000012fd
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x10): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 52) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x18): OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x000012fd
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x19): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 52) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x1a): OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x000012fd
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 52) fe80::2 > fe80::1: AH(spi=0x00000100,sumlen=16,seq=0x11): OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00000b91
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 352) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x1b): OSPFv3, Database Description, length 328
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x00000b91
+	  Advertising Router 1.1.1.1, seq 0x8000000b, age 14s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000008, age 69s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 74s, length 12
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 54s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 54s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 54s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 54s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 1019s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 873s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 873s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 873s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 49s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 1082s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 49s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 74s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x12): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 312) fe80::2 > fe80::1: AH(spi=0x00000100,sumlen=16,seq=0x13): OSPFv3, Database Description, length 288
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x00000b92
+	  Advertising Router 1.1.1.1, seq 0x80000008, age 68s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000a, age 39s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1020s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 865s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 865s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 865s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 1084s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 33s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 33s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 52) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x1c): OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00000b92
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 196) fe80::2 > fe80::1: AH(spi=0x00000100,sumlen=16,seq=0x14): OSPFv3, LS-Request, length 172
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 1.1.1.1
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+	  Advertising Router 1.1.1.1
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 172) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x1d): OSPFv3, LS-Request, length 148
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 2.2.2.2
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 52) fe80::2 > fe80::1: AH(spi=0x00000100,sumlen=16,seq=0x15): OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x00000b93
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 532) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x1e): OSPFv3, LS-Update, length 508
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x8000000b, age 15s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 75s, length 12
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 874s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 74
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 874s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 84
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 874s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 74
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 1020s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 64
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8, metric 74
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7, metric 84
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6, metric 74
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 64
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 50s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::1, Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 75s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	      Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 50s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8:0:12::/64, metric 10
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 52) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x1f): OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00000b93
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 456) fe80::2 > fe80::1: AH(spi=0x00000100,sumlen=16,seq=0x16): OSPFv3, LS-Update, length 432
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x8000000a, age 40s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8, metric 74
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7, metric 84
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6, metric 74
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 64
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 866s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 74
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 866s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 84
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 866s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 74
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1021s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 64
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 34s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 34s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8:0:12::/64, metric 10
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 116) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x17): OSPFv3, LS-Update, length 92
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 2.2.2.2, seq 0x8000000b, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 116) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x20): OSPFv3, LS-Update, length 92
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x8000000c, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 300) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x18): OSPFv3, LS-Ack, length 276
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x8000000b, age 15s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 75s, length 12
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 874s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 874s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 874s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 1020s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 55s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 50s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 75s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 50s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 260) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x21): OSPFv3, LS-Ack, length 236
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x8000000a, age 40s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.8
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.7
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 866s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 866s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 866s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1021s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 34s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 34s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x22): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 116) fe80::2 > fe80::1: AH(spi=0x00000100,sumlen=16,seq=0x19): OSPFv3, LS-Update, length 92
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 2.2.2.2, seq 0x8000000b, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 264) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x1a): OSPFv3, LS-Update, length 240
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000004, age 1s, length 12
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 16777215
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 16777215
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000004, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	      Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 116) fe80::1 > fe80::2: AH(spi=0x00000100,sumlen=16,seq=0x23): OSPFv3, LS-Update, length 92
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x8000000c, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 84) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x1b): OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x8000000c, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 188) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x24): OSPFv3, LS-Update, length 164
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 16777215
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 16777215
+		2001:db8::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 200) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x25): OSPFv3, LS-Ack, length 176
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000b, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000004, age 1s, length 12
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000004, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 160) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x1c): OSPFv3, LS-Ack, length 136
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x8000000c, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x1d): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 84) fe80::2 > fe80::1: AH(spi=0x00000100,sumlen=16,seq=0x1e): OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x8000000c, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 60) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x26): OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x8000000c, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x27): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x1f): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x28): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x20): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x29): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x21): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x2a): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x22): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x2b): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x23): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x2c): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x24): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x2d): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x25): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x2e): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x26): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x2f): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x27): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x30): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x28): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x31): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::2 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x29): OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header AH (51) payload length: 64) fe80::1 > ff02::5: AH(spi=0x00000100,sumlen=16,seq=0x32): OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 2.2.2.2, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
diff --git a/tests/ospf3_auth-vv.out b/tests/ospf3_auth-vv.out
new file mode 100644
index 0000000..69b7c26
--- /dev/null
+++ b/tests/ospf3_auth-vv.out
@@ -0,0 +1,10 @@
+IP6 (class 0xc0, hlim 1, next-header OSPF (89) payload length: 88) fe80::20c:29ff:fe9e:c1b2 > ff02::5: OSPFv3, Hello, length 88
+	Router-ID 10.10.10.2, Backbone Area
+	Options [V6, External, Router, Authentication Trailer]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.2, Priority 1
+	  Designated Router 10.10.10.1, Backup Designated Router 10.10.10.2
+	  Neighbor List:
+	    10.10.10.1
+	Authentication Type HMAC, Length 48, SAID 1, CSN 0x00000000:52da4e0e
+	Authentication Data 0x0000:  ca4d 7d58 69a5 da3c 2a69 0eda a732 9bee
+	Authentication Data 0x0010:  9d7f 448c 9f31 fbe4 a0e9 b39c 6da6 cca1
diff --git a/tests/ospf3_auth.pcap b/tests/ospf3_auth.pcap
new file mode 100644
index 0000000..4b5bc81
--- /dev/null
+++ b/tests/ospf3_auth.pcap
Binary files differ
diff --git a/tests/ospf3_bc-vv.out b/tests/ospf3_bc-vv.out
new file mode 100644
index 0000000..3cc3f36
--- /dev/null
+++ b/tests/ospf3_bc-vv.out
@@ -0,0 +1,335 @@
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 1.1.1.1
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::1: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00001d46
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::2: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x0000242c
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 168) fe80::1 > fe80::2: OSPFv3, Database Description, length 168
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x00001d46
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 39s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 40s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 34s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 34s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 148) fe80::2 > fe80::1: OSPFv3, Database Description, length 148
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x00001d47
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 4s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 5s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 5s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 5s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 5s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 4s, length 24
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::2: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00001d47
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 100) fe80::2 > fe80::1: OSPFv3, LS-Request, length 100
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 1.1.1.1
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 88) fe80::1 > fe80::2: OSPFv3, LS-Request, length 88
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::1: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x00001d48
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 288) fe80::1 > fe80::2: OSPFv3, LS-Update, length 288
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 40s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 74
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 84
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 74
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0, metric 64
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 35s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::1, Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 35s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8:0:12::/64, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 232) fe80::2 > fe80::1: OSPFv3, LS-Update, length 232
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 5s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 74
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 84
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 74
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0, metric 64
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 5s, length 24
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::2: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00001d48
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::2 > ff02::5: OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 168) fe80::1 > ff02::5: OSPFv3, LS-Update, length 168
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1s, length 12
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		1.1.1.1
+		2.2.2.2
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	      Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 1.1.1.1, seq 0x80000003, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 76) fe80::2 > ff02::5: OSPFv3, LS-Update, length 76
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 1s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 136) fe80::1 > ff02::5: OSPFv3, LS-Ack, length 136
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 5s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 6s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 5s, length 24
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 196) fe80::2 > ff02::5: OSPFv3, LS-Ack, length 196
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 40s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 41s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 35s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 35s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1s, length 12
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.20.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 1.1.1.1, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::2 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::1 > fe80::2: OSPFv3, LS-Update, length 92
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 1.1.1.1, seq 0x80000003, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::1 > ff02::5: OSPFv3, LS-Update, length 60
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000004, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 76) fe80::2 > fe80::1: OSPFv3, LS-Update, length 76
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 5s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::1 > ff02::5: OSPFv3, LS-Ack, length 56
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000003, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 5s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.5
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::2 > ff02::5: OSPFv3, LS-Ack, length 56
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000003, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 1.1.1.1, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::1 > fe80::2: OSPFv3, LS-Update, length 60
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000004, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::2 > ff02::5: OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000004, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.5, Interface 0.0.0.5, metric 10
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > ff02::5: OSPFv3, LS-Ack, length 36
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	  Advertising Router 1.1.1.1, seq 0x80000004, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	  Advertising Router 2.2.2.2, seq 0x80000004, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 1.1.1.1, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 1.1.1.1, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 1.1.1.1, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Area 0.0.0.1
+	Options [V6, External, Router]
+	  Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+	  Designated Router 1.1.1.1, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
diff --git a/tests/ospf3_mp-vv.out b/tests/ospf3_mp-vv.out
new file mode 100644
index 0000000..ee1ef04
--- /dev/null
+++ b/tests/ospf3_mp-vv.out
@@ -0,0 +1,817 @@
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > ff02::5: OSPFv3, Hello, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::1: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00000bbd
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x000015b5
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 268) fe80::1 > fe80::3: OSPFv3, Database Description, length 268
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x00000bbd
+	  Advertising Router 1.1.1.1, seq 0x80000012, age 29s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 436s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x8000000a, age 445s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 476s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 30s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 810s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 605s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 605s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 595s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 29s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 29s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 476s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 228) fe80::3 > fe80::1: OSPFv3, Database Description, length 228
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x00000bbe
+	  Advertising Router 1.1.1.1, seq 0x8000000f, age 435s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 435s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x8000000d, age 32s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 811s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 809s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 32s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 32s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 32s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 32s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 32s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 124) fe80::3 > fe80::1: OSPFv3, LS-Request, length 124
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	  Advertising Router 1.1.1.1
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00000bbe
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 100) fe80::1 > fe80::3: OSPFv3, LS-Request, length 100
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::1: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x00000bbf
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 296) fe80::3 > fe80::1: OSPFv3, LS-Update, length 296
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000d, age 33s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 10
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 20
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 10
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 812s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 100, Link-local address fe80::3, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::3/128, Options [Local address], metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 376) fe80::1 > fe80::3: OSPFv3, LS-Update, length 376
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000012, age 30s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 477s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		3.3.3.3
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 596s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 20
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 606s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 10
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 606s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0, metric 10
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 31s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 30s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::1, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 477s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 30s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::1/128, Options [Local address], metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00000bbf
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000e, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::1 > fe80::3: OSPFv3, LS-Update, length 60
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000013, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::2: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00000d54
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 196) fe80::3 > fe80::2: OSPFv3, LS-Ack, length 196
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000012, age 30s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 477s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 596s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 606s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 606s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 31s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 30s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 477s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 30s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00000b59
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 268) fe80::2 > fe80::3: OSPFv3, Database Description, length 268
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x00000d54
+	  Advertising Router 1.1.1.1, seq 0x8000000f, age 439s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 29s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x8000000a, age 448s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 478s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 814s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 30s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 608s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 608s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 598s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 29s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 29s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 478s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 156) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 156
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000d, age 33s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 812s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 33s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 196) fe80::3 > fe80::1: OSPFv3, LS-Ack, length 196
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000012, age 30s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 477s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 596s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 606s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 606s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 31s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 30s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 477s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 30s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 368) fe80::3 > fe80::2: OSPFv3, Database Description, length 368
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x00000d55
+	  Advertising Router 1.1.1.1, seq 0x80000012, age 32s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 438s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x8000000e, age 2s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 479s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 814s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 33s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 811s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 608s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 608s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 598s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 35s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 35s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 35s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 34s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 32s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 34s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 479s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00000d55
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 136) fe80::2 > fe80::3: OSPFv3, LS-Request, length 136
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 3.3.3.3
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 64) fe80::3 > fe80::2: OSPFv3, LS-Request, length 64
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::2: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x00000d56
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 424) fe80::3 > fe80::2: OSPFv3, LS-Update, length 424
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000e, age 3s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	  Advertising Router 1.1.1.1, seq 0x80000012, age 33s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 36s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 10
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 36s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 20
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 36s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 10
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 812s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 34s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 35s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 100, Link-local address fe80::3, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 35s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::3/128, Options [Local address], metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 33s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::1/128, Options [Local address], metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 188) fe80::2 > fe80::3: OSPFv3, LS-Update, length 188
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 30s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 30s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 30s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::2/128, Options [Local address], metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00000d56
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 188) fe80::3 > fe80::2: OSPFv3, LS-Update, length 188
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 31s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 32s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::2/128, Options [Local address], metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 188) fe80::3 > fe80::1: OSPFv3, LS-Update, length 188
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 31s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 32s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::2/128, Options [Local address], metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 96) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 96
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 31s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 32s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::2 > fe80::3: OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000013, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 216) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 216
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000e, age 3s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000012, age 33s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 36s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 36s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 36s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 812s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 34s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 35s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 35s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 33s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 96) fe80::3 > fe80::2: OSPFv3, LS-Ack, length 96
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 30s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 30s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 30s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 96) fe80::3 > fe80::1: OSPFv3, LS-Ack, length 96
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 30s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 30s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 30s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 96) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 96
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000012, age 31s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 32s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.5
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 31s, length 32
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::1 > fe80::3: OSPFv3, LS-Update, length 60
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000013, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::2: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000013, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000013, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000e, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::1 > fe80::3: OSPFv3, LS-Update, length 56
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 300) fe80::3 > fe80::2: OSPFv3, LS-Update, length 300
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		3.3.3.3
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 16777215
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 16777215
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0, metric 16777215
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x8000000f, age 1s, length 36
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	      Neighbor Router-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 300) fe80::3 > fe80::1: OSPFv3, LS-Update, length 300
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		3.3.3.3
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 16777215
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 16777215
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0, metric 16777215
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x8000000f, age 1s, length 36
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	      Neighbor Router-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::2: OSPFv3, LS-Ack, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000013, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::1: OSPFv3, LS-Ack, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000013, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 176) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 176
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000013, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	  Advertising Router 3.3.3.3, seq 0x8000000f, age 1s, length 36
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 136) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 136
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000e, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::2 > fe80::3: OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000013, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::2: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000013, age 7s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000013, age 7s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::2 > fe80::3: OSPFv3, LS-Update, length 56
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::2: OSPFv3, LS-Update, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::1: OSPFv3, LS-Update, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::2: OSPFv3, LS-Ack, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000013, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::1: OSPFv3, LS-Ack, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000013, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 76) fe80::3 > fe80::1: OSPFv3, LS-Update, length 76
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000f, age 5s, length 36
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Router-ID 2.2.2.2
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	      Neighbor Router-ID 1.1.1.1
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 56
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000013, age 7s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000f, age 5s, length 36
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > ff02::5: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > ff02::5: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > ff02::5: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > ff02::5: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > ff02::5: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Neighbor List:
+	    3.3.3.3
diff --git a/tests/ospf3_nbma-vv.out b/tests/ospf3_nbma-vv.out
new file mode 100644
index 0000000..5b8eed9
--- /dev/null
+++ b/tests/ospf3_nbma-vv.out
@@ -0,0 +1,912 @@
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > fe80::2: OSPFv3, Hello, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > fe80::1: OSPFv3, Hello, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3
+	  Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > fe80::3: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Designated Router 1.1.1.1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::1: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x0000149b
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00001b67
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 308) fe80::1 > fe80::3: OSPFv3, Database Description, length 308
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x0000149b
+	  Advertising Router 1.1.1.1, seq 0x8000000d, age 209s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000a, age 517s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000006, age 1127s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1157s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 330s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 509s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1303s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1303s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1303s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 329s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 1307s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1303s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 329s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1157s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 148) fe80::3 > fe80::1: OSPFv3, Database Description, length 148
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x0000149c
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 14s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 124s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 124s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 114s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 134s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 134s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 160) fe80::3 > fe80::1: OSPFv3, LS-Request, length 160
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	  Advertising Router 1.1.1.1
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x0000149c
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 76) fe80::1 > fe80::3: OSPFv3, LS-Request, length 76
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::1: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x0000149d
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 228) fe80::3 > fe80::1: OSPFv3, LS-Update, length 228
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 115s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 20
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 125s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 10
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 125s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0, metric 10
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 135s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 100, Link-local address fe80::3, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 135s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::/64, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 504) fe80::1 > fe80::3: OSPFv3, LS-Update, length 504
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000006, age 1128s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	  Advertising Router 2.2.2.2, seq 0x8000000a, age 518s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	  Advertising Router 1.1.1.1, seq 0x8000000d, age 210s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1158s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		3.3.3.3
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1304s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1304s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 20
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 510s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 331s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 1308s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 330s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::1, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1158s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 330s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::/64, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x0000149d
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > fe80::1: OSPFv3, LS-Update, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000007, age 1s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::1 > fe80::3: OSPFv3, LS-Update, length 92
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 1.1.1.1, seq 0x8000000e, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 52) fe80::3 > fe80::1: OSPFv3, LS-Update, length 52
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > fe80::3: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Designated Router 2.2.2.2
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::2: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x0000027c
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00000cd9
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 308) fe80::2 > fe80::3: OSPFv3, Database Description, length 308
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x0000027c
+	  Advertising Router 1.1.1.1, seq 0x8000000a, age 556s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000d, age 209s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000006, age 1130s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1160s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 546s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 330s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1306s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1306s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1306s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 1310s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 329s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1305s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 329s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1160s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 348) fe80::3 > fe80::2: OSPFv3, Database Description, length 348
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x0000027d
+	  Advertising Router 1.1.1.1, seq 0x8000000d, age 212s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000a, age 520s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000007, age 2s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1160s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 333s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 512s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 127s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 127s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 117s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1306s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1306s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 332s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 1310s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 136s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 332s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 1160s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 76) fe80::3 > fe80::2: OSPFv3, LS-Request, length 76
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x0000027d
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 136) fe80::2 > fe80::3: OSPFv3, LS-Request, length 136
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 3.3.3.3
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 216) fe80::2 > fe80::3: OSPFv3, LS-Update, length 216
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x8000000d, age 210s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 547s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 330s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 330s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::/64, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::3 > fe80::2: OSPFv3, Database Description, length 28
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x0000027e
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 404) fe80::3 > fe80::2: OSPFv3, LS-Update, length 404
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000007, age 3s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 1.1.1.1, seq 0x8000000d, age 213s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 118s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2, metric 20
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 128s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1, metric 10
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 128s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0, metric 10
+		2001:db8:0:3::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 513s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 334s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 137s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 100, Link-local address fe80::3, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 333s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::1, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 333s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::/64, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::3: OSPFv3, Database Description, length 28
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x0000027e
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 136) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 136
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 115s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 125s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 125s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 135s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 135s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000007, age 1s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 216) fe80::3 > fe80::2: OSPFv3, LS-Update, length 216
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x8000000d, age 211s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 332s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 548s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::/64, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 216) fe80::3 > fe80::1: OSPFv3, LS-Update, length 216
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Priority 1, Link-local address fe80::2, Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x8000000d, age 211s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 332s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 548s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 10
+		2001:db8:0:12::/64, metric 0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 1:
+		2001:db8::/64, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 116) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 116
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x8000000d, age 211s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 332s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 548s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::2 > fe80::3: OSPFv3, LS-Update, length 92
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 2.2.2.2, seq 0x8000000e, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 216) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 216
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000007, age 3s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x8000000d, age 213s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 118s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.2
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 128s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.1
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 128s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 513s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 334s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000001, age 137s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 333s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 333s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 116) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 116
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 36
+	    Link LSA (8), Link Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 2.2.2.2, seq 0x8000000d, age 211s, length 4
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 332s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 1.1.1.1, seq 0x80000001, age 548s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000001, age 331s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::1 > fe80::3: OSPFv3, LS-Update, length 92
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 1.1.1.1, seq 0x8000000e, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::3 > fe80::2: OSPFv3, LS-Update, length 92
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 1.1.1.1, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::3 > fe80::1: OSPFv3, LS-Update, length 92
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 1.1.1.1, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 52) fe80::3 > fe80::1: OSPFv3, LS-Update, length 52
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 244) fe80::3 > fe80::2: OSPFv3, LS-Update, length 244
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		3.3.3.3
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000008, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 244) fe80::3 > fe80::1: OSPFv3, LS-Update, length 244
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Options [V6, External, Router, Demand Circuit]
+	      Connected Routers:
+		3.3.3.3
+		2.2.2.2
+		1.1.1.1
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4, metric 16777215
+		2001:db8:0:34::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:4::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	      Prefixes 1:
+		2001:db8::/64, metric 0
+	  Advertising Router 3.3.3.3, seq 0x80000008, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::1 > fe80::3: OSPFv3, LS-Update, length 56
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::2: OSPFv3, LS-Update, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::1: OSPFv3, LS-Update, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::2 > fe80::3: OSPFv3, LS-Update, length 92
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 2.2.2.2, seq 0x8000000e, age 5s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 176) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 176
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	  Advertising Router 3.3.3.3, seq 0x80000008, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::3 > fe80::2: OSPFv3, LS-Update, length 92
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 2.2.2.2, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 92) fe80::3 > fe80::1: OSPFv3, LS-Update, length 92
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+	  Advertising Router 2.2.2.2, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 236) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 236
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 16
+	    Network LSA (2), Area Local Scope, LSA-ID 0.0.0.6
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.4
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 3.3.3.3, seq 0x80000002, age 1s, length 24
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.24.0
+	  Advertising Router 3.3.3.3, seq 0x80000008, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 1.1.1.1, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::2 > fe80::3: OSPFv3, LS-Update, length 56
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::2: OSPFv3, LS-Update, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 56) fe80::3 > fe80::1: OSPFv3, LS-Update, length 56
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3, metric 16777215
+		2001:db8:0:12::/64, metric 0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 76) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 76
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x8000000e, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 52) fe80::3 > fe80::1: OSPFv3, LS-Update, length 52
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Prefixes 0:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000003, age 3600s, length 12
+	    Intra-Area Prefix LSA (9), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x80000002, age 3600s, length 16
+	    Inter-Area Prefix LSA (3), Area Local Scope, LSA-ID 0.0.0.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > fe80::2: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > fe80::1: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > fe80::3: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Designated Router 3.3.3.3, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::2: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000009, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000009, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > fe80::3: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Designated Router 3.3.3.3, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000009, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x80000009, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::2: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000a, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000a, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000a, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 3.3.3.3, seq 0x8000000a, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > fe80::2: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > fe80::1: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::2 > fe80::3: OSPFv3, LS-Update, length 60
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::1 > fe80::3: OSPFv3, LS-Update, length 60
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x8000000f, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::2: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x8000000f, age 2s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x8000000f, age 2s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > fe80::2: OSPFv3, LS-Ack, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::3 > fe80::1: OSPFv3, LS-Ack, length 36
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 1s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 2.2.2.2, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x8000000f, age 2s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 1.1.1.1, seq 0x8000000f, age 2s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 60) fe80::3 > fe80::1: OSPFv3, LS-Update, length 60
+	Router-ID 3.3.3.3, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+	      Options [V6, External, Router, Demand Circuit], RLA-Flags [ABR]
+	      Neighbor Network-ID 3.3.3.3
+	      Neighbor Interface-ID 0.0.0.6, Interface 0.0.0.6, metric 64
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > fe80::3: OSPFv3, LS-Ack, length 36
+	Router-ID 1.1.1.1, Backbone Area
+	  Advertising Router 2.2.2.2, seq 0x8000000f, age 6s, length 20
+	    Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > fe80::3: OSPFv3, Hello, length 40
+	Router-ID 1.1.1.1, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Designated Router 3.3.3.3, Backup Designated Router 1.1.1.1
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::2 > fe80::3: OSPFv3, Hello, length 40
+	Router-ID 2.2.2.2, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 1
+	  Designated Router 3.3.3.3, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    3.3.3.3
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > fe80::2: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 44) fe80::3 > fe80::1: OSPFv3, Hello, length 44
+	Router-ID 3.3.3.3, Backbone Area
+	Options [V6, External, Router]
+	  Hello Timer 30s, Dead Timer 120s, Interface-ID 0.0.0.6, Priority 100
+	  Designated Router 3.3.3.3, Backup Designated Router 2.2.2.2
+	  Neighbor List:
+	    2.2.2.2
+	    1.1.1.1
diff --git a/tests/pimv2_bootstrap-v.out b/tests/pimv2_bootstrap-v.out
new file mode 100644
index 0000000..1d56445
--- /dev/null
+++ b/tests/pimv2_bootstrap-v.out
@@ -0,0 +1,24 @@
+IP (tos 0xc0, ttl 1, id 477, offset 0, flags [none], proto PIM (103), length 66)
+    10.0.0.5 > 224.0.0.13: PIMv2, length 46
+	Bootstrap, cksum 0xe410 (correct) tag=4b0 hashmlen=0 BSRprio=0 BSR=1.1.1.1 (group0: 224.0.0.0/4 RPcnt=2 FRPcnt=2 RP0=2.2.2.2,holdtime=2m30s,prio=0 RP1=3.3.3.3,holdtime=2m30s,prio=0)
+IP (tos 0xc0, ttl 255, id 433, offset 0, flags [none], proto PIM (103), length 42)
+    10.0.0.6 > 1.1.1.1: PIMv2, length 22
+	Candidate RP Advertisement, cksum 0xee5e (correct) prefix-cnt=1 prio=0 holdtime=2m30s RP=3.3.3.3 Group0=224.0.0.0/4
+IP (tos 0xc0, ttl 1, id 520, offset 0, flags [none], proto PIM (103), length 66)
+    10.0.0.5 > 224.0.0.13: PIMv2, length 46
+	Bootstrap, cksum 0xdf74 (correct) tag=94c hashmlen=0 BSRprio=0 BSR=1.1.1.1 (group0: 224.0.0.0/4 RPcnt=2 FRPcnt=2 RP0=2.2.2.2,holdtime=2m30s,prio=0 RP1=3.3.3.3,holdtime=2m30s,prio=0)
+IP (tos 0xc0, ttl 255, id 471, offset 0, flags [none], proto PIM (103), length 42)
+    10.0.0.6 > 1.1.1.1: PIMv2, length 22
+	Candidate RP Advertisement, cksum 0xee5e (correct) prefix-cnt=1 prio=0 holdtime=2m30s RP=3.3.3.3 Group0=224.0.0.0/4
+IP (tos 0xc0, ttl 1, id 563, offset 0, flags [none], proto PIM (103), length 66)
+    10.0.0.5 > 224.0.0.13: PIMv2, length 46
+	Bootstrap, cksum 0xd555 (correct) tag=136b hashmlen=0 BSRprio=0 BSR=1.1.1.1 (group0: 224.0.0.0/4 RPcnt=2 FRPcnt=2 RP0=2.2.2.2,holdtime=2m30s,prio=0 RP1=3.3.3.3,holdtime=2m30s,prio=0)
+IP (tos 0xc0, ttl 255, id 508, offset 0, flags [none], proto PIM (103), length 42)
+    10.0.0.6 > 1.1.1.1: PIMv2, length 22
+	Candidate RP Advertisement, cksum 0xee5e (correct) prefix-cnt=1 prio=0 holdtime=2m30s RP=3.3.3.3 Group0=224.0.0.0/4
+IP (tos 0xc0, ttl 1, id 606, offset 0, flags [none], proto PIM (103), length 66)
+    10.0.0.5 > 224.0.0.13: PIMv2, length 46
+	Bootstrap, cksum 0xe3ab (correct) tag=515 hashmlen=0 BSRprio=0 BSR=1.1.1.1 (group0: 224.0.0.0/4 RPcnt=2 FRPcnt=2 RP0=2.2.2.2,holdtime=2m30s,prio=0 RP1=3.3.3.3,holdtime=2m30s,prio=0)
+IP (tos 0xc0, ttl 255, id 547, offset 0, flags [none], proto PIM (103), length 42)
+    10.0.0.6 > 1.1.1.1: PIMv2, length 22
+	Candidate RP Advertisement, cksum 0xee5e (correct) prefix-cnt=1 prio=0 holdtime=2m30s RP=3.3.3.3 Group0=224.0.0.0/4
diff --git a/tests/pimv2_dm-v.out b/tests/pimv2_dm-v.out
new file mode 100644
index 0000000..334120b
--- /dev/null
+++ b/tests/pimv2_dm-v.out
@@ -0,0 +1,238 @@
+IP (tos 0xc0, ttl 1, id 121, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 115, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0x0, ttl 31, id 4621, offset 0, flags [none], proto UDP (17), length 1498)
+    172.16.40.10.1064 > 239.123.123.123.5001: UDP, length 1470
+IP (tos 0xc0, ttl 1, id 122, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x8fd8 (correct), upstream-neighbor: 10.0.0.1
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 0, pruned sources: 1
+	      pruned source #1: 172.16.40.10
+IP (tos 0xc0, ttl 1, id 130, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 123, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 141, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 131, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 150, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 138, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 160, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 147, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 168, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 154, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 179, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 162, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 187, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 169, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0x0, ttl 31, id 4804, offset 0, flags [none], proto UDP (17), length 1498)
+    172.16.40.10.1064 > 239.123.123.123.5001: UDP, length 1470
+IP (tos 0x0, ttl 31, id 4805, offset 0, flags [none], proto UDP (17), length 1498)
+    172.16.40.10.1064 > 239.123.123.123.5001: UDP, length 1470
+IP (tos 0xc0, ttl 1, id 171, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x8fd8 (correct), upstream-neighbor: 10.0.0.1
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 0, pruned sources: 1
+	      pruned source #1: 172.16.40.10
+IP (tos 0xc0, ttl 1, id 198, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 178, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 206, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 185, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 217, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 194, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 225, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 201, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 236, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 209, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 245, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 216, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0x0, ttl 31, id 4988, offset 0, flags [none], proto UDP (17), length 1498)
+    172.16.40.10.1064 > 239.123.123.123.5001: UDP, length 1470
+IP (tos 0x0, ttl 31, id 4989, offset 0, flags [none], proto UDP (17), length 1498)
+    172.16.40.10.1064 > 239.123.123.123.5001: UDP, length 1470
+IP (tos 0xc0, ttl 1, id 218, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x8fd8 (correct), upstream-neighbor: 10.0.0.1
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 0, pruned sources: 1
+	      pruned source #1: 172.16.40.10
+IP (tos 0xc0, ttl 1, id 255, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb3eb (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76852f6
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 226, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x4fce (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd767b714
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
diff --git a/tests/pimv2_hellos-v.out b/tests/pimv2_hellos-v.out
new file mode 100644
index 0000000..535dd52
--- /dev/null
+++ b/tests/pimv2_hellos-v.out
@@ -0,0 +1,42 @@
+IP (tos 0xc0, ttl 1, id 895, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xaa6e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0x3f0ef4cd
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 1093, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x6083 (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0x3ef93ece
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 912, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xaa6e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0x3f0ef4cd
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 1112, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x6083 (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0x3ef93ece
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 927, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.2 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xaa6e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0x3f0ef4cd
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 1129, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.1 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x6083 (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0x3ef93ece
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
diff --git a/tests/pimv2_register-v.out b/tests/pimv2_register-v.out
new file mode 100644
index 0000000..54d4407
--- /dev/null
+++ b/tests/pimv2_register-v.out
@@ -0,0 +1,8 @@
+IP (tos 0x0, ttl 255, id 350, offset 0, flags [none], proto PIM (103), length 128)
+    192.168.0.6 > 192.168.1.254: PIMv2, length 108
+	Register, cksum 0xdeff (correct), Flags [ none ]
+	IP (tos 0x0, ttl 254, id 15, offset 0, flags [none], proto ICMP (1), length 100)
+    192.168.20.10 > 239.1.2.3: ICMP echo request, id 3, seq 0, length 80
+IP (tos 0xc0, ttl 255, id 642, offset 0, flags [none], proto PIM (103), length 38)
+    192.168.1.254 > 192.168.0.6: PIMv2, length 18
+	Register Stop, cksum 0x1628 (correct) group=239.1.2.3 source=192.168.20.10
diff --git a/tests/pimv2_sm-v.out b/tests/pimv2_sm-v.out
new file mode 100644
index 0000000..546316a
--- /dev/null
+++ b/tests/pimv2_sm-v.out
@@ -0,0 +1,300 @@
+IP (tos 0xc0, ttl 1, id 130, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 129, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 139, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 150, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 146, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 169, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 163, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 175, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 186, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 179, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 186, offset 0, flags [none], proto IGMP (2), length 44)
+    1.1.1.1 > 224.0.0.2: igmp pimv1 RP-reachable group 239.123.123.123 RP 1.1.1.1 hold 4m30s
+IP (tos 0xc0, ttl 1, id 205, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 197, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 213, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 224, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 214, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 230, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 243, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 250, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 240, offset 0, flags [none], proto IGMP (2), length 44)
+    1.1.1.1 > 224.0.0.2: igmp pimv1 RP-reachable group 239.123.123.123 RP 1.1.1.1 hold 4m30s
+IP (tos 0xc0, ttl 1, id 250, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 261, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 280, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 266, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 287, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 300, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 285, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 292, offset 0, flags [none], proto IGMP (2), length 44)
+    1.1.1.1 > 224.0.0.2: igmp pimv1 RP-reachable group 239.123.123.123 RP 1.1.1.1 hold 4m30s
+IP (tos 0xc0, ttl 1, id 316, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 301, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 326, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 337, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 319, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 353, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 335, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 362, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 346, offset 0, flags [none], proto IGMP (2), length 44)
+    1.1.1.1 > 224.0.0.2: igmp pimv1 RP-reachable group 239.123.123.123 RP 1.1.1.1 hold 4m30s
+IP (tos 0xc0, ttl 1, id 374, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 354, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 390, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 372, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 399, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 1, pruned sources: 0
+	      joined source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 412, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 388, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 420, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Join / Prune, cksum 0x5ae5 (correct), upstream-neighbor: 10.0.0.13
+	  1 group(s), holdtime: 3m30s
+	    group #1: 239.123.123.123, joined sources: 0, pruned sources: 1
+	      pruned source #1: 1.1.1.1(SWR)
+IP (tos 0xc0, ttl 1, id 431, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.14 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0x41fe (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd76fc4dc
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
+IP (tos 0xc0, ttl 1, id 404, offset 0, flags [none], proto PIM (103), length 54)
+    10.0.0.13 > 224.0.0.13: PIMv2, length 34
+	Hello, cksum 0xb52e (correct)
+	  Hold Time Option (1), length 2, Value: 1m45s
+	  Generation ID Option (20), length 4, Value: 0xd77051ab
+	  DR Priority Option (19), length 4, Value: 1
+	  State Refresh Capability Option (21), length 4, Value: v1
diff --git a/tests/print-A.out b/tests/print-A.out
index 9daff5a..d35b968 100644
--- a/tests/print-A.out
+++ b/tests/print-A.out
@@ -7,7 +7,7 @@
 IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [.], ack 1, win 8192, options [nop,nop,TS val 1306300950 ecr 1306300950], length 0
 E..4.j@.@.!X.........p.P7X..7z.... .7......
 M...M...
-IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202
+IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202: HTTP: GET / HTTP/1.1
 E....l@.@. ..........p.P7X..7z.... ........
 M...M...GET / HTTP/1.1
 Host: localhost
@@ -21,7 +21,7 @@
 IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [.], ack 203, win 8192, options [nop,nop,TS val 1306300952 ecr 1306300951], length 0
 E..4..@.@............P.p7z..7X.I.. .7......
 M...M...
-IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559
+IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559: HTTP: HTTP/1.1 200 OK
 E.....@.@..%.........P.p7z..7X.I.. ........
 M...M...HTTP/1.1 200 OK
 Date: Wed, 06 Jul 2005 03:57:35 GMT
diff --git a/tests/print-AA.out b/tests/print-AA.out
index a1bc485..d2ea084 100644
--- a/tests/print-AA.out
+++ b/tests/print-AA.out
@@ -7,7 +7,7 @@
 IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [.], ack 1, win 8192, options [nop,nop,TS val 1306300950 ecr 1306300950], length 0
 ..............E..4.j@.@.!X.........p.P7X..7z.... .7......
 M...M...
-IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202
+IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202: HTTP: GET / HTTP/1.1
 ..............E....l@.@. ..........p.P7X..7z.... ........
 M...M...GET / HTTP/1.1
 Host: localhost
@@ -21,7 +21,7 @@
 IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [.], ack 203, win 8192, options [nop,nop,TS val 1306300952 ecr 1306300951], length 0
 ..............E..4..@.@............P.p7z..7X.I.. .7......
 M...M...
-IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559
+IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559: HTTP: HTTP/1.1 200 OK
 ..............E.....@.@..%.........P.p7z..7X.I.. ........
 M...M...HTTP/1.1 200 OK
 Date: Wed, 06 Jul 2005 03:57:35 GMT
diff --git a/tests/print-capX.out b/tests/print-capX.out
index 22b9090..8a27a96 100644
--- a/tests/print-capX.out
+++ b/tests/print-capX.out
@@ -13,7 +13,7 @@
 	0x0010:  7f00 0001 da70 0050 3758 897f 377a 8df2  .....p.P7X..7z..
 	0x0020:  8010 2000 37d0 0000 0101 080a 4ddc 9216  ....7.......M...
 	0x0030:  4ddc 9216                                M...
-IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202
+IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202: HTTP: GET / HTTP/1.1
 	0x0000:  4500 00fe 1b6c 4000 4006 208c 7f00 0001  E....l@.@.......
 	0x0010:  7f00 0001 da70 0050 3758 897f 377a 8df2  .....p.P7X..7z..
 	0x0020:  8018 2000 fef2 0000 0101 080a 4ddc 9217  ............M...
@@ -35,7 +35,7 @@
 	0x0010:  7f00 0001 0050 da70 377a 8df2 3758 8a49  .....P.p7z..7X.I
 	0x0020:  8010 2000 3703 0000 0101 080a 4ddc 9218  ....7.......M...
 	0x0030:  4ddc 9217                                M...
-IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559
+IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559: HTTP: HTTP/1.1 200 OK
 	0x0000:  4500 15eb 1fe6 4000 4006 0725 7f00 0001  E.....@.@..%....
 	0x0010:  7f00 0001 0050 da70 377a 8df2 3758 8a49  .....P.p7z..7X.I
 	0x0020:  8018 2000 13e0 0000 0101 080a 4ddc 9219  ............M...
diff --git a/tests/print-capXX.out b/tests/print-capXX.out
index 524030c..8fc3095 100644
--- a/tests/print-capXX.out
+++ b/tests/print-capXX.out
@@ -16,7 +16,7 @@
 	0x0020:  0001 da70 0050 3758 897f 377a 8df2 8010  ...p.P7X..7z....
 	0x0030:  2000 37d0 0000 0101 080a 4ddc 9216 4ddc  ..7.......M...M.
 	0x0040:  9216                                     ..
-IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202
+IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202: HTTP: GET / HTTP/1.1
 	0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
 	0x0010:  00fe 1b6c 4000 4006 208c 7f00 0001 7f00  ...l@.@.........
 	0x0020:  0001 da70 0050 3758 897f 377a 8df2 8018  ...p.P7X..7z....
@@ -40,7 +40,7 @@
 	0x0020:  0001 0050 da70 377a 8df2 3758 8a49 8010  ...P.p7z..7X.I..
 	0x0030:  2000 3703 0000 0101 080a 4ddc 9218 4ddc  ..7.......M...M.
 	0x0040:  9217                                     ..
-IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559
+IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559: HTTP: HTTP/1.1 200 OK
 	0x0000:  0000 0000 0000 0000 0000 0000 0800 4500  ..............E.
 	0x0010:  15eb 1fe6 4000 4006 0725 7f00 0001 7f00  ....@.@..%......
 	0x0020:  0001 0050 da70 377a 8df2 3758 8a49 8018  ...P.p7z..7X.I..
diff --git a/tests/print-x.out b/tests/print-x.out
index 34e0544..f2a4e2c 100644
--- a/tests/print-x.out
+++ b/tests/print-x.out
@@ -13,7 +13,7 @@
 	0x0010:  7f00 0001 da70 0050 3758 897f 377a 8df2
 	0x0020:  8010 2000 37d0 0000 0101 080a 4ddc 9216
 	0x0030:  4ddc 9216
-IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202
+IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202: HTTP: GET / HTTP/1.1
 	0x0000:  4500 00fe 1b6c 4000 4006 208c 7f00 0001
 	0x0010:  7f00 0001 da70 0050 3758 897f 377a 8df2
 	0x0020:  8018 2000 fef2 0000 0101 080a 4ddc 9217
@@ -35,7 +35,7 @@
 	0x0010:  7f00 0001 0050 da70 377a 8df2 3758 8a49
 	0x0020:  8010 2000 3703 0000 0101 080a 4ddc 9218
 	0x0030:  4ddc 9217
-IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559
+IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559: HTTP: HTTP/1.1 200 OK
 	0x0000:  4500 15eb 1fe6 4000 4006 0725 7f00 0001
 	0x0010:  7f00 0001 0050 da70 377a 8df2 3758 8a49
 	0x0020:  8018 2000 13e0 0000 0101 080a 4ddc 9219
diff --git a/tests/print-xx.out b/tests/print-xx.out
index 2d5b241..542fdc3 100644
--- a/tests/print-xx.out
+++ b/tests/print-xx.out
@@ -16,7 +16,7 @@
 	0x0020:  0001 da70 0050 3758 897f 377a 8df2 8010
 	0x0030:  2000 37d0 0000 0101 080a 4ddc 9216 4ddc
 	0x0040:  9216
-IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202
+IP 127.0.0.1.55920 > 127.0.0.1.80: Flags [P.], seq 1:203, ack 1, win 8192, options [nop,nop,TS val 1306300951 ecr 1306300950], length 202: HTTP: GET / HTTP/1.1
 	0x0000:  0000 0000 0000 0000 0000 0000 0800 4500
 	0x0010:  00fe 1b6c 4000 4006 208c 7f00 0001 7f00
 	0x0020:  0001 da70 0050 3758 897f 377a 8df2 8018
@@ -40,7 +40,7 @@
 	0x0020:  0001 0050 da70 377a 8df2 3758 8a49 8010
 	0x0030:  2000 3703 0000 0101 080a 4ddc 9218 4ddc
 	0x0040:  9217
-IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559
+IP 127.0.0.1.80 > 127.0.0.1.55920: Flags [P.], seq 1:5560, ack 203, win 8192, options [nop,nop,TS val 1306300953 ecr 1306300951], length 5559: HTTP: HTTP/1.1 200 OK
 	0x0000:  0000 0000 0000 0000 0000 0000 0800 4500
 	0x0010:  15eb 1fe6 4000 4006 0725 7f00 0001 7f00
 	0x0020:  0001 0050 da70 377a 8df2 3758 8a49 8018
diff --git a/tests/radius-rfc4675-v.out b/tests/radius-rfc4675-v.out
new file mode 100644
index 0000000..ff0e96f
--- /dev/null
+++ b/tests/radius-rfc4675-v.out
@@ -0,0 +1,43 @@
+IP (tos 0x0, ttl 64, id 20820, offset 0, flags [none], proto UDP (17), length 108)
+    127.0.0.1.53334 > 127.0.0.1.1812: RADIUS, length: 80
+	Access-Request (1), id: 0x46, Authenticator: f44757bc498c3393763a27d0b2393702
+	  User-Name Attribute (1), length: 12, Value: bob-tagged
+	  User-Password Attribute (2), length: 18, Value: 
+	  NAS-IP-Address Attribute (4), length: 6, Value: 127.0.0.1
+	  NAS-Port Attribute (5), length: 6, Value: 1
+	  Message-Authenticator Attribute (80), length: 18, Value: .....b..7-...b.
+IP (tos 0x0, ttl 64, id 20821, offset 0, flags [none], proto UDP (17), length 81)
+    127.0.0.1.1812 > 127.0.0.1.53334: RADIUS, length: 53
+	Access-Accept (2), id: 0x46, Authenticator: 766a0314eaf4b95f1ec271ae19cb3bdc
+	  Egress-VLANID Attribute (56), length: 6, Value: Tagged (0x31) 123
+	  Ingress-Filters Attribute (57), length: 6, Value: Enabled
+	  Egress-VLAN-Name Attribute (58), length: 11, Value: Tagged (0x31) vlanname
+	  User-Priority-Table Attribute (59), length: 10, Value: 
+IP (tos 0x0, ttl 64, id 21127, offset 0, flags [none], proto UDP (17), length 110)
+    127.0.0.1.46281 > 127.0.0.1.1812: RADIUS, length: 82
+	Access-Request (1), id: 0xb5, Authenticator: 11851d8b1b483f54a864b703ea21f4dc
+	  User-Name Attribute (1), length: 14, Value: bob-untagged
+	  User-Password Attribute (2), length: 18, Value: 
+	  NAS-IP-Address Attribute (4), length: 6, Value: 127.0.0.1
+	  NAS-Port Attribute (5), length: 6, Value: 1
+	  Message-Authenticator Attribute (80), length: 18, Value: ..o..}f..d.;..R[
+IP (tos 0x0, ttl 64, id 21128, offset 0, flags [none], proto UDP (17), length 71)
+    127.0.0.1.1812 > 127.0.0.1.46281: RADIUS, length: 43
+	Access-Accept (2), id: 0xb5, Authenticator: e223a663823b20ccc18bcf90c3ecbe27
+	  Egress-VLANID Attribute (56), length: 6, Value: Untagged (0x32) 123
+	  Ingress-Filters Attribute (57), length: 6, Value: Disabled
+	  Egress-VLAN-Name Attribute (58), length: 11, Value: Untagged (0x32) vlanname
+IP (tos 0x0, ttl 64, id 21190, offset 0, flags [none], proto UDP (17), length 109)
+    127.0.0.1.39300 > 127.0.0.1.1812: RADIUS, length: 81
+	Access-Request (1), id: 0x5a, Authenticator: 8dd685f50f837e8ad29e9cc095261172
+	  User-Name Attribute (1), length: 13, Value: bob-invalid
+	  User-Password Attribute (2), length: 18, Value: 
+	  NAS-IP-Address Attribute (4), length: 6, Value: 127.0.0.1
+	  NAS-Port Attribute (5), length: 6, Value: 1
+	  Message-Authenticator Attribute (80), length: 18, Value: ....(..^A.f.....
+IP (tos 0x0, ttl 64, id 21191, offset 0, flags [none], proto UDP (17), length 71)
+    127.0.0.1.1812 > 127.0.0.1.39300: RADIUS, length: 43
+	Access-Accept (2), id: 0x5a, Authenticator: fbaa7d05d009953514d00697da4d1dfc
+	  Egress-VLANID Attribute (56), length: 6, Value: Unknown tag (0x33) 123
+	  Ingress-Filters Attribute (57), length: 6, Value: #3
+	  Egress-VLAN-Name Attribute (58), length: 11, Value: Unknown tag (0x33) vlanname
diff --git a/tests/radius-rfc5176-v.out b/tests/radius-rfc5176-v.out
new file mode 100644
index 0000000..aa3210d
--- /dev/null
+++ b/tests/radius-rfc5176-v.out
@@ -0,0 +1,24 @@
+IP (tos 0x0, ttl 4, id 29161, offset 0, flags [none], proto UDP (17), length 66)
+    10.0.0.10.12345 > 10.0.0.1.3799: RADIUS, length: 38
+	Disconnect-Request (40), id: 0x01, Authenticator: e1792d2b4ab349f1a4c0fcc733d091c1
+	  Message-Authenticator Attribute (80), length: 18, Value: XQ=f(G..sJ0.....
+IP (tos 0x0, ttl 4, id 18682, offset 0, flags [none], proto UDP (17), length 66)
+    10.0.0.1.3799 > 10.0.0.10.12345: RADIUS, length: 38
+	Disconnect-ACK (41), id: 0x02, Authenticator: 3bc9c343f689990756b96c583a56890a
+	  Message-Authenticator Attribute (80), length: 18, Value: .O........iC,'}.
+IP (tos 0x0, ttl 4, id 22542, offset 0, flags [none], proto UDP (17), length 66)
+    10.0.0.1.3799 > 10.0.0.10.12345: RADIUS, length: 38
+	Disconnect-NAK (42), id: 0x03, Authenticator: d867c308c9c43112b3a669a0e8c0ab8c
+	  Message-Authenticator Attribute (80), length: 18, Value: ...p.I...(."....
+IP (tos 0x0, ttl 4, id 16413, offset 0, flags [none], proto UDP (17), length 66)
+    10.0.0.10.12345 > 10.0.0.1.3799: RADIUS, length: 38
+	CoA-Request (43), id: 0x04, Authenticator: 5f18309be67cd6150fe4c3a0b93536c9
+	  Message-Authenticator Attribute (80), length: 18, Value: '..6|.F..._...[.
+IP (tos 0x0, ttl 4, id 170, offset 0, flags [none], proto UDP (17), length 66)
+    10.0.0.1.3799 > 10.0.0.10.12345: RADIUS, length: 38
+	CoA-ACK (44), id: 0x05, Authenticator: 55ab6cb78aa161d692753fa9130c5019
+	  Message-Authenticator Attribute (80), length: 18, Value: .........+.x...s
+IP (tos 0x0, ttl 4, id 29645, offset 0, flags [none], proto UDP (17), length 66)
+    10.0.0.1.3799 > 10.0.0.10.12345: RADIUS, length: 38
+	CoA-NAK (45), id: 0x06, Authenticator: 40f21bdee27a87a5d757a30bfed62f28
+	  Message-Authenticator Attribute (80), length: 18, Value: .%y.....x...&j..
diff --git a/tests/radius-v.out b/tests/radius-v.out
new file mode 100644
index 0000000..6aae418
--- /dev/null
+++ b/tests/radius-v.out
@@ -0,0 +1,47 @@
+IP (tos 0x0, ttl 255, id 70, offset 0, flags [none], proto UDP (17), length 167)
+    10.0.0.1.1645 > 10.0.0.100.1812: RADIUS, length: 139
+	Access-Request (1), id: 0x05, Authenticator: ecfe3d2fe4473ec6299095ee46aedf77
+	  NAS-IP-Address Attribute (4), length: 6, Value: 10.0.0.1
+	  NAS-Port Attribute (5), length: 6, Value: 50012
+	  NAS-Port-Type Attribute (61), length: 6, Value: Ethernet
+	  User-Name Attribute (1), length: 14, Value: John.McGuirk
+	  Called-Station-Id Attribute (30), length: 19, Value: 00-19-06-EA-B8-8C
+	  Calling-Station-Id Attribute (31), length: 19, Value: 00-14-22-E9-54-5E
+	  Service-Type Attribute (6), length: 6, Value: Framed
+	  Framed-MTU Attribute (12), length: 6, Value: 1500
+	  EAP-Message Attribute (79), length: 19, Value: .
+	  Message-Authenticator Attribute (80), length: 18, Value: (....$..p.Q1o.x.
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 137)
+    10.0.0.100.1812 > 10.0.0.1.1645: RADIUS, length: 109
+	Access-Challenge (11), id: 0x05, Authenticator: f050649184625d36f14c9075b7a48b83
+	  Framed-IP-Address Attribute (8), length: 6, Value: NAS Select
+	  Framed-MTU Attribute (12), length: 6, Value: 576
+	  Service-Type Attribute (6), length: 6, Value: Framed
+	  Reply-Message Attribute (18), length: 11, Value: Hello, %u
+	  EAP-Message Attribute (79), length: 24, Value: ..
+	  Message-Authenticator Attribute (80), length: 18, Value: ...<.(.X.13..t4.
+	  State Attribute (24), length: 18, Value: ..../.0$.s..1..w
+IP (tos 0x0, ttl 255, id 71, offset 0, flags [none], proto UDP (17), length 202)
+    10.0.0.1.1645 > 10.0.0.100.1812: RADIUS, length: 174
+	Access-Request (1), id: 0x06, Authenticator: 6a6f38e6dae830304d2333e5d5364643
+	  NAS-IP-Address Attribute (4), length: 6, Value: 10.0.0.1
+	  NAS-Port Attribute (5), length: 6, Value: 50012
+	  NAS-Port-Type Attribute (61), length: 6, Value: Ethernet
+	  User-Name Attribute (1), length: 14, Value: John.McGuirk
+	  Called-Station-Id Attribute (30), length: 19, Value: 00-19-06-EA-B8-8C
+	  Calling-Station-Id Attribute (31), length: 19, Value: 00-14-22-E9-54-5E
+	  Service-Type Attribute (6), length: 6, Value: Framed
+	  Framed-MTU Attribute (12), length: 6, Value: 1500
+	  State Attribute (24), length: 18, Value: ..../.0$.s..1..w
+	  EAP-Message Attribute (79), length: 36, Value: ..
+	  Message-Authenticator Attribute (80), length: 18, Value: '&.q1.....Ojb..8
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 125)
+    10.0.0.100.1812 > 10.0.0.1.1645: RADIUS, length: 97
+	Access-Accept (2), id: 0x06, Authenticator: fbba6a784c7decb314caf0f27944a37b
+	  Framed-IP-Address Attribute (8), length: 6, Value: NAS Select
+	  Framed-MTU Attribute (12), length: 6, Value: 576
+	  Service-Type Attribute (6), length: 6, Value: Framed
+	  Reply-Message Attribute (18), length: 21, Value: Hello, John.McGuirk
+	  EAP-Message Attribute (79), length: 6, Value: ..
+	  Message-Authenticator Attribute (80), length: 18, Value: ...b...2.^..NLc`
+	  User-Name Attribute (1), length: 14, Value: John.McGuirk
diff --git a/tests/rpl-14-dao.pcap b/tests/rpl-14-dao.pcap
new file mode 100644
index 0000000..9a164e4
--- /dev/null
+++ b/tests/rpl-14-dao.pcap
Binary files differ
diff --git a/tests/rpl-14-daovvv.out b/tests/rpl-14-daovvv.out
new file mode 100644
index 0000000..7869e6b
--- /dev/null
+++ b/tests/rpl-14-daovvv.out
@@ -0,0 +1 @@
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:pandora is fun0x0al,seq:1,instance:1,Dagid,40]
diff --git a/tests/rpl-19-pickdag.out b/tests/rpl-19-pickdag.out
new file mode 100644
index 0000000..2460ada
--- /dev/null
+++ b/tests/rpl-19-pickdag.out
@@ -0,0 +1 @@
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x000x000x000x000x000x000x000x000x000x000x000x000x000x00,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
diff --git a/tests/rpl-19-pickdag.pcap b/tests/rpl-19-pickdag.pcap
new file mode 100644
index 0000000..3eca6c9
--- /dev/null
+++ b/tests/rpl-19-pickdag.pcap
Binary files differ
diff --git a/tests/rpl-19-pickdagvvv.out b/tests/rpl-19-pickdagvvv.out
new file mode 100644
index 0000000..bd93453
--- /dev/null
+++ b/tests/rpl-19-pickdagvvv.out
@@ -0,0 +1 @@
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x000x000x000x000x000x000x000x000x000x000x000x000x000x00,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  0x0000:  0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010:  3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
diff --git a/tests/rpl-26-senddaoack.pcap b/tests/rpl-26-senddaoack.pcap
new file mode 100644
index 0000000..fd397a4
--- /dev/null
+++ b/tests/rpl-26-senddaoack.pcap
Binary files differ
diff --git a/tests/rpl-26-senddaovv.out b/tests/rpl-26-senddaovv.out
new file mode 100644
index 0000000..6d11c81
--- /dev/null
+++ b/tests/rpl-26-senddaovv.out
@@ -0,0 +1 @@
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object Ack [dagid:thisismydicedag2,seq:11,instance:43,status:0]
diff --git a/tests/rpvst-v.out b/tests/rpvst-v.out
new file mode 100644
index 0000000..c55c1eb
--- /dev/null
+++ b/tests/rpvst-v.out
@@ -0,0 +1,68 @@
+DTPv1, length 38
+	Domain TLV (0x0001) TLV, length 10, cisco
+	Status TLV (0x0002) TLV, length 5, 0x81
+	DTP type TLV (0x0003) TLV, length 5, 0xa5
+	Neighbor TLV (0x0004) TLV, length 10, 00:1f:6d:96:ec:04
+DTPv1, length 38
+	Domain TLV (0x0001) TLV, length 10, cisco
+	Status TLV (0x0002) TLV, length 5, 0x81
+	DTP type TLV (0x0003) TLV, length 5, 0xa5
+	Neighbor TLV (0x0004) TLV, length 10, 00:1f:6d:96:ec:04
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8005.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8005.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8005.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8005.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8005.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8005.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+VTPv1, Message Summary advertisement (0x01), length 77
+	Domain name: cisco, Followers: 0
+	  Config Rev 2, Updater 155.1.37.7, Timestamp 0x39333033 0x30313030 0x30393030, MD5 digest: fb393cf67014e50aa79c7c5b193f6fe1
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8005.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8005.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8005.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8005.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:1f:6d:96:ec:00.8004, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8005.00:1f:6d:96:ec:00.8004, length 42
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8005.00:1f:6d:96:ec:00, root-pathcost 0, port-role Designated
+Loopback, skipCount 0, Reply, receipt number 0, data (40 octets)
diff --git a/tests/rpvstp-trunk-native-vid5.pcap b/tests/rpvstp-trunk-native-vid5.pcap
new file mode 100644
index 0000000..4c9908b
--- /dev/null
+++ b/tests/rpvstp-trunk-native-vid5.pcap
Binary files differ
diff --git a/tests/rstp-v.out b/tests/rstp-v.out
new file mode 100644
index 0000000..318b450
--- /dev/null
+++ b/tests/rstp-v.out
@@ -0,0 +1,90 @@
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal, Learn], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal, Learn], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal, Learn], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal, Learn], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal, Learn], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal, Learn], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Proposal, Learn], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Topology change, Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Topology change, Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Topology change, Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
+STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8001.00:19:06:ea:b8:80.800c, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0, port-role Designated
diff --git a/tests/rsvp_infloop-v.out b/tests/rsvp_infloop-v.out
new file mode 100644
index 0000000..9084e15
--- /dev/null
+++ b/tests/rsvp_infloop-v.out
@@ -0,0 +1,35 @@
+IP (tos 0x0, ttl 128, id 0, offset 0, flags [DF], proto RSVP (46), length 40)
+    208.208.77.43 > 192.168.1.1: 
+	RSVPv1 Hello Message (20), Flags: [none], length: 20, ttl: 64, checksum: 0x98ce
+	  ERO Object (20) Flags: [reject if unknown], Class-Type: IPv4 (1), length: 8
+	    Subobject Type: Label, length 0
+	    ERROR: zero length ERO subtype
+	  ERROR: object header too short 0 < 4
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto RSVP (46), length 40)
+    199.106.167.61 > 192.168.1.1: 
+	RSVPv1 Hello Message (20), Flags: [none], length: 20, ttl: 64, checksum: 0x98ce
+	  ERO Object (20) Flags: [reject if unknown], Class-Type: IPv4 (1), length: 8
+	    Subobject Type: Label, length 0
+	    ERROR: zero length ERO subtype
+	  ERROR: object header too short 0 < 4
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto RSVP (46), length 40)
+    179.9.22.16 > 192.168.1.1: 
+	RSVPv1 Hello Message (20), Flags: [none], length: 20, ttl: 128, checksum: 0x58ce
+	  ERO Object (20) Flags: [reject if unknown], Class-Type: IPv4 (1), length: 8
+	    Subobject Type: Label, length 0
+	    ERROR: zero length ERO subtype
+	  ERROR: object header too short 0 < 4
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto RSVP (46), length 40)
+    99.107.153.33 > 192.168.1.1: 
+	RSVPv1 Hello Message (20), Flags: [none], length: 20, ttl: 128, checksum: 0x58ce
+	  ERO Object (20) Flags: [reject if unknown], Class-Type: IPv4 (1), length: 8
+	    Subobject Type: Label, length 0
+	    ERROR: zero length ERO subtype
+	  ERROR: object header too short 0 < 4
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto RSVP (46), length 40)
+    188.46.23.116 > 192.168.1.1: 
+	RSVPv1 Hello Message (20), Flags: [none], length: 20, ttl: 128, checksum: 0x58ce
+	  ERO Object (20) Flags: [reject if unknown], Class-Type: IPv4 (1), length: 8
+	    Subobject Type: Label, length 0
+	    ERROR: zero length ERO subtype
+	  ERROR: object header too short 0 < 4
diff --git a/tests/stp-v.out b/tests/stp-v.out
new file mode 100644
index 0000000..66d3081
--- /dev/null
+++ b/tests/stp-v.out
@@ -0,0 +1,42 @@
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
+STP 802.1d, Config, Flags [none], bridge-id 8001.00:19:06:ea:b8:80.8005, length 43
+	message-age 0.00s, max-age 20.00s, hello-time 2.00s, forwarding-delay 15.00s
+	root-id 8001.00:19:06:ea:b8:80, root-pathcost 0
diff --git a/tests/udld-v.out b/tests/udld-v.out
new file mode 100644
index 0000000..cb55b8a
--- /dev/null
+++ b/tests/udld-v.out
@@ -0,0 +1,261 @@
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x03), length 60
+	Checksum 0x6d85 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 4, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 1
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805d (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 1
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805e (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 1
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805c (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 2
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805d (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 2
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805b (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 3
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805c (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 3
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805a (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 4
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805b (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 4
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x8059 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 5
+UDLDv1, Code Echo message (2), Flags [RT] (0x00), length 80
+	Checksum 0x805a (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 7s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 5
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x795c (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 1
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x795d (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 1
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x795b (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 2
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x795c (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 2
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x795a (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 3
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x795b (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 3
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7959 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 4
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x795a (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 4
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7958 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 5
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7959 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 5
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7957 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 6
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7958 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 6
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7956 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 7
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7957 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 7
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7955 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 8
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7956 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 8
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7954 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1025X4W3
+	Port-ID TLV (0x0002) TLV, length 5, Fa0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S2
+	Sequence Number TLV (0x0007) TLV, length 4, 9
+UDLDv1, Code Probe message (1), Flags [RT, RSY] (0x01), length 80
+	Checksum 0x7955 (unverified)
+	Device-ID TLV (0x0001) TLV, length 11, FOC1031Z7JG
+	Port-ID TLV (0x0002) TLV, length 5, Gi0/1
+	Echo TLV (0x0003) TLV, length 24, 
+	Message Interval TLV (0x0004) TLV, length 1, 15s
+	Timeout Interval TLV (0x0005) TLV, length 1, 5s
+	Device Name TLV (0x0006) TLV, length 2, S1
+	Sequence Number TLV (0x0007) TLV, length 4, 9
diff --git a/tests/vrrp-v.out b/tests/vrrp-v.out
new file mode 100644
index 0000000..47b3c7d
--- /dev/null
+++ b/tests/vrrp-v.out
@@ -0,0 +1,266 @@
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 191, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 191, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 191, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 191, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 191, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 191, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 191, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 191, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 88
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.91 > 224.0.0.18: vrrp 10.0.0.91 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 191, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 192, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 192, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 192, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 192, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 192, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 192, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 88
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 192, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 192, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.92 > 224.0.0.18: vrrp 10.0.0.92 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 192, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 88
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.93 > 224.0.0.18: vrrp 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.94 > 224.0.0.18: vrrp 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.95 > 224.0.0.18: vrrp 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.96 > 224.0.0.18: vrrp 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP6 (hlim 255, next-header VRRP (112) payload length: 40) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 36)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16, addrs(2): 10.4.44.100,10.4.44.200
+IP6 (hlim 255, next-header VRRP (112) payload length: 88) fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 48)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28, addrs(3): 10.4.42.1,10.4.42.2,10.4.42.3 auth "abcdefgh"
+IP (tos 0x0, ttl 255, id 4660, offset 0, flags [none], proto VRRP (112), length 40)
+    10.0.0.97 > 224.0.0.18: vrrp 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20, addrs: 10.4.43.150
diff --git a/tests/vrrp.out b/tests/vrrp.out
new file mode 100644
index 0000000..c9b1664
--- /dev/null
+++ b/tests/vrrp.out
@@ -0,0 +1,165 @@
+IP 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 191, authtype simple, intvl 10s, length 28
+IP 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 191, authtype none, intvl 10s, length 20
+IP 10.0.0.91 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 191, intvl 1000cs, length 16
+IP 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 191, authtype simple, intvl 10s, length 28
+IP 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 191, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 88
+IP 10.0.0.91 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 191, intvl 1000cs, length 16
+IP 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 191, authtype simple, intvl 10s, length 28
+IP 10.0.0.91 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 191, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 88
+IP6 fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 40
+IP 10.0.0.91 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 191, intvl 1000cs, length 16
+IP 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 192, authtype simple, intvl 10s, length 28
+IP 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 192, authtype none, intvl 10s, length 20
+IP 10.0.0.92 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 192, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe66:cf60 > ff02::12: ip-proto-112 88
+IP 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 192, authtype simple, intvl 10s, length 28
+IP 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 192, authtype none, intvl 10s, length 20
+IP 10.0.0.92 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 192, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 88
+IP6 fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 40
+IP 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 192, authtype simple, intvl 10s, length 28
+IP 10.0.0.92 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 192, authtype none, intvl 10s, length 20
+IP 10.0.0.92 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 192, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 88
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20
+IP 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 88
+IP6 fe80::d6ca:6dff:fe72:b1da > ff02::12: ip-proto-112 40
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 193, authtype none, intvl 10s, length 20
+IP 10.0.0.93 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 193, authtype simple, intvl 10s, length 28
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP 10.0.0.93 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 193, intvl 1000cs, length 16
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20
+IP 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 88
+IP6 fe80::d6ca:6dff:fe66:cf65 > ff02::12: ip-proto-112 40
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20
+IP 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 194, authtype simple, intvl 10s, length 28
+IP 10.0.0.94 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 194, authtype none, intvl 10s, length 20
+IP 10.0.0.94 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 194, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20
+IP 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe65:d45c > ff02::12: ip-proto-112 88
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20
+IP 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 195, authtype simple, intvl 10s, length 28
+IP 10.0.0.95 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 195, authtype none, intvl 10s, length 20
+IP 10.0.0.95 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 195, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20
+IP 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe65:d46b > ff02::12: ip-proto-112 88
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 196, authtype simple, intvl 10s, length 28
+IP 10.0.0.96 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 196, authtype none, intvl 10s, length 20
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP 10.0.0.96 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 196, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 40
+IP6 fe80::d6ca:6dff:fe72:b1e4 > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 40
+IP 10.0.0.97 > 224.0.0.18: VRRPv3, Advertisement, vrid 44, prio 197, intvl 1000cs, length 16
+IP6 fe80::20c:42ff:fe5e:c2dc > ff02::12: ip-proto-112 88
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 42, prio 197, authtype simple, intvl 10s, length 28
+IP 10.0.0.97 > 224.0.0.18: VRRPv2, Advertisement, vrid 43, prio 197, authtype none, intvl 10s, length 20
diff --git a/tests/vrrp.pcap b/tests/vrrp.pcap
new file mode 100644
index 0000000..8db1e20
--- /dev/null
+++ b/tests/vrrp.pcap
Binary files differ
diff --git a/tftp.h b/tftp.h
deleted file mode 100644
index 6a092e0..0000000
--- a/tftp.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tftp.h,v 1.2 2008-04-11 16:47:38 gianluca Exp $ (LBL) */
-/*
- * Copyright (c) 1983, 1993
- *	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 the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. 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 BY THE REGENTS 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 THE REGENTS 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.
- *
- *	@(#)tftp.h	8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _TFTP_H_
-#define	_TFTP_H_
-
-/*
- * Trivial File Transfer Protocol (IEN-133)
- */
-#define	SEGSIZE		512		/* data segment size */
-
-/*
- * Packet types.
- */
-#define	RRQ	01			/* read request */
-#define	WRQ	02			/* write request */
-#define	DATA	03			/* data packet */
-#define	ACK	04			/* acknowledgement */
-#define	TFTP_ERROR	05			/* error code */
-#define OACK	06			/* option acknowledgement */
-
-struct	tftphdr {
-	unsigned short	th_opcode;		/* packet type */
-	union {
-		unsigned short	tu_block;	/* block # */
-		unsigned short	tu_code;	/* error code */
-		char	tu_stuff[1];	/* request packet stuff */
-	} th_u;
-	char	th_data[1];		/* data or error string */
-};
-
-#define	th_block	th_u.tu_block
-#define	th_code		th_u.tu_code
-#define	th_stuff	th_u.tu_stuff
-#define	th_msg		th_data
-
-/*
- * Error codes.
- */
-#define	EUNDEF		0		/* not defined */
-#define	ENOTFOUND	1		/* file not found */
-#define	EACCESS		2		/* access violation */
-#define	ENOSPACE	3		/* disk full or allocation exceeded */
-#define	EBADOP		4		/* illegal TFTP operation */
-#define	EBADID		5		/* unknown transfer ID */
-#define	EEXISTS		6		/* file already exists */
-#define	ENOUSER		7		/* no such user */
-
-#endif /* !_TFTP_H_ */
diff --git a/timed.h b/timed.h
deleted file mode 100644
index f8d5a11..0000000
--- a/timed.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.6 2008-02-05 19:46:19 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1983, 1993
- *	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 the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. 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 BY THE REGENTS 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 THE REGENTS 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.
- *
- *	@(#)timed.h	8.1 (Berkeley) 6/2/93
- */
-
-#ifndef	_PROTOCOLS_TIMED_H_
-#define	_PROTOCOLS_TIMED_H_
-
-/*
- * Time Synchronization Protocol
- */
-
-#define	TSPVERSION	1
-#define ANYADDR 	NULL
-
-struct tsp_timeval {
-	u_int32_t	tv_sec;
-	u_int32_t	tv_usec;
-};
-
-struct tsp {
-	u_int8_t	tsp_type;
-	u_int8_t	tsp_vers;
-	u_int16_t	tsp_seq;
-	union {
-		struct tsp_timeval tspu_time;
-		int8_t tspu_hopcnt;
-	} tsp_u;
-	int8_t tsp_name[256];
-};
-
-#define	tsp_time	tsp_u.tspu_time
-#define	tsp_hopcnt	tsp_u.tspu_hopcnt
-
-/*
- * Command types.
- */
-#define	TSP_ANY			0	/* match any types */
-#define	TSP_ADJTIME		1	/* send adjtime */
-#define	TSP_ACK			2	/* generic acknowledgement */
-#define	TSP_MASTERREQ		3	/* ask for master's name */
-#define	TSP_MASTERACK		4	/* acknowledge master request */
-#define	TSP_SETTIME		5	/* send network time */
-#define	TSP_MASTERUP		6	/* inform slaves that master is up */
-#define	TSP_SLAVEUP		7	/* slave is up but not polled */
-#define	TSP_ELECTION		8	/* advance candidature for master */
-#define	TSP_ACCEPT		9	/* support candidature of master */
-#define	TSP_REFUSE		10	/* reject candidature of master */
-#define	TSP_CONFLICT		11	/* two or more masters present */
-#define	TSP_RESOLVE		12	/* masters' conflict resolution */
-#define	TSP_QUIT		13	/* reject candidature if master is up */
-#define	TSP_DATE		14	/* reset the time (date command) */
-#define	TSP_DATEREQ		15	/* remote request to reset the time */
-#define	TSP_DATEACK		16	/* acknowledge time setting  */
-#define	TSP_TRACEON		17	/* turn tracing on */
-#define	TSP_TRACEOFF		18	/* turn tracing off */
-#define	TSP_MSITE		19	/* find out master's site */
-#define	TSP_MSITEREQ		20	/* remote master's site request */
-#define	TSP_TEST		21	/* for testing election algo */
-#define	TSP_SETDATE		22	/* New from date command */
-#define	TSP_SETDATEREQ		23	/* New remote for above */
-#define	TSP_LOOP		24	/* loop detection packet */
-
-#define	TSPTYPENUMBER		25
-
-#endif /* !_TIMED_H_ */
diff --git a/token.h b/token.h
deleted file mode 100644
index 73a8271..0000000
--- a/token.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.6 2002-12-11 07:14:12 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1998, Larry Lile
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice unmodified, this list of conditions, and the following
- *    disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 THE AUTHOR 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.
- *
- */
-
-#define TOKEN_HDRLEN		14
-#define TOKEN_RING_MAC_LEN	6
-#define ROUTING_SEGMENT_MAX	16
-#define IS_SOURCE_ROUTED(trp)	((trp)->token_shost[0] & 0x80)
-#define FRAME_TYPE(trp)		(((trp)->token_fc & 0xC0) >> 6)
-#define TOKEN_FC_LLC		1
-
-#define BROADCAST(trp)		((EXTRACT_16BITS(&(trp)->token_rcf) & 0xE000) >> 13)
-#define RIF_LENGTH(trp)		((EXTRACT_16BITS(&(trp)->token_rcf) & 0x1f00) >> 8)
-#define DIRECTION(trp)		((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0080) >> 7)
-#define LARGEST_FRAME(trp)	((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0070) >> 4)
-#define RING_NUMBER(trp, x)	((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0xfff0) >> 4)
-#define BRIDGE_NUMBER(trp, x)	((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0x000f))
-#define SEGMENT_COUNT(trp)	((int)((RIF_LENGTH(trp) - 2) / 2))
-
-struct token_header {
-	u_int8_t  token_ac;
-	u_int8_t  token_fc;
-	u_int8_t  token_dhost[TOKEN_RING_MAC_LEN];
-	u_int8_t  token_shost[TOKEN_RING_MAC_LEN];
-	u_int16_t token_rcf;
-	u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
-};
diff --git a/udp.h b/udp.h
index d712dfc..743ddfa 100644
--- a/udp.h
+++ b/udp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.13 2007-08-08 17:20:58 hannes Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -39,12 +38,14 @@
  * Per RFC 768, September, 1981.
  */
 struct udphdr {
-	u_int16_t	uh_sport;		/* source port */
-	u_int16_t	uh_dport;		/* destination port */
-	u_int16_t	uh_ulen;		/* udp length */
-	u_int16_t	uh_sum;			/* udp checksum */
+	uint16_t	uh_sport;		/* source port */
+	uint16_t	uh_dport;		/* destination port */
+	uint16_t	uh_ulen;		/* udp length */
+	uint16_t	uh_sum;			/* udp checksum */
 };
 
+#define BOOTPS_PORT 67		/* RFC951 */
+#define BOOTPC_PORT 68		/* RFC951 */
 #define TFTP_PORT 69		/*XXX*/
 #define KERBEROS_PORT 88	/*XXX*/
 #define SUNRPC_PORT 111		/*XXX*/
@@ -73,6 +74,7 @@
 #define RADIUS_NEW_PORT 1812
 #define RADIUS_ACCOUNTING_PORT 1646
 #define RADIUS_NEW_ACCOUNTING_PORT 1813
+#define RADIUS_COA_PORT 3799
 #define HSRP_PORT 1985		/*XXX*/
 #define LMP_PORT                701 /* rfc4204 */
 #define LWRES_PORT		921
@@ -85,15 +87,17 @@
 #define BFD_ECHO_PORT           3785 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */
 #define WB_PORT			4567
 #define SFLOW_PORT              6343 /* http://www.sflow.org/developers/specifications.php */
-#define LWAPP_DATA_PORT         12222 /* draft-ohara-capwap-lwapp-04.txt */
-#define LWAPP_CONTROL_PORT      12223 /* draft-ohara-capwap-lwapp-04.txt */
+#define LWAPP_DATA_PORT         12222 /* RFC 5412 */
+#define LWAPP_CONTROL_PORT      12223 /* RFC 5412 */
 #define OTV_PORT                8472  /* draft-hasmit-otv-04 */
-#define VXLAN_PORT              4789  /* draft-mahalingam-dutt-dcops-vxlan-04 */
+#define VXLAN_PORT              4789  /* RFC 7348 */
+#define GENEVE_PORT             6081  /* draft-gross-geneve-02 */
 
 #ifdef INET6
-#define RIPNG_PORT 521		/*XXX*/
+#define RIPNG_PORT              521   /* RFC 2080 */
 #define DHCP6_SERV_PORT 546	/*XXX*/
 #define DHCP6_CLI_PORT 547	/*XXX*/
-#define BABEL_PORT 6696
-#define BABEL_PORT_OLD 6697
+#define AHCP_PORT 5359		/* draft-chroboczek-ahcp-00 */
+#define BABEL_PORT              6696  /* RFC 6126 errata */
+#define BABEL_PORT_OLD          6697  /* RFC 6126 */
 #endif
diff --git a/util.c b/util.c
index 2ea7636..b37f3d8 100644
--- a/util.c
+++ b/util.c
@@ -19,11 +19,23 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.109 2007-01-29 09:59:42 hannes Exp $ (LBL)";
-#endif
+/*
+ * txtproto_print() derived from original code by Hannes Gredler
+ * (hannes@juniper.net):
+ *
+ * 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, and (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.
+ * 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.
+ */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -32,11 +44,9 @@
 
 #include <sys/stat.h>
 
-#include <errno.h>
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#include <pcap.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -44,15 +54,14 @@
 
 #include "interface.h"
 
-char * ts_format(register int, register int);
-
 /*
  * Print out a null-terminated filename (or other ascii string).
  * If ep is NULL, assume no truncation check is needed.
  * Return true if truncated.
  */
 int
-fn_print(register const u_char *s, register const u_char *ep)
+fn_print(netdissect_options *ndo,
+         register const u_char *s, register const u_char *ep)
 {
 	register int ret;
 	register u_char c;
@@ -66,14 +75,13 @@
 		}
 		if (!ND_ISASCII(c)) {
 			c = ND_TOASCII(c);
-			putchar('M');
-			putchar('-');
+			ND_PRINT((ndo, "M-"));
 		}
 		if (!ND_ISPRINT(c)) {
 			c ^= 0x40;	/* DEL to ?, others to alpha */
-			putchar('^');
+			ND_PRINT((ndo, "^"));
 		}
-		putchar(c);
+		ND_PRINT((ndo, "%c", c));
 	}
 	return(ret);
 }
@@ -84,8 +92,8 @@
  * Return true if truncated.
  */
 int
-fn_printn(register const u_char *s, register u_int n,
-	  register const u_char *ep)
+fn_printn(netdissect_options *ndo,
+          register const u_char *s, register u_int n, register const u_char *ep)
 {
 	register u_char c;
 
@@ -94,14 +102,13 @@
 		c = *s++;
 		if (!ND_ISASCII(c)) {
 			c = ND_TOASCII(c);
-			putchar('M');
-			putchar('-');
+			ND_PRINT((ndo, "M-"));
 		}
 		if (!ND_ISPRINT(c)) {
 			c ^= 0x40;	/* DEL to ?, others to alpha */
-			putchar('^');
+			ND_PRINT((ndo, "^"));
 		}
-		putchar(c);
+		ND_PRINT((ndo, "%c", c));
 	}
 	return (n == 0) ? 0 : 1;
 }
@@ -112,8 +119,9 @@
  * Return true if truncated.
  */
 int
-fn_printzp(register const u_char *s, register u_int n,
-	  register const u_char *ep)
+fn_printzp(netdissect_options *ndo,
+           register const u_char *s, register u_int n,
+           register const u_char *ep)
 {
 	register int ret;
 	register u_char c;
@@ -128,14 +136,13 @@
 		}
 		if (!ND_ISASCII(c)) {
 			c = ND_TOASCII(c);
-			putchar('M');
-			putchar('-');
+			ND_PRINT((ndo, "M-"));
 		}
 		if (!ND_ISPRINT(c)) {
 			c ^= 0x40;	/* DEL to ?, others to alpha */
-			putchar('^');
+			ND_PRINT((ndo, "^"));
 		}
-		putchar(c);
+		ND_PRINT((ndo, "%c", c));
 	}
 	return (n == 0) ? 0 : ret;
 }
@@ -143,12 +150,37 @@
 /*
  * Format the timestamp
  */
-char *
-ts_format(register int sec, register int usec)
+static char *
+ts_format(netdissect_options *ndo
+#ifndef HAVE_PCAP_SET_TSTAMP_PRECISION
+_U_
+#endif
+, int sec, int usec)
 {
-        static char buf[sizeof("00:00:00.000000")];
-        (void)snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%06u",
-               sec / 3600, (sec % 3600) / 60, sec % 60, usec);
+	static char buf[sizeof("00:00:00.000000000")];
+	const char *format;
+
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+	switch (ndo->ndo_tstamp_precision) {
+
+	case PCAP_TSTAMP_PRECISION_MICRO:
+		format = "%02d:%02d:%02d.%06u";
+		break;
+
+	case PCAP_TSTAMP_PRECISION_NANO:
+		format = "%02d:%02d:%02d.%09u";
+		break;
+
+	default:
+		format = "%02d:%02d:%02d.{unknown precision}";
+		break;
+	}
+#else
+	format = "%02d:%02d:%02d.%06u";
+#endif
+
+	snprintf(buf, sizeof(buf), format,
+                 sec / 3600, (sec % 3600) / 60, sec % 60, usec);
 
         return buf;
 }
@@ -157,7 +189,8 @@
  * Print the timestamp
  */
 void
-ts_print(register const struct timeval *tvp)
+ts_print(netdissect_options *ndo,
+         register const struct timeval *tvp)
 {
 	register int s;
 	struct tm *tm;
@@ -167,20 +200,20 @@
 	int d_usec;
 	int d_sec;
 
-	switch (tflag) {
+	switch (ndo->ndo_tflag) {
 
 	case 0: /* Default */
 		s = (tvp->tv_sec + thiszone) % 86400;
-                (void)printf("%s ", ts_format(s, tvp->tv_usec));
+		ND_PRINT((ndo, "%s ", ts_format(ndo, s, tvp->tv_usec)));
 		break;
 
 	case 1: /* No time stamp */
 		break;
 
 	case 2: /* Unix timeval style */
-		(void)printf("%u.%06u ",
+		ND_PRINT((ndo, "%u.%06u ",
 			     (unsigned)tvp->tv_sec,
-			     (unsigned)tvp->tv_usec);
+			     (unsigned)tvp->tv_usec));
 		break;
 
 	case 3: /* Microseconds since previous packet */
@@ -188,20 +221,20 @@
 		if (b_sec == 0) {
                         /* init timestamp for first packet */
                         b_usec = tvp->tv_usec;
-                        b_sec = tvp->tv_sec;                        
+                        b_sec = tvp->tv_sec;
                 }
 
                 d_usec = tvp->tv_usec - b_usec;
                 d_sec = tvp->tv_sec - b_sec;
-                
+
                 while (d_usec < 0) {
                     d_usec += 1000000;
                     d_sec--;
                 }
 
-                (void)printf("%s ", ts_format(d_sec, d_usec));
+                ND_PRINT((ndo, "%s ", ts_format(ndo, d_sec, d_usec)));
 
-                if (tflag == 3) { /* set timestamp for last packet */
+                if (ndo->ndo_tflag == 3) { /* set timestamp for last packet */
                     b_sec = tvp->tv_sec;
                     b_usec = tvp->tv_usec;
                 }
@@ -212,11 +245,11 @@
 		Time = (tvp->tv_sec + thiszone) - s;
 		tm = gmtime (&Time);
 		if (!tm)
-			printf("Date fail  ");
+			ND_PRINT((ndo, "Date fail  "));
 		else
-			printf("%04d-%02d-%02d %s ",
+			ND_PRINT((ndo, "%04d-%02d-%02d %s ",
                                tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
-                               ts_format(s, tvp->tv_usec));
+                               ts_format(ndo, s, tvp->tv_usec)));
 		break;
 	}
 }
@@ -227,7 +260,8 @@
  * is represented as 1y1w1d1h1m1s.
  */
 void
-relts_print(int secs)
+relts_print(netdissect_options *ndo,
+            int secs)
 {
 	static const char *lengths[] = {"y", "w", "d", "h", "m", "s"};
 	static const int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
@@ -235,16 +269,16 @@
 	const int *s = seconds;
 
 	if (secs == 0) {
-		(void)printf("0s");
+		ND_PRINT((ndo, "0s"));
 		return;
 	}
 	if (secs < 0) {
-		(void)printf("-");
+		ND_PRINT((ndo, "-"));
 		secs = -secs;
 	}
 	while (secs > 0) {
 		if (secs >= *s) {
-			(void)printf("%d%s", secs / *s, *l);
+			ND_PRINT((ndo, "%d%s", secs / *s, *l));
 			secs -= (secs / *s) * *s;
 		}
 		s++;
@@ -259,21 +293,21 @@
  */
 
 int
-print_unknown_data(const u_char *cp,const char *ident,int len)
+print_unknown_data(netdissect_options *ndo, const u_char *cp,const char *ident,int len)
 {
 	if (len < 0) {
-		printf("%sDissector error: print_unknown_data called with negative length",
-		    ident);
+          ND_PRINT((ndo,"%sDissector error: print_unknown_data called with negative length",
+		    ident));
 		return(0);
 	}
-	if (snapend - cp < len)
-		len = snapend - cp;
+	if (ndo->ndo_snapend - cp < len)
+		len = ndo->ndo_snapend - cp;
 	if (len < 0) {
-		printf("%sDissector error: print_unknown_data called with pointer past end of packet",
-		    ident);
+          ND_PRINT((ndo,"%sDissector error: print_unknown_data called with pointer past end of packet",
+		    ident));
 		return(0);
 	}
-        hex_print(ident,cp,len);
+        hex_print(ndo, ident,cp,len);
 	return(1); /* everything is ok */
 }
 
@@ -282,7 +316,7 @@
  */
 const char *
 tok2strbuf(register const struct tok *lp, register const char *fmt,
-	   register int v, char *buf, size_t bufsize)
+	   register u_int v, char *buf, size_t bufsize)
 {
 	if (lp != NULL) {
 		while (lp->s != NULL) {
@@ -303,7 +337,7 @@
  */
 const char *
 tok2str(register const struct tok *lp, register const char *fmt,
-	register int v)
+	register u_int v)
 {
 	static char buf[4][128];
 	static int idx = 0;
@@ -321,12 +355,13 @@
  */
 static char *
 bittok2str_internal(register const struct tok *lp, register const char *fmt,
-	   register int v, register int sep)
+	   register u_int v, const char *sep)
 {
         static char buf[256]; /* our stringbuffer */
         int buflen=0;
-        register int rotbit; /* this is the bit we rotate through all bitpositions */
-        register int tokval;
+        register u_int rotbit; /* this is the bit we rotate through all bitpositions */
+        register u_int tokval;
+        const char * sepstr = "";
 
 	while (lp != NULL && lp->s != NULL) {
             tokval=lp->v;   /* load our first value */
@@ -339,7 +374,8 @@
 		if (tokval == (v&rotbit)) {
                     /* ok we have found something */
                     buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s%s",
-                                     lp->s, sep ? ", " : "");
+                                     sepstr, lp->s);
+                    sepstr = sep;
                     break;
                 }
                 rotbit=rotbit<<1; /* no match - lets shift and try again */
@@ -347,23 +383,10 @@
             lp++;
 	}
 
-        /* user didn't want string seperation - no need to cut off trailing seperators */
-        if (!sep) {
-            return (buf);
-        }
-
-        if (buflen != 0) { /* did we find anything */
-            /* yep, set the the trailing zero 2 bytes before to eliminate the last comma & whitespace */
-            buf[buflen-2] = '\0';
-            return (buf);
-        }
-        else {
+        if (buflen == 0)
             /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
-            if (fmt == NULL)
-		fmt = "#%d";
-            (void)snprintf(buf, sizeof(buf), fmt, v);
-            return (buf);
-        }
+            (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
+        return (buf);
 }
 
 /*
@@ -372,9 +395,9 @@
  */
 char *
 bittok2str_nosep(register const struct tok *lp, register const char *fmt,
-	   register int v)
+	   register u_int v)
 {
-    return (bittok2str_internal(lp, fmt, v, 0));
+    return (bittok2str_internal(lp, fmt, v, ""));
 }
 
 /*
@@ -383,9 +406,9 @@
  */
 char *
 bittok2str(register const struct tok *lp, register const char *fmt,
-	   register int v)
+	   register u_int v)
 {
-    return (bittok2str_internal(lp, fmt, v, 1));
+    return (bittok2str_internal(lp, fmt, v, ", "));
 }
 
 /*
@@ -415,9 +438,9 @@
  */
 
 int
-mask2plen(u_int32_t mask)
+mask2plen(uint32_t mask)
 {
-	u_int32_t bitmasks[33] = {
+	uint32_t bitmasks[33] = {
 		0x00000000,
 		0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
 		0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
@@ -468,6 +491,249 @@
 }
 #endif /* INET6 */
 
+/*
+ * Routine to print out information for text-based protocols such as FTP,
+ * HTTP, SMTP, RTSP, SIP, ....
+ */
+#define MAX_TOKEN	128
+
+/*
+ * Fetch a token from a packet, starting at the specified index,
+ * and return the length of the token.
+ *
+ * Returns 0 on error; yes, this is indistinguishable from an empty
+ * token, but an "empty token" isn't a valid token - it just means
+ * either a space character at the beginning of the line (this
+ * includes a blank line) or no more tokens remaining on the line.
+ */
+static int
+fetch_token(netdissect_options *ndo, const u_char *pptr, u_int idx, u_int len,
+    u_char *tbuf, size_t tbuflen)
+{
+	size_t toklen = 0;
+
+	for (; idx < len; idx++) {
+		if (!ND_TTEST(*(pptr + idx))) {
+			/* ran past end of captured data */
+			return (0);
+		}
+		if (!isascii(*(pptr + idx))) {
+			/* not an ASCII character */
+			return (0);
+		}
+		if (isspace(*(pptr + idx))) {
+			/* end of token */
+			break;
+		}
+		if (!isprint(*(pptr + idx))) {
+			/* not part of a command token or response code */
+			return (0);
+		}
+		if (toklen + 2 > tbuflen) {
+			/* no room for this character and terminating '\0' */
+			return (0);
+		}
+		tbuf[toklen] = *(pptr + idx);
+		toklen++;
+	}
+	if (toklen == 0) {
+		/* no token */
+		return (0);
+	}
+	tbuf[toklen] = '\0';
+
+	/*
+	 * Skip past any white space after the token, until we see
+	 * an end-of-line (CR or LF).
+	 */
+	for (; idx < len; idx++) {
+		if (!ND_TTEST(*(pptr + idx))) {
+			/* ran past end of captured data */
+			break;
+		}
+		if (*(pptr + idx) == '\r' || *(pptr + idx) == '\n') {
+			/* end of line */
+			break;
+		}
+		if (!isascii(*(pptr + idx)) || !isprint(*(pptr + idx))) {
+			/* not a printable ASCII character */
+			break;
+		}
+		if (!isspace(*(pptr + idx))) {
+			/* beginning of next token */
+			break;
+		}
+	}
+	return (idx);
+}
+
+/*
+ * Scan a buffer looking for a line ending - LF or CR-LF.
+ * Return the index of the character after the line ending or 0 if
+ * we encounter a non-ASCII or non-printable character or don't find
+ * the line ending.
+ */
+static u_int
+print_txt_line(netdissect_options *ndo, const char *protoname,
+    const char *prefix, const u_char *pptr, u_int idx, u_int len)
+{
+	u_int startidx;
+	u_int linelen;
+
+	startidx = idx;
+	while (idx < len) {
+		ND_TCHECK(*(pptr+idx));
+		if (*(pptr+idx) == '\n') {
+			/*
+			 * LF without CR; end of line.
+			 * Skip the LF and print the line, with the
+			 * exception of the LF.
+			 */
+			linelen = idx - startidx;
+			idx++;
+			goto print;
+		} else if (*(pptr+idx) == '\r') {
+			/* CR - any LF? */
+			if ((idx+1) >= len) {
+				/* not in this packet */
+				return (0);
+			}
+			ND_TCHECK(*(pptr+idx+1));
+			if (*(pptr+idx+1) == '\n') {
+				/*
+				 * CR-LF; end of line.
+				 * Skip the CR-LF and print the line, with
+				 * the exception of the CR-LF.
+				 */
+				linelen = idx - startidx;
+				idx += 2;
+				goto print;
+			}
+
+			/*
+			 * CR followed by something else; treat this
+			 * as if it were binary data, and don't print
+			 * it.
+			 */
+			return (0);
+		} else if (!isascii(*(pptr+idx)) ||
+		    (!isprint(*(pptr+idx)) && *(pptr+idx) != '\t')) {
+			/*
+			 * Not a printable ASCII character and not a tab;
+			 * treat this as if it were binary data, and
+			 * don't print it.
+			 */
+			return (0);
+		}
+		idx++;
+	}
+
+	/*
+	 * All printable ASCII, but no line ending after that point
+	 * in the buffer; treat this as if it were truncated.
+	 */
+trunc:
+	linelen = idx - startidx;
+	ND_PRINT((ndo, "%s%.*s[!%s]", prefix, (int)linelen, pptr + startidx,
+	    protoname));
+	return (0);
+
+print:
+	ND_PRINT((ndo, "%s%.*s", prefix, (int)linelen, pptr + startidx));
+	return (idx);
+}
+
+void
+txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
+    const char *protoname, const char **cmds, u_int flags)
+{
+	u_int idx, eol;
+	u_char token[MAX_TOKEN+1];
+	const char *cmd;
+	int is_reqresp = 0;
+	const char *pnp;
+
+	if (cmds != NULL) {
+		/*
+		 * This protocol has more than just request and
+		 * response lines; see whether this looks like a
+		 * request or response.
+		 */
+		idx = fetch_token(ndo, pptr, 0, len, token, sizeof(token));
+		if (idx != 0) {
+			/* Is this a valid request name? */
+			while ((cmd = *cmds++) != NULL) {
+				if (strcasecmp((const char *)token, cmd) == 0) {
+					/* Yes. */
+					is_reqresp = 1;
+					break;
+				}
+			}
+
+			/*
+			 * No - is this a valid response code (3 digits)?
+			 *
+			 * Is this token the response code, or is the next
+			 * token the response code?
+			 */
+			if (flags & RESP_CODE_SECOND_TOKEN) {
+				/*
+				 * Next token - get it.
+				 */
+				idx = fetch_token(ndo, pptr, idx, len, token,
+				    sizeof(token));
+			}
+			if (idx != 0) {
+				if (isdigit(token[0]) && isdigit(token[1]) &&
+				    isdigit(token[2]) && token[3] == '\0') {
+					/* Yes. */
+					is_reqresp = 1;
+				}
+			}
+		}
+	} else {
+		/*
+		 * This protocol has only request and response lines
+		 * (e.g., FTP, where all the data goes over a
+		 * different connection); assume the payload is
+		 * a request or response.
+		 */
+		is_reqresp = 1;
+	}
+
+	/* Capitalize the protocol name */
+	for (pnp = protoname; *pnp != '\0'; pnp++)
+		ND_PRINT((ndo, "%c", toupper(*pnp)));
+
+	if (is_reqresp) {
+		/*
+		 * In non-verbose mode, just print the protocol, followed
+		 * by the first line as the request or response info.
+		 *
+		 * In verbose mode, print lines as text until we run out
+		 * of characters or see something that's not a
+		 * printable-ASCII line.
+		 */
+		if (ndo->ndo_vflag) {
+			/*
+			 * We're going to print all the text lines in the
+			 * request or response; just print the length
+			 * on the first line of the output.
+			 */
+			ND_PRINT((ndo, ", length: %u", len));
+			for (idx = 0;
+			    idx < len && (eol = print_txt_line(ndo, protoname, "\n\t", pptr, idx, len)) != 0;
+			    idx = eol)
+				;
+		} else {
+			/*
+			 * Just print the first text line.
+			 */
+			print_txt_line(ndo, protoname, ": ", pptr, 0, len);
+		}
+	}
+}
+
 /* VARARGS */
 void
 error(const char *fmt, ...)
@@ -584,27 +850,23 @@
 }
 
 void
-safeputs(const char *s, int maxlen)
+safeputs(netdissect_options *ndo,
+         const u_char *s, const u_int maxlen)
 {
-	int idx = 0;
+	u_int idx = 0;
 
 	while (*s && idx < maxlen) {
-		safeputchar(*s);
-                idx++;
+		safeputchar(ndo, *s);
+		idx++;
 		s++;
 	}
 }
 
 void
-safeputchar(int c)
+safeputchar(netdissect_options *ndo,
+            const u_char c)
 {
-	unsigned char ch;
-
-	ch = (unsigned char)(c & 0xff);
-	if (ch < 0x80 && ND_ISPRINT(ch))
-		printf("%c", ch);
-	else
-		printf("\\0x%02x", ch);
+	ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c));
 }
 
 #ifdef LBL_ALIGN
diff --git a/version.c b/version.c
index 6481d27..e7db708 100644
--- a/version.c
+++ b/version.c
@@ -1 +1 @@
-const char version[] = "4.5.1";
+const char version[] = "4.7.4";
diff --git a/vfprintf.c b/vfprintf.c
index 6f8407a..6f3e15f 100644
--- a/vfprintf.c
+++ b/vfprintf.c
@@ -19,11 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/vfprintf.c,v 1.6 2003-11-16 09:36:45 guy Exp $ (LBL)";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/win32/Include/bittypes.h b/win32/Include/bittypes.h
deleted file mode 100644
index 95aa9fa..0000000
--- a/win32/Include/bittypes.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 1999 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the project 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 BY THE PROJECT 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 THE PROJECT 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.
- */
-#ifndef _BITTYPES_H
-#define _BITTYPES_H
-
-#ifndef HAVE_U_INT8_T
-typedef unsigned char u_int8_t;
-typedef signed char int8_t;
-#endif /* HAVE_U_INT8_T */
-
-#ifndef HAVE_U_INT16_T
-typedef unsigned short u_int16_t;
-typedef signed short int16_t;
-#endif /* HAVE_U_INT16_T */
-
-#ifndef HAVE_U_INT32_T
-typedef unsigned int u_int32_t;
-typedef signed int int32_t;
-#endif /* HAVE_U_INT32_T */
-
-#ifndef HAVE_U_INT64_T
-#ifdef _MSC_EXTENSIONS
-typedef unsigned _int64 u_int64_t;
-typedef _int64 int64_t;
-#else /* _MSC_EXTENSIONS */
-typedef unsigned long long u_int64_t;
-typedef long long int64_t;
-#endif /* _MSC_EXTENSIONS */
-#endif /* HAVE_U_INT64_T */
-
-#ifndef PRId64
-#ifdef _MSC_EXTENSIONS
-#define PRId64	"I64d"
-#else /* _MSC_EXTENSIONS */
-#define PRId64	"lld"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRId64 */
-
-#ifndef PRIo64
-#ifdef _MSC_EXTENSIONS
-#define PRIo64	"I64o"
-#else /* _MSC_EXTENSIONS */
-#define PRIo64	"llo"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRIo64 */
-
-#ifndef PRIx64
-#ifdef _MSC_EXTENSIONS
-#define PRIx64	"I64x"
-#else /* _MSC_EXTENSIONS */
-#define PRIx64	"llx"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRIx64 */
-
-#ifndef PRIu64
-#ifdef _MSC_EXTENSIONS
-#define PRIu64	"I64u"
-#else /* _MSC_EXTENSIONS */
-#define PRIu64	"llu"
-#endif /* _MSC_EXTENSIONS */
-#endif /* PRIu64 */
-
-#endif /* _BITTYPES_H */
diff --git a/win32/Include/errno.h b/win32/Include/errno.h
deleted file mode 100644
index 7cf599f..0000000
--- a/win32/Include/errno.h
+++ /dev/null
@@ -1,132 +0,0 @@
-#ifndef _I386_ERRNO_H
-#define _I386_ERRNO_H
-
-#define	EPERM		 1	/* Operation not permitted */
-#define	ENOENT		 2	/* No such file or directory */
-#define	ESRCH		 3	/* No such process */
-#define	EINTR		 4	/* Interrupted system call */
-#define	EIO		 5	/* I/O error */
-#define	ENXIO		 6	/* No such device or address */
-#define	E2BIG		 7	/* Arg list too long */
-#define	ENOEXEC		 8	/* Exec format error */
-#define	EBADF		 9	/* Bad file number */
-#define	ECHILD		10	/* No child processes */
-#define	EAGAIN		11	/* Try again */
-#define	ENOMEM		12	/* Out of memory */
-#define	EACCES		13	/* Permission denied */
-#define	EFAULT		14	/* Bad address */
-#define	ENOTBLK		15	/* Block device required */
-#define	EBUSY		16	/* Device or resource busy */
-#define	EEXIST		17	/* File exists */
-#define	EXDEV		18	/* Cross-device link */
-#define	ENODEV		19	/* No such device */
-#define	ENOTDIR		20	/* Not a directory */
-#define	EISDIR		21	/* Is a directory */
-#define	EINVAL		22	/* Invalid argument */
-#define	ENFILE		23	/* File table overflow */
-#define	EMFILE		24	/* Too many open files */
-#define	ENOTTY		25	/* Not a typewriter */
-#define	ETXTBSY		26	/* Text file busy */
-#define	EFBIG		27	/* File too large */
-#define	ENOSPC		28	/* No space left on device */
-#define	ESPIPE		29	/* Illegal seek */
-#define	EROFS		30	/* Read-only file system */
-#define	EMLINK		31	/* Too many links */
-#define	EPIPE		32	/* Broken pipe */
-#define	EDOM		33	/* Math argument out of domain of func */
-#define	ERANGE		34	/* Math result not representable */
-#define	EDEADLK		35	/* Resource deadlock would occur */
-#define	ENAMETOOLONG	36	/* File name too long */
-#define	ENOLCK		37	/* No record locks available */
-#define	ENOSYS		38	/* Function not implemented */
-#define	ENOTEMPTY	39	/* Directory not empty */
-#define	ELOOP		40	/* Too many symbolic links encountered */
-#define	EWOULDBLOCK	EAGAIN	/* Operation would block */
-#define	ENOMSG		42	/* No message of desired type */
-#define	EIDRM		43	/* Identifier removed */
-#define	ECHRNG		44	/* Channel number out of range */
-#define	EL2NSYNC	45	/* Level 2 not synchronized */
-#define	EL3HLT		46	/* Level 3 halted */
-#define	EL3RST		47	/* Level 3 reset */
-#define	ELNRNG		48	/* Link number out of range */
-#define	EUNATCH		49	/* Protocol driver not attached */
-#define	ENOCSI		50	/* No CSI structure available */
-#define	EL2HLT		51	/* Level 2 halted */
-#define	EBADE		52	/* Invalid exchange */
-#define	EBADR		53	/* Invalid request descriptor */
-#define	EXFULL		54	/* Exchange full */
-#define	ENOANO		55	/* No anode */
-#define	EBADRQC		56	/* Invalid request code */
-#define	EBADSLT		57	/* Invalid slot */
-
-#define	EDEADLOCK	EDEADLK
-
-#define	EBFONT		59	/* Bad font file format */
-#define	ENOSTR		60	/* Device not a stream */
-#define	ENODATA		61	/* No data available */
-#define	ETIME		62	/* Timer expired */
-#define	ENOSR		63	/* Out of streams resources */
-#define	ENONET		64	/* Machine is not on the network */
-#define	ENOPKG		65	/* Package not installed */
-#define	EREMOTE		66	/* Object is remote */
-#define	ENOLINK		67	/* Link has been severed */
-#define	EADV		68	/* Advertise error */
-#define	ESRMNT		69	/* Srmount error */
-#define	ECOMM		70	/* Communication error on send */
-#define	EPROTO		71	/* Protocol error */
-#define	EMULTIHOP	72	/* Multihop attempted */
-#define	EDOTDOT		73	/* RFS specific error */
-#define	EBADMSG		74	/* Not a data message */
-#define	EOVERFLOW	75	/* Value too large for defined data type */
-#define	ENOTUNIQ	76	/* Name not unique on network */
-#define	EBADFD		77	/* File descriptor in bad state */
-#define	EREMCHG		78	/* Remote address changed */
-#define	ELIBACC		79	/* Can not access a needed shared library */
-#define	ELIBBAD		80	/* Accessing a corrupted shared library */
-#define	ELIBSCN		81	/* .lib section in a.out corrupted */
-#define	ELIBMAX		82	/* Attempting to link in too many shared libraries */
-#define	ELIBEXEC	83	/* Cannot exec a shared library directly */
-#define	EILSEQ		84	/* Illegal byte sequence */
-#define	ERESTART	85	/* Interrupted system call should be restarted */
-#define	ESTRPIPE	86	/* Streams pipe error */
-#define	EUSERS		87	/* Too many users */
-#define	ENOTSOCK	88	/* Socket operation on non-socket */
-#define	EDESTADDRREQ	89	/* Destination address required */
-#define	EMSGSIZE	90	/* Message too long */
-#define	EPROTOTYPE	91	/* Protocol wrong type for socket */
-#define	ENOPROTOOPT	92	/* Protocol not available */
-#define	EPROTONOSUPPORT	93	/* Protocol not supported */
-#define	ESOCKTNOSUPPORT	94	/* Socket type not supported */
-#define	EOPNOTSUPP	95	/* Operation not supported on transport endpoint */
-#define	EPFNOSUPPORT	96	/* Protocol family not supported */
-#define	EAFNOSUPPORT	97	/* Address family not supported by protocol */
-#define	EADDRINUSE	98	/* Address already in use */
-#define	EADDRNOTAVAIL	99	/* Cannot assign requested address */
-#define	ENETDOWN	100	/* Network is down */
-#define	ENETUNREACH	101	/* Network is unreachable */
-#define	ENETRESET	102	/* Network dropped connection because of reset */
-#define	ECONNABORTED	103	/* Software caused connection abort */
-#define	ECONNRESET	104	/* Connection reset by peer */
-#define	ENOBUFS		105	/* No buffer space available */
-#define	EISCONN		106	/* Transport endpoint is already connected */
-#define	ENOTCONN	107	/* Transport endpoint is not connected */
-#define	ESHUTDOWN	108	/* Cannot send after transport endpoint shutdown */
-#define	ETOOMANYREFS	109	/* Too many references: cannot splice */
-#define	ETIMEDOUT	110	/* Connection timed out */
-#define	ECONNREFUSED	111	/* Connection refused */
-#define	EHOSTDOWN	112	/* Host is down */
-#define	EHOSTUNREACH	113	/* No route to host */
-#define	EALREADY	114	/* Operation already in progress */
-#define	EINPROGRESS	115	/* Operation now in progress */
-#define	ESTALE		116	/* Stale NFS file handle */
-#define	EUCLEAN		117	/* Structure needs cleaning */
-#define	ENOTNAM		118	/* Not a XENIX named type file */
-#define	ENAVAIL		119	/* No XENIX semaphores available */
-#define	EISNAM		120	/* Is a named type file */
-#define	EREMOTEIO	121	/* Remote I/O error */
-#define	EDQUOT		122	/* Quota exceeded */
-
-#define	ENOMEDIUM	123	/* No medium found */
-#define	EMEDIUMTYPE	124	/* Wrong medium type */
-
-#endif
diff --git a/win32/Include/getopt.h b/win32/Include/getopt.h
deleted file mode 100644
index b439ab1..0000000
--- a/win32/Include/getopt.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* Declarations for getopt.
-   Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
-   When `getopt' finds an option that takes an argument,
-   the argument value is returned here.
-   Also, when `ordering' is RETURN_IN_ORDER,
-   each non-option ARGV-element is returned here.  */
-
-#ifndef WIN32
-extern char *optarg;
-#endif
-
-/* Index in ARGV of the next element to be scanned.
-   This is used for communication to and from the caller
-   and for communication between successive calls to `getopt'.
-
-   On entry to `getopt', zero means this is the first call; initialize.
-
-   When `getopt' returns EOF, this is the index of the first of the
-   non-option elements that the caller should itself scan.
-
-   Otherwise, `optind' communicates from one call to the next
-   how much of ARGV has been scanned so far.  */
-
-#ifndef WIN32
-extern int optind;
-#endif
-
-/* Callers store zero here to inhibit the error message `getopt' prints
-   for unrecognized options.  */
-
-#ifndef WIN32
-extern int opterr;
-#endif
-
-/* Set to an option character which was unrecognized.  */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
-   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
-   of `struct option' terminated by an element containing a name which is
-   zero.
-
-   The field `has_arg' is:
-   no_argument		(or 0) if the option does not take an argument,
-   required_argument	(or 1) if the option requires an argument,
-   optional_argument 	(or 2) if the option takes an optional argument.
-
-   If the field `flag' is not NULL, it points to a variable that is set
-   to the value given in the field `val' when the option is found, but
-   left unchanged if the option is not found.
-
-   To have a long-named option do something other than set an `int' to
-   a compiled-in constant, such as set a value from `optarg', set the
-   option's `flag' field to zero and its `val' field to a nonzero
-   value (the equivalent single-letter option character, if there is
-   one).  For long options that have a zero `flag' field, `getopt'
-   returns the contents of the `val' field.  */
-
-struct option
-{
-#if	__STDC__
-  const char *name;
-#else
-  char *name;
-#endif
-  /* has_arg can't be an enum because some compilers complain about
-     type mismatches in all the code that assumes it is an int.  */
-  int has_arg;
-  int *flag;
-  int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'.  */
-
-#define	no_argument		0
-#define required_argument	1
-#define optional_argument	2
-
-#if __STDC__
-#if defined(__GNU_LIBRARY__)
-/* Many other libraries have conflicting prototypes for getopt, with
-   differences in the consts, in stdlib.h.  To avoid compilation
-   errors, only prototype getopt for the GNU C library.  */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* not __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
-		        const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
-			     const char *shortopts,
-		             const struct option *longopts, int *longind);
-
-/* Internal only.  Users should not call this directly.  */
-extern int _getopt_internal (int argc, char *const *argv,
-			     const char *shortopts,
-		             const struct option *longopts, int *longind,
-			     int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* not __STDC__ */
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/win32/Src/getopt.c b/win32/Src/getopt.c
deleted file mode 100644
index be74ef0..0000000
--- a/win32/Src/getopt.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 1987, 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 the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. 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 BY THE REGENTS 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 THE REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getopt.c	8.3 (Berkeley) 4/27/95";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int	opterr = 1,		/* if error message should be printed */
-	optind = 1,		/* index into parent argv vector */
-	optopt,			/* character checked for validity */
-	optreset;		/* reset getopt */
-char	*optarg;		/* argument associated with option */
-
-#define	BADCH	(int)'?'
-#define	BADARG	(int)':'
-#define	EMSG	""
-
-/*
- * getopt --
- *	Parse argc/argv argument vector.
- */
-int
-getopt(nargc, nargv, ostr)
-	int nargc;
-	char * const *nargv;
-	const char *ostr;
-{
-	extern char *program_name;
-	static char *place = EMSG;		/* option letter processing */
-	char *oli;				/* option letter list index */
-
-	if (optreset || !*place) {		/* update scanning pointer */
-		optreset = 0;
-		if (optind >= nargc || *(place = nargv[optind]) != '-') {
-			place = EMSG;
-			return (-1);
-		}
-		if (place[1] && *++place == '-') {	/* found "--" */
-			++optind;
-			place = EMSG;
-			return (-1);
-		}
-	}					/* option letter okay? */
-	if ((optopt = (int)*place++) == (int)':' ||
-	    !(oli = strchr(ostr, optopt))) {
-		/*
-		 * if the user didn't specify '-' as an option,
-		 * assume it means -1.
-		 */
-		if (optopt == (int)'-')
-			return (-1);
-		if (!*place)
-			++optind;
-		if (opterr && *ostr != ':')
-			(void)fprintf(stderr,
-			    "%s: illegal option -- %c\n", program_name, optopt);
-		return (BADCH);
-	}
-	if (*++oli != ':') {			/* don't need argument */
-		optarg = NULL;
-		if (!*place)
-			++optind;
-	}
-	else {					/* need an argument */
-		if (*place)			/* no white space */
-			optarg = place;
-		else if (nargc <= ++optind) {	/* no arg */
-			place = EMSG;
-			if (*ostr == ':')
-				return (BADARG);
-			if (opterr)
-				(void)fprintf(stderr,
-				    "%s: option requires an argument -- %c\n",
-				    program_name, optopt);
-			return (BADCH);
-		}
-	 	else				/* white space */
-			optarg = nargv[optind];
-		place = EMSG;
-		++optind;
-	}
-	return (optopt);			/* dump back option letter */
-}
diff --git a/win32/prj/GNUmakefile b/win32/prj/GNUmakefile
index bffdaaa..d0504e3 100644
--- a/win32/prj/GNUmakefile
+++ b/win32/prj/GNUmakefile
@@ -39,6 +39,7 @@
 	../../missing/datalinks.o \
 	../../missing/strsep.o \
 	../../missing/inet_pton.o \
+	../../missing/getopt_long.o \
 	../../machdep.o \
 	../../oui.o \
 	../../parsenfsfh.o \
@@ -146,7 +147,6 @@
 	../../smbutil.o \
 	../../tcpdump.o \
 	../../util.o \
-	../../Win32/src/getopt.o \
 	../../cpack.o \
 	../../ipproto.o \
 	../../l2vpn.o \
diff --git a/win32/prj/WinDump.dsp b/win32/prj/WinDump.dsp
index f3b3513..acafddd 100644
--- a/win32/prj/WinDump.dsp
+++ b/win32/prj/WinDump.dsp
@@ -42,7 +42,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../../../winpcap/wpcap/libpcap/bpf" /I "../../../winpcap/wpcap/libpcap" /I "../../../winpcap/wpcap/libpcap/Win32/Include" /I "../../../winpcap/wpcap/libpcap/Win32/Include/net" /I "../../Win32/Include" /I "../../linux-Include" /I "../../lbl" /I "../../" /I "../../../winpcap/wpcap/win32-extensions" /D "NDEBUG" /D "INET6" /D "WIN32" /D "_MBCS" /D "_CONSOLE" /D "__STDC__" /D "WPCAP" /D HAVE_ADDRINFO=1 /D HAVE_SOCKADDR_STORAGE=1 /D HAVE_PCAP_LIST_DATALINKS=1 /D HAVE_PCAP_SET_DATALINK=1 /D HAVE_PCAP_DATALINK_NAME_TO_VAL=1 /D HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION=1 /D HAVE_PCAP_DUMP_FTELL=1 /D HAVE_BPF_DUMP=1 /D HAVE_PCAP_DUMP_FLUSH=1 /D HAVE_PCAP_FINDALLDEVS=1 /D HAVE_PCAP_IF_T=1 /D HAVE_PCAP_LIB_VERSION=1 /D "HAVE_REMOTE" /D _U_= /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../../../winpcap/wpcap/libpcap/bpf" /I "../../../winpcap/wpcap/libpcap" /I "../../../winpcap/wpcap/libpcap/Win32/Include" /I "../../../winpcap/wpcap/libpcap/Win32/Include/net" /I "../../Win32/Include" /I "../../linux-Include" /I "../../lbl" /I "../../" /I "../../../winpcap/wpcap/win32-extensions" /D "NDEBUG" /D "INET6" /D "WIN32" /D "_MBCS" /D "_CONSOLE" /D "__STDC__" /D "WPCAP" /D HAVE_ADDRINFO=1 /D HAVE_SOCKADDR_STORAGE=1 /D HAVE_PCAP_LIST_DATALINKS=1 /D HAVE_PCAP_SET_DATALINK=1 /D HAVE_PCAP_DATALINK_NAME_TO_VAL=1 /D HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION=1 /D HAVE_PCAP_DUMP_FTELL=1 /D HAVE_BPF_DUMP=1 /D HAVE_PCAP_DUMP_FLUSH=1 /D HAVE_PCAP_FINDALLDEVS=1 /D HAVE_PCAP_IF_T=1 /D HAVE_PCAP_LIB_VERSION=1 /D "HAVE_REMOTE" /D _U_= /DUSE_ETHER_NTOHOST /YX /FD /c
 # ADD BASE RSC /l 0x410 /d "NDEBUG"
 # ADD RSC /l 0x410 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -66,7 +66,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /Gi /GX /ZI /I "../../../winpcap/wpcap/libpcap/bpf" /I "../../../winpcap/wpcap/libpcap" /I "../../../winpcap/wpcap/libpcap/Win32/Include" /I "../../../winpcap/wpcap/libpcap/Win32/Include/net" /I "../../Win32/Include" /I "../../linux-Include" /I "../../lbl" /I "../../" /I "../../../winpcap/wpcap/win32-extensions" /D "_DEBUG" /D "_WINDOWS" /D "INET6" /D "WIN32" /D "_MBCS" /D "_CONSOLE" /D "__STDC__" /D "WPCAP" /D HAVE_ADDRINFO=1 /D HAVE_SOCKADDR_STORAGE=1 /D HAVE_PCAP_LIST_DATALINKS=1 /D HAVE_PCAP_SET_DATALINK=1 /D HAVE_PCAP_DATALINK_NAME_TO_VAL=1 /D HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION=1 /D HAVE_PCAP_DUMP_FTELL=1 /D HAVE_BPF_DUMP=1 /D HAVE_PCAP_DUMP_FLUSH=1 /D HAVE_PCAP_FINDALLDEVS=1 /D HAVE_PCAP_IF_T=1 /D HAVE_PCAP_LIB_VERSION=1 /D "HAVE_REMOTE" /D _U_= /FR /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /Gi /GX /ZI /I "../../../winpcap/wpcap/libpcap/bpf" /I "../../../winpcap/wpcap/libpcap" /I "../../../winpcap/wpcap/libpcap/Win32/Include" /I "../../../winpcap/wpcap/libpcap/Win32/Include/net" /I "../../Win32/Include" /I "../../linux-Include" /I "../../lbl" /I "../../" /I "../../../winpcap/wpcap/win32-extensions" /D "_DEBUG" /D "_WINDOWS" /D "INET6" /D "WIN32" /D "_MBCS" /D "_CONSOLE" /D "__STDC__" /D "WPCAP" /D HAVE_ADDRINFO=1 /D HAVE_SOCKADDR_STORAGE=1 /D HAVE_PCAP_LIST_DATALINKS=1 /D HAVE_PCAP_SET_DATALINK=1 /D HAVE_PCAP_DATALINK_NAME_TO_VAL=1 /D HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION=1 /D HAVE_PCAP_DUMP_FTELL=1 /D HAVE_BPF_DUMP=1 /D HAVE_PCAP_DUMP_FLUSH=1 /D HAVE_PCAP_FINDALLDEVS=1 /D HAVE_PCAP_IF_T=1 /D HAVE_PCAP_LIB_VERSION=1 /D "HAVE_REMOTE" /D _U_= /DUSE_ETHER_NTOHOST /FR /YX /FD /c
 # ADD BASE RSC /l 0x410 /d "_DEBUG"
 # ADD RSC /l 0x410 /d "_DEBUG"
 BSC32=bscmake.exe
@@ -113,7 +113,7 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\Src\getopt.c
+SOURCE=..\..\missing\getopt_long.c
 # End Source File
 # Begin Source File
 
@@ -633,6 +633,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\Src\ether_ntohost.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\util.c
 # End Source File
 # End Target
diff --git a/win32/prj/WinDump.sln b/win32/prj/WinDump.sln
deleted file mode 100644
index 55a842f..0000000
--- a/win32/prj/WinDump.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinDump", "WinDump.vcproj", "{CA799811-AF71-4C88-BBDA-CDC49B13758B}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{CA799811-AF71-4C88-BBDA-CDC49B13758B}.Debug|Win32.ActiveCfg = Debug|Win32
-		{CA799811-AF71-4C88-BBDA-CDC49B13758B}.Debug|Win32.Build.0 = Debug|Win32
-		{CA799811-AF71-4C88-BBDA-CDC49B13758B}.Release|Win32.ActiveCfg = Release|Win32
-		{CA799811-AF71-4C88-BBDA-CDC49B13758B}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/win32/prj/WinDump.vcproj b/win32/prj/WinDump.vcproj
deleted file mode 100644
index d42d4bc..0000000
--- a/win32/prj/WinDump.vcproj
+++ /dev/null
@@ -1,3250 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8.00"
-	Name="WinDump"
-	ProjectGUID="{CA799811-AF71-4C88-BBDA-CDC49B13758B}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory=".\../.."
-			IntermediateDirectory=".\Debug"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\../../WinDump.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="4"
-				AdditionalIncludeDirectories="../../../winpcap/wpcap/libpcap/bpf,../../../winpcap/wpcap/libpcap,../../../winpcap/wpcap/libpcap/Win32/Include,../../../winpcap/wpcap/libpcap/Win32/Include/net,../../Win32/Include,../../linux-Include,../../lbl,../../,../../../winpcap/wpcap/win32-extensions"
-				PreprocessorDefinitions="_DEBUG;_WINDOWS;INET6;WIN32;_CONSOLE;__STDC__;WPCAP;HAVE_ADDRINFO=1;HAVE_SOCKADDR_STORAGE=1;HAVE_PCAP_LIST_DATALINKS=1;HAVE_PCAP_SET_DATALINK=1;HAVE_PCAP_DATALINK_NAME_TO_VAL=1;HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION=1;HAVE_PCAP_DUMP_FTELL=1;HAVE_BPF_DUMP=1;HAVE_PCAP_DUMP_FLUSH=1;HAVE_PCAP_FINDALLDEVS=1;HAVE_PCAP_IF_T=1;HAVE_PCAP_LIB_VERSION=1;HAVE_REMOTE;_U_=;_CRT_SECURE_NO_WARNINGS"
-				MinimalRebuild="true"
-				RuntimeLibrary="1"
-				PrecompiledHeaderFile=".\Debug/WinDump.pch"
-				AssemblerListingLocation=".\Debug/"
-				ObjectFile=".\Debug/"
-				ProgramDataBaseFileName=".\Debug/"
-				BrowseInformation="1"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="_DEBUG"
-				Culture="1040"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="wpcap.lib odbc32.lib odbccp32.lib wsock32.lib"
-				OutputFile="debug/WinDump.exe"
-				LinkIncremental="2"
-				SuppressStartupBanner="true"
-				AdditionalLibraryDirectories="../../../winpcap/wpcap/PRJ/Debug/x86"
-				GenerateDebugInformation="true"
-				ProgramDatabaseFile=".\../../WinDump.pdb"
-				GenerateMapFile="true"
-				MapFileName=".\Debug/WinDump.map"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\../../WinDump.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory=".\../.."
-			IntermediateDirectory=".\Release"
-			ConfigurationType="1"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-			UseOfMFC="0"
-			ATLMinimizesCRunTimeLibraryUsage="false"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-				TypeLibraryName=".\../../WinDump.tlb"
-				HeaderFileName=""
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="2"
-				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="../../../winpcap/wpcap/libpcap/bpf,../../../winpcap/wpcap/libpcap,../../../winpcap/wpcap/libpcap/Win32/Include,../../../winpcap/wpcap/libpcap/Win32/Include/net,../../Win32/Include,../../linux-Include,../../lbl,../../,../../../winpcap/wpcap/win32-extensions"
-				PreprocessorDefinitions="NDEBUG;INET6;WIN32;_CONSOLE;__STDC__;WPCAP;HAVE_ADDRINFO=1;HAVE_SOCKADDR_STORAGE=1;HAVE_PCAP_LIST_DATALINKS=1;HAVE_PCAP_SET_DATALINK=1;HAVE_PCAP_DATALINK_NAME_TO_VAL=1;HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION=1;HAVE_PCAP_DUMP_FTELL=1;HAVE_BPF_DUMP=1;HAVE_PCAP_DUMP_FLUSH=1;HAVE_PCAP_FINDALLDEVS=1;HAVE_PCAP_IF_T=1;HAVE_PCAP_LIB_VERSION=1;HAVE_REMOTE;_U_=;_CRT_SECURE_NO_WARNINGS"
-				StringPooling="true"
-				RuntimeLibrary="0"
-				EnableFunctionLevelLinking="true"
-				PrecompiledHeaderFile=".\Release/WinDump.pch"
-				AssemblerListingLocation=".\Release/"
-				ObjectFile=".\Release/"
-				ProgramDataBaseFileName=".\Release/"
-				WarningLevel="3"
-				SuppressStartupBanner="true"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-				PreprocessorDefinitions="NDEBUG"
-				Culture="1040"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="odbc32.lib odbccp32.lib wsock32.lib wpcap.lib"
-				OutputFile="release/WinDump.exe"
-				LinkIncremental="1"
-				SuppressStartupBanner="true"
-				AdditionalLibraryDirectories="../../../winpcap/wpcap/PRJ/Release/x86"
-				ProgramDatabaseFile=".\../../WinDump.pdb"
-				SubSystem="1"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-				SuppressStartupBanner="true"
-				OutputFile=".\../../WinDump.bsc"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<File
-			RelativePath="..\..\addrtoname.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\af.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\bpf_dump.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\checksum.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\cpack.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\datalinks.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\dlnames.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\Src\getopt.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\gmpls.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\gmt2local.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\inet_aton.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\inet_ntop.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\inet_pton.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\ipproto.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\l2vpn.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\machdep.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\nlpid.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\oui.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\parsenfsfh.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-802_11.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ah.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-aodv.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ap1394.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-arcnet.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-arp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ascii.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-atalk.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-atm.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-beep.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-bfd.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-bgp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-bootp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-bt.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-cdp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-cfm.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-chdlc.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-cip.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-cnfp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-dccp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-decnet.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-dhcp6.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-domain.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-dtp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-dvmrp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-eap.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-egp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-eigrp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-enc.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-esp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ether.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-fddi.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-fr.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-frag6.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-gre.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-hsrp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-icmp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-icmp6.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-igmp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-igrp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ip.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ip6.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ip6opts.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ipcomp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ipfc.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ipx.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-isakmp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-isoclns.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-juniper.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-krb.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-l2tp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-lane.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ldp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-llc.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-lldp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-lmp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-lspping.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-lwapp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-lwres.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-mobile.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-mobility.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-mpcp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-mpls.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-msdp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-netbios.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-nfs.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ntp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-null.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-olsr.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ospf.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ospf6.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-pgm.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-pim.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ppp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-pppoe.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-pptp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-radius.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-raw.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-rip.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-ripng.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-rpki-rtr.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-rrcp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-rsvp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-rt6.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-rx.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-sctp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-sflow.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-sip.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-sl.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-sll.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-slow.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-smb.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-snmp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-stp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-sunatm.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-sunrpc.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-symantec.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-syslog.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-tcp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-telnet.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-tftp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-timed.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-token.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-udld.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-udp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-vjc.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-vqp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-vrrp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-vtp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-wb.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\print-zephyr.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\setsignal.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\signature.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\smbutil.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\strcasecmp.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\strlcat.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\strlcpy.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\missing\strsep.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\Tcpdump.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-		<File
-			RelativePath="..\..\util.c"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCLCompilerTool"
-					AdditionalIncludeDirectories=""
-					PreprocessorDefinitions=""
-				/>
-			</FileConfiguration>
-		</File>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>