]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use nd_ types in 802.x and FDDI headers.
authorGuy Harris <[email protected]>
Tue, 12 Dec 2017 18:36:21 +0000 (10:36 -0800)
committerGuy Harris <[email protected]>
Tue, 12 Dec 2017 18:36:21 +0000 (10:36 -0800)
Use EXTRACT_U_1() as required by those changes.  Remove
no-longer-necessary & operators from other EXTRACT_ calls.

While we're at it, add MAC_ADDR_LEN to netdissect.h, and use it instead
of ETHER_ADDR_LEN; eliminate ETHER_ADDR_LEN.

Move the maximum Ethernet length field value to ethertype.h, under the
name MAX_ETHERNET_LENGTH_VAL.

Move the Ethernet header structure, and the #define for the Ethernet
header length, to print-ether.c; in non-Ethernet dissectors that were
using the Ethernet header structure, just declare two nd_mac_addr
variables for the source and destination MAC addresses and use them
instead of the Ethernet header (we don't need the type field there).

These changes leave nothing in ether.h, so eliminate it.

24 files changed:
Makefile.in
addrtoname.c
ether.h [deleted file]
ethertype.h
netdissect.h
print-aoe.c
print-arp.c
print-cfm.c
print-ether.c
print-fddi.c
print-ipfc.c
print-isoclns.c
print-lane.c
print-llc.c
print-loopback.c
print-medsa.c
print-openflow-1.0.c
print-rrcp.c
print-sll.c
print-slow.c
print-symantec.c
print-tipc.c
print-token.c
print-vqp.c

index e13b1d6eb3c980a37eeb8ae8d07c8d280632827b..47ff53a1f824dcfc1a348c420ce7f0e0fac931d2 100644 (file)
@@ -259,7 +259,6 @@ HDR = \
        atm.h \
        chdlc.h \
        cpack.h \
-       ether.h \
        ethertype.h \
        extract.h \
        funcattrs.h \
index c481b807adde8a1cccf45b03cc3abdd1725b0f28..003ce51211eb5d087925b0b56c60769fb95b7e45 100644 (file)
@@ -73,10 +73,6 @@ extern int ether_ntohost(char *, const struct ether_addr *);
 #include "extract.h"
 #include "oui.h"
 
-#ifndef ETHER_ADDR_LEN
-#define ETHER_ADDR_LEN 6
-#endif
-
 /*
  * hash tables for whatever-to-name translations
  *
@@ -600,7 +596,7 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep,
        if (len == 0)
                return ("<empty>");
 
-       if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
+       if (type == LINKADDR_ETHER && len == MAC_ADDR_LEN)
                return (etheraddr_string(ndo, ep));
 
        if (type == LINKADDR_FRELAY)
diff --git a/ether.h b/ether.h
deleted file mode 100644 (file)
index 6491678..0000000
--- a/ether.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)if_ether.h  8.3 (Berkeley) 5/2/95
- */
-
-#define        ETHERMTU        1500
-
-/*
- * The number of bytes in an ethernet (MAC) address.
- */
-#define        ETHER_ADDR_LEN          6
-
-/*
- * Structure of an Ethernet header.
- */
-struct ether_header {
-       uint8_t         ether_dhost[ETHER_ADDR_LEN];
-       uint8_t         ether_shost[ETHER_ADDR_LEN];
-       uint16_t        ether_length_type;
-};
-
-/*
- * Length of an Ethernet header; note that some compilers may pad
- * "struct ether_header" to a multiple of 4 bytes, for example, so
- * "sizeof (struct ether_header)" may not give the right answer.
- */
-#define ETHER_HDRLEN           14
index f38ec8e4f7881f377353fb7740bf1fb69a7a0b42..7719a6f043aae966a6cee44664b9b9745682435f 100644 (file)
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
+/*
+ * Maximum length of the length field in an Ethernet header; any value
+ * greater than this is not a length value, so it's either an Ethernet
+ * type or an invalid value.
+ */
+#define        MAX_ETHERNET_LENGTH_VAL 1500
+
 /*
  * Ethernet types.
  *
index e306684322618465473a6ce0811613e05cdf149f..11907ea98e9d485cd64e5ca89c7d5b30c590b803 100644 (file)
@@ -90,9 +90,8 @@ typedef struct {
 /*
  * Use this for MAC addresses.
  */
-typedef struct {
-       unsigned char bytes[6];
-} nd_mac_addr;
+#define MAC_ADDR_LEN   6               /* length of MAC addresses */
+typedef unsigned char nd_mac_addr[MAC_ADDR_LEN];
 
 /*
  * Use this for blobs of bytes; make them arrays of nd_byte.
index 01f485dd90cde433151f8228810ed3d36e9bfb1f..d821ec68a8124d44145647f826a3116ee3c92bb8 100644 (file)
@@ -38,7 +38,6 @@
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ether.h"
 
 static const char tstr[] = " [|aoe]";
 
@@ -289,9 +288,9 @@ aoev1_mac_print(netdissect_options *ndo,
                ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", EXTRACT_U_1(cp))));
                cp += 1;
                /* Ethernet Address */
-               ND_TCHECK_LEN(cp, ETHER_ADDR_LEN);
+               ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
                ND_PRINT((ndo, ", Ethernet Address: %s", etheraddr_string(ndo, cp)));
-               cp += ETHER_ADDR_LEN;
+               cp += MAC_ADDR_LEN;
        }
        return;
 
@@ -310,7 +309,7 @@ aoev1_reserve_print(netdissect_options *ndo,
        const u_char *ep = cp + len;
        uint8_t nmacs, i;
 
-       if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
+       if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % MAC_ADDR_LEN)
                goto invalid;
        /* RCmd */
        ND_TCHECK_1(cp);
@@ -321,12 +320,12 @@ aoev1_reserve_print(netdissect_options *ndo,
        nmacs = EXTRACT_U_1(cp);
        cp += 1;
        ND_PRINT((ndo, ", NMacs: %u", nmacs));
-       if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
+       if (AOEV1_RESERVE_ARG_LEN + nmacs * MAC_ADDR_LEN != len)
                goto invalid;
        /* addresses */
        for (i = 0; i < nmacs; i++) {
                ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
-               cp += ETHER_ADDR_LEN;
+               cp += MAC_ADDR_LEN;
        }
        return;
 
index 37320a84b6dd57b1e5d4dbfa9a220cd9a14f6b00..174ecaf13ffaf0a38e567e60a4d23d6a323857c3 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "netdissect.h"
 #include "addrtoname.h"
-#include "ether.h"
 #include "ethertype.h"
 #include "extract.h"
 
index 94624564693ddd4d4e0799bb34b64ccb8cb488f9..0a666478a47e15d4701863b26ef9d609d03d9253 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "netdissect.h"
 #include "extract.h"
-#include "ether.h"
 #include "addrtoname.h"
 #include "oui.h"
 #include "af.h"
@@ -116,8 +115,8 @@ struct cfm_lbm_t {
 struct cfm_ltm_t {
     uint8_t transaction_id[4];
     uint8_t ttl;
-    uint8_t original_mac[ETHER_ADDR_LEN];
-    uint8_t target_mac[ETHER_ADDR_LEN];
+    nd_mac_addr original_mac;
+    nd_mac_addr target_mac;
 };
 
 static const struct tok cfm_ltm_flag_values[] = {
@@ -638,7 +637,7 @@ cfm_print(netdissect_options *ndo,
                 /* IEEE 802.1Q-2014 Section 21.5.3.3: Chassis ID */
                 switch (chassis_id_type) {
                 case CFM_CHASSIS_ID_MAC_ADDRESS:
-                    if (chassis_id_length != ETHER_ADDR_LEN) {
+                    if (chassis_id_length != MAC_ADDR_LEN) {
                         ND_PRINT((ndo, " (invalid MAC address length)"));
                         hexdump = TRUE;
                         break;
index 8d8341bae107b77352c88b3d79f7c655401dbea6..7e7216c4cd1e7cb0213e4454bf4b1d8f658ef5b2 100644 (file)
 #include "extract.h"
 #include "addrtoname.h"
 #include "ethertype.h"
-#include "ether.h"
+
+/*
+ * Structure of an Ethernet header.
+ */
+struct ether_header {
+       nd_mac_addr     ether_dhost;
+       nd_mac_addr     ether_shost;
+       nd_uint16_t     ether_length_type;
+};
+
+/*
+ * Length of an Ethernet header; note that some compilers may pad
+ * "struct ether_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct ether_header)" may not give the right answer.
+ */
+#define ETHER_HDRLEN           14
 
 const struct tok ethertype_values[] = {
     { ETHERTYPE_IP,            "IPv4" },
@@ -102,9 +117,9 @@ ether_hdr_print(netdissect_options *ndo,
                     etheraddr_string(ndo, ESRC(ep)),
                     etheraddr_string(ndo, EDST(ep))));
 
-       length_type = EXTRACT_BE_U_2(&ep->ether_length_type);
+       length_type = EXTRACT_BE_U_2(ep->ether_length_type);
        if (!ndo->ndo_qflag) {
-               if (length_type <= ETHERMTU) {
+               if (length_type <= MAX_ETHERNET_LENGTH_VAL) {
                        ND_PRINT((ndo, ", 802.3"));
                        length = length_type;
                } else
@@ -112,7 +127,7 @@ ether_hdr_print(netdissect_options *ndo,
                                       tok2str(ethertype_values,"Unknown", length_type),
                                        length_type));
         } else {
-                if (length_type <= ETHERMTU) {
+                if (length_type <= MAX_ETHERNET_LENGTH_VAL) {
                         ND_PRINT((ndo, ", 802.3"));
                        length = length_type;
                } else
@@ -168,13 +183,13 @@ ether_print(netdissect_options *ndo,
        src.addr_string = etheraddr_string;
        dst.addr = EDST(ep);
        dst.addr_string = etheraddr_string;
-       length_type = EXTRACT_BE_U_2(&ep->ether_length_type);
+       length_type = EXTRACT_BE_U_2(ep->ether_length_type);
 
 recurse:
        /*
         * Is it (gag) an 802.3 encapsulation?
         */
-       if (length_type <= ETHERMTU) {
+       if (length_type <= MAX_ETHERNET_LENGTH_VAL) {
                /* Try to print the LLC-layer header & higher layers */
                llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
                if (llc_hdrlen < 0) {
@@ -207,7 +222,7 @@ recurse:
                }
 
                length_type = EXTRACT_BE_U_2(p + 2);
-               if (ndo->ndo_eflag && length_type > ETHERMTU)
+               if (ndo->ndo_eflag && length_type > MAX_ETHERNET_LENGTH_VAL)
                        ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", length_type)));
                p += 4;
                length -= 4;
index 27803783b7d8e70b1b09df75554d5237391391bf..01f376f823c71204a0f93b6cc8732decc3b73524 100644 (file)
 #include <string.h>
 
 #include "netdissect.h"
+#include "extract.h"
 #include "addrtoname.h"
-#include "ether.h"
 
 /*
  * Based on Ultrix if_fddi.h
  */
 
 struct fddi_header {
-       u_char  fddi_fc;                /* frame control */
-       u_char  fddi_dhost[6];
-       u_char  fddi_shost[6];
+       nd_uint8_t  fddi_fc;            /* frame control */
+       nd_mac_addr fddi_dhost;
+       nd_mac_addr fddi_shost;
 };
 
 /*
@@ -261,7 +261,7 @@ fddi_hdr_print(netdissect_options *ndo,
        dstname = etheraddr_string(ndo, fdst);
 
        if (!ndo->ndo_qflag)
-               print_fddi_fc(ndo, fddip->fddi_fc);
+               print_fddi_fc(ndo, EXTRACT_U_1(fddip->fddi_fc));
        ND_PRINT((ndo, "%s > %s, length %u: ",
               srcname, dstname,
               length));
@@ -277,7 +277,8 @@ u_int
 fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
        const struct fddi_header *fddip = (const struct fddi_header *)p;
-       struct ether_header ehdr;
+       uint8_t fc;
+       nd_mac_addr srcmac, dstmac;
        struct lladdr_info src, dst;
        int llc_hdrlen;
 
@@ -286,17 +287,19 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
                return (caplen);
        }
 
+       fc = EXTRACT_U_1(fddip->fddi_fc);
+
        /*
         * Get the FDDI addresses into a canonical form
         */
-       extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
+       extract_fddi_addrs(fddip, (char *)srcmac, (char *)dstmac);
 
        if (ndo->ndo_eflag)
-               fddi_hdr_print(ndo, fddip, length, ESRC(&ehdr), EDST(&ehdr));
+               fddi_hdr_print(ndo, fddip, length, srcmac, dstmac);
 
-       src.addr = ESRC(&ehdr);
+       src.addr = srcmac;
        src.addr_string = etheraddr_string;
-       dst.addr = EDST(&ehdr);
+       dst.addr = dstmac;
        dst.addr_string = etheraddr_string;
 
        /* Skip over FDDI MAC header */
@@ -305,7 +308,7 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
        caplen -= FDDI_HDRLEN;
 
        /* Frame Control field determines interpretation of packet */
-       if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
+       if ((fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
                /* Try to print the LLC-layer header & higher layers */
                llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
                if (llc_hdrlen < 0) {
@@ -317,14 +320,14 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
                                ND_DEFAULTPRINT(p, caplen);
                        llc_hdrlen = -llc_hdrlen;
                }
-       } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) {
+       } else if ((fc & FDDIFC_CLFF) == FDDIFC_SMT) {
                fddi_smt_print(ndo, p, caplen);
                llc_hdrlen = 0;
        } else {
                /* Some kinds of FDDI packet we cannot handle intelligently */
                if (!ndo->ndo_eflag)
-                       fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
-                           EDST(&ehdr));
+                       fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, srcmac,
+                           dstmac);
                if (!ndo->ndo_suppress_default_print)
                        ND_DEFAULTPRINT(p, caplen);
                llc_hdrlen = 0;
index b8a08e9626e733225888c388f37825b290e42cf6..2ba51271876be554b9b3e54588be594baeabb798 100644 (file)
 #include "netdissect.h"
 #include "addrtoname.h"
 
-#include "ether.h"
-
 struct ipfc_header {
-       u_char  ipfc_dhost[8];
-       u_char  ipfc_shost[8];
+       nd_byte ipfc_dhost[2+MAC_ADDR_LEN];
+       nd_byte ipfc_shost[2+MAC_ADDR_LEN];
 };
 
 #define IPFC_HDRLEN 16
@@ -52,8 +50,8 @@ extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
         * We assume that, as per RFC 2625, the lower 48 bits of the
         * source and destination addresses are MAC addresses.
         */
-       memcpy(ipfcdst, (const char *)&ipfcp->ipfc_dhost[2], 6);
-       memcpy(ipfcsrc, (const char *)&ipfcp->ipfc_shost[2], 6);
+       memcpy(ipfcdst, (const char *)&ipfcp->ipfc_dhost[2], MAC_ADDR_LEN);
+       memcpy(ipfcsrc, (const char *)&ipfcp->ipfc_shost[2], MAC_ADDR_LEN);
 }
 
 /*
@@ -92,7 +90,7 @@ static u_int
 ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
        const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
-       struct ether_header ehdr;
+       nd_mac_addr srcmac, dstmac;
        struct lladdr_info src, dst;
        int llc_hdrlen;
 
@@ -103,14 +101,14 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
        /*
         * Get the network addresses into a canonical form
         */
-       extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
+       extract_ipfc_addrs(ipfcp, (char *)srcmac, (char *)dstmac);
 
        if (ndo->ndo_eflag)
-               ipfc_hdr_print(ndo, ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
+               ipfc_hdr_print(ndo, ipfcp, length, srcmac, dstmac);
 
-       src.addr = ESRC(&ehdr);
+       src.addr = srcmac;
        src.addr_string = etheraddr_string;
-       dst.addr = EDST(&ehdr);
+       dst.addr = dstmac;
        dst.addr_string = etheraddr_string;
 
        /* Skip over Network_Header */
index 131fe7f4d91f1cec2faab607e89c72b18694ef91..b92d2b145189b4e6aaad5ac5515aafa94648d24a 100644 (file)
@@ -36,7 +36,6 @@
 
 #include "netdissect.h"
 #include "addrtoname.h"
-#include "ether.h"
 #include "nlpid.h"
 #include "extract.h"
 #include "gmpls.h"
@@ -49,7 +48,7 @@ static const char tstr[] = " [|isis]";
  * IS-IS is defined in ISO 10589.  Look there for protocol definitions.
  */
 
-#define SYSTEM_ID_LEN  ETHER_ADDR_LEN
+#define SYSTEM_ID_LEN  MAC_ADDR_LEN
 #define NODE_ID_LEN     (SYSTEM_ID_LEN+1)
 #define LSP_ID_LEN      (SYSTEM_ID_LEN+2)
 
@@ -2609,11 +2608,11 @@ isis_print(netdissect_options *ndo,
            }
            break;
        case ISIS_TLV_ISNEIGH:
-           while (tmp >= ETHER_ADDR_LEN) {
-                ND_TCHECK_LEN(tptr, ETHER_ADDR_LEN);
-                ND_PRINT((ndo, "\n\t      SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN)));
-                tmp -= ETHER_ADDR_LEN;
-                tptr += ETHER_ADDR_LEN;
+           while (tmp >= MAC_ADDR_LEN) {
+                ND_TCHECK_LEN(tptr, MAC_ADDR_LEN);
+                ND_PRINT((ndo, "\n\t      SNPA: %s", isis_print_id(tptr, MAC_ADDR_LEN)));
+                tmp -= MAC_ADDR_LEN;
+                tptr += MAC_ADDR_LEN;
            }
            break;
 
index ccc235273330dab771ae4c5ef0879b682e04328b..cc4cb6bb0d1a0a60f8437b9c4b987b5618cb7ff5 100644 (file)
 
 #include "netdissect.h"
 #include "extract.h"
-#include "ether.h"
 
 struct lecdatahdr_8023 {
   uint16_t le_header;
-  uint8_t h_dest[ETHER_ADDR_LEN];
-  uint8_t h_source[ETHER_ADDR_LEN];
+  nd_mac_addr h_dest;
+  nd_mac_addr h_source;
   uint16_t h_type;
 };
 
index f009f1ae2e1dad7a702d9aca182e654909954851..cd368b3f39de33befd325a97db8b214ac4da3a42 100644 (file)
@@ -210,11 +210,11 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                /*
                 * This is an Ethernet_802.3 IPX frame; it has an
                 * 802.3 header (i.e., an Ethernet header where the
-                * type/length field is <= ETHERMTU, i.e. it's a length
-                * field, not a type field), but has no 802.2 header -
-                * the IPX packet starts right after the Ethernet header,
-                * with a signature of two bytes of 0xFF (which is
-                * LLCSAP_GLOBAL).
+                * type/length field is <= MAX_ETHERNET_LENGTH_VAL,
+                * i.e. it's a length field, not a type field), but
+                * has no 802.2 header - the IPX packet starts right
+                * after the Ethernet header, with a signature of two
+                * bytes of 0xFF (which is LLCSAP_GLOBAL).
                 *
                 * (It might also have been an Ethernet_802.3 IPX at
                 * one time, but got bridged onto another network,
index b740202569d98a3582ddbb8237f8ef7224875951..205c4aed7cbee7e4708798ceda8ba6b61300506f 100644 (file)
@@ -40,7 +40,6 @@
 
 #include "netdissect.h"
 #include "extract.h"
-#include "ether.h"
 #include "addrtoname.h"
 
 static const char tstr[] = " [|loopback]";
@@ -84,9 +83,9 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le
                        if (len < 8)
                                goto invalid;
                        /* forwarding address */
-                       ND_TCHECK_LEN(cp, ETHER_ADDR_LEN);
+                       ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
                        ND_PRINT((ndo, ", forwarding address %s", etheraddr_string(ndo, cp)));
-                       cp += ETHER_ADDR_LEN;
+                       cp += MAC_ADDR_LEN;
                        /* data */
                        ND_PRINT((ndo, ", data (%u octets)", len - 8));
                        ND_TCHECK_LEN(cp, len - 8);
index 95e608f0d0c3c7c15a2340ba5c9eb1be77a6c780..562033388afbbb77d0f9ac979ca71eb05c7307d6 100644 (file)
@@ -28,7 +28,6 @@
 #include <netdissect-stdinc.h>
 
 #include "netdissect.h"
-#include "ether.h"
 #include "ethertype.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -158,7 +157,7 @@ medsa_print(netdissect_options *ndo,
        caplen -= 8;
 
        ether_type = EXTRACT_BE_U_2(&medsa->ether_type);
-       if (ether_type <= ETHERMTU) {
+       if (ether_type <= MAX_ETHERNET_LENGTH_VAL) {
                /* Try to print the LLC-layer header & higher layers */
                if (llc_print(ndo, bp, length, caplen, src, dst) < 0) {
                        /* packet type not known, print raw packet */
index ec9b6a187595583669f34a0a9b676076f0d02a8b..d544a3a96f8e31c74c1b37b6bf3fb43a6cde7012 100644 (file)
@@ -67,7 +67,6 @@
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ether.h"
 #include "ethertype.h"
 #include "ipproto.h"
 #include "oui.h"
@@ -1153,9 +1152,9 @@ of10_phy_ports_print(netdissect_options *ndo,
                ND_PRINT((ndo, "\n\t  port_no %s", tok2str(ofpp_str, "%u", EXTRACT_BE_U_2(cp))));
                cp += 2;
                /* hw_addr */
-               ND_TCHECK_LEN(cp, ETHER_ADDR_LEN);
+               ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
                ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
-               cp += ETHER_ADDR_LEN;
+               cp += MAC_ADDR_LEN;
                /* name */
                ND_TCHECK_LEN(cp, OFP_MAX_PORT_NAME_LEN);
                ND_PRINT((ndo, ", name '"));
@@ -1365,15 +1364,15 @@ of10_match_print(netdissect_options *ndo,
                ND_PRINT((ndo, "%smatch in_port %s", pfx, tok2str(ofpp_str, "%u", EXTRACT_BE_U_2(cp))));
        cp += 2;
        /* dl_src */
-       ND_TCHECK_LEN(cp, ETHER_ADDR_LEN);
+       ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
        if (! (wildcards & OFPFW_DL_SRC))
                ND_PRINT((ndo, "%smatch dl_src %s", pfx, etheraddr_string(ndo, cp)));
-       cp += ETHER_ADDR_LEN;
+       cp += MAC_ADDR_LEN;
        /* dl_dst */
-       ND_TCHECK_LEN(cp, ETHER_ADDR_LEN);
+       ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
        if (! (wildcards & OFPFW_DL_DST))
                ND_PRINT((ndo, "%smatch dl_dst %s", pfx, etheraddr_string(ndo, cp)));
-       cp += ETHER_ADDR_LEN;
+       cp += MAC_ADDR_LEN;
        /* dl_vlan */
        ND_TCHECK_2(cp);
        if (! (wildcards & OFPFW_DL_VLAN))
@@ -1543,9 +1542,9 @@ of10_actions_print(netdissect_options *ndo,
                case OFPAT_SET_DL_SRC:
                case OFPAT_SET_DL_DST:
                        /* dl_addr */
-                       ND_TCHECK_LEN(cp, ETHER_ADDR_LEN);
+                       ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
                        ND_PRINT((ndo, ", dl_addr %s", etheraddr_string(ndo, cp)));
-                       cp += ETHER_ADDR_LEN;
+                       cp += MAC_ADDR_LEN;
                        /* pad */
                        ND_TCHECK_6(cp);
                        cp += 6;
@@ -1720,9 +1719,9 @@ of10_port_mod_print(netdissect_options *ndo,
        ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_BE_U_2(cp))));
        cp += 2;
        /* hw_addr */
-       ND_TCHECK_LEN(cp, ETHER_ADDR_LEN);
+       ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
        ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
-       cp += ETHER_ADDR_LEN;
+       cp += MAC_ADDR_LEN;
        /* config */
        ND_TCHECK_4(cp);
        ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_BE_U_4(cp)));
index d96b1dc42a6d255d87c4b07502dd7b630b475cae..ecfa3740bf9546b829280967747cb53aedb554e1 100644 (file)
@@ -49,7 +49,6 @@
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
-#include "ether.h"
 
 #define RRCP_OPCODE_MASK       0x7F    /* 0x00 = hello, 0x01 = get, 0x02 = set */
 #define RRCP_ISREPLY           0x80    /* 0 = request to switch, 0x80 = reply from switch */
index 58a1649ee740125e2eee1652beae995e1153e658..53ee4e96e1fd182b24f5a275d8228307dcb48513 100644 (file)
@@ -32,8 +32,6 @@
 #include "ethertype.h"
 #include "extract.h"
 
-#include "ether.h"
-
 /*
  * For captures on Linux cooked sockets, we construct a fake header
  * that includes:
@@ -149,7 +147,7 @@ sll_print(netdissect_options *ndo, register const struct sll_header *sllp, u_int
        if (!ndo->ndo_qflag) {
                ether_type = EXTRACT_BE_U_2(&sllp->sll_protocol);
 
-               if (ether_type <= ETHERMTU) {
+               if (ether_type <= MAX_ETHERNET_LENGTH_VAL) {
                        /*
                         * Not an Ethernet type; what type is it?
                         */
@@ -232,7 +230,7 @@ recurse:
         * Is it (gag) an 802.3 encapsulation, or some non-Ethernet
         * packet type?
         */
-       if (ether_type <= ETHERMTU) {
+       if (ether_type <= MAX_ETHERNET_LENGTH_VAL) {
                /*
                 * Yes - what type is it?
                 */
@@ -285,7 +283,7 @@ recurse:
                }
 
                ether_type = EXTRACT_BE_U_2(p + 2);
-               if (ether_type <= ETHERMTU)
+               if (ether_type <= MAX_ETHERNET_LENGTH_VAL)
                        ether_type = LINUX_SLL_P_802_2;
                if (!ndo->ndo_qflag) {
                        ND_PRINT((ndo, "ethertype %s, ",
index d30aa219f7455a0d5b6eb22587360cf45c97659b..c6b6bd7c8e3241d14b536dffc156d1bd1dbee5c3 100644 (file)
@@ -29,7 +29,6 @@
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ether.h"
 #include "oui.h"
 
 #define        SLOW_PROTO_LACP                     1
@@ -202,7 +201,7 @@ static const struct tok slow_tlv_values[] = {
 
 struct lacp_tlv_actor_partner_info_t {
     nd_uint16_t sys_pri;
-    uint8_t sys[ETHER_ADDR_LEN];
+    nd_mac_addr sys;
     nd_uint16_t key;
     nd_uint16_t port_pri;
     nd_uint16_t port;
@@ -229,7 +228,7 @@ struct lacp_tlv_collector_info_t {
 
 struct marker_tlv_marker_info_t {
     nd_uint16_t req_port;
-    uint8_t req_sys[ETHER_ADDR_LEN];
+    nd_mac_addr req_sys;
     nd_uint32_t req_trans_id;
     uint8_t pad[2];
 };
index c1fe3bd4162b6f3a8768e1a1f41cd9019dbd9d25..56f7fc260f40360a9f4617671bb0d07c02372866 100644 (file)
@@ -31,8 +31,6 @@
 #include "extract.h"
 #include "ethertype.h"
 
-#include "ether.h"
-
 struct symantec_header {
        uint8_t  stuff1[6];
        uint16_t ether_type;
@@ -49,14 +47,14 @@ symantec_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int len
 
        etype = EXTRACT_BE_U_2(&sp->ether_type);
        if (!ndo->ndo_qflag) {
-               if (etype <= ETHERMTU)
+               if (etype <= MAX_ETHERNET_LENGTH_VAL)
                          ND_PRINT((ndo, "invalid ethertype %u", etype));
                 else
                          ND_PRINT((ndo, "ethertype %s (0x%04x)",
                                       tok2str(ethertype_values,"Unknown", etype),
                                        etype));
         } else {
-                if (etype <= ETHERMTU)
+                if (etype <= MAX_ETHERNET_LENGTH_VAL)
                           ND_PRINT((ndo, "invalid ethertype %u", etype));
                 else
                           ND_PRINT((ndo, "%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype)));
@@ -94,7 +92,7 @@ symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_
 
        ether_type = EXTRACT_BE_U_2(&sp->ether_type);
 
-       if (ether_type <= ETHERMTU) {
+       if (ether_type <= MAX_ETHERNET_LENGTH_VAL) {
                /* ether_type not known, print raw packet */
                if (!ndo->ndo_eflag)
                        symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
index 8c421ee35ae47da17b3ba2b74b6e5c606bea99c5..90077a0c70fb03b1f683c2343e190af1284bb8ba 100644 (file)
@@ -34,7 +34,6 @@
 #include <netdissect-stdinc.h>
 
 #include "netdissect.h"
-#include "ether.h"
 #include "ethertype.h"
 #include "extract.h"
 
index 730c155d75f0e08569188a9cbe0c4628e8a2e50e..5cca3b072ca443f79dbddcb413af99f36f7ca3ed 100644 (file)
@@ -37,7 +37,6 @@
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ether.h"
 
 /*
  * Copyright (c) 1998, Larry Lile
  */
 
 #define TOKEN_HDRLEN           14
-#define TOKEN_RING_MAC_LEN     6
 #define ROUTING_SEGMENT_MAX    16
 #define IS_SOURCE_ROUTED(trp)  ((trp)->token_shost[0] & 0x80)
-#define FRAME_TYPE(trp)                (((trp)->token_fc & 0xC0) >> 6)
+#define FRAME_TYPE(trp)                ((EXTRACT_U_1((trp)->token_fc) & 0xC0) >> 6)
 #define TOKEN_FC_LLC           1
 
-#define BROADCAST(trp)         ((EXTRACT_BE_U_2(&(trp)->token_rcf) & 0xE000) >> 13)
-#define RIF_LENGTH(trp)                ((EXTRACT_BE_U_2(&(trp)->token_rcf) & 0x1f00) >> 8)
-#define DIRECTION(trp)         ((EXTRACT_BE_U_2(&(trp)->token_rcf) & 0x0080) >> 7)
-#define LARGEST_FRAME(trp)     ((EXTRACT_BE_U_2(&(trp)->token_rcf) & 0x0070) >> 4)
-#define RING_NUMBER(trp, x)    ((EXTRACT_BE_U_2(&(trp)->token_rseg[x]) & 0xfff0) >> 4)
-#define BRIDGE_NUMBER(trp, x)  ((EXTRACT_BE_U_2(&(trp)->token_rseg[x]) & 0x000f))
+#define BROADCAST(trp)         ((EXTRACT_BE_U_2((trp)->token_rcf) & 0xE000) >> 13)
+#define RIF_LENGTH(trp)                ((EXTRACT_BE_U_2((trp)->token_rcf) & 0x1f00) >> 8)
+#define DIRECTION(trp)         ((EXTRACT_BE_U_2((trp)->token_rcf) & 0x0080) >> 7)
+#define LARGEST_FRAME(trp)     ((EXTRACT_BE_U_2((trp)->token_rcf) & 0x0070) >> 4)
+#define RING_NUMBER(trp, x)    ((EXTRACT_BE_U_2((trp)->token_rseg[x]) & 0xfff0) >> 4)
+#define BRIDGE_NUMBER(trp, x)  ((EXTRACT_BE_U_2((trp)->token_rseg[x]) & 0x000f))
 #define SEGMENT_COUNT(trp)     ((int)((RIF_LENGTH(trp) - 2) / 2))
 
 struct token_header {
-       uint8_t  token_ac;
-       uint8_t  token_fc;
-       uint8_t  token_dhost[TOKEN_RING_MAC_LEN];
-       uint8_t  token_shost[TOKEN_RING_MAC_LEN];
-       uint16_t token_rcf;
-       uint16_t token_rseg[ROUTING_SEGMENT_MAX];
+       nd_uint8_t   token_ac;
+       nd_uint8_t   token_fc;
+       nd_mac_addr  token_dhost;
+       nd_mac_addr  token_shost;
+       nd_uint16_t  token_rcf;
+       nd_uint16_t  token_rseg[ROUTING_SEGMENT_MAX];
 };
 
 static const char tstr[] = "[|token-ring]";
@@ -116,8 +114,8 @@ token_hdr_print(netdissect_options *ndo,
 
        if (!ndo->ndo_qflag)
                ND_PRINT((ndo, "%02x %02x ",
-                      trp->token_ac,
-                      trp->token_fc));
+                      EXTRACT_U_1(trp->token_ac),
+                      EXTRACT_U_1(trp->token_fc)));
        ND_PRINT((ndo, "%s > %s, length %u: ",
               srcname, dstname,
               length));
@@ -150,7 +148,7 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
 {
        const struct token_header *trp;
        int llc_hdrlen;
-       struct ether_header ehdr;
+       nd_mac_addr srcmac, dstmac;
        struct lladdr_info src, dst;
        u_int route_len = 0, hdr_len = TOKEN_HDRLEN;
        int seg;
@@ -165,15 +163,15 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
        /*
         * Get the TR addresses into a canonical form
         */
-       extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));
+       extract_token_addrs(trp, (char*)srcmac, (char*)dstmac);
 
        /* Adjust for source routing information in the MAC header */
        if (IS_SOURCE_ROUTED(trp)) {
                /* Clear source-routed bit */
-               *ESRC(&ehdr) &= 0x7f;
+               srcmac[0] &= 0x7f;
 
                if (ndo->ndo_eflag)
-                       token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
+                       token_hdr_print(ndo, trp, length, srcmac, dstmac);
 
                if (caplen < TOKEN_HDRLEN + 2) {
                        ND_PRINT((ndo, "%s", tstr));
@@ -193,20 +191,20 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
                                ND_PRINT((ndo, " [%d:%d]", RING_NUMBER(trp, seg),
                                    BRIDGE_NUMBER(trp, seg)));
                } else {
-                       ND_PRINT((ndo, "rt = %x", EXTRACT_BE_U_2(&trp->token_rcf)));
+                       ND_PRINT((ndo, "rt = %x", EXTRACT_BE_U_2(trp->token_rcf)));
 
                        for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
-                               ND_PRINT((ndo, ":%x", EXTRACT_BE_U_2(&trp->token_rseg[seg])));
+                               ND_PRINT((ndo, ":%x", EXTRACT_BE_U_2(trp->token_rseg[seg])));
                }
                ND_PRINT((ndo, " (%s) ", largest_frame[LARGEST_FRAME(trp)]));
        } else {
                if (ndo->ndo_eflag)
-                       token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
+                       token_hdr_print(ndo, trp, length, srcmac, dstmac);
        }
 
-       src.addr = ESRC(&ehdr);
+       src.addr = srcmac;
        src.addr_string = etheraddr_string;
-       dst.addr = EDST(&ehdr);
+       dst.addr = dstmac;
        dst.addr_string = etheraddr_string;
 
        /* Skip over token ring MAC header and routing information */
@@ -230,7 +228,7 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
                /* XXX - dissect MAC packets if frame type is 0 */
                if (!ndo->ndo_eflag)
                        token_hdr_print(ndo, trp, length + TOKEN_HDRLEN + route_len,
-                           ESRC(&ehdr), EDST(&ehdr));
+                           srcmac, dstmac);
                if (!ndo->ndo_suppress_default_print)
                        ND_DEFAULTPRINT(p, caplen);
        }
index a9a5bf604bdbe066554d5a01409da9917fa6c796..5dd9939bcb969e42a14f0eea9d2612b56223c962 100644 (file)
@@ -26,7 +26,6 @@
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ether.h"
 
 #define VQP_VERSION                            1
 #define VQP_EXTRACT_VERSION(x) ((x)&0xFF)
@@ -192,7 +191,7 @@ vqp_print(netdissect_options *ndo, register const u_char *pptr, register u_int l
             /* those objects have similar semantics - fall through */
        case VQP_OBJ_MAC_ADDRESS:
        case VQP_OBJ_MAC_NULL:
-            if (vqp_obj_len != ETHER_ADDR_LEN)
+            if (vqp_obj_len != MAC_ADDR_LEN)
                 goto trunc;
              ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr)));
               break;