]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* $KAME: pfkeyv2.h,v 1.10 2000/03/22 07:04:20 sakane Exp $ */ | |
26 | ||
27 | /* | |
28 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
29 | * All rights reserved. | |
30 | * | |
31 | * Redistribution and use in source and binary forms, with or without | |
32 | * modification, are permitted provided that the following conditions | |
33 | * are met: | |
34 | * 1. Redistributions of source code must retain the above copyright | |
35 | * notice, this list of conditions and the following disclaimer. | |
36 | * 2. Redistributions in binary form must reproduce the above copyright | |
37 | * notice, this list of conditions and the following disclaimer in the | |
38 | * documentation and/or other materials provided with the distribution. | |
39 | * 3. Neither the name of the project nor the names of its contributors | |
40 | * may be used to endorse or promote products derived from this software | |
41 | * without specific prior written permission. | |
42 | * | |
43 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
44 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
46 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
49 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
50 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
51 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
52 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
53 | * SUCH DAMAGE. | |
54 | */ | |
55 | ||
1c79356b A |
56 | /* |
57 | * This file has been derived rfc 2367, | |
58 | * And added some flags of SADB_KEY_FLAGS_ as SADB_X_EXT_. | |
59 | * sakane@ydc.co.jp | |
60 | */ | |
61 | ||
62 | #ifndef _NET_PFKEYV2_H_ | |
63 | #define _NET_PFKEYV2_H_ | |
9bccf70c | 64 | #include <sys/appleapiopts.h> |
1c79356b A |
65 | |
66 | /* | |
67 | This file defines structures and symbols for the PF_KEY Version 2 | |
68 | key management interface. It was written at the U.S. Naval Research | |
69 | Laboratory. This file is in the public domain. The authors ask that | |
70 | you leave this credit intact on any copies of this file. | |
71 | */ | |
72 | #ifndef __PFKEY_V2_H | |
73 | #define __PFKEY_V2_H 1 | |
74 | ||
75 | #define PF_KEY_V2 2 | |
76 | #define PFKEYV2_REVISION 199806L | |
77 | ||
78 | #define SADB_RESERVED 0 | |
79 | #define SADB_GETSPI 1 | |
80 | #define SADB_UPDATE 2 | |
81 | #define SADB_ADD 3 | |
82 | #define SADB_DELETE 4 | |
83 | #define SADB_GET 5 | |
84 | #define SADB_ACQUIRE 6 | |
85 | #define SADB_REGISTER 7 | |
86 | #define SADB_EXPIRE 8 | |
87 | #define SADB_FLUSH 9 | |
88 | #define SADB_DUMP 10 | |
89 | #define SADB_X_PROMISC 11 | |
90 | #define SADB_X_PCHANGE 12 | |
91 | ||
92 | #define SADB_X_SPDUPDATE 13 | |
93 | #define SADB_X_SPDADD 14 | |
94 | #define SADB_X_SPDDELETE 15 /* by policy index */ | |
95 | #define SADB_X_SPDGET 16 | |
96 | #define SADB_X_SPDACQUIRE 17 | |
97 | #define SADB_X_SPDDUMP 18 | |
98 | #define SADB_X_SPDFLUSH 19 | |
99 | #define SADB_X_SPDSETIDX 20 | |
9bccf70c | 100 | #define SADB_X_SPDEXPIRE 21 |
1c79356b A |
101 | #define SADB_X_SPDDELETE2 22 /* by policy id */ |
102 | #define SADB_MAX 22 | |
103 | ||
104 | struct sadb_msg { | |
105 | u_int8_t sadb_msg_version; | |
106 | u_int8_t sadb_msg_type; | |
107 | u_int8_t sadb_msg_errno; | |
108 | u_int8_t sadb_msg_satype; | |
109 | u_int16_t sadb_msg_len; | |
9bccf70c | 110 | u_int16_t sadb_msg_reserved; |
1c79356b A |
111 | u_int32_t sadb_msg_seq; |
112 | u_int32_t sadb_msg_pid; | |
1c79356b A |
113 | }; |
114 | ||
115 | struct sadb_ext { | |
116 | u_int16_t sadb_ext_len; | |
117 | u_int16_t sadb_ext_type; | |
118 | }; | |
119 | ||
120 | struct sadb_sa { | |
121 | u_int16_t sadb_sa_len; | |
122 | u_int16_t sadb_sa_exttype; | |
123 | u_int32_t sadb_sa_spi; | |
124 | u_int8_t sadb_sa_replay; | |
125 | u_int8_t sadb_sa_state; | |
126 | u_int8_t sadb_sa_auth; | |
127 | u_int8_t sadb_sa_encrypt; | |
128 | u_int32_t sadb_sa_flags; | |
129 | }; | |
130 | ||
55e303ae A |
131 | #ifdef __APPLE_API_PRIVATE |
132 | struct sadb_sa_2 { | |
133 | struct sadb_sa sa; | |
134 | u_int16_t sadb_sa_natt_port; | |
135 | u_int16_t sadb_reserved0; | |
136 | u_int32_t sadb_reserved1; | |
137 | }; | |
138 | #endif | |
139 | ||
1c79356b A |
140 | struct sadb_lifetime { |
141 | u_int16_t sadb_lifetime_len; | |
142 | u_int16_t sadb_lifetime_exttype; | |
143 | u_int32_t sadb_lifetime_allocations; | |
144 | u_int64_t sadb_lifetime_bytes; | |
145 | u_int64_t sadb_lifetime_addtime; | |
146 | u_int64_t sadb_lifetime_usetime; | |
147 | }; | |
148 | ||
149 | struct sadb_address { | |
150 | u_int16_t sadb_address_len; | |
151 | u_int16_t sadb_address_exttype; | |
152 | u_int8_t sadb_address_proto; | |
153 | u_int8_t sadb_address_prefixlen; | |
154 | u_int16_t sadb_address_reserved; | |
155 | }; | |
156 | ||
157 | struct sadb_key { | |
158 | u_int16_t sadb_key_len; | |
159 | u_int16_t sadb_key_exttype; | |
160 | u_int16_t sadb_key_bits; | |
161 | u_int16_t sadb_key_reserved; | |
162 | }; | |
163 | ||
164 | struct sadb_ident { | |
165 | u_int16_t sadb_ident_len; | |
166 | u_int16_t sadb_ident_exttype; | |
167 | u_int16_t sadb_ident_type; | |
168 | u_int16_t sadb_ident_reserved; | |
169 | u_int64_t sadb_ident_id; | |
170 | }; | |
1c79356b A |
171 | |
172 | struct sadb_sens { | |
173 | u_int16_t sadb_sens_len; | |
174 | u_int16_t sadb_sens_exttype; | |
175 | u_int32_t sadb_sens_dpd; | |
176 | u_int8_t sadb_sens_sens_level; | |
177 | u_int8_t sadb_sens_sens_len; | |
178 | u_int8_t sadb_sens_integ_level; | |
179 | u_int8_t sadb_sens_integ_len; | |
180 | u_int32_t sadb_sens_reserved; | |
181 | }; | |
182 | ||
183 | struct sadb_prop { | |
184 | u_int16_t sadb_prop_len; | |
185 | u_int16_t sadb_prop_exttype; | |
186 | u_int8_t sadb_prop_replay; | |
187 | u_int8_t sadb_prop_reserved[3]; | |
188 | }; | |
189 | ||
190 | struct sadb_comb { | |
191 | u_int8_t sadb_comb_auth; | |
192 | u_int8_t sadb_comb_encrypt; | |
193 | u_int16_t sadb_comb_flags; | |
194 | u_int16_t sadb_comb_auth_minbits; | |
195 | u_int16_t sadb_comb_auth_maxbits; | |
196 | u_int16_t sadb_comb_encrypt_minbits; | |
197 | u_int16_t sadb_comb_encrypt_maxbits; | |
198 | u_int32_t sadb_comb_reserved; | |
199 | u_int32_t sadb_comb_soft_allocations; | |
200 | u_int32_t sadb_comb_hard_allocations; | |
201 | u_int64_t sadb_comb_soft_bytes; | |
202 | u_int64_t sadb_comb_hard_bytes; | |
203 | u_int64_t sadb_comb_soft_addtime; | |
204 | u_int64_t sadb_comb_hard_addtime; | |
205 | u_int64_t sadb_comb_soft_usetime; | |
206 | u_int64_t sadb_comb_hard_usetime; | |
207 | }; | |
208 | ||
209 | struct sadb_supported { | |
210 | u_int16_t sadb_supported_len; | |
211 | u_int16_t sadb_supported_exttype; | |
212 | u_int32_t sadb_supported_reserved; | |
213 | }; | |
214 | ||
215 | struct sadb_alg { | |
216 | u_int8_t sadb_alg_id; | |
217 | u_int8_t sadb_alg_ivlen; | |
218 | u_int16_t sadb_alg_minbits; | |
219 | u_int16_t sadb_alg_maxbits; | |
220 | u_int16_t sadb_alg_reserved; | |
221 | }; | |
222 | ||
223 | struct sadb_spirange { | |
224 | u_int16_t sadb_spirange_len; | |
225 | u_int16_t sadb_spirange_exttype; | |
226 | u_int32_t sadb_spirange_min; | |
227 | u_int32_t sadb_spirange_max; | |
228 | u_int32_t sadb_spirange_reserved; | |
229 | }; | |
230 | ||
231 | struct sadb_x_kmprivate { | |
232 | u_int16_t sadb_x_kmprivate_len; | |
233 | u_int16_t sadb_x_kmprivate_exttype; | |
234 | u_int32_t sadb_x_kmprivate_reserved; | |
235 | }; | |
236 | ||
9bccf70c A |
237 | /* |
238 | * XXX Additional SA Extension. | |
239 | * mode: tunnel or transport | |
240 | * reqid: to make SA unique nevertheless the address pair of SA are same. | |
241 | * Mainly it's for VPN. | |
242 | */ | |
243 | struct sadb_x_sa2 { | |
244 | u_int16_t sadb_x_sa2_len; | |
245 | u_int16_t sadb_x_sa2_exttype; | |
246 | u_int8_t sadb_x_sa2_mode; | |
247 | u_int8_t sadb_x_sa2_reserved1; | |
248 | u_int16_t sadb_x_sa2_reserved2; | |
55e303ae | 249 | u_int32_t sadb_x_sa2_sequence; |
9bccf70c A |
250 | u_int32_t sadb_x_sa2_reqid; |
251 | }; | |
252 | ||
1c79356b | 253 | /* XXX Policy Extension */ |
9bccf70c | 254 | /* sizeof(struct sadb_x_policy) == 16 */ |
1c79356b A |
255 | struct sadb_x_policy { |
256 | u_int16_t sadb_x_policy_len; | |
257 | u_int16_t sadb_x_policy_exttype; | |
258 | u_int16_t sadb_x_policy_type; /* See policy type of ipsec.h */ | |
259 | u_int8_t sadb_x_policy_dir; /* direction, see ipsec.h */ | |
260 | u_int8_t sadb_x_policy_reserved; | |
261 | u_int32_t sadb_x_policy_id; | |
262 | u_int32_t sadb_x_policy_reserved2; | |
263 | }; | |
264 | /* | |
265 | * When policy_type == IPSEC, it is followed by some of | |
266 | * the ipsec policy request. | |
267 | * [total length of ipsec policy requests] | |
268 | * = (sadb_x_policy_len * sizeof(uint64_t) - sizeof(struct sadb_x_policy)) | |
269 | */ | |
270 | ||
271 | /* XXX IPsec Policy Request Extension */ | |
272 | /* | |
273 | * This structure is aligned 8 bytes. | |
274 | */ | |
275 | struct sadb_x_ipsecrequest { | |
276 | u_int16_t sadb_x_ipsecrequest_len; /* structure length aligned to 8 bytes. | |
277 | * This value is true length of bytes. | |
278 | * Not in units of 64 bits. */ | |
279 | u_int16_t sadb_x_ipsecrequest_proto; /* See ipsec.h */ | |
280 | u_int8_t sadb_x_ipsecrequest_mode; /* See IPSEC_MODE_XX in ipsec.h. */ | |
281 | u_int8_t sadb_x_ipsecrequest_level; /* See IPSEC_LEVEL_XX in ipsec.h */ | |
282 | u_int16_t sadb_x_ipsecrequest_reqid; /* See ipsec.h */ | |
283 | ||
284 | /* | |
285 | * followed by source IP address of SA, and immediately followed by | |
286 | * destination IP address of SA. These encoded into two of sockaddr | |
287 | * structure without any padding. Must set each sa_len exactly. | |
288 | * Each of length of the sockaddr structure are not aligned to 64bits, | |
289 | * but sum of x_request and addresses is aligned to 64bits. | |
290 | */ | |
291 | }; | |
292 | ||
293 | #define SADB_EXT_RESERVED 0 | |
294 | #define SADB_EXT_SA 1 | |
295 | #define SADB_EXT_LIFETIME_CURRENT 2 | |
296 | #define SADB_EXT_LIFETIME_HARD 3 | |
297 | #define SADB_EXT_LIFETIME_SOFT 4 | |
298 | #define SADB_EXT_ADDRESS_SRC 5 | |
299 | #define SADB_EXT_ADDRESS_DST 6 | |
300 | #define SADB_EXT_ADDRESS_PROXY 7 | |
301 | #define SADB_EXT_KEY_AUTH 8 | |
302 | #define SADB_EXT_KEY_ENCRYPT 9 | |
303 | #define SADB_EXT_IDENTITY_SRC 10 | |
304 | #define SADB_EXT_IDENTITY_DST 11 | |
305 | #define SADB_EXT_SENSITIVITY 12 | |
306 | #define SADB_EXT_PROPOSAL 13 | |
307 | #define SADB_EXT_SUPPORTED_AUTH 14 | |
308 | #define SADB_EXT_SUPPORTED_ENCRYPT 15 | |
309 | #define SADB_EXT_SPIRANGE 16 | |
310 | #define SADB_X_EXT_KMPRIVATE 17 | |
311 | #define SADB_X_EXT_POLICY 18 | |
9bccf70c A |
312 | #define SADB_X_EXT_SA2 19 |
313 | #define SADB_EXT_MAX 19 | |
1c79356b A |
314 | |
315 | #define SADB_SATYPE_UNSPEC 0 | |
316 | #define SADB_SATYPE_AH 2 | |
317 | #define SADB_SATYPE_ESP 3 | |
318 | #define SADB_SATYPE_RSVP 5 | |
319 | #define SADB_SATYPE_OSPFV2 6 | |
320 | #define SADB_SATYPE_RIPV2 7 | |
321 | #define SADB_SATYPE_MIP 8 | |
322 | #define SADB_X_SATYPE_IPCOMP 9 | |
323 | #define SADB_X_SATYPE_POLICY 10 | |
324 | #define SADB_SATYPE_MAX 11 | |
325 | ||
326 | #define SADB_SASTATE_LARVAL 0 | |
327 | #define SADB_SASTATE_MATURE 1 | |
328 | #define SADB_SASTATE_DYING 2 | |
329 | #define SADB_SASTATE_DEAD 3 | |
330 | #define SADB_SASTATE_MAX 3 | |
331 | ||
332 | #define SADB_SAFLAGS_PFS 1 | |
333 | ||
9bccf70c A |
334 | /* RFC2367 numbers - meets RFC2407 */ |
335 | #define SADB_AALG_NONE 0 | |
336 | #define SADB_AALG_MD5HMAC 1 /*2*/ | |
337 | #define SADB_AALG_SHA1HMAC 2 /*3*/ | |
338 | #define SADB_AALG_MAX 8 | |
339 | /* private allocations - based on RFC2407/IANA assignment */ | |
340 | #define SADB_X_AALG_SHA2_256 6 /*5*/ | |
341 | #define SADB_X_AALG_SHA2_384 7 /*6*/ | |
342 | #define SADB_X_AALG_SHA2_512 8 /*7*/ | |
343 | /* private allocations should use 249-255 (RFC2407) */ | |
344 | #define SADB_X_AALG_MD5 3 /*249*/ /* Keyed MD5 */ | |
345 | #define SADB_X_AALG_SHA 4 /*250*/ /* Keyed SHA */ | |
346 | #define SADB_X_AALG_NULL 5 /*251*/ /* null authentication */ | |
347 | ||
348 | /* RFC2367 numbers - meets RFC2407 */ | |
349 | #define SADB_EALG_NONE 0 | |
350 | #define SADB_EALG_DESCBC 1 /*2*/ | |
351 | #define SADB_EALG_3DESCBC 2 /*3*/ | |
352 | #define SADB_EALG_NULL 3 /*11*/ | |
353 | #define SADB_EALG_MAX 12 | |
354 | /* private allocations - based on RFC2407/IANA assignment */ | |
355 | #define SADB_X_EALG_CAST128CBC 5 /*6*/ | |
356 | #define SADB_X_EALG_BLOWFISHCBC 4 /*7*/ | |
357 | #define SADB_X_EALG_RIJNDAELCBC 12 | |
358 | #define SADB_X_EALG_AES 12 | |
359 | /* private allocations should use 249-255 (RFC2407) */ | |
1c79356b A |
360 | |
361 | #if 1 /*nonstandard */ | |
362 | #define SADB_X_CALG_NONE 0 | |
363 | #define SADB_X_CALG_OUI 1 | |
364 | #define SADB_X_CALG_DEFLATE 2 | |
365 | #define SADB_X_CALG_LZS 3 | |
366 | #define SADB_X_CALG_MAX 4 | |
367 | #endif | |
368 | ||
369 | #define SADB_IDENTTYPE_RESERVED 0 | |
370 | #define SADB_IDENTTYPE_PREFIX 1 | |
371 | #define SADB_IDENTTYPE_FQDN 2 | |
372 | #define SADB_IDENTTYPE_USERFQDN 3 | |
373 | #define SADB_X_IDENTTYPE_ADDR 4 | |
374 | #define SADB_IDENTTYPE_MAX 4 | |
375 | ||
376 | /* `flags' in sadb_sa structure holds followings */ | |
377 | #define SADB_X_EXT_NONE 0x0000 /* i.e. new format. */ | |
378 | #define SADB_X_EXT_OLD 0x0001 /* old format. */ | |
55e303ae A |
379 | #ifdef __APPLE_API_PRIVATE |
380 | #define SADB_X_EXT_NATT 0x0002 /* Use UDP encapsulation to traverse NAT */ | |
381 | #define SADB_X_EXT_NATT_KEEPALIVE 0x0004 /* Local node is behind NAT, send keepalives */ | |
382 | /* Should only be set for outbound SAs */ | |
383 | #endif | |
1c79356b A |
384 | |
385 | #define SADB_X_EXT_IV4B 0x0010 /* IV length of 4 bytes in use */ | |
386 | #define SADB_X_EXT_DERIV 0x0020 /* DES derived */ | |
387 | #define SADB_X_EXT_CYCSEQ 0x0040 /* allowing to cyclic sequence. */ | |
388 | ||
389 | /* three of followings are exclusive flags each them */ | |
390 | #define SADB_X_EXT_PSEQ 0x0000 /* sequencial padding for ESP */ | |
391 | #define SADB_X_EXT_PRAND 0x0100 /* random padding for ESP */ | |
392 | #define SADB_X_EXT_PZERO 0x0200 /* zero padding for ESP */ | |
393 | #define SADB_X_EXT_PMASK 0x0300 /* mask for padding flag */ | |
394 | ||
395 | #if 1 | |
396 | #define SADB_X_EXT_RAWCPI 0x0080 /* use well known CPI (IPComp) */ | |
397 | #endif | |
398 | ||
399 | #define SADB_KEY_FLAGS_MAX 0x0fff | |
400 | ||
401 | /* SPI size for PF_KEYv2 */ | |
402 | #define PFKEY_SPI_SIZE sizeof(u_int32_t) | |
403 | ||
404 | /* Identifier for menber of lifetime structure */ | |
405 | #define SADB_X_LIFETIME_ALLOCATIONS 0 | |
406 | #define SADB_X_LIFETIME_BYTES 1 | |
407 | #define SADB_X_LIFETIME_ADDTIME 2 | |
408 | #define SADB_X_LIFETIME_USETIME 3 | |
409 | ||
410 | /* The rate for SOFT lifetime against HARD one. */ | |
411 | #define PFKEY_SOFT_LIFETIME_RATE 80 | |
412 | ||
413 | /* Utilities */ | |
414 | #define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1))) | |
415 | #define PFKEY_EXTLEN(msg) \ | |
416 | PFKEY_UNUNIT64(((struct sadb_ext *)(msg))->sadb_ext_len) | |
417 | #define PFKEY_ADDR_PREFIX(ext) \ | |
418 | (((struct sadb_address *)(ext))->sadb_address_prefixlen) | |
419 | #define PFKEY_ADDR_PROTO(ext) \ | |
420 | (((struct sadb_address *)(ext))->sadb_address_proto) | |
421 | #define PFKEY_ADDR_SADDR(ext) \ | |
422 | ((struct sockaddr *)((caddr_t)(ext) + sizeof(struct sadb_address))) | |
423 | ||
1c79356b A |
424 | /* in 64bits */ |
425 | #define PFKEY_UNUNIT64(a) ((a) << 3) | |
426 | #define PFKEY_UNIT64(a) ((a) >> 3) | |
1c79356b A |
427 | |
428 | #endif /* __PFKEY_V2_H */ | |
429 | ||
430 | #endif /* _NET_PFKEYV2_H_ */ |