ip_fw.h revision 232865
1/*- 2 * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * 25 * $FreeBSD: head/sys/netinet/ip_fw.h 232865 2012-03-12 14:07:57Z melifaro $ 26 */ 27 28#ifndef _IPFW2_H 29#define _IPFW2_H 30 31/* 32 * The default rule number. By the design of ip_fw, the default rule 33 * is the last one, so its number can also serve as the highest number 34 * allowed for a rule. The ip_fw code relies on both meanings of this 35 * constant. 36 */ 37#define IPFW_DEFAULT_RULE 65535 38 39/* 40 * Default number of ipfw tables. 41 */ 42#define IPFW_TABLES_MAX 128 43 44/* 45 * Most commands (queue, pipe, tag, untag, limit...) can have a 16-bit 46 * argument between 1 and 65534. The value 0 is unused, the value 47 * 65535 (IP_FW_TABLEARG) is used to represent 'tablearg', i.e. the 48 * can be 1..65534, or 65535 to indicate the use of a 'tablearg' 49 * result of the most recent table() lookup. 50 * Note that 16bit is only a historical limit, resulting from 51 * the use of a 16-bit fields for that value. In reality, we can have 52 * 2^32 pipes, queues, tag values and so on, and use 0 as a tablearg. 53 */ 54#define IPFW_ARG_MIN 1 55#define IPFW_ARG_MAX 65534 56#define IP_FW_TABLEARG 65535 /* XXX should use 0 */ 57 58/* 59 * Number of entries in the call stack of the call/return commands. 60 * Call stack currently is an uint16_t array with rule numbers. 61 */ 62#define IPFW_CALLSTACK_SIZE 16 63 64/* IP_FW3 header/opcodes */ 65typedef struct _ip_fw3_opheader { 66 uint16_t opcode; /* Operation opcode */ 67 uint16_t reserved[3]; /* Align to 64-bit boundary */ 68} ip_fw3_opheader; 69 70 71/* IPFW extented tables support */ 72#define IP_FW_TABLE_XADD 86 /* add entry */ 73#define IP_FW_TABLE_XDEL 87 /* delete entry */ 74#define IP_FW_TABLE_XGETSIZE 88 /* get table size */ 75#define IP_FW_TABLE_XLIST 89 /* list table contents */ 76 77/* 78 * The kernel representation of ipfw rules is made of a list of 79 * 'instructions' (for all practical purposes equivalent to BPF 80 * instructions), which specify which fields of the packet 81 * (or its metadata) should be analysed. 82 * 83 * Each instruction is stored in a structure which begins with 84 * "ipfw_insn", and can contain extra fields depending on the 85 * instruction type (listed below). 86 * Note that the code is written so that individual instructions 87 * have a size which is a multiple of 32 bits. This means that, if 88 * such structures contain pointers or other 64-bit entities, 89 * (there is just one instance now) they may end up unaligned on 90 * 64-bit architectures, so the must be handled with care. 91 * 92 * "enum ipfw_opcodes" are the opcodes supported. We can have up 93 * to 256 different opcodes. When adding new opcodes, they should 94 * be appended to the end of the opcode list before O_LAST_OPCODE, 95 * this will prevent the ABI from being broken, otherwise users 96 * will have to recompile ipfw(8) when they update the kernel. 97 */ 98 99enum ipfw_opcodes { /* arguments (4 byte each) */ 100 O_NOP, 101 102 O_IP_SRC, /* u32 = IP */ 103 O_IP_SRC_MASK, /* ip = IP/mask */ 104 O_IP_SRC_ME, /* none */ 105 O_IP_SRC_SET, /* u32=base, arg1=len, bitmap */ 106 107 O_IP_DST, /* u32 = IP */ 108 O_IP_DST_MASK, /* ip = IP/mask */ 109 O_IP_DST_ME, /* none */ 110 O_IP_DST_SET, /* u32=base, arg1=len, bitmap */ 111 112 O_IP_SRCPORT, /* (n)port list:mask 4 byte ea */ 113 O_IP_DSTPORT, /* (n)port list:mask 4 byte ea */ 114 O_PROTO, /* arg1=protocol */ 115 116 O_MACADDR2, /* 2 mac addr:mask */ 117 O_MAC_TYPE, /* same as srcport */ 118 119 O_LAYER2, /* none */ 120 O_IN, /* none */ 121 O_FRAG, /* none */ 122 123 O_RECV, /* none */ 124 O_XMIT, /* none */ 125 O_VIA, /* none */ 126 127 O_IPOPT, /* arg1 = 2*u8 bitmap */ 128 O_IPLEN, /* arg1 = len */ 129 O_IPID, /* arg1 = id */ 130 131 O_IPTOS, /* arg1 = id */ 132 O_IPPRECEDENCE, /* arg1 = precedence << 5 */ 133 O_IPTTL, /* arg1 = TTL */ 134 135 O_IPVER, /* arg1 = version */ 136 O_UID, /* u32 = id */ 137 O_GID, /* u32 = id */ 138 O_ESTAB, /* none (tcp established) */ 139 O_TCPFLAGS, /* arg1 = 2*u8 bitmap */ 140 O_TCPWIN, /* arg1 = desired win */ 141 O_TCPSEQ, /* u32 = desired seq. */ 142 O_TCPACK, /* u32 = desired seq. */ 143 O_ICMPTYPE, /* u32 = icmp bitmap */ 144 O_TCPOPTS, /* arg1 = 2*u8 bitmap */ 145 146 O_VERREVPATH, /* none */ 147 O_VERSRCREACH, /* none */ 148 149 O_PROBE_STATE, /* none */ 150 O_KEEP_STATE, /* none */ 151 O_LIMIT, /* ipfw_insn_limit */ 152 O_LIMIT_PARENT, /* dyn_type, not an opcode. */ 153 154 /* 155 * These are really 'actions'. 156 */ 157 158 O_LOG, /* ipfw_insn_log */ 159 O_PROB, /* u32 = match probability */ 160 161 O_CHECK_STATE, /* none */ 162 O_ACCEPT, /* none */ 163 O_DENY, /* none */ 164 O_REJECT, /* arg1=icmp arg (same as deny) */ 165 O_COUNT, /* none */ 166 O_SKIPTO, /* arg1=next rule number */ 167 O_PIPE, /* arg1=pipe number */ 168 O_QUEUE, /* arg1=queue number */ 169 O_DIVERT, /* arg1=port number */ 170 O_TEE, /* arg1=port number */ 171 O_FORWARD_IP, /* fwd sockaddr */ 172 O_FORWARD_MAC, /* fwd mac */ 173 O_NAT, /* nope */ 174 O_REASS, /* none */ 175 176 /* 177 * More opcodes. 178 */ 179 O_IPSEC, /* has ipsec history */ 180 O_IP_SRC_LOOKUP, /* arg1=table number, u32=value */ 181 O_IP_DST_LOOKUP, /* arg1=table number, u32=value */ 182 O_ANTISPOOF, /* none */ 183 O_JAIL, /* u32 = id */ 184 O_ALTQ, /* u32 = altq classif. qid */ 185 O_DIVERTED, /* arg1=bitmap (1:loop, 2:out) */ 186 O_TCPDATALEN, /* arg1 = tcp data len */ 187 O_IP6_SRC, /* address without mask */ 188 O_IP6_SRC_ME, /* my addresses */ 189 O_IP6_SRC_MASK, /* address with the mask */ 190 O_IP6_DST, 191 O_IP6_DST_ME, 192 O_IP6_DST_MASK, 193 O_FLOW6ID, /* for flow id tag in the ipv6 pkt */ 194 O_ICMP6TYPE, /* icmp6 packet type filtering */ 195 O_EXT_HDR, /* filtering for ipv6 extension header */ 196 O_IP6, 197 198 /* 199 * actions for ng_ipfw 200 */ 201 O_NETGRAPH, /* send to ng_ipfw */ 202 O_NGTEE, /* copy to ng_ipfw */ 203 204 O_IP4, 205 206 O_UNREACH6, /* arg1=icmpv6 code arg (deny) */ 207 208 O_TAG, /* arg1=tag number */ 209 O_TAGGED, /* arg1=tag number */ 210 211 O_SETFIB, /* arg1=FIB number */ 212 O_FIB, /* arg1=FIB desired fib number */ 213 214 O_SOCKARG, /* socket argument */ 215 216 O_CALLRETURN, /* arg1=called rule number */ 217 218 O_FORWARD_IP6, /* fwd sockaddr_in6 */ 219 220 O_LAST_OPCODE /* not an opcode! */ 221}; 222 223 224/* 225 * The extension header are filtered only for presence using a bit 226 * vector with a flag for each header. 227 */ 228#define EXT_FRAGMENT 0x1 229#define EXT_HOPOPTS 0x2 230#define EXT_ROUTING 0x4 231#define EXT_AH 0x8 232#define EXT_ESP 0x10 233#define EXT_DSTOPTS 0x20 234#define EXT_RTHDR0 0x40 235#define EXT_RTHDR2 0x80 236 237/* 238 * Template for instructions. 239 * 240 * ipfw_insn is used for all instructions which require no operands, 241 * a single 16-bit value (arg1), or a couple of 8-bit values. 242 * 243 * For other instructions which require different/larger arguments 244 * we have derived structures, ipfw_insn_*. 245 * 246 * The size of the instruction (in 32-bit words) is in the low 247 * 6 bits of "len". The 2 remaining bits are used to implement 248 * NOT and OR on individual instructions. Given a type, you can 249 * compute the length to be put in "len" using F_INSN_SIZE(t) 250 * 251 * F_NOT negates the match result of the instruction. 252 * 253 * F_OR is used to build or blocks. By default, instructions 254 * are evaluated as part of a logical AND. An "or" block 255 * { X or Y or Z } contains F_OR set in all but the last 256 * instruction of the block. A match will cause the code 257 * to skip past the last instruction of the block. 258 * 259 * NOTA BENE: in a couple of places we assume that 260 * sizeof(ipfw_insn) == sizeof(u_int32_t) 261 * this needs to be fixed. 262 * 263 */ 264typedef struct _ipfw_insn { /* template for instructions */ 265 u_int8_t opcode; 266 u_int8_t len; /* number of 32-bit words */ 267#define F_NOT 0x80 268#define F_OR 0x40 269#define F_LEN_MASK 0x3f 270#define F_LEN(cmd) ((cmd)->len & F_LEN_MASK) 271 272 u_int16_t arg1; 273} ipfw_insn; 274 275/* 276 * The F_INSN_SIZE(type) computes the size, in 4-byte words, of 277 * a given type. 278 */ 279#define F_INSN_SIZE(t) ((sizeof (t))/sizeof(u_int32_t)) 280 281/* 282 * This is used to store an array of 16-bit entries (ports etc.) 283 */ 284typedef struct _ipfw_insn_u16 { 285 ipfw_insn o; 286 u_int16_t ports[2]; /* there may be more */ 287} ipfw_insn_u16; 288 289/* 290 * This is used to store an array of 32-bit entries 291 * (uid, single IPv4 addresses etc.) 292 */ 293typedef struct _ipfw_insn_u32 { 294 ipfw_insn o; 295 u_int32_t d[1]; /* one or more */ 296} ipfw_insn_u32; 297 298/* 299 * This is used to store IP addr-mask pairs. 300 */ 301typedef struct _ipfw_insn_ip { 302 ipfw_insn o; 303 struct in_addr addr; 304 struct in_addr mask; 305} ipfw_insn_ip; 306 307/* 308 * This is used to forward to a given address (ip). 309 */ 310typedef struct _ipfw_insn_sa { 311 ipfw_insn o; 312 struct sockaddr_in sa; 313} ipfw_insn_sa; 314 315/* 316 * This is used to forward to a given address (ipv6). 317 */ 318typedef struct _ipfw_insn_sa6 { 319 ipfw_insn o; 320 struct sockaddr_in6 sa; 321} ipfw_insn_sa6; 322 323/* 324 * This is used for MAC addr-mask pairs. 325 */ 326typedef struct _ipfw_insn_mac { 327 ipfw_insn o; 328 u_char addr[12]; /* dst[6] + src[6] */ 329 u_char mask[12]; /* dst[6] + src[6] */ 330} ipfw_insn_mac; 331 332/* 333 * This is used for interface match rules (recv xx, xmit xx). 334 */ 335typedef struct _ipfw_insn_if { 336 ipfw_insn o; 337 union { 338 struct in_addr ip; 339 int glob; 340 } p; 341 char name[IFNAMSIZ]; 342} ipfw_insn_if; 343 344/* 345 * This is used for storing an altq queue id number. 346 */ 347typedef struct _ipfw_insn_altq { 348 ipfw_insn o; 349 u_int32_t qid; 350} ipfw_insn_altq; 351 352/* 353 * This is used for limit rules. 354 */ 355typedef struct _ipfw_insn_limit { 356 ipfw_insn o; 357 u_int8_t _pad; 358 u_int8_t limit_mask; /* combination of DYN_* below */ 359#define DYN_SRC_ADDR 0x1 360#define DYN_SRC_PORT 0x2 361#define DYN_DST_ADDR 0x4 362#define DYN_DST_PORT 0x8 363 364 u_int16_t conn_limit; 365} ipfw_insn_limit; 366 367/* 368 * This is used for log instructions. 369 */ 370typedef struct _ipfw_insn_log { 371 ipfw_insn o; 372 u_int32_t max_log; /* how many do we log -- 0 = all */ 373 u_int32_t log_left; /* how many left to log */ 374} ipfw_insn_log; 375 376/* 377 * Data structures required by both ipfw(8) and ipfw(4) but not part of the 378 * management API are protected by IPFW_INTERNAL. 379 */ 380#ifdef IPFW_INTERNAL 381/* Server pool support (LSNAT). */ 382struct cfg_spool { 383 LIST_ENTRY(cfg_spool) _next; /* chain of spool instances */ 384 struct in_addr addr; 385 u_short port; 386}; 387#endif 388 389/* Redirect modes id. */ 390#define REDIR_ADDR 0x01 391#define REDIR_PORT 0x02 392#define REDIR_PROTO 0x04 393 394#ifdef IPFW_INTERNAL 395/* Nat redirect configuration. */ 396struct cfg_redir { 397 LIST_ENTRY(cfg_redir) _next; /* chain of redir instances */ 398 u_int16_t mode; /* type of redirect mode */ 399 struct in_addr laddr; /* local ip address */ 400 struct in_addr paddr; /* public ip address */ 401 struct in_addr raddr; /* remote ip address */ 402 u_short lport; /* local port */ 403 u_short pport; /* public port */ 404 u_short rport; /* remote port */ 405 u_short pport_cnt; /* number of public ports */ 406 u_short rport_cnt; /* number of remote ports */ 407 int proto; /* protocol: tcp/udp */ 408 struct alias_link **alink; 409 /* num of entry in spool chain */ 410 u_int16_t spool_cnt; 411 /* chain of spool instances */ 412 LIST_HEAD(spool_chain, cfg_spool) spool_chain; 413}; 414#endif 415 416#ifdef IPFW_INTERNAL 417/* Nat configuration data struct. */ 418struct cfg_nat { 419 /* chain of nat instances */ 420 LIST_ENTRY(cfg_nat) _next; 421 int id; /* nat id */ 422 struct in_addr ip; /* nat ip address */ 423 char if_name[IF_NAMESIZE]; /* interface name */ 424 int mode; /* aliasing mode */ 425 struct libalias *lib; /* libalias instance */ 426 /* number of entry in spool chain */ 427 int redir_cnt; 428 /* chain of redir instances */ 429 LIST_HEAD(redir_chain, cfg_redir) redir_chain; 430}; 431#endif 432 433#define SOF_NAT sizeof(struct cfg_nat) 434#define SOF_REDIR sizeof(struct cfg_redir) 435#define SOF_SPOOL sizeof(struct cfg_spool) 436 437/* Nat command. */ 438typedef struct _ipfw_insn_nat { 439 ipfw_insn o; 440 struct cfg_nat *nat; 441} ipfw_insn_nat; 442 443/* Apply ipv6 mask on ipv6 addr */ 444#define APPLY_MASK(addr,mask) \ 445 (addr)->__u6_addr.__u6_addr32[0] &= (mask)->__u6_addr.__u6_addr32[0]; \ 446 (addr)->__u6_addr.__u6_addr32[1] &= (mask)->__u6_addr.__u6_addr32[1]; \ 447 (addr)->__u6_addr.__u6_addr32[2] &= (mask)->__u6_addr.__u6_addr32[2]; \ 448 (addr)->__u6_addr.__u6_addr32[3] &= (mask)->__u6_addr.__u6_addr32[3]; 449 450/* Structure for ipv6 */ 451typedef struct _ipfw_insn_ip6 { 452 ipfw_insn o; 453 struct in6_addr addr6; 454 struct in6_addr mask6; 455} ipfw_insn_ip6; 456 457/* Used to support icmp6 types */ 458typedef struct _ipfw_insn_icmp6 { 459 ipfw_insn o; 460 uint32_t d[7]; /* XXX This number si related to the netinet/icmp6.h 461 * define ICMP6_MAXTYPE 462 * as follows: n = ICMP6_MAXTYPE/32 + 1 463 * Actually is 203 464 */ 465} ipfw_insn_icmp6; 466 467/* 468 * Here we have the structure representing an ipfw rule. 469 * 470 * It starts with a general area (with link fields and counters) 471 * followed by an array of one or more instructions, which the code 472 * accesses as an array of 32-bit values. 473 * 474 * Given a rule pointer r: 475 * 476 * r->cmd is the start of the first instruction. 477 * ACTION_PTR(r) is the start of the first action (things to do 478 * once a rule matched). 479 * 480 * When assembling instruction, remember the following: 481 * 482 * + if a rule has a "keep-state" (or "limit") option, then the 483 * first instruction (at r->cmd) MUST BE an O_PROBE_STATE 484 * + if a rule has a "log" option, then the first action 485 * (at ACTION_PTR(r)) MUST be O_LOG 486 * + if a rule has an "altq" option, it comes after "log" 487 * + if a rule has an O_TAG option, it comes after "log" and "altq" 488 * 489 * NOTE: we use a simple linked list of rules because we never need 490 * to delete a rule without scanning the list. We do not use 491 * queue(3) macros for portability and readability. 492 */ 493 494struct ip_fw { 495 struct ip_fw *x_next; /* linked list of rules */ 496 struct ip_fw *next_rule; /* ptr to next [skipto] rule */ 497 /* 'next_rule' is used to pass up 'set_disable' status */ 498 499 uint16_t act_ofs; /* offset of action in 32-bit units */ 500 uint16_t cmd_len; /* # of 32-bit words in cmd */ 501 uint16_t rulenum; /* rule number */ 502 uint8_t set; /* rule set (0..31) */ 503#define RESVD_SET 31 /* set for default and persistent rules */ 504 uint8_t _pad; /* padding */ 505 uint32_t id; /* rule id */ 506 507 /* These fields are present in all rules. */ 508 uint64_t pcnt; /* Packet counter */ 509 uint64_t bcnt; /* Byte counter */ 510 uint32_t timestamp; /* tv_sec of last match */ 511 512 ipfw_insn cmd[1]; /* storage for commands */ 513}; 514 515#define ACTION_PTR(rule) \ 516 (ipfw_insn *)( (u_int32_t *)((rule)->cmd) + ((rule)->act_ofs) ) 517 518#define RULESIZE(rule) (sizeof(struct ip_fw) + \ 519 ((struct ip_fw *)(rule))->cmd_len * 4 - 4) 520 521#if 1 // should be moved to in.h 522/* 523 * This structure is used as a flow mask and a flow id for various 524 * parts of the code. 525 * addr_type is used in userland and kernel to mark the address type. 526 * fib is used in the kernel to record the fib in use. 527 * _flags is used in the kernel to store tcp flags for dynamic rules. 528 */ 529struct ipfw_flow_id { 530 uint32_t dst_ip; 531 uint32_t src_ip; 532 uint16_t dst_port; 533 uint16_t src_port; 534 uint8_t fib; 535 uint8_t proto; 536 uint8_t _flags; /* protocol-specific flags */ 537 uint8_t addr_type; /* 4=ip4, 6=ip6, 1=ether ? */ 538 struct in6_addr dst_ip6; 539 struct in6_addr src_ip6; 540 uint32_t flow_id6; 541 uint32_t extra; /* queue/pipe or frag_id */ 542}; 543#endif 544 545#define IS_IP6_FLOW_ID(id) ((id)->addr_type == 6) 546 547/* 548 * Dynamic ipfw rule. 549 */ 550typedef struct _ipfw_dyn_rule ipfw_dyn_rule; 551 552struct _ipfw_dyn_rule { 553 ipfw_dyn_rule *next; /* linked list of rules. */ 554 struct ip_fw *rule; /* pointer to rule */ 555 /* 'rule' is used to pass up the rule number (from the parent) */ 556 557 ipfw_dyn_rule *parent; /* pointer to parent rule */ 558 u_int64_t pcnt; /* packet match counter */ 559 u_int64_t bcnt; /* byte match counter */ 560 struct ipfw_flow_id id; /* (masked) flow id */ 561 u_int32_t expire; /* expire time */ 562 u_int32_t bucket; /* which bucket in hash table */ 563 u_int32_t state; /* state of this rule (typically a 564 * combination of TCP flags) 565 */ 566 u_int32_t ack_fwd; /* most recent ACKs in forward */ 567 u_int32_t ack_rev; /* and reverse directions (used */ 568 /* to generate keepalives) */ 569 u_int16_t dyn_type; /* rule type */ 570 u_int16_t count; /* refcount */ 571}; 572 573/* 574 * Definitions for IP option names. 575 */ 576#define IP_FW_IPOPT_LSRR 0x01 577#define IP_FW_IPOPT_SSRR 0x02 578#define IP_FW_IPOPT_RR 0x04 579#define IP_FW_IPOPT_TS 0x08 580 581/* 582 * Definitions for TCP option names. 583 */ 584#define IP_FW_TCPOPT_MSS 0x01 585#define IP_FW_TCPOPT_WINDOW 0x02 586#define IP_FW_TCPOPT_SACK 0x04 587#define IP_FW_TCPOPT_TS 0x08 588#define IP_FW_TCPOPT_CC 0x10 589 590#define ICMP_REJECT_RST 0x100 /* fake ICMP code (send a TCP RST) */ 591#define ICMP6_UNREACH_RST 0x100 /* fake ICMPv6 code (send a TCP RST) */ 592 593/* 594 * These are used for lookup tables. 595 */ 596 597#define IPFW_TABLE_CIDR 1 /* Table for holding IPv4/IPv6 prefixes */ 598#define IPFW_TABLE_INTERFACE 2 /* Table for holding interface names */ 599#define IPFW_TABLE_MAXTYPE 2 /* Maximum valid number */ 600 601typedef struct _ipfw_table_entry { 602 in_addr_t addr; /* network address */ 603 u_int32_t value; /* value */ 604 u_int16_t tbl; /* table number */ 605 u_int8_t masklen; /* mask length */ 606} ipfw_table_entry; 607 608typedef struct _ipfw_table_xentry { 609 uint16_t len; /* Total entry length */ 610 uint8_t type; /* entry type */ 611 uint8_t masklen; /* mask length */ 612 uint16_t tbl; /* table number */ 613 uint32_t value; /* value */ 614 union { 615 /* Longest field needs to be aligned by 4-byte boundary */ 616 struct in6_addr addr6; /* IPv6 address */ 617 char iface[IF_NAMESIZE]; /* interface name */ 618 } k; 619} ipfw_table_xentry; 620 621typedef struct _ipfw_table { 622 u_int32_t size; /* size of entries in bytes */ 623 u_int32_t cnt; /* # of entries */ 624 u_int16_t tbl; /* table number */ 625 ipfw_table_entry ent[0]; /* entries */ 626} ipfw_table; 627 628typedef struct _ipfw_xtable { 629 ip_fw3_opheader opheader; /* eXtended tables are controlled via IP_FW3 */ 630 uint32_t size; /* size of entries in bytes */ 631 uint32_t cnt; /* # of entries */ 632 uint16_t tbl; /* table number */ 633 uint8_t type; /* table type */ 634 ipfw_table_xentry xent[0]; /* entries */ 635} ipfw_xtable; 636 637#endif /* _IPFW2_H */ 638