ip_fw.h revision 146894
1193267Sjkim/*-
2193267Sjkim * Copyright (c) 2002 Luigi Rizzo, Universita` di Pisa
3193267Sjkim *
4193267Sjkim * Redistribution and use in source and binary forms, with or without
5193267Sjkim * modification, are permitted provided that the following conditions
6193267Sjkim * are met:
7316303Sjkim * 1. Redistributions of source code must retain the above copyright
8316303Sjkim *    notice, this list of conditions and the following disclaimer.
9316303Sjkim * 2. Redistributions in binary form must reproduce the above copyright
10316303Sjkim *    notice, this list of conditions and the following disclaimer in the
11316303Sjkim *    documentation and/or other materials provided with the distribution.
12193267Sjkim *
13193267Sjkim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14316303Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16316303Sjkim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17316303Sjkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18316303Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19316303Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20316303Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21316303Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22316303Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23316303Sjkim * SUCH DAMAGE.
24316303Sjkim *
25316303Sjkim * $FreeBSD: head/sys/netinet/ip_fw.h 146894 2005-06-03 01:10:28Z mlaier $
26316303Sjkim */
27316303Sjkim
28316303Sjkim#ifndef _IPFW2_H
29316303Sjkim#define _IPFW2_H
30316303Sjkim
31316303Sjkim/*
32316303Sjkim * The kernel representation of ipfw rules is made of a list of
33316303Sjkim * 'instructions' (for all practical purposes equivalent to BPF
34316303Sjkim * instructions), which specify which fields of the packet
35316303Sjkim * (or its metadata) should be analysed.
36316303Sjkim *
37316303Sjkim * Each instruction is stored in a structure which begins with
38316303Sjkim * "ipfw_insn", and can contain extra fields depending on the
39316303Sjkim * instruction type (listed below).
40316303Sjkim * Note that the code is written so that individual instructions
41316303Sjkim * have a size which is a multiple of 32 bits. This means that, if
42316303Sjkim * such structures contain pointers or other 64-bit entities,
43316303Sjkim * (there is just one instance now) they may end up unaligned on
44316303Sjkim * 64-bit architectures, so the must be handled with care.
45316303Sjkim *
46316303Sjkim * "enum ipfw_opcodes" are the opcodes supported. We can have up
47316303Sjkim * to 256 different opcodes. When adding new opcodes, they should
48316303Sjkim * be appended to the end of the opcode list before O_LAST_OPCODE,
49316303Sjkim * this will prevent the ABI from being broken, otherwise users
50316303Sjkim * will have to recompile ipfw(8) when they update the kernel.
51316303Sjkim */
52316303Sjkim
53316303Sjkimenum ipfw_opcodes {		/* arguments (4 byte each)	*/
54316303Sjkim	O_NOP,
55316303Sjkim
56316303Sjkim	O_IP_SRC,		/* u32 = IP			*/
57316303Sjkim	O_IP_SRC_MASK,		/* ip = IP/mask			*/
58316303Sjkim	O_IP_SRC_ME,		/* none				*/
59316303Sjkim	O_IP_SRC_SET,		/* u32=base, arg1=len, bitmap	*/
60316303Sjkim
61316303Sjkim	O_IP_DST,		/* u32 = IP			*/
62316303Sjkim	O_IP_DST_MASK,		/* ip = IP/mask			*/
63316303Sjkim	O_IP_DST_ME,		/* none				*/
64316303Sjkim	O_IP_DST_SET,		/* u32=base, arg1=len, bitmap	*/
65316303Sjkim
66316303Sjkim	O_IP_SRCPORT,		/* (n)port list:mask 4 byte ea	*/
67316303Sjkim	O_IP_DSTPORT,		/* (n)port list:mask 4 byte ea	*/
68316303Sjkim	O_PROTO,		/* arg1=protocol		*/
69316303Sjkim
70316303Sjkim	O_MACADDR2,		/* 2 mac addr:mask		*/
71316303Sjkim	O_MAC_TYPE,		/* same as srcport		*/
72316303Sjkim
73316303Sjkim	O_LAYER2,		/* none				*/
74316303Sjkim	O_IN,			/* none				*/
75316303Sjkim	O_FRAG,			/* none				*/
76316303Sjkim
77316303Sjkim	O_RECV,			/* none				*/
78316303Sjkim	O_XMIT,			/* none				*/
79316303Sjkim	O_VIA,			/* none				*/
80316303Sjkim
81316303Sjkim	O_IPOPT,		/* arg1 = 2*u8 bitmap		*/
82316303Sjkim	O_IPLEN,		/* arg1 = len			*/
83316303Sjkim	O_IPID,			/* arg1 = id			*/
84316303Sjkim
85316303Sjkim	O_IPTOS,		/* arg1 = id			*/
86316303Sjkim	O_IPPRECEDENCE,		/* arg1 = precedence << 5	*/
87316303Sjkim	O_IPTTL,		/* arg1 = TTL			*/
88316303Sjkim
89316303Sjkim	O_IPVER,		/* arg1 = version		*/
90316303Sjkim	O_UID,			/* u32 = id			*/
91316303Sjkim	O_GID,			/* u32 = id			*/
92316303Sjkim	O_ESTAB,		/* none (tcp established)	*/
93316303Sjkim	O_TCPFLAGS,		/* arg1 = 2*u8 bitmap		*/
94316303Sjkim	O_TCPWIN,		/* arg1 = desired win		*/
95316303Sjkim	O_TCPSEQ,		/* u32 = desired seq.		*/
96316303Sjkim	O_TCPACK,		/* u32 = desired seq.		*/
97316303Sjkim	O_ICMPTYPE,		/* u32 = icmp bitmap		*/
98316303Sjkim	O_TCPOPTS,		/* arg1 = 2*u8 bitmap		*/
99316303Sjkim
100316303Sjkim	O_VERREVPATH,		/* none				*/
101316303Sjkim	O_VERSRCREACH,		/* none				*/
102316303Sjkim
103316303Sjkim	O_PROBE_STATE,		/* none				*/
104316303Sjkim	O_KEEP_STATE,		/* none				*/
105316303Sjkim	O_LIMIT,		/* ipfw_insn_limit		*/
106316303Sjkim	O_LIMIT_PARENT,		/* dyn_type, not an opcode.	*/
107316303Sjkim
108316303Sjkim	/*
109316303Sjkim	 * These are really 'actions'.
110316303Sjkim	 */
111316303Sjkim
112316303Sjkim	O_LOG,			/* ipfw_insn_log		*/
113316303Sjkim	O_PROB,			/* u32 = match probability	*/
114316303Sjkim
115316303Sjkim	O_CHECK_STATE,		/* none				*/
116316303Sjkim	O_ACCEPT,		/* none				*/
117316303Sjkim	O_DENY,			/* none 			*/
118316303Sjkim	O_REJECT,		/* arg1=icmp arg (same as deny)	*/
119217365Sjkim	O_COUNT,		/* none				*/
120217365Sjkim	O_SKIPTO,		/* arg1=next rule number	*/
121217365Sjkim	O_PIPE,			/* arg1=pipe number		*/
122217365Sjkim	O_QUEUE,		/* arg1=queue number		*/
123217365Sjkim	O_DIVERT,		/* arg1=port number		*/
124217365Sjkim	O_TEE,			/* arg1=port number		*/
125217365Sjkim	O_FORWARD_IP,		/* fwd sockaddr			*/
126217365Sjkim	O_FORWARD_MAC,		/* fwd mac			*/
127217365Sjkim
128217365Sjkim	/*
129217365Sjkim	 * More opcodes.
130217365Sjkim	 */
131217365Sjkim	O_IPSEC,		/* has ipsec history 		*/
132217365Sjkim	O_IP_SRC_LOOKUP,	/* arg1=table number, u32=value	*/
133193267Sjkim	O_IP_DST_LOOKUP,	/* arg1=table number, u32=value	*/
134316303Sjkim	O_ANTISPOOF,		/* none				*/
135316303Sjkim	O_JAIL,			/* u32 = id			*/
136316303Sjkim	O_ALTQ,			/* u32 = altq classif. qid	*/
137316303Sjkim	O_DIVERTED,		/* arg1=bitmap (1:loop, 2:out)	*/
138316303Sjkim	O_TCPDATALEN,		/* arg1 = tcp data len		*/
139316303Sjkim	O_IP6_SRC,		/* address without mask		*/
140316303Sjkim	O_IP6_SRC_ME,		/* my addresses			*/
141316303Sjkim	O_IP6_SRC_MASK,		/* address with the mask	*/
142316303Sjkim	O_IP6_DST,
143316303Sjkim	O_IP6_DST_ME,
144316303Sjkim	O_IP6_DST_MASK,
145316303Sjkim	O_FLOW6ID,		/* for flow id tag in the ipv6 pkt */
146316303Sjkim	O_ICMP6TYPE,		/* icmp6 packet type filtering	*/
147217365Sjkim	O_EXT_HDR,		/* filtering for ipv6 extension header */
148217365Sjkim	O_IP6,
149193267Sjkim
150316303Sjkim	/*
151193267Sjkim	 * actions for ng_ipfw
152193267Sjkim	 */
153193267Sjkim	O_NETGRAPH,		/* send to ng_ipfw		*/
154193267Sjkim	O_NGTEE,		/* copy to ng_ipfw		*/
155193267Sjkim
156193267Sjkim	O_IP4,
157193267Sjkim
158193267Sjkim	O_LAST_OPCODE		/* not an opcode!		*/
159193267Sjkim};
160193267Sjkim
161193267Sjkim/*
162193341Sjkim * The extension header are filtered only for presence using a bit
163193341Sjkim * vector with a flag for each header.
164193341Sjkim */
165193341Sjkim#define EXT_FRAGMENT	0x1
166193341Sjkim#define EXT_HOPOPTS	0x2
167193341Sjkim#define EXT_ROUTING	0x4
168193341Sjkim#define EXT_AH		0x8
169193341Sjkim#define EXT_ESP		0x10
170284583Sjkim
171284583Sjkim/*
172284583Sjkim * Template for instructions.
173193267Sjkim *
174193267Sjkim * ipfw_insn is used for all instructions which require no operands,
175193267Sjkim * a single 16-bit value (arg1), or a couple of 8-bit values.
176 *
177 * For other instructions which require different/larger arguments
178 * we have derived structures, ipfw_insn_*.
179 *
180 * The size of the instruction (in 32-bit words) is in the low
181 * 6 bits of "len". The 2 remaining bits are used to implement
182 * NOT and OR on individual instructions. Given a type, you can
183 * compute the length to be put in "len" using F_INSN_SIZE(t)
184 *
185 * F_NOT	negates the match result of the instruction.
186 *
187 * F_OR		is used to build or blocks. By default, instructions
188 *		are evaluated as part of a logical AND. An "or" block
189 *		{ X or Y or Z } contains F_OR set in all but the last
190 *		instruction of the block. A match will cause the code
191 *		to skip past the last instruction of the block.
192 *
193 * NOTA BENE: in a couple of places we assume that
194 *	sizeof(ipfw_insn) == sizeof(u_int32_t)
195 * this needs to be fixed.
196 *
197 */
198typedef struct	_ipfw_insn {	/* template for instructions */
199	enum ipfw_opcodes	opcode:8;
200	u_int8_t	len;	/* numer of 32-byte words */
201#define	F_NOT		0x80
202#define	F_OR		0x40
203#define	F_LEN_MASK	0x3f
204#define	F_LEN(cmd)	((cmd)->len & F_LEN_MASK)
205
206	u_int16_t	arg1;
207} ipfw_insn;
208
209/*
210 * The F_INSN_SIZE(type) computes the size, in 4-byte words, of
211 * a given type.
212 */
213#define	F_INSN_SIZE(t)	((sizeof (t))/sizeof(u_int32_t))
214
215/*
216 * This is used to store an array of 16-bit entries (ports etc.)
217 */
218typedef struct	_ipfw_insn_u16 {
219	ipfw_insn o;
220	u_int16_t ports[2];	/* there may be more */
221} ipfw_insn_u16;
222
223/*
224 * This is used to store an array of 32-bit entries
225 * (uid, single IPv4 addresses etc.)
226 */
227typedef struct	_ipfw_insn_u32 {
228	ipfw_insn o;
229	u_int32_t d[1];	/* one or more */
230} ipfw_insn_u32;
231
232/*
233 * This is used to store IP addr-mask pairs.
234 */
235typedef struct	_ipfw_insn_ip {
236	ipfw_insn o;
237	struct in_addr	addr;
238	struct in_addr	mask;
239} ipfw_insn_ip;
240
241/*
242 * This is used to forward to a given address (ip).
243 */
244typedef struct  _ipfw_insn_sa {
245	ipfw_insn o;
246	struct sockaddr_in sa;
247} ipfw_insn_sa;
248
249/*
250 * This is used for MAC addr-mask pairs.
251 */
252typedef struct	_ipfw_insn_mac {
253	ipfw_insn o;
254	u_char addr[12];	/* dst[6] + src[6] */
255	u_char mask[12];	/* dst[6] + src[6] */
256} ipfw_insn_mac;
257
258/*
259 * This is used for interface match rules (recv xx, xmit xx).
260 */
261typedef struct	_ipfw_insn_if {
262	ipfw_insn o;
263	union {
264		struct in_addr ip;
265		int glob;
266	} p;
267	char name[IFNAMSIZ];
268} ipfw_insn_if;
269
270/*
271 * This is used for pipe and queue actions, which need to store
272 * a single pointer (which can have different size on different
273 * architectures.
274 * Note that, because of previous instructions, pipe_ptr might
275 * be unaligned in the overall structure, so it needs to be
276 * manipulated with care.
277 */
278typedef struct	_ipfw_insn_pipe {
279	ipfw_insn	o;
280	void		*pipe_ptr;	/* XXX */
281} ipfw_insn_pipe;
282
283/*
284 * This is used for storing an altq queue id number.
285 */
286typedef struct _ipfw_insn_altq {
287	ipfw_insn	o;
288	u_int32_t	qid;
289} ipfw_insn_altq;
290
291/*
292 * This is used for limit rules.
293 */
294typedef struct	_ipfw_insn_limit {
295	ipfw_insn o;
296	u_int8_t _pad;
297	u_int8_t limit_mask;	/* combination of DYN_* below	*/
298#define	DYN_SRC_ADDR	0x1
299#define	DYN_SRC_PORT	0x2
300#define	DYN_DST_ADDR	0x4
301#define	DYN_DST_PORT	0x8
302
303	u_int16_t conn_limit;
304} ipfw_insn_limit;
305
306/*
307 * This is used for log instructions.
308 */
309typedef struct  _ipfw_insn_log {
310        ipfw_insn o;
311	u_int32_t max_log;	/* how many do we log -- 0 = all */
312	u_int32_t log_left;	/* how many left to log 	*/
313} ipfw_insn_log;
314
315/* Apply ipv6 mask on ipv6 addr */
316#define APPLY_MASK(addr,mask)                          \
317    (addr)->__u6_addr.__u6_addr32[0] &= (mask)->__u6_addr.__u6_addr32[0]; \
318    (addr)->__u6_addr.__u6_addr32[1] &= (mask)->__u6_addr.__u6_addr32[1]; \
319    (addr)->__u6_addr.__u6_addr32[2] &= (mask)->__u6_addr.__u6_addr32[2]; \
320    (addr)->__u6_addr.__u6_addr32[3] &= (mask)->__u6_addr.__u6_addr32[3];
321
322/* Structure for ipv6 */
323typedef struct _ipfw_insn_ip6 {
324       ipfw_insn o;
325       struct in6_addr addr6;
326       struct in6_addr mask6;
327} ipfw_insn_ip6;
328
329/* Used to support icmp6 types */
330typedef struct _ipfw_insn_icmp6 {
331       ipfw_insn o;
332       uint32_t d[7]; /* XXX This number si related to the netinet/icmp6.h
333                       *     define ICMP6_MAXTYPE
334                       *     as follows: n = ICMP6_MAXTYPE/32 + 1
335                        *     Actually is 203
336                       */
337} ipfw_insn_icmp6;
338
339/*
340 * Here we have the structure representing an ipfw rule.
341 *
342 * It starts with a general area (with link fields and counters)
343 * followed by an array of one or more instructions, which the code
344 * accesses as an array of 32-bit values.
345 *
346 * Given a rule pointer  r:
347 *
348 *  r->cmd		is the start of the first instruction.
349 *  ACTION_PTR(r)	is the start of the first action (things to do
350 *			once a rule matched).
351 *
352 * When assembling instruction, remember the following:
353 *
354 *  + if a rule has a "keep-state" (or "limit") option, then the
355 *	first instruction (at r->cmd) MUST BE an O_PROBE_STATE
356 *  + if a rule has a "log" option, then the first action
357 *	(at ACTION_PTR(r)) MUST be O_LOG
358 *  + if a rule has an "altq" option, it comes after "log"
359 *
360 * NOTE: we use a simple linked list of rules because we never need
361 * 	to delete a rule without scanning the list. We do not use
362 *	queue(3) macros for portability and readability.
363 */
364
365struct ip_fw {
366	struct ip_fw	*next;		/* linked list of rules		*/
367	struct ip_fw	*next_rule;	/* ptr to next [skipto] rule	*/
368	/* 'next_rule' is used to pass up 'set_disable' status		*/
369
370	u_int16_t	act_ofs;	/* offset of action in 32-bit units */
371	u_int16_t	cmd_len;	/* # of 32-bit words in cmd	*/
372	u_int16_t	rulenum;	/* rule number			*/
373	u_int8_t	set;		/* rule set (0..31)		*/
374#define	RESVD_SET	31	/* set for default and persistent rules */
375	u_int8_t	_pad;		/* padding			*/
376
377	/* These fields are present in all rules.			*/
378	u_int64_t	pcnt;		/* Packet counter		*/
379	u_int64_t	bcnt;		/* Byte counter			*/
380	u_int32_t	timestamp;	/* tv_sec of last match		*/
381
382	ipfw_insn	cmd[1];		/* storage for commands		*/
383};
384
385#define ACTION_PTR(rule)				\
386	(ipfw_insn *)( (u_int32_t *)((rule)->cmd) + ((rule)->act_ofs) )
387
388#define RULESIZE(rule)  (sizeof(struct ip_fw) + \
389	((struct ip_fw *)(rule))->cmd_len * 4 - 4)
390
391/*
392 * This structure is used as a flow mask and a flow id for various
393 * parts of the code.
394 */
395struct ipfw_flow_id {
396	u_int32_t	dst_ip;
397	u_int32_t	src_ip;
398	u_int16_t	dst_port;
399	u_int16_t	src_port;
400	u_int8_t	proto;
401	u_int8_t	flags;	/* protocol-specific flags */
402	uint8_t		addr_type; /* 4 = ipv4, 6 = ipv6, 1=ether ? */
403	struct in6_addr dst_ip6;	/* could also store MAC addr! */
404	struct in6_addr src_ip6;
405	u_int32_t	flow_id6;
406};
407
408#define IS_IP6_FLOW_ID(id)	((id)->addr_type == 6)
409
410/*
411 * Dynamic ipfw rule.
412 */
413typedef struct _ipfw_dyn_rule ipfw_dyn_rule;
414
415struct _ipfw_dyn_rule {
416	ipfw_dyn_rule	*next;		/* linked list of rules.	*/
417	struct ip_fw *rule;		/* pointer to rule		*/
418	/* 'rule' is used to pass up the rule number (from the parent)	*/
419
420	ipfw_dyn_rule *parent;		/* pointer to parent rule	*/
421	u_int64_t	pcnt;		/* packet match counter		*/
422	u_int64_t	bcnt;		/* byte match counter		*/
423	struct ipfw_flow_id id;		/* (masked) flow id		*/
424	u_int32_t	expire;		/* expire time			*/
425	u_int32_t	bucket;		/* which bucket in hash table	*/
426	u_int32_t	state;		/* state of this rule (typically a
427					 * combination of TCP flags)
428					 */
429	u_int32_t	ack_fwd;	/* most recent ACKs in forward	*/
430	u_int32_t	ack_rev;	/* and reverse directions (used	*/
431					/* to generate keepalives)	*/
432	u_int16_t	dyn_type;	/* rule type			*/
433	u_int16_t	count;		/* refcount			*/
434};
435
436/*
437 * Definitions for IP option names.
438 */
439#define	IP_FW_IPOPT_LSRR	0x01
440#define	IP_FW_IPOPT_SSRR	0x02
441#define	IP_FW_IPOPT_RR		0x04
442#define	IP_FW_IPOPT_TS		0x08
443
444/*
445 * Definitions for TCP option names.
446 */
447#define	IP_FW_TCPOPT_MSS	0x01
448#define	IP_FW_TCPOPT_WINDOW	0x02
449#define	IP_FW_TCPOPT_SACK	0x04
450#define	IP_FW_TCPOPT_TS		0x08
451#define	IP_FW_TCPOPT_CC		0x10
452
453#define	ICMP_REJECT_RST		0x100	/* fake ICMP code (send a TCP RST) */
454
455/*
456 * These are used for lookup tables.
457 */
458typedef struct	_ipfw_table_entry {
459	in_addr_t	addr;		/* network address		*/
460	u_int32_t	value;		/* value			*/
461	u_int16_t	tbl;		/* table number			*/
462	u_int8_t	masklen;	/* mask length			*/
463} ipfw_table_entry;
464
465typedef struct	_ipfw_table {
466	u_int32_t	size;		/* size of entries in bytes	*/
467	u_int32_t	cnt;		/* # of entries			*/
468	u_int16_t	tbl;		/* table number			*/
469	ipfw_table_entry ent[0];	/* entries			*/
470} ipfw_table;
471
472/*
473 * Main firewall chains definitions and global var's definitions.
474 */
475#ifdef _KERNEL
476
477/* Return values from ipfw_chk() */
478enum {
479	IP_FW_PASS = 0,
480	IP_FW_DENY,
481	IP_FW_DIVERT,
482	IP_FW_TEE,
483	IP_FW_DUMMYNET,
484	IP_FW_NETGRAPH,
485	IP_FW_NGTEE,
486};
487
488/* flags for divert mtag */
489#define	IP_FW_DIVERT_LOOPBACK_FLAG	0x00080000
490#define	IP_FW_DIVERT_OUTPUT_FLAG	0x00100000
491
492/*
493 * Structure for collecting parameters to dummynet for ip6_output forwarding
494 */
495struct _ip6dn_args {
496       struct ip6_pktopts *opt_or;
497       struct route_in6 ro_or;
498       int flags_or;
499       struct ip6_moptions *im6o_or;
500       struct ifnet *origifp_or;
501       struct ifnet *ifp_or;
502       struct sockaddr_in6 dst_or;
503       u_long mtu_or;
504       struct route_in6 ro_pmtu_or;
505};
506
507/*
508 * Arguments for calling ipfw_chk() and dummynet_io(). We put them
509 * all into a structure because this way it is easier and more
510 * efficient to pass variables around and extend the interface.
511 */
512struct ip_fw_args {
513	struct mbuf	*m;		/* the mbuf chain		*/
514	struct ifnet	*oif;		/* output interface		*/
515	struct sockaddr_in *next_hop;	/* forward address		*/
516	struct ip_fw	*rule;		/* matching rule		*/
517	struct ether_header *eh;	/* for bridged packets		*/
518
519	int flags;			/* for dummynet			*/
520
521	struct ipfw_flow_id f_id;	/* grabbed from IP header	*/
522	u_int32_t	cookie;		/* a cookie depending on rule action */
523	struct inpcb	*inp;
524
525	struct _ip6dn_args	dummypar; /* dummynet->ip6_output */
526};
527
528/*
529 * Function definitions.
530 */
531
532/* Firewall hooks */
533struct sockopt;
534struct dn_flow_set;
535
536int ipfw_check_in(void *, struct mbuf **, struct ifnet *, int, struct inpcb *inp);
537int ipfw_check_out(void *, struct mbuf **, struct ifnet *, int, struct inpcb *inp);
538
539int ipfw_chk(struct ip_fw_args *);
540
541int ipfw_init(void);
542void ipfw_destroy(void);
543
544void flush_pipe_ptrs(struct dn_flow_set *match); /* used by dummynet */
545
546typedef int ip_fw_ctl_t(struct sockopt *);
547extern ip_fw_ctl_t *ip_fw_ctl_ptr;
548extern int fw_one_pass;
549extern int fw_enable;
550
551/* For kernel ipfw_ether and ipfw_bridge. */
552typedef	int ip_fw_chk_t(struct ip_fw_args *args);
553extern	ip_fw_chk_t	*ip_fw_chk_ptr;
554#define	IPFW_LOADED	(ip_fw_chk_ptr != NULL)
555
556#endif /* _KERNEL */
557#endif /* _IPFW2_H */
558