]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-fddi.c
Skip the LLC and SNAP headers with -x.
[tcpdump] / print-fddi.c
index 0d740089c7c8db7586829150963e3016a41346cf..7576b6f0d4f679ea46d7573311405e6ba0990717 100644 (file)
@@ -255,8 +255,8 @@ fddi_hdr_print(netdissect_options *ndo,
 {
        const char *srcname, *dstname;
 
-       srcname = etheraddr_string(fsrc);
-       dstname = etheraddr_string(fdst);
+       srcname = etheraddr_string(ndo, fsrc);
+       dstname = etheraddr_string(ndo, fdst);
 
        if (ndo->ndo_vflag)
                ND_PRINT((ndo, "%02x %s %s %d: ",
@@ -277,16 +277,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);
        }
 
        /*
@@ -305,32 +305,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(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)
-                               ndo->ndo_default_print(ndo, p, caplen);
+                               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)
-                       ndo->ndo_default_print(ndo, p, caplen);
+                       ND_DEFAULTPRINT(p, caplen);
+               llc_hdrlen = 0;
        }
+       return (FDDI_HDRLEN + llc_hdrlen);
 }
 
 /*
@@ -342,7 +339,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));
 }