]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Some compilers may pad structures to a length that's a multiple of 2 or
authorguy <guy>
Mon, 9 Oct 2000 03:24:24 +0000 (03:24 +0000)
committerguy <guy>
Mon, 9 Oct 2000 03:24:24 +0000 (03:24 +0000)
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.

ether.h
print-arp.c

diff --git a/ether.h b/ether.h
index 105e05e369638d1322ad1c4ae1dd1129a0239c19..96ddec79c135d4b08872b6064f5089420f64bd3a 100644 (file)
--- a/ether.h
+++ b/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.
  */
 #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.
  */
index 26cb7cde7e92fd80bdf66c6a8195af4182abe667..306801efb2525a20325e4dbe318d39f439d29c96 100644 (file)
@@ -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;