ipsec.h revision 125098
1105197Ssam/*	$FreeBSD: head/sys/netipsec/ipsec.h 125098 2004-01-27 17:42:57Z sam $	*/
2105197Ssam/*	$KAME: ipsec.h,v 1.53 2001/11/20 08:32:38 itojun Exp $	*/
3105197Ssam
4105197Ssam/*
5105197Ssam * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6105197Ssam * All rights reserved.
7105197Ssam *
8105197Ssam * Redistribution and use in source and binary forms, with or without
9105197Ssam * modification, are permitted provided that the following conditions
10105197Ssam * are met:
11105197Ssam * 1. Redistributions of source code must retain the above copyright
12105197Ssam *    notice, this list of conditions and the following disclaimer.
13105197Ssam * 2. Redistributions in binary form must reproduce the above copyright
14105197Ssam *    notice, this list of conditions and the following disclaimer in the
15105197Ssam *    documentation and/or other materials provided with the distribution.
16105197Ssam * 3. Neither the name of the project nor the names of its contributors
17105197Ssam *    may be used to endorse or promote products derived from this software
18105197Ssam *    without specific prior written permission.
19105197Ssam *
20105197Ssam * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21105197Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22105197Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23105197Ssam * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24105197Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25105197Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26105197Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27105197Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28105197Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29105197Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30105197Ssam * SUCH DAMAGE.
31105197Ssam */
32105197Ssam
33105197Ssam/*
34105197Ssam * IPsec controller part.
35105197Ssam */
36105197Ssam
37105197Ssam#ifndef _NETIPSEC_IPSEC_H_
38105197Ssam#define _NETIPSEC_IPSEC_H_
39105197Ssam
40105197Ssam#if defined(_KERNEL) && !defined(_LKM) && !defined(KLD_MODULE)
41105197Ssam#include "opt_inet.h"
42105197Ssam#include "opt_ipsec.h"
43105197Ssam#endif
44105197Ssam
45105197Ssam#include <net/pfkeyv2.h>
46105197Ssam#include <netipsec/keydb.h>
47120585Ssam#include <netipsec/ipsec_osdep.h>
48105197Ssam
49105197Ssam#ifdef _KERNEL
50105197Ssam
51105197Ssam/*
52105197Ssam * Security Policy Index
53105197Ssam * Ensure that both address families in the "src" and "dst" are same.
54105197Ssam * When the value of the ul_proto is ICMPv6, the port field in "src"
55105197Ssam * specifies ICMPv6 type, and the port field in "dst" specifies ICMPv6 code.
56105197Ssam */
57105197Ssamstruct secpolicyindex {
58105197Ssam	u_int8_t dir;			/* direction of packet flow, see blow */
59105197Ssam	union sockaddr_union src;	/* IP src address for SP */
60105197Ssam	union sockaddr_union dst;	/* IP dst address for SP */
61105197Ssam	u_int8_t prefs;			/* prefix length in bits for src */
62105197Ssam	u_int8_t prefd;			/* prefix length in bits for dst */
63105197Ssam	u_int16_t ul_proto;		/* upper layer Protocol */
64105197Ssam#ifdef notyet
65105197Ssam	uid_t uids;
66105197Ssam	uid_t uidd;
67105197Ssam	gid_t gids;
68105197Ssam	gid_t gidd;
69105197Ssam#endif
70105197Ssam};
71105197Ssam
72105197Ssam/* Security Policy Data Base */
73105197Ssamstruct secpolicy {
74105197Ssam	LIST_ENTRY(secpolicy) chain;
75119643Ssam	struct mtx lock;
76105197Ssam
77105197Ssam	u_int refcnt;			/* reference count */
78105197Ssam	struct secpolicyindex spidx;	/* selector */
79105197Ssam	u_int32_t id;			/* It's unique number on the system. */
80105197Ssam	u_int state;			/* 0: dead, others: alive */
81105197Ssam#define IPSEC_SPSTATE_DEAD	0
82105197Ssam#define IPSEC_SPSTATE_ALIVE	1
83120585Ssam	u_int16_t policy;		/* policy_type per pfkeyv2.h */
84120585Ssam	u_int16_t scangen;		/* scan generation # */
85105197Ssam	struct ipsecrequest *req;
86105197Ssam				/* pointer to the ipsec request tree, */
87105197Ssam				/* if policy == IPSEC else this value == NULL.*/
88105197Ssam
89105197Ssam	/*
90105197Ssam	 * lifetime handler.
91105197Ssam	 * the policy can be used without limitiation if both lifetime and
92105197Ssam	 * validtime are zero.
93105197Ssam	 * "lifetime" is passed by sadb_lifetime.sadb_lifetime_addtime.
94105197Ssam	 * "validtime" is passed by sadb_lifetime.sadb_lifetime_usetime.
95105197Ssam	 */
96120585Ssam	time_t created;		/* time created the policy */
97120585Ssam	time_t lastused;	/* updated every when kernel sends a packet */
98105197Ssam	long lifetime;		/* duration of the lifetime of this policy */
99105197Ssam	long validtime;		/* duration this policy is valid without use */
100105197Ssam};
101105197Ssam
102120585Ssam#define	SECPOLICY_LOCK_INIT(_sp) \
103120585Ssam	mtx_init(&(_sp)->lock, "ipsec policy", NULL, MTX_DEF)
104120585Ssam#define	SECPOLICY_LOCK(_sp)		mtx_lock(&(_sp)->lock)
105120585Ssam#define	SECPOLICY_UNLOCK(_sp)		mtx_unlock(&(_sp)->lock)
106120585Ssam#define	SECPOLICY_LOCK_DESTROY(_sp)	mtx_destroy(&(_sp)->lock)
107120585Ssam#define	SECPOLICY_LOCK_ASSERT(_sp)	mtx_assert(&(_sp)->lock, MA_OWNED)
108120585Ssam
109105197Ssam/* Request for IPsec */
110105197Ssamstruct ipsecrequest {
111105197Ssam	struct ipsecrequest *next;
112105197Ssam				/* pointer to next structure */
113105197Ssam				/* If NULL, it means the end of chain. */
114105197Ssam	struct secasindex saidx;/* hint for search proper SA */
115105197Ssam				/* if __ss_len == 0 then no address specified.*/
116105197Ssam	u_int level;		/* IPsec level defined below. */
117105197Ssam
118105197Ssam	struct secasvar *sav;	/* place holder of SA for use */
119105197Ssam	struct secpolicy *sp;	/* back pointer to SP */
120119643Ssam	struct mtx lock;	/* to interlock updates */
121105197Ssam};
122105197Ssam
123120585Ssam/*
124120585Ssam * Need recursion for when crypto callbacks happen directly,
125120585Ssam * as in the case of software crypto.  Need to look at how
126120585Ssam * hard it is to remove this...
127120585Ssam */
128120585Ssam#define	IPSECREQUEST_LOCK_INIT(_isr) \
129120585Ssam	mtx_init(&(_isr)->lock, "ipsec request", NULL, MTX_DEF | MTX_RECURSE)
130120585Ssam#define	IPSECREQUEST_LOCK(_isr)		mtx_lock(&(_isr)->lock)
131120585Ssam#define	IPSECREQUEST_UNLOCK(_isr)	mtx_unlock(&(_isr)->lock)
132120585Ssam#define	IPSECREQUEST_LOCK_DESTROY(_isr)	mtx_destroy(&(_isr)->lock)
133120585Ssam#define	IPSECREQUEST_LOCK_ASSERT(_isr)	mtx_assert(&(_isr)->lock, MA_OWNED)
134120585Ssam
135105197Ssam/* security policy in PCB */
136105197Ssamstruct inpcbpolicy {
137105197Ssam	struct secpolicy *sp_in;
138105197Ssam	struct secpolicy *sp_out;
139105197Ssam	int priv;			/* privileged socket ? */
140105197Ssam};
141105197Ssam
142105197Ssam/* SP acquiring list table. */
143105197Ssamstruct secspacq {
144105197Ssam	LIST_ENTRY(secspacq) chain;
145105197Ssam
146105197Ssam	struct secpolicyindex spidx;
147105197Ssam
148120585Ssam	time_t created;		/* for lifetime */
149105197Ssam	int count;		/* for lifetime */
150105197Ssam	/* XXX: here is mbuf place holder to be sent ? */
151105197Ssam};
152105197Ssam#endif /* _KERNEL */
153105197Ssam
154105197Ssam/* according to IANA assignment, port 0x0000 and proto 0xff are reserved. */
155105197Ssam#define IPSEC_PORT_ANY		0
156105197Ssam#define IPSEC_ULPROTO_ANY	255
157105197Ssam#define IPSEC_PROTO_ANY		255
158105197Ssam
159105197Ssam/* mode of security protocol */
160105197Ssam/* NOTE: DON'T use IPSEC_MODE_ANY at SPD.  It's only use in SAD */
161105197Ssam#define	IPSEC_MODE_ANY		0	/* i.e. wildcard. */
162105197Ssam#define	IPSEC_MODE_TRANSPORT	1
163105197Ssam#define	IPSEC_MODE_TUNNEL	2
164105197Ssam
165105197Ssam/*
166105197Ssam * Direction of security policy.
167105197Ssam * NOTE: Since INVALID is used just as flag.
168105197Ssam * The other are used for loop counter too.
169105197Ssam */
170105197Ssam#define IPSEC_DIR_ANY		0
171105197Ssam#define IPSEC_DIR_INBOUND	1
172105197Ssam#define IPSEC_DIR_OUTBOUND	2
173105197Ssam#define IPSEC_DIR_MAX		3
174105197Ssam#define IPSEC_DIR_INVALID	4
175105197Ssam
176105197Ssam/* Policy level */
177105197Ssam/*
178105197Ssam * IPSEC, ENTRUST and BYPASS are allowed for setsockopt() in PCB,
179105197Ssam * DISCARD, IPSEC and NONE are allowed for setkey() in SPD.
180105197Ssam * DISCARD and NONE are allowed for system default.
181105197Ssam */
182105197Ssam#define IPSEC_POLICY_DISCARD	0	/* discarding packet */
183105197Ssam#define IPSEC_POLICY_NONE	1	/* through IPsec engine */
184105197Ssam#define IPSEC_POLICY_IPSEC	2	/* do IPsec */
185105197Ssam#define IPSEC_POLICY_ENTRUST	3	/* consulting SPD if present. */
186105197Ssam#define IPSEC_POLICY_BYPASS	4	/* only for privileged socket. */
187105197Ssam
188105197Ssam/* Security protocol level */
189105197Ssam#define	IPSEC_LEVEL_DEFAULT	0	/* reference to system default */
190105197Ssam#define	IPSEC_LEVEL_USE		1	/* use SA if present. */
191105197Ssam#define	IPSEC_LEVEL_REQUIRE	2	/* require SA. */
192105197Ssam#define	IPSEC_LEVEL_UNIQUE	3	/* unique SA. */
193105197Ssam
194105197Ssam#define IPSEC_MANUAL_REQID_MAX	0x3fff
195105197Ssam				/*
196105197Ssam				 * if security policy level == unique, this id
197105197Ssam				 * indicate to a relative SA for use, else is
198105197Ssam				 * zero.
199105197Ssam				 * 1 - 0x3fff are reserved for manual keying.
200105197Ssam				 * 0 are reserved for above reason.  Others is
201105197Ssam				 * for kernel use.
202105197Ssam				 * Note that this id doesn't identify SA
203105197Ssam				 * by only itself.
204105197Ssam				 */
205105197Ssam#define IPSEC_REPLAYWSIZE  32
206105197Ssam
207105197Ssam/* old statistics for ipsec processing */
208105197Ssamstruct ipsecstat {
209105197Ssam	u_quad_t in_success;  /* succeeded inbound process */
210105197Ssam	u_quad_t in_polvio;
211105197Ssam			/* security policy violation for inbound process */
212105197Ssam	u_quad_t in_nosa;     /* inbound SA is unavailable */
213105197Ssam	u_quad_t in_inval;    /* inbound processing failed due to EINVAL */
214105197Ssam	u_quad_t in_nomem;    /* inbound processing failed due to ENOBUFS */
215105197Ssam	u_quad_t in_badspi;   /* failed getting a SPI */
216105197Ssam	u_quad_t in_ahreplay; /* AH replay check failed */
217105197Ssam	u_quad_t in_espreplay; /* ESP replay check failed */
218105197Ssam	u_quad_t in_ahauthsucc; /* AH authentication success */
219105197Ssam	u_quad_t in_ahauthfail; /* AH authentication failure */
220105197Ssam	u_quad_t in_espauthsucc; /* ESP authentication success */
221105197Ssam	u_quad_t in_espauthfail; /* ESP authentication failure */
222105197Ssam	u_quad_t in_esphist[256];
223105197Ssam	u_quad_t in_ahhist[256];
224105197Ssam	u_quad_t in_comphist[256];
225105197Ssam	u_quad_t out_success; /* succeeded outbound process */
226105197Ssam	u_quad_t out_polvio;
227105197Ssam			/* security policy violation for outbound process */
228105197Ssam	u_quad_t out_nosa;    /* outbound SA is unavailable */
229105197Ssam	u_quad_t out_inval;   /* outbound process failed due to EINVAL */
230105197Ssam	u_quad_t out_nomem;    /* inbound processing failed due to ENOBUFS */
231105197Ssam	u_quad_t out_noroute; /* there is no route */
232105197Ssam	u_quad_t out_esphist[256];
233105197Ssam	u_quad_t out_ahhist[256];
234105197Ssam	u_quad_t out_comphist[256];
235125098Ssam
236125098Ssam	u_quad_t spdcachelookup;
237125098Ssam	u_quad_t spdcachemiss;
238105197Ssam};
239105197Ssam
240105197Ssam/* statistics for ipsec processing */
241105197Ssamstruct newipsecstat {
242105197Ssam	u_int32_t ips_in_polvio;	/* input: sec policy violation */
243105197Ssam	u_int32_t ips_out_polvio;	/* output: sec policy violation */
244105197Ssam	u_int32_t ips_out_nosa;		/* output: SA unavailable  */
245105197Ssam	u_int32_t ips_out_nomem;	/* output: no memory available */
246105197Ssam	u_int32_t ips_out_noroute;	/* output: no route available */
247105197Ssam	u_int32_t ips_out_inval;	/* output: generic error */
248105197Ssam	u_int32_t ips_out_bundlesa;	/* output: bundled SA processed */
249105197Ssam	u_int32_t ips_mbcoalesced;	/* mbufs coalesced during clone */
250105197Ssam	u_int32_t ips_clcoalesced;	/* clusters coalesced during clone */
251105197Ssam	u_int32_t ips_clcopied;		/* clusters copied during clone */
252105197Ssam	u_int32_t ips_mbinserted;	/* mbufs inserted during makespace */
253105197Ssam	/*
254105197Ssam	 * Temporary statistics for performance analysis.
255105197Ssam	 */
256105197Ssam	/* See where ESP/AH/IPCOMP header land in mbuf on input */
257105197Ssam	u_int32_t ips_input_front;
258105197Ssam	u_int32_t ips_input_middle;
259105197Ssam	u_int32_t ips_input_end;
260105197Ssam};
261105197Ssam
262105197Ssam/*
263105197Ssam * Definitions for IPsec & Key sysctl operations.
264105197Ssam */
265105197Ssam/*
266105197Ssam * Names for IPsec & Key sysctl objects
267105197Ssam */
268105197Ssam#define IPSECCTL_STATS			1	/* stats */
269105197Ssam#define IPSECCTL_DEF_POLICY		2
270105197Ssam#define IPSECCTL_DEF_ESP_TRANSLEV	3	/* int; ESP transport mode */
271105197Ssam#define IPSECCTL_DEF_ESP_NETLEV		4	/* int; ESP tunnel mode */
272105197Ssam#define IPSECCTL_DEF_AH_TRANSLEV	5	/* int; AH transport mode */
273105197Ssam#define IPSECCTL_DEF_AH_NETLEV		6	/* int; AH tunnel mode */
274105197Ssam#if 0	/* obsolete, do not reuse */
275105197Ssam#define IPSECCTL_INBOUND_CALL_IKE	7
276105197Ssam#endif
277105197Ssam#define	IPSECCTL_AH_CLEARTOS		8
278105197Ssam#define	IPSECCTL_AH_OFFSETMASK		9
279105197Ssam#define	IPSECCTL_DFBIT			10
280105197Ssam#define	IPSECCTL_ECN			11
281105197Ssam#define	IPSECCTL_DEBUG			12
282105197Ssam#define	IPSECCTL_ESP_RANDPAD		13
283105197Ssam#define IPSECCTL_MAXID			14
284105197Ssam
285105197Ssam#define IPSECCTL_NAMES { \
286105197Ssam	{ 0, 0 }, \
287105197Ssam	{ 0, 0 }, \
288105197Ssam	{ "def_policy", CTLTYPE_INT }, \
289105197Ssam	{ "esp_trans_deflev", CTLTYPE_INT }, \
290105197Ssam	{ "esp_net_deflev", CTLTYPE_INT }, \
291105197Ssam	{ "ah_trans_deflev", CTLTYPE_INT }, \
292105197Ssam	{ "ah_net_deflev", CTLTYPE_INT }, \
293105197Ssam	{ 0, 0 }, \
294105197Ssam	{ "ah_cleartos", CTLTYPE_INT }, \
295105197Ssam	{ "ah_offsetmask", CTLTYPE_INT }, \
296105197Ssam	{ "dfbit", CTLTYPE_INT }, \
297105197Ssam	{ "ecn", CTLTYPE_INT }, \
298105197Ssam	{ "debug", CTLTYPE_INT }, \
299105197Ssam	{ "esp_randpad", CTLTYPE_INT }, \
300105197Ssam}
301105197Ssam
302105197Ssam#define IPSEC6CTL_NAMES { \
303105197Ssam	{ 0, 0 }, \
304105197Ssam	{ 0, 0 }, \
305105197Ssam	{ "def_policy", CTLTYPE_INT }, \
306105197Ssam	{ "esp_trans_deflev", CTLTYPE_INT }, \
307105197Ssam	{ "esp_net_deflev", CTLTYPE_INT }, \
308105197Ssam	{ "ah_trans_deflev", CTLTYPE_INT }, \
309105197Ssam	{ "ah_net_deflev", CTLTYPE_INT }, \
310105197Ssam	{ 0, 0 }, \
311105197Ssam	{ 0, 0 }, \
312105197Ssam	{ 0, 0 }, \
313105197Ssam	{ 0, 0 }, \
314105197Ssam	{ "ecn", CTLTYPE_INT }, \
315105197Ssam	{ "debug", CTLTYPE_INT }, \
316105197Ssam	{ "esp_randpad", CTLTYPE_INT }, \
317105197Ssam}
318105197Ssam
319105197Ssam#ifdef _KERNEL
320105197Ssamstruct ipsec_output_state {
321105197Ssam	struct mbuf *m;
322105197Ssam	struct route *ro;
323105197Ssam	struct sockaddr *dst;
324105197Ssam};
325105197Ssam
326105197Ssamstruct ipsec_history {
327105197Ssam	int ih_proto;
328105197Ssam	u_int32_t ih_spi;
329105197Ssam};
330105197Ssam
331105197Ssamextern int ipsec_debug;
332105197Ssam
333105197Ssamextern struct newipsecstat newipsecstat;
334105197Ssamextern struct secpolicy ip4_def_policy;
335105197Ssamextern int ip4_esp_trans_deflev;
336105197Ssamextern int ip4_esp_net_deflev;
337105197Ssamextern int ip4_ah_trans_deflev;
338105197Ssamextern int ip4_ah_net_deflev;
339105197Ssamextern int ip4_ah_cleartos;
340105197Ssamextern int ip4_ah_offsetmask;
341105197Ssamextern int ip4_ipsec_dfbit;
342105197Ssamextern int ip4_ipsec_ecn;
343105197Ssamextern int ip4_esp_randpad;
344105197Ssamextern int crypto_support;
345105197Ssam
346105197Ssam#define ipseclog(x)	do { if (ipsec_debug) log x; } while (0)
347105197Ssam/* for openbsd compatibility */
348105197Ssam#define	DPRINTF(x)	do { if (ipsec_debug) printf x; } while (0)
349105197Ssam
350124764Ssam/* XXX for KAME code compatibility */
351124764Ssam#define ipsec_pcbconn(_x)
352124764Ssam#define	ipsec_pcbdisconn(_x)
353124764Ssam
354119643Ssamextern	struct ipsecrequest *ipsec_newisr(void);
355119643Ssamextern	void ipsec_delisr(struct ipsecrequest *);
356119643Ssam
357105197Ssamstruct tdb_ident;
358105197Ssamextern struct secpolicy *ipsec_getpolicy __P((struct tdb_ident*, u_int));
359105197Ssamstruct inpcb;
360105197Ssamextern struct secpolicy *ipsec4_checkpolicy __P((struct mbuf *, u_int, u_int,
361105197Ssam	int *, struct inpcb *));
362105197Ssamextern struct secpolicy *ipsec_getpolicybysock(struct mbuf *, u_int,
363105197Ssam	struct inpcb *, int *);
364105197Ssamextern struct secpolicy * ipsec_getpolicybyaddr(struct mbuf *, u_int,
365105197Ssam	int, int *);
366105197Ssam
367105197Ssamstruct inpcb;
368105197Ssamextern int ipsec_init_policy __P((struct socket *so, struct inpcbpolicy **));
369105197Ssamextern int ipsec_copy_policy
370105197Ssam	__P((struct inpcbpolicy *, struct inpcbpolicy *));
371105197Ssamextern u_int ipsec_get_reqlevel __P((struct ipsecrequest *));
372105197Ssamextern int ipsec_in_reject __P((struct secpolicy *, struct mbuf *));
373105197Ssam
374105197Ssamextern int ipsec4_set_policy __P((struct inpcb *inp, int optname,
375105197Ssam	caddr_t request, size_t len, int priv));
376105197Ssamextern int ipsec4_get_policy __P((struct inpcb *inpcb, caddr_t request,
377105197Ssam	size_t len, struct mbuf **mp));
378105197Ssamextern int ipsec4_delete_pcbpolicy __P((struct inpcb *));
379105197Ssamextern int ipsec4_in_reject __P((struct mbuf *, struct inpcb *));
380105197Ssam
381105197Ssamstruct secas;
382105197Ssamstruct tcpcb;
383105197Ssamextern int ipsec_chkreplay __P((u_int32_t, struct secasvar *));
384105197Ssamextern int ipsec_updatereplay __P((u_int32_t, struct secasvar *));
385105197Ssam
386105197Ssamextern size_t ipsec4_hdrsiz __P((struct mbuf *, u_int, struct inpcb *));
387105197Ssamextern size_t ipsec_hdrsiz_tcp __P((struct tcpcb *));
388105197Ssam
389105197Ssamunion sockaddr_union;
390105197Ssamextern char * ipsec_address(union sockaddr_union* sa);
391105197Ssamextern const char *ipsec_logsastr __P((struct secasvar *));
392105197Ssam
393105197Ssamextern void ipsec_dumpmbuf __P((struct mbuf *));
394105197Ssam
395105197Ssamstruct m_tag;
396106680Ssamextern void ah4_input(struct mbuf *m, int off);
397120585Ssamextern void ah4_ctlinput(int cmd, struct sockaddr *sa, void *);
398106680Ssamextern void esp4_input(struct mbuf *m, int off);
399120585Ssamextern void esp4_ctlinput(int cmd, struct sockaddr *sa, void *);
400106680Ssamextern void ipcomp4_input(struct mbuf *m, int off);
401105197Ssamextern int ipsec4_common_input(struct mbuf *m, ...);
402105197Ssamextern int ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav,
403105197Ssam			int skip, int protoff, struct m_tag *mt);
404105197Ssamextern int ipsec4_process_packet __P((struct mbuf *, struct ipsecrequest *,
405105197Ssam			int, int));
406105197Ssamextern int ipsec_process_done __P((struct mbuf *, struct ipsecrequest *));
407105197Ssam
408105197Ssamextern struct mbuf *ipsec_copypkt __P((struct mbuf *));
409105197Ssam
410105197Ssamextern	void m_checkalignment(const char* where, struct mbuf *m0,
411105197Ssam		int off, int len);
412105197Ssamextern	struct mbuf *m_clone(struct mbuf *m0);
413105197Ssamextern	struct mbuf *m_makespace(struct mbuf *m0, int skip, int hlen, int *off);
414105197Ssamextern	caddr_t m_pad(struct mbuf *m, int n);
415105197Ssamextern	int m_striphdr(struct mbuf *m, int skip, int hlen);
416105197Ssam#endif /* _KERNEL */
417105197Ssam
418105197Ssam#ifndef _KERNEL
419105197Ssamextern caddr_t ipsec_set_policy __P((char *, int));
420105197Ssamextern int ipsec_get_policylen __P((caddr_t));
421105197Ssamextern char *ipsec_dump_policy __P((caddr_t, char *));
422105197Ssam
423105197Ssamextern const char *ipsec_strerror __P((void));
424105197Ssam#endif /* !_KERNEL */
425105197Ssam
426105197Ssam#endif /* _NETIPSEC_IPSEC_H_ */
427