1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef _LINUX_XFRM_H
8 #define _LINUX_XFRM_H
9 #include <linux/in6.h>
10 #include <linux/types.h>
11 #include <linux/stddef.h>
12 typedef union {
13   __be32 a4;
14   __be32 a6[4];
15   struct in6_addr in6;
16 } xfrm_address_t;
17 struct xfrm_id {
18   xfrm_address_t daddr;
19   __be32 spi;
20   __u8 proto;
21 };
22 struct xfrm_sec_ctx {
23   __u8 ctx_doi;
24   __u8 ctx_alg;
25   __u16 ctx_len;
26   __u32 ctx_sid;
27   char ctx_str[] __counted_by(ctx_len);
28 };
29 #define XFRM_SC_DOI_RESERVED 0
30 #define XFRM_SC_DOI_LSM 1
31 #define XFRM_SC_ALG_RESERVED 0
32 #define XFRM_SC_ALG_SELINUX 1
33 struct xfrm_selector {
34   xfrm_address_t daddr;
35   xfrm_address_t saddr;
36   __be16 dport;
37   __be16 dport_mask;
38   __be16 sport;
39   __be16 sport_mask;
40   __u16 family;
41   __u8 prefixlen_d;
42   __u8 prefixlen_s;
43   __u8 proto;
44   int ifindex;
45   __kernel_uid32_t user;
46 };
47 #define XFRM_INF (~(__u64) 0)
48 struct xfrm_lifetime_cfg {
49   __u64 soft_byte_limit;
50   __u64 hard_byte_limit;
51   __u64 soft_packet_limit;
52   __u64 hard_packet_limit;
53   __u64 soft_add_expires_seconds;
54   __u64 hard_add_expires_seconds;
55   __u64 soft_use_expires_seconds;
56   __u64 hard_use_expires_seconds;
57 };
58 struct xfrm_lifetime_cur {
59   __u64 bytes;
60   __u64 packets;
61   __u64 add_time;
62   __u64 use_time;
63 };
64 struct xfrm_replay_state {
65   __u32 oseq;
66   __u32 seq;
67   __u32 bitmap;
68 };
69 #define XFRMA_REPLAY_ESN_MAX 4096
70 struct xfrm_replay_state_esn {
71   unsigned int bmp_len;
72   __u32 oseq;
73   __u32 seq;
74   __u32 oseq_hi;
75   __u32 seq_hi;
76   __u32 replay_window;
77   __u32 bmp[];
78 };
79 struct xfrm_algo {
80   char alg_name[64];
81   unsigned int alg_key_len;
82   char alg_key[];
83 };
84 struct xfrm_algo_auth {
85   char alg_name[64];
86   unsigned int alg_key_len;
87   unsigned int alg_trunc_len;
88   char alg_key[];
89 };
90 struct xfrm_algo_aead {
91   char alg_name[64];
92   unsigned int alg_key_len;
93   unsigned int alg_icv_len;
94   char alg_key[];
95 };
96 struct xfrm_stats {
97   __u32 replay_window;
98   __u32 replay;
99   __u32 integrity_failed;
100 };
101 enum {
102   XFRM_POLICY_TYPE_MAIN = 0,
103   XFRM_POLICY_TYPE_SUB = 1,
104   XFRM_POLICY_TYPE_MAX = 2,
105   XFRM_POLICY_TYPE_ANY = 255
106 };
107 enum {
108   XFRM_POLICY_IN = 0,
109   XFRM_POLICY_OUT = 1,
110   XFRM_POLICY_FWD = 2,
111   XFRM_POLICY_MASK = 3,
112   XFRM_POLICY_MAX = 3
113 };
114 enum {
115   XFRM_SHARE_ANY,
116   XFRM_SHARE_SESSION,
117   XFRM_SHARE_USER,
118   XFRM_SHARE_UNIQUE
119 };
120 #define XFRM_MODE_TRANSPORT 0
121 #define XFRM_MODE_TUNNEL 1
122 #define XFRM_MODE_ROUTEOPTIMIZATION 2
123 #define XFRM_MODE_IN_TRIGGER 3
124 #define XFRM_MODE_BEET 4
125 #define XFRM_MODE_MAX 5
126 enum {
127   XFRM_MSG_BASE = 0x10,
128   XFRM_MSG_NEWSA = 0x10,
129 #define XFRM_MSG_NEWSA XFRM_MSG_NEWSA
130   XFRM_MSG_DELSA,
131 #define XFRM_MSG_DELSA XFRM_MSG_DELSA
132   XFRM_MSG_GETSA,
133 #define XFRM_MSG_GETSA XFRM_MSG_GETSA
134   XFRM_MSG_NEWPOLICY,
135 #define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY
136   XFRM_MSG_DELPOLICY,
137 #define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY
138   XFRM_MSG_GETPOLICY,
139 #define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY
140   XFRM_MSG_ALLOCSPI,
141 #define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI
142   XFRM_MSG_ACQUIRE,
143 #define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE
144   XFRM_MSG_EXPIRE,
145 #define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE
146   XFRM_MSG_UPDPOLICY,
147 #define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY
148   XFRM_MSG_UPDSA,
149 #define XFRM_MSG_UPDSA XFRM_MSG_UPDSA
150   XFRM_MSG_POLEXPIRE,
151 #define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE
152   XFRM_MSG_FLUSHSA,
153 #define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA
154   XFRM_MSG_FLUSHPOLICY,
155 #define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
156   XFRM_MSG_NEWAE,
157 #define XFRM_MSG_NEWAE XFRM_MSG_NEWAE
158   XFRM_MSG_GETAE,
159 #define XFRM_MSG_GETAE XFRM_MSG_GETAE
160   XFRM_MSG_REPORT,
161 #define XFRM_MSG_REPORT XFRM_MSG_REPORT
162   XFRM_MSG_MIGRATE,
163 #define XFRM_MSG_MIGRATE XFRM_MSG_MIGRATE
164   XFRM_MSG_NEWSADINFO,
165 #define XFRM_MSG_NEWSADINFO XFRM_MSG_NEWSADINFO
166   XFRM_MSG_GETSADINFO,
167 #define XFRM_MSG_GETSADINFO XFRM_MSG_GETSADINFO
168   XFRM_MSG_NEWSPDINFO,
169 #define XFRM_MSG_NEWSPDINFO XFRM_MSG_NEWSPDINFO
170   XFRM_MSG_GETSPDINFO,
171 #define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
172   XFRM_MSG_MAPPING,
173 #define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
174   XFRM_MSG_SETDEFAULT,
175 #define XFRM_MSG_SETDEFAULT XFRM_MSG_SETDEFAULT
176   XFRM_MSG_GETDEFAULT,
177 #define XFRM_MSG_GETDEFAULT XFRM_MSG_GETDEFAULT
178   __XFRM_MSG_MAX
179 };
180 #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
181 #define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)
182 struct xfrm_user_sec_ctx {
183   __u16 len;
184   __u16 exttype;
185   __u8 ctx_alg;
186   __u8 ctx_doi;
187   __u16 ctx_len;
188 };
189 struct xfrm_user_tmpl {
190   struct xfrm_id id;
191   __u16 family;
192   xfrm_address_t saddr;
193   __u32 reqid;
194   __u8 mode;
195   __u8 share;
196   __u8 optional;
197   __u32 aalgos;
198   __u32 ealgos;
199   __u32 calgos;
200 };
201 struct xfrm_encap_tmpl {
202   __u16 encap_type;
203   __be16 encap_sport;
204   __be16 encap_dport;
205   xfrm_address_t encap_oa;
206 };
207 enum xfrm_ae_ftype_t {
208   XFRM_AE_UNSPEC,
209   XFRM_AE_RTHR = 1,
210   XFRM_AE_RVAL = 2,
211   XFRM_AE_LVAL = 4,
212   XFRM_AE_ETHR = 8,
213   XFRM_AE_CR = 16,
214   XFRM_AE_CE = 32,
215   XFRM_AE_CU = 64,
216   __XFRM_AE_MAX
217 #define XFRM_AE_MAX (__XFRM_AE_MAX - 1)
218 };
219 struct xfrm_userpolicy_type {
220   __u8 type;
221   __u16 reserved1;
222   __u8 reserved2;
223 };
224 enum xfrm_attr_type_t {
225   XFRMA_UNSPEC,
226   XFRMA_ALG_AUTH,
227   XFRMA_ALG_CRYPT,
228   XFRMA_ALG_COMP,
229   XFRMA_ENCAP,
230   XFRMA_TMPL,
231   XFRMA_SA,
232   XFRMA_POLICY,
233   XFRMA_SEC_CTX,
234   XFRMA_LTIME_VAL,
235   XFRMA_REPLAY_VAL,
236   XFRMA_REPLAY_THRESH,
237   XFRMA_ETIMER_THRESH,
238   XFRMA_SRCADDR,
239   XFRMA_COADDR,
240   XFRMA_LASTUSED,
241   XFRMA_POLICY_TYPE,
242   XFRMA_MIGRATE,
243   XFRMA_ALG_AEAD,
244   XFRMA_KMADDRESS,
245   XFRMA_ALG_AUTH_TRUNC,
246   XFRMA_MARK,
247   XFRMA_TFCPAD,
248   XFRMA_REPLAY_ESN_VAL,
249   XFRMA_SA_EXTRA_FLAGS,
250   XFRMA_PROTO,
251   XFRMA_ADDRESS_FILTER,
252   XFRMA_PAD,
253   XFRMA_OFFLOAD_DEV,
254   XFRMA_SET_MARK,
255   XFRMA_SET_MARK_MASK,
256   XFRMA_IF_ID,
257   XFRMA_MTIMER_THRESH,
258   __XFRMA_MAX
259 #define XFRMA_OUTPUT_MARK XFRMA_SET_MARK
260 #define XFRMA_MAX (__XFRMA_MAX - 1)
261 };
262 struct xfrm_mark {
263   __u32 v;
264   __u32 m;
265 };
266 enum xfrm_sadattr_type_t {
267   XFRMA_SAD_UNSPEC,
268   XFRMA_SAD_CNT,
269   XFRMA_SAD_HINFO,
270   __XFRMA_SAD_MAX
271 #define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1)
272 };
273 struct xfrmu_sadhinfo {
274   __u32 sadhcnt;
275   __u32 sadhmcnt;
276 };
277 enum xfrm_spdattr_type_t {
278   XFRMA_SPD_UNSPEC,
279   XFRMA_SPD_INFO,
280   XFRMA_SPD_HINFO,
281   XFRMA_SPD_IPV4_HTHRESH,
282   XFRMA_SPD_IPV6_HTHRESH,
283   __XFRMA_SPD_MAX
284 #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1)
285 };
286 struct xfrmu_spdinfo {
287   __u32 incnt;
288   __u32 outcnt;
289   __u32 fwdcnt;
290   __u32 inscnt;
291   __u32 outscnt;
292   __u32 fwdscnt;
293 };
294 struct xfrmu_spdhinfo {
295   __u32 spdhcnt;
296   __u32 spdhmcnt;
297 };
298 struct xfrmu_spdhthresh {
299   __u8 lbits;
300   __u8 rbits;
301 };
302 struct xfrm_usersa_info {
303   struct xfrm_selector sel;
304   struct xfrm_id id;
305   xfrm_address_t saddr;
306   struct xfrm_lifetime_cfg lft;
307   struct xfrm_lifetime_cur curlft;
308   struct xfrm_stats stats;
309   __u32 seq;
310   __u32 reqid;
311   __u16 family;
312   __u8 mode;
313   __u8 replay_window;
314   __u8 flags;
315 #define XFRM_STATE_NOECN 1
316 #define XFRM_STATE_DECAP_DSCP 2
317 #define XFRM_STATE_NOPMTUDISC 4
318 #define XFRM_STATE_WILDRECV 8
319 #define XFRM_STATE_ICMP 16
320 #define XFRM_STATE_AF_UNSPEC 32
321 #define XFRM_STATE_ALIGN4 64
322 #define XFRM_STATE_ESN 128
323 };
324 #define XFRM_SA_XFLAG_DONT_ENCAP_DSCP 1
325 #define XFRM_SA_XFLAG_OSEQ_MAY_WRAP 2
326 struct xfrm_usersa_id {
327   xfrm_address_t daddr;
328   __be32 spi;
329   __u16 family;
330   __u8 proto;
331 };
332 struct xfrm_aevent_id {
333   struct xfrm_usersa_id sa_id;
334   xfrm_address_t saddr;
335   __u32 flags;
336   __u32 reqid;
337 };
338 struct xfrm_userspi_info {
339   struct xfrm_usersa_info info;
340   __u32 min;
341   __u32 max;
342 };
343 struct xfrm_userpolicy_info {
344   struct xfrm_selector sel;
345   struct xfrm_lifetime_cfg lft;
346   struct xfrm_lifetime_cur curlft;
347   __u32 priority;
348   __u32 index;
349   __u8 dir;
350   __u8 action;
351 #define XFRM_POLICY_ALLOW 0
352 #define XFRM_POLICY_BLOCK 1
353   __u8 flags;
354 #define XFRM_POLICY_LOCALOK 1
355 #define XFRM_POLICY_ICMP 2
356   __u8 share;
357 };
358 struct xfrm_userpolicy_id {
359   struct xfrm_selector sel;
360   __u32 index;
361   __u8 dir;
362 };
363 struct xfrm_user_acquire {
364   struct xfrm_id id;
365   xfrm_address_t saddr;
366   struct xfrm_selector sel;
367   struct xfrm_userpolicy_info policy;
368   __u32 aalgos;
369   __u32 ealgos;
370   __u32 calgos;
371   __u32 seq;
372 };
373 struct xfrm_user_expire {
374   struct xfrm_usersa_info state;
375   __u8 hard;
376 };
377 struct xfrm_user_polexpire {
378   struct xfrm_userpolicy_info pol;
379   __u8 hard;
380 };
381 struct xfrm_usersa_flush {
382   __u8 proto;
383 };
384 struct xfrm_user_report {
385   __u8 proto;
386   struct xfrm_selector sel;
387 };
388 struct xfrm_user_kmaddress {
389   xfrm_address_t local;
390   xfrm_address_t remote;
391   __u32 reserved;
392   __u16 family;
393 };
394 struct xfrm_user_migrate {
395   xfrm_address_t old_daddr;
396   xfrm_address_t old_saddr;
397   xfrm_address_t new_daddr;
398   xfrm_address_t new_saddr;
399   __u8 proto;
400   __u8 mode;
401   __u16 reserved;
402   __u32 reqid;
403   __u16 old_family;
404   __u16 new_family;
405 };
406 struct xfrm_user_mapping {
407   struct xfrm_usersa_id id;
408   __u32 reqid;
409   xfrm_address_t old_saddr;
410   xfrm_address_t new_saddr;
411   __be16 old_sport;
412   __be16 new_sport;
413 };
414 struct xfrm_address_filter {
415   xfrm_address_t saddr;
416   xfrm_address_t daddr;
417   __u16 family;
418   __u8 splen;
419   __u8 dplen;
420 };
421 struct xfrm_user_offload {
422   int ifindex;
423   __u8 flags;
424 };
425 #define XFRM_OFFLOAD_IPV6 1
426 #define XFRM_OFFLOAD_INBOUND 2
427 #define XFRM_OFFLOAD_PACKET 4
428 struct xfrm_userpolicy_default {
429 #define XFRM_USERPOLICY_UNSPEC 0
430 #define XFRM_USERPOLICY_BLOCK 1
431 #define XFRM_USERPOLICY_ACCEPT 2
432   __u8 in;
433   __u8 fwd;
434   __u8 out;
435 };
436 #define XFRMGRP_ACQUIRE 1
437 #define XFRMGRP_EXPIRE 2
438 #define XFRMGRP_SA 4
439 #define XFRMGRP_POLICY 8
440 #define XFRMGRP_REPORT 0x20
441 enum xfrm_nlgroups {
442   XFRMNLGRP_NONE,
443 #define XFRMNLGRP_NONE XFRMNLGRP_NONE
444   XFRMNLGRP_ACQUIRE,
445 #define XFRMNLGRP_ACQUIRE XFRMNLGRP_ACQUIRE
446   XFRMNLGRP_EXPIRE,
447 #define XFRMNLGRP_EXPIRE XFRMNLGRP_EXPIRE
448   XFRMNLGRP_SA,
449 #define XFRMNLGRP_SA XFRMNLGRP_SA
450   XFRMNLGRP_POLICY,
451 #define XFRMNLGRP_POLICY XFRMNLGRP_POLICY
452   XFRMNLGRP_AEVENTS,
453 #define XFRMNLGRP_AEVENTS XFRMNLGRP_AEVENTS
454   XFRMNLGRP_REPORT,
455 #define XFRMNLGRP_REPORT XFRMNLGRP_REPORT
456   XFRMNLGRP_MIGRATE,
457 #define XFRMNLGRP_MIGRATE XFRMNLGRP_MIGRATE
458   XFRMNLGRP_MAPPING,
459 #define XFRMNLGRP_MAPPING XFRMNLGRP_MAPPING
460   __XFRMNLGRP_MAX
461 };
462 #define XFRMNLGRP_MAX (__XFRMNLGRP_MAX - 1)
463 #endif
464