xref: /freebsd/sys/net/if_vlan_var.h (revision 2cc2df490e841a1bb427efd6d6bd35109f7326c4)
12cc2df49SGarrett Wollman /*
22cc2df49SGarrett Wollman  * Copyright 1998 Massachusetts Institute of Technology
32cc2df49SGarrett Wollman  *
42cc2df49SGarrett Wollman  * Permission to use, copy, modify, and distribute this software and
52cc2df49SGarrett Wollman  * its documentation for any purpose and without fee is hereby
62cc2df49SGarrett Wollman  * granted, provided that both the above copyright notice and this
72cc2df49SGarrett Wollman  * permission notice appear in all copies, that both the above
82cc2df49SGarrett Wollman  * copyright notice and this permission notice appear in all
92cc2df49SGarrett Wollman  * supporting documentation, and that the name of M.I.T. not be used
102cc2df49SGarrett Wollman  * in advertising or publicity pertaining to distribution of the
112cc2df49SGarrett Wollman  * software without specific, written prior permission.  M.I.T. makes
122cc2df49SGarrett Wollman  * no representations about the suitability of this software for any
132cc2df49SGarrett Wollman  * purpose.  It is provided "as is" without express or implied
142cc2df49SGarrett Wollman  * warranty.
152cc2df49SGarrett Wollman  *
162cc2df49SGarrett Wollman  * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
172cc2df49SGarrett Wollman  * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
182cc2df49SGarrett Wollman  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
192cc2df49SGarrett Wollman  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
202cc2df49SGarrett Wollman  * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212cc2df49SGarrett Wollman  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222cc2df49SGarrett Wollman  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
232cc2df49SGarrett Wollman  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
242cc2df49SGarrett Wollman  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
252cc2df49SGarrett Wollman  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
262cc2df49SGarrett Wollman  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
272cc2df49SGarrett Wollman  * SUCH DAMAGE.
282cc2df49SGarrett Wollman  *
292cc2df49SGarrett Wollman  *	$Id$
302cc2df49SGarrett Wollman  */
312cc2df49SGarrett Wollman 
322cc2df49SGarrett Wollman #ifndef _NET_IF_VLAN_VAR_H_
332cc2df49SGarrett Wollman #define	_NET_IF_VLAN_VAR_H_	1
342cc2df49SGarrett Wollman 
352cc2df49SGarrett Wollman #ifdef KERNEL
362cc2df49SGarrett Wollman struct	ifvlan {
372cc2df49SGarrett Wollman 	struct	arpcom ifv_ac;	/* make this an interface */
382cc2df49SGarrett Wollman 	struct	ifnet *ifv_p;	/* parent inteface of this vlan */
392cc2df49SGarrett Wollman 	struct	ifv_linkmib {
402cc2df49SGarrett Wollman 		int	ifvm_parent;
412cc2df49SGarrett Wollman 		u_int16_t ifvm_proto; /* encapsulation ethertype */
422cc2df49SGarrett Wollman 		u_int16_t ifvm_tag; /* tag to apply on packets leaving if */
432cc2df49SGarrett Wollman 	}	ifv_mib;
442cc2df49SGarrett Wollman };
452cc2df49SGarrett Wollman #define	ifv_if	ifv_ac.ac_if
462cc2df49SGarrett Wollman #define	ifv_tag	ifv_mib.ifvm_tag
472cc2df49SGarrett Wollman #endif /* KERNEL */
482cc2df49SGarrett Wollman 
492cc2df49SGarrett Wollman struct	ether_vlan_header {
502cc2df49SGarrett Wollman 	u_char	evl_dhost[ETHER_ADDR_LEN];
512cc2df49SGarrett Wollman 	u_char	evl_shost[ETHER_ADDR_LEN];
522cc2df49SGarrett Wollman 	u_int16_t evl_encap_proto;
532cc2df49SGarrett Wollman 	u_int16_t evl_tag;
542cc2df49SGarrett Wollman 	u_int16_t evl_proto;
552cc2df49SGarrett Wollman };
562cc2df49SGarrett Wollman 
572cc2df49SGarrett Wollman #define	EVL_VLANOFTAG(tag) ((tag) & 4095)
582cc2df49SGarrett Wollman #define	EVL_PRIOFTAG(tag) (((tag) >> 13) & 7)
592cc2df49SGarrett Wollman #define	EVL_ENCAPLEN	4	/* length in octets of encapsulation */
602cc2df49SGarrett Wollman 
612cc2df49SGarrett Wollman /* When these sorts of interfaces get their own identifier... */
622cc2df49SGarrett Wollman #define	IFT_8021_VLAN	IFT_PROPVIRTUAL
632cc2df49SGarrett Wollman 
642cc2df49SGarrett Wollman /* sysctl(3) tags, for compatibility purposes */
652cc2df49SGarrett Wollman #define	VLANCTL_PROTO	1
662cc2df49SGarrett Wollman #define	VLANCTL_MAX	2
672cc2df49SGarrett Wollman 
682cc2df49SGarrett Wollman /*
692cc2df49SGarrett Wollman  * Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls.
702cc2df49SGarrett Wollman  */
712cc2df49SGarrett Wollman struct	vlanreq {
722cc2df49SGarrett Wollman 	char	vlr_parent[IFNAMSIZ];
732cc2df49SGarrett Wollman 	u_short	vlr_tag;
742cc2df49SGarrett Wollman };
752cc2df49SGarrett Wollman #define	SIOCSETVLAN	SIOCSIFGENERIC
762cc2df49SGarrett Wollman #define	SIOCGETVLAN	SIOCGIFGENERIC
772cc2df49SGarrett Wollman 
782cc2df49SGarrett Wollman #ifdef KERNEL
792cc2df49SGarrett Wollman /* shared with if_ethersubr.c: */
802cc2df49SGarrett Wollman extern	u_int vlan_proto;
812cc2df49SGarrett Wollman extern	int vlan_input(struct ether_header *eh, struct mbuf *m);
822cc2df49SGarrett Wollman #endif
832cc2df49SGarrett Wollman 
842cc2df49SGarrett Wollman #endif /* _NET_IF_VLAN_VAR_H_ */
85