• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * 802.1Q VLAN protocol definitions
3  *
4  * Copyright (C) 1999-2013, Broadcom Corporation
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.
17  *
18  * $Id: vlan.h 382883 2013-02-04 23:26:09Z $
19  */
20 
21 #ifndef _vlan_h_
22 #define _vlan_h_
23 
24 #ifndef _TYPEDEFS_H_
25 #include <typedefs.h>
26 #endif
27 
28 /* This marks the start of a packed structure section. */
29 #include <packed_section_start.h>
30 
31 #ifndef	 VLAN_VID_MASK
32 #define VLAN_VID_MASK		0xfff	/* low 12 bits are vlan id */
33 #endif
34 
35 #define	VLAN_CFI_SHIFT		12	/* canonical format indicator bit */
36 #define VLAN_PRI_SHIFT		13	/* user priority */
37 
38 #define VLAN_PRI_MASK		7	/* 3 bits of priority */
39 
40 #define	VLAN_TPID_OFFSET	12	/* offset of tag protocol id field */
41 #define	VLAN_TCI_OFFSET		14	/* offset of tag ctrl info field */
42 
43 #define	VLAN_TAG_LEN		4
44 #define	VLAN_TAG_OFFSET		(2 * ETHER_ADDR_LEN)	/* offset in Ethernet II packet only */
45 
46 #define VLAN_TPID		0x8100	/* VLAN ethertype/Tag Protocol ID */
47 
48 struct vlan_header {
49 	uint16	vlan_type;		/* 0x8100 */
50 	uint16	vlan_tag;		/* priority, cfi and vid */
51 };
52 
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;
59 };
60 
61 struct dot3_mac_llc_snapvlan_header {
62 	uint8	ether_dhost[ETHER_ADDR_LEN];	/* dest mac */
63 	uint8	ether_shost[ETHER_ADDR_LEN];	/* src mac */
64 	uint16	length;				/* frame length incl header */
65 	uint8	dsap;				/* always 0xAA */
66 	uint8	ssap;				/* always 0xAA */
67 	uint8	ctl;				/* always 0x03 */
68 	uint8	oui[3];				/* RFC1042: 0x00 0x00 0x00
69 						 * Bridge-Tunnel: 0x00 0x00 0xF8
70 						 */
71 	uint16	vlan_type;			/* 0x8100 */
72 	uint16	vlan_tag;			/* priority, cfi and vid */
73 	uint16	ether_type;			/* ethertype */
74 };
75 
76 #define	ETHERVLAN_HDR_LEN	(ETHER_HDR_LEN + VLAN_TAG_LEN)
77 
78 
79 /* This marks the end of a packed structure section. */
80 #include <packed_section_end.h>
81 
82 #define ETHERVLAN_MOVE_HDR(d, s) \
83 do { \
84 	struct ethervlan_header t; \
85 	t = *(struct ethervlan_header *)(s); \
86 	*(struct ethervlan_header *)(d) = t; \
87 } while (0)
88 
89 #endif /* _vlan_h_ */
90