1 /* $NetBSD: pfkeyv2.h,v 1.35 2023/01/04 01:58:33 knakahara Exp $ */ 2 /* $KAME: pfkeyv2.h,v 1.36 2003/07/25 09:33:37 itojun Exp $ */ 3 4 /* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the project nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 /* 34 * This file has been derived rfc 2367, 35 * And added some flags of SADB_KEY_FLAGS_ as SADB_X_EXT_. 36 * sakane@ydc.co.jp 37 */ 38 39 #ifndef _NET_PFKEYV2_H_ 40 #define _NET_PFKEYV2_H_ 41 42 /* 43 This file defines structures and symbols for the PF_KEY Version 2 44 key management interface. It was written at the U.S. Naval Research 45 Laboratory. This file is in the public domain. The authors ask that 46 you leave this credit intact on any copies of this file. 47 */ 48 #ifndef __PFKEY_V2_H 49 #define __PFKEY_V2_H 1 50 51 #define PF_KEY_V2 2 52 #define PFKEYV2_REVISION 199806L 53 54 #define SADB_RESERVED 0 55 #define SADB_GETSPI 1 56 #define SADB_UPDATE 2 57 #define SADB_ADD 3 58 #define SADB_DELETE 4 59 #define SADB_GET 5 60 #define SADB_ACQUIRE 6 61 #define SADB_REGISTER 7 62 #define SADB_EXPIRE 8 63 #define SADB_FLUSH 9 64 #define SADB_DUMP 10 65 #define SADB_X_PROMISC 11 66 #define SADB_X_PCHANGE 12 67 68 #define SADB_X_SPDUPDATE 13 69 #define SADB_X_SPDADD 14 70 #define SADB_X_SPDDELETE 15 /* by policy index */ 71 #define SADB_X_SPDGET 16 72 #define SADB_X_SPDACQUIRE 17 73 #define SADB_X_SPDDUMP 18 74 #define SADB_X_SPDFLUSH 19 75 #define SADB_X_SPDSETIDX 20 76 #define SADB_X_SPDEXPIRE 21 /* not yet */ 77 #define SADB_X_SPDDELETE2 22 /* by policy id */ 78 #define SADB_X_NAT_T_NEW_MAPPING 23 79 #if 0 80 #define SADB_X_MIGRATE 24 /* KAME */ 81 #endif 82 #define SADB_MAX 23 83 84 struct sadb_msg { 85 uint8_t sadb_msg_version; 86 uint8_t sadb_msg_type; 87 uint8_t sadb_msg_errno; 88 uint8_t sadb_msg_satype; 89 uint16_t sadb_msg_len; 90 uint16_t sadb_msg_reserved; 91 uint32_t sadb_msg_seq; 92 uint32_t sadb_msg_pid; 93 }; 94 95 struct sadb_ext { 96 uint16_t sadb_ext_len; 97 uint16_t sadb_ext_type; 98 }; 99 100 struct sadb_sa { 101 uint16_t sadb_sa_len; 102 uint16_t sadb_sa_exttype; 103 uint32_t sadb_sa_spi; 104 uint8_t sadb_sa_replay; 105 uint8_t sadb_sa_state; 106 uint8_t sadb_sa_auth; 107 uint8_t sadb_sa_encrypt; 108 uint32_t sadb_sa_flags; 109 }; 110 111 struct sadb_lifetime { 112 uint16_t sadb_lifetime_len; 113 uint16_t sadb_lifetime_exttype; 114 uint32_t sadb_lifetime_allocations; 115 uint64_t sadb_lifetime_bytes; 116 uint64_t sadb_lifetime_addtime; 117 uint64_t sadb_lifetime_usetime; 118 }; 119 120 struct sadb_address { 121 uint16_t sadb_address_len; 122 uint16_t sadb_address_exttype; 123 uint8_t sadb_address_proto; 124 uint8_t sadb_address_prefixlen; 125 uint16_t sadb_address_reserved; 126 }; 127 128 struct sadb_key { 129 uint16_t sadb_key_len; 130 uint16_t sadb_key_exttype; 131 uint16_t sadb_key_bits; 132 uint16_t sadb_key_reserved; 133 }; 134 135 struct sadb_ident { 136 uint16_t sadb_ident_len; 137 uint16_t sadb_ident_exttype; 138 uint16_t sadb_ident_type; 139 uint16_t sadb_ident_reserved; 140 uint64_t sadb_ident_id; 141 }; 142 143 struct sadb_sens { 144 uint16_t sadb_sens_len; 145 uint16_t sadb_sens_exttype; 146 uint32_t sadb_sens_dpd; 147 uint8_t sadb_sens_sens_level; 148 uint8_t sadb_sens_sens_len; 149 uint8_t sadb_sens_integ_level; 150 uint8_t sadb_sens_integ_len; 151 uint32_t sadb_sens_reserved; 152 }; 153 154 struct sadb_prop { 155 uint16_t sadb_prop_len; 156 uint16_t sadb_prop_exttype; 157 uint8_t sadb_prop_replay; 158 uint8_t sadb_prop_reserved[3]; 159 }; 160 161 struct sadb_comb { 162 uint8_t sadb_comb_auth; 163 uint8_t sadb_comb_encrypt; 164 uint16_t sadb_comb_flags; 165 uint16_t sadb_comb_auth_minbits; 166 uint16_t sadb_comb_auth_maxbits; 167 uint16_t sadb_comb_encrypt_minbits; 168 uint16_t sadb_comb_encrypt_maxbits; 169 uint32_t sadb_comb_reserved; 170 uint32_t sadb_comb_soft_allocations; 171 uint32_t sadb_comb_hard_allocations; 172 uint64_t sadb_comb_soft_bytes; 173 uint64_t sadb_comb_hard_bytes; 174 uint64_t sadb_comb_soft_addtime; 175 uint64_t sadb_comb_hard_addtime; 176 uint64_t sadb_comb_soft_usetime; 177 uint64_t sadb_comb_hard_usetime; 178 }; 179 180 struct sadb_supported { 181 uint16_t sadb_supported_len; 182 uint16_t sadb_supported_exttype; 183 uint32_t sadb_supported_reserved; 184 }; 185 186 struct sadb_alg { 187 uint8_t sadb_alg_id; 188 uint8_t sadb_alg_ivlen; 189 uint16_t sadb_alg_minbits; 190 uint16_t sadb_alg_maxbits; 191 uint16_t sadb_alg_reserved; 192 }; 193 194 struct sadb_spirange { 195 uint16_t sadb_spirange_len; 196 uint16_t sadb_spirange_exttype; 197 uint32_t sadb_spirange_min; 198 uint32_t sadb_spirange_max; 199 uint32_t sadb_spirange_reserved; 200 }; 201 202 struct sadb_x_kmprivate { 203 uint16_t sadb_x_kmprivate_len; 204 uint16_t sadb_x_kmprivate_exttype; 205 uint32_t sadb_x_kmprivate_reserved; 206 }; 207 208 /* 209 * XXX Additional SA Extension. 210 * mode: tunnel or transport 211 * reqid: to make SA unique nevertheless the address pair of SA are same. 212 * Mainly it's for VPN. 213 */ 214 struct sadb_x_sa2 { 215 uint16_t sadb_x_sa2_len; 216 uint16_t sadb_x_sa2_exttype; 217 uint8_t sadb_x_sa2_mode; 218 uint8_t sadb_x_sa2_reserved1; 219 uint16_t sadb_x_sa2_reserved2; 220 uint32_t sadb_x_sa2_sequence; 221 uint32_t sadb_x_sa2_reqid; /* topmost 16bits are always 0 */ 222 }; 223 224 /* XXX Policy Extension */ 225 /* sizeof(struct sadb_x_policy) == 16 */ 226 struct sadb_x_policy { 227 uint16_t sadb_x_policy_len; 228 uint16_t sadb_x_policy_exttype; 229 uint16_t sadb_x_policy_type; /* See policy type of ipsec.h */ 230 uint8_t sadb_x_policy_dir; /* direction, see ipsec.h */ 231 uint8_t sadb_x_policy_flags; 232 #define IPSEC_POLICY_FLAG_ORIGIN_KERNEL 0x80 /* policy is generated by kernel */ 233 #define sadb_x_policy_reserved sadb_x_policy_flags 234 uint32_t sadb_x_policy_id; 235 uint32_t sadb_x_policy_reserved2; 236 }; 237 /* 238 * When policy_type == IPSEC, it is followed by some of 239 * the ipsec policy request. 240 * [total length of ipsec policy requests] 241 * = (sadb_x_policy_len * sizeof(uint64_t) - sizeof(struct sadb_x_policy)) 242 */ 243 244 /* XXX IPsec Policy Request Extension */ 245 /* 246 * This structure is aligned 8 bytes. 247 */ 248 struct sadb_x_ipsecrequest { 249 uint16_t sadb_x_ipsecrequest_len; /* structure length in 64 bits. */ 250 uint16_t sadb_x_ipsecrequest_proto; /* See ipsec.h */ 251 uint8_t sadb_x_ipsecrequest_mode; /* See IPSEC_MODE_XX in ipsec.h. */ 252 uint8_t sadb_x_ipsecrequest_level; /* See IPSEC_LEVEL_XX in ipsec.h */ 253 uint16_t sadb_x_ipsecrequest_reqid; /* See ipsec.h */ 254 255 /* 256 * followed by source IP address of SA, and immediately followed by 257 * destination IP address of SA. These encoded into two of sockaddr 258 * structure without any padding. Must set each sa_len exactly. 259 * Each of length of the sockaddr structure are not aligned to 64bits, 260 * but sum of x_request and addresses is aligned to 64bits. 261 */ 262 }; 263 264 /* NAT traversal type, see draft-ietf-ipsec-udp-encaps-06 */ 265 /* sizeof(struct sadb_x_nat_t_type) == 8 */ 266 struct sadb_x_nat_t_type { 267 uint16_t sadb_x_nat_t_type_len; 268 uint16_t sadb_x_nat_t_type_exttype; 269 uint8_t sadb_x_nat_t_type_type; 270 uint8_t sadb_x_nat_t_type_reserved[3]; 271 }; 272 273 /* NAT traversal source or destination port */ 274 /* sizeof(struct sadb_x_nat_t_port) == 8 */ 275 struct sadb_x_nat_t_port { 276 uint16_t sadb_x_nat_t_port_len; 277 uint16_t sadb_x_nat_t_port_exttype; 278 uint16_t sadb_x_nat_t_port_port; 279 uint16_t sadb_x_nat_t_port_reserved; 280 }; 281 282 /* ESP fragmentation size */ 283 /* sizeof(struct sadb_x_nat_t_frag) == 8 */ 284 struct sadb_x_nat_t_frag { 285 uint16_t sadb_x_nat_t_frag_len; 286 uint16_t sadb_x_nat_t_frag_exttype; 287 uint16_t sadb_x_nat_t_frag_fraglen; 288 uint16_t sadb_x_nat_t_frag_reserved; 289 }; 290 291 292 #define SADB_EXT_RESERVED 0 293 #define SADB_EXT_SA 1 294 #define SADB_EXT_LIFETIME_CURRENT 2 295 #define SADB_EXT_LIFETIME_HARD 3 296 #define SADB_EXT_LIFETIME_SOFT 4 297 #define SADB_EXT_ADDRESS_SRC 5 298 #define SADB_EXT_ADDRESS_DST 6 299 #define SADB_EXT_ADDRESS_PROXY 7 300 #define SADB_EXT_KEY_AUTH 8 301 #define SADB_EXT_KEY_ENCRYPT 9 302 #define SADB_EXT_IDENTITY_SRC 10 303 #define SADB_EXT_IDENTITY_DST 11 304 #define SADB_EXT_SENSITIVITY 12 305 #define SADB_EXT_PROPOSAL 13 306 #define SADB_EXT_SUPPORTED_AUTH 14 307 #define SADB_EXT_SUPPORTED_ENCRYPT 15 308 #define SADB_EXT_SPIRANGE 16 309 #define SADB_X_EXT_KMPRIVATE 17 310 #define SADB_X_EXT_POLICY 18 311 #define SADB_X_EXT_SA2 19 312 #define SADB_X_EXT_NAT_T_TYPE 20 313 #define SADB_X_EXT_NAT_T_SPORT 21 314 #define SADB_X_EXT_NAT_T_DPORT 22 315 #define SADB_X_EXT_NAT_T_OA 23 /* compat */ 316 #define SADB_X_EXT_NAT_T_OAI 23 317 #define SADB_X_EXT_NAT_T_OAR 24 318 #define SADB_X_EXT_NAT_T_FRAG 25 319 #if 0 320 #define SADB_X_EXT_TAG 25 /* KAME */ 321 #define SADB_X_EXT_SA3 26 /* KAME */ 322 #define SADB_X_EXT_PACKET 27 /* KAME */ 323 #endif 324 #define SADB_EXT_MAX 25 325 326 #define SADB_SATYPE_UNSPEC 0 327 #define SADB_SATYPE_AH 2 328 #define SADB_SATYPE_ESP 3 329 #define SADB_SATYPE_RSVP 5 330 #define SADB_SATYPE_OSPFV2 6 331 #define SADB_SATYPE_RIPV2 7 332 #define SADB_SATYPE_MIP 8 333 #define SADB_X_SATYPE_IPCOMP 9 334 /*#define SADB_X_SATYPE_POLICY 10 obsolete, do not reuse */ 335 #define SADB_X_SATYPE_TCPSIGNATURE 11 336 #define SADB_SATYPE_MAX 12 337 338 #define SADB_SASTATE_LARVAL 0 339 #define SADB_SASTATE_MATURE 1 340 #define SADB_SASTATE_DYING 2 341 #define SADB_SASTATE_DEAD 3 342 #define SADB_SASTATE_MAX 3 343 344 #define SADB_SASTATE_USABLE_P(sav) \ 345 ((sav)->state == SADB_SASTATE_MATURE || (sav)->state == SADB_SASTATE_DYING) 346 347 #define SADB_SAFLAGS_PFS 1 348 349 /* 350 * Statistics variable definitions. For ESP/AH/IPCOMP we define 351 * indirection arrays of 256 elements indexed by algorithm (which 352 * is uint8_t. All unknown/unhandled entries are summed in the 0th 353 * element. We provide three variables per protocol: 354 * 1. *_STATS_INIT: a list of initializers 355 * 2. *_STATS_NUM: number of algorithms/statistics including (0/unknown) 356 * 3. *_STATS_STR: a list of strings to symbolically print the statistics 357 */ 358 359 /* RFC2367 numbers - meets RFC2407 */ 360 #define SADB_AALG_NONE 0 361 #define SADB_AALG_MD5HMAC 2 362 #define SADB_AALG_SHA1HMAC 3 363 #define SADB_AALG_MAX 251 364 /* private allocations - based on RFC2407/IANA assignment */ 365 #define SADB_X_AALG_SHA2_256 5 366 #define SADB_X_AALG_SHA2_384 6 367 #define SADB_X_AALG_SHA2_512 7 368 #define SADB_X_AALG_RIPEMD160HMAC 8 369 #define SADB_X_AALG_AES_XCBC_MAC 9 /* RFC3566 */ 370 #define SADB_X_AALG_AES128GMAC 11 /* RFC4543 + Errata1821 */ 371 #define SADB_X_AALG_AES192GMAC 12 372 #define SADB_X_AALG_AES256GMAC 13 373 /* private allocations should use 249-255 (RFC2407) */ 374 #define SADB_X_AALG_MD5 249 /* Keyed MD5 */ 375 #define SADB_X_AALG_SHA 250 /* Keyed SHA */ 376 #define SADB_X_AALG_NULL 251 /* null authentication */ 377 #define SADB_X_AALG_TCP_MD5 252 /* Keyed TCP-MD5 (RFC2385) */ 378 379 380 #define SADB_AALG_STATS_INIT \ 381 [SADB_AALG_NONE] = 1, \ 382 [SADB_AALG_MD5HMAC] = 2, \ 383 [SADB_AALG_SHA1HMAC] = 3, \ 384 [SADB_X_AALG_SHA2_256] = 4, \ 385 [SADB_X_AALG_SHA2_384] = 5, \ 386 [SADB_X_AALG_SHA2_512] = 6, \ 387 [SADB_X_AALG_RIPEMD160HMAC] = 7, \ 388 [SADB_X_AALG_AES_XCBC_MAC] = 8, \ 389 [SADB_X_AALG_AES128GMAC] = 9, \ 390 [SADB_X_AALG_AES192GMAC] = 10, \ 391 [SADB_X_AALG_AES256GMAC] = 11, \ 392 [SADB_X_AALG_MD5] = 12, \ 393 [SADB_X_AALG_SHA] = 13, \ 394 [SADB_X_AALG_NULL] = 14, \ 395 [SADB_X_AALG_TCP_MD5] = 15, 396 397 #define SADB_AALG_STATS_NUM 16 398 #define SADB_AALG_STATS_STR \ 399 "*unknown*", \ 400 "none", \ 401 "hmac-md5", \ 402 "hmac-sha1", \ 403 "hmac-sha2-256", \ 404 "hmac-sha2-384", \ 405 "hmac-sha2-512", \ 406 "hmac-ripe-md160", \ 407 "aes-xbc-mac", \ 408 "aes-128-mac", \ 409 "aes-192-mac", \ 410 "aes-256-mac", \ 411 "md5", \ 412 "sha", \ 413 "null", \ 414 "tcp-md5", 415 416 /* RFC2367 numbers - meets RFC2407 */ 417 #define SADB_EALG_NONE 0 418 #define SADB_EALG_DESCBC 2 419 #define SADB_EALG_3DESCBC 3 420 #define SADB_EALG_NULL 11 421 #define SADB_EALG_MAX 250 422 /* private allocations - based on RFC2407/IANA assignment */ 423 #define SADB_X_EALG_CAST128CBC 6 424 #define SADB_X_EALG_BLOWFISHCBC 7 425 #define SADB_X_EALG_RIJNDAELCBC 12 426 #define SADB_X_EALG_AES 12 427 #define SADB_X_EALG_AESCTR 13 /* RFC3686 */ 428 #define SADB_X_EALG_AESGCM8 18 /* RFC4106 */ 429 #define SADB_X_EALG_AESGCM12 19 430 #define SADB_X_EALG_AESGCM16 20 431 #define SADB_X_EALG_CAMELLIACBC 22 /* RFC4312 */ 432 #define SADB_X_EALG_AESGMAC 23 /* RFC4543 + Errata1821 */ 433 /* private allocations should use 249-255 (RFC2407) */ 434 #define SADB_X_EALG_SKIPJACK 250 435 436 #define SADB_EALG_STATS_INIT \ 437 [SADB_EALG_NONE] = 1, \ 438 [SADB_EALG_DESCBC] = 2, \ 439 [SADB_EALG_3DESCBC] = 3, \ 440 [SADB_EALG_NULL] = 4, \ 441 [SADB_X_EALG_CAST128CBC] = 5, \ 442 [SADB_X_EALG_BLOWFISHCBC] = 6, \ 443 [SADB_X_EALG_RIJNDAELCBC] = 7, \ 444 [SADB_X_EALG_AESCTR] = 8, \ 445 [SADB_X_EALG_AESGCM8] = 9, \ 446 [SADB_X_EALG_AESGCM12] = 10, \ 447 [SADB_X_EALG_AESGCM16] = 11, \ 448 [SADB_X_EALG_CAMELLIACBC] = 12, \ 449 [SADB_X_EALG_AESGMAC] = 13, \ 450 [SADB_X_EALG_SKIPJACK] = 14, 451 452 #define SADB_EALG_STATS_NUM 15 453 #define SADB_EALG_STATS_STR \ 454 "*unknown*", \ 455 "none", \ 456 "des-cbc", \ 457 "3des-cbc", \ 458 "null", \ 459 "cast128-cbc", \ 460 "blowfish-cbc", \ 461 "aes-cbc", \ 462 "aes-ctr", \ 463 "aes-gcm-8", \ 464 "aes-gcm-12", \ 465 "aes-gcm-16", \ 466 "camelia-cbc", \ 467 "aes-gmac", \ 468 "skipjack", 469 470 /* private allocations - based on RFC2407/IANA assignment */ 471 #define SADB_X_CALG_NONE 0 472 #define SADB_X_CALG_OUI 1 473 #define SADB_X_CALG_DEFLATE 2 474 #define SADB_X_CALG_LZS 3 475 #define SADB_X_CALG_MAX 4 476 477 #define SADB_CALG_STATS_INIT \ 478 [SADB_X_CALG_NONE] = 1, \ 479 [SADB_X_CALG_OUI] = 2, \ 480 [SADB_X_CALG_DEFLATE] = 3, \ 481 [SADB_X_CALG_LZS] = 4, 482 483 #define SADB_CALG_STATS_NUM 5 484 485 #define SADB_CALG_STATS_STR \ 486 "*unknown*", \ 487 "none", \ 488 "oui", \ 489 "deflate", \ 490 "lzs", 491 492 493 #define SADB_IDENTTYPE_RESERVED 0 494 #define SADB_IDENTTYPE_PREFIX 1 495 #define SADB_IDENTTYPE_FQDN 2 496 #define SADB_IDENTTYPE_USERFQDN 3 497 #define SADB_X_IDENTTYPE_ADDR 4 498 #define SADB_IDENTTYPE_MAX 4 499 500 /* `flags' in sadb_sa structure holds followings */ 501 #define SADB_X_EXT_NONE 0x0000 /* i.e. new format. */ 502 #define SADB_X_EXT_OLD 0x0001 /* old format. */ 503 504 #define SADB_X_EXT_IV4B 0x0010 /* IV length of 4 bytes in use */ 505 #define SADB_X_EXT_DERIV 0x0020 /* DES derived */ 506 #define SADB_X_EXT_CYCSEQ 0x0040 /* allowing to cyclic sequence. */ 507 508 /* three of followings are exclusive flags each them */ 509 #define SADB_X_EXT_PSEQ 0x0000 /* sequential padding for ESP */ 510 #define SADB_X_EXT_PRAND 0x0100 /* random padding for ESP */ 511 #define SADB_X_EXT_PZERO 0x0200 /* zero padding for ESP */ 512 #define SADB_X_EXT_PMASK 0x0300 /* mask for padding flag */ 513 514 #if 1 515 #define SADB_X_EXT_RAWCPI 0x0080 /* use well known CPI (IPComp) */ 516 #endif 517 518 #define SADB_KEY_FLAGS_MAX 0x0fff 519 520 /* SPI size for PF_KEYv2 */ 521 #define PFKEY_SPI_SIZE sizeof(uint32_t) 522 523 /* Identifier for menber of lifetime structure */ 524 #define SADB_X_LIFETIME_ALLOCATIONS 0 525 #define SADB_X_LIFETIME_BYTES 1 526 #define SADB_X_LIFETIME_ADDTIME 2 527 #define SADB_X_LIFETIME_USETIME 3 528 529 /* The rate for SOFT lifetime against HARD one. */ 530 #define PFKEY_SOFT_LIFETIME_RATE 80 531 532 /* Utilities */ 533 #define PFKEY_ALIGN8(a) (1 + (((a) - 1) | (8 - 1))) 534 #define PFKEY_EXTLEN(msg) \ 535 PFKEY_UNUNIT64(((const struct sadb_ext *)(const void *)(msg))->sadb_ext_len) 536 #define PFKEY_ADDR_PREFIX(ext) \ 537 (((const struct sadb_address *)(const void *)(ext))->sadb_address_prefixlen) 538 #define PFKEY_ADDR_PROTO(ext) \ 539 (((const struct sadb_address *)(const void *)(ext))->sadb_address_proto) 540 #define PFKEY_ADDR_SADDR(ext) \ 541 ((struct sockaddr *)(void *)((char *)(void *)(ext) + \ 542 sizeof(struct sadb_address))) 543 544 /* in 64bits */ 545 #define PFKEY_UNUNIT64(a) ((a) << 3) 546 #define PFKEY_UNIT64(a) ((a) >> 3) 547 548 #endif /* __PFKEY_V2_H */ 549 550 #endif /* !_NET_PFKEYV2_H_ */ 551