11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * VLAN An implementation of 802.1Q VLAN tagging. 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Authors: Ben Greear <greearb@candelatech.com> 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 71da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License 81da177e4SLinus Torvalds * as published by the Free Software Foundation; either version 91da177e4SLinus Torvalds * 2 of the License, or (at your option) any later version. 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds */ 121da177e4SLinus Torvalds 131da177e4SLinus Torvalds #ifndef _LINUX_IF_VLAN_H_ 141da177e4SLinus Torvalds #define _LINUX_IF_VLAN_H_ 151da177e4SLinus Torvalds 161da177e4SLinus Torvalds #ifdef __KERNEL__ 171da177e4SLinus Torvalds #include <linux/netdevice.h> 180610d11bSStephen Hemminger #include <linux/etherdevice.h> 1965ac6a5fSJesse Gross #include <linux/rtnetlink.h> 20187f1882SPaul Gortmaker #include <linux/bug.h> 211da177e4SLinus Torvalds 22a3f671b3SJoe Perches #define VLAN_HLEN 4 /* The additional bytes required by VLAN 23a3f671b3SJoe Perches * (in addition to the Ethernet header) 241da177e4SLinus Torvalds */ 251da177e4SLinus Torvalds #define VLAN_ETH_HLEN 18 /* Total octets in header. */ 261da177e4SLinus Torvalds #define VLAN_ETH_ZLEN 64 /* Min. octets in frame sans FCS */ 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds /* 291da177e4SLinus Torvalds * According to 802.3ac, the packet can be 4 bytes longer. --Klika Jan 301da177e4SLinus Torvalds */ 311da177e4SLinus Torvalds #define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */ 321da177e4SLinus Torvalds #define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */ 331da177e4SLinus Torvalds 34740c15d0SPatrick McHardy /* 35740c15d0SPatrick McHardy * struct vlan_hdr - vlan header 36740c15d0SPatrick McHardy * @h_vlan_TCI: priority and VLAN ID 37740c15d0SPatrick McHardy * @h_vlan_encapsulated_proto: packet type ID or len 38740c15d0SPatrick McHardy */ 39740c15d0SPatrick McHardy struct vlan_hdr { 40740c15d0SPatrick McHardy __be16 h_vlan_TCI; 41740c15d0SPatrick McHardy __be16 h_vlan_encapsulated_proto; 42740c15d0SPatrick McHardy }; 43740c15d0SPatrick McHardy 44740c15d0SPatrick McHardy /** 45740c15d0SPatrick McHardy * struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr) 46740c15d0SPatrick McHardy * @h_dest: destination ethernet address 47740c15d0SPatrick McHardy * @h_source: source ethernet address 48740c15d0SPatrick McHardy * @h_vlan_proto: ethernet protocol (always 0x8100) 49740c15d0SPatrick McHardy * @h_vlan_TCI: priority and VLAN ID 50740c15d0SPatrick McHardy * @h_vlan_encapsulated_proto: packet type ID or len 51740c15d0SPatrick McHardy */ 521da177e4SLinus Torvalds struct vlan_ethhdr { 53740c15d0SPatrick McHardy unsigned char h_dest[ETH_ALEN]; 54740c15d0SPatrick McHardy unsigned char h_source[ETH_ALEN]; 55740c15d0SPatrick McHardy __be16 h_vlan_proto; 56740c15d0SPatrick McHardy __be16 h_vlan_TCI; 57740c15d0SPatrick McHardy __be16 h_vlan_encapsulated_proto; 581da177e4SLinus Torvalds }; 591da177e4SLinus Torvalds 601da177e4SLinus Torvalds #include <linux/skbuff.h> 611da177e4SLinus Torvalds 621da177e4SLinus Torvalds static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb) 631da177e4SLinus Torvalds { 6498e399f8SArnaldo Carvalho de Melo return (struct vlan_ethhdr *)skb_mac_header(skb); 651da177e4SLinus Torvalds } 661da177e4SLinus Torvalds 6705423b24SEric Dumazet #define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */ 6805423b24SEric Dumazet #define VLAN_PRIO_SHIFT 13 6905423b24SEric Dumazet #define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator */ 7005423b24SEric Dumazet #define VLAN_TAG_PRESENT VLAN_CFI_MASK 7105423b24SEric Dumazet #define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ 72b738127dSJesse Gross #define VLAN_N_VID 4096 731da177e4SLinus Torvalds 741da177e4SLinus Torvalds /* found in socket.c */ 75881d966bSEric W. Biederman extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); 761da177e4SLinus Torvalds 776dcbbe25SNeil Horman static inline int is_vlan_dev(struct net_device *dev) 786dcbbe25SNeil Horman { 796dcbbe25SNeil Horman return dev->priv_flags & IFF_802_1Q_VLAN; 806dcbbe25SNeil Horman } 816dcbbe25SNeil Horman 8205423b24SEric Dumazet #define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT) 8305423b24SEric Dumazet #define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT) 841da177e4SLinus Torvalds 857750f403SPatrick McHardy #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 8665ac6a5fSJesse Gross 87cec9c133SJiri Pirko extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev, 88cec9c133SJiri Pirko u16 vlan_id); 8922d1ba74SPatrick McHardy extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); 9022d1ba74SPatrick McHardy extern u16 vlan_dev_vlan_id(const struct net_device *dev); 9122d1ba74SPatrick McHardy 926a32e4f9SEric Dumazet extern bool vlan_do_receive(struct sk_buff **skb, bool last_handler); 93bcc6d479SJiri Pirko extern struct sk_buff *vlan_untag(struct sk_buff *skb); 949b22ea56SPatrick McHardy 9587002b03SJiri Pirko extern int vlan_vid_add(struct net_device *dev, unsigned short vid); 9687002b03SJiri Pirko extern void vlan_vid_del(struct net_device *dev, unsigned short vid); 9787002b03SJiri Pirko 98348a1443SJiri Pirko extern int vlan_vids_add_by_dev(struct net_device *dev, 99348a1443SJiri Pirko const struct net_device *by_dev); 100348a1443SJiri Pirko extern void vlan_vids_del_by_dev(struct net_device *dev, 101348a1443SJiri Pirko const struct net_device *by_dev); 102*9b361c13SJiri Pirko 103*9b361c13SJiri Pirko extern bool vlan_uses_dev(const struct net_device *dev); 1047750f403SPatrick McHardy #else 105cec9c133SJiri Pirko static inline struct net_device * 106cec9c133SJiri Pirko __vlan_find_dev_deep(struct net_device *real_dev, u16 vlan_id) 107cec9c133SJiri Pirko { 108cec9c133SJiri Pirko return NULL; 109cec9c133SJiri Pirko } 110cec9c133SJiri Pirko 11122d1ba74SPatrick McHardy static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev) 11222d1ba74SPatrick McHardy { 11322d1ba74SPatrick McHardy BUG(); 11422d1ba74SPatrick McHardy return NULL; 11522d1ba74SPatrick McHardy } 11622d1ba74SPatrick McHardy 11722d1ba74SPatrick McHardy static inline u16 vlan_dev_vlan_id(const struct net_device *dev) 11822d1ba74SPatrick McHardy { 11922d1ba74SPatrick McHardy BUG(); 12022d1ba74SPatrick McHardy return 0; 12122d1ba74SPatrick McHardy } 12222d1ba74SPatrick McHardy 1236a32e4f9SEric Dumazet static inline bool vlan_do_receive(struct sk_buff **skb, bool last_handler) 1249b22ea56SPatrick McHardy { 1256a32e4f9SEric Dumazet if (((*skb)->vlan_tci & VLAN_VID_MASK) && last_handler) 1260988c4c7SJesse Gross (*skb)->pkt_type = PACKET_OTHERHOST; 1273701e513SJesse Gross return false; 1289b22ea56SPatrick McHardy } 129e1c096e2SHerbert Xu 1306139e75fSDavid S. Miller static inline struct sk_buff *vlan_untag(struct sk_buff *skb) 131bcc6d479SJiri Pirko { 132bcc6d479SJiri Pirko return skb; 133bcc6d479SJiri Pirko } 13487002b03SJiri Pirko 13587002b03SJiri Pirko static inline int vlan_vid_add(struct net_device *dev, unsigned short vid) 13687002b03SJiri Pirko { 13787002b03SJiri Pirko return 0; 13887002b03SJiri Pirko } 13987002b03SJiri Pirko 14087002b03SJiri Pirko static inline void vlan_vid_del(struct net_device *dev, unsigned short vid) 14187002b03SJiri Pirko { 14287002b03SJiri Pirko } 143348a1443SJiri Pirko 144348a1443SJiri Pirko static inline int vlan_vids_add_by_dev(struct net_device *dev, 145348a1443SJiri Pirko const struct net_device *by_dev) 146348a1443SJiri Pirko { 147348a1443SJiri Pirko return 0; 148348a1443SJiri Pirko } 149348a1443SJiri Pirko 150348a1443SJiri Pirko static inline void vlan_vids_del_by_dev(struct net_device *dev, 151348a1443SJiri Pirko const struct net_device *by_dev) 152348a1443SJiri Pirko { 153348a1443SJiri Pirko } 154*9b361c13SJiri Pirko 155*9b361c13SJiri Pirko static inline bool vlan_uses_dev(const struct net_device *dev) 156*9b361c13SJiri Pirko { 157*9b361c13SJiri Pirko return false; 158*9b361c13SJiri Pirko } 1597750f403SPatrick McHardy #endif 1601da177e4SLinus Torvalds 1619bb8582eSPatrick McHardy /** 1620b5c9db1SJiri Pirko * vlan_insert_tag - regular VLAN tag inserting 1631da177e4SLinus Torvalds * @skb: skbuff to tag 1649bb8582eSPatrick McHardy * @vlan_tci: VLAN TCI to insert 1651da177e4SLinus Torvalds * 1661da177e4SLinus Torvalds * Inserts the VLAN tag into @skb as part of the payload 1671da177e4SLinus Torvalds * Returns a VLAN tagged skb. If a new skb is created, @skb is freed. 1681da177e4SLinus Torvalds * 1691da177e4SLinus Torvalds * Following the skb_unshare() example, in case of error, the calling function 1701da177e4SLinus Torvalds * doesn't have to worry about freeing the original skb. 1710b5c9db1SJiri Pirko * 1720b5c9db1SJiri Pirko * Does not change skb->protocol so this function can be used during receive. 1731da177e4SLinus Torvalds */ 1740b5c9db1SJiri Pirko static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci) 1751da177e4SLinus Torvalds { 1761da177e4SLinus Torvalds struct vlan_ethhdr *veth; 1771da177e4SLinus Torvalds 17811a100f8SPatrick McHardy if (skb_cow_head(skb, VLAN_HLEN) < 0) { 17911a100f8SPatrick McHardy kfree_skb(skb); 1801da177e4SLinus Torvalds return NULL; 1811da177e4SLinus Torvalds } 1821da177e4SLinus Torvalds veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN); 1831da177e4SLinus Torvalds 1841da177e4SLinus Torvalds /* Move the mac addresses to the beginning of the new header. */ 185a3f671b3SJoe Perches memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN); 186e4dd6188SJarek Poplawski skb->mac_header -= VLAN_HLEN; 1871da177e4SLinus Torvalds 1881da177e4SLinus Torvalds /* first, the ethernet type */ 18957d3ae84SPatrick McHardy veth->h_vlan_proto = htons(ETH_P_8021Q); 1901da177e4SLinus Torvalds 1919bb8582eSPatrick McHardy /* now, the TCI */ 1929bb8582eSPatrick McHardy veth->h_vlan_TCI = htons(vlan_tci); 1931da177e4SLinus Torvalds 1940b5c9db1SJiri Pirko return skb; 1950b5c9db1SJiri Pirko } 1961da177e4SLinus Torvalds 1970b5c9db1SJiri Pirko /** 1980b5c9db1SJiri Pirko * __vlan_put_tag - regular VLAN tag inserting 1990b5c9db1SJiri Pirko * @skb: skbuff to tag 2000b5c9db1SJiri Pirko * @vlan_tci: VLAN TCI to insert 2010b5c9db1SJiri Pirko * 2020b5c9db1SJiri Pirko * Inserts the VLAN tag into @skb as part of the payload 2030b5c9db1SJiri Pirko * Returns a VLAN tagged skb. If a new skb is created, @skb is freed. 2040b5c9db1SJiri Pirko * 2050b5c9db1SJiri Pirko * Following the skb_unshare() example, in case of error, the calling function 2060b5c9db1SJiri Pirko * doesn't have to worry about freeing the original skb. 2070b5c9db1SJiri Pirko */ 2080b5c9db1SJiri Pirko static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 2090b5c9db1SJiri Pirko { 2100b5c9db1SJiri Pirko skb = vlan_insert_tag(skb, vlan_tci); 2110b5c9db1SJiri Pirko if (skb) 2120b5c9db1SJiri Pirko skb->protocol = htons(ETH_P_8021Q); 2131da177e4SLinus Torvalds return skb; 2141da177e4SLinus Torvalds } 2151da177e4SLinus Torvalds 2161da177e4SLinus Torvalds /** 2171da177e4SLinus Torvalds * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting 2181da177e4SLinus Torvalds * @skb: skbuff to tag 2199bb8582eSPatrick McHardy * @vlan_tci: VLAN TCI to insert 2201da177e4SLinus Torvalds * 2216aa895b0SPatrick McHardy * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest 2221da177e4SLinus Torvalds */ 2239bb8582eSPatrick McHardy static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, 2249bb8582eSPatrick McHardy u16 vlan_tci) 2251da177e4SLinus Torvalds { 22605423b24SEric Dumazet skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci; 2271da177e4SLinus Torvalds return skb; 2281da177e4SLinus Torvalds } 2291da177e4SLinus Torvalds 2301da177e4SLinus Torvalds #define HAVE_VLAN_PUT_TAG 2311da177e4SLinus Torvalds 2321da177e4SLinus Torvalds /** 2331da177e4SLinus Torvalds * vlan_put_tag - inserts VLAN tag according to device features 2341da177e4SLinus Torvalds * @skb: skbuff to tag 2359bb8582eSPatrick McHardy * @vlan_tci: VLAN TCI to insert 2361da177e4SLinus Torvalds * 2371da177e4SLinus Torvalds * Assumes skb->dev is the target that will xmit this frame. 2381da177e4SLinus Torvalds * Returns a VLAN tagged skb. 2391da177e4SLinus Torvalds */ 2409bb8582eSPatrick McHardy static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 2411da177e4SLinus Torvalds { 2421da177e4SLinus Torvalds if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 2439bb8582eSPatrick McHardy return __vlan_hwaccel_put_tag(skb, vlan_tci); 2441da177e4SLinus Torvalds } else { 2459bb8582eSPatrick McHardy return __vlan_put_tag(skb, vlan_tci); 2461da177e4SLinus Torvalds } 2471da177e4SLinus Torvalds } 2481da177e4SLinus Torvalds 2491da177e4SLinus Torvalds /** 2501da177e4SLinus Torvalds * __vlan_get_tag - get the VLAN ID that is part of the payload 2511da177e4SLinus Torvalds * @skb: skbuff to query 2529bb8582eSPatrick McHardy * @vlan_tci: buffer to store vlaue 2531da177e4SLinus Torvalds * 2541da177e4SLinus Torvalds * Returns error if the skb is not of VLAN type 2551da177e4SLinus Torvalds */ 2569bb8582eSPatrick McHardy static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) 2571da177e4SLinus Torvalds { 2581da177e4SLinus Torvalds struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; 2591da177e4SLinus Torvalds 26057d3ae84SPatrick McHardy if (veth->h_vlan_proto != htons(ETH_P_8021Q)) { 2611da177e4SLinus Torvalds return -EINVAL; 2621da177e4SLinus Torvalds } 2631da177e4SLinus Torvalds 2649bb8582eSPatrick McHardy *vlan_tci = ntohs(veth->h_vlan_TCI); 2651da177e4SLinus Torvalds return 0; 2661da177e4SLinus Torvalds } 2671da177e4SLinus Torvalds 2681da177e4SLinus Torvalds /** 2691da177e4SLinus Torvalds * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[] 2701da177e4SLinus Torvalds * @skb: skbuff to query 2719bb8582eSPatrick McHardy * @vlan_tci: buffer to store vlaue 2721da177e4SLinus Torvalds * 2736aa895b0SPatrick McHardy * Returns error if @skb->vlan_tci is not set correctly 2741da177e4SLinus Torvalds */ 27518149935SPatrick McHardy static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, 2769bb8582eSPatrick McHardy u16 *vlan_tci) 2771da177e4SLinus Torvalds { 2786aa895b0SPatrick McHardy if (vlan_tx_tag_present(skb)) { 27905423b24SEric Dumazet *vlan_tci = vlan_tx_tag_get(skb); 2801da177e4SLinus Torvalds return 0; 2811da177e4SLinus Torvalds } else { 2829bb8582eSPatrick McHardy *vlan_tci = 0; 2831da177e4SLinus Torvalds return -EINVAL; 2841da177e4SLinus Torvalds } 2851da177e4SLinus Torvalds } 2861da177e4SLinus Torvalds 2871da177e4SLinus Torvalds #define HAVE_VLAN_GET_TAG 2881da177e4SLinus Torvalds 2891da177e4SLinus Torvalds /** 2901da177e4SLinus Torvalds * vlan_get_tag - get the VLAN ID from the skb 2911da177e4SLinus Torvalds * @skb: skbuff to query 2929bb8582eSPatrick McHardy * @vlan_tci: buffer to store vlaue 2931da177e4SLinus Torvalds * 2941da177e4SLinus Torvalds * Returns error if the skb is not VLAN tagged 2951da177e4SLinus Torvalds */ 2969bb8582eSPatrick McHardy static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) 2971da177e4SLinus Torvalds { 2981da177e4SLinus Torvalds if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 2999bb8582eSPatrick McHardy return __vlan_hwaccel_get_tag(skb, vlan_tci); 3001da177e4SLinus Torvalds } else { 3019bb8582eSPatrick McHardy return __vlan_get_tag(skb, vlan_tci); 3021da177e4SLinus Torvalds } 3031da177e4SLinus Torvalds } 3041da177e4SLinus Torvalds 3050a85df00SHao Zheng /** 3060a85df00SHao Zheng * vlan_get_protocol - get protocol EtherType. 3070a85df00SHao Zheng * @skb: skbuff to query 3080a85df00SHao Zheng * 3090a85df00SHao Zheng * Returns the EtherType of the packet, regardless of whether it is 3100a85df00SHao Zheng * vlan encapsulated (normal or hardware accelerated) or not. 3110a85df00SHao Zheng */ 3120a85df00SHao Zheng static inline __be16 vlan_get_protocol(const struct sk_buff *skb) 3130a85df00SHao Zheng { 3140a85df00SHao Zheng __be16 protocol = 0; 3150a85df00SHao Zheng 3160a85df00SHao Zheng if (vlan_tx_tag_present(skb) || 3170a85df00SHao Zheng skb->protocol != cpu_to_be16(ETH_P_8021Q)) 3180a85df00SHao Zheng protocol = skb->protocol; 3190a85df00SHao Zheng else { 3200a85df00SHao Zheng __be16 proto, *protop; 3210a85df00SHao Zheng protop = skb_header_pointer(skb, offsetof(struct vlan_ethhdr, 3220a85df00SHao Zheng h_vlan_encapsulated_proto), 3230a85df00SHao Zheng sizeof(proto), &proto); 3240a85df00SHao Zheng if (likely(protop)) 3250a85df00SHao Zheng protocol = *protop; 3260a85df00SHao Zheng } 3270a85df00SHao Zheng 3280a85df00SHao Zheng return protocol; 3290a85df00SHao Zheng } 330396cf943SPravin B Shelar 331396cf943SPravin B Shelar static inline void vlan_set_encap_proto(struct sk_buff *skb, 332396cf943SPravin B Shelar struct vlan_hdr *vhdr) 333396cf943SPravin B Shelar { 334396cf943SPravin B Shelar __be16 proto; 335396cf943SPravin B Shelar unsigned char *rawp; 336396cf943SPravin B Shelar 337396cf943SPravin B Shelar /* 338396cf943SPravin B Shelar * Was a VLAN packet, grab the encapsulated protocol, which the layer 339396cf943SPravin B Shelar * three protocols care about. 340396cf943SPravin B Shelar */ 341396cf943SPravin B Shelar 342396cf943SPravin B Shelar proto = vhdr->h_vlan_encapsulated_proto; 343396cf943SPravin B Shelar if (ntohs(proto) >= 1536) { 344396cf943SPravin B Shelar skb->protocol = proto; 345396cf943SPravin B Shelar return; 346396cf943SPravin B Shelar } 347396cf943SPravin B Shelar 348396cf943SPravin B Shelar rawp = skb->data; 349396cf943SPravin B Shelar if (*(unsigned short *) rawp == 0xFFFF) 350396cf943SPravin B Shelar /* 351396cf943SPravin B Shelar * This is a magic hack to spot IPX packets. Older Novell 352396cf943SPravin B Shelar * breaks the protocol design and runs IPX over 802.3 without 353396cf943SPravin B Shelar * an 802.2 LLC layer. We look for FFFF which isn't a used 354396cf943SPravin B Shelar * 802.2 SSAP/DSAP. This won't work for fault tolerant netware 355396cf943SPravin B Shelar * but does for the rest. 356396cf943SPravin B Shelar */ 357396cf943SPravin B Shelar skb->protocol = htons(ETH_P_802_3); 358396cf943SPravin B Shelar else 359396cf943SPravin B Shelar /* 360396cf943SPravin B Shelar * Real 802.2 LLC 361396cf943SPravin B Shelar */ 362396cf943SPravin B Shelar skb->protocol = htons(ETH_P_802_2); 363396cf943SPravin B Shelar } 3641da177e4SLinus Torvalds #endif /* __KERNEL__ */ 3651da177e4SLinus Torvalds 3661da177e4SLinus Torvalds /* VLAN IOCTLs are found in sockios.h */ 3671da177e4SLinus Torvalds 3681da177e4SLinus Torvalds /* Passed in vlan_ioctl_args structure to determine behaviour. */ 3691da177e4SLinus Torvalds enum vlan_ioctl_cmds { 3701da177e4SLinus Torvalds ADD_VLAN_CMD, 3711da177e4SLinus Torvalds DEL_VLAN_CMD, 3721da177e4SLinus Torvalds SET_VLAN_INGRESS_PRIORITY_CMD, 3731da177e4SLinus Torvalds SET_VLAN_EGRESS_PRIORITY_CMD, 3741da177e4SLinus Torvalds GET_VLAN_INGRESS_PRIORITY_CMD, 3751da177e4SLinus Torvalds GET_VLAN_EGRESS_PRIORITY_CMD, 3761da177e4SLinus Torvalds SET_VLAN_NAME_TYPE_CMD, 3771da177e4SLinus Torvalds SET_VLAN_FLAG_CMD, 3781da177e4SLinus Torvalds GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */ 3791da177e4SLinus Torvalds GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */ 3801da177e4SLinus Torvalds }; 3811da177e4SLinus Torvalds 382a4bf3af4SPatrick McHardy enum vlan_flags { 383a4bf3af4SPatrick McHardy VLAN_FLAG_REORDER_HDR = 0x1, 38470c03b49SPatrick McHardy VLAN_FLAG_GVRP = 0x2, 3855e756593SPatrick McHardy VLAN_FLAG_LOOSE_BINDING = 0x4, 386a4bf3af4SPatrick McHardy }; 387a4bf3af4SPatrick McHardy 3881da177e4SLinus Torvalds enum vlan_name_types { 3891da177e4SLinus Torvalds VLAN_NAME_TYPE_PLUS_VID, /* Name will look like: vlan0005 */ 3901da177e4SLinus Torvalds VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like: eth1.0005 */ 3911da177e4SLinus Torvalds VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Name will look like: vlan5 */ 3921da177e4SLinus Torvalds VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /* Name will look like: eth0.5 */ 3931da177e4SLinus Torvalds VLAN_NAME_TYPE_HIGHEST 3941da177e4SLinus Torvalds }; 3951da177e4SLinus Torvalds 3961da177e4SLinus Torvalds struct vlan_ioctl_args { 3971da177e4SLinus Torvalds int cmd; /* Should be one of the vlan_ioctl_cmds enum above. */ 3981da177e4SLinus Torvalds char device1[24]; 3991da177e4SLinus Torvalds 4001da177e4SLinus Torvalds union { 4011da177e4SLinus Torvalds char device2[24]; 4021da177e4SLinus Torvalds int VID; 4031da177e4SLinus Torvalds unsigned int skb_priority; 4041da177e4SLinus Torvalds unsigned int name_type; 4051da177e4SLinus Torvalds unsigned int bind_type; 4067da82c06SJiri Pirko unsigned int flag; /* Matches vlan_dev_priv flags */ 4071da177e4SLinus Torvalds } u; 4081da177e4SLinus Torvalds 4091da177e4SLinus Torvalds short vlan_qos; 4101da177e4SLinus Torvalds }; 4111da177e4SLinus Torvalds 4121da177e4SLinus Torvalds #endif /* !(_LINUX_IF_VLAN_H_) */ 413