1 /*******************************************************************************
3 * Copyright 2004, Broadcom Corporation
6 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
7 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
8 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
9 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
10 * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
11 ******************************************************************************/
13 #ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
14 #define _NET_ETHERNET_H_
21 #define PACKED __attribute__((packed))
27 * The number of bytes in an ethernet (MAC) address.
29 #ifndef ETHER_ADDR_LEN
30 #define ETHER_ADDR_LEN 6
34 * The number of bytes in the type field.
36 #ifndef ETHER_TYPE_LEN
37 #define ETHER_TYPE_LEN 2
41 * The number of bytes in the trailing CRC field.
44 #define ETHER_CRC_LEN 4
48 * The length of the combined header.
51 #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
55 * The minimum packet length.
58 #define ETHER_MIN_LEN 64
62 * The minimum packet user data length.
64 #ifndef ETHER_MIN_DATA
65 #define ETHER_MIN_DATA 46
69 * The maximum packet length.
72 #define ETHER_MAX_LEN 1518
76 * The maximum packet user data length.
78 #define ETHER_MAX_DATA 1500
81 * Used to uniquely identify a 802.1q VLAN-tagged header.
83 #define VLAN_TAG 0x8100
86 * Located after dest & src address in ether header.
88 #define VLAN_FIELDS_OFFSET (ETHER_ADDR_LEN * 2)
91 * 4 bytes of vlan field info.
93 #define VLAN_FIELDS_SIZE 4
95 /* location of bits in 16-bit vlan fields */
96 #define VLAN_PRI_SHIFT 13 /* user priority */
97 #define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
99 /* 3 bits of priority */
100 #define VLAN_PRI_MASK 7
101 /* 12 bits of vlan identfier (VID) */
102 #define VLAN_VID_MASK 0xFFF /* VLAN identifier (VID) field */
105 uint16 tag_type
; /* 0x8100 for VLAN */
106 uint16 tag_control
; /* prio | cfi | vid */
109 /* 802.1X ethertype */
111 #define ETHER_TYPE_IP 0x0800 /* IP */
112 #define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
113 #define ETHER_TYPE_802_1X 0x888e /* 802.1x */
115 #define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4byte subtype follows ethertype */
116 #define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
119 * A macro to validate a length with
121 #define ETHER_IS_VALID_LEN(foo) \
122 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
124 #ifndef __NET_ETHERNET_H
125 #ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
127 * Structure of a 10Mb/s Ethernet header.
129 struct ether_header
{
130 uint8 ether_dhost
[ETHER_ADDR_LEN
];
131 uint8 ether_shost
[ETHER_ADDR_LEN
];
136 * Structure of a 48-bit Ethernet address.
139 uint8 octet
[ETHER_ADDR_LEN
];
145 * Takes a pointer, returns true if a 48-bit multicast address
146 * (including broadcast, since it is all ones)
148 #define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
151 * Takes a pointer, returns true if a 48-bit broadcast (all ones)
153 #define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
154 ((uint8 *)(ea))[1] & \
155 ((uint8 *)(ea))[2] & \
156 ((uint8 *)(ea))[3] & \
157 ((uint8 *)(ea))[4] & \
158 ((uint8 *)(ea))[5]) == 0xff)
160 static const struct ether_addr ether_bcast
= {{255, 255, 255, 255, 255, 255}};
163 * Takes a pointer, returns true if a 48-bit null address (all zeros)
165 #define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
166 ((uint8 *)(ea))[1] | \
167 ((uint8 *)(ea))[2] | \
168 ((uint8 *)(ea))[3] | \
169 ((uint8 *)(ea))[4] | \
170 ((uint8 *)(ea))[5]) == 0)
172 /* Differentiated Services Codepoint - lower 6 bits of tos in iphdr */
173 #define DSCP_PRI_MASK 0x3F /* bits 0-6 */
174 #define DSCP_WME_PRI_MASK 0x38 /* bits 3-6 */
175 #define DSCP_WME_PRI_SHIFT 3
179 #endif /* _NET_ETHERNET_H_ */
This page took 0.049558 seconds and 5 git commands to generate.