]> The Tcpdump Group git mirrors - tcpdump/commitdiff
NDOize more small decoders
authorDenis Ovsienko <[email protected]>
Wed, 12 Mar 2014 16:02:32 +0000 (20:02 +0400)
committerDenis Ovsienko <[email protected]>
Wed, 12 Mar 2014 16:02:32 +0000 (20:02 +0400)
This change converts decoders for: DLT_RAW, IPv6 routing header, USB,
Symantec firewall and cHDLC.

12 files changed:
interface.h
netdissect.h
print-chdlc.c
print-ip.c
print-ip6.c
print-juniper.c
print-ppp.c
print-raw.c
print-rt6.c
print-symantec.c
print-usb.c
tcpdump.c

index 6ac6ab4648955f43639af86950e5fd8137f92d7c..63e6247766cc4637da1fe00b244e2d1687005465 100644 (file)
@@ -213,7 +213,6 @@ extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *,
        const u_char *);
 extern void icmp_print(const u_char *, u_int, const u_char *, int);
 extern void igmp_print(const u_char *, u_int);
-extern void ipN_print(const u_char *, u_int);
 extern void ipx_print(const u_char *, u_int);
 extern void isoclns_print(const u_char *, u_int, u_int);
 extern void krb_print(const u_char *);
@@ -250,12 +249,9 @@ extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void q933_print(const u_char *, u_int);
 extern void vqp_print(register const u_char *, register u_int);
-extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void rip_print(const u_char *, u_int);
 extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_print(register const u_char *, u_int);
 extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int juniper_mfr_print(const struct pcap_pkthdr *, register const u_char *);
@@ -274,7 +270,6 @@ extern u_int juniper_chdlc_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void snmp_print(const u_char *, u_int);
 extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
-extern u_int symantec_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void tcp_print(const u_char *, u_int, const u_char *, int);
 extern void tftp_print(const u_char *, u_int);
 extern void timed_print(const u_char *);
@@ -314,8 +309,6 @@ extern void zmtp1_print_datagram(const u_char *, const u_int);
 extern void sip_print(const u_char *, u_int);
 extern void syslog_print(const u_char *, u_int);
 extern int mptcp_print(const u_char *, u_int, u_char);
-extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
 
 
 #ifdef INET6
@@ -324,7 +317,6 @@ extern int hbhopt_print(const u_char *);
 extern int dstopt_print(const u_char *);
 extern int mobility_print(const u_char *, const u_char *);
 extern void ripng_print(const u_char *, unsigned int);
-extern int rt6_print(const u_char *, const u_char *);
 extern void ospf6_print(const u_char *, u_int);
 extern void dhcp6_print(const u_char *, u_int);
 extern void babel_print(const u_char *, u_int);
index 9cbf6aa0f1834c9c63a89f6b6e844c9d5eb8bece..9cc9b73e6360b52ff165e7352bf24f1e2df6b5e3 100644 (file)
@@ -392,6 +392,13 @@ extern u_int arcnet_linux_if_print(netdissect_options *, const struct pcap_pkthd
 extern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
 extern void gre_print(netdissect_options *, const u_char *, u_int);
 extern int vjc_print(netdissect_options *, register const char *, u_short);
+extern void ipN_print(netdissect_options *, const u_char *, u_int);
+extern u_int raw_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_48_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_64_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int symantec_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int chdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
 
 /* stuff that has not yet been rototiled */
 extern const u_char * ns_nprint (register const u_char *, register const u_char *);
@@ -412,10 +419,6 @@ extern void bootp_print(netdissect_options *,const u_char *,
                        u_int, u_short, u_short);
 extern void bgp_print(netdissect_options *,const u_char *, int);
 extern void bxxp_print(netdissect_options *,const u_char *, u_int);
-extern void chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
-                          register const u_char *p);
-extern void chdlc_print(netdissect_options *ndo,
-                       register const u_char *p, u_int length, u_int caplen);
 extern void cisco_autorp_print(netdissect_options *,
                               const u_char *, u_int);
 extern void cnfp_print(netdissect_options *,const u_char *cp,
@@ -439,7 +442,6 @@ extern void igmp_print(netdissect_options *,
                       register const u_char *, u_int);
 extern void igrp_print(netdissect_options *,const u_char *, u_int,
                       const u_char *);
-extern void ipN_print(netdissect_options *,const u_char *, u_int);
 extern void ipx_print(netdissect_options *,const u_char *, u_int);
 extern void isoclns_print(netdissect_options *,const u_char *,
                          u_int, u_int, const u_char *, const u_char *);
@@ -477,9 +479,6 @@ extern void ppp_hdlc_if_print(u_char *,
 extern void ppp_bsdos_if_print(u_char *,
                               const struct pcap_pkthdr *, const u_char *);
 
-extern void raw_if_print(u_char *,
-                        const struct pcap_pkthdr *, const u_char *);
-
 extern void rip_print(netdissect_options *,const u_char *, u_int);
 extern void rpki_rtr_print(netdissect_options *,const u_char *, u_int);
 
@@ -541,6 +540,7 @@ extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr
 #ifdef INET6
 extern void ip6_print(netdissect_options *,const u_char *, u_int);
 extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
+extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
 #if 0
 extern void ip6_opt_print(netdissect_options *,const u_char *, int);
 extern int hbhopt_print(netdissect_options *,const u_char *);
@@ -548,7 +548,6 @@ extern int dstopt_print(netdissect_options *,const u_char *);
 extern void icmp6_print(netdissect_options *,const u_char *,
                        const u_char *);
 extern void ripng_print(netdissect_options *,const u_char *, int);
-extern int rt6_print(netdissect_options *,const u_char *, const u_char *);
 extern void ospf6_print(netdissect_options *,const u_char *, u_int);
 extern void dhcp6_print(netdissect_options *,const u_char *,
                        u_int, u_int16_t, u_int16_t);
index 74edb40a24430a2d66d1b3ae66e9bf23649ecba0..f84007478312b68ea0065c248b64ebaec6496484 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "ethertype.h"
 #include "extract.h"
-#include "ppp.h"
 #include "chdlc.h"
 
-static void chdlc_slarp_print(const u_char *, u_int);
+static void chdlc_slarp_print(netdissect_options *, const u_char *, u_int);
 
 static const struct tok chdlc_cast_values[] = {
     { CHDLC_UNICAST, "unicast" },
@@ -45,29 +42,29 @@ static const struct tok chdlc_cast_values[] = {
 
 /* Standard CHDLC printer */
 u_int
-chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
        register u_int length = h->len;
        register u_int caplen = h->caplen;
 
        if (caplen < CHDLC_HDRLEN) {
-               printf("[|chdlc]");
+               ND_PRINT((ndo, "[|chdlc]"));
                return (caplen);
        }
-        return (chdlc_print(p,length));
+        return (chdlc_print(ndo, p,length));
 }
 
 u_int
-chdlc_print(register const u_char *p, u_int length) {
+chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
        u_int proto;
 
        proto = EXTRACT_16BITS(&p[2]);
-       if (eflag) {
-                printf("%s, ethertype %s (0x%04x), length %u: ",
+       if (ndo->ndo_eflag) {
+                ND_PRINT((ndo, "%s, ethertype %s (0x%04x), length %u: ",
                        tok2str(chdlc_cast_values, "0x%02x", p[0]),
                        tok2str(ethertype_values, "Unknown", proto),
                        proto,
-                       length);
+                       length));
        }
 
        length -= CHDLC_HDRLEN;
@@ -75,15 +72,15 @@ chdlc_print(register const u_char *p, u_int length) {
 
        switch (proto) {
        case ETHERTYPE_IP:
-               ip_print(gndo, p, length);
+               ip_print(ndo, p, length);
                break;
 #ifdef INET6
        case ETHERTYPE_IPV6:
-               ip6_print(gndo, p, length);
+               ip6_print(ndo, p, length);
                break;
 #endif
        case CHDLC_TYPE_SLARP:
-               chdlc_slarp_print(p, length);
+               chdlc_slarp_print(ndo, p, length);
                break;
 #if 0
        case CHDLC_TYPE_CDP:
@@ -104,8 +101,8 @@ chdlc_print(register const u_char *p, u_int length) {
                     isoclns_print(p, length, length);
                 break;
        default:
-                if (!eflag)
-                        printf("unknown CHDLC protocol (0x%04x)", proto);
+                if (!ndo->ndo_eflag)
+                        ND_PRINT((ndo, "unknown CHDLC protocol (0x%04x)", proto));
                 break;
        }
 
@@ -137,20 +134,20 @@ struct cisco_slarp {
 #define SLARP_MAX_LEN  18
 
 static void
-chdlc_slarp_print(const u_char *cp, u_int length)
+chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
 {
        const struct cisco_slarp *slarp;
         u_int sec,min,hrs,days;
 
-        printf("SLARP (length: %u), ",length);
+       ND_PRINT((ndo, "SLARP (length: %u), ",length));
        if (length < SLARP_MIN_LEN)
                goto trunc;
 
        slarp = (const struct cisco_slarp *)cp;
-       TCHECK2(*slarp, SLARP_MIN_LEN);
+       ND_TCHECK2(*slarp, SLARP_MIN_LEN);
        switch (EXTRACT_32BITS(&slarp->code)) {
        case SLARP_REQUEST:
-               printf("request");
+               ND_PRINT((ndo, "request"));
                /*
                 * At least according to William "Chops" Westfield's
                 * message in
@@ -162,42 +159,42 @@ chdlc_slarp_print(const u_char *cp, u_int length)
                 */
                break;
        case SLARP_REPLY:
-               printf("reply %s/%s",
+               ND_PRINT((ndo, "reply %s/%s",
                        ipaddr_string(&slarp->un.addr.addr),
-                       ipaddr_string(&slarp->un.addr.mask));
+                       ipaddr_string(&slarp->un.addr.mask)));
                break;
        case SLARP_KEEPALIVE:
-               printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
+               ND_PRINT((ndo, "keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
                        EXTRACT_32BITS(&slarp->un.keep.myseq),
                        EXTRACT_32BITS(&slarp->un.keep.yourseq),
-                       EXTRACT_16BITS(&slarp->un.keep.rel));
+                       EXTRACT_16BITS(&slarp->un.keep.rel)));
 
                 if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */
                         cp += SLARP_MIN_LEN;
-                        if (!TTEST2(*cp, 4))
+                        if (!ND_TTEST2(*cp, 4))
                                 goto trunc;
                         sec = EXTRACT_32BITS(cp) / 1000;
                         min = sec / 60; sec -= min * 60;
                         hrs = min / 60; min -= hrs * 60;
                         days = hrs / 24; hrs -= days * 24;
-                        printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec);
+                        ND_PRINT((ndo, ", link uptime=%ud%uh%um%us",days,hrs,min,sec));
                 }
                break;
        default:
-               printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code));
-                if (vflag <= 1)
-                    print_unknown_data(gndo,cp+4,"\n\t",length-4);
+               ND_PRINT((ndo, "0x%02x unknown", EXTRACT_32BITS(&slarp->code)));
+                if (ndo->ndo_vflag <= 1)
+                    print_unknown_data(ndo,cp+4,"\n\t",length-4);
                break;
        }
 
-       if (SLARP_MAX_LEN < length && vflag)
-               printf(", (trailing junk: %d bytes)", length - SLARP_MAX_LEN);
-        if (vflag > 1)
-            print_unknown_data(gndo,cp+4,"\n\t",length-4);
+       if (SLARP_MAX_LEN < length && ndo->ndo_vflag)
+               ND_PRINT((ndo, ", (trailing junk: %d bytes)", length - SLARP_MAX_LEN));
+        if (ndo->ndo_vflag > 1)
+            print_unknown_data(ndo,cp+4,"\n\t",length-4);
        return;
 
 trunc:
-       printf("[|slarp]");
+       ND_PRINT((ndo, "[|slarp]"));
 }
 
 
index b37b2b3319cc8bba66e30197f940d1a7f065e98a..977f50faeb04a59d74e8bf337ace8fdf8beded32 100644 (file)
@@ -668,7 +668,7 @@ ip_print(netdissect_options *ndo,
 }
 
 void
-ipN_print(register const u_char *bp, register u_int length)
+ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
 {
        struct ip hdr;
 
@@ -679,11 +679,11 @@ ipN_print(register const u_char *bp, register u_int length)
        memcpy (&hdr, bp, 4);
        switch (IP_V(&hdr)) {
        case 4:
-               ip_print (gndo, bp, length);
+               ip_print (ndo, bp, length);
                return;
 #ifdef INET6
        case 6:
-               ip6_print (gndo, bp, length);
+               ip6_print (ndo, bp, length);
                return;
 #endif
        default:
index b06e93607ebba5465bbdcb921a680414f8001c73..d3fe53a6d8fb291b5f2a24686a824ed982a8ecf1 100644 (file)
@@ -184,7 +184,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
                        nh = *cp;
                        return;
                case IPPROTO_ROUTING:
-                       advance = rt6_print(cp, (const u_char *)ip6);
+                       advance = rt6_print(ndo, cp, (const u_char *)ip6);
                        nh = *cp;
                        break;
                case IPPROTO_SCTP:
index 3f93a36c3710b4ef0af552a06dbde58d6c9a12a0..c375e7f715fd4032df1e6572d847414f980df35f 100644 (file)
@@ -712,7 +712,7 @@ juniper_chdlc_print(const struct pcap_pkthdr *h, register const u_char *p)
 
         p+=l2info.header_len;
         /* this DLT contains nothing but raw c-hdlc frames */
-        chdlc_print(p, l2info.length);
+        chdlc_print(gndo, p, l2info.length);
         return l2info.header_len;
 }
 #endif
index b22439871d85b5b046fdb842e8a709dc8a43169d..47cb959d0b423a21954bce9b9a47fd9face26cb7 100644 (file)
@@ -1665,7 +1665,7 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 
        case CHDLC_UNICAST:
        case CHDLC_BCAST:
-               return (chdlc_if_print(h, p));
+               return (chdlc_if_print(gndo, h, p));
 
        default:
                if (eflag)
index 2aa07f2056c2cf6497701013e5a5d528cbd0e441..83f66b488efa66bbc87a0858b09dab076ff4ccd4 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
 
 /*
  * The DLT_RAW packet has no header. It contains a raw IP packet.
  */
 
 u_int
-raw_if_print(const struct pcap_pkthdr *h, const u_char *p)
+raw_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
-       if (eflag)
-               printf("ip: ");
+       if (ndo->ndo_eflag)
+               ND_PRINT((ndo, "ip: "));
 
-       ipN_print(p, h->len);
+       ipN_print(ndo, p, h->len);
 
        return (0);
 }
index b3064eb8624a85695005024e6226530f9d3bf747..798598be89d3f0e95f19a759e3ffeb02de814453 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "ip6.h"
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
 
 int
-rt6_print(register const u_char *bp, const u_char *bp2 _U_)
+rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2 _U_)
 {
        register const struct ip6_rthdr *dp;
        register const struct ip6_rthdr0 *dp0;
@@ -48,13 +46,13 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
        len = dp->ip6r_len;
 
        /* 'ep' points to the end of available data. */
-       ep = snapend;
+       ep = ndo->ndo_snapend;
 
-       TCHECK(dp->ip6r_segleft);
+       ND_TCHECK(dp->ip6r_segleft);
 
-       printf("srcrt (len=%d", dp->ip6r_len);  /*)*/
-       printf(", type=%d", dp->ip6r_type);
-       printf(", segleft=%d", dp->ip6r_segleft);
+       ND_PRINT((ndo, "srcrt (len=%d", dp->ip6r_len)); /*)*/
+       ND_PRINT((ndo, ", type=%d", dp->ip6r_type));
+       ND_PRINT((ndo, ", segleft=%d", dp->ip6r_segleft));
 
        switch (dp->ip6r_type) {
 #ifndef IPV6_RTHDR_TYPE_0
@@ -67,10 +65,10 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
        case IPV6_RTHDR_TYPE_2:                 /* Mobile IPv6 ID-20 */
                dp0 = (struct ip6_rthdr0 *)dp;
 
-               TCHECK(dp0->ip6r0_reserved);
-               if (dp0->ip6r0_reserved || vflag) {
-                       printf(", rsv=0x%0x",
-                           EXTRACT_32BITS(&dp0->ip6r0_reserved));
+               ND_TCHECK(dp0->ip6r0_reserved);
+               if (dp0->ip6r0_reserved || ndo->ndo_vflag) {
+                       ND_PRINT((ndo, ", rsv=0x%0x",
+                           EXTRACT_32BITS(&dp0->ip6r0_reserved)));
                }
 
                if (len % 2 == 1)
@@ -81,11 +79,11 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
                        if ((u_char *)(addr + 1) > ep)
                                goto trunc;
 
-                       printf(", [%d]%s", i, ip6addr_string(addr));
+                       ND_PRINT((ndo, ", [%d]%s", i, ip6addr_string(addr)));
                        addr++;
                }
                /*(*/
-               printf(") ");
+               ND_PRINT((ndo, ") "));
                return((dp0->ip6r0_len + 1) << 3);
                break;
        default:
@@ -94,7 +92,7 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
        }
 
  trunc:
-       fputs("[|srcrt]", stdout);
+       ND_PRINT((ndo, "[|srcrt]"));
        return -1;
 }
 #endif /* INET6 */
index f636308a7fe6433d42ba3d90856048f636973b2d..fd19286e6852a2f684bd7a15ddb616f067f8d262 100644 (file)
@@ -25,9 +25,7 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "ethertype.h"
 
@@ -40,7 +38,7 @@ struct symantec_header {
 };
 
 static inline void
-symantec_hdr_print(register const u_char *bp, u_int length)
+symantec_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
 {
        register const struct symantec_header *sp;
        u_int16_t etype;
@@ -48,21 +46,21 @@ symantec_hdr_print(register const u_char *bp, u_int length)
        sp = (const struct symantec_header *)bp;
 
        etype = EXTRACT_16BITS(&sp->ether_type);
-       if (!qflag) {
+       if (!ndo->ndo_qflag) {
                if (etype <= ETHERMTU)
-                         (void)printf("invalid ethertype %u", etype);
+                         ND_PRINT((ndo, "invalid ethertype %u", etype));
                 else
-                         (void)printf("ethertype %s (0x%04x)",
+                         ND_PRINT((ndo, "ethertype %s (0x%04x)",
                                       tok2str(ethertype_values,"Unknown", etype),
-                                       etype);
+                                       etype));
         } else {
                 if (etype <= ETHERMTU)
-                          (void)printf("invalid ethertype %u", etype);
+                          ND_PRINT((ndo, "invalid ethertype %u", etype));
                 else
-                          (void)printf("%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype));
+                          ND_PRINT((ndo, "%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype)));
         }
 
-       (void)printf(", length %u: ", length);
+       ND_PRINT((ndo, ", length %u: ", length));
 }
 
 /*
@@ -72,7 +70,7 @@ symantec_hdr_print(register const u_char *bp, u_int length)
  * is the number of bytes actually captured.
  */
 u_int
-symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
+symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
@@ -80,12 +78,12 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
        u_short ether_type;
 
        if (caplen < sizeof (struct symantec_header)) {
-               printf("[|symantec]");
+               ND_PRINT((ndo, "[|symantec]"));
                return caplen;
        }
 
-       if (eflag)
-               symantec_hdr_print(p, length);
+       if (ndo->ndo_eflag)
+               symantec_hdr_print(ndo, p, length);
 
        length -= sizeof (struct symantec_header);
        caplen -= sizeof (struct symantec_header);
@@ -96,18 +94,18 @@ symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
 
        if (ether_type <= ETHERMTU) {
                /* ether_type not known, print raw packet */
-               if (!eflag)
-                       symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+               if (!ndo->ndo_eflag)
+                       symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
 
-               if (!suppress_default_print)
-                       default_print(p, caplen);
-       } else if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+               if (!ndo->ndo_suppress_default_print)
+                       ndo->ndo_default_print(ndo, p, caplen);
+       } else if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
                /* ether_type not known, print raw packet */
-               if (!eflag)
-                       symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+               if (!ndo->ndo_eflag)
+                       symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
 
-               if (!suppress_default_print)
-                       default_print(p, caplen);
+               if (!ndo->ndo_suppress_default_print)
+                       ndo->ndo_default_print(ndo, p, caplen);
        }
 
        return (sizeof (struct symantec_header));
index 4db5d5074a368feb071272d3daf606daae1e761e..7f453e33a28ac24be3782f87d019df63373beb46 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
 
 
 #if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
@@ -82,49 +79,49 @@ get_direction(int transfer_type, int event_type)
 }
 
 static void
-usb_header_print(const pcap_usb_header *uh)
+usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
 {
        int direction;
 
        switch(uh->transfer_type)
        {
                case URB_ISOCHRONOUS:
-                       printf("ISOCHRONOUS");
+                       ND_PRINT((ndo, "ISOCHRONOUS"));
                        break;
                case URB_INTERRUPT:
-                       printf("INTERRUPT");
+                       ND_PRINT((ndo, "INTERRUPT"));
                        break;
                case URB_CONTROL:
-                       printf("CONTROL");
+                       ND_PRINT((ndo, "CONTROL"));
                        break;
                case URB_BULK:
-                       printf("BULK");
+                       ND_PRINT((ndo, "BULK"));
                        break;
                default:
-                       printf(" ?");
+                       ND_PRINT((ndo, " ?"));
        }
 
        switch(uh->event_type)
        {
                case URB_SUBMIT:
-                       printf(" SUBMIT");
+                       ND_PRINT((ndo, " SUBMIT"));
                        break;
                case URB_COMPLETE:
-                       printf(" COMPLETE");
+                       ND_PRINT((ndo, " COMPLETE"));
                        break;
                case URB_ERROR:
-                       printf(" ERROR");
+                       ND_PRINT((ndo, " ERROR"));
                        break;
                default:
-                       printf(" ?");
+                       ND_PRINT((ndo, " ?"));
        }
 
        direction = get_direction(uh->transfer_type, uh->event_type);
        if(direction == 1)
-               printf(" from");
+               ND_PRINT((ndo, " from"));
        else if(direction == 2)
-               printf(" to");
-       printf(" %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f);
+               ND_PRINT((ndo, " to"));
+       ND_PRINT((ndo, " %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f));
 }
 
 /*
@@ -136,14 +133,15 @@ usb_header_print(const pcap_usb_header *uh)
  * is the number of bytes actually captured.
  */
 u_int
-usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_48_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+                        register const u_char *p)
 {
        if (h->caplen < sizeof(pcap_usb_header)) {
-               printf("%s", tstr);
+               ND_PRINT((ndo, "%s", tstr));
                return(sizeof(pcap_usb_header));
        }
 
-       usb_header_print((const pcap_usb_header *) p);
+       usb_header_print(ndo, (const pcap_usb_header *) p);
 
        return(sizeof(pcap_usb_header));
 }
@@ -158,14 +156,15 @@ usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
  * is the number of bytes actually captured.
  */
 u_int
-usb_linux_64_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_64_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+                        register const u_char *p)
 {
        if (h->caplen < sizeof(pcap_usb_header_mmapped)) {
-               printf("%s", tstr);
+               ND_PRINT((ndo, "%s", tstr));
                return(sizeof(pcap_usb_header_mmapped));
        }
 
-       usb_header_print((const pcap_usb_header *) p);
+       usb_header_print(ndo, (const pcap_usb_header *) p);
 
        return(sizeof(pcap_usb_header_mmapped));
 }
index d820edd4db8f5a7e2a21454ab5f09590e373944d..251c73a3dccb627c8c8991cf8dc5fbeff5cba54c 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -180,14 +180,7 @@ static const struct printer printers[] = {
        { ppp_bsdos_if_print,   DLT_PPP_BSDOS },
 #endif
        { fddi_if_print,        DLT_FDDI },
-       { raw_if_print,         DLT_RAW },
        { atm_if_print,         DLT_ATM_RFC1483 },
-#ifdef DLT_C_HDLC
-       { chdlc_if_print,       DLT_C_HDLC },
-#endif
-#ifdef DLT_HDLC
-       { chdlc_if_print,       DLT_HDLC },
-#endif
 #ifdef DLT_PPP_SERIAL
        { ppp_hdlc_if_print,    DLT_PPP_SERIAL },
 #endif
@@ -224,9 +217,6 @@ static const struct printer printers[] = {
 #ifdef DLT_ENC
        { enc_if_print,         DLT_ENC },
 #endif
-#ifdef DLT_SYMANTEC_FIREWALL
-       { symantec_if_print,    DLT_SYMANTEC_FIREWALL },
-#endif
 #ifdef DLT_IEEE802_11_RADIO_AVS
        { ieee802_11_radio_avs_if_print,        DLT_IEEE802_11_RADIO_AVS },
 #endif
@@ -277,20 +267,6 @@ static const struct printer printers[] = {
 #endif
 #ifdef DLT_MFR
        { mfr_if_print,         DLT_MFR },
-#endif
-#ifdef HAVE_PCAP_USB_H
-#ifdef DLT_USB_LINUX
-       { usb_linux_48_byte_print, DLT_USB_LINUX},
-#endif /* DLT_USB_LINUX */
-#ifdef DLT_USB_LINUX_MMAPPED
-       { usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
-#endif /* DLT_USB_LINUX_MMAPPED */
-#endif /* HAVE_PCAP_USB_H */
-#ifdef DLT_IPV4
-       { raw_if_print,         DLT_IPV4 },
-#endif
-#ifdef DLT_IPV6
-       { raw_if_print,         DLT_IPV6 },
 #endif
        { NULL,                 0 },
 };
@@ -343,6 +319,30 @@ static const struct ndo_printer ndo_printers[] = {
        { 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
        { NULL,                 0 },
 };