2 * Copyright 1998 Massachusetts Institute of Technology
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose and without fee is hereby
6 * granted, provided that both the above copyright notice and this
7 * permission notice appear in all copies, that both the above
8 * copyright notice and this permission notice appear in all
9 * supporting documentation, and that the name of M.I.T. not be used
10 * in advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission. M.I.T. makes
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied
16 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
17 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #ifndef _NET_IF_VLAN_VAR_H_
33 #define _NET_IF_VLAN_VAR_H_ 1
35 struct ether_vlan_header {
36 u_char evl_dhost[ETHER_ADDR_LEN];
37 u_char evl_shost[ETHER_ADDR_LEN];
38 u_int16_t evl_encap_proto;
43 #define EVL_VLID_MASK 0x0FFF
44 #define EVL_VLANOFTAG(tag) ((tag) & EVL_VLID_MASK)
45 #define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7)
47 /* sysctl(3) tags, for compatibility purposes */
48 #define VLANCTL_PROTO 1
52 * Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls.
55 char vlr_parent[IFNAMSIZ];
58 #define SIOCSETVLAN SIOCSIFGENERIC
59 #define SIOCGETVLAN SIOCGIFGENERIC
63 * Drivers that are capable of adding and removing the VLAN header
64 * in hardware indicate they support this by marking IFCAP_VLAN_HWTAGGING
65 * in if_capabilities. Drivers for hardware that is capable
66 * of handling larger MTU's that may include a software-appended
67 * VLAN header w/o lowering the normal MTU should mark IFCAP_VLAN_MTU
68 * in if_capabilities; this notifies the VLAN code it can leave the
69 * MTU on the vlan interface at the normal setting.
73 * VLAN tags are stored in host byte order. Byte swapping may be
76 * Drivers that support hardware VLAN tag stripping fill in the
77 * received VLAN tag (containing both vlan and priority information)
78 * into the ether_vtag mbuf packet header field:
80 * m->m_pkthdr.ether_vtag = vlan_id; // ntohs()?
81 * m->m_flags |= M_VLANTAG;
83 * to mark the packet m with the specified VLAN tag.
85 * On output the driver should check the mbuf for the M_VLANTAG
86 * flag to see if a VLAN tag is present and valid:
88 * if (m->m_flags & M_VLANTAG) {
89 * ... = m->m_pkthdr.ether_vtag; // htons()?
90 * ... pass tag to hardware ...
93 * Note that a driver must indicate it supports hardware VLAN
94 * stripping/insertion by marking IFCAP_VLAN_HWTAGGING in
98 #define VLAN_CAPABILITIES(_ifp) do { \
99 if ((_ifp)->if_vlantrunk != NULL) \
100 (*vlan_trunk_cap_p)(_ifp); \
103 extern void (*vlan_trunk_cap_p)(struct ifnet *);
106 #endif /* _NET_IF_VLAN_VAR_H_ */