ip_fil.h revision 72006
1/*
2 * Copyright (C) 1993-2000 by Darren Reed.
3 *
4 * Redistribution and use in source and binary forms are permitted
5 * provided that this notice is preserved and due credit is given
6 * to the original author and the contributors.
7 *
8 * @(#)ip_fil.h	1.35 6/5/96
9 * $Id: ip_fil.h,v 2.29.2.4 2000/11/12 11:54:53 darrenr Exp $
10 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_fil.h 72006 2001-02-04 14:26:56Z darrenr $
11 */
12
13#ifndef	__IP_FIL_H__
14#define	__IP_FIL_H__
15
16/*
17 * Pathnames for various IP Filter control devices.  Used by LKM
18 * and userland, so defined here.
19 */
20#define	IPNAT_NAME	"/dev/ipnat"
21#define	IPSTATE_NAME	"/dev/ipstate"
22#define	IPAUTH_NAME	"/dev/ipauth"
23
24#ifndef	SOLARIS
25# define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
26#endif
27
28#if defined(KERNEL) && !defined(_KERNEL)
29# define	_KERNEL
30#endif
31
32#ifndef	__P
33# ifdef	__STDC__
34#  define	__P(x)	x
35# else
36#  define	__P(x)	()
37# endif
38#endif
39
40#if defined(__STDC__) || defined(__GNUC__)
41# define	SIOCADAFR	_IOW('r', 60, struct frentry *)
42# define	SIOCRMAFR	_IOW('r', 61, struct frentry *)
43# define	SIOCSETFF	_IOW('r', 62, u_int)
44# define	SIOCGETFF	_IOR('r', 63, u_int)
45# define	SIOCGETFS	_IOWR('r', 64, struct friostat *)
46# define	SIOCIPFFL	_IOWR('r', 65, int)
47# define	SIOCIPFFB	_IOR('r', 66, int)
48# define	SIOCADIFR	_IOW('r', 67, struct frentry *)
49# define	SIOCRMIFR	_IOW('r', 68, struct frentry *)
50# define	SIOCSWAPA	_IOR('r', 69, u_int)
51# define	SIOCINAFR	_IOW('r', 70, struct frentry *)
52# define	SIOCINIFR	_IOW('r', 71, struct frentry *)
53# define	SIOCFRENB	_IOW('r', 72, u_int)
54# define	SIOCFRSYN	_IOW('r', 73, u_int)
55# define	SIOCFRZST	_IOWR('r', 74, struct friostat *)
56# define	SIOCZRLST	_IOWR('r', 75, struct frentry *)
57# define	SIOCAUTHW	_IOWR('r', 76, struct fr_info *)
58# define	SIOCAUTHR	_IOWR('r', 77, struct fr_info *)
59# define	SIOCATHST	_IOWR('r', 78, struct fr_authstat *)
60# define	SIOCSTLCK	_IOWR('r', 79, u_int)
61# define	SIOCSTPUT	_IOWR('r', 80, struct ipstate_save *)
62# define	SIOCSTGET	_IOWR('r', 81, struct ipstate_save *)
63# define	SIOCSTGSZ	_IOWR('r', 82, struct natget *)
64# define	SIOCGFRST	_IOWR('r', 83, struct ipfrstat *)
65#else
66# define	SIOCADAFR	_IOW(r, 60, struct frentry *)
67# define	SIOCRMAFR	_IOW(r, 61, struct frentry *)
68# define	SIOCSETFF	_IOW(r, 62, u_int)
69# define	SIOCGETFF	_IOR(r, 63, u_int)
70# define	SIOCGETFS	_IOWR(r, 64, struct friostat *)
71# define	SIOCIPFFL	_IOWR(r, 65, int)
72# define	SIOCIPFFB	_IOR(r, 66, int)
73# define	SIOCADIFR	_IOW(r, 67, struct frentry *)
74# define	SIOCRMIFR	_IOW(r, 68, struct frentry *)
75# define	SIOCSWAPA	_IOR(r, 69, u_int)
76# define	SIOCINAFR	_IOW(r, 70, struct frentry *)
77# define	SIOCINIFR	_IOW(r, 71, struct frentry *)
78# define	SIOCFRENB	_IOW(r, 72, u_int)
79# define	SIOCFRSYN	_IOW(r, 73, u_int)
80# define	SIOCFRZST	_IOWR(r, 74, struct friostat *)
81# define	SIOCZRLST	_IOWR(r, 75, struct frentry *)
82# define	SIOCAUTHW	_IOWR(r, 76, struct fr_info *)
83# define	SIOCAUTHR	_IOWR(r, 77, struct fr_info *)
84# define	SIOCATHST	_IOWR(r, 78, struct fr_authstat *)
85# define	SIOCSTLCK	_IOWR(r, 79, u_int)
86# define	SIOCSTPUT	_IOWR(r, 80, struct ipstate_save *)
87# define	SIOCSTGET	_IOWR(r, 81, struct ipstate_save *)
88# define	SIOCSTGSZ	_IOWR(r, 82, struct natget *)
89# define	SIOCGFRST	_IOWR(r, 83, struct ipfrstat *)
90#endif
91#define	SIOCADDFR	SIOCADAFR
92#define	SIOCDELFR	SIOCRMAFR
93#define	SIOCINSFR	SIOCINAFR
94
95
96typedef	struct	fr_ip	{
97	u_32_t	fi_v:4;		/* IP version */
98	u_32_t	fi_fl:4;	/* packet flags */
99	u_32_t	fi_tos:8;	/* IP packet TOS */
100	u_32_t	fi_ttl:8;	/* IP packet TTL */
101	u_32_t	fi_p:8;		/* IP packet protocol */
102	union	i6addr fi_src;	/* source address from packet */
103	union	i6addr fi_dst;	/* destination address from packet */
104	u_32_t	fi_optmsk;	/* bitmask composed from IP options */
105	u_short	fi_secmsk;	/* bitmask composed from IP security options */
106	u_short	fi_auth;	/* authentication code from IP sec. options */
107} fr_ip_t;
108
109#define	FI_OPTIONS	(FF_OPTIONS >> 24)
110#define	FI_TCPUDP	(FF_TCPUDP >> 24)	/* TCP/UCP implied comparison*/
111#define	FI_FRAG		(FF_FRAG >> 24)
112#define	FI_SHORT	(FF_SHORT >> 24)
113#define	FI_CMP		(FI_OPTIONS|FI_TCPUDP|FI_SHORT)
114
115#define	fi_saddr	fi_src.in4.s_addr
116#define	fi_daddr	fi_dst.in4.s_addr
117
118
119/*
120 * These are both used by the state and NAT code to indicate that one port or
121 * the other should be treated as a wildcard.
122 */
123#define	FI_W_SPORT	0x00000100
124#define	FI_W_DPORT	0x00000200
125#define	FI_WILDP	(FI_W_SPORT|FI_W_DPORT)
126#define	FI_W_SADDR	0x00000400
127#define	FI_W_DADDR	0x00000800
128#define	FI_WILDA	(FI_W_SADDR|FI_W_DADDR)
129#define	FI_NEWFR	0x00001000
130
131typedef	struct	fr_info	{
132	void	*fin_ifp;		/* interface packet is `on' */
133	struct	fr_ip	fin_fi;		/* IP Packet summary */
134	u_short	fin_data[2];		/* TCP/UDP ports, ICMP code/type */
135	u_char	fin_out;		/* in or out ? 1 == out, 0 == in */
136	u_char	fin_rev;		/* state only: 1 = reverse */
137	u_short	fin_hlen;		/* length of IP header in bytes */
138	u_char	fin_tcpf;		/* TCP header flags (SYN, ACK, etc) */
139	/* From here on is packet specific */
140	u_char	fin_icode;		/* ICMP error to return */
141	u_short	fin_rule;		/* rule # last matched */
142	u_32_t	fin_group;		/* group number, -1 for none */
143	struct	frentry *fin_fr;	/* last matching rule */
144	char	*fin_dp;		/* start of data past IP header */
145	u_short	fin_dlen;		/* length of data portion of packet */
146	u_short	fin_id;			/* IP packet id field */
147	void	*fin_mp;		/* pointer to pointer to mbuf */
148#if SOLARIS
149	void	*fin_qfm;		/* pointer to mblk where pkt starts */
150	void	*fin_qif;
151#endif
152	u_short	fin_plen;
153	u_short	fin_off;
154} fr_info_t;
155
156#define	fin_v	fin_fi.fi_v
157
158/*
159 * Size for compares on fr_info structures
160 */
161#define	FI_CSIZE	offsetof(fr_info_t, fin_icode)
162
163/*
164 * Size for copying cache fr_info structure
165 */
166#define	FI_COPYSIZE	offsetof(fr_info_t, fin_dp)
167
168typedef	struct	frdest	{
169	void	*fd_ifp;
170	struct	in_addr	fd_ip;
171	char	fd_ifname[IFNAMSIZ];
172} frdest_t;
173
174typedef	struct	frpcmp	{
175	int	frp_cmp;	/* data for port comparisons */
176	u_short	frp_port;	/* top port for <> and >< */
177	u_short	frp_top;	/* top port for <> and >< */
178} frpcmp_t;
179
180typedef	struct	frtuc	{
181	u_char	ftu_tcpfm;	/* tcp flags mask */
182	u_char	ftu_tcpf;	/* tcp flags */
183	frpcmp_t	ftu_src;
184	frpcmp_t	ftu_dst;
185} frtuc_t;
186
187#define	ftu_scmp	ftu_src.frp_cmp
188#define	ftu_dcmp	ftu_dst.frp_cmp
189#define	ftu_sport	ftu_src.frp_port
190#define	ftu_dport	ftu_dst.frp_port
191#define	ftu_stop	ftu_src.frp_top
192#define	ftu_dtop	ftu_dst.frp_top
193
194typedef	struct	frentry {
195	struct	frentry	*fr_next;
196	u_32_t	fr_group;	/* group to which this rule belongs */
197	u_32_t	fr_grhead;	/* group # which this rule starts */
198	struct	frentry	*fr_grp;
199	int	fr_ref;		/* reference count - for grouping */
200	void	*fr_ifa;
201#if BSD >= 199306
202	void	*fr_oifa;
203#endif
204	/*
205	 * These are only incremented when a packet  matches this rule and
206	 * it is the last match
207	 */
208	U_QUAD_T	fr_hits;
209	U_QUAD_T	fr_bytes;
210	/*
211	 * Fields after this may not change whilst in the kernel.
212	 */
213	struct	fr_ip	fr_ip;
214	struct	fr_ip	fr_mip;	/* mask structure */
215
216
217	u_short	fr_icmpm;	/* data for ICMP packets (mask) */
218	u_short	fr_icmp;
219
220	frtuc_t	fr_tuc;
221	u_32_t	fr_flags;	/* per-rule flags && options (see below) */
222	u_int	fr_skip;	/* # of rules to skip */
223	u_int	fr_loglevel;	/* syslog log facility + priority */
224	int	(*fr_func) __P((int, ip_t *, fr_info_t *));	/* call this function */
225	int	fr_sap;		/* For solaris only */
226	u_char	fr_icode;	/* return ICMP code */
227	char	fr_ifname[IFNAMSIZ];
228#if BSD >= 199306
229	char	fr_oifname[IFNAMSIZ];
230#endif
231	struct	frdest	fr_tif;	/* "to" interface */
232	struct	frdest	fr_dif;	/* duplicate packet interfaces */
233	u_int	fr_cksum;	/* checksum on filter rules for performance */
234} frentry_t;
235
236#define	fr_v		fr_ip.fi_v
237#define	fr_proto	fr_ip.fi_p
238#define	fr_ttl		fr_ip.fi_ttl
239#define	fr_tos		fr_ip.fi_tos
240#define	fr_tcpfm	fr_tuc.ftu_tcpfm
241#define	fr_tcpf		fr_tuc.ftu_tcpf
242#define	fr_scmp		fr_tuc.ftu_scmp
243#define	fr_dcmp		fr_tuc.ftu_dcmp
244#define	fr_dport	fr_tuc.ftu_dport
245#define	fr_sport	fr_tuc.ftu_sport
246#define	fr_stop		fr_tuc.ftu_stop
247#define	fr_dtop		fr_tuc.ftu_dtop
248#define	fr_dst		fr_ip.fi_dst.in4
249#define	fr_src		fr_ip.fi_src.in4
250#define	fr_dmsk		fr_mip.fi_dst.in4
251#define	fr_smsk		fr_mip.fi_src.in4
252
253#ifndef	offsetof
254#define	offsetof(t,m)	(int)((&((t *)0L)->m))
255#endif
256#define	FR_CMPSIZ	(sizeof(struct frentry) - offsetof(frentry_t, fr_ip))
257
258/*
259 * fr_flags
260 */
261#define	FR_BLOCK	0x00001	/* do not allow packet to pass */
262#define	FR_PASS		0x00002	/* allow packet to pass */
263#define	FR_OUTQUE	0x00004	/* outgoing packets */
264#define	FR_INQUE	0x00008	/* ingoing packets */
265#define	FR_LOG		0x00010	/* Log */
266#define	FR_LOGB		0x00011	/* Log-fail */
267#define	FR_LOGP		0x00012	/* Log-pass */
268#define	FR_LOGBODY	0x00020	/* Log the body */
269#define	FR_LOGFIRST	0x00040	/* Log the first byte if state held */
270#define	FR_RETRST	0x00080	/* Return TCP RST packet - reset connection */
271#define	FR_RETICMP	0x00100	/* Return ICMP unreachable packet */
272#define	FR_FAKEICMP	0x00180	/* Return ICMP unreachable with fake source */
273#define	FR_NOMATCH	0x00200	/* no match occured */
274#define	FR_ACCOUNT	0x00400	/* count packet bytes */
275#define	FR_KEEPFRAG	0x00800	/* keep fragment information */
276#define	FR_KEEPSTATE	0x01000	/* keep `connection' state information */
277#define	FR_INACTIVE	0x02000
278#define	FR_QUICK	0x04000	/* match & stop processing list */
279#define	FR_FASTROUTE	0x08000	/* bypass normal routing */
280#define	FR_CALLNOW	0x10000	/* call another function (fr_func) if matches */
281#define	FR_DUP		0x20000	/* duplicate packet */
282#define	FR_LOGORBLOCK	0x40000	/* block the packet if it can't be logged */
283#define	FR_NOTSRCIP	0x80000	/* not the src IP# */
284#define	FR_NOTDSTIP	0x100000	/* not the dst IP# */
285#define	FR_AUTH		0x200000	/* use authentication */
286#define	FR_PREAUTH	0x400000	/* require preauthentication */
287#define	FR_DONTCACHE	0x800000	/* don't cache the result */
288
289#define	FR_LOGMASK	(FR_LOG|FR_LOGP|FR_LOGB)
290#define	FR_RETMASK	(FR_RETICMP|FR_RETRST|FR_FAKEICMP)
291
292/*
293 * These correspond to #define's for FI_* and are stored in fr_flags
294 */
295#define	FF_OPTIONS	0x01000000
296#define	FF_TCPUDP	0x02000000
297#define	FF_FRAG		0x04000000
298#define	FF_SHORT	0x08000000
299/*
300 * recognized flags for SIOCGETFF and SIOCSETFF, and get put in fr_flags
301 */
302#define	FF_LOGPASS	0x10000000
303#define	FF_LOGBLOCK	0x20000000
304#define	FF_LOGNOMATCH	0x40000000
305#define	FF_LOGGING	(FF_LOGPASS|FF_LOGBLOCK|FF_LOGNOMATCH)
306#define	FF_BLOCKNONIP	0x80000000	/* Solaris2 Only */
307
308#define	FR_NONE 0
309#define	FR_EQUAL 1
310#define	FR_NEQUAL 2
311#define FR_LESST 3
312#define FR_GREATERT 4
313#define FR_LESSTE 5
314#define FR_GREATERTE 6
315#define	FR_OUTRANGE 7
316#define	FR_INRANGE 8
317
318typedef	struct	filterstats {
319	u_long	fr_pass;	/* packets allowed */
320	u_long	fr_block;	/* packets denied */
321	u_long	fr_nom;		/* packets which don't match any rule */
322	u_long	fr_short;	/* packets which are short */
323	u_long	fr_ppkl;	/* packets allowed and logged */
324	u_long	fr_bpkl;	/* packets denied and logged */
325	u_long	fr_npkl;	/* packets unmatched and logged */
326	u_long	fr_pkl;		/* packets logged */
327	u_long	fr_skip;	/* packets to be logged but buffer full */
328	u_long	fr_ret;		/* packets for which a return is sent */
329	u_long	fr_acct;	/* packets for which counting was performed */
330	u_long	fr_bnfr;	/* bad attempts to allocate fragment state */
331	u_long	fr_nfr;		/* new fragment state kept */
332	u_long	fr_cfr;		/* add new fragment state but complete pkt */
333	u_long	fr_bads;	/* bad attempts to allocate packet state */
334	u_long	fr_ads;		/* new packet state kept */
335	u_long	fr_chit;	/* cached hit */
336	u_long	fr_tcpbad;	/* TCP checksum check failures */
337	u_long	fr_pull[2];	/* good and bad pullup attempts */
338	u_long	fr_badsrc;	/* source received doesn't match route */
339	u_long	fr_badttl;	/* TTL in packet doesn't reach minimum */
340#if SOLARIS
341	u_long	fr_notdata;	/* PROTO/PCPROTO that have no data */
342	u_long	fr_nodata;	/* mblks that have no data */
343	u_long	fr_bad;		/* bad IP packets to the filter */
344	u_long	fr_notip;	/* packets passed through no on ip queue */
345	u_long	fr_drop;	/* packets dropped - no info for them! */
346	u_long	fr_copy;	/* messages copied due to db_ref > 1 */
347#endif
348	u_long	fr_ipv6[2];	/* IPv6 packets in/out */
349} filterstats_t;
350
351/*
352 * For SIOCGETFS
353 */
354typedef	struct	friostat	{
355	struct	filterstats	f_st[2];
356	struct	frentry		*f_fin[2];
357	struct	frentry		*f_fout[2];
358	struct	frentry		*f_acctin[2];
359	struct	frentry		*f_acctout[2];
360	struct	frentry		*f_fin6[2];
361	struct	frentry		*f_fout6[2];
362	struct	frentry		*f_acctin6[2];
363	struct	frentry		*f_acctout6[2];
364	struct	frentry		*f_auth;
365	struct	frgroup		*f_groups[3][2];
366	u_long	f_froute[2];
367	int	f_defpass;	/* default pass - from fr_pass */
368	char	f_active;	/* 1 or 0 - active rule set */
369	char	f_running;	/* 1 if running, else 0 */
370	char	f_logging;	/* 1 if enabled, else 0 */
371	char	f_version[32];	/* version string */
372	int	f_locks[4];
373} friostat_t;
374
375typedef struct	optlist {
376	u_short ol_val;
377	int	ol_bit;
378} optlist_t;
379
380
381/*
382 * Group list structure.
383 */
384typedef	struct frgroup {
385	u_32_t	fg_num;
386	struct	frgroup	*fg_next;
387	struct	frentry	*fg_head;
388	struct	frentry	**fg_start;
389} frgroup_t;
390
391
392/*
393 * Log structure.  Each packet header logged is prepended by one of these.
394 * Following this in the log records read from the device will be an ipflog
395 * structure which is then followed by any packet data.
396 */
397typedef	struct	iplog	{
398	u_32_t	ipl_magic;
399	u_int	ipl_count;
400	u_long	ipl_sec;
401	u_long	ipl_usec;
402	size_t	ipl_dsize;
403	struct	iplog	*ipl_next;
404} iplog_t;
405
406#define IPL_MAGIC 0x49504c4d /* 'IPLM' */
407
408typedef	struct	ipflog	{
409#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \
410        (defined(OpenBSD) && (OpenBSD >= 199603))
411	u_char	fl_ifname[IFNAMSIZ];
412#else
413	u_int	fl_unit;
414	u_char	fl_ifname[4];
415#endif
416	u_char	fl_plen;	/* extra data after hlen */
417	u_char	fl_hlen;	/* length of IP headers saved */
418	u_short	fl_loglevel;	/* syslog log level */
419	u_32_t	fl_rule;
420	u_32_t	fl_group;
421	u_32_t	fl_flags;
422	u_32_t	fl_lflags;
423} ipflog_t;
424
425
426#ifndef	ICMP_UNREACH_FILTER
427# define	ICMP_UNREACH_FILTER	13
428#endif
429
430#ifndef	IPF_LOGGING
431# define	IPF_LOGGING	0
432#endif
433#ifndef	IPF_DEFAULT_PASS
434# define	IPF_DEFAULT_PASS	FR_PASS
435#endif
436
437#define	IPMINLEN(i, h)	((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h)))
438#define	IPLLOGSIZE	8192
439
440/*
441 * Device filenames for reading log information.  Use ipf on Solaris2 because
442 * ipl is already a name used by something else.
443 */
444#ifndef	IPL_NAME
445# if	SOLARIS
446#  define	IPL_NAME	"/dev/ipf"
447# else
448#  define	IPL_NAME	"/dev/ipl"
449# endif
450#endif
451#define	IPL_NAT		IPNAT_NAME
452#define	IPL_STATE	IPSTATE_NAME
453#define	IPL_AUTH	IPAUTH_NAME
454
455#define	IPL_LOGIPF	0	/* Minor device #'s for accessing logs */
456#define	IPL_LOGNAT	1
457#define	IPL_LOGSTATE	2
458#define	IPL_LOGAUTH	3
459#define	IPL_LOGMAX	3
460
461#if !defined(CDEV_MAJOR) && defined (__FreeBSD_version) && \
462    (__FreeBSD_version >= 220000)
463# define	CDEV_MAJOR	79
464#endif
465
466/*
467 * Post NetBSD 1.2 has the PFIL interface for packet filters.  This turns
468 * on those hooks.  We don't need any special mods in non-IP Filter code
469 * with this!
470 */
471#if (defined(NetBSD) && (NetBSD > 199609) && (NetBSD <= 1991011)) || \
472    (defined(NetBSD1_2) && NetBSD1_2 > 1) || (defined(__FreeBSD_version) && \
473     (__FreeBSD_version >= 500011))
474# if (NetBSD >= 199905)
475#  define PFIL_HOOKS
476# endif
477# ifdef PFIL_HOOKS
478#  define NETBSD_PF
479# endif
480#endif
481
482
483#ifndef	_KERNEL
484struct ifnet;
485extern	int	fr_check __P((ip_t *, int, void *, int, mb_t **));
486extern	int	(*fr_checkp) __P((ip_t *, int, void *, int, mb_t **));
487extern	int	send_reset __P((ip_t *, struct ifnet *));
488extern	int	icmp_error __P((ip_t *, struct ifnet *));
489extern	int	ipf_log __P((void));
490extern	int	ipfr_fastroute __P((ip_t *, fr_info_t *, frdest_t *));
491extern	struct	ifnet *get_unit __P((char *, int));
492# if defined(__NetBSD__) || defined(__OpenBSD__) || \
493	  (_BSDI_VERSION >= 199701) || (__FreeBSD_version >= 300000)
494extern	int	iplioctl __P((dev_t, u_long, caddr_t, int));
495# else
496extern	int	iplioctl __P((dev_t, int, caddr_t, int));
497# endif
498extern	int	iplopen __P((dev_t, int));
499extern	int	iplclose __P((dev_t, int));
500#else /* #ifndef _KERNEL */
501# if defined(__NetBSD__) && defined(PFIL_HOOKS)
502extern	void	ipfilterattach __P((int));
503# endif
504extern	int	iplattach __P((void));
505extern	int	ipl_enable __P((void));
506extern	int	ipl_disable __P((void));
507extern	void	ipflog_init __P((void));
508extern	int	ipflog_clear __P((minor_t));
509extern	int	ipflog_read __P((minor_t, struct uio *));
510extern	int	ipflog __P((u_int, ip_t *, fr_info_t *, mb_t *));
511extern	int	ipllog __P((int, fr_info_t *, void **, size_t *, int *, int));
512extern	int	send_icmp_err __P((ip_t *, int, fr_info_t *, int));
513extern	int	send_reset __P((ip_t *, fr_info_t *));
514# if	SOLARIS
515extern	int	fr_check __P((ip_t *, int, void *, int, qif_t *, mb_t **));
516extern	int	(*fr_checkp) __P((ip_t *, int, void *,
517				  int, qif_t *, mb_t **));
518#  if SOLARIS2 >= 7
519extern	int	iplioctl __P((dev_t, int, intptr_t, int, cred_t *, int *));
520#  else
521extern	int	iplioctl __P((dev_t, int, int *, int, cred_t *, int *));
522#  endif
523extern	int	iplopen __P((dev_t *, int, int, cred_t *));
524extern	int	iplclose __P((dev_t, int, int, cred_t *));
525extern	int	ipfsync __P((void));
526extern	int	ipfr_fastroute __P((ip_t *, mblk_t *, mblk_t **,
527				    fr_info_t *, frdest_t *));
528extern	void	copyin_mblk __P((mblk_t *, size_t, size_t, char *));
529extern	void	copyout_mblk __P((mblk_t *, size_t, size_t, char *));
530extern	int	fr_qin __P((queue_t *, mblk_t *));
531extern	int	fr_qout __P((queue_t *, mblk_t *));
532extern	int	iplread __P((dev_t, struct uio *, cred_t *));
533# else /* SOLARIS */
534extern	int	fr_check __P((ip_t *, int, void *, int, mb_t **));
535extern	int	(*fr_checkp) __P((ip_t *, int, void *, int, mb_t **));
536extern	int	ipfr_fastroute __P((mb_t *, fr_info_t *, frdest_t *));
537extern	size_t	mbufchainlen __P((mb_t *));
538#  ifdef	__sgi
539#   include <sys/cred.h>
540extern	int	iplioctl __P((dev_t, int, caddr_t, int, cred_t *, int *));
541extern	int	iplopen __P((dev_t *, int, int, cred_t *));
542extern	int	iplclose __P((dev_t, int, int, cred_t *));
543extern	int	iplread __P((dev_t, struct uio *, cred_t *));
544extern	int	ipfsync __P((void));
545extern	int	ipfilter_sgi_attach __P((void));
546extern	void	ipfilter_sgi_detach __P((void));
547extern	void	ipfilter_sgi_intfsync __P((void));
548#  else
549#   ifdef	IPFILTER_LKM
550extern	int	iplidentify __P((char *));
551#   endif
552#   if (_BSDI_VERSION >= 199510) || (__FreeBSD_version >= 220000) || \
553      (NetBSD >= 199511) || defined(__OpenBSD__)
554#    if defined(__NetBSD__) || (_BSDI_VERSION >= 199701) || \
555       defined(__OpenBSD__) || (__FreeBSD_version >= 300000)
556extern	int	iplioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
557#    else
558extern	int	iplioctl __P((dev_t, int, caddr_t, int, struct proc *));
559#    endif
560extern	int	iplopen __P((dev_t, int, int, struct proc *));
561extern	int	iplclose __P((dev_t, int, int, struct proc *));
562#   else
563#    ifndef	linux
564extern	int	iplopen __P((dev_t, int));
565extern	int	iplclose __P((dev_t, int));
566extern	int	iplioctl __P((dev_t, int, caddr_t, int));
567#    else
568extern	int	iplioctl(struct inode *, struct file *, u_int, u_long);
569extern	int	iplopen __P((struct inode *, struct file *));
570extern	void	iplclose __P((struct inode *, struct file *));
571#    endif /* !linux */
572#   endif /* (_BSDI_VERSION >= 199510) */
573#   if	BSD >= 199306
574extern	int	iplread __P((dev_t, struct uio *, int));
575#   else
576#    ifndef linux
577extern	int	iplread __P((dev_t, struct uio *));
578#    else
579extern	int	iplread(struct inode *, struct file *, char *, int);
580#    endif /* !linux */
581#   endif /* BSD >= 199306 */
582#  endif /* __ sgi */
583# endif /* SOLARIS */
584#endif /* #ifndef _KERNEL */
585
586extern	char	*memstr __P((char *, char *, int, int));
587extern	void	fixskip __P((frentry_t **, frentry_t *, int));
588extern	int	countbits __P((u_32_t));
589extern	int	ipldetach __P((void));
590extern	u_short	ipf_cksum __P((u_short *, int));
591extern	int	ircopyptr __P((void *, void *, size_t));
592extern	int	iwcopyptr __P((void *, void *, size_t));
593
594extern	int	frflush __P((minor_t, int));
595extern	void	frsync __P((void));
596extern	frgroup_t *fr_addgroup __P((u_32_t, frentry_t *, minor_t, int));
597extern	void	fr_delgroup __P((u_32_t, u_32_t, minor_t, int));
598extern	frgroup_t *fr_findgroup __P((u_32_t, u_32_t, minor_t, int,
599				    frgroup_t ***));
600
601extern	int	fr_copytolog __P((int, char *, int));
602extern	void	fr_forgetifp __P((void *));
603extern	void	fr_getstat __P((struct friostat *));
604extern	int	fr_ifpaddr __P((int, void *, struct in_addr *));
605extern	int	fr_lock __P((caddr_t, int *));
606extern  void	fr_makefrip __P((int, ip_t *, fr_info_t *));
607extern	u_short	fr_tcpsum __P((mb_t *, ip_t *, tcphdr_t *));
608extern	int	fr_scanlist __P((u_32_t, ip_t *, fr_info_t *, void *));
609extern	int	fr_tcpudpchk __P((frtuc_t *, fr_info_t *));
610extern	int	fr_verifysrc __P((struct in_addr, void *));
611
612extern	int	ipl_unreach;
613extern	int	fr_running;
614extern	u_long	ipl_frouteok[2];
615extern	int	fr_pass;
616extern	int	fr_flags;
617extern	int	fr_active;
618extern	int	fr_chksrc;
619extern	int	fr_minttl;
620extern	int	fr_minttllog;
621extern	fr_info_t	frcache[2];
622extern	char	ipfilter_version[];
623extern	iplog_t	**iplh[IPL_LOGMAX+1], *iplt[IPL_LOGMAX+1];
624extern	size_t	iplused[IPL_LOGMAX + 1];
625extern	struct frentry *ipfilter[2][2], *ipacct[2][2];
626#ifdef	USE_INET6
627extern	struct frentry *ipfilter6[2][2], *ipacct6[2][2];
628extern	int	icmptoicmp6types[ICMP_MAXTYPE+1];
629extern	int	icmptoicmp6unreach[ICMP_MAX_UNREACH];
630#endif
631extern	struct frgroup *ipfgroups[3][2];
632extern	struct filterstats frstats[];
633
634#endif	/* __IP_FIL_H__ */
635