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