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