xref: /linux/include/uapi/linux/xfrm.h (revision 4e484b3e969b52effd95c17f7a86f39208b2ccf4)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells #ifndef _LINUX_XFRM_H
3607ca46eSDavid Howells #define _LINUX_XFRM_H
4607ca46eSDavid Howells 
515e318bdSJiri Benc #include <linux/in6.h>
6607ca46eSDavid Howells #include <linux/types.h>
7607ca46eSDavid Howells 
8607ca46eSDavid Howells /* All of the structures in this file may not change size as they are
9607ca46eSDavid Howells  * passed into the kernel from userspace via netlink sockets.
10607ca46eSDavid Howells  */
11607ca46eSDavid Howells 
12607ca46eSDavid Howells /* Structure to encapsulate addresses. I do not want to use
13607ca46eSDavid Howells  * "standard" structure. My apologies.
14607ca46eSDavid Howells  */
15607ca46eSDavid Howells typedef union {
16607ca46eSDavid Howells 	__be32		a4;
17607ca46eSDavid Howells 	__be32		a6[4];
1815e318bdSJiri Benc 	struct in6_addr	in6;
19607ca46eSDavid Howells } xfrm_address_t;
20607ca46eSDavid Howells 
21607ca46eSDavid Howells /* Ident of a specific xfrm_state. It is used on input to lookup
22607ca46eSDavid Howells  * the state by (spi,daddr,ah/esp) or to store information about
23607ca46eSDavid Howells  * spi, protocol and tunnel address on output.
24607ca46eSDavid Howells  */
25607ca46eSDavid Howells struct xfrm_id {
26607ca46eSDavid Howells 	xfrm_address_t	daddr;
27607ca46eSDavid Howells 	__be32		spi;
28607ca46eSDavid Howells 	__u8		proto;
29607ca46eSDavid Howells };
30607ca46eSDavid Howells 
31607ca46eSDavid Howells struct xfrm_sec_ctx {
32607ca46eSDavid Howells 	__u8	ctx_doi;
33607ca46eSDavid Howells 	__u8	ctx_alg;
34607ca46eSDavid Howells 	__u16	ctx_len;
35607ca46eSDavid Howells 	__u32	ctx_sid;
36607ca46eSDavid Howells 	char	ctx_str[0];
37607ca46eSDavid Howells };
38607ca46eSDavid Howells 
39607ca46eSDavid Howells /* Security Context Domains of Interpretation */
40607ca46eSDavid Howells #define XFRM_SC_DOI_RESERVED 0
41607ca46eSDavid Howells #define XFRM_SC_DOI_LSM 1
42607ca46eSDavid Howells 
43607ca46eSDavid Howells /* Security Context Algorithms */
44607ca46eSDavid Howells #define XFRM_SC_ALG_RESERVED 0
45607ca46eSDavid Howells #define XFRM_SC_ALG_SELINUX 1
46607ca46eSDavid Howells 
47607ca46eSDavid Howells /* Selector, used as selector both on policy rules (SPD) and SAs. */
48607ca46eSDavid Howells 
49607ca46eSDavid Howells struct xfrm_selector {
50607ca46eSDavid Howells 	xfrm_address_t	daddr;
51607ca46eSDavid Howells 	xfrm_address_t	saddr;
52607ca46eSDavid Howells 	__be16	dport;
53607ca46eSDavid Howells 	__be16	dport_mask;
54607ca46eSDavid Howells 	__be16	sport;
55607ca46eSDavid Howells 	__be16	sport_mask;
56607ca46eSDavid Howells 	__u16	family;
57607ca46eSDavid Howells 	__u8	prefixlen_d;
58607ca46eSDavid Howells 	__u8	prefixlen_s;
59607ca46eSDavid Howells 	__u8	proto;
60607ca46eSDavid Howells 	int	ifindex;
61607ca46eSDavid Howells 	__kernel_uid32_t	user;
62607ca46eSDavid Howells };
63607ca46eSDavid Howells 
64607ca46eSDavid Howells #define XFRM_INF (~(__u64)0)
65607ca46eSDavid Howells 
66607ca46eSDavid Howells struct xfrm_lifetime_cfg {
67607ca46eSDavid Howells 	__u64	soft_byte_limit;
68607ca46eSDavid Howells 	__u64	hard_byte_limit;
69607ca46eSDavid Howells 	__u64	soft_packet_limit;
70607ca46eSDavid Howells 	__u64	hard_packet_limit;
71607ca46eSDavid Howells 	__u64	soft_add_expires_seconds;
72607ca46eSDavid Howells 	__u64	hard_add_expires_seconds;
73607ca46eSDavid Howells 	__u64	soft_use_expires_seconds;
74607ca46eSDavid Howells 	__u64	hard_use_expires_seconds;
75607ca46eSDavid Howells };
76607ca46eSDavid Howells 
77607ca46eSDavid Howells struct xfrm_lifetime_cur {
78607ca46eSDavid Howells 	__u64	bytes;
79607ca46eSDavid Howells 	__u64	packets;
80607ca46eSDavid Howells 	__u64	add_time;
81607ca46eSDavid Howells 	__u64	use_time;
82607ca46eSDavid Howells };
83607ca46eSDavid Howells 
84607ca46eSDavid Howells struct xfrm_replay_state {
85607ca46eSDavid Howells 	__u32	oseq;
86607ca46eSDavid Howells 	__u32	seq;
87607ca46eSDavid Howells 	__u32	bitmap;
88607ca46eSDavid Howells };
89607ca46eSDavid Howells 
90607ca46eSDavid Howells #define XFRMA_REPLAY_ESN_MAX	4096
91607ca46eSDavid Howells 
92607ca46eSDavid Howells struct xfrm_replay_state_esn {
93607ca46eSDavid Howells 	unsigned int	bmp_len;
94607ca46eSDavid Howells 	__u32		oseq;
95607ca46eSDavid Howells 	__u32		seq;
96607ca46eSDavid Howells 	__u32		oseq_hi;
97607ca46eSDavid Howells 	__u32		seq_hi;
98607ca46eSDavid Howells 	__u32		replay_window;
99607ca46eSDavid Howells 	__u32		bmp[0];
100607ca46eSDavid Howells };
101607ca46eSDavid Howells 
102607ca46eSDavid Howells struct xfrm_algo {
103607ca46eSDavid Howells 	char		alg_name[64];
104607ca46eSDavid Howells 	unsigned int	alg_key_len;    /* in bits */
105607ca46eSDavid Howells 	char		alg_key[0];
106607ca46eSDavid Howells };
107607ca46eSDavid Howells 
108607ca46eSDavid Howells struct xfrm_algo_auth {
109607ca46eSDavid Howells 	char		alg_name[64];
110607ca46eSDavid Howells 	unsigned int	alg_key_len;    /* in bits */
111607ca46eSDavid Howells 	unsigned int	alg_trunc_len;  /* in bits */
112607ca46eSDavid Howells 	char		alg_key[0];
113607ca46eSDavid Howells };
114607ca46eSDavid Howells 
115607ca46eSDavid Howells struct xfrm_algo_aead {
116607ca46eSDavid Howells 	char		alg_name[64];
117607ca46eSDavid Howells 	unsigned int	alg_key_len;	/* in bits */
118607ca46eSDavid Howells 	unsigned int	alg_icv_len;	/* in bits */
119607ca46eSDavid Howells 	char		alg_key[0];
120607ca46eSDavid Howells };
121607ca46eSDavid Howells 
122607ca46eSDavid Howells struct xfrm_stats {
123607ca46eSDavid Howells 	__u32	replay_window;
124607ca46eSDavid Howells 	__u32	replay;
125607ca46eSDavid Howells 	__u32	integrity_failed;
126607ca46eSDavid Howells };
127607ca46eSDavid Howells 
128607ca46eSDavid Howells enum {
129607ca46eSDavid Howells 	XFRM_POLICY_TYPE_MAIN	= 0,
130607ca46eSDavid Howells 	XFRM_POLICY_TYPE_SUB	= 1,
131607ca46eSDavid Howells 	XFRM_POLICY_TYPE_MAX	= 2,
132607ca46eSDavid Howells 	XFRM_POLICY_TYPE_ANY	= 255
133607ca46eSDavid Howells };
134607ca46eSDavid Howells 
135607ca46eSDavid Howells enum {
136607ca46eSDavid Howells 	XFRM_POLICY_IN	= 0,
137607ca46eSDavid Howells 	XFRM_POLICY_OUT	= 1,
138607ca46eSDavid Howells 	XFRM_POLICY_FWD	= 2,
139607ca46eSDavid Howells 	XFRM_POLICY_MASK = 3,
140607ca46eSDavid Howells 	XFRM_POLICY_MAX	= 3
141607ca46eSDavid Howells };
142607ca46eSDavid Howells 
143607ca46eSDavid Howells enum {
144607ca46eSDavid Howells 	XFRM_SHARE_ANY,		/* No limitations */
145607ca46eSDavid Howells 	XFRM_SHARE_SESSION,	/* For this session only */
146607ca46eSDavid Howells 	XFRM_SHARE_USER,	/* For this user only */
147607ca46eSDavid Howells 	XFRM_SHARE_UNIQUE	/* Use once */
148607ca46eSDavid Howells };
149607ca46eSDavid Howells 
150607ca46eSDavid Howells #define XFRM_MODE_TRANSPORT 0
151607ca46eSDavid Howells #define XFRM_MODE_TUNNEL 1
152607ca46eSDavid Howells #define XFRM_MODE_ROUTEOPTIMIZATION 2
153607ca46eSDavid Howells #define XFRM_MODE_IN_TRIGGER 3
154607ca46eSDavid Howells #define XFRM_MODE_BEET 4
155607ca46eSDavid Howells #define XFRM_MODE_MAX 5
156607ca46eSDavid Howells 
157607ca46eSDavid Howells /* Netlink configuration messages.  */
158607ca46eSDavid Howells enum {
159607ca46eSDavid Howells 	XFRM_MSG_BASE = 0x10,
160607ca46eSDavid Howells 
161607ca46eSDavid Howells 	XFRM_MSG_NEWSA = 0x10,
162607ca46eSDavid Howells #define XFRM_MSG_NEWSA XFRM_MSG_NEWSA
163607ca46eSDavid Howells 	XFRM_MSG_DELSA,
164607ca46eSDavid Howells #define XFRM_MSG_DELSA XFRM_MSG_DELSA
165607ca46eSDavid Howells 	XFRM_MSG_GETSA,
166607ca46eSDavid Howells #define XFRM_MSG_GETSA XFRM_MSG_GETSA
167607ca46eSDavid Howells 
168607ca46eSDavid Howells 	XFRM_MSG_NEWPOLICY,
169607ca46eSDavid Howells #define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY
170607ca46eSDavid Howells 	XFRM_MSG_DELPOLICY,
171607ca46eSDavid Howells #define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY
172607ca46eSDavid Howells 	XFRM_MSG_GETPOLICY,
173607ca46eSDavid Howells #define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY
174607ca46eSDavid Howells 
175607ca46eSDavid Howells 	XFRM_MSG_ALLOCSPI,
176607ca46eSDavid Howells #define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI
177607ca46eSDavid Howells 	XFRM_MSG_ACQUIRE,
178607ca46eSDavid Howells #define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE
179607ca46eSDavid Howells 	XFRM_MSG_EXPIRE,
180607ca46eSDavid Howells #define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE
181607ca46eSDavid Howells 
182607ca46eSDavid Howells 	XFRM_MSG_UPDPOLICY,
183607ca46eSDavid Howells #define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY
184607ca46eSDavid Howells 	XFRM_MSG_UPDSA,
185607ca46eSDavid Howells #define XFRM_MSG_UPDSA XFRM_MSG_UPDSA
186607ca46eSDavid Howells 
187607ca46eSDavid Howells 	XFRM_MSG_POLEXPIRE,
188607ca46eSDavid Howells #define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE
189607ca46eSDavid Howells 
190607ca46eSDavid Howells 	XFRM_MSG_FLUSHSA,
191607ca46eSDavid Howells #define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA
192607ca46eSDavid Howells 	XFRM_MSG_FLUSHPOLICY,
193607ca46eSDavid Howells #define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
194607ca46eSDavid Howells 
195607ca46eSDavid Howells 	XFRM_MSG_NEWAE,
196607ca46eSDavid Howells #define XFRM_MSG_NEWAE XFRM_MSG_NEWAE
197607ca46eSDavid Howells 	XFRM_MSG_GETAE,
198607ca46eSDavid Howells #define XFRM_MSG_GETAE XFRM_MSG_GETAE
199607ca46eSDavid Howells 
200607ca46eSDavid Howells 	XFRM_MSG_REPORT,
201607ca46eSDavid Howells #define XFRM_MSG_REPORT XFRM_MSG_REPORT
202607ca46eSDavid Howells 
203607ca46eSDavid Howells 	XFRM_MSG_MIGRATE,
204607ca46eSDavid Howells #define XFRM_MSG_MIGRATE XFRM_MSG_MIGRATE
205607ca46eSDavid Howells 
206607ca46eSDavid Howells 	XFRM_MSG_NEWSADINFO,
207607ca46eSDavid Howells #define XFRM_MSG_NEWSADINFO XFRM_MSG_NEWSADINFO
208607ca46eSDavid Howells 	XFRM_MSG_GETSADINFO,
209607ca46eSDavid Howells #define XFRM_MSG_GETSADINFO XFRM_MSG_GETSADINFO
210607ca46eSDavid Howells 
211607ca46eSDavid Howells 	XFRM_MSG_NEWSPDINFO,
212607ca46eSDavid Howells #define XFRM_MSG_NEWSPDINFO XFRM_MSG_NEWSPDINFO
213607ca46eSDavid Howells 	XFRM_MSG_GETSPDINFO,
214607ca46eSDavid Howells #define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
215607ca46eSDavid Howells 
216844f7eaaSEugene Syromiatnikov 	XFRM_MSG_MAPPING,
217844f7eaaSEugene Syromiatnikov #define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
218844f7eaaSEugene Syromiatnikov 
2192d151d39SSteffen Klassert 	XFRM_MSG_SETDEFAULT,
2202d151d39SSteffen Klassert #define XFRM_MSG_SETDEFAULT XFRM_MSG_SETDEFAULT
2212d151d39SSteffen Klassert 	XFRM_MSG_GETDEFAULT,
2222d151d39SSteffen Klassert #define XFRM_MSG_GETDEFAULT XFRM_MSG_GETDEFAULT
223607ca46eSDavid Howells 	__XFRM_MSG_MAX
224607ca46eSDavid Howells };
225607ca46eSDavid Howells #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
226607ca46eSDavid Howells 
227607ca46eSDavid Howells #define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)
228607ca46eSDavid Howells 
229607ca46eSDavid Howells /*
230607ca46eSDavid Howells  * Generic LSM security context for comunicating to user space
231607ca46eSDavid Howells  * NOTE: Same format as sadb_x_sec_ctx
232607ca46eSDavid Howells  */
233607ca46eSDavid Howells struct xfrm_user_sec_ctx {
234607ca46eSDavid Howells 	__u16			len;
235607ca46eSDavid Howells 	__u16			exttype;
236607ca46eSDavid Howells 	__u8			ctx_alg;  /* LSMs: e.g., selinux == 1 */
237607ca46eSDavid Howells 	__u8			ctx_doi;
238607ca46eSDavid Howells 	__u16			ctx_len;
239607ca46eSDavid Howells };
240607ca46eSDavid Howells 
241607ca46eSDavid Howells struct xfrm_user_tmpl {
242607ca46eSDavid Howells 	struct xfrm_id		id;
243607ca46eSDavid Howells 	__u16			family;
244607ca46eSDavid Howells 	xfrm_address_t		saddr;
245607ca46eSDavid Howells 	__u32			reqid;
246607ca46eSDavid Howells 	__u8			mode;
247607ca46eSDavid Howells 	__u8			share;
248607ca46eSDavid Howells 	__u8			optional;
249607ca46eSDavid Howells 	__u32			aalgos;
250607ca46eSDavid Howells 	__u32			ealgos;
251607ca46eSDavid Howells 	__u32			calgos;
252607ca46eSDavid Howells };
253607ca46eSDavid Howells 
254607ca46eSDavid Howells struct xfrm_encap_tmpl {
255607ca46eSDavid Howells 	__u16		encap_type;
256607ca46eSDavid Howells 	__be16		encap_sport;
257607ca46eSDavid Howells 	__be16		encap_dport;
258607ca46eSDavid Howells 	xfrm_address_t	encap_oa;
259607ca46eSDavid Howells };
260607ca46eSDavid Howells 
261607ca46eSDavid Howells /* AEVENT flags  */
262607ca46eSDavid Howells enum xfrm_ae_ftype_t {
263607ca46eSDavid Howells 	XFRM_AE_UNSPEC,
264607ca46eSDavid Howells 	XFRM_AE_RTHR=1,	/* replay threshold*/
265607ca46eSDavid Howells 	XFRM_AE_RVAL=2, /* replay value */
266607ca46eSDavid Howells 	XFRM_AE_LVAL=4, /* lifetime value */
267607ca46eSDavid Howells 	XFRM_AE_ETHR=8, /* expiry timer threshold */
268607ca46eSDavid Howells 	XFRM_AE_CR=16, /* Event cause is replay update */
269607ca46eSDavid Howells 	XFRM_AE_CE=32, /* Event cause is timer expiry */
270607ca46eSDavid Howells 	XFRM_AE_CU=64, /* Event cause is policy update */
271607ca46eSDavid Howells 	__XFRM_AE_MAX
272607ca46eSDavid Howells 
273607ca46eSDavid Howells #define XFRM_AE_MAX (__XFRM_AE_MAX - 1)
274607ca46eSDavid Howells };
275607ca46eSDavid Howells 
276607ca46eSDavid Howells struct xfrm_userpolicy_type {
277607ca46eSDavid Howells 	__u8		type;
278607ca46eSDavid Howells 	__u16		reserved1;
279607ca46eSDavid Howells 	__u8		reserved2;
280607ca46eSDavid Howells };
281607ca46eSDavid Howells 
282607ca46eSDavid Howells /* Netlink message attributes.  */
283607ca46eSDavid Howells enum xfrm_attr_type_t {
284607ca46eSDavid Howells 	XFRMA_UNSPEC,
285607ca46eSDavid Howells 	XFRMA_ALG_AUTH,		/* struct xfrm_algo */
286607ca46eSDavid Howells 	XFRMA_ALG_CRYPT,	/* struct xfrm_algo */
287607ca46eSDavid Howells 	XFRMA_ALG_COMP,		/* struct xfrm_algo */
288607ca46eSDavid Howells 	XFRMA_ENCAP,		/* struct xfrm_algo + struct xfrm_encap_tmpl */
289607ca46eSDavid Howells 	XFRMA_TMPL,		/* 1 or more struct xfrm_user_tmpl */
290607ca46eSDavid Howells 	XFRMA_SA,		/* struct xfrm_usersa_info  */
291607ca46eSDavid Howells 	XFRMA_POLICY,		/*struct xfrm_userpolicy_info */
292607ca46eSDavid Howells 	XFRMA_SEC_CTX,		/* struct xfrm_sec_ctx */
293607ca46eSDavid Howells 	XFRMA_LTIME_VAL,
294607ca46eSDavid Howells 	XFRMA_REPLAY_VAL,
295607ca46eSDavid Howells 	XFRMA_REPLAY_THRESH,
296607ca46eSDavid Howells 	XFRMA_ETIMER_THRESH,
297607ca46eSDavid Howells 	XFRMA_SRCADDR,		/* xfrm_address_t */
298607ca46eSDavid Howells 	XFRMA_COADDR,		/* xfrm_address_t */
299607ca46eSDavid Howells 	XFRMA_LASTUSED,		/* unsigned long  */
300607ca46eSDavid Howells 	XFRMA_POLICY_TYPE,	/* struct xfrm_userpolicy_type */
301607ca46eSDavid Howells 	XFRMA_MIGRATE,
302607ca46eSDavid Howells 	XFRMA_ALG_AEAD,		/* struct xfrm_algo_aead */
303607ca46eSDavid Howells 	XFRMA_KMADDRESS,        /* struct xfrm_user_kmaddress */
304607ca46eSDavid Howells 	XFRMA_ALG_AUTH_TRUNC,	/* struct xfrm_algo_auth */
305607ca46eSDavid Howells 	XFRMA_MARK,		/* struct xfrm_mark */
306607ca46eSDavid Howells 	XFRMA_TFCPAD,		/* __u32 */
30734a3d4b2SRichard Guy Briggs 	XFRMA_REPLAY_ESN_VAL,	/* struct xfrm_replay_state_esn */
308a947b0a9SNicolas Dichtel 	XFRMA_SA_EXTRA_FLAGS,	/* __u32 */
309d3623099SNicolas Dichtel 	XFRMA_PROTO,		/* __u8 */
310870a2df4SNicolas Dichtel 	XFRMA_ADDRESS_FILTER,	/* struct xfrm_address_filter */
311de95c4a4SNicolas Dichtel 	XFRMA_PAD,
31229e42766SAntony Antony 	XFRMA_OFFLOAD_DEV,	/* struct xfrm_user_offload */
3139b42c1f1SSteffen Klassert 	XFRMA_SET_MARK,		/* __u32 */
3149b42c1f1SSteffen Klassert 	XFRMA_SET_MARK_MASK,	/* __u32 */
3157e652640SSteffen Klassert 	XFRMA_IF_ID,		/* __u32 */
316*4e484b3eSAntony Antony 	XFRMA_MTIMER_THRESH,	/* __u32 in seconds for input SA */
317607ca46eSDavid Howells 	__XFRMA_MAX
318607ca46eSDavid Howells 
3199b42c1f1SSteffen Klassert #define XFRMA_OUTPUT_MARK XFRMA_SET_MARK	/* Compatibility */
320607ca46eSDavid Howells #define XFRMA_MAX (__XFRMA_MAX - 1)
321607ca46eSDavid Howells };
322607ca46eSDavid Howells 
323607ca46eSDavid Howells struct xfrm_mark {
324607ca46eSDavid Howells 	__u32           v; /* value */
325607ca46eSDavid Howells 	__u32           m; /* mask */
326607ca46eSDavid Howells };
327607ca46eSDavid Howells 
328607ca46eSDavid Howells enum xfrm_sadattr_type_t {
329607ca46eSDavid Howells 	XFRMA_SAD_UNSPEC,
330607ca46eSDavid Howells 	XFRMA_SAD_CNT,
331607ca46eSDavid Howells 	XFRMA_SAD_HINFO,
332607ca46eSDavid Howells 	__XFRMA_SAD_MAX
333607ca46eSDavid Howells 
334607ca46eSDavid Howells #define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1)
335607ca46eSDavid Howells };
336607ca46eSDavid Howells 
337607ca46eSDavid Howells struct xfrmu_sadhinfo {
338607ca46eSDavid Howells 	__u32 sadhcnt; /* current hash bkts */
339607ca46eSDavid Howells 	__u32 sadhmcnt; /* max allowed hash bkts */
340607ca46eSDavid Howells };
341607ca46eSDavid Howells 
342607ca46eSDavid Howells enum xfrm_spdattr_type_t {
343607ca46eSDavid Howells 	XFRMA_SPD_UNSPEC,
344607ca46eSDavid Howells 	XFRMA_SPD_INFO,
345607ca46eSDavid Howells 	XFRMA_SPD_HINFO,
346880a6fabSChristophe Gouault 	XFRMA_SPD_IPV4_HTHRESH,
347880a6fabSChristophe Gouault 	XFRMA_SPD_IPV6_HTHRESH,
348607ca46eSDavid Howells 	__XFRMA_SPD_MAX
349607ca46eSDavid Howells 
350607ca46eSDavid Howells #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1)
351607ca46eSDavid Howells };
352607ca46eSDavid Howells 
353607ca46eSDavid Howells struct xfrmu_spdinfo {
354607ca46eSDavid Howells 	__u32 incnt;
355607ca46eSDavid Howells 	__u32 outcnt;
356607ca46eSDavid Howells 	__u32 fwdcnt;
357607ca46eSDavid Howells 	__u32 inscnt;
358607ca46eSDavid Howells 	__u32 outscnt;
359607ca46eSDavid Howells 	__u32 fwdscnt;
360607ca46eSDavid Howells };
361607ca46eSDavid Howells 
362607ca46eSDavid Howells struct xfrmu_spdhinfo {
363607ca46eSDavid Howells 	__u32 spdhcnt;
364607ca46eSDavid Howells 	__u32 spdhmcnt;
365607ca46eSDavid Howells };
366607ca46eSDavid Howells 
367880a6fabSChristophe Gouault struct xfrmu_spdhthresh {
368880a6fabSChristophe Gouault 	__u8 lbits;
369880a6fabSChristophe Gouault 	__u8 rbits;
370880a6fabSChristophe Gouault };
371880a6fabSChristophe Gouault 
372607ca46eSDavid Howells struct xfrm_usersa_info {
373607ca46eSDavid Howells 	struct xfrm_selector		sel;
374607ca46eSDavid Howells 	struct xfrm_id			id;
375607ca46eSDavid Howells 	xfrm_address_t			saddr;
376607ca46eSDavid Howells 	struct xfrm_lifetime_cfg	lft;
377607ca46eSDavid Howells 	struct xfrm_lifetime_cur	curlft;
378607ca46eSDavid Howells 	struct xfrm_stats		stats;
379607ca46eSDavid Howells 	__u32				seq;
380607ca46eSDavid Howells 	__u32				reqid;
381607ca46eSDavid Howells 	__u16				family;
382607ca46eSDavid Howells 	__u8				mode;		/* XFRM_MODE_xxx */
383607ca46eSDavid Howells 	__u8				replay_window;
384607ca46eSDavid Howells 	__u8				flags;
385607ca46eSDavid Howells #define XFRM_STATE_NOECN	1
386607ca46eSDavid Howells #define XFRM_STATE_DECAP_DSCP	2
387607ca46eSDavid Howells #define XFRM_STATE_NOPMTUDISC	4
388607ca46eSDavid Howells #define XFRM_STATE_WILDRECV	8
389607ca46eSDavid Howells #define XFRM_STATE_ICMP		16
390607ca46eSDavid Howells #define XFRM_STATE_AF_UNSPEC	32
391607ca46eSDavid Howells #define XFRM_STATE_ALIGN4	64
392607ca46eSDavid Howells #define XFRM_STATE_ESN		128
393607ca46eSDavid Howells };
394607ca46eSDavid Howells 
395a947b0a9SNicolas Dichtel #define XFRM_SA_XFLAG_DONT_ENCAP_DSCP	1
396428d2459SPetr Vaněk #define XFRM_SA_XFLAG_OSEQ_MAY_WRAP	2
397a947b0a9SNicolas Dichtel 
398607ca46eSDavid Howells struct xfrm_usersa_id {
399607ca46eSDavid Howells 	xfrm_address_t			daddr;
400607ca46eSDavid Howells 	__be32				spi;
401607ca46eSDavid Howells 	__u16				family;
402607ca46eSDavid Howells 	__u8				proto;
403607ca46eSDavid Howells };
404607ca46eSDavid Howells 
405607ca46eSDavid Howells struct xfrm_aevent_id {
406607ca46eSDavid Howells 	struct xfrm_usersa_id		sa_id;
407607ca46eSDavid Howells 	xfrm_address_t			saddr;
408607ca46eSDavid Howells 	__u32				flags;
409607ca46eSDavid Howells 	__u32				reqid;
410607ca46eSDavid Howells };
411607ca46eSDavid Howells 
412607ca46eSDavid Howells struct xfrm_userspi_info {
413607ca46eSDavid Howells 	struct xfrm_usersa_info		info;
414607ca46eSDavid Howells 	__u32				min;
415607ca46eSDavid Howells 	__u32				max;
416607ca46eSDavid Howells };
417607ca46eSDavid Howells 
418607ca46eSDavid Howells struct xfrm_userpolicy_info {
419607ca46eSDavid Howells 	struct xfrm_selector		sel;
420607ca46eSDavid Howells 	struct xfrm_lifetime_cfg	lft;
421607ca46eSDavid Howells 	struct xfrm_lifetime_cur	curlft;
422607ca46eSDavid Howells 	__u32				priority;
423607ca46eSDavid Howells 	__u32				index;
424607ca46eSDavid Howells 	__u8				dir;
425607ca46eSDavid Howells 	__u8				action;
426607ca46eSDavid Howells #define XFRM_POLICY_ALLOW	0
427607ca46eSDavid Howells #define XFRM_POLICY_BLOCK	1
428607ca46eSDavid Howells 	__u8				flags;
429607ca46eSDavid Howells #define XFRM_POLICY_LOCALOK	1	/* Allow user to override global policy */
430607ca46eSDavid Howells 	/* Automatically expand selector to include matching ICMP payloads. */
431607ca46eSDavid Howells #define XFRM_POLICY_ICMP	2
432607ca46eSDavid Howells 	__u8				share;
433607ca46eSDavid Howells };
434607ca46eSDavid Howells 
435607ca46eSDavid Howells struct xfrm_userpolicy_id {
436607ca46eSDavid Howells 	struct xfrm_selector		sel;
437607ca46eSDavid Howells 	__u32				index;
438607ca46eSDavid Howells 	__u8				dir;
439607ca46eSDavid Howells };
440607ca46eSDavid Howells 
441607ca46eSDavid Howells struct xfrm_user_acquire {
442607ca46eSDavid Howells 	struct xfrm_id			id;
443607ca46eSDavid Howells 	xfrm_address_t			saddr;
444607ca46eSDavid Howells 	struct xfrm_selector		sel;
445607ca46eSDavid Howells 	struct xfrm_userpolicy_info	policy;
446607ca46eSDavid Howells 	__u32				aalgos;
447607ca46eSDavid Howells 	__u32				ealgos;
448607ca46eSDavid Howells 	__u32				calgos;
449607ca46eSDavid Howells 	__u32				seq;
450607ca46eSDavid Howells };
451607ca46eSDavid Howells 
452607ca46eSDavid Howells struct xfrm_user_expire {
453607ca46eSDavid Howells 	struct xfrm_usersa_info		state;
454607ca46eSDavid Howells 	__u8				hard;
455607ca46eSDavid Howells };
456607ca46eSDavid Howells 
457607ca46eSDavid Howells struct xfrm_user_polexpire {
458607ca46eSDavid Howells 	struct xfrm_userpolicy_info	pol;
459607ca46eSDavid Howells 	__u8				hard;
460607ca46eSDavid Howells };
461607ca46eSDavid Howells 
462607ca46eSDavid Howells struct xfrm_usersa_flush {
463607ca46eSDavid Howells 	__u8				proto;
464607ca46eSDavid Howells };
465607ca46eSDavid Howells 
466607ca46eSDavid Howells struct xfrm_user_report {
467607ca46eSDavid Howells 	__u8				proto;
468607ca46eSDavid Howells 	struct xfrm_selector		sel;
469607ca46eSDavid Howells };
470607ca46eSDavid Howells 
471607ca46eSDavid Howells /* Used by MIGRATE to pass addresses IKE should use to perform
472607ca46eSDavid Howells  * SA negotiation with the peer */
473607ca46eSDavid Howells struct xfrm_user_kmaddress {
474607ca46eSDavid Howells 	xfrm_address_t                  local;
475607ca46eSDavid Howells 	xfrm_address_t                  remote;
476607ca46eSDavid Howells 	__u32				reserved;
477607ca46eSDavid Howells 	__u16				family;
478607ca46eSDavid Howells };
479607ca46eSDavid Howells 
480607ca46eSDavid Howells struct xfrm_user_migrate {
481607ca46eSDavid Howells 	xfrm_address_t			old_daddr;
482607ca46eSDavid Howells 	xfrm_address_t			old_saddr;
483607ca46eSDavid Howells 	xfrm_address_t			new_daddr;
484607ca46eSDavid Howells 	xfrm_address_t			new_saddr;
485607ca46eSDavid Howells 	__u8				proto;
486607ca46eSDavid Howells 	__u8				mode;
487607ca46eSDavid Howells 	__u16				reserved;
488607ca46eSDavid Howells 	__u32				reqid;
489607ca46eSDavid Howells 	__u16				old_family;
490607ca46eSDavid Howells 	__u16				new_family;
491607ca46eSDavid Howells };
492607ca46eSDavid Howells 
493607ca46eSDavid Howells struct xfrm_user_mapping {
494607ca46eSDavid Howells 	struct xfrm_usersa_id		id;
495607ca46eSDavid Howells 	__u32				reqid;
496607ca46eSDavid Howells 	xfrm_address_t			old_saddr;
497607ca46eSDavid Howells 	xfrm_address_t			new_saddr;
498607ca46eSDavid Howells 	__be16				old_sport;
499607ca46eSDavid Howells 	__be16				new_sport;
500607ca46eSDavid Howells };
501607ca46eSDavid Howells 
502870a2df4SNicolas Dichtel struct xfrm_address_filter {
503d3623099SNicolas Dichtel 	xfrm_address_t			saddr;
504d3623099SNicolas Dichtel 	xfrm_address_t			daddr;
505d3623099SNicolas Dichtel 	__u16				family;
506d3623099SNicolas Dichtel 	__u8				splen;
507d3623099SNicolas Dichtel 	__u8				dplen;
508d3623099SNicolas Dichtel };
509d3623099SNicolas Dichtel 
510d77e38e6SSteffen Klassert struct xfrm_user_offload {
511d77e38e6SSteffen Klassert 	int				ifindex;
512d77e38e6SSteffen Klassert 	__u8				flags;
513d77e38e6SSteffen Klassert };
514d77e38e6SSteffen Klassert #define XFRM_OFFLOAD_IPV6	1
515d77e38e6SSteffen Klassert #define XFRM_OFFLOAD_INBOUND	2
516d77e38e6SSteffen Klassert 
5172d151d39SSteffen Klassert struct xfrm_userpolicy_default {
518f8d858e6SNicolas Dichtel #define XFRM_USERPOLICY_UNSPEC	0
519f8d858e6SNicolas Dichtel #define XFRM_USERPOLICY_BLOCK	1
520f8d858e6SNicolas Dichtel #define XFRM_USERPOLICY_ACCEPT	2
521f8d858e6SNicolas Dichtel 	__u8				in;
522f8d858e6SNicolas Dichtel 	__u8				fwd;
523f8d858e6SNicolas Dichtel 	__u8				out;
5242d151d39SSteffen Klassert };
5252d151d39SSteffen Klassert 
526607ca46eSDavid Howells #ifndef __KERNEL__
527607ca46eSDavid Howells /* backwards compatibility for userspace */
528607ca46eSDavid Howells #define XFRMGRP_ACQUIRE		1
529607ca46eSDavid Howells #define XFRMGRP_EXPIRE		2
530607ca46eSDavid Howells #define XFRMGRP_SA		4
531607ca46eSDavid Howells #define XFRMGRP_POLICY		8
532607ca46eSDavid Howells #define XFRMGRP_REPORT		0x20
533607ca46eSDavid Howells #endif
534607ca46eSDavid Howells 
535607ca46eSDavid Howells enum xfrm_nlgroups {
536607ca46eSDavid Howells 	XFRMNLGRP_NONE,
537607ca46eSDavid Howells #define XFRMNLGRP_NONE		XFRMNLGRP_NONE
538607ca46eSDavid Howells 	XFRMNLGRP_ACQUIRE,
539607ca46eSDavid Howells #define XFRMNLGRP_ACQUIRE	XFRMNLGRP_ACQUIRE
540607ca46eSDavid Howells 	XFRMNLGRP_EXPIRE,
541607ca46eSDavid Howells #define XFRMNLGRP_EXPIRE	XFRMNLGRP_EXPIRE
542607ca46eSDavid Howells 	XFRMNLGRP_SA,
543607ca46eSDavid Howells #define XFRMNLGRP_SA		XFRMNLGRP_SA
544607ca46eSDavid Howells 	XFRMNLGRP_POLICY,
545607ca46eSDavid Howells #define XFRMNLGRP_POLICY	XFRMNLGRP_POLICY
546607ca46eSDavid Howells 	XFRMNLGRP_AEVENTS,
547607ca46eSDavid Howells #define XFRMNLGRP_AEVENTS	XFRMNLGRP_AEVENTS
548607ca46eSDavid Howells 	XFRMNLGRP_REPORT,
549607ca46eSDavid Howells #define XFRMNLGRP_REPORT	XFRMNLGRP_REPORT
550607ca46eSDavid Howells 	XFRMNLGRP_MIGRATE,
551607ca46eSDavid Howells #define XFRMNLGRP_MIGRATE	XFRMNLGRP_MIGRATE
552607ca46eSDavid Howells 	XFRMNLGRP_MAPPING,
553607ca46eSDavid Howells #define XFRMNLGRP_MAPPING	XFRMNLGRP_MAPPING
554607ca46eSDavid Howells 	__XFRMNLGRP_MAX
555607ca46eSDavid Howells };
556607ca46eSDavid Howells #define XFRMNLGRP_MAX	(__XFRMNLGRP_MAX - 1)
557607ca46eSDavid Howells 
558607ca46eSDavid Howells #endif /* _LINUX_XFRM_H */
559