ipsec.h revision 188306
113044Sasami/* $FreeBSD: head/sys/netipsec/ipsec.h 188306 2009-02-08 09:27:07Z bz $ */ 213044Sasami/* $KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $ */ 313044Sasami 413044Sasami/*- 513044Sasami * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 613044Sasami * All rights reserved. 713044Sasami * 813044Sasami * Redistribution and use in source and binary forms, with or without 913044Sasami * modification, are permitted provided that the following conditions 1013044Sasami * are met: 1113044Sasami * 1. Redistributions of source code must retain the above copyright 1213044Sasami * notice, this list of conditions and the following disclaimer. 1313044Sasami * 2. Redistributions in binary form must reproduce the above copyright 1413044Sasami * notice, this list of conditions and the following disclaimer in the 1513044Sasami * documentation and/or other materials provided with the distribution. 1613044Sasami * 3. Neither the name of the project nor the names of its contributors 1713044Sasami * may be used to endorse or promote products derived from this software 1813044Sasami * without specific prior written permission. 1913044Sasami * 2013044Sasami * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2113044Sasami * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2213044Sasami * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2313044Sasami * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2413044Sasami * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2513044Sasami * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2613044Sasami * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2713044Sasami * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2813044Sasami * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2913044Sasami * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3013044Sasami * SUCH DAMAGE. 3113044Sasami */ 3213044Sasami 3313044Sasami/* 3413044Sasami * IPsec controller part. 3536628Scharnier */ 3636628Scharnier 3750476Speter#ifndef _NETIPSEC_IPSEC_H_ 3836628Scharnier#define _NETIPSEC_IPSEC_H_ 3936628Scharnier 4013044Sasami#if defined(_KERNEL) && !defined(_LKM) && !defined(KLD_MODULE) 4148568Sbillf#include "opt_inet.h" 4213044Sasami#include "opt_ipsec.h" 4313044Sasami#endif 4445329Speter 4513044Sasami#include <net/pfkeyv2.h> 4613044Sasami#include <netipsec/keydb.h> 4713044Sasami 4813044Sasami#ifdef _KERNEL 4913044Sasami 5069793Sobrien#define IPSEC_ASSERT(_c,_m) KASSERT(_c, _m) 5113044Sasami 5213044Sasami#define IPSEC_IS_PRIVILEGED_SO(_so) \ 5313044Sasami ((_so)->so_cred != NULL && \ 5413044Sasami priv_check_cred((_so)->so_cred, PRIV_NETINET_IPSEC, 0) \ 5513044Sasami == 0) 5639228Sgibbs 5713052Sasami/* 5813044Sasami * Security Policy Index 5913044Sasami * Ensure that both address families in the "src" and "dst" are same. 6013044Sasami * When the value of the ul_proto is ICMPv6, the port field in "src" 6113044Sasami * specifies ICMPv6 type, and the port field in "dst" specifies ICMPv6 code. 6213044Sasami */ 63109417Sphkstruct secpolicyindex { 6413044Sasami u_int8_t dir; /* direction of packet flow, see blow */ 6513044Sasami union sockaddr_union src; /* IP src address for SP */ 66109417Sphk union sockaddr_union dst; /* IP dst address for SP */ 6713044Sasami u_int8_t prefs; /* prefix length in bits for src */ 6813044Sasami u_int8_t prefd; /* prefix length in bits for dst */ 6913044Sasami u_int16_t ul_proto; /* upper layer Protocol */ 7013762Sasami#ifdef notyet 7113044Sasami uid_t uids; 7213044Sasami uid_t uidd; 7313044Sasami gid_t gids; 7413044Sasami gid_t gidd; 7513044Sasami#endif 7613044Sasami}; 7713044Sasami 7813044Sasami/* Security Policy Data Base */ 7913044Sasamistruct secpolicy { 8092539Simp LIST_ENTRY(secpolicy) chain; 81109417Sphk struct mtx lock; 8292539Simp 8392539Simp u_int refcnt; /* reference count */ 8492539Simp struct secpolicyindex spidx; /* selector */ 8592539Simp u_int32_t id; /* It's unique number on the system. */ 8692539Simp u_int state; /* 0: dead, others: alive */ 87109417Sphk#define IPSEC_SPSTATE_DEAD 0 8892539Simp#define IPSEC_SPSTATE_ALIVE 1 8913044Sasami u_int16_t policy; /* policy_type per pfkeyv2.h */ 9013044Sasami u_int16_t scangen; /* scan generation # */ 9192539Simp struct ipsecrequest *req; 9213044Sasami /* pointer to the ipsec request tree, */ 9313044Sasami /* if policy == IPSEC else this value == NULL.*/ 9413044Sasami 9583329Sru /* 9613044Sasami * lifetime handler. 9713044Sasami * the policy can be used without limitiation if both lifetime and 9813044Sasami * validtime are zero. 9913044Sasami * "lifetime" is passed by sadb_lifetime.sadb_lifetime_addtime. 10013044Sasami * "validtime" is passed by sadb_lifetime.sadb_lifetime_usetime. 10113044Sasami */ 10213044Sasami time_t created; /* time created the policy */ 10313044Sasami time_t lastused; /* updated every when kernel sends a packet */ 10413044Sasami long lifetime; /* duration of the lifetime of this policy */ 10513044Sasami long validtime; /* duration this policy is valid without use */ 10613044Sasami}; 10713044Sasami 10813044Sasami#define SECPOLICY_LOCK_INIT(_sp) \ 10913044Sasami mtx_init(&(_sp)->lock, "ipsec policy", NULL, MTX_DEF) 11013044Sasami#define SECPOLICY_LOCK(_sp) mtx_lock(&(_sp)->lock) 11113044Sasami#define SECPOLICY_UNLOCK(_sp) mtx_unlock(&(_sp)->lock) 11213044Sasami#define SECPOLICY_LOCK_DESTROY(_sp) mtx_destroy(&(_sp)->lock) 11313044Sasami#define SECPOLICY_LOCK_ASSERT(_sp) mtx_assert(&(_sp)->lock, MA_OWNED) 11413044Sasami 11513044Sasami/* Request for IPsec */ 11613044Sasamistruct ipsecrequest { 11713044Sasami struct ipsecrequest *next; 11813044Sasami /* pointer to next structure */ 11913044Sasami /* If NULL, it means the end of chain. */ 12013044Sasami struct secasindex saidx;/* hint for search proper SA */ 12113044Sasami /* if __ss_len == 0 then no address specified.*/ 12213044Sasami u_int level; /* IPsec level defined below. */ 12313044Sasami 12413044Sasami struct secasvar *sav; /* place holder of SA for use */ 12513044Sasami struct secpolicy *sp; /* back pointer to SP */ 12613044Sasami struct mtx lock; /* to interlock updates */ 12713044Sasami}; 12813044Sasami 12913044Sasami/* 13013044Sasami * Need recursion for when crypto callbacks happen directly, 13113044Sasami * as in the case of software crypto. Need to look at how 13213044Sasami * hard it is to remove this... 13313044Sasami */ 13413044Sasami#define IPSECREQUEST_LOCK_INIT(_isr) \ 13513044Sasami mtx_init(&(_isr)->lock, "ipsec request", NULL, MTX_DEF | MTX_RECURSE) 13613044Sasami#define IPSECREQUEST_LOCK(_isr) mtx_lock(&(_isr)->lock) 13713044Sasami#define IPSECREQUEST_UNLOCK(_isr) mtx_unlock(&(_isr)->lock) 13813044Sasami#define IPSECREQUEST_LOCK_DESTROY(_isr) mtx_destroy(&(_isr)->lock) 13945329Speter#define IPSECREQUEST_LOCK_ASSERT(_isr) mtx_assert(&(_isr)->lock, MA_OWNED) 14045329Speter 14145329Speter/* security policy in PCB */ 14245329Speterstruct inpcbpolicy { 14345329Speter struct secpolicy *sp_in; 14445329Speter struct secpolicy *sp_out; 14513044Sasami int priv; /* privileged socket ? */ 14613044Sasami}; 14713044Sasami 14813044Sasami/* SP acquiring list table. */ 14913044Sasamistruct secspacq { 15013044Sasami LIST_ENTRY(secspacq) chain; 15113044Sasami 15213044Sasami struct secpolicyindex spidx; 15313044Sasami 15413044Sasami time_t created; /* for lifetime */ 15513044Sasami int count; /* for lifetime */ 15613044Sasami /* XXX: here is mbuf place holder to be sent ? */ 15713044Sasami}; 15813044Sasami#endif /* _KERNEL */ 15913044Sasami 16013044Sasami/* according to IANA assignment, port 0x0000 and proto 0xff are reserved. */ 16136628Scharnier#define IPSEC_PORT_ANY 0 16213044Sasami#define IPSEC_ULPROTO_ANY 255 16313044Sasami#define IPSEC_PROTO_ANY 255 16413044Sasami 16592539Simp/* mode of security protocol */ 16613044Sasami/* NOTE: DON'T use IPSEC_MODE_ANY at SPD. It's only use in SAD */ 16713044Sasami#define IPSEC_MODE_ANY 0 /* i.e. wildcard. */ 168109417Sphk#define IPSEC_MODE_TRANSPORT 1 169109417Sphk#define IPSEC_MODE_TUNNEL 2 170109417Sphk#define IPSEC_MODE_TCPMD5 3 /* TCP MD5 mode */ 17113044Sasami 17213044Sasami/* 17313044Sasami * Direction of security policy. 17413044Sasami * NOTE: Since INVALID is used just as flag. 17513044Sasami * The other are used for loop counter too. 17613044Sasami */ 17713044Sasami#define IPSEC_DIR_ANY 0 17813044Sasami#define IPSEC_DIR_INBOUND 1 17913044Sasami#define IPSEC_DIR_OUTBOUND 2 180109472Sphk#define IPSEC_DIR_MAX 3 18113044Sasami#define IPSEC_DIR_INVALID 4 18213044Sasami 18313044Sasami/* Policy level */ 18413044Sasami/* 185109421Sphk * IPSEC, ENTRUST and BYPASS are allowed for setsockopt() in PCB, 18613044Sasami * DISCARD, IPSEC and NONE are allowed for setkey() in SPD. 18713044Sasami * DISCARD and NONE are allowed for system default. 18813044Sasami */ 18913044Sasami#define IPSEC_POLICY_DISCARD 0 /* discarding packet */ 19013044Sasami#define IPSEC_POLICY_NONE 1 /* through IPsec engine */ 19113044Sasami#define IPSEC_POLICY_IPSEC 2 /* do IPsec */ 19213044Sasami#define IPSEC_POLICY_ENTRUST 3 /* consulting SPD if present. */ 19313044Sasami#define IPSEC_POLICY_BYPASS 4 /* only for privileged socket. */ 19413044Sasami 19513044Sasami/* Security protocol level */ 19648568Sbillf#define IPSEC_LEVEL_DEFAULT 0 /* reference to system default */ 19713044Sasami#define IPSEC_LEVEL_USE 1 /* use SA if present. */ 19813044Sasami#define IPSEC_LEVEL_REQUIRE 2 /* require SA. */ 19913044Sasami#define IPSEC_LEVEL_UNIQUE 3 /* unique SA. */ 20013044Sasami 20113044Sasami#define IPSEC_MANUAL_REQID_MAX 0x3fff 20213044Sasami /* 20313044Sasami * if security policy level == unique, this id 20413044Sasami * indicate to a relative SA for use, else is 20513044Sasami * zero. 20613044Sasami * 1 - 0x3fff are reserved for manual keying. 20748568Sbillf * 0 are reserved for above reason. Others is 20813044Sasami * for kernel use. 20913044Sasami * Note that this id doesn't identify SA 21013044Sasami * by only itself. 211109472Sphk */ 21213044Sasami#define IPSEC_REPLAYWSIZE 32 21313044Sasami 21413044Sasami/* statistics for ipsec processing */ 21513044Sasamistruct ipsecstat { 21613044Sasami u_quad_t in_success; /* succeeded inbound process */ 21713044Sasami u_quad_t in_polvio; 21813044Sasami /* security policy violation for inbound process */ 21913044Sasami u_quad_t in_nosa; /* inbound SA is unavailable */ 22013044Sasami u_quad_t in_inval; /* inbound processing failed due to EINVAL */ 22113044Sasami u_quad_t in_nomem; /* inbound processing failed due to ENOBUFS */ 22213044Sasami u_quad_t in_badspi; /* failed getting a SPI */ 22313044Sasami u_quad_t in_ahreplay; /* AH replay check failed */ 22413044Sasami u_quad_t in_espreplay; /* ESP replay check failed */ 22513044Sasami u_quad_t in_ahauthsucc; /* AH authentication success */ 22613044Sasami u_quad_t in_ahauthfail; /* AH authentication failure */ 22713044Sasami u_quad_t in_espauthsucc; /* ESP authentication success */ 22813044Sasami u_quad_t in_espauthfail; /* ESP authentication failure */ 22913044Sasami u_quad_t in_esphist[256]; 23013044Sasami u_quad_t in_ahhist[256]; 23113044Sasami u_quad_t in_comphist[256]; 23213044Sasami u_quad_t out_success; /* succeeded outbound process */ 23313044Sasami u_quad_t out_polvio; 23413044Sasami /* security policy violation for outbound process */ 23513044Sasami u_quad_t out_nosa; /* outbound SA is unavailable */ 23613044Sasami u_quad_t out_inval; /* outbound process failed due to EINVAL */ 23713044Sasami u_quad_t out_nomem; /* inbound processing failed due to ENOBUFS */ 23813044Sasami u_quad_t out_noroute; /* there is no route */ 23913044Sasami u_quad_t out_esphist[256]; 24013044Sasami u_quad_t out_ahhist[256]; 24113044Sasami u_quad_t out_comphist[256]; 24213044Sasami 24313044Sasami u_quad_t spdcachelookup; 24413044Sasami u_quad_t spdcachemiss; 24513044Sasami 24613044Sasami u_int32_t ips_in_polvio; /* input: sec policy violation */ 24713044Sasami u_int32_t ips_out_polvio; /* output: sec policy violation */ 24813044Sasami u_int32_t ips_out_nosa; /* output: SA unavailable */ 24913044Sasami u_int32_t ips_out_nomem; /* output: no memory available */ 25013044Sasami u_int32_t ips_out_noroute; /* output: no route available */ 25113044Sasami u_int32_t ips_out_inval; /* output: generic error */ 25213044Sasami u_int32_t ips_out_bundlesa; /* output: bundled SA processed */ 25313044Sasami u_int32_t ips_mbcoalesced; /* mbufs coalesced during clone */ 25413044Sasami u_int32_t ips_clcoalesced; /* clusters coalesced during clone */ 255109421Sphk u_int32_t ips_clcopied; /* clusters copied during clone */ 25613044Sasami u_int32_t ips_mbinserted; /* mbufs inserted during makespace */ 25713044Sasami /* 25813044Sasami * Temporary statistics for performance analysis. 25913044Sasami */ 26013044Sasami /* See where ESP/AH/IPCOMP header land in mbuf on input */ 26113044Sasami u_int32_t ips_input_front; 26213044Sasami u_int32_t ips_input_middle; 26313044Sasami u_int32_t ips_input_end; 26413044Sasami}; 265109417Sphk 266109417Sphk/* 26713044Sasami * Definitions for IPsec & Key sysctl operations. 26813044Sasami */ 269109417Sphk/* 27013044Sasami * Names for IPsec & Key sysctl objects 271109417Sphk */ 272109417Sphk#define IPSECCTL_STATS 1 /* stats */ 27313044Sasami#define IPSECCTL_DEF_POLICY 2 27448568Sbillf#define IPSECCTL_DEF_ESP_TRANSLEV 3 /* int; ESP transport mode */ 27513044Sasami#define IPSECCTL_DEF_ESP_NETLEV 4 /* int; ESP tunnel mode */ 27613044Sasami#define IPSECCTL_DEF_AH_TRANSLEV 5 /* int; AH transport mode */ 27713044Sasami#define IPSECCTL_DEF_AH_NETLEV 6 /* int; AH tunnel mode */ 27813044Sasami#if 0 /* obsolete, do not reuse */ 27913044Sasami#define IPSECCTL_INBOUND_CALL_IKE 7 28013044Sasami#endif 28113044Sasami#define IPSECCTL_AH_CLEARTOS 8 28213044Sasami#define IPSECCTL_AH_OFFSETMASK 9 28313044Sasami#define IPSECCTL_DFBIT 10 28413044Sasami#define IPSECCTL_ECN 11 28513044Sasami#define IPSECCTL_DEBUG 12 28692539Simp#define IPSECCTL_ESP_RANDPAD 13 28713044Sasami#define IPSECCTL_MAXID 14 28813044Sasami 28913044Sasami#define IPSECCTL_NAMES { \ 29013044Sasami { 0, 0 }, \ 29113044Sasami { 0, 0 }, \ 29232116Simp { "def_policy", CTLTYPE_INT }, \ 29313044Sasami { "esp_trans_deflev", CTLTYPE_INT }, \ 29451690Sbillf { "esp_net_deflev", CTLTYPE_INT }, \ 29532116Simp { "ah_trans_deflev", CTLTYPE_INT }, \ 29632116Simp { "ah_net_deflev", CTLTYPE_INT }, \ 29713044Sasami { 0, 0 }, \ 29832116Simp { "ah_cleartos", CTLTYPE_INT }, \ 29913044Sasami { "ah_offsetmask", CTLTYPE_INT }, \ 30013044Sasami { "dfbit", CTLTYPE_INT }, \ 30113044Sasami { "ecn", CTLTYPE_INT }, \ 30232116Simp { "debug", CTLTYPE_INT }, \ 30313044Sasami { "esp_randpad", CTLTYPE_INT }, \ 30413044Sasami} 30513044Sasami 30613044Sasami#define IPSEC6CTL_NAMES { \ 30713044Sasami { 0, 0 }, \ 30813044Sasami { 0, 0 }, \ 30913044Sasami { "def_policy", CTLTYPE_INT }, \ 31013044Sasami { "esp_trans_deflev", CTLTYPE_INT }, \ 31113044Sasami { "esp_net_deflev", CTLTYPE_INT }, \ 31213044Sasami { "ah_trans_deflev", CTLTYPE_INT }, \ 31313044Sasami { "ah_net_deflev", CTLTYPE_INT }, \ 31413044Sasami { 0, 0 }, \ 31513044Sasami { 0, 0 }, \ 31613044Sasami { 0, 0 }, \ 31713044Sasami { 0, 0 }, \ 31813044Sasami { "ecn", CTLTYPE_INT }, \ 31913044Sasami { "debug", CTLTYPE_INT }, \ 32013044Sasami { "esp_randpad", CTLTYPE_INT }, \ 32113044Sasami} 32213044Sasami 32313044Sasami#ifdef _KERNEL 32413044Sasamistruct ipsec_output_state { 32513044Sasami struct mbuf *m; 32613044Sasami struct route *ro; 32713044Sasami struct sockaddr *dst; 32813044Sasami}; 32913044Sasami 33013044Sasamistruct ipsec_history { 33113044Sasami int ih_proto; 33213044Sasami u_int32_t ih_spi; 33313044Sasami}; 33413044Sasami 33513044Sasamiextern int ipsec_debug; 33613044Sasami#ifdef REGRESSION 33713044Sasamiextern int ipsec_replay; 33813044Sasamiextern int ipsec_integrity; 33913044Sasami#endif 34013044Sasami 34113044Sasamiextern struct ipsecstat ipsec4stat; 34213044Sasamiextern struct secpolicy ip4_def_policy; 34313044Sasamiextern int ip4_esp_trans_deflev; 34413044Sasamiextern int ip4_esp_net_deflev; 34513044Sasamiextern int ip4_ah_trans_deflev; 34613044Sasamiextern int ip4_ah_net_deflev; 34713044Sasamiextern int ip4_ah_cleartos; 34813044Sasamiextern int ip4_ah_offsetmask; 34913044Sasamiextern int ip4_ipsec_dfbit; 35092539Simpextern int ip4_ipsec_ecn; 35113044Sasamiextern int ip4_esp_randpad; 35213044Sasamiextern int crypto_support; 35313044Sasami 35413044Sasami#define ipseclog(x) do { if (V_ipsec_debug) log x; } while (0) 35513044Sasami/* for openbsd compatibility */ 35613044Sasami#define DPRINTF(x) do { if (V_ipsec_debug) printf x; } while (0) 35713044Sasami 35813044Sasamiextern struct ipsecrequest *ipsec_newisr(void); 35913044Sasamiextern void ipsec_delisr(struct ipsecrequest *); 36013044Sasami 36113044Sasamistruct tdb_ident; 36213044Sasamiextern void ipsec_init(void); 36313044Sasamiextern struct secpolicy *ipsec_getpolicy __P((struct tdb_ident*, u_int)); 36492539Simpstruct inpcb; 36513044Sasamiextern struct secpolicy *ipsec4_checkpolicy __P((struct mbuf *, u_int, u_int, 36613044Sasami int *, struct inpcb *)); 367109417Sphkextern struct secpolicy * ipsec_getpolicybyaddr(struct mbuf *, u_int, 368109417Sphk int, int *); 369109417Sphk 370109417Sphkstruct inpcb; 371109417Sphkextern int ipsec_init_policy __P((struct socket *so, struct inpcbpolicy **)); 372109417Sphkextern int ipsec_copy_policy 373109417Sphk __P((struct inpcbpolicy *, struct inpcbpolicy *)); 374109417Sphkextern u_int ipsec_get_reqlevel __P((struct ipsecrequest *)); 37513044Sasamiextern int ipsec_in_reject __P((struct secpolicy *, struct mbuf *)); 37613044Sasami 37713044Sasamiextern int ipsec_set_policy __P((struct inpcb *inp, int optname, 378109417Sphk caddr_t request, size_t len, struct ucred *cred)); 37913044Sasamiextern int ipsec_get_policy __P((struct inpcb *inpcb, caddr_t request, 38013044Sasami size_t len, struct mbuf **mp)); 38113044Sasamiextern int ipsec_delete_pcbpolicy __P((struct inpcb *)); 382109417Sphkextern int ipsec4_in_reject __P((struct mbuf *, struct inpcb *)); 38313044Sasami 384109421Sphkstruct secas; 385109417Sphkstruct tcpcb; 38613044Sasamiextern int ipsec_chkreplay __P((u_int32_t, struct secasvar *)); 387109421Sphkextern int ipsec_updatereplay __P((u_int32_t, struct secasvar *)); 388109421Sphk 389109421Sphkextern size_t ipsec_hdrsiz __P((struct mbuf *, u_int, struct inpcb *)); 390109421Sphkextern size_t ipsec_hdrsiz_tcp __P((struct tcpcb *)); 391109421Sphk 392109421Sphkunion sockaddr_union; 393109421Sphkextern char * ipsec_address(union sockaddr_union* sa); 394109421Sphkextern const char *ipsec_logsastr __P((struct secasvar *)); 395109421Sphk 396109421Sphkextern void ipsec_dumpmbuf __P((struct mbuf *)); 39713044Sasami 39813044Sasamistruct m_tag; 39913044Sasamiextern void ah4_input(struct mbuf *m, int off); 40013044Sasamiextern void ah4_ctlinput(int cmd, struct sockaddr *sa, void *); 40113044Sasamiextern void esp4_input(struct mbuf *m, int off); 40213044Sasamiextern void esp4_ctlinput(int cmd, struct sockaddr *sa, void *); 40313044Sasamiextern void ipcomp4_input(struct mbuf *m, int off); 40413044Sasamiextern int ipsec4_common_input(struct mbuf *m, ...); 40513044Sasamiextern int ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, 40613044Sasami int skip, int protoff, struct m_tag *mt); 40713044Sasamiextern int ipsec4_process_packet __P((struct mbuf *, struct ipsecrequest *, 40813044Sasami int, int)); 40982943Sphkextern int ipsec_process_done __P((struct mbuf *, struct ipsecrequest *)); 41082943Sphk 41182943Sphkextern struct mbuf *ipsec_copypkt __P((struct mbuf *)); 41282943Sphk 41382943Sphkextern void m_checkalignment(const char* where, struct mbuf *m0, 41482943Sphk int off, int len); 41582943Sphkextern struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off); 41682943Sphkextern caddr_t m_pad(struct mbuf *m, int n); 41713044Sasamiextern int m_striphdr(struct mbuf *m, int skip, int hlen); 41813044Sasami 41913044Sasami#ifdef DEV_ENC 42013044Sasami#define ENC_BEFORE 0x0001 42113044Sasami#define ENC_AFTER 0x0002 42213044Sasami#define ENC_IN 0x0100 42313044Sasami#define ENC_OUT 0x0200 42413044Sasamiextern int ipsec_filter(struct mbuf **, int, int); 42513044Sasamiextern void ipsec_bpf(struct mbuf *, struct secasvar *, int, int); 42613044Sasami#endif 42713044Sasami#endif /* _KERNEL */ 42892539Simp 42913044Sasami#ifndef _KERNEL 430109417Sphkextern caddr_t ipsec_set_policy __P((char *, int)); 43113044Sasamiextern int ipsec_get_policylen __P((caddr_t)); 43282943Sphkextern char *ipsec_dump_policy __P((caddr_t, char *)); 433109417Sphk 43413044Sasamiextern const char *ipsec_strerror __P((void)); 43582943Sphk 43682943Sphk#else 43782943Sphk#include <netipsec/vipsec.h> 43882943Sphk#endif /* ! KERNEL */ 439109417Sphk 44082943Sphk#endif /* _NETIPSEC_IPSEC_H_ */ 44113044Sasami