update libfreeswan/pfkeyv2.h
[strongswan.git] / src / libfreeswan / pfkeyv2.h
1 /*
2 RFC 2367 PF_KEY Key Management API July 1998
3
4
5 Appendix D: Sample Header File
6
7 This file defines structures and symbols for the PF_KEY Version 2
8 key management interface. It was written at the U.S. Naval Research
9 Laboratory. This file is in the public domain. The authors ask that
10 you leave this credit intact on any copies of this file.
11 */
12 #ifndef __PFKEY_V2_H
13 #define __PFKEY_V2_H 1
14
15 #define PF_KEY_V2 2
16 #define PFKEYV2_REVISION 199806L
17
18 #define SADB_RESERVED 0
19 #define SADB_GETSPI 1
20 #define SADB_UPDATE 2
21 #define SADB_ADD 3
22 #define SADB_DELETE 4
23 #define SADB_GET 5
24 #define SADB_ACQUIRE 6
25 #define SADB_REGISTER 7
26 #define SADB_EXPIRE 8
27 #define SADB_FLUSH 9
28 #define SADB_DUMP 10
29 #define SADB_X_PROMISC 11
30 #define SADB_X_PCHANGE 12
31 #define SADB_X_GRPSA 13
32 #define SADB_X_ADDFLOW 14
33 #define SADB_X_DELFLOW 15
34 #define SADB_X_DEBUG 16
35 #define SADB_X_NAT_T_NEW_MAPPING 17
36 #define SADB_MAX 17
37
38 struct sadb_msg {
39 uint8_t sadb_msg_version;
40 uint8_t sadb_msg_type;
41 uint8_t sadb_msg_errno;
42 uint8_t sadb_msg_satype;
43 uint16_t sadb_msg_len;
44 uint16_t sadb_msg_reserved;
45 uint32_t sadb_msg_seq;
46 uint32_t sadb_msg_pid;
47 };
48
49 struct sadb_ext {
50 uint16_t sadb_ext_len;
51 uint16_t sadb_ext_type;
52 };
53
54 struct sadb_sa {
55 uint16_t sadb_sa_len;
56 uint16_t sadb_sa_exttype;
57 uint32_t sadb_sa_spi;
58 uint8_t sadb_sa_replay;
59 uint8_t sadb_sa_state;
60 uint8_t sadb_sa_auth;
61 uint8_t sadb_sa_encrypt;
62 uint32_t sadb_sa_flags;
63 uint32_t /*IPsecSAref_t*/ sadb_x_sa_ref; /* 32 bits */
64 uint8_t sadb_x_reserved[4];
65 };
66
67 struct sadb_sa_v1 {
68 uint16_t sadb_sa_len;
69 uint16_t sadb_sa_exttype;
70 uint32_t sadb_sa_spi;
71 uint8_t sadb_sa_replay;
72 uint8_t sadb_sa_state;
73 uint8_t sadb_sa_auth;
74 uint8_t sadb_sa_encrypt;
75 uint32_t sadb_sa_flags;
76 };
77
78 struct sadb_lifetime {
79 uint16_t sadb_lifetime_len;
80 uint16_t sadb_lifetime_exttype;
81 uint32_t sadb_lifetime_allocations;
82 uint64_t sadb_lifetime_bytes;
83 uint64_t sadb_lifetime_addtime;
84 uint64_t sadb_lifetime_usetime;
85 uint32_t sadb_x_lifetime_packets;
86 uint32_t sadb_x_lifetime_reserved;
87 };
88
89 struct sadb_address {
90 uint16_t sadb_address_len;
91 uint16_t sadb_address_exttype;
92 uint8_t sadb_address_proto;
93 uint8_t sadb_address_prefixlen;
94 uint16_t sadb_address_reserved;
95 };
96
97 struct sadb_key {
98 uint16_t sadb_key_len;
99 uint16_t sadb_key_exttype;
100 uint16_t sadb_key_bits;
101 uint16_t sadb_key_reserved;
102 };
103
104 struct sadb_ident {
105 uint16_t sadb_ident_len;
106 uint16_t sadb_ident_exttype;
107 uint16_t sadb_ident_type;
108 uint16_t sadb_ident_reserved;
109 uint64_t sadb_ident_id;
110 };
111
112 struct sadb_sens {
113 uint16_t sadb_sens_len;
114 uint16_t sadb_sens_exttype;
115 uint32_t sadb_sens_dpd;
116 uint8_t sadb_sens_sens_level;
117 uint8_t sadb_sens_sens_len;
118 uint8_t sadb_sens_integ_level;
119 uint8_t sadb_sens_integ_len;
120 uint32_t sadb_sens_reserved;
121 };
122
123 struct sadb_prop {
124 uint16_t sadb_prop_len;
125 uint16_t sadb_prop_exttype;
126 uint8_t sadb_prop_replay;
127 uint8_t sadb_prop_reserved[3];
128 };
129
130 struct sadb_comb {
131 uint8_t sadb_comb_auth;
132 uint8_t sadb_comb_encrypt;
133 uint16_t sadb_comb_flags;
134 uint16_t sadb_comb_auth_minbits;
135 uint16_t sadb_comb_auth_maxbits;
136 uint16_t sadb_comb_encrypt_minbits;
137 uint16_t sadb_comb_encrypt_maxbits;
138 uint32_t sadb_comb_reserved;
139 uint32_t sadb_comb_soft_allocations;
140 uint32_t sadb_comb_hard_allocations;
141 uint64_t sadb_comb_soft_bytes;
142 uint64_t sadb_comb_hard_bytes;
143 uint64_t sadb_comb_soft_addtime;
144 uint64_t sadb_comb_hard_addtime;
145 uint64_t sadb_comb_soft_usetime;
146 uint64_t sadb_comb_hard_usetime;
147 uint32_t sadb_x_comb_soft_packets;
148 uint32_t sadb_x_comb_hard_packets;
149 };
150
151 struct sadb_supported {
152 uint16_t sadb_supported_len;
153 uint16_t sadb_supported_exttype;
154 uint32_t sadb_supported_reserved;
155 };
156
157 struct sadb_alg {
158 uint8_t sadb_alg_id;
159 uint8_t sadb_alg_ivlen;
160 uint16_t sadb_alg_minbits;
161 uint16_t sadb_alg_maxbits;
162 uint16_t sadb_alg_reserved;
163 };
164
165 struct sadb_spirange {
166 uint16_t sadb_spirange_len;
167 uint16_t sadb_spirange_exttype;
168 uint32_t sadb_spirange_min;
169 uint32_t sadb_spirange_max;
170 uint32_t sadb_spirange_reserved;
171 };
172
173 struct sadb_x_kmprivate {
174 uint16_t sadb_x_kmprivate_len;
175 uint16_t sadb_x_kmprivate_exttype;
176 uint32_t sadb_x_kmprivate_reserved;
177 };
178
179 struct sadb_x_satype {
180 uint16_t sadb_x_satype_len;
181 uint16_t sadb_x_satype_exttype;
182 uint8_t sadb_x_satype_satype;
183 uint8_t sadb_x_satype_reserved[3];
184 };
185
186 struct sadb_x_policy {
187 uint16_t sadb_x_policy_len;
188 uint16_t sadb_x_policy_exttype;
189 uint16_t sadb_x_policy_type;
190 uint8_t sadb_x_policy_dir;
191 uint8_t sadb_x_policy_reserved;
192 uint32_t sadb_x_policy_id;
193 uint32_t sadb_x_policy_reserved2;
194 };
195
196 struct sadb_x_debug {
197 uint16_t sadb_x_debug_len;
198 uint16_t sadb_x_debug_exttype;
199 uint32_t sadb_x_debug_tunnel;
200 uint32_t sadb_x_debug_netlink;
201 uint32_t sadb_x_debug_xform;
202 uint32_t sadb_x_debug_eroute;
203 uint32_t sadb_x_debug_spi;
204 uint32_t sadb_x_debug_radij;
205 uint32_t sadb_x_debug_esp;
206 uint32_t sadb_x_debug_ah;
207 uint32_t sadb_x_debug_rcv;
208 uint32_t sadb_x_debug_pfkey;
209 uint32_t sadb_x_debug_ipcomp;
210 uint32_t sadb_x_debug_verbose;
211 uint8_t sadb_x_debug_reserved[4];
212 };
213
214 struct sadb_x_nat_t_type {
215 uint16_t sadb_x_nat_t_type_len;
216 uint16_t sadb_x_nat_t_type_exttype;
217 uint8_t sadb_x_nat_t_type_type;
218 uint8_t sadb_x_nat_t_type_reserved[3];
219 };
220 struct sadb_x_nat_t_port {
221 uint16_t sadb_x_nat_t_port_len;
222 uint16_t sadb_x_nat_t_port_exttype;
223 uint16_t sadb_x_nat_t_port_port;
224 uint16_t sadb_x_nat_t_port_reserved;
225 };
226
227 /*
228 * A protocol structure for passing through the transport level
229 * protocol. It contains more fields than are actually used/needed
230 * but it is this way to be compatible with the structure used in
231 * OpenBSD (http://www.openbsd.org/cgi-bin/cvsweb/src/sys/net/pfkeyv2.h)
232 */
233 struct sadb_protocol {
234 uint16_t sadb_protocol_len;
235 uint16_t sadb_protocol_exttype;
236 uint8_t sadb_protocol_proto;
237 uint8_t sadb_protocol_direction;
238 uint8_t sadb_protocol_flags;
239 uint8_t sadb_protocol_reserved2;
240 };
241
242 #define SADB_EXT_RESERVED 0
243 #define SADB_EXT_SA 1
244 #define SADB_EXT_LIFETIME_CURRENT 2
245 #define SADB_EXT_LIFETIME_HARD 3
246 #define SADB_EXT_LIFETIME_SOFT 4
247 #define SADB_EXT_ADDRESS_SRC 5
248 #define SADB_EXT_ADDRESS_DST 6
249 #define SADB_EXT_ADDRESS_PROXY 7
250 #define SADB_EXT_KEY_AUTH 8
251 #define SADB_EXT_KEY_ENCRYPT 9
252 #define SADB_EXT_IDENTITY_SRC 10
253 #define SADB_EXT_IDENTITY_DST 11
254 #define SADB_EXT_SENSITIVITY 12
255 #define SADB_EXT_PROPOSAL 13
256 #define SADB_EXT_SUPPORTED_AUTH 14
257 #define SADB_EXT_SUPPORTED_ENCRYPT 15
258 #define SADB_EXT_SPIRANGE 16
259 #define SADB_X_EXT_KMPRIVATE 17
260 #define SADB_X_EXT_SATYPE2 18
261 #ifdef KERNEL26_HAS_KAME_DUPLICATES
262 #define SADB_X_EXT_POLICY 18
263 #endif
264 #define SADB_X_EXT_SA2 19
265 #define SADB_X_EXT_ADDRESS_DST2 20
266 #define SADB_X_EXT_ADDRESS_SRC_FLOW 21
267 #define SADB_X_EXT_ADDRESS_DST_FLOW 22
268 #define SADB_X_EXT_ADDRESS_SRC_MASK 23
269 #define SADB_X_EXT_ADDRESS_DST_MASK 24
270 #define SADB_X_EXT_DEBUG 25
271 #define SADB_X_EXT_PROTOCOL 26
272 #define SADB_X_EXT_NAT_T_TYPE 27
273 #define SADB_X_EXT_NAT_T_SPORT 28
274 #define SADB_X_EXT_NAT_T_DPORT 29
275 #define SADB_X_EXT_NAT_T_OA 30
276 #define SADB_EXT_MAX 30
277
278 /* SADB_X_DELFLOW required over and above SADB_X_SAFLAGS_CLEARFLOW */
279 #define SADB_X_EXT_ADDRESS_DELFLOW \
280 ( (1<<SADB_X_EXT_ADDRESS_SRC_FLOW) \
281 | (1<<SADB_X_EXT_ADDRESS_DST_FLOW) \
282 | (1<<SADB_X_EXT_ADDRESS_SRC_MASK) \
283 | (1<<SADB_X_EXT_ADDRESS_DST_MASK))
284
285 #define SADB_SATYPE_UNSPEC 0
286 #define SADB_SATYPE_AH 2
287 #define SADB_SATYPE_ESP 3
288 #define SADB_SATYPE_RSVP 5
289 #define SADB_SATYPE_OSPFV2 6
290 #define SADB_SATYPE_RIPV2 7
291 #define SADB_SATYPE_MIP 8
292 #define SADB_X_SATYPE_IPIP 9
293 #ifdef KERNEL26_HAS_KAME_DUPLICATES
294 #define SADB_X_SATYPE_IPCOMP 9 /* ICK! */
295 #endif
296 #define SADB_X_SATYPE_COMP 10
297 #define SADB_X_SATYPE_INT 11
298 #define SADB_SATYPE_MAX 11
299
300 #define SADB_SASTATE_LARVAL 0
301 #define SADB_SASTATE_MATURE 1
302 #define SADB_SASTATE_DYING 2
303 #define SADB_SASTATE_DEAD 3
304 #define SADB_SASTATE_MAX 3
305
306 #define SADB_SAFLAGS_PFS 1
307 #define SADB_X_SAFLAGS_REPLACEFLOW 2
308 #define SADB_X_SAFLAGS_CLEARFLOW 4
309 #define SADB_X_SAFLAGS_INFLOW 8
310
311 /* Authentication algorithms */
312 #define SADB_AALG_NONE 0
313 #define SADB_AALG_MD5HMAC 2
314 #define SADB_AALG_SHA1HMAC 3
315 #define SADB_X_AALG_SHA2_256HMAC 5
316 #define SADB_X_AALG_SHA2_384HMAC 6
317 #define SADB_X_AALG_SHA2_512HMAC 7
318 #define SADB_X_AALG_RIPEMD160HMAC 8
319 #define SADB_X_AALG_AES_XCBC_MAC 9
320 #define SADB_X_AALG_NULL 251 /* kame */
321 #define SADB_AALG_MAX 251
322
323 /* Encryption algorithms */
324 #define SADB_EALG_NONE 0
325 #define SADB_EALG_DESCBC 2
326 #define SADB_EALG_3DESCBC 3
327 #define SADB_X_EALG_CASTCBC 6
328 #define SADB_X_EALG_BLOWFISHCBC 7
329 #define SADB_EALG_NULL 11
330 #define SADB_X_EALG_AESCBC 12
331 #define SADB_X_EALG_AESCTR 13
332 #define SADB_X_EALG_AES_CCM_ICV8 14
333 #define SADB_X_EALG_AES_CCM_ICV12 15
334 #define SADB_X_EALG_AES_CCM_ICV16 16
335 #define SADB_X_EALG_AES_GCM_ICV8 18
336 #define SADB_X_EALG_AES_GCM_ICV12 19
337 #define SADB_X_EALG_AES_GCM_ICV16 20
338 #define SADB_X_EALG_CAMELLIACBC 22
339 #define SADB_EALG_MAX 253 /* last EALG */
340 /* private allocations should use 249-255 (RFC2407) */
341 #define SADB_X_EALG_SERPENTCBC 252 /* draft-ietf-ipsec-ciph-aes-cbc-00 */
342 #define SADB_X_EALG_TWOFISHCBC 253 /* draft-ietf-ipsec-ciph-aes-cbc-00 */
343
344 /* Compression algorithms */
345 #define SADB_X_CALG_NONE 0
346 #define SADB_X_CALG_OUI 1
347 #define SADB_X_CALG_DEFLATE 2
348 #define SADB_X_CALG_LZS 3
349 #define SADB_X_CALG_LZJH 4
350 #define SADB_X_CALG_MAX 4
351
352 #define SADB_X_TALG_NONE 0
353 #define SADB_X_TALG_IPv4_in_IPv4 1
354 #define SADB_X_TALG_IPv6_in_IPv4 2
355 #define SADB_X_TALG_IPv4_in_IPv6 3
356 #define SADB_X_TALG_IPv6_in_IPv6 4
357 #define SADB_X_TALG_MAX 4
358
359 /* Identity Extension values */
360 #define SADB_IDENTTYPE_RESERVED 0
361 #define SADB_IDENTTYPE_PREFIX 1
362 #define SADB_IDENTTYPE_FQDN 2
363 #define SADB_IDENTTYPE_USERFQDN 3
364 #define SADB_IDENTTYPE_MAX 3
365
366 #endif /* __PFKEY_V2_H */