]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ether.c
From Peter Fales <[email protected]>: add support for
[tcpdump] / print-ether.c
index 8ac9487b8f6448c2538a044a47f9c6629c36a509..2826c7bbd252f0377fd892b4123017f5192a5965 100644 (file)
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.70 2002-06-11 17:08:45 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.76 2002-12-19 09:39:12 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
+#include <tcpdump-stdinc.h>
 
 #include <stdio.h>
 #include <pcap.h>
@@ -42,7 +38,6 @@ static const char rcsid[] =
 
 #include "ether.h"
 
-const u_char *packetp;
 const u_char *snapend;
 
 static inline void
@@ -79,14 +74,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;
@@ -123,34 +110,17 @@ ether_print(const u_char *p, u_int length, u_int caplen)
 }
 
 /*
- * This is the top level routine of the printer.  'p' is the points
- * to the ether header of the packet, 'h->tv' is the timestamp,
+ * This is the top level routine of the printer.  'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
  * '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, 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, h->len, h->caplen);
 
-       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');
-
-       --infodelay;
-       if (infoprint)
-               info(0);
+       return (ETHER_HDRLEN);
 }
 
 /*
@@ -249,6 +219,10 @@ ether_encap_print(u_short ethertype, const u_char *p,
                }
                return (1);
 
+        case ETHERTYPE_LOOPBACK:
+                printf("loopback");
+                return (1);
+
        case ETHERTYPE_MPLS:
        case ETHERTYPE_MPLS_MULTI:
                mpls_print(p, length);