atm.h \
chdlc.h \
cpack.h \
- ether.h \
ethertype.h \
extract.h \
funcattrs.h \
#include "extract.h"
#include "oui.h"
-#ifndef ETHER_ADDR_LEN
-#define ETHER_ADDR_LEN 6
-#endif
-
/*
* hash tables for whatever-to-name translations
*
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)
+++ /dev/null
-/*
- * 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
* 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.
*
/*
* 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.
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ether.h"
static const char tstr[] = " [|aoe]";
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;
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);
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;
#include "netdissect.h"
#include "addrtoname.h"
-#include "ether.h"
#include "ethertype.h"
#include "extract.h"
#include "netdissect.h"
#include "extract.h"
-#include "ether.h"
#include "addrtoname.h"
#include "oui.h"
#include "af.h"
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[] = {
/* 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;
#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" },
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
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
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) {
}
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;
#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;
};
/*
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));
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;
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 */
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) {
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;
#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
* 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);
}
/*
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;
/*
* 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 */
#include "netdissect.h"
#include "addrtoname.h"
-#include "ether.h"
#include "nlpid.h"
#include "extract.h"
#include "gmpls.h"
* 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)
}
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;
#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;
};
/*
* 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,
#include "netdissect.h"
#include "extract.h"
-#include "ether.h"
#include "addrtoname.h"
static const char tstr[] = " [|loopback]";
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);
#include <netdissect-stdinc.h>
#include "netdissect.h"
-#include "ether.h"
#include "ethertype.h"
#include "addrtoname.h"
#include "extract.h"
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 */
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ether.h"
#include "ethertype.h"
#include "ipproto.h"
#include "oui.h"
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 '"));
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))
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;
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)));
#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 */
#include "ethertype.h"
#include "extract.h"
-#include "ether.h"
-
/*
* For captures on Linux cooked sockets, we construct a fake header
* that includes:
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?
*/
* 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?
*/
}
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, ",
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ether.h"
#include "oui.h"
#define SLOW_PROTO_LACP 1
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;
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];
};
#include "extract.h"
#include "ethertype.h"
-#include "ether.h"
-
struct symantec_header {
uint8_t stuff1[6];
uint16_t ether_type;
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)));
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));
#include <netdissect-stdinc.h>
#include "netdissect.h"
-#include "ether.h"
#include "ethertype.h"
#include "extract.h"
#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]";
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));
{
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;
/*
* 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));
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 */
/* 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);
}
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ether.h"
#define VQP_VERSION 1
#define VQP_EXTRACT_VERSION(x) ((x)&0xFF)
/* 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;