1224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#ifndef _UAPI_IF_TUNNEL_H_
2224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define _UAPI_IF_TUNNEL_H_
3224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
4224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#include <linux/types.h>
56e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#include <linux/if.h>
66e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#include <linux/ip.h>
76e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#include <linux/in6.h>
8224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#include <asm/byteorder.h>
9224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
10224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
11224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCGETTUNNEL   (SIOCDEVPRIVATE + 0)
12224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCADDTUNNEL   (SIOCDEVPRIVATE + 1)
13224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCDELTUNNEL   (SIOCDEVPRIVATE + 2)
14224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCCHGTUNNEL   (SIOCDEVPRIVATE + 3)
15224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCGETPRL      (SIOCDEVPRIVATE + 4)
16224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCADDPRL      (SIOCDEVPRIVATE + 5)
17224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCDELPRL      (SIOCDEVPRIVATE + 6)
18224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCCHGPRL      (SIOCDEVPRIVATE + 7)
19224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCGET6RD      (SIOCDEVPRIVATE + 8)
20224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCADD6RD      (SIOCDEVPRIVATE + 9)
21224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCDEL6RD      (SIOCDEVPRIVATE + 10)
22224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define SIOCCHG6RD      (SIOCDEVPRIVATE + 11)
23224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
24224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define GRE_CSUM	__cpu_to_be16(0x8000)
25224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define GRE_ROUTING	__cpu_to_be16(0x4000)
26224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define GRE_KEY		__cpu_to_be16(0x2000)
27224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define GRE_SEQ		__cpu_to_be16(0x1000)
28224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define GRE_STRICT	__cpu_to_be16(0x0800)
29224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define GRE_REC		__cpu_to_be16(0x0700)
303318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_ACK		__cpu_to_be16(0x0080)
313318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_FLAGS	__cpu_to_be16(0x0078)
32224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define GRE_VERSION	__cpu_to_be16(0x0007)
33224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
343318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_IS_CSUM(f)		((f) & GRE_CSUM)
353318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_IS_ROUTING(f)	((f) & GRE_ROUTING)
363318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_IS_KEY(f)		((f) & GRE_KEY)
373318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_IS_SEQ(f)		((f) & GRE_SEQ)
383318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_IS_STRICT(f)	((f) & GRE_STRICT)
393318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_IS_REC(f)		((f) & GRE_REC)
403318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_IS_ACK(f)		((f) & GRE_ACK)
413318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris
423318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_VERSION_0		__cpu_to_be16(0x0000)
433318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_VERSION_1		__cpu_to_be16(0x0001)
443318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_PROTO_PPP		__cpu_to_be16(0x880b)
453318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris#define GRE_PPTP_KEY_MASK	__cpu_to_be32(0xffff)
463318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris
47224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct ip_tunnel_parm {
48224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	char			name[IFNAMSIZ];
49224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	int			link;
50224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__be16			i_flags;
51224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__be16			o_flags;
52224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__be32			i_key;
53224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__be32			o_key;
54224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	struct iphdr		iph;
55224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng};
56224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
57224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengenum {
58224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_UNSPEC,
59224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_LINK,
60224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_LOCAL,
61224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_REMOTE,
62224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_TTL,
63224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_TOS,
64224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_ENCAP_LIMIT,
65224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_FLOWINFO,
66224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_FLAGS,
67224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_PROTO,
68224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_PMTUDISC,
69224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_6RD_PREFIX,
70224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_6RD_RELAY_PREFIX,
71224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_6RD_PREFIXLEN,
72224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
737c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_IPTUN_ENCAP_TYPE,
747c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_IPTUN_ENCAP_FLAGS,
757c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_IPTUN_ENCAP_SPORT,
767c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_IPTUN_ENCAP_DPORT,
773318540b58f2d22ddaf211f3c8887785372e4e28Christopher Ferris	IFLA_IPTUN_COLLECT_METADATA,
78224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__IFLA_IPTUN_MAX,
79224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng};
80224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define IFLA_IPTUN_MAX	(__IFLA_IPTUN_MAX - 1)
81224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
827c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferrisenum tunnel_encap_types {
837c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	TUNNEL_ENCAP_NONE,
847c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	TUNNEL_ENCAP_FOU,
857c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	TUNNEL_ENCAP_GUE,
867c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris};
877c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris
887c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define TUNNEL_ENCAP_FLAG_CSUM		(1<<0)
897c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris#define TUNNEL_ENCAP_FLAG_CSUM6		(1<<1)
9012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define TUNNEL_ENCAP_FLAG_REMCSUM	(1<<2)
917c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris
92224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* SIT-mode i_flags */
93224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define	SIT_ISATAP	0x0001
94224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
95224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct ip_tunnel_prl {
96224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__be32			addr;
97224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__u16			flags;
98224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__u16			__reserved;
99224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__u32			datalen;
100224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__u32			__reserved2;
101224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	/* data follows */
102224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng};
103224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
104224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* PRL flags */
105224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define	PRL_DEFAULT		0x0001
106224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
107224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengstruct ip_tunnel_6rd {
108224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	struct in6_addr		prefix;
109224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__be32			relay_prefix;
110224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__u16			prefixlen;
111224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__u16			relay_prefixlen;
112224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng};
113224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
114224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengenum {
115224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_UNSPEC,
116224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_LINK,
117224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_IFLAGS,
118224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_OFLAGS,
119224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_IKEY,
120224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_OKEY,
121224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_LOCAL,
122224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_REMOTE,
123224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_TTL,
124224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_TOS,
125224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_PMTUDISC,
126224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_ENCAP_LIMIT,
127224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_FLOWINFO,
128224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_GRE_FLAGS,
1297c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_GRE_ENCAP_TYPE,
1307c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_GRE_ENCAP_FLAGS,
1317c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_GRE_ENCAP_SPORT,
1327c0b639731767acd9b3788628d81174c641fa6b9Christopher Ferris	IFLA_GRE_ENCAP_DPORT,
13312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	IFLA_GRE_COLLECT_METADATA,
1346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris	IFLA_GRE_IGNORE_DF,
135224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__IFLA_GRE_MAX,
136224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng};
137224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
138224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define IFLA_GRE_MAX	(__IFLA_GRE_MAX - 1)
139224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
140224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng/* VTI-mode i_flags */
141314752488cb92b9f86028836d0b8eabd8acb6a7cChristopher Ferris#define VTI_ISVTI ((__force __be16)0x0001)
142224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
143224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Chengenum {
144224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_VTI_UNSPEC,
145224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_VTI_LINK,
146224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_VTI_IKEY,
147224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_VTI_OKEY,
148224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_VTI_LOCAL,
149224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	IFLA_VTI_REMOTE,
150224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng	__IFLA_VTI_MAX,
151224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng};
152224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng
153224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#define IFLA_VTI_MAX	(__IFLA_VTI_MAX - 1)
154224b54f69543a5c0ec18f99bd717d2b724582eb6Ben Cheng#endif /* _UAPI_IF_TUNNEL_H_ */
155