xref: /freebsd/sys/netinet/ip_fw.h (revision e9b1dc32c9bd2ebae5f9e140bfa0e0321bc366b5)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29 
30 #ifndef _IPFW2_H
31 #define _IPFW2_H
32 
33 /*
34  * The default rule number.  By the design of ip_fw, the default rule
35  * is the last one, so its number can also serve as the highest number
36  * allowed for a rule.  The ip_fw code relies on both meanings of this
37  * constant.
38  */
39 #define	IPFW_DEFAULT_RULE	65535
40 
41 #define	RESVD_SET		31	/*set for default and persistent rules*/
42 #define	IPFW_MAX_SETS		32	/* Number of sets supported by ipfw*/
43 
44 /*
45  * Compat values for old clients
46  */
47 #ifndef	_KERNEL
48 #define	IPFW_TABLES_MAX		65535
49 #define	IPFW_TABLES_DEFAULT	128
50 #endif
51 
52 /*
53  * Most commands (queue, pipe, tag, untag, limit...) can have a 16-bit
54  * argument between 1 and 65534. The value 0 (IP_FW_TARG) is used
55  * to represent 'tablearg' value, e.g.  indicate the use of a 'tablearg'
56  * result of the most recent table() lookup.
57  * Note that 16bit is only a historical limit, resulting from
58  * the use of a 16-bit fields for that value. In reality, we can have
59  * 2^32 pipes, queues, tag values and so on.
60  */
61 #define	IPFW_ARG_MIN		1
62 #define	IPFW_ARG_MAX		65534
63 #define IP_FW_TABLEARG		65535	/* Compat value for old clients */
64 #define	IP_FW_TARG		0	/* Current tablearg value */
65 #define	IP_FW_NAT44_GLOBAL	65535	/* arg1 value for "nat global" */
66 
67 /*
68  * Number of entries in the call stack of the call/return commands.
69  * Call stack currently is an uint16_t array with rule numbers.
70  */
71 #define	IPFW_CALLSTACK_SIZE	16
72 
73 /* IP_FW3 header/opcodes */
74 typedef struct _ip_fw3_opheader {
75 	uint16_t opcode;	/* Operation opcode */
76 	uint16_t version;	/* Opcode version */
77 	uint16_t reserved[2];	/* Align to 64-bit boundary */
78 } ip_fw3_opheader;
79 
80 /* IP_FW3 opcodes */
81 #define	IP_FW_TABLE_XADD	86	/* add entry */
82 #define	IP_FW_TABLE_XDEL	87	/* delete entry */
83 #define	IP_FW_TABLE_XGETSIZE	88	/* get table size (deprecated) */
84 #define	IP_FW_TABLE_XLIST	89	/* list table contents */
85 #define	IP_FW_TABLE_XDESTROY	90	/* destroy table */
86 #define	IP_FW_TABLES_XLIST	92	/* list all tables  */
87 #define	IP_FW_TABLE_XINFO	93	/* request info for one table */
88 #define	IP_FW_TABLE_XFLUSH	94	/* flush table data */
89 #define	IP_FW_TABLE_XCREATE	95	/* create new table  */
90 #define	IP_FW_TABLE_XMODIFY	96	/* modify existing table */
91 #define	IP_FW_XGET		97	/* Retrieve configuration */
92 #define	IP_FW_XADD		98	/* add rule */
93 #define	IP_FW_XDEL		99	/* del rule */
94 #define	IP_FW_XMOVE		100	/* move rules to different set  */
95 #define	IP_FW_XZERO		101	/* clear accounting */
96 #define	IP_FW_XRESETLOG		102	/* zero rules logs */
97 #define	IP_FW_SET_SWAP		103	/* Swap between 2 sets */
98 #define	IP_FW_SET_MOVE		104	/* Move one set to another one */
99 #define	IP_FW_SET_ENABLE	105	/* Enable/disable sets */
100 #define	IP_FW_TABLE_XFIND	106	/* finds an entry */
101 #define	IP_FW_XIFLIST		107	/* list tracked interfaces */
102 #define	IP_FW_TABLES_ALIST	108	/* list table algorithms */
103 #define	IP_FW_TABLE_XSWAP	109	/* swap two tables */
104 #define	IP_FW_TABLE_VLIST	110	/* dump table value hash */
105 
106 #define	IP_FW_NAT44_XCONFIG	111	/* Create/modify NAT44 instance */
107 #define	IP_FW_NAT44_DESTROY	112	/* Destroys NAT44 instance */
108 #define	IP_FW_NAT44_XGETCONFIG	113	/* Get NAT44 instance config */
109 #define	IP_FW_NAT44_LIST_NAT	114	/* List all NAT44 instances */
110 #define	IP_FW_NAT44_XGETLOG	115	/* Get log from NAT44 instance */
111 
112 #define	IP_FW_DUMP_SOPTCODES	116	/* Dump available sopts/versions */
113 #define	IP_FW_DUMP_SRVOBJECTS	117	/* Dump existing named objects */
114 
115 #define	IP_FW_NAT64STL_CREATE	130	/* Create stateless NAT64 instance */
116 #define	IP_FW_NAT64STL_DESTROY	131	/* Destroy stateless NAT64 instance */
117 #define	IP_FW_NAT64STL_CONFIG	132	/* Modify stateless NAT64 instance */
118 #define	IP_FW_NAT64STL_LIST	133	/* List stateless NAT64 instances */
119 #define	IP_FW_NAT64STL_STATS	134	/* Get NAT64STL instance statistics */
120 #define	IP_FW_NAT64STL_RESET_STATS 135	/* Reset NAT64STL instance statistics */
121 
122 #define	IP_FW_NAT64LSN_CREATE	140	/* Create stateful NAT64 instance */
123 #define	IP_FW_NAT64LSN_DESTROY	141	/* Destroy stateful NAT64 instance */
124 #define	IP_FW_NAT64LSN_CONFIG	142	/* Modify stateful NAT64 instance */
125 #define	IP_FW_NAT64LSN_LIST	143	/* List stateful NAT64 instances */
126 #define	IP_FW_NAT64LSN_STATS	144	/* Get NAT64LSN instance statistics */
127 #define	IP_FW_NAT64LSN_LIST_STATES 145	/* Get stateful NAT64 states */
128 #define	IP_FW_NAT64LSN_RESET_STATS 146	/* Reset NAT64LSN instance statistics */
129 
130 #define	IP_FW_NPTV6_CREATE	150	/* Create NPTv6 instance */
131 #define	IP_FW_NPTV6_DESTROY	151	/* Destroy NPTv6 instance */
132 #define	IP_FW_NPTV6_CONFIG	152	/* Modify NPTv6 instance */
133 #define	IP_FW_NPTV6_LIST	153	/* List NPTv6 instances */
134 #define	IP_FW_NPTV6_STATS	154	/* Get NPTv6 instance statistics */
135 #define	IP_FW_NPTV6_RESET_STATS	155	/* Reset NPTv6 instance statistics */
136 
137 /*
138  * The kernel representation of ipfw rules is made of a list of
139  * 'instructions' (for all practical purposes equivalent to BPF
140  * instructions), which specify which fields of the packet
141  * (or its metadata) should be analysed.
142  *
143  * Each instruction is stored in a structure which begins with
144  * "ipfw_insn", and can contain extra fields depending on the
145  * instruction type (listed below).
146  * Note that the code is written so that individual instructions
147  * have a size which is a multiple of 32 bits. This means that, if
148  * such structures contain pointers or other 64-bit entities,
149  * (there is just one instance now) they may end up unaligned on
150  * 64-bit architectures, so the must be handled with care.
151  *
152  * "enum ipfw_opcodes" are the opcodes supported. We can have up
153  * to 256 different opcodes. When adding new opcodes, they should
154  * be appended to the end of the opcode list before O_LAST_OPCODE,
155  * this will prevent the ABI from being broken, otherwise users
156  * will have to recompile ipfw(8) when they update the kernel.
157  */
158 
159 enum ipfw_opcodes {		/* arguments (4 byte each)	*/
160 	O_NOP,
161 
162 	O_IP_SRC,		/* u32 = IP			*/
163 	O_IP_SRC_MASK,		/* ip = IP/mask			*/
164 	O_IP_SRC_ME,		/* none				*/
165 	O_IP_SRC_SET,		/* u32=base, arg1=len, bitmap	*/
166 
167 	O_IP_DST,		/* u32 = IP			*/
168 	O_IP_DST_MASK,		/* ip = IP/mask			*/
169 	O_IP_DST_ME,		/* none				*/
170 	O_IP_DST_SET,		/* u32=base, arg1=len, bitmap	*/
171 
172 	O_IP_SRCPORT,		/* (n)port list:mask 4 byte ea	*/
173 	O_IP_DSTPORT,		/* (n)port list:mask 4 byte ea	*/
174 	O_PROTO,		/* arg1=protocol		*/
175 
176 	O_MACADDR2,		/* 2 mac addr:mask		*/
177 	O_MAC_TYPE,		/* same as srcport		*/
178 
179 	O_LAYER2,		/* none				*/
180 	O_IN,			/* none				*/
181 	O_FRAG,			/* none				*/
182 
183 	O_RECV,			/* none				*/
184 	O_XMIT,			/* none				*/
185 	O_VIA,			/* none				*/
186 
187 	O_IPOPT,		/* arg1 = 2*u8 bitmap		*/
188 	O_IPLEN,		/* arg1 = len			*/
189 	O_IPID,			/* arg1 = id			*/
190 
191 	O_IPTOS,		/* arg1 = id			*/
192 	O_IPPRECEDENCE,		/* arg1 = precedence << 5	*/
193 	O_IPTTL,		/* arg1 = TTL			*/
194 
195 	O_IPVER,		/* arg1 = version		*/
196 	O_UID,			/* u32 = id			*/
197 	O_GID,			/* u32 = id			*/
198 	O_ESTAB,		/* none (tcp established)	*/
199 	O_TCPFLAGS,		/* arg1 = 2*u8 bitmap		*/
200 	O_TCPWIN,		/* arg1 = desired win		*/
201 	O_TCPSEQ,		/* u32 = desired seq.		*/
202 	O_TCPACK,		/* u32 = desired seq.		*/
203 	O_ICMPTYPE,		/* u32 = icmp bitmap		*/
204 	O_TCPOPTS,		/* arg1 = 2*u8 bitmap		*/
205 
206 	O_VERREVPATH,		/* none				*/
207 	O_VERSRCREACH,		/* none				*/
208 
209 	O_PROBE_STATE,		/* none				*/
210 	O_KEEP_STATE,		/* none				*/
211 	O_LIMIT,		/* ipfw_insn_limit		*/
212 	O_LIMIT_PARENT,		/* dyn_type, not an opcode.	*/
213 
214 	/*
215 	 * These are really 'actions'.
216 	 */
217 
218 	O_LOG,			/* ipfw_insn_log		*/
219 	O_PROB,			/* u32 = match probability	*/
220 
221 	O_CHECK_STATE,		/* none				*/
222 	O_ACCEPT,		/* none				*/
223 	O_DENY,			/* none 			*/
224 	O_REJECT,		/* arg1=icmp arg (same as deny)	*/
225 	O_COUNT,		/* none				*/
226 	O_SKIPTO,		/* arg1=next rule number	*/
227 	O_PIPE,			/* arg1=pipe number		*/
228 	O_QUEUE,		/* arg1=queue number		*/
229 	O_DIVERT,		/* arg1=port number		*/
230 	O_TEE,			/* arg1=port number		*/
231 	O_FORWARD_IP,		/* fwd sockaddr			*/
232 	O_FORWARD_MAC,		/* fwd mac			*/
233 	O_NAT,                  /* nope                         */
234 	O_REASS,                /* none                         */
235 
236 	/*
237 	 * More opcodes.
238 	 */
239 	O_IPSEC,		/* has ipsec history 		*/
240 	O_IP_SRC_LOOKUP,	/* arg1=table number, u32=value	*/
241 	O_IP_DST_LOOKUP,	/* arg1=table number, u32=value	*/
242 	O_ANTISPOOF,		/* none				*/
243 	O_JAIL,			/* u32 = id			*/
244 	O_ALTQ,			/* u32 = altq classif. qid	*/
245 	O_DIVERTED,		/* arg1=bitmap (1:loop, 2:out)	*/
246 	O_TCPDATALEN,		/* arg1 = tcp data len		*/
247 	O_IP6_SRC,		/* address without mask		*/
248 	O_IP6_SRC_ME,		/* my addresses			*/
249 	O_IP6_SRC_MASK,		/* address with the mask	*/
250 	O_IP6_DST,
251 	O_IP6_DST_ME,
252 	O_IP6_DST_MASK,
253 	O_FLOW6ID,		/* for flow id tag in the ipv6 pkt */
254 	O_ICMP6TYPE,		/* icmp6 packet type filtering	*/
255 	O_EXT_HDR,		/* filtering for ipv6 extension header */
256 	O_IP6,
257 
258 	/*
259 	 * actions for ng_ipfw
260 	 */
261 	O_NETGRAPH,		/* send to ng_ipfw		*/
262 	O_NGTEE,		/* copy to ng_ipfw		*/
263 
264 	O_IP4,
265 
266 	O_UNREACH6,		/* arg1=icmpv6 code arg (deny)  */
267 
268 	O_TAG,   		/* arg1=tag number */
269 	O_TAGGED,		/* arg1=tag number */
270 
271 	O_SETFIB,		/* arg1=FIB number */
272 	O_FIB,			/* arg1=FIB desired fib number */
273 
274 	O_SOCKARG,		/* socket argument */
275 
276 	O_CALLRETURN,		/* arg1=called rule number */
277 
278 	O_FORWARD_IP6,		/* fwd sockaddr_in6             */
279 
280 	O_DSCP,			/* 2 u32 = DSCP mask */
281 	O_SETDSCP,		/* arg1=DSCP value */
282 	O_IP_FLOW_LOOKUP,	/* arg1=table number, u32=value	*/
283 
284 	O_EXTERNAL_ACTION,	/* arg1=id of external action handler */
285 	O_EXTERNAL_INSTANCE,	/* arg1=id of eaction handler instance */
286 	O_EXTERNAL_DATA,	/* variable length data */
287 
288 	O_SKIP_ACTION,		/* none				*/
289 
290 	O_LAST_OPCODE		/* not an opcode!		*/
291 };
292 
293 /*
294  * The extension header are filtered only for presence using a bit
295  * vector with a flag for each header.
296  */
297 #define EXT_FRAGMENT	0x1
298 #define EXT_HOPOPTS	0x2
299 #define EXT_ROUTING	0x4
300 #define EXT_AH		0x8
301 #define EXT_ESP		0x10
302 #define EXT_DSTOPTS	0x20
303 #define EXT_RTHDR0		0x40
304 #define EXT_RTHDR2		0x80
305 
306 /*
307  * Template for instructions.
308  *
309  * ipfw_insn is used for all instructions which require no operands,
310  * a single 16-bit value (arg1), or a couple of 8-bit values.
311  *
312  * For other instructions which require different/larger arguments
313  * we have derived structures, ipfw_insn_*.
314  *
315  * The size of the instruction (in 32-bit words) is in the low
316  * 6 bits of "len". The 2 remaining bits are used to implement
317  * NOT and OR on individual instructions. Given a type, you can
318  * compute the length to be put in "len" using F_INSN_SIZE(t)
319  *
320  * F_NOT	negates the match result of the instruction.
321  *
322  * F_OR		is used to build or blocks. By default, instructions
323  *		are evaluated as part of a logical AND. An "or" block
324  *		{ X or Y or Z } contains F_OR set in all but the last
325  *		instruction of the block. A match will cause the code
326  *		to skip past the last instruction of the block.
327  *
328  * NOTA BENE: in a couple of places we assume that
329  *	sizeof(ipfw_insn) == sizeof(u_int32_t)
330  * this needs to be fixed.
331  *
332  */
333 typedef struct	_ipfw_insn {	/* template for instructions */
334 	u_int8_t 	opcode;
335 	u_int8_t	len;	/* number of 32-bit words */
336 #define	F_NOT		0x80
337 #define	F_OR		0x40
338 #define	F_LEN_MASK	0x3f
339 #define	F_LEN(cmd)	((cmd)->len & F_LEN_MASK)
340 
341 	u_int16_t	arg1;
342 } ipfw_insn;
343 
344 /*
345  * The F_INSN_SIZE(type) computes the size, in 4-byte words, of
346  * a given type.
347  */
348 #define	F_INSN_SIZE(t)	((sizeof (t))/sizeof(u_int32_t))
349 
350 /*
351  * This is used to store an array of 16-bit entries (ports etc.)
352  */
353 typedef struct	_ipfw_insn_u16 {
354 	ipfw_insn o;
355 	u_int16_t ports[2];	/* there may be more */
356 } ipfw_insn_u16;
357 
358 /*
359  * This is used to store an array of 32-bit entries
360  * (uid, single IPv4 addresses etc.)
361  */
362 typedef struct	_ipfw_insn_u32 {
363 	ipfw_insn o;
364 	u_int32_t d[1];	/* one or more */
365 } ipfw_insn_u32;
366 
367 /*
368  * This is used to store IP addr-mask pairs.
369  */
370 typedef struct	_ipfw_insn_ip {
371 	ipfw_insn o;
372 	struct in_addr	addr;
373 	struct in_addr	mask;
374 } ipfw_insn_ip;
375 
376 /*
377  * This is used to forward to a given address (ip).
378  */
379 typedef struct  _ipfw_insn_sa {
380 	ipfw_insn o;
381 	struct sockaddr_in sa;
382 } ipfw_insn_sa;
383 
384 /*
385  * This is used to forward to a given address (ipv6).
386  */
387 typedef struct _ipfw_insn_sa6 {
388 	ipfw_insn o;
389 	struct sockaddr_in6 sa;
390 } ipfw_insn_sa6;
391 
392 /*
393  * This is used for MAC addr-mask pairs.
394  */
395 typedef struct	_ipfw_insn_mac {
396 	ipfw_insn o;
397 	u_char addr[12];	/* dst[6] + src[6] */
398 	u_char mask[12];	/* dst[6] + src[6] */
399 } ipfw_insn_mac;
400 
401 /*
402  * This is used for interface match rules (recv xx, xmit xx).
403  */
404 typedef struct	_ipfw_insn_if {
405 	ipfw_insn o;
406 	union {
407 		struct in_addr ip;
408 		int glob;
409 		uint16_t kidx;
410 	} p;
411 	char name[IFNAMSIZ];
412 } ipfw_insn_if;
413 
414 /*
415  * This is used for storing an altq queue id number.
416  */
417 typedef struct _ipfw_insn_altq {
418 	ipfw_insn	o;
419 	u_int32_t	qid;
420 } ipfw_insn_altq;
421 
422 /*
423  * This is used for limit rules.
424  */
425 typedef struct	_ipfw_insn_limit {
426 	ipfw_insn o;
427 	u_int8_t _pad;
428 	u_int8_t limit_mask;	/* combination of DYN_* below	*/
429 #define	DYN_SRC_ADDR	0x1
430 #define	DYN_SRC_PORT	0x2
431 #define	DYN_DST_ADDR	0x4
432 #define	DYN_DST_PORT	0x8
433 
434 	u_int16_t conn_limit;
435 } ipfw_insn_limit;
436 
437 /*
438  * This is used for log instructions.
439  */
440 typedef struct  _ipfw_insn_log {
441         ipfw_insn o;
442 	u_int32_t max_log;	/* how many do we log -- 0 = all */
443 	u_int32_t log_left;	/* how many left to log 	*/
444 } ipfw_insn_log;
445 
446 /* Legacy NAT structures, compat only */
447 #ifndef	_KERNEL
448 /*
449  * Data structures required by both ipfw(8) and ipfw(4) but not part of the
450  * management API are protected by IPFW_INTERNAL.
451  */
452 #ifdef IPFW_INTERNAL
453 /* Server pool support (LSNAT). */
454 struct cfg_spool {
455 	LIST_ENTRY(cfg_spool)   _next;          /* chain of spool instances */
456 	struct in_addr          addr;
457 	u_short                 port;
458 };
459 #endif
460 
461 /* Redirect modes id. */
462 #define REDIR_ADDR      0x01
463 #define REDIR_PORT      0x02
464 #define REDIR_PROTO     0x04
465 
466 #ifdef IPFW_INTERNAL
467 /* Nat redirect configuration. */
468 struct cfg_redir {
469 	LIST_ENTRY(cfg_redir)   _next;          /* chain of redir instances */
470 	u_int16_t               mode;           /* type of redirect mode */
471 	struct in_addr	        laddr;          /* local ip address */
472 	struct in_addr	        paddr;          /* public ip address */
473 	struct in_addr	        raddr;          /* remote ip address */
474 	u_short                 lport;          /* local port */
475 	u_short                 pport;          /* public port */
476 	u_short                 rport;          /* remote port  */
477 	u_short                 pport_cnt;      /* number of public ports */
478 	u_short                 rport_cnt;      /* number of remote ports */
479 	int                     proto;          /* protocol: tcp/udp */
480 	struct alias_link       **alink;
481 	/* num of entry in spool chain */
482 	u_int16_t               spool_cnt;
483 	/* chain of spool instances */
484 	LIST_HEAD(spool_chain, cfg_spool) spool_chain;
485 };
486 #endif
487 
488 #ifdef IPFW_INTERNAL
489 /* Nat configuration data struct. */
490 struct cfg_nat {
491 	/* chain of nat instances */
492 	LIST_ENTRY(cfg_nat)     _next;
493 	int                     id;                     /* nat id */
494 	struct in_addr          ip;                     /* nat ip address */
495 	char                    if_name[IF_NAMESIZE];   /* interface name */
496 	int                     mode;                   /* aliasing mode */
497 	struct libalias	        *lib;                   /* libalias instance */
498 	/* number of entry in spool chain */
499 	int                     redir_cnt;
500 	/* chain of redir instances */
501 	LIST_HEAD(redir_chain, cfg_redir) redir_chain;
502 };
503 #endif
504 
505 #define SOF_NAT         sizeof(struct cfg_nat)
506 #define SOF_REDIR       sizeof(struct cfg_redir)
507 #define SOF_SPOOL       sizeof(struct cfg_spool)
508 
509 #endif	/* ifndef _KERNEL */
510 
511 
512 struct nat44_cfg_spool {
513 	struct in_addr	addr;
514 	uint16_t	port;
515 	uint16_t	spare;
516 };
517 #define NAT44_REDIR_ADDR	0x01
518 #define NAT44_REDIR_PORT	0x02
519 #define NAT44_REDIR_PROTO	0x04
520 
521 /* Nat redirect configuration. */
522 struct nat44_cfg_redir {
523 	struct in_addr	laddr;		/* local ip address */
524 	struct in_addr	paddr;		/* public ip address */
525 	struct in_addr	raddr;		/* remote ip address */
526 	uint16_t	lport;		/* local port */
527 	uint16_t	pport;		/* public port */
528 	uint16_t	rport;		/* remote port  */
529 	uint16_t	pport_cnt;	/* number of public ports */
530 	uint16_t	rport_cnt;	/* number of remote ports */
531 	uint16_t	mode;		/* type of redirect mode */
532 	uint16_t	spool_cnt;	/* num of entry in spool chain */
533 	uint16_t	spare;
534 	uint32_t	proto;		/* protocol: tcp/udp */
535 };
536 
537 /* Nat configuration data struct. */
538 struct nat44_cfg_nat {
539 	char		name[64];	/* nat name */
540 	char		if_name[64];	/* interface name */
541 	uint32_t	size;		/* structure size incl. redirs */
542 	struct in_addr	ip;		/* nat IPv4 address */
543 	uint32_t	mode;		/* aliasing mode */
544 	uint32_t	redir_cnt;	/* number of entry in spool chain */
545 };
546 
547 /* Nat command. */
548 typedef struct	_ipfw_insn_nat {
549  	ipfw_insn	o;
550  	struct cfg_nat *nat;
551 } ipfw_insn_nat;
552 
553 /* Apply ipv6 mask on ipv6 addr */
554 #define APPLY_MASK(addr,mask)                          \
555     (addr)->__u6_addr.__u6_addr32[0] &= (mask)->__u6_addr.__u6_addr32[0]; \
556     (addr)->__u6_addr.__u6_addr32[1] &= (mask)->__u6_addr.__u6_addr32[1]; \
557     (addr)->__u6_addr.__u6_addr32[2] &= (mask)->__u6_addr.__u6_addr32[2]; \
558     (addr)->__u6_addr.__u6_addr32[3] &= (mask)->__u6_addr.__u6_addr32[3];
559 
560 /* Structure for ipv6 */
561 typedef struct _ipfw_insn_ip6 {
562        ipfw_insn o;
563        struct in6_addr addr6;
564        struct in6_addr mask6;
565 } ipfw_insn_ip6;
566 
567 /* Used to support icmp6 types */
568 typedef struct _ipfw_insn_icmp6 {
569        ipfw_insn o;
570        uint32_t d[7]; /* XXX This number si related to the netinet/icmp6.h
571                        *     define ICMP6_MAXTYPE
572                        *     as follows: n = ICMP6_MAXTYPE/32 + 1
573                         *     Actually is 203
574                        */
575 } ipfw_insn_icmp6;
576 
577 /*
578  * Here we have the structure representing an ipfw rule.
579  *
580  * Layout:
581  * struct ip_fw_rule
582  * [ counter block, size = rule->cntr_len ]
583  * [ one or more instructions, size = rule->cmd_len * 4 ]
584  *
585  * It starts with a general area (with link fields).
586  * Counter block may be next (if rule->cntr_len > 0),
587  * followed by an array of one or more instructions, which the code
588  * accesses as an array of 32-bit values. rule->cmd_len represents
589  * the total instructions legth in u32 worrd, while act_ofs represents
590  * rule action offset in u32 words.
591  *
592  * When assembling instruction, remember the following:
593  *
594  *  + if a rule has a "keep-state" (or "limit") option, then the
595  *	first instruction (at r->cmd) MUST BE an O_PROBE_STATE
596  *  + if a rule has a "log" option, then the first action
597  *	(at ACTION_PTR(r)) MUST be O_LOG
598  *  + if a rule has an "altq" option, it comes after "log"
599  *  + if a rule has an O_TAG option, it comes after "log" and "altq"
600  *
601  *
602  * All structures (excluding instructions) are u64-aligned.
603  * Please keep this.
604  */
605 
606 struct ip_fw_rule {
607 	uint16_t	act_ofs;	/* offset of action in 32-bit units */
608 	uint16_t	cmd_len;	/* # of 32-bit words in cmd	*/
609 	uint16_t	spare;
610 	uint8_t		set;		/* rule set (0..31)		*/
611 	uint8_t		flags;		/* rule flags			*/
612 	uint32_t	rulenum;	/* rule number			*/
613 	uint32_t	id;		/* rule id			*/
614 
615 	ipfw_insn	cmd[1];		/* storage for commands		*/
616 };
617 #define	IPFW_RULE_NOOPT		0x01	/* Has no options in body	*/
618 #define	IPFW_RULE_JUSTOPTS	0x02	/* new format of rule body	*/
619 
620 /* Unaligned version */
621 
622 /* Base ipfw rule counter block. */
623 struct ip_fw_bcounter {
624 	uint16_t	size;		/* Size of counter block, bytes	*/
625 	uint8_t		flags;		/* flags for given block	*/
626 	uint8_t		spare;
627 	uint32_t	timestamp;	/* tv_sec of last match		*/
628 	uint64_t	pcnt;		/* Packet counter		*/
629 	uint64_t	bcnt;		/* Byte counter			*/
630 };
631 
632 
633 #ifndef	_KERNEL
634 /*
635  * Legacy rule format
636  */
637 struct ip_fw {
638 	struct ip_fw	*x_next;	/* linked list of rules		*/
639 	struct ip_fw	*next_rule;	/* ptr to next [skipto] rule	*/
640 	/* 'next_rule' is used to pass up 'set_disable' status		*/
641 
642 	uint16_t	act_ofs;	/* offset of action in 32-bit units */
643 	uint16_t	cmd_len;	/* # of 32-bit words in cmd	*/
644 	uint16_t	rulenum;	/* rule number			*/
645 	uint8_t		set;		/* rule set (0..31)		*/
646 	uint8_t		_pad;		/* padding			*/
647 	uint32_t	id;		/* rule id */
648 
649 	/* These fields are present in all rules.			*/
650 	uint64_t	pcnt;		/* Packet counter		*/
651 	uint64_t	bcnt;		/* Byte counter			*/
652 	uint32_t	timestamp;	/* tv_sec of last match		*/
653 
654 	ipfw_insn	cmd[1];		/* storage for commands		*/
655 };
656 #endif
657 
658 #define ACTION_PTR(rule)				\
659 	(ipfw_insn *)( (u_int32_t *)((rule)->cmd) + ((rule)->act_ofs) )
660 
661 #define RULESIZE(rule)  (sizeof(*(rule)) + (rule)->cmd_len * 4 - 4)
662 
663 
664 #if 1 // should be moved to in.h
665 /*
666  * This structure is used as a flow mask and a flow id for various
667  * parts of the code.
668  * addr_type is used in userland and kernel to mark the address type.
669  * fib is used in the kernel to record the fib in use.
670  * _flags is used in the kernel to store tcp flags for dynamic rules.
671  */
672 struct ipfw_flow_id {
673 	uint32_t	dst_ip;
674 	uint32_t	src_ip;
675 	uint16_t	dst_port;
676 	uint16_t	src_port;
677 	uint8_t		fib;	/* XXX: must be uint16_t */
678 	uint8_t		proto;
679 	uint8_t		_flags;	/* protocol-specific flags */
680 	uint8_t		addr_type; /* 4=ip4, 6=ip6, 1=ether ? */
681 	struct in6_addr dst_ip6;
682 	struct in6_addr src_ip6;
683 	uint32_t	flow_id6;
684 	uint32_t	extra; /* queue/pipe or frag_id */
685 };
686 #endif
687 
688 #define	IS_IP4_FLOW_ID(id)	((id)->addr_type == 4)
689 #define IS_IP6_FLOW_ID(id)	((id)->addr_type == 6)
690 
691 /*
692  * Dynamic ipfw rule.
693  */
694 typedef struct _ipfw_dyn_rule ipfw_dyn_rule;
695 
696 struct _ipfw_dyn_rule {
697 	ipfw_dyn_rule	*next;		/* linked list of rules.	*/
698 	struct ip_fw *rule;		/* pointer to rule		*/
699 	/* 'rule' is used to pass up the rule number (from the parent)	*/
700 
701 	ipfw_dyn_rule *parent;		/* pointer to parent rule	*/
702 	u_int64_t	pcnt;		/* packet match counter		*/
703 	u_int64_t	bcnt;		/* byte match counter		*/
704 	struct ipfw_flow_id id;		/* (masked) flow id		*/
705 	u_int32_t	expire;		/* expire time			*/
706 	u_int32_t	bucket;		/* which bucket in hash table	*/
707 	u_int32_t	state;		/* state of this rule (typically a
708 					 * combination of TCP flags)
709 					 */
710 	u_int32_t	ack_fwd;	/* most recent ACKs in forward	*/
711 	u_int32_t	ack_rev;	/* and reverse directions (used	*/
712 					/* to generate keepalives)	*/
713 	u_int16_t	dyn_type;	/* rule type			*/
714 	u_int16_t	count;		/* refcount			*/
715 	u_int16_t	kidx;		/* index of named object */
716 } __packed __aligned(8);
717 
718 /*
719  * Definitions for IP option names.
720  */
721 #define	IP_FW_IPOPT_LSRR	0x01
722 #define	IP_FW_IPOPT_SSRR	0x02
723 #define	IP_FW_IPOPT_RR		0x04
724 #define	IP_FW_IPOPT_TS		0x08
725 
726 /*
727  * Definitions for TCP option names.
728  */
729 #define	IP_FW_TCPOPT_MSS	0x01
730 #define	IP_FW_TCPOPT_WINDOW	0x02
731 #define	IP_FW_TCPOPT_SACK	0x04
732 #define	IP_FW_TCPOPT_TS		0x08
733 #define	IP_FW_TCPOPT_CC		0x10
734 
735 #define	ICMP_REJECT_RST		0x100	/* fake ICMP code (send a TCP RST) */
736 #define	ICMP6_UNREACH_RST	0x100	/* fake ICMPv6 code (send a TCP RST) */
737 #define	ICMP_REJECT_ABORT	0x101	/* fake ICMP code (send an SCTP ABORT) */
738 #define	ICMP6_UNREACH_ABORT	0x101	/* fake ICMPv6 code (send an SCTP ABORT) */
739 
740 /*
741  * These are used for lookup tables.
742  */
743 
744 #define	IPFW_TABLE_ADDR		1	/* Table for holding IPv4/IPv6 prefixes */
745 #define	IPFW_TABLE_INTERFACE	2	/* Table for holding interface names */
746 #define	IPFW_TABLE_NUMBER	3	/* Table for holding ports/uid/gid/etc */
747 #define	IPFW_TABLE_FLOW		4	/* Table for holding flow data */
748 #define	IPFW_TABLE_MAXTYPE	4	/* Maximum valid number */
749 
750 #define	IPFW_TABLE_CIDR	IPFW_TABLE_ADDR	/* compat */
751 
752 /* Value types */
753 #define	IPFW_VTYPE_LEGACY	0xFFFFFFFF	/* All data is filled in */
754 #define	IPFW_VTYPE_SKIPTO	0x00000001	/* skipto/call/callreturn */
755 #define	IPFW_VTYPE_PIPE		0x00000002	/* pipe/queue */
756 #define	IPFW_VTYPE_FIB		0x00000004	/* setfib */
757 #define	IPFW_VTYPE_NAT		0x00000008	/* nat */
758 #define	IPFW_VTYPE_DSCP		0x00000010	/* dscp */
759 #define	IPFW_VTYPE_TAG		0x00000020	/* tag/untag */
760 #define	IPFW_VTYPE_DIVERT	0x00000040	/* divert/tee */
761 #define	IPFW_VTYPE_NETGRAPH	0x00000080	/* netgraph/ngtee */
762 #define	IPFW_VTYPE_LIMIT	0x00000100	/* limit */
763 #define	IPFW_VTYPE_NH4		0x00000200	/* IPv4 nexthop */
764 #define	IPFW_VTYPE_NH6		0x00000400	/* IPv6 nexthop */
765 
766 typedef struct	_ipfw_table_entry {
767 	in_addr_t	addr;		/* network address		*/
768 	u_int32_t	value;		/* value			*/
769 	u_int16_t	tbl;		/* table number			*/
770 	u_int8_t	masklen;	/* mask length			*/
771 } ipfw_table_entry;
772 
773 typedef struct	_ipfw_table_xentry {
774 	uint16_t	len;		/* Total entry length		*/
775 	uint8_t		type;		/* entry type			*/
776 	uint8_t		masklen;	/* mask length			*/
777 	uint16_t	tbl;		/* table number			*/
778 	uint16_t	flags;		/* record flags			*/
779 	uint32_t	value;		/* value			*/
780 	union {
781 		/* Longest field needs to be aligned by 4-byte boundary	*/
782 		struct in6_addr	addr6;	/* IPv6 address 		*/
783 		char	iface[IF_NAMESIZE];	/* interface name	*/
784 	} k;
785 } ipfw_table_xentry;
786 #define	IPFW_TCF_INET	0x01		/* CIDR flags: IPv4 record	*/
787 
788 typedef struct	_ipfw_table {
789 	u_int32_t	size;		/* size of entries in bytes	*/
790 	u_int32_t	cnt;		/* # of entries			*/
791 	u_int16_t	tbl;		/* table number			*/
792 	ipfw_table_entry ent[0];	/* entries			*/
793 } ipfw_table;
794 
795 typedef struct	_ipfw_xtable {
796 	ip_fw3_opheader	opheader;	/* IP_FW3 opcode */
797 	uint32_t	size;		/* size of entries in bytes	*/
798 	uint32_t	cnt;		/* # of entries			*/
799 	uint16_t	tbl;		/* table number			*/
800 	uint8_t		type;		/* table type			*/
801 	ipfw_table_xentry xent[0];	/* entries			*/
802 } ipfw_xtable;
803 
804 typedef struct  _ipfw_obj_tlv {
805 	uint16_t        type;		/* TLV type */
806 	uint16_t	flags;		/* TLV-specific flags		*/
807 	uint32_t        length;		/* Total length, aligned to u64	*/
808 } ipfw_obj_tlv;
809 #define	IPFW_TLV_TBL_NAME	1
810 #define	IPFW_TLV_TBLNAME_LIST	2
811 #define	IPFW_TLV_RULE_LIST	3
812 #define	IPFW_TLV_DYNSTATE_LIST	4
813 #define	IPFW_TLV_TBL_ENT	5
814 #define	IPFW_TLV_DYN_ENT	6
815 #define	IPFW_TLV_RULE_ENT	7
816 #define	IPFW_TLV_TBLENT_LIST	8
817 #define	IPFW_TLV_RANGE		9
818 #define	IPFW_TLV_EACTION	10
819 #define	IPFW_TLV_COUNTERS	11
820 #define	IPFW_TLV_OBJDATA	12
821 #define	IPFW_TLV_STATE_NAME	14
822 
823 #define	IPFW_TLV_EACTION_BASE	1000
824 #define	IPFW_TLV_EACTION_NAME(arg)	(IPFW_TLV_EACTION_BASE + (arg))
825 
826 typedef struct _ipfw_obj_data {
827 	ipfw_obj_tlv	head;
828 	void		*data[0];
829 } ipfw_obj_data;
830 
831 /* Object name TLV */
832 typedef struct _ipfw_obj_ntlv {
833 	ipfw_obj_tlv	head;		/* TLV header			*/
834 	uint16_t	idx;		/* Name index			*/
835 	uint8_t		set;		/* set, if applicable		*/
836 	uint8_t		type;		/* object type, if applicable	*/
837 	uint32_t	spare;		/* unused			*/
838 	char		name[64];	/* Null-terminated name		*/
839 } ipfw_obj_ntlv;
840 
841 /* IPv4/IPv6 L4 flow description */
842 struct tflow_entry {
843 	uint8_t		af;
844 	uint8_t		proto;
845 	uint16_t	spare;
846 	uint16_t	sport;
847 	uint16_t	dport;
848 	union {
849 		struct {
850 			struct in_addr	sip;
851 			struct in_addr	dip;
852 		} a4;
853 		struct {
854 			struct in6_addr	sip6;
855 			struct in6_addr	dip6;
856 		} a6;
857 	} a;
858 };
859 
860 typedef struct _ipfw_table_value {
861 	uint32_t	tag;		/* O_TAG/O_TAGGED */
862 	uint32_t	pipe;		/* O_PIPE/O_QUEUE */
863 	uint16_t	divert;		/* O_DIVERT/O_TEE */
864 	uint16_t	skipto;		/* skipto, CALLRET */
865 	uint32_t	netgraph;	/* O_NETGRAPH/O_NGTEE */
866 	uint32_t	fib;		/* O_SETFIB */
867 	uint32_t	nat;		/* O_NAT */
868 	uint32_t	nh4;
869 	uint8_t		dscp;
870 	uint8_t		spare0;
871 	uint16_t	spare1;
872 	struct in6_addr	nh6;
873 	uint32_t	limit;		/* O_LIMIT */
874 	uint32_t	zoneid;		/* scope zone id for nh6 */
875 	uint64_t	reserved;
876 } ipfw_table_value;
877 
878 /* Table entry TLV */
879 typedef struct	_ipfw_obj_tentry {
880 	ipfw_obj_tlv	head;		/* TLV header			*/
881 	uint8_t		subtype;	/* subtype (IPv4,IPv6)		*/
882 	uint8_t		masklen;	/* mask length			*/
883 	uint8_t		result;		/* request result		*/
884 	uint8_t		spare0;
885 	uint16_t	idx;		/* Table name index		*/
886 	uint16_t	spare1;
887 	union {
888 		/* Longest field needs to be aligned by 8-byte boundary	*/
889 		struct in_addr		addr;	/* IPv4 address		*/
890 		uint32_t		key;		/* uid/gid/port	*/
891 		struct in6_addr		addr6;	/* IPv6 address 	*/
892 		char	iface[IF_NAMESIZE];	/* interface name	*/
893 		struct tflow_entry	flow;
894 	} k;
895 	union {
896 		ipfw_table_value	value;	/* value data */
897 		uint32_t		kidx;	/* value kernel index */
898 	} v;
899 } ipfw_obj_tentry;
900 #define	IPFW_TF_UPDATE	0x01		/* Update record if exists	*/
901 /* Container TLV */
902 #define	IPFW_CTF_ATOMIC	0x01		/* Perform atomic operation	*/
903 /* Operation results */
904 #define	IPFW_TR_IGNORED		0	/* Entry was ignored (rollback)	*/
905 #define	IPFW_TR_ADDED		1	/* Entry was successfully added	*/
906 #define	IPFW_TR_UPDATED		2	/* Entry was successfully updated*/
907 #define	IPFW_TR_DELETED		3	/* Entry was successfully deleted*/
908 #define	IPFW_TR_LIMIT		4	/* Entry was ignored (limit)	*/
909 #define	IPFW_TR_NOTFOUND	5	/* Entry was not found		*/
910 #define	IPFW_TR_EXISTS		6	/* Entry already exists		*/
911 #define	IPFW_TR_ERROR		7	/* Request has failed (unknown)	*/
912 
913 typedef struct _ipfw_obj_dyntlv {
914 	ipfw_obj_tlv	head;
915 	ipfw_dyn_rule	state;
916 } ipfw_obj_dyntlv;
917 #define	IPFW_DF_LAST	0x01		/* Last state in chain		*/
918 
919 /* Containter TLVs */
920 typedef struct _ipfw_obj_ctlv {
921 	ipfw_obj_tlv	head;		/* TLV header			*/
922 	uint32_t	count;		/* Number of sub-TLVs		*/
923 	uint16_t	objsize;	/* Single object size		*/
924 	uint8_t		version;	/* TLV version			*/
925 	uint8_t		flags;		/* TLV-specific flags		*/
926 } ipfw_obj_ctlv;
927 
928 /* Range TLV */
929 typedef struct _ipfw_range_tlv {
930 	ipfw_obj_tlv	head;		/* TLV header			*/
931 	uint32_t	flags;		/* Range flags			*/
932 	uint16_t	start_rule;	/* Range start			*/
933 	uint16_t	end_rule;	/* Range end			*/
934 	uint32_t	set;		/* Range set to match		 */
935 	uint32_t	new_set;	/* New set to move/swap to	*/
936 } ipfw_range_tlv;
937 #define	IPFW_RCFLAG_RANGE	0x01	/* rule range is set		*/
938 #define	IPFW_RCFLAG_ALL		0x02	/* match ALL rules		*/
939 #define	IPFW_RCFLAG_SET		0x04	/* match rules in given set	*/
940 /* User-settable flags */
941 #define	IPFW_RCFLAG_USER	(IPFW_RCFLAG_RANGE | IPFW_RCFLAG_ALL | \
942 	IPFW_RCFLAG_SET)
943 /* Internally used flags */
944 #define	IPFW_RCFLAG_DEFAULT	0x0100	/* Do not skip defaul rule	*/
945 
946 typedef struct _ipfw_ta_tinfo {
947 	uint32_t	flags;		/* Format flags			*/
948 	uint32_t	spare;
949 	uint8_t		taclass4;	/* algorithm class		*/
950 	uint8_t		spare4;
951 	uint16_t	itemsize4;	/* item size in runtime		*/
952 	uint32_t	size4;		/* runtime structure size	*/
953 	uint32_t	count4;		/* number of items in runtime	*/
954 	uint8_t		taclass6;	/* algorithm class		*/
955 	uint8_t		spare6;
956 	uint16_t	itemsize6;	/* item size in runtime		*/
957 	uint32_t	size6;		/* runtime structure size	*/
958 	uint32_t	count6;		/* number of items in runtime	*/
959 } ipfw_ta_tinfo;
960 #define	IPFW_TACLASS_HASH	1	/* algo is based on hash	*/
961 #define	IPFW_TACLASS_ARRAY	2	/* algo is based on array	*/
962 #define	IPFW_TACLASS_RADIX	3	/* algo is based on radix tree	*/
963 
964 #define	IPFW_TATFLAGS_DATA	0x0001		/* Has data filled in	*/
965 #define	IPFW_TATFLAGS_AFDATA	0x0002		/* Separate data per AF	*/
966 #define	IPFW_TATFLAGS_AFITEM	0x0004		/* diff. items per AF	*/
967 
968 typedef struct _ipfw_xtable_info {
969 	uint8_t		type;		/* table type (addr,iface,..)	*/
970 	uint8_t		tflags;		/* type flags			*/
971 	uint16_t	mflags;		/* modification flags		*/
972 	uint16_t	flags;		/* generic table flags		*/
973 	uint16_t	spare[3];
974 	uint32_t	vmask;		/* bitmask with value types 	*/
975 	uint32_t	set;		/* set table is in		*/
976 	uint32_t	kidx;		/* kernel index			*/
977 	uint32_t	refcnt;		/* number of references		*/
978 	uint32_t	count;		/* Number of records		*/
979 	uint32_t	size;		/* Total size of records(export)*/
980 	uint32_t	limit;		/* Max number of records	*/
981 	char		tablename[64];	/* table name */
982 	char		algoname[64];	/* algorithm name		*/
983 	ipfw_ta_tinfo	ta_info;	/* additional algo stats	*/
984 } ipfw_xtable_info;
985 /* Generic table flags */
986 #define	IPFW_TGFLAGS_LOCKED	0x01	/* Tables is locked from changes*/
987 /* Table type-specific flags */
988 #define	IPFW_TFFLAG_SRCIP	0x01
989 #define	IPFW_TFFLAG_DSTIP	0x02
990 #define	IPFW_TFFLAG_SRCPORT	0x04
991 #define	IPFW_TFFLAG_DSTPORT	0x08
992 #define	IPFW_TFFLAG_PROTO	0x10
993 /* Table modification flags */
994 #define	IPFW_TMFLAGS_LIMIT	0x0002	/* Change limit value		*/
995 #define	IPFW_TMFLAGS_LOCK	0x0004	/* Change table lock state	*/
996 
997 typedef struct _ipfw_iface_info {
998 	char		ifname[64];	/* interface name		*/
999 	uint32_t	ifindex;	/* interface index		*/
1000 	uint32_t	flags;		/* flags			*/
1001 	uint32_t	refcnt;		/* number of references		*/
1002 	uint32_t	gencnt;		/* number of changes		*/
1003 	uint64_t	spare;
1004 } ipfw_iface_info;
1005 #define	IPFW_IFFLAG_RESOLVED	0x01	/* Interface exists		*/
1006 
1007 typedef struct _ipfw_ta_info {
1008 	char		algoname[64];	/* algorithm name		*/
1009 	uint32_t	type;		/* lookup type			*/
1010 	uint32_t	flags;
1011 	uint32_t	refcnt;
1012 	uint32_t	spare0;
1013 	uint64_t	spare1;
1014 } ipfw_ta_info;
1015 
1016 typedef struct _ipfw_obj_header {
1017 	ip_fw3_opheader	opheader;	/* IP_FW3 opcode		*/
1018 	uint32_t	spare;
1019 	uint16_t	idx;		/* object name index		*/
1020 	uint8_t		objtype;	/* object type			*/
1021 	uint8_t		objsubtype;	/* object subtype		*/
1022 	ipfw_obj_ntlv	ntlv;		/* object name tlv		*/
1023 } ipfw_obj_header;
1024 
1025 typedef struct _ipfw_obj_lheader {
1026 	ip_fw3_opheader	opheader;	/* IP_FW3 opcode		*/
1027 	uint32_t	set_mask;	/* disabled set mask		*/
1028 	uint32_t	count;		/* Total objects count		*/
1029 	uint32_t	size;		/* Total size (incl. header)	*/
1030 	uint32_t	objsize;	/* Size of one object		*/
1031 } ipfw_obj_lheader;
1032 
1033 #define	IPFW_CFG_GET_STATIC	0x01
1034 #define	IPFW_CFG_GET_STATES	0x02
1035 #define	IPFW_CFG_GET_COUNTERS	0x04
1036 typedef struct _ipfw_cfg_lheader {
1037 	ip_fw3_opheader	opheader;	/* IP_FW3 opcode		*/
1038 	uint32_t	set_mask;	/* enabled set mask		*/
1039 	uint32_t	spare;
1040 	uint32_t	flags;		/* Request flags		*/
1041 	uint32_t	size;		/* neded buffer size		*/
1042 	uint32_t	start_rule;
1043 	uint32_t	end_rule;
1044 } ipfw_cfg_lheader;
1045 
1046 typedef struct _ipfw_range_header {
1047 	ip_fw3_opheader	opheader;	/* IP_FW3 opcode		*/
1048 	ipfw_range_tlv	range;
1049 } ipfw_range_header;
1050 
1051 typedef struct _ipfw_sopt_info {
1052 	uint16_t	opcode;
1053 	uint8_t		version;
1054 	uint8_t		dir;
1055 	uint8_t		spare;
1056 	uint64_t	refcnt;
1057 } ipfw_sopt_info;
1058 
1059 #endif /* _IPFW2_H */
1060