if_vlan_var.h (92081) | if_vlan_var.h (106932) |
---|---|
1/* 2 * Copyright 1998 Massachusetts Institute of Technology 3 * 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 --- 12 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 * | 1/* 2 * Copyright 1998 Massachusetts Institute of Technology 3 * 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 --- 12 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/net/if_vlan_var.h 92081 2002-03-11 09:26:07Z mux $ | 29 * $FreeBSD: head/sys/net/if_vlan_var.h 106932 2002-11-14 23:43:16Z sam $ |
30 */ 31 32#ifndef _NET_IF_VLAN_VAR_H_ 33#define _NET_IF_VLAN_VAR_H_ 1 34 | 30 */ 31 32#ifndef _NET_IF_VLAN_VAR_H_ 33#define _NET_IF_VLAN_VAR_H_ 1 34 |
35#ifdef _KERNEL 36struct vlan_mc_entry { 37 struct ether_addr mc_addr; 38 SLIST_ENTRY(vlan_mc_entry) mc_entries; 39}; 40 41struct ifvlan { 42 struct arpcom ifv_ac; /* make this an interface */ 43 struct ifnet *ifv_p; /* parent inteface of this vlan */ 44 struct ifv_linkmib { 45 int ifvm_parent; 46 u_int16_t ifvm_proto; /* encapsulation ethertype */ 47 u_int16_t ifvm_tag; /* tag to apply on packets leaving if */ 48 } ifv_mib; 49 SLIST_HEAD(__vlan_mchead, vlan_mc_entry) vlan_mc_listhead; 50 LIST_ENTRY(ifvlan) ifv_list; 51}; 52#define ifv_if ifv_ac.ac_if 53#define ifv_tag ifv_mib.ifvm_tag 54#endif /* _KERNEL */ 55 | |
56struct ether_vlan_header { 57 u_char evl_dhost[ETHER_ADDR_LEN]; 58 u_char evl_shost[ETHER_ADDR_LEN]; 59 u_int16_t evl_encap_proto; 60 u_int16_t evl_tag; 61 u_int16_t evl_proto; 62}; 63 64#define EVL_VLANOFTAG(tag) ((tag) & 4095) 65#define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7) | 35struct 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; 39 u_int16_t evl_tag; 40 u_int16_t evl_proto; 41}; 42 43#define EVL_VLANOFTAG(tag) ((tag) & 4095) 44#define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7) |
66#define EVL_ENCAPLEN 4 /* length in octets of encapsulation */ | |
67 68/* sysctl(3) tags, for compatibility purposes */ 69#define VLANCTL_PROTO 1 70#define VLANCTL_MAX 2 71 72/* 73 * Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls. 74 */ 75struct vlanreq { 76 char vlr_parent[IFNAMSIZ]; 77 u_short vlr_tag; 78}; 79#define SIOCSETVLAN SIOCSIFGENERIC 80#define SIOCGETVLAN SIOCGIFGENERIC 81 | 45 46/* sysctl(3) tags, for compatibility purposes */ 47#define VLANCTL_PROTO 1 48#define VLANCTL_MAX 2 49 50/* 51 * Configuration structure for SIOCSETVLAN and SIOCGETVLAN ioctls. 52 */ 53struct vlanreq { 54 char vlr_parent[IFNAMSIZ]; 55 u_short vlr_tag; 56}; 57#define SIOCSETVLAN SIOCSIFGENERIC 58#define SIOCGETVLAN SIOCGIFGENERIC 59 |
60#ifdef _KERNEL 61/* 62 * Drivers that are capable of adding and removing the VLAN header 63 * in hardware indicate they support this by marking IFCAP_VLAN_HWTAGGING 64 * in if_capabilities. Drivers for hardware that is also capable 65 * of handling larger MTU's that may include a software-appended 66 * VLAN header w/o lowering the normal MTU should mark IFCAP_VLA_MTU 67 * in if_capabilities; this notfies the VLAN code it can leave the 68 * MTU on the vlan interface at the normal setting. 69 */ 70 71/* 72 * Drivers that support hardware VLAN tagging pass a packet's tag 73 * up through the stack by appending a packet tag with this value. 74 * Output is handled likewise, the driver must locate the packet 75 * tag to extract the VLAN tag. The following macros are used to 76 * do this work. On input, do: 77 * 78 * VLAN_INPUT_TAG(ifp, m, tag,); 79 * 80 * to mark the packet m with the specified VLAN tag. The last 81 * parameter provides code to execute in case of an error. On 82 * output the driver should check ifnet to see if any VLANs are 83 * in use and only then check for a packet tag; this is done with: 84 * 85 * struct m_tag *mtag; 86 * mtag = VLAN_OUTPUT_TAG(ifp, m); 87 * if (mtag != NULL) { 88 * ... = VLAN_TAG_VALUE(mtag); 89 * ... pass tag to hardware ... 90 * } 91 * 92 * Note that a driver must indicate it supports hardware VLAN 93 * tagging by marking IFCAP_VLAN_HWTAGGING in if_capabilities. 94 */ 95#define MTAG_VLAN 1035328035 96#define MTAG_VLAN_TAG 0 /* tag of VLAN interface */ 97 98#define VLAN_INPUT_TAG(_ifp, _m, _t, _errcase) do { \ 99 struct m_tag *mtag; \ 100 mtag = m_tag_alloc(MTAG_VLAN, MTAG_VLAN_TAG, \ 101 sizeof (u_int), M_DONTWAIT); \ 102 if (mtag == NULL) { \ 103 (_ifp)->if_ierrors++; \ 104 m_freem(_m); \ 105 _errcase; \ 106 } \ 107 *(u_int *)(mtag+1) = (_t); \ 108 m_tag_prepend((_m), mtag); \ 109} while (0) 110 111#define VLAN_OUTPUT_TAG(_ifp, _m) \ 112 ((_ifp)->if_nvlans != 0 ? \ 113 m_tag_locate((_m), MTAG_VLAN, MTAG_VLAN_TAG, NULL) : NULL) 114#define VLAN_TAG_VALUE(_mt) (*(u_int *)((_mt)+1)) 115#endif /* _KERNEL */ 116 |
|
82#endif /* _NET_IF_VLAN_VAR_H_ */ | 117#endif /* _NET_IF_VLAN_VAR_H_ */ |