xform_ipip.c revision 195782
1/*	$FreeBSD: head/sys/netipsec/xform_ipip.c 195782 2009-07-20 13:55:33Z rwatson $	*/
2/*	$OpenBSD: ip_ipip.c,v 1.25 2002/06/10 18:04:55 itojun Exp $ */
3/*-
4 * The authors of this code are John Ioannidis (ji@tla.org),
5 * Angelos D. Keromytis (kermit@csd.uch.gr) and
6 * Niels Provos (provos@physnet.uni-hamburg.de).
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.
18 *
19 * Copyright (C) 1995, 1996, 1997, 1998, 1999 by John Ioannidis,
20 * Angelos D. Keromytis and Niels Provos.
21 * Copyright (c) 2001, Angelos D. Keromytis.
22 *
23 * Permission to use, copy, and modify this software with or without fee
24 * is hereby granted, provided that this entire notice is included in
25 * all copies of any software which is or includes a copy or
26 * modification of this software.
27 * You may use this code under the GNU public license if you so wish. Please
28 * contribute changes back to the authors under this freer than GPL license
29 * so that we may further the use of strong encryption without limitations to
30 * all.
31 *
32 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
33 * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
34 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
35 * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
36 * PURPOSE.
37 */
38
39/*
40 * IP-inside-IP processing
41 */
42#include "opt_inet.h"
43#include "opt_inet6.h"
44#include "opt_enc.h"
45
46#include <sys/param.h>
47#include <sys/systm.h>
48#include <sys/mbuf.h>
49#include <sys/socket.h>
50#include <sys/kernel.h>
51#include <sys/protosw.h>
52#include <sys/sysctl.h>
53#include <sys/vimage.h>
54
55#include <net/if.h>
56#include <net/pfil.h>
57#include <net/route.h>
58#include <net/netisr.h>
59#include <net/vnet.h>
60
61#include <netinet/in.h>
62#include <netinet/in_systm.h>
63#include <netinet/in_var.h>
64#include <netinet/ip.h>
65#include <netinet/ip_ecn.h>
66#include <netinet/ip_var.h>
67#include <netinet/ip_encap.h>
68#ifdef MROUTING
69#include <netinet/ip_mroute.h>
70#endif
71
72#include <netipsec/ipsec.h>
73#include <netipsec/xform.h>
74
75#include <netipsec/ipip_var.h>
76
77#ifdef INET6
78#include <netinet/ip6.h>
79#include <netipsec/ipsec6.h>
80#include <netinet6/ip6_ecn.h>
81#include <netinet6/in6_var.h>
82#include <netinet6/ip6protosw.h>
83#endif
84
85#include <netipsec/key.h>
86#include <netipsec/key_debug.h>
87
88#include <machine/stdarg.h>
89
90/*
91 * We can control the acceptance of IP4 packets by altering the sysctl
92 * net.inet.ipip.allow value.  Zero means drop them, all else is acceptance.
93 */
94VNET_DEFINE(int, ipip_allow) = 0;
95VNET_DEFINE(struct ipipstat, ipipstat);
96
97SYSCTL_DECL(_net_inet_ipip);
98SYSCTL_VNET_INT(_net_inet_ipip, OID_AUTO,
99	ipip_allow,	CTLFLAG_RW,	&VNET_NAME(ipip_allow),	0, "");
100SYSCTL_VNET_STRUCT(_net_inet_ipip, IPSECCTL_STATS,
101	stats,		CTLFLAG_RD,	&VNET_NAME(ipipstat),	ipipstat, "");
102
103/* XXX IPCOMP */
104#define	M_IPSEC	(M_AUTHIPHDR|M_AUTHIPDGM|M_DECRYPTED)
105
106static void _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp);
107
108#ifdef INET6
109/*
110 * Really only a wrapper for ipip_input(), for use with IPv6.
111 */
112int
113ip4_input6(struct mbuf **m, int *offp, int proto)
114{
115#if 0
116	/* If we do not accept IP-in-IP explicitly, drop.  */
117	if (!V_ipip_allow && ((*m)->m_flags & M_IPSEC) == 0) {
118		DPRINTF(("%s: dropped due to policy\n", __func__));
119		V_ipipstat.ipips_pdrops++;
120		m_freem(*m);
121		return IPPROTO_DONE;
122	}
123#endif
124	_ipip_input(*m, *offp, NULL);
125	return IPPROTO_DONE;
126}
127#endif /* INET6 */
128
129#ifdef INET
130/*
131 * Really only a wrapper for ipip_input(), for use with IPv4.
132 */
133void
134ip4_input(struct mbuf *m, int off)
135{
136#if 0
137	/* If we do not accept IP-in-IP explicitly, drop.  */
138	if (!V_ipip_allow && (m->m_flags & M_IPSEC) == 0) {
139		DPRINTF(("%s: dropped due to policy\n", __func__));
140		V_ipipstat.ipips_pdrops++;
141		m_freem(m);
142		return;
143	}
144#endif
145	_ipip_input(m, off, NULL);
146}
147#endif /* INET */
148
149/*
150 * ipip_input gets called when we receive an IP{46} encapsulated packet,
151 * either because we got it at a real interface, or because AH or ESP
152 * were being used in tunnel mode (in which case the rcvif element will
153 * contain the address of the encX interface associated with the tunnel.
154 */
155
156static void
157_ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp)
158{
159#ifdef INET
160	register struct sockaddr_in *sin;
161#endif
162	register struct ifnet *ifp;
163	register struct ifaddr *ifa;
164	struct ip *ipo;
165#ifdef INET6
166	register struct sockaddr_in6 *sin6;
167	struct ip6_hdr *ip6 = NULL;
168	u_int8_t itos;
169#endif
170	u_int8_t nxt;
171	int isr;
172	u_int8_t otos;
173	u_int8_t v;
174	int hlen;
175
176	V_ipipstat.ipips_ipackets++;
177
178	m_copydata(m, 0, 1, &v);
179
180	switch (v >> 4) {
181#ifdef INET
182        case 4:
183		hlen = sizeof(struct ip);
184		break;
185#endif /* INET */
186#ifdef INET6
187        case 6:
188		hlen = sizeof(struct ip6_hdr);
189		break;
190#endif
191        default:
192		V_ipipstat.ipips_family++;
193		m_freem(m);
194		return /* EAFNOSUPPORT */;
195	}
196
197	/* Bring the IP header in the first mbuf, if not there already */
198	if (m->m_len < hlen) {
199		if ((m = m_pullup(m, hlen)) == NULL) {
200			DPRINTF(("%s: m_pullup (1) failed\n", __func__));
201			V_ipipstat.ipips_hdrops++;
202			return;
203		}
204	}
205
206	ipo = mtod(m, struct ip *);
207
208#ifdef MROUTING
209	if (ipo->ip_v == IPVERSION && ipo->ip_p == IPPROTO_IPV4) {
210		if (IN_MULTICAST(((struct ip *)((char *) ipo + iphlen))->ip_dst.s_addr)) {
211			ipip_mroute_input (m, iphlen);
212			return;
213		}
214	}
215#endif /* MROUTING */
216
217	/* Keep outer ecn field. */
218	switch (v >> 4) {
219#ifdef INET
220	case 4:
221		otos = ipo->ip_tos;
222		break;
223#endif /* INET */
224#ifdef INET6
225	case 6:
226		otos = (ntohl(mtod(m, struct ip6_hdr *)->ip6_flow) >> 20) & 0xff;
227		break;
228#endif
229	default:
230		panic("ipip_input: unknown ip version %u (outer)", v>>4);
231	}
232
233	/* Remove outer IP header */
234	m_adj(m, iphlen);
235
236	/* Sanity check */
237	if (m->m_pkthdr.len < sizeof(struct ip))  {
238		V_ipipstat.ipips_hdrops++;
239		m_freem(m);
240		return;
241	}
242
243	m_copydata(m, 0, 1, &v);
244
245	switch (v >> 4) {
246#ifdef INET
247        case 4:
248		hlen = sizeof(struct ip);
249		break;
250#endif /* INET */
251
252#ifdef INET6
253        case 6:
254		hlen = sizeof(struct ip6_hdr);
255		break;
256#endif
257	default:
258		V_ipipstat.ipips_family++;
259		m_freem(m);
260		return; /* EAFNOSUPPORT */
261	}
262
263	/*
264	 * Bring the inner IP header in the first mbuf, if not there already.
265	 */
266	if (m->m_len < hlen) {
267		if ((m = m_pullup(m, hlen)) == NULL) {
268			DPRINTF(("%s: m_pullup (2) failed\n", __func__));
269			V_ipipstat.ipips_hdrops++;
270			return;
271		}
272	}
273
274	/*
275	 * RFC 1853 specifies that the inner TTL should not be touched on
276	 * decapsulation. There's no reason this comment should be here, but
277	 * this is as good as any a position.
278	 */
279
280	/* Some sanity checks in the inner IP header */
281	switch (v >> 4) {
282#ifdef INET
283    	case 4:
284                ipo = mtod(m, struct ip *);
285                nxt = ipo->ip_p;
286		ip_ecn_egress(V_ip4_ipsec_ecn, &otos, &ipo->ip_tos);
287                break;
288#endif /* INET */
289#ifdef INET6
290    	case 6:
291                ip6 = (struct ip6_hdr *) ipo;
292                nxt = ip6->ip6_nxt;
293		itos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
294		ip_ecn_egress(V_ip6_ipsec_ecn, &otos, &itos);
295		ip6->ip6_flow &= ~htonl(0xff << 20);
296		ip6->ip6_flow |= htonl((u_int32_t) itos << 20);
297                break;
298#endif
299	default:
300		panic("ipip_input: unknown ip version %u (inner)", v>>4);
301	}
302
303	/* Check for local address spoofing. */
304	if ((m->m_pkthdr.rcvif == NULL ||
305	    !(m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK)) &&
306	    V_ipip_allow != 2) {
307	    	IFNET_RLOCK();
308		TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
309			TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
310#ifdef INET
311				if (ipo) {
312					if (ifa->ifa_addr->sa_family !=
313					    AF_INET)
314						continue;
315
316					sin = (struct sockaddr_in *) ifa->ifa_addr;
317
318					if (sin->sin_addr.s_addr ==
319					    ipo->ip_src.s_addr)	{
320						V_ipipstat.ipips_spoof++;
321						m_freem(m);
322						IFNET_RUNLOCK();
323						return;
324					}
325				}
326#endif /* INET */
327
328#ifdef INET6
329				if (ip6) {
330					if (ifa->ifa_addr->sa_family !=
331					    AF_INET6)
332						continue;
333
334					sin6 = (struct sockaddr_in6 *) ifa->ifa_addr;
335
336					if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &ip6->ip6_src)) {
337						V_ipipstat.ipips_spoof++;
338						m_freem(m);
339						IFNET_RUNLOCK();
340						return;
341					}
342
343				}
344#endif /* INET6 */
345			}
346		}
347		IFNET_RUNLOCK();
348	}
349
350	/* Statistics */
351	V_ipipstat.ipips_ibytes += m->m_pkthdr.len - iphlen;
352
353#ifdef DEV_ENC
354	switch (v >> 4) {
355#ifdef INET
356	case 4:
357		ipsec_bpf(m, NULL, AF_INET, ENC_IN|ENC_AFTER);
358		break;
359#endif
360#ifdef INET6
361	case 6:
362		ipsec_bpf(m, NULL, AF_INET6, ENC_IN|ENC_AFTER);
363		break;
364#endif
365	default:
366		panic("%s: bogus ip version %u", __func__, v>>4);
367	}
368	/* pass the mbuf to enc0 for packet filtering */
369	if (ipsec_filter(&m, PFIL_IN, ENC_IN|ENC_AFTER) != 0)
370		return;
371#endif
372
373	/*
374	 * Interface pointer stays the same; if no IPsec processing has
375	 * been done (or will be done), this will point to a normal
376	 * interface. Otherwise, it'll point to an enc interface, which
377	 * will allow a packet filter to distinguish between secure and
378	 * untrusted packets.
379	 */
380
381	switch (v >> 4) {
382#ifdef INET
383	case 4:
384		isr = NETISR_IP;
385		break;
386#endif
387#ifdef INET6
388	case 6:
389		isr = NETISR_IPV6;
390		break;
391#endif
392	default:
393		panic("%s: bogus ip version %u", __func__, v>>4);
394	}
395
396	if (netisr_queue(isr, m)) {	/* (0) on success. */
397		V_ipipstat.ipips_qfull++;
398		DPRINTF(("%s: packet dropped because of full queue\n",
399			__func__));
400	}
401}
402
403int
404ipip_output(
405	struct mbuf *m,
406	struct ipsecrequest *isr,
407	struct mbuf **mp,
408	int skip,
409	int protoff
410)
411{
412	struct secasvar *sav;
413	u_int8_t tp, otos;
414	struct secasindex *saidx;
415	int error;
416#ifdef INET
417	u_int8_t itos;
418	struct ip *ipo;
419#endif /* INET */
420#ifdef INET6
421	struct ip6_hdr *ip6, *ip6o;
422#endif /* INET6 */
423
424	sav = isr->sav;
425	IPSEC_ASSERT(sav != NULL, ("null SA"));
426	IPSEC_ASSERT(sav->sah != NULL, ("null SAH"));
427
428	/* XXX Deal with empty TDB source/destination addresses. */
429
430	m_copydata(m, 0, 1, &tp);
431	tp = (tp >> 4) & 0xff;  /* Get the IP version number. */
432
433	saidx = &sav->sah->saidx;
434	switch (saidx->dst.sa.sa_family) {
435#ifdef INET
436	case AF_INET:
437		if (saidx->src.sa.sa_family != AF_INET ||
438		    saidx->src.sin.sin_addr.s_addr == INADDR_ANY ||
439		    saidx->dst.sin.sin_addr.s_addr == INADDR_ANY) {
440			DPRINTF(("%s: unspecified tunnel endpoint "
441			    "address in SA %s/%08lx\n", __func__,
442			    ipsec_address(&saidx->dst),
443			    (u_long) ntohl(sav->spi)));
444			V_ipipstat.ipips_unspec++;
445			error = EINVAL;
446			goto bad;
447		}
448
449		M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
450		if (m == 0) {
451			DPRINTF(("%s: M_PREPEND failed\n", __func__));
452			V_ipipstat.ipips_hdrops++;
453			error = ENOBUFS;
454			goto bad;
455		}
456
457		ipo = mtod(m, struct ip *);
458
459		ipo->ip_v = IPVERSION;
460		ipo->ip_hl = 5;
461		ipo->ip_len = htons(m->m_pkthdr.len);
462		ipo->ip_ttl = V_ip_defttl;
463		ipo->ip_sum = 0;
464		ipo->ip_src = saidx->src.sin.sin_addr;
465		ipo->ip_dst = saidx->dst.sin.sin_addr;
466
467		ipo->ip_id = ip_newid();
468
469		/* If the inner protocol is IP... */
470		if (tp == IPVERSION) {
471			/* Save ECN notification */
472			m_copydata(m, sizeof(struct ip) +
473			    offsetof(struct ip, ip_tos),
474			    sizeof(u_int8_t), (caddr_t) &itos);
475
476			ipo->ip_p = IPPROTO_IPIP;
477
478			/*
479			 * We should be keeping tunnel soft-state and
480			 * send back ICMPs if needed.
481			 */
482			m_copydata(m, sizeof(struct ip) +
483			    offsetof(struct ip, ip_off),
484			    sizeof(u_int16_t), (caddr_t) &ipo->ip_off);
485			ipo->ip_off = ntohs(ipo->ip_off);
486			ipo->ip_off &= ~(IP_DF | IP_MF | IP_OFFMASK);
487			ipo->ip_off = htons(ipo->ip_off);
488		}
489#ifdef INET6
490		else if (tp == (IPV6_VERSION >> 4)) {
491			u_int32_t itos32;
492
493			/* Save ECN notification. */
494			m_copydata(m, sizeof(struct ip) +
495			    offsetof(struct ip6_hdr, ip6_flow),
496			    sizeof(u_int32_t), (caddr_t) &itos32);
497			itos = ntohl(itos32) >> 20;
498			ipo->ip_p = IPPROTO_IPV6;
499			ipo->ip_off = 0;
500		}
501#endif /* INET6 */
502		else {
503			goto nofamily;
504		}
505
506		otos = 0;
507		ip_ecn_ingress(ECN_ALLOWED, &otos, &itos);
508		ipo->ip_tos = otos;
509		break;
510#endif /* INET */
511
512#ifdef INET6
513	case AF_INET6:
514		if (IN6_IS_ADDR_UNSPECIFIED(&saidx->dst.sin6.sin6_addr) ||
515		    saidx->src.sa.sa_family != AF_INET6 ||
516		    IN6_IS_ADDR_UNSPECIFIED(&saidx->src.sin6.sin6_addr)) {
517			DPRINTF(("%s: unspecified tunnel endpoint "
518			    "address in SA %s/%08lx\n", __func__,
519			    ipsec_address(&saidx->dst),
520			    (u_long) ntohl(sav->spi)));
521			V_ipipstat.ipips_unspec++;
522			error = ENOBUFS;
523			goto bad;
524		}
525
526		/* scoped address handling */
527		ip6 = mtod(m, struct ip6_hdr *);
528		if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_src))
529			ip6->ip6_src.s6_addr16[1] = 0;
530		if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_dst))
531			ip6->ip6_dst.s6_addr16[1] = 0;
532
533		M_PREPEND(m, sizeof(struct ip6_hdr), M_DONTWAIT);
534		if (m == 0) {
535			DPRINTF(("%s: M_PREPEND failed\n", __func__));
536			V_ipipstat.ipips_hdrops++;
537			error = ENOBUFS;
538			goto bad;
539		}
540
541		/* Initialize IPv6 header */
542		ip6o = mtod(m, struct ip6_hdr *);
543		ip6o->ip6_flow = 0;
544		ip6o->ip6_vfc &= ~IPV6_VERSION_MASK;
545		ip6o->ip6_vfc |= IPV6_VERSION;
546		ip6o->ip6_plen = htons(m->m_pkthdr.len);
547		ip6o->ip6_hlim = V_ip_defttl;
548		ip6o->ip6_dst = saidx->dst.sin6.sin6_addr;
549		ip6o->ip6_src = saidx->src.sin6.sin6_addr;
550
551#ifdef INET
552		if (tp == IPVERSION) {
553			/* Save ECN notification */
554			m_copydata(m, sizeof(struct ip6_hdr) +
555			    offsetof(struct ip, ip_tos), sizeof(u_int8_t),
556			    (caddr_t) &itos);
557
558			/* This is really IPVERSION. */
559			ip6o->ip6_nxt = IPPROTO_IPIP;
560		} else
561#endif /* INET */
562			if (tp == (IPV6_VERSION >> 4)) {
563				u_int32_t itos32;
564
565				/* Save ECN notification. */
566				m_copydata(m, sizeof(struct ip6_hdr) +
567				    offsetof(struct ip6_hdr, ip6_flow),
568				    sizeof(u_int32_t), (caddr_t) &itos32);
569				itos = ntohl(itos32) >> 20;
570
571				ip6o->ip6_nxt = IPPROTO_IPV6;
572			} else {
573				goto nofamily;
574			}
575
576		otos = 0;
577		ip_ecn_ingress(ECN_ALLOWED, &otos, &itos);
578		ip6o->ip6_flow |= htonl((u_int32_t) otos << 20);
579		break;
580#endif /* INET6 */
581
582	default:
583nofamily:
584		DPRINTF(("%s: unsupported protocol family %u\n", __func__,
585		    saidx->dst.sa.sa_family));
586		V_ipipstat.ipips_family++;
587		error = EAFNOSUPPORT;		/* XXX diffs from openbsd */
588		goto bad;
589	}
590
591	V_ipipstat.ipips_opackets++;
592	*mp = m;
593
594#ifdef INET
595	if (saidx->dst.sa.sa_family == AF_INET) {
596#if 0
597		if (sav->tdb_xform->xf_type == XF_IP4)
598			tdb->tdb_cur_bytes +=
599			    m->m_pkthdr.len - sizeof(struct ip);
600#endif
601		V_ipipstat.ipips_obytes += m->m_pkthdr.len - sizeof(struct ip);
602	}
603#endif /* INET */
604
605#ifdef INET6
606	if (saidx->dst.sa.sa_family == AF_INET6) {
607#if 0
608		if (sav->tdb_xform->xf_type == XF_IP4)
609			tdb->tdb_cur_bytes +=
610			    m->m_pkthdr.len - sizeof(struct ip6_hdr);
611#endif
612		V_ipipstat.ipips_obytes +=
613		    m->m_pkthdr.len - sizeof(struct ip6_hdr);
614	}
615#endif /* INET6 */
616
617	return 0;
618bad:
619	if (m)
620		m_freem(m);
621	*mp = NULL;
622	return (error);
623}
624
625#ifdef IPSEC
626static int
627ipe4_init(struct secasvar *sav, struct xformsw *xsp)
628{
629	sav->tdb_xform = xsp;
630	return 0;
631}
632
633static int
634ipe4_zeroize(struct secasvar *sav)
635{
636	sav->tdb_xform = NULL;
637	return 0;
638}
639
640static int
641ipe4_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff)
642{
643	/* This is a rather serious mistake, so no conditional printing. */
644	printf("%s: should never be called\n", __func__);
645	if (m)
646		m_freem(m);
647	return EOPNOTSUPP;
648}
649
650static struct xformsw ipe4_xformsw = {
651	XF_IP4,		0,		"IPv4 Simple Encapsulation",
652	ipe4_init,	ipe4_zeroize,	ipe4_input,	ipip_output,
653};
654
655extern struct domain inetdomain;
656static struct protosw ipe4_protosw = {
657	.pr_type =	SOCK_RAW,
658	.pr_domain =	&inetdomain,
659	.pr_protocol =	IPPROTO_IPV4,
660	.pr_flags =	PR_ATOMIC|PR_ADDR|PR_LASTHDR,
661	.pr_input =	ip4_input,
662	.pr_ctloutput =	rip_ctloutput,
663	.pr_usrreqs =	&rip_usrreqs
664};
665#ifdef INET6
666static struct ip6protosw ipe6_protosw = {
667	.pr_type =	SOCK_RAW,
668	.pr_domain =	&inetdomain,
669	.pr_protocol =	IPPROTO_IPV6,
670	.pr_flags =	PR_ATOMIC|PR_ADDR|PR_LASTHDR,
671	.pr_input =	ip4_input6,
672	.pr_ctloutput =	rip_ctloutput,
673	.pr_usrreqs =	&rip_usrreqs
674};
675#endif
676
677/*
678 * Check the encapsulated packet to see if we want it
679 */
680static int
681ipe4_encapcheck(const struct mbuf *m, int off, int proto, void *arg)
682{
683	/*
684	 * Only take packets coming from IPSEC tunnels; the rest
685	 * must be handled by the gif tunnel code.  Note that we
686	 * also return a minimum priority when we want the packet
687	 * so any explicit gif tunnels take precedence.
688	 */
689	return ((m->m_flags & M_IPSEC) != 0 ? 1 : 0);
690}
691
692static void
693ipe4_attach(void)
694{
695
696	xform_register(&ipe4_xformsw);
697	/* attach to encapsulation framework */
698	/* XXX save return cookie for detach on module remove */
699	(void) encap_attach_func(AF_INET, -1,
700		ipe4_encapcheck, &ipe4_protosw, NULL);
701#ifdef INET6
702	(void) encap_attach_func(AF_INET6, -1,
703		ipe4_encapcheck, (struct protosw *)&ipe6_protosw, NULL);
704#endif
705}
706SYSINIT(ipe4_xform_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_MIDDLE, ipe4_attach, NULL);
707#endif	/* IPSEC */
708