summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in1
-rw-r--r--addrtoname.c6
-rw-r--r--ether.h57
-rw-r--r--ethertype.h7
-rw-r--r--netdissect.h5
-rw-r--r--print-aoe.c11
-rw-r--r--print-arp.c1
-rw-r--r--print-cfm.c7
-rw-r--r--print-ether.c29
-rw-r--r--print-fddi.c31
-rw-r--r--print-ipfc.c20
-rw-r--r--print-isoclns.c13
-rw-r--r--print-lane.c5
-rw-r--r--print-llc.c10
-rw-r--r--print-loopback.c5
-rw-r--r--print-medsa.c3
-rw-r--r--print-openflow-1.0.c21
-rw-r--r--print-rrcp.c1
-rw-r--r--print-sll.c8
-rw-r--r--print-slow.c5
-rw-r--r--print-symantec.c8
-rw-r--r--print-tipc.c1
-rw-r--r--print-token.c52
-rw-r--r--print-vqp.c3
24 files changed, 126 insertions, 184 deletions
diff --git a/Makefile.in b/Makefile.in
index e13b1d6e..47ff53a1 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -259,7 +259,6 @@ HDR = \
atm.h \
chdlc.h \
cpack.h \
- ether.h \
ethertype.h \
extract.h \
funcattrs.h \
diff --git a/addrtoname.c b/addrtoname.c
index c481b807..003ce512 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -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
index 64916789..00000000
--- 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
diff --git a/ethertype.h b/ethertype.h
index f38ec8e4..7719a6f0 100644
--- a/ethertype.h
+++ b/ethertype.h
@@ -20,6 +20,13 @@
*/
/*
+ * 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.
*
* We wrap the declarations with #ifdef, so that if a file includes
diff --git a/netdissect.h b/netdissect.h
index e3066843..11907ea9 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -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.
diff --git a/print-aoe.c b/print-aoe.c
index 01f485dd..d821ec68 100644
--- a/print-aoe.c
+++ b/print-aoe.c
@@ -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;
diff --git a/print-arp.c b/print-arp.c
index 37320a84..174ecaf1 100644
--- a/print-arp.c
+++ b/print-arp.c
@@ -31,7 +31,6 @@
#include "netdissect.h"
#include "addrtoname.h"
-#include "ether.h"
#include "ethertype.h"
#include "extract.h"
diff --git a/print-cfm.c b/print-cfm.c
index 94624564..0a666478 100644
--- a/print-cfm.c
+++ b/print-cfm.c
@@ -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;
diff --git a/print-ether.c b/print-ether.c
index 8d8341ba..7e7216c4 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -31,7 +31,22 @@
#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;
diff --git a/print-fddi.c b/print-fddi.c
index 27803783..01f376f8 100644
--- a/print-fddi.c
+++ b/print-fddi.c
@@ -30,17 +30,17 @@
#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;
diff --git a/print-ipfc.c b/print-ipfc.c
index b8a08e96..2ba51271 100644
--- a/print-ipfc.c
+++ b/print-ipfc.c
@@ -34,11 +34,9 @@
#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 */
diff --git a/print-isoclns.c b/print-isoclns.c
index 131fe7f4..b92d2b14 100644
--- a/print-isoclns.c
+++ b/print-isoclns.c
@@ -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;
diff --git a/print-lane.c b/print-lane.c
index ccc23527..cc4cb6bb 100644
--- a/print-lane.c
+++ b/print-lane.c
@@ -30,12 +30,11 @@
#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;
};
diff --git a/print-llc.c b/print-llc.c
index f009f1ae..cd368b3f 100644
--- a/print-llc.c
+++ b/print-llc.c
@@ -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,
diff --git a/print-loopback.c b/print-loopback.c
index b7402025..205c4aed 100644
--- a/print-loopback.c
+++ b/print-loopback.c
@@ -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);
diff --git a/print-medsa.c b/print-medsa.c
index 95e608f0..56203338 100644
--- a/print-medsa.c
+++ b/print-medsa.c
@@ -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 */
diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c
index ec9b6a18..d544a3a9 100644
--- a/print-openflow-1.0.c
+++ b/print-openflow-1.0.c
@@ -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)));
diff --git a/print-rrcp.c b/print-rrcp.c
index d96b1dc4..ecfa3740 100644
--- a/print-rrcp.c
+++ b/print-rrcp.c
@@ -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 */
diff --git a/print-sll.c b/print-sll.c
index 58a1649e..53ee4e96 100644
--- a/print-sll.c
+++ b/print-sll.c
@@ -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, ",
diff --git a/print-slow.c b/print-slow.c
index d30aa219..c6b6bd7c 100644
--- a/print-slow.c
+++ b/print-slow.c
@@ -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];
};
diff --git a/print-symantec.c b/print-symantec.c
index c1fe3bd4..56f7fc26 100644
--- a/print-symantec.c
+++ b/print-symantec.c
@@ -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));
diff --git a/print-tipc.c b/print-tipc.c
index 8c421ee3..90077a0c 100644
--- a/print-tipc.c
+++ b/print-tipc.c
@@ -34,7 +34,6 @@
#include <netdissect-stdinc.h>
#include "netdissect.h"
-#include "ether.h"
#include "ethertype.h"
#include "extract.h"
diff --git a/print-token.c b/print-token.c
index 730c155d..5cca3b07 100644
--- a/print-token.c
+++ b/print-token.c
@@ -37,7 +37,6 @@
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ether.h"
/*
* Copyright (c) 1998, Larry Lile
@@ -68,27 +67,26 @@
*/
#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);
}
diff --git a/print-vqp.c b/print-vqp.c
index a9a5bf60..5dd9939b 100644
--- a/print-vqp.c
+++ b/print-vqp.c
@@ -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;