X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/6e07bc747cfa438a48a738881479a07a3bd0d3b9..d75ee07998ef8ac0fc1a9a6beea2e15a3ca1f726:/print-sll.c diff --git a/print-sll.c b/print-sll.c index d8661a9e..eaf77978 100644 --- a/print-sll.c +++ b/print-sll.c @@ -20,21 +20,14 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.5 2001-06-08 04:48:23 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.12 2002-12-19 09:39:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include -#include -#include - -struct mbuf; -struct rtentry; - -#include +#include #include #include @@ -94,24 +87,20 @@ sll_print(register const struct sll_header *sllp, u_int 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, + * This is the top level routine of the printer. 'p' points to the + * Linux "cooked capture" 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 -sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) +u_int +sll_if_print(const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; register const struct sll_header *sllp; - u_short pkttype; - struct ether_header ehdr; u_short ether_type; u_short extracted_ethertype; - ts_print(&h->ts); - if (caplen < SLL_HDR_LEN) { /* * XXX - this "can't happen" because "pcap-linux.c" always @@ -119,67 +108,17 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) * cooked socket capture. */ printf("[|sll]"); - goto out; + return (caplen); } sllp = (const struct sll_header *)p; - /* - * Fake up an Ethernet header for the benefit of printers that - * insist on "packetp" pointing to an Ethernet header. - */ - pkttype = ntohs(sllp->sll_pkttype); - - /* The source address is in the packet header */ - memcpy(ehdr.ether_shost, sllp->sll_addr, ETHER_ADDR_LEN); - - if (pkttype != LINUX_SLL_OUTGOING) { - /* - * We received this packet. - * - * We don't know the destination address, so - * we fake it - all 0's except that the - * bottommost bit of the bottommost octet - * is set for a unicast packet, all 0's except - * that the bottommost bit of the uppermost - * octet is set for a multicast packet, all - * 1's for a broadcast packet. - */ - if (pkttype == LINUX_SLL_BROADCAST) - memset(ehdr.ether_dhost, 0xFF, ETHER_ADDR_LEN); - else { - memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN); - if (pkttype == LINUX_SLL_MULTICAST) - ehdr.ether_dhost[0] = 1; - else - ehdr.ether_dhost[ETHER_ADDR_LEN-1] = 1; - } - } else { - /* - * We sent this packet; we don't know whether it's - * broadcast, multicast, or unicast, so just make - * the destination address all 0's. - */ - memset(ehdr.ether_dhost, 0, ETHER_ADDR_LEN); - } - if (eflag) sll_print(sllp, 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. + * Go past the cooked-mode header. */ - snapend = p + caplen; - /* - * Actually, the only printers that use packetp are print-arp.c - * and print-bootp.c, and they assume that packetp points to an - * Ethernet header. The right thing to do is to fix them to know - * which link type is in use when they excavate. XXX - */ - packetp = (u_char *)&ehdr; - length -= SLL_HDR_LEN; caplen -= SLL_HDR_LEN; p += SLL_HDR_LEN; @@ -209,8 +148,8 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) * 802.2. * Try to print the LLC-layer header & higher layers. */ - if (llc_print(p, length, caplen, ESRC(&ehdr), - EDST(&ehdr), &extracted_ethertype) == 0) + if (llc_print(p, length, caplen, NULL, NULL, + &extracted_ethertype) == 0) goto unknown; /* unknown LLC type */ break; @@ -235,8 +174,6 @@ sll_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p) if (!xflag && !qflag) default_print(p, caplen); } - if (xflag) - default_print(p, caplen); - out: - putchar('\n'); + + return (SLL_HDR_LEN); }