]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Merge branch 'master' of git+ssh://bpf.tcpdump.org/tcpdump/master/git/tcpdump
authorMichael Richardson <[email protected]>
Wed, 22 Apr 2015 20:17:35 +0000 (16:17 -0400)
committerMichael Richardson <[email protected]>
Wed, 22 Apr 2015 20:17:35 +0000 (16:17 -0400)
190 files changed:
CHANGES
INSTALL.txt
Makefile.in
TODO [deleted file]
addrtoname.c
af.c
atmuni31.h [deleted file]
bpf_dump.c
checksum.c
cpack.c
gmpls.c
gmt2local.c
in_cksum.c
interface.h
ipproto.c
l2vpn.c
netdissect.h
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-fr.c
print-frag6.c
print-geneve.c
print-geonet.c
print-gre.c
print-hsrp.c
print-icmp.c
print-icmp6.c
print-igmp.c
print-igrp.c
print-ip.c
print-ip6.c
print-ip6opts.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-ospf.c
print-ospf6.c
print-otv.c
print-pflog.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-rx.c
print-sctp.c
print-sflow.c
print-sip.c
print-sl.c
print-sll.c
print-slow.c
print-smb.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
print.c [new file with mode: 0644]
print.h [new file with mode: 0644]
signature.c
smbutil.c
tcp.h
tcpdump.c
tests/TESTLIST
tests/TESTonce
tests/cve2015-0261-crash.out [new file with mode: 0644]
tests/cve2015-0261-crash.pcap [new file with mode: 0644]
tests/cve2015-0261-ipv6.out [new file with mode: 0644]
tests/cve2015-0261-ipv6.pcap [new file with mode: 0644]
tests/dtp-v.out
tests/ieee802.11_exthdr.out
tests/ieee802.11_rx-stbc.out
tests/kday1.out [new file with mode: 0644]
tests/kday1.pcap [new file with mode: 0644]
tests/kday2.out [new file with mode: 0644]
tests/kday2.pcap [new file with mode: 0644]
tests/kday3.out [new file with mode: 0644]
tests/kday3.pcap [new file with mode: 0644]
tests/kday4.out [new file with mode: 0644]
tests/kday4.pcap [new file with mode: 0644]
tests/kday5.out [new file with mode: 0644]
tests/kday5.pcap [new file with mode: 0644]
tests/kday6.out [new file with mode: 0644]
tests/kday6.pcap [new file with mode: 0644]
tests/kday7.out [new file with mode: 0644]
tests/kday7.pcap [new file with mode: 0644]
tests/kday8.out [new file with mode: 0644]
tests/kday8.pcap [new file with mode: 0644]
tests/lldp_cdp-ev.out
tests/of10_s4810-vvvv.out
util-print.c [new file with mode: 0644]
util.c

diff --git a/CHANGES b/CHANGES
index 2dbcfa9a0accdee5e847e8846ba21b801b62348f..3cd618cc05163ed34bcd47db9e2f98221186e994 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,18 @@
-Monday March. 11, 2015 [email protected]
+Tuesday April 14, 2015 [email protected]
+  Summary for 4.8.0 tcpdump release
+       Fix "-x" for Apple PKTAP and PPI packets
+
+Friday April 10, 2015 [email protected]
+  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 [email protected]
   Summary for 4.7.3 tcpdump release
        Capsicum fixes for FreeBSD 10
 
-Monday March. 10, 2015 [email protected]
+Tuesday March 10, 2015 [email protected]
   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
index dcb52b86894bbc333a21fb11c3c49f712a144506..2abadd6eaff8b2286a5863ce157dec9f7f2133e2 100644 (file)
@@ -51,7 +51,6 @@ ah.h          - IPSEC Authentication Header definitions
 appletalk.h    - AppleTalk definitions
 atime.awk      - TCP ack awk script
 atm.h          - ATM traffic type definitions
-atmuni31.h     - ATM Q.2931 definitions
 bpf_dump.c     - BPF program printing routines, in case libpcap doesn't
                  have them
 chdlc.h                - Cisco HDLC definitions
index a0dc559ada69c1589e783af09e1b7f1dd9297633..ddb24981e99cafbb2af3cfaed943eeb4891454da 100644 (file)
@@ -70,7 +70,7 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
        @rm -f $@
        $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
 
-CSRC = setsignal.c tcpdump.c
+CSRC = setsignal.c tcpdump.c util.c
 
 LIBNETDISSECT_SRC=\
        addrtoname.c \
@@ -86,6 +86,7 @@ LIBNETDISSECT_SRC=\
        nlpid.c \
        oui.c \
        parsenfsfh.c \
+       print.c \
        print-802_11.c \
        print-802_15_4.c \
        print-ah.c \
@@ -215,7 +216,7 @@ LIBNETDISSECT_SRC=\
        print-zephyr.c \
        print-zeromq.c \
        signature.c \
-       util.c
+       util-print.c
 
 LOCALSRC = @LOCALSRC@
 GENSRC = version.c
@@ -236,7 +237,6 @@ HDR = \
        ah.h \
        appletalk.h \
        atm.h \
-       atmuni31.h \
        chdlc.h \
        cpack.h \
        ether.h \
diff --git a/TODO b/TODO
deleted file mode 100644 (file)
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
index 6d957389ba4ac3a9d86aae3232b4a92e7a92b152..e131958302f4b0e5aea2c235deb1bece77280e98 100644 (file)
@@ -22,7 +22,6 @@
  *  and address to string conversion routines
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/af.c b/af.c
index bea6d977763fcddd0798f1856965dacffff65672..2a2159d75bb77ba299f3da215f073eac3b9b4296 100644 (file)
--- a/af.c
+++ b/af.c
@@ -15,7 +15,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/atmuni31.h b/atmuni31.h
deleted file mode 100644 (file)
index 0f85430..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
- * 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 Yen Yen Lim and
-        North Dakota State University
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- */
-
-/* Based on UNI3.1 standard by ATM Forum */
-
-/* ATM traffic types based on VPI=0 and (the following VCI */
-#define VCI_PPC                        0x05    /* Point-to-point signal msg */
-#define VCI_BCC                        0x02    /* Broadcast signal msg */
-#define VCI_OAMF4SC            0x03    /* Segment OAM F4 flow cell */
-#define VCI_OAMF4EC            0x04    /* End-to-end OAM F4 flow cell */
-#define VCI_METAC              0x01    /* Meta signal msg */
-#define VCI_ILMIC              0x10    /* ILMI msg */
-
-/* Q.2931 signalling messages */
-#define CALL_PROCEED           0x02    /* call proceeding */
-#define CONNECT                        0x07    /* connect */
-#define CONNECT_ACK            0x0f    /* connect_ack */
-#define SETUP                  0x05    /* setup */
-#define RELEASE                        0x4d    /* release */
-#define RELEASE_DONE           0x5a    /* release_done */
-#define RESTART                        0x46    /* restart */
-#define RESTART_ACK            0x4e    /* restart ack */
-#define STATUS                 0x7d    /* status */
-#define STATUS_ENQ             0x75    /* status ack */
-#define ADD_PARTY              0x80    /* add party */
-#define ADD_PARTY_ACK          0x81    /* add party ack */
-#define ADD_PARTY_REJ          0x82    /* add party rej */
-#define DROP_PARTY             0x83    /* drop party */
-#define DROP_PARTY_ACK         0x84    /* drop party ack */
-
-/* Information Element Parameters in the signalling messages */
-#define CAUSE                  0x08    /* cause */
-#define ENDPT_REF              0x54    /* endpoint reference */
-#define AAL_PARA               0x58    /* ATM adaptation layer parameters */
-#define TRAFF_DESCRIP          0x59    /* atm traffic descriptors */
-#define CONNECT_ID             0x5a    /* connection identifier */
-#define QOS_PARA               0x5c    /* quality of service parameters */
-#define B_HIGHER               0x5d    /* broadband higher layer information */
-#define B_BEARER               0x5e    /* broadband bearer capability */
-#define B_LOWER                        0x5f    /* broadband lower information */
-#define CALLING_PARTY          0x6c    /* calling party number */
-#define CALLED_PARTY           0x70    /* called party nmber */
-
-#define Q2931                  0x09
-
-/* Q.2931 signalling general messages format */
-#define PROTO_POS       0      /* offset of protocol discriminator */
-#define CALL_REF_POS    2      /* offset of call reference value */
-#define MSG_TYPE_POS    5      /* offset of message type */
-#define MSG_LEN_POS     7      /* offset of mesage length */
-#define IE_BEGIN_POS    9      /* offset of first information element */
-
-/* format of signalling messages */
-#define TYPE_POS       0
-#define LEN_POS                2
-#define FIELD_BEGIN_POS 4
index 2ef852834085d882777dd25d4324bb26eda8ce6f..05ae760a8f29e0a0005e0d82d47114cd4fae55a5 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index d8263c7a244a63002e55d52f9dff21446fb98ba0..1d771365e581df7cd3fc1cba7503777898bd7d5d 100644 (file)
@@ -17,7 +17,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/cpack.c b/cpack.c
index 16bfd151698e8c195193a1880944f74c6e3f538f..88028a3dd6fb3054a0dd8c38bb260c8b6701ca2b 100644 (file)
--- a/cpack.c
+++ b/cpack.c
@@ -27,7 +27,6 @@
  * OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/gmpls.c b/gmpls.c
index c9fd9bb8ac6c56db6af7315bdc73f28ba6bd79d8..b4837a1eb58db6a44e6de1f6bf3c3ea1964b0302 100644 (file)
--- a/gmpls.c
+++ b/gmpls.c
@@ -13,7 +13,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 6958f66a464019ddfcf44890d86016011159889f..2ab9c102d4fc9e4ac07ded917c1254fb816b7cdd 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 171728a88ceb14a96e340c1e283d9ecb88c823d3..efbc38e0bf37cd12638319ba9524c635db9227ee 100644 (file)
@@ -35,7 +35,6 @@
  *     @(#)in_cksum.c  8.1 (Berkeley) 6/10/93
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
index 2389c2e1e1ab9f1d26f39fac65789e76b3305b35..f033fc71808b5d0ed3c43fb64c952f29d22f2962 100644 (file)
@@ -150,48 +150,3 @@ extern void bpf_dump(const struct bpf_program *, int);
 #endif
 
 #include "netdissect.h"
-
-/* forward compatibility */
-
-#ifndef NETDISSECT_REWORKED
-extern netdissect_options *gndo;
-
-#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 suppress_default_print gndo->ndo_suppress_default_print
-#define packettype gndo->ndo_packettype
-#define sigsecret gndo->ndo_sigsecret
-#define Wflag gndo->ndo_Wflag
-#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 Hflag gndo->ndo_Hflag
-#define snaplen     gndo->ndo_snaplen
-#define snapend     gndo->ndo_snapend
-
-extern void default_print(const u_char *, u_int);
-
-#endif
index e44b74814bb4ea564a907f105ffb8370046122e7..8143eda8d2e73b9b044f87419a7e3e5de63f453e 100644 (file)
--- a/ipproto.c
+++ b/ipproto.c
@@ -13,7 +13,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/l2vpn.c b/l2vpn.c
index 54037aa19bc35391a6758006a259dc1e95fecec2..e9b72fff502269bd6d9cb7732c4921c66411c776 100644 (file)
--- a/l2vpn.c
+++ b/l2vpn.c
@@ -13,7 +13,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index b25f4c9fd5e79487f4d22e9858deb63b8f42bec3..be78857e5afe1271c69d5d2e21ec1fcd363c573c 100644 (file)
@@ -81,9 +81,9 @@ 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;
@@ -271,8 +271,9 @@ struct netdissect_options {
  *     http://www.kb.cert.org/vuls/id/162289
  */
 #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))
+         (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
 
 /* True if "var" was captured */
 #define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
@@ -292,7 +293,6 @@ extern void relts_print(netdissect_options *, 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 const char *tok2str(const struct tok *, const char *, int);
 
 /*
  * Flags for txtproto_print().
@@ -386,10 +386,10 @@ 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,
-                        void (*)(netdissect_options *, const u_char *),
-                        const u_char *);
+extern u_int ether_print(netdissect_options *,
+                         const u_char *, u_int, u_int,
+                         void (*)(netdissect_options *, const u_char *),
+                         const u_char *);
 
 extern u_int ether_if_print(netdissect_options *,
                             const struct pcap_pkthdr *,const u_char *);
@@ -453,14 +453,15 @@ 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_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 int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *);
+extern int snap_print(netdissect_options *, const u_char *, u_int, u_int,
+       const u_char *, const u_char *, 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);
@@ -627,4 +628,6 @@ extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
 extern void geonet_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *geo_pck, u_int len);
 extern void calm_fast_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *calm_pck, u_int len);
 
+extern netdissect_options *gndo;
+
 #endif  /* netdissect_h */
diff --git a/nlpid.c b/nlpid.c
index 919e87dd4ae8cc1faf683b4c8e2cf1409dddc8dd..b9d59c4c8212d3ad5eee5652cbd332c8abb88bc2 100644 (file)
--- a/nlpid.c
+++ b/nlpid.c
@@ -13,7 +13,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/oui.c b/oui.c
index 2aea5ad74d0ac5c9824bc5396210841dfaec93ac..d29a6016777b25a1d04da8d9fcd5a17e2d6543bd 100644 (file)
--- a/oui.c
+++ b/oui.c
@@ -13,7 +13,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 826ca94e4c5ccddefa8f431526460cf4bf5566da..4d14f3d63e0dcb647643faaea518b21607d8a6fe 100644 (file)
@@ -40,7 +40,6 @@
  * Western Research Laboratory
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 697e2c92600078769cf449b9d913fd52d14fc6c4..2b4463ec07ac6fbf5bfde74a5af3d1792ed632e7 100644 (file)
@@ -20,7 +20,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 #define        IEEE802_11_BSSID_LEN            6
 #define        IEEE802_11_RA_LEN               6
 #define        IEEE802_11_TA_LEN               6
+#define        IEEE802_11_ADDR1_LEN            6
 #define        IEEE802_11_SEQ_LEN              2
 #define        IEEE802_11_CTL_LEN              2
+#define        IEEE802_11_CARRIED_FC_LEN       2
+#define        IEEE802_11_HT_CONTROL_LEN       4
 #define        IEEE802_11_IV_LEN               3
 #define        IEEE802_11_KID_LEN              1
 
@@ -166,15 +168,15 @@ static const struct tok ctrl_str[] = {
 #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_PROTECTED(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];
+       uint8_t         da[IEEE802_11_DA_LEN];
+       uint8_t         sa[IEEE802_11_SA_LEN];
+       uint8_t         bssid[IEEE802_11_BSSID_LEN];
        uint16_t        seq_ctrl;
 };
 
@@ -292,85 +294,90 @@ struct mgmt_body_t {
        struct tim_t    tim;
 };
 
-struct ctrl_rts_t {
+struct ctrl_control_wrapper_hdr_t {
        uint16_t        fc;
        uint16_t        duration;
-       uint8_t         ra[6];
-       uint8_t         ta[6];
-       uint8_t         fcs[4];
+       uint8_t         addr1[IEEE802_11_ADDR1_LEN];
+       uint16_t        carried_fc[IEEE802_11_CARRIED_FC_LEN];
+       uint16_t        ht_control[IEEE802_11_HT_CONTROL_LEN];
+};
+
+#define        CTRL_CONTROL_WRAPPER_HDRLEN     (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+                                        IEEE802_11_ADDR1_LEN+\
+                                        IEEE802_11_CARRIED_FC_LEN+\
+                                        IEEE802_11_HT_CONTROL_LEN)
+
+struct ctrl_rts_hdr_t {
+       uint16_t        fc;
+       uint16_t        duration;
+       uint8_t         ra[IEEE802_11_RA_LEN];
+       uint8_t         ta[IEEE802_11_TA_LEN];
 };
 
 #define        CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
                         IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
 
-struct ctrl_cts_t {
+struct ctrl_cts_hdr_t {
        uint16_t        fc;
        uint16_t        duration;
-       uint8_t         ra[6];
-       uint8_t         fcs[4];
+       uint8_t         ra[IEEE802_11_RA_LEN];
 };
 
 #define        CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
 
-struct ctrl_ack_t {
+struct ctrl_ack_hdr_t {
        uint16_t        fc;
        uint16_t        duration;
-       uint8_t         ra[6];
-       uint8_t         fcs[4];
+       uint8_t         ra[IEEE802_11_RA_LEN];
 };
 
 #define        CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
 
-struct ctrl_ps_poll_t {
+struct ctrl_ps_poll_hdr_t {
        uint16_t        fc;
        uint16_t        aid;
-       uint8_t         bssid[6];
-       uint8_t         ta[6];
-       uint8_t         fcs[4];
+       uint8_t         bssid[IEEE802_11_BSSID_LEN];
+       uint8_t         ta[IEEE802_11_TA_LEN];
 };
 
 #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 {
+struct ctrl_end_hdr_t {
        uint16_t        fc;
        uint16_t        duration;
-       uint8_t         ra[6];
-       uint8_t         bssid[6];
-       uint8_t         fcs[4];
+       uint8_t         ra[IEEE802_11_RA_LEN];
+       uint8_t         bssid[IEEE802_11_BSSID_LEN];
 };
 
 #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 {
+struct ctrl_end_ack_hdr_t {
        uint16_t        fc;
        uint16_t        duration;
-       uint8_t         ra[6];
-       uint8_t         bssid[6];
-       uint8_t         fcs[4];
+       uint8_t         ra[IEEE802_11_RA_LEN];
+       uint8_t         bssid[IEEE802_11_BSSID_LEN];
 };
 
 #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 {
+struct ctrl_ba_hdr_t {
        uint16_t        fc;
        uint16_t        duration;
-       uint8_t         ra[6];
-       uint8_t         fcs[4];
+       uint8_t         ra[IEEE802_11_RA_LEN];
 };
 
 #define        CTRL_BA_HDRLEN  (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
 
-struct ctrl_bar_t {
+struct ctrl_bar_hdr_t {
        uint16_t        fc;
        uint16_t        dur;
-       uint8_t         ra[6];
-       uint8_t         ta[6];
+       uint8_t         ra[IEEE802_11_RA_LEN];
+       uint8_t         ta[IEEE802_11_TA_LEN];
        uint16_t        ctl;
        uint16_t        seq;
-       uint8_t         fcs[4];
 };
 
 #define        CTRL_BAR_HDRLEN         (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
@@ -1283,7 +1290,7 @@ wep_print(netdissect_options *ndo,
                return 0;
        iv = EXTRACT_LE_32BITS(p);
 
-       ND_PRINT((ndo, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
+       ND_PRINT((ndo, " IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
            IV_KEYID(iv)));
 
        return 1;
@@ -1801,7 +1808,7 @@ handle_auth(netdissect_options *ndo,
 
 static int
 handle_deauth(netdissect_options *ndo,
-              const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+              const uint8_t *src, const u_char *p, u_int length)
 {
        struct mgmt_body_t  pbody;
        const char *reason = NULL;
@@ -1821,7 +1828,7 @@ handle_deauth(netdissect_options *ndo,
        if (ndo->ndo_eflag) {
                ND_PRINT((ndo, ": %s", reason));
        } else {
-               ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, pmh->sa), reason));
+               ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, src), reason));
        }
        return 1;
 }
@@ -1886,7 +1893,7 @@ handle_deauth(netdissect_options *ndo,
 
 static int
 handle_action(netdissect_options *ndo,
-              const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+              const uint8_t *src, const u_char *p, u_int length)
 {
        if (!ND_TTEST2(*p, 2))
                return 0;
@@ -1895,7 +1902,7 @@ handle_action(netdissect_options *ndo,
        if (ndo->ndo_eflag) {
                ND_PRINT((ndo, ": "));
        } else {
-               ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, pmh->sa)));
+               ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, src)));
        }
        switch (p[0]) {
        case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break;
@@ -1926,10 +1933,13 @@ handle_action(netdissect_options *ndo,
 
 static int
 mgmt_body_print(netdissect_options *ndo,
-                uint16_t fc, const struct mgmt_header_t *pmh,
-                const u_char *p, u_int length)
+                uint16_t fc, const uint8_t *src, const u_char *p, u_int length)
 {
        ND_PRINT((ndo, "%s", tok2str(st_str, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc))));
+
+       /* There may be a problem w/ AP not having this bit set */
+       if (FC_PROTECTED(fc))
+               return wep_print(ndo, p);
        switch (FC_SUBTYPE(fc)) {
        case ST_ASSOC_REQUEST:
                return handle_assoc_request(ndo, p, length);
@@ -1950,17 +1960,11 @@ mgmt_body_print(netdissect_options *ndo,
        case ST_DISASSOC:
                return handle_disassoc(ndo, p, length);
        case ST_AUTH:
-               if (!ND_TTEST2(*p, 3))
-                       return 0;
-               if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
-                       ND_PRINT((ndo, "Authentication (Shared-Key)-3 "));
-                       return wep_print(ndo, p);
-               }
                return handle_auth(ndo, p, length);
        case ST_DEAUTH:
-               return handle_deauth(ndo, pmh, p, length);
+               return handle_deauth(ndo, src, p, length);
        case ST_ACTION:
-               return handle_action(ndo, pmh, p, length);
+               return handle_action(ndo, src, p, length);
        default:
                return 1;
        }
@@ -1985,67 +1989,63 @@ ctrl_body_print(netdissect_options *ndo,
                        return 0;
                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))));
+                           etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra),
+                           etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta),
+                           EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)),
+                           EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq))));
                break;
        case CTRL_BA:
                if (!ND_TTEST2(*p, CTRL_BA_HDRLEN))
                        return 0;
                if (!ndo->ndo_eflag)
                        ND_PRINT((ndo, " RA:%s ",
-                           etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
+                           etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
                break;
        case CTRL_PS_POLL:
                if (!ND_TTEST2(*p, CTRL_PS_POLL_HDRLEN))
                        return 0;
                ND_PRINT((ndo, " AID(%x)",
-                   EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))));
+                   EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_hdr_t *)p)->aid))));
                break;
        case CTRL_RTS:
                if (!ND_TTEST2(*p, CTRL_RTS_HDRLEN))
                        return 0;
                if (!ndo->ndo_eflag)
                        ND_PRINT((ndo, " TA:%s ",
-                           etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
+                           etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta)));
                break;
        case CTRL_CTS:
                if (!ND_TTEST2(*p, CTRL_CTS_HDRLEN))
                        return 0;
                if (!ndo->ndo_eflag)
                        ND_PRINT((ndo, " RA:%s ",
-                           etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
+                           etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
                break;
        case CTRL_ACK:
                if (!ND_TTEST2(*p, CTRL_ACK_HDRLEN))
                        return 0;
                if (!ndo->ndo_eflag)
                        ND_PRINT((ndo, " RA:%s ",
-                           etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
+                           etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
                break;
        case CTRL_CF_END:
                if (!ND_TTEST2(*p, CTRL_END_HDRLEN))
                        return 0;
                if (!ndo->ndo_eflag)
                        ND_PRINT((ndo, " RA:%s ",
-                           etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra)));
+                           etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra)));
                break;
        case CTRL_END_ACK:
                if (!ND_TTEST2(*p, CTRL_END_ACK_HDRLEN))
                        return 0;
                if (!ndo->ndo_eflag)
                        ND_PRINT((ndo, " RA:%s ",
-                           etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra)));
+                           etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra)));
                break;
        }
        return 1;
 }
 
-/*
- * Print Header funcs
- */
-
 /*
  *  Data Frame - Address field contents
  *
@@ -2056,10 +2056,55 @@ ctrl_body_print(netdissect_options *ndo,
  *    1    |  1      |  RA    | TA     | DA     | SA
  */
 
+/*
+ * Function to get source and destination MAC addresses for a data frame.
+ */
+static void
+get_data_src_dst_mac(uint16_t fc, const u_char *p, const uint8_t **srcp,
+                     const uint8_t **dstp)
+{
+#define ADDR1  (p + 4)
+#define ADDR2  (p + 10)
+#define ADDR3  (p + 16)
+#define ADDR4  (p + 24)
+
+       if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
+               *srcp = ADDR2;
+               *dstp = ADDR1;
+       } else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) {
+               *srcp = ADDR3;
+               *dstp = ADDR1;
+       } else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
+               *srcp = ADDR2;
+               *dstp = ADDR3;
+       } else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) {
+               *srcp = ADDR4;
+               *dstp = ADDR3;
+       }
+
+#undef ADDR1
+#undef ADDR2
+#undef ADDR3
+#undef ADDR4
+}
+
+static void
+get_mgmt_src_dst_mac(const u_char *p, const uint8_t **srcp, const uint8_t **dstp)
+{
+       const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
+
+       if (srcp != NULL)
+               *srcp = hp->sa;
+       if (dstp != NULL)
+               *dstp = hp->da;
+}
+
+/*
+ * Print Header funcs
+ */
+
 static void
-data_header_print(netdissect_options *ndo,
-                  uint16_t fc, const u_char *p, const uint8_t **srcp,
-                  const uint8_t **dstp)
+data_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p)
 {
        u_int subtype = FC_SUBTYPE(fc);
 
@@ -2086,42 +2131,18 @@ data_header_print(netdissect_options *ndo,
 #define ADDR4  (p + 24)
 
        if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
-               if (srcp != NULL)
-                       *srcp = ADDR2;
-               if (dstp != NULL)
-                       *dstp = ADDR1;
-               if (!ndo->ndo_eflag)
-                       return;
                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 (!ndo->ndo_eflag)
-                       return;
                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 (!ndo->ndo_eflag)
-                       return;
                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 (!ndo->ndo_eflag)
-                       return;
                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)));
@@ -2134,77 +2155,60 @@ data_header_print(netdissect_options *ndo,
 }
 
 static void
-mgmt_header_print(netdissect_options *ndo,
-                  const u_char *p, const uint8_t **srcp, const uint8_t **dstp)
+mgmt_header_print(netdissect_options *ndo, const u_char *p)
 {
        const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
 
-       if (srcp != NULL)
-               *srcp = hp->sa;
-       if (dstp != NULL)
-               *dstp = hp->da;
-       if (!ndo->ndo_eflag)
-               return;
-
        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(netdissect_options *ndo,
-                  uint16_t fc, const u_char *p, const uint8_t **srcp,
-                  const uint8_t **dstp)
+ctrl_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p)
 {
-       if (srcp != NULL)
-               *srcp = NULL;
-       if (dstp != NULL)
-               *dstp = NULL;
-       if (!ndo->ndo_eflag)
-               return;
-
        switch (FC_SUBTYPE(fc)) {
        case CTRL_BAR:
                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))));
+                   etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra),
+                   etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta),
+                   EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)),
+                   EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq))));
                break;
        case CTRL_BA:
                ND_PRINT((ndo, "RA:%s ",
-                   etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
+                   etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
                break;
        case CTRL_PS_POLL:
                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)));
+                   etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->bssid),
+                   etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->ta)));
                break;
        case CTRL_RTS:
                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)));
+                   etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ra),
+                   etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta)));
                break;
        case CTRL_CTS:
                ND_PRINT((ndo, "RA:%s ",
-                   etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
+                   etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
                break;
        case CTRL_ACK:
                ND_PRINT((ndo, "RA:%s ",
-                   etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
+                   etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
                break;
        case CTRL_CF_END:
                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)));
+                   etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra),
+                   etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->bssid)));
                break;
        case CTRL_END_ACK:
                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)));
+                   etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra),
+                   etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->bssid)));
                break;
        default:
-               ND_PRINT((ndo, "(H) Unknown Ctrl Subtype"));
+               /* We shouldn't get here - we should already have quit */
                break;
        }
 }
@@ -2220,8 +2224,12 @@ extract_header_length(netdissect_options *ndo,
                return MGMT_HDRLEN;
        case T_CTRL:
                switch (FC_SUBTYPE(fc)) {
+               case CTRL_CONTROL_WRAPPER:
+                       return CTRL_CONTROL_WRAPPER_HDRLEN;
                case CTRL_BAR:
                        return CTRL_BAR_HDRLEN;
+               case CTRL_BA:
+                       return CTRL_BA_HDRLEN;
                case CTRL_PS_POLL:
                        return CTRL_PS_POLL_HDRLEN;
                case CTRL_RTS:
@@ -2235,6 +2243,7 @@ extract_header_length(netdissect_options *ndo,
                case CTRL_END_ACK:
                        return CTRL_END_ACK_HDRLEN;
                default:
+                       ND_PRINT((ndo, "unknown 802.11 ctrl frame subtype (%d)", FC_SUBTYPE(fc)));
                        return 0;
                }
        case T_DATA:
@@ -2243,7 +2252,7 @@ extract_header_length(netdissect_options *ndo,
                        len += 2;
                return len;
        default:
-               ND_PRINT((ndo, "unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)));
+               ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
                return 0;
        }
 }
@@ -2255,15 +2264,12 @@ extract_mesh_header_length(const u_char *p)
 }
 
 /*
- * Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
- * to point to the source and destination MAC addresses in any case if
- * "srcp" and "dstp" aren't null.
+ * Print the 802.11 MAC header.
  */
 static void
 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)
+                      u_int meshdrlen)
 {
        if (ndo->ndo_vflag) {
                if (FC_MORE_DATA(fc))
@@ -2276,8 +2282,8 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
                        ND_PRINT((ndo, "Retry "));
                if (FC_ORDER(fc))
                        ND_PRINT((ndo, "Strictly Ordered "));
-               if (FC_WEP(fc))
-                       ND_PRINT((ndo, "WEP Encrypted "));
+               if (FC_PROTECTED(fc))
+                       ND_PRINT((ndo, "Protected "));
                if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL)
                        ND_PRINT((ndo, "%dus ",
                            EXTRACT_LE_16BITS(
@@ -2301,19 +2307,15 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
 
        switch (FC_TYPE(fc)) {
        case T_MGMT:
-               mgmt_header_print(ndo, p, srcp, dstp);
+               mgmt_header_print(ndo, p);
                break;
        case T_CTRL:
-               ctrl_header_print(ndo, fc, p, srcp, dstp);
+               ctrl_header_print(ndo, fc, p);
                break;
        case T_DATA:
-               data_header_print(ndo, fc, p, srcp, dstp);
+               data_header_print(ndo, fc, p);
                break;
        default:
-               ND_PRINT((ndo, "(header) unknown IEEE802.11 frame type (%d)",
-                   FC_TYPE(fc)));
-               *srcp = NULL;
-               *dstp = NULL;
                break;
        }
 }
@@ -2330,7 +2332,7 @@ ieee802_11_print(netdissect_options *ndo,
        uint16_t fc;
        u_int caplen, hdrlen, meshdrlen;
        const uint8_t *src, *dst;
-       u_short extracted_ethertype;
+       int llc_hdrlen;
 
        caplen = orig_caplen;
        /* Remove FCS, if present */
@@ -2353,6 +2355,10 @@ ieee802_11_print(netdissect_options *ndo,
 
        fc = EXTRACT_LE_16BITS(p);
        hdrlen = extract_header_length(ndo, fc);
+       if (hdrlen == 0) {
+               /* Unknown frame type or control frame subtype; quit. */
+               return (0);
+       }
        if (pad)
                hdrlen = roundup2(hdrlen, 4);
        if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
@@ -2362,13 +2368,13 @@ ieee802_11_print(netdissect_options *ndo,
        } else
                meshdrlen = 0;
 
-
        if (caplen < hdrlen) {
                ND_PRINT((ndo, "%s", tstr));
                return hdrlen;
        }
 
-       ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen, &src, &dst);
+       if (ndo->ndo_eflag)
+               ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen);
 
        /*
         * Go past the 802.11 header.
@@ -2379,8 +2385,8 @@ ieee802_11_print(netdissect_options *ndo,
 
        switch (FC_TYPE(fc)) {
        case T_MGMT:
-               if (!mgmt_body_print(ndo, fc,
-                   (const struct mgmt_header_t *)(p - hdrlen), p, length)) {
+               get_mgmt_src_dst_mac(p - hdrlen, &src, &dst);
+               if (!mgmt_body_print(ndo, fc, src, p, length)) {
                        ND_PRINT((ndo, "%s", tstr));
                        return hdrlen;
                }
@@ -2395,30 +2401,29 @@ ieee802_11_print(netdissect_options *ndo,
                if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc)))
                        return hdrlen;  /* no-data frame */
                /* There may be a problem w/ AP not having this bit set */
-               if (FC_WEP(fc)) {
+               if (FC_PROTECTED(fc)) {
+                       ND_PRINT((ndo, "Data"));
                        if (!wep_print(ndo, p)) {
                                ND_PRINT((ndo, "%s", tstr));
                                return hdrlen;
                        }
-               } else if (llc_print(ndo, p, length, caplen, dst, src,
-                   &extracted_ethertype) == 0) {
-                       /*
-                        * Some kinds of LLC packet we cannot
-                        * handle intelligently
-                        */
-                       if (!ndo->ndo_eflag)
-                               ieee_802_11_hdr_print(ndo, fc, p - hdrlen, hdrlen,
-                                   meshdrlen, NULL, NULL);
-                       if (extracted_ethertype)
-                               ND_PRINT((ndo, "(LLC %s) ",
-                                   etherproto_string(
-                                       htons(extracted_ethertype))));
-                       if (!ndo->ndo_suppress_default_print)
-                               ND_DEFAULTPRINT(p, caplen);
+               } else {
+                       get_data_src_dst_mac(fc, p - hdrlen, &src, &dst);
+                       llc_hdrlen = llc_print(ndo, p, length, caplen, dst, src);
+                       if (llc_hdrlen < 0) {
+                               /*
+                                * Some kinds of LLC packet we cannot
+                                * handle intelligently
+                                */
+                               if (!ndo->ndo_suppress_default_print)
+                                       ND_DEFAULTPRINT(p, caplen);
+                               llc_hdrlen = -llc_hdrlen;
+                       }
+                       hdrlen += llc_hdrlen;
                }
                break;
        default:
-               ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
+               /* We shouldn't get here - we should already have quit */
                break;
        }
 
index 26c28ee652aa6e71c48d68e3154e1cb043acb73b..b41e15ac56168bd045922670a2b41bef9b663326 100644 (file)
@@ -20,7 +20,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 0badf48233bffc1b915278c12529d9e779009735..015967caf8361a9fea24a927cb15328c28e6e521 100644 (file)
@@ -21,7 +21,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index a9ae38a972334cfafd0302a46cbb67a047d8fb9a..7c69e7b34f4ea576091b9c762a0ea79c5ea65875 100644 (file)
@@ -29,7 +29,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index ef27eee6bc2d57f31cfd76073f06e3adc75a28fd..a29fef50e19c631669a008465bb65732b3bbb287 100644 (file)
@@ -30,7 +30,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index f8bc1fc9b990e539b9d78570955831d35fe16a02..a1dfc66b66ae562d20c81b90a0b77043dafd11ea 100644 (file)
@@ -29,7 +29,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 3befe2335bd0fc36e2f6e61cd8edc2a6664d478f..8adf94f420f89c33756bb0bc800c2e705a1ecb8b 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -57,8 +56,8 @@ ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int lengt
        fp = (const struct firewire_header *)bp;
 
        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)));
+                    linkaddr_string(ndo, fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
+                    linkaddr_string(ndo, fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)));
 
        firewire_type = EXTRACT_16BITS(&fp->firewire_type);
        if (!ndo->ndo_qflag) {
index 0ffb9220709b6253b372d3ccb59b0284dbffa7f7..cd6f5d9a996fd46bb2d766c2eb7bf723a1944548 100644 (file)
@@ -21,7 +21,6 @@
  * From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 76f39fe084a681e1c8a5c8e32cf9d01d6fabbc7e..b54a30f0e554523bbd485823975e430f299e0981 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 3cefef33aeb4f8578138e81e49e857b623aa3a9f..71f16ff4c816fa763e31c037103ef460035fb3fa 100644 (file)
@@ -36,7 +36,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 61405493d0ea3685ab2ecf4afa3b85fb3a80aa97..0a235c82b3fc74926ceeb9796b33f2e0c9b11dc0 100644 (file)
@@ -21,7 +21,6 @@
  * Format and print AppleTalk packets.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 8faf715dac2dbb24d0bd4881dc9537fe8f9f70cc..d2f18f7a3ae9bd52178408d7f8944b1163a666bc 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 #include "extract.h"
 #include "addrtoname.h"
 #include "atm.h"
-#include "atmuni31.h"
 #include "llc.h"
 
+/* start of the original atmuni31.h */
+
+/*
+ * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
+ * 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 Yen Yen Lim and
+        North Dakota State University
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/* Based on UNI3.1 standard by ATM Forum */
+
+/* ATM traffic types based on VPI=0 and (the following VCI */
+#define VCI_PPC                        0x05    /* Point-to-point signal msg */
+#define VCI_BCC                        0x02    /* Broadcast signal msg */
+#define VCI_OAMF4SC            0x03    /* Segment OAM F4 flow cell */
+#define VCI_OAMF4EC            0x04    /* End-to-end OAM F4 flow cell */
+#define VCI_METAC              0x01    /* Meta signal msg */
+#define VCI_ILMIC              0x10    /* ILMI msg */
+
+/* Q.2931 signalling messages */
+#define CALL_PROCEED           0x02    /* call proceeding */
+#define CONNECT                        0x07    /* connect */
+#define CONNECT_ACK            0x0f    /* connect_ack */
+#define SETUP                  0x05    /* setup */
+#define RELEASE                        0x4d    /* release */
+#define RELEASE_DONE           0x5a    /* release_done */
+#define RESTART                        0x46    /* restart */
+#define RESTART_ACK            0x4e    /* restart ack */
+#define STATUS                 0x7d    /* status */
+#define STATUS_ENQ             0x75    /* status ack */
+#define ADD_PARTY              0x80    /* add party */
+#define ADD_PARTY_ACK          0x81    /* add party ack */
+#define ADD_PARTY_REJ          0x82    /* add party rej */
+#define DROP_PARTY             0x83    /* drop party */
+#define DROP_PARTY_ACK         0x84    /* drop party ack */
+
+/* Information Element Parameters in the signalling messages */
+#define CAUSE                  0x08    /* cause */
+#define ENDPT_REF              0x54    /* endpoint reference */
+#define AAL_PARA               0x58    /* ATM adaptation layer parameters */
+#define TRAFF_DESCRIP          0x59    /* atm traffic descriptors */
+#define CONNECT_ID             0x5a    /* connection identifier */
+#define QOS_PARA               0x5c    /* quality of service parameters */
+#define B_HIGHER               0x5d    /* broadband higher layer information */
+#define B_BEARER               0x5e    /* broadband bearer capability */
+#define B_LOWER                        0x5f    /* broadband lower information */
+#define CALLING_PARTY          0x6c    /* calling party number */
+#define CALLED_PARTY           0x70    /* called party nmber */
+
+#define Q2931                  0x09
+
+/* Q.2931 signalling general messages format */
+#define PROTO_POS       0      /* offset of protocol discriminator */
+#define CALL_REF_POS    2      /* offset of call reference value */
+#define MSG_TYPE_POS    5      /* offset of message type */
+#define MSG_LEN_POS     7      /* offset of mesage length */
+#define IE_BEGIN_POS    9      /* offset of first information element */
+
+/* format of signalling messages */
+#define TYPE_POS       0
+#define LEN_POS                2
+#define FIELD_BEGIN_POS 4
+
+/* end of the original atmuni31.h */
+
 static const char tstr[] = "[|atm]";
 
 #define OAM_CRC10_MASK 0x3ff
@@ -126,22 +214,20 @@ static const struct tok *oam_functype_values[16] = {
 /*
  * Print an RFC 1483 LLC-encapsulated ATM frame.
  */
-static void
+static u_int
 atm_llc_print(netdissect_options *ndo,
               const u_char *p, int length, int caplen)
 {
-       u_short extracted_ethertype;
-
-       if (!llc_print(ndo, p, length, caplen, NULL, NULL,
-           &extracted_ethertype)) {
-               /* ether_type not known, print raw packet */
-               if (extracted_ethertype) {
-                       ND_PRINT((ndo, "(LLC %s) ",
-               etherproto_string(htons(extracted_ethertype))));
-               }
+       int llc_hdrlen;
+
+       llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+       if (llc_hdrlen < 0) {
+               /* packet not known, print raw packet */
                if (!ndo->ndo_suppress_default_print)
                        ND_DEFAULTPRINT(p, caplen);
+               llc_hdrlen = -llc_hdrlen;
        }
+       return (llc_hdrlen);
 }
 
 /*
@@ -229,7 +315,7 @@ atm_if_print(netdissect_options *ndo,
                caplen -= 20;
                hdrlen += 20;
        }
-       atm_llc_print(ndo, p, length, caplen);
+       hdrlen += atm_llc_print(ndo, p, length, caplen);
        return (hdrlen);
 }
 
index 75cb32cf19e943b098ebbc01a96bd3027e446c78..bb2612c6df42d2b515061650d4606b85c7cff453 100644 (file)
@@ -26,7 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 7982feb5c362333c1bb246fd0480a0f5517ddc23..4c5bc84a41f4dc1046925891c1e08a94f8f55d4b 100644 (file)
@@ -9,7 +9,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index f1c2ee8cea8fc9c3418b5e39734a5e36293956a8..0450175f8b7a7a063f8142b2e317fccc9680433b 100644 (file)
@@ -13,7 +13,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index c617c3bbbed39959bd78afa5f29be22dc94251f5..6a4fa2c0ff50e3f0c92befe8cb81516152a0c458 100644 (file)
@@ -30,7 +30,6 @@
  * complete BGP support.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index fe0a070ca093a0fb26742fb5a8145f27f92620d4..07c518e8a09b00b22284e4c81df031a85fc73e0e 100644 (file)
@@ -21,7 +21,6 @@
  * Format and print bootp packets.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 128daade063f8ade4c449803bbc5422c6a4d785a..68c02a61610eb0d3bedf8974c52d1db4b077c31e 100644 (file)
@@ -17,7 +17,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 5cc39f418531ec39e903f4483b5c4ea221ff2ceb..5d1cb64f6d96cf1ace35e88feba089b1f4fd9325 100644 (file)
@@ -15,7 +15,6 @@
  * Original code by Ola Martin Lykkja ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 7b9f28ceae4fbbc2ef2836ba49ab29c789ee8a8d..6417c1a8e57883bc3949475c7ef867fd8b93ef6a 100644 (file)
@@ -34,7 +34,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 932f7bccea6803d84bc8e529aa1f9133a01a645f..c28bd8825b79bb3a15d54758108da6cd38eeab37 100644 (file)
@@ -24,7 +24,6 @@
  *    http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index a85eec09139ea45b1d2df9abfc5dd7af9ee7a2a8..735fb1ee0a0e83429e332213a72147a50870b1e2 100644 (file)
@@ -17,7 +17,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 3951ef77cdff5ce7388f00b8ac8527c2eb8a58db..766ae3810c306148a1e10d8e7aeff08396fb9a09 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 91abe08d306ae6db93bdabca79688782926da6eb..fde5ab44512f59170a0d082da70413ed03a7096d 100644 (file)
@@ -20,7 +20,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -62,7 +61,7 @@ cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
 {
        u_int caplen = h->caplen;
        u_int length = h->len;
-       u_short extracted_ethertype;
+       int llc_hdrlen;
 
        if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
                ND_PRINT((ndo, "[|cip]"));
@@ -76,26 +75,22 @@ cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
                /*
                 * LLC header is present.  Try to print it & higher layers.
                 */
-               if (llc_print(ndo, p, length, caplen, NULL, NULL,
-                   &extracted_ethertype) == 0) {
-                       /* ether_type not known, print raw packet */
-                       if (!ndo->ndo_eflag)
-                               cip_print(ndo, length);
-                       if (extracted_ethertype) {
-                               ND_PRINT((ndo, "(LLC %s) ",
-                              etherproto_string(htons(extracted_ethertype))));
-                       }
+               llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+               if (llc_hdrlen < 0) {
+                       /* packet type not known, print raw packet */
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
+                       llc_hdrlen = -llc_hdrlen;
                }
        } else {
                /*
                 * LLC header is absent; treat it as just IP.
                 */
+               llc_hdrlen = 0;
                ip_print(ndo, p, length);
        }
 
-       return (0);
+       return (llc_hdrlen);
 }
 
 
index d80d7fd27442c2742d1da7e4e75073bc0bc1ae35..ea8b318df36309076c68ffcc7cea6fc4745864e7 100644 (file)
@@ -38,7 +38,6 @@
  *    http://www.cisco.com/c/en/us/td/docs/net_mgmt/netflow_collection_engine/3-6/user/guide/format.html#wp1005892
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 45468b555473c70c487aadbd9c78483f73660d09..979f6d34261d71bf66fe3980b117601fdf79aa60 100644 (file)
@@ -7,7 +7,6 @@
  * BSD-style license that accompanies tcpdump or the GNU GPL version 2
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 5414ec20b5cdf486287f090ae4185a71c3144a7a..f32b511e541e393605e1a3051a0ce5abd7baa46d 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 53b96ef954c98478878dfaa489032b5dc1489dfd..ff55917a0db656436567a1473b0da3b71ec39883 100644 (file)
@@ -40,7 +40,6 @@
  *  RFC6334: Dual-Stack Lite option,
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 8805007acf3f43c998967db7b077cba049aab796..3fcd9016db1bc51cab6abb27527d819e3e0249ed 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 5d84a770eecaa78ca44424869b441711dadd8d36..5983b84363549abc8491d1a808e00cf8f7f739f5 100644 (file)
@@ -17,7 +17,6 @@
  * Original code by Carles Kishimoto <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 96a0ee73f578dfd53a22df520b01a895516bacc4..8e0083260bd61771c9ff4871abc0485ebae6e8aa 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 0e2c2d38a1d8ba1c6ec83da437f8e4eaaf41945e..58b1159e3979973ad74c98276552d9d6356c7130 100644 (file)
@@ -21,7 +21,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 9c5c811e74e53bc399a555866e8a27298b52e055..8e4abc65abb09e696033413c10dda4e4c7fa7a93 100644 (file)
@@ -18,7 +18,6 @@
  * Initial contribution from Jeff Honig ([email protected]).
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index cab77ba509aaf3503b4bf57fbc4e0de7c5f0793d..5718d5114344f89c4aaaad0b13b1888a02d92012 100644 (file)
@@ -14,7 +14,6 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 7bd8631e5207b35fd09c05acefe82c5669ffddda..84dc01ba4e65854e9a952f977e5a06286d4e5211 100644 (file)
@@ -21,7 +21,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 8e267d45cdf9381d0eff7f70dbbaee8eaefeb0e0..d4101cef3d436da13035b6a250a8ac05d1338de1 100644 (file)
@@ -21,7 +21,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index e57d993b965e846ffc5670d470d198a08ce8e604..f4906260baad56d9cc82f9555f42b7b44e7abb48 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -123,7 +122,7 @@ ether_hdr_print(netdissect_options *ndo,
  * a pointer to a function that can print header information for that
  * frame's protocol, and an argument to pass to that function.
  */
-void
+u_int
 ether_print(netdissect_options *ndo,
             const u_char *p, u_int length, u_int caplen,
             void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
@@ -131,11 +130,16 @@ ether_print(netdissect_options *ndo,
        struct ether_header *ep;
        u_int orig_length;
        u_short ether_type;
-       u_short extracted_ether_type;
+       u_int hdrlen;
+       int llc_hdrlen;
 
-       if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) {
+       if (caplen < ETHER_HDRLEN) {
+               ND_PRINT((ndo, "[|ether]"));
+               return (caplen);
+       }
+       if (length < ETHER_HDRLEN) {
                ND_PRINT((ndo, "[|ether]"));
-               return;
+               return (length);
        }
 
        if (ndo->ndo_eflag) {
@@ -149,6 +153,7 @@ ether_print(netdissect_options *ndo,
        caplen -= ETHER_HDRLEN;
        ep = (struct ether_header *)p;
        p += ETHER_HDRLEN;
+       hdrlen = ETHER_HDRLEN;
 
        ether_type = EXTRACT_16BITS(&ep->ether_type);
 
@@ -158,18 +163,14 @@ recurse:
         */
        if (ether_type <= ETHERMTU) {
                /* Try to print the LLC-layer header & higher layers */
-               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) {
-                               if (print_encap_header != NULL)
-                                       (*print_encap_header)(ndo, encap_header_arg);
-                               ether_hdr_print(ndo, (u_char *)ep, orig_length);
-                       }
-
+               llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep));
+               if (llc_hdrlen < 0) {
+                       /* packet type not known, print raw packet */
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
+                       llc_hdrlen = -llc_hdrlen;
                }
+               hdrlen += llc_hdrlen;
        } else if (ether_type == ETHERTYPE_8021Q  ||
                 ether_type == ETHERTYPE_8021Q9100 ||
                 ether_type == ETHERTYPE_8021Q9200 ||
@@ -178,9 +179,13 @@ recurse:
                 * Print VLAN information, and then go back and process
                 * the enclosed type field.
                 */
-               if (caplen < 4 || length < 4) {
+               if (caplen < 4) {
+                       ND_PRINT((ndo, "[|vlan]"));
+                       return (hdrlen + caplen);
+               }
+               if (length < 4) {
                        ND_PRINT((ndo, "[|vlan]"));
-                       return;
+                       return (hdrlen + length);
                }
                if (ndo->ndo_eflag) {
                        uint16_t tag = EXTRACT_16BITS(p);
@@ -194,6 +199,7 @@ recurse:
                p += 4;
                length -= 4;
                caplen -= 4;
+               hdrlen += 4;
                goto recurse;
        } else if (ether_type == ETHERTYPE_JUMBO) {
                /*
@@ -206,18 +212,14 @@ recurse:
                 * there's an LLC header and payload.
                 */
                /* Try to print the LLC-layer header & higher layers */
-               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) {
-                               if (print_encap_header != NULL)
-                                       (*print_encap_header)(ndo, encap_header_arg);
-                               ether_hdr_print(ndo, (u_char *)ep, orig_length);
-                       }
-
+               llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep));
+               if (llc_hdrlen < 0) {
+                       /* packet type not known, print raw packet */
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
+                       llc_hdrlen = -llc_hdrlen;
                }
+               hdrlen += llc_hdrlen;
        } else {
                if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
                        /* ether_type not known, print raw packet */
@@ -231,6 +233,7 @@ recurse:
                                ND_DEFAULTPRINT(p, caplen);
                }
        }
+       return (hdrlen);
 }
 
 /*
@@ -243,9 +246,7 @@ u_int
 ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
                const u_char *p)
 {
-       ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
-
-       return (ETHER_HDRLEN);
+       return (ether_print(ndo, p, h->len, h->caplen, NULL, NULL));
 }
 
 /*
@@ -270,9 +271,7 @@ netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
        }
 
        /* Skip the pseudo-header. */
-       ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
-
-       return (4 + ETHER_HDRLEN);
+       return (4 + ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL));
 }
 
 /*
@@ -300,9 +299,7 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
        }
 
        /* Skip the pseudo-header, preamble, and SOF. */
-       ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
-
-       return (12 + ETHER_HDRLEN);
+       return (12 + ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL));
 }
 
 /*
index ad760c851f384663aebde1256c268c78ad9e64f5..fbda09d7a9f31ef9336ba8ae9281e5d1cecc536a 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -259,17 +258,11 @@ fddi_hdr_print(netdissect_options *ndo,
        srcname = etheraddr_string(ndo, fsrc);
        dstname = etheraddr_string(ndo, fdst);
 
-       if (ndo->ndo_vflag)
-               ND_PRINT((ndo, "%02x %s %s %d: ",
-                      fddip->fddi_fc,
-                      srcname, dstname,
-                      length));
-       else if (ndo->ndo_qflag)
-               ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
-       else {
+       if (!ndo->ndo_qflag)
                print_fddi_fc(ndo, fddip->fddi_fc);
-               ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
-       }
+       ND_PRINT((ndo, "%s > %s, length %u: ",
+              srcname, dstname,
+              length));
 }
 
 static inline void
@@ -278,16 +271,16 @@ fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_)
        ND_PRINT((ndo, "<SMT printer not yet implemented>"));
 }
 
-void
+u_int
 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;
+       int llc_hdrlen;
 
        if (caplen < FDDI_HDRLEN) {
                ND_PRINT((ndo, "[|fddi]"));
-               return;
+               return (caplen);
        }
 
        /*
@@ -306,32 +299,29 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
        /* 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(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
-                   &extracted_ethertype) == 0) {
+               llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr));
+               if (llc_hdrlen < 0) {
                        /*
                         * Some kinds of LLC packet we cannot
                         * handle intelligently
                         */
-                       if (!ndo->ndo_eflag)
-                               fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN,
-                                   ESRC(&ehdr), EDST(&ehdr));
-                       if (extracted_ethertype) {
-                               ND_PRINT((ndo, "(LLC %s) ",
-                       etherproto_string(htons(extracted_ethertype))));
-                       }
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
+                       llc_hdrlen = -llc_hdrlen;
                }
-       } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
+       } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) {
                fddi_smt_print(ndo, p, caplen);
-       else {
+               llc_hdrlen = 0;
+       } else {
                /* Some kinds of FDDI packet we cannot handle intelligently */
                if (!ndo->ndo_eflag)
                        fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
                            EDST(&ehdr));
                if (!ndo->ndo_suppress_default_print)
                        ND_DEFAULTPRINT(p, caplen);
+               llc_hdrlen = 0;
        }
+       return (FDDI_HDRLEN + llc_hdrlen);
 }
 
 /*
@@ -343,7 +333,5 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 u_int
 fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
-       fddi_print(ndo, p, h->len, h->caplen);
-
-       return (FDDI_HDRLEN);
+       return (fddi_print(ndo, p, h->len, h->caplen));
 }
index 7dbac817d55ca876309fbdb640be9dee22fe2cfb..6626e31f98e2af361684cee4c94e908d6dad78c7 100644 (file)
@@ -14,7 +14,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -187,26 +186,28 @@ static const struct tok ForCES_LFBs[] = {
        {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),
@@ -1198,7 +1199,9 @@ otlv_print(netdissect_options *ndo,
        }
 
        /* XXX - do anything with ops->flags? */
-       rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
+        if(ops->print) {
+                rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
+        }
        return rc;
 
 trunc:
index 0832522ce3c1de014da07640e7dc9e634e0cd3b1..17321b1459e3cb6d9d302786129ead6b7449a77c 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -331,7 +330,7 @@ fr_print(netdissect_options *ndo,
                break;
 
        case NLPID_SNAP:
-               if (snap_print(ndo, p, length, length, 0) == 0) {
+               if (snap_print(ndo, p, length, length, NULL, NULL, 0) == 0) {
                        /* ether_type not known, print raw packet */
                         if (!ndo->ndo_eflag)
                             fr_hdr_print(ndo, length + hdr_len, hdr_len,
index 1290952885587d9971339c03b93f2d80f9fd252f..53dafb4c81f27db1710b8c77cfa614bfa8542016 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 2187ab8e528f12f1a2d98bd089125c0acbc11be9..56b9f2b58db16d2c54d1b7ceb89b27c04e495f89 100644 (file)
@@ -15,7 +15,6 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index edfb7f2d6c0e359d929b8fb3926e169cd9bb76f4..6daf8b1d7e500ae09885a2b11be9dbee0182b864 100644 (file)
@@ -15,7 +15,6 @@
  * Original code by Ola Martin Lykkja ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 4d7705f80edca018fa25b76862d035582a8306ff..ec2095561a2867af29b86018bb71c6a44ba3a14c 100644 (file)
@@ -36,7 +36,6 @@
  * RFC1701 (GRE), RFC1702 (GRE IPv4), and RFC2637 (Enhanced GRE)
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 0e2420f712762934c61fc9cb26823199cef380a9..35272b941115874ceb2179cc3214937df3ca4a21 100644 (file)
@@ -29,7 +29,6 @@
 
 /* Cisco Hot Standby Router Protocol (HSRP). */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 59eb007707e0eba1f35eaba9733142e820c70400..e70398767dc7ee9daf093221842b6a0b5b106bab 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 81563e6c81389308823b0de6a916cf973ca5ea8e..f6907a4c24abbc9d78e959fc6980c186a70bc07e 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index e4808a77861a2cd04416003e38d8080084df28c8..d3a685aa9b970191d9b889d9c746d7e49e052aec 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index fbb313427c72026ce5795ec508fe9618e33c48a7..7f4f1302c3d6875183bf14f90aa5d80044f309ca 100644 (file)
@@ -21,7 +21,6 @@
  * Initial contribution from Francis Dupont ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index ceea5363f28b3b00b5a8923b5f498028cad034cb..dddb5965ec2ad19936df52d83bb12e9c54e533bc 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index dd6b7f5105adb6037059988ca943547d566d14bf..fa4619261360666346c29de5b22c1d60af55f0a7 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 14ad42c3c99a6502fd26ddb2467d16d1306db30f..355c37a584b619dae9be1045c73a0577ab37202e 100644 (file)
@@ -27,7 +27,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 1ba687e843e0524baf48a4c5ae3a7c6d8c083b90..2504bfd9ae93511900f15130fe68f64e5c7930ce 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 295ac0fdab3d4e568171bc533babf9e792a743f6..93b00f284699da57a97c1a2864c8bedc9b907dee 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -74,19 +73,19 @@ ipfc_hdr_print(netdissect_options *ndo,
        /*
         * XXX - show the upper 16 bits?  Do so only if "vflag" is set?
         */
-       ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
+       ND_PRINT((ndo, "%s > %s, length %u: ", srcname, dstname, length));
 }
 
-static void
+static u_int
 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;
+       int llc_hdrlen;
 
        if (caplen < IPFC_HDRLEN) {
                ND_PRINT((ndo, "[|ipfc]"));
-               return;
+               return (caplen);
        }
        /*
         * Get the network addresses into a canonical form
@@ -102,22 +101,17 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
        caplen -= IPFC_HDRLEN;
 
        /* Try to print the LLC-layer header & higher layers */
-       if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
-           &extracted_ethertype) == 0) {
+       llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr));
+       if (llc_hdrlen < 0) {
                /*
                 * Some kinds of LLC packet we cannot
                 * handle intelligently
                 */
-               if (!ndo->ndo_eflag)
-                       ipfc_hdr_print(ndo, ipfcp, length + IPFC_HDRLEN,
-                           ESRC(&ehdr), EDST(&ehdr));
-               if (extracted_ethertype) {
-                       ND_PRINT((ndo, "(LLC %s) ",
-               etherproto_string(htons(extracted_ethertype))));
-               }
                if (!ndo->ndo_suppress_default_print)
                        ND_DEFAULTPRINT(p, caplen);
+               llc_hdrlen = -llc_hdrlen;
        }
+       return (IPFC_HDRLEN + llc_hdrlen);
 }
 
 /*
@@ -129,7 +123,5 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 u_int
 ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
-       ipfc_print(ndo, p, h->len, h->caplen);
-
-       return (IPFC_HDRLEN);
+       return (ipfc_print(ndo, p, h->len, h->caplen));
 }
index c4ff16aba2f6daf29dbb38113fbe28e83a7c179f..6abc5c8008b474364cb5b826138424b8740ca6ac 100644 (file)
@@ -1,4 +1,3 @@
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 93f5d595586217befdc30b77b6040befb38bbc45..12ec7dcf454c1383313feb8757ad47e58ed50f54 100644 (file)
@@ -22,7 +22,6 @@
  * Contributed by Brad Parker ([email protected]).
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index bef0b45ef7f955543a0cf32dbe62973b1c823787..5267ad2499b0e56049424a7829becb6326b4f316 100644 (file)
@@ -28,7 +28,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index bd109ab9ad2eaf9d5f24d460282747363705048c..d29165620f4cca54709dbf3285d25e31b456820d 100644 (file)
@@ -24,7 +24,6 @@
  * complete IS-IS & CLNP support.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -3081,15 +3080,31 @@ osi_print_cksum(netdissect_options *ndo,
 {
         uint16_t calculated_checksum;
 
-        /* do not attempt to verify the checksum if it is zero */
-        if (!checksum) {
-                ND_PRINT((ndo, "(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 {
+                const 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) {
                         ND_PRINT((ndo, " (correct)"));
                 } else {
-                        ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
+                        truncated = "incorrect";
+#if 0
+                        trunc:
+#endif
+                        ND_PRINT((ndo, " (%s should be 0x%04x)", truncated, calculated_checksum));
                 }
         }
 }
index e4bb77c9d7a35e44fee76132e02fe74c26804b21..6ae5b6d8d19619a6bdbe5497d60a8f315e5caf5c 100644 (file)
@@ -20,7 +20,6 @@
 __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
@@ -920,7 +919,7 @@ u_int
 juniper_atm1_print(netdissect_options *ndo,
                    const struct pcap_pkthdr *h, register const u_char *p)
 {
-        uint16_t extracted_ethertype;
+        int llc_hdrlen;
 
         struct juniper_l2info_t l2info;
 
@@ -938,8 +937,8 @@ juniper_atm1_print(netdissect_options *ndo,
         if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
             EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
 
-            if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL,
-                          &extracted_ethertype) != 0)
+            llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
+            if (llc_hdrlen > 0)
                 return l2info.header_len;
         }
 
@@ -969,7 +968,7 @@ u_int
 juniper_atm2_print(netdissect_options *ndo,
                    const struct pcap_pkthdr *h, register const u_char *p)
 {
-        uint16_t extracted_ethertype;
+        int llc_hdrlen;
 
         struct juniper_l2info_t l2info;
 
@@ -987,8 +986,8 @@ juniper_atm2_print(netdissect_options *ndo,
         if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
             EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
 
-            if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL,
-                          &extracted_ethertype) != 0)
+            llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
+            if (llc_hdrlen > 0)
                 return l2info.header_len;
         }
 
index 2eebfa69bb83d0c254871ee7186187d0dccf11b2..3b4798c6eeea7722176bdd8ae03c66c93a8748cc 100644 (file)
@@ -21,7 +21,6 @@
  * Initial contribution from John Hawkinson ([email protected]).
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 346dae9d52c661b12ae181697affd5e6fd02ebae..4ebc35ee16e953a901b920e7ac5f196ab8ed2b6b 100644 (file)
@@ -21,7 +21,6 @@
  * L2TP support contributed by Motonori Shindo ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index c1e0b2e8e11f36cc9b0b502e8f41ce9d9ac3ed83..1f10fab14046a3f634f6dfc50b88c9601630fb6e 100644 (file)
@@ -20,7 +20,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 3f741d136ce45d510ef9d1e9d2b3cff9d4d2ddd7..cf421c436972fad433739a5181617e25e04dfa49 100644 (file)
@@ -14,7 +14,6 @@
  *  and Steinar Haug ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index e8a3314c5c79b9c305c06736fefc72b4a88b383e..1398e99624eb0d8a2eac50c32d405ea73d08adee 100644 (file)
@@ -22,7 +22,6 @@
  *     with an awful lot of hacking by Jeffrey Mogul, DECWRL
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -138,23 +137,31 @@ static const struct oui_tok oui_to_tok[] = {
 };
 
 /*
- * Returns non-zero IFF it succeeds in printing the header
+ * If we printed information about the payload, returns the length of the LLC
+ * header, plus the length of any SNAP header following it.
+ *
+ * Otherwise (for example, if the packet has unknown SAPs or has a SNAP
+ * header with an unknown OUI/PID combination), returns the *negative*
+ * of that value.
  */
 int
 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)
+         const u_char *esrc, const u_char *edst)
 {
        uint8_t dsap_field, dsap, ssap_field, ssap;
        uint16_t control;
+       u_int hdrlen;
        int is_u;
-       register int ret;
-
-       *extracted_ethertype = 0;
 
-       if (caplen < 3 || length < 3) {
+       if (caplen < 3) {
                ND_PRINT((ndo, "[|llc]"));
                ND_DEFAULTPRINT((u_char *)p, caplen);
-               return (1);
+               return (caplen);
+       }
+       if (length < 3) {
+               ND_PRINT((ndo, "[|llc]"));
+               ND_DEFAULTPRINT((u_char *)p, caplen);
+               return (length);
        }
 
        dsap_field = *p;
@@ -172,15 +179,21 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                 * U frame.
                 */
                is_u = 1;
+               hdrlen = 3;     /* DSAP, SSAP, 1-byte control field */
        } else {
                /*
                 * The control field in I and S frames is
                 * 2 bytes...
                 */
-               if (caplen < 4 || length < 4) {
+               if (caplen < 4) {
                        ND_PRINT((ndo, "[|llc]"));
                        ND_DEFAULTPRINT((u_char *)p, caplen);
-                       return (1);
+                       return (caplen);
+               }
+               if (length < 4) {
+                       ND_PRINT((ndo, "[|llc]"));
+                       ND_DEFAULTPRINT((u_char *)p, caplen);
+                       return (length);
                }
 
                /*
@@ -188,6 +201,7 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                 */
                control = EXTRACT_LE_16BITS(p + 2);
                is_u = 0;
+               hdrlen = 4;     /* DSAP, SSAP, 2-byte control field */
        }
 
        if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
@@ -210,7 +224,7 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                ND_PRINT((ndo, "IPX 802.3: "));
 
             ipx_print(ndo, p, length);
-            return (1);
+            return (0);                /* no LLC header */
        }
 
        dsap = dsap_field & ~LLC_IG;
@@ -232,21 +246,47 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                }
        }
 
+       /*
+        * Skip LLC header.
+        */
+       p += hdrlen;
+       length -= hdrlen;
+       caplen -= hdrlen;
+
+       if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP
+           && control == LLC_UI) {
+               /*
+                * XXX - what *is* the right bridge pad value here?
+                * Does anybody ever bridge one form of LAN traffic
+                * over a networking type that uses 802.2 LLC?
+                */
+               if (!snap_print(ndo, p, length, caplen, esrc, edst, 2)) {
+                       /*
+                        * Unknown packet type; tell our caller, by
+                        * returning a negative value, so they
+                        * can print the raw packet.
+                        */
+                       return (-(hdrlen + 5)); /* include LLC and SNAP header */
+               } else
+                       return (hdrlen + 5);    /* include LLC and SNAP header */
+       }
+
        if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D &&
            control == LLC_UI) {
-               stp_print(ndo, p+3, length-3);
-               return (1);
+               stp_print(ndo, p, length);
+               return (hdrlen);
        }
 
        if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
            control == LLC_UI) {
-               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);
+               /*
+                * This is an RFC 948-style IP packet, with
+                * an 802.3 header and an 802.2 LLC header
+                * with the source and destination SAPs being
+                * the IP SAP.
+                */
+               ip_print(ndo, p, length);
+               return (hdrlen);
        }
 
        if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
@@ -255,14 +295,12 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                 * This is an Ethernet_802.2 IPX frame, with an 802.3
                 * header and an 802.2 LLC header with the source and
                 * destination SAPs being the IPX SAP.
-                *
-                * Skip DSAP, LSAP, and control field.
                 */
                 if (ndo->ndo_eflag)
                         ND_PRINT((ndo, "IPX 802.2: "));
 
-               ipx_print(ndo, p+3, length-3);
-               return (1);
+               ipx_print(ndo, p, length);
+               return (hdrlen);
        }
 
 #ifdef TCPDUMP_DO_SMB
@@ -278,37 +316,14 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                 * LLC_S_FMT, set in the first byte of the control field)
                 * and UI frames (whose control field is just 3, LLC_U_FMT).
                 */
-
-               /*
-                * Skip the LLC header.
-                */
-               if (is_u) {
-                       p += 3;
-                       length -= 3;
-               } else {
-                       p += 4;
-                       length -= 4;
-               }
                netbeui_print(ndo, control, p, length);
-               return (1);
+               return (hdrlen);
        }
 #endif
        if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
            && control == LLC_UI) {
-               isoclns_print(ndo, p + 3, length - 3, caplen - 3);
-               return (1);
-       }
-
-       if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP
-           && control == LLC_UI) {
-               /*
-                * XXX - what *is* the right bridge pad value here?
-                * Does anybody ever bridge one form of LAN traffic
-                * over a networking type that uses 802.2 LLC?
-                */
-               ret = snap_print(ndo, p+3, length-3, caplen-3, 2);
-               if (ret)
-                       return (ret);
+               isoclns_print(ndo, p, length, caplen);
+               return (hdrlen);
        }
 
        if (!ndo->ndo_eflag) {
@@ -338,13 +353,12 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                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));
-
-               p += 3;
+                       length + hdrlen));
 
                if ((control & ~LLC_U_POLL) == LLC_XID) {
                        if (*p == LLC_XID_FI) {
                                ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
+                               return (hdrlen);
                        }
                }
        } else {
@@ -353,20 +367,37 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                                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 + hdrlen));
+                       return (hdrlen);        /* no payload to print */
                } else {
                        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 + hdrlen));
+               }
+       }
+       return (-hdrlen);
+}
+
+static const struct tok *
+oui_to_struct_tok(uint32_t orgcode)
+{
+       const struct tok *tok = null_values;
+       const struct oui_tok *otp;
+
+       for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) {
+               if (otp->oui == orgcode) {
+                       tok = otp->tok;
+                       break;
                }
        }
-       return(1);
+       return (tok);
 }
 
 int
-snap_print(netdissect_options *ndo, 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,
+       const u_char *esrc, const u_char *edst, u_int bridge_pad)
 {
        uint32_t orgcode;
        register u_short et;
@@ -379,21 +410,17 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
        et = EXTRACT_16BITS(p + 3);
 
        if (ndo->ndo_eflag) {
-               const struct tok *tok = null_values;
-               const struct oui_tok *otp;
-
-               for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) {
-                       if (otp->oui == orgcode) {
-                               tok = otp->tok;
-                               break;
-                       }
-               }
-               ND_PRINT((ndo, "oui %s (0x%06x), %s %s (0x%04x): ",
+               /*
+                * Somebody's already printed the MAC addresses, if there
+                * are any, so just print the SNAP header, not the MAC
+                * addresses.
+                */
+               ND_PRINT((ndo, "oui %s (0x%06x), %s %s (0x%04x), length %u: ",
                     tok2str(oui_values, "Unknown", orgcode),
                     orgcode,
                     (orgcode == 0x000000 ? "ethertype" : "pid"),
-                    tok2str(tok, "Unknown", et),
-                    et));
+                    tok2str(oui_to_struct_tok(orgcode), "Unknown", et),
+                    et, length - 5));
        }
        p += 5;
        length -= 5;
@@ -522,6 +549,33 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                        return (1);
                }
        }
+       if (!ndo->ndo_eflag) {
+               /*
+                * Nobody printed the MAC addresses, so print them, if
+                * we have any.
+                */
+               if (esrc != NULL && edst != NULL) {
+                       ND_PRINT((ndo, "%s > %s ",
+                               etheraddr_string(ndo, esrc),
+                               etheraddr_string(ndo, edst)));
+               }
+               /*
+                * Print the SNAP header, but if the OUI is 000000, don't
+                * bother printing it, and report the PID as being an
+                * ethertype.
+                */
+               if (orgcode == 0x000000) {
+                       ND_PRINT((ndo, "SNAP, ethertype %s (0x%04x), length %u: ",
+                            tok2str(ethertype_values, "Unknown", et),
+                            et, length));
+               } else {
+                       ND_PRINT((ndo, "SNAP, oui %s (0x%06x), pid %s (0x%04x), length %u: ",
+                            tok2str(oui_values, "Unknown", orgcode),
+                            orgcode,
+                            tok2str(oui_to_struct_tok(orgcode), "Unknown", et),
+                            et, length));
+               }
+       }
        return (0);
 
 trunc:
index ce3c09382a651fa9711f8e45dd04c0e5311bd3a0..e4bed732edc3d63882b872755899dc66eb855efc 100644 (file)
@@ -19,7 +19,6 @@
  * DCBX extensions by Kaladhar Musunuru <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 904dd712986e3d2e7bc7eaaa527091bffc0cc904..ca1d5cd05d9a4c5230b705f067d322bdb086a7e0 100644 (file)
@@ -17,7 +17,6 @@
  * by Manu Pathak ([email protected]), May 2005
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 9a74ae611397c537fe32ab5c4968e51ce51747a5..481cf6eef801f68aba4b94075833c3cbf167ca0e 100644 (file)
@@ -30,7 +30,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 888adfafbcdc8bf17c517359de44eff242d15519..ae43fef32034d22b215388857981f11626346153 100644 (file)
@@ -13,7 +13,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 5b8683f76905d266b695a0baee430c6b020aa1eb..a6c05a3977b9b6a4a55123b2d718f7868b21db01 100644 (file)
@@ -17,7 +17,6 @@
  * Original code by Carles Kishimoto <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index d78c9a9068597db5c9143012f12e4228f22b0dd7..c7f04685ec3a7b83eeee64a93c5c08eb2f003c0a 100644 (file)
@@ -27,7 +27,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 33f8777977f856424ee2267e626864d66af24b94..be7a30a4615bc28015f2e409118bf6f0a77d9f89 100644 (file)
@@ -22,7 +22,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index df412eeb289799e6f8801b0692c612c1382ff83d..b61d0f5dcdd9df73f0dd4544497523e386e6b856 100644 (file)
@@ -36,7 +36,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 83447cff15d4190f904af197f564d013168622a8..787d04092a1a165a761fb487bf5c0fb1e16f5cdb 100644 (file)
@@ -27,7 +27,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -69,11 +68,30 @@ struct ip6_mobility {
 #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
 
-/* XXX: unused */
-#define IP6MOPT_BU_MINLEN      10
-#define IP6MOPT_BA_MINLEN      13
-#define IP6MOPT_BR_MINLEN      2
+static const struct tok ip6m_str[] = {
+       { IP6M_BINDING_REQUEST,  "BRR"  },
+       { IP6M_HOME_TEST_INIT,   "HoTI" },
+       { IP6M_CAREOF_TEST_INIT, "CoTI" },
+       { IP6M_HOME_TEST,        "HoT"  },
+       { IP6M_CAREOF_TEST,      "CoT"  },
+       { IP6M_BINDING_UPDATE,   "BU"   },
+       { IP6M_BINDING_ACK,      "BA"   },
+       { IP6M_BINDING_ERROR,    "BE"   },
+       { 0, NULL }
+};
+
+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    */
+};
 
 /* Mobility Header Options */
 #define IP6MOPT_MINLEN         2
@@ -95,16 +113,20 @@ mobility_opt_print(netdissect_options *ndo,
        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:
@@ -203,15 +225,17 @@ mobility_print(netdissect_options *ndo,
 
        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;
+       }
+       ND_PRINT((ndo, "mobility: %s", tok2str(ip6m_str, "type-#%u", type)));
        switch (type) {
        case IP6M_BINDING_REQUEST:
-               ND_PRINT((ndo, "mobility: BRR"));
                hlen = IP6M_MINLEN;
                break;
        case IP6M_HOME_TEST_INIT:
        case IP6M_CAREOF_TEST_INIT:
-               ND_PRINT((ndo, "mobility: %soTI",
-                       type == IP6M_HOME_TEST_INIT ? "H" : "C"));
                hlen = IP6M_MINLEN;
                if (ndo->ndo_vflag) {
                        ND_TCHECK2(*mh, hlen + 8);
@@ -224,8 +248,6 @@ mobility_print(netdissect_options *ndo,
                break;
        case IP6M_HOME_TEST:
        case IP6M_CAREOF_TEST:
-               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;
@@ -247,7 +269,6 @@ mobility_print(netdissect_options *ndo,
                hlen += 8;
                break;
        case IP6M_BINDING_UPDATE:
-               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;
@@ -272,7 +293,6 @@ mobility_print(netdissect_options *ndo,
                hlen += 2;
                break;
        case IP6M_BINDING_ACK:
-               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)
@@ -288,7 +308,6 @@ mobility_print(netdissect_options *ndo,
                hlen += 2;
                break;
        case IP6M_BINDING_ERROR:
-               ND_PRINT((ndo, "mobility: BE"));
                ND_TCHECK(mh->ip6m_data8[0]);
                ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
                /* Reserved */
@@ -298,7 +317,7 @@ mobility_print(netdissect_options *ndo,
                hlen += 16;
                break;
        default:
-               ND_PRINT((ndo, "mobility: type-#%u len=%u", type, mh->ip6m_len));
+               ND_PRINT((ndo, " len=%u", mh->ip6m_len));
                return(mhlen);
                break;
        }
index 9da3582d540919237f2a64e866db54c9629de600..e2b6c394f2d9ef2696dbe143c8dc41f58d6865f5 100644 (file)
@@ -17,7 +17,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index bc34d50623d3e0e6c066585174981ccd81287f30..03ff1b3ee4b5ecc660e0b076f89add533317db31 100644 (file)
@@ -26,7 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index f85f1d24a886c3e2361b0bbdc20856625e68ac98..947ffc4ffa4d8c397e323fabf6367a9465508fc5 100644 (file)
@@ -32,7 +32,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index fb802b58fd4dff387fd65434ade35a24eabd021d..16abc3ecb71f3005209e0571824c5a709c0bbc13 100644 (file)
@@ -16,7 +16,6 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index fcd0006482687850fae573e303beb9604209256a..840892107a72af5fd3aac9c4fb19eeb8b4d28374 100644 (file)
@@ -26,7 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 95da4cba4f2dba97b6797e06fd5953ffdb4cb7ae..a29b930cb30f25ea4c01a57cc34efb9c1208a484 100644 (file)
@@ -25,7 +25,6 @@
  * DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index dd2f7f12fd2b8033b3e62c29a729a880aff67ac2..e5f081a492b20b8151a8343d8adcb9d3cd8bfaf2 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index e83d47a7dd58db4b0d478a47398f1d8f22865d27..c3ea82b6abe794aa1adccf88b779ca52258487c7 100644 (file)
@@ -23,7 +23,6 @@
  *     loosely based on print-bootp.c
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 166f777dee2b24b660950fbd201b7ef171308c4f..8801e7b7ab330c970e5c7c852798380612767026 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index b90eea1aa3047a3569a0affdb99b80d802e07439..737273135268ce3c385e66600f0147da640d0d1d 100644 (file)
@@ -19,7 +19,6 @@
  * IPv6 additions by Florian Forster <octo at verplant.org>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index a36c32f3b29a3457351461b2632ae881be6ba1d6..9fb0f635cc7bbdefd9619c861b882d32a3069430 100644 (file)
@@ -56,7 +56,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 8825ae3d5c8714a72fc559536f00d59ebf0bf55c..0563edead79b3ea76bfa3aaccec615b26839c75b 100644 (file)
@@ -30,7 +30,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 3583417ad54c39b468479034acf947323278516e..3e0d03c564de963042cfd32214fe89ae44a6d4a3 100644 (file)
@@ -21,7 +21,6 @@
  * OSPF support contributed by Jeffrey Honig ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 49210bc04dc5ace87248d458ea68ee225ecf809f..0d25baaca83d8b33d2ac62af5d256e9c12d8fc2c 100644 (file)
@@ -21,7 +21,6 @@
  * OSPF support contributed by Jeffrey Honig ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 53a79dea5db1a5e1f10306952a9ba5125fcdc0c6..3255ddb07e65eaaf1193460ada9bb5995e503dda 100644 (file)
@@ -13,7 +13,6 @@
  * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 72ae276320ce9a18ee669ff582cfb69e972616c5..0df10c84163ad478cab557cbdd7f56d383c96004 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 6a8342539f477707d8d4dc05deb62d1c8c29b22f..58aa34695da88dac8bd41e0f73b62659253b47f2 100644 (file)
@@ -13,7 +13,6 @@
  * Original code by Andy Heffernan ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 15f4c51300e880b8fc447b5a5bf0cb9f1ff0ecaf..a8bcdcf81fa6c5f1bed9a03aba7f079cca4b4f3a 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index e376cc6e6ab96c7336bdc2dc448fbcb1509ae140..9fa6b5634827a7490d7bc7b1e2c7dfa8e5780664 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -141,7 +140,7 @@ pktap_if_print(netdissect_options *ndo,
 
        case PKT_REC_PACKET:
                if ((printer = lookup_printer(dlt)) != NULL) {
-                       printer(ndo, h, p);
+                       hdrlen += printer(ndo, h, p);
                } else {
                        if (!ndo->ndo_eflag)
                                pktap_header_print(ndo, (u_char *)hdr,
index 06678b0f65aaa86acafd0e1c5a807cef98a0b0b0..dde1cdb0be51de95ade781f047080e64c99aa86c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Oracle
  */
-#define NETDISSECT_REWORKED
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -45,7 +45,7 @@ ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
        ND_PRINT((ndo, ", length %u: ", length));
 }
 
-static void
+static u_int
 ppi_print(netdissect_options *ndo,
                const struct pcap_pkthdr *h, const u_char *p)
 {
@@ -55,21 +55,26 @@ ppi_print(netdissect_options *ndo,
        u_int length = h->len;
        uint16_t len;
        uint32_t dlt;
+       uint32_t hdrlen;
 
        if (caplen < sizeof(ppi_header_t)) {
                ND_PRINT((ndo, "[|ppi]"));
-               return;
+               return (caplen);
        }
 
        hdr = (ppi_header_t *)p;
        len = EXTRACT_LE_16BITS(&hdr->ppi_len);
-       if (len < sizeof(ppi_header_t)) {
+       if (caplen < len) {
+               /*
+                * If we don't have the entire PPI header, don't
+                * bother.
+                */
                ND_PRINT((ndo, "[|ppi]"));
-               return;
+               return (caplen);
        }
-       if (caplen < len) {
+       if (len < sizeof(ppi_header_t)) {
                ND_PRINT((ndo, "[|ppi]"));
-               return;
+               return (len);
        }
        dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
 
@@ -81,14 +86,16 @@ ppi_print(netdissect_options *ndo,
        p += len;
 
        if ((printer = lookup_printer(dlt)) != NULL) {
-               printer(ndo, h, p);
+               hdrlen = printer(ndo, h, p);
        } else {
                if (!ndo->ndo_eflag)
                        ppi_header_print(ndo, (u_char *)hdr, length + len);
 
                if (!ndo->ndo_suppress_default_print)
                        ND_DEFAULTPRINT(p, caplen);
+               hdrlen = 0;
        }
+       return (len + hdrlen);
 }
 
 /*
@@ -101,9 +108,7 @@ u_int
 ppi_if_print(netdissect_options *ndo,
                const struct pcap_pkthdr *h, const u_char *p)
 {
-       ppi_print(ndo, h, p);
-
-       return (sizeof(ppi_header_t));
+       return (ppi_print(ndo, h, p));
 }
 
 /*
index edc03c021c4e27a43eccad12b6475f6f7e62c9b8..d9bca84c511082cedacd78b702373af2c4b596cf 100644 (file)
@@ -29,7 +29,6 @@
  * o BAP support
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 1624c5e50f3b26fbe03191141d9faec5a289e521..8a2870a9517dfd23fb258271551dcf9e4c031725 100644 (file)
@@ -21,7 +21,6 @@
  * Original code by Greg Stark <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index c77868d46256e0f9bf3327f4a4fbb918e1f6c026..1691dc6a17154975f9feb6a6cde8a70dc0ce0eb6 100644 (file)
@@ -21,7 +21,6 @@
  * PPTP support contributed by Motonori Shindo ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 5cf8ad2b6f805aa5939873c4ad3be7b5eeb4600e..c66c79381edfe602dab649e4a4e9831c06d66eb0 100644 (file)
@@ -48,7 +48,6 @@
  * TODO: Among other things to print ok MacIntosh and Vendor values
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index d20387c644c9149502615c601b763b42c61b9772..74d63639958937045b30717ba09d4d161122e9d5 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index c1b036e442f36667afba8db6cd00f0d0658aea92..e76c56f6e00562c2d7a2f1114ed315d15d84eade 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 4bc900d105ac6a8a58c6a5eb383d94ebd9ee2135..a0318d15b07ff4a04d082640b3337d29d0405672 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 101e41dafbbe39f532f087cb7d840c7e1e05667e..c9c4e0ab13477835e973625b7a2b1b88d190ec04 100644 (file)
@@ -17,7 +17,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -178,6 +177,7 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
     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;
 
     ND_PRINT((ndo, "%sRPKI-RTRv%u, %s PDU (%u), length: %u",
@@ -250,10 +250,10 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
        {
            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);
@@ -286,10 +286,10 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
                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';
-               ND_PRINT((ndo, "%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;
@@ -306,6 +306,11 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
     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
@@ -330,13 +335,13 @@ rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_
        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;
         }
 
-        ND_TCHECK2(*tptr, pdu_len);
         if (tlen < pdu_len) {
             goto trunc;
         }
index 2370d9c20e254aeeffec3850123a0d9a73e3b714..cb1779557723b759bf2c37c857bb2819b3dff359 100644 (file)
@@ -21,7 +21,6 @@
  * and Realtek Echo Protocol (RRCP-REP) packets.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 263ef3d4656ac1f3d5d036ed36f930c36822ef68..2c510f30cda03574dce2740a5fe60f83948d7e7e 100644 (file)
@@ -15,7 +15,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 3d5f9e3721a10d6c627309a53293dd9f14506cdb..baa6945e4daf0ed8d63f583ba81bb3aaca3fa228 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 8a9babbc1f0f6efcd93158e1f22aaedaa2219b13..d2935a461eae57992ef1b9dd75a8f573905a9ea3 100644 (file)
@@ -32,7 +32,6 @@
  * Ken Hornstein <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 4b595f2e825e268473e769b96cc9e373b28f39ed..d48202f50326b5cfa22ece83eefbcb127a0a032c 100644 (file)
@@ -33,7 +33,6 @@
  * SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 24112f44ad1b1e37816212cd31984c5e0401f444..708f76052a115ab8bc7a88c062bf3f802b9a2ad5 100644 (file)
@@ -19,7 +19,6 @@
  * Expansion and refactoring by Rick Jones <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index d0fd349f25e7e0acffcbe310cd55d9bf69d5b8c6..5c5d1fec7d3c2ffc827cd5dc3b715bff9d0aa098 100644 (file)
@@ -15,7 +15,6 @@
  * Guy Harris.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index bd410ce21a28ff49e0128c4022645cae73e5fa07..cdf9945594446ad560c4a9588d4dc37b56e00ed9 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 1f5f60084a20441ce34f6add5e65c2e915aa2b89..e3e6ec96e28865b13205d7af2e2e042d989a97eb 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -198,7 +197,8 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
        u_int length = h->len;
        register const struct sll_header *sllp;
        u_short ether_type;
-       u_short extracted_ethertype;
+       int llc_hdrlen;
+       u_int hdrlen;
 
        if (caplen < SLL_HDR_LEN) {
                /*
@@ -221,6 +221,7 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
        length -= SLL_HDR_LEN;
        caplen -= SLL_HDR_LEN;
        p += SLL_HDR_LEN;
+       hdrlen = SLL_HDR_LEN;
 
        ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
 
@@ -247,23 +248,17 @@ recurse:
                         * 802.2.
                         * Try to print the LLC-layer header & higher layers.
                         */
-                       if (llc_print(ndo, p, length, caplen, NULL, NULL,
-                           &extracted_ethertype) == 0)
+                       llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+                       if (llc_hdrlen < 0)
                                goto unknown;   /* unknown LLC type */
+                       hdrlen += llc_hdrlen;
                        break;
 
                default:
-                       extracted_ethertype = 0;
                        /*FALLTHROUGH*/
 
                unknown:
-                       /* ether_type not known, print raw packet */
-                       if (!ndo->ndo_eflag)
-                               sll_print(ndo, sllp, length + SLL_HDR_LEN);
-                       if (extracted_ethertype) {
-                               ND_PRINT((ndo, "(LLC %s) ",
-                              etherproto_string(htons(extracted_ethertype))));
-                       }
+                       /* packet type not known, print raw packet */
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
                        break;
@@ -273,9 +268,13 @@ recurse:
                 * Print VLAN information, and then go back and process
                 * the enclosed type field.
                 */
-               if (caplen < 4 || length < 4) {
+               if (caplen < 4) {
+                       ND_PRINT((ndo, "[|vlan]"));
+                       return (hdrlen + caplen);
+               }
+               if (length < 4) {
                        ND_PRINT((ndo, "[|vlan]"));
-                       return (SLL_HDR_LEN);
+                       return (hdrlen + length);
                }
                if (ndo->ndo_eflag) {
                        uint16_t tag = EXTRACT_16BITS(p);
@@ -293,6 +292,7 @@ recurse:
                p += 4;
                length -= 4;
                caplen -= 4;
+               hdrlen += 4;
                goto recurse;
        } else {
                if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
@@ -304,5 +304,5 @@ recurse:
                }
        }
 
-       return (SLL_HDR_LEN);
+       return (hdrlen);
 }
index 2db3581e2bf76953bd32a95d0f610596c8545e0c..968534e5c9b06e52e581e1b3badfd067d06df536 100644 (file)
@@ -18,7 +18,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index f5be9ffc4428f7279a3a7e3b29ba60c9a0b0ebd3..b8c5d9d539dce92eeb93f44b51e0a3613124a441 100644 (file)
@@ -6,7 +6,6 @@
  * or later
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index f5501582ba7a3b8aec3455ec7f55a4857ab013fd..04654f4593d55b2b902f7ae18be36ecbde6d9b0f 100644 (file)
@@ -56,7 +56,6 @@
  #     @(#)snmp.awk.x  1.1 (LANL) 1/15/90
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 93bb600028585558bf2ae53f3d8ecd7aea4f5a16..a89932d6580f9fd3e9652396eb80d490419763e7 100644 (file)
@@ -9,7 +9,6 @@
  * Contributed by Lennert Buytenhek <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index fc03d42a47027c9f47b4fe6f5e35991fbee06818..d22e83a43d9dd8bb82fd3e7067f6651106461610 100644 (file)
@@ -30,7 +30,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index bc7138de5d53c3acfbdeeac275b5dc8ff4af7f8b..1bca04e49ec0507c196a8235b3a24039e270a456 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index dcff2a66bf05d1aba6521bb4c2f62d837e3703d6..665dbcc290318a5b7d7e0d5a16127efcbf498489 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 5e3cd4f70fe07ddab8f24eb746521b3416d40c1b..2d48181502a600730d3da714b8626aef82bfd1c5 100644 (file)
@@ -14,7 +14,6 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index bc200e2f8e21a5d243985e2a5ed3eae0b93f7aec..5c979235e6fe19f2612ff510c52731a0c29898e6 100644 (file)
@@ -28,7 +28,6 @@
 __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
@@ -64,6 +63,8 @@ static int tcp_verify_signature(netdissect_options *ndo,
 #endif
 
 static void print_tcp_rst_data(netdissect_options *, register const u_char *sp, u_int length);
+static void print_tcp_fastopen_option(netdissect_options *ndo, register const u_char *cp,
+                                      u_int datalen, int exp);
 
 #define MAX_RST_DATA_LEN       30
 
@@ -135,6 +136,7 @@ static const struct tok tcp_option_values[] = {
         { TCPOPT_AUTH, "enhanced auth" },
         { TCPOPT_UTO, "uto" },
         { TCPOPT_MPTCP, "mptcp" },
+        { TCPOPT_FASTOPEN, "tfo" },
         { TCPOPT_EXPERIMENT2, "exp" },
         { 0, NULL }
 };
@@ -584,6 +586,12 @@ tcp_print(netdissect_options *ndo,
                                         goto bad;
                                 break;
 
+                        case TCPOPT_FASTOPEN:
+                                datalen = len - 2;
+                                LENCHECK(datalen);
+                                print_tcp_fastopen_option(ndo, cp, datalen, FALSE);
+                                break;
+
                         case TCPOPT_EXPERIMENT2:
                                 datalen = len - 2;
                                 LENCHECK(datalen);
@@ -595,21 +603,8 @@ tcp_print(netdissect_options *ndo,
 
                                 switch(magic) {
 
-                                case 0xf989:
-                                        /* TCP Fast Open: RFC 7413 */
-                                        if (datalen == 2) {
-                                                /* Fast Open Cookie Request */
-                                                ND_PRINT((ndo, "tfo cookiereq"));
-                                        } else {
-                                                /* Fast Open Cookie */
-                                                if (datalen % 2 != 0 || datalen < 6 || datalen > 18) {
-                                                        ND_PRINT((ndo, "tfo malformed"));
-                                                } else {
-                                                        ND_PRINT((ndo, "tfo cookie "));
-                                                        for (i = 2; i < datalen; ++i)
-                                                                ND_PRINT((ndo, "%02x", cp[i]));
-                                                }
-                                        }
+                                case 0xf989: /* TCP Fast Open RFC 7413 */
+                                        print_tcp_fastopen_option(ndo, cp + 2, datalen - 2, TRUE);
                                         break;
 
                                 default:
@@ -797,6 +792,30 @@ print_tcp_rst_data(netdissect_options *ndo,
         ND_PRINT((ndo, "]"));
 }
 
+static void
+print_tcp_fastopen_option(netdissect_options *ndo, register const u_char *cp,
+                          u_int datalen, int exp)
+{
+        u_int i;
+
+        if (exp)
+                ND_PRINT((ndo, "tfo"));
+
+        if (datalen == 0) {
+                /* Fast Open Cookie Request */
+                ND_PRINT((ndo, " cookiereq"));
+        } else {
+                /* Fast Open Cookie */
+                if (datalen % 2 != 0 || datalen < 4 || datalen > 16) {
+                        ND_PRINT((ndo, " malformed"));
+                } else {
+                        ND_PRINT((ndo, " cookie "));
+                        for (i = 0; i < datalen; ++i)
+                                ND_PRINT((ndo, "%02x", cp[i]));
+                }
+        }
+}
+
 #ifdef HAVE_LIBCRYPTO
 USES_APPLE_DEPRECATED_API
 static int
index fa59b1fe9531ed794ea411db4129cf1fe34934dd..b3f17ed28791f0ca7d937f4c289bdc5294efad03 100644 (file)
@@ -45,7 +45,6 @@
  *      are preserved in all copies.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 9b88e74f1022767590a3c52fefd9f59fc843c0f6..acb8ca9d6947f25d5de0cbfec35eb1eadd0789f3 100644 (file)
@@ -21,7 +21,6 @@
  * Format and print trivial file transfer protocol packets.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 5830bc7be07781c3e83fc603395a8e6df64d850e..1d8c5804fffd61dc5799b0c542b452116045234b 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index b883fba9fed663440ba2469d1047766197c8d0f4..f75d9f23a6c39f001e24804e571747a17b618574 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index b88bcf7925207540c90547ae18c4f8c6a8cfe813..6bf2b23da8f9272f38fb503bd15518c1dd020b97 100644 (file)
@@ -24,7 +24,6 @@
  *     Guy Harris <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -113,14 +112,13 @@ token_hdr_print(netdissect_options *ndo,
        srcname = etheraddr_string(ndo, fsrc);
        dstname = etheraddr_string(ndo, fdst);
 
-       if (ndo->ndo_vflag)
-               ND_PRINT((ndo, "%02x %02x %s %s %d: ",
+       if (!ndo->ndo_qflag)
+               ND_PRINT((ndo, "%02x %02x ",
                       trp->token_ac,
-                      trp->token_fc,
-                      srcname, dstname,
-                      length));
-       else
-               ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
+                      trp->token_fc));
+       ND_PRINT((ndo, "%s > %s, length %u: ",
+              srcname, dstname,
+              length));
 }
 
 static const char *broadcast_indicator[] = {
@@ -149,7 +147,7 @@ u_int
 token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
        const struct token_header *trp;
-       u_short extracted_ethertype;
+       int llc_hdrlen;
        struct ether_header ehdr;
        u_int route_len = 0, hdr_len = TOKEN_HDRLEN;
        int seg;
@@ -211,20 +209,15 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
        /* 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(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
-                   &extracted_ethertype) == 0) {
-                       /* ether_type not known, print raw packet */
-                       if (!ndo->ndo_eflag)
-                               token_hdr_print(ndo, trp,
-                                   length + TOKEN_HDRLEN + route_len,
-                                   ESRC(&ehdr), EDST(&ehdr));
-                       if (extracted_ethertype) {
-                               ND_PRINT((ndo, "(LLC %s) ",
-                       etherproto_string(htons(extracted_ethertype))));
-                       }
+               llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr),
+                   EDST(&ehdr));
+               if (llc_hdrlen < 0) {
+                       /* packet type not known, print raw packet */
                        if (!ndo->ndo_suppress_default_print)
                                ND_DEFAULTPRINT(p, caplen);
+                       llc_hdrlen = -llc_hdrlen;
                }
+               hdr_len += llc_hdrlen;
        } else {
                /* Some kinds of TR packet we cannot handle intelligently */
                /* XXX - dissect MAC packets if frame type is 0 */
index 15e2bf6fae492f864fae592fe021f2e8a4c6001e..fd6fdf9177fe3f80b60e3e2f1a20736559675833 100644 (file)
@@ -18,7 +18,6 @@
  * Original code by Carles Kishimoto <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index c3edf6ef5de19b855731cd0c30bf07ab6a2d0275..17816121a6c987261ab137db90e8689440729238 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 75f78fc9025a825a4fc3064b768a00ddd4868b4b..d0ad6141c06bafbff6d1bf29ec8edb24b671fb64 100644 (file)
@@ -19,7 +19,6 @@
  *
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 24f8a122c09b92a2b4cf82f5fae8f75037d3bc95..fc7aafa946c1aef2737384a26ce825c1e59307d7 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index ce3572ac520898bb5fc5d281ae7f5b32a3334194..45150b6d56a213a203a55a036fdd908ae3eac893 100644 (file)
@@ -17,7 +17,6 @@
  * Original code by Carles Kishimoto <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index f739d1ed71659cfebc69f3f63a02a8da0e682890..30f89d3419d6a044ff5f30c620f4c4e972415682 100644 (file)
@@ -23,7 +23,6 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 9fe86e3c4bb67cea2775ed3a421d717f776dfe49..b771c643cde914e3117d79f486a70ecb51107441 100644 (file)
@@ -22,7 +22,6 @@
  * Original code ode by Carles Kishimoto <[email protected]>
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index c4de68d5fb4f52793bc25d6b0d1b3599493ab182..c123b4cee4ba41577787bd4516ca61338cab9228 100644 (file)
@@ -13,7 +13,6 @@
  * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 38c2a6727c6cbff449658f8e93d1d76fa349692a..4fa5e3800fbf3b341a212c848fe6a3926ea94e08 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -202,7 +201,7 @@ wb_id(netdissect_options *ndo,
        len -= sizeof(*io) * nid;
        io = (struct id_off *)(id + 1);
        cp = (char *)(io + nid);
-       if (!ND_TTEST2(cp, len)) {
+       if (ND_TTEST2(cp, len)) {
                ND_PRINT((ndo, "\""));
                fn_print(ndo, (u_char *)cp, (u_char *)cp + len);
                ND_PRINT((ndo, "\""));
@@ -267,7 +266,7 @@ wb_prep(netdissect_options *ndo,
        }
        n = EXTRACT_32BITS(&prep->pp_n);
        ps = (const struct pgstate *)(prep + 1);
-       while (--n >= 0 && !ND_TTEST(*ps)) {
+       while (--n >= 0 && ND_TTEST(*ps)) {
                const struct id_off *io, *ie;
                char c = '<';
 
@@ -276,7 +275,7 @@ wb_prep(netdissect_options *ndo,
                    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 && !ND_TTEST(*io); ++io) {
+               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 = ',';
index 8132c49af7a1d928d9b4d5f5319c5b790012bc6c..c004f144860c8859326645420cbb232d4ebd9446 100644 (file)
@@ -20,7 +20,6 @@
  * PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index ba22c96e72ad00a182437a93f176991a47ef15b1..b73020359c98c47dc25a63cba150c3425003e121 100644 (file)
@@ -28,7 +28,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/print.c b/print.c
new file mode 100644 (file)
index 0000000..648a899
--- /dev/null
+++ b/print.c
@@ -0,0 +1,482 @@
+/*
+ * 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.
+ *
+ * Support for splitting captures into multiple files with a maximum
+ * file size:
+ *
+ * Copyright (c) 2001
+ *     Seth Webster <[email protected]>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <tcpdump-stdinc.h>
+
+#include "netdissect.h"
+#include "interface.h"
+#include "addrtoname.h"
+#include "print.h"
+
+struct printer {
+       if_printer f;
+       int type;
+};
+
+static const struct printer printers[] = {
+       { ether_if_print,       DLT_EN10MB },
+#ifdef DLT_IPNET
+       { ipnet_if_print,       DLT_IPNET },
+#endif
+#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 },
+#endif
+#ifdef DLT_ATM_CLIP
+       { cip_if_print,         DLT_ATM_CLIP },
+#endif
+#ifdef DLT_IP_OVER_FC
+       { ipfc_if_print,        DLT_IP_OVER_FC },
+#endif
+       { 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 },
+#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_ETHER
+       { pppoe_if_print,       DLT_PPP_ETHER },
+#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_ENC
+       { enc_if_print,         DLT_ENC },
+#endif
+       { sl_if_print,          DLT_SLIP },
+#ifdef DLT_SLIP_BSDOS
+       { sl_bsdos_if_print,    DLT_SLIP_BSDOS },
+#endif
+#ifdef DLT_LTALK
+       { ltalk_if_print,       DLT_LTALK },
+#endif
+#ifdef DLT_JUNIPER_ATM1
+       { juniper_atm1_print,   DLT_JUNIPER_ATM1 },
+#endif
+#ifdef DLT_JUNIPER_ATM2
+       { juniper_atm2_print,   DLT_JUNIPER_ATM2 },
+#endif
+#ifdef DLT_JUNIPER_MFR
+       { juniper_mfr_print,    DLT_JUNIPER_MFR },
+#endif
+#ifdef DLT_JUNIPER_MLFR
+       { juniper_mlfr_print,   DLT_JUNIPER_MLFR },
+#endif
+#ifdef DLT_JUNIPER_MLPPP
+       { juniper_mlppp_print,  DLT_JUNIPER_MLPPP },
+#endif
+#ifdef DLT_JUNIPER_PPPOE
+       { juniper_pppoe_print,  DLT_JUNIPER_PPPOE },
+#endif
+#ifdef DLT_JUNIPER_PPPOE_ATM
+       { juniper_pppoe_atm_print, DLT_JUNIPER_PPPOE_ATM },
+#endif
+#ifdef DLT_JUNIPER_GGSN
+       { juniper_ggsn_print,   DLT_JUNIPER_GGSN },
+#endif
+#ifdef DLT_JUNIPER_ES
+       { juniper_es_print,     DLT_JUNIPER_ES },
+#endif
+#ifdef DLT_JUNIPER_MONITOR
+       { juniper_monitor_print, DLT_JUNIPER_MONITOR },
+#endif
+#ifdef DLT_JUNIPER_SERVICES
+       { juniper_services_print, DLT_JUNIPER_SERVICES },
+#endif
+#ifdef DLT_JUNIPER_ETHER
+       { juniper_ether_print,  DLT_JUNIPER_ETHER },
+#endif
+#ifdef DLT_JUNIPER_PPP
+       { juniper_ppp_print,    DLT_JUNIPER_PPP },
+#endif
+#ifdef DLT_JUNIPER_FRELAY
+       { juniper_frelay_print, DLT_JUNIPER_FRELAY },
+#endif
+#ifdef DLT_JUNIPER_CHDLC
+       { juniper_chdlc_print,  DLT_JUNIPER_CHDLC },
+#endif
+#ifdef DLT_PKTAP
+       { pktap_if_print,       DLT_PKTAP },
+#endif
+#ifdef DLT_IEEE802_11_RADIO
+       { ieee802_11_radio_if_print,    DLT_IEEE802_11_RADIO },
+#endif
+#ifdef DLT_IEEE802_11
+       { ieee802_11_if_print,  DLT_IEEE802_11},
+#endif
+#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 void    ndo_default_print(netdissect_options *ndo, const u_char *bp,
+                   u_int length);
+
+static void    ndo_error(netdissect_options *ndo _U_, 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 _U_, const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+                   __attribute__((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+                   ;
+
+static int     tcpdump_printf(netdissect_options *ndo _U_, const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+                    __attribute ((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+                    ;
+
+void
+init_print(u_int32_t localnet, u_int32_t mask, uint32_t timezone_offset)
+{
+
+       thiszone = timezone_offset;
+       init_addrtoname(gndo, localnet, mask);
+       init_checksum();
+}
+
+if_printer
+lookup_printer(int type)
+{
+       const struct printer *p;
+
+       for (p = 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 = printers; p->f; ++p)
+                       if (DLT_PKTAP == p->type)
+                               return p->f;
+       }
+#endif
+
+       return NULL;
+       /* NOTREACHED */
+}
+
+int
+has_printer(int type)
+{
+
+       return (lookup_printer(type) != NULL);
+}
+
+struct print_info
+get_print_info(int type)
+{
+       struct print_info printinfo;
+
+       printinfo.ndo = gndo;
+       printinfo.printer = lookup_printer(type);
+       if (printinfo.printer == NULL) {
+               gndo->ndo_dltname = pcap_datalink_val_to_name(type);
+               if (gndo->ndo_dltname != NULL)
+                       error("packet printing is not supported for link type %s: use -w",
+                             gndo->ndo_dltname);
+               else
+                       error("packet printing is not supported for link type %d: use -w", type);
+       }
+       return (printinfo);
+}
+
+void
+pretty_print_packet(struct print_info *print_info, const struct pcap_pkthdr *h,
+    const u_char *sp, u_int packets_captured)
+{
+       u_int hdrlen;
+        netdissect_options *ndo;
+
+        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 member
+        * of the netdissect_options structure.
+        */
+       ndo->ndo_snapend = sp + h->caplen;
+
+        hdrlen = (*print_info->printer)(print_info->ndo, h, sp);
+
+       /*
+        * 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 (ndo->ndo_Xflag > 1) {
+                       /*
+                        * Include the link-layer header.
+                        */
+                       hex_and_ascii_print(ndo, "\n\t", sp, h->caplen);
+               } else {
+                       /*
+                        * Don't include the link-layer header - and if
+                        * we have nothing past the link-layer header,
+                        * print nothing.
+                        */
+                       if (h->caplen > hdrlen)
+                               hex_and_ascii_print(ndo, "\n\t", sp + hdrlen,
+                                   h->caplen - hdrlen);
+               }
+       } else if (ndo->ndo_xflag) {
+               /*
+                * Print the raw packet data in hex.
+                */
+               if (ndo->ndo_xflag > 1) {
+                       /*
+                        * Include the link-layer header.
+                        */
+                        hex_print(ndo, "\n\t", sp, h->caplen);
+               } else {
+                       /*
+                        * Don't include the link-layer header - and if
+                        * we have nothing past the link-layer header,
+                        * print nothing.
+                        */
+                       if (h->caplen > hdrlen)
+                               hex_print(ndo, "\n\t", sp + hdrlen,
+                                          h->caplen - hdrlen);
+               }
+       } else if (ndo->ndo_Aflag) {
+               /*
+                * Print the raw packet data in ASCII.
+                */
+               if (ndo->ndo_Aflag > 1) {
+                       /*
+                        * Include the link-layer header.
+                        */
+                       ascii_print(ndo, sp, h->caplen);
+               } else {
+                       /*
+                        * Don't include the link-layer header - and if
+                        * we have nothing past the link-layer header,
+                        * print nothing.
+                        */
+                       if (h->caplen > hdrlen)
+                               ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen);
+               }
+       }
+
+       putchar('\n');
+}
+
+/*
+ * By default, print the specified data out in hex and ASCII.
+ */
+static void
+ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+       hex_and_ascii_print(ndo, "\n\t", bp, length); /* pass on lf and indentation string */
+}
+
+/* VARARGS */
+static void
+ndo_error(netdissect_options *ndo _U_, const char *fmt, ...)
+{
+       va_list ap;
+
+       (void)fprintf(stderr, "%s: ", program_name);
+       va_start(ap, fmt);
+       (void)vfprintf(stderr, fmt, ap);
+       va_end(ap);
+       if (*fmt) {
+               fmt += strlen(fmt);
+               if (fmt[-1] != '\n')
+                       (void)fputc('\n', stderr);
+       }
+       exit(1);
+       /* NOTREACHED */
+}
+
+/* VARARGS */
+static void
+ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...)
+{
+       va_list ap;
+
+       (void)fprintf(stderr, "%s: WARNING: ", program_name);
+       va_start(ap, fmt);
+       (void)vfprintf(stderr, fmt, ap);
+       va_end(ap);
+       if (*fmt) {
+               fmt += strlen(fmt);
+               if (fmt[-1] != '\n')
+                       (void)fputc('\n', stderr);
+       }
+}
+
+static int
+tcpdump_printf(netdissect_options *ndo _U_, const char *fmt, ...)
+{
+       va_list args;
+       int ret;
+
+       va_start(args, fmt);
+       ret = vfprintf(stdout, fmt, args);
+       va_end(args);
+
+       return (ret);
+}
+
+void
+ndo_set_function_pointers(netdissect_options *ndo)
+{
+
+       ndo->ndo_default_print=ndo_default_print;
+       ndo->ndo_printf=tcpdump_printf;
+       ndo->ndo_error=ndo_error;
+       ndo->ndo_warning=ndo_warning;
+}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/print.h b/print.h
new file mode 100644 (file)
index 0000000..048359d
--- /dev/null
+++ b/print.h
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ *
+ * Support for splitting captures into multiple files with a maximum
+ * file size:
+ *
+ * Copyright (c) 2001
+ *     Seth Webster <[email protected]>
+ */
+
+#ifndef print_h
+#define print_h
+
+struct print_info {
+       netdissect_options *ndo;
+       if_printer printer;
+};
+
+void   init_print(u_int32_t localnet, u_int32_t mask,
+           uint32_t timezone_offset);
+
+int    has_printer(int type);
+
+struct print_info      get_print_info(int type);
+
+void   pretty_print_packet(struct print_info *print_info,
+           const struct pcap_pkthdr *h, const u_char *sp,
+           u_int packets_captured);
+
+void   ndo_set_function_pointers(netdissect_options *ndo);
+
+#endif /* print_h */
index 324035fb8b3c9ee63d392b1828099a4fa8d98723..84a3a64d59177f7dcc8775b16419d88779c326c0 100644 (file)
@@ -15,7 +15,6 @@
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 1c1742c26dd32383478b358167cc1914458a1d5c..06354fb4180aa8ebe160e596a5f20ec4bdda3f62 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -6,7 +6,6 @@
  * or later
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
diff --git a/tcp.h b/tcp.h
index c18d1382511c53d0d1a662673807c0b659999bb0..e8c8d2ca9b89eae112888256c5cd3f9fdd024a55 100644 (file)
--- a/tcp.h
+++ b/tcp.h
@@ -85,6 +85,7 @@ struct tcphdr {
 #define        TCPOPT_UTO              28      /* tcp user timeout (rfc5482) */
 #define           TCPOLEN_UTO                  4
 #define        TCPOPT_MPTCP            30      /* MPTCP options */
+#define TCPOPT_FASTOPEN                34      /* TCP Fast Open (rfc7413) */
 #define TCPOPT_EXPERIMENT2     254     /* experimental headers (rfc4727) */
 
 #define TCPOPT_TSTAMP_HDR      \
index 2a32adbabb6468fdd05152373636c7b21a5b5fdb..8e5994f0bee0edaf5d157aa55ee2baef91f8c920 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -122,6 +122,8 @@ extern int SIZE_BUF;
 #include "gmt2local.h"
 #include "pcap-missing.h"
 
+#include "print.h"
+
 #ifndef PATH_MAX
 #define PATH_MAX 1024
 #endif
@@ -151,8 +153,6 @@ static int infoprint;
 
 char *program_name;
 
-int32_t thiszone;              /* seconds offset from gmt to local time */
-
 /* Forwards */
 static RETSIGTYPE cleanup(int);
 static RETSIGTYPE child_cleanup(int);
@@ -161,21 +161,9 @@ 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 *);
-static void ndo_default_print(netdissect_options *, const u_char *, u_int);
 static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *);
 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))
-#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);
@@ -192,192 +180,6 @@ RETSIGTYPE requestinfo(int);
 static void info(int);
 static u_int packets_captured;
 
-struct printer {
-       if_printer f;
-       int type;
-};
-
-
-static const struct printer printers[] = {
-       { ether_if_print,       DLT_EN10MB },
-#ifdef DLT_IPNET
-       { ipnet_if_print,       DLT_IPNET },
-#endif
-#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 },
-#endif
-#ifdef DLT_ATM_CLIP
-       { cip_if_print,         DLT_ATM_CLIP },
-#endif
-#ifdef DLT_IP_OVER_FC
-       { ipfc_if_print,        DLT_IP_OVER_FC },
-#endif
-       { 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 },
-#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_ETHER
-       { pppoe_if_print,       DLT_PPP_ETHER },
-#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_ENC
-       { enc_if_print,         DLT_ENC },
-#endif
-       { sl_if_print,          DLT_SLIP },
-#ifdef DLT_SLIP_BSDOS
-       { sl_bsdos_if_print,    DLT_SLIP_BSDOS },
-#endif
-#ifdef DLT_LTALK
-       { ltalk_if_print,       DLT_LTALK },
-#endif
-#ifdef DLT_JUNIPER_ATM1
-       { juniper_atm1_print,   DLT_JUNIPER_ATM1 },
-#endif
-#ifdef DLT_JUNIPER_ATM2
-       { juniper_atm2_print,   DLT_JUNIPER_ATM2 },
-#endif
-#ifdef DLT_JUNIPER_MFR
-       { juniper_mfr_print,    DLT_JUNIPER_MFR },
-#endif
-#ifdef DLT_JUNIPER_MLFR
-       { juniper_mlfr_print,   DLT_JUNIPER_MLFR },
-#endif
-#ifdef DLT_JUNIPER_MLPPP
-       { juniper_mlppp_print,  DLT_JUNIPER_MLPPP },
-#endif
-#ifdef DLT_JUNIPER_PPPOE
-       { juniper_pppoe_print,  DLT_JUNIPER_PPPOE },
-#endif
-#ifdef DLT_JUNIPER_PPPOE_ATM
-       { juniper_pppoe_atm_print, DLT_JUNIPER_PPPOE_ATM },
-#endif
-#ifdef DLT_JUNIPER_GGSN
-       { juniper_ggsn_print,   DLT_JUNIPER_GGSN },
-#endif
-#ifdef DLT_JUNIPER_ES
-       { juniper_es_print,     DLT_JUNIPER_ES },
-#endif
-#ifdef DLT_JUNIPER_MONITOR
-       { juniper_monitor_print, DLT_JUNIPER_MONITOR },
-#endif
-#ifdef DLT_JUNIPER_SERVICES
-       { juniper_services_print, DLT_JUNIPER_SERVICES },
-#endif
-#ifdef DLT_JUNIPER_ETHER
-       { juniper_ether_print,  DLT_JUNIPER_ETHER },
-#endif
-#ifdef DLT_JUNIPER_PPP
-       { juniper_ppp_print,    DLT_JUNIPER_PPP },
-#endif
-#ifdef DLT_JUNIPER_FRELAY
-       { juniper_frelay_print, DLT_JUNIPER_FRELAY },
-#endif
-#ifdef DLT_JUNIPER_CHDLC
-       { juniper_chdlc_print,  DLT_JUNIPER_CHDLC },
-#endif
-#ifdef DLT_PKTAP
-       { pktap_if_print,       DLT_PKTAP },
-#endif
-#ifdef DLT_IEEE802_11_RADIO
-       { ieee802_11_radio_if_print,    DLT_IEEE802_11_RADIO },
-#endif
-#ifdef DLT_IEEE802_11
-       { ieee802_11_if_print,  DLT_IEEE802_11},
-#endif
-#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 const struct tok status_flags[] = {
 #ifdef PCAP_IF_UP
        { PCAP_IF_UP,       "Up"       },
@@ -389,43 +191,6 @@ static const struct tok status_flags[] = {
        { 0, NULL }
 };
 
-if_printer
-lookup_printer(int type)
-{
-       const struct printer *p;
-
-       for (p = 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 = printers; p->f; ++p)
-                       if (DLT_PKTAP == p->type)
-                               return p->f;
-       }
-#endif
-
-       return NULL;
-       /* NOTREACHED */
-}
-
 static pcap_t *pd;
 
 static int supports_monitor_mode;
@@ -434,11 +199,6 @@ extern int optind;
 extern int opterr;
 extern char *optarg;
 
-struct print_info {
-        netdissect_options *ndo;
-        if_printer printer;
-};
-
 struct dump_info {
        char    *WFileName;
        char    *CurrentFileName;
@@ -486,7 +246,7 @@ show_tstamp_types_and_exit(const char *device, pcap_t *pd)
 static void
 show_dlts_and_exit(const char *device, pcap_t *pd)
 {
-       int n_dlts;
+       int n_dlts, i;
        int *dlts = 0;
        const char *dlt_name;
 
@@ -507,26 +267,26 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
        if (supports_monitor_mode)
                (void) fprintf(stderr, "Data link types for %s %s (use option -y to set):\n",
                    device,
-                   Iflag ? "when in monitor mode" : "when not in monitor mode");
+                   gndo->ndo_Iflag ? "when in monitor mode" : "when not in monitor mode");
        else
                (void) fprintf(stderr, "Data link types for %s (use option -y to set):\n",
                    device);
 
-       while (--n_dlts >= 0) {
-               dlt_name = pcap_datalink_val_to_name(dlts[n_dlts]);
+       for (i = 0; i < n_dlts; i++) {
+               dlt_name = pcap_datalink_val_to_name(dlts[i]);
                if (dlt_name != NULL) {
                        (void) fprintf(stderr, "  %s (%s)", dlt_name,
-                           pcap_datalink_val_to_description(dlts[n_dlts]));
+                           pcap_datalink_val_to_description(dlts[i]));
 
                        /*
                         * OK, does tcpdump handle that type?
                         */
-                       if (lookup_printer(dlts[n_dlts]) == NULL)
+                       if (!has_printer(dlts[i]))
                                (void) fprintf(stderr, " (printing not supported)");
                        fprintf(stderr, "\n");
                } else {
                        (void) fprintf(stderr, "  DLT %d (printing not supported)\n",
-                           dlts[n_dlts]);
+                           dlts[i]);
                }
        }
 #ifdef HAVE_PCAP_FREE_DATALINKS
@@ -790,11 +550,11 @@ MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
             error("Makefilename: malloc");
 
         /* Process with strftime if Gflag is set. */
-        if (Gflag != 0) {
+        if (gndo->ndo_Gflag != 0) {
           struct tm *local_tm;
 
           /* Convert Gflag_time to a usable format */
-          if ((local_tm = localtime(&Gflag_time)) == NULL) {
+          if ((local_tm = localtime(&gndo->ndo_Gflag_time)) == NULL) {
                   error("MakeTimedFilename: localtime");
           }
 
@@ -815,38 +575,6 @@ MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
         free(filename);
 }
 
-static int tcpdump_printf(netdissect_options *ndo _U_,
-                         const char *fmt, ...)
-{
-
-  va_list args;
-  int ret;
-
-  va_start(args, fmt);
-  ret=vfprintf(stdout, fmt, args);
-  va_end(args);
-
-  return ret;
-}
-
-static struct print_info
-get_print_info(int type)
-{
-       struct print_info printinfo;
-
-       printinfo.ndo = gndo;
-       printinfo.printer = lookup_printer(type);
-       if (printinfo.printer == NULL) {
-               gndo->ndo_dltname = pcap_datalink_val_to_name(type);
-               if (gndo->ndo_dltname != NULL)
-                       error("packet printing is not supported for link type %s: use -w",
-                             gndo->ndo_dltname);
-               else
-                       error("packet printing is not supported for link type %d: use -w", type);
-       }
-       return (printinfo);
-}
-
 static char *
 get_next_file(FILE *VFile, char *ptr)
 {
@@ -967,6 +695,7 @@ main(int argc, char **argv)
 {
        register int cnt, op, i;
        bpf_u_int32 localnet =0 , netmask = 0;
+       int timezone_offset = 0;
        register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName;
        pcap_handler callback;
        int type;
@@ -1001,14 +730,11 @@ main(int argc, char **argv)
        if(wsockinit() != 0) return 1;
 #endif /* WIN32 */
 
-       jflag=-1;       /* not set */
+       gndo->ndo_jflag=-1;     /* not set */
         gndo->ndo_Oflag=1;
        gndo->ndo_Rflag=1;
        gndo->ndo_dlt=-1;
-       gndo->ndo_default_print=ndo_default_print;
-       gndo->ndo_printf=tcpdump_printf;
-       gndo->ndo_error=ndo_error;
-       gndo->ndo_warning=ndo_warning;
+       ndo_set_function_pointers(gndo);
        gndo->ndo_snaplen = DEFAULT_SNAPLEN;
        gndo->ndo_immediate = 0;
 
@@ -1048,17 +774,17 @@ main(int argc, char **argv)
                        break;
 
                case 'A':
-                       ++Aflag;
+                       ++gndo->ndo_Aflag;
                        break;
 
                case 'b':
-                       ++bflag;
+                       ++gndo->ndo_bflag;
                        break;
 
 #if defined(HAVE_PCAP_CREATE) || defined(WIN32)
                case 'B':
-                       Bflag = atoi(optarg)*1024;
-                       if (Bflag <= 0)
+                       gndo->ndo_Bflag = atoi(optarg)*1024;
+                       if (gndo->ndo_Bflag <= 0)
                                error("invalid packet buffer size %s", optarg);
                        break;
 #endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */
@@ -1070,8 +796,8 @@ main(int argc, char **argv)
                        break;
 
                case 'C':
-                       Cflag = atoi(optarg) * 1000000;
-                       if (Cflag < 0)
+                       gndo->ndo_Cflag = atoi(optarg) * 1000000;
+                       if (gndo->ndo_Cflag < 0)
                                error("invalid file size %s", optarg);
                        break;
 
@@ -1088,7 +814,7 @@ main(int argc, char **argv)
                        break;
 
                case 'e':
-                       ++eflag;
+                       ++gndo->ndo_eflag;
                        break;
 
                case 'E':
@@ -1099,7 +825,7 @@ main(int argc, char **argv)
                        break;
 
                case 'f':
-                       ++fflag;
+                       ++gndo->ndo_fflag;
                        break;
 
                case 'F':
@@ -1107,15 +833,15 @@ main(int argc, char **argv)
                        break;
 
                case 'G':
-                       Gflag = atoi(optarg);
-                       if (Gflag < 0)
+                       gndo->ndo_Gflag = atoi(optarg);
+                       if (gndo->ndo_Gflag < 0)
                                error("invalid number of seconds %s", optarg);
 
                         /* We will create one file initially. */
-                        Gflag_count = 0;
+                        gndo->ndo_Gflag_count = 0;
 
                        /* Grab the current time for rotation use. */
-                       if ((Gflag_time = time(NULL)) == (time_t)-1) {
+                       if ((gndo->ndo_Gflag_time = time(NULL)) == (time_t)-1) {
                                error("main: can't get current time: %s",
                                    pcap_strerror(errno));
                        }
@@ -1127,7 +853,7 @@ main(int argc, char **argv)
                        break;
 
                case 'H':
-                       ++Hflag;
+                       ++gndo->ndo_Hflag;
                        break;
 
                case 'i':
@@ -1174,14 +900,14 @@ main(int argc, char **argv)
 
 #ifdef HAVE_PCAP_CREATE
                case 'I':
-                       ++Iflag;
+                       ++gndo->ndo_Iflag;
                        break;
 #endif /* HAVE_PCAP_CREATE */
 
 #ifdef HAVE_PCAP_SET_TSTAMP_TYPE
                case 'j':
-                       jflag = pcap_tstamp_type_name_to_val(optarg);
-                       if (jflag < 0)
+                       gndo->ndo_jflag = pcap_tstamp_type_name_to_val(optarg);
+                       if (gndo->ndo_jflag < 0)
                                error("invalid time stamp type %s", optarg);
                        break;
 
@@ -1212,7 +938,7 @@ main(int argc, char **argv)
                        break;
 
                case 'K':
-                       ++Kflag;
+                       ++gndo->ndo_Kflag;
                        break;
 
                case 'm':
@@ -1220,7 +946,7 @@ main(int argc, char **argv)
                        if (smiLoadModule(optarg) == 0) {
                                error("could not load MIB module %s", optarg);
                        }
-                       sflag = 1;
+                       gndo->ndo_sflag = 1;
 #else
                        (void)fprintf(stderr, "%s: ignoring option `-m %s' ",
                                      program_name, optarg);
@@ -1233,28 +959,28 @@ main(int argc, char **argv)
 #ifndef HAVE_LIBCRYPTO
                        warning("crypto code not compiled in");
 #endif
-                       sigsecret = optarg;
+                       gndo->ndo_sigsecret = optarg;
                        break;
 
                case 'n':
-                       ++nflag;
+                       ++gndo->ndo_nflag;
                        break;
 
                case 'N':
-                       ++Nflag;
+                       ++gndo->ndo_Nflag;
                        break;
 
                case 'O':
-                       Oflag = 0;
+                       gndo->ndo_Oflag = 0;
                        break;
 
                case 'p':
-                       ++pflag;
+                       ++gndo->ndo_pflag;
                        break;
 
                case 'q':
-                       ++qflag;
-                       ++suppress_default_print;
+                       ++gndo->ndo_qflag;
+                       ++gndo->ndo_suppress_default_print;
                        break;
 
 #ifdef HAVE_PCAP_SETDIRECTION
@@ -1275,75 +1001,75 @@ main(int argc, char **argv)
                        break;
 
                case 'R':
-                       Rflag = 0;
+                       gndo->ndo_Rflag = 0;
                        break;
 
                case 's':
-                       snaplen = strtol(optarg, &end, 0);
+                       gndo->ndo_snaplen = strtol(optarg, &end, 0);
                        if (optarg == end || *end != '\0'
-                           || snaplen < 0 || snaplen > MAXIMUM_SNAPLEN)
+                           || gndo->ndo_snaplen < 0 || gndo->ndo_snaplen > MAXIMUM_SNAPLEN)
                                error("invalid snaplen %s", optarg);
-                       else if (snaplen == 0)
-                               snaplen = MAXIMUM_SNAPLEN;
+                       else if (gndo->ndo_snaplen == 0)
+                               gndo->ndo_snaplen = MAXIMUM_SNAPLEN;
                        break;
 
                case 'S':
-                       ++Sflag;
+                       ++gndo->ndo_Sflag;
                        break;
 
                case 't':
-                       ++tflag;
+                       ++gndo->ndo_tflag;
                        break;
 
                case 'T':
                        if (strcasecmp(optarg, "vat") == 0)
-                               packettype = PT_VAT;
+                               gndo->ndo_packettype = PT_VAT;
                        else if (strcasecmp(optarg, "wb") == 0)
-                               packettype = PT_WB;
+                               gndo->ndo_packettype = PT_WB;
                        else if (strcasecmp(optarg, "rpc") == 0)
-                               packettype = PT_RPC;
+                               gndo->ndo_packettype = PT_RPC;
                        else if (strcasecmp(optarg, "rtp") == 0)
-                               packettype = PT_RTP;
+                               gndo->ndo_packettype = PT_RTP;
                        else if (strcasecmp(optarg, "rtcp") == 0)
-                               packettype = PT_RTCP;
+                               gndo->ndo_packettype = PT_RTCP;
                        else if (strcasecmp(optarg, "snmp") == 0)
-                               packettype = PT_SNMP;
+                               gndo->ndo_packettype = PT_SNMP;
                        else if (strcasecmp(optarg, "cnfp") == 0)
-                               packettype = PT_CNFP;
+                               gndo->ndo_packettype = PT_CNFP;
                        else if (strcasecmp(optarg, "tftp") == 0)
-                               packettype = PT_TFTP;
+                               gndo->ndo_packettype = PT_TFTP;
                        else if (strcasecmp(optarg, "aodv") == 0)
-                               packettype = PT_AODV;
+                               gndo->ndo_packettype = PT_AODV;
                        else if (strcasecmp(optarg, "carp") == 0)
-                               packettype = PT_CARP;
+                               gndo->ndo_packettype = PT_CARP;
                        else if (strcasecmp(optarg, "radius") == 0)
-                               packettype = PT_RADIUS;
+                               gndo->ndo_packettype = PT_RADIUS;
                        else if (strcasecmp(optarg, "zmtp1") == 0)
-                               packettype = PT_ZMTP1;
+                               gndo->ndo_packettype = PT_ZMTP1;
                        else if (strcasecmp(optarg, "vxlan") == 0)
-                               packettype = PT_VXLAN;
+                               gndo->ndo_packettype = PT_VXLAN;
                        else if (strcasecmp(optarg, "pgm") == 0)
-                               packettype = PT_PGM;
+                               gndo->ndo_packettype = PT_PGM;
                        else if (strcasecmp(optarg, "pgm_zmtp1") == 0)
-                               packettype = PT_PGM_ZMTP1;
+                               gndo->ndo_packettype = PT_PGM_ZMTP1;
                        else if (strcasecmp(optarg, "lmp") == 0)
-                               packettype = PT_LMP;
+                               gndo->ndo_packettype = PT_LMP;
                        else
                                error("unknown packet type `%s'", optarg);
                        break;
 
                case 'u':
-                       ++uflag;
+                       ++gndo->ndo_uflag;
                        break;
 
 #ifdef HAVE_PCAP_DUMP_FLUSH
                case 'U':
-                       ++Uflag;
+                       ++gndo->ndo_Uflag;
                        break;
 #endif
 
                case 'v':
-                       ++vflag;
+                       ++gndo->ndo_vflag;
                        break;
 
                case 'V':
@@ -1355,20 +1081,20 @@ main(int argc, char **argv)
                        break;
 
                case 'W':
-                       Wflag = atoi(optarg);
-                       if (Wflag < 0)
+                       gndo->ndo_Wflag = atoi(optarg);
+                       if (gndo->ndo_Wflag < 0)
                                error("invalid number of output files %s", optarg);
-                       WflagChars = getWflagChars(Wflag);
+                       gndo->ndo_WflagChars = getWflagChars(gndo->ndo_Wflag);
                        break;
 
                case 'x':
-                       ++xflag;
-                       ++suppress_default_print;
+                       ++gndo->ndo_xflag;
+                       ++gndo->ndo_suppress_default_print;
                        break;
 
                case 'X':
-                       ++Xflag;
-                       ++suppress_default_print;
+                       ++gndo->ndo_Xflag;
+                       ++gndo->ndo_suppress_default_print;
                        break;
 
                case 'y':
@@ -1435,11 +1161,11 @@ main(int argc, char **argv)
                show_devices_and_exit();
 #endif
 
-       switch (tflag) {
+       switch (gndo->ndo_tflag) {
 
        case 0: /* Default */
        case 4: /* Default + Date*/
-               thiszone = gmt2local(0);
+               timezone_offset = gmt2local(0);
                break;
 
        case 1: /* No time stamp */
@@ -1453,7 +1179,7 @@ main(int argc, char **argv)
                break;
        }
 
-       if (fflag != 0 && (VFileName != NULL || RFileName != NULL))
+       if (gndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL))
                error("-f can not be used with -V or -r");
 
        if (VFileName != NULL && RFileName != NULL)
@@ -1611,15 +1337,15 @@ main(int argc, char **argv)
                        supports_monitor_mode = 1;
                else
                        supports_monitor_mode = 0;
-               status = pcap_set_snaplen(pd, snaplen);
+               status = pcap_set_snaplen(pd, gndo->ndo_snaplen);
                if (status != 0)
                        error("%s: Can't set snapshot length: %s",
                            device, pcap_statustostr(status));
-               status = pcap_set_promisc(pd, !pflag);
+               status = pcap_set_promisc(pd, !gndo->ndo_pflag);
                if (status != 0)
                        error("%s: Can't set promiscuous mode: %s",
                            device, pcap_statustostr(status));
-               if (Iflag) {
+               if (gndo->ndo_Iflag) {
                        status = pcap_set_rfmon(pd, 1);
                        if (status != 0)
                                error("%s: Can't set monitor mode: %s",
@@ -1629,15 +1355,15 @@ main(int argc, char **argv)
                if (status != 0)
                        error("%s: pcap_set_timeout failed: %s",
                            device, pcap_statustostr(status));
-               if (Bflag != 0) {
-                       status = pcap_set_buffer_size(pd, Bflag);
+               if (gndo->ndo_Bflag != 0) {
+                       status = pcap_set_buffer_size(pd, gndo->ndo_Bflag);
                        if (status != 0)
                                error("%s: Can't set buffer size: %s",
                                    device, pcap_statustostr(status));
                }
 #ifdef HAVE_PCAP_SET_TSTAMP_TYPE
-                if (jflag != -1) {
-                       status = pcap_set_tstamp_type(pd, jflag);
+                if (gndo->ndo_jflag != -1) {
+                       status = pcap_set_tstamp_type(pd, gndo->ndo_jflag);
                        if (status < 0)
                                error("%s: Can't set time stamp type: %s",
                                      device, pcap_statustostr(status));
@@ -1726,11 +1452,11 @@ main(int argc, char **argv)
                        (void)fflush(stderr);
                }
                i = pcap_snapshot(pd);
-               if (snaplen < i) {
-                       warning("snaplen raised from %d to %d", snaplen, i);
-                       snaplen = i;
+               if (gndo->ndo_snaplen < i) {
+                       warning("snaplen raised from %d to %d", gndo->ndo_snaplen, i);
+                       gndo->ndo_snaplen = i;
                }
-                if(fflag != 0) {
+                if(gndo->ndo_fflag != 0) {
                         if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
                                 warning("foreign (-f) flag used but: %s", ebuf);
                         }
@@ -1742,7 +1468,7 @@ main(int argc, char **argv)
        else
                cmdbuf = copy_argv(&argv[optind]);
 
-       if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
+       if (pcap_compile(pd, &fcode, cmdbuf, gndo->ndo_Oflag, netmask) < 0)
                error("%s", pcap_geterr(pd));
        if (dflag) {
                bpf_dump(&fcode, dflag);
@@ -1750,8 +1476,7 @@ main(int argc, char **argv)
                free(cmdbuf);
                exit(0);
        }
-       init_addrtoname(gndo, localnet, netmask);
-        init_checksum();
+       init_print(localnet, netmask, timezone_offset);
 
 #ifndef WIN32
        (void)setsignal(SIGPIPE, cleanup);
@@ -1840,8 +1565,8 @@ main(int argc, char **argv)
                        error("malloc of dumpinfo.CurrentFileName");
 
                /* We do not need numbering for dumpfiles if Cflag isn't set. */
-               if (Cflag != 0)
-                 MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, WflagChars);
+               if (gndo->ndo_Cflag != 0)
+                 MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, gndo->ndo_WflagChars);
                else
                  MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0);
 
@@ -1853,7 +1578,7 @@ main(int argc, char **argv)
                 */
                capng_update(
                        CAPNG_DROP,
-                       (Cflag || Gflag ? 0 : CAPNG_PERMITTED)
+                       (gndo->ndo_Cflag || gndo->ndo_Gflag ? 0 : CAPNG_PERMITTED)
                                | CAPNG_EFFECTIVE,
                        CAP_DAC_OVERRIDE
                        );
@@ -1864,7 +1589,7 @@ main(int argc, char **argv)
 #ifdef HAVE_CAPSICUM
                set_dumper_capsicum_rights(p);
 #endif
-               if (Cflag != 0 || Gflag != 0) {
+               if (gndo->ndo_Cflag != 0 || gndo->ndo_Gflag != 0) {
 #ifdef HAVE_CAPSICUM
                        dumpinfo.WFileName = strdup(basename(WFileName));
                        dumpinfo.dirfd = open(dirname(WFileName),
@@ -1895,7 +1620,7 @@ main(int argc, char **argv)
                        pcap_userdata = (u_char *)p;
                }
 #ifdef HAVE_PCAP_DUMP_FLUSH
-               if (Uflag)
+               if (gndo->ndo_Uflag)
                        pcap_dump_flush(p);
 #endif
        } else {
@@ -1914,7 +1639,7 @@ main(int argc, char **argv)
                (void)setsignal(SIGNAL_REQ_INFO, requestinfo);
 #endif
 
-       if (vflag > 0 && WFileName) {
+       if (gndo->ndo_vflag > 0 && WFileName) {
                /*
                 * When capturing to a file, "-v" means tcpdump should,
                 * every 10 secodns, "v"erbosely report the number of
@@ -1937,7 +1662,7 @@ main(int argc, char **argv)
                 * to a file from the -V file).  Print a message to
                 * the standard error on UN*X.
                 */
-               if (!vflag && !WFileName) {
+               if (!gndo->ndo_vflag && !WFileName) {
                        (void)fprintf(stderr,
                            "%s: verbose output suppressed, use -v or -vv for full protocol decode\n",
                            program_name);
@@ -1947,18 +1672,18 @@ main(int argc, char **argv)
                dlt_name = pcap_datalink_val_to_name(dlt);
                if (dlt_name == NULL) {
                        (void)fprintf(stderr, "listening on %s, link-type %u, capture size %u bytes\n",
-                           device, dlt, snaplen);
+                           device, dlt, gndo->ndo_snaplen);
                } else {
                        (void)fprintf(stderr, "listening on %s, link-type %s (%s), capture size %u bytes\n",
                            device, dlt_name,
-                           pcap_datalink_val_to_description(dlt), snaplen);
+                           pcap_datalink_val_to_description(dlt), gndo->ndo_snaplen);
                }
                (void)fflush(stderr);
        }
 #endif /* WIN32 */
 
 #ifdef HAVE_CAPSICUM
-       cansandbox = (nflag && VFileName == NULL && zflag == NULL);
+       cansandbox = (gndo->ndo_nflag && VFileName == NULL && zflag == NULL);
        if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
                error("unable to enter the capability mode");
        if (cap_sandboxed())
@@ -2033,7 +1758,7 @@ main(int argc, char **argv)
                                        RFileName, dlt_name,
                                        pcap_datalink_val_to_description(new_dlt));
                                }
-                               if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
+                               if (pcap_compile(pd, &fcode, cmdbuf, gndo->ndo_Oflag, netmask) < 0)
                                        error("%s", pcap_geterr(pd));
                                if (pcap_setfilter(pd, &fcode) < 0)
                                        error("%s", pcap_geterr(pd));
@@ -2187,9 +1912,6 @@ static void
 dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 {
        struct dump_info *dump_info;
-#ifdef HAVE_CAPSICUM
-       cap_rights_t rights;
-#endif
 
        ++packets_captured;
 
@@ -2205,7 +1927,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
         * first thereby cancelling the Cflag boundary (since the file should
         * be 0).
         */
-       if (Gflag != 0) {
+       if (gndo->ndo_Gflag != 0) {
                /* Check if it is time to rotate */
                time_t t;
 
@@ -2217,16 +1939,16 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
 
 
                /* If the time is greater than the specified window, rotate */
-               if (t - Gflag_time >= Gflag) {
+               if (t - gndo->ndo_Gflag_time >= gndo->ndo_Gflag) {
 #ifdef HAVE_CAPSICUM
                        FILE *fp;
                        int fd;
 #endif
 
                        /* Update the Gflag_time */
-                       Gflag_time = t;
+                       gndo->ndo_Gflag_time = t;
                        /* Update Gflag_count */
-                       Gflag_count++;
+                       gndo->ndo_Gflag_count++;
                        /*
                         * Close the current file and open a new one.
                         */
@@ -2242,9 +1964,9 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
                         * Check to see if we've exceeded the Wflag (when
                         * not using Cflag).
                         */
-                       if (Cflag == 0 && Wflag > 0 && Gflag_count >= Wflag) {
+                       if (gndo->ndo_Cflag == 0 && gndo->ndo_Wflag > 0 && gndo->ndo_Gflag_count >= gndo->ndo_Wflag) {
                                (void)fprintf(stderr, "Maximum file limit reached: %d\n",
-                                   Wflag);
+                                   gndo->ndo_Wflag);
                                exit(0);
                                /* NOTREACHED */
                        }
@@ -2259,16 +1981,16 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
                         * 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;
+                       gndo->ndo_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.
                         */
-                       if (Cflag != 0)
+                       if (gndo->ndo_Cflag != 0)
                                MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0,
-                                   WflagChars);
+                                   gndo->ndo_WflagChars);
                        else
                                MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, 0);
 
@@ -2310,12 +2032,12 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
         * larger than Cflag - the last packet written to the
         * file could put it over Cflag.
         */
-       if (Cflag != 0) {
+       if (gndo->ndo_Cflag != 0) {
                long size = pcap_dump_ftell(dump_info->p);
 
                if (size == -1)
                        error("ftell fails on output file");
-               if (size > Cflag) {
+               if (size > gndo->ndo_Cflag) {
 #ifdef HAVE_CAPSICUM
                        FILE *fp;
                        int fd;
@@ -2333,17 +2055,17 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
                        if (zflag != NULL)
                                compress_savefile(dump_info->CurrentFileName);
 
-                       Cflag_count++;
-                       if (Wflag > 0) {
-                               if (Cflag_count >= Wflag)
-                                       Cflag_count = 0;
+                       gndo->ndo_Cflag_count++;
+                       if (gndo->ndo_Wflag > 0) {
+                               if (gndo->ndo_Cflag_count >= gndo->ndo_Wflag)
+                                       gndo->ndo_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);
+                       MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, gndo->ndo_Cflag_count, gndo->ndo_WflagChars);
 #ifdef HAVE_LIBCAP_NG
                        capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
                        capng_apply(CAPNG_SELECT_BOTH);
@@ -2378,7 +2100,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
 
        pcap_dump((u_char *)dump_info->p, h, sp);
 #ifdef HAVE_PCAP_DUMP_FLUSH
-       if (Uflag)
+       if (gndo->ndo_Uflag)
                pcap_dump_flush(dump_info->p);
 #endif
 
@@ -2396,7 +2118,7 @@ dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 
        pcap_dump(user, h, sp);
 #ifdef HAVE_PCAP_DUMP_FLUSH
-       if (Uflag)
+       if (gndo->ndo_Uflag)
                pcap_dump_flush((pcap_dumper_t *)user);
 #endif
 
@@ -2409,95 +2131,14 @@ static void
 print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 {
        struct print_info *print_info;
-       u_int hdrlen;
-        netdissect_options *ndo;
 
        ++packets_captured;
 
        ++infodelay;
 
        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 member
-        * of the netdissect_options structure.
-        */
-       ndo->ndo_snapend = sp + h->caplen;
-
-        hdrlen = (*print_info->printer)(print_info->ndo, h, sp);
-
-       /*
-        * 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 (ndo->ndo_Xflag > 1) {
-                       /*
-                        * Include the link-layer header.
-                        */
-                       hex_and_ascii_print(ndo, "\n\t", sp, h->caplen);
-               } else {
-                       /*
-                        * Don't include the link-layer header - and if
-                        * we have nothing past the link-layer header,
-                        * print nothing.
-                        */
-                       if (h->caplen > hdrlen)
-                               hex_and_ascii_print(ndo, "\n\t", sp + hdrlen,
-                                   h->caplen - hdrlen);
-               }
-       } else if (ndo->ndo_xflag) {
-               /*
-                * Print the raw packet data in hex.
-                */
-               if (ndo->ndo_xflag > 1) {
-                       /*
-                        * Include the link-layer header.
-                        */
-                        hex_print(ndo, "\n\t", sp, h->caplen);
-               } else {
-                       /*
-                        * Don't include the link-layer header - and if
-                        * we have nothing past the link-layer header,
-                        * print nothing.
-                        */
-                       if (h->caplen > hdrlen)
-                               hex_print(ndo, "\n\t", sp + hdrlen,
-                                          h->caplen - hdrlen);
-               }
-       } else if (ndo->ndo_Aflag) {
-               /*
-                * Print the raw packet data in ASCII.
-                */
-               if (ndo->ndo_Aflag > 1) {
-                       /*
-                        * Include the link-layer header.
-                        */
-                       ascii_print(ndo, sp, h->caplen);
-               } else {
-                       /*
-                        * Don't include the link-layer header - and if
-                        * we have nothing past the link-layer header,
-                        * print nothing.
-                        */
-                       if (h->caplen > hdrlen)
-                               ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen);
-               }
-       }
-
-       putchar('\n');
+       pretty_print_packet(print_info, h, sp, packets_captured);
 
        --infodelay;
        if (infoprint)
@@ -2531,21 +2172,6 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
        char Wpcap_version[]="3.1";
 #endif
 
-/*
- * By default, print the specified data out in hex and ASCII.
- */
-static void
-ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
-{
-       hex_and_ascii_print(ndo, "\n\t", bp, length); /* pass on lf and indentation string */
-}
-
-void
-default_print(const u_char *bp, u_int length)
-{
-       ndo_default_print(gndo, bp, length);
-}
-
 #ifdef SIGNAL_REQ_INFO
 RETSIGTYPE requestinfo(int signo _U_)
 {
@@ -2649,44 +2275,6 @@ print_usage(void)
        (void)fprintf(stderr,
 "\t\t[ -Z user ] [ expression ]\n");
 }
-
-
-
-/* VARARGS */
-static void
-ndo_error(netdissect_options *ndo _U_, const char *fmt, ...)
-{
-       va_list ap;
-
-       (void)fprintf(stderr, "%s: ", program_name);
-       va_start(ap, fmt);
-       (void)vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       if (*fmt) {
-               fmt += strlen(fmt);
-               if (fmt[-1] != '\n')
-                       (void)fputc('\n', stderr);
-       }
-       exit(1);
-       /* NOTREACHED */
-}
-
-/* VARARGS */
-static void
-ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...)
-{
-       va_list ap;
-
-       (void)fprintf(stderr, "%s: WARNING: ", program_name);
-       va_start(ap, fmt);
-       (void)vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       if (*fmt) {
-               fmt += strlen(fmt);
-               if (fmt[-1] != '\n')
-                       (void)fputc('\n', stderr);
-       }
-}
 /*
  * Local Variables:
  * c-style: whitesmith
index 472468c523a6df76036cc4ad03b57557d718c6ac..35963c62260b3ee717abec229ea92fb040daf87d 100644 (file)
@@ -267,3 +267,25 @@ 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
index e58377b313aacaf2e72dc5224fede7cf69b41071..30ffccdb27f9224c65292fd8b81c36d952645c11 100755 (executable)
@@ -12,13 +12,23 @@ $input=$ARGV[1];
 $output=$ARGV[2];
 $options=$ARGV[3];
 
+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";
+    $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";
     }
diff --git a/tests/cve2015-0261-crash.out b/tests/cve2015-0261-crash.out
new file mode 100644 (file)
index 0000000..1946280
--- /dev/null
@@ -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 (file)
index 0000000..c876c1f
Binary files /dev/null and b/tests/cve2015-0261-crash.pcap differ
diff --git a/tests/cve2015-0261-ipv6.out b/tests/cve2015-0261-ipv6.out
new file mode 100644 (file)
index 0000000..4674ada
--- /dev/null
@@ -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 (file)
index 0000000..a8a32ba
Binary files /dev/null and b/tests/cve2015-0261-ipv6.pcap differ
index 1d73418ac72738002058a6f696516771a44c140a..4eb566b98943d65fc895a6ac2ee0641f17b5386c 100644 (file)
@@ -3,28 +3,53 @@ DTPv1, length 38
        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
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP, oui Cisco (0x00000c), pid Unknown (0x0003), length 68: 
+       0x0000:  aaaa 0300 000c 0003 0000 0000 0100 0ccc  ................
+       0x0010:  cccc 0019 06ea b885 0025 aaaa 0300 000c  .........%......
+       0x0020:  2004 0100 0100 084c 6162 0000 0200 0504  .......Lab......
+       0x0030:  0003 0005 4000 0400 0a00 1906 eab8 8500  ....@...........
+       0x0040:  0000 0000 0000 0000 f7a7 fe42            ...........B
 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
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP, oui Cisco (0x00000c), pid Unknown (0x0003), length 68: 
+       0x0000:  aaaa 0300 000c 0003 0000 0000 0100 0ccc  ................
+       0x0010:  cccc 0019 06ea b885 0025 aaaa 0300 000c  .........%......
+       0x0020:  2004 0100 0100 084c 6162 0000 0200 0504  .......Lab......
+       0x0030:  0003 0005 4000 0400 0a00 1906 eab8 8500  ....@...........
+       0x0040:  0000 0000 0000 0000 f7a7 fe42            ...........B
 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
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP, oui Cisco (0x00000c), pid Unknown (0x0003), length 68: 
+       0x0000:  aaaa 0300 000c 0003 0000 0000 0100 0ccc  ................
+       0x0010:  cccc 0019 06ea b885 0025 aaaa 0300 000c  .........%......
+       0x0020:  2004 0100 0100 084c 6162 0000 0200 0504  .......Lab......
+       0x0030:  0003 0005 4000 0400 0a00 1906 eab8 8500  ....@...........
+       0x0040:  0000 0000 0000 0000 f7a7 fe42            ...........B
 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
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP, oui Cisco (0x00000c), pid Unknown (0x0003), length 68: 
+       0x0000:  aaaa 0300 000c 0003 0000 0000 0100 0ccc  ................
+       0x0010:  cccc 0019 06ea b885 0025 aaaa 0300 000c  .........%......
+       0x0020:  2004 0100 0100 084c 6162 0000 0200 0504  .......Lab......
+       0x0030:  0003 0005 4000 0400 0a00 1906 eab8 8514  ....@...........
+       0x0040:  0002 000f 0000 0000 7232 1da6            ........r2..
 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
+00:19:06:ea:b8:85 > 01:00:0c:00:00:00 SNAP, oui Cisco (0x00000c), pid Unknown (0x0003), length 68: 
+       0x0000:  aaaa 0300 000c 0003 0000 0000 0100 0ccc  ................
+       0x0010:  cccc 0019 06ea b885 0025 aaaa 0300 000c  .........%......
+       0x0020:  2004 0100 0100 084c 6162 0000 0200 0504  .......Lab......
+       0x0030:  0003 0005 4000 0400 0a00 1906 eab8 8514  ....@...........
+       0x0040:  0002 000f 0000 0000 7232 1da6            ........r2..
index dd1689d462c0ef9848b32cf21359a3c89953f90d..dc5d1cb2bf801f7d532712d951f255a0e937e3db 100644 (file)
@@ -1,26 +1,26 @@
-10016360us tsft 1.0 Mb/s 2412 MHz 11b -22dB signal -86dB noise antenna 1 [bit 31] 0us Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
-10018922us tsft 1.0 Mb/s 2412 MHz 11b -19dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-10017245us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
-10085301us tsft 1.0 Mb/s 2412 MHz 11b -19dB signal -86dB noise antenna 1 [bit 31] 0us Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
-10087718us tsft 1.0 Mb/s 2412 MHz 11b -18dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-10086042us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
-10284358us tsft 1.0 Mb/s 2412 MHz 11b -61dB signal -86dB noise antenna 1 [bit 31] 0us Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
-10288217us tsft 1.0 Mb/s 2412 MHz 11b -46dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-10286542us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
-10351366us tsft 1.0 Mb/s 2412 MHz 11b -70dB signal -86dB noise antenna 1 [bit 31] 0us Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
-10353769us tsft 1.0 Mb/s 2412 MHz 11b -57dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-10352092us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
-10418368us tsft 1.0 Mb/s 2412 MHz 11b -67dB signal -86dB noise antenna 1 [bit 31] 0us Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
-10420929us tsft 1.0 Mb/s 2412 MHz 11b -73dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-10419253us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
-10485371us tsft 1.0 Mb/s 2412 MHz 11b -72dB signal -86dB noise antenna 1 [bit 31] 0us Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
-10489278us tsft 1.0 Mb/s 2412 MHz 11b -74dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-10487602us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
-13338508us tsft 1.0 Mb/s 2412 MHz 11b -14dB signal -86dB noise antenna 1 [bit 31] 314us Authentication (Open System)-1: Successful
-13340215us tsft 1.0 Mb/s 2412 MHz 11b -17dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-13339435us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Authentication (Open System)-2: 
-13341999us tsft 1.0 Mb/s 2412 MHz 11b -18dB signal -86dB noise antenna 1 [bit 31] 314us Assoc Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
-13346458us tsft 1.0 Mb/s 2412 MHz 11b -18dB signal -86dB noise antenna 0 [bit 31] 0us Acknowledgment RA:90:a4:de:c0:46:0a 
-13344925us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] 314us Assoc Response AID(1) :: Successful
-13355433us tsft 2412 MHz 11g -22dB signal -86dB noise antenna 1 19.5 Mb/s MCS 2 20 MHz lon GI [bit 31] 48us 
-13454791us tsft 2412 MHz 11g -21dB signal -86dB noise antenna 1 52.0 Mb/s MCS 11 20 MHz lon GI [bit 31] Pwr Mgmt 44us 
+10016360us tsft 1.0 Mb/s 2412 MHz 11b -22dB signal -86dB noise antenna 1 [bit 31] Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
+10018922us tsft 1.0 Mb/s 2412 MHz 11b -19dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+10017245us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
+10085301us tsft 1.0 Mb/s 2412 MHz 11b -19dB signal -86dB noise antenna 1 [bit 31] Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
+10087718us tsft 1.0 Mb/s 2412 MHz 11b -18dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+10086042us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
+10284358us tsft 1.0 Mb/s 2412 MHz 11b -61dB signal -86dB noise antenna 1 [bit 31] Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
+10288217us tsft 1.0 Mb/s 2412 MHz 11b -46dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+10286542us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
+10351366us tsft 1.0 Mb/s 2412 MHz 11b -70dB signal -86dB noise antenna 1 [bit 31] Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
+10353769us tsft 1.0 Mb/s 2412 MHz 11b -57dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+10352092us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
+10418368us tsft 1.0 Mb/s 2412 MHz 11b -67dB signal -86dB noise antenna 1 [bit 31] Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
+10420929us tsft 1.0 Mb/s 2412 MHz 11b -73dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+10419253us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
+10485371us tsft 1.0 Mb/s 2412 MHz 11b -72dB signal -86dB noise antenna 1 [bit 31] Probe Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
+10489278us tsft 1.0 Mb/s 2412 MHz 11b -74dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+10487602us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Probe Response (omus) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit] CH: 1
+13338508us tsft 1.0 Mb/s 2412 MHz 11b -14dB signal -86dB noise antenna 1 [bit 31] Authentication (Open System)-1: Successful
+13340215us tsft 1.0 Mb/s 2412 MHz 11b -17dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+13339435us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Authentication (Open System)-2: 
+13341999us tsft 1.0 Mb/s 2412 MHz 11b -18dB signal -86dB noise antenna 1 [bit 31] Assoc Request (omus) [1.0 2.0 5.5 11.0 6.0 9.0 12.0 18.0 Mbit]
+13346458us tsft 1.0 Mb/s 2412 MHz 11b -18dB signal -86dB noise antenna 0 [bit 31] Acknowledgment RA:90:a4:de:c0:46:0a 
+13344925us tsft 1.0 Mb/s -86dB noise 27dBm tx power [bit 15] Assoc Response AID(1) :: Successful
+13355433us tsft 2412 MHz 11g -22dB signal -86dB noise antenna 1 19.5 Mb/s MCS 2 20 MHz lon GI [bit 31] 
+13454791us tsft 2412 MHz 11g -21dB signal -86dB noise antenna 1 52.0 Mb/s MCS 11 20 MHz lon GI [bit 31] 
index 9f483b95a9efe0ca2811cccfe65264b7031d4ede..1daa16fbf0e2c28ab6a397034190e2fee5ca430b 100644 (file)
@@ -1,3 +1,3 @@
-7268us tsft 2462 MHz 11g -51dB signal antenna 1 150.0 Mb/s MCS 7 40 MHz short GI RX-STBC1 CF +QoS Data IV: 11 Pad 20 KeyID 0
-119738173us tsft 2462 MHz 11g -46dB signal antenna 1 135.0 Mb/s MCS 7 40 MHz lon GI RX-STBC2 CF +QoS Data IV:  1 Pad 20 KeyID 0
-470382336us tsft 2462 MHz 11g -45dB signal antenna 1 150.0 Mb/s MCS 7 40 MHz short GI RX-STBC3 CF +QoS Data IV:  5 Pad 20 KeyID 0
+7268us tsft 2462 MHz 11g -51dB signal antenna 1 150.0 Mb/s MCS 7 40 MHz short GI RX-STBC1 Data IV: 11 Pad 20 KeyID 0
+119738173us tsft 2462 MHz 11g -46dB signal antenna 1 135.0 Mb/s MCS 7 40 MHz lon GI RX-STBC2 Data IV:  1 Pad 20 KeyID 0
+470382336us tsft 2462 MHz 11g -45dB signal antenna 1 150.0 Mb/s MCS 7 40 MHz short GI RX-STBC3 Data IV:  5 Pad 20 KeyID 0
diff --git a/tests/kday1.out b/tests/kday1.out
new file mode 100644 (file)
index 0000000..eaaacaa
--- /dev/null
@@ -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 (file)
index 0000000..ca2d960
Binary files /dev/null and b/tests/kday1.pcap differ
diff --git a/tests/kday2.out b/tests/kday2.out
new file mode 100644 (file)
index 0000000..770fc3b
--- /dev/null
@@ -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 (file)
index 0000000..28e921b
Binary files /dev/null and b/tests/kday2.pcap differ
diff --git a/tests/kday3.out b/tests/kday3.out
new file mode 100644 (file)
index 0000000..f6fd728
--- /dev/null
@@ -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 (file)
index 0000000..e22de28
Binary files /dev/null and b/tests/kday3.pcap differ
diff --git a/tests/kday4.out b/tests/kday4.out
new file mode 100644 (file)
index 0000000..00836ee
--- /dev/null
@@ -0,0 +1,64 @@
+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
+       0x0000:  4510 0034 f5c8 4000 3e06 4504 cc09 3384  E..4..@.>.E...3.
+       0x0010:  cc09 3650 c39f 0016 49d1 c854 6c6f 1322  ..6P....I..Tlo."
+       0x0020:  8010 0ffc 858b 0000 0101 080a 381c 3209  ............8.2.
+       0x0030:  4fe7 cfd4                                O...
+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 (file)
index 0000000..f25e84a
Binary files /dev/null and b/tests/kday4.pcap differ
diff --git a/tests/kday5.out b/tests/kday5.out
new file mode 100644 (file)
index 0000000..7aeae72
--- /dev/null
@@ -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 (file)
index 0000000..759bf88
Binary files /dev/null and b/tests/kday5.pcap differ
diff --git a/tests/kday6.out b/tests/kday6.out
new file mode 100644 (file)
index 0000000..3b0ed96
--- /dev/null
@@ -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 (file)
index 0000000..7c6ab89
Binary files /dev/null and b/tests/kday6.pcap differ
diff --git a/tests/kday7.out b/tests/kday7.out
new file mode 100644 (file)
index 0000000..5179a0f
--- /dev/null
@@ -0,0 +1,63 @@
+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
+       0x0000:  4510 0034 f5c8 4000 3e06 4504 cc09 3384  E..4..@.>.E...3.
+       0x0010:  cc09 3650 c39f 0016 49d1 c854 6c6f 1322  ..6P....I..Tlo."
+       0x0020:  8010 0ffc 858b 0000 0101 080a 381c 3209  ............8.2.
+       0x0030:  4fe7 cfd4                                O...
+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 (file)
index 0000000..ec1da78
Binary files /dev/null and b/tests/kday7.pcap differ
diff --git a/tests/kday8.out b/tests/kday8.out
new file mode 100644 (file)
index 0000000..2d84b72
--- /dev/null
@@ -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 (file)
index 0000000..83577f6
Binary files /dev/null and b/tests/kday8.pcap differ
index d9fc6477872e2f45bbea3e17f634bc18c692ded9..5743b46670465adf7f6f74538abd29b7c913804e 100644 (file)
@@ -1,4 +1,4 @@
-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
+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), length 366: 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)
@@ -17,7 +17,7 @@
        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
+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), length 370: 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)
            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
+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), length 366: 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)
        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
+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), length 370: 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)
index dabc2f2be3994f117ba41976d64b206a1e844b0e..efec098facae9b368c519ac33d208e8d40704a7a 100644 (file)
@@ -1236,6 +1236,10 @@ IP (tos 0x0, ttl 64, id 53123, offset 0, flags [DF], proto TCP (6), length 144)
         action type OUTPUT, len 8, port 1
         data (60 octets), frame decoding below
 67:68:00:00:00:00 > 61:62:63:64:65:66 Null Information, send seq 0, rcv seq 0, Flags [Command], length 46
+       0x0000:  0000 0000 0000 0000 0000 0000 0000 0000  ................
+       0x0010:  0000 0000 0000 0000 0000 0000 0000 0000  ................
+       0x0020:  0000 0000 0000 0000 0000 0000 0000 0112  ................
+       0x0030:  0008 0000 0045                           .....E
        version 1.0, type BARRIER_REQUEST, length 8, xid 0x00000045
 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
     10.0.0.81.56068 > 10.0.0.20.6633: Flags [P.], cksum 0xb6f1 (correct), seq 14734:14742, ack 4821, win 1035, options [nop,nop,TS val 3 ecr 47837403], length 8: OpenFlow
diff --git a/util-print.c b/util-print.c
new file mode 100644 (file)
index 0000000..2c3eb65
--- /dev/null
@@ -0,0 +1,777 @@
+/*
+ * Copyright (c) 1990, 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.
+ */
+
+/*
+ * txtproto_print() derived from original code by Hannes Gredler
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <sys/stat.h>
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "interface.h"
+
+int32_t thiszone;              /* seconds offset from gmt to local time */
+
+/*
+ * 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(netdissect_options *ndo,
+         register const u_char *s, register const u_char *ep)
+{
+       register int ret;
+       register u_char c;
+
+       ret = 1;                        /* assume truncated */
+       while (ep == NULL || s < ep) {
+               c = *s++;
+               if (c == '\0') {
+                       ret = 0;
+                       break;
+               }
+               if (!ND_ISASCII(c)) {
+                       c = ND_TOASCII(c);
+                       ND_PRINT((ndo, "M-"));
+               }
+               if (!ND_ISPRINT(c)) {
+                       c ^= 0x40;      /* DEL to ?, others to alpha */
+                       ND_PRINT((ndo, "^"));
+               }
+               ND_PRINT((ndo, "%c", c));
+       }
+       return(ret);
+}
+
+/*
+ * Print out a counted filename (or other ascii string).
+ * If ep is NULL, assume no truncation check is needed.
+ * Return true if truncated.
+ */
+int
+fn_printn(netdissect_options *ndo,
+          register const u_char *s, register u_int n, register const u_char *ep)
+{
+       register u_char c;
+
+       while (n > 0 && (ep == NULL || s < ep)) {
+               n--;
+               c = *s++;
+               if (!ND_ISASCII(c)) {
+                       c = ND_TOASCII(c);
+                       ND_PRINT((ndo, "M-"));
+               }
+               if (!ND_ISPRINT(c)) {
+                       c ^= 0x40;      /* DEL to ?, others to alpha */
+                       ND_PRINT((ndo, "^"));
+               }
+               ND_PRINT((ndo, "%c", c));
+       }
+       return (n == 0) ? 0 : 1;
+}
+
+/*
+ * Print out a null-padded filename (or other ascii string).
+ * If ep is NULL, assume no truncation check is needed.
+ * Return true if truncated.
+ */
+int
+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;
+
+       ret = 1;                        /* assume truncated */
+       while (n > 0 && (ep == NULL || s < ep)) {
+               n--;
+               c = *s++;
+               if (c == '\0') {
+                       ret = 0;
+                       break;
+               }
+               if (!ND_ISASCII(c)) {
+                       c = ND_TOASCII(c);
+                       ND_PRINT((ndo, "M-"));
+               }
+               if (!ND_ISPRINT(c)) {
+                       c ^= 0x40;      /* DEL to ?, others to alpha */
+                       ND_PRINT((ndo, "^"));
+               }
+               ND_PRINT((ndo, "%c", c));
+       }
+       return (n == 0) ? 0 : ret;
+}
+
+/*
+ * Format the timestamp
+ */
+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.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;
+}
+
+/*
+ * Print the timestamp
+ */
+void
+ts_print(netdissect_options *ndo,
+         register const struct timeval *tvp)
+{
+       register int s;
+       struct tm *tm;
+       time_t Time;
+       static unsigned b_sec;
+       static unsigned b_usec;
+       int d_usec;
+       int d_sec;
+
+       switch (ndo->ndo_tflag) {
+
+       case 0: /* Default */
+               s = (tvp->tv_sec + thiszone) % 86400;
+               ND_PRINT((ndo, "%s ", ts_format(ndo, s, tvp->tv_usec)));
+               break;
+
+       case 1: /* No time stamp */
+               break;
+
+       case 2: /* Unix timeval style */
+               ND_PRINT((ndo, "%u.%06u ",
+                            (unsigned)tvp->tv_sec,
+                            (unsigned)tvp->tv_usec));
+               break;
+
+       case 3: /* Microseconds since previous packet */
+        case 5: /* Microseconds since first packet */
+               if (b_sec == 0) {
+                        /* init timestamp for first packet */
+                        b_usec = tvp->tv_usec;
+                        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--;
+                }
+
+                ND_PRINT((ndo, "%s ", ts_format(ndo, d_sec, d_usec)));
+
+                if (ndo->ndo_tflag == 3) { /* set timestamp for last packet */
+                    b_sec = tvp->tv_sec;
+                    b_usec = tvp->tv_usec;
+                }
+               break;
+
+       case 4: /* Default + Date*/
+               s = (tvp->tv_sec + thiszone) % 86400;
+               Time = (tvp->tv_sec + thiszone) - s;
+               tm = gmtime (&Time);
+               if (!tm)
+                       ND_PRINT((ndo, "Date fail  "));
+               else
+                       ND_PRINT((ndo, "%04d-%02d-%02d %s ",
+                               tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+                               ts_format(ndo, s, tvp->tv_usec)));
+               break;
+       }
+}
+
+/*
+ * Print a relative number of seconds (e.g. hold time, prune timer)
+ * in the form 5m1s.  This does no truncation, so 32230861 seconds
+ * is represented as 1y1w1d1h1m1s.
+ */
+void
+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};
+       const char **l = lengths;
+       const int *s = seconds;
+
+       if (secs == 0) {
+               ND_PRINT((ndo, "0s"));
+               return;
+       }
+       if (secs < 0) {
+               ND_PRINT((ndo, "-"));
+               secs = -secs;
+       }
+       while (secs > 0) {
+               if (secs >= *s) {
+                       ND_PRINT((ndo, "%d%s", secs / *s, *l));
+                       secs -= (secs / *s) * *s;
+               }
+               s++;
+               l++;
+       }
+}
+
+/*
+ *  this is a generic routine for printing unknown data;
+ *  we pass on the linefeed plus indentation string to
+ *  get a proper output - returns 0 on error
+ */
+
+int
+print_unknown_data(netdissect_options *ndo, const u_char *cp,const char *ident,int len)
+{
+       if (len < 0) {
+          ND_PRINT((ndo,"%sDissector error: print_unknown_data called with negative length",
+                   ident));
+               return(0);
+       }
+       if (ndo->ndo_snapend - cp < len)
+               len = ndo->ndo_snapend - cp;
+       if (len < 0) {
+          ND_PRINT((ndo,"%sDissector error: print_unknown_data called with pointer past end of packet",
+                   ident));
+               return(0);
+       }
+        hex_print(ndo, ident,cp,len);
+       return(1); /* everything is ok */
+}
+
+/*
+ * Convert a token value to a string; use "fmt" if not found.
+ */
+const char *
+tok2strbuf(register const struct tok *lp, register const char *fmt,
+          register u_int v, char *buf, size_t bufsize)
+{
+       if (lp != NULL) {
+               while (lp->s != NULL) {
+                       if (lp->v == v)
+                               return (lp->s);
+                       ++lp;
+               }
+       }
+       if (fmt == NULL)
+               fmt = "#%d";
+
+       (void)snprintf(buf, bufsize, fmt, v);
+       return (const char *)buf;
+}
+
+/*
+ * Convert a token value to a string; use "fmt" if not found.
+ */
+const char *
+tok2str(register const struct tok *lp, register const char *fmt,
+       register u_int v)
+{
+       static char buf[4][128];
+       static int idx = 0;
+       char *ret;
+
+       ret = buf[idx];
+       idx = (idx+1) & 3;
+       return tok2strbuf(lp, fmt, v, ret, sizeof(buf[0]));
+}
+
+/*
+ * Convert a bit token value to a string; use "fmt" if not found.
+ * this is useful for parsing bitfields, the output strings are seperated
+ * if the s field is positive.
+ */
+static char *
+bittok2str_internal(register const struct tok *lp, register const char *fmt,
+          register u_int v, const char *sep)
+{
+        static char buf[256]; /* our stringbuffer */
+        int buflen=0;
+        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 */
+            rotbit=1;
+            while (rotbit != 0) {
+                /*
+                 * lets AND the rotating bit with our token value
+                 * and see if we have got a match
+                 */
+               if (tokval == (v&rotbit)) {
+                    /* ok we have found something */
+                    buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s%s",
+                                     sepstr, lp->s);
+                    sepstr = sep;
+                    break;
+                }
+                rotbit=rotbit<<1; /* no match - lets shift and try again */
+            }
+            lp++;
+       }
+
+        if (buflen == 0)
+            /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
+            (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
+        return (buf);
+}
+
+/*
+ * Convert a bit token value to a string; use "fmt" if not found.
+ * this is useful for parsing bitfields, the output strings are not seperated.
+ */
+char *
+bittok2str_nosep(register const struct tok *lp, register const char *fmt,
+          register u_int v)
+{
+    return (bittok2str_internal(lp, fmt, v, ""));
+}
+
+/*
+ * Convert a bit token value to a string; use "fmt" if not found.
+ * this is useful for parsing bitfields, the output strings are comma seperated.
+ */
+char *
+bittok2str(register const struct tok *lp, register const char *fmt,
+          register u_int v)
+{
+    return (bittok2str_internal(lp, fmt, v, ", "));
+}
+
+/*
+ * Convert a value to a string using an array; the macro
+ * tok2strary() in <interface.h> is the public interface to
+ * this function and ensures that the second argument is
+ * correct for bounds-checking.
+ */
+const char *
+tok2strary_internal(register const char **lp, int n, register const char *fmt,
+       register int v)
+{
+       static char buf[128];
+
+       if (v >= 0 && v < n && lp[v] != NULL)
+               return lp[v];
+       if (fmt == NULL)
+               fmt = "#%d";
+       (void)snprintf(buf, sizeof(buf), fmt, v);
+       return (buf);
+}
+
+/*
+ * Convert a 32-bit netmask to prefixlen if possible
+ * the function returns the prefix-len; if plen == -1
+ * then conversion was not possible;
+ */
+
+int
+mask2plen(uint32_t mask)
+{
+       uint32_t bitmasks[33] = {
+               0x00000000,
+               0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
+               0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
+               0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
+               0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
+               0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000,
+               0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
+               0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0,
+               0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff
+       };
+       int prefix_len = 32;
+
+       /* let's see if we can transform the mask into a prefixlen */
+       while (prefix_len >= 0) {
+               if (bitmasks[prefix_len] == mask)
+                       break;
+               prefix_len--;
+       }
+       return (prefix_len);
+}
+
+#ifdef INET6
+int
+mask62plen(const u_char *mask)
+{
+       u_char bitmasks[9] = {
+               0x00,
+               0x80, 0xc0, 0xe0, 0xf0,
+               0xf8, 0xfc, 0xfe, 0xff
+       };
+       int byte;
+       int cidr_len = 0;
+
+       for (byte = 0; byte < 16; byte++) {
+               u_int bits;
+
+               for (bits = 0; bits < (sizeof (bitmasks) / sizeof (bitmasks[0])); bits++) {
+                       if (mask[byte] == bitmasks[bits]) {
+                               cidr_len += bits;
+                               break;
+                       }
+               }
+
+               if (mask[byte] != 0xff)
+                       break;
+       }
+       return (cidr_len);
+}
+#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);
+               }
+       }
+}
+
+void
+safeputs(netdissect_options *ndo,
+         const u_char *s, const u_int maxlen)
+{
+       u_int idx = 0;
+
+       while (*s && idx < maxlen) {
+               safeputchar(ndo, *s);
+               idx++;
+               s++;
+       }
+}
+
+void
+safeputchar(netdissect_options *ndo,
+            const u_char c)
+{
+       ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c));
+}
+
+#ifdef LBL_ALIGN
+/*
+ * Some compilers try to optimize memcpy(), using the alignment constraint
+ * on the argument pointer type.  by using this function, we try to avoid the
+ * optimization.
+ */
+void
+unaligned_memcpy(void *p, const void *q, size_t l)
+{
+       memcpy(p, q, l);
+}
+
+/* As with memcpy(), so with memcmp(). */
+int
+unaligned_memcmp(const void *p, const void *q, size_t l)
+{
+       return (memcmp(p, q, l));
+}
+#endif
+
diff --git a/util.c b/util.c
index 5569021c242ca7d9155f4bcdb68a19353cc6ea9b..4a20a4b50c412b4684b6cb921db9f8e327711fb6 100644 (file)
--- a/util.c
+++ b/util.c
@@ -35,7 +35,6 @@
  * FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include "interface.h"
 
-/*
- * 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(netdissect_options *ndo,
-         register const u_char *s, register const u_char *ep)
-{
-       register int ret;
-       register u_char c;
-
-       ret = 1;                        /* assume truncated */
-       while (ep == NULL || s < ep) {
-               c = *s++;
-               if (c == '\0') {
-                       ret = 0;
-                       break;
-               }
-               if (!ND_ISASCII(c)) {
-                       c = ND_TOASCII(c);
-                       ND_PRINT((ndo, "M-"));
-               }
-               if (!ND_ISPRINT(c)) {
-                       c ^= 0x40;      /* DEL to ?, others to alpha */
-                       ND_PRINT((ndo, "^"));
-               }
-               ND_PRINT((ndo, "%c", c));
-       }
-       return(ret);
-}
-
-/*
- * Print out a counted filename (or other ascii string).
- * If ep is NULL, assume no truncation check is needed.
- * Return true if truncated.
- */
-int
-fn_printn(netdissect_options *ndo,
-          register const u_char *s, register u_int n, register const u_char *ep)
-{
-       register u_char c;
-
-       while (n > 0 && (ep == NULL || s < ep)) {
-               n--;
-               c = *s++;
-               if (!ND_ISASCII(c)) {
-                       c = ND_TOASCII(c);
-                       ND_PRINT((ndo, "M-"));
-               }
-               if (!ND_ISPRINT(c)) {
-                       c ^= 0x40;      /* DEL to ?, others to alpha */
-                       ND_PRINT((ndo, "^"));
-               }
-               ND_PRINT((ndo, "%c", c));
-       }
-       return (n == 0) ? 0 : 1;
-}
-
-/*
- * Print out a null-padded filename (or other ascii string).
- * If ep is NULL, assume no truncation check is needed.
- * Return true if truncated.
- */
-int
-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;
-
-       ret = 1;                        /* assume truncated */
-       while (n > 0 && (ep == NULL || s < ep)) {
-               n--;
-               c = *s++;
-               if (c == '\0') {
-                       ret = 0;
-                       break;
-               }
-               if (!ND_ISASCII(c)) {
-                       c = ND_TOASCII(c);
-                       ND_PRINT((ndo, "M-"));
-               }
-               if (!ND_ISPRINT(c)) {
-                       c ^= 0x40;      /* DEL to ?, others to alpha */
-                       ND_PRINT((ndo, "^"));
-               }
-               ND_PRINT((ndo, "%c", c));
-       }
-       return (n == 0) ? 0 : ret;
-}
-
-/*
- * Format the timestamp
- */
-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.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;
-}
-
-/*
- * Print the timestamp
- */
-void
-ts_print(netdissect_options *ndo,
-         register const struct timeval *tvp)
-{
-       register int s;
-       struct tm *tm;
-       time_t Time;
-       static unsigned b_sec;
-       static unsigned b_usec;
-       int d_usec;
-       int d_sec;
-
-       switch (ndo->ndo_tflag) {
-
-       case 0: /* Default */
-               s = (tvp->tv_sec + thiszone) % 86400;
-               ND_PRINT((ndo, "%s ", ts_format(ndo, s, tvp->tv_usec)));
-               break;
-
-       case 1: /* No time stamp */
-               break;
-
-       case 2: /* Unix timeval style */
-               ND_PRINT((ndo, "%u.%06u ",
-                            (unsigned)tvp->tv_sec,
-                            (unsigned)tvp->tv_usec));
-               break;
-
-       case 3: /* Microseconds since previous packet */
-        case 5: /* Microseconds since first packet */
-               if (b_sec == 0) {
-                        /* init timestamp for first packet */
-                        b_usec = tvp->tv_usec;
-                        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--;
-                }
-
-                ND_PRINT((ndo, "%s ", ts_format(ndo, d_sec, d_usec)));
-
-                if (ndo->ndo_tflag == 3) { /* set timestamp for last packet */
-                    b_sec = tvp->tv_sec;
-                    b_usec = tvp->tv_usec;
-                }
-               break;
-
-       case 4: /* Default + Date*/
-               s = (tvp->tv_sec + thiszone) % 86400;
-               Time = (tvp->tv_sec + thiszone) - s;
-               tm = gmtime (&Time);
-               if (!tm)
-                       ND_PRINT((ndo, "Date fail  "));
-               else
-                       ND_PRINT((ndo, "%04d-%02d-%02d %s ",
-                               tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
-                               ts_format(ndo, s, tvp->tv_usec)));
-               break;
-       }
-}
-
-/*
- * Print a relative number of seconds (e.g. hold time, prune timer)
- * in the form 5m1s.  This does no truncation, so 32230861 seconds
- * is represented as 1y1w1d1h1m1s.
- */
-void
-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};
-       const char **l = lengths;
-       const int *s = seconds;
-
-       if (secs == 0) {
-               ND_PRINT((ndo, "0s"));
-               return;
-       }
-       if (secs < 0) {
-               ND_PRINT((ndo, "-"));
-               secs = -secs;
-       }
-       while (secs > 0) {
-               if (secs >= *s) {
-                       ND_PRINT((ndo, "%d%s", secs / *s, *l));
-                       secs -= (secs / *s) * *s;
-               }
-               s++;
-               l++;
-       }
-}
-
-/*
- *  this is a generic routine for printing unknown data;
- *  we pass on the linefeed plus indentation string to
- *  get a proper output - returns 0 on error
- */
-
-int
-print_unknown_data(netdissect_options *ndo, const u_char *cp,const char *ident,int len)
-{
-       if (len < 0) {
-          ND_PRINT((ndo,"%sDissector error: print_unknown_data called with negative length",
-                   ident));
-               return(0);
-       }
-       if (ndo->ndo_snapend - cp < len)
-               len = ndo->ndo_snapend - cp;
-       if (len < 0) {
-          ND_PRINT((ndo,"%sDissector error: print_unknown_data called with pointer past end of packet",
-                   ident));
-               return(0);
-       }
-        hex_print(ndo, ident,cp,len);
-       return(1); /* everything is ok */
-}
-
-/*
- * Convert a token value to a string; use "fmt" if not found.
- */
-const char *
-tok2strbuf(register const struct tok *lp, register const char *fmt,
-          register u_int v, char *buf, size_t bufsize)
-{
-       if (lp != NULL) {
-               while (lp->s != NULL) {
-                       if (lp->v == v)
-                               return (lp->s);
-                       ++lp;
-               }
-       }
-       if (fmt == NULL)
-               fmt = "#%d";
-
-       (void)snprintf(buf, bufsize, fmt, v);
-       return (const char *)buf;
-}
-
-/*
- * Convert a token value to a string; use "fmt" if not found.
- */
-const char *
-tok2str(register const struct tok *lp, register const char *fmt,
-       register int v)
-{
-       static char buf[4][128];
-       static int idx = 0;
-       char *ret;
-
-       ret = buf[idx];
-       idx = (idx+1) & 3;
-       return tok2strbuf(lp, fmt, v, ret, sizeof(buf[0]));
-}
-
-/*
- * Convert a bit token value to a string; use "fmt" if not found.
- * this is useful for parsing bitfields, the output strings are seperated
- * if the s field is positive.
- */
-static char *
-bittok2str_internal(register const struct tok *lp, register const char *fmt,
-          register int v, register int 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;
-        const char * sepstr = "";
-
-       while (lp != NULL && lp->s != NULL) {
-            tokval=lp->v;   /* load our first value */
-            rotbit=1;
-            while (rotbit != 0) {
-                /*
-                 * lets AND the rotating bit with our token value
-                 * and see if we have got a match
-                 */
-               if (tokval == (v&rotbit)) {
-                    /* ok we have found something */
-                    buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s%s",
-                                     sepstr, lp->s);
-                    sepstr = sep ? ", " : "";
-                    break;
-                }
-                rotbit=rotbit<<1; /* no match - lets shift and try again */
-            }
-            lp++;
-       }
-
-        if (buflen == 0)
-            /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
-            (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%d" : fmt, v);
-        return (buf);
-}
-
-/*
- * Convert a bit token value to a string; use "fmt" if not found.
- * this is useful for parsing bitfields, the output strings are not seperated.
- */
-char *
-bittok2str_nosep(register const struct tok *lp, register const char *fmt,
-          register int v)
-{
-    return (bittok2str_internal(lp, fmt, v, 0));
-}
-
-/*
- * Convert a bit token value to a string; use "fmt" if not found.
- * this is useful for parsing bitfields, the output strings are comma seperated.
- */
-char *
-bittok2str(register const struct tok *lp, register const char *fmt,
-          register int v)
-{
-    return (bittok2str_internal(lp, fmt, v, 1));
-}
-
-/*
- * Convert a value to a string using an array; the macro
- * tok2strary() in <interface.h> is the public interface to
- * this function and ensures that the second argument is
- * correct for bounds-checking.
- */
-const char *
-tok2strary_internal(register const char **lp, int n, register const char *fmt,
-       register int v)
-{
-       static char buf[128];
-
-       if (v >= 0 && v < n && lp[v] != NULL)
-               return lp[v];
-       if (fmt == NULL)
-               fmt = "#%d";
-       (void)snprintf(buf, sizeof(buf), fmt, v);
-       return (buf);
-}
-
-/*
- * Convert a 32-bit netmask to prefixlen if possible
- * the function returns the prefix-len; if plen == -1
- * then conversion was not possible;
- */
-
-int
-mask2plen(uint32_t mask)
-{
-       uint32_t bitmasks[33] = {
-               0x00000000,
-               0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
-               0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
-               0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
-               0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
-               0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000,
-               0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
-               0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0,
-               0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff
-       };
-       int prefix_len = 32;
-
-       /* let's see if we can transform the mask into a prefixlen */
-       while (prefix_len >= 0) {
-               if (bitmasks[prefix_len] == mask)
-                       break;
-               prefix_len--;
-       }
-       return (prefix_len);
-}
-
-#ifdef INET6
-int
-mask62plen(const u_char *mask)
-{
-       u_char bitmasks[9] = {
-               0x00,
-               0x80, 0xc0, 0xe0, 0xf0,
-               0xf8, 0xfc, 0xfe, 0xff
-       };
-       int byte;
-       int cidr_len = 0;
-
-       for (byte = 0; byte < 16; byte++) {
-               u_int bits;
-
-               for (bits = 0; bits < (sizeof (bitmasks) / sizeof (bitmasks[0])); bits++) {
-                       if (mask[byte] == bitmasks[bits]) {
-                               cidr_len += bits;
-                               break;
-                       }
-               }
-
-               if (mask[byte] != 0xff)
-                       break;
-       }
-       return (cidr_len);
-}
-#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, ...)
@@ -848,43 +167,3 @@ read_infile(char *fname)
        cp[cc] = '\0';
        return (cp);
 }
-
-void
-safeputs(netdissect_options *ndo,
-         const u_char *s, const u_int maxlen)
-{
-       u_int idx = 0;
-
-       while (*s && idx < maxlen) {
-               safeputchar(ndo, *s);
-               idx++;
-               s++;
-       }
-}
-
-void
-safeputchar(netdissect_options *ndo,
-            const u_char c)
-{
-       ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c));
-}
-
-#ifdef LBL_ALIGN
-/*
- * Some compilers try to optimize memcpy(), using the alignment constraint
- * on the argument pointer type.  by using this function, we try to avoid the
- * optimization.
- */
-void
-unaligned_memcpy(void *p, const void *q, size_t l)
-{
-       memcpy(p, q, l);
-}
-
-/* As with memcpy(), so with memcmp(). */
-int
-unaligned_memcmp(const void *p, const void *q, size_t l)
-{
-       return (memcmp(p, q, l));
-}
-#endif