ip_ipsp.h revision 1.123
1/* $OpenBSD: ip_ipsp.h,v 1.123 2003/07/24 08:03:20 itojun Exp $ */ 2/* 3 * The authors of this code are John Ioannidis (ji@tla.org), 4 * Angelos D. Keromytis (kermit@csd.uch.gr), 5 * Niels Provos (provos@physnet.uni-hamburg.de) and 6 * Niklas Hallqvist (niklas@appli.se). 7 * 8 * The original version of this code was written by John Ioannidis 9 * for BSD/OS in Athens, Greece, in November 1995. 10 * 11 * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996, 12 * by Angelos D. Keromytis. 13 * 14 * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis 15 * and Niels Provos. 16 * 17 * Additional features in 1999 by Angelos D. Keromytis and Niklas Hallqvist. 18 * 19 * Copyright (c) 1995, 1996, 1997, 1998, 1999 by John Ioannidis, 20 * Angelos D. Keromytis and Niels Provos. 21 * Copyright (c) 1999 Niklas Hallqvist. 22 * Copyright (c) 2001, Angelos D. Keromytis. 23 * 24 * Permission to use, copy, and modify this software with or without fee 25 * is hereby granted, provided that this entire notice is included in 26 * all copies of any software which is or includes a copy or 27 * modification of this software. 28 * You may use this code under the GNU public license if you so wish. Please 29 * contribute changes back to the authors under this freer than GPL license 30 * so that we may further the use of strong encryption without limitations to 31 * all. 32 * 33 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 34 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY 35 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE 36 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR 37 * PURPOSE. 38 */ 39 40#ifndef _NETINET_IPSP_H_ 41#define _NETINET_IPSP_H_ 42 43/* IPSP global definitions. */ 44 45#include <sys/types.h> 46#include <sys/queue.h> 47#include <sys/timeout.h> 48#include <netinet/in.h> 49 50union sockaddr_union { 51 struct sockaddr sa; 52 struct sockaddr_in sin; 53 struct sockaddr_in6 sin6; 54}; 55 56/* HMAC key sizes */ 57#define MD5HMAC96_KEYSIZE 16 58#define SHA1HMAC96_KEYSIZE 20 59#define RIPEMD160HMAC96_KEYSIZE 20 60#define SHA2_256HMAC96_KEYSIZE 32 61#define SHA2_384HMAC96_KEYSIZE 48 62#define SHA2_512HMAC96_KEYSIZE 64 63 64#define AH_HMAC_HASHLEN 12 /* 96 bits of authenticator */ 65#define AH_HMAC_RPLENGTH 4 /* 32 bits of replay counter */ 66#define AH_HMAC_INITIAL_RPL 1 /* Replay counter initial value */ 67 68/* Authenticator lengths */ 69#define AH_MD5_ALEN 16 70#define AH_SHA1_ALEN 20 71#define AH_RMD160_ALEN 20 72#define AH_SHA2_256_ALEN 32 73#define AH_SHA2_384_ALEN 48 74#define AH_SHA2_512_ALEN 64 75#define AH_ALEN_MAX 64 /* Keep updated */ 76 77/* Reserved SPI numbers */ 78#define SPI_LOCAL_USE 0 79#define SPI_RESERVED_MIN 1 80#define SPI_RESERVED_MAX 255 81 82/* Reserved CPI numbers */ 83#define CPI_RESERVED_MIN 1 84#define CPI_RESERVED_MAX 255 85#define CPI_PRIVATE_MIN 61440 86#define CPI_PRIVATE_MAX 65535 87 88/* sysctl default values */ 89#define IPSEC_DEFAULT_EMBRYONIC_SA_TIMEOUT 60 /* 1 minute */ 90#define IPSEC_DEFAULT_PFS 1 91#define IPSEC_DEFAULT_SOFT_ALLOCATIONS 0 92#define IPSEC_DEFAULT_EXP_ALLOCATIONS 0 93#define IPSEC_DEFAULT_SOFT_BYTES 0 94#define IPSEC_DEFAULT_EXP_BYTES 0 95#define IPSEC_DEFAULT_SOFT_TIMEOUT 80000 96#define IPSEC_DEFAULT_EXP_TIMEOUT 86400 97#define IPSEC_DEFAULT_SOFT_FIRST_USE 3600 98#define IPSEC_DEFAULT_EXP_FIRST_USE 7200 99#define IPSEC_DEFAULT_DEF_ENC "aes" 100#define IPSEC_DEFAULT_DEF_AUTH "hmac-sha1" 101#define IPSEC_DEFAULT_EXPIRE_ACQUIRE 30 102#define IPSEC_DEFAULT_DEF_COMP "deflate" 103 104struct sockaddr_encap { 105 u_int8_t sen_len; /* length */ 106 u_int8_t sen_family; /* PF_KEY */ 107 u_int16_t sen_type; /* see SENT_* */ 108 union { 109 struct { /* SENT_IP4 */ 110 u_int8_t Direction; 111 struct in_addr Src; 112 struct in_addr Dst; 113 u_int8_t Proto; 114 u_int16_t Sport; 115 u_int16_t Dport; 116 } Sip4; 117 118 struct { /* SENT_IP6 */ 119 u_int8_t Direction; 120 struct in6_addr Src; 121 struct in6_addr Dst; 122 u_int8_t Proto; 123 u_int16_t Sport; 124 u_int16_t Dport; 125 } Sip6; 126 127 struct ipsec_policy *PolicyHead; /* SENT_IPSP */ 128 } Sen; 129}; 130 131#define IPSP_DIRECTION_IN 0x1 132#define IPSP_DIRECTION_OUT 0x2 133 134#define sen_data Sen.Data 135#define sen_ip_src Sen.Sip4.Src 136#define sen_ip_dst Sen.Sip4.Dst 137#define sen_proto Sen.Sip4.Proto 138#define sen_sport Sen.Sip4.Sport 139#define sen_dport Sen.Sip4.Dport 140#define sen_direction Sen.Sip4.Direction 141#define sen_ip6_src Sen.Sip6.Src 142#define sen_ip6_dst Sen.Sip6.Dst 143#define sen_ip6_proto Sen.Sip6.Proto 144#define sen_ip6_sport Sen.Sip6.Sport 145#define sen_ip6_dport Sen.Sip6.Dport 146#define sen_ip6_direction Sen.Sip6.Direction 147#define sen_ipsp Sen.PolicyHead 148 149/* 150 * The "type" is really part of the address as far as the routing 151 * system is concerned. By using only one bit in the type field 152 * for each type, we sort-of make sure that different types of 153 * encapsulation addresses won't be matched against the wrong type. 154 * 155 */ 156 157#define SENT_IP4 0x0001 /* data is two struct in_addr */ 158#define SENT_IPSP 0x0002 /* data as in IP4/6 plus SPI */ 159#define SENT_IP6 0x0004 160 161#define SENT_LEN sizeof(struct sockaddr_encap) 162 163struct ipsec_ref { 164 u_int16_t ref_type; /* Subtype of data */ 165 int16_t ref_len; /* Length of data following */ 166 int ref_count; /* Reference count */ 167 int ref_malloctype; /* malloc(9) type, for freeing */ 168}; 169 170struct ipsec_acquire { 171 union sockaddr_union ipa_addr; 172 u_int32_t ipa_seq; 173 struct sockaddr_encap ipa_info; 174 struct sockaddr_encap ipa_mask; 175 struct timeout ipa_timeout; 176 struct ipsec_policy *ipa_policy; 177 struct inpcb *ipa_pcb; 178 TAILQ_ENTRY(ipsec_acquire) ipa_ipo_next; 179 TAILQ_ENTRY(ipsec_acquire) ipa_next; 180 TAILQ_ENTRY(ipsec_acquire) ipa_inp_next; 181}; 182 183struct ipsec_policy { 184 struct sockaddr_encap ipo_addr; 185 struct sockaddr_encap ipo_mask; 186 187 union sockaddr_union ipo_src; /* Local address to use */ 188 union sockaddr_union ipo_dst; /* Remote gateway -- if it's zeroed: 189 * - on output, we try to contact the 190 * remote host directly (if needed). 191 * - on input, we accept on if the 192 * inner source is the same as the 193 * outer source address, or if transport 194 * mode was used. 195 */ 196 197 u_int64_t ipo_last_searched; /* Timestamp of last lookup */ 198 199 u_int8_t ipo_flags; /* See IPSP_POLICY_* definitions */ 200 u_int8_t ipo_type; /* USE/ACQUIRE/... */ 201 u_int8_t ipo_sproto; /* ESP/AH; if zero, use system dflts */ 202 203 int ipo_ref_count; 204 205 struct tdb *ipo_tdb; /* Cached entry */ 206 207 struct ipsec_ref *ipo_srcid; 208 struct ipsec_ref *ipo_dstid; 209 struct ipsec_ref *ipo_local_cred; 210 struct ipsec_ref *ipo_local_auth; 211 212 TAILQ_HEAD(ipo_acquires_head, ipsec_acquire) ipo_acquires; /* List of acquires */ 213 TAILQ_ENTRY(ipsec_policy) ipo_tdb_next; /* List TDB policies */ 214 TAILQ_ENTRY(ipsec_policy) ipo_list; /* List of all policies */ 215}; 216 217#define IPSP_POLICY_NONE 0x0000 /* No flags set */ 218#define IPSP_POLICY_SOCKET 0x0001 /* Socket-attached policy */ 219#define IPSP_POLICY_STATIC 0x0002 /* Static policy */ 220 221#define IPSP_IPSEC_USE 0 /* Use if existing, don't acquire */ 222#define IPSP_IPSEC_ACQUIRE 1 /* Try acquire, let packet through */ 223#define IPSP_IPSEC_REQUIRE 2 /* Require SA */ 224#define IPSP_PERMIT 3 /* Permit traffic through */ 225#define IPSP_DENY 4 /* Deny traffic */ 226#define IPSP_IPSEC_DONTACQ 5 /* Require, but don't acquire */ 227 228/* Notification types */ 229#define NOTIFY_SOFT_EXPIRE 0 /* Soft expiration of SA */ 230#define NOTIFY_HARD_EXPIRE 1 /* Hard expiration of SA */ 231#define NOTIFY_REQUEST_SA 2 /* Establish an SA */ 232 233#define NOTIFY_SATYPE_CONF 1 /* SA should do encryption */ 234#define NOTIFY_SATYPE_AUTH 2 /* SA should do authentication */ 235#define NOTIFY_SATYPE_TUNNEL 4 /* SA should use tunneling */ 236#define NOTIFY_SATYPE_COMP 5 /* SA (IPCA) should use compression */ 237 238/* Authentication types */ 239#define IPSP_AUTH_NONE 0 240#define IPSP_AUTH_PASSPHRASE 1 241#define IPSP_AUTH_RSA 2 242 243/* Credential types */ 244#define IPSP_CRED_NONE 0 245#define IPSP_CRED_KEYNOTE 1 246#define IPSP_CRED_X509 2 247 248/* Identity types */ 249#define IPSP_IDENTITY_NONE 0 250#define IPSP_IDENTITY_PREFIX 1 251#define IPSP_IDENTITY_FQDN 2 252#define IPSP_IDENTITY_USERFQDN 3 253#define IPSP_IDENTITY_CONNECTION 4 254 255/* 256 * For encapsulation routes are possible not only for the destination 257 * address but also for the protocol, source and destination ports 258 * if available 259 */ 260 261struct route_enc { 262 struct rtentry *re_rt; 263 struct sockaddr_encap re_dst; 264}; 265 266struct tdb { /* tunnel descriptor block */ 267 /* 268 * Each TDB is on three hash tables: one keyed on dst/spi/sproto, 269 * one keyed on dst/sproto, and one keyed on src/sproto. The first 270 * is used for finding a specific TDB, the second for finding TDBs 271 * TDBs for outgoing policy matching, and the third for incoming 272 * policy matching. The following three fields maintain the hash 273 * queues in those three tables. 274 */ 275 struct tdb *tdb_hnext; /* dst/spi/sproto table */ 276 struct tdb *tdb_anext; /* dst/sproto table */ 277 struct tdb *tdb_snext; /* src/sproto table */ 278 struct tdb *tdb_inext; 279 struct tdb *tdb_onext; 280 281 struct xformsw *tdb_xform; /* Transform to use */ 282 struct enc_xform *tdb_encalgxform; /* Enc algorithm */ 283 struct auth_hash *tdb_authalgxform; /* Auth algorithm */ 284 struct comp_algo *tdb_compalgxform; /* Compression algo */ 285 286#define TDBF_UNIQUE 0x00001 /* This should not be used by others */ 287#define TDBF_TIMER 0x00002 /* Absolute expiration timer in use */ 288#define TDBF_BYTES 0x00004 /* Check the byte counters */ 289#define TDBF_ALLOCATIONS 0x00008 /* Check the flows counters */ 290#define TDBF_INVALID 0x00010 /* This SPI is not valid yet/anymore */ 291#define TDBF_FIRSTUSE 0x00020 /* Expire after first use */ 292#define TDBF_HALFIV 0x00040 /* Use half-length IV (ESP old only) */ 293#define TDBF_SOFT_TIMER 0x00080 /* Soft expiration */ 294#define TDBF_SOFT_BYTES 0x00100 /* Soft expiration */ 295#define TDBF_SOFT_ALLOCATIONS 0x00200 /* Soft expiration */ 296#define TDBF_SOFT_FIRSTUSE 0x00400 /* Soft expiration */ 297#define TDBF_PFS 0x00800 /* Ask for PFS from Key Mgmt. */ 298#define TDBF_TUNNELING 0x01000 /* Force IP-IP encapsulation */ 299#define TDBF_NOREPLAY 0x02000 /* No replay counter present */ 300#define TDBF_RANDOMPADDING 0x04000 /* Random data in the ESP padding */ 301#define TDBF_SKIPCRYPTO 0x08000 /* Skip actual crypto processing */ 302#define TDBF_USEDTUNNEL 0x10000 /* Appended a tunnel header in past */ 303 304 u_int32_t tdb_flags; /* Flags related to this TDB */ 305 306 struct timeout tdb_timer_tmo; 307 struct timeout tdb_first_tmo; 308 struct timeout tdb_stimer_tmo; 309 struct timeout tdb_sfirst_tmo; 310 311 u_int32_t tdb_seq; /* Tracking number for PFKEY */ 312 u_int32_t tdb_exp_allocations; /* Expire after so many flows */ 313 u_int32_t tdb_soft_allocations; /* Expiration warning */ 314 u_int32_t tdb_cur_allocations; /* Total number of allocs */ 315 316 u_int64_t tdb_exp_bytes; /* Expire after so many bytes passed */ 317 u_int64_t tdb_soft_bytes; /* Expiration warning */ 318 u_int64_t tdb_cur_bytes; /* Current count of bytes */ 319 320 u_int64_t tdb_exp_timeout; /* When does the SPI expire */ 321 u_int64_t tdb_soft_timeout; /* Send soft-expire warning */ 322 u_int64_t tdb_established; /* When was SPI established */ 323 324 u_int64_t tdb_first_use; /* When was it first used */ 325 u_int64_t tdb_soft_first_use; /* Soft warning */ 326 u_int64_t tdb_exp_first_use; /* Expire if tdb_first_use + 327 * tdb_exp_first_use <= curtime 328 */ 329 330 u_int64_t tdb_last_used; /* When was this SA last used */ 331 u_int64_t tdb_last_marked;/* Last SKIPCRYPTO status change */ 332 333 u_int64_t tdb_cryptoid; /* Crypto session ID */ 334 335 u_int32_t tdb_spi; /* SPI */ 336 u_int16_t tdb_amxkeylen; /* Raw authentication key length */ 337 u_int16_t tdb_emxkeylen; /* Raw encryption key length */ 338 u_int16_t tdb_ivlen; /* IV length */ 339 u_int8_t tdb_sproto; /* IPsec protocol */ 340 u_int8_t tdb_wnd; /* Replay window */ 341 u_int8_t tdb_satype; /* SA type (RFC2367, PF_KEY) */ 342 343 union sockaddr_union tdb_dst; /* Destination address */ 344 union sockaddr_union tdb_src; /* Source address */ 345 union sockaddr_union tdb_proxy; 346 347 u_int8_t *tdb_amxkey; /* Raw authentication key */ 348 u_int8_t *tdb_emxkey; /* Raw encryption key */ 349 350 u_int32_t tdb_rpl; /* Replay counter */ 351 u_int32_t tdb_bitmap; /* Used for replay sliding window */ 352 353 u_int32_t tdb_epoch; /* Used by the kernfs interface */ 354 u_int8_t tdb_iv[4]; /* Used for HALF-IV ESP */ 355 356 struct ipsec_ref *tdb_local_cred; 357 struct ipsec_ref *tdb_remote_cred; 358 struct ipsec_ref *tdb_srcid; /* Source ID for this SA */ 359 struct ipsec_ref *tdb_dstid; /* Destination ID for this SA */ 360 struct ipsec_ref *tdb_local_auth;/* Local authentication material */ 361 struct ipsec_ref *tdb_remote_auth;/* Remote authentication material */ 362 363 u_int32_t tdb_mtu; /* MTU at this point in the chain */ 364 u_int64_t tdb_mtutimeout; /* When to ignore this entry */ 365 366 struct sockaddr_encap tdb_filter; /* What traffic is acceptable */ 367 struct sockaddr_encap tdb_filtermask; /* And the mask */ 368 369 TAILQ_HEAD(tdb_inp_head_in, inpcb) tdb_inp_in; 370 TAILQ_HEAD(tdb_inp_head_out, inpcb) tdb_inp_out; 371 TAILQ_HEAD(tdb_policy_head, ipsec_policy) tdb_policy_head; 372}; 373 374struct tdb_ident { 375 u_int32_t spi; 376 union sockaddr_union dst; 377 u_int8_t proto; 378}; 379 380struct tdb_crypto { 381 u_int32_t tc_spi; 382 union sockaddr_union tc_dst; 383 u_int8_t tc_proto; 384 int tc_protoff; 385 int tc_skip; 386 caddr_t tc_ptr; 387}; 388 389struct ipsecinit { 390 u_int8_t *ii_enckey; 391 u_int8_t *ii_authkey; 392 u_int16_t ii_enckeylen; 393 u_int16_t ii_authkeylen; 394 u_int8_t ii_encalg; 395 u_int8_t ii_authalg; 396 u_int8_t ii_compalg; 397}; 398 399/* xform IDs */ 400#define XF_IP4 1 /* IP inside IP */ 401#define XF_AH 2 /* AH */ 402#define XF_ESP 3 /* ESP */ 403#define XF_TCPSIGNATURE 5 /* TCP MD5 Signature option, RFC 2358 */ 404#define XF_IPCOMP 6 /* IPCOMP */ 405 406/* xform attributes */ 407#define XFT_AUTH 0x0001 408#define XFT_CONF 0x0100 409#define XFT_COMP 0x1000 410 411#define IPSEC_ZEROES_SIZE 256 /* Larger than an IP6 extension hdr. */ 412#define IPSEC_KERNFS_BUFSIZE 4096 413 414#if BYTE_ORDER == LITTLE_ENDIAN 415static __inline u_int64_t 416htonq(u_int64_t q) 417{ 418 register u_int32_t u, l; 419 u = q >> 32; 420 l = (u_int32_t) q; 421 422 return htonl(u) | ((u_int64_t)htonl(l) << 32); 423} 424 425#define ntohq(_x) htonq(_x) 426 427#elif BYTE_ORDER == BIG_ENDIAN 428 429#define htonq(_x) (_x) 430#define ntohq(_x) htonq(_x) 431 432#else 433#error "Please fix <machine/endian.h>" 434#endif 435 436#ifdef _KERNEL 437 438struct xformsw { 439 u_short xf_type; /* Unique ID of xform */ 440 u_short xf_flags; /* flags (see below) */ 441 char *xf_name; /* human-readable name */ 442 int (*xf_attach)(void); /* called at config time */ 443 int (*xf_init)(struct tdb *, struct xformsw *, struct ipsecinit *); 444 int (*xf_zeroize)(struct tdb *); /* termination */ 445 int (*xf_input)(struct mbuf *, struct tdb *, int, int); /* input */ 446 int (*xf_output)(struct mbuf *, struct tdb *, struct mbuf **, 447 int, int); /* output */ 448}; 449 450/* 451 * Protects all tdb lists. 452 * Must at least be splsoftnet (note: do not use splsoftclock as it is 453 * special on some architectures, assuming it is always an spl lowering 454 * operation). 455 */ 456#define spltdb splsoftnet 457 458extern int encdebug; 459extern int ipsec_acl; 460extern int ipsec_keep_invalid; 461extern int ipsec_in_use; 462extern u_int64_t ipsec_last_added; 463extern int ipsec_require_pfs; 464extern int ipsec_expire_acquire; 465 466extern int ipsec_policy_pool_initialized; 467 468extern int ipsec_soft_allocations; 469extern int ipsec_exp_allocations; 470extern int ipsec_soft_bytes; 471extern int ipsec_exp_bytes; 472extern int ipsec_soft_timeout; 473extern int ipsec_exp_timeout; 474extern int ipsec_soft_first_use; 475extern int ipsec_exp_first_use; 476extern char ipsec_def_enc[]; 477extern char ipsec_def_auth[]; 478extern char ipsec_def_comp[]; 479 480extern struct enc_xform enc_xform_des; 481extern struct enc_xform enc_xform_3des; 482extern struct enc_xform enc_xform_blf; 483extern struct enc_xform enc_xform_cast5; 484extern struct enc_xform enc_xform_skipjack; 485 486extern struct auth_hash auth_hash_hmac_md5_96; 487extern struct auth_hash auth_hash_hmac_sha1_96; 488extern struct auth_hash auth_hash_hmac_ripemd_160_96; 489 490extern struct comp_algo comp_algo_deflate; 491 492extern TAILQ_HEAD(ipsec_policy_head, ipsec_policy) ipsec_policy_head; 493extern TAILQ_HEAD(ipsec_acquire_head, ipsec_acquire) ipsec_acquire_head; 494 495extern struct xformsw xformsw[], *xformswNXFORMSW; 496 497/* Check if a given tdb has encryption, authentication and/or tunneling */ 498#define TDB_ATTRIB(x) (((x)->tdb_encalgxform ? NOTIFY_SATYPE_CONF : 0) | \ 499 ((x)->tdb_authalgxform ? NOTIFY_SATYPE_AUTH : 0) | \ 500 ((x)->tdb_compalgxform ? NOTIFY_SATYPE_COMP : 0)) 501 502/* Traverse spi chain and get attributes */ 503 504#define SPI_CHAIN_ATTRIB(have, TDB_DIR, TDBP) do {\ 505 int s = spltdb(); \ 506 struct tdb *tmptdb = (TDBP); \ 507 \ 508 (have) = 0; \ 509 while (tmptdb && tmptdb->tdb_xform) { \ 510 if (tmptdb == NULL || tmptdb->tdb_flags & TDBF_INVALID) \ 511 break; \ 512 (have) |= TDB_ATTRIB(tmptdb); \ 513 tmptdb = tmptdb->TDB_DIR; \ 514 } \ 515 splx(s); \ 516} while (0) 517 518/* Misc. */ 519extern char *inet_ntoa4(struct in_addr); 520extern char *ipsp_address(union sockaddr_union); 521 522/* TDB management routines */ 523extern void tdb_add_inp(struct tdb *, struct inpcb *, int); 524extern u_int32_t reserve_spi(u_int32_t, u_int32_t, union sockaddr_union *, 525 union sockaddr_union *, u_int8_t, int *); 526extern struct tdb *gettdb(u_int32_t, union sockaddr_union *, u_int8_t); 527extern struct tdb *gettdbbyaddr(union sockaddr_union *, u_int8_t, 528 struct ipsec_ref *, struct ipsec_ref *, struct ipsec_ref *, 529 struct mbuf *, int, struct sockaddr_encap *, struct sockaddr_encap *); 530extern struct tdb *gettdbbysrc(union sockaddr_union *, u_int8_t, 531 struct ipsec_ref *, struct ipsec_ref *, struct mbuf *, int, 532 struct sockaddr_encap *, struct sockaddr_encap *); 533extern void puttdb(struct tdb *); 534extern void tdb_delete(struct tdb *); 535extern struct tdb *tdb_alloc(void); 536extern int tdb_init(struct tdb *, u_int16_t, struct ipsecinit *); 537extern int tdb_walk(int (*)(struct tdb *, void *, int), void *); 538 539/* XF_IP4 */ 540extern int ipe4_attach(void); 541extern int ipe4_init(struct tdb *, struct xformsw *, struct ipsecinit *); 542extern int ipe4_zeroize(struct tdb *); 543extern int ipip_output(struct mbuf *, struct tdb *, struct mbuf **, int, int); 544extern void ipe4_input(struct mbuf *, ...); 545extern void ipip_input(struct mbuf *, int, struct ifnet *); 546 547#ifdef INET 548extern void ip4_input(struct mbuf *, ...); 549#endif /* INET */ 550 551#ifdef INET6 552extern int ip4_input6(struct mbuf **, int *, int); 553#endif /* INET */ 554 555/* XF_ETHERIP */ 556extern int etherip_output(struct mbuf *, struct tdb *, struct mbuf **, 557 int, int); 558extern void etherip_input(struct mbuf *, ...); 559 560/* XF_AH */ 561extern int ah_attach(void); 562extern int ah_init(struct tdb *, struct xformsw *, struct ipsecinit *); 563extern int ah_zeroize(struct tdb *); 564extern int ah_output(struct mbuf *, struct tdb *, struct mbuf **, int, int); 565extern int ah_output_cb(void *); 566extern int ah_input(struct mbuf *, struct tdb *, int, int); 567extern int ah_input_cb(void *); 568extern int ah_sysctl(int *, u_int, void *, size_t *, void *, size_t); 569extern int ah_massage_headers(struct mbuf **, int, int, int, int); 570 571#ifdef INET 572extern void ah4_input(struct mbuf *, ...); 573extern int ah4_input_cb(struct mbuf *, ...); 574extern void *ah4_ctlinput(int, struct sockaddr *, void *); 575#endif /* INET */ 576 577#ifdef INET6 578extern int ah6_input(struct mbuf **, int *, int); 579extern int ah6_input_cb(struct mbuf *, int, int); 580#endif /* INET6 */ 581 582/* XF_ESP */ 583extern int esp_attach(void); 584extern int esp_init(struct tdb *, struct xformsw *, struct ipsecinit *); 585extern int esp_zeroize(struct tdb *); 586extern int esp_output(struct mbuf *, struct tdb *, struct mbuf **, int, int); 587extern int esp_output_cb(void *); 588extern int esp_input(struct mbuf *, struct tdb *, int, int); 589extern int esp_input_cb(void *); 590extern int esp_sysctl(int *, u_int, void *, size_t *, void *, size_t); 591 592#ifdef INET 593extern void esp4_input(struct mbuf *, ...); 594extern int esp4_input_cb(struct mbuf *, ...); 595extern void *esp4_ctlinput(int, struct sockaddr *, void *); 596#endif /* INET */ 597 598#ifdef INET6 599extern int esp6_input(struct mbuf **, int *, int); 600extern int esp6_input_cb(struct mbuf *, int, int); 601#endif /* INET6 */ 602 603/* XF_IPCOMP */ 604extern int ipcomp_attach(void); 605extern int ipcomp_init(struct tdb *, struct xformsw *, struct ipsecinit *); 606extern int ipcomp_zeroize(struct tdb *); 607extern int ipcomp_output(struct mbuf *, struct tdb *, struct mbuf **, int, int); 608extern int ipcomp_output_cb(void *); 609extern int ipcomp_input(struct mbuf *, struct tdb *, int, int); 610extern int ipcomp_input_cb(void *); 611extern int ipcomp_sysctl(int *, u_int, void *, size_t *, void *, size_t); 612 613#ifdef INET 614extern void ipcomp4_input(struct mbuf *, ...); 615extern int ipcomp4_input_cb(struct mbuf *, ...); 616#endif /* INET */ 617 618#ifdef INET6 619extern int ipcomp6_input(struct mbuf **, int *, int); 620extern int ipcomp6_input_cb(struct mbuf *, int, int); 621#endif /* INET6 */ 622 623/* XF_TCPSIGNATURE */ 624extern int tcp_signature_tdb_attach(void); 625extern int tcp_signature_tdb_init(struct tdb *, struct xformsw *, 626 struct ipsecinit *); 627extern int tcp_signature_tdb_zeroize(struct tdb *); 628extern int tcp_signature_tdb_input(struct mbuf *, struct tdb *, int, 629 int); 630extern int tcp_signature_tdb_output(struct mbuf *, struct tdb *, 631 struct mbuf **, int, int); 632 633/* Padding */ 634extern caddr_t m_pad(struct mbuf *, int); 635 636/* Replay window */ 637extern int checkreplaywindow32(u_int32_t, u_int32_t, u_int32_t *, u_int32_t, 638 u_int32_t *, int); 639 640extern unsigned char ipseczeroes[]; 641 642/* Packet processing */ 643extern int ipsp_process_packet(struct mbuf *, struct tdb *, int, int); 644extern int ipsp_process_done(struct mbuf *, struct tdb *); 645extern struct tdb *ipsp_spd_lookup(struct mbuf *, int, int, int *, int, 646 struct tdb *, struct inpcb *); 647extern struct tdb *ipsp_spd_inp(struct mbuf *, int, int, int *, int, 648 struct tdb *, struct inpcb *, struct ipsec_policy *); 649extern int ipsec_common_input_cb(struct mbuf *, struct tdb *, int, int, 650 struct m_tag *); 651extern int ipsp_acquire_sa(struct ipsec_policy *, union sockaddr_union *, 652 union sockaddr_union *, struct sockaddr_encap *, struct mbuf *); 653extern struct ipsec_policy *ipsec_add_policy(struct inpcb *, int, int); 654extern void ipsec_update_policy(struct inpcb *, struct ipsec_policy *, 655 int, int); 656extern int ipsec_delete_policy(struct ipsec_policy *); 657extern struct ipsec_acquire *ipsp_pending_acquire(struct ipsec_policy *, 658 union sockaddr_union *); 659extern void ipsp_delete_acquire(void *); 660extern int ipsp_is_unspecified(union sockaddr_union); 661extern void ipsp_reffree(struct ipsec_ref *); 662extern void ipsp_skipcrypto_unmark(struct tdb_ident *); 663extern void ipsp_skipcrypto_mark(struct tdb_ident *); 664extern struct m_tag *ipsp_parse_headers(struct mbuf *, int, u_int8_t); 665extern int ipsp_ref_match(struct ipsec_ref *, struct ipsec_ref *); 666extern ssize_t ipsec_hdrsz(struct tdb *); 667extern void ipsec_adjust_mtu(struct mbuf *, u_int32_t); 668extern int ipsp_print_tdb(struct tdb *, char *, size_t); 669extern struct ipsec_acquire *ipsec_get_acquire(u_int32_t); 670extern int ipsp_aux_match(struct ipsec_ref *, struct ipsec_ref *, 671 struct ipsec_ref *, struct ipsec_ref *, struct ipsec_ref *, 672 struct ipsec_ref *, struct ipsec_ref *, struct ipsec_ref *, 673 struct sockaddr_encap *, struct sockaddr_encap *, 674 struct sockaddr_encap *, struct sockaddr_encap *); 675#endif /* _KERNEL */ 676#endif /* _NETINET_IPSP_H_ */ 677