Back to home page

OSCL-LXR

 
 

    


0001 #ifndef __NET_TUN_PROTO_H
0002 #define __NET_TUN_PROTO_H
0003 
0004 #include <linux/if_ether.h>
0005 #include <linux/types.h>
0006 
0007 /* One byte protocol values as defined by VXLAN-GPE and NSH. These will
0008  * hopefully get a shared IANA registry.
0009  */
0010 #define TUN_P_IPV4      0x01
0011 #define TUN_P_IPV6      0x02
0012 #define TUN_P_ETHERNET  0x03
0013 #define TUN_P_NSH       0x04
0014 #define TUN_P_MPLS_UC   0x05
0015 
0016 static inline __be16 tun_p_to_eth_p(u8 proto)
0017 {
0018     switch (proto) {
0019     case TUN_P_IPV4:
0020         return htons(ETH_P_IP);
0021     case TUN_P_IPV6:
0022         return htons(ETH_P_IPV6);
0023     case TUN_P_ETHERNET:
0024         return htons(ETH_P_TEB);
0025     case TUN_P_NSH:
0026         return htons(ETH_P_NSH);
0027     case TUN_P_MPLS_UC:
0028         return htons(ETH_P_MPLS_UC);
0029     }
0030     return 0;
0031 }
0032 
0033 static inline u8 tun_p_from_eth_p(__be16 proto)
0034 {
0035     switch (proto) {
0036     case htons(ETH_P_IP):
0037         return TUN_P_IPV4;
0038     case htons(ETH_P_IPV6):
0039         return TUN_P_IPV6;
0040     case htons(ETH_P_TEB):
0041         return TUN_P_ETHERNET;
0042     case htons(ETH_P_NSH):
0043         return TUN_P_NSH;
0044     case htons(ETH_P_MPLS_UC):
0045         return TUN_P_MPLS_UC;
0046     }
0047     return 0;
0048 }
0049 
0050 #endif