X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9298dc84c8b02a79fbd2f4680d370da0cc316ea5..e8b3b33cbe4cd2ba724d4f209b1ed5fb7f884aff:/print-ether.c diff --git a/print-ether.c b/print-ether.c index 24d19929..2826c7bb 100644 --- a/print-ether.c +++ b/print-ether.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -20,21 +20,14 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.63 2001-03-12 00:24:54 guy 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 -#include -#include - -struct mbuf; -struct rtentry; - -#include +#include #include #include @@ -45,11 +38,10 @@ struct rtentry; #include "ether.h" -const u_char *packetp; const u_char *snapend; static inline void -ether_print(register const u_char *bp, u_int length) +ether_hdr_print(register const u_char *bp, u_int length) { register const struct ether_header *ep; @@ -67,38 +59,20 @@ ether_print(register const u_char *bp, u_int length) length); } -/* - * 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, - * '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) +ether_print(const u_char *p, u_int length, u_int caplen) { - u_int caplen = h->caplen; - u_int length = h->len; struct ether_header *ep; u_short ether_type; u_short extracted_ethertype; - ts_print(&h->ts); - if (caplen < ETHER_HDRLEN) { printf("[|ether]"); - goto out; + return; } if (eflag) - ether_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; + ether_hdr_print(p, length); length -= ETHER_HDRLEN; caplen -= ETHER_HDRLEN; @@ -117,7 +91,7 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) - ether_print((u_char *)ep, length + ETHER_HDRLEN); + ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN); if (extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); @@ -129,14 +103,24 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) &extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) - ether_print((u_char *)ep, length + ETHER_HDRLEN); + ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN); 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' 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. + */ +u_int +ether_if_print(const struct pcap_pkthdr *h, const u_char *p) +{ + ether_print(p, h->len, h->caplen); + + return (ETHER_HDRLEN); } /* @@ -190,6 +174,7 @@ ether_encap_print(u_short ethertype, const u_char *p, return (1); case ETHERTYPE_IPX: + printf("(NOV-ETHII) "); ipx_print(p, length); return (1); @@ -211,7 +196,7 @@ ether_encap_print(u_short ethertype, const u_char *p, extracted_ethertype) == 0) { /* ether_type not known, print raw packet */ if (!eflag) - ether_print(p - 18, length + 4); + ether_hdr_print(p - 18, length + 4); if (*extracted_ethertype) { printf("(LLC %s) ", etherproto_string(htons(*extracted_ethertype))); @@ -224,8 +209,8 @@ ether_encap_print(u_short ethertype, const u_char *p, case ETHERTYPE_PPPOED: case ETHERTYPE_PPPOES: pppoe_print(p, length); - return (1); - + return (1); + case ETHERTYPE_PPP: printf("ppp"); if (length) { @@ -234,6 +219,15 @@ 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); + return (1); + case ETHERTYPE_LAT: case ETHERTYPE_SCA: case ETHERTYPE_MOPRC: