]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-token.c
Pointers into packet data should usually be pointers to unsigned 1-byte
[tcpdump] / print-token.c
index 74dc536bdcc0e24724a71590115f574c81cb5a4f..d17e9506863544d53a840db6f379597b68a0223b 100644 (file)
@@ -24,8 +24,8 @@
  *     Guy Harris <[email protected]>
  */
 #ifndef lint
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.21 2002-12-18 09:41:18 guy Exp $";
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.26 2005-07-07 01:22:21 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -118,13 +118,6 @@ token_print(const u_char *p, u_int length, u_int caplen)
         */
        extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));
 
-       /*
-        * 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 global.
-        */
-       snapend = p + caplen;
-
        /* Adjust for source routing information in the MAC header */
        if (IS_SOURCE_ROUTED(trp)) {
                /* Clear source-routed bit */
@@ -174,7 +167,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
                                printf("(LLC %s) ",
                        etherproto_string(htons(extracted_ethertype)));
                        }
-                       if (!xflag && !qflag)
+                       if (!suppress_default_print)
                                default_print(p, caplen);
                }
        } else {
@@ -183,7 +176,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
                if (!eflag)
                        token_hdr_print(trp, length + TOKEN_HDRLEN + route_len,
                            ESRC(&ehdr), EDST(&ehdr));
-               if (!xflag && !qflag)
+               if (!suppress_default_print)
                        default_print(p, caplen);
        }
        return (hdr_len);
@@ -192,30 +185,11 @@ token_print(const u_char *p, u_int length, u_int caplen)
 /*
  * This is the top level routine of the printer.  'p' points
  * to the TR header of the packet, 'h->ts' is the timestamp,
- * 'h->length' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
  */
-void
-token_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
+u_int
+token_if_print(const struct pcap_pkthdr *h, const u_char *p)
 {
-       u_int caplen = h->caplen;
-       u_int length = h->len;
-       u_int hdr_len;
-
-       ++infodelay;
-       ts_print(&h->ts);
-
-       hdr_len = token_print(p, length, caplen);
-
-       /*
-        * If "-x" was specified, print packet data in hex.
-        */
-       if (xflag)
-               default_print_packet(p, caplen, hdr_len);
-
-       putchar('\n');
-
-       --infodelay;
-       if (infoprint)
-               info(0);
+       return (token_print(p, h->len, h->caplen));
 }