Deleted Added
full compact
21c21
< * $FreeBSD: head/contrib/tcpdump/print-ether.c 56896 2000-01-30 01:05:24Z fenner $
---
> * $FreeBSD: head/contrib/tcpdump/print-ether.c 75118 2001-04-03 07:50:46Z fenner $
25c25
< "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.48 1999/11/21 09:36:51 fenner Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.61 2000/12/22 22:45:10 guy Exp $ (LBL)";
36d35
< #if __STDC__
39,40d37
< #endif
< #include <net/if.h>
43,49d39
< #include <net/ethernet.h>
< #include <netinet/in_systm.h>
< #include <netinet/ip.h>
< #include <netinet/ip_var.h>
< #include <netinet/udp.h>
< #include <netinet/udp_var.h>
< #include <netinet/tcp.h>
54,57d43
< #ifdef INET6
< #include <netinet/ip6.h>
< #endif
<
61a48,49
> #include "ether.h"
>
84,85d71
< static u_short extracted_ethertype;
<
98a85
> u_short extracted_ethertype;
102c89
< if (caplen < sizeof(struct ether_header)) {
---
> if (caplen < ETHER_HDRLEN) {
118,119c105,106
< length -= sizeof(struct ether_header);
< caplen -= sizeof(struct ether_header);
---
> length -= ETHER_HDRLEN;
> caplen -= ETHER_HDRLEN;
121c108
< p += sizeof(struct ether_header);
---
> p += ETHER_HDRLEN;
131c118,119
< if (llc_print(p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
---
> if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
> &extracted_ethertype) == 0) {
134c122
< ether_print((u_char *)ep, length);
---
> ether_print((u_char *)ep, length + ETHER_HDRLEN);
142c130,131
< } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
---
> } else if (ether_encap_print(ether_type, p, length, caplen,
> &extracted_ethertype) == 0) {
145c134
< ether_print((u_char *)ep, length + sizeof(*ep));
---
> ether_print((u_char *)ep, length + ETHER_HDRLEN);
161,162c150,153
< * Stuffs the ether type into a global for the benefit of lower layers
< * that might want to know what it is.
---
> * The Ethernet type code is passed through a pointer; if it was
> * ETHERTYPE_8021Q, it gets updated to be the Ethernet type of
> * the 802.1Q payload, for the benefit of lower layers that might
> * want to know what it is.
167c158
< u_int length, u_int caplen)
---
> u_int length, u_int caplen, u_short *extracted_ethertype)
170c161
< extracted_ethertype = ethertype;
---
> *extracted_ethertype = ethertype;
208,212c199,203
< printf("802.1Q vlan#%d P%d%s",
< ntohs(*(unsigned short*)p)&0xFFF,
< ntohs(*(unsigned short*)p)>>13,
< (ntohs(*(unsigned short*)p)&0x1000) ? " CFI" : "");
< ethertype = ntohs(*(unsigned short*)(p+2));
---
> printf("802.1Q vlan#%d P%d%s ",
> ntohs(*(u_int16_t *)p) & 0xfff,
> ntohs(*(u_int16_t *)p) >> 13,
> (ntohs(*(u_int16_t *)p) & 0x1000) ? " CFI" : "");
> ethertype = ntohs(*(u_int16_t *)(p + 2));
216c207
< if (ethertype > ETHERMTU)
---
> if (ethertype > ETHERMTU)
219c210
< extracted_ethertype = 0;
---
> *extracted_ethertype = 0;
221c212,213
< if (llc_print(p, length, caplen, p-18, p-12) == 0) {
---
> if (llc_print(p, length, caplen, p - 18, p - 12,
> extracted_ethertype) == 0) {
224,225c216,217
< ether_print(p-18, length+4);
< if (extracted_ethertype) {
---
> ether_print(p - 18, length + 4);
> if (*extracted_ethertype) {
227c219
< etherproto_string(htons(extracted_ethertype)));
---
> etherproto_string(htons(*extracted_ethertype)));
230c222
< default_print(p-18, caplen+4);
---
> default_print(p - 18, caplen + 4);