pfkeyv2.h 9.6 KB

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