PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/include/uapi/linux/xfrm.h

https://gitlab.com/webhaikal/SenseiOneplus3
C Header | 526 lines | 429 code | 73 blank | 24 comment | 0 complexity | f2fbfaee3520b5c15f26fff8a7a488bb MD5 | raw file
  1. #ifndef _LINUX_XFRM_H
  2. #define _LINUX_XFRM_H
  3. #include <linux/types.h>
  4. /* All of the structures in this file may not change size as they are
  5. * passed into the kernel from userspace via netlink sockets.
  6. */
  7. /* Structure to encapsulate addresses. I do not want to use
  8. * "standard" structure. My apologies.
  9. */
  10. typedef union {
  11. __be32 a4;
  12. __be32 a6[4];
  13. } xfrm_address_t;
  14. /* Ident of a specific xfrm_state. It is used on input to lookup
  15. * the state by (spi,daddr,ah/esp) or to store information about
  16. * spi, protocol and tunnel address on output.
  17. */
  18. struct xfrm_id {
  19. xfrm_address_t daddr;
  20. __be32 spi;
  21. __u8 proto;
  22. };
  23. struct xfrm_sec_ctx {
  24. __u8 ctx_doi;
  25. __u8 ctx_alg;
  26. __u16 ctx_len;
  27. __u32 ctx_sid;
  28. char ctx_str[0];
  29. };
  30. /* Security Context Domains of Interpretation */
  31. #define XFRM_SC_DOI_RESERVED 0
  32. #define XFRM_SC_DOI_LSM 1
  33. /* Security Context Algorithms */
  34. #define XFRM_SC_ALG_RESERVED 0
  35. #define XFRM_SC_ALG_SELINUX 1
  36. /* Selector, used as selector both on policy rules (SPD) and SAs. */
  37. struct xfrm_selector {
  38. xfrm_address_t daddr;
  39. xfrm_address_t saddr;
  40. __be16 dport;
  41. __be16 dport_mask;
  42. __be16 sport;
  43. __be16 sport_mask;
  44. __u16 family;
  45. __u8 prefixlen_d;
  46. __u8 prefixlen_s;
  47. __u8 proto;
  48. int ifindex;
  49. __kernel_uid32_t user;
  50. };
  51. #define XFRM_INF (~(__u64)0)
  52. struct xfrm_lifetime_cfg {
  53. __u64 soft_byte_limit;
  54. __u64 hard_byte_limit;
  55. __u64 soft_packet_limit;
  56. __u64 hard_packet_limit;
  57. __u64 soft_add_expires_seconds;
  58. __u64 hard_add_expires_seconds;
  59. __u64 soft_use_expires_seconds;
  60. __u64 hard_use_expires_seconds;
  61. };
  62. struct xfrm_lifetime_cur {
  63. __u64 bytes;
  64. __u64 packets;
  65. __u64 add_time;
  66. __u64 use_time;
  67. };
  68. struct xfrm_replay_state {
  69. __u32 oseq;
  70. __u32 seq;
  71. __u32 bitmap;
  72. };
  73. #define XFRMA_REPLAY_ESN_MAX 4096
  74. struct xfrm_replay_state_esn {
  75. unsigned int bmp_len;
  76. __u32 oseq;
  77. __u32 seq;
  78. __u32 oseq_hi;
  79. __u32 seq_hi;
  80. __u32 replay_window;
  81. __u32 bmp[0];
  82. };
  83. struct xfrm_algo {
  84. char alg_name[64];
  85. unsigned int alg_key_len; /* in bits */
  86. char alg_key[0];
  87. };
  88. struct xfrm_algo_auth {
  89. char alg_name[64];
  90. unsigned int alg_key_len; /* in bits */
  91. unsigned int alg_trunc_len; /* in bits */
  92. char alg_key[0];
  93. };
  94. struct xfrm_algo_aead {
  95. char alg_name[64];
  96. unsigned int alg_key_len; /* in bits */
  97. unsigned int alg_icv_len; /* in bits */
  98. char alg_key[0];
  99. };
  100. struct xfrm_stats {
  101. __u32 replay_window;
  102. __u32 replay;
  103. __u32 integrity_failed;
  104. };
  105. enum {
  106. XFRM_POLICY_TYPE_MAIN = 0,
  107. XFRM_POLICY_TYPE_SUB = 1,
  108. XFRM_POLICY_TYPE_MAX = 2,
  109. XFRM_POLICY_TYPE_ANY = 255
  110. };
  111. enum {
  112. XFRM_POLICY_IN = 0,
  113. XFRM_POLICY_OUT = 1,
  114. XFRM_POLICY_FWD = 2,
  115. XFRM_POLICY_MASK = 3,
  116. XFRM_POLICY_MAX = 3
  117. };
  118. enum {
  119. XFRM_SHARE_ANY, /* No limitations */
  120. XFRM_SHARE_SESSION, /* For this session only */
  121. XFRM_SHARE_USER, /* For this user only */
  122. XFRM_SHARE_UNIQUE /* Use once */
  123. };
  124. #define XFRM_MODE_TRANSPORT 0
  125. #define XFRM_MODE_TUNNEL 1
  126. #define XFRM_MODE_ROUTEOPTIMIZATION 2
  127. #define XFRM_MODE_IN_TRIGGER 3
  128. #define XFRM_MODE_BEET 4
  129. #define XFRM_MODE_MAX 5
  130. /* Netlink configuration messages. */
  131. enum {
  132. XFRM_MSG_BASE = 0x10,
  133. XFRM_MSG_NEWSA = 0x10,
  134. #define XFRM_MSG_NEWSA XFRM_MSG_NEWSA
  135. XFRM_MSG_DELSA,
  136. #define XFRM_MSG_DELSA XFRM_MSG_DELSA
  137. XFRM_MSG_GETSA,
  138. #define XFRM_MSG_GETSA XFRM_MSG_GETSA
  139. XFRM_MSG_NEWPOLICY,
  140. #define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY
  141. XFRM_MSG_DELPOLICY,
  142. #define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY
  143. XFRM_MSG_GETPOLICY,
  144. #define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY
  145. XFRM_MSG_ALLOCSPI,
  146. #define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI
  147. XFRM_MSG_ACQUIRE,
  148. #define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE
  149. XFRM_MSG_EXPIRE,
  150. #define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE
  151. XFRM_MSG_UPDPOLICY,
  152. #define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY
  153. XFRM_MSG_UPDSA,
  154. #define XFRM_MSG_UPDSA XFRM_MSG_UPDSA
  155. XFRM_MSG_POLEXPIRE,
  156. #define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE
  157. XFRM_MSG_FLUSHSA,
  158. #define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA
  159. XFRM_MSG_FLUSHPOLICY,
  160. #define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
  161. XFRM_MSG_NEWAE,
  162. #define XFRM_MSG_NEWAE XFRM_MSG_NEWAE
  163. XFRM_MSG_GETAE,
  164. #define XFRM_MSG_GETAE XFRM_MSG_GETAE
  165. XFRM_MSG_REPORT,
  166. #define XFRM_MSG_REPORT XFRM_MSG_REPORT
  167. XFRM_MSG_MIGRATE,
  168. #define XFRM_MSG_MIGRATE XFRM_MSG_MIGRATE
  169. XFRM_MSG_NEWSADINFO,
  170. #define XFRM_MSG_NEWSADINFO XFRM_MSG_NEWSADINFO
  171. XFRM_MSG_GETSADINFO,
  172. #define XFRM_MSG_GETSADINFO XFRM_MSG_GETSADINFO
  173. XFRM_MSG_NEWSPDINFO,
  174. #define XFRM_MSG_NEWSPDINFO XFRM_MSG_NEWSPDINFO
  175. XFRM_MSG_GETSPDINFO,
  176. #define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
  177. XFRM_MSG_MAPPING,
  178. #define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
  179. __XFRM_MSG_MAX
  180. };
  181. #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
  182. #define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)
  183. /*
  184. * Generic LSM security context for comunicating to user space
  185. * NOTE: Same format as sadb_x_sec_ctx
  186. */
  187. struct xfrm_user_sec_ctx {
  188. __u16 len;
  189. __u16 exttype;
  190. __u8 ctx_alg; /* LSMs: e.g., selinux == 1 */
  191. __u8 ctx_doi;
  192. __u16 ctx_len;
  193. };
  194. struct xfrm_user_tmpl {
  195. struct xfrm_id id;
  196. __u16 family;
  197. xfrm_address_t saddr;
  198. __u32 reqid;
  199. __u8 mode;
  200. __u8 share;
  201. __u8 optional;
  202. __u32 aalgos;
  203. __u32 ealgos;
  204. __u32 calgos;
  205. };
  206. struct xfrm_encap_tmpl {
  207. __u16 encap_type;
  208. __be16 encap_sport;
  209. __be16 encap_dport;
  210. xfrm_address_t encap_oa;
  211. };
  212. /* AEVENT flags */
  213. enum xfrm_ae_ftype_t {
  214. XFRM_AE_UNSPEC,
  215. XFRM_AE_RTHR=1, /* replay threshold*/
  216. XFRM_AE_RVAL=2, /* replay value */
  217. XFRM_AE_LVAL=4, /* lifetime value */
  218. XFRM_AE_ETHR=8, /* expiry timer threshold */
  219. XFRM_AE_CR=16, /* Event cause is replay update */
  220. XFRM_AE_CE=32, /* Event cause is timer expiry */
  221. XFRM_AE_CU=64, /* Event cause is policy update */
  222. __XFRM_AE_MAX
  223. #define XFRM_AE_MAX (__XFRM_AE_MAX - 1)
  224. };
  225. struct xfrm_userpolicy_type {
  226. __u8 type;
  227. __u16 reserved1;
  228. __u8 reserved2;
  229. };
  230. /* Netlink message attributes. */
  231. enum xfrm_attr_type_t {
  232. XFRMA_UNSPEC,
  233. XFRMA_ALG_AUTH, /* struct xfrm_algo */
  234. XFRMA_ALG_CRYPT, /* struct xfrm_algo */
  235. XFRMA_ALG_COMP, /* struct xfrm_algo */
  236. XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */
  237. XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */
  238. XFRMA_SA, /* struct xfrm_usersa_info */
  239. XFRMA_POLICY, /*struct xfrm_userpolicy_info */
  240. XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */
  241. XFRMA_LTIME_VAL,
  242. XFRMA_REPLAY_VAL,
  243. XFRMA_REPLAY_THRESH,
  244. XFRMA_ETIMER_THRESH,
  245. XFRMA_SRCADDR, /* xfrm_address_t */
  246. XFRMA_COADDR, /* xfrm_address_t */
  247. XFRMA_LASTUSED, /* unsigned long */
  248. XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */
  249. XFRMA_MIGRATE,
  250. XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */
  251. XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */
  252. XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */
  253. XFRMA_MARK, /* struct xfrm_mark */
  254. XFRMA_TFCPAD, /* __u32 */
  255. XFRMA_REPLAY_ESN_VAL, /* struct xfrm_replay_esn */
  256. XFRMA_SA_EXTRA_FLAGS, /* __u32 */
  257. XFRMA_PROTO, /* __u8 */
  258. XFRMA_ADDRESS_FILTER, /* struct xfrm_address_filter */
  259. __XFRMA_MAX
  260. #define XFRMA_MAX (__XFRMA_MAX - 1)
  261. };
  262. struct xfrm_mark {
  263. __u32 v; /* value */
  264. __u32 m; /* mask */
  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; /* current hash bkts */
  275. __u32 sadhmcnt; /* max allowed hash bkts */
  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; /* XFRM_MODE_xxx */
  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. struct xfrm_usersa_id {
  326. xfrm_address_t daddr;
  327. __be32 spi;
  328. __u16 family;
  329. __u8 proto;
  330. };
  331. struct xfrm_aevent_id {
  332. struct xfrm_usersa_id sa_id;
  333. xfrm_address_t saddr;
  334. __u32 flags;
  335. __u32 reqid;
  336. };
  337. struct xfrm_userspi_info {
  338. struct xfrm_usersa_info info;
  339. __u32 min;
  340. __u32 max;
  341. };
  342. struct xfrm_userpolicy_info {
  343. struct xfrm_selector sel;
  344. struct xfrm_lifetime_cfg lft;
  345. struct xfrm_lifetime_cur curlft;
  346. __u32 priority;
  347. __u32 index;
  348. __u8 dir;
  349. __u8 action;
  350. #define XFRM_POLICY_ALLOW 0
  351. #define XFRM_POLICY_BLOCK 1
  352. __u8 flags;
  353. #define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */
  354. /* Automatically expand selector to include matching ICMP payloads. */
  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. /* Used by MIGRATE to pass addresses IKE should use to perform
  389. * SA negotiation with the peer */
  390. struct xfrm_user_kmaddress {
  391. xfrm_address_t local;
  392. xfrm_address_t remote;
  393. __u32 reserved;
  394. __u16 family;
  395. };
  396. struct xfrm_user_migrate {
  397. xfrm_address_t old_daddr;
  398. xfrm_address_t old_saddr;
  399. xfrm_address_t new_daddr;
  400. xfrm_address_t new_saddr;
  401. __u8 proto;
  402. __u8 mode;
  403. __u16 reserved;
  404. __u32 reqid;
  405. __u16 old_family;
  406. __u16 new_family;
  407. };
  408. struct xfrm_user_mapping {
  409. struct xfrm_usersa_id id;
  410. __u32 reqid;
  411. xfrm_address_t old_saddr;
  412. xfrm_address_t new_saddr;
  413. __be16 old_sport;
  414. __be16 new_sport;
  415. };
  416. struct xfrm_address_filter {
  417. xfrm_address_t saddr;
  418. xfrm_address_t daddr;
  419. __u16 family;
  420. __u8 splen;
  421. __u8 dplen;
  422. };
  423. #ifndef __KERNEL__
  424. /* backwards compatibility for userspace */
  425. #define XFRMGRP_ACQUIRE 1
  426. #define XFRMGRP_EXPIRE 2
  427. #define XFRMGRP_SA 4
  428. #define XFRMGRP_POLICY 8
  429. #define XFRMGRP_REPORT 0x20
  430. #endif
  431. enum xfrm_nlgroups {
  432. XFRMNLGRP_NONE,
  433. #define XFRMNLGRP_NONE XFRMNLGRP_NONE
  434. XFRMNLGRP_ACQUIRE,
  435. #define XFRMNLGRP_ACQUIRE XFRMNLGRP_ACQUIRE
  436. XFRMNLGRP_EXPIRE,
  437. #define XFRMNLGRP_EXPIRE XFRMNLGRP_EXPIRE
  438. XFRMNLGRP_SA,
  439. #define XFRMNLGRP_SA XFRMNLGRP_SA
  440. XFRMNLGRP_POLICY,
  441. #define XFRMNLGRP_POLICY XFRMNLGRP_POLICY
  442. XFRMNLGRP_AEVENTS,
  443. #define XFRMNLGRP_AEVENTS XFRMNLGRP_AEVENTS
  444. XFRMNLGRP_REPORT,
  445. #define XFRMNLGRP_REPORT XFRMNLGRP_REPORT
  446. XFRMNLGRP_MIGRATE,
  447. #define XFRMNLGRP_MIGRATE XFRMNLGRP_MIGRATE
  448. XFRMNLGRP_MAPPING,
  449. #define XFRMNLGRP_MAPPING XFRMNLGRP_MAPPING
  450. __XFRMNLGRP_MAX
  451. };
  452. #define XFRMNLGRP_MAX (__XFRMNLGRP_MAX - 1)
  453. #endif /* _LINUX_XFRM_H */