1 /* 2 * 802.1Q VLAN protocol definitions 3 * 4 * Copyright (C) 1999-2011, 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,v 9.7 2009-03-13 01:11:50 Exp $ 19 */ 20 21 22 #ifndef _vlan_h_ 23 #define _vlan_h_ 24 25 #ifndef _TYPEDEFS_H_ 26 #include <typedefs.h> 27 #endif 28 29 30 #include <packed_section_start.h> 31 32 #define VLAN_VID_MASK 0xfff 33 #define VLAN_CFI_SHIFT 12 34 #define VLAN_PRI_SHIFT 13 35 36 #define VLAN_PRI_MASK 7 37 38 #define VLAN_TAG_LEN 4 39 #define VLAN_TAG_OFFSET (2 * ETHER_ADDR_LEN) 40 41 #define VLAN_TPID 0x8100 42 43 struct ethervlan_header { 44 uint8 ether_dhost[ETHER_ADDR_LEN]; 45 uint8 ether_shost[ETHER_ADDR_LEN]; 46 uint16 vlan_type; 47 uint16 vlan_tag; 48 uint16 ether_type; 49 }; 50 51 #define ETHERVLAN_HDR_LEN (ETHER_HDR_LEN + VLAN_TAG_LEN) 52 53 54 55 #include <packed_section_end.h> 56 57 #define ETHERVLAN_MOVE_HDR(d, s) \ 58 do { \ 59 struct ethervlan_header t; \ 60 t = *(struct ethervlan_header *)(s); \ 61 *(struct ethervlan_header *)(d) = t; \ 62 } while (0) 63 64 #endif 65