]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-token.c
Default to first interface from pcap_findalldevs()
[tcpdump] / print-token.c
index 33647a14c069cc4c149c4f45bdb714ea285cfaec..6f9950db6aabdb8f119e8f06fe58a814d8c25818 100644 (file)
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
 #include <string.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 #include "ether.h"
@@ -112,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[] = {
@@ -148,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;
@@ -210,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 */