mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 18:14:29 +08:00
Some compilers may pad structures to a length that's a multiple of 2 or
4 bytes, even though no member in the structure requires such an alignment; don't use "sizeof (struct ether_arp), explicitly #define the header length and use that #defined value. We don't use "struct ether_addr" in any dissectors, so there's no need to define it in "ether.h" - and, if compilers pad it to a multiple of 4 bytes, you can't use it anyway, as it'll be 8 bytes long, not 6 bytes long.
This commit is contained in:
parent
d16cf6488c
commit
596742a577
9
ether.h
9
ether.h
@ -1,4 +1,4 @@
|
||||
/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.5 2000-10-09 02:59:39 guy Exp $ (LBL) */
|
||||
/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.6 2000-10-09 03:24:24 guy Exp $ (LBL) */
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -41,13 +41,6 @@
|
||||
*/
|
||||
#define ETHER_ADDR_LEN 6
|
||||
|
||||
/*
|
||||
* Ethernet address - 6 octets
|
||||
*/
|
||||
struct ether_addr {
|
||||
u_int8_t ether_addr_octet[ETHER_ADDR_LEN];
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.47 2000-09-24 07:42:31 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.48 2000-10-09 03:24:25 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -78,6 +78,8 @@ struct arphdr {
|
||||
#endif
|
||||
};
|
||||
|
||||
#define ARP_HDRLEN 8
|
||||
|
||||
/*
|
||||
* Ethernet Address Resolution Protocol.
|
||||
*
|
||||
@ -98,6 +100,8 @@ struct ether_arp {
|
||||
#define arp_pln ea_hdr.ar_pln
|
||||
#define arp_op ea_hdr.ar_op
|
||||
|
||||
#define ETHER_ARP_HDRLEN (ARP_HDRLEN + 6 + 4 + 6 + 4)
|
||||
|
||||
#define SHA(ap) ((ap)->arp_sha)
|
||||
#define THA(ap) ((ap)->arp_tha)
|
||||
#define SPA(ap) ((ap)->arp_spa)
|
||||
@ -125,7 +129,7 @@ arp_print(register const u_char *bp, u_int length, u_int caplen)
|
||||
printf("[|arp]");
|
||||
return;
|
||||
}
|
||||
if (length < sizeof(struct ether_arp)) {
|
||||
if (length < ETHER_ARP_HDRLEN) {
|
||||
(void)printf("truncated-arp");
|
||||
default_print((u_char *)ap, length);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user