allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / include / proto / vlan.h
blobac9a46325be5ba3a1df55c2fc24d19f050460bb5
1 /*
2 * 802.1Q VLAN protocol definitions
4 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * $Id: vlan.h 345182 2012-07-16 23:31:56Z $
21 #ifndef _vlan_h_
22 #define _vlan_h_
24 #ifndef _TYPEDEFS_H_
25 #include <typedefs.h>
26 #endif
28 /* This marks the start of a packed structure section. */
29 #include <packed_section_start.h>
31 #ifndef VLAN_VID_MASK
32 #define VLAN_VID_MASK 0xfff /* low 12 bits are vlan id */
33 #endif
35 #define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
36 #define VLAN_PRI_SHIFT 13 /* user priority */
38 #define VLAN_PRI_MASK 7 /* 3 bits of priority */
40 #define VLAN_TPID_OFFSET 12 /* offset of tag protocol id field */
41 #define VLAN_TCI_OFFSET 14 /* offset of tag ctrl info field */
43 #define VLAN_TAG_LEN 4
44 #define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN) /* offset in Ethernet II packet only */
46 #define VLAN_TPID 0x8100 /* VLAN ethertype/Tag Protocol ID */
48 struct vlan_header {
49 uint16 vlan_type; /* 0x8100 */
50 uint16 vlan_tag; /* priority, cfi and vid */
53 struct ethervlan_header {
54 uint8 ether_dhost[ETHER_ADDR_LEN];
55 uint8 ether_shost[ETHER_ADDR_LEN];
56 uint16 vlan_type; /* 0x8100 */
57 uint16 vlan_tag; /* priority, cfi and vid */
58 uint16 ether_type;
61 #define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN)
64 /* This marks the end of a packed structure section. */
65 #include <packed_section_end.h>
67 #define ETHERVLAN_MOVE_HDR(d, s) \
68 do { \
69 struct ethervlan_header t; \
70 t = *(struct ethervlan_header *)(s); \
71 *(struct ethervlan_header *)(d) = t; \
72 } while (0)
74 #endif /* _vlan_h_ */