]> The Tcpdump Group git mirrors - tcpdump/commitdiff
NDOize 5 more decoders
authorDenis Ovsienko <[email protected]>
Fri, 7 Mar 2014 13:52:45 +0000 (17:52 +0400)
committerDenis Ovsienko <[email protected]>
Fri, 7 Mar 2014 15:51:31 +0000 (19:51 +0400)
Update Apple's IP over IEEE1394, Bluetooth, CALM/FAST, IPv6 fragments
and LAN emulation decoders. Remove some stray passages while at it.

interface.h
netdissect.h
print-ap1394.c
print-atm.c
print-bt.c
print-calm-fast.c
print-frag6.c
print-ip6.c
print-lane.c
tcpdump.c

index 49372ac8f9bc6992bfa32c0c2cacc5026157a10b..e00748af8edf829fe8aa2533f3191c4d34e65a95 100644 (file)
@@ -211,7 +211,6 @@ extern char *q922_string(const u_char *);
 extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
        const u_char *);
-extern u_int ap1394_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *,
        const u_char *);
 extern void gre_print(const u_char *, u_int);
@@ -258,8 +257,6 @@ extern void vqp_print(register const u_char *, register u_int);
 extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void rip_print(const u_char *, u_int);
 extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void lane_print(const u_char *, u_int, u_int);
-extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int 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);
@@ -322,7 +319,6 @@ extern void bfd_print(const u_char *, u_int, u_int);
 extern void sip_print(const u_char *, u_int);
 extern void syslog_print(const u_char *, u_int);
 extern int mptcp_print(const u_char *, u_int, u_char);
-extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
 extern void vxlan_print(const u_char *, u_int);
@@ -334,7 +330,6 @@ extern void ahcp_print(const u_char *, const u_int);
 extern void ip6_opt_print(const u_char *, int);
 extern int hbhopt_print(const u_char *);
 extern int dstopt_print(const u_char *);
-extern int frag6_print(const u_char *, const u_char *);
 extern int mobility_print(const u_char *, const u_char *);
 extern void ripng_print(const u_char *, unsigned int);
 extern int rt6_print(const u_char *, const u_char *);
index e55502983ad6dbf81952c4f3ce860b7d44288a7c..25618c7a480fdc9fe38708a45b0467a54907dc65 100644 (file)
@@ -380,6 +380,10 @@ extern void igrp_print(netdissect_options *, const u_char *, u_int);
 extern void msdp_print(netdissect_options *, const u_char *, u_int);
 extern u_int null_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 extern void mobile_print(netdissect_options *, const u_char *, u_int);
+extern u_int ap1394_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int bt_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int lane_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 
 /* stuff that has not yet been rototiled */
 extern const u_char * ns_nprint (register const u_char *, register const u_char *);
@@ -533,12 +537,11 @@ 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 *);
 #if 0
 extern void ip6_opt_print(netdissect_options *,const u_char *, int);
 extern int hbhopt_print(netdissect_options *,const u_char *);
 extern int dstopt_print(netdissect_options *,const u_char *);
-extern int frag6_print(netdissect_options *,const u_char *,
-                      const u_char *);
 extern void icmp6_print(netdissect_options *,const u_char *,
                        const u_char *);
 extern void ripng_print(netdissect_options *,const u_char *, int);
index 3d1cb2e43349e84598cbf6155e7f129b5cf62cae..6a9e891a573bfeafdc74c43f5667200772f8741f 100644 (file)
@@ -25,9 +25,7 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 #include "ethertype.h"
@@ -50,27 +48,27 @@ struct firewire_header {
 #define FIREWIRE_HDRLEN                18
 
 static inline void
-ap1394_hdr_print(register const u_char *bp, u_int length)
+ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
 {
        register const struct firewire_header *fp;
        u_int16_t firewire_type;
 
        fp = (const struct firewire_header *)bp;
 
-       (void)printf("%s > %s",
+       ND_PRINT((ndo, "%s > %s",
                     linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
-                    linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
+                    linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)));
 
        firewire_type = EXTRACT_16BITS(&fp->firewire_type);
-       if (!qflag) {
-               (void)printf(", ethertype %s (0x%04x)",
+       if (!ndo->ndo_qflag) {
+               ND_PRINT((ndo, ", ethertype %s (0x%04x)",
                               tok2str(ethertype_values,"Unknown", firewire_type),
-                               firewire_type);
+                               firewire_type));
         } else {
-                (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type));
+                ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type)));
         }
 
-       (void)printf(", length %u: ", length);
+       ND_PRINT((ndo, ", length %u: ", length));
 }
 
 /*
@@ -80,7 +78,7 @@ ap1394_hdr_print(register const u_char *bp, u_int length)
  * is the number of bytes actually captured.
  */
 u_int
-ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
@@ -88,12 +86,12 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
        u_short ether_type;
 
        if (caplen < FIREWIRE_HDRLEN) {
-               printf("[|ap1394]");
+               ND_PRINT((ndo, "[|ap1394]"));
                return FIREWIRE_HDRLEN;
        }
 
-       if (eflag)
-               ap1394_hdr_print(p, length);
+       if (ndo->ndo_eflag)
+               ap1394_hdr_print(ndo, p, length);
 
        length -= FIREWIRE_HDRLEN;
        caplen -= FIREWIRE_HDRLEN;
@@ -101,13 +99,13 @@ ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
        p += FIREWIRE_HDRLEN;
 
        ether_type = EXTRACT_16BITS(&fp->firewire_type);
-       if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+       if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
                /* ether_type not known, print raw packet */
-               if (!eflag)
-                       ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
+               if (!ndo->ndo_eflag)
+                       ap1394_hdr_print(ndo, (u_char *)fp, length + FIREWIRE_HDRLEN);
 
-               if (!suppress_default_print)
-                       default_print(p, caplen);
+               if (!ndo->ndo_suppress_default_print)
+                       ndo->ndo_default_print(ndo, p, caplen);
        }
 
        return FIREWIRE_HDRLEN;
index 1e075d745b38e031d7626dec5728f49afa840be2..dbd251ffc11d2d41f1359fe6ef08e740adbe8772 100644 (file)
@@ -329,7 +329,7 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
                break;
 
        case ATM_LANE:
-               lane_print(p, length, caplen);
+               lane_print(gndo, p, length, caplen);
                break;
        }
 }
index 03a18dc484ce168568f15e8129b9b3224076e6ab..95741e605ad53479efe4237cd121441cbcc8a43d 100644 (file)
@@ -23,9 +23,6 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"
 
  * is the number of bytes actually captured.
  */
 u_int
-bt_if_print(const struct pcap_pkthdr *h, const u_char *p)
+bt_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
        const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p;
 
        if (caplen < BT_HDRLEN) {
-               printf("[|bt]");
+               ND_PRINT((ndo, "[|bt]"));
                return (BT_HDRLEN);
        }
        caplen -= BT_HDRLEN;
        length -= BT_HDRLEN;
        p += BT_HDRLEN;
-       if (eflag)
-               (void)printf("hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out");
+       if (ndo->ndo_eflag)
+               ND_PRINT((ndo, "hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out"));
 
-       if (!suppress_default_print)
-               default_print(p, caplen);
+       if (!ndo->ndo_suppress_default_print)
+               ndo->ndo_default_print(ndo, p, caplen);
 
        return (BT_HDRLEN);
 }
index d67c6f5451363f1cea6da8a28cc8fcd014afec9c..3d58fe0d7b3a8f227cbf8fdcc0780794f4c7be88 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
-#include "extract.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 
 /*
@@ -46,12 +42,12 @@ calm_fast_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_
        length -= 2;
        bp += 2;
 
-       printf("CALM FAST src:%s; ", etheraddr_string(eth+6));
-       printf("SrcNwref:%d; ", srcNwref);
-       printf("DstNwref:%d; ", dstNwref);
+       ND_PRINT((ndo, "CALM FAST src:%s; ", etheraddr_string(eth+6)));
+       ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
+       ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
 
        if (ndo->ndo_vflag)
-               default_print(bp, length);
+               ndo->ndo_default_print(ndo, bp, length);
 }
 
 
index 0cc99d50e775633d608f2656badae0c8f990cc76..b8c49fd986946b5866011f6d1856e546909d6db7 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "ip6.h"
-
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 
 int
-frag6_print(register const u_char *bp, register const u_char *bp2)
+frag6_print(netdissect_options *ndo, register const u_char *bp, register const u_char *bp2)
 {
        register const struct ip6_frag *dp;
        register const struct ip6_hdr *ip6;
@@ -43,34 +40,31 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
        dp = (const struct ip6_frag *)bp;
        ip6 = (const struct ip6_hdr *)bp2;
 
-       TCHECK(dp->ip6f_offlg);
+       ND_TCHECK(dp->ip6f_offlg);
 
-       if (vflag) {
-               printf("frag (0x%08x:%d|%ld)",
+       if (ndo->ndo_vflag) {
+               ND_PRINT((ndo, "frag (0x%08x:%d|%ld)",
                       EXTRACT_32BITS(&dp->ip6f_ident),
                       EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
                       sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
-                              (long)(bp - bp2) - sizeof(struct ip6_frag));
+                              (long)(bp - bp2) - sizeof(struct ip6_frag)));
        } else {
-               printf("frag (%d|%ld)",
+               ND_PRINT((ndo, "frag (%d|%ld)",
                       EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
                       sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
-                              (long)(bp - bp2) - sizeof(struct ip6_frag));
+                              (long)(bp - bp2) - sizeof(struct ip6_frag)));
        }
 
-#if 1
        /* it is meaningless to decode non-first fragment */
        if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
                return -1;
        else
-#endif
        {
-               fputs(" ", stdout);
+               ND_PRINT((ndo, " "));
                return sizeof(struct ip6_frag);
        }
 trunc:
-       fputs("[|frag]", stdout);
+       ND_PRINT((ndo, "[|frag]"));
        return -1;
-#undef TCHECK
 }
 #endif /* INET6 */
index a2d35ffec3fbf0712d9716bea46603074f92f451..62525346c5c76db705844a8bdea16cba3aa304c2 100644 (file)
@@ -163,7 +163,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
                        nh = *cp;
                        break;
                case IPPROTO_FRAGMENT:
-                       advance = frag6_print(cp, (const u_char *)ip6);
+                       advance = frag6_print(ndo, cp, (const u_char *)ip6);
                        if (ndo->ndo_snapend <= cp + advance)
                                return;
                        nh = *cp;
index 49dc3ab1b66d78849645c97b641899b07e28e11a..dd8aff0be2c8b28ecc918f6294087224e5c2a81c 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "ether.h"
 
-#ifndef ETHER_ADDR_LEN
-#define ETHER_ADDR_LEN 6
-#endif
-
 struct lecdatahdr_8023 {
   u_int16_t le_header;
   u_int8_t h_dest[ETHER_ADDR_LEN];
@@ -85,12 +79,12 @@ lane_hdr_print(netdissect_options *ndo, const u_char *bp)
  * This assumes 802.3, not 802.5, LAN emulation.
  */
 void
-lane_print(const u_char *p, u_int length, u_int caplen)
+lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
        struct lane_controlhdr *lec;
 
        if (caplen < sizeof(struct lane_controlhdr)) {
-               printf("[|lane]");
+               ND_PRINT((ndo, "[|lane]"));
                return;
        }
 
@@ -99,9 +93,9 @@ lane_print(const u_char *p, u_int length, u_int caplen)
                /*
                 * LE Control.
                 */
-               printf("lec: proto %x vers %x %s",
+               ND_PRINT((ndo, "lec: proto %x vers %x %s",
                    lec->lec_proto, lec->lec_vers,
-                   tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode)));
+                   tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))));
                return;
        }
 
@@ -116,13 +110,13 @@ lane_print(const u_char *p, u_int length, u_int caplen)
         * Now print the encapsulated frame, under the assumption
         * that it's an Ethernet frame.
         */
-       ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
+       ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
 }
 
 u_int
-lane_if_print(const struct pcap_pkthdr *h, const u_char *p)
+lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
-       lane_print(p, h->len, h->caplen);
+       lane_print(ndo, p, h->len, h->caplen);
 
        return (sizeof(struct lecdatahdr_8023));
 }
index aeb43cc4f55050bcd41193326bc76fe10148d09e..17ecbedf0c49a739bc0da7c40a4325c4a92b0494 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -172,9 +172,6 @@ static const struct printer printers[] = {
        { arcnet_linux_if_print, DLT_ARCNET_LINUX },
 #endif
        { token_if_print,       DLT_IEEE802 },
-#ifdef DLT_LANE8023
-       { lane_if_print,        DLT_LANE8023 },
-#endif
        { sl_if_print,          DLT_SLIP },
 #ifdef DLT_SLIP_BSDOS
        { sl_bsdos_if_print,    DLT_SLIP_BSDOS },
@@ -234,9 +231,6 @@ static const struct printer printers[] = {
 #ifdef DLT_SYMANTEC_FIREWALL
        { symantec_if_print,    DLT_SYMANTEC_FIREWALL },
 #endif
-#ifdef DLT_APPLE_IP_OVER_IEEE1394
-       { ap1394_if_print,      DLT_APPLE_IP_OVER_IEEE1394 },
-#endif
 #ifdef DLT_IEEE802_11_RADIO_AVS
        { ieee802_11_radio_avs_if_print,        DLT_IEEE802_11_RADIO_AVS },
 #endif
@@ -288,9 +282,6 @@ static const struct printer printers[] = {
 #ifdef DLT_MFR
        { mfr_if_print,         DLT_MFR },
 #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 HAVE_PCAP_USB_H
 #ifdef DLT_USB_LINUX
        { usb_linux_48_byte_print, DLT_USB_LINUX},
@@ -343,6 +334,15 @@ static const struct ndo_printer ndo_printers[] = {
        { 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
        { NULL,                 0 },
 };