pfkeyv2.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /* PF_KEY user interface, this is defined by rfc2367 so
  3. * do not make arbitrary modifications or else this header
  4. * file will not be compliant.
  5. */
  6. #ifndef _LINUX_PFKEY2_H
  7. #define _LINUX_PFKEY2_H
  8. #include <linux/types.h>
  9. #define PF_KEY_V2 2
  10. #define PFKEYV2_REVISION 199806L
  11. struct sadb_msg {
  12. __u8 sadb_msg_version;
  13. __u8 sadb_msg_type;
  14. __u8 sadb_msg_errno;
  15. __u8 sadb_msg_satype;
  16. __u16 sadb_msg_len;
  17. __u16 sadb_msg_reserved;
  18. __u32 sadb_msg_seq;
  19. __u32 sadb_msg_pid;
  20. } __attribute__((packed));
  21. /* sizeof(struct sadb_msg) == 16 */
  22. struct sadb_ext {
  23. __u16 sadb_ext_len;
  24. __u16 sadb_ext_type;
  25. } __attribute__((packed));
  26. /* sizeof(struct sadb_ext) == 4 */
  27. struct sadb_sa {
  28. __u16 sadb_sa_len;
  29. __u16 sadb_sa_exttype;
  30. __be32 sadb_sa_spi;
  31. __u8 sadb_sa_replay;
  32. __u8 sadb_sa_state;
  33. __u8 sadb_sa_auth;
  34. __u8 sadb_sa_encrypt;
  35. __u32 sadb_sa_flags;
  36. } __attribute__((packed));
  37. /* sizeof(struct sadb_sa) == 16 */
  38. struct sadb_lifetime {
  39. __u16 sadb_lifetime_len;
  40. __u16 sadb_lifetime_exttype;
  41. __u32 sadb_lifetime_allocations;
  42. __u64 sadb_lifetime_bytes;
  43. __u64 sadb_lifetime_addtime;
  44. __u64 sadb_lifetime_usetime;
  45. } __attribute__((packed));
  46. /* sizeof(struct sadb_lifetime) == 32 */
  47. struct sadb_address {
  48. __u16 sadb_address_len;
  49. __u16 sadb_address_exttype;
  50. __u8 sadb_address_proto;
  51. __u8 sadb_address_prefixlen;
  52. __u16 sadb_address_reserved;
  53. } __attribute__((packed));
  54. /* sizeof(struct sadb_address) == 8 */
  55. struct sadb_key {
  56. __u16 sadb_key_len;
  57. __u16 sadb_key_exttype;
  58. __u16 sadb_key_bits;
  59. __u16 sadb_key_reserved;
  60. } __attribute__((packed));
  61. /* sizeof(struct sadb_key) == 8 */
  62. struct sadb_ident {
  63. __u16 sadb_ident_len;
  64. __u16 sadb_ident_exttype;
  65. __u16 sadb_ident_type;
  66. __u16 sadb_ident_reserved;
  67. __u64 sadb_ident_id;
  68. } __attribute__((packed));
  69. /* sizeof(struct sadb_ident) == 16 */
  70. struct sadb_sens {
  71. __u16 sadb_sens_len;
  72. __u16 sadb_sens_exttype;
  73. __u32 sadb_sens_dpd;
  74. __u8 sadb_sens_sens_level;
  75. __u8 sadb_sens_sens_len;
  76. __u8 sadb_sens_integ_level;
  77. __u8 sadb_sens_integ_len;
  78. __u32 sadb_sens_reserved;
  79. } __attribute__((packed));
  80. /* sizeof(struct sadb_sens) == 16 */
  81. /* followed by:
  82. __u64 sadb_sens_bitmap[sens_len];
  83. __u64 sadb_integ_bitmap[integ_len]; */
  84. struct sadb_prop {
  85. __u16 sadb_prop_len;
  86. __u16 sadb_prop_exttype;
  87. __u8 sadb_prop_replay;
  88. __u8 sadb_prop_reserved[3];
  89. } __attribute__((packed));
  90. /* sizeof(struct sadb_prop) == 8 */
  91. /* followed by:
  92. struct sadb_comb sadb_combs[(sadb_prop_len +
  93. sizeof(__u64) - sizeof(struct sadb_prop)) /
  94. sizeof(struct sadb_comb)]; */
  95. struct sadb_comb {
  96. __u8 sadb_comb_auth;
  97. __u8 sadb_comb_encrypt;
  98. __u16 sadb_comb_flags;
  99. __u16 sadb_comb_auth_minbits;
  100. __u16 sadb_comb_auth_maxbits;
  101. __u16 sadb_comb_encrypt_minbits;
  102. __u16 sadb_comb_encrypt_maxbits;
  103. __u32 sadb_comb_reserved;
  104. __u32 sadb_comb_soft_allocations;
  105. __u32 sadb_comb_hard_allocations;
  106. __u64 sadb_comb_soft_bytes;
  107. __u64 sadb_comb_hard_bytes;
  108. __u64 sadb_comb_soft_addtime;
  109. __u64 sadb_comb_hard_addtime;
  110. __u64 sadb_comb_soft_usetime;
  111. __u64 sadb_comb_hard_usetime;
  112. } __attribute__((packed));
  113. /* sizeof(struct sadb_comb) == 72 */
  114. struct sadb_supported {
  115. __u16 sadb_supported_len;
  116. __u16 sadb_supported_exttype;
  117. __u32 sadb_supported_reserved;
  118. } __attribute__((packed));
  119. /* sizeof(struct sadb_supported) == 8 */
  120. /* followed by:
  121. struct sadb_alg sadb_algs[(sadb_supported_len +
  122. sizeof(__u64) - sizeof(struct sadb_supported)) /
  123. sizeof(struct sadb_alg)]; */
  124. struct sadb_alg {
  125. __u8 sadb_alg_id;
  126. __u8 sadb_alg_ivlen;
  127. __u16 sadb_alg_minbits;
  128. __u16 sadb_alg_maxbits;
  129. __u16 sadb_alg_reserved;
  130. } __attribute__((packed));
  131. /* sizeof(struct sadb_alg) == 8 */
  132. struct sadb_spirange {
  133. __u16 sadb_spirange_len;
  134. __u16 sadb_spirange_exttype;
  135. __u32 sadb_spirange_min;
  136. __u32 sadb_spirange_max;
  137. __u32 sadb_spirange_reserved;
  138. } __attribute__((packed));
  139. /* sizeof(struct sadb_spirange) == 16 */
  140. struct sadb_x_kmprivate {
  141. __u16 sadb_x_kmprivate_len;
  142. __u16 sadb_x_kmprivate_exttype;
  143. __u32 sadb_x_kmprivate_reserved;
  144. } __attribute__((packed));
  145. /* sizeof(struct sadb_x_kmprivate) == 8 */
  146. struct sadb_x_sa2 {
  147. __u16 sadb_x_sa2_len;
  148. __u16 sadb_x_sa2_exttype;
  149. __u8 sadb_x_sa2_mode;
  150. __u8 sadb_x_sa2_reserved1;
  151. __u16 sadb_x_sa2_reserved2;
  152. __u32 sadb_x_sa2_sequence;
  153. __u32 sadb_x_sa2_reqid;
  154. } __attribute__((packed));
  155. /* sizeof(struct sadb_x_sa2) == 16 */
  156. struct sadb_x_policy {
  157. __u16 sadb_x_policy_len;
  158. __u16 sadb_x_policy_exttype;
  159. __u16 sadb_x_policy_type;
  160. __u8 sadb_x_policy_dir;
  161. __u8 sadb_x_policy_reserved;
  162. __u32 sadb_x_policy_id;
  163. __u32 sadb_x_policy_priority;
  164. } __attribute__((packed));
  165. /* sizeof(struct sadb_x_policy) == 16 */
  166. struct sadb_x_ipsecrequest {
  167. __u16 sadb_x_ipsecrequest_len;
  168. __u16 sadb_x_ipsecrequest_proto;
  169. __u8 sadb_x_ipsecrequest_mode;
  170. __u8 sadb_x_ipsecrequest_level;
  171. __u16 sadb_x_ipsecrequest_reserved1;
  172. __u32 sadb_x_ipsecrequest_reqid;
  173. __u32 sadb_x_ipsecrequest_reserved2;
  174. } __attribute__((packed));
  175. /* sizeof(struct sadb_x_ipsecrequest) == 16 */
  176. /* This defines the TYPE of Nat Traversal in use. Currently only one
  177. * type of NAT-T is supported, draft-ietf-ipsec-udp-encaps-06
  178. */
  179. struct sadb_x_nat_t_type {
  180. __u16 sadb_x_nat_t_type_len;
  181. __u16 sadb_x_nat_t_type_exttype;
  182. __u8 sadb_x_nat_t_type_type;
  183. __u8 sadb_x_nat_t_type_reserved[3];
  184. } __attribute__((packed));
  185. /* sizeof(struct sadb_x_nat_t_type) == 8 */
  186. /* Pass a NAT Traversal port (Source or Dest port) */
  187. struct sadb_x_nat_t_port {
  188. __u16 sadb_x_nat_t_port_len;
  189. __u16 sadb_x_nat_t_port_exttype;
  190. __be16 sadb_x_nat_t_port_port;
  191. __u16 sadb_x_nat_t_port_reserved;
  192. } __attribute__((packed));
  193. /* sizeof(struct sadb_x_nat_t_port) == 8 */
  194. /* Generic LSM security context */
  195. struct sadb_x_sec_ctx {
  196. __u16 sadb_x_sec_len;
  197. __u16 sadb_x_sec_exttype;
  198. __u8 sadb_x_ctx_alg; /* LSMs: e.g., selinux == 1 */
  199. __u8 sadb_x_ctx_doi;
  200. __u16 sadb_x_ctx_len;
  201. } __attribute__((packed));
  202. /* sizeof(struct sadb_sec_ctx) = 8 */
  203. /* Used by MIGRATE to pass addresses IKE will use to perform
  204. * negotiation with the peer */
  205. struct sadb_x_kmaddress {
  206. __u16 sadb_x_kmaddress_len;
  207. __u16 sadb_x_kmaddress_exttype;
  208. __u32 sadb_x_kmaddress_reserved;
  209. } __attribute__((packed));
  210. /* sizeof(struct sadb_x_kmaddress) == 8 */
  211. /* To specify the SA dump filter */
  212. struct sadb_x_filter {
  213. __u16 sadb_x_filter_len;
  214. __u16 sadb_x_filter_exttype;
  215. __u32 sadb_x_filter_saddr[4];
  216. __u32 sadb_x_filter_daddr[4];
  217. __u16 sadb_x_filter_family;
  218. __u8 sadb_x_filter_splen;
  219. __u8 sadb_x_filter_dplen;
  220. } __attribute__((packed));
  221. /* sizeof(struct sadb_x_filter) == 40 */
  222. /* Message types */
  223. #define SADB_RESERVED 0
  224. #define SADB_GETSPI 1
  225. #define SADB_UPDATE 2
  226. #define SADB_ADD 3
  227. #define SADB_DELETE 4
  228. #define SADB_GET 5
  229. #define SADB_ACQUIRE 6
  230. #define SADB_REGISTER 7
  231. #define SADB_EXPIRE 8
  232. #define SADB_FLUSH 9
  233. #define SADB_DUMP 10
  234. #define SADB_X_PROMISC 11
  235. #define SADB_X_PCHANGE 12
  236. #define SADB_X_SPDUPDATE 13
  237. #define SADB_X_SPDADD 14
  238. #define SADB_X_SPDDELETE 15
  239. #define SADB_X_SPDGET 16
  240. #define SADB_X_SPDACQUIRE 17
  241. #define SADB_X_SPDDUMP 18
  242. #define SADB_X_SPDFLUSH 19
  243. #define SADB_X_SPDSETIDX 20
  244. #define SADB_X_SPDEXPIRE 21
  245. #define SADB_X_SPDDELETE2 22
  246. #define SADB_X_NAT_T_NEW_MAPPING 23
  247. #define SADB_X_MIGRATE 24
  248. #define SADB_MAX 24
  249. /* Security Association flags */
  250. #define SADB_SAFLAGS_PFS 1
  251. #define SADB_SAFLAGS_NOPMTUDISC 0x20000000
  252. #define SADB_SAFLAGS_DECAP_DSCP 0x40000000
  253. #define SADB_SAFLAGS_NOECN 0x80000000
  254. /* Security Association states */
  255. #define SADB_SASTATE_LARVAL 0
  256. #define SADB_SASTATE_MATURE 1
  257. #define SADB_SASTATE_DYING 2
  258. #define SADB_SASTATE_DEAD 3
  259. #define SADB_SASTATE_MAX 3
  260. /* Security Association types */
  261. #define SADB_SATYPE_UNSPEC 0
  262. #define SADB_SATYPE_AH 2
  263. #define SADB_SATYPE_ESP 3
  264. #define SADB_SATYPE_RSVP 5
  265. #define SADB_SATYPE_OSPFV2 6
  266. #define SADB_SATYPE_RIPV2 7
  267. #define SADB_SATYPE_MIP 8
  268. #define SADB_X_SATYPE_IPCOMP 9
  269. #define SADB_SATYPE_MAX 9
  270. /* Authentication algorithms */
  271. #define SADB_AALG_NONE 0
  272. #define SADB_AALG_MD5HMAC 2
  273. #define SADB_AALG_SHA1HMAC 3
  274. #define SADB_X_AALG_SHA2_256HMAC 5
  275. #define SADB_X_AALG_SHA2_384HMAC 6
  276. #define SADB_X_AALG_SHA2_512HMAC 7
  277. #define SADB_X_AALG_RIPEMD160HMAC 8
  278. #define SADB_X_AALG_AES_XCBC_MAC 9
  279. #define SADB_X_AALG_NULL 251 /* kame */
  280. #define SADB_AALG_MAX 251
  281. /* Encryption algorithms */
  282. #define SADB_EALG_NONE 0
  283. #define SADB_EALG_DESCBC 2
  284. #define SADB_EALG_3DESCBC 3
  285. #define SADB_X_EALG_CASTCBC 6
  286. #define SADB_X_EALG_BLOWFISHCBC 7
  287. #define SADB_EALG_NULL 11
  288. #define SADB_X_EALG_AESCBC 12
  289. #define SADB_X_EALG_AESCTR 13
  290. #define SADB_X_EALG_AES_CCM_ICV8 14
  291. #define SADB_X_EALG_AES_CCM_ICV12 15
  292. #define SADB_X_EALG_AES_CCM_ICV16 16
  293. #define SADB_X_EALG_AES_GCM_ICV8 18
  294. #define SADB_X_EALG_AES_GCM_ICV12 19
  295. #define SADB_X_EALG_AES_GCM_ICV16 20
  296. #define SADB_X_EALG_CAMELLIACBC 22
  297. #define SADB_X_EALG_NULL_AES_GMAC 23
  298. #define SADB_EALG_MAX 253 /* last EALG */
  299. /* private allocations should use 249-255 (RFC2407) */
  300. #define SADB_X_EALG_SERPENTCBC 252 /* draft-ietf-ipsec-ciph-aes-cbc-00 */
  301. #define SADB_X_EALG_TWOFISHCBC 253 /* draft-ietf-ipsec-ciph-aes-cbc-00 */
  302. /* Compression algorithms */
  303. #define SADB_X_CALG_NONE 0
  304. #define SADB_X_CALG_OUI 1
  305. #define SADB_X_CALG_DEFLATE 2
  306. #define SADB_X_CALG_LZS 3
  307. #define SADB_X_CALG_LZJH 4
  308. #define SADB_X_CALG_MAX 4
  309. /* Extension Header values */
  310. #define SADB_EXT_RESERVED 0
  311. #define SADB_EXT_SA 1
  312. #define SADB_EXT_LIFETIME_CURRENT 2
  313. #define SADB_EXT_LIFETIME_HARD 3
  314. #define SADB_EXT_LIFETIME_SOFT 4
  315. #define SADB_EXT_ADDRESS_SRC 5
  316. #define SADB_EXT_ADDRESS_DST 6
  317. #define SADB_EXT_ADDRESS_PROXY 7
  318. #define SADB_EXT_KEY_AUTH 8
  319. #define SADB_EXT_KEY_ENCRYPT 9
  320. #define SADB_EXT_IDENTITY_SRC 10
  321. #define SADB_EXT_IDENTITY_DST 11
  322. #define SADB_EXT_SENSITIVITY 12
  323. #define SADB_EXT_PROPOSAL 13
  324. #define SADB_EXT_SUPPORTED_AUTH 14
  325. #define SADB_EXT_SUPPORTED_ENCRYPT 15
  326. #define SADB_EXT_SPIRANGE 16
  327. #define SADB_X_EXT_KMPRIVATE 17
  328. #define SADB_X_EXT_POLICY 18
  329. #define SADB_X_EXT_SA2 19
  330. /* The next four entries are for setting up NAT Traversal */
  331. #define SADB_X_EXT_NAT_T_TYPE 20
  332. #define SADB_X_EXT_NAT_T_SPORT 21
  333. #define SADB_X_EXT_NAT_T_DPORT 22
  334. #define SADB_X_EXT_NAT_T_OA 23
  335. #define SADB_X_EXT_SEC_CTX 24
  336. /* Used with MIGRATE to pass @ to IKE for negotiation */
  337. #define SADB_X_EXT_KMADDRESS 25
  338. #define SADB_X_EXT_FILTER 26
  339. #define SADB_EXT_MAX 26
  340. /* Identity Extension values */
  341. #define SADB_IDENTTYPE_RESERVED 0
  342. #define SADB_IDENTTYPE_PREFIX 1
  343. #define SADB_IDENTTYPE_FQDN 2
  344. #define SADB_IDENTTYPE_USERFQDN 3
  345. #define SADB_IDENTTYPE_MAX 3
  346. #endif /* !(_LINUX_PFKEY2_H) */