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 #define ETHER_ADDR_LEN 6
32 * The number of bytes in the type field.
34 #define ETHER_TYPE_LEN 2
37 * The number of bytes in the trailing CRC field.
39 #define ETHER_CRC_LEN 4
42 * The length of the combined header.
44 #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
47 * The minimum packet length.
49 #define ETHER_MIN_LEN 64
52 * The minimum packet user data length.
54 #define ETHER_MIN_DATA 46
57 * The maximum packet length.
59 #define ETHER_MAX_LEN 1518
62 * The maximum packet user data length.
64 #define ETHER_MAX_DATA 1500
67 * Used to uniquely identify a 802.1q VLAN-tagged header.
69 #define VLAN_TAG 0x8100
72 * Located after dest & src address in ether header.
74 #define VLAN_FIELDS_OFFSET (ETHER_ADDR_LEN * 2)
77 * 4 bytes of vlan field info.
79 #define VLAN_FIELDS_SIZE 4
81 /* location of bits in 16-bit vlan fields */
82 #define VLAN_PRI_SHIFT 13 /* user priority */
83 #define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
85 /* 3 bits of priority */
86 #define VLAN_PRI_MASK 7
87 /* 12 bits of vlan identfier (VID) */
88 #define VLAN_VID_MASK 0xFFF /* VLAN identifier (VID) field */
91 uint16 tag_type
; /* 0x8100 for VLAN */
92 uint16 tag_control
; /* prio | cfi | vid */
95 /* 802.1X ethertype */
97 #define ETHER_TYPE_IP 0x0800 /* IP */
98 #define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
99 #define ETHER_TYPE_802_1X 0x888e /* 802.1x */
101 #define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4byte subtype follows ethertype */
102 #define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
105 * A macro to validate a length with
107 #define ETHER_IS_VALID_LEN(foo) \
108 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
111 #ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
113 * Structure of a 10Mb/s Ethernet header.
115 struct ether_header
{
116 uint8 ether_dhost
[ETHER_ADDR_LEN
];
117 uint8 ether_shost
[ETHER_ADDR_LEN
];
122 * Structure of a 48-bit Ethernet address.
125 uint8 octet
[ETHER_ADDR_LEN
];
130 * Takes a pointer, returns true if a 48-bit multicast address
131 * (including broadcast, since it is all ones)
133 #define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
136 * Takes a pointer, returns true if a 48-bit broadcast (all ones)
138 #define ETHER_ISBCAST(ea) ((((uint8 *)(ea))[0] & \
139 ((uint8 *)(ea))[1] & \
140 ((uint8 *)(ea))[2] & \
141 ((uint8 *)(ea))[3] & \
142 ((uint8 *)(ea))[4] & \
143 ((uint8 *)(ea))[5]) == 0xff)
145 static const struct ether_addr ether_bcast
= {{255, 255, 255, 255, 255, 255}};
148 * Takes a pointer, returns true if a 48-bit null address (all zeros)
150 #define ETHER_ISNULLADDR(ea) ((((uint8 *)(ea))[0] | \
151 ((uint8 *)(ea))[1] | \
152 ((uint8 *)(ea))[2] | \
153 ((uint8 *)(ea))[3] | \
154 ((uint8 *)(ea))[4] | \
155 ((uint8 *)(ea))[5]) == 0)
157 /* Differentiated Services Codepoint - lower 6 bits of tos in iphdr */
158 #define DSCP_PRI_MASK 0x3F /* bits 0-6 */
159 #define DSCP_WME_PRI_MASK 0x38 /* bits 3-6 */
160 #define DSCP_WME_PRI_SHIFT 3
164 #endif /* _NET_ETHERNET_H_ */
This page took 0.051612 seconds and 5 git commands to generate.