]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ether.c
remove some EXTRACT_ lookalikes plus misc. display cleanup
[tcpdump] / print-ether.c
index 5909f4c61223c8760d19f4d8c70d875cd626437d..9b1d85f0289b7fa8a63cc73445ceb16fe306f244 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.73 2002-09-05 21:25:40 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.80 2003-05-22 14:31:36 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -38,26 +38,27 @@ static const char rcsid[] =
 
 #include "ether.h"
 
-const u_char *packetp;
 const u_char *snapend;
 
 static inline void
 ether_hdr_print(register const u_char *bp, u_int length)
 {
        register const struct ether_header *ep;
-
        ep = (const struct ether_header *)bp;
-       if (qflag)
-               (void)printf("%s %s %d: ",
-                            etheraddr_string(ESRC(ep)),
-                            etheraddr_string(EDST(ep)),
-                            length);
-       else
-               (void)printf("%s %s %s %d: ",
-                            etheraddr_string(ESRC(ep)),
-                            etheraddr_string(EDST(ep)),
-                            etherproto_string(ep->ether_type),
-                            length);
+
+       (void)printf("%s > %s",
+                    etheraddr_string(ESRC(ep)),
+                    etheraddr_string(EDST(ep)));
+
+       if (!qflag) {
+               if (ntohs(ep->ether_type) <= ETHERMTU)
+                         (void)printf(", 802.2");
+                else 
+                         (void)printf(", ethertype %s",
+                                      etherproto_string(ep->ether_type));            
+        }
+
+       (void)printf(", length %u: ", length);
 }
 
 void
@@ -75,14 +76,6 @@ ether_print(const u_char *p, u_int length, u_int caplen)
        if (eflag)
                ether_hdr_print(p, length);
 
-       /*
-        * Some printers want to get back at the ethernet addresses,
-        * and/or check that they're not walking off the end of the packet.
-        * Rather than pass them all the way down, we set these globals.
-        */
-       packetp = p;
-       snapend = p + caplen;
-
        length -= ETHER_HDRLEN;
        caplen -= ETHER_HDRLEN;
        ep = (struct ether_header *)p;
@@ -124,29 +117,12 @@ ether_print(const u_char *p, u_int length, u_int caplen)
  * 'h->length' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
  */
-void
-ether_if_print(u_char *user _U_, const struct pcap_pkthdr *h, const u_char *p)
+u_int
+ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
 {
-       u_int caplen = h->caplen;
-       u_int length = h->len;
-
-       ++infodelay;
-       ts_print(&h->ts);
-
-       ether_print(p, length, caplen);
-
-       /*
-        * If "-x" was specified, print stuff past the Ethernet header,
-        * if there's anything to print.
-        */
-       if (xflag && caplen > ETHER_HDRLEN)
-               default_print(p + ETHER_HDRLEN, caplen - ETHER_HDRLEN);
-
-       putchar('\n');
+       ether_print(p, h->len, h->caplen);
 
-       --infodelay;
-       if (infoprint)
-               info(0);
+       return (ETHER_HDRLEN);
 }
 
 /*