*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.67 2002-04-07 09:50:31 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
#include "config.h"
#endif
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-
-struct mbuf;
-struct rtentry;
-
-#include <netinet/in.h>
+#include <tcpdump-stdinc.h>
#include <stdio.h>
#include <pcap.h>
#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
if (caplen < ETHER_HDRLEN) {
printf("[|ether]");
- goto out;
+ return;
}
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;
if (!xflag && !qflag)
default_print(p, caplen);
}
- if (xflag)
- default_print(p, caplen);
- out:
- putchar('\n');
}
/*
- * 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, length, caplen);
+ ether_print(p, h->len, h->caplen);
- --infodelay;
- if (infoprint)
- info(0);
+ return (ETHER_HDRLEN);
}
/*
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
pppoe_print(p, length);
- return (1);
-
+ return (1);
+
case ETHERTYPE_PPP:
printf("ppp");
if (length) {
}
return (1);
+ case ETHERTYPE_LOOPBACK:
+ printf("loopback");
+ return (1);
+
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
mpls_print(p, length);