pfkeyv2.h
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:9k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  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. uint32_t 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(strut 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. u_int32_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. uint16_t 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. /* Message types */
  194. #define SADB_RESERVED 0
  195. #define SADB_GETSPI 1
  196. #define SADB_UPDATE 2
  197. #define SADB_ADD 3
  198. #define SADB_DELETE 4
  199. #define SADB_GET 5
  200. #define SADB_ACQUIRE 6
  201. #define SADB_REGISTER 7
  202. #define SADB_EXPIRE 8
  203. #define SADB_FLUSH 9
  204. #define SADB_DUMP 10
  205. #define SADB_X_PROMISC 11
  206. #define SADB_X_PCHANGE 12
  207. #define SADB_X_SPDUPDATE 13
  208. #define SADB_X_SPDADD 14
  209. #define SADB_X_SPDDELETE 15
  210. #define SADB_X_SPDGET 16
  211. #define SADB_X_SPDACQUIRE 17
  212. #define SADB_X_SPDDUMP 18
  213. #define SADB_X_SPDFLUSH 19
  214. #define SADB_X_SPDSETIDX 20
  215. #define SADB_X_SPDEXPIRE 21
  216. #define SADB_X_SPDDELETE2 22
  217. #define SADB_X_NAT_T_NEW_MAPPING 23
  218. #define SADB_MAX 23
  219. /* Security Association flags */
  220. #define SADB_SAFLAGS_PFS 1
  221. #define SADB_SAFLAGS_NOPMTUDISC 0x20000000
  222. #define SADB_SAFLAGS_DECAP_DSCP 0x40000000
  223. #define SADB_SAFLAGS_NOECN 0x80000000
  224. /* Security Association states */
  225. #define SADB_SASTATE_LARVAL 0
  226. #define SADB_SASTATE_MATURE 1
  227. #define SADB_SASTATE_DYING 2
  228. #define SADB_SASTATE_DEAD 3
  229. #define SADB_SASTATE_MAX 3
  230. /* Security Association types */
  231. #define SADB_SATYPE_UNSPEC 0
  232. #define SADB_SATYPE_AH 2
  233. #define SADB_SATYPE_ESP 3
  234. #define SADB_SATYPE_RSVP 5
  235. #define SADB_SATYPE_OSPFV2 6
  236. #define SADB_SATYPE_RIPV2 7
  237. #define SADB_SATYPE_MIP 8
  238. #define SADB_X_SATYPE_IPCOMP 9
  239. #define SADB_SATYPE_MAX 9
  240. /* Authentication algorithms */
  241. #define SADB_AALG_NONE 0
  242. #define SADB_AALG_MD5HMAC 2
  243. #define SADB_AALG_SHA1HMAC 3
  244. #define SADB_X_AALG_SHA2_256HMAC 5
  245. #define SADB_X_AALG_SHA2_384HMAC 6
  246. #define SADB_X_AALG_SHA2_512HMAC 7
  247. #define SADB_X_AALG_RIPEMD160HMAC 8
  248. #define SADB_X_AALG_NULL 251 /* kame */
  249. #define SADB_AALG_MAX 251
  250. /* Encryption algorithms */
  251. #define SADB_EALG_NONE 0
  252. #define SADB_EALG_DESCBC 2
  253. #define SADB_EALG_3DESCBC 3
  254. #define SADB_X_EALG_CASTCBC 6
  255. #define SADB_X_EALG_BLOWFISHCBC 7
  256. #define SADB_EALG_NULL 11
  257. #define SADB_X_EALG_AESCBC 12
  258. #define SADB_EALG_MAX                   253 /* last EALG */
  259. /* private allocations should use 249-255 (RFC2407) */
  260. #define SADB_X_EALG_SERPENTCBC  252     /* draft-ietf-ipsec-ciph-aes-cbc-00 */
  261. #define SADB_X_EALG_TWOFISHCBC  253     /* draft-ietf-ipsec-ciph-aes-cbc-00 */
  262. /* Compression algorithms */
  263. #define SADB_X_CALG_NONE 0
  264. #define SADB_X_CALG_OUI 1
  265. #define SADB_X_CALG_DEFLATE 2
  266. #define SADB_X_CALG_LZS 3
  267. #define SADB_X_CALG_LZJH 4
  268. #define SADB_X_CALG_MAX 4
  269. /* Extension Header values */
  270. #define SADB_EXT_RESERVED 0
  271. #define SADB_EXT_SA 1
  272. #define SADB_EXT_LIFETIME_CURRENT 2
  273. #define SADB_EXT_LIFETIME_HARD 3
  274. #define SADB_EXT_LIFETIME_SOFT 4
  275. #define SADB_EXT_ADDRESS_SRC 5
  276. #define SADB_EXT_ADDRESS_DST 6
  277. #define SADB_EXT_ADDRESS_PROXY 7
  278. #define SADB_EXT_KEY_AUTH 8
  279. #define SADB_EXT_KEY_ENCRYPT 9
  280. #define SADB_EXT_IDENTITY_SRC 10
  281. #define SADB_EXT_IDENTITY_DST 11
  282. #define SADB_EXT_SENSITIVITY 12
  283. #define SADB_EXT_PROPOSAL 13
  284. #define SADB_EXT_SUPPORTED_AUTH 14
  285. #define SADB_EXT_SUPPORTED_ENCRYPT 15
  286. #define SADB_EXT_SPIRANGE 16
  287. #define SADB_X_EXT_KMPRIVATE 17
  288. #define SADB_X_EXT_POLICY 18
  289. #define SADB_X_EXT_SA2 19
  290. /* The next four entries are for setting up NAT Traversal */
  291. #define SADB_X_EXT_NAT_T_TYPE 20
  292. #define SADB_X_EXT_NAT_T_SPORT 21
  293. #define SADB_X_EXT_NAT_T_DPORT 22
  294. #define SADB_X_EXT_NAT_T_OA 23
  295. #define SADB_EXT_MAX 23
  296. /* Identity Extension values */
  297. #define SADB_IDENTTYPE_RESERVED 0
  298. #define SADB_IDENTTYPE_PREFIX 1
  299. #define SADB_IDENTTYPE_FQDN 2
  300. #define SADB_IDENTTYPE_USERFQDN 3
  301. #define SADB_IDENTTYPE_MAX 3
  302. #endif /* !(_LINUX_PFKEY2_H) */