188768458SSam Leffler /* $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $ */ 288768458SSam Leffler 3c398230bSWarner Losh /*- 451369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 551369649SPedro F. Giffuni * 688768458SSam Leffler * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 788768458SSam Leffler * All rights reserved. 888768458SSam Leffler * 988768458SSam Leffler * Redistribution and use in source and binary forms, with or without 1088768458SSam Leffler * modification, are permitted provided that the following conditions 1188768458SSam Leffler * are met: 1288768458SSam Leffler * 1. Redistributions of source code must retain the above copyright 1388768458SSam Leffler * notice, this list of conditions and the following disclaimer. 1488768458SSam Leffler * 2. Redistributions in binary form must reproduce the above copyright 1588768458SSam Leffler * notice, this list of conditions and the following disclaimer in the 1688768458SSam Leffler * documentation and/or other materials provided with the distribution. 1788768458SSam Leffler * 3. Neither the name of the project nor the names of its contributors 1888768458SSam Leffler * may be used to endorse or promote products derived from this software 1988768458SSam Leffler * without specific prior written permission. 2088768458SSam Leffler * 2188768458SSam Leffler * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2288768458SSam Leffler * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2388768458SSam Leffler * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2488768458SSam Leffler * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2588768458SSam Leffler * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2688768458SSam Leffler * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2788768458SSam Leffler * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2888768458SSam Leffler * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2988768458SSam Leffler * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3088768458SSam Leffler * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3188768458SSam Leffler * SUCH DAMAGE. 3288768458SSam Leffler */ 3388768458SSam Leffler 3488768458SSam Leffler /* 3588768458SSam Leffler * IPsec controller part. 3688768458SSam Leffler */ 3788768458SSam Leffler 3888768458SSam Leffler #ifndef _NETIPSEC_IPSEC_H_ 3988768458SSam Leffler #define _NETIPSEC_IPSEC_H_ 4088768458SSam Leffler 4188768458SSam Leffler #include <net/pfkeyv2.h> 4288768458SSam Leffler #include <netipsec/keydb.h> 4388768458SSam Leffler 4488768458SSam Leffler #ifdef _KERNEL 4588768458SSam Leffler 462d957916SAndrey V. Elsukov #include <sys/_lock.h> 472d957916SAndrey V. Elsukov #include <sys/_mutex.h> 482d957916SAndrey V. Elsukov #include <sys/_rwlock.h> 492d957916SAndrey V. Elsukov 504b4b5fb6SGeorge V. Neville-Neil #define IPSEC_ASSERT(_c,_m) KASSERT(_c, _m) 514b4b5fb6SGeorge V. Neville-Neil 5288768458SSam Leffler /* 5388768458SSam Leffler * Security Policy Index 5488768458SSam Leffler * Ensure that both address families in the "src" and "dst" are same. 5588768458SSam Leffler * When the value of the ul_proto is ICMPv6, the port field in "src" 5688768458SSam Leffler * specifies ICMPv6 type, and the port field in "dst" specifies ICMPv6 code. 5788768458SSam Leffler */ 5888768458SSam Leffler struct secpolicyindex { 5988768458SSam Leffler union sockaddr_union src; /* IP src address for SP */ 6088768458SSam Leffler union sockaddr_union dst; /* IP dst address for SP */ 61fcf59617SAndrey V. Elsukov uint8_t ul_proto; /* upper layer Protocol */ 62fcf59617SAndrey V. Elsukov uint8_t dir; /* direction of packet flow */ 63fcf59617SAndrey V. Elsukov uint8_t prefs; /* prefix length in bits for src */ 64fcf59617SAndrey V. Elsukov uint8_t prefd; /* prefix length in bits for dst */ 65fcf59617SAndrey V. Elsukov }; 66fcf59617SAndrey V. Elsukov 67fcf59617SAndrey V. Elsukov /* Request for IPsec */ 68fcf59617SAndrey V. Elsukov struct ipsecrequest { 69fcf59617SAndrey V. Elsukov struct secasindex saidx;/* hint for search proper SA */ 70fcf59617SAndrey V. Elsukov /* if __ss_len == 0 then no address specified.*/ 71fcf59617SAndrey V. Elsukov u_int level; /* IPsec level defined below. */ 7288768458SSam Leffler }; 7388768458SSam Leffler 7488768458SSam Leffler /* Security Policy Data Base */ 7588768458SSam Leffler struct secpolicy { 7693201211SAndrey V. Elsukov TAILQ_ENTRY(secpolicy) chain; 77fcf59617SAndrey V. Elsukov LIST_ENTRY(secpolicy) idhash; 78fcf59617SAndrey V. Elsukov LIST_ENTRY(secpolicy) drainq; 7988768458SSam Leffler 8088768458SSam Leffler struct secpolicyindex spidx; /* selector */ 81fcf59617SAndrey V. Elsukov #define IPSEC_MAXREQ 4 82fcf59617SAndrey V. Elsukov struct ipsecrequest *req[IPSEC_MAXREQ]; 83fcf59617SAndrey V. Elsukov u_int tcount; /* IPsec transforms count */ 84fcf59617SAndrey V. Elsukov volatile u_int refcnt; /* reference count */ 8593201211SAndrey V. Elsukov u_int policy; /* policy_type per pfkeyv2.h */ 8647568136SAndrey V. Elsukov u_int state; 8747568136SAndrey V. Elsukov #define IPSEC_SPSTATE_DEAD 0 88fcf59617SAndrey V. Elsukov #define IPSEC_SPSTATE_LARVAL 1 89fcf59617SAndrey V. Elsukov #define IPSEC_SPSTATE_ALIVE 2 90fcf59617SAndrey V. Elsukov #define IPSEC_SPSTATE_PCB 3 91fcf59617SAndrey V. Elsukov #define IPSEC_SPSTATE_IFNET 4 92fcf59617SAndrey V. Elsukov uint32_t priority; /* priority of this policy */ 93fcf59617SAndrey V. Elsukov uint32_t id; /* It's unique number on the system. */ 9488768458SSam Leffler /* 9588768458SSam Leffler * lifetime handler. 9688768458SSam Leffler * the policy can be used without limitiation if both lifetime and 9788768458SSam Leffler * validtime are zero. 9888768458SSam Leffler * "lifetime" is passed by sadb_lifetime.sadb_lifetime_addtime. 9988768458SSam Leffler * "validtime" is passed by sadb_lifetime.sadb_lifetime_usetime. 10088768458SSam Leffler */ 1019ffa9677SSam Leffler time_t created; /* time created the policy */ 1029ffa9677SSam Leffler time_t lastused; /* updated every when kernel sends a packet */ 10388768458SSam Leffler long lifetime; /* duration of the lifetime of this policy */ 10488768458SSam Leffler long validtime; /* duration this policy is valid without use */ 10588768458SSam Leffler }; 10688768458SSam Leffler 1079ffa9677SSam Leffler /* 108fcf59617SAndrey V. Elsukov * PCB security policies. 109fcf59617SAndrey V. Elsukov * Application can setup private security policies for socket. 110fcf59617SAndrey V. Elsukov * Such policies can have IPSEC, BYPASS and ENTRUST type. 111fcf59617SAndrey V. Elsukov * By default, policies are set to NULL. This means that they have ENTRUST type. 112fcf59617SAndrey V. Elsukov * When application sets BYPASS or IPSEC type policy, the flags field 113fcf59617SAndrey V. Elsukov * is also updated. When flags is not set, the system could store 114fcf59617SAndrey V. Elsukov * used security policy into the sp_in/sp_out pointer to speed up further 115fcf59617SAndrey V. Elsukov * lookups. 1169ffa9677SSam Leffler */ 11788768458SSam Leffler struct inpcbpolicy { 11888768458SSam Leffler struct secpolicy *sp_in; 11988768458SSam Leffler struct secpolicy *sp_out; 120fcf59617SAndrey V. Elsukov 121fcf59617SAndrey V. Elsukov uint32_t genid; 122fcf59617SAndrey V. Elsukov uint16_t flags; 123fcf59617SAndrey V. Elsukov #define INP_INBOUND_POLICY 0x0001 124fcf59617SAndrey V. Elsukov #define INP_OUTBOUND_POLICY 0x0002 125fcf59617SAndrey V. Elsukov uint16_t hdrsz; 12688768458SSam Leffler }; 12788768458SSam Leffler 12888768458SSam Leffler /* SP acquiring list table. */ 12988768458SSam Leffler struct secspacq { 13088768458SSam Leffler LIST_ENTRY(secspacq) chain; 13188768458SSam Leffler 13288768458SSam Leffler struct secpolicyindex spidx; 13388768458SSam Leffler 1349ffa9677SSam Leffler time_t created; /* for lifetime */ 13588768458SSam Leffler int count; /* for lifetime */ 13688768458SSam Leffler /* XXX: here is mbuf place holder to be sent ? */ 13788768458SSam Leffler }; 13888768458SSam Leffler #endif /* _KERNEL */ 13988768458SSam Leffler 140fcf59617SAndrey V. Elsukov /* buffer size for formatted output of ipsec address */ 141fcf59617SAndrey V. Elsukov #define IPSEC_ADDRSTRLEN (INET6_ADDRSTRLEN + 11) 142fcf59617SAndrey V. Elsukov 14388768458SSam Leffler /* according to IANA assignment, port 0x0000 and proto 0xff are reserved. */ 14488768458SSam Leffler #define IPSEC_PORT_ANY 0 14588768458SSam Leffler #define IPSEC_ULPROTO_ANY 255 14688768458SSam Leffler #define IPSEC_PROTO_ANY 255 14788768458SSam Leffler 14888768458SSam Leffler /* mode of security protocol */ 14988768458SSam Leffler /* NOTE: DON'T use IPSEC_MODE_ANY at SPD. It's only use in SAD */ 15088768458SSam Leffler #define IPSEC_MODE_ANY 0 /* i.e. wildcard. */ 15188768458SSam Leffler #define IPSEC_MODE_TRANSPORT 1 15288768458SSam Leffler #define IPSEC_MODE_TUNNEL 2 1531cfd4b53SBruce M Simpson #define IPSEC_MODE_TCPMD5 3 /* TCP MD5 mode */ 15488768458SSam Leffler 15588768458SSam Leffler /* 15688768458SSam Leffler * Direction of security policy. 15788768458SSam Leffler * NOTE: Since INVALID is used just as flag. 15888768458SSam Leffler * The other are used for loop counter too. 15988768458SSam Leffler */ 16088768458SSam Leffler #define IPSEC_DIR_ANY 0 16188768458SSam Leffler #define IPSEC_DIR_INBOUND 1 16288768458SSam Leffler #define IPSEC_DIR_OUTBOUND 2 16388768458SSam Leffler #define IPSEC_DIR_MAX 3 16488768458SSam Leffler #define IPSEC_DIR_INVALID 4 16588768458SSam Leffler 16688768458SSam Leffler /* Policy level */ 16788768458SSam Leffler /* 16888768458SSam Leffler * IPSEC, ENTRUST and BYPASS are allowed for setsockopt() in PCB, 16988768458SSam Leffler * DISCARD, IPSEC and NONE are allowed for setkey() in SPD. 17088768458SSam Leffler * DISCARD and NONE are allowed for system default. 17188768458SSam Leffler */ 17288768458SSam Leffler #define IPSEC_POLICY_DISCARD 0 /* discarding packet */ 17388768458SSam Leffler #define IPSEC_POLICY_NONE 1 /* through IPsec engine */ 17488768458SSam Leffler #define IPSEC_POLICY_IPSEC 2 /* do IPsec */ 17588768458SSam Leffler #define IPSEC_POLICY_ENTRUST 3 /* consulting SPD if present. */ 17688768458SSam Leffler #define IPSEC_POLICY_BYPASS 4 /* only for privileged socket. */ 17788768458SSam Leffler 17822986c67SAndrey V. Elsukov /* Policy scope */ 17922986c67SAndrey V. Elsukov #define IPSEC_POLICYSCOPE_ANY 0x00 /* unspecified */ 18022986c67SAndrey V. Elsukov #define IPSEC_POLICYSCOPE_GLOBAL 0x01 /* global scope */ 18122986c67SAndrey V. Elsukov #define IPSEC_POLICYSCOPE_IFNET 0x02 /* if_ipsec(4) scope */ 18222986c67SAndrey V. Elsukov #define IPSEC_POLICYSCOPE_PCB 0x04 /* PCB scope */ 18322986c67SAndrey V. Elsukov 18488768458SSam Leffler /* Security protocol level */ 18588768458SSam Leffler #define IPSEC_LEVEL_DEFAULT 0 /* reference to system default */ 18688768458SSam Leffler #define IPSEC_LEVEL_USE 1 /* use SA if present. */ 18788768458SSam Leffler #define IPSEC_LEVEL_REQUIRE 2 /* require SA. */ 18888768458SSam Leffler #define IPSEC_LEVEL_UNIQUE 3 /* unique SA. */ 18988768458SSam Leffler 19088768458SSam Leffler #define IPSEC_MANUAL_REQID_MAX 0x3fff 19188768458SSam Leffler /* 19288768458SSam Leffler * if security policy level == unique, this id 19388768458SSam Leffler * indicate to a relative SA for use, else is 19488768458SSam Leffler * zero. 19588768458SSam Leffler * 1 - 0x3fff are reserved for manual keying. 19688768458SSam Leffler * 0 are reserved for above reason. Others is 19788768458SSam Leffler * for kernel use. 19888768458SSam Leffler * Note that this id doesn't identify SA 19988768458SSam Leffler * by only itself. 20088768458SSam Leffler */ 20188768458SSam Leffler #define IPSEC_REPLAYWSIZE 32 20288768458SSam Leffler 2032cb64cb2SGeorge V. Neville-Neil /* statistics for ipsec processing */ 20488768458SSam Leffler struct ipsecstat { 205c80211e3SAndrey V. Elsukov uint64_t ips_in_polvio; /* input: sec policy violation */ 2066794f460SAndrey V. Elsukov uint64_t ips_in_nomem; /* input: no memory available */ 2076794f460SAndrey V. Elsukov uint64_t ips_in_inval; /* input: generic error */ 2086794f460SAndrey V. Elsukov 209c80211e3SAndrey V. Elsukov uint64_t ips_out_polvio; /* output: sec policy violation */ 210c80211e3SAndrey V. Elsukov uint64_t ips_out_nosa; /* output: SA unavailable */ 211c80211e3SAndrey V. Elsukov uint64_t ips_out_nomem; /* output: no memory available */ 212c80211e3SAndrey V. Elsukov uint64_t ips_out_noroute; /* output: no route available */ 213c80211e3SAndrey V. Elsukov uint64_t ips_out_inval; /* output: generic error */ 214c80211e3SAndrey V. Elsukov uint64_t ips_out_bundlesa; /* output: bundled SA processed */ 2156794f460SAndrey V. Elsukov 216f8e73c47SFabien Thomas uint64_t ips_spdcache_hits; /* SPD cache hits */ 217f8e73c47SFabien Thomas uint64_t ips_spdcache_misses; /* SPD cache misses */ 218f8e73c47SFabien Thomas 219c80211e3SAndrey V. Elsukov uint64_t ips_clcopied; /* clusters copied during clone */ 220c80211e3SAndrey V. Elsukov uint64_t ips_mbinserted; /* mbufs inserted during makespace */ 22188768458SSam Leffler /* 22288768458SSam Leffler * Temporary statistics for performance analysis. 22388768458SSam Leffler */ 22488768458SSam Leffler /* See where ESP/AH/IPCOMP header land in mbuf on input */ 225c80211e3SAndrey V. Elsukov uint64_t ips_input_front; 226c80211e3SAndrey V. Elsukov uint64_t ips_input_middle; 227c80211e3SAndrey V. Elsukov uint64_t ips_input_end; 22888768458SSam Leffler }; 22988768458SSam Leffler 23088768458SSam Leffler /* 23188768458SSam Leffler * Definitions for IPsec & Key sysctl operations. 23288768458SSam Leffler */ 23388768458SSam Leffler #define IPSECCTL_STATS 1 /* stats */ 23488768458SSam Leffler #define IPSECCTL_DEF_POLICY 2 23588768458SSam Leffler #define IPSECCTL_DEF_ESP_TRANSLEV 3 /* int; ESP transport mode */ 23688768458SSam Leffler #define IPSECCTL_DEF_ESP_NETLEV 4 /* int; ESP tunnel mode */ 23788768458SSam Leffler #define IPSECCTL_DEF_AH_TRANSLEV 5 /* int; AH transport mode */ 23888768458SSam Leffler #define IPSECCTL_DEF_AH_NETLEV 6 /* int; AH tunnel mode */ 23988768458SSam Leffler #if 0 /* obsolete, do not reuse */ 24088768458SSam Leffler #define IPSECCTL_INBOUND_CALL_IKE 7 24188768458SSam Leffler #endif 24288768458SSam Leffler #define IPSECCTL_AH_CLEARTOS 8 24388768458SSam Leffler #define IPSECCTL_AH_OFFSETMASK 9 24488768458SSam Leffler #define IPSECCTL_DFBIT 10 24588768458SSam Leffler #define IPSECCTL_ECN 11 24688768458SSam Leffler #define IPSECCTL_DEBUG 12 24788768458SSam Leffler #define IPSECCTL_ESP_RANDPAD 13 248d9d59bb1SWojciech Macek #define IPSECCTL_MIN_PMTU 14 24988768458SSam Leffler 25088768458SSam Leffler #ifdef _KERNEL 251db8c0879SAndrey V. Elsukov #include <sys/counter.h> 252db8c0879SAndrey V. Elsukov 253ef91a976SAndrey V. Elsukov struct ipsec_ctx_data; 2541a01e0e7SAndrey V. Elsukov #define IPSEC_INIT_CTX(_ctx, _mp, _inp, _sav, _af, _enc) do { \ 255ef91a976SAndrey V. Elsukov (_ctx)->mp = (_mp); \ 2561a01e0e7SAndrey V. Elsukov (_ctx)->inp = (_inp); \ 257ef91a976SAndrey V. Elsukov (_ctx)->sav = (_sav); \ 258ef91a976SAndrey V. Elsukov (_ctx)->af = (_af); \ 259ef91a976SAndrey V. Elsukov (_ctx)->enc = (_enc); \ 260ef91a976SAndrey V. Elsukov } while(0) 261ef91a976SAndrey V. Elsukov int ipsec_run_hhooks(struct ipsec_ctx_data *ctx, int direction); 262ef91a976SAndrey V. Elsukov 263eddfbb76SRobert Watson VNET_DECLARE(int, ipsec_debug); 2641e77c105SRobert Watson #define V_ipsec_debug VNET(ipsec_debug) 265eddfbb76SRobert Watson 266eddfbb76SRobert Watson #ifdef REGRESSION 267eddfbb76SRobert Watson VNET_DECLARE(int, ipsec_replay); 268eddfbb76SRobert Watson VNET_DECLARE(int, ipsec_integrity); 26982cea7e6SBjoern A. Zeeb 27082cea7e6SBjoern A. Zeeb #define V_ipsec_replay VNET(ipsec_replay) 2711e77c105SRobert Watson #define V_ipsec_integrity VNET(ipsec_integrity) 272eddfbb76SRobert Watson #endif 27388768458SSam Leffler 274db8c0879SAndrey V. Elsukov VNET_PCPUSTAT_DECLARE(struct ipsecstat, ipsec4stat); 27582cea7e6SBjoern A. Zeeb VNET_DECLARE(int, ip4_esp_trans_deflev); 27682cea7e6SBjoern A. Zeeb VNET_DECLARE(int, ip4_esp_net_deflev); 27782cea7e6SBjoern A. Zeeb VNET_DECLARE(int, ip4_ah_trans_deflev); 27882cea7e6SBjoern A. Zeeb VNET_DECLARE(int, ip4_ah_net_deflev); 27982cea7e6SBjoern A. Zeeb VNET_DECLARE(int, ip4_ipsec_dfbit); 280d9d59bb1SWojciech Macek VNET_DECLARE(int, ip4_ipsec_min_pmtu); 28182cea7e6SBjoern A. Zeeb VNET_DECLARE(int, ip4_ipsec_ecn); 28282cea7e6SBjoern A. Zeeb VNET_DECLARE(int, crypto_support); 28339bbca6fSFabien Thomas VNET_DECLARE(int, async_crypto); 284fcf59617SAndrey V. Elsukov VNET_DECLARE(int, natt_cksum_policy); 28582cea7e6SBjoern A. Zeeb 286db8c0879SAndrey V. Elsukov #define IPSECSTAT_INC(name) \ 287db8c0879SAndrey V. Elsukov VNET_PCPUSTAT_ADD(struct ipsecstat, ipsec4stat, name, 1) 28882cea7e6SBjoern A. Zeeb #define V_ip4_esp_trans_deflev VNET(ip4_esp_trans_deflev) 28982cea7e6SBjoern A. Zeeb #define V_ip4_esp_net_deflev VNET(ip4_esp_net_deflev) 29082cea7e6SBjoern A. Zeeb #define V_ip4_ah_trans_deflev VNET(ip4_ah_trans_deflev) 29182cea7e6SBjoern A. Zeeb #define V_ip4_ah_net_deflev VNET(ip4_ah_net_deflev) 29282cea7e6SBjoern A. Zeeb #define V_ip4_ipsec_dfbit VNET(ip4_ipsec_dfbit) 293d9d59bb1SWojciech Macek #define V_ip4_ipsec_min_pmtu VNET(ip4_ipsec_min_pmtu) 29482cea7e6SBjoern A. Zeeb #define V_ip4_ipsec_ecn VNET(ip4_ipsec_ecn) 29582cea7e6SBjoern A. Zeeb #define V_crypto_support VNET(crypto_support) 29639bbca6fSFabien Thomas #define V_async_crypto VNET(async_crypto) 297fcf59617SAndrey V. Elsukov #define V_natt_cksum_policy VNET(natt_cksum_policy) 29882cea7e6SBjoern A. Zeeb 299603724d3SBjoern A. Zeeb #define ipseclog(x) do { if (V_ipsec_debug) log x; } while (0) 30088768458SSam Leffler /* for openbsd compatibility */ 3017f1f6591SAndrey V. Elsukov #ifdef IPSEC_DEBUG 3027f1f6591SAndrey V. Elsukov #define IPSEC_DEBUG_DECLARE(x) x 303603724d3SBjoern A. Zeeb #define DPRINTF(x) do { if (V_ipsec_debug) printf x; } while (0) 3047f1f6591SAndrey V. Elsukov #else 3057f1f6591SAndrey V. Elsukov #define IPSEC_DEBUG_DECLARE(x) 3067f1f6591SAndrey V. Elsukov #define DPRINTF(x) 3077f1f6591SAndrey V. Elsukov #endif 30888768458SSam Leffler 30988768458SSam Leffler struct inpcb; 310fcf59617SAndrey V. Elsukov struct m_tag; 311fcf59617SAndrey V. Elsukov struct secasvar; 312fcf59617SAndrey V. Elsukov struct sockopt; 313fcf59617SAndrey V. Elsukov struct tcphdr; 314fcf59617SAndrey V. Elsukov union sockaddr_union; 315fcf59617SAndrey V. Elsukov 316fcf59617SAndrey V. Elsukov int ipsec_if_input(struct mbuf *, struct secasvar *, uint32_t); 317fcf59617SAndrey V. Elsukov 318fcf59617SAndrey V. Elsukov struct ipsecrequest *ipsec_newisr(void); 319fcf59617SAndrey V. Elsukov void ipsec_delisr(struct ipsecrequest *); 320fcf59617SAndrey V. Elsukov struct secpolicy *ipsec4_checkpolicy(const struct mbuf *, struct inpcb *, 32122bbefb2SAndrey V. Elsukov int *, int); 32288768458SSam Leffler 323fcf59617SAndrey V. Elsukov u_int ipsec_get_reqlevel(struct secpolicy *, u_int); 32488768458SSam Leffler 325fcf59617SAndrey V. Elsukov void udp_ipsec_adjust_cksum(struct mbuf *, struct secasvar *, int, int); 326fcf59617SAndrey V. Elsukov int udp_ipsec_output(struct mbuf *, struct secasvar *); 32788768458SSam Leffler 3288b7f3994SMarcin Wojtas int ipsec_chkreplay(uint32_t, uint32_t *, struct secasvar *); 329fcf59617SAndrey V. Elsukov int ipsec_updatereplay(uint32_t, struct secasvar *); 3302e08e39fSConrad Meyer int ipsec_updateid(struct secasvar *, crypto_session_t *, crypto_session_t *); 331fcf59617SAndrey V. Elsukov int ipsec_initialized(void); 3326b66194bSKornel Duleba size_t ipsec_hdrsiz_internal(struct secpolicy *); 33388768458SSam Leffler 334fcf59617SAndrey V. Elsukov void ipsec_setspidx_inpcb(struct inpcb *, struct secpolicyindex *, u_int); 33588768458SSam Leffler 336fcf59617SAndrey V. Elsukov void ipsec4_setsockaddrs(const struct mbuf *, union sockaddr_union *, 337fcf59617SAndrey V. Elsukov union sockaddr_union *); 338fcf59617SAndrey V. Elsukov int ipsec4_common_input_cb(struct mbuf *, struct secasvar *, int, int); 339de1da299SKonstantin Belousov int ipsec4_check_pmtu(struct ifnet *, struct mbuf *, struct secpolicy *, int); 340de1da299SKonstantin Belousov int ipsec4_process_packet(struct ifnet *, struct mbuf *, struct secpolicy *, 341*00524fd4SKonstantin Belousov struct inpcb *, u_long); 342fcf59617SAndrey V. Elsukov int ipsec_process_done(struct mbuf *, struct secpolicy *, struct secasvar *, 343fcf59617SAndrey V. Elsukov u_int); 34488768458SSam Leffler 34588768458SSam Leffler extern void m_checkalignment(const char* where, struct mbuf *m0, 34688768458SSam Leffler int off, int len); 34788768458SSam Leffler extern struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off); 34888768458SSam Leffler extern caddr_t m_pad(struct mbuf *m, int n); 34988768458SSam Leffler extern int m_striphdr(struct mbuf *m, int skip, int hlen); 35019ad9831SBjoern A. Zeeb 35188768458SSam Leffler #endif /* _KERNEL */ 35288768458SSam Leffler 35388768458SSam Leffler #ifndef _KERNEL 35450ecbc51SLexi Winter extern caddr_t ipsec_set_policy(const char *, int); 35550ecbc51SLexi Winter extern int ipsec_get_policylen(c_caddr_t); 35650ecbc51SLexi Winter extern char *ipsec_dump_policy(c_caddr_t, const char *); 35718961126SAndrey V. Elsukov extern const char *ipsec_strerror(void); 3588b615593SMarko Zec 3598b615593SMarko Zec #endif /* ! KERNEL */ 36088768458SSam Leffler 36188768458SSam Leffler #endif /* _NETIPSEC_IPSEC_H_ */ 362