153642Sguido/*
2255332Scy * Copyright (C) 2012 by Darren Reed.
353642Sguido *
480482Sdarrenr * See the IPFILTER.LICENCE file for details on licencing.
553642Sguido *
653642Sguido * @(#)ip_compat.h	1.8 1/14/96
757126Sguido * $FreeBSD: stable/11/sys/contrib/ipfilter/netinet/ip_compat.h 369277 2021-02-16 00:48:38Z cy $
8172776Sdarrenr * Id: ip_compat.h,v 2.142.2.57 2007/10/10 09:51:42 darrenr Exp $
953642Sguido */
1053642Sguido
1153642Sguido#ifndef	__IP_COMPAT_H__
1253642Sguido#define	__IP_COMPAT_H__
1353642Sguido
1453642Sguido#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__)
1553642Sguido# undef	KERNEL
1653642Sguido# undef	_KERNEL
1753642Sguido# undef 	__KERNEL__
1853642Sguido# define	KERNEL
1953642Sguido# define	_KERNEL
2053642Sguido# define 	__KERNEL__
2153642Sguido#endif
2253642Sguido
23305138Sdim#ifndef	SOLARIS
24344833Scy# if defined(sun) && defined(__SVR4)
25305138Sdim#  define	SOLARIS		1
26305138Sdim# else
27305138Sdim#  define	SOLARIS		0
28305138Sdim# endif
29305138Sdim#endif
30145522Sdarrenr
31145522Sdarrenr
32344833Scy#if defined(__SVR4)
33145522Sdarrenr# define index   strchr
34145522Sdarrenr# if !defined(_KERNEL)
3553642Sguido#  define	bzero(a,b)	memset(a,0,b)
3653642Sguido#  define	bcmp		memcmp
3753642Sguido#  define	bcopy(a,b,c)	memmove(b,a,c)
3853642Sguido# endif
3953642Sguido#endif
4053642Sguido
41145522Sdarrenr#ifndef LIFNAMSIZ
42145522Sdarrenr# ifdef IF_NAMESIZE
4392685Sdarrenr#  define	LIFNAMSIZ	IF_NAMESIZE
4492685Sdarrenr# else
4592685Sdarrenr#  ifdef	IFNAMSIZ
4692685Sdarrenr#   define	LIFNAMSIZ	IFNAMSIZ
4792685Sdarrenr#  else
4892685Sdarrenr#   define	LIFNAMSIZ	16
4992685Sdarrenr#  endif
5092685Sdarrenr# endif
5192685Sdarrenr#endif
5292685Sdarrenr
53145522Sdarrenr
5453642Sguido#  define IPL_EXTERN(ep) ipl##ep
5553642Sguido
5692685Sdarrenr/*
5792685Sdarrenr * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD.
5892685Sdarrenr */
59369246Scy#ifndef _KERNEL
60369246Scy# define ADD_KERNEL
61369246Scy# define _KERNEL
62369246Scy# define KERNEL
63369246Scy#endif
64369246Scy#include <sys/uio.h>
65369246Scy#ifdef ADD_KERNEL
66369246Scy# undef _KERNEL
67369246Scy# undef KERNEL
68369246Scy#endif
6992685Sdarrenr
70255332Scy#define	NETBSD_GE_REV(x)	(defined(__NetBSD_Version__) && \
71255332Scy				 (__NetBSD_Version__ >= (x)))
72255332Scy#define	NETBSD_GT_REV(x)	(defined(__NetBSD_Version__) && \
73255332Scy				 (__NetBSD_Version__ > (x)))
74255332Scy#define	NETBSD_LT_REV(x)	(defined(__NetBSD_Version__) && \
75255332Scy				 (__NetBSD_Version__ < (x)))
76145522Sdarrenr
77145522Sdarrenr
78145522Sdarrenr/* ----------------------------------------------------------------------- */
79145522Sdarrenr/*                                F R E E B S D                            */
80145522Sdarrenr/* ----------------------------------------------------------------------- */
81369246Scy#define HAS_SYS_MD5_H	1
82369246Scy#if defined(_KERNEL)
83369246Scy# include "opt_bpf.h"
84369246Scy# include "opt_inet6.h"
85369246Scy# if defined(INET6) && !defined(USE_INET6)
86369246Scy#  define USE_INET6
8760857Sdarrenr# endif
88369246Scy#else
89369246Scy# if !defined(USE_INET6) && !defined(NOINET6)
90369246Scy#  define	USE_INET6
91369246Scy# endif
92369246Scy#endif
93145522Sdarrenr
94369246Scy#if defined(_KERNEL)
95369246Scy# include <netinet/ip_var.h>
96369246Scy# define	p_cred	td_ucred
97369246Scy# define	p_uid	td_ucred->cr_ruid
98255332Scy
9953642Sguido/*
100145522Sdarrenr * When #define'd, the 5.2.1 kernel panics when used with the ftp proxy.
101145522Sdarrenr * There may be other, safe, kernels but this is not extensively tested yet.
10253642Sguido */
103369246Scy# define HAVE_M_PULLDOWN
104369277Scy# if !defined(IPFILTER_LKM) && defined(__FreeBSD__)
105369246Scy#  include "opt_ipfilter.h"
106369246Scy# endif
107369246Scy# define	COPYIN(a,b,c)	copyin((caddr_t)(a), (caddr_t)(b), (c))
108369246Scy# define	COPYOUT(a,b,c)	copyout((caddr_t)(a), (caddr_t)(b), (c))
109145522Sdarrenr
110369246Scy#else
111369246Scy# include <inttypes.h>
112369246Scy#endif /* _KERNEL */
113145522Sdarrenr
114369246Scy#include <sys/selinfo.h>
115369246Scy#include <sys/lock.h>
116369246Scy#include <sys/malloc.h>
117369246Scy#include <sys/mutex.h>
118369246Scy#define	KRWLOCK_FILL_SZ		56
119369246Scy#define	KMUTEX_FILL_SZ		56
120369246Scy#include <sys/rwlock.h>
121369246Scy#define	KMUTEX_T		struct mtx
122369246Scy#define	KRWLOCK_T		struct rwlock
123281192Sglebius
124281192Sglebius#ifdef _KERNEL
125369246Scy# define	READ_ENTER(x)		rw_rlock(&(x)->ipf_lk)
126369246Scy# define	WRITE_ENTER(x)		rw_wlock(&(x)->ipf_lk)
127369246Scy# define	MUTEX_DOWNGRADE(x)	rw_downgrade(&(x)->ipf_lk)
128369246Scy# define	MUTEX_TRY_UPGRADE(x)	rw_try_upgrade(&(x)->ipf_lk)
129369246Scy# define	RWLOCK_INIT(x,y)	rw_init(&(x)->ipf_lk, (y))
130369246Scy# define	RW_DESTROY(x)		rw_destroy(&(x)->ipf_lk)
131369246Scy# define	RWLOCK_EXIT(x)		do { \
132172776Sdarrenr					    if (rw_wowned(&(x)->ipf_lk)) \
133255332Scy					    	rw_wunlock(&(x)->ipf_lk); \
134255332Scy					    else \
135172776Sdarrenr						rw_runlock(&(x)->ipf_lk); \
136172776Sdarrenr					} while (0)
137369246Scy# include <net/if_var.h>
138369246Scy# define	GETKTIME(x)	microtime((struct timeval *)x)
139145522Sdarrenr
140369246Scy# include <netinet/in_systm.h>
141369246Scy# include <netinet/ip.h>
142369246Scy# include <machine/in_cksum.h>
143145522Sdarrenr
144369246Scy# define	USE_MUTEXES
145369246Scy# define	MUTEX_ENTER(x)		mtx_lock(&(x)->ipf_lk)
146369246Scy# define	MUTEX_EXIT(x)		mtx_unlock(&(x)->ipf_lk)
147369246Scy# define	MUTEX_INIT(x,y)		mtx_init(&(x)->ipf_lk, (y), NULL,\
148145522Sdarrenr						 MTX_DEF)
149369246Scy# define	MUTEX_DESTROY(x)	mtx_destroy(&(x)->ipf_lk)
150369246Scy# define	MUTEX_NUKE(x)		bzero((x), sizeof(*(x)))
151255332Scy/*
152255332Scy * Whilst the sx(9) locks on FreeBSD have the right semantics and interface
153255332Scy * for what we want to use them for, despite testing showing they work -
154255332Scy * with a WITNESS kernel, it generates LOR messages.
155255332Scy */
156369246Scy# include <machine/atomic.h>
157369246Scy# define	ATOMIC_INC(x)		{ mtx_lock(&softc->ipf_rw.ipf_lk); (x)++; \
158255332Scy					  mtx_unlock(&softc->ipf_rw.ipf_lk); }
159369246Scy# define	ATOMIC_DEC(x)		{ mtx_lock(&softc->ipf_rw.ipf_lk); (x)--; \
160255332Scy					  mtx_unlock(&softc->ipf_rw.ipf_lk); }
161369246Scy# define	ATOMIC_INCL(x)		atomic_add_long(&(x), 1)
162369246Scy# define	ATOMIC_INC64(x)		ATOMIC_INC(x)
163369246Scy# define	ATOMIC_INC32(x)		atomic_add_32((u_int *)&(x), 1)
164369246Scy# define	ATOMIC_DECL(x)		atomic_add_long(&(x), -1)
165369246Scy# define	ATOMIC_DEC64(x)		ATOMIC_DEC(x)
166369246Scy# define	ATOMIC_DEC32(x)		atomic_add_32((u_int *)&(x), -1)
167369246Scy# define	SPL_X(x)	;
168369246Scy# define	SPL_NET(x)	;
169369246Scy# define	SPL_IMP(x)	;
170369246Scy# define	SPL_SCHED(x)	;
171369246Scy# define	GET_MINOR		dev2unit
172369246Scy# define	MSGDSIZE(m)	mbufchainlen(m)
173369246Scy# define	M_LEN(m)	(m)->m_len
174369246Scy# define	M_ADJ(m,x)	m_adj(m, x)
175369246Scy# define	M_COPY(x)	m_copy((x), 0, M_COPYALL)
176369246Scy# define	M_DUP(m)	m_dup(m, M_NOWAIT)
177369246Scy# define	IPF_PANIC(x,y)	if (x) { printf y; panic("ipf_panic"); }
178145522Sdarrenrtypedef struct mbuf mb_t;
179145522Sdarrenr
180281192Sglebius#else	/* !_KERNEL */
181369246Scy# ifndef _NET_IF_VAR_H_
182281192Sglebius/*
183281192Sglebius * Userland emulation of struct ifnet.
184281192Sglebius */
185281192Sglebiusstruct route;
186281192Sglebiusstruct mbuf;
187281192Sglebiusstruct ifnet {
188281192Sglebius	char			if_xname[IFNAMSIZ];
189281192Sglebius	TAILQ_HEAD(, ifaddr)	if_addrlist;
190281192Sglebius	int	(*if_output)(struct ifnet *, struct mbuf *,
191281192Sglebius	    const struct sockaddr *, struct route *);
192281192Sglebius};
193369246Scy# endif /* _NET_IF_VAR_H_ */
194281192Sglebius#endif /* _KERNEL */
195145522Sdarrenr
196369246Scy#define	IFNAME(x)	((struct ifnet *)x)->if_xname
197369246Scy#define	COPYIFNAME(v, x, b) \
198369246Scy			(void) strncpy(b, \
199369246Scy			       ((struct ifnet *)x)->if_xname, \
200369246Scy			       LIFNAMSIZ)
201281192Sglebius
202145522Sdarrenrtypedef	u_long		ioctlcmd_t;
203145522Sdarrenrtypedef	struct uio	uio_t;
204145522Sdarrenrtypedef	int		minor_t;
205145522Sdarrenrtypedef	u_int32_t	u_32_t;
206145522Sdarrenr# define	U_32_T	1
207145522Sdarrenr
208145522Sdarrenr
209145522Sdarrenr/* ----------------------------------------------------------------------- */
210145522Sdarrenr/*                           G E N E R I C                                 */
211145522Sdarrenr/* ----------------------------------------------------------------------- */
212145522Sdarrenr
213145522Sdarrenr/*
214145522Sdarrenr * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in
215145522Sdarrenr * filter rules.
216145522Sdarrenr */
217153876Sguido#if !defined(IPFILTER_BPF)
218153876Sguido# if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \
219153876Sguido     (defined(NBPFILTER) && (NBPFILTER > 0))
220153876Sguido#  define	IPFILTER_BPF
221153876Sguido# endif
222145522Sdarrenr#endif
223145522Sdarrenr
224145522Sdarrenr/*
225145522Sdarrenr * Userland locking primitives
226145522Sdarrenr */
227255332Scy#ifndef _KERNEL
228369246Scy# if !defined(KMUTEX_FILL_SZ)
229369246Scy#  define	KMUTEX_FILL_SZ	1
230369246Scy# endif
231369246Scy# if !defined(KRWLOCK_FILL_SZ)
232369246Scy#  define	KRWLOCK_FILL_SZ	1
233369246Scy# endif
234255332Scy#endif
235255332Scy
236145522Sdarrenrtypedef	struct	{
237145522Sdarrenr	char	*eMm_owner;
238145522Sdarrenr	char	*eMm_heldin;
239145522Sdarrenr	u_int	eMm_magic;
240145522Sdarrenr	int	eMm_held;
241145522Sdarrenr	int	eMm_heldat;
242145522Sdarrenr} eMmutex_t;
243145522Sdarrenr
244145522Sdarrenrtypedef	struct	{
245145522Sdarrenr	char	*eMrw_owner;
246145522Sdarrenr	char	*eMrw_heldin;
247145522Sdarrenr	u_int	eMrw_magic;
248145522Sdarrenr	short	eMrw_read;
249145522Sdarrenr	short	eMrw_write;
250145522Sdarrenr	int	eMrw_heldat;
251145522Sdarrenr} eMrwlock_t;
252145522Sdarrenr
253145522Sdarrenrtypedef union {
254255332Scy	char	_fill[KMUTEX_FILL_SZ];
255145522Sdarrenr#ifdef KMUTEX_T
256145522Sdarrenr	struct	{
257145522Sdarrenr		KMUTEX_T	ipf_slk;
258255332Scy		const char	*ipf_lname;
259145522Sdarrenr	} ipf_lkun_s;
260145522Sdarrenr#endif
261145522Sdarrenr	eMmutex_t	ipf_emu;
262145522Sdarrenr} ipfmutex_t;
263145522Sdarrenr
264145522Sdarrenrtypedef union {
265255332Scy	char	_fill[KRWLOCK_FILL_SZ];
266145522Sdarrenr#ifdef KRWLOCK_T
267145522Sdarrenr	struct	{
268145522Sdarrenr		KRWLOCK_T	ipf_slk;
269255332Scy		const char	*ipf_lname;
270145522Sdarrenr		int		ipf_sr;
271145522Sdarrenr		int		ipf_sw;
272145522Sdarrenr		u_int		ipf_magic;
273145522Sdarrenr	} ipf_lkun_s;
274145522Sdarrenr#endif
275145522Sdarrenr	eMrwlock_t	ipf_emu;
276145522Sdarrenr} ipfrwlock_t;
277145522Sdarrenr
278145522Sdarrenr#define	ipf_lk		ipf_lkun_s.ipf_slk
279145522Sdarrenr#define	ipf_lname	ipf_lkun_s.ipf_lname
280145522Sdarrenr#define	ipf_isr		ipf_lkun_s.ipf_sr
281145522Sdarrenr#define	ipf_isw		ipf_lkun_s.ipf_sw
282145522Sdarrenr#define	ipf_magic	ipf_lkun_s.ipf_magic
283145522Sdarrenr
284369277Scy#if !defined(__GNUC__) || defined(__FreeBSD__)
285145522Sdarrenr# ifndef	INLINE
286145522Sdarrenr#  define	INLINE
287145522Sdarrenr# endif
288145522Sdarrenr#else
289145522Sdarrenr# define	INLINE	__inline__
290145522Sdarrenr#endif
291145522Sdarrenr
292369277Scy#if defined(__FreeBSD__) && defined(_KERNEL)
293255332Scy     CTASSERT(sizeof(ipfrwlock_t) == KRWLOCK_FILL_SZ);
294255332Scy     CTASSERT(sizeof(ipfmutex_t) == KMUTEX_FILL_SZ);
295145522Sdarrenr#endif
296145522Sdarrenr
297255332Scy
298145522Sdarrenr/*
299145522Sdarrenr * In a non-kernel environment, there are a lot of macros that need to be
300145522Sdarrenr * filled in to be null-ops or to point to some compatibility function,
301145522Sdarrenr * somewhere in userland.
302145522Sdarrenr */
303145522Sdarrenr#ifndef _KERNEL
304145522Sdarrenrtypedef	struct	mb_s	{
305145522Sdarrenr	struct	mb_s	*mb_next;
306255332Scy	char		*mb_data;
307255332Scy	void		*mb_ifp;
308145522Sdarrenr	int		mb_len;
309255332Scy	int		mb_flags;
310145522Sdarrenr	u_long		mb_buf[2048];
311145522Sdarrenr} mb_t;
312145522Sdarrenr# undef		m_next
313145522Sdarrenr# define	m_next		mb_next
314255332Scy# undef		m_len
315255332Scy# define	m_len		mb_len
316255332Scy# undef		m_flags
317255332Scy# define	m_flags		mb_flags
318255332Scy# undef		m_data
319255332Scy# define	m_data		mb_data
320255332Scy# undef		M_MCAST
321255332Scy# define	M_MCAST		0x01
322255332Scy# undef		M_BCAST
323255332Scy# define	M_BCAST		0x02
324255332Scy# undef		M_MBCAST
325255332Scy# define	M_MBCAST	0x04
326255332Scy# define	MSGDSIZE(m)	msgdsize(m)
327255332Scy# define	M_LEN(m)	(m)->mb_len
328255332Scy# define	M_ADJ(m,x)	(m)->mb_len += x
329255332Scy# define	M_COPY(m)	dupmbt(m)
330255332Scy# define	M_DUP(m)	dupmbt(m)
331145522Sdarrenr# define	GETKTIME(x)	gettimeofday((struct timeval *)(x), NULL)
332255332Scy# define	MTOD(m, t)	((t)(m)->mb_data)
333255332Scy# define	FREE_MB_T(m)	freembt(m)
334255332Scy# define	ALLOC_MB_T(m,l)	(m) = allocmbt(l)
335255332Scy# define	PREP_MB_T(f, m)	do { \
336255332Scy						(m)->mb_next = *(f)->fin_mp; \
337255332Scy						*(fin)->fin_mp = (m); \
338255332Scy						(f)->fin_m = (m); \
339255332Scy					} while (0)
340145522Sdarrenr# define	SLEEP(x,y)	1;
341145522Sdarrenr# define	WAKEUP(x,y)	;
342161356Sguido# define	POLLWAKEUP(y)	;
343145522Sdarrenr# define	IPF_PANIC(x,y)	;
344145522Sdarrenr# define	PANIC(x,y)	;
345170268Sdarrenr# define	SPL_SCHED(x)	;
346145522Sdarrenr# define	SPL_NET(x)	;
347145522Sdarrenr# define	SPL_IMP(x)	;
348145522Sdarrenr# define	SPL_X(x)	;
349145522Sdarrenr# define	KMALLOC(a,b)	(a) = (b)malloc(sizeof(*a))
350145522Sdarrenr# define	KMALLOCS(a,b,c)	(a) = (b)malloc(c)
351145522Sdarrenr# define	KFREE(x)	free(x)
352145522Sdarrenr# define	KFREES(x,s)	free(x)
353145522Sdarrenr# define	GETIFP(x, v)	get_unit(x,v)
354255332Scy# define	GETIFMTU_4(x)	2048
355255332Scy# define	GETIFMTU_6(x)	2048
356153876Sguido# define	COPYIN(a,b,c)	bcopywrap((a), (b), (c))
357153876Sguido# define	COPYOUT(a,b,c)	bcopywrap((a), (b), (c))
358145522Sdarrenr# define	COPYDATA(m, o, l, b)	bcopy(MTOD((mb_t *)m, char *) + (o), \
359145522Sdarrenr					      (b), (l))
360145522Sdarrenr# define	COPYBACK(m, o, l, b)	bcopy((b), \
361145522Sdarrenr					      MTOD((mb_t *)m, char *) + (o), \
362145522Sdarrenr					      (l))
363172776Sdarrenr# define	UIOMOVE(a,b,c,d)	ipfuiomove((caddr_t)a,b,c,d)
364369245Sgit2svnextern	void	m_copydata(mb_t *, int, int, caddr_t);
365369245Sgit2svnextern	int	ipfuiomove(caddr_t, int, int, struct uio *);
366369245Sgit2svnextern	int	bcopywrap(void *, void *, size_t);
367369245Sgit2svnextern	mb_t	*allocmbt(size_t);
368369245Sgit2svnextern	mb_t	*dupmbt(mb_t *);
369369245Sgit2svnextern	void	freembt(mb_t *);
370145522Sdarrenr
371255332Scy# define	MUTEX_DESTROY(x)	eMmutex_destroy(&(x)->ipf_emu, \
372255332Scy							__FILE__, __LINE__)
373145522Sdarrenr# define	MUTEX_ENTER(x)		eMmutex_enter(&(x)->ipf_emu, \
374145522Sdarrenr						      __FILE__, __LINE__)
375255332Scy# define	MUTEX_EXIT(x)		eMmutex_exit(&(x)->ipf_emu, \
376255332Scy						     __FILE__, __LINE__)
377255332Scy# define	MUTEX_INIT(x,y)		eMmutex_init(&(x)->ipf_emu, y, \
378255332Scy						     __FILE__, __LINE__)
379145522Sdarrenr# define	MUTEX_NUKE(x)		bzero((x), sizeof(*(x)))
380145522Sdarrenr
381145522Sdarrenr# define	MUTEX_DOWNGRADE(x)	eMrwlock_downgrade(&(x)->ipf_emu, \
382145522Sdarrenr							   __FILE__, __LINE__)
383314251Scy# define	MUTEX_TRY_UPGRADE(x)	eMrwlock_try_upgrade(&(x)->ipf_emu, \
384314251Scy							   __FILE__, __LINE__)
385145522Sdarrenr# define	READ_ENTER(x)		eMrwlock_read_enter(&(x)->ipf_emu, \
386145522Sdarrenr							    __FILE__, __LINE__)
387145522Sdarrenr# define	RWLOCK_INIT(x, y)	eMrwlock_init(&(x)->ipf_emu, y)
388145522Sdarrenr# define	RWLOCK_EXIT(x)		eMrwlock_exit(&(x)->ipf_emu)
389145522Sdarrenr# define	RW_DESTROY(x)		eMrwlock_destroy(&(x)->ipf_emu)
390145522Sdarrenr# define	WRITE_ENTER(x)		eMrwlock_write_enter(&(x)->ipf_emu, \
391145522Sdarrenr							     __FILE__, \
392145522Sdarrenr							     __LINE__)
393145522Sdarrenr
394145522Sdarrenr# define	USE_MUTEXES		1
395145522Sdarrenr
396369245Sgit2svnextern void eMmutex_destroy(eMmutex_t *, char *, int);
397369245Sgit2svnextern void eMmutex_enter(eMmutex_t *, char *, int);
398369245Sgit2svnextern void eMmutex_exit(eMmutex_t *, char *, int);
399369245Sgit2svnextern void eMmutex_init(eMmutex_t *, char *, char *, int);
400369245Sgit2svnextern void eMrwlock_destroy(eMrwlock_t *);
401369245Sgit2svnextern void eMrwlock_exit(eMrwlock_t *);
402369245Sgit2svnextern void eMrwlock_init(eMrwlock_t *, char *);
403369245Sgit2svnextern void eMrwlock_read_enter(eMrwlock_t *, char *, int);
404369245Sgit2svnextern void eMrwlock_write_enter(eMrwlock_t *, char *, int);
405369245Sgit2svnextern void eMrwlock_downgrade(eMrwlock_t *, char *, int);
406145522Sdarrenr
407145522Sdarrenr#endif
408145522Sdarrenr
409255332Scyextern	mb_t	*allocmbt(size_t);
410255332Scy
411145522Sdarrenr#define	MAX_IPV4HDR	((0xf << 2) + sizeof(struct icmp) + sizeof(ip_t) + 8)
412145522Sdarrenr
413145522Sdarrenr#ifndef	IP_OFFMASK
414145522Sdarrenr# define	IP_OFFMASK	0x1fff
415145522Sdarrenr#endif
416145522Sdarrenr
417145522Sdarrenr
418145522Sdarrenr/*
419145522Sdarrenr * On BSD's use quad_t as a guarantee for getting at least a 64bit sized
420145522Sdarrenr * object.
421145522Sdarrenr */
422358666Scy#if !defined(__amd64__) && !SOLARIS
423145522Sdarrenr# define	USE_QUAD_T
424145640Sdarrenr# define	U_QUAD_T	unsigned long long
425145640Sdarrenr# define	QUAD_T		long long
426369273Scy#else /* BSD  */
427255332Scy# if !defined(U_QUAD_T)
428255332Scy#  define	U_QUAD_T	u_long
429255332Scy#  define	QUAD_T		long
430255332Scy# endif
431369273Scy#endif /* BSD */
432145522Sdarrenr
433145522Sdarrenr
43460857Sdarrenr#ifdef	USE_INET6
435344833Scy# if defined(__NetBSD__) || defined(__FreeBSD__)
43660857Sdarrenr#  include <netinet/ip6.h>
437145522Sdarrenr#  include <netinet/icmp6.h>
438344833Scy#   if defined(_KERNEL)
439145522Sdarrenr#    include <netinet6/ip6_var.h>
440145522Sdarrenr#   endif
44160857Sdarrenrtypedef	struct ip6_hdr	ip6_t;
44260857Sdarrenr# endif
44360857Sdarrenr#endif
44460857Sdarrenr
44553642Sguido#ifndef	MAX
446145522Sdarrenr# define	MAX(a,b)	(((a) > (b)) ? (a) : (b))
44753642Sguido#endif
44853642Sguido
449145522Sdarrenr#if defined(_KERNEL)
450369272Scy# if SOLARIS && !defined(INSTANCES)
451145522Sdarrenr#  define	COPYDATA	mb_copydata
452145522Sdarrenr#  define	COPYBACK	mb_copyback
453145522Sdarrenr# else
454145522Sdarrenr#  define	COPYDATA	m_copydata
455145522Sdarrenr#  define	COPYBACK	m_copyback
456145522Sdarrenr# endif
457369246Scy# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \
458369246Scy      defined(__FreeBSD__)
459369246Scy#  include <vm/vm.h>
460369246Scy# endif
461369246Scy# if NETBSD_GE_REV(105180000)
462369246Scy#  include <uvm/uvm_extern.h>
463369246Scy# else
464369246Scy#  include <vm/vm_extern.h>
465145522Sdarrenrextern  vm_map_t        kmem_map;
466369246Scy# endif
467369246Scy# include <sys/proc.h>
468145522Sdarrenr
469369246Scy# ifdef IPFILTER_M_IPFILTER
470369246Scy#  include <sys/malloc.h>
471145522SdarrenrMALLOC_DECLARE(M_IPFILTER);
472369246Scy#  define	_M_IPF		M_IPFILTER
473369246Scy# else /* IPFILTER_M_IPFILTER */
474369246Scy#  ifdef M_PFIL
475369246Scy#   define	_M_IPF		M_PFIL
476369246Scy#  else
477369246Scy#   ifdef M_IPFILTER
478145522Sdarrenr#    define	_M_IPF		M_IPFILTER
479145522Sdarrenr#   else
480369246Scy#    define	_M_IPF		M_TEMP
481369246Scy#   endif /* M_IPFILTER */
482369246Scy#  endif /* M_PFIL */
483369246Scy# endif /* IPFILTER_M_IPFILTER */
484369246Scy# if !defined(KMALLOC)
485369246Scy#  define	KMALLOC(a, b)	MALLOC((a), b, sizeof(*(a)), _M_IPF, M_NOWAIT)
486369246Scy# endif
487369246Scy# if !defined(KMALLOCS)
488369246Scy#  define	KMALLOCS(a, b, c)	MALLOC((a), b, (c), _M_IPF, M_NOWAIT)
489369246Scy# endif
490369246Scy# if !defined(KFREE)
491369246Scy#  define	KFREE(x)	FREE((x), _M_IPF)
492369246Scy# endif
493369246Scy#  if !defined(KFREES)
494369246Scy# define	KFREES(x,s)	FREE((x), _M_IPF)
495369246Scy# endif
496369246Scy# define	UIOMOVE(a,b,c,d)	uiomove((caddr_t)a,b,d)
497369246Scy# define	SLEEP(id, n)	tsleep((id), PPAUSE|PCATCH, n, 0)
498369246Scy# define	WAKEUP(id,x)	wakeup(id+x)
499369246Scy# if !defined(POLLWAKEUP)
500369246Scy#  define	POLLWAKEUP(x)	selwakeup(softc->ipf_selwait+x)
501369246Scy# endif
502369246Scy# define	GETIFP(n, v)	ifunit(n)
503369246Scy# define	GETIFMTU_4(x)	((struct ifnet *)x)->if_mtu
504369246Scy# define	GETIFMTU_6(x)	((struct ifnet *)x)->if_mtu
505145522Sdarrenr
506145522Sdarrenr# if !defined(USE_MUTEXES) && !defined(SPL_NET)
507255754Scy#  define	SPL_IMP(x)	x = splimp()
508255754Scy#  define	SPL_NET(x)	x = splnet()
509172776Sdarrenr#  if !defined(SPL_SCHED)
510172776Sdarrenr#   define	SPL_SCHED(x)	x = splsched()
511172776Sdarrenr#  endif
512145522Sdarrenr#  define	SPL_X(x)	(void) splx(x)
513145522Sdarrenr# endif /* !USE_MUTEXES */
514145522Sdarrenr
515145522Sdarrenr# ifndef FREE_MB_T
516145522Sdarrenr#  define	FREE_MB_T(m)	m_freem(m)
517145522Sdarrenr# endif
518255332Scy# ifndef ALLOC_MB_T
519255332Scy#  ifdef MGETHDR
520255332Scy#   define	ALLOC_MB_T(m,l)	do { \
521260715Sglebius					MGETHDR((m), M_NOWAIT, MT_HEADER); \
522255332Scy					if ((m) != NULL) { \
523255332Scy						(m)->m_len = (l); \
524255332Scy						(m)->m_pkthdr.len = (l); \
525255332Scy					} \
526255332Scy				} while (0)
527255332Scy#  else
528255332Scy#   define	ALLOC_MB_T(m,l)	do { \
529260715Sglebius					MGET((m), M_NOWAIT, MT_HEADER); \
530255332Scy					if ((m) != NULL) { \
531255332Scy						(m)->m_len = (l); \
532255332Scy						(m)->m_pkthdr.len = (l); \
533255332Scy					} \
534255332Scy				} while (0)
535255332Scy#  endif
536255332Scy# endif
537255332Scy# ifndef PREP_MB_T
538255332Scy#  define	PREP_MB_T(f, m)	do { \
539255332Scy						mb_t *_o = *(f)->fin_mp; \
540255332Scy						(m)->m_next = _o; \
541255332Scy						*(fin)->fin_mp = (m); \
542255332Scy						if (_o->m_flags & M_PKTHDR) { \
543255332Scy							(m)->m_pkthdr.len += \
544255332Scy							    _o->m_pkthdr.len; \
545255332Scy							(m)->m_pkthdr.rcvif = \
546255332Scy							  _o->m_pkthdr.rcvif; \
547255332Scy						} \
548255332Scy					} while (0)
549255332Scy# endif
550255332Scy# ifndef M_DUP
551255332Scy#  ifdef M_COPYALL
552255332Scy#   define	M_DUP(m)	m_dup(m, 0, M_COPYALL, 0)
553255332Scy#  else
554255332Scy#   define	M_DUP(m)	m_dup(m)
555255332Scy#  endif
556255332Scy# endif
557145522Sdarrenr
558145522Sdarrenr# ifndef MTOD
559145522Sdarrenr#  define	MTOD(m,t)	mtod(m,t)
560145522Sdarrenr# endif
561145522Sdarrenr
562145522Sdarrenr# ifndef COPYIN
563145522Sdarrenr#  define	COPYIN(a,b,c)	(bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
564145522Sdarrenr#  define	COPYOUT(a,b,c)	(bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
565145522Sdarrenr# endif
566145522Sdarrenr
567344837Scy# if SOLARIS && !defined(KMALLOC)
568145522Sdarrenr#  define	KMALLOC(a,b)	(a) = (b)new_kmem_alloc(sizeof(*(a)), \
569145522Sdarrenr							KMEM_NOSLEEP)
570145522Sdarrenr#  define	KMALLOCS(a,b,c)	(a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP)
571145522Sdarrenr# endif
572145522Sdarrenr
573145522Sdarrenr# ifndef	GET_MINOR
574183397Sed#  define	GET_MINOR(x)	dev2unit(x)
575145522Sdarrenr# endif
576145522Sdarrenr# define	PANIC(x,y)	if (x) panic y
577145522Sdarrenr#endif /* _KERNEL */
578145522Sdarrenr
579172776Sdarrenr#if !defined(IFNAME) && !defined(_KERNEL)
580255332Scy# define	IFNAME(x)	get_ifname((struct ifnet *)x)
581145522Sdarrenr#endif
582145522Sdarrenr#ifndef	COPYIFNAME
583145522Sdarrenr# define	NEED_FRGETIFNAME
584369245Sgit2svnextern	char	*ipf_getifname(struct ifnet *, char *);
585172776Sdarrenr# define	COPYIFNAME(v, x, b) \
586255332Scy				ipf_getifname((struct ifnet *)x, b)
587145522Sdarrenr#endif
588145522Sdarrenr
589145522Sdarrenr#ifndef ASSERT
590172776Sdarrenr# ifdef _KERNEL
591172776Sdarrenr#  define	ASSERT(x)
592172776Sdarrenr# else
593172776Sdarrenr#  define	ASSERT(x)	do { if (!(x)) abort(); } while (0)
594172776Sdarrenr# endif
595145522Sdarrenr#endif
596145522Sdarrenr
597170268Sdarrenr#ifndef BCOPYIN
598170268Sdarrenr#  define	BCOPYIN(a,b,c)	(bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
599170268Sdarrenr#  define	BCOPYOUT(a,b,c)	(bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
600170268Sdarrenr#endif
601170268Sdarrenr
60253642Sguido/*
603145522Sdarrenr * Because the ctype(3) posix definition, if used "safely" in code everywhere,
604145522Sdarrenr * would mean all normal code that walks through strings needed casts.  Yuck.
605145522Sdarrenr */
606145522Sdarrenr#define	ISALNUM(x)	isalnum((u_char)(x))
607145522Sdarrenr#define	ISALPHA(x)	isalpha((u_char)(x))
608145522Sdarrenr#define	ISDIGIT(x)	isdigit((u_char)(x))
609145522Sdarrenr#define	ISSPACE(x)	isspace((u_char)(x))
610145522Sdarrenr#define	ISUPPER(x)	isupper((u_char)(x))
611145522Sdarrenr#define	ISXDIGIT(x)	isxdigit((u_char)(x))
612145522Sdarrenr#define	ISLOWER(x)	islower((u_char)(x))
613145522Sdarrenr#define	TOUPPER(x)	toupper((u_char)(x))
614145522Sdarrenr#define	TOLOWER(x)	tolower((u_char)(x))
615145522Sdarrenr
616145522Sdarrenr/*
617145522Sdarrenr * If mutexes aren't being used, turn all the mutex functions into null-ops.
618145522Sdarrenr */
619145522Sdarrenr#if !defined(USE_MUTEXES)
620145522Sdarrenr# define	USE_SPL			1
621145522Sdarrenr# undef		RW_DESTROY
622145522Sdarrenr# undef		MUTEX_INIT
623145522Sdarrenr# undef		MUTEX_NUKE
624145522Sdarrenr# undef		MUTEX_DESTROY
625145522Sdarrenr# define	MUTEX_ENTER(x)		;
626145522Sdarrenr# define	READ_ENTER(x)		;
627145522Sdarrenr# define	WRITE_ENTER(x)		;
628145522Sdarrenr# define	MUTEX_DOWNGRADE(x)	;
629314251Scy# define	MUTEX_TRY_UPGRADE(x)	;
630145522Sdarrenr# define	RWLOCK_INIT(x, y)	;
631145522Sdarrenr# define	RWLOCK_EXIT(x)		;
632145522Sdarrenr# define	RW_DESTROY(x)		;
633145522Sdarrenr# define	MUTEX_EXIT(x)		;
634145522Sdarrenr# define	MUTEX_INIT(x,y)		;
635145522Sdarrenr# define	MUTEX_DESTROY(x)	;
636145522Sdarrenr# define	MUTEX_NUKE(x)		;
637145522Sdarrenr#endif /* !USE_MUTEXES */
638145522Sdarrenr#ifndef	ATOMIC_INC
639145522Sdarrenr# define	ATOMIC_INC(x)		(x)++
640145522Sdarrenr# define	ATOMIC_DEC(x)		(x)--
641145522Sdarrenr#endif
642145522Sdarrenr
643153876Sguido#if defined(USE_SPL) && defined(_KERNEL)
644153876Sguido# define	SPL_INT(x)	int x
645153876Sguido#else
646153876Sguido# define	SPL_INT(x)
647153876Sguido#endif
648153876Sguido
649145522Sdarrenr/*
650145522Sdarrenr * If there are no atomic operations for bit sizes defined, define them to all
651145522Sdarrenr * use a generic one that works for all sizes.
652145522Sdarrenr */
653145522Sdarrenr#ifndef	ATOMIC_INCL
654145522Sdarrenr# define	ATOMIC_INCL		ATOMIC_INC
655145522Sdarrenr# define	ATOMIC_INC64		ATOMIC_INC
656145522Sdarrenr# define	ATOMIC_INC32		ATOMIC_INC
657145522Sdarrenr# define	ATOMIC_DECL		ATOMIC_DEC
658145522Sdarrenr# define	ATOMIC_DEC64		ATOMIC_DEC
659145522Sdarrenr# define	ATOMIC_DEC32		ATOMIC_DEC
660145522Sdarrenr#endif
661145522Sdarrenr
662145522Sdarrenr#ifndef HDR_T_PRIVATE
663145522Sdarrenrtypedef	struct	tcphdr	tcphdr_t;
664145522Sdarrenrtypedef	struct	udphdr	udphdr_t;
665145522Sdarrenr#endif
666145522Sdarrenrtypedef	struct	icmp	icmphdr_t;
667145522Sdarrenrtypedef	struct	ip	ip_t;
668145522Sdarrenrtypedef	struct	ether_header	ether_header_t;
669145522Sdarrenrtypedef	struct	tcpiphdr	tcpiphdr_t;
670145522Sdarrenr
671145522Sdarrenr#ifndef	FR_GROUPLEN
672145522Sdarrenr# define	FR_GROUPLEN	16
673145522Sdarrenr#endif
674145522Sdarrenr
675145522Sdarrenr#ifndef offsetof
676255332Scy# define offsetof(t,m) (size_t)((&((t *)0L)->m))
677145522Sdarrenr#endif
678255332Scy#ifndef stsizeof
679255332Scy# define stsizeof(t,m)	sizeof(((t *)0L)->m)
680255332Scy#endif
681145522Sdarrenr
682145522Sdarrenr/*
683145522Sdarrenr * This set of macros has been brought about because on Tru64 it is not
684145522Sdarrenr * possible to easily assign or examine values in a structure that are
685145522Sdarrenr * bit fields.
686145522Sdarrenr */
687145522Sdarrenr#ifndef IP_V
688145522Sdarrenr# define	IP_V(x)		(x)->ip_v
689145522Sdarrenr#endif
690145522Sdarrenr#ifndef	IP_V_A
691145522Sdarrenr# define	IP_V_A(x,y)	(x)->ip_v = (y)
692145522Sdarrenr#endif
693145522Sdarrenr#ifndef	IP_HL
694145522Sdarrenr# define	IP_HL(x)	(x)->ip_hl
695145522Sdarrenr#endif
696145522Sdarrenr#ifndef	IP_HL_A
697170268Sdarrenr# define	IP_HL_A(x,y)	(x)->ip_hl = ((y) & 0xf)
698145522Sdarrenr#endif
699145522Sdarrenr#ifndef	TCP_X2
700145522Sdarrenr# define	TCP_X2(x)	(x)->th_x2
701145522Sdarrenr#endif
702145522Sdarrenr#ifndef	TCP_X2_A
703145522Sdarrenr# define	TCP_X2_A(x,y)	(x)->th_x2 = (y)
704145522Sdarrenr#endif
705145522Sdarrenr#ifndef	TCP_OFF
706145522Sdarrenr# define	TCP_OFF(x)	(x)->th_off
707145522Sdarrenr#endif
708145522Sdarrenr#ifndef	TCP_OFF_A
709145522Sdarrenr# define	TCP_OFF_A(x,y)	(x)->th_off = (y)
710145522Sdarrenr#endif
711145522Sdarrenr#define	IPMINLEN(i, h)	((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h)))
712145522Sdarrenr
713145522Sdarrenr#define	TCPF_ALL	(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\
714145522Sdarrenr			 TH_ECN|TH_CWR)
715145522Sdarrenr
716358666Scy#if !SOLARIS && !defined(m_act)
717145522Sdarrenr# define	m_act	m_nextpkt
718255332Scy#endif
719145522Sdarrenr
720145522Sdarrenr/*
72153642Sguido * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108.
72253642Sguido *
72353642Sguido * Basic Option
72453642Sguido *
72553642Sguido * 00000001   -   (Reserved 4)
72653642Sguido * 00111101   -   Top Secret
72753642Sguido * 01011010   -   Secret
72853642Sguido * 10010110   -   Confidential
72953642Sguido * 01100110   -   (Reserved 3)
73053642Sguido * 11001100   -   (Reserved 2)
73153642Sguido * 10101011   -   Unclassified
73253642Sguido * 11110001   -   (Reserved 1)
73353642Sguido */
73453642Sguido#define	IPSO_CLASS_RES4		0x01
73553642Sguido#define	IPSO_CLASS_TOPS		0x3d
73653642Sguido#define	IPSO_CLASS_SECR		0x5a
73753642Sguido#define	IPSO_CLASS_CONF		0x96
73853642Sguido#define	IPSO_CLASS_RES3		0x66
73953642Sguido#define	IPSO_CLASS_RES2		0xcc
74053642Sguido#define	IPSO_CLASS_UNCL		0xab
74153642Sguido#define	IPSO_CLASS_RES1		0xf1
74253642Sguido
74353642Sguido#define	IPSO_AUTH_GENSER	0x80
74453642Sguido#define	IPSO_AUTH_ESI		0x40
74553642Sguido#define	IPSO_AUTH_SCI		0x20
74653642Sguido#define	IPSO_AUTH_NSA		0x10
74753642Sguido#define	IPSO_AUTH_DOE		0x08
74853642Sguido#define	IPSO_AUTH_UN		0x06
74953642Sguido#define	IPSO_AUTH_FTE		0x01
75053642Sguido
75153642Sguido/*
75253642Sguido * IP option #defines
75353642Sguido */
754145522Sdarrenr#undef	IPOPT_RR
755255332Scy#define	IPOPT_RR	7
756145522Sdarrenr#undef	IPOPT_ZSU
75753642Sguido#define	IPOPT_ZSU	10	/* ZSU */
758145522Sdarrenr#undef	IPOPT_MTUP
75953642Sguido#define	IPOPT_MTUP	11	/* MTUP */
760145522Sdarrenr#undef	IPOPT_MTUR
76153642Sguido#define	IPOPT_MTUR	12	/* MTUR */
762145522Sdarrenr#undef	IPOPT_ENCODE
76353642Sguido#define	IPOPT_ENCODE	15	/* ENCODE */
764145522Sdarrenr#undef	IPOPT_TS
765145522Sdarrenr#define	IPOPT_TS	68
766145522Sdarrenr#undef	IPOPT_TR
76753642Sguido#define	IPOPT_TR	82	/* TR */
768145522Sdarrenr#undef	IPOPT_SECURITY
769145522Sdarrenr#define	IPOPT_SECURITY	130
770145522Sdarrenr#undef	IPOPT_LSRR
771145522Sdarrenr#define	IPOPT_LSRR	131
772145522Sdarrenr#undef	IPOPT_E_SEC
77353642Sguido#define	IPOPT_E_SEC	133	/* E-SEC */
774145522Sdarrenr#undef	IPOPT_CIPSO
77553642Sguido#define	IPOPT_CIPSO	134	/* CIPSO */
776145522Sdarrenr#undef	IPOPT_SATID
777145522Sdarrenr#define	IPOPT_SATID	136
77853642Sguido#ifndef	IPOPT_SID
77953642Sguido# define	IPOPT_SID	IPOPT_SATID
78053642Sguido#endif
781145522Sdarrenr#undef	IPOPT_SSRR
782145522Sdarrenr#define	IPOPT_SSRR	137
783145522Sdarrenr#undef	IPOPT_ADDEXT
78453642Sguido#define	IPOPT_ADDEXT	147	/* ADDEXT */
785145522Sdarrenr#undef	IPOPT_VISA
78653642Sguido#define	IPOPT_VISA	142	/* VISA */
787145522Sdarrenr#undef	IPOPT_IMITD
78853642Sguido#define	IPOPT_IMITD	144	/* IMITD */
789145522Sdarrenr#undef	IPOPT_EIP
79053642Sguido#define	IPOPT_EIP	145	/* EIP */
791145522Sdarrenr#undef	IPOPT_RTRALRT
792145522Sdarrenr#define	IPOPT_RTRALRT	148	/* RTRALRT */
793145522Sdarrenr#undef	IPOPT_SDB
794145522Sdarrenr#define	IPOPT_SDB	149
795145522Sdarrenr#undef	IPOPT_NSAPA
796145522Sdarrenr#define	IPOPT_NSAPA	150
797145522Sdarrenr#undef	IPOPT_DPS
798145522Sdarrenr#define	IPOPT_DPS	151
799145522Sdarrenr#undef	IPOPT_UMP
800145522Sdarrenr#define	IPOPT_UMP	152
801145522Sdarrenr#undef	IPOPT_FINN
80253642Sguido#define	IPOPT_FINN	205	/* FINN */
803255332Scy#undef	IPOPT_AH
804255332Scy#define	IPOPT_AH	256+IPPROTO_AH
80553642Sguido
806369246Scy#define	ICMP_UNREACH_ADMIN_PROHIBIT	ICMP_UNREACH_FILTER_PROHIB
807369246Scy#define	ICMP_UNREACH_FILTER	ICMP_UNREACH_FILTER_PROHIB
808349653Scy
80953642Sguido#ifndef	IPVERSION
81053642Sguido# define	IPVERSION	4
81153642Sguido#endif
81253642Sguido#ifndef	IPOPT_MINOFF
81353642Sguido# define	IPOPT_MINOFF	4
81453642Sguido#endif
81553642Sguido#ifndef	IPOPT_COPIED
81653642Sguido# define	IPOPT_COPIED(x)	((x)&0x80)
81753642Sguido#endif
81853642Sguido#ifndef	IPOPT_EOL
81953642Sguido# define	IPOPT_EOL	0
82053642Sguido#endif
82153642Sguido#ifndef	IPOPT_NOP
82253642Sguido# define	IPOPT_NOP	1
82353642Sguido#endif
82453642Sguido#ifndef	IP_MF
82553642Sguido# define	IP_MF	((u_short)0x2000)
82653642Sguido#endif
82753642Sguido#ifndef	ETHERTYPE_IP
82853642Sguido# define	ETHERTYPE_IP	((u_short)0x0800)
82953642Sguido#endif
83053642Sguido#ifndef	TH_FIN
83153642Sguido# define	TH_FIN	0x01
83253642Sguido#endif
83353642Sguido#ifndef	TH_SYN
83453642Sguido# define	TH_SYN	0x02
83553642Sguido#endif
83653642Sguido#ifndef	TH_RST
83753642Sguido# define	TH_RST	0x04
83853642Sguido#endif
83953642Sguido#ifndef	TH_PUSH
84053642Sguido# define	TH_PUSH	0x08
84153642Sguido#endif
84253642Sguido#ifndef	TH_ACK
84353642Sguido# define	TH_ACK	0x10
84453642Sguido#endif
84553642Sguido#ifndef	TH_URG
84653642Sguido# define	TH_URG	0x20
84753642Sguido#endif
848145522Sdarrenr#undef	TH_ACKMASK
849145522Sdarrenr#define	TH_ACKMASK	(TH_FIN|TH_SYN|TH_RST|TH_ACK)
850145522Sdarrenr
85153642Sguido#ifndef	IPOPT_EOL
85253642Sguido# define	IPOPT_EOL	0
85353642Sguido#endif
85453642Sguido#ifndef	IPOPT_NOP
85553642Sguido# define	IPOPT_NOP	1
85653642Sguido#endif
85753642Sguido#ifndef	IPOPT_RR
85853642Sguido# define	IPOPT_RR	7
85953642Sguido#endif
86053642Sguido#ifndef	IPOPT_TS
86153642Sguido# define	IPOPT_TS	68
86253642Sguido#endif
86353642Sguido#ifndef	IPOPT_SECURITY
86453642Sguido# define	IPOPT_SECURITY	130
86553642Sguido#endif
86653642Sguido#ifndef	IPOPT_LSRR
86753642Sguido# define	IPOPT_LSRR	131
86853642Sguido#endif
86953642Sguido#ifndef	IPOPT_SATID
87053642Sguido# define	IPOPT_SATID	136
87153642Sguido#endif
87253642Sguido#ifndef	IPOPT_SSRR
87353642Sguido# define	IPOPT_SSRR	137
87453642Sguido#endif
87553642Sguido#ifndef	IPOPT_SECUR_UNCLASS
87653642Sguido# define	IPOPT_SECUR_UNCLASS	((u_short)0x0000)
87753642Sguido#endif
87853642Sguido#ifndef	IPOPT_SECUR_CONFID
87953642Sguido# define	IPOPT_SECUR_CONFID	((u_short)0xf135)
88053642Sguido#endif
88153642Sguido#ifndef	IPOPT_SECUR_EFTO
88253642Sguido# define	IPOPT_SECUR_EFTO	((u_short)0x789a)
88353642Sguido#endif
88453642Sguido#ifndef	IPOPT_SECUR_MMMM
88553642Sguido# define	IPOPT_SECUR_MMMM	((u_short)0xbc4d)
88653642Sguido#endif
88753642Sguido#ifndef	IPOPT_SECUR_RESTR
88853642Sguido# define	IPOPT_SECUR_RESTR	((u_short)0xaf13)
88953642Sguido#endif
89053642Sguido#ifndef	IPOPT_SECUR_SECRET
89153642Sguido# define	IPOPT_SECUR_SECRET	((u_short)0xd788)
89253642Sguido#endif
89353642Sguido#ifndef IPOPT_SECUR_TOPSECRET
89453642Sguido# define	IPOPT_SECUR_TOPSECRET	((u_short)0x6bc5)
89553642Sguido#endif
89653642Sguido#ifndef IPOPT_OLEN
89753642Sguido# define	IPOPT_OLEN	1
89853642Sguido#endif
899145522Sdarrenr#ifndef	IPPROTO_HOPOPTS
900145522Sdarrenr# define	IPPROTO_HOPOPTS	0
901145522Sdarrenr#endif
902255332Scy#ifndef	IPPROTO_IPIP
903255332Scy# define	IPPROTO_IPIP	4
904255332Scy#endif
905145522Sdarrenr#ifndef	IPPROTO_ENCAP
906255332Scy# define	IPPROTO_ENCAP	98
907145522Sdarrenr#endif
908145522Sdarrenr#ifndef	IPPROTO_IPV6
909145522Sdarrenr# define	IPPROTO_IPV6	41
910145522Sdarrenr#endif
911145522Sdarrenr#ifndef	IPPROTO_ROUTING
912145522Sdarrenr# define	IPPROTO_ROUTING	43
913145522Sdarrenr#endif
914145522Sdarrenr#ifndef	IPPROTO_FRAGMENT
915145522Sdarrenr# define	IPPROTO_FRAGMENT	44
916145522Sdarrenr#endif
91792685Sdarrenr#ifndef	IPPROTO_GRE
91892685Sdarrenr# define	IPPROTO_GRE	47	/* GRE encaps RFC 1701 */
91992685Sdarrenr#endif
92092685Sdarrenr#ifndef	IPPROTO_ESP
92192685Sdarrenr# define	IPPROTO_ESP	50
92292685Sdarrenr#endif
923145522Sdarrenr#ifndef	IPPROTO_AH
924145522Sdarrenr# define	IPPROTO_AH	51
925145522Sdarrenr#endif
92692685Sdarrenr#ifndef	IPPROTO_ICMPV6
92792685Sdarrenr# define	IPPROTO_ICMPV6	58
92892685Sdarrenr#endif
929145522Sdarrenr#ifndef	IPPROTO_NONE
930145522Sdarrenr# define	IPPROTO_NONE	59
93153642Sguido#endif
932145522Sdarrenr#ifndef	IPPROTO_DSTOPTS
933145522Sdarrenr# define	IPPROTO_DSTOPTS	60
93453642Sguido#endif
935153876Sguido#ifndef	IPPROTO_MOBILITY
936153876Sguido# define	IPPROTO_MOBILITY	135
93753642Sguido#endif
938153876Sguido
93953642Sguido#ifndef	ICMP_ROUTERADVERT
94053642Sguido# define	ICMP_ROUTERADVERT	9
94153642Sguido#endif
94253642Sguido#ifndef	ICMP_ROUTERSOLICIT
94353642Sguido# define	ICMP_ROUTERSOLICIT	10
94453642Sguido#endif
94592685Sdarrenr#ifndef	ICMP6_DST_UNREACH
94692685Sdarrenr# define	ICMP6_DST_UNREACH	1
94792685Sdarrenr#endif
94892685Sdarrenr#ifndef	ICMP6_PACKET_TOO_BIG
94992685Sdarrenr# define	ICMP6_PACKET_TOO_BIG	2
95092685Sdarrenr#endif
95192685Sdarrenr#ifndef	ICMP6_TIME_EXCEEDED
95292685Sdarrenr# define	ICMP6_TIME_EXCEEDED	3
95392685Sdarrenr#endif
95492685Sdarrenr#ifndef	ICMP6_PARAM_PROB
95592685Sdarrenr# define	ICMP6_PARAM_PROB	4
95692685Sdarrenr#endif
95792685Sdarrenr
95892685Sdarrenr#ifndef	ICMP6_ECHO_REQUEST
95992685Sdarrenr# define	ICMP6_ECHO_REQUEST	128
96092685Sdarrenr#endif
96192685Sdarrenr#ifndef	ICMP6_ECHO_REPLY
96292685Sdarrenr# define	ICMP6_ECHO_REPLY	129
96392685Sdarrenr#endif
96492685Sdarrenr#ifndef	ICMP6_MEMBERSHIP_QUERY
96592685Sdarrenr# define	ICMP6_MEMBERSHIP_QUERY	130
96692685Sdarrenr#endif
96792685Sdarrenr#ifndef	MLD6_LISTENER_QUERY
96892685Sdarrenr# define	MLD6_LISTENER_QUERY	130
96992685Sdarrenr#endif
97092685Sdarrenr#ifndef	ICMP6_MEMBERSHIP_REPORT
97192685Sdarrenr# define	ICMP6_MEMBERSHIP_REPORT	131
97292685Sdarrenr#endif
97392685Sdarrenr#ifndef	MLD6_LISTENER_REPORT
97492685Sdarrenr# define	MLD6_LISTENER_REPORT	131
97592685Sdarrenr#endif
97692685Sdarrenr#ifndef	ICMP6_MEMBERSHIP_REDUCTION
97792685Sdarrenr# define	ICMP6_MEMBERSHIP_REDUCTION	132
97892685Sdarrenr#endif
97992685Sdarrenr#ifndef	MLD6_LISTENER_DONE
98092685Sdarrenr# define	MLD6_LISTENER_DONE	132
98192685Sdarrenr#endif
98292685Sdarrenr#ifndef	ND_ROUTER_SOLICIT
98392685Sdarrenr# define	ND_ROUTER_SOLICIT	133
98492685Sdarrenr#endif
98592685Sdarrenr#ifndef	ND_ROUTER_ADVERT
98692685Sdarrenr# define	ND_ROUTER_ADVERT	134
98792685Sdarrenr#endif
98892685Sdarrenr#ifndef	ND_NEIGHBOR_SOLICIT
98992685Sdarrenr# define	ND_NEIGHBOR_SOLICIT	135
99092685Sdarrenr#endif
99192685Sdarrenr#ifndef	ND_NEIGHBOR_ADVERT
99292685Sdarrenr# define	ND_NEIGHBOR_ADVERT	136
99392685Sdarrenr#endif
99492685Sdarrenr#ifndef	ND_REDIRECT
99592685Sdarrenr# define	ND_REDIRECT	137
99692685Sdarrenr#endif
99792685Sdarrenr#ifndef	ICMP6_ROUTER_RENUMBERING
99892685Sdarrenr# define	ICMP6_ROUTER_RENUMBERING	138
99992685Sdarrenr#endif
100092685Sdarrenr#ifndef	ICMP6_WRUREQUEST
100192685Sdarrenr# define	ICMP6_WRUREQUEST	139
100292685Sdarrenr#endif
100392685Sdarrenr#ifndef	ICMP6_WRUREPLY
100492685Sdarrenr# define	ICMP6_WRUREPLY		140
100592685Sdarrenr#endif
100692685Sdarrenr#ifndef	ICMP6_FQDN_QUERY
100792685Sdarrenr# define	ICMP6_FQDN_QUERY	139
100892685Sdarrenr#endif
100992685Sdarrenr#ifndef	ICMP6_FQDN_REPLY
101092685Sdarrenr# define	ICMP6_FQDN_REPLY	140
101192685Sdarrenr#endif
101292685Sdarrenr#ifndef	ICMP6_NI_QUERY
101392685Sdarrenr# define	ICMP6_NI_QUERY		139
101492685Sdarrenr#endif
101592685Sdarrenr#ifndef	ICMP6_NI_REPLY
101692685Sdarrenr# define	ICMP6_NI_REPLY		140
101792685Sdarrenr#endif
101892685Sdarrenr#ifndef	MLD6_MTRACE_RESP
101992685Sdarrenr# define	MLD6_MTRACE_RESP	200
102092685Sdarrenr#endif
102192685Sdarrenr#ifndef	MLD6_MTRACE
102292685Sdarrenr# define	MLD6_MTRACE		201
102392685Sdarrenr#endif
102492685Sdarrenr#ifndef	ICMP6_HADISCOV_REQUEST
102592685Sdarrenr# define	ICMP6_HADISCOV_REQUEST	202
102692685Sdarrenr#endif
102792685Sdarrenr#ifndef	ICMP6_HADISCOV_REPLY
102892685Sdarrenr# define	ICMP6_HADISCOV_REPLY	203
102992685Sdarrenr#endif
103092685Sdarrenr#ifndef	ICMP6_MOBILEPREFIX_SOLICIT
103192685Sdarrenr# define	ICMP6_MOBILEPREFIX_SOLICIT	204
103292685Sdarrenr#endif
103392685Sdarrenr#ifndef	ICMP6_MOBILEPREFIX_ADVERT
103492685Sdarrenr# define	ICMP6_MOBILEPREFIX_ADVERT	205
103592685Sdarrenr#endif
103692685Sdarrenr#ifndef	ICMP6_MAXTYPE
103792685Sdarrenr# define	ICMP6_MAXTYPE		205
103892685Sdarrenr#endif
103992685Sdarrenr
104092685Sdarrenr#ifndef	ICMP6_DST_UNREACH_NOROUTE
104192685Sdarrenr# define	ICMP6_DST_UNREACH_NOROUTE	0
104292685Sdarrenr#endif
104392685Sdarrenr#ifndef	ICMP6_DST_UNREACH_ADMIN
104492685Sdarrenr# define	ICMP6_DST_UNREACH_ADMIN		1
104592685Sdarrenr#endif
104692685Sdarrenr#ifndef	ICMP6_DST_UNREACH_NOTNEIGHBOR
104792685Sdarrenr# define	ICMP6_DST_UNREACH_NOTNEIGHBOR	2
104892685Sdarrenr#endif
104992685Sdarrenr#ifndef	ICMP6_DST_UNREACH_BEYONDSCOPE
105092685Sdarrenr# define	ICMP6_DST_UNREACH_BEYONDSCOPE	2
105192685Sdarrenr#endif
105292685Sdarrenr#ifndef	ICMP6_DST_UNREACH_ADDR
105392685Sdarrenr# define	ICMP6_DST_UNREACH_ADDR		3
105492685Sdarrenr#endif
105592685Sdarrenr#ifndef	ICMP6_DST_UNREACH_NOPORT
105692685Sdarrenr# define	ICMP6_DST_UNREACH_NOPORT	4
105792685Sdarrenr#endif
105892685Sdarrenr#ifndef	ICMP6_TIME_EXCEED_TRANSIT
105992685Sdarrenr# define	ICMP6_TIME_EXCEED_TRANSIT	0
106092685Sdarrenr#endif
106192685Sdarrenr#ifndef	ICMP6_TIME_EXCEED_REASSEMBLY
106292685Sdarrenr# define	ICMP6_TIME_EXCEED_REASSEMBLY	1
106392685Sdarrenr#endif
106492685Sdarrenr
106592685Sdarrenr#ifndef	ICMP6_NI_SUCCESS
106692685Sdarrenr# define	ICMP6_NI_SUCCESS	0
106792685Sdarrenr#endif
106892685Sdarrenr#ifndef	ICMP6_NI_REFUSED
106992685Sdarrenr# define	ICMP6_NI_REFUSED	1
107092685Sdarrenr#endif
107192685Sdarrenr#ifndef	ICMP6_NI_UNKNOWN
107292685Sdarrenr# define	ICMP6_NI_UNKNOWN	2
107392685Sdarrenr#endif
107492685Sdarrenr
107592685Sdarrenr#ifndef	ICMP6_ROUTER_RENUMBERING_COMMAND
107692685Sdarrenr# define	ICMP6_ROUTER_RENUMBERING_COMMAND	0
107792685Sdarrenr#endif
107892685Sdarrenr#ifndef	ICMP6_ROUTER_RENUMBERING_RESULT
107992685Sdarrenr# define	ICMP6_ROUTER_RENUMBERING_RESULT	1
108092685Sdarrenr#endif
108192685Sdarrenr#ifndef	ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
108292685Sdarrenr# define	ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET	255
108392685Sdarrenr#endif
108492685Sdarrenr
108592685Sdarrenr#ifndef	ICMP6_PARAMPROB_HEADER
108692685Sdarrenr# define	ICMP6_PARAMPROB_HEADER	0
108792685Sdarrenr#endif
108892685Sdarrenr#ifndef	ICMP6_PARAMPROB_NEXTHEADER
108992685Sdarrenr# define	ICMP6_PARAMPROB_NEXTHEADER	1
109092685Sdarrenr#endif
109192685Sdarrenr#ifndef	ICMP6_PARAMPROB_OPTION
109292685Sdarrenr# define	ICMP6_PARAMPROB_OPTION	2
109392685Sdarrenr#endif
109492685Sdarrenr
109592685Sdarrenr#ifndef	ICMP6_NI_SUBJ_IPV6
109692685Sdarrenr# define	ICMP6_NI_SUBJ_IPV6	0
109792685Sdarrenr#endif
109892685Sdarrenr#ifndef	ICMP6_NI_SUBJ_FQDN
109992685Sdarrenr# define	ICMP6_NI_SUBJ_FQDN	1
110092685Sdarrenr#endif
110192685Sdarrenr#ifndef	ICMP6_NI_SUBJ_IPV4
110292685Sdarrenr# define	ICMP6_NI_SUBJ_IPV4	2
110392685Sdarrenr#endif
110492685Sdarrenr
1105255332Scy#ifndef	MLD_MTRACE_RESP
1106255332Scy# define	MLD_MTRACE_RESP		200
1107255332Scy#endif
1108255332Scy#ifndef	MLD_MTRACE
1109255332Scy# define	MLD_MTRACE		201
1110255332Scy#endif
1111255332Scy#ifndef	MLD6_MTRACE_RESP
1112255332Scy# define	MLD6_MTRACE_RESP	MLD_MTRACE_RESP
1113255332Scy#endif
1114255332Scy#ifndef	MLD6_MTRACE
1115255332Scy# define	MLD6_MTRACE		MLD_MTRACE
1116255332Scy#endif
1117255332Scy
1118255332Scy#if !defined(IPV6_FLOWINFO_MASK)
1119255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN)
1120255332Scy#  define IPV6_FLOWINFO_MASK	0x0fffffff	/* flow info (28 bits) */
1121255332Scy# else
1122255332Scy#  if(BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN)
1123255332Scy#   define IPV6_FLOWINFO_MASK	0xffffff0f	/* flow info (28 bits) */
1124255332Scy#  endif /* LITTLE_ENDIAN */
1125255332Scy# endif
1126255332Scy#endif
1127255332Scy#if !defined(IPV6_FLOWLABEL_MASK)
1128255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN)
1129255332Scy#  define IPV6_FLOWLABEL_MASK	0x000fffff	/* flow label (20 bits) */
1130255332Scy# else
1131255332Scy#  if (BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN)
1132255332Scy#   define IPV6_FLOWLABEL_MASK	0xffff0f00	/* flow label (20 bits) */
1133255332Scy#  endif /* LITTLE_ENDIAN */
1134255332Scy# endif
1135255332Scy#endif
1136255332Scy
113772006Sdarrenr/*
113872006Sdarrenr * ECN is a new addition to TCP - RFC 2481
113972006Sdarrenr */
114072006Sdarrenr#ifndef TH_ECN
114172006Sdarrenr# define	TH_ECN	0x40
114272006Sdarrenr#endif
114372006Sdarrenr#ifndef TH_CWR
114472006Sdarrenr# define	TH_CWR	0x80
114572006Sdarrenr#endif
114672006Sdarrenr#define	TH_ECNALL	(TH_ECN|TH_CWR)
114772006Sdarrenr
1148145522Sdarrenr/*
1149145522Sdarrenr * TCP States
1150145522Sdarrenr */
1151170268Sdarrenr#define IPF_TCPS_LISTEN		0	/* listening for connection */
1152170268Sdarrenr#define IPF_TCPS_SYN_SENT	1	/* active, have sent syn */
1153170268Sdarrenr#define IPF_TCPS_SYN_RECEIVED	2	/* have send and received syn */
1154170268Sdarrenr#define IPF_TCPS_HALF_ESTAB	3	/* for connections not fully "up" */
1155145522Sdarrenr/* states < IPF_TCPS_ESTABLISHED are those where connections not established */
1156170268Sdarrenr#define IPF_TCPS_ESTABLISHED	4	/* established */
1157170268Sdarrenr#define IPF_TCPS_CLOSE_WAIT	5	/* rcvd fin, waiting for close */
1158145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */
1159170268Sdarrenr#define IPF_TCPS_FIN_WAIT_1	6	/* have closed, sent fin */
1160170268Sdarrenr#define IPF_TCPS_CLOSING	7	/* closed xchd FIN; await FIN ACK */
1161170268Sdarrenr#define IPF_TCPS_LAST_ACK	8	/* had fin and close; await FIN ACK */
1162145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */
1163170268Sdarrenr#define IPF_TCPS_FIN_WAIT_2	9	/* have closed, fin is acked */
1164170268Sdarrenr#define IPF_TCPS_TIME_WAIT	10	/* in 2*msl quiet wait after close */
1165170268Sdarrenr#define IPF_TCPS_CLOSED		11	/* closed */
1166145522Sdarrenr#define IPF_TCP_NSTATES		12
116772006Sdarrenr
1168145522Sdarrenr#define	TCP_MSL			120
1169145522Sdarrenr
1170145522Sdarrenr#undef	ICMP_MAX_UNREACH
1171145522Sdarrenr#define	ICMP_MAX_UNREACH	14
1172145522Sdarrenr#undef	ICMP_MAXTYPE
1173145522Sdarrenr#define	ICMP_MAXTYPE		18
1174145522Sdarrenr
1175145522Sdarrenr#ifndef	LOG_FTP
1176145522Sdarrenr# define	LOG_FTP		(11<<3)
1177145522Sdarrenr#endif
1178145522Sdarrenr#ifndef	LOG_AUTHPRIV
1179145522Sdarrenr# define	LOG_AUTHPRIV	(10<<3)
1180145522Sdarrenr#endif
1181145522Sdarrenr#ifndef	LOG_AUDIT
1182145522Sdarrenr# define	LOG_AUDIT	(13<<3)
1183145522Sdarrenr#endif
1184145522Sdarrenr#ifndef	LOG_NTP
1185145522Sdarrenr# define	LOG_NTP		(12<<3)
1186145522Sdarrenr#endif
1187145522Sdarrenr#ifndef	LOG_SECURITY
1188145522Sdarrenr# define	LOG_SECURITY	(13<<3)
1189145522Sdarrenr#endif
1190145522Sdarrenr#ifndef	LOG_LFMT
1191145522Sdarrenr# define	LOG_LFMT	(14<<3)
1192145522Sdarrenr#endif
1193145522Sdarrenr#ifndef	LOG_CONSOLE
1194145522Sdarrenr# define	LOG_CONSOLE	(14<<3)
1195145522Sdarrenr#endif
1196145522Sdarrenr
1197145522Sdarrenr/*
1198145522Sdarrenr * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data,
1199145522Sdarrenr * another IP header and then 64 bits of data, totalling 56.  Of course,
1200153876Sguido * the last 64 bits is dependent on that being available.
1201145522Sdarrenr */
1202145522Sdarrenr#define	ICMPERR_ICMPHLEN	8
1203145522Sdarrenr#define	ICMPERR_IPICMPHLEN	(20 + 8)
1204145522Sdarrenr#define	ICMPERR_MINPKTLEN	(20 + 8 + 20)
1205145522Sdarrenr#define	ICMPERR_MAXPKTLEN	(20 + 8 + 20 + 8)
1206145522Sdarrenr#define ICMP6ERR_MINPKTLEN	(40 + 8)
1207145522Sdarrenr#define ICMP6ERR_IPICMPHLEN	(40 + 8 + 40)
1208145522Sdarrenr
1209145522Sdarrenr#ifndef MIN
1210145522Sdarrenr# define	MIN(a,b)	(((a)<(b))?(a):(b))
1211145522Sdarrenr#endif
1212145522Sdarrenr
1213255332Scy#ifdef RESCUE
1214255332Scy# undef IPFILTER_BPF
1215255332Scy#endif
1216255332Scy
1217145522Sdarrenr#ifdef IPF_DEBUG
1218145522Sdarrenr# define	DPRINT(x)	printf x
1219145522Sdarrenr#else
1220145522Sdarrenr# define	DPRINT(x)
1221145522Sdarrenr#endif
1222145522Sdarrenr
1223255332Scy#ifdef DTRACE_PROBE
1224255332Scy# ifdef _KERNEL
1225255332Scy#  define	DT(_n)			DTRACE_PROBE(_n)
1226255332Scy#  define	DT1(_n,_a,_b)		DTRACE_PROBE1(_n,_a,_b)
1227255332Scy#  define	DT2(_n,_a,_b,_c,_d)	DTRACE_PROBE2(_n,_a,_b,_c,_d)
1228255332Scy#  define	DT3(_n,_a,_b,_c,_d,_e,_f)	\
1229255332Scy					DTRACE_PROBE3(_n,_a,_b,_c,_d,_e,_f)
1230255332Scy#  define	DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) \
1231255332Scy				DTRACE_PROBE4(_n,_a,_b,_c,_d,_e,_f,_g,_h)
1232255332Scy# else
1233255332Scy#  define	DT(_n)
1234255332Scy#  define	DT1(_n,_a,_b)
1235255332Scy#  define	DT2(_n,_a,_b,_c,_d)
1236255332Scy#  define	DT3(_n,_a,_b,_c,_d,_e,_f)
1237255332Scy#  define	DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h)
1238255332Scy# endif
1239255332Scy#else
1240255332Scy# define	DT(_n)
1241255332Scy# define	DT1(_n,_a,_b)
1242255332Scy# define	DT2(_n,_a,_b,_c,_d)
1243255332Scy# define	DT3(_n,_a,_b,_c,_d,_e,_f)
1244255332Scy# define	DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h)
1245255332Scy#endif
1246255332Scy
1247255332Scystruct ip6_routing {
1248255332Scy	u_char	ip6r_nxt;	/* next header */
1249255332Scy	u_char	ip6r_len;	/* length in units of 8 octets */
1250255332Scy	u_char	ip6r_type;	/* always zero */
1251255332Scy	u_char	ip6r_segleft;	/* segments left */
1252255332Scy	u_32_t	ip6r_reserved;	/* reserved field */
1253255332Scy};
1254255332Scy
125553642Sguido#endif	/* __IP_COMPAT_H__ */
1256