1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2001 Daniel Hartmeier 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * $OpenBSD: pfvar.h,v 1.282 2009/01/29 15:12:28 pyr Exp $ 32 * $FreeBSD$ 33 */ 34 35 #ifndef _NET_PFVAR_H_ 36 #define _NET_PFVAR_H_ 37 38 #include <sys/counter.h> 39 #include <sys/tree.h> 40 #include <sys/queue.h> 41 42 #include <net/radix.h> 43 #include <netinet/in.h> 44 45 #include <netpfil/pf/pf.h> 46 #include <netpfil/pf/pf_altq.h> 47 48 #ifndef __packed 49 #define __packed __attribute__((__packed__)) 50 #endif 51 52 /* Both IPv4 and IPv6 */ 53 #ifdef PF_INET_INET6 54 55 #define PF_AEQ(a, b, c) \ 56 ((c == AF_INET && (a)->addr32[0] == (b)->addr32[0]) || \ 57 (c == AF_INET6 && (a)->addr32[3] == (b)->addr32[3] && \ 58 (a)->addr32[2] == (b)->addr32[2] && \ 59 (a)->addr32[1] == (b)->addr32[1] && \ 60 (a)->addr32[0] == (b)->addr32[0])) \ 61 62 #define PF_ANEQ(a, b, c) \ 63 ((c == AF_INET && (a)->addr32[0] != (b)->addr32[0]) || \ 64 (c == AF_INET6 && ((a)->addr32[0] != (b)->addr32[0] || \ 65 (a)->addr32[1] != (b)->addr32[1] || \ 66 (a)->addr32[2] != (b)->addr32[2] || \ 67 (a)->addr32[3] != (b)->addr32[3]))) \ 68 69 #define PF_AZERO(a, c) \ 70 ((c == AF_INET && !(a)->addr32[0]) || \ 71 (c == AF_INET6 && !(a)->addr32[0] && !(a)->addr32[1] && \ 72 !(a)->addr32[2] && !(a)->addr32[3] )) \ 73 74 #define PF_MATCHA(n, a, m, b, f) \ 75 pf_match_addr(n, a, m, b, f) 76 77 #define PF_ACPY(a, b, f) \ 78 pf_addrcpy(a, b, f) 79 80 #define PF_AINC(a, f) \ 81 pf_addr_inc(a, f) 82 83 #define PF_POOLMASK(a, b, c, d, f) \ 84 pf_poolmask(a, b, c, d, f) 85 86 #else 87 88 /* Just IPv6 */ 89 90 #ifdef PF_INET6_ONLY 91 92 #define PF_AEQ(a, b, c) \ 93 ((a)->addr32[3] == (b)->addr32[3] && \ 94 (a)->addr32[2] == (b)->addr32[2] && \ 95 (a)->addr32[1] == (b)->addr32[1] && \ 96 (a)->addr32[0] == (b)->addr32[0]) \ 97 98 #define PF_ANEQ(a, b, c) \ 99 ((a)->addr32[3] != (b)->addr32[3] || \ 100 (a)->addr32[2] != (b)->addr32[2] || \ 101 (a)->addr32[1] != (b)->addr32[1] || \ 102 (a)->addr32[0] != (b)->addr32[0]) \ 103 104 #define PF_AZERO(a, c) \ 105 (!(a)->addr32[0] && \ 106 !(a)->addr32[1] && \ 107 !(a)->addr32[2] && \ 108 !(a)->addr32[3] ) \ 109 110 #define PF_MATCHA(n, a, m, b, f) \ 111 pf_match_addr(n, a, m, b, f) 112 113 #define PF_ACPY(a, b, f) \ 114 pf_addrcpy(a, b, f) 115 116 #define PF_AINC(a, f) \ 117 pf_addr_inc(a, f) 118 119 #define PF_POOLMASK(a, b, c, d, f) \ 120 pf_poolmask(a, b, c, d, f) 121 122 #else 123 124 /* Just IPv4 */ 125 #ifdef PF_INET_ONLY 126 127 #define PF_AEQ(a, b, c) \ 128 ((a)->addr32[0] == (b)->addr32[0]) 129 130 #define PF_ANEQ(a, b, c) \ 131 ((a)->addr32[0] != (b)->addr32[0]) 132 133 #define PF_AZERO(a, c) \ 134 (!(a)->addr32[0]) 135 136 #define PF_MATCHA(n, a, m, b, f) \ 137 pf_match_addr(n, a, m, b, f) 138 139 #define PF_ACPY(a, b, f) \ 140 (a)->v4.s_addr = (b)->v4.s_addr 141 142 #define PF_AINC(a, f) \ 143 do { \ 144 (a)->addr32[0] = htonl(ntohl((a)->addr32[0]) + 1); \ 145 } while (0) 146 147 #define PF_POOLMASK(a, b, c, d, f) \ 148 do { \ 149 (a)->addr32[0] = ((b)->addr32[0] & (c)->addr32[0]) | \ 150 (((c)->addr32[0] ^ 0xffffffff ) & (d)->addr32[0]); \ 151 } while (0) 152 153 #endif /* PF_INET_ONLY */ 154 #endif /* PF_INET6_ONLY */ 155 #endif /* PF_INET_INET6 */ 156 157 /* 158 * XXX callers not FIB-aware in our version of pf yet. 159 * OpenBSD fixed it later it seems, 2010/05/07 13:33:16 claudio. 160 */ 161 #define PF_MISMATCHAW(aw, x, af, neg, ifp, rtid) \ 162 ( \ 163 (((aw)->type == PF_ADDR_NOROUTE && \ 164 pf_routable((x), (af), NULL, (rtid))) || \ 165 (((aw)->type == PF_ADDR_URPFFAILED && (ifp) != NULL && \ 166 pf_routable((x), (af), (ifp), (rtid))) || \ 167 ((aw)->type == PF_ADDR_TABLE && \ 168 !pfr_match_addr((aw)->p.tbl, (x), (af))) || \ 169 ((aw)->type == PF_ADDR_DYNIFTL && \ 170 !pfi_match_addr((aw)->p.dyn, (x), (af))) || \ 171 ((aw)->type == PF_ADDR_RANGE && \ 172 !pf_match_addr_range(&(aw)->v.a.addr, \ 173 &(aw)->v.a.mask, (x), (af))) || \ 174 ((aw)->type == PF_ADDR_ADDRMASK && \ 175 !PF_AZERO(&(aw)->v.a.mask, (af)) && \ 176 !PF_MATCHA(0, &(aw)->v.a.addr, \ 177 &(aw)->v.a.mask, (x), (af))))) != \ 178 (neg) \ 179 ) 180 181 #define PF_ALGNMNT(off) (((off) % 2) == 0) 182 183 #ifdef _KERNEL 184 185 struct pf_kpooladdr { 186 struct pf_addr_wrap addr; 187 TAILQ_ENTRY(pf_kpooladdr) entries; 188 char ifname[IFNAMSIZ]; 189 struct pfi_kkif *kif; 190 }; 191 192 TAILQ_HEAD(pf_kpalist, pf_kpooladdr); 193 194 struct pf_kpool { 195 struct pf_kpalist list; 196 struct pf_kpooladdr *cur; 197 struct pf_poolhashkey key; 198 struct pf_addr counter; 199 int tblidx; 200 u_int16_t proxy_port[2]; 201 u_int8_t opts; 202 }; 203 204 union pf_krule_ptr { 205 struct pf_krule *ptr; 206 u_int32_t nr; 207 }; 208 209 struct pf_krule { 210 struct pf_rule_addr src; 211 struct pf_rule_addr dst; 212 union pf_krule_ptr skip[PF_SKIP_COUNT]; 213 char label[PF_RULE_LABEL_SIZE]; 214 char ifname[IFNAMSIZ]; 215 char qname[PF_QNAME_SIZE]; 216 char pqname[PF_QNAME_SIZE]; 217 char tagname[PF_TAG_NAME_SIZE]; 218 char match_tagname[PF_TAG_NAME_SIZE]; 219 220 char overload_tblname[PF_TABLE_NAME_SIZE]; 221 222 TAILQ_ENTRY(pf_krule) entries; 223 struct pf_kpool rpool; 224 225 counter_u64_t evaluations; 226 counter_u64_t packets[2]; 227 counter_u64_t bytes[2]; 228 229 struct pfi_kkif *kif; 230 struct pf_kanchor *anchor; 231 struct pfr_ktable *overload_tbl; 232 233 pf_osfp_t os_fingerprint; 234 235 int rtableid; 236 u_int32_t timeout[PFTM_MAX]; 237 u_int32_t max_states; 238 u_int32_t max_src_nodes; 239 u_int32_t max_src_states; 240 u_int32_t max_src_conn; 241 struct { 242 u_int32_t limit; 243 u_int32_t seconds; 244 } max_src_conn_rate; 245 u_int32_t qid; 246 u_int32_t pqid; 247 u_int32_t rt_listid; 248 u_int32_t nr; 249 u_int32_t prob; 250 uid_t cuid; 251 pid_t cpid; 252 253 counter_u64_t states_cur; 254 counter_u64_t states_tot; 255 counter_u64_t src_nodes; 256 257 u_int16_t return_icmp; 258 u_int16_t return_icmp6; 259 u_int16_t max_mss; 260 u_int16_t tag; 261 u_int16_t match_tag; 262 u_int16_t scrub_flags; 263 264 struct pf_rule_uid uid; 265 struct pf_rule_gid gid; 266 267 u_int32_t rule_flag; 268 u_int8_t action; 269 u_int8_t direction; 270 u_int8_t log; 271 u_int8_t logif; 272 u_int8_t quick; 273 u_int8_t ifnot; 274 u_int8_t match_tag_not; 275 u_int8_t natpass; 276 277 u_int8_t keep_state; 278 sa_family_t af; 279 u_int8_t proto; 280 u_int8_t type; 281 u_int8_t code; 282 u_int8_t flags; 283 u_int8_t flagset; 284 u_int8_t min_ttl; 285 u_int8_t allow_opts; 286 u_int8_t rt; 287 u_int8_t return_ttl; 288 u_int8_t tos; 289 u_int8_t set_tos; 290 u_int8_t anchor_relative; 291 u_int8_t anchor_wildcard; 292 293 u_int8_t flush; 294 u_int8_t prio; 295 u_int8_t set_prio[2]; 296 297 struct { 298 struct pf_addr addr; 299 u_int16_t port; 300 } divert; 301 }; 302 303 struct pf_ksrc_node { 304 LIST_ENTRY(pf_ksrc_node) entry; 305 struct pf_addr addr; 306 struct pf_addr raddr; 307 union pf_krule_ptr rule; 308 struct pfi_kkif *kif; 309 counter_u64_t bytes[2]; 310 counter_u64_t packets[2]; 311 u_int32_t states; 312 u_int32_t conn; 313 struct pf_threshold conn_rate; 314 u_int32_t creation; 315 u_int32_t expire; 316 sa_family_t af; 317 u_int8_t ruletype; 318 }; 319 #endif 320 321 struct pf_state_scrub { 322 struct timeval pfss_last; /* time received last packet */ 323 u_int32_t pfss_tsecr; /* last echoed timestamp */ 324 u_int32_t pfss_tsval; /* largest timestamp */ 325 u_int32_t pfss_tsval0; /* original timestamp */ 326 u_int16_t pfss_flags; 327 #define PFSS_TIMESTAMP 0x0001 /* modulate timestamp */ 328 #define PFSS_PAWS 0x0010 /* stricter PAWS checks */ 329 #define PFSS_PAWS_IDLED 0x0020 /* was idle too long. no PAWS */ 330 #define PFSS_DATA_TS 0x0040 /* timestamp on data packets */ 331 #define PFSS_DATA_NOTS 0x0080 /* no timestamp on data packets */ 332 u_int8_t pfss_ttl; /* stashed TTL */ 333 u_int8_t pad; 334 u_int32_t pfss_ts_mod; /* timestamp modulation */ 335 }; 336 337 struct pf_state_host { 338 struct pf_addr addr; 339 u_int16_t port; 340 u_int16_t pad; 341 }; 342 343 struct pf_state_peer { 344 struct pf_state_scrub *scrub; /* state is scrubbed */ 345 u_int32_t seqlo; /* Max sequence number sent */ 346 u_int32_t seqhi; /* Max the other end ACKd + win */ 347 u_int32_t seqdiff; /* Sequence number modulator */ 348 u_int16_t max_win; /* largest window (pre scaling) */ 349 u_int16_t mss; /* Maximum segment size option */ 350 u_int8_t state; /* active state level */ 351 u_int8_t wscale; /* window scaling factor */ 352 u_int8_t tcp_est; /* Did we reach TCPS_ESTABLISHED */ 353 u_int8_t pad[1]; 354 }; 355 356 /* Keep synced with struct pf_state_key. */ 357 struct pf_state_key_cmp { 358 struct pf_addr addr[2]; 359 u_int16_t port[2]; 360 sa_family_t af; 361 u_int8_t proto; 362 u_int8_t pad[2]; 363 }; 364 365 struct pf_state_key { 366 struct pf_addr addr[2]; 367 u_int16_t port[2]; 368 sa_family_t af; 369 u_int8_t proto; 370 u_int8_t pad[2]; 371 372 LIST_ENTRY(pf_state_key) entry; 373 TAILQ_HEAD(, pf_state) states[2]; 374 }; 375 376 /* Keep synced with struct pf_state. */ 377 struct pf_state_cmp { 378 u_int64_t id; 379 u_int32_t creatorid; 380 u_int8_t direction; 381 u_int8_t pad[3]; 382 }; 383 384 #define PFSTATE_ALLOWOPTS 0x01 385 #define PFSTATE_SLOPPY 0x02 386 /* was PFSTATE_PFLOW 0x04 */ 387 #define PFSTATE_NOSYNC 0x08 388 #define PFSTATE_ACK 0x10 389 #define PFSTATE_SETPRIO 0x0200 390 #define PFSTATE_SETMASK (PFSTATE_SETPRIO) 391 392 #ifdef _KERNEL 393 struct pf_state { 394 u_int64_t id; 395 u_int32_t creatorid; 396 u_int8_t direction; 397 u_int8_t pad[3]; 398 399 u_int refs; 400 TAILQ_ENTRY(pf_state) sync_list; 401 TAILQ_ENTRY(pf_state) key_list[2]; 402 LIST_ENTRY(pf_state) entry; 403 struct pf_state_peer src; 404 struct pf_state_peer dst; 405 union pf_krule_ptr rule; 406 union pf_krule_ptr anchor; 407 union pf_krule_ptr nat_rule; 408 struct pf_addr rt_addr; 409 struct pf_state_key *key[2]; /* addresses stack and wire */ 410 struct pfi_kkif *kif; 411 struct pfi_kkif *rt_kif; 412 struct pf_ksrc_node *src_node; 413 struct pf_ksrc_node *nat_src_node; 414 counter_u64_t packets[2]; 415 counter_u64_t bytes[2]; 416 u_int32_t creation; 417 u_int32_t expire; 418 u_int32_t pfsync_time; 419 u_int16_t tag; 420 u_int8_t log; 421 u_int8_t state_flags; 422 u_int8_t timeout; 423 u_int8_t sync_state; /* PFSYNC_S_x */ 424 425 /* XXX */ 426 u_int8_t sync_updates; 427 u_int8_t _tail[3]; 428 }; 429 #endif 430 431 /* 432 * Unified state structures for pulling states out of the kernel 433 * used by pfsync(4) and the pf(4) ioctl. 434 */ 435 struct pfsync_state_scrub { 436 u_int16_t pfss_flags; 437 u_int8_t pfss_ttl; /* stashed TTL */ 438 #define PFSYNC_SCRUB_FLAG_VALID 0x01 439 u_int8_t scrub_flag; 440 u_int32_t pfss_ts_mod; /* timestamp modulation */ 441 } __packed; 442 443 struct pfsync_state_peer { 444 struct pfsync_state_scrub scrub; /* state is scrubbed */ 445 u_int32_t seqlo; /* Max sequence number sent */ 446 u_int32_t seqhi; /* Max the other end ACKd + win */ 447 u_int32_t seqdiff; /* Sequence number modulator */ 448 u_int16_t max_win; /* largest window (pre scaling) */ 449 u_int16_t mss; /* Maximum segment size option */ 450 u_int8_t state; /* active state level */ 451 u_int8_t wscale; /* window scaling factor */ 452 u_int8_t pad[6]; 453 } __packed; 454 455 struct pfsync_state_key { 456 struct pf_addr addr[2]; 457 u_int16_t port[2]; 458 }; 459 460 struct pfsync_state { 461 u_int64_t id; 462 char ifname[IFNAMSIZ]; 463 struct pfsync_state_key key[2]; 464 struct pfsync_state_peer src; 465 struct pfsync_state_peer dst; 466 struct pf_addr rt_addr; 467 u_int32_t rule; 468 u_int32_t anchor; 469 u_int32_t nat_rule; 470 u_int32_t creation; 471 u_int32_t expire; 472 u_int32_t packets[2][2]; 473 u_int32_t bytes[2][2]; 474 u_int32_t creatorid; 475 sa_family_t af; 476 u_int8_t proto; 477 u_int8_t direction; 478 u_int8_t __spare[2]; 479 u_int8_t log; 480 u_int8_t state_flags; 481 u_int8_t timeout; 482 u_int8_t sync_flags; 483 u_int8_t updates; 484 } __packed; 485 486 #define PFSYNC_FLAG_SRCNODE 0x04 487 #define PFSYNC_FLAG_NATSRCNODE 0x08 488 489 /* for copies to/from network byte order */ 490 /* ioctl interface also uses network byte order */ 491 #define pf_state_peer_hton(s,d) do { \ 492 (d)->seqlo = htonl((s)->seqlo); \ 493 (d)->seqhi = htonl((s)->seqhi); \ 494 (d)->seqdiff = htonl((s)->seqdiff); \ 495 (d)->max_win = htons((s)->max_win); \ 496 (d)->mss = htons((s)->mss); \ 497 (d)->state = (s)->state; \ 498 (d)->wscale = (s)->wscale; \ 499 if ((s)->scrub) { \ 500 (d)->scrub.pfss_flags = \ 501 htons((s)->scrub->pfss_flags & PFSS_TIMESTAMP); \ 502 (d)->scrub.pfss_ttl = (s)->scrub->pfss_ttl; \ 503 (d)->scrub.pfss_ts_mod = htonl((s)->scrub->pfss_ts_mod);\ 504 (d)->scrub.scrub_flag = PFSYNC_SCRUB_FLAG_VALID; \ 505 } \ 506 } while (0) 507 508 #define pf_state_peer_ntoh(s,d) do { \ 509 (d)->seqlo = ntohl((s)->seqlo); \ 510 (d)->seqhi = ntohl((s)->seqhi); \ 511 (d)->seqdiff = ntohl((s)->seqdiff); \ 512 (d)->max_win = ntohs((s)->max_win); \ 513 (d)->mss = ntohs((s)->mss); \ 514 (d)->state = (s)->state; \ 515 (d)->wscale = (s)->wscale; \ 516 if ((s)->scrub.scrub_flag == PFSYNC_SCRUB_FLAG_VALID && \ 517 (d)->scrub != NULL) { \ 518 (d)->scrub->pfss_flags = \ 519 ntohs((s)->scrub.pfss_flags) & PFSS_TIMESTAMP; \ 520 (d)->scrub->pfss_ttl = (s)->scrub.pfss_ttl; \ 521 (d)->scrub->pfss_ts_mod = ntohl((s)->scrub.pfss_ts_mod);\ 522 } \ 523 } while (0) 524 525 #define pf_state_counter_hton(s,d) do { \ 526 d[0] = htonl((s>>32)&0xffffffff); \ 527 d[1] = htonl(s&0xffffffff); \ 528 } while (0) 529 530 #define pf_state_counter_from_pfsync(s) \ 531 (((u_int64_t)(s[0])<<32) | (u_int64_t)(s[1])) 532 533 #define pf_state_counter_ntoh(s,d) do { \ 534 d = ntohl(s[0]); \ 535 d = d<<32; \ 536 d += ntohl(s[1]); \ 537 } while (0) 538 539 TAILQ_HEAD(pf_krulequeue, pf_krule); 540 541 struct pf_kanchor; 542 543 struct pf_kruleset { 544 struct { 545 struct pf_krulequeue queues[2]; 546 struct { 547 struct pf_krulequeue *ptr; 548 struct pf_krule **ptr_array; 549 u_int32_t rcount; 550 u_int32_t ticket; 551 int open; 552 } active, inactive; 553 } rules[PF_RULESET_MAX]; 554 struct pf_kanchor *anchor; 555 u_int32_t tticket; 556 int tables; 557 int topen; 558 }; 559 560 RB_HEAD(pf_kanchor_global, pf_kanchor); 561 RB_HEAD(pf_kanchor_node, pf_kanchor); 562 struct pf_kanchor { 563 RB_ENTRY(pf_kanchor) entry_global; 564 RB_ENTRY(pf_kanchor) entry_node; 565 struct pf_kanchor *parent; 566 struct pf_kanchor_node children; 567 char name[PF_ANCHOR_NAME_SIZE]; 568 char path[MAXPATHLEN]; 569 struct pf_kruleset ruleset; 570 int refcnt; /* anchor rules */ 571 int match; /* XXX: used for pfctl black magic */ 572 }; 573 RB_PROTOTYPE(pf_kanchor_global, pf_kanchor, entry_global, pf_anchor_compare); 574 RB_PROTOTYPE(pf_kanchor_node, pf_kanchor, entry_node, pf_kanchor_compare); 575 576 #define PF_RESERVED_ANCHOR "_pf" 577 578 #define PFR_TFLAG_PERSIST 0x00000001 579 #define PFR_TFLAG_CONST 0x00000002 580 #define PFR_TFLAG_ACTIVE 0x00000004 581 #define PFR_TFLAG_INACTIVE 0x00000008 582 #define PFR_TFLAG_REFERENCED 0x00000010 583 #define PFR_TFLAG_REFDANCHOR 0x00000020 584 #define PFR_TFLAG_COUNTERS 0x00000040 585 /* Adjust masks below when adding flags. */ 586 #define PFR_TFLAG_USRMASK (PFR_TFLAG_PERSIST | \ 587 PFR_TFLAG_CONST | \ 588 PFR_TFLAG_COUNTERS) 589 #define PFR_TFLAG_SETMASK (PFR_TFLAG_ACTIVE | \ 590 PFR_TFLAG_INACTIVE | \ 591 PFR_TFLAG_REFERENCED | \ 592 PFR_TFLAG_REFDANCHOR) 593 #define PFR_TFLAG_ALLMASK (PFR_TFLAG_PERSIST | \ 594 PFR_TFLAG_CONST | \ 595 PFR_TFLAG_ACTIVE | \ 596 PFR_TFLAG_INACTIVE | \ 597 PFR_TFLAG_REFERENCED | \ 598 PFR_TFLAG_REFDANCHOR | \ 599 PFR_TFLAG_COUNTERS) 600 601 struct pf_kanchor_stackframe; 602 603 struct pfr_table { 604 char pfrt_anchor[MAXPATHLEN]; 605 char pfrt_name[PF_TABLE_NAME_SIZE]; 606 u_int32_t pfrt_flags; 607 u_int8_t pfrt_fback; 608 }; 609 610 enum { PFR_FB_NONE, PFR_FB_MATCH, PFR_FB_ADDED, PFR_FB_DELETED, 611 PFR_FB_CHANGED, PFR_FB_CLEARED, PFR_FB_DUPLICATE, 612 PFR_FB_NOTMATCH, PFR_FB_CONFLICT, PFR_FB_NOCOUNT, PFR_FB_MAX }; 613 614 struct pfr_addr { 615 union { 616 struct in_addr _pfra_ip4addr; 617 struct in6_addr _pfra_ip6addr; 618 } pfra_u; 619 u_int8_t pfra_af; 620 u_int8_t pfra_net; 621 u_int8_t pfra_not; 622 u_int8_t pfra_fback; 623 }; 624 #define pfra_ip4addr pfra_u._pfra_ip4addr 625 #define pfra_ip6addr pfra_u._pfra_ip6addr 626 627 enum { PFR_DIR_IN, PFR_DIR_OUT, PFR_DIR_MAX }; 628 enum { PFR_OP_BLOCK, PFR_OP_PASS, PFR_OP_ADDR_MAX, PFR_OP_TABLE_MAX }; 629 enum { PFR_TYPE_PACKETS, PFR_TYPE_BYTES, PFR_TYPE_MAX }; 630 #define PFR_NUM_COUNTERS (PFR_DIR_MAX * PFR_OP_ADDR_MAX * PFR_TYPE_MAX) 631 #define PFR_OP_XPASS PFR_OP_ADDR_MAX 632 633 struct pfr_astats { 634 struct pfr_addr pfras_a; 635 u_int64_t pfras_packets[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; 636 u_int64_t pfras_bytes[PFR_DIR_MAX][PFR_OP_ADDR_MAX]; 637 long pfras_tzero; 638 }; 639 640 enum { PFR_REFCNT_RULE, PFR_REFCNT_ANCHOR, PFR_REFCNT_MAX }; 641 642 struct pfr_tstats { 643 struct pfr_table pfrts_t; 644 u_int64_t pfrts_packets[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; 645 u_int64_t pfrts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; 646 u_int64_t pfrts_match; 647 u_int64_t pfrts_nomatch; 648 long pfrts_tzero; 649 int pfrts_cnt; 650 int pfrts_refcnt[PFR_REFCNT_MAX]; 651 }; 652 653 struct pfr_ktstats { 654 struct pfr_table pfrts_t; 655 counter_u64_t pfrkts_packets[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; 656 counter_u64_t pfrkts_bytes[PFR_DIR_MAX][PFR_OP_TABLE_MAX]; 657 counter_u64_t pfrkts_match; 658 counter_u64_t pfrkts_nomatch; 659 long pfrkts_tzero; 660 int pfrkts_cnt; 661 int pfrkts_refcnt[PFR_REFCNT_MAX]; 662 }; 663 #define pfrts_name pfrts_t.pfrt_name 664 #define pfrts_flags pfrts_t.pfrt_flags 665 666 #ifndef _SOCKADDR_UNION_DEFINED 667 #define _SOCKADDR_UNION_DEFINED 668 union sockaddr_union { 669 struct sockaddr sa; 670 struct sockaddr_in sin; 671 struct sockaddr_in6 sin6; 672 }; 673 #endif /* _SOCKADDR_UNION_DEFINED */ 674 675 struct pfr_kcounters { 676 counter_u64_t pfrkc_counters; 677 long pfrkc_tzero; 678 }; 679 #define pfr_kentry_counter(kc, dir, op, t) \ 680 ((kc)->pfrkc_counters + \ 681 (dir) * PFR_OP_ADDR_MAX * PFR_TYPE_MAX + (op) * PFR_TYPE_MAX + (t)) 682 683 #ifdef _KERNEL 684 SLIST_HEAD(pfr_kentryworkq, pfr_kentry); 685 struct pfr_kentry { 686 struct radix_node pfrke_node[2]; 687 union sockaddr_union pfrke_sa; 688 SLIST_ENTRY(pfr_kentry) pfrke_workq; 689 struct pfr_kcounters pfrke_counters; 690 u_int8_t pfrke_af; 691 u_int8_t pfrke_net; 692 u_int8_t pfrke_not; 693 u_int8_t pfrke_mark; 694 }; 695 696 SLIST_HEAD(pfr_ktableworkq, pfr_ktable); 697 RB_HEAD(pfr_ktablehead, pfr_ktable); 698 struct pfr_ktable { 699 struct pfr_ktstats pfrkt_kts; 700 RB_ENTRY(pfr_ktable) pfrkt_tree; 701 SLIST_ENTRY(pfr_ktable) pfrkt_workq; 702 struct radix_node_head *pfrkt_ip4; 703 struct radix_node_head *pfrkt_ip6; 704 struct pfr_ktable *pfrkt_shadow; 705 struct pfr_ktable *pfrkt_root; 706 struct pf_kruleset *pfrkt_rs; 707 long pfrkt_larg; 708 int pfrkt_nflags; 709 }; 710 #define pfrkt_t pfrkt_kts.pfrts_t 711 #define pfrkt_name pfrkt_t.pfrt_name 712 #define pfrkt_anchor pfrkt_t.pfrt_anchor 713 #define pfrkt_ruleset pfrkt_t.pfrt_ruleset 714 #define pfrkt_flags pfrkt_t.pfrt_flags 715 #define pfrkt_cnt pfrkt_kts.pfrkts_cnt 716 #define pfrkt_refcnt pfrkt_kts.pfrkts_refcnt 717 #define pfrkt_packets pfrkt_kts.pfrkts_packets 718 #define pfrkt_bytes pfrkt_kts.pfrkts_bytes 719 #define pfrkt_match pfrkt_kts.pfrkts_match 720 #define pfrkt_nomatch pfrkt_kts.pfrkts_nomatch 721 #define pfrkt_tzero pfrkt_kts.pfrkts_tzero 722 #endif 723 724 #ifdef _KERNEL 725 struct pfi_kkif { 726 char pfik_name[IFNAMSIZ]; 727 union { 728 RB_ENTRY(pfi_kkif) _pfik_tree; 729 LIST_ENTRY(pfi_kkif) _pfik_list; 730 } _pfik_glue; 731 #define pfik_tree _pfik_glue._pfik_tree 732 #define pfik_list _pfik_glue._pfik_list 733 counter_u64_t pfik_packets[2][2][2]; 734 counter_u64_t pfik_bytes[2][2][2]; 735 u_int32_t pfik_tzero; 736 u_int pfik_flags; 737 struct ifnet *pfik_ifp; 738 struct ifg_group *pfik_group; 739 u_int pfik_rulerefs; 740 TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs; 741 }; 742 #endif 743 744 #define PFI_IFLAG_REFS 0x0001 /* has state references */ 745 #define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */ 746 747 struct pf_pdesc { 748 struct { 749 int done; 750 uid_t uid; 751 gid_t gid; 752 } lookup; 753 u_int64_t tot_len; /* Make Mickey money */ 754 union { 755 struct tcphdr *tcp; 756 struct udphdr *udp; 757 struct icmp *icmp; 758 #ifdef INET6 759 struct icmp6_hdr *icmp6; 760 #endif /* INET6 */ 761 void *any; 762 } hdr; 763 764 struct pf_krule *nat_rule; /* nat/rdr rule applied to packet */ 765 struct pf_addr *src; /* src address */ 766 struct pf_addr *dst; /* dst address */ 767 u_int16_t *sport; 768 u_int16_t *dport; 769 struct pf_mtag *pf_mtag; 770 771 u_int32_t p_len; /* total length of payload */ 772 773 u_int16_t *ip_sum; 774 u_int16_t *proto_sum; 775 u_int16_t flags; /* Let SCRUB trigger behavior in 776 * state code. Easier than tags */ 777 #define PFDESC_TCP_NORM 0x0001 /* TCP shall be statefully scrubbed */ 778 #define PFDESC_IP_REAS 0x0002 /* IP frags would've been reassembled */ 779 sa_family_t af; 780 u_int8_t proto; 781 u_int8_t tos; 782 u_int8_t dir; /* direction */ 783 u_int8_t sidx; /* key index for source */ 784 u_int8_t didx; /* key index for destination */ 785 }; 786 787 /* flags for RDR options */ 788 #define PF_DPORT_RANGE 0x01 /* Dest port uses range */ 789 #define PF_RPORT_RANGE 0x02 /* RDR'ed port uses range */ 790 791 /* UDP state enumeration */ 792 #define PFUDPS_NO_TRAFFIC 0 793 #define PFUDPS_SINGLE 1 794 #define PFUDPS_MULTIPLE 2 795 796 #define PFUDPS_NSTATES 3 /* number of state levels */ 797 798 #define PFUDPS_NAMES { \ 799 "NO_TRAFFIC", \ 800 "SINGLE", \ 801 "MULTIPLE", \ 802 NULL \ 803 } 804 805 /* Other protocol state enumeration */ 806 #define PFOTHERS_NO_TRAFFIC 0 807 #define PFOTHERS_SINGLE 1 808 #define PFOTHERS_MULTIPLE 2 809 810 #define PFOTHERS_NSTATES 3 /* number of state levels */ 811 812 #define PFOTHERS_NAMES { \ 813 "NO_TRAFFIC", \ 814 "SINGLE", \ 815 "MULTIPLE", \ 816 NULL \ 817 } 818 819 #define ACTION_SET(a, x) \ 820 do { \ 821 if ((a) != NULL) \ 822 *(a) = (x); \ 823 } while (0) 824 825 #define REASON_SET(a, x) \ 826 do { \ 827 if ((a) != NULL) \ 828 *(a) = (x); \ 829 if (x < PFRES_MAX) \ 830 counter_u64_add(V_pf_status.counters[x], 1); \ 831 } while (0) 832 833 struct pf_kstatus { 834 counter_u64_t counters[PFRES_MAX]; /* reason for passing/dropping */ 835 counter_u64_t lcounters[LCNT_MAX]; /* limit counters */ 836 counter_u64_t fcounters[FCNT_MAX]; /* state operation counters */ 837 counter_u64_t scounters[SCNT_MAX]; /* src_node operation counters */ 838 uint32_t states; 839 uint32_t src_nodes; 840 uint32_t running; 841 uint32_t since; 842 uint32_t debug; 843 uint32_t hostid; 844 char ifname[IFNAMSIZ]; 845 uint8_t pf_chksum[PF_MD5_DIGEST_LENGTH]; 846 }; 847 848 struct pf_divert { 849 union { 850 struct in_addr ipv4; 851 struct in6_addr ipv6; 852 } addr; 853 u_int16_t port; 854 }; 855 856 #define PFFRAG_FRENT_HIWAT 5000 /* Number of fragment entries */ 857 #define PFR_KENTRY_HIWAT 200000 /* Number of table entries */ 858 859 /* 860 * Limit the length of the fragment queue traversal. Remember 861 * search entry points based on the fragment offset. 862 */ 863 #define PF_FRAG_ENTRY_POINTS 16 864 865 /* 866 * The number of entries in the fragment queue must be limited 867 * to avoid DoS by linear seaching. Instead of a global limit, 868 * use a limit per entry point. For large packets these sum up. 869 */ 870 #define PF_FRAG_ENTRY_LIMIT 64 871 872 /* 873 * ioctl parameter structures 874 */ 875 876 struct pfioc_pooladdr { 877 u_int32_t action; 878 u_int32_t ticket; 879 u_int32_t nr; 880 u_int32_t r_num; 881 u_int8_t r_action; 882 u_int8_t r_last; 883 u_int8_t af; 884 char anchor[MAXPATHLEN]; 885 struct pf_pooladdr addr; 886 }; 887 888 struct pfioc_rule { 889 u_int32_t action; 890 u_int32_t ticket; 891 u_int32_t pool_ticket; 892 u_int32_t nr; 893 char anchor[MAXPATHLEN]; 894 char anchor_call[MAXPATHLEN]; 895 struct pf_rule rule; 896 }; 897 898 struct pfioc_natlook { 899 struct pf_addr saddr; 900 struct pf_addr daddr; 901 struct pf_addr rsaddr; 902 struct pf_addr rdaddr; 903 u_int16_t sport; 904 u_int16_t dport; 905 u_int16_t rsport; 906 u_int16_t rdport; 907 sa_family_t af; 908 u_int8_t proto; 909 u_int8_t direction; 910 }; 911 912 struct pfioc_state { 913 struct pfsync_state state; 914 }; 915 916 struct pfioc_src_node_kill { 917 sa_family_t psnk_af; 918 struct pf_rule_addr psnk_src; 919 struct pf_rule_addr psnk_dst; 920 u_int psnk_killed; 921 }; 922 923 struct pfioc_state_kill { 924 struct pf_state_cmp psk_pfcmp; 925 sa_family_t psk_af; 926 int psk_proto; 927 struct pf_rule_addr psk_src; 928 struct pf_rule_addr psk_dst; 929 char psk_ifname[IFNAMSIZ]; 930 char psk_label[PF_RULE_LABEL_SIZE]; 931 u_int psk_killed; 932 }; 933 934 struct pfioc_states { 935 int ps_len; 936 union { 937 caddr_t psu_buf; 938 struct pfsync_state *psu_states; 939 } ps_u; 940 #define ps_buf ps_u.psu_buf 941 #define ps_states ps_u.psu_states 942 }; 943 944 struct pfioc_src_nodes { 945 int psn_len; 946 union { 947 caddr_t psu_buf; 948 struct pf_src_node *psu_src_nodes; 949 } psn_u; 950 #define psn_buf psn_u.psu_buf 951 #define psn_src_nodes psn_u.psu_src_nodes 952 }; 953 954 struct pfioc_if { 955 char ifname[IFNAMSIZ]; 956 }; 957 958 struct pfioc_tm { 959 int timeout; 960 int seconds; 961 }; 962 963 struct pfioc_limit { 964 int index; 965 unsigned limit; 966 }; 967 968 struct pfioc_altq_v0 { 969 u_int32_t action; 970 u_int32_t ticket; 971 u_int32_t nr; 972 struct pf_altq_v0 altq; 973 }; 974 975 struct pfioc_altq_v1 { 976 u_int32_t action; 977 u_int32_t ticket; 978 u_int32_t nr; 979 /* 980 * Placed here so code that only uses the above parameters can be 981 * written entirely in terms of the v0 or v1 type. 982 */ 983 u_int32_t version; 984 struct pf_altq_v1 altq; 985 }; 986 987 /* 988 * Latest version of struct pfioc_altq_vX. This must move in lock-step with 989 * the latest version of struct pf_altq_vX as it has that struct as a 990 * member. 991 */ 992 #define PFIOC_ALTQ_VERSION PF_ALTQ_VERSION 993 994 struct pfioc_qstats_v0 { 995 u_int32_t ticket; 996 u_int32_t nr; 997 void *buf; 998 int nbytes; 999 u_int8_t scheduler; 1000 }; 1001 1002 struct pfioc_qstats_v1 { 1003 u_int32_t ticket; 1004 u_int32_t nr; 1005 void *buf; 1006 int nbytes; 1007 u_int8_t scheduler; 1008 /* 1009 * Placed here so code that only uses the above parameters can be 1010 * written entirely in terms of the v0 or v1 type. 1011 */ 1012 u_int32_t version; /* Requested version of stats struct */ 1013 }; 1014 1015 /* Latest version of struct pfioc_qstats_vX */ 1016 #define PFIOC_QSTATS_VERSION 1 1017 1018 struct pfioc_ruleset { 1019 u_int32_t nr; 1020 char path[MAXPATHLEN]; 1021 char name[PF_ANCHOR_NAME_SIZE]; 1022 }; 1023 1024 #define PF_RULESET_ALTQ (PF_RULESET_MAX) 1025 #define PF_RULESET_TABLE (PF_RULESET_MAX+1) 1026 struct pfioc_trans { 1027 int size; /* number of elements */ 1028 int esize; /* size of each element in bytes */ 1029 struct pfioc_trans_e { 1030 int rs_num; 1031 char anchor[MAXPATHLEN]; 1032 u_int32_t ticket; 1033 } *array; 1034 }; 1035 1036 #define PFR_FLAG_ATOMIC 0x00000001 /* unused */ 1037 #define PFR_FLAG_DUMMY 0x00000002 1038 #define PFR_FLAG_FEEDBACK 0x00000004 1039 #define PFR_FLAG_CLSTATS 0x00000008 1040 #define PFR_FLAG_ADDRSTOO 0x00000010 1041 #define PFR_FLAG_REPLACE 0x00000020 1042 #define PFR_FLAG_ALLRSETS 0x00000040 1043 #define PFR_FLAG_ALLMASK 0x0000007F 1044 1045 struct pfioc_table { 1046 struct pfr_table pfrio_table; 1047 void *pfrio_buffer; 1048 int pfrio_esize; 1049 int pfrio_size; 1050 int pfrio_size2; 1051 int pfrio_nadd; 1052 int pfrio_ndel; 1053 int pfrio_nchange; 1054 int pfrio_flags; 1055 u_int32_t pfrio_ticket; 1056 }; 1057 #define pfrio_exists pfrio_nadd 1058 #define pfrio_nzero pfrio_nadd 1059 #define pfrio_nmatch pfrio_nadd 1060 #define pfrio_naddr pfrio_size2 1061 #define pfrio_setflag pfrio_size2 1062 #define pfrio_clrflag pfrio_nadd 1063 1064 struct pfioc_iface { 1065 char pfiio_name[IFNAMSIZ]; 1066 void *pfiio_buffer; 1067 int pfiio_esize; 1068 int pfiio_size; 1069 int pfiio_nzero; 1070 int pfiio_flags; 1071 }; 1072 1073 /* 1074 * ioctl operations 1075 */ 1076 1077 #define DIOCSTART _IO ('D', 1) 1078 #define DIOCSTOP _IO ('D', 2) 1079 #define DIOCADDRULE _IOWR('D', 4, struct pfioc_rule) 1080 #define DIOCGETRULES _IOWR('D', 6, struct pfioc_rule) 1081 #define DIOCGETRULE _IOWR('D', 7, struct pfioc_rule) 1082 /* XXX cut 8 - 17 */ 1083 #define DIOCCLRSTATES _IOWR('D', 18, struct pfioc_state_kill) 1084 #define DIOCGETSTATE _IOWR('D', 19, struct pfioc_state) 1085 #define DIOCSETSTATUSIF _IOWR('D', 20, struct pfioc_if) 1086 #define DIOCGETSTATUS _IOWR('D', 21, struct pf_status) 1087 #define DIOCCLRSTATUS _IO ('D', 22) 1088 #define DIOCNATLOOK _IOWR('D', 23, struct pfioc_natlook) 1089 #define DIOCSETDEBUG _IOWR('D', 24, u_int32_t) 1090 #define DIOCGETSTATES _IOWR('D', 25, struct pfioc_states) 1091 #define DIOCCHANGERULE _IOWR('D', 26, struct pfioc_rule) 1092 /* XXX cut 26 - 28 */ 1093 #define DIOCSETTIMEOUT _IOWR('D', 29, struct pfioc_tm) 1094 #define DIOCGETTIMEOUT _IOWR('D', 30, struct pfioc_tm) 1095 #define DIOCADDSTATE _IOWR('D', 37, struct pfioc_state) 1096 #define DIOCCLRRULECTRS _IO ('D', 38) 1097 #define DIOCGETLIMIT _IOWR('D', 39, struct pfioc_limit) 1098 #define DIOCSETLIMIT _IOWR('D', 40, struct pfioc_limit) 1099 #define DIOCKILLSTATES _IOWR('D', 41, struct pfioc_state_kill) 1100 #define DIOCSTARTALTQ _IO ('D', 42) 1101 #define DIOCSTOPALTQ _IO ('D', 43) 1102 #define DIOCADDALTQV0 _IOWR('D', 45, struct pfioc_altq_v0) 1103 #define DIOCADDALTQV1 _IOWR('D', 45, struct pfioc_altq_v1) 1104 #define DIOCGETALTQSV0 _IOWR('D', 47, struct pfioc_altq_v0) 1105 #define DIOCGETALTQSV1 _IOWR('D', 47, struct pfioc_altq_v1) 1106 #define DIOCGETALTQV0 _IOWR('D', 48, struct pfioc_altq_v0) 1107 #define DIOCGETALTQV1 _IOWR('D', 48, struct pfioc_altq_v1) 1108 #define DIOCCHANGEALTQV0 _IOWR('D', 49, struct pfioc_altq_v0) 1109 #define DIOCCHANGEALTQV1 _IOWR('D', 49, struct pfioc_altq_v1) 1110 #define DIOCGETQSTATSV0 _IOWR('D', 50, struct pfioc_qstats_v0) 1111 #define DIOCGETQSTATSV1 _IOWR('D', 50, struct pfioc_qstats_v1) 1112 #define DIOCBEGINADDRS _IOWR('D', 51, struct pfioc_pooladdr) 1113 #define DIOCADDADDR _IOWR('D', 52, struct pfioc_pooladdr) 1114 #define DIOCGETADDRS _IOWR('D', 53, struct pfioc_pooladdr) 1115 #define DIOCGETADDR _IOWR('D', 54, struct pfioc_pooladdr) 1116 #define DIOCCHANGEADDR _IOWR('D', 55, struct pfioc_pooladdr) 1117 /* XXX cut 55 - 57 */ 1118 #define DIOCGETRULESETS _IOWR('D', 58, struct pfioc_ruleset) 1119 #define DIOCGETRULESET _IOWR('D', 59, struct pfioc_ruleset) 1120 #define DIOCRCLRTABLES _IOWR('D', 60, struct pfioc_table) 1121 #define DIOCRADDTABLES _IOWR('D', 61, struct pfioc_table) 1122 #define DIOCRDELTABLES _IOWR('D', 62, struct pfioc_table) 1123 #define DIOCRGETTABLES _IOWR('D', 63, struct pfioc_table) 1124 #define DIOCRGETTSTATS _IOWR('D', 64, struct pfioc_table) 1125 #define DIOCRCLRTSTATS _IOWR('D', 65, struct pfioc_table) 1126 #define DIOCRCLRADDRS _IOWR('D', 66, struct pfioc_table) 1127 #define DIOCRADDADDRS _IOWR('D', 67, struct pfioc_table) 1128 #define DIOCRDELADDRS _IOWR('D', 68, struct pfioc_table) 1129 #define DIOCRSETADDRS _IOWR('D', 69, struct pfioc_table) 1130 #define DIOCRGETADDRS _IOWR('D', 70, struct pfioc_table) 1131 #define DIOCRGETASTATS _IOWR('D', 71, struct pfioc_table) 1132 #define DIOCRCLRASTATS _IOWR('D', 72, struct pfioc_table) 1133 #define DIOCRTSTADDRS _IOWR('D', 73, struct pfioc_table) 1134 #define DIOCRSETTFLAGS _IOWR('D', 74, struct pfioc_table) 1135 #define DIOCRINADEFINE _IOWR('D', 77, struct pfioc_table) 1136 #define DIOCOSFPFLUSH _IO('D', 78) 1137 #define DIOCOSFPADD _IOWR('D', 79, struct pf_osfp_ioctl) 1138 #define DIOCOSFPGET _IOWR('D', 80, struct pf_osfp_ioctl) 1139 #define DIOCXBEGIN _IOWR('D', 81, struct pfioc_trans) 1140 #define DIOCXCOMMIT _IOWR('D', 82, struct pfioc_trans) 1141 #define DIOCXROLLBACK _IOWR('D', 83, struct pfioc_trans) 1142 #define DIOCGETSRCNODES _IOWR('D', 84, struct pfioc_src_nodes) 1143 #define DIOCCLRSRCNODES _IO('D', 85) 1144 #define DIOCSETHOSTID _IOWR('D', 86, u_int32_t) 1145 #define DIOCIGETIFACES _IOWR('D', 87, struct pfioc_iface) 1146 #define DIOCSETIFFLAG _IOWR('D', 89, struct pfioc_iface) 1147 #define DIOCCLRIFFLAG _IOWR('D', 90, struct pfioc_iface) 1148 #define DIOCKILLSRCNODES _IOWR('D', 91, struct pfioc_src_node_kill) 1149 struct pf_ifspeed_v0 { 1150 char ifname[IFNAMSIZ]; 1151 u_int32_t baudrate; 1152 }; 1153 1154 struct pf_ifspeed_v1 { 1155 char ifname[IFNAMSIZ]; 1156 u_int32_t baudrate32; 1157 /* layout identical to struct pf_ifspeed_v0 up to this point */ 1158 u_int64_t baudrate; 1159 }; 1160 1161 /* Latest version of struct pf_ifspeed_vX */ 1162 #define PF_IFSPEED_VERSION 1 1163 1164 #define DIOCGIFSPEEDV0 _IOWR('D', 92, struct pf_ifspeed_v0) 1165 #define DIOCGIFSPEEDV1 _IOWR('D', 92, struct pf_ifspeed_v1) 1166 1167 #endif /* _NET_PFVAR_H_ */ 1168