1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_IF_TUNNEL_H_
3 #define _UAPI_IF_TUNNEL_H_
4 
5 #include <linux/types.h>
6 #include <linux/if.h>
7 #include <linux/ip.h>
8 #include <linux/in6.h>
9 #include <asm/byteorder.h>
10 
11 
12 #define SIOCGETTUNNEL   (SIOCDEVPRIVATE + 0)
13 #define SIOCADDTUNNEL   (SIOCDEVPRIVATE + 1)
14 #define SIOCDELTUNNEL   (SIOCDEVPRIVATE + 2)
15 #define SIOCCHGTUNNEL   (SIOCDEVPRIVATE + 3)
16 #define SIOCGETPRL      (SIOCDEVPRIVATE + 4)
17 #define SIOCADDPRL      (SIOCDEVPRIVATE + 5)
18 #define SIOCDELPRL      (SIOCDEVPRIVATE + 6)
19 #define SIOCCHGPRL      (SIOCDEVPRIVATE + 7)
20 #define SIOCGET6RD      (SIOCDEVPRIVATE + 8)
21 #define SIOCADD6RD      (SIOCDEVPRIVATE + 9)
22 #define SIOCDEL6RD      (SIOCDEVPRIVATE + 10)
23 #define SIOCCHG6RD      (SIOCDEVPRIVATE + 11)
24 
25 #define GRE_CSUM	__cpu_to_be16(0x8000)
26 #define GRE_ROUTING	__cpu_to_be16(0x4000)
27 #define GRE_KEY		__cpu_to_be16(0x2000)
28 #define GRE_SEQ		__cpu_to_be16(0x1000)
29 #define GRE_STRICT	__cpu_to_be16(0x0800)
30 #define GRE_REC		__cpu_to_be16(0x0700)
31 #define GRE_ACK		__cpu_to_be16(0x0080)
32 #define GRE_FLAGS	__cpu_to_be16(0x0078)
33 #define GRE_VERSION	__cpu_to_be16(0x0007)
34 
35 #define GRE_IS_CSUM(f)		((f) & GRE_CSUM)
36 #define GRE_IS_ROUTING(f)	((f) & GRE_ROUTING)
37 #define GRE_IS_KEY(f)		((f) & GRE_KEY)
38 #define GRE_IS_SEQ(f)		((f) & GRE_SEQ)
39 #define GRE_IS_STRICT(f)	((f) & GRE_STRICT)
40 #define GRE_IS_REC(f)		((f) & GRE_REC)
41 #define GRE_IS_ACK(f)		((f) & GRE_ACK)
42 
43 #define GRE_VERSION_0		__cpu_to_be16(0x0000)
44 #define GRE_VERSION_1		__cpu_to_be16(0x0001)
45 #define GRE_PROTO_PPP		__cpu_to_be16(0x880b)
46 #define GRE_PPTP_KEY_MASK	__cpu_to_be32(0xffff)
47 
48 struct ip_tunnel_parm {
49 	char			name[IFNAMSIZ];
50 	int			link;
51 	__be16			i_flags;
52 	__be16			o_flags;
53 	__be32			i_key;
54 	__be32			o_key;
55 	struct iphdr		iph;
56 };
57 
58 enum {
59 	IFLA_IPTUN_UNSPEC,
60 	IFLA_IPTUN_LINK,
61 	IFLA_IPTUN_LOCAL,
62 	IFLA_IPTUN_REMOTE,
63 	IFLA_IPTUN_TTL,
64 	IFLA_IPTUN_TOS,
65 	IFLA_IPTUN_ENCAP_LIMIT,
66 	IFLA_IPTUN_FLOWINFO,
67 	IFLA_IPTUN_FLAGS,
68 	IFLA_IPTUN_PROTO,
69 	IFLA_IPTUN_PMTUDISC,
70 	IFLA_IPTUN_6RD_PREFIX,
71 	IFLA_IPTUN_6RD_RELAY_PREFIX,
72 	IFLA_IPTUN_6RD_PREFIXLEN,
73 	IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
74 	IFLA_IPTUN_ENCAP_TYPE,
75 	IFLA_IPTUN_ENCAP_FLAGS,
76 	IFLA_IPTUN_ENCAP_SPORT,
77 	IFLA_IPTUN_ENCAP_DPORT,
78 	IFLA_IPTUN_COLLECT_METADATA,
79 	IFLA_IPTUN_FWMARK,
80 	__IFLA_IPTUN_MAX,
81 };
82 #define IFLA_IPTUN_MAX	(__IFLA_IPTUN_MAX - 1)
83 
84 enum tunnel_encap_types {
85 	TUNNEL_ENCAP_NONE,
86 	TUNNEL_ENCAP_FOU,
87 	TUNNEL_ENCAP_GUE,
88 	TUNNEL_ENCAP_MPLS,
89 };
90 
91 #define TUNNEL_ENCAP_FLAG_CSUM		(1<<0)
92 #define TUNNEL_ENCAP_FLAG_CSUM6		(1<<1)
93 #define TUNNEL_ENCAP_FLAG_REMCSUM	(1<<2)
94 
95 /* SIT-mode i_flags */
96 #define	SIT_ISATAP	0x0001
97 
98 struct ip_tunnel_prl {
99 	__be32			addr;
100 	__u16			flags;
101 	__u16			__reserved;
102 	__u32			datalen;
103 	__u32			__reserved2;
104 	/* data follows */
105 };
106 
107 /* PRL flags */
108 #define	PRL_DEFAULT		0x0001
109 
110 struct ip_tunnel_6rd {
111 	struct in6_addr		prefix;
112 	__be32			relay_prefix;
113 	__u16			prefixlen;
114 	__u16			relay_prefixlen;
115 };
116 
117 enum {
118 	IFLA_GRE_UNSPEC,
119 	IFLA_GRE_LINK,
120 	IFLA_GRE_IFLAGS,
121 	IFLA_GRE_OFLAGS,
122 	IFLA_GRE_IKEY,
123 	IFLA_GRE_OKEY,
124 	IFLA_GRE_LOCAL,
125 	IFLA_GRE_REMOTE,
126 	IFLA_GRE_TTL,
127 	IFLA_GRE_TOS,
128 	IFLA_GRE_PMTUDISC,
129 	IFLA_GRE_ENCAP_LIMIT,
130 	IFLA_GRE_FLOWINFO,
131 	IFLA_GRE_FLAGS,
132 	IFLA_GRE_ENCAP_TYPE,
133 	IFLA_GRE_ENCAP_FLAGS,
134 	IFLA_GRE_ENCAP_SPORT,
135 	IFLA_GRE_ENCAP_DPORT,
136 	IFLA_GRE_COLLECT_METADATA,
137 	IFLA_GRE_IGNORE_DF,
138 	IFLA_GRE_FWMARK,
139 	IFLA_GRE_ERSPAN_INDEX,
140 	IFLA_GRE_ERSPAN_VER,
141 	IFLA_GRE_ERSPAN_DIR,
142 	IFLA_GRE_ERSPAN_HWID,
143 	__IFLA_GRE_MAX,
144 };
145 
146 #define IFLA_GRE_MAX	(__IFLA_GRE_MAX - 1)
147 
148 /* VTI-mode i_flags */
149 #define VTI_ISVTI ((__force __be16)0x0001)
150 
151 enum {
152 	IFLA_VTI_UNSPEC,
153 	IFLA_VTI_LINK,
154 	IFLA_VTI_IKEY,
155 	IFLA_VTI_OKEY,
156 	IFLA_VTI_LOCAL,
157 	IFLA_VTI_REMOTE,
158 	IFLA_VTI_FWMARK,
159 	__IFLA_VTI_MAX,
160 };
161 
162 #define IFLA_VTI_MAX	(__IFLA_VTI_MAX - 1)
163 
164 #define TUNNEL_CSUM		__cpu_to_be16(0x01)
165 #define TUNNEL_ROUTING		__cpu_to_be16(0x02)
166 #define TUNNEL_KEY		__cpu_to_be16(0x04)
167 #define TUNNEL_SEQ		__cpu_to_be16(0x08)
168 #define TUNNEL_STRICT		__cpu_to_be16(0x10)
169 #define TUNNEL_REC		__cpu_to_be16(0x20)
170 #define TUNNEL_VERSION		__cpu_to_be16(0x40)
171 #define TUNNEL_NO_KEY		__cpu_to_be16(0x80)
172 #define TUNNEL_DONT_FRAGMENT    __cpu_to_be16(0x0100)
173 #define TUNNEL_OAM		__cpu_to_be16(0x0200)
174 #define TUNNEL_CRIT_OPT		__cpu_to_be16(0x0400)
175 #define TUNNEL_GENEVE_OPT	__cpu_to_be16(0x0800)
176 #define TUNNEL_VXLAN_OPT	__cpu_to_be16(0x1000)
177 #define TUNNEL_NOCACHE		__cpu_to_be16(0x2000)
178 #define TUNNEL_ERSPAN_OPT	__cpu_to_be16(0x4000)
179 #define TUNNEL_GTP_OPT		__cpu_to_be16(0x8000)
180 
181 #define TUNNEL_OPTIONS_PRESENT \
182 		(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT | \
183 		TUNNEL_GTP_OPT)
184 
185 #endif /* _UAPI_IF_TUNNEL_H_ */
186