xref: /xnu-11215.41.3/bsd/net/if_vlan_var.h (revision 33de042d024d46de5ff4e89f2471de6608e37fa4)
1 /*
2  * Copyright (c) 2003, 2024 Apple Computer, Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 /*
29  * Copyright 1998 Massachusetts Institute of Technology
30  *
31  * Permission to use, copy, modify, and distribute this software and
32  * its documentation for any purpose and without fee is hereby
33  * granted, provided that both the above copyright notice and this
34  * permission notice appear in all copies, that both the above
35  * copyright notice and this permission notice appear in all
36  * supporting documentation, and that the name of M.I.T. not be used
37  * in advertising or publicity pertaining to distribution of the
38  * software without specific, written prior permission.  M.I.T. makes
39  * no representations about the suitability of this software for any
40  * purpose.  It is provided "as is" without express or implied
41  * warranty.
42  *
43  * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
44  * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
45  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
46  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
47  * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
50  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54  * SUCH DAMAGE.
55  *
56  * $FreeBSD: src/sys/net/if_vlan_var.h,v 1.16 2003/07/08 21:54:20 wpaul Exp $
57  */
58 
59 #ifndef _NET_IF_VLAN_VAR_H_
60 #define _NET_IF_VLAN_VAR_H_     1
61 
62 #include <net/ethernet.h>
63 #include <net/if_var.h>
64 #include <sys/types.h>
65 
66 #define ETHER_VLAN_ENCAP_LEN    4       /* len of 802.1Q VLAN encapsulation */
67 
68 #ifdef KERNEL_PRIVATE
69 /* VLAN encapsulation header */
70 struct ether_vlan_encap_header {
71 	u_int16_t evle_tag;
72 	u_int16_t evle_proto;
73 };
74 #endif /* KERNEL_PRIVATE */
75 
76 struct  ether_vlan_header {
77 	u_char  evl_dhost[ETHER_ADDR_LEN];
78 	u_char  evl_shost[ETHER_ADDR_LEN];
79 	u_int16_t evl_encap_proto;
80 	u_int16_t evl_tag;
81 	u_int16_t evl_proto;
82 };
83 
84 #define EVL_VLID_MASK   0x0FFF
85 #define EVL_VLANOFTAG(tag) ((tag) & EVL_VLID_MASK)
86 #define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7)
87 
88 #if 0
89 /* sysctl(3) tags, for compatibility purposes */
90 #define VLANCTL_PROTO   1
91 #define VLANCTL_MAX     2
92 #endif
93 
94 /*
95  * Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls.
96  */
97 struct  vlanreq {
98 	char    vlr_parent[IFNAMSIZ];
99 	u_short vlr_tag;
100 };
101 
102 #ifdef KERNEL_PRIVATE
103 int vlan_family_init(void);
104 #endif /* KERNEL_PRIVATE */
105 #endif /* _NET_IF_VLAN_VAR_H_ */
106