pfkeyv2.h 10 KB

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