/include/linux/xfrm.h

https://github.com/airy09/android_kernel_sony_apq8064 · C Header · 504 lines · 411 code · 69 blank · 24 comment · 0 complexity · b9b0569f78eaca86dae6de573c6eba53 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. struct xfrm_replay_state_esn {
  74. unsigned int bmp_len;
  75. __u32 oseq;
  76. __u32 seq;
  77. __u32 oseq_hi;
  78. __u32 seq_hi;
  79. __u32 replay_window;
  80. __u32 bmp[0];
  81. };
  82. struct xfrm_algo {
  83. char alg_name[64];
  84. unsigned int alg_key_len; /* in bits */
  85. char alg_key[0];
  86. };
  87. struct xfrm_algo_auth {
  88. char alg_name[64];
  89. unsigned int alg_key_len; /* in bits */
  90. unsigned int alg_trunc_len; /* in bits */
  91. char alg_key[0];
  92. };
  93. struct xfrm_algo_aead {
  94. char alg_name[64];
  95. unsigned int alg_key_len; /* in bits */
  96. unsigned int alg_icv_len; /* in bits */
  97. char alg_key[0];
  98. };
  99. struct xfrm_stats {
  100. __u32 replay_window;
  101. __u32 replay;
  102. __u32 integrity_failed;
  103. };
  104. enum {
  105. XFRM_POLICY_TYPE_MAIN = 0,
  106. XFRM_POLICY_TYPE_SUB = 1,
  107. XFRM_POLICY_TYPE_MAX = 2,
  108. XFRM_POLICY_TYPE_ANY = 255
  109. };
  110. enum {
  111. XFRM_POLICY_IN = 0,
  112. XFRM_POLICY_OUT = 1,
  113. XFRM_POLICY_FWD = 2,
  114. XFRM_POLICY_MASK = 3,
  115. XFRM_POLICY_MAX = 3
  116. };
  117. enum {
  118. XFRM_SHARE_ANY, /* No limitations */
  119. XFRM_SHARE_SESSION, /* For this session only */
  120. XFRM_SHARE_USER, /* For this user only */
  121. XFRM_SHARE_UNIQUE /* Use once */
  122. };
  123. #define XFRM_MODE_TRANSPORT 0
  124. #define XFRM_MODE_TUNNEL 1
  125. #define XFRM_MODE_ROUTEOPTIMIZATION 2
  126. #define XFRM_MODE_IN_TRIGGER 3
  127. #define XFRM_MODE_BEET 4
  128. #define XFRM_MODE_MAX 5
  129. /* Netlink configuration messages. */
  130. enum {
  131. XFRM_MSG_BASE = 0x10,
  132. XFRM_MSG_NEWSA = 0x10,
  133. #define XFRM_MSG_NEWSA XFRM_MSG_NEWSA
  134. XFRM_MSG_DELSA,
  135. #define XFRM_MSG_DELSA XFRM_MSG_DELSA
  136. XFRM_MSG_GETSA,
  137. #define XFRM_MSG_GETSA XFRM_MSG_GETSA
  138. XFRM_MSG_NEWPOLICY,
  139. #define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY
  140. XFRM_MSG_DELPOLICY,
  141. #define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY
  142. XFRM_MSG_GETPOLICY,
  143. #define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY
  144. XFRM_MSG_ALLOCSPI,
  145. #define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI
  146. XFRM_MSG_ACQUIRE,
  147. #define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE
  148. XFRM_MSG_EXPIRE,
  149. #define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE
  150. XFRM_MSG_UPDPOLICY,
  151. #define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY
  152. XFRM_MSG_UPDSA,
  153. #define XFRM_MSG_UPDSA XFRM_MSG_UPDSA
  154. XFRM_MSG_POLEXPIRE,
  155. #define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE
  156. XFRM_MSG_FLUSHSA,
  157. #define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA
  158. XFRM_MSG_FLUSHPOLICY,
  159. #define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY
  160. XFRM_MSG_NEWAE,
  161. #define XFRM_MSG_NEWAE XFRM_MSG_NEWAE
  162. XFRM_MSG_GETAE,
  163. #define XFRM_MSG_GETAE XFRM_MSG_GETAE
  164. XFRM_MSG_REPORT,
  165. #define XFRM_MSG_REPORT XFRM_MSG_REPORT
  166. XFRM_MSG_MIGRATE,
  167. #define XFRM_MSG_MIGRATE XFRM_MSG_MIGRATE
  168. XFRM_MSG_NEWSADINFO,
  169. #define XFRM_MSG_NEWSADINFO XFRM_MSG_NEWSADINFO
  170. XFRM_MSG_GETSADINFO,
  171. #define XFRM_MSG_GETSADINFO XFRM_MSG_GETSADINFO
  172. XFRM_MSG_NEWSPDINFO,
  173. #define XFRM_MSG_NEWSPDINFO XFRM_MSG_NEWSPDINFO
  174. XFRM_MSG_GETSPDINFO,
  175. #define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
  176. XFRM_MSG_MAPPING,
  177. #define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
  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. /*
  183. * Generic LSM security context for comunicating to user space
  184. * NOTE: Same format as sadb_x_sec_ctx
  185. */
  186. struct xfrm_user_sec_ctx {
  187. __u16 len;
  188. __u16 exttype;
  189. __u8 ctx_alg; /* LSMs: e.g., selinux == 1 */
  190. __u8 ctx_doi;
  191. __u16 ctx_len;
  192. };
  193. struct xfrm_user_tmpl {
  194. struct xfrm_id id;
  195. __u16 family;
  196. xfrm_address_t saddr;
  197. __u32 reqid;
  198. __u8 mode;
  199. __u8 share;
  200. __u8 optional;
  201. __u32 aalgos;
  202. __u32 ealgos;
  203. __u32 calgos;
  204. };
  205. struct xfrm_encap_tmpl {
  206. __u16 encap_type;
  207. __be16 encap_sport;
  208. __be16 encap_dport;
  209. xfrm_address_t encap_oa;
  210. };
  211. /* AEVENT flags */
  212. enum xfrm_ae_ftype_t {
  213. XFRM_AE_UNSPEC,
  214. XFRM_AE_RTHR=1, /* replay threshold*/
  215. XFRM_AE_RVAL=2, /* replay value */
  216. XFRM_AE_LVAL=4, /* lifetime value */
  217. XFRM_AE_ETHR=8, /* expiry timer threshold */
  218. XFRM_AE_CR=16, /* Event cause is replay update */
  219. XFRM_AE_CE=32, /* Event cause is timer expiry */
  220. XFRM_AE_CU=64, /* Event cause is policy update */
  221. __XFRM_AE_MAX
  222. #define XFRM_AE_MAX (__XFRM_AE_MAX - 1)
  223. };
  224. struct xfrm_userpolicy_type {
  225. __u8 type;
  226. __u16 reserved1;
  227. __u8 reserved2;
  228. };
  229. /* Netlink message attributes. */
  230. enum xfrm_attr_type_t {
  231. XFRMA_UNSPEC,
  232. XFRMA_ALG_AUTH, /* struct xfrm_algo */
  233. XFRMA_ALG_CRYPT, /* struct xfrm_algo */
  234. XFRMA_ALG_COMP, /* struct xfrm_algo */
  235. XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */
  236. XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */
  237. XFRMA_SA, /* struct xfrm_usersa_info */
  238. XFRMA_POLICY, /*struct xfrm_userpolicy_info */
  239. XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */
  240. XFRMA_LTIME_VAL,
  241. XFRMA_REPLAY_VAL,
  242. XFRMA_REPLAY_THRESH,
  243. XFRMA_ETIMER_THRESH,
  244. XFRMA_SRCADDR, /* xfrm_address_t */
  245. XFRMA_COADDR, /* xfrm_address_t */
  246. XFRMA_LASTUSED, /* unsigned long */
  247. XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */
  248. XFRMA_MIGRATE,
  249. XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */
  250. XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */
  251. XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */
  252. XFRMA_MARK, /* struct xfrm_mark */
  253. XFRMA_TFCPAD, /* __u32 */
  254. XFRMA_REPLAY_ESN_VAL, /* struct xfrm_replay_esn */
  255. __XFRMA_MAX
  256. #define XFRMA_MAX (__XFRMA_MAX - 1)
  257. };
  258. struct xfrm_mark {
  259. __u32 v; /* value */
  260. __u32 m; /* mask */
  261. };
  262. enum xfrm_sadattr_type_t {
  263. XFRMA_SAD_UNSPEC,
  264. XFRMA_SAD_CNT,
  265. XFRMA_SAD_HINFO,
  266. __XFRMA_SAD_MAX
  267. #define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1)
  268. };
  269. struct xfrmu_sadhinfo {
  270. __u32 sadhcnt; /* current hash bkts */
  271. __u32 sadhmcnt; /* max allowed hash bkts */
  272. };
  273. enum xfrm_spdattr_type_t {
  274. XFRMA_SPD_UNSPEC,
  275. XFRMA_SPD_INFO,
  276. XFRMA_SPD_HINFO,
  277. __XFRMA_SPD_MAX
  278. #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1)
  279. };
  280. struct xfrmu_spdinfo {
  281. __u32 incnt;
  282. __u32 outcnt;
  283. __u32 fwdcnt;
  284. __u32 inscnt;
  285. __u32 outscnt;
  286. __u32 fwdscnt;
  287. };
  288. struct xfrmu_spdhinfo {
  289. __u32 spdhcnt;
  290. __u32 spdhmcnt;
  291. };
  292. struct xfrm_usersa_info {
  293. struct xfrm_selector sel;
  294. struct xfrm_id id;
  295. xfrm_address_t saddr;
  296. struct xfrm_lifetime_cfg lft;
  297. struct xfrm_lifetime_cur curlft;
  298. struct xfrm_stats stats;
  299. __u32 seq;
  300. __u32 reqid;
  301. __u16 family;
  302. __u8 mode; /* XFRM_MODE_xxx */
  303. __u8 replay_window;
  304. __u8 flags;
  305. #define XFRM_STATE_NOECN 1
  306. #define XFRM_STATE_DECAP_DSCP 2
  307. #define XFRM_STATE_NOPMTUDISC 4
  308. #define XFRM_STATE_WILDRECV 8
  309. #define XFRM_STATE_ICMP 16
  310. #define XFRM_STATE_AF_UNSPEC 32
  311. #define XFRM_STATE_ALIGN4 64
  312. #define XFRM_STATE_ESN 128
  313. };
  314. struct xfrm_usersa_id {
  315. xfrm_address_t daddr;
  316. __be32 spi;
  317. __u16 family;
  318. __u8 proto;
  319. };
  320. struct xfrm_aevent_id {
  321. struct xfrm_usersa_id sa_id;
  322. xfrm_address_t saddr;
  323. __u32 flags;
  324. __u32 reqid;
  325. };
  326. struct xfrm_userspi_info {
  327. struct xfrm_usersa_info info;
  328. __u32 min;
  329. __u32 max;
  330. };
  331. struct xfrm_userpolicy_info {
  332. struct xfrm_selector sel;
  333. struct xfrm_lifetime_cfg lft;
  334. struct xfrm_lifetime_cur curlft;
  335. __u32 priority;
  336. __u32 index;
  337. __u8 dir;
  338. __u8 action;
  339. #define XFRM_POLICY_ALLOW 0
  340. #define XFRM_POLICY_BLOCK 1
  341. __u8 flags;
  342. #define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */
  343. /* Automatically expand selector to include matching ICMP payloads. */
  344. #define XFRM_POLICY_ICMP 2
  345. __u8 share;
  346. };
  347. struct xfrm_userpolicy_id {
  348. struct xfrm_selector sel;
  349. __u32 index;
  350. __u8 dir;
  351. };
  352. struct xfrm_user_acquire {
  353. struct xfrm_id id;
  354. xfrm_address_t saddr;
  355. struct xfrm_selector sel;
  356. struct xfrm_userpolicy_info policy;
  357. __u32 aalgos;
  358. __u32 ealgos;
  359. __u32 calgos;
  360. __u32 seq;
  361. };
  362. struct xfrm_user_expire {
  363. struct xfrm_usersa_info state;
  364. __u8 hard;
  365. };
  366. struct xfrm_user_polexpire {
  367. struct xfrm_userpolicy_info pol;
  368. __u8 hard;
  369. };
  370. struct xfrm_usersa_flush {
  371. __u8 proto;
  372. };
  373. struct xfrm_user_report {
  374. __u8 proto;
  375. struct xfrm_selector sel;
  376. };
  377. /* Used by MIGRATE to pass addresses IKE should use to perform
  378. * SA negotiation with the peer */
  379. struct xfrm_user_kmaddress {
  380. xfrm_address_t local;
  381. xfrm_address_t remote;
  382. __u32 reserved;
  383. __u16 family;
  384. };
  385. struct xfrm_user_migrate {
  386. xfrm_address_t old_daddr;
  387. xfrm_address_t old_saddr;
  388. xfrm_address_t new_daddr;
  389. xfrm_address_t new_saddr;
  390. __u8 proto;
  391. __u8 mode;
  392. __u16 reserved;
  393. __u32 reqid;
  394. __u16 old_family;
  395. __u16 new_family;
  396. };
  397. struct xfrm_user_mapping {
  398. struct xfrm_usersa_id id;
  399. __u32 reqid;
  400. xfrm_address_t old_saddr;
  401. xfrm_address_t new_saddr;
  402. __be16 old_sport;
  403. __be16 new_sport;
  404. };
  405. #ifndef __KERNEL__
  406. /* backwards compatibility for userspace */
  407. #define XFRMGRP_ACQUIRE 1
  408. #define XFRMGRP_EXPIRE 2
  409. #define XFRMGRP_SA 4
  410. #define XFRMGRP_POLICY 8
  411. #define XFRMGRP_REPORT 0x20
  412. #endif
  413. enum xfrm_nlgroups {
  414. XFRMNLGRP_NONE,
  415. #define XFRMNLGRP_NONE XFRMNLGRP_NONE
  416. XFRMNLGRP_ACQUIRE,
  417. #define XFRMNLGRP_ACQUIRE XFRMNLGRP_ACQUIRE
  418. XFRMNLGRP_EXPIRE,
  419. #define XFRMNLGRP_EXPIRE XFRMNLGRP_EXPIRE
  420. XFRMNLGRP_SA,
  421. #define XFRMNLGRP_SA XFRMNLGRP_SA
  422. XFRMNLGRP_POLICY,
  423. #define XFRMNLGRP_POLICY XFRMNLGRP_POLICY
  424. XFRMNLGRP_AEVENTS,
  425. #define XFRMNLGRP_AEVENTS XFRMNLGRP_AEVENTS
  426. XFRMNLGRP_REPORT,
  427. #define XFRMNLGRP_REPORT XFRMNLGRP_REPORT
  428. XFRMNLGRP_MIGRATE,
  429. #define XFRMNLGRP_MIGRATE XFRMNLGRP_MIGRATE
  430. XFRMNLGRP_MAPPING,
  431. #define XFRMNLGRP_MAPPING XFRMNLGRP_MAPPING
  432. __XFRMNLGRP_MAX
  433. };
  434. #define XFRMNLGRP_MAX (__XFRMNLGRP_MAX - 1)
  435. #endif /* _LINUX_XFRM_H */