Fix pmacct build when no nfacctd | pmacctd options are selected
[openwrt.git] / openwrt / package / linux / kernel-source / include / proto / ethernet.h
1 /*******************************************************************************
2 * $Id$
3 * Copyright 2004, Broadcom Corporation
4 * All Rights Reserved.
5 *
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 ******************************************************************************/
12
13 #ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
14 #define _NET_ETHERNET_H_
15
16 #ifndef _TYPEDEFS_H_
17 #include "typedefs.h"
18 #endif
19
20 #if defined(__GNUC__)
21 #define PACKED __attribute__((packed))
22 #else
23 #define PACKED
24 #endif
25
26 /*
27 * The number of bytes in an ethernet (MAC) address.
28 */
29 #define ETHER_ADDR_LEN 6
30
31 /*
32 * The number of bytes in the type field.
33 */
34 #define ETHER_TYPE_LEN 2
35
36 /*
37 * The number of bytes in the trailing CRC field.
38 */
39 #define ETHER_CRC_LEN 4
40
41 /*
42 * The length of the combined header.
43 */
44 #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
45
46 /*
47 * The minimum packet length.
48 */
49 #define ETHER_MIN_LEN 64
50
51 /*
52 * The minimum packet user data length.
53 */
54 #define ETHER_MIN_DATA 46
55
56 /*
57 * The maximum packet length.
58 */
59 #define ETHER_MAX_LEN 1518
60
61 /*
62 * The maximum packet user data length.
63 */
64 #define ETHER_MAX_DATA 1500
65
66 /*
67 * Used to uniquely identify a 802.1q VLAN-tagged header.
68 */
69 #define VLAN_TAG 0x8100
70
71 /*
72 * Located after dest & src address in ether header.
73 */
74 #define VLAN_FIELDS_OFFSET (ETHER_ADDR_LEN * 2)
75
76 /*
77 * 4 bytes of vlan field info.
78 */
79 #define VLAN_FIELDS_SIZE 4
80
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 */
84
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 */
89
90 struct vlan_tags {
91 uint16 tag_type; /* 0x8100 for VLAN */
92 uint16 tag_control; /* prio | cfi | vid */
93 } PACKED ;
94
95 /* 802.1X ethertype */
96
97 #define ETHER_TYPE_IP 0x0800 /* IP */
98 #define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
99 #define ETHER_TYPE_802_1X 0x888e /* 802.1x */
100
101 #define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4byte subtype follows ethertype */
102 #define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
103
104 /*
105 * A macro to validate a length with
106 */
107 #define ETHER_IS_VALID_LEN(foo) \
108 ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
109
110
111 #ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
112 /*
113 * Structure of a 10Mb/s Ethernet header.
114 */
115 struct ether_header {
116 uint8 ether_dhost[ETHER_ADDR_LEN];
117 uint8 ether_shost[ETHER_ADDR_LEN];
118 uint16 ether_type;
119 } PACKED ;
120
121 /*
122 * Structure of a 48-bit Ethernet address.
123 */
124 struct ether_addr {
125 uint8 octet[ETHER_ADDR_LEN];
126 } PACKED ;
127 #endif
128
129 /*
130 * Takes a pointer, returns true if a 48-bit multicast address
131 * (including broadcast, since it is all ones)
132 */
133 #define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
134
135 /*
136 * Takes a pointer, returns true if a 48-bit broadcast (all ones)
137 */
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)
144
145 static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
146
147 /*
148 * Takes a pointer, returns true if a 48-bit null address (all zeros)
149 */
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)
156
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
161
162 #undef PACKED
163
164 #endif /* _NET_ETHERNET_H_ */
This page took 0.049301 seconds and 5 git commands to generate.