1/*	$NetBSD: ip_fil.h,v 1.19 2010/04/17 21:00:44 darrenr Exp $	*/
2
3/*
4 * Copyright (C) 1993-2001, 2003 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 *
8 * @(#)ip_fil.h	1.35 6/5/96
9 * Id: ip_fil.h,v 2.170.2.63 2010/01/31 16:22:55 darrenr Exp
10 */
11
12#ifndef _NETINET_IP_FIL_H_
13#define _NETINET_IP_FIL_H_
14
15#include "netinet/ip_compat.h"
16
17#ifndef	SOLARIS
18# define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
19#endif
20
21#if defined(__STDC__) || defined(__GNUC__) || defined(_AIX51)
22# define	SIOCADAFR	_IOW('r', 60, struct ipfobj)
23# define	SIOCRMAFR	_IOW('r', 61, struct ipfobj)
24# define	SIOCSETFF	_IOW('r', 62, u_int)
25# define	SIOCGETFF	_IOR('r', 63, u_int)
26# define	SIOCGETFS	_IOWR('r', 64, struct ipfobj)
27# define	SIOCIPFFL	_IOWR('r', 65, int)
28# define	SIOCIPFFB	_IOR('r', 66, int)
29# define	SIOCADIFR	_IOW('r', 67, struct ipfobj)
30# define	SIOCRMIFR	_IOW('r', 68, struct ipfobj)
31# define	SIOCSWAPA	_IOR('r', 69, u_int)
32# define	SIOCINAFR	_IOW('r', 70, struct ipfobj)
33# define	SIOCINIFR	_IOW('r', 71, struct ipfobj)
34# define	SIOCFRENB	_IOW('r', 72, u_int)
35# define	SIOCFRSYN	_IOW('r', 73, u_int)
36# define	SIOCFRZST	_IOWR('r', 74, struct ipfobj)
37# define	SIOCZRLST	_IOWR('r', 75, struct ipfobj)
38# define	SIOCAUTHW	_IOWR('r', 76, struct ipfobj)
39# define	SIOCAUTHR	_IOWR('r', 77, struct ipfobj)
40# define	SIOCSTAT1	_IOWR('r', 78, struct ipfobj)
41# define	SIOCSTLCK	_IOWR('r', 79, u_int)
42# define	SIOCSTPUT	_IOWR('r', 80, struct ipfobj)
43# define	SIOCSTGET	_IOWR('r', 81, struct ipfobj)
44# define	SIOCSTGSZ	_IOWR('r', 82, struct ipfobj)
45# define	SIOCSTAT2	_IOWR('r', 83, struct ipfobj)
46# define	SIOCSETLG	_IOWR('r', 84, int)
47# define	SIOCGETLG	_IOWR('r', 85, int)
48# define	SIOCFUNCL	_IOWR('r', 86, struct ipfunc_resolve)
49# define	SIOCIPFGETNEXT	_IOWR('r', 87, struct ipfobj)
50# define	SIOCIPFGET	_IOWR('r', 88, struct ipfobj)
51# define	SIOCIPFSET	_IOWR('r', 89, struct ipfobj)
52# define	SIOCIPFL6	_IOWR('r', 90, int)
53# define	SIOCIPFITER	_IOWR('r', 91, struct ipfobj)
54# define	SIOCGENITER	_IOWR('r', 92, struct ipfobj)
55# define	SIOCGTABL	_IOWR('r', 93, struct ipfobj)
56# define	SIOCIPFDELTOK	_IOWR('r', 94, int)
57# define	SIOCLOOKUPITER	_IOWR('r', 95, struct ipfobj)
58# define	SIOCGTQTAB	_IOWR('r', 96, struct ipfobj)
59#else
60# define	SIOCADAFR	_IOW(r, 60, struct ipfobj)
61# define	SIOCRMAFR	_IOW(r, 61, struct ipfobj)
62# define	SIOCSETFF	_IOW(r, 62, u_int)
63# define	SIOCGETFF	_IOR(r, 63, u_int)
64# define	SIOCGETFS	_IOWR(r, 64, struct ipfobj)
65# define	SIOCIPFFL	_IOWR(r, 65, int)
66# define	SIOCIPFFB	_IOR(r, 66, int)
67# define	SIOCADIFR	_IOW(r, 67, struct ipfobj)
68# define	SIOCRMIFR	_IOW(r, 68, struct ipfobj)
69# define	SIOCSWAPA	_IOR(r, 69, u_int)
70# define	SIOCINAFR	_IOW(r, 70, struct ipfobj)
71# define	SIOCINIFR	_IOW(r, 71, struct ipfobj)
72# define	SIOCFRENB	_IOW(r, 72, u_int)
73# define	SIOCFRSYN	_IOW(r, 73, u_int)
74# define	SIOCFRZST	_IOWR(r, 74, struct ipfobj)
75# define	SIOCZRLST	_IOWR(r, 75, struct ipfobj)
76# define	SIOCAUTHW	_IOWR(r, 76, struct ipfobj)
77# define	SIOCAUTHR	_IOWR(r, 77, struct ipfobj)
78# define	SIOCSTAT1	_IOWR(r, 78, struct ipfobj)
79# define	SIOCSTLCK	_IOWR(r, 79, u_int)
80# define	SIOCSTPUT	_IOWR(r, 80, struct ipfobj)
81# define	SIOCSTGET	_IOWR(r, 81, struct ipfobj)
82# define	SIOCSTGSZ	_IOWR(r, 82, struct ipfobj)
83# define	SIOCSTAT2	_IOWR(r, 83, struct ipfobj)
84# define	SIOCSETLG	_IOWR(r, 84, int)
85# define	SIOCGETLG	_IOWR(r, 85, int)
86# define	SIOCFUNCL	_IOWR(r, 86, struct ipfunc_resolve)
87# define	SIOCIPFGETNEXT	_IOWR(r, 87, struct ipfobj)
88# define	SIOCIPFGET	_IOWR(r, 88, struct ipfobj)
89# define	SIOCIPFSET	_IOWR(r, 89, struct ipfobj)
90# define	SIOCIPFL6	_IOWR(r, 90, int)
91# define	SIOCIPFITER	_IOWR(r, 91, struct ipfobj)
92# define	SIOCGENITER	_IOWR(r, 92, struct ipfobj)
93# define	SIOCGTABL	_IOWR(r, 93, struct ipfobj)
94# define	SIOCIPFDELTOK	_IOWR(r, 94, int)
95# define	SIOCLOOKUPITER	_IOWR(r, 95, struct ipfobj)
96# define	SIOCGTQTAB	_IOWR(r, 96, struct ipfobj)
97#endif
98#define	SIOCADDFR	SIOCADAFR
99#define	SIOCDELFR	SIOCRMAFR
100#define	SIOCINSFR	SIOCINAFR
101#define	SIOCATHST	SIOCSTAT1
102#define	SIOCGFRST	SIOCSTAT2
103
104
105struct ipscan;
106struct ifnet;
107
108
109typedef	int	(* lookupfunc_t)(void *, int, void *);
110
111/*
112 * i6addr is used as a container for both IPv4 and IPv6 addresses, as well
113 * as other types of objects, depending on its qualifier.
114 */
115#ifdef	USE_INET6
116typedef	union	i6addr	{
117	u_32_t	i6[4];
118	struct	in_addr	in4;
119	struct	in6_addr in6;
120	void	*vptr[2];
121	lookupfunc_t	lptr[2];
122	struct {
123		u_short	type;
124		u_short	subtype;
125		char	label[12];
126	} i6un;
127} i6addr_t;
128#else
129typedef	union	i6addr	{
130	u_32_t	i6[4];
131	struct	in_addr	in4;
132	void	*vptr[2];
133	lookupfunc_t	lptr[2];
134	struct {
135		u_short	type;
136		u_short	subtype;
137		char	label[12];
138	} i6un;
139} i6addr_t;
140#endif
141
142#define in4_addr	in4.s_addr
143#define	iplookupnum	i6[1]
144#define	iplookupname	i6un.label
145#define	iplookuptype	i6un.type
146#define	iplookupsubtype	i6un.subtype
147/*
148 * NOTE: These DO overlap the above on 64bit systems and this IS recognised.
149 */
150#define	iplookupptr	vptr[0]
151#define	iplookupfunc	lptr[1]
152
153/* Avoid casting to a type presuming 64-bit alignment. */
154#define	I60(x)	(((u_32_t *)(x))[0])
155#define	I61(x)	(((u_32_t *)(x))[1])
156#define	I62(x)	(((u_32_t *)(x))[2])
157#define	I63(x)	(((u_32_t *)(x))[3])
158#define	HI60(x)	ntohl(((u_32_t *)(x))[0])
159#define	HI61(x)	ntohl(((u_32_t *)(x))[1])
160#define	HI62(x)	ntohl(((u_32_t *)(x))[2])
161#define	HI63(x)	ntohl(((u_32_t *)(x))[3])
162
163#define	IP6_EQ(a,b)	((I63(a) == I63(b)) && (I62(a) == I62(b)) && \
164			 (I61(a) == I61(b)) && (I60(a) == I60(b)))
165#define	IP6_NEQ(a,b)	((I63(a) != I63(b)) || (I62(a) != I62(b)) || \
166			 (I61(a) != I61(b)) || (I60(a) != I60(b)))
167#define IP6_ISZERO(a)   ((I60(a) | I61(a) | I62(a) | I63(a)) == 0)
168#define IP6_NOTZERO(a)  ((I60(a) | I61(a) | I62(a) | I63(a)) != 0)
169#define	IP6_GT(a,b)	(HI60(a) > HI60(b) || (HI60(a) == HI60(b) && \
170			  (HI61(a) > HI61(b) || (HI61(a) == HI61(b) && \
171			    (HI62(a) > HI62(b) || (HI62(a) == HI62(b) && \
172			      HI63(a) > HI63(b)))))))
173#define	IP6_LT(a,b)	(HI60(a) < HI60(b) || (HI60(a) == HI60(b) && \
174			  (HI61(a) < HI61(b) || (HI61(a) == HI61(b) && \
175			    (HI62(a) < HI62(b) || (HI62(a) == HI62(b) && \
176			      HI63(a) < HI63(b)))))))
177#define	NLADD(n,x)	htonl(ntohl(n) + (x))
178#define	IP6_INC(a)	\
179		{ u_32_t *_i6 = (u_32_t *)(a); \
180		  _i6[3] = NLADD(_i6[3], 1); \
181		  if (_i6[3] == 0) { \
182			_i6[2] = NLADD(_i6[2], 1); \
183			if (_i6[2] == 0) { \
184				_i6[1] = NLADD(_i6[1], 1); \
185				if (_i6[1] == 0) { \
186					_i6[0] = NLADD(_i6[0], 1); \
187				} \
188			} \
189		  } \
190		}
191#define	IP6_ADD(a,x,d)	\
192		{ i6addr_t *_s = (i6addr_t *)(a); \
193		  i6addr_t *_d = (i6addr_t *)(d); \
194		  _d->i6[0] = NLADD(_s->i6[0], x); \
195		  if (ntohl(_d->i6[0]) < ntohl(_s->i6[0])) { \
196			_d->i6[1] = NLADD(_d->i6[1], 1); \
197			if (ntohl(_d->i6[1]) < ntohl(_s->i6[1])) { \
198				_d->i6[2] = NLADD(_d->i6[2], 1); \
199				if (ntohl(_d->i6[2]) < ntohl(_s->i6[2])) { \
200					_d->i6[3] = NLADD(_d->i6[3], 1); \
201				} \
202			} \
203		  } \
204		}
205#define	IP6_AND(a,b,d)	{ i6addr_t *_s1 = (i6addr_t *)(a); \
206			  i6addr_t *_s2 = (i6addr_t *)(b); \
207			  i6addr_t *_d = (i6addr_t *)(d); \
208			  _d->i6[0] = _s1->i6[0] & _s2->i6[0]; \
209			  _d->i6[1] = _s1->i6[1] & _s2->i6[1]; \
210			  _d->i6[2] = _s1->i6[2] & _s2->i6[2]; \
211			  _d->i6[3] = _s1->i6[3] & _s2->i6[3]; \
212			}
213#define	IP6_MERGE(a,b,c) \
214			{ i6addr_t *_d, *_s1, *_s2; \
215			  _d = (i6addr_t *)(a); \
216			  _s1 = (i6addr_t *)(b); \
217			  _s2 = (i6addr_t *)(c); \
218			  _d->i6[0] |= _s1->i6[0] & ~_s2->i6[0]; \
219			  _d->i6[1] |= _s1->i6[1] & ~_s2->i6[1]; \
220			  _d->i6[2] |= _s1->i6[2] & ~_s2->i6[2]; \
221			  _d->i6[2] |= _s1->i6[3] & ~_s2->i6[3]; \
222			}
223
224
225typedef	struct	fr_ip	{
226	u_32_t	fi_v:4;		/* IP version */
227	u_32_t	fi_xx:4;	/* spare */
228	u_32_t	fi_tos:8;	/* IP packet TOS */
229	u_32_t	fi_ttl:8;	/* IP packet TTL */
230	u_32_t	fi_p:8;		/* IP packet protocol */
231	u_32_t	fi_optmsk;	/* bitmask composed from IP options */
232	i6addr_t fi_src;	/* source address from packet */
233	i6addr_t fi_dst;	/* destination address from packet */
234	u_short	fi_secmsk;	/* bitmask composed from IP security options */
235	u_short	fi_auth;	/* authentication code from IP sec. options */
236	u_32_t	fi_flx;		/* packet flags */
237	u_32_t	fi_tcpmsk;	/* TCP options set/reset */
238	u_32_t	fi_res1;	/* RESERVED */
239} fr_ip_t;
240
241/*
242 * For use in fi_flx
243 */
244#define	FI_TCPUDP	0x0001	/* TCP/UCP implied comparison*/
245#define	FI_OPTIONS	0x0002
246#define	FI_FRAG		0x0004
247#define	FI_SHORT	0x0008
248#define	FI_NATED	0x0010
249#define	FI_MULTICAST	0x0020
250#define	FI_BROADCAST	0x0040
251#define	FI_MBCAST	0x0080
252#define	FI_STATE	0x0100
253#define	FI_BADNAT	0x0200
254#define	FI_BAD		0x0400
255#define	FI_OOW		0x0800	/* Out of state window, else match */
256#define	FI_ICMPERR	0x1000
257#define	FI_FRAGBODY	0x2000
258#define	FI_BADSRC	0x4000
259#define	FI_LOWTTL	0x8000
260#define	FI_CMP		0xcf03	/* Not FI_FRAG,FI_NATED,FI_FRAGTAIL,broadcast */
261#define	FI_ICMPCMP	0x0003	/* Flags we can check for ICMP error packets */
262#define	FI_WITH		0xeffe	/* Not FI_TCPUDP */
263#define	FI_V6EXTHDR	0x10000
264#define	FI_COALESCE	0x20000
265#define	FI_NEWNAT	0x40000
266#define	FI_MOREFRAG	0x80000
267#define	FI_NOCKSUM	0x20000000	/* don't do a L4 checksum validation */
268#define	FI_DONTCACHE	0x40000000	/* don't cache the result */
269#define	FI_IGNORE	0x80000000
270
271#define	fi_saddr	fi_src.in4.s_addr
272#define	fi_daddr	fi_dst.in4.s_addr
273#define	fi_srcnum	fi_src.iplookupnum
274#define	fi_dstnum	fi_dst.iplookupnum
275#define	fi_srcname	fi_src.iplookupname
276#define	fi_dstname	fi_dst.iplookupname
277#define	fi_srctype	fi_src.iplookuptype
278#define	fi_dsttype	fi_dst.iplookuptype
279#define	fi_srcsubtype	fi_src.iplookupsubtype
280#define	fi_dstsubtype	fi_dst.iplookupsubtype
281#define	fi_srcptr	fi_src.iplookupptr
282#define	fi_dstptr	fi_dst.iplookupptr
283#define	fi_srcfunc	fi_src.iplookupfunc
284#define	fi_dstfunc	fi_dst.iplookupfunc
285
286
287/*
288 * These are both used by the state and NAT code to indicate that one port or
289 * the other should be treated as a wildcard.
290 * NOTE: When updating, check bit masks in ip_state.h and update there too.
291 */
292#define	SI_W_SPORT	0x00000100
293#define	SI_W_DPORT	0x00000200
294#define	SI_WILDP	(SI_W_SPORT|SI_W_DPORT)
295#define	SI_W_SADDR	0x00000400
296#define	SI_W_DADDR	0x00000800
297#define	SI_WILDA	(SI_W_SADDR|SI_W_DADDR)
298#define	SI_NEWFR	0x00001000
299#define	SI_CLONE	0x00002000
300#define	SI_CLONED	0x00004000
301
302
303typedef	struct	fr_info	{
304	void	*fin_ifp;		/* interface packet is `on' */
305	fr_ip_t	fin_fi;		/* IP Packet summary */
306	union	{
307		u_short	fid_16[2];	/* TCP/UDP ports, ICMP code/type */
308		u_32_t	fid_32;
309	} fin_dat;
310	int	fin_out;		/* in or out ? 1 == out, 0 == in */
311	int	fin_rev;		/* state only: 1 = reverse */
312	u_short	fin_hlen;		/* length of IP header in bytes */
313	u_char	fin_tcpf;		/* TCP header flags (SYN, ACK, etc) */
314	u_char	fin_icode;		/* ICMP error to return */
315	u_32_t	fin_rule;		/* rule # last matched */
316	char	fin_group[FR_GROUPLEN];	/* group number, -1 for none */
317	struct	frentry *fin_fr;	/* last matching rule */
318	void	*fin_dp;		/* start of data past IP header */
319	int	fin_dlen;		/* length of data portion of packet */
320	int	fin_plen;
321	int	fin_ipoff;		/* # bytes from buffer start to hdr */
322	u_short	fin_id;			/* IP packet id field */
323	u_short	fin_off;
324	int	fin_depth;		/* Group nesting depth */
325	int	fin_error;		/* Error code to return */
326	int	fin_cksum;		/* -1 bad, 1 good, 0 not done */
327	u_int	fin_pktnum;
328	void	*fin_nattag;
329	void	*fin_exthdr;
330	ip_t	*fin_ip;
331	mb_t	**fin_mp;		/* pointer to pointer to mbuf */
332	mb_t	*fin_m;			/* pointer to mbuf */
333#ifdef	MENTAT
334	mb_t	*fin_qfm;		/* pointer to mblk where pkt starts */
335	void	*fin_qpi;
336	char	fin_ifname[LIFNAMSIZ];
337#endif
338#ifdef	__sgi
339	void	*fin_hbuf;
340#endif
341} fr_info_t;
342
343#define	fin_v		fin_fi.fi_v
344#define	fin_p		fin_fi.fi_p
345#define	fin_flx		fin_fi.fi_flx
346#define	fin_optmsk	fin_fi.fi_optmsk
347#define	fin_secmsk	fin_fi.fi_secmsk
348#define	fin_auth	fin_fi.fi_auth
349#define	fin_src		fin_fi.fi_src.in4
350#define	fin_src6	fin_fi.fi_src.in6
351#define	fin_saddr	fin_fi.fi_saddr
352#define	fin_dst		fin_fi.fi_dst.in4
353#define	fin_dst6	fin_fi.fi_dst.in6
354#define	fin_daddr	fin_fi.fi_daddr
355#define	fin_data	fin_dat.fid_16
356#define	fin_sport	fin_dat.fid_16[0]
357#define	fin_dport	fin_dat.fid_16[1]
358#define	fin_ports	fin_dat.fid_32
359
360#define	IPF_IN		0
361#define	IPF_OUT		1
362
363typedef	struct frentry	*(*ipfunc_t)(fr_info_t *, u_32_t *);
364typedef	int		(*ipfuncinit_t)(struct frentry *);
365
366typedef	struct	ipfunc_resolve	{
367	char		ipfu_name[32];
368	ipfunc_t	ipfu_addr;
369	ipfuncinit_t	ipfu_init;
370} ipfunc_resolve_t;
371
372/*
373 * Size for compares on fr_info structures
374 */
375#define	FI_CSIZE	offsetof(fr_info_t, fin_icode)
376#define	FI_LCSIZE	offsetof(fr_info_t, fin_dp)
377
378/*
379 * Size for copying cache fr_info structure
380 */
381#define	FI_COPYSIZE	offsetof(fr_info_t, fin_dp)
382
383/*
384 * Structure for holding IPFilter's tag information
385 */
386#define	IPFTAG_LEN	16
387typedef	struct	{
388	union	{
389		u_32_t	iptu_num[4];
390		char	iptu_tag[IPFTAG_LEN];
391	} ipt_un;
392	int	ipt_not;
393} ipftag_t;
394
395#define	ipt_tag	ipt_un.iptu_tag
396#define	ipt_num	ipt_un.iptu_num
397
398
399/*
400 * This structure is used to hold information about the next hop for where
401 * to forward a packet.
402 */
403typedef	struct	frdest	{
404	void	*fd_ifp;
405	i6addr_t	fd_ip6;
406	char	fd_ifname[LIFNAMSIZ];
407} frdest_t;
408
409#define	fd_ip	fd_ip6.in4
410
411
412/*
413 * This structure holds information about a port comparison.
414 */
415typedef	struct	frpcmp	{
416	int	frp_cmp;	/* data for port comparisons */
417	u_short	frp_port;	/* top port for <> and >< */
418	u_short	frp_top;	/* top port for <> and >< */
419} frpcmp_t;
420
421#define FR_NONE 0
422#define FR_EQUAL 1
423#define FR_NEQUAL 2
424#define FR_LESST 3
425#define FR_GREATERT 4
426#define FR_LESSTE 5
427#define FR_GREATERTE 6
428#define FR_OUTRANGE 7
429#define FR_INRANGE 8
430#define FR_INCRANGE 9
431
432/*
433 * Structure containing all the relevant TCP things that can be checked in
434 * a filter rule.
435 */
436typedef	struct	frtuc	{
437	u_char		ftu_tcpfm;	/* tcp flags mask */
438	u_char		ftu_tcpf;	/* tcp flags */
439	frpcmp_t	ftu_src;
440	frpcmp_t	ftu_dst;
441} frtuc_t;
442
443#define	ftu_scmp	ftu_src.frp_cmp
444#define	ftu_dcmp	ftu_dst.frp_cmp
445#define	ftu_sport	ftu_src.frp_port
446#define	ftu_dport	ftu_dst.frp_port
447#define	ftu_stop	ftu_src.frp_top
448#define	ftu_dtop	ftu_dst.frp_top
449
450#define	FR_TCPFMAX	0x3f
451
452/*
453 * This structure makes up what is considered to be the IPFilter specific
454 * matching components of a filter rule, as opposed to the data structures
455 * used to define the result which are in frentry_t and not here.
456 */
457typedef	struct	fripf	{
458	fr_ip_t	fri_ip;
459	fr_ip_t	fri_mip;	/* mask structure */
460
461	u_short	fri_icmpm;		/* data for ICMP packets (mask) */
462	u_short	fri_icmp;
463
464	frtuc_t	fri_tuc;
465	int	fri_satype;		/* addres type */
466	int	fri_datype;		/* addres type */
467	int	fri_sifpidx;		/* doing dynamic addressing */
468	int	fri_difpidx;		/* index into fr_ifps[] to use when */
469} fripf_t;
470
471#define	fri_dlookup	fri_mip.fi_dst
472#define	fri_slookup	fri_mip.fi_src
473#define	fri_dstnum	fri_mip.fi_dstnum
474#define	fri_srcnum	fri_mip.fi_srcnum
475#define	fri_dstname	fri_mip.fi_dstname
476#define	fri_srcname	fri_mip.fi_srcname
477#define	fri_dstptr	fri_mip.fi_dstptr
478#define	fri_srcptr	fri_mip.fi_srcptr
479
480#define	FRI_NORMAL	0	/* Normal address */
481#define	FRI_DYNAMIC	1	/* dynamic address */
482#define	FRI_LOOKUP	2	/* address is a pool # */
483#define	FRI_RANGE	3	/* address/mask is a range */
484#define	FRI_NETWORK	4	/* network address from if */
485#define	FRI_BROADCAST	5	/* broadcast address from if */
486#define	FRI_PEERADDR	6	/* Peer address for P-to-P */
487#define	FRI_NETMASKED	7	/* network address with netmask from if */
488
489
490typedef	struct	frentry	* (* frentfunc_t)(fr_info_t *);
491
492typedef	struct	frentry {
493	ipfmutex_t	fr_lock;
494	struct	frentry	*fr_next;
495	struct	frentry	**fr_grp;
496	struct	ipscan	*fr_isc;
497	void	*fr_ifas[4];
498	void	*fr_ptr;	/* for use with fr_arg */
499	char	*fr_comment;	/* text comment for rule */
500	int	fr_ref;		/* reference count - for grouping */
501	int	fr_statecnt;	/* state count - for limit rules */
502	/*
503	 * The line number from a file is here because we need to be able to
504	 * match the rule generated with ``grep rule ipf.conf | ipf -rf -''
505	 * with the rule loaded using ``ipf -f ipf.conf'' - thus it can't be
506	 * on the other side of fr_func.
507	 */
508	int	fr_flineno;	/* line number from conf file */
509	/*
510	 * These are only incremented when a packet  matches this rule and
511	 * it is the last match
512	 */
513	U_QUAD_T	fr_hits;
514	U_QUAD_T	fr_bytes;
515
516	/*
517	 * For PPS rate limiting
518	 * fr_lpu is used to always have the same size for this field,
519	 * allocating 64bits for seconds and 32bits for milliseconds.
520	 */
521	union {
522		struct timeval	frp_lastpkt;
523		char	frp_bytes[12];
524	} fr_lpu;
525	int		fr_curpps;
526
527	union	{
528		void		*fru_data;
529		void *		fru_caddr;
530		fripf_t		*fru_ipf;
531		frentfunc_t	fru_func;
532	} fr_dun;
533
534	/*
535	 * Fields after this may not change whilst in the kernel.
536	 */
537	ipfunc_t fr_func; 	/* call this function */
538	int	fr_dsize;
539	int	fr_pps;
540	int	fr_statemax;	/* max reference count */
541	u_32_t	fr_type;
542	u_32_t	fr_flags;	/* per-rule flags && options (see below) */
543	u_32_t	fr_logtag;	/* user defined log tag # */
544	u_32_t	fr_collect;	/* collection number */
545	u_int	fr_arg;		/* misc. numeric arg for rule */
546	u_int	fr_loglevel;	/* syslog log facility + priority */
547	u_int	fr_age[2];	/* non-TCP timeouts */
548	u_char	fr_v;
549	u_char	fr_icode;	/* return ICMP code */
550	char	fr_group[FR_GROUPLEN];	/* group to which this rule belongs */
551	char	fr_grhead[FR_GROUPLEN];	/* group # which this rule starts */
552	ipftag_t fr_nattag;
553	char	fr_ifnames[4][LIFNAMSIZ];
554	char	fr_isctag[16];
555	frdest_t fr_tifs[2];	/* "to"/"reply-to" interface */
556	frdest_t fr_dif;	/* duplicate packet interface */
557	/*
558	 * This must be last and will change after loaded into the kernel.
559	 */
560	u_int	fr_cksum;	/* checksum on filter rules for performance */
561} frentry_t;
562
563#define	fr_lastpkt	fr_lpu.frp_lastpkt
564#define	fr_caddr	fr_dun.fru_caddr
565#define	fr_data		fr_dun.fru_data
566#define	fr_dfunc	fr_dun.fru_func
567#define	fr_ipf		fr_dun.fru_ipf
568#define	fr_ip		fr_ipf->fri_ip
569#define	fr_mip		fr_ipf->fri_mip
570#define	fr_icmpm	fr_ipf->fri_icmpm
571#define	fr_icmp		fr_ipf->fri_icmp
572#define	fr_tuc		fr_ipf->fri_tuc
573#define	fr_satype	fr_ipf->fri_satype
574#define	fr_datype	fr_ipf->fri_datype
575#define	fr_sifpidx	fr_ipf->fri_sifpidx
576#define	fr_difpidx	fr_ipf->fri_difpidx
577#define	fr_proto	fr_ip.fi_p
578#define	fr_mproto	fr_mip.fi_p
579#define	fr_ttl		fr_ip.fi_ttl
580#define	fr_mttl		fr_mip.fi_ttl
581#define	fr_tos		fr_ip.fi_tos
582#define	fr_mtos		fr_mip.fi_tos
583#define	fr_tcpfm	fr_tuc.ftu_tcpfm
584#define	fr_tcpf		fr_tuc.ftu_tcpf
585#define	fr_scmp		fr_tuc.ftu_scmp
586#define	fr_dcmp		fr_tuc.ftu_dcmp
587#define	fr_dport	fr_tuc.ftu_dport
588#define	fr_sport	fr_tuc.ftu_sport
589#define	fr_stop		fr_tuc.ftu_stop
590#define	fr_dtop		fr_tuc.ftu_dtop
591#define	fr_dst		fr_ip.fi_dst.in4
592#define	fr_daddr	fr_ip.fi_dst.in4.s_addr
593#define	fr_src		fr_ip.fi_src.in4
594#define	fr_saddr	fr_ip.fi_src.in4.s_addr
595#define	fr_dmsk		fr_mip.fi_dst.in4
596#define	fr_dmask	fr_mip.fi_dst.in4.s_addr
597#define	fr_smsk		fr_mip.fi_src.in4
598#define	fr_smask	fr_mip.fi_src.in4.s_addr
599#define	fr_dstnum	fr_ip.fi_dstnum
600#define	fr_srcnum	fr_ip.fi_srcnum
601#define	fr_dlookup	fr_ip.fi_dst
602#define	fr_slookup	fr_ip.fi_src
603#define	fr_dstname	fr_ip.fi_dstname
604#define	fr_srcname	fr_ip.fi_srcname
605#define	fr_dsttype	fr_ip.fi_dsttype
606#define	fr_srctype	fr_ip.fi_srctype
607#define	fr_dstsubtype	fr_ip.fi_dstsubtype
608#define	fr_srcsubtype	fr_ip.fi_srcsubtype
609#define	fr_dstptr	fr_mip.fi_dstptr
610#define	fr_srcptr	fr_mip.fi_srcptr
611#define	fr_dstfunc	fr_mip.fi_dstfunc
612#define	fr_srcfunc	fr_mip.fi_srcfunc
613#define	fr_optbits	fr_ip.fi_optmsk
614#define	fr_optmask	fr_mip.fi_optmsk
615#define	fr_secbits	fr_ip.fi_secmsk
616#define	fr_secmask	fr_mip.fi_secmsk
617#define	fr_authbits	fr_ip.fi_auth
618#define	fr_authmask	fr_mip.fi_auth
619#define	fr_flx		fr_ip.fi_flx
620#define	fr_mflx		fr_mip.fi_flx
621#define	fr_ifname	fr_ifnames[0]
622#define	fr_oifname	fr_ifnames[2]
623#define	fr_ifa		fr_ifas[0]
624#define	fr_oifa		fr_ifas[2]
625#define	fr_tif		fr_tifs[0]
626#define	fr_rif		fr_tifs[1]
627
628#define	FR_NOLOGTAG	0
629
630#define	FR_CMPSIZ	(sizeof(struct frentry) - \
631			 offsetof(struct frentry, fr_func))
632
633/*
634 * fr_type
635 */
636#define	FR_T_NONE	0
637#define	FR_T_IPF	1	/* IPF structures */
638#define	FR_T_BPFOPC	2	/* BPF opcode */
639#define	FR_T_CALLFUNC	3	/* callout to function in fr_func only */
640#define	FR_T_COMPIPF	4	/* compiled C code */
641#define	FR_T_BUILTIN	0x80000000	/* rule is in kernel space */
642
643/*
644 * fr_flags
645 */
646#define	FR_CALL		0x00000	/* call rule */
647#define	FR_BLOCK	0x00001	/* do not allow packet to pass */
648#define	FR_PASS		0x00002	/* allow packet to pass */
649#define	FR_AUTH		0x00003	/* use authentication */
650#define	FR_PREAUTH	0x00004	/* require preauthentication */
651#define	FR_ACCOUNT	0x00005	/* Accounting rule */
652#define	FR_SKIP		0x00006	/* skip rule */
653#define	FR_DIVERT	0x00007	/* divert rule */
654#define	FR_CMDMASK	0x0000f
655#define	FR_LOG		0x00010	/* Log */
656#define	FR_LOGB		0x00011	/* Log-fail */
657#define	FR_LOGP		0x00012	/* Log-pass */
658#define	FR_LOGMASK	(FR_LOG|FR_CMDMASK)
659#define	FR_CALLNOW	0x00020	/* call another function (fr_func) if matches */
660#define	FR_NOTSRCIP	0x00040
661#define	FR_NOTDSTIP	0x00080
662#define	FR_QUICK	0x00100	/* match & stop processing list */
663#define	FR_KEEPFRAG	0x00200	/* keep fragment information */
664#define	FR_KEEPSTATE	0x00400	/* keep `connection' state information */
665#define	FR_FASTROUTE	0x00800	/* bypass normal routing */
666#define	FR_RETRST	0x01000	/* Return TCP RST packet - reset connection */
667#define	FR_RETICMP	0x02000	/* Return ICMP unreachable packet */
668#define	FR_FAKEICMP	0x03000	/* Return ICMP unreachable with fake source */
669#define	FR_OUTQUE	0x04000	/* outgoing packets */
670#define	FR_INQUE	0x08000	/* ingoing packets */
671#define	FR_LOGBODY	0x10000	/* Log the body */
672#define	FR_LOGFIRST	0x20000	/* Log the first byte if state held */
673#define	FR_LOGORBLOCK	0x40000	/* block the packet if it can't be logged */
674#define	FR_DUP		0x80000	/* duplicate packet */
675#define	FR_FRSTRICT	0x100000	/* strict frag. cache */
676#define	FR_STSTRICT	0x200000	/* strict keep state */
677#define	FR_NEWISN	0x400000	/* new ISN for outgoing TCP */
678#define	FR_NOICMPERR	0x800000	/* do not match ICMP errors in state */
679#define	FR_STATESYNC	0x1000000	/* synchronize state to slave */
680#define	FR_NOMATCH	0x8000000	/* no match occured */
681		/*	0x10000000 	FF_LOGPASS */
682		/*	0x20000000 	FF_LOGBLOCK */
683		/*	0x40000000 	FF_LOGNOMATCH */
684		/*	0x80000000 	FF_BLOCKNONIP */
685#define	FR_COPIED	0x40000000	/* copied from user space */
686#define	FR_INACTIVE	0x80000000	/* only used when flush'ing rules */
687
688#define	FR_RETMASK	(FR_RETICMP|FR_RETRST|FR_FAKEICMP)
689#define	FR_ISBLOCK(x)	(((x) & FR_CMDMASK) == FR_BLOCK)
690#define	FR_ISPASS(x)	(((x) & FR_CMDMASK) == FR_PASS)
691#define	FR_ISAUTH(x)	(((x) & FR_CMDMASK) == FR_AUTH)
692#define	FR_ISPREAUTH(x)	(((x) & FR_CMDMASK) == FR_PREAUTH)
693#define	FR_ISACCOUNT(x)	(((x) & FR_CMDMASK) == FR_ACCOUNT)
694#define	FR_ISSKIP(x)	(((x) & FR_CMDMASK) == FR_SKIP)
695#define	FR_ISNOMATCH(x)	((x) & FR_NOMATCH)
696#define	FR_INOUT	(FR_INQUE|FR_OUTQUE)
697
698/*
699 * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags
700 */
701#define	FF_LOGPASS	0x10000000
702#define	FF_LOGBLOCK	0x20000000
703#define	FF_LOGNOMATCH	0x40000000
704#define	FF_LOGGING	(FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH)
705#define	FF_BLOCKNONIP	0x80000000	/* Solaris2 Only */
706
707
708/*
709 * Structure that passes information on what/how to flush to the kernel.
710 */
711typedef	struct	ipfflush	{
712	int	ipflu_how;
713	int	ipflu_arg;
714} ipfflush_t;
715
716
717/*
718 *
719 */
720typedef	struct	ipfgetctl	{
721	u_int	ipfg_min;	/* min value */
722	u_int	ipfg_current;	/* current value */
723	u_int	ipfg_max;	/* max value */
724	u_int	ipfg_default;	/* default value */
725	u_int	ipfg_steps;	/* value increments */
726	char	ipfg_name[40];	/* tag name for this control */
727} ipfgetctl_t;
728
729typedef	struct	ipfsetctl	{
730	int	ipfs_which;	/* 0 = min 1 = current 2 = max 3 = default */
731	u_int	ipfs_value;	/* min value */
732	char	ipfs_name[40];	/* tag name for this control */
733} ipfsetctl_t;
734
735
736/*
737 * Some of the statistics below are in their own counters, but most are kept
738 * in this single structure so that they can all easily be collected and
739 * copied back as required.
740 */
741typedef	struct	filterstats {
742	u_long	fr_pass;	/* packets allowed */
743	u_long	fr_block;	/* packets denied */
744	u_long	fr_nom;		/* packets which don't match any rule */
745	u_long	fr_short;	/* packets which are short */
746	u_long	fr_ppkl;	/* packets allowed and logged */
747	u_long	fr_bpkl;	/* packets denied and logged */
748	u_long	fr_npkl;	/* packets unmatched and logged */
749	u_long	fr_pkl;		/* packets logged */
750	u_long	fr_skip;	/* packets to be logged but buffer full */
751	u_long	fr_ret;		/* packets for which a return is sent */
752	u_long	fr_acct;	/* packets for which counting was performed */
753	u_long	fr_bnfr;	/* bad attempts to allocate fragment state */
754	u_long	fr_nfr;		/* new fragment state kept */
755	u_long	fr_cfr;		/* add new fragment state but complete pkt */
756	u_long	fr_bads;	/* bad attempts to allocate packet state */
757	u_long	fr_ads;		/* new packet state kept */
758	u_long	fr_chit;	/* cached hit */
759	u_long	fr_tcpbad;	/* TCP checksum check failures */
760	u_long	fr_pull[2];	/* good and bad pullup attempts */
761	u_long	fr_badsrc;	/* source received doesn't match route */
762	u_long	fr_badttl;	/* TTL in packet doesn't reach minimum */
763	u_long	fr_bad;		/* bad IP packets to the filter */
764	u_long	fr_ipv6;	/* IPv6 packets in/out */
765	u_long	fr_ppshit;	/* dropped because of pps ceiling */
766	u_long	fr_ipud;	/* IP id update failures */
767} filterstats_t;
768
769/*
770 * Log structure.  Each packet header logged is prepended by one of these.
771 * Following this in the log records read from the device will be an ipflog
772 * structure which is then followed by any packet data.
773 */
774typedef	struct	iplog	{
775	u_32_t		ipl_magic;
776	u_int		ipl_count;
777	struct	timeval	ipl_time;
778	size_t		ipl_dsize;
779	struct	iplog	*ipl_next;
780} iplog_t;
781
782#define	ipl_sec		ipl_time.tv_sec
783#define	ipl_usec	ipl_time.tv_usec
784
785#define IPL_MAGIC	0x49504c4d	/* 'IPLM' */
786#define IPL_MAGIC_NAT	0x49504c4e	/* 'IPLN' */
787#define IPL_MAGIC_STATE	0x49504c53	/* 'IPLS' */
788#define	IPLOG_SIZE	sizeof(iplog_t)
789
790typedef	struct	ipflog	{
791#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \
792        (defined(OpenBSD) && (OpenBSD >= 199603))
793#else
794	u_int	fl_unit;
795#endif
796	u_32_t	fl_rule;
797	u_32_t	fl_flags;
798	u_32_t	fl_lflags;
799	u_32_t	fl_logtag;
800	ipftag_t	fl_nattag;
801	u_short	fl_plen;	/* extra data after hlen */
802	u_short	fl_loglevel;	/* syslog log level */
803	char	fl_group[FR_GROUPLEN];
804	u_char	fl_hlen;	/* length of IP headers saved */
805	u_char	fl_dir;
806	u_char	fl_xxx[2];	/* pad */
807	char	fl_ifname[LIFNAMSIZ];
808} ipflog_t;
809
810#ifndef	IPF_LOGGING
811# define	IPF_LOGGING	0
812#endif
813#ifndef	IPF_DEFAULT_PASS
814# define	IPF_DEFAULT_PASS	FR_PASS
815#endif
816
817#define	DEFAULT_IPFLOGSIZE	8192
818#ifndef	IPFILTER_LOGSIZE
819# define	IPFILTER_LOGSIZE	DEFAULT_IPFLOGSIZE
820#else
821# if IPFILTER_LOGSIZE < DEFAULT_IPFLOGSIZE
822#  error IPFILTER_LOGSIZE too small.  Must be >= DEFAULT_IPFLOGSIZE
823# endif
824#endif
825
826#define	IPF_OPTCOPY	0x07ff00	/* bit mask of copied options */
827
828/*
829 * Device filenames for reading log information.  Use ipf on Solaris2 because
830 * ipl is already a name used by something else.
831 */
832#ifndef	IPL_NAME
833# if	SOLARIS
834#  define	IPL_NAME	"/dev/ipf"
835# else
836#  define	IPL_NAME	"/dev/ipl"
837# endif
838#endif
839/*
840 * Pathnames for various IP Filter control devices.  Used by LKM
841 * and userland, so defined here.
842 */
843#define	IPNAT_NAME	"/dev/ipnat"
844#define	IPSTATE_NAME	"/dev/ipstate"
845#define	IPAUTH_NAME	"/dev/ipauth"
846#define	IPSYNC_NAME	"/dev/ipsync"
847#define	IPSCAN_NAME	"/dev/ipscan"
848#define	IPLOOKUP_NAME	"/dev/iplookup"
849
850#define	IPL_LOGIPF	0	/* Minor device #'s for accessing logs */
851#define	IPL_LOGNAT	1
852#define	IPL_LOGSTATE	2
853#define	IPL_LOGAUTH	3
854#define	IPL_LOGSYNC	4
855#define	IPL_LOGSCAN	5
856#define	IPL_LOGLOOKUP	6
857#define	IPL_LOGCOUNT	7
858#define	IPL_LOGMAX	7
859#define	IPL_LOGSIZE	IPL_LOGMAX + 1
860#define	IPL_LOGALL	-1
861#define	IPL_LOGNONE	-2
862
863/*
864 * For SIOCGETFS
865 */
866typedef	struct	friostat	{
867	struct	filterstats	f_st[2];
868	struct	frentry		*f_ipf[2][2];
869	struct	frentry		*f_acct[2][2];
870	struct	frentry		*f_ipf6[2][2];
871	struct	frentry		*f_acct6[2][2];
872	struct	frentry		*f_auth;
873	struct	frgroup		*f_groups[IPL_LOGSIZE][2];
874	u_long	f_froute[2];
875	u_long	f_ticks;
876	int	f_locks[IPL_LOGSIZE];
877	size_t	f_kmutex_sz;
878	size_t	f_krwlock_sz;
879	int	f_defpass;	/* default pass - from fr_pass */
880	int	f_active;	/* 1 or 0 - active rule set */
881	int	f_running;	/* 1 if running, else 0 */
882	int	f_logging;	/* 1 if enabled, else 0 */
883	int	f_features;
884	char	f_version[32];	/* version string */
885} friostat_t;
886
887#define	f_fin		f_ipf[0]
888#define	f_fin6		f_ipf6[0]
889#define	f_fout		f_ipf[1]
890#define	f_fout6		f_ipf6[1]
891#define	f_acctin	f_acct[0]
892#define	f_acctin6	f_acct6[0]
893#define	f_acctout	f_acct[1]
894#define	f_acctout6	f_acct6[1]
895
896#define	IPF_FEAT_LKM		0x001
897#define	IPF_FEAT_LOG		0x002
898#define	IPF_FEAT_LOOKUP		0x004
899#define	IPF_FEAT_BPF		0x008
900#define	IPF_FEAT_COMPILED	0x010
901#define	IPF_FEAT_CKSUM		0x020
902#define	IPF_FEAT_SYNC		0x040
903#define	IPF_FEAT_SCAN		0x080
904#define	IPF_FEAT_IPV6		0x100
905
906typedef struct	optlist {
907	u_short ol_val;
908	int	ol_bit;
909} optlist_t;
910
911
912/*
913 * Group list structure.
914 */
915typedef	struct frgroup {
916	struct	frgroup	*fg_next;
917	struct	frentry	*fg_head;
918	struct	frentry	*fg_start;
919	u_32_t	fg_flags;
920	int	fg_ref;
921	char	fg_name[FR_GROUPLEN];
922} frgroup_t;
923
924#define	FG_NAME(g)	(*(g)->fg_name == '\0' ? "" : (g)->fg_name)
925
926
927/*
928 * Used by state and NAT tables
929 */
930typedef struct icmpinfo {
931	u_short	ici_id;
932	u_short	ici_seq;
933	u_char	ici_type;
934} icmpinfo_t;
935
936typedef struct udpinfo {
937	u_short	us_sport;
938	u_short	us_dport;
939} udpinfo_t;
940
941
942typedef	struct	tcpdata	{
943	u_32_t	td_end;
944	u_32_t	td_maxend;
945	u_32_t	td_maxwin;
946	u_32_t	td_winscale;
947	u_32_t	td_maxseg;
948	int	td_winflags;
949} tcpdata_t;
950
951#define	TCP_WSCALE_MAX		14
952
953#define	TCP_WSCALE_SEEN		0x00000001
954#define	TCP_WSCALE_FIRST	0x00000002
955#define	TCP_SACK_PERMIT		0x00000004
956
957
958typedef	struct tcpinfo {
959	u_short	ts_sport;
960	u_short	ts_dport;
961	tcpdata_t ts_data[2];
962} tcpinfo_t;
963
964
965/*
966 * Structures to define a GRE header as seen in a packet.
967 */
968struct	grebits	{
969	u_32_t	grb_C:1;
970	u_32_t	grb_R:1;
971	u_32_t	grb_K:1;
972	u_32_t	grb_S:1;
973	u_32_t	grb_s:1;
974	u_32_t	grb_recur:1;
975	u_32_t	grb_A:1;
976	u_32_t	grb_flags:3;
977	u_32_t	grb_ver:3;
978	u_short	grb_ptype;
979};
980
981typedef	struct	grehdr	{
982	union	{
983		struct	grebits	gru_bits;
984		u_short	gru_flags;
985	} gr_un;
986	u_short	gr_len;
987	u_short	gr_call;
988} grehdr_t;
989
990#define	gr_flags	gr_un.gru_flags
991#define	gr_bits		gr_un.gru_bits
992#define	gr_ptype	gr_bits.grb_ptype
993#define	gr_C		gr_bits.grb_C
994#define	gr_R		gr_bits.grb_R
995#define	gr_K		gr_bits.grb_K
996#define	gr_S		gr_bits.grb_S
997#define	gr_s		gr_bits.grb_s
998#define	gr_recur	gr_bits.grb_recur
999#define	gr_A		gr_bits.grb_A
1000#define	gr_ver		gr_bits.grb_ver
1001
1002/*
1003 * GRE information tracked by "keep state"
1004 */
1005typedef	struct	greinfo	{
1006	u_short	gs_call[2];
1007	u_short	gs_flags;
1008	u_short	gs_ptype;
1009} greinfo_t;
1010
1011#define	GRE_REV(x)	((ntohs(x) >> 13) & 7)
1012
1013
1014/*
1015 * Format of an Authentication header
1016 */
1017typedef	struct	authhdr	{
1018	u_char	ah_next;
1019	u_char	ah_plen;
1020	u_short	ah_reserved;
1021	u_32_t	ah_spi;
1022	u_32_t	ah_seq;
1023	/* Following the sequence number field is 0 or more bytes of */
1024	/* authentication data, as specified by ah_plen - RFC 2402.  */
1025} authhdr_t;
1026
1027
1028/*
1029 * Timeout tail queue list member
1030 */
1031typedef	struct	ipftqent	{
1032	struct ipftqent **tqe_pnext;
1033	struct ipftqent *tqe_next;
1034	struct	ipftq	*tqe_ifq;
1035	void	*tqe_parent;		/* pointer back to NAT/state struct */
1036	u_long	tqe_die;		/* when this entriy is to die */
1037	u_long	tqe_touched;
1038	int	tqe_flags;
1039	int	tqe_state[2];		/* current state of this entry */
1040} ipftqent_t;
1041
1042#define	TQE_RULEBASED	0x00000001
1043
1044
1045/*
1046 * Timeout tail queue head for IPFilter
1047 */
1048typedef struct  ipftq   {
1049	ipfmutex_t	ifq_lock;
1050	u_int	ifq_ttl;
1051	ipftqent_t	*ifq_head;
1052	ipftqent_t	**ifq_tail;
1053	struct	ipftq	*ifq_next;
1054	struct	ipftq	**ifq_pnext;
1055	int	ifq_ref;
1056	u_int	ifq_flags;
1057} ipftq_t;
1058
1059#define	IFQF_USER	0x01		/* User defined aging */
1060#define	IFQF_DELETE	0x02		/* Marked for deletion */
1061#define	IFQF_PROXY	0x04		/* Timeout queue in use by a proxy */
1062
1063#define	IPF_HZ_MULT	1
1064#define	IPF_HZ_DIVIDE	2		/* How many times a second ipfilter */
1065					/* checks its timeout queues.       */
1066#define	IPF_TTLVAL(x)	(((x) / IPF_HZ_MULT) * IPF_HZ_DIVIDE)
1067
1068typedef	int	(*ipftq_delete_fn_t)(void *);
1069
1070/*
1071 * Structure to define address for pool lookups.
1072 */
1073typedef	struct	{
1074	u_char		adf_len;
1075	i6addr_t	adf_addr;
1076} addrfamily_t;
1077
1078
1079/*
1080 * Object structure description.  For passing through in ioctls.
1081 */
1082typedef	struct	ipfobj	{
1083	u_32_t	ipfo_rev;		/* IPFilter version number */
1084	u_32_t	ipfo_size;		/* size of object at ipfo_ptr */
1085	void	*ipfo_ptr;		/* pointer to object */
1086	int	ipfo_type;		/* type of object being pointed to */
1087	int	ipfo_offset;		/* bytes from ipfo_ptr where to start */
1088	u_char	ipfo_xxxpad[32];	/* reserved for future use */
1089} ipfobj_t;
1090
1091#define	IPFOBJ_FRENTRY		0	/* struct frentry */
1092#define	IPFOBJ_IPFSTAT		1	/* struct friostat */
1093#define	IPFOBJ_IPFINFO		2	/* struct fr_info */
1094#define	IPFOBJ_AUTHSTAT		3	/* struct fr_authstat */
1095#define	IPFOBJ_FRAGSTAT		4	/* struct ipfrstat */
1096#define	IPFOBJ_IPNAT		5	/* struct ipnat */
1097#define	IPFOBJ_NATSTAT		6	/* struct natstat */
1098#define	IPFOBJ_STATESAVE	7	/* struct ipstate_save */
1099#define	IPFOBJ_NATSAVE		8	/* struct nat_save */
1100#define	IPFOBJ_NATLOOKUP	9	/* struct natlookup */
1101#define	IPFOBJ_IPSTATE		10	/* struct ipstate */
1102#define	IPFOBJ_STATESTAT	11	/* struct ips_stat */
1103#define	IPFOBJ_FRAUTH		12	/* struct frauth */
1104#define	IPFOBJ_TUNEABLE		13	/* struct ipftune */
1105#define	IPFOBJ_NAT		14	/* struct nat */
1106#define	IPFOBJ_IPFITER		15	/* struct ipfruleiter */
1107#define	IPFOBJ_GENITER		16	/* struct ipfgeniter */
1108#define	IPFOBJ_GTABLE		17	/* struct ipftable */
1109#define	IPFOBJ_LOOKUPITER	18	/* struct ipflookupiter */
1110#define	IPFOBJ_STATETQTAB	19	/* struct ipftq [NSTATES] */
1111#define	IPFOBJ_COUNT		20	/* How many #defines are above this? */
1112
1113
1114typedef	union	ipftunevalptr	{
1115	void	*ipftp_void;
1116	u_long	*ipftp_long;
1117	u_int	*ipftp_int;
1118	u_short	*ipftp_short;
1119	u_char	*ipftp_char;
1120} ipftunevalptr_t;
1121
1122typedef	struct	ipftuneable	{
1123	ipftunevalptr_t	ipft_una;
1124	const char	*ipft_name;
1125	u_long		ipft_min;
1126	u_long		ipft_max;
1127	int		ipft_sz;
1128	int		ipft_flags;
1129	struct ipftuneable *ipft_next;
1130} ipftuneable_t;
1131
1132#define	ipft_addr	ipft_una.ipftp_void
1133#define	ipft_plong	ipft_una.ipftp_long
1134#define	ipft_pint	ipft_una.ipftp_int
1135#define	ipft_pshort	ipft_una.ipftp_short
1136#define	ipft_pchar	ipft_una.ipftp_char
1137
1138#define	IPFT_RDONLY	1	/* read-only */
1139#define	IPFT_WRDISABLED	2	/* write when disabled only */
1140
1141typedef	union	ipftuneval	{
1142	u_long	ipftu_long;
1143	u_int	ipftu_int;
1144	u_short	ipftu_short;
1145	u_char	ipftu_char;
1146} ipftuneval_t;
1147
1148typedef	struct	ipftune	{
1149	void    	*ipft_cookie;
1150	ipftuneval_t	ipft_un;
1151	u_long  	ipft_min;
1152	u_long  	ipft_max;
1153	int		ipft_sz;
1154	int		ipft_flags;
1155	char		ipft_name[80];
1156} ipftune_t;
1157
1158#define	ipft_vlong	ipft_un.ipftu_long
1159#define	ipft_vint	ipft_un.ipftu_int
1160#define	ipft_vshort	ipft_un.ipftu_short
1161#define	ipft_vchar	ipft_un.ipftu_char
1162
1163/*
1164 *
1165 */
1166typedef	struct	ipfruleiter {
1167	int		iri_inout;
1168	char		iri_group[FR_GROUPLEN];
1169	int		iri_active;
1170	int		iri_nrules;
1171	int		iri_v;
1172	frentry_t	*iri_rule;
1173} ipfruleiter_t;
1174
1175/*
1176 * Values for iri_inout
1177 */
1178#define	F_IN	0
1179#define	F_OUT	1
1180#define	F_ACIN	2
1181#define	F_ACOUT	3
1182
1183
1184typedef	struct	ipfgeniter {
1185	int	igi_type;
1186	int	igi_nitems;
1187	void	*igi_data;
1188} ipfgeniter_t;
1189
1190#define	IPFGENITER_IPF		0
1191#define	IPFGENITER_NAT		1
1192#define	IPFGENITER_IPNAT	2
1193#define	IPFGENITER_FRAG		3
1194#define	IPFGENITER_AUTH		4
1195#define	IPFGENITER_STATE	5
1196#define	IPFGENITER_NATFRAG	6
1197#define	IPFGENITER_HOSTMAP	7
1198#define	IPFGENITER_LOOKUP	8
1199
1200typedef	struct	ipftable {
1201	int	ita_type;
1202	void	*ita_table;
1203} ipftable_t;
1204
1205#define	IPFTABLE_BUCKETS	1
1206#define	IPFTABLE_BUCKETS_NATIN	2
1207#define	IPFTABLE_BUCKETS_NATOUT	3
1208
1209
1210/*
1211 *
1212 */
1213typedef struct ipftoken {
1214	struct ipftoken	*ipt_next;
1215	struct ipftoken	**ipt_pnext;
1216	void		*ipt_ctx;
1217	void		*ipt_data;
1218	u_long		ipt_die;
1219	int		ipt_type;
1220	int		ipt_uid;
1221	int		ipt_subtype;
1222	int		ipt_ref;
1223} ipftoken_t;
1224
1225
1226/*
1227** HPUX Port
1228*/
1229#ifdef __hpux
1230/* HP-UX locking sequence deadlock detection module lock MAJOR ID */
1231# define	IPF_SMAJ	0	/* temp assignment XXX, not critical */
1232#endif
1233
1234#if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \
1235    (__FreeBSD_version >= 220000)
1236# define	CDEV_MAJOR	79
1237#endif
1238
1239/*
1240 * Post NetBSD 1.2 has the PFIL interface for packet filters.  This turns
1241 * on those hooks.  We don't need any special mods in non-IP Filter code
1242 * with this!
1243 */
1244#if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \
1245    (defined(NetBSD1_2) && NetBSD1_2 > 1) || \
1246    (defined(__FreeBSD__) && (__FreeBSD_version >= 500043))
1247# if (NetBSD >= 199905)
1248#  define PFIL_HOOKS
1249# endif
1250# ifdef PFIL_HOOKS
1251#  define NETBSD_PF
1252# endif
1253#endif
1254
1255#ifdef _KERNEL
1256# define	FR_VERBOSE(verb_pr)
1257# define	FR_DEBUG(verb_pr)
1258#else
1259extern	void	debug(char *, ...);
1260extern	void	verbose(char *, ...);
1261# define	FR_VERBOSE(verb_pr)	verbose verb_pr
1262# define	FR_DEBUG(verb_pr)	debug verb_pr
1263#endif
1264
1265
1266#ifndef	_KERNEL
1267extern	int	fr_check(struct ip *, int, void *, int, mb_t **);
1268extern	int	(*fr_checkp)(ip_t *, int, void *, int, mb_t **);
1269extern	int	ipf_log(void);
1270extern	struct	ifnet *get_unit(char *, int);
1271extern	char	*get_ifname(struct ifnet *);
1272# if defined(__NetBSD__) || defined(__OpenBSD__) || \
1273	  (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000)
1274extern	int	iplioctl(int, ioctlcmd_t, void *, int);
1275# else
1276extern	int	iplioctl(int, ioctlcmd_t, void *, int);
1277# endif
1278extern	int	iplopen(dev_t, int);
1279extern	int	iplclose(dev_t, int);
1280extern	void	m_freem(mb_t *);
1281extern	int	bcopywrap(void *, void *, size_t);
1282#else /* #ifndef _KERNEL */
1283# ifdef BSD
1284#  if (defined(__NetBSD__) && (__NetBSD_Version__ < 399000000)) || \
1285      defined(__osf__) || \
1286      (defined(__FreeBSD_version) && (__FreeBSD_version < 500043))
1287#   include <sys/select.h>
1288#  else
1289#   include <sys/selinfo.h>
1290#  endif
1291extern struct selinfo ipfselwait[IPL_LOGSIZE];
1292# endif
1293# if defined(__NetBSD__) && defined(PFIL_HOOKS)
1294extern	void	ipfilterattach(int);
1295# endif
1296extern	int	ipl_enable(void);
1297extern	int	ipl_disable(void);
1298extern	int	ipf_inject(fr_info_t *, mb_t *);
1299# ifdef MENTAT
1300extern	int	fr_check(struct ip *, int, void *, int, void *,
1301			      mblk_t **);
1302#  if SOLARIS
1303#   if SOLARIS2 >= 7
1304extern	int	iplioctl(dev_t, int, intptr_t, int, cred_t *, int *);
1305#   else
1306extern	int	iplioctl(dev_t, int, int *, int, cred_t *, int *);
1307#   endif
1308extern	int	iplopen(dev_t *, int, int, cred_t *);
1309extern	int	iplclose(dev_t, int, int, cred_t *);
1310extern	int	iplread(dev_t, uio_t *, cred_t *);
1311extern	int	iplwrite(dev_t, uio_t *, cred_t *);
1312#  endif
1313#  ifdef __hpux
1314extern	int	iplopen(dev_t, int, intptr_t, int);
1315extern	int	iplclose(dev_t, int, int);
1316extern	int	iplioctl(dev_t, int, void *, int);
1317extern	int	iplread(dev_t, uio_t *);
1318extern	int	iplwrite(dev_t, uio_t *);
1319extern	int	iplselect(dev_t, int);
1320#  endif
1321extern	int	fr_qout(queue_t *, mblk_t *);
1322# else /* MENTAT */
1323extern	int	fr_check(struct ip *, int, void *, int, mb_t **);
1324extern	int	(*fr_checkp)(ip_t *, int, void *, int, mb_t **);
1325extern	size_t	mbufchainlen(mb_t *);
1326#  ifdef	__sgi
1327#   include <sys/cred.h>
1328extern	int	iplioctl(dev_t, int, void *, int, cred_t *, int *);
1329extern	int	iplopen(dev_t *, int, int, cred_t *);
1330extern	int	iplclose(dev_t, int, int, cred_t *);
1331extern	int	iplread(dev_t, uio_t *, cred_t *);
1332extern	int	iplwrite(dev_t, uio_t *, cred_t *);
1333extern	int	ipfilter_sgi_attach(void);
1334extern	void	ipfilter_sgi_detach(void);
1335extern	void	ipfilter_sgi_intfsync(void);
1336#  else
1337#   ifdef	IPFILTER_LKM
1338extern	int	iplidentify(char *);
1339#   endif
1340#   if (defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199510)) || \
1341       (defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)) || \
1342       (defined(NetBSD) && (NetBSD >= 199511)) || defined(__OpenBSD__)
1343#    if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \
1344        defined(__OpenBSD__) || (__FreeBSD_version >= 300000)
1345#     if (__FreeBSD_version >= 500024)
1346#      if (__FreeBSD_version >= 502116)
1347extern	int	iplioctl(struct cdev*, u_long, void *, int, struct thread *);
1348#      else
1349extern	int	iplioctl(dev_t, u_long, void *, int, struct thread *);
1350#      endif /* __FreeBSD_version >= 502116 */
1351#     else
1352#      if  (__NetBSD_Version__ >= 499001000)
1353extern	int	iplioctl(dev_t, u_long, void *, int, struct lwp *);
1354#       else
1355#       if  (__NetBSD_Version__ >= 399001400)
1356extern	int	iplioctl(dev_t, u_long, caddr_t, int, struct lwp *);
1357#       else
1358extern	int	iplioctl(dev_t, u_long, caddr_t, int, struct proc *);
1359#       endif
1360#      endif
1361#     endif /* __FreeBSD_version >= 500024 */
1362#    else
1363extern	int	iplioctl(dev_t, int, void *, int, struct lwp *);
1364#    endif
1365#    if (__FreeBSD_version >= 500024)
1366#      if (__FreeBSD_version >= 502116)
1367extern	int	iplopen(struct cdev*, int, int, struct thread *);
1368extern	int	iplclose(struct cdev*, int, int, struct thread *);
1369#      else
1370extern	int	iplopen(dev_t, int, int, struct thread *);
1371extern	int	iplclose(dev_t, int, int, struct thread *);
1372#      endif /* __FreeBSD_version >= 502116 */
1373#    else
1374#     if  (__NetBSD_Version__ >= 399001400)
1375extern	int	iplopen(dev_t, int, int, struct lwp *);
1376extern	int	iplclose(dev_t, int, int, struct lwp *);
1377#     else
1378extern	int	iplopen(dev_t, int, int, struct proc *);
1379extern	int	iplclose(dev_t, int, int, struct proc *);
1380#     endif /* __NetBSD_Version__ >= 399001400 */
1381#    endif /* __FreeBSD_version >= 500024 */
1382#   else
1383#    ifdef linux
1384extern	int	iplioctl(struct inode *, struct file *, u_int, u_long);
1385#    else
1386extern	int	iplopen(dev_t, int);
1387extern	int	iplclose(dev_t, int);
1388extern	int	iplioctl(dev_t, int, void *, int);
1389#    endif
1390#   endif /* (_BSDI_VERSION >= 199510) */
1391#   if defined(BSD) && (BSD >= 199306)
1392#      if (__FreeBSD_version >= 502116)
1393extern	int	iplread(struct cdev*, struct uio *, int);
1394extern	int	iplwrite(struct cdev*, struct uio *, int);
1395#      else
1396extern	int	iplread(dev_t, struct uio *, int);
1397extern	int	iplwrite(dev_t, struct uio *, int);
1398#      endif /* __FreeBSD_version >= 502116 */
1399#   else
1400#    ifndef linux
1401extern	int	iplread(dev_t, struct uio *);
1402extern	int	iplwrite(dev_t, struct uio *);
1403#    endif
1404#   endif /* BSD >= 199306 */
1405#  endif /* __ sgi */
1406# endif /* MENTAT */
1407
1408# if defined(__FreeBSD_version)
1409extern	int	ipf_pfil_hook(void);
1410extern	int	ipf_pfil_unhook(void);
1411extern	void	ipf_event_reg(void);
1412extern	void	ipf_event_dereg(void);
1413# endif
1414
1415#endif /* #ifndef _KERNEL */
1416
1417extern	ipfmutex_t	ipl_mutex, ipf_authmx, ipf_rw, ipf_hostmap;
1418extern	ipfmutex_t	ipf_timeoutlock, ipf_stinsert, ipf_natio, ipf_nat_new;
1419extern	ipfrwlock_t	ipf_mutex, ipf_global, ip_poolrw, ipf_ipidfrag;
1420extern	ipfrwlock_t	ipf_frag, ipf_state, ipf_nat, ipf_natfrag, ipf_auth;
1421extern	ipfrwlock_t	ipf_frcache, ipf_tokens;
1422
1423extern	char	*memstr(const char *, char *, size_t, size_t);
1424extern	int	count4bits(u_32_t);
1425extern	int	frrequest(int, ioctlcmd_t, void *, int, int);
1426extern	char	*getifname(struct ifnet *);
1427extern	int	ipfattach(void);
1428extern	int	ipfdetach(void);
1429extern	u_short	ipf_cksum(u_short *, int);
1430extern	int	copyinptr(void *, void *, size_t);
1431extern	int	copyoutptr(void *, void *, size_t);
1432extern	int	fr_fastroute(mb_t *, mb_t **, fr_info_t *, frdest_t *);
1433extern	int	fr_inobj(void *, ipfobj_t *, void *, int);
1434extern	int	fr_inobjsz(void *, void *, int, int);
1435extern	int	fr_ioctlswitch(int, void *, ioctlcmd_t, int, int, void *);
1436extern	int	fr_ipf_ioctl(void *, ioctlcmd_t, int, int, void *);
1437extern	int	fr_ipftune(ioctlcmd_t, void *);
1438extern	int	fr_outobj(void *, void *, int);
1439extern	int	fr_outobjk(ipfobj_t *, void *);
1440extern	int	fr_outobjsz(void *, void *, int, int);
1441extern	void	*fr_pullup(mb_t *, fr_info_t *, int);
1442extern	void	fr_resolvedest(struct frdest *, int);
1443extern	int	fr_resolvefunc(void *);
1444extern	void	*fr_resolvenic(char *, int);
1445extern	int	fr_send_icmp_err(int, fr_info_t *, int);
1446extern	int	fr_send_reset(fr_info_t *);
1447#if  (defined(__FreeBSD_version) && (__FreeBSD_version < 501000)) || \
1448    !defined(_KERNEL) || defined(linux)
1449extern	int	ppsratecheck(struct timeval *, int *, int);
1450#endif
1451extern	ipftq_t	*fr_addtimeoutqueue(ipftq_t **, u_int);
1452extern	void	fr_deletequeueentry(ipftqent_t *);
1453extern	int	fr_deletetimeoutqueue(ipftq_t *);
1454extern	void	fr_freetimeoutqueue(ipftq_t *);
1455extern	void	fr_movequeue(ipftqent_t *, ipftq_t *, ipftq_t *);
1456extern	void	fr_queueappend(ipftqent_t *, ipftq_t *, void *);
1457extern	void	fr_queueback(ipftqent_t *);
1458extern	void	fr_queuefront(ipftqent_t *);
1459extern	void	fr_checkv4sum(fr_info_t *);
1460extern	int	fr_checkl4sum(fr_info_t *);
1461extern	int	fr_ifpfillv4addr(int, struct sockaddr_in *,
1462				      struct sockaddr_in *, struct in_addr *,
1463				      struct in_addr *);
1464extern	int	fr_coalesce(fr_info_t *);
1465#ifdef	USE_INET6
1466extern	void	fr_checkv6sum(fr_info_t *);
1467extern	int	fr_ifpfillv6addr(int, struct sockaddr_in6 *,
1468				      struct sockaddr_in6 *, struct in_addr *,
1469				      struct in_addr *);
1470#endif
1471
1472extern	int		fr_addipftune(ipftuneable_t *);
1473extern	int		fr_delipftune(ipftuneable_t *);
1474
1475extern	int	frflush(minor_t, int, int);
1476extern	void	frsync(void *);
1477extern	frgroup_t *fr_addgroup(char *, void *, u_32_t, minor_t, int);
1478extern	int	fr_derefrule(frentry_t **);
1479extern	void	fr_delgroup(char *, minor_t, int);
1480extern	frgroup_t *fr_findgroup(char *, minor_t, int, frgroup_t ***);
1481
1482extern	int	fr_loginit(void);
1483extern	int	ipflog_canread(int);
1484extern	int	ipflog_clear(minor_t);
1485extern	int	ipflog_read(minor_t, uio_t *);
1486extern	int	ipflog(fr_info_t *, u_int);
1487extern	int	ipllog(int, fr_info_t *, void **, size_t *, int *, int);
1488extern	void	fr_logunload(void);
1489
1490extern	frentry_t	*fr_acctpkt(fr_info_t *, u_32_t *);
1491extern	int		fr_copytolog(int, char *, int);
1492extern	u_short		fr_cksum(mb_t *, ip_t *, int, void *, int);
1493extern	void		fr_deinitialise(void);
1494extern	frentry_t 	*fr_dolog(fr_info_t *, u_32_t *);
1495extern	frentry_t 	*fr_dstgrpmap(fr_info_t *, u_32_t *);
1496extern	void		fr_fixskip(frentry_t **, frentry_t *, int);
1497extern	void		fr_forgetifp(void *);
1498extern	frentry_t 	*fr_getrulen(int, char *, u_32_t);
1499extern	int		fr_ifpaddr(int, int, void *,
1500				struct in_addr *, struct in_addr *);
1501extern	int		fr_initialise(void);
1502extern	int		fr_lock(void *, int *);
1503extern  int		fr_makefrip(int, ip_t *, fr_info_t *);
1504extern	int		fr_matchtag(ipftag_t *, ipftag_t *);
1505extern	int		fr_matchicmpqueryreply(int, icmpinfo_t *,
1506					    struct icmp *, int);
1507extern	u_32_t		fr_newisn(fr_info_t *);
1508extern	u_short		fr_nextipid(fr_info_t *);
1509extern	int	ipf_queueflush(ipftq_delete_fn_t, ipftq_t *, ipftq_t *);
1510extern	int		fr_scanlist(fr_info_t *, u_32_t);
1511extern	frentry_t 	*fr_srcgrpmap(fr_info_t *, u_32_t *);
1512extern	int		fr_tcpudpchk(fr_info_t *, frtuc_t *);
1513extern	int		fr_verifysrc(fr_info_t *fin);
1514extern	int		fr_zerostats(void *);
1515extern	ipftoken_t	*ipf_findtoken(int, int, void *);
1516extern	void		ipf_dereftoken(ipftoken_t *);
1517extern	int		ipf_getnextrule(ipftoken_t *, void *);
1518extern	void		ipf_expiretokens(void);
1519extern	void		ipf_freetoken(ipftoken_t *);
1520extern	int		ipf_deltoken(int,int, void *);
1521extern	int		ipfsync(void);
1522extern	int		ipf_genericiter(void *, int, void *);
1523#ifndef ipf_random
1524extern	u_32_t		ipf_random(void);
1525#endif
1526#ifdef NEED_LOCAL_RAND
1527extern	void		ipf_rand_push(void *, int);
1528#endif
1529
1530extern	int	fr_running;
1531extern	u_long	fr_frouteok[2];
1532extern	int	fr_pass;
1533extern	int	fr_flags;
1534extern	int	fr_active;
1535extern	int	fr_chksrc;
1536extern	int	fr_minttl;
1537extern	int	fr_refcnt;
1538extern	int	fr_control_forwarding;
1539extern	int	fr_update_ipid;
1540extern	int	nat_logging;
1541extern	int	ipstate_logging;
1542extern	int	ipl_suppress;
1543extern	int	ipl_logmax;
1544extern	int	ipl_logall;
1545extern	int	ipl_logsize;
1546extern	u_long	fr_ticks;
1547extern	fr_info_t	frcache[2][8];
1548extern	char	ipfilter_version[];
1549extern	iplog_t	**iplh[IPL_LOGSIZE], *iplt[IPL_LOGSIZE];
1550extern	int	iplused[IPL_LOGMAX + 1];
1551extern	struct frentry *ipfilter[2][2], *ipacct[2][2];
1552#ifdef	USE_INET6
1553extern	struct frentry *ipfilter6[2][2], *ipacct6[2][2];
1554extern	int	icmptoicmp6types[ICMP_MAXTYPE+1];
1555extern	int	icmptoicmp6unreach[ICMP_MAX_UNREACH];
1556extern	int	icmpreplytype6[ICMP6_MAXTYPE + 1];
1557#endif
1558#ifdef	IPFILTER_COMPAT
1559extern	int	fr_in_compat(ipfobj_t *, void *);
1560extern	int	fr_out_compat(ipfobj_t *, void *);
1561#endif
1562extern	int	icmpreplytype4[ICMP_MAXTYPE + 1];
1563extern	struct frgroup *ipfgroups[IPL_LOGSIZE][2];
1564extern	struct filterstats frstats[];
1565extern	frentry_t *ipfrule_match(fr_info_t *);
1566extern	u_char	ipf_iss_secret[32];
1567extern	ipftuneable_t ipf_tuneables[];
1568
1569#endif /* _NETINET_IP_FIL_H_ */
1570